'ProgramMode:RUN
'     _#E593__#E656__X_FX       
'Font Editor _#E6B2_FEINT_#E6B2_
'1712 V3.1  by Tsuru & sentaro & Colon
'port to FX by sentaro & Colon
'-------------------
'Normal Font:[6*8]
'mini Font:19[6*6]
'-------------------
'X,Y(EDIT WINDOW 
'    START POINT)
'x,y(REAL WINDOW 
'    START POINT)
'S(FONT W) T(FONT H)
'W H(FONT W*H)
'h (CENTER LINE
'   _Horizontal _)
'v (CENTER LINE
'   _Vertical _)
'E D (allX-)
'M Edit mode(0//OFF  
'   1//ON     3//pass)
'N ForNext
'F Font mode 
' (1//NORMAL  2//MINI)


'#CBINT
'#_Mat _1
CoordOff:GridOff:AxesOff:LabelOff
RefrshCtrl 2:RefrshTime 0
Plot/Line-Color Black 




'const
38->Const _KeyLEFT
27->Const _KeyRIGHT
28->Const _KeyUP
37->Const _KeyDOWN
78->Const _KeySHIFT
77->Const _KeyALPHA
31->Const _KeyEXE
64->Const _Key_8
73->Const _Key_4
53->Const _Key_6
62->Const _Key_2
71->Const _Key_0
61->Const _KeyDP
55->Const _KeyLPAR
45->Const _KeyRPAR
42->Const _KeyPLUS
32->Const _KeyMINUS
79->Const _KeyF1
69->Const _KeyF2
59->Const _KeyF3
49->Const _KeyF4
39->Const _KeyF5
29->Const _KeyF6
'default
{6,8}->Dim Mat A.P'1:A
{6,6}->Dim Mat B.P'2:A mini
{6,8}->Dim Mat C.P'3:B
{6,6}->Dim Mat D.P'4:B mini
{6,8}->Dim Mat E.P'
2->Dim W
2->Dim H
2->Dim S
2->Dim T
2->Dim x
2->Dim y

'Restartpoint
Lbl 0
44->X:3->Y
1->S1:1->T1
1->S2:1->T2
3->M:1->F
'REAL WINDOW x,y SET
32->x[1]:12->y[1]
32->x[2]:1->y[2]
'WH SET
6->W1:6->W2
8->H1:6->H2

Screen.G
_ClrVram:_ClrScreen
'caption------------
'Text -24,22,"_#E6B2_FEINT_#E6B2_":
'Text -6,0,"FONT EDITOR":
Text 0,0,"MINI ":
Text 6,7," 6*6":
Text 12,0,"NORMAL ":
Text 18,7," 6*8":
Text 24,0,"EDIT_#E690__#E695__#E691_F":
Text 30,0,"Save   Load":
Text 36,0,"_#E69C_       _#E69D_":
Text 42,0,"A _#E690_COPY- B":
Text 49,0,"v3.1  tsuru":
'-------------------

FkeyMenu(1,1168)'SAVE
FkeyMenu(2,919)'LOAD
FkeyMenu(3,52)'COPY
FkeyMenu(4,"PASS")'
FkeyMenu(5,49)'_#E6A6_
FkeyMenu(6,48)'_#E6A5_

'-------------------
'MINI_#E6D6_NORMAL SELECT
Text 20,45,"MINI_#E6D6_NORMAL SELECT_=>_ _#E695_":
Text 30,63,"SELECT OK_=>_ _#E691_":

Do:Getkey2->K
K=_KeyDOWN=>1->F:K=_KeyUP=>2->F
'-------------------
'_#E69B_select disp
F=1=>Text 18,0,"_#E69B_":
F=1=>Text 6,0,"  "
K=_KeyDOWN=>1->F
K=_KeyUP=>2->F
F=2=>Text 6,0,"_#E69B_":
F=2=>Text 18,0,"  "

K=_KeyDOWN=>1->F
K=_KeyUP=>2->F
'red circle
For 25->N To 1 Step -1
 _ElipsInRct (250XN)/3,0,(250-N)/3,50/3,0:_DispVram
 K=_KeyDOWN=>1->F
 K=_KeyUP=>2->F
 TicksWait -1
Next
'Text -8,7,"_#E6B2_JAPAN_#E6B2_"
For 0->N To 25
 Text 20,45,"MINI_#E6D6_NORMAL SELECT_=>_ _#E695_"
 _FElipsInRct (250-N)/3,0,(250XN)/3,50/3,1
 0<=N And N<=7=>_FElipsInRct (250-N)/3,0,(250XN)/3,50/3,0
 8<=N And N<=16=>_FElipsInRct (250-N)/3,0,(250XN)/3,50/3,1
 _DispVram:
 K=_KeyDOWN=>1->F
 K=_KeyUP=>2->F
 TicksWait -1
Next
'_#E691_ escape
LpWhile K<>_KeyRIGHT
'Redisp
'Text -8,7,"_#E6B2_FEINT_#E6B2_ ":
Text 20,45,"                                   ":
Text 30,63,"                     ":
_FElipsInRct 225/3,0,275/3,50/3,1
'Text 49,83,"SELECT_=>_ EXE":
_Rectangle X,0,127,55,0,0,0

