←↑↓→ Joypad
Space Button A
Shift Button B
diff --git a/presets/pce/siegegame.c b/presets/pce/siegegame.c
new file mode 100644
index 00000000..8115b385
--- /dev/null
+++ b/presets/pce/siegegame.c
@@ -0,0 +1,241 @@
+/*
+Text-based version of a Blockade-style game.
+For more information, see "Making Arcade Games in C".
+*/
+
+#include
+#include
+#include
+#include
+
+#define COLS 50
+#define ROWS 28
+
+typedef unsigned char byte;
+typedef signed char sbyte;
+typedef unsigned short word;
+typedef signed short sword;
+
+// get the character at a specfic x/y position
+byte readcharxy(byte x, byte y) {
+ gotoxy(x,y); // set cursor position
+ return cpeekc();
+}
+
+void delay(byte count) {
+ while (count--) {
+ waitvsync();
+ }
+}
+
+////////// GAME DATA
+
+typedef struct {
+ byte x;
+ byte y;
+ byte dir;
+ word score;
+ char head_attr;
+ char tail_attr;
+ int collided:1;
+ int human:1;
+} Player;
+
+Player players[2];
+
+byte credits = 0;
+byte frames_per_move;
+byte gameover;
+
+#define START_SPEED 12
+#define MAX_SPEED 5
+#define MAX_SCORE 7
+
+///////////
+
+const char BOX_CHARS[8] = { '+', '+', '+', '+',
+ '-', '-', '!', '!'};
+
+void draw_box(byte x, byte y, byte x2, byte y2, const char* chars) {
+ byte x1 = x;
+ cputcxy(x, y, chars[2]);
+ cputcxy(x2, y, chars[3]);
+ cputcxy(x, y2, chars[0]);
+ cputcxy(x2, y2, chars[1]);
+ while (++x < x2) {
+ cputcxy(x, y, chars[5]);
+ cputcxy(x, y2, chars[4]);
+ }
+ while (++y < y2) {
+ cputcxy(x1, y, chars[6]);
+ cputcxy(x2, y, chars[7]);
+ }
+}
+
+void draw_playfield() {
+ draw_box(0,1,COLS-1,ROWS-1,BOX_CHARS);
+ cputsxy( 0, 0, "Plyr1:");
+ cputsxy(20, 0, "Plyr2:");
+ cputcxy( 7, 0, players[0].score+'0');
+ cputcxy(27, 0, players[1].score+'0');
+}
+
+typedef enum { D_RIGHT, D_DOWN, D_LEFT, D_UP } dir_t;
+const sbyte DIR_X[4] = { 1, 0, -1, 0 };
+const sbyte DIR_Y[4] = { 0, 1, 0, -1 };
+
+void init_game() {
+ memset(players, 0, sizeof(players));
+ players[0].head_attr = '1';
+ players[1].head_attr = '2';
+ players[0].tail_attr = '#';
+ players[1].tail_attr = '*';
+ frames_per_move = START_SPEED;
+}
+
+void reset_players() {
+ players[0].x = players[0].y = 5;
+ players[0].dir = D_RIGHT;
+ players[1].x = COLS-6;
+ players[1].y = ROWS-6;
+ players[1].dir = D_LEFT;
+ players[0].collided = players[1].collided = 0;
+}
+
+void draw_player(Player* p) {
+ cputcxy(p->x, p->y, p->head_attr);
+}
+
+void move_player(Player* p) {
+ cputcxy(p->x, p->y, p->tail_attr);
+ p->x += DIR_X[p->dir];
+ p->y += DIR_Y[p->dir];
+ if ((readcharxy(p->x, p->y) & 0x7f) != ' ')
+ p->collided = 1;
+ draw_player(p);
+}
+
+void human_control(Player* p) {
+ byte dir = 0xff;
+ char joy;
+ if (!p->human) return;
+ //if (!kbhit()) return;
+ joy = joy_read(0);
+ if (JOY_UP(joy)) dir = D_UP;
+ if (JOY_LEFT(joy)) dir = D_LEFT;
+ if (JOY_RIGHT(joy)) dir = D_RIGHT;
+ if (JOY_DOWN(joy)) dir = D_DOWN;
+ // don't let the player reverse direction
+ if (dir < 0x80 && dir != (p->dir ^ 2)) {
+ p->dir = dir;
+ }
+}
+
+byte ai_try_dir(Player* p, dir_t dir, byte shift) {
+ byte x,y;
+ dir &= 3;
+ x = p->x + (DIR_X[dir] << shift);
+ y = p->y + (DIR_Y[dir] << shift);
+ if (x < COLS && y < ROWS
+ && (readcharxy(x, y) & 0x7f) == ' ') {
+ p->dir = dir;
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+void ai_control(Player* p) {
+ dir_t dir;
+ if (p->human) return;
+ dir = p->dir;
+ if (!ai_try_dir(p, dir, 0)) {
+ ai_try_dir(p, dir+1, 0);
+ ai_try_dir(p, dir-1, 0);
+ } else {
+ ai_try_dir(p, dir-1, 0) && ai_try_dir(p, dir-1, 1+(rand() & 3));
+ ai_try_dir(p, dir+1, 0) && ai_try_dir(p, dir+1, 1+(rand() & 3));
+ ai_try_dir(p, dir, rand() & 3);
+ }
+}
+
+void flash_colliders() {
+ byte i;
+ // flash players that collided
+ for (i=0; i<56; i++) {
+ delay(2);
+ revers(players[0].collided && (i&1));
+ draw_player(&players[0]);
+ revers(players[1].collided && (i&1));
+ draw_player(&players[1]);
+ }
+ revers(0);
+}
+
+void make_move() {
+ byte i;
+ for (i=0; i MAX_SPEED) frames_per_move--;
+ // game over?
+ if (players[0].score != players[1].score) {
+ if (players[0].score >= MAX_SCORE)
+ declare_winner(0);
+ else if (players[1].score >= MAX_SCORE)
+ declare_winner(1);
+ }
+}
+
+void play_game() {
+ gameover = 0;
+ init_game();
+ players[0].human = 1;
+ while (!gameover) {
+ play_round();
+ }
+}
+
+void main() {
+ joy_install (joy_static_stddrv);
+ play_game();
+}
diff --git a/presets/pce/test_conio.c b/presets/pce/test_conio.c
new file mode 100644
index 00000000..36fed0f9
--- /dev/null
+++ b/presets/pce/test_conio.c
@@ -0,0 +1,14 @@
+
+#include
+#include
+
+int tmp; // need at least 1 variable
+
+int main() {
+ clrscr();
+ bgcolor(COLOR_BLUE);
+ textcolor(COLOR_WHITE);
+ cputs("\r\n*** HELLO WORLD! ***");
+ while (1) ;
+ return 0;
+}
diff --git a/src/platform/_index.ts b/src/platform/_index.ts
index 31494be6..e71fedf4 100644
--- a/src/platform/_index.ts
+++ b/src/platform/_index.ts
@@ -18,6 +18,7 @@ export function importPlatform(name: string) : Promise {
case "msx": return import("../platform/msx");
case "mw8080bw": return import("../platform/mw8080bw");
case "nes": return import("../platform/nes");
+ case "pce": return import("../platform/pce");
case "script": return import("../platform/script");
case "sms": return import("../platform/sms");
case "sound_konami": return import("../platform/sound_konami");
diff --git a/src/platform/pce.ts b/src/platform/pce.ts
new file mode 100644
index 00000000..f8cdb59e
--- /dev/null
+++ b/src/platform/pce.ts
@@ -0,0 +1,3824 @@
+import { Platform, Preset, getToolForFilename_6502 } from "../common/baseplatform";
+import { Keys, PLATFORMS, RasterVideo } from "../common/emu";
+
+const PCE_PRESETS = [
+ {id:'test_conio.c', name:'Hello World (conio)'},
+ {id:'siegegame.c', name:'Siege Game (conio)'},
+]
+
+class PCEnginePlatform implements Platform {
+ mainElement : HTMLElement;
+ pce : PCE;
+ video : RasterVideo;
+
+ constructor(mainElement) {
+ this.mainElement = mainElement;
+ }
+ start(): void | Promise {
+ this.pce = new PCE();
+ this.video = new RasterVideo(this.mainElement,684,262,{overscan:true});
+ this.video.create();
+ this.pce.SetCanvas(this.video.canvas);
+ }
+ reset(): void {
+ this.pce.Reset();
+ }
+ isRunning(): boolean {
+ return this.pce.TimerID != null;
+ }
+ pause(): void {
+ this.pce.Pause();
+ }
+ resume(): void {
+ this.pce.CreateAudioContext();
+ this.pce.Start();
+ }
+ getPresets(): Preset[] {
+ return PCE_PRESETS;
+ }
+ loadROM(title: string, rom: any) {
+ this.pce.Pause();
+ this.pce.Init();
+ this.pce.SetROM(rom);
+ }
+ getPlatformName(): string {
+ return "PC Engine";
+ }
+ getToolForFilename(fn: string): string {
+ return getToolForFilename_6502(fn);
+ }
+ getDefaultExtension(): string {
+ return ".pce";
+ }
+}
+
+PLATFORMS['pce'] = PCEnginePlatform;
+
+/*
+
+https://github.com/yhzmr442/jspce
+
+MIT License
+
+Copyright (c) 2019 yhzmr442
+
+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.
+
+*/
+
+class PCE {
+ SuperGrafx: boolean;
+ CountryTypePCE: number;
+ CountryTypeTG16: number;
+ CountryType: any;
+ GamePadButton6: boolean;
+ MultiTap: boolean;
+ TimerID: number | null;c
+ MainCanvas: HTMLCanvasElement | null = null;
+ Ctx: CanvasRenderingContext2D | null = null;
+ ImageData: ImageData | null = null;
+ DrawFlag: boolean;
+ Mapper: any;
+ OpCycles: number[];
+ OpBytes: number[];
+ A: number;
+ X: number;
+ Y: number;
+ PC: number;
+ S: number;
+ P: number;
+ NZCacheTable: any[];
+ NFlag: number;
+ VFlag: number;
+ TFlag: number;
+ BFlag: number;
+ DFlag: number;
+ IFlag: number;
+ ZFlag: number;
+ CFlag: number;
+ TIQFlag: number;
+ IRQ1Flag: number;
+ IRQ2Flag: number;
+ ProgressClock: number;
+ CPUBaseClock: number;
+ BaseClock1: number;
+ BaseClock3: number;
+ BaseClock5: number;
+ BaseClock7: number;
+ BaseClock10: number;
+ TransferSrc: number;
+ TransferDist: number;
+ TransferLen: number;
+ TransferAlt: number;
+ LastInt: number;
+ MPRSelect: any;
+ MPR: any;
+ RAM: any[];
+ RAMMask: number;
+ BRAM: any[];
+ BRAMUse: boolean;
+ INTIRQ2: number;
+ IntDisableRegister: number;
+ MapperBase = class {
+ ROM: number[];
+ Core: any;
+ constructor(rom, core) {
+ this.ROM = rom;
+ this.Core = core;
+ }
+
+ Init() {
+ }
+
+ Read(address) {
+ return 0xFF;
+ }
+
+ Write(address, data) {
+ }
+ };
+ Mapper0: typeof this.MapperBase;
+ Mapper1: typeof this.MapperBase;
+ Mapper2: typeof this.MapperBase;
+ VDC: any;
+ INTTIQ: number;
+ Palette: any[];
+ PaletteData: any[];
+ MonoPaletteData: any[];
+ VCEBaseClock: number;
+ VCEControl: number;
+ VCEAddress: number;
+ VCEData: number;
+ VPCRegister: any[];
+ VPCWindow1: number;
+ VPCWindow2: number;
+ VPCPriority: any[];
+ VDCPutLineProgressClock: number;
+ VDCPutLine: number;
+ VDCLineClock: number;
+ ScreenSize: any[];
+ PutScreenSize: any[];
+ VScreenWidthArray: any[];
+ ReverseBit: any[];
+ ReverseBit16: any[];
+ ReverseBit256: any[];
+ SPAddressMask: any[];
+ WaveDataArray: any[];
+ WaveClockCounter: number;
+ WaveVolume: number;
+ WebAudioCtx: AudioContext;
+ WebAudioJsNode: any;
+ WebAudioGainNode: any;
+ WebAudioBufferSize: number;
+ PSGClock: number;
+ WaveLfoOn: any;
+ PSGChannel: any;
+ WaveVolumeLeft: any;
+ WaveVolumeRight: any;
+ PSGBaseClock: any;
+ PSGProgressClock: number;
+ WaveLfoControl: number;
+ WaveLfoFreqency: number;
+ TimerBaseClock: any;
+ TimerReload: number;
+ TimerFlag: boolean;
+ TimerCounter: number;
+ TimerPrescaler: number;
+ JoystickSEL: number;
+ JoystickCLR: number;
+ KeyUpFunction: null;
+ KeyDownFunction: null;
+ Keybord: any[];
+ GamePad: any[];
+ GamePadSelect: number;
+ GamePadButtonSelect: number;
+ GamePadBuffer: number;
+ GamePadData: any[];
+ GamePadKeyData: { index: number; data: number; }[];
+ GamePadPovData: number[];
+ VDCSelect: number = 0;
+ ScreenWidthMAX = 0;
+ ScreenHeightMAX = 0;
+
+ constructor() {
+ /* ***************** */
+ /* **** Setting **** */
+ /* ***************** */
+ this.SuperGrafx = false;
+ this.CountryTypePCE = 0x40;
+ this.CountryTypeTG16 = 0x00;
+ this.CountryType = this.CountryTypePCE;
+ this.GamePadButton6 = false;
+ this.MultiTap = false;
+
+ /* ******************* */
+ /* **** Construct **** */
+ /* ******************* */
+ this.EtcConstruct();
+ this.CPUConstruct();
+ this.StorageConstruct();
+ this.VCEConstruct();
+ this.VPCConstruct();
+ this.VDCConstruct();
+ this.SoundConstruct();
+ this.PSGConstruct();
+ this.TimerConstruct();
+ this.JoystickConstruct();
+ }
+
+
+ /* ************* */
+ /* **** ETC **** */
+ /* ************* */
+ EtcConstruct() {
+ this.TimerID = null;
+ this.MainCanvas = null;
+ this.Ctx = null;
+ this.ImageData = null;
+ }
+
+
+ UpdateAnimationFrame() {
+ this.TimerID = window.requestAnimationFrame(this.UpdateAnimationFrame.bind(this));
+ this.Run();
+ }
+
+
+ CancelAnimationFrame() {
+ window.cancelAnimationFrame(this.TimerID);
+ this.TimerID = null;
+ }
+
+
+ Pause() {
+ if(this.TimerID != null) {
+ this.JoystickEventRelease();
+ this.CancelAnimationFrame();
+ }
+ }
+
+
+ Start() {
+ if(this.TimerID == null) {
+ this.JoystickEventInit();
+ this.UpdateAnimationFrame();
+ }
+ }
+
+
+ Run() {
+ this.CheckGamePad();
+ this.DrawFlag = false;
+ while(!this.DrawFlag) {
+ this.CPURun();
+ this.VDCRun();
+ this.TimerRun();
+ this.PSGRun();
+ }
+ }
+
+
+ Reset() {
+ this.StorageReset();
+ this.Mapper.Init();
+ this.CPUInit();
+ this.VCEInit();
+ this.VPCInit();
+ this.VDCInit();
+ this.TimerInit();
+ this.JoystickInit();
+ this.PSGInit();
+ this.CPUReset();
+ }
+
+
+ Init() {
+ this.StorageInit();
+ this.CPUInit();
+ this.VCEInit();
+ this.VPCInit();
+ this.VDCInit();
+ this.TimerInit();
+ this.JoystickInit();
+ this.PSGInit();
+ }
+
+
+ SetCanvas(canvas: HTMLCanvasElement) {
+ this.MainCanvas = canvas;
+ if (!this.MainCanvas.getContext)
+ return false;
+
+ this.Ctx = this.MainCanvas.getContext("2d");
+ this.ImageData = this.Ctx.createImageData(this.MainCanvas.width, this.MainCanvas.height); // this.ScreenWidthMAX, this.ScreenHeightMAX);
+ for(let i=0; i { return i & 0x80; });
+ this.NZCacheTable[0x00] = 0x02;
+
+ this.NFlag = 0x80;
+ this.VFlag = 0x40;
+ this.TFlag = 0x20;
+ this.BFlag = 0x10;
+ this.DFlag = 0x08;
+ this.IFlag = 0x04;
+ this.ZFlag = 0x02;
+ this.CFlag = 0x01;
+
+ this.TIQFlag = 0x04;
+ this.IRQ1Flag = 0x02;
+ this.IRQ2Flag = 0x01;
+
+ this.ProgressClock = 0;
+ this.CPUBaseClock = 0;
+
+ this.BaseClock1 = 12;
+ this.BaseClock3 = 6;
+ this.BaseClock5 = 4;
+ this.BaseClock7 = 3;
+ this.BaseClock10 = 2;
+
+ this.TransferSrc = 0;
+ this.TransferDist = 0;
+ this.TransferLen = 0;
+ this.TransferAlt = 0;
+ }
+
+
+ CPUReset() {
+ this.TransferSrc = 0;
+ this.TransferDist = 0;
+ this.TransferLen = 0;
+ this.TransferAlt = 0;
+
+ this.CPUBaseClock = this.BaseClock1;
+
+ this.SetIFlag();
+ this.PC = this.Get16(0xFFFE);
+ }
+
+
+ CPUInit() {
+ this.A = 0;
+ this.X = 0;
+ this.Y = 0;
+ this.PC = 0;
+ this.S = 0;
+ this.P = 0x00;
+
+ this.ProgressClock = 0;
+ this.CPUBaseClock = this.BaseClock1;
+
+ this.TransferSrc = 0;
+ this.TransferDist = 0;
+ this.TransferLen = 0;
+ this.TransferAlt = 0;
+
+ this.LastInt = 0x00;
+ }
+
+
+ CPURun() {
+ this.ProgressClock = 0;
+
+ let tmp = this.LastInt;
+ this.LastInt = (this.P & this.IFlag) == 0x00 ? this.GetIntStatus() : 0x00;
+
+ if(tmp != 0x00 && this.TransferLen == 0) {
+ this.LastInt = 0x00;
+
+ if((tmp & this.TIQFlag) == this.TIQFlag) {//TIQ
+ this.Push(this.PCH());
+ this.Push(this.PCL());
+ this.Push(this.P);
+ this.P = 0x04;
+ this.PC = this.Get16(0xFFFA);
+ } else if((tmp & this.IRQ1Flag) == this.IRQ1Flag) {//IRQ1
+ this.Push(this.PCH());
+ this.Push(this.PCL());
+ this.Push(this.P);
+ this.P = 0x04;
+ this.PC = this.Get16(0xFFF8);
+ } else if((tmp & this.IRQ2Flag) == this.IRQ2Flag) {//IRQ2
+ this.Push(this.PCH());
+ this.Push(this.PCL());
+ this.Push(this.P);
+ this.SetIFlag();
+ this.PC = this.Get16(0xFFF6);
+ }
+ this.ProgressClock = 8 * this.CPUBaseClock;
+ } else
+ this.OpExec();
+ }
+
+
+ OpExec() {
+ let address;
+ let tmp;
+ let data;
+ let bit;
+ let i;
+
+ let op = this.Get(this.PC);
+
+ switch(op) {
+ case 0x69: // ADC IMM
+ this.ADC(this.PC + 1);
+ break;
+ case 0x65: // ADC ZP
+ this.ADC(this.ZP());
+ break;
+ case 0x75: // ADC ZP, X
+ this.ADC(this.ZP_X());
+ break;
+ case 0x72: // ADC (IND)
+ this.ADC(this.IND());
+ break;
+ case 0x61: // ADC (IND, X)
+ this.ADC(this.IND_X());
+ break;
+ case 0x71: // ADC (IND), Y
+ this.ADC(this.IND_Y());
+ break;
+ case 0x6D: // ADC ABS
+ this.ADC(this.ABS());
+ break;
+ case 0x7D: // ADC ABS, X
+ this.ADC(this.ABS_X());
+ break;
+ case 0x79: // ADC ABS, Y
+ this.ADC(this.ABS_Y());
+ break;
+
+ case 0xE9: // SBC IMM
+ this.SBC(this.PC + 1);
+ break;
+ case 0xE5: // SBC ZP
+ this.SBC(this.ZP());
+ break;
+ case 0xF5: // SBC ZP, X
+ this.SBC(this.ZP_X());
+ break;
+ case 0xF2: // SBC (IND)
+ this.SBC(this.IND());
+ break;
+ case 0xE1: // SBC (IND, X)
+ this.SBC(this.IND_X());
+ break;
+ case 0xF1: // SBC (IND), Y
+ this.SBC(this.IND_Y());
+ break;
+ case 0xED: // SBC ABS
+ this.SBC(this.ABS());
+ break;
+ case 0xFD: // SBC ABS, X
+ this.SBC(this.ABS_X());
+ break;
+ case 0xF9: // SBC ABS, Y
+ this.SBC(this.ABS_Y());
+ break;
+
+ case 0x29: // AND IMM
+ this.AND(this.PC + 1);
+ break;
+ case 0x25: // AND ZP
+ this.AND(this.ZP());
+ break;
+ case 0x35: // AND ZP, X
+ this.AND(this.ZP_X());
+ break;
+ case 0x32: // AND (IND)
+ this.AND(this.IND());
+ break;
+ case 0x21: // AND (IND, X)
+ this.AND(this.IND_X());
+ break;
+ case 0x31: // AND (IND), Y
+ this.AND(this.IND_Y());
+ break;
+ case 0x2D: // AND ABS
+ this.AND(this.ABS());
+ break;
+ case 0x3D: // AND ABS, X
+ this.AND(this.ABS_X());
+ break;
+ case 0x39: // AND ABS, Y
+ this.AND(this.ABS_Y());
+ break;
+
+ case 0x49: // EOR IMM
+ this.EOR(this.PC + 1);
+ break;
+ case 0x45: // EOR ZP
+ this.EOR(this.ZP());
+ break;
+ case 0x55: // EOR ZP, X
+ this.EOR(this.ZP_X());
+ break;
+ case 0x52: // EOR (IND)
+ this.EOR(this.IND());
+ break;
+ case 0x41: // EOR (IND, X)
+ this.EOR(this.IND_X());
+ break;
+ case 0x51: // EOR (IND), Y
+ this.EOR(this.IND_Y());
+ break;
+ case 0x4D: // EOR ABS
+ this.EOR(this.ABS());
+ break;
+ case 0x5D: // EOR ABS, X
+ this.EOR(this.ABS_X());
+ break;
+ case 0x59: // EOR ABS, Y
+ this.EOR(this.ABS_Y());
+ break;
+
+ case 0x09: // ORA IMM
+ this.ORA(this.PC + 1);
+ break;
+ case 0x05: // ORA ZP
+ this.ORA(this.ZP());
+ break;
+ case 0x15: // ORA ZP, X
+ this.ORA(this.ZP_X());
+ break;
+ case 0x12: // ORA (IND)
+ this.ORA(this.IND());
+ break;
+ case 0x01: // ORA (IND, X)
+ this.ORA(this.IND_X());
+ break;
+ case 0x11: // ORA (IND), Y
+ this.ORA(this.IND_Y());
+ break;
+ case 0x0D: // ORA ABS
+ this.ORA(this.ABS());
+ break;
+ case 0x1D: // ORA ABS, X
+ this.ORA(this.ABS_X());
+ break;
+ case 0x19: // ORA ABS, Y
+ this.ORA(this.ABS_Y());
+ break;
+
+ case 0x06: // ASL ZP
+ address = this.ZP();
+ this.Set(address, this.ASL(this.Get(address)));
+ break;
+ case 0x16: // ASL ZP, X
+ address = this.ZP_X();
+ this.Set(address, this.ASL(this.Get(address)));
+ break;
+ case 0x0E: // ASL ABS
+ address = this.ABS();
+ this.Set(address, this.ASL(this.Get(address)));
+ break;
+ case 0x1E: // ASL ABS, X
+ address = this.ABS_X();
+ this.Set(address, this.ASL(this.Get(address)));
+ break;
+ case 0x0A: // ASL A
+ this.A = this.ASL(this.A);
+ break;
+
+ case 0x46: // LSR ZP
+ address = this.ZP();
+ this.Set(address, this.LSR(this.Get(address)));
+ break;
+ case 0x56: // LSR ZP, X
+ address = this.ZP_X();
+ this.Set(address, this.LSR(this.Get(address)));
+ break;
+ case 0x4E: // LSR ABS
+ address = this.ABS();
+ this.Set(address, this.LSR(this.Get(address)));
+ break;
+ case 0x5E: // LSR ABS, X
+ address = this.ABS_X();
+ this.Set(address, this.LSR(this.Get(address)));
+ break;
+ case 0x4A: // LSR A
+ this.A = this.LSR(this.A);
+ break;
+
+ case 0x26: // ROL ZP
+ address = this.ZP();
+ this.Set(address, this.ROL(this.Get(address)));
+ break;
+ case 0x36: // ROL ZP, X
+ address = this.ZP_X();
+ this.Set(address, this.ROL(this.Get(address)));
+ break;
+ case 0x2E: // ROL ABS
+ address = this.ABS();
+ this.Set(address, this.ROL(this.Get(address)));
+ break;
+ case 0x3E: // ROL ABS, X
+ address = this.ABS_X();
+ this.Set(address, this.ROL(this.Get(address)));
+ break;
+ case 0x2A: // ROL A
+ this.A = this.ROL(this.A);
+ break;
+
+ case 0x66: // ROR ZP
+ address = this.ZP();
+ this.Set(address, this.ROR(this.Get(address)));
+ break;
+ case 0x76: // ROR ZP, X
+ address = this.ZP_X();
+ this.Set(address, this.ROR(this.Get(address)));
+ break;
+ case 0x6E: // ROR ABS
+ address = this.ABS();
+ this.Set(address, this.ROR(this.Get(address)));
+ break;
+ case 0x7E: // ROR ABS, X
+ address = this.ABS_X();
+ this.Set(address, this.ROR(this.Get(address)));
+ break;
+ case 0x6A: // ROR A
+ this.A = this.ROR(this.A);
+ break;
+
+ case 0x0F: // BBR0
+ this.BBRi(0);
+ break;
+ case 0x1F: // BBR1
+ this.BBRi(1);
+ break;
+ case 0x2F: // BBR2
+ this.BBRi(2);
+ break;
+ case 0x3F: // BBR3
+ this.BBRi(3);
+ break;
+ case 0x4F: // BBR4
+ this.BBRi(4);
+ break;
+ case 0x5F: // BBR5
+ this.BBRi(5);
+ break;
+ case 0x6F: // BBR6
+ this.BBRi(6);
+ break;
+ case 0x7F: // BBR7
+ this.BBRi(7);
+ break;
+
+ case 0x8F: // BBS0
+ this.BBSi(0);
+ break;
+ case 0x9F: // BBS1
+ this.BBSi(1);
+ break;
+ case 0xAF: // BBS2
+ this.BBSi(2);
+ break;
+ case 0xBF: // BBS3
+ this.BBSi(3);
+ break;
+ case 0xCF: // BBS4
+ this.BBSi(4);
+ break;
+ case 0xDF: // BBS5
+ this.BBSi(5);
+ break;
+ case 0xEF: // BBS6
+ this.BBSi(6);
+ break;
+ case 0xFF: // BBS7
+ this.BBSi(7);
+ break;
+
+ case 0x90: // BCC
+ this.Branch((this.P & this.CFlag) == 0x00, 1);
+ break;
+ case 0xB0: // BCS
+ this.Branch((this.P & this.CFlag) == this.CFlag, 1);
+ break;
+ case 0xD0: // BNE
+ this.Branch((this.P & this.ZFlag) == 0x00, 1);
+ break;
+ case 0xF0: // BEQ
+ this.Branch((this.P & this.ZFlag) == this.ZFlag, 1);
+ break;
+ case 0x10: // BPL
+ this.Branch((this.P & this.NFlag) == 0x00, 1);
+ break;
+ case 0x30: // BMI
+ this.Branch((this.P & this.NFlag) == this.NFlag, 1);
+ break;
+ case 0x50: // BVC
+ this.Branch((this.P & this.VFlag) == 0x00, 1);
+ break;
+ case 0x70: // BVS
+ this.Branch((this.P & this.VFlag) == this.VFlag, 1);
+ break;
+ case 0x80: // BRA
+ this.Branch(true, 1);
+ break;
+
+ case 0x44: // BSR
+ this.PC++;
+ this.Push(this.PCH());
+ this.Push(this.PCL());
+ this.Branch(true, 0);
+ break;
+ case 0x20: // JSR ABS
+ tmp = this.ABS();
+ this.PC += 2;
+ this.Push(this.PCH());
+ this.Push(this.PCL());
+ this.PC = tmp;
+ this.ClearTFlag();
+ break;
+
+ case 0x40: // RTI
+ this.P = this.Pull();
+ this.toPCL(this.Pull());
+ this.toPCH(this.Pull());
+ break;
+ case 0x60: // RTS
+ this.ClearTFlag();
+ this.toPCL(this.Pull());
+ this.toPCH(this.Pull());
+ this.PC++;
+ break;
+
+ case 0x4C: // JMP ABS
+ this.PC = this.ABS();
+ this.ClearTFlag();
+ break;
+ case 0x6C: // JMP (ABS)
+ this.PC = this.ABS_IND();
+ this.ClearTFlag();
+ break;
+ case 0x7C: // JMP (ABS, X)
+ this.PC = this.ABS_X_IND();
+ this.ClearTFlag();
+ break;
+
+ case 0x00: // BRK
+ this.PC += 2;
+ this.Push(this.PCH());
+ this.Push(this.PCL());
+ this.SetBFlag();
+ this.Push(this.P);
+ this.ClearDFlag();
+ this.ClearTFlag();
+ this.SetIFlag();
+ this.PC = this.Get16(0xFFF6);
+ break;
+
+ case 0x62: // CLA
+ this.A = 0x00;
+ this.ClearTFlag();
+ break;
+ case 0x82: // CLX
+ this.X = 0x00;
+ this.ClearTFlag();
+ break;
+ case 0xC2: // CLY
+ this.Y = 0x00;
+ this.ClearTFlag();
+ break;
+
+ case 0x18: // CLC
+ this.ClearCFlag();
+ this.ClearTFlag();
+ break;
+ case 0xD8: // CLD
+ this.ClearDFlag();
+ this.ClearTFlag();
+ break;
+ case 0x58: // CLI
+ this.ClearIFlag();
+ this.ClearTFlag();
+ break;
+ case 0xB8: // CLV
+ this.ClearVFlag();
+ this.ClearTFlag();
+ break;
+
+ case 0x38: // SEC
+ this.SetCFlag();
+ this.ClearTFlag();
+ break;
+ case 0xF8: // SED
+ this.SetDFlag();
+ this.ClearTFlag();
+ break;
+ case 0x78: // SEI
+ this.SetIFlag();
+ this.ClearTFlag();
+ break;
+ case 0xF4: // SET
+ this.SetTFlag();
+ break;
+
+ case 0xC9: // CMP IMM
+ this.Compare(this.A, this.PC + 1);
+ break;
+ case 0xC5: // CMP ZP
+ this.Compare(this.A, this.ZP());
+ break;
+ case 0xD5: // CMP ZP, X
+ this.Compare(this.A, this.ZP_X());
+ break;
+ case 0xD2: // CMP (IND)
+ this.Compare(this.A, this.IND());
+ break;
+ case 0xC1: // CMP (IND, X)
+ this.Compare(this.A, this.IND_X());
+ break;
+ case 0xD1: // CMP (IND), Y
+ this.Compare(this.A, this.IND_Y());
+ break;
+ case 0xCD: // CMP ABS
+ this.Compare(this.A, this.ABS());
+ break;
+ case 0xDD: // CMP ABS, X
+ this.Compare(this.A, this.ABS_X());
+ break;
+ case 0xD9: // CMP ABS, Y
+ this.Compare(this.A, this.ABS_Y());
+ break;
+ case 0xE0: // CPX IMM
+ this.Compare(this.X, this.PC + 1);
+ break;
+ case 0xE4: // CPX ZP
+ this.Compare(this.X, this.ZP());
+ break;
+ case 0xEC: // CPX ABS
+ this.Compare(this.X, this.ABS());
+ break;
+ case 0xC0: // CPY IMM
+ this.Compare(this.Y, this.PC + 1);
+ break;
+ case 0xC4: // CPY ZP
+ this.Compare(this.Y, this.ZP());
+ break;
+ case 0xCC: // CPY ABS
+ this.Compare(this.Y, this.ABS());
+ break;
+
+ case 0xC6: // DEC ZP
+ address = this.ZP();
+ this.Set(address, this.Decrement(this.Get(address)));
+ break;
+ case 0xD6: // DEC ZP, X
+ address = this.ZP_X();
+ this.Set(address, this.Decrement(this.Get(address)));
+ break;
+ case 0xCE: // DEC ABS
+ address = this.ABS();
+ this.Set(address, this.Decrement(this.Get(address)));
+ break;
+ case 0xDE: // DEC ABS, X
+ address = this.ABS_X();
+ this.Set(address, this.Decrement(this.Get(address)));
+ break;
+ case 0x3A: // DEC A
+ this.A = this.Decrement(this.A);
+ break;
+ case 0xCA: // DEX
+ this.X = this.Decrement(this.X);
+ break;
+ case 0x88: // DEY
+ this.Y = this.Decrement(this.Y);
+ break;
+
+ case 0xE6: // INC ZP
+ address = this.ZP();
+ this.Set(address, this.Increment(this.Get(address)));
+ break;
+ case 0xF6: // INC ZP, X
+ address = this.ZP_X();
+ this.Set(address, this.Increment(this.Get(address)));
+ break;
+ case 0xEE: // INC ABS
+ address = this.ABS();
+ this.Set(address, this.Increment(this.Get(address)));
+ break;
+ case 0xFE: // INC ABS, X
+ address = this.ABS_X();
+ this.Set(address, this.Increment(this.Get(address)));
+ break;
+ case 0x1A: // INC A
+ this.A = this.Increment(this.A);
+ break;
+ case 0xE8: // INX
+ this.X = this.Increment(this.X);
+ break;
+ case 0xC8: // INY
+ this.Y = this.Increment(this.Y);
+ break;
+
+ case 0x48: // PHA
+ this.Push(this.A);
+ this.ClearTFlag();
+ break;
+ case 0x08: // PHP
+ this.Push(this.P);
+ this.ClearTFlag();
+ break;
+ case 0xDA: // PHX
+ this.Push(this.X);
+ this.ClearTFlag();
+ break;
+ case 0x5A: // PHY
+ this.Push(this.Y);
+ this.ClearTFlag();
+ break;
+
+ case 0x68: // PLA
+ this.A = this.Pull();
+ this.SetNZFlag(this.A);
+ this.ClearTFlag();
+ break;
+ case 0x28: // PLP
+ this.P = this.Pull();
+ break;
+ case 0xFA: // PLX
+ this.X = this.Pull();
+ this.SetNZFlag(this.X);
+ this.ClearTFlag();
+ break;
+ case 0x7A: // PLY
+ this.Y = this.Pull();
+ this.SetNZFlag(this.Y);
+ this.ClearTFlag();
+ break;
+
+ case 0x07: // RMB0
+ this.RMBi(0);
+ break;
+ case 0x17: // RMB1
+ this.RMBi(1);
+ break;
+ case 0x27: // RMB2
+ this.RMBi(2);
+ break;
+ case 0x37: // RMB3
+ this.RMBi(3);
+ break;
+ case 0x47: // RMB4
+ this.RMBi(4);
+ break;
+ case 0x57: // RMB5
+ this.RMBi(5);
+ break;
+ case 0x67: // RMB6
+ this.RMBi(6);
+ break;
+ case 0x77: // RMB7
+ this.RMBi(7);
+ break;
+
+ case 0x87: // SMB0
+ this.SMBi(0);
+ break;
+ case 0x97: // SMB1
+ this.SMBi(1);
+ break;
+ case 0xA7: // SMB2
+ this.SMBi(2);
+ break;
+ case 0xB7: // SMB3
+ this.SMBi(3);
+ break;
+ case 0xC7: // SMB4
+ this.SMBi(4);
+ break;
+ case 0xD7: // SMB5
+ this.SMBi(5);
+ break;
+ case 0xE7: // SMB6
+ this.SMBi(6);
+ break;
+ case 0xF7: // SMB7
+ this.SMBi(7);
+ break;
+
+ case 0x22: // SAX
+ tmp = this.A;
+ this.A = this.X;
+ this.X = tmp;
+ this.ClearTFlag();
+ break;
+ case 0x42: // SAY
+ tmp = this.A;
+ this.A = this.Y;
+ this.Y = tmp;
+ this.ClearTFlag();
+ break;
+ case 0x02: // SXY
+ tmp = this.X;
+ this.X = this.Y;
+ this.Y = tmp;
+ this.ClearTFlag();
+ break;
+
+ case 0xAA: // TAX
+ this.X = this.A;
+ this.SetNZFlag(this.X);
+ this.ClearTFlag();
+ break;
+ case 0xA8: // TAY
+ this.Y = this.A;
+ this.SetNZFlag(this.Y);
+ this.ClearTFlag();
+ break;
+ case 0xBA: // TSX
+ this.X = this.S;
+ this.SetNZFlag(this.X);
+ this.ClearTFlag();
+ break;
+ case 0x8A: // TXA
+ this.A = this.X;
+ this.SetNZFlag(this.A);
+ this.ClearTFlag();
+ break;
+ case 0x9A: // TXS
+ this.S = this.X;
+ this.ClearTFlag();
+ break;
+ case 0x98: // TYA
+ this.A = this.Y;
+ this.SetNZFlag(this.A);
+ this.ClearTFlag();
+ break;
+
+ case 0x89: // BIT IMM
+ this.BIT(this.PC + 1);
+ break;
+ case 0x24: // BIT ZP
+ this.BIT(this.ZP());
+ break;
+ case 0x34: // BIT ZP, X
+ this.BIT(this.ZP_X());
+ break;
+ case 0x2C: // BIT ABS
+ this.BIT(this.ABS());
+ break;
+ case 0x3C: // BIT ABS, X
+ this.BIT(this.ABS_X());
+ break;
+
+ case 0x83: // TST IMM ZP
+ this.TST(this.PC + 1, 0x2000 | this.Get(this.PC + 2));
+ break;
+ case 0xA3: // TST IMM ZP, X
+ this.TST(this.PC + 1, 0x2000 | ((this.Get(this.PC + 2) + this.X) & 0xFF));
+ break;
+ case 0x93: // TST IMM ABS
+ this.TST(this.PC + 1, this.Get16(this.PC + 2));
+ break;
+ case 0xB3: // TST IMM ABS, X
+ this.TST(this.PC + 1, (this.Get16(this.PC + 2) + this.X) & 0xFFFF);
+ break;
+
+ case 0x14: // TRB ZP
+ this.TRB(this.ZP())
+ break;
+ case 0x1C: // TRB ABS
+ this.TRB(this.ABS())
+ break;
+
+ case 0x04: // TSB ZP
+ this.TSB(this.ZP())
+ break;
+ case 0x0C: // TSB ABS
+ this.TSB(this.ABS())
+ break;
+
+ case 0xA9: // LDA IMM
+ this.A = this.Load(this.PC + 1);
+ break;
+ case 0xA5: // LDA ZP
+ this.A = this.Load(this.ZP());
+ break;
+ case 0xB5: // LDA ZP, X
+ this.A = this.Load(this.ZP_X());
+ break;
+ case 0xB2: // LDA (IND)
+ this.A = this.Load(this.IND());
+ break;
+ case 0xA1: // LDA (IND, X)
+ this.A = this.Load(this.IND_X());
+ break;
+ case 0xB1: // LDA (IND), Y
+ this.A = this.Load(this.IND_Y());
+ break;
+ case 0xAD: // LDA ABS
+ this.A = this.Load(this.ABS());
+ break;
+ case 0xBD: // LDA ABS, X
+ this.A = this.Load(this.ABS_X());
+ break;
+ case 0xB9: // LDA ABS, Y
+ this.A = this.Load(this.ABS_Y());
+ break;
+ case 0xA2: // LDX IMM
+ this.X = this.Load(this.PC + 1);
+ break;
+ case 0xA6: // LDX ZP
+ this.X = this.Load(this.ZP());
+ break;
+ case 0xB6: // LDX ZP, Y
+ this.X = this.Load(this.ZP_Y());
+ break;
+ case 0xAE: // LDX ABS
+ this.X = this.Load(this.ABS());
+ break;
+ case 0xBE: // LDX ABS, Y
+ this.X = this.Load(this.ABS_Y());
+ break;
+ case 0xA0: // LDY IMM
+ this.Y = this.Load(this.PC + 1);
+ break;
+ case 0xA4: // LDY ZP
+ this.Y = this.Load(this.ZP());
+ break;
+ case 0xB4: // LDY ZP, X
+ this.Y = this.Load(this.ZP_X());
+ break;
+ case 0xAC: // LDY ABS
+ this.Y = this.Load(this.ABS());
+ break;
+ case 0xBC: // LDY ABS, X
+ this.Y = this.Load(this.ABS_X());
+ break;
+
+ case 0x85: // STA ZP
+ this.Store(this.ZP(), this.A);
+ break;
+ case 0x95: // STA ZP, X
+ this.Store(this.ZP_X(), this.A);
+ break;
+ case 0x92: // STA (IND)
+ this.Store(this.IND(), this.A);
+ break;
+ case 0x81: // STA (IND, X)
+ this.Store(this.IND_X(), this.A);
+ break;
+ case 0x91: // STA (IND), Y
+ this.Store(this.IND_Y(), this.A);
+ break;
+ case 0x8D: // STA ABS
+ this.Store(this.ABS(), this.A);
+ break;
+ case 0x9D: // STA ABS, X
+ this.Store(this.ABS_X(), this.A);
+ break;
+ case 0x99: // STA ABS, Y
+ this.Store(this.ABS_Y(), this.A);
+ break;
+ case 0x86: // STX ZP
+ this.Store(this.ZP(), this.X);
+ break;
+ case 0x96: // STX ZP, Y
+ this.Store(this.ZP_Y(), this.X);
+ break;
+ case 0x8E: // STX ABS
+ this.Store(this.ABS(), this.X);
+ break;
+ case 0x84: // STY ZP
+ this.Store(this.ZP(), this.Y);
+ break;
+ case 0x94: // STY ZP, X
+ this.Store(this.ZP_X(), this.Y);
+ break;
+ case 0x8C: // STY ABS
+ this.Store(this.ABS(), this.Y);
+ break;
+ case 0x64: // STZ ZP
+ this.Store(this.ZP(), 0x00);
+ break;
+ case 0x74: // STZ ZP, X
+ this.Store(this.ZP_X(), 0x00);
+ break;
+ case 0x9C: // STZ ABS
+ this.Store(this.ABS(), 0x00);
+ break;
+ case 0x9E: // STZ ABS, X
+ this.Store(this.ABS_X(), 0x00);
+ break;
+
+ case 0xEA: // NOP
+ this.ClearTFlag();
+ break;
+
+ case 0x03: // ST0
+ this.SetVDCRegister(this.Get(this.PC + 1), this.VDCSelect);
+ this.ClearTFlag();
+ break;
+ case 0x13: // ST1
+ this.SetVDCLow(this.Get(this.PC + 1), this.VDCSelect);
+ this.ClearTFlag();
+ break;
+ case 0x23: // ST2
+ this.SetVDCHigh(this.Get(this.PC + 1), this.VDCSelect);
+ this.ClearTFlag();
+ break;
+
+ case 0x53: // TAMi
+ data = this.Get(this.PC + 1);
+ bit = 0x01;
+ if(data == 0x00)
+ data = this.MPRSelect;
+ else
+ this.MPRSelect = data;
+ for(i=0; i<8; i++)
+ if((data & (bit << i)) != 0x00)
+ this.MPR[i] = this.A << 13;
+ break;
+ case 0x43: // TMAi
+ data = this.Get(this.PC + 1);
+ bit = 0x01;
+ if(data == 0x00)
+ data = this.MPRSelect;
+ else
+ this.MPRSelect = data;
+ for(i=0; i<8; i++)
+ if((data & (bit << i)) != 0x00)
+ this.A = this.MPR[i] >>> 13;
+ break;
+
+ case 0xF3: // TAI
+ if(this.TransferLen == 0) {
+ this.TransferSrc = this.Get16(this.PC + 1);
+ this.TransferDist = this.Get16(this.PC + 3);
+ this.TransferLen = this.Get16(this.PC + 5);
+ this.TransferAlt = 1;
+ this.ProgressClock = 17;
+ }
+
+ this.Set(this.TransferDist, this.Get(this.TransferSrc));
+ this.TransferSrc = (this.TransferSrc + this.TransferAlt) & 0xFFFF;
+ this.TransferDist = (this.TransferDist + 1) & 0xFFFF;
+ this.TransferLen = (this.TransferLen - 1) & 0xFFFF;
+ this.TransferAlt = this.TransferAlt == 1 ? -1 : 1;
+ this.ProgressClock += 6;
+
+ if(this.TransferLen == 0) {
+ this.ClearTFlag();
+ this.PC += 7;
+ }
+ break;
+ case 0xC3: // TDD
+ if(this.TransferLen == 0) {
+ this.TransferSrc = this.Get16(this.PC + 1);
+ this.TransferDist = this.Get16(this.PC + 3);
+ this.TransferLen = this.Get16(this.PC + 5);
+ this.ProgressClock = 17;
+ }
+
+ this.Set(this.TransferDist, this.Get(this.TransferSrc));
+ this.TransferSrc = (this.TransferSrc - 1) & 0xFFFF;
+ this.TransferDist = (this.TransferDist - 1) & 0xFFFF;
+ this.TransferLen = (this.TransferLen - 1) & 0xFFFF;
+ this.ProgressClock += 6;
+
+ if(this.TransferLen == 0) {
+ this.ClearTFlag();
+ this.PC += 7;
+ }
+ break;
+ case 0xE3: // TIA
+ if(this.TransferLen == 0) {
+ this.TransferSrc = this.Get16(this.PC + 1);
+ this.TransferDist = this.Get16(this.PC + 3);
+ this.TransferLen = this.Get16(this.PC + 5);
+ this.TransferAlt = 1;
+ this.ProgressClock = 17;
+ }
+
+ this.Set(this.TransferDist, this.Get(this.TransferSrc));
+ this.TransferSrc = (this.TransferSrc + 1) & 0xFFFF;
+ this.TransferDist = (this.TransferDist + this.TransferAlt) & 0xFFFF;
+ this.TransferLen = (this.TransferLen - 1) & 0xFFFF;
+ this.TransferAlt = this.TransferAlt == 1 ? -1 : 1;
+ this.ProgressClock += 6;
+
+ if(this.TransferLen == 0) {
+ this.ClearTFlag();
+ this.PC += 7;
+ }
+ break;
+ case 0x73: // TII
+ if(this.TransferLen == 0) {
+ this.TransferSrc = this.Get16(this.PC + 1);
+ this.TransferDist = this.Get16(this.PC + 3);
+ this.TransferLen = this.Get16(this.PC + 5);
+ this.ProgressClock = 17;
+ }
+
+ this.Set(this.TransferDist, this.Get(this.TransferSrc));
+ this.TransferSrc = (this.TransferSrc + 1) & 0xFFFF;
+ this.TransferDist = (this.TransferDist + 1) & 0xFFFF;
+ this.TransferLen = (this.TransferLen - 1) & 0xFFFF;
+ this.ProgressClock += 6;
+
+ if(this.TransferLen == 0) {
+ this.ClearTFlag();
+ this.PC += 7;
+ }
+
+ break;
+ case 0xD3: // TIN
+ if(this.TransferLen == 0) {
+ this.TransferSrc = this.Get16(this.PC + 1);
+ this.TransferDist = this.Get16(this.PC + 3);
+ this.TransferLen = this.Get16(this.PC + 5);
+ this.ProgressClock = 17;
+ }
+
+ this.Set(this.TransferDist, this.Get(this.TransferSrc));
+ this.TransferSrc = (this.TransferSrc + 1) & 0xFFFF;
+ this.TransferLen = (this.TransferLen - 1) & 0xFFFF;
+ this.ProgressClock += 6;
+
+ if(this.TransferLen == 0) {
+ this.ClearTFlag();
+ this.PC += 7;
+ }
+ break;
+
+ case 0xD4: // CSH
+ this.ClearTFlag();
+ this.CPUBaseClock = this.BaseClock7;
+ break;
+ case 0x54: // CSL
+ this.ClearTFlag();
+ this.CPUBaseClock = this.BaseClock1;
+ break;
+ default:
+ this.ClearTFlag();//NOP
+ break;
+ }
+ this.PC += this.OpBytes[op];
+ this.ProgressClock = (this.ProgressClock + this.OpCycles[op]) * this.CPUBaseClock;
+ }
+
+ Adder(address, neg) {
+ let data0;
+ let data1 = this.Get(address);
+
+ if(!neg && (this.P & this.TFlag) == this.TFlag) {
+ this.ProgressClock = 3;
+ data0 = this.Get(0x2000 | this.X);
+ } else
+ data0 = this.A;
+
+ if(neg)
+ data1 = ~data1 & 0xFF;
+
+ let carry = this.P & 0x01;
+ let tmp = data0 + data1 + carry;
+
+ if((this.P & this.DFlag) == 0x00) {
+ if((((~data0 & ~data1 & tmp) | (data0 & data1 & ~tmp)) & 0x80) == 0x80)
+ this.SetVFlag();
+ else
+ this.ClearVFlag();
+ } else {
+ this.ProgressClock += 1;
+ if(neg) {
+ if((tmp & 0x0F) > 0x09)
+ tmp -= 0x06;
+ if((tmp & 0xF0) > 0x90)
+ tmp -= 0x60;
+ } else {
+ if(((data0 & 0x0F) + (data1 & 0x0F) + carry) > 0x09)
+ tmp += 0x06;
+ if((tmp & 0x1F0) > 0x90)
+ tmp += 0x60;
+ }
+ }
+
+ if(tmp > 0xFF)
+ this.SetCFlag();
+ else
+ this.ClearCFlag();
+
+ tmp &= 0xFF;
+ this.SetNZFlag(tmp);
+
+ if(!neg && (this.P & this.TFlag) == this.TFlag)
+ this.Set(0x2000 | this.X, tmp);
+ else
+ this.A = tmp;
+
+ this.ClearTFlag();
+ }
+
+
+ ADC(address) {
+ this.Adder(address, false);
+ }
+
+
+ SBC(address) {
+ this.Adder(address, true);
+ }
+
+
+ AND(address) {
+ let data0;
+ let data1 = this.Get(address);
+
+ if((this.P & this.TFlag) == 0x00) {
+ data0 = this.A;
+ } else {
+ this.ProgressClock = 3;
+ data0 = this.Get(0x2000 | this.X);
+ }
+
+ let tmp = data0 & data1;
+ this.SetNZFlag(tmp);
+
+ if((this.P & this.TFlag) == 0x00)
+ this.A = tmp;
+ else
+ this.Set(0x2000 | this.X, tmp);
+
+ this.ClearTFlag();
+ }
+
+
+ EOR(address) {
+ let data0;
+ let data1 = this.Get(address);
+
+ if((this.P & this.TFlag) == 0x00) {
+ data0 = this.A;
+ } else {
+ this.ProgressClock = 3;
+ data0 = this.Get(0x2000 | this.X);
+ }
+
+ let tmp = data0 ^ data1;
+ this.SetNZFlag(tmp);
+
+ if((this.P & this.TFlag) == 0x00)
+ this.A = tmp;
+ else
+ this.Set(0x2000 | this.X, tmp);
+
+ this.ClearTFlag();
+ }
+
+
+ ORA(address) {
+ let data0;
+ let data1 = this.Get(address);
+
+ if((this.P & this.TFlag) == 0x00) {
+ data0 = this.A;
+ } else {
+ this.ProgressClock = 3;
+ data0 = this.Get(0x2000 | this.X);
+ }
+
+ let tmp = data0 | data1;
+ this.SetNZFlag(tmp);
+
+ if((this.P & this.TFlag) == 0x00)
+ this.A = tmp;
+ else
+ this.Set(0x2000 | this.X, tmp);
+
+ this.ClearTFlag();
+ }
+
+
+ ASL(data) {
+ data <<= 1;
+ if(data > 0xFF)
+ this.SetCFlag();
+ else
+ this.ClearCFlag();
+
+ data &= 0xFF;
+ this.SetNZFlag(data);
+ this.ClearTFlag();
+ return data;
+ }
+
+
+ LSR(data) {
+ if((data & 0x01) == 0x01)
+ this.SetCFlag();
+ else
+ this.ClearCFlag();
+
+ data >>= 1;
+ this.SetNZFlag(data);
+ this.ClearTFlag();
+ return data;
+ }
+
+
+ ROL(data) {
+ data = (data << 1) | (this.P & 0x01);
+ if(data > 0xFF)
+ this.SetCFlag();
+ else
+ this.ClearCFlag();
+
+ data &= 0xFF;
+ this.SetNZFlag(data);
+ this.ClearTFlag();
+ return data;
+ }
+
+
+ ROR(data) {
+ let tmp = this.P & this.CFlag;
+ if((data & 0x01) == 0x01)
+ this.SetCFlag();
+ else
+ this.ClearCFlag();
+
+ data = (data >> 1) | (tmp << 7);
+ this.SetNZFlag(data);
+ this.ClearTFlag();
+ return data;
+ }
+
+
+ BBRi(bit) {
+ let tmp = this.Get(this.ZP());
+ tmp = (tmp >> bit) & 0x01;
+ this.Branch(tmp == 0, 2);
+ }
+
+
+ BBSi(bit) {
+ let tmp = this.Get(this.ZP());
+ tmp = (tmp >> bit) & 0x01;
+ this.Branch(tmp == 1, 2);
+ }
+
+
+ Branch(status, adr) {
+ this.ClearTFlag();
+ if(status) {
+ let tmp = this.Get(this.PC + adr);
+ if(tmp >= 0x80)
+ tmp |= 0xFF00;
+ this.PC = (this.PC + adr + 1 + tmp) & 0xFFFF;
+ this.ProgressClock = 2;
+ } else
+ this.PC += adr + 1;
+ }
+
+
+ Compare(data0, data1) {
+ data0 -= this.Get(data1);
+ if(data0 < 0)
+ this.ClearCFlag();
+ else
+ this.SetCFlag();
+
+ this.ClearTFlag();
+ this.SetNZFlag(data0 & 0xFF);
+ }
+
+
+ Decrement(data) {
+ data = (data - 1) & 0xFF;
+ this.SetNZFlag(data);
+ this.ClearTFlag();
+ return data;
+ }
+
+
+ Increment(data) {
+ data = (data + 1) & 0xFF;
+ this.SetNZFlag(data);
+ this.ClearTFlag();
+ return data;
+ }
+
+
+ Push(data) {
+ this.Set(0x2100 | this.S, data);
+ this.S = (this.S - 1) & 0xFF;
+ }
+
+
+ Pull() {
+ this.S = (this.S + 1) & 0xFF;
+ return this.Get(0x2100 | this.S);
+ }
+
+
+ RMBi(bit) {
+ let address = this.ZP();
+ this.Set(address, this.Get(address) & ~(0x01 << bit));
+ this.ClearTFlag();
+ }
+
+
+ SMBi(bit) {
+ let address = this.ZP();
+ this.Set(address, this.Get(address) | (0x01 << bit));
+ this.ClearTFlag();
+ }
+
+
+ BIT(address) {
+ let tmp = this.Get(address);
+ this.SetNZFlag(this.A & tmp);
+ this.P = (this.P & ~(this.NFlag | this.VFlag)) | (tmp & (this.NFlag | this.VFlag));
+ this.ClearTFlag();
+ }
+
+
+ TST(address0, address1) {
+ let tmp0 = this.Get(address0);
+ let tmp1 = this.Get(address1);
+ this.SetNZFlag(tmp0 & tmp1);
+ this.P = (this.P & ~(this.NFlag | this.VFlag)) | (tmp1 & (this.NFlag | this.VFlag));
+ this.ClearTFlag();
+ }
+
+
+ TRB(address) {
+ let tmp = this.Get(address);
+ let res = ~this.A & tmp;
+ this.Set(address, res);
+ this.SetNZFlag(res);
+ this.P = (this.P & ~(this.NFlag | this.VFlag)) | (tmp & (this.NFlag | this.VFlag));
+ this.ClearTFlag();
+ }
+
+
+ TSB(address) {
+ let tmp = this.Get(address);
+ let res = this.A | tmp;
+ this.Set(address, res);
+ this.SetNZFlag(res);
+ this.P = (this.P & ~(this.NFlag | this.VFlag)) | (tmp & (this.NFlag | this.VFlag));
+ this.ClearTFlag();
+ }
+
+
+ Load(address) {
+ let data = this.Get(address);
+ this.SetNZFlag(data);
+ this.ClearTFlag();
+ return data;
+ }
+
+
+ Store(address, data) {
+ this.Set(address, data);
+ this.ClearTFlag();
+ }
+
+
+ ZP() {
+ return 0x2000 | this.Get(this.PC + 1);
+ }
+
+
+ ZP_X() {
+ return 0x2000 | ((this.Get(this.PC + 1) + this.X) & 0xFF);
+ }
+
+
+ ZP_Y() {
+ return 0x2000 | ((this.Get(this.PC + 1) + this.Y) & 0xFF);
+ }
+
+
+ IND() {
+ return this.Get16(0x2000 | this.Get(this.PC + 1));
+ }
+
+
+ IND_X() {
+ return this.Get16(0x2000 | ((this.Get(this.PC + 1) + this.X) & 0xFF));
+ }
+
+
+ IND_Y() {
+ return (this.Get16(0x2000 | this.Get(this.PC + 1)) + this.Y) & 0xFFFF;
+ }
+
+
+ ABS() {
+ return this.Get16(this.PC + 1);
+ }
+
+
+ ABS_X() {
+ return (this.Get16(this.PC + 1) + this.X) & 0xFFFF;
+ }
+
+
+ ABS_Y() {
+ return (this.Get16(this.PC + 1) + this.Y) & 0xFFFF;
+ }
+
+
+ ABS_IND() {
+ return this.Get16(this.Get16(this.PC + 1));
+ }
+
+
+ ABS_X_IND() {
+ return this.Get16((this.Get16(this.PC + 1) + this.X) & 0xFFFF);
+ }
+
+
+ SetNZFlag(data) { // Set N Z Flags
+ this.P = (this.P & ~(this.NFlag | this.ZFlag)) | this.NZCacheTable[data];
+ }
+
+
+ SetVFlag() { // Set V Flag
+ this.P |= this.VFlag;
+ }
+
+
+ ClearVFlag() { // Clear V Flag
+ this.P &= ~this.VFlag;
+ }
+
+
+ SetTFlag() { // Set T Flag
+ this.P |= this.TFlag;
+ }
+
+
+ ClearTFlag() { // Clear T Flag
+ this.P &= ~this.TFlag;
+ }
+
+
+ SetBFlag() { // Set B Flag
+ this.P |= this.BFlag;
+ }
+
+
+ ClearBFlag() { // Clear B Flag
+ this.P &= ~this.BFlag;
+ }
+
+
+ SetDFlag() { // Set D Flag
+ this.P |= this.DFlag;
+ }
+
+
+ ClearDFlag() { // Clear D Flag
+ this.P &= ~this.DFlag;
+ }
+
+
+ SetIFlag() { // Set I Flag
+ this.P |= this.IFlag;
+ }
+
+
+ ClearIFlag() { // Clear I Flag
+ this.P &= ~this.IFlag;
+ }
+
+
+ SetCFlag() { // Set C Flag
+ this.P |= this.CFlag;
+ }
+
+
+ ClearCFlag() { // Clear C Flag
+ this.P &= ~this.CFlag;
+ }
+
+
+ PCH() {
+ return this.PC >> 8;
+ }
+
+
+ PCL() {
+ return this.PC & 0x00FF;
+ }
+
+
+ toPCH(data) {
+ this.PC = (this.PC & 0x00FF) | (data << 8);
+ }
+
+
+ toPCL(data) {
+ this.PC = (this.PC & 0xFF00) | data;
+ }
+
+
+ /* ***************** */
+ /* **** Storage **** */
+ /* ***************** */
+ StorageConstruct() {
+ this.MPR = new Array(8);
+ this.MPRSelect = 0;
+ this.RAM = new Array(0x8000);
+ this.RAMMask = 0x1FFF;
+ this.BRAM = new Array(0x2000).fill(0x00);
+ this.BRAMUse = false;
+
+ this.INTIRQ2 = 0x00;
+ this.IntDisableRegister = 0;
+
+ this.Mapper = null;
+
+ this.Mapper0 = class extends this.MapperBase {
+ Address: number;
+ constructor(rom, core) {
+ super(rom, core);
+
+ let tmp = this.ROM.length - 1;
+ this.Address = 0x80000;
+ while(this.Address > 0x0000) {
+ if((this.Address & tmp) != 0x0000)
+ break;
+ this.Address >>>= 1;
+ }
+ }
+
+ Read(address) {
+ if(address >= this.ROM.length)
+ return this.ROM[(address & (this.Address - 1)) | this.Address];
+ else
+ return this.ROM[address];
+ }
+ };
+
+ this.Mapper1 = class extends this.MapperBase {
+ ROM: any;
+ Address: number;
+ constructor(rom, core) {
+ super(rom, core);
+ this.Address = 0;
+ }
+
+ Init() {
+ this.Address = 0;
+ }
+
+ Read(address) {
+ if(address < 0x80000)
+ return this.ROM[address];
+ else
+ return this.ROM[this.Address | (address & 0x7FFFF)];
+ }
+
+ Write(address, data) {
+ this.Address = ((address & 0x000F) + 1) << 19;
+ }
+ };
+
+ this.Mapper2 = class extends this.MapperBase {
+ ROM: any;
+ constructor(rom, core) {
+ super(rom, core);
+ this.ROM = rom.concat(new Array(0x80000).fill(0x00));
+ }
+
+ Read(address) {
+ return this.ROM[address];
+ }
+
+ Write(address, data) {
+ if(address >= 0x80000)
+ this.ROM[address] = data;
+ }
+ };
+ }
+
+
+ GetIntStatus() {
+ return ~this.IntDisableRegister & this.GetIntReqest();
+ }
+
+
+ GetIntDisable() {
+ return this.IntDisableRegister;
+ }
+
+
+ SetIntDisable(data) {
+ this.IntDisableRegister = data;
+ this.TimerAcknowledge();
+ }
+
+
+ GetIntReqest() {
+ return (((this.VDC[0].VDCStatus | this.VDC[1].VDCStatus) & 0x3F) != 0x00 ? this.IRQ1Flag : 0x00) | this.INTIRQ2 | this.INTTIQ;
+ }
+
+
+ SetIntReqest(data) {
+ this.TimerAcknowledge();
+ }
+
+
+ SetROM(rom) {
+ this.Init();
+ let tmp = rom.slice(rom.length % 8192);
+ //if(tmp[0x001FFF] < 0xE0)
+ // tmp = tmp.map((d) => {return this.ReverseBit[d];});
+ this.Mapper = new this.Mapper0(tmp, this);
+ this.CPUReset();
+ }
+
+
+ StorageInit() {
+ this.RAM.fill(0x00);
+ this.RAMMask = this.SuperGrafx ? 0x7FFF : 0x1FFF;
+ this.StorageReset();
+ }
+
+
+ StorageReset() {
+ this.IntDisableRegister = 0x00;//IntInit
+
+ for(let i=0; i<7; i++)
+ this.MPR[i] = 0xFF << 13;
+ this.MPR[7] = 0x00;
+
+ this.MPRSelect = 0x01;
+ }
+
+
+ Get16(address) {
+ return (this.Get(address + 1) << 8) | this.Get(address);
+ }
+
+
+ Get(address) {
+ address = this.MPR[address >> 13] | (address & 0x1FFF);
+
+ if(address < 0x100000)// ROM
+ return this.Mapper.Read(address);
+
+ if(address < 0x1EE000)// NOT USE
+ return 0xFF;
+
+ if(address < 0x1F0000) {// BRAM
+ if(this.BRAMUse)
+ return this.BRAM[address & 0x1FFF];
+ else
+ return 0xFF;
+ }
+
+ if(address < 0x1F8000)// RAM
+ return this.RAM[address & this.RAMMask];
+
+ if(address < 0x1FE000)// NOT USE
+ return 0xFF;
+
+ if(address < 0x1FE400) {// VDC
+ if(this.SuperGrafx) {
+ let tmp = address & 0x00001F;
+ if(tmp < 0x00008) {
+ switch(address & 0x000003) {// VDC#1
+ case 0x00:
+ return this.GetVDCStatus(0);
+ case 0x01:
+ return 0x00;
+ case 0x02:
+ return this.GetVDCLow(0);
+ case 0x03:
+ return this.GetVDCHigh(0);
+ }
+ } else if(tmp < 0x00010) {// VPC
+ return this.GetVPC(tmp & 0x000007);
+ } else if(tmp < 0x00018) {// VDC#2
+ switch(address & 0x000003) {
+ case 0x00:
+ return this.GetVDCStatus(1);
+ case 0x01:
+ return 0x00;
+ case 0x02:
+ return this.GetVDCLow(1);
+ case 0x03:
+ return this.GetVDCHigh(1);
+ }
+ } else {
+ return 0xFF;
+ }
+ } else {
+ switch(address & 0x000003) {// VDC#1
+ case 0x00:
+ return this.GetVDCStatus(0);
+ case 0x01:
+ return 0x00;
+ case 0x02:
+ return this.GetVDCLow(0);
+ case 0x03:
+ return this.GetVDCHigh(0);
+ }
+ }
+ }
+
+ if(address < 0x1FE800) {// VCE
+ switch(address & 0x000007) {
+ case 0x04:
+ return this.GetVCEDataLow();
+ case 0x05:
+ return this.GetVCEDataHigh();
+ default:
+ return 0x00;
+
+ }
+ }
+
+ if(address < 0x1FEC00)// PSG
+ return this.GetPSG(address & 0x00000F);
+
+ if(address < 0x1FF000)// TIMER
+ return this.ReadTimerCounter();
+
+ if(address < 0x1FF400)// IO
+ return this.GetJoystick();
+
+ if(address < 0x1FF800) {// INT Register
+ switch(address & 0x000003) {
+ case 0x02:
+ return this.GetIntDisable();
+ case 0x03:
+ return this.GetIntReqest();
+ default:
+ return 0x00;
+ }
+ }
+
+ return 0xFF;//EXT
+ }
+
+
+ Set(address, data) {
+ address = this.MPR[address >> 13] | (address & 0x1FFF);
+
+ if(address < 0x100000) {// ROM
+ this.Mapper.Write(address, data);
+ return;
+ }
+
+ if(address < 0x1EE000)// NOT USE
+ return;
+
+ if(address < 0x1F0000) {// BRAM
+ if(this.BRAMUse)
+ this.BRAM[address & 0x1FFF] = data;
+ return;
+ }
+
+ if(address < 0x1F8000) {// RAM
+ this.RAM[address & this.RAMMask] = data;
+ return;
+ }
+
+ if(address < 0x1FE000)// NOT USE
+ return;
+
+ if(address < 0x1FE400) {// VDC
+ if(this.SuperGrafx) {
+ let tmp = address & 0x00001F;
+ if(tmp < 0x00008) {
+ switch(address & 0x000003) {// VDC#1
+ case 0x00:
+ this.SetVDCRegister(data, 0);
+ break;
+ case 0x02:
+ this.SetVDCLow(data, 0);
+ break;
+ case 0x03:
+ this.SetVDCHigh(data, 0);
+ break;
+ }
+ } else if(tmp < 0x00010) {// VPC
+ this.SetVPC(tmp & 0x000007, data);
+ } else if(tmp < 0x00018) {// VDC#2
+ switch(address & 0x000003) {
+ case 0x00:
+ this.SetVDCRegister(data, 1);
+ break;
+ case 0x02:
+ this.SetVDCLow(data, 1);
+ break;
+ case 0x03:
+ this.SetVDCHigh(data, 1);
+ break;
+ }
+ }
+ } else {
+ switch(address & 0x000003) {// VDC#1
+ case 0x00:
+ this.SetVDCRegister(data, 0);
+ break;
+ case 0x01:
+ break;
+ case 0x02:
+ this.SetVDCLow(data, 0);
+ break;
+ case 0x03:
+ this.SetVDCHigh(data, 0);
+ break;
+ }
+ }
+ return;
+ }
+
+ if(address < 0x1FE800) {// VCE
+ switch(address & 0x000007) {
+ case 0x00:
+ this.SetVCEControl(data);
+ break;
+ case 0x02:
+ this.SetVCEAddressLow(data);
+ break;
+ case 0x03:
+ this.SetVCEAddressHigh(data);
+ break;
+ case 0x04:
+ this.SetVCEDataLow(data);
+ break;
+ case 0x05:
+ this.SetVCEDataHigh(data);
+ break;
+ }
+ return;
+ }
+
+ if(address < 0x1FEC00) {// PSG
+ this.SetPSG(address & 0x00000F, data);
+ return;
+ }
+
+ if(address < 0x1FF000) {// TIMER
+ switch(address & 0x000001) {
+ case 0x00:
+ this.WirteTimerReload(data);
+ break;
+ case 0x01:
+ this.WirteTimerControl(data);
+ break;
+ }
+ return;
+ }
+
+ if(address < 0x1FF400) {// IO
+ this.SetJoystick(data);
+ return;
+ }
+
+ if(address < 0x1FF800) {// INT Register
+ switch(address & 0x000003) {
+ case 0x02:
+ this.SetIntDisable(data);
+ break;
+ case 0x03:
+ this.SetIntReqest(data);
+ break;
+ }
+ return;
+ }
+ }
+
+
+ /* ************* */
+ /* **** VCE **** */
+ /* ************* */
+ VCEConstruct() {
+ this.Palette = new Array(512);
+ this.PaletteData = new Array(512);
+ this.MonoPaletteData = new Array(512);
+
+ this.VCEBaseClock = 0;
+ this.VCEControl = 0;
+ this.VCEAddress = 0;
+ this.VCEData = 0;
+ }
+
+
+ VCEInit() {
+ this.Palette.fill(0x0000);
+ for(let i=0; i<512; i++) {
+ this.PaletteData[i] = {r:0, g:0, b:0};
+ this.MonoPaletteData[i] = {r:0, g:0, b:0};
+ }
+
+ this.VCEBaseClock = this.BaseClock5;
+ this.VCEControl = 0x00;
+ this.VCEAddress = 0x00;
+ this.VCEData = 0x00;
+ }
+
+
+ SetVCEControl(data) {
+ this.VCEControl = data;
+
+ switch(data & 0x03) {
+ case 0x00:
+ this.VCEBaseClock = this.BaseClock5;
+ break;
+ case 0x01:
+ this.VCEBaseClock = this.BaseClock7;
+ break;
+ case 0x02:
+ case 0x03:
+ this.VCEBaseClock = this.BaseClock10;
+ break;
+ }
+ }
+
+
+ SetVCEAddressLow(data) {
+ this.VCEAddress = (this.VCEAddress & 0xFF00) | data;
+ }
+
+
+ SetVCEAddressHigh(data) {
+ this.VCEAddress = ((this.VCEAddress & 0x00FF) | (data << 8)) & 0x01FF;
+ }
+
+
+ GetVCEDataLow() {
+ return this.Palette[this.VCEAddress] & 0x00FF;
+ }
+
+
+ GetVCEDataHigh() {
+ let tmp = (this.Palette[this.VCEAddress] & 0xFF00) >> 8;
+ this.VCEAddress = (this.VCEAddress + 1) & 0x01FF;
+ return tmp;
+ }
+
+
+ SetVCEDataLow(data) {
+ this.Palette[this.VCEAddress] = (this.Palette[this.VCEAddress] & 0xFF00) | data;
+ this.ToPalettes();
+ }
+
+
+ SetVCEDataHigh(data) {
+ this.Palette[this.VCEAddress] = (this.Palette[this.VCEAddress] & 0x00FF) | (data << 8);
+ this.ToPalettes();
+ this.VCEAddress = (this.VCEAddress + 1) & 0x01FF;
+ }
+
+
+ ToPalettes() {
+ let color = this.Palette[this.VCEAddress];
+ let tmp = this.PaletteData[this.VCEAddress];
+ tmp.r = ((color >> 3) & 0x07) * 36;
+ tmp.g = ((color >> 6) & 0x07) * 36;
+ tmp.b = (color & 0x07) * 36;
+
+ let mono = tmp.r * 0.299 + tmp.g * 0.587 + tmp.b * 0.114;
+ this.MonoPaletteData[this.VCEAddress].r = mono;
+ this.MonoPaletteData[this.VCEAddress].g = mono;
+ this.MonoPaletteData[this.VCEAddress].b = mono;
+ }
+
+
+ /* ************* */
+ /* **** VPC **** */
+ /* ************* */
+ VPCConstruct() {
+ this.VPCRegister = new Array(8);
+ this.VDCSelect = 0;
+ this.VPCWindow1 = 0;
+ this.VPCWindow2 = 0;
+ this.VPCPriority = new Array(4);
+ }
+
+
+ VPCInit() {
+ this.VPCRegister.fill(0x00);
+ this.VPCRegister[0] = 0x11;
+ this.VPCRegister[1] = 0x11;
+ this.VPCRegister[7] = 0xFF;
+
+ this.VDCSelect = 0;
+ this.VPCWindow1 = 0;
+ this.VPCWindow2 = 0;
+ this.VPCPriority.fill(0x01);
+ }
+
+
+ SetVPC(no, data) {
+ if(no == 0x07)
+ return;
+
+ this.VPCRegister[no] = data;
+ if(no == 0x06)
+ this.VDCSelect = data & 0x01;
+
+ if(no == 0x02 || no == 0x03) {
+ this.VPCWindow1 = (this.VPCRegister[0x02] | ((this.VPCRegister[0x03] & 0x03) << 8)) - 64;
+ if(this.VPCWindow1 < 0)
+ this.VPCWindow1 = 1024;
+ }
+
+ if(no == 0x04 || no == 0x05) {
+ this.VPCWindow2 = (this.VPCRegister[0x04] | ((this.VPCRegister[0x05] & 0x03) << 8)) - 64;
+ if(this.VPCWindow2 < 0)
+ this.VPCWindow2 = -1;
+ }
+
+ if(no == 0x00) {
+ this.VPCPriority[2] = this.VPCRegister[0x00] >> 4;
+ this.VPCPriority[3] = this.VPCRegister[0x00] & 0x0F;
+ }
+
+ if(no == 0x01) {
+ this.VPCPriority[0] = this.VPCRegister[0x01] >> 4;
+ this.VPCPriority[1] = this.VPCRegister[0x01] & 0x0F;
+ }
+ }
+
+
+ GetVPC(no) {
+ return this.VPCRegister[no];
+ }
+
+
+ /* ************* */
+ /* **** VDC **** */
+ /* ************* */
+ VDCConstruct() {
+ this.DrawFlag = false;
+ this.VDCPutLineProgressClock = 0;
+ this.VDCPutLine = 0;
+ this.VDC = new Array(2);
+
+ this.VDCLineClock = 1368;
+
+ this.ScreenSize = [];
+ this.ScreenSize[this.BaseClock5] = 342;
+ this.ScreenSize[this.BaseClock7] = 456;
+ this.ScreenSize[this.BaseClock10] = 684;
+
+ this.PutScreenSize = [];
+ this.PutScreenSize[this.BaseClock5] = 320;
+ this.PutScreenSize[this.BaseClock7] = 428;
+ this.PutScreenSize[this.BaseClock10] = 640;
+
+ this.ScreenHeightMAX = 262;
+ this.ScreenWidthMAX = 684;
+
+ this.VScreenWidthArray = [];
+ this.VScreenWidthArray[0x00] = 32;
+ this.VScreenWidthArray[0x10] = 64;
+ this.VScreenWidthArray[0x20] = 128;
+ this.VScreenWidthArray[0x30] = 128;
+
+ this.ReverseBit = new Array(0x100).fill(0x00);
+ this.ReverseBit = this.ReverseBit.map((d, i) => { return ((i & 0x80) >> 7) | ((i & 0x40) >> 5) |
+ ((i & 0x20) >> 3) | ((i & 0x10) >> 1) |
+ ((i & 0x08) << 1) | ((i & 0x04) << 3) |
+ ((i & 0x02) << 5) | ((i & 0x01) << 7); });
+
+ this.ReverseBit16 = new Array(0x10000).fill(0x00);
+ this.ReverseBit16 = this.ReverseBit16.map((d, i) => { return (this.ReverseBit[i & 0x00FF] << 8) | this.ReverseBit[(i & 0xFF00) >> 8]; });
+
+ this.ReverseBit256 = new Array(0x100).fill(0x00);
+ this.ReverseBit256 = this.ReverseBit256.map((d, i) => { let b = this.ReverseBit[i];
+ return ((b & 0x80) << (28 - 7)) |
+ ((b & 0x40) << (24 - 6)) |
+ ((b & 0x20) << (20 - 5)) |
+ ((b & 0x10) << (16 - 4)) |
+ ((b & 0x08) << (12 - 3)) |
+ ((b & 0x04) << ( 8 - 2)) |
+ ((b & 0x02) << ( 4 - 1)) |
+ ((b & 0x01) << ( 0 - 0)); });
+
+ this.SPAddressMask = [];
+ this.SPAddressMask[16] = [];
+ this.SPAddressMask[32] = [];
+ this.SPAddressMask[16][16] = 0x07FE;
+ this.SPAddressMask[16][32] = 0x07FE & 0x07FA;
+ this.SPAddressMask[16][64] = 0x07FE & 0x07F2;
+ this.SPAddressMask[32][16] = 0x07FC;
+ this.SPAddressMask[32][32] = 0x07FC & 0x07FA;
+ this.SPAddressMask[32][64] = 0x07FC & 0x07F2;
+ }
+
+
+ MakeSpriteLine(vdcno) {
+ let vdcc = this.VDC[vdcno];
+
+ let sp = vdcc.SPLine;
+ for(let i=0; i> 8) + 16;
+ height = height > 32 ? 64 : height;
+
+ if(line < y || line > (y + height - 1))
+ continue;
+
+ let x = (satb[s + 1] & 0x3FF) - 32;
+ let width = ((attribute & 0x0100) >> 4) + 16;
+ if((x + width) <= 0)
+ continue;
+
+ let spy = line - y;
+ if((attribute & 0x8000) == 0x8000)
+ spy = (height - 1) - spy;
+
+ let index = ((satb[s + 2] & this.SPAddressMask[width][height]) << 5) | (((spy & 0x30) << 3) | (spy & 0x0F));
+
+ let data0;
+ let data1;
+ let data2;
+ let data3;
+ if((attribute & 0x0800) == 0x0000) {
+ data0 = revbit16[vram[index]];
+ data1 = revbit16[vram[index + 16]];
+ data2 = revbit16[vram[index + 32]];
+ data3 = revbit16[vram[index + 48]];
+ if(width == 32) {
+ data0 |= revbit16[vram[(index | 0x0040)]] << 16;
+ data1 |= revbit16[vram[(index | 0x0040) + 16]] << 16;
+ data2 |= revbit16[vram[(index | 0x0040) + 32]] << 16;
+ data3 |= revbit16[vram[(index | 0x0040) + 48]] << 16;
+ }
+ } else {
+ data0 = vram[index];
+ data1 = vram[index + 16];
+ data2 = vram[index + 32];
+ data3 = vram[index + 48];
+ if(width == 32) {
+ data0 = (data0 << 16) | vram[(index | 0x0040)];
+ data1 = (data1 << 16) | vram[(index | 0x0040) + 16];
+ data2 = (data2 << 16) | vram[(index | 0x0040) + 32];
+ data3 = (data3 << 16) | vram[(index | 0x0040) + 48];
+ }
+ }
+
+ let palette = ((attribute & 0x000F) << 4) | 0x0100;
+ let priority = attribute & 0x0080;
+
+ let j = 0;
+ if(x < 0) {
+ j -= x;
+ x = 0;
+ }
+
+ for(; j>> j) & 0x0001)
+ | (((data1 >>> j) << 1) & 0x0002)
+ | (((data2 >>> j) << 2) & 0x0004)
+ | (((data3 >>> j) << 3) & 0x0008);
+ if(dot != 0x00) {
+ spx.data = dot;
+ spx.palette = palette;
+ spx.priority = priority;
+ }
+ }
+
+ if(spx.no == 255)
+ spx.no = i;
+
+ if(i != 0 && spx.no == 0)
+ vdcc.VDCStatus |= vdcc.VDCRegister[0x05] & 0x0001;//SetSpriteCollisionINT
+
+ if(++dotcount == 256) {
+ vdcc.VDCStatus |= vdcc.VDCRegister[0x05] & 0x0002;//SetSpriteOverINT
+ if(vdcc.SpriteLimit)
+ return;
+ }
+ }
+ }
+ }
+
+
+ MakeBGLine(vdcno) {
+ let vdcc = this.VDC[vdcno];
+
+ let sp = vdcc.SPLine;
+ let bg = vdcc.BGLine;
+ let sw = vdcc.ScreenWidth;
+ let leftblank = ((vdcc.HDS + vdcc.HSW) << 3) + vdcc.DrawBGIndex;
+
+ if((vdcc.VDCRegister[0x05] & 0x0080) == 0x0080) {
+ let WidthMask = vdcc.VScreenWidth - 1;
+
+ let x = vdcc.VDCRegister[0x07];
+ let index_x = (x >> 3) & WidthMask;
+ x = (x & 0x07) << 2;
+
+ let y = vdcc.DrawBGLine;
+ let index_y = ((y >> 3) & (vdcc.VScreenHeight - 1)) * vdcc.VScreenWidth;
+ y = y & 0x07;
+
+ let vram = vdcc.VRAM;
+ let bgx = 0;
+ let revbit = this.ReverseBit256;
+
+ while(bgx < sw) {
+ let tmp = vram[index_x + index_y];
+ let address = ((tmp & 0x0FFF) << 4) + y;
+ let palette = (tmp & 0xF000) >> 8;
+
+ let data0 = vram[address];
+ let data1 = vram[address + 8];
+ let data = (revbit[ data0 & 0x00FF ] ) |
+ (revbit[(data0 & 0xFF00) >> 8] << 1) |
+ (revbit[ data1 & 0x00FF ] << 2) |
+ (revbit[(data1 & 0xFF00) >> 8] << 3);
+
+ for(; x<32 && bgx>> x) & 0x0F;
+ let spbgx = sp[bgx];
+ bg[bgx + leftblank] = spbgx.data != 0x00 && (dot == 0x00 || spbgx.priority == 0x0080) ?
+ spbgx.data | spbgx.palette : dot | (dot == 0x00 ? 0x00 : palette);
+ }
+
+ x = 0;
+ index_x = (index_x + 1) & WidthMask;
+ }
+ } else {
+ for(let i=0; i 0) {//VRAMtoSATB
+ vdcc.VRAMtoSATBCount -= this.ProgressClock;
+ if(vdcc.VRAMtoSATBCount <= 0)
+ vdcc.VDCStatus = (vdcc.VDCStatus & 0xBF) | ((vdcc.VDCRegister[0x0F] & 0x0001) << 3);//VRAMtoSATB INT
+ }
+
+ if(vdcc.VRAMtoVRAMCount > 0) {//VRAMtoVRAM
+ vdcc.VRAMtoVRAMCount -= this.ProgressClock;
+ if(vdcc.VRAMtoVRAMCount <= 0)
+ vdcc.VDCStatus = (vdcc.VDCStatus & 0xBF) | ((vdcc.VDCRegister[0x0F] & 0x0002) << 3);//VRAMtoVRAM INT
+ }
+ }
+
+
+ VDCProcess(vdcno) {
+ let vdcc = this.VDC[vdcno];
+
+ vdcc.VDCProgressClock -= this.VDCLineClock;
+
+ vdcc.DrawBGIndex = 0;
+ vdcc.BGLine.fill(0x100);
+
+ for(let i=0; i 261)
+ vline -= 261;
+ if(vdcc.DrawBGYLine == vline) {
+ vdcc.VDCStatus |= (vdcc.VDCRegister[0x05] & 0x0008) << 2;//SetVSync INT
+ if(vdcc.VRAMtoSATBStartFlag) {//VRAMtoSATB
+ for(let i=0, addr=vdcc.VDCRegister[0x13]; i<256; i++, addr++)
+ vdcc.SATB[i] = vdcc.VRAM[addr];
+ vdcc.VRAMtoSATBCount = 256 * this.VCEBaseClock;
+ vdcc.VDCStatus |= 0x40;
+ vdcc.VRAMtoSATBStartFlag = (vdcc.VDCRegister[0x0F] & 0x0010) == 0x0010;
+ }
+ }
+
+ vdcc.RasterCount++;
+ if(vdcc.DrawBGYLine == (vdcc.VDS + vdcc.VSW - 1))
+ vdcc.RasterCount = 64;
+
+ if(vdcc.RasterCount == vdcc.VDCRegister[0x06] && (vdcc.VDCStatus & 0x20) == 0x00)
+ vdcc.VDCStatus |= vdcc.VDCRegister[0x05] & 0x0004;//SetRaster INT
+
+ vdcc.DrawBGIndex += vdcc.DrawLineWidth;
+ }
+ }
+
+
+ VDCRun() {
+ this.VDCProcessDMA(0);
+ this.VDC[0].VDCProgressClock += this.ProgressClock;
+
+ if(this.SuperGrafx) {
+ this.VDCProcessDMA(1);
+ this.VDC[1].VDCProgressClock += this.ProgressClock;
+ }
+
+ while(this.VDC[0].VDCProgressClock >= this.VDCLineClock) {
+ this.VDCProcess(0);
+ if(this.SuperGrafx)
+ this.VDCProcess(1);
+ }
+
+ this.VDCPutLineProgressClock += this.ProgressClock;
+ if(this.VDCPutLineProgressClock >= this.VDCLineClock) {
+ this.VDCPutLineProgressClock -= this.VDCLineClock;
+ this.VDCPutLine++;
+
+ if(this.VDCPutLine == this.ScreenHeightMAX) {
+ this.VDCPutLine = 0;
+ this.GetScreenSize(0);
+ this.VDC[0].DrawBGYLine = 0;
+ if(this.SuperGrafx) {
+ this.GetScreenSize(1);
+ this.VDC[1].DrawBGYLine = 0;
+ }
+ this.DrawFlag = true;
+ this.Ctx.putImageData(this.ImageData, 0, 0);
+ }
+
+ let palettes = (this.VCEControl & 0x80) == 0x00 ? this.PaletteData : this.MonoPaletteData;
+
+ let data = this.ImageData.data;
+ let imageIndex = this.VDCPutLine * this.ScreenWidthMAX * 4;
+ let black = palettes[0x100];
+
+ let sw = this.ScreenSize[this.VCEBaseClock];
+ let bgl0 = this.VDC[0].BGLine;
+
+ if(this.SuperGrafx) {//VPC
+ let window1 = this.VPCWindow1;
+ let window2 = this.VPCWindow2;
+ let priority = this.VPCPriority;
+
+ let bgl1 = this.VDC[1].BGLine;
+ for(let bgx=0; bgx < sw; bgx++, imageIndex+=4) {
+ let wflag = 0x00;
+ if(bgx >= window1)
+ wflag |= 0x01;
+ if(bgx <= window2)
+ wflag |= 0x02;
+
+ let bg0 = bgl0[bgx];
+ let bg1 = bgl1[bgx];
+
+ let color;
+ switch(priority[wflag]) {
+ case 0x04 | 0x03:
+ if(bg0 > 0x100 || bg1 > 0x100)
+ color = palettes[bg0 > 0x100 ? bg0 : bg1];
+ else
+ color = palettes[(bg0 & 0x0FF) != 0x000 ? bg0 : bg1];
+
+ break;
+ case 0x08 | 0x03:
+ if(bg0 < 0x100 && bg0 != 0x000)
+ color = palettes[bg0];
+ else
+ color = palettes[(bg1 & 0x0FF) != 0x000 ? bg1 : bg0];
+ break;
+ case 0x00 | 0x03:
+ case 0x0C | 0x03:
+ color = palettes[(bg0 & 0x0FF) != 0x000 ? bg0 : bg1];
+ break;
+ case 0x00 | 0x01:
+ case 0x04 | 0x01:
+ case 0x08 | 0x01:
+ case 0x0C | 0x01:
+ color = palettes[bg0];
+ break;
+ case 0x00 | 0x02:
+ case 0x04 | 0x02:
+ case 0x08 | 0x02:
+ case 0x0C | 0x02:
+ color = palettes[bg1];
+ break;
+ default:
+ color = black;
+ break;
+ }
+ data[imageIndex] = color.r;
+ data[imageIndex + 1] = color.g;
+ data[imageIndex + 2] = color.b;
+ }
+ } else {
+ for(let bgx=0; bgx < sw; bgx++, imageIndex+=4) {
+ let color = palettes[bgl0[bgx]];
+ data[imageIndex] = color.r;
+ data[imageIndex + 1] = color.g;
+ data[imageIndex + 2] = color.b;
+ }
+ }
+ }
+ }
+
+
+ GetScreenSize(vdcno) {
+ let vdcc = this.VDC[vdcno];
+ let r = vdcc.VDCRegister;
+
+ vdcc.VScreenWidth = this.VScreenWidthArray[r[0x09] & 0x0030];
+
+ vdcc.VScreenHeight = (r[0x09] & 0x0040) == 0x0000 ? 32 : 64;
+ vdcc.VScreenHeightMask = vdcc.VScreenHeight * 8 - 1;
+ vdcc.ScreenWidth = ((r[0x0B] & 0x007F) + 1) * 8;
+
+ if(vdcc.ScreenWidth > this.ScreenWidthMAX)
+ vdcc.ScreenWidth = this.ScreenWidthMAX;
+
+ vdcc.HDS = (r[0x0A] & 0x7F00) >> 8;
+ vdcc.HSW = r[0x0A] & 0x001F;
+
+ vdcc.HDE = (r[0x0B] & 0x7F00) >> 8;
+ vdcc.HDW = r[0x0B] & 0x007F;
+
+ vdcc.VDS = ((r[0x0C] & 0xFF00) >> 8);
+ vdcc.VSW = r[0x0C] & 0x001F;
+
+ vdcc.VDW = r[0x0D] & 0x01FF;
+
+ vdcc.VCR = r[0x0E] & 0x00FF;
+
+ vdcc.ScreenSize = this.ScreenSize[this.VCEBaseClock];
+ if(this.MainCanvas.width != vdcc.ScreenSize) {
+ //this.MainCanvas.style.width = (this.PutScreenSize[this.VCEBaseClock] * 2) + 'px';
+ this.MainCanvas.width = this.PutScreenSize[this.VCEBaseClock];
+ }
+
+ vdcc.DrawLineWidth = (vdcc.HDS + vdcc.HSW + vdcc.HDE + vdcc.HDW + 1) << 3;
+ if(vdcc.DrawLineWidth <= this.ScreenSize[this.BaseClock5])
+ vdcc.DrawLineWidth = this.ScreenSize[this.BaseClock5];
+ else if(vdcc.DrawLineWidth <= this.ScreenSize[this.BaseClock7])
+ vdcc.DrawLineWidth = this.ScreenSize[this.BaseClock7];
+ else vdcc.DrawLineWidth = this.ScreenSize[this.BaseClock10];
+
+ vdcc.VDCBurst = (r[0x05] & 0x00C0) == 0x0000 ? true : false;
+ }
+
+
+ VDCInit() {
+ this.VDCPutLineProgressClock = 0;
+ this.VDCPutLine = 0;
+ this.DrawFlag = false;
+
+ for(let vdcno=0; vdcno<2; vdcno++) {
+ this.VDC[vdcno] = {
+ VDCRegister: new Array(20).fill(0x0000),
+ VRAM: new Array(0x10000).fill(0x0000),
+ SATB: new Array(256).fill(0x0000),
+ VDCBurst: false,
+ SpriteLimit: false,
+
+ SPLine: new Array(this.ScreenWidthMAX),
+ BGLine: new Array(this.ScreenWidthMAX).fill(0x00),
+
+ VDCStatus: 0x00,
+ VDCRegisterSelect: 0x00,
+ WriteVRAMData: 0x0000,
+
+ VRAMtoSATBStartFlag: false,
+ VRAMtoSATBCount: 0,
+ VRAMtoVRAMCount: 0,
+
+ RasterCount: 64,
+ VDCProgressClock: 0,
+ DrawBGYLine: 0,
+ DrawBGLine: 0,
+
+ VScreenWidth: 0,
+ VScreenHeight: 0,
+ VScreenHeightMask: 0,
+ ScreenWidth: 0,
+ ScreenSize: 0,
+ DrawLineWidth: 0,
+ DrawBGIndex: 0,
+
+ HDS: 0,
+ HSW: 0,
+ HDE: 0,
+ HDW: 0,
+ VDS: 0,
+ VSW: 0,
+ VDW: 0,
+ VCR: 0};
+
+ for(let i=0; i 0; l--) {
+ vram[d] = vram[s];
+ s = (s + si) & 0xFFFF;
+ d = (d + di) & 0xFFFF;
+ }
+ return;
+ }
+
+ if(vdcc.VDCRegisterSelect == 0x13)//VRAMtoSATB
+ vdcc.VRAMtoSATBStartFlag = true;
+ }
+
+
+ GetVRAMIncrement(vdcno) {
+ switch(this.VDC[vdcno].VDCRegister[0x05] & 0x1800) {
+ case 0x0000:
+ return 1;
+ case 0x0800:
+ return 32;
+ case 0x1000:
+ return 64;
+ case 0x1800:
+ return 128;
+ }
+ }
+
+
+ GetVDCStatus(vdcno) {
+ let tmp = this.VDC[vdcno].VDCStatus;
+ this.VDC[vdcno].VDCStatus &= 0x40;
+ return tmp;
+ }
+
+
+ GetVDCLow(vdcno) {
+ return this.VDC[vdcno].VDCRegister[this.VDC[vdcno].VDCRegisterSelect] & 0x00FF;
+ }
+
+
+ GetVDCHigh(vdcno) {
+ let vdcc = this.VDC[vdcno];
+
+ if(vdcc.VDCRegisterSelect == 0x02 || vdcc.VDCRegisterSelect == 0x03) {
+ let tmp = (vdcc.VDCRegister[0x02] & 0xFF00) >> 8;
+ vdcc.VDCRegister[0x02] = vdcc.VRAM[vdcc.VDCRegister[0x01]];
+ vdcc.VDCRegister[0x03] = vdcc.VDCRegister[0x02];
+ vdcc.VDCRegister[0x01] = (vdcc.VDCRegister[0x01] + this.GetVRAMIncrement(vdcno)) & 0xFFFF;
+ return tmp;
+ }
+
+ return (vdcc.VDCRegister[vdcc.VDCRegisterSelect] & 0xFF00) >> 8;
+ }
+
+
+ /* *************** */
+ /* **** Sound **** */
+ /* *************** */
+ SoundConstruct() {
+ this.WaveDataArray = [];
+ this.WaveClockCounter = 0;
+ this.WaveVolume = 1.0;
+
+ this.WebAudioCtx = null;
+ this.WebAudioJsNode = null;
+ this.WebAudioGainNode = null;
+ this.WebAudioBufferSize = 2048;
+
+ this.PSGClock = 3579545;
+ }
+
+
+ WebAudioFunction(e) {
+ let output = [];
+ let data = [];
+
+ for(let i=0; i<2; i++) {
+ output[i] = e.outputBuffer.getChannelData(i);
+ data[i] = new Float32Array(this.WebAudioBufferSize);
+ if(this.WaveDataArray[i].length < this.WebAudioBufferSize) {
+ data[i].fill(0.0);
+ } else {
+ for(let j=0; j this.WebAudioBufferSize * 2)
+ this.WaveDataArray[i] = this.WaveDataArray[i].slice(this.WebAudioBufferSize);
+ }
+ output[i].set(data[i]);
+ }
+ }
+
+ SoundInit() {
+ this.WaveClockCounter = 0;
+ this.WaveDataArray = [];
+ this.WaveDataArray[0] = [];
+ this.WaveDataArray[1] = [];
+
+ if(typeof AudioContext !== "undefined" && this.WebAudioCtx == null) {
+ this.CreateAudioContext();
+ }
+ }
+
+ CreateAudioContext() {
+ this.WebAudioCtx = new window.AudioContext();
+ this.WebAudioJsNode = this.WebAudioCtx.createScriptProcessor(this.WebAudioBufferSize, 0, 2);
+ this.WebAudioJsNode.onaudioprocess = this.WebAudioFunction.bind(this);
+ this.WebAudioGainNode = this.WebAudioCtx.createGain();
+ this.WebAudioJsNode.connect(this.WebAudioGainNode);
+ this.WebAudioGainNode.connect(this.WebAudioCtx.destination);
+ }
+
+ SoundSet() {
+ let waveoutleft;
+ let waveoutright;
+ let ch;
+
+ let i;
+ let j;
+ let out;
+
+ this.WaveClockCounter += this.WebAudioCtx.sampleRate;
+ if(this.WaveClockCounter >= this.PSGClock) {
+ this.WaveClockCounter -= this.PSGClock;
+
+ waveoutleft = 0;
+ waveoutright = 0;
+ for(j=0; j<6; j++) {
+ if(j != 1 || !this.WaveLfoOn) {
+ ch = this.PSGChannel[j];
+
+ if(j < 4 || !ch.noiseon)
+ out = ch.keyon ? (ch.dda ? ch.R[6] & 0x1F : ch.wave[ch.index]) : 0;
+ else
+ out = (ch.noise & 0x0001) == 0x0001 ? 0x0F : 0;
+
+ waveoutleft += out * ch.leftvol;
+ waveoutright += out * ch.rightvol;
+ }
+ }
+ this.WaveDataArray[0].push(waveoutleft * this.WaveVolumeLeft);
+ this.WaveDataArray[1].push(waveoutright * this.WaveVolumeRight);
+ this.WebAudioGainNode.gain.value = this.WaveVolume;
+ }
+ }
+
+
+ /* ************* */
+ /* **** PSG **** */
+ /* ************* */
+ PSGConstruct() {
+ this.PSGChannel = new Array(6);
+ this.PSGBaseClock = this.BaseClock3;
+
+ this.PSGProgressClock = 0;
+
+ this.WaveVolumeLeft = 0;
+ this.WaveVolumeRight = 0;
+
+ this.WaveLfoOn = false;
+ this.WaveLfoControl = 0;
+ this.WaveLfoFreqency = 0;
+ }
+
+
+ PSGInit() {
+ this.SoundInit();
+
+ for(let i=0; i 0) {
+ i--;
+ j = 0;
+
+ if(this.WaveLfoOn) {
+ ch0 = this.PSGChannel[0];
+ ch1 = this.PSGChannel[1];
+ if(ch0.keyon) {
+ if(ch0.count == 0) {
+ ch0.index = (ch0.index + 1) & 0x1F;
+ freqtmp = 0;
+ if(this.WaveLfoControl != 0x00) {
+ freqtmp = ch1.wave[ch1.index];
+ freqtmp = freqtmp > 0x0F ? freqtmp - 0x20 : freqtmp & 0x0F;
+ freqtmp <<= 4 * (this.WaveLfoControl - 1);
+ }
+ freqtmp = ch0.freq + freqtmp;
+ if(freqtmp < 0)
+ freqtmp = 0;
+ ch0.count = freqtmp;
+ } else
+ ch0.count--;
+
+ if(ch1.count == 0) {
+ ch1.index = (ch1.index + 1) & 0x1F;
+ ch1.count = ch1.freq * this.WaveLfoFreqency;
+ } else
+ ch1.count--;
+ }
+ j = 2;
+ }
+
+ for(; j<6; j++) {
+ ch = this.PSGChannel[j];
+ if(j < 4 || !ch.noiseon) {
+ if(ch.keyon && !ch.dda) {
+ if(ch.count == 0) {
+ ch.index = (ch.index + 1) & 0x1F;
+ ch.count = ch.freq;
+ } else
+ ch.count--;
+ }
+ } else {
+ if(ch.keyon && !ch.dda) {
+ if(ch.count == 0) {
+ ch.index = (ch.index + 1) & 0x1F;
+ if(ch.index == 0)
+ ch.noise = (ch.noise >> 1) | (((ch.noise << 12) ^ (ch.noise << 15)) & 0x8000);
+ ch.count = ch.noisefreq;
+ } else
+ ch.count--;
+ }
+ }
+ }
+ this.SoundSet();
+ }
+ }
+
+
+ SetPSG(r, data) {
+ if(r == 0) {
+ this.PSGChannel[0].R[0] = data & 0x07;
+ return;
+ }
+
+ if(this.PSGChannel[0].R[0] > 5)
+ return;
+
+ let ch = this.PSGChannel[this.PSGChannel[0].R[0]];
+ ch.R[r] = data;
+
+ switch(r) {
+ case 1:
+ this.PSGChannel[0].R[1] = data;
+ this.WaveVolumeLeft = (data & 0xF0) >> 4;
+ this.WaveVolumeRight = data & 0x0F;
+ return;
+
+ case 2:
+ case 3:
+ ch.freq = ((ch.R[3] << 8) | ch.R[2]) & 0x0FFF;
+ return;
+
+ case 4:
+ ch.keyon = (data & 0x80) == 0x80 ? true : false;
+ ch.dda = (data & 0x40) == 0x40 ? true : false;
+ if((data & 0x40) == 0x40)
+ ch.index = 0;
+ ch.vol = data & 0x1F;
+ case 5:
+ let vol = ch.R[4] & 0x1F;
+ ch.leftvol = ((ch.R[5] & 0xF0) >> 4) * vol;
+ ch.rightvol = (ch.R[5] & 0x0F) * vol;
+ return;
+
+ case 6:
+ if(!ch.dda) {
+ ch.wave[ch.index] = data & 0x1F;
+ ch.index = (ch.index + 1) & 0x1F;
+ }
+ return;
+
+ case 7:
+ ch.noiseon = (data & 0x80) == 0x80 ? true : false;
+ ch.noisefreq = (data & 0x1F) ^ 0x1F;
+ return;
+
+ case 8:
+ this.PSGChannel[0].R[8] = data;
+ this.WaveLfoFreqency = data;
+ return;
+
+ case 9:
+ this.PSGChannel[0].R[9] = data;
+ this.WaveLfoOn = (data & 0x80) == 0x80 ? true : false;
+ this.WaveLfoControl = data & 0x03;
+ return;
+ }
+ }
+
+
+ GetPSG(r) {
+ if(r > 9)
+ return 0xFF;
+ if(r == 0 || r == 1 || r == 8 || r == 9)
+ return this.PSGChannel[0].R[r];
+ if(this.PSGChannel[0].R[0] > 5)
+ return 0xFF;
+ return this.PSGChannel[this.PSGChannel[0].R[0]].R[r];
+ }
+
+
+ /* *************** */
+ /* **** TIMER **** */
+ /* *************** */
+ TimerConstruct() {
+ this.TimerBaseClock = this.BaseClock7;
+ this.TimerReload = 0;
+ this.TimerFlag = false;
+ this.TimerCounter = 0;
+ this.TimerPrescaler = 0;
+ this.INTTIQ = 0;
+ }
+
+
+ TimerInit() {
+ this.TimerReload = 0x00;
+ this.TimerFlag = false;
+ this.TimerCounter = 0x00;
+ this.TimerPrescaler = 0;
+ this.INTTIQ = 0x00;
+ }
+
+
+ ReadTimerCounter() {
+ return this.TimerCounter;
+ }
+
+
+ TimerAcknowledge() {
+ this.INTTIQ = 0x00;
+ }
+
+
+ WirteTimerReload(data) {
+ this.TimerReload = data & 0x7F;
+ }
+
+
+ WirteTimerControl(data) {
+ if(!this.TimerFlag && (data & 0x01) == 0x01) {
+ this.TimerCounter = this.TimerReload;
+ this.TimerPrescaler = 0;
+ }
+
+ this.TimerFlag = (data & 0x01) == 0x01 ? true : false;
+ }
+
+
+ TimerRun() {
+ if(this.TimerFlag) {
+ this.TimerPrescaler += this.ProgressClock;
+ while(this.TimerPrescaler >= (1024 * this.TimerBaseClock)) {
+ this.TimerPrescaler -= 1024 * this.TimerBaseClock;
+ this.TimerCounter--;
+ if(this.TimerCounter < 0) {
+ this.TimerCounter = this.TimerReload;
+ this.INTTIQ = this.TIQFlag;
+ }
+ }
+ }
+ }
+
+
+ /* ****************** */
+ /* **** Joystick **** */
+ /* ****************** */
+ JoystickConstruct() {
+ this.JoystickSEL = 0;
+ this.JoystickCLR = 0;
+ this.KeyUpFunction = null;
+ this.KeyDownFunction = null;
+
+ this.Keybord = new Array(5).fill([]);
+ this.Keybord = this.Keybord.map((d) => { return new Array(4); });
+
+ this.GamePad = new Array(5).fill([]);
+ this.GamePad = this.Keybord.map((d) => { return new Array(4); });
+
+ this.GamePadSelect = 0x00;
+ this.GamePadButtonSelect = 0x00;
+ this.GamePadBuffer = 0x00;
+
+ this.GamePadData = [];
+ this.GamePadData["STANDARD PAD"] = [
+ [[{type:"B", index:1}],// SHOT1
+ [{type:"B", index:0}],// SHOT2
+ [{type:"B", index:8}],// SELECT
+ [{type:"B", index:9}, {type:"B", index:2}],// RUN
+ [{type:"B", index:12}],// UP
+ [{type:"B", index:13}],// DOWN
+ [{type:"B", index:14}],// LEFT
+ [{type:"B", index:15}]],// RIGHT
+
+ [[{type:"B", index:1}],// SHOT1
+ [{type:"B", index:0}],// SHOT2
+ [{type:"B", index:8}],// SELECT
+ [{type:"B", index:9}],// RUN
+ [{type:"B", index:12}],// UP
+ [{type:"B", index:13}],// DOWN
+ [{type:"B", index:14}],// LEFT
+ [{type:"B", index:15}],// RIGHT
+ [{type:"B", index:7}],// SHOT3
+ [{type:"B", index:5}],// SHOT4
+ [{type:"B", index:2}],// SHOT5
+ [{type:"B", index:3}]]];// SHOT6
+
+ this.GamePadData["HORI PAD 3 TURBO (Vendor: 0f0d Product: 0009)"] = [// Chrome
+ [[{type:"B", index:2}],// SHOT1
+ [{type:"B", index:1}],// SHOT2
+ [{type:"B", index:8}],// SELECT
+ [{type:"B", index:9}, {type:"B", index:0}],// RUN
+ [{type:"P", index:9}],// UP (POV)
+ [{type:"N", index:0}],// DOWN (POV)
+ [{type:"N", index:0}],// LEFT (POV)
+ [{type:"N", index:0}]],// RIGHT (POV)
+
+ [[{type:"B", index:2}],// SHOT1
+ [{type:"B", index:1}],// SHOT2
+ [{type:"B", index:8}],// SELECT
+ [{type:"B", index:9}],// RUN
+ [{type:"P", index:9}],// UP (POV)
+ [{type:"N", index:0}],// DOWN (POV)
+ [{type:"N", index:0}],// LEFT (POV)
+ [{type:"N", index:0}],// RIGHT (POV)
+ [{type:"B", index:7}],// SHOT3
+ [{type:"B", index:5}],// SHOT4
+ [{type:"B", index:0}],// SHOT5
+ [{type:"B", index:3}]]];// SHOT6
+
+ this.GamePadData["0f0d-0009-HORI PAD 3 TURBO"] = this.GamePadData["HORI PAD 3 TURBO (Vendor: 0f0d Product: 0009)"];// Firefox
+ this.GamePadData["UNKNOWN PAD"] = this.GamePadData["HORI PAD 3 TURBO (Vendor: 0f0d Product: 0009)"];
+
+ this.GamePadKeyData = [{index:0, data:0x01}, {index:0, data:0x02},
+ {index:0, data:0x04}, {index:0, data:0x08},
+ {index:1, data:0x01}, {index:1, data:0x04},
+ {index:1, data:0x08}, {index:1, data:0x02},
+ {index:2, data:0x01}, {index:2, data:0x02},
+ {index:2, data:0x04}, {index:2, data:0x08}];
+
+ this.GamePadPovData = [0x01, 0x01|0x02, 0x02, 0x02|0x04, 0x04, 0x04|0x08, 0x08, 0x01|0x08];
+ }
+
+
+ JoystickInit() {
+ this.JoystickSEL = 0;
+ this.JoystickCLR = 0;
+
+ for(let i=0; i> 1;
+
+ if((this.JoystickSEL == 1 && this.JoystickCLR == 0) && (sel == 1 && clr == 1)) {
+ this.JoystickSEL = 0;
+ this.JoystickCLR = 0;
+ this.GamePadSelect = 0;
+ if(this.GamePadButton6)
+ this.GamePadButtonSelect = this.GamePadButtonSelect ^ 0x02;
+ this.GamePadBuffer = 0xB0 | this.CountryType;
+ return;
+ }
+
+ if((this.JoystickSEL == 0 && this.JoystickCLR == 0) && (sel == 1 && clr == 0))
+ this.GamePadSelect++;
+
+ this.JoystickSEL = sel;
+ this.JoystickCLR = clr;
+
+ let no = this.MultiTap ? this.GamePadSelect - 1 : 0;
+ if(no < 5) {
+ let tmp = this.GamePadButtonSelect | this.JoystickSEL;
+ this.GamePadBuffer = (this.Keybord[no][tmp] & this.GamePad[no][tmp]) | this.CountryType;
+ } else
+ this.GamePadBuffer = 0xB0 | this.CountryType;
+ }
+
+
+ GetJoystick() {
+ return this.GamePadBuffer;
+ }
+
+
+ UnsetButtonRUN(no) {
+ this.Keybord[no][0] |= 0x08;
+ }
+
+
+ UnsetButtonSELECT(no) {
+ this.Keybord[no][0] |= 0x04;
+ }
+
+
+ UnsetButtonSHOT2(no) {
+ this.Keybord[no][0] |= 0x02;
+ }
+
+
+ UnsetButtonSHOT1(no) {
+ this.Keybord[no][0] |= 0x01;
+ }
+
+
+ UnsetButtonLEFT(no) {
+ this.Keybord[no][1] |= 0x08;
+ }
+
+
+ UnsetButtonDOWN(no) {
+ this.Keybord[no][1] |= 0x04;
+ }
+
+
+ UnsetButtonRIGHT(no) {
+ this.Keybord[no][1] |= 0x02;
+ }
+
+
+ UnsetButtonUP(no) {
+ this.Keybord[no][1] |= 0x01;
+ }
+
+
+ UnsetButtonSHOT6(no) {
+ this.Keybord[no][2] |= 0x08;
+ }
+
+
+ UnsetButtonSHOT5(no) {
+ this.Keybord[no][2] |= 0x04;
+ }
+
+
+ UnsetButtonSHOT4(no) {
+ this.Keybord[no][2] |= 0x02;
+ }
+
+
+ UnsetButtonSHOT3(no) {
+ this.Keybord[no][2] |= 0x01;
+ }
+
+
+ SetButtonRUN(no) {
+ this.Keybord[no][0] &= ~0x08;
+ }
+
+
+ SetButtonSELECT(no) {
+ this.Keybord[no][0] &= ~0x04;
+ }
+
+
+ SetButtonSHOT2(no) {
+ this.Keybord[no][0] &= ~0x02;
+ }
+
+
+ SetButtonSHOT1(no) {
+ this.Keybord[no][0] &= ~0x01;
+ }
+
+
+ SetButtonLEFT(no) {
+ this.Keybord[no][1] &= ~0x08;
+ }
+
+
+ SetButtonDOWN(no) {
+ this.Keybord[no][1] &= ~0x04;
+ }
+
+
+ SetButtonRIGHT(no) {
+ this.Keybord[no][1] &= ~0x02;
+ }
+
+
+ SetButtonUP(no) {
+ this.Keybord[no][1] &= ~0x01;
+ }
+
+
+ SetButtonSHOT6(no) {
+ this.Keybord[no][2] &= ~0x08;
+ }
+
+
+ SetButtonSHOT5(no) {
+ this.Keybord[no][2] &= ~0x04;
+ }
+
+
+ SetButtonSHOT4(no) {
+ this.Keybord[no][2] &= ~0x02;
+ }
+
+
+ SetButtonSHOT3(no) {
+ this.Keybord[no][2] &= ~0x01;
+ }
+
+
+ CheckKeyUpFunction(evt) {
+ switch (evt.keyCode){
+ case Keys['START'].c:// RUN 'S'
+ this.UnsetButtonRUN(0);
+ break;
+ case Keys['SELECT'].c:// SELECT 'A'
+ this.UnsetButtonSELECT(0);
+ break;
+ case Keys['A'].c:// SHOT2 'Z'
+ case Keys['GP_A'].c:// SHOT2 'Z'
+ this.UnsetButtonSHOT2(0);
+ break;
+ case Keys['B'].c:// SHOT1 'X'
+ case Keys['GP_B'].c:// SHOT1 'X'
+ this.UnsetButtonSHOT1(0);
+ break;
+
+ case 86:// SHOT2 'V'
+ this.UnsetButtonSHOT2(0);
+ break;
+ case 66:// SHOT1 'B'
+ this.UnsetButtonSHOT1(0);
+ break;
+
+ case 37:// LEFT
+ this.UnsetButtonLEFT(0);
+ break;
+ case 39:// RIGHT
+ this.UnsetButtonRIGHT(0);
+ break;
+ case 40:// DOWN
+ this.UnsetButtonDOWN(0);
+ break;
+ case 38:// UP
+ this.UnsetButtonUP(0);
+ break;
+
+ case 71:// SHOT6 'G'
+ this.UnsetButtonSHOT6(0);
+ break;
+ case 70:// SHOT5 'F'
+ this.UnsetButtonSHOT5(0);
+ break;
+ case 68:// SHOT4 'D'
+ this.UnsetButtonSHOT4(0);
+ break;
+ case 67:// SHOT3 'C'
+ this.UnsetButtonSHOT3(0);
+ break;
+ }
+ //evt.preventDefault();
+ }
+
+
+ CheckKeyDownFunction(evt) {
+ switch (evt.keyCode){
+ case Keys['START'].c:// RUN 'S'
+ this.SetButtonRUN(0);
+ break;
+ case Keys['SELECT'].c:// SELECT 'A'
+ this.SetButtonSELECT(0);
+ break;
+ case Keys['A'].c:// SHOT2 'Z'
+ case Keys['GP_A'].c:// SHOT2 'Z'
+ this.SetButtonSHOT2(0);
+ break;
+ case Keys['B'].c:// SHOT2 'Z'
+ case Keys['GP_B'].c:// SHOT2 'Z'
+ this.SetButtonSHOT1(0);
+ break;
+
+ case 86:// SHOT2 'V'
+ this.SetButtonSHOT2(0);
+ break;
+ case 66:// SHOT1 'B'
+ this.SetButtonSHOT1(0);
+ break;
+
+ case 37:// LEFT
+ this.SetButtonLEFT(0);
+ break;
+ case 39:// RIGHT
+ this.SetButtonRIGHT(0);
+ break;
+ case 40:// DOWN
+ this.SetButtonDOWN(0);
+ break;
+ case 38:// UP
+ this.SetButtonUP(0);
+ break;
+
+ case 71:// SHOT6 'G'
+ this.SetButtonSHOT6(0);
+ break;
+ case 70:// SHOT5 'F'
+ this.SetButtonSHOT5(0);
+ break;
+ case 68:// SHOT4 'D'
+ this.SetButtonSHOT4(0);
+ break;
+ case 67:// SHOT3 'C'
+ this.SetButtonSHOT3(0);
+ break;
+ }
+ //evt.preventDefault();
+ }
+
+
+ JoystickEventInit() {
+ this.KeyUpFunction = this.CheckKeyUpFunction.bind(this);
+ this.KeyDownFunction = this.CheckKeyDownFunction.bind(this);
+ this.MainCanvas.addEventListener("keyup", this.KeyUpFunction, true);
+ this.MainCanvas.addEventListener("keydown", this.KeyDownFunction, true);
+ }
+
+
+ JoystickEventRelease() {
+ this.MainCanvas.removeEventListener("keyup", this.KeyUpFunction, true);
+ this.MainCanvas.removeEventListener("keydown", this.KeyDownFunction, true);
+ }
+
+ CheckGamePad() {
+ for(let i=0; i 0.5)
+ this.GamePad[i][this.GamePadKeyData[tmp].index] &= ~this.GamePadKeyData[tmp].data;
+ break;
+ case "AB":
+ if(pad.axes[val1.index] > -0.75)
+ this.GamePad[i][this.GamePadKeyData[tmp].index] &= ~this.GamePadKeyData[tmp].data;
+ break;
+ case "P":
+ let povtmp = ((pad.axes[val1.index] + 1) * 7 / 2 + 0.5) | 0;
+ this.GamePad[i][1] &= ~(povtmp <= 7 ? this.GamePadPovData[povtmp] : 0x00);
+ break;
+ }
+ }
+ tmp++;
+ }
+ }
+ }
+ }
+}
diff --git a/src/worker/fs/fs65-pce.data b/src/worker/fs/fs65-pce.data
new file mode 100644
index 00000000..b206e252
--- /dev/null
+++ b/src/worker/fs/fs65-pce.data
@@ -0,0 +1,36397 @@
+;
+; _file.inc
+;
+; (C) Copyright 2002 Ullrich von Bassewitz (uz@cc65.org)
+;
+
+; Assembler include file that makes the constants and structures in _file.h
+; available for asm code.
+
+; Struct _FILE
+.struct _FILE
+ f_fd .byte
+ f_flags .byte
+ f_pushback .byte
+.endstruct
+
+; Flags field
+_FCLOSED = $00
+_FOPEN = $01
+_FEOF = $02
+_FERROR = $04
+_FPUSHBACK = $08
+
+; File table
+.global __filetab
+
+
+;
+; _heap.inc
+;
+; (c) Copyright 2003, Ullrich von Bassewitz (uz@cc65.org)
+;
+
+; Assembler include file that makes the constants and structures in _heap.h
+; available for asm code.
+
+; Struct freeblock
+; NOTE: For performance reasons, the asm code often uses increment/decrement
+; operators to access other offsets, so just changing offsets here will
+; probably not work.
+.struct freeblock
+ size .word
+ next .addr
+ prev .addr
+.endstruct
+
+; Struct usedblock
+; See notes above
+.struct usedblock
+ size .word
+ start .addr
+.endstruct
+
+HEAP_MIN_BLOCKSIZE = .sizeof (freeblock) ; Minimum size of an allocated block
+HEAP_ADMIN_SPACE = .sizeof (usedblock) ; Additional space for used bock
+
+; Variables
+.global ___heaporg
+.global ___heapptr
+.global ___heapend
+.global ___heapfirst
+.global ___heaplast
+;
+; Accelerator definitions.
+;
+
+; ---------------------------------------------------------------------------
+; Speed definitions for all accelerator, to be used as input for the 'set'
+; functions.
+
+
+SPEED_SLOW = $00
+SPEED_FAST = $FF
+
+SPEED_1X = SPEED_SLOW
+SPEED_2X = 2 - 1
+SPEED_3X = 3 - 1
+SPEED_4X = 4 - 1
+SPEED_5X = 5 - 1
+SPEED_6X = 6 - 1
+SPEED_7X = 7 - 1
+SPEED_8X = 8 - 1
+SPEED_10X = 10 - 1
+SPEED_12X = 12 - 1
+SPEED_16X = 16 - 1
+SPEED_20X = 20 - 1
+
+
+; ---------------------------------------------------------------------------
+; C64/C128 Super CPU cartridge
+
+SuperCPU_Slow := $D07A
+SuperCPU_Fast := $D07B
+SuperCPU_Speed_Mode := $D0B8
+SuperCPU_Detect := $D0BC
+
+
+; ---------------------------------------------------------------------------
+; C64DTV
+
+C64DTV_Extended_Regs := $D03F
+
+C64DTV_Slow = $00
+C64DTV_Fast = $03
+
+
+; ---------------------------------------------------------------------------
+; C128 native and C128 in C64 mode
+
+C128_VICIIE_CLK := $D030
+
+
+; ---------------------------------------------------------------------------
+; C64 Chameleon cartridge
+
+CHAMELEON_CFGTUR := $D0F3
+CHAMELEON_CFGENA := $D0FE
+
+CHAMELEON_ENABLE_REGS = $2A
+CHAMELEON_DISABLE_REGS = $FF
+
+CHAMELEON_CFGTUR_LIMIT_1MHZ = %00001100
+CHAMELEON_CFGTUR_LIMIT_NONE = %10000000
+
+
+; ---------------------------------------------------------------------------
+; C65/C64DX in C64 mode
+
+C65_VICIII_KEY := $D02F
+C65_VICIII_CTRL_B := $D031
+
+C65_VICIII_UNLOCK_1 = $A5
+C65_VICIII_UNLOCK_2 = $96
+
+
+; ---------------------------------------------------------------------------
+; C64 Turbo Master cartridge
+
+TURBOMASTER_DETECT := $BF53
+
+TURBOMASTER_SPEED_REG := $00
+
+
+;-----------------------------------------------------------------------------
+; Zero page
+
+WNDLFT := $20 ; Text window left
+WNDWDTH := $21 ; Text window width
+WNDTOP := $22 ; Text window top
+WNDBTM := $23 ; Text window bottom+1
+CH := $24 ; Cursor horizontal position
+CV := $25 ; Cursor vertical position
+BASL := $28 ; Text base address low
+BASH := $29 ; Text base address high
+INVFLG := $32 ; Normal/inverse(/flash)
+PROMPT := $33 ; Used by GETLN
+RNDL := $4E ; Random counter low
+RNDH := $4F ; Random counter high
+HIMEM := $73 ; Highest available memory address+1
+CURLIN := $75 ; Current line number being executed
+
+;-----------------------------------------------------------------------------
+; Vectors
+
+DOSWARM := $03D0 ; DOS warmstart vector
+BRKVec := $03F0 ; Break vector
+SOFTEV := $03F2 ; Vector for warm start
+PWREDUP := $03F4 ; This must be = EOR #$A5 of SOFTEV+1
+
+;-----------------------------------------------------------------------------
+; Hardware
+
+; Keyboard input
+KBD := $C000 ; Read keyboard
+KBDSTRB := $C010 ; Clear keyboard strobe
+
+; 80 column video
+CLR80COL:= $C000 ; Disable 80 column store
+SET80COL:= $C001 ; Enable 80 column store
+RD80COL := $C018 ; >127 if 80 column store enabled
+RD80VID := $C01F ; >127 if 80 column video enabled
+
+; Character set
+CLRALTCHAR := $C00E ; Normal Apple II char set
+SETALTCHAR := $C00F ; Norm/inv LC, no flash
+ALTCHARSET := $C01E ; >127 if alt charset switched in
+
+; Language card
+RDLCBNK2:= $C011 ; >127 if LC bank 2 in use
+RDLCRAM := $C012 ; >127 if LC is read enabled
+ROMIN := $C081 ; Swap in D000-FFFF ROM
+LCBANK2 := $C083 ; Swap in LC bank 2
+LCBANK1 := $C08B ; Swap in LC bank 1
+
+; Vertical blanking
+RDVBLBAR := $C019 ; >127 if not vertical blanking
+RDVBLMSK := $C041 ; >127 if VBL interrupts enabled
+DISVBL := $C05A ; Disable VBL interrupts
+ENVBL := $C05B ; Enable VBL interrupts
+
+; Video mode
+TXTCLR := $C050 ; Display graphics
+TXTSET := $C051 ; Display text
+MIXCLR := $C052 ; Disable 4 lines of text
+MIXSET := $C053 ; Enable 4 lines of text
+LOWSCR := $C054 ; Page 1
+HISCR := $C055 ; Page 2
+LORES := $C056 ; Lores graphics
+HIRES := $C057 ; Hires graphics
+DHIRESON := $C05E ; Enable double-width graphics
+DHIRESOFF := $C05F ; Disable double-width graphics
+
+; Game controller
+TAPEIN := $C060 ; Read casette input / Switch input 3
+BUTN0 := $C061 ; Switch input 0 / Open-Apple key
+BUTN1 := $C062 ; Switch input 1 / Closed-Apple key
+BUTN2 := $C063 ; Switch input 2 / Shift key
+PADDL0 := $C064 ; Analog input 0
+PADDL1 := $C065 ; Analog input 1
+PADDL2 := $C066 ; Analog input 2
+PADDL3 := $C067 ; Analog input 3
+PTRIG := $C070 ; Analog input reset
+
+; Input/Output Unit
+IOUDISON := $C07E ; Disable IOU
+IOUDISOFF := $C07F ; Enable IOU
+
+; Control Your Apple
+CYAREG := $C036 ; Bits 0-3=disk detect 4=shadow all banks 7=fast
+; Convert characters to screen codes
+
+; Helper macro that converts and outputs one character
+.macro _scrcode char
+ .if (char < 256)
+ .byte (char + 128)
+ .else
+ .error "scrcode: Character constant out of range"
+ .endif
+.endmacro
+
+.macro scrcode arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
+
+ ; Bail out if next argument is empty
+ .if .blank (arg1)
+ .exitmacro
+ .endif
+
+ ; Check for a string
+ .if .match ({arg1}, "")
+
+ ; Walk over all string chars
+ .repeat .strlen (arg1), i
+ _scrcode {.strat (arg1, i)}
+ .endrepeat
+
+ ; Check for a number
+ .elseif .match (.left (1, {arg1}), 0)
+
+ ; Just output the number
+ _scrcode arg1
+
+ ; Check for a character
+ .elseif .match (.left (1, {arg1}), 'a')
+
+ ; Just output the character
+ _scrcode arg1
+
+ ; Anything else is an error
+ .else
+
+ .error "scrcode: invalid argument type"
+
+ .endif
+
+ ; Call the macro recursively with the remaining args
+ scrcode arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
+.endmacro
+;/*****************************************************************************/
+;/* */
+;/* ascii_charmap.inc */
+;/* */
+;/* No translations, encodings are stored as they were typed in the host. */
+;/* */
+;/* */
+;/* 2019-09-07, Greg King */
+;/* */
+;/* This software is provided "as-is", without any expressed or implied */
+;/* warranty. In no event will the authors be held liable for any damages */
+;/* arising from the use of this software. */
+;/* */
+;/* Permission is granted to anyone to use this software for any purpose, */
+;/* including commercial applications, and to alter it and redistribute it */
+;/* freely, subject to the following restrictions: */
+;/* */
+;/* 1. The origin of this software must not be misrepresented; you must not */
+;/* claim that you wrote the original software. If you use this software */
+;/* in a product, an acknowledgment in the product documentation would be */
+;/* appreciated, but is not required. */
+;/* 2. Altered source versions must be plainly marked as such, and must not */
+;/* be misrepresented as being the original software. */
+;/* 3. This notice must not be removed or altered from any source */
+;/* distribution. */
+;/* */
+;/*****************************************************************************/
+
+;/* ASCII */
+.charmap $00, $00
+.charmap $01, $01
+.charmap $02, $02
+.charmap $03, $03
+.charmap $04, $04
+.charmap $05, $05
+.charmap $06, $06
+.charmap $07, $07
+.charmap $08, $08
+.charmap $09, $09
+.charmap $0A, $0A
+.charmap $0B, $0B
+.charmap $0C, $0C
+.charmap $0D, $0D
+.charmap $0E, $0E
+.charmap $0F, $0F
+.charmap $10, $10
+.charmap $11, $11
+.charmap $12, $12
+.charmap $13, $13
+.charmap $14, $14
+.charmap $15, $15
+.charmap $16, $16
+.charmap $17, $17
+.charmap $18, $18
+.charmap $19, $19
+.charmap $1A, $1A
+.charmap $1B, $1B
+.charmap $1C, $1C
+.charmap $1D, $1D
+.charmap $1E, $1E
+.charmap $1F, $1F
+.charmap $20, $20
+.charmap $21, $21
+.charmap $22, $22
+.charmap $23, $23
+.charmap $24, $24
+.charmap $25, $25
+.charmap $26, $26
+.charmap $27, $27
+.charmap $28, $28
+.charmap $29, $29
+.charmap $2A, $2A
+.charmap $2B, $2B
+.charmap $2C, $2C
+.charmap $2D, $2D
+.charmap $2E, $2E
+.charmap $2F, $2F
+.charmap $30, $30
+.charmap $31, $31
+.charmap $32, $32
+.charmap $33, $33
+.charmap $34, $34
+.charmap $35, $35
+.charmap $36, $36
+.charmap $37, $37
+.charmap $38, $38
+.charmap $39, $39
+.charmap $3A, $3A
+.charmap $3B, $3B
+.charmap $3C, $3C
+.charmap $3D, $3D
+.charmap $3E, $3E
+.charmap $3F, $3F
+.charmap $40, $40
+.charmap $41, $41
+.charmap $42, $42
+.charmap $43, $43
+.charmap $44, $44
+.charmap $45, $45
+.charmap $46, $46
+.charmap $47, $47
+.charmap $48, $48
+.charmap $49, $49
+.charmap $4A, $4A
+.charmap $4B, $4B
+.charmap $4C, $4C
+.charmap $4D, $4D
+.charmap $4E, $4E
+.charmap $4F, $4F
+.charmap $50, $50
+.charmap $51, $51
+.charmap $52, $52
+.charmap $53, $53
+.charmap $54, $54
+.charmap $55, $55
+.charmap $56, $56
+.charmap $57, $57
+.charmap $58, $58
+.charmap $59, $59
+.charmap $5A, $5A
+.charmap $5B, $5B
+.charmap $5C, $5C
+.charmap $5D, $5D
+.charmap $5E, $5E
+.charmap $5F, $5F
+.charmap $60, $60
+.charmap $61, $61
+.charmap $62, $62
+.charmap $63, $63
+.charmap $64, $64
+.charmap $65, $65
+.charmap $66, $66
+.charmap $67, $67
+.charmap $68, $68
+.charmap $69, $69
+.charmap $6A, $6A
+.charmap $6B, $6B
+.charmap $6C, $6C
+.charmap $6D, $6D
+.charmap $6E, $6E
+.charmap $6F, $6F
+.charmap $70, $70
+.charmap $71, $71
+.charmap $72, $72
+.charmap $73, $73
+.charmap $74, $74
+.charmap $75, $75
+.charmap $76, $76
+.charmap $77, $77
+.charmap $78, $78
+.charmap $79, $79
+.charmap $7A, $7A
+.charmap $7B, $7B
+.charmap $7C, $7C
+.charmap $7D, $7D
+.charmap $7E, $7E
+.charmap $7F, $7F
+
+;/* beyond ASCII */
+.charmap $80, $80
+.charmap $81, $81
+.charmap $82, $82
+.charmap $83, $83
+.charmap $84, $84
+.charmap $85, $85
+.charmap $86, $86
+.charmap $87, $87
+.charmap $88, $88
+.charmap $89, $89
+.charmap $8A, $8A
+.charmap $8B, $8B
+.charmap $8C, $8C
+.charmap $8D, $8D
+.charmap $8E, $8E
+.charmap $8F, $8F
+.charmap $90, $90
+.charmap $91, $91
+.charmap $92, $92
+.charmap $93, $93
+.charmap $94, $94
+.charmap $95, $95
+.charmap $96, $96
+.charmap $97, $97
+.charmap $98, $98
+.charmap $99, $99
+.charmap $9A, $9A
+.charmap $9B, $9B
+.charmap $9C, $9C
+.charmap $9D, $9D
+.charmap $9E, $9E
+.charmap $9F, $9F
+.charmap $A0, $A0
+.charmap $A1, $A1
+.charmap $A2, $A2
+.charmap $A3, $A3
+.charmap $A4, $A4
+.charmap $A5, $A5
+.charmap $A6, $A6
+.charmap $A7, $A7
+.charmap $A8, $A8
+.charmap $A9, $A9
+.charmap $AA, $AA
+.charmap $AB, $AB
+.charmap $AC, $AC
+.charmap $AD, $AD
+.charmap $AE, $AE
+.charmap $AF, $AF
+.charmap $B0, $B0
+.charmap $B1, $B1
+.charmap $B2, $B2
+.charmap $B3, $B3
+.charmap $B4, $B4
+.charmap $B5, $B5
+.charmap $B6, $B6
+.charmap $B7, $B7
+.charmap $B8, $B8
+.charmap $B9, $B9
+.charmap $BA, $BA
+.charmap $BB, $BB
+.charmap $BC, $BC
+.charmap $BD, $BD
+.charmap $BE, $BE
+.charmap $BF, $BF
+.charmap $C0, $C0
+.charmap $C1, $C1
+.charmap $C2, $C2
+.charmap $C3, $C3
+.charmap $C4, $C4
+.charmap $C5, $C5
+.charmap $C6, $C6
+.charmap $C7, $C7
+.charmap $C8, $C8
+.charmap $C9, $C9
+.charmap $CA, $CA
+.charmap $CB, $CB
+.charmap $CC, $CC
+.charmap $CD, $CD
+.charmap $CE, $CE
+.charmap $CF, $CF
+.charmap $D0, $D0
+.charmap $D1, $D1
+.charmap $D2, $D2
+.charmap $D3, $D3
+.charmap $D4, $D4
+.charmap $D5, $D5
+.charmap $D6, $D6
+.charmap $D7, $D7
+.charmap $D8, $D8
+.charmap $D9, $D9
+.charmap $DA, $DA
+.charmap $DB, $DB
+.charmap $DC, $DC
+.charmap $DD, $DD
+.charmap $DE, $DE
+.charmap $DF, $DF
+.charmap $E0, $E0
+.charmap $E1, $E1
+.charmap $E2, $E2
+.charmap $E3, $E3
+.charmap $E4, $E4
+.charmap $E5, $E5
+.charmap $E6, $E6
+.charmap $E7, $E7
+.charmap $E8, $E8
+.charmap $E9, $E9
+.charmap $EA, $EA
+.charmap $EB, $EB
+.charmap $EC, $EC
+.charmap $ED, $ED
+.charmap $EE, $EE
+.charmap $EF, $EF
+.charmap $F0, $F0
+.charmap $F1, $F1
+.charmap $F2, $F2
+.charmap $F3, $F3
+.charmap $F4, $F4
+.charmap $F5, $F5
+.charmap $F6, $F6
+.charmap $F7, $F7
+.charmap $F8, $F8
+.charmap $F9, $F9
+.charmap $FA, $FA
+.charmap $FB, $FB
+.charmap $FC, $FC
+.charmap $FD, $FD
+.charmap $FE, $FE
+.charmap $FF, $FF
+;-------------------------------------------------------------------------
+; Atari System Equates
+; by Freddy Offenga, Christian Groessler, and Christian Krueger
+;
+; References:
+; - Atari 400/800 OS rev.B source code, Atari 1979
+; - Atari OS manual - XL addendum
+; - Atari XL/XE rev.2 source code, Atari 1984
+; - Mapping the Atari - revised edition, Ian Chadwick 1985
+; - SpartaDOS-X User Guide (Aug-8-2016)
+;
+; ##old## old OS rev.B label - moved or deleted
+; ##1200xl## new label introduced in 1200XL OS (rev.10/11)
+; ##rev2## new label introduced in XL/XE OS rev.2
+;-------------------------------------------------------------------------
+
+;-------------------------------------------------------------------------
+; Configuration Equates
+;-------------------------------------------------------------------------
+
+MAXDEV = 33 ;offset to last possible entry of HATABS
+IOCBSZ = 16 ;length of IOCB
+
+SEIOCB = 0*IOCBSZ ;##rev2## screen editor IOCB index
+MAXIOC = 8*IOCBSZ ;first invalid IOCB index
+
+DSCTSZ = 128 ;##rev2## disk sector size
+
+LEDGE = 2 ;left edge
+REDGE = 39 ;right edge
+
+INIML = $0700 ;##rev2## initial MEMLO
+
+ICSORG = $CC00 ;##rev2## international character set origin
+DCSORG = $E000 ;##rev2## domestic character set origin
+
+; IOCB Command Code Equates
+
+OPEN = $03 ;open
+GETREC = $05 ;get record
+GETCHR = $07 ;get character(s)
+PUTREC = $09 ;put record
+PUTCHR = $0B ;put character(s)
+CLOSE = $0C ;close
+STATIS = $0D ;status
+SPECIL = $0E ;special
+
+; DOS IOCB command codes
+
+RENAME = $20 ;rename disk file
+DELETE = $21 ;delete disk file
+LOCKFL = $23 ;lock file (set to read-only)
+UNLOCK = $24 ;unlock file
+POINT = $25 ;point sector
+NOTE = $26 ;note sector
+GETFL = $27 ;get file length
+CHDIR_MYDOS = $29 ;change directory (MyDOS)
+MKDIR = $2A ;make directory (MyDOS/SpartaDOS)
+RMDIR = $2B ;remove directory (SpartaDOS)
+CHDIR_SPDOS = $2C ;change directory (SpartaDOS)
+FORMAT = $FE ;format
+
+GETCWD = $30 ;get current directory (MyDOS/SpartaDOS)
+
+; Special Entry Command Equates
+; DOS Commands
+; Command line table, Index values for (DOSVEC),Y -- COMTAB
+; Compatible with OS/A+, DOS XL and SpartaDOS
+
+COMTAB = 0 ;DOS entry jump vector
+ZCRNAME = 3 ;file name crunch routine jump vector
+BUFOFF = 10 ;next parameter buffer offset
+COMFNAM = 33 ;destination buffer for crunch routine
+LBUF = 63 ;command line input buffer
+
+; Screen IOCB Commands
+
+DRAWLN = $11 ;draw line
+FILLIN = $12 ;draw line with right fill
+
+; ICAX1 Auxiliary Byte 1 Equates
+
+APPEND = $01 ;open write append (D:)
+DIRECT = $02 ;open for directory access (D:)
+OPNIN = $04 ;open for input (all devices)
+OPNOT = $08 ;open for output (all devices)
+MXDMOD = $10 ;open for mixed mode (E:, S:)
+INSCLR = $20 ;open for input without clearing screen
+
+; Device Code Equates
+
+CASSET = 'C' ;cassette
+DISK = 'D' ;disk
+SCREDT = 'E' ;screen editor
+KBD = 'K' ;keyboard
+PRINTR = 'P' ;printer
+DISPLY = 'S' ;screen display
+
+; SIO Command Code Equates
+
+SIO_FORMAT = $21 ;format disk (default density)
+SIO_FORMATS = $22 ;1050: format medium density
+SIO_CONFIG = $44 ;configure drive
+SIO_CONFIGSF = $4B ;slow/fast configure drive??
+SIO_RDPERCOM = $4E ;read PERCOM block (XF551)
+SIO_WRPERCOM = $4F ;write PERCOM block (XF551)
+SIO_WRITE = $50 ;write sector
+SIO_READ = $52 ;read sector
+SIO_STAT = $53 ;get status information
+SIO_VERIFY = $56 ;verify sector
+SIO_WRITEV = $57 ;write sector with verify
+SIO_WRITETRK = $60 ;write track (Speedy)
+SIO_READTRK = $62 ;read track (Speedy)
+
+; SIO Status Code (DSTATS)
+; Input: data direction
+; Bit #7 - W (write operation)
+; #6 - R (read operation)
+; Output: status code
+; $01 (001) -- OPERATION COMPLETE (NO ERRORS)
+; $8A (138) -- DEVICE TIMEOUT (DOESN'T RESPOND)
+; $8B (139) -- DEVICE NAK
+; $8C (140) -- SERIAL BUS INPUT FRAMING ERROR
+; $8E (142) -- SERIAL BUS DATA FRAME OVERRUN ERROR
+; $8F (143) -- SERIAL BUS DATA FRAME CHECKSUM ERROR
+; $90 (144) -- DEVICE DONE ERROR
+
+; Character and Key Code Equates
+
+CLS = $7D ;##rev2## clear screen
+EOL = $9B ;end of line (RETURN)
+
+HELP = $11 ;##1200xl## key code for HELP
+CNTLF1 = $83 ;##1200xl## key code for CTRL-F1
+CNTLF2 = $84 ;##1200xl## key code for CTRL-F2
+CNTLF3 = $93 ;##1200xl## key code for CTRL-F3
+CNTLF4 = $94 ;##1200xl## key code for CTRL-F4
+CNTL1 = $9F ;##1200xl## key code for CTRL-1
+
+; Status Code Equates
+
+SUCCES = 1 ;($01) succesful operation
+
+BRKABT = 128 ;($80) BREAK key abort
+PRVOPN = 129 ;($81) IOCB already open error
+NONDEV = 130 ;($82) nonexistent device error
+WRONLY = 131 ;($83) IOCB opened for write only error
+NVALID = 132 ;($84) invalid command error
+NOTOPN = 133 ;($85) device/file not open error
+BADIOC = 134 ;($86) invalid IOCB index error
+RDONLY = 135 ;($87) IOCB opened for read only error
+EOFERR = 136 ;($88) end of file error
+TRNRCD = 137 ;($89) truncated record error
+TIMOUT = 138 ;($8A) peripheral device timeout error
+DNACK = 139 ;($8B) device does not acknowledge command
+FRMERR = 140 ;($8C) serial bus framing error
+CRSROR = 141 ;($8D) cursor overrange error
+OVRRUN = 142 ;($8E) serial bus data overrun error
+CHKERR = 143 ;($8F) serial bus checksum error
+DERROR = 144 ;($90) device done (operation incomplete)
+BADMOD = 145 ;($91) bad screen mode number error
+FNCNOT = 146 ;($92) function not implemented in handler
+SCRMEM = 147 ;($93) insufficient memory for screen mode
+
+DSKFMT = 148 ;($94) SpartaDOS: unrecognized disk format
+INCVER = 149 ;($95) SpartaDOS: disk was made with incompat. version
+DIRNFD = 150 ;($96) SpartaDOS: directory not found
+FEXIST = 151 ;($97) SpartaDOS: file exists
+NOTBIN = 152 ;($98) SpartaDOS: file not binary
+LSYMND = 154 ;($9A) SDX: loader symbol not defined
+BADPRM = 156 ;($9C) SDX: bad parameter
+OUTOFM = 158 ;($9E) SDX: out of memory
+INVDEV = 160 ;($A0) invalid device number
+TMOF = 161 ;($A1) too many open files
+DSKFLL = 162 ;($A2) disk full
+FATLIO = 163 ;($A3) fatal I/O error
+FNMSMT = 164 ;($A4) internal file number mismatch
+INVFNM = 165 ;($A5) invalid file name
+PDLERR = 166 ;($A6) point data length error
+EPERM = 167 ;($A7) permission denied
+DINVCM = 168 ;($A8) command invalid for disk
+DIRFLL = 169 ;($A9) directory full
+FNTFND = 170 ;($AA) file not found
+PNTINV = 171 ;($AB) point invalid
+BADDSK = 173 ;($AD) bad disk
+INCFMT = 176 ;($B0) DOS 3: incompatible file system
+XNTBIN = 180 ;($B4) XDOS: file not binary
+
+; DCB Device Bus Equates
+
+DISKID = $31 ;##rev2## disk bus ID
+PDEVN = $40 ;##rev2## printer bus ID
+CASET = $60 ;##rev2## cassette bus ID
+
+; Bus Command Equates
+
+FOMAT = '!' ;##rev2## format command
+PUTSEC = 'P' ;##rev2## put sector command
+READ = 'R' ;##rev2## read command
+STATC = 'S' ;##rev2## status command
+WRITE = 'W' ;##rev2## write command
+
+; Command Auxiliary Byte Equates
+
+DOUBLE = 'D' ;##rev2## print 20 characters double width
+NORMAL = 'N' ;##rev2## print 40 characters normally
+PLOT = 'P' ;##rev2## plot
+SIDWAY = 'S' ;##rev2## print 16 characters sideways
+
+; Bus Response Equates
+
+ACK = 'A' ;##rev2## device acknowledged
+COMPLT = 'C' ;##rev2## device succesfully completed operation
+ERROR = 'E' ;##rev2## device incurred error
+NACK = 'N' ;##rev2## device did not understand
+
+; Floating Point Miscellaneous Equates
+
+FPREC = 6 ;precision
+
+FMPREC = FPREC-1 ;##rev2## length of mantissa
+
+; Cassette Record Type Equates
+
+HDR = $FB ;##rev2## header
+DTA = $FC ;##rev2## data record
+DT1 = $FA ;##rev2## last data record
+EOT = $FE ;##rev2## end of tape (file)
+
+TONE1 = 2 ;##rev2## record
+TONE2 = 1 ;##rev2## playback
+
+; Cassette Timing Equates
+
+WLEADN = 1152 ;##rev2## NTSC 19.2 second WRITE file leader
+RLEADN = 576 ;##rev2## NTSC 9.6 second READ file leader
+WIRGLN = 180 ;##rev2## NTSC 3.0 second WRITE IRG
+RIRGLN = 120 ;##rev2## NTSC 2.0 second READ IRG
+WSIRGN = 15 ;##rev2## NTSC 0.25 second WRITE short IRG
+RSIRGN = 10 ;##rev2## NTSC 0.16 second READ short IRG
+BEEPNN = 30 ;##rev2## NTSC 0.5 second beep duration
+BEEPFN = 10 ;##rev2## NTSC 0.16 seconrd beep duration
+
+WLEADP = 960 ;##rev2## PAL 19.2 second WRITE file leader
+RLEADP = 480 ;##rev2## PAL 9.6 second READ file leader
+WIRGLP = 150 ;##rev2## PAL 3.0 second WRITE IRG
+RIRGLP = 100 ;##rev2## PAL 2.0 second READ IRG
+WSIRGP = 13 ;##rev2## PAL 0.25 second WRITE short IRG
+RSIRGP = 8 ;##rev2## PAL 0.16 second READ short IRG
+BEEPNP = 25 ;##rev2## PAL 0.5 second beep duration
+BEEPFP = 8 ;##rev2## PAL 0.16 seconrd beep duration
+
+WIRGHI = 0 ;##rev2## high WRITE IRG
+RIRGHI = 0 ;##rev2## high READ IRG
+
+; Power-up Validation Byte Value Equates
+
+PUPVL1 = $5C ;##rev2## power-up validation value 1
+PUPVL2 = $93 ;##rev2## power-up validation value 2
+PUPVL3 = $25 ;##rev2## power-up validation value 3
+
+; Relocating Loader Miscellaneous Equates
+
+DATAER = 156 ;##rev2## end of record appears before END
+MEMERR = 157 ;##rev2## memory insufficient for load error
+
+; Miscellaneous Equates
+
+IOCFRE = $FF ;IOCB free indication
+
+B19200 = $0028 ;##rev2## 19200 baud POKEY counter value
+B00600 = $05CC ;##rev2## 600 baud POKEY counter value
+
+HITONE = $05 ;##rev2## FSK high freq. POKEY counter value
+LOTONE = $07 ;##rev2## FSK low freq. POKEY counter value
+
+NCOMLO = $34 ;##rev2## PIA lower NOT COMMAND line command
+NCOMHI = $3C ;##rev2## PIA raise NOT COMMAND line command
+
+MOTRGO = $34 ;##rev2## PIA cassette motor ON command
+MOTRST = $3C ;##rev2## PIA cassette motor OFF command
+
+NODAT = $00 ;##rev2## SIO immediate operation
+GETDAT = $40 ;##rev2## SIO read data frame
+PUTDAT = $80 ;##rev2## SIO write data frame
+
+CRETRI = 13 ;##rev2## number of command frame retries
+DRETRI = 1 ;##rev2## number of device retries
+CTIM = 2 ;##rev2## command frame ACK timeout
+
+NBUFSZ = 40 ;##rev2## print normal buffer size
+DBUFSZ = 20 ;##rev2## print double buffer size
+SBUFSZ = 29 ;##rev2## print sideways buffer size
+
+;-------------------------------------------------------------------------
+; Page Zero Address Equates
+;-------------------------------------------------------------------------
+
+LINZBS = $00 ;LINBUG RAM (WILL BE REPLACED BY MONITOR RAM)
+LNFLG = $00 ;##1200xl## 1-byte LNBUG flag (0 = not LNBUG)
+NGFLAG = $01 ;##1200xl## 1-byte memory status (0 = failure)
+
+; Not Cleared
+
+CASINI = $02 ;CASSETTE INIT LOCATION
+RAMLO = $04 ;RAM POINTER FOR MEMORY TEST
+TRAMSZ = $06 ;TEMPORARY REGISTER FOR RAM SIZE
+;TSTDAT = $07 ;##old## RAM TEST DATA REGISTER
+CMCMD = $07 ;##rev2## 1-byte command communications
+
+; Cleared upon Coldstart only
+
+WARMST = $08 ;WARM START FLAG
+BOOTQ = $09 ;SUCCESSFUL BOOT FLAG
+DOSVEC = $0A ;DISK SOFTWARE START VECTOR
+DOSINI = $0C ;DISK SOFTWARE INIT ADDRESS
+APPMHI = $0E ;APPLICATIONS MEMORY HI LIMIT
+
+; Cleared upon Coldstart or Warmstart
+
+INTZBS = $10 ;INTERRUPT HANDLER
+
+POKMSK = $10 ;SYSTEM MASK FOR POKEY IRQ ENABLE (shadow of IRQEN)
+BRKKEY = $11 ;BREAK KEY FLAG
+RTCLOK = $12 ;REAL TIME CLOCK (IN 16 MSEC UNITS>
+BUFADR = $15 ;INDIRECT BUFFER ADDRESS REGISTER
+ICCOMT = $17 ;COMMAND FOR VECTOR
+DSKFMS = $18 ;DISK FILE MANAGER POINTER
+DSKUTL = $1A ;DISK UTILITIES POINTER
+ABUFPT = $1C ;##1200xl## 4-byte ACMI buffer pointer area
+
+;PTIMOT = $1C ;##old## PRINTER TIME OUT REGISTER
+;PBPNT = $1D ;##old## PRINT BUFFER POINTER
+;PBUFSZ = $1E ;##old## PRINT BUFFER SIZE
+;PTEMP = $1F ;##old## TEMPORARY REGISTER
+
+ZIOCB = $20 ;ZERO PAGE I/O CONTROL BLOCK
+IOCBAS = $20 ;16-byte page zero IOCB
+ICHIDZ = $20 ;HANDLER INDEX NUMBER (FF = IOCB FREE)
+ICDNOZ = $21 ;DEVICE NUMBER (DRIVE NUMBER)
+ICCOMZ = $22 ;COMMAND CODE
+ICSTAZ = $23 ;STATUS OF LAST IOCB ACTION
+ICBALZ = $24 ;BUFFER ADDRESS LOW BYTE
+ICBAHZ = $25 ;1-byte high buffer address
+ICPTLZ = $26 ;PUT BYTE ROUTINE ADDRESS -1
+ICPTHZ = $27 ;1-byte high PUT-BYTE routine address
+ICBLLZ = $28 ;BUFFER LENGTH LOW BYTE
+ICBLHZ = $29 ;1-byte high buffer length
+ICAX1Z = $2A ;AUXILIARY INFORMATION FIRST BYTE
+ICAX2Z = $2B ;1-byte second auxiliary information
+ICSPRZ = $2C ;4-byte spares
+
+ENTVEC = $2C ;##rev2## 2-byte (not used)
+ICIDNO = $2E ;IOCB NUMBER X 16
+CIOCHR = $2F ;CHARACTER BYTE FOR CURRENT OPERATION
+
+STATUS = $30 ;INTERNAL STATUS STORAGE
+CHKSUM = $31 ;CHECKSUM (SINGLE BYTE SUM WITH CARRY)
+BUFRLO = $32 ;POINTER TO DATA BUFFER (LO BYTE)
+BUFRHI = $33 ;POINTER TO DATA BUFFER (HI BYTE)
+BFENLO = $34 ;NEXT BYTE PAST END OF THE DATA BUFFER LO
+BFENHI = $35 ;NEXT BYTE PAST END OF THE DATA BUFFER HI
+;CRETRY = $36 ;##old## NUMBER OF COMMAND FRAME RETRIES
+;DRETRY = $37 ;##old## NUMBER OF DEVICE RETRIES
+LTEMP = $36 ;##1200xl## 2-byte loader temporary
+BUFRFL = $38 ;DATA BUFFER FULL FLAG
+RECVDN = $39 ;RECEIVE DONE FLAG
+XMTDON = $3A ;TRANSMISSION DONE FLAG
+CHKSNT = $3B ;CHECKSUM SENT FLAG
+NOCKSM = $3C ;NO CHECKSUM FOLLOWS DATA FLAG
+BPTR = $3D ;1-byte cassette buffer pointer
+FTYPE = $3E ;1-byte cassette IRG type
+FEOF = $3F ;1-byte cassette EOF flag (0 = quiet)
+FREQ = $40 ;1-byte cassette beep counter
+SOUNDR = $41 ;NOISY I/0 FLAG. (ZERO IS QUIET)
+
+CRITIC = $42 ;DEFINES CRITICAL SECTION (CRITICAL IF NON-Z)
+
+FMSZPG = $43 ;DISK FILE MANAGER SYSTEM ZERO PAGE
+
+;CKEY = $4A ;##old## FLAG SET WHEN GAME START PRESSED
+ZCHAIN = $4A ;##1200xl## 2-byte handler linkage chain pointer
+;CASSBT = $4B ;##old## CASSETTE BOOT FLAG
+DSTAT = $4C ;DISPLAY STATUS
+ATRACT = $4D ;ATRACT FLAG
+DRKMSK = $4E ;DARK ATRACT MASK
+COLRSH = $4F ;ATRACT COLOR SHIFTER (EOR'ED WITH PLAYFIELD
+
+
+TMPCHR = $50 ;1-byte temporary character
+HOLD1 = $51 ;1-byte temporary
+LMARGN = $52 ;left margin (normally 2, cc65 C startup code sets it to 0)
+RMARGN = $53 ;right margin (normally 39 if no XEP80 is used)
+ROWCRS = $54 ;1-byte cursor row
+COLCRS = $55 ;2-byte cursor column
+DINDEX = $57 ;1-byte display mode
+SAVMSC = $58 ;2-byte saved memory scan counter
+OLDROW = $5A ;1-byte prior row
+OLDCOL = $5B ;2-byte prior column
+OLDCHR = $5D ;DATA UNDER CURSOR
+OLDADR = $5E ;2-byte saved cursor memory address
+FKDEF = $60 ;##1200xl## 2-byte function key definition table
+;NEWROW = $60 ;##old## POINT DRAW GOES TO
+;NEWCOL = $61 ;##old##
+PALNTS = $62 ;##1200xl## 1-byte PAL/NTSC indicator (0 = NTSC)
+LOGCOL = $63 ;POINTS AT COLUMN IN LOGICAL LINE
+ADRESS = $64 ;2-byte temporary address
+
+MLTTMP = $66 ;1-byte temporary
+OPNTMP = $66 ;FIRST BYTE IS USED IN OPEN AS TEMP
+TOADR = $66 ;##rev2## 2-byte destination address
+
+SAVADR = $68 ;2-byte saved address
+FRMADR = $68 ;##rev2## 2-byte source address
+
+RAMTOP = $6A ;RAM SIZE DEFINED BY POWER ON LOGIC
+BUFCNT = $6B ;BUFFER COUNT
+BUFSTR = $6C ;EDITOR GETCH POINTER
+BITMSK = $6E ;BIT MASK
+SHFAMT = $6F ;1-byte shift amount for pixel justifucation
+ROWAC = $70 ;2-byte draw working row
+COLAC = $72 ;2-byte draw working column
+ENDPT = $74 ;2-byte end point
+DELTAR = $76 ;1-byte row difference
+DELTAC = $77 ;2-byte column difference
+KEYDEF = $79 ;##1200xl## 2-byte key definition table address
+;ROWINC = $79 ;##old##
+;COLINC = $7A ;##old##
+SWPFLG = $7B ;NON-0 1F TXT AND REGULAR RAM IS SWAPPED
+HOLDCH = $7C ;CH IS MOVED HERE IN KGETCH BEFORE CNTL & SH
+INSDAT = $7D ;1-byte temporary
+COUNTR = $7E ;2-byte draw iteration count
+
+; Floating Point Package Page Zero Address Equates
+
+FR0 = $D4 ;6-byte register 0
+FR0M = $D5 ;##rev2## 5-byte register 0 mantissa
+QTEMP = $D9 ;##rev2## 1-byte temporary
+
+FRE = $DA ;6-byte (internal) register E
+
+FR1 = $E0 ;FP REG1
+FR1M = $E1 ;##rev2## 5-byte register 1 mantissa
+
+FR2 = $E6 ;6-byte (internal) register 2
+
+FRX = $EC ;1-byte temporary
+
+EEXP = $ED ;VALUE OF E
+
+FRSIGN = $EE ;##rev2## 1-byte floating point sign
+NSIGN = $EE ;SIGN OF #
+
+PLYCNT = $EF ;##rev2## 1-byte polynomial degree
+ESIGN = $EF ;SIGN OF EXPONENT
+
+SGNFLG = $F0 ;##rev2## 1-byte sign flag
+FCHRFLG = $F0 ;1ST CHAR FLAG
+
+XFMFLG = $F1 ;##rev2## 1-byte transform flag
+DIGRT = $F1 ;# OF DIGITS RIGHT OF DECIMAL
+
+CIX = $F2 ;CURRENT INPUT INDEX
+INBUFF = $F3 ;POINTS TO USER'S LINE INPUT BUFFER
+
+ZTEMP1 = $F5 ;2-byte temporary
+ZTEMP4 = $F7 ;2-byte temporary
+ZTEMP3 = $F9 ;2-byte temporary
+
+;DEGFLG = $FB ;##old## same as RADFLG
+;RADFLG = $FB ;##old## 0=RADIANS, 6=DEGREES
+
+FLPTR = $FC ;2-byte floating point number pointer
+FPTR2 = $FE ;2-byte floating point number pointer
+
+;-------------------------------------------------------------------------
+; Page Two Address Equates
+;-------------------------------------------------------------------------
+
+INTABS = $0200 ;INTERRUPT RAM
+
+VDSLST = $0200 ;DISPLAY LIST NMI VECTOR
+VPRCED = $0202 ;PROCEED LINE IRQ VECTOR
+VINTER = $0204 ;INTERRUPT LINE IRQ VECTOR
+VBREAK = $0206 ;SOFTWARE BREAK (00) INSTRUCTION IRQ VECTOR
+VKEYBD = $0208 ;POKEY KEYBOARD IRQ VECTOR
+VSERIN = $020A ;POKEY SERIAL INPUT READY IRQ
+VSEROR = $020C ;POKEY SERIAL OUTPUT READY IRQ
+VSEROC = $020E ;POKEY SERIAL OUTPUT COMPLETE IRQ
+VTIMR1 = $0210 ;POKEY TIMER 1 IRQ
+VTIMR2 = $0212 ;POKEY TIMER 2 IRQ
+VTIMR4 = $0214 ;POKEY TIMER 4 IRQ
+VIMIRQ = $0216 ;IMMEDIATE IRQ VECTOR
+CDTMV1 = $0218 ;COUNT DOWN TIMER 1
+CDTMV2 = $021A ;COUNT DOWN TIMER 2
+CDTMV3 = $021C ;COUNT DOWN TIMER 3
+CDTMV4 = $021E ;COUNT DOWN TIMER 4
+CDTMV5 = $0220 ;COUNT DOWN TIMER 5
+VVBLKI = $0222 ;IMMEDIATE VERTICAL BLANK NMI VECTOR
+VVBLKD = $0224 ;DEFERRED VERTICAL BLANK NMI VECTOR
+CDTMA1 = $0226 ;COUNT DOWN TIMER 1 JSR ADDRESS
+CDTMA2 = $0228 ;COUNT DOWN TIMER 2 JSR ADDRESS
+CDTMF3 = $022A ;COUNT DOWN TIMER 3 FLAG
+SRTIMR = $022B ;SOFTWARE REPEAT TIMER
+CDTMF4 = $022C ;COUNT DOWN TIMER 4 FLAG
+INTEMP = $022D ;IAN'S TEMP
+CDTMF5 = $022E ;COUNT DOWN TIMER FLAG 5
+SDMCTL = $022F ;SAVE DMACTL REGISTER
+SDLSTL = $0230 ;SAVE DISPLAY LIST LOW BYTE
+SDLSTH = $0231 ;SAVE DISPLAY LIST HI BYTE
+SSKCTL = $0232 ;SKCTL REGISTER RAM
+LCOUNT = $0233 ;##1200xl## 1-byte relocating loader record
+LPENH = $0234 ;LIGHT PEN HORIZONTAL VALUE
+LPENV = $0235 ;LIGHT PEN VERTICAL VALUE
+BRKKY = $0236 ;BREAK KEY VECTOR
+;RELADR = $0238 ;##1200xl## 2-byte relocatable loader address
+VPIRQ = $0238 ;##rev2## 2-byte parallel device IRQ vector
+CDEVIC = $023A ;COMMAND FRAME BUFFER - DEVICE
+CCOMND = $023B ;COMMAND
+CAUX1 = $023C ;COMMAND AUX BYTE 1
+CAUX2 = $023D ;COMMAND AUX BYTE 2
+
+TEMP = $023E ;TEMPORARY RAM CELL
+
+ERRFLG = $023F ;ERROR FLAG - ANY DEVICE ERROR EXCEPT TIME OUT
+
+DFLAGS = $0240 ;DISK FLAGS FROM SECTOR ONE
+DBSECT = $0241 ;NUMBER OF DISK BOOT SECTORS
+BOOTAD = $0242 ;ADDRESS WHERE DISK BOOT LOADER WILL BE PUT
+COLDST = $0244 ;COLDSTART FLAG (1=IN MIDDLE OF COLDSTART>
+RECLEN = $0245 ;##1200xl## 1-byte relocating loader record length
+DSKTIM = $0246 ;DISK TIME OUT REGISTER
+;LINBUF = $0247 ;##old## CHAR LINE BUFFER
+PDVMSK = $0247 ;##rev2## 1-byte parallel device selection mask
+SHPDVS = $0248 ;##rev2## 1-byte PDVS (parallel device select)
+PDIMSK = $0249 ;##rev2## 1-byte parallel device IRQ selection
+RELADR = $024A ;##rev2## 2-byte relocating loader relative adr.
+PPTMPA = $024C ;##rev2## 1-byte parallel device handler temporary
+PPTMPX = $024D ;##rev2## 1-byte parallel device handler temporary
+
+CHSALT = $026B ;##1200xl## 1-byte character set alternate
+VSFLAG = $026C ;##1200xl## 1-byte fine vertical scroll count
+KEYDIS = $026D ;##1200xl## 1-byte keyboard disable
+FINE = $026E ;##1200xl## 1-byte fine scrolling mode
+GPRIOR = $026F ;GLOBAL PRIORITY CELL
+
+PADDL0 = $0270 ;1-byte potentiometer 0
+PADDL1 = $0271 ;1-byte potentiometer 1
+PADDL2 = $0272 ;1-byte potentiometer 2
+PADDL3 = $0273 ;1-byte potentiometer 3
+PADDL4 = $0274 ;1-byte potentiometer 4
+PADDL5 = $0275 ;1-byte potentiometer 5
+PADDL6 = $0276 ;1-byte potentiometer 6
+PADDL7 = $0277 ;1-byte potentiometer 7
+
+STICK0 = $0278 ;1-byte joystick 0
+STICK1 = $0279 ;1-byte joystick 1
+STICK2 = $027A ;1-byte joystick 2
+STICK3 = $027B ;1-byte joystick 3
+
+PTRIG0 = $027C ;1-byte paddle trigger 0
+PTRIG1 = $027D ;1-byte paddle trigger 1
+PTRIG2 = $027E ;1-byte paddle trigger 2
+PTRIG3 = $027F ;1-byte paddle trigger 3
+PTRIG4 = $0280 ;1-byte paddle trigger 4
+PTRIG5 = $0281 ;1-byte paddle trigger 5
+PTRIG6 = $0281 ;1-byte paddle trigger 6
+PTRIG7 = $0283 ;1-byte paddle trigger 7
+
+STRIG0 = $0284 ;1-byte joystick trigger 0
+STRIG1 = $0285 ;1-byte joystick trigger 1
+STRIG2 = $0286 ;1-byte joystick trigger 2
+STRIG3 = $0287 ;1-byte joystick trigger 3
+
+;CSTAT = $0288 ;##old## cassette status register
+HIBYTE = $0288 ;##1200xl## 1-byte relocating loader high byte
+WMODE = $0289 ;1-byte cassette WRITE mode
+BLIM = $028A ;1-byte cassette buffer limit
+IMASK = $028B ;##rev2## (not used)
+JVECK = $028C ;2-byte jump vector or temporary
+NEWADR = $028E ;##1200xl## 2-byte relocating address
+TXTROW = $0290 ;TEXT ROWCRS
+TXTCOL = $0291 ;TEXT COLCRS
+TINDEX = $0293 ;TEXT INDEX
+TXTMSC = $0294 ;FOOLS CONVRT INTO NEW MSC
+TXTOLD = $0296 ;OLDROW & OLDCOL FOR TEXT (AND THEN SOME)
+;TMPX1 = $029C ;##old## 1-byte temporary register
+CRETRY = $029C ;##1200xl## 1-byte number of command frame retries
+HOLD3 = $029D ;1-byte temporary
+SUBTMP = $029E ;1-byte temporary
+HOLD2 = $029F ;1-byte (not used)
+DMASK = $02A0 ;1-byte display (pixel location) mask
+TMPLBT = $02A1 ;1-byte (not used)
+ESCFLG = $02A2 ;ESCAPE FLAG
+TABMAP = $02A3 ;15-byte (120 bit) tab stop bit map
+LOGMAP = $02B2 ;LOGICAL LINE START BIT MAP
+INVFLG = $02B6 ;INVERSE VIDEO FLAG (TOGGLED BY ATARI KEY)
+FILFLG = $02B7 ;RIGHT FILL FLAG FOR DRAW
+TMPROW = $02B8 ;1-byte temporary row
+TMPCOL = $02B9 ;2-byte temporary column
+SCRFLG = $02BB ;SET IF SCROLL OCCURS
+HOLD4 = $02BC ;TEMP CELL USED IN DRAW ONLY
+;HOLD5 = $02BD ;##old## DITTO
+DRETRY = $02BD ;##1200xl## 1-byte number of device retries
+SHFLOK = $02BE ;1-byte shift/control lock flags
+BOTSCR = $02BF ;BOTTOM OF SCREEN 24 NORM 4 SPLIT
+
+PCOLR0 = $02C0 ;1-byte player-missile 0 color/luminance
+PCOLR1 = $02C1 ;1-byte player-missile 1 color/luminance
+PCOLR2 = $02C2 ;1-byte player-missile 2 color/luminance
+PCOLR3 = $02C3 ;1-byte player-missile 3 color/luminance
+
+COLOR0 = $02C4 ;1-byte playfield 0 color/luminance
+COLOR1 = $02C5 ;1-byte playfield 1 color/luminance
+COLOR2 = $02C6 ;1-byte playfield 2 color/luminance
+COLOR3 = $02C7 ;1-byte playfield 3 color/luminance
+
+COLOR4 = $02C8 ;1-byte background color/luminance
+
+PARMBL = $02C9 ;##rev2## 6-byte relocating loader parameter
+RUNADR = $02C9 ;##1200xl## 2-byte run address
+HIUSED = $02CB ;##1200xl## 2-byte highest non-zero page address
+ZHIUSE = $02CD ;##1200xl## 2-byte highest zero page address
+
+OLDPAR = $02CF ;##rev2## 6-byte relocating loader parameter
+GBYTEA = $02CF ;##1200xl## 2-byte GET-BYTE routine address
+LOADAD = $02D1 ;##1200xl## 2-byte non-zero page load address
+ZLOADA = $02D3 ;##1200xl## 2-byte zero page load address
+
+DSCTLN = $02D5 ;##1200xl## 2-byte disk sector length
+ACMISR = $02D7 ;##1200xl## 2-byte ACMI interrupt service routine
+KRPDEL = $02D9 ;##1200xl## 1-byte auto-repeat delay
+KEYREP = $02DA ;##1200xl## 1-byte auto-repeat rate
+NOCLIK = $02DB ;##1200xl## 1-byte key click disable
+HELPFG = $02DC ;##1200xl## 1-byte HELP key flag (0 = no HELP)
+DMASAV = $02DD ;##1200xl## 1-byte SDMCTL save/restore
+PBPNT = $02DE ;##1200xl## 1-byte printer buffer pointer
+PBUFSZ = $02DF ;##1200xl## 1-byte printer buffer size
+
+GLBABS = $02E0 ;4-byte global variables for non-DOS users
+RUNAD = $02E0 ;##map## 2-byte binary file run address
+INITAD = $02E2 ;##map## 2-byte binary file initialization address
+
+RAMSIZ = $02E4 ;RAM SIZE (HI BYTE ONLY)
+MEMTOP = $02E5 ;TOP OF AVAILABLE USER MEMORY
+MEMLO = $02E7 ;BOTTOM OF AVAILABLE USER MEMORY
+HNDLOD = $02E9 ;##1200xl## 1-byte user load flag
+DVSTAT = $02EA ;STATUS BUFFER
+CBAUDL = $02EE ;1-byte low cassette baud rate
+CBAUDH = $02EF ;1-byte high cassette baud rate
+CRSINH = $02F0 ;CURSOR INHIBIT (00 = CURSOR ON)
+KEYDEL = $02F1 ;KEY DELAY
+CH1 = $02F2 ;1-byte prior keyboard character
+CHACT = $02F3 ;CHACTL REGISTER RAM
+CHBAS = $02F4 ;CHBAS REGISTER RAM
+
+NEWROW = $02F5 ;##1200xl## 1-byte draw destination row
+NEWCOL = $02F6 ;##1200xl## 2-byte draw destination column
+ROWINC = $02F8 ;##1200xl## 1-byte draw row increment
+COLINC = $02F9 ;##1200xl## 1-byte draw column increment
+
+CHAR = $02FA ;1-byte internal character
+ATACHR = $02FB ;ATASCII CHARACTER
+CH = $02FC ;GLOBAL VARIABLE FOR KEYBOARD
+FILDAT = $02FD ;RIGHT FILL DATA
+DSPFLG = $02FE ;DISPLAY FLAG DISPLAY CNTLS IF NON-ZERO
+SSFLAG = $02FF ;START/STOP FLAG FOR PAGING (CNTL 1). CLEARE
+
+;-------------------------------------------------------------------------
+; Page Three Address Equates
+;-------------------------------------------------------------------------
+
+DCB = $0300 ;DEVICE CONTROL BLOCK
+DDEVIC = $0300 ;PERIPHERAL UNIT 1 BUS I.D. NUMBER
+DUNIT = $0301 ;UNIT NUMBER
+DCOMND = $0302 ;BUS COMMAND
+DSTATS = $0303 ;COMMAND TYPE/STATUS RETURN
+DBUFLO = $0304 ;1-byte low data buffer address
+DBUFHI = $0305 ;1-byte high data buffer address
+DTIMLO = $0306 ;DEVICE TIME OUT IN 1 SECOND UNITS
+DUNUSE = $0307 ;UNUSED BYTE
+DBYTLO = $0308 ;1-byte low number of bytes to transfer
+DBYTHI = $0309 ;1-byte high number of bytes to transfer
+DAUX1 = $030A ;1-byte first command auxiliary
+DAUX2 = $030B ;1-byte second command auxiliary
+
+TIMER1 = $030C ;INITIAL TIMER VALUE
+;ADDCOR = $030E ;##old## ADDITION CORRECTION
+JMPERS = $030E ;##1200xl## 1-byte jumper options
+CASFLG = $030F ;CASSETTE MODE WHEN SET
+TIMER2 = $0310 ;2-byte final baud rate timer value
+TEMP1 = $0312 ;TEMPORARY STORAGE REGISTER
+;TEMP2 = $0314 ;##old## TEMPORARY STORAGE REGISTER
+TEMP2 = $0313 ;##1200xl## 1-byte temporary
+PTIMOT = $0314 ;##1200xl## 1-byte printer timeout
+TEMP3 = $0315 ;TEMPORARY STORAGE REGISTER
+SAVIO = $0316 ;SAVE SERIAL IN DATA PORT
+TIMFLG = $0317 ;TIME OUT FLAG FOR BAUD RATE CORRECTION
+STACKP = $0318 ;SIO STACK POINTER SAVE CELL
+TSTAT = $0319 ;TEMPORARY STATUS HOLDER
+
+HATABS = $031A ;35-byte handler address table (was 38 bytes)
+PUPBT1 = $033D ;##1200xl## 1-byte power-up validation byte 1
+PUPBT2 = $033E ;##1200xl## 1-byte power-up validation byte 2
+PUPBT3 = $033F ;##1200xl## 1-byte power-up validation byte 3
+
+IOCB = $0340 ;I/O CONTROL BLOCKS
+ICHID = $0340 ;HANDLER INDEX NUMBER (FF=IOCB FREE)
+ICDNO = $0341 ;DEVICE NUMBER (DRIVE NUMBER)
+ICCOM = $0342 ;COMMAND CODE
+ICSTA = $0343 ;STATUS OF LAST IOCB ACTION
+ICBAL = $0344 ;1-byte low buffer address
+ICBAH = $0345 ;1-byte high buffer address
+ICPTL = $0346 ;1-byte low PUT-BYTE routine address - 1
+ICPTH = $0347 ;1-byte high PUT-BYTE routine address - 1
+ICBLL = $0348 ;1-byte low buffer length
+ICBLH = $0349 ;1-byte high buffer length
+ICAX1 = $034A ;1-byte first auxiliary information
+ICAX2 = $034B ;1-byte second auxiliary information
+ICAX3 = $034C ;1-byte third auxiliary information
+ICAX4 = $034D ;1-byte fourth auxiliary information
+ICAX5 = $034E ;1-byte fifth auxiliary information
+ICSPR = $034F ;SPARE BYTE
+
+PRNBUF = $03C0 ;PRINTER BUFFER
+SUPERF = $03E8 ;##1200xl## 1-byte editor super function flag
+CKEY = $03E9 ;##1200xl## 1-byte cassette boot request flag
+CASSBT = $03EA ;##1200xl## 1-byte cassette boot flag
+CARTCK = $03EB ;##1200xl## 1-byte cartridge equivalence check
+DERRF = $03EC ;##rev2## 1-byte screen OPEN error flag
+
+; Remainder of Page Three Not Cleared upon Reset
+
+ACMVAR = $03ED ;##1200xl## 11 bytes reserved for ACMI
+BASICF = $03F8 ;##rev2## 1-byte BASIC switch flag
+MINTLK = $03F9 ;##1200xl## 1-byte ACMI module interlock
+GINTLK = $03FA ;##1200xl## 1-byte cartridge interlock
+CHLINK = $03FB ;##1200xl## 2-byte loaded handler chain link
+CASBUF = $03FD ;CASSETTE BUFFER
+
+;-------------------------------------------------------------------------
+; Page Four/Five Address Equates
+;-------------------------------------------------------------------------
+
+; USER AREA STARTS HERE AND GOES TO END OF PAGE FIVE
+USAREA = $0480 ;128 bytes reserved for application
+
+LBPR1 = $057E ;LBUFF PREFIX 1
+LBPR2 = $057F ;LBUFF PREFIX 2
+LBUFF = $0580 ;128-byte line buffer
+
+PLYARG = $05E0 ;6-byte floating point polynomial argument
+FPSCR = $05E6 ;6-byte floating point temporary
+FPSCR1 = $05EC ;6-byte floating point temporary
+
+;LBFEND = $05FF ;##old## END OF LBUFF
+
+
+DOS = $0700
+
+;-------------------------------------------------------------------------
+; SpartaDOS-X Definitions
+;-------------------------------------------------------------------------
+
+SDX_FLAG = DOS ; 'S' for SpartaDOS
+SDX_VERSION = $0701 ; SD version (e.g. $32 = 3.2, $40 = 4.0)
+ ; address $0702 contains sub-version, e.g.
+ ; 8 in case of SDX 4.48
+SDX_KERNEL = $0703 ; SDX kernel entry point
+SDX_BLOCK_IO = $0706 ; block I/O entry point
+SDX_MISC = $0709 ; "misc" entry point
+SDX_DEVICE = $0761
+SDX_DATE = $077B ; day, month, year (3 bytes)
+SDX_TIME = $077E ; hour, min, sec (3 bytes)
+SDX_DATESET = $0781
+SDX_PATH = $07A0 ; 64 bytes
+SDX_IFSYMBOL = $07EB ; only valid on SDX 4.40 or newer
+SDX_S_LOOKUP = SDX_IFSYMBOL ; alternative name for SDX_IFSYMBOL
+
+; values for SDX_DEVICE
+
+SDX_CLK_DEV = $10 ; clock device
+
+; clock device functions
+
+SDX_KD_GETTD = 100 ; get time and date
+SDX_KD_SETTD = 101 ; set time and date
+
+;-------------------------------------------------------------------------
+; Cartridge Address Equates
+;-------------------------------------------------------------------------
+
+CARTCS = $BFFA ;##rev2## 2-byte cartridge coldstart address
+CART = $BFFC ;##rev2## 1-byte cartridge present indicator
+ ;0=Cart Exists
+CARTFG = $BFFD ;##rev2## 1-byte cartridge flags
+ ;D7 0=Not a Diagnostic Cart
+ ; 1=Is a Diagnostic cart and control is
+ ; given to cart before any OS is init.
+ ;D2 0=Init but Do not Start Cart
+ ; 1=Init and Start Cart
+ ;D0 0=Do not boot disk
+ ; 1=Boot Disk
+CARTAD = $BFFE ;##rev2## 2-byte cartridge start vector
+
+;-------------------------------------------------------------------------
+; CTIA/GTIA Address Equates
+;-------------------------------------------------------------------------
+
+GTIA = $D000 ;CTIA/GTIA area
+.include "atari_gtia.inc"
+
+;-------------------------------------------------------------------------
+; PBI Address Equates
+;-------------------------------------------------------------------------
+
+PBI = $D100 ;##rev2## parallel bus interface area
+
+; Read Addresses
+
+PDVI = $D1FF ;##rev2## parallel device IRQ status
+
+; Write Addresses
+
+PDVS = $D1FF ;##rev2## parallel device select
+
+;-------------------------------------------------------------------------
+; POKEY Address Equates
+;-------------------------------------------------------------------------
+
+POKEY = $D200 ;POKEY area
+.include "atari_pokey.inc"
+
+; POKEY KBCODE Values
+
+KEY_NONE = $FF
+
+KEY_0 = $32
+KEY_1 = $1F
+KEY_2 = $1E
+KEY_3 = $1A
+KEY_4 = $18
+KEY_5 = $1D
+KEY_6 = $1B
+KEY_7 = $33
+KEY_8 = $35
+KEY_9 = $30
+
+KEY_A = $3F
+KEY_B = $15
+KEY_C = $12
+KEY_D = $3A
+KEY_E = $2A
+KEY_F = $38
+KEY_G = $3D
+KEY_H = $39
+KEY_I = $0D
+KEY_J = $01
+KEY_K = $05
+KEY_L = $00
+KEY_M = $25
+KEY_N = $23
+KEY_O = $08
+KEY_P = $0A
+KEY_Q = $2F
+KEY_R = $28
+KEY_S = $3E
+KEY_T = $2D
+KEY_U = $0B
+KEY_V = $10
+KEY_W = $2E
+KEY_X = $16
+KEY_Y = $2B
+KEY_Z = $17
+
+KEY_COMMA = $20
+KEY_PERIOD = $22
+KEY_SLASH = $26
+KEY_SEMICOLON = $02
+KEY_PLUS = $06
+KEY_ASTERISK = $07
+KEY_DASH = $0E
+KEY_EQUALS = $0F
+KEY_LESSTHAN = $36
+KEY_GREATERTHAN = $37
+
+KEY_ESC = $1C
+KEY_TAB = $2C
+KEY_SPACE = $21
+KEY_RETURN = $0C
+KEY_DELETE = $34
+KEY_CAPS = $3C
+KEY_INVERSE = $27
+KEY_HELP = $11
+
+KEY_F1 = $03
+KEY_F2 = $04
+KEY_F3 = $13
+KEY_F4 = $14
+
+KEY_SHIFT = $40
+KEY_CTRL = $80
+
+; Composed keys
+
+KEY_EXCLAMATIONMARK = KEY_1 | KEY_SHIFT
+KEY_QUOTE = KEY_2 | KEY_SHIFT
+KEY_HASH = KEY_3 | KEY_SHIFT
+KEY_DOLLAR = KEY_4 | KEY_SHIFT
+KEY_PERCENT = KEY_5 | KEY_SHIFT
+KEY_AMPERSAND = KEY_6 | KEY_SHIFT
+KEY_APOSTROPHE = KEY_7 | KEY_SHIFT
+KEY_AT = KEY_8 | KEY_SHIFT
+KEY_OPENINGPARAN = KEY_9 | KEY_SHIFT
+KEY_CLOSINGPARAN = KEY_0 | KEY_SHIFT
+KEY_UNDERLINE = KEY_DASH | KEY_SHIFT
+KEY_BAR = KEY_EQUALS | KEY_SHIFT
+KEY_COLON = KEY_SEMICOLON | KEY_SHIFT
+KEY_BACKSLASH = KEY_PLUS | KEY_SHIFT
+KEY_CIRCUMFLEX = KEY_ASTERISK | KEY_SHIFT
+KEY_OPENINGBRACKET = KEY_COMMA | KEY_SHIFT
+KEY_CLOSINGBRACKET = KEY_PERIOD | KEY_SHIFT
+KEY_QUESTIONMARK = KEY_SLASH | KEY_SHIFT
+KEY_CLEAR = KEY_LESSTHAN | KEY_SHIFT
+KEY_INSERT = KEY_GREATERTHAN | KEY_SHIFT
+
+KEY_UP = KEY_DASH | KEY_CTRL
+KEY_DOWN = KEY_EQUALS | KEY_CTRL
+KEY_LEFT = KEY_PLUS | KEY_CTRL
+KEY_RIGHT = KEY_ASTERISK | KEY_CTRL
+
+;-------------------------------------------------------------------------
+; ANTIC Address Equates
+;-------------------------------------------------------------------------
+
+ANTIC = $D400 ;ANTIC area
+.include "atari_antic.inc"
+
+; PBI RAM Address Equates
+
+PBIRAM = $D600 ;##rev2## parallel bus interface RAM area
+
+; Parallel Device Address Equates
+
+PDID1 = $D803 ;##rev2## parallel device ID 1
+PDIDV = $D805 ;##rev2## parallel device I/O vector
+PDIRQV = $D808 ;##rev2## parallel device IRQ vector
+PDID2 = $D80B ;##rev2## parallel device ID 2
+PDVV = $D80D ;##rev2## parallel device vector table
+
+;-------------------------------------------------------------------------
+; PIA Address Equates
+;-------------------------------------------------------------------------
+
+PIA = $D300 ;PIA area
+
+PORTA = $D300 ;port A direction register or jacks one/two
+PORTB = $D301 ;port B direction register or memory management
+
+PACTL = $D302 ;port A control
+PBCTL = $D303 ;port B control
+
+;-------------------------------------------------------------------------
+; Floating Point Package Address Equates
+;-------------------------------------------------------------------------
+
+AFP = $D800 ;convert ASCII to floating point
+FASC = $D8E6 ;convert floating point to ASCII
+IFP = $D9AA ;convert integer to floating point
+FPI = $D9D2 ;convert floating point to integer
+ZFR0 = $DA44 ;zero FR0
+ZF1 = $DA46 ;zero floating point number
+FSUB = $DA60 ;subtract floating point numbers
+FADD = $DA66 ;add floating point numbers
+FMUL = $DADB ;multiply floating point numbers
+FDIV = $DB28 ;divide floating point numbers
+PLYEVL = $DD40 ;evaluate floating point polynomial
+FLD0R = $DD89 ;load floating point number
+FLD0P = $DD8D ;load floating point number
+FLD1R = $DD98 ;load floating point number
+PLD1P = $DD9C ;load floating point number
+FST0R = $DDA7 ;store floating point number
+FST0P = $DDAB ;store floating point number
+FMOVE = $DDB6 ;move floating point number
+LOG = $DECD ;calculate floating point logarithm
+LOG10 = $DED1 ;calculate floating point base 10 logarithm
+EXP = $DDC0 ;calculate floating point exponential
+EXP10 = $DDCC ;calculate floating point base 10 exponential
+
+;-------------------------------------------------------------------------
+; Device Handler Vector Table Address Equates
+;-------------------------------------------------------------------------
+
+EDITRV = $E400 ;editor handler vector table
+SCRENV = $E410 ;screen handler vector table
+KEYBDV = $E420 ;keyboard handler vector table
+PRINTV = $E430 ;printer handler vector table
+CASETV = $E440 ;cassette handler vector table
+
+;-------------------------------------------------------------------------
+; Jump Vector Address Equates
+;-------------------------------------------------------------------------
+
+DISKIV = $E450 ;vector to initialize DIO
+DSKINV = $E453 ;vector to DIO
+.ifdef __ATARIXL__
+.ifndef SHRAM_HANDLERS
+.import CIO_handler, SIO_handler, SETVBV_handler
+.endif
+.define CIOV CIO_handler
+.define SIOV SIO_handler
+.define SETVBV SETVBV_handler
+CIOV_org = $E456 ;vector to CIO
+SIOV_org = $E459 ;vector to SIO
+SETVBV_org = $E45C ;vector to set VBLANK parameters
+.else
+CIOV = $E456 ;vector to CIO
+SIOV = $E459 ;vector to SIO
+SETVBV = $E45C ;vector to set VBLANK parameters
+; aliases in order not to have to sprinkle common code with .ifdefs
+CIOV_org = CIOV
+SIOV_org = SIOV
+SETVBV_org = SETVBV
+.endif
+SYSVBV = $E45F ;vector to process immediate VBLANK
+XITVBV = $E462 ;vector to process deferred VBLANK
+SIOINV = $E465 ;vector to initialize SIO
+SENDEV = $E468 ;vector to enable SEND
+INTINV = $E46B ;vector to initialize interrupt handler
+CIOINV = $E46E ;vector to initialize CIO
+BLKBDV = $E471 ;vector to power-up display
+WARMSV = $E474 ;vector to warmstart
+COLDSV = $E477 ;vector to coldstart
+RBLOKV = $E47A ;vector to read cassette block
+CSOPIV = $E47D ;vector to open cassette for input
+VCTABL = $E480 ;RAM vector initial value table
+PUPDIV = $E480 ;##rev2## vector to power-up display
+SLFTSV = $E483 ;##rev2## vector to self-test
+PHENTV = $E486 ;##rev2## vector to enter peripheral handler
+PHUNLV = $E489 ;##rev2## vector to unlink peripheral handler
+PHINIV = $E48C ;##rev2## vector to initialize peripheral handler
+GPDVV = $E48F ;##rev2## generic parallel device handler vector
+
+; NOTE: OS rom self-test labels are not included in this file
+
+;-------------------------------------------------------------------------
+; Some misc. stuff from the 400/800 rev.B source
+;-------------------------------------------------------------------------
+
+; THE FOLLOWING ARE IN BASIC CARTRIDGE:
+SIN = $BD81 ;FR0 <- SIN (FR0) DEGFLG (0=RAD,6=DEG) CARRY
+COS = $BD73 ;FR0 <- COS (FR0) CARRY
+ATAN = $BE43 ;FR0 <- ATAN(FR0) CARRY
+SQR = $BEB1 ;FR0 <- ROOT(FR0) CARRY
+
+RADON = 0 ;INDICATES RADIANS
+DEGON = 6 ;INDICATES DEGREES
+
+ASCZER = '0' ;ASCII ZERO
+COLON = $3A ;ASCII COLON
+CR = $9B ;SYSTEM EOL (CARRIAGE RETURN)
+
+;-------------------------------------------------------------------------
+; 6502
+;-------------------------------------------------------------------------
+
+NMIVEC = $FFFA
+RESVEC = $FFFC
+IRQVEC = $FFFE
+
+;-------------------------------------------------------------------------
+; BASIC
+;-------------------------------------------------------------------------
+
+LOMEM = $80 ;2-byte low memory pointer
+VNTP = $82 ;2-byte variable name table address
+VNTD = $84 ;2-byte variable name table end + 1
+VVTP = $86 ;2-byte variable value table
+STMTAB = $88 ;2-byte statement table address
+STMCUR = $8A ;2-byte current statement pointer
+STARP = $8C ;2-byte string and array table pointer
+RUNSTK = $8E ;2-byte runtime stack address
+BMEMTOP = $90 ;2-byte top of memory pointer
+STOPLN = $BA ;2-byte stopped line number
+ERRSAVE = $C3 ;1-byte error code
+PTABW = $C9 ;1-byte tab width
+
+;-------------------------------------------------------------------------
+; ATASCII CHARACTER DEFS
+;-------------------------------------------------------------------------
+
+ATCLR = $7D ;CLEAR SCREEN CHARACTER
+ATRUB = $7E ;BACK SPACE (RUBOUT)
+ATTAB = $7F ;TAB
+ATEOL = $9B ;END-OF-LINE
+ATDELL = $9C ;delete line
+ATINSL = $9D ;insert line
+ATCTAB = $9E ;clear TAB
+ATSTAB = $9F ;set TAB
+ATBEL = $FD ;CONSOLE BELL
+ATDEL = $FE ;delete char.
+ATINS = $FF ;insert char.
+ATURW = $1C ;UP-ARROW
+ATDRW = $1D ;DOWN-ARROW
+ATLRW = $1E ;LEFT-ARROW
+ATRRW = $1F ;RIGHT-ARROW
+ATESC = $1B ;ESCAPE
+
+;-------------------------------------------------------------------------
+; OFFSETS INTO SECTSIZETAB (DIO functions)
+;-------------------------------------------------------------------------
+
+sst_flag = 0 ; length 1
+sst_sectsize = 1 ; 2
+sst_driveno = 3 ; 1 (drive #)
+sst_size = 4 ; size of one entry
+ ; if changed, adapt diopncls.s
+
+;-------------------------------------------------------------------------
+; OFFSETS INTO dio_phys_pos
+;-------------------------------------------------------------------------
+
+diopp_head = 0 ; head
+diopp_track = 1 ; track / cylinder
+diopp_sector = 3 ; sector
+diopp_size = 5 ; size of structure
+
+;-------------------------------------------------------------------------
+; VALUES for dos_type
+;-------------------------------------------------------------------------
+
+SPARTADOS = 0
+REALDOS = 1
+BWDOS = 2
+OSADOS = 3 ; OS/A+
+XDOS = 4
+ATARIDOS = 5
+MYDOS = 6
+NODOS = 255
+; The DOSes with dos_type below or equal MAX_DOS_WITH_CMDLINE do support
+; command line arguments.
+MAX_DOS_WITH_CMDLINE = XDOS
+
+;-------------------------------------------------------------------------
+; XDOS defines (version 2.4, taken from xdos24.pdf)
+;-------------------------------------------------------------------------
+
+XOPT = $070B ; XDOS options
+XCAR = $070C ; XDOS cartridge address (+ $70D)
+XPAT = $086F ; XDOS bugfix and patch number
+XVER = $0870 ; XDOS version number
+XFILE = $087D ; XDOS filename buffer
+XLINE = $0880 ; XDOS DUP input line
+XGLIN = $0871 ; get line
+XSKIP = $0874 ; skip parameter
+.ifdef __ATARIXL__
+.ifndef SHRAM_HANDLERS
+.import XMOVE_handler
+.endif
+.define XMOVE XMOVE_handler
+XMOVE_org = $0877 ; move filename
+.else
+XMOVE = $0877 ; move filename
+.endif
+XGNUM = $087A ; get number
+
+;-------------------------------------------------------------------------
+; End of atari.inc
+;-------------------------------------------------------------------------
+; Convert characters to screen codes
+
+; Helper macro that converts and outputs one character
+.macro _scrcode char
+ .if (char >= 0) .and (char <= 31)
+ .byte (char + 64)
+ .elseif (char >= 32) .and (char <= 95)
+ .byte (char - 32)
+ .elseif (char >= 96) .and (char <= 127)
+ .byte char
+ .elseif (char >= 128) .and (char <= 159)
+ .byte (char + 64)
+ .elseif (char >= 160) .and (char <= 223)
+ .byte (char - 32)
+ .elseif (char >= 224) .and (char <= 255)
+ .byte char
+ .else
+ .error "scrcode: Character constant out of range"
+ .endif
+.endmacro
+
+.macro scrcode arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
+
+ ; Bail out if next argument is empty
+ .if .blank (arg1)
+ .exitmacro
+ .endif
+
+ ; Check for a string
+ .if .match ({arg1}, "")
+
+ ; Walk over all string chars
+ .repeat .strlen (arg1), i
+ _scrcode {.strat (arg1, i)}
+ .endrepeat
+
+ ; Check for a number
+ .elseif .match (.left (1, {arg1}), 0)
+
+ ; Just output the number
+ _scrcode arg1
+
+ ; Check for a character
+ .elseif .match (.left (1, {arg1}), 'a')
+
+ ; Just output the character
+ _scrcode arg1
+
+ ; Anything else is an error
+ .else
+
+ .error "scrcode: invalid argument type"
+
+ .endif
+
+ ; Call the macro recursively with the remaining args
+ scrcode arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
+.endmacro
+
+; Atari 2600 TIA & RIOT read / write registers
+;
+; Florent Flament (contact@florentflament.com), 2017
+
+; TIA & RIOT registers mapping
+.include "atari2600_tia.inc"
+.include "atari2600_riot.inc"
+; Atari 2600 RIOT read / write registers
+;
+; Source: DASM - vcs.h
+; Details available in: Stella Programmer's Guide by Steve Wright
+;
+; Florent Flament (contact@florentflament.com), 2017
+
+; Read registers
+SWCHA := $0280
+SWACNT := $0281
+SWCHB := $0282
+SWBCNT := $0283
+INTIM := $0284
+TIMINT := $0285
+
+; Write registers
+TIM1T := $0294
+TIM8T := $0295
+TIM64T := $0296
+T1024T := $0297
+; Atari 2600 TIA read / write registers
+;
+; Source: DASM - vcs.h
+; Details available in: Stella Programmer's Guide by Steve Wright
+;
+; Florent Flament (contact@florentflament.com), 2017
+
+; Read registers
+VSYNC := $00
+VBLANK := $01
+WSYNC := $02
+RSYNC := $03
+NUSIZ0 := $04
+NUSIZ1 := $05
+COLUP0 := $06
+COLUP1 := $07
+COLUPF := $08
+COLUBK := $09
+CTRLPF := $0A
+REFP0 := $0B
+REFP1 := $0C
+PF0 := $0D
+PF1 := $0E
+PF2 := $0F
+RESP0 := $10
+RESP1 := $11
+RESM0 := $12
+RESM1 := $13
+RESBL := $14
+AUDC0 := $15
+AUDC1 := $16
+AUDF0 := $17
+AUDF1 := $18
+AUDV0 := $19
+AUDV1 := $1A
+GRP0 := $1B
+GRP1 := $1C
+ENAM0 := $1D
+ENAM1 := $1E
+ENABL := $1F
+HMP0 := $20
+HMP1 := $21
+HMM0 := $22
+HMM1 := $23
+HMBL := $24
+VDELP0 := $25
+VDELP1 := $26
+VDELBL := $27
+RESMP0 := $28
+RESMP1 := $29
+HMOVE := $2A
+HMCLR := $2B
+CXCLR := $2C
+
+; Write registers
+CXM0P := $00
+CXM1P := $01
+CXP0FB := $02
+CXP1FB := $03
+CXM0FB := $04
+CXM1FB := $05
+CXBLPF := $06
+CXPPMM := $07
+INPT0 := $08
+INPT1 := $09
+INPT2 := $0A
+INPT3 := $0B
+INPT4 := $0C
+INPT5 := $0D
+;-------------------------------------------------------------------------
+; Atari 5200 System Equates
+; by Christian Groessler
+; taken from EQUATES.INC from Atari Inc.
+;-------------------------------------------------------------------------
+
+;-------------------------------------------------------------------------
+; ATASCII CHARACTER DEFS
+;-------------------------------------------------------------------------
+
+ATEOL = $9B ; END-OF-LINE, used by CONIO
+
+;-------------------------------------------------------------------------
+; CONIO CHARACTER DEFS
+;-------------------------------------------------------------------------
+
+CH_ULCORNER = $0B ; '+' sign
+CH_URCORNER = $0B
+CH_LLCORNER = $0B
+CH_LRCORNER = $0B
+CH_HLINE = $0D ; dash
+CH_VLINE = $01 ; exclamation mark
+
+;-------------------------------------------------------------------------
+; Zero Page
+;-------------------------------------------------------------------------
+
+POKMSK = $00 ; Mask for Pokey IRQ enable
+RTCLOK = $01 ; 60 hz. clock
+JUMP = $01
+CRITIC = $03 ; Critical section
+ATRACT = $04 ; Attract Mode
+
+SDLSTL = $05 ; DLISTL Shadow
+SDLSTH = $06 ; DLISTH "
+SDMCTL = $07 ; DMACTL "
+
+PCOLR0 = $08 ; COLPM0 Shadow
+PCOLR1 = $09 ; COLPM1 "
+PCOLR2 = $0A ; COLPM2 "
+PCOLR3 = $0B ; COLPM3 "
+
+COLOR0 = $0C ; COLPF0 Shadow
+COLOR1 = $0D ; COLPF1 "
+COLOR2 = $0E ; COLPF2 "
+COLOR3 = $0F ; COLPF3 "
+COLOR4 = $10 ; COLBK "
+
+PADDL0 = $11 ; POT0 Shadow
+PADDL1 = $12 ; POT1 "
+PADDL2 = $13 ; POT2 "
+PADDL3 = $14 ; POT3 "
+PADDL4 = $15 ; POT4 "
+PADDL5 = $16 ; POT5 "
+PADDL6 = $17 ; POT6 "
+PADDL7 = $18 ; POT7 "
+
+; cc65 runtime zero page variables
+
+ROWCRS_5200 = $19
+COLCRS_5200 = $1A
+SAVMSC = $1B ; pointer to screen memory (conio)
+
+;-------------------------------------------------------------------------
+; Page #2
+;-------------------------------------------------------------------------
+
+;Interrupt Vectors
+
+VIMIRQ = $0200 ; Immediate IRQ
+ ; Preset $FC03 (SYSIRQ)
+VVBLKI = $0202 ; Vblank immediate
+ ; Preset $FCB8 (SYSVBL)
+VVBLKD = $0204 ; Vblank deferred
+ ; Preset $FCB2 (XITVBL)
+VDSLST = $0206 ; Display List
+ ; Preset $FEA1 (OSDLI)
+VKYBDI = $0208 ; Keyboard immediate
+ ; Preset $FD02 (SYSKBD)
+VKYBDF = $020A ; Deferred Keyboard
+ ; Preset $FCB2 (XITVBL)
+VTRIGR = $020C ; Soft Trigger
+VBRKOP = $020E ; BRK Opcode
+VSERIN = $0210 ; Serial in Ready
+VSEROR = $0212 ; Serial Out Ready
+VSEROC = $0214 ; Serial Output complete
+VTIMR1 = $0216 ; Pokey Timer 1
+VTIMR2 = $0218 ; Pokey Timer 2
+VTIMR4 = $021A ; Pokey Timer 4
+
+
+
+;-------------------------------------------------------------------------
+; CTIA/GTIA Address Equates
+;-------------------------------------------------------------------------
+
+GTIA = $C000 ; CTIA/GTIA area
+.include "atari_gtia.inc"
+
+;-------------------------------------------------------------------------
+; ANTIC Address Equates
+;-------------------------------------------------------------------------
+
+ANTIC = $D400 ; ANTIC area
+.include "atari_antic.inc"
+
+;-------------------------------------------------------------------------
+; POKEY Address Equates
+;-------------------------------------------------------------------------
+
+POKEY = $E800 ; POKEY area
+.include "atari_pokey.inc"
+
+;-------------------------------------------------------------------------
+; conio color defines
+;-------------------------------------------------------------------------
+
+COLOR_WHITE = 0
+COLOR_RED = 1
+COLOR_GREEN = 2
+COLOR_BLACK = 3
+
+;-------------------------------------------------------------------------
+; Cartridge Parameters
+;-------------------------------------------------------------------------
+
+CARTNM = $BFE8 ; Cartridge Name Area
+COPYD = $BFFC ; Copyright Decade in Cart
+COPYR = $BFFD ; Copyright Year in Cart
+ ; $FF=Diagnostic Cart
+GOCART = $BFFE ; Cartridge Start Vector
+
+CHRORG = $F800 ; Character Generator Base
+; Atari 7800 TIA & RIOT read / write registers
+;
+; Karri Kaksonen (karri@sipo.fi), 2022
+
+; TIA, RIOT & MARIA registers mapping
+.include "atari7800_tia.inc"
+.include "atari7800_riot.inc"
+.include "atari7800_maria.inc"
+
+; constants for the conio implementation
+mono_charsperline = 40
+charsperline = 20
+screenrows = 28
+
+; Atari 7800 MARIA read / write registers
+;
+
+; Read registers
+BKGRND := $20
+P0C1 := $21
+P0C2 := $22
+P0C3 := $23
+MWSYNC := $24
+P1C1 := $25
+P1C2 := $26
+P1C3 := $27
+MSTAT := $28
+P2C1 := $29
+P2C2 := $2A
+P2C3 := $2B
+DPPH := $2C
+P3C1 := $2D
+P3C2 := $2E
+P3C3 := $2F
+DPPL := $30
+P4C1 := $31
+P4C2 := $32
+P4C3 := $33
+CHBASE := $34
+P5C1 := $35
+P5C2 := $36
+P5C3 := $37
+OFFSET := $38
+P6C1 := $39
+P6C2 := $3A
+P6C3 := $3B
+CTRL := $3C
+P7C1 := $3D
+P7C2 := $3E
+P7C3 := $3F
+
+; Write registers
+
+; Atari 7800 RIOT read / write registers
+;
+; Source: DASM - vcs.h
+; Details available in: Stella Programmer's Guide by Steve Wright
+;
+; Florent Flament (contact@florentflament.com), 2017
+
+; Read registers
+SWCHA := $0280
+CTLSWA := $0281
+SWCHB := $0282
+CTLSWB := $0283
+INTIM := $0284
+TIMINT := $0285
+
+; Write registers
+TIM1T := $0294
+TIM8T := $0295
+TIM64T := $0296
+T1024T := $0297
+; Atari 7800 TIA read / write registers
+;
+; Source: DASM - vcs.h
+; Details available in: Stella Programmer's Guide by Steve Wright
+;
+; Florent Flament (contact@florentflament.com), 2017
+
+; Read registers
+VSYNC := $00
+VBLANK := $01
+WSYNC := $02
+RSYNC := $03
+NUSIZ0 := $04
+NUSIZ1 := $05
+COLUP0 := $06
+COLUP1 := $07
+COLUPF := $08
+COLUBK := $09
+CTRLPF := $0A
+REFP0 := $0B
+REFP1 := $0C
+PF0 := $0D
+PF1 := $0E
+PF2 := $0F
+RESP0 := $10
+RESP1 := $11
+RESM0 := $12
+RESM1 := $13
+RESBL := $14
+AUDC0 := $15
+AUDC1 := $16
+AUDF0 := $17
+AUDF1 := $18
+AUDV0 := $19
+AUDV1 := $1A
+GRP0 := $1B
+GRP1 := $1C
+ENAM0 := $1D
+ENAM1 := $1E
+ENABL := $1F
+HMP0 := $20
+HMP1 := $21
+HMM0 := $22
+HMM1 := $23
+HMBL := $24
+VDELP0 := $25
+VDELP1 := $26
+VDELBL := $27
+RESMP0 := $28
+RESMP1 := $29
+HMOVE := $2A
+HMCLR := $2B
+CXCLR := $2C
+
+; Write registers
+CXM0P := $00
+CXM1P := $01
+CXP0FB := $02
+CXP1FB := $03
+CXM0FB := $04
+CXM1FB := $05
+CXBLPF := $06
+CXPPMM := $07
+INPT0 := $08
+INPT1 := $09
+INPT2 := $0A
+INPT3 := $0B
+INPT4 := $0C
+INPT5 := $0D
+;-------------------------------------------------------------------------
+; ANTIC Address Equates
+;-------------------------------------------------------------------------
+
+; Read Addresses
+
+VCOUNT = ANTIC + $0B ;vertical line counter
+PENH = ANTIC + $0C ;light pen horizontal position
+PENV = ANTIC + $0D ;light pen vertical position
+NMIST = ANTIC + $0F ;NMI interrupt status
+
+; Write Addresses
+
+DMACTL = ANTIC + $00 ;DMA control
+CHACTL = ANTIC + $01 ;character control
+DLISTL = ANTIC + $02 ;low display list address
+DLISTH = ANTIC + $03 ;high display list address
+HSCROL = ANTIC + $04 ;horizontal scroll
+VSCROL = ANTIC + $05 ;vertical scroll
+PMBASE = ANTIC + $07 ;player-missile base address
+CHBASE = ANTIC + $09 ;character base address
+WSYNC = ANTIC + $0A ;wait for HBLANK synchronization
+NMIEN = ANTIC + $0E ;NMI enable
+NMIRES = ANTIC + $0F ;NMI interrupt reset
+
+
+;-------------------------------------------------------------------------
+; Antic opcodes
+;-------------------------------------------------------------------------
+
+; usage example:
+;
+; ScreenDL:
+; .byte DL_BLK8
+; .byte DL_BLK8
+; .byte DL_CHR40x8x1 | DL_LMS | DL_DLI
+; .word ScreenAlignment
+; .byte DL_BLK1 | DL_DLI
+; .byte DL_MAP320x1x1 | DL_LMS
+; .word Screen
+;
+; .repeat 99
+; .byte DL_MAP320x1x1
+; .endrepeat
+; .byte DL_MAP320x1x1 | DL_LMS
+; .word Screen + 40 * 100 ; 100 lines a 40 byte, 'Screen' has to be aligned correctly!
+; .repeat 92
+; .byte DL_MAP320x1x1
+; .endrepeat
+;
+; .byte DL_JVB
+
+; absolute instructions (non mode lines)
+
+DL_JMP = 1
+DL_JVB = 65
+
+; DL_BLKn display n empty lines (just background)
+
+DL_BLK1 = 0
+DL_BLK2 = 16
+DL_BLK3 = 32
+DL_BLK4 = 48
+DL_BLK5 = 64
+DL_BLK6 = 80
+DL_BLK7 = 96
+DL_BLK8 = 112
+
+; absolute instructions (mode lines)
+
+DL_CHR40x8x1 = 2 ; monochrome, 40 character & 8 scanlines per mode line (GR. 0)
+DL_CHR40x10x1 = 3 ; monochrome, 40 character & 10 scanlines per mode line
+DL_CHR40x8x4 = 4 ; colour, 40 character & 8 scanlines per mode line (GR. 12)
+DL_CHR40x16x4 = 5 ; colour, 40 character & 16 scanlines per mode line (GR. 13)
+DL_CHR20x8x2 = 6 ; colour (duochrome per character), 20 character & 8 scanlines per mode line (GR. 1)
+DL_CHR20x16x2 = 7 ; colour (duochrome per character), 20 character & 16 scanlines per mode line (GR. 2)
+
+DL_MAP40x8x4 = 8 ; colour, 40 pixel & 8 scanlines per mode line (GR. 3)
+DL_MAP80x4x2 = 9 ; 'duochrome', 80 pixel & 4 scanlines per mode line (GR.4)
+DL_MAP80x4x4 = 10 ; colour, 80 pixel & 4 scanlines per mode line (GR.5)
+DL_MAP160x2x2 = 11 ; 'duochrome', 160 pixel & 2 scanlines per mode line (GR.6)
+DL_MAP160x1x2 = 12 ; 'duochrome', 160 pixel & 1 scanline per mode line (GR.14)
+DL_MAP160x2x4 = 13 ; 4 colours, 160 pixel & 2 scanlines per mode line (GR.7)
+DL_MAP160x1x4 = 14 ; 4 colours, 160 pixel & 1 scanline per mode line (GR.15)
+DL_MAP320x1x1 = 15 ; monochrome, 320 pixel & 1 scanline per mode line (GR.8)
+
+; modifiers on mode lines...
+
+DL_HSCROL = 16
+DL_VSCROL = 32
+DL_LMS = 64
+
+; general modifier...
+
+DL_DLI = 128
+;/*****************************************************************************/
+;/* */
+;/* atari_atascii_charmap.inc */
+;/* */
+;/* Atari system standard string mapping ISO-8859-1 -> AtASCII */
+;/* */
+;/* */
+;/* */
+;/* C 2016 Christian Krueger */
+;/* */
+;/* */
+;/* This software is provided 'as-is', without any expressed or implied */
+;/* warranty. In no event will the authors be held liable for any damages */
+;/* arising from the use of this software. */
+;/* */
+;/* Permission is granted to anyone to use this software for any purpose, */
+;/* including commercial applications, and to alter it and redistribute it */
+;/* freely, subject to the following restrictions: */
+;/* */
+;/* 1. The origin of this software must not be misrepresented; you must not */
+;/* claim that you wrote the original software. If you use this software */
+;/* in a product, an acknowledgment in the product documentation would be */
+;/* appreciated but is not required. */
+;/* 2. Altered source versions must be plainly marked as such, and must not */
+;/* be misrepresented as being the original software. */
+;/* 3. This notice may not be removed or altered from any source */
+;/* distribution. */
+;/* */
+;/*****************************************************************************/
+
+.charmap $00, $00
+.charmap $01, $01
+.charmap $02, $02
+.charmap $03, $03
+.charmap $04, $04
+.charmap $05, $05
+.charmap $06, $06
+.charmap $07, $FD
+.charmap $08, $08
+.charmap $09, $7F
+.charmap $0A, $9B
+.charmap $0B, $0B
+.charmap $0C, $7D
+.charmap $0D, $0D
+.charmap $0E, $0E
+.charmap $0F, $0F
+
+.charmap $10, $10
+.charmap $11, $11
+.charmap $12, $12
+.charmap $13, $13
+.charmap $14, $14
+.charmap $15, $15
+.charmap $16, $16
+.charmap $17, $17
+.charmap $18, $18
+.charmap $19, $19
+.charmap $1A, $1A
+.charmap $1B, $1B
+.charmap $1C, $1C
+.charmap $1D, $1D
+.charmap $1E, $1E
+.charmap $1F, $1F
+
+.charmap $20, $20
+.charmap $21, $21
+.charmap $22, $22
+.charmap $23, $23
+.charmap $24, $24
+.charmap $25, $25
+.charmap $26, $26
+.charmap $27, $27
+.charmap $28, $28
+.charmap $29, $29
+.charmap $2A, $2A
+.charmap $2B, $2B
+.charmap $2C, $2C
+.charmap $2D, $2D
+.charmap $2E, $2E
+.charmap $2F, $2F
+
+.charmap $30, $30
+.charmap $31, $31
+.charmap $32, $32
+.charmap $33, $33
+.charmap $34, $34
+.charmap $35, $35
+.charmap $36, $36
+.charmap $37, $37
+.charmap $38, $38
+.charmap $39, $39
+.charmap $3A, $3A
+.charmap $3B, $3B
+.charmap $3C, $3C
+.charmap $3D, $3D
+.charmap $3E, $3E
+.charmap $3F, $3F
+
+.charmap $40, $40
+.charmap $41, $41
+.charmap $42, $42
+.charmap $43, $43
+.charmap $44, $44
+.charmap $45, $45
+.charmap $46, $46
+.charmap $47, $47
+.charmap $48, $48
+.charmap $49, $49
+.charmap $4A, $4A
+.charmap $4B, $4B
+.charmap $4C, $4C
+.charmap $4D, $4D
+.charmap $4E, $4E
+.charmap $4F, $4F
+
+.charmap $50, $50
+.charmap $51, $51
+.charmap $52, $52
+.charmap $53, $53
+.charmap $54, $54
+.charmap $55, $55
+.charmap $56, $56
+.charmap $57, $57
+.charmap $58, $58
+.charmap $59, $59
+.charmap $5A, $5A
+.charmap $5B, $5B
+.charmap $5C, $5C
+.charmap $5D, $5D
+.charmap $5E, $5E
+.charmap $5F, $5F
+
+.charmap $60, $60
+.charmap $61, $61
+.charmap $62, $62
+.charmap $63, $63
+.charmap $64, $64
+.charmap $65, $65
+.charmap $66, $66
+.charmap $67, $67
+.charmap $68, $68
+.charmap $69, $69
+.charmap $6A, $6A
+.charmap $6B, $6B
+.charmap $6C, $6C
+.charmap $6D, $6D
+.charmap $6E, $6E
+.charmap $6F, $6F
+
+.charmap $70, $70
+.charmap $71, $71
+.charmap $72, $72
+.charmap $73, $73
+.charmap $74, $74
+.charmap $75, $75
+.charmap $76, $76
+.charmap $77, $77
+.charmap $78, $78
+.charmap $79, $79
+.charmap $7A, $7A
+.charmap $7B, $7B
+.charmap $7C, $7C
+.charmap $7D, $7D
+.charmap $7E, $7E
+.charmap $7F, $7F
+
+.charmap $80, $80
+.charmap $81, $81
+.charmap $82, $82
+.charmap $83, $83
+.charmap $84, $84
+.charmap $85, $85
+.charmap $86, $86
+.charmap $87, $87
+.charmap $88, $88
+.charmap $89, $89
+.charmap $8A, $8A
+.charmap $8B, $8B
+.charmap $8C, $8C
+.charmap $8D, $8D
+.charmap $8E, $8E
+.charmap $8F, $8F
+
+.charmap $90, $90
+.charmap $91, $91
+.charmap $92, $92
+.charmap $93, $93
+.charmap $94, $94
+.charmap $95, $95
+.charmap $96, $96
+.charmap $97, $97
+.charmap $98, $98
+.charmap $99, $99
+.charmap $9A, $9A
+.charmap $9B, $9B
+.charmap $9C, $9C
+.charmap $9D, $9D
+.charmap $9E, $9E
+.charmap $9F, $9F
+
+.charmap $A0, $A0
+.charmap $A1, $A1
+.charmap $A2, $A2
+.charmap $A3, $A3
+.charmap $A4, $A4
+.charmap $A5, $A5
+.charmap $A6, $A6
+.charmap $A7, $A7
+.charmap $A8, $A8
+.charmap $A9, $A9
+.charmap $AA, $AA
+.charmap $AB, $AB
+.charmap $AC, $AC
+.charmap $AD, $AD
+.charmap $AE, $AE
+.charmap $AF, $AF
+
+.charmap $B0, $B0
+.charmap $B1, $B1
+.charmap $B2, $B2
+.charmap $B3, $B3
+.charmap $B4, $B4
+.charmap $B5, $B5
+.charmap $B6, $B6
+.charmap $B7, $B7
+.charmap $B8, $B8
+.charmap $B9, $B9
+.charmap $BA, $BA
+.charmap $BB, $BB
+.charmap $BC, $BC
+.charmap $BD, $BD
+.charmap $BE, $BE
+.charmap $BF, $BF
+
+.charmap $C0, $C0
+.charmap $C1, $C1
+.charmap $C2, $C2
+.charmap $C3, $C3
+.charmap $C4, $C4
+.charmap $C5, $C5
+.charmap $C6, $C6
+.charmap $C7, $C7
+.charmap $C8, $C8
+.charmap $C9, $C9
+.charmap $CA, $CA
+.charmap $CB, $CB
+.charmap $CC, $CC
+.charmap $CD, $CD
+.charmap $CE, $CE
+.charmap $CF, $CF
+
+.charmap $D0, $D0
+.charmap $D1, $D1
+.charmap $D2, $D2
+.charmap $D3, $D3
+.charmap $D4, $D4
+.charmap $D5, $D5
+.charmap $D6, $D6
+.charmap $D7, $D7
+.charmap $D8, $D8
+.charmap $D9, $D9
+.charmap $DA, $DA
+.charmap $DB, $DB
+.charmap $DC, $DC
+.charmap $DD, $DD
+.charmap $DE, $DE
+.charmap $DF, $DF
+
+.charmap $E0, $E0
+.charmap $E1, $E1
+.charmap $E2, $E2
+.charmap $E3, $E3
+.charmap $E4, $E4
+.charmap $E5, $E5
+.charmap $E6, $E6
+.charmap $E7, $E7
+.charmap $E8, $E8
+.charmap $E9, $E9
+.charmap $EA, $EA
+.charmap $EB, $EB
+.charmap $EC, $EC
+.charmap $ED, $ED
+.charmap $EE, $EE
+.charmap $EF, $EF
+
+.charmap $F0, $F0
+.charmap $F1, $F1
+.charmap $F2, $F2
+.charmap $F3, $F3
+.charmap $F4, $F4
+.charmap $F5, $F5
+.charmap $F6, $F6
+.charmap $F7, $F7
+.charmap $F8, $F8
+.charmap $F9, $F9
+.charmap $FA, $FA
+.charmap $FB, $FB
+.charmap $FC, $FC
+.charmap $FD, $FD
+.charmap $FE, $FE
+.charmap $FF, $FF
+;-------------------------------------------------------------------------
+; CTIA/GTIA Address Equates
+;-------------------------------------------------------------------------
+
+; Read/Write Addresses
+
+CONSOL = GTIA + $1F ;console switches and speaker control
+
+; Read Addresses
+
+M0PF = GTIA + $00 ;missile 0 and playfield collision
+M1PF = GTIA + $01 ;missile 1 and playfield collision
+M2PF = GTIA + $02 ;missile 2 and playfield collision
+M3PF = GTIA + $03 ;missile 3 and playfield collision
+
+P0PF = GTIA + $04 ;player 0 and playfield collision
+P1PF = GTIA + $05 ;player 1 and playfield collision
+P2PF = GTIA + $06 ;player 2 and playfield collision
+P3PF = GTIA + $07 ;player 3 and playfield collision
+
+M0PL = GTIA + $08 ;missile 0 and player collision
+M1PL = GTIA + $09 ;missile 1 and player collision
+M2PL = GTIA + $0A ;missile 2 and player collision
+M3PL = GTIA + $0B ;missile 3 and player collision
+
+P0PL = GTIA + $0C ;player 0 and player collision
+P1PL = GTIA + $0D ;player 1 and player collision
+P2PL = GTIA + $0E ;player 2 and player collision
+P3PL = GTIA + $0F ;player 3 and player collision
+
+TRIG0 = GTIA + $10 ;joystick trigger 0
+TRIG1 = GTIA + $11 ;joystick trigger 1
+
+TRIG2 = GTIA + $12 ;cartridge interlock
+TRIG3 = GTIA + $13 ;ACMI module interlock
+
+PAL = GTIA + $14 ;##rev2## PAL/NTSC indicator
+
+; Write Addresses
+
+HPOSP0 = GTIA + $00 ;player 0 horizontal position
+HPOSP1 = GTIA + $01 ;player 1 horizontal position
+HPOSP2 = GTIA + $02 ;player 2 horizontal position
+HPOSP3 = GTIA + $03 ;player 3 horizontal position
+
+HPOSM0 = GTIA + $04 ;missile 0 horizontal position
+HPOSM1 = GTIA + $05 ;missile 1 horizontal position
+HPOSM2 = GTIA + $06 ;missile 2 horizontal position
+HPOSM3 = GTIA + $07 ;missile 3 horizontal position
+
+SIZEP0 = GTIA + $08 ;player 0 size
+SIZEP1 = GTIA + $09 ;player 1 size
+SIZEP2 = GTIA + $0A ;player 2 size
+SIZEP3 = GTIA + $0B ;player 3 size
+
+SIZEM = GTIA + $0C ;missile sizes
+
+GRAFP0 = GTIA + $0D ;player 0 graphics
+GRAFP1 = GTIA + $0E ;player 1 graphics
+GRAFP2 = GTIA + $0F ;player 2 graphics
+GRAFP3 = GTIA + $10 ;player 3 graphics
+
+GRAFM = GTIA + $11 ;missile graphics
+
+COLPM0 = GTIA + $12 ;player-missile 0 color/luminance
+COLPM1 = GTIA + $13 ;player-missile 1 color/luminance
+COLPM2 = GTIA + $14 ;player-missile 2 color/luminance
+COLPM3 = GTIA + $15 ;player-missile 3 color/luminance
+
+COLPF0 = GTIA + $16 ;playfield 0 color/luminance
+COLPF1 = GTIA + $17 ;playfield 1 color/luminance
+COLPF2 = GTIA + $18 ;playfield 2 color/luminance
+COLPF3 = GTIA + $19 ;playfield 3 color/luminance
+
+COLBK = GTIA + $1A ;background color/luminance
+
+PRIOR = GTIA + $1B ;priority select
+VDELAY = GTIA + $1C ;vertical delay
+GRACTL = GTIA + $1D ;graphic control
+HITCLR = GTIA + $1E ;collision clear
+
+
+; Hue values
+
+HUE_GREY = 0
+HUE_GOLD = 1
+HUE_GOLDORANGE = 2
+HUE_REDORANGE = 3
+HUE_ORANGE = 4
+HUE_MAGENTA = 5
+HUE_PURPLE = 6
+HUE_BLUE = 7
+HUE_BLUE2 = 8
+HUE_CYAN = 9
+HUE_BLUEGREEN = 10
+HUE_BLUEGREEN2 = 11
+HUE_GREEN = 12
+HUE_YELLOWGREEN = 13
+HUE_YELLOW = 14
+HUE_YELLOWRED = 15
+
+; Color defines, similar to c64 colors (untested)
+
+GTIA_COLOR_BLACK = (HUE_GREY << 4)
+GTIA_COLOR_WHITE = (HUE_GREY << 4 | 7 << 1)
+GTIA_COLOR_RED = (HUE_REDORANGE << 4 | 1 << 1)
+GTIA_COLOR_CYAN = (HUE_CYAN << 4 | 3 << 1)
+GTIA_COLOR_VIOLET = (HUE_PURPLE << 4 | 4 << 1)
+GTIA_COLOR_GREEN = (HUE_GREEN << 4 | 2 << 1)
+GTIA_COLOR_BLUE = (HUE_BLUE << 4 | 2 << 1)
+GTIA_COLOR_YELLOW = (HUE_YELLOW << 4 | 7 << 1)
+GTIA_COLOR_ORANGE = (HUE_ORANGE << 4 | 5 << 1)
+GTIA_COLOR_BROWN = (HUE_YELLOW << 4 | 2 << 1)
+GTIA_COLOR_LIGHTRED = (HUE_REDORANGE << 4 | 6 << 1)
+GTIA_COLOR_GRAY1 = (HUE_GREY << 4 | 2 << 1)
+GTIA_COLOR_GRAY2 = (HUE_GREY << 4 | 3 << 1)
+GTIA_COLOR_LIGHTGREEN = (HUE_GREEN << 4 | 6 << 1)
+GTIA_COLOR_LIGHTBLUE = (HUE_BLUE << 4 | 6 << 1)
+GTIA_COLOR_GRAY3 = (HUE_GREY << 4 | 5 << 1)
+;-------------------------------------------------------------------------
+; POKEY Address Equates
+;-------------------------------------------------------------------------
+
+; Read Addresses
+
+POT0 = POKEY + $00 ;potentiometer 0
+POT1 = POKEY + $01 ;potentiometer 1
+POT2 = POKEY + $02 ;potentiometer 2
+POT3 = POKEY + $03 ;potentiometer 3
+POT4 = POKEY + $04 ;potentiometer 4
+POT5 = POKEY + $05 ;potentiometer 5
+POT6 = POKEY + $06 ;potentiometer 6
+POT7 = POKEY + $07 ;potentiometer 7
+
+ALLPOT = POKEY + $08 ;potentiometer port status
+KBCODE = POKEY + $09 ;keyboard code
+RANDOM = POKEY + $0A ;random number generator
+SERIN = POKEY + $0D ;serial port input
+IRQST = POKEY + $0E ;IRQ interrupt status
+SKSTAT = POKEY + $0F ;serial port and keyboard status
+
+; Write Addresses
+
+AUDF1 = POKEY + $00 ;channel 1 audio frequency
+AUDC1 = POKEY + $01 ;channel 1 audio control
+
+AUDF2 = POKEY + $02 ;channel 2 audio frequency
+AUDC2 = POKEY + $03 ;channel 2 audio control
+
+AUDF3 = POKEY + $04 ;channel 3 audio frequency
+AUDC3 = POKEY + $05 ;channel 3 audio control
+
+AUDF4 = POKEY + $06 ;channel 4 audio frequency
+AUDC4 = POKEY + $07 ;channel 4 audio control
+
+AUDCTL = POKEY + $08 ;audio control
+STIMER = POKEY + $09 ;start timers
+SKRES = POKEY + $0A ;reset SKSTAT status
+POTGO = POKEY + $0B ;start potentiometer scan sequence
+SEROUT = POKEY + $0D ;serial port output
+IRQEN = POKEY + $0E ;IRQ interrupt enable
+SKCTL = POKEY + $0F ;serial port and keyboard control
+;/*****************************************************************************/
+;/* */
+;/* atari_screen_charmap.inc */
+;/* */
+;/* Atari system internal string mapping ISO-8859-1 -> Internal/Screen-Code */
+;/* */
+;/* */
+;/* */
+;/* C 2016 Christian Krueger */
+;/* */
+;/* */
+;/* This software is provided 'as-is', without any expressed or implied */
+;/* warranty. In no event will the authors be held liable for any damages */
+;/* arising from the use of this software. */
+;/* */
+;/* Permission is granted to anyone to use this software for any purpose, */
+;/* including commercial applications, and to alter it and redistribute it */
+;/* freely, subject to the following restrictions: */
+;/* */
+;/* 1. The origin of this software must not be misrepresented; you must not */
+;/* claim that you wrote the original software. If you use this software */
+;/* in a product, an acknowledgment in the product documentation would be */
+;/* appreciated but is not required. */
+;/* 2. Altered source versions must be plainly marked as such, and must not */
+;/* be misrepresented as being the original software. */
+;/* 3. This notice may not be removed or altered from any source */
+;/* distribution. */
+;/* */
+;/*****************************************************************************/
+
+.charmap $00, $40
+.charmap $01, $41
+.charmap $02, $42
+.charmap $03, $43
+.charmap $04, $44
+.charmap $05, $45
+.charmap $06, $46
+.charmap $07, $FD
+.charmap $08, $48
+.charmap $09, $7F
+.charmap $0A, $DB
+.charmap $0B, $4B
+.charmap $0C, $7D
+.charmap $0D, $4D
+.charmap $0E, $4E
+.charmap $0F, $4F
+
+.charmap $10, $50
+.charmap $11, $51
+.charmap $12, $52
+.charmap $13, $53
+.charmap $14, $54
+.charmap $15, $55
+.charmap $16, $56
+.charmap $17, $57
+.charmap $18, $58
+.charmap $19, $59
+.charmap $1A, $5A
+.charmap $1B, $5B
+.charmap $1C, $5C
+.charmap $1D, $5D
+.charmap $1E, $5E
+.charmap $1F, $5F
+
+.charmap $20, $00
+
+.charmap $21, $01
+.charmap $22, $02
+.charmap $23, $03
+.charmap $24, $04
+.charmap $25, $05
+.charmap $26, $06
+.charmap $27, $07
+.charmap $28, $08
+.charmap $29, $09
+.charmap $2A, $0A
+.charmap $2B, $0B
+.charmap $2C, $0C
+.charmap $2D, $0D
+.charmap $2E, $0E
+.charmap $2F, $0F
+
+.charmap $30, $10
+.charmap $31, $11
+.charmap $32, $12
+.charmap $33, $13
+.charmap $34, $14
+.charmap $35, $15
+.charmap $36, $16
+.charmap $37, $17
+.charmap $38, $18
+.charmap $39, $19
+.charmap $3A, $1A
+.charmap $3B, $1B
+.charmap $3C, $1C
+.charmap $3D, $1D
+.charmap $3E, $1E
+.charmap $3F, $1F
+
+.charmap $40, $20
+.charmap $41, $21
+.charmap $42, $22
+.charmap $43, $23
+.charmap $44, $24
+.charmap $45, $25
+.charmap $46, $26
+.charmap $47, $27
+.charmap $48, $28
+.charmap $49, $29
+.charmap $4A, $2A
+.charmap $4B, $2B
+.charmap $4C, $2C
+.charmap $4D, $2D
+.charmap $4E, $2E
+.charmap $4F, $2F
+
+.charmap $50, $30
+.charmap $51, $31
+.charmap $52, $32
+.charmap $53, $33
+.charmap $54, $34
+.charmap $55, $35
+.charmap $56, $36
+.charmap $57, $37
+.charmap $58, $38
+.charmap $59, $39
+.charmap $5A, $3A
+.charmap $5B, $3B
+.charmap $5C, $3C
+.charmap $5D, $3D
+.charmap $5E, $3E
+.charmap $5F, $3F
+
+.charmap $60, $60
+.charmap $61, $61
+.charmap $62, $62
+.charmap $63, $63
+.charmap $64, $64
+.charmap $65, $65
+.charmap $66, $66
+.charmap $67, $67
+.charmap $68, $68
+.charmap $69, $69
+.charmap $6A, $6A
+.charmap $6B, $6B
+.charmap $6C, $6C
+.charmap $6D, $6D
+.charmap $6E, $6E
+.charmap $6F, $6F
+
+.charmap $70, $70
+.charmap $71, $71
+.charmap $72, $72
+.charmap $73, $73
+.charmap $74, $74
+.charmap $75, $75
+.charmap $76, $76
+.charmap $77, $77
+.charmap $78, $78
+.charmap $79, $79
+.charmap $7A, $7A
+.charmap $7B, $7B
+.charmap $7C, $7C
+.charmap $7D, $7D
+.charmap $7E, $7E
+.charmap $7F, $7F
+
+.charmap $80, $C0
+.charmap $81, $C1
+.charmap $82, $C2
+.charmap $83, $C3
+.charmap $84, $C4
+.charmap $85, $C5
+.charmap $86, $C6
+.charmap $87, $C7
+.charmap $88, $C8
+.charmap $89, $C9
+.charmap $8A, $CA
+.charmap $8B, $CB
+.charmap $8C, $CC
+.charmap $8D, $CD
+.charmap $8E, $CE
+.charmap $8F, $CF
+
+.charmap $90, $D0
+.charmap $91, $D1
+.charmap $92, $D2
+.charmap $93, $D3
+.charmap $94, $D4
+.charmap $95, $D5
+.charmap $96, $D6
+.charmap $97, $D7
+.charmap $98, $D8
+.charmap $99, $D9
+.charmap $9A, $DA
+.charmap $9B, $DB
+.charmap $9C, $DC
+.charmap $9D, $DD
+.charmap $9E, $DE
+.charmap $9F, $DF
+
+.charmap $A0, $80
+.charmap $A1, $81
+.charmap $A2, $82
+.charmap $A3, $83
+.charmap $A4, $84
+.charmap $A5, $85
+.charmap $A6, $86
+.charmap $A7, $87
+.charmap $A8, $88
+.charmap $A9, $89
+.charmap $AA, $8A
+.charmap $AB, $8B
+.charmap $AC, $8C
+.charmap $AD, $8D
+.charmap $AE, $8E
+.charmap $AF, $8F
+
+.charmap $B0, $90
+.charmap $B1, $91
+.charmap $B2, $92
+.charmap $B3, $93
+.charmap $B4, $94
+.charmap $B5, $95
+.charmap $B6, $96
+.charmap $B7, $97
+.charmap $B8, $98
+.charmap $B9, $99
+.charmap $BA, $9A
+.charmap $BB, $9B
+.charmap $BC, $9C
+.charmap $BD, $9D
+.charmap $BE, $9E
+.charmap $BF, $9F
+
+.charmap $C0, $A0
+.charmap $C1, $A1
+.charmap $C2, $A2
+.charmap $C3, $A3
+.charmap $C4, $A4
+.charmap $C5, $A5
+.charmap $C6, $A6
+.charmap $C7, $A7
+.charmap $C8, $A8
+.charmap $C9, $A9
+.charmap $CA, $AA
+.charmap $CB, $AB
+.charmap $CC, $AC
+.charmap $CD, $AD
+.charmap $CE, $AE
+.charmap $CF, $AF
+
+.charmap $D0, $B0
+.charmap $D1, $B1
+.charmap $D2, $B2
+.charmap $D3, $B3
+.charmap $D4, $B4
+.charmap $D5, $B5
+.charmap $D6, $B6
+.charmap $D7, $B7
+.charmap $D8, $B8
+.charmap $D9, $B9
+.charmap $DA, $BA
+.charmap $DB, $BB
+.charmap $DC, $BC
+.charmap $DD, $BD
+.charmap $DE, $BE
+.charmap $DF, $BF
+
+.charmap $E0, $E0
+.charmap $E1, $E1
+.charmap $E2, $E2
+.charmap $E3, $E3
+.charmap $E4, $E4
+.charmap $E5, $E5
+.charmap $E6, $E6
+.charmap $E7, $E7
+.charmap $E8, $E8
+.charmap $E9, $E9
+.charmap $EA, $EA
+.charmap $EB, $EB
+.charmap $EC, $EC
+.charmap $ED, $ED
+.charmap $EE, $EE
+.charmap $EF, $EF
+
+.charmap $F0, $F0
+.charmap $F1, $F1
+.charmap $F2, $F2
+.charmap $F3, $F3
+.charmap $F4, $F4
+.charmap $F5, $F5
+.charmap $F6, $F6
+.charmap $F7, $F7
+.charmap $F8, $F8
+.charmap $F9, $F9
+.charmap $FA, $FA
+.charmap $FB, $FB
+.charmap $FC, $FC
+.charmap $FD, $FD
+.charmap $FE, $FE
+.charmap $FF, $FF
+
+;
+; Oric Atmos definitions
+; BASIC 1.1 addresses
+;
+
+
+; ---------------------------------------------------------------------------
+; Constants
+
+SCREEN_XSIZE = 40 ; screen columns
+SCREEN_YSIZE = 28 ; screen rows
+
+FUNCTKEY = $A5
+
+FNAME_LEN = 16 ; maximum length of file-name
+
+
+; ---------------------------------------------------------------------------
+; Zero page
+
+SCRPTR := $12
+BASIC_BUF := $35
+CHARGOT := $E8
+TXTPTR := $E9
+
+
+; ---------------------------------------------------------------------------
+; Low memory
+
+MODEKEY := $0209
+CAPSLOCK := $020C ; $7F = not locked, $FF = locked
+PATTERN := $0213
+IRQVec := $0245 ; "fast" interrupt vector
+JOINFLAG := $025A ; 0 = don't joiu, $4A = join BASIC programs
+VERIFYFLAG := $025B ; 0 = load, 1 = verify
+CURS_Y := $0268
+CURS_X := $0269
+STATUS := $026A
+BACKGRND := $026B
+FOREGRND := $026C
+TIMER3 := $0276
+CFILE_NAME := $027F
+CFOUND_NAME := $0293
+FILESTART := $02A9
+FILEEND := $02AB
+AUTORUN := $02AD ; $00 = only load, $C7 = autorun
+LANGFLAG := $02AE ; $00 = BASIC, $80 = machine code
+LOADERR := $02B1
+KEYBUF := $02DF
+PARMERR := $02E0
+PARAM1 := $02E1 ; & $02E2
+PARAM2 := $02E3 ; & $02E4
+PARAM3 := $02E5 ; & $02E6
+BANGVEC := $02F5
+
+
+; ---------------------------------------------------------------------------
+; I/O locations
+
+; 6522
+.struct VIA ; Versatile Interface Adapter
+ .res $0300
+PRB .byte ; Port Register B
+PRA .byte ; Port Register A
+DDRB .byte ; Data Direction Register B
+DDRA .byte ; Data Direction Register A
+T1 .word ; Timer 1
+T1L .word ; Timer 1 Latch
+T2 .word ; Timer 2
+SR .byte ; Shift Register
+ACR .byte ; Auxiliary Control Register
+PCR .byte ; Peripheral Control Register
+IFR .byte ; Interrupt Flags Register
+IER .byte ; Interrupt Enable Register
+PRA2 .byte ; Port Register A without handshaking
+.endstruct
+
+; 6551
+.struct ACIA ; Asynchronous Communications Interface Adapter
+ .res $031C
+DATA .byte
+STATUS .byte
+CMD .byte ; Command register
+CTRL .byte ; Control register
+.endstruct
+
+SCREEN := $BB80
+
+
+; ---------------------------------------------------------------------------
+; ROM entries
+
+GETLINE := $C592
+TEXT := $EC21
+HIRES := $EC33
+CURSET := $F0C8
+CURMOV := $F0FD
+DRAW := $F110
+CHAR := $F12D
+POINT := $F1C8
+PAPER := $F204
+INK := $F210
+PRINT := $F77C
+
+; Sound Effects
+PING := $FA9F
+PING1 := $FA85
+SHOOT := $FAB5
+SHOOT1 := $FA9B
+EXPLODE := $FACB
+EXPLODE1 := $FAB1
+ZAP := $FAE1
+ZAP1 := $FAC7
+TICK := $FB14
+TICK1 := $FAFA
+TOCK := $FB2A
+TOCK1 := $FB10
+;
+; C128 generic definitions. Stolen from Elite128
+;
+
+
+; ---------------------------------------------------------------------------
+; Zero page, Commodore stuff
+
+TXTPTR := $3D ; Pointer into BASIC source code
+STATUS := $90 ; Kernal I/O completion status
+TIME := $A0 ; 60HZ clock
+FNAM_LEN := $B7 ; Length of filename
+SECADR := $B9 ; Secondary address
+DEVNUM := $BA ; Device number
+FNAM := $BB ; Address of filename
+FNAM_BANK := $C7 ; Bank for filename
+KEY_COUNT := $D0 ; Number of keys in input buffer
+FKEY_COUNT := $D1 ; Characters for function key
+MODE := $D7 ; 40-/80-column mode (bit 7: 80 columns)
+GRAPHM := $D8 ; Graphics mode flags (bits 5-7)
+CHARDIS := $D9 ; Bit 2 shadow for location $01
+CURS_X := $EC ; Cursor column
+CURS_Y := $EB ; Cursor row
+SCREEN_PTR := $E0 ; Pointer to current char in text screen
+CRAM_PTR := $E2 ; Pointer to current char in color RAM
+
+CHARCOLOR := $F1
+RVS := $F3 ; Reverse output flag
+SCROLL := $F8 ; Disable scrolling flag
+
+BASIC_BUF := $0200 ; Location of command-line
+BASIC_BUF_LEN = 162 ; Maximum length of command-line
+
+FETCH := $02A2 ; Fetch subroutine in RAM
+FETVEC := $02AA ; Vector patch location for FETCH
+STASH := $02AF ; Stash routine in RAM
+STAVEC := $02B9 ; Vector patch location for STASH
+IRQInd := $02FD ; JMP $0000 -- used as indirect IRQ vector
+PALFLAG := $0A03 ; $FF=PAL, $00=NTSC
+INIT_STATUS := $0A04 ; Flags: Reset/Restore initiation status
+VM2 := $0A2D ; VIC-IIe shadow for $D018 -- graphics mode
+FKEY_LEN := $1000 ; Function key lengths
+FKEY_TEXT := $100A ; Function key texts
+
+KBDREPEAT := $028a
+KBDREPEATRATE := $028b
+KBDREPEATDELAY := $028c
+
+; ---------------------------------------------------------------------------
+; Vectors
+
+IRQVec := $0314
+BRKVec := $0316
+NMIVec := $0318
+KeyStoreVec := $033C
+
+; ---------------------------------------------------------------------------
+; I/O: VIC
+
+VIC := $D000
+VIC_SPR0_X := $D000
+VIC_SPR0_Y := $D001
+VIC_SPR1_X := $D002
+VIC_SPR1_Y := $D003
+VIC_SPR2_X := $D004
+VIC_SPR2_Y := $D005
+VIC_SPR3_X := $D006
+VIC_SPR3_Y := $D007
+VIC_SPR4_X := $D008
+VIC_SPR4_Y := $D009
+VIC_SPR5_X := $D00A
+VIC_SPR5_Y := $D00B
+VIC_SPR6_X := $D00C
+VIC_SPR6_Y := $D00D
+VIC_SPR7_X := $D00E
+VIC_SPR7_Y := $D00F
+VIC_SPR_HI_X := $D010
+VIC_SPR_ENA := $D015
+VIC_SPR_EXP_Y := $D017
+VIC_SPR_EXP_X := $D01D
+VIC_SPR_MCOLOR := $D01C
+VIC_SPR_BG_PRIO := $D01B
+
+VIC_SPR_MCOLOR0 := $D025
+VIC_SPR_MCOLOR1 := $D026
+
+VIC_SPR0_COLOR := $D027
+VIC_SPR1_COLOR := $D028
+VIC_SPR2_COLOR := $D029
+VIC_SPR3_COLOR := $D02A
+VIC_SPR4_COLOR := $D02B
+VIC_SPR5_COLOR := $D02C
+VIC_SPR6_COLOR := $D02D
+VIC_SPR7_COLOR := $D02E
+
+VIC_CTRL1 := $D011
+VIC_CTRL2 := $D016
+
+VIC_HLINE := $D012
+
+VIC_LPEN_X := $D013
+VIC_LPEN_Y := $D014
+
+VIC_VIDEO_ADR := $D018
+
+VIC_IRR := $D019 ; Interrupt request register
+VIC_IMR := $D01A ; Interrupt mask register
+
+VIC_BORDERCOLOR := $D020
+VIC_BG_COLOR0 := $D021
+VIC_BG_COLOR1 := $D022
+VIC_BG_COLOR2 := $D023
+VIC_BG_COLOR3 := $D024
+
+; 128 stuff:
+VIC_KBD_128 := $D02F ; Extended kbd bits (visible in 64 mode)
+VIC_CLK_128 := $D030 ; Clock rate register (visible in 64 mode)
+
+
+; ---------------------------------------------------------------------------
+; I/O: SID
+
+SID := $D400
+SID_S1Lo := $D400
+SID_S1Hi := $D401
+SID_PB1Lo := $D402
+SID_PB1Hi := $D403
+SID_Ctl1 := $D404
+SID_AD1 := $D405
+SID_SUR1 := $D406
+
+SID_S2Lo := $D407
+SID_S2Hi := $D408
+SID_PB2Lo := $D409
+SID_PB2Hi := $D40A
+SID_Ctl2 := $D40B
+SID_AD2 := $D40C
+SID_SUR2 := $D40D
+
+SID_S3Lo := $D40E
+SID_S3Hi := $D40F
+SID_PB3Lo := $D410
+SID_PB3Hi := $D411
+SID_Ctl3 := $D412
+SID_AD3 := $D413
+SID_SUR3 := $D414
+
+SID_FltLo := $D415
+SID_FltHi := $D416
+SID_FltCtl := $D417
+SID_Amp := $D418
+SID_ADConv1 := $D419
+SID_ADConv2 := $D41A
+SID_Noise := $D41B
+SID_Read3 := $D41C
+
+; ---------------------------------------------------------------------------
+; I/O: VDC (128 only)
+
+VDC_INDEX := $D600 ; register address port
+VDC_DATA := $D601 ; data port
+
+; Registers
+VDC_DATA_HI = 18 ; video RAM address (big endian)
+VDC_DATA_LO = 19
+VDC_CSET = 28
+VDC_RAM_RW = 31 ; RAM port
+
+; ---------------------------------------------------------------------------
+; I/O: Complex Interface Adapters
+
+CIA1 := $DC00
+CIA1_PRA := $DC00 ; Port A
+CIA1_PRB := $DC01 ; Port B
+CIA1_DDRA := $DC02 ; Data direction register for port A
+CIA1_DDRB := $DC03 ; Data direction register for port B
+CIA1_TA := $DC04 ; 16-bit timer A
+CIA1_TB := $DC06 ; 16-bit timer B
+CIA1_TOD10 := $DC08 ; Time-of-day tenths of a second
+CIA1_TODSEC := $DC09 ; Time-of-day seconds
+CIA1_TODMIN := $DC0A ; Time-of-day minutes
+CIA1_TODHR := $DC0B ; Time-of-day hours
+CIA1_SDR := $DC0C ; Serial data register
+CIA1_ICR := $DC0D ; Interrupt control register
+CIA1_CRA := $DC0E ; Control register for timer A
+CIA1_CRB := $DC0F ; Control register for timer B
+
+CIA2 := $DD00
+CIA2_PRA := $DD00
+CIA2_PRB := $DD01
+CIA2_DDRA := $DD02
+CIA2_DDRB := $DD03
+CIA2_TA := $DD04
+CIA2_TB := $DD06
+CIA2_TOD10 := $DD08
+CIA2_TODSEC := $DD09
+CIA2_TODMIN := $DD0A
+CIA2_TODHR := $DD0B
+CIA2_SDR := $DD0C
+CIA2_ICR := $DD0D
+CIA2_CRA := $DD0E
+CIA2_CRB := $DD0F
+
+; ---------------------------------------------------------------------------
+; I/O: MMU
+
+MMU_CR := $FF00
+MMU_CFG_CC65 := %00001110 ; Bank 0 with kernal ROM
+MMU_CFG_RAM0 := %00111111 ; Bank 0 full RAM
+MMU_CFG_RAM1 := %01111111 ; Bank 1 full RAM
+MMU_CFG_RAM2 := %10111111 ; Bank 2 full RAM
+MMU_CFG_RAM3 := %11111111 ; Bank 3 full RAM
+MMU_CFG_IFROM := %01010111 ; Bank 1 with Internal Function RAM/ROM
+MMU_CFG_EFROM := %01101011 ; Bank 1 with External Function RAM/ROM
+
+; ---------------------------------------------------------------------------
+; Super CPU
+
+SCPU_VIC_Bank1 := $D075
+SCPU_Slow := $D07A
+SCPU_Fast := $D07B
+SCPU_EnableRegs := $D07E
+SCPU_DisableRegs:= $D07F
+SCPU_Detect := $D0BC
+;
+; C16 generic definitions.
+;
+; The C16 and Plus/4 are identical, so just include the Plus/4 include file.
+
+
+.include "plus4.inc"
+
+
+;
+; C64 generic definitions. Stolen from Elite128
+;
+
+
+; ---------------------------------------------------------------------------
+; Zero page, Commodore stuff
+
+VARTAB := $2D ; Pointer to start of BASIC variables
+MEMSIZE := $37 ; Pointer to highest BASIC RAM location (+1)
+TXTPTR := $7A ; Pointer into BASIC source code
+STATUS := $90 ; Kernal I/O completion status
+TIME := $A0 ; 60 HZ clock
+FNAM_LEN := $B7 ; Length of filename
+SECADR := $B9 ; Secondary address
+DEVNUM := $BA ; Device number
+FNAM := $BB ; Pointer to filename
+KEY_COUNT := $C6 ; Number of keys in input buffer
+RVS := $C7 ; Reverse flag
+CURS_FLAG := $CC ; 1 = cursor off
+CURS_BLINK := $CD ; Blink counter
+CURS_CHAR := $CE ; Character under the cursor
+CURS_STATE := $CF ; Cursor blink state
+SCREEN_PTR := $D1 ; Pointer to current char in text screen
+CURS_X := $D3 ; Cursor column
+CURS_Y := $D6 ; Cursor row
+CRAM_PTR := $F3 ; Pointer to current char in color RAM
+FREKZP := $FB ; Five unused bytes
+
+BASIC_BUF := $200 ; Location of command-line
+BASIC_BUF_LEN = 89 ; Maximum length of command-line
+
+CHARCOLOR := $286
+CURS_COLOR := $287 ; Color under the cursor
+PALFLAG := $2A6 ; $01 = PAL, $00 = NTSC
+
+KBDREPEAT := $28a
+KBDREPEATRATE := $28b
+KBDREPEATDELAY := $28c
+
+; ---------------------------------------------------------------------------
+; Vector and other locations
+
+IRQVec := $0314
+BRKVec := $0316
+NMIVec := $0318
+
+; ---------------------------------------------------------------------------
+; Screen size
+
+XSIZE = 40
+YSIZE = 25
+
+; ---------------------------------------------------------------------------
+; I/O: VIC
+
+VIC := $D000
+VIC_SPR0_X := $D000
+VIC_SPR0_Y := $D001
+VIC_SPR1_X := $D002
+VIC_SPR1_Y := $D003
+VIC_SPR2_X := $D004
+VIC_SPR2_Y := $D005
+VIC_SPR3_X := $D006
+VIC_SPR3_Y := $D007
+VIC_SPR4_X := $D008
+VIC_SPR4_Y := $D009
+VIC_SPR5_X := $D00A
+VIC_SPR5_Y := $D00B
+VIC_SPR6_X := $D00C
+VIC_SPR6_Y := $D00D
+VIC_SPR7_X := $D00E
+VIC_SPR7_Y := $D00F
+VIC_SPR_HI_X := $D010
+VIC_SPR_ENA := $D015
+VIC_SPR_EXP_Y := $D017
+VIC_SPR_EXP_X := $D01D
+VIC_SPR_MCOLOR := $D01C
+VIC_SPR_BG_PRIO := $D01B
+VIC_SPR_COLL := $D01E
+VIC_SPR_BG_COLL := $D01F
+
+VIC_SPR_MCOLOR0 := $D025
+VIC_SPR_MCOLOR1 := $D026
+
+VIC_SPR0_COLOR := $D027
+VIC_SPR1_COLOR := $D028
+VIC_SPR2_COLOR := $D029
+VIC_SPR3_COLOR := $D02A
+VIC_SPR4_COLOR := $D02B
+VIC_SPR5_COLOR := $D02C
+VIC_SPR6_COLOR := $D02D
+VIC_SPR7_COLOR := $D02E
+
+VIC_CTRL1 := $D011
+VIC_CTRL2 := $D016
+
+VIC_HLINE := $D012
+
+VIC_LPEN_X := $D013
+VIC_LPEN_Y := $D014
+
+VIC_VIDEO_ADR := $D018
+
+VIC_IRR := $D019 ; Interrupt request register
+VIC_IMR := $D01A ; Interrupt mask register
+
+VIC_BORDERCOLOR := $D020
+VIC_BG_COLOR0 := $D021
+VIC_BG_COLOR1 := $D022
+VIC_BG_COLOR2 := $D023
+VIC_BG_COLOR3 := $D024
+
+; 128 stuff:
+VIC_KBD_128 := $D02F ; Extended kbd bits (visible in 64 mode)
+VIC_CLK_128 := $D030 ; Clock rate register (visible in 64 mode)
+
+
+; ---------------------------------------------------------------------------
+; I/O: SID
+
+SID := $D400
+SID_S1Lo := $D400
+SID_S1Hi := $D401
+SID_PB1Lo := $D402
+SID_PB1Hi := $D403
+SID_Ctl1 := $D404
+SID_AD1 := $D405
+SID_SUR1 := $D406
+
+SID_S2Lo := $D407
+SID_S2Hi := $D408
+SID_PB2Lo := $D409
+SID_PB2Hi := $D40A
+SID_Ctl2 := $D40B
+SID_AD2 := $D40C
+SID_SUR2 := $D40D
+
+SID_S3Lo := $D40E
+SID_S3Hi := $D40F
+SID_PB3Lo := $D410
+SID_PB3Hi := $D411
+SID_Ctl3 := $D412
+SID_AD3 := $D413
+SID_SUR3 := $D414
+
+SID_FltLo := $D415
+SID_FltHi := $D416
+SID_FltCtl := $D417
+SID_Amp := $D418
+SID_ADConv1 := $D419
+SID_ADConv2 := $D41A
+SID_Noise := $D41B
+SID_Read3 := $D41C
+
+; ---------------------------------------------------------------------------
+; I/O: VDC (128 only)
+
+VDC_INDEX := $D600
+VDC_DATA := $D601
+
+; ---------------------------------------------------------------------------
+; I/O: Complex Interface Adapters
+
+CIA1 := $DC00
+CIA1_PRA := $DC00 ; Port A
+CIA1_PRB := $DC01 ; Port B
+CIA1_DDRA := $DC02 ; Data direction register for port A
+CIA1_DDRB := $DC03 ; Data direction register for port B
+CIA1_TA := $DC04 ; 16-bit timer A
+CIA1_TB := $DC06 ; 16-bit timer B
+CIA1_TOD10 := $DC08 ; Time-of-day tenths of a second
+CIA1_TODSEC := $DC09 ; Time-of-day seconds
+CIA1_TODMIN := $DC0A ; Time-of-day minutes
+CIA1_TODHR := $DC0B ; Time-of-day hours
+CIA1_SDR := $DC0C ; Serial data register
+CIA1_ICR := $DC0D ; Interrupt control register
+CIA1_CRA := $DC0E ; Control register for timer A
+CIA1_CRB := $DC0F ; Control register for timer B
+
+CIA2 := $DD00
+CIA2_PRA := $DD00
+CIA2_PRB := $DD01
+CIA2_DDRA := $DD02
+CIA2_DDRB := $DD03
+CIA2_TA := $DD04
+CIA2_TB := $DD06
+CIA2_TOD10 := $DD08
+CIA2_TODSEC := $DD09
+CIA2_TODMIN := $DD0A
+CIA2_TODHR := $DD0B
+CIA2_SDR := $DD0C
+CIA2_ICR := $DD0D
+CIA2_CRA := $DD0E
+CIA2_CRB := $DD0F
+
+; ---------------------------------------------------------------------------
+; Super CPU
+
+SCPU_VIC_Bank1 := $D075
+SCPU_Slow := $D07A
+SCPU_Fast := $D07B
+SCPU_EnableRegs := $D07E
+SCPU_DisableRegs:= $D07F
+SCPU_Detect := $D0BC
+
+
+; ---------------------------------------------------------------------------
+; Processor Port at $01
+
+LORAM = $01 ; Enable the basic rom
+HIRAM = $02 ; Enable the kernal rom
+IOEN = $04 ; Enable I/O
+CASSDATA = $08 ; Cassette data
+CASSPLAY = $10 ; Cassette: Play
+CASSMOT = $20 ; Cassette motor on
+TP_FAST = $80 ; Switch Rossmoeller TurboProcess to fast mode
+
+RAMONLY = $F8 ; (~(LORAM | HIRAM | IOEN)) & $FF
+; Convert characters to screen codes
+
+; Macro that converts one character.
+; scrbyte() can be used as an instruction operand
+.define scrbyte(code) (<(.strat ("h@dbdlhh", code >> 5) << 4) ^ code)
+
+; Helper macro that stores one character
+.macro _scrcode char
+ .if (char < 256)
+ .byte scrbyte {char}
+ .else
+ .error "scrcode: Character constant out of range"
+ .endif
+.endmacro
+
+.macro scrcode arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
+
+ ; Bail out if next argument is empty
+ .if .blank ({arg1})
+ .exitmacro
+ .endif
+
+ ; Check for a string
+ .if .match ({arg1}, "")
+
+ ; Walk over all string chars
+ .repeat .strlen (arg1), i
+ _scrcode {.strat (arg1, i)}
+ .endrepeat
+
+ ; Check for a number
+ .elseif .match (.left (1, {arg1}), 0)
+
+ ; Just output the number
+ _scrcode arg1
+
+ ; Check for a character
+ .elseif .match (.left (1, {arg1}), 'a')
+
+ ; Just output the character
+ _scrcode arg1
+
+ ; Anything else is an error
+ .else
+ .error "scrcode: invalid argument type"
+ .endif
+
+ ; Call the macro recursively with the remaining args
+ scrcode arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
+.endmacro
+;
+; Zero page variables and I/O definitions for the CBM 510
+;
+; Taken from a kernal disassembly done by myself in 2000/2001.
+;
+; 2001-09-13, Ullrich von Bassewitz
+; 2014-04-02, Greg King
+
+
+;-----------------------------------------------------------------------------
+; Zeropage stuff
+
+ExecReg := $00 ; Controls execution memory bank
+IndReg := $01 ; Controls indirect indexed load-store bank
+
+TXTPTR := $85 ; Far pointer into BASIC source code
+FNAM := $90 ; Far pointer to LOAD/SAVE file-name
+FNAM_LEN := $9D ; Holds length of file-name
+
+; ---------------------------------------------------------------------------
+; Screen size
+
+XSIZE = 40
+YSIZE = 25
+
+;-----------------------------------------------------------------------------
+; I/O Definitions
+; Note: These numbers aren't addresses. They are offsets from the start of
+; each chip's register set. They are used in the indirect indexed addressing
+; mode.
+
+; I/O $d800: VIC-II
+
+VIC_SPR0_X = $00
+VIC_SPR0_Y = $01
+VIC_SPR1_X = $02
+VIC_SPR1_Y = $03
+VIC_SPR2_X = $04
+VIC_SPR2_Y = $05
+VIC_SPR3_X = $06
+VIC_SPR3_Y = $07
+VIC_SPR4_X = $08
+VIC_SPR4_Y = $09
+VIC_SPR5_X = $0A
+VIC_SPR5_Y = $0B
+VIC_SPR6_X = $0C
+VIC_SPR6_Y = $0D
+VIC_SPR7_X = $0E
+VIC_SPR7_Y = $0F
+VIC_SPR_HI_X = $10
+VIC_SPR_ENA = $15
+VIC_SPR_EXP_Y = $17
+VIC_SPR_EXP_X = $1D
+VIC_SPR_MCOLOR = $1C
+VIC_SPR_BG_PRIO = $1B
+
+VIC_SPR_MCOLOR0 = $25
+VIC_SPR_MCOLOR1 = $26
+
+VIC_SPR0_COLOR = $27
+VIC_SPR1_COLOR = $28
+VIC_SPR2_COLOR = $29
+VIC_SPR3_COLOR = $2A
+VIC_SPR4_COLOR = $2B
+VIC_SPR5_COLOR = $2C
+VIC_SPR6_COLOR = $2D
+VIC_SPR7_COLOR = $2E
+
+VIC_CTRL1 = $11
+VIC_CTRL2 = $16
+
+VIC_HLINE = $12
+
+VIC_LPEN_X = $13
+VIC_LPEN_Y = $14
+
+VIC_VIDEO_ADR = $18
+
+VIC_IRR = $19 ; Interrupt request register
+VIC_IMR = $1A ; Interrupt mask register
+
+VIC_BORDERCOLOR = $20
+VIC_BG_COLOR0 = $21
+VIC_BG_COLOR1 = $22
+VIC_BG_COLOR2 = $23
+VIC_BG_COLOR3 = $24
+
+
+; I/O $da00: SID 6581
+
+SID_S1Lo = $00
+SID_S1Hi = $01
+SID_PB1Lo = $02
+SID_PB1Hi = $03
+SID_Ctl1 = $04
+SID_AD1 = $05
+SID_SUR1 = $06
+
+SID_S2Lo = $07
+SID_S2Hi = $08
+SID_PB2Lo = $09
+SID_PB2Hi = $0A
+SID_Ctl2 = $0B
+SID_AD2 = $0C
+SID_SUR2 = $0D
+
+SID_S3Lo = $0E
+SID_S3Hi = $0F
+SID_PB3Lo = $10
+SID_PB3Hi = $11
+SID_Ctl3 = $12
+SID_AD3 = $13
+SID_SUR3 = $14
+
+SID_FltLo = $15
+SID_FltHi = $16
+SID_FltCtl = $17
+SID_Amp = $18
+SID_ADConv1 = $19
+SID_ADConv2 = $1A
+SID_Noise = $1B
+SID_Read3 = $1C
+
+
+; I/O $db00: CIA 6526, Inter Process Communication
+; I/O $dc00: CIA 6526
+
+.struct CIA
+ PRA .byte
+ PRB .byte
+ DDRA .byte
+ DDRB .byte
+ .union
+ .struct
+ TALO .byte
+ TAHI .byte
+ .endstruct
+ TA .word
+ .endunion
+ .union
+ .struct
+ TBLO .byte
+ TBHI .byte
+ .endstruct
+ TB .word
+ .endunion
+ TOD10 .byte
+ TODSEC .byte
+ TODMIN .byte
+ TODHR .byte
+ SDR .byte
+ ICR .byte
+ CRA .byte
+ CRB .byte
+.endstruct
+
+
+; I/O $dd00: ACIA 6551
+
+.struct ACIA
+ DATA .byte
+ STATUS .byte
+ CMD .byte
+ CTRL .BYTE
+.endstruct
+
+
+; I/O $de00: Triport #1 6525
+; I/O $df00: Triport #2 6525
+
+.struct TPI
+ PRA .byte
+ PRB .byte
+ .union
+ PRC .byte
+ INT .byte
+ .endunion
+ DDRA .byte
+ DDRB .byte
+ .union
+ DDRC .byte
+ IMR .byte
+ .endunion
+ CR .byte
+ AIR .byte
+.endstruct
+
+
+;-----------------------------------------------------------------------------
+; Our video memory address
+
+COLOR_RAM := $D400 ; System bank
+
+
+;-----------------------------------------------------------------------------
+
+BASIC_BUF := $FB5E ; Bank 0 location of command-line
+BASIC_BUF_LEN = 162 ; Maximum length of command-line
+;
+; Zero page variables and I/O definitions for the CBM 610
+;
+; Taken from a kernal disassembly done by myself in 1987.
+;
+; 1998-09-28, Ullrich von Bassewitz
+; 2014-04-02, Greg King
+
+
+; ---------------------------------------------------------------------------
+; Zeropage stuff
+
+ExecReg := $00 ; Controls execution memory bank
+IndReg := $01 ; Controls indirect indexed load-store bank
+
+TXTPTR := $85 ; Far pointer into BASIC source code
+FNAM := $90 ; Far pointer to LOAD/SAVE file-name
+FNAM_LEN := $9D ; Holds length of file-name
+
+; ---------------------------------------------------------------------------
+; Screen size
+
+XSIZE = 80
+YSIZE = 25
+
+; ---------------------------------------------------------------------------
+; I/O definitions
+
+
+; I/O $d800: CRTC 6545
+
+.struct CRTC
+ ADDR .byte
+ DATA .byte
+.endstruct
+
+
+; I/O $db00: CIA 6526, Inter Process Communication
+;
+; IPCcia = $db00
+
+.struct CIA
+ PRA .byte
+ PRB .byte
+ DDRA .byte
+ DDRB .byte
+ .union
+ .struct
+ TALO .byte
+ TAHI .byte
+ .endstruct
+ TA .word
+ .endunion
+ .union
+ .struct
+ TBLO .byte
+ TBHI .byte
+ .endstruct
+ TB .word
+ .endunion
+ TOD10 .byte
+ TODSEC .byte
+ TODMIN .byte
+ TODHR .byte
+ SDR .byte
+ ICR .byte
+ CRA .byte
+ CRB .byte
+.endstruct
+
+
+; I/O $dc00: CIA 6526
+;
+; cia = $dc00
+
+
+; I/O $dd00: ACIA 6551
+;
+; acia = $dd00
+
+.struct ACIA
+ DATA .byte
+ STATUS .byte
+ CMD .byte
+ CTRL .BYTE
+.endstruct
+
+
+; I/O $de00: Triport #1 6525
+;
+; tpi1 = $de00
+
+.struct TPI
+ PRA .byte
+ PRB .byte
+ .union
+ PRC .byte
+ INT .byte
+ .endunion
+ DDRA .byte
+ DDRB .byte
+ .union
+ DDRC .byte
+ IMR .byte
+ .endunion
+ CR .byte
+ AIR .byte
+.endstruct
+
+
+; I/O $df00: Triport #2 6525
+
+; tpi2 = $df00
+
+
+;-----------------------------------------------------------------------------
+
+BASIC_BUF := $FA5E ; Bank 1 location of command-line
+BASIC_BUF_LEN = 162 ; Maximum length of command-line
+;
+; Definitions for CBM file types. From cbm.h
+;
+; Ullrich von Bassewitz, 2012-06-03
+;
+
+; Define bitmapped constants for the table entries
+
+.enum
+ CBM_T_REG = $10 ; Bit set for regular files
+ CBM_T_SEQ = $10 ; Sequential file
+ CBM_T_PRG = $11 ; Program file
+ CBM_T_USR = $12 ; User file
+ CBM_T_REL = $13 ; Relative file
+ CBM_T_VRP = $14 ; Vorpal fast-loadable format
+ CBM_T_DEL = $00 ; Deleted file
+ CBM_T_CBM = $01 ; 1581 sub-partition
+ CBM_T_DIR = $02 ; IDE64 and CMD sub-directory
+ CBM_T_LNK = $03 ; IDE64 soft-link
+ CBM_T_OTHER = $04 ; File-type not recognized
+ CBM_T_HEADER = $05 ; Disk header / title
+.endenum
+
+
+; The following function maps the start character for a file type to
+; one of the file types above. Note: 'd' will always mapped to CBM_T_DEL.
+; The calling function has to look at the following character to determine
+; if the file type is actually CBM_T_DIR.
+;
+; unsigned char __fastcall__ _cbm_filetype (unsigned char c);
+
+ .global __cbm_filetype
+
+
+;
+; Olli Savia
+; Greg King
+;
+; Commodore-compatibles Kernal functions
+;
+
+.if .def(__CX16__)
+ ; CX16 extended jump table
+ KBDBUF_PEEK := $FEBD
+ KBDBUF_GET_MODIFIERS := $FEC0
+ KBDBUF_PUT := $FEC3
+ I2C_READ_BYTE := $FEC6
+ I2C_WRITE_BYTE := $FEC9
+ CX_MONITOR := $FECC
+ ENTROPY_GET := $FECF
+ CONSOLE_SET_PAGE_MSG := $FED5
+ CONSOLE_PUT_IMAGE := $FED8
+ CONSOLE_INIT := $FEDB
+ CONSOLE_PUT_CHAR := $FEDE
+ CONSOLE_GET_CHAR := $FEE1
+ MEMORY_FILL := $FEE4
+ MEMORY_COPY := $FEE7
+ MEMORY_CRC := $FEEA
+ MEMORY_DECOMPRESS := $FEED
+ SPRITE_SET_IMAGE := $FEF0
+ SPRITE_SET_POSITION := $FEF3
+ FB_INIT := $FEF6
+ FB_GET_INFO := $FEF9
+ FB_SET_PALETTE := $FEFC
+ FB_CURSOR_POSITION := $FEFF
+ FB_CURSOR_NEXT_LINE := $FF02
+ FB_GET_PIXEL := $FF05
+ FB_GET_PIXELS := $FF08
+ FB_SET_PIXEL := $FF0B
+ FB_SET_PIXELS := $FF0E
+ FB_SET_8_PIXELS := $FF11
+ FB_SET_8_PIXELS_OPAQUE := $FF14
+ FB_FILL_PIXELS := $FF17
+ FB_FILTER_PIXELS := $FF1A
+ FB_MOVE_PIXELS := $FF1D
+ GRAPH_INIT := $FF20
+ GRAPH_CLEAR := $FF23
+ GRAPH_SET_WINDOW := $FF26
+ GRAPH_SET_COLORS := $FF29
+ GRAPH_DRAW_LINE := $FF2C
+ GRAPH_DRAW_RECT := $FF2F
+ GRAPH_MOVE_RECT := $FF32
+ GRAPH_DRAW_OVAL := $FF35
+ GRAPH_DRAW_IMAGE := $FF38
+ GRAPH_SET_FONT := $FF3B
+ GRAPH_GET_CHAR_SIZE := $FF3E
+ GRAPH_PUT_CHAR := $FF41
+ MULTI_ACPTR := $FF44
+ RESTORE_BASIC := $FF47
+ CLOCK_SET_DATE_TIME := $FF4D
+ CLOCK_GET_DATE_TIME := $FF50
+ JOYSTICK_SCAN := $FF53
+ JOYSTICK_GET := $FF56
+ SCREEN_MODE := $FF5F
+ SCREEN_SET_CHARSET := $FF62
+ MOUSE_CONFIG := $FF68
+ MOUSE_GET := $FF6B
+.endif
+
+.if .def(__C128__)
+ ; C128 extended jump table
+ C64MODE := $FF4D
+ SWAPPER := $FF5F
+ SETBNK := $FF68
+.endif
+
+.if .def(__C128__) || .def(__CX16__)
+ ; Extended jump table
+ CLSALL := $FF4A
+ LKUPLA := $FF59
+ LKUPSA := $FF5C
+ PFKEY := $FF65
+ JSRFAR := $FF6E
+ INDFET := $FF74
+ INDSTA := $FF77
+ INDCMP := $FF7A
+ PRIMM := $FF7D
+.endif
+
+.if .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__)
+ CINT := $FF81
+ IOINIT := $FF84
+ RAMTAS := $FF87
+.elseif .def(__VIC20__)
+ CINT := $E518 ; No entries are in the Kernal jump table of the VIC-20 for these three (3) functions.
+ IOINIT := $FDF9 ; The entries for these functions have been set to point directly to the functions
+ RAMTAS := $FD8D ; in the Kernal, to maintain compatibility with the other Commodore platforms.
+.elseif .def(__CBM510__) || .def(__CBM610__)
+ IOINIT := $FF7B
+ CINT := $FF7E
+.endif
+
+.if .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__)
+ RESTOR := $FF8A
+ VECTOR := $FF8D
+.elseif .def(__CBM510__) || .def(__CBM610__)
+ VECTOR := $FF84
+ RESTOR := $FF87
+.endif
+
+.if .def(__CBM510__) || .def(__CBM610__) || .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__)
+ SETMSG := $FF90
+ SECOND := $FF93
+ TKSA := $FF96
+ MEMTOP := $FF99
+ MEMBOT := $FF9C
+ SCNKEY := $FF9F
+ SETTMO := $FFA2
+ ACPTR := $FFA5
+ CIOUT := $FFA8
+ UNTLK := $FFAB
+ UNLSN := $FFAE
+ LISTEN := $FFB1
+ TALK := $FFB4
+ READST := $FFB7
+ SETLFS := $FFBA
+ SETNAM := $FFBD
+ OPEN := $FFC0
+ CLOSE := $FFC3
+.endif
+
+; Available on all platforms including PET
+CHKIN := $FFC6
+CKOUT := $FFC9
+CHKOUT := $FFC9
+CLRCH := $FFCC
+CLRCHN := $FFCC
+BASIN := $FFCF
+CHRIN := $FFCF
+BSOUT := $FFD2
+CHROUT := $FFD2
+
+.if .def(__CBM510__) || .def(__CBM610__) || .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__)
+ LOAD := $FFD5
+ SAVE := $FFD8
+ SETTIM := $FFDB
+ RDTIM := $FFDE
+.endif
+
+; Available on all platforms including PET
+STOP := $FFE1
+GETIN := $FFE4
+CLALL := $FFE7
+UDTIM := $FFEA
+
+.if .def(__CBM510__) || .def(__CBM610__) || .def(__VIC20__) || .def(__C64__) || .def(__C128__) || .def(__C16__) || .def(__CX16__)
+ SCREEN := $FFED
+ PLOT := $FFF0
+ IOBASE := $FFF3
+.endif
+
+; ---------------------------------------------------------------------------
+; Kernal routines, direct entries
+;
+; Unlike the above, these are not standard functions with entries in the jump
+; table. They do not exist in all Kernals, and where they do the entry point is
+; specific to that particular machine and possibly even Kernal version.
+;
+; This list is not comprehensive: missing items for particular machines
+; should be added as needed.
+;
+; UPDCRAMPTR: Updates the color RAM pointer to match the screen RAM pointer.
+;
+
+.if .def(__VIC20__)
+ CLRSCR := $E55F
+ KBDREAD := $E5CF
+ UPDCRAMPTR := $EAB2
+.elseif .def(__C64__)
+ CLRSCR := $E544
+ KBDREAD := $E5B4
+ NMIEXIT := $FEBC
+ UPDCRAMPTR := $EA24
+.elseif .def(__C128__)
+ CLRSCR := $C142
+ KBDREAD := $C006
+ NMIEXIT := $FF33
+ NEWLINE := $C363
+ PRINT := $C322
+ CURS_SET := $CD57
+ CURS_ON := $CD6F
+ CURS_OFF := $CD9F
+.elseif .def(__C16__)
+ CLRSCR := $D88B
+ KBDREAD := $D8C1
+.endif
+;/*****************************************************************************/
+;/* */
+;/* cbm_petscii_charmap.inc */
+;/* */
+;/* CBM system standard string mapping ISO-8859-1 -> PetSCII */
+;/* */
+;/* */
+;/* 2019-03-10, Greg King */
+;/* */
+;/* This software is provided "as-is", without any expressed or implied */
+;/* warranty. In no event will the authors be held liable for any damages */
+;/* arising from the use of this software. */
+;/* */
+;/* Permission is granted to anyone to use this software for any purpose, */
+;/* including commercial applications, and to alter it and redistribute it */
+;/* freely, subject to the following restrictions: */
+;/* */
+;/* 1. The origin of this software must not be misrepresented; you must not */
+;/* claim that you wrote the original software. If you use this software */
+;/* in a product, an acknowledgment in the product documentation would be */
+;/* appreciated, but is not required. */
+;/* 2. Altered source versions must be plainly marked as such, and must not */
+;/* be misrepresented as being the original software. */
+;/* 3. This notice must not be removed or altered from any source */
+;/* distribution. */
+;/* */
+;/*****************************************************************************/
+
+.charmap $00, $00
+.charmap $01, $01
+.charmap $02, $02
+.charmap $03, $03
+.charmap $04, $04
+.charmap $05, $05
+.charmap $06, $06
+.charmap $07, $07
+.charmap $08, $14
+.charmap $09, $09
+.charmap $0A, $0D
+.charmap $0B, $11
+.charmap $0C, $93
+.charmap $0D, $0A
+.charmap $0E, $0E
+.charmap $0F, $0F
+.charmap $10, $10
+.charmap $11, $0B
+.charmap $12, $12
+.charmap $13, $13
+.charmap $14, $08
+.charmap $15, $15
+.charmap $16, $16
+.charmap $17, $17
+.charmap $18, $18
+.charmap $19, $19
+.charmap $1A, $1A
+.charmap $1B, $1B
+.charmap $1C, $1C
+.charmap $1D, $1D
+.charmap $1E, $1E
+.charmap $1F, $1F
+
+.charmap $20, $20
+.charmap $21, $21
+.charmap $22, $22
+.charmap $23, $23
+.charmap $24, $24
+.charmap $25, $25
+.charmap $26, $26
+.charmap $27, $27
+.charmap $28, $28
+.charmap $29, $29
+.charmap $2A, $2A
+.charmap $2B, $2B
+.charmap $2C, $2C
+.charmap $2D, $2D
+.charmap $2E, $2E
+.charmap $2F, $2F
+.charmap $30, $30
+.charmap $31, $31
+.charmap $32, $32
+.charmap $33, $33
+.charmap $34, $34
+.charmap $35, $35
+.charmap $36, $36
+.charmap $37, $37
+.charmap $38, $38
+.charmap $39, $39
+.charmap $3A, $3A
+.charmap $3B, $3B
+.charmap $3C, $3C
+.charmap $3D, $3D
+.charmap $3E, $3E
+.charmap $3F, $3F
+
+.charmap $40, $40
+.charmap $41, $C1
+.charmap $42, $C2
+.charmap $43, $C3
+.charmap $44, $C4
+.charmap $45, $C5
+.charmap $46, $C6
+.charmap $47, $C7
+.charmap $48, $C8
+.charmap $49, $C9
+.charmap $4A, $CA
+.charmap $4B, $CB
+.charmap $4C, $CC
+.charmap $4D, $CD
+.charmap $4E, $CE
+.charmap $4F, $CF
+.charmap $50, $D0
+.charmap $51, $D1
+.charmap $52, $D2
+.charmap $53, $D3
+.charmap $54, $D4
+.charmap $55, $D5
+.charmap $56, $D6
+.charmap $57, $D7
+.charmap $58, $D8
+.charmap $59, $D9
+.charmap $5A, $DA
+.charmap $5B, $5B
+.charmap $5C, $BF
+.charmap $5D, $5D
+.charmap $5E, $5E
+.charmap $5F, $A4
+
+.charmap $60, $AD
+.charmap $61, $41
+.charmap $62, $42
+.charmap $63, $43
+.charmap $64, $44
+.charmap $65, $45
+.charmap $66, $46
+.charmap $67, $47
+.charmap $68, $48
+.charmap $69, $49
+.charmap $6A, $4A
+.charmap $6B, $4B
+.charmap $6C, $4C
+.charmap $6D, $4D
+.charmap $6E, $4E
+.charmap $6F, $4F
+.charmap $70, $50
+.charmap $71, $51
+.charmap $72, $52
+.charmap $73, $53
+.charmap $74, $54
+.charmap $75, $55
+.charmap $76, $56
+.charmap $77, $57
+.charmap $78, $58
+.charmap $79, $59
+.charmap $7A, $5A
+.charmap $7B, $B3
+.charmap $7C, $DD
+.charmap $7D, $AB
+.charmap $7E, $B1
+.charmap $7F, $DF
+
+.charmap $80, $80
+.charmap $81, $81
+.charmap $82, $82
+.charmap $83, $83
+.charmap $84, $84
+.charmap $85, $85
+.charmap $86, $86
+.charmap $87, $87
+.charmap $88, $88
+.charmap $89, $89
+.charmap $8A, $8A
+.charmap $8B, $8B
+.charmap $8C, $8C
+.charmap $8D, $8D
+.charmap $8E, $8E
+.charmap $8F, $8F
+.charmap $90, $90
+.charmap $91, $91
+.charmap $92, $92
+.charmap $93, $0C
+.charmap $94, $94
+.charmap $95, $95
+.charmap $96, $96
+.charmap $97, $97
+.charmap $98, $98
+.charmap $99, $99
+.charmap $9A, $9A
+.charmap $9B, $9B
+.charmap $9C, $9C
+.charmap $9D, $9D
+.charmap $9E, $9E
+.charmap $9F, $9F
+
+.charmap $A0, $A0
+.charmap $A1, $A1
+.charmap $A2, $A2
+.charmap $A3, $A3
+.charmap $A4, $A4
+.charmap $A5, $A5
+.charmap $A6, $A6
+.charmap $A7, $A7
+.charmap $A8, $A8
+.charmap $A9, $A9
+.charmap $AA, $AA
+.charmap $AB, $AB
+.charmap $AC, $AC
+.charmap $AD, $AD
+.charmap $AE, $AE
+.charmap $AF, $AF
+.charmap $B0, $B0
+.charmap $B1, $B1
+.charmap $B2, $B2
+.charmap $B3, $B3
+.charmap $B4, $B4
+.charmap $B5, $B5
+.charmap $B6, $B6
+.charmap $B7, $B7
+.charmap $B8, $B8
+.charmap $B9, $B9
+.charmap $BA, $BA
+.charmap $BB, $BB
+.charmap $BC, $BC
+.charmap $BD, $BD
+.charmap $BE, $BE
+.charmap $BF, $BF
+
+.charmap $C0, $60
+.charmap $C1, $61
+.charmap $C2, $62
+.charmap $C3, $63
+.charmap $C4, $64
+.charmap $C5, $65
+.charmap $C6, $66
+.charmap $C7, $67
+.charmap $C8, $68
+.charmap $C9, $69
+.charmap $CA, $6A
+.charmap $CB, $6B
+.charmap $CC, $6C
+.charmap $CD, $6D
+.charmap $CE, $6E
+.charmap $CF, $6F
+.charmap $D0, $70
+.charmap $D1, $71
+.charmap $D2, $72
+.charmap $D3, $73
+.charmap $D4, $74
+.charmap $D5, $75
+.charmap $D6, $76
+.charmap $D7, $77
+.charmap $D8, $78
+.charmap $D9, $79
+.charmap $DA, $7A
+.charmap $DB, $7B
+.charmap $DC, $7C
+.charmap $DD, $7D
+.charmap $DE, $7E
+.charmap $DF, $7F
+
+.charmap $E0, $E0
+.charmap $E1, $E1
+.charmap $E2, $E2
+.charmap $E3, $E3
+.charmap $E4, $E4
+.charmap $E5, $E5
+.charmap $E6, $E6
+.charmap $E7, $E7
+.charmap $E8, $E8
+.charmap $E9, $E9
+.charmap $EA, $EA
+.charmap $EB, $EB
+.charmap $EC, $EC
+.charmap $ED, $ED
+.charmap $EE, $EE
+.charmap $EF, $EF
+.charmap $F0, $F0
+.charmap $F1, $F1
+.charmap $F2, $F2
+.charmap $F3, $F3
+.charmap $F4, $F4
+.charmap $F5, $F5
+.charmap $F6, $F6
+.charmap $F7, $F7
+.charmap $F8, $F8
+.charmap $F9, $F9
+.charmap $FA, $FA
+.charmap $FB, $FB
+.charmap $FC, $FC
+.charmap $FD, $FD
+.charmap $FE, $FE
+.charmap $FF, $FF
+;/*****************************************************************************/
+;/* */
+;/* cbm_screen_charmap.inc */
+;/* */
+;/* c Copyright 2019, Gerhard W. Gruber (sparhawk@gmx.at) */
+;/* */
+;/* When using CBM mode, this include converts character literals */
+;/* from ASCII to screen-code mapping, so you can write directly */
+;/* to the screen memory. */
+;/* */
+;/* If this include is used, no additional macros are needed. */
+;/* */
+;/*****************************************************************************/
+
+; Char $00 -> c + 128
+.charmap $00, $80
+
+; Char $01 ... $1A -> c + 128 + 64 control alphabet
+.charmap $01, $C1
+.charmap $02, $C2
+.charmap $03, $C3
+.charmap $04, $C4
+.charmap $05, $C5
+.charmap $06, $C6
+.charmap $07, $C7
+.charmap $08, $C8
+.charmap $09, $C9
+.charmap $0A, $CA
+.charmap $0B, $CB
+.charmap $0C, $CC
+.charmap $0D, $CD
+.charmap $0E, $CE
+.charmap $0F, $CF
+.charmap $10, $D0
+.charmap $11, $D1
+.charmap $12, $D2
+.charmap $13, $D3
+.charmap $14, $D4
+.charmap $15, $D5
+.charmap $16, $D6
+.charmap $17, $D7
+.charmap $18, $D8
+.charmap $19, $D9
+.charmap $1A, $DA
+
+; Char $1B ... $1F -> c + 128
+.charmap $1B, $9B
+.charmap $1C, $9C
+.charmap $1D, $9D
+.charmap $1E, $9E
+.charmap $1F, $9F
+
+; Char $20 ... $3F -> c
+.charmap $20, $20
+.charmap $21, $21
+.charmap $22, $22
+.charmap $23, $23
+.charmap $24, $24
+.charmap $25, $25
+.charmap $26, $26
+.charmap $27, $27
+.charmap $28, $28
+.charmap $29, $29
+.charmap $2A, $2A
+.charmap $2B, $2B
+.charmap $2C, $2C
+.charmap $2D, $2D
+.charmap $2E, $2E
+.charmap $2F, $2F
+.charmap $30, $30
+.charmap $31, $31
+.charmap $32, $32
+.charmap $33, $33
+.charmap $34, $34
+.charmap $35, $35
+.charmap $36, $36
+.charmap $37, $37
+.charmap $38, $38
+.charmap $39, $39
+.charmap $3A, $3A
+.charmap $3B, $3B
+.charmap $3C, $3C
+.charmap $3D, $3D
+.charmap $3E, $3E
+.charmap $3F, $3F
+
+; Char $40 -> c - 64
+.charmap $40, $00
+
+; Char $41 ... $5A -> c upper-case alphabet
+.charmap $41, $41
+.charmap $42, $42
+.charmap $43, $43
+.charmap $44, $44
+.charmap $45, $45
+.charmap $46, $46
+.charmap $47, $47
+.charmap $48, $48
+.charmap $49, $49
+.charmap $4A, $4A
+.charmap $4B, $4B
+.charmap $4C, $4C
+.charmap $4D, $4D
+.charmap $4E, $4E
+.charmap $4F, $4F
+.charmap $50, $50
+.charmap $51, $51
+.charmap $52, $52
+.charmap $53, $53
+.charmap $54, $54
+.charmap $55, $55
+.charmap $56, $56
+.charmap $57, $57
+.charmap $58, $58
+.charmap $59, $59
+.charmap $5A, $5A
+
+; Char $5B ... $5F -> c - 64
+.charmap $5B, $1B
+.charmap $5C, $1C
+.charmap $5D, $1D
+.charmap $5E, $1E
+.charmap $5F, $1F
+
+; Char $60 -> c - 32
+.charmap $60, $40
+
+; Char $61 ... $7A -> c - 32 - 64 lower-case alphabet
+.charmap $61, $01
+.charmap $62, $02
+.charmap $63, $03
+.charmap $64, $04
+.charmap $65, $05
+.charmap $66, $06
+.charmap $67, $07
+.charmap $68, $08
+.charmap $69, $09
+.charmap $6A, $0A
+.charmap $6B, $0B
+.charmap $6C, $0C
+.charmap $6D, $0D
+.charmap $6E, $0E
+.charmap $6F, $0F
+.charmap $70, $10
+.charmap $71, $11
+.charmap $72, $12
+.charmap $73, $13
+.charmap $74, $14
+.charmap $75, $15
+.charmap $76, $16
+.charmap $77, $17
+.charmap $78, $18
+.charmap $79, $19
+.charmap $7A, $1A
+
+; Char $7B ... $7F -> c - 32
+.charmap $7B, $5B
+.charmap $7C, $5C
+.charmap $7D, $5D
+.charmap $7E, $5E
+.charmap $7F, $5F
+
+; Char $80 -> c + 64
+.charmap $80, $C0
+
+; Char $81 ... $9A -> c control alphabet
+.charmap $81, $81
+.charmap $82, $82
+.charmap $83, $83
+.charmap $84, $84
+.charmap $85, $85
+.charmap $86, $86
+.charmap $87, $87
+.charmap $88, $88
+.charmap $89, $89
+.charmap $8A, $8A
+.charmap $8B, $8B
+.charmap $8C, $8C
+.charmap $8D, $8D
+.charmap $8E, $8E
+.charmap $8F, $8F
+.charmap $90, $90
+.charmap $91, $91
+.charmap $92, $92
+.charmap $93, $93
+.charmap $94, $94
+.charmap $95, $95
+.charmap $96, $96
+.charmap $97, $97
+.charmap $98, $98
+.charmap $99, $99
+.charmap $9A, $9A
+
+; Char $9B ... $9F -> c + 64
+.charmap $9B, $DB
+.charmap $9C, $DC
+.charmap $9D, $DD
+.charmap $9E, $DE
+.charmap $9F, $DF
+
+; Char $A0 ... $BF -> c - 64
+.charmap $A0, $60
+.charmap $A1, $61
+.charmap $A2, $62
+.charmap $A3, $63
+.charmap $A4, $64
+.charmap $A5, $65
+.charmap $A6, $66
+.charmap $A7, $67
+.charmap $A8, $68
+.charmap $A9, $69
+.charmap $AA, $6A
+.charmap $AB, $6B
+.charmap $AC, $6C
+.charmap $AD, $6D
+.charmap $AE, $6E
+.charmap $AF, $6F
+.charmap $B0, $70
+.charmap $B1, $71
+.charmap $B2, $72
+.charmap $B3, $73
+.charmap $B4, $74
+.charmap $B5, $75
+.charmap $B6, $76
+.charmap $B7, $77
+.charmap $B8, $78
+.charmap $B9, $79
+.charmap $BA, $7A
+.charmap $BB, $7B
+.charmap $BC, $7C
+.charmap $BD, $7D
+.charmap $BE, $7E
+.charmap $BF, $7F
+
+; Char $C0 ... $DF -> c - 128
+.charmap $C0, $40
+
+; Char $C1 ... $DA -> c - 128 - 64 lower-case alphabet
+.charmap $C1, $01
+.charmap $C2, $02
+.charmap $C3, $03
+.charmap $C4, $04
+.charmap $C5, $05
+.charmap $C6, $06
+.charmap $C7, $07
+.charmap $C8, $08
+.charmap $C9, $09
+.charmap $CA, $0A
+.charmap $CB, $0B
+.charmap $CC, $0C
+.charmap $CD, $0D
+.charmap $CE, $0E
+.charmap $CF, $0F
+.charmap $D0, $10
+.charmap $D1, $11
+.charmap $D2, $12
+.charmap $D3, $13
+.charmap $D4, $14
+.charmap $D5, $15
+.charmap $D6, $16
+.charmap $D7, $17
+.charmap $D8, $18
+.charmap $D9, $19
+.charmap $DA, $1A
+
+; Char $DB ... $DF -> c - 128
+.charmap $DB, $5B
+.charmap $DC, $5C
+.charmap $DD, $5D
+.charmap $DE, $5E
+.charmap $DF, $5F
+
+; Char $E0 ... $FF -> c - 128
+.charmap $E0, $60
+.charmap $E1, $61
+.charmap $E2, $62
+.charmap $E3, $63
+.charmap $E4, $64
+.charmap $E5, $65
+.charmap $E6, $66
+.charmap $E7, $67
+.charmap $E8, $68
+.charmap $E9, $69
+.charmap $EA, $6A
+.charmap $EB, $6B
+.charmap $EC, $6C
+.charmap $ED, $6D
+.charmap $EE, $6E
+.charmap $EF, $6F
+.charmap $F0, $70
+.charmap $F1, $71
+.charmap $F2, $72
+.charmap $F3, $73
+.charmap $F4, $74
+.charmap $F5, $75
+.charmap $F6, $76
+.charmap $F7, $77
+.charmap $F8, $78
+.charmap $F9, $79
+.charmap $FA, $7A
+.charmap $FB, $7B
+.charmap $FC, $7C
+.charmap $FD, $7D
+.charmap $FE, $7E
+.charmap $FF, $7F
+; CPU bitmask constants
+CPU_ISET_NONE = $0001
+CPU_ISET_6502 = $0002
+CPU_ISET_6502X = $0004
+CPU_ISET_6502DTV = $0008
+CPU_ISET_65SC02 = $0010
+CPU_ISET_65C02 = $0020
+CPU_ISET_65816 = $0040
+CPU_ISET_SWEET16 = $0080
+CPU_ISET_HUC6280 = $0100
+;CPU_ISET_M740 = $0200 not actually implemented
+CPU_ISET_4510 = $0400
+
+; CPU capabilities
+CPU_NONE = CPU_ISET_NONE
+CPU_6502 = CPU_ISET_6502
+CPU_6502X = CPU_ISET_6502|CPU_ISET_6502X
+CPU_6502DTV = CPU_ISET_6502|CPU_ISET_6502X|CPU_ISET_6502DTV
+CPU_65SC02 = CPU_ISET_6502|CPU_ISET_65SC02
+CPU_65C02 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02
+CPU_65816 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65816
+CPU_SWEET16 = CPU_ISET_SWEET16
+CPU_HUC6280 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02|CPU_ISET_HUC6280
+CPU_4510 = CPU_ISET_6502|CPU_ISET_65SC02|CPU_ISET_65C02|CPU_ISET_4510
+;*
+;** VTech Creativision Definitions
+;*
+
+;** Screen
+SCREEN_ROWS = 24
+SCREEN_COLS = 32
+SCREEN_PTR := $3A
+CURSOR_X := $3C
+CURSOR_Y := $3D
+
+;** VDP
+VDP_DATA_R := $2000
+VDP_STATUS_R := $2001
+VDP_DATA_W := $3000
+VDP_CONTROL_W := $3001
+
+;** PIA
+PIA0_DATA := $1000
+PIA0_STATUS := $1001
+PIA1_DATA := $1002
+PIA1_STATUS := $1003
+
+;** General
+CH_VLINE = 33
+CH_HLINE = 34
+CH_ULCORNER = 35
+CH_URCORNER = 36
+CH_LLCORNER = 37
+CH_LRCORNER = 38
+
+;** I/O (Zero-page variables)
+ZP_KEYBOARD := $10
+ZP_JOY0_DIR := $11
+ZP_JOY1_DIR := $13
+ZP_JOY0_BUTTONS := $16
+ZP_JOY1_BUTTONS := $17
+
+;** Joystick direction values (ZP_JOY0_DIR/ZP_JOY1_DIR)
+JOY_N = $49
+JOY_NNE = $48
+JOY_NE = $47
+JOY_ENE = $46
+JOY_E = $45
+JOY_ESE = $44
+JOY_SE = $43
+JOY_SSE = $42
+JOY_S = $41
+JOY_SSW = $40
+JOY_SW = $4F
+JOY_WSW = $4E
+JOY_W = $4D
+JOY_WNW = $4C
+JOY_NW = $4B
+JOY_NNW = $4A
+
+;** BIOS routines
+BIOS_NMI_RESET_ADDR := $F808
+BIOS_PLAY_TUNE1 := $FBD6
+BIOS_PLAY_SONG := $FBED
+BIOS_PLAY_TUNE2 := $FCE6
+BIOS_WRITE_VDP_REG := $FE1F
+BIOS_QUIET_PSG := $FE54
+BIOS_POKE_PSG := $FE77
+BIOS_IRQ1_ADDR := $FF3F
+BIOS_IRQ2_ADDR := $FF52
+; ctype.inc
+;
+; This file is part of
+; cc65 - a freeware C compiler for 6502 based systems
+;
+; https://cc65.github.io
+;
+; See "LICENSE" file for legal information.
+;
+; Definitions for the character type tables
+;
+; Ullrich von Bassewitz, 08.09.2001
+;
+
+; Define bitmapped constants for the table entries
+
+CT_NONE = %00000000 ; Nothing special
+CT_LOWER = %00000001 ; 0 - Lower case char
+CT_UPPER = %00000010 ; 1 - Upper case char
+CT_DIGIT = %00000100 ; 2 - Numeric digit
+CT_XDIGIT = %00001000 ; 3 - Hex digit (both, lower and upper)
+CT_CTRL = %00010000 ; 4 - Control character
+CT_SPACE = %00100000 ; 5 - The space character itself
+CT_OTHER_WS = %01000000 ; 6 - Other whitespace ('\f', '\n', '\r', '\t' and '\v')
+CT_SPACE_TAB = %10000000 ; 7 - Space or tab character
+
+; Combined stuff
+CT_ALNUM = (CT_LOWER | CT_UPPER | CT_DIGIT)
+CT_ALPHA = (CT_LOWER | CT_UPPER)
+CT_CTRL_SPACE = (CT_CTRL | CT_SPACE)
+CT_NOT_PUNCT = (CT_SPACE | CT_CTRL | CT_DIGIT | CT_UPPER | CT_LOWER)
+; ctype_common.inc
+;
+; This file is part of
+; cc65 - a freeware C compiler for 6502 based systems
+;
+; https://cc65.github.io
+;
+; See "LICENSE" file for legal information.
+;
+; Character specification table for some common targets.
+;
+
+ .include "ctypetable.inc"
+ .export __ctypeidx
+
+; The tables are readonly, put them into the rodata segment
+
+.rodata
+
+__ctypeidx:
+ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 0/00 ___ctrl_@___, 1/01 ___ctrl_A___
+ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 2/02 ___ctrl_B___, 3/03 ___ctrl_C___
+ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 4/04 ___ctrl_D___, 5/05 ___ctrl_E___
+ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 6/06 ___ctrl_F___, 7/07 ___ctrl_G___
+ ct_mix CT_CTRL_IDX, CT_CTRL_WS_SPACETAB_IDX ; 8/08 ___ctrl_H___, 9/09 ___ctrl_I___
+ ct_mix CT_CTRL_WS_IDX, CT_CTRL_WS_IDX ; 10/0a ___ctrl_J___, 11/0b ___ctrl_K___
+ ct_mix CT_CTRL_WS_IDX, CT_CTRL_WS_IDX ; 12/0c ___ctrl_L___, 13/0d ___ctrl_M___
+ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 14/0e ___ctrl_N___, 15/0f ___ctrl_O___
+ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 16/10 ___ctrl_P___, 17/11 ___ctrl_Q___
+ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 18/12 ___ctrl_R___, 19/13 ___ctrl_S___
+ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 20/14 ___ctrl_T___, 21/15 ___ctrl_U___
+ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 22/16 ___ctrl_V___, 23/17 ___ctrl_W___
+ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 24/18 ___ctrl_X___, 25/19 ___ctrl_Y___
+ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 26/1a ___ctrl_Z___, 27/1b ___ctrl_[___
+ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 28/1c ___ctrl_\___, 29/1d ___ctrl_]___
+ ct_mix CT_CTRL_IDX, CT_CTRL_IDX ; 30/1e ___ctrl_^___, 31/1f ___ctrl_____
+
+ ct_mix CT_SPACE_SPACETAB_IDX, CT_NONE_IDX ; 32/20 ___SPACE___, 33/21 _____!_____
+ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 34/22 _____"_____, 35/23 _____#_____
+ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 36/24 _____$_____, 37/25 _____%_____
+ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 38/26 _____&_____, 39/27 _____'_____
+ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 40/28 _____(_____, 41/29 _____)_____
+ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 42/2a _____*_____, 43/2b _____+_____
+ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 44/2c _____,_____, 45/2d _____-_____
+ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 46/2e _____._____, 47/2f _____/_____
+ ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 48/30 _____0_____, 49/31 _____1_____
+ ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 50/32 _____2_____, 51/33 _____3_____
+ ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 52/34 _____4_____, 53/35 _____5_____
+ ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 54/36 _____6_____, 55/37 _____7_____
+ ct_mix CT_DIGIT_XDIGIT_IDX, CT_DIGIT_XDIGIT_IDX ; 56/38 _____8_____, 57/39 _____9_____
+ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 58/3a _____:_____, 59/3b _____;_____
+ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 60/3c _____<_____, 61/3d _____=_____
+ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 62/3e _____>_____, 63/3f _____?_____
+
+ ct_mix CT_NONE_IDX, CT_UPPER_XDIGIT_IDX ; 64/40 _____@_____, 65/41 _____A_____
+ ct_mix CT_UPPER_XDIGIT_IDX, CT_UPPER_XDIGIT_IDX ; 66/42 _____B_____, 67/43 _____C_____
+ ct_mix CT_UPPER_XDIGIT_IDX, CT_UPPER_XDIGIT_IDX ; 68/44 _____D_____, 69/45 _____E_____
+ ct_mix CT_UPPER_XDIGIT_IDX, CT_UPPER_IDX ; 70/46 _____F_____, 71/47 _____G_____
+ ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 72/48 _____H_____, 73/49 _____I_____
+ ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 74/4a _____J_____, 75/4b _____K_____
+ ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 76/4c _____L_____, 77/4d _____M_____
+ ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 78/4e _____N_____, 79/4f _____O_____
+ ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 80/50 _____P_____, 81/51 _____Q_____
+ ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 82/52 _____R_____, 83/53 _____S_____
+ ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 84/54 _____T_____, 85/55 _____U_____
+ ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 86/56 _____V_____, 87/57 _____W_____
+ ct_mix CT_UPPER_IDX, CT_UPPER_IDX ; 88/58 _____X_____, 89/59 _____Y_____
+ ct_mix CT_UPPER_IDX, CT_NONE_IDX ; 90/5a _____Z_____, 91/5b _____[_____
+ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 92/5c _____\_____, 93/5d _____]_____
+ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 94/5e _____^_____, 95/5f _UNDERLINE_
+
+ ct_mix CT_NONE_IDX, CT_LOWER_XDIGIT_IDX ; 96/60 ___grave___, 97/61 _____a_____
+ ct_mix CT_LOWER_XDIGIT_IDX, CT_LOWER_XDIGIT_IDX ; 98/62 _____b_____, 99/63 _____c_____
+ ct_mix CT_LOWER_XDIGIT_IDX, CT_LOWER_XDIGIT_IDX ; 100/64 _____d_____, 101/65 _____e_____
+ ct_mix CT_LOWER_XDIGIT_IDX, CT_LOWER_IDX ; 102/66 _____f_____, 103/67 _____g_____
+ ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 104/68 _____h_____, 105/69 _____i_____
+ ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 106/6a _____j_____, 107/6b _____k_____
+ ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 108/6c _____l_____, 109/6d _____m_____
+ ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 110/6e _____n_____, 111/6f _____o_____
+ ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 112/70 _____p_____, 113/71 _____q_____
+ ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 114/72 _____r_____, 115/73 _____s_____
+ ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 116/74 _____t_____, 117/75 _____u_____
+ ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 118/76 _____v_____, 119/77 _____w_____
+ ct_mix CT_LOWER_IDX, CT_LOWER_IDX ; 120/78 _____x_____, 121/79 _____y_____
+ ct_mix CT_LOWER_IDX, CT_NONE_IDX ; 122/7a _____z_____, 123/7b _____{_____
+ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 124/7c _____|_____, 125/7d _____}_____
+ ct_mix CT_NONE_IDX, CT_WS_IDX ; 126/7e _____~_____, 127/7f ____DEL____
+
+.repeat 64
+ ct_mix CT_NONE_IDX, CT_NONE_IDX ; 128-255
+.endrepeat
+; ctypetable.inc
+;
+; This file is part of
+; cc65 - a freeware C compiler for 6502 based systems
+;
+; https://cc65.github.io
+;
+; See "LICENSE" file for legal information.
+;
+; Data covering all possible combinations of character flags for target specific definition
+;
+
+.include "ctype.inc"
+.export __ctype
+
+; Table definition covering all possible ctype combinations
+
+.rodata
+__ctype:
+ct_none: .byte CT_NONE
+ct_lower: .byte CT_LOWER
+ct_upper: .byte CT_UPPER
+ct_digit_xdigit: .byte CT_DIGIT | CT_XDIGIT
+ct_lower_xdigit: .byte CT_LOWER | CT_XDIGIT
+ct_upper_xdigit: .byte CT_UPPER | CT_XDIGIT
+ct_ctrl: .byte CT_CTRL
+ct_ws: .byte CT_OTHER_WS
+ct_ctrl_ws: .byte CT_CTRL | CT_OTHER_WS
+ct_space_spacetab: .byte CT_SPACE | CT_SPACE_TAB
+ct_ctrl_ws_spacetab: .byte CT_CTRL | CT_OTHER_WS | CT_SPACE_TAB
+
+; build indices out of the table above:
+
+CT_NONE_IDX = ct_none - __ctype
+CT_LOWER_IDX = ct_lower - __ctype
+CT_UPPER_IDX = ct_upper - __ctype
+CT_DIGIT_XDIGIT_IDX = ct_digit_xdigit - __ctype
+CT_LOWER_XDIGIT_IDX = ct_lower_xdigit - __ctype
+CT_UPPER_XDIGIT_IDX = ct_upper_xdigit - __ctype
+CT_CTRL_IDX = ct_ctrl - __ctype
+CT_WS_IDX = ct_ws - __ctype
+CT_CTRL_WS_IDX = ct_ctrl_ws - __ctype
+CT_SPACE_SPACETAB_IDX = ct_space_spacetab - __ctype
+CT_CTRL_WS_SPACETAB_IDX = ct_ctrl_ws_spacetab - __ctype
+
+.macro ct_mix lower, upper
+ .byte ((lower) & $0F) | ((upper) << 4)
+.endmacro
+;
+; CX16 r39 definitions
+;
+
+; ---------------------------------------------------------------------------
+; Constants
+
+.enum COLOR
+ BLACK = $00
+ WHITE
+ RED
+ CYAN
+ PURPLE
+ GREEN
+ BLUE
+ YELLOW
+ ORANGE
+ BROWN
+ PINK
+ LIGHTRED = PINK
+ GRAY1
+ GRAY2
+ LIGHTGREEN
+ LIGHTBLUE
+ GRAY3
+.endenum
+
+; Special characters
+.enum CH
+COLOR_SWAP = $01
+STOP = $03
+UNDERLINE
+WHITE
+BOLD
+BELL
+BACKSPACE
+TAB
+LINEFEED
+ITALIC
+OUTLINE
+ENTER
+FONT_LOWER
+FONT_ISO
+F9
+CURS_DOWN
+REVERSE
+HOME
+DEL
+F10
+F11
+F12
+SHIFT_TAB
+RED = $1C
+CURS_RIGHT
+GREEN
+BLUE
+LIRA = $5C
+ORANGE = $81
+RUN = $83
+HELP
+F1
+F3
+F5
+F7
+F2
+F4
+F6
+F8
+SHIFT_ENTER
+FONT_UPPER
+FONT_PET
+BLACK
+CURS_UP
+ATTR_CLEAR
+SCRN_CLEAR
+INS
+BROWN
+PINK
+LIGHTRED = PINK
+GRAY1
+GRAY2
+LIGHTGREEN
+LIGHTBLUE
+GRAY3
+PURPLE
+CURS_LEFT
+YELLOW
+CYAN
+SHIFT_SPACE
+LTEE = $AB
+LLCORNER = $AD
+URCORNER
+ULCORNER = $B0
+BTEE
+TTEE
+RTEE
+LRCORNER = $BD
+HLINE = $C0
+CROSS = $DB
+VLINE = $DD
+PI
+.endenum
+
+; ---------------------------------------------------------------------------
+; Zero page
+
+; Banking registers
+RAM_BANK := $00
+ROM_BANK := $01
+
+; GEOS and graphics pseudo-registers
+.struct gREG
+ .org $02
+ .union
+ r0 .word
+ .struct
+ r0L .byte
+ r0H .byte
+ .endstruct
+ .endunion
+ .union
+ r1 .word
+ .struct
+ r1L .byte
+ r1H .byte
+ .endstruct
+ .endunion
+ .union
+ r2 .word
+ .struct
+ r2L .byte
+ r2H .byte
+ .endstruct
+ .endunion
+ .union
+ r3 .word
+ .struct
+ r3L .byte
+ r3H .byte
+ .endstruct
+ .endunion
+ .union
+ r4 .word
+ .struct
+ r4L .byte
+ r4H .byte
+ .endstruct
+ .endunion
+ .union
+ r5 .word
+ .struct
+ r5L .byte
+ r5H .byte
+ .endstruct
+ .endunion
+ .union
+ r6 .word
+ .struct
+ r6L .byte
+ r6H .byte
+ .endstruct
+ .endunion
+ .union
+ r7 .word
+ .struct
+ r7L .byte
+ r7H .byte
+ .endstruct
+ .endunion
+ .union
+ r8 .word
+ .struct
+ r8L .byte
+ r8H .byte
+ .endstruct
+ .endunion
+ .union
+ r9 .word
+ .struct
+ r9L .byte
+ r9H .byte
+ .endstruct
+ .endunion
+ .union
+ r10 .word
+ .struct
+ r10L .byte
+ r10H .byte
+ .endstruct
+ .endunion
+ .union
+ r11 .word
+ .struct
+ r11L .byte
+ r11H .byte
+ .endstruct
+ .endunion
+ .union
+ r12 .word
+ .struct
+ r12L .byte
+ r12H .byte
+ .endstruct
+ .endunion
+ .union
+ r13 .word
+ .struct
+ r13L .byte
+ r13H .byte
+ .endstruct
+ .endunion
+ .union
+ r14 .word
+ .struct
+ r14L .byte
+ r14H .byte
+ .endstruct
+ .endunion
+ .union
+ r15 .word
+ .struct
+ r15L .byte
+ r15H .byte
+ .endstruct
+ .endunion
+.endstruct
+
+; Kernal
+KTEMP2 := $80 ; 2 bytes for temporary storage
+IMPARM := $82 ; Pointer for PRIMM function
+FNAM := $8A ; Pointer to filename
+
+; BASIC
+TXTPTR := $EE ; Pointer into BASIC source code
+
+; Page two
+
+BASIC_BUF := $0200 ; Location of command-line
+BASIC_BUF_LEN = 81 ; Maximum length of command-line
+
+SCREEN_PTR := $0262 ; Pointer to current row on text screen (16 bits)
+STATUS := $0287 ; Status from previous I/O operation
+IN_DEV := $028B ; Current input device number
+OUT_DEV := $028C ; Current output device number
+FNAM_LEN := $028F ; Length of filename
+SECADR := $0291 ; Secondary address
+DEVNUM := $0292 ; Device number
+CURS_COLOR := $0373 ; Color under the cursor
+CHARCOLOR := $0376 ; Cursor's color nybbles (high: background, low: foreground)
+RVS := $0377 ; Reverse flag
+CURS_FLAG := $037B ; 1 = cursor off
+CURS_BLINK := $037C ; Blink counter
+CURS_CHAR := $037D ; Character under the cursor
+CURS_STATE := $037E ; Cursor blink state
+CURS_X := $0380 ; Cursor column
+CURS_Y := $0383 ; Cursor row
+LLEN := $0386 ; Line length
+NLINES := $0387 ; Number of screen lines
+
+; BASIC
+VARTAB := $03E1 ; Pointer to start of BASIC variables
+MEMSIZE := $0259 ; Pointer to highest BASIC RAM location (+1)
+
+; ---------------------------------------------------------------------------
+; Vector and other locations
+
+IRQVec := $0314
+BRKVec := $0316
+NMIVec := $0318
+
+; ---------------------------------------------------------------------------
+; I/O locations
+
+; 65C22 Versatile Interface Adapter
+.struct VIA1 ; Versatile Interface Adapter
+ .org $9F00
+ PRB .byte ; mouse, LED, VIC bus (Port Register B)
+ PRA .byte ; keyboard, controllers (Port Register A)
+ DDRB .byte ; (Data Direction Register B)
+ DDRA .byte ; (Data Direction Register A)
+ T1 .word ; (Timer 1)
+ T1L .word ; (Timer 1 Latch)
+ T2 .word ; (Timer 2)
+ SR .byte ; (Shift Register)
+ ACR .byte ; (Auxiliary Control Register)
+ PCR .byte ; (Peripheral Control Register)
+ IFR .byte ; (Interrupt Flags Register)
+ IER .byte ; (Interrupt Enable Register)
+ PRA2 .byte ; keyboard, controllers (PRA without handshake)
+.endstruct
+
+; 65C22 Versatile Interface Adapter
+.struct VIA2
+ .org $9F10
+ PRB .byte
+ PRA .byte
+ DDRB .byte
+ DDRA .byte
+ T1 .word
+ T1L .word
+ T2 .word
+ SR .byte
+ ACR .byte
+ PCR .byte
+ IFR .byte
+ IER .byte
+ PRA2 .byte
+.endstruct
+
+; Video Enhanced Retro Adapter
+; Has audio and SPI.
+.scope VERA
+
+ ; External registers
+
+ .struct
+ .org $9F20
+ ADDR .faraddr ; Address for data port access
+ DATA0 .byte ; First data port
+ DATA1 .byte ; Second data port
+ CTRL .byte ; Control register
+ IRQ_EN .byte ; Interrupt enable bits
+ IRQ_FLAGS .byte ; Interrupt flags
+ IRQ_RASTER .byte ; Line where IRQ will occur
+ .endstruct
+ .enum ; Address automatic increment amounts
+ DEC0 = (($00 << 1) | $01) << 3
+ DEC1 = (($01 << 1) | $01) << 3
+ DEC2 = (($02 << 1) | $01) << 3
+ DEC4 = (($03 << 1) | $01) << 3
+ DEC8 = (($04 << 1) | $01) << 3
+ DEC16 = (($05 << 1) | $01) << 3
+ DEC32 = (($06 << 1) | $01) << 3
+ DEC64 = (($07 << 1) | $01) << 3
+ DEC128 = (($08 << 1) | $01) << 3
+ DEC256 = (($09 << 1) | $01) << 3
+ DEC512 = (($0A << 1) | $01) << 3
+ DEC40 = (($0B << 1) | $01) << 3
+ DEC80 = (($0C << 1) | $01) << 3
+ DEC160 = (($0D << 1) | $01) << 3
+ DEC320 = (($0E << 1) | $01) << 3
+ DEC640 = (($0F << 1) | $01) << 3
+ INC0 = (($00 << 1) | $00) << 3
+ INC1 = (($01 << 1) | $00) << 3
+ INC2 = (($02 << 1) | $00) << 3
+ INC4 = (($03 << 1) | $00) << 3
+ INC8 = (($04 << 1) | $00) << 3
+ INC16 = (($05 << 1) | $00) << 3
+ INC32 = (($06 << 1) | $00) << 3
+ INC64 = (($07 << 1) | $00) << 3
+ INC128 = (($08 << 1) | $00) << 3
+ INC256 = (($09 << 1) | $00) << 3
+ INC512 = (($0A << 1) | $00) << 3
+ INC40 = (($0B << 1) | $00) << 3
+ INC80 = (($0C << 1) | $00) << 3
+ INC160 = (($0D << 1) | $00) << 3
+ INC320 = (($0E << 1) | $00) << 3
+ INC640 = (($0F << 1) | $00) << 3
+ .endenum
+ .enum ; Interrupt request flags
+ VERT_SYNC = %00000001
+ RASTER_IRQ = %00000010
+ SPR_COLLIDED = %00000100
+ AUDIO_LOW = %00001000
+ .endenum
+ .scope DISP ; Display controller
+ SELECT1 = %00000010
+ .union
+ .org $9F29
+ .struct
+ ; These four registers are visible when the DCSEL flag = %0
+ VIDEO .byte
+ HSCALE .byte
+ VSCALE .byte
+ FRAME .byte
+ .endstruct
+ .struct
+ ; These four registers are visible when the DCSEL flag = %1
+ HSTART .byte
+ HSTOP .byte
+ VSTART .byte
+ VSTOP .byte
+ .endstruct
+ .endunion
+ .enum MODE ; Output mode
+ DISABLE = $00
+ VGA
+ NTSC
+ RGB ; Interlaced, composite sync
+ .endenum
+ .enum DISABLE
+ COLOR = %00000100 ; NTSC monochrome
+ .endenum
+ .enum ENABLE
+ LAYER0 = %00010000
+ LAYER1 = %00100000
+ SPRITES = %01000000
+ .endenum
+ .endscope
+ .struct L0 ; Display layer 0
+ .org $9F2D
+ CONFIG .byte
+ MAP_BASE .byte
+ TILE_BASE .byte
+ HSCROLL .word
+ VSCROLL .word
+ .endstruct
+ .struct L1 ; Display layer 1
+ .org $9F34
+ CONFIG .byte
+ MAP_BASE .byte
+ TILE_BASE .byte
+ HSCROLL .word
+ VSCROLL .word
+ .endstruct
+ .enum ; Layer display modes
+ TILE1BPP = %00000000 | $00
+ TILE2BPP
+ TILE4BPP
+ TILE8BPP
+ T256C = %00001000
+ BITMAP1BPP = %00000100 | $00
+ BITMAP2BPP
+ BITMAP4BPP
+ BITMAP8BPP
+ .endenum
+ .enum MAP ; Map geometry
+ WIDTH32 = $00 << 4
+ WIDTH64 = $01 << 4
+ WIDTH128 = $02 << 4
+ WIDTH256 = $03 << 4
+ HEIGHT32 = $00 << 6
+ HEIGHT64 = $01 << 6
+ HEIGHT128 = $02 << 6
+ HEIGHT256 = $03 << 6
+ .endenum
+ .enum TILE ; Tile geometry
+ WIDTH8 = $00
+ WIDTH16 = $01
+ WIDTH320 = WIDTH8
+ WIDTH640 = WIDTH16
+ HEIGHT8 = $00 << 1
+ HEIGHT16 = $01 << 1
+ .endenum
+ .scope PCM ; Pulse-Code Modulator
+ .struct
+ .org $9F3B
+ CTRL .byte
+ RATE .byte
+ DATA .byte
+ .endstruct
+ .enum
+ STEREO = %00010000
+ BITS16 = %00100000
+ RESET = %10000000
+ .endenum
+ .endscope
+ .scope SPI
+ .struct
+ .org $9F3E
+ DATA .byte
+ CTRL .byte
+ .endstruct
+ .enum
+ SELECT = %00000001
+ SLOW = %00000010
+ .endenum
+ .endscope
+
+ ; Internal RAM and registers
+
+ .struct
+ .org $000000
+ VRAM .res $020000 ; 128 Kibibytes
+ .endstruct
+ .scope PSG ; Programmable Sound Generator
+ .struct
+ PITCH .word
+ VOL .byte ; Right, left sides; volume
+ WAVEFORM .byte ; Wave shape, pulse width
+ .endstruct
+ LEFT = %01 << 6
+ RIGHT = %10 << 6
+ .enum
+ PULSE = $00 << 6
+ SAWTOOTH = $01 << 6
+ TRIANGLE = $02 << 6
+ NOISE = $03 << 6
+ .endenum
+ .struct
+ .org $01F9C0
+ VOICES .res $10 * 4
+ .endstruct
+ .endscope
+ .struct
+ .org $01FA00
+ PALETTE .word $0100
+ .endstruct
+ .scope SPRITE
+ .struct ; Sprite attributes
+ ADDR .addr ; Address and color mode
+ XX .word ; Co-ordinates
+ YY .word
+ Z_FLIP .byte ; Collision mask, Z-depth, flip bits
+ SIZE_PAL .byte
+ .endstruct
+ .enum FLIP
+ NONE = %00000000
+ HORIZ
+ VERT
+ BOTH
+ .endenum
+ .enum DEPTH
+ DISABLE = $00 << 2
+ CANVAS = $01 << 2
+ LAYER0 = $02 << 2
+ LAYER1 = $03 << 2
+ .endenum
+ .enum ; Sprite geometry
+ WIDTH8 = $00 << 4
+ WIDTH16 = $01 << 4
+ WIDTH32 = $02 << 4
+ WIDTH64 = $03 << 4
+ HEIGHT8 = $00 << 6
+ HEIGHT16 = $01 << 6
+ HEIGHT32 = $02 << 6
+ HEIGHT64 = $03 << 6
+ COLORS16 = $00 << 7
+ COLORS256 = $01 << 7
+ .endenum
+ .endscope
+ .struct
+ .org $01FC00
+ SPRITES .res 128 * 8
+ .endstruct
+.endscope
+
+; YM2151 audio chip
+.struct YM2151
+ .org $9F40
+ ADDR .byte
+ .union
+ DATA .byte
+ STATUS .byte
+ .endunion
+.endstruct
+
+; X16 Emulator device
+; This device doesn't exist on the real machine.
+.struct EMULATOR
+ .org $9FB0
+ DEBUG .byte ; Boolean: debugging enabled
+ VERALOG .byte ; Boolean: log VERA activity
+ KEYBOARDLOG .byte ; Boolean: log keyboard data
+ ECHO .byte ; Type of echo that's enabled
+ SAVEXIT .byte ; Boolean: save machine state on exit
+ GIFREC .byte ; Method of recording GIF movie
+ .res 2
+ CYCLECOUNT .dword ; Running count of CPU cycles (Read-Only)
+ .res 1
+ KEYMAP .byte ; Current keyboard layout number (Read-Only)
+ DETECT .byte 2 ; If is "16" string, then running on emulator (RO)
+.endstruct
+
+; ---------------------------------------------------------------------------
+; Banked RAM and ROM
+
+TIMER := $A03B ; (bank 0) 60 Hz. timer (3 bytes, big-endian)
+
+.struct BANK
+ .org $A000
+ RAM .res $2000 ; 8 Kibibyte window into 512 Kibibytes or 2048 Kibibytes
+ ROM .res $4000 ; 16 Kibibyte window into 128 Kibibytes
+.endstruct
+;/*****************************************************************************/
+;/* */
+;/* em-error.inc */
+;/* */
+;/* EM error codes */
+;/* */
+;/* */
+;/* */
+;/* (C) 2002-2012, Ullrich von Bassewitz */
+;/* Roemerstrasse 52 */
+;/* D-70794 Filderstadt */
+;/* EMail: uz@cc65.org */
+;/* */
+;/* */
+;/* This software is provided 'as-is', without any expressed or implied */
+;/* warranty. In no event will the authors be held liable for any damages */
+;/* arising from the use of this software. */
+;/* */
+;/* Permission is granted to anyone to use this software for any purpose, */
+;/* including commercial applications, and to alter it and redistribute it */
+;/* freely, subject to the following restrictions: */
+;/* */
+;/* 1. The origin of this software must not be misrepresented; you must not */
+;/* claim that you wrote the original software. If you use this software */
+;/* in a product, an acknowledgment in the product documentation would be */
+;/* appreciated but is not required. */
+;/* 2. Altered source versions must be plainly marked as such, and must not */
+;/* be misrepresented as being the original software. */
+;/* 3. This notice may not be removed or altered from any source */
+;/* distribution. */
+;/* */
+;/*****************************************************************************/
+
+
+
+; Error constants
+.enum
+ EM_ERR_OK ; No error
+ EM_ERR_NO_DRIVER ; No driver available
+ EM_ERR_CANNOT_LOAD ; Error loading driver
+ EM_ERR_INV_DRIVER ; Invalid driver
+ EM_ERR_NO_DEVICE ; Device (hardware) not found
+ EM_ERR_INSTALLED ; A driver is already installed
+
+ EM_ERR_COUNT ; Special: Number of error messages
+.endenum
+
+
+
+;/*****************************************************************************/
+;/* */
+;/* em-kernel.inc */
+;/* */
+;/* EM kernel interface */
+;/* */
+;/* */
+;/* */
+;/* (C) 2002-2003 Ullrich von Bassewitz */
+;/* Roemerstrasse 52 */
+;/* D-70794 Filderstadt */
+;/* EMail: uz@cc65.org */
+;/* */
+;/* */
+;/* This software is provided 'as-is', without any expressed or implied */
+;/* warranty. In no event will the authors be held liable for any damages */
+;/* arising from the use of this software. */
+;/* */
+;/* Permission is granted to anyone to use this software for any purpose, */
+;/* including commercial applications, and to alter it and redistribute it */
+;/* freely, subject to the following restrictions: */
+;/* */
+;/* 1. The origin of this software must not be misrepresented; you must not */
+;/* claim that you wrote the original software. If you use this software */
+;/* in a product, an acknowledgment in the product documentation would be */
+;/* appreciated but is not required. */
+;/* 2. Altered source versions must be plainly marked as such, and must not */
+;/* be misrepresented as being the original software. */
+;/* 3. This notice may not be removed or altered from any source */
+;/* distribution. */
+;/* */
+;/*****************************************************************************/
+
+
+
+;------------------------------------------------------------------------------
+; The driver header
+
+.struct EMD_HDR
+ ID .byte 3 ; Contains 0x65, 0x6d, 0x64 ("emd")
+ VERSION .byte 1 ; Interface version
+ LIBREF .addr ; Library reference
+ JUMPTAB .struct
+ INSTALL .addr ; INSTALL routine
+ UNINSTALL .addr ; UNINSTALL routine
+ PAGECOUNT .addr ; PAGECOUNT routine
+ MAP .addr ; MAP routine
+ USE .addr ; USE routine
+ MAPCLEAN .addr ; MAPCLEAN routine
+ COPYFROM .addr ; COPYFROM routine
+ COPYTO .addr ; COPYTO routine
+ .endstruct
+.endstruct
+
+;------------------------------------------------------------------------------
+; The EMD API version, stored in EMD_HDR::VERSION
+
+EMD_API_VERSION = $02
+
+;------------------------------------------------------------------------------
+; The asm equivalent to the C em_copy structure
+
+.struct EM_COPY
+ BUF .addr ; Memory buffer to copy from or to
+ OFFS .byte ; Offset into page
+ PAGE .word ; Starting page to copy from or to
+ COUNT .word ; Number of bytes to copy
+ UNUSED .byte ; Make the size 8 bytes
+.endstruct
+
+;------------------------------------------------------------------------------
+; Variables
+
+ .global _em_drv ; Pointer to driver
+
+;------------------------------------------------------------------------------
+; Driver entry points
+
+ .global emd_install
+ .global emd_uninstall
+ .global emd_pagecount
+ .global emd_map
+ .global emd_use
+ .global emd_commit
+ .global emd_copyfrom
+ .global emd_copyto
+
+;------------------------------------------------------------------------------
+; ASM functions
+
+ .global em_clear_ptr
+
+;------------------------------------------------------------------------------
+; C callable functions
+
+ .global _em_load_driver
+ .global _em_unload
+ .global _em_install
+ .global _em_uninstall
+ .global _em_pagecount
+ .global _em_map
+ .global _em_use
+ .global _em_commit
+ .global _em_copyfrom
+ .global _em_copyto
+
+;
+; Ullrich von Bassewitz, 16.05.2000
+;
+
+; Variables and functions
+
+ .global ___errno, ___oserror
+ .global ___osmaperrno
+ .global ___seterrno
+ .global ___directerrno, ___mappederrno
+
+; Error codes, must match the values in the C headers
+.enum
+ EOK ; No error
+ ENOENT ; No such file or directory
+ ENOMEM ; Out of memory
+ EACCES ; Permission denied
+ ENODEV ; No such device
+ EMFILE ; Too many open files
+ EBUSY ; Device or resource busy
+ EINVAL ; Invalid argument
+ ENOSPC ; No space left on device
+ EEXIST ; File exists
+ EAGAIN ; Try again
+ EIO ; I/O error
+ EINTR ; Interrupted system call
+ ENOSYS ; Function not implemented
+ ESPIPE ; Illegal seek
+ ERANGE ; Range error
+ EBADF ; Bad file number
+ ENOEXEC ; Exec format error
+ EUNKNOWN ; Unknown OS specific error - must be last!
+
+ EMAX = EUNKNOWN ; Highest error code
+.endenum
+
+
+;
+; Ullrich von Bassewitz, 05.06.1999
+;
+
+; Predefined file handles
+STDIN_FILENO = 0
+STDOUT_FILENO = 1
+STDERR_FILENO = 2
+
+; File mode constants, must match the values in the C headers
+O_RDONLY = $01
+O_WRONLY = $02
+O_RDWR = $03
+O_CREAT = $10
+O_TRUNC = $20
+O_APPEND = $40
+O_EXCL = $80
+
+
+
+
+;-------------------------------------------------------------------------------
+; gamate.inc
+;
+; Gamate system specific definitions
+;
+; (w) 2015 Groepaz/Hitmen (groepaz@gmx.net)
+; based on technical reference by PeT (mess@utanet.at)
+;-------------------------------------------------------------------------------
+
+; look at gamate.h for comments, they are not duplicated here
+
+AUDIO_BASE = $4000
+
+JOY_DATA = $4400
+
+JOY_DATA_UP = $01
+JOY_DATA_DOWN = $02
+JOY_DATA_LEFT = $04
+JOY_DATA_RIGHT = $08
+JOY_DATA_FIRE_A = $10
+JOY_DATA_FIRE_B = $20
+JOY_DATA_START = $40
+JOY_DATA_SELECT = $80
+
+LCD_WIDTH = 160
+LCD_HEIGHT = 152
+
+LCD_BASE = $5000
+LCD_MODE = $5001
+LCD_XPOS = $5002
+LCD_YPOS = $5003
+LCD_X = $5004
+LCD_Y = $5005
+LCD_READ = $5006
+LCD_DATA = $5007
+
+LCD_MODE_INC_X = $00
+LCD_MODE_INC_Y = $40
+LCD_XPOS_PLANE1 = $00
+LCD_XPOS_PLANE2 = $80
+
+; constants for the conio implementation
+charsperline = (LCD_WIDTH / 8)
+screenrows = (LCD_HEIGHT / 8)
+
+CH_HLINE = 1
+CH_VLINE = 2
+
+COLOR_WHITE = 0
+COLOR_GREY2 = 1
+COLOR_GREY1 = 2
+COLOR_BLACK = 3
+
+; bios zp usage:
+ZP_NMI_4800 = $0a
+ZP_IRQ_COUNT = $0b
+ZP_IRQ_CTRL = $0c
+
+ZP_IRQ_CNT1 = $0e
+ZP_IRQ_CNT2 = $0f
+ZP_IRQ_CNT3 = $10
+ZP_IRQ_CNT4 = $11
+
+ZP_NMI_FLAG = $e8
+
+; add - Add without carry
+.macro add Arg1, Arg2
+ clc
+ .if .paramcount = 2
+ adc Arg1, Arg2
+ .else
+ adc Arg1
+ .endif
+.endmacro
+
+; sub - subtract without borrow
+.macro sub Arg1, Arg2
+ sec
+ .if .paramcount = 2
+ sbc Arg1, Arg2
+ .else
+ sbc Arg1
+ .endif
+.endmacro
+
+; bge - jump if unsigned greater or equal
+.macro bge Arg
+ bcs Arg
+.endmacro
+
+; blt - Jump if unsigned less
+.macro blt Arg
+ bcc Arg
+.endmacro
+
+; bgt - jump if unsigned greater
+.macro bgt Arg
+ beq *+4
+ bcs Arg
+.endmacro
+
+; ble - jump if unsigned less or equal
+.macro ble Arg
+ beq Arg
+ bcc Arg
+.endmacro
+
+; bnz - jump if not zero
+.macro bnz Arg
+ bne Arg
+.endmacro
+
+; bze - jump if zero
+.macro bze Arg
+ beq Arg
+.endmacro
+
+;
+; get_tv.inc
+;
+; Ullrich von Bassewitz, 2004-10-15
+;
+; Defines for the get_tv function.
+
+
+
+; Error codes returned by all functions
+.enum TV
+ NTSC
+ PAL
+ OTHER
+.endenum
+
+
+; get_tv function
+
+ .global _get_tv
+
+
+;/*****************************************************************************/
+;/* */
+;/* joy-error.inc */
+;/* */
+;/* Joystick error codes */
+;/* */
+;/* */
+;/* */
+;/* (C) 2002 Ullrich von Bassewitz */
+;/* Wacholderweg 14 */
+;/* D-70597 Stuttgart */
+;/* EMail: uz@musoftware.de */
+;/* */
+;/* */
+;/* This software is provided 'as-is', without any expressed or implied */
+;/* warranty. In no event will the authors be held liable for any damages */
+;/* arising from the use of this software. */
+;/* */
+;/* Permission is granted to anyone to use this software for any purpose, */
+;/* including commercial applications, and to alter it and redistribute it */
+;/* freely, subject to the following restrictions: */
+;/* */
+;/* 1. The origin of this software must not be misrepresented; you must not */
+;/* claim that you wrote the original software. If you use this software */
+;/* in a product, an acknowledgment in the product documentation would be */
+;/* appreciated but is not required. */
+;/* 2. Altered source versions must be plainly marked as such, and must not */
+;/* be misrepresented as being the original software. */
+;/* 3. This notice may not be removed or altered from any source */
+;/* distribution. */
+;/* */
+;/*****************************************************************************/
+
+
+
+; Error codes
+JOY_ERR_OK = 0 ; No error
+JOY_ERR_NO_DRIVER = 1 ; No driver available
+JOY_ERR_CANNOT_LOAD = 2 ; Error loading driver
+JOY_ERR_INV_DRIVER = 3 ; Invalid driver
+JOY_ERR_NO_DEVICE = 4 ; Device (hardware) not found
+
+
+
+;/*****************************************************************************/
+;/* */
+;/* joy-kernel.inc */
+;/* */
+;/* Internally used joystick functions */
+;/* */
+;/* */
+;/* */
+;/* (C) 2002-2006, Ullrich von Bassewitz */
+;/* Roemerstrasse 52 */
+;/* D-70794 Filderstadt */
+;/* EMail: uz@cc65.org */
+;/* */
+;/* */
+;/* This software is provided 'as-is', without any expressed or implied */
+;/* warranty. In no event will the authors be held liable for any damages */
+;/* arising from the use of this software. */
+;/* */
+;/* Permission is granted to anyone to use this software for any purpose, */
+;/* including commercial applications, and to alter it and redistribute it */
+;/* freely, subject to the following restrictions: */
+;/* */
+;/* 1. The origin of this software must not be misrepresented; you must not */
+;/* claim that you wrote the original software. If you use this software */
+;/* in a product, an acknowledgment in the product documentation would be */
+;/* appreciated but is not required. */
+;/* 2. Altered source versions must be plainly marked as such, and must not */
+;/* be misrepresented as being the original software. */
+;/* 3. This notice may not be removed or altered from any source */
+;/* distribution. */
+;/* */
+;/*****************************************************************************/
+
+
+
+
+
+
+;------------------------------------------------------------------------------
+; Driver header stuff
+
+.struct JOY_HDR
+ ID .byte 3 ; $6A, $6F, $79 ("joy")
+ VERSION .byte 1 ; Interface version
+ LIBREF .addr ; Library reference
+ JUMPTAB .struct
+ INSTALL .addr ; INSTALL routine
+ UNINSTALL .addr ; UNINSTALL routine
+ COUNT .addr ; COUNT routine
+ READ .addr ; READ routine
+ .endstruct
+.endstruct
+
+;------------------------------------------------------------------------------
+; The JOY API version, stored in JOY_HDR::VERSION
+
+JOY_API_VERSION = $05
+
+;------------------------------------------------------------------------------
+; Variables
+
+ .global _joy_drv ; Pointer to driver
+ .global _joy_masks
+
+;------------------------------------------------------------------------------
+; Driver entry points
+
+ .global joy_install
+ .global joy_uninstall
+ .global joy_count
+ .global joy_read
+
+;------------------------------------------------------------------------------
+; C callable functions
+
+ .global _joy_load_driver
+ .global _joy_unload
+ .global _joy_install
+ .global _joy_uninstall
+ .global _joy_count
+ .global _joy_read
+
+ .global _joy_clear_ptr
+; ---------------------------------------------------------------------------
+;
+; KIM-1 definitions
+;
+; ---------------------------------------------------------------------------
+
+
+RAMSTART := $0200 ; Entry point
+
+
+; ---------------------------------------------------------------------------
+; Monitor Functions
+; ---------------------------------------------------------------------------
+OUTCHR := $1EA0 ; Output character
+INTCHR := $1E5A ; Input character without case conversion
+DUMPT := $1800 ; Dump memory to tape
+LOADT := $1873 ; Load memory from tape
+START := $1C4F ; Enter KIM-1 monitor
+SCANDS := $1F1F ; Scan 7-segment display
+KEYIN := $1F40 ; Open up keyboard channel
+GETKEY := $1F6A ; Return key from keyboard
+
+
+; ---------------------------------------------------------------------------
+; System Memory
+; ---------------------------------------------------------------------------
+SAL := $17F5 ; Tape load address low
+SAH := $17F6 ; Tape load address high
+EAL := $17F7 ; Tape address end low
+EAH := $17F8 ; Tape address end high
+ID := $17F9 ; Tape Identification number
+.macro jeq Target
+ .if .match(Target, 0)
+ bne *+5
+ jmp Target
+ .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127)
+ beq Target
+ .else
+ bne *+5
+ jmp Target
+ .endif
+.endmacro
+.macro jne Target
+ .if .match(Target, 0)
+ beq *+5
+ jmp Target
+ .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127)
+ bne Target
+ .else
+ beq *+5
+ jmp Target
+ .endif
+.endmacro
+.macro jmi Target
+ .if .match(Target, 0)
+ bpl *+5
+ jmp Target
+ .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127)
+ bmi Target
+ .else
+ bpl *+5
+ jmp Target
+ .endif
+.endmacro
+.macro jpl Target
+ .if .match(Target, 0)
+ bmi *+5
+ jmp Target
+ .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127)
+ bpl Target
+ .else
+ bmi *+5
+ jmp Target
+ .endif
+.endmacro
+.macro jcs Target
+ .if .match(Target, 0)
+ bcc *+5
+ jmp Target
+ .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127)
+ bcs Target
+ .else
+ bcc *+5
+ jmp Target
+ .endif
+.endmacro
+.macro jcc Target
+ .if .match(Target, 0)
+ bcs *+5
+ jmp Target
+ .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127)
+ bcc Target
+ .else
+ bcs *+5
+ jmp Target
+ .endif
+.endmacro
+.macro jvs Target
+ .if .match(Target, 0)
+ bvc *+5
+ jmp Target
+ .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127)
+ bvs Target
+ .else
+ bvc *+5
+ jmp Target
+ .endif
+.endmacro
+.macro jvc Target
+ .if .match(Target, 0)
+ bvs *+5
+ jmp Target
+ .elseif .def(Target) .and .const((*-2)-(Target)) .and ((*+2)-(Target) <= 127)
+ bvc Target
+ .else
+ bvs *+5
+ jmp Target
+ .endif
+.endmacro
+; Lynx system hardware includes
+; Shawn Jefferson
+; June 18th, 2004
+;
+; Reference:
+; Bastian Schick's Lynx Documentation
+; http://www.geocities.ws/SiliconValley/Byte/4242/lynx/
+;
+
+; ***
+; *** Suzy Addresses
+; ***
+
+; Sprite Control Block
+
+TMPADRL = $FC00
+TMPADRH = $FC01
+TILTACUML = $FC02
+TILTACUMH = $FC03
+HOFFL = $FC04
+HOFFH = $FC05
+VOFFL = $FC06
+VOFFH = $FC07
+VIDBASL = $FC08
+VIDBASH = $FC09
+COLLBASL = $FC0A
+COLLBASH = $FC0B
+VIDADRL = $FC0C
+VIDADRH = $FC0D
+COLLADRL = $FC0E
+COLLADRH = $FC0F
+SCBNEXTL = $FC10
+SCBNEXTH = $FC11
+SPRDLINEL = $FC12
+SPRDLINEH = $FC13
+HPOSSTRTL = $FC14
+HPOSSTRTH = $FC15
+VPOSSTRTL = $FC16
+VPOSSTRTH = $FC17
+SPRHSIZL = $FC18
+SPRHSIZH = $FC19
+SPRVSIZL = $FC1A
+SPRVSIZH = $FC1B
+STRETCHL = $FC1C
+STRETCHH = $FC1D
+TILTL = $FC1E
+TILTH = $FC1F
+SPRDOFFL = $FC20
+SPRDOFFH = $FC21
+SPRVPOSL = $FC22
+SPRVPOSH = $FC23
+COLLOFFL = $FC24
+COLLOFFH = $FC25
+VSIZACUML = $FC26
+VSIZACUMH = $FC27
+HSIZOFFL = $FC28
+HSIZOFFH = $FC29
+VSIZOFFL = $FC2A
+VSIZOFFH = $FC2B
+SCBADRL = $FC2C
+SCBADRH = $FC2D
+PROCADRL = $FC2E
+PROCADRH = $FC2F
+
+; Suzy Math
+
+MATHD = $FC52
+MATHC = $FC53
+MATHB = $FC54
+MATHA = $FC55
+MATHP = $FC56
+MATHN = $FC57
+MATHH = $FC60
+MATHG = $FC61
+MATHF = $FC62
+MATHE = $FC63
+MATHM = $FC6C
+MATHL = $FC6D
+MATHK = $FC6E
+MATHJ = $FC6F
+
+; Suzy Misc
+
+SPRCTL0 = $FC80
+SPRCTL1 = $FC81
+SPRCOLL = $FC82
+SPRINIT = $FC83
+SUZYHREV = $FC88
+SUZYSREV = $FC89
+SUZYBUSEN = $FC90
+SPRGO = $FC91
+SPRSYS = $FC92
+JOYSTICK = $FCB0
+SWITCHES = $FCB1
+RCART0 = $FCB2
+RCART1 = $FCB3
+LEDS = $FCC0
+PARSTATUS = $FCC2
+PARDATA = $FCC3
+HOWIE = $FCC4
+
+
+; ***
+; *** Mikey Addresses
+; ***
+
+; Mikey Timers
+
+TIMER0 = $FD00
+TIMER1 = $FD04
+TIMER2 = $FD08
+TIMER3 = $FD0C
+TIMER4 = $FD10
+TIMER5 = $FD14
+TIMER6 = $FD18
+TIMER7 = $FD1C
+HTIMER = $FD00 ; horizontal line timer (timer 0)
+VTIMER = $FD08 ; vertical blank timer (timer 2)
+STIMER = $FD1C ; sound timer (timer 7)
+
+HTIMBKUP = $FD00 ; horizontal line timer (timer 0)
+HTIMCTLA = $FD01
+HTIMCNT = $FD02
+HTIMCTLB = $FD03
+VTIMBKUP = $FD08 ; vertical blank timer (timer 2)
+VTIMCTLA = $FD09
+VTIMCNT = $FD0A
+VTIMCTLB = $FD0B
+BAUDBKUP = $FD10 ; serial timer (timer 4)
+STIMBKUP = $FD1C ; sound timer (timer 7)
+STIMCTLA = $FD1D
+STIMCNT = $FD1E
+STIMCTLB = $FD1F
+
+TIM0BKUP = $FD00
+TIM0CTLA = $FD01
+TIM0CNT = $FD02
+TIM0CTLB = $FD03
+TIM1BKUP = $FD04
+TIM1CTLA = $FD05
+TIM1CNT = $FD06
+TIM1CTLB = $FD07
+TIM2BKUP = $FD08
+TIM2CTLA = $FD09
+TIM2CNT = $FD0A
+TIM2CTLB = $FD0B
+TIM3BKUP = $FD0C
+TIM3CTLA = $FD0D
+TIM3CNT = $FD0E
+TIM3CTLB = $FD0F
+TIM4BKUP = $FD10
+TIM4CTLA = $FD11
+TIM4CNT = $FD12
+TIM4CTLB = $FD13
+TIM5BKUP = $FD14
+TIM5CTLA = $FD15
+TIM5CNT = $FD16
+TIM5CTLB = $FD17
+TIM6BKUP = $FD18
+TIM6CTLA = $FD19
+TIM6CNT = $FD1A
+TIM6CTLB = $FD1B
+TIM7BKUP = $FD1C
+TIM7CTLA = $FD1D
+TIM7CNT = $FD1E
+TIM7CTLB = $FD1F
+
+; Mikey Audio
+
+AUDIO0 = $FD20 ; audio channel 0
+AUDIO1 = $FD28 ; audio channel 1
+AUDIO2 = $FD30 ; audio channel 2
+AUDIO3 = $FD38 ; audio channel 3
+
+AUD0VOL = $FD20
+AUD0FEED = $FD21
+AUD0OUT = $FD22
+AUD0SHIFT = $FD23
+AUD0BKUP = $FD24
+AUD0CTLA = $FD25
+AUD0CNT = $FD26
+AUD0CTLB = $FD27
+AUD1VOL = $FD28
+AUD1FEED = $FD29
+AUD1OUT = $FD2A
+AUD1SHIFT = $FD2B
+AUD1BKUP = $FD2C
+AUD1CTLA = $FD2D
+AUD1CNT = $FD2E
+AUD1CTLB = $FD2F
+AUD2VOL = $FD30
+AUD2FEED = $FD31
+AUD2OUT = $FD32
+AUD2SHIFT = $FD33
+AUD2BKUP = $FD34
+AUD2CTLA = $FD35
+AUD2CNT = $FD36
+AUD2CTLB = $FD37
+AUD3VOL = $FD38
+AUD3FEED = $FD39
+AUD3OUT = $FD3A
+AUD3SHIFT = $FD3B
+AUD3BKUP = $FD3C
+AUD3CTLA = $FD3D
+AUD3CNT = $FD3E
+AUD3CTLB = $FD3F
+MSTEREO = $FD50
+
+; Mikey Misc
+
+; Interrupt bits in INTRST and INTSET
+TIMER0_INTERRUPT = $01
+TIMER1_INTERRUPT = $02
+TIMER2_INTERRUPT = $04
+TIMER3_INTERRUPT = $08
+TIMER4_INTERRUPT = $10
+TIMER5_INTERRUPT = $20
+TIMER6_INTERRUPT = $40
+TIMER7_INTERRUPT = $80
+
+HBL_INTERRUPT = TIMER0_INTERRUPT
+VBL_INTERRUPT = TIMER2_INTERRUPT
+SERIAL_INTERRUPT = TIMER4_INTERRUPT
+SND_INTERRUPT = TIMER7_INTERRUPT
+
+INTRST = $FD80
+INTSET = $FD81
+MAGRDY0 = $FD84
+MAGRDY1 = $FD85
+AUDIN = $FD86
+SYSCTL1 = $FD87
+MIKEYHREV = $FD88
+MIKEYSREV = $FD89
+IODIR = $FD8A
+IODAT = $FD8B
+TxIntEnable = %10000000
+RxIntEnable = %01000000
+TxParEnable = %00010000
+ResetErr = %00001000
+TxOpenColl = %00000100
+TxBreak = %00000010
+ParEven = %00000001
+TxReady = %10000000
+RxReady = %01000000
+TxEmpty = %00100000
+RxParityErr = %00010000
+RxOverrun = %00001000
+RxFrameErr = %00000100
+RxBreak = %00000010
+ParityBit = %00000001
+SERCTL = $FD8C
+SERDAT = $FD8D
+SDONEACK = $FD90
+CPUSLEEP = $FD91
+DISPCTL = $FD92
+PBKUP = $FD93
+DISPADRL = $FD94
+DISPADRH = $FD95
+MTEST0 = $FD9C
+MTEST1 = $FD9D
+MTEST2 = $FD9E
+PALETTE = $FDA0 ; hardware rgb palette
+GCOLMAP = $FDA0 ; hardware rgb palette (green)
+RBCOLMAP = $FDB0 ; hardware rgb palette (red-blue)
+
+
+; ***
+; *** Misc Hardware + 6502 vectors
+; ***
+
+MAPCTL = $FFF9
+VECTORS = $FFFB
+INTVECTL = $FFFE
+INTVECTH = $FFFF
+RSTVECTL = $FFFC
+RSTVECTH = $FFFD
+NMIVECTL = $FFFA
+NMIVECTH = $FFFB
+
+;*****************************************************************************/
+;* */
+;* modload.inc */
+;* */
+;* o65 module loader interface for cc65 */
+;* */
+;* */
+;* */
+;* (C) 2002 Ullrich von Bassewitz */
+;* Wacholderweg 14 */
+;* D-70597 Stuttgart */
+;* EMail: uz@musoftware.de */
+;* */
+;* */
+;* This software is provided 'as-is', without any expressed or implied */
+;* warranty. In no event will the authors be held liable for any damages */
+;* arising from the use of this software. */
+;* */
+;* Permission is granted to anyone to use this software for any purpose, */
+;* including commercial applications, and to alter it and redistribute it */
+;* freely, subject to the following restrictions: */
+;* */
+;* 1. The origin of this software must not be misrepresented; you must not */
+;* claim that you wrote the original software. If you use this software */
+;* in a product, an acknowledgment in the product documentation would be */
+;* appreciated but is not required. */
+;* 2. Altered source versions must be plainly marked as such, and must not */
+;* be misrepresented as being the original software. */
+;* 3. This notice may not be removed or altered from any source */
+;* distribution. */
+;* */
+;*****************************************************************************/
+
+
+
+; Exports structures and functions to load relocatable o65 modules at
+; runtime.
+
+
+
+; Offsets for the mod_ctrl struct. This struct is passed to the module loader.
+; It contains stuff, the loader needs to work, and another area where the
+; loader will place informational data if it was successful. You will have to
+; check the return code of mod_load before accessing any of these additional
+; struct members.
+.struct MOD_CTRL
+ READ .addr
+ CALLERDATA .word
+ MODULE .addr ; Pointer to module data
+ MODULE_SIZE .word ; Total size of loaded module
+ MODULE_ID .word
+.endstruct
+
+; unsigned char mod_load (struct mod_ctrl* ctrl);
+; /* Load a module into memory and relocate it. The function will return an
+; * error code (see below). If MLOAD_OK is returned, the outgoing fields in
+; * the passed mod_ctrl struct contain information about the module just
+; * loaded.
+; */
+.global _mod_load
+
+; void mod_free (void* module);
+; /* Free a loaded module. Note: The given pointer is the pointer to the
+; * module memory, not a pointer to a control structure.
+; */
+.global _mod_free
+
+; Errors
+.enum
+ MLOAD_OK ; Module load successful
+ MLOAD_ERR_READ ; Read error
+ MLOAD_ERR_HDR ; Header error
+ MLOAD_ERR_OS ; Wrong OS
+ MLOAD_ERR_FMT ; Data format error
+ MLOAD_ERR_MEM ; Not enough memory
+.endenum
+
+
+.ifndef DYN_DRV
+ DYN_DRV = 1
+.endif
+
+.macro module_header module_label
+ .if DYN_DRV
+ .segment "HEADER"
+ .else
+ .data
+ .export module_label
+ module_label:
+ .endif
+.endmacro
+;/*****************************************************************************/
+;/* */
+;/* mouse-kernel.inc */
+;/* */
+;/* Mouse API */
+;/* */
+;/* */
+;/* */
+;/* (C) 2003-2009, Ullrich von Bassewitz */
+;/* Roemerstrasse 52 */
+;/* D-70794 Filderstadt */
+;/* EMail: uz@cc65.org */
+;/* */
+;/* */
+;/* */
+;/* */
+;/* This software is provided 'as-is', without any expressed or implied */
+;/* warranty. In no event will the authors be held liable for any damages */
+;/* arising from the use of this software. */
+;/* */
+;/* Permission is granted to anyone to use this software for any purpose, */
+;/* including commercial applications, and to alter it and redistribute it */
+;/* freely, subject to the following restrictions: */
+;/* */
+;/* 1. The origin of this software must not be misrepresented; you must not */
+;/* claim that you wrote the original software. If you use this software */
+;/* in a product, an acknowledgment in the product documentation would be */
+;/* appreciated but is not required. */
+;/* 2. Altered source versions must be plainly marked as such, and must not */
+;/* be misrepresented as being the original software. */
+;/* 3. This notice may not be removed or altered from any source */
+;/* distribution. */
+;/* */
+;/*****************************************************************************/
+
+
+
+
+;------------------------------------------------------------------------------
+; Error codes
+
+.enum
+ MOUSE_ERR_OK ; No error
+ MOUSE_ERR_NO_DRIVER ; No driver available
+ MOUSE_ERR_CANNOT_LOAD ; Error loading driver
+ MOUSE_ERR_INV_DRIVER ; Invalid driver
+ MOUSE_ERR_NO_DEVICE ; Mouse hardware not found
+ MOUSE_ERR_INV_IOCTL ; Invalid ioctl code
+
+ MOUSE_ERR_COUNT ; Special: Number of error codes
+.endenum
+
+;------------------------------------------------------------------------------
+; The driver header
+
+.struct MOUSE_HDR
+ ID .byte 3 ; Contains 0x6D, 0x6F, 0x75 ("mou")
+ VERSION .byte 1 ; Interface version
+ LIBREF .addr ; Library reference
+ JUMPTAB .struct
+ INSTALL .addr
+ UNINSTALL .addr
+ HIDE .addr
+ SHOW .addr
+ SETBOX .addr
+ GETBOX .addr
+ MOVE .addr
+ BUTTONS .addr
+ POS .addr
+ INFO .addr
+ IOCTL .addr
+ IRQ .addr
+ .endstruct
+ FLAGS .byte ; Mouse driver flags
+ CALLBACKS .struct ; Jump instructions
+ .byte ; JMP opcode
+ CHIDE .addr ; Jump address
+ .byte
+ CSHOW .addr
+ .byte
+ CPREP .addr
+ .byte
+ CDRAW .addr
+ .byte
+ CMOVEX .addr
+ .byte
+ CMOVEY .addr
+ .endstruct
+.endstruct
+
+;------------------------------------------------------------------------------
+; The mouse callback structure
+
+.struct MOUSE_CALLBACKS
+ HIDE .addr ; Hide the mouse cursor
+ SHOW .addr ; Show the mouse cursor
+ PREP .addr ; Prepare to move the mouse cursor
+ DRAW .addr ; Draw the mouse cursor
+ MOVEX .addr ; Move the mouse cursor to X coord
+ MOVEY .addr ; Move the mouse cursor to Y coord
+.endstruct
+
+;------------------------------------------------------------------------------
+; The mouse API version, stored in MOUSE_HDR::VERSION
+
+MOUSE_API_VERSION = $06
+
+;------------------------------------------------------------------------------
+; Bitmapped mouse driver flags, stored in MOUSE_HDR::FLAGS.
+; Note: If neither of MOUSE_FLAG_XXX_IRQ is set, no interrupts are supplied
+; to the driver. If one of the bits is set, the interrupt vector MUST be
+; valid.
+; Beware: Some of the bits are tested using the BIT instruction, so do not
+; change the values without checking the code!
+
+MOUSE_FLAG_EARLY_IRQ = $40 ; Enable IRQ *before* calling INSTALL
+MOUSE_FLAG_LATE_IRQ = $80 ; Enable IRQ *after* calling INSTALL
+
+;------------------------------------------------------------------------------
+; Mouse button definitions
+
+MOUSE_BTN_LEFT = $10
+MOUSE_BTN_RIGHT = $01
+
+;------------------------------------------------------------------------------
+; Structures used to return data from the mouse driver
+
+.struct MOUSE_POS
+ XCOORD .word
+ YCOORD .word
+.endstruct
+
+.struct MOUSE_INFO
+ POS .tag MOUSE_POS
+ BUTTONS .byte
+.endstruct
+
+.struct MOUSE_BOX
+ MINX .word
+ MINY .word
+ MAXX .word
+ MAXY .word
+.endstruct
+
+;------------------------------------------------------------------------------
+; Variables
+
+ .global _mouse_drv ; Pointer to driver
+ .global _mouse_hidden ; Counter, 0 = mouse is visible
+
+;------------------------------------------------------------------------------
+; C callable functions
+
+ .global _mouse_load_driver
+ .global _mouse_unload
+ .global _mouse_install
+ .global _mouse_uninstall
+ .global _mouse_geterrormsg
+ .global _mouse_hide
+ .global _mouse_show
+ .global _mouse_setbox
+ .global _mouse_getbox
+ .global _mouse_move
+ .global _mouse_buttons
+ .global _mouse_pos
+ .global _mouse_info
+ .global _mouse_ioctl
+
+ .global _mouse_clear_ptr
+
+;------------------------------------------------------------------------------
+; Driver entry points (asm callable)
+
+ .global mouse_install
+ .global mouse_uninstall
+ .global mouse_hide
+ .global mouse_show
+ .global mouse_setbox
+ .global mouse_getbox
+ .global mouse_move
+ .global mouse_buttons
+ .global mouse_pos
+ .global mouse_info
+ .global mouse_ioctl
+;
+; NES definitions. By Groepaz/Hitmem.
+;
+
+
+;; FIXME: optimize zeropage usage
+
+SCREEN_PTR = $62 ;2
+CRAM_PTR = $64 ;2
+CHARCOLOR = $66
+BGCOLOR = $67
+RVS = $68
+CURS_X = $69
+CURS_Y = $6a
+
+tickcount = $6b ;2
+
+VBLANK_FLAG = $70
+
+ringbuff = $0200
+ringwrite = $71
+ringread = $72
+ringcount = $73
+
+ppuhi = $74
+ppulo = $75
+ppuval = $76
+
+screenrows = (30-1)
+charsperline = 32
+xsize = charsperline
+
+;; PPU defines
+
+PPU_CTRL1 = $2000
+PPU_CTRL2 = $2001
+PPU_STATUS = $2002
+PPU_SPR_ADDR = $2003
+PPU_SPR_IO = $2004
+PPU_VRAM_ADDR1 = $2005
+PPU_VRAM_ADDR2 = $2006
+PPU_VRAM_IO = $2007
+
+;; APU defines
+
+APU_PULSE1CTRL = $4000 ; Pulse #1 Control Register (W)
+APU_PULSE1RAMP = $4001 ; Pulse #1 Ramp Control Register (W)
+APU_PULSE1FTUNE = $4002 ; Pulse #1 Fine Tune (FT) Register (W)
+APU_PULSE1CTUNE = $4003 ; Pulse #1 Coarse Tune (CT) Register (W)
+APU_PULSE2CTRL = $4004 ; Pulse #2 Control Register (W)
+APU_PULSE2RAMP = $4005 ; Pulse #2 Ramp Control Register (W)
+APU_PULSE2FTUNE = $4006 ; Pulse #2 Fine Tune Register (W)
+APU_PULSE2STUNE = $4007 ; Pulse #2 Coarse Tune Register (W)
+APU_TRICTRL1 = $4008 ; Triangle Control Register #1 (W)
+APU_TRICTRL2 = $4009 ; Triangle Control Register #2 (?)
+APU_TRIFREQ1 = $400A ; Triangle Frequency Register #1 (W)
+APU_TRIFREQ2 = $400B ; Triangle Frequency Register #2 (W)
+APU_NOISECTRL = $400C ; Noise Control Register #1 (W)
+;;APU_ = $400D ; Unused (???)
+APU_NOISEFREQ1 = $400E ; Noise Frequency Register #1 (W)
+APU_NOISEFREQ2 = $400F ; Noise Frequency Register #2 (W)
+APU_MODCTRL = $4010 ; Delta Modulation Control Register (W)
+APU_MODDA = $4011 ; Delta Modulation D/A Register (W)
+APU_MODADDR = $4012 ; Delta Modulation Address Register (W)
+APU_MODLEN = $4013 ; Delta Modulation Data Length Register (W)
+APU_SPR_DMA = $4014 ; Sprite DMA Register (W)
+APU_CHANCTRL = $4015 ; Sound/Vertical Clock Signal Register (R)
+APU_PAD1 = $4016 ; Joypad #1 (RW)
+APU_PAD2 = $4017 ; Joypad #2/SOFTCLK (RW)
+
+
+CH_HLINE = 11
+CH_VLINE = 14
+CH_ULCORNER = 176
+CH_URCORNER = 174
+CH_LLCORNER = 173
+CH_LRCORNER = 189
+CH_TTEE = 178
+CH_RTEE = 179
+CH_BTEE = 177
+CH_LTEE = 171
+CH_CROSS = 123
+CH_CURS_UP = 145
+CH_CURS_DOWN = 17
+CH_CURS_LEFT = 157
+CH_CURS_RIGHT = 29
+CH_PI = 126
+CH_DEL = 20
+CH_INS = 148
+CH_ENTER = 10
+CH_STOP = 3
+CH_ESC = 27
+
+;*****************************************************************************/
+;* */
+;* o65.inc */
+;* */
+;* Definitions for the o65 file format */
+;* */
+;* */
+;* */
+;* (C) 2002-2009, Ullrich von Bassewitz */
+;* Roemerstrasse 52 */
+;* D-70794 Filderstadt */
+;* EMail: uz@cc65.org */
+;* */
+;* */
+;* This software is provided 'as-is', without any expressed or implied */
+;* warranty. In no event will the authors be held liable for any damages */
+;* arising from the use of this software. */
+;* */
+;* Permission is granted to anyone to use this software for any purpose, */
+;* including commercial applications, and to alter it and redistribute it */
+;* freely, subject to the following restrictions: */
+;* */
+;* 1. The origin of this software must not be misrepresented; you must not */
+;* claim that you wrote the original software. If you use this software */
+;* in a product, an acknowledgment in the product documentation would be */
+;* appreciated but is not required. */
+;* 2. Altered source versions must be plainly marked as such, and must not */
+;* be misrepresented as being the original software. */
+;* 3. This notice may not be removed or altered from any source */
+;* distribution. */
+;* */
+;*****************************************************************************/
+
+
+
+; This files exports structures and constants to handle the o65 relocatable
+; file format as defined by Andre Fachat.
+
+
+
+; The o65 header structure (6502 format)
+.struct O65_HDR
+ MARKER .byte 2 ; Non-C64 marker: $01 $00
+ MAGIC .byte 3 ; o65 magic: "o65"
+ VERSION .byte 1 ; Version number
+ MODE .word ; Mode word
+ TBASE .word ; Original text (code) segment address
+ TLEN .word ; Size of text (code) segment
+ DBASE .word ; Original data segment address
+ DLEN .word ; Size of data segment
+ BBASE .word ; Original bss segment address
+ BLEN .word ; Size of bss segment
+ ZBASE .word ; Original zp segment address
+ ZLEN .word ; Size of zp segment
+ STACK .word ; Stacksize needed
+.endstruct
+
+; Marker, magic and version number
+O65_MARKER_0 = $01
+O65_MARKER_1 = $00
+O65_MAGIC_0 = $6F ; 'o'
+O65_MAGIC_1 = $36 ; '6'
+O65_MAGIC_2 = $35 ; '5'
+O65_VERSION = $00
+
+; Defines for the mode word
+O65_CPU_65816 = $8000 ; Executable is for 65816
+O65_CPU_6502 = $0000 ; Executable is for the 6502
+O65_CPU_MASK = $8000 ; Mask to extract CPU type
+
+O65_RELOC_PAGE = $4000 ; Page wise relocation
+O65_RELOC_BYTE = $0000 ; Byte wise relocation
+O65_RELOC_MASK = $4000 ; Mask to extract relocation type
+
+O65_SIZE_32BIT = $2000 ; All size words are 32bit
+O65_SIZE_16BIT = $0000 ; All size words are 16bit
+O65_SIZE_MASK = $2000 ; Mask to extract size
+
+O65_FTYPE_OBJ = $1000 ; Object file
+O65_FTYPE_EXE = $0000 ; Executable file
+O65_FTYPE_MASK = $1000 ; Mask to extract type
+
+O65_ADDR_SIMPLE = $0800 ; Simple addressing
+O65_ADDR_DEFAULT = $0000 ; Default addressing
+O65_ADDR_MASK = $0800 ; Mask to extract addressing
+
+O65_CHAIN = $0400 ; Chained file, another one follows
+O65_CHAIN_MASK = $0400 ; Mask to extract chain flag
+
+O65_BSSZERO = $0200 ; BSS segment must be zeroed
+O65_BSSZERO_MASK = $0200 ; Mask to extract bss zero flag
+
+; The following is used if O65_CPU == 6502
+O65_CPU2_6502 = $0000 ; Executable is for 6502
+O65_CPU2_65C02 = $0010 ; Executable is for 65C02
+O65_CPU2_65SC02 = $0020 ; Executable is for 65SC02
+O65_CPU2_65CE02 = $0030 ; Executable is for 65CE02
+O65_CPU2_6502X = $0040 ; Executable is for NMOS 6502
+O65_CPU2_65816_EMU = $0050 ; Executable is for 65816 in emul mode
+O65_CPU2_MASK = $00F0 ; Mask to extract CPU2 field
+
+O65_ALIGN_1 = $0000 ; Bytewise alignment
+O65_ALIGN_2 = $0001 ; Align words
+O65_ALIGN_4 = $0002 ; Align longwords
+O65_ALIGN_256 = $0003 ; Align pages (256 bytes)
+O65_ALIGN_MASK = $0003 ; Mask to extract alignment
+
+; The mode word as generated by the ld65 linker
+O65_MODE_CC65 = O65_CPU_6502 | O65_RELOC_BYTE | O65_SIZE_16BIT | O65_FTYPE_EXE | O65_ADDR_SIMPLE | O65_ALIGN_1
+
+; Relocation type codes
+O65_RTYPE_WORD = $80
+O65_RTYPE_HIGH = $40
+O65_RTYPE_LOW = $20
+O65_RTYPE_SEGADDR = $C0
+O65_RTYPE_SEG = $A0
+O65_RTYPE_MASK = $E0
+
+; Segment IDs
+O65_SEGID_UNDEF = $00
+O65_SEGID_ABS = $01
+O65_SEGID_TEXT = $02
+O65_SEGID_DATA = $03
+O65_SEGID_BSS = $04
+O65_SEGID_ZP = $05
+O65_SEGID_MASK = $07
+
+; Option tags
+O65_OPT_FILENAME = 0
+O65_OPT_OS = 1
+O65_OPT_ASM = 2
+O65_OPT_AUTHOR = 3
+O65_OPT_TIMESTAMP = 4
+
+; Operating system codes for O65_OPT_OS
+O65_OS_OSA65 = 1
+O65_OS_LUNIX = 2
+O65_OS_CC65 = 3
+O65_OS_OPENCBM = 4
+
+; Load errors
+O65_LOAD_OK = 0 ; Module load successful
+O65_LOAD_ERR_READ = 1 ; Read error
+O65_LOAD_ERR_HDR = 2 ; Header error
+O65_LOAD_ERR_OS = 3 ; Wrong OS
+O65_LOAD_ERR_FMT = 4 ; Data format error
+O65_LOAD_ERR_MEM = 5 ; Not enough memory
+
+
+
+; opcodes.inc
+; ca65 6502 - opcode definitions, mainly for self modifying code
+;
+; Christian Krger, latest change: 18-Sep-2010
+;
+; This software is provided 'as-is', without any expressed or implied
+; warranty. In no event will the authors be held liable for any damages
+; arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any purpose,
+; including commercial applications, and to alter it and redistribute it
+; freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must not
+; claim that you wrote the original software. If you use this software
+; in a product, an acknowledgment in the product documentation would be
+; appreciated but is not required.
+; 2. Altered source versions must be plainly marked as such, and must not
+; be misrepresented as being the original software.
+; 3. This notice may not be removed or altered from any source
+; distribution.
+;
+
+; Opcode-Table
+; ------------
+; Post fix explanation:
+; imm = #$00
+; zp = $00
+; zpx = $00,X
+; zpy = $00,Y
+; izp = ($00)
+; izx = ($00,X)
+; izy = ($00),Y
+; abs = $0000
+; abx = $0000,X
+; aby = $0000,Y
+; ind = ($0000)
+; iax = ($0000,X)
+; rel = $0000 (PC-relative) (supressed here)
+
+.macpack cpu
+
+OPC_BRK = $00
+OPC_ORA_izx = $01
+OPC_ORA_zp = $05
+OPC_ASL_zp = $06
+OPC_PHP = $08
+OPC_ORA_imm = $09
+OPC_ASL = $0A
+OPC_ORA_abs = $0D
+OPC_ASL_abs = $0E
+
+OPC_BPL = $10
+OPC_ORA_izy = $11
+OPC_ORA_zpx = $15
+OPC_ASL_zpx = $16
+OPC_CLC = $18
+OPC_ORA_aby = $19
+OPC_ORA_abx = $1D
+OPC_ASL_abx = $1E
+
+OPC_JSR_abs = $20
+OPC_AND_izx = $21
+OPC_BIT_zp = $24
+OPC_AND_zp = $25
+OPC_ROL_zp = $26
+OPC_PLP = $28
+OPC_AND_imm = $29
+OPC_ROL = $2A
+OPC_BIT_abs = $2C
+OPC_AND_abs = $2D
+OPC_ROL_abs = $2E
+
+OPC_BMI = $30
+OPC_AND_izy = $31
+OPC_AND_zpx = $35
+OPC_ROL_zpx = $36
+OPC_SEC = $38
+OPC_AND_aby = $39
+OPC_AND_abx = $3D
+OPC_ROL_abx = $3E
+
+
+OPC_RTI = $40
+OPC_EOR_izx = $41
+OPC_EOR_zp = $45
+OPC_LSR_zp = $46
+OPC_PHA = $48
+OPC_EOR_imm = $49
+OPC_LSR = $4A
+OPC_JMP_abs = $4C
+OPC_EOR_abs = $4D
+OPC_LSR_abs = $4E
+
+OPC_BVC = $50
+OPC_EOR_izy = $51
+OPC_EOR_zpx = $55
+OPC_LSR_zpx = $56
+OPC_CLI = $58
+OPC_EOR_aby = $59
+OPC_EOR_abx = $5D
+OPC_LSR_abx = $5E
+
+OPC_RTS = $60
+OPC_ADC_izx = $61
+OPC_ADC_zp = $65
+OPC_ROR_zp = $66
+OPC_PLA = $68
+OPC_ADC_imm = $69
+OPC_ROR = $6A
+OPC_JMP_ind = $6C
+OPC_ADC_abs = $6D
+OPC_ROR_abs = $6E
+
+OPC_BVS = $70
+OPC_ADC_izy = $71
+OPC_ADC_zpx = $75
+OPC_ROR_zpx = $76
+OPC_SEI = $78
+OPC_ADC_aby = $79
+OPC_ADC_abx = $7D
+OPC_ROR_abx = $7E
+
+OPC_STA_izx = $81
+OPC_STY_zp = $84
+OPC_STA_zp = $85
+OPC_STX_zp = $86
+OPC_DEY = $88
+OPC_TXA = $8A
+OPC_STY_abs = $8C
+OPC_STA_abs = $8D
+OPC_STX_abs = $8E
+
+OPC_BCC = $90
+OPC_STA_izy = $91
+OPC_STY_zpx = $94
+OPC_STA_zpx = $95
+OPC_STX_zpy = $96
+OPC_TYA = $98
+OPC_STA_aby = $99
+OPC_TXS = $9A
+OPC_STA_abx = $9D
+
+OPC_LDY_imm = $A0
+OPC_LDA_izx = $A1
+OPC_LDX_imm = $A2
+OPC_LDY_zp = $A4
+OPC_LDA_zp = $A5
+OPC_LDX_zp = $A6
+OPC_TAY = $A8
+OPC_LDA_imm = $A9
+OPC_TAX = $AA
+OPC_LDY_abs = $AC
+OPC_LDA_abs = $AD
+OPC_LDX_abs = $AE
+
+OPC_BCS = $B0
+OPC_LDA_izy = $B1
+OPC_LDY_zpx = $B4
+OPC_LDA_zpx = $B5
+OPC_LDX_zpy = $B6
+OPC_CLV = $B8
+OPC_LDA_aby = $B9
+OPC_TSX = $BA
+OPC_LDY_abx = $BC
+OPC_LDA_abx = $BD
+OPC_LDX_aby = $BE
+
+OPC_CPY_imm = $C0
+OPC_CMP_izx = $C1
+OPC_CPY_zp = $C4
+OPC_CMP_zp = $C5
+OPC_DEC_zp = $C6
+OPC_INY = $C8
+OPC_CMP_imm = $C9
+OPC_DEX = $CA
+OPC_CPY_abs = $CC
+OPC_CMP_abs = $CD
+OPC_DEC_abs = $CE
+
+OPC_BNE = $D0
+OPC_CMP_izy = $D1
+OPC_CMP_zpx = $D5
+OPC_DEC_zpx = $D6
+OPC_CLD = $D8
+OPC_CMP_aby = $D9
+OPC_CMP_abx = $DD
+OPC_DEC_abx = $DE
+
+OPC_CPX_imm = $E0
+OPC_SBC_izx = $E1
+OPC_CPX_zp = $E4
+OPC_SBC_zp = $E5
+OPC_INC_zp = $E6
+OPC_INX = $E8
+OPC_SBC_imm = $E9
+OPC_NOP = $EA
+OPC_CPX_abs = $EC
+OPC_SBC_abs = $ED
+OPC_INC_abs = $EE
+
+
+OPC_BEQ = $F0
+OPC_SBC_izy = $F1
+OPC_SBC_zpx = $F5
+OPC_INC_zpx = $F6
+OPC_SED = $F8
+OPC_SBC_aby = $F9
+OPC_SBC_abx = $FD
+OPC_INC_abx = $FE
+
+
+.if (.cpu .bitand ::CPU_ISET_65SC02)
+
+; OPC_NOP = $02 ; doublet
+; OPC_NOP = $03 ; doublet
+OPC_TSB_zp = $04
+; OPC_NOP = $0B ; doublet
+OPC_TSB_abs = $0C
+
+OPC_ORA_izp = $12
+; OPC_NOP = $13 ; doublet
+OPC_TRB_zp = $14
+OPC_INC = $1A
+; OPC_NOP = $1B ; doublet
+OPC_TRB_abs = $1C
+
+; OPC_NOP = $22 ; doublet
+; OPC_NOP = $23 ; doublet
+; OPC_NOP = $2B ; doublet
+
+OPC_AND_izp = $32
+; OPC_NOP = $33 ; doublet
+OPC_BIT_zpx = $34
+OPC_DEC = $3A
+; OPC_NOP = $3B ; doublet
+OPC_BIT_abx = $3C
+
+; OPC_NOP = $42 ; doublet
+; OPC_NOP = $43 ; doublet
+; OPC_NOP = $44 ; doublet
+; OPC_NOP = $4B ; doublet
+
+OPC_EOR_izp = $52
+; OPC_NOP = $53 ; doublet
+; OPC_NOP = $54 ; doublet
+; OPC_NOP = $5A ; doublet
+; OPC_NOP = $5B ; doublet
+
+; OPC_NOP = $62 ; doublet
+; OPC_NOP = $63 ; doublet
+OPC_STZ_zp = $64
+; OPC_NOP = $6B ; doublet
+
+OPC_ADC_izp = $72
+; OPC_NOP = $73 ; doublet
+OPC_STZ_zpx = $74
+OPC_PLY = $7A
+; OPC_NOP = $7B ; doublet
+OPC_JMP_iax = $7C
+
+OPC_BRA = $80
+; OPC_NOP = $82 ; doublet
+; OPC_NOP = $83 ; doublet
+OPC_BIT_imm = $89
+; OPC_NOP = $8B ; doublet
+
+OPC_STA_izp = $92
+; OPC_NOP = $93 ; doublet
+; OPC_NOP = $9B ; doublet
+OPC_STZ_abs = $9C
+OPC_STZ_abx = $9E
+
+; OPC_NOP = $A3 ; doublet
+; OPC_NOP = $AB ; doublet
+
+OPC_LDA_izp = $B2
+; OPC_NOP = $B3 ; doublet
+; OPC_NOP = $BB ; doublet
+
+; OPC_NOP = $C2 ; doublet
+; OPC_NOP = $C3 ; doublet
+; OPC_NOP = $CB ; doublet
+
+OPC_CMP_izp = $D2
+; OPC_NOP = $D3 ; doublet
+; OPC_NOP = $D4 ; doublet
+OPC_PHX = $DA
+; OPC_NOP = $DB ; doublet
+; OPC_NOP = $DC ; doublet
+
+; OPC_NOP = $E2 ; doublet
+; OPC_NOP = $E3 ; doublet
+; OPC_NOP = $EB ; doublet
+
+OPC_SBC_izp = $F2
+; OPC_NOP = $F3 ; doublet
+; OPC_NOP = $F4 ; doublet
+OPC_PLX = $FA
+; OPC_NOP = $FB ; doublet
+; OPC_NOP = $FC ; doublet
+
+
+.if (.cpu .bitand ::CPU_ISET_65C02)
+
+; bit instructions for 65C02
+
+OPC_RMB0 = $07
+OPC_RMB1 = $17
+OPC_RMB2 = $27
+OPC_RMB3 = $37
+OPC_RMB4 = $47
+OPC_RMB5 = $57
+OPC_RMB6 = $67
+OPC_RMB7 = $77
+
+OPC_SMB0 = $87
+OPC_SMB1 = $97
+OPC_SMB2 = $A7
+OPC_SMB3 = $B7
+OPC_SMB4 = $C7
+OPC_SMB5 = $D7
+OPC_SMB6 = $E7
+OPC_SMB7 = $F7
+
+OPC_BBR0 = $0F
+OPC_BBR1 = $1F
+OPC_BBR2 = $2F
+OPC_BBR3 = $3F
+OPC_BBR4 = $4F
+OPC_BBR5 = $5F
+OPC_BBR6 = $6F
+OPC_BBR7 = $7F
+
+OPC_BBS0 = $8F
+OPC_BBS1 = $9F
+OPC_BBS2 = $AF
+OPC_BBS3 = $BF
+OPC_BBS4 = $CF
+OPC_BBS5 = $DF
+OPC_BBS6 = $EF
+OPC_BBS7 = $FF
+
+.else
+
+; no bit instructions for 65SC02
+
+; OPC_NOP = $07 ; doublet
+; OPC_NOP = $17 ; doublet
+; OPC_NOP = $27 ; doublet
+; OPC_NOP = $37 ; doublet
+; OPC_NOP = $47 ; doublet
+; OPC_NOP = $57 ; doublet
+; OPC_NOP = $67 ; doublet
+; OPC_NOP = $77 ; doublet
+; OPC_NOP = $87 ; doublet
+; OPC_NOP = $97 ; doublet
+; OPC_NOP = $A7 ; doublet
+; OPC_NOP = $B7 ; doublet
+; OPC_NOP = $C7 ; doublet
+; OPC_NOP = $D7 ; doublet
+; OPC_NOP = $E7 ; doublet
+; OPC_NOP = $F7 ; doublet
+; OPC_NOP = $0F ; doublet
+; OPC_NOP = $1F ; doublet
+; OPC_NOP = $2F ; doublet
+; OPC_NOP = $3F ; doublet
+; OPC_NOP = $4F ; doublet
+; OPC_NOP = $5F ; doublet
+; OPC_NOP = $6F ; doublet
+; OPC_NOP = $7F ; doublet
+; OPC_NOP = $8F ; doublet
+; OPC_NOP = $9F ; doublet
+; OPC_NOP = $AF ; doublet
+; OPC_NOP = $BF ; doublet
+; OPC_NOP = $CF ; doublet
+; OPC_NOP = $DF ; doublet
+; OPC_NOP = $EF ; doublet
+; OPC_NOP = $FF ; doublet
+
+.endif
+
+.elseif (.cpu .bitand ::CPU_ISET_6502X)
+
+; stable, undocumented opcodes
+
+; OPC_KIL = $02 ; unstable
+OPC_SLO_izx = $03
+OPC_NOP_zp = $04
+OPC_SLO_zp = $07
+OPC_ANC_imm = $0B
+OPC_NOP_abs = $0C
+OPC_SLO_abs = $0F
+
+; OPC_KIL = $12 ; unstable
+OPC_SLO_izy = $13
+OPC_NOP_zpx = $14
+OPC_SLO_zpx = $17
+;OPC_NOP = $1A
+OPC_SLO_aby = $1B
+OPC_NOP_abx = $1C
+OPC_SLO_abx = $1F
+
+; OPC_KIL = $22 ; unstable
+OPC_RLA_izx = $23
+OPC_RLA_zp = $27
+OPC_ANC_imm = $2B
+OPC_RLA_abs = $2F
+
+; OPC_KIL = $32 ; unstable
+OPC_RLA_izy = $33
+OPC_NOP_zpx = $34
+OPC_RLA_zpx = $37
+; OPC_NOP = $3A ; doublet
+OPC_RLA_aby = $3B
+OPC_NOP_abx = $3C
+OPC_RLA_abx = $3F
+
+; OPC_KIL = $42 ; unstable
+OPC_SRE_izx = $43
+OPC_NOP_zp = $44
+OPC_SRE_zp = $47
+OPC_ALR_imm = $4B
+OPC_SRE_abs = $4F
+
+; OPC_KIL = $52 ; unstable
+OPC_SRE_izy = $53
+OPC_NOP_zpx = $54
+OPC_SRE_zpx = $57
+; OPC_NOP = $5A ; doublet
+OPC_SRE_aby = $5B
+OPC_NOP_abx = $5C
+OPC_SRE_abx = $5F
+
+; OPC_KIL = $62
+OPC_RRA_izx = $63
+OPC_NOP_zp = $64
+OPC_RRA_zp = $67
+OPC_ARR_imm = $6B
+OPC_RRA_abs = $6F
+
+; OPC_KIL = $72
+OPC_RRA_izy = $73
+OPC_NOP_zpx = $74
+OPC_RRA_zpx = $77
+; OPC_NOP = $7A ; doublet
+OPC_RRA_aby = $7B
+OPC_NOP_abx = $7C
+OPC_RRA_abx = $7F
+
+OPC_NOP_imm = $80
+; OPC_NOP_imm = $82 ; doublet
+OPC_SAX_izx = $83
+OPC_SAX_zp = $87
+; OPC_NOP_imm = $89 ; doublet
+; OPC_XAA = $8B ; unstable
+OPC_SAX_abs = $8F
+
+; OPC_KIL = $92 ; unstable
+; OPC_AHX_izy = $93 ; unstable
+OPC_SAX_zpy = $97
+; OPC_TAS_aby = $9B ; unstable
+; OPC_SHY_abx = $9C ; unstable
+; OPC_SHX_aby = $9E ; unstable
+; OPC_AHX_aby = $9F ; unstable
+
+OPC_LAX_izx = $A3
+OPC_LAX_zp = $A7
+; OPC_LAX_imm = $AB ; unstable
+OPC_LAX_abs = $AF
+
+; OPC_KIL = $B2 ; unstable
+OPC_LAX_izy = $B3
+OPC_LAX_zpy = $B7
+OPC_LAS_aby = $BB
+OPC_LAX_aby = $BF
+
+; OPC_NOP_imm = $C2 ; doublet
+OPC_DCP_izx = $C3
+OPC_DCP_zp = $C7
+OPC_AXS_imm = $CB
+OPC_DCP_abs = $CF
+
+; OPC_KIL = $D2 ; unstable
+OPC_DCP_izy = $D3
+OPC_NOP_zpx = $D4
+OPC_DCP_zpx = $D7
+OPC_NOP_DA = $DA
+OPC_DCP_aby = $DB
+OPC_NOP_abx = $DC
+OPC_DCP_abx = $DF
+
+; OPC_NOP_imm = $E2 ; doublet
+OPC_ISC_izx = $E3
+OPC_ISC_zp = $E7
+; OPC_SBC_imm = $EB ; doublet
+OPC_ISC_abs = $EF
+
+; OPC_KIL = $F2 ; unstable
+OPC_ISC_izy = $F3
+OPC_NOP_zpx = $F4
+OPC_ISC_zpx = $F7
+OPC_NOP_FA = $FA
+OPC_ISC_aby = $FB
+OPC_NOP_abx = $FC
+OPC_ISC_abx = $FF
+
+.if (.cpu .bitand ::CPU_ISET_6502DTV)
+
+OPC_BRA = $12
+OPC_SAC_imm = $32
+OPC_SIR_imm = $42
+
+.endif
+
+.endif
+;
+; PCE definitions. By Groepaz/Hitmen.
+;
+
+; FIXME: Screen dimensions can change according to the selected video mode.
+screenrows = (224/8)
+charsperline = 61
+
+CH_HLINE = 1
+CH_VLINE = 2
+
+; HuC6270 -- Video Display Controller (VDC)
+
+VDC_MAWR = 0 ; Memory Address Write Register
+VDC_MARR = 1 ; Memory Address Read Register
+VDC_VWR = 2 ; VRAM Write Register
+VDC_VRR = 2 ; VRAM Read Register
+VDC_UNK03 = 3 ; (unknown)
+VDC_UNK04 = 4 ; (unknown)
+VDC_CR = 5 ; Control Register
+VDC_RCR = 6 ; Raster Counter Register
+VDC_BXR = 7 ; Background X-Scroll Register
+VDC_BYR = 8 ; Background Y-Scroll Register
+VDC_MWR = 9 ; Memory-access Width Register
+VDC_HSR = 10 ; Horizontal Sync Register
+VDC_HDR = 11 ; Horizontal Display Register
+VDC_VSR = 12 ; Vertical sync Register
+VDC_VDR = 13 ; Vertical Display register
+VDC_VCR = 14 ; Vertical display END position register
+VDC_DCR = 15 ; (DMA) Control Register
+VDC_SOUR = 16 ; (DMA) Source Register
+VDC_DESR = 17 ; (DMA) Destination Register
+VDC_LENR = 18 ; (DMA) Length Register
+VDC_SATB = 19 ; Sprite Attribute Table
+
+; VDC port
+; Note: The zero-page addressing mode is redirected to page $20.
+; We avoid it by using mirror locations that are outside of the zero page.
+
+VDC_CTRL := $0200
+VDC_DATA_LO := $0202
+VDC_DATA_HI := $0203
+
+; HuC6260 -- Video Color Encoder (VCE)
+
+; The DAC has a palette of 512 colours.
+; The bitmap of that data is 0000000gggrrrbbb (Green, Red, Blue).
+; You can read and write the DAC registers.
+
+VCE := $0400 ; base
+
+VCE_CTRL := $0400 ; write $00 to reset
+VCE_ADDR_LO := $0402 ; LSB of byte offset into palette
+VCE_ADDR_HI := $0403 ; MSB of byte offset into palette
+VCE_DATA_LO := $0404 ; LSB of 16-bit palette data
+VCE_DATA_HI := $0405 ; MSB of 16-bit palette data
+
+; Programmable Sound Generator (PSG)
+
+PSG := $0800 ; base
+
+PSG_CHAN_SELECT := $0800
+PSG_GLOBAL_PAN := $0801
+PSG_FREQ_LO := $0802
+PSG_FREQ_HI := $0803
+PSG_CHAN_CTRL := $0804
+PSG_CHAN_PAN := $0805
+PSG_CHAN_DATA := $0806
+PSG_NOISE := $0807
+PSG_LFO_FREQ := $0808
+PSG_LFO_CTRL := $0809
+
+; Timer
+
+TIMER := $0C00 ; base
+
+TIMER_COUNT := $0C00
+TIMER_CTRL := $0C01
+
+JOY_CTRL := $1000
+
+IRQ_MASK := $1402
+IRQ_STATUS := $1403
+
+CDR_MEM_DISABLE := $1803
+CDR_MEM_ENABLE := $1807
+
+; Write to a VDC register.
+.macro VREG arg1, arg2
+ st0 #arg1
+ st1 #<(arg2)
+ st2 #>(arg2)
+.endmacro
+;
+; PET generic definitions.
+;
+
+
+; ---------------------------------------------------------------------------
+; Zero page, Commodore stuff
+
+VARTAB := $2A ; Pointer to start of BASIC variables
+MEMSIZE := $34 ; Size of memory installed
+TXTPTR := $77 ; Pointer into BASIC source code
+TIME := $8D ; 60HZ clock
+KEY_COUNT := $9E ; Number of keys in input buffer
+RVS := $9F ; Reverse flag
+CURS_FLAG := $A7 ; 1 = cursor off
+CURS_BLINK := $A8 ; Blink counter
+CURS_CHAR := $A9 ; Character under the cursor
+CURS_STATE := $AA ; Cursor blink state
+SCREEN_PTR := $C4 ; Pointer to current char in text screen
+CURS_X := $C6 ; Cursor column
+FNLEN := $D1 ; Length of filename
+LFN := $D2 ; Current Logical File Number
+SECADR := $D3 ; Secondary address
+DEVNUM := $D4 ; Device number
+SCR_LINELEN := $D5 ; Screen line length
+CURS_Y := $D8 ; Cursor row
+FNADR := $DA ; Pointer to file name
+
+; 80-Column CBMs
+KBDREPEAT80 := $E4
+KBDRPTRATE80 := $E5
+KBDRPTDELAY80 := $E6
+
+BASIC_BUF := $200 ; Location of command-line
+BASIC_BUF_LEN = 81 ; Maximum length of command-line
+
+KEY_BUF := $26F ; Keyboard buffer
+
+; 40-Column PETs/CBMs
+KBDRPTDELAY40 := $3E9
+KBDRPTRATE40 := $3EA
+KBDREPEAT40 := $3EE
+KBDREPEAT40B := $3F8
+
+;----------------------------------------------------------------------------
+; PET ROM type detection
+
+PET_DETECT := $FFFB
+PET_2000 = $CA
+PET_3000 = $FC
+PET_4000 = $FD
+
+;----------------------------------------------------------------------------
+; Vector and other locations
+
+IRQVec := $0090
+BRKVec := $0092
+NMIVec := $0094
+
+; ---------------------------------------------------------------------------
+; I/O: 6520 PIA1
+
+PIA1 := $E810 ; PIA1 base address
+PIA1_PORTA := PIA1+$0 ; Port A (PA) and data direction register A (DDRA)
+PIA1_PACTL := PIA1+$1 ; Port A control register (CRA)
+PIA1_PORTB := PIA1+$2 ; Port B (PB) and data direction register B (DDRB)
+PIA1_PBCTL := PIA1+$3 ; Port B control register (CRB)
+
+; ---------------------------------------------------------------------------
+; I/O: 6520 PIA2
+
+PIA2 := $E820 ; PIA2 base address
+PIA2_PORTA := PIA2+$0 ; Port A (PA) and data direction register A (DDRA)
+PIA2_PACTL := PIA2+$1 ; Port A control register (CRA)
+PIA2_PORTB := PIA2+$2 ; Port B (PB) and data direction register B (DDRB)
+PIA2_PBCTL := PIA2+$3 ; Port B control register (CRB)
+
+; ---------------------------------------------------------------------------
+; I/O: 6522 VIA
+
+VIA := $E840 ; VIA base address
+VIA_PB := VIA+$0 ; Port register B
+VIA_PA1 := VIA+$1 ; Port register A
+VIA_PRB := VIA+$0 ; *** Deprecated ***
+VIA_PRA := VIA+$1 ; *** Deprecated ***
+VIA_DDRB := VIA+$2 ; Data direction register B
+VIA_DDRA := VIA+$3 ; Data direction register A
+VIA_T1CL := VIA+$4 ; Timer 1, low byte
+VIA_T1CH := VIA+$5 ; Timer 1, high byte
+VIA_T1LL := VIA+$6 ; Timer 1 latch, low byte
+VIA_T1LH := VIA+$7 ; Timer 1 latch, high byte
+VIA_T2CL := VIA+$8 ; Timer 2, low byte
+VIA_T2CH := VIA+$9 ; Timer 2, high byte
+VIA_SR := VIA+$A ; Shift register
+VIA_CR := VIA+$B ; Auxiliary control register
+VIA_PCR := VIA+$C ; Peripheral control register
+VIA_IFR := VIA+$D ; Interrupt flag register
+VIA_IER := VIA+$E ; Interrupt enable register
+VIA_PA2 := VIA+$F ; Port register A w/o handshake
+;
+; Plus/4 generic definitions.
+;
+
+
+; ---------------------------------------------------------------------------
+; Zero page, Commodore stuff
+
+TMPPTR := $22 ; Temporary ptr used by BASIC
+VARTAB := $2D ; Pointer to start of BASIC variables
+MEMSIZE := $37 ; Pointer to highest BASIC RAM location (+1)
+TXTPTR := $3B ; Pointer into BASIC source code
+STATUS := $90 ; Kernal I/O completion status
+TIME := $A3 ; 60HZ clock
+FNAM_LEN := $AB ; Length of filename
+LFN := $AC ; Logical file number
+SECADR := $AD ; Secondary address
+DEVNUM := $AE ; Device number
+FNAM := $AF ; Pointer to filename for OPEN
+KEY_COUNT := $EF ; Number of keys in input buffer
+RVS := $C2 ; Reverse flag
+CURS_X := $CA ; Cursor column
+CURS_Y := $CD ; Cursor row
+SCREEN_PTR := $C8 ; Pointer to current char in text screen
+CRAM_PTR := $EA ; Pointer to current char in color RAM
+
+BASIC_BUF := $200 ; Location of command-line
+BASIC_BUF_LEN = 89 ; Maximum length of command-line
+
+FNBUF := $25E ; Buffer for filename
+FETCH := $494 ; lda (zp),y from RAM
+CHARCOLOR := $53B
+FKEY_COUNT := $55D ; Characters for function key
+FKEY_SPACE := $55F ; Function key definitions
+FKEY_ORIG := $F3D2 ; Original definitions
+
+KBDREPEAT := $540
+KBDREPEATRATE := $541
+KBDREPEATDELAY := $542
+
+; ---------------------------------------------------------------------------
+; Vector and other locations
+
+IRQVec := $0314
+BRKVec := $0316
+NMIVec := $0318
+
+; ---------------------------------------------------------------------------
+; Screen size
+
+XSIZE = 40
+YSIZE = 25
+
+; ---------------------------------------------------------------------------
+; I/O
+
+TED_T1LO := $FF00
+TED_T1HI := $FF01
+TED_T2LO := $FF02
+TED_T2HI := $FF03
+TED_T3LO := $FF04
+TED_T4HI := $FF05
+TED_MULTI1 := $FF07
+TED_KBD := $FF08
+TED_CURSHI := $FF0C
+TED_CURSLO := $FF0D
+TED_V1FRQLO := $FF0E
+TED_V2FRQLO := $FF0F
+TED_V2FRQHI := $FF10
+TED_CLK := $FF13
+TED_BGCOLOR := $FF15
+TED_COLOR1 := $FF16
+TED_COLOR2 := $FF17
+TED_COLOR3 := $FF18
+TED_BORDERCOLOR := $FF19
+TED_VLINEHI := $FF1C
+TED_VLINELO := $FF1D
+TED_HPOS := $FF1E
+TED_ROMSEL := $FF3E
+TED_RAMSEL := $FF3F
+
+; ---------------------------------------------------------------------------
+; RAM/ROM selection addresses
+
+ENABLE_ROM := TED_ROMSEL
+ENABLE_RAM := TED_RAMSEL
+;****************************************************************************
+;* *
+;* ser-error.inc *
+;* *
+;* Serial communication API *
+;* *
+;* *
+;* *
+;* (C) 2003-2012, Ullrich von Bassewitz *
+;* Roemerstrasse 52 *
+;* D-70794 Filderstadt *
+;* EMail: uz@cc65.org *
+;* *
+;* *
+;*This software is provided 'as-is', without any expressed or implied *
+;*warranty. In no event will the authors be held liable for any damages *
+;*arising from the use of this software. *
+;* *
+;*Permission is granted to anyone to use this software for any purpose, *
+;*including commercial applications, and to alter it and redistribute it *
+;*freely, subject to the following restrictions: *
+;* *
+;*1. The origin of this software must not be misrepresented; you must not *
+;* claim that you wrote the original software. If you use this software *
+;* in a product, an acknowledgment in the product documentation would be *
+;* appreciated but is not required. *
+;*2. Altered source versions must be plainly marked as such, and must not *
+;* be misrepresented as being the original software. *
+;*3. This notice may not be removed or altered from any source *
+;* distribution. *
+;* *
+;****************************************************************************
+
+
+
+;------------------------------------------------------------------------------
+; Error codes
+
+.enum
+ SER_ERR_OK ; Not an error - relax
+ SER_ERR_NO_DRIVER ; No driver available
+ SER_ERR_CANNOT_LOAD ; Error loading driver
+ SER_ERR_INV_DRIVER ; Invalid driver
+ SER_ERR_NO_DEVICE ; Device (hardware) not found
+ SER_ERR_BAUD_UNAVAIL ; Baud rate not available
+ SER_ERR_NO_DATA ; Nothing to read
+ SER_ERR_OVERFLOW ; No room in send buffer
+ SER_ERR_INIT_FAILED ; Initialization failed
+ SER_ERR_INV_IOCTL ; IOCTL not supported
+ SER_ERR_INSTALLED ; A driver is already installed
+ SER_ERR_NOT_OPEN ; Driver not open
+
+ SER_ERR_COUNT ; Special: Number of error codes
+.endenum
+
+;****************************************************************************
+;* *
+;* ser-kernel.inc *
+;* *
+;* Serial communication API *
+;* *
+;* *
+;* *
+;*(C) 2003-2006, Ullrich von Bassewitz *
+;* Roemerstrasse 52 *
+;* D-70794 Filderstadt *
+;*EMail: uz@cc65.org *
+;* *
+;* *
+;*This software is provided 'as-is', without any expressed or implied *
+;*warranty. In no event will the authors be held liable for any damages *
+;*arising from the use of this software. *
+;* *
+;*Permission is granted to anyone to use this software for any purpose, *
+;*including commercial applications, and to alter it and redistribute it *
+;*freely, subject to the following restrictions: *
+;* *
+;*1. The origin of this software must not be misrepresented; you must not *
+;* claim that you wrote the original software. If you use this software *
+;* in a product, an acknowledgment in the product documentation would be *
+;* appreciated but is not required. *
+;*2. Altered source versions must be plainly marked as such, and must not *
+;* be misrepresented as being the original software. *
+;*3. This notice may not be removed or altered from any source *
+;* distribution. *
+;* *
+;****************************************************************************
+
+
+
+;------------------------------------------------------------------------------
+; The driver header
+
+.struct SER_HDR
+ ID .byte 3 ; Contains 0x73, 0x65, 0x72 ("ser")
+ VERSION .byte 1 ; Interface version
+ LIBREF .addr ; Library reference
+ JUMPTAB .struct
+ SER_INSTALL .addr ; SER_INSTALL routine
+ SER_UNINSTALL .addr ; SER_UNINSTALL routine
+ SER_OPEN .addr ; SER_OPEN routine
+ SER_CLOSE .addr ; SER_CLOSE routine
+ SER_GET .addr ; SER_GET routine
+ SER_PUT .addr ; SER_PUT routine
+ SER_STATUS .addr ; SER_STATUS routine
+ SER_IOCTL .addr ; SER_IOCTL routine
+ SER_IRQ .addr ; SER_IRQ routine
+ .endstruct
+.endstruct
+
+
+;------------------------------------------------------------------------------
+; The SER API version, stored SER_HDR::VERSION
+
+SER_API_VERSION = $02
+
+;------------------------------------------------------------------------------
+; ser_params
+
+.struct SER_PARAMS
+ BAUDRATE .byte ; Baudrate
+ DATABITS .byte ; Number of data bits
+ STOPBITS .byte ; Number of stop bits
+ PARITY .byte ; Parity setting
+ HANDSHAKE .byte ; Type of handshake to use
+.endstruct
+
+;------------------------------------------------------------------------------
+; Serial parameters
+
+; Baudrate
+SER_BAUD_45_5 = $00
+SER_BAUD_50 = $01
+SER_BAUD_75 = $02
+SER_BAUD_110 = $03
+SER_BAUD_134_5 = $04
+SER_BAUD_150 = $05
+SER_BAUD_300 = $06
+SER_BAUD_600 = $07
+SER_BAUD_1200 = $08
+SER_BAUD_1800 = $09
+SER_BAUD_2400 = $0A
+SER_BAUD_3600 = $0B
+SER_BAUD_4800 = $0C
+SER_BAUD_7200 = $0D
+SER_BAUD_9600 = $0E
+SER_BAUD_19200 = $0F
+SER_BAUD_38400 = $10
+SER_BAUD_57600 = $11
+SER_BAUD_115200 = $12
+SER_BAUD_230400 = $13
+SER_BAUD_31250 = $14
+SER_BAUD_62500 = $15
+SER_BAUD_56_875 = $16
+
+; Data bit settings
+SER_BITS_5 = $00
+SER_BITS_6 = $01
+SER_BITS_7 = $02
+SER_BITS_8 = $03
+
+; Stop bit settings
+SER_STOP_1 = $00
+SER_STOP_2 = $01
+
+; Parity
+SER_PAR_NONE = $00
+SER_PAR_ODD = $01
+SER_PAR_EVEN = $02
+SER_PAR_MARK = $03
+SER_PAR_SPACE = $04
+
+; Handshake
+SER_HS_NONE = $00 ; No handshake
+SER_HS_HW = $01 ; Hardware (RTS/CTS) handshake
+SER_HS_SW = $02 ; Software handshake
+
+; Bit masks to mask out things from the status returned by ser_status
+SER_STATUS_PE = $01 ; Parity error
+SER_STATUS_FE = $02 ; Framing error
+SER_STATUS_OE = $04 ; Overrun error
+SER_STATUS_DCD = $20 ; NOT data carrier detect
+SER_STATUS_DSR = $40 ; NOT data set ready
+
+;------------------------------------------------------------------------------
+; Variables
+
+ .global _ser_drv ; Pointer to driver
+
+;------------------------------------------------------------------------------
+; Driver entry points
+
+ .global ser_install
+ .global ser_uninstall
+ .global ser_open
+ .global ser_close
+ .global ser_get
+ .global ser_put
+ .global ser_status
+ .global ser_ioctl
+ .global ser_irq
+
+;------------------------------------------------------------------------------
+; C callable functions
+
+ .global _ser_load_driver
+ .global _ser_unload
+ .global _ser_install
+ .global _ser_uninstall
+ .global _ser_open
+ .global _ser_close
+ .global _ser_get
+ .global _ser_put
+ .global _ser_status
+ .global _ser_ioctl
+
+ .global _ser_clear_ptr
+;/*****************************************************************************/
+;/* */
+;/* signal.inc */
+;/* */
+;/* Signal handling definitions */
+;/* */
+;/* */
+;/* */
+;/* (C) 2002 Ullrich von Bassewitz */
+;/* Wacholderweg 14 */
+;/* D-70597 Stuttgart */
+;/* EMail: uz@musoftware.de */
+;/* */
+;/* */
+;/* This software is provided 'as-is', without any expressed or implied */
+;/* warranty. In no event will the authors be held liable for any damages */
+;/* arising from the use of this software. */
+;/* */
+;/* Permission is granted to anyone to use this software for any purpose, */
+;/* including commercial applications, and to alter it and redistribute it */
+;/* freely, subject to the following restrictions: */
+;/* */
+;/* 1. The origin of this software must not be misrepresented; you must not */
+;/* claim that you wrote the original software. If you use this software */
+;/* in a product, an acknowledgment in the product documentation would be */
+;/* appreciated but is not required. */
+;/* 2. Altered source versions must be plainly marked as such, and must not */
+;/* be misrepresented as being the original software. */
+;/* 3. This notice may not be removed or altered from any source */
+;/* distribution. */
+;/* */
+;/*****************************************************************************/
+
+
+
+; Standard signal handling functions
+SIG_ERR = $0000
+
+; Signal numbers
+SIGABRT = 0
+SIGFPE = 1
+SIGILL = 2
+SIGINT = 3
+SIGSEGV = 4
+SIGTERM = 5
+SIGCOUNT = 6 ; Number of signals
+
+; Table with signal handlers (asm code only)
+.global sigtable
+
+; Function declarations
+.global ___sig_ign
+.global ___sig_dfl
+.global _signal
+.global _raise
+
+
+; smc.mac
+; ca65 Macro-Pack for Self Modifying Code (SMC)
+;
+; (c) Christian Krüger, latest change: 17-Jul-2016
+;
+; This software is provided 'as-is', without any expressed or implied
+; warranty. In no event will the authors be held liable for any damages
+; arising from the use of this software.
+;
+; Permission is granted to anyone to use this software for any purpose,
+; including commercial applications, and to alter it and redistribute it
+; freely, subject to the following restrictions:
+;
+; 1. The origin of this software must not be misrepresented; you must not
+; claim that you wrote the original software. If you use this software
+; in a product, an acknowledgment in the product documentation would be
+; appreciated but is not required.
+; 2. Altered source versions must be plainly marked as such, and must not
+; be misrepresented as being the original software.
+; 3. This notice may not be removed or altered from any source
+; distribution.
+;
+
+.define _SMCDesignator .mid(0, .tcount(label) - 1, label) .ident(.concat(.string(.right(1, label)), "_SMC"))
+.define _SMCAlias .mid(0, .tcount(alias) - 1, alias) .ident(.concat(.string(.right(1, alias)), "_SMC"))
+.define SMC_AbsAdr $FADE
+.define SMC_ZpAdr $00
+.define SMC_Opcode nop
+.define SMC_Value $42
+
+.macro SMC_OperateOnValue opcode, label
+ opcode _SMCDesignator+1
+.endmacro
+
+.macro SMC_OperateOnLowByte opcode, label
+ SMC_OperateOnValue opcode, label
+.endmacro
+
+.macro SMC_OperateOnHighByte opcode, label
+ opcode _SMCDesignator + 2
+.endmacro
+
+.macro SMC_Import alias
+.import _SMCAlias
+.endmacro
+
+.macro SMC_Export alias, label
+.export _SMCAlias := _SMCDesignator
+.endmacro
+
+.macro SMC label, statement
+_SMCDesignator: statement
+.endmacro
+
+.macro SMC_TransferOpcode label, opcode, register
+.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
+ lda #opcode
+ sta _SMCDesignator
+.elseif .match ({register}, x)
+ ldx #opcode
+ stx _SMCDesignator
+.elseif .match ({register}, y)
+ ldy #opcode
+ sty _SMCDesignator
+.else
+ .error "Invalid usage of macro 'SMC_TransferOpcode'"
+.endif
+.endmacro
+
+.macro SMC_LoadOpcode label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+ lda _SMCDesignator
+.elseif .match ({register}, x)
+ ldx _SMCDesignator
+.elseif .match ({register}, y)
+ ldy _SMCDesignator
+.else
+ .error "Invalid usage of macro 'SMC_LoadOpcode'"
+.endif
+.endmacro
+
+.macro SMC_StoreOpcode label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+ sta _SMCDesignator
+.elseif .match ({register}, x)
+ stx _SMCDesignator
+.elseif .match ({register}, y)
+ sty _SMCDesignator
+.else
+ .error "Invalid usage of macro 'SMC_StoreOpcode'"
+.endif
+.endmacro
+
+.macro SMC_ChangeBranch label, destination, register
+.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
+ lda #(<(destination - _SMCDesignator -2))
+ sta _SMCDesignator+1
+.elseif .match ({register}, x)
+ ldx #(<(destination - _SMCDesignator - 2))
+ stx _SMCDesignator+1
+.elseif .match ({register}, y)
+ ldy #(<(destination - _SMCDesignator - 2))
+ sty _SMCDesignator+1
+.else
+ .error "Invalid usage of macro 'SMC_ChangeBranch'"
+.endif
+.endmacro
+
+.macro SMC_TransferValue label, value, register
+.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
+ lda value
+ sta _SMCDesignator+1
+.elseif .match ({register}, x)
+ ldx value
+ stx _SMCDesignator+1
+.elseif .match ({register}, y)
+ ldy value
+ sty _SMCDesignator+1
+.else
+ .error "Invalid usage of macro 'SMC_TransferValue'"
+.endif
+.endmacro
+
+.macro SMC_LoadValue label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+ lda _SMCDesignator+1
+.elseif .match ({register}, x)
+ ldx _SMCDesignator+1
+.elseif .match ({register}, y)
+ ldy _SMCDesignator+1
+.else
+ .error "Invalid usage of macro 'SMC_LoadValue'"
+.endif
+.endmacro
+
+.macro SMC_StoreValue label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+ sta _SMCDesignator+1
+.elseif .match ({register}, x)
+ stx _SMCDesignator+1
+.elseif .match ({register}, y)
+ sty _SMCDesignator+1
+.else
+ .error "Invalid usage of macro 'SMC_StoreValue'"
+.endif
+.endmacro
+
+
+.macro SMC_TransferLowByte label, value, register
+SMC_TransferValue label, value, register
+.endmacro
+
+.macro SMC_LoadLowByte label, register
+SMC_LoadValue label, register
+.endmacro
+
+.macro SMC_StoreLowByte label, register
+SMC_StoreValue label, register
+.endmacro
+
+.macro SMC_TransferHighByte label, value, register
+.if .paramcount = 2 .or .match ({register}, a) .or .match ({register}, )
+ lda value
+ sta _SMCDesignator+2
+.elseif .match ({register}, x)
+ ldx value
+ stx _SMCDesignator+2
+.elseif .match ({register}, y)
+ ldy value
+ sty _SMCDesignator+2
+.else
+ .error "Invalid usage of macro 'SMC_TransferHighByte'"
+.endif
+.endmacro
+
+.macro SMC_LoadHighByte label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+ lda _SMCDesignator+2
+.elseif .match ({register}, x)
+ ldx _SMCDesignator+2
+.elseif .match ({register}, y)
+ ldy _SMCDesignator+2
+.else
+ .error "Invalid usage of macro 'SMC_LoadHighByte'"
+.endif
+.endmacro
+
+.macro SMC_StoreHighByte label, register
+.if .paramcount = 1 .or .match ({register}, a) .or .match ({register}, )
+ sta _SMCDesignator+2
+.elseif .match ({register}, x)
+ stx _SMCDesignator+2
+.elseif .match ({register}, y)
+ sty _SMCDesignator+2
+.else
+ .error "Invalid usage of macro 'SMC_StoreHighByte'"
+.endif
+.endmacro
+
+.macro SMC_TransferAddressSingle label, address, register
+.if .paramcount = 2 .or .match ((register), a) .or .match ({register}, )
+ .if (.match (.left (1, {address}), #))
+ ; immediate mode
+ lda #<(.right (.tcount ({address})-1, {address}))
+ sta _SMCDesignator+1
+ lda #>(.right (.tcount ({address})-1, {address}))
+ sta _SMCDesignator+2
+ .else
+ ; assume absolute or zero page
+ lda address
+ sta _SMCDesignator+1
+ lda 1+(address)
+ sta _SMCDesignator+2
+ .endif
+.elseif .match ((register), x)
+ .if (.match (.left (1, {address}), #))
+ ; immediate mode
+ ldx #<(.right (.tcount ({address})-1, {address}))
+ stx _SMCDesignator+1
+ ldx #>(.right (.tcount ({address})-1, {address}))
+ stx _SMCDesignator+2
+ .else
+ ; assume absolute or zero page
+ ldx address
+ stx _SMCDesignator+1
+ ldx 1+(address)
+ stx _SMCDesignator+2
+ .endif
+.elseif .match ((register), y)
+ .if (.match (.left (1, {address}), #))
+ ; immediate mode
+ ldy #<(.right (.tcount ({address})-1, {address}))
+ sty _SMCDesignator+1
+ ldy #>(.right (.tcount ({address})-1, {address}))
+ sty _SMCDesignator+2
+ .else
+ ; assume absolute or zero page
+ ldy address
+ sty _SMCDesignator+1
+ ldy 1+(address)
+ sty _SMCDesignator+2
+ .endif
+.else
+ .error "Invalid usage of macro 'SMC_TransferAddressSingle'"
+.endif
+.endmacro
+
+.macro SMC_TransferAddress label, address
+.if (.match (.left (1, {address}), #))
+ ; immediate mode
+ lda #<(.right (.tcount ({address})-1, {address}))
+ sta _SMCDesignator+1
+ ldx #>(.right (.tcount ({address})-1, {address}))
+ stx _SMCDesignator+2
+.else
+ ; assume absolute or zero page
+ lda {address}
+ sta _SMCDesignator+1
+ ldx 1+{address}
+ stx _SMCDesignator)+2
+.endif
+.endmacro
+
+.macro SMC_StoreAddress label
+ sta _SMCDesignator+1
+ stx _SMCDesignator+2
+.endmacro
+;*****************************************************************************/
+;* */
+;* stdio.inc */
+;* */
+;* Mirror definitions for stdio.h */
+;* */
+;* */
+;* */
+;* (C) 2003-2005, Ullrich von Bassewitz */
+;* Roemerstrasse 52 */
+;* D-70794 Filderstadt */
+;* EMail: uz@cc65.org */
+;* */
+;* */
+;* This software is provided 'as-is', without any expressed or implied */
+;* warranty. In no event will the authors be held liable for any damages */
+;* arising from the use of this software. */
+;* */
+;* Permission is granted to anyone to use this software for any purpose, */
+;* including commercial applications, and to alter it and redistribute it */
+;* freely, subject to the following restrictions: */
+;* */
+;* 1. The origin of this software must not be misrepresented; you must not */
+;* claim that you wrote the original software. If you use this software */
+;* in a product, an acknowledgment in the product documentation would be */
+;* appreciated but is not required. */
+;* 2. Altered source versions must be plainly marked as such, and must not */
+;* be misrepresented as being the original software. */
+;* 3. This notice may not be removed or altered from any source */
+;* distribution. */
+;* */
+;*****************************************************************************/
+
+
+
+;----------------------------------------------------------------------------
+; Constants
+
+_IOFBF = 0
+_IOLBF = 1
+_IONBF = 2
+BUFSIZ = 256
+EOF = -1
+.if .defined(__APPLE2__)
+FILENAME_MAX = 64+1
+.elseif .defined(__ATARI__)
+FILENAME_MAX = 63+1
+.elseif .defined(__CBM__)
+FILENAME_MAX = 255
+.elseif .defined(__LUNIX__)
+FILENAME_MAX = 80+1
+.elseif .defined(__TELESTRAT__)
+FILENAME_MAX = 50+1
+.else
+FILENAME_MAX = 16+1
+.endif
+L_tmpnam = FILENAME_MAX
+SEEK_CUR = 0
+SEEK_END = 1
+SEEK_SET = 2
+TMP_MAX = 256
+
+; Maximum number of open files (size of the file table)
+FOPEN_MAX = 8
+
+;----------------------------------------------------------------------------
+; External variables
+
+ .global _stdin
+ .global _stdout
+ .global _stderr
+
+
+
+; supervision symbols
+
+; supervision 65c02s
+; in cc65 up to 2.9.1 65c02 means 65sc02
+
+lcd_addr = $4000
+LCD_LINESIZE = $30
+LCD_WIDTH = 160
+LCD_HEIGHT = 160
+; 2 bit per pixel, packed
+
+lcd_width = $2000
+lcd_height = $2001
+lcd_xpos = $2002 ; in pixel, bit 0+1 not used
+lcd_ypos = $2003 ; weird
+
+sv_port_r = $2021
+sv_port_w = $2022
+
+sv_timer_count = $2023
+; read for quitting
+sv_timer_quit = $2024
+
+; bit 0 timer, bit 1 dma
+sv_irq_source = $2027
+SV_IRQ_REQUEST_TIMER = 1
+SV_IRQ_REQUEST_DMA = 2
+
+; bit 5,6,7 select bank at 0x8000
+sv_bank = $2026
+SV_NMI_ENABLE_ON = 1
+SV_IRQ_ENABLE_TIMER = 2
+SV_IRQ_ENABLE_DMA = 4
+SV_LCD_ON = 8
+SV_TIMER_MODE_240Hz = $10 ; else 15360
+
+
+; low activ/pressed
+sv_control = $2020
+SV_RIGHT = 1
+SV_LEFT = 2
+SV_DOWN = 4
+SV_UP = 8
+SV_BUTTONB = $10
+SV_BUTTONA = $20
+SV_SELECT = $40
+SV_START = $80
+
+; frequency=125000/counter
+sv_audio_right_counter = $2010 ;word
+sv_audio_left_counter = $2014
+SV_AUDIO_ON =$40
+;bits 0..3 volume
+; bit 4 ?
+; bit 5 ?
+sv_audio_right_control = $2012
+sv_audio_left_control = $2016
+; write activates tone for x/60 sec (0 means 256)
+sv_audio_right_timer = $2013
+sv_audio_left_timer = $2017
+
+
+;read for irq quitting
+sv_dma_quit = $2025
+sv_dma_on = $201c
+; bit 7 true start, false stop
+sv_dma_start = $2018 ; word
+sv_dma_size = $201a ; *32 samples
+sv_dma_control = $201b
+; bit 0,1 speed: 0 15360, 11 15360/4
+; bit 2,3 volume: 0 silent, 11 loud
+
+sv_noise_volume = $2028 ; and frequency
+sv_noise_timer = $2029
+sv_noise_control = $202a
+; ---------------------------------------------------------------------------
+;
+; SYM-1 definitions
+;
+; ---------------------------------------------------------------------------
+
+
+RAMSTART := $0200 ; Entry point
+
+
+; ---------------------------------------------------------------------------
+; Monitor Functions
+; ---------------------------------------------------------------------------
+WARM := $8003 ; Monitor entry
+SVNMI := $809B ; Save NMI entry
+INBYTE := $81D9 ; Get two HEX characters and pack
+ASCNIB := $8275 ; Test for carriage-return
+INCCMP := $82B2 ; Increment pointer
+CHKSAD := $82DD ; Compute checksum
+OUTPC := $82EE ; Display program counter
+OUTBYT := $82FA ; Print byte as two ASCII characters
+OUTS2 := $8319 ; Print pointer
+INSTAT := $8386 ; Determine if key is pressed
+GETKEY := $88AF ; Get key (disregarding monitor login)
+SCAND := $8906 ; Flash LED display (once)
+KEYQ := $8923 ; Test for keypress
+BEEP := $8972 ; Make a beep
+CONFIG := $89A5 ; Configure I/O
+OUTDSP := $89C1 ; Output to on-board LED display
+INCHR := $8A1B ; Input character and convert to uppercase
+OUTCHR := $8A47 ; Output character
+INTCHR := $8A58 ; Input character without case conversion
+DLYF := $8AE6 ; Delay 1 bit time
+DLYH := $8AE9 ; Delay 1/2 bit time
+RESET := $8B4A ; Hard reset
+ACCESS := $8B86 ; Unlock lowest 4K memory
+NACCES := $8B9C ; Lock lowest 4K memory
+L8C78 := $8C78 ; Link to tape
+DUMPT := $8E87 ; Dump memory to tape
+LOADT := $8C78 ; Load memory from tape
+TAPEMODE := $00FD ; Top bit on for high-speed
+
+
+; ---------------------------------------------------------------------------
+; System Memory
+; ---------------------------------------------------------------------------
+DISBUF := $A640 ; On-Board Display Buffer
+DISBUF0 := $A640 ; Left-Most digit
+DISBUF1 := $A641 ; Second digit
+DISBUF2 := $A642 ; Third
+DISBUF3 := $A643 ; Fourth
+DISBUF4 := $A644 ; Fifth
+DISBUF5 := $A645 ; Sixth and right-most digit
+DISBUF6 := $A646 ; Not-used / right of display (shift buffer)
+RDIG := $A645 ; Right-most digit (same as DISBUF5)
+P3L := $A64A ; Parameter 3 (low-byte)
+P3H := $A64B ; (high-byte)
+P2L := $A64C ; Parameter 2
+P2H := $A64D ;
+P1L := $A64E ; Parameter 1
+P1H := $A64F
+PARNR := $A649 ; Number of Parameters Entered
+PADBIT := $A650 ; Pad Bits for Carriage Return
+SDBYT := $A651 ; Baud Rate for RS232 (01-4800,06-2400,10-1200,24-600,4C-300,D5-110)
+ERCNT := $A652 ; Error Count (Max FF)
+TECHO := $A653 ; Terminal Echo (bit-7=ECHO/NO, 6=CTL-O TOGGLE)
+TOUTFL := $A654 ; Output Flags (bit-7=CRT IN, 6=TTY IN, 5=TTY OUT, 4=CRT OUT)
+KSHFL := $A655 ; Keyboard Shift Flag
+TV := $A656 ; Trace Velocity (0=Single Step)
+LSTCOM := $A657 ; Last Monitor Command
+MAXRC := $A658 ; Maximum Record Length for Memory Dump
+
+
+; ---------------------------------------------------------------------------
+; Register Followers
+; ---------------------------------------------------------------------------
+PCLR := $A659 ; Program Counter (low-byte)
+PCHR := $A65A ; (high-byte)
+SR := $A65B ; Stack Pointer
+FR := $A65C ; Status Register Flags
+AR := $A65D ; A Register
+XR := $A65E ; X Register
+YR := $A65F ; Y Register
+
+
+; ---------------------------------------------------------------------------
+; I/O Vectors (3 bytes each)
+; ---------------------------------------------------------------------------
+INVEC := $A660 ; Input Character
+OUTVEC := $A663 ; Output Character
+INSVEC := $A666 ; Input Status
+URSVEC := $A669 ; Unrecognized Syntax
+URCVEC := $A66C ; Unrecognized Command / Error
+SCNVEC := $A66F ; Scan On-board Display
+
+
+; ---------------------------------------------------------------------------
+; Trace and Interrupt Vectors (2 bytes each)
+; ---------------------------------------------------------------------------
+EXEVEC := $A672 ; Exec and Alternate InVec
+TRCVEC := $A674 ; Trace
+UBRKVC := $A676 ; User Break after Monitor
+UIRQVC := $A678 ; User non-break IRQ after Monitor
+NMIVEC := $A67A ; Non-Maskable Interrupt
+RSTVEC := $A67C ; Reset
+IRQVEC := $A67E ; Interrupt Request
+
+
+; ---------------------------------------------------------------------------
+; I/O Registers
+; ---------------------------------------------------------------------------
+;
+; 6532 (U27)
+;
+PADA := $A400 ; Keyboard / Display
+P3DA := $A402 ; Serial I/O
+DDPADA := $A401 ; Data-Direction Register for PADA
+DDP3DA := $A403 ; Data-Direction Register for P3DA
+WEDRTA := $A404 ; Write-Edge Detect Read Timer A
+WEDRFA := $A405 ; Write-Edge Detect Read-Int Flags A
+WEDRTB := $A406 ; Write-Edge Detect Read Timer B
+WEDRFB := $A407 ; Write-Edge Detect Read-Int Flags B
+TIM0001 := $A41C ; Timer / 1
+TIM0008 := $A41D ; Timer / 8
+TIM0064 := $A41E ; Timer / 64
+TIM1024 := $A41F ; Timer / 1024
+;
+; 6522 (U25)
+;
+OR1A := $A001 ; Input / Output Register for 1A
+DDR1A := $A003 ; Data-Direction Register for 1A
+OR1B := $A000 ; Input / Output Register for 1B
+DDR1B := $A002 ; Data-Direction Register for 1B
+TIC1L := $A004 ;
+TIC1H := $A005 ;
+TIL1L := $A006 ;
+TIL1H := $A007 ;
+T2L1L := $A008 ;
+T2C1L := $A008 ;
+T2C1H := $A009 ;
+SR1 := $A00A ;
+ACR1 := $A00B ;
+PCR1 := $A00C ;
+IFR1 := $A00D ;
+IER1 := $A00E ;
+DR1A := $A00F ;
+;
+; 6522 (U28)
+;
+OR2A := $A801 ; Input / Output Register for 2A
+DDR2A := $A803 ; Data-Direction Register for 2A
+OR2B := $A800 ; Input / Output Register for 2B
+DDR2B := $A802 ; Data-Direction Register for 2B
+TIC2L := $A804 ;
+TIC2H := $A805 ;
+TIL2L := $A806 ;
+TIL2H := $A807 ;
+T2L2L := $A808 ;
+T2C2L := $A808 ;
+T2C2H := $A809 ;
+SR2 := $A80A ;
+ACR2 := $A80B ;
+PCR2 := $A80C ;
+IFR2 := $A80D ;
+IER2 := $A80E ;
+DR2A := $A80F ;
+;
+; 6522 (U29)
+;
+OR3A := $AC01 ; Write-Protect RAM, Debug On/Off, I/O-3A
+DDR3A := $AC03 ; Data-Direction Register for 3A
+OR3B := $AC00 ; Input / Output Register for 3B
+DDR3B := $AC02 ; Data-Direction Register for 3B
+TIC3L := $AC04 ;
+TIC3H := $AC05 ;
+TIL3L := $AC06 ;
+TIL3H := $AC07 ;
+T2L3L := $AC08 ;
+T2C3L := $AC08 ;
+T2C3H := $AC09 ;
+SR3 := $AC0A ;
+ACR3 := $AC0B ;
+PCR3 := $AC0C ;
+IFR3 := $AC0D ;
+IER3 := $AC0E ;
+DR3A := $AC0F ;
+;
+; Oric TELEMON definition
+; TELEMON 2.4 & Orix
+; For Orix check http://orix.oric.org
+;
+
+; ---------------------------------------------------------------------------
+; Constants
+
+SCREEN_XSIZE = 40 ; Screen columns
+SCREEN_YSIZE = 28 ; Screen rows
+
+FUNCTKEY = $A5
+
+FNAME_LEN = 11 ; Maximum length of file-name
+
+; ---------------------------------------------------------------------------
+; I/O Identifier
+; Theses identifers are used for channel management
+;
+
+XKBD = $80 ; Keyboard
+XRSE = $83 ; RS232 in
+XSCR = $88 ; Screen
+XRSS = $90 ; RS232 out
+
+; ---------------------------------------------------------------------------
+; Zero page
+
+; ---------------------------------------------------------------------------
+; Page 00
+RES := $00
+RESB := $02
+
+DECDEB := $04
+DECFIN := $06
+DECCIB := $08
+DECTRV := $0A
+
+TR0 := $0C
+TR1 := $0D
+TR2 := $0E
+TR3 := $0F
+TR4 := $10
+TR5 := $11
+TR6 := $12
+TR7 := $13
+
+DEFAFF := $14
+
+IRQSVA := $21 ; Used to save A when a BRK call occurs
+IRQSVX := $22 ; Used to save X when a BRK call occurs
+IRQSVY := $23 ; Used to save Y when a BRK call occurs
+IRQSVP := $24 ; Used to save P when a BRK call occurs
+
+ADSCR := $26
+SCRNB := $28 ; Id of the current window
+
+ADKBD := $2A ; Address ASCII conversion table
+
+
+PTR_READ_DEST := $2C ; Used for XFREAD and XWRITE only in Orix
+
+ADCLK := $40 ; Address for clock display
+TIMEUS := $42
+TIMEUD := $44 ; Counter clock (1/10 of a second)
+
+
+HRSX := $46
+HRSY := $47
+
+XLPRBI := $48 ; Printer flag (b7)
+
+HRSX40 := $49
+HRSX6 := $4A
+
+ADHRS := $4B ; Hires screen address (word)
+
+HRS1 := $4D
+HRS2 := $4F
+HRS3 := $51
+HRS4 := $53
+HRS5 := $55
+
+HRSFB := $57
+
+VABKP1 := $58
+
+; RS232T
+; b0-b3 : speed
+; 1111 => 19200 bps (please note that telestrat can't handle this speed without stopping all IRQ except ACIA's one)
+; 1100 => 9600 bps (default from TELEMON)
+; 1110 => 4800 bps
+; 1010 => 2400 bps
+; 1000 => 1200 bps
+; 0111 => 600 bps
+; 0110 => 300 bps
+; 0101 => 150 bps
+; 0010 => 75 bps
+
+; b4 : 0 external clock, 1 internal clock
+; b6-b5 : 00 8 bits
+; 01 7 bits
+; 10 6 bits
+; 11 5 bits
+; b7 : 0 a stop
+
+RS232T := $59
+
+; RS232C
+; b0-b3 : 0
+; b4 : 1 if echo
+; b5 : 1 if parity
+; b7-b6 : 00 in/out parity odd
+; : 01 on/out parity even
+; : 10 parity sent, answer not tested
+; : 11 SPACE SENT, reception not tested
+
+RS232C := $5A
+INDRS := $5B
+
+; Float and integer management
+ACC1E := $60
+ACC1M := $61
+ACC1S := $65
+ACC1EX := $66
+ACC1J := $67
+ACC2E := $68
+ACC2M := $69
+ACC2S := $6D
+ACCPS := $6E
+ACC3 := $6F
+
+ACC4E := $73
+ACC4M := $74
+
+
+FLDT0 := $74
+FLDT1 := $75
+FLDT2 := $76
+FLSVY := $77
+FLTR0 := $7D
+FLTR1 := $7E
+
+; Menu management
+MENDDY := $62
+MENDFY := $63
+MENX := $64
+MENDY := $66
+FLGMEN := $68
+ADMEN := $69
+
+FLSGN := $8A
+FLINT := $88
+FLSVS := $89
+FLERR := $8B
+
+VARLNG := $8C
+VARAPL := $D0
+
+; ---------------------------------------------------------------------------
+; Low memory
+IRQVec := $02FB ; "fast" interrupt vector
+
+; ---------------------------------------------------------------------------
+; I/O locations
+
+; 6522
+.struct VIA ; Versatile Interface Adapter
+ .res $0300
+PRB .byte ; Port Register B
+PRA .byte ; Port Register A
+DDRB .byte ; Data Direction Register B
+DDRA .byte ; Data Direction Register A
+T1 .word ; Timer 1
+T1L .word ; Timer 1 Latch
+T2 .word ; Timer 2
+SR .byte ; Shift Register
+ACR .byte ; Auxiliary Control Register
+PCR .byte ; Peripheral Control Register
+IFR .byte ; Interrupt Flags Register
+IER .byte ; Interrupt Enable Register
+PRA2 .byte ; Port Register A without handshaking
+.endstruct
+
+
+.struct VIA2 ; Versatile Interface Adapter
+ .res $0320
+PRB .byte ; Port Register B
+PRA .byte ; Port Register A
+DDRB .byte ; Data Direction Register B
+DDRA .byte ; Data Direction Register A
+T1 .word ; Timer 1
+T1L .word ; Timer 1 Latch
+T2 .word ; Timer 2
+SR .byte ; Shift Register
+ACR .byte ; Auxiliary Control Register
+PCR .byte ; Peripheral Control Register
+IFR .byte ; Interrupt Flags Register
+IER .byte ; Interrupt Enable Register
+PRA2 .byte ; Port Register A without handshaking
+.endstruct
+
+; 6551
+.struct ACIA ; Asynchronous Communications Interface Adapter
+ .res $031C
+DATA .byte
+STATUS .byte
+CMD .byte ; Command register
+CTRL .byte ; Control register
+.endstruct
+
+SCREEN := $BB80
+
+
+; ---------------------------------------------------------------------------
+; ROM entries
+
+; TELEMON primitives (2.4 & 3.x)
+
+; all values are used to call bank 7 of telestrat cardridge. It works with 'brk value'
+XOP0 = $00 ; Open device on channel 0
+XOP1 = $01 ; Open device on channel 1
+XOP2 = $02 ; Open device on channel 2
+XOP3 = $03 ; Open device on channel 3
+
+XCL0 = $04 ; Close channel 0
+XCL1 = $05 ; Close channel 1
+XCL2 = $06 ; Close channel 2
+XCL3 = $07 ; Close channel 3
+
+XRD0 = $08
+XRDW0 = $0C
+
+XWR0 = $10 ; Write a char in channel 0
+XWR1 = $11 ; Write a char in channel 1
+XWR2 = $12 ; Write a char in channel 2
+XWR3 = $13 ; Write a char in channel 3
+
+XWSTR0 = $14 ; Write a string in text mode channel 0
+XWSTR1 = $15 ; Write a string in text mode channel 1
+XWSTR2 = $16 ; Write a string in text mode channel 2
+XWSTR3 = $17 ; Write a string in text mode channel 3
+
+XDECAL = $18
+
+XTEXT = $19
+XHIRES = $1A
+XEFFHI = $1B ; Clear hires screen
+XFILLM = $1C
+XMINMA = $1F
+XVARS = $24 ; Only in Orix, in TELEMON 2.4, it's XNOMFI ($24)
+XCRLF = $25 ; Jump a line and return to the beginning of the line
+XDECAY = $26
+XFREAD = $27 ; Only in Orix
+XBINDX = $28 ; Convert a number into hex and displays on channel 0
+XDECIM = $29
+XHEXA = $2A ; Convert a number into hex
+
+XEDT = $2D ; Launch editor
+XINSER = $2E
+
+XSCELG = $2F ; Search a line in editor mode
+XOPEN = $30 ; Only in Orix
+XECRPR = $33 ; Displays prompt
+XCOSCR = $34 ; Switch off cursor
+XCSSCR = $35 ; Switch on cursor
+XSCRSE = $36
+XSCROH = $37 ; Scroll up text screen
+XSCROB = $38 ; Scroll down text screen
+XSCRNE = $39 ; Load charset from rom to ram
+XCLOSE = $3A ; Only in Orix close file
+XFWRITE = $3B ; Only in Orix write file
+
+; Clock primitive
+XRECLK = $3C ; Reset clock
+XCLCL = $3D ; Close clock
+XWRCLK = $3E ; Displays clock in the address in A & Y registers
+
+XFSEEK = $3F ; Only in Orix
+
+; Sound primitives
+XSONPS = $40 ; Send data to PSG register (14 values)
+XOUPS = $42 ; Send Oups sound into PSG
+XPLAY = $43 ; Play a sound
+XSOUND = $44
+XMUSIC = $45
+XZAP = $46 ; Send Zap sound to PSG
+XSHOOT = $47
+
+; Path Management
+XGETCWD = $48 ; Get current CWD
+XPUTCWD = $49 ; Chdir
+
+; File management
+XMKDIR = $4B ; Create a folder. Only available in Orix
+
+XHCHRS = $4C ; Hard copy hires
+
+; File management
+XRM = $4D ; Remove a folder or a file. Only available in Orix
+
+XFWR = $4E ; Put a char on the first screen. Only available in Orix
+
+; Keyboard primitives
+XALLKB = $50 ; Read Keyboard, and populate KBDCOL
+XKBDAS = $51 ; Ascii conversion
+XGOKBD = $52 ; Swap keyboard type (Qwerty, French ...)
+
+; Buffer management
+XECRBU = $54 ; Write A or AY in the buffer
+XLISBU = $55 ; Read A or AY in the buffer
+XTSTBU = $56
+XVIDBU = $57 ; Flush the buffer
+XINIBU = $58 ; Initialize the buffer X
+XDEFBU = $59 ; Reset all value of the buffer
+XBUSY = $5A ; Test if the buffer is empty
+
+XMALLOC = $5B ; Only in Orix
+
+; RS232 primitives
+XSDUMP = $5C ; RS232 input dump
+XCONSO = $5D ; Swap screen into RS232 terminal
+XSLOAD = $5E ; Read a file from RS232
+XSSAVE = $5F ; Write a file to RS232
+
+; Minitel primitives
+XMLOAD = $60 ; Read a file from Minitel
+XMSAVE = $61 ; Write a file to Minitel
+
+XFREE = $62 ; Only in Orix
+
+XEXEC = $63 ; Only in Orix
+
+; Next Minitel primitives
+XWCXFI = $63 ; Wait connection
+XLIGNE = $64 ;
+XDECON = $65 ; Minitel disconnection
+XMOUT = $66 ; Send a byte to minitel (from A)
+
+XSOUT = $67 ; Send accumulator value (A) to RS232, available in TELEMON 2.4 : if RS232 buffer is full, the Oric Telestrat freezes
+
+XHRSSE = $8C ; Set hires position cursor
+XDRAWA = $8D ; Draw a line absolute
+XDRAWR = $8E ; Draw a line (relative)
+XCIRCL = $8F ; Draw a circle
+XCURSE = $90 ; Plot a pixel
+XCURMO = $91 ; Move to x,y pos in Hires
+XPAPER = $92
+XINK = $93
+XBOX = $94 ; Draw a box
+XABOX = $95
+XFILL = $96
+XCHAR = $97 ; Display a char on the screen in Hires
+XSCHAR = $98 ; Draw a string in hires
+XEXPLO = $9C ; Send Explode sound to PSG
+XPING = $9D ; Send Ping sound to PSG
+
+; ---------------------------------------------------------------------------
+; ROM entries variables
+
+PWD_PTR = $00
+
+; ---------------------------------------------------------------------------
+;
+BUFTRV := $100
+
+
+; ---------------------------------------------------------------------------
+; Page $200
+BNKST := $200 ; Used to store signature of 8 bank (length : 8 bytes)
+TABDRV := $208
+
+DRVDEF := $20C
+FLGTEL := $20D
+KOROM := $20E ; Used to compute the size of all rom bank. The result is store here. The value is in KB
+KORAM := $20F ; Used to compute the size of all ram bank. The result is store here. The value is in KB
+; Time management
+TIMED := $210 ; Clock (1/10 of seconds)
+TIMES := $211
+TIMEM := $212
+TIMEH := $213
+FLGCLK := $214
+FLGCLK_FLAG := $215
+FLGCUR := $216 ; Cursor management flag
+; screens position managements
+
+FLGCUR_STATE := $217 ; Cursor state flag
+
+ADSCRL := $218
+ADSCRH := $21C
+SCRX := $220
+SCRY := $224
+
+SCRDX := $228
+SCRFX := $22C
+SCRDY := $230
+SCRFY := $234
+SCRBAL := $238
+SCRBAH := $23C
+SCRCT := $240
+SCRCF := $244
+FLGSCR := $248
+CURSCR := $24C
+
+HARD_COPY_HIRES := $250 ; Hard copy vector
+
+SCRTXT := $256
+SCRHIR := $25C
+SCRTRA := $262 ; 6 bytes lenfth
+
+; Keyboard management
+KBDCOL := $268 ; 8 bytes length
+KBDFLG_KEY := $270 ; 0 if no key pressed
+KBDVRR := $272
+
+KBDVRL := $273
+FLGKBD := $275
+KBDFCT := $276
+KBDSHT := $278
+
+KBDKEY := $279
+KBDCTC := $27E
+LPRX := $286
+LPRY := $287
+LPRFX := $288
+LPRFY := $289
+FLGLPR := $28A
+
+; Joysticks management
+FLGJCK := $28C
+JCGVAL := $28D
+JCDVAL := $28E
+JCKTAB := $29D
+
+
+HRSPAT := $2AA ; Hires pattern : it's used to draw pattern for a line or a circle
+HRSERR := $2AB
+
+IOTAB0 := $2AE
+IOTAB1 := $2B2
+IOTAB2 := $2B6
+IOTAB3 := $2BA
+ADIOB := $2BE ; 48 bytes length
+FLGRST := $2EE
+CSRND := $2EF
+VNMI := $2F4
+ADIODB_VECTOR := $2f7 ; 3 bytes length
+
+IRQVECTOR := $2FA
+VAPLIC := $2FD
+
+; ---------------------------------------------------------------------------
+; Page $400
+EXBNK := $40C
+VEXBNK := $414
+BNKCIB := $417
+
+; ---------------------------------------------------------------------------
+; Page $500
+
+DRIVE := $500
+ERRNB := $512
+SAVES := $513
+BUFNOM := $517
+VSALO0 := $528
+VSALO1 := $529
+FTYPE := $52C ; File type
+DESALO := $52D
+FISALO := $52F
+EXSALO := $531
+EXTDEF := $55D ; Default extension. At the start of telemon, it's set to ".COM"
+BUFEDT := $590 ; Buffer edition
+
+MAX_BUFEDT_LENGTH=110
+
+; ---------------------------------------------------------------------------
+; Hardware
+CH376_DATA := $340
+CH376_COMMAND := $341
+
+; RAM overlays buffer
+BUFBUF := $c080
+
+; ---------------------------------------------------------------------------
+; Stratsed vectors
+; Stratsed is the main OS for Telestrat
+XMERGE := $FF0E
+XFST := $FF11
+XSPUT := $FF14
+XSTAKE := $FF17
+XTAKE := $FF20
+XOPENS := $FF1A ; XOPEN from Stratsed
+XCLOSES := $FF1D ; XCLOSE from Stratsed
+XPUT := $FF23
+XREWIN := $FF29
+XJUMP := $FF2C
+XLGBUF := $FF2F
+XERVEC := $FF32
+XESAVE := $FF35
+XCOPY := $FF38
+XDNAME := $FF3B
+XSTATU := $FF3E
+XUPDAT := $FF41
+XFORMA := $FF44
+XDELBK := $FF4A
+XDELN := $FF4D
+XPROT := $FF50
+XUNPRO := $FF53
+XDIRN := $FF56
+XBKP := $FF59
+XINITI := $FF5C
+XERREU := $FF5F
+XLOAD := $FF62
+XDEFSA := $FF65
+XDEFLO := $FF68
+XSAVE := $FF6B
+XNOMDE := $FF6E
+XCREAY := $FF71
+XDETSE := $FF74
+XLIBSE := $FF77
+XTRVCA := $FF7A
+XTRVNM := $FF7D
+XTRVNX := $FF80
+XBUCA := $FF86
+XVBUF1 := $FF89
+XSVSEC := $FF8C
+XSAY := $FF8F
+XSBUF1 := $FF92
+XSBUF2 := $FF95
+XSBUF3 := $FF98
+XSCAT := $FF9B
+XPRSEC := $FFA1
+XPBUF1 := $FFA4
+XPMAP := $FFA7
+XRWTS := $FFAA
+
+; ---------------------------------------------------------------------------
+; MACRO
+
+.macro BRK_TELEMON value
+ .byte $00,value
+.endmacro
+;*****************************************************************************/
+;* */
+;* tgi-error.inc */
+;* */
+;* TGI error codes */
+;* */
+;* */
+;* */
+;* (C) 2002-2012, Ullrich von Bassewitz */
+;* Roemerstrasse 52 */
+;* D-70794 Filderstadt */
+;* EMail: uz@cc65.org */
+;* */
+;* */
+;* This software is provided 'as-is', without any expressed or implied */
+;* warranty. In no event will the authors be held liable for any damages */
+;* arising from the use of this software. */
+;* */
+;* Permission is granted to anyone to use this software for any purpose, */
+;* including commercial applications, and to alter it and redistribute it */
+;* freely, subject to the following restrictions: */
+;* */
+;* 1. The origin of this software must not be misrepresented; you must not */
+;* claim that you wrote the original software. If you use this software */
+;* in a product, an acknowledgment in the product documentation would be */
+;* appreciated but is not required. */
+;* 2. Altered source versions must be plainly marked as such, and must not */
+;* be misrepresented as being the original software. */
+;* 3. This notice may not be removed or altered from any source */
+;* distribution. */
+;* */
+;*****************************************************************************/
+
+
+
+; Error constants
+.enum
+ TGI_ERR_OK ; No error
+ TGI_ERR_NO_DRIVER ; No driver available
+ TGI_ERR_CANNOT_LOAD ; Error loading driver or font
+ TGI_ERR_INV_DRIVER ; Invalid driver
+ TGI_ERR_INV_MODE ; Mode not supported by driver
+ TGI_ERR_INV_ARG ; Invalid function argument
+ TGI_ERR_INV_FUNC ; Function not supported
+ TGI_ERR_INV_FONT ; Font file is invalid
+ TGI_ERR_NO_RES ; Out of resources (memory, handles, ...)
+ TGI_ERR_UNKNOWN ; Unknown error
+ TGI_ERR_INSTALLED ; A driver is already installed
+
+ TGI_ERR_COUNT ; Special: Number of error messages
+.endenum
+
+;*****************************************************************************/
+;* */
+;* tgi-kernel.inc */
+;* */
+;* TGI kernel interface */
+;* */
+;* */
+;* */
+;* (C) 2002-2012, Ullrich von Bassewitz */
+;* Roemerstrasse 52 */
+;* D-70794 Filderstadt */
+;* EMail: uz@cc65.org */
+;* */
+;* */
+;* This software is provided 'as-is', without any expressed or implied */
+;* warranty. In no event will the authors be held liable for any damages */
+;* arising from the use of this software. */
+;* */
+;* Permission is granted to anyone to use this software for any purpose, */
+;* including commercial applications, and to alter it and redistribute it */
+;* freely, subject to the following restrictions: */
+;* */
+;* 1. The origin of this software must not be misrepresented; you must not */
+;* claim that you wrote the original software. If you use this software */
+;* in a product, an acknowledgment in the product documentation would be */
+;* appreciated but is not required. */
+;* 2. Altered source versions must be plainly marked as such, and must not */
+;* be misrepresented as being the original software. */
+;* 3. This notice may not be removed or altered from any source */
+;* distribution. */
+;* */
+;*****************************************************************************/
+
+
+
+;------------------------------------------------------------------------------
+; The driver header
+
+.struct TGI_HDR
+ ID .byte 3 ; Contains 0x74, 0x67, 0x69 ("tgi")
+ VERSION .byte 1 ; Interface version
+ LIBREF .addr ; Library reference
+ VARS .struct
+ XRES .word 1 ; X resolution
+ YRES .word 1 ; Y resolution
+ COLORCOUNT .byte 1 ; Number of available colors
+ PAGECOUNT .byte 1 ; Number of screens available
+ FONTWIDTH .byte 1 ; System font width in pixel
+ FONTHEIGHT .byte 1 ; System font height in pixel
+ ASPECTRATIO .word 1 ; Fixed point 8.8 format
+ FLAGS .byte 1 ; TGI driver flags
+ .endstruct
+ JUMPTAB .struct
+ INSTALL .addr ; INSTALL routine
+ UNINSTALL .addr ; UNINSTALL routine
+ INIT .addr ; INIT routine
+ DONE .addr ; DONE routine
+ GETERROR .addr ; GETERROR routine
+ CONTROL .addr ; CONTROL routine
+ CLEAR .addr ; CLEAR routine
+ SETVIEWPAGE .addr ; SETVIEWPAGE routine
+ SETDRAWPAGE .addr ; SETDRAWPAGE routine
+ SETCOLOR .addr ; SETCOLOR routine
+ SETPALETTE .addr ; SETPALETTE routine
+ GETPALETTE .addr ; GETPALETTE routine
+ GETDEFPALETTE .addr ; GETDEFPALETTE routine
+ SETPIXEL .addr ; SETPIXEL routine
+ GETPIXEL .addr ; GETPIXEL routine
+ LINE .addr ; LINE routine
+ BAR .addr ; BAR routine
+ TEXTSTYLE .addr ; TEXTSTYLE routine
+ OUTTEXT .addr ; OUTTEXT routine
+ .endstruct
+.endstruct
+
+;------------------------------------------------------------------------------
+; The TGI API version, stored at TGI_HDR_VERSION
+
+TGI_API_VERSION = $06
+
+;------------------------------------------------------------------------------
+; Bitmapped tgi driver flags, stored in TGI_HDR::VARS::FLAGS.
+; Beware: Some of the bits are tested using the BIT instruction, so do not
+; change the values without checking the code!
+
+TGI_BM_FONT_FINESCALE = $80 ; Bitmap fonts are fine grained scalable
+
+;------------------------------------------------------------------------------
+; Text constants
+
+TGI_FONT_BITMAP = 0
+TGI_FONT_VECTOR = 1
+
+TGI_TEXT_HORIZONTAL = 0
+TGI_TEXT_VERTICAL = 1
+
+;----------------------------------------------------------------------------
+; Results of tgi_outcode
+
+TGI_CLIP_NONE = $00
+TGI_CLIP_LEFT = $01
+TGI_CLIP_RIGHT = $02
+TGI_CLIP_BOTTOM = $04
+TGI_CLIP_TOP = $08
+
+;------------------------------------------------------------------------------
+; ASM accessible color constants
+
+ .global tgi_color_black:zp ; Target-specific value for black
+ .global tgi_color_white:zp ; Target-specific value for white
+
+;------------------------------------------------------------------------------
+; C accessible variables
+
+ .global _tgi_drv ; Pointer to driver
+ .global _tgi_error ; Last error code
+ .global _tgi_gmode ; Flag: graphics mode active
+ .global _tgi_curx ; Current drawing cursor X
+ .global _tgi_cury ; Current drawing cursor Y
+ .global _tgi_color ; Current drawing color
+ .global _tgi_font ; Which font to use
+ .global _tgi_textdir ; Current text direction
+ .global _tgi_vectorfont ; Pointer to vector font
+ .global _tgi_textscalew ; Text magnification for the width
+ .global _tgi_textscaleh ; Text magnification for the height
+ .global _tgi_charwidth ; Width of scaled system font char
+ .global _tgi_charheight ; Height of scaled system font char
+ .global _tgi_xres ; X resolution of the current mode
+ .global _tgi_yres ; Y resolution of the current mode
+ .global _tgi_xmax ; Maximum X coordinate
+ .global _tgi_ymax ; Maximum Y coordinate
+ .global _tgi_colorcount ; Number of available colors
+ .global _tgi_pagecount ; Number of available screen pages
+ .global _tgi_fontwidth ; System font width
+ .global _tgi_fontheight ; System font height
+ .global _tgi_aspectratio ; Aspect ratio, fixed point 8.8
+ .global _tgi_flags ; TGI driver flags
+
+;------------------------------------------------------------------------------
+; ASM accessible variables
+
+ .global tgi_clip_x1 ; Coordinate for line clipper
+ .global tgi_clip_y1 ; Coordinate for line clipper
+ .global tgi_clip_x2 ; Coordinate for line clipper
+ .global tgi_clip_y2 ; Coordinate for line clipper
+
+;------------------------------------------------------------------------------
+; Driver entry points
+
+ .global tgi_install
+ .global tgi_uninstall
+ .global tgi_init
+ .global tgi_done
+ .global tgi_geterror
+ .global tgi_control
+ .global tgi_clear
+ .global tgi_setviewpage
+ .global tgi_setdrawpage
+ .global tgi_setcolor
+ .global tgi_setpalette
+ .global tgi_getpalette
+ .global tgi_getdefpalette
+ .global tgi_setpixel
+ .global tgi_getpixel
+ .global tgi_line
+ .global tgi_bar
+ .global tgi_textstyle
+ .global tgi_outtext
+
+;------------------------------------------------------------------------------
+; ASM functions
+
+ .global tgi_clear_ptr
+ .global tgi_clippedline
+ .global tgi_curtoxy
+ .global tgi_getset
+ .global tgi_imulround
+ .global tgi_inv_arg
+ .global tgi_inv_drv
+ .global tgi_linepop
+ .global tgi_outcode
+ .global tgi_popxy
+ .global tgi_popxy2
+ .global tgi_set_ptr
+
+;------------------------------------------------------------------------------
+; C callable functions
+
+ .global _tgi_arc
+ .global _tgi_bar
+ .global _tgi_circle
+ .global _tgi_clear
+ .global _tgi_done
+ .global _tgi_ellipse
+ .global _tgi_getaspectratio
+ .global _tgi_getcolor
+ .global _tgi_getcolorcount
+ .global _tgi_getdefpalette
+ .global _tgi_geterror
+ .global _tgi_geterrormsg
+ .global _tgi_getmaxcolor
+ .global _tgi_getmaxx
+ .global _tgi_getmaxy
+ .global _tgi_getpagecount
+ .global _tgi_getpalette
+ .global _tgi_getpixel
+ .global _tgi_gettextheight
+ .global _tgi_gettextwidth
+ .global _tgi_getxres
+ .global _tgi_getyres
+ .global _tgi_gotoxy
+ .global _tgi_imulround
+ .global _tgi_init
+ .global _tgi_install
+ .global _tgi_install_vectorfont
+ .global _tgi_ioctl
+ .global _tgi_line
+ .global _tgi_lineto
+ .global _tgi_load_driver
+ .global _tgi_outtext
+ .global _tgi_outtextxy
+ .global _tgi_pieslice
+ .global _tgi_setaspectratio
+ .global _tgi_setcolor
+ .global _tgi_setdrawpage
+ .global _tgi_setpalette
+ .global _tgi_setpixel
+ .global _tgi_settextdir
+ .global _tgi_settextscale
+ .global _tgi_settextstyle
+ .global _tgi_setviewpage
+ .global _tgi_uninstall
+ .global _tgi_unload
+;*****************************************************************************/
+;* */
+;* tgi-vectorfont.inc */
+;* */
+;* TGI vector font definitions */
+;* */
+;* */
+;* */
+;* (C) 2009, Ullrich von Bassewitz */
+;* Roemerstrasse 52 */
+;* D-70794 Filderstadt */
+;* EMail: uz@cc65.org */
+;* */
+;* */
+;* This software is provided 'as-is', without any expressed or implied */
+;* warranty. In no event will the authors be held liable for any damages */
+;* arising from the use of this software. */
+;* */
+;* Permission is granted to anyone to use this software for any purpose, */
+;* including commercial applications, and to alter it and redistribute it */
+;* freely, subject to the following restrictions: */
+;* */
+;* 1. The origin of this software must not be misrepresented; you must not */
+;* claim that you wrote the original software. If you use this software */
+;* in a product, an acknowledgment in the product documentation would be */
+;* appreciated but is not required. */
+;* 2. Altered source versions must be plainly marked as such, and must not */
+;* be misrepresented as being the original software. */
+;* 3. This notice may not be removed or altered from any source */
+;* distribution. */
+;* */
+;*****************************************************************************/
+
+
+
+;------------------------------------------------------------------------------
+; Vectorfont constants
+
+TGI_VF_VERSION = $00 ; File version number
+TGI_VF_FIRSTCHAR = $20 ; First char in file
+TGI_VF_LASTCHAR = $7E ; Last char in file
+TGI_VF_CCOUNT = (TGI_VF_LASTCHAR - TGI_VF_FIRSTCHAR + 1)
+
+;------------------------------------------------------------------------------
+; TCH file header and font data structures
+
+; TCH file header
+.struct TGI_VF_HDR
+ MAGIC .byte 3 ; "TCH"
+ VERSION .byte 1 ; Version number
+ SIZE .word 1 ; Font data size
+.endstruct
+
+; Font data loaded directly from file
+.struct TGI_VECTORFONT
+ TOP .byte ; Height of char
+ BOTTOM .byte ; Descender
+ HEIGHT .byte ; Maximum char height
+ WIDTHS .byte ::TGI_VF_CCOUNT ; Char widths
+ CHARS .word ::TGI_VF_CCOUNT ; Pointer to character defs
+ OPS .byte ; Actually dynamic
+.endstruct
+
+;------------------------------------------------------------------------------
+; C callable functions
+
+ .global _tgi_vectorchar
+
+
+
+;/*****************************************************************************/
+;/* */
+;/* time.inc */
+;/* */
+;/* Date and time */
+;/* */
+;/* */
+;/* */
+;/* (C) 2009 Ullrich von Bassewitz */
+;/* Roemerstrasse 52 */
+;/* D-70794 Filderstadt */
+;/* EMail: uz@cc65.org */
+;/* */
+;/* */
+;/* This software is provided 'as-is', without any expressed or implied */
+;/* warranty. In no event will the authors be held liable for any damages */
+;/* arising from the use of this software. */
+;/* */
+;/* Permission is granted to anyone to use this software for any purpose, */
+;/* including commercial applications, and to alter it and redistribute it */
+;/* freely, subject to the following restrictions: */
+;/* */
+;/* 1. The origin of this software must not be misrepresented; you must not */
+;/* claim that you wrote the original software. If you use this software */
+;/* in a product, an acknowledgment in the product documentation would be */
+;/* appreciated but is not required. */
+;/* 2. Altered source versions must be plainly marked as such, and must not */
+;/* be misrepresented as being the original software. */
+;/* 3. This notice may not be removed or altered from any source */
+;/* distribution. */
+;/* */
+;/*****************************************************************************/
+
+
+
+;------------------------------------------------------------------------------
+; Struct tm - must match the struct defined in time.h
+
+.struct tm
+ tm_sec .word
+ tm_min .word
+ tm_hour .word
+ tm_mday .word
+ tm_mon .word
+ tm_year .word
+ tm_wday .word
+ tm_yday .word
+ tm_isdst .word
+.endstruct
+
+
+;------------------------------------------------------------------------------
+; Struct timespec - must match the struct defined in time.h
+
+.struct timespec
+ tv_sec .dword
+ tv_nsec .dword
+.endstruct
+
+
+;------------------------------------------------------------------------------
+; Exported functions
+
+.global _clock_getres
+.global _clock_gettime
+.global _clock_settime
+.global _localtime
+.global _mktime
+;/*****************************************************************************/
+;/* */
+;/* utsname.inc */
+;/* */
+;/* Return system information */
+;/* */
+;/* */
+;/* */
+;/* (C) 2003 Ullrich von Bassewitz */
+;/* Roemerstrasse 52 */
+;/* D-70794 Filderstadt */
+;/* EMail: uz@cc65.org */
+;/* */
+;/* */
+;/* This software is provided 'as-is', without any expressed or implied */
+;/* warranty. In no event will the authors be held liable for any damages */
+;/* arising from the use of this software. */
+;/* */
+;/* Permission is granted to anyone to use this software for any purpose, */
+;/* including commercial applications, and to alter it and redistribute it */
+;/* freely, subject to the following restrictions: */
+;/* */
+;/* 1. The origin of this software must not be misrepresented; you must not */
+;/* claim that you wrote the original software. If you use this software */
+;/* in a product, an acknowledgment in the product documentation would be */
+;/* appreciated but is not required. */
+;/* 2. Altered source versions must be plainly marked as such, and must not */
+;/* be misrepresented as being the original software. */
+;/* 3. This notice may not be removed or altered from any source */
+;/* distribution. */
+;/* */
+;/*****************************************************************************/
+
+
+
+; Struct utsname
+.struct utsname
+ sysname .byte 17
+ nodename .byte 9
+ release .byte 9
+ version .byte 9
+ machine .byte 25
+.endstruct
+
+
+
+;
+; VIC-20 generic definitions. Stolen mostly from c64.inc -- Steve Schmidtke
+;
+
+; ---------------------------------------------------------------------------
+; Zero page, Commodore stuff
+
+VARTAB := $2D ; Pointer to start of BASIC variables
+MEMSIZE := $37 ; Pointer to highest BASIC RAM location (+1)
+TXTPTR := $7A ; Pointer into BASIC source code
+STATUS := $90 ; Kernal I/O completion status
+TIME := $A0 ; 60HZ clock
+FNAM_LEN := $B7 ; Length of filename
+SECADR := $B9 ; Secondary address
+DEVNUM := $BA ; Device number
+FNAM := $BB ; Pointer to filename
+KEY_COUNT := $C6 ; Number of keys in input buffer
+RVS := $C7 ; Reverse flag
+CURS_FLAG := $CC ; 1 = cursor off
+CURS_BLINK := $CD ; Blink counter
+CURS_CHAR := $CE ; Character under the cursor
+CURS_STATE := $CF ; Cursor blink state
+SCREEN_PTR := $D1 ; Pointer to current char in text screen
+CURS_X := $D3 ; Cursor column
+CURS_Y := $D6 ; Cursor row
+CRAM_PTR := $F3 ; Pointer to current char in color RAM
+
+BASIC_BUF := $200 ; Location of command-line
+BASIC_BUF_LEN = 89 ; Maximum length of command-line
+
+CHARCOLOR := $286
+CURS_COLOR := $287 ; Color under the cursor
+
+KBDREPEAT := $28a
+KBDREPEATRATE := $28b
+KBDREPEATDELAY := $28c
+
+RSSTAT := $297 ; RS-232 device driver status
+
+; ---------------------------------------------------------------------------
+; Screen size
+
+XSIZE = 22
+YSIZE = 23
+
+; ---------------------------------------------------------------------------
+; Vector and other locations
+
+IRQVec := $0314
+BRKVec := $0316
+NMIVec := $0318
+
+; ---------------------------------------------------------------------------
+; I/O: 6560 VIC
+
+VIC := $9000
+VIC_CR0 := VIC+$0
+VIC_CR1 := VIC+$1
+VIC_CR2 := VIC+$2
+VIC_CR3 := VIC+$3
+VIC_LINES := VIC+$3 ; Screen lines, bit 7 is bit 0 from VIC_HLINE
+VIC_CR4 := VIC+$4
+VIC_HLINE := VIC+$4 ; Rasterline, bits 1-8
+VIC_CR5 := VIC+$5
+VIC_CR6 := VIC+$6
+VIC_CR7 := VIC+$7
+VIC_CR8 := VIC+$8
+VIC_CR9 := VIC+$9
+VIC_CRA := VIC+$A
+VIC_CRB := VIC+$B
+VIC_CRC := VIC+$C
+VIC_CRD := VIC+$D
+VIC_CRE := VIC+$E
+VIC_CRF := VIC+$F
+VIC_COLOR := VIC+$F ; Border and background color
+
+; ---------------------------------------------------------------------------
+; I/O: 6522 VIA1
+
+VIA1 := $9110 ; VIA1 base address
+VIA1_JOY := VIA1+$0 ; *** Deprecated ***
+VIA1_PB := VIA1+$0 ; Port register B
+VIA1_PA1 := VIA1+$1 ; Port register A
+VIA1_DDRB := VIA1+$2 ; Data direction register B
+VIA1_DDRA := VIA1+$3 ; Data direction register A
+VIA1_T1CL := VIA1+$4 ; Timer 1, low byte
+VIA1_T1CH := VIA1+$5 ; Timer 1, high byte
+VIA1_T1LL := VIA1+$6 ; Timer 1 latch, low byte
+VIA1_T1LH := VIA1+$7 ; Timer 1 latch, high byte
+VIA1_T2CL := VIA1+$8 ; Timer 2, low byte
+VIA1_T2CH := VIA1+$9 ; Timer 2, high byte
+VIA1_SR := VIA1+$A ; Shift register
+VIA1_ACR := VIA1+$B ; Auxiliary control register
+VIA1_PCR := VIA1+$C ; Peripheral control register
+VIA1_IFR := VIA1+$D ; Interrupt flag register
+VIA1_IER := VIA1+$E ; Interrupt enable register
+VIA1_PA2 := VIA1+$F ; Port register A w/o handshake
+
+; ---------------------------------------------------------------------------
+; I/O: 6522 VIA2
+
+VIA2 := $9120 ; VIA2 base address
+VIA2_JOY := VIA2+$0 ; *** Deprecated ***
+VIA2_PB := VIA2+$0 ; Port register B
+VIA2_PA1 := VIA2+$1 ; Port register A
+VIA2_DDRB := VIA2+$2 ; Data direction register B
+VIA2_DDRA := VIA2+$3 ; Data direction register A
+VIA2_T1CL := VIA2+$4 ; Timer 1, low byte
+VIA2_T1CH := VIA2+$5 ; Timer 1, high byte
+VIA2_T1LL := VIA2+$6 ; Timer 1 latch, low byte
+VIA2_T1LH := VIA2+$7 ; Timer 1 latch, high byte
+VIA2_T2CL := VIA2+$8 ; Timer 2, low byte
+VIA2_T2CH := VIA2+$9 ; Timer 2, high byte
+VIA2_SR := VIA2+$A ; Shift register
+VIA2_ACR := VIA2+$B ; Auxiliary control register
+VIA2_PCR := VIA2+$C ; Peripheral control register
+VIA2_IFR := VIA2+$D ; Interrupt flag register
+VIA2_IER := VIA2+$E ; Interrupt enable register
+VIA2_PA2 := VIA2+$F ; Port register A w/o handshake
+;
+; zeropage.inc
+;
+; (C) Copyright 2002-2012, Ullrich von Bassewitz (uz@cc65.org)
+;
+
+; Assembler include file that imports the runtime zero page locations used
+; by the compiler, ready for usage in asm code.
+
+
+ .globalzp sp, sreg, regsave
+ .globalzp ptr1, ptr2, ptr3, ptr4
+ .globalzp tmp1, tmp2, tmp3, tmp4
+ .globalzp regbank
+
+; The size of the register bank
+regbanksize = 6
+
+; The total amount of zero page space used
+zpspace = 26
+
+; The amount of space that needs to be saved by an interrupt handler that
+; calls C code (does not include the register bank, which is saved by the
+; generated C code if required).
+zpsavespace = zpspace - regbanksize
+
+# Linker config. to produce a NEC PC-Engine 8K, 16K, or 32K image (.bin)
+SYMBOLS {
+ __CARTSIZE__: type = weak, value = $2000; # $2000, $4000, or $8000
+ __STACKSIZE__: type = weak, value = $0300; # 3 pages stack
+}
+MEMORY {
+ ZP: file = "", start = $0000, define = yes, size = $0100;
+ # RAM bank
+ MAIN: file = "", start = $2200, define = yes, size = $1E00 - __STACKSIZE__;
+ # ROM banks, before swapping, and after mapping
+ ROM: file = %O, start = $10000 - __CARTSIZE__, size = __CARTSIZE__, fill = yes, fillval = $FF;
+}
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp;
+ EXTZP: load = ZP, type = zp, optional = yes;
+ APPZP: load = ZP, type = zp, optional = yes;
+ DATA: load = ROM, run = MAIN, type = rw, define = yes;
+ INIT: load = MAIN, type = bss, optional = yes;
+ BSS: load = MAIN, type = bss, define = yes;
+ RODATA: load = ROM, type = ro;
+ CODE: load = ROM, type = ro;
+ LOWCODE: load = ROM, type = ro, optional = yes;
+ ONCE: load = ROM, type = ro, optional = yes;
+ STARTUP: load = ROM, type = ro, start = $FFF6 - $0066;
+ VECTORS: load = ROM, type = ro, start = $FFF6;
+}
+FEATURES {
+ CONDES: type = constructor,
+ label = __CONSTRUCTOR_TABLE__,
+ count = __CONSTRUCTOR_COUNT__,
+ segment = ONCE;
+ CONDES: type = destructor,
+ label = __DESTRUCTOR_TABLE__,
+ count = __DESTRUCTOR_COUNT__,
+ segment = RODATA;
+ CONDES: type = interruptor,
+ label = __INTERRUPTOR_TABLE__,
+ count = __INTERRUPTOR_COUNT__,
+ segment = RODATA,
+ import = __CALLIRQ__;
+}
+/*****************************************************************************/
+/* */
+/* 6502.h */
+/* */
+/* 6502 specific declarations */
+/* */
+/* */
+/* */
+/* (C) 1998-2012, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _6502_H
+#define _6502_H
+
+
+
+/* We need size_t */
+#ifndef _HAVE_size_t
+#define _HAVE_size_t
+typedef unsigned size_t;
+#endif
+
+
+
+/* Possible returns of getcpu() */
+#define CPU_6502 0
+#define CPU_65C02 1
+#define CPU_65816 2
+#define CPU_4510 3
+#define CPU_65SC02 4
+#define CPU_65CE02 5
+#define CPU_HUC6280 6
+#define CPU_2A0x 7
+#define CPU_45GS02 8
+
+unsigned char getcpu (void);
+/* Detect the CPU the program is running on */
+
+
+
+/* Macros for CPU instructions */
+#define BRK() __asm__ ("brk")
+#define CLI() __asm__ ("cli")
+#define SEI() __asm__ ("sei")
+
+
+
+/* Struct that holds the registers for the sys function */
+struct regs {
+ unsigned char a; /* A register value */
+ unsigned char x; /* X register value */
+ unsigned char y; /* Y register value */
+ unsigned char flags; /* Flags value */
+ unsigned pc; /* Program counter */
+};
+
+/* Defines for the flags in the regs structure */
+#define F6502_N 0x80 /* N flag */
+#define F6502_V 0x40 /* V flag */
+#define F6502_B 0x10 /* B flag */
+#define F6502_D 0x08 /* D flag */
+#define F6502_I 0x04 /* I flag */
+#define F6502_Z 0x02 /* Z flag */
+#define F6502_C 0x01 /* C flag */
+
+/* Function to call any machine language subroutine. All registers in the
+** regs structure are passed into the routine and the results are passed
+** out. The B flag is ignored on input. The called routine must end with
+** an RTS.
+*/
+void __fastcall__ _sys (struct regs* r);
+
+
+
+/* Set and reset the break vector. The given user function is called if
+** a break occurs. The values of the registers may be read from the brk_...
+** variables. The value in brk_pc will point to the address that contains
+** the brk instruction.
+** The set_brk function will install an exit handler that will reset the
+** vector if the program ends.
+*/
+
+extern unsigned char brk_a; /* A register value */
+extern unsigned char brk_x; /* X register value */
+extern unsigned char brk_y; /* Y register value */
+extern unsigned char brk_sr; /* Status register */
+extern unsigned brk_pc; /* PC value */
+
+typedef void (*brk_handler) (void);
+/* Type of the break handler */
+
+void __fastcall__ set_brk (brk_handler f);
+/* Set the break vector to the given address */
+
+void reset_brk (void);
+/* Reset the break vector to the original value */
+
+
+
+/* Possible returns for irq_handler() */
+#define IRQ_NOT_HANDLED 0
+#define IRQ_HANDLED 1
+
+typedef unsigned char (*irq_handler) (void);
+/* Type of the C level interrupt request handler */
+
+void __fastcall__ set_irq (irq_handler f, void *stack_addr, size_t stack_size);
+/* Set the C level interrupt request vector to the given address */
+
+void reset_irq (void);
+/* Reset the C level interrupt request vector */
+
+
+
+/* End of 6502.h */
+#endif
+/*****************************************************************************/
+/* */
+/* _6522.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* */
+/* */
+/* (C) 2004 Stefan Haubenthal */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef __VIA_H
+#define __VIA_H
+
+
+
+/* Define a structure with the 6522 register offsets.
+** NOTE: The timer registers are not declared as 16 bit registers, because
+** the order in which the two 8 bit halves are written is important, and
+** the compiler doesn't guarantee any order when writing 16 bit values.
+*/
+struct __6522 {
+ unsigned char prb; /* Port register B */
+ unsigned char pra; /* Port register A */
+ unsigned char ddrb; /* Data direction register B */
+ unsigned char ddra; /* Data direction register A */
+ unsigned char t1_lo; /* Timer 1, low byte */
+ unsigned char t1_hi; /* Timer 1, high byte */
+ unsigned char t1l_lo; /* Timer 1 latch, low byte */
+ unsigned char t1l_hi; /* Timer 1 latch, high byte */
+ unsigned char t2_lo; /* Timer 2, low byte */
+ unsigned char t2_hi; /* Timer 2, high byte */
+ unsigned char sr; /* Shift register */
+ unsigned char acr; /* Auxiliary control register */
+ unsigned char pcr; /* Peripheral control register */
+ unsigned char ifr; /* Interrupt flag register */
+ unsigned char ier; /* Interrupt enable register */
+ unsigned char pra2; /* Port register A w/o handshake */
+};
+
+
+
+/* End of _6522.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* _6525.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* */
+/* */
+/* (C) 1998-2000 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@musoftware.de */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef __6525_H
+#define __6525_H
+
+
+
+/* Define a structure with the 6525 register offsets. The shadow registers
+** (if port C is unused) are currently not implemented, we would need a
+** union to do that, however that would introduce an additional name.
+*/
+struct __6525 {
+ unsigned char pra; /* Port register A */
+ unsigned char prb; /* Port register B */
+ unsigned char prc; /* Port register C */
+ unsigned char ddra; /* Data direction register A */
+ unsigned char ddrb; /* Data direction register B */
+ unsigned char ddrc; /* Data direction register C */
+ unsigned char cr; /* Control register */
+ unsigned char air; /* Active interrupt register */
+};
+
+
+
+/* End of _6525.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* _6526.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* */
+/* */
+/* (C) 1998-2000 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@musoftware.de */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef __6526_H
+#define __6526_H
+
+
+
+/* Define a structure with the 6526 register offsets.
+** NOTE: The timer registers are not declared as 16 bit registers, because
+** the order in which the two 8 bit halves are written is important, and
+** the compiler doesn't guarantee any order when writing 16 bit values.
+*/
+struct __6526 {
+ unsigned char pra; /* Port register A */
+ unsigned char prb; /* Port register B */
+ unsigned char ddra; /* Data direction register A */
+ unsigned char ddrb; /* Data direction register B */
+ unsigned char ta_lo; /* Timer A, low byte */
+ unsigned char ta_hi; /* Timer A, high byte */
+ unsigned char tb_lo; /* Timer B, low byte */
+ unsigned char tb_hi; /* Timer B, high byte */
+ unsigned char tod_10; /* TOD, 1/10 sec. */
+ unsigned char tod_sec; /* TOD, seconds */
+ unsigned char tod_min; /* TOD, minutes */
+ unsigned char tod_hour; /* TOD, hours */
+ unsigned char sdr; /* Serial data register */
+ unsigned char icr; /* Interrupt control register */
+ unsigned char cra; /* Control register A */
+ unsigned char crb; /* Control register B */
+};
+
+
+
+/* End of _6526.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* _6545.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* */
+/* */
+/* (C) 1998-2000 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@musoftware.de */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef __6545_H
+#define __6545_H
+
+
+
+/* Define a structure with the 6545 register offsets */
+struct __6545 {
+ unsigned char ctrl; /* Control register */
+ unsigned char data; /* Data register */
+};
+
+
+
+/* End of _6545.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* _6551.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* */
+/* */
+/* (C) 1998-2000 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@musoftware.de */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef __6551_H
+#define __6551_H
+
+
+
+/* Define a structure with the 6551 register offsets */
+struct __6551 {
+ unsigned char data; /* Data register */
+ unsigned char status; /* Status register */
+ unsigned char cmd; /* Command register */
+ unsigned char ctrl; /* Control register */
+};
+
+
+
+/* End of _6551.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* _antic.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* */
+/* "ANTIC, Alphanumeric Television Interface Controller, is responsible for */
+/* the generation of playfield graphics which is delivered as a datastream */
+/* to the related CTIA/GTIA chip. The CTIA/GTIA provides the coloring of the */
+/* playfield graphics, and is responsible for adding overlaid sprite */
+/* (referred to as "Player/Missile graphics" by Atari). Atari advertised it */
+/* as a true microprocessor, in that it has an instruction set to run */
+/* programs (called display lists) to process data. ANTIC has no capacity */
+/* for writing back computed values to memory, it merely reads data from */
+/* memory and processes it for output to the screen, therefore it is not */
+/* Turing complete." - Wikipedia article on "ANTIC" (with edits) */
+/* */
+/* (C) 2000 Freddy Offenga */
+/* 24-Jan-2011: Christian Krueger: Added defines for Antic instruction set */
+/* 2019-01-16: Bill Kendrick : More defines for registers */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+#ifndef __ANTIC_H
+#define __ANTIC_H
+
+/*****************************************************************************/
+/* Define a structure with the ANTIC coprocessor's register offsets */
+/*****************************************************************************/
+
+struct __antic {
+ unsigned char dmactl; /* (W) direct memory access control */
+ unsigned char chactl; /* (W) character mode control */
+ unsigned char dlistl; /* display list pointer low-byte */
+ unsigned char dlisth; /* display list pointer high-byte */
+ unsigned char hscrol; /* (W) horizontal scroll enable */
+ unsigned char vscrol; /* (W) vertical scroll enable */
+ unsigned char unuse0; /* unused */
+ unsigned char pmbase; /* (W) msb of p/m base address (for when DMACTL has player and/or missile DMA enabled) */
+ unsigned char unuse1; /* unused */
+ unsigned char chbase; /* (W) msb of character set base address */
+ unsigned char wsync; /* (W) wait for horizontal synchronization */
+ unsigned char vcount; /* (R) vertical line counter */
+ unsigned char penh; /* (R) light pen horizontal position */
+ unsigned char penv; /* (R) light pen vertical position */
+ unsigned char nmien; /* (W) non-maskable interrupt enable */
+ union {
+ /* (W) ("NMIRES") nmi reset -- clears the interrupt request register;
+ ** resets all of the NMI status together
+ */
+ unsigned char nmires;
+
+ /* (R) ("NMIST") nmi status -- holds cause for the NMI interrupt */
+ unsigned char nmist;
+ };
+};
+
+
+/*****************************************************************************/
+/* DMACTL register options */
+/*****************************************************************************/
+
+/* Initialized to 0x22: DMA fetch, normal playfield, no PMG DMA, double-line PMGs */
+
+/* Playfield modes: */
+#define DMACTL_PLAYFIELD_NONE 0x00
+#define DMACTL_PLAYFIELD_NARROW 0x01 /* e.g., 32 bytes per scanline with thick borders */
+#define DMACTL_PLAYFIELD_NORMAL 0x02 /* e.g., 40 bytes per scanline with normal borders */
+#define DMACTL_PLAYFIELD_WIDE 0x03 /* e.g., 48 bytes per scanline with no borders (overscan) */
+
+/* Other options: */
+
+/* If not set, GTIA's GRAFP0 thru GRAFP3, and/or GRAFM registers are used for
+** player & missile shapes, respectively. (Modify the registers during the horizontal blank
+** (Display List Interrupt), a la "racing the beam" on an Atari VCS/2600, )
+** if set, ANTIC's PMBASE will be used to fetch shapes from memory via DMA.
+*/
+#define DMACTL_DMA_MISSILES 0x04
+#define DMACTL_DMA_PLAYERS 0x08
+
+/* Unless set, PMGs (as fetched via DMA) will be double-scanline resolution */
+#define DMACTL_PMG_SINGLELINE 0x10
+
+/* Unless set, ANTIC operation is disabled, since it cannot fetch
+** Display List instructions
+*/
+#define DMACTL_DMA_FETCH 0x20
+
+
+/*****************************************************************************/
+/* CHACTL register options */
+/*****************************************************************************/
+
+/* Initialized to 2 (CHACTL_CHAR_NORMAL | CHACTL_INV_PRESENT) */
+
+/* Inverted (upside-down) characters */
+#define CHACTL_CHAR_NORMAL 0x00
+#define CHACTL_CHAR_INVERTED 0x04
+
+/* Inverse (reverse-video) characters */
+#define CHACTL_INV_TRANS 0x00 /* chars with high-bit shown */
+#define CHACTL_INV_OPAQUE 0x01 /* chars with high-bit appear as space */
+#define CHACTL_INV_PRESENT 0x02 /* chars with high-bit are reverse-video */
+
+
+/*****************************************************************************/
+/* Values for NMIEN (enabling interrupts) & NMIST (cause for the interrupt) */
+/*****************************************************************************/
+
+/* Display List Interrupts
+** Called on a modeline when "DL_DLI" bit is set the ANTIC instruction,
+** and jumps through VDSLST vector.
+*/
+#define NMIEN_DLI 0x80
+
+/* Vertical Blank Interrupt
+** Called during every vertical blank; see SYSVBV, VVBLKI, CRITIC, and VVBLKD,
+** as well as the SETVBV routine.
+*/
+#define NMIEN_VBI 0x40
+
+/* [Reset] key pressed */
+#define NMIEN_RESET 0x20
+
+
+/*****************************************************************************/
+/* ANTIC instruction set */
+/*****************************************************************************/
+
+/* Absolute instructions (non mode lines) */
+#define DL_JMP ((unsigned char) 1)
+#define DL_JVB ((unsigned char) 65)
+
+#define DL_BLK1 ((unsigned char) 0) /* 1 blank scanline */
+#define DL_BLK2 ((unsigned char) 16) /* 2 blank scanlines */
+#define DL_BLK3 ((unsigned char) 32) /* ...etc. */
+#define DL_BLK4 ((unsigned char) 48)
+#define DL_BLK5 ((unsigned char) 64)
+#define DL_BLK6 ((unsigned char) 80)
+#define DL_BLK7 ((unsigned char) 96)
+#define DL_BLK8 ((unsigned char) 112)
+
+
+/* Absolute instructions (mode lines) */
+
+/* Note: Actual width varies (e.g., 40 vs 32 vs 48) depending on
+** normal vs narrow vs wide (overscan) playfield setting; see DMACTL
+*/
+
+/* Character modes (text, tile graphics, etc.) */
+
+/* monochrome, 40 character & 8 scanlines per mode line (aka Atari BASIC GRAPHICS 0 via OS's CIO routines) */
+#define DL_CHR40x8x1 ((unsigned char) 2)
+
+/* monochrome, 40 character & 10 scanlines per mode line (like GR. 0, with descenders) */
+#define DL_CHR40x10x1 ((unsigned char) 3)
+
+/* colour, 40 character & 8 scanlines per mode line (GR. 12) */
+#define DL_CHR40x8x4 ((unsigned char) 4)
+
+/* colour, 40 character & 16 scanlines per mode line (GR. 13) */
+#define DL_CHR40x16x4 ((unsigned char) 5)
+
+/* colour (duochrome per character), 20 character & 8 scanlines per mode line (GR. 1) */
+#define DL_CHR20x8x2 ((unsigned char) 6)
+
+/* colour (duochrome per character), 20 character & 16 scanlines per mode line (GR. 2) */
+#define DL_CHR20x16x2 ((unsigned char) 7)
+
+
+/* Bitmap modes */
+
+/* colour, 40 pixel & 8 scanlines per mode line (GR. 3) */
+#define DL_MAP40x8x4 ((unsigned char) 8)
+
+/* 'duochrome', 80 pixel & 4 scanlines per mode line (GR.4) */
+#define DL_MAP80x4x2 ((unsigned char) 9)
+
+/* colour, 80 pixel & 4 scanlines per mode line (GR.5) */
+#define DL_MAP80x4x4 ((unsigned char) 10)
+
+/* 'duochrome', 160 pixel & 2 scanlines per mode line (GR.6) */
+#define DL_MAP160x2x2 ((unsigned char) 11)
+
+/* 'duochrome', 160 pixel & 1 scanline per mode line (GR.14) */
+#define DL_MAP160x1x2 ((unsigned char) 12)
+
+/* 4 colours, 160 pixel & 2 scanlines per mode line (GR.7) */
+#define DL_MAP160x2x4 ((unsigned char) 13)
+
+/* 4 colours, 160 pixel & 1 scanline per mode line (GR.15) */
+#define DL_MAP160x1x4 ((unsigned char) 14)
+
+/* monochrome, 320 pixel & 1 scanline per mode line (GR.8) */
+#define DL_MAP320x1x1 ((unsigned char) 15)
+
+
+/* Equivalents, for people familiar with Atari 8-bit OS */
+
+#define DL_GRAPHICS0 DL_CHR40x8x1
+#define DL_GRAPHICS1 DL_CHR20x8x2
+#define DL_GRAPHICS2 DL_CHR20x16x2
+#define DL_GRAPHICS3 DL_MAP40x8x4
+#define DL_GRAPHICS4 DL_MAP80x4x2
+#define DL_GRAPHICS5 DL_MAP80x4x4
+#define DL_GRAPHICS6 DL_MAP160x2x2
+#define DL_GRAPHICS7 DL_MAP160x2x4
+#define DL_GRAPHICS8 DL_MAP320x1x1
+#define DL_GRAPHICS9 DL_MAP320x1x1 /* N.B.: GRAPHICS 9, 10, and 11 also involve GTIA's PRIOR register */
+#define DL_GRAPHICS10 DL_MAP320x1x1
+#define DL_GRAPHICS11 DL_MAP320x1x1
+#define DL_GRAPHICS12 DL_CHR40x8x4 /* N.B.: Atari 400/800 OS didn't have GRAPHICS 12 or 13 */
+#define DL_GRAPHICS13 DL_CHR40x16x4
+#define DL_GRAPHICS14 DL_MAP160x1x2
+#define DL_GRAPHICS15 DL_MAP160x1x4
+
+/* Atari 400/800 OS didn't have GRAPHICS 14 or 15, so they were known by "6+" and "7+" */
+#define DL_GRAPHICS6PLUS DL_GRAPHICS14
+#define DL_GRAPHICS7PLUS DL_GRAPHICS15
+
+/* Neither Atari 400/800 nor XL OS supported 10-scanline (descenders) text mode via CIO */
+#define DL_GRAPHICS0_DESCENDERS DL_CHR40x10x1
+
+/* Modifiers to mode lines */
+#define DL_HSCROL(x) ((unsigned char)((x) | 16)) /* enable smooth horizontal scrolling on this line; see HSCROL */
+#define DL_VSCROL(x) ((unsigned char)((x) | 32)) /* enable smooth vertical scrolling on this line; see VSCROL */
+#define DL_LMS(x) ((unsigned char)((x) | 64)) /* Load Memory Scan (next two bytes must be the LSB/MSB of the data to load) */
+
+/* General modifier */
+#define DL_DLI(x) ((unsigned char)((x) | 128)) /* enable Display List Interrupt on this mode line */
+
+
+/* End of _antic.h */
+#endif /* #ifndef __ANTIC_H */
+/*****************************************************************************/
+/* */
+/* _atari5200os.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+#ifndef __ATARI5200OS_H
+#define __ATARI5200OS_H
+
+
+struct __os {
+
+ /*Page zero*/
+ unsigned char pokmsk; // = $00 System mask for POKEY IRQ enable
+ unsigned char rtclok[2]; // = $01,$02 Real time clock
+ unsigned char critic; // = $03 Critical section flag
+ unsigned char atract; // = $04 Attract mode counter
+
+ union {
+ struct {
+ unsigned char sdlstl; // = $05 Save display list LO
+ unsigned char sdlsth; // = $06 Save display list HI
+ };
+ void* sdlst; // = $05,$06 Display list shadow
+ };
+
+ unsigned char sdmctl; // = $07 DMACTL shadow
+ unsigned char pcolr0; // = $08 PM color 0
+ unsigned char pcolr1; // = $09 PM color 1
+ unsigned char pcolr2; // = $0A PM color 2
+ unsigned char pcolr3; // = $0B PM color 3
+ unsigned char color0; // = $0C PF color 0
+ unsigned char color1; // = $0D PF color 1
+ unsigned char color2; // = $0E PF color 2
+ unsigned char color3; // = $0F PF color 3
+ unsigned char color4; // = $10 PF color 4
+ unsigned char paddl0; // = $11 POT0 Shadow
+ unsigned char paddl1; // = $12 POT1 Shadow
+ unsigned char paddl2; // = $13 POT2 Shadow
+ unsigned char paddl3; // = $14 POT3 Shadow
+ unsigned char paddl4; // = $15 POT4 Shadow
+ unsigned char paddl5; // = $16 POT5 Shadow
+ unsigned char paddl6; // = $17 POT6 Shadow
+ unsigned char paddl7; // = $18 POT7 Shadow
+
+ /*cc65 runtime zero page variables*/
+ unsigned char rowcrs_5200; // = $19 Cursor row (conio)
+ unsigned char colcrs_5200; // = $1A Cursor column (conio)
+ unsigned char* savmsc; // = $1B/$1C Pointer to screen memory (conio)
+
+ unsigned char _filler_1[0xE3]; // = $1D-$FF Filler
+
+ /*Stack*/
+ unsigned char stack[0x100]; // = $100-$1FF Stack
+
+ /*Page 2 OS variables*/
+ void (*vinter)(void); // = $200 Immediate IRQ vector
+ void (*vvblki)(void); // = $202 Immediate VBI vector
+ void (*vvblkd)(void); // = $204 Deferred VBI vector
+ void (*vdslst)(void); // = $206 DLI vector
+ void (*vkeybd)(void); // = $208 Keyboard IRQ vector
+ void (*vkeypd)(void); // = $20A Keyboard continuation vector
+ void (*vbrkky)(void); // = $20C Break key interrupt vector
+ void (*vbreak)(void); // = $20E BRK instruction interrupt vector
+ void (*vserin)(void); // = $210 Serial input ready vector
+ void (*vseror)(void); // = $212 Serial output data needed vector
+ void (*vseroc)(void); // = $214 Serial output completed vector
+ void (*vtimr1)(void); // = $216 POKEY timer 1 IRQ vector
+ void (*vtimr2)(void); // = $218 POKEY timer 2 IRQ vector
+ void (*vtimr4)(void); // = $21A POKEY timer 4 IRQ vector
+
+};
+
+#endif
+/*****************************************************************************/
+/* */
+/* _atarios.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+#ifndef __ATARIOS_H
+#define __ATARIOS_H
+
+
+/* IOCB Command Codes */
+
+#define IOCB_OPEN 0x03 /* open */
+#define IOCB_GETREC 0x05 /* get record */
+#define IOCB_GETCHR 0x07 /* get character(s) */
+#define IOCB_PUTREC 0x09 /* put record */
+#define IOCB_PUTCHR 0x0B /* put character(s) */
+#define IOCB_CLOSE 0x0C /* close */
+#define IOCB_STATIS 0x0D /* status */
+#define IOCB_SPECIL 0x0E /* special */
+#define IOCB_DRAWLN 0x11 /* draw line */
+#define IOCB_FILLIN 0x12 /* draw line with right fill */
+#define IOCB_RENAME 0x20 /* rename disk file */
+#define IOCB_DELETE 0x21 /* delete disk file */
+#define IOCB_LOCKFL 0x23 /* lock file (set to read-only) */
+#define IOCB_UNLOCK 0x24 /* unlock file */
+#define IOCB_POINT 0x25 /* point sector */
+#define IOCB_NOTE 0x26 /* note sector */
+#define IOCB_GETFL 0x27 /* get file length */
+#define IOCB_CHDIR_MYDOS 0x29 /* change directory (MyDOS) */
+#define IOCB_MKDIR 0x2A /* make directory (MyDOS/SpartaDOS) */
+#define IOCB_RMDIR 0x2B /* remove directory (SpartaDOS) */
+#define IOCB_CHDIR_SPDOS 0x2C /* change directory (SpartaDOS) */
+#define IOCB_GETCWD 0x30 /* get current directory (MyDOS/SpartaDOS) */
+#define IOCB_FORMAT 0xFE /* format */
+
+
+/* Device control block */
+
+struct __dcb {
+ unsigned char ddevic; /* device id */
+ unsigned char dunit; /* unit number */
+ unsigned char dcomnd; /* command */
+ unsigned char dstats; /* command type / status return */
+ void *dbuf; /* pointer to buffer */
+ unsigned char dtimlo; /* device timeout in seconds */
+ unsigned char dunuse; /* - unused - */
+ unsigned int dbyt; /* # of bytes to transfer */
+ union {
+ struct {
+ unsigned char daux1; /* 1st command auxiliary byte */
+ unsigned char daux2; /* 2nd command auxiliary byte */
+ };
+ unsigned int daux; /* auxiliary as word */
+ };
+};
+
+typedef struct __dcb dcb_t;
+
+
+/* I/O control block */
+
+struct __iocb {
+ unsigned char handler; /* handler index number (0xff free) */
+ unsigned char drive; /* device number (drive) */
+ unsigned char command; /* command */
+ unsigned char status; /* status of last operation */
+ void* buffer; /* pointer to buffer */
+ void* put_byte; /* pointer to device's PUT BYTE routine */
+ unsigned int buflen; /* length of buffer */
+ unsigned char aux1; /* 1st auxiliary byte */
+ unsigned char aux2; /* 2nd auxiliary byte */
+ unsigned char aux3; /* 3rd auxiliary byte */
+ unsigned char aux4; /* 4th auxiliary byte */
+ unsigned char aux5; /* 5th auxiliary byte */
+ unsigned char spare; /* spare byte */
+};
+
+typedef struct __iocb iocb_t;
+
+
+/* DOS 2.x zeropage variables */
+
+struct __dos2x {
+ unsigned char* zbufp; /* points to user filename */
+ unsigned char* zdrva; /* points to serveral buffers (mostly VTOC) */
+ unsigned char* zsba; /* points to sector buffer */
+ unsigned char errno; /* number of occurred error */
+};
+
+typedef struct __dos2x dos2x_t;
+
+
+/* A single device handler formed by it's routines */
+
+struct __devhdl {
+ void *open; /* address of OPEN routine -1 */
+ void *close; /* address of CLOSE routine -1 */
+ void *get; /* address of GET BYTE routine -1 */
+ void *put; /* address of PUT BYTE routine -1 */
+ void *status; /* address of GET STATUS routine -1 */
+ void *special; /* address od SPECIAL routine -1 */
+ unsigned char jmp_inst; /* a "JMP" byte, should be $4C */
+ void (*init)(void); /* init routine (JMP INIT) */
+ unsigned char reserved; /* unused */
+};
+
+typedef struct __devhdl devhdl_t;
+
+
+/* List of device handlers, as managed in HATABS */
+
+struct __hatabs {
+ unsigned char id; /* ATASCII code of handler e.g. 'C','D','E','K','P','S','R' */
+ devhdl_t* devhdl; /* Pointer to routines of device */
+};
+
+typedef struct __hatabs hatabs_t;
+
+
+/* Floating point register */
+
+struct __fpreg {
+#ifdef OS_REV2
+ unsigned char fr;
+ unsigned char frm[5]; /* 5-byte register mantissa */
+#else
+ unsigned char fr[6]; /* 6 bytes for single register */
+#endif
+};
+
+typedef struct __fpreg fpreg_t;
+
+enum { /* enum for access of floating point registers */
+ FPIDX_R0 = 0, /* (to use as index) */
+ FPIDX_RE = 1,
+ FPIDX_R1 = 2,
+ FPIDX_R2 = 3
+};
+
+
+/* Define a structure with atari os register offsets */
+
+struct __os {
+
+ // --- Zero-Page ---
+
+#ifdef OSA
+ unsigned char* linzbs; // = $00/$01 LINBUG RAM (WILL BE REPLACED BY MONITOR RAM)
+#else
+ unsigned char linflg; // = $00 LNBUG FLAG (0 = NOT LNBUG)
+ unsigned char ngflag; // = $01 MEMORY STATUS (0 = FAILURE)
+#endif
+ unsigned char* casini; // = $02/$03 CASSETTE INIT LOCATION
+ unsigned char* ramlo; // = $04/$05 RAM POINTER FOR MEMORY TEST
+
+#ifdef OSA
+ unsigned char tramsz; // = $06 FLAG FOR LEFT CARTRIDGE
+ unsigned char tstdat; // = $07 FLAG FOR RIGHT CARTRIDGE
+#else
+ unsigned char trnsmz; // = $06 TEMPORARY REGISTER FOR RAM SIZE
+ unsigned char tstdat; // = $07 UNUSED (NOT TOUCHED DURING RESET/COLD START)
+#endif
+
+ // Cleared upon Coldstart only
+
+ unsigned char warmst; // = $08 WARM START FLAG
+ unsigned char bootq; // = $09 SUCCESSFUL BOOT FLAG
+ void (*dosvec)(void); // = $0A/$0B DISK SOFTWARE START VECTOR
+ void (*dosini)(void); // = $0C/$0D DISK SOFTWARE INIT ADDRESS
+ unsigned char* appmhi; // = $0E/$0F APPLICATIONS MEMORY HI LIMIT
+
+ // Cleared upon Coldstart or Warmstart
+
+ unsigned char pokmsk; // = $10 SYSTEM MASK FOR POKEY IRQ ENABLE
+ unsigned char brkkey; // = $11 BREAK KEY FLAG
+ unsigned char rtclok[3]; // = $12-$14 REAL TIME CLOCK (IN 16 MSEC UNITS)
+ unsigned char* bufadr; // = $15/$16 INDIRECT BUFFER ADDRESS REGISTER
+ unsigned char iccomt; // = $17 COMMAND FOR VECTOR
+ unsigned char* dskfms; // = $18/$19 DISK FILE MANAGER POINTER
+ unsigned char* dskutl; // = $1A/$1B DISK UTILITIES POINTER
+#ifdef OSA
+ unsigned char ptimot; // = $1C PRINTER TIME OUT REGISTER
+ unsigned char pbpnt; // = $1D PRINT BUFFER POINTER
+ unsigned char pbufsz; // = $1E PRINT BUFFER SIZE
+ unsigned char ptemp; // = $1F TEMPORARY REGISTER
+#else
+ unsigned char abufpt[4]; // = $1C-$1F ACMI BUFFER POINTER AREA
+#endif
+ iocb_t ziocb; // = $20-$2F ZERO PAGE I/O CONTROL BLOCK
+
+ unsigned char status; // = $30 INTERNAL STATUS STORAGE
+ unsigned char chksum; // = $31 CHECKSUM (SINGLE BYTE SUM WITH CARRY)
+ unsigned char* bufr; // = $32/$33 POINTER TO DATA BUFFER
+ unsigned char* bfen; // = $34/$35 NEXT BYTE PAST END OF THE DATA BUFFER LO
+#ifdef OSA
+ unsigned char cretry; // = $36 NUMBER OF COMMAND FRAME RETRIES
+ unsigned char dretry; // = $37 NUMBER OF DEVICE RETRIES
+#else
+ unsigned int ltemp; // = $36/$37 LOADER TEMPORARY
+#endif
+ unsigned char bufrfl; // = $38 DATA BUFFER FULL FLAG
+ unsigned char recvdn; // = $39 RECEIVE DONE FLAG
+ unsigned char xmtdon; // = $3A TRANSMISSION DONE FLAG
+ unsigned char chksnt; // = $3B CHECKSUM SENT FLAG
+ unsigned char nocksm; // = $3C NO CHECKSUM FOLLOWS DATA FLAG
+ unsigned char bptr; // = $3D CASSETTE BUFFER POINTER
+ unsigned char ftype; // = $3E CASSETTE IRG TYPE
+ unsigned char feof; // = $3F CASSETTE EOF FLAG (0 // = QUIET)
+
+ unsigned char freq; // = $40 CASSETTE BEEP COUNTER
+ unsigned char soundr; // = $41 NOISY I/0 FLAG. (ZERO IS QUIET)
+ unsigned char critic; // = $42 DEFINES CRITICAL SECTION (CRITICAL IF NON-Z)
+ dos2x_t fmszpg; // = $43-$49 DISK FILE MANAGER SYSTEM ZERO PAGE
+#ifdef OSA
+ unsigned char ckey; // = $4A FLAG SET WHEN GAME START PRESSED
+ unsigned char cassbt; // = $4B CASSETTE BOOT FLAG
+#else
+ void* zchain; // = $4A/$4B HANDLER LINKAGE CHAIN POINTER
+#endif
+ unsigned char dstat; // = $4C DISPLAY STATUS
+ unsigned char atract; // = $4D ATRACT FLAG
+ unsigned char drkmsk; // = $4E DARK ATRACT MASK
+ unsigned char colrsh; // = $4F ATRACT COLOR SHIFTER (EOR'ED WITH PLAYFIELD
+
+ unsigned char tmpchr; // = $50 TEMPORARY CHARACTER
+ unsigned char hold1; // = $51 TEMPORARY
+ unsigned char lmargn; // = $52 LEFT MARGIN (NORMALLY 2, CC65 C STARTUP CODE SETS IT TO 0)
+ unsigned char rmargn; // = $53 RIGHT MARGIN (NORMALLY 39 IF NO XEP80 IS USED)
+ unsigned char rowcrs; // = $54 1CURSOR ROW
+ unsigned int colcrs; // = $55/$56 CURSOR COLUMN
+ unsigned char dindex; // = $57 DISPLAY MODE
+ unsigned char* savmsc; // = $58/$59 SAVED MEMORY SCAN COUNTER
+ unsigned char oldrow; // = $5A PRIOR ROW
+ unsigned int oldcol; // = $5B/$5C PRIOR COLUMN
+ unsigned char oldchr; // = $5D DATA UNDER CURSOR
+ unsigned char* oldadr; // = $5E/$5F SAVED CURSOR MEMORY ADDRESS
+
+#ifdef OSA
+ unsigned char newrow; // = $60 POINT DRAW GOES TO
+ unsigned int newcol; // = $61/$62 COLUMN DRAW GOES TO
+#else
+ unsigned char* fkdef; // = $60/$61 FUNCTION KEY DEFINITION TABLE
+ unsigned char palnts; // = $62 PAL/NTSC INDICATOR (0 // = NTSC)
+#endif
+ unsigned char logcol; // = $63 POINTS AT COLUMN IN LOGICAL LINE
+ unsigned char* adress; // = $64/$65 TEMPORARY ADDRESS
+ unsigned int mlttmp; // = $66/$67 TEMPORARY / FIRST BYTE IS USED IN OPEN AS TEMP
+ unsigned int savadr; // = $68/$69 SAVED ADDRESS
+ unsigned char ramtop; // = $6A RAM SIZE DEFINED BY POWER ON LOGIC
+ unsigned char bufcnt; // = $6B BUFFER COUNT
+ unsigned char* bufstr; // = $6C/$6D EDITOR GETCH POINTER
+ unsigned char bitmsk; // = $6E BIT MASK
+ unsigned char shfamt; // = $6F SHIFT AMOUNT FOR PIXEL JUSTIFUCATION
+
+ unsigned int rowac; // = $70/$71 DRAW WORKING ROW
+ unsigned int colac; // = $72/$73 DRAW WORKING COLUMN
+ unsigned char* endpt; // = $74/$75 END POINT
+ unsigned char deltar; // = $76 ROW DIFFERENCE
+ unsigned int deltac; // = $77/$78 COLUMN DIFFERENCE
+#ifdef OSA
+ unsigned char rowinc; // = $79 ROWINC
+ unsigned char colinc; // = $7A COLINC
+#else
+ unsigned char* keydef; // = $79/$7A 2-BYTE KEY DEFINITION TABLE ADDRESS
+#endif
+ unsigned char swpflg; // = $7B NON-0 1F TXT AND REGULAR RAM IS SWAPPED
+ unsigned char holdch; // = $7C CH IS MOVED HERE IN KGETCH BEFORE CNTL & SH
+ unsigned char insdat; // = $7D 1-BYTE TEMPORARY
+ unsigned int countr; // = $7E/$7F 2-BYTE DRAW ITERATION COUNT
+
+ unsigned char _free_1[0xD4-0x7F-1]; // USER SPACE
+
+ // Floating Point Package Page Zero Address Equates
+ fpreg_t fpreg[4]; // = $D4-$EB 4 REGSITERS, ACCCESS LIKE "fpreg[FPIDX_R0].fr"
+ unsigned char frx; // = $EC 1-BYTE TEMPORARY
+ unsigned char eexp; // = $ED VALUE OF EXP
+#ifdef OS_REV2
+ unsigned char frsign; // = $EE ##REV2## 1-BYTE FLOATING POINT SIGN
+ unsigned char plycnt; // = $EF ##REV2## 1-BYTE POLYNOMIAL DEGREE
+ unsigned char sgnflg; // = $F0 ##REV2## 1-BYTE SIGN FLAG
+ unsigned char xfmflg; // = $F1 ##REV2## 1-BYTE TRANSFORM FLAG
+#else
+ unsigned char nsign; // = $EE SIGN OF #
+ unsigned char esign; // = $EF SIGN OF EXPONENT
+ unsigned char fchrflg; // = $F0 1ST CHAR FLAG
+ unsigned char digrt; // = $F1 # OF DIGITS RIGHT OF DECIMAL
+#endif
+ unsigned char cix; // = $F2 CURRENT INPUT INDEX
+ unsigned char* inbuff; // = $F3/$F4 POINTS TO USER'S LINE INPUT BUFFER
+ unsigned int ztemp1; // = $F5/$F6 2-BYTE TEMPORARY
+ unsigned int ztemp4; // = $F7/$F8 2-BYTE TEMPORARY
+ unsigned int ztemp3; // = $F9/$FA 2-BYTE TEMPORARY
+
+ union {
+ unsigned char degflg; // = $FB ##OLD## SAME AS RADFLG
+ unsigned char radflg; // = $FB ##OLD## 0=RADIANS, 6=DEGREES
+ };
+
+ fpreg_t* flptr; // = $FC/$FD 2-BYTE FLOATING POINT NUMBER POINTER
+ fpreg_t* fptr2; // = $FE/$FF 2-BYTE FLOATING POINT NUMBER POINTER
+
+ // --- Page 1 ---
+
+ unsigned char stack[0x100]; // STACK
+
+ // --- Page 2 ---
+
+ void (*vdslst)(void); // = $0200/$0201 DISPLAY LIST NMI VECTOR
+ void (*vprced)(void); // = $0202/$0203 PROCEED LINE IRQ VECTOR
+ void (*vinter)(void); // = $0204/$0205 INTERRUPT LINE IRQ VECTOR
+ void (*vbreak)(void); // = $0206/$0207 SOFTWARE BREAK (00) INSTRUCTION IRQ VECTOR
+ void (*vkeybd)(void); // = $0208/$0209 POKEY KEYBOARD IRQ VECTOR
+ void (*vserin)(void); // = $020A/$020B POKEY SERIAL INPUT READY IRQ
+ void (*vseror)(void); // = $020C/$020D POKEY SERIAL OUTPUT READY IRQ
+ void (*vseroc)(void); // = $020E/$020F POKEY SERIAL OUTPUT COMPLETE IRQ
+ void (*vtimr1)(void); // = $0210/$0211 POKEY TIMER 1 IRQ
+ void (*vtimr2)(void); // = $0212/$0213 POKEY TIMER 2 IRQ
+ void (*vtimr4)(void); // = $0214/$0215 POKEY TIMER 4 IRQ
+ void (*vimirq)(void); // = $0216/$0217 IMMEDIATE IRQ VECTOR
+ unsigned int cdtmv1; // = $0218/$0219 COUNT DOWN TIMER 1
+ unsigned int cdtmv2; // = $021A/$021B COUNT DOWN TIMER 2
+ unsigned int cdtmv3; // = $021C/$021D COUNT DOWN TIMER 3
+ unsigned int cdtmv4; // = $021E/$021F COUNT DOWN TIMER 4
+ unsigned int cdtmv5; // = $0220/$0221 COUNT DOWN TIMER 5
+ void (*vvblki)(void); // = $0222/$0223 IMMEDIATE VERTICAL BLANK NMI VECTOR
+ void (*vvblkd)(void); // = $0224/$0225 DEFERRED VERTICAL BLANK NMI VECTOR
+ void (*cdtma1)(void); // = $0226/$0227 COUNT DOWN TIMER 1 JSR ADDRESS
+ void (*cdtma2)(void); // = $0228/$0229 COUNT DOWN TIMER 2 JSR ADDRESS
+ unsigned char cdtmf3; // = $022A COUNT DOWN TIMER 3 FLAG
+ unsigned char srtimr; // = $022B SOFTWARE REPEAT TIMER
+ unsigned char cdtmf4; // = $022C COUNT DOWN TIMER 4 FLAG
+ unsigned char intemp; // = $022D IAN'S TEMP
+ unsigned char cdtmf5; // = $022E COUNT DOWN TIMER FLAG 5
+ unsigned char sdmctl; // = $022F SAVE DMACTL REGISTER
+ union {
+ struct {
+ unsigned char sdlstl; // = $0230 SAVE DISPLAY LIST LOW BYTE
+ unsigned char sdlsth; // = $0231 SAVE DISPLAY LIST HI BYTE
+ };
+ void* sdlst; // = $0230/$0231 (same as above as pointer)
+ };
+ unsigned char sskctl; // = $0232 SKCTL REGISTER RAM
+#ifdef OSA
+ unsigned char _spare_1; // = $0233 No OS use.
+#else
+ unsigned char lcount; // = $0233 ##1200xl## 1-byte relocating loader record
+#endif
+ unsigned char lpenh; // = $0234 LIGHT PEN HORIZONTAL VALUE
+ unsigned char lpenv; // = $0235 LIGHT PEN VERTICAL VALUE
+ void (*brkky)(void); // = $0236/$0237 BREAK KEY VECTOR
+#ifdef OSA
+ unsigned char spare2[2]; // = $0238/$0239 No OS use.
+#else
+ void (*vpirq)(void); // = $0238/$0239 ##rev2## 2-byte parallel device IRQ vector
+#endif
+ unsigned char cdevic; // = $023A COMMAND FRAME BUFFER - DEVICE
+ unsigned char ccomnd; // = $023B COMMAND
+ union {
+ struct {
+ unsigned char caux1; // = $023C COMMAND AUX BYTE 1
+ unsigned char caux2; // = $023D COMMAND AUX BYTE 2
+ };
+ unsigned int caux; // = $023C/$023D (same as above as word)
+ };
+ unsigned char temp; // = $023E TEMPORARY RAM CELL
+ unsigned char errflg; // = $023F ERROR FLAG - ANY DEVICE ERROR EXCEPT TIME OUT
+ unsigned char dflags; // = $0240 DISK FLAGS FROM SECTOR ONE
+ unsigned char dbsect; // = $0241 NUMBER OF DISK BOOT SECTORS
+ unsigned char* bootad; // = $0242/$0243 ADDRESS WHERE DISK BOOT LOADER WILL BE PUT
+ unsigned char coldst; // = $0244 COLDSTART FLAG (1=IN MIDDLE OF COLDSTART>
+#ifdef OSA
+ unsigned char spare3; // = $0245 No OS use.
+#else
+ unsigned char reclen; // = $0245 ##1200xl## 1-byte relocating loader record length
+#endif
+ unsigned char dsktim; // = $0246 DISK TIME OUT REGISTER
+#ifdef OSA
+ unsigned char linbuf[40]; // = $0247-$026E ##old## CHAR LINE BUFFER
+#else
+ unsigned char pdvmsk; // = $0247 ##rev2## 1-byte parallel device selection mask
+ unsigned char shpdvs; // = $0248 ##rev2## 1-byte PDVS (parallel device select)
+ unsigned char pdimsk; // = $0249 ##rev2## 1-byte parallel device IRQ selection
+ unsigned int reladr; // = $024A/$024B ##rev2## 2-byte relocating loader relative adr.
+ unsigned char pptmpa; // = $024C ##rev2## 1-byte parallel device handler temporary
+ unsigned char pptmpx; // = $024D ##rev2## 1-byte parallel device handler temporary
+ unsigned char _reserved_1[29]; // = $024E-$026A RESERVED
+ unsigned char chsalt; // = $026B ##1200xl## 1-byte character set alternate
+ unsigned char vsflag; // = $026C ##1200xl## 1-byte fine vertical scroll count
+ unsigned char keydis; // = $026D ##1200xl## 1-byte keyboard disable
+ unsigned char fine; // = $026E ##1200xl## 1-byte fine scrolling mode
+#endif
+ unsigned char gprior; // = $026F GLOBAL PRIORITY CELL
+ unsigned char paddl0; // = $0270 1-BYTE POTENTIOMETER 0
+ unsigned char paddl1; // = $0271 1-BYTE POTENTIOMETER 1
+ unsigned char paddl2; // = $0272 1-BYTE POTENTIOMETER 2
+ unsigned char paddl3; // = $0273 1-BYTE POTENTIOMETER 3
+ unsigned char paddl4; // = $0274 1-BYTE POTENTIOMETER 4
+ unsigned char paddl5; // = $0275 1-BYTE POTENTIOMETER 5
+ unsigned char paddl6; // = $0276 1-BYTE POTENTIOMETER 6
+ unsigned char paddl7; // = $0277 1-BYTE POTENTIOMETER 7
+ unsigned char stick0; // = $0278 1-byte joystick 0
+ unsigned char stick1; // = $0279 1-byte joystick 1
+ unsigned char stick2; // = $027A 1-byte joystick 2
+ unsigned char stick3; // = $027B 1-byte joystick 3
+ unsigned char ptrig0; // = $027C 1-BYTE PADDLE TRIGGER 0
+ unsigned char ptrig1; // = $027D 1-BYTE PADDLE TRIGGER 1
+ unsigned char ptrig2; // = $027E 1-BYTE PADDLE TRIGGER 2
+ unsigned char ptrig3; // = $027F 1-BYTE PADDLE TRIGGER 3
+ unsigned char ptrig4; // = $0280 1-BYTE PADDLE TRIGGER 4
+ unsigned char ptrig5; // = $0281 1-BYTE PADDLE TRIGGER 5
+ unsigned char ptrig6; // = $0281 1-BYTE PADDLE TRIGGER 6
+ unsigned char ptrig7; // = $0283 1-BYTE PADDLE TRIGGER 7
+ unsigned char strig0; // = $0284 1-BYTE JOYSTICK TRIGGER 0
+ unsigned char strig1; // = $0285 1-BYTE JOYSTICK TRIGGER 1
+ unsigned char strig2; // = $0286 1-BYTE JOYSTICK TRIGGER 2
+ unsigned char strig3; // = $0287 1-BYTE JOYSTICK TRIGGER 3
+#ifdef OSA
+ unsigned char cstat; // = $0288 ##old## cassette status register
+#else
+ unsigned char hibyte; // = $0288 ##1200xl## 1-byte relocating loader high byte
+#endif
+ unsigned char wmode; // = $0289 1-byte cassette WRITE mode
+ unsigned char blim; // = $028A 1-byte cassette buffer limit
+#ifdef OSA
+ unsigned char _reserved_2[5]; // = $028B-$028F RESERVED
+#else
+ unsigned char imask; // = $028B ##rev2## (not used)
+ void (*jveck)(void); // = $028C/$028D 2-byte jump vector
+ unsigned newadr; // = $028E/028F ##1200xl## 2-byte relocating address
+#endif
+ unsigned char txtrow; // = $0290 TEXT ROWCRS
+ unsigned txtcol; // = $0291/$0292 TEXT COLCRS
+ unsigned char tindex; // = $0293 TEXT INDEX
+ unsigned char* txtmsc; // = $0294/$0295 FOOLS CONVRT INTO NEW MSC
+ unsigned char txtold[6]; // = $0296-$029B OLDROW & OLDCOL FOR TEXT (AND THEN SOME)
+#ifdef OSA
+ unsigned char tmpx1; // = $029C ##old## 1--byte temporary register
+#else
+ unsigned char cretry; // = $029C ##1200xl## 1-byte number of command frame retries
+#endif
+ unsigned char hold3; // = $029D 1-byte temporary
+ unsigned char subtmp; // = $029E 1-byte temporary
+ unsigned char hold2; // = $029F 1-byte (not used)
+ unsigned char dmask; // = $02A0 1-byte display (pixel location) mask
+ unsigned char tmplbt; // = $02A1 1-byte (not used)
+ unsigned char escflg; // = $02A2 ESCAPE FLAG
+ unsigned char tabmap[15]; // = $02A3-$02B1 15-byte (120 bit) tab stop bit map
+ unsigned char logmap[4]; // = $02B2-$02B5 LOGICAL LINE START BIT MAP
+ unsigned char invflg; // = $02B6 INVERSE VIDEO FLAG (TOGGLED BY ATARI KEY)
+ unsigned char filflg; // = $02B7 RIGHT FILL FLAG FOR DRAW
+ unsigned char tmprow; // = $02B8 1-byte temporary row
+ unsigned tmpcol; // = $02B9/$02BA 2-byte temporary column
+ unsigned char scrflg; // = $02BB SET IF SCROLL OCCURS
+ unsigned char hold4; // = $02BC TEMP CELL USED IN DRAW ONLY
+#ifdef OSA
+ unsigned char hold5; // = $02BD ##old## DITTO
+#else
+ unsigned char dretry; // = $02BD ##1200xl## 1-byte number of device retries
+#endif
+ unsigned char shflok; // = $02BE 1-byte shift/control lock flags
+ unsigned char botscr; // = $02BF BOTTOM OF SCREEN 24 NORM 4 SPLIT
+ unsigned char pcolr0; // = $02C0 1-byte player-missile 0 color/luminance
+ unsigned char pcolr1; // = $02C1 1-byte player-missile 1 color/luminance
+ unsigned char pcolr2; // = $02C2 1-byte player-missile 2 color/luminance
+ unsigned char pcolr3; // = $02C3 1-byte player-missile 3 color/luminance
+ unsigned char color0; // = $02C4 1-byte playfield 0 color/luminance
+ unsigned char color1; // = $02C5 1-byte playfield 1 color/luminance
+ unsigned char color2; // = $02C6 1-byte playfield 2 color/luminance
+ unsigned char color3; // = $02C7 1-byte playfield 3 color/luminance
+ unsigned char color4; // = $02C8 1-byte background color/luminance
+#ifdef OSA
+ unsigned char _spare_2[23]; // = $02C9-$02DF No OS use.
+#else
+ union {
+ unsigned char parmbl[6]; // = $02C9 ##rev2## 6-byte relocating loader parameter
+ struct {
+ void (*runadr)(void); // = $02C9 ##1200xl## 2-byte run address
+ unsigned int hiused; // = $02CB ##1200xl## 2-byte highest non-zero page address
+ unsigned int zhiuse; // = $02CD ##1200xl## 2-byte highest zero page address
+ };
+ };
+ union {
+ unsigned char oldpar[6]; // = $02CF ##rev2## 6-byte relocating loader parameter
+ struct {
+ void (*gbytea)(void); // = $02CF ##1200xl## 2-byte GET-BYTE routine address
+ unsigned int loadad; // = $02D1 ##1200xl## 2-byte non-zero page load address
+ unsigned int zloada; // = $02D3 ##1200xl## 2-byte zero page load address
+ };
+ };
+ unsigned int dsctln; // = $02D5 ##1200xl## 2-byte disk sector length
+ unsigned int acmisr; // = $02D7 ##1200xl## 2-byte ACMI interrupt service routine
+ unsigned char krpdel; // = $02D9 ##1200xl## 1-byte auto-repeat delay
+ unsigned char keyrep; // = $02DA ##1200xl## 1-byte auto-repeat rate
+ unsigned char noclik; // = $02DB ##1200xl## 1-byte key click disable
+ unsigned char helpfg; // = $02DC ##1200xl## 1-byte HELP key flag (0 = no HELP)
+ unsigned char dmasav; // = $02DD ##1200xl## 1-byte SDMCTL save/restore
+ unsigned char pbpnt; // = $02DE ##1200xl## 1-byte printer buffer pointer
+ unsigned char pbufsz; // = $02DF ##1200xl## 1-byte printer buffer size
+#endif
+ union {
+ unsigned char glbabs[4]; // = $02E0-$02E3 byte global variables for non-DOS users
+ struct {
+ void (*runad)(void); // = $02E0 ##map## 2-byte binary file run address
+ void (*initad)(void); // = $02E2 ##map## 2-byte binary file initialization address
+ };
+ };
+ unsigned char ramsiz; // = $02E4 RAM SIZE (HI BYTE ONLY)
+ void* memtop; // = $02E5 TOP OF AVAILABLE USER MEMORY
+ void* memlo; // = $02E7 BOTTOM OF AVAILABLE USER MEMORY
+#ifdef OSA
+ unsigned char _spare_3; // = $02E9 No OS use.
+#else
+ unsigned char hndlod; // = $02E9 ##1200xl## 1-byte user load flag
+#endif
+ unsigned char dvstat[4]; // = $02EA-$02ED STATUS BUFFER
+ union {
+ unsigned int cbaud; // = $02EE/$02EF 2-byte cassette baud rate
+ struct {
+ unsigned char cbaudl; // = $02EE 1-byte low cassette baud rate
+ unsigned char cbaudh; // = $02EF 1-byte high cassette baud rate
+ };
+ };
+ unsigned char crsinh; // = $02F0 CURSOR INHIBIT (00 = CURSOR ON)
+ unsigned char keydel; // = $02F1 KEY DELAY
+ unsigned char ch1; // = $02F2 1-byte prior keyboard character
+ unsigned char chact; // = $02F3 CHACTL REGISTER RAM
+ unsigned char chbas; // = $02F4 CHBAS REGISTER RAM
+#ifdef OSA
+ unsigned char _spare_4[5]; // = $02F5-$02F9 No OS use.
+#else
+ unsigned char newrow; // = $02F5 ##1200xl## 1-byte draw destination row
+ unsigned int newcol; // = $02F6/$02F7 ##1200xl## 2-byte draw destination column
+ unsigned char rowinc; // = $02F8 ##1200xl## 1-byte draw row increment
+ unsigned char colinc; // = $02F9 ##1200xl## 1-byte draw column increment
+#endif
+ unsigned char char_; // = $02FA 1-byte internal character (naming changed due to do keyword conflict)
+ unsigned char atachr; // = $02FB ATASCII CHARACTER
+ unsigned char ch; // = $02FC GLOBAL VARIABLE FOR KEYBOARD
+ unsigned char fildat; // = $02FD RIGHT FILL DATA
+ unsigned char dspflg; // = $02FE DISPLAY FLAG DISPLAY CNTLS IF NON-ZERO
+ unsigned char ssflag; // = $02FF START/STOP FLAG FOR PAGING (CNTL 1). CLEARE
+
+ // --- Page 3 ---
+
+ dcb_t dcb; // = $0300-$030B DEVICE CONTROL BLOCK
+ unsigned int timer1; // = $030C/$030D INITIAL TIMER VALUE
+#ifdef OSA
+ unsigned char addcor; // = $030E ##old## ADDITION CORRECTION
+#else
+ unsigned char jmpers; // = $030E ##1200xl## 1-byte jumper options
+#endif
+ unsigned char casflg; // = $030F CASSETTE MODE WHEN SET
+ unsigned int timer2; // = $0310/$0311 2-byte final baud rate timer value
+ unsigned char temp1; // = $0312 TEMPORARY STORAGE REGISTER
+#ifdef OSA
+ unsigned char _spare_5; // = $0313 unused
+ unsigned char temp2; // = $0314 ##old## TEMPORARY STORAGE REGISTER
+#else
+ unsigned char temp2; // = $0313 ##1200xl## 1-byte temporary
+ unsigned char ptimot; // = $0314 ##1200xl## 1-byte printer timeout
+#endif
+ unsigned char temp3; // = $0315 TEMPORARY STORAGE REGISTER
+ unsigned char savio; // = $0316 SAVE SERIAL IN DATA PORT
+ unsigned char timflg; // = $0317 TIME OUT FLAG FOR BAUD RATE CORRECTION
+ unsigned char stackp; // = $0318 SIO STACK POINTER SAVE CELL
+ unsigned char tstat; // = $0319 TEMPORARY STATUS HOLDER
+#ifdef OSA
+ hatabs_t hatabs[12]; // = $031A-$033D handler address table
+ unsigned int zeropad; // = $033E/$033F zero padding
+#else
+ hatabs_t hatabs[11]; // = $031A-$033A handler address table
+ unsigned int zeropad; // = $033B/$033C zero padding
+ unsigned char pupbt1; // = $033D ##1200xl## 1-byte power-up validation byte 1
+ unsigned char pupbt2; // = $033E ##1200xl## 1-byte power-up validation byte 2
+ unsigned char pupbt3; // = $033F ##1200xl## 1-byte power-up validation byte 3
+#endif
+
+ iocb_t iocb[8]; // = $0340-$03BF 8 I/O Control Blocks
+ unsigned char prnbuf[40]; // = $03C0-$3E7 PRINTER BUFFER
+#ifdef OSA
+ unsigned char _spare_6[151]; // = $03E8-$047F unused
+#else
+ unsigned char superf; // = $03E8 ##1200xl## 1-byte editor super function flag
+ unsigned char ckey; // = $03E9 ##1200xl## 1-byte cassette boot request flag
+ unsigned char cassbt; // = $03EA ##1200xl## 1-byte cassette boot flag
+ unsigned char cartck; // = $03EB ##1200xl## 1-byte cartridge equivalence check
+ unsigned char derrf; // = $03EC ##rev2## 1-byte screen OPEN error flag
+ unsigned char acmvar[11]; // = $03ED-$03F7 ##1200xl## reserved for ACMI, not cleared upon reset
+ unsigned char basicf; // = $03F8 ##rev2## 1-byte BASIC switch flag
+ unsigned char mintlk; // = $03F9 ##1200xl## 1-byte ACMI module interlock
+ unsigned char gintlk; // = $03FA ##1200xl## 1-byte cartridge interlock
+ void* chlink; // = $03FB/$03FC ##1200xl## 2-byte loaded handler chain link
+ unsigned char casbuf[131]; // = $03FD-$047F CASSETTE BUFFER
+#endif
+
+ // --- Page 4 ---
+
+ unsigned char usarea[128]; // = $0480 128 bytes reserved for application
+
+ // --- Page 5 ---
+
+ unsigned char _spare_7[126]; // = $0500-$057D reserved for FP package / unused
+ unsigned char lbpr1; // = $057E LBUFF PREFIX 1
+ unsigned char lbpr2; // = $057F LBUFF PREFIX 2
+ unsigned char lbuff[128]; // = $0580-$05FF 128-byte line buffer
+};
+
+
+/* Define a structure with the zero page atari basic register offsets */
+
+struct __basic {
+ void* lowmem; // = $80/$81 POINTER TO BASIC'S LOW MEMORY
+ void* vntp; // = $82/$83 BEGINNING ADDRESS OF THE VARIABLE NAME TABLE
+ void* vntd; // = $84/$85 POINTER TO THE ENDING ADDRESS OF THE VARIABLE NAME TABLE PLUS ONE
+ void* vvtp; // = $86/$87 ADDRESS FOR THE VARIABLE VALUE TABLE
+ void* stmtab; // = $88/$89 ADDRESS OF THE STATEMENT TABLE
+ void* stmcur; // = $8A/$8B CURRENT BASIC STATEMENT POINTER
+ void* starp; // = $8C/$8D ADDRESS FOR THE STRING AND ARRAY TABLE
+ void* runstk; // = $8E/$8F ADDRESS OF THE RUNTIME STACK
+ void* memtop; // = $90/$91 POINTER TO THE TOP OF BASIC MEMORY
+
+ unsigned char _internal_1[0xBA-0x91-1]; // INTERNAL DATA
+
+ unsigned int stopln; // = $BA/$BB LINE WHERE A PROGRAM WAS STOPPED
+
+ unsigned char _internal_2[0xC3-0xBB-1]; // INTERNAL DATA
+
+ unsigned char errsav; // = $C3 NUMBER OF THE ERROR CODE
+
+ unsigned char _internal_3[0xC9-0xC3-1]; // INTERNAL DATA
+
+ unsigned char ptabw; // = $C9 NUMBER OF COLUMNS BETWEEN TAB STOPS
+ unsigned char loadflg; // = $CA LIST PROTECTION
+
+ unsigned char _internal_4[0xD4-0xCA-1]; // INTERNAL DATA
+
+ unsigned int binint; // = $D4/$D5 USR-CALL RETURN VALUE
+};
+
+#endif
+/*****************************************************************************/
+/* */
+/* _gtia.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* "GTIA, Graphic Television Interface Adaptor, is a custom chip used in the */
+/* Atari 8-bit family of computers and in the Atari 5200 console. In these */
+/* systems, GTIA chip works together with ANTIC to produce video display. */
+/* ANTIC generates the playfield graphics (text and bitmap) while GTIA */
+/* provides the color for the playfield and adds overlay objects known as */
+/* player/missile graphics (sprites)" - Wikipedia article on "GTIA" */
+/* */
+/* */
+/* (C) 2000 Freddy Offenga */
+/* 2019-01-16: Bill Kendrick : More defines for registers */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+#ifndef __GTIA_H
+#define __GTIA_H
+
+/*****************************************************************************/
+/* Define a structure with the GTIA register offsets for write (W) */
+/*****************************************************************************/
+
+struct __gtia_write {
+ unsigned char hposp0; /* 0x00: horizontal position of player 0 */
+ unsigned char hposp1; /* 0x01: horizontal position of player 1 */
+ unsigned char hposp2; /* 0x02: horizontal position of player 2 */
+ unsigned char hposp3; /* 0x03: horizontal position of player 3 */
+ unsigned char hposm0; /* 0x04: horizontal position of missile 0 */
+ unsigned char hposm1; /* 0x05: horizontal position of missile 1 */
+ unsigned char hposm2; /* 0x06: horizontal position of missile 2 */
+ unsigned char hposm3; /* 0x07: horizontal position of missile 3 */
+
+ unsigned char sizep0; /* 0x08: size of player 0 */
+ unsigned char sizep1; /* 0x09: size of player 1 */
+ unsigned char sizep2; /* 0x0A: size of player 2 */
+ unsigned char sizep3; /* 0x0B: size of player 3 */
+ unsigned char sizem; /* 0x0C: size of missiles */
+
+ unsigned char grafp0; /* 0x0D: graphics shape player 0 (used when ANTIC is not instructed to use DMA; see DMACTL) */
+ unsigned char grafp1; /* 0x0E: graphics shape player 1 */
+ unsigned char grafp2; /* 0x0F: graphics shape player 2 */
+ unsigned char grafp3; /* 0x10: graphics shape player 3 */
+ unsigned char grafm; /* 0x11: graphics shape missiles */
+
+ unsigned char colpm0; /* 0x12: color player and missile 0 */
+ unsigned char colpm1; /* 0x13: color player and missile 1 */
+ unsigned char colpm2; /* 0x14: color player and missile 2 */
+ unsigned char colpm3; /* 0x15: color player and missile 3 */
+ unsigned char colpf0; /* 0x16: color playfield 0 */
+ unsigned char colpf1; /* 0x17: color playfield 1 */
+ unsigned char colpf2; /* 0x18: color playfield 2 */
+ unsigned char colpf3; /* 0x19: color playfield 3 */
+ unsigned char colbk; /* 0x1A: color background */
+
+ unsigned char prior; /* 0x1B: priority selection */
+
+ unsigned char vdelay;
+ /* 0x1C: vertical delay -- one-line resolution movement of
+ ** vertical position of an object when two line resolution display is enabled
+ */
+
+ unsigned char gractl; /* 0x1D: stick/paddle latch, p/m control */
+
+ unsigned char hitclr; /* 0x1E: clear p/m collision */
+ unsigned char consol; /* 0x1F: builtin speaker */
+};
+
+
+/*****************************************************************************/
+/* (W) Values for SIZEP0-SIZEP3 and SIZEM registers: */
+/*****************************************************************************/
+
+#define PMG_SIZE_NORMAL 0x0 /* one color clock per pixel */
+#define PMG_SIZE_DOUBLE 0x1 /* two color clocks per pixel */
+#define PMG_SIZE_QUAD 0x3 /* four color clocks per pixel */
+
+
+/* COLPM0-COLPM3, COLPF0-COLPF3, COLBK color registers */
+
+/*****************************************************************************/
+/* Color definitions */
+/*****************************************************************************/
+
+/* Make a GTIA color value */
+#define _gtia_mkcolor(hue,lum) (((hue) << 4) | ((lum) << 1))
+
+/* Luminance values go from 0 (black) to 7 (white) */
+
+/* Hue values */
+/* (These can vary depending on TV standard (NTSC vs PAL),
+** tint potentiometer settings, TV tint settings, emulator palette, etc.)
+*/
+#define HUE_GREY 0
+#define HUE_GOLD 1
+#define HUE_GOLDORANGE 2
+#define HUE_REDORANGE 3
+#define HUE_ORANGE 4
+#define HUE_MAGENTA 5
+#define HUE_PURPLE 6
+#define HUE_BLUE 7
+#define HUE_BLUE2 8
+#define HUE_CYAN 9
+#define HUE_BLUEGREEN 10
+#define HUE_BLUEGREEN2 11
+#define HUE_GREEN 12
+#define HUE_YELLOWGREEN 13
+#define HUE_YELLOW 14
+#define HUE_YELLOWRED 15
+
+/* Color defines, similar to c64 colors (untested) */
+/* Hardware palette values (for GTIA colxxx registers) */
+#define GTIA_COLOR_BLACK _gtia_mkcolor(HUE_GREY,0)
+#define GTIA_COLOR_WHITE _gtia_mkcolor(HUE_GREY,7)
+#define GTIA_COLOR_RED _gtia_mkcolor(HUE_REDORANGE,1)
+#define GTIA_COLOR_CYAN _gtia_mkcolor(HUE_CYAN,3)
+#define GTIA_COLOR_VIOLET _gtia_mkcolor(HUE_PURPLE,4)
+#define GTIA_COLOR_GREEN _gtia_mkcolor(HUE_GREEN,2)
+#define GTIA_COLOR_BLUE _gtia_mkcolor(HUE_BLUE,2)
+#define GTIA_COLOR_YELLOW _gtia_mkcolor(HUE_YELLOW,7)
+#define GTIA_COLOR_ORANGE _gtia_mkcolor(HUE_ORANGE,5)
+#define GTIA_COLOR_BROWN _gtia_mkcolor(HUE_YELLOW,2)
+#define GTIA_COLOR_LIGHTRED _gtia_mkcolor(HUE_REDORANGE,6)
+#define GTIA_COLOR_GRAY1 _gtia_mkcolor(HUE_GREY,2)
+#define GTIA_COLOR_GRAY2 _gtia_mkcolor(HUE_GREY,3)
+#define GTIA_COLOR_LIGHTGREEN _gtia_mkcolor(HUE_GREEN,6)
+#define GTIA_COLOR_LIGHTBLUE _gtia_mkcolor(HUE_BLUE,6)
+#define GTIA_COLOR_GRAY3 _gtia_mkcolor(HUE_GREY,5)
+
+
+/*****************************************************************************/
+/* (W) PRIOR register values */
+/*****************************************************************************/
+
+#define PRIOR_P03_PF03 0x01 /* Players 0-3, then Playfields 0-3, then background */
+#define PRIOR_P01_PF03_P23 0x02 /* Players 0-1, then Playfields 0-3, then Players 2-3, then background */
+#define PRIOR_PF03_P03 0x04 /* Playfields 0-3, then Players 0-3, then background */
+#define PRIOR_PF01_P03_PF23 0x08 /* Playfields 0-1, then Players 0-3, then Playfields 2-3, then background */
+
+#define PRIOR_5TH_PLAYER 0x10 /* Four missiles combine to be a 5th player (uses COLPF3) */
+
+/* Causes overlap of players 0 & 1 and of players 2 & 3 to result in a third color,
+** the logical OR of the two players' colors, and other overlaps (e.g., players 0 and 2)
+** to result in black (0x00).
+*/
+#define PRIOR_OVERLAP_3RD_COLOR 0x20
+
+
+/*****************************************************************************/
+/* (W) GTIA special graphics mode options for GPRIOR */
+/*****************************************************************************/
+
+/* Pixels are 2 color clocks wide, and one scanline tall
+** (so 80x192 in normal playfield width).
+** May be used with both bitmap and character modelines.
+*/
+
+/* 16 shade shades of the background (COLBK) hue;
+** Note: brightnesses other than 0 (darkest) in COLBK cause additional effects
+*/
+#define PRIOR_GFX_MODE_9 0x40
+
+/* 9 color palette mode;
+** COLPM0 (acts as background) thru COLPM3, followed by COLPF0 thru COLPF3, and COLBK
+*/
+#define PRIOR_GFX_MODE_10 0x80
+
+/* 16 hues of the background (COLBK) brightness;
+** Note: hues other than 0 (greys) in COLBK caus additional effects
+*/
+#define PRIOR_GFX_MODE_11 0xC0
+
+
+/*****************************************************************************/
+/* (W) VDELAY register values */
+/*****************************************************************************/
+
+#define VDELAY_MISSILE0 0x01
+#define VDELAY_MISSILE1 0x02
+#define VDELAY_MISSILE2 0x04
+#define VDELAY_MISSILE3 0x08
+#define VDELAY_PLAYER0 0x10
+#define VDELAY_PLAYER1 0x20
+#define VDELAY_PLAYER2 0x40
+#define VDELAY_PLAYER3 0x80
+
+
+/*****************************************************************************/
+/* (W) GRACTL register values */
+/*****************************************************************************/
+
+#define GRACTL_MISSLES 0x01 /* enable missiles */
+#define GRACTL_PLAYERS 0x02 /* enable players */
+
+/* "Latch" triggers; once pressed, will give a continuous
+** pressed input until this bit is cleared
+*/
+#define GRACTL_LATCH_TRIGGER_INPUTS 0x04
+
+
+/*****************************************************************************/
+/* Define a structure with the GTIA register offsets for read (R) */
+/*****************************************************************************/
+
+struct __gtia_read {
+ unsigned char m0pf; /* 0x00: missile 0 to playfield collision */
+ unsigned char m1pf; /* 0x01: missile 1 to playfield collision */
+ unsigned char m2pf; /* 0x02: missile 2 to playfield collision */
+ unsigned char m3pf; /* 0x03: missile 3 to playfield collision */
+ unsigned char p0pf; /* 0x04: player 0 to playfield collision */
+ unsigned char p1pf; /* 0x05: player 1 to playfield collision */
+ unsigned char p2pf; /* 0x06: player 2 to playfield collision */
+ unsigned char p3pf; /* 0x07: player 3 to playfield collision */
+ unsigned char m0pl; /* 0x08: missile 0 to player collision */
+ unsigned char m1pl; /* 0x09: missile 1 to player collision */
+ unsigned char m2pl; /* 0x0A: missile 2 to player collision */
+ unsigned char m3pl; /* 0x0B: missile 3 to player collision */
+ unsigned char p0pl; /* 0x0C: player 0 to player collision */
+ unsigned char p1pl; /* 0x0D: player 1 to player collision */
+ unsigned char p2pl; /* 0x0E: player 2 to player collision */
+ unsigned char p3pl; /* 0x0F: player 3 to player collision */
+
+ unsigned char trig0; /* 0x10: joystick trigger 0 (0=pressed, 1=released) */
+ unsigned char trig1; /* 0x11: joystick trigger 1 */
+ unsigned char trig2; /* 0x12: joystick trigger 2 */
+ unsigned char trig3; /* 0x13: joystick trigger 3 */
+
+ unsigned char pal; /* 0x14: pal/ntsc flag */
+
+ unsigned char unused[10];
+
+ unsigned char consol; /* 0x1F: console buttons */
+};
+
+
+/*****************************************************************************/
+/* (R) PAL register possible values */
+/*****************************************************************************/
+
+/* Note: This only tells you whether the GTIA is PAL or NTSC; some NTSC
+** systems are modded with PAL ANTIC chips; testing VCOUNT limits can be
+** done to check for that. Seems like it's not possible to test for SECAM
+*/
+
+#define TV_STD_PAL 0x1
+#define TV_STD_NTSC 0xE
+
+
+/*****************************************************************************/
+/* Macros for reading console keys (Start/Select/Option) via CONSOL register */
+/*****************************************************************************/
+
+#define CONSOL_START(x) !((unsigned char)((x) & 1)) /* true if Start pressed */
+#define CONSOL_SELECT(x) !((unsigned char)((x) & 2)) /* true if Select pressed */
+#define CONSOL_OPTION(x) !((unsigned char)((x) & 4)) /* true if Option pressed */
+
+
+/* End of _gtia.h */
+#endif /* #ifndef __GTIA_H */
+/*
+** _heap.h
+**
+** Ullrich von Bassewitz, 1998-06-03, 2004-12-19
+**
+*/
+
+
+
+#ifndef __HEAP_H
+#define __HEAP_H
+
+
+
+/* Structure that preceeds a user block in most cases.
+** The aligned_malloc function may generate blocks where the start pointer
+** and size are splitted to handle a memory hole that is needed for
+** alignment.
+*/
+struct usedblock {
+ unsigned size;
+ struct usedblock* start;
+};
+
+/* Space needed for administering used blocks */
+#define HEAP_ADMIN_SPACE sizeof (struct usedblock)
+
+/* The data type used to implement the free list.
+** Beware: Field order is significant!
+*/
+struct freeblock {
+ unsigned size;
+ struct freeblock* next;
+ struct freeblock* prev;
+};
+
+
+
+/* Variables that describe the heap */
+extern unsigned* __heaporg; /* Bottom of heap */
+extern unsigned* __heapptr; /* Current top */
+extern unsigned* __heapend; /* Upper limit */
+extern struct freeblock* __heapfirst; /* First free block in list */
+extern struct freeblock* __heaplast; /* Last free block in list */
+
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _heaporg __heaporg
+#define _heapptr __heapptr
+#define _heapend __heapend
+#define _heapfirst __heapfirst
+#define _heaplast __heaplast
+#endif
+
+/* End of _heap.h */
+
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* _maria.h */
+/* */
+/* Atari 7800, Maria chip register hardware structures */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+/*
+ * MARIA registers
+ */
+struct __maria {
+ unsigned char bkgrnd;
+ unsigned char p0c1;
+ unsigned char p0c2;
+ unsigned char p0c3;
+ unsigned char wsync;
+ unsigned char p1c1;
+ unsigned char p1c2;
+ unsigned char p1c3;
+ unsigned char mstat;
+ unsigned char p2c1;
+ unsigned char p2c2;
+ unsigned char p2c3;
+ unsigned char dpph;
+ unsigned char p3c1;
+ unsigned char p3c2;
+ unsigned char p3c3;
+ unsigned char dppl;
+ unsigned char p4c1;
+ unsigned char p4c2;
+ unsigned char p4c3;
+ unsigned char chbase;
+ unsigned char p5c1;
+ unsigned char p5c2;
+ unsigned char p5c3;
+ unsigned char offset;
+ unsigned char p6c1;
+ unsigned char p6c2;
+ unsigned char p6c3;
+ unsigned char ctrl;
+ unsigned char p7c1;
+ unsigned char p7c2;
+ unsigned char p7c3;
+};
+/*****************************************************************************/
+/* */
+/* _mikey.h */
+/* */
+/* Atari Lynx, Mikey chip register hardware structures */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+#ifndef __MIKEY_H
+#define __MIKEY_H
+
+/* timer structure */
+typedef struct _mikey_timer {
+ unsigned char reload;
+ unsigned char control;
+ unsigned char count;
+ unsigned char control2;
+} _mikey_timer;
+
+typedef struct _mikey_all_timers {
+ struct _mikey_timer timer[8];
+} _mikey_all_timers;
+
+/* audio channel structure */
+typedef struct _mikey_audio {
+ unsigned char volume;
+ unsigned char feedback;
+ unsigned char dac;
+ unsigned char shiftlo;
+ unsigned char reload;
+ unsigned char control;
+ unsigned char count;
+ unsigned char other;
+} _mikey_audio;
+
+/* Define a structure with the mikey register offsets */
+struct __mikey {
+ struct _mikey_timer timer0; // 0xFD00
+ struct _mikey_timer timer1; // 0xFD04
+ struct _mikey_timer timer2; // 0xFD08
+ struct _mikey_timer timer3; // 0xFD0C
+ struct _mikey_timer timer4; // 0xFD10
+ struct _mikey_timer timer5; // 0xFD14
+ struct _mikey_timer timer6; // 0xFD18
+ struct _mikey_timer timer7; // 0xFD1C
+ struct _mikey_audio channel_a; // 0xFD20
+ struct _mikey_audio channel_b; // 0xFD28
+ struct _mikey_audio channel_c; // 0xFD30
+ struct _mikey_audio channel_d; // 0xFD38
+ unsigned char attena; // 0xFD40 ?? not yet allocated?
+ unsigned char attenb; // 0xFD41 |
+ unsigned char attenc; // 0xFD42 |
+ unsigned char attend; // 0xFD43 |
+ unsigned char panning; // 0xFD44 |
+ unsigned char unused0[11]; // 0xFD45 - 0xFD4F not used
+ unsigned char mstereo; // 0xFD50 stereo control bits
+ unsigned char unused1[47]; // 0xFD51 - 0xFD7F not used
+ unsigned char intrst; // 0xFD80 interrupt poll 0
+ unsigned char intset; // 0xFD81 interrupt poll 1
+ unsigned char unused2[2]; // 0xFD82 - 0xFD83 not used
+ unsigned char magrdy0; // 0xFD84 mag tape channel0 ready bit
+ unsigned char magrdy1; // 0xFD85 mag tape channel1 ready bit
+ unsigned char audin; // 0xFD86 audio in
+ unsigned char sysctl1; // 0xFD87 control bits
+ unsigned char mikeyrev; // 0xFD88 mikey hardware rev
+ unsigned char mikeysrev; // 0xFD89 mikey software rev
+ unsigned char iodir; // 0xFD8A parallel i/o data dir
+ unsigned char iodat; // 0xFD8B parallel data
+ unsigned char serctl; // 0xFD8C serial control register
+ unsigned char serdat; // 0xFD8D serial data
+ unsigned char unused3[2]; // 0xFD8E - 0xFD8F not used
+ unsigned char sdoneack; // 0xFD90 suzy done acknowledge
+ unsigned char cpusleep; // 0xFD91 cpu bus request disable
+ unsigned char dispctl; // 0xFD92 video bus request enable, viddma
+ unsigned char pkbkup; // 0xFD93 magic 'P' count
+ unsigned char *scrbase; // 0xFD94 start address of video display
+ unsigned char unused4[6]; // 0xFD96 - 0xFD9B not used
+ unsigned char mtest0; // 0xFD9C
+ unsigned char mtest1; // 0xFD9D
+ unsigned char mtest2; // 0xFD9E
+ unsigned char unused5; // 0xFD9F not used
+ unsigned char palette[32]; // 0xFDA0 - 0xFDBF palette 32 bytes
+ // 0xFDC0 - 0xFDFF not used
+};
+
+
+#endif
+
+/*****************************************************************************/
+/* */
+/* _pbi.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* */
+/* */
+/* (C) 2000 Freddy Offenga */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+#ifndef __PBI_H
+#define __PBI_H
+
+/* parallel bus interface area */
+#define PBI ((unsigned char*)0xD100)
+
+/* parallel device IRQ status */
+#define PDVI ((unsigned char*)0xD1FF)
+
+/* parallel device select */
+#define PDVS ((unsigned char*)0xD1FF)
+
+/* parallel bus interface RAM area */
+#define PBIRAM ((unsigned char*)0xD600)
+
+/* parallel device ID 1 */
+#define PDID1 ((unsigned char*)0xD803)
+
+/* parallel device I/O vector */
+#define PDIDV ((unsigned char*)0xD805)
+
+/* parallel device IRQ vector */
+#define PDIRQV ((unsigned char*)0xD808)
+
+/* parallel device ID 2 */
+#define PDID2 ((unsigned char*)0xD80B)
+
+/* parallel device vector table */
+#define PDVV ((unsigned char*)0xD80D)
+
+/* End of _pbi.h */
+#endif /* #ifndef __PBI_H */
+
+/*****************************************************************************/
+/* */
+/* _pia.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* The Peripheral Interface Adapter (PIA) chip (a 6520 or 6820) provides */
+/* parallel I/O interfacing; it was used in Atari 400/800 and Commodore PET */
+/* family of computers, for joystick and some interrupts. */
+/* Sources; various + Wikpedia article on "Peripheral Interface Adapter". */
+/* */
+/* */
+/* (C) 2000 Freddy Offenga */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef __PIA_H
+#define __PIA_H
+
+
+/* Define a structure with the PIA register offsets */
+struct __pia {
+ unsigned char porta; /* port A data r/w */
+ unsigned char portb; /* port B data r/w */
+ unsigned char pactl; /* port A control */
+ unsigned char pbctl; /* port B control */
+};
+
+/* (Some specific register values for Atari defined in atari.h) */
+
+/* End of _pia.h */
+#endif
+/*****************************************************************************/
+/* */
+/* _pokey.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* POKEY, Pot Keyboard Integrated Circuit, is a digital I/O chip designed */
+/* for the Atari 8-bit family of home computers; it combines functions for */
+/* sampling (ADC) potentiometers (such as game paddles) and scan matrices of */
+/* switches (such as a computer keyboard) as well as sound generation. */
+/* It produces four voices of distinctive square wave sound, either as clear */
+/* tones or modified with a number of distortion settings. - Wikipedia */
+/* "POKEY" article. */
+/* */
+/* */
+/* (C) 2000 Freddy Offenga */
+/* 2019-01-16: Bill Kendrick : More defines for registers */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef __POKEY_H
+#define __POKEY_H
+
+
+
+/*****************************************************************************/
+/* Define a structure with the POKEY register offsets for write (W) */
+/*****************************************************************************/
+
+struct __pokey_write {
+ unsigned char audf1; /* audio channel #1 frequency */
+ unsigned char audc1; /* audio channel #1 control */
+ unsigned char audf2; /* audio channel #2 frequency */
+ unsigned char audc2; /* audio channel #2 control */
+ unsigned char audf3; /* audio channel #3 frequency */
+ unsigned char audc3; /* audio channel #3 control */
+ unsigned char audf4; /* audio channel #4 frequency */
+ unsigned char audc4; /* audio channel #4 control */
+ unsigned char audctl; /* audio control */
+ unsigned char stimer; /* start pokey timers */
+
+ unsigned char skrest;
+ /* reset serial port status reg.;
+ ** Reset BITs 5 - 7 of the serial port status register (SKCTL) to "1"
+ */
+
+ unsigned char potgo; /* start paddle scan sequence (see "ALLPOT") */
+ unsigned char unuse1; /* unused */
+ unsigned char serout; /* serial port data output */
+ unsigned char irqen; /* interrupt request enable */
+ unsigned char skctl; /* serial port control */
+};
+
+
+/*****************************************************************************/
+/* (W) AUDC1-4 register values */
+/*****************************************************************************/
+
+/* Meaningful values for the distortion bits.
+** The first process is to divide the clock value by the frequency,
+** then mask the output using the polys in the order below;
+** finally, the result is divided by two.
+*/
+#define AUDC_POLYS_5_17 0x00
+#define AUDC_POLYS_5 0x20 /* Same as 0x60 */
+#define AUDC_POLYS_5_4 0x40
+#define AUDC_POLYS_17 0x80
+#define AUDC_POLYS_NONE 0xA0 /* Same as 0xE0 */
+#define AUDC_POLYS_4 0xC0
+
+/* When set, the volume value in AUDC1-4 bits 0-3 is sent directly to the speaker;
+** it is not modulated with the frequency specified in the AUDF1-4 registers.
+** (See "De Re Atari" Chapter 7: Sound)
+*/
+#define AUDC_VOLUME_ONLY 0x10
+
+
+/*****************************************************************************/
+/* (W) AUDCTL register values */
+/*****************************************************************************/
+
+#define AUDCTL_CLOCKBASE_15HZ 0x01 /* Switch main clock base from 64 KHz to 15 KHz */
+#define AUDCTL_HIGHPASS_CHAN2 0x02 /* Insert high pass filter into channel two, clocked by channel four */
+#define AUDCTL_HIGHPASS_CHAN1 0x04 /* Insert high pass filter into channel one, clocked by channel two */
+#define AUDCTL_JOIN_CHAN34 0x08 /* Join channels four and three (16 bit) */
+#define AUDCTL_JOIN_CHAN12 0x10 /* Join channels two and one (16 bit) */
+#define AUDCTL_CLOCK_CHAN3_179MHZ 0x20 /* Clock channel three with 1.79 MHz */
+#define AUDCTL_CLOCK_CHAN1_179MHZ 0x40 /* Clock channel one with 1.79 MHz */
+#define AUDCTL_9BIT_POLY 0x80 /* Makes the 17 bit poly counter into nine bit poly (see also: RANDOM) */
+
+
+/*****************************************************************************/
+/* (W) IRQEN register values */
+/*****************************************************************************/
+
+#define IRQEN_TIMER_1 0x01 /* The POKEY timer one interrupt is enabled */
+#define IRQEN_TIMER_2 0x02 /* The POKEY timer two interrupt is enabled */
+#define IRQEN_TIMER_4 0x04 /* The POKEY timer four interrupt is enabled */
+#define IRQEN_SERIAL_TRANS_FINISHED 0x08 /* The serial out transmission finished interrupt is enabled */
+#define IRQEN_SERIAL_OUT_DATA_REQUIRED 0x10 /* The serial output data required interrupt is enabled */
+#define IRQEN_SERIAL_IN_DATA_READY 0x20 /* The serial input data ready interrupt is enabled. */
+#define IRQEN_OTHER_KEY 0x40 /* The "other key" interrupt is enabled */
+#define IRQEN_BREAK_KEY 0x80 /* The BREAK key is enabled */
+
+
+/*****************************************************************************/
+/* (W) SKCTL register values */
+/*****************************************************************************/
+
+#define SKCTL_KEYBOARD_DEBOUNCE 0x01 /* Enable keyboard debounce circuits */
+#define SKCTL_KEYBOARD_SCANNING 0x02 /* Enable keyboard scanning circuit */
+
+/* Fast pot scan
+** The pot scan counter completes its sequence in two TV line times instead of
+** one frame time (228 scan lines). Not as accurate as the normal pot scan
+*/
+#define SKCTL_FAST_POT_SCAN 0x04
+
+/* POKEY two-tone mode
+** Serial output is transmitted as a two-tone signal rather than a logic true/false.
+*/
+#define SKCTL_TWO_TONE_MODE 0x08
+
+/* Force break (serial output to zero) */
+#define SKCTL_FORCE_BREAK 0x80
+
+
+/* Bits 4, 5, and 6 of SKCTL set Serial Mode Control: */
+
+/* Trans. & Receive rates set by external clock; Also internal clock phase reset to zero. */
+#define SKCTL_SER_MODE_TX_EXT_RX_EXT 0x00
+
+/* Trans. rate set by external clock; Receive asynch. (ch. 4) (CH3 and CH4). */
+#define SKCTL_SER_MODE_TX_EXT_RX_ASYNC 0x10
+
+/* Trans. & Receive rates set by Chan. 4; Chan. 4 output on Bi-Direct. clock line. */
+#define SKCTL_SER_MODE_TX_CH4_RX_CH4_BIDIR 0x20
+
+/* N.B.: Bit combination 0,1,1 not useful */
+
+/* Trans. rate set by Chan. 4; Receive rate set by external clock. */
+#define SKCTL_SER_MODE_TX_CH4_RX_EXT 0x40
+
+/* N.B.: Bit combination 1,0,1 not useful */
+
+/* Trans. rate set by Chan. 2; Receive rate set by Chan. 4; Chan. 4 out on Bi-Direct. clock line. */
+#define SKCTL_SER_MODE_TX_CH2_RX_CH4_BIDIR 0x60
+
+/* Trans. rate set by Chan. 2; Receive asynch. (chan 3 & 4); Bi-Direct. clock not used (tri-state condition). */
+#define SKCTL_SER_MODE_TX_CH4_RX_ASYNC 0x70
+
+
+/*****************************************************************************/
+/* Define a structure with the POKEY register offsets for read (R) */
+/*****************************************************************************/
+
+struct __pokey_read {
+ unsigned char pot0; /* paddle 0 value */
+ unsigned char pot1; /* paddle 1 value */
+ unsigned char pot2; /* paddle 2 value */
+ unsigned char pot3; /* paddle 3 value */
+ unsigned char pot4; /* paddle 4 value */
+ unsigned char pot5; /* paddle 5 value */
+ unsigned char pot6; /* paddle 6 value */
+ unsigned char pot7; /* paddle 7 value */
+ unsigned char allpot; /* eight paddle port status (see "POTGO") */
+ unsigned char kbcode; /* keyboard code */
+ unsigned char random; /* random number generator */
+ unsigned char unuse2; /* unused */
+ unsigned char unuse3; /* unused */
+ unsigned char serin; /* serial port input */
+ unsigned char irqst; /* interrupt request status */
+ unsigned char skstat; /* serial port status */
+};
+
+
+/*****************************************************************************/
+/* (R) SKSTAT register values */
+/*****************************************************************************/
+
+#define SKSTAT_SERIN_SHIFTREG_BUSY 0x02 /* Serial input shift register busy */
+#define SKSTAT_LASTKEY_PRESSED 0x04 /* the last key is still pressed */
+#define SKSTAT_SHIFTKEY_PRESSED 0x08 /* the [Shift] key is pressed */
+#define SKSTAT_DATA_READ_INGORING_SHIFTREG 0x10 /* Data can be read directly from the serial input port, ignoring the shift register. */
+#define SKSTAT_KEYBOARD_OVERRUN 0x20 /* Keyboard over-run; Reset BITs 7, 6 and 5 (latches) to 1, using SKREST */
+#define SKSTAT_INPUT_OVERRUN 0x40 /* Serial data input over-run. Reset latches as above. */
+#define SKSTAT_INPUT_FRAMEERROR 0x80 /* Serial data input frame error caused by missing or extra bits. Reset latches as above. */
+
+
+/* KBCODE, internal keyboard codes for Atari 8-bit computers,
+** are #defined as "KEY_..." in "atari.h".
+** Note some keys are not read via KBCODE:
+** - Reset
+** - Start, Select, and Option; see CONSOL in "gtia.h"
+** - Break
+*/
+
+
+/* End of _pokey.h */
+#endif /* #ifndef __POKEY_H */
+/*****************************************************************************/
+/* */
+/* Atari VCS 2600 RIOT registers addresses */
+/* */
+/* Source: DASM - vcs.h */
+/* */
+/* Florent Flament (contact@florentflament.com), 2017 */
+/* */
+/*****************************************************************************/
+
+/* RIOT registers */
+struct __riot {
+ unsigned char swcha;
+ unsigned char swacnt;
+ unsigned char swchb;
+ unsigned char swbcnt;
+ unsigned char intim;
+ unsigned char timint;
+
+ unsigned char unused[14];
+
+ unsigned char tim1t;
+ unsigned char tim8t;
+ unsigned char tim64t;
+ unsigned char t1024t;
+};
+/*****************************************************************************/
+/* */
+/* _sid.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* */
+/* */
+/* (C) 1998-2000 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@musoftware.de */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef __SID_H
+#define __SID_H
+
+
+
+/* Define a structure with the sid register offsets */
+struct __sid_voice {
+ unsigned freq; /* Frequency */
+ unsigned pw; /* Pulse width */
+ unsigned char ctrl; /* Control register */
+ unsigned char ad; /* Attack/decay */
+ unsigned char sr; /* Sustain/release */
+};
+struct __sid {
+ struct __sid_voice v1; /* Voice 1 */
+ struct __sid_voice v2; /* Voice 2 */
+ struct __sid_voice v3; /* Voice 3 */
+ unsigned flt_freq; /* Filter frequency */
+ unsigned char flt_ctrl; /* Filter control register */
+ unsigned char amp; /* Amplitude */
+ unsigned char ad1; /* A/D converter 1 */
+ unsigned char ad2; /* A/D converter 2 */
+ unsigned char noise; /* Noise generator */
+ unsigned char read3; /* Value of voice 3 */
+};
+
+
+
+/* End of _sid.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* _suzy.h */
+/* */
+/* Atari Lynx, Suzy chip register hardware structures */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+#ifndef __SUZY_H
+#define __SUZY_H
+
+/* Joypad $FCB0 */
+#define JOYPAD_RIGHT 0x10
+#define JOYPAD_LEFT 0x20
+#define JOYPAD_DOWN 0x40
+#define JOYPAD_UP 0x80
+#define BUTTON_OPTION1 0x08
+#define BUTTON_OPTION2 0x04
+#define BUTTON_INNER 0x02
+#define BUTTON_OUTER 0x01
+
+/* Switches $FCB1 */
+#define BUTTON_PAUSE 0x01
+
+
+/* Hardware Math */
+#define FACTOR_A *(unsigned int *) 0xFC54
+#define FACTOR_B *(unsigned int *) 0xFC52
+#define PRODUCT0 *(unsigned int *) 0xFC60
+#define PRODUCT1 *(unsigned int *) 0xFC62
+#define PRODUCT *(long *) 0xFC60
+
+#define DIVIDEND0 *(unsigned int *) 0xFC60
+#define DIVIDEND1 *(unsigned int *) 0xFC62
+#define DIVIDEND *(long *) 0xFC60
+#define DIVISOR *(unsigned int *) 0xFC56
+#define QUOTIENT0 *(unsigned int *) 0xFC52
+#define QUOTIENT1 *(unsigned int *) 0xFC54
+#define QUOTIENT *(long *) 0xFC52
+#define REMAINDER0 *(unsigned int *) 0xFC6C
+#define REMAINDER1 *(unsigned int *) 0xFC6E
+#define REMAINDER *(long *) 0xFC6C
+
+
+/* Sprite control block (SCB) defines */
+
+/* SPRCTL0 $FC80 */
+#define BPP_4 0xC0
+#define BPP_3 0x80
+#define BPP_2 0x40
+#define BPP_1 0x00
+#define HFLIP 0x20
+#define VFLIP 0x10
+#define TYPE_SHADOW 0x07
+#define TYPE_XOR 0x06
+#define TYPE_NONCOLL 0x05
+#define TYPE_NORMAL 0x04
+#define TYPE_BOUNDARY 0x03
+#define TYPE_BSHADOW 0x02
+#define TYPE_BACKNONCOLL 0x01
+#define TYPE_BACKGROUND 0x00
+
+/* SPRCTL1 $FC81 */
+#define LITERAL 0x80
+#define PACKED 0x00
+#define ALGO3 0x40
+#define RENONE 0x00
+#define REHV 0x10
+#define REHVS 0x20
+#define REHVST 0x30
+#define REUSEPAL 0x08
+#define SKIP 0x04
+#define DRAWUP 0x02
+#define DRAWLEFT 0x01
+
+typedef struct SCB_REHVST_PAL { // SCB with all attributes
+ unsigned char sprctl0;
+ unsigned char sprctl1;
+ unsigned char sprcoll;
+ char *next;
+ unsigned char *data;
+ signed int hpos;
+ signed int vpos;
+ unsigned int hsize;
+ unsigned int vsize;
+ unsigned int stretch;
+ unsigned int tilt;
+ unsigned char penpal[8];
+} SCB_REHVST_PAL;
+
+typedef struct SCB_REHVST { // SCB without pallette
+ unsigned char sprctl0;
+ unsigned char sprctl1;
+ unsigned char sprcoll;
+ char *next;
+ unsigned char *data;
+ signed int hpos;
+ signed int vpos;
+ unsigned int hsize;
+ unsigned int vsize;
+ unsigned int stretch;
+ unsigned int tilt;
+} SCB_REHVST;
+
+typedef struct SCB_REHV { // SCB without stretch/tilt
+ unsigned char sprctl0;
+ unsigned char sprctl1;
+ unsigned char sprcoll;
+ char *next;
+ unsigned char *data;
+ signed int hpos;
+ signed int vpos;
+ unsigned int hsize;
+ unsigned int vsize;
+} SCB_REHV;
+
+typedef struct SCB_REHV_PAL { // SCB without str/tilt, w/ penpal
+ unsigned char sprctl0;
+ unsigned char sprctl1;
+ unsigned char sprcoll;
+ char *next;
+ unsigned char *data;
+ signed int hpos;
+ signed int vpos;
+ unsigned int hsize;
+ unsigned int vsize;
+ unsigned char penpal[8];
+} SCB_REHV_PAL;
+
+typedef struct SCB_REHVS { // SCB w/o tilt & penpal
+ unsigned char sprctl0;
+ unsigned char sprctl1;
+ unsigned char sprcoll;
+ char *next;
+ unsigned char *data;
+ signed int hpos;
+ signed int vpos;
+ unsigned int hsize;
+ unsigned int vsize;
+ unsigned int stretch;
+} SCB_REHVS;
+
+typedef struct SCB_REHVS_PAL { // SCB w/o tilt w/penpal
+ unsigned char sprctl0;
+ unsigned char sprctl1;
+ unsigned char sprcoll;
+ char *next;
+ unsigned char *data;
+ signed int hpos;
+ signed int vpos;
+ unsigned int hsize;
+ unsigned int vsize;
+ unsigned int stretch;
+ unsigned char penpal[8];
+} SCB_REHVS_PAL;
+
+typedef struct SCB_RENONE { // SCB w/o size/stretch/tilt/pal
+ unsigned char sprctl0;
+ unsigned char sprctl1;
+ unsigned char sprcoll;
+ char *next;
+ unsigned char *data;
+ signed int hpos;
+ signed int vpos;
+} SCB_RENONE;
+
+typedef struct SCB_RENONE_PAL { // SCB w/o size/str/tilt w/penpal
+ unsigned char sprctl0;
+ unsigned char sprctl1;
+ unsigned char sprcoll;
+ char *next;
+ unsigned char *data;
+ signed int hpos;
+ signed int vpos;
+ unsigned char penpal[8];
+} SCB_RENONE_PAL;
+
+typedef struct PENPAL_4 {
+ unsigned char penpal[8];
+} PENPAL_4;
+
+typedef struct PENPAL_3 {
+ unsigned char penpal[4];
+} PENPAL_3;
+
+typedef struct PENPAL_2 {
+ unsigned char penpal[2];
+} PENPAL_2;
+
+typedef struct PENPAL_1 {
+ unsigned char penpal[1];
+} PENPAL_1;
+
+/* Misc system defines */
+
+/* SPRGO $FC91 */
+#define EVER_ON 0x04
+#define SPRITE_GO 0x01
+
+/* SPRSYS (write) $FC92 */
+#define SIGNMATH 0x80
+#define ACCUMULATE 0x40
+#define NO_COLLIDE 0x20
+#define VSTRETCH 0x10
+#define LEFTHAND 0x08
+#define CLR_UNSAFE 0x04
+#define SPRITESTOP 0x02
+
+/* SPRSYS (read) $FC92 */
+#define MATHWORKING 0x80
+#define MATHWARNING 0x40
+#define MATHCARRY 0x20
+#define VSTRETCHING 0x10
+#define LEFTHANDED 0x08
+#define UNSAFE_ACCESS 0x04
+#define SPRITETOSTOP 0x02
+#define SPRITEWORKING 0x01
+
+/* MAPCTL $FFF9 */
+#define HIGHSPEED 0x80
+#define VECTORSPACE 0x08
+#define ROMSPACE 0x04
+#define MIKEYSPACE 0x02
+#define SUZYSPACE 0x01
+
+
+/* Suzy Hardware Registers */
+struct __suzy {
+ unsigned int tmpadr; // 0xFC00 Temporary address
+ unsigned int tiltacc; // 0xFC02 Tilt accumulator
+ unsigned int hoff; // 0xFC04 Offset to H edge of screen
+ unsigned int voff; // 0xFC06 Offset to V edge of screen
+ unsigned char *sprbase; // 0xFC08 Base address of sprite
+ unsigned char *colbase; // 0xFC0A Base address of collision buffer
+ unsigned char *vidadr; // 0xFC0C Current vid buffer address
+ unsigned char *coladr; // 0xFC0E Current col buffer address
+ unsigned char *scbnext; // 0xFC10 Address of next SCB
+ unsigned char *sprdline; // 0xFC12 start of sprite data line address
+ unsigned char *hposstrt; // 0xFC14 start hpos
+ unsigned char *vposstrt; // 0xFC16 start vpos
+ unsigned char *sprhsize; // 0xFC18 sprite h size
+ unsigned char *sprvsize; // 0xFC1A sprite v size
+ unsigned int stretchl; // 0xFC1C H size adder
+ unsigned int tilt; // 0xFC1E H pos adder
+ unsigned int sprdoff; // 0xFC20 offset to next sprite data line
+ unsigned int sprvpos; // 0xFC22 current vpos
+ unsigned int colloff; // 0xFC24 offset to collision depository
+ unsigned int vsizeacc; // 0xFC26 vertical size accumulator
+ unsigned int hsizeoff; // 0xFC28 horizontal size offset
+ unsigned int vsizeoff; // 0xFC2A vertical size offset
+ unsigned char *scbaddr; // 0xFC2C address of current SCB
+ unsigned char *procaddr; // 0xFC2E address of current spr data proc
+ unsigned char unused0[32]; // 0xFC30 - 0xFC4F reserved/unused
+ unsigned char unused1[2]; // 0xFC50 - 0xFC51 do not use
+ unsigned char mathd; // 0xFC52
+ unsigned char mathc; // 0xFC53
+ unsigned char mathb; // 0xFC54
+ unsigned char matha; // 0xFC55
+ unsigned char mathp; // 0xFC56
+ unsigned char mathn; // 0xFC57
+ unsigned char unused2[8]; // 0xFC58 - 0xFC5F do not use
+ unsigned char mathh; // 0xFC60
+ unsigned char mathg; // 0xFC61
+ unsigned char mathf; // 0xFC62
+ unsigned char mathe; // 0xFC63
+ unsigned char unused3[8]; // 0xFC64 - 0xFC6B do not use
+ unsigned char mathm; // 0xFC6C
+ unsigned char mathl; // 0xFC6D
+ unsigned char mathk; // 0xFC6E
+ unsigned char mathj; // 0xFC6F
+ unsigned char unused4[16]; // 0xFC70 - 0xFC7F do not use
+ unsigned char sprctl0; // 0xFC80 sprite control bits 0
+ unsigned char sprctl1; // 0xFC81 sprite control bits 1
+ unsigned char sprcoll; // 0xFC82 sprite collision number
+ unsigned char sprinit; // 0xFC83 sprite initialization bits
+ unsigned char unused5[4]; // 0xFC84 - 0xFC87 unused
+ unsigned char suzyhrev; // 0xFC88 suzy hardware rev
+ unsigned char suzysrev; // 0xFC89 suzy software rev
+ unsigned char unused6[6]; // 0xFC8A - 0xFC8F unused
+ unsigned char suzybusen; // 0xFC90 suzy bus enable
+ unsigned char sprgo; // 0xFC91 sprite process start bit
+ unsigned char sprsys; // 0xFC92 sprite system control bits
+ unsigned char unused7[29]; // 0xFC93 - 0xFCAF unused
+ unsigned char joystick; // 0xFCB0 joystick and buttons
+ unsigned char switches; // 0xFCB1 other switches
+ unsigned char cart0; // 0xFCB2 cart0 r/w
+ unsigned char cart1; // 0xFCB3 cart1 r/w
+ unsigned char unused8[8]; // 0xFCB4 - 0xFCBF unused
+ unsigned char leds; // 0xFCC0 leds
+ unsigned char unused9; // 0xFCC1 unused
+ unsigned char parstat; // 0xFCC2 parallel port status
+ unsigned char pardata; // 0xFCC3 parallel port data
+ unsigned char howie; // 0xFCC4 howie (?)
+ // 0xFCC5 - 0xFCFF unused
+};
+
+
+#endif
+
+/*****************************************************************************/
+/* */
+/* _ted.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* */
+/* */
+/* (C) 2003 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef __TED_H
+#define __TED_H
+
+
+
+/* Define a structure with the ted register offsets */
+struct __ted {
+ unsigned char t1_lo; /* Timer #1 low */
+ unsigned char t1_hi; /* Timer #1 high */
+ unsigned char t2_lo; /* Timer #2 low */
+ unsigned char t2_hi; /* Timer #2 high */
+ unsigned char t3_lo; /* Timer #3 low */
+ unsigned char t3_hi; /* Timer #3 high */
+ unsigned char vscroll; /* Vertical scroll control */
+ unsigned char hscroll; /* Horizontal scroll control */
+ unsigned char kbdlatch; /* Keyboard latch */
+ unsigned char irr; /* Interrupt request register */
+ unsigned char imr; /* Interrupt mask register */
+ unsigned char irq_rasterline; /* Interrupt rasterline */
+ unsigned char cursor_hi; /* Cursor position high */
+ unsigned char cursor_lo; /* Cursor position low */
+ unsigned char snd1_freq_lo; /* Channel #1 frequency */
+ unsigned char snd2_freq_lo; /* Channel #2 frequency low */
+ unsigned char snd2_freq_hi; /* Channel #2 frequency high */
+ unsigned char snd_ctrl; /* Sound control */
+ unsigned char misc; /* Channel #1 frequency high and more */
+ unsigned char char_addr; /* Character data base address */
+ unsigned char video_addr; /* Video memory base address */
+ unsigned char bgcolor; /* Background color */
+ unsigned char color1; /* Color register #1 */
+ unsigned char color2; /* Color register #2 */
+ unsigned char color3; /* Color register #3 */
+ unsigned char bordercolor; /* Border color */
+ unsigned char bmap_reload_hi; /* Bitmap reload bits 8+9 */
+ unsigned char bmap_reload_lo; /* Bitmap reload bits 0-7 */
+ unsigned char rasterline_hi; /* Current rasterline bit 8 */
+ unsigned char rasterline_lo; /* Current rasterline bits 0-7 */
+ unsigned char rastercolumn; /* Current rastercolumn */
+ unsigned char cursor_blink; /* Cursor blink attribute */
+ unsigned char unused[30]; /* Unused */
+ unsigned char enable_rom; /* Write enables ROM */
+ unsigned char enable_ram; /* Write enables RAM */
+};
+
+
+
+/* End of _ted.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* Atari VCS 2600 TIA registers addresses */
+/* */
+/* Source: DASM - vcs.h */
+/* */
+/* Florent Flament (contact@florentflament.com), 2017 */
+/* */
+/*****************************************************************************/
+
+/* TIA write / read registers */
+struct __tia {
+ union {
+ unsigned char vsync;
+ unsigned char cxm0p;
+ };
+ union {
+ unsigned char vblank;
+ unsigned char cxm1p;
+ };
+ union {
+ unsigned char wsync;
+ unsigned char cxp0fb;
+ };
+ union {
+ unsigned char rsync;
+ unsigned char cxp1fb;
+ };
+ union {
+ unsigned char nusiz0;
+ unsigned char cxm0fb;
+ };
+ union {
+ unsigned char nusiz1;
+ unsigned char cxm1fb;
+ };
+ union {
+ unsigned char colup0;
+ unsigned char cxblpf;
+ };
+ union {
+ unsigned char colup1;
+ unsigned char cxppmm;
+ };
+ union {
+ unsigned char colupf;
+ unsigned char inpt0;
+ };
+ union {
+ unsigned char colubk;
+ unsigned char inpt1;
+ };
+ union {
+ unsigned char ctrlpf;
+ unsigned char inpt2;
+ };
+ union {
+ unsigned char refp0;
+ unsigned char inpt3;
+ };
+ union {
+ unsigned char refp1;
+ unsigned char inpt4;
+ };
+ union {
+ unsigned char pf0;
+ unsigned char inpt5;
+ };
+ unsigned char pf1;
+ unsigned char pf2;
+ unsigned char resp0;
+ unsigned char resp1;
+ unsigned char resm0;
+ unsigned char resm1;
+ unsigned char resbl;
+ unsigned char audc0;
+ unsigned char audc1;
+ unsigned char audf0;
+ unsigned char audf1;
+ unsigned char audv0;
+ unsigned char audv1;
+ unsigned char grp0;
+ unsigned char grp1;
+ unsigned char enam0;
+ unsigned char enam1;
+ unsigned char enabl;
+ unsigned char hmp0;
+ unsigned char hmp1;
+ unsigned char hmm0;
+ unsigned char hmm1;
+ unsigned char hmbl;
+ unsigned char vdelp0;
+ unsigned char vdelp1;
+ unsigned char vdelbl;
+ unsigned char resmp0;
+ unsigned char resmp1;
+ unsigned char hmove;
+ unsigned char hmclr;
+ unsigned char cxclr;
+};
+/*****************************************************************************/
+/* */
+/* _vdc.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* */
+/* */
+/* (C) 1998-2000 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@musoftware.de */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef __VDC_H
+#define __VDC_H
+
+
+
+/* Define a structure with the vdc register offsets */
+struct __vdc {
+ unsigned char ctrl; /* Control register */
+ unsigned char data; /* Data register */
+};
+
+
+
+/* End of _vdc.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* _vic.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* */
+/* */
+/* (C) 2002 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@musoftware.de */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef __VIC_H
+#define __VIC_H
+
+
+
+/* Define a structure with the vic register offsets */
+struct __vic {
+ unsigned char leftborder;
+ unsigned char upperborder;
+ unsigned char charsperline; /* Characters per line */
+ unsigned char linecount; /* Number of lines */
+ unsigned char rasterline; /* Current raster line */
+ unsigned char addr; /* Address of chargen and video ram */
+ unsigned char strobe_x; /* Light pen, X position */
+ unsigned char strobe_y; /* Light pen, Y position */
+ unsigned char analog_x; /* Analog input X */
+ unsigned char analog_y; /* Analog input Y */
+ unsigned char voice1; /* Sound generator #1 */
+ unsigned char voice2; /* Sound generator #2 */
+ unsigned char voice3; /* Sound generator #3 */
+ unsigned char noise; /* Noise generator */
+ unsigned char volume_color; /* Bits 0..3: volume, 4..7: color */
+ unsigned char bg_border_color;/* Background and border color */
+};
+
+
+
+/* End of _vic.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* _vic2.h */
+/* */
+/* Internal include file, do not use directly */
+/* */
+/* */
+/* */
+/* (C) 1998-2012, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef __VIC2_H
+#define __VIC2_H
+
+
+
+/* Define a structure with the vic register offsets. In cc65 mode, there
+** are aliases for the field accessible as arrays.
+*/
+#if __CC65_STD__ == __CC65_STD_CC65__
+struct __vic2 {
+ union {
+ struct {
+ unsigned char spr0_x; /* Sprite 0, X coordinate */
+ unsigned char spr0_y; /* Sprite 0, Y coordinate */
+ unsigned char spr1_x; /* Sprite 1, X coordinate */
+ unsigned char spr1_y; /* Sprite 1, Y coordinate */
+ unsigned char spr2_x; /* Sprite 2, X coordinate */
+ unsigned char spr2_y; /* Sprite 2, Y coordinate */
+ unsigned char spr3_x; /* Sprite 3, X coordinate */
+ unsigned char spr3_y; /* Sprite 3, Y coordinate */
+ unsigned char spr4_x; /* Sprite 4, X coordinate */
+ unsigned char spr4_y; /* Sprite 4, Y coordinate */
+ unsigned char spr5_x; /* Sprite 5, X coordinate */
+ unsigned char spr5_y; /* Sprite 5, Y coordinate */
+ unsigned char spr6_x; /* Sprite 6, X coordinate */
+ unsigned char spr6_y; /* Sprite 6, Y coordinate */
+ unsigned char spr7_x; /* Sprite 7, X coordinate */
+ unsigned char spr7_y; /* Sprite 7, Y coordinate */
+ };
+ struct {
+ unsigned char x; /* X coordinate */
+ unsigned char y; /* Y coordinate */
+ } spr_pos[8];
+ };
+ unsigned char spr_hi_x; /* High bits of X coordinate */
+ unsigned char ctrl1; /* Control register 1 */
+ unsigned char rasterline; /* Current raster line */
+ union {
+ struct {
+ unsigned char strobe_x; /* Light pen, X position */
+ unsigned char strobe_y; /* Light pen, Y position */
+ };
+ struct {
+ unsigned char x; /* Light pen, X position */
+ unsigned char y; /* Light pen, Y position */
+ } strobe;
+ };
+ unsigned char spr_ena; /* Enable sprites */
+ unsigned char ctrl2; /* Control register 2 */
+ unsigned char spr_exp_y; /* Expand sprites in Y dir */
+ unsigned char addr; /* Address of chargen and video ram */
+ unsigned char irr; /* Interrupt request register */
+ unsigned char imr; /* Interrupt mask register */
+ unsigned char spr_bg_prio; /* Priority to background */
+ unsigned char spr_mcolor; /* Sprite multicolor bits */
+ unsigned char spr_exp_x; /* Expand sprites in X dir */
+ unsigned char spr_coll; /* Sprite/sprite collision reg */
+ unsigned char spr_bg_coll; /* Sprite/background collision reg */
+ unsigned char bordercolor; /* Border color */
+ union {
+ struct {
+ unsigned char bgcolor0; /* Background color 0 */
+ unsigned char bgcolor1; /* Background color 1 */
+ unsigned char bgcolor2; /* Background color 2 */
+ unsigned char bgcolor3; /* Background color 3 */
+ };
+ unsigned char bgcolor[4]; /* Background colors */
+ };
+ union {
+ struct {
+ unsigned char spr_mcolor0; /* Color 0 for multicolor sprites */
+ unsigned char spr_mcolor1; /* Color 1 for multicolor sprites */
+ };
+ /* spr_color is already used ... */
+ unsigned char spr_mcolors[2]; /* Color for multicolor sprites */
+ };
+ union {
+ struct {
+ unsigned char spr0_color; /* Color sprite 0 */
+ unsigned char spr1_color; /* Color sprite 1 */
+ unsigned char spr2_color; /* Color sprite 2 */
+ unsigned char spr3_color; /* Color sprite 3 */
+ unsigned char spr4_color; /* Color sprite 4 */
+ unsigned char spr5_color; /* Color sprite 5 */
+ unsigned char spr6_color; /* Color sprite 6 */
+ unsigned char spr7_color; /* Color sprite 7 */
+ };
+ unsigned char spr_color[8]; /* Colors for the sprites */
+ };
+
+ /* The following ones are only valid in the C128: */
+ unsigned char x_kbd; /* Additional keyboard lines */
+ unsigned char clock; /* Clock switch bit */
+};
+#else
+struct __vic2 {
+ unsigned char spr0_x; /* Sprite 0, X coordinate */
+ unsigned char spr0_y; /* Sprite 0, Y coordinate */
+ unsigned char spr1_x; /* Sprite 1, X coordinate */
+ unsigned char spr1_y; /* Sprite 1, Y coordinate */
+ unsigned char spr2_x; /* Sprite 2, X coordinate */
+ unsigned char spr2_y; /* Sprite 2, Y coordinate */
+ unsigned char spr3_x; /* Sprite 3, X coordinate */
+ unsigned char spr3_y; /* Sprite 3, Y coordinate */
+ unsigned char spr4_x; /* Sprite 4, X coordinate */
+ unsigned char spr4_y; /* Sprite 4, Y coordinate */
+ unsigned char spr5_x; /* Sprite 5, X coordinate */
+ unsigned char spr5_y; /* Sprite 5, Y coordinate */
+ unsigned char spr6_x; /* Sprite 6, X coordinate */
+ unsigned char spr6_y; /* Sprite 6, Y coordinate */
+ unsigned char spr7_x; /* Sprite 7, X coordinate */
+ unsigned char spr7_y; /* Sprite 7, Y coordinate */
+ unsigned char spr_hi_x; /* High bits of X coordinate */
+ unsigned char ctrl1; /* Control register 1 */
+ unsigned char rasterline; /* Current raster line */
+ unsigned char strobe_x; /* Light pen, X position */
+ unsigned char strobe_y; /* Light pen, Y position */
+ unsigned char spr_ena; /* Enable sprites */
+ unsigned char ctrl2; /* Control register 2 */
+ unsigned char spr_exp_y; /* Expand sprites in Y dir */
+ unsigned char addr; /* Address of chargen and video ram */
+ unsigned char irr; /* Interrupt request register */
+ unsigned char imr; /* Interrupt mask register */
+ unsigned char spr_bg_prio; /* Priority to background */
+ unsigned char spr_mcolor; /* Sprite multicolor bits */
+ unsigned char spr_exp_x; /* Expand sprites in X dir */
+ unsigned char spr_coll; /* Sprite/sprite collision reg */
+ unsigned char spr_bg_coll; /* Sprite/background collision reg */
+ unsigned char bordercolor; /* Border color */
+ unsigned char bgcolor0; /* Background color 0 */
+ unsigned char bgcolor1; /* Background color 1 */
+ unsigned char bgcolor2; /* Background color 2 */
+ unsigned char bgcolor3; /* Background color 3 */
+ unsigned char spr_mcolor0; /* Color 0 for multicolor sprites */
+ unsigned char spr_mcolor1; /* Color 1 for multicolor sprites */
+ unsigned char spr0_color; /* Color sprite 0 */
+ unsigned char spr1_color; /* Color sprite 1 */
+ unsigned char spr2_color; /* Color sprite 2 */
+ unsigned char spr3_color; /* Color sprite 3 */
+ unsigned char spr4_color; /* Color sprite 4 */
+ unsigned char spr5_color; /* Color sprite 5 */
+ unsigned char spr6_color; /* Color sprite 6 */
+ unsigned char spr7_color; /* Color sprite 7 */
+
+ /* The following ones are only valid in the C128: */
+ unsigned char x_kbd; /* Additional keyboard lines */
+ unsigned char clock; /* Clock switch bit */
+};
+#endif
+
+
+
+/* End of _vic2.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* accelerator.h */
+/* */
+/* Accelerator specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2018 Marco van den Heuvel */
+/* EMail: blackystardust68@yahoo.com */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _ACCELERATOR_H
+#define _ACCELERATOR_H
+
+/*****************/
+/* Speed defines */
+/*****************/
+
+#define SPEED_SLOW 0x00
+#define SPEED_FAST 0xFF
+
+#define SPEED_1X SPEED_SLOW
+#define SPEED_2X 2 - 1 /* C64 Chameleon, C64DTV, C128, PET 65816, Apple2 Fast Chip, Apple2 TransWarp, Apple2 Zip Chip */
+#define SPEED_3X 3 - 1 /* C64 Chameleon, C65, PET 65816, Apple2 Booster, Apple 2 Fast Chip, Apple2 Titan, Apple2 TransWarp, Apple2 Zip Chip */
+#define SPEED_4X 4 - 1 /* C64 Chameleon, C64 TurboMaster, C64 TurboProcess, PET 65816, Apple2 Fast Chip, Apple2 Zip Chip */
+#define SPEED_5X 5 - 1 /* C64 Chameleon, PET 65816, Apple2 Fast Chip */
+#define SPEED_6X 6 - 1 /* C64 Chameleon, PET 65816, Apple2 Fast Chip */
+#define SPEED_7X 7 - 1 /* PET 65816, Apple2 Fast Chip */
+#define SPEED_8X 8 - 1 /* C64 Flash8, PET 65816, Apple 2 Fast Chip */
+#define SPEED_10X 10 - 1 /* PET 65816, Apple2 Fast Chip */
+#define SPEED_12X 12 - 1 /* Apple2 Fast Chip */
+#define SPEED_16X 16 - 1 /* Apple2 Fast Chip */
+#define SPEED_20X 20 - 1 /* C64/C128 SuperCPU */
+
+/***********************************/
+/* Accelerator function prototypes */
+/***********************************/
+
+/* C64/C128 SuperCPU cartridge */
+
+unsigned char __fastcall__ set_scpu_speed (unsigned char speed);
+
+/* Set the speed of the SuperCPU cartridge, using SPEED_SLOW will switch to
+ * 1 Mhz mode, SPEED_20X or SPEED_FAST will switch to 20 Mhz mode.
+ *
+ * Note that any value lower than SPEED_20X will switch to 1 Mhz mode, and
+ * any value higher or equal to SPEED_20X will switch to 20 Mhz mode.
+ *
+ * This function will return the actual speed the CPU is at after trying
+ * to set the requested speed, if this is not the speed that was requested
+ * then possibly the hardware speed switch prevented any software speed
+ * switching.
+ *
+ * This function does not check for the presence of the SuperCPU cartridge,
+ * make sure you use 'detect_scpu();' before using.
+ */
+
+unsigned char get_scpu_speed (void);
+
+/* Get the speed of the SuperCPU cartridge.
+ *
+ * Possible return values:
+ * SPEED_1X : 1 Mhz mode
+ * SPEED_20X : 20 Mhz mode
+ *
+ * This function does not check for the presence of the SuperCPU cartridge,
+ * make sure you use 'detect_scpu();' before using.
+ */
+
+unsigned char detect_scpu (void);
+
+/* Check for the presence of the SuperCPU cartridge.
+ *
+ * Possible return values:
+ * 0x00 : SuperCPU cartridge not present
+ * 0x01 : SuperCPU cartridge present
+ */
+
+
+/* C64DTV */
+
+unsigned char __fastcall__ set_c64dtv_speed (unsigned char speed);
+
+/* Set the speed of the C64DTV, using SPEED_SLOW will switch to
+ * slow mode, SPEED_2X or SPEED_FAST will switch to fast mode.
+ *
+ * Note that any value higher or equal to SPEED_2X will switch to fast mode.
+ *
+ * This function will return the actual speed the CPU is at after trying
+ * to set the requested speed, to my knowledge the switch should not fail.
+ *
+ * This function does not check for the presence of the C64DTV,
+ * make sure you use 'detect_c64dtv();' before using.
+ */
+
+unsigned char get_c64dtv_speed (void);
+
+/* Get the speed of the C64DTV.
+ *
+ * Possible return values:
+ * SPEED_1X : slow mode
+ * SPEED_2X : fast mode
+ *
+ * This function does not check for the presence of the C64DTV,
+ * make sure you use 'detect_c64dtv();' before using.
+ */
+
+unsigned char detect_c64dtv (void);
+
+/* Check for the presence of the C64DTV.
+ *
+ * Possible return values:
+ * 0x00 : C64DTV not present
+ * 0x01 : C64DTV present
+ */
+
+
+/* C128 8502 CPU */
+
+unsigned char __fastcall__ set_c128_speed (unsigned char speed);
+
+/* Set the speed of the C128 8502 CPU, using SPEED_SLOW will switch to
+ * 1 Mhz (slow) mode, SPEED_2X or SPEED_FAST will switch to 2Mhz (fast) mode.
+ *
+ * Note that any value higher or equal to SPEED_2X will switch to fast mode.
+ *
+ * This function will return the actual speed the CPU is at after trying
+ * to set the requested speed, to my knowledge the switching should not fail.
+ *
+ * This function does not check if the C128 CPU is the current CPU, make sure
+ * you use 'detect_c128();' before using.
+ */
+
+unsigned char get_c128_speed (void);
+
+/* Get the speed of the C128 8502 CPU.
+ *
+ * Possible return values:
+ * SPEED_SLOW : Slow mode
+ * SPEED_2X : Fast mode
+ *
+ * This function does not check if the C128 CPU is the current CPU, make sure
+ * you use 'detect_c128();' before using.
+ */
+
+unsigned char detect_c128 (void);
+
+/* Check if the C128 CPU is the current CPU.
+ *
+ * Possible return values:
+ * 0x00 : C128 CPU is not the current CPU
+ * 0x01 : C128 CPU is the current CPU
+ */
+
+
+/* C64 Chameleon cartridge */
+
+unsigned char __fastcall__ set_chameleon_speed (unsigned char speed);
+
+/* Set the speed of the C64 Chameleon cartridge, the following inputs
+ * are accepted:
+ * SPEED_SLOW : 1 Mhz mode
+ * SPEED_1X : 1 Mhz mode
+ * SPEED_2X : 2 Mhz mode
+ * SPEED_3X : 3 Mhz mode
+ * SPEED_4X : 4 Mhz mode
+ * SPEED_5X : 5 Mhz mode
+ * SPEED_6X : 6 Mhz mode
+ * SPEED_FAST : Maximum speed mode
+ *
+ * Note that any value higher or equal to SPEED_7X will switch to maximum
+ * speed mode.
+ *
+ * This function will return the actual speed the CPU is at after trying
+ * to set the requested speed, to my knowledge the switching should not fail.
+ *
+ * This function does not check for the presence of the C64 Chameleon cartridge,
+ * make sure you use 'detect_chameleon();' before using.
+ */
+
+unsigned char get_chameleon_speed (void);
+
+;/* Get the speed of the C64 Chameleon cartridge.
+; *
+; * Possible return values:
+; * SPEED_SLOW : Slow mode
+; * SPEED_2X : 2Mhz mode
+; * SPEED_3X : 3Mhz mode
+; * SPEED_4X : 4Mhz mode
+; * SPEED_5X : 5Mhz mode
+; * SPEED_6X : 6Mhz mode
+; * SPEED_FAST : Maximum speed mode
+; *
+; * This function does not check for the presence of the C64 Chameleon cartridge,
+; * make sure you use 'detect_chameleon();' before using.
+; */
+
+unsigned char detect_chameleon (void);
+
+/* Check for the presence of the C64 Chameleon cartridge.
+ *
+ * Possible return values:
+ * 0x00 : C64 Chameleon cartridge not present
+ * 0x01 : C64 Chameleon cartridge present
+ */
+
+
+/* C65/C64DX in C64 mode */
+
+unsigned char __fastcall__ set_c65_speed (unsigned char speed);
+
+/* Set the speed of the C65/C64DX CPU, using SPEED_SLOW will switch to
+ * 1 Mhz mode, SPEED_3X or SPEED_FAST will switch to 3.5 Mhz (fast) mode.
+ *
+ * Note that any value higher or equal to SPEED_3X will switch to fast mode.
+ *
+ * This function will return the actual speed the CPU is at after trying
+ * to set the requested speed, to my knowledge the switching should not fail.
+ *
+ * This function does not check for the presence of a C65/C64DX in C64 mode,
+ * make sure you use 'detect_c65();' before using.
+ */
+
+unsigned char get_c65_speed (void);
+
+/* Get the speed of the C65/C64DX CPU.
+ *
+ * Possible return values:
+ * SPEED_SLOW : Slow mode
+ * SPEED_3X : Fast mode
+ *
+ * This function does not check for the presence of a C65/C64DX in C64 mode,
+ * make sure you use 'detect_c65();' before using.
+ */
+
+unsigned char detect_c65 (void);
+
+/* Check for the presence of a C65/C64DX in C64 mode.
+ *
+ * Possible return values:
+ * 0x00 : C65/C64DX in C64 mode not present
+ * 0x01 : C65/C64DX in C64 mode present
+ */
+
+
+/* C64 Turbo Master cartridge */
+
+unsigned char __fastcall__ set_turbomaster_speed (unsigned char speed);
+
+/* Set the speed of the Turbo Master cartridge, using SPEED_SLOW will switch to
+ * 1 Mhz mode, SPEED_4X or SPEED_FAST will switch to 4 Mhz mode.
+ *
+ * Note that any value higher or equal to SPEED_4X will switch to 4 Mhz mode,
+ * any value lower than SPEED_4X will switch to 1 Mhz mode.
+ *
+ * This function will return the actual speed the CPU is at after trying
+ * to set the requested speed, if the speed is different it might indicate
+ * that the hardware switch has locked the speed.
+ *
+ * This function does not check for the presence of a Turbo Master cartridge,
+ * make sure you use 'detect_turbomaster();' before using.
+ */
+
+unsigned char get_turbomaster_speed (void);
+
+/* Get the speed of the Turbo Master cartridge.
+ *
+ * Possible return values:
+ * SPEED_SLOW : 1 Mhz mode
+ * SPEED_4X : 4 Mhz mode
+ *
+ * This function does not check for the presence of a Turbo Master cartridge,
+ * make sure you use 'detect_turbomaster();' before using.
+ */
+
+unsigned char detect_turbomaster (void);
+
+/* Check for the presence of a C64 Turbo Master cartridge.
+ *
+ * Possible return values:
+ * 0x00 : C64 Turbo Master cartridge not present
+ * 0x01 : C64 Turbo Master cartridge present
+ */
+
+/* End of accelerator.h */
+#endif
+
+/*****************************************************************************/
+/* */
+/* apple2.h */
+/* */
+/* Apple ][ system specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2000 Kevin Ruland, */
+/* (C) 2003 Ullrich von Bassewitz, */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _APPLE2_H
+#define _APPLE2_H
+
+
+
+/* Check for errors */
+#if !defined(__APPLE2__)
+# error This module may only be used when compiling for the Apple ][!
+#endif
+
+#include
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Color defines */
+#define COLOR_BLACK 0x00
+#define COLOR_WHITE 0x01
+
+/* TGI color defines */
+#define TGI_COLOR_BLACK 0x00
+#define TGI_COLOR_GREEN 0x01
+#define TGI_COLOR_PURPLE 0x02
+#define TGI_COLOR_WHITE 0x03
+#define TGI_COLOR_BLACK2 0x04
+#define TGI_COLOR_ORANGE 0x05
+#define TGI_COLOR_BLUE 0x06
+#define TGI_COLOR_WHITE2 0x07
+
+#define TGI_COLOR_MAGENTA TGI_COLOR_BLACK2
+#define TGI_COLOR_DARKBLUE TGI_COLOR_WHITE2
+#define TGI_COLOR_DARKGREEN 0x08
+#define TGI_COLOR_GRAY 0x09
+#define TGI_COLOR_CYAN 0x0A
+#define TGI_COLOR_BROWN 0x0B
+#define TGI_COLOR_GRAY2 0x0C
+#define TGI_COLOR_PINK 0x0D
+#define TGI_COLOR_YELLOW 0x0E
+#define TGI_COLOR_AQUA 0x0F
+
+/* Characters codes */
+#define CH_ENTER 0x0D
+#define CH_ESC 0x1B
+#define CH_CURS_LEFT 0x08
+#define CH_CURS_RIGHT 0x15
+
+#if !defined(__APPLE2ENH__)
+#define CH_HLINE '-'
+#define CH_VLINE '!'
+#define CH_ULCORNER '+'
+#define CH_URCORNER '+'
+#define CH_LLCORNER '+'
+#define CH_LRCORNER '+'
+#define CH_TTEE '+'
+#define CH_BTEE '+'
+#define CH_LTEE '+'
+#define CH_RTEE '+'
+#define CH_CROSS '+'
+#endif
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x10
+#define JOY_DOWN_MASK 0x20
+#define JOY_LEFT_MASK 0x04
+#define JOY_RIGHT_MASK 0x08
+#define JOY_BTN_1_MASK 0x40
+#define JOY_BTN_2_MASK 0x80
+
+/* Return codes for get_ostype */
+#define APPLE_UNKNOWN 0x00
+#define APPLE_II 0x10 /* Apple ][ */
+#define APPLE_IIPLUS 0x11 /* Apple ][+ */
+#define APPLE_IIIEM 0x20 /* Apple /// (emulation) */
+#define APPLE_IIE 0x30 /* Apple //e */
+#define APPLE_IIEENH 0x31 /* Apple //e (enhanced) */
+#define APPLE_IIECARD 0x32 /* Apple //e Option Card */
+#define APPLE_IIC 0x40 /* Apple //c */
+#define APPLE_IIC35 0x41 /* Apple //c (3.5 ROM) */
+#define APPLE_IICEXP 0x43 /* Apple //c (Mem. Exp.) */
+#define APPLE_IICREV 0x44 /* Apple //c (Rev. Mem. Exp.) */
+#define APPLE_IICPLUS 0x45 /* Apple //c Plus */
+#define APPLE_IIGS 0x80 /* Apple IIgs */
+#define APPLE_IIGS1 0x81 /* Apple IIgs (ROM 1) */
+#define APPLE_IIGS3 0x83 /* Apple IIgs (ROM 3) */
+
+extern unsigned char _dos_type;
+/* Valid _dos_type values:
+**
+** AppleDOS 3.3 - 0x00
+** ProDOS 8 1.0.1 - 0x10
+** ProDOS 8 1.0.2 - 0x10
+** ProDOS 8 1.1.1 - 0x11
+** ProDOS 8 1.2 - 0x12
+** ProDOS 8 1.3 - 0x13
+** ProDOS 8 1.4 - 0x14
+** ProDOS 8 1.5 - 0x15
+** ProDOS 8 1.6 - 0x16
+** ProDOS 8 1.7 - 0x17
+** ProDOS 8 1.8 - 0x18
+** ProDOS 8 1.9 - 0x18 (!)
+** ProDOS 8 2.0.1 - 0x21
+** ProDOS 8 2.0.2 - 0x22
+** ProDOS 8 2.0.3 - 0x23
+** ProDOS 8 2.4.x - 0x24
+*/
+
+
+
+/*****************************************************************************/
+/* Variables */
+/*****************************************************************************/
+
+
+
+/* The file stream implementation and the POSIX I/O functions will use the
+** following struct to set the date and time stamp on files. This specificially
+** applies to the open and fopen functions.
+*/
+extern struct {
+ struct {
+ unsigned day :5;
+ unsigned mon :4;
+ unsigned year :7;
+ } createdate; /* Current date: 0 */
+ struct {
+ unsigned char min;
+ unsigned char hour;
+ } createtime; /* Current time: 0 */
+} _datetime;
+
+/* The addresses of the static drivers */
+#if !defined(__APPLE2ENH__)
+extern void a2_auxmem_emd[];
+extern void a2_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
+extern void a2_stdmou_mou[]; /* Referred to by mouse_static_stddrv[] */
+extern void a2_ssc_ser[]; /* Referred to by ser_static_stddrv[] */
+extern void a2_gs_ser[]; /* IIgs serial driver */
+extern void a2_hi_tgi[]; /* Referred to by tgi_static_stddrv[] */
+extern void a2_lo_tgi[];
+#endif
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+unsigned char get_ostype (void);
+/* Get the machine type. Returns one of the APPLE_xxx codes. */
+
+void rebootafterexit (void);
+/* Reboot machine after program termination has completed. */
+
+#define ser_apple2_slot(num) ser_ioctl (0, (void*) (num))
+/* Select a slot number from 1 to 7 prior to ser_open.
+** The default slot number is 2.
+*/
+
+#define tgi_apple2_mix(onoff) tgi_ioctl (0, (void*) (onoff))
+/* If onoff is 1, graphics/text mixed mode is enabled.
+** If onoff is 0, graphics/text mixed mode is disabled.
+*/
+
+/* The following #defines will cause the matching functions calls in conio.h
+** to be overlaid by macros with the same names, saving the function call
+** overhead.
+*/
+#define _textcolor(color) COLOR_WHITE
+#define _bgcolor(color) COLOR_BLACK
+#define _bordercolor(color) COLOR_BLACK
+#define _cpeekcolor() COLOR_WHITE
+#define _cpeekrevers() 0
+
+
+
+/* End of apple2.h */
+#endif
+/*****************************************************************************/
+/* */
+/* apple2_filetype.h */
+/* */
+/* Apple ][ file type definitions */
+/* */
+/* */
+/* */
+/* (C) 2017 Bill Chatfield, */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _APPLE2_FILETYPE_H
+#define _APPLE2_FILETYPE_H
+
+
+
+/* Check for errors */
+#if !defined(__APPLE2__)
+# error This module may only be used when compiling for the Apple ][!
+#endif
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* ProDOS general file types */
+#define PRODOS_T_UNK 0x00 /* Unknown */
+#define PRODOS_T_BAD 0x01 /* Bad blocks */
+#define PRODOS_T_PCD 0x02 /* Pascal code */
+#define PRODOS_T_PTX 0x03 /* Pascal text */
+#define PRODOS_T_TXT 0x04 /* ASCII text */
+#define PRODOS_T_PDA 0x05 /* Pascal data */
+#define PRODOS_T_BIN 0x06 /* Binary */
+#define PRODOS_T_FNT 0x07 /* Apple III font */
+#define PRODOS_T_FOT 0x08 /* Hi-res, dbl hi-res graphics */
+#define PRODOS_T_BA3 0x09 /* Apple III BASIC program */
+#define PRODOS_T_DA3 0x09 /* Apple III BASIC data */
+#define PRODOS_T_WPF 0x0A /* Generic word processing */
+#define PRODOS_T_SOS 0x0B /* SOS system */
+#define PRODOS_T_DIR 0x0F /* ProDOS directory */
+
+/* ProDOS productivity file types */
+#define PRODOS_T_RPD 0x10 /* RPS data */
+#define PRODOS_T_RPI 0x11 /* RPS index */
+#define PRODOS_T_AFD 0x12 /* AppleFile discard */
+#define PRODOS_T_AFM 0x13 /* AppleFile model */
+#define PRODOS_T_AFR 0x14 /* AppleFile report */
+#define PRODOS_T_SCL 0x15 /* Screen library */
+#define PRODOS_T_PFS 0x16 /* PFS document */
+#define PRODOS_T_ADB 0x19 /* AppleWorks database */
+#define PRODOS_T_AWP 0x1A /* AppleWorks word processing */
+#define PRODOS_T_ASP 0x1B /* AppleWorks spreadsheet */
+
+/* ProDOS code file types */
+#define PRODOS_T_TDM 0x20 /* Desktop Manager */
+#define PRODOS_T_IPS 0x21 /* Instant Pascal source */
+#define PRODOS_T_UPV 0x22 /* USCD Pascal volume */
+#define PRODOS_T_3SD 0x29 /* SOS directory */
+#define PRODOS_T_8SC 0x2A /* Source code */
+#define PRODOS_T_8OB 0x2B /* Object code */
+#define PRODOS_T_8IC 0x2C /* Interpreted code */
+#define PRODOS_T_8LD 0x2D /* Language data */
+#define PRODOS_T_P8C 0x2E /* ProDOS 8 code module */
+
+/* ProDOS miscellaneous file types */
+#define PRODOS_T_OCR 0x41 /* Optical char recognition */
+#define PRODOS_T_FTD 0x42 /* File type definitions */
+
+/* ProDOS Apple IIgs general file types */
+#define PRODOS_T_GWP 0x50 /* Apple IIgs word processing */
+#define PRODOS_T_GSS 0x51 /* Apple IIgs spreadsheet */
+#define PRODOS_T_GDB 0x52 /* Apple IIgs database */
+#define PRODOS_T_DRW 0x53 /* Object oriented graphics */
+#define PRODOS_T_GDP 0x54 /* Apple IIgs desktop publish */
+#define PRODOS_T_HMD 0x55 /* HyperMedia */
+#define PRODOS_T_EDU 0x56 /* Educational program data */
+#define PRODOS_T_STN 0x57 /* Stationary */
+#define PRODOS_T_HLP 0x58 /* Help */
+#define PRODOS_T_COM 0x59 /* Communications */
+#define PRODOS_T_CFG 0x5A /* Configuration */
+#define PRODOS_T_ANM 0x5B /* Animation */
+#define PRODOS_T_MUM 0x5C /* Multimedia */
+#define PRODOS_T_ENT 0x5D /* Entertainment */
+#define PRODOS_T_DVU 0x5E /* Development utility */
+
+/* ProDOS PC Transporter file types */
+#define PRODOS_T_PRE 0x60 /* PC pre-boot */
+#define PRODOS_T_BIO 0x6B /* PC BIOS */
+#define PRODOS_T_NCF 0x66 /* ProDOS File Nav command file */
+#define PRODOS_T_DVR 0x6D /* PC driver */
+#define PRODOS_T_PRE2 0x6E /* PC pre-boot */
+#define PRODOS_T_HDV 0x6F /* PC hard disk image */
+
+/* ProDOS Kreative Software file types */
+#define PRODOS_T_SN2 0x70 /* Sabine's Notebook 2.0 */
+#define PRODOS_T_KMT 0x71
+#define PRODOS_T_DSR 0x72
+#define PRODOS_T_BAN 0x73
+#define PRODOS_T_CG7 0x74
+#define PRODOS_T_TNJ 0x75
+#define PRODOS_T_SA7 0x76
+#define PRODOS_T_KES 0x77
+#define PRODOS_T_JAP 0x78
+#define PRODOS_T_CSL 0x79
+#define PRODOS_T_TME 0x7A
+#define PRODOS_T_TLB 0x7B
+#define PRODOS_T_MR7 0x7C
+#define PRODOS_T_MLR 0x7D /* Mika City */
+#define PRODOS_T_MMM 0x7E
+#define PRODOS_T_JCP 0x7F
+
+/* ProDOS GEOS file types */
+#define PRODOS_T_GES 0x80 /* GEOS system file */
+#define PRODOS_T_GEA 0x81 /* GEOS desk accessory */
+#define PRODOS_T_GEO 0x82 /* GEOS application */
+#define PRODOS_T_GED 0x83 /* GEOS document */
+#define PRODOS_T_GEF 0x84 /* GEOS font */
+#define PRODOS_T_GEP 0x85 /* GEOS printer driver */
+#define PRODOS_T_GEI 0x86 /* GEOS input driver */
+#define PRODOS_T_GEX 0x87 /* GEOS auxiliary driver */
+#define PRODOS_T_GEV 0x89 /* GEOS swap file */
+#define PRODOS_T_GEC 0x8B /* GEOS clock driver */
+#define PRODOS_T_GEK 0x8C /* GEOS interface card driver */
+#define PRODOS_T_GEW 0x8D /* GEOS formatting data */
+
+/* ProDOS Apple IIgs BASIC file types */
+#define PRODOS_T_WP 0xA0 /* WordPerfect */
+#define PRODOS_T_GSB 0xAB /* Apple IIgs BASIC program */
+#define PRODOS_T_TDF 0xAB /* Apple IIgs BASIC TDF */
+#define PRODOS_T_BDF 0xAB /* Apple IIgs BASIC data */
+
+/* ProDOS Apple IIgs system file types */
+#define PRODOS_T_SRC 0xB0 /* Apple IIgs source code */
+#define PRODOS_T_OBJ 0xB1 /* Apple IIgs object code */
+#define PRODOS_T_LIB 0xB2 /* Apple IIgs library */
+#define PRODOS_T_S16 0xB3 /* Apple IIgs application pgm */
+#define PRODOS_T_RTL 0xB4 /* Apple IIgs runtime library */
+#define PRODOS_T_EXE 0xB5 /* Apple IIgs shell script */
+#define PRODOS_T_PIF 0xB6 /* Apple IIgs permanent init */
+#define PRODOS_T_TIF 0xB7 /* Apple IIgs temporary init */
+#define PRODOS_T_NDA 0xB8 /* Apple IIgs new desk accesry */
+#define PRODOS_T_CDA 0xB9 /* Apple IIgs classic desk aces */
+#define PRODOS_T_TOL 0xBA /* Apple IIgs tool */
+#define PRODOS_T_DRV 0xBB /* Apple IIgs device driver */
+#define PRODOS_T_LDF 0xBC /* Apple IIgs generic load file */
+#define PRODOS_T_FST 0xBD /* Apple IIgs file sys translat */
+#define PRODOS_T_DOC 0xBF /* Apple IIgs document */
+
+/* ProDOS graphics file types */
+#define PRODOS_T_PNT 0xC0 /* Apple IIgs packed sup hi-res */
+#define PRODOS_T_PIC 0xC1 /* Apple IIgs super hi-res */
+#define PRODOS_T_ANI 0xC2 /* PaintWorks animation */
+#define PRODOS_T_PAL 0xC3 /* PaintWorks palette */
+#define PRODOS_T_OOG 0xC5 /* Object-oriented graphics */
+#define PRODOS_T_SCR 0xC6 /* Script */
+#define PRODOS_T_CDV 0xC7 /* Apple IIgs control panel */
+#define PRODOS_T_FON 0xC8 /* Apple IIgs font */
+#define PRODOS_T_FND 0xC9 /* Apple IIgs Finder data */
+#define PRODOS_T_ICN 0xCA /* Apple IIgs icon */
+
+/* ProDOS audio file types */
+#define PRODOS_T_MUS 0xD5 /* Music */
+#define PRODOS_T_INS 0xD6 /* Instrument */
+#define PRODOS_T_MID 0xD7 /* MIDI */
+#define PRODOS_T_SND 0xD8 /* Apple IIgs audio */
+#define PRODOS_T_DBM 0xDB /* DB master document */
+
+/* ProDOS miscellaneous file types */
+#define PRODOS_T_LBR 0xE0 /* Archive */
+#define PRODOS_T_ATK 0xE2 /* AppleTalk data */
+#define PRODOS_T_R16 0xEE /* EDASM 816 relocatable code */
+#define PRODOS_T_PAR 0xEF /* Pascal area */
+
+/* ProDOS system file types */
+#define PRODOS_T_CMD 0xF0 /* ProDOS command file */
+#define PRODOS_T_OVL 0xF1 /* User defined 1 */
+#define PRODOS_T_UD2 0xF2 /* User defined 2 */
+#define PRODOS_T_UD3 0xF3 /* User defined 3 */
+#define PRODOS_T_UD4 0xF4 /* User defined 4 */
+#define PRODOS_T_BAT 0xF5 /* User defined 5 */
+#define PRODOS_T_UD6 0xF6 /* User defined 6 */
+#define PRODOS_T_UD7 0xF7 /* User defined 7 */
+#define PRODOS_T_PRG 0xF8 /* User defined 8 */
+#define PRODOS_T_P16 0xF9 /* ProDOS-16 system file */
+#define PRODOS_T_INT 0xFA /* Integer BASIC program */
+#define PRODOS_T_IVR 0xFB /* Integer BASIC variables */
+#define PRODOS_T_BAS 0xFC /* Applesoft BASIC program */
+#define PRODOS_T_VAR 0xFD /* Applesoft BASIC variables */
+#define PRODOS_T_REL 0xFE /* EDASM relocatable code */
+#define PRODOS_T_SYS 0xFF /* ProDOS-8 system file */
+
+/* The auxiliary type of a text file specifies its record length.
+** A record length of 0 indicates a sequential text file, which is
+** equivalent to text files of other operating systems like MacOS
+** or Windows, except that lines are delimited by carriage returns
+** only. An auxiliary type value greater than 0 for a text file,
+** which is the record length, indicates a random access text file
+** with fixed-length lines.
+*/
+#define PRODOS_AUX_T_TXT_SEQ 0x0000 /* Sequential text */
+
+/* 8IC auxiliary types */
+#define PRODOS_AUX_T_8IC_APEX_PGM 0x8003 /* Apex program */
+
+/* GWP auxiliary types */
+#define PRODOS_AUX_T_GWP_TEACH 0x5445 /* Teach */
+#define PRODOS_AUX_T_GWP_DELUXEWRITE 0x8001 /* DeluxeWrite */
+#define PRODOS_AUX_T_GWP_APPLEWORKS_GS 0x8010 /* AppleWorks GS */
+
+/* GSS auxiliary types */
+#define PRODOS_AUX_T_GSS_APPLEWORKS_GS 0x8010 /* AppleWorks GS */
+
+/* GDB auxiliary types */
+#define PRODOS_AUX_T_GDB_APPLEWORKS_GS 0x8010 /* AppleWorks GS DB */
+#define PRODOS_AUX_T_GDB_AWGS_TMPL 0x8011 /* AWGS template */
+#define PRODOS_AUX_T_GDB_GSAS 0x8013
+
+/* DRW auxiliary types */
+#define PRODOS_AUX_T_DRW_OO_GRAPHICS 0x8013 /* AWGS O-O graphics */
+
+/* GDP auxiliary types */
+#define PRODOS_AUX_T_GDP_GRAPHICWRITER 0x8002 /* A2gs GraphicWriter */
+#define PRODOS_AUX_T_GDP_APPLEWORKS_GS 0x8010 /* A2gs AWGS */
+
+/* HMD auxiliary types */
+#define PRODOS_AUX_T_HMD_HYPERCARD_GS 0x0001 /* HyperCard GS */
+#define PRODOS_AUX_T_HMD_TUTOR_TECH 0x8001 /* Tutor-Tech */
+#define PRODOS_AUX_T_HMD_HYPERSTUDIO 0x8002 /* HyperStudio */
+#define PRODOS_AUX_T_HMD_NEXUS 0x8003 /* Nexus */
+
+/* COM auxiliary types */
+#define PRODOS_AUX_T_COM_APPLEWORKS_GS 0x8003 /* AppleWorks GS */
+
+/* MLR auxiliary types */
+#define PRODOS_AUX_T_MLR_SCRIPT 0x005C /* Mika City script */
+#define PRODOS_AUX_T_MLR_COLOR_TABLE 0xC7AB /* Mika City color table */
+#define PRODOS_AUX_T_MLR_CHARACTER_DEF 0xCDEF /* Mika City character def */
+
+/* LDF auxiliary types */
+#define PRODOS_AUX_T_LDF_NIFTY_LIST_MOD 0x4001 /* Nifty list module */
+#define PRODOS_AUX_T_LDF_SUPER_INFO_MOD 0x4002 /* Super info module */
+#define PRODOS_AUX_T_LDF_TWILIGHT_MOD 0x4004 /* Twilight module */
+#define PRODOS_AUX_T_LDF_MARINETTI_LLM 0x4004 /* Marinetti link layer mod */
+
+/* PNT auxiliary types */
+#define PRODOS_AUX_T_PNT_PK_SUPER_HIRES 0x0001 /* Packed super hi-res */
+#define PRODOS_AUX_T_PNT_APPLE_PREF 0x0002 /* Apple preferred format */
+#define PRODOS_AUX_T_PNT_PK_QUICKDRAWII 0x0003 /* Packed QuickDraw II */
+
+/* PIC auxiliary types */
+#define PRODOS_AUX_T_PIC_QUICKDRAW 0x0001 /* QuickDraw image */
+#define PRODOS_AUX_T_PIC_SHIRES_3200 0x0002 /* Super hi-res 3200 */
+
+/* FON auxiliary types */
+#define PRODOS_AUX_T_FON_QUICKDRAW_BIT 0x0000 /* QuickDraw bitmap font */
+#define PRODOS_AUX_T_FON_POINTLESS_TT 0x0001 /* Pointless TrueType font */
+
+/* SND auxiliary types */
+#define PRODOS_AUX_T_SND_AIFF 0x0000 /* AIFF */
+#define PRODOS_AUX_T_SND_AIFF_C 0x0001 /* AIFF-C */
+#define PRODOS_AUX_T_SND_ASIF_INSTR 0x0002 /* ASIF instrument */
+#define PRODOS_AUX_T_SND_SOUND_RSRC 0x0003 /* Sound resource */
+#define PRODOS_AUX_T_SND_MIDI_SYNTH_WAV 0x0004 /* MIDI synth wave */
+#define PRODOS_AUX_T_SND_HYPERSTUDIO 0x8001 /* HyperStudio sound */
+
+/* LBR auxiliary types */
+#define PRODOS_AUX_T_LBR_ALU 0x0000 /* ALU */
+#define PRODOS_AUX_T_LBR_APPLE_SINGLE 0x0001 /* AppleSingle */
+#define PRODOS_AUX_T_LBR_APPLEDBL_HDR 0x0002 /* AppleDouble header */
+#define PRODOS_AUX_T_LBR_APPLEDBL_DATA 0x0003 /* AppleDouble data */
+#define PRODOS_AUX_T_LBR_BINARY_II 0x8000 /* Binary II */
+#define PRODOS_AUX_T_LBR_APPLELINK_ACU 0x8001 /* AppleLink ACU */
+#define PRODOS_AUX_T_LBR_SHRINKIT 0x8002 /* ShrinkIt */
+
+/* LBR auxiliary types */
+#define PRODOS_AUX_T_ATK_EASYMNT_ALIAS 0x0000 /* EasyMount alias */
+
+/* BAS auxiliary types */
+#define PRODOS_AUX_T_BAS_PGM_LOAD_ADDR 0x0801 /* Applesoft pgm load addr */
+
+
+
+/*****************************************************************************/
+/* Variables */
+/*****************************************************************************/
+
+
+
+/* The file stream implementation and the POSIX I/O functions will use the
+** following variables to determine the file type and auxiliary type to use.
+** This applies specifically to the fopen and open functions.
+*/
+extern unsigned char _filetype; /* Default: PRODOS_T_BIN */
+extern unsigned int _auxtype; /* Default: 0 */
+
+/* End of apple2_filetype.h */
+#endif
+/*****************************************************************************/
+/* */
+/* apple2enh.h */
+/* */
+/* enhanced Apple //e system specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2004 Oliver Schmidt, */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _APPLE2ENH_H
+#define _APPLE2ENH_H
+
+
+
+/* Check for errors */
+#if !defined(__APPLE2ENH__)
+# error This module may only be used when compiling for the enhanced Apple //e!
+#endif
+
+
+
+#include
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Characters codes */
+#define CH_DEL 0x7F
+#define CH_CURS_UP 0x0B
+#define CH_CURS_DOWN 0x0A
+
+#define CH_HLINE 0x5F
+#define CH_VLINE 0xDF
+#define CH_ULCORNER 0x5F
+#define CH_URCORNER 0x20
+#define CH_LLCORNER 0xD4
+#define CH_LRCORNER 0xDF
+#define CH_TTEE 0x5F
+#define CH_BTEE 0xD4
+#define CH_LTEE 0xD4
+#define CH_RTEE 0xDF
+#define CH_CROSS 0xD4
+
+/* These are defined to be OpenApple + NumberKey */
+#define CH_F1 0xB1
+#define CH_F2 0xB2
+#define CH_F3 0xB3
+#define CH_F4 0xB4
+#define CH_F5 0xB5
+#define CH_F6 0xB6
+#define CH_F7 0xB7
+#define CH_F8 0xB8
+#define CH_F9 0xB9
+#define CH_F10 0xB0
+
+/* Video modes */
+#define VIDEOMODE_40x24 0x0011
+#define VIDEOMODE_80x24 0x0012
+#define VIDEOMODE_40COL VIDEOMODE_40x24
+#define VIDEOMODE_80COL VIDEOMODE_80x24
+
+
+
+/*****************************************************************************/
+/* Variables */
+/*****************************************************************************/
+
+
+
+/* The addresses of the static drivers */
+extern void a2e_auxmem_emd[];
+extern void a2e_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
+extern void a2e_stdmou_mou[]; /* Referred to by mouse_static_stddrv[] */
+extern void a2e_ssc_ser[]; /* Referred to by ser_static_stddrv[] */
+extern void a2e_gs_ser[]; /* IIgs serial driver */
+extern void a2e_hi_tgi[]; /* Referred to by tgi_static_stddrv[] */
+extern void a2e_lo_tgi[];
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+unsigned __fastcall__ videomode (unsigned mode);
+/* Set the video mode, return the old mode. Call with one of the VIDEOMODE_xx
+** constants.
+*/
+
+void waitvsync (void);
+/* Wait for start of next frame */
+
+
+
+/* End of apple2enh.h */
+#endif
+/*****************************************************************************/
+/* */
+/* arpa/inet.h */
+/* */
+/* Endianness utilities for cc65 */
+/* */
+/* */
+/* */
+/* (C) 2023 Colin Leroy-Mira, */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _ARPA_INET_H
+#define _ARPA_INET_H
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+#if (__OPT_i__ < 200)
+int __fastcall__ ntohs (int val);
+int __fastcall__ htons (int val);
+#else
+
+#define ntohs(x) \
+ ( \
+ __AX__=(x), \
+ asm("sta tmp1"), \
+ asm("txa"), \
+ asm("ldx tmp1"), \
+ __AX__ \
+ )
+#define htons(x) ntohs(x)
+
+#endif
+
+long __fastcall__ ntohl (long val);
+long __fastcall__ htonl (long val);
+
+
+
+/* End of arpa/inet.h */
+#endif
+/*****************************************************************************/
+/* */
+/* ascii_charmap.h */
+/* */
+/* No translations, encodings are stored as they were typed in the host. */
+/* */
+/* */
+/* 2019-09-07, Greg King */
+/* */
+/* This software is provided "as-is", without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated, but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice must not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+/* No include guard here. Each charnap header
+** may be included many times in a source file.
+*/
+
+#pragma warn (remap-zero, push, off)
+
+/* ASCII */
+#pragma charmap (0x00, 0x00)
+#pragma charmap (0x01, 0x01)
+#pragma charmap (0x02, 0x02)
+#pragma charmap (0x03, 0x03)
+#pragma charmap (0x04, 0x04)
+#pragma charmap (0x05, 0x05)
+#pragma charmap (0x06, 0x06)
+#pragma charmap (0x07, 0x07)
+#pragma charmap (0x08, 0x08)
+#pragma charmap (0x09, 0x09)
+#pragma charmap (0x0A, 0x0A)
+#pragma charmap (0x0B, 0x0B)
+#pragma charmap (0x0C, 0x0C)
+#pragma charmap (0x0D, 0x0D)
+#pragma charmap (0x0E, 0x0E)
+#pragma charmap (0x0F, 0x0F)
+#pragma charmap (0x10, 0x10)
+#pragma charmap (0x11, 0x11)
+#pragma charmap (0x12, 0x12)
+#pragma charmap (0x13, 0x13)
+#pragma charmap (0x14, 0x14)
+#pragma charmap (0x15, 0x15)
+#pragma charmap (0x16, 0x16)
+#pragma charmap (0x17, 0x17)
+#pragma charmap (0x18, 0x18)
+#pragma charmap (0x19, 0x19)
+#pragma charmap (0x1A, 0x1A)
+#pragma charmap (0x1B, 0x1B)
+#pragma charmap (0x1C, 0x1C)
+#pragma charmap (0x1D, 0x1D)
+#pragma charmap (0x1E, 0x1E)
+#pragma charmap (0x1F, 0x1F)
+#pragma charmap (0x20, 0x20)
+#pragma charmap (0x21, 0x21)
+#pragma charmap (0x22, 0x22)
+#pragma charmap (0x23, 0x23)
+#pragma charmap (0x24, 0x24)
+#pragma charmap (0x25, 0x25)
+#pragma charmap (0x26, 0x26)
+#pragma charmap (0x27, 0x27)
+#pragma charmap (0x28, 0x28)
+#pragma charmap (0x29, 0x29)
+#pragma charmap (0x2A, 0x2A)
+#pragma charmap (0x2B, 0x2B)
+#pragma charmap (0x2C, 0x2C)
+#pragma charmap (0x2D, 0x2D)
+#pragma charmap (0x2E, 0x2E)
+#pragma charmap (0x2F, 0x2F)
+#pragma charmap (0x30, 0x30)
+#pragma charmap (0x31, 0x31)
+#pragma charmap (0x32, 0x32)
+#pragma charmap (0x33, 0x33)
+#pragma charmap (0x34, 0x34)
+#pragma charmap (0x35, 0x35)
+#pragma charmap (0x36, 0x36)
+#pragma charmap (0x37, 0x37)
+#pragma charmap (0x38, 0x38)
+#pragma charmap (0x39, 0x39)
+#pragma charmap (0x3A, 0x3A)
+#pragma charmap (0x3B, 0x3B)
+#pragma charmap (0x3C, 0x3C)
+#pragma charmap (0x3D, 0x3D)
+#pragma charmap (0x3E, 0x3E)
+#pragma charmap (0x3F, 0x3F)
+#pragma charmap (0x40, 0x40)
+#pragma charmap (0x41, 0x41)
+#pragma charmap (0x42, 0x42)
+#pragma charmap (0x43, 0x43)
+#pragma charmap (0x44, 0x44)
+#pragma charmap (0x45, 0x45)
+#pragma charmap (0x46, 0x46)
+#pragma charmap (0x47, 0x47)
+#pragma charmap (0x48, 0x48)
+#pragma charmap (0x49, 0x49)
+#pragma charmap (0x4A, 0x4A)
+#pragma charmap (0x4B, 0x4B)
+#pragma charmap (0x4C, 0x4C)
+#pragma charmap (0x4D, 0x4D)
+#pragma charmap (0x4E, 0x4E)
+#pragma charmap (0x4F, 0x4F)
+#pragma charmap (0x50, 0x50)
+#pragma charmap (0x51, 0x51)
+#pragma charmap (0x52, 0x52)
+#pragma charmap (0x53, 0x53)
+#pragma charmap (0x54, 0x54)
+#pragma charmap (0x55, 0x55)
+#pragma charmap (0x56, 0x56)
+#pragma charmap (0x57, 0x57)
+#pragma charmap (0x58, 0x58)
+#pragma charmap (0x59, 0x59)
+#pragma charmap (0x5A, 0x5A)
+#pragma charmap (0x5B, 0x5B)
+#pragma charmap (0x5C, 0x5C)
+#pragma charmap (0x5D, 0x5D)
+#pragma charmap (0x5E, 0x5E)
+#pragma charmap (0x5F, 0x5F)
+#pragma charmap (0x60, 0x60)
+#pragma charmap (0x61, 0x61)
+#pragma charmap (0x62, 0x62)
+#pragma charmap (0x63, 0x63)
+#pragma charmap (0x64, 0x64)
+#pragma charmap (0x65, 0x65)
+#pragma charmap (0x66, 0x66)
+#pragma charmap (0x67, 0x67)
+#pragma charmap (0x68, 0x68)
+#pragma charmap (0x69, 0x69)
+#pragma charmap (0x6A, 0x6A)
+#pragma charmap (0x6B, 0x6B)
+#pragma charmap (0x6C, 0x6C)
+#pragma charmap (0x6D, 0x6D)
+#pragma charmap (0x6E, 0x6E)
+#pragma charmap (0x6F, 0x6F)
+#pragma charmap (0x70, 0x70)
+#pragma charmap (0x71, 0x71)
+#pragma charmap (0x72, 0x72)
+#pragma charmap (0x73, 0x73)
+#pragma charmap (0x74, 0x74)
+#pragma charmap (0x75, 0x75)
+#pragma charmap (0x76, 0x76)
+#pragma charmap (0x77, 0x77)
+#pragma charmap (0x78, 0x78)
+#pragma charmap (0x79, 0x79)
+#pragma charmap (0x7A, 0x7A)
+#pragma charmap (0x7B, 0x7B)
+#pragma charmap (0x7C, 0x7C)
+#pragma charmap (0x7D, 0x7D)
+#pragma charmap (0x7E, 0x7E)
+#pragma charmap (0x7F, 0x7F)
+
+/* beyond ASCII */
+#pragma charmap (0x80, 0x80)
+#pragma charmap (0x81, 0x81)
+#pragma charmap (0x82, 0x82)
+#pragma charmap (0x83, 0x83)
+#pragma charmap (0x84, 0x84)
+#pragma charmap (0x85, 0x85)
+#pragma charmap (0x86, 0x86)
+#pragma charmap (0x87, 0x87)
+#pragma charmap (0x88, 0x88)
+#pragma charmap (0x89, 0x89)
+#pragma charmap (0x8A, 0x8A)
+#pragma charmap (0x8B, 0x8B)
+#pragma charmap (0x8C, 0x8C)
+#pragma charmap (0x8D, 0x8D)
+#pragma charmap (0x8E, 0x8E)
+#pragma charmap (0x8F, 0x8F)
+#pragma charmap (0x90, 0x90)
+#pragma charmap (0x91, 0x91)
+#pragma charmap (0x92, 0x92)
+#pragma charmap (0x93, 0x93)
+#pragma charmap (0x94, 0x94)
+#pragma charmap (0x95, 0x95)
+#pragma charmap (0x96, 0x96)
+#pragma charmap (0x97, 0x97)
+#pragma charmap (0x98, 0x98)
+#pragma charmap (0x99, 0x99)
+#pragma charmap (0x9A, 0x9A)
+#pragma charmap (0x9B, 0x9B)
+#pragma charmap (0x9C, 0x9C)
+#pragma charmap (0x9D, 0x9D)
+#pragma charmap (0x9E, 0x9E)
+#pragma charmap (0x9F, 0x9F)
+#pragma charmap (0xA0, 0xA0)
+#pragma charmap (0xA1, 0xA1)
+#pragma charmap (0xA2, 0xA2)
+#pragma charmap (0xA3, 0xA3)
+#pragma charmap (0xA4, 0xA4)
+#pragma charmap (0xA5, 0xA5)
+#pragma charmap (0xA6, 0xA6)
+#pragma charmap (0xA7, 0xA7)
+#pragma charmap (0xA8, 0xA8)
+#pragma charmap (0xA9, 0xA9)
+#pragma charmap (0xAA, 0xAA)
+#pragma charmap (0xAB, 0xAB)
+#pragma charmap (0xAC, 0xAC)
+#pragma charmap (0xAD, 0xAD)
+#pragma charmap (0xAE, 0xAE)
+#pragma charmap (0xAF, 0xAF)
+#pragma charmap (0xB0, 0xB0)
+#pragma charmap (0xB1, 0xB1)
+#pragma charmap (0xB2, 0xB2)
+#pragma charmap (0xB3, 0xB3)
+#pragma charmap (0xB4, 0xB4)
+#pragma charmap (0xB5, 0xB5)
+#pragma charmap (0xB6, 0xB6)
+#pragma charmap (0xB7, 0xB7)
+#pragma charmap (0xB8, 0xB8)
+#pragma charmap (0xB9, 0xB9)
+#pragma charmap (0xBA, 0xBA)
+#pragma charmap (0xBB, 0xBB)
+#pragma charmap (0xBC, 0xBC)
+#pragma charmap (0xBD, 0xBD)
+#pragma charmap (0xBE, 0xBE)
+#pragma charmap (0xBF, 0xBF)
+#pragma charmap (0xC0, 0xC0)
+#pragma charmap (0xC1, 0xC1)
+#pragma charmap (0xC2, 0xC2)
+#pragma charmap (0xC3, 0xC3)
+#pragma charmap (0xC4, 0xC4)
+#pragma charmap (0xC5, 0xC5)
+#pragma charmap (0xC6, 0xC6)
+#pragma charmap (0xC7, 0xC7)
+#pragma charmap (0xC8, 0xC8)
+#pragma charmap (0xC9, 0xC9)
+#pragma charmap (0xCA, 0xCA)
+#pragma charmap (0xCB, 0xCB)
+#pragma charmap (0xCC, 0xCC)
+#pragma charmap (0xCD, 0xCD)
+#pragma charmap (0xCE, 0xCE)
+#pragma charmap (0xCF, 0xCF)
+#pragma charmap (0xD0, 0xD0)
+#pragma charmap (0xD1, 0xD1)
+#pragma charmap (0xD2, 0xD2)
+#pragma charmap (0xD3, 0xD3)
+#pragma charmap (0xD4, 0xD4)
+#pragma charmap (0xD5, 0xD5)
+#pragma charmap (0xD6, 0xD6)
+#pragma charmap (0xD7, 0xD7)
+#pragma charmap (0xD8, 0xD8)
+#pragma charmap (0xD9, 0xD9)
+#pragma charmap (0xDA, 0xDA)
+#pragma charmap (0xDB, 0xDB)
+#pragma charmap (0xDC, 0xDC)
+#pragma charmap (0xDD, 0xDD)
+#pragma charmap (0xDE, 0xDE)
+#pragma charmap (0xDF, 0xDF)
+#pragma charmap (0xE0, 0xE0)
+#pragma charmap (0xE1, 0xE1)
+#pragma charmap (0xE2, 0xE2)
+#pragma charmap (0xE3, 0xE3)
+#pragma charmap (0xE4, 0xE4)
+#pragma charmap (0xE5, 0xE5)
+#pragma charmap (0xE6, 0xE6)
+#pragma charmap (0xE7, 0xE7)
+#pragma charmap (0xE8, 0xE8)
+#pragma charmap (0xE9, 0xE9)
+#pragma charmap (0xEA, 0xEA)
+#pragma charmap (0xEB, 0xEB)
+#pragma charmap (0xEC, 0xEC)
+#pragma charmap (0xED, 0xED)
+#pragma charmap (0xEE, 0xEE)
+#pragma charmap (0xEF, 0xEF)
+#pragma charmap (0xF0, 0xF0)
+#pragma charmap (0xF1, 0xF1)
+#pragma charmap (0xF2, 0xF2)
+#pragma charmap (0xF3, 0xF3)
+#pragma charmap (0xF4, 0xF4)
+#pragma charmap (0xF5, 0xF5)
+#pragma charmap (0xF6, 0xF6)
+#pragma charmap (0xF7, 0xF7)
+#pragma charmap (0xF8, 0xF8)
+#pragma charmap (0xF9, 0xF9)
+#pragma charmap (0xFA, 0xFA)
+#pragma charmap (0xFB, 0xFB)
+#pragma charmap (0xFC, 0xFC)
+#pragma charmap (0xFD, 0xFD)
+#pragma charmap (0xFE, 0xFE)
+#pragma charmap (0xFF, 0xFF)
+
+#pragma warn (remap-zero, pop)
+/*****************************************************************************/
+/* */
+/* assert.h */
+/* */
+/* Diagnostics */
+/* */
+/* */
+/* */
+/* (C) 1998-2015, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _ASSERT_H
+#define _ASSERT_H
+
+
+
+#undef assert
+#ifdef NDEBUG
+# define assert(expr)
+#else
+extern void __fastcall__ __afailed (const char*, unsigned);
+# define assert(expr) ((expr)? (void)0 : __afailed(__FILE__, __LINE__))
+#endif
+
+/* TODO: Guard with #if __CC65_STD__ >= __CC65_STD_C11__ if there
+** is a C11 mode.
+*/
+#if __CC65_STD__ > __CC65_STD_C99__
+# define static_assert _Static_assert
+#endif
+
+
+
+/* End of assert.h */
+#endif
+/*****************************************************************************/
+/* */
+/* atari.h */
+/* */
+/* Atari system specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2000-2021 Mark Keates */
+/* Freddy Offenga */
+/* Christian Groessler */
+/* Bill Kendrick */
+/* et al. */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _ATARI_H
+#define _ATARI_H
+
+
+/* Check for errors */
+#if !defined(__ATARI__)
+# error This module may only be used when compiling for the Atari!
+#endif
+
+
+/*****************************************************************************/
+/* Character codes */
+/*****************************************************************************/
+
+#define CH_DELCHR 0xFE /* delete char under the cursor */
+#define CH_ENTER 0x9B
+#define CH_ESC 0x1B
+#define CH_CURS_UP 28
+#define CH_CURS_DOWN 29
+#define CH_CURS_LEFT 30
+#define CH_CURS_RIGHT 31
+
+#define CH_TAB 0x7F /* tabulator */
+#define CH_EOL 0x9B /* end-of-line marker */
+#define CH_CLR 0x7D /* clear screen */
+#define CH_BEL 0xFD /* bell */
+#define CH_DEL 0x7E /* back space (delete char to the left) */
+#define CH_RUBOUT 0x7E /* back space (old, deprecated) */
+#define CH_DELLINE 0x9C /* delete line */
+#define CH_INSLINE 0x9D /* insert line */
+
+/* These are defined to be Atari + NumberKey */
+#define CH_F1 177
+#define CH_F2 178
+#define CH_F3 179
+#define CH_F4 180
+#define CH_F5 181
+#define CH_F6 182
+#define CH_F7 183
+#define CH_F8 184
+#define CH_F9 185
+#define CH_F10 176
+
+#define CH_ULCORNER 0x11
+#define CH_URCORNER 0x05
+#define CH_LLCORNER 0x1A
+#define CH_LRCORNER 0x03
+#define CH_TTEE 0x17
+#define CH_BTEE 0x18
+#define CH_LTEE 0x01
+#define CH_RTEE 0x04
+#define CH_CROSS 0x13
+#define CH_HLINE 0x12
+#define CH_VLINE 0x7C
+
+
+/*****************************************************************************/
+/* Masks for joy_read */
+/*****************************************************************************/
+
+#define JOY_UP_MASK 0x01
+#define JOY_DOWN_MASK 0x02
+#define JOY_LEFT_MASK 0x04
+#define JOY_RIGHT_MASK 0x08
+#define JOY_BTN_1_MASK 0x10
+
+#define JOY_FIRE_MASK JOY_BTN_1_MASK
+#define JOY_FIRE(v) ((v) & JOY_FIRE_MASK)
+
+
+/*****************************************************************************/
+/* Keyboard values returned by kbcode / CH */
+/*****************************************************************************/
+
+#define KEY_NONE ((unsigned char) 0xFF)
+
+#define KEY_0 ((unsigned char) 0x32)
+#define KEY_1 ((unsigned char) 0x1F)
+#define KEY_2 ((unsigned char) 0x1E)
+#define KEY_3 ((unsigned char) 0x1A)
+#define KEY_4 ((unsigned char) 0x18)
+#define KEY_5 ((unsigned char) 0x1D)
+#define KEY_6 ((unsigned char) 0x1B)
+#define KEY_7 ((unsigned char) 0x33)
+#define KEY_8 ((unsigned char) 0x35)
+#define KEY_9 ((unsigned char) 0x30)
+
+#define KEY_A ((unsigned char) 0x3F)
+#define KEY_B ((unsigned char) 0x15)
+#define KEY_C ((unsigned char) 0x12)
+#define KEY_D ((unsigned char) 0x3A)
+#define KEY_E ((unsigned char) 0x2A)
+#define KEY_F ((unsigned char) 0x38)
+#define KEY_G ((unsigned char) 0x3D)
+#define KEY_H ((unsigned char) 0x39)
+#define KEY_I ((unsigned char) 0x0D)
+#define KEY_J ((unsigned char) 0x01)
+#define KEY_K ((unsigned char) 0x05)
+#define KEY_L ((unsigned char) 0x00)
+#define KEY_M ((unsigned char) 0x25)
+#define KEY_N ((unsigned char) 0x23)
+#define KEY_O ((unsigned char) 0x08)
+#define KEY_P ((unsigned char) 0x0A)
+#define KEY_Q ((unsigned char) 0x2F)
+#define KEY_R ((unsigned char) 0x28)
+#define KEY_S ((unsigned char) 0x3E)
+#define KEY_T ((unsigned char) 0x2D)
+#define KEY_U ((unsigned char) 0x0B)
+#define KEY_V ((unsigned char) 0x10)
+#define KEY_W ((unsigned char) 0x2E)
+#define KEY_X ((unsigned char) 0x16)
+#define KEY_Y ((unsigned char) 0x2B)
+#define KEY_Z ((unsigned char) 0x17)
+
+#define KEY_COMMA ((unsigned char) 0x20)
+#define KEY_PERIOD ((unsigned char) 0x22)
+#define KEY_SLASH ((unsigned char) 0x26)
+#define KEY_SEMICOLON ((unsigned char) 0x02)
+#define KEY_PLUS ((unsigned char) 0x06)
+#define KEY_ASTERISK ((unsigned char) 0x07)
+#define KEY_DASH ((unsigned char) 0x0E)
+#define KEY_EQUALS ((unsigned char) 0x0F)
+#define KEY_LESSTHAN ((unsigned char) 0x36)
+#define KEY_GREATERTHAN ((unsigned char) 0x37)
+
+#define KEY_ESC ((unsigned char) 0x1C)
+#define KEY_TAB ((unsigned char) 0x2C)
+#define KEY_SPACE ((unsigned char) 0x21)
+#define KEY_RETURN ((unsigned char) 0x0C)
+#define KEY_DELETE ((unsigned char) 0x34)
+#define KEY_CAPS ((unsigned char) 0x3C)
+#define KEY_INVERSE ((unsigned char) 0x27)
+#define KEY_HELP ((unsigned char) 0x11)
+
+/* Function keys only exist on the 1200XL model. */
+#define KEY_F1 ((unsigned char) 0x03)
+#define KEY_F2 ((unsigned char) 0x04)
+#define KEY_F3 ((unsigned char) 0x13)
+#define KEY_F4 ((unsigned char) 0x14)
+
+/* N.B. Cannot read Ctrl key alone */
+#define KEY_CTRL ((unsigned char) 0x80)
+
+/* N.B. Cannot read Shift key alone via KBCODE;
+** instead, check "Shfit key press" bit of SKSTAT register.
+** Also, no way to tell left Shift from right Shift.
+*/
+#define KEY_SHIFT ((unsigned char) 0x40)
+
+
+/* Composed keys
+** (Other combinations are possible, including Shift+Ctrl+key,
+** though not all such combinations are available.)
+*/
+
+#define KEY_EXCLAMATIONMARK (KEY_1 | KEY_SHIFT)
+#define KEY_QUOTE (KEY_2 | KEY_SHIFT)
+#define KEY_HASH (KEY_3 | KEY_SHIFT)
+#define KEY_DOLLAR (KEY_4 | KEY_SHIFT)
+#define KEY_PERCENT (KEY_5 | KEY_SHIFT)
+#define KEY_AMPERSAND (KEY_6 | KEY_SHIFT)
+#define KEY_APOSTROPHE (KEY_7 | KEY_SHIFT)
+#define KEY_AT (KEY_8 | KEY_SHIFT)
+#define KEY_OPENINGPARAN (KEY_9 | KEY_SHIFT)
+#define KEY_CLOSINGPARAN (KEY_0 | KEY_SHIFT)
+#define KEY_UNDERLINE (KEY_DASH | KEY_SHIFT)
+#define KEY_BAR (KEY_EQUALS | KEY_SHIFT)
+#define KEY_COLON (KEY_SEMICOLON | KEY_SHIFT)
+#define KEY_BACKSLASH (KEY_PLUS | KEY_SHIFT)
+#define KEY_CIRCUMFLEX (KEY_ASTERISK | KEY_SHIFT)
+#define KEY_OPENINGBRACKET (KEY_COMMA | KEY_SHIFT)
+#define KEY_CLOSINGBRACKET (KEY_PERIOD | KEY_SHIFT)
+#define KEY_QUESTIONMARK (KEY_SLASH | KEY_SHIFT)
+#define KEY_CLEAR (KEY_LESSTHAN | KEY_SHIFT)
+#define KEY_INSERT (KEY_GREATERTHAN | KEY_SHIFT)
+
+#define KEY_UP (KEY_DASH | KEY_CTRL)
+#define KEY_DOWN (KEY_EQUALS | KEY_CTRL)
+#define KEY_LEFT (KEY_PLUS | KEY_CTRL)
+#define KEY_RIGHT (KEY_ASTERISK | KEY_CTRL)
+
+
+/*****************************************************************************/
+/* Color register functions */
+/*****************************************************************************/
+
+extern void __fastcall__ _setcolor (unsigned char color_reg, unsigned char hue, unsigned char luminance);
+extern void __fastcall__ _setcolor_low (unsigned char color_reg, unsigned char color_value);
+extern unsigned char __fastcall__ _getcolor (unsigned char color_reg);
+
+/*****************************************************************************/
+/* Other screen functions */
+/*****************************************************************************/
+
+extern void waitvsync (void); /* wait for start of next frame */
+extern int __fastcall__ _graphics (unsigned char mode); /* mode value same as in BASIC */
+extern void __fastcall__ _scroll (signed char numlines);
+ /* numlines > 0 scrolls up */
+ /* numlines < 0 scrolls down */
+
+
+/*****************************************************************************/
+/* Sound function */
+/*****************************************************************************/
+
+extern void __fastcall__ _sound (unsigned char voice, unsigned char frequency, unsigned char distortion, unsigned char volume);
+
+/*****************************************************************************/
+/* Misc. functions */
+/*****************************************************************************/
+
+extern unsigned char get_ostype(void); /* get ROM version */
+extern unsigned char get_tv(void); /* get TV system */
+extern void _save_vecs(void); /* save system vectors */
+extern void _rest_vecs(void); /* restore system vectors */
+extern char *_getdefdev(void); /* get default floppy device */
+extern unsigned char _is_cmdline_dos(void); /* does DOS support command lines */
+
+
+/*****************************************************************************/
+/* Global variables */
+/*****************************************************************************/
+
+extern unsigned char _dos_type; /* the DOS flavour */
+#ifndef __ATARIXL__
+extern void atr130_emd[];
+extern void atrstd_joy[]; /* referred to by joy_static_stddrv[] */
+extern void atrmj8_joy[];
+extern void atrjoy_mou[];
+extern void atrst_mou[]; /* referred to by mouse_static_stddrv[] */
+extern void atrami_mou[];
+extern void atrtrk_mou[];
+extern void atrtt_mou[];
+extern void atrrdev_ser[]; /* referred to by ser_static_stddrv[] */
+extern void atr3_tgi[];
+extern void atr4_tgi[];
+extern void atr5_tgi[];
+extern void atr6_tgi[];
+extern void atr7_tgi[];
+extern void atr8_tgi[]; /* referred to by tgi_static_stddrv[] */
+extern void atr8p2_tgi[];
+extern void atr9_tgi[];
+extern void atr9p2_tgi[];
+extern void atr10_tgi[];
+extern void atr10p2_tgi[];
+extern void atr11_tgi[];
+extern void atr14_tgi[];
+extern void atr15_tgi[];
+extern void atr15p2_tgi[];
+#else
+extern void atrx130_emd[];
+extern void atrxstd_joy[]; /* referred to by joy_static_stddrv[] */
+extern void atrxmj8_joy[];
+extern void atrxjoy_mou[];
+extern void atrxst_mou[]; /* referred to by mouse_static_stddrv[] */
+extern void atrxami_mou[];
+extern void atrxtrk_mou[];
+extern void atrxtt_mou[];
+extern void atrxrdev_ser[]; /* referred to by ser_static_stddrv[] */
+extern void atrx3_tgi[];
+extern void atrx4_tgi[];
+extern void atrx5_tgi[];
+extern void atrx6_tgi[];
+extern void atrx7_tgi[];
+extern void atrx8_tgi[]; /* referred to by tgi_static_stddrv[] */
+extern void atrx8p2_tgi[];
+extern void atrx9_tgi[];
+extern void atrx9p2_tgi[];
+extern void atrx10_tgi[];
+extern void atrx10p2_tgi[];
+extern void atrx11_tgi[];
+extern void atrx14_tgi[];
+extern void atrx15_tgi[];
+extern void atrx15p2_tgi[];
+#endif
+
+
+/*****************************************************************************/
+/* get_ostype return value defines (for explanation, see ostype.s) */
+/*****************************************************************************/
+
+/* masks */
+#define AT_OS_TYPE_MAIN 7
+#define AT_OS_TYPE_MINOR (7 << 3)
+/* AT_OS_TYPE_MAIN values */
+#define AT_OS_UNKNOWN 0
+#define AT_OS_400800 1
+#define AT_OS_1200XL 2
+#define AT_OS_XLXE 3
+/* AS_OS_TYPE_MINOR values */
+/* for 400/800 remember this are the ROM versions */
+/* to check whether the hw is PAL or NTSC, use get_tv() */
+#define AT_OS_400800PAL_A 1
+#define AT_OS_400800PAL_B 2
+#define AT_OS_400800NTSC_A 1
+#define AT_OS_400800NTSC_B 2
+#define AT_OS_1200_10 1
+#define AT_OS_1200_11 2
+#define AT_OS_XLXE_1 1
+#define AT_OS_XLXE_2 2
+#define AT_OS_XLXE_3 3
+#define AT_OS_XLXE_4 4
+
+
+/*****************************************************************************/
+/* get_tv return values */
+/*****************************************************************************/
+
+#define AT_NTSC 0
+#define AT_PAL 1
+
+
+/*****************************************************************************/
+/* valid _dos_type values */
+/*****************************************************************************/
+
+#define SPARTADOS 0
+#define REALDOS 1
+#define BWDOS 2
+#define OSADOS 3
+#define XDOS 4
+#define ATARIDOS 5
+#define MYDOS 6
+#define NODOS 255
+
+
+/*****************************************************************************/
+/* Define hardware and where they're mapped in memory */
+/*****************************************************************************/
+
+#include <_atarios.h>
+#define OS (*(struct __os*)0x0000)
+#define BASIC (*(struct __basic*)0x0080)
+
+#include <_gtia.h>
+#define GTIA_READ (*(struct __gtia_read*)0xD000)
+#define GTIA_WRITE (*(struct __gtia_write*)0xD000)
+
+#include <_pbi.h>
+
+#include <_pokey.h>
+#define POKEY_READ (*(struct __pokey_read*)0xD200)
+#define POKEY_WRITE (*(struct __pokey_write*)0xD200)
+
+#include <_pia.h>
+#define PIA (*(struct __pia*)0xD300)
+
+#include <_antic.h>
+#define ANTIC (*(struct __antic*)0xD400)
+
+
+/*****************************************************************************/
+/* conio and TGI color defines */
+/*****************************************************************************/
+
+/* Note that the conio color implementation is monochrome
+** (textcolor just sets text brightness low or high, depending on background
+** color)
+** These values can be used with bordercolor(), bgcolor(), and _setcolor_low()
+*/
+#define COLOR_BLACK GTIA_COLOR_BLACK
+#define COLOR_WHITE GTIA_COLOR_WHITE
+#define COLOR_RED GTIA_COLOR_RED
+#define COLOR_CYAN GTIA_COLOR_CYAN
+#define COLOR_PURPLE GTIA_COLOR_VIOLET
+#define COLOR_GREEN GTIA_COLOR_GREEN
+#define COLOR_BLUE GTIA_COLOR_BLUE
+#define COLOR_YELLOW GTIA_COLOR_YELLOW
+#define COLOR_ORANGE GTIA_COLOR_ORANGE
+#define COLOR_BROWN GTIA_COLOR_BROWN
+#define COLOR_LIGHTRED GTIA_COLOR_LIGHTRED
+#define COLOR_GRAY1 GTIA_COLOR_GRAY1
+#define COLOR_GRAY2 GTIA_COLOR_GRAY2
+#define COLOR_LIGHTGREEN GTIA_COLOR_LIGHTGREEN
+#define COLOR_LIGHTBLUE GTIA_COLOR_LIGHTBLUE
+#define COLOR_GRAY3 GTIA_COLOR_GRAY3
+
+/* TGI color defines */
+#define TGI_COLOR_BLACK COLOR_BLACK
+#define TGI_COLOR_WHITE COLOR_WHITE
+#define TGI_COLOR_RED COLOR_RED
+#define TGI_COLOR_CYAN COLOR_CYAN
+#define TGI_COLOR_PURPLE COLOR_PURPLE
+#define TGI_COLOR_GREEN COLOR_GREEN
+#define TGI_COLOR_BLUE COLOR_BLUE
+#define TGI_COLOR_YELLOW COLOR_YELLOW
+#define TGI_COLOR_ORANGE COLOR_ORANGE
+#define TGI_COLOR_BROWN COLOR_BROWN
+#define TGI_COLOR_LIGHTRED COLOR_LIGHTRED
+#define TGI_COLOR_GRAY1 COLOR_GRAY1
+#define TGI_COLOR_GRAY2 COLOR_GRAY2
+#define TGI_COLOR_LIGHTGREEN COLOR_LIGHTGREEN
+#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
+#define TGI_COLOR_GRAY3 COLOR_GRAY3
+
+
+/*****************************************************************************/
+/* PIA PORTA and PORTB register bits */
+/*****************************************************************************/
+
+/* See also: "JOY_xxx_MASK" in "atari.h" */
+
+/* Paddle 0-3 triggers (per PORTA bits) */
+#define PORTA_PTRIG3 0x80
+#define PORTA_PTRIG2 0x40
+#define PORTA_PTRIG1 0x08
+#define PORTA_PTRIG0 0x04
+
+
+/* On the Atari 400/800, PORTB is the same as PORTA, but for controller ports 3 & 4. */
+
+/* Paddle 4-7 triggers (per PORTB bits); only 400/800 had four controller ports */
+#define PORTB_PTRIG7 0x80
+#define PORTB_PTRIG6 0x40
+#define PORTB_PTRIG5 0x08
+#define PORTB_PTRIG4 0x04
+
+
+/* On the XL series of computers, PORTB has been changed to a memory and
+** LED control (1200XL model only) register (read/write):
+*/
+
+/* If set, the built-in OS is enabled, and occupies the address range $C000-$FFFF
+** (except that the area $D000-$D7FF will only access the hardware registers.)
+** If clear, RAM is enabled in this area (again, save for the hole.)
+*/
+#define PORTB_OSROM 0x01
+
+/* If set, RAM is enabled for the address range $A000-$BFFF.
+** If clear, the built-in BASIC ROM is enabled at this address.
+** And if there is a cartridge installed in the computer, it makes no difference.
+*/
+#define PORTB_BASICROM 0x02
+
+/* If set, the corresponding LED is turned off. If clear, the LED will be on.
+** (1200XL only)
+*/
+#define PORTB_LED1 0x04
+#define PORTB_LED2 0x08
+
+
+/* On the XE series of computers, PORTB is a bank-selected memory control register (read/write): */
+
+/* These bits determine which memory bank is visible to the CPU and/or ANTIC chip
+** when their Bank Switch bit is set. There are four possible banks of 16KB each.
+*/
+#define PORTB_BANKSELECT1 0x00
+#define PORTB_BANKSELECT2 0x04
+#define PORTB_BANKSELECT3 0x08
+#define PORTB_BANKSELECT4 0x0C
+
+/* If set, the CPU and/or ANTIC chip will access bank-switched memory mapped to the
+** address range $4000-$7FFF.
+** If clear, the CPU and/or ANTIC will see normal memory in this region.
+*/
+#define PORTB_BANKSWITCH_CPU 0x10
+#define PORTB_BANKSWITCH_ANTIC 0x20
+
+/* If set, RAM is enabled for the address range $5000-$57FF.
+** If clear, the self-test ROM (physically located at $D000-$D7FF, under the hardware registers)
+** is remapped to this memory area.
+*/
+#define PORTB_SELFTEST 0x80
+
+
+/*****************************************************************************/
+/* PACTL and PBCTL register bits */
+/*****************************************************************************/
+
+/* (W) Peripheral PA1/PB1 interrupt (IRQ) ("peripheral proceed line available") enable.
+** One equals enable. Set by the OS but available to the user; reset on powerup.
+** (PxCTL_IRQ_STATUS (R) bit will get set upon interrupt occurance)
+*/
+#define PxCTL_IRQ_ENABLE 0x01 /* bit 0 */
+
+/* Note: Bit 1 is always set to */
+
+/* (W) Controls PORTA/PORTB addressing
+** 1 = PORTA/PORTB register; read/write to controller port
+** 0 = direction control register; write to direction controls
+** (allows setting data flow; write 0s & 1s to PORTA/PORTB bits
+** to set which port's pins are read (input), or write (output),
+** respectively)
+*/
+#define PxCTL_ADDRESSING 0x04 /* bit 2 */
+
+/* (W) Peripheral motor control line; Turn the cassette on or off
+** (PACTL-specific register bit)
+** 0 = on
+** 1 = off
+*/
+#define PACTL_MOTOR_CONTROL 0x08 /* bit 3 */
+
+/* Peripheral command identification (serial bus command line)
+** (PBCTL-specific register bit)
+*/
+#define PBCTL_PERIPH_CMD_IDENT 0x08 /* bit 3 */
+
+/* Note: Bits 4 & 5 are always set to 1 */
+
+/* Note: Bit 6 is always set to 0 */
+
+/* (R) Peripheral interrupt (IRQ) status bit.
+** Set by Peripherals (PORTA / PORTB). Reset by reading from PORTA / PORTB.
+** PACTL's is interrupt status of PROCEED
+** PBCTL's is interrupt status of SIO
+*/
+#define PxCTL_IRQ_STATUS 0x80
+
+
+/* The following #define will cause the matching function calls in conio.h
+** to be overlaid by macros with the same names, saving the function call
+** overhead.
+*/
+#define _textcolor(color) COLOR_WHITE
+
+/* End of atari.h */
+#endif
+/*****************************************************************************/
+/* */
+/* Atari VCS 2600 TIA & RIOT registers addresses */
+/* */
+/* Source: DASM Version 1.05 - vcs.h */
+/* */
+/* Florent Flament (contact@florentflament.com), 2017 */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _ATARI2600_H
+#define _ATARI2600_H
+
+
+
+/* Check for errors */
+#if !defined(__ATARI2600__)
+# error This module may only be used when compiling for the Atari 2600!
+#endif
+
+#include <_tia.h>
+#define TIA (*(struct __tia*)0x0000)
+
+#include <_riot.h>
+#define RIOT (*(struct __riot*)0x0280)
+
+
+
+/* End of atari2600.h */
+#endif
+/*****************************************************************************/
+/* */
+/* atari5200.h */
+/* */
+/* Atari 5200 system specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2014 Christian Groessler */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _ATARI5200_H
+#define _ATARI5200_H
+
+
+
+/* check for errors */
+#if !defined(__ATARI5200__)
+# error This module may only be used when compiling for the Atari 5200!
+#endif
+
+/* no support for dynamically loadable drivers */
+#define DYN_DRV 0
+
+/* the addresses of the static drivers */
+extern void atr5200std_joy[]; /* referred to by joy_static_stddrv[] */
+
+/* masks for joy_read */
+#define JOY_UP_MASK 0x01
+#define JOY_DOWN_MASK 0x02
+#define JOY_LEFT_MASK 0x04
+#define JOY_RIGHT_MASK 0x08
+#define JOY_BTN_1_MASK 0x10
+
+/* character codes */
+#define CH_ULCORNER 0x0B /* '+' sign */
+#define CH_URCORNER 0x0B
+#define CH_LLCORNER 0x0B
+#define CH_LRCORNER 0x0B
+#define CH_HLINE 0x0D /* dash */
+#define CH_VLINE 0x01 /* exclamation mark */
+
+/* get_tv return values */
+#define AT_NTSC 0
+#define AT_PAL 1
+
+/* Define variables used by the OS*/
+#include <_atari5200os.h>
+#define OS (*(struct __os*)0x0000)
+
+/* define hardware */
+#include <_gtia.h>
+#define GTIA_READ (*(struct __gtia_read*)0xC000)
+#define GTIA_WRITE (*(struct __gtia_write*)0xC000)
+
+#include <_pokey.h>
+#define POKEY_READ (*(struct __pokey_read*)0xE800)
+#define POKEY_WRITE (*(struct __pokey_write*)0xE800)
+
+#include <_antic.h>
+#define ANTIC (*(struct __antic*)0xD400)
+
+/* conio color defines */
+#define COLOR_WHITE 0x00
+#define COLOR_RED 0x01
+#define COLOR_GREEN 0x02
+#define COLOR_BLACK 0x03
+
+/* The following #define will cause the matching function calls in conio.h
+** to be overlaid by macros with the same names, saving the function call
+** overhead.
+*/
+#define _bordercolor(color) 0
+
+/* wait for start of next frame */
+extern void waitvsync (void);
+
+/* end of atari5200.h */
+#endif
+/*****************************************************************************/
+/* */
+/* Atari VCS 7800 TIA & RIOT registers addresses */
+/* */
+/* Karri Kaksonen (karri@sipo.fi), 2022 */
+/* */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _ATARI7800_H
+#define _ATARI7800_H
+
+/* Check for errors */
+#if !defined(__ATARI7800__)
+# error This module may only be used when compiling for the Atari 7800!
+#endif
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Color defines */
+#define COLOR_BLACK 0x00
+#define COLOR_GREY 0x01
+#define COLOR_LIGHTGREY 0x02
+#define COLOR_WHITE 0x03
+
+/* TGI color defines (default palette) */
+#define TGI_COLOR_BLACK COLOR_BLACK
+#define TGI_COLOR_GREY COLOR_GREY
+#define TGI_COLOR_LIGHTGREY COLOR_LIGHTGREY
+#define TGI_COLOR_WHITE COLOR_WHITE
+
+/* Masks for joy_read */
+#define JOY_RIGHT_MASK 0x80
+#define JOY_LEFT_MASK 0x40
+#define JOY_DOWN_MASK 0x20
+#define JOY_UP_MASK 0x10
+#define JOY_BTN_1_MASK 0x01
+#define JOY_BTN_2_MASK 0x02
+
+#define JOY_BTN_A_MASK JOY_BTN_1_MASK
+#define JOY_BTN_B_MASK JOY_BTN_2_MASK
+
+#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
+#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
+
+/* No support for dynamically loadable drivers */
+#define DYN_DRV 0
+
+extern unsigned char get_tv(void); /* get TV system */
+
+#include <_tia.h>
+#define TIA (*(struct __tia*)0x0000)
+
+#include <_riot.h>
+#define RIOT (*(struct __riot*)0x0280)
+
+#include <_maria.h>
+#define MARIA (*(struct __maria*)0x0020)
+
+/* End of atari7800.h */
+#endif
+/*****************************************************************************/
+/* */
+/* atari_atascii_charmap.h */
+/* */
+/* Atari system standard string mapping (ISO-8859-1 -> AtASCII) */
+/* */
+/* */
+/* */
+/* (C) 2016 Christian Krueger */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+/* No include guard here! Multiple use in one file may be intentional. */
+
+#pragma charmap (0x00, 0x00)
+#pragma charmap (0x01, 0x01)
+#pragma charmap (0x02, 0x02)
+#pragma charmap (0x03, 0x03)
+#pragma charmap (0x04, 0x04)
+#pragma charmap (0x05, 0x05)
+#pragma charmap (0x06, 0x06)
+#pragma charmap (0x07, 0xFD)
+#pragma charmap (0x08, 0x08)
+#pragma charmap (0x09, 0x7F)
+#pragma charmap (0x0A, 0x9B)
+#pragma charmap (0x0B, 0x0B)
+#pragma charmap (0x0C, 0x7D)
+#pragma charmap (0x0D, 0x0D)
+#pragma charmap (0x0E, 0x0E)
+#pragma charmap (0x0F, 0x0F)
+
+#pragma charmap (0x10, 0x10)
+#pragma charmap (0x11, 0x11)
+#pragma charmap (0x12, 0x12)
+#pragma charmap (0x13, 0x13)
+#pragma charmap (0x14, 0x14)
+#pragma charmap (0x15, 0x15)
+#pragma charmap (0x16, 0x16)
+#pragma charmap (0x17, 0x17)
+#pragma charmap (0x18, 0x18)
+#pragma charmap (0x19, 0x19)
+#pragma charmap (0x1A, 0x1A)
+#pragma charmap (0x1B, 0x1B)
+#pragma charmap (0x1C, 0x1C)
+#pragma charmap (0x1D, 0x1D)
+#pragma charmap (0x1E, 0x1E)
+#pragma charmap (0x1F, 0x1F)
+
+#pragma charmap (0x20, 0x20)
+#pragma charmap (0x21, 0x21)
+#pragma charmap (0x22, 0x22)
+#pragma charmap (0x23, 0x23)
+#pragma charmap (0x24, 0x24)
+#pragma charmap (0x25, 0x25)
+#pragma charmap (0x26, 0x26)
+#pragma charmap (0x27, 0x27)
+#pragma charmap (0x28, 0x28)
+#pragma charmap (0x29, 0x29)
+#pragma charmap (0x2A, 0x2A)
+#pragma charmap (0x2B, 0x2B)
+#pragma charmap (0x2C, 0x2C)
+#pragma charmap (0x2D, 0x2D)
+#pragma charmap (0x2E, 0x2E)
+#pragma charmap (0x2F, 0x2F)
+
+#pragma charmap (0x30, 0x30)
+#pragma charmap (0x31, 0x31)
+#pragma charmap (0x32, 0x32)
+#pragma charmap (0x33, 0x33)
+#pragma charmap (0x34, 0x34)
+#pragma charmap (0x35, 0x35)
+#pragma charmap (0x36, 0x36)
+#pragma charmap (0x37, 0x37)
+#pragma charmap (0x38, 0x38)
+#pragma charmap (0x39, 0x39)
+#pragma charmap (0x3A, 0x3A)
+#pragma charmap (0x3B, 0x3B)
+#pragma charmap (0x3C, 0x3C)
+#pragma charmap (0x3D, 0x3D)
+#pragma charmap (0x3E, 0x3E)
+#pragma charmap (0x3F, 0x3F)
+
+#pragma charmap (0x40, 0x40)
+#pragma charmap (0x41, 0x41)
+#pragma charmap (0x42, 0x42)
+#pragma charmap (0x43, 0x43)
+#pragma charmap (0x44, 0x44)
+#pragma charmap (0x45, 0x45)
+#pragma charmap (0x46, 0x46)
+#pragma charmap (0x47, 0x47)
+#pragma charmap (0x48, 0x48)
+#pragma charmap (0x49, 0x49)
+#pragma charmap (0x4A, 0x4A)
+#pragma charmap (0x4B, 0x4B)
+#pragma charmap (0x4C, 0x4C)
+#pragma charmap (0x4D, 0x4D)
+#pragma charmap (0x4E, 0x4E)
+#pragma charmap (0x4F, 0x4F)
+
+#pragma charmap (0x50, 0x50)
+#pragma charmap (0x51, 0x51)
+#pragma charmap (0x52, 0x52)
+#pragma charmap (0x53, 0x53)
+#pragma charmap (0x54, 0x54)
+#pragma charmap (0x55, 0x55)
+#pragma charmap (0x56, 0x56)
+#pragma charmap (0x57, 0x57)
+#pragma charmap (0x58, 0x58)
+#pragma charmap (0x59, 0x59)
+#pragma charmap (0x5A, 0x5A)
+#pragma charmap (0x5B, 0x5B)
+#pragma charmap (0x5C, 0x5C)
+#pragma charmap (0x5D, 0x5D)
+#pragma charmap (0x5E, 0x5E)
+#pragma charmap (0x5F, 0x5F)
+
+#pragma charmap (0x60, 0x60)
+#pragma charmap (0x61, 0x61)
+#pragma charmap (0x62, 0x62)
+#pragma charmap (0x63, 0x63)
+#pragma charmap (0x64, 0x64)
+#pragma charmap (0x65, 0x65)
+#pragma charmap (0x66, 0x66)
+#pragma charmap (0x67, 0x67)
+#pragma charmap (0x68, 0x68)
+#pragma charmap (0x69, 0x69)
+#pragma charmap (0x6A, 0x6A)
+#pragma charmap (0x6B, 0x6B)
+#pragma charmap (0x6C, 0x6C)
+#pragma charmap (0x6D, 0x6D)
+#pragma charmap (0x6E, 0x6E)
+#pragma charmap (0x6F, 0x6F)
+
+#pragma charmap (0x70, 0x70)
+#pragma charmap (0x71, 0x71)
+#pragma charmap (0x72, 0x72)
+#pragma charmap (0x73, 0x73)
+#pragma charmap (0x74, 0x74)
+#pragma charmap (0x75, 0x75)
+#pragma charmap (0x76, 0x76)
+#pragma charmap (0x77, 0x77)
+#pragma charmap (0x78, 0x78)
+#pragma charmap (0x79, 0x79)
+#pragma charmap (0x7A, 0x7A)
+#pragma charmap (0x7B, 0x7B)
+#pragma charmap (0x7C, 0x7C)
+#pragma charmap (0x7D, 0x7D)
+#pragma charmap (0x7E, 0x7E)
+#pragma charmap (0x7F, 0x7F)
+
+#pragma charmap (0x80, 0x80)
+#pragma charmap (0x81, 0x81)
+#pragma charmap (0x82, 0x82)
+#pragma charmap (0x83, 0x83)
+#pragma charmap (0x84, 0x84)
+#pragma charmap (0x85, 0x85)
+#pragma charmap (0x86, 0x86)
+#pragma charmap (0x87, 0x87)
+#pragma charmap (0x88, 0x88)
+#pragma charmap (0x89, 0x89)
+#pragma charmap (0x8A, 0x8A)
+#pragma charmap (0x8B, 0x8B)
+#pragma charmap (0x8C, 0x8C)
+#pragma charmap (0x8D, 0x8D)
+#pragma charmap (0x8E, 0x8E)
+#pragma charmap (0x8F, 0x8F)
+
+#pragma charmap (0x90, 0x90)
+#pragma charmap (0x91, 0x91)
+#pragma charmap (0x92, 0x92)
+#pragma charmap (0x93, 0x93)
+#pragma charmap (0x94, 0x94)
+#pragma charmap (0x95, 0x95)
+#pragma charmap (0x96, 0x96)
+#pragma charmap (0x97, 0x97)
+#pragma charmap (0x98, 0x98)
+#pragma charmap (0x99, 0x99)
+#pragma charmap (0x9A, 0x9A)
+#pragma charmap (0x9B, 0x9B)
+#pragma charmap (0x9C, 0x9C)
+#pragma charmap (0x9D, 0x9D)
+#pragma charmap (0x9E, 0x9E)
+#pragma charmap (0x9F, 0x9F)
+
+#pragma charmap (0xA0, 0xA0)
+#pragma charmap (0xA1, 0xA1)
+#pragma charmap (0xA2, 0xA2)
+#pragma charmap (0xA3, 0xA3)
+#pragma charmap (0xA4, 0xA4)
+#pragma charmap (0xA5, 0xA5)
+#pragma charmap (0xA6, 0xA6)
+#pragma charmap (0xA7, 0xA7)
+#pragma charmap (0xA8, 0xA8)
+#pragma charmap (0xA9, 0xA9)
+#pragma charmap (0xAA, 0xAA)
+#pragma charmap (0xAB, 0xAB)
+#pragma charmap (0xAC, 0xAC)
+#pragma charmap (0xAD, 0xAD)
+#pragma charmap (0xAE, 0xAE)
+#pragma charmap (0xAF, 0xAF)
+
+#pragma charmap (0xB0, 0xB0)
+#pragma charmap (0xB1, 0xB1)
+#pragma charmap (0xB2, 0xB2)
+#pragma charmap (0xB3, 0xB3)
+#pragma charmap (0xB4, 0xB4)
+#pragma charmap (0xB5, 0xB5)
+#pragma charmap (0xB6, 0xB6)
+#pragma charmap (0xB7, 0xB7)
+#pragma charmap (0xB8, 0xB8)
+#pragma charmap (0xB9, 0xB9)
+#pragma charmap (0xBA, 0xBA)
+#pragma charmap (0xBB, 0xBB)
+#pragma charmap (0xBC, 0xBC)
+#pragma charmap (0xBD, 0xBD)
+#pragma charmap (0xBE, 0xBE)
+#pragma charmap (0xBF, 0xBF)
+
+#pragma charmap (0xC0, 0xC0)
+#pragma charmap (0xC1, 0xC1)
+#pragma charmap (0xC2, 0xC2)
+#pragma charmap (0xC3, 0xC3)
+#pragma charmap (0xC4, 0xC4)
+#pragma charmap (0xC5, 0xC5)
+#pragma charmap (0xC6, 0xC6)
+#pragma charmap (0xC7, 0xC7)
+#pragma charmap (0xC8, 0xC8)
+#pragma charmap (0xC9, 0xC9)
+#pragma charmap (0xCA, 0xCA)
+#pragma charmap (0xCB, 0xCB)
+#pragma charmap (0xCC, 0xCC)
+#pragma charmap (0xCD, 0xCD)
+#pragma charmap (0xCE, 0xCE)
+#pragma charmap (0xCF, 0xCF)
+
+#pragma charmap (0xD0, 0xD0)
+#pragma charmap (0xD1, 0xD1)
+#pragma charmap (0xD2, 0xD2)
+#pragma charmap (0xD3, 0xD3)
+#pragma charmap (0xD4, 0xD4)
+#pragma charmap (0xD5, 0xD5)
+#pragma charmap (0xD6, 0xD6)
+#pragma charmap (0xD7, 0xD7)
+#pragma charmap (0xD8, 0xD8)
+#pragma charmap (0xD9, 0xD9)
+#pragma charmap (0xDA, 0xDA)
+#pragma charmap (0xDB, 0xDB)
+#pragma charmap (0xDC, 0xDC)
+#pragma charmap (0xDD, 0xDD)
+#pragma charmap (0xDE, 0xDE)
+#pragma charmap (0xDF, 0xDF)
+
+#pragma charmap (0xE0, 0xE0)
+#pragma charmap (0xE1, 0xE1)
+#pragma charmap (0xE2, 0xE2)
+#pragma charmap (0xE3, 0xE3)
+#pragma charmap (0xE4, 0xE4)
+#pragma charmap (0xE5, 0xE5)
+#pragma charmap (0xE6, 0xE6)
+#pragma charmap (0xE7, 0xE7)
+#pragma charmap (0xE8, 0xE8)
+#pragma charmap (0xE9, 0xE9)
+#pragma charmap (0xEA, 0xEA)
+#pragma charmap (0xEB, 0xEB)
+#pragma charmap (0xEC, 0xEC)
+#pragma charmap (0xED, 0xED)
+#pragma charmap (0xEE, 0xEE)
+#pragma charmap (0xEF, 0xEF)
+
+#pragma charmap (0xF0, 0xF0)
+#pragma charmap (0xF1, 0xF1)
+#pragma charmap (0xF2, 0xF2)
+#pragma charmap (0xF3, 0xF3)
+#pragma charmap (0xF4, 0xF4)
+#pragma charmap (0xF5, 0xF5)
+#pragma charmap (0xF6, 0xF6)
+#pragma charmap (0xF7, 0xF7)
+#pragma charmap (0xF8, 0xF8)
+#pragma charmap (0xF9, 0xF9)
+#pragma charmap (0xFA, 0xFA)
+#pragma charmap (0xFB, 0xFB)
+#pragma charmap (0xFC, 0xFC)
+#pragma charmap (0xFD, 0xFD)
+#pragma charmap (0xFE, 0xFE)
+#pragma charmap (0xFF, 0xFF)
+
+/*****************************************************************************/
+/* */
+/* atari_screen_charmap.h */
+/* */
+/* Atari system internal string mapping (ISO-8859-1 -> Internal/Screen-Code) */
+/* */
+/* */
+/* */
+/* (C) 2016 Christian Krueger */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+/* No include guard here! Multiple use in one file may be intentional. */
+
+#pragma warn (remap-zero, push, off)
+#pragma charmap (0x00, 0x40)
+#pragma warn (remap-zero, pop)
+
+#pragma charmap (0x01, 0x41)
+#pragma charmap (0x02, 0x42)
+#pragma charmap (0x03, 0x43)
+#pragma charmap (0x04, 0x44)
+#pragma charmap (0x05, 0x45)
+#pragma charmap (0x06, 0x46)
+#pragma charmap (0x07, 0xFD)
+#pragma charmap (0x08, 0x48)
+#pragma charmap (0x09, 0x7F)
+#pragma charmap (0x0A, 0xDB)
+#pragma charmap (0x0B, 0x4B)
+#pragma charmap (0x0C, 0x7D)
+#pragma charmap (0x0D, 0x4D)
+#pragma charmap (0x0E, 0x4E)
+#pragma charmap (0x0F, 0x4F)
+
+#pragma charmap (0x10, 0x50)
+#pragma charmap (0x11, 0x51)
+#pragma charmap (0x12, 0x52)
+#pragma charmap (0x13, 0x53)
+#pragma charmap (0x14, 0x54)
+#pragma charmap (0x15, 0x55)
+#pragma charmap (0x16, 0x56)
+#pragma charmap (0x17, 0x57)
+#pragma charmap (0x18, 0x58)
+#pragma charmap (0x19, 0x59)
+#pragma charmap (0x1A, 0x5A)
+#pragma charmap (0x1B, 0x5B)
+#pragma charmap (0x1C, 0x5C)
+#pragma charmap (0x1D, 0x5D)
+#pragma charmap (0x1E, 0x5E)
+#pragma charmap (0x1F, 0x5F)
+
+#pragma warn (remap-zero, push, off)
+#pragma charmap (0x20, 0x00)
+#pragma warn (remap-zero, pop)
+
+#pragma charmap (0x21, 0x01)
+#pragma charmap (0x22, 0x02)
+#pragma charmap (0x23, 0x03)
+#pragma charmap (0x24, 0x04)
+#pragma charmap (0x25, 0x05)
+#pragma charmap (0x26, 0x06)
+#pragma charmap (0x27, 0x07)
+#pragma charmap (0x28, 0x08)
+#pragma charmap (0x29, 0x09)
+#pragma charmap (0x2A, 0x0A)
+#pragma charmap (0x2B, 0x0B)
+#pragma charmap (0x2C, 0x0C)
+#pragma charmap (0x2D, 0x0D)
+#pragma charmap (0x2E, 0x0E)
+#pragma charmap (0x2F, 0x0F)
+
+#pragma charmap (0x30, 0x10)
+#pragma charmap (0x31, 0x11)
+#pragma charmap (0x32, 0x12)
+#pragma charmap (0x33, 0x13)
+#pragma charmap (0x34, 0x14)
+#pragma charmap (0x35, 0x15)
+#pragma charmap (0x36, 0x16)
+#pragma charmap (0x37, 0x17)
+#pragma charmap (0x38, 0x18)
+#pragma charmap (0x39, 0x19)
+#pragma charmap (0x3A, 0x1A)
+#pragma charmap (0x3B, 0x1B)
+#pragma charmap (0x3C, 0x1C)
+#pragma charmap (0x3D, 0x1D)
+#pragma charmap (0x3E, 0x1E)
+#pragma charmap (0x3F, 0x1F)
+
+#pragma charmap (0x40, 0x20)
+#pragma charmap (0x41, 0x21)
+#pragma charmap (0x42, 0x22)
+#pragma charmap (0x43, 0x23)
+#pragma charmap (0x44, 0x24)
+#pragma charmap (0x45, 0x25)
+#pragma charmap (0x46, 0x26)
+#pragma charmap (0x47, 0x27)
+#pragma charmap (0x48, 0x28)
+#pragma charmap (0x49, 0x29)
+#pragma charmap (0x4A, 0x2A)
+#pragma charmap (0x4B, 0x2B)
+#pragma charmap (0x4C, 0x2C)
+#pragma charmap (0x4D, 0x2D)
+#pragma charmap (0x4E, 0x2E)
+#pragma charmap (0x4F, 0x2F)
+
+#pragma charmap (0x50, 0x30)
+#pragma charmap (0x51, 0x31)
+#pragma charmap (0x52, 0x32)
+#pragma charmap (0x53, 0x33)
+#pragma charmap (0x54, 0x34)
+#pragma charmap (0x55, 0x35)
+#pragma charmap (0x56, 0x36)
+#pragma charmap (0x57, 0x37)
+#pragma charmap (0x58, 0x38)
+#pragma charmap (0x59, 0x39)
+#pragma charmap (0x5A, 0x3A)
+#pragma charmap (0x5B, 0x3B)
+#pragma charmap (0x5C, 0x3C)
+#pragma charmap (0x5D, 0x3D)
+#pragma charmap (0x5E, 0x3E)
+#pragma charmap (0x5F, 0x3F)
+
+#pragma charmap (0x60, 0x60)
+#pragma charmap (0x61, 0x61)
+#pragma charmap (0x62, 0x62)
+#pragma charmap (0x63, 0x63)
+#pragma charmap (0x64, 0x64)
+#pragma charmap (0x65, 0x65)
+#pragma charmap (0x66, 0x66)
+#pragma charmap (0x67, 0x67)
+#pragma charmap (0x68, 0x68)
+#pragma charmap (0x69, 0x69)
+#pragma charmap (0x6A, 0x6A)
+#pragma charmap (0x6B, 0x6B)
+#pragma charmap (0x6C, 0x6C)
+#pragma charmap (0x6D, 0x6D)
+#pragma charmap (0x6E, 0x6E)
+#pragma charmap (0x6F, 0x6F)
+
+#pragma charmap (0x70, 0x70)
+#pragma charmap (0x71, 0x71)
+#pragma charmap (0x72, 0x72)
+#pragma charmap (0x73, 0x73)
+#pragma charmap (0x74, 0x74)
+#pragma charmap (0x75, 0x75)
+#pragma charmap (0x76, 0x76)
+#pragma charmap (0x77, 0x77)
+#pragma charmap (0x78, 0x78)
+#pragma charmap (0x79, 0x79)
+#pragma charmap (0x7A, 0x7A)
+#pragma charmap (0x7B, 0x7B)
+#pragma charmap (0x7C, 0x7C)
+#pragma charmap (0x7D, 0x7D)
+#pragma charmap (0x7E, 0x7E)
+#pragma charmap (0x7F, 0x7F)
+
+#pragma charmap (0x80, 0xC0)
+#pragma charmap (0x81, 0xC1)
+#pragma charmap (0x82, 0xC2)
+#pragma charmap (0x83, 0xC3)
+#pragma charmap (0x84, 0xC4)
+#pragma charmap (0x85, 0xC5)
+#pragma charmap (0x86, 0xC6)
+#pragma charmap (0x87, 0xC7)
+#pragma charmap (0x88, 0xC8)
+#pragma charmap (0x89, 0xC9)
+#pragma charmap (0x8A, 0xCA)
+#pragma charmap (0x8B, 0xCB)
+#pragma charmap (0x8C, 0xCC)
+#pragma charmap (0x8D, 0xCD)
+#pragma charmap (0x8E, 0xCE)
+#pragma charmap (0x8F, 0xCF)
+
+#pragma charmap (0x90, 0xD0)
+#pragma charmap (0x91, 0xD1)
+#pragma charmap (0x92, 0xD2)
+#pragma charmap (0x93, 0xD3)
+#pragma charmap (0x94, 0xD4)
+#pragma charmap (0x95, 0xD5)
+#pragma charmap (0x96, 0xD6)
+#pragma charmap (0x97, 0xD7)
+#pragma charmap (0x98, 0xD8)
+#pragma charmap (0x99, 0xD9)
+#pragma charmap (0x9A, 0xDA)
+#pragma charmap (0x9B, 0xDB)
+#pragma charmap (0x9C, 0xDC)
+#pragma charmap (0x9D, 0xDD)
+#pragma charmap (0x9E, 0xDE)
+#pragma charmap (0x9F, 0xDF)
+
+#pragma charmap (0xA0, 0x80)
+#pragma charmap (0xA1, 0x81)
+#pragma charmap (0xA2, 0x82)
+#pragma charmap (0xA3, 0x83)
+#pragma charmap (0xA4, 0x84)
+#pragma charmap (0xA5, 0x85)
+#pragma charmap (0xA6, 0x86)
+#pragma charmap (0xA7, 0x87)
+#pragma charmap (0xA8, 0x88)
+#pragma charmap (0xA9, 0x89)
+#pragma charmap (0xAA, 0x8A)
+#pragma charmap (0xAB, 0x8B)
+#pragma charmap (0xAC, 0x8C)
+#pragma charmap (0xAD, 0x8D)
+#pragma charmap (0xAE, 0x8E)
+#pragma charmap (0xAF, 0x8F)
+
+#pragma charmap (0xB0, 0x90)
+#pragma charmap (0xB1, 0x91)
+#pragma charmap (0xB2, 0x92)
+#pragma charmap (0xB3, 0x93)
+#pragma charmap (0xB4, 0x94)
+#pragma charmap (0xB5, 0x95)
+#pragma charmap (0xB6, 0x96)
+#pragma charmap (0xB7, 0x97)
+#pragma charmap (0xB8, 0x98)
+#pragma charmap (0xB9, 0x99)
+#pragma charmap (0xBA, 0x9A)
+#pragma charmap (0xBB, 0x9B)
+#pragma charmap (0xBC, 0x9C)
+#pragma charmap (0xBD, 0x9D)
+#pragma charmap (0xBE, 0x9E)
+#pragma charmap (0xBF, 0x9F)
+
+#pragma charmap (0xC0, 0xA0)
+#pragma charmap (0xC1, 0xA1)
+#pragma charmap (0xC2, 0xA2)
+#pragma charmap (0xC3, 0xA3)
+#pragma charmap (0xC4, 0xA4)
+#pragma charmap (0xC5, 0xA5)
+#pragma charmap (0xC6, 0xA6)
+#pragma charmap (0xC7, 0xA7)
+#pragma charmap (0xC8, 0xA8)
+#pragma charmap (0xC9, 0xA9)
+#pragma charmap (0xCA, 0xAA)
+#pragma charmap (0xCB, 0xAB)
+#pragma charmap (0xCC, 0xAC)
+#pragma charmap (0xCD, 0xAD)
+#pragma charmap (0xCE, 0xAE)
+#pragma charmap (0xCF, 0xAF)
+
+#pragma charmap (0xD0, 0xB0)
+#pragma charmap (0xD1, 0xB1)
+#pragma charmap (0xD2, 0xB2)
+#pragma charmap (0xD3, 0xB3)
+#pragma charmap (0xD4, 0xB4)
+#pragma charmap (0xD5, 0xB5)
+#pragma charmap (0xD6, 0xB6)
+#pragma charmap (0xD7, 0xB7)
+#pragma charmap (0xD8, 0xB8)
+#pragma charmap (0xD9, 0xB9)
+#pragma charmap (0xDA, 0xBA)
+#pragma charmap (0xDB, 0xBB)
+#pragma charmap (0xDC, 0xBC)
+#pragma charmap (0xDD, 0xBD)
+#pragma charmap (0xDE, 0xBE)
+#pragma charmap (0xDF, 0xBF)
+
+#pragma charmap (0xE0, 0xE0)
+#pragma charmap (0xE1, 0xE1)
+#pragma charmap (0xE2, 0xE2)
+#pragma charmap (0xE3, 0xE3)
+#pragma charmap (0xE4, 0xE4)
+#pragma charmap (0xE5, 0xE5)
+#pragma charmap (0xE6, 0xE6)
+#pragma charmap (0xE7, 0xE7)
+#pragma charmap (0xE8, 0xE8)
+#pragma charmap (0xE9, 0xE9)
+#pragma charmap (0xEA, 0xEA)
+#pragma charmap (0xEB, 0xEB)
+#pragma charmap (0xEC, 0xEC)
+#pragma charmap (0xED, 0xED)
+#pragma charmap (0xEE, 0xEE)
+#pragma charmap (0xEF, 0xEF)
+
+#pragma charmap (0xF0, 0xF0)
+#pragma charmap (0xF1, 0xF1)
+#pragma charmap (0xF2, 0xF2)
+#pragma charmap (0xF3, 0xF3)
+#pragma charmap (0xF4, 0xF4)
+#pragma charmap (0xF5, 0xF5)
+#pragma charmap (0xF6, 0xF6)
+#pragma charmap (0xF7, 0xF7)
+#pragma charmap (0xF8, 0xF8)
+#pragma charmap (0xF9, 0xF9)
+#pragma charmap (0xFA, 0xFA)
+#pragma charmap (0xFB, 0xFB)
+#pragma charmap (0xFC, 0xFC)
+#pragma charmap (0xFD, 0xFD)
+#pragma charmap (0xFE, 0xFE)
+#pragma charmap (0xFF, 0xFF)
+
+/*****************************************************************************/
+/* */
+/* atmos.h */
+/* */
+/* Oric Atmos system-specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2002 Debrune Jérome, */
+/* (C) 2003-2013 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _ATMOS_H
+#define _ATMOS_H
+
+
+
+/* Check for errors */
+#if !defined(__ATMOS__)
+# error This module may only be used when compiling for the Oric Atmos!
+#endif
+
+
+
+/* Color defines */
+#define COLOR_BLACK 0x00
+#define COLOR_RED 0x01
+#define COLOR_GREEN 0x02
+#define COLOR_YELLOW 0x03
+#define COLOR_BLUE 0x04
+#define COLOR_MAGENTA 0x05
+#define COLOR_CYAN 0x06
+#define COLOR_WHITE 0x07
+
+/* TGI color defines */
+/* White and red are swapped, so that the pallete
+** driver is compatible with black-and-white drivers.
+*/
+#define TGI_COLOR_BLACK COLOR_BLACK
+#define TGI_COLOR_WHITE 1
+#define TGI_COLOR_GREEN COLOR_GREEN
+#define TGI_COLOR_YELLOW COLOR_YELLOW
+#define TGI_COLOR_BLUE COLOR_BLUE
+#define TGI_COLOR_MAGENTA COLOR_MAGENTA
+#define TGI_COLOR_CYAN COLOR_CYAN
+#define TGI_COLOR_RED 7
+
+
+
+/* Define hardware */
+#include <_6522.h>
+#define VIA (*(struct __6522*)0x300)
+
+
+
+/* These are defined to be FUNCT + NumberKey */
+#define CH_F1 0xB1
+#define CH_F2 0xB2
+#define CH_F3 0xB3
+#define CH_F4 0xB4
+#define CH_F5 0xB5
+#define CH_F6 0xB6
+#define CH_F7 0xB7
+#define CH_F8 0xB8
+#define CH_F9 0xB9
+#define CH_F10 0xB0
+
+
+
+/* Character codes */
+#define CH_ULCORNER '+'
+#define CH_URCORNER '+'
+#define CH_LLCORNER '+'
+#define CH_LRCORNER '+'
+#define CH_TTEE '+'
+#define CH_BTEE '+'
+#define CH_LTEE '+'
+#define CH_RTEE '+'
+#define CH_CROSS '+'
+#define CH_CURS_UP 11
+#define CH_CURS_DOWN 10
+#define CH_CURS_LEFT 8
+#define CH_CURS_RIGHT 9
+#define CH_DEL 127
+#define CH_ENTER 13
+#define CH_STOP 3
+#define CH_LIRA 95
+#define CH_ESC 27
+
+
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x10
+#define JOY_DOWN_MASK 0x08
+#define JOY_LEFT_MASK 0x01
+#define JOY_RIGHT_MASK 0x02
+#define JOY_BTN_1_MASK 0x20
+
+#define JOY_FIRE_MASK JOY_BTN_1_MASK
+#define JOY_FIRE(v) ((v) & JOY_FIRE_MASK)
+
+
+
+/* No support for dynamically loadable drivers */
+#define DYN_DRV 0
+
+
+
+/* The addresses of the static drivers */
+extern void atmos_pase_joy[]; /* Referred to by joy_static_stddrv[] */
+extern void atmos_ijk_joy[];
+extern void atmos_acia_ser[]; /* Referred to by ser_static_stddrv[] */
+extern void atmos_228_200_3_tgi[];
+extern void atmos_240_200_2_tgi[]; /* Referred to by tgi_static_stddrv[] */
+
+
+
+/*****************************************************************************/
+/* Functions */
+/*****************************************************************************/
+
+
+
+void __fastcall__ atmos_load(const char* name);
+/* Load Atmos tape. */
+
+void __fastcall__ atmos_save(const char* name, const void* start, const void* end);
+/* Save Atmos tape. */
+
+void atmos_explode (void);
+/* Bomb sound effect */
+
+void atmos_ping (void);
+/* Bell or ricochet sound effect */
+
+void atmos_shoot (void);
+/* Pistol sound effect */
+
+void atmos_tick (void);
+/* High-pitch click */
+
+void atmos_tock (void);
+/* Low-pitch click */
+
+void atmos_zap (void);
+/* Raygun sound effect */
+
+
+
+/* End of atmos.h */
+#endif
+/*****************************************************************************/
+/* */
+/* c128.h */
+/* */
+/* C128 system specific definitions */
+/* */
+/* */
+/* */
+/* (C) 1998-2013, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _C128_H
+#define _C128_H
+
+
+
+/* Check for errors */
+#if !defined(__C128__)
+# error This module may only be used when compiling for the C128!
+#endif
+
+
+
+/* Additional key defines */
+#define CH_F1 133
+#define CH_F2 137
+#define CH_F3 134
+#define CH_F4 138
+#define CH_F5 135
+#define CH_F6 139
+#define CH_F7 136
+#define CH_F8 140
+
+/* Color defines */
+#define COLOR_BLACK 0x00
+#define COLOR_WHITE 0x01
+#define COLOR_RED 0x02
+#define COLOR_CYAN 0x03
+#define COLOR_PURPLE 0x04
+#define COLOR_GREEN 0x05
+#define COLOR_BLUE 0x06
+#define COLOR_YELLOW 0x07
+#define COLOR_ORANGE 0x08
+#define COLOR_BROWN 0x09
+#define COLOR_LIGHTRED 0x0A
+#define COLOR_GRAY1 0x0B
+#define COLOR_GRAY2 0x0C
+#define COLOR_LIGHTGREEN 0x0D
+#define COLOR_LIGHTBLUE 0x0E
+#define COLOR_GRAY3 0x0F
+
+/* TGI color defines */
+#define TGI_COLOR_BLACK COLOR_BLACK
+#define TGI_COLOR_WHITE COLOR_WHITE
+#define TGI_COLOR_RED COLOR_RED
+#define TGI_COLOR_CYAN COLOR_CYAN
+#define TGI_COLOR_PURPLE COLOR_PURPLE
+#define TGI_COLOR_GREEN COLOR_GREEN
+#define TGI_COLOR_BLUE COLOR_BLUE
+#define TGI_COLOR_YELLOW COLOR_YELLOW
+#define TGI_COLOR_ORANGE COLOR_ORANGE
+#define TGI_COLOR_BROWN COLOR_BROWN
+#define TGI_COLOR_LIGHTRED COLOR_LIGHTRED
+#define TGI_COLOR_GRAY1 COLOR_GRAY1
+#define TGI_COLOR_GRAY2 COLOR_GRAY2
+#define TGI_COLOR_LIGHTGREEN COLOR_LIGHTGREEN
+#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
+#define TGI_COLOR_GRAY3 COLOR_GRAY3
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x01
+#define JOY_DOWN_MASK 0x02
+#define JOY_LEFT_MASK 0x04
+#define JOY_RIGHT_MASK 0x08
+#define JOY_BTN_1_MASK 0x10
+
+/* Video mode defines */
+#define VIDEOMODE_40x25 0x00
+#define VIDEOMODE_80x25 0x80
+#define VIDEOMODE_40COL VIDEOMODE_40x25
+#define VIDEOMODE_80COL VIDEOMODE_80x25
+
+
+
+/* Define hardware */
+#include <_vic2.h>
+#define VIC (*(struct __vic2*)0xD000)
+
+#include <_sid.h>
+#define SID (*(struct __sid*)0xD400)
+
+#include <_vdc.h>
+#define VDC (*(struct __vdc*)0xD600)
+
+#include <_6526.h>
+#define CIA1 (*(struct __6526*)0xDC00)
+#define CIA2 (*(struct __6526*)0xDD00)
+
+
+
+/* Define special memory areas */
+#define COLOR_RAM ((unsigned char*)0xD800)
+
+
+
+/* The addresses of the static drivers */
+extern void c128_georam_emd[];
+extern void c128_ram_emd[];
+extern void c128_ram2_emd[];
+extern void c128_ramcart_emd[];
+extern void c128_reu_emd[];
+extern void c128_vdc_emd[];
+extern void c128_ptvjoy_joy[];
+extern void c128_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
+extern void c128_1351_mou[]; /* Referred to by mouse_static_stddrv[] */
+extern void c128_joy_mou[];
+extern void c128_inkwell_mou[];
+extern void c128_pot_mou[];
+extern void c128_swlink_ser[]; /* Referred to by ser_static_stddrv[] */
+extern void c128_hi_tgi[];
+extern void c128_vdc_tgi[]; /* Referred to by tgi_static_stddrv[] */
+extern void c128_vdc2_tgi[];
+
+
+
+unsigned __fastcall__ videomode (unsigned Mode);
+/* Set the video mode, return the old mode. Call with one of the VIDEOMODE_xx
+** constants.
+*/
+
+void toggle_videomode (void);
+/* Toggle the video mode between 40 and 80 chars (calls SWAPPER).
+** THIS FUNCTION IS DEPRECATED, please use videomode instead!
+*/
+
+void c64mode (void);
+/* Switch the C128 into C64 mode. Note: This function will not return! */
+
+void fast (void);
+/* Switch the CPU into 2MHz mode. Note: This will disable video when in
+** 40 column mode.
+*/
+
+void slow (void);
+/* Switch the CPU into 1MHz mode. */
+
+unsigned char isfast (void);
+/* Returns 1 if the CPU is in 2MHz mode. */
+
+/* End of c128.h */
+#endif
+/*****************************************************************************/
+/* */
+/* c16.h */
+/* */
+/* C16 system specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2002 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@musoftware.de */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _C16_H
+#define _C16_H
+
+
+
+/* Check for errors */
+#if !defined(__C16__)
+# error This module may only be used when compiling for the C16!
+#endif
+
+
+
+/* Include the base header file for the 264 series. */
+#include
+
+
+
+/* The addresses of the static drivers */
+extern void c16_ram_emd[];
+extern void c16_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
+
+
+
+/* End of c16.h */
+#endif
+/*****************************************************************************/
+/* */
+/* c64.h */
+/* */
+/* C64 system-specific definitions */
+/* */
+/* */
+/* */
+/* (C) 1998-2013 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _C64_H
+#define _C64_H
+
+
+
+/* Check for errors */
+#if !defined(__C64__)
+# error This module may only be used when compiling for the C64!
+#endif
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Additional key defines */
+#define CH_F1 133
+#define CH_F2 137
+#define CH_F3 134
+#define CH_F4 138
+#define CH_F5 135
+#define CH_F6 139
+#define CH_F7 136
+#define CH_F8 140
+
+/* Color defines */
+#define COLOR_BLACK 0x00
+#define COLOR_WHITE 0x01
+#define COLOR_RED 0x02
+#define COLOR_CYAN 0x03
+#define COLOR_PURPLE 0x04
+#define COLOR_GREEN 0x05
+#define COLOR_BLUE 0x06
+#define COLOR_YELLOW 0x07
+#define COLOR_ORANGE 0x08
+#define COLOR_BROWN 0x09
+#define COLOR_LIGHTRED 0x0A
+#define COLOR_GRAY1 0x0B
+#define COLOR_GRAY2 0x0C
+#define COLOR_LIGHTGREEN 0x0D
+#define COLOR_LIGHTBLUE 0x0E
+#define COLOR_GRAY3 0x0F
+
+/* TGI color defines */
+#define TGI_COLOR_BLACK COLOR_BLACK
+#define TGI_COLOR_WHITE COLOR_WHITE
+#define TGI_COLOR_RED COLOR_RED
+#define TGI_COLOR_CYAN COLOR_CYAN
+#define TGI_COLOR_PURPLE COLOR_PURPLE
+#define TGI_COLOR_GREEN COLOR_GREEN
+#define TGI_COLOR_BLUE COLOR_BLUE
+#define TGI_COLOR_YELLOW COLOR_YELLOW
+#define TGI_COLOR_ORANGE COLOR_ORANGE
+#define TGI_COLOR_BROWN COLOR_BROWN
+#define TGI_COLOR_LIGHTRED COLOR_LIGHTRED
+#define TGI_COLOR_GRAY1 COLOR_GRAY1
+#define TGI_COLOR_GRAY2 COLOR_GRAY2
+#define TGI_COLOR_LIGHTGREEN COLOR_LIGHTGREEN
+#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
+#define TGI_COLOR_GRAY3 COLOR_GRAY3
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x01
+#define JOY_DOWN_MASK 0x02
+#define JOY_LEFT_MASK 0x04
+#define JOY_RIGHT_MASK 0x08
+#define JOY_BTN_1_MASK 0x10
+
+/* Define hardware */
+#include <_vic2.h>
+#define VIC (*(struct __vic2*)0xD000)
+
+#include <_sid.h>
+#define SID (*(struct __sid*)0xD400)
+
+#include <_6526.h>
+#define CIA1 (*(struct __6526*)0xDC00)
+#define CIA2 (*(struct __6526*)0xDD00)
+
+/* Define special memory areas */
+#define COLOR_RAM ((unsigned char*)0xD800)
+
+/* Return codes for get_ostype */
+#define C64_OS_US 0xAA /* US version */
+#define C64_OS_PET64 0x64 /* PET 64 */
+#define C64_OS_SX64 0x43 /* SX-64 */
+#define C64_EU_NEW 0x03
+#define C64_EU_OLD 0x00
+#define C64_DTV 0xFF /* C64 DTV */
+
+
+
+/*****************************************************************************/
+/* Variables */
+/*****************************************************************************/
+
+
+
+/* The addresses of the static drivers */
+extern void c64_65816_emd[];
+extern void c64_c256k_emd[];
+extern void c64_dqbb_emd[];
+extern void c64_georam_emd[];
+extern void c64_isepic_emd[];
+extern void c64_kerberos_emd[];
+extern void c64_ram_emd[];
+extern void c64_ramcart_emd[];
+extern void c64_reu_emd[];
+extern void c64_vdc_emd[];
+extern void c64_rrr_emd[];
+extern void dtv_himem_emd[];
+extern void c64_hitjoy_joy[];
+extern void c64_numpad_joy[];
+extern void c64_ptvjoy_joy[];
+extern void c64_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
+extern void c64_1351_mou[]; /* Referred to by mouse_static_stddrv[] */
+extern void c64_joy_mou[];
+extern void c64_inkwell_mou[];
+extern void c64_pot_mou[];
+extern void c64_swlink_ser[]; /* Referred to by ser_static_stddrv[] */
+extern void c64_hi_tgi[]; /* Referred to by tgi_static_stddrv[] */
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+unsigned char get_ostype (void);
+/* Get the ROM version. Returns one of the C64_OS_xxx codes. */
+
+
+
+/* End of c64.h */
+#endif
+/*****************************************************************************/
+/* */
+/* cbm.h */
+/* */
+/* CBM system-specific definitions */
+/* */
+/* */
+/* */
+/* (C) 1998-2015, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _CBM_H
+#define _CBM_H
+
+
+
+/* Check for errors */
+#if !defined(__CBM__)
+# error This module may be used only when compiling for CBM machines!
+#endif
+
+
+
+/* We need NULL. */
+#include
+
+/* Load the system-specific files here, if needed. */
+#if defined(__C64__) && !defined(_C64_H)
+# include
+#elif defined(__VIC20__) && !defined(_VIC20_H)
+# include
+#elif defined(__C128__) && !defined(_C128_H)
+# include
+#elif defined(__PLUS4__) && !defined(_PLUS4_H)
+# include
+#elif defined(__C16__) && !defined(_C16_H)
+# include
+#elif defined(__CBM510__) && !defined(_CBM510_H)
+# include
+#elif defined(__CBM610__) && !defined(_CBM610_H)
+# include
+#elif defined(__PET__) && !defined(_PET_H)
+# include
+#elif defined(__CX16__) && !defined(_CX16_H)
+# include
+#endif
+
+/* Include definitions for CBM file types */
+#include
+
+
+
+#define JOY_FIRE_MASK JOY_BTN_1_MASK
+#define JOY_FIRE(v) ((v) & JOY_FIRE_MASK)
+
+
+
+/*****************************************************************************/
+/* Variables */
+/*****************************************************************************/
+
+
+
+/* The file stream implementation and the POSIX I/O functions will
+** use the following variable to determine the file type to use.
+*/
+extern char _filetype; /* Defaults to 's' */
+
+
+
+/*****************************************************************************/
+/* Character-codes (CBM charset) */
+/*****************************************************************************/
+
+
+
+#define CH_HLINE 192
+#define CH_VLINE 221
+#define CH_ULCORNER 176
+#define CH_URCORNER 174
+#define CH_LLCORNER 173
+#define CH_LRCORNER 189
+#define CH_TTEE 178
+#define CH_BTEE 177
+#define CH_LTEE 171
+#define CH_RTEE 179
+#define CH_CROSS 219
+#define CH_CURS_UP 145
+#define CH_CURS_DOWN 17
+#define CH_CURS_LEFT 157
+#define CH_CURS_RIGHT 29
+#define CH_PI 222
+#define CH_HOME 19
+#define CH_DEL 20
+#define CH_INS 148
+#define CH_ENTER 13
+#define CH_STOP 3
+#define CH_LIRA 92
+#define CH_ESC 27
+#define CH_FONT_LOWER 14
+#define CH_FONT_UPPER 142
+
+
+
+/*****************************************************************************/
+/* Definitions for directory reading functions */
+/*****************************************************************************/
+
+
+
+/* CBM FILE ACCESS */
+#define CBM_A_RO 1 /* Read only */
+#define CBM_A_WO 2 /* Write only */
+#define CBM_A_RW 3 /* Read, Write */
+
+struct cbm_dirent {
+ char name[17]; /* File name in PetSCII, limited to 16 chars */
+ unsigned int size; /* Size, in 254-/256-byte blocks */
+ unsigned char type;
+ unsigned char access;
+};
+
+
+
+/*****************************************************************************/
+/* Machine info */
+/*****************************************************************************/
+
+
+
+#define TV_NTSC 0
+#define TV_PAL 1
+#define TV_OTHER 2
+
+unsigned char get_tv (void);
+/* Return the video mode the machine is using. */
+
+#define KBREPEAT_CURSOR 0x00
+#define KBREPEAT_NONE 0x40
+#define KBREPEAT_ALL 0x80
+
+unsigned char __fastcall__ kbrepeat (unsigned char mode);
+/* Changes which keys have automatic repeat. */
+
+#if !defined(__CBM610__)
+void waitvsync (void);
+/* Wait for the start of the next video field. */
+#endif
+
+/*****************************************************************************/
+/* CBM kernal functions */
+/*****************************************************************************/
+
+
+
+/* Constants to use with cbm_open() for openning a file for reading or
+** writing without the need to append ",r" or ",w" to the filename.
+**
+** e.g., cbm_open(2, 8, CBM_READ, "0:data,s");
+*/
+#define CBM_READ 0 /* default is ",p" */
+#define CBM_WRITE 1 /* ditto */
+#define CBM_SEQ 2 /* default is ",r" -- or ",s" when writing */
+
+/* Kernal-level functions */
+unsigned char cbm_k_acptr (void);
+unsigned char cbm_k_basin (void);
+void __fastcall__ cbm_k_bsout (unsigned char C);
+unsigned char __fastcall__ cbm_k_chkin (unsigned char FN);
+unsigned char cbm_k_chrin (void);
+void __fastcall__ cbm_k_chrout (unsigned char C);
+void __fastcall__ cbm_k_ciout (unsigned char C);
+unsigned char __fastcall__ cbm_k_ckout (unsigned char FN);
+void cbm_k_clall (void);
+void __fastcall__ cbm_k_close (unsigned char FN);
+void cbm_k_clrch (void);
+unsigned char cbm_k_getin (void);
+unsigned cbm_k_iobase (void);
+void __fastcall__ cbm_k_listen (unsigned char dev);
+unsigned int __fastcall__ cbm_k_load(unsigned char flag, unsigned addr);
+unsigned char cbm_k_open (void);
+unsigned char cbm_k_readst (void);
+unsigned char __fastcall__ cbm_k_save(unsigned int start, unsigned int end);
+void cbm_k_scnkey (void);
+void __fastcall__ cbm_k_second (unsigned char addr);
+void __fastcall__ cbm_k_setlfs (unsigned char LFN, unsigned char DEV,
+ unsigned char SA);
+void __fastcall__ cbm_k_setnam (const char* Name);
+void __fastcall__ cbm_k_settim (unsigned long timer);
+void __fastcall__ cbm_k_talk (unsigned char dev);
+void __fastcall__ cbm_k_tksa (unsigned char addr);
+void cbm_k_udtim (void);
+void cbm_k_unlsn (void);
+void cbm_k_untlk (void);
+
+
+
+/*****************************************************************************/
+/* BASIC-like file I/O functions */
+/*****************************************************************************/
+
+
+
+/* The cbm_* I/O functions below set __oserror (see errno.h),
+** in case of an error.
+**
+** error-code BASIC error
+** ---------- -----------
+** 1 = too many files
+** 2 = file open
+** 3 = file not open
+** 4 = file not found
+** 5 = device not present
+** 6 = not input-file
+** 7 = not output-file
+** 8 = missing file-name
+** 9 = illegal device-number
+**
+** 10 = STOP-key pushed
+** 11 = general I/O-error
+*/
+
+
+
+unsigned int __fastcall__ cbm_load (const char* name, unsigned char device, void* data);
+/* Loads file "name", from given device, to given address -- or, to the load
+** address of the file if "data" is the null pointer (like load"name",8,1
+** in BASIC).
+** Returns number of bytes that were loaded if loading was successful;
+** otherwise 0, "__oserror" contains an error-code, then (see table above).
+*/
+
+unsigned char __fastcall__ cbm_save (const char* name, unsigned char device,
+ const void* addr, unsigned int size);
+/* Saves "size" bytes, starting at "addr", to a file.
+** Returns 0 if saving was successful, otherwise an error-code (see table
+** above).
+*/
+
+unsigned char __fastcall__ cbm_open (unsigned char lfn, unsigned char device,
+ unsigned char sec_addr, const char* name);
+/* Opens a file. Works just like the BASIC command.
+** Returns 0 if openning was successful, otherwise an error-code (see table
+** above).
+*/
+
+void __fastcall__ cbm_close (unsigned char lfn);
+/* Closes a file */
+
+int __fastcall__ cbm_read (unsigned char lfn, void* buffer, unsigned int size);
+/* Reads up to "size" bytes from a file into "buffer".
+** Returns the number of actually-read bytes, 0 if there are no bytes left.
+** -1 in case of an error; then, __oserror contains an error-code (see table
+** above). (Remember: 0 means end-of-file; -1 means error.)
+*/
+
+int __fastcall__ cbm_write (unsigned char lfn, const void* buffer,
+ unsigned int size);
+/* Writes up to "size" bytes from "buffer" to a file.
+** Returns the number of actually-written bytes, or -1 in case of an error;
+** __oserror contains an error-code, then (see above table).
+*/
+
+unsigned char cbm_opendir (unsigned char lfn, unsigned char device, ...);
+/* Opens directory listing. Returns 0 if opening directory was successful;
+** otherwise, an error-code corresponding to cbm_open(). As an optional
+** argument, the name of the directory may be passed to the function. If
+** no explicit name is specified, "$" is used.
+*/
+
+unsigned char __fastcall__ cbm_readdir (unsigned char lfn,
+ struct cbm_dirent* l_dirent);
+/* Reads one directory line into cbm_dirent structure.
+** Returns 0 if reading directory-line was successful.
+** Returns non-zero if reading directory failed, or no more file-names to read.
+** Returns 2 on last line. Then, l_dirent->size = the number of "blocks free",
+** "blocks used", or "mb free". Return codes:
+** 0 = read file-name
+** 1 = couldn't read directory
+** 2 = read "blocks free", "blocks used", or "mb free"
+** 3 = couldn't find start of file-name
+** 4 = couldn't find end of file-name
+** 5 = couldn't read file-type
+** 6 = premature end of file
+*/
+
+void __fastcall__ cbm_closedir (unsigned char lfn);
+/* Closes directory by cbm_close(lfn) */
+
+
+
+/* End of cbm.h */
+#endif
+/*****************************************************************************/
+/* */
+/* cbm264.h */
+/* */
+/* System specific definitions for the C16, C116 and Plus/4 */
+/* */
+/* */
+/* */
+/* (C) 1998-2003 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _CBM264_H
+#define _CBM264_H
+
+
+
+/* Check for errors */
+#if !defined(__C16__)
+# error This module may only be used when compiling for the Plus/4 or C16!
+#endif
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Additional key defines */
+#define CH_F1 133
+#define CH_F2 137
+#define CH_F3 134
+#define CH_F4 138
+#define CH_F5 135
+#define CH_F6 139
+#define CH_F7 136
+#define CH_F8 140
+
+
+
+/* Color attributes */
+#define CATTR_LUMA0 0x00
+#define CATTR_LUMA1 0x10
+#define CATTR_LUMA2 0x20
+#define CATTR_LUMA3 0x30
+#define CATTR_LUMA4 0x40
+#define CATTR_LUMA5 0x50
+#define CATTR_LUMA6 0x60
+#define CATTR_LUMA7 0x70
+#define CATTR_BLINK 0x80
+
+/* Base colors */
+#define BCOLOR_BLACK 0x00
+#define BCOLOR_WHITE 0x01
+#define BCOLOR_RED 0x02
+#define BCOLOR_CYAN 0x03
+#define BCOLOR_PURPLE 0x04
+#define BCOLOR_GREEN 0x05
+#define BCOLOR_BLUE 0x06
+#define BCOLOR_YELLOW 0x07
+#define BCOLOR_ORANGE 0x08
+#define BCOLOR_BROWN 0x09
+#define BCOLOR_LEMON 0x0A /* What's that color? */
+#define BCOLOR_LIGHTVIOLET 0x0B
+#define BCOLOR_BLUEGREEN 0x0C
+#define BCOLOR_LIGHTBLUE 0x0D
+#define BCOLOR_DARKBLUE 0x0E
+#define BCOLOR_LIGHTGREEN 0x0F
+
+/* Now try to mix up a C64/C128 compatible palette */
+#define COLOR_BLACK (BCOLOR_BLACK)
+#define COLOR_WHITE (BCOLOR_WHITE | CATTR_LUMA7)
+#define COLOR_RED (BCOLOR_RED | CATTR_LUMA4)
+#define COLOR_CYAN (BCOLOR_CYAN | CATTR_LUMA7)
+#define COLOR_PURPLE (BCOLOR_VIOLET | CATTR_LUMA7)
+#define COLOR_GREEN (BCOLOR_GREEN | CATTR_LUMA7)
+#define COLOR_BLUE (BCOLOR_BLUE | CATTR_LUMA7)
+#define COLOR_YELLOW (BCOLOR_YELLOW | CATTR_LUMA7)
+#define COLOR_ORANGE (BCOLOR_ORANGE | CATTR_LUMA7)
+#define COLOR_BROWN (BCOLOR_BROWN | CATTR_LUMA7)
+#define COLOR_LIGHTRED (BCOLOR_RED | CATTR_LUMA7)
+#define COLOR_GRAY1 (BCOLOR_WHITE | CATTR_LUMA1)
+#define COLOR_GRAY2 (BCOLOR_WHITE | CATTR_LUMA3)
+#define COLOR_LIGHTGREEN (BCOLOR_LIGHTGREEN | CATTR_LUMA7)
+#define COLOR_LIGHTBLUE (BCOLOR_LIGHTBLUE | CATTR_LUMA7)
+#define COLOR_GRAY3 (BCOLOR_WHITE | CATTR_LUMA5)
+
+
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x01
+#define JOY_DOWN_MASK 0x02
+#define JOY_LEFT_MASK 0x04
+#define JOY_RIGHT_MASK 0x08
+#define JOY_BTN_1_MASK 0x80
+
+
+
+/* Define hardware */
+#include <_ted.h>
+#define TED (*(struct __ted*)0xFF00)
+
+/* Define special memory areas */
+#define COLOR_RAM ((unsigned char*)0x0800)
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+void fast (void);
+/* Switch the CPU into double-clock mode. */
+
+void slow (void);
+/* Switch the CPU into single-clock mode. */
+
+unsigned char isfast (void);
+/* Returns 1 if the CPU is in double-clock mode. */
+
+
+
+/* End of cbm264.h */
+#endif
+/*****************************************************************************/
+/* */
+/* cbm510.h */
+/* */
+/* System-specific definitions for the CBM5x0 / P500 */
+/* */
+/* */
+/* */
+/* (C) 2001-2013, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _CBM510_H
+#define _CBM510_H
+
+
+
+/* Check for errors */
+#if !defined(__CBM510__)
+# error This module may only be used when compiling for the CBM 510!
+#endif
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Additional key defines */
+#define CH_F1 224
+#define CH_F2 225
+#define CH_F3 226
+#define CH_F4 227
+#define CH_F5 228
+#define CH_F6 229
+#define CH_F7 230
+#define CH_F8 231
+#define CH_F9 232
+#define CH_F10 233
+#define CH_F11 234
+#define CH_F12 235
+#define CH_F13 236
+#define CH_F14 237
+#define CH_F15 238
+#define CH_F16 239
+#define CH_F17 240
+#define CH_F18 241
+#define CH_F19 242
+#define CH_F20 243
+
+/* Color defines */
+#define COLOR_BLACK 0x00
+#define COLOR_WHITE 0x01
+#define COLOR_RED 0x02
+#define COLOR_CYAN 0x03
+#define COLOR_PURPLE 0x04
+#define COLOR_GREEN 0x05
+#define COLOR_BLUE 0x06
+#define COLOR_YELLOW 0x07
+#define COLOR_ORANGE 0x08
+#define COLOR_BROWN 0x09
+#define COLOR_LIGHTRED 0x0A
+#define COLOR_GRAY1 0x0B
+#define COLOR_GRAY2 0x0C
+#define COLOR_LIGHTGREEN 0x0D
+#define COLOR_LIGHTBLUE 0x0E
+#define COLOR_GRAY3 0x0F
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x01
+#define JOY_DOWN_MASK 0x02
+#define JOY_LEFT_MASK 0x04
+#define JOY_RIGHT_MASK 0x08
+#define JOY_BTN_1_MASK 0x10
+
+/* Define hardware */
+#include <_vic2.h>
+#define VIC (*(struct __vic2*)0xD800)
+
+#include <_sid.h>
+#define SID (*(struct __sid*)0xDA00)
+
+#include <_6526.h>
+#define CIA2 (*(struct __6526*)0xDC00)
+
+#include <_6551.h>
+#define ACIA (*(struct __6551*)0xDD00)
+
+#include <_6525.h>
+#define TPI1 (*(struct __6525*)0xDE00)
+#define TPI2 (*(struct __6525*)0xDF00)
+
+
+
+/*****************************************************************************/
+/* Variables */
+/*****************************************************************************/
+
+
+
+/* The addresses of the static drivers */
+extern void cbm510_inkwl_mou[];
+extern void cbm510_joy_mou[]; /* Referred to by mouse_static_stddrv[] */
+extern void cbm510_ram_emd[];
+extern void cbm510_std_joy[]; /* Referred to by joy_static_stddrv[] */
+extern void cbm510_std_ser[]; /* Referred to by ser_static_stddrv[] */
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+/* Special routines to read/write bytes and words in the system bank */
+unsigned char __fastcall__ peekbsys (unsigned addr);
+unsigned __fastcall__ peekwsys (unsigned addr);
+void __fastcall__ pokebsys (unsigned addr, unsigned char val);
+void __fastcall__ pokewsys (unsigned addr, unsigned val);
+
+#if defined(__OPT_i__) && (__OPT_i__ >= 600)
+#define peekbsys(addr) \
+ __AX__ = (addr), \
+ __asm__ ("sta ptr1"), \
+ __asm__ ("stx ptr1+1"), \
+ __asm__ ("ldx $01"), \
+ __asm__ ("lda #$0F"), \
+ __asm__ ("sta $01"), \
+ __asm__ ("ldy #$00"), \
+ __asm__ ("lda (ptr1),y"), \
+ __asm__ ("stx $01"), \
+ __asm__ ("ldx #$00"), \
+ __AX__
+#endif
+
+
+
+/* End of cbm510.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* cbm610.h */
+/* */
+/* CBM610 system specific definitions */
+/* */
+/* */
+/* */
+/* (C) 1998-2009, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _CBM610_H
+#define _CBM610_H
+
+
+
+/* Check for errors */
+#if !defined(__CBM610__)
+# error This module may only be used when compiling for the CBM 610!
+#endif
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Additional key defines */
+#define CH_F1 224
+#define CH_F2 225
+#define CH_F3 226
+#define CH_F4 227
+#define CH_F5 228
+#define CH_F6 229
+#define CH_F7 230
+#define CH_F8 231
+#define CH_F9 232
+#define CH_F10 233
+#define CH_F11 234
+#define CH_F12 235
+#define CH_F13 236
+#define CH_F14 237
+#define CH_F15 238
+#define CH_F16 239
+#define CH_F17 240
+#define CH_F18 241
+#define CH_F19 242
+#define CH_F20 243
+
+/* Color defines */
+#define COLOR_BLACK 0x00
+#define COLOR_WHITE 0x01
+
+/* Define hardware */
+#include <_6545.h>
+#define CRTC (*(struct __6545)0xD800)
+
+#include <_sid.h>
+#define SID (*(struct __sid*)0xDA00)
+
+#include <_6526.h>
+#define CIA1 (*(struct __6526*)0xDB00)
+#define CIA2 (*(struct __6526*)0xDC00)
+
+#include <_6551.h>
+#define ACIA (*(struct __6551*)0xDD00)
+
+#include <_6525.h>
+#define TPI1 (*(struct __6525*)0xDE00)
+#define TPI2 (*(struct __6525*)0xDF00)
+
+
+
+/*****************************************************************************/
+/* Variables */
+/*****************************************************************************/
+
+
+
+/* The addresses of the static drivers */
+extern void cbm610_ram_emd[];
+extern void cbm610_std_ser[]; /* Referred to by ser_static_stddrv[] */
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+/* Special routines to read/write bytes and words in the system bank */
+unsigned char __fastcall__ peekbsys (unsigned addr);
+unsigned __fastcall__ peekwsys (unsigned addr);
+void __fastcall__ pokebsys (unsigned addr, unsigned char val);
+void __fastcall__ pokewsys (unsigned addr, unsigned val);
+
+#if defined(__OPT_i__) && (__OPT_i__ >= 600)
+#define peekbsys(addr) \
+ __AX__ = (addr), \
+ __asm__ ("sta ptr1"), \
+ __asm__ ("stx ptr1+1"), \
+ __asm__ ("ldx $01"), \
+ __asm__ ("lda #$0F"), \
+ __asm__ ("sta $01"), \
+ __asm__ ("ldy #$00"), \
+ __asm__ ("lda (ptr1),y"), \
+ __asm__ ("stx $01"), \
+ __asm__ ("ldx #$00"), \
+ __AX__
+#endif
+
+
+
+/* The following #defines will cause the matching functions calls in conio.h
+** to be overlaid by macros with the same names, saving the function call
+** overhead.
+*/
+#define _textcolor(color) COLOR_WHITE
+#define _bgcolor(color) COLOR_BLACK
+#define _bordercolor(color) COLOR_BLACK
+#define _cpeekcolor(color) COLOR_WHITE
+
+
+
+/* End of cbm610.h */
+#endif
+/*****************************************************************************/
+/* */
+/* cbm_filetype.h */
+/* */
+/* Definitions for CBM file types */
+/* */
+/* */
+/* */
+/* (C) 2012, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _CBM_FILETYPE_H
+#define _CBM_FILETYPE_H
+
+
+
+/* Check for errors */
+#if !defined(__CBM__)
+# error This module may be used only when compiling for CBM machines!
+#endif
+
+
+
+/*****************************************************************************/
+/* Definitions */
+/*****************************************************************************/
+
+
+
+/* CBM FILE TYPES. The definitions are used within standard headers, so we
+** be careful with identifiers in the user name space.
+** "Regular" files have a special bit set so it's easier to pick them out.
+*/
+#define _CBM_T_REG 0x10U /* Bit set for regular files */
+#define _CBM_T_SEQ 0x10U
+#define _CBM_T_PRG 0x11U
+#define _CBM_T_USR 0x12U
+#define _CBM_T_REL 0x13U
+#define _CBM_T_VRP 0x14U /* Vorpal fast-loadable format */
+#define _CBM_T_DEL 0x00U
+#define _CBM_T_CBM 0x01U /* 1581 sub-partition */
+#define _CBM_T_DIR 0x02U /* IDE64 and CMD sub-directory */
+#define _CBM_T_LNK 0x03U /* IDE64 soft-link */
+#define _CBM_T_OTHER 0x04U /* File-type not recognized */
+#define _CBM_T_HEADER 0x05U /* Disk header / title */
+
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* Allow for names without leading underscores */
+#define CBM_T_DEL _CBM_T_DEL
+#define CBM_T_SEQ _CBM_T_SEQ
+#define CBM_T_PRG _CBM_T_PRG
+#define CBM_T_USR _CBM_T_USR
+#define CBM_T_REL _CBM_T_REL
+#define CBM_T_CBM _CBM_T_CBM
+#define CBM_T_DIR _CBM_T_DIR
+#define CBM_T_LNK _CBM_T_LNK
+#define CBM_T_VRP _CBM_T_VRP
+#define CBM_T_OTHER _CBM_T_OTHER
+#define CBM_T_HEADER _CBM_T_HEADER
+#endif
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+unsigned char __fastcall__ _cbm_filetype (unsigned char c);
+/* Map the start character for a file type to one of the file types above.
+** Note: 'd' will always mapped to CBM_T_DEL. The calling function has to
+** look at the following character to determine if the file type is actually
+** CBM_T_DIR.
+** This is a function used by the implementation. There is usually no need
+** to call it from user code.
+*/
+
+
+
+/* End of cbm_filetype.h */
+#endif
+
+
+/*****************************************************************************/
+/* */
+/* cbm_petscii_charmap.h */
+/* */
+/* CBM system standard string mapping (ISO-8859-1 -> PetSCII) */
+/* */
+/* */
+/* 2019-03-10, Greg King */
+/* */
+/* This software is provided "as-is", without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated, but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice must not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+/* No include guard here! Multiple use in one file might be intentional. */
+
+#pragma warn (remap-zero, push, off)
+
+#pragma charmap (0x00, 0x00)
+#pragma charmap (0x01, 0x01)
+#pragma charmap (0x02, 0x02)
+#pragma charmap (0x03, 0x03)
+#pragma charmap (0x04, 0x04)
+#pragma charmap (0x05, 0x05)
+#pragma charmap (0x06, 0x06)
+#pragma charmap (0x07, 0x07)
+#pragma charmap (0x08, 0x14)
+#pragma charmap (0x09, 0x09)
+#pragma charmap (0x0A, 0x0D)
+#pragma charmap (0x0B, 0x11)
+#pragma charmap (0x0C, 0x93)
+#pragma charmap (0x0D, 0x0A)
+#pragma charmap (0x0E, 0x0E)
+#pragma charmap (0x0F, 0x0F)
+#pragma charmap (0x10, 0x10)
+#pragma charmap (0x11, 0x0B)
+#pragma charmap (0x12, 0x12)
+#pragma charmap (0x13, 0x13)
+#pragma charmap (0x14, 0x08)
+#pragma charmap (0x15, 0x15)
+#pragma charmap (0x16, 0x16)
+#pragma charmap (0x17, 0x17)
+#pragma charmap (0x18, 0x18)
+#pragma charmap (0x19, 0x19)
+#pragma charmap (0x1A, 0x1A)
+#pragma charmap (0x1B, 0x1B)
+#pragma charmap (0x1C, 0x1C)
+#pragma charmap (0x1D, 0x1D)
+#pragma charmap (0x1E, 0x1E)
+#pragma charmap (0x1F, 0x1F)
+
+#pragma charmap (0x20, 0x20)
+#pragma charmap (0x21, 0x21)
+#pragma charmap (0x22, 0x22)
+#pragma charmap (0x23, 0x23)
+#pragma charmap (0x24, 0x24)
+#pragma charmap (0x25, 0x25)
+#pragma charmap (0x26, 0x26)
+#pragma charmap (0x27, 0x27)
+#pragma charmap (0x28, 0x28)
+#pragma charmap (0x29, 0x29)
+#pragma charmap (0x2A, 0x2A)
+#pragma charmap (0x2B, 0x2B)
+#pragma charmap (0x2C, 0x2C)
+#pragma charmap (0x2D, 0x2D)
+#pragma charmap (0x2E, 0x2E)
+#pragma charmap (0x2F, 0x2F)
+#pragma charmap (0x30, 0x30)
+#pragma charmap (0x31, 0x31)
+#pragma charmap (0x32, 0x32)
+#pragma charmap (0x33, 0x33)
+#pragma charmap (0x34, 0x34)
+#pragma charmap (0x35, 0x35)
+#pragma charmap (0x36, 0x36)
+#pragma charmap (0x37, 0x37)
+#pragma charmap (0x38, 0x38)
+#pragma charmap (0x39, 0x39)
+#pragma charmap (0x3A, 0x3A)
+#pragma charmap (0x3B, 0x3B)
+#pragma charmap (0x3C, 0x3C)
+#pragma charmap (0x3D, 0x3D)
+#pragma charmap (0x3E, 0x3E)
+#pragma charmap (0x3F, 0x3F)
+
+#pragma charmap (0x40, 0x40)
+#pragma charmap (0x41, 0xC1)
+#pragma charmap (0x42, 0xC2)
+#pragma charmap (0x43, 0xC3)
+#pragma charmap (0x44, 0xC4)
+#pragma charmap (0x45, 0xC5)
+#pragma charmap (0x46, 0xC6)
+#pragma charmap (0x47, 0xC7)
+#pragma charmap (0x48, 0xC8)
+#pragma charmap (0x49, 0xC9)
+#pragma charmap (0x4A, 0xCA)
+#pragma charmap (0x4B, 0xCB)
+#pragma charmap (0x4C, 0xCC)
+#pragma charmap (0x4D, 0xCD)
+#pragma charmap (0x4E, 0xCE)
+#pragma charmap (0x4F, 0xCF)
+#pragma charmap (0x50, 0xD0)
+#pragma charmap (0x51, 0xD1)
+#pragma charmap (0x52, 0xD2)
+#pragma charmap (0x53, 0xD3)
+#pragma charmap (0x54, 0xD4)
+#pragma charmap (0x55, 0xD5)
+#pragma charmap (0x56, 0xD6)
+#pragma charmap (0x57, 0xD7)
+#pragma charmap (0x58, 0xD8)
+#pragma charmap (0x59, 0xD9)
+#pragma charmap (0x5A, 0xDA)
+#pragma charmap (0x5B, 0x5B)
+#pragma charmap (0x5C, 0xBF)
+#pragma charmap (0x5D, 0x5D)
+#pragma charmap (0x5E, 0x5E)
+#pragma charmap (0x5F, 0xA4)
+
+#pragma charmap (0x60, 0xAD)
+#pragma charmap (0x61, 0x41)
+#pragma charmap (0x62, 0x42)
+#pragma charmap (0x63, 0x43)
+#pragma charmap (0x64, 0x44)
+#pragma charmap (0x65, 0x45)
+#pragma charmap (0x66, 0x46)
+#pragma charmap (0x67, 0x47)
+#pragma charmap (0x68, 0x48)
+#pragma charmap (0x69, 0x49)
+#pragma charmap (0x6A, 0x4A)
+#pragma charmap (0x6B, 0x4B)
+#pragma charmap (0x6C, 0x4C)
+#pragma charmap (0x6D, 0x4D)
+#pragma charmap (0x6E, 0x4E)
+#pragma charmap (0x6F, 0x4F)
+#pragma charmap (0x70, 0x50)
+#pragma charmap (0x71, 0x51)
+#pragma charmap (0x72, 0x52)
+#pragma charmap (0x73, 0x53)
+#pragma charmap (0x74, 0x54)
+#pragma charmap (0x75, 0x55)
+#pragma charmap (0x76, 0x56)
+#pragma charmap (0x77, 0x57)
+#pragma charmap (0x78, 0x58)
+#pragma charmap (0x79, 0x59)
+#pragma charmap (0x7A, 0x5A)
+#pragma charmap (0x7B, 0xB3)
+#pragma charmap (0x7C, 0xDD)
+#pragma charmap (0x7D, 0xAB)
+#pragma charmap (0x7E, 0xB1)
+#pragma charmap (0x7F, 0xDF)
+
+#pragma charmap (0x80, 0x80)
+#pragma charmap (0x81, 0x81)
+#pragma charmap (0x82, 0x82)
+#pragma charmap (0x83, 0x83)
+#pragma charmap (0x84, 0x84)
+#pragma charmap (0x85, 0x85)
+#pragma charmap (0x86, 0x86)
+#pragma charmap (0x87, 0x87)
+#pragma charmap (0x88, 0x88)
+#pragma charmap (0x89, 0x89)
+#pragma charmap (0x8A, 0x8A)
+#pragma charmap (0x8B, 0x8B)
+#pragma charmap (0x8C, 0x8C)
+#pragma charmap (0x8D, 0x8D)
+#pragma charmap (0x8E, 0x8E)
+#pragma charmap (0x8F, 0x8F)
+#pragma charmap (0x90, 0x90)
+#pragma charmap (0x91, 0x91)
+#pragma charmap (0x92, 0x92)
+#pragma charmap (0x93, 0x0C)
+#pragma charmap (0x94, 0x94)
+#pragma charmap (0x95, 0x95)
+#pragma charmap (0x96, 0x96)
+#pragma charmap (0x97, 0x97)
+#pragma charmap (0x98, 0x98)
+#pragma charmap (0x99, 0x99)
+#pragma charmap (0x9A, 0x9A)
+#pragma charmap (0x9B, 0x9B)
+#pragma charmap (0x9C, 0x9C)
+#pragma charmap (0x9D, 0x9D)
+#pragma charmap (0x9E, 0x9E)
+#pragma charmap (0x9F, 0x9F)
+
+#pragma charmap (0xA0, 0xA0)
+#pragma charmap (0xA1, 0xA1)
+#pragma charmap (0xA2, 0xA2)
+#pragma charmap (0xA3, 0xA3)
+#pragma charmap (0xA4, 0xA4)
+#pragma charmap (0xA5, 0xA5)
+#pragma charmap (0xA6, 0xA6)
+#pragma charmap (0xA7, 0xA7)
+#pragma charmap (0xA8, 0xA8)
+#pragma charmap (0xA9, 0xA9)
+#pragma charmap (0xAA, 0xAA)
+#pragma charmap (0xAB, 0xAB)
+#pragma charmap (0xAC, 0xAC)
+#pragma charmap (0xAD, 0xAD)
+#pragma charmap (0xAE, 0xAE)
+#pragma charmap (0xAF, 0xAF)
+#pragma charmap (0xB0, 0xB0)
+#pragma charmap (0xB1, 0xB1)
+#pragma charmap (0xB2, 0xB2)
+#pragma charmap (0xB3, 0xB3)
+#pragma charmap (0xB4, 0xB4)
+#pragma charmap (0xB5, 0xB5)
+#pragma charmap (0xB6, 0xB6)
+#pragma charmap (0xB7, 0xB7)
+#pragma charmap (0xB8, 0xB8)
+#pragma charmap (0xB9, 0xB9)
+#pragma charmap (0xBA, 0xBA)
+#pragma charmap (0xBB, 0xBB)
+#pragma charmap (0xBC, 0xBC)
+#pragma charmap (0xBD, 0xBD)
+#pragma charmap (0xBE, 0xBE)
+#pragma charmap (0xBF, 0xBF)
+
+#pragma charmap (0xC0, 0x60)
+#pragma charmap (0xC1, 0x61)
+#pragma charmap (0xC2, 0x62)
+#pragma charmap (0xC3, 0x63)
+#pragma charmap (0xC4, 0x64)
+#pragma charmap (0xC5, 0x65)
+#pragma charmap (0xC6, 0x66)
+#pragma charmap (0xC7, 0x67)
+#pragma charmap (0xC8, 0x68)
+#pragma charmap (0xC9, 0x69)
+#pragma charmap (0xCA, 0x6A)
+#pragma charmap (0xCB, 0x6B)
+#pragma charmap (0xCC, 0x6C)
+#pragma charmap (0xCD, 0x6D)
+#pragma charmap (0xCE, 0x6E)
+#pragma charmap (0xCF, 0x6F)
+#pragma charmap (0xD0, 0x70)
+#pragma charmap (0xD1, 0x71)
+#pragma charmap (0xD2, 0x72)
+#pragma charmap (0xD3, 0x73)
+#pragma charmap (0xD4, 0x74)
+#pragma charmap (0xD5, 0x75)
+#pragma charmap (0xD6, 0x76)
+#pragma charmap (0xD7, 0x77)
+#pragma charmap (0xD8, 0x78)
+#pragma charmap (0xD9, 0x79)
+#pragma charmap (0xDA, 0x7A)
+#pragma charmap (0xDB, 0x7B)
+#pragma charmap (0xDC, 0x7C)
+#pragma charmap (0xDD, 0x7D)
+#pragma charmap (0xDE, 0x7E)
+#pragma charmap (0xDF, 0x7F)
+
+#pragma charmap (0xE0, 0xE0)
+#pragma charmap (0xE1, 0xE1)
+#pragma charmap (0xE2, 0xE2)
+#pragma charmap (0xE3, 0xE3)
+#pragma charmap (0xE4, 0xE4)
+#pragma charmap (0xE5, 0xE5)
+#pragma charmap (0xE6, 0xE6)
+#pragma charmap (0xE7, 0xE7)
+#pragma charmap (0xE8, 0xE8)
+#pragma charmap (0xE9, 0xE9)
+#pragma charmap (0xEA, 0xEA)
+#pragma charmap (0xEB, 0xEB)
+#pragma charmap (0xEC, 0xEC)
+#pragma charmap (0xED, 0xED)
+#pragma charmap (0xEE, 0xEE)
+#pragma charmap (0xEF, 0xEF)
+#pragma charmap (0xF0, 0xF0)
+#pragma charmap (0xF1, 0xF1)
+#pragma charmap (0xF2, 0xF2)
+#pragma charmap (0xF3, 0xF3)
+#pragma charmap (0xF4, 0xF4)
+#pragma charmap (0xF5, 0xF5)
+#pragma charmap (0xF6, 0xF6)
+#pragma charmap (0xF7, 0xF7)
+#pragma charmap (0xF8, 0xF8)
+#pragma charmap (0xF9, 0xF9)
+#pragma charmap (0xFA, 0xFA)
+#pragma charmap (0xFB, 0xFB)
+#pragma charmap (0xFC, 0xFC)
+#pragma charmap (0xFD, 0xFD)
+#pragma charmap (0xFE, 0xFE)
+#pragma charmap (0xFF, 0xFF)
+
+#pragma warn (remap-zero, pop)
+/*****************************************************************************/
+/* */
+/* cbm_screen_charmap.h */
+/* */
+/* (c) Copyright 2019, Gerhard W. Gruber (sparhawk@gmx.at) */
+/* */
+/* When using CBM mode, this include converts character literals */
+/* from ASCII to screen-code mapping, so you can write directly */
+/* to the screen memory. */
+/* */
+/* If this include is used, no additional macros are needed. */
+/* */
+/*****************************************************************************/
+
+/* No include guard here! Multiple use in one file may be intentional. */
+
+#pragma warn (remap-zero, push, off)
+
+// Char $00 -> c + 128
+#pragma charmap (0x00, 0x80)
+
+// Char $01 ... $1A -> c + 128 + 64 (control alphabet)
+#pragma charmap (0x01, 0xC1)
+#pragma charmap (0x02, 0xC2)
+#pragma charmap (0x03, 0xC3)
+#pragma charmap (0x04, 0xC4)
+#pragma charmap (0x05, 0xC5)
+#pragma charmap (0x06, 0xC6)
+#pragma charmap (0x07, 0xC7)
+#pragma charmap (0x08, 0xC8)
+#pragma charmap (0x09, 0xC9)
+#pragma charmap (0x0A, 0xCA)
+#pragma charmap (0x0B, 0xCB)
+#pragma charmap (0x0C, 0xCC)
+#pragma charmap (0x0D, 0xCD)
+#pragma charmap (0x0E, 0xCE)
+#pragma charmap (0x0F, 0xCF)
+#pragma charmap (0x10, 0xD0)
+#pragma charmap (0x11, 0xD1)
+#pragma charmap (0x12, 0xD2)
+#pragma charmap (0x13, 0xD3)
+#pragma charmap (0x14, 0xD4)
+#pragma charmap (0x15, 0xD5)
+#pragma charmap (0x16, 0xD6)
+#pragma charmap (0x17, 0xD7)
+#pragma charmap (0x18, 0xD8)
+#pragma charmap (0x19, 0xD9)
+#pragma charmap (0x1A, 0xDA)
+
+// Char $1B ... $1F -> c + 128
+#pragma charmap (0x1B, 0x9B)
+#pragma charmap (0x1C, 0x9C)
+#pragma charmap (0x1D, 0x9D)
+#pragma charmap (0x1E, 0x9E)
+#pragma charmap (0x1F, 0x9F)
+
+// Char $20 ... $3F -> c
+#pragma charmap (0x20, 0x20)
+#pragma charmap (0x21, 0x21)
+#pragma charmap (0x22, 0x22)
+#pragma charmap (0x23, 0x23)
+#pragma charmap (0x24, 0x24)
+#pragma charmap (0x25, 0x25)
+#pragma charmap (0x26, 0x26)
+#pragma charmap (0x27, 0x27)
+#pragma charmap (0x28, 0x28)
+#pragma charmap (0x29, 0x29)
+#pragma charmap (0x2A, 0x2A)
+#pragma charmap (0x2B, 0x2B)
+#pragma charmap (0x2C, 0x2C)
+#pragma charmap (0x2D, 0x2D)
+#pragma charmap (0x2E, 0x2E)
+#pragma charmap (0x2F, 0x2F)
+#pragma charmap (0x30, 0x30)
+#pragma charmap (0x31, 0x31)
+#pragma charmap (0x32, 0x32)
+#pragma charmap (0x33, 0x33)
+#pragma charmap (0x34, 0x34)
+#pragma charmap (0x35, 0x35)
+#pragma charmap (0x36, 0x36)
+#pragma charmap (0x37, 0x37)
+#pragma charmap (0x38, 0x38)
+#pragma charmap (0x39, 0x39)
+#pragma charmap (0x3A, 0x3A)
+#pragma charmap (0x3B, 0x3B)
+#pragma charmap (0x3C, 0x3C)
+#pragma charmap (0x3D, 0x3D)
+#pragma charmap (0x3E, 0x3E)
+#pragma charmap (0x3F, 0x3F)
+
+// Char $40 -> c - 64
+#pragma charmap (0x40, 0x00)
+
+// Char $41 ... $5A -> c (upper-case alphabet)
+#pragma charmap (0x41, 0x41)
+#pragma charmap (0x42, 0x42)
+#pragma charmap (0x43, 0x43)
+#pragma charmap (0x44, 0x44)
+#pragma charmap (0x45, 0x45)
+#pragma charmap (0x46, 0x46)
+#pragma charmap (0x47, 0x47)
+#pragma charmap (0x48, 0x48)
+#pragma charmap (0x49, 0x49)
+#pragma charmap (0x4A, 0x4A)
+#pragma charmap (0x4B, 0x4B)
+#pragma charmap (0x4C, 0x4C)
+#pragma charmap (0x4D, 0x4D)
+#pragma charmap (0x4E, 0x4E)
+#pragma charmap (0x4F, 0x4F)
+#pragma charmap (0x50, 0x50)
+#pragma charmap (0x51, 0x51)
+#pragma charmap (0x52, 0x52)
+#pragma charmap (0x53, 0x53)
+#pragma charmap (0x54, 0x54)
+#pragma charmap (0x55, 0x55)
+#pragma charmap (0x56, 0x56)
+#pragma charmap (0x57, 0x57)
+#pragma charmap (0x58, 0x58)
+#pragma charmap (0x59, 0x59)
+#pragma charmap (0x5A, 0x5A)
+
+// Char $5B ... $5F -> c - 64
+#pragma charmap (0x5B, 0x1B)
+#pragma charmap (0x5C, 0x1C)
+#pragma charmap (0x5D, 0x1D)
+#pragma charmap (0x5E, 0x1E)
+#pragma charmap (0x5F, 0x1F)
+
+// Char $60 -> c - 32
+#pragma charmap (0x60, 0x40)
+
+// Char $61 ... $7A -> c - 32 - 64 (lower-case alphabet)
+#pragma charmap (0x61, 0x01)
+#pragma charmap (0x62, 0x02)
+#pragma charmap (0x63, 0x03)
+#pragma charmap (0x64, 0x04)
+#pragma charmap (0x65, 0x05)
+#pragma charmap (0x66, 0x06)
+#pragma charmap (0x67, 0x07)
+#pragma charmap (0x68, 0x08)
+#pragma charmap (0x69, 0x09)
+#pragma charmap (0x6A, 0x0A)
+#pragma charmap (0x6B, 0x0B)
+#pragma charmap (0x6C, 0x0C)
+#pragma charmap (0x6D, 0x0D)
+#pragma charmap (0x6E, 0x0E)
+#pragma charmap (0x6F, 0x0F)
+#pragma charmap (0x70, 0x10)
+#pragma charmap (0x71, 0x11)
+#pragma charmap (0x72, 0x12)
+#pragma charmap (0x73, 0x13)
+#pragma charmap (0x74, 0x14)
+#pragma charmap (0x75, 0x15)
+#pragma charmap (0x76, 0x16)
+#pragma charmap (0x77, 0x17)
+#pragma charmap (0x78, 0x18)
+#pragma charmap (0x79, 0x19)
+#pragma charmap (0x7A, 0x1A)
+
+// Char $7B ... $7F -> c - 32
+#pragma charmap (0x7B, 0x5B)
+#pragma charmap (0x7C, 0x5C)
+#pragma charmap (0x7D, 0x5D)
+#pragma charmap (0x7E, 0x5E)
+#pragma charmap (0x7F, 0x5F)
+
+// Char $80 -> c + 64
+#pragma charmap (0x80, 0xC0)
+
+// Char $81 ... $9A -> c (control alphabet)
+#pragma charmap (0x81, 0x81)
+#pragma charmap (0x82, 0x82)
+#pragma charmap (0x83, 0x83)
+#pragma charmap (0x84, 0x84)
+#pragma charmap (0x85, 0x85)
+#pragma charmap (0x86, 0x86)
+#pragma charmap (0x87, 0x87)
+#pragma charmap (0x88, 0x88)
+#pragma charmap (0x89, 0x89)
+#pragma charmap (0x8A, 0x8A)
+#pragma charmap (0x8B, 0x8B)
+#pragma charmap (0x8C, 0x8C)
+#pragma charmap (0x8D, 0x8D)
+#pragma charmap (0x8E, 0x8E)
+#pragma charmap (0x8F, 0x8F)
+#pragma charmap (0x90, 0x90)
+#pragma charmap (0x91, 0x91)
+#pragma charmap (0x92, 0x92)
+#pragma charmap (0x93, 0x93)
+#pragma charmap (0x94, 0x94)
+#pragma charmap (0x95, 0x95)
+#pragma charmap (0x96, 0x96)
+#pragma charmap (0x97, 0x97)
+#pragma charmap (0x98, 0x98)
+#pragma charmap (0x99, 0x99)
+#pragma charmap (0x9A, 0x9A)
+
+// Char $9B ... $9F -> c + 64
+#pragma charmap (0x9B, 0xDB)
+#pragma charmap (0x9C, 0xDC)
+#pragma charmap (0x9D, 0xDD)
+#pragma charmap (0x9E, 0xDE)
+#pragma charmap (0x9F, 0xDF)
+
+// Char $A0 ... $BF -> c - 64
+#pragma charmap (0xA0, 0x60)
+#pragma charmap (0xA1, 0x61)
+#pragma charmap (0xA2, 0x62)
+#pragma charmap (0xA3, 0x63)
+#pragma charmap (0xA4, 0x64)
+#pragma charmap (0xA5, 0x65)
+#pragma charmap (0xA6, 0x66)
+#pragma charmap (0xA7, 0x67)
+#pragma charmap (0xA8, 0x68)
+#pragma charmap (0xA9, 0x69)
+#pragma charmap (0xAA, 0x6A)
+#pragma charmap (0xAB, 0x6B)
+#pragma charmap (0xAC, 0x6C)
+#pragma charmap (0xAD, 0x6D)
+#pragma charmap (0xAE, 0x6E)
+#pragma charmap (0xAF, 0x6F)
+#pragma charmap (0xB0, 0x70)
+#pragma charmap (0xB1, 0x71)
+#pragma charmap (0xB2, 0x72)
+#pragma charmap (0xB3, 0x73)
+#pragma charmap (0xB4, 0x74)
+#pragma charmap (0xB5, 0x75)
+#pragma charmap (0xB6, 0x76)
+#pragma charmap (0xB7, 0x77)
+#pragma charmap (0xB8, 0x78)
+#pragma charmap (0xB9, 0x79)
+#pragma charmap (0xBA, 0x7A)
+#pragma charmap (0xBB, 0x7B)
+#pragma charmap (0xBC, 0x7C)
+#pragma charmap (0xBD, 0x7D)
+#pragma charmap (0xBE, 0x7E)
+#pragma charmap (0xBF, 0x7F)
+
+// Char $C0 ... $DF -> c - 128
+#pragma charmap (0xC0, 0x40)
+
+// Char $C1 ... $DA -> c - 128 - 64 (lower-case alphabet)
+#pragma charmap (0xC1, 0x01)
+#pragma charmap (0xC2, 0x02)
+#pragma charmap (0xC3, 0x03)
+#pragma charmap (0xC4, 0x04)
+#pragma charmap (0xC5, 0x05)
+#pragma charmap (0xC6, 0x06)
+#pragma charmap (0xC7, 0x07)
+#pragma charmap (0xC8, 0x08)
+#pragma charmap (0xC9, 0x09)
+#pragma charmap (0xCA, 0x0A)
+#pragma charmap (0xCB, 0x0B)
+#pragma charmap (0xCC, 0x0C)
+#pragma charmap (0xCD, 0x0D)
+#pragma charmap (0xCE, 0x0E)
+#pragma charmap (0xCF, 0x0F)
+#pragma charmap (0xD0, 0x10)
+#pragma charmap (0xD1, 0x11)
+#pragma charmap (0xD2, 0x12)
+#pragma charmap (0xD3, 0x13)
+#pragma charmap (0xD4, 0x14)
+#pragma charmap (0xD5, 0x15)
+#pragma charmap (0xD6, 0x16)
+#pragma charmap (0xD7, 0x17)
+#pragma charmap (0xD8, 0x18)
+#pragma charmap (0xD9, 0x19)
+#pragma charmap (0xDA, 0x1A)
+
+// Char $DB ... $DF -> c - 128
+#pragma charmap (0xDB, 0x5B)
+#pragma charmap (0xDC, 0x5C)
+#pragma charmap (0xDD, 0x5D)
+#pragma charmap (0xDE, 0x5E)
+#pragma charmap (0xDF, 0x5F)
+
+// Char $E0 ... $FF -> c - 128
+#pragma charmap (0xE0, 0x60)
+#pragma charmap (0xE1, 0x61)
+#pragma charmap (0xE2, 0x62)
+#pragma charmap (0xE3, 0x63)
+#pragma charmap (0xE4, 0x64)
+#pragma charmap (0xE5, 0x65)
+#pragma charmap (0xE6, 0x66)
+#pragma charmap (0xE7, 0x67)
+#pragma charmap (0xE8, 0x68)
+#pragma charmap (0xE9, 0x69)
+#pragma charmap (0xEA, 0x6A)
+#pragma charmap (0xEB, 0x6B)
+#pragma charmap (0xEC, 0x6C)
+#pragma charmap (0xED, 0x6D)
+#pragma charmap (0xEE, 0x6E)
+#pragma charmap (0xEF, 0x6F)
+#pragma charmap (0xF0, 0x70)
+#pragma charmap (0xF1, 0x71)
+#pragma charmap (0xF2, 0x72)
+#pragma charmap (0xF3, 0x73)
+#pragma charmap (0xF4, 0x74)
+#pragma charmap (0xF5, 0x75)
+#pragma charmap (0xF6, 0x76)
+#pragma charmap (0xF7, 0x77)
+#pragma charmap (0xF8, 0x78)
+#pragma charmap (0xF9, 0x79)
+#pragma charmap (0xFA, 0x7A)
+#pragma charmap (0xFB, 0x7B)
+#pragma charmap (0xFC, 0x7C)
+#pragma charmap (0xFD, 0x7D)
+#pragma charmap (0xFE, 0x7E)
+#pragma charmap (0xFF, 0x7F)
+
+#pragma warn (remap-zero, pop)
+/*****************************************************************************/
+/* */
+/* cc65.h */
+/* */
+/* Target independent but cc65 specific utility functions */
+/* */
+/* */
+/* */
+/* (C) 2009-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _CC65_H
+#define _CC65_H
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+long __fastcall__ idiv32by16r16 (long rhs, int lhs);
+/* Divide a 32 bit signed value by a 16 bit signed value yielding a 16
+** bit result and a 16 bit remainder. The former is returned in the lower 16
+** bit of the result, the latter in the upper. If you don't need the
+** remainder, just assign (or cast) to an int.
+*/
+
+unsigned long __fastcall__ udiv32by16r16 (unsigned long rhs, unsigned lhs);
+/* Divide a 32 bit unsigned value by a 16 bit unsigned value yielding a 16
+** bit result and a 16 bit remainder. The former is returned in the lower 16
+** bit of the result, the latter in the upper. If you don't need the
+** remainder, just assign (or cast) to an unsigned.
+*/
+
+int __fastcall__ imul8x8r16 (signed char lhs, signed char rhs);
+/* Multiply two signed 8 bit to yield an signed 16 bit result */
+
+long __fastcall__ imul16x16r32 (int lhs, int rhs);
+/* Multiply two signed 16 bit to yield a signed 32 bit result */
+
+unsigned __fastcall__ umul8x8r16 (unsigned char lhs, unsigned char rhs);
+/* Multiply two unsigned 8 bit to yield an unsigned 16 bit result */
+
+unsigned long __fastcall__ umul16x8r32 (unsigned lhs, unsigned char rhs);
+/* Multiply an unsigned 16 bit by an unsigned 8 bit number yielding a 24
+** bit unsigned result that is extended to 32 bits for easier handling from C.
+*/
+
+unsigned long __fastcall__ umul16x16r32 (unsigned lhs, unsigned rhs);
+/* Multiply two unsigned 16 bit to yield an unsigned 32 bit result */
+
+unsigned int __fastcall__ mul20 (unsigned char value);
+/* Multiply an 8 bit unsigned value by 20 and return the 16 bit unsigned
+** result
+*/
+
+unsigned int __fastcall__ mul40 (unsigned char value);
+/* Multiply an 8 bit unsigned value by 40 and return the 16 bit unsigned
+** result
+*/
+
+int __fastcall__ _sin (unsigned x);
+/* Return the sine of the argument, which must be in range 0..360. The result
+** is in 8.8 fixed point format, which means that 1.0 = $100 and -1.0 = $FF00.
+*/
+
+int __fastcall__ _cos (unsigned x);
+/* Return the cosine of the argument, which must be in range 0..360. The result
+** is in 8.8 fixed point format, which means that 1.0 = $100 and -1.0 = $FF00.
+*/
+
+unsigned char doesclrscrafterexit (void);
+/* Indicates whether the screen automatically be cleared after program
+** termination.
+*/
+
+
+
+/* End of cc65.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* conio.h */
+/* */
+/* Direct console I/O */
+/* */
+/* */
+/* */
+/* (C) 1998-2007 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+/*
+** This is the direct console interface for cc65. I do not like the function
+** names very much, but the first version started as a rewrite of Borland's
+** conio, and, even if the interface has changed, the names did not.
+**
+** The interface does direct screen I/O, so it is fast enough for most
+** programs. I did not implement text windows, since many applications do
+** not need them and should not pay for the additional overhead. It should
+** be easy to add text windows on a higher level if needed,
+**
+** Most routines do not check the parameters. This may be unfortunate but is
+** also related to speed. The coordinates are always 0/0 based.
+*/
+
+
+
+#ifndef _CONIO_H
+#define _CONIO_H
+
+
+
+#include
+#include
+
+
+
+/*****************************************************************************/
+/* Functions */
+/*****************************************************************************/
+
+
+
+void clrscr (void);
+/* Clear the whole screen and put the cursor into the top left corner */
+
+unsigned char kbhit (void);
+/* Return true if there's a key waiting, return false if not */
+
+void __fastcall__ gotox (unsigned char x);
+/* Set the cursor to the specified X position, leave the Y position untouched */
+
+void __fastcall__ gotoy (unsigned char y);
+/* Set the cursor to the specified Y position, leave the X position untouched */
+
+void __fastcall__ gotoxy (unsigned char x, unsigned char y);
+/* Set the cursor to the specified position */
+
+unsigned char wherex (void);
+/* Return the X position of the cursor */
+
+unsigned char wherey (void);
+/* Return the Y position of the cursor */
+
+void __fastcall__ cputc (char c);
+/* Output one character at the current cursor position */
+
+void __fastcall__ cputcxy (unsigned char x, unsigned char y, char c);
+/* Same as "gotoxy (x, y); cputc (c);" */
+
+void __fastcall__ cputs (const char* s);
+/* Output a NUL-terminated string at the current cursor position */
+
+void __fastcall__ cputsxy (unsigned char x, unsigned char y, const char* s);
+/* Same as "gotoxy (x, y); puts (s);" */
+
+int cprintf (const char* format, ...);
+/* Like printf(), but uses direct screen output */
+
+int __fastcall__ vcprintf (const char* format, va_list ap);
+/* Like vprintf(), but uses direct screen output */
+
+char cgetc (void);
+/* Return a character from the keyboard. If there is no character available,
+** the function waits until the user does press a key. If cursor is set to
+** 1 (see below), a blinking cursor is displayed while waiting.
+*/
+
+int cscanf (const char* format, ...);
+/* Like scanf(), but uses direct keyboard input */
+
+int __fastcall__ vcscanf (const char* format, va_list ap);
+/* Like vscanf(), but uses direct keyboard input */
+
+char cpeekc (void);
+/* Return the character from the current cursor position */
+
+unsigned char cpeekcolor (void);
+/* Return the color from the current cursor position */
+
+unsigned char cpeekrevers (void);
+/* Return the reverse attribute from the current cursor position.
+** If the character is reversed, then return 1; return 0 otherwise.
+*/
+
+void __fastcall__ cpeeks (char* s, unsigned int length);
+/* Return a string of the characters that start at the current cursor position.
+** Put the string into the buffer to which "s" points. The string will have
+** "length" characters, then will be '\0'-terminated.
+*/
+
+unsigned char __fastcall__ cursor (unsigned char onoff);
+/* If onoff is 1, a cursor is displayed when waiting for keyboard input. If
+** onoff is 0, the cursor is hidden when waiting for keyboard input. The
+** function returns the old cursor setting.
+*/
+
+unsigned char __fastcall__ revers (unsigned char onoff);
+/* Enable/disable reverse character display. This may not be supported by
+** the output device. Return the old setting.
+*/
+
+unsigned char __fastcall__ textcolor (unsigned char color);
+/* Set the color for text output. The old color setting is returned. */
+
+unsigned char __fastcall__ bgcolor (unsigned char color);
+/* Set the color for the background. The old color setting is returned. */
+
+unsigned char __fastcall__ bordercolor (unsigned char color);
+/* Set the color for the border. The old color setting is returned. */
+
+void __fastcall__ chline (unsigned char length);
+/* Output a horizontal line with the given length starting at the current
+** cursor position.
+*/
+
+void __fastcall__ chlinexy (unsigned char x, unsigned char y, unsigned char length);
+/* Same as "gotoxy (x, y); chline (length);" */
+
+void __fastcall__ cvline (unsigned char length);
+/* Output a vertical line with the given length at the current cursor
+** position.
+*/
+
+void __fastcall__ cvlinexy (unsigned char x, unsigned char y, unsigned char length);
+/* Same as "gotoxy (x, y); cvline (length);" */
+
+void __fastcall__ cclear (unsigned char length);
+/* Clear part of a line (write length spaces). */
+
+void __fastcall__ cclearxy (unsigned char x, unsigned char y, unsigned char length);
+/* Same as "gotoxy (x, y); cclear (length);" */
+
+void __fastcall__ screensize (unsigned char* x, unsigned char* y);
+/* Return the current screen size. */
+
+void __fastcall__ cputhex8 (unsigned char val);
+void __fastcall__ cputhex16 (unsigned val);
+/* These shouldn't be here... */
+
+
+
+/*****************************************************************************/
+/* Macros */
+/*****************************************************************************/
+
+
+
+/* On some platforms, functions are not available or are dummys. To suppress
+** the call to these functions completely, the platform header files may
+** define macros for these functions that start with an underline. If such a
+** macro exists, a new macro is defined here, that expands to the one with the
+** underline. The reason for this two stepped approach is that it is sometimes
+** necessary to take the address of the function, which is not possible when
+** using a macro. Since the function prototype is still present, #undefining
+** the macro will give access to the actual function.
+*/
+
+#ifdef _textcolor
+# define textcolor(color) _textcolor(color)
+#endif
+#ifdef _bgcolor
+# define bgcolor(color) _bgcolor(color)
+#endif
+#ifdef _bordercolor
+# define bordercolor(color) _bordercolor(color)
+#endif
+#ifdef _cpeekcolor
+# define cpeekcolor() _cpeekcolor()
+#endif
+#ifdef _cpeekrevers
+# define cpeekrevers() _cpeekrevers()
+#endif
+
+
+
+/* End of conio.h */
+#endif
+/*****************************************************************************/
+/* */
+/* creativision.h */
+/* */
+/* Creativision system specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2013 cvemu */
+/* (C) 2017 Christian Groessler */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+#ifndef _CVISION_H
+#define _CVISION_H
+
+/* Character codes */
+#define CH_VLINE 33
+#define CH_HLINE 34
+#define CH_ULCORNER 35
+#define CH_URCORNER 36
+#define CH_LLCORNER 37
+#define CH_LRCORNER 38
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x10
+#define JOY_DOWN_MASK 0x04
+#define JOY_LEFT_MASK 0x20
+#define JOY_RIGHT_MASK 0x08
+#define JOY_BTN_1_MASK 0x01
+#define JOY_BTN_2_MASK 0x02
+
+/* no support for dynamically loadable drivers */
+#define DYN_DRV 0
+
+/* Colours - from TMS9918 */
+#define COLOR_TRANSPARENT 0
+#define COLOR_BLACK 1
+#define COLOR_MED_GREEN 2
+#define COLOR_LIGHT_GREEN 3
+#define COLOR_DARK_BLUE 4
+#define COLOR_LIGHT_BLUE 5
+#define COLOR_DARK_RED 6
+#define COLOR_CYAN 7
+#define COLOR_MED_RED 8
+#define COLOR_LIGHT_RED 9
+#define COLOR_DARK_YELLOW 10
+#define COLOR_LIGHT_YELLOW 11
+#define COLOR_DARK_GREEN 12
+#define COLOR_MAGENTA 13
+#define COLOR_GREY 14
+#define COLOR_WHITE 15
+
+/* Protos */
+void __fastcall__ psg_outb (unsigned char b);
+void __fastcall__ psg_delay (unsigned char b);
+void psg_silence (void);
+void __fastcall__ bios_playsound (const void *a, unsigned char b);
+
+#endif /* #ifndef _CVISION_H */
+/*****************************************************************************/
+/* */
+/* ctype.h */
+/* */
+/* Character handling */
+/* */
+/* */
+/* */
+/* (C) 1998-2013, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _CTYPE_H
+#define _CTYPE_H
+
+/* Bits used to specify character classes */
+#define _CT_LOWER 0x01 /* 0 - Lower case char */
+#define _CT_UPPER 0x02 /* 1 - Upper case char */
+#define _CT_DIGIT 0x04 /* 2 - Numeric digit */
+#define _CT_XDIGIT 0x08 /* 3 - Hex digit (both lower and upper) */
+#define _CT_CNTRL 0x10 /* 4 - Control character */
+#define _CT_SPACE 0x20 /* 5 - The space character itself */
+#define _CT_OTHER_WS 0x40 /* 6 - Other whitespace ('\f', '\n', '\r', '\t', and '\v') */
+#define _CT_SPACE_TAB 0x80 /* 7 - Space or tab character */
+
+/* Bit combinations */
+#define _CT_ALNUM (_CT_LOWER | _CT_UPPER | _CT_DIGIT)
+#define _CT_ALPHA (_CT_LOWER | _CT_UPPER)
+#define _CT_NOT_GRAPH (_CT_CNTRL | _CT_SPACE)
+#define _CT_NOT_PRINT (_CT_CNTRL)
+#define _CT_NOT_PUNCT (_CT_SPACE | _CT_CNTRL | _CT_DIGIT | _CT_UPPER | _CT_LOWER)
+#define _CT_WS (_CT_SPACE | _CT_OTHER_WS)
+
+/* Character classification functions */
+int __fastcall__ isalnum (int c);
+int __fastcall__ isalpha (int c);
+#if __CC65_STD__ >= __CC65_STD_CC65__
+int __fastcall__ isascii (int c); /* non standard */
+#endif
+int __fastcall__ iscntrl (int c);
+int __fastcall__ isdigit (int c);
+int __fastcall__ isgraph (int c);
+int __fastcall__ islower (int c);
+int __fastcall__ isprint (int c);
+int __fastcall__ ispunct (int c);
+int __fastcall__ isspace (int c);
+int __fastcall__ isupper (int c);
+int __fastcall__ isxdigit (int c);
+#if __CC65_STD__ >= __CC65_STD_C99__
+int __fastcall__ isblank (int c); /* New in C99 */
+#endif
+
+int __fastcall__ toupper (int c); /* Always external */
+int __fastcall__ tolower (int c); /* Always external */
+
+#if __CC65_STD__ >= __CC65_STD_CC65__
+unsigned char __fastcall__ toascii (unsigned char c); /* non standard */
+/* Convert a target-specific character to ASCII. */
+#endif
+
+/* End of ctype.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* cx16.h */
+/* */
+/* CX16 system-specific definitions */
+/* For prerelease 39 */
+/* */
+/* */
+/* This software is provided "as-is", without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated, but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _CX16_H
+#define _CX16_H
+
+
+
+/* Check for errors */
+#ifndef __CX16__
+# error This module may be used only when compiling for the CX16!
+#endif
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Additional output character codes */
+#define CH_COLOR_SWAP 0x01
+#define CH_UNDERLINE 0x04
+#define CH_WHITE 0x05
+#define CH_BOLD 0x06
+#define CH_BACKSPACE 0x08
+#define CH_ITALIC 0x0B
+#define CH_OUTLINE 0x0C
+#define CH_FONT_ISO 0x0F
+#define CH_RED 0x1C
+#define CH_GREEN 0x1E
+#define CH_BLUE 0x1F
+#define CH_ORANGE 0x81
+#define CH_FONT_PET 0x8F
+#define CH_BLACK 0x90
+#define CH_ATTR_CLEAR 0x92
+#define CH_BROWN 0x95
+#define CH_PINK 0x96
+#define CH_LIGHTRED CH_PINK
+#define CH_GRAY1 0x97
+#define CH_GRAY2 0x98
+#define CH_LIGHTGREEN 0x99
+#define CH_LIGHTBLUE 0x9A
+#define CH_GRAY3 0x9B
+#define CH_PURPLE 0x9C
+#define CH_YELLOW 0x9E
+#define CH_CYAN 0x9F
+#define CH_SHIFT_SPACE 0xA0
+
+/* Additional key defines */
+#define CH_SHIFT_TAB 0x18
+#define CH_HELP 0x84
+#define CH_F1 0x85
+#define CH_F2 0x89
+#define CH_F3 0x86
+#define CH_F4 0x8A
+#define CH_F5 0x87
+#define CH_F6 0x8B
+#define CH_F7 0x88
+#define CH_F8 0x8C
+#define CH_F9 0x10
+#define CH_F10 0x15
+#define CH_F11 0x16
+#define CH_F12 0x17
+
+/* Color defines */
+#define COLOR_BLACK 0x00
+#define COLOR_WHITE 0x01
+#define COLOR_RED 0x02
+#define COLOR_CYAN 0x03
+#define COLOR_PURPLE 0x04
+#define COLOR_GREEN 0x05
+#define COLOR_BLUE 0x06
+#define COLOR_YELLOW 0x07
+#define COLOR_ORANGE 0x08
+#define COLOR_BROWN 0x09
+#define COLOR_PINK 0x0A
+#define COLOR_LIGHTRED COLOR_PINK
+#define COLOR_GRAY1 0x0B
+#define COLOR_GRAY2 0x0C
+#define COLOR_LIGHTGREEN 0x0D
+#define COLOR_LIGHTBLUE 0x0E
+#define COLOR_GRAY3 0x0F
+
+/* TGI color defines */
+#define TGI_COLOR_BLACK COLOR_BLACK
+#define TGI_COLOR_WHITE COLOR_WHITE
+#define TGI_COLOR_RED COLOR_RED
+#define TGI_COLOR_CYAN COLOR_CYAN
+#define TGI_COLOR_PURPLE COLOR_PURPLE
+#define TGI_COLOR_GREEN COLOR_GREEN
+#define TGI_COLOR_BLUE COLOR_BLUE
+#define TGI_COLOR_YELLOW COLOR_YELLOW
+#define TGI_COLOR_ORANGE COLOR_ORANGE
+#define TGI_COLOR_BROWN COLOR_BROWN
+#define TGI_COLOR_LIGHTRED COLOR_LIGHTRED
+#define TGI_COLOR_GRAY1 COLOR_GRAY1
+#define TGI_COLOR_GRAY2 COLOR_GRAY2
+#define TGI_COLOR_LIGHTGREEN COLOR_LIGHTGREEN
+#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
+#define TGI_COLOR_GRAY3 COLOR_GRAY3
+
+/* NES controller masks for joy_read() */
+
+#define JOY_BTN_1_MASK 0x80
+#define JOY_BTN_2_MASK 0x40
+#define JOY_BTN_3_MASK 0x20
+#define JOY_BTN_4_MASK 0x10
+#define JOY_UP_MASK 0x08
+#define JOY_DOWN_MASK 0x04
+#define JOY_LEFT_MASK 0x02
+#define JOY_RIGHT_MASK 0x01
+
+#define JOY_BTN_A_MASK JOY_BTN_1_MASK
+#define JOY_BTN_B_MASK JOY_BTN_2_MASK
+#define JOY_SELECT_MASK JOY_BTN_3_MASK
+#define JOY_START_MASK JOY_BTN_4_MASK
+
+#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
+#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
+#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
+#define JOY_START(v) ((v) & JOY_START_MASK)
+
+#define JOY_FIRE2_MASK JOY_BTN_2_MASK
+#define JOY_FIRE2(v) ((v) & JOY_FIRE2_MASK)
+
+/* Additional mouse button mask */
+#define MOUSE_BTN_MIDDLE 0x02
+
+/* get_tv() return codes
+** set_tv() argument codes
+*/
+enum {
+ TV_NONE = 0x00,
+ TV_VGA,
+ TV_NTSC_COLOR,
+ TV_RGB,
+ TV_NONE2,
+ TV_VGA2,
+ TV_NTSC_MONO,
+ TV_RGB2
+};
+
+/* Video modes for videomode() */
+#define VIDEOMODE_80x60 0x00
+#define VIDEOMODE_80x30 0x01
+#define VIDEOMODE_40x60 0x02
+#define VIDEOMODE_40x30 0x03
+#define VIDEOMODE_40x15 0x04
+#define VIDEOMODE_20x30 0x05
+#define VIDEOMODE_20x15 0x06
+#define VIDEOMODE_80COL VIDEOMODE_80x60
+#define VIDEOMODE_40COL VIDEOMODE_40x30
+#define VIDEOMODE_320x240 0x80
+#define VIDEOMODE_SWAP (-1)
+
+/* VERA's address increment/decrement numbers */
+enum {
+ VERA_DEC_0 = ((0 << 1) | 1) << 3,
+ VERA_DEC_1 = ((1 << 1) | 1) << 3,
+ VERA_DEC_2 = ((2 << 1) | 1) << 3,
+ VERA_DEC_4 = ((3 << 1) | 1) << 3,
+ VERA_DEC_8 = ((4 << 1) | 1) << 3,
+ VERA_DEC_16 = ((5 << 1) | 1) << 3,
+ VERA_DEC_32 = ((6 << 1) | 1) << 3,
+ VERA_DEC_64 = ((7 << 1) | 1) << 3,
+ VERA_DEC_128 = ((8 << 1) | 1) << 3,
+ VERA_DEC_256 = ((9 << 1) | 1) << 3,
+ VERA_DEC_512 = ((10 << 1) | 1) << 3,
+ VERA_DEC_40 = ((11 << 1) | 1) << 3,
+ VERA_DEC_80 = ((12 << 1) | 1) << 3,
+ VERA_DEC_160 = ((13 << 1) | 1) << 3,
+ VERA_DEC_320 = ((14 << 1) | 1) << 3,
+ VERA_DEC_640 = ((15 << 1) | 1) << 3,
+ VERA_INC_0 = ((0 << 1) | 0) << 3,
+ VERA_INC_1 = ((1 << 1) | 0) << 3,
+ VERA_INC_2 = ((2 << 1) | 0) << 3,
+ VERA_INC_4 = ((3 << 1) | 0) << 3,
+ VERA_INC_8 = ((4 << 1) | 0) << 3,
+ VERA_INC_16 = ((5 << 1) | 0) << 3,
+ VERA_INC_32 = ((6 << 1) | 0) << 3,
+ VERA_INC_64 = ((7 << 1) | 0) << 3,
+ VERA_INC_128 = ((8 << 1) | 0) << 3,
+ VERA_INC_256 = ((9 << 1) | 0) << 3,
+ VERA_INC_512 = ((10 << 1) | 0) << 3,
+ VERA_INC_40 = ((11 << 1) | 0) << 3,
+ VERA_INC_80 = ((12 << 1) | 0) << 3,
+ VERA_INC_160 = ((13 << 1) | 0) << 3,
+ VERA_INC_320 = ((14 << 1) | 0) << 3,
+ VERA_INC_640 = ((15 << 1) | 0) << 3
+};
+
+/* VERA's interrupt flags */
+#define VERA_IRQ_VSYNC 0b00000001
+#define VERA_IRQ_RASTER 0b00000010
+#define VERA_IRQ_SPR_COLL 0b00000100
+#define VERA_IRQ_AUDIO_LOW 0b00001000
+
+
+/* Define hardware. */
+
+#define RAM_BANK (*(unsigned char *)0x00)
+#define ROM_BANK (*(unsigned char *)0x01)
+
+#include <_6522.h>
+#define VIA1 (*(volatile struct __6522 *)0x9F00)
+#define VIA2 (*(volatile struct __6522 *)0x9F10)
+
+/* A structure with the Video Enhanced Retro Adapter's external registers */
+struct __vera {
+ unsigned short address; /* Address for data ports */
+ unsigned char address_hi;
+ unsigned char data0; /* Data port 0 */
+ unsigned char data1; /* Data port 1 */
+ unsigned char control; /* Control register */
+ unsigned char irq_enable; /* Interrupt enable bits */
+ unsigned char irq_flags; /* Interrupt flags */
+ unsigned char irq_raster; /* Line where IRQ will occur */
+ union {
+ struct { /* Visible when DCSEL flag = 0 */
+ unsigned char video; /* Flags to enable video layers */
+ unsigned char hscale; /* Horizontal scale factor */
+ unsigned char vscale; /* Vertical scale factor */
+ unsigned char border; /* Border color (NTSC mode) */
+ };
+ struct { /* Visible when DCSEL flag = 1 */
+ unsigned char hstart; /* Horizontal start position */
+ unsigned char hstop; /* Horizontal stop position */
+ unsigned char vstart; /* Vertical start position */
+ unsigned char vstop; /* Vertical stop position */
+ };
+ struct { /* Visible when DCSEL flag = 2 */
+ unsigned char fxctrl;
+ unsigned char fxtilebase;
+ unsigned char fxmapbase;
+ unsigned char fxmult;
+ };
+ struct { /* Visible when DCSEL flag = 3 */
+ unsigned char fxxincrl;
+ unsigned char fxxincrh;
+ unsigned char fxyincrl;
+ unsigned char fxyincrh;
+ };
+ struct { /* Visible when DCSEL flag = 4 */
+ unsigned char fxxposl;
+ unsigned char fxxposh;
+ unsigned char fxyposl;
+ unsigned char fxyposh;
+ };
+ struct { /* Visible when DCSEL flag = 5 */
+ unsigned char fxxposs;
+ unsigned char fxyposs;
+ unsigned char fxpolyfilll;
+ unsigned char fxpolyfillh;
+ };
+ struct { /* Visible when DCSEL flag = 6 */
+ unsigned char fxcachel;
+ unsigned char fxcachem;
+ unsigned char fxcacheh;
+ unsigned char fxcacheu;
+ };
+ struct { /* Visible when DCSEL flag = 63 */
+ unsigned char dcver0;
+ unsigned char dcver1;
+ unsigned char dcver2;
+ unsigned char dcver3;
+ };
+ } display;
+ struct {
+ unsigned char config; /* Layer map geometry */
+ unsigned char mapbase; /* Map data address */
+ unsigned char tilebase; /* Tile address and geometry */
+ unsigned int hscroll; /* Smooth scroll horizontal offset */
+ unsigned int vscroll; /* Smooth scroll vertical offset */
+ } layer0;
+ struct {
+ unsigned char config;
+ unsigned char mapbase;
+ unsigned char tilebase;
+ unsigned int hscroll;
+ unsigned int vscroll;
+ } layer1;
+ struct {
+ unsigned char control; /* PCM format */
+ unsigned char rate; /* Sample rate */
+ unsigned char data; /* PCM output queue */
+ } audio; /* Pulse-Code Modulation registers */
+ struct {
+ unsigned char data;
+ unsigned char control;
+ } spi; /* SD card interface */
+};
+#define VERA (*(volatile struct __vera *)0x9F20)
+
+/* Audio chip */
+struct __ym2151 {
+ unsigned char reg; /* Register number for data */
+ union {
+ unsigned char data;
+ unsigned char status; /* Busy flag */
+ };
+};
+#define YM2151 (*(volatile struct __ym2151 *)0x9F40)
+
+/* A structure with the x16emu's settings registers */
+struct __emul {
+ unsigned char debug; /* Boolean: debugging enabled */
+ unsigned char vera_action; /* Boolean: displaying VERA activity */
+ unsigned char keyboard; /* Boolean: displaying typed keys */
+ unsigned char echo; /* How to send Kernal output to host */
+ unsigned char save_on_exit; /* Boolean: save machine state on exit */
+ unsigned char gif_method; /* How GIF movie is being recorded */
+ unsigned char const unused1[2];
+ unsigned long const cycle_count; /* Running total of CPU cycles (8 MHz.) */
+ unsigned char const unused2[1];
+ unsigned char const keymap; /* Keyboard layout number */
+ char const detect[2]; /* "16" if running on x16emu */
+};
+#define EMULATOR (*(volatile struct __emul *)0x9FB0)
+
+/* An array window into the half Mebibyte or two Mebibytes of banked RAM */
+#define BANK_RAM ((unsigned char *)0xA000)
+
+
+
+/* The addresses of the static drivers */
+
+extern void cx16_std_joy[]; /* Referenced by joy_static_stddrv[] */
+extern void cx16_std_mou[]; /* Referenced by mouse_static_stddrv[] */
+extern void cx320p1_tgi[]; /* Referenced by tgi_static_stddrv[] */
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+unsigned short get_numbanks (void);
+/* Return the number of RAM banks that the machine has. */
+
+signed char get_ostype (void);
+/* Get the ROM build version.
+** -1 -- custom build
+** Negative -- prerelease build
+** Positive -- release build
+*/
+
+unsigned char get_tv (void);
+/* Return the video signal type that the machine is using.
+** Return a TV_xx constant.
+*/
+
+void __fastcall__ set_tv (unsigned char type);
+/* Set the video signal type that the machine will use.
+** Call with a TV_xx constant.
+*/
+
+unsigned char __fastcall__ vera_layer_enable (unsigned char layers);
+/* Display the layers that are "named" by the bit flags in layers.
+** A value of 0b01 shows layer 0, a value of 0b10 shows layer 1,
+** a value of 0b11 shows both layers. Return the previous value.
+*/
+
+unsigned char __fastcall__ vera_sprites_enable (unsigned char mode);
+/* Enable the sprite engine when mode is non-zero (true);
+** disable sprites when mode is zero. Return the previous mode.
+*/
+
+signed char __fastcall__ videomode (signed char mode);
+/* Set the video mode, return the old mode.
+** Return -1 if Mode isn't valid.
+** Call with one of the VIDEOMODE_xx constants.
+*/
+
+unsigned char __fastcall__ vpeek (unsigned long addr);
+/* Get a byte from a location in VERA's internal address space. */
+
+void __fastcall__ vpoke (unsigned char data, unsigned long addr);
+/* Put a byte into a location in VERA's internal address space.
+** (addr is second instead of first for the sake of code efficiency.)
+*/
+
+
+
+/* End of cX16.h */
+#endif
+/*****************************************************************************/
+/* */
+/* dbg.h */
+/* */
+/* Debugger module interface */
+/* */
+/* */
+/* */
+/* (C) 1998-2000, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+/*
+** This is the interface to the cc65 debugger. Since many of the functions
+** used for the debugger are quite usable even in another context, they
+** are declared here.
+**
+** To use the debugger, just call DbgInit in your application. Once it has
+** been called, the debugger will catch any BRK opcode. Use the BREAK macro
+** defined below to insert breakpoints into your code.
+**
+** There are currently a lot of things that cannot be debugged, graphical
+** applications are an example. The debugger does not save your screen
+** contents, so even your text screen gets destroyed. However, you can
+** debug the C and runtime library, even if the debugger is using this
+** stuff itself.
+**
+** Note: When using the debugger, there are some other identifiers with
+** external linkage, that start with Dbg. Avoid those names if you use the
+** module.
+*/
+
+
+
+#ifndef _DBG_H
+#define _DBG_H
+
+
+
+/*****************************************************************************/
+/* Utility functions */
+/*****************************************************************************/
+
+
+
+unsigned __fastcall__ DbgDisAsm (unsigned Addr, char* Buf, unsigned char Len);
+/* Disassemble one instruction at address addr into the given buffer.
+** The resulting line has the format, "AAAA__BB_BB_BB___OPC_OPERAND",
+** where AAAA is the hexadecimal representation of addr, BB are the
+** bytes (in hex) that make the instruction, OPC is the mnemonic, and
+** OPERAND is an operand for the instruction.
+** The buffer is filled with spaces up to the given length and terminated as
+** a usual C string. NOTE: Buf must be able to hold Len+1 characters.
+** The function returns the length of the disassembled instruction, so,
+** to disassemble the next instruction, add the return value to addr
+** and call the function again.
+*/
+
+unsigned __fastcall__ DbgDisAsmLen (unsigned Addr);
+/* Disassemble one instruction, but do only return the length, do not
+** create a visible representation. This function is useful when
+** disassembling backwards, it is much faster than DbgDisAsm.
+*/
+
+int __fastcall__ DbgIsRAM (unsigned Addr);
+/* Return true if we can read and write the given address */
+
+char* __cdecl__ DbgMemDump (unsigned Addr, char* Buf, unsigned char Len);
+/* Create a line of a memory dump in the given buffer. The buffer contains
+** the starting address (4 digits hex), then Len bytes in this format:
+** "AAAA__XX_YY_ZZ_...". The passed char buffer must hold Len*3+5 bytes
+** plus a terminator byte.
+** The function does not work correctly if the created string is longer
+** than 255 bytes.
+** The return value is Buf.
+*/
+
+
+
+/*****************************************************************************/
+/* High level user interface */
+/*****************************************************************************/
+
+
+
+void __fastcall__ DbgInit (unsigned unused);
+/* Initialize the debugger. Use 0 as parameter. The debugger will popup on
+** next brk encountered.
+*/
+
+#define BREAK() __asm__ ("brk")
+/* Use this to insert breakpoints into your code */
+
+
+
+/* End of dbg.h */
+#endif
+
+
+
+
+/*****************************************************************************/
+/* */
+/* device.h */
+/* */
+/* Device handling */
+/* */
+/* */
+/* */
+/* (C) 2012 Oliver Schmidt, */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _DEVICE_H
+#define _DEVICE_H
+
+
+
+#ifndef _HAVE_size_t
+typedef unsigned size_t;
+#define _HAVE_size_t
+#endif
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+#define INVALID_DEVICE 255
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+unsigned char getfirstdevice (void);
+
+unsigned char __fastcall__ getnextdevice (unsigned char device);
+
+unsigned char getcurrentdevice (void);
+
+char* __fastcall__ getdevicedir (unsigned char device, char* buf, size_t size);
+
+
+
+/* End of device.h */
+#endif
+/*****************************************************************************/
+/* */
+/* dio.h */
+/* */
+/* Low-Level diskette I/O functions */
+/* */
+/* */
+/* */
+/* (C) 2005 Christian Groessler */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _DIO_H
+#define _DIO_H
+
+
+
+/* Please note: All functions in this file will set __oserror *and* return its
+** value. The only exception is dio_open, which will return NULL, but __oserror
+** will be set. All function will also set __oserror in case of successful
+** execution, effectively clearing it.
+*/
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+typedef struct __dhandle_t *dhandle_t;
+
+typedef struct {
+ unsigned char head;
+ unsigned track;
+ unsigned sector;
+} dio_phys_pos;
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+unsigned __fastcall__ dio_query_sectsize (dhandle_t handle);
+/* returns sector size */
+
+unsigned __fastcall__ dio_query_sectcount (dhandle_t handle);
+/* returns sector count */
+
+dhandle_t __fastcall__ dio_open (unsigned char device);
+/* open device for subsequent dio access */
+
+unsigned char __fastcall__ dio_close (dhandle_t handle);
+/* close device, returns oserror (0 for success) */
+
+unsigned char __fastcall__ dio_read (dhandle_t handle,
+ unsigned sect_num,
+ void *buffer);
+/* read sector from device to memory at */
+/* the number of bytes transferred depends on the sector size */
+/* returns oserror (0 for success) */
+
+unsigned char __fastcall__ dio_write (dhandle_t handle,
+ unsigned sect_num,
+ const void *buffer);
+/* write memory at to sector on device , no verify */
+/* the number of bytes transferred depends on the sector size */
+/* returns oserror (0 for success) */
+
+unsigned char __fastcall__ dio_write_verify (dhandle_t handle,
+ unsigned sect_num,
+ const void *buffer);
+/* write memory at to sector on device , verify after write */
+/* the number of bytes transferred depends on the sector size */
+/* returns oserror (0 for success) */
+
+unsigned char __fastcall__ dio_phys_to_log (dhandle_t handle,
+ const dio_phys_pos *physpos, /* input */
+ unsigned *sectnum); /* output */
+/* convert physical sector address (head/track/sector) to logical sector number */
+/* returns oserror (0 for success) */
+
+unsigned char __fastcall__ dio_log_to_phys (dhandle_t handle,
+ const unsigned *sectnum, /* input */
+ dio_phys_pos *physpos); /* output */
+/* convert logical sector number to physical sector address (head/track/sector) */
+/* returns oserror (0 for success) */
+
+#endif /* #ifndef _DIO_H */
+/*****************************************************************************/
+/* */
+/* dirent.h */
+/* */
+/* Directory entries for cc65 */
+/* */
+/* */
+/* */
+/* (C) 2005 Oliver Schmidt, */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _DIRENT_H
+#define _DIRENT_H
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+typedef struct DIR DIR;
+
+#if defined(__APPLE2__)
+
+struct dirent {
+ char d_name[16];
+ unsigned d_ino;
+ unsigned d_blocks;
+ unsigned long d_size;
+ unsigned char d_type;
+ struct {
+ unsigned day :5;
+ unsigned mon :4;
+ unsigned year :7;
+ } d_cdate;
+ struct {
+ unsigned char min;
+ unsigned char hour;
+ } d_ctime;
+ unsigned char d_access;
+ unsigned d_auxtype;
+ struct {
+ unsigned day :5;
+ unsigned mon :4;
+ unsigned year :7;
+ } d_mdate;
+ struct {
+ unsigned char min;
+ unsigned char hour;
+ } d_mtime;
+};
+
+#define _DE_ISREG(t) ((t) != 0x0F)
+#define _DE_ISDIR(t) ((t) == 0x0F)
+#define _DE_ISLBL(t) (0)
+#define _DE_ISLNK(t) (0)
+
+#elif defined(__ATARI__)
+
+struct dirent {
+ char d_name[13]; /* 8.3 + trailing 0 */
+ unsigned char d_type;
+};
+
+#define _DE_ISREG(t) ((t) != 0xC4)
+#define _DE_ISDIR(t) ((t) == 0xC4)
+#define _DE_ISLBL(t) (0)
+#define _DE_ISLNK(t) (0)
+
+#elif defined(__CBM__)
+
+struct dirent {
+ char d_name[16+1];
+ unsigned int d_off;
+ unsigned int d_blocks;
+ unsigned char d_type; /* See _CBM_T_xxx defines */
+
+ /* bsd extensions */
+ unsigned char d_namlen;
+};
+
+/* File type specification macros. We need definitions of CBM file types. */
+#include
+
+#define _DE_ISREG(t) (((t) & _CBM_T_REG) != 0)
+#define _DE_ISDIR(t) ((t) == _CBM_T_DIR)
+#define _DE_ISLBL(t) ((t) == _CBM_T_HEADER)
+#define _DE_ISLNK(t) ((t) == _CBM_T_LNK)
+
+#elif defined(__LYNX__)
+
+struct dirent {
+ unsigned char d_blocks;
+ unsigned int d_offset;
+ char d_type;
+ void *d_address;
+ unsigned int d_size;
+};
+
+extern struct dirent FileEntry;
+#pragma zpsym ("FileEntry");
+
+#define _DE_ISREG(t) (1)
+#define _DE_ISDIR(t) (0)
+#define _DE_ISLBL(t) (0)
+#define _DE_ISLNK(t) (0)
+
+#else
+
+struct dirent {
+ char d_name[1];
+};
+
+#define _DE_ISREG(t) (1)
+#define _DE_ISDIR(t) (0)
+#define _DE_ISLBL(t) (0)
+#define _DE_ISLNK(t) (0)
+
+#endif
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+DIR* __fastcall__ opendir (const char* name);
+
+struct dirent* __fastcall__ readdir (DIR* dir);
+
+int __fastcall__ closedir (DIR* dir);
+
+long __fastcall__ telldir (DIR* dir);
+
+void __fastcall__ seekdir (DIR* dir, long offs);
+
+void __fastcall__ rewinddir (DIR* dir);
+
+
+
+/* End of dirent.h */
+#endif
+/*****************************************************************************/
+/* */
+/* em.h */
+/* */
+/* API for extended memory access */
+/* */
+/* */
+/* */
+/* (C) 2002-2012, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _EM_H
+#define _EM_H
+
+
+
+/*****************************************************************************/
+/* Definitions */
+/*****************************************************************************/
+
+
+
+/* Size of an extended memory page */
+#define EM_PAGE_SIZE 256
+
+/* Error codes */
+#define EM_ERR_OK 0 /* No error */
+#define EM_ERR_NO_DRIVER 1 /* No driver available */
+#define EM_ERR_CANNOT_LOAD 2 /* Error loading driver */
+#define EM_ERR_INV_DRIVER 3 /* Invalid driver */
+#define EM_ERR_NO_DEVICE 4 /* Device (hardware) not found */
+#define EM_ERR_INSTALLED 5 /* A driver is already installed */
+
+/* Parameters for the em_copy_... functions. NOTE: The first seven bytes
+** have the same order and alignment as needed for the Commodore REU, so
+** don't change the order without changing the assembler file that defines
+** the struct offsets and the code in the REU driver.
+*/
+struct em_copy {
+ void* buf; /* Memory buffer to copy from or to */
+ unsigned char offs; /* Offset into page */
+ unsigned page; /* Starting page to copy from or to */
+ unsigned count; /* Number of bytes to copy */
+ unsigned char unused; /* Make the size 8 bytes */
+};
+
+
+
+/*****************************************************************************/
+/* Functions */
+/*****************************************************************************/
+
+
+
+unsigned char __fastcall__ em_load_driver (const char* driver);
+/* Load and install an extended memory driver. Return an error code. */
+
+unsigned char em_unload (void);
+/* Uninstall, then unload the currently loaded driver. */
+
+unsigned char __fastcall__ em_install (const void* driver);
+/* Install an already loaded driver. Return an error code. */
+
+unsigned char em_uninstall (void);
+/* Uninstall the currently loaded driver and return an error code.
+** Note: This call does not free allocated memory.
+*/
+
+unsigned em_pagecount (void);
+/* Return the total number of 256 byte pages available in extended memory. */
+
+void* __fastcall__ em_map (unsigned page);
+/* Unmap the current page from memory and map a new one. The function returns
+** a pointer to the location of the page in memory. Note: Without calling
+** em_commit, the old contents of the memory window may be lost!
+*/
+
+void* __fastcall__ em_use (unsigned page);
+/* Tell the driver that the memory window is associated with a given page.
+** This call is very similar to em_map. The difference is that the driver
+** does not necessarily transfer the current contents of the extended
+** memory into the returned window. If you're going to just write to the
+** window and the current contents of the window are invalid or no longer
+** use, this call may perform better than em_map.
+*/
+
+void em_commit (void);
+/* Commit changes in the memory window to extended storage. If the contents
+** of the memory window have been changed, these changes may be lost if
+** em_map, em_copyfrom or em_copyto are called without calling em_commit
+** first. Note: Not calling em_commit does not mean that the changes are
+** discarded, it does just mean that some drivers will discard the changes.
+*/
+
+void __fastcall__ em_copyfrom (const struct em_copy* copy_data);
+/* Copy from extended into linear memory. Note: This may invalidate the
+** currently mapped page.
+*/
+
+void __fastcall__ em_copyto (const struct em_copy* copy_data);
+/* Copy from linear into extended memory. Note: This may invalidate the
+** currently mapped page.
+*/
+
+
+
+/* End of em.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* em-kernel.h */
+/* */
+/* Internally used EM functions */
+/* */
+/* */
+/* */
+/* (C) 2002-2003 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _EM_KERNEL_H
+#define _EM_KERNEL_H
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* A structure that describes the header of an extended memory driver loaded
+** into memory.
+*/
+typedef struct {
+
+ /* Driver header */
+ char id[3]; /* Contains 0x65, 0x6d, 0x64 ("emd") */
+ unsigned char version; /* Interface version */
+ void* libreference; /* Library reference */
+
+ /* Jump vectors. Note that these are not C callable */
+ void* install; /* INSTALL routine */
+ void* deinstall; /* DEINSTALL routine */
+ void* pagecount; /* PAGECOUNT routine */
+ void* map; /* MAP routine */
+ void* use; /* USE routine */
+ void* mapclean; /* MAPCLEAN routine */
+ void* copyfrom; /* COPYFROM routine */
+ void* copyto; /* COPYTO routine */
+
+} em_drv_header;
+
+
+
+/* EM kernel variables */
+extern em_drv_header* em_drv; /* Pointer to driver */
+
+
+
+/* End of em-kernel.h */
+#endif
+/*****************************************************************************/
+/* */
+/* errno.h */
+/* */
+/* Error codes */
+/* */
+/* */
+/* */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _ERRNO_H
+#define _ERRNO_H
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Operating system specific error code */
+extern unsigned char __oserror;
+
+#if __CC65_STD__ >= __CC65_STD_CC65__
+/* define the name with just one underscore for backwards compatibility */
+#define _oserror __oserror
+#endif
+
+extern int __errno;
+/* System errors go here */
+
+#define errno __errno
+/* errno must be a macro */
+
+
+
+/* Possible error codes */
+#define ENOENT 1 /* No such file or directory */
+#define ENOMEM 2 /* Out of memory */
+#define EACCES 3 /* Permission denied */
+#define ENODEV 4 /* No such device */
+#define EMFILE 5 /* Too many open files */
+#define EBUSY 6 /* Device or resource busy */
+#define EINVAL 7 /* Invalid argument */
+#define ENOSPC 8 /* No space left on device */
+#define EEXIST 9 /* File exists */
+#define EAGAIN 10 /* Try again */
+#define EIO 11 /* I/O error */
+#define EINTR 12 /* Interrupted system call */
+#define ENOSYS 13 /* Function not implemented */
+#define ESPIPE 14 /* Illegal seek */
+#define ERANGE 15 /* Range error */
+#define EBADF 16 /* Bad file number */
+#define ENOEXEC 17 /* Exec format error */
+#define EUNKNOWN 18 /* Unknown OS specific error */
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+int __fastcall__ __osmaperrno (unsigned char oserror);
+/* Map an operating system specific error code (for example from __oserror)
+** into one of the E... codes above. It is user callable.
+*/
+
+#if __CC65_STD__ >= __CC65_STD_CC65__
+/* define the name with just one underscore for backwards compatibility */
+#define _osmaperrno __osmaperrno
+#endif
+
+unsigned char __fastcall__ __seterrno (unsigned char code);
+/* Set errno to a specific error code and return zero. Used by the library */
+
+#if __CC65_STD__ >= __CC65_STD_CC65__
+/* define the name with just one underscore for backwards compatibility */
+#define _seterrno __seterrno
+#endif
+
+int __fastcall__ __directerrno (unsigned char code);
+/* Set errno to a specific error code, clear __oserror and return -1. Used
+** by the library.
+*/
+
+#if __CC65_STD__ >= __CC65_STD_CC65__
+/* define the name with just one underscore for backwards compatibility */
+#define _directerrno __directerrno
+#endif
+
+int __fastcall__ __mappederrno (unsigned char code);
+/* Set __oserror to the given platform specific error code. If it is a real
+** error code (not zero) set errno to the corresponding system error code
+** and return -1. Otherwise return zero.
+** Used by the library.
+*/
+
+#if __CC65_STD__ >= __CC65_STD_CC65__
+/* define the name with just one underscore for backwards compatibility */
+#define _mappederrno __mappederrno
+#endif
+
+/* End of errno.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* fcntl.h */
+/* */
+/* File control operations */
+/* */
+/* */
+/* */
+/* (C) 1998-2004 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _FCNTL_H
+#define _FCNTL_H
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Flag values for the open() call */
+#define O_RDONLY 0x01
+#define O_WRONLY 0x02
+#define O_RDWR 0x03
+#define O_CREAT 0x10
+#define O_TRUNC 0x20
+#define O_APPEND 0x40
+#define O_EXCL 0x80
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+/* Functions */
+int open (const char* name, int flags, ...); /* May take a mode argument */
+int __fastcall__ close (int fd);
+int __fastcall__ creat (const char* name, unsigned mode);
+
+
+
+/* End of fcntl.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* gamate.h */
+/* */
+/* Gamate system specific definitions */
+/* */
+/* */
+/* */
+/* (w) 2015 Groepaz/Hitmen (groepaz@gmx.net) */
+/* based on technical reference by PeT (mess@utanet.at) */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+#ifndef _GAMATE_H
+#define _GAMATE_H
+
+/* Check for errors */
+#if !defined(__GAMATE__)
+# error This module may only be used when compiling for the Gamate!
+#endif
+
+#define AUDIO_BASE 0x4000
+
+/*
+ base clock cpu clock/32 ?
+
+0/1: 1. channel(right): 12 bit frequency: right frequency 0 nothing, 1 high;
+ 3 23khz; 4 17,3; 10 6,9; 15 4.6; $60 720hz; $eff 18,0; $fff 16,9 hz)
+ (delay clock/32)
+2/3: 2. channel(left): 12 bit frequency
+4/5: 3. channel(both): 12 bit frequency
+6: 0..5 noise frequency 0 fast 1f slow (about 500us) 15.6ns--> clock/32 counts
+7 control (hinibble right)
+ bit 0: right channel high (full cycle, else square pulse/tone)
+ bit 1: left channel high
+ bit 2: both channel high
+ bit 3: set right tone (else noise)
+ bit 4: set left channel normal
+ bit 5: set both normal
+ bits 30: 11 high, 10 square, 01 noise, 00 noise only when square high
+ noise means switches channel to ad converter based noise algorithmen
+ (white noise shift register 17bit wide, repeats after about 130000 cycles)
+ probably out=!bit16, bit0=bit16 xor bit13; runs through, so start value anything than 0
+8: 1st volume: 0..3 square volume; bit 4 envelope (higher priority)
+9: 2nd volume
+10: 3rd volume
+11/12: envelope delay time 0 fast, 0xffff slow/nearly no effect (2 22us, 4 56us)
+ frequency $800, envelope $10 2 times in pulse high time (4*16*16)
+13: envelope control
+ 0-3 one time falling
+ 4-7 one time rising
+ 8 falling
+ 9 one time falling
+ a starts with down falling, rising; same falling time, but double/longer cycle
+ b one time falling, on
+ c rising
+ d one time rising, on
+ e rising, falling (double cycle before restart)
+ f one time rising
+ bit 0: once only
+ bit 1: full tone
+ bit 2: start rising (else falling)
+ bit 3:
+*/
+
+/* LCD
+
+ resolution 160x152 in 4 greys/greens
+ 2 256x256 sized bitplanes (2x 8kbyte ram)
+*/
+#define LCD_BASE 0x5000
+
+#define LCD_MODE 0x5001
+/*
+ bit 3..0 (from zeropage 15)
+ bit 0 set no normal screen display, seldom scrolling effects on screen;
+ bytes written to somewhat actual display refresh position!?
+ bytes read "random"
+ bit 1,2,3 no effect
+ bit 4 swaps plane intensity
+ bit 5 ? display effect
+ bit 6 on y auto increment (else auto x increment), reading
+ bit 7 ? lcd flickering
+*/
+#define LCD_MODE_INC_Y 0x40
+
+#define LCD_XPOS 0x5002 /* smooth scrolling X */
+#define LCD_YPOS 0x5003 /* smooth scrolling Y */
+/*
+ smooth scrolling until $c8 with 200 limit
+ after 200 display if ((value & 0xf) < 8) display of (value & 0xf) - 8
+ chaos lines from value + current line from plane 2 only then lines starting
+ with zero (problematic 200 limit/overrun implementation!?)
+*/
+#define LCD_X 0x5004 /* x-addr */
+/*
+ bit 5,6 no effect
+ bit 7 0 1st/1 2nd bitplane
+*/
+#define LCD_XPOS_PLANE1 0x00
+#define LCD_XPOS_PLANE2 0x80
+
+#define LCD_Y 0x5005 /* y-addr */
+
+#define LCD_READ 0x5006 /* read from RAM (no auto inc?) */
+#define LCD_DATA 0x5007 /* write to RAM */
+
+/* BIOS zeropage usage */
+
+/* locations 0x0a-0x0c, 0x0e-0x11 and 0xe8 are in use by the BIOS IRQ/NMI handlers */
+#define ZP_NMI_4800 0x0a /* content of I/O reg 4800 gets copied here each NMI */
+
+#define ZP_IRQ_COUNT 0x0b /* increments once per IRQ, used elsewhere in the
+ BIOS for synchronisation purposes */
+#define ZP_IRQ_CTRL 0x0c /* if 0 then cartridge irq stubs will not get called */
+
+/* each of the following 4 increments by 1 per IRQ - it is _not_ a 32bit
+ counter (see code at $ffa6 in BIOS)
+ these are not used elsewhere in the bios and can be (re)set as needed by
+ the user.
+*/
+#define ZP_IRQ_CNT1 0x0e
+#define ZP_IRQ_CNT2 0x0f
+#define ZP_IRQ_CNT3 0x10
+#define ZP_IRQ_CNT4 0x11
+
+#define ZP_NMI_FLAG 0xe8 /* set to 0xff each NMI */
+
+/* constants for the conio implementation */
+#define COLOR_BLACK 0x03
+#define COLOR_GRAY2 0x02
+#define COLOR_GRAY1 0x01
+#define COLOR_WHITE 0x00
+
+#define CH_HLINE 1
+#define CH_VLINE 2
+#define CH_CROSS 3
+#define CH_ULCORNER 4
+#define CH_URCORNER 5
+#define CH_LLCORNER 6
+#define CH_LRCORNER 7
+#define CH_TTEE 8
+#define CH_BTEE 9
+
+#define CH_RTEE 11
+#define CH_LTEE 12
+
+#define CH_ENTER 13
+#define CH_PI 18
+
+#define TV_NTSC 0
+#define TV_PAL 1
+#define TV_OTHER 2
+
+/* No support for dynamically loadable drivers */
+#define DYN_DRV 0
+
+#define JOY_DATA 0x4400 /* hw register to read the pad bits from */
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x01
+#define JOY_DOWN_MASK 0x02
+#define JOY_LEFT_MASK 0x04
+#define JOY_RIGHT_MASK 0x08
+#define JOY_BTN_1_MASK 0x10
+#define JOY_BTN_2_MASK 0x20
+#define JOY_BTN_3_MASK 0x40
+#define JOY_BTN_4_MASK 0x80
+
+#define JOY_BTN_A_MASK JOY_BTN_1_MASK
+#define JOY_BTN_B_MASk JOY_BTN_2_MASK
+#define JOY_START_MASK JOY_BTN_3_MASK
+#define JOY_SELECT_MASK JOY_BTN_4_MASK
+
+#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
+#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
+#define JOY_START(v) ((v) & JOY_START_MASK)
+#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
+
+/* The addresses of the static drivers */
+extern void gamate_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
+
+void waitvsync (void);
+/* Wait for start of next frame */
+
+/* NOTE: all Gamate are "NTSC" */
+#define get_tv() TV_NTSC
+/* Return the video mode the machine is using. */
+
+/* End of gamate.h */
+#endif
+
+/*
+ Supreme GEOS header file
+ includes all other headers
+
+ Maciej 'YTM/Elysium' Witkowiak, 27.10.1999
+*/
+
+
+
+#ifndef _GEOS_H
+#define _GEOS_H
+
+
+
+/* Check for errors */
+#if !defined(__GEOS__)
+# error This module may only be used when compiling for GEOS!
+#endif
+
+
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+
+#define CH_ULCORNER '+'
+#define CH_URCORNER '+'
+#define CH_LLCORNER '+'
+#define CH_LRCORNER '+'
+#define CH_TTEE '+'
+#define CH_RTEE '+'
+#define CH_BTEE '+'
+#define CH_LTEE '+'
+#define CH_CROSS '+'
+
+#define CH_F1 KEY_F1
+#define CH_F2 KEY_F2
+#define CH_F3 KEY_F3
+#define CH_F4 KEY_F4
+#define CH_F5 KEY_F5
+#define CH_F6 KEY_F6
+#define CH_F7 KEY_F7
+#define CH_F8 KEY_F8
+
+#define CH_CURS_UP KEY_UP
+#define CH_CURS_DOWN KEY_DOWN
+#define CH_CURS_LEFT KEY_LEFT
+#define CH_CURS_RIGHT KEY_RIGHT
+#define CH_DEL KEY_DELETE
+#define CH_INS KEY_INSERT
+#define CH_ENTER KEY_ENTER
+#define CH_STOP KEY_STOP
+#define CH_ESC KEY_ESC
+
+#define COLOR_BLACK BLACK
+#define COLOR_WHITE WHITE
+#define COLOR_RED RED
+#define COLOR_CYAN CYAN
+#define COLOR_PURPLE PURPLE
+#define COLOR_GREEN GREEN
+#define COLOR_BLUE BLUE
+#define COLOR_YELLOW YELLOW
+#define COLOR_ORANGE ORANGE
+#define COLOR_BROWN BROWN
+#define COLOR_LIGHTRED LTRED
+#define COLOR_GRAY1 DKGREY
+#define COLOR_GRAY2 MEDGREY
+#define COLOR_LIGHTGREEN LTGREEN
+#define COLOR_LIGHTBLUE LTBLUE
+#define COLOR_GRAY3 LTGREY
+
+#define TGI_COLOR_BLACK COLOR_BLACK
+#define TGI_COLOR_WHITE COLOR_WHITE
+#define TGI_COLOR_RED COLOR_RED
+#define TGI_COLOR_CYAN COLOR_CYAN
+#define TGI_COLOR_PURPLE COLOR_PURPLE
+#define TGI_COLOR_GREEN COLOR_GREEN
+#define TGI_COLOR_BLUE COLOR_BLUE
+#define TGI_COLOR_YELLOW COLOR_YELLOW
+#define TGI_COLOR_ORANGE COLOR_ORANGE
+#define TGI_COLOR_BROWN COLOR_BROWN
+#define TGI_COLOR_LIGHTRED COLOR_LIGHTRED
+#define TGI_COLOR_GRAY1 COLOR_GRAY1
+#define TGI_COLOR_GRAY2 COLOR_GRAY2
+#define TGI_COLOR_LIGHTGREEN COLOR_LIGHTGREEN
+#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
+#define TGI_COLOR_GRAY3 COLOR_GRAY3
+
+#define JOY_UP_MASK 0x01
+#define JOY_DOWN_MASK 0x02
+#define JOY_LEFT_MASK 0x04
+#define JOY_RIGHT_MASK 0x08
+#define JOY_BTN_1_MASK 0x10
+
+
+
+/* End of geos.h */
+#endif
+/*
+ GEOS constants
+
+ reassembled by Maciej 'YTM/Elysium' Witkowiak
+*/
+
+/* Here are constants which didn't fit into any other category... */
+
+#ifndef _GCONST_H
+#define _GCONST_H
+
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+#define FALSE 0
+#define TRUE 0xff
+#define MOUSE_SPRNUM 0
+#define DISK_DRV_LGH 0x0d80
+
+/* drivetypes */
+#define DRV_NULL 0
+#define DRV_1541 1
+#define DRV_1571 2
+#define DRV_1581 3
+#define DRV_NETWORK 15
+
+/* various disk constants */
+#define REL_FILE_NUM 9
+#define CMND_FILE_NUM 15
+#define MAX_CMND_STR 32
+#define DIR_1581_TRACK 40
+#define DIR_ACC_CHAN 13
+#define DIR_TRACK 18
+#define N_TRACKS 35
+#define DK_NM_ID_LEN 18
+#define TRACK 9
+#define SECTOR 12
+#define TOTAL_BLOCKS 664
+
+/* offset to something */
+#define OFF_INDEX_PTR 1
+
+/* values for CPU_DATA memory config - C64 */
+#define IO_IN 0x35
+#define KRNL_IO_IN 0x36
+#define KRNL_BAS_IO_IN 0x37
+
+/* values for MMU config - C128 */
+#define CIOIN 0x7E
+#define CRAM64K 0x7F
+#define CKRNLBASIOIN 0x40
+#define CKRNLIOIN 0x4E
+
+/* alarmSetFlag */
+#define ALARMMASK 4
+
+#define CLR_SAVE 0x40
+#define CONSTRAINED 0x40
+#define UN_CONSTRAINED 0
+#define FG_SAVE 0x80
+
+#define FUTURE1 7
+#define FUTURE2 8
+#define FUTURE3 9
+#define FUTURE4 10
+#define USELAST 127
+#define SHORTCUT 128
+
+#endif
+/*
+ GEOS functions from disk driver
+
+ by Maciej 'YTM/Elysium' Witkowiak
+*/
+
+#ifndef _GDISK_H
+#define _GDISK_H
+
+#include
+
+char __fastcall__ ReadBuff(struct tr_se *myTrSe);
+char __fastcall__ WriteBuff(struct tr_se *myTrSe);
+
+char __fastcall__ GetBlock(struct tr_se *myTrSe, char *buffer);
+char __fastcall__ PutBlock(struct tr_se *myTrSe, const char *buffer);
+char __fastcall__ ReadBlock(struct tr_se *myTrSe, char *buffer);
+char __fastcall__ WriteBlock(struct tr_se *myTrSe, const char *buffer);
+char __fastcall__ VerWriteBlock(struct tr_se *myTrSe, const char *buffer);
+
+unsigned CalcBlksFree(void);
+char ChkDkGEOS(void);
+char SetGEOSDisk(void);
+char NewDisk(void);
+char OpenDisk(void);
+
+char __fastcall__ FindBAMBit(struct tr_se *myTrSe);
+char __fastcall__ BlkAlloc(struct tr_se output[], unsigned length);
+char __fastcall__ NxtBlkAlloc(struct tr_se *startTrSe,
+ struct tr_se output[], unsigned length);
+char __fastcall__ FreeBlock(struct tr_se *myTrSe);
+struct tr_se __fastcall__ SetNextFree(struct tr_se *myTrSe);
+// above needs (unsigned) casts on both sides of '='
+
+char GetDirHead(void);
+char PutDirHead(void);
+void __fastcall__ GetPtrCurDkNm(char *name);
+
+void EnterTurbo(void);
+void ExitTurbo(void);
+void PurgeTurbo(void);
+
+char __fastcall__ ChangeDiskDevice(char newdev);
+
+/* disk header offsets i.e. index curDirHead with these */
+#define OFF_TO_BAM 4
+#define OFF_DISK_NAME 144
+#define OFF_GS_DTYPE 189
+#define OFF_OP_TR_SC 171
+#define OFF_GS_ID 173
+/* disk errors reported in _oserror */
+#define ANY_FAULT 0xf0
+#define G_EOF 0
+#define NO_BLOCKS 1
+#define INV_TRACK 2
+#define INSUFF_SPACE 3
+#define FULL_DIRECTORY 4
+#define FILE_NOT_FOUND 5
+#define BAD_BAM 6
+#define UNOPENED_VLIR 7
+#define INV_RECORD 8
+#define OUT_OF_RECORDS 9
+#define STRUCT_MISMAT 10
+#define BFR_OVERFLOW 11
+#define CANCEL_ERR 12
+#define DEV_NOT_FOUND 13
+#define INCOMPATIBLE 14
+#define HDR_NOT_THERE 0x20
+#define NO_SYNC 0x21
+#define DBLK_NOT_THERE 0x22
+#define DAT_CHKSUM_ERR 0x23
+#define WR_VER_ERR 0x25
+#define WR_PR_ON 0x26
+#define HDR_CHKSUM_ERR 0x27
+#define DSK_ID_MISMAT 0x29
+#define BYTE_DEC_ERR 0x2e
+#define DOS_MISMATCH 0x73
+
+#endif
+/*
+ GEOS dialog box functions
+
+ by Maciej 'YTM/Elysium' Witkowiak
+*/
+
+#ifndef _GDLGBOX_H
+#define _GDLGBOX_H
+
+char __fastcall__ DoDlgBox(const char *dboxstring);
+char RstrFrmDialogue(void);
+
+/* These are custom, predefined dialog boxes, I'm sure you'll find them usable
+ Most of them show 2 lines of text */
+
+char __fastcall__ DlgBoxYesNo(const char *line1, const char *line2);
+char __fastcall__ DlgBoxOkCancel(const char *line1, const char *line2);
+void __fastcall__ DlgBoxOk(const char *line1, const char *line2);
+char __fastcall__ DlgBoxGetString(char *myString, char strLength,
+ const char *line1, const char *line2);
+char __fastcall__ DlgBoxFileSelect(const char *classtxt, char ftype,
+ char *fname);
+
+/* This is a more general dialog box, works like printf in a window */
+char MessageBox(char mode, const char *format, ...);
+
+/* mode argument for MessageBox() */
+enum {
+ MB_EMPTY=0,
+ MB_OK,
+ MB_OKCANCEL,
+ MB_YESNO,
+ MB_LAST };
+
+/* Now the command string type */
+
+typedef void dlgBoxStr;
+
+/* and command string commands - macros */
+
+#define DB_DEFPOS(pattern) (char)(DEF_DB_POS | (pattern))
+#define DB_SETPOS(pattern,top,bot,left,right) \
+ (char)(SET_DB_POS | (pattern)), (char)(top), (char)(bot), \
+ (unsigned)(left), (unsigned)(right)
+#define DB_ICON(i,x,y) (char)(i), (char)(x), (char)(y)
+#define DB_TXTSTR(x,y,text) (char)DBTXTSTR, (char)(x), (char)(y), (text)
+#define DB_VARSTR(x,y,ptr) (char)DBVARSTR, (char)(x), (char)(y), (char)(ptr)
+#define DB_GETSTR(x,y,ptr,length) (char)DBGETSTRING, (char)(x), (char)(y), (char)(ptr), (char)(length)
+#define DB_SYSOPV(ptr) (char)DBSYSOPV, (unsigned)(ptr)
+#define DB_GRPHSTR(ptr) (char)DBGRPHSTR, (unsigned)(ptr)
+#define DB_GETFILES(x,y) (char)DBGETFILES, (char)(x), (char)(y)
+#define DB_OPVEC(ptr) (char)DBOPVEC, (unsigned)(ptr)
+#define DB_USRICON(x,y,ptr) (char)DBUSRICON, (char)(x), (char)(y), (unsigned)(ptr)
+#define DB_USRROUT(ptr) (char)DB_USR_ROUT, (unsigned)(ptr)
+#define DB_END (char)NULL
+
+/*
+ part of constants below is used internally, but some are useful for macros above
+*/
+
+/* icons for DB_ICON */
+#define OK 1
+#define CANCEL 2
+#define YES 3
+#define NO 4
+#define OPEN 5
+#define DISK 6
+/* commands - internally used by command macros */
+#define DBTXTSTR 11
+#define DBVARSTR 12
+#define DBGETSTRING 13
+#define DBSYSOPV 14
+#define DBGRPHSTR 15
+#define DBGETFILES 16
+#define DBOPVEC 17
+#define DBUSRICON 18
+#define DB_USR_ROUT 19
+/* icons tabulation in standard window */
+#define DBI_X_0 1
+#define DBI_X_1 9
+#define DBI_X_2 17
+#define DBI_Y_0 8
+#define DBI_Y_1 40
+#define DBI_Y_2 72
+/* standard window size defaults */
+#define SET_DB_POS 0
+#define DEF_DB_POS 0x80
+#define DEF_DB_TOP 32
+#define DEF_DB_BOT 127
+#define DEF_DB_LEFT 64
+#define DEF_DB_RIGHT 255
+/* text tabulation in standard window */
+#define TXT_LN_1_Y 16
+#define TXT_LN_2_Y 32
+#define TXT_LN_3_Y 48
+#define TXT_LN_4_Y 64
+#define TXT_LN_5_Y 80
+#define TXT_LN_X 16
+/* system icons size */
+#define SYSDBI_HEIGHT 16
+#define SYSDBI_WIDTH 6
+/* dialogbox string offsets */
+#define OFF_DB_FORM 0
+#define OFF_DB_TOP 1
+#define OFF_DB_BOT 2
+#define OFF_DB_LEFT 3
+#define OFF_DB_RIGHT 5
+#define OFF_DB_1STCMD 7
+
+#endif
+/*
+ GEOS filesystem functions
+
+ by Maciej 'YTM/Elysium' Witkowiak
+*/
+
+#ifndef _GFILE_H
+#define _GFILE_H
+
+#include
+
+struct filehandle *Get1stDirEntry(void);
+struct filehandle *GetNxtDirEntry(void);
+
+char __fastcall__ FindFTypes(char *buffer, char ftype, char fmaxnum, const char *classtxt);
+
+char __fastcall__ GetFile(char flag, const char *fname,
+ const char *loadaddr, const char *datadname, const char *datafname);
+char __fastcall__ FindFile(const char *fname);
+char __fastcall__ ReadFile(struct tr_se *myTrSe, char *buffer, unsigned flength);
+char __fastcall__ SaveFile(char skip, struct fileheader *myHeader);
+char __fastcall__ FreeFile(struct tr_se myTable[]);
+char __fastcall__ DeleteFile(const char *fname);
+char __fastcall__ RenameFile(const char *source, const char *target);
+
+char ReadByte(void);
+
+char __fastcall__ FollowChain(struct tr_se *startTrSe, char *buffer);
+char __fastcall__ GetFHdrInfo(struct filehandle *myFile);
+
+char __fastcall__ OpenRecordFile(const char *fname);
+char CloseRecordFile(void);
+char NextRecord(void);
+char PreviousRecord(void);
+char __fastcall__ PointRecord(char);
+char DeleteRecord(void);
+char InsertRecord(void);
+char AppendRecord(void);
+char __fastcall__ ReadRecord(char *buffer, unsigned flength);
+char __fastcall__ WriteRecord(const char *buffer, unsigned flength);
+char UpdateRecordFile(void);
+
+/* GEOS filetypes */
+#define NOT_GEOS 0
+#define BASIC 1
+#define ASSEMBLY 2
+#define DATA 3
+#define SYSTEM 4
+#define DESK_ACC 5
+#define APPLICATION 6
+#define APPL_DATA 7
+#define FONT 8
+#define PRINTER 9
+#define INPUT_DEVICE 10
+#define DISK_DEVICE 11
+#define SYSTEM_BOOT 12
+#define TEMPORARY 13
+#define AUTO_EXEC 14
+#define INPUT_128 15
+#define NUMFILETYPES 16
+/* supported structures */
+#define SEQUENTIAL 0
+#define VLIR 1
+/* DOS filetypes */
+#define DEL 0
+#define SEQ 1
+#define PRG 2
+#define USR 3
+#define REL 4
+#define CBM 5
+
+#endif
+/*
+ GEOS graphic (non icon/menu/sprite) functions
+
+ by Maciej 'YTM/Elysium' Witkowiak
+*/
+
+#ifndef _GGRAPH_H
+#define _GGRAPH_H
+
+#include
+
+void __fastcall__ SetPattern(char newpattern);
+
+void __fastcall__ HorizontalLine(char pattern, char y, unsigned xstart, unsigned xend);
+void __fastcall__ InvertLine(char y, unsigned xstart, unsigned xend);
+void __fastcall__ RecoverLine(char y, unsigned xstart, unsigned xend);
+void __fastcall__ VerticalLine(char pattern, char ystart, char yend, unsigned x);
+
+void __fastcall__ InitDrawWindow(struct window *myRectangle);
+void Rectangle(void);
+void __fastcall__ FrameRectangle(char pattern);
+void InvertRectangle(void);
+void ImprintRectangle(void);
+void RecoverRectangle(void);
+
+void __fastcall__ DrawLine(char mode, struct window *topBotCoords);
+
+void __fastcall__ DrawPoint(char mode, struct pixel *myPixel);
+char __fastcall__ TestPoint(struct pixel *myPixel);
+
+void __fastcall__ PutChar(char character, char y, unsigned x);
+void __fastcall__ PutString(char *myString, char y, unsigned x);
+void __fastcall__ PutDecimal(char style, unsigned value, char y, unsigned x);
+
+char __fastcall__ GetCharWidth(char character);
+void __fastcall__ LoadCharSet(struct fontdesc *myFont);
+void UseSystemFont(void);
+
+void __fastcall__ BitmapUp(struct iconpic *myIcon);
+void __fastcall__ BitmapClip(char skipl, char skipr, unsigned skiptop,
+ struct iconpic *myIcon);
+void __fastcall__ BitOtherClip(void *proc1, void *proc2, char skipl,
+ char skipr, unsigned skiptop,
+ struct iconpic *myIcon);
+
+void __fastcall__ GraphicsString(const void *myGfxString);
+
+#ifdef __GEOS_CBM__
+void SetNewMode(void);
+#endif
+
+/* VIC colour constants */
+#define BLACK 0
+#define WHITE 1
+#define RED 2
+#define CYAN 3
+#define PURPLE 4
+#define GREEN 5
+#define BLUE 6
+#define YELLOW 7
+#define ORANGE 8
+#define BROWN 9
+#define LTRED 10
+#define DKGREY 11
+#define GREY 12
+#define MEDGREY 12
+#define LTGREEN 13
+#define LTBLUE 14
+#define LTGREY 15
+/* VIC memory banks - lowest 2 bits of cia2base+0 */
+#define GRBANK0 3
+#define GRBANK1 2
+#define GRBANK2 1
+#define GRBANK3 0
+/* VIC screen sizes */
+#define VIC_X_POS_OFF 24
+#define VIC_Y_POS_OFF 50
+#ifdef __GEOS_CBM__
+#define SC_BYTE_WIDTH 40
+#define SC_PIX_HEIGHT 200
+#define SC_PIX_WIDTH 320
+#define SC_SIZE 8000
+#else
+#define SC_BYTE_WIDTH 70
+#define SC_PIX_HEIGHT 192
+#define SC_PIX_WIDTH 560
+#define SC_SIZE 13440
+#endif
+/* VDC screen constants */
+#define SCREENBYTEWIDTH 80
+#define SCREENPIXELWIDTH 640
+/* control characters for use as numbers, not characters */
+#define BACKSPACE 8
+#define FORWARDSPACE 9
+#define TAB 9
+#define LF 10
+#define HOME 11
+#define PAGE_BREAK 12
+#define UPLINE 12
+#define CR 13
+#define ULINEON 14
+#define ULINEOFF 15
+#define ESC_GRAPHICS 16
+#define ESC_RULER 17
+#define REV_ON 18
+#define REV_OFF 19
+#define GOTOX 20
+#define GOTOY 21
+#define GOTOXY 22
+#define NEWCARDSET 23
+#define BOLDON 24
+#define ITALICON 25
+#define OUTLINEON 26
+#define PLAINTEXT 27
+/* control characters for use in
+ strings: eg: str[10]=CBOLDON "Hello"; */
+#define CCR "\015"
+#define CULINEON "\016"
+#define CULINEOFF "\017"
+#define CREV_ON "\022"
+#define CREV_OFF "\023"
+#define CBOLDON "\030"
+#define CITALICON "\031"
+#define COUTLINEON "\032"
+#define CPLAINTEXT "\033"
+
+/*values of currentMode */
+/* bitNumbers */
+#define UNDERLINE_BIT 7
+#define BOLD_BIT 6
+#define REVERSE_BIT 5
+#define ITALIC_BIT 4
+#define OUTLINE_BIT 3
+#define SUPERSCRIPT_BIT 2
+#define SUBSCRIPT_BIT 1
+/* bitMasks */
+#define SET_UNDERLINE 0x80
+#define SET_BOLD 0x40
+#define SET_REVERSE 0x20
+#define SET_ITALIC 0x10
+#define SET_OUTLINE 0x08
+#define SET_SUPERSCRIPT 0x04
+#define SET_SUBSCRIPT 0x02
+#define SET_PLAINTEXT 0
+/* values of dispBufferOn */
+#define ST_WRGS_FORE 0x20
+#define ST_WR_BACK 0x40
+#define ST_WR_FORE 0x80
+/* PutDecimal parameters */
+/* leading zeros? */
+#define SET_NOSURPRESS 0
+#define SET_SURPRESS 0x40
+/* justification */
+#define SET_RIGHTJUST 0
+#define SET_LEFTJUST 0x80
+/* C128 x-extension flags */
+#define ADD1_W 0x2000
+#define DOUBLE_B 0x80
+#define DOUBLE_W 0x8000
+/* DrawLine/DrawPoint mode values */
+#define DRAW_ERASE 0x00
+#define DRAW_DRAW 0x40
+#define DRAW_COPY 0x80
+
+typedef void graphicStr;
+
+#define MOVEPENTO(x,y) (char)1, (unsigned)(x), (char)(y)
+#define LINETO(x,y) (char)2, (unsigned)(x), (char)(y)
+#define RECTANGLETO(x,y) (char)3, (unsigned)(x), (char)(y)
+#define NEWPATTERN(p) (char)5, (char)(p)
+#define FRAME_RECTO(x,y) (char)7, (unsigned)(x), (char)(y)
+#define PEN_X_DELTA(x) (char)8, (unsigned)(x)
+#define PEN_Y_DELTA(y) (char)9, (char)(y)
+#define PEN_XY_DELTA(x,y) (char)10, (unsigned)(x), (char)(y)
+#define GSTR_END (char)NULL
+/* ESC_PUTSTRING can't be implemented - it needs text, not pointer to it
+ #define ESC_PUTSTRING(x,y,text) (char)6, (unsigned)(x), (char)(y), (text), (char)NULL
+*/
+
+#endif
+/*
+ GEOS memory and string functions
+
+ by Maciej 'YTM/Elysium' Witkowiak
+*/
+
+#ifndef _GMEMORY_H
+#define _GMEMORY_H
+
+#include
+
+void __fastcall__ CopyString(char *dest, const char *source);
+char __fastcall__ CmpString(const char *dest, const char *source);
+void __fastcall__ CopyFString(char len, char *dest, const char *source);
+char __fastcall__ CmpFString(char len, char *dest, const char *source);
+
+unsigned __fastcall__ CRC(const char *buffer, unsigned len);
+void* __fastcall__ ClearRam(char *dest, unsigned len);
+void* __fastcall__ FillRam(char *dest, char what, unsigned len);
+
+void* __fastcall__ MoveData(char *dest, const char *source, unsigned len);
+
+void __fastcall__ InitRam(char *myInitTab);
+
+void __fastcall__ StashRAM(char REUBank, unsigned len, char *reuaddy, const char *cpuaddy);
+void __fastcall__ FetchRAM(char REUBank, unsigned len, const char *reuaddy, char *cpuaddy);
+void __fastcall__ SwapRAM(char REUBank, unsigned len, char *reuaddy, char *cpuaddy);
+char __fastcall__ VerifyRAM(char REUBank, unsigned len, const char *reuaddy, const char *cpuaddy);
+
+#endif
+/*
+ GEOS menu and icon functions
+
+ by Maciej 'YTM/Elysium' Witkowiak
+*/
+
+#ifndef _GMENU_H
+#define _GMENU_H
+
+#include
+
+void __fastcall__ DoMenu(struct menu *myMenu);
+void ReDoMenu(void);
+void RecoverMenu(void);
+void RecoverAllMenus(void);
+void DoPreviousMenu(void);
+void GotoFirstMenu(void);
+
+void __fastcall__ DoIcons(struct icontab *myIconTab);
+
+/* DoMenu - menutypes */
+#define MENU_ACTION 0x00
+#define DYN_SUB_MENU 0x40
+#define SUB_MENU 0x80
+#define HORIZONTAL 0x00
+#define VERTICAL 0x80
+/* menu string offsets */
+#define OFF_MY_TOP 0
+#define OFF_MY_BOT 1
+#define OFF_MX_LEFT 2
+#define OFF_MX_RIGHT 4
+#define OFF_NUM_M_ITEMS 6
+#define OFF_1ST_M_ITEM 7
+/* icon string offsets */
+#define OFF_NM_ICNS 0
+#define OFF_IC_XMOUSE 1
+#define OFF_IC_YMOUSE 3
+#define OFF_PIC_ICON 0
+#define OFF_X_ICON_POS 2
+#define OFF_Y_ICON_POS 3
+#define OFF_WDTH_ICON 4
+#define OFF_HEIGHT_ICON 5
+#define OFF_SRV_RT_ICON 6
+#define OFF_NX_ICON 8
+/* icons, menus status flags */
+#define ST_FLASH 0x80
+#define ST_INVERT 0x40
+#define ST_LD_AT_ADDR 0x01
+#define ST_LD_DATA 0x80
+#define ST_PR_DATA 0x40
+#define ST_WR_PR 0x40
+
+#endif
+/*
+ GEOS processes (~multitasking) functions
+
+ by Maciej 'YTM/Elysium' Witkowiak
+*/
+
+#ifndef _GPROCESS_H
+#define _GPROCESS_H
+
+#include
+
+void __fastcall__ InitProcesses(char number, struct process *proctab);
+void __fastcall__ RestartProcess(char number);
+void __fastcall__ EnableProcess(char number);
+void __fastcall__ BlockProcess(char number);
+void __fastcall__ UnblockProcess(char number);
+void __fastcall__ FreezeProcess(char number);
+void __fastcall__ UnfreezeProcess(char number);
+
+void __fastcall__ Sleep(unsigned jiffies);
+
+#endif
+/*
+ GEOS mouse and sprite functions
+
+ by Maciej 'YTM/Elysium' Witkowiak
+*/
+
+#ifndef _GSPRITE_H
+#define _GSPRITE_H
+
+void StartMouseMode(void);
+void ClearMouseMode(void);
+void MouseUp(void);
+void MouseOff(void);
+char __fastcall__ IsMseInRegion(struct window *region);
+
+void __fastcall__ DrawSprite(char spritenum, const char *spritepic);
+void __fastcall__ PosSprite(char spritenum, struct pixel *position);
+void __fastcall__ EnablSprite(char spritenum);
+void __fastcall__ DisablSprite(char spritenum);
+
+void __fastcall__ InitTextPrompt(char height);
+void __fastcall__ PromptOn(struct pixel *position);
+void PromptOff(void);
+char GetNextChar(void);
+
+/* keyboard constants */
+#define KEY_F1 1
+#define KEY_F2 2
+#define KEY_F3 3
+#define KEY_F4 4
+#define KEY_F5 5
+#define KEY_F6 6
+#define KEY_NOSCRL 7
+#define KEY_ENTER 13
+#define KEY_F7 14
+#define KEY_F8 15
+#define KEY_HOME 18
+#define KEY_CLEAR 19
+#define KEY_LARROW 20
+#define KEY_UPARROW 21
+#define KEY_STOP 22
+#define KEY_RUN 23
+#define KEY_BPS 24
+#define KEY_HELP 25
+#define KEY_ALT 26
+#define KEY_ESC 27
+#define KEY_INSERT 28
+#define KEY_INVALID 31
+#define KEY_LEFT BACKSPACE
+#ifdef __GEOS_CBM__
+#define KEY_UP 16
+#define KEY_DOWN 17
+#define KEY_DELETE 29
+#define KEY_RIGHT 30
+#else
+#define KEY_UP 11
+#define KEY_DOWN 10
+#define KEY_DELETE 127
+#define KEY_RIGHT 21
+#endif
+
+/* values of faultData - pointer position vs. mouseWindow */
+/* bit numbers */
+#define OFFTOP_BIT 7
+#define OFFBOTTOM_BIT 6
+#define OFFLEFT_BIT 5
+#define OFFRIGHT_BIT 4
+#define OFFMENU_BIT 3
+/* bit masks */
+#define SET_OFFTOP 0x80
+#define SET_OFFBOTTOM 0x40
+#define SET_OFFLEFT 0x20
+#define SET_OFFRIGHT 0x10
+#define SET_OFFMENU 0x08
+
+/* mouseOn */
+/* bit numbers */
+#define MOUSEON_BIT 7
+#define MENUON_BIT 6
+#define ICONSON_BIT 5
+/* bit masks */
+#define SET_MSE_ON 0x80
+#define SET_MENUON 0x40
+#define SET_ICONSON 0x20
+
+/* pressFlag */
+/* bit numbers */
+#define KEYPRESS_BIT 7
+#define INPUT_BIT 6
+#define MOUSE_BIT 5
+/* bit masks */
+#define SET_KEYPRESS 0x80
+#define SET_INPUTCHG 0x40
+#define SET_MOUSE 0x20
+
+#endif
+/*
+ GEOS structs
+
+ by Maciej 'YTM/Elysium' Witkowiak
+*/
+
+/*
+ apart from initializing data, structures below can be used to
+ speed up access to data and let cc65 to generate better code
+ e.g. if you have menu defined as TopMenu and you want to change the number of
+ menu items use:
+ ((struct menu*)&TopMenu)->number=newNumber;
+ This will be translated into single lda/sta pair
+*/
+
+#ifndef _GSTRUCT_H
+#define _GSTRUCT_H
+
+typedef void (*void_func) (void);
+
+struct s_date { /* system date & time */
+ char s_year;
+ char s_month;
+ char s_day;
+ char s_hour;
+ char s_minutes;
+ char s_seconds;
+};
+
+struct tr_se { /* track and sector */
+ char track;
+ char sector;
+};
+
+struct fileheader { /* header block (like fileHeader) */
+ struct tr_se n_block;
+ char icon_desc[3];
+ char icon_pic[63];
+ char dostype;
+ char type;
+ char structure;
+ unsigned load_address;
+ unsigned end_address;
+ unsigned exec_address;
+ char class_name[19];
+ char column_flag;
+ char author[63];
+ char note[96];
+};
+
+#ifdef __GEOS_CBM__
+
+struct f_date { /* date in filedesctiptor */
+ char f_year;
+ char f_month;
+ char f_day;
+ char f_hour;
+ char f_minute;
+};
+
+struct filehandle { /* filehandle in directory sectors */
+ char dostype; /* or in dirEntryBuf */
+ struct tr_se n_block;
+ char name[16];
+ struct tr_se header;
+ char structure;
+ char type;
+ struct f_date date;
+ unsigned size;
+};
+
+#else /* #ifdef __GEOS_CBM__ */
+
+struct f_date { /* date in filedesctiptor */
+ unsigned f_day:5;
+ unsigned f_month:4;
+ unsigned f_year:7;
+ char f_minute;
+ char f_hour;
+};
+
+struct filehandle { /* filehandle in directory sectors */
+ unsigned name_len:4; /* or in dirEntryBuf */
+ unsigned structure:4;
+ char name[15];
+ char type;
+ struct tr_se n_block;
+ unsigned size;
+ char byte_size[3];
+ struct f_date date;
+ char version;
+ char min_version;
+ char access;
+ struct tr_se header;
+ struct f_date mod_date;
+ struct tr_se dir_head;
+};
+
+#endif /* #ifdef __GEOS_CBM__ */
+
+struct pixel { /* describes point */
+ unsigned x;
+ char y;
+};
+
+struct fontdesc { /* describes font */
+ char baseline;
+ char width;
+ char height;
+ char *index_tbl;
+ char *data_ptr;
+};
+
+struct window { /* describes screen region */
+ char top;
+ char bot;
+ unsigned left;
+ unsigned right;
+};
+
+struct VLIR_info { /* VLIR information */
+ char curRecord; /* currently only used in VLIR */
+ char usedRecords; /* as system info (curRecord is mainly of your interest */
+ char fileWritten;
+ unsigned fileSize;
+};
+
+struct process { /* process info, declare table of that type */
+ unsigned pointer; /* (like: struct process proctab[2]= ... */
+ unsigned jiffies; /* last entry MUST BE {0,0} */
+};
+
+struct iconpic { /* icon/encoded bitmap description */
+ char *pic_ptr; /* ptr to a photo scrap (or encoded bitmap) */
+ char x; /* position in cards (*8 pixels) */
+ char y;
+ char width; /* in cards */
+ char height; /* in lines (pixels) */
+};
+
+struct icondef { /* icon definition for DoIcons */
+ char *pic_ptr; /* ptr to a photo scrap (or encoded bitmap) */
+ char x; /* position in cards (*8 pixels) */
+ char y;
+ char width; /* of icon (in cards) */
+ char height; /* of icon in lines (pixels) */
+ unsigned proc_ptr; /* pointer to function handling that icon */
+};
+
+struct icontab {
+ char number; /* number of declared icons */
+ struct pixel mousepos; /* position of mouse after DoIcons */
+ struct icondef tab[]; /* table of size declared by icontab.number */
+};
+
+struct menuitem {
+ char *name;
+ char type;
+ void *rest; /* may be ptr to function, or ptr to struct menu (submenu) */
+};
+
+struct menu {
+ struct window size;
+ char number;
+ struct menuitem items[];
+};
+
+struct inittab { /* use struct inittab mytab[n] for initram */
+ unsigned ptr; /* ptr to 1st byte */
+ char number; /* number of following bytes */
+ char values[]; /* actual string of bytes */
+};
+
+#endif
+/*
+ GEOS system addresses and locations
+
+ reassembled by Maciej 'YTM/Elysium' Witkowiak
+*/
+
+#ifndef _GSYM_H
+#define _GSYM_H
+
+#include
+
+#define r0 (*(unsigned*)(R_BASE + 0x00))
+#define r0L (*(char*)(R_BASE + 0x00))
+#define r0H (*(char*)(R_BASE + 0x01))
+#define r1 (*(unsigned*)(R_BASE + 0x02))
+#define r1L (*(char*)(R_BASE + 0x02))
+#define r1H (*(char*)(R_BASE + 0x03))
+#define drawWindow (*(struct window*)(R_BASE + 0x04))
+#define r2 (*(unsigned*)(R_BASE + 0x04))
+#define r2L (*(char*)(R_BASE + 0x04))
+#define r2H (*(char*)(R_BASE + 0x05))
+#define r3 (*(unsigned*)(R_BASE + 0x06))
+#define r3L (*(char*)(R_BASE + 0x06))
+#define r3H (*(char*)(R_BASE + 0x07))
+#define r4 (*(unsigned*)(R_BASE + 0x08))
+#define r4L (*(char*)(R_BASE + 0x08))
+#define r4H (*(char*)(R_BASE + 0x09))
+#define r5 (*(unsigned*)(R_BASE + 0x0a))
+#define r5L (*(char*)(R_BASE + 0x0a))
+#define r5H (*(char*)(R_BASE + 0x0b))
+#define r6 (*(unsigned*)(R_BASE + 0x0c))
+#define r6L (*(char*)(R_BASE + 0x0c))
+#define r6H (*(char*)(R_BASE + 0x0d))
+#define r7 (*(unsigned*)(R_BASE + 0x0e))
+#define r7L (*(char*)(R_BASE + 0x0e))
+#define r7H (*(char*)(R_BASE + 0x0f))
+#define r8 (*(unsigned*)(R_BASE + 0x10))
+#define r8L (*(char*)(R_BASE + 0x10))
+#define r8H (*(char*)(R_BASE + 0x11))
+#define r9 (*(unsigned*)(R_BASE + 0x12))
+#define r9L (*(char*)(R_BASE + 0x12))
+#define r9H (*(char*)(R_BASE + 0x13))
+#define r10 (*(unsigned*)(R_BASE + 0x14))
+#define r10L (*(char*)(R_BASE + 0x14))
+#define r10H (*(char*)(R_BASE + 0x15))
+#define r11 (*(unsigned*)(R_BASE + 0x16))
+#define r11L (*(char*)(R_BASE + 0x16))
+#define r11H (*(char*)(R_BASE + 0x17))
+#define r12 (*(unsigned*)(R_BASE + 0x18))
+#define r12L (*(char*)(R_BASE + 0x18))
+#define r12H (*(char*)(R_BASE + 0x19))
+#define r13 (*(unsigned*)(R_BASE + 0x1a))
+#define r13L (*(char*)(R_BASE + 0x1a))
+#define r13H (*(char*)(R_BASE + 0x1b))
+#define r14 (*(unsigned*)(R_BASE + 0x1c))
+#define r14L (*(char*)(R_BASE + 0x1c))
+#define r14H (*(char*)(R_BASE + 0x1d))
+#define r15 (*(unsigned*)(R_BASE + 0x1e))
+#define r15L (*(char*)(R_BASE + 0x1e))
+#define r15H (*(char*)(R_BASE + 0x1f))
+
+#ifdef __GEOS_CBM__
+
+#define nameBuf char[17]
+#define blockBuf char[256]
+
+#define CPU_DDR (*(char*)0x00)
+#define CPU_DATA (*(char*)0x01)
+
+#define R_BASE 0x02
+
+#define curPattern (*(unsigned*)0x22)
+#define string (*(unsigned*)0x24)
+#define curFontDesc (*(struct fontdesc*)0x26)
+#define currentMode (*(char*)0x2e)
+#define dispBufferOn (*(char*)0x2f)
+#define mouseOn (*(char*)0x30)
+#define msePicPtr (*(unsigned*)0x31)
+#define curWindow (*(struct window*)0x33)
+#define pressFlag (*(char*)0x39)
+#define mousePos (*(struct pixel*)0x3a)
+#define returnAddress (*(unsigned*)0x3d)
+#define graphMode (*(char*)0x3f)
+#define STATUS (*(char*)0x90)
+#define curDevice (*(char*)0xba)
+
+#define irqvec (*(void_func*)0x0314)
+#define bkvec (*(void_func*)0x0316)
+#define nmivec (*(void_func*)0x0318)
+
+#define APP_RAM ((char*)0x0400)
+#define BACK_SCR_BASE ((char*)0x6000)
+#define PRINTBASE ((char*)0x7900)
+#define OS_VARS ((char*)0x8000)
+
+#define diskBlkBuf ((blockBuf)0x8000)
+#define fileHeader (*(struct fileheader*)0x8100)
+#define curDirHead ((blockBuf)0x8200)
+#define fileTrScTab ((struct tr_se[128])0x8300)
+#define dirEntryBuf (*(struct filehandle*)0x8400)
+
+#define DrACurDkNm ((nameBuf)0x841e)
+#define DrBCurDkNm ((nameBuf)0x8430)
+#define dataFileName ((nameBuf)0x8442)
+#define dataDiskName ((nameBuf)0x8453)
+#define PrntFileName ((nameBuf)0x8465)
+#define PrntDiskName ((nameBuf)0x8476)
+
+#define curDrive (*(char*)0x8489)
+#define diskOpenFlg (*(char*)0x848a)
+#define isGEOS (*(char*)0x848b)
+#define interleave (*(char*)0x848c)
+#define NUMDRV (*(char*)0x848d)
+
+#define driveType ((char[4])0x848e)
+#define turboFlags ((char[4])0x8492)
+
+#define VLIRInfo (*(struct VLIR_info*)0x8496)
+
+#define appMain (*(void_func*)0x849b)
+#define intTopVector (*(void_func*)0x849d)
+#define intBotVector (*(void_func*)0x849f)
+#define mouseVector (*(void_func*)0x84a1)
+#define keyVector (*(void_func*)0x84a3)
+#define inputVector (*(void_func*)0x84a5)
+#define mouseFaultVec (*(void_func*)0x84a7)
+#define otherPressVec (*(void_func*)0x84a9)
+#define StringFaultVec (*(void_func*)0x84ab)
+#define alarmTmtVector (*(void_func*)0x84ad)
+#define BRKVector (*(void_func*)0x84af)
+#define RecoverVector (*(void_func*)0x84b1)
+
+#define selectionFlash (*(char*)0x84b3)
+#define alphaFlag (*(char*)0x84b4)
+#define iconSelFlg (*(char*)0x84b5)
+#define faultData (*(char*)0x84b6)
+#define menuNumber (*(char*)0x84b7)
+#define mouseWindow (*(struct window*)0x84b8)
+#define stringXY (*(struct pixel*)0x84be)
+#define mousePicData (*(char*)0x84c1)
+
+#define maxMouseSpeed (*(char*)0x8501)
+#define minMouseSpeed (*(char*)0x8502)
+#define mouseAccel (*(char*)0x8503)
+#define keyData (*(char*)0x8504)
+#define mouseData (*(char*)0x8505)
+#define inputData (*(char*)0x8506)
+#define mouseSpeed (*(char*)0x8507)
+#define random (*(char*)0x850a)
+#define saveFontTab (*(struct fontdesc*)0x850c)
+
+#define dblClickCount (*(char*)0x8515)
+#define system_date (*(struct s_date*)0x8516)
+#define alarmSetFlag (*(char*)0x851c)
+#define sysDBData (*(char*)0x851d)
+#define screencolors (*(char*)0x851e)
+#define dlgBoxRamBuf (*(char*)0x851f)
+
+#define savedmoby2 (*(char*)0x88bb)
+#define scr80polar (*(char*)0x88bc)
+#define scr80colors (*(char*)0x88bd)
+#define vdcClrMode (*(char*)0x88be)
+#define driveData ((char[4])0x88bf)
+#define ramExpSize (*(char*)0x88c3)
+#define sysRAMFlg (*(char*)0x88c4)
+#define firstBoot (*(char*)0x88c5)
+#define curType (*(char*)0x88c6)
+#define ramBase (*(char*)0x88c7)
+#define inputDevName ((nameBuf)0x88cb)
+#define DrCCurDkNm ((nameBuf)0x88dc)
+#define DrDCurDkNm ((nameBuf)0x88ee)
+#define dir2Head ((blockBuf)0x8900)
+#define SPRITE_PICS ((char*)0x8a00)
+#define sprpic ((char[8][64])0x8a00)
+#define COLOR_MATRIX ((char[1000])0x8c00)
+#define objPointer ((char[8])0x8ff8)
+
+#define DISK_BASE ((char*)0x9000)
+#define SCREEN_BASE ((char*)0xa000)
+#define OS_ROM ((char*)0xc000)
+#define OS_JUMPTAB ((char*)0xc100)
+#define EXP_BASE ((char*)0xdf00)
+#define MOUSE_BASE_128 ((char*)0xfd00)
+#define MOUSE_JMP_128 ((char*)0xfd00)
+#define END_MOUSE_128 ((char*)0xfe80)
+#define MOUSE_BASE ((char*)0xfe80)
+#define MOUSE_JMP ((char*)0xfe80)
+
+#define config (*(char*)0xff00)
+#define END_MOUSE ((char*)0xfffa)
+
+#define NMI_VECTOR (*(void_func*)0xfffa)
+#define RESET_VECTOR (*(void_func*)0xfffc)
+#define IRQ_VECTOR (*(void_func*)0xfffe)
+
+#define vicbase ((char*)0xd000)
+#define sidbase ((char*)0xd400)
+#define mmu ((char*)0xd500)
+#define VDC ((char*)0xd600)
+#define ctab ((char*)0xd800)
+#define cia1base ((char*)0xdc00)
+#define cia2base ((char*)0xdd00)
+
+#define mob0xpos (*(char*)0xd000)
+#define mob0ypos (*(char*)0xd001)
+#define mob1xpos (*(char*)0xd002)
+#define mob1ypos (*(char*)0xd003)
+#define mob2xpos (*(char*)0xd004)
+#define mob2ypos (*(char*)0xd005)
+#define mob3xpos (*(char*)0xd006)
+#define mob3ypos (*(char*)0xd007)
+#define mob4xpos (*(char*)0xd008)
+#define mob4ypos (*(char*)0xd009)
+#define mob5xpos (*(char*)0xd00a)
+#define mob5ypos (*(char*)0xd00b)
+#define mob6xpos (*(char*)0xd00c)
+#define mob6ypos (*(char*)0xd00d)
+#define mob7xpos (*(char*)0xd00e)
+#define mob7ypos (*(char*)0xd00f)
+#define msbxpos (*(char*)0xd010)
+#define grcntrl1 (*(char*)0xd011)
+#define rasreg (*(char*)0xd012)
+#define lpxpos (*(char*)0xd013)
+#define lpypos (*(char*)0xd014)
+#define mobenble (*(char*)0xd015)
+#define grcntrl2 (*(char*)0xd016)
+#define grmemptr (*(char*)0xd018)
+#define grirq (*(char*)0xd019)
+#define grirqen (*(char*)0xd01a)
+#define moby2 (*(char*)0xd017)
+#define mobprior (*(char*)0xd01b)
+#define mobmcm (*(char*)0xd01c)
+#define mobx2 (*(char*)0xd01d)
+#define mobmobcol (*(char*)0xd01e)
+#define mobbakcol (*(char*)0xd01f)
+#define extclr (*(char*)0xd020)
+#define bakclr0 (*(char*)0xd021)
+#define bakclr1 (*(char*)0xd022)
+#define bakclr2 (*(char*)0xd023)
+#define bakclr3 (*(char*)0xd024)
+#define mcmclr0 (*(char*)0xd025)
+#define mcmclr1 (*(char*)0xd026)
+#define mob0clr (*(char*)0xd027)
+#define mob1clr (*(char*)0xd028)
+#define mob2clr (*(char*)0xd029)
+#define mob3clr (*(char*)0xd02a)
+#define mob4clr (*(char*)0xd02b)
+#define mob5clr (*(char*)0xd02c)
+#define mob6clr (*(char*)0xd02d)
+#define mob7clr (*(char*)0xd02e)
+#define keyreg (*(char*)0xd02f)
+#define clkreg (*(char*)0xd030)
+
+#define vdcreg (*(char*)0xd600)
+#define vdcdata (*(char*)0xd601)
+
+#else /* #ifdef __GEOS_CBM__ */
+
+#define nameBuf char[16]
+#define blockBuf char[512]
+
+#define R_BASE 0x00
+
+#define curPattern (*(unsigned*)0x022c)
+#define string (*(unsigned*)0x53)
+#define curFontDesc (*(struct fontdesc*)0x0218)
+#define currentMode (*(char*)0x021c)
+#define dispBufferOn (*(char*)0x021d)
+#define mouseOn (*(char*)0x5d)
+#define curWindow (*(struct window*)0x021e)
+#define pressFlag (*(char*)0x08fe)
+#define mousePos (*(struct pixel*)0x0241)
+#define returnAddress (*(unsigned*)0x64)
+
+#define diskBlkBuf ((blockBuf)0xf659)
+#define fileHeader (*(struct fileheader*)0xf859)
+#define curDirHead ((char[39])0xfa80)
+#define dirEntryBuf (*(struct filehandle*)0xfa59)
+
+#define DrACurDkNm ((nameBuf)0xfaa7)
+#define DrBCurDkNm ((nameBuf)0xfab7)
+#define dataFileName ((nameBuf)0x02a4)
+#define dataDiskName ((nameBuf)0x02b4)
+#define PrntFileName ((nameBuf)0x08ac)
+
+#define curDrive (*(char*)0xf60d)
+#define diskOpenFlg (*(char*)0xf617)
+#define NUMDRV (*(char*)0xf60e)
+
+#define driveType ((char[4])0xfaf3)
+
+#define VLIRInfo (*(struct VLIR_info*)0xf618)
+
+#define appMain (*(void_func*)0x0200)
+#define intTopVector (*(void_func*)0x0202)
+#define intBotVector (*(void_func*)0x0204)
+#define mouseVector (*(void_func*)0x0206)
+#define keyVector (*(void_func*)0x0208)
+#define inputVector (*(void_func*)0x020a)
+#define mouseFaultVec (*(void_func*)0x020c)
+#define otherPressVec (*(void_func*)0x020e)
+#define StringFaultVec (*(void_func*)0x0210)
+#define alarmTmtVector (*(void_func*)0x0212)
+#define BRKVector (*(void_func*)0x0214)
+#define RecoverVector (*(void_func*)0x0216)
+
+#define selectionFlash (*(char*)0x0224)
+#define alphaFlag (*(char*)0x0225)
+#define iconSelFlg (*(char*)0x0226)
+#define faultData (*(char*)0x0227)
+#define menuNumber (*(char*)0x0228)
+#define mouseWindow (*(struct window*)0x57)
+#define stringXY (*(struct pixel*)0x022e)
+
+#define maxMouseSpeed (*(char*)0x027d)
+#define minMouseSpeed (*(char*)0x027e)
+#define mouseAccel (*(char*)0x027f)
+#define keyData (*(char*)0x0245)
+#define mouseData (*(char*)0x0246)
+#define inputData (*(char*)0x0247)
+#define random (*(char*)0x024c)
+#define saveFontTab (*(struct fontdesc*)0x024e)
+
+#define dblClickCount (*(char*)0x0258)
+#define system_date (*(struct s_date*)0xf200)
+#define sysDBData (*(char*)0x0259)
+#define dlgBoxRamBuf (*(char*)0xf381)
+
+#define firstBoot (*(char*)0x0281)
+#define inputDevName ((nameBuf)0x08cc)
+#define DrCCurDkNm ((nameBuf)0xfac7)
+#define DrDCurDkNm ((nameBuf)0xfad7)
+
+#define mobenble (*(char*)0x0818)
+#define moby2 (*(char*)0x081a)
+#define mobx2 (*(char*)0x0819)
+
+#endif /* #ifdef __GEOS_CBM__ */
+
+#endif
+/*
+ GEOS system functions
+
+ by Maciej 'YTM/Elysium' Witkowiak
+*/
+
+#ifndef _GSYS_H
+#define _GSYS_H
+
+void FirstInit(void);
+void InitForIO(void);
+void DoneWithIO(void);
+void MainLoop(void);
+void EnterDeskTop(void);
+void ToBASIC(void);
+void Panic(void);
+
+void __fastcall__ CallRoutine(void *myRoutine);
+
+unsigned GetSerialNumber(void);
+char GetRandom(void);
+
+void __fastcall__ SetDevice(char newdev);
+
+char get_ostype(void);
+
+/* possible return values of get_ostype, machine and version flags will
+ be combined with OR */
+ /* machine flags */
+#define GEOS64 0x00
+#define GEOS4 0x04 /* plus4 geos is not or'ed with version */
+#define GEOS128 0x80
+ /* version flags */
+#define MEGAPATCH3 0x03
+#define GATEWAY 0x08
+#define GEOS_V10 0x10
+#define GEOS_V11 0x11
+#define GEOS_V12 0x12
+#define GEOS_V13 0x13
+#define GEOS_V15 0x15
+#define GEOS_V20 0x20
+#define WHEELS 0x40 /* only Wheels? */
+
+char get_tv(void);
+
+/* possible return values of get_tv, these flags will be combined
+ note that columns state can be changed during runtime and get_tv
+ always returns the current state */
+#define COLUMNS40 0x00
+#define COLUMNS80 0x01
+#define TV_PAL 0x00
+#define TV_NTSC 0x80
+
+#endif
+/*****************************************************************************/
+/* */
+/* inttypes.h */
+/* */
+/* Format conversion of integer types */
+/* */
+/* */
+/* */
+/* (C) 2002-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+/* Note: This file is not fully ISO 9899-1999 compliant because cc65 lacks
+** a 64 bit data types and is not able to return structs > 4 bytes. The
+** declarations have been adjusted accordingly or left out.
+*/
+
+
+
+#ifndef _INTTYPES_H
+#define _INTTYPES_H
+
+
+
+/* inttypes.h must always include stdint.h */
+#ifndef _STDINT_H
+#include
+#endif
+
+
+
+/* Standard functions */
+intmax_t __fastcall__ imaxabs (intmax_t val);
+intmax_t __fastcall__ strtoimax (const char* nptr, char** endptr, int base);
+uintmax_t __fastcall__ strtoumax (const char* nptr, char** endptr, int base);
+
+
+
+/* printf() macros for signed integers */
+#define PRId8 "d"
+#define PRId16 "d"
+#define PRId32 "ld"
+
+#define PRIdLEAST8 "d"
+#define PRIdLEAST16 "d"
+#define PRIdLEAST32 "ld"
+
+#define PRIdFAST8 "d"
+#define PRIdFAST16 "d"
+#define PRIdFAST32 "ld"
+
+#define PRIdMAX "ld"
+#define PRIdPTR "d"
+
+#define PRIi8 "i"
+#define PRIi16 "i"
+#define PRIi32 "li"
+
+#define PRIiLEAST8 "i"
+#define PRIiLEAST16 "i"
+#define PRIiLEAST32 "li"
+
+#define PRIiFAST8 "i"
+#define PRIiFAST16 "i"
+#define PRIiFAST32 "li"
+
+#define PRIiMAX "li"
+#define PRIiPTR "i"
+
+/* fprintf() macros for unsigned integers */
+#define PRIo8 "o"
+#define PRIo16 "o"
+#define PRIo32 "lo"
+
+#define PRIoLEAST8 "o"
+#define PRIoLEAST16 "o"
+#define PRIoLEAST32 "lo"
+
+#define PRIoFAST8 "o"
+#define PRIoFAST16 "o"
+#define PRIoFAST32 "lo"
+
+#define PRIoMAX "lo"
+#define PRIoPTR "o"
+
+#define PRIu8 "u"
+#define PRIu16 "u"
+#define PRIu32 "lu"
+
+#define PRIuLEAST8 "u"
+#define PRIuLEAST16 "u"
+#define PRIuLEAST32 "lu"
+
+#define PRIuFAST8 "u"
+#define PRIuFAST16 "u"
+#define PRIuFAST32 "lu"
+
+#define PRIuMAX "lu"
+#define PRIuPTR "u"
+
+#define PRIx8 "x"
+#define PRIx16 "x"
+#define PRIx32 "lx"
+
+#define PRIxLEAST8 "x"
+#define PRIxLEAST16 "x"
+#define PRIxLEAST32 "lx"
+
+#define PRIxFAST8 "x"
+#define PRIxFAST16 "x"
+#define PRIxFAST32 "lx"
+
+#define PRIxMAX "lx"
+#define PRIxPTR "x"
+
+#define PRIX8 "X"
+#define PRIX16 "X"
+#define PRIX32 "lX"
+
+#define PRIXLEAST8 "X"
+#define PRIXLEAST16 "X"
+#define PRIXLEAST32 "lX"
+
+#define PRIXFAST8 "X"
+#define PRIXFAST16 "X"
+#define PRIXFAST32 "lX"
+
+#define PRIXMAX "lX"
+#define PRIXPTR "X"
+
+/* fscanf() macros for signed integers */
+#define SCNd8 "hd"
+#define SCNd16 "d"
+#define SCNd32 "ld"
+
+#define SCNdLEAST8 "hd"
+#define SCNdLEAST16 "d"
+#define SCNdLEAST32 "ld"
+
+#define SCNdFAST8 "hd"
+#define SCNdFAST16 "d"
+#define SCNdFAST32 "ld"
+
+#define SCNdMAX "ld"
+#define SCNdPTR "d"
+
+#define SCNi8 "hi"
+#define SCNi16 "i"
+#define SCNi32 "li"
+
+#define SCNiLEAST8 "hi"
+#define SCNiLEAST16 "i"
+#define SCNiLEAST32 "li"
+
+#define SCNiFAST8 "hi"
+#define SCNiFAST16 "i"
+#define SCNiFAST32 "li"
+
+#define SCNiMAX "li"
+#define SCNiPTR "i"
+
+/* fscanf() macros for unsigned integers */
+#define SCNo8 "ho"
+#define SCNo16 "o"
+#define SCNo32 "lo"
+
+#define SCNoLEAST8 "ho"
+#define SCNoLEAST16 "o"
+#define SCNoLEAST32 "lo"
+
+#define SCNoFAST8 "ho"
+#define SCNoFAST16 "o"
+#define SCNoFAST32 "lo"
+
+#define SCNoMAX "lo"
+#define SCNoPTR "o"
+
+#define SCNu8 "hu"
+#define SCNu16 "u"
+#define SCNu32 "lu"
+
+#define SCNuLEAST8 "hu"
+#define SCNuLEAST16 "u"
+#define SCNuLEAST32 "lu"
+
+#define SCNuFAST8 "hu"
+#define SCNuFAST16 "u"
+#define SCNuFAST32 "lu"
+
+#define SCNuMAX "lu"
+#define SCNuPTR "u"
+
+#define SCNx8 "hx"
+#define SCNx16 "x"
+#define SCNx32 "lx"
+
+#define SCNxLEAST8 "hx"
+#define SCNxLEAST16 "x"
+#define SCNxLEAST32 "lx"
+
+#define SCNxFAST8 "hx"
+#define SCNxFAST16 "x"
+#define SCNxFAST32 "lx"
+
+#define SCNxMAX "lx"
+#define SCNxPTR "x"
+
+
+
+/* End of inttypes.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* iso646.h */
+/* */
+/* Alternative spellings */
+/* */
+/* */
+/* */
+/* (C) 1998-2000 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@musoftware.de */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _ISO646_H
+#define _ISO646_H
+
+
+
+/* Operator tokens */
+#define and &&
+#define and_eq &=
+#define bitand &
+#define bitor |
+#define compl ~
+#define not !
+#define not_eq !=
+#define or ||
+#define or_eq |=
+#define xor ^
+#define xor_eq ^=
+
+
+
+/* End of iso646.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* joystick.h */
+/* */
+/* Read the joystick on systems that support it */
+/* */
+/* */
+/* */
+/* (C) 1998-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _JOYSTICK_H
+#define _JOYSTICK_H
+
+
+
+#include
+
+
+
+/*****************************************************************************/
+/* Definitions */
+/*****************************************************************************/
+
+
+
+/* Error codes */
+#define JOY_ERR_OK 0 /* No error */
+#define JOY_ERR_NO_DRIVER 1 /* No driver available */
+#define JOY_ERR_CANNOT_LOAD 2 /* Error loading driver */
+#define JOY_ERR_INV_DRIVER 3 /* Invalid driver */
+#define JOY_ERR_NO_DEVICE 4 /* Device (hardware) not found */
+
+/* Argument for the joy_read function */
+#define JOY_1 0
+#define JOY_2 1
+
+/* Macros that evaluate the return code of joy_read */
+#define JOY_UP(v) ((v) & JOY_UP_MASK)
+#define JOY_DOWN(v) ((v) & JOY_DOWN_MASK)
+#define JOY_LEFT(v) ((v) & JOY_LEFT_MASK)
+#define JOY_RIGHT(v) ((v) & JOY_RIGHT_MASK)
+#define JOY_BTN_1(v) ((v) & JOY_BTN_1_MASK) /* Universally available */
+#define JOY_BTN_2(v) ((v) & JOY_BTN_2_MASK) /* Second button if available */
+#define JOY_BTN_3(v) ((v) & JOY_BTN_3_MASK) /* Third button if available */
+#define JOY_BTN_4(v) ((v) & JOY_BTN_4_MASK) /* Fourth button if available */
+
+/* The name of the standard joystick driver for a platform */
+extern const char joy_stddrv[];
+
+/* The address of the static standard joystick driver for a platform */
+extern const void joy_static_stddrv[];
+
+
+
+/*****************************************************************************/
+/* Functions */
+/*****************************************************************************/
+
+
+
+unsigned char __fastcall__ joy_load_driver (const char* driver);
+/* Load and install a joystick driver. Return an error code. */
+
+unsigned char joy_unload (void);
+/* Uninstall, then unload the currently loaded driver. */
+
+unsigned char __fastcall__ joy_install (const void* driver);
+/* Install an already loaded driver. Return an error code. */
+
+unsigned char joy_uninstall (void);
+/* Uninstall the currently loaded driver and return an error code.
+** Note: This call does not free allocated memory.
+*/
+
+unsigned char joy_count (void);
+/* Return the number of joysticks supported by the driver */
+
+unsigned char __fastcall__ joy_read (unsigned char joystick);
+/* Read a particular joystick */
+
+
+
+/* End of joystick.h */
+#endif
+/*****************************************************************************/
+/* */
+/* joy-kernel.h */
+/* */
+/* Internally used joystick functions */
+/* */
+/* */
+/* */
+/* (C) 2002-2006, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _JOY_KERNEL_H
+#define _JOY_KERNEL_H
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* A structure that describes the header of a joystick driver loaded into
+** memory.
+*/
+typedef struct {
+
+ /* Driver header */
+ char id[3]; /* Contains 0x6a, 0x6f, 0x79 ("joy") */
+ unsigned char version; /* Interface version */
+ void* libreference; /* Library reference */
+
+ /* Jump vectors. Note that these are not C callable */
+ void* install; /* INSTALL routine */
+ void* uninstall; /* UNINSTALL routine */
+ void* count; /* COUNT routine */
+ void* read; /* READ routine */
+
+} joy_drv_header;
+
+
+
+/* JOY kernel variables */
+extern joy_drv_header* joy_drv; /* Pointer to driver */
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+void joy_clear_ptr (void);
+/* Clear the joy_drv pointer */
+
+
+
+/* End of joy-kernel.h */
+#endif
+/*****************************************************************************/
+/* */
+/* kim1.h */
+/* */
+/* KIM-1 system-specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2022 Dave Plummer */
+/* Email: davepl@davepl.com */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+#ifndef _KIM1_H
+#define _KIM1_H
+
+/* Check for errors */
+#if !defined(__KIM1__)
+# error This module may only be used when compiling for the KIM-1!
+#endif
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* Hardware */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+/* Read from tape */
+int __fastcall__ loadt (unsigned char);
+
+/* Write to tape */
+int __fastcall__ dumpt (unsigned char, const void*, const void*);
+
+
+/* Write to 7-segment LED display. Due to hardware limitations it only
+** displays briefly, so must be called repeatedly to update the
+** display.
+**/
+void __fastcall__ scandisplay(unsigned char left, unsigned char middle, unsigned char right);
+
+/*
+** Get a keypress from the keypad. Returns $00-$0F(0-F), $10(AD), $11(DA), $12(+),
+** $13(GO), $14(PC) or $15 for no keypress.
+**/
+int __fastcall__ getkey();
+
+/* End of kim1.h */
+#endif
+/*****************************************************************************/
+/* */
+/* limits.h */
+/* */
+/* Sizes of integer types */
+/* */
+/* */
+/* */
+/* (C) 1998-2002 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@musoftware.de */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _LIMITS_H
+#define _LIMITS_H
+
+
+#define CHAR_BIT 8
+
+#define SCHAR_MIN ((signed char) 0x80)
+#define SCHAR_MAX 127
+
+#define UCHAR_MAX 255
+
+#define CHAR_MIN 0
+#define CHAR_MAX 255
+
+#define SHRT_MIN ((short) 0x8000)
+#define SHRT_MAX 32767
+
+#define USHRT_MAX 65535U
+
+#define INT_MIN ((int) 0x8000)
+#define INT_MAX 32767
+
+#define UINT_MAX 65535U
+
+#define LONG_MAX 2147483647L
+#define LONG_MIN ((long) 0x80000000)
+
+#define ULONG_MAX 4294967295UL
+
+#if __CC65_STD__ >= __CC65_STD_CC65__
+/* These defines that are platform dependent */
+/* FILENAME_MAX in stdlib.h is defined as the same value as PATH_MAX */
+#if defined(__APPLE2__)
+# define PATH_MAX (64+1)
+#elif defined(__ATARI__)
+# define PATH_MAX (63+1)
+#elif defined(__CBM__)
+# define PATH_MAX (255) /* should be 256+1, see libsrc/common/_cmd.s why it's not */
+#elif defined(__LUNIX__)
+# define PATH_MAX (80+1)
+#elif defined(__TELESTRAT__)
+# define PATH_MAX (50+1)
+#else
+# define PATH_MAX (16+1)
+#endif
+#endif /* __CC65_STD__ >= __CC65_STD_CC65__ */
+
+/* End of limits.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* locale.h */
+/* */
+/* Localization */
+/* */
+/* */
+/* */
+/* (C) 1998-2005 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _LOCALE_H
+#define _LOCALE_H
+
+
+
+/* NULL pointer */
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+/* Locale information constants */
+#define LC_ALL 0
+#define LC_COLLATE 1
+#define LC_CTYPE 2
+#define LC_MONETARY 3
+#define LC_NUMERIC 4
+#define LC_TIME 5
+
+/* Struct containing locale settings */
+struct lconv {
+ char* currency_symbol;
+ char* decimal_point;
+ char* grouping;
+ char* int_curr_symbol;
+ char* mon_decimal_point;
+ char* mon_grouping;
+ char* mon_thousands_sep;
+ char* negative_sign;
+ char* positive_sign;
+ char* thousands_sep;
+ char frac_digits;
+ char int_frac_digits;
+ char n_cs_precedes;
+ char n_sep_by_space;
+ char n_sign_posn;
+ char p_cs_precedes;
+ char p_sep_by_space;
+ char p_sign_posn;
+};
+
+/* Function prototypes */
+struct lconv* localeconv (void);
+char* __fastcall__ setlocale (int category, const char* locale);
+
+
+
+/* End of locale.h */
+#endif
+/*****************************************************************************/
+/* */
+/* lynx.h */
+/* */
+/* Lynx system-specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2003 Shawn Jefferson */
+/* */
+/* Adapted with many changes Ullrich von Bassewitz, 2004-10-09 */
+/* */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _LYNX_H
+#define _LYNX_H
+
+
+
+/* Check for errors */
+#if !defined(__LYNX__)
+# error This module may only be used when compiling for the Lynx game console!
+#endif
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Color defines */
+#define COLOR_TRANSPARENT 0x00
+#define COLOR_BLACK 0x01
+#define COLOR_RED 0x02
+#define COLOR_PINK 0x03
+#define COLOR_LIGHTGREY 0x04
+#define COLOR_GREY 0x05
+#define COLOR_DARKGREY 0x06
+#define COLOR_BROWN 0x07
+#define COLOR_PEACH 0x08
+#define COLOR_YELLOW 0x09
+#define COLOR_LIGHTGREEN 0x0A
+#define COLOR_GREEN 0x0B
+#define COLOR_PURPLE 0x0C
+#define COLOR_BLUE 0x0D
+#define COLOR_LIGHTBLUE 0x0E
+#define COLOR_WHITE 0x0F
+
+/* TGI color defines (default palette) */
+#define TGI_COLOR_TRANSPARENT COLOR_TRANSPARENT
+#define TGI_COLOR_BLACK COLOR_BLACK
+#define TGI_COLOR_RED COLOR_RED
+#define TGI_COLOR_PINK COLOR_PINK
+#define TGI_COLOR_LIGHTGREY COLOR_LIGHTGREY
+#define TGI_COLOR_GREY COLOR_GREY
+#define TGI_COLOR_DARKGREY COLOR_DARKGREY
+#define TGI_COLOR_BROWN COLOR_BROWN
+#define TGI_COLOR_ORANGE COLOR_BROWN
+#define TGI_COLOR_PEACH COLOR_PEACH
+#define TGI_COLOR_YELLOW COLOR_YELLOW
+#define TGI_COLOR_LIGHTGREEN COLOR_LIGHTGREEN
+#define TGI_COLOR_GREEN COLOR_GREEN
+#define TGI_COLOR_PURPLE COLOR_PURPLE
+#define TGI_COLOR_BLUE COLOR_BLUE
+#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
+#define TGI_COLOR_WHITE COLOR_WHITE
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x80
+#define JOY_DOWN_MASK 0x40
+#define JOY_LEFT_MASK 0x20
+#define JOY_RIGHT_MASK 0x10
+#define JOY_BTN_1_MASK 0x01
+#define JOY_BTN_2_MASK 0x02
+
+#define JOY_BTN_A_MASK JOY_BTN_1_MASK
+#define JOY_BTN_B_MASK JOY_BTN_2_MASK
+
+#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
+#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
+
+/* No support for dynamically loadable drivers */
+#define DYN_DRV 0
+
+
+
+/*****************************************************************************/
+/* Variables */
+/*****************************************************************************/
+
+
+
+/* The addresses of the static drivers */
+extern void lynx_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
+extern void lynx_comlynx_ser[]; /* Referred to by ser_static_stddrv[] */
+extern void lynx_160_102_16_tgi[]; /* Referred to by tgi_static_stddrv[] */
+
+
+
+/*****************************************************************************/
+/* Sound support */
+/*****************************************************************************/
+
+
+
+void lynx_snd_init (void);
+/* Initialize the sound driver */
+
+void lynx_snd_pause (void);
+/* Pause sound */
+
+void lynx_snd_continue (void);
+/* Continue sound after pause */
+
+void __fastcall__ lynx_snd_play (unsigned char channel, unsigned char *music);
+/* Play tune on channel */
+
+void lynx_snd_stop (void);
+/* Stop sound on all channels */
+
+void __fastcall__ lynx_snd_stop_channel (unsigned char channel);
+/* Stop sound on all channels */
+
+unsigned char lynx_snd_active(void);
+/* Show which channels are active */
+
+
+
+/*****************************************************************************/
+/* Accessing the cart */
+/*****************************************************************************/
+
+
+
+void __fastcall__ lynx_load (int fileno);
+/* Load a file into ram. The first entry is fileno=0. */
+
+void __fastcall__ lynx_exec (int fileno);
+/* Load a file into ram and execute it. */
+
+
+
+/*****************************************************************************/
+/* Accessing the EEPROM */
+/*****************************************************************************/
+
+
+
+unsigned __fastcall__ lynx_eeprom_read (unsigned char cell);
+/* Read a 16 bit word from the given address */
+
+unsigned __fastcall__ lynx_eeprom_write (unsigned char cell, unsigned val);
+/* Write the word at the given address */
+
+void __fastcall__ lynx_eeprom_erase (unsigned char cell);
+/* Clear the word at the given address */
+
+unsigned __fastcall__ lynx_eeread (unsigned cell);
+/* Read a 16 bit word from the given address 93C46 93C66 or 93C86*/
+
+unsigned __fastcall__ lynx_eewrite (unsigned cell, unsigned val);
+/* Write the word at the given address 93C46 93C66 or 93C86*/
+
+
+
+/*****************************************************************************/
+/* TGI extras */
+/*****************************************************************************/
+
+
+
+#define tgi_sprite(spr) tgi_ioctl(0, spr)
+#define tgi_flip() tgi_ioctl(1, (void*)0)
+#define tgi_setbgcolor(bgcol) tgi_ioctl(2, (void*)(bgcol))
+#define tgi_setframerate(rate) tgi_ioctl(3, (void*)(rate))
+#define tgi_busy() tgi_ioctl(4, (void*)0)
+#define tgi_updatedisplay() tgi_ioctl(4, (void*)1)
+#define tgi_setcollisiondetection(active) tgi_ioctl(5, (void*)(active))
+
+/* Define Hardware */
+#include <_mikey.h>
+#define MIKEY (*(struct __mikey *)0xFD00)
+
+#define _MIKEY_TIMERS (*(struct _mikey_all_timers *) 0xFD00) // mikey_timers[8]
+#define _HBL_TIMER (*(struct _mikey_timer *) 0xFD00) // timer0 (HBL)
+#define _VBL_TIMER (*(struct _mikey_timer *) 0xFD08) // timer2 (VBL)
+#define _UART_TIMER (*(struct _mikey_timer *) 0xFD14) // timer4 (UART)
+#define _VIDDMA (*(unsigned int *) 0xFD92) // dispctl/viddma
+
+#include <_suzy.h>
+#define SUZY (*(struct __suzy*)0xFC00)
+
+
+
+/* End of lynx.h */
+#endif
+/*****************************************************************************/
+/* */
+/* lz4.h */
+/* */
+/* Decompression routine for the 'lz4' format */
+/* */
+/* */
+/* */
+/* (C) 2017 Mega Cat Studios */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _LZ4_H
+#define _LZ4_H
+
+void __fastcall__ decompress_lz4 (const unsigned char* src, unsigned char* const dst,
+ const unsigned short uncompressed_size);
+/* Decompresses the source buffer into the destination buffer.
+** The size of the decompressed data must be known in advance, LZ4
+** does not include any terminator in-stream.
+*/
+
+/* end of lz4.h */
+#endif
+/*****************************************************************************/
+/* */
+/* modload.h */
+/* */
+/* o65 module loader interface for cc65 */
+/* */
+/* */
+/* */
+/* (C) 2002 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@musoftware.de */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+/* Exports structures and functions to load relocatable o65 modules at
+** runtime.
+*/
+
+
+
+#ifndef _MODLOAD_H
+#define _MODLOAD_H
+
+
+
+/* The following struct is passed to the module loader. It contains stuff,
+** the loader needs to work, and another area where the loader will place
+** informational data if it was successful. You will have to check the return
+** code of mod_load before accessing any of these additional struct members.
+*/
+struct mod_ctrl {
+ /* Parameters passed into the loader routine. The member callerdata
+ ** is an opaque 16 bit datatype that may be used by the caller to
+ ** pass data through to the read routine. The read routine is used by the
+ ** loader to load any required data. There are several calls where the
+ ** read routine is passed a count of 1, so you may choose to make this
+ ** a special case when implementing read(). The read() should return the
+ ** number of bytes actually read. If the return value differs from the
+ ** passed count, this is considered an error.
+ ** NOTE: read() is designed so that the POSIX read() routine can be used
+ ** for this vector, if you're loading from disk.
+ */
+ int __fastcall__ (*read) (int callerdata, void* buffer, unsigned count);
+ int callerdata;
+
+ /* Parameters set by the loader routine */
+ void* module; /* Pointer to module data */
+ unsigned module_size; /* Total size of loaded module */
+ unsigned module_id; /* Module id */
+};
+
+
+
+unsigned char __fastcall__ mod_load (struct mod_ctrl* ctrl);
+/* Load a module into memory and relocate it. The function will return an
+** error code (see below). If MLOAD_OK is returned, the outgoing fields in
+** the passed mod_ctrl struct contain information about the module just
+** loaded.
+*/
+
+void __fastcall__ mod_free (void* module);
+/* Free a loaded module. Note: The given pointer is the pointer to the
+** module memory, not a pointer to a control structure.
+*/
+
+
+
+/* Errors */
+#define MLOAD_OK 0 /* Module load successful */
+#define MLOAD_ERR_READ 1 /* Read error */
+#define MLOAD_ERR_HDR 2 /* Header error */
+#define MLOAD_ERR_OS 3 /* Wrong OS */
+#define MLOAD_ERR_FMT 4 /* Data format error */
+#define MLOAD_ERR_MEM 5 /* Not enough memory */
+
+
+
+/* End of modload.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* mouse.h */
+/* */
+/* Mouse API */
+/* */
+/* */
+/* */
+/* (C) 2003-2013, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _MOUSE_H
+#define _MOUSE_H
+
+
+
+/*****************************************************************************/
+/* Definitions */
+/*****************************************************************************/
+
+
+
+/* Error codes */
+#define MOUSE_ERR_OK 0 /* No error */
+#define MOUSE_ERR_NO_DRIVER 1 /* No driver available */
+#define MOUSE_ERR_CANNOT_LOAD 2 /* Error loading driver */
+#define MOUSE_ERR_INV_DRIVER 3 /* Invalid driver */
+#define MOUSE_ERR_NO_DEVICE 4 /* Mouse hardware not found */
+#define MOUSE_ERR_INV_IOCTL 5 /* Invalid ioctl code */
+
+/* Mouse button masks */
+#define MOUSE_BTN_LEFT 0x10
+#define MOUSE_BTN_RIGHT 0x01
+
+/* Structure containing the mouse coordinates */
+struct mouse_pos {
+ int x;
+ int y;
+};
+
+/* Structure containing information about the mouse */
+struct mouse_info {
+ struct mouse_pos pos; /* Mouse position */
+ unsigned char buttons; /* Mouse button mask */
+};
+
+/* Structure used for getbox/setbox */
+struct mouse_box {
+ int minx;
+ int miny;
+ int maxx;
+ int maxy;
+};
+
+/* Structure containing mouse callback functions. These functions are declared
+** in C notation here, but they cannot be C functions (at least not easily),
+** since they may be called from within an interrupt.
+*/
+struct mouse_callbacks {
+
+ void (*hide) (void);
+ /* Hide the mouse cursor. */
+
+ void (*show) (void);
+ /* Show the mouse cursor. */
+
+ void (*prep) (void);
+ /* Prepare to move the mouse cursor. This function is called,
+ ** even when the cursor is currently invisible.
+ */
+
+ void (*draw) (void);
+ /* Draw the mouse cursor. This function is called,
+ ** even when the cursor is currently invisible.
+ */
+
+ void __fastcall__ (*movex) (int x);
+ /* Move the mouse cursor to the new X coordinate. This function is called,
+ ** even when the cursor is currently invisible.
+ */
+
+ void __fastcall__ (*movey) (int y);
+ /* Move the mouse cursor to the new Y coordinate. This function is called,
+ ** even when the cursor is currently invisible.
+ */
+};
+
+
+
+/*****************************************************************************/
+/* Declarations */
+/*****************************************************************************/
+
+
+
+/* The default mouse callbacks */
+extern const struct mouse_callbacks mouse_def_callbacks;
+
+#if defined(__CBM__)
+
+/* The default mouse pointer shape used by the default mouse callbacks */
+extern const unsigned char mouse_def_pointershape[63];
+
+/* The default mouse pointer color used by the default mouse callbacks */
+extern const unsigned char mouse_def_pointercolor;
+
+#endif
+
+/* The name of the standard mouse driver for a platform */
+extern const char mouse_stddrv[];
+
+/* The address of the static standard mouse driver for a platform */
+extern const void mouse_static_stddrv[];
+
+
+
+/*****************************************************************************/
+/* Functions */
+/*****************************************************************************/
+
+
+
+unsigned char __fastcall__ mouse_load_driver (const struct mouse_callbacks* c,
+ const char* driver);
+/* Load and install a mouse driver, return an error code. */
+
+unsigned char mouse_unload (void);
+/* Uninstall, then unload the currently loaded driver. */
+
+unsigned char __fastcall__ mouse_install (const struct mouse_callbacks* c,
+ void* driver);
+/* Install an already loaded driver. Return an error code. */
+
+unsigned char mouse_uninstall (void);
+/* Uninstall the currently loaded driver. Return an error code. */
+
+const char* __fastcall__ mouse_geterrormsg (unsigned char code);
+/* Get an error message describing the error in code. */
+
+void mouse_hide (void);
+/* Hide the mouse. The function manages a counter and may be called more than
+** once. For each call to mouse_hide there must be a call to mouse_show to make
+** the mouse visible again.
+*/
+
+void mouse_show (void);
+/* Show the mouse. See mouse_hide() for more information. */
+
+void __fastcall__ mouse_setbox (const struct mouse_box* box);
+/* Set the bounding box for the mouse pointer movement. The mouse X and Y
+** coordinates will never go outside the given box.
+** NOTE: The function does *not* check if the mouse is currently inside the
+** given margins. The proper way to use this function therefore is:
+**
+** - Hide the mouse
+** - Set the bounding box
+** - Place the mouse at the desired position
+** - Show the mouse again.
+**
+** NOTE2: When setting the box to something that is larger than the actual
+** screen, the positioning of the mouse cursor can fail. If such margins
+** are really what you want, you have to use your own cursor routines.
+*/
+
+void __fastcall__ mouse_getbox (struct mouse_box* box);
+/* Get the current bounding box for the mouse pointer movement. */
+
+void __fastcall__ mouse_move (int x, int y);
+/* Set the mouse cursor to the given position. If a mouse cursor is defined
+** and currently visible, the mouse cursor is also moved.
+** NOTE: This function does not check if the given position is valid and
+** inside the bounding box.
+*/
+
+unsigned char mouse_buttons (void);
+/* Return a bit mask encoding the states of the mouse buttons. Use the
+** MOUSE_BTN_XXX flags to decode a specific button.
+*/
+
+void __fastcall__ mouse_pos (struct mouse_pos* pos);
+/* Return the current mouse position. */
+
+void __fastcall__ mouse_info (struct mouse_info* info);
+/* Return the state of the mouse buttons and the position of the mouse. */
+
+unsigned char __fastcall__ mouse_ioctl (unsigned char code, void* data);
+/* Call the driver-specific ioctl function. Return an error code.
+** NON-PORTABLE!
+*/
+
+
+
+/* End of mouse.h */
+#endif
+/*****************************************************************************/
+/* */
+/* mouse-kernel.h */
+/* */
+/* Internally used mouse functions */
+/* */
+/* */
+/* */
+/* (C) 2003-2006, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _MOUSE_KERNEL_H
+#define _MOUSE_KERNEL_H
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Mouse kernel variables */
+extern void* mouse_drv; /* Pointer to driver */
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+void mouse_clear_ptr (void);
+/* Clear the mouse_drv pointer */
+
+
+
+/* End of mouse-kernel.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* nes.h */
+/* */
+/* NES system specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2002-2003 Groepaz/Hitmen */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _NES_H
+#define _NES_H
+
+
+
+/* Check for errors */
+#if !defined(__NES__)
+# error This module may only be used when compiling for the NES!
+#endif
+
+
+
+/* Key and character defines */
+#define CH_ENTER '\n'
+#define CH_CURS_UP 0x01
+#define CH_CURS_DOWN 0x02
+#define CH_CURS_LEFT 0x03
+#define CH_CURS_RIGHT 0x04
+#define CH_ESC 8
+#define CH_DEL 20
+
+#define CH_CROSS 0x10
+#define CH_RTEE 0x17
+#define CH_LTEE 0x0f
+#define CH_TTEE 0x16
+#define CH_BTEE 0x15
+#define CH_HLINE 0x0b
+#define CH_VLINE 0x0e
+#define CH_ULCORNER 0x14
+#define CH_URCORNER 0x12
+#define CH_LLCORNER 0x11
+#define CH_LRCORNER 0x08
+#define CH_PI 0x05
+
+/* Color defines */
+#define COLOR_BLACK 0x00
+#define COLOR_WHITE 0x01
+#define COLOR_RED 0x02
+#define COLOR_CYAN 0x03
+#define COLOR_PURPLE 0x04
+#define COLOR_GREEN 0x05
+#define COLOR_BLUE 0x06
+#define COLOR_YELLOW 0x07
+#define COLOR_ORANGE 0x08
+#define COLOR_BROWN 0x09
+#define COLOR_LIGHTRED 0x0A
+#define COLOR_GRAY1 0x0B
+#define COLOR_GRAY2 0x0C
+#define COLOR_LIGHTGREEN 0x0D
+#define COLOR_LIGHTBLUE 0x0E
+#define COLOR_GRAY3 0x0F
+
+/* TGI color defines (default palette) */
+#define TGI_COLOR_BLACK COLOR_BLACK
+#define TGI_COLOR_RED COLOR_RED
+#define TGI_COLOR_PINK COLOR_LIGHTRED
+#define TGI_COLOR_LIGHTGREY COLOR_GRAY1
+#define TGI_COLOR_GREY COLOR_GRAY2
+#define TGI_COLOR_DARKGREY COLOR_GRAY3
+#define TGI_COLOR_BROWN COLOR_BROWN
+#define TGI_COLOR_PEACH COLOR_CYAN
+#define TGI_COLOR_YELLOW COLOR_YELLOW
+#define TGI_COLOR_LIGHTGREEN COLOR_LIGHTGREEN
+#define TGI_COLOR_GREEN COLOR_GREEN
+#define TGI_COLOR_DARKBROWN COLOR_ORANGE
+#define TGI_COLOR_PURPLE COLOR_PURPLE
+#define TGI_COLOR_BLUE COLOR_BLUE
+#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
+#define TGI_COLOR_WHITE COLOR_WHITE
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x10
+#define JOY_DOWN_MASK 0x20
+#define JOY_LEFT_MASK 0x40
+#define JOY_RIGHT_MASK 0x80
+#define JOY_BTN_1_MASK 0x01
+#define JOY_BTN_2_MASK 0x02
+#define JOY_BTN_3_MASK 0x04
+#define JOY_BTN_4_MASK 0x08
+
+#define JOY_BTN_A_MASK JOY_BTN_1_MASK
+#define JOY_BTN_B_MASK JOY_BTN_2_MASK
+#define JOY_SELECT_MASK JOY_BTN_3_MASK
+#define JOY_START_MASK JOY_BTN_4_MASK
+
+#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
+#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
+#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
+#define JOY_START(v) ((v) & JOY_START_MASK)
+
+/* Return codes of get_tv */
+#define TV_NTSC 0
+#define TV_PAL 1
+#define TV_OTHER 2
+
+/* No support for dynamically loadable drivers */
+#define DYN_DRV 0
+
+/* Define hardware */
+
+/* Picture Processing Unit */
+struct __ppu {
+ unsigned char control;
+ unsigned char mask; /* color; show sprites, background */
+ signed char volatile const status;
+ struct {
+ unsigned char address;
+ unsigned char data;
+ } sprite;
+ unsigned char scroll;
+ struct {
+ unsigned char address;
+ unsigned char data;
+ } vram;
+};
+#define PPU (*(struct __ppu*)0x2000)
+#define SPRITE_DMA (APU.sprite.dma)
+
+/* Audio Processing Unit */
+struct __apu {
+ struct {
+ unsigned char control; /* duty, counter halt, volume/envelope */
+ unsigned char ramp;
+ unsigned char period_low; /* timing */
+ unsigned char len_period_high; /* length, timing */
+ } pulse[2];
+ struct {
+ unsigned char counter; /* counter halt, linear counter */
+ unsigned char unused;
+ unsigned char period_low; /* timing */
+ unsigned char len_period_high; /* length, timing */
+ } triangle;
+ struct {
+ unsigned char control; /* counter halt, volume/envelope */
+ unsigned char unused;
+ unsigned char period; /* loop, timing */
+ unsigned char len; /* length */
+ } noise;
+ struct {
+ unsigned char control; /* IRQ, loop, rate */
+ unsigned char output; /* output value */
+ unsigned char address;
+ unsigned char length;
+ } delta_mod; /* delta pulse-code modulation */
+ struct {
+ unsigned char dma;
+ } sprite;
+ signed char volatile status;
+ unsigned char unused;
+ unsigned char fcontrol;
+};
+#define APU (*(struct __apu*)0x4000)
+
+#define JOYPAD ((unsigned char volatile[2])0x4016)
+
+/* The addresses of the static drivers */
+extern void nes_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
+extern void nes_64_56_2_tgi[]; /* Referred to by tgi_static_stddrv[] */
+
+
+
+void waitvsync (void);
+/* Wait for start of the next frame */
+
+unsigned char get_tv (void);
+/* Return the video mode the machine is using. */
+
+
+
+/* End of nes.h */
+#endif
+/*****************************************************************************/
+/* */
+/* o65.h */
+/* */
+/* Definitions for the o65 file format */
+/* */
+/* */
+/* */
+/* (C) 2002-2009, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+/* This files exports structures and constants to handle the o65 relocatable
+** file format as defined by Andre Fachat. See the original document under
+**
+** http://www.6502.org/users/andre/o65/fileformat.html
+**
+** for more information.
+*/
+
+
+
+#ifndef _O65_H
+#define _O65_H
+
+
+
+/* o65 size type. It is 2 bytes for the 6502 and 4 bytes for the 65816 */
+typedef unsigned o65_size;
+
+
+/* Structure that defines the o65 file header */
+typedef struct o65_header o65_header;
+struct o65_header {
+ char marker[2]; /* Non-C64 marker */
+ char magic[3]; /* o65 magic */
+ char version; /* Version number */
+ unsigned mode; /* Mode word */
+ o65_size tbase; /* Original text (code) segment address */
+ o65_size tlen; /* Size of text (code) segment */
+ o65_size dbase; /* Original data segment address */
+ o65_size dlen; /* Size of data segment */
+ o65_size bbase; /* Original bss segment address */
+ o65_size blen; /* Size of bss segment */
+ o65_size zbase; /* Original zp segment address */
+ o65_size zlen; /* Size of zp segment */
+ o65_size stack; /* Stacksize needed */
+};
+
+
+
+/* Marker, magic and version number */
+#define O65_MARKER_0 0x01
+#define O65_MARKER_1 0x00
+#define O65_MAGIC_0 0x6F /* 'o' */
+#define O65_MAGIC_1 0x36 /* '6' */
+#define O65_MAGIC_2 0x35 /* '5' */
+#define O65_VERSION 0x00
+
+/* Defines for the mode word */
+#define O65_CPU_65816 0x8000 /* Executable is for 65816 */
+#define O65_CPU_6502 0x0000 /* Executable is for the 6502 */
+#define O65_CPU_MASK 0x8000 /* Mask to extract CPU type */
+
+#define O65_RELOC_PAGE 0x4000 /* Page wise relocation */
+#define O65_RELOC_BYTE 0x0000 /* Byte wise relocation */
+#define O65_RELOC_MASK 0x4000 /* Mask to extract relocation type */
+
+#define O65_SIZE_32BIT 0x2000 /* All size words are 32bit */
+#define O65_SIZE_16BIT 0x0000 /* All size words are 16bit */
+#define O65_SIZE_MASK 0x2000 /* Mask to extract size */
+
+#define O65_FTYPE_OBJ 0x1000 /* Object file */
+#define O65_FTYPE_EXE 0x0000 /* Executable file */
+#define O65_FTYPE_MASK 0x1000 /* Mask to extract type */
+
+#define O65_ADDR_SIMPLE 0x0800 /* Simple addressing */
+#define O65_ADDR_DEFAULT 0x0000 /* Default addressing */
+#define O65_ADDR_MASK 0x0800 /* Mask to extract addressing */
+
+#define O65_CHAIN 0x0400 /* Chained file, another one follows */
+#define O65_CHAIN_MASK 0x0400 /* Mask to extract chain flag */
+
+#define O65_BSSZERO 0x0200 /* BSS segment must be zeroed */
+#define O65_BSSZERO_MASK 0x0200 /* Mask to extract bss zero flag */
+
+/* The following is used if O65_CPU == 6502 */
+#define O65_CPU2_6502 0x0000 /* Executable is for 6502 */
+#define O65_CPU2_65C02 0x0010 /* Executable is for 65C02 */
+#define O65_CPU2_65SC02 0x0020 /* Executable is for 65SC02 */
+#define O65_CPU2_65CE02 0x0030 /* Executable is for 65CE02 */
+#define O65_CPU2_6502X 0x0040 /* Executable is for NMOS 6502 */
+#define O65_CPU2_65816_EMU 0x0050 /* Executable is for 65816 in emul mode */
+#define O65_CPU2_MASK 0x00F0 /* Mask to extract CPU2 field */
+
+#define O65_ALIGN_1 0x0000 /* Bytewise alignment */
+#define O65_ALIGN_2 0x0001 /* Align words */
+#define O65_ALIGN_4 0x0002 /* Align longwords */
+#define O65_ALIGN_256 0x0003 /* Align pages (256 bytes) */
+#define O65_ALIGN_MASK 0x0003 /* Mask to extract alignment */
+
+/* The mode word as generated by the ld65 linker */
+#define O65_MODE_CC65 (O65_CPU_6502 | \
+ O65_RELOC_BYTE | \
+ O65_SIZE_16BIT | \
+ O65_FTYPE_EXE | \
+ O65_ADDR_SIMPLE | \
+ O65_ALIGN_1)
+
+/* The four o65 segment types. */
+#define O65_SEGID_UNDEF 0x00
+#define O65_SEGID_ABS 0x01
+#define O65_SEGID_TEXT 0x02
+#define O65_SEGID_DATA 0x03
+#define O65_SEGID_BSS 0x04
+#define O65_SEGID_ZP 0x05
+#define O65_SEGID_MASK 0x07
+
+/* Relocation type codes */
+#define O65_RTYPE_WORD 0x80
+#define O65_RTYPE_HIGH 0x40
+#define O65_RTYPE_LOW 0x20
+#define O65_RTYPE_SEGADDR 0xC0
+#define O65_RTYPE_SEG 0xA0
+#define O65_RTYPE_MASK 0xE0
+
+/* Segment IDs */
+#define O65_SEGID_UNDEF 0x00
+#define O65_SEGID_ABS 0x01
+#define O65_SEGID_TEXT 0x02
+#define O65_SEGID_DATA 0x03
+#define O65_SEGID_BSS 0x04
+#define O65_SEGID_ZP 0x05
+#define O65_SEGID_MASK 0x07
+
+/* Option tags */
+#define O65_OPT_FILENAME 0
+#define O65_OPT_OS 1
+#define O65_OPT_ASM 2
+#define O65_OPT_AUTHOR 3
+#define O65_OPT_TIMESTAMP 4
+
+/* Operating system codes for O65_OPT_OS */
+#define O65_OS_OSA65 1
+#define O65_OS_LUNIX 2
+#define O65_OS_CC65 3
+#define O65_OS_OPENCBM 4
+
+
+
+/* End of o65.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* osic1p.h */
+/* */
+/* Challenger 1P system specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2015 Stephan Muehlstrasser */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+#ifndef _OSIC1P_H
+#define _OSIC1P_H
+
+/* Check for errors */
+#if !defined(__OSIC1P__)
+# error "This module may only be used when compiling for the Challenger 1P!"
+#endif
+
+/* Colors are not functional, display is black and white only. */
+#define COLOR_BLACK 0x00
+#define COLOR_WHITE 0x01
+
+#define CH_ULCORNER 0xCC
+#define CH_URCORNER 0xCD
+#define CH_LLCORNER 0xCB
+#define CH_LRCORNER 0xCE
+#define CH_TTEE 0xD9
+#define CH_BTEE 0xD7
+#define CH_LTEE 0xD8
+#define CH_RTEE 0xDA
+#define CH_CROSS 0xDB
+#define CH_HLINE 0x94
+#define CH_VLINE 0x95
+
+#define CH_ENTER 0x0D
+
+/* The following #defines will cause the matching functions calls in conio.h
+** to be overlaid by macros with the same names, saving the function call
+** overhead.
+*/
+#define _textcolor(color) COLOR_WHITE
+#define _bgcolor(color) COLOR_BLACK
+#define _bordercolor(color) COLOR_BLACK
+#define _cpeekcolor(color) COLOR_WHITE
+
+#endif
+/*****************************************************************************/
+/* */
+/* pce.h */
+/* */
+/* PC-Engine system-specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2015, Groepaz/Hitmen */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+#ifndef _PCE_H
+#define _PCE_H
+
+/* Check for errors */
+#if !defined(__PCE__)
+# error This module may only be used when compiling for the PCE!
+#endif
+
+#define CH_HLINE 1
+#define CH_VLINE 2
+#define CH_CROSS 3
+#define CH_ULCORNER 4
+#define CH_URCORNER 5
+#define CH_LLCORNER 6
+#define CH_LRCORNER 7
+#define CH_TTEE 8
+#define CH_BTEE 9
+#define CH_LTEE 10
+#define CH_RTEE 11
+
+#define CH_ENTER 13
+#define CH_PI 18
+
+/* Color defines (CBM-compatible, for conio) */
+#define COLOR_BLACK 0x00
+#define COLOR_WHITE 0x01
+#define COLOR_RED 0x02
+#define COLOR_CYAN 0x03
+#define COLOR_PURPLE 0x04
+#define COLOR_GREEN 0x05
+#define COLOR_BLUE 0x06
+#define COLOR_YELLOW 0x07
+#define COLOR_ORANGE 0x08
+#define COLOR_BROWN 0x09
+#define COLOR_LIGHTRED 0x0A
+#define COLOR_GRAY1 0x0B
+#define COLOR_GRAY2 0x0C
+#define COLOR_LIGHTGREEN 0x0D
+#define COLOR_LIGHTBLUE 0x0E
+#define COLOR_GRAY3 0x0F
+
+#define TV_NTSC 0
+#define TV_PAL 1
+#define TV_OTHER 2
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x10
+#define JOY_DOWN_MASK 0x40
+#define JOY_LEFT_MASK 0x80
+#define JOY_RIGHT_MASK 0x20
+#define JOY_BTN_1_MASK 0x01
+#define JOY_BTN_2_MASK 0x02
+#define JOY_BTN_3_MASK 0x04
+#define JOY_BTN_4_MASK 0x08
+
+#define JOY_BTN_I_MASK JOY_BTN_1_MASK
+#define JOY_BTN_II_MASK JOY_BTN_2_MASK
+#define JOY_SELECT_MASK JOY_BTN_3_MASK
+#define JOY_RUN_MASK JOY_BTN_4_MASK
+
+#define JOY_BTN_I(v) ((v) & JOY_BTN_I_MASK)
+#define JOY_BTN_II(v) ((v) & JOY_BTN_II_MASK)
+#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
+#define JOY_RUN(v) ((v) & JOY_RUN_MASK)
+
+/* No support for dynamically loadable drivers */
+#define DYN_DRV 0
+
+/* The addresses of the static drivers */
+extern void pce_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
+
+void waitvsync (void);
+/* Wait for start of the next frame */
+
+/* NOTE: all PCEs are NTSC. */
+#define get_tv() TV_NTSC
+/* Return the video mode the machine is using. */
+
+/* End of pce.h */
+#endif
+/*****************************************************************************/
+/* */
+/* peekpoke.h */
+/* */
+/* PEEK and POKE macros for those who want to write BASIC code in C */
+/* */
+/* */
+/* */
+/* (C) 2003 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _PEEKPOKE_H
+#define _PEEKPOKE_H
+
+
+
+/*****************************************************************************/
+/* Macros */
+/*****************************************************************************/
+
+
+
+#define POKE(addr,val) (*(unsigned char*) (addr) = (val))
+#define POKEW(addr,val) (*(unsigned*) (addr) = (val))
+#define PEEK(addr) (*(unsigned char*) (addr))
+#define PEEKW(addr) (*(unsigned*) (addr))
+
+
+
+/* End of peekpoke.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* pen.h */
+/* */
+/* Lightpen API */
+/* */
+/* */
+/* This software is provided "as-is", without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated, but is not required. */
+/* 2. Altered source versions must be marked plainly as such; and, must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _PEN_H
+#define _PEN_H
+
+
+
+/*****************************************************************************/
+/* Declarations */
+/*****************************************************************************/
+
+
+
+/* A program optionally can set this pointer to a function that gives
+** a calibration value to a driver. If this pointer isn't NULL,
+** then a driver that wants a value can call that function.
+** pen_adjuster must be set before the driver is installed.
+*/
+extern void __fastcall__ (*pen_adjuster) (unsigned char *pValue);
+
+
+
+/*****************************************************************************/
+/* Functions */
+/*****************************************************************************/
+
+
+
+void __fastcall__ pen_calibrate (unsigned char *XOffset);
+/* Ask the user to help to calibrate a lightpen. Changes the screen!
+** A pointer to this function can be put into pen_adjuster.
+*/
+
+void __fastcall__ pen_adjust (const char *filename);
+/* Get a lightpen calibration value from a file if it exists. Otherwise, call
+** pen_calibrate() to create a value; then, write it into a file, so that it
+** will be available at the next time that the lightpen is used.
+** Might change the screen.
+** pen_adjust() is optional; if you want to use its feature,
+** then it must be called before a driver is installed.
+** Note: This function merely saves the file-name pointer, and sets
+** the pen_adjuster pointer. The file will be read only when a driver
+** is installed, and only if that driver wants to be calibrated.
+*/
+
+
+
+/* End of pen.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* pet.h */
+/* */
+/* PET system specific definitions */
+/* */
+/* */
+/* */
+/* (C) 1998-2005 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _PET_H
+#define _PET_H
+
+
+
+/* Check for errors */
+#if !defined(__PET__)
+# error This module may only be used when compiling for the CBM PET!
+#endif
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Color defines */
+#define COLOR_BLACK 0x00
+#define COLOR_WHITE 0x01
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x01
+#define JOY_DOWN_MASK 0x02
+#define JOY_LEFT_MASK 0x04
+#define JOY_RIGHT_MASK 0x08
+#define JOY_BTN_1_MASK 0x10
+
+/* Define hardware */
+#include <_pia.h>
+#define PIA1 (*(struct __pia*)0xE810)
+#define PIA2 (*(struct __pia*)0xE820)
+
+#include <_6522.h>
+#define VIA (*(struct __6522*)0xE840)
+
+/* All models from 40xx and above */
+#include <_6545.h>
+#define CRTC (*(struct __6545)0xE880)
+
+/* SuperPET only */
+#include <_6551.h>
+#define ACIA (*(struct __6551*)0xEFF0)
+
+
+
+/*****************************************************************************/
+/* Variables */
+/*****************************************************************************/
+
+
+
+/* The addresses of the static drivers */
+extern void pet_ptvjoy_joy[];
+extern void pet_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+/* The following #defines will cause the matching functions calls in conio.h
+** to be overlaid by macros with the same names, saving the function call
+** overhead.
+*/
+#define _textcolor(color) COLOR_WHITE
+#define _bgcolor(color) COLOR_BLACK
+#define _bordercolor(color) COLOR_BLACK
+#define _cpeekcolor(color) COLOR_WHITE
+
+
+
+/* End of pet.h */
+#endif
+/*****************************************************************************/
+/* */
+/* plus4.h */
+/* */
+/* Plus/4 system specific definitions */
+/* */
+/* */
+/* */
+/* (C) 1998-2006, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _PLUS4_H
+#define _PLUS4_H
+
+
+
+/* Check for errors */
+#if !defined(__PLUS4__)
+# error This module may only be used when compiling for the Plus/4!
+#endif
+
+
+
+/* Include the base header file for the 264 series. */
+#include
+
+/* Define hardware */
+#include <_6551.h>
+#define ACIA (*(struct __6551*)0xFD00)
+
+
+
+/* The addresses of the static drivers */
+extern void plus4_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
+extern void plus4_stdser_ser[]; /* Referred to by ser_static_stddrv[] */
+
+
+
+/* End of plus4.h */
+#endif
+/*****************************************************************************/
+/* */
+/* serial.h */
+/* */
+/* Serial communication API */
+/* */
+/* */
+/* */
+/* (C) 2003-2012, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _SERIAL_H
+#define _SERIAL_H
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Baudrate settings */
+#define SER_BAUD_45_5 0x00
+#define SER_BAUD_50 0x01
+#define SER_BAUD_75 0x02
+#define SER_BAUD_110 0x03
+#define SER_BAUD_134_5 0x04
+#define SER_BAUD_150 0x05
+#define SER_BAUD_300 0x06
+#define SER_BAUD_600 0x07
+#define SER_BAUD_1200 0x08
+#define SER_BAUD_1800 0x09
+#define SER_BAUD_2400 0x0A
+#define SER_BAUD_3600 0x0B
+#define SER_BAUD_4800 0x0C
+#define SER_BAUD_7200 0x0D
+#define SER_BAUD_9600 0x0E
+#define SER_BAUD_19200 0x0F
+#define SER_BAUD_38400 0x10
+#define SER_BAUD_57600 0x11
+#define SER_BAUD_115200 0x12
+#define SER_BAUD_230400 0x13
+#define SER_BAUD_31250 0x14
+#define SER_BAUD_62500 0x15
+#define SER_BAUD_56_875 0x16
+
+/* Data bit settings */
+#define SER_BITS_5 0x00
+#define SER_BITS_6 0x01
+#define SER_BITS_7 0x02
+#define SER_BITS_8 0x03
+
+/* Stop bit settings */
+#define SER_STOP_1 0x00 /* One stop bit */
+#define SER_STOP_2 0x01 /* Two stop bits */
+
+/* Parity settings */
+#define SER_PAR_NONE 0x00
+#define SER_PAR_ODD 0x01
+#define SER_PAR_EVEN 0x02
+#define SER_PAR_MARK 0x03
+#define SER_PAR_SPACE 0x04
+
+/* Handshake settings. The latter two may be combined. */
+#define SER_HS_NONE 0x00 /* No handshake */
+#define SER_HS_HW 0x01 /* Hardware (RTS/CTS) handshake */
+#define SER_HS_SW 0x02 /* Software handshake */
+
+/* Bit masks to mask out things from the status returned by ser_status.
+** These are 6551 specific and must be mapped by drivers for other chips.
+*/
+#define SER_STATUS_PE 0x01 /* Parity error */
+#define SER_STATUS_FE 0x02 /* Framing error */
+#define SER_STATUS_OE 0x04 /* Overrun error */
+#define SER_STATUS_DCD 0x20 /* NOT data carrier detect */
+#define SER_STATUS_DSR 0x40 /* NOT data set ready */
+
+/* Error codes returned by all functions */
+#define SER_ERR_OK 0x00 /* Not an error - relax */
+#define SER_ERR_NO_DRIVER 0x01 /* No driver available */
+#define SER_ERR_CANNOT_LOAD 0x02 /* Error loading driver */
+#define SER_ERR_INV_DRIVER 0x03 /* Invalid driver */
+#define SER_ERR_NO_DEVICE 0x04 /* Device (hardware) not found */
+#define SER_ERR_BAUD_UNAVAIL 0x05 /* Baud rate not available */
+#define SER_ERR_NO_DATA 0x06 /* Nothing to read */
+#define SER_ERR_OVERFLOW 0x07 /* No room in send buffer */
+#define SER_ERR_INIT_FAILED 0x08 /* Initialization failed */
+#define SER_ERR_INV_IOCTL 0x09 /* IOCTL not supported */
+#define SER_ERR_INSTALLED 0x0A /* A driver is already installed */
+#define SER_ERR_NOT_OPEN 0x0B /* Driver is not open */
+
+/* Struct containing parameters for the serial port */
+struct ser_params {
+ unsigned char baudrate; /* Baudrate */
+ unsigned char databits; /* Number of data bits */
+ unsigned char stopbits; /* Number of stop bits */
+ unsigned char parity; /* Parity setting */
+ unsigned char handshake; /* Type of handshake to use */
+};
+
+/* The name of the standard serial driver for a platform */
+extern const char ser_stddrv[];
+
+/* The address of the static standard serial driver for a platform */
+extern const void ser_static_stddrv[];
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+unsigned char __fastcall__ ser_load_driver (const char* driver);
+/* Load and install a serial driver. Return an error code. */
+
+unsigned char ser_unload (void);
+/* Uninstall, then unload the currently loaded driver. */
+
+unsigned char __fastcall__ ser_install (const void* driver);
+/* Install an already loaded driver. Return an error code. */
+
+unsigned char ser_uninstall (void);
+/* Uninstall the currently loaded driver and return an error code.
+** Note: This call does not free allocated memory.
+*/
+
+unsigned char __fastcall__ ser_open (const struct ser_params* params);
+/* "Open" the port by setting the port parameters and enable interrupts. */
+
+unsigned char ser_close (void);
+/* "Close" the port. Clear buffers and disable interrupts. */
+
+unsigned char __fastcall__ ser_get (char* b);
+/* Get a character from the serial port. If no characters are available, the
+** function will return SER_ERR_NO_DATA, so this is not a fatal error.
+*/
+
+unsigned char __fastcall__ ser_put (char b);
+/* Send a character via the serial port. There is a transmit buffer, but
+** transmitting is not done via interrupt. The function returns
+** SER_ERR_OVERFLOW if there is no space left in the transmit buffer.
+*/
+
+unsigned char __fastcall__ ser_status (unsigned char* status);
+/* Return the serial port status. */
+
+unsigned char __fastcall__ ser_ioctl (unsigned char code, void* data);
+/* Driver specific entry. */
+
+
+
+/* End of serial.h */
+#endif
+/*****************************************************************************/
+/* */
+/* setjmp.h */
+/* */
+/* Nonlocal jumps */
+/* */
+/* */
+/* */
+/* (C) 1998-2009, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _SETJMP_H
+#define _SETJMP_H
+
+
+
+typedef char jmp_buf [5];
+
+
+
+int __fastcall__ __setjmp (jmp_buf buf);
+#define setjmp __setjmp /* ISO insists on a macro */
+void __fastcall__ longjmp (jmp_buf buf, int retval) __attribute__((noreturn));
+
+
+
+/* End of setjmp.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* signal.h */
+/* */
+/* Signal handling definitions */
+/* */
+/* */
+/* */
+/* (C) 2002-2005, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _SIGNAL_H
+#define _SIGNAL_H
+
+
+
+/* sig_atomic_t */
+typedef unsigned char sig_atomic_t;
+
+/* Type of a signal handler */
+typedef void __fastcall__ (*__sigfunc) (int);
+
+/* Functions that implement SIG_IGN and SIG_DFL */
+void __fastcall__ __sig_ign (int);
+void __fastcall__ __sig_dfl (int);
+
+/* Standard signal handling functions */
+#define SIG_DFL __sig_dfl
+#define SIG_IGN __sig_ign
+#define SIG_ERR ((__sigfunc) 0x0000)
+
+/* Signal numbers */
+#define SIGABRT 0
+#define SIGFPE 1
+#define SIGILL 2
+#define SIGINT 3
+#define SIGSEGV 4
+#define SIGTERM 5
+
+/* Function declarations */
+__sigfunc __fastcall__ signal (int sig, __sigfunc func);
+int __fastcall__ raise (int sig);
+
+
+
+/* End of signal.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* stdarg.h */
+/* */
+/* Variable arguments */
+/* */
+/* */
+/* */
+/* (C) 1998-2004 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _STDARG_H
+#define _STDARG_H
+
+
+
+typedef unsigned char* va_list;
+
+#define va_start(ap, fix) ap = ((va_list)&(fix))
+#define va_arg(ap,type) (*(type*)(ap -= ((sizeof (type) + 1) & ~1)))
+#if __CC65_STD__ >= __CC65_STD_C99__
+#define va_copy(dest, src) ((dest)=(src))
+#endif
+#define va_end(ap)
+
+
+
+/* End of stdarg.h */
+#endif
+
+
+
+
+/*****************************************************************************/
+/* */
+/* stdbool.h */
+/* */
+/* C99 Boolean definitions */
+/* */
+/* */
+/* */
+/* (C) 2002 Greg King */
+/* */
+/* */
+/* This software is provided "as-is," without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment, in the product's documentation, */
+/* would be appreciated, but is not required. */
+/* 2. Alterred source versions must be marked plainly as such, */
+/* and must not be misrepresented as being the original software. */
+/* 3. This notice may not be removed or alterred */
+/* from any source distribution. */
+/*****************************************************************************/
+
+
+
+#ifndef _STDBOOL_H
+#define _STDBOOL_H
+
+
+
+#define bool _Bool
+typedef unsigned char _Bool;
+
+/* Standard test-results. */
+#define false 0
+#define true 1
+
+/* All three names are macroes. */
+#define __bool_true_false_are_defined 1
+
+
+
+/* End of stdbool.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* stddef.h */
+/* */
+/* Common definitions */
+/* */
+/* */
+/* */
+/* (C) 1998-2009, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _STDDEF_H
+#define _STDDEF_H
+
+
+
+/* Standard data types */
+#ifndef _HAVE_ptrdiff_t
+#define _HAVE_ptrdiff_t
+typedef int ptrdiff_t;
+#endif
+#ifndef _HAVE_wchar_t
+#define _HAVE_wchar_t
+typedef char wchar_t;
+#endif
+#ifndef _HAVE_size_t
+#define _HAVE_size_t
+typedef unsigned size_t;
+#endif
+
+/* NULL pointer */
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+/* offsetof macro */
+#define offsetof(type, member) (size_t) (&((type*) 0)->member)
+
+
+
+/* End of stddef.h */
+#endif
+/*****************************************************************************/
+/* */
+/* stdint.h */
+/* */
+/* Standard integer types */
+/* */
+/* */
+/* */
+/* (C) 2002 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@musoftware.de */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+/* Note: This file is not fully ISO 9899-1999 compliant because cc65 lacks
+** a 64 bit data types. The declarations have been adjusted accordingly.
+*/
+
+
+
+#ifndef _STDINT_H
+#define _STDINT_H
+
+
+
+/* Exact-width integer types */
+typedef signed char int8_t;
+typedef int int16_t;
+typedef long int32_t;
+typedef unsigned char uint8_t;
+typedef unsigned uint16_t;
+typedef unsigned long uint32_t;
+
+#define INT8_MIN ((int8_t) 0x80)
+#define INT8_MAX ((int8_t) 0x7F)
+#define INT16_MIN ((int16_t) 0x8000)
+#define INT16_MAX ((int16_t) 0x7FFF)
+#define INT32_MIN ((int32_t) 0x80000000)
+#define INT32_MAX ((int32_t) 0x7FFFFFFF)
+#define UINT8_MAX ((uint8_t) 0xFF)
+#define UINT16_MAX ((uint16_t) 0xFFFF)
+#define UINT32_MAX ((uint32_t) 0xFFFFFFFF)
+
+/* Minimum-width integer types */
+typedef signed char int_least8_t;
+typedef int int_least16_t;
+typedef long int_least32_t;
+typedef unsigned char uint_least8_t;
+typedef unsigned uint_least16_t;
+typedef unsigned long uint_least32_t;
+
+#define INT_LEAST8_MIN ((int_least8_t) 0x80)
+#define INT_LEAST8_MAX ((int_least8_t) 0x7F)
+#define INT_LEAST16_MIN ((int_least16_t) 0x8000)
+#define INT_LEAST16_MAX ((int_least16_t) 0x7FFF)
+#define INT_LEAST32_MIN ((int_least32_t) 0x80000000)
+#define INT_LEAST32_MAX ((int_least32_t) 0x7FFFFFFF)
+#define UINT_LEAST8_MAX ((uint_least8_t) 0xFF)
+#define UINT_LEAST16_MAX ((uint_least16_t) 0xFFFF)
+#define UINT_LEAST32_MAX ((uint_least32_t) 0xFFFFFFFF)
+
+/* Fastest minimum-width integer types */
+typedef signed char int_fast8_t;
+typedef int int_fast16_t;
+typedef long int_fast32_t;
+typedef unsigned char uint_fast8_t;
+typedef unsigned uint_fast16_t;
+typedef unsigned long uint_fast32_t;
+
+#define INT_FAST8_MIN ((int_fast8_t) 0x80)
+#define INT_FAST8_MAX ((int_fast8_t) 0x7F)
+#define INT_FAST16_MIN ((int_fast16_t) 0x8000)
+#define INT_FAST16_MAX ((int_fast16_t) 0x7FFF)
+#define INT_FAST32_MIN ((int_fast32_t) 0x80000000)
+#define INT_FAST32_MAX ((int_fast32_t) 0x7FFFFFFF)
+#define UINT_FAST8_MAX ((uint_fast8_t) 0xFF)
+#define UINT_FAST16_MAX ((uint_fast16_t) 0xFFFF)
+#define UINT_FAST32_MAX ((uint_fast32_t) 0xFFFFFFFF)
+
+/* Integer types capable of holding object pointers */
+typedef int intptr_t;
+typedef unsigned uintptr_t;
+
+#define INTPTR_MIN ((intptr_t)0x8000)
+#define INTPTR_MAX ((intptr_t)0x7FFF)
+#define UINTPTR_MAX ((uintptr_t) 0xFFFF)
+
+/* Greatest width integer types */
+typedef long intmax_t;
+typedef unsigned long uintmax_t;
+
+#define INTMAX_MIN ((intmax_t) 0x80000000)
+#define INTMAX_MAX ((intmax_t) 0x7FFFFFFF)
+#define UINTMAX_MAX ((uintmax_t) 0xFFFFFFFF)
+
+/* Limits of other integer types */
+#define PTRDIFF_MIN ((int) 0x8000)
+#define PTRDIFF_MAX ((int) 0x7FFF)
+
+#define SIG_ATOMIC_MIN ((unsigned char) 0x00)
+#define SIG_ATOMIC_MAX ((unsigned char) 0xFF)
+
+#define SIZE_MAX 0xFFFF
+
+/* Macros for minimum width integer constants */
+#define INT8_C(c) c
+#define INT16_C(c) c
+#define INT32_C(c) c##L
+#define UINT8_C(c) c##U
+#define UINT16_C(c) c##U
+#define UINT32_C(c) c##UL
+
+/* Macros for greatest width integer constants */
+#define INTMAX_C(c) c##L
+#define UINTMAX_C(c) c##UL
+
+
+
+/* End of stdint.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* stdio.h */
+/* */
+/* Input/output */
+/* */
+/* */
+/* */
+/* (C) 1998-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _STDIO_H
+#define _STDIO_H
+
+
+/* NULL pointer */
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+/* size_t is needed */
+#ifndef _HAVE_size_t
+#define _HAVE_size_t
+typedef unsigned size_t;
+#endif
+
+/* stdio.h should not define va_list, so we use an equivalent type in the
+ compiler namespace instead */
+typedef unsigned char* __va_list;
+
+/* Types */
+typedef struct _FILE FILE;
+typedef unsigned long fpos_t;
+
+/* Standard file descriptors */
+extern FILE* stdin;
+extern FILE* stdout;
+extern FILE* stderr;
+
+/* Standard defines */
+#define _IOFBF 0
+#define _IOLBF 1
+#define _IONBF 2
+#define BUFSIZ 256
+#define EOF -1
+#define FOPEN_MAX 8
+#define SEEK_CUR 0
+#define SEEK_END 1
+#define SEEK_SET 2
+#define TMP_MAX 256
+
+/* These defines that are platform dependent */
+/* FILENAME_MAX is defined as the same value as PATH_MAX in limits.h, but we
+ are not allowed to include limits.h here */
+#if defined(__APPLE2__)
+# define FILENAME_MAX (64+1)
+#elif defined(__ATARI__)
+# define FILENAME_MAX (63+1)
+#elif defined(__CBM__)
+# define FILENAME_MAX (255) /* should be 256+1, see libsrc/common/_cmd.s why it's not */
+#elif defined(__LUNIX__)
+# define FILENAME_MAX (80+1)
+#elif defined(__TELESTRAT__)
+# define FILENAME_MAX (50+1)
+#else
+# define FILENAME_MAX (16+1)
+#endif
+
+#define L_tmpnam FILENAME_MAX
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+/* Functions */
+void __fastcall__ clearerr (FILE* f);
+int __fastcall__ fclose (FILE* f);
+int __fastcall__ feof (FILE* f);
+int __fastcall__ ferror (FILE* f);
+int __fastcall__ fflush (FILE* f);
+int __fastcall__ fgetc (FILE* f);
+char* __fastcall__ fgets (char* buf, size_t size, FILE* f);
+FILE* __fastcall__ fopen (const char* name, const char* mode);
+int fprintf (FILE* f, const char* format, ...);
+int __fastcall__ fputc (int c, FILE* f);
+int __fastcall__ fputs (const char* s, FILE* f);
+size_t __fastcall__ fread (void* buf, size_t size, size_t count, FILE* f);
+FILE* __fastcall__ freopen (const char* name, const char* mode, FILE* f);
+size_t __fastcall__ fwrite (const void* buf, size_t size, size_t count, FILE* f);
+int __fastcall__ fgetpos (FILE* f, fpos_t *pos);
+int __fastcall__ fsetpos (FILE* f, const fpos_t* pos);
+long __fastcall__ ftell (FILE* f);
+int __fastcall__ fseek (FILE* f, long offset, int whence);
+void __fastcall__ rewind (FILE *f);
+int getchar (void);
+char* __fastcall__ gets (char* s);
+void __fastcall__ perror (const char* s);
+int printf (const char* format, ...);
+int __fastcall__ putchar (int c);
+int __fastcall__ puts (const char* s);
+int __fastcall__ remove (const char* name);
+int __fastcall__ rename (const char* oldname, const char* newname);
+int snprintf (char* buf, size_t size, const char* format, ...);
+int sprintf (char* buf, const char* format, ...);
+int __fastcall__ ungetc (int c, FILE* f);
+int __fastcall__ vfprintf (FILE* f, const char* format, __va_list ap);
+int __fastcall__ vprintf (const char* format, __va_list ap);
+int __fastcall__ vsnprintf (char* buf, size_t size, const char* format, __va_list ap);
+int __fastcall__ vsprintf (char* buf, const char* format, __va_list ap);
+
+int scanf (const char* format, ...);
+int fscanf (FILE* f, const char* format, ...);
+int sscanf (const char* s, const char* format, ...);
+int __fastcall__ vscanf (const char* format, __va_list ap);
+int __fastcall__ vsscanf (const char* s, const char* format, __va_list ap);
+int __fastcall__ vfscanf (FILE* f, const char* format, __va_list ap);
+
+#if __CC65_STD__ == __CC65_STD_CC65__
+FILE* __fastcall__ fdopen (int fd, const char* mode); /* Unix */
+int __fastcall__ fileno (FILE* f); /* Unix */
+#endif
+void __fastcall__ __poserror (const char* msg); /* cc65 */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _poserror __poserror
+#endif
+
+/* Masking macros for some functions */
+#define getc(f) fgetc (f) /* ANSI */
+#define putc(c, f) fputc (c, f) /* ANSI */
+
+
+
+/* End of stdio.h */
+#endif
+/*****************************************************************************/
+/* */
+/* stdlib.h */
+/* */
+/* General utilities */
+/* */
+/* */
+/* */
+/* (C) 1998-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _STDLIB_H
+#define _STDLIB_H
+
+
+
+/* size_t is needed */
+#ifndef _HAVE_size_t
+typedef unsigned size_t;
+#define _HAVE_size_t
+#endif
+
+/* NULL pointer */
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+/* Standard exit codes */
+#define EXIT_SUCCESS 0
+#define EXIT_FAILURE 1
+
+#if __CC65_STD__ == __CC65_STD_CC65__
+
+/* Those non-standard cc65 exit constants definitions are in addition
+** to the EXIT_SUCCESS and EXIT_FAILURE constants, which should not be
+** redefined
+*/
+#define EXIT_ASSERT 2
+#define EXIT_ABORT 3
+
+#endif
+
+
+/* Return type of the div function */
+typedef struct {
+ int rem;
+ int quot;
+} div_t;
+
+/* Return type of the ldiv function (which currently doesn't exist) */
+typedef struct {
+ long rem;
+ long quot;
+} ldiv_t;
+
+/* Memory management */
+void* __fastcall__ malloc (size_t size);
+void* __fastcall__ calloc (size_t count, size_t size);
+void* __fastcall__ realloc (void* block, size_t size);
+void __fastcall__ free (void* block);
+
+/* Non standard memory management functions */
+
+#if __CC65_STD__ == __CC65_STD_CC65__
+int __fastcall__ posix_memalign (void** memptr, size_t alignment, size_t size);
+/* Allocate a block of memory with the given "size", which is aligned to a
+** memory address that is a multiple of "alignment". "alignment" MUST NOT be
+** zero, and MUST be a power of two; otherwise, this function will return
+** EINVAL. The function returns ENOMEM if not enough memory is available
+** to satisfy the request. "memptr" must point to a variable; that variable
+** will return the address of the allocated memory. Use free() to release that
+** allocated block.
+*/
+#endif
+
+void __fastcall__ __heapadd (void* mem, size_t size);
+/* Add a block to the heap */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _heapadd __heapadd
+#endif
+
+size_t __fastcall__ __heapblocksize (const void* block);
+/* Return the size of an allocated block */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _heapblocksize __heapblocksize
+#endif
+
+size_t __heapmemavail (void);
+/* Return the total free heap space */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _heapmemavail __heapmemavail
+#endif
+
+size_t __heapmaxavail (void);
+/* Return the size of the largest free block on the heap */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _heapmaxavail __heapmaxavail
+#endif
+
+
+/* Random numbers */
+#define RAND_MAX 0x7FFF
+int rand (void);
+void __fastcall__ srand (unsigned seed);
+void __randomize (void); /* Non-standard */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _randomize __randomize
+#endif
+
+/* Other standard stuff */
+void abort (void) __attribute__ ((noreturn));
+int __fastcall__ abs (int val);
+long __fastcall__ labs (long val);
+int __fastcall__ atoi (const char* s);
+long __fastcall__ atol (const char* s);
+int __fastcall__ atexit (void (*exitfunc) (void));
+void* __fastcall__ bsearch (const void* key, const void* base, size_t n,
+ size_t size, int __fastcall__ (* cmp) (const void*, const void*));
+div_t __fastcall__ div (int numer, int denom);
+void __fastcall__ exit (int ret) __attribute__ ((noreturn));
+char* __fastcall__ getenv (const char* name);
+void __fastcall__ qsort (void* base, size_t count, size_t size,
+ int __fastcall__ (* compare) (const void*, const void*));
+long __fastcall__ strtol (const char* nptr, char** endptr, int base);
+unsigned long __fastcall__ strtoul (const char* nptr, char** endptr, int base);
+int __fastcall__ system (const char* s);
+
+/* Non-ANSI functions */
+void __fastcall__ __swap (void* p, void* q, size_t size);
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _swap __swap
+#endif
+#if __CC65_STD__ == __CC65_STD_CC65__
+char* __fastcall__ itoa (int val, char* buf, int radix);
+char* __fastcall__ utoa (unsigned val, char* buf, int radix);
+char* __fastcall__ ltoa (long val, char* buf, int radix);
+char* __fastcall__ ultoa (unsigned long val, char* buf, int radix);
+int __fastcall__ putenv (char* s);
+#endif
+
+
+
+/* End of stdlib.h */
+#endif
+/*****************************************************************************/
+/* */
+/* string.h */
+/* */
+/* String handling */
+/* */
+/* */
+/* */
+/* (C) 1998-2014, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _STRING_H
+#define _STRING_H
+
+/* NULL pointer */
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+/* size_t is needed */
+#ifndef _HAVE_size_t
+#define _HAVE_size_t
+typedef unsigned size_t;
+#endif
+
+char* __fastcall__ strcat (char* dest, const char* src);
+char* __fastcall__ strchr (const char* s, int c);
+int __fastcall__ strcmp (const char* s1, const char* s2);
+int __fastcall__ strcoll (const char* s1, const char* s2);
+char* __fastcall__ strcpy (char* dest, const char* src);
+size_t __fastcall__ strcspn (const char* s1, const char* s2);
+char* __fastcall__ strerror (int errcode);
+size_t __fastcall__ strlen (const char* s);
+char* __fastcall__ strncat (char* s1, const char* s2, size_t count);
+int __fastcall__ strncmp (const char* s1, const char* s2, size_t count);
+char* __fastcall__ strncpy (char* dest, const char* src, size_t count);
+char* __fastcall__ strpbrk (const char* str, const char* set);
+char* __fastcall__ strrchr (const char* s, int c);
+size_t __fastcall__ strspn (const char* s1, const char* s2);
+char* __fastcall__ strstr (const char* str, const char* substr);
+char* __fastcall__ strtok (char* s1, const char* s2);
+size_t __fastcall__ strxfrm (char* s1, const char* s2, size_t count);
+void* __fastcall__ memchr (const void* mem, int c, size_t count);
+int __fastcall__ memcmp (const void* p1, const void* p2, size_t count);
+void* __fastcall__ memcpy (void* dest, const void* src, size_t count);
+void* __fastcall__ memmove (void* dest, const void* src, size_t count);
+void* __fastcall__ memset (void* s, int c, size_t count);
+
+/* The following is an internal function, the compiler will replace memset
+** with it if the fill value is zero. Never use this one directly!
+*/
+void* __fastcall__ __bzero (void* ptr, size_t n);
+
+/* Non standard: */
+#if __CC65_STD__ == __CC65_STD_CC65__
+void __fastcall__ bzero (void* ptr, size_t n); /* BSD */
+char* __fastcall__ strdup (const char* s); /* SYSV/BSD */
+int __fastcall__ stricmp (const char* s1, const char* s2); /* DOS/Windows */
+int __fastcall__ strcasecmp (const char* s1, const char* s2); /* Same for Unix */
+int __fastcall__ strnicmp (const char* s1, const char* s2, size_t count); /* DOS/Windows */
+int __fastcall__ strncasecmp (const char* s1, const char* s2, size_t count); /* Same for Unix */
+size_t __fastcall__ strnlen (const char* s, size_t maxlen); /* POSIX.1-2008 */
+char* __fastcall__ strlwr (char* s);
+char* __fastcall__ strlower (char* s);
+char* __fastcall__ strupr (char* s);
+char* __fastcall__ strupper (char* s);
+char* __fastcall__ strqtok (char* s1, const char* s2);
+#endif
+
+const char* __fastcall__ __stroserror (unsigned char errcode);
+/* Map an operating system error number to an error message. */
+#if __CC65_STD__ == __CC65_STD_CC65__
+/* define old name with one underscore for backwards compatibility */
+#define _stroserror __stroserror
+#endif
+
+
+/* End of string.h */
+#endif
+/*****************************************************************************/
+/* */
+/* supervision.h */
+/* */
+/* Supervision specific definitions */
+/* */
+/* */
+/* */
+/* 2003 Peter Trauner (trap@utanet.at) */
+/* */
+/* */
+/* This software is provided "as-is," without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment, in the product's documentation, */
+/* would be appreciated, but is not required. */
+/* 2. Alterred source versions must be marked plainly as such, */
+/* and must not be misrepresented as being the original software. */
+/* 3. This notice may not be removed or alterred */
+/* from any source distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _SUPERVISION_H
+#define _SUPERVISION_H
+
+
+
+/* Check for errors */
+#if !defined(__SUPERVISION__)
+# error This module may only be used when compiling for the Supervision!
+#endif
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+struct __sv_lcd {
+ unsigned char width;
+ unsigned char height;
+ unsigned char xpos;
+ unsigned char ypos;
+};
+#define SV_LCD (*(struct __sv_lcd*)0x2000)
+
+struct __sv_tone {
+ unsigned delay;
+ unsigned char control;
+ unsigned char timer;
+};
+#define SV_RIGHT (*(struct __sv_tone*)0x2010)
+#define SV_LEFT (*(struct __sv_tone*)0x2014)
+
+struct __sv_noise {
+ unsigned char volume; /* and frequency */
+ unsigned char timer;
+ unsigned char control;
+};
+#define SV_NOISE (*(struct __sv_noise*)0x2028)
+
+struct __io_port {
+ unsigned char in;
+ unsigned char out;
+};
+#define IO_PORT (*(struct __io_port*)0x2021)
+
+struct __sv_dma {
+ unsigned start;
+ unsigned char size;
+ unsigned char control;
+ unsigned char on;
+};
+#define SV_DMA (*(struct __sv_dma*)0x2018)
+
+#define SV_CONTROL (*(unsigned char*)0x2020)
+
+#define SV_BANK (*(unsigned char*)0x2026)
+#define SV_BANK_COMBINE(nmi,irq_timer,irq_dma,lcd_on, timer_prescale, bank) \
+ ((nmi)?1:0)|((irq_timer)?2:0)|((irq_dma)?4:0)|((lcd_on)?8:0) \
+ |((timer_prescale)?0x10:0)|((bank)<<5)
+
+#define SV_VIDEO ((unsigned char*)0x4000)
+#define SV_TIMER_COUNT (*(unsigned char*)0x2023)
+
+
+
+/* Counters incremented asynchronously!
+** If you want more complex, copy the crt0.s file from the libsrc/supervision
+** directory and code them yourself (in assembler)
+*/
+extern unsigned char sv_nmi_counter;
+extern unsigned char sv_timer_irq_counter;
+extern unsigned char sv_timer_dma_counter;
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x08
+#define JOY_DOWN_MASK 0x04
+#define JOY_LEFT_MASK 0x02
+#define JOY_RIGHT_MASK 0x01
+#define JOY_BTN_1_MASK 0x20
+#define JOY_BTN_2_MASK 0x10
+#define JOY_BTN_3_MASK 0x80
+#define JOY_BTN_4_MASK 0x40
+
+#define JOY_BTN_A_MASK JOY_BTN_1_MASK
+#define JOY_BTN_B_MASk JOY_BTN_2_MASK
+#define JOY_START_MASK JOY_BTN_3_MASK
+#define JOY_SELECT_MASK JOY_BTN_4_MASK
+
+#define JOY_BTN_A(v) ((v) & JOY_BTN_A_MASK)
+#define JOY_BTN_B(v) ((v) & JOY_BTN_B_MASK)
+#define JOY_START(v) ((v) & JOY_START_MASK)
+#define JOY_SELECT(v) ((v) & JOY_SELECT_MASK)
+
+/* No support for dynamically loadable drivers */
+#define DYN_DRV 0
+
+/* The addresses of the static drivers */
+extern void supervision_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
+
+
+
+/* End of supervision.h */
+#endif
+/*****************************************************************************/
+/* */
+/* sym1.h */
+/* */
+/* Sym-1 system-specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2020 Wayne Parham */
+/* EMail: wayne@parhamdata.com */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _SYM1_H
+#define _SYM1_H
+
+
+
+/* Check for errors */
+#if !defined(__SYM1__)
+# error This module may only be used when compiling for the Sym-1!
+#endif
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Display character definitions */
+#define DISP_1 0x06 // '1'
+#define DISP_2 0x5B // '2'
+#define DISP_3 0x4F // '3'
+#define DISP_4 0x66 // '4'
+#define DISP_5 0x6D // '5'
+#define DISP_6 0x7C // '6'
+#define DISP_7 0x07 // '7'
+#define DISP_8 0x7F // '8'
+#define DISP_9 0x67 // '9'
+#define DISP_0 0x3F // '0'
+#define DISP_A 0x77 // 'A'
+#define DISP_b 0x7C // 'b'
+#define DISP_C 0x39 // 'C'
+#define DISP_c 0x58 // 'c'
+#define DISP_d 0x5E // 'd'
+#define DISP_E 0x79 // 'E'
+#define DISP_e 0x7B // 'e'
+#define DISP_F 0x71 // 'F'
+#define DISP_G 0x7D // 'G'
+#define DISP_g 0x6F // 'g'
+#define DISP_H 0x76 // 'H'
+#define DISP_h 0x74 // 'h'
+#define DISP_I 0x06 // 'I'
+#define DISP_i 0x04 // 'i'
+#define DISP_J 0x1E // 'J'
+#define DISP_K 0x74 // 'K'
+#define DISP_L 0x38 // 'L'
+#define DISP_M_1 0x33 // 'M'
+#define DISP_M_2 0x27 // 2nd half
+#define DISP_n 0x54 // 'n'
+#define DISP_O 0x3F // 'O'
+#define DISP_o 0x5C // 'o'
+#define DISP_P 0x73 // 'P'
+#define DISP_q 0x67 // 'q'
+#define DISP_r 0x50 // 'r'
+#define DISP_S 0x6D // 'S'
+#define DISP_t 0x46 // 't'
+#define DISP_U 0x3E // 'U'
+#define DISP_u 0x1C // 'u'
+#define DISP_V_1 0x64 // 'V'
+#define DISP_V_2 0x52 // 2nd half
+#define DISP_W_1 0x3C // 'W'
+#define DISP_W_2 0x1E // 2nd half
+#define DISP_Y 0x6E // 'Y'
+#define DISP_Z 0x5B // 'Z'
+#define DISP_SPACE 0x00 // ' '
+#define DISP_PERIOD 0x80 // '.'
+#define DISP_HYPHEN 0x40 // '-'
+#define DISP_APOSTR 0x20 // '''
+#define DISP_EQUAL 0x41 // '='
+#define DISP_3_BAR 0x49 // '='
+#define DISP_BOTTOM 0x08 // '_'
+#define DISP_TOP 0x01 // Top segment
+#define DISP_LEFT 0x30 // '|' Left side, both segments
+#define DISP_RIGHT 0x06 // '|' Right side, both segments
+#define DISP_DEGREE 0x63 // 'o' An 'o' character in the upper segments
+#define DISP_HAT 0x23 // 'n' An 'n' character in the upper segments
+#define DISP_FORK 0x62 // 'u' A 'u' character in the upper segments
+#define DISP_SLASH 0x51 // '/'
+#define DISP_BACKSLASH 0x34 // '\'
+#define DISP_TOP_RIGHT 0x02 // Top right segment
+#define DISP_TOP_LEFT 0x20 // Top left segment
+#define DISP_LOW_RIGHT 0x04 // Lower right segment
+#define DISP_LOW_LEFT 0x10 // Lower left segment
+
+
+/*****************************************************************************/
+/* Hardware */
+/*****************************************************************************/
+
+
+
+#include <_6522.h>
+#define VIA1 (*(struct __6522*)0xA000) // U25
+#define VIA2 (*(struct __6522*)0xA800) // U28
+#define VIA3 (*(struct __6522*)0xAC00) // U29
+
+
+struct _display {
+ unsigned char d0; // left-most seven-segment display
+ unsigned char d1; // second seven-segment display
+ unsigned char d2; // third seven-segment display
+ unsigned char d3; // fouth seven-segment display
+ unsigned char d4; // fifth seven-segment display
+ unsigned char d5; // sixth seven-segment display
+ unsigned char d6; // buffer byte to the right
+};
+#define DISPLAY (*(struct _display*)0xA640)
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+void beep (void);
+/* Beep sound. */
+
+void fdisp (void);
+/* Flash display */
+
+int __fastcall__ loadt (unsigned char);
+/* Read from tape */
+
+int __fastcall__ dumpt (unsigned char, const void*, const void*);
+/* Write to tape */
+
+
+
+/* End of sym1.h */
+#endif
+/*****************************************************************************/
+/* */
+/* stat.h */
+/* */
+/* Constants for the mode argument of open and creat */
+/* */
+/* */
+/* */
+/* (C) 2003 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _STAT_H
+#define _STAT_H
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+#define S_IREAD 0x01
+#define S_IWRITE 0x02
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+/* End of stat.h */
+#endif
+/*****************************************************************************/
+/* */
+/* types.h */
+/* */
+/* Primitive system data types for cc65 */
+/* */
+/* */
+/* */
+/* (C) 2003 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _TYPES_H
+#define _TYPES_H
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* off_t is also defined in unistd.h */
+#ifndef _HAVE_off_t
+#define _HAVE_off_t
+typedef long int off_t;
+#endif
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+/* End of types.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* utsname.h */
+/* */
+/* Return system information */
+/* */
+/* */
+/* */
+/* (C) 2003 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _UTSNAME_H
+#define _UTSNAME_H
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/*
+** Suggested field contents:
+**
+** sysname
+** Should contain the name of the underlying operating system, or "cc65"
+** if the program runs on the bare machine.
+**
+** nodename
+** Is empty or may be defined by the implementor.
+**
+** release
+** Contains the operating system release or the major/minor cc65 version
+** if sysname contains "cc65".
+**
+** version
+** Contains the operating system version or the cc65 patch version if
+** sysname contains "cc65".
+**
+** machine
+** Contains the complete name of the machine, like "Commodore 64",
+** "Oric Atmos" or similar.
+**
+** Beware: The library sources written in assembler have knowledge about this
+** struct!
+*/
+struct utsname {
+ char sysname[17];
+ char nodename[9];
+ char release[9];
+ char version[9];
+ char machine[25];
+};
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+int __fastcall__ uname (struct utsname* buf);
+/* Return system information */
+
+
+
+/* End of utsname.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* target.h */
+/* */
+/* Target specific definitions */
+/* */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _TARGET_H
+#define _TARGET_H
+
+
+
+/* Include the correct target specific file */
+#if defined(__APPLE2ENH__)
+# include
+#elif defined(__APPLE2__)
+# include
+#elif defined(__ATARI__)
+# include
+#elif defined(__ATARI2600__)
+# include
+#elif defined(__ATARI5200__)
+# include
+#elif defined(__ATARI7800__)
+# include
+#elif defined(__ATMOS__)
+# include
+#elif defined(__CBM__)
+# include
+#elif defined(__CREATIVISION__)
+# include
+#elif defined(__GAMATE__)
+# include
+#elif defined(__GEOS__)
+# include
+#elif defined(__LYNX__)
+# include
+#elif defined(__NES__)
+# include
+#elif defined(__OSIC1P__)
+# include
+#elif defined(__PCE__)
+# include
+#elif defined(__SUPERVISION__)
+# include
+#elif defined(__TELESTRAT__)
+# include
+#endif
+
+
+
+/* End of target.h */
+#endif
+/*****************************************************************************/
+/* */
+/* telestrat.h */
+/* */
+/* Oric Telestrat system-specific definitions */
+/* */
+/* */
+/* */
+/* (C) 2017 Debrune Jérome, */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+
+/* Color defines */
+#define COLOR_BLACK 0x00
+#define COLOR_RED 0x01
+#define COLOR_GREEN 0x02
+#define COLOR_YELLOW 0x03
+#define COLOR_BLUE 0x04
+#define COLOR_MAGENTA 0x05
+#define COLOR_CYAN 0x06
+#define COLOR_WHITE 0x07
+
+/* TGI color defines */
+/* White and red are swapped, so that the pallete
+** driver is compatible with black-and-white drivers.
+*/
+#define TGI_COLOR_BLACK COLOR_BLACK
+#define TGI_COLOR_WHITE 1
+#define TGI_COLOR_GREEN COLOR_GREEN
+#define TGI_COLOR_YELLOW COLOR_YELLOW
+#define TGI_COLOR_BLUE COLOR_BLUE
+#define TGI_COLOR_MAGENTA COLOR_MAGENTA
+#define TGI_COLOR_CYAN COLOR_CYAN
+#define TGI_COLOR_RED 7
+
+
+/* Define hardware */
+#include <_6522.h>
+#define VIA (*(struct __6522*)0x300)
+
+
+
+/* These are defined to be FUNCT + NumberKey */
+#define CH_F1 0xB1
+#define CH_F2 0xB2
+#define CH_F3 0xB3
+#define CH_F4 0xB4
+#define CH_F5 0xB5
+#define CH_F6 0xB6
+#define CH_F7 0xB7
+#define CH_F8 0xB8
+#define CH_F9 0xB9
+#define CH_F10 0xB0
+
+
+
+/* Character codes */
+#define CH_ULCORNER '+'
+#define CH_URCORNER '+'
+#define CH_LLCORNER '+'
+#define CH_LRCORNER '+'
+#define CH_TTEE '+'
+#define CH_BTEE '+'
+#define CH_LTEE '+'
+#define CH_RTEE '+'
+#define CH_CROSS '+'
+#define CH_HLINE '-'
+#define CH_VLINE '|'
+#define CH_CURS_UP 11
+#define CH_CURS_DOWN 10
+#define CH_CURS_LEFT 8
+#define CH_CURS_RIGHT 9
+#define CH_DEL 127
+#define CH_ENTER 13
+#define CH_STOP 3
+#define CH_LIRA 95
+#define CH_ESC 27
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x10
+#define JOY_DOWN_MASK 0x08
+#define JOY_LEFT_MASK 0x02
+#define JOY_RIGHT_MASK 0x01
+#define JOY_BTN_1_MASK 0x04
+
+#define JOY_FIRE_MASK JOY_BTN_1_MASK
+#define JOY_FIRE(v) ((v) & JOY_FIRE_MASK)
+
+
+/* The addresses of the static drivers */
+extern void telestrat_joy[]; /* Referred to by joy_static_stddrv[] */
+extern void telestrat_228_200_3_tgi[];
+extern void telestrat_240_200_2_tgi[]; /* Referred to by tgi_static_stddrv[] */
+
+
+void oups();
+void ping();
+void zap();
+void shoot();
+void explode();
+
+void kbdclick1();
+
+/* The following #defines will cause the matching functions calls in conio.h
+** to be overlaid by macros with the same names, saving the function call
+** overhead.
+*/
+#define _bordercolor(color) COLOR_BLACK
+/*****************************************************************************/
+/* */
+/* tgi.h */
+/* */
+/* Tiny graphics interface */
+/* */
+/* */
+/* */
+/* (C) 2002-2013, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _TGI_H
+#define _TGI_H
+
+
+
+#include
+#include
+
+
+
+/*****************************************************************************/
+/* Definitions */
+/*****************************************************************************/
+
+
+
+/* Font constants for use with tgi_settextstyle */
+#define TGI_FONT_BITMAP 0
+#define TGI_FONT_VECTOR 1
+
+/* Direction constants for use with tgi_settextstyle */
+#define TGI_TEXT_HORIZONTAL 0
+#define TGI_TEXT_VERTICAL 1
+
+/* The name of the standard tgi driver for a platform */
+extern const char tgi_stddrv[];
+
+/* The address of the static standard tgi driver for a platform */
+extern const void tgi_static_stddrv[];
+
+/* A vector font definition */
+typedef struct tgi_vectorfont tgi_vectorfont;
+
+
+
+/*****************************************************************************/
+/* Functions */
+/*****************************************************************************/
+
+
+
+void __fastcall__ tgi_load_driver (const char* name);
+/* Load and install the given driver. */
+
+void tgi_unload (void);
+/* Uninstall, then unload the currently loaded driver. Will call tgi_done if
+** necessary.
+*/
+
+void __fastcall__ tgi_install (const void* driver);
+/* Install an already loaded driver. */
+
+void tgi_uninstall (void);
+/* Uninstall the currently loaded driver but do not unload it. Will call
+** tgi_done if necessary.
+*/
+
+void tgi_init (void);
+/* Initialize the already loaded graphics driver. */
+
+void tgi_done (void);
+/* End graphics mode, switch back to text mode. Will NOT uninstall or unload
+** the driver!
+*/
+
+const tgi_vectorfont* __fastcall__ tgi_load_vectorfont (const char* name);
+/* Load a vector font into memory and return it. In case of errors, NULL is
+** returned and an error is set, which can be retrieved using tgi_geterror.
+** To use the font, it has to be installed using tgi_install_vectorfont.
+*/
+
+void __fastcall__ tgi_install_vectorfont (const tgi_vectorfont* font);
+/* Install a vector font for use. More than one vector font can be loaded,
+** but only one can be active. This function is used to tell which one. Call
+** with a NULL pointer to uninstall the currently installed font.
+*/
+
+void __fastcall__ tgi_free_vectorfont (const tgi_vectorfont* font);
+/* Free a vector font that was previously loaded into memory. */
+
+unsigned char tgi_geterror (void);
+/* Return the error code for the last operation. This will also clear the
+** error.
+*/
+
+const char* __fastcall__ tgi_geterrormsg (unsigned char code);
+/* Get an error message describing the error in code. */
+
+void tgi_clear (void);
+/* Clear the drawpage. */
+
+unsigned tgi_getpagecount (void);
+/* Returns the number of screen pages available. */
+
+void __fastcall__ tgi_setviewpage (unsigned char page);
+/* Set the visible page. Will set an error if the page is not available. */
+
+void __fastcall__ tgi_setdrawpage (unsigned char page);
+/* Set the drawable page. Will set an error if the page is not available. */
+
+unsigned char tgi_getcolorcount (void);
+/* Get the number of available colors. Zero means 256 colors. */
+
+unsigned char tgi_getmaxcolor (void);
+/* Return the maximum supported color number (the number of colors would
+** then be getmaxcolor()+1).
+*/
+
+void __fastcall__ tgi_setcolor (unsigned char color);
+/* Set the current drawing color. */
+
+unsigned char tgi_getcolor (void);
+/* Return the current drawing color. */
+
+void __fastcall__ tgi_setpalette (const unsigned char* palette);
+/* Set the palette (not available with all drivers/hardware). palette is
+** a pointer to as many entries as there are colors.
+*/
+
+const unsigned char* tgi_getpalette (void);
+/* Return the current palette. */
+
+const unsigned char* tgi_getdefpalette (void);
+/* Return the default palette. */
+
+unsigned tgi_getxres (void);
+/* Return the resolution in X direction. */
+
+unsigned tgi_getmaxx (void);
+/* Return the maximum x coordinate. The resolution in x direction is
+** getmaxx() + 1
+*/
+
+unsigned tgi_getyres (void);
+/* Return the resolution in Y direction. */
+
+unsigned tgi_getmaxy (void);
+/* Return the maximum y coordinate. The resolution in y direction is
+** getmaxy() + 1
+*/
+
+unsigned tgi_getaspectratio (void);
+/* Returns the aspect ratio for the loaded driver. The aspect ratio is an
+** 8.8 fixed point value.
+*/
+
+void __fastcall__ tgi_setaspectratio (unsigned aspectratio);
+/* Set a new aspect ratio for the loaded driver. The aspect ratio is an
+** 8.8 fixed point value.
+*/
+
+unsigned char __fastcall__ tgi_getpixel (int x, int y);
+/* Get the color value of a pixel. */
+
+void __fastcall__ tgi_setpixel (int x, int y);
+/* Plot a pixel in the current drawing color. */
+
+void __fastcall__ tgi_gotoxy (int x, int y);
+/* Set the graphics cursor to the given position. */
+
+void __fastcall__ tgi_line (int x1, int y1, int x2, int y2);
+/* Draw a line in the current drawing color. The graphics cursor will
+** be set to x2/y2 by this call.
+*/
+
+void __fastcall__ tgi_lineto (int x2, int y2);
+/* Draw a line in the current drawing color from the graphics cursor to the
+** new end point. The graphics cursor will be updated to x2/y2.
+*/
+
+void __fastcall__ tgi_circle (int x, int y, unsigned char radius);
+/* Draw a circle in the current drawing color. */
+
+void __fastcall__ tgi_ellipse (int x, int y, unsigned char rx, unsigned char ry);
+/* Draw a full ellipse with center at x/y and radii rx/ry using the current
+** drawing color.
+*/
+
+void __fastcall__ tgi_arc (int x, int y, unsigned char rx, unsigned char ry,
+ unsigned sa, unsigned ea);
+/* Draw an ellipse arc with center at x/y and radii rx/ry using the current
+** drawing color. The arc covers the angle between sa and ea (startangle and
+** endangle), which must be in the range 0..360 (otherwise the function may
+** behave unexpectedly).
+*/
+
+void __fastcall__ tgi_pieslice (int x, int y, unsigned char rx, unsigned char ry,
+ unsigned sa, unsigned ea);
+/* Draw an ellipse pie slice with center at x/y and radii rx/ry using the
+** current drawing color. The pie slice covers the angle between sa and ea
+** (startangle and endangle), which must be in the range 0..360 (otherwise the
+** function may behave unextectedly).
+*/
+
+void __fastcall__ tgi_bar (int x1, int y1, int x2, int y2);
+/* Draw a bar (a filled rectangle) using the current color. */
+
+void __fastcall__ tgi_settextdir (unsigned char dir);
+/* Set the direction for text output. dir is one of the TGI_TEXT_XXX
+** constants.
+*/
+
+void __fastcall__ tgi_settextscale (unsigned width, unsigned height);
+/* Set the scaling for text output. The scaling factors for width and height
+** are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
+*/
+
+void __fastcall__ tgi_settextstyle (unsigned width, unsigned height,
+ unsigned char dir, unsigned char font);
+/* Set the style for text output. The scaling factors for width and height
+** are 8.8 fixed point values. This means that $100 = 1 $200 = 2 etc.
+** dir is one of the TGI_TEXT_XXX constants. font is one of the TGI_FONT_XXX
+** constants.
+*/
+
+unsigned __fastcall__ tgi_gettextwidth (const char* s);
+/* Calculate the width of the text in pixels according to the current text
+** style.
+*/
+
+unsigned __fastcall__ tgi_gettextheight (const char* s);
+/* Calculate the height of the text in pixels according to the current text
+** style.
+*/
+
+void __fastcall__ tgi_outtext (const char* s);
+/* Output text at the current graphics cursor position. The graphics cursor
+** is moved to the end of the text.
+*/
+
+void __fastcall__ tgi_outtextxy (int x, int y, const char* s);
+/* Output text at the given cursor position. The graphics cursor is moved to
+** the end of the text.
+*/
+
+unsigned __fastcall__ tgi_ioctl (unsigned char code, void* data);
+/* Call the driver specific control function. What this function does for
+** a specific code depends on the driver. The driver will set an error
+** for unknown codes or values.
+*/
+
+int __fastcall__ tgi_imulround (int rhs, int lhs);
+/* Helper function for functions using sine/cosine: Multiply two values, one
+** being an 8.8 fixed point one, and return the rounded and scaled result.
+*/
+
+
+
+/* End of tgi.h */
+#endif
+/*****************************************************************************/
+/* */
+/* tgi-error.h */
+/* */
+/* TGI error codes */
+/* */
+/* */
+/* */
+/* (C) 2002-2012, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _TGI_ERROR_H
+#define _TGI_ERROR_H
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+#define TGI_ERR_OK 0 /* No error */
+#define TGI_ERR_NO_DRIVER 1 /* No driver available */
+#define TGI_ERR_CANNOT_LOAD 2 /* Error loading driver or font */
+#define TGI_ERR_INV_DRIVER 3 /* Invalid driver */
+#define TGI_ERR_INV_MODE 4 /* Mode not supported by driver */
+#define TGI_ERR_INV_ARG 5 /* Invalid function argument */
+#define TGI_ERR_INV_FUNC 6 /* Function not supported */
+#define TGI_ERR_INV_FONT 7 /* Font file is invalid */
+#define TGI_ERR_NO_RES 8 /* Out of resources */
+#define TGI_ERR_INSTALLED 9 /* A driver is already installed */
+
+
+
+/* End of tgi-error.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* tgi-kernel.h */
+/* */
+/* TGI kernel interface */
+/* */
+/* */
+/* */
+/* (C) 2002-2012, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _TGI_KERNEL_H
+#define _TGI_KERNEL_H
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* TGI kernel variables */
+extern void* tgi_drv; /* Pointer to driver */
+extern unsigned char tgi_error; /* Last error code */
+extern unsigned char tgi_gmode; /* Flag: Graphics mode active */
+extern int tgi_curx; /* Current drawing cursor X */
+extern int tgi_cury; /* Current drawing cursor Y */
+extern unsigned char tgi_color; /* Current drawing color */
+extern unsigned char tgi_font; /* Current font type */
+extern unsigned tgi_xres; /* X resolution of the current mode */
+extern unsigned tgi_yres; /* Y resolution of the current mode */
+extern unsigned char tgi_colorcount; /* Number of available colors */
+extern unsigned char tgi_pagecount; /* Number of available screens */
+extern unsigned char tgi_fontwidth; /* System font width in pixels */
+extern unsigned char tgi_fontheight; /* System font height in pixels */
+extern unsigned tgi_aspectratio; /* Aspect ratio as fixed point 8.8 */
+extern unsigned char tgi_flags; /* TGI driver flags */
+extern unsigned tgi_textscalew[2]; /* Vector/bitmap font scale 8.8 */
+extern unsigned tgi_textscaleh[2]; /* Vector/bitmap font scale 8.8 */
+extern unsigned tgi_charwidth; /* Width of scaled bitmap font */
+extern unsigned tgi_charheight; /* Height of scaled bitmap font */
+
+
+
+/* End of tgi-kernel.h */
+#endif
+
+
+
+
+/*****************************************************************************/
+/* */
+/* tgi-vectorfont.h */
+/* */
+/* TGI vector font definitions */
+/* */
+/* */
+/* */
+/* (C) 2009, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _TGI_VECTORFONT_H
+#define _TGI_VECTORFONT_H
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+#define TGI_VF_FIRSTCHAR 0x20 /* First char in file */
+#define TGI_VF_LASTCHAR 0x7E /* Last char in file */
+#define TGI_VF_CCOUNT (TGI_VF_LASTCHAR - TGI_VF_FIRSTCHAR + 1)
+
+#define TGI_VF_VERSION 0x00 /* File version number */
+
+/* TCH file header */
+typedef struct tgi_vectorfont_header tgi_vectorfont_header;
+struct tgi_vectorfont_header {
+ unsigned char magic[3]; /* "TCH" */
+ unsigned char version; /* Version number */
+ unsigned size; /* Font data size */
+};
+
+/* Font data loaded directly from file */
+struct tgi_vectorfont {
+ unsigned char top; /* Height of char */
+ unsigned char baseline; /* Character baseline */
+ unsigned char bottom; /* Descender */
+ unsigned char widths[TGI_VF_CCOUNT]; /* Char widths */
+ unsigned char* chars[TGI_VF_CCOUNT]; /* Pointer to character defs */
+ unsigned char vec_ops[1]; /* Actually dynamic */
+};
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+void __fastcall__ tgi_vectorchar (char C);
+/* Draw one character of the vector font at the current graphics cursor
+** position using the current font magnification.
+*/
+
+
+
+/* End of tgi-vectorfont.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* time.h */
+/* */
+/* Date and time */
+/* */
+/* */
+/* */
+/* (C) 1998-2012 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _TIME_H
+#define _TIME_H
+
+
+
+/* NULL pointer */
+#ifndef NULL
+#define NULL ((void *) 0)
+#endif
+
+/* size_t is needed */
+#ifndef _HAVE_size_t
+#define _HAVE_size_t
+typedef unsigned size_t;
+#endif
+
+typedef unsigned long time_t;
+typedef unsigned long clock_t;
+
+/* Structure for broken down time */
+struct tm {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+};
+
+#if defined(__ATARI5200__)
+# define CLOCKS_PER_SEC 60
+#elif defined(__ATMOS__)
+# define CLOCKS_PER_SEC 100
+#elif defined(__CBM__)
+# if defined(__CBM510__) || defined(__CBM610__)
+/* The 510/610 gets its clock from the AC current */
+# define CLOCKS_PER_SEC 50
+# else
+# define CLOCKS_PER_SEC 60
+# endif
+#elif defined(__NES__)
+# define CLOCKS_PER_SEC 50
+#elif defined(__PCE__)
+# define CLOCKS_PER_SEC 60
+#elif defined(__GAMATE__)
+# define CLOCKS_PER_SEC 135 /* FIXME */
+#elif defined(__GEOS__)
+# define CLOCKS_PER_SEC 1
+#elif defined(__TELESTRAT__)
+# define CLOCKS_PER_SEC 10
+#elif defined(__ATARI__) || defined (__LYNX__)
+/* Read the clock rate at runtime */
+clock_t __clocks_per_sec (void);
+# define CLOCKS_PER_SEC __clocks_per_sec()
+#endif
+#define CLOCK_REALTIME 0
+
+
+
+/* ISO C function prototypes */
+char* __fastcall__ asctime (const struct tm* timep);
+clock_t clock (void);
+char* __fastcall__ ctime (const time_t* timep);
+struct tm* __fastcall__ gmtime (const time_t* timep);
+struct tm* __fastcall__ localtime (const time_t* timep);
+time_t __fastcall__ mktime (struct tm* timep);
+size_t __fastcall__ strftime (char* buf, size_t bufsize, const char* format, const struct tm* tm);
+time_t __fastcall__ time (time_t* t);
+
+
+#if __CC65_STD__ >= __CC65_STD_CC65__
+
+typedef unsigned char clockid_t;
+
+/* Structure for seconds and nanoseconds */
+struct timespec {
+ time_t tv_sec;
+ long tv_nsec;
+};
+
+/* Timezone representation, default is UTC */
+extern struct _timezone {
+ char daylight; /* True if daylight savings time active */
+ long timezone; /* Number of seconds behind UTC */
+ char tzname[5]; /* Name of timezone, e.g. CET */
+ char dstname[5]; /* Name when daylight true, e.g. CEST */
+} _tz;
+
+#define CLK_TCK CLOCKS_PER_SEC
+
+/* POSIX function prototypes */
+int __fastcall__ clock_getres (clockid_t clock_id, struct timespec *res);
+int __fastcall__ clock_gettime (clockid_t clock_id, struct timespec *tp);
+int __fastcall__ clock_settime (clockid_t clock_id, const struct timespec *tp);
+
+#endif
+
+
+/* End of time.h */
+
+#endif
+/*****************************************************************************/
+/* */
+/* unistd.h */
+/* */
+/* Unix compatibility header file for cc65 */
+/* */
+/* */
+/* */
+/* (C) 2003-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _UNISTD_H
+#define _UNISTD_H
+
+
+
+/*****************************************************************************/
+/* Data */
+/*****************************************************************************/
+
+
+
+/* Predefined file handles */
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+
+/* WE need size_t */
+#ifndef _HAVE_size_t
+#define _HAVE_size_t
+typedef unsigned size_t;
+#endif
+
+/* We need off_t if sys/types is not included */
+#ifndef _HAVE_off_t
+#define _HAVE_off_t
+typedef long int off_t;
+#endif
+
+/* Stuff for getopt */
+extern char *optarg;
+extern int optind, opterr, optopt;
+
+
+
+/*****************************************************************************/
+/* Code */
+/*****************************************************************************/
+
+
+
+/* Files */
+int __fastcall__ write (int fd, const void* buf, unsigned count);
+int __fastcall__ read (int fd, void* buf, unsigned count);
+off_t __fastcall__ lseek (int fd, off_t offset, int whence);
+int __fastcall__ unlink (const char* name); /* Same as remove() */
+
+/* Directories */
+int __fastcall__ chdir (const char* name);
+char* __fastcall__ getcwd (char* buf, size_t size);
+int mkdir (const char* name, ...); /* May take a mode argument */
+int __fastcall__ rmdir (const char* name);
+
+/* Others */
+unsigned __fastcall__ sleep (unsigned seconds);
+int __fastcall__ getopt (int argc, char* const* argv, const char* optstring);
+
+/* Non standard: */
+#if __CC65_STD__ == __CC65_STD_CC65__
+int __fastcall__ exec (const char* progname, const char* cmdline);
+#endif
+
+
+
+/* End of unistd.h */
+#endif
+
+
+
+/*****************************************************************************/
+/* */
+/* vic20.h */
+/* */
+/* VIC-20 system-specific definitions */
+/* */
+/* */
+/* */
+/* (C) 1998-2004 Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
+/* */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _VIC20_H
+#define _VIC20_H
+
+
+
+/* Check for errors */
+#if !defined(__VIC20__)
+# error This module may only be used when compiling for the Vic20!
+#endif
+
+
+
+/* Additional key defines */
+#define CH_F1 133
+#define CH_F2 137
+#define CH_F3 134
+#define CH_F4 138
+#define CH_F5 135
+#define CH_F6 139
+#define CH_F7 136
+#define CH_F8 140
+
+
+
+/* Color defines */
+#define COLOR_BLACK 0x00
+#define COLOR_WHITE 0x01
+#define COLOR_RED 0x02
+#define COLOR_CYAN 0x03
+#define COLOR_PURPLE 0x04
+#define COLOR_GREEN 0x05
+#define COLOR_BLUE 0x06
+#define COLOR_YELLOW 0x07
+/* Only the background and multi-color characters can have these colors. */
+#define COLOR_ORANGE 0x08
+#define COLOR_LIGHTORANGE 0x09
+#define COLOR_PINK 0x0A
+#define COLOR_LIGHTCYAN 0x0B
+#define COLOR_LIGHTVIOLET 0x0C
+#define COLOR_LIGHTGREEN 0x0D
+#define COLOR_LIGHTBLUE 0x0E
+#define COLOR_LIGHTYELLOW 0x0F
+
+/* TGI color defines */
+#define TGI_COLOR_BLACK COLOR_BLACK
+#define TGI_COLOR_WHITE COLOR_WHITE
+#define TGI_COLOR_RED COLOR_RED
+#define TGI_COLOR_CYAN COLOR_CYAN
+#define TGI_COLOR_PURPLE COLOR_PURPLE
+#define TGI_COLOR_GREEN COLOR_GREEN
+#define TGI_COLOR_BLUE COLOR_BLUE
+#define TGI_COLOR_YELLOW COLOR_YELLOW
+/* Only the background and multi-color graphics can have these colors. */
+#define TGI_COLOR_ORANGE COLOR_ORANGE
+#define TGI_COLOR_LIGHTORANGE COLOR_LIGHTORANGE
+#define TGI_COLOR_PINK COLOR_PINK
+#define TGI_COLOR_LIGHTCYAN COLOR_LIGHTCYAN
+#define TGI_COLOR_LIGHTVIOLET COLOR_LIGHTVIOLET
+#define TGI_COLOR_LIGHTGREEN COLOR_LIGHTGREEN
+#define TGI_COLOR_LIGHTBLUE COLOR_LIGHTBLUE
+#define TGI_COLOR_LIGHTYELLOW COLOR_LIGHTYELLOW
+
+
+
+/* tgi_ioctl() commands */
+#define TGI_IOCTL_VIC20_SET_PATTERN 0x01 /* Set 8-byte pattern for tgi_bar(). */
+
+
+
+/* Masks for joy_read */
+#define JOY_UP_MASK 0x01
+#define JOY_DOWN_MASK 0x02
+#define JOY_LEFT_MASK 0x04
+#define JOY_RIGHT_MASK 0x08
+#define JOY_BTN_1_MASK 0x10
+
+
+
+/* Define hardware */
+#include <_vic.h>
+#define VIC (*(struct __vic*)0x9000)
+
+#include <_6522.h>
+#define VIA1 (*(struct __6522*)0x9110)
+#define VIA2 (*(struct __6522*)0x9120)
+
+
+
+/* Define special memory areas */
+#define COLOR_RAM ((unsigned char*)0x9600)
+
+
+
+/* The addresses of the static drivers */
+extern void vic20_ptvjoy_joy[];
+extern void vic20_stdjoy_joy[]; /* Referred to by joy_static_stddrv[] */
+
+extern void vic20_rama_emd[];
+extern void vic20_georam_emd[];
+
+extern void vic20_hi_tgi[]; /* Referred to by tgi_static_stddrv[] */
+
+
+
+/* End of vic20.h */
+#endif
+/*****************************************************************************/
+/* */
+/* zlib.h */
+/* */
+/* Decompression routines for the 'deflate' format */
+/* */
+/* */
+/* */
+/* (C) 2000-2015 Piotr Fusik */
+/* */
+/* This file is based on the zlib.h from 'zlib' general purpose compression */
+/* library, version 1.1.3, (C) 1995-1998 Jean-loup Gailly and Mark Adler. */
+/* */
+/* Jean-loup Gailly Mark Adler */
+/* jloup@gzip.org madler@alumni.caltech.edu */
+/* */
+/* This software is provided 'as-is', without any expressed or implied */
+/* warranty. In no event will the authors be held liable for any damages */
+/* arising from the use of this software. */
+/* */
+/* Permission is granted to anyone to use this software for any purpose, */
+/* including commercial applications, and to alter it and redistribute it */
+/* freely, subject to the following restrictions: */
+/* */
+/* 1. The origin of this software must not be misrepresented; you must not */
+/* claim that you wrote the original software. If you use this software */
+/* in a product, an acknowledgment in the product documentation would be */
+/* appreciated but is not required. */
+/* 2. Altered source versions must be plainly marked as such, and must not */
+/* be misrepresented as being the original software. */
+/* 3. This notice may not be removed or altered from any source */
+/* distribution. */
+/* */
+/*****************************************************************************/
+
+
+
+#ifndef _ZLIB_H
+#define _ZLIB_H
+
+#define Z_OK 0
+#define Z_DATA_ERROR (-3)
+/* Return codes for uncompress() */
+
+#define Z_DEFLATED 8
+/* The deflate compression method (the only one supported) */
+
+#define Z_NULL 0
+
+
+unsigned __fastcall__ inflatemem (unsigned char* dest,
+ const unsigned char* source);
+/*
+ Decompresses the source buffer into the destination buffer.
+ Returns the size of the uncompressed data (number of bytes written starting
+ from dest).
+
+ This function expects data in the DEFLATE format, described in RFC
+ (Request for Comments) 1951 in the file
+ ftp://ds.internic.net/rfc/rfc1951.txt.
+
+ This function does not exist in the original zlib. Its implementation
+ using original zlib might be following:
+
+ unsigned inflatemem (char* dest, const char* source)
+ {
+ z_stream stream;
+
+ stream.next_in = (Bytef*) source;
+ stream.avail_in = 65535;
+
+ stream.next_out = dest;
+ stream.avail_out = 65535;
+
+ stream.zalloc = (alloc_func) 0;
+ stream.zfree = (free_func) 0;
+
+ inflateInit2(&stream, -MAX_WBITS);
+ inflate(&stream, Z_FINISH);
+ inflateEnd(&stream);
+
+ return stream.total_out;
+ }
+*/
+
+
+int __fastcall__ uncompress (unsigned char* dest, unsigned* destLen,
+ const unsigned char* source, unsigned sourceLen);
+/*
+ Original zlib description:
+
+ Decompresses the source buffer into the destination buffer. sourceLen is
+ the byte length of the source buffer. Upon entry, destLen is the total
+ size of the destination buffer, which must be large enough to hold the
+ entire uncompressed data. (The size of the uncompressed data must have
+ been saved previously by the compressor and transmitted to the decompressor
+ by some mechanism outside the scope of this compression library.)
+ Upon exit, destLen is the actual size of the compressed buffer.
+ This function can be used to decompress a whole file at once if the
+ input file is mmap'ed.
+
+ uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
+ enough memory, Z_BUF_ERROR if there was not enough room in the output
+ buffer, or Z_DATA_ERROR if the input data was corrupted.
+
+ Implementation notes:
+
+ This function expects data in the ZLIB format, described in RFC 1950
+ in the file ftp://ds.internic.net/rfc/rfc1950.txt. The ZLIB format is
+ essentially the DEFLATE format plus a very small header and Adler-32
+ checksum.
+
+ Z_MEM_ERROR and Z_BUF_ERROR are never returned in this implementation.
+*/
+
+
+unsigned long __fastcall__ adler32 (unsigned long adler,
+ const unsigned char* buf,
+ unsigned len);
+
+/*
+ Original zlib description:
+
+ Update a running Adler-32 checksum with the bytes buf[0..len-1] and
+ return the updated checksum. If buf is NULL, this function returns
+ the required initial value for the checksum.
+ An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
+ much faster. Usage example:
+
+ unsigned long adler = adler32(0L, Z_NULL, 0);
+
+ while (read_buffer(buffer, length) != EOF) {
+ adler = adler32(adler, buffer, length);
+ }
+ if (adler != original_adler) error();
+
+ Implementation notes:
+
+ This function isn't actually much faster than crc32(), but it is smaller
+ and does not use any lookup tables.
+*/
+
+
+unsigned long __fastcall__ crc32 (unsigned long crc,
+ const unsigned char* buf,
+ unsigned len);
+/*
+ Original zlib description:
+
+ Update a running crc with the bytes buf[0..len-1] and return the updated
+ crc. If buf is NULL, this function returns the required initial value
+ for the crc. Pre- and post-conditioning (one's complement) is performed
+ within this function so it shouldn't be done by the application.
+ Usage example:
+
+ unsigned long crc = crc32(0L, Z_NULL, 0);
+
+ while (read_buffer(buffer, length) != EOF) {
+ crc = crc32(crc, buffer, length);
+ }
+ if (crc != original_crc) error();
+
+ Implementation notes:
+
+ This function uses statically allocated 1 KB lookup table. The table is
+ initialised before it is used for the first time (that is, if buffer is
+ NULL or length is zero, then the lookup table isn't initialised).
+*/
+
+
+/* end of zlib.h */
+#endif
+
+
+
+naUz
Uzna ` k + 0 / _ k 3 /
+ 0 m @V@e_*T@e*T@e*T@e5*T@e6 * 2! %
+%
+
+
+
+
+ H
+ I
+ &
+
+
+ $
+ L
+ + A S S E R T I O N F A I L E D # I# N# # %# s# :# %# u#
+# # , - . / )('"
2!
+) ( ' 8
+ 2 ! "
$%&