XA for beginner: multipart TAP files?

Here you can ask questions or provide insights about how to use efficiently 6502 assembly code on the Oric.
User avatar
Symoon
Archivist
Posts: 2307
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

XA for beginner: multipart TAP files?

Post by Symoon »

Hi,
I'm planning to have a program loaded from tape, divided it two parts:
Part 1- HIRES loading screen + some data tables (hidden inside the HIRES screen)
Part 2- main program
Of course this would be loaded by a small basic loader, but let's leave this one out of the problem.

So my queston is:
- if I do this with two different .S files in XA, how do I do to be able to use the tables from part 1 into the code of part 2 (I suspect something like include or alike), and without having XA including these tables in the final part 2 TAP file?
- alternatively, would it be possible to have two TAP files generated from a single .S file?
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: XA for beginner: multipart TAP files?

Post by Dbug »

The key here is do define your memory layout appropriately.

What has been loaded, stays in memory, and can be reused in the second part.

You can technically use a single .S file and conditional assembly, like pass on the XA command line a value using -DNAME=VALUE and then check in the code if this value exists or have a specific value and depending of that assemble or not some code.

The simplest would be to have two separate files, which can share some common definition file containing things like size and locations of tables.

Then you can either use the bss section or symbol definitions to tell the assembler that "at this address there I've the beginning of an array" without actually having that data be part of the binary file.

If you look in OSDK\sample\floppybuilder\code you can see the following:

Code: Select all

//
// FloppyBuilder/Loader system
// Compatible with both C and Assembler modules
//
#include "floppy_description.h"

#ifdef ASSEMBLER    // 6502 Assembler API
#define LoadFileAt(fileIndex,address)          lda #fileIndex:sta _LoaderApiEntryIndex:lda #<address:sta _LoaderApiAddressLow:lda #>address:sta _LoaderApiAddressHigh:jsr _LoadApiLoadFileFromDirectory
#define InitializeFileAt(fileIndex,address)    lda #fileIndex:sta _LoaderApiEntryIndex:lda #<address:sta _LoaderApiAddressLow:lda #>address:sta _LoaderApiAddressHigh:jsr _LoadApiInitializeFileFromDirectory

#else               // C Compiler API
extern unsigned char LoaderApiEntryIndex;
extern unsigned char LoaderApiAddressLow;
extern unsigned char LoaderApiAddressHigh;
extern void* LoaderApiAddress;

#define LoadFileAt(fileIndex,address)          LoaderApiEntryIndex=fileIndex;LoaderApiAddress=(void*)address;LoadApiLoadFileFromDirectory();
#define InitializeFileAt(fileIndex,address)    LoaderApiEntryIndex=fileIndex;LoaderApiAddress=(void*)address;LoadApiInitializeFileFromDirectory();

#endif
The "ASSEMBLER" thing is passed on the command line of XA when it's assembling an assembler module, so that uses the top bloc of code, the bottom one is used when the ASSEMBLER symbol is not defined.

And that's called using this

Code: Select all

%osdk%\bin\xa -DASSEMBLER=XA source_file.s -o generated_binary_file.o
For the tables you can do something as simple as that:

Code: Select all

HiresScreen = $A000
MyMagicTable = $BCDE
User avatar
Symoon
Archivist
Posts: 2307
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

Re: XA for beginner: multipart TAP files?

Post by Symoon »

Thanks, so far I was lazy and using the default OSDK settings, but I think I won't escape learning a bit deeper ;)
Will try!
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: XA for beginner: multipart TAP files?

Post by Dbug »

You can use the OSDK standard to do that, like you can define OSDKXAPARAMS to pass additional parameters, so in your case you could use something like OSDKXAPARAMS=-DGAMEINTRO for the first part and OSDKXAPARAMS=-DACTUALGAME for the second part and use something like

Code: Select all

#ifdef GAMEINTRO
#endif

#ifdef ACTUALGAME
#endif
or you can -DPART=1 and -DPART=2 and use #if instead of #ifdef

Code: Select all

#if PART=1
#endif

#if PART=2
#endif
Post Reply