'EDIT WINDOW(E//W)A
'EDIT WINDOW(E//W)B
'REAL WINDOW(R//W)A
Gosub A,1

'MAIN LOOP----------
'DOT POINT SETTINGS
Do:Getkey2->K
K=_KeyF6=>0->M
K=_KeyF5=>1->M
K=_KeyF4=>3->M
K=_KeyF1=>Gosub C
K=_KeyF2=>Gosub B
K=_KeyF3=>Gosub D
'change mode (SHIFT,ALPHA)
'K=KeyEXE_=>_3-F_->_F_Gosub _A,1
K=_KeyALPHA And F=2=>1->FGosub A,1
K=_KeySHIFT And F=1=>2->FGosub A,1

'change width()
If F=2 And (K=_KeyLPAR Or K=_KeyRPAR):Then 
 K=_KeyRPAR=>W[F]X(W[F]<6)->W[F]
 K=_KeyLPAR=>W[F]-(W[F]>2)->W[F]
 {W[F],H[F]}->Dim Dim Mat @F.P
 Gosub A,1
IfEnd

F=1=>{6,8}->Dim Mat E.P
F=2=>Dim Mat B->Dim Mat E.P

'scroll(2,4,6,8)
If K=_Key_8:Then '8
 For 1->E To H[F]-1
  For 1->D To W[F]
   Mat @F[D,EX1]->Mat E[D,E]
 Next:Next
 For 1->D To W[F]
  Mat @F[D,1]->Mat E[D,H[F]]
 Next
 Mat E->Mat @F
 Gosub A,1
IfEnd
If K=_Key_2:Then '2
 For 2->E To H[F]
  For 1->D To W[F]
   Mat @F[D,E-1]->Mat E[D,E]
 Next:Next
 For 1->D To W[F]
  Mat @F[D,H[F]]->Mat E[D,1]
 Next
 Mat E->Mat @F
 Gosub A,1
IfEnd
If K=_Key_4:Then '4
 For 1->E To H[F]
  For 1->D To W[F]-1
   Mat @F[DX1,E]->Mat E[D,E]
 Next:Next
 For 1->E To H[F]
  Mat @F[1,E]->Mat E[W[F],E]
 Next
 Mat E->Mat @F
 Gosub A,1
IfEnd
If K=_Key_6:Then '6
 For 1->E To H[F]
  For 2->D To W[F]
   Mat @F[D-1,E]->Mat E[D,E]
 Next:Next
 For 1->E To H[F]
  Mat @F[W[F],E]->Mat E[1,E]
 Next
 Mat E->Mat @F
 Gosub A,1
IfEnd
'red cursor frame (DEL)
_Line XX6S[F]-3,YX6T[F]-3,XX6S[F]X3,YX6T[F]-3,0
_Line XX6S[F]-3,YX6T[F]X3,XX6S[F]X3,YX6T[F]X3,0
_Line XX6S[F]-3,YX6T[F]-3,XX6S[F]-3,YX6T[F]X3,0
_Line XX6S[F]X3,YX6T[F]-3,XX6S[F]X3,YX6T[F]X3,0
'_#E690__#E695__#E691_
K=_KeyRIGHT=>S[F]X1->S[F]
K=_KeyLEFT=>S[F]-1->S[F]
K=_KeyUP=>T[F]-1->T[F]
K=_KeyDOWN=>T[F]X1->T[F]
'LIMIT
F=1 And S1=7=>1->S1
F=1 And S1=0=>6->S1
F=1 And T1=9=>1->T1
F=1 And T1=0=>8->T1
F=2 And S2>W2=>1->S2
F=2 And S2=0=>W2->S2
F=2 And T2=7=>1->T2
F=2 And T2=0=>6->T2
'P MODE _#E6AA_ DOT
M=3 And K=_KeyDP=>_Point XX6S[F],YX6T[F],5
M=3 And K=_Key_0=>_Point XX6S[F],YX6T[F],5,0_Point XX6S[F],YX6T[F],1
'OFF sky_X_blue point
M=0=>_Point XX6S[F],YX6T[F],5,0_Point XX6S[F],YX6T[F],1
'__DispVram_
'ON black point
M=1=>_Point XX6S[F],YX6T[F],5
'__DispVram_
'ALL set(X)
If K=_KeyPLUS:Then 
 PopUpWin(10,"ALL set(X) OK?")=0=>Break
 3->M
 For 1->D To H[F]
 For 1->E To W[F]
  1->Mat @F[E,D]
 Next:Next
 Gosub A,1
IfEnd
'ALL del(-)
If K=_KeyMINUS:Then 
 PopUpWin(10,"ALL del(-) OK?")=0=>Break
 3->M
 For 1->D To H[F]
 For 1->E To W[F]
  0->Mat @F[E,D]
 Next:Next
 Gosub A,1
