Acknowledged about SECTIONs in RAM, SECTIONs in ROM, and interrupts. But the distinction in RGBDS between "labels" and "symbols", with only labels eligible to be
.local, was kicking my behind at the time.
adam_smasher wrote:You really ought to use the HALT instruction and wait for the vblank interrupt instead of busy looping in your main loop; this puts the CPU into low-power mode and saves battery
Agreed in principle. Are there examples?
adam_smasher wrote:I don't know anything about needing to "release the controller", as you do on lines 344-346. That might be on me, though! Do you have a documentation source for that?
Search
"GameBoy Programming Info" by Marat Fayzullin for "Set 1s at both P14 and P15 lines". Keeping the key matrix deselected while not reading could be a power saving method. Or it could just be cargo cult programming based on incomplete knowledge of hardware behavior, especially given the state the scene was in when Marat was most active.
koitsu is referring to
WAI on 65816 and some 65C02 variants, and
SWI 2 on GBA. These not only save battery on hardware but also improve emulation speed especially on a slow or mobile device. It's just a matter of sitting down and troubleshooting the IRQ edge cases, such as possibly not firing at all while rendering is disabled. And even though I use mGBA most of the time, beware in #gbdev on EFnet has convinced me to occasionally run it in (proprietary) bgb with "reality" and all "break on" enabled. (Sorry calima.)
As for the HALT "delay slot" quirk: RGBDS is encoding HALT as
76 00, a 2-byte instruction with the second being $00 (NOP). This reminded me of how the disassembler in the Apple II Monitor ROM since roughly IIGS ROM 01 began to treat BRK as the 2-byte instruction that it is.