I made a rework by avoiding the EMIT word which extensive looping is making the output slow.
By creating string buffers then using the word OUTPUT (probably similar in BASIC; see previous exchanges), it looks better (weird interferences in EMU71 are not seen anymore). Thanks for all supportive hints in this thread.
The result is a mix of further actions for a smooth update:
- string buffers with maximum 255 char long
- only the necessary number will be updated (frame draw one time; draw of HH MM SS only after check this is necessary)
- no date update check (if you keep it running 1 week, only the time will change)
The test on an hardware is still open (all test in EMU71 and Video80 done).
So far working.. (Linux 64bits PC starting windows binaries from ILPER ILVIDEO80 EMU71)
Clock in Video80 with EMU71 and Forth.
a) install timeasm
b) install HP71B1 and CLOCK; see below
c) start with STARTCLO: you have now a good looking clock (fonts mostly from Sylvain Cote proposal)
d) EXIT with pressing the key E
HP71B1
Code:
VARIABLE CELLV
HERE 0 , HERE SWAP - CELLV !
-1 CONSTANT TRUE
0 CONSTANT FALSE
: >= < 0= ;
: 0<> 0= 0= ;
: .R >R S->D R> D.R ;
: D0= OR 0= ;
: D= D- D0= ;
: 2, , , ;
: 2! SWAP OVER ! 5+ ! ;
: 2@ DUP 5+ @ SWAP @ ;
: 2CONSTANT CREATE , , DOES> 2@ ;
: 2VARIABLE CREATE 0 , 0 , DOES> ;
: 2NIP 2SWAP 2DROP ;
: AT-XY 27 EMIT 37 EMIT SWAP EMIT EMIT ;
: AT-XY<BF 2SWAP 27 CHR$ S<& 37 CHR$ S<& 4 ROLL CHR$ S<& ROT
CHR$ S<& ;
: BLANK 20 FILL ;
: CELLS 5 * ;
: CELL+ 5+ ;
: CELL- 5- ;
: CHAR+ 2+ ;
: CHAR- 2- ;
: CHAR BL WORD CHAR+ C@ ;
: NIP SWAP DROP ;
: N>$ S->D STR$ ;
: ON TRUE SWAP ! ;
: OFF FALSE SWAP ! ;
: PAGE 27 EMIT 69 EMIT ;
: WITHIN OVER - >R - R> U< ;
: VALUE CREATE , DOES> @ ;
: CHARS 2* ;
: COMPARE S= 0<> ;
: MS 0 DO LOOP ;
: PERFORM @ EXECUTE ;
: -ROT ROT ROT ;
: PMOD DUP -ROT MOD DUP 0< IF + ELSE NIP THEN ;
: STRDUMP OVER 0 DO DUP I SWAP MOD 0= IF CR ELSE THEN -ROT C@+ .
ROT " " TYPE LOOP 2DROP ;
CLOCK
Code:
76 STRING LINEBUF 180 STRING SIDEBUF 84 STRING NBBUFSTR
32 STRING SEPBUFSTR 56 10 STRING-ARRAY NUMBCLO
" ########## #### #### #### #### ##########"
1 NUMBCLO S!
" ## ## ## ## ## ## ## "
2 NUMBCLO S!
" ######## ## ############ ## ########"
3 NUMBCLO S!
" ######## ## ## ####### ## ##########"
4 NUMBCLO S!
" ## ## ## ########## ## ## ##"
5 NUMBCLO S!
" ########## ## ######## ## ##########"
6 NUMBCLO S!
" ########## ## ########## #### ##########"
7 NUMBCLO S!
" ######## ## ## ## ## ## ##"
8 NUMBCLO S!
" ########## #### ############ #### ##########"
9 NUMBCLO S!
" ########## #### ########## ## ##########"
10 NUMBCLO S!
VARIABLE YY VARIABLE MM VARIABLE DD
: DATESET " DATE$" BASIC$ 2 LEFT$ VAL DROP YY ! PAD 1 CHARS +
COUNT DROP 8 4 5 SUB$ VAL DROP MM ! PAD 1 CHARS + COUNT DROP 8
2 RIGHT$ VAL DROP DD ! ;
VARIABLE TIMEHH VARIABLE TIMEMM VARIABLE TIMESS
VARIABLE TIMEHH-N VARIABLE TIMEMM-N VARIABLE TIMESS-N
: TIMEINIT -1 TIMEHH ! -1 TIMEMM ! -1 TIMESS ! ;
: TIMEUPDT TIME FTOI DUP 3600 / TIMEHH ! 3600 MOD DUP 60 /
TIMEMM ! 60 MOD TIMESS ! ;
: TIMEUPDT-N TIME FTOI DUP 3600 / TIMEHH-N ! 3600 MOD DUP 60 /
TIMEMM-N ! 60 MOD TIMESS-N ! ;
: CLEARSTR DROP DUP 1 CHARS - 0 SWAP C! 0 ;
72 STRING LCLO
" +----------------------------------------------------------------------+"
LCLO S!
: DRAW-LINES LINEBUF CLEARSTR 1 1 AT-XY<BF LCLO S<& OUTPUT
LINEBUF CLEARSTR 1 11 AT-XY<BF LCLO S<& OUTPUT LINEBUF CLEARSTR
1 21 AT-XY<BF LCLO S<& OUTPUT ;
: DRAW-SIDES SIDEBUF CLEARSTR 11 2 DO 1 I AT-XY<BF " |" S<& 72
I AT-XY<BF " |" S<& LOOP 21 12 DO 1 I AT-XY<BF " |" S<& 72 I
AT-XY<BF " |" S<& LOOP OUTPUT ;
: DRAW-FRAMEC DRAW-LINES DRAW-SIDES ;
: DRAW-SEP SEPBUFSTR CLEARSTR 24 6 AT-XY<BF " ##" S<& 48 6
AT-XY<BF " ##" S<& 25 15 AT-XY<BF " #" S<& 49 15 AT-XY<BF " #"
S<& 25 17 AT-XY<BF " #" S<& 49 17 AT-XY<BF " #" S<& OUTPUT ;
: OUTNB NBBUFSTR CLEARSTR ROT 1 + NUMBCLO 2SWAP 8 1 DO 6 PICK
6 PICK I + 1 - AT-XY<BF 2OVER I 1 - 8 * 1 + I 8 * SUB$ S<& LOOP
2NIP 2NIP OUTPUT ;
: DRAW-DATE 4 3 YY @ 10 / OUTNB 14 3 YY @ 10 MOD OUTNB 28 3 MM
@ 10 / OUTNB 38 3 MM @ 10 MOD OUTNB 52 3 DD @ 10 / OUTNB 62 3
DD @ 10 MOD OUTNB ;
: UPDATE-SS TIMESS-N @ 10 / DUP TIMESS @ 10 / <> IF 52 13 ROT
OUTNB ELSE DROP THEN TIMESS-N @ 10 MOD DUP TIMESS @ 10 MOD <>
IF 62 13 ROT OUTNB ELSE DROP THEN ;
: UPDATE-MM TIMEMM-N @ 10 / DUP TIMEMM @ 10 / <> IF 28 13
ROT OUTNB ELSE DROP THEN TIMEMM-N @ 10 MOD DUP TIMEMM @ 10 MOD
<> IF 38 13 ROT OUTNB ELSE DROP THEN ;
: UPDATE-HH TIMEHH-N @ 10 / DUP TIMEHH @ 10 / <> IF 4 13 ROT
OUTNB ELSE DROP THEN TIMEHH-N @ 10 MOD DUP TIMEHH @ 10 MOD <>
IF 14 13 ROT OUTNB ELSE DROP THEN ;
: INITCLO DELAY00 PAGE DRAW-FRAMEC DRAW-SEP DATESET DRAW-DATE
TIMEINIT TIMEUPDT-N UPDATE-SS UPDATE-MM UPDATE-HH ;
: UPDATE-CLOCK TIMEUPDT-N TIMEHH @ TIMEHH-N @ <> IF UPDATE-HH
UPDATE-MM UPDATE-SS TIMEHH-N @ TIMEHH ! TIMEMM-N @ TIMEMM !
TIMESS-N @ TIMESS ! ELSE TIMEMM @ TIMEMM-N @ <> IF UPDATE-MM
UPDATE-SS TIMEMM-N @ TIMEMM ! TIMESS-N @ TIMESS ! ELSE TIMESS @
TIMESS-N @ <> IF UPDATE-SS TIMESS-N @ TIMESS ! ELSE THEN THEN
THEN ;
: RETIMELO BEGIN UPDATE-CLOCK ?TERMINAL IF KEY DUP 69 <> IF
101 <> IF FALSE ELSE TRUE THEN ELSE DROP TRUE THEN ELSE FALSE
THEN UNTIL ;
: STARTCLO INITCLO RETIMELO ;
This was worked out on a cross-development based on gforth. Presentation of details planned so far for Allschwill 2024. An additional layer for retranscription of HP71B word into gforth words was necessary (subject still in development; so far all float, integer, string words retranscriptions available).
words in FORTHRAM
LIST
Code:
STARTCLO
RETIMELO
UPDATE-CLOCK
INITCLO
UPDATE-HH
UPDATE-MM
UPDATE-SS
DRAW-DATE
OUTNB
DRAW-SEP
DRAW-FRAMEC
DRAW-SIDES
DRAW-LINES
LCLO
CLEARSTR
TIMEUPDT-N
TIMEUPDT
TIMEINIT
TIMESS-N
TIMEMM-N
TIMEHH-N
TIMESS
TIMEMM
TIMEHH
DATESET
DD
MM
YY
NUMBCLO
SEPBUFSTR
NBBUFSTR
SIDEBUF
LINEBUF
STRDUMP
PMOD
-ROT
PERFORM
MS
COMPARE
CHARS
VALUE
WITHIN
PAGE
OFF
ON
N>$
NIP
CHAR
CHAR-
CHAR+
CELL-
CELL+
CELLS
BLANK
AT-XY<BF
AT-XY
2NIP
2VARIABLE
2CONSTANT
2@
2!
2,
D=
D0=
.R
0<>
>=
FALSE
TRUE
CELLV
TIMED
SKIP
PRINT
FINDW
FSCRATCH
LIST
BREAK
FINISH
CONT
BP
STEP
READYSTEP
SST
SSTOUT
SSTERROR
NEWRTN
RTNSAVE
RS.
UN:
UN:C
WORD@
WORDNAME
FTEMP
"STR
+ADDR
5SP
'END
HERE0
ENDA
HEREN
'NAME
SPEC?
SPECIAL
NFASTR
NAME
NFA
ADDR-
S.
ROOM?
D-R
D-D
D-*
D-P
DELAY00
BASE?
SHOW
DUMP+
DUMP
N-A
PAUSE
PAUSELEN
TIME
BRRUN
DOSST
TIME
UPDATE 29Nov2023. When using the HP71B hardware (and ILPER and VIDEO), initialize the variable PRIMARY to zero with 0 PRIMARY ! (else it will put the data into the corresponding device like printer or others which are in the loop)