Skip to content

Instantly share code, notes, and snippets.

@ped7g
Created October 27, 2020 02:34
Show Gist options
  • Save ped7g/bd8afcc1baf2301197a9421d5b685b27 to your computer and use it in GitHub Desktop.
Save ped7g/bd8afcc1baf2301197a9421d5b685b27 to your computer and use it in GitHub Desktop.
ZX Spectrum Next - show how 8bit defined colors expand the two "BB" bits to full 9bit color definition
; show how 8-bit color values RRRGGGBB are being extended to full 9-bit definition
; displays blue squares with 8bit blue part 0, 1, 2, 3 (all possible blue shades in 8b)
; and under them the 9bit defined blues as %000, %011, %101, %111 (how 8b extends to 9b)
; assembling: sjasmplus color8vs9b.asm ( https://github.com/z00m128/sjasmplus )
DEVICE ZXSPECTRUMNEXT : OPT --syntax=abfw
ORG $8000
start:
di
ld a,7
out (254),a ; BORDER 7
; clear screen pixels with zeroes
ld hl,$4000
ld de,$4001
ld bc,$1800
ld (hl),l
ldir
ld (hl),7<<3 ; PAPER 7 : INK 0
ld bc,$2FF
ldir
; put attribute data at rows 2, 4, 6 and 7
ld hl,attr_data
ld de,$5800 + 32*2 + 1
ld bc,8
ldir
ld de,$5800 + 32*4 + 1
ld bc,8
ldir
ld de,$5800 + 32*6 + 1
ld bc,8
ldir
ld de,$5800 + 32*7 + 1
ld bc,8
ldir
; standard ULA (only), reset scroll, reset clip window
nextreg $14,$E3 ,, $15,0 ,, $68,0 ,, $69,0 ,, $26,0 ,, $27,0 ,, $1C,$04
nextreg $1A,0 ,, $1A,255 ,, $1A,0 ,, $1A,191
; setup palette (first ULA, standard), PAPER 0,1,2,3 to be blue 0,1,2,3 in 8bit
nextreg $43,0 ,, $40,16+0 ,, $41,0 ,, $41,1 ,, $41,2 ,, $41,3
; BRIGHT 1 + PAPER 0,1,2,3 to be blue %000, %011, %101, %111 in 9bit
nextreg $40,16+8 ,, $44,0 ,, $44,0 ,, $44,1 ,, $44,1 ,, $44,2 ,, $44,1 ,, $44,3 ,, $44,1
jr $
attr_data:
HEX 00 38 08 38 10 38 18 38 ; row 2 PAPER 0, 1, 2, 3 one square apart
HEX 40 38 48 38 50 38 58 38 ; row 4 *bright* PAPER 0, 1, 2, 3 one square apart
HEX 00 08 10 18 38 38 38 38 ; row 6 PAPER 0, 1, 2, 3 together
HEX 40 48 50 58 38 38 38 38 ; row 7 *bright* PAPER 0, 1, 2, 3 together
SAVENEX OPEN "color8vs9b.nex", start, $c000
SAVENEX BANK 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment