Lightning Driver Coding Examples

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
Post Reply
computergui
Posts: 21
Joined: Tue Mar 09, 2021 10:56 pm

Lightning Driver Coding Examples

Post by computergui »

Looking to use the Lightning driver for a new project. Wondering if anyone has any examples they could share on using this driver?

I appreciate the driver ASM file has a ton of documentation. Looking to shorten up my learning curve!

D
Timex Sinclair 1000 with ZXPand
Timex Sinclair 1500 - 4
Timex Sinclair 2068 -2
ZX Spectrum 48K - 12ish...
ZX Spectrum Plus
ZX Spectrum 128K
ZX Spectrum Plus 2
ZX Spectrum Plus 3
Sinclair QL
ZX Spectrum Next KS 2 (when it lands!)
ZX 48K Spider
ZX Max 128
User avatar
marste
Posts: 250
Joined: Sun Aug 10, 2014 9:58 pm
Location: Italy
Contact:

Re: Lightning Driver Coding Examples

Post by marste »

Far from being a hires expert, but curious of this driver I had a look at the LightningDriver.asm, and the source is wonderfully documented and is not long at all to be read. Moreover itself is a demo, and the part that is writing the screen (simply cleaning it in this case) is:

Code: Select all

CLEAR_HIRES_DFILE:
        LD   HL,HR_DFILE
        LD   C,DISPLAY_LINES
        LD   DE,HDO_NEXT_LINE
        LD   A,$1E                              ; Use the Sinclair I register value for the line.
        JR   CDF_ROW                            ; Jump ahead to fill the first line.

CDF_ROW_JP:
        LD   (HL),Z80_JP                        ; Insert the end of line terminator routine.
        INC  HL
        SET  7,H
        LD   (HL),E
        INC  HL
        LD   (HL),D
        RES  7,H
        INC  HL

CDF_ROW:
        CALL FILL_LINE                          ; Fill all column positions of the line.

        DEC  C
        JR   NZ,CDF_ROW_JP                      ; Repeat for all display lines.

        LD   (HL),Z80_RET                       ; Insert the terminator routine for the final line.
        RET

; ----------------------
; Fill Display File Line
; ----------------------
; Entry: HL=Address of the display file line.
;        A=Value of the I register value for this line.

FILL_LINE:
        SET  7,H
        LD   (HL),A                             ; Insert the I register value.
        RES  7,H
        INC  HL

        LD   B,DISPLAY_COLUMNS

CDF_COL:
        LD   (HL),_BLACK                        ; Fill a column position.
        INC  HL
        DJNZ CDF_COL                            ; Repeat for all columns.

        RET
Now you can change this piece of code to write whatever you want on the screen, all based on the structure of each line that is (the number is the offset of the value in the line):

Code: Select all

; 0       I register value to use for the line.
; 1-32    Character codes for the 32 display columns.
; 33-35   End of line terminator bytes (JP HDO_NEXT_LINE, or RET for the final line).
If you will be more specific on your doubts maybe I (if I'll be able) or some expert might try to answer.

This of course is regarding the display driver. A different type of beast is managing sprites, scrolling, game logic, etc...
Fruitcake
Posts: 346
Joined: Wed Sep 01, 2010 10:53 pm

Re: Lightning Driver Coding Examples

Post by Fruitcake »

I've released an update to my pseudo hi-res Lightning Display Driver (the mechanism behind my demonstration program Celebration). The source code now contains a pre-populated display file to better show the use of the 3 output modes (previously it just demonstrated a black screen). The source code and pre-built program files are available for download.

The main changes are:
  • Additional output routines to avoid having to specify the I register value per line, thereby reducing the size of the display file. An I register value per line can still be specified if required.
  • Improved picture alignment.
  • Contains a pre-populated display file demonstrating the intermixing of the 3 output modes.
  • Demonstrates how Chroma colour can be used with the display driver.
  • Demonstrates the use of both the ROM and a custom routine to generate the VSync pulses.

The pre-populated display file shows how 'standard' pseudo hi-res (in this instance the graphics from the title screen of Software Farm's Forty Niner) can be intermixed with the Sinclair character set and a new lowercase character set:

LightningDriverDemo_BlackWhite.gif
LightningDriverDemo_BlackWhite.gif (2.77 KiB) Viewed 1779 times

The image will appear coloured if a Chroma 81 interface is detected:

LightningDriverDemo_Colour.gif
LightningDriverDemo_Colour.gif (2.8 KiB) Viewed 1779 times
Spinnetti
Posts: 253
Joined: Sat Sep 12, 2020 11:29 pm

Re: Lightning Driver Coding Examples

Post by Spinnetti »

Very cool!
Zeddy: ZX80, ZX81/ZXpand, TS1000/ZXpand, TS1500/Zxpand+
Speccy: 48k, +, +2, +3, TS2068, "Bare Metal" Pi, Next KS2, IF1/Microdrives/Vdrive/Light Gun/VGA-Joy
QL: Minerva/QL-VGA/Custom PSU
C5: 24v, LiFE battery, Disc brakes
Post Reply