org &8000
txt_output equ &bb5a
scr_set_mode equ &bc0e
km_wait_char equ &bb06
start:
ld a,2
call scr_set_mode
call asic_enable
di
ld bc,&7fb8
out (c),c
ld ix,read_rgb_colours
ld b,32
ld a,&40
cc:
push bc
ld bc,&7f00
out (c),c
out (c),a
inc a
ld hl,(&6400)
ld (ix+0),l
ld (ix+1),h
inc ix
inc ix
pop bc
djnz cc
ld bc,&7fa0
out (c),c
ei
call check_colours
call km_wait_char
ret
print_hex:
push af
srl a
srl a
srl a
srl a
call print_nibble
pop af
print_nibble:
and &f
cp 9+1
jr c,number_digit
sub 10
add a,"A"
call txt_output
ret
number_digit:
add a,"0"
call txt_output
ret
print_msg:
ld a,(hl)
inc hl
or a
ret z
call txt_output
jr print_msg
check_colours:
ld b,32
ld ix,read_rgb_colours
ld iy,expected_rgb_colours
chkloop:
push ix
push iy
ld hl,pen1_txt
call print_msg
ld a,'&'
call txt_output
ld a,32
sub b
call print_hex
pop ix
pop iy
ld l,(ix+0)
ld h,(ix+1)
ld e,(iy+0)
ld d,(iy+1)
inc ix
inc ix
inc iy
inc iy
push ix
push iy
or a
sbc hl,de
jr z,chkloop2
add hl,de
push hl
ld hl,pen2_txt
call print_msg
ld a,'&'
call txt_output
pop hl
ld a,h
call print_hex
ld a,l
call print_hex
ld hl,pen3_txt
call print_msg
ld a,'&'
call txt_output
ld a,d
call print_hex
ld a,e
call print_hex
ld a,13
call txt_output
ld a,10
call txt_output
jr chkloop3
chkloop2:
ld hl,pen4_txt
call print_msg
chkloop3:
ld a,32
sub b
cp 24
call z,km_wait_char
pop iy
pop ix
djnz chkloop
ret
pen1_txt:
defb "Ink ",0
pen2_txt:
defb " is wrong. Got ",0
pen3_txt:
defb " should be ",0
pen4_txt:
defb " is correct.",13,10,0
read_rgb_colours:
defs 32*2
asic_enable:
push af
push hl
push bc
push de
ld hl,asic_sequence
ld bc,&bc00
ld d,16
ae1:
ld a,(hl)
out (c),a
inc hl
dec d
jr nz,ae1
ld a,&ee
out (c),a
pop de
pop bc
pop hl
pop af
ret
asic_sequence:
defb &ff,&00
defb &ff,&77,&b3,&51,&a8,&d4,&62,&39,&9c,&46,&2b,&15,&8a,&cd
asic_colour macro _r,_g,_b
defw (_g*256)+(_r*16)+_b
endm
expected_rgb_colours:
asic_colour &06,&06,&06
asic_colour &06,&06,&06
asic_colour &00,&0f,&06
asic_colour &0f,&0f,&06
asic_colour &00,&00,&06
asic_colour &0f,&00,&06
asic_colour &00,&06,&06
asic_colour &0f,&06,&06
asic_colour &0f,&00,&06
asic_colour &0f,&0f,&06
asic_colour &0f,&0f,&00
asic_colour &0f,&0f,&0f
asic_colour &0f,&00,&00
asic_colour &0f,&00,&0f
asic_colour &0f,&06,&00
asic_colour &0f,&06,&0f
asic_colour &00,&00,&06
asic_colour &00,&0f,&06
asic_colour &00,&0f,&00
asic_colour &00,&0f,&0f
asic_colour &00,&00,&00
asic_colour &00,&00,&0f
asic_colour &00,&06,&00
asic_colour &00,&06,&0f
asic_colour &06,&00,&06
asic_colour &06,&0f,&06
asic_colour &06,&0f,&00
asic_colour &06,&0f,&0f
asic_colour &06,&00,&00
asic_colour &06,&00,&0f
asic_colour &06,&06,&00
asic_colour &06,&06,&0f
end