.( loading graphic editor ) update D> \listF\listLIB\5TH_GFX2 modulechk D> \listF\listLIB\5TH_DRVMOUSE modulechk .( gedit - load existing image ) .( geditnew - start new image ) .( EGh - graphic editor help ) var ghandle var sizex var sizey var zoomx var zoomy var zoomup var zoom var selcol var gbrush 1 vari geditcycdir 5 vari geditcyccur Dstral const EGfile str F1 - help" msghelp str pick the color" msgpick str draw pixels" msgpix str fill with color" msgfill Dstr \listF\TXT_EG" tmphlpfile : EGh tmphlpfile fs. ; : gclose ghandle @ dup if dynde ghandle off else drop then ; : geditmsg ( addr -- ) ghandle @ emitscreen ! 1A 3B at! 14 do space loop 1A 3B at! write screen emitscreen ! ; : zoomupdate zoom @ if 14 do 14 do i 4 * 226 + dup 4 + i2 4 * 1+ dup 4 + ghandle @ i zoomx @ + i2 zoomy @ + screen point c@ boxf loop loop then ; : selcoldisp 226 27F 55 64 ghandle @ selcol @ boxf ; var tmp1 : grinit ghandle @ 0 = if 280 1E0 imgalloc ghandle ! then ghandle @ cls tmp1 off ( display palette ) 24 do 6 do i2 5 * dup 5 + i 5 * 1C2 + dup 5 + ghandle @ tmp1 @ boxf tmp1 @ 1+ tmp1 ! loop loop [ FF FF FF calccol ] sizex @ 1+ 0 sizey @ 1+ 0 ghandle @ box [ FF FF FF calccol ] 276 225 51 0 ghandle @ box [ FF FF FF calccol ] selcol ! selcoldisp B4 C8 1C2 1DF ghandle @ FF boxf msghelp geditmsg ; rh tmp1 : geditpict ( x y -- ) push push 1 i sizex @ bound? if 1 i2 sizey @ bound? if gbrush @ dup 2 = if selcol @ i i2 ghandle @ pset zoomup on then 3 = if sizex @ sizey @ imgalloc ghandle @ dynp over dynp -1 -1 vidput dup push selcol @ i2 1- i3 1- pop imgfill dup dynp ghandle @ dynp 1 1 vidput dynde zoomup on then then then pop pop 2drop ; : gsavepict sizex @ sizey @ imgalloc ( imgbuf ) ghandle @ dynp over dynp -1 -1 vidput dup EGfile fsDsave dynde ; : ged ghandle @ if until ghandle @ dynp screen dynp 4B008 cmove zoomup @ if zoomupdate zoomup off then KBD_F@ dup 1+ if dup 400 = if done then ( ESC ) dup 401 = if tmphlpfile fsdisp then ( F1 ) dup 402 = if gsavepict then ( F2 ) dup 405 = if msgpick geditmsg 1 gbrush ! then ( F5 ) dup 406 = if msgpix geditmsg 2 gbrush ! then ( F6 ) 407 = if msgfill geditmsg 3 gbrush ! then ( F7 ) else drop then mousekeyr @ if 0 mousex @ A - sizex @ 12 - bound zoomx ! 0 mousey @ A - sizey @ 12 - bound zoomy ! zoom on ghandle @ emitscreen ! 45 1D at! zoomx @ . space zoomy @ . space space space space screen emitscreen ! zoomupdate then mousekeyl @ if gbrush @ 1 = if mousex @ mousey @ ghandle @ point c@ selcol ! selcoldisp else 225 mousex @ 276 bound? if 0 mousey @ 51 bound? if mousex @ 225 - 4 / zoomx @ + mousey @ 1- 4 / zoomy @ + geditpict then then mousex @ mousey @ geditpict then then mousedo update geditcyccur @ geditcycdir @ + dup geditcyccur ! dup dup dup FF setpal 1 swap 3E bound? 0 = if geditcycdir @ neg geditcycdir ! then loop screen cls else ." no picture loaded" then ; : gedit ( file -- ) dup EGfile str2Dstr ! fsDloadnew ( imgbuf ) dup imgsize sizey ! sizex ! grinit dup dynp ghandle @ dynp 1 1 vidput dynde ged ; : geditnew ( xsize ysize -- ) sizey ! sizex ! grinit ged ; rh tmphlpfile rh ghandle rh sizex rh sizey rh zoomx rh zoomy rh zoomup rh zoom rh gclose rh geditmsg rh zoomupdate rh selcoldisp rh grinit rh geditpict rh gsavepict rh ged rh selcol rh msghelp rh msgpix rh msgpick rh msgfill rh gbrush rh geditcycdir rh geditcyccur rh EGfile