Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MEGA65: NCM not using fgcolour from Colour RAM #328

Closed
ki-bo opened this issue Mar 21, 2022 · 7 comments · Fixed by #330
Closed

MEGA65: NCM not using fgcolour from Colour RAM #328

ki-bo opened this issue Mar 21, 2022 · 7 comments · Fixed by #330

Comments

@ki-bo
Copy link
Contributor

ki-bo commented Mar 21, 2022

When using nibble-colour mode (NCM), a pixel value of $f shall not directly address palette index $f, but rather use the palette index defined in the Colour RAM (the fgcolour).

Happens with both master and next branch.

See attached demo program. The screen shall turn red (tested with Nexys A7 board). With Xemu, the screen turns white.

ncm_fgcolor_bug.txt

@lgblgblgb lgblgblgb changed the title NCM not using fgcolour from Colour RAM MEGA65: NCM not using fgcolour from Colour RAM Mar 22, 2022
@lgblgblgb lgblgblgb self-assigned this Mar 22, 2022
@lgblgblgb
Copy link
Owner

lgblgblgb commented Mar 22, 2022

Thanks for the bug report also for the example code! Yes - as we discussed already -, it seems to be a problem, that this feature is not emulated. I'll have a look, hopefully soon, it's always nice to have an issue though that I won't forget about the issue ...

@lgblgblgb
Copy link
Owner

lgblgblgb commented Mar 22, 2022

A very quick try to fix the issue, using the hyppo branch though for now. Totally untested yet, at this point.

@ki-bo
Copy link
Contributor Author

ki-bo commented Mar 22, 2022

Thanks! I just tested the hyppo branch build. If color $f is set, it uses the lower 4 bits of Colour RAM byte 1 as intended. That's good! But I think we need to look further.

One can also set bits 4-7 in Col RAM byte 1, and these bits are also utilised in NCM mode (on real Mega65). For this to be used, one must reset bit ATTR (5) of $d031. The current fix seems to ignore the Col RAM bits 4-7 in case Screen Memory sets color $f, as it seems.

@lgblgblgb
Copy link
Owner

Unfortunately the problem that MEGA65 is too complex and though in hardware it does not matter to have an extra "condition" (or not just only one) in an emulator each ones slows things down even more and more since CPU is a linearly executing stuff unlike a real hardware like FPGA. But anyway, hopefully there is enough juice in a modern PC to make emulation slower with more accurate emulation though ;)

Honestly, personally I never used NCM mode too much at all, it did not even exist on older MEGA65 implementations (or later only with sprites), IIRC (FCM existed before ...). So I also need to study this a bit more, since no idea what you've said about other bits, and what's for that at all, at least not by heart ...

Also it's worth to invite @hernandp into the conversation as the VIC-IV emulation expert, since in decent Xemu's at least he had a quite large amount of work to make VIC-IV emulation better, based on my initial and crude version back to then.

Btw, the reason I haven't tested this fix at all, since I did it in my lunch time during work within a minute or so ;) Thus there was not so much possibility to try / compare, especially not with real MEGA65 what I should be at home for ...

@lgblgblgb
Copy link
Owner

lgblgblgb commented Mar 22, 2022

By the way, I think I mode further conversation into another issue, since this one is much more related to the " colour index 15 should be the foreground colour in NCM" kind of problem. New issue on the other problem(s?): #329

@hernandp
Copy link
Contributor

Hello friends. I implemented the first version of NCM in Xemu, so I could check this and assess how precise our emulation is.
Right now I don't remember the details of operation of NCM.
I think NCM is a nice video-mode -may be the optimal in the current M65 design- since it uses less memory than FCM, allowing more "display throughput" when DMAing screens, and so on.

ki-bo added a commit to ki-bo/xemu that referenced this issue Mar 22, 2022
* Respecting palette(16) pointer in case fgcolor is selected
lgblgblgb added a commit that referenced this issue Mar 22, 2022
MEGA65: Upper 4 bits fgcolor NCM fix #328
@lgblgblgb lgblgblgb linked a pull request Mar 22, 2022 that will close this issue
lgblgblgb referenced this issue Mar 22, 2022
* Respecting palette(16) pointer in case fgcolor is selected
@lgblgblgb
Copy link
Owner

Since I opened two issues, let's close this for now.

@hernandp Yes, otherwise I agree, NCM is useful to save RAM especially in the case when you want something like 640*400 which would eat major amount of the internal RAM already ... I meant only that NCM as a character(-ish) mode is newer than FCM and I haven't used too much to know it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants