Annotation of Gnu-Mach/chips/bt431.c, revision 1.1

1.1     ! root        1: /* 
        !             2:  * Mach Operating System
        !             3:  * Copyright (c) 1991,1990,1989 Carnegie Mellon University
        !             4:  * All Rights Reserved.
        !             5:  * 
        !             6:  * Permission to use, copy, modify and distribute this software and its
        !             7:  * documentation is hereby granted, provided that both the copyright
        !             8:  * notice and this permission notice appear in all copies of the
        !             9:  * software, derivative works or modified versions, and any portions
        !            10:  * thereof, and that both notices appear in supporting documentation.
        !            11:  * 
        !            12:  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
        !            13:  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
        !            14:  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
        !            15:  * 
        !            16:  * Carnegie Mellon requests users of this software to return to
        !            17:  * 
        !            18:  *  Software Distribution Coordinator  or  [email protected]
        !            19:  *  School of Computer Science
        !            20:  *  Carnegie Mellon University
        !            21:  *  Pittsburgh PA 15213-3890
        !            22:  * 
        !            23:  * any improvements or extensions that they make and grant Carnegie Mellon
        !            24:  * the rights to redistribute these changes.
        !            25:  */
        !            26: /*
        !            27:  *     File: bt431.c
        !            28:  *     Author: Alessandro Forin, Carnegie Mellon University
        !            29:  *     Date:   8/91
        !            30:  *
        !            31:  *     Routines for the bt431 Cursor
        !            32:  */
        !            33: 
        !            34: #include <platforms.h>
        !            35: 
        !            36: #include <chips/bt431.h>
        !            37: #include <chips/screen.h>
        !            38: 
        !            39: #ifdef DECSTATION
        !            40: /*
        !            41:  * This configuration uses two twin 431s
        !            42:  */
        !            43: #define        set_value(x)    (((x)<<8)|((x)&0xff))
        !            44: #define        get_value(x)    ((x)&0xff)
        !            45: 
        !            46: typedef struct {
        !            47:        volatile unsigned short addr_lo;
        !            48:        short                           pad0;
        !            49:        volatile unsigned short addr_hi;
        !            50:        short                           pad1;
        !            51:        volatile unsigned short addr_cmap;
        !            52:        short                           pad2;
        !            53:        volatile unsigned short addr_reg;
        !            54:        short                           pad3;
        !            55: } bt431_padded_regmap_t;
        !            56: 
        !            57: #else  /*DECSTATION*/
        !            58: 
        !            59: #define set_value(x)   x
        !            60: #define get_value(x)   x
        !            61: typedef bt431_regmap_t bt431_padded_regmap_t;
        !            62: #define        wbflush()
        !            63: 
        !            64: #endif /*DECSTATION*/
        !            65: 
        !            66: /*
        !            67:  * Generic register access
        !            68:  */
        !            69: void
        !            70: bt431_select_reg( regs, regno)
        !            71:        bt431_padded_regmap_t   *regs;
        !            72: {
        !            73:        regs->addr_lo = set_value(regno&0xff);
        !            74:        regs->addr_hi = set_value((regno >> 8) & 0xff);
        !            75:        wbflush();
        !            76: }
        !            77: 
        !            78: void 
        !            79: bt431_write_reg( regs, regno, val)
        !            80:        bt431_padded_regmap_t   *regs;
        !            81: {
        !            82:        bt431_select_reg( regs, regno );
        !            83:        regs->addr_reg = set_value(val);
        !            84:        wbflush();
        !            85: }
        !            86: 
        !            87: unsigned char
        !            88: bt431_read_reg( regs, regno)
        !            89:        bt431_padded_regmap_t   *regs;
        !            90: {
        !            91:        bt431_select_reg( regs, regno );
        !            92:        return get_value(regs->addr_reg);
        !            93: }
        !            94: 
        !            95: /* when using autoincrement */
        !            96: #define        bt431_write_reg_autoi( regs, regno, val)        \
        !            97:        {                                               \
        !            98:                (regs)->addr_reg = set_value(val);      \
        !            99:                wbflush();                              \
        !           100:        }
        !           101: #define        bt431_read_reg_autoi( regs, regno)              \
        !           102:                get_value(((regs)->addr_reg))
        !           103: 
        !           104: #define        bt431_write_cmap_autoi( regs, regno, val)       \
        !           105:        {                                               \
        !           106:                (regs)->addr_cmap = (val);              \
        !           107:                wbflush();                              \
        !           108:        }
        !           109: #define        bt431_read_cmap_autoi( regs, regno)             \
        !           110:                ((regs)->addr_cmap)
        !           111: 
        !           112: 
        !           113: /*
        !           114:  * Cursor ops
        !           115:  */
        !           116: bt431_cursor_on(regs)
        !           117:        bt431_padded_regmap_t   *regs;
        !           118: {
        !           119:        bt431_write_reg( regs, BT431_REG_CMD,
        !           120:                         BT431_CMD_CURS_ENABLE|BT431_CMD_OR_CURSORS|
        !           121:                         BT431_CMD_4_1_MUX|BT431_CMD_THICK_1);
        !           122: }
        !           123: 
        !           124: bt431_cursor_off(regs)
        !           125:        bt431_padded_regmap_t   *regs;
        !           126: {
        !           127:        bt431_write_reg( regs, BT431_REG_CMD, BT431_CMD_4_1_MUX);
        !           128: }
        !           129: 
        !           130: bt431_pos_cursor(regs,x,y)
        !           131:        bt431_padded_regmap_t   *regs;
        !           132:        register int    x,y;
        !           133: {
        !           134: #define lo(v)  ((v)&0xff)
        !           135: #define hi(v)  (((v)&0xf00)>>8)
        !           136: 
        !           137:        /*
        !           138:         * Cx = x + D + H - P
        !           139:         *  P = 37 if 1:1, 52 if 4:1, 57 if 5:1
        !           140:         *  D = pixel skew between outdata and external data
        !           141:         *  H = pixels between HSYNCH falling and active video
        !           142:         *
        !           143:         * Cy = y + V - 32
        !           144:         *  V = scanlines between HSYNCH falling, two or more
        !           145:         *      clocks after VSYNCH falling, and active video
        !           146:         */
        !           147: 
        !           148:        bt431_write_reg( regs, BT431_REG_CXLO, lo(x + 360));
        !           149:        /* use autoincr feature */
        !           150:        bt431_write_reg_autoi( regs, BT431_REG_CXHI, hi(x + 360));
        !           151:        bt431_write_reg_autoi( regs, BT431_REG_CYLO, lo(y + 36));
        !           152:        bt431_write_reg_autoi( regs, BT431_REG_CYHI, hi(y + 36));
        !           153: }
        !           154: 
        !           155: 
        !           156: bt431_cursor_sprite( regs, cursor)
        !           157:        bt431_padded_regmap_t   *regs;
        !           158:        register unsigned short *cursor;
        !           159: {
        !           160:        register int    i;
        !           161: 
        !           162:        bt431_select_reg( regs, BT431_REG_CRAM_BASE+0);
        !           163:        for (i = 0; i < 512; i++)
        !           164:                bt431_write_cmap_autoi( regs, BT431_REG_CRAM_BASE+i, *cursor++);
        !           165: }
        !           166: 
        !           167: #if 1
        !           168: bt431_print_cursor(regs)
        !           169:        bt431_padded_regmap_t   *regs;
        !           170: {
        !           171:        unsigned short curs[512];
        !           172:        register int i;
        !           173: 
        !           174:        bt431_select_reg( regs, BT431_REG_CRAM_BASE+0);
        !           175:        for (i = 0; i < 512; i++) {
        !           176:                curs[i] = bt431_read_cmap_autoi( regs, BT431_REG_CRAM_BASE+i);
        !           177:        }
        !           178:        for (i = 0; i < 512; i += 16)
        !           179:                printf("%x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x\n",
        !           180:                        curs[i], curs[i+1], curs[i+2], curs[i+3],
        !           181:                        curs[i+4], curs[i+5], curs[i+6], curs[i+7],
        !           182:                        curs[i+8], curs[i+9], curs[i+10], curs[i+11],
        !           183:                        curs[i+12], curs[i+13], curs[i+14], curs[i+15]);
        !           184: }
        !           185: 
        !           186: #endif
        !           187: 
        !           188: /*
        !           189:  * Initialization
        !           190:  */
        !           191: unsigned /*char*/short bt431_default_cursor[64*8] = {
        !           192:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           193:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           194:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           195:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           196:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           197:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           198:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           199:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           200:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           201:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           202:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           203:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           204:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           205:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           206:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           207:        0xffff, 0, 0, 0, 0, 0, 0, 0,
        !           208:        0,
        !           209: };
        !           210: 
        !           211: bt431_init(regs)
        !           212:        bt431_padded_regmap_t   *regs;
        !           213: {
        !           214:        register int    i;
        !           215: 
        !           216:        /* use 4:1 input mux */
        !           217:        bt431_write_reg( regs, BT431_REG_CMD,
        !           218:                         BT431_CMD_CURS_ENABLE|BT431_CMD_OR_CURSORS|
        !           219:                         BT431_CMD_4_1_MUX|BT431_CMD_THICK_1);
        !           220: 
        !           221:        /* home cursor */
        !           222:        bt431_write_reg_autoi( regs, BT431_REG_CXLO, 0x00);
        !           223:        bt431_write_reg_autoi( regs, BT431_REG_CXHI, 0x00);
        !           224:        bt431_write_reg_autoi( regs, BT431_REG_CYLO, 0x00);
        !           225:        bt431_write_reg_autoi( regs, BT431_REG_CYHI, 0x00);
        !           226: 
        !           227:        /* no crosshair window */
        !           228:        bt431_write_reg_autoi( regs, BT431_REG_WXLO, 0x00);
        !           229:        bt431_write_reg_autoi( regs, BT431_REG_WXHI, 0x00);
        !           230:        bt431_write_reg_autoi( regs, BT431_REG_WYLO, 0x00);
        !           231:        bt431_write_reg_autoi( regs, BT431_REG_WYHI, 0x00);
        !           232:        bt431_write_reg_autoi( regs, BT431_REG_WWLO, 0x00);
        !           233:        bt431_write_reg_autoi( regs, BT431_REG_WWHI, 0x00);
        !           234:        bt431_write_reg_autoi( regs, BT431_REG_WHLO, 0x00);
        !           235:        bt431_write_reg_autoi( regs, BT431_REG_WHHI, 0x00);
        !           236: 
        !           237:        /* load default cursor */
        !           238:        bt431_cursor_sprite( regs, bt431_default_cursor);
        !           239: }

unix.superglobalmegacorp.com

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