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

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.  */
1.1.1.10! root      125: #define MAX_PIXELS_PER_LINE 1760
        !           126: 
        !           127: /* ((MAX_PIXELS_PER_LINE/2)/2 since sprites are always lores.  */
        !           128: #define MAX_SPR_PIXELS (((MAXVPOS + 1)*2 + 1) * (MAX_PIXELS_PER_LINE / 4))
1.1.1.9   root      129: 
                    130: struct sprite_entry
                    131: {
                    132:     unsigned short pos;
                    133:     unsigned short max;
                    134:     unsigned int first_pixel;
                    135:     unsigned int has_attached;
1.1       root      136: };
                    137: 
1.1.1.9   root      138: union sps_union {
                    139:     uae_u8 bytes[2 * MAX_SPR_PIXELS];
                    140:     uae_u32 words[2 * MAX_SPR_PIXELS / 4];
1.1       root      141: };
1.1.1.9   root      142: extern union sps_union spixstate;
                    143: extern uae_u16 spixels[MAX_SPR_PIXELS * 2];
1.1       root      144: 
                    145: /* Way too much... */
1.1.1.4   root      146: #define MAX_REG_CHANGE ((MAXVPOS + 1) * 2 * MAXHPOS)
1.1       root      147: 
                    148: #ifdef OS_WITHOUT_MEMORY_MANAGEMENT
                    149: extern struct color_change *color_changes[2];
                    150: #else
                    151: extern struct color_change color_changes[2][MAX_REG_CHANGE];
                    152: #endif
                    153: 
1.1.1.4   root      154: extern struct color_entry color_tables[2][(MAXVPOS+1) * 2];
1.1       root      155: extern struct color_entry *curr_color_tables, *prev_color_tables;
                    156: 
1.1.1.9   root      157: extern struct sprite_entry *curr_sprite_entries, *prev_sprite_entries;
1.1       root      158: extern struct color_change *curr_color_changes, *prev_color_changes;
                    159: extern struct draw_info *curr_drawinfo, *prev_drawinfo;
                    160: 
                    161: /* struct decision contains things we save across drawing frames for
                    162:  * comparison (smart update stuff). */
                    163: struct decision {
1.1.1.7   root      164:     /* Records the leftmost access of BPL1DAT.  */
1.1.1.9   root      165:     int plfleft, plfright, plflinelen;
1.1       root      166:     /* Display window: native coordinates, depend on lores state.  */
                    167:     int diwfirstword, diwlastword;
                    168:     int ctable;
                    169: 
1.1.1.9   root      170:     uae_u16 bplcon0, bplcon2;
1.1.1.10! root      171:     uae_u16 bplcon3, bplcon4;
1.1.1.9   root      172:     uae_u8 nr_planes;
                    173:     uae_u8 bplres;
1.1       root      174: };
                    175: 
                    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 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.