Skip to content

Conversation

@nippur72
Copy link
Contributor

@nippur72 nippur72 commented Aug 8, 2023

this PR implements TOD (time of the day) and ALARM in the chip MOS6526 (Commodore 64's CIA).

To make it work with c64.h the _c64_tick() needs to set M6526_PIN_TOD into the pins at the rate of 50 or 60 Hz. This can be easily done with a counter. I use something like this in my c64.h:

    // create a 50 Hz signal for TOD (CIA1)
    if(++sys->tod_counter > (C64_FREQUENCY / 50)) sys->tod_counter = 0; 

    // ...
   
        // feed the TOD signal to the CIA1
        if(sys->tod_counter == 0) cia1_pins |= M6526_TOD;  

I haven't made a PR for c64.h yet because I still use an old version of it, but will do once I upgrade.

I did not test the alarm functionality, as my program only makes use of the time of day, and I don't have any test programs.

@floooh
Copy link
Owner

floooh commented Aug 9, 2023

Just a heads up, I'll most likely won't be able to look at this PR for a long time (too much other stuff on my table atm), and also without being able to properly test its behaviour it's unlikely to be merged.

@nippur72
Copy link
Contributor Author

Hi, just to let you know that I fixed the code in order to pass all the VICE tests for TOD. I hope that can help you for a possible merge in the future.

And if you are curious to see why I needed the TOD feature, here we are emulating an italian Videotel modem cartridge for the C64:

  • click here
  • hit F5 to go to Videotel menu
  • hit F1 to dial a number
  • enter a telephone number (whatever)
  • wait for connection to the BBS
  • in the status bar, the connection time is counted using the TOD 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants