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
208 stars 32 forks source link

MEGA65: Test and improve V400 mode #291

Closed lgblgblgb closed 2 years ago

lgblgblgb commented 3 years ago

In general there can be problems with modes using V400 (though bitplane mode is probably OK, in fact no other mode was tested too much with V400 other than bitplane). Now just one example, but in general, it's maybe a good idea to look this whole issue in a generic way.

One example of the problem with OpenROMs

OpenROMs display only the top half of the screen, but not the bottom half, if 80x50 mode is used (it's OK 25 lines mode). Just trying to cursor down beyond the half of the screen, type something, and cursor up again: the cursor is again visible, the text is not, though in memory dump, the screen content clearly shows the typed text is there in the screen memory. According to FeralChild, 80x50 just works fine on the hardware. The problem with Xemu is found by Maurice.

Reasoning

My theory: OpenROMs may use V400 to achieve the 50 lines resolution which is not handled correctly (or at all) by Xemu. This is maybe true for "legacy" VIC-II modes (hires, MCM?) as well, I've never tested that (I even don't know if it's supported to have double vertical resolution with V400 set then as far as I remember, the documentation states for C65 at least, that V400 has no effect on VIC-II modes only bitplanes, but I can imagine that MEGA65 can do V400 legacy VIC-II modes as well unlike the C65). I'm quite sure, this is handled in bitplane mode though, since it was tested with various BASIC programs from the ClosedROMs project. So my conclusion: this is maybe not handled in other modes too much.

Note: EFFICTIVE_V400 should be used instead of REG_V400 macro because of some hacks which judges a certain situation as V200 even if it "should be" V400.

hernandp commented 3 years ago

I'll take this for the next week. Thanks.

lgblgblgb commented 3 years ago

OK, it seems I found the issue, at least for OpenROMs, in generic terms, it still can be questionable. Also my fix is a kind of hack. Talking about the OpenROMs issue now only.

Fix (workaround) and explanation

It seems it's a regression (in commit fcc01afccf7829fe1f2dc4024c84b7052af98748) introduced by myself, when double RRB needed that in a special case, a V400 setting still should mean V200. Thus I could not use REG_V400 macro directly any more, thus I introduced EFFECTIVE_V400 variable instead. However that EFFECTIVE_V400 as only updated in vic4_open_frame_access() thinking that V400/V200 is frame level stuff does not make sense to update it at other places. Problem: display_row_count is only set in a single function vic4_update_vertical_borders() which may see the EFFECTIVE_V400 value not yet updated, thus setting the display_row_count variable with V200 yet. My ugly solution: insert an extra line to update EFFECTIVE_V400 also in that function: vic4_update_vertical_borders().

Plans

Probably it would be better to update EFFECTIVE_V400 at register write time, when any register touched what is used as an "input" to calculate EFFECTIVE_V400, rather than guessing where I should update it, which was the problem here too, that I missed some important place where it was not updated. However for now it was easier to copy that single line and also put to another place as well as a kind of dirty but quick workaround.

lgblgblgb commented 2 years ago

I'm not sure about thus bug, since compared to the initial bug report, I've fixed Open-ROMs and possibly other scenarios with introducing the "EFFECTIVE_V400" thing. It's a question that this issue needs to be kept open, resolved or not, or worth to have more work, etc ...

lgblgblgb commented 2 years ago

@hernandp What do you think, do we need this "too generic" issue open? The initial problem with OpenROM and 80x50 text screen in general is resolved by me already, I am not sure what we need here still. If so, a more specific issue should be open though I think.

hernandp commented 2 years ago

I looked at this today, I think we can close it until a very specific issue with V400 appears.

On Wed, 31 Aug 2022 at 17:44 LGB @.***> wrote:

@hernandp https://github.com/hernandp What do you think, do we need this "too generic" issue open? The initial problem with OpenROM and 80x50 text screen in general is resolved by me already, I am not sure what we need here still. If so, a more specific issue should be open though I think.

— Reply to this email directly, view it on GitHub https://github.com/lgblgblgb/xemu/issues/291#issuecomment-1233402645, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABEFMBJTPRRPAHUMX76RURDV3672LANCNFSM5EFI7GEQ . You are receiving this because you were mentioned.Message ID: @.***>