; модуль шрифта FNT ( адаптация )

FntPgn
Font    EQU #C000+4

      ;  DISP PgnAdr
   ;     ORG PgnAdr

FNTovl  ld (bfnt.sp),sp
;------ редактор ----------------
BBF     call bfnt.sOvFNTpg
        CALL SV_UNDO
BFnt    LD A,%1111
bfnt    LD IX,WFnt
        LD (IX+6),A
       ; LD SP,(SPP)
        ld sp,0
.sp  EQU $-2
        CALL Win_
        CP #FF
      ;  JP Z,RES_TSK2
       jr z,.exit
        LD BC,TBFnt
        JP TAB_JP

.exit   call CLOSE
.sOvFNTpg   ld a,(ExtMem)
            or a
           ret z
            ld hl,#C000
            ld de,#F600
            ld bc,2048+4
            ld a,ovFNTpg
            call ExOnP_AddP
           jp RAM_N

efnt    LD A,%1101
        JR bfnt

erfnt   CALL NoData_
        JP efnt

ReFnt   CALL ReWin
        JR BFnt

TBFnt   DW FntPrt
        DW BEFnt
        DW FntOpen
        DW FntSave2048
        DW FntSave768
        DW FntDrv
        DW SMatrix
        DW SMetg

FntDrv  CALL Driver
        JR efnt

;WFnt    DEFB 1,2,12,13,6*8,5,%00001111
;        DEFB 0
;        DEFW TFnt         ; объект-текст
;        DEFW SFnt         ; объект-подсветка (выборка)
;        DEFW #FFFF

WFnt    DB 10,4,12,13,5*8,5,%00001111
        DB 0
        DW TFnt         ; объект-текст
        DW SFnt         ; объект-подсветка (выборка)
        DW #FFFF
;TFnt
;    if rus
;        DEFB "Fnt ",#98,#e0,#a8,#e4,#e2,13;шрифт",13
;        DEFB #8f,#a5,#e7,#a0,#e2,#ec,13;"Печать",13
;        DEFB #90,#a5,#a4,#a0,#aa,#e2,#ae,#e0,13;"Редактор",13
;        DEFB #8e,#e2,#aa,#e0,#eb,#e2,#ec,#5f,13;"Открыть_",13
;        DEFB #91, #AE, #E5, #E0, #A0, #AD, #A8, #E2, #EC," 2048_",13
;        DEFB #91, #AE, #E5, #E0, #A0, #AD, #A8, #E2, #EC,"  768_",13
;     ;   DEFB #84,#a8,#e1,#aa,#ae,#a2,#ae,#a4,13;"Дисковод",13
;         DB #0A : DW TDriveNum
;        DEFB 15,13
;        DEFB #8c,#a0,#e2,#e0,#a8,#e6,#a0,": ";Матрица: "
;    else
;        DEFB "FNT font",13
;        DEFB "Type",13
;        DEFB "Editor",13
;        DEFB "Load_",13
;        DEFB "Save 2048_",13
;        DEFB "Save  768_",13
;     ;   DEFB "Drive",13
;         DB #0A : DW TDriveNum
;        DEFB 15,13
;        DEFB "Matrix: "
;    endif
;tmtx    DEFB "8x8",13
;    if rus
;        DEFB #8c,#a5,#e2,#ae,#a4,":   ";"Метод:   "
;    else
;        DEFB "Mode:   "
;    endif
;tmet    DEFB "Or ",0

TFnt        MSG_FNT_Title : DB 13
            MSG_FNT_Type : DB 13
            MSG_FNT_Editor : DB 13
            MSG_FNT_Load_ : DB 13
            MSG_FNT_Sv2048 : DB 13
            MSG_FNT_Sv768 : DB 13
            DB #0A : DW TDriveNum
            DB 15,13
            MSG_FNT_Matrix : DB #17,7
tmtx        DB "8x8",13
            MSG_FNT_Mode : DB #17,7
