41 lines
1.9 KiB
Python
41 lines
1.9 KiB
Python
"""Guard the actual original airborne dispatcher and keyboard arithmetic sites."""
|
|
from pathlib import Path
|
|
import struct
|
|
import unittest
|
|
|
|
EXE = Path(__file__).resolve().parents[2]/'Original/Neutron.exe'
|
|
|
|
|
|
class AirSteeringEvidence(unittest.TestCase):
|
|
def test_air_mode_falls_through_to_real_input_handler(self):
|
|
raw = EXE.read_bytes()
|
|
self.assertEqual(struct.unpack_from('<4I', raw, 0x38ba4),
|
|
(0x438b31, 0x438b60, 0x438b6d, 0x438b82))
|
|
# Mode1 logs then continues at mode2's call site. It does not return.
|
|
self.assertEqual(raw[0x38b6a:0x38b76], bytes.fromhex('83c4048b4424108b17508bcf'))
|
|
self.assertEqual(raw[0x38b76:0x38b7c], bytes.fromhex('ff9228010000'))
|
|
self.assertEqual(struct.unpack_from('<I', raw, 0xa3bdc+0x128)[0], 0x439900)
|
|
|
|
def test_source_air_input_constants_and_decisive_instructions(self):
|
|
raw = EXE.read_bytes()
|
|
for address, value in [(0x48d96c,100), (0x48d948,.5), (0x4afd28,-30),
|
|
(0x48d404,30), (0x49d5dc,0.9090909361839294),
|
|
(0x49d5b8,0.0181818176060915)]:
|
|
self.assertAlmostEqual(struct.unpack_from('<f',raw,address-0x400000)[0],value)
|
|
for address, pattern in [
|
|
(0x439943,'381d5d985000'), # Left before Right.
|
|
(0x439966,'381d5f985000'),
|
|
(0x439a3a,'d80d6cd94800'), #100*dt turn ramp.
|
|
(0x439b38,'d986bc060000'), # Forward reads source speed increment.
|
|
(0x439b71,'d986c4060000d80ddcd54900'), # Coast threshold max*10/11.
|
|
(0x439c53,'d986c0060000d80d48d94800'), # Air Down half decay.
|
|
(0x439dad,'c786d40600000000f041'), # Mode1 turn cap+30.
|
|
(0x438047,'d80db8d54900'), # Air lateral1/55.
|
|
]:
|
|
expected=bytes.fromhex(pattern)
|
|
self.assertEqual(raw[address-0x400000:address-0x400000+len(expected)],expected,hex(address))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|