         *= $c000
;---------------------------------------
; VIDEO - Set Character, border & screen
;         colours

; Syntax: video n n n
; n=[0-f] Char,border,screen colours
;  respectivly. Use ? if not to change.
;---------------------------------------

indr3    = $12
nountick = $59
stdonum  = $61
buffer   = $0840
openfnum = $0906
close    = $0909
strout   = $100f
nounstart = $101b


         lda #63      ;fudge 4 wildcards
         sta t2
         sta t3

         jsr digit     ;Get nybble value
         bcs setbad                ;char
         sta t1
set1     jsr digit               ;border
         bcs setbad
         sta t2
         jsr digit               ;screen
         bcs setbad
         sta t3

set2     lda t3
         cmp #63
         beq set3
         cmp t1     ;chk if char=screen
         beq setbad

set3     lda t1       ;move in colours
         cmp #63     ;(with wildcarding)
         beq *+5
         sta 646
         lda t2
         cmp #63
         beq *+5
         sta 53280
         lda t3
         cmp #63
         beq *+5
         sta 53281

         lda #0
         clc
         rts


setbad  ;Show instructions

         lda #1    ;Open up output file
         ldx stdonum   ;I wish it could
         jsr openfnum   ;be just stdout
         bcs setbad1+1

         lda #<text
         sta indr3
         lda #>text
         sta indr3+1
         lda stdonum
         jsr strout
         bcs setbad1+1
         lda stdonum
         jsr close
         lda #0
         bcc setbad1
         lda #24
         sec
         .byte $24
setbad1  clc
         rts


text     .byte 13
         .text "Syntax: video n n n"
         .byte 13
         .text "n=[0-f] Char, border "
         .text "& screen colours   "
         .text "respectivly. Use ? if n"
         .text "ot to change."
         .byte 13,13,64


digit  ;Get char and convert to nybble

         jsr nounstart
         bmi digitexit-1
         lda buffer,x
         beq digitexit-1
         cmp #63             ;chk if "?"
         beq digit2
         sec          ;convert to nybble
         sbc #48
         bcc digitexit-1
         cmp #10
         bcc digit1
         sbc #7
digit1   cmp #16
         bcs digitexit
digit2   inc nountick
         clc
         .byte $24
         sec
digitexit rts

t1       = *
t2       = t1+1
t3       = t2+1