tmet        DB "Or ",0

SFnt    ; DEFB 1,3,10,1,%11
        ; DEFB 1,4,10,1,%11
        ; DEFB 1,5,10,1,%11
        ; DEFB 1,6,10,1,%11
        ; DEFB 1,7,10,1,%11
        ; DEFB 1,8,10,1,%11
        DB 1,3,10,128+6,%11

        ; DEFB 1,10,10,1,%11
        ; DEFB 1,11,10,1,%11
        DB 1,10,10,128+2,%11
        DEFB #FF

FntSave2048
        CALL FntID
        JP NZ,erfnt
        LD HL,FnFnt
        CALL FNEdit
        JP C,efnt
        LD HL,FnFnt
        CALL FromName
        LD B,#08
        EXSAVEF #8000,Font,2048,AddPage
        JP efnt

FntSave768
        CALL FntID
        JP NZ,erfnt
        LD HL,FnFnt
        CALL FNEdit
        JP C,efnt
        LD HL,FnFnt
        CALL FromName
        LD B,#03
        EXSAVEF #8000,Font+256,768,AddPage
        JP efnt

;FNameFnt
  ;  if rus
  ;      DB #a1,#a5,#a7,#a8,#ac,#a5,#ad,#a8,"fnt";"безимениfnt"
  ;  else
  ;      DB "noname  fnt"
  ;  endif
;-----------------------------
SMatrix LD HL,WMtrx
        CALL PupMnu
        CALL CLOSE_
        CP #FF
        JP Z,efnt
        LD (fmatrix),A
        ADD A,A
        ADD A,A
        LD BC,TMtrx
        LD H,0
        LD L,A
        ADD HL,BC
        LD DE,tmtx
        LD BC,3
        LDIR
        JP efnt

WMtrx   DEFB 6,11,4,8,7*8,7,%00001110
        DEFB 0
        DEFW TMtrx        ; объект-текст
        DEFW SMtrx        ; объект-подсветка (выборка)
        DEFW #FFFF

TMtrx   DEFB "8x8",13
        DEFB "7x8",13
        DEFB "6x8",13
        DEFB "5x8",13
        DEFB "4x8",13
        DEFB "3x8",0

SMtrx   ; DEFB 1,1,2,1,%11
        ; DEFB 1,2,2,1,%11
        ; DEFB 1,3,2,1,%11
        ; DEFB 1,4,2,1,%11
        ; DEFB 1,5,2,1,%11
        ; DEFB 1,6,2,1,%11
        DB 1,1,2,128+6,%11
        DEFB #FF
;------------------------------------
SMetg   LD HL,WFMet
        CALL PupMnu
        CALL CLOSE_
        CP #FF
        JP Z,efnt
        PUSH AF
        ADD A,A
        ADD A,A
        LD BC,TFMet
        LD H,0
        LD L,A
        ADD HL,BC
        LD DE,tmet
        LD BC,3
        LDIR
        POP AF
        LD BC,orpitb
        CALL TAB_HL
        LD (orpi+1),HL
        JP efnt

orpitb  DW OR_PUT
        DW XOR_PUT
        DW AND_PUT

WFMet   DEFB 6,11,4,5,7*8,7,%00001110
        DEFB 0
        DEFW TFMet        ; объект-текст
        DEFW SFMet        ; объект-подсветка (выборка)
        DEFW #FFFF

TFMet   DEFB "Or ",13
        DEFB "Xor",13
        DEFB "And",0

SFMet   ; DEFB 1,1,2,1,%11
        ; DEFB 1,2,2,1,%11
        ; DEFB 1,3,2,1,%11
        DB 1,1,2,128+3,%11
        DEFB #FF

;------------------------------

fmatrix DB 0

