;
; DMA PROCESSOR FOR OS9/68008 (6502 VERO CPU CARD) 
;

        .org    $FF80

os9     SEI
        LDA #$7F
        STA $FE4E          ;Disable 6522 Interupts
        LDA #3
        STA $FE30          ;Set Rom Page to $03 (BBC B Only)
        LDA #$00           ; 68008 Vector setup
        STA $2000          ; $2000-3 SSP   ($00004000)
        STA $2001          ; $2004-7 RESET ($00008662)
        STA $2004
        STA $2005
        STA $2003
        STA $2400          ; Set $2400 ($00000400) to $00 Used to send commands
        LDA #$40           ; to BBC B OS IE  PRINT GET
        STA $2002
        LDA #$86
        STA $2006
        LDA #$62
        STA $2007
        LDA #$34
        STA $FC47          ; Set 68008 Reset Hi (Start 68008)
mainlp  LDA #$00
        STA $2400
        JMP mainlp

.org    $FF00
start   LDA #$40
        STA $0D00          ; Set NMI routine to RTI
        SEI
        CLD
        LDX #$FF
        TXS
clram   LDX #$04           ; Clear BBC ram $0400-$7FFF
        STX $01
        STA $00
        TAY
loop    STA ($00),Y
        CMP $01
        BEQ exit
        INY
        BNE loop
        INY
        INX
        INC $01
        BPL loop          ; clear ram until &8000
exit    LDX #$0F
        STX $FE42         ; Set 6522 Port PB1 / PB2
        DEX
        STX $FE40
        LDX #0
        JMP os9           ; Jump to OS9 Start up

        NOP
int     PHA               ; Dummy interupt (test only)
        LDA #$FF
        STA $FE40
        LDA #0
        STA $FE40
        PLA
        RTI


        .org   $FFFA
nmi     .word  $0D00
reset   .word  start
irq     .word  int
        .end

