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: VIC-II bank ignored when displaying sprites in VIC-IV mode #342

Closed dillof closed 2 years ago

dillof commented 2 years ago

Describe the bug The VIC-II bank is set to $8000 via CIA2_PRA, VIC hot registers disabled, charset, screen position, and sprite pointer set via VIC-IV registers.

On MEGA65, the correct sprites are displayed, on xmega65 the data from bank 0 is displayed instead.

Used version of the project

**** The Evolving MEGA65 emulator from LGB ****
This software is part of the Xemu project: https://github.com/lgblgblgb/xemu
CREATED: travis@lgb on Darwin 18.7.0 at Tue Apr 26 10:24:46 GMT 2022
CREATED: clang 4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.8) 64LE for osx
VERSION: https://github.com/lgblgblgb/xemu.git master 08ed0450f53a65a285dcac802373aea4f9c6450d 20220426121838 official-build
EMULATE: MEGA65 (mega65): xmega65 (../../build/bin/xmega65.native) for mega65 on osx (native) using cc

To Reproduce Start the attached program on the emulator.

anykey-mega65.prg.zip

Sources are at GitHub. (For the build above, I've commented out line 135 of start-vicii.s that copies the sprite data to bank 0 as a workaround for this bug.)

If it helps, I can try to create a smaller example program.

Expected behavior In the lower right corner, a logo should be displayed.

Screenshots

How it looks in the emulator:

Screenshot 2022-05-19 at 18 07 17

How it looks on the MEGA65:

Screenshot 2022-05-19 at 18 07 35

Computer/Device (please complete the following information):

Additional context

lgblgblgb commented 2 years ago

@hernandp Any chance you to want this? :) If no, I would queue it for myself after my ongoing things sorted out a bit.

hernandp commented 2 years ago

Sure , I will handle it

On Tue, 24 May 2022 at 16:20 LGB @.***> wrote:

@hernandp https://github.com/hernandp Any chance you to want this? :) If no, I would queue it for myself after my ongoing things sorted out a bit.

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

hernandp commented 2 years ago

@dillof Looking at your code, it is possible that for the MEGA65 case you are not touching any of the $DD00 registers?

.if .not .defined(__MEGA65__)
    lda CIA2_PRA ; switch VIC bank
    and #$fc
    ora #((base_address >> 14) ^ 3)
    sta CIA2_PRA
.endif
.endmacro

Because I wrote some other test programs and I'm a bit puzzled on how banking scheme is behaving with MEGA65 mode.

dillof commented 2 years ago

That is for the MEGA65 native program, which mostly uses VIC-IV native registers.

The error above is from the C64 program running in C64 mode on the MEGA65, in which case the bank switching is done.

If it helps, I can try to make a simpler demo program over the weekend.

hernandp commented 2 years ago

Fixed. Now I understand: bank is fetched always from bits 14 and 15 and this may be set by $D06C-$D06E or $DD00 if Hotregs are enabled. Sounds much better.

image

hernandp commented 2 years ago

PR issued. https://github.com/lgblgblgb/xemu/pull/355

lgblgblgb commented 2 years ago

@hernandp Closing this now. If you have objection not to do that yet, please tell ;)