FntPrt  CALL FntID
        JP NZ,erfnt
        CALL NOKEY_
        CALL LOADSCR
        CALL AddRam
        LD A,(fmatrix)
        NEG
        ADD A,#08
        LD (fmlen),A
        LD A,(fmatrix)
        LD BC,smatrix
        ADD A,A
        LD H,0
        LD L,A
        ADD HL,BC
        LD DE,farw
        LDI
        LD B,6
djn1    LD A,(HL)
        LD (DE),A
        INC DE
        DJNZ djn1
        DEC HL
        LDI

        CALL XOR_PUT
        LD HL,ArwFnt1
        LD DE,ArwFnt2
        LD A,ARW_NEW
        CALL GUI
        LD HL,Ret
        CALL ARW_SCN_
        JP C,ReFnt

        LD HL,(ARW_X)
        LD (FNT_X),HL
        LD (FNTX),HL
        CALL AddRam

prfnt   CALL FntCur
prfnt_  XOR A
        LD (23560),A
        HALT
        CALL #1F54
        JP NC,ReFnt_
;       CALL BREAK
;       LD A,(BRK)
;       BIT 1,A
;       JP NZ,ReFnt_
        LD A,(23560)
        CP 14
        JP Z,ReFnt_
        AND A
        JR Z,prfnt_

        PUSH AF
        CALL FntCur
        POP AF

        CP 12
        JP Z,FDEL
        CP 7
        JP Z,FRUS_LAT
        CP 6
        JP Z,FCAPS
        CP 8
        JP Z,FLEFT
        CP 9
        JP Z,FRIGHT
        CP 10
        JP Z,FDN
        CP 11
        JP Z,FUP
        CP 13
        JP Z,FCR

orpi    CALL OR_PUT
        CALL PERECOD
        CALL clcfnt
        LD BC,(FNT_X)
        CALL OutPix
        CALL AddFX
        JR prfnt

ReFnt_  CALL FntCur
        CALL SAVESCR
        JP ReFnt

AddFX   LD BC,(FNT_X)
        LD A,0
fmlen   EQU $-1
        ADD A,C
        LD (FNT_X),A
        RET
AddFY   LD A,(FNT_Y)
        ADD A,8
      ;  LD (FNT_Y),A    ; в zfy_ это есть, зачем лишнее /DA
        JR zfy_
SubFX   LD A,(fmlen)
        LD C,A
        LD A,(FNT_X)
        SUB C
        LD (FNT_X),A
        RET
SubFY   LD A,(FNT_Y)
        SUB 8
zfy_    CP 185        ; 192-8 ; bugfix ;  /DA
        JR C,zfy
         and 7        ; XOR A   ; заменил, чтобы не сбивались строки ; /DA
zfy     LD (FNT_Y),A
        RET
;-------------------------
FRUS_LAT
        CALL RUS_LAT
        JP prfnt
FCAPS   CALL CAPS
        JP prfnt

FDEL    CALL AND_PUT
        LD A,(fmatrix)
        LD BC,alkha
        LD H,0
        LD L,A
        ADD HL,BC
        LD A,(HL)
        LD (FBuff),A
        LD HL,FBuff
        LD DE,FBuff+1
        LD BC,7
        LDIR
        CALL SubFX
        LD HL,FBuff
        LD BC,(FNT_X)
        CALL OutPix
        JP prfnt

alkha   DB %11111111
        DB %11111110
        DB %11111100
        DB %11111000
        DB %11110000
        DB %11100000

FCR     LD HL,(FNTX)
        LD (FNT_X),HL
        CALL AddFY
        JR pka
FRIGHT  CALL AddFX
pka     LD HL,(FNT_X)
        LD (FNTX),HL
        JP prfnt
FLEFT   CALL SubFX
        JR pka
FDN     CALL AddFY
        JR pka
FUP     CALL SubFY
        JR pka
;----------------------------------
FNT_X   DB 0
FNT_Y   DB 0
FNTX    DW 0

ArwFnt1 LD HL,farw
        LD BC,(ARW_X)
        LD (ArwXM),BC
        JP OutPix

