IRClock shows a digital watch at the top right of the screen in 80x60 mode.
The program relocates it self to golden memory ($400) when run to make room for normal BASIC development.
The program reads the current time from the RTC but afterwards the RTC is not used to keep the time.
The time can be set by poke'ing values into $400 = hours, $401 = minutes and $402 = seconds.
Now you have a handy time-keeper while you program away on your most recent BASIC game.
Try It Now!
Download the program here:
If you really want to see the source, you can go to https://github.com/jimmydansbo/cx16stuff and look for irclock.asm
#R45
IRClock
- JimmyDansbo
- Posts: 476
- Joined: Sun Apr 26, 2020 8:10 pm
- Location: Denmark
- Contact:
IRClock
- Attachments
-
- irclock.zip
- (649 Bytes) Downloaded 669 times
Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
- JimmyDansbo
- Posts: 476
- Joined: Sun Apr 26, 2020 8:10 pm
- Location: Denmark
- Contact:
Re: IRClock
Because this was written before the system had a working RTC
I may update it in the future, but you are welcome to grab a copy of the code and modify it your self.
I may update it in the future, but you are welcome to grab a copy of the code and modify it your self.
Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
Re: IRClock
Thanks, Jimmy. Does this use interrupts to print the clock?
With the RTC change, this would be a great tutorial for the use of interrupt-driven routines. It's not just a neat example, but it's actually useful, too!
With the RTC change, this would be a great tutorial for the use of interrupt-driven routines. It's not just a neat example, but it's actually useful, too!
- JimmyDansbo
- Posts: 476
- Joined: Sun Apr 26, 2020 8:10 pm
- Location: Denmark
- Contact:
Re: IRClock
It does use interrupt to draw the clock and my main goal with the program was to have a small working example on how to install an interrupt handler.
Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
- JimmyDansbo
- Posts: 476
- Joined: Sun Apr 26, 2020 8:10 pm
- Location: Denmark
- Contact:
Re: IRClock
Now updated to read startup time from RTC
Visit my Github repo
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
or my personal site with CX16/C64/6502 related information.
Feel free to contact me regarding any of my projects or even about meeting up somewhere near Denmark
Re: IRClock
Thanks for sharing these notes about the RTC and interrupt. I understand how this is working (using an IRQ to basically "simulate" the old Commodore jiffies count of 60?)
I tried the following in cc65:
__asm__("jsr $ff50"); // lock_get_date_time
__asm__("sta %v", reg_a);
__asm__("stx %v", reg_x);
__asm__("sty %v", reg_y);
And only reg_a is getting populated with the SECONDS count (where I defined reg_a, _x, _y as unsigned char).
Is there really no easier way to get sub-second precision besides something like the IRClock example?
Even if it's not super "atomic clock" like precision, sub-second timing is also useful for animation and movements (like waiting 15 or 30 jiffies) or having priorities (like checking for certain conditions at a high rate vs a slower rate).
I tried the following in cc65:
__asm__("jsr $ff50"); // lock_get_date_time
__asm__("sta %v", reg_a);
__asm__("stx %v", reg_x);
__asm__("sty %v", reg_y);
And only reg_a is getting populated with the SECONDS count (where I defined reg_a, _x, _y as unsigned char).
Is there really no easier way to get sub-second precision besides something like the IRClock example?
Even if it's not super "atomic clock" like precision, sub-second timing is also useful for animation and movements (like waiting 15 or 30 jiffies) or having priorities (like checking for certain conditions at a high rate vs a slower rate).
Re: IRClock
You could use STTIM and RDTIM, at $FFDB and $FFDE respectively. Those set a timer with jiffie resolution that you can set and get. It uses A as the MSB, X as the middle byte, and Y as the LSB.voidstar wrote: ↑Tue May 02, 2023 5:27 pm Thanks for sharing these notes about the RTC and interrupt. I understand how this is working (using an IRQ to basically "simulate" the old Commodore jiffies count of 60?)
I tried the following in cc65:
__asm__("jsr $ff50"); // lock_get_date_time
__asm__("sta %v", reg_a);
__asm__("stx %v", reg_x);
__asm__("sty %v", reg_y);
And only reg_a is getting populated with the SECONDS count (where I defined reg_a, _x, _y as unsigned char).
Is there really no easier way to get sub-second precision besides something like the IRClock example?
Even if it's not super "atomic clock" like precision, sub-second timing is also useful for animation and movements (like waiting 15 or 30 jiffies) or having priorities (like checking for certain conditions at a high rate vs a slower rate).
Code: Select all
;SET THE CLOCK TO 10 MINUTES = 3600 JIFFIES
LDA #0 ;MOST SIGNIFICANT
LDX #>3600
LDY #<3600 ;LEAST SIGNIFICANT
JSR $FFDB
Code: Select all
JSR $FFDE
STY TIME
STX TIME+1
STA TIME+2