4 ms·
The original Asteroids source code has been released, we can look at what it did! (Also, even before that the EPROM images had been disassembled, but looking at
by LukeShu 4y ago
The original Asteroids source code has been released, we can look at what it did! (Also, even before that the EPROM images had been disassembled, but looking at the original sources is more fun.)
It indeed used (-128, 128) for (-180°,180°)
For instance, here it is using 64 (written as "40", because hexadecimal) for "PI/2":
COS: CLC ;COS(A)=SIN(A+PI/2)
ADC I,40
; JMP SIN
It implements COS in terms of SIN, and SIN wraps everything to be in the domain [0,64] (that is [0°,90°] ) then retrieves that from the lookup table.
code: https://github.com/historicalsource/asteroids/blob/main/A35131.1A#L2411-L2438 https://github.com/historicalsource/asteroids/blob/main/A351...
table: https://github.com/historicalsource/asteroids/blob/main/A35127.XX#L567-L575 https://github.com/historicalsource/asteroids/blob/main/A351...