;Subprograms

set_vmode
		ld	a,#82
		ld	bc,#50
	  	rst	#10
		ret


open_video_mem
		push	af
		in	a,(win1)
		ld	(previous),a
		ld	a,#50
		out 	(win1),a
		pop	af
		ret

open_video_mem1
		push	af
		in	a,(win1)
		ld	(previous),a
		ld	a,#58
		out 	(win1),a
		pop	af
		ret

close_video_mem
		push	af
		ld	a,(previous)
		out	(win1),a
		pop	af
		ret


previous	defb	0

clear_screen
		ld	b,a
		and	%00001111
		rlca
		rlca
		rlca
		rlca
		or	b
		ld	(clear_color),a
		in	a,(win1)
		push	af
		ld	a,#50
		out	(win1),a
		ld	b,0
clear_screen1	push	bc
		ld	a,b
		out	(port_y),a
		ld	hl,#4000
		ld	de,#4001
		ld	bc,320
		ld	a,0
clear_color	equ	$-1
		ld	(hl),a
		ldir
		pop	bc
		djnz	clear_screen1
		pop	af
		out	(win1),a
		ret


wait_a_key
		ld	c,#30
		rst	#10
		ret

wait_q_key
		ld	c,#31
		rst	#10
		jr	z,wait_q_key
		cp	"Q"
		ret	z
		cp	"q"
		ret	z
		jp	wait_q_key

wait_a_click
		push	af
;waitclick1
;                ld      a,(mouse_keys)
;                bit     0,a
;                jr      z,waitclick1
;                pop     af
;                ret







setpalette
;Set your palette
		ld	hl,palette	;Addr. of palette
		ld	e,0		;Start colour
		ld	d,16		;Quantity of colours (16 colours for 640x256 mode)
		ld	b,#ff		;Palette mask
		ld	a,0		;Palette page
		ld	c,#a4		;System function
		rst	#8		;Call BIOS
		ret
palette
;b,g,r,0
;16 colours of your palette
;			BBB GGG RRR
		defb	#00,#00,#00,#00 ;0 -Black
		defb	#BF,#00,#00,#00 ;1 - 
		defb	#00,#00,#FF,#00 ;2 -Red
		defb	#FF,#00,#FF,#00 ;3 -
		defb	#00,#BF,#00,#00 ;4 -Green
		defb	#DF,#DF,#00,#00 ;5 -
		defb	#00,#FF,#FF,#00 ;6 -
		defb	#FF,#FF,#FF,#00 ;7 -White
		defb	#7F,#7F,#7F,#00 ;8 -
		defb	#BF,#BF,#BF,#00 ;9 -Gray
		defb	#DF,#DF,#DF,#00 ;10-
		defb	#97,#97,#97,#00 ;11-Dark gray
		defb	#00,#00,#00,#00 ;12-
		defb	#00,#00,#00,#00 ;13-
		defb	#00,#00,#00,#00 ;14-
		defb	#00,#00,#00,#00 ;15-


font
*B c:\speccy\aedit\6x8.fnt
;*B 6x8.fnt

