
;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 warplight1
        bpl checklight2
        ldx #$5d         ;light on color
        and #$7f
        sta warplight1
        bne *+4
        ldx #$cf         ;light off color

        stx bitmap0screen+6*40+15
        stx bitmap0screen+6*40+16
        stx bitmap0screen+6*40+17
        stx bitmap0screen+7*40+15
        stx bitmap0screen+7*40+16
        stx bitmap0screen+7*40+17

checklight2
        lda warplight2
        bpl checklight3
        ldx #$5d         ;light on color
        and #$7f
        sta warplight2
        bne *+4
        ldx #$cf         ;light off color

        stx bitmap0screen+7*40+20
        stx bitmap0screen+7*40+21
        stx bitmap0screen+8*40+20
        stx bitmap0screen+8*40+21

checklight3
        lda warplight3
        bpl checklight4
        ldx #$5d         ;light on color
        and #$7f
        sta warplight3
        bne *+4
        ldx #$cf         ;light off color

        stx bitmap0screen+7*40+24
        stx bitmap0screen+7*40+25
        stx bitmap0screen+8*40+24
        stx bitmap0screen+8*40+25
checklight4
        lda warplight4
        bpl checklight5
        ldx #$5d         ;light on color
        and #$7f
        sta warplight4
        bne *+4
        ldx #$cf         ;light off color

        stx bitmap0screen+6*40+28
        stx bitmap0screen+6*40+29
        stx bitmap0screen+6*40+30
        stx bitmap0screen+7*40+28
        stx bitmap0screen+7*40+29
        stx bitmap0screen+7*40+30
checklight5
        rts
