Recently I finally tracked down what I thought was a bug in my emulator when playing Battletoads. Very rarely the toad would float above platforms, usually in the snake pit, but sometimes in the ice stage. Once floating he could still stand on things and walk around, but not hit any enemies or the exit hole on snake levels.
I thought it must be an emulator bug in those areas the timing seemed different (the status bar is lower in the snake pit, for example). At some point I caught myself pressing left and right at the same time (using the keyboard arrow keys) and clued in. I held them and the toad just floated up. Argh! I knew about a similar problem in Zelda 2, but hadn't yet bothered to filter this from joypad input. The reason it occured mostly in those vertical scrolling areas is that those are the places where you're changing directions often, thus more likely to press both at the same time.
I just wanted to mention this as a source of phantom bugs in a game that is hard on emulators. I came up with a joypad "filter" which eliminates simultaneous use of left and right, and up and down, preferring the most recently pressed direction ("rollover") rather than just clearing that axis when both are pressed. It was tricky to get the algorithm correct and compact, so I'm showing the code I used.
Update: I fixed a bug in the code (holding l+r then pressing up or down caused x axis direction to swap). Like I said, it's a tricky algorithm to get right!
I thought it must be an emulator bug in those areas the timing seemed different (the status bar is lower in the snake pit, for example). At some point I caught myself pressing left and right at the same time (using the keyboard arrow keys) and clued in. I held them and the toad just floated up. Argh! I knew about a similar problem in Zelda 2, but hadn't yet bothered to filter this from joypad input. The reason it occured mostly in those vertical scrolling areas is that those are the places where you're changing directions often, thus more likely to press both at the same time.
I just wanted to mention this as a source of phantom bugs in a game that is hard on emulators. I came up with a joypad "filter" which eliminates simultaneous use of left and right, and up and down, preferring the most recently pressed direction ("rollover") rather than just clearing that axis when both are pressed. It was tricky to get the algorithm correct and compact, so I'm showing the code I used.
Code:
const int x_axis = 0xc0;
const int y_axis = 0x30;
int mask = ~0x50;
int prev;
int filter_joypad( int joypad )
{
int changed = prev ^ joypad;
int hidden = joypad & ~mask;
if ( (changed & x_axis) && (hidden & x_axis) )
mask ^= x_axis;
if ( (changed & y_axis) && (hidden & y_axis) )
mask ^= y_axis;
prev = joypad;
return joypad & mask;
}
const int y_axis = 0x30;
int mask = ~0x50;
int prev;
int filter_joypad( int joypad )
{
int changed = prev ^ joypad;
int hidden = joypad & ~mask;
if ( (changed & x_axis) && (hidden & x_axis) )
mask ^= x_axis;
if ( (changed & y_axis) && (hidden & y_axis) )
mask ^= y_axis;
prev = joypad;
return joypad & mask;
}
Update: I fixed a bug in the code (holding l+r then pressing up or down caused x axis direction to swap). Like I said, it's a tricky algorithm to get right!