        ORG #7E00



;pentagon
;novosibirsk ?
;baltic ?
;scorpion / kay
;profi 

;in none
;out - (memmode) 0 - no CACHE  1 - cache is on board
;    call CCHON - enable cache
;    call CCHOFF - disable cache

cache_test:
        DI 



        LD HL,0
;V.M.G. CACHE TEST
        XOR A
        IN A,(#FB)
        LD A,B
        LD (HL),A
        LD A,(HL)
        CP B
        JP NZ,NOCACH1
        IN A,(#7B)
        XOR A
        JP ACTIVATE   ;V.M.G. CACHE PRESENT

;BALTIK CACHE TEST
NOCACH1 LD BC,#7E
        LD A,#A0
        OUT (C),A
        LD A,B
        LD (HL),A
        LD A,(HL)
        CP B
        JP NZ,NOCACH2
        XOR A
        OUT (C),A
        INC A
        JP ACTIVATE

;NOVOSIBIRSK CACHE TEST
NOCACH2 LD BC,#0F
        LD A,1
        OUT (C),A
        LD A,B
        LD (HL),A
        LD A,(HL)
        CP B
        JP NZ,NOCACH3
        LD A,3
        OUT (C),A
        DEC A
        JP ACTIVATE

;SCORPION/KAY CACHE TEST
NOCACH3 LD BC,#7FFD
        LD A,#10
        OUT (C),A
        LD B,#1F
        LD A,1
        OUT (C),A
        LD A,B
        LD (HL),A
        LD A,(HL)
        CP B
        JP NZ,NOCACH4
        XOR A
        OUT (C),A
        LD A,3
        JP ACTIVATE

;PROFI CACHE TEST
NOCACH4
        LD BC,#7FFD
        LD A,#10
        OUT (C),A
        LD B,#DF
        OUT (C),A
        LD A,B
        LD (HL),A
        LD A,(HL)
        CP B
        JP NZ,NOCACH5
        XOR A
        OUT (C),A
        LD A,4
        JP ACTIVATE
NOCACH5 
        xor a
        (memmode),a
        RET 

ACTIVATE ADD A,A
         ADD A,A
        LD E,A
        LD D,0
        LD HL,CCHTAB
        ADD HL,DE
        LD A,(HL)
        LD (SS1),A
        INC HL
        LD A,(HL)
        LD (SS1+1),A
        INC HL
        LD A,(HL)
        LD (SS2),A
        INC HL
        LD A,(HL)
        LD (SS2+1),A

        ld a,1
        ld (memmode),a
        ret

CCHTAB  DW VMGON
        DW VMGOFF
        DW BALTON
        DW BALTOFF
        DW NOVOSON
        DW NOVOSOFF
        DW SCORPON
        DW SCORPOFF
        DW PROFION
        DW PROFIOFF

CCHON   JP  0
SS1     EQU $-2
CCHOFF  JP  0
SS2     EQU $-2
STRK    DW 0


memmode  db 0

VMGON   IN A,(#FB)
        RET 
VMGOFF  IN A,(#7B)
        RET 
BALTON  LD A,#A0
        OUT (#7E),A
        RET 
BALTOFF XOR A
        OUT (#7E),A
        RET 
NOVOSON LD A,1
        OUT (#0F),A
        RET 
NOVOSOFF LD A,3
        OUT (#0F),A
        RET 
SCORPON LD BC,#1FFD
        LD A,1
        OUT (C),A
        RET 
SCORPOFF LD BC,#1FFD
        XOR A
        OUT (C),A
        RET 
PROFION LD BC,#DFFD
        LD A,#10
        OUT (C),A
        RET 
PROFIOFF LD BC,#DFFD
        XOR A
        OUT (C),A
        RET 

