2 #include "../port/lib.h"
7 #include "../port/error.h"
15 typedef struct Cursor3dfx Cursor3dfx;
32 tdfxenable(VGAscr* scr)
40 if(p == nil || p->vid != 0x121A)
42 scr->mmio = vmap(p->mem[0].bar&~0x0F, p->mem[0].size);
46 addvgaseg("3dfxmmio", p->mem[0].bar&~0x0F, p->mem[0].size);
49 addvgaseg("3dfxscreen", scr->paddr, scr->apsize);
52 * Find a place for the cursor data in display memory.
53 * If SDRAM then there's 16MB memory else it's SGRAM
54 * and can count it based on the power-on straps -
55 * chip size can be 8Mb or 16Mb, and there can be 4 or
57 * Use the last 1KB of the framebuffer.
59 mmio = (void*)((uchar*)scr->mmio+dramInit0);
60 if(*(mmio+1) & 0x40000000)
63 if(*mmio & 0x08000000)
67 if(*mmio & 0x04000000)
72 scr->storage = i - 1024;
76 tdfxcurdisable(VGAscr* scr)
78 Cursor3dfx *cursor3dfx;
82 cursor3dfx = (void*)((uchar*)scr->mmio+hwCur);
83 cursor3dfx->vidProcCfg &= ~0x08000000;
87 tdfxcurload(VGAscr* scr, Cursor* curs)
91 Cursor3dfx *cursor3dfx;
95 cursor3dfx = (void*)((uchar*)scr->mmio+hwCur);
98 * Disable the cursor then load the new image in
99 * the top-left of the 64x64 array.
100 * The cursor data is stored in memory as 128-bit
101 * words consisting of plane 0 in the least significant 64-bits
102 * and plane 1 in the most significant.
103 * The X11 cursor truth table is:
109 * Unused portions of the image have been initialised to be
112 cursor3dfx->vidProcCfg &= ~0x08000000;
113 p = (uchar*)scr->vaddr + scr->storage;
114 for(y = 0; y < 16; y++){
115 *p++ = curs->clr[2*y]|curs->set[2*y];
116 *p++ = curs->clr[2*y+1]|curs->set[2*y+1];
118 *p++ = curs->set[2*y];
119 *p++ = curs->set[2*y+1];
124 * Save the cursor hotpoint and enable the cursor.
125 * The 0,0 cursor point is bottom-right.
127 scr->offset.x = 63+curs->offset.x;
128 scr->offset.y = 63+curs->offset.y;
129 cursor3dfx->vidProcCfg |= 0x08000000;
133 tdfxcurmove(VGAscr* scr, Point p)
135 Cursor3dfx *cursor3dfx;
139 cursor3dfx = (void*)((uchar*)scr->mmio+hwCur);
141 cursor3dfx->hwCurLoc = ((p.y+scr->offset.y)<<16)|(p.x+scr->offset.x);
147 tdfxcurenable(VGAscr* scr)
149 Cursor3dfx *cursor3dfx;
154 cursor3dfx = (void*)((uchar*)scr->mmio+hwCur);
159 cursor3dfx->hwCurC0 = 0xFFFFFFFF;
160 cursor3dfx->hwCurC1 = 0x00000000;
163 * Initialise the 64x64 cursor to be transparent (X11 mode).
165 cursor3dfx->hwCurPatAddr = scr->storage;
166 memset((uchar*)scr->vaddr + scr->storage, 0, 64*16);
169 * Load, locate and enable the 64x64 cursor in X11 mode.
171 tdfxcurload(scr, &arrow);
172 tdfxcurmove(scr, ZP);
173 cursor3dfx->vidProcCfg |= 0x08000002;
176 VGAdev vga3dfxdev = {
185 VGAcur vga3dfxcur = {