Wednesday, September 23, 2015

Making speed control easier

Just a quick post today about a couple of enhancements to make it easier to select CPU speed on the MEGA65:

1. The CPU now defaults to be locked to 48MHz, so that it is as fast as possible by default.

2. To enable slower speeds (under C128/C65 speed control register direction): POKE0,64

3. To force the CPU back to full speed: POKE0,65

4. The ASC/DIN key on a real C65 keyboard will have a similar effect to the above.

The POKE 0 system uses a special over load of the CPU DDR port at $00 - if $40 or $41 are written, then the DDR is not changed, but instead the CPU speed control function is followed instead.

12 comments:

  1. Then, if I understand it right, whenever one would like to switch between the speeds, these steps will be needed:

    lda #$40
    sta $00

    For switching from 48 to 3.5 MHz:

    lda #$47
    sta $d02f
    lda #$53
    sta $d02f
    lda #$bf
    and $d054
    sta $d054

    For switching from from 3.5 to 1 MHz:

    lda #$a5
    sta $d02f
    lda #$96
    sta $d02f
    lda #$bf
    and $d031
    sta $d031

    Is it right?

    ReplyDelete
    Replies
    1. Hello,

      Yes, you have it pretty much correct. You can of course use LDA #$40 TRB/TSB $D054 to save 3 bytes and some cycles by using the 4502 bit fiddling instructions.

      At some point I should also just add a register that lets you read the current CPU speed.

      Paul.

      Delete
    2. Thanks! And is it the same in C64 mode? (Also forced to 48 MHz by default and etc.)

      Delete
    3. Hello,

      Yes, the POKE0 trick forces the CPU in all modes, no matter what else the ROM or other software might do. That is, after POKE0,65 it is impossible to run the CPU at less than 48MHz, until you POKE0,64.

      Paul.

      Delete
    4. So, the default setting at the start, it depends only on the actual state of the ASC/DIN switch equally in both modes? (And it works in run-time, too?)

      I mean it would be wise to make a difference between the two ways of entering the C64 mode. If you turn the machine on by holding the C= key, then it should be by default set to 1 MHz instead. However, if you use the GO64 command, the actual values should be preserved. Then you might type something like FAST:GO64 or SLOW:GO64 etc. (Just an idea.)

      If a C64 keyboard is used, then there is no ASC/DIN key to press, and it is not so comfortable always to type those POKE commands.

      Delete
    5. Yes, the ASC/DIN switch will operate in all modes in realtime.

      Yes, we could get more sophisticated about the mode and speed selection -- and we will in due course as we develop the hypervisor further. Double-tapping RESTORE will bring up a hypervisor menu that I imagine will have options such as selecting cpu speed among other things. This will also solve the problem of people using it without a real or reproduction C65 keyboard.

      Paul.

      Delete
  2. But don't remove the poke command for changing speed....I grinned when I read that and felt Commodore 64 is back! :D By the way. I sold my C64c (real one) because I am replacing it with Mega65 so I did not feel any lose at all :)

    I just love poking in basic to configure hardware settings, can you do more of that too? :D

    ReplyDelete
    Replies
    1. Hello,

      So far we are all loving the POKE0 feature, so I don't see it going away anytime. Further adjustments will be possible via POKEs, but the convenient method, once implemented, will be to double-tap RESTORE and use an on-screen menu.

      Paul.

      Delete
  3. I hate on-screen menu..it feels like I am running an emulator and I press F12 under Windows...to pop emulator configuration in windows mode...arrgh..>_<....UNLESS....UNLESS...the on-screen menu is actually using the current BASIC mode you are in...and not some fpga switch virtual disk menu..or like you see in tv where you change gamma, etc...then I am happy. As long it relies on the actual current OS kernal to display the screen mode...like you do certain poke in c128 mode to get the credit and About displayed in c128 mode basic...then I am ok with that. As long it is integrated in the actual c65 core/kernal of the OS itself and it calls it on screen menu some where in the registry of the OS itself that can also be called via coding in basic...I AM HAPPY!!

    * hint, hint, if that is not implemented...change it to that..hint, hint, hint *

    ReplyDelete
    Replies
    1. Hello,

      Don't worry, the hypervisor is just another 6502 program running on the MEGA65 hardware -- the gamma won't change. It will still use the C64 charset or whatever we decide, it will still be C64 or C65 text mode for it.

      However, it can't rely on the OS to display the screen menu, because you might want to, for example, switch speed while playing a game or using a cartridge or something. Thus it has to be a level below that.

      There will be programming ways to access the same functions, so don't worry. Be assured that we are totally committed to this feeling like a real 8-bit computer at every step. I think you will actually find the on-screen menu, when done, to be quite fitting and a natural part of the experience -- basically it will be like the freeze button on an Action Replay, but with a different set of options (but including freeze, of course).

      Paul.

      Delete
    2. I am in tears of happiness...literally I am about to cry :;( Thank you * wipes tears from my eyes *....I want it to be 100% real...real..authentic........thank you.......:)

      Delete
  4. I want it to feel like real C65/C64...and not fpga...not core...not emulator....I want to be soooo real 100%.....aaah

    ReplyDelete