Harry Potter Posted September 11, 2021 Share Posted September 11, 2021 Hi! I am working on a text adventure for the C64 and eventually port it to the C128, Plus4, Apple2E and Atari8 platforms. In the mean time, I am working on an open-source version with enough to derive other text adventures. Now, I have an optimization technique called the Cubby-Hole technique. This puts code and data in locations used by the BASIC and OS but not needed by the program. I know some things about the .XEX file's makeup. I know that I can load multiple chunks into memory but don't know enough about the format. What's the format? 1 Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted September 11, 2021 Share Posted September 11, 2021 One would hope your assembler or toolset will take care of that for you. E.g. in MADS you have the ORG to determine the load address and then optionally an INI between segments if you want to run some code between block loads (for example to move data to RAM under the OS) and finally a RUN statement to launch the main code. Quote Link to comment Share on other sites More sharing options...
ilmenit Posted September 11, 2021 Share Posted September 11, 2021 it's very simple: https://www.atarimax.com/jindroush.atari.org/afmtexe.html Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 11, 2021 Author Share Posted September 11, 2021 I have cc65. Its default configuration takes care of that for me, but I'm using a special configuration., and, being a general C compiler, cc65 doesn't otherwise handle that for me. I need to set up the config myself. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 11, 2021 Author Share Posted September 11, 2021 ilminit: I thank you for your link. Now, I have another question: how do I define a start address for a specific module or not to run the module? Quote Link to comment Share on other sites More sharing options...
vitoco Posted September 11, 2021 Share Posted September 11, 2021 (edited) Binary files in the A8 computers are composed as a sequence of blocks of data. Each block must be preceded by two words: and a loading address (A) and a terminating address (B), and then (B-A+1) bytes of data. The bytes in words are in Lo-Hi order. The first block must be preceded by the word $FFFF, and any other block may omit it. So, if you want to load arbitrary data in different portions of the memory, just precede each block of data with the corresponding A and B values, and the file itself with $FFFF. On 9/11/2021 at 4:43 PM, Harry Potter said: how do I define a start address for a specific module or not to run the module? There are two special vectors in memory: $02E0 (RUNAD) and $02E2 (INITAD). As soon as you load a value in INITAD, the loader or OS will JSR to the pointed address, and at the end of the load, the OS will JMP to the RUNAD if it was loaded. On 9/11/2021 at 4:38 PM, Harry Potter said: I need to set up the config myself. If you can do perl commands, I wrote a tool to manage XEX files, which it can also create XEX files from binary data files: XEX-Filter Edited September 13, 2021 by vitoco 1 Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted September 11, 2021 Share Posted September 11, 2021 (edited) If you use the xex format of cc65 then it will add the load addresses for you based on the load address of the memory area's segment. Edited September 11, 2021 by Wrathchild Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 11, 2021 Author Share Posted September 11, 2021 Thank you. I have to load a module in $02E2, right? If not, how do I write to it? Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted September 11, 2021 Share Posted September 11, 2021 Again, you shouldn't have to. Lets look at atari-asm-xex.cfg FEATURES { STARTADDRESS: default = $2E00; } SYMBOLS { __STARTADDRESS__: type = export, value = %S; } MEMORY { ZP: file = "", define = yes, start = $0082, size = $007E; MAIN: file = %O, define = yes, start = %S, size = $BC20 - %S; } FILES { %O: format = atari; } FORMATS { atari: runad = start; } SEGMENTS { ZEROPAGE: load = ZP, type = zp, optional = yes; EXTZP: load = ZP, type = zp, optional = yes; # to enable modules to be able to link to C and assembler programs CODE: load = MAIN, type = rw, define = yes; RODATA: load = MAIN, type = ro optional = yes; DATA: load = MAIN, type = rw optional = yes; BSS: load = MAIN, type = bss, optional = yes, define = yes; } The code will be launched at the start address of the file... so the first MEMORY block of the file is MAIN and the start address is the STARTADRESSS, which (if not overridden) is $2E00. Obviously there are 100 and 1 ways to skin a cat and so if this isn't sufficient you'll need to be more specific about what you want to achieve, what you've tried so far etc Quote Link to comment Share on other sites More sharing options...
vitoco Posted September 11, 2021 Share Posted September 11, 2021 5 minutes ago, Harry Potter said: I have to load a module in $02E2, right? Yes if you want to initialize something in the middle of the loading and then continue with the loading of the remaining blocks/modules. But if you want to run your code after all the modules were loaded, you need to add a 2 byte module at $02E0 with the run address, at the end for simplicity. Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted September 11, 2021 Share Posted September 11, 2021 So in your config file you can state a 'module' init address, e.g. FORMATS { atari: runad = start, initad = SYSCHKCHNK: __SYSTEM_CHECK__; } Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 11, 2021 Author Share Posted September 11, 2021 Thank you, again. I am also working on a memory expansion for the Atari XL to load data into the extra RAM (Name?) and allow use of some of the OS's memory that are unused by cc65 programs. It currently works, but I need to add significant functionality to it, i.e. support of extra RAM in printf() and direct printing. I've been working on the Hidden64's (the C64 version of the library) free() function but have problems. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 11, 2021 Author Share Posted September 11, 2021 cc65's docs report a trailer. What's its format? Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted September 11, 2021 Share Posted September 11, 2021 I think that just refers to the run vector, for example you might not use one if you wrote a (more general term) TSR which returns to DOS or a Cart. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 11, 2021 Author Share Posted September 11, 2021 How do I define a trailer? Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted September 11, 2021 Share Posted September 11, 2021 (edited) See the earlier posts, e.g. #11, its the 'runad' i.e. I've loaded everything, now transfer control to it. Edited September 11, 2021 by Wrathchild Quote Link to comment Share on other sites More sharing options...
sanny Posted September 12, 2021 Share Posted September 12, 2021 (edited) See for example https://cc65.github.io/doc/atari.html#ss11.6 and https://cc65.github.io/doc/atari.html#ss4.1 . All load chunks can selectively be turned off, RTFM Edited September 12, 2021 by sanny typo fix Quote Link to comment Share on other sites More sharing options...
ivop Posted September 12, 2021 Share Posted September 12, 2021 20 hours ago, vitoco said: and a loading address (A) and a terminating address (B), and then (B+A+1) bytes of data. B-A+1 1 Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 13, 2021 Author Share Posted September 13, 2021 Should I just exclude the trailer? Quote Link to comment Share on other sites More sharing options...
xxl Posted September 13, 2021 Share Posted September 13, 2021 On 9/11/2021 at 10:19 PM, Harry Potter said: I know that I can load multiple chunks into memory but don't know enough about the format if as a human from C64 you are disturbed by RUN and INIT addresses ($ 2E0- $ 2e3) then they can be configured elsewhere, also blocks can be compressed with LZ4, aPL or ZX0 algorithms. For example, LiteDOS handles LZ4 compressed blocks very well. An advanced user can also create xex in such a way that it can be loaded from a non-linear block order - eg in the case of paragraph games it would apply. chkxex.exe eve.cex 001: $02E0 $02E1: $0002 RUN $0C00 002: $0C00 $2E63: $2264 (LZ4:1352) 003: $0080 $00EC: $006D Len: 5 101 bytes chkxex.exe eve.obx 001: $02E0 $02E1: $0002 RUN $0C00 002: $0C00 $2E63: $2264 003: $0080 $00EC: $006D Len: 8 929 bytes Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted September 13, 2021 Share Posted September 13, 2021 59 minutes ago, Harry Potter said: Should I just exclude the trailer? On 9/11/2021 at 10:07 PM, Wrathchild said: you'll need to be more specific about what you want to achieve Presumably you want to launch the program when its loaded and so this would be left as-is? If needs be just make a dummy binary using the segments in your config file and try and load it into Altirra with the debugger enabled and this will output the segments loaded and entry addresses ran. If that doesn't match your expectation then you can post that up and we can take a look Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 14, 2021 Author Share Posted September 14, 2021 Attached is one config file for my memory enhancement library. I don't have the actual code ready for use as I don't yet know how to fill the trailers. atarixl_small.cfg Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted September 14, 2021 Share Posted September 14, 2021 You seem to be over thinking things, e.g. the 'TRAILER' memory area of 6 bytes will be populated through its associated SEGMENT with something like: .import __CODE_RUN__ .segment "AUTOSTRT" .word $2E0 .word $2E2 .word __CODE_RUN__ Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted September 14, 2021 Author Share Posted September 14, 2021 Thank you. Just what I needed. 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.