|
|
|
|
|
by kstenerud
254 days ago
|
|
SNK were the gods of the 68000. I still remember back in the day getting a bug report on my 68000 emulator: When playing King of Fighters, the time counter would go down to 0 and then wrap around to 99, effectively preventing the round from ending. Eventually I tracked it down to the behavior of SBCD (Subtract Binary Coded Decimal): Internally, the chip actually does update the overflow flag reliably (it's marked as undefined in the docs). SNK was checking the V flag and ending the round when it got set. https://github.com/kstenerud/Musashi/blob/master/m68k_in.c#L... SBCD was an old throwback instruction that was hardly used anymore, and the register variant took 6 cycles to complete (vs 4 for binary subtraction). HOWEVER... For displaying the timer counter on-screen, they saved a ton of cycles with this scheme because extracting the digits from a BCD value is a simple shift by 4 bits (6 cycles) rather than a VERY expensive divide (140 cycles). |
|