Timer on the screen countdown

Page 3/5
1 | 2 | | 4 | 5

By Dolphin101546015

Master (254)

Dolphin101546015's picture

10-04-2020, 02:24

My X-Basic version with ASCII Art Smile
Time settings by CURSOR KEYs and ENTER.
SPACE - Exit program
Setup storing to memory and restore after program runing again:

10 SET BEEP 1,4
20 _TURBO ON
30 DEFINTA-Z:DIM T(4):COLOR 15,0,0:FOR I=0 TO 255:VPOKE&H800+I,0:NEXT I
40 VDP(13)=&HF4:VDP(14)=&HF0
50 IF PEEK(&HD003)=13THEN T(1)=PEEK(&HD000):T(2)=PEEK(&HD001):T(3)=PEEK(&HD002)
60 Y=1:MX=99:CLS:PRINT"Setup timer":VPOKE&H80B,224
70 PRINT"Hours  :";T(1):PRINT"Minutes:";T(2):PRINT"Seconds:";T(3)
80 A=STICK(0):T(Y)=T(Y)-((A=3)AND(T(Y)0))
90 IF INKEY$=CHR$(13) THEN VPOKE&H800+Y*10+1,0:Y=Y+1:IF Y<4 THEN MX=59:VPOKE&H800+Y*10+1,224 ELSE 120
100 TIME=0
110 IF TIME<6 GOTO 110 ELSE LOCATE 8,Y:PRINTT(Y):GOTO 80
120 CLS:POKE&HD003,13:POKE&HD000,T(1):POKE&HD001,T(2):POKE&HD002,T(3)
130 H$=STR$(T(1)):M$=STR$(T(2)):S$=STR$(T(3))
140 IF LEN(H$)<3 THEN H$="0"+RIGHT$(H$,1) ELSE H$=RIGHT$(H$,2)
150 IF LEN(M$)<3 THEN M$="0"+RIGHT$(M$,1) ELSE M$=RIGHT$(M$,2)
160 IF LEN(S$)<3 THEN S$="0"+RIGHT$(S$,1) ELSE S$=RIGHT$(S$,2)
170 IF T(1)=0 AND T(2)=0 AND T(3)<10 THEN BEEP:COLOR 15,6,6
180 O$=H$+":"+M$+":"+S$:FOR Y=0TO7:Y1=Y*80
190 FOR X=1TOLEN(O$):CH=ASC(MID$(O$,X,1))
200 MS=128:CD=PEEK(&H1BBF+CH*8+Y):X1=X*8
210 FOR I=0TO7:IF CD AND MS THEN C=CH ELSE C=0
220 VPOKEY1+X1+I,C:MS=MS/2:NEXT I
230 IF STRIG(0) GOTO 280 ELSE NEXT X,Y
240 TM=TIME/60:IF TM=OT GOTO 240 ELSE OT=TM
250 T(3)=T(3)-1:IF T(3)>=0 GOTO 130 ELSE T(3)=59
260 T(2)=T(2)-1:IF T(2)>=0 GOTO 130 ELSE T(2)=59
270 T(1)=T(1)-1:IF T(1)>=0 GOTO 130
280 FOR I=0 TO 10:BEEP:NEXT I:CLS:COLOR 15,0,0
290 _TURBO OFF

By gdx

Prophet (3427)

gdx's picture

10-04-2020, 02:18

Line 300 is used when the hour is entered.
CTRL-STOP is used to quit the timer.
The line 110 is to reset the timer.

By Dolphin101546015

Master (254)

Dolphin101546015's picture

10-04-2020, 08:12

Another version with big digits and blinking divisors:

10 SET BEEP 1,4:COLOR=(6,2,0,0)
20 _TURBO ON
30 DEFINTA-Z:DIM T(4):COLOR 15,0,0:FOR I=0 TO 255:VPOKE&H800+I,0:NEXT I
40 IF PEEK(&HD003)=13THEN T(1)=PEEK(&HD000):T(2)=PEEK(&HD001):T(3)=PEEK(&HD002)
50 Y=1:MX=23:CLS:PRINT"Setup timer":VPOKE&H80B,224:VDP(13)=&HF4:VDP(14)=&HF0
60 PRINT"Hours  :";T(1):PRINT"Minutes:";T(2):PRINT"Seconds:";T(3)
70 A=STICK(0):T(Y)=T(Y)-((A=3)AND(T(Y)0))
80 IF INKEY$=CHR$(13) OR A=5 THEN VPOKE&H800+Y*10+1,0:Y=Y+1:IF Y<4 THEN MX=59:VPOKE&H800+Y*10+1,224 ELSE 110
90 TIME=0
100 IF TIME<4 GOTO 100 ELSE LOCATE 8,Y:PRINTT(Y):GOTO 70
110 CLS:POKE&HD003,13:POKE&HD000,T(1):POKE&HD001,T(2):POKE&HD002,T(3)
120 H$=STR$(T(1)):M$=STR$(T(2)):S$=STR$(T(3))
130 IF LEN(H$)<3 THEN H$="0"+RIGHT$(H$,1) ELSE H$=RIGHT$(H$,2)
140 IF LEN(M$)<3 THEN M$="0"+RIGHT$(M$,1) ELSE M$=RIGHT$(M$,2)
150 IF LEN(S$)<3 THEN S$="0"+RIGHT$(S$,1) ELSE S$=RIGHT$(S$,2)
160 IF T(1)=0 AND T(2)=0 AND T(3)<10 THEN BEEP:COLOR 15,6,6
170 I=160:CF=CF XOR 156:VPOKE I+25,CF:VPOKEI+54,CF:I=I+240:VPOKE I+25,CF:VPOKEI+54,CF
180 O$=H$+M$+S$:FORY=0TO7:X1=0:Y1=Y*80:FOR X=1TO6:CH=ASC(MID$(O$,X,1))
190 MS=128:CD=PEEK(&H1BBF+CH*8+Y):X1=X1+12:IF (X=3) OR (X=5) THEN X1=X1+5
200 FORI=0TO5:IFCDANDMSTHEN C=CH ELSE C=0
210 VPOKEY1+X1+I*2-12,C:VPOKEY1+X1+I*2-11,C:MS=MS/2:NEXT I:IF STRIG(0) GOTO 260 ELSE NEXT X,Y
220 TM=TIME/60:IF TM=OT GOTO 220 ELSE OT=TM
230 T(3)=T(3)-1:IF T(3)>=0 GOTO 120 ELSE T(3)=59
240 T(2)=T(2)-1:IF T(2)>=0 GOTO 120 ELSE T(2)=59
250 T(1)=T(1)-1:IF T(1)>=0 GOTO 120
260 FOR I=0 TO 10:BEEP:NEXT I:CLS:COLOR 15,0,0
270 _TURBO OFF

By Dolphin101546015

Master (254)

Dolphin101546015's picture

10-04-2020, 10:00

And last one mod Pro version with pseudographic and PSG beeper at the end:

