|
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 | + UWORD op=COPPER_MOVE; |
| 33 | + c = ci; |
| 34 | + if(c) |
| 35 | + { |
| 36 | + short out = FALSE; |
| 37 | + while(!out) |
| 38 | + { |
| 39 | + switch(c->OpCode & 3) |
| 40 | + { |
| 41 | + case COPPER_MOVE: |
| 42 | + { |
| 43 | + if(c->DESTADDR == (((UWORD)field1) & 0x1fe)) |
| 44 | + { |
| 45 | + short mask; |
| 46 | + if((mask = op&0xC000)) |
| 47 | + { |
| 48 | + if(c->OpCode & mask) |
| 49 | + { |
| 50 | + c->DESTDATA = field2; |
| 51 | + return c; |
| 52 | + } |
| 53 | + } |
| 54 | + else |
| 55 | + { |
| 56 | + c->DESTDATA = field2; |
| 57 | + return c; |
| 58 | + } |
| 59 | + } |
| 60 | + c++; |
| 61 | + break; |
| 62 | + } |
| 63 | + case COPPER_WAIT: |
| 64 | + { |
| 65 | + if(c->HWAITPOS == 255) |
| 66 | + { |
| 67 | + return 0; |
| 68 | + } |
| 69 | + else c++; |
| 70 | + break; |
| 71 | + } |
| 72 | + case CPRNXTBUF: |
| 73 | + { |
| 74 | + if(c->NXTLIST == NULL) |
| 75 | + { |
| 76 | + out = TRUE; |
| 77 | + } |
| 78 | + else |
| 79 | + { |
| 80 | + if((c = c->NXTLIST->CopIns) == NULL) |
| 81 | + { |
| 82 | + out = TRUE; |
| 83 | + } |
| 84 | + } |
| 85 | + break; |
| 86 | + } |
| 87 | + default: |
| 88 | + { |
| 89 | + out=TRUE; |
| 90 | + break; |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | + } |
| 95 | + return 0; |
| 96 | +} |
| 97 | + |
11 | 98 | /***************************************************************************** |
12 | 99 |
|
13 | 100 | NAME */ |
|
55 | 142 | AROS_LIBFUNC_INIT |
56 | 143 |
|
57 | 144 | WORD t; |
| 145 | + int i; |
| 146 | + volatile struct Custom *custom = (struct Custom *)0xdff000; |
58 | 147 |
|
59 | 148 | if (!vp) |
| 149 | + { |
| 150 | + // No ViewPort? Then alter the colors directly |
| 151 | + for (i = 0; i < count ; i++) |
| 152 | + custom->color[i] = *colors++; |
60 | 153 | return; |
61 | | - |
| 154 | + } |
62 | 155 | ASSERT_VALID_PTR(vp); |
63 | 156 | ASSERT_VALID_PTR(colors); |
64 | 157 |
|
65 | 158 | /* TODO: Optimization */ |
| 159 | + struct ColorMap *cm; |
| 160 | + UWORD *ct; |
| 161 | + |
| 162 | + // 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 |
| 163 | + if(vp->ColorMap) |
| 164 | + { |
| 165 | + cm = vp->ColorMap; |
| 166 | + ct = cm->ColorTable; |
| 167 | + if(count > cm->Count) count = cm->Count; |
| 168 | + for(i = 0; i<count; i++) |
| 169 | + { |
| 170 | + *ct++ = *colors++; |
| 171 | + } |
| 172 | + colors -= count; // back to first color |
| 173 | + } |
66 | 174 |
|
67 | 175 | for (t = 0; t < count; t ++ ) |
68 | 176 | { |
|
79 | 187 |
|
80 | 188 | SetRGB32( vp, t, r, g, b ); |
81 | 189 | } |
| 190 | + |
| 191 | + ObtainSemaphore(GfxBase->ActiViewCprSemaphore); |
| 192 | + for (t = 0; t < count; t ++ ) |
| 193 | + { |
| 194 | + // Remaining question: Do we need to check VP_HIDE? |
| 195 | + if(vp->DspIns) |
| 196 | + { |
| 197 | + // we need to store it into the intermediate CopperList too |
| 198 | + pokeCL(vp->DspIns->CopLStart, &custom->color[t], colors[t]); |
| 199 | + pokeCL(vp->DspIns->CopSStart, &custom->color[t], colors[t]); |
| 200 | + pokeCI(vp->DspIns->CopIns, &custom->color[t], colors[t]); |
| 201 | + } |
| 202 | + } |
| 203 | + ReleaseSemaphore(GfxBase->ActiViewCprSemaphore); |
| 204 | + |
| 205 | + // To make it visible immediately we need to update the view. To simplify it, we call MrgCop |
| 206 | + MrgCop(GfxBase->ActiView); |
| 207 | + if(TypeOfMem(GfxBase->ActiView->LOFCprList->start) == MEMF_CHIP) |
| 208 | + GfxBase->LOFlist = GfxBase->ActiView->LOFCprList->start; |
82 | 209 |
|
83 | 210 | AROS_LIBFUNC_EXIT |
84 | 211 |
|
|
0 commit comments