; заливка, новая версия с использованием Texture.asm

FillPgn
             DISP PgnAdr

BFill
             call Texture
             ld a,(Texture.fselect)
             or a
            ret nz

             call LOADSCR
             call SV_UNDO
             ld de,FillCur
             call SV_ARW

.lp          ld hl,.Rf
             call ARW_SCN_
            jr nc,.fill
             call SAVESCR
            jp LD_ARW

.fill        ld hl,(ARW_X)
             call .fillHL
            jr .lp

.fillHL      ld (.xy),hl
             call .SOLIDFF
             ld a,(Texture.fsolid)
             or a
             call z,.txtrFF
            ret



.Rf     DI
        LD A,(23560)
        EX AF,AF'
        XOR A
        LD (23560),A
        EX AF,AF'
        RES 5,A
        CP "Y"
        CALL Z,.sul
        LD A,(GUI_PAGE)
        CALL RAM
        EI
        RET

.sul    ; LD A,ScrPage
        ; CALL RAM
        call ScrRam
        LD HL,#4000
        LD DE,SCREEN+6912
        LD BC,6912
        LDIR
        JP NOKEY_



;  Далее частями взято из Fill1.asm с изменениями /DA

; TXTRFF  CALL GETTEX
;         CALL SOLIDFF
.txtrFF
        CALL SAVESCR
       ; LD A,ScrPage
       ; CALL RAM
        LD HL,#C000
        LD DE,#DB00
        LD BC,#C000
        CALL wss
        CALL LOADSCR
        RET

.SOLIDFF LD A,SuxPage
        CALL RAM
        ld de, 0     ; LD DE,(CONSTS) ; /DA
.xy   EQU $-2
        PUSH DE
        CALL I1
        POP HL
        CALL I2
           call ScrRam
           ld hl,#5800     ; заполнение атрибутов залитой области   ; /DA
           ld bc,#0003     ; 768
1           push bc
            push hl
            ld a,h
            add a,a
            add a,a
            add a,a
            ld d,a
            and #58
            ld h,a
            ld e,l
            ld bc,#0800
2            ld a,(de)
             xor (hl)
             or c
             ld c,a
             inc d
             inc h
            djnz 2B
             pop hl
              ld a,c
              or a
             jr z,3F
              ld a,(hl)
              call MIXCOL
              ld (hl),a
3             inc hl
             pop bc
            djnz 1B
             dec c
            jr nz,1B
        RET




; Tipa iz EDP... A v EDP iz ArtStudio...

I1      LD      HL,BUFF
        LD      B,#08
I14     LD      DE,#FFFF
i15     EQU     $-#02
        SRL     D
        LD      (i15),DE
        LD      C,#08
I15     LD      (HL),E
        INC     HL
        LD      (HL),D
        INC     HL
        LD      A,E
        RRCA
        RR      D
        RR      E
        DEC     C
        JR      NZ,I15
        DJNZ    I14
        RET
I2      PUSH    HL
        LD      A,L
        AND     #07
        INC     A
        LD      B,A
        CALL    I16
        LD      A,(HL)