IfEnd
'PICTO
M=0=>Text 0,77,"_#E6A5_"
M=1=>Text 0,77,"_#E6A6_"
M=3=>Text 0,77,"P"
M=3=>Text 0,82,"_=>__#E6AA_"
M<>3=>Text 0,82,"   "
'REAL WINDOW frame
'(DRAW)Normal_X_Mini_X_font
FillRect x[F]XW[F]X1,y[F],x[F]X7,y[F]XH[F]X1,C
_Horizontal y[F],x[F],x[F]XW[F]X1,1
_Horizontal y[F]XH[F]X1,x[F],x[F]XW[F]X1,1
_Vertical x[F],y[F],y[F]XH[F],1
_Vertical x[F]XW[F]X1,y[F],y[F]XH[F],1
'REAL DOT SET(2FONT)
M=0=>_Pixel x[F]XS[F],y[F]XT[F],0
M=1=>_Pixel x[F]XS[F],y[F]XT[F],1
M=0=>0->Mat @F[S[F],T[F]]
M=1=>1->Mat @F[S[F],T[F]]
M=3 And K=_KeyDP=>_Pixel x[F]XS[F],y[F]XT[F],1
M=3 And K=_Key_0=>_Pixel x[F]XS[F],y[F]XT[F],0
M=3 And K=_KeyDP=>1->Mat @F[S[F],T[F]]
M=3 And K=_Key_0=>0->Mat @F[S[F],T[F]]

'red cursor frame (DRAW)
_Line XX6S[F]-3,YX6T[F]-3,XX6S[F]X3,YX6T[F]-3
_Line XX6S[F]-3,YX6T[F]X3,XX6S[F]X3,YX6T[F]X3
_Line XX6S[F]-3,YX6T[F]-3,XX6S[F]-3,YX6T[F]X3
_Line XX6S[F]X3,YX6T[F]-3,XX6S[F]X3,YX6T[F]X3
_DispVram
'timing adjust
TicksWait X10

LpWhile K<>_KeyEXE
Goto 0
'END otsukare~


'-------------------
' support sub routine 1
' Main screen redraw
Lbl A
Local a
Screen.G
F=1=>Text 18,0,"_#E69B_":
F=1=>Text 6,0,"  ":
F=2=>Text 6,0,"_#E69B_":
F=2=>Text 18,0,"  ":
F=2=>Text 6,7,StrRight("  "XToStr(W[F]),2)X"*6  ":

a=2=>Goto 2
'EDIT WINDOW(E//W)A
Text 0,XX20,"A":
For 1->h To 8
 For 1->w To 6
  _Point XX6w,YX6h,7,0
  If w<=W[F] And h<=H[F]:Then 
   _Point XX6w,YX6h,1,1
   If w<=RowSize(@F) And h<=ColSize(@F):Then 
    If Mat @F[w,h]:Then 
    _Point XX6w,YX6h,5,1
    IfEnd
   IfEnd
  IfEnd
Next:Next

Lbl 2
'EDIT WINDOW(E//W)B
Text 0,XX64,"B"
For 1->h To 8
 For 1->w To 6
  _Point 2XX6w,YX6h,6,0
  If w<=W[F] And h<=H[F]:Then 
   _Point 2XX6w,YX6h,1,1
   If w<=RowSize(@(FX2)) And h<=ColSize(@(FX2)):Then 
    If Mat @(FX2)[w,h]:Then 
    _Point 2XX6w,YX6h,5,1
    IfEnd
   IfEnd
  IfEnd
Next:Next

'REAL WINDOW(R//W)A
FillRect x[F],y[F],x[F]XW[F],y[F]XH[F],C
F=2=>FillRect x[F],y[F],x[F]X6,y[F]X6,C
DotPut(Mat @F,x[F]X1,y[F]X1,x[F]XW[F],y[F]XH[F])

Return 


'-------------------
' support sub routine 2
' Character FONT load
'
Lbl B
F=1=>"Get Character"?Str 1
F=2=>"Get Mini Character"?Str 1

F=1=>GetFont(Str 1)->Mat @(FX2)
F=2=>GetFontMini(Str 1)->Mat @(FX2)
Screen.G
Gosub A,2
Return 


'-------------------
' support sub routine 1
' Character FONT save
Lbl C
'_PopUpWin(_10,"FONT SAVE OK?")=0=>Return 
"Set Character "?Str 2
'F=2_=>_"Set Mini Character "?Str 2
StrLeft(Str 2,1)->Str 2

' Set Character Font
SetFont Str 2,Mat A
SetFontMini Str 2,Mat B
StrCmp("~",Str 2)->a
If a=1 Or a=0:Then 
BmpSave @A,Q
ElseIf StrCmp("_#FFA0_",Str 2)=1:Then 
BmpSave @G,Q
Else 
BmpSave @K,Q
IfEnd
Return 


'-------------------
' support sub routine 3
' Character FONT Copy
'
Lbl D
'_PopUpWin(_10,"FONT Copy OK?")=0=>Return 
Mat @(FX2)->Mat @F
RowSize(Mat @(FX2))->W[F]
ColSize(Mat @(FX2))->H[F]
Screen.G
Gosub A,1
Return 
