aboutsummaryrefslogtreecommitdiff
path: root/xex.rst
diff options
context:
space:
mode:
Diffstat (limited to 'xex.rst')
-rw-r--r--xex.rst110
1 files changed, 110 insertions, 0 deletions
diff --git a/xex.rst b/xex.rst
index 8f77f6e..39d32d9 100644
--- a/xex.rst
+++ b/xex.rst
@@ -80,9 +80,119 @@ exit.
The run address segment is the one that loads the 2-byte run address
into address **$02E0**, aka **RUNAD**.
+Raw Data Blocks
+---------------
+
+When init code runs, the file is still being loaded. It's open on IOCB
+#1, and the init code can read some or all of the rest of the file
+itself, before returning to DOS. The part of the file read by an init
+segment doesn't have to conform to the regular XEX file structure, so
+they're referred to here as raw data blocks.
+
+Raw data blocks usually occur in files created with "packer" or
+"compressor" programs, or occasionally in other large programs (Turbo
+BASIC is an example). Raw data blocks are generally found just after
+an init address segment. If you have an executable that loads just
+fine on a real Atari or emulator, but fails with **xexcat** and
+**xexamine**, a raw data block is usually the reason why.
+
+Files with raw data blocks also can't be loaded by simple bootloaders
+such as Fenders 3-sector loader.
+
EXAMPLES
========
+Assembly
+---------
+
+Here is a simple assembly language program that changes the background
+of the GRAPHICS 0 text screen to black, and the text to high-intensity white::
+
+ 1000 *= $0600
+ 1010 START
+ 1020 LDA #0
+ 1030 STA 710
+ 1040 LDA #$0F
+ 1050 STA 709
+ 1060 RTS
+ 2000 *= $02E0 ; AKA RUNAD
+ 2010 .WORD START
+
+To assemble this with either Atari's Assembler/Editor or OSS Mac/65,
+the command is::
+
+ ASM ,,#D:COLORS.XEX
+
+This will create a binary file that looks like this::
+
+ offset 0: FF FF 00 06 0A 06 A9 00
+ offset 8: 8D C6 02 A9 0F 8D C5 02
+ offset 16: 60 E0 02 E1 02 00 06
+
+This is a complete (though short) XEX file, and it can be loaded from
+the DOS menu (or D1: prompt, if you use a command-line-based DOS).
+
+The first 2 bytes ($FF, $FF) are the signature for the initial
+segment header.
+
+The next 2 bytes ($00, $06) are the load address of the first segment
+($0600, in 6502-style LSB-first notation).
+
+The next 2 bytes ($0A, $06) are the end address ($060A).
+
+Since the header says to load data from $0600 to $060A, there are 11
+data bytes in the segment, beginning with $A9, $00 (the 6502 object
+code for the *LDA #0* instruction), and extending to the $60 (RTS
+opcode) at offset 16.
+
+The data from the first segment is immediately followed by the header
+of the next segment, at offset 17. A $FF, $FF signature would be allowed
+here, but in the example, the 2nd segment uses the 4-byte header.
+
+At offset 17, the $E0, $02 (aka $02E0) is the load address. $E1, $02
+($02E1) is the end address. $02E0/$02E1 is known as *RUNAD* in the
+Atari world, and it's the address where DOS will find the entry point
+to the program when it's done being loaded.
+
+The next (and last) 2 bytes are $00, $06 (aka $0600), which is the run
+address itself (to be deposited at *RUNAD*).
+
+There are no more segments, since we've reached end of file.
+
+Data Only
+---------
+
+Since a XEX file can load arbitrary data at arbitrary addresses, there's
+simpler way to accomplish the color changes. Instead of writing code to
+do the job, we just create a XEX file that loads the colors we want
+directly into the color shadow registers.
+
+In BASIC, you'd say::
+
+ POKE 709,15
+ POKE 710,0
+
+...but BASIC doesn't have an easy way to create a XEX file.
+An assembler is a more convenient tool. The code is::
+
+ 1000 *= $02C5
+ 1010 .BYTE $0F,$00
+
+The binary looks like this::
+
+ ff ff C5 02 C6 02 0F 00
+
+The file begins with $FF, $FF header, then the 2-byte load address
+($C5, $02 for address $02C5), then the 2-byte end address ($C6, $02,
+aka $02C6), then the 2 bytes of data to be stored there ($0F, $00).
+
+When loaded, this will store $0F at address $02C5 (aka *COLOR0*,
+the text luminance in *GRAPHICS 0*) and $00 at $02C6 (*COLOR1*, the
+*GRAPHICS 0* background color).
+
+Notice that there's no run or init address. That's because no code is
+executed; it's just 2 bytes of raw data.
+
HISTORY
=======