2020-09-20 23:49:36 +02:00
|
|
|
%import syslib
|
|
|
|
%import textio
|
|
|
|
%import floats
|
2019-02-03 00:14:56 +01:00
|
|
|
%zeropage basicsafe
|
2019-01-24 21:45:50 +01:00
|
|
|
|
2020-09-22 01:34:05 +02:00
|
|
|
; Note: this program is compatible with C64 and CX16.
|
2018-11-25 01:17:39 +01:00
|
|
|
|
2019-07-29 23:11:13 +02:00
|
|
|
main {
|
2018-11-25 01:17:39 +01:00
|
|
|
|
2018-12-18 15:12:56 +01:00
|
|
|
sub start() {
|
2018-11-25 01:17:39 +01:00
|
|
|
|
2020-09-19 22:37:24 +02:00
|
|
|
txt.lowercase()
|
2018-11-25 01:17:39 +01:00
|
|
|
|
2019-01-15 21:35:15 +01:00
|
|
|
; use optimized routine to write text
|
2020-08-27 18:10:22 +02:00
|
|
|
txt.print("Hello!\n")
|
2018-12-18 15:12:56 +01:00
|
|
|
|
|
|
|
; use iteration to write text
|
2019-01-15 21:35:15 +01:00
|
|
|
str question = "How are you?\n"
|
2019-08-18 03:16:23 +02:00
|
|
|
ubyte char
|
|
|
|
for char in question
|
2020-09-22 01:34:05 +02:00
|
|
|
txt.chrout(char)
|
2018-12-18 15:12:56 +01:00
|
|
|
|
2019-01-15 21:35:15 +01:00
|
|
|
; use indexed loop to write characters
|
2018-12-18 15:12:56 +01:00
|
|
|
str bye = "Goodbye!\n"
|
2020-02-07 01:22:07 +01:00
|
|
|
for char in 0 to len(bye)-1
|
2020-09-22 01:34:05 +02:00
|
|
|
txt.chrout(bye[char])
|
|
|
|
|
|
|
|
ubyte time_lo
|
|
|
|
ubyte time_mid
|
|
|
|
ubyte time_hi
|
|
|
|
|
|
|
|
%asm {{
|
|
|
|
stx P8ZP_SCRATCH_REG
|
|
|
|
jsr c64.RDTIM ; A/X/Y
|
|
|
|
sta time_lo
|
|
|
|
stx time_mid
|
|
|
|
sty time_hi
|
|
|
|
ldx P8ZP_SCRATCH_REG
|
|
|
|
}}
|
|
|
|
|
|
|
|
float clock_seconds = ((mkword(time_mid, time_lo) as float) + (time_hi as float)*65536.0) / 60
|
2019-01-24 23:31:16 +01:00
|
|
|
float hours = floor(clock_seconds / 3600)
|
|
|
|
clock_seconds -= hours*3600
|
|
|
|
float minutes = floor(clock_seconds / 60)
|
|
|
|
clock_seconds = floor(clock_seconds - minutes * 60.0)
|
2019-01-24 21:45:50 +01:00
|
|
|
|
2020-09-22 01:34:05 +02:00
|
|
|
txt.print("system time (jiffy clock) is ")
|
2020-09-20 23:49:36 +02:00
|
|
|
floats.print_f(hours)
|
2020-09-22 01:34:05 +02:00
|
|
|
txt.chrout(':')
|
2020-09-20 23:49:36 +02:00
|
|
|
floats.print_f(minutes)
|
2020-09-22 01:34:05 +02:00
|
|
|
txt.chrout(':')
|
2020-09-20 23:49:36 +02:00
|
|
|
floats.print_f(clock_seconds)
|
2020-09-22 01:34:05 +02:00
|
|
|
txt.chrout('\n')
|
2020-02-07 01:22:07 +01:00
|
|
|
|
2020-08-27 18:10:22 +02:00
|
|
|
txt.print("bye!\n")
|
2020-03-13 00:27:33 +01:00
|
|
|
}
|
2018-11-25 01:17:39 +01:00
|
|
|
}
|