ArwFnt2 LD HL,farw
        LD BC,0
ArwXM   EQU $-2
        JP OutPix

FntCur  CALL XOR_PUT
        LD HL,farw
        LD BC,(FNT_X)
        JP OutPix

farw    DS 8

smatrix
matr8   DB %11100111
        DB %00011000
matr7   DB %11101110
        DB %00010000
matr6   DB %11001100
        DB %00110000
matr5   DB %11011000
        DB %00100000
matr4   DB %10010000
        DB %01100000
matr3   DB %10100000
        DB %01000000

;-- работа с диском -----

FntOpen   ld a,(ExtMem)
          or a
          call z,AskAddP
         jp c,efnt
        LD HL,SORTfnt
        CALL FilerE
        JP C,efnt
        LD A,(SEC_LEN)
        CP #03
        JP Z,Fnt768
        LD B,A
        EXLOAD #8000,Font,START_SEC,AddPage
fnaz    JP C,efnt
        CALL CrFID
        LD DE,FnFnt
        CALL ToName
        JP efnt

Fnt768  PUSH AF
        CALL AddRam
        LD HL,Font
        LD DE,Font+1
        LD BC,2047
        LD (HL),0
        LDIR
        POP AF
        LD B,A
        EXLOAD #8000,Font+256,START_SEC,AddPage
        JR fnaz

FnFnt  ; DB #a1,#a5,#a7,#a8,#ac,#a5,#ad,#a8,"fnt";"безимениfnt"
         DB "font    fnt"

SORTfnt ; DB #00,#08,#03,#FF
         DB %0000,8,3,0
         DB %1010,"bge_ovr.Cod",#00
         DB %1001,"add","ovb","hlp","hst",#FF

;--- Редактор ---------------
BEFnt   CALL FntID
        JP Z,BEFnt_
       ; CALL ASK
         ld a,(ExtMem)
         or a
         call z,AskAddP
        JP C,efnt
        CALL AddRam
        LD HL,Font
        LD DE,Font+1
        LD BC,2047
        LD (HL),0
        LDIR
        LD HL,15616
        LD DE,Font+256
        LD BC,768
        LDIR
        CALL CrFID
BEFnt_  CALL LOADSCR
        CALL PRINT
fntedit CALL AddRam
        LD A,(char)
        CALL fntsel
        LD DE,FBuff
        LD BC,8
        LDIR
fnedit    ; LD SP,(SPP)
         ld sp,(bfnt.sp)
        LD A,(char)
        PUSH AF
        CP 32
        JR NC,okfnt_
        LD A,"?"
okfnt_  LD (tchar),A
        POP AF
        LD C,0
        LD DE,betext
        EX AF,AF'
        LD A,GET_NUM
        CALL GUI
        LD HL,TBFnt1
        CALL SPEdit_
        EX AF,AF'
        LD A,(But)
        AND A
        JP Z,ReFnt
        EX AF,AF'
        CP #FF
        JR Z,eefnt
        PUSH AF
        CALL AddRam
        POP AF
        LD BC,TBEFnt
        JP TAB_JP

bfnt_   LD A,%1001
        LD (IX+6),A
        JR fntedit

bfnt__  LD A,%1001
        LD (IX+6),A
        JR fnedit

eefnt   CALL savfnt
        LD A,(BRK)
        BIT 1,A
        JP NZ,ReFnt
        CALL FntSel
        JP bfnt_

TBEFnt  DW DelFnt
        DW InvFnt
        DW SavFnt
        DW UndFnt
        DW SavAs
        DW RLft
        DW RUp
        DW RDn
        DW RRgt
        DW RRLft
        DW RRUp
        DW RRDn
        DW RRRgt  ; [12]
        DW OthFnt

        DW FELft  ; [14]
        DW FEDn
        DW FEUp
        DW FERgt

FELft   CALL savfnt
        LD HL,char
        DEC (HL)
