Hello, Guest the thread was viewed1.6k times and contains 8 replies

last post from TOS22 at the

Different Behavior (only) in BASIC when enabling VIC IV in different ROM Versions

  • Hi, I have found a strange behavior when enabling VIC IV in BASIC65 in ROM 920383 (but not in M/L).

    Usually you would POKE 53295,71 and then POKE 53295,83 to activate the MEGA65 specific IO Context

    This works like a charm in previous ROM Versions (920377 or 920366).

    But with V920383, BASIC65 does not prompt "READY" and with a second call, it freezes. The same behavior in the emulator and on the real machine. How come?


    But this is interesting:

    In M/L you would load the two values into x and y register and make a stx followed by an immediate sty to 53295 (as it was suggested by ubik in Sep20).

    This works perfectly in every ROM Version.


    Do you have any experience with that?

  • I can reproduce your finding: knocking the KEY register (53295) with 71 then 83 while in MEGA65 mode does nothing in ROM 920377 and misbehaves in ROM 920383. On MEGA65 hardware, it's not exactly a crash, but it's unstable behavior.


    Notably, it works as expected in C64 mode, which is the intent of the KEY register. Can you explain further how you noticed that this fails in MEGA65 mode? Do you have a use case for requesting the VIC-IV registers when they're already available in MEGA65 mode?


    I'm not saying it's not a bug worth fixing—and it might be an indicator of a worse issue—though a use case might help prioritize it. I filed it here, feel free to add any additional information: https://github.com/MEGA65/mega65-rom-public/issues/51


    Thanks!

    — Dan

  • ooh I just noticed something slightly interesting: doing the knock sequence in ROM 920377 then holding the cursor-down key causes the screen to flicker with `@` symbols. Is that the same for you?


    I'm still not comfortable that the behavior has changed between ROMs but one could say there's a bit of instability in both cases.

  • Notably, it works as expected in C64 mode, which is the intent of the KEY register. Can you explain further how you noticed that this fails in MEGA65 mode? Do you have a use case for requesting the VIC-IV registers when they're already available in MEGA65 mode?

    Hi, Dan! I found it while writing a sprites library for TCC, with an VIC IV enabling subroutine that works from whatever context it is called. It was interesting for me, that knocking with (ldx#$47 and stx$d02f) and then (ldx#$53 and stx$d02f) hangs the machine on the 920383 when already in VIC IV context, which was not the case in the previous ROM Versions. But this did not happen when I loaded the values into two different registers and stored them immediately after another to $d02f.

    Then, I tried it in BASIC, and it seemed, that it has the same issue again, what ubik in his post already mentioned years ago (Accessing VIC-IV features from BASIC10 / C65 mode)

    But there is not really a use case for that, I simly stumbled over it ...

    Matthias

  • ooh I just noticed something slightly interesting: doing the knock sequence in ROM 920377 then holding the cursor-down key causes the screen to flicker with `@` symbols. Is that the same for you?

    Yes, I can confirm that. This is strange! And also in ROM 920366. But, by using ML and only with knocking the 2 values immediately after another, does interestingly not trigger this weird behavior (which makes it easier for a ML subroutine, because if it also triggered it, I would have to check the calling context first ...)

  • It's possible that the safest way to knock the KEY register is in ML with interrupts disabled. The User's Guide describes this with POKEs, so if it's actually unsafe without ML and interrupts disabled, we should probably rewrite that part of the book. (That'd be unfortunate because it's a neat short demo!)

  • You're right. Actually, that was the problem ... in the one ML routine, where the system didn't hang, I had also interrupts disabled. That explains it completely! And yes, this is unfortunate also in my opinion - the special thing was to have this knocking mechanism in BASIC without the need to address ML directly ...

    Thank you!

  • VIC IV mode is enabled by default in BASIC65, so there is no need to apply the knocking sequence.

    While it is true, that VIC IV is enabled by default on the MEGA65, there could be situations when the additional VIC IV registers are hidden unintentionally or on purpose. For example, the manual (M-7) mentions, that you can hide the VIC III/VIC IV registers by simply knocking the KEY register with twice zero. I have not tested that. And this is the reason why I thought it would be good starting point to make sure, that the VIC IV registers are visible before using those registers ...