fs2port/port/include/hires.h

74 lines
2.6 KiB
C

// chunk5's hires drawing kernels (PlotColorPixel, DrawColorLine,
// DrawColorSpan) and the pen state chunk5 keeps as self-modified
// opcodes (SetPixelDrawMode, SetEvenAndOddColorsAndPrepRowRoutine,
// SceneryOpDayOnly / SceneryOpModeWhite), operating on the hires pages
// inside fs2Ram through the HiresTableLo/Hi row tables exactly as the
// 6502 code does.
#ifndef HIRES_H
#define HIRES_H
#include <stdbool.h>
#include <stdint.h>
#define HIRES_ROWS 192
#define HIRES_BYTES_PER_ROW 40
// DrawColorLine's endpoint cells ($E9..$EC), shared with every caller.
#define ZP_LINE_X1 0xE9
#define ZP_LINE_Y1 0xEA
#define ZP_LINE_X2 0xEB
#define ZP_LINE_Y2 0xEC
#define HIRES_WIDTH 280
#define HIRES_COLOR_COLUMNS 140
#define HIRES_PIXELS_PER_BYTE 7
#define HIRES_SPLIT_BIT 3 // colour pixel whose two bits straddle a byte
// chunk5 hires colour codes (ToHiresColorTable values).
typedef enum HiresColorE {
HIRES_BLACK1 = 0,
HIRES_VIOLET = 1,
HIRES_GREEN = 2,
HIRES_WHITE1 = 3,
HIRES_BLACK2 = 4,
HIRES_BLUE = 5,
HIRES_ORANGE = 6,
HIRES_WHITE2 = 7,
} HiresColorE;
// Decode the hires page at `pageBase` ($2000 or $4000) into a 280x192
// 0x00RRGGBB image, approximating the NTSC colour of bit pairs.
void hiresDecodeToRgb(uint16_t pageBase, uint32_t *out);
// DrawColorLine: Bresenham line from ($E9,$EA) to ($EB,$EC) in colour
// pixels; charges the frame work counter.
void hiresDrawColorLine(void);
// DrawColorSpan: paint `width + 1` colour pixels ending at column $27
// on the row HiresRowPtr points at.
void hiresDrawColorSpan(uint8_t width);
// PlotColorPixel: plot one colour pixel; sets HiresRowPtr to the row.
// Returns the pixel's bit index in *outBit and byte index in *outByte
// (the X/Y registers the 6502 routine leaves behind).
void hiresPlotColorPixel(uint8_t column, uint8_t row, uint8_t *outBit, uint8_t *outByte);
// MapColorAndPrepRowRoutine: select the span pen from $0876.
void hiresMapColorAndPrepRowRoutine(void);
// The HiresTableLo/Hi row address for `row` (rotated by HiresPageDelta).
uint16_t hiresRowAddress(uint8_t row);
// SetEvenAndOddColorsAndPrepRowRoutine: select the span pen for a hires
// colour code.
void hiresSetEvenAndOddColors(uint8_t hiresColor);
// SceneryOpDayOnly (false: dotted lines) / SceneryOpModeWhite (true).
void hiresSetPaintLines(bool paint);
// SetPixelDrawMode: select the line/pixel pen. Bit 7 selects EOR.
void hiresSetPixelDrawMode(uint8_t color);
// Load HiresRowPtr ($8E/$8F) from the row tables.
void hiresSetRowPtr(uint8_t row);
#endif