10 _TURBO ON
20 DEFINTA-Z:DIM T(4):COLOR 15,0,0:FOR I=0 TO 255:VPOKE&H800+I,0:NEXT I
30 FORI=0TO10:READA:OUT&HA0,I:OUT&HA1,A:VPOKE&H14F8+I,127:NEXTI:COLOR=(6,2,0,0)
40 IF PEEK(&HD003)=13THEN T(1)=PEEK(&HD000):T(2)=PEEK(&HD001):T(3)=PEEK(&HD002)
50 Y=1:MX=99:CLS:PRINT"Setup timer":VPOKE&H80B,224:VDP(13)=&HF4:VDP(14)=&HF0
60 PRINT"Hours  :";T(1):PRINT"Minutes:";T(2):PRINT"Seconds:";T(3)
70 A=STICK(0):T(Y)=T(Y)-((A=3)AND(T(Y)0))
80 IF INKEY$=CHR$(13) OR A=5 THEN VPOKE&H800+Y*10+1,0:Y=Y+1:IF Y<4 THEN MX=59:VPOKE&H800+Y*10+1,224 ELSE 110
90 TIME=0:VPOKE&H14F8,0:DATA 100,0,0,0,0,0,0,28,0,0,0
100 IF TIME<4 GOTO 100 ELSE LOCATE 8,Y:PRINTT(Y):GOTO 70
110 CLS:POKE&HD003,13:POKE&HD000,T(1):POKE&HD001,T(2):POKE&HD002,T(3)
120 H$=STR$(T(1)):M$=STR$(T(2)):S$=STR$(T(3)):CF=CFXOR156
130 IF LEN(H$)<3 THEN H$="0"+RIGHT$(H$,1) ELSE H$=RIGHT$(H$,2)
140 IF LEN(M$)<3 THEN M$="0"+RIGHT$(M$,1) ELSE M$=RIGHT$(M$,2)
150 IF LEN(S$)<3 THEN S$="0"+RIGHT$(S$,1) ELSE S$=RIGHT$(S$,2)
160 IF T(1)=0ANDT(2)=0ANDT(3)<6ANDT(3)>0 THEN OUT&HA0,8:OUT&HA1,12:COLOR 15,6,6
170 I=160:VPOKEI+25,CF:VPOKEI+54,CF:I=I+240:VPOKEI+25,CF:VPOKEI+54,CF
180 O$=H$+M$+S$:FORY=0TO7:X1=0:Y1=Y*80:FOR X=1TO6:CH=ASC(MID$(O$,X,1))
190 MS=128:CD=PEEK(&H1BBF+CH*8+Y):X1=X1+12:IF (X=3) OR (X=5) THEN X1=X1+5
200 FORI=0TO5:IFCDANDMSTHEN C=159 ELSE C=0' c=ch for ASCII
210 VPOKEY1+X1+I*2-12,C:VPOKEY1+X1+I*2-11,C:MS=MS/2:NEXT I:IF STRIG(0) GOTO 260 ELSE NEXT X,Y:OUT&HA0,8:OUT&HA1,0
220 TM=TIME/60:IF TM=OT GOTO 220 ELSE OT=TM
230 T(3)=T(3)-1:IF T(3)>=0 GOTO 120 ELSE T(3)=59
240 T(2)=T(2)-1:IF T(2)>=0 GOTO 120 ELSE T(2)=59
250 T(1)=T(1)-1:IF T(1)>=0 GOTO 120
260 OUT&HA0,0:OUT&HA1,50:OUT&HA0,8:OUT&HA1,12:TIME=0
270 IFTIME<99GOTO270ELSECLS:COLOR15,0,0:OUT&HA0,0:OUT&HA1,0:OUT&HA0,8:OUT&HA1,0
280 _TURBO OFF

Actualy I trying it for fun, but now understand, how it useful and convinient!
Thank you! Cool

By gdx

Prophet (3427)

gdx's picture

10-04-2020, 12:28

Dolphin101546015,

I tried your first program and a syntax error occurs at the line 80. It's weird since this line hasn't changed in the other two versions.

PS: Why do you use X-Basic? The speed of the Basic is sufficient to make a Timer.

By Dolphin101546015

Master (254)

Dolphin101546015's picture

10-04-2020, 15:42

gdx wrote:

Dolphin101546015,

I tried your first program and a syntax error occurs at the line 80. It's weird since this line hasn't changed in the other two versions.

PS: Why do you use X-Basic? The speed of the Basic is sufficient to make a Timer.

I post only code when it tested.
I using X-Basic, coz out is possible inside one second with it.

By Grauw

Ascended (8905)

Grauw's picture

10-04-2020, 15:53

@gdx Use the quote button to copy/paste the source code. There are <’s in it and it wasn’t escaped as &lt; so it doesn’t show up due to the forum software.

By gdx

Prophet (3427)

gdx's picture

10-04-2020, 16:49

Lately, I can't edit or quote the messages. Something must have changed.
I have displayed the source code but I do not see any coded characters.

Where should it be?

By Dolphin101546015

Master (254)

Dolphin101546015's picture

10-04-2020, 19:42

Shocked!
Here all 3 versions

If someone want it :)
All 3 progs require MSX2 screen0 mode with width 80.

X-Basic might be loaded from GIT with font editor.

By Grauw

Ascended (8905)

Grauw's picture

10-04-2020, 20:20

gdx wrote:

Lately, I can't edit or quote the messages. Something must have changed.
I have displayed the source code but I do not see any coded characters.
Where should it be?

That’s strange, it works fine here. Maybe try to clear cookies and re-login?

Line 80 of Dolphin’s first version and line 70 of versions two and three should be:

A=STICK(0):T(Y)=T(Y)-((A=3)AND(T(Y)<MX))+((A=7)AND(T(Y)>0))

I think the rest of the code displays correctly.

Page 3/5
1 | 2 | | 4 | 5