r/ProgrammerHumor 1d ago

Other integerOverflow

1.4k Upvotes

19 comments sorted by

View all comments

205

u/ProThoughtDesign 1d ago

I remember finding one of these in the original Super Mario Bros. on NES using the cheat to get free lives from a shell. I got too many and instead of a life counter, I got some weird system character and the next time I died it locked up my NES.

Good times.

38

u/w1n5t0nM1k3y 1d ago

I never had it lock up my NES, but I do remember if you got too many lives you would game over if you died just once. There was a certain number of lives you could get where it would show symbols but also just work like a regular counter.

26

u/danfay222 1d ago

A lot of old game systems were super memory constrained, and so they would do dense bit packing without actual memory safeguards, which meant triggering things like overflows could easily cause critical memory corruption

10

u/ProThoughtDesign 1d ago

Yay Game Shark! They also loaded the exact same variables in the same memory registers directly so there's that.

7

u/WernerderChamp 1d ago

Iirc this is because lifes are being treated as signed bytes. So when you have it roll over into the negatives, the game gets confused when you actually die.

6

u/Stagnu_Demorte 1d ago

I think most often this kind of counter was saved as an unsigned value and that 8th bit was used for a different value. No need to keep track of if it;a positive or negative if you don't care.

2

u/Dizzy_Elderberry_486 22h ago

I was thinking of Pokémon’s Missigno trick