Skip to content

Instantly share code, notes, and snippets.

@neuro-sys
Created October 15, 2019 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neuro-sys/68ddea06ad0abf126c5b8f6f5d1fbc72 to your computer and use it in GitHub Desktop.
Save neuro-sys/68ddea06ad0abf126c5b8f6f5d1fbc72 to your computer and use it in GitHub Desktop.
32 hardware colors of Amstrad CPC
org &8000
run &8000
jp start
HWCOLN EQU 32 ; Number of hardware colors
c1 db 0 ; Ink color index
vsync ld b, &f5
vsync1 in a, (c)
rra
jp nc, vsync1
vsync2 in a, (c)
rra
jp c, vsync2
ret
; A holds number of frames to sleep
sleepf ld e, a
sleepf1 call vsync
dec e
jp nz, sleepf1
ret
; disable interrupts
disint
ld hl, &c9fb
ld (&38), hl
ret
; c holds pen index
selpen ld b, &7f
out (c), c
ret
; no input
selbor ld bc, &7f10
out (c), c
ret
; a holds ink
setink
or &40
ld c, a
ld b, &7f
out (c), c
ret
start
call disint
ld a, 1
ld (c1), a
loop
ld a, 50
call sleepf
ld c, 0
call selpen
ld a, (c1)
call setink
call selbor
ld a, (c1)
call setink
ld hl, c1
inc (hl)
ld a, HWCOLN
cp (hl)
jp nz, loop
ld a, 0
ld (hl), a
jp loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment