Difference between revisions of "Classic Elite entity states"

From Elite Wiki
(A.I.)
(Add C64 entitiy layout)
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
Upon launching from the Space Station the player is confronted by several entities, the planet ahead, the space station behind, and perhaps additional ships. The following description of each entity's state is specific to the BBC Disk [[Classic_Elite|Classic version of Elite]], there are some variations in the other 8-bit versions.
+
Upon launching from the Space Station the player is confronted by several entities, the planet ahead, the space station behind, and perhaps additional ships.
 +
 
 +
== BBC Disk Version ==
 +
 
 +
The following description of each entity's state is specific to the BBC Disk [[Classic_Elite|Classic version of Elite]], there are some variations in the other 8-bit versions.
  
 
Each entity has a state represented in 37 bytes. The first 9 bytes are the (x,y,z) coordinates to 23bit precision with the player at the origin. The next 18 bytes store a 9-member rotation matrix, with the positive unit vector scaled to 0x6000. A pointer of 2 bytes points to a heap that contains processed vertex data for display.
 
Each entity has a state represented in 37 bytes. The first 9 bytes are the (x,y,z) coordinates to 23bit precision with the player at the origin. The next 18 bytes store a 9-member rotation matrix, with the positive unit vector scaled to 0x6000. A pointer of 2 bytes points to a heap that contains processed vertex data for display.
  
Single bytes represent the entity's speed, acceleration, remaining energy, and counters for roll and pitch actions currently underway.  
+
Single bytes represent the entity's speed, acceleration, remaining energy, and counters for roll and pitch actions currently underway.
 +
 
 +
