\ BAR GRAPH ON BOB load screen 2005.11.17 \ BY CURTIS SCHREIER \ THE ARCHITECT OF DESIRE \ grundhog@travelin.com STRUCTURE OF BAR 2005.11.01 natural structure of engineering value |<- MAXVAL ->| |------------------+-----------| VALUE |<- VAL ->| structure of bar printed on screen Using MOD (rem quo) we get whole blocks and index to cross character |<- MAXBAR finest grain ->| |<- XVAL ->| | 6 x number of characters |-----------------|||----------| send characters | SLICES=6 from ram font | WHOLES # REST | cross moves -|- | . . . . . . SEGS . . . . . . | 6 places in block (characters in bar) HEX \ basic serial moves to BOB based on SEMIT 2005.10.22 : S{ 7B SEMIT ; \ BOB command prefix= { : (#) <# # #> ; \ format 1 digit : (##) <# # # #> ; \ format 2 digit : (#PH) <# # # 2E HOLD # # #> ; \ format xx.xx 4 digit & dot : >RAM S{ 54 SEMIT 34 SEMIT ; \ {T4 print ram chars : >TXT S{ 54 SEMIT 30 SEMIT ; \ {T0 print text chars : SCLR >TXT S{ 41 SEMIT 31 SEMIT 37 SEMIT ; \ {A17 wipe scrn : S-CR 0D SEMIT ; \ send CR : SSPACE 20 SEMIT ; \ send space : S. ( n-- ) S>D (.) STYPE SSPACE ; \ full number print : S#. ( n-- ) S>D (#) STYPE ; \ single digit print : S##. ( n-- ) S>D (##) STYPE ; \ 2 digits print DECIMAL : SPH. ( #### -- ) 1400 MIN S>D (#PH) STYPE SSPACE ; \ print 4 dig fixed pt like pH \ scaled bar to BOB basic resources 2005.11.15 DECIMAL 6 CONSTANT SLICES \ slice character into strips 20 CONSTANT SEGS \ text boxes full bar width SLICES SEGS * 1- CONSTANT MAXBAR \ finest grain in bar VARIABLE #WHOLES \ leading boxes line VARIABLE REST \ trling boxes line or blank VARIABLE #EMIT \ ram characters VARIABLE MAXVAL \ unscaled value maximum 1000 MAXVAL ! \ trial value VARIABLE XVAL \ scaled value, BOB ready 06 CONSTANT WHOLIN \ represents value 00 CONSTANT RESTLIN \ represents blank space : SCALE ( N -- n ) MAXVAL @ MIN \ check limit MAXBAR MAXVAL @ */ ; \ standard scaling techniq \ make the scaled bar 2005.11.16 HEX : LIN-DRAW ( char quan -- ) \ draw horiz line char FOR DUP SEMIT NEXT DROP ; \ : BAR ( N -- ) \ draw scaled bar SLICES /MOD ( rem quo ) \ DUP WHOLIN SWAP LIN-DRAW \ draw WHOLE blocks SWAP DUP 0= IF SEMIT \ draw cross or ELSE 11 + SEMIT \ end-of-bar character THEN SEGS SWAP - 1- ( rest ) \ draw REST of blocks RESTLIN SWAP LIN-DRAW ; : SGOTO ( col row -- ) \ position cursor " {C" COUNT STYPE SWAP S##. S##. ; \ print the number, scale it and bar to BOB 2005.11.16 DECIMAL : .BAR ( n -- ) \ print number & bar under >TXT DUP S. SSPACE SSPACE S-CR \ the number >RAM SCALE BAR >TXT S-CR ; \ the bar \ MOUSE READ a test of pygmy and bob screen \ Particular to Pygmy Forth \ tracks the mouse movement on the PC screen and prints \ x and y coors via bars on BOB screen \ mouse on PC text screen : MT M+CUR SCLR BEGIN M@P/S 0= WHILE SWAP 0 0 SGOTO .BAR S-CR .BAR REPEAT ; : SAYS 0 6 SGOTO " Click to stop" COUNT STYPE ; \ mouse on PC grafx screen : M0 HIGPH 0 0 635 435 LINE! 635 0 0 435 LINE! SAYS MT CLR80 ; \ draws big x, cursor on main scrn \ mouse coords & bars to bob \ M+CUR start mouse with cursor M@P/S ( -- x y click ) \ setup for BOB screen, doublesize letters 2005.11.17 \ Set SCOLOR and SRAMCOLOR to provide contrasting backgds \ for best bar effect VARIABLE SCOLOR 7 SCOLOR ! \ display bkg 0blk 1red 2grn 3yel VARIABLE STXTCOLOR 1 STXTCOLOR ! \ letters 4blu 5mag 6cyn 7wht VARIABLE SRAMCOLOR 0 SRAMCOLOR ! \ ram grfx backgrounds : SET-BOB >TXT 17 FOR " {L" COUNT STYPE I S##. " 11" COUNT STYPE SSPACE NEXT 17 FOR " {I" COUNT STYPE I S##. " 0" COUNT STYPE SSPACE NEXT " {MI" COUNT STYPE SSPACE \ no outline " {D" COUNT STYPE SCOLOR @ S#. SSPACE \ char bkd " {E" COUNT STYPE STXTCOLOR @ S#. SSPACE \ char color " {F" COUNT STYPE SCOLOR @ S#. SSPACE \ scrn color " {U" COUNT STYPE SRAMCOLOR @ S#. SSPACE \ ram char bkd " {T0" COUNT STYPE ;