+Karl G Posted January 19 Share Posted January 19 For 7800basic projects that use extra RAM and have a lot of variables to manage, does anyone have any tips on how to make the process easier to manage/maintain? As things stand now, I might have something like this: dim Var1 = $4000 dim Var2 = $4001 ; 8 bytes dim Var3 = $4009 ; Etc. In assembly this would be something like: ORG $4000 Var1 ds 1 Var2 ds 8 Var3 ds 1 ; Etc. In the latter case, if I wanted to change the number of bytes of Var2, or if I had a reason to change the order of where they are stored in memory, I wouldn't have to recompute the addresses. Does anyone have a good way of handling this? I don't mind using inline assembly, but I can't just throw in an "ORG $4000" in the middle of 7800basic source without crashing my program. Quote Link to comment Share on other sites More sharing options...
+SmittyB Posted January 19 Share Posted January 19 My first thought would be to use a spreadsheet with the name in one column, length in the next column, a third column to calculate the address based on the address and length of the previous record, and then the 4th column would be the text output ready to be copied over to your project as necessary. 2 Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted January 19 Share Posted January 19 This sounds more like 7800Basic needs to be updated to support allocating variables in extended RAM. That would make the most sense to do. I'm not sure how difficult that would be... depends on whether variable allocation is currently tracked by the compiler or not. Quote Link to comment Share on other sites More sharing options...
+Karl G Posted January 19 Author Share Posted January 19 2 minutes ago, splendidnut said: This sounds more like 7800Basic needs to be updated to support allocating variables in extended RAM. That would make the most sense to do. I'm not sure how difficult that would be... depends on whether variable allocation is currently tracked by the compiler or not. It can allocate variables in extended RAM now. One can use dim to assign a variable to any address. I'm just looking for a better way to define the variables in a way so they will auto-increment the address based on storage size like I can do in assembly. Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted January 19 Share Posted January 19 Ah, so you need dimension-ed array support. 1 Quote Link to comment Share on other sites More sharing options...
+Karl G Posted January 19 Author Share Posted January 19 I could always roll something myself to include generated by a simple preprocessor script, but I wanted to see if anyone had any clever solutions for this that they use themselves. Quote Link to comment Share on other sites More sharing options...
+splendidnut Posted January 19 Share Posted January 19 Yeah, it would be cool to see a clever solution... But, if you're willing, you might want to look and see how hard this would be to implement in the compiler. Implementing it there would be a win for everyone. Quote Link to comment Share on other sites More sharing options...
+Karl G Posted January 20 Author Share Posted January 20 20 hours ago, splendidnut said: Yeah, it would be cool to see a clever solution... But, if you're willing, you might want to look and see how hard this would be to implement in the compiler. Implementing it there would be a win for everyone. I'd be happy to contribute if desired, though since it's a language direction issue, it would be up to Mike as to if or how such a feature would be added. In the meantime I made a quick and dirty script that I will share here in case anyone else would find it useful. Quote Link to comment Share on other sites More sharing options...
+Karl G Posted January 20 Author Share Posted January 20 I've made a small Python script to generate variable symbols with the appropriate addresses, which I am sharing here. It supports an optional storage size parameter (1 byte if not specified), and an optional repeat number, which will generate the specified number of symbols of the specified storage size with that name, followed by a numeric suffix. The script looks for a file named vars.src in the current directory. The first line of the file is the base starting address (e.g. $2200 or $4000, but also could be a name defined in BASIC code). All lines after that are variables to be defined, with optional parameters for the storage size in bytes, and number of iterations for repeating variables. Running the script will produce the file vars.asm with the specified variables defined at the correct addresses. Additionally, the symbols BASE_ADDRESS and NEXT_VAR are added to the output, corresponding to the starting address supplied in the source file, and the next free address after all variables have been defined, respectively. The generated vars.asm can be included in the 7800basic project with an inline statement. genvars.py Here's an example vars.src file: $4000 CharName 8 16 Race 1 16 Class 1 16 Traits 1 16 Defects 1 16 STR 1 16 DEX 1 16 CON 1 16 INT 1 16 WIS 1 16 CHA 1 16 Luck 1 16 Items 10 16 Gold 2 CurrentMap CurrentX CurrentY This produces the following output in vars.asm: BASE_ADDRESS = $4000 CharName0 = $4000 + 0 CharName1 = $4000 + 8 CharName2 = $4000 + 16 CharName3 = $4000 + 24 CharName4 = $4000 + 32 CharName5 = $4000 + 40 CharName6 = $4000 + 48 CharName7 = $4000 + 56 CharName8 = $4000 + 64 CharName9 = $4000 + 72 CharName10 = $4000 + 80 CharName11 = $4000 + 88 CharName12 = $4000 + 96 CharName13 = $4000 + 104 CharName14 = $4000 + 112 CharName15 = $4000 + 120 Race0 = $4000 + 128 Race1 = $4000 + 129 Race2 = $4000 + 130 Race3 = $4000 + 131 Race4 = $4000 + 132 Race5 = $4000 + 133 Race6 = $4000 + 134 Race7 = $4000 + 135 Race8 = $4000 + 136 Race9 = $4000 + 137 Race10 = $4000 + 138 Race11 = $4000 + 139 Race12 = $4000 + 140 Race13 = $4000 + 141 Race14 = $4000 + 142 Race15 = $4000 + 143 Class0 = $4000 + 144 Class1 = $4000 + 145 Class2 = $4000 + 146 Class3 = $4000 + 147 Class4 = $4000 + 148 Class5 = $4000 + 149 Class6 = $4000 + 150 Class7 = $4000 + 151 Class8 = $4000 + 152 Class9 = $4000 + 153 Class10 = $4000 + 154 Class11 = $4000 + 155 Class12 = $4000 + 156 Class13 = $4000 + 157 Class14 = $4000 + 158 Class15 = $4000 + 159 Traits0 = $4000 + 160 Traits1 = $4000 + 161 Traits2 = $4000 + 162 Traits3 = $4000 + 163 Traits4 = $4000 + 164 Traits5 = $4000 + 165 Traits6 = $4000 + 166 Traits7 = $4000 + 167 Traits8 = $4000 + 168 Traits9 = $4000 + 169 Traits10 = $4000 + 170 Traits11 = $4000 + 171 Traits12 = $4000 + 172 Traits13 = $4000 + 173 Traits14 = $4000 + 174 Traits15 = $4000 + 175 Defects0 = $4000 + 176 Defects1 = $4000 + 177 Defects2 = $4000 + 178 Defects3 = $4000 + 179 Defects4 = $4000 + 180 Defects5 = $4000 + 181 Defects6 = $4000 + 182 Defects7 = $4000 + 183 Defects8 = $4000 + 184 Defects9 = $4000 + 185 Defects10 = $4000 + 186 Defects11 = $4000 + 187 Defects12 = $4000 + 188 Defects13 = $4000 + 189 Defects14 = $4000 + 190 Defects15 = $4000 + 191 STR0 = $4000 + 192 STR1 = $4000 + 193 STR2 = $4000 + 194 STR3 = $4000 + 195 STR4 = $4000 + 196 STR5 = $4000 + 197 STR6 = $4000 + 198 STR7 = $4000 + 199 STR8 = $4000 + 200 STR9 = $4000 + 201 STR10 = $4000 + 202 STR11 = $4000 + 203 STR12 = $4000 + 204 STR13 = $4000 + 205 STR14 = $4000 + 206 STR15 = $4000 + 207 DEX0 = $4000 + 208 DEX1 = $4000 + 209 DEX2 = $4000 + 210 DEX3 = $4000 + 211 DEX4 = $4000 + 212 DEX5 = $4000 + 213 DEX6 = $4000 + 214 DEX7 = $4000 + 215 DEX8 = $4000 + 216 DEX9 = $4000 + 217 DEX10 = $4000 + 218 DEX11 = $4000 + 219 DEX12 = $4000 + 220 DEX13 = $4000 + 221 DEX14 = $4000 + 222 DEX15 = $4000 + 223 CON0 = $4000 + 224 CON1 = $4000 + 225 CON2 = $4000 + 226 CON3 = $4000 + 227 CON4 = $4000 + 228 CON5 = $4000 + 229 CON6 = $4000 + 230 CON7 = $4000 + 231 CON8 = $4000 + 232 CON9 = $4000 + 233 CON10 = $4000 + 234 CON11 = $4000 + 235 CON12 = $4000 + 236 CON13 = $4000 + 237 CON14 = $4000 + 238 CON15 = $4000 + 239 INT0 = $4000 + 240 INT1 = $4000 + 241 INT2 = $4000 + 242 INT3 = $4000 + 243 INT4 = $4000 + 244 INT5 = $4000 + 245 INT6 = $4000 + 246 INT7 = $4000 + 247 INT8 = $4000 + 248 INT9 = $4000 + 249 INT10 = $4000 + 250 INT11 = $4000 + 251 INT12 = $4000 + 252 INT13 = $4000 + 253 INT14 = $4000 + 254 INT15 = $4000 + 255 WIS0 = $4000 + 256 WIS1 = $4000 + 257 WIS2 = $4000 + 258 WIS3 = $4000 + 259 WIS4 = $4000 + 260 WIS5 = $4000 + 261 WIS6 = $4000 + 262 WIS7 = $4000 + 263 WIS8 = $4000 + 264 WIS9 = $4000 + 265 WIS10 = $4000 + 266 WIS11 = $4000 + 267 WIS12 = $4000 + 268 WIS13 = $4000 + 269 WIS14 = $4000 + 270 WIS15 = $4000 + 271 CHA0 = $4000 + 272 CHA1 = $4000 + 273 CHA2 = $4000 + 274 CHA3 = $4000 + 275 CHA4 = $4000 + 276 CHA5 = $4000 + 277 CHA6 = $4000 + 278 CHA7 = $4000 + 279 CHA8 = $4000 + 280 CHA9 = $4000 + 281 CHA10 = $4000 + 282 CHA11 = $4000 + 283 CHA12 = $4000 + 284 CHA13 = $4000 + 285 CHA14 = $4000 + 286 CHA15 = $4000 + 287 Luck0 = $4000 + 288 Luck1 = $4000 + 289 Luck2 = $4000 + 290 Luck3 = $4000 + 291 Luck4 = $4000 + 292 Luck5 = $4000 + 293 Luck6 = $4000 + 294 Luck7 = $4000 + 295 Luck8 = $4000 + 296 Luck9 = $4000 + 297 Luck10 = $4000 + 298 Luck11 = $4000 + 299 Luck12 = $4000 + 300 Luck13 = $4000 + 301 Luck14 = $4000 + 302 Luck15 = $4000 + 303 Items0 = $4000 + 304 Items1 = $4000 + 314 Items2 = $4000 + 324 Items3 = $4000 + 334 Items4 = $4000 + 344 Items5 = $4000 + 354 Items6 = $4000 + 364 Items7 = $4000 + 374 Items8 = $4000 + 384 Items9 = $4000 + 394 Items10 = $4000 + 404 Items11 = $4000 + 414 Items12 = $4000 + 424 Items13 = $4000 + 434 Items14 = $4000 + 444 Items15 = $4000 + 454 Gold = $4000 + 464 CurrentMap = $4000 + 466 CurrentX = $4000 + 467 CurrentY = $4000 + 468 NEXT_VAR = $4000 + 469 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.