Add include function
Hi,
Can there be an include option in Fast basic for assets like pictures, soundfiles just an option to load them at a specific address so they are emmbed inside the compiled code
To include binary data in your program, you can use the DATA statement. For more details, see the BYTEFILE and WORDFILE commands in the "Loading data from a file" section of the FastBasic manual, at https://github.com/dmsc/fastbasic/blob/master/manual.md#general-statements . Once the data is loaded, you can use the MOVE statement to transfer it to the correct memory address at runtime. This method is straightforward, but it has a drawback: your data will use up RAM twice.
Another option is to load your data at runtime using the BGET command. While this means your program will be distributed as multiple files, it's the best approach during development on an Atari. You won't need to modify your program or data files between each run, which streamlines the development process.
If you need to add data that loads at a specific address directly into your program, you'll need to use external tools. This is a task that goes beyond the capabilities of the FastBasic IDE and compiler.
For a simpler approach, you can concatenate two binary-load files: first your data file, and then your compiled FastBasic program. The Atari binary load format supports this, and it will load both files into their specified memory addresses.
For even more advanced usage, you can create a custom linker file. This allows you to adjust the load addresses of different program sections. For example, you could create a FastBasic executable that loads at lower memory addresses, giving you more available space for other purposes.
ok clear, just one other question is there away to use a file,bas and for example an external file containing code like functions so that I dont have to all in one single file. Just like in other languages .h or ,inc files.
The "include" feature can be done via pre-processing. This is kind of trivial with cat on Linux. For example, I have three files and want to compile a single .xex, so this works. I understand the same can be accomplished with a .bat script on Windows:
`#!/bin/bash
# build.sh - merge FastBasic source files and compile
mktemp /tmp/magical.bas
# Concatenate in the proper order
cat init.bas familiar.bas main.bas > /tmp/magical.bas
# Compile with FastBasic
fastbasic /tmp/magical.bas
cp /tmp/magical.xex ./magical.xex
# Remove temporary file
rm "/tmp/magical.bas"`