Skip to content

Develop#283

Merged
alekmaul merged 115 commits intomasterfrom
develop
Jun 10, 2024
Merged

Develop#283
alekmaul merged 115 commits intomasterfrom
develop

Conversation

@alekmaul
Copy link
Copy Markdown
Owner

No description provided.

alekmaul and others added 30 commits March 9, 2024 10:37
undisbeliever and others added 29 commits May 18, 2024 10:20
Modifies WaitForVBlank() so it can be called with any DB register value.

Also documents that WaitForVBlank() will preserve A/X/Y registers.
The speed_change jsr in `_MouseRead` can crash if `mouseSpeedChange` is
in a different bank to `_MouseRead`.

speed_change has been changed to a child label to illuminate that
`_MouseRead` is calling a subroutine outside of vblank.asm.
mouse_read has been moved to vblank.asm and the same comments already
exist in vblank.asm.
Saves 2 cycles and matches the _GetScope call in the VBlank ISR.
Writes to nmi_handler are not atomic and the VBlank ISR can crash if a
VBlank Interrupt occurs in the middle of the nmi_handler write.

To fix this crash, nmiSet() is now a function that will temporarily
disable interrupts so nmi_handler can be safely written to.

This commit also modifies consoleInit() to use nmiSet().
 * Test for lag-frames
 * Remove oamMemory DMA transfer (now handled by the VBlank ISR)
 * Remove snes_vblank_count++ (now handled by the VBlank ISR)
These functions did not multiply the argument by 2 when converting the
`value` argument (0-4) to an X index register value (0, 2, 4, 6, 8).
I have tested and confirmed `padsDown(i) == pad_keysrepeat[i]` before
making this change.
padsClear() is not clearing the high byte of the pad variables.

Using long addressing is faster then changing DB register.

Also:
 * Added bounds testing to padsClear()
 * padsClear() can be called with an 8 bit Index
 * Document pad arrays.
 * pads*() value parameter is an index, not an address.
 * Clarify pads*() parameter range
It is only used in the NMI ISR and should not be used for IRQ interrupts.
Fixes potential memory corruption in NMI ISR.
The VBlank ISR changes the Direct Page Register to
`tcc__registers_nmi_isr`.  If `tcc__registers_nmi_isr` is not page
aligned, a 1 cycle penalty will be applied to all direct-page
instructions in the VBlank ISR (including the `nmi_handler`).
`vblank_flag` can be used to determine if it is OK to read from `bgInfo`
in `myconsoleVblank()`.
@alekmaul alekmaul merged commit 5edc3ef into master Jun 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants