An assembly version of the scroll demo. Super fast!
; ; Scroll ZX ; v1.00 Steven Reid (c) 2022 ; A very simple scroll demo in assembly. ; ; +++ ; ; Header and startup ; ; start up stuff org 16514 ; stored in REM at top (ZX81) jr start ; needed for z80asm ; title and copyright (will show on listing) copy: db $17,$3f,$3d,$00,$38,$28,$37,$34,$31,$31 db $17,$17,$38,$31,$37,$18,$1e,$1c,$1e,$1e db $17,$76 ; *ZX SCROLL**SLR/2022* start: call slow ; SLOW is required. call cls ; clear screen ; end header and startup ; ; --- ; +++ ; ; Main Loop ; mainloop: ; replicate this in assembly! ; 20 FOR X=0 TO 6.3 STEP .3 ld b,21 ; 21 positions! next: push bc ; save position var ld hl,50 ; short pause call newpause ; and pause (also allows) ; 30 SCROLL ld hl,(d_file) ; get top of screen memory inc hl ; move to top of screen ld d,h ; copy value into ld e,l ; de ld bc,33 ; set hl to next line add hl,bc ; by adding33 ld bc,693 ; prepare to copy lines 1-23 ldir ; starting at top ; 40 LET L=15+14*SIN X pop bc ; restore position (b) ld hl,positions ; location of computed vaules ld d,0 ; set d to zero ld e,b ; set e to position (b) add hl,de ; add to get location dec hl ; subtract 1 ld e,(hl) ; put tab vaule in e ; 50 PRINT TAB L;"ZX" ld hl,(d_file) ; get top of screen memory add hl,de ; add vaule from above ld de,661 ; move to bottom of screen add hl,de ; postion on bottom row ld a,63 ; load a with Z ld (hl),a ; and print it inc hl ; move over one ld a,61 ; load a with X ld (hl),a ; and print it ; 60 NEXT X djnz next ; loop through positions ; 70 RUN jp mainloop ; run again! ; End of loop! ; ; +++ ; ; Routines ; ; Print string at HL ; stops when reaches $FF ; print: ld a,(hl) ; load character inc hl ; increment memory cp $ff ; last character? ret z ; yep, return rst $10 ; nope, print it! jr print ; loop ; ; Delay ; ; set bc to speed ; press space to pframe: dw $0000 newpause: ld (pframe),hl call kscan ; get key press inc l jr z,lppause ; not yet loop dec l ld b,h ld c,l call findchar ; yep, grab character pressed ld a,(hl) and a ; pressed space (break or 0)? jr nz,lppause ; not yet loop call wait ; make sure user has let go of key jp stop ; stop! ; loop! lppause: ld hl,(pframe) dec hl ld a,h or l jr nz,newpause ; not zero, keep going! ret ; pause is done! wait: call kscan ; Wait for human to take finger off of key. inc l jr nz,wait ret ; +++ ; ; Data and Defines ; ; ZX81 system vars d_file: equ $400c d_fcc: equ 16398 frames: equ 16436 ; ZX81 ROM functions kscan: equ $02bb findchar: equ $07bd stop: equ $0cdc slow: equ $0f2b fast: equ $02e7 save: equ $02f9 printat: equ $08f5 pause: equ $0f35 cls: equ $0a2a ; Calculated positions positions: db 15,19,23,26,28 db 29,29,27,24,21 db 17,13, 9, 5, 3 db 1, 1, 2, 4, 7 db 11 ; end defines ; ---