The remaining 3 bytes represent the entity's A.I., which we shall refer to as the '''Attack''', '''Behaviour''' and '''Visible States'''. Some bits serve more than one purpose if they are set. (See the A.I. section below for details)
 +
 
 +
== C64 Version ==
 +
 
 +
This information based on the [https://github.com/Kroc/elite-harmless Elite C64 disassembly on GitHub].
 +
 
 +
{| class="wikitable"
 +
! Byte Offset
 +
! Data Size
 +
! Name
 +
! Description
 +
! Zero Page Addr.
 +
|-
 +
| +0
 +
| 3 bytes
 +
| xpos
 +
| 3D X-position within space
 +
| $09
 +
|-
 +
| +3
 +
| 3 bytes
 +
| ypos
 +
| 3D Y-position within space
 +
| $0C
 +
|-
 +
| +6
 +
| 3 bytes
 +
| zpos
 +
| 3D Z-position within space
 +
| $0F
 +
|-
 +
| +9
 +
| 2 bytes
 +
| m0x0
 +
| Part of the 3×3 rotation matrix
 +
| $12
 +
|-
 +
| +11
 +
| 2 bytes
 +
| m0x1
 +
| Part of the 3×3 rotation matrix
 +
| $14
 +
|-
 +
| +13
 +
| 2 bytes
 +
| m0x2
 +
| Part of the 3×3 rotation matrix
 +
| $16
 +
|-
 +
| +15
 +
| 2 bytes
 +
| m1x0
 +
| Part of the 3×3 rotation matrix
 +
| $18
 +
|-
 +
| +17
 +
| 2 bytes
 +
| m1x1
 +
| Part of the 3×3 rotation matrix
 +
| $1A
 +
|-
 +
| +19
 +
| 2 bytes
 +
| m1x2
 +
| Part of the 3×3 rotation matrix
 +
| $1C
 +
|-
 +
| +21
 +
| 2 bytes
 +
| m2x0
 +
| Part of the 3×3 rotation matrix
 +
| $1E
 +
|-
 +
| +23
 +
| 2 bytes
 +
| m2x1
 +
| Part of the 3×3 rotation matrix
 +
| $20
 +
|-
 +
| +25
 +
| 2 bytes
 +
| m2x2
 +
| Part of the 3×3 rotation matrix
 +
| $22
 +
|-
 +
| +27
 +
| 2 bytes
 +
| vertexData
 +
| A pointer to already processed vertex data
 +
| $24
 +
|-
 +
| +29
 +
| 1 byte
 +
| roll
 +
| X-Rotation
 +
| $26
 +
|-
 +
| +30
 +
| 1 byte
 +
| pitch
 +
| Z-Rotation
 +
| $27
 +
|-
 +
| +31
 +
| 1 byte
 +
| visibility
 +
| A.I. Visibility state flags, as described in the A.I. section below
 +
| $28
 +
|-
 +
| +32
 +
| 1 byte
 +
| attack
 +
| A.I. Attack state flags, as described in the A.I. section below
 +
| $29
 +
|-
 +
| +33
 +
| 1 byte
 +
| speed
 +
| Forward momentum
 +
| $2A
 +
|-
 +
| +34
 +
| 1 byte
 +
| acceleration
 +
| Acceleration rate
 +
| $2B
 +
|-
 +
| +35
 +
| 1 byte
 +
| energy
 +
| Energy level
 +
| $2C
 +
|-
 +
| +36
 +
| 1 byte
 +
| behaviour
 +
| A.I. Behaviour state flags, as described in the A.I. section below
 +
| $2D
 +
|}
  
 
== A.I. ==
 
== A.I. ==
 
The remaining 3 bytes represent the entity's A.I., which we shall refer to as the '''Attack''', '''Behaviour''' and '''Visible States'''. Some bits serve more than one purpose if they are set.
 
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 77: Line 219:
 
|Number of missiles or thargons remaining within entity, maximum is 7.
 
|Number of missiles or thargons remaining within entity, maximum is 7.
 
|}
 
|}
The arrangement of the bits is driven by the preferences of 6502 code. [http://wiki.nesdev.com/w/index.php/6502_assembly_optimisations#Easily_test_2_upper_bits_of_a_variable Direct bit tests exist for the highest bits], and the lower bits tend to be used to count small quantities.
+
The arrangement of the bits is driven by the preferences of 6502 machine code. [http://wiki.nesdev.com/w/index.php/6502_assembly_optimisations#Easily_test_2_upper_bits_of_a_variable Direct bit tests exist for the highest bits], and the lower bits tend to be used to count small quantities.
  
 
Source code for the BBC tape and TUBE versions of BBC Elite can be found at [http://www.iancgbell.clara.net/elite/text/index.htm Ian Bell's] web site and were used to disassemble and interpret the Disk version described here.
 
Source code for the BBC tape and TUBE versions of BBC Elite can be found at [http://www.iancgbell.clara.net/elite/text/index.htm Ian Bell's] web site and were used to disassemble and interpret the Disk version described here.
 +
 +
[[Category:Classic]]

Latest revision as of 22:48, 12 January 2019

Upon launching from the Space Station the player is confronted by several entities, the planet ahead, the space station behind, and perhaps additional ships.

BBC Disk Version

The following description of each entity's state is specific to the BBC Disk Classic version of Elite, there are some variations in the other 8-bit versions.

Each entity has a state represented in 37 bytes. The first 9 bytes are the (x,y,z) coordinates to 23bit precision with the player at the origin. The next 18 bytes store a 9-member rotation matrix, with the positive unit vector scaled to 0x6000. A pointer of 2 bytes points to a heap that contains processed vertex data for display.

Single bytes represent the entity's speed, acceleration, remaining energy, and counters for roll and pitch actions currently underway.

The remaining 3 bytes represent the entity's A.I., which we shall refer to as the Attack, Behaviour and Visible States. Some bits serve more than one purpose if they are set. (See the A.I. section below for details)

C64 Version

This information based on the Elite C64 disassembly on GitHub.

Byte Offset Data Size Name Description Zero Page Addr.
+0 3 bytes xpos 3D X-position within space $09
+3 3 bytes ypos 3D Y-position within space $0C
+6 3 bytes zpos 3D Z-position within space $0F
+9 2 bytes m0x0 Part of the 3×3 rotation matrix $12
+11 2 bytes m0x1 Part of the 3×3 rotation matrix $14
+13 2 bytes m0x2 Part of the 3×3 rotation matrix $16
+15 2 bytes m1x0 Part of the 3×3 rotation matrix $18
+17 2 bytes m1x1 Part of the 3×3 rotation matrix $1A
+19 2 bytes m1x2 Part of the 3×3 rotation matrix $1C
+21 2 bytes m2x0 Part of the 3×3 rotation matrix $1E
+23 2 bytes m2x1 Part of the 3×3 rotation matrix $20
+25 2 bytes m2x2 Part of the 3×3 rotation matrix $22
+27 2 bytes vertexData A pointer to already processed vertex data $24
+29 1 byte roll X-Rotation $26
+30 1 byte pitch Z-Rotation $27
+31 1 byte visibility A.I. Visibility state flags, as described in the A.I. section below $28
+32 1 byte attack A.I. Attack state flags, as described in the A.I. section below $29
+33 1 byte speed Forward momentum $2A
+34 1 byte acceleration Acceleration rate $2B
+35 1 byte energy Energy level $2C
+36 1 byte behaviour A.I. Behaviour state flags, as described in the A.I. section below $2D

A.I.

Bit Attack State
7 A.I. is active, use tactics. Missiles' trajectory updated 8 times more often than others.
6 Missile's target is player, or entity is more than mildly aggressive.
5,4,3,2,1 I.D. of Missile's target, or refinement to level of aggression.
0 Entity has an E.C.M. (Electronic Counter Measures) to destroy in-flight missiles.
Bit Behaviour State
7 Remove entity silently, too far away or entity is scooped cargo.
6 Entity is a Police vessel, destroying one affects your legal status.
5 Entity (Shuttle or Transporter) under Space Station protection, will launch cops.
4 Entity is docking, go to planet then to space station.
3 Pirate, attack player if not in space station safety zone, else fly away from player.
2 Entity is angry with player, accuracy of shooting determined by level of aggression.
1 Bounty hunter, attacks player if player's legal status is fugitive.
0 Peaceful trader, maybe attacks player if player's legal status is fugitive.
Bit Visible State
7 Terminate entity with a dust explosion
6 Entity is firing laser at player, or entity is exploding.
5 Display nodes of wire-frame or explosion, not a far-away dot.
4 Keep visible on scanner
3 Recent rendering to screen needs to be erased (draw with EOR operation again)
2,1,0 Number of missiles or thargons remaining within entity, maximum is 7.

The arrangement of the bits is driven by the preferences of 6502 machine code. Direct bit tests exist for the highest bits, and the lower bits tend to be used to count small quantities.

Source code for the BBC tape and TUBE versions of BBC Elite can be found at Ian Bell's web site and were used to disassemble and interpret the Disk version described here.