135 lines
5.1 KiB
C
135 lines
5.1 KiB
C
/*
|
|
* Copyright (c) 2024 Scott Duensing, scott@kangaroopunch.com
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
|
|
#ifdef __F256K__
|
|
#include "f256lib.h"
|
|
#else
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "util.h"
|
|
#endif
|
|
|
|
|
|
#define A23D2_FAR_BLOCK 42
|
|
#define DATABASE_FAR_BLOCK 43
|
|
|
|
#define DATABASE_FAR 0x56000
|
|
#define DRAWLIST_P0_FAR 0x57000
|
|
#define DRAWLIST_P1_FAR 0x57800
|
|
|
|
#define DATABASE 0x8000
|
|
#define DRAWLIST_P0 0x9000
|
|
#define DRAWLIST_P1 0x9800
|
|
|
|
|
|
// A2-3D2 Function Addresses.
|
|
#define A23D2_ENTRYN 0x6090
|
|
#define A23D2_NXTPT 0x6118
|
|
#define A23D2_SINEX 0x61f6
|
|
#define A23D2_COSEX 0x620f
|
|
|
|
// A2-3D2 Data Addresses.
|
|
#define A23D2_TEST_DATABASE 0x80fb
|
|
#define A23D2_TDATA 0x613e
|
|
#define A23D2_IBP 0x9b
|
|
|
|
// Stuff A2-3D2 is going to clobber that our compiler may want.
|
|
#define COMPILER_ZP_START 0x60 // To 0xC2
|
|
#define COMPILER_ZP_LENGTH 0x62
|
|
#define A23D2_ZP_START COMPILER_ZP_START
|
|
#define A23D2_ZP_LENGTH COMPILER_ZP_LENGTH
|
|
|
|
// Our Scratch Addresses.
|
|
#define CAMERA_SHARED_START 0x200 // To 0x209
|
|
#define CAMERA_SHARED_LENGTH 0x9
|
|
#define SCRATCH_END 0x2ff
|
|
#define COMPILER_ZP_SAVE (CAMERA_SHARED_START + CAMERA_SHARED_LENGTH)
|
|
#define A23D2_ZP_SAVE (COMPILER_ZP_SAVE + COMPILER_ZP_LENGTH)
|
|
|
|
|
|
// A2-3D1 Commands. Commented out items are Apple ][ only.
|
|
#define PNT 0x00 // xLSB, xMSB, yLSB, yMSB, zLSB, zMSB - Define 3D Point
|
|
#define SPNT 0x01 // xLSB, xMSB, yLSB, yMSB, zLSB, zMSB - Define 3D Start Point
|
|
#define CPNT 0x02 // xLSB, xMSB, yLSB, yMSB, zLSB, zMSB - Define 3D Continue Point
|
|
#define RAY 0x03 // xLSB, xMSB, yLSB, yMSB, zLSB, zMSB - Define 3D Ray
|
|
#define CLPSW 0x04 // N - Define Clipper (0=off, 1=on)
|
|
#define EYE 0x05 // xLSB, xMSB, yLSB, yMSB, zLSB, zMSB, P, B, H - Define 3D Eye/Camera
|
|
#define LIN2D 0x06 // X1, Y1, X2, Y2 - Draw 2D Line
|
|
//#define DISP 0x07 // N - Display Select (50=set graphics, 51=set text, 52=clear mixed, 53=set mixed, 54=set page 1, 55=set page 2, 56=clear hi-res, 57=set hi-res)
|
|
//#define ERAS 0x08 // N - Erase Screen (0=erase page 1, 1=erase page 2, 2=fill page 1, 3=fill page 2)
|
|
//#define DRAW 0x09 // N - Select Draw Page (0=page 1, 1=page 2)
|
|
#define PNT2D 0x0a // X1, Y1 - Draw 2D Point
|
|
#define JMP 0x0b // LSB, MSB - Interpretive Jump
|
|
//#define LMODE 0x0c // N - Line Drawing Mode (0=solid, 1=xor)
|
|
#define ARRAY 0x0d // LSB, MSB - Enable Output Array
|
|
#define SCRSZ 0x0e // WIDTH, HEIGHT, xCENTER, yCENTER - Define Screen Size
|
|
#define FIELD 0x0f // xLSB, xMSB, yLSB, yMSB, zLSB, zMSB - Field of View Selection
|
|
#define INIT 0x10 // Easy Init
|
|
#define NOP 0x11 // No Operation
|
|
|
|
// A2-3D2 Commands. Commented out items are Apple ][ only.
|
|
#define STCOL 0x12 // COL - Set Color
|
|
#define ICALL 0x13 // STAT, LOC, ADDR - Independent Object Call
|
|
#define SRES 0x14 // RES - Set Resolution (0=140x192, 1=280x192)
|
|
//#define HLIN 0x15 // x1L, x1H, y1, x2L, x2H, y2 - Hi-Res (280x192) Line 2D
|
|
//#define SHRB 0x16 // xL, xH, y - Set Hi-Res Bias
|
|
//#define HLIN2 0x17 // x1, y1, x2, y2 - Hi-Res (x limited) Line 2D
|
|
//#define HPNT 0x18 // xL, xH, y - Hi-Res (280x192) Point 2D
|
|
//#define HPNT2 0x19 // x, y - Hi-Res (x limited) Point 2D
|
|
#define SKIP 0x1a // SIZE, STATUS - Skip Segment
|
|
//#define PAUS 0x1b // TIME - Pause for TIME/5ths of a Second
|
|
#define SET323 0x1c // LSB, MSB - Set 3D to 3D Array Address
|
|
#define GN323 0x1d // STATUS - Set 3D to 3D Status
|
|
#define END 0x79 // End of Database
|
|
|
|
|
|
typedef struct cameraS { // 9 bytes.
|
|
int16_t x;
|
|
int16_t y;
|
|
int16_t z;
|
|
byte p;
|
|
byte b;
|
|
byte h;
|
|
} cameraT;
|
|
|
|
|
|
extern volatile cameraT *_camera;
|
|
extern volatile cameraT *_cameraInDatabase;
|
|
extern volatile byte *_pointer;
|
|
|
|
extern uint16_t _drawlist;
|
|
extern uint16_t _drawlistInDatabase;
|
|
|
|
extern uint16_t _bytes;
|
|
extern uint8_t _x1;
|
|
extern uint8_t _y1;
|
|
extern uint8_t _x2;
|
|
extern uint8_t _y2;
|
|
extern bool _useColor;
|
|
extern byte _mmu;
|
|
extern byte _ram;
|
|
|
|
|
|
void a23d2Draw(void);
|
|
void a23d2Init(void);
|
|
void a23d2Render(void);
|