157 lines
7.6 KiB
C
157 lines
7.6 KiB
C
// Zero-page and RAM addresses the port shares with chunk5.
|
|
//
|
|
// The port runs the scenery bytecode against a 64K RAM image whose
|
|
// zero page mirrors chunk5's working variables. Every address the C
|
|
// code touches is named here so there is exactly one place that says
|
|
// what each cell means.
|
|
//
|
|
// The RAM image (port/sceneryRam_FS2.1.bin) was captured from the
|
|
// FS2.1 release under MAME. FS2.1's chunk5 lays a few cells out
|
|
// differently from the FS2 source in src/chunk5.s; those are marked
|
|
// "FS2.1 layout" and the source address is given for cross-reference.
|
|
|
|
#ifndef CHUNK5_ZP_H
|
|
#define CHUNK5_ZP_H
|
|
|
|
// --- Frame setup / section base ------------------------------------
|
|
#define ZP_SCRATCH_X 0x18 // L6BB0 scratch X (16-bit)
|
|
#define ZP_SCRATCH_Y 0x1B
|
|
#define ZP_SCRATCH_Z 0x1E
|
|
#define ZP_POLY_MODE 0x2C // polygon-mode flag ($FF while pooling vertices)
|
|
#define ZP_BASE_X 0x4A // L631D section base, 24-bit x3 (mid/hi at +0/+1, low at +2)
|
|
#define ZP_BASE_Y 0x4D
|
|
#define ZP_BASE_Z 0x50
|
|
#define ZP_EXPONENT 0x2F // auto-scale exponent of the latest xform-B
|
|
#define RAM_PREV_EXPONENT 0x08EE // exponent of the previous xform-B (curve alignment)
|
|
#define ZP_SCALE_CACHE 0x35 // $35/$36 = last $68/$69 seen by L631D
|
|
#define ZP_AIRCRAFT_X 0x5A // six 16-bit pairs $5A..$65 feeding L6BB0
|
|
#define ZP_AIRCRAFT_X_HI 0x5C
|
|
#define ZP_AIRCRAFT_Y 0x5E
|
|
#define ZP_ALTITUDE 0x5F // 16-bit altitude straddles $5F/$60
|
|
#define ZP_AIRCRAFT_Y_HI 0x60
|
|
#define ZP_AIRCRAFT_Z 0x62
|
|
#define ZP_AIRCRAFT_Z_HI 0x64
|
|
#define ZP_CAM_X 0x66 // camera-vs-section deltas $66/$68/$6A
|
|
#define ZP_CAM_Y 0x68
|
|
#define ZP_CAM_Z 0x6A
|
|
#define ZP_MATRIX 0x78 // 3x3 int16 rotation matrix $78..$89 (row-major, LE)
|
|
#define ZP_MATRIX_ROW1 0x7E
|
|
#define ZP_MATRIX_ROW2 0x84
|
|
#define ZP_STREAM_PTR 0x8B // ($8B/$8C) scenery cursor in chunk5; the port keeps a C pointer
|
|
|
|
// --- Vertex pipeline (source layout; nothing else in the image uses these) ---
|
|
#define ZP_V2_CLIPPED 0x8A // EmitClippedLine: V2 was clipped
|
|
#define ZP_CURVE_STEP 0x9E // $9E/$A0/$A2 = curve step (x,y,z)
|
|
#define ZP_STICKY_OUTCODE 0xB4 // polygon clip pass: side of previous vertex
|
|
#define ZP_POOL_COUNT 0xB5 // polygon vertex count
|
|
#define ZP_V1_OUTCODE 0xCA
|
|
#define ZP_V1 0xCB // V1 x/y/z at $CB..$D0
|
|
#define ZP_V1_SCREEN_COL 0xD1
|
|
#define ZP_V1_SCREEN_ROW 0xD2
|
|
#define ZP_V2_OUTCODE 0xD3 // also the polygon Z-hi AND accumulator in polygon mode
|
|
#define ZP_V2 0xD4 // V2 x/y/z at $D4..$D9
|
|
#define ZP_V2_SCREEN_COL 0xDA
|
|
#define ZP_V2_SCREEN_ROW 0xDB
|
|
#define ZP_V1_SHADOW 0x08 // $08..$10 = snapshot of $CA..$D2 (SnapshotVertex1ToShadow)
|
|
#define ZP_V2_SHADOW 0xDC // $DC..$E2 = snapshot of $D3..$D9 (EmitClippedLine_ClipV2)
|
|
#define ZP_VERTEX_BYTES 6 // x lo/hi, y lo/hi, z lo/hi
|
|
#define ZP_VERTEX_RECORD_BYTES 9 // outcode + xyz + screen col/row
|
|
|
|
// --- Absolute RAM cells --------------------------------------------
|
|
#define RAM_CACHED_POOL 0x0140 // 8-byte cached vertex slots (opcodes $31/$32/$33/$35/$42)
|
|
#define RAM_CACHED_POOL_CAP 80
|
|
#define RAM_CACHED_POOL_STRIDE 8
|
|
#define RAM_RADAR_VIEW 0x0836 // RadarView flag
|
|
#define RAM_FILL_COLOR 0x0876 // polygon fill colour register (low nibble indexes ToHiresColorTable)
|
|
#define RAM_HEADER_SECTION 0x08E5 // $0D HEADER working copy $08E5..$08E9
|
|
#define RAM_HEADER_COUNT 0x08E6
|
|
#define RAM_HEADER_DEST 0x08E7
|
|
#define RAM_HEADER_CACHE_IDX 0x08E9
|
|
#define RAM_HEADER_CACHE 0x08EA // 4 cached section ids
|
|
#define RAM_V1_CLIPPED 0x08C4 // EmitClippedLine: V1 was clipped
|
|
#define RAM_HORIZON_POLY_BASE 0x0A78 // horizon polygon records, 16 bytes per bank quadrant
|
|
#define RAM_SCENERY_ENTRY 0xA7E0 // LA7E0: ProcessScenery entry pointer
|
|
#define RAM_IO_START 0xC000 // Apple II I/O range; never a valid scenery/load target
|
|
#define RAM_IO_END 0xD000
|
|
#define RAM_SIZE 0x10000
|
|
|
|
// --- Screen geometry used by ProjectVertex -------------------------
|
|
#define CHUNK5_SCREEN_CENTRE_COL 0x46 // column bias (0..139 colour pixels)
|
|
#define CHUNK5_SCREEN_CENTRE_ROW 0x31 // row bias (0..98 viewport rows)
|
|
#define CHUNK5_COLOR_COLUMNS 140
|
|
#define CHUNK5_POLY_VERTEX_CAP 60 // ProcessVertex2 caps the pool at $3C
|
|
|
|
// --- Cells and constants shared by several modules (consolidated 2026-09-06) --
|
|
#define DEGREES_360 0x168
|
|
#define FUEL_BURN_INDEX 0xF2
|
|
#define INPUT_MODE_MAGNETO 3
|
|
#define NEEDLE_STEPS 0x58
|
|
#define RAM_AIRSPEED 0x0A11
|
|
#define RAM_ALT_ADJUST 0x099E
|
|
#define RAM_ATIS_BUSY 0x0913
|
|
#define RAM_ATIS_NAME_PTR 0x092A
|
|
#define RAM_BOMB_TIMER 0x0A54
|
|
#define RAM_CARB_HEAT 0x0A58
|
|
#define RAM_CHT 0x099C
|
|
#define RAM_CLIMB_NEEDLE 0x0A36
|
|
#define RAM_COM_FREQ 0x089F
|
|
#define RAM_COM_GATE 0x0909
|
|
#define RAM_COURSE_STEP_A 0x0847
|
|
#define RAM_COURSE_STEP_B 0x0849
|
|
#define RAM_CRASH_CODE 0x0834
|
|
#define RAM_DAY_PHASE 0x083C
|
|
#define RAM_ENEMIES_DOWN 0x0898
|
|
#define RAM_ENGINE_FAULTS 0x0991
|
|
#define RAM_ENVELOPE_TIMER 0x0899
|
|
#define RAM_FUEL_LEFT 0x0992
|
|
#define RAM_FUEL_RIGHT 0x0995
|
|
#define RAM_HEADING 0x09E4
|
|
#define RAM_HEADING_ADJUST 0x08AB
|
|
#define RAM_LANDING_FLAG 0x089A
|
|
#define RAM_MAG_COMPASS 0x08B2
|
|
#define RAM_MAG_VAR_A 0x0846
|
|
#define RAM_MAG_VAR_B 0x0848
|
|
#define RAM_NAV1_FREQ 0x08F7
|
|
#define RAM_NAV2_FREQ 0x08F5
|
|
#define RAM_NAV_ACTIVE 0x08F4
|
|
#define RAM_NAV_GATE 0x08F2
|
|
#define RAM_OIL_TEMP 0x099D
|
|
#define RAM_PROP_DRAG 0x0A0D
|
|
#define RAM_SEASON_SCALE 0x0884
|
|
#define RAM_SIDESLIP 0x09C2
|
|
#define RAM_STATION_X 0x08FE
|
|
#define RAM_STATION_Z 0x08FA
|
|
#define RAM_TANK_SELECT 0x0998
|
|
#define RAM_TARGET_RPM 0x0990
|
|
#define RAM_THROTTLE 0x0A6F
|
|
#define RAM_TURB_X 0x08A1
|
|
#define RAM_TURN_LATCH 0x08B9
|
|
#define RAM_TURN_PREV_PAGE1 0x0A40
|
|
#define RAM_TURN_PREV_PAGE2 0x0A41
|
|
#define RAM_WAR_REPORT_DUE 0x08C8
|
|
#define RPM_IDLE_FLOOR 0x0D
|
|
#define ZP_A5 0xA5
|
|
#define ZP_A7 0xA7
|
|
#define ZP_ALT 0x5F
|
|
#define ZP_ALT_LO 0x5F
|
|
#define ZP_ATT_BANK 0x6E // $6E/$6F
|
|
#define ZP_ATT_HEADING 0x70 // $70/$71
|
|
#define ZP_B7 0xB7
|
|
#define ZP_B8 0xB8
|
|
#define ZP_BC 0xBC
|
|
#define ZP_BE 0xBE
|
|
#define ZP_C2 0xC2
|
|
#define ZP_C4 0xC4
|
|
#define ZP_LINE_DX 0x21
|
|
#define ZP_LINE_DY 0x22
|
|
#define ZP_MAX_ROW 0xF0
|
|
#define ZP_MIN_ROW 0xEF
|
|
#define ZP_MSG_VALUE 0xB6 // ValueForString
|
|
#define ZP_POS_X_HI 0x5C
|
|
#define ZP_POS_Z_HI 0x64
|
|
#define ZP_SPAN_RIGHT 0x27
|
|
#define ZP_TICK_COUNT 0x34
|
|
#define ZP_WORK_HI 0x33
|
|
#define ZP_WORK_LO 0x32
|
|
|
|
#endif
|