Annotation of uae/src/include/drawing.h, revision 1.1.1.8

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       root       23: /* We ignore that many lores pixels at the start of the display. These are
                     24:  * invisible anyway due to hardware DDF limits. */
                     25: #define DISPLAY_LEFT_SHIFT 0x38
                     26: #define PIXEL_XPOS(HPOS) (((HPOS)*2 - DISPLAY_LEFT_SHIFT) << lores_shift)
                     27: 
                     28: /* @@@ Is maxhpos + 4 - 1 correct? (4 less isn't enough) */
1.1.1.6   root       29: #define max_diwlastword (PIXEL_XPOS(maxhpos + 4 - 1))
1.1       root       30: 
                     31: extern int lores_factor, lores_shift, sprite_width;
                     32: 
1.1.1.7   root       33: STATIC_INLINE int coord_hw_to_window_x (int x)
1.1       root       34: {
                     35:     x -= DISPLAY_LEFT_SHIFT;
                     36:     return x << lores_shift;
                     37: }
                     38: 
                     39: extern int framecnt;
                     40: 
1.1.1.8 ! root       41: 
        !            42: /* color values in two formats: 12 (OCS/ECS) or 24 (AGA) bit Amiga RGB (color_regs),
        !            43:  * and the native color value; both for each Amiga hardware color register. 
        !            44:  *
        !            45:  * !!! See color_reg_xxx functions below before touching !!!
        !            46:  */
1.1       root       47: struct color_entry {
1.1.1.8 ! root       48:     uae_u16 color_regs_ecs[32];
        !            49:     xcolnr acolors[256];
        !            50:     uae_u32 color_regs_aga[256];
1.1       root       51: };
                     52: 
1.1.1.8 ! root       53: /* convert 24 bit AGA Amiga RGB to native color */
        !            54: /* warning: ugly and works with little-endian cpu's only */
        !            55: #define CONVERT_RGB(c) \
        !            56:     ( xbluecolors[((uae_u8*)(&c))[0]] | xgreencolors[((uae_u8*)(&c))[1]] | xredcolors[((uae_u8*)(&c))[2]] )
        !            57: 
        !            58: STATIC_INLINE xcolnr getxcolor (int c)
        !            59: {
        !            60:     if (currprefs.chipset_mask & CSMASK_AGA)
        !            61:        return CONVERT_RGB(c);
        !            62:     else
        !            63:        return xcolors[c];
        !            64: }
        !            65: 
        !            66: /* functions for reading, writing, copying and comparing struct color_entry */
        !            67: STATIC_INLINE int color_reg_get (struct color_entry *ce, int c)
        !            68: {
        !            69:     if (currprefs.chipset_mask & CSMASK_AGA)
        !            70:        return ce->color_regs_aga[c];
        !            71:     else
        !            72:        return ce->color_regs_ecs[c];
        !            73: }
        !            74: STATIC_INLINE void color_reg_set (struct color_entry *ce, int c, int v)
        !            75: {
        !            76:     if (currprefs.chipset_mask & CSMASK_AGA)
        !            77:        ce->color_regs_aga[c] = v;
        !            78:     else
        !            79:        ce->color_regs_ecs[c] = v;
        !            80: }
        !            81: STATIC_INLINE int color_reg_cmp (struct color_entry *ce1, struct color_entry *ce2)
        !            82: {
        !            83:     if (currprefs.chipset_mask & CSMASK_AGA)
        !            84:        return memcmp (ce1->color_regs_aga, ce2->color_regs_aga, sizeof (uae_u32) * 256);
        !            85:     else
        !            86:        return memcmp (ce1->color_regs_ecs, ce2->color_regs_ecs, sizeof (uae_u16) * 32);    
        !            87: }
        !            88: /* ugly copy hack, is there better solution? */
        !            89: STATIC_INLINE void color_reg_cpy (struct color_entry *dst, struct color_entry *src)
        !            90: {
        !            91:     if (currprefs.chipset_mask & CSMASK_AGA) {
        !            92:        /* copy acolors and color_regs_aga */
        !            93:        memcpy (dst->acolors, src->acolors, sizeof(struct color_entry) - sizeof(uae_u16) * 32);
        !            94:     } else {
        !            95:        /* copy first 32 acolors and color_regs_ecs */
        !            96:        memcpy (dst->color_regs_ecs, src->color_regs_ecs,
        !            97:                sizeof(struct color_entry) - sizeof(uae_u32) * 256 - sizeof(xcolnr) * (256-32));
        !            98:     }
        !            99: }
        !           100: 
