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

HALTCNT accesses should only work via BIOS code #2309

Closed
fleroviux opened this issue Sep 16, 2021 · 4 comments
Closed

HALTCNT accesses should only work via BIOS code #2309

fleroviux opened this issue Sep 16, 2021 · 4 comments
Labels
pending This issue needs more investigation by a maintainer to triage appropriately
Milestone

Comments

@fleroviux
Copy link

fleroviux commented Sep 16, 2021

I found two edge-cases when accessing HALTCNT:

  1. writes to HALTCNT seem to not work when R15 is not inside the BIOS region. I.e. on hardware a direct write from IWRAM or ROM code to HALTCNT doesn't appear to have any effect, but performing a CpuSet to it appears to work.
  2. writing a halfword to HALTCNT & ~1 appears to work on HW but doesn't seem to work on mGBA?

I attached a test ROM which I used to confirm the behavior on AGB-001, AGS-100 and a N3DS.
The first value should be around 2, the second should be around 1038 but the exact values don't matter.

haltcnt.zip

@endrift
Copy link
Member

endrift commented Sep 18, 2021

Strange, I was pretty sure HALTCNT could be used to HALT outside of BIOS too.

But yes, I handle HALTCNT a bit weirdly internally to mGBA due to the POSTFLG flag being on the high byte. This is something I should fix.

@endrift endrift added this to the mGBA 0.10.0 milestone Sep 18, 2021
@endrift endrift modified the milestones: mGBA 0.10.0, mGBA 0.10.1 Jun 16, 2022
@endrift endrift modified the milestones: mGBA 0.10.1, mGBA 0.10.2 Nov 28, 2022
@endrift endrift modified the milestones: mGBA 0.10.2, mGBA 0.10.3 Mar 14, 2023
@endrift endrift added the pending This issue needs more investigation by a maintainer to triage appropriately label Aug 5, 2023
@endrift
Copy link
Member

endrift commented Dec 21, 2023

I have a fix in preparation for this, but I'm not going to backport it into 0.10.3.

@fleroviux, do you know if the behavior of HALTCNT depends on the old state of POSTFLG? It seems like it should try to do a halt if you write to POSTFLG at the same time.

@endrift endrift modified the milestones: mGBA 0.10.3, mGBA 0.11.0 Dec 21, 2023
@fleroviux
Copy link
Author

fleroviux commented Dec 21, 2023

@endrift I'm not sure if I understand your question, could you elaborate? As far as I am aware POSTFLG cannot change after being set by the BIOS and HALTCNT doesn't really care / works the same regardless of what you write to the lower/POSTFLG byte.

@profi200
Copy link

profi200 commented Dec 22, 2023

My experience with the "POSTFLG" reg has been that it doesn't do anything besides changing the code path the BIOS takes on cold boot and it's write once. It didn't have any effect on HALTCNT. Games work fine if you don't set this reg and boot straight into them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending This issue needs more investigation by a maintainer to triage appropriately
Projects
None yet
Development

No branches or pull requests

3 participants