;
; Micro-KIM demos
; (C) 2016 by Aart Bik
;
; For use with cross-assembler
; win2c64 (Windows), lin2c64 (linux),
; or mac2c64 (MacOS)
;
; http://www.aartbik.com/
;
; Demo that adjusts brightness of one
; character (or segment) on the LED
; display. This technique can be used
; in a wide variety of demos that change
; the brightness of the LED display
; somehow, such as fading the display
; in and out, a sliding glow effect, or
; giving emphasis to parts of the
; LED display
;

;
; Define symbols for the 6532 RIOT addresses.
;
sad  = $1740   ; A data register
padd = $1741   ; A data direction register
sbd  = $1742   ; B data register
pbdd = $1743   ; B data direction register

;
; Start program at free RAM.
;
.org $0200

;
; Set the 6532 RIOT data direction registers.
; 
             lda #$7f
             sta padd
             lda #$3f
             sta pbdd
;
; Main loop for display.
;
display_loop ldx #0
             ldy #9
char_loop    lda #0
             sta sad          ; no flicker
             sty sbd
             lda data, x
             sta sad
             txa
             ldx #4
char_delay   dex
             bne char_delay  ; glow up character
             tax
             inx
             iny
             iny
             cpx #6
             bne char_loop
;
; Glow up individual character (or segment)
; much more than the others.
;  
             lda #0
             sta sad
             lda #11
             sta sbd
             lda #$f7  ; change to $40 for segment
             sta sad
             ldx #200
bright_delay dex
             bne bright_delay
;
; Keep refreshing full LED display.
;  
             jmp display_loop
;
; Data to display (all 'A's for this demo).
;
data .byte $f7 $f7 $f7 $f7 $f7 $f7