Created
February 15, 2021 22:54
-
-
Save ped7g/8cec25437635f3995fbfe1d70e6d5673 to your computer and use it in GitHub Desktop.
ZX Spectrum Z80 asm - Attribute brightness checkerboard routine, optimized to size (32B)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Author: Ped7g ; (C) 2021 ; license: https://opensource.org/licenses/MIT | |
; Z80 assembly, syntax for sjasmplus: https://github.com/z00m128/sjasmplus | |
; to build: sjasmplus AllanTurveyCheckerboard.asm | |
OPT --syntax=abf : DEVICE ZXSPECTRUM48,31999 : ORG $8000 | |
; D:E = field height:width, A = attribute, modifies: AF, HL, BC, IXL | |
drawCheckerboard: | |
ld hl,$5800 | |
.alternateLine | |
xor $40 ; alternate BRIGHT 1 | |
ld ixl,d ; field height counter | |
.doNextLine | |
push af | |
ld c,$20 ; line total length counter | |
.doLine | |
ld b,e ; field width counter | |
xor $40 ; alternate BRIGHT 1 | |
.fillSpan | |
ld (hl),a | |
inc hl | |
dec c | |
jr z,.lineDone | |
djnz .fillSpan | |
jr .doLine | |
.lineDone | |
pop af | |
bit 2,h | |
ret nz ; stop at HL == $5C00 (overdraw extra $100 bytes (8 lines)) | |
dec ixl | |
jr nz,.doNextLine | |
jr .alternateLine | |
DISPLAY "Size of drawCheckerboard routine: ",/D,$-drawCheckerboard | |
start: | |
ld de,$0A05 | |
ld a,7<<3 ; PAPER 7 : INK 0 : BRIGTH 0 : FLASH 0 | |
call drawCheckerboard | |
jr $ | |
SAVESNA "checkerboard.sna", start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment