|
8 | 8 | #include <aros/debug.h>
|
9 | 9 | #include "graphics_intern.h"
|
10 | 10 |
|
| 11 | +static void pokeCL(UWORD *ci, UWORD target, UWORD table) |
| 12 | +{ |
| 13 | + ULONG targ = (ULONG)target; |
| 14 | + if(!ci) return; |
| 15 | + targ &= 0x1fe; |
| 16 | + for(;ci;ci+=2) |
| 17 | + { |
| 18 | + if( ((*ci)==0xffff) && ((*(ci+1) == 0xfffe))) return; |
| 19 | + if(*ci == targ) break; |
| 20 | + } |
| 21 | + if (((*ci) == 0xffff) && ((*(ci+1)==0xfffe))) return; |
| 22 | + if(*ci == targ) |
| 23 | + { |
| 24 | + ci++; |
| 25 | + *ci++ = table; |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +static struct CopIns *pokeCI(struct CopIns *ci, UWORD *field1, short field2) |
| 30 | +{ |
| 31 | + struct CopIns *c; |
| 32 | + c = ci; |
| 33 | + if(c) |
| 34 | + { |
| 35 | + short out = FALSE; |
| 36 | + while(!out) |
| 37 | + { |
| 38 | + switch(c->OpCode & 3) |
| 39 | + { |
| 40 | + case COPPER_MOVE: |
| 41 | + { |
| 42 | + if(c->DESTADDR == (((UWORD)field1) & 0x1fe)) |
| 43 | + { |
| 44 | + short mask; |
| 45 | + if((mask = op&0xC000)) |
| 46 | + { |
| 47 | + if(c->OpCode & mask) |
| 48 | + { |
| 49 | + c->DESTDATA = field2; |
| 50 | + return c; |
| 51 | + } |
| 52 | + } |
| 53 | + else |
| 54 | + { |
| 55 | + c->DESTDATA = field2; |
| 56 | + return c; |
| 57 | + } |
| 58 | + } |
| 59 | + c++; |
| 60 | + break; |
| 61 | + } |
| 62 | + case COPPER_WAIT: |
| 63 | + { |
| 64 | + if(c->HWAITPOS == 255) |
| 65 | + { |
| 66 | + return 0; |
| 67 | + } |
| 68 | + else c++; |
| 69 | + break; |
| 70 | + } |
| 71 | + case CPRNXTBUF: |
| 72 | + { |
| 73 | + if(c->NXTLIST == NULL) |
| 74 | + { |
| 75 | + out = TRUE; |
| 76 | + } |
| 77 | + else |
| 78 | + { |
| 79 | + if((c = c->NXTLIST->CopIns) == NULL) |
| 80 | + { |
| 81 | + out = TRUE; |
| 82 | + } |
| 83 | + } |
| 84 | + break; |
| 85 | + } |
| 86 | + default: |
| 87 | + { |
| 88 | + out=TRUE; |
| 89 | + break; |
| 90 | + } |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | + return 0; |
| 95 | +} |
| 96 | + |
11 | 97 | /*****************************************************************************
|
12 | 98 |
|
13 | 99 | NAME */
|
|
55 | 141 | AROS_LIBFUNC_INIT
|
56 | 142 |
|
57 | 143 | WORD t;
|
| 144 | + int i; |
| 145 | + volatile struct Custom *custom = (struct Custom *)0xdff000; |
58 | 146 |
|
59 | 147 | if (!vp)
|
| 148 | + { |
| 149 | + // No ViewPort? Then alter the colors directly |
| 150 | + for (i = 0; i < count ; i++) |
| 151 | + custom->color[i] = *colors++; |
60 | 152 | return;
|
61 |
| - |
| 153 | + } |
62 | 154 | ASSERT_VALID_PTR(vp);
|
63 | 155 | ASSERT_VALID_PTR(colors);
|
64 | 156 |
|
65 | 157 | /* TODO: Optimization */
|
| 158 | + struct ColorMap *cm; |
| 159 | + UWORD *ct; |
| 160 | + |
| 161 | + // Why do we need this? Answer: For non hidd screens SetRGB32 might fail to fill the color table. This is a good place, I think |
| 162 | + if(vp->ColorMap) |
| 163 | + { |
| 164 | + cm = vp->ColorMap; |
| 165 | + ct = cm->ColorTable; |
| 166 | + if(count > cm->Count) count = cm->Count; |
| 167 | + for(i = 0; i<count; i++) |
| 168 | + { |
| 169 | + *ct++ = *colors++; |
| 170 | + } |
| 171 | + colors -= count; // back to first color |
| 172 | + } |
66 | 173 |
|
67 | 174 | for (t = 0; t < count; t ++ )
|
68 | 175 | {
|
|
79 | 186 |
|
80 | 187 | SetRGB32( vp, t, r, g, b );
|
81 | 188 | }
|
| 189 | + |
| 190 | + ObtainSemaphore(GfxBase->ActiViewCprSemaphore); |
| 191 | + for (t = 0; t < count; t ++ ) |
| 192 | + { |
| 193 | + // Remaining question: Do we need to check VP_HIDE? |
| 194 | + if(vp->DspIns) |
| 195 | + { |
| 196 | + // we need to store it into the intermediate CopperList too |
| 197 | + pokeCL(vp->DspIns->CopLStart, &custom->color[t], colors[t]); |
| 198 | + pokeCL(vp->DspIns->CopSStart, &custom->color[t], colors[t]); |
| 199 | + pokeCI(vp->DspIns->CopIns, &custom->color[t], colors[t]); |
| 200 | + } |
| 201 | + } |
| 202 | + ReleaseSemaphore(GfxBase->ActiViewCprSemaphore); |
| 203 | + |
| 204 | + // To make it visible immediately we need to update the view. To simplify it, we call MrgCop |
| 205 | + MrgCop(GfxBase->ActiView); |
82 | 206 |
|
83 | 207 | AROS_LIBFUNC_EXIT
|
84 | 208 |
|
|
0 commit comments