bb1     JP bfnt_
FEDn    CALL savfnt
        LD A,(char)
        ADD A,32
fedn    LD (char),A
        JR bb1
FEUp    CALL savfnt
        LD A,(char)
        SUB 32
        JR fedn
FERgt   CALL savfnt
        LD HL,char
        INC (HL)
        JR bb1

BEHot   DB CS,"5"
         DW 14
        DB CS,"6"
         DW 15
        DB CS,"7"
         DW 16
        DB CS,"8"
         DW 17
        DB #FF

char    DB 1
FntAdr  DW 0 ; адрес символа [char]
;------- end -----------------
RRLft   LD B,0
        LD HL,Font
rrlft   PUSH BC
        CALL rlft
        POP BC
        DJNZ rrlft
print   CALL PRINT
        JP bfnt_

RLft    LD HL,FBuff
        CALL rlft
        JP bfnt__
rlft    LD B,8
rf1     LD A,(HL)
        RLCA
        LD (HL),A
        INC HL
        DJNZ rf1
        RET

RRRgt   LD HL,Font
        LD B,0
rrrgt   PUSH BC
        CALL rrgt
        POP BC
        DJNZ rrrgt
        JP print

RRgt    LD HL,FBuff
        CALL rrgt
        JP bfnt__

rrgt    LD B,8
rf2     LD A,(HL)
        RRCA
        LD (HL),A
        INC HL
        DJNZ rf2
        RET

RRDn    LD HL,Font+6
        LD B,0
rrdn    PUSH BC,HL
        CALL rdn
        POP HL,BC
        LD DE,8
        ADD HL,DE
        DJNZ rrdn
        JP print

RDn     LD HL,FBuff+6
        CALL rdn
        JP bfnt__

rdn     LD D,H
        LD E,L
        INC DE
        LD A,(DE)
        EX AF,AF'
        LD B,7
rf3     LD A,(HL)
        LD (DE),A
        DEC DE
        DEC HL
        DJNZ rf3
        EX AF,AF'
        LD (DE),A
        RET
;--------------
RRUp    LD HL,Font
        LD B,0
rrup    PUSH BC
        PUSH HL
        CALL rup
        POP HL
        POP BC
        LD DE,8
        ADD HL,DE
        DJNZ rrup
        JP print

RUp     LD HL,FBuff
        CALL rup
        JP bfnt__

rup     LD D,H
        LD E,L
        INC DE
        LD A,(HL)
        EX AF,AF'
        LD B,7
rf4     LD A,(DE)
        LD (HL),A
        INC DE
        INC HL
        DJNZ rf4
        EX AF,AF'
        LD (HL),A
        RET
;-----------------------
DelFnt  LD HL,FBuff
        LD DE,FBuff+1
        LD BC,7
        LD (HL),B
        LDIR
        JP bfnt__

InvFnt  LD HL,FBuff
        LD B,8
invfnt  LD A,(HL)
        CPL
        LD (HL),A
        INC HL
        DJNZ invfnt
        JP bfnt__

SavFnt  CALL savfnt
        JP bfnt__

savfnt  CALL AddRam
        LD HL,FBuff
        LD DE,(FntAdr)
        LD BC,8
        LDIR
        JP PRINT

UndFnt  LD HL,(FntAdr)
        LD DE,FBuff
        LD BC,8
        LDIR
        CALL PRINT
        JP bfnt__

SavAs   CALL NOKEY_
        LD HL,Ret
        CALL ARW_SCN_
        JP C,bfnt__
        CALL FntSel
        JP C,bfnt_
        CALL AddRam
        LD HL,FBuff
        LD DE,(FntAdr)
        LD BC,8
        LDIR
        CALL PRINT
        JP bfnt_

