; Source for polled keyboard ROM. Generated by disassembling code.

        LFCBE = $FCBE
        LFCC6 = $FCC6
        LFCCF = $FCCF

        *=$FD00

        txa
        pha
        tya
        pha
LFD04:  lda     #$01
LFD06:  jsr     LFCBE
        jsr     LFCC6
        bne     LFD13
LFD0E:  asl     a
        bne     LFD06
        beq     LFD66
LFD13:  lsr     a
        bcc     LFD1F
        rol     a
        cpx     #$21
        bne     LFD0E
        lda     #$1B
        bne     LFD40
LFD1F:  jsr     LFDC8
        tya
        sta     $0213
        asl     a
        asl     a
        asl     a
        sec
        sbc     $0213
        sta     $0213
        txa
        lsr     a
        jsr     LFDC8
        bne     LFD66
        clc
        tya
        adc     $0213
        tay
        lda     TABLE,y
LFD40:  cmp     $0215
        bne     LFD6B
        dec     $0214
        beq     LFD75
        ldy     #$05
LFD4C:  ldx     #$C8
LFD4E:  dex
        bne     LFD4E
        dey
        bne     LFD4C
        beq     LFD04
LFD56:  cmp     #$01
        beq     LFD8F
        ldy     #$00
        cmp     #$02
        beq     LFDA7
        ldy     #$C0
        cmp     #$20
        beq     LFDA7
LFD66:  lda     #$00
        sta     $0216
LFD6B:  sta     $0215
        lda     #$02
        sta     $0214
        bne     LFD04
LFD75:  ldx     #$96
        cmp     $0216
        bne     LFD7E
        ldx     #$14
LFD7E:  stx     $0214
        sta     $0216
        lda     #$01
        jsr     LFCBE
        jsr     LFCCF
LFD8C:  lsr     a
        bcc     LFDC2
LFD8F:  tax
        and     #$03
        beq     LFD9F
        ldy     #$10
        lda     $0215
        bpl     LFDA7
        ldy     #$F0
        bne     LFDA7
LFD9F:  ldy     #$00
        cpx     #$20
        bne     LFDA7
        ldy     #$C0
LFDA7:  lda     $0215
        and     #$7F
        cmp     #$20
        beq     LFDB7
        sty     $0213
        clc
        adc     $0213
LFDB7:  sta     $0213
        pla
        tay
        pla
        tax
        lda     $0213
        rts

LFDC2:  bne     LFD56
        ldy     #$20
        bne     LFDA7
LFDC8:  ldy     #$08
LFDCA:  dey
        asl     a
        bcc     LFDCA
        rts

TABLE:  .byte $D0, $BB, $2F, $20, $5A, $41, $51, $2C
        .byte $4D, $4E, $42, $56, $43, $58, $4B, $4A
        .byte $48, $47, $46, $44, $53, $49, $55, $59
        .byte $54, $52, $45, $57, $00, $00, $0D, $0A
        .byte $4F, $4C, $2E, $00, $FF, $2D, $BA, $30
        .byte $B9, $B8, $B7, $B6, $B5, $B4, $B3, $B2, $B1