1.1       root      101: /*
                    102:  * The idea behind this code is that at some point during each horizontal
                    103:  * line, we decide how to draw this line. There are many more-or-less
                    104:  * independent decisions, each of which can be taken at a different horizontal
                    105:  * position.
                    106:  * Sprites, color changes and bitplane delay changes are handled specially:
                    107:  * There isn't a single decision, but a list of structures containing
                    108:  * information on how to draw the line.
                    109:  */
                    110: 
                    111: struct color_change {
                    112:     int linepos;
                    113:     int regno;
                    114:     unsigned long value;
                    115: };
                    116: 
                    117: struct sprite_draw {
                    118:     int linepos;
                    119:     int num;
                    120:     int ctl;
                    121:     uae_u32 datab;
                    122: };
                    123: 
                    124: struct delay_change {
                    125:     int linepos;
                    126:     unsigned int value;
                    127: };
                    128: 
                    129: /* Way too much... */
1.1.1.4   root      130: #define MAX_REG_CHANGE ((MAXVPOS + 1) * 2 * MAXHPOS)
1.1       root      131: 
                    132: #ifdef OS_WITHOUT_MEMORY_MANAGEMENT
                    133: extern struct sprite_draw  *sprite_positions[2];
                    134: extern struct color_change *color_changes[2];
                    135: extern struct delay_change *delay_changes;
                    136: #else
                    137: extern struct sprite_draw sprite_positions[2][MAX_REG_CHANGE];
                    138: extern struct color_change color_changes[2][MAX_REG_CHANGE];
                    139: /* We don't remember those across frames, that would be too much effort.
                    140:  * We simply redraw the line whenever we see one of these. */
                    141: extern struct delay_change delay_changes[MAX_REG_CHANGE];
                    142: #endif
                    143: 
1.1.1.4   root      144: extern struct color_entry color_tables[2][(MAXVPOS+1) * 2];
1.1       root      145: extern struct color_entry *curr_color_tables, *prev_color_tables;
                    146: 
                    147: extern struct sprite_draw *curr_sprite_positions, *prev_sprite_positions;
                    148: extern struct color_change *curr_color_changes, *prev_color_changes;
                    149: extern struct draw_info *curr_drawinfo, *prev_drawinfo;
                    150: 
                    151: /* struct decision contains things we save across drawing frames for
                    152:  * comparison (smart update stuff). */
                    153: struct decision {
                    154:     unsigned long color0;
                    155:     int which;
1.1.1.7   root      156: 
                    157:     /* Data fetching coordinates.  */
1.1       root      158:     int plfstrt, plflinelen;
1.1.1.7   root      159:     /* Records the leftmost access of BPL1DAT.  */
                    160:     int plfleft;
1.1       root      161:     /* Display window: native coordinates, depend on lores state.  */
                    162:     int diwfirstword, diwlastword;
                    163:     int ctable;
                    164: 
                    165:     uae_u16 bplcon0, bplcon1, bplcon2;
1.1.1.8 ! root      166:     uae_u16 fmode, bplcon4;
1.1       root      167: };
                    168: 
1.1.1.8 ! root      169: extern int fetchmode, prefetch, fetchsize, fetchstart, fetchstart_shift;
        !           170: extern void expand_fetchmodes (int, int);
        !           171: 
