        INCLUDE "KerBGE",11
        INCLUDE "NumGUI",12

        ORG #6128
        INCLUDE "GuiVar",13

        ORG PgnAdr

START   LD (RETAD+1),HL
        LD (spp),SP

        CALL SV_UNDO
Start   CALL LOADSCR
        CALL ERASE_ALLW
        LD A,%1111
start   LD SP,0
spp     EQU $-2
        LD IX,SPR_WIN
        LD (IX+6),A
        CALL IniVar
        LD A,Win
        CALL GUI
        CP #FF
        JP Z,RETURN
        PUSH AF
        CALL AddRam
        POP AF
        LD BC,TABjp
        JP TAB_JP

TABjp   DW Cut
        DW Look
        DW Delete
        DW Out
        DW Format
        DW New
        DW LoadSPR
        DW SaveSPR
        DW SaveCOD
        DW Compile
        DW DRIVE
        DW INFO
        DW ABOUT

New     CALL ASK
        JP C,noclose
        CALL Create
        JP noclose

WAITKEYM LD A,WAITKEY
         JP GUI
NOKEYM  LD A,NOKEY
        JP GUI

SORTspr DB #01,"SPR",#FF

LoadSPR LD HL,SORTspr
        CALL FilerE
        JP C,noclose
        LD A,(SEC_LEN)
        LD B,A
        LD HL,#8000
        LD DE,#C000
        LD IX,(START_SEC)
        LD A,4
        LD C,#05
        EX AF,AF'
        LD A,SL_BANK
        CALL GUI
        LD DE,SCRNAME
        CALL ToName
        JP noclose

AddRam  LD A,AddPage
        JP RAM

SCRNAME DB "безимениSPR"
CODNAME DB "безимениCOD"

SaveSPR LD A,(All)
        AND A
        JP Z,NoSpr
        CALL IDL
        LD HL,SCRNAME
        CALL FNEdit
        JP C,noclose
        LD HL,SCRNAME
        CALL FromName
        CALL AddRam
        LD HL,(Float)
        LD DE,#C000
        AND A
        SBC HL,DE
        PUSH HL
        POP IX
        DEC HL
        INC H
        LD B,H
        LD HL,#8000
        LD DE,#C000
        LD A,AddPage
        LD C,11
        EX AF,AF'
        LD A,SL_BANK
        CALL GUI
        JP noclose

SaveCOD LD A,(All)
        AND A
        JP Z,NoSpr
        CALL IDL
        LD HL,CODNAME
        CALL FNEdit
        JP C,noclose
        LD HL,CODNAME
        CALL FromName
        CALL AddRam
        LD HL,(Float)
        LD DE,Sprites
        SBC HL,DE
        PUSH HL
        POP IX
        DEC HL
        INC H
        LD B,H
        LD HL,#8000
        LD DE,Sprites
        LD A,AddPage
        LD C,11
        EX AF,AF'
        LD A,SL_BANK
        CALL GUI
        JP noclose

Create  CALL AddRam
        LD HL,Head
        LD DE,Head+1
        LD BC,16343
        LD (HL),0
        LDIR 
        LD HL,head
        LD DE,Head
        LD BC,4
        LDIR 
        XOR A
        LD (All),A
        LD (teksp),A
        LD HL,TABLICA
        LD (FloatTab),HL
        LD HL,Sprites
        LD (Float),HL
Ret     RET 

DRIVE   CALL Driver
        JP noclose

Format  LD A,%1111
format  LD IX,FOR_WIN
        LD (IX+6),A
        LD A,Win
        CALL GUI
        CP #FF
        JP Z,clstart
        LD BC,TABFOR
        JP TAB_JP

TABFOR  DW Atrib
        DW SSize

SSize   LD A,(Fsize)
        CP 4
        JR Z,onsi
        LD A,4
        LD (Fsize),A
        XOR A
        LD (FSIZE),A
        JR fjp

