; old version (not used) / DA

FillPgn
        DISP PgnAdr

BFill   LD A,%1111
bfill   LD IX,WFill
        LD (IX+6),A
        CALL Win_
        CP #FF
        JP Z,RES_TSK2
        LD BC,TBFill
        JP TAB_JP

bfill__ CALL CLOSE
bfill_  LD A,%1101
        JR bfill

TBFill  DW ESolid
        DW ETFill
        DW EEFill
        DW EWash
        DW EWash_
        DW ELdFill
        DW ESvFill
        DW EFDrive

EFDrive CALL Driver
        JR bfill_

ELdFill LD HL,SORTtxr
        CALL FilerE
        JP C,bfill_
        LD B,4
        EXLOAD #8000,TEXTURE,START_SEC,PgnPage1
        JP C,bfill_
        LD DE,FNameTxr
        CALL ToName
        JP bfill_

ESvFill LD HL,FNameTxr
        CALL FNEdit
        JR C,bfill_
        LD HL,FNameTxr
        CALL FromName
        LD B,4
        EXSAVEF #8000,TEXTURE,1024,PgnPage1
        JP C,bfill_
        JR bfill_

SORTtxr DB #00,4,#FF

EEFill  LD A,%1110
eefill  LD IX,WTFill
        LD (IX+6),A
        CALL Win_
        CP #FF
        JP Z,bfill__
        LD (TEXTNUMB),A
        CALL GETTEX
        LD DE,TBUFF
        LD BC,32
        LDIR
eedit1  LD HL,TBDat1
        CALL SPEdit
        CP #FF
        JR Z,eedit
        AND A
        JR Z,txtrcls
        DEC A
        JR Z,txtrinv
        DEC A
        JR Z,txtrund
        CALL cbuff
        JP txtrf
eedit1_ LD A,%1101
        LD (IX+6),A
        JR eedit1

eedit   CALL CLOSE
        CALL cbuff
        LD A,%1100
        JR eefill

cbuff   LD HL,TBUFF
        LD DE,(TXRADR)
        LD BC,32
        LDIR
        RET

txtrund LD HL,(TXRADR)
        LD DE,TBUFF
        LD BC,32
        LDIR
        JR eedit1_

txtrinv LD HL,TBUFF
        LD B,32
djnz11  LD A,(HL)
        CPL
        LD (HL),A
        INC HL
        DJNZ djnz11
        JR eedit1_

txtrcls LD HL,TBUFF
        LD DE,TBUFF+1
        LD BC,31
        LD (HL),0
        LDIR
        JR eedit1_

TBDat1  DB #08,#03
        DB #0F,#0C
        DW TBUFF
        DW #0103
        DW #0202
        DW #0A03
        DW BSText
        DW BSSel
        DW Nil

BSText
    if rus
        DB #90,#a5,#a4,#a0,#aa,#e2,#ae,#e0,#20,#e2,#a5,#aa,#e1,#e2,#e3,#e0,13;"Редактор текстур",13
        DB 22,10,6,#93,#a1,#e0,#a0,#e2,#ec,13;"Убрать",13
        DB #88,#ad,#a2,#a5,#e0,#e2,13;"Инверт",13
        DB #8e,#e2,#ac,#a5,#ad,#a0,0;"Отмена",0
    else
        DB "Texture",13
        DB 22,10,6,"Delete",13
        DB "Invert",13
        DB "Undo",0
    endif

BSSel   DEFB 10,6,4,1,%11
        DEFB 10,7,4,1,%11
        DEFB 10,8,4,1,%11
        DEFB #FF

ESolid  CALL NOKEY_
        LD HL,SOLIDFF
        JR CHU

ETFill  CALL etfill
        CALL CLOSE
        JP bfill_

etfill  LD IX,WTFill
        CALL Win_
        CP #FF
        RET Z
        LD (TEXTNUMB),A
txtrf   LD HL,TXTRFF
CHU     LD (MT+1),HL
        CALL SV_UNDO
        CALL LOADSCR
        LD DE,FillCur
        CALL SV_ARW

lz      LD HL,Rf
        CALL ARW_SCN_
        JR C,FEx
        LD HL,(ARW_X)
        LD (CONSTS),HL
MT      CALL 0
        JR lz

FEx     CALL SAVESCR
        CALL LD_ARW
        JP RES_TSK

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
        LD HL,#4000
        LD DE,SCREEN+6912
        LD BC,6912
        LDIR
        JP NOKEY_
;**********************************
;текстурная заливка
; E=x, D=y, A=номер текстуры (0..255)

GETTEX  LD A,0
TEXTNUMB EQU $-1
        LD BC,TEXTURE
        LD H,0
        LD L,A
        DUP 5
        ADD HL,HL
        EDUP
        ADD HL,BC
        LD (TXRADR),HL
        RET

TXTRFF  CALL GETTEX
        CALL SOLIDFF
        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,(CONSTS)
        PUSH DE
        CALL I1
        POP HL
        CALL I2
        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

TXRADR   DW 0
;..........................
CONSTS  DEFW #1010

EWash_  CALL CLOSE
ewash_  CALL ewash2
        JP RES_TSK

