prog8/examples/cx16/datetime.p8

61 lines
1.4 KiB
Plaintext
Raw Normal View History

; CommanderX16 text datetime example!
; make sure to compile with the cx16 compiler target.
2020-09-09 20:49:32 +00:00
%target cx16
2020-08-27 16:21:12 +00:00
%import cx16textio
%zeropage basicsafe
2020-07-26 22:32:59 +00:00
main {
2020-07-26 21:32:20 +00:00
sub start() {
cx16.r0 = mkword(8, 2020 - 1900)
cx16.r1 = mkword(19, 27)
cx16.r2 = mkword(0, 16)
cx16.r3 = 0
cx16.clock_set_date_time()
txt.lowercase()
2020-08-26 17:34:12 +00:00
repeat {
c64.CHROUT(19) ; HOME
2020-08-27 16:21:12 +00:00
txt.print("\n yyyy-mm-dd HH:MM:SS.jj\n\n")
2020-08-26 17:34:12 +00:00
cx16.clock_get_date_time()
c64.CHROUT(' ')
print_date()
c64.CHROUT(' ')
print_time()
}
}
sub print_date() {
txt.print_uw(1900 + lsb(cx16.r0))
2020-08-26 17:34:12 +00:00
c64.CHROUT('-')
if msb(cx16.r0) < 10
2020-08-26 17:34:12 +00:00
c64.CHROUT('0')
txt.print_ub(msb(cx16.r0))
2020-08-26 17:34:12 +00:00
c64.CHROUT('-')
if lsb(cx16.r1) < 10
2020-08-26 17:34:12 +00:00
c64.CHROUT('0')
txt.print_ub(lsb(cx16.r1))
2020-08-26 17:34:12 +00:00
}
2020-08-26 17:34:12 +00:00
sub print_time() {
if msb(cx16.r1) < 10
2020-08-26 17:34:12 +00:00
c64.CHROUT('0')
txt.print_ub(msb(cx16.r1))
2020-08-26 17:34:12 +00:00
c64.CHROUT(':')
if lsb(cx16.r2) < 10
2020-08-26 17:34:12 +00:00
c64.CHROUT('0')
txt.print_ub(lsb(cx16.r2))
2020-08-26 17:34:12 +00:00
c64.CHROUT(':')
if msb(cx16.r2) < 10
2020-08-26 17:34:12 +00:00
c64.CHROUT('0')
txt.print_ub(msb(cx16.r2))
2020-08-26 17:34:12 +00:00
c64.CHROUT('.')
if lsb(cx16.r3) < 10
2020-08-26 17:34:12 +00:00
c64.CHROUT('0')
txt.print_ub(lsb(cx16.r3))
2020-08-23 22:26:26 +00:00
}
}
2020-08-24 21:18:46 +00:00