4 ms·
The rotation step may be 5.625 degrees. That would be equivalent to a division of 90° by 16, which could be accomplished by a simple 4 bit shift One of the ori
by FatalLogic 6y ago
The rotation step may be 5.625 degrees. That would be equivalent to a division of 90° by 16, which could be accomplished by a simple 4 bit shift
One of the original design documents mentions a 90°/16 division operation: https://arcadeblogger.com/2018/10/24/atari-asteroids-creating-a-vector-arcade-classic/ https://arcadeblogger.com/2018/10/24/atari-asteroids-creatin...
- Someone 6y agoI don’t see where “a division of 90° by 16” would be used in the game. Given the CPUs of the time, I would think they wouldn’t compute angles, but use a lookup table of sines and cosines (possibly in a single table, and scaled by a convenient factor). I would guess they used a lookup table to look up sines and cosines, and picked a power of two for the number of different angles because increasing the angle with wraparound is faster that way. Compare (made up assembly language) INC reg CMP reg, #0x10 BNE dontWrap CLR reg dontWrap: RTS with INC REG AND REG, #0x0F RTS
- FatalLogic 6y agoWhat you've said sounds more likely. The original code can be seen here: http://www.ionpool.net/arcade/astcode/asteroids_code_project.html http://www.ionpool.net/arcade/astcode/asteroids_code_project... The rotation code apparently starts at 0x7086, which adds or subtracts 3 from a one byte variable. If that 8 bit variable maps to a full 360 degrees of rotation, that would result in steps of about 4.2 degrees, but I don't know because I couldn't follow the code after that
- justinlloyd 6y agoReaching back in some ancient memory from 35+ years ago I recall that the rotation tables were sin/cos and the cos table overlapped the sin table by 180 degrees. I think there was 256 entries in When the ship rotated it stepped through the rotation table by three entries at a time, and took advantage of the 8-bit accumulator wrapping around. Then the value was used as a look-up in a table. The ships direction was a value of 0x00 to 0xFF, and that was used as an index in to the rotation table. I would need to read through the disassembly again to refresh my memory.