TBFnt1  DB #07,#04       ; X,Y окна
        DB #11,#08       ; ширина, высота
        DW FBuff         ; адрес спрайта
        DW #0103         ; X,Y окна редактора
        DW #0101         ; размеры спрайта
        DW #0603         ; X,Y preview
        DW BEText        ; текст
        DW BESel         ; подсветка
        DW BEHot         ; горячие клавиши

;BEText
;    if rus
;        DB "ASCII ", #e1,#a8,#ac,#a2,#ae,#ab,#22;символ ",#22
;    else
;        DB "ASCII symbol",#22
;    endif

BEText  MSG_FNT_ASCII : DB " ",#22
tchar   DB "?",#22," ["
betext  DB "000] ",13
        DB 22,8,3
;    if rus
;        DB #93,#a1,#e0,#a0,#e2,#ec,13;"Убрать",13
;        DB #88,#ad,#a2,#a5,#e0,#e2,13;"Инверт",13
;        DB #87,#a0,#af,#a8,#e1,#ec,13;"Запись",13
;        DB #8e,#e2,#ac,#a5,#ad,#a0,13;"Отмена",13
;        DB 22,12,3
;        DB #91,#ae,#e5,#e0,#20,#a2,13;"Сохр в",13
;        DB 22,12,4,#ab,13 ; "л"
;        DB 22,13,4,#a2,13 ; "в"
;        DB 22,14,4,#ad,13 ; "н"
;        DB 22,15,4,#af,13 ; "п"

;        DB 22,12,5,#ab,13
;        DB #90,#a0,#a7,#ad,#ae,#a5,13;"Разное",13
;        DB 22,13,5,#a2,13
;        DB 22,14,5,#ad,13
;        DB 22,15,5,#af,13
;    else
;        DB "Clear",13
;        DB "Invert",13
;        DB "Save",13
;        DB "Undo",13
;        DB 22,12,3
;        DB "Copy",13
;        DB 22,12,4,"l",13 ; "л"
;        DB 22,13,4,"u",13 ; "в"
;        DB 22,14,4,"d",13 ; "н"
;        DB 22,15,4,"r",13 ; "п"

;        DB 22,12,5,"l",13
;        DB "Misc.",13
;        DB 22,13,5,"u",13
;        DB 22,14,5,"d",13
;        DB 22,15,5,"r",13
;    endif
;        DB 0

        MSG_FNT_Clear : DB 13
        MSG_FNT_Invert : DB 13
        MSG_FNT_Save : DB 13
        MSG_FNT_Undo : DB 13
        DB 22,12,3
        MSG_FNT_Copy  : DB 13
        MSG_FNT_left  : DB #17,1
        MSG_FNT_up    : DB #17,2
        MSG_FNT_down  : DB #17,3
        MSG_FNT_right : DB 13
        MSG_FNT_left  : DB #17,1
        MSG_FNT_up    : DB #17,2
        MSG_FNT_down  : DB #17,3
        MSG_FNT_right : DB 13
        MSG_FNT_Misc  : DB 0


BESel   ; DEFB 8,3,4,1,%11
        ; DEFB 8,4,4,1,%11
        ; DEFB 8,5,4,1,%11
        ; DEFB 8,6,4,1,%11
        DB 8,3,4,128+4,%11
        DEFB 12,3,4,1,%11

        DEFB 12,4,1,1,%11
        DEFB 13,4,1,1,%11
        DEFB 14,4,1,1,%11
        DEFB 15,4,1,1,%11

        DEFB 12,5,1,1,%11
        DEFB 13,5,1,1,%11
        DEFB 14,5,1,1,%11
        DEFB 15,5,1,1,%11
        DEFB 12,6,4,1,%11
        DEFB #FF

PRINT   CALL AddRam
        LD HL,#0010
        LD (xy),HL
        XOR A
        LD B,8
ja2     PUSH BC
        LD B,32
ja1     PUSH BC
        PUSH AF
        LD BC,0
