Another advantage of XTRICATOR is the program based on it doesn't take any space for the display. The 6K HFILE display file is generated at runtime, so it doesn't take space on the tape. This results in faster loading than other pseudo-HRG programs
For example, Z-Xtricator is only 7K on tape. But the corporate splash screen (side 2 of the cassette) is 9K and all it does is display a static picture! James talks about this:
escher wrote: ↑Mon Sep 30, 2024 7:56 amthe only "improvements" [Software Farm] asked for was adding a screen to choose which keys are used for controls (good) and adding in a huge loading screen with the cosmic cockerel (bad). This later demand was ridiculous since it took twice as long to load the screen as the actual game, and I had to use their old hi-res routine since my routine didn't enable the cockerel to be displayed the same way - so after several minutes loading that screen, once you press a key the 6K display file and old hi-res routine are dumped and the game switches over to Z-Xtricator and the more economical IM2 routine.
SETUP
=====
It's easy to set up. The XTRICATOR routine is self-contained in REM 1. Then your game:
Code: Select all
CALL $40B8 ;BUILD_HFILE in XTRICATOR routine
CALL $40AA ;ENABLE_IM2 in XTRICATOR routine
DRAWING
========
Next to draw something on the screen. Demo has a subroutine to set up a basic playfield:
To draw a single character on the HFILE, demo has a routine called H-draw_Character:
HdrwCHR puts '5' in HFILE for each of the 8 scanlines at the position give in HL
Strings of characters are done in a similar way (copy each string to HFILE 8 times)
HFILE Screen Locations
====================
All you need to know is what Row and Column you want. Then let the assembler figure out the exact address
If you want to put a standard character on the screen, use this in your code
Code: Select all
LD HL,HFILE+3+22*HLINE+2 ;Row 22 Column 2
LD A,$21 ;'5' _5
call HdrwCHR
UDG
====
To draw pseudo-UDG characters instead of standard characters is just a matter of changing the CHR on each scanline. The ship is a 3-byte-wide sprite:

- spriteSHIP.png (11.18 KiB) Viewed 8447 times
Code: Select all
;bit-patterns bytes
;00000000 00000000 00000000 00 00 00 ' ' 0 scan line
;00000000 00000000 00000000 00 00 00 ' ' 1
;00001111 11110000 00000000 0F F0 00 ' ±±±±±±±± ' 2
;01111100 00011000 00000000 7A 0A 00 ' ±±±±± ±± ' 3
;11111111 11111111 11110000 FF FF F0 '±±±±±±±±±±±±±±±±±±±± ' 4
;11111111 11111111 11110000 FF FF F0 '±±±±±±±±±±±±±±±±±±±± ' 5
;11111111 11111111 00000000 FF FF 00 '±±±±±±±±±±±±±±±± ' 6
;00001111 11111111 00000000 0F FF 00 ' ±±±±±±±±±±±± ' 7
Search for those bit patterns in CHR table in the ROM starting at $1E00 (not all bit patterns are in the standard character set ... but these are)
Those bytes belong to these CHR
Code: Select all
db $00,$00,$00
db $00,$00,$00
db $02,$01,$00
db $2A,$3D,$00
db $80,$80,$04
db $80,$80,$04
db $80,$80,$00
db $87,$80,$00
FASM_Z80.zip (ZX81rom.asm) has the ROM disassembly in searchable form (thanks PokeMon!). Then you can search for the bit pattern. If it is found, you can use that CHR
Code: Select all
; ------------------------
; THE 'ZX81 CHARACTER SET'
; ------------------------
...
L1E00:
...
; $01 - Character: mosaic CHR$(1)
DEFB %11110000
DEFB %11110000
DEFB %11110000
DEFB %11110000
DEFB %00000000
DEFB %00000000
DEFB %00000000
DEFB %00000000
For the bit-pattern 11110000, it is found in several characters including 01 and 04. Note that it is used in the display (standard display or HRG) on a scanline basis, so the sprites can use different CHR mix-and-match