ewash2  LD A,ScrPage
        CALL RAM
        LD HL,#C000+6912
        LD DE,#4000
        LD BC,6912
        LDIR
        LD A,RamPage
        CALL RAM
        LD DE,#4000
        LD HL,#C000
        LD BC,6144
C0      LD A,(DE)
        AND (HL)
        LD (DE),A
        INC HL
        INC DE
        DEC BC
        LD A,C
        OR B
        JR NZ,C0
        LD A,ScrPage
        CALL RAM
        LD HL,#C000
        LD DE,#4000
        LD BC,6144
c1      LD A,(DE)
        OR (HL)
        LD (DE),A
        INC HL
        INC DE
        DEC BC
        LD A,C
        OR B
        JR NZ,c1
        CALL SAVESCR
        RET

EWash   CALL CLOSE_ALLW
wS      LD IX,WTFill
        CALL Win_
        CP #FF
        JP Z,RES_TSK2
        LD (TEXTNUMB),A
        CALL GETTEX

        CALL LOADSCR
        CALL LD_UNDO

        LD HL,#C000
        LD DE,#DB00
        LD BC,#C000
        CALL wss

        CALL SAVEOBJ
        JP Main

wss     PUSH BC
        PUSH DE
        LD B,12
a3      PUSH BC
        LD DE,(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

WTFill  DEFB 3,2,25,13,4*8,4,%00001110
; Bit 0 - окно с заголовком/без
; Bit 1 - "перерисовать" окно да/нет
; Bit 2 - тискать окно по экрану да/нет
; Bit 3 - выход из окна-ткнуть только лишь за пределами (CANCEL)
        DEFB 0
        DEFW Nil          ; объект-текст
        DEFW Nil          ; объект-подсветка (выборка)
        DEFW Nil          ; горячие клавиши
        DEFW BTFill       ; объект-кнопки (выборка)
        DEFW #FFFF

BTFill
        DB 1,1,2,2,7,%11
        DW TEXTURE
        DB 4,1,2,2,7,%11
        DW TEXTURE+32
        DB 7,1,2,2,7,%11
        DW TEXTURE+64
        DB 10,1,2,2,7,%11
        DW TEXTURE+96
        DB 13,1,2,2,7,%11
        DW TEXTURE+128
        DB 16,1,2,2,7,%11
        DW TEXTURE+160
        DB 19,1,2,2,7,%11
        DW TEXTURE+192
        DB 22,1,2,2,7,%11
        DW TEXTURE+224

        DB 1,4,2,2,7,%11
        DW TEXTURE+256
        DB 4,4,2,2,7,%11
        DW TEXTURE+288
        DB 7,4,2,2,7,%11
        DW TEXTURE+320
        DB 10,4,2,2,7,%11
        DW TEXTURE+352
        DB 13,4,2,2,7,%11
        DW TEXTURE+384
        DB 16,4,2,2,7,%11
        DW TEXTURE+416
        DB 19,4,2,2,7,%11
        DW TEXTURE+448
        DB 22,4,2,2,7,%11
        DW TEXTURE+480

        DB 1,7,2,2,7,%11
        DW TEXTURE+512
        DB 4,7,2,2,7,%11
        DW TEXTURE+544
        DB 7,7,2,2,7,%11
        DW TEXTURE+576
        DB 10,7,2,2,7,%11
        DW TEXTURE+608
        DB 13,7,2,2,7,%11
        DW TEXTURE+640
        DB 16,7,2,2,7,%11
        DW TEXTURE+672
        DB 19,7,2,2,7,%11
        DW TEXTURE+704
        DB 22,7,2,2,7,%11
        DW TEXTURE+736

        DB 1,10,2,2,7,%11
        DW TEXTURE+768
        DB 4,10,2,2,7,%11
        DW TEXTURE+800
        DB 7,10,2,2,7,%11
        DW TEXTURE+832
        DB 10,10,2,2,7,%11
        DW TEXTURE+864
        DB 13,10,2,2,7,%11
        DW TEXTURE+896
        DB 16,10,2,2,7,%11
        DW TEXTURE+928
        DB 19,10,2,2,7,%11
        DW TEXTURE+960
        DB 22,10,2,2,7,%11
        DW TEXTURE+992
        DB #FF

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

WFill   DEFB #11,2,9,12,6*8+1,6+1,%00001111
; Bit 0 - окно с заголовком/без
; Bit 1 - "перерисовать" окно да/нет
; Bit 2 - тискать окно по экрану да/нет
; Bit 3 - выход из окна-ткнуть только лишь за пределами (CANCEL)
        DEFB 0
        DEFW TFill        ; объект-текст
        DEFW SFill        ; объект-подсветка (выборка)
        DEFW #FFFF

SFill   DEFB 1,3,7,1,%11
        DEFB 1,4,7,1,%11
        DEFB 1,5,7,1,%11
        DEFB 1,6,7,1,%11
        DEFB 1,7,7,1,%11
        DEFB 1,8,7,1,%11
        DEFB 1,9,7,1,%11
        DEFB 1,10,7,1,%11
        DEFB #FF

TEXTURE
        ENT
te      ORG $,PgnPage1
    INCBIN "bgetxr.t"
        DISP TEXTURE+1024

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