xy      EQU $-2
        CALL WRITE
        LD BC,(xy)
        INC B
        LD (xy),BC
        POP AF
        INC A
        POP BC
        DJNZ ja1
        LD BC,(xy)
        INC C
        LD B,0
        LD (xy),BC
        POP BC
        DJNZ ja2

muskat  LD HL,#5800+512
        LD DE,#5800+513
        LD BC,255
        LD (HL),7
        LDIR
        LD HL,#5800+512
        LD A,(char)
        LD C,A
        LD B,0
        ADD HL,BC
        LD (HL),4
        RET

WRITE   DI
        LD H,0
        LD L,A
        ADD HL,HL
        ADD HL,HL
        ADD HL,HL
        LD DE,Font
        ADD HL,DE
        LD (STASC+1),HL
        LD (STC),SP
        LD A,C
        AND #18
        ADD A,#40
        LD H,A
        LD A,C
        AND 7
        RRCA
        RRCA
        RRCA
        ADD A,B
        LD L,A
STASC   LD SP,0
        POP DE
        LD (HL),E
        INC H
        LD (HL),D
        INC H
        POP DE
        LD (HL),E
        INC H
        LD (HL),D
        INC H
        POP DE
        LD (HL),E
        INC H
        LD (HL),D
        INC H
        POP DE
        LD (HL),E
        INC H
        LD (HL),D
        LD SP,0
STC     EQU $-2
        EI
        RET

; - определение выбранной буквы

FntSel  LD A,(ARW_YC)
        CP 16
        RET C
        SUB 16
        DUP 5
        ADD A,A
        EDUP
        LD B,A
        LD A,(ARW_XC)
        ADD A,B

        LD (char),A
fntsel  PUSH AF
        CALL muskat
        POP AF
clcfnt  LD H,0
        LD L,A
        ADD HL,HL
        ADD HL,HL
        ADD HL,HL
        LD BC,Font
        ADD HL,BC
        LD (FntAdr),HL
        XOR A
        RET

OthFnt  PUSH IX
        LD IX,WFOnt
        CALL Win_
        CALL CLOSE_
        POP IX
        CP #FF
        JP Z,bfnt_
        PUSH AF
        CALL AddRam
        POP AF
        LD BC,TBOtF
        JP TAB_JP

TBOtF   DW FNaek
        DW FFont
        DW FObrez
        DW FAdd
;--------------------------
FObrez  LD HL,Font
        LD BC,256*8
fobrez  LD A,(HL)
        AND %11110000
        LD (HL),A
        INC HL
        DEC BC
        LD A,B
        OR C
        JR NZ,fobrez
        JP print

FAdd    LD HL,Font
        LD BC,256*8
fadd    LD A,(HL)
        DUP 4
        SRL A
        EDUP
        OR (HL)
        LD (HL),A
        INC HL
        DEC BC
        LD A,B
        OR C
        JR NZ,fadd
        JP print

FNaek   CALL SV_UNDO
        CALL LOADSCR
        CALL AddRam
        LD HL,Font
        LD DE,#4000
        LD B,0
fnaek2  PUSH BC
        LD B,8
        PUSH DE
fnaek1  LD A,(HL)
        LD (DE),A
        INC HL
        INC D
        DJNZ fnaek1
        POP DE
        INC DE
        POP BC
        DJNZ fnaek2
        CALL SAVESCR
        JP BEFnt

FFont   CALL LOADSCR
        CALL AddRam
        LD HL,#4000
        LD DE,Font
        LD B,0
ffont2  PUSH BC
        PUSH HL
        LD B,8
ffont1  LD A,(HL)
        LD (DE),A
        INC H
        INC DE
        DJNZ ffont1
        POP HL
        INC HL
        POP BC
        DJNZ ffont2
        JP BEFnt

WFOnt   DEFB 16,8,8,8,6*8,7,%00001111
        DEFB 0
        DEFW TFOnt        ; объект-текст
        DEFW SFOnt        ; объект-подсветка (выборка)
        DEFW #FFFF

