1 #ifndef ANTIC_H_
2 #define ANTIC_H_
3 
4 #include "atari.h"
5 
6 /*
7  * Offset to registers in custom relative to start of antic memory addresses.
8  */
9 
10 #define ANTIC_OFFSET_DMACTL 0x00
11 #define ANTIC_OFFSET_CHACTL 0x01
12 #define ANTIC_OFFSET_DLISTL 0x02
13 #define ANTIC_OFFSET_DLISTH 0x03
14 #define ANTIC_OFFSET_HSCROL 0x04
15 #define ANTIC_OFFSET_VSCROL 0x05
16 #define ANTIC_OFFSET_PMBASE 0x07
17 #define ANTIC_OFFSET_CHBASE 0x09
18 #define ANTIC_OFFSET_WSYNC 0x0a
19 #define ANTIC_OFFSET_VCOUNT 0x0b
20 #define ANTIC_OFFSET_PENH 0x0c
21 #define ANTIC_OFFSET_PENV 0x0d
22 #define ANTIC_OFFSET_NMIEN 0x0e
23 #define ANTIC_OFFSET_NMIRES 0x0f
24 #define ANTIC_OFFSET_NMIST 0x0f
25 
26 extern UBYTE ANTIC_CHACTL;
27 extern UBYTE ANTIC_CHBASE;
28 extern UWORD ANTIC_dlist;
29 extern UBYTE ANTIC_DMACTL;
30 extern UBYTE ANTIC_HSCROL;
31 extern UBYTE ANTIC_NMIEN;
32 extern UBYTE ANTIC_NMIST;
33 extern UBYTE ANTIC_PMBASE;
34 extern UBYTE ANTIC_VSCROL;
35 
36 extern int ANTIC_break_ypos;
37 extern int ANTIC_ypos;
38 extern int ANTIC_wsync_halt;
39 
40 /* Current clock cycle in a scanline.
41    Normally 0 <= ANTIC_xpos && ANTIC_xpos < ANTIC_LINE_C, but in some cases ANTIC_xpos >= ANTIC_LINE_C,
42    which means that we are already in line (ypos + 1). */
43 extern int ANTIC_xpos;
44 
45 /* ANTIC_xpos limit for the currently running 6502 emulation. */
46 extern int ANTIC_xpos_limit;
47 
48 /* Main clock value at the beginning of the current scanline. */
49 extern unsigned int ANTIC_screenline_cpu_clock;
50 
51 /* Current main clock value. */
52 #define ANTIC_CPU_CLOCK (ANTIC_screenline_cpu_clock + ANTIC_XPOS)
53 
54 #define ANTIC_NMIST_C	6
55 #define ANTIC_NMI_C	12
56 
57 /* Number of cycles per scanline. */
58 #define ANTIC_LINE_C   114
59 
60 /* STA WSYNC resumes here. */
61 #define ANTIC_WSYNC_C  106
62 
63 /* Number of memory refresh cycles per scanline.
64    In the first scanline of a font mode there are actually less than ANTIC_DMAR
65    memory refresh cycles. */
66 #define ANTIC_DMAR     9
67 
68 extern int ANTIC_artif_mode;
69 extern int ANTIC_artif_new;
70 
71 extern UBYTE ANTIC_PENH_input;
72 extern UBYTE ANTIC_PENV_input;
73 
74 int ANTIC_Initialise(int *argc, char *argv[]);
75 void ANTIC_Reset(void);
76 void ANTIC_Frame(int draw_display);
77 UBYTE ANTIC_GetByte(UWORD addr, int no_side_effects);
78 void ANTIC_PutByte(UWORD addr, UBYTE byte);
79 
80 UBYTE ANTIC_GetDLByte(UWORD *paddr);
81 UWORD ANTIC_GetDLWord(UWORD *paddr);
82 
83 /* always call ANTIC_UpdateArtifacting after changing ANTIC_artif_mode */
84 void ANTIC_UpdateArtifacting(void);
85 
86 /* Video memory access */
87 void ANTIC_VideoMemset(UBYTE *ptr, UBYTE val, ULONG size);
88 void ANTIC_VideoPutByte(UBYTE *ptr, UBYTE val);
89 
90 /* GTIA calls it on a write to PRIOR */
91 void ANTIC_SetPrior(UBYTE prior);
92 
93 /* Saved states */
94 void ANTIC_StateSave(void);
95 void ANTIC_StateRead(void);
96 
97 /* Pointer to 16 KB seen by ANTIC in 0x4000-0x7fff.
98    If it's the same what the CPU sees (and what's in memory[0x4000..0x7fff],
99    then NULL. */
100 extern const UBYTE *ANTIC_xe_ptr;
101 
102 /* PM graphics for GTIA */
103 extern int ANTIC_player_dma_enabled;
104 extern int ANTIC_missile_dma_enabled;
105 extern int ANTIC_player_gra_enabled;
106 extern int ANTIC_missile_gra_enabled;
107 extern int ANTIC_player_flickering;
108 extern int ANTIC_missile_flickering;
109 
110 /* ANTIC colour lookup tables, used by GTIA */
111 extern UWORD ANTIC_cl[128];
112 extern ULONG ANTIC_lookup_gtia9[16];
113 extern ULONG ANTIC_lookup_gtia11[16];
114 extern UWORD ANTIC_hires_lookup_l[128];
115 
116 #ifdef NEW_CYCLE_EXACT
117 #define ANTIC_NOT_DRAWING -999
118 #define ANTIC_DRAWING_SCREEN (ANTIC_cur_screen_pos!=ANTIC_NOT_DRAWING)
119 extern int ANTIC_delayed_wsync;
120 extern int ANTIC_cur_screen_pos;
121 extern const int *ANTIC_cpu2antic_ptr;
122 extern const int *ANTIC_antic2cpu_ptr;
123 void ANTIC_UpdateScanline(void);
124 void ANTIC_UpdateScanlinePrior(UBYTE byte);
125 
126 #define ANTIC_XPOS ( ANTIC_DRAWING_SCREEN ? ANTIC_cpu2antic_ptr[ANTIC_xpos] : ANTIC_xpos )
127 #else
128 #define ANTIC_XPOS ANTIC_xpos
129 #endif /* NEW_CYCLE_EXACT */
130 
131 #ifndef NO_SIMPLE_PAL_BLENDING
132 /* Set to 1 to enable simplified emulation of PAL blending, that uses only
133    the standard 8-bit palette. */
134 extern int ANTIC_pal_blending;
135 #endif /* NO_SIMPLE_PAL_BLENDING */
136 
137 #endif /* ANTIC_H_ */
138