onsi    CALL LOADSCR
        CALL AddRam
        CALL SelOne
        LD A,3
        LD (Fsize),A
        LD A,1
        LD (FSIZE),A
        LD A,(IX+2)
        LD (XSIZE),A
        LD A,(IX+3)
        LD (YSIZE),A
        JP Start

Atrib   LD A,(Fatr)
        CP 3
        JR Z,ona
        LD A,3
        LD (Fatr),A
        LD A,1
fff     LD (bite),A
fjp     LD A,%1101
        JR format
ona     LD A,4
        LD (Fatr),A
        XOR A
        JR fff
bite    DB 0

FOR_WIN DB 6,8,9,6,6*8,6,%1111,0
        DW TFOR
        DW SFOR
        DW #FFFF

; x, y, номер опции, состояние (#00/#FF)

TFOR    DB "Параметры",13
        DB "Атрибуты ",4,13
Fatr    EQU $-2
        DB "Размер   ",4,0
Fsize   EQU $-2
SFOR    DB 1,3,7,1,%10
        DB 1,4,7,1,%10
        DB #FF

SPR_WIN DB 4,4,12,17,7*8,7,%1111,0
        DW TSPR
        DW SSPR
        DW #FFFF

TSPR    DB "Спрайтер 1.o4",13
        DB "Вырезать",13
        DB "Просмотр",13
        DB "Удаление",13
        DB "Поместить",13
        DB "Формат_",13
        DB "Новый SPR",13
        DB "Открыть SPR_",13
        DB "Сохранить SPR_",13
        DB "Сохранить CODE_",13
        DB "Компиляция SPR_",13
        DB "Дисковод",13
        DB "Информация",13
        DB "О программе",0
SSPR    DB 1,3,10,1,%11
        DB 1,4,10,1,%11
        DB 1,5,10,1,%11
        DB 1,6,10,1,%11
        DB 1,7,10,1,%11
        DB 1,8,10,1,%11
        DB 1,9,10,1,%11
        DB 1,10,10,1,%11
        DB 1,11,10,1,%11
        DB 1,12,10,1,%11
        DB 1,13,10,1,%11
        DB 1,14,10,1,%11
        DB 1,15,10,1,%11
        DB #FF

About   DB 7,9,19,6,5*8,5,%1111,0
        DW TAbout
        DW #FFFF

TAbout  DB "Burial Sprite Cutter v1.o4",13
        DB "(c) Sinn/Delirium Tremens",13
        DB "   from Freedom'1999-o1",0

ABOUT   LD IX,About
        LD A,Window
        CALL GUI
        CALL NOKEYM
        CALL WAITKEYM
        JP clstart

Out     CALL IDL
        LD A,(All)
        AND A
        JP Z,NoSpr

out     CALL CLS
        LD HL,Start
        CALL SelSpr
        CALL LOADSCR
        CALL AddRam
        CALL Recoord

        LD A,(teksp)
        CALL Search
        LD (IX+2),B
        LD (IX+3),C

        XOR A
        CALL Ramka8
        JP C,Start

        LD A,(teksp)
        CALL Search
        LD (IX+2),B
        LD (IX+3),C
        CALL LoadW

        CALL SAVESCR
        CALL NOKEYM
        JP out

ramka   DB 0,0,1,1,0

calc    CALL GET_LEN
        LD DE,(Float)
        ADD HL,DE
        JP C,OutMem
        RET 

Cut     CALL IDL
        LD A,(All)
        CP #FF
        JP Z,OutMem
        CALL LOADSCR
        CALL AddRam
Loop1   LD A,(All)
        CP #FF
        JP Z,OutMem
        CALL SelOne
        CALL TakeSpriteSA
        JR Loop1

TakeSpriteSA
        CALL AddRam
        CALL calc
        LD DE,(Float)
        CALL SaveW
        LD HL,(FloatTab)
        PUSH DE
        PUSH HL
        EX DE,HL
        LD DE,Sprites
        SBC HL,DE
        EX DE,HL
        POP HL
        LD (HL),E
        INC HL
        LD (HL),D
        INC HL
        LD A,(IX+2)
        LD (HL),A
        INC HL
        LD A,(IX+3)
        LD (HL),A
        INC HL
        LD A,(bite)
        LD (HL),A
        INC HL
        LD (FloatTab),HL
        POP DE
        LD (Float),DE
        LD A,(All)
        INC A
        LD (All),A
        RET 

Delete  CALL NOKEYM
        CALL IDL
        LD A,(All)
        AND A
        JP Z,NoSpr

        CALL CLS
        LD HL,Start
        CALL SelSpr

        LD A,(teksp)
        CALL Search
        LD (toHL),HL
        LD (toDE),DE
        LD A,(teksp)
        INC A
        CALL Search
        LD (fromHL),HL
        LD (fromDE),DE

        LD IX,(toHL)
        CALL GET_LEN
        LD (decsm),HL

        LD A,(teksp)
        INC A
        LD B,A
        LD A,(All)
        CP B
        JP Z,lastdec

        LD HL,#FFFF
        LD DE,(fromDE)
        SBC HL,DE
        PUSH HL
        POP BC ; ДЛИНА СПРАЙТА

        LD HL,(fromDE)
        LD DE,(toDE)
        LDIR 

        LD HL,Sprites
        LD DE,(fromHL)
        SBC HL,DE
        PUSH HL
        POP BC

        LD HL,(fromHL)
        LD DE,(toHL)
        LDIR 

        LD HL,(toHL)
        LD A,(teksp)
        LD B,A
        LD A,(All)
        SUB B
        LD B,A
dcl1    PUSH BC
        LD E,(HL)
        INC HL
        LD D,(HL)
        DEC HL
        EX DE,HL
        LD BC,(decsm)
        SBC HL,BC
        EX DE,HL
        LD (HL),E
        INC HL
        LD (HL),D
        LD BC,4
        ADD HL,BC
        POP BC
        DJNZ dcl1
        JR decall

lastdec LD A,(teksp)
        DEC A
        LD (teksp),A

decall  LD A,(All)
        DEC A
        LD (All),A

        LD HL,(Float)
        LD BC,(decsm)
        SBC HL,BC
        LD (Float),HL
        LD HL,(FloatTab)
        LD BC,5
        SBC HL,BC
        LD (FloatTab),HL

        LD A,(All)
        AND A
        CALL Z,Create
        JP Start

toHL    DW 0
toDE    DW 0
fromHL  DW 0
fromDE  DW 0
decsm   DW 0
;...................................
;. Вход:                           .
;.  A  - номер спрайта (0-255)     .
;. Выход:                          .
;.  HL - adress in TABLICA         .
;.  BC - width, high               .
;.  DE - adress in RAM             .
;.  A  - формат                    .
;...................................

Search: LD HL,TABLICA
        AND A
        JR Z,FirSpSch

        LD B,A
        LD DE,5
sloop   PUSH DE
        PUSH HL
        LD E,(HL)
        INC HL
        LD D,(HL)

        PUSH HL
        EX DE,HL
        LD DE,Sprites
        ADD HL,DE
        EX DE,HL
        POP HL

        LD (adrrsp+1),DE
        POP HL
        POP DE
        ADD HL,DE
        DJNZ sloop
adrrsp  LD DE,0
consrch PUSH HL
        INC HL
        INC HL
        LD B,(HL)
        INC HL
        LD C,(HL)
        INC HL
        LD A,(HL)
        POP HL
        RET 

FirSpSch:
        LD DE,Sprites
        JR consrch

rmx     DB 0,0,0,0,1

GET_LEN:
        LD A,(IX+3)
        ADD A,A
        ADD A,A
        ADD A,A
        LD B,A
        LD HL,0
        LD D,0
        LD E,(IX+2)
        ADD HL,DE
        DJNZ $-1
        LD A,(IX+4)
        AND A
        RET Z
        LD A,(IX+3)
        LD B,A
        LD D,0
        LD E,(IX+2)
        ADD HL,DE
        DJNZ $-1
        RET 

; Просмотр архива спрайтов

SINFO   DB 6,20,19,4,5*8,5,%0010,0
        DW DL
        DW #FFFF

DL      DB "000: 000 x 000 атрибуты:  ",13
SM      DB "Смещение 00000 Длина 00000",0

Sinfo   AND A
        JR Z,sinoa
        LD A,3;"["
        JR obsi

sinoa   LD A,4;"]"
obsi    LD (DL+25),A

        LD A,(IX+2)
        EX AF,AF'
        LD DE,DL+5
        LD C,0
        LD A,GET_NUM
        CALL GUI

        LD A,(IX+3)
        EX AF,AF'
        LD DE,DL+11
        LD C,0
        LD A,GET_NUM
        CALL GUI

        LD A,(teksp)
        EX AF,AF'
        LD DE,DL
        LD C,0
        LD A,GET_NUM
        CALL GUI

        LD HL,(smi)
        LD DE,Sprites
        SBC HL,DE
        LD DE,SM+9
        LD C,1
        LD A,GET_NUM
        CALL GUI

        CALL GET_LEN
        LD DE,SM+21
        LD C,1
        LD A,GET_NUM
        CALL GUI

        LD A,(IX+3)
        CP 21
        JR C,norm
        LD A,%0010
        JR okr
norm    LD A,%0000
        JR okr

okr     PUSH IX
        LD IX,SINFO
        LD (IX+6),A
        LD A,Window
        CALL GUI
        POP IX
        RET 

Look    CALL NOKEYM
        CALL IDL
        LD A,(All)
        AND A
        JP Z,NoSpr
        LD HL,Start
        CALL SelSpr
        JP Start

SelSpr  LD (brka+1),HL
        LD IX,rmx
        XOR A
        LD (IX+0),A
        LD (IX+1),A
        CALL CLS
        CALL AddRam
        PUSH IX
        LD A,%0010
        LD IX,SINFO
        LD (IX+6),A
        LD A,Window
        CALL GUI
        POP IX

loopen  LD A,(teksp)
        CALL Search
        LD (smi),DE
        LD (IX+2),B
        LD (IX+3),C
        LD (IX+4),A
        HALT 
        PUSH AF
        CALL LoadW
        POP AF
        CALL Sinfo

;dloop  CALL DIRSCN
dloop   PUSH IX
        POP HL
        LD DE,bufix
        LD BC,5
        LDIR 
        HALT 

        XOR A
        CALL BREAK
brka    JP C,0
        LD A,DIRSCN
        CALL GUI
        LD A,(DIRECT)
        AND A
        JR Z,dloop
        BIT 2,A
        JR NZ,UPSPR
        BIT 3,A
        JR NZ,DNSPR
        BIT 4,A
        RET NZ
        JR loopen

UPSPR   LD A,(teksp)
        INC A
        LD B,A
        LD A,(All)
        CP B
        JP Z,dloop
        LD A,B
loopgo  LD (teksp),A
        PUSH IX
        LD IX,bufix
        CALL CLSW
        LD A,(IX+3)
        CP 21
        JP C,nOrm
        LD IX,SINFO
        LD A,Window
        CALL GUI
nOrm    POP IX
        JP loopen

DNSPR   LD A,(teksp)
        AND A
        JP Z,dloop
        DEC A
        JP loopgo

CLSW    CALL CLSVV
        LD A,7
        CALL setv
        RET 

smi     DW 0
bufix   DS 5

; A - аттрибууты нет/да

LoadW   PUSH AF
        CALL LoadWS
        POP AF
        AND A
        RET Z
        CALL LoadWA
        RET 

SaveW   CALL SaveWS
        LD A,(bite)
        AND A
        RET Z
        CALL SaveWA
        RET 
;......................
FSIZE   DB 0
XSIZE   DB 1
YSIZE   DB 1

SelOne  LD IX,ramka
        CALL Recoord

        LD A,(bite)
        LD (IX+4),A
        LD A,(FSIZE)
        AND A
        JR NZ,ysi
        LD A,1
        LD (IX+2),A
        LD (IX+3),A
        CALL R8Sel
        JP C,Start
        CALL NOKEYM
        RET 

ysi     LD A,(XSIZE)
        LD (IX+2),A
        LD A,(YSIZE)
        LD (IX+3),A

        LD A,32
        LD B,(IX+2)
        SUB B
        Amul8
        LD (ARWXMX),A
        LD A,24
        LD B,(IX+3)
        SUB B
        Amul8
        LD (ARWYMX),A

        LD B,4
        HALT 
        DJNZ $-1

        XOR A
        CALL Ramka8_
        JP C,Start

        LD A,(IX+0)
        LD B,(IX+2)
        ADD A,B

        EX AF,AF'
        LD A,(ARWXMX)
        LD B,A
        SRL B
        SRL B
        SRL B
        EX AF,AF'
        INC B
        CP B

        JR NC,corrx
        LD A,(IX+0)
        LD B,(IX+2)
        ADD A,B
        Amul8
        LD (ARW_X),A
        RET 

corrx   XOR A
        LD (ARW_X),A
        LD A,(IX+1)
        LD B,(IX+3)
        ADD A,B

        EX AF,AF'
        LD A,(ARWYMX)
        LD B,A
        SRL B
        SRL B
        SRL B
        EX AF,AF'
        INC B
        CP B
        JR NC,corry

        LD A,(IX+1)
        LD B,(IX+3)
        ADD A,B
        Amul8
        LD (ARW_Y),A
        RET 

corry   XOR A
        LD (ARW_Y),A
        RET 

Recoord LD A,(ARW_X)
        SRL A
        SRL A
        SRL A
        LD (IX+0),A
        LD A,(ARW_Y)
        SRL A
        SRL A
        SRL A
        LD (IX+1),A
        RET 

clstart CALL CLOSE
noclose LD A,%1101
        JP start
;.......................................
err     LD IX,errorw
        JR errout_

OutMem  LD IX,freew
        LD A,Window
        CALL GUI
        CALL NOKEYM
        CALL WAITKEYM
        JP Start

NoSpr   LD IX,nospr
errout_ LD A,Window
        CALL GUI
        CALL NOKEYM
        CALL WAITKEYM
        JP clstart

INFO_WIN
        DB 7,7,18,7,5*8,5,%1111,0
        DW TINF
        DW #FFFF

TINF    DB "Состояние SPR файла:",13
SPRLN   DB "Длина SPR ......... 00000",13
CODLN   DB "Длина CODE ........ 00000",13
SPNUM   DB "Спрайтов ............ 000",0

INFO    CALL IDL

        LD HL,(Float)
        LD DE,#C000
        SBC HL,DE
        LD DE,SPRLN+20
        LD C,1
        LD A,GET_NUM
        CALL GUI

        LD HL,(Float)
        LD DE,Sprites
        SBC HL,DE
        LD DE,CODLN+20
        LD C,1
        LD A,GET_NUM
        CALL GUI

        LD A,(All)
        LD DE,SPNUM+22
        LD C,0
        EX AF,AF'
        LD A,GET_NUM
        CALL GUI

        LD IX,INFO_WIN
        LD A,Window
        CALL GUI
        CALL NOKEYM
        CALL WAITKEYM
        JP clstart

freew   DB 13,9,10,5,5*8,5,%1111,0
        DW tfreew
        DW #FFFF
tfreew  DB " Внимание!",13
        DB "Мало памяти",0

nospr   DB 13,9,10,5,5*8,5,%1111,0
        DW tnospr
        DW #FFFF
tnospr  DB "  Внимание!",13
        DB "Нет спрайтов",0

errorw  DB 10,9,12,5,5*8,5,%1111,0
        DW terr
        DW #FFFF
terr    DB "   Внимание!",13
        DB "Файл отсутствует",0

IDL     CALL AddRam
        LD HL,Head
        LD A,(HL)
        CP "S"
        JP NZ,err
        INC HL
        LD A,(HL)
        CP "P"
        JP NZ,err
        INC HL
        LD A,(HL)
        CP "R"
        JP NZ,err
        INC HL
        LD A,(HL)
        CP "-"
        JP NZ,err
        RET 

;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
;- компиляция кода в DB
errsp   CALL CLOSE
        LD SP,0
Sp      EQU $-2
        JP noclose

WWait   DB 11,8,11,5,2*8+7,7,%1111,0
        DW TWait
        DW #FFFF
TWait   DB "   Внимание!",13
        DB "Идет процесс_",0

Compile
        LD A,(All)
        AND A
        JP Z,NoSpr
        CALL IDL

        LD HL,FNAME
        CALL FNEdit
        JP C,noclose

        LD IX,WWait
        LD A,Window
        CALL GUI

        LD (Sp),SP
retry   LD A,LOAD_CAT
        CALL GUI
        JR C,errsp

        LD C,#0A
        LD A,DOS_FUNC
        CALL GUI
        JR Z,nokds
        JR okds
nokds   LD A,2
        CALL GET_MSG
        AND A
        JR Z,retry
        JR errsp
okds    LD HL,0
        LD (total),HL
        LD (FR_FLUSH),HL
        LD HL,(END_DISK)
        LD (TEK_SEC),HL
        CALL INI_BUFF

        LD A,0
cont    PUSH AF
        CALL SSpr
        POP AF
        INC A
        LD HL,All
        CP (HL)
        JR NZ,cont
        XOR A           ; добавить конец диска
        CALL ADD_BYTE
        CALL Flush      ; сбросили остаток буфера

ClFile  LD HL,FNAME
        LD DE,23773
        LD BC,11
        LDIR 
        LD HL,#4000
        LD DE,(total)
        PUSH DE
        DEC DE
        INC D
        LD B,D
        POP DE
        LD C,#FF
        LD A,DOS_FUNC
        CALL GUI
        JP errsp

FNAME   DB "безимениWRD"
;------------------------
; сборс одного спрайта
SSpr    PUSH AF
        LD DE,name+3
        CALL CONV
        LD HL,name
        LD B,6
        CALL ADD_BYTES
        POP AF

        CALL Search
        LD (yesrgb),A
        LD (GADR+1),DE
        LD (nach),DE
        LD A,B
        LD (b0),A
        LD A,C
        LD (c0),A
        LD A,0

        LD C,1
c0      EQU $-1
dnz4
        LD B,0
b0      EQU $-1
dnz3    PUSH BC
        LD HL,dbsym
        LD B,4
        CALL ADD_BYTES
        LD B,7
dnz2    PUSH BC
        CALL GADR
        LD A,(HL)
        LD DE,bytsym1
        PUSH DE
        CALL CONV
        POP HL
        LD B,4
        CALL move
        CALL ADD_BYTES
        POP BC
        DJNZ dnz2
        CALL GADR
        LD A,(HL)
        LD DE,bytsym2
        PUSH DE
        CALL CONV
        POP HL
        LD B,4
        CALL move
        CALL ADD_BYTES
        POP BC
        DJNZ dnz3
        DEC C
        JR NZ,dnz4

        LD A,0
yesrgb  EQU $-1
        AND A
        RET Z

        LD HL,0
nach    EQU $-2

        LD A,(c0)
        LD C,A
dnz11   LD A,(b0)
        Amul8
        LD B,A
dnz10   INC HL
        DJNZ dnz10
        DEC C
        JR NZ,dnz11

        LD A,(c0)
        LD C,A
dnz13   LD A,(b0)
        LD B,A
dnz12   PUSH BC
        PUSH HL
        LD A,(HL)
        LD DE,bytsym3
        PUSH DE
        CALL CONV
        LD HL,dbsym1
        LD B,4
        CALL ADD_BYTES
        POP HL
        LD B,5
        CALL move
        CALL ADD_BYTES
        POP HL
        INC HL
        POP BC
        DJNZ dnz12
        DEC C
        JR NZ,dnz13
        RET 
;-----------------------
move    LD B,4
        LD A,(HL)
        CP "0"
        JR NZ,ok1
        INC HL
        DEC B
ok1     LD A,(HL)
        CP "0"
        RET NZ
        INC HL
        DEC B
        RET 

GADR    LD HL,#C000
        PUSH HL
        INC HL
        LD (GADR+1),HL
        POP HL
        RET 

ADD_BYTES
dnz1    PUSH BC
        PUSH HL
        LD A,(HL)
        CALL ADD_BYTE
        POP HL
        INC HL
        POP BC
        DJNZ dnz1
        RET 

ADD_BYTE
        LD HL,(badr)
        LD (HL),A
        INC HL
        LD (badr),HL
        LD HL,(total)
        INC HL
        LD A,H
        OR L
        JP Z,BIG_FILE
        LD (total),HL
        LD HL,(bbyte)
        INC HL
        LD (bbyte),HL
        LD DE,lbuff
        AND A
        SBC HL,DE
        CALL Z,FLUSH
        RET 

Flush   LD HL,(bbyte)
        LD A,H
        OR L
        RET Z
FLUSH   LD HL,(FR_FLUSH)
        LD B,0
        LD C,'lbuff
        ADD HL,BC
        LD (FR_FLUSH),HL

        LD HL,(FREE_SEC)
        LD DE,(FR_FLUSH)
        AND A
        SBC HL,DE
        JP C,OFF_DISK

        LD HL,buffer
        LD DE,(TEK_SEC)
        LD B,'lbuff
        LD C,#06
        LD A,DOS_FUNC
        CALL GUI
        JP C,errsp
INI_BUFF:
        LD HL,buffer
        LD (badr),HL
        LD HL,0
        LD (bbyte),HL
        RET 

FR_FLUSH DW 0

OFF_DISK
        LD IX,WOff
        JR mess

BIG_FILE
        LD IX,WBig
mess    LD A,Window
        CALL GUI
        LD A,NOKEY
        CALL GUI
        LD A,WAITKEY
        CALL GUI
        CALL CLOSE
        JP errsp

WOff    DB 11,8,9,5,2*8+7,7,%1111,0
        DW TOff
        DW #FFFF
TOff    DB " Внимание!",13
        DB "Диск полон_",0

WBig    DB 10,8,12,6,2*8+7,7,%1111,0
        DW TBig
        DW #FFFF
TBig    DB "    Внимание!",13
        DB "Данные не входят",13
        DB "  в один файл_",0

CONV    LD C,0
        EX AF,AF'
        LD A,GET_NUM
        JP GUI

name    DB "SPR"
        DB "000"
lbuff   EQU 1024
total   DW 0             ; сколько всего байтов файл
dbsym   DB #09,"DB "
bytsym1 DB "000,"
bytsym2 DB "000",13,10
dbsym1  DB #09,"DB "
bytsym3 DB "000",13,10
bbyte   DW 0
badr    DW buffer

RETURN  XOR A
RETAD   JP 0
head    DB "SPR-"

LEN=$-PgnAdr
buffer  DS lbuff

         ORG #C000
Head     DS 4
All      DB 0
FloatTab DW TABLICA
Float    DW Sprites
teksp    DB 0
TABLICA  DS 1275; next(2),x(1),y(1),flag(1)
Sprites  NOP 

         ORG BGE_RUN