;TFOnt
;    if rus
;        DB #90,#a0,#a7,#ad,#ae,#a5,13;"Разное",13
;        DB #8d,#a0,#20,#ed,#aa,#e0,#a0,#ad,13;"На экран",13
;        DB #91,#20,#ed,#aa,#e0,#a0,#ad,#a0,13;"С экрана",13
;        DB #8e,#a1,#e0,#a5,#a7,#a0,#e2,#ec,13;"Обрезать",13
;        DB #84,#ae,#a1,#a0,#a2,#a8,#e2,#ec,0;"Добавить",0
;    else
;        DB "Misc.",13
;        DB "->Screen",13
;        DB "<-Screen",13
;        DB "Crop",13
;        DB "Add",0
;    endif
TFOnt
          MSG_FNT_MiscT : DB 13
          MSG_FNT_toScreen : DB 13
          MSG_FNT_atScreen : DB 13
          MSG_FNT_Crop : DB 13
          MSG_FNT_Add
          DB 0


SFOnt   ; DEFB 1,3,5,1,%11
        ; DEFB 1,4,5,1,%11
        ; DEFB 1,5,5,1,%11
        ; DEFB 1,6,5,1,%11
        DB 1,3,6,128+4,%11
        DEFB #FF
;---------------------------------
;CrFID   CALL AddRam    ; теперь по другому v3.12 /DA
;        LD HL,fntid
;        LD DE,#C000
;        LD BC,4
;        LDIR
;        RET

;fntid   DB "FONT"
;FntID   CALL AddRam
;        LD HL,#C000
;        LD A,(HL)
;        CP "F"
;        RET NZ
;        INC HL
;        LD A,(HL)
;        CP "O"
;        RET NZ
;        INC HL
;        LD A,(HL)
;        CP "N"
;        RET NZ
;        INC HL
;        LD A,(HL)
;        CP "T"
;        RET



; -------- Описание хранения информации в буфере AddPage -------
; --------       для Fnt и Chnk (Dithering) v3.12        -------
;   Addres #C000 : DB "F*D*" , где * - 'y' или 'n' в зависимости от наличия данных
;          #C004 : Fnt file 2048 bytes
;          #C904 : Dithering file 3072 bytes
; --------------------------------------------------------------


;FntID    call AddRam
;         inc hl
;         ld a,(hl)
;         cp "y"
;        ret nz
;         inc hl
;         ld a,(hl)
;         cp "D"
;        ret nz
;         inc hl
;         ld a,(hl)
;         cp "n"
;        ret z
;         cp "y"
;        ret

;CrFID   call FntID
;        ld hl,#C003
;        ld a,"n"
;       jr nz,1F
;        ld a,"y"
;1       ld (hl),a
;        dec hl
;        ld (hl),"D"
;        dec hl
;        ld (hl),"y"
;        dec hl
;        ld (hl),"F"
;       ret


Fnt_F__  call AddRam
         ld hl,#C000
         ld a,(hl)
         cp "F"
        ret nz
         call .c1
        ret nz
         inc hl
         ld a,(hl)
         cp "D"
        ret nz
.c1
         inc hl
         ld a,(hl)
         cp "y"
        ret z
         cp "n"
        ret

FntID    call Fnt_F__
        ret nz
         dec hl
         dec hl
         ld a,"y"
         cp (hl)
        ret

CrFID    call Fnt_F__
         ld l,#03   ; HL=#C003
         ld a,"n"
        jr z,1F
         ld (hl),a     ; dith
1        dec hl
         ld (hl),"D"
         dec hl
         ld (hl),"y"
         dec hl
         ld (hl),"F"
        ret


;LFnt    EQU $-BBF
FBuff   NOP
        DB 0,0,0,0,0,0,0,0

LFnt    EQU $-BBF

        DISPLAY "FNT len   :",/a,LFnt
      ;  ENT


