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

"zombie mode" does exist on the gba #364

Open
ITotalJustice opened this issue Feb 25, 2024 · 4 comments
Open

"zombie mode" does exist on the gba #364

ITotalJustice opened this issue Feb 25, 2024 · 4 comments
Assignees

Comments

@ITotalJustice
Copy link

APU: remove "Zombie" mode emulation (does not appear to exist on GBA)
I don't have a test rom for this, however i know of at least 1 game that relies on zombie mode, that game being Prehistorik Man (which is pretty much a test rom :p).

during the intro (both of them), both square channels will have a volume of 15, along with left/right volume of 8 (7 + 1). the game then writes to envelope which causes the volume to be incremented, so volume is now 16, which gets masked down to 0.

i have tested this on my gba sp, the square channels are silenced as they overflow to 0. not sure the exact way this works, but according to the wiki, this behaviour is true across all systems:

fun env_write() {
  if (channel enabled) {
    if (old_period == 0 && !old_mode) {
      volume++;
    }
    volume &= 0xF;
  }
}

i am not sure the exact way in which zombie mode works. implementing it how the wiki describes (which is for dmg) breaks metroid zero intro when the ship lands.

@ITotalJustice
Copy link
Author

here's metroid zero mission with the bug i described when using the code above:

how it should sound:

screen_record-2024-02-25_16.08.18.mp4

how it sounds with zombie mode:

screen_record-2024-02-25_16.09.11.mp4

so while it does exist, it's not exactly as it's implemented above (or on the wiki) for the gba...

@fleroviux
Copy link
Member

So, as I understand this only proves that "Zombie" mode exists in GBC mode on GBA (SP), right? It is very possible that GBA mode doesn't actually use the same set of PSGs as CGB mode but rather a reimplementation.

@fleroviux
Copy link
Member

To be clear: this is the issue that prompted my removal of "Zombie" mode emulation:
#335

But I haven't done any dedicated/extra testing to figure out if it actually exists in any capacity.

@ITotalJustice
Copy link
Author

ITotalJustice commented Feb 25, 2024

i managed to get zombie mode to happen on my gba in gba mode. sadly i can't make sense of the audio output as it's not consistent. It does play in a loop of sorts, it repeats every 8(?) seconds, with the last 5-8 seconds being the same output (volume = 15).

i've tried a few other methods of triggering zombie mode, but i've only been successful in changing the mode to trigger it

/*
test: write to env with period = 0, mode alternating
hw: volume changes!
*/

#include <tonc.h>

enum {
    ENVELOPE_SUB = 0 << 11,
    ENVELOPE_ADD = 1 << 11,
};

int main(void) {
    irq_init(NULL);
    irq_enable(II_VBLANK);

    REG_SNDSTAT = SSTAT_ENABLE;
    REG_SNDDSCNT = SDS_DMG100;
    REG_SNDDMGCNT = SDMG_LVOL(7) | SDMG_RVOL(7) | SDMG_LSQR1 | SDMG_RSQR1;

    int mode = ENVELOPE_ADD;
    REG_SND1CNT = (15 << 12) | mode | (0 << 8);
    REG_SND1FREQ = SFREQ_RESET | SFREQ_RATE(416);

    int wait = 60;
    while (1) {
        if (--wait == 0) {
            mode = mode == ENVELOPE_ADD ? ENVELOPE_SUB : ENVELOPE_ADD;
            REG_SND1CNT = (15 << 12) | mode | (0 << 8);
            wait = 60;
        }
        VBlankIntrWait();
    }
}

beep_overflow.zip

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

No branches or pull requests

2 participants