
;this code is part of the data, and handles turning off and on lights.
;0 -> light off , 1 -> light on
;bit 7 is set if the light has changed, for easy detection


lightscode

        lda dielight1
        bpl checklight2
        ldx #$7f         ;light on color
        and #$7f
        sta dielight1
        bne *+4
        ldx #$89         ;light off color

        stx bitmap0screen+$87
        stx bitmap0screen+$87+1
        stx bitmap0screen+$87+40
        stx bitmap0screen+$87+41

checklight2
        lda dielight2
        bpl checklight3
        ldx #$7f         ;light on color
        and #$7f
        sta dielight2
        bne *+4
        ldx #$89         ;light off color

        stx bitmap0screen+$8b
        stx bitmap0screen+$8b+1
        stx bitmap0screen+$8b+40
        stx bitmap0screen+$8b+41

checklight3
        lda dielight3
        bpl checklight4
        ldx #$7f         ;light on color
        and #$7f
        sta dielight3
        bne *+4
        ldx #$89         ;light off color

        stx bitmap0screen+$8f
        stx bitmap0screen+$8f+1
        stx bitmap0screen+$8f+40
        stx bitmap0screen+$8f+41
checklight4
        rts

