Vamiga: Hostages - shot as soon as you break cover bug

Created on 2 Nov 2020  路  4Comments  路  Source: dirkwhoffmann/vAmiga

Most helpful comment

Modulos should not be cached (and same with most other registers too), only unsafe register is BLTCON0 active channel bits and BLTCON1 fill/line draw bits (causes really unexpected behavior which can't be found without schematics, for example one possible effect is that cycle diagram changes to something normally impossible, another possibility is blitter stopping until next BLTSIZE write)

Hostages changes modulo immediately after BLTSIZE write and blit is wide enough which means blitter always sees the new modulo when blitter adds the modulos.

All 4 comments

Confirmed. This bug makes the game pretty hard 馃ゴ:

Bildschirmfoto 2020-11-02 um 07 06 43

The EAB thread gives the import hint. The issue is related to the Blitter. When running with debug option BLT_GUARD, vAmiga floods the console with warning messages of this kind:

[5736] (265,138) 01A082  0 BCBSD- 602C 17C0 Memory: AGNUS OVERWRITES BLITTER AT ADDR 2193c
[5736] (284,205) 01A10A  0 BCBSD- 602C 17C0 Blitter: BLTBMOD written while Blitter is running

The first one is just a warning. It tells us that there might be a race condition between the Blitter and other components. The game produced this message all the time, even in those portions of the game that run fine.

The second message comes up around the time when the player is shot. It might be the root cause of the bug. The game modifies a Blitter register while the Blitter is running which is a bad idea in general. I need to write some test cases to find out if modifying the MOD registers results in predictable behavior (I guess it does as long as the registers are not read by the Blitter at the time they are modified). The current implementation of vAmiga doesn't handle on-the-fly modifications of the MOD registers due to this code:

    if (bltconDESC()) {
        incr = -2;
        ash  = 16 - bltconASH();
        bsh  = 16 - bltconBSH();
        amod = -bltamod;
        bmod = -bltbmod;
        cmod = -bltcmod;
        dmod = -bltdmod;
    } else {
        incr = 2;
        ash  = bltconASH();
        bsh  = bltconBSH();
        amod = bltamod;
        bmod = bltbmod;
        cmod = bltcmod;
        dmod = bltdmod;
    }

The code is executed at the beginning of a Blitter operation. Besides doing other stuff, it reads all MOD registers and uses these values throughout the whole operation. This is not what the real hardware does (there is no second register set inside the hardware Blitter).

I remember that I played this game a lot back in the day 馃グ.

Modulos should not be cached (and same with most other registers too), only unsafe register is BLTCON0 active channel bits and BLTCON1 fill/line draw bits (causes really unexpected behavior which can't be found without schematics, for example one possible effect is that cycle diagram changes to something normally impossible, another possibility is blitter stopping until next BLTSIZE write)

Hostages changes modulo immediately after BLTSIZE write and blit is wide enough which means blitter always sees the new modulo when blitter adds the modulos.

I wonder if it can be a similar issue in #377 if they change something after a blit has been started? I would expect they don't, but I guess you never know.

Indeed. With the latest changes (Blitter register caching removed), the game is much easier now. No more issues so far 馃槑.

Bildschirmfoto 2020-11-04 um 19 17 00

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dirkwhoffmann picture dirkwhoffmann  路  3Comments

dirkwhoffmann picture dirkwhoffmann  路  4Comments

dirkwhoffmann picture dirkwhoffmann  路  3Comments

Gianmarco72 picture Gianmarco72  路  4Comments

dirkwhoffmann picture dirkwhoffmann  路  3Comments