1.1.1.3   root      172: /* Compute the number of bitplanes from a value written to BPLCON0  */
                    173: #define GET_PLANES(x) ((((x) >> 12) & 7) | (((x) & 0x10) >> 1))
                    174: 
1.1       root      175: /* Anything related to changes in hw registers during the DDF for one
                    176:  * line. */
                    177: struct draw_info {
                    178:     int first_sprite_draw, last_sprite_draw;
                    179:     int first_color_change, last_color_change;
                    180:     int first_delay_change, last_delay_change;
                    181:     int nr_color_changes, nr_sprites;
                    182: };
                    183: 
1.1.1.4   root      184: extern struct decision line_decisions[2 * (MAXVPOS+1) + 1];
                    185: extern struct draw_info line_drawinfo[2][2 * (MAXVPOS+1) + 1];
1.1       root      186: 
1.1.1.4   root      187: extern uae_u8 line_data[(MAXVPOS+1) * 2][MAX_PLANES * MAX_WORDS_PER_LINE * 2];
1.1       root      188: 
1.1.1.7   root      189: extern uae_u8 *real_bplpt[8];
                    190: 
1.1       root      191: /* Functions in drawing.c.  */
                    192: extern int coord_native_to_amiga_y (int);
                    193: extern int coord_native_to_amiga_x (int);
                    194: 
                    195: extern void record_diw_line (int first, int last);
                    196: extern void hardware_line_completed (int lineno);
                    197: 
                    198: /* Determine how to draw a scan line.  */
                    199: enum nln_how {
                    200:     /* All lines on a non-doubled display. */
                    201:     nln_normal,
                    202:     /* Non-interlace, doubled display.  */
                    203:     nln_doubled,
                    204:     /* Interlace, doubled display, upper line.  */
                    205:     nln_upper,
                    206:     /* Interlace, doubled display, lower line.  */
1.1.1.2   root      207:     nln_lower,
                    208:     /* This line normal, next one black.  */
                    209:     nln_nblack
1.1       root      210: };
                    211: 
1.1.1.2   root      212: extern void hsync_record_line_state (int lineno, enum nln_how, int changed);
1.1       root      213: extern void vsync_handle_redraw (int long_frame, int lof_changed);
                    214: extern void init_hardware_for_drawing_frame (void);
                    215: extern void finish_drawing_frame (void);
                    216: extern void reset_drawing (void);
                    217: extern void drawing_init (void);
                    218: extern void notice_interlace_seen (void);
                    219: 
                    220: /* Finally, stuff that shouldn't really be shared.  */
                    221: 
                    222: extern int thisframe_first_drawn_line, thisframe_last_drawn_line;
                    223: extern uae_u16 clxdat, clxcon;
                    224: extern int clx_sprmask;
                    225: extern int diwfirstword,diwlastword;
1.1.1.3   root      226: 
                    227: #define IHF_SCROLLLOCK 0
                    228: #define IHF_QUIT_PROGRAM 1
                    229: #define IHF_PICASSO 2
                    230: #define IHF_SOUNDADJUST 3
                    231: 
                    232: extern int inhibit_frame;
                    233: 
1.1.1.5   root      234: STATIC_INLINE void set_inhibit_frame (int bit)
1.1.1.3   root      235: {
                    236:     inhibit_frame |= 1 << bit;
                    237: }
1.1.1.5   root      238: STATIC_INLINE void clear_inhibit_frame (int bit)
1.1.1.3   root      239: {
                    240:     inhibit_frame &= ~(1 << bit);
                    241: }
1.1.1.5   root      242: STATIC_INLINE void toggle_inhibit_frame (int bit)
1.1.1.3   root      243: {
1.1.1.8 ! root      244:     inhibit_frame ^= 1 << bit;
1.1.1.3   root      245: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.