]> git.sur5r.net Git - cc65/blob - include/_atarios.h
9a8a864b72606e9bf48557e5c23c3d5a9dd96dc5
[cc65] / include / _atarios.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                  _atarios.h                                               */
4 /*                                                                           */
5 /*            Internal include file, do not use directly                     */
6 /*                                                                           */
7 /*                                                                           */
8 /* This software is provided 'as-is', without any expressed or implied       */
9 /* warranty.  In no event will the authors be held liable for any damages    */
10 /* arising from the use of this software.                                    */
11 /*                                                                           */
12 /* Permission is granted to anyone to use this software for any purpose,     */
13 /* including commercial applications, and to alter it and redistribute it    */
14 /* freely, subject to the following restrictions:                            */
15 /*                                                                           */
16 /* 1. The origin of this software must not be misrepresented; you must not   */
17 /*    claim that you wrote the original software. If you use this software   */
18 /*    in a product, an acknowledgment in the product documentation would be  */
19 /*    appreciated but is not required.                                       */
20 /* 2. Altered source versions must be plainly marked as such, and must not   */
21 /*    be misrepresented as being the original software.                      */
22 /* 3. This notice may not be removed or altered from any source              */
23 /*    distribution.                                                          */
24 /*                                                                           */
25 /*****************************************************************************/
26
27 #ifndef __ATARIOS_H
28 #define __ATARIOS_H
29
30
31 /* IOCB Command Codes */
32
33 #define IOCB_OPEN        0x03  /* open */
34 #define IOCB_GETREC      0x05  /* get record */
35 #define IOCB_GETCHR      0x07  /* get character(s) */
36 #define IOCB_PUTREC      0x09  /* put record */
37 #define IOCB_PUTCHR      0x0B  /* put character(s) */
38 #define IOCB_CLOSE       0x0C  /* close */
39 #define IOCB_STATIS      0x0D  /* status */
40 #define IOCB_SPECIL      0x0E  /* special */
41 #define IOCB_DRAWLN      0x11  /* draw line */
42 #define IOCB_FILLIN      0x12  /* draw line with right fill */
43 #define IOCB_RENAME      0x20  /* rename disk file */
44 #define IOCB_DELETE      0x21  /* delete disk file */
45 #define IOCB_LOCKFL      0x23  /* lock file (set to read-only) */
46 #define IOCB_UNLOCK      0x24  /* unlock file */
47 #define IOCB_POINT       0x25  /* point sector */
48 #define IOCB_NOTE        0x26  /* note sector */
49 #define IOCB_GETFL       0x27  /* get file length */
50 #define IOCB_CHDIR_MYDOS 0x29  /* change directory (MyDOS) */
51 #define IOCB_MKDIR       0x2A  /* make directory (MyDOS/SpartaDOS) */
52 #define IOCB_RMDIR       0x2B  /* remove directory (SpartaDOS) */
53 #define IOCB_CHDIR_SPDOS 0x2C  /* change directory (SpartaDOS) */
54 #define IOCB_GETCWD      0x30  /* get current directory (MyDOS/SpartaDOS) */
55 #define IOCB_FORMAT      0xFE  /* format */
56
57
58 /* Device control block */
59
60 struct __dcb {
61     unsigned char ddevic;           /* device id */
62     unsigned char dunit;            /* unit number */
63     unsigned char dcomnd;           /* command */
64     unsigned char dstats;           /* command type / status return */
65     void          *dbuf;            /* pointer to buffer */
66     unsigned char dtimlo;           /* device timeout in seconds */
67     unsigned char dunuse;           /* - unused - */
68     unsigned int  dbyt;             /* # of bytes to transfer */
69     union {    
70         struct {
71             unsigned char daux1;    /* 1st command auxiliary byte */
72             unsigned char daux2;    /* 2nd command auxiliary byte */
73         };
74         unsigned int daux;          /* auxiliary as word */
75     };
76 };
77
78 typedef struct __dcb dcb_t;
79
80
81 /* I/O control block */
82
83 struct __iocb {
84     unsigned char   handler;    /* handler index number (0xff free) */
85     unsigned char   drive;      /* device number (drive) */
86     unsigned char   command;    /* command */
87     unsigned char   status;     /* status of last operation */
88     void*           buffer;     /* pointer to buffer */
89     void*           put_byte;   /* pointer to device's PUT BYTE routine */
90     unsigned int    buflen;     /* length of buffer */
91     unsigned char   aux1;       /* 1st auxiliary byte */
92     unsigned char   aux2;       /* 2nd auxiliary byte */
93     unsigned char   aux3;       /* 3rd auxiliary byte */
94     unsigned char   aux4;       /* 4th auxiliary byte */
95     unsigned char   aux5;       /* 5th auxiliary byte */
96     unsigned char   spare;      /* spare byte */
97 };
98
99 typedef struct __iocb iocb_t;
100
101
102 /* DOS 2.x zeropage variables */
103
104 struct __dos2x {
105     unsigned char*  zbufp;      /* points to user filename */
106     unsigned char*  zdrva;      /* points to serveral buffers (mostly VTOC) */
107     unsigned char*  zsba;       /* points to sector buffer */
108     unsigned char   errno;      /* number of occured error */
109 };
110
111 typedef struct __dos2x dos2x_t;
112
113
114 /* A single device handler formed by it's routines */
115
116 struct __devhdl {
117     void *open;                 /* address of OPEN routine -1 */
118     void *close;                /* address of CLOSE routine -1 */
119     void *get;                  /* address of GET BYTE routine -1 */
120     void *put;                  /* address of PUT BYTE routine -1 */
121     void *status;               /* address of GET STATUS routine -1 */
122     void *special;              /* address od SPECIAL routine -1 */
123     void (*init)(void);         /* init routine (JMP INIT) */
124     void *reserved;             /* unused */
125 };
126
127 typedef struct __devhdl devhdl_t;
128
129
130 /* List of device handlers, as managed in HATABS */
131
132 struct __hatabs {
133     unsigned char   id;         /* ATASCII code of handler e.g. 'C','D','E','K','P','S','R' */
134     devhdl_t*       devhdl;     /* Pointer to routines of device */
135 };
136
137 typedef struct __hatabs hatabs_t;
138
139
140 /* Floating point register */
141
142 struct __fpreg {
143 #ifdef OS_REV2
144     unsigned char fr;
145     unsigned char frm[5];       /* 5-byte register mantissa */
146 #else
147     unsigned char fr[6];        /* 6 bytes for single register */
148 #endif
149 };
150
151 typedef struct __fpreg fpreg_t;
152
153 enum {                          /* enum for access of floating point registers */
154     R0 = 0,                     /* (to use as index) */
155     RE = 1,
156     R1 = 2,
157     R2 = 3
158 } FPIDX;
159
160
161 /* Define a structure with atari os register offsets */
162
163 struct __os {
164
165     // --- Zero-Page ---
166
167 #ifdef OSA
168     unsigned char*  linzbs;                 // = $00/$01        LINBUG RAM (WILL BE REPLACED BY MONITOR RAM)
169 #else           
170     unsigned char   linflg;                 // = $00            LNBUG FLAG (0 = NOT LNBUG)
171     unsigned char   ngflag;                 // = $01            MEMORY STATUS (0 = FAILURE)
172 #endif          
173     unsigned char*  casini;                 // = $02/$03        CASSETTE INIT LOCATION
174     unsigned char*  ramlo;                  // = $04/$05        RAM POINTER FOR MEMORY TEST
175                 
176 #ifdef OSA           
177     unsigned char   tramsz;                 // = $06            FLAG FOR LEFT CARTRIDGE
178     unsigned char   tstdat;                 // = $07            FLAG FOR RIGHT CARTRIDGE
179 #else           
180     unsigned char   trnsmz;                 // = $06            TEMPORARY REGISTER FOR RAM SIZE
181     unsigned char   tstdat;                 // = $07            UNUSED (NOT TOUCHED DURING RESET/COLD START)
182 #endif
183             
184     // Cleared upon Coldstart only                
185                     
186     unsigned char   warmst;                 // = $08            WARM START FLAG
187     unsigned char   bootq;                  // = $09            SUCCESSFUL BOOT FLAG   
188     void (*dosvec)(void);                   // = $0A/$0B        DISK SOFTWARE START VECTOR
189     void (*dosini)(void);                   // = $0C/$0D        DISK SOFTWARE INIT ADDRESS
190     unsigned char*  appmhi;                 // = $0E/$0F        APPLICATIONS MEMORY HI LIMIT    
191
192     // Cleared upon Coldstart or Warmstart
193
194     unsigned char   pokmsk;                 // = $10            SYSTEM MASK FOR POKEY IRQ ENABLE
195     unsigned char   brkkey;                 // = $11            BREAK KEY FLAG
196     unsigned char   rtclok[3];              // = $12-$14        REAL TIME CLOCK (IN 16 MSEC UNITS)
197     unsigned char*  bufadr;                 // = $15/$16        INDIRECT BUFFER ADDRESS REGISTER
198     unsigned char   iccomt;                 // = $17            COMMAND FOR VECTOR
199     unsigned char*  dskfms;                 // = $18/$19        DISK FILE MANAGER POINTER
200     unsigned char*  dskutl;                 // = $1A/$1B        DISK UTILITIES POINTER
201 #ifdef OSA   
202     unsigned char   ptimot;                 // = $1C            PRINTER TIME OUT REGISTER
203     unsigned char   pbpnt;                  // = $1D            PRINT BUFFER POINTER
204     unsigned char   pbufsz;                 // = $1E            PRINT BUFFER SIZE
205     unsigned char   ptemp;                  // = $1F            TEMPORARY REGISTER
206 #else               
207     unsigned char   abufpt[4];              // = $1C-$1F        ACMI BUFFER POINTER AREA
208 #endif              
209     iocb_t          ziocb;                  // = $20-$2F        ZERO PAGE I/O CONTROL BLOCK
210                     
211     unsigned char   status;                 // = $30            INTERNAL STATUS STORAGE
212     unsigned char   chksum;                 // = $31            CHECKSUM (SINGLE BYTE SUM WITH CARRY)
213     unsigned char*  bufr;                   // = $32/$33        POINTER TO DATA BUFFER
214     unsigned char*  bfen;                   // = $34/$35        NEXT BYTE PAST END OF THE DATA BUFFER LO
215 #ifdef OSA                   
216     unsigned char   cretry;                 // = $36            NUMBER OF COMMAND FRAME RETRIES
217     unsigned char   dretry;                 // = $37            NUMBER OF DEVICE RETRIES
218 #else               
219     unsigned int    ltemp;                  // = $36/$37        LOADER TEMPORARY
220 #endif              
221     unsigned char   bufrfl;                 // = $38            DATA BUFFER FULL FLAG
222     unsigned char   recvdn;                 // = $39            RECEIVE DONE FLAG
223     unsigned char   xmtdon;                 // = $3A            TRANSMISSION DONE FLAG
224     unsigned char   chksnt;                 // = $3B            CHECKSUM SENT FLAG
225     unsigned char   nocksm;                 // = $3C            NO CHECKSUM FOLLOWS DATA FLAG
226     unsigned char   bptr;                   // = $3D            CASSETTE BUFFER POINTER
227     unsigned char   ftype;                  // = $3E            CASSETTE IRG TYPE
228     unsigned char   feof;                   // = $3F            CASSETTE EOF FLAG (0 // = QUIET)
229                     
230     unsigned char   freq;                   // = $40            CASSETTE BEEP COUNTER
231     unsigned char   soundr;                 // = $41            NOISY I/0 FLAG. (ZERO IS QUIET)
232     unsigned char   critic;                 // = $42            DEFINES CRITICAL SECTION (CRITICAL IF NON-Z)
233     dos2x_t         fmszpg;                 // = $43-$49        DISK FILE MANAGER SYSTEM ZERO PAGE
234 #ifdef OSA                   
235     unsigned char   ckey;                   // = $4A            FLAG SET WHEN GAME START PRESSED
236     unsigned char   cassbt;                 // = $4B            CASSETTE BOOT FLAG
237 #else               
238     void*           zchain;                 // = $4A/$4B        HANDLER LINKAGE CHAIN POINTER
239 #endif              
240     unsigned char   dstat;                  // = $4C            DISPLAY STATUS
241     unsigned char   atract;                 // = $4D            ATRACT FLAG
242     unsigned char   drkmsk;                 // = $4E            DARK ATRACT MASK
243     unsigned char   colrsh;                 // = $4F            ATRACT COLOR SHIFTER (EOR'ED WITH PLAYFIELD
244                 
245     unsigned char   tmpchr;                 // = $50            TEMPORARY CHARACTER
246     unsigned char   hold1;                  // = $51            TEMPORARY
247     unsigned char   lmargn;                 // = $52            LEFT MARGIN (NORMALLY 2, CC65 C STARTUP CODE SETS IT TO 0)
248     unsigned char   rmargn;                 // = $53            RIGHT MARGIN (NORMALLY 39 IF NO XEP80 IS USED)
249     unsigned char   rowcrs;                 // = $54            1CURSOR ROW
250     unsigned int    colcrs;                 // = $55/$56        CURSOR COLUMN
251     unsigned char   dindex;                 // = $57            DISPLAY MODE
252     unsigned char*  savmsc;                 // = $58/$59        SAVED MEMORY SCAN COUNTER
253     unsigned char   oldrow;                 // = $5A            PRIOR ROW
254     unsigned int    oldcol;                 // = $5B/$5C        PRIOR COLUMN
255     unsigned char   oldchr;                 // = $5D            DATA UNDER CURSOR
256     unsigned char*  oldadr;                 // = $5E/$5F        SAVED CURSOR MEMORY ADDRESS
257     
258 #ifdef OSA 
259     unsigned char   newrow;                 // = $60            POINT DRAW GOES TO
260     unsigned int    newcol;                 // = $61/$62        COLUMN DRAW GOES TO
261 #else               
262     unsigned char*  fkdef;                  // = $60/$61        FUNCTION KEY DEFINITION TABLE
263     unsigned char   palnts;                 // = $62            PAL/NTSC INDICATOR (0 // = NTSC)
264 #endif          
265     unsigned char   logcol;                 // = $63            POINTS AT COLUMN IN LOGICAL LINE
266     unsigned char*  adress;                 // = $64/$65        TEMPORARY ADDRESS
267     unsigned int    mlttmp;                 // = $66/$67        TEMPORARY / FIRST BYTE IS USED IN OPEN AS TEMP          
268     unsigned int    savadr;                 // = $68/$69        SAVED ADDRESS        
269     unsigned char   ramtop;                 // = $6A            RAM SIZE DEFINED BY POWER ON LOGIC
270     unsigned char   bufcnt;                 // = $6B            BUFFER COUNT
271     unsigned char*  bufstr;                 // = $6C/$6D        EDITOR GETCH POINTER
272     unsigned char   bitmsk;                 // = $6E            BIT MASK
273     unsigned char   shfamt;                 // = $6F            SHIFT AMOUNT FOR PIXEL JUSTIFUCATION
274                 
275     unsigned int    rowac;                  // = $70/$71        DRAW WORKING ROW
276     unsigned int    colac;                  // = $72/$73        DRAW WORKING COLUMN
277     unsigned char*  endpt;                  // = $74/$75        END POINT
278     unsigned char   deltar;                 // = $76            ROW DIFFERENCE
279     unsigned int    deltac;                 // = $77/$78        COLUMN DIFFERENCE
280 #ifdef OSA               
281     unsigned char   rowinc;                 // = $79            ROWINC 
282     unsigned char   colinc;                 // = $7A            COLINC
283 #else           
284     unsigned char*  keydef;                 // = $79/$7A        2-BYTE KEY DEFINITION TABLE ADDRESS
285 #endif          
286     unsigned char   swpflg;                 // = $7B            NON-0 1F TXT AND REGULAR RAM IS SWAPPED
287     unsigned char   holdch;                 // = $7C            CH IS MOVED HERE IN KGETCH BEFORE CNTL & SH
288     unsigned char   insdat;                 // = $7D            1-BYTE TEMPORARY
289     unsigned int    countr;                 // = $7E/$7F        2-BYTE DRAW ITERATION COUNT
290     
291     unsigned char   _free_1[0xD4-0x7F-1];   // USER SPACE
292     
293                                             // Floating Point Package Page Zero Address Equates
294     fpreg_t         fpreg[4];               // = $D4-$EB        4 REGSITERS, ACCCESS LIKE "fpreg[R0].fr"        
295     unsigned char   frx;                    // = $EC            1-BYTE TEMPORARY   
296     unsigned char   eexp;                   // = $ED            VALUE OF EXP
297 #ifdef OS_REV2          
298     unsigned char   frsign;                 // = $EE            ##REV2## 1-BYTE FLOATING POINT SIGN
299     unsigned char   plycnt;                 // = $EF            ##REV2## 1-BYTE POLYNOMIAL DEGREE
300     unsigned char   sgnflg;                 // = $F0            ##REV2## 1-BYTE SIGN FLAG
301     unsigned char   xfmflg;                 // = $F1            ##REV2## 1-BYTE TRANSFORM FLAG
302 #else           
303     unsigned char   nsign;                  // = $EE            SIGN OF #
304     unsigned char   esign;                  // = $EF            SIGN OF EXPONENT
305     unsigned char   fchrflg;                // = $F0            1ST CHAR FLAG
306     unsigned char   digrt;                  // = $F1            # OF DIGITS RIGHT OF DECIMAL
307 #endif          
308     unsigned char   cix;                    // = $F2            CURRENT INPUT INDEX
309     unsigned char*  inbuff;                 // = $F3/$F4        POINTS TO USER'S LINE INPUT BUFFER                           
310     unsigned int    ztemp1;                 // = $F5/$F6        2-BYTE TEMPORARY
311     unsigned int    ztemp4;                 // = $F7/$F8        2-BYTE TEMPORARY
312     unsigned int    ztemp3;                 // = $F9/$FA        2-BYTE TEMPORARY
313                 
314     union {         
315         unsigned char   degflg;             // = $FB            ##OLD## SAME AS RADFLG
316         unsigned char   radflg;             // = $FB            ##OLD## 0=RADIANS, 6=DEGREES
317     };
318             
319     fpreg_t*        flptr;                  // = $FC/$FD        2-BYTE FLOATING POINT NUMBER POINTER
320     fpreg_t*        fptr2;                  // = $FE/$FF        2-BYTE FLOATING POINT NUMBER POINTER
321
322     // --- Page 1 ---
323
324     unsigned char   stack[0x100];           // STACK
325
326     // --- Page 2 ---
327
328     void (*vdslst)(void);                   // = $0200/$0201    DISPLAY LIST NMI VECTOR
329     void (*vprced)(void);                   // = $0202/$0203    PROCEED LINE IRQ VECTOR
330     void (*vinter)(void);                   // = $0204/$0205    INTERRUPT LINE IRQ VECTOR
331     void (*vbreak)(void);                   // = $0206/$0207    SOFTWARE BREAK (00) INSTRUCTION IRQ VECTOR
332     void (*vkeybd)(void);                   // = $0208/$0209    POKEY KEYBOARD IRQ VECTOR
333     void (*vserin)(void);                   // = $020A/$020B    POKEY SERIAL INPUT READY IRQ
334     void (*vseror)(void);                   // = $020C/$020D    POKEY SERIAL OUTPUT READY IRQ
335     void (*vseroc)(void);                   // = $020E/$020F    POKEY SERIAL OUTPUT COMPLETE IRQ
336     void (*vtimr1)(void);                   // = $0210/$0201    POKEY TIMER 1 IRQ
337     void (*vtimr2)(void);                   // = $0212/$0203    POKEY TIMER 2 IRQ
338     void (*vtimr4)(void);                   // = $0214/$0205    POKEY TIMER 4 IRQ
339     void (*vimirq)(void);                   // = $0216/$0207    IMMEDIATE IRQ VECTOR
340     unsigned int cdtmv1;                    // = $0218/$0210    COUNT DOWN TIMER 1
341     unsigned int cdtmv2;                    // = $021A/$021B    COUNT DOWN TIMER 2
342     unsigned int cdtmv3;                    // = $021C/$021D    COUNT DOWN TIMER 3
343     unsigned int cdtmv4;                    // = $021E/$021F    COUNT DOWN TIMER 4
344     unsigned int cdtmv5;                    // = $0220/$0221    COUNT DOWN TIMER 5
345     void (*vvblki)(void);                   // = $0222/$0223    IMMEDIATE VERTICAL BLANK NMI VECTOR
346     void (*vvblkd)(void);                   // = $0224/$0224    DEFERRED VERTICAL BLANK NMI VECTOR
347     void (*cdtma1)(void);                   // = $0226/$0227    COUNT DOWN TIMER 1 JSR ADDRESS
348     void (*cdtma2)(void);                   // = $0228/$0229    COUNT DOWN TIMER 2 JSR ADDRESS
349     unsigned char cdtmf3;                   // = $022A          COUNT DOWN TIMER 3 FLAG
350     unsigned char srtimr;                   // = $022B          SOFTWARE REPEAT TIMER
351     unsigned char cdtmf4;                   // = $022C          COUNT DOWN TIMER 4 FLAG
352     unsigned char intemp;                   // = $022D          IAN'S TEMP
353     unsigned char cdtmf5;                   // = $022E          COUNT DOWN TIMER FLAG 5
354     unsigned char sdmctl;                   // = $022F          SAVE DMACTL REGISTER
355     union {
356         struct {
357             unsigned char sdlstl;           // = $0230          SAVE DISPLAY LIST LOW BYTE
358             unsigned char sdlsth;           // = $0231          SAVE DISPLAY LIST HI BYTE     
359         };
360         void*   sdlst;                      // = $0230/$0231    (same as above as pointer)
361     };
362     unsigned char sskctl;                   // = $0232          SKCTL REGISTER RAM
363 #ifdef OSA 
364     unsigned char _spare_1;                 // = $0233          No OS use.
365 #else
366     unsigned char lcount;                   // = $0233          ##1200xl## 1-byte relocating loader record
367 #endif          
368     unsigned char lpenh;                    // = $0234          LIGHT PEN HORIZONTAL VALUE
369     unsigned char lpenv;                    // = $0235          LIGHT PEN VERTICAL VALUE
370     void (*brkky)(void);                    // = $0236/$0237    BREAK KEY VECTOR
371 #ifdef OSA           
372     unsigned char spare2[2];                // = $0238/$0239    No OS use.
373 #else           
374     void (*vpirq)(void);                    // = $0238/$0239    ##rev2## 2-byte parallel device IRQ vector
375 #endif          
376     unsigned char cdevic;                   // = $023A          COMMAND FRAME BUFFER - DEVICE
377     unsigned char ccomnd;                   // = $023B          COMMAND
378     union {
379         struct {    
380             unsigned char caux1;            // = $023C          COMMAND AUX BYTE 1
381             unsigned char caux2;            // = $023D          COMMAND AUX BYTE 2
382         };
383         unsigned int caux;                  // = $023C/$023D    (same as above as word)
384     };
385     unsigned char temp;                     // = $023E          TEMPORARY RAM CELL
386     unsigned char errflg;                   // = $023F          ERROR FLAG - ANY DEVICE ERROR EXCEPT TIME OUT
387     unsigned char dflags;                   // = $0240          DISK FLAGS FROM SECTOR ONE
388     unsigned char dbsect;                   // = $0241          NUMBER OF DISK BOOT SECTORS
389     unsigned char* bootad;                  // = $0242/$0243    ADDRESS WHERE DISK BOOT LOADER WILL BE PUT
390     unsigned char coldst;                   // = $0244          COLDSTART FLAG (1=IN MIDDLE OF COLDSTART>
391 #ifdef OSA           
392     unsigned char spare3;                   // = $0245          No OS use.
393 #else           
394     unsigned char reclen;                   // = $0245          ##1200xl## 1-byte relocating loader record length
395 #endif              
396     unsigned char dsktim;                   // = $0246          DISK TIME OUT REGISTER
397 #ifdef OSA               
398     unsigned char linbuf[40];               // = $0247-$026E    ##old## CHAR LINE BUFFER
399 #else           
400     unsigned char pdvmsk;                   // = $0247          ##rev2## 1-byte parallel device selection mask
401     unsigned char shpdvs;                   // = $0248          ##rev2## 1-byte PDVS (parallel device select)
402     unsigned char pdimsk;                   // = $0249          ##rev2## 1-byte parallel device IRQ selection
403     unsigned int  reladr;                   // = $024A/$024B    ##rev2## 2-byte relocating loader relative adr.
404     unsigned char pptmpa;                   // = $024C          ##rev2## 1-byte parallel device handler temporary
405     unsigned char pptmpx;                   // = $024D          ##rev2## 1-byte parallel device handler temporary
406     unsigned char _reserved_1[29];          // = $024E-$026A    RESERVED
407     unsigned char chsalt;                   // = $026B          ##1200xl## 1-byte character set alternate
408     unsigned char vsflag;                   // = $026C          ##1200xl## 1-byte fine vertical scroll count
409     unsigned char keydis;                   // = $026D          ##1200xl## 1-byte keyboard disable
410     unsigned char fine;                     // = $026E          ##1200xl## 1-byte fine scrolling mode
411 #endif              
412     unsigned char gprior;                   // = $026F          GLOBAL PRIORITY CELL
413     unsigned char paddl0;                   // = $0270          1-BYTE POTENTIOMETER 0
414     unsigned char paddl1;                   // = $0271          1-BYTE POTENTIOMETER 1
415     unsigned char paddl2;                   // = $0272          1-BYTE POTENTIOMETER 2
416     unsigned char paddl3;                   // = $0273          1-BYTE POTENTIOMETER 3
417     unsigned char paddl4;                   // = $0274          1-BYTE POTENTIOMETER 4
418     unsigned char paddl5;                   // = $0275          1-BYTE POTENTIOMETER 5
419     unsigned char paddl6;                   // = $0276          1-BYTE POTENTIOMETER 6
420     unsigned char paddl7;                   // = $0277          1-BYTE POTENTIOMETER 7
421     unsigned char stick0;                   // = $0278          1-byte joystick 0
422     unsigned char stick1;                   // = $0279          1-byte joystick 1
423     unsigned char stick2;                   // = $027A          1-byte joystick 2
424     unsigned char stick3;                   // = $027B          1-byte joystick 3
425     unsigned char ptrig0;                   // = $027C          1-BYTE PADDLE TRIGGER 0
426     unsigned char ptrig1;                   // = $027D          1-BYTE PADDLE TRIGGER 1
427     unsigned char ptrig2;                   // = $027E          1-BYTE PADDLE TRIGGER 2
428     unsigned char ptrig3;                   // = $027F          1-BYTE PADDLE TRIGGER 3
429     unsigned char ptrig4;                   // = $0280          1-BYTE PADDLE TRIGGER 4
430     unsigned char ptrig5;                   // = $0281          1-BYTE PADDLE TRIGGER 5
431     unsigned char ptrig6;                   // = $0281          1-BYTE PADDLE TRIGGER 6
432     unsigned char ptrig7;                   // = $0283          1-BYTE PADDLE TRIGGER 7
433     unsigned char strig0;                   // = $0284          1-BYTE JOYSTICK TRIGGER 0
434     unsigned char strig1;                   // = $0285          1-BYTE JOYSTICK TRIGGER 1
435     unsigned char strig2;                   // = $0286          1-BYTE JOYSTICK TRIGGER 2
436     unsigned char strig3;                   // = $0287          1-BYTE JOYSTICK TRIGGER 3
437 #ifdef OSA           
438     unsigned char cstat;                    // = $0288          ##old## cassette status register
439 #else           
440     unsigned char hibyte;                   // = $0288          ##1200xl## 1-byte relocating loader high byte
441 #endif          
442     unsigned char wmode;                    // = $0289          1-byte cassette WRITE mode
443     unsigned char blim;                     // = $028A          1-byte cassette buffer limit
444 #ifdef OSA
445     unsigned char _reserved_2[5];           // = $028B-$028F    RESERVED
446 #else    
447     unsigned char imask;                    // = $028B          ##rev2## (not used)
448     void (*jveck)(void);                    // = $028C/$028D    2-byte jump vector
449     unsigned newadr;                        // = $028E/028F     ##1200xl## 2-byte relocating address
450 #endif              
451     unsigned char txtrow;                   // = $0290          TEXT ROWCRS
452     unsigned txtcol;                        // = $0291/$0292    TEXT COLCRS
453     unsigned char tindex;                   // = $0293          TEXT INDEX
454     unsigned char* txtmsc;                  // = $0294/$0295    FOOLS CONVRT INTO NEW MSC
455     unsigned char txtold[6];                // = $0296-$029B    OLDROW & OLDCOL FOR TEXT (AND THEN SOME)
456 #ifdef OSA               
457     unsigned char tmpx1;                    // = $029C          ##old## 1--byte temporary register
458 #else           
459     unsigned char cretry;                   // = $029C          ##1200xl## 1-byte number of command frame retries
460 #endif              
461     unsigned char hold3;                    // = $029D          1-byte temporary
462     unsigned char subtmp;                   // = $029E          1-byte temporary
463     unsigned char hold2;                    // = $029F          1-byte (not used)
464     unsigned char dmask;                    // = $02A0          1-byte display (pixel location) mask
465     unsigned char tmplbt;                   // = $02A1          1-byte (not used)
466     unsigned char escflg;                   // = $02A2          ESCAPE FLAG
467     unsigned char tabmap[15];               // = $02A3-$02B1    15-byte (120 bit) tab stop bit map
468     unsigned char logmap[4];                // = $02B2-$02B5    LOGICAL LINE START BIT MAP
469     unsigned char invflg;                   // = $02B6          INVERSE VIDEO FLAG (TOGGLED BY ATARI KEY)
470     unsigned char filflg;                   // = $02B7          RIGHT FILL FLAG FOR DRAW
471     unsigned char tmprow;                   // = $02B8          1-byte temporary row
472     unsigned tmpcol;                        // = $02B9/$02BA    2-byte temporary column
473     unsigned char scrflg;                   // = $02BB          SET IF SCROLL OCCURS
474     unsigned char hold4;                    // = $02BC          TEMP CELL USED IN DRAW ONLY
475 #ifdef OSA           
476     unsigned char hold5;                    // = $02BD          ##old## DITTO
477 #else           
478     unsigned char dretry;                   // = $02BD          ##1200xl## 1-byte number of device retries
479 #endif              
480     unsigned char shflok;                   // = $02BE          1-byte shift/control lock flags
481     unsigned char botscr;                   // = $02BF          BOTTOM OF SCREEN   24 NORM 4 SPLIT
482     unsigned char pcolr0;                   // = $02C0          1-byte player-missile 0 color/luminance
483     unsigned char pcolr1;                   // = $02C1          1-byte player-missile 1 color/luminance
484     unsigned char pcolr2;                   // = $02C2          1-byte player-missile 2 color/luminance
485     unsigned char pcolr3;                   // = $02C3          1-byte player-missile 3 color/luminance 
486     unsigned char color0;                   // = $02C4          1-byte playfield 0 color/luminance
487     unsigned char color1;                   // = $02C5          1-byte playfield 1 color/luminance
488     unsigned char color2;                   // = $02C6          1-byte playfield 2 color/luminance
489     unsigned char color3;                   // = $02C7          1-byte playfield 3 color/luminance
490     unsigned char color4;                   // = $02C8          1-byte background color/luminance
491 #ifdef OSA 
492     unsigned char _spare_2[23];             // = $02C9-$02DF    No OS use.
493 #else
494     union {
495         unsigned char parmbl[6];            // = $02C9          ##rev2## 6-byte relocating loader parameter
496         struct {        
497             void (*runadr)(void);           // = $02C9          ##1200xl## 2-byte run address
498             unsigned int hiused;            // = $02CB          ##1200xl## 2-byte highest non-zero page address
499             unsigned int zhiuse;            // = $02CD          ##1200xl## 2-byte highest zero page address
500         };       
501     };       
502     union {     
503         unsigned char oldpar[6];            // = $02CF          ##rev2## 6-byte relocating loader parameter
504         struct {        
505             void (*gbytea)(void);           // = $02CF          ##1200xl## 2-byte GET-BYTE routine address
506             unsigned int loadad;            // = $02D1          ##1200xl## 2-byte non-zero page load address
507             unsigned int zloada;            // = $02D3          ##1200xl## 2-byte zero page load address
508         };       
509     };       
510     unsigned int dsctln;                    // = $02D5          ##1200xl## 2-byte disk sector length
511     unsigned int acmisr;                    // = $02D7          ##1200xl## 2-byte ACMI interrupt service routine
512     unsigned char krpdel;                   // = $02D9          ##1200xl## 1-byte auto-repeat delay
513     unsigned char keyrep;                   // = $02DA          ##1200xl## 1-byte auto-repeat rate
514     unsigned char noclik;                   // = $02DB          ##1200xl## 1-byte key click disable
515     unsigned char helpfg;                   // = $02DC          ##1200xl## 1-byte HELP key flag (0 = no HELP)
516     unsigned char dmasav;                   // = $02DD          ##1200xl## 1-byte SDMCTL save/restore
517     unsigned char pbpnt;                    // = $02DE          ##1200xl## 1-byte printer buffer pointer
518     unsigned char pbufsz;                   // = $02DF          ##1200xl## 1-byte printer buffer size
519 #endif      
520     union {         
521         unsigned char glbabs[4];            // = $02E0-$02E3    byte global variables for non-DOS users
522         struct {        
523             void (*runad)(void);            // = $02E0          ##map## 2-byte binary file run address
524             void (*initad)(void);           // = $02E2          ##map## 2-byte binary file initialization address
525         };      
526     };    
527     unsigned char ramsiz;                   // = $02E4          RAM SIZE (HI BYTE ONLY)
528     void* memtop;                           // = $02E5          TOP OF AVAILABLE USER MEMORY
529     void* memlo;                            // = $02E7          BOTTOM OF AVAILABLE USER MEMORY
530 #ifdef OSA       
531     unsigned char _spare_3;                 // = $02E9          No OS use.
532 #else       
533     unsigned char hndlod;                   // = $02E9          ##1200xl## 1-byte user load flag
534 #endif      
535     unsigned char dvstat[4];                // = $02EA-$02ED    STATUS BUFFER
536     union {     
537         unsigned int cbaud;                 // = $02EE/$02EF    2-byte cassette baud rate
538         struct {        
539             unsigned char cbaudl;           // = $02EE          1-byte low cassette baud rate
540             unsigned char cbaudh;           // = $02EF          1-byte high cassette baud rate
541         };    
542     };  
543     unsigned char crsinh;                   // = $02F0          CURSOR INHIBIT (00 = CURSOR ON)
544     unsigned char keydel;                   // = $02F1          KEY DELAY
545     unsigned char ch1;                      // = $02F2          1-byte prior keyboard character
546     unsigned char chact;                    // = $02F3          CHACTL REGISTER RAM
547     unsigned char chbas;                    // = $02F4          CHBAS REGISTER RAM
548 #ifdef OSA       
549     unsigned char _spare_4[5];              // = $02F5-$02F9    No OS use.
550 #else           
551     unsigned char newrow;                   // = $02F5          ##1200xl## 1-byte draw destination row
552     unsigned int  newcol;                   // = $02F6/$02F7    ##1200xl## 2-byte draw destination column
553     unsigned char rowinc;                   // = $02F8          ##1200xl## 1-byte draw row increment
554     unsigned char colinc;                   // = $02F9          ##1200xl## 1-byte draw column increment
555 #endif      
556     unsigned char char_;                    // = $02FA          1-byte internal character (naming changed due to do keyword conflict)
557     unsigned char atachr;                   // = $02FB          ATASCII CHARACTER
558     unsigned char ch;                       // = $02FC          GLOBAL VARIABLE FOR KEYBOARD
559     unsigned char fildat;                   // = $02FD          RIGHT FILL DATA <DRAW>
560     unsigned char dspflg;                   // = $02FE          DISPLAY FLAG   DISPLAY CNTLS IF NON-ZERO
561     unsigned char ssflag;                   // = $02FF          START/STOP FLAG FOR PAGING (CNTL 1). CLEARE
562         
563     // --- Page 3 ---
564
565     dcb_t dcb;                              // = $0300-$030B    DEVICE CONTROL BLOCK
566     unsigned int timer1;                    // = $030C/$030D    INITIAL TIMER VALUE
567 #ifdef OSA                      
568     unsigned char addcor;                   // = $030E          ##old## ADDITION CORRECTION
569 #else                       
570     unsigned char jmpers;                   // = $030E          ##1200xl## 1-byte jumper options
571 #endif          
572     unsigned char casflg;                   // = $030F          CASSETTE MODE WHEN SET
573     unsigned int  timer2;                   // = $0310/$0311    2-byte final baud rate timer value
574     unsigned char temp1;                    // = $0312          TEMPORARY STORAGE REGISTER
575 #ifdef OSA                  
576     unsigned char _spare_5;                 // = $0313          unused
577     unsigned char temp2;                    // = $0314          ##old## TEMPORARY STORAGE REGISTER
578 #else                               
579     unsigned char temp2;                    // = $0313          ##1200xl## 1-byte temporary
580     unsigned char ptimot;                   // = $0314          ##1200xl## 1-byte printer timeout
581 #endif                  
582     unsigned char temp3;                    // = $0315          TEMPORARY STORAGE REGISTER
583     unsigned char savio;                    // = $0316          SAVE SERIAL IN DATA PORT
584     unsigned char timflg;                   // = $0317          TIME OUT FLAG FOR BAUD RATE CORRECTION
585     unsigned char stackp;                   // = $0318          SIO STACK POINTER SAVE CELL
586     unsigned char tstat;                    // = $0319          TEMPORARY STATUS HOLDER
587 #ifdef OSA              
588     hatabs_t      hatabs[12];               // = $031A-$033D    handler address table
589     unsigned int  zeropad;                  // = $033E/$033F    zero padding
590 #else           
591     hatabs_t      hatabs[11];               // = $031A-$033A    handler address table
592     unsigned int  zeropad;                  // = $033B/$033C    zero padding
593     unsigned char pupbt1;                   // = $033D          ##1200xl## 1-byte power-up validation byte 1
594     unsigned char pupbt2;                   // = $033E          ##1200xl## 1-byte power-up validation byte 2
595     unsigned char pupbt3;                   // = $033F          ##1200xl## 1-byte power-up validation byte 3
596 #endif
597
598     iocb_t        iocb[8];                  // = $0340-$03BF    8 I/O Control Blocks
599     unsigned char prnbuf[40];               // = $03C0-$3E7     PRINTER BUFFER
600 #ifdef OSA           
601     unsigned char _spare_6[151];            // = $03E8-$047F    unused
602 #else               
603     unsigned char superf;                   // = $03E8          ##1200xl## 1-byte editor super function flag
604     unsigned char ckey;                     // = $03E9          ##1200xl## 1-byte cassette boot request flag
605     unsigned char cassbt;                   // = $03EA          ##1200xl## 1-byte cassette boot flag
606     unsigned char cartck;                   // = $03EB          ##1200xl## 1-byte cartridge equivalence check
607     unsigned char derrf;                    // = $03EC          ##rev2## 1-byte screen OPEN error flag
608     unsigned char acmvar[11];               // = $03ED-$03F7    ##1200xl## reserved for ACMI, not cleared upon reset
609     unsigned char basicf;                   // = $03F8          ##rev2## 1-byte BASIC switch flag
610     unsigned char mintlk;                   // = $03F9          ##1200xl## 1-byte ACMI module interlock
611     unsigned char gintlk;                   // = $03FA          ##1200xl## 1-byte cartridge interlock
612     void*         chlink;                   // = $03FB/$03FC    ##1200xl## 2-byte loaded handler chain link
613     unsigned char casbuf[131];              // = $03FD-$047F    CASSETTE BUFFER
614 #endif
615
616     // --- Page 4 ---
617
618     unsigned char usarea[128];              // = $0480          128 bytes reserved for application
619
620     // --- Page 5 ---
621
622     unsigned char _spare_7[126];            // = $0500-$057D    reserved for FP package / unused
623     unsigned char lbpr1;                    // = $057E          LBUFF PREFIX 1
624     unsigned char lbpr2;                    // = $057F          LBUFF PREFIX 2
625     unsigned char lbuff[128];               // = $0580-$05FF    128-byte line buffer
626 };
627
628
629 /* Define a structure with the zero page atari basic register offsets */
630
631 struct __basic {
632     void*         lowmem;                   // = $80/$81        POINTER TO BASIC'S LOW MEMORY
633     void*         vntp;                     // = $82/$83        BEGINNING ADDRESS OF THE VARIABLE NAME TABLE
634     void*         vntd;                     // = $84/$85        POINTER TO THE ENDING ADDRESS OF THE VARIABLE NAME TABLE PLUS ONE
635     void*         vvtp;                     // = $86/$87        ADDRESS FOR THE VARIABLE VALUE TABLE
636     void*         stmtab;                   // = $88/$89        ADDRESS OF THE STATEMENT TABLE
637     void*         stmcur;                   // = $8A/$8B        CURRENT BASIC STATEMENT POINTER
638     void*         starp;                    // = $8C/$8D        ADDRESS FOR THE STRING AND ARRAY TABLE
639     void*         runstk;                   // = $8E/$8F        ADDRESS OF THE RUNTIME STACK
640     void*         memtop;                   // = $90/$91        POINTER TO THE TOP OF BASIC MEMORY
641     
642     unsigned char   _internal_1[0xBA-0x91-1];  // INTERNAL DATA
643
644     unsigned int  stopln;                   // = $BA/$BB        LINE WHERE A PROGRAM WAS STOPPED
645
646     unsigned char   _internal_2[0xC3-0xBB-1];   // INTERNAL DATA
647
648     unsigned char errsav;                   // = $C3            NUMBER OF THE ERROR CODE
649
650     unsigned char   _internal_3[0xC9-0xC3-1];   // INTERNAL DATA
651
652     unsigned char ptabw;                    // = $C9            NUMBER OF COLUMNS BETWEEN TAB STOPS
653     unsigned char loadflg;                  // = $CA            LIST PROTECTION
654
655     unsigned char   _internal_4[0xD4-0xCA-1];   // INTERNAL DATA
656
657     unsigned int  binint;                   // = $D4/$D5        USR-CALL RETURN VALUE
658 };
659
660 #endif