I17     RLA
        DJNZ    I17
        POP     HL
        RET     C
        LD      IX,#C000
        LD      (IX+#00),#00
        INC     IX
        LD      A,L
        OR      A
        JR      NZ,I18
        INC     L
I18     LD      A,#01
        LD      DE,#8000
        CALL    I71
        DI
I19     LD      BC,#FFFC
        ADD     IX,BC
        LD      A,(IX+#03)
        OR      A
        JR      Z,I23
        LD      L,(IX+#00)
        LD      H,(IX+#01)
        LD      E,(IX+#02)
        LD      A,(IX+#03)
        AND     #0F
        BIT     3,A
        JR      Z,I20
        OR      #F0
I20     LD      D,A
        BIT     7,(IX+#03)
        LD      A,#00
        JR      NZ,I21
        LD      A,#FF
I21     LD      (I77),A
        BIT     6,(IX+#03)
        LD      A,#01
        JR      Z,I22
        LD      A,#FF
I22     CALL    I24
        JR      I19
I23     EI
        RET
I24     LD      (I73),A
        LD      (I74),HL
        LD      (I75),DE
        LD      D,#00
I25     PUSH    HL
        CALL    I16
        LD      A,(HL)
        LD      (I34),A
        LD      C,A
        LD      B,#08
        POP     HL
        LD      A,(I73)
        OR      A
        LD      A,L
        JP      M,I26
        AND     #07
        JR      Z,I29
        JR      I27
I26     AND     #07
        NEG
        ADD     A,#07
        JR      Z,I29
I27     LD      D,#FF
I28     PUSH    AF
        CALL    I48
        POP     AF
        DEC     A
        JR      NZ,I28
        LD      D,#00
I29     PUSH    HL
        PUSH    DE
        LD      A,E
        DEC     A
        CP      #08
        JR      C,I30
        LD      E,#08
I30     LD      A,(I73)
        OR      A
        JP      P,I32
        LD      A,L
        AND     #07
        INC     A
        SUB     E
        JR      NC,I31
        ADD     A,E
        LD      E,A
I31     LD      A,L
        INC     A
        SUB     E
        LD      L,A
I32     LD      A,L
        AND     #07
        ADD     A,A
        LD      L,A
        LD      A,E
        DEC     A
        ADD     A,A
        ADD     A,A
        ADD     A,A
        ADD     A,A
        ADD     A,L
        LD      HL,BUFF
        ADD     A,L
        LD      L,A
        JR      NC,I33
        INC     H
I33     INC     HL
        LD      A,(HL)
        CPL
        LD      E,A
        LD      A,#00
I34     EQU     $-#01
        AND     E
        CP      E
        POP     DE
        POP     HL
        PUSH    AF
        LD      A,(I77)
        OR      A
        JR      NZ,I38
        POP     AF
        PUSH    AF
        JR      Z,I37
        LD      A,(I73)
        OR      A
        JP      M,I35
        BIT     7,C
        JR      I36
I35     BIT     0,C
I36     JR      NZ,I37
        PUSH    HL
        PUSH    DE
        LD      DE,#0000
        NEG
        PUSH    AF
        ADD     A,L
        LD      L,A
        POP     AF
        CALL    I71
        POP     DE
        POP     HL
I37     LD      A,#FF
        LD      (I77),A
I38     LD      A,C
        OR      A
        JR      NZ,I41
        LD      A,B
        CP      #08
        JR      NZ,I41
        LD      A,D
        DEC     A
        JR      Z,I39
        CALL    I61
        LD      (I74),HL
        LD      D,#01
I39     PUSH    HL
        CALL    I16
        LD      (HL),#FF
        POP     HL
        LD      A,E
        SUB     #08
        LD      E,A
        JR      NC,I40
        LD      E,#00
I40     POP     AF
        JR      I45
I41     POP     AF
        JR      NZ,I43
        LD      A,D
        OR      A
        JR      Z,I42
        CALL    I61
        CALL    I64
        LD      D,#00
I42     LD      A,E
        SUB     B
        LD      E,A
        RET     C
        RET     Z
        JR      I45
I43     CALL    I48
        JR      NZ,I43
        PUSH    HL
        CALL    I16
        EX      AF,AF'
        LD      C,A
        XOR     #FF
        JR      Z,I44
        LD      B,A
        LD      A,(HL)
        AND     C
        OR      B
        LD      (HL),A
I44     POP     HL
        LD      A,D
        INC     A
        RET     Z
I45     LD      A,(I73)
        OR      A
        LD      A,L
        JP      M,I46
        AND     #F8
        ADD     A,#08
        JR      I47
I46     OR      #07
        SUB     #08
I47     LD      L,A
        JP      NC,I25
        LD      A,D
        DEC     A
        JP      Z,I64
        RET
I16     LD      A,H
        LD      C,H
        SRL     A
        SCF
        RRA
        SRL     A
        XOR     C
        AND     #F8
        XOR     C
        LD      H,A
        LD      A,L
        RLCA
        RLCA
        RLCA
        XOR     C
        AND     #C7
        XOR     C
        RLCA
        RLCA
        LD      L,A
        RET
I48     LD      A,(I73)
        OR      A
        LD      A,D
        JP      M,I56
        INC     A
        JR      NZ,I49
        EX      AF,AF'
        SLA     C
        SCF
        RLA
        EX      AF,AF'
        JR      I55
I49     DEC     A
        JR      NZ,I51
        EX      AF,AF'
        SLA     C
        JR      NC,I50
        RLA
        EX      AF,AF'
        JR      I53
I50     RLA
        EX      AF,AF'
        CALL    I61
        LD      (I74),HL
        LD      D,#01
        JR      I54
I51     EX      AF,AF'
        SLA     C
        JR      C,I52
        RLA
        EX      AF,AF'
        JR      I54
I52     RLA
        EX      AF,AF'
        CALL    I61
        CALL    I64
        LD      D,#00
I53     XOR     A
        LD      (I75),A
        LD      A,E
        DEC     E
        CP      #02
        JR      NC,I55
        LD      D,#FF
        LD      E,#00
        JR      I55
I54     LD      A,E
        OR      A
        JR      Z,I55
        DEC     E
I55     DEC     B
        RET
I56     INC     A
        JR      NZ,I57
        EX      AF,AF'
        SRL     C
        SCF
        RRA
        EX      AF,AF'
        JR      I55
I57     DEC     A
        JR      NZ,I59
        EX      AF,AF'
        SRL     C
        JR      NC,I58
        RRA
        EX      AF,AF'
        JR      I53
I58     RRA
        EX      AF,AF'
        CALL    I61
        LD      (I74),HL
        LD      D,#01
        JR      I54
I59     EX      AF,AF'
        SRL     C
        JR      C,I60
        RRA
        EX      AF,AF'
        JR      I54
I60     RRA
        EX      AF,AF'
        CALL    I61
        CALL    I64
        LD      D,#00
        JR      I53
I61     LD      A,(I73)
        OR      A
        LD      A,L
        JP      M,I62
        AND     #F8
        LD      L,A
        LD      A,#08
        SUB     B
        ADD     A,L
        LD      L,A
        RET
I62     AND     #F8
        ADD     A,B
        DEC     A
        LD      L,A
        RET
I63     LD      A,H
        OR      A
        RET Z
        LD A,(I73)
        LD D,#FF
        DEC H
        CALL I71
        INC H
        RET
I64     PUSH HL
        PUSH DE
        EX DE,HL
        LD HL,(I74)
        LD A,(I73)
        OR A
        JP M,I65
        LD A,E
        SUB L
        JR I66
I65     LD A,L
        SUB E
I66     JR Z,I70
        POP DE
        PUSH DE
        LD D,E
        LD E,A
        LD A,(I76)
        OR A
        JR Z,I68
        LD A,D
        OR A
        JR NZ,I67
        LD A,(I75)
        OR A
        JR Z,I68
        CP E
        JR NZ,I68
I67     LD A,(I76)
        DEC A
        JR Z,I69
        CALL I63
        JR I70
I68     CALL I63
I69     LD A,H
        CP #BF
        JR Z,I70
        INC H
        LD A,(I73)
        LD D,#81
        CALL I71
I70     POP DE
        POP HL
        RET
I71     PUSH BC
        LD (IX+#00),L
        LD (IX+#01),H
        LD (IX+#02),E
        ADD A,A
        ADD A,A
        ADD A,A
        ADD A,A
        AND #70
        LD B,A
        LD A,D
        AND #8F
        OR B
        LD (IX+#03),A
        LD BC,#0004
        ADD IX,BC
        JR NC,I72
        LD BC,#FFFC
        ADD IX,BC
I72     POP BC
        RET

I73     NOP
I74     NOP
        NOP
I75     NOP
I76     NOP
I77     NOP

; BUFF    DEFS    #80  ; переместил в основной файл /DA


wss     PUSH BC
        PUSH DE
        LD B,12
a3      PUSH BC
        LD DE,TBUFF     ;(TXRADR)
        LD B,16
a2      PUSH HL
        PUSH BC
        LD B,16
a1_     LD A,(DE)
        AND (HL)
        LD (HL),A
        INC DE
        INC HL
        LD A,(DE)
        AND (HL)
        LD (HL),A
        INC HL
        DEC DE
        DJNZ a1_
        POP BC
        POP HL
        CALL INC_Y
        INC DE
        INC DE
        DJNZ a2
        POP BC
        DJNZ a3

        POP HL
;       LD HL,#C000
;       LD DE,#C000; 4000
        POP DE
        LD BC,6144
c5      LD A,(DE)
        OR (HL)
        LD (DE),A
        INC HL
        INC DE
        DEC BC
        LD A,C
        OR B
        JR NZ,c5
        RET

FillCur DB #1F,#40,#4F,#A0,#0F,#60,#87,#10
        DB #E3,#08,#F1,#04,#FB,#00,#FF,#00
        DB #FF,#00,#FF,#00,#FF,#00,#FF,#00
        DB #FF,#00,#FF,#00,#FF,#00,#FF,#00


LFill   EQU $-BFill
        ENT
       DISPLAY "Fill len   :",/a,LFill

