lgblgblgb / xemu

Emulations (running on Linux/Unix/Windows/macOS, utilizing SDL2) of some - mainly - 8 bit machines, including the Commodore LCD, Commodore 65, and the MEGA65 as well.
https://github.com/lgblgblgb/xemu/wiki
GNU General Public License v2.0
201 stars 31 forks source link

MEGA65: utility menu tools cannot be started #369

Open lgblgblgb opened 1 year ago

lgblgblgb commented 1 year ago

Originally issue #368 but it's a more generic one: since the big changes of #140 utility menu items (configure, fdisk, keyboard test) do not work and produces only "white screen".

Since #140 I needed tons of modifications to allow newer HYPPO to be able to work inside Xemu/MEGA65. These changes are so interlocked, cannot be separated or reverted back step-by-step (to find the exact change which introduced the problem). However one side effect of this project is the inaccessibility of the utility menu items, that worked before, but not anymore after that project. Because of the "monolithic" nature of the big change, it's not possible to trace back (git bisect or anything like that) the exact change/commit which introduced the issue.

This problem - though known for me since a year or so - was handled as "low priority" issue (or even "cosmetic") as these are not so important in an emulator (Xemu anyway overrides settings, can format disk image as its own etc etc) as on a real machine. However, indeed, it shows there is some regression here since worked before, and the exact problem may reveal a more generic issue which can resolve other currently unknown problems as well in seemingly very different scenarios.

Note that even the first post in issue #140 the problem was already known, but would block the whole project of "new-HYPPO" if not ignored. Since then I made several attempts to track down this issue, but no luck. Anyway even those tries of mine revealed some issues Xemu did wrongly, which helped in emulation quality in general, but still, so far the root of the issue is not resolved yet.

The utility menu can be more easily triggered with two of these methods (no need for superhero reflexes ...):

So far, every tries of mine to find the actual problem (there were at least 2 occasions when I had hours of time to try to find the problem) was unsuccessful :(

lgblgblgb commented 7 months ago

What I've done so far (IIRC ... but the quoted source fragment is fresh now, of course not by heart for that part).

from mega65-core repository, file src/hyppo/main.asm:

utility_end_of_list:
        ;; XXX Get input from user (accept only numbers 1 - 9)
        jsr scankeyboard
        cmp #$ff
        beq utility_end_of_list
        cmp #$31
        bcc utility_end_of_list
        cmp #$39
        bcs utility_end_of_list

        ;; XXX Based on input, find that utility
        and #$f
        tax
        dex ;; input is 1-9, so subtract one for list beginning at 0
        jsr utillist_rewind
ueol2:  jsr utillist_validity_check
        ;; Select again if first choice invalid
        bcc utility_end_of_list
        dex
        bmi ueol1
        jsr utillist_next
        bra ueol2
ueol1:

        inc $d021

After selecting (let's say 1, ie CONFIGURE) utility, inc $d021 is executed, and this causes the screen goes white. Something here then goes horribly wrong. It seems, even hypervisor RAM is overwritten (?) what I can see in matrix mode, after the selection, compared to before the utility selection.

My gut feeling says that it's something of these, or mix of:

Though so far this does not helped exactly to pinpoint the issue that I can fix ...