; Gemaakt door Jeff? Ik weet het niet zeker, hij is al zo oud...
        ORG   0C000H

;Invoer in reg. DE de tabel waar naartoe moet worden gefaded
;Opmerking: kleur 0 en 15 worden niet aangepast dus hoef je ze ook niet in te
;           voeren

        LD    HL,EPALET
        LD    B,14

FADER:
        PUSH  BC
        LD    A,(HL)
        PUSH  AF
        AND   240
        EX    AF,AF
        LD    A,(DE)
        PUSH  AF
        AND   240
        LD    B,A
        EX    AF,AF
        CALL  VRGLK2
        LD    C,A
        POP   AF
        AND   15
        LD    B,A
        POP   AF
        AND   15
        CALL  VRGLK1
        ADD   A,C
        LD    (HL),A
        INC   HL
        INC   DE
        LD    A,(DE)
        LD    B,A
        LD    A,(HL)
        CALL  VRGLK1
        LD    (HL),A
        INC   HL
        INC   DE
        POP   BC
        DJNZ  FADER

; COLOR=RESTORE
        DI
        LD    A,1
        OUT   (99H),A
        LD    A,144
        OUT   (99H),A
        LD    BC,1C9AH
        LD    HL,EPALET
        OTIR
        EI
        RET

VRGLK1: CP    B
        RET   Z
        JR    NC,AFTRK1
        INC   A
        RET
AFTRK1: DEC   A
        RET
VRGLK2: CP    B
        RET   Z
        JR    NC,AFTRK2
        ADD   A,16
        RET
AFTRK2: SUB   16
        RET

;Kleur-tabellen (color 1 t/m 14)
EPALET: DEFB  00H,0,11H,6,33H,7,17H,1,27H,3,51H,1,27H,6,71H,1,73H,3
        DEFB  61H,6,64H,6,11H,4,65H,2,55H,5

PALET1: DEFB  00H,0,00H,0,00H,0,00H,0,00H,0,00H,0,00H,0,00H,0,00H,0
        DEFB  00H,0,00H,0,00H,0,00H,0,00H,0
PALET2: DEFB  00H,0,00H,0,00H,0,00H,0,00H,0,00H,0,00H,0,00H,0,00H,0
        DEFB  00H,0,00H,0,00H,0,00H,0,00H,0
PALET3: DEFB  00H,0,00H,0,00H,0,00H,0,00H,0,00H,0,00H,0,00H,0,00H,0
        DEFB  00H,0,00H,0,00H,0,00H,0,00H,0
PALET4: DEFB  00H,0,00H,0,00H,0,00H,0,00H,0,00H,0,00H,0,00H,0,00H,0
        DEFB  00H,0,00H,0,00H,0,00H,0,00H,0

H,0,00H,0
PALET4: DEFB  00H,0,00H,0,00H,0,00H,0,00H,0,00H,0,00H,0,00H