110 lines
5.2 KiB
C
110 lines
5.2 KiB
C
// C translation of chunk4 ($0200-$25FF): the fixed-point math helpers,
|
|
// the instrument needle / pixel-list / message drawing routines and the
|
|
// disk block loader. Function names follow the disassembly labels.
|
|
|
|
#ifndef CHUNK4_H
|
|
#define CHUNK4_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
// Math ---------------------------------------------------------------
|
|
|
|
// AXDiv2: signed halve of a 16-bit value.
|
|
uint16_t chunk4AxDiv2(uint16_t ax);
|
|
// DivideSigned16 (L16A2): $C2/$C3 = (A:X) / ($C4/$C5); charges 35 work
|
|
// units. Returns the quotient (also left in $C2/$C3).
|
|
int16_t chunk4DivideSigned16(uint8_t aHi, uint8_t xLo);
|
|
// MultiplyAXByC2: 16x16 unsigned multiply into $C6..$C9; returns the
|
|
// middle word ($C7 low, $C8 high) the 6502 leaves in A/X.
|
|
uint16_t chunk4MultiplyAXByC2(uint16_t ax);
|
|
// MultiplyXY (L1818): signed 7x7 multiply. `carryIn` is the caller's
|
|
// carry flag, which becomes bit 0 of the low byte. Returns lo | hi<<8.
|
|
uint16_t chunk4MultiplyXY(uint8_t y, uint8_t x, bool carryIn);
|
|
// MultiplyXYAndHalve (L180C).
|
|
uint16_t chunk4MultiplyXYAndHalve(uint8_t y, uint8_t x);
|
|
// NegateAX (L1880).
|
|
uint16_t chunk4NegateAX(uint16_t ax);
|
|
// ScaleC2ByAX / ScaleC2ByAXIntoC2 / ScaleC2ByC4 / ZPScale.
|
|
int16_t chunk4ScaleC2ByAX(uint16_t ax);
|
|
int16_t chunk4ScaleC2ByAXIntoC2(uint16_t ax);
|
|
int16_t chunk4ScaleC2ByC4(void);
|
|
void chunk4ZpScale(uint8_t xSlot, uint8_t ySlot, uint8_t destSlot);
|
|
// SinByteAngle (L1763) and SinShiftedByteAngle (L1768).
|
|
int16_t chunk4SinByteAngle(uint8_t angle);
|
|
int16_t chunk4SinShiftedByteAngle(uint8_t angle);
|
|
|
|
// Drawing ------------------------------------------------------------
|
|
|
|
void chunk4ClearViewportsToBlack(void);
|
|
void chunk4DrawFuelOrOilGauge(uint8_t xLo, uint8_t y);
|
|
void chunk4DrawIndicatorDialNeedle(uint8_t pos, uint8_t index);
|
|
// DrawMessage (slew readout with the 5-digit number in $B6/$B7).
|
|
void chunk4DrawMessage(uint16_t msg);
|
|
void chunk4DrawMessageOrange(uint16_t msg);
|
|
void chunk4DrawMessageWhite(uint16_t msg);
|
|
void chunk4DrawMultiMessage(uint16_t msg);
|
|
// DrawPixelList: PixelListData points at the list; x may exceed 255
|
|
// through PixelListXHi.
|
|
void chunk4DrawPixelList(uint8_t xLo, uint8_t y);
|
|
void chunk4DrawPixelListHelper(uint16_t list, uint8_t xLo, uint8_t y);
|
|
// DivideByAXAndSetDigitY: one decimal digit of $B6/$B7 into ($B8),Y.
|
|
void chunk4DivideByAXAndSetDigitY(uint16_t divisor, uint8_t digitIndex);
|
|
|
|
// Instrument updaters (Init entries take the initial value).
|
|
void chunk4UpdateAileronPositionIndicator(uint8_t value);
|
|
void chunk4UpdateAileronPositionIndicatorInit(uint8_t value);
|
|
void chunk4UpdateAirspeedIndicator(void);
|
|
void chunk4UpdateAirspeedIndicatorInit(uint8_t value);
|
|
// UpdateAltimeterIndicator's shared table interpolator: returns A and
|
|
// leaves the 16-bit result in $C2/$C3.
|
|
uint8_t chunk4UpdateAltimeterIndicator(void);
|
|
void chunk4UpdateAltimeterIndicatorInit(void);
|
|
void chunk4UpdateAltimeterIndicatorInit2(void);
|
|
void chunk4UpdateElevatorPositionIndicator(uint8_t value);
|
|
void chunk4UpdateElevatorPositionIndicatorInit(uint8_t value);
|
|
void chunk4UpdateFlapsIndicator(uint8_t value);
|
|
void chunk4UpdateFlapsIndicatorInit(uint8_t value);
|
|
void chunk4UpdateFuelTankGaugesInitLeft(uint8_t value);
|
|
void chunk4UpdateFuelTankGaugesInitRight(uint8_t value);
|
|
void chunk4UpdateFuelTankGaugesLeft(void);
|
|
void chunk4UpdateFuelTankGaugesRight(void);
|
|
void chunk4UpdateFuelTankIndicator(void);
|
|
void chunk4UpdateMixtureControlIndicator(uint8_t value);
|
|
void chunk4UpdateMixtureControlIndicatorInit(uint8_t value);
|
|
void chunk4UpdateOilTempAndPressureGaugesInitPressure(uint8_t value);
|
|
void chunk4UpdateOilTempAndPressureGaugesInitTemp(uint8_t value);
|
|
void chunk4UpdateOilTempAndPressureGaugesPressure(void);
|
|
void chunk4UpdateOilTempAndPressureGaugesTemp(void);
|
|
void chunk4UpdateRudderPositionIndicator(uint8_t value);
|
|
void chunk4UpdateRudderPositionIndicatorInit(uint8_t value);
|
|
void chunk4UpdateSlipSkidIndicator(uint8_t value);
|
|
void chunk4UpdateSlipSkidIndicatorInit(uint8_t value);
|
|
void chunk4UpdateThrottleIndicator(uint8_t value);
|
|
void chunk4UpdateThrottleIndicatorInit(uint8_t value);
|
|
void chunk4UpdateTrimIndicator(uint8_t value);
|
|
void chunk4UpdateTrimIndicatorInit(uint8_t value);
|
|
void chunk4UpdateVerticalSpeedIndicator(void);
|
|
void chunk4UpdateVerticalSpeedIndicatorInit(uint8_t value);
|
|
|
|
// Disk loader -------------------------------------------------------
|
|
|
|
// ComputeBlockFromSector: false = carry clear (in range).
|
|
bool chunk4ComputeBlockFromSector(void);
|
|
void chunk4DoReadBlock(uint8_t blockLo, uint8_t blockHi);
|
|
void chunk4DoReadBlockWithStandardDataBuffer(uint8_t blockLo, uint8_t blockHi);
|
|
// FetchSectorFromDisk: returns the carry (always clear).
|
|
bool chunk4FetchSectorFromDisk(void);
|
|
void chunk4PopulateA5ThruA8From1E03(void);
|
|
void chunk4ReadBlocks(uint8_t listIndex);
|
|
void chunk4SwapFourPagesWithStash(void);
|
|
void chunk4SwapPagesWithStash(uint8_t pages);
|
|
void chunk4SwapZP(void);
|
|
|
|
// The seven scenery-loader thunks (SceneryLoaderThunk1..7). In 64K
|
|
// mode Apply64KPatchTable routes them to chunk3; the 48K targets are
|
|
// not part of the disassembly, so unpatched calls fail (carry set).
|
|
bool chunk4SceneryLoaderThunk(int index);
|
|
void chunk4SetLoaderPatched(bool patched);
|
|
|
|
#endif
|