Z80 Assembly programming for the Camputers Lynx
Documentation Unfortunately, there is very little documetation on the Camputers Lynx... fortunately the' Lynx User' newsletter covered everything pretty clearly... you can get it here:LynxUser on Github The Mysteries of the LynxAddress bus! The Lynx does not use all the bits of the address bus for accessing memory... I guess they figured that as the machine had only 16k, that using all the 'bits' of the memory address were excessive... two bits are unused... and that means certain areas are 'Mirrored'... so the same bank appears in multiple places! Lets take a look at which of the 16 bits are ignored! ... in the chart below, bits marked X are ignored, and bits marked 1 work normally.
What's the effect of this? well, because on the 48k lynx 32k is VRAM... this just leaves 2x 8k banks of ram... and each of these 2 banks appear in 4 different positions!
The extra 4 Video Ram banks are 8k each... One for Red, Green and Blue... and an 'alternate green' which can be paged in There is also 24k rom which can be paged in... these appear 'Above' the ram mentioned previously... and these do not apply to the rom banking Lets take a look at the bank switching options
BankSwitching The bits of the byte written to port &FFFF will control which banks are accessed ... the combination of the bits selected will define the resultant memory accessed by the Z80
VRAM Access The Video Ram is accessible via the Z80 addressable range, but we nee to page in the correct bank AND set the right video option... This is done with Port &0080
To write to the banks, we need to enable CPU access... and Lock the bank we DONT want to write to. If we do not wait for redraw (with bit 6) then screen distortion will occur (black pixels) as we cannot write to VRAM while the CRTC beam is drawing the screen. Note... you cannot Read and Write to a bank at the same time... so you can't copy one area of the screen to another to soft-scroll! Also it is virtually impossible to READ VRAM from code not in ROM... this is because the Lynx's limited address bus means it can only address 16k, and when READ is set to the VRAM the normal ram disappears!... this means the running code would have to be in VRAM (thus visible) which in most cases is not practical. See the table below for the correct settings depending what you want to do
To speed things up if we just want to do black and white, We can take advantage of the Lynx write banking to write to both Blue+AltGreen, or Red+Green at the same time .... note it is not possible to write to Red+Green+Blue at the same time
Screen corruption due to shared Vram Note: Because of the limited address bus, writing to the areas B or A in &8000-&9F80 or &6000-&7F80 will affect the matching screen ram... meaning random pixels may light up! Even worse, it seems these writes do not affect the internal ram even if bit 0 of &FFFF is set... meaning the write is 'consumed' by the screen Because the stack is at &8FFF, it seems to be outside the visible screen on the PALE emulator... but inside the visible screen on JYNX !?! Therefore, ideally, we should avoid using the stack too! Simple Memory Map The bankswitching options can make things tricky... but here is a 'simple' memory map of what you can expect to see on a 48k Lynx
Lynx TAP file format As the LYNX has no cartridges, our best way of getting data from our assembler to the Lynx is to make a TAP file... Creating a valid TAP file requires some byte calculations, but is not too hard... here is the format of the TAP file
Lynx Keymap The keyboard responds to all ports with a bitmask of %****XXXX 10***00* ... where XXXX is one of the ports below
Lynx Sound The Lynx uses 'Beeper sound' almost identical to the ZX Spectrum - however unlike the spectrum beeper, the Camputers Lynx has the ability to set volume level. Sound is controlled on the lynx by port &0084 - or any port that matches the bitmask %********10***10*
|
Buy my Assembly programming book on Amazon in Print or Kindle! Available worldwide! Search 'ChibiAkumas' on your local Amazon website! Click here for more info! Buy my Assembly programming book on Amazon in Print or Kindle! Available worldwide! Search 'ChibiAkumas' on your local Amazon website! Click here for more info! |