// Course Plotter (FS2 64K-only feature, chunk2 lines 25-150). // // FS2's `CoursePlotterState` is one of three values: // 0 = OFF, 1 = RECORD, 2 = DISPLAY // // In RECORD mode the simulator samples the aircraft's position every // `sampleRate` frames into a circular buffer ($D000-$DFFF in the // language card). DISPLAY mode redraws the recorded course in the // radar viewport. // // The C port keeps the same state machine but stores samples in an // in-process buffer (4KB) rather than the LC bank. Recording uses // either NORMAL (range=$06, rate=$0A) or PRECISION (range=$04, rate=$02) // per FS2 chunk2 BeginNormalCourseRecording / BeginPrecisionRecording. #ifndef COURSE_PLOTTER_H #define COURSE_PLOTTER_H #include #include struct AircraftT; struct FramebufferT; typedef enum CoursePlotterStateE { COURSE_PLOT_OFF = 0, COURSE_PLOT_RECORD = 1, COURSE_PLOT_DISPLAY = 2 } CoursePlotterStateE; #define COURSE_PLOT_BUFFER_BYTES 4096 #define COURSE_PLOT_SAMPLE_BYTES 8 // 2 * 24-bit XYZ rounded up typedef struct CoursePlotterT { CoursePlotterStateE state; uint8_t sampleRate; // frames between samples (chunk2: $0A normal, $02 precision) uint8_t sampleRange; // chunk2 sampleRange byte uint8_t sampleCounter; // counts down to 0, then take a sample bool anyData; // true once a sample has been captured uint16_t recordPos; // byte offset into buffer uint8_t buffer[COURSE_PLOT_BUFFER_BYTES]; } CoursePlotterT; void coursePlotterInit(CoursePlotterT *cp); // Begin a recording session. Mode must be RECORD or OFF; precision // chooses between normal (rate 10/range 6) and precision (rate 2/range 4). void coursePlotterBeginRecord(CoursePlotterT *cp, bool precision); void coursePlotterBeginDisplay(CoursePlotterT *cp); void coursePlotterTurnOff(CoursePlotterT *cp); // Per-frame: if state == RECORD, count down sampleCounter and snapshot // the aircraft's scenery position into the buffer when it hits 0. void coursePlotterStep(CoursePlotterT *cp, const struct AircraftT *ac); // Render the recorded course on top of the framebuffer (called when // state == DISPLAY in radar/3D view). void coursePlotterRender(const CoursePlotterT *cp, struct FramebufferT *fb, const struct AircraftT *ac); // Draw a short status line ("COURSE PLOT REC" / "COURSE PLOT VIEW") // when the plotter is active. No-op when off. void coursePlotterDrawStatus(const CoursePlotterT *cp, struct FramebufferT *fb); #endif