.kl_new_fast_ticker equ &bce0
.mc_wait_flyback equ &bd19
.kl_del_fast_ticker equ &bce6
.km_test_key equ &bb1e
.mc_set_inks equ &bd25
.scr_set_mode equ &bc0e
.txt_output equ &bb5a
.txt_set_cursor equ &bb75
org &8000
.start
ld a,2
call scr_set_mode
ld a,&c9
ld (mc_set_inks),a
ld hl,message
call print_msg
call set_vsync_pos
call set_hsync_pos
call set_vdisp
call set_hdisp
call calc_ram_size
call mc_wait_flyback
halt
halt
call mc_wait_flyback
ld a,6
ld (ticker_counter),a
ld hl,colours
ld (current_colour_pointer),hl
ld hl,ticker_event_block
ld b,%11000001
ld c,&80
ld de,ticker_function
call kl_new_fast_ticker
mainloop:
call mc_wait_flyback
call check_keys
jp c,quit_to_basic
halt
halt
jp mainloop
check_keys:
ld a,0
call km_test_key
jp nz,do_up
ld a,2
call km_test_key
jp nz,do_down
ld a,8
call km_test_key
jp nz,do_left
ld a,1
call km_test_key
jp nz,do_right
ld a,47
call km_test_key
ret z
scf
ret
print_msg:
ld a,(hl)
inc hl
or a
ret z
call txt_output
jr print_msg
do_up:
bit 7,c
jr nz,make_shorter
ld a,(vsync_pos)
inc a
ld (vsync_pos),a
call set_vsync_pos
or a
ret
make_shorter:
ld a,(vdisp)
dec a
ld (vdisp),a
call set_vdisp
or a
ret
make_taller:
ld a,(vdisp)
inc a
ld (vdisp),a
call set_vdisp
or a
ret
.do_down
bit 7,c
jr nz,make_taller
ld a,(vsync_pos)
dec a
ld (vsync_pos),a
call set_vsync_pos
or a
ret
.do_left
bit 7,c
jr nz,make_thinner
ld a,(hsync_pos)
inc a
ld (hsync_pos),a
call set_hsync_pos
or a
ret
.make_thinner
ld a,(hdisp)
dec a
ld (hdisp),a
call set_hdisp
or a
ret
.do_right
bit 7,c
jr nz,make_fatter
ld a,(hsync_pos)
dec a
ld (hsync_pos),a
call set_hsync_pos
or a
ret
.make_fatter
ld a,(hdisp)
inc a
ld (hdisp),a
call set_hdisp
or a
ret
.set_vsync_pos
ld h,1
ld l,2
call txt_set_cursor
ld a,'&'
call txt_output
ld a,(vsync_pos)
call print_hex
ld bc,&bc07
out (c),c
ld a,(vsync_pos)
inc b
out (c),a
ret
.set_hsync_pos
ld h,1
ld l,4
call txt_set_cursor
ld a,'&'
call txt_output
ld a,(hsync_pos)
call print_hex
ld bc,&bc02
out (c),c
ld a,(hsync_pos)
inc b
out (c),a
ret
.set_vdisp
ld h,1
ld l,6
call txt_set_cursor
ld a,'&'
call txt_output
ld a,(vdisp)
call print_hex
ld bc,&bc06
out (c),c
ld a,(vdisp)
inc b
out (c),a
call calc_ram_size
ret
.set_hdisp
ld h,1
ld l,8
call txt_set_cursor
ld a,'&'
call txt_output
ld a,(hdisp)
call print_hex
ld bc,&bc01
out (c),c
ld a,(hdisp)
inc b
out (c),a
call calc_ram_size
ret
.vsync_pos defb 30
.hsync_pos defb 30
.vdisp defb 25
.hdisp defb 40
.quit_to_basic
ld hl,ticker_event_block
call kl_del_fast_ticker
ret
.ticker_event_block
defs 10
.ticker_function
push af
push hl
ld a,(ticker_counter)
dec a
ld (ticker_counter),a
or a
jr nz,ticker_function2
ld a,6
ld (ticker_counter),a
ld hl,colours
ld (current_colour_pointer),hl
.ticker_function2
ld hl,(current_colour_pointer)
ld bc,&7f10
out (c),c
ld a,(hl)
out (c),a
inc hl
ld (current_colour_pointer),hl
ld hl,ticker_event_block+2
ld (hl),#00
pop hl
pop af
ret
print_hex:
push af
rrca
rrca
rrca
rrca
call print_hex_digit
pop af
.print_hex_digit
and &f
cp 10
jr nc,print_hex_digit2
add a,'0'
jp txt_output
print_hex_digit2:
add a,'A'-10
jp txt_output
calc_ram_size:
ld h,1
ld l,13
call txt_set_cursor
ld a,(hdisp)
ld l,a
ld h,0
add hl,hl
ld a,(vdisp)
call mul16
add hl,hl
add hl,hl
add hl,hl
push hl
ld a,'&'
call txt_output
ld a,h
call print_hex
pop hl
ld a,l
call print_hex
ret
mul16:
ld e,l
ld d,h
mul16a:
dec a
ret z
add hl,de
jr mul16a
message:
defb 31,1,1,"Vsync Position (CRTC Register 7):"
defb 31,1,3,"Hsync Position (CRTC Register 2):"
defb 31,1,5,"Vertical Displayed (CRTC Register 6):"
defb 31,1,7,"Horizontal Displayed (CRTC Register 1):"
defb 31,1,12,"RAM used (approx):"
defb 31,1,20,"up/down cursor key (no shift): Change vsync pos",10,13
defb "left/right cursor key (no shift): Change hsync pos",10,13
defb "up/down cursor key (shift): Change height",10,13
defb "left/right cursor key (shift): Change width",10,13
defb 0
.ticker_counter defb 0
.current_colour_pointer defw colours
.colours
defb &43
defb &40
defb &54
defb &4b
defb &45
defb &51