|
|
1.1 root 1: /*
2: * Data used for communication between custom.c and drawing.c.
3: *
4: * Copyright 1996-1998 Bernd Schmidt
5: */
6:
7: #define SMART_UPDATE 1
8:
9: #ifdef SUPPORT_PENGUINS
10: #undef SMART_UPDATE
11: #define SMART_UPDATE 1
12: #endif
13:
14: #define MAX_PLANES 8
15:
1.1.1.4 root 16: #define RES_LORES 0
17: #define RES_HIRES 1
18: #define RES_SUPERHIRES 2
19:
20: /* calculate shift depending on resolution (replaced "decided_hires ? 4 : 8") (TW) */
21: #define RES_SHIFT(res) ((res) == RES_LORES ? 8 : (res) == RES_HIRES ? 4 : 2)
22:
1.1.1.9 ! root 23: /* According to the HRM, pixel data spends a couple of cycles somewhere in the chips
! 24: before it appears on-screen. */
! 25: #define DIW_DDF_OFFSET 9
! 26:
1.1 root 27: /* We ignore that many lores pixels at the start of the display. These are
28: * invisible anyway due to hardware DDF limits. */
29: #define DISPLAY_LEFT_SHIFT 0x38
1.1.1.9 ! root 30: #define PIXEL_XPOS(HPOS) (((HPOS)*2 - DISPLAY_LEFT_SHIFT + DIW_DDF_OFFSET - 1) << lores_shift)
1.1 root 31:
1.1.1.9 ! root 32: #define max_diwlastword (PIXEL_XPOS(maxhpos))
1.1 root 33:
34: extern int lores_factor, lores_shift, sprite_width;
35:
1.1.1.7 root 36: STATIC_INLINE int coord_hw_to_window_x (int x)
1.1 root 37: {
38: x -= DISPLAY_LEFT_SHIFT;
39: return x << lores_shift;
40: }
41:
1.1.1.9 ! root 42: STATIC_INLINE int coord_diw_to_window_x (int x)
! 43: {
! 44: return (x - DISPLAY_LEFT_SHIFT + DIW_DDF_OFFSET - 1) << lores_shift;
! 45: }
! 46:
1.1 root 47: extern int framecnt;
48:
1.1.1.8 root 49:
50: /* color values in two formats: 12 (OCS/ECS) or 24 (AGA) bit Amiga RGB (color_regs),
51: * and the native color value; both for each Amiga hardware color register.
52: *
53: * !!! See color_reg_xxx functions below before touching !!!
54: */
1.1 root 55: struct color_entry {
1.1.1.8 root 56: uae_u16 color_regs_ecs[32];
57: xcolnr acolors[256];
58: uae_u32 color_regs_aga[256];
1.1 root 59: };
60:
1.1.1.8 root 61: /* convert 24 bit AGA Amiga RGB to native color */
62: /* warning: ugly and works with little-endian cpu's only */
63: #define CONVERT_RGB(c) \
64: ( xbluecolors[((uae_u8*)(&c))[0]] | xgreencolors[((uae_u8*)(&c))[1]] | xredcolors[((uae_u8*)(&c))[2]] )
65:
66: STATIC_INLINE xcolnr getxcolor (int c)
67: {
68: if (currprefs.chipset_mask & CSMASK_AGA)
69: return CONVERT_RGB(c);
70: else
71: return xcolors[c];
72: }
73:
74: /* functions for reading, writing, copying and comparing struct color_entry */
75: STATIC_INLINE int color_reg_get (struct color_entry *ce, int c)
76: {
77: if (currprefs.chipset_mask & CSMASK_AGA)
78: return ce->color_regs_aga[c];
79: else
80: return ce->color_regs_ecs[c];
81: }
82: STATIC_INLINE void color_reg_set (struct color_entry *ce, int c, int v)
83: {
84: if (currprefs.chipset_mask & CSMASK_AGA)
85: ce->color_regs_aga[c] = v;
86: else
87: ce->color_regs_ecs[c] = v;
88: }
89: STATIC_INLINE int color_reg_cmp (struct color_entry *ce1, struct color_entry *ce2)
90: {
91: if (currprefs.chipset_mask & CSMASK_AGA)
92: return memcmp (ce1->color_regs_aga, ce2->color_regs_aga, sizeof (uae_u32) * 256);
93: else
94: return memcmp (ce1->color_regs_ecs, ce2->color_regs_ecs, sizeof (uae_u16) * 32);
95: }
96: /* ugly copy hack, is there better solution? */
97: STATIC_INLINE void color_reg_cpy (struct color_entry *dst, struct color_entry *src)
98: {
99: if (currprefs.chipset_mask & CSMASK_AGA) {
100: /* copy acolors and color_regs_aga */
101: memcpy (dst->acolors, src->acolors, sizeof(struct color_entry) - sizeof(uae_u16) * 32);
102: } else {
103: /* copy first 32 acolors and color_regs_ecs */
104: memcpy (dst->color_regs_ecs, src->color_regs_ecs,
105: sizeof(struct color_entry) - sizeof(uae_u32) * 256 - sizeof(xcolnr) * (256-32));
106: }
107: }
108:
1.1 root 109: /*
110: * The idea behind this code is that at some point during each horizontal
111: * line, we decide how to draw this line. There are many more-or-less
112: * independent decisions, each of which can be taken at a different horizontal
113: * position.
1.1.1.9 ! root 114: * Sprites and color changes are handled specially: There isn't a single decision,
! 115: * but a list of structures containing information on how to draw the line.
1.1 root 116: */
117:
118: struct color_change {
119: int linepos;
120: int regno;
121: unsigned long value;
122: };
123:
1.1.1.9 ! root 124: /* 440 rather than 880, since sprites are always lores. */
! 125: #define MAX_SPR_PIXELS (((MAXVPOS + 1)*2 + 1) * 440)
! 126:
! 127: struct sprite_entry
! 128: {
! 129: unsigned short pos;
! 130: unsigned short max;
! 131: unsigned int first_pixel;
! 132: unsigned int has_attached;
1.1 root 133: };
134:
1.1.1.9 ! root 135: union sps_union {
! 136: uae_u8 bytes[2 * MAX_SPR_PIXELS];
! 137: uae_u32 words[2 * MAX_SPR_PIXELS / 4];
1.1 root 138: };
1.1.1.9 ! root 139: extern union sps_union spixstate;
! 140: extern uae_u16 spixels[MAX_SPR_PIXELS * 2];
1.1 root 141:
142: /* Way too much... */
1.1.1.4 root 143: #define MAX_REG_CHANGE ((MAXVPOS + 1) * 2 * MAXHPOS)
1.1 root 144:
145: #ifdef OS_WITHOUT_MEMORY_MANAGEMENT
146: extern struct color_change *color_changes[2];
147: #else
148: extern struct color_change color_changes[2][MAX_REG_CHANGE];
149: #endif
150:
1.1.1.4 root 151: extern struct color_entry color_tables[2][(MAXVPOS+1) * 2];
1.1 root 152: extern struct color_entry *curr_color_tables, *prev_color_tables;
153:
1.1.1.9 ! root 154: extern struct sprite_entry *curr_sprite_entries, *prev_sprite_entries;
1.1 root 155: extern struct color_change *curr_color_changes, *prev_color_changes;
156: extern struct draw_info *curr_drawinfo, *prev_drawinfo;
157:
158: /* struct decision contains things we save across drawing frames for
159: * comparison (smart update stuff). */
160: struct decision {
1.1.1.7 root 161: /* Records the leftmost access of BPL1DAT. */
1.1.1.9 ! root 162: int plfleft, plfright, plflinelen;
1.1 root 163: /* Display window: native coordinates, depend on lores state. */
164: int diwfirstword, diwlastword;
165: int ctable;
166:
1.1.1.9 ! root 167: uae_u16 bplcon0, bplcon2;
1.1.1.8 root 168: uae_u16 fmode, bplcon4;
1.1.1.9 ! root 169: uae_u8 nr_planes;
! 170: uae_u8 bplres;
1.1 root 171: };
172:
1.1.1.8 root 173: extern int fetchmode, prefetch, fetchsize, fetchstart, fetchstart_shift;
174: extern void expand_fetchmodes (int, int);
175:
1.1 root 176: /* Anything related to changes in hw registers during the DDF for one
177: * line. */
178: struct draw_info {
1.1.1.9 ! root 179: int first_sprite_entry, last_sprite_entry;
1.1 root 180: int first_color_change, last_color_change;
181: int nr_color_changes, nr_sprites;
182: };
183:
1.1.1.9 ! root 184: extern int next_sprite_entry;
! 185:
1.1.1.4 root 186: extern struct decision line_decisions[2 * (MAXVPOS+1) + 1];
187: extern struct draw_info line_drawinfo[2][2 * (MAXVPOS+1) + 1];
1.1 root 188:
1.1.1.4 root 189: extern uae_u8 line_data[(MAXVPOS+1) * 2][MAX_PLANES * MAX_WORDS_PER_LINE * 2];
1.1 root 190:
1.1.1.7 root 191: extern uae_u8 *real_bplpt[8];
192:
1.1 root 193: /* Functions in drawing.c. */
194: extern int coord_native_to_amiga_y (int);
195: extern int coord_native_to_amiga_x (int);
196:
197: extern void record_diw_line (int first, int last);
198: extern void hardware_line_completed (int lineno);
199:
200: /* Determine how to draw a scan line. */
201: enum nln_how {
202: /* All lines on a non-doubled display. */
203: nln_normal,
204: /* Non-interlace, doubled display. */
205: nln_doubled,
206: /* Interlace, doubled display, upper line. */
207: nln_upper,
208: /* Interlace, doubled display, lower line. */
1.1.1.2 root 209: nln_lower,
210: /* This line normal, next one black. */
211: nln_nblack
1.1 root 212: };
213:
1.1.1.2 root 214: extern void hsync_record_line_state (int lineno, enum nln_how, int changed);
1.1 root 215: extern void vsync_handle_redraw (int long_frame, int lof_changed);
216: extern void init_hardware_for_drawing_frame (void);
217: extern void finish_drawing_frame (void);
218: extern void reset_drawing (void);
219: extern void drawing_init (void);
220: extern void notice_interlace_seen (void);
221:
222: /* Finally, stuff that shouldn't really be shared. */
223:
224: extern int thisframe_first_drawn_line, thisframe_last_drawn_line;
225: extern uae_u16 clxdat, clxcon;
226: extern int clx_sprmask;
227: extern int diwfirstword,diwlastword;
1.1.1.3 root 228:
229: #define IHF_SCROLLLOCK 0
230: #define IHF_QUIT_PROGRAM 1
231: #define IHF_PICASSO 2
232: #define IHF_SOUNDADJUST 3
233:
234: extern int inhibit_frame;
235:
1.1.1.5 root 236: STATIC_INLINE void set_inhibit_frame (int bit)
1.1.1.3 root 237: {
238: inhibit_frame |= 1 << bit;
239: }
1.1.1.5 root 240: STATIC_INLINE void clear_inhibit_frame (int bit)
1.1.1.3 root 241: {
242: inhibit_frame &= ~(1 << bit);
243: }
1.1.1.5 root 244: STATIC_INLINE void toggle_inhibit_frame (int bit)
1.1.1.3 root 245: {
1.1.1.8 root 246: inhibit_frame ^= 1 << bit;
1.1.1.3 root 247: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.