Search
lxdream.org :: lxdream/src/pvr2/tacore.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/tacore.c
changeset 736:a02d1475ccfd
prev677:3ee62740ff8f
next753:1fe39c3a9bbc
author nkeynes
date Mon Jul 14 07:44:42 2008 +0000 (13 years ago)
permissions -rw-r--r--
last change Re-indent everything consistently
Fix include guards for consistency as well
file annotate diff log raw
1.1 --- a/src/pvr2/tacore.c Thu May 29 10:50:25 2008 +0000
1.2 +++ b/src/pvr2/tacore.c Mon Jul 14 07:44:42 2008 +0000
1.3 @@ -141,8 +141,8 @@
1.4 int32_t current_vertex_type;
1.5 uint32_t accept_vertexes; /* 0 = NO, 1 = YES */
1.6 int32_t vertex_count; /* index of last start-vertex seen, or -1 if no vertexes
1.7 - * are present
1.8 - */
1.9 + * are present
1.10 + */
1.11 uint32_t max_vertex; /* Maximum number of vertexes in the current polygon (3/4/6/8) */
1.12 uint32_t current_list_type;
1.13 uint32_t current_tile_matrix; /* Memory location of the first tile for the current list. */
1.14 @@ -189,7 +189,7 @@
1.15 int pvr2_ta_load_state( FILE *f )
1.16 {
1.17 if( fread( &ta_status, sizeof(ta_status), 1, f ) != 1 )
1.18 - return 1;
1.19 + return 1;
1.20 return 0;
1.21 }
1.22
1.23 @@ -220,7 +220,7 @@
1.24 MMIO_WRITE( PVR2, TA_POLYPOS, MMIO_READ( PVR2, TA_POLYBASE ) );
1.25 uint32_t plistpos = MMIO_READ( PVR2, TA_LISTBASE ) >> 2;
1.26 if( ta_status.tilelist_dir == TA_GROW_DOWN ) {
1.27 - plistpos -= ta_status.tilelist_size;
1.28 + plistpos -= ta_status.tilelist_size;
1.29 }
1.30 MMIO_WRITE( PVR2, TA_LISTPOS, plistpos );
1.31 ta_status.tilelist_start = plistpos;
1.32 @@ -231,28 +231,28 @@
1.33 int ai,ri,gi,bi;
1.34
1.35 if( TA_IS_INF(a) ) {
1.36 - ai = 255;
1.37 + ai = 255;
1.38 } else {
1.39 - ai = 256 * CLAMP(a,0.0,1.0) - 1;
1.40 - if( ai < 0 ) ai = 0;
1.41 + ai = 256 * CLAMP(a,0.0,1.0) - 1;
1.42 + if( ai < 0 ) ai = 0;
1.43 }
1.44 if( TA_IS_INF(r) ) {
1.45 - ri = 255;
1.46 + ri = 255;
1.47 } else {
1.48 - ri = 256 * CLAMP(r,0.0,1.0) - 1;
1.49 - if( ri < 0 ) ri = 0;
1.50 + ri = 256 * CLAMP(r,0.0,1.0) - 1;
1.51 + if( ri < 0 ) ri = 0;
1.52 }
1.53 if( TA_IS_INF(g) ) {
1.54 - gi = 255;
1.55 + gi = 255;
1.56 } else {
1.57 - gi = 256 * CLAMP(g,0.0,1.0) - 1;
1.58 - if( gi < 0 ) gi = 0;
1.59 + gi = 256 * CLAMP(g,0.0,1.0) - 1;
1.60 + if( gi < 0 ) gi = 0;
1.61 }
1.62 if( TA_IS_INF(b) ) {
1.63 - bi = 255;
1.64 + bi = 255;
1.65 } else {
1.66 - bi = 256 * CLAMP(b,0.0,1.0) - 1;
1.67 - if( bi < 0 ) bi = 0;
1.68 + bi = 256 * CLAMP(b,0.0,1.0) - 1;
1.69 + if( bi < 0 ) bi = 0;
1.70 }
1.71 return (ai << 24) | (ri << 16) | (gi << 8) | bi;
1.72 }
1.73 @@ -260,14 +260,14 @@
1.74 static uint32_t parse_intensity_colour( uint32_t base, float intensity )
1.75 {
1.76 unsigned int i = (unsigned int)(256 * CLAMP(intensity, 0.0,1.0));
1.77 -
1.78 +
1.79 return
1.80 - (((((base & 0xFF) * i) & 0xFF00) |
1.81 - (((base & 0xFF00) * i) & 0xFF0000) |
1.82 - (((base & 0xFF0000) * i) & 0xFF000000)) >> 8) |
1.83 - (base & 0xFF000000);
1.84 + (((((base & 0xFF) * i) & 0xFF00) |
1.85 + (((base & 0xFF00) * i) & 0xFF0000) |
1.86 + (((base & 0xFF0000) * i) & 0xFF000000)) >> 8) |
1.87 + (base & 0xFF000000);
1.88 }
1.89 -
1.90 +
1.91 /**
1.92 * Initialize the specified TA list.
1.93 */
1.94 @@ -283,31 +283,31 @@
1.95 * Don't ask me why, it just does...
1.96 */
1.97 if( ((ta_status.tilelist_dir == TA_GROW_DOWN && list_end <= tile_matrix) ||
1.98 - (ta_status.tilelist_dir == TA_GROW_UP && list_end >= tile_matrix )) &&
1.99 - listtype <= TA_LIST_PUNCH_OUT ) {
1.100 - int i;
1.101 - uint32_t *p;
1.102 - for( i=0; i < listtype; i++ ) {
1.103 - int size = tilematrix_sizes[(config & 0x03)] << 2;
1.104 - ta_status.current_tile_matrix += ta_status.width * ta_status.height * size;
1.105 - config >>= 4;
1.106 - }
1.107 - ta_status.current_tile_size = tilematrix_sizes[(config & 0x03)];
1.108 + (ta_status.tilelist_dir == TA_GROW_UP && list_end >= tile_matrix )) &&
1.109 + listtype <= TA_LIST_PUNCH_OUT ) {
1.110 + int i;
1.111 + uint32_t *p;
1.112 + for( i=0; i < listtype; i++ ) {
1.113 + int size = tilematrix_sizes[(config & 0x03)] << 2;
1.114 + ta_status.current_tile_matrix += ta_status.width * ta_status.height * size;
1.115 + config >>= 4;
1.116 + }
1.117 + ta_status.current_tile_size = tilematrix_sizes[(config & 0x03)];
1.118
1.119 - /* Initialize each tile to 0xF0000000 */
1.120 - if( ta_status.current_tile_size != 0 ) {
1.121 - p = (uint32_t *)(video_base + ta_status.current_tile_matrix);
1.122 - for( i=0; i< ta_status.width * ta_status.height; i++ ) {
1.123 - *p = 0xF0000000;
1.124 - p += ta_status.current_tile_size;
1.125 - }
1.126 - }
1.127 + /* Initialize each tile to 0xF0000000 */
1.128 + if( ta_status.current_tile_size != 0 ) {
1.129 + p = (uint32_t *)(video_base + ta_status.current_tile_matrix);
1.130 + for( i=0; i< ta_status.width * ta_status.height; i++ ) {
1.131 + *p = 0xF0000000;
1.132 + p += ta_status.current_tile_size;
1.133 + }
1.134 + }
1.135 } else {
1.136 - ta_status.current_tile_size = 0;
1.137 + ta_status.current_tile_size = 0;
1.138 }
1.139
1.140 if( tile_matrix == list_end ) {
1.141 - ta_status.current_tile_size = 0;
1.142 + ta_status.current_tile_size = 0;
1.143 }
1.144
1.145 ta_status.state = STATE_IN_LIST;
1.146 @@ -316,12 +316,12 @@
1.147 }
1.148
1.149 static int list_events[5] = {EVENT_PVR_OPAQUE_DONE, EVENT_PVR_OPAQUEMOD_DONE,
1.150 - EVENT_PVR_TRANS_DONE, EVENT_PVR_TRANSMOD_DONE,
1.151 - EVENT_PVR_PUNCHOUT_DONE };
1.152 + EVENT_PVR_TRANS_DONE, EVENT_PVR_TRANSMOD_DONE,
1.153 + EVENT_PVR_PUNCHOUT_DONE };
1.154
1.155 static void ta_end_list() {
1.156 if( ta_status.current_list_type != TA_LIST_NONE ) {
1.157 - asic_event( list_events[ta_status.current_list_type] );
1.158 + asic_event( list_events[ta_status.current_list_type] );
1.159 }
1.160 ta_status.current_list_type = TA_LIST_NONE;
1.161 ta_status.current_vertex_type = TA_VERTEX_LISTLESS;
1.162 @@ -348,15 +348,15 @@
1.163 int end = MMIO_READ( PVR2, TA_POLYEND );
1.164 uint32_t *target = (uint32_t *)(video_base + posn);
1.165 for( rv=0; rv < length; rv++ ) {
1.166 - if( posn == end ) {
1.167 - asic_event( EVENT_PVR_PRIM_ALLOC_FAIL );
1.168 - // ta_status.state = STATE_ERROR;
1.169 - break;
1.170 - }
1.171 - if( posn < PVR2_RAM_SIZE ) {
1.172 - *target++ = *data++;
1.173 - }
1.174 - posn += 4;
1.175 + if( posn == end ) {
1.176 + asic_event( EVENT_PVR_PRIM_ALLOC_FAIL );
1.177 + // ta_status.state = STATE_ERROR;
1.178 + break;
1.179 + }
1.180 + if( posn < PVR2_RAM_SIZE ) {
1.181 + *target++ = *data++;
1.182 + }
1.183 + posn += 4;
1.184 }
1.185
1.186 MMIO_WRITE( PVR2, TA_POLYPOS, posn );
1.187 @@ -374,41 +374,41 @@
1.188 uint32_t limit = MMIO_READ( PVR2, TA_LISTEND ) >> 2;
1.189 uint32_t newposn;
1.190 if( ta_status.tilelist_dir == TA_GROW_DOWN ) {
1.191 - newposn = posn - ta_status.tilelist_size;
1.192 - if( posn == limit ) {
1.193 - PVRRAM(posn<<2) = 0xF0000000;
1.194 - PVRRAM(reference) = 0xE0000000 | (posn<<2);
1.195 - return TA_NO_ALLOC;
1.196 - } else if( posn < limit ) {
1.197 - PVRRAM(reference) = 0xE0000000 | (posn<<2);
1.198 - return TA_NO_ALLOC;
1.199 - } else if( newposn <= limit ) {
1.200 - } else if( newposn <= (limit + ta_status.tilelist_size) ) {
1.201 - asic_event( EVENT_PVR_MATRIX_ALLOC_FAIL );
1.202 - MMIO_WRITE( PVR2, TA_LISTPOS, newposn );
1.203 - } else {
1.204 - MMIO_WRITE( PVR2, TA_LISTPOS, newposn );
1.205 - }
1.206 - PVRRAM(reference) = 0xE0000000 | (posn<<2);
1.207 - return posn << 2;
1.208 + newposn = posn - ta_status.tilelist_size;
1.209 + if( posn == limit ) {
1.210 + PVRRAM(posn<<2) = 0xF0000000;
1.211 + PVRRAM(reference) = 0xE0000000 | (posn<<2);
1.212 + return TA_NO_ALLOC;
1.213 + } else if( posn < limit ) {
1.214 + PVRRAM(reference) = 0xE0000000 | (posn<<2);
1.215 + return TA_NO_ALLOC;
1.216 + } else if( newposn <= limit ) {
1.217 + } else if( newposn <= (limit + ta_status.tilelist_size) ) {
1.218 + asic_event( EVENT_PVR_MATRIX_ALLOC_FAIL );
1.219 + MMIO_WRITE( PVR2, TA_LISTPOS, newposn );
1.220 + } else {
1.221 + MMIO_WRITE( PVR2, TA_LISTPOS, newposn );
1.222 + }
1.223 + PVRRAM(reference) = 0xE0000000 | (posn<<2);
1.224 + return posn << 2;
1.225 } else {
1.226 - newposn = posn + ta_status.tilelist_size;
1.227 - if( posn == limit ) {
1.228 - PVRRAM(posn<<2) = 0xF0000000;
1.229 - PVRRAM(reference) = 0xE0000000 | (posn<<2);
1.230 - return TA_NO_ALLOC;
1.231 - } else if ( posn > limit ) {
1.232 - PVRRAM(reference) = 0xE0000000 | (posn<<2);
1.233 - return TA_NO_ALLOC;
1.234 - } else if( newposn >= limit ) {
1.235 - } else if( newposn >= (limit - ta_status.tilelist_size) ) {
1.236 - asic_event( EVENT_PVR_MATRIX_ALLOC_FAIL );
1.237 - MMIO_WRITE( PVR2, TA_LISTPOS, newposn );
1.238 - } else {
1.239 - MMIO_WRITE( PVR2, TA_LISTPOS, newposn );
1.240 - }
1.241 - PVRRAM(reference) = 0xE0000000 | (posn<<2);
1.242 - return posn << 2;
1.243 + newposn = posn + ta_status.tilelist_size;
1.244 + if( posn == limit ) {
1.245 + PVRRAM(posn<<2) = 0xF0000000;
1.246 + PVRRAM(reference) = 0xE0000000 | (posn<<2);
1.247 + return TA_NO_ALLOC;
1.248 + } else if ( posn > limit ) {
1.249 + PVRRAM(reference) = 0xE0000000 | (posn<<2);
1.250 + return TA_NO_ALLOC;
1.251 + } else if( newposn >= limit ) {
1.252 + } else if( newposn >= (limit - ta_status.tilelist_size) ) {
1.253 + asic_event( EVENT_PVR_MATRIX_ALLOC_FAIL );
1.254 + MMIO_WRITE( PVR2, TA_LISTPOS, newposn );
1.255 + } else {
1.256 + MMIO_WRITE( PVR2, TA_LISTPOS, newposn );
1.257 + }
1.258 + PVRRAM(reference) = 0xE0000000 | (posn<<2);
1.259 + return posn << 2;
1.260 }
1.261 }
1.262
1.263 @@ -423,67 +423,67 @@
1.264 int i;
1.265
1.266 if( ta_status.clip_mode == TA_POLYCMD_CLIP_OUTSIDE &&
1.267 - x >= ta_status.clip.x1 && x <= ta_status.clip.x2 &&
1.268 - y >= ta_status.clip.y1 && y <= ta_status.clip.y2 ) {
1.269 - /* Tile clipped out */
1.270 - return;
1.271 + x >= ta_status.clip.x1 && x <= ta_status.clip.x2 &&
1.272 + y >= ta_status.clip.y1 && y <= ta_status.clip.y2 ) {
1.273 + /* Tile clipped out */
1.274 + return;
1.275 }
1.276
1.277 if( (tile_entry & 0x80000000) &&
1.278 - ta_status.last_triangle_bounds.x1 != -1 &&
1.279 - ta_status.last_triangle_bounds.x1 <= x &&
1.280 - ta_status.last_triangle_bounds.x2 >= x &&
1.281 - ta_status.last_triangle_bounds.y1 <= y &&
1.282 - ta_status.last_triangle_bounds.y2 >= y ) {
1.283 - /* potential for triangle stacking */
1.284 - lasttri = tile_entry & 0xE1E00000;
1.285 + ta_status.last_triangle_bounds.x1 != -1 &&
1.286 + ta_status.last_triangle_bounds.x1 <= x &&
1.287 + ta_status.last_triangle_bounds.x2 >= x &&
1.288 + ta_status.last_triangle_bounds.y1 <= y &&
1.289 + ta_status.last_triangle_bounds.y2 >= y ) {
1.290 + /* potential for triangle stacking */
1.291 + lasttri = tile_entry & 0xE1E00000;
1.292 }
1.293 -
1.294 -
1.295 +
1.296 +
1.297 if( PVRRAM(tile) == 0xF0000000 ) {
1.298 - PVRRAM(tile) = tile_entry;
1.299 - PVRRAM(tile+4) = 0xF0000000;
1.300 - return;
1.301 + PVRRAM(tile) = tile_entry;
1.302 + PVRRAM(tile+4) = 0xF0000000;
1.303 + return;
1.304 }
1.305
1.306 while(1) {
1.307 - value = PVRRAM(tile);
1.308 - for( i=1; i<ta_status.current_tile_size; i++ ) {
1.309 - tile += 4;
1.310 - uint32_t nextval = PVRRAM(tile);
1.311 - if( nextval == 0xF0000000 ) {
1.312 - if( lasttri != 0 && lasttri == (value&0xE1E00000) ) {
1.313 - int count = (value & 0x1E000000) + 0x02000000;
1.314 - if( count < 0x20000000 ) {
1.315 - PVRRAM(tile-4) = (value & 0xE1FFFFFF) | count;
1.316 - return;
1.317 - }
1.318 - }
1.319 - if( i < ta_status.current_tile_size-1 ) {
1.320 - PVRRAM(tile) = tile_entry;
1.321 - PVRRAM(tile+4) = 0xF0000000;
1.322 - return;
1.323 - }
1.324 - }
1.325 - value = nextval;
1.326 - }
1.327 + value = PVRRAM(tile);
1.328 + for( i=1; i<ta_status.current_tile_size; i++ ) {
1.329 + tile += 4;
1.330 + uint32_t nextval = PVRRAM(tile);
1.331 + if( nextval == 0xF0000000 ) {
1.332 + if( lasttri != 0 && lasttri == (value&0xE1E00000) ) {
1.333 + int count = (value & 0x1E000000) + 0x02000000;
1.334 + if( count < 0x20000000 ) {
1.335 + PVRRAM(tile-4) = (value & 0xE1FFFFFF) | count;
1.336 + return;
1.337 + }
1.338 + }
1.339 + if( i < ta_status.current_tile_size-1 ) {
1.340 + PVRRAM(tile) = tile_entry;
1.341 + PVRRAM(tile+4) = 0xF0000000;
1.342 + return;
1.343 + }
1.344 + }
1.345 + value = nextval;
1.346 + }
1.347
1.348 - if( value == 0xF0000000 ) {
1.349 - tile = ta_alloc_tilelist(tile);
1.350 - if( tile != TA_NO_ALLOC ) {
1.351 - PVRRAM(tile) = tile_entry;
1.352 - PVRRAM(tile+4) = 0xF0000000;
1.353 - }
1.354 - return;
1.355 - } else if( (value & 0xFF000000) == 0xE0000000 ) {
1.356 - value &= 0x00FFFFFF;
1.357 - if( value == tilestart )
1.358 - return; /* Loop */
1.359 - tilestart = tile = value;
1.360 - } else {
1.361 - /* This should never happen */
1.362 - return;
1.363 - }
1.364 + if( value == 0xF0000000 ) {
1.365 + tile = ta_alloc_tilelist(tile);
1.366 + if( tile != TA_NO_ALLOC ) {
1.367 + PVRRAM(tile) = tile_entry;
1.368 + PVRRAM(tile+4) = 0xF0000000;
1.369 + }
1.370 + return;
1.371 + } else if( (value & 0xFF000000) == 0xE0000000 ) {
1.372 + value &= 0x00FFFFFF;
1.373 + if( value == tilestart )
1.374 + return; /* Loop */
1.375 + tilestart = tile = value;
1.376 + } else {
1.377 + /* This should never happen */
1.378 + return;
1.379 + }
1.380 }
1.381 }
1.382
1.383 @@ -504,21 +504,21 @@
1.384 * clamping here)
1.385 */
1.386 for( i=0; i<ta_status.vertex_count; i++ ) {
1.387 - if( ta_status.poly_vertex[i].x < 0.0 || TA_IS_NINF(ta_status.poly_vertex[i].x) ) {
1.388 - tx[i] = -1;
1.389 - } else if( ta_status.poly_vertex[i].x > (float)INT_MAX || TA_IS_INF(ta_status.poly_vertex[i].x) ) {
1.390 - tx[i] = INT_MAX/32;
1.391 - } else {
1.392 - tx[i] = (int)(ta_status.poly_vertex[i].x / 32.0);
1.393 - }
1.394 - if( ta_status.poly_vertex[i].y < 0.0 || TA_IS_NINF(ta_status.poly_vertex[i].y)) {
1.395 - ty[i] = -1;
1.396 - } else if( ta_status.poly_vertex[i].y > (float)INT_MAX || TA_IS_INF(ta_status.poly_vertex[i].y) ) {
1.397 - ty[i] = INT_MAX/32;
1.398 - } else {
1.399 - ty[i] = (int)(ta_status.poly_vertex[i].y / 32.0);
1.400 - }
1.401 -
1.402 + if( ta_status.poly_vertex[i].x < 0.0 || TA_IS_NINF(ta_status.poly_vertex[i].x) ) {
1.403 + tx[i] = -1;
1.404 + } else if( ta_status.poly_vertex[i].x > (float)INT_MAX || TA_IS_INF(ta_status.poly_vertex[i].x) ) {
1.405 + tx[i] = INT_MAX/32;
1.406 + } else {
1.407 + tx[i] = (int)(ta_status.poly_vertex[i].x / 32.0);
1.408 + }
1.409 + if( ta_status.poly_vertex[i].y < 0.0 || TA_IS_NINF(ta_status.poly_vertex[i].y)) {
1.410 + ty[i] = -1;
1.411 + } else if( ta_status.poly_vertex[i].y > (float)INT_MAX || TA_IS_INF(ta_status.poly_vertex[i].y) ) {
1.412 + ty[i] = INT_MAX/32;
1.413 + } else {
1.414 + ty[i] = (int)(ta_status.poly_vertex[i].y / 32.0);
1.415 + }
1.416 +
1.417 }
1.418
1.419 /* Compute bounding box for each triangle individually, as well
1.420 @@ -526,21 +526,21 @@
1.421 */
1.422
1.423 for( i=0; i<ta_status.vertex_count-2; i++ ) {
1.424 - triangle_bound[i].x1 = MIN3(tx[i],tx[i+1],tx[i+2]);
1.425 - triangle_bound[i].x2 = MAX3(tx[i],tx[i+1],tx[i+2]);
1.426 - triangle_bound[i].y1 = MIN3(ty[i],ty[i+1],ty[i+2]);
1.427 - triangle_bound[i].y2 = MAX3(ty[i],ty[i+1],ty[i+2]);
1.428 - if( i == 0 ) {
1.429 - polygon_bound.x1 = triangle_bound[0].x1;
1.430 - polygon_bound.y1 = triangle_bound[0].y1;
1.431 - polygon_bound.x2 = triangle_bound[0].x2;
1.432 - polygon_bound.y2 = triangle_bound[0].y2;
1.433 - } else {
1.434 - polygon_bound.x1 = MIN(polygon_bound.x1, triangle_bound[i].x1);
1.435 - polygon_bound.x2 = MAX(polygon_bound.x2, triangle_bound[i].x2);
1.436 - polygon_bound.y1 = MIN(polygon_bound.y1, triangle_bound[i].y1);
1.437 - polygon_bound.y2 = MAX(polygon_bound.y2, triangle_bound[i].y2);
1.438 - }
1.439 + triangle_bound[i].x1 = MIN3(tx[i],tx[i+1],tx[i+2]);
1.440 + triangle_bound[i].x2 = MAX3(tx[i],tx[i+1],tx[i+2]);
1.441 + triangle_bound[i].y1 = MIN3(ty[i],ty[i+1],ty[i+2]);
1.442 + triangle_bound[i].y2 = MAX3(ty[i],ty[i+1],ty[i+2]);
1.443 + if( i == 0 ) {
1.444 + polygon_bound.x1 = triangle_bound[0].x1;
1.445 + polygon_bound.y1 = triangle_bound[0].y1;
1.446 + polygon_bound.x2 = triangle_bound[0].x2;
1.447 + polygon_bound.y2 = triangle_bound[0].y2;
1.448 + } else {
1.449 + polygon_bound.x1 = MIN(polygon_bound.x1, triangle_bound[i].x1);
1.450 + polygon_bound.x2 = MAX(polygon_bound.x2, triangle_bound[i].x2);
1.451 + polygon_bound.y1 = MIN(polygon_bound.y1, triangle_bound[i].y1);
1.452 + polygon_bound.y2 = MAX(polygon_bound.y2, triangle_bound[i].y2);
1.453 + }
1.454 }
1.455
1.456 /* Clamp the polygon bounds to the frustum */
1.457 @@ -551,95 +551,95 @@
1.458
1.459 /* Set the "single tile" flag if it's entirely contained in 1 tile */
1.460 if( polygon_bound.x1 == polygon_bound.x2 &&
1.461 - polygon_bound.y1 == polygon_bound.y2 ) {
1.462 - poly_context[0] |= 0x00200000;
1.463 + polygon_bound.y1 == polygon_bound.y2 ) {
1.464 + poly_context[0] |= 0x00200000;
1.465 }
1.466 -
1.467 +
1.468 /* If the polygon is entirely clipped, don't even write the polygon data */
1.469 switch( ta_status.clip_mode ) {
1.470 case TA_POLYCMD_CLIP_NONE:
1.471 - if( polygon_bound.x2 < 0 || polygon_bound.x1 >= ta_status.width ||
1.472 - polygon_bound.y2 < 0 || polygon_bound.y1 >= ta_status.height ) {
1.473 - return;
1.474 - }
1.475 - break;
1.476 + if( polygon_bound.x2 < 0 || polygon_bound.x1 >= ta_status.width ||
1.477 + polygon_bound.y2 < 0 || polygon_bound.y1 >= ta_status.height ) {
1.478 + return;
1.479 + }
1.480 + break;
1.481 case TA_POLYCMD_CLIP_INSIDE:
1.482 - if( polygon_bound.x2 < ta_status.clip.x1 || polygon_bound.x1 > ta_status.clip.x2 ||
1.483 - polygon_bound.y2 < ta_status.clip.y1 || polygon_bound.y1 > ta_status.clip.y2 ) {
1.484 - return;
1.485 - } else {
1.486 - /* Clamp to clip bounds */
1.487 - if( polygon_bound.x1 < ta_status.clip.x1 ) polygon_bound.x1 = ta_status.clip.x1;
1.488 - if( polygon_bound.x2 > ta_status.clip.x2 ) polygon_bound.x2 = ta_status.clip.x2;
1.489 - if( polygon_bound.y1 < ta_status.clip.y1 ) polygon_bound.y1 = ta_status.clip.y1;
1.490 - if( polygon_bound.y2 > ta_status.clip.y2 ) polygon_bound.y2 = ta_status.clip.y2;
1.491 - }
1.492 - break;
1.493 + if( polygon_bound.x2 < ta_status.clip.x1 || polygon_bound.x1 > ta_status.clip.x2 ||
1.494 + polygon_bound.y2 < ta_status.clip.y1 || polygon_bound.y1 > ta_status.clip.y2 ) {
1.495 + return;
1.496 + } else {
1.497 + /* Clamp to clip bounds */
1.498 + if( polygon_bound.x1 < ta_status.clip.x1 ) polygon_bound.x1 = ta_status.clip.x1;
1.499 + if( polygon_bound.x2 > ta_status.clip.x2 ) polygon_bound.x2 = ta_status.clip.x2;
1.500 + if( polygon_bound.y1 < ta_status.clip.y1 ) polygon_bound.y1 = ta_status.clip.y1;
1.501 + if( polygon_bound.y2 > ta_status.clip.y2 ) polygon_bound.y2 = ta_status.clip.y2;
1.502 + }
1.503 + break;
1.504 case TA_POLYCMD_CLIP_OUTSIDE:
1.505 - if( polygon_bound.x1 >= ta_status.clip.x1 && polygon_bound.x2 <= ta_status.clip.x2 &&
1.506 - polygon_bound.y1 >= ta_status.clip.y1 && polygon_bound.y2 <= ta_status.clip.y2 ) {
1.507 - return;
1.508 - }
1.509 - break;
1.510 + if( polygon_bound.x1 >= ta_status.clip.x1 && polygon_bound.x2 <= ta_status.clip.x2 &&
1.511 + polygon_bound.y1 >= ta_status.clip.y1 && polygon_bound.y2 <= ta_status.clip.y2 ) {
1.512 + return;
1.513 + }
1.514 + break;
1.515 }
1.516
1.517 /* Ok, we're good to go - write out the polygon first */
1.518 uint32_t tile_entry = (MMIO_READ( PVR2, TA_POLYPOS ) - ta_status.polybuf_start) >> 2 |
1.519 - ta_status.poly_pointer;
1.520 -
1.521 + ta_status.poly_pointer;
1.522 +
1.523 int status = ta_write_polygon_buffer( poly_context, ta_status.poly_context_size );
1.524 if( status == 0 ) {
1.525 - /* No memory available - abort */
1.526 - return;
1.527 + /* No memory available - abort */
1.528 + return;
1.529 } else {
1.530 - for( i=0; i<ta_status.vertex_count && status != 0; i++ ) {
1.531 - status = ta_write_polygon_buffer( (uint32_t *)(&ta_status.poly_vertex[i]), 3 + ta_status.poly_vertex_size );
1.532 - }
1.533 + for( i=0; i<ta_status.vertex_count && status != 0; i++ ) {
1.534 + status = ta_write_polygon_buffer( (uint32_t *)(&ta_status.poly_vertex[i]), 3 + ta_status.poly_vertex_size );
1.535 + }
1.536 }
1.537
1.538 if( ta_status.current_tile_size == 0 ) {
1.539 - /* No memory for tile entry, so don't write anything */
1.540 - return;
1.541 + /* No memory for tile entry, so don't write anything */
1.542 + return;
1.543 }
1.544
1.545 /* And now the tile entries. Triangles are different from everything else */
1.546 if( ta_status.vertex_count == 3 ) {
1.547 - tile_entry |= 0x80000000;
1.548 - for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {
1.549 - for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {
1.550 - ta_write_tile_entry( x,y,tile_entry );
1.551 - }
1.552 - }
1.553 - ta_status.last_triangle_bounds.x1 = polygon_bound.x1;
1.554 - ta_status.last_triangle_bounds.y1 = polygon_bound.y1;
1.555 - ta_status.last_triangle_bounds.x2 = polygon_bound.x2;
1.556 - ta_status.last_triangle_bounds.y2 = polygon_bound.y2;
1.557 + tile_entry |= 0x80000000;
1.558 + for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {
1.559 + for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {
1.560 + ta_write_tile_entry( x,y,tile_entry );
1.561 + }
1.562 + }
1.563 + ta_status.last_triangle_bounds.x1 = polygon_bound.x1;
1.564 + ta_status.last_triangle_bounds.y1 = polygon_bound.y1;
1.565 + ta_status.last_triangle_bounds.x2 = polygon_bound.x2;
1.566 + ta_status.last_triangle_bounds.y2 = polygon_bound.y2;
1.567 } else if( ta_status.current_vertex_type == TA_VERTEX_SPRITE ||
1.568 - ta_status.current_vertex_type == TA_VERTEX_TEX_SPRITE ) {
1.569 - tile_entry |= 0xA0000000;
1.570 - for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {
1.571 - for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {
1.572 - ta_write_tile_entry( x,y,tile_entry );
1.573 - }
1.574 - }
1.575 - ta_status.last_triangle_bounds.x1 = polygon_bound.x1;
1.576 - ta_status.last_triangle_bounds.y1 = polygon_bound.y1;
1.577 - ta_status.last_triangle_bounds.x2 = polygon_bound.x2;
1.578 - ta_status.last_triangle_bounds.y2 = polygon_bound.y2;
1.579 + ta_status.current_vertex_type == TA_VERTEX_TEX_SPRITE ) {
1.580 + tile_entry |= 0xA0000000;
1.581 + for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {
1.582 + for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {
1.583 + ta_write_tile_entry( x,y,tile_entry );
1.584 + }
1.585 + }
1.586 + ta_status.last_triangle_bounds.x1 = polygon_bound.x1;
1.587 + ta_status.last_triangle_bounds.y1 = polygon_bound.y1;
1.588 + ta_status.last_triangle_bounds.x2 = polygon_bound.x2;
1.589 + ta_status.last_triangle_bounds.y2 = polygon_bound.y2;
1.590 } else {
1.591 - for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {
1.592 - for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {
1.593 - uint32_t entry = tile_entry;
1.594 - for( i=0; i<ta_status.vertex_count-2; i++ ) {
1.595 - if( triangle_bound[i].x1 <= x && triangle_bound[i].x2 >= x &&
1.596 - triangle_bound[i].y1 <= y && triangle_bound[i].y2 >= y ) {
1.597 - entry |= (0x40000000>>i);
1.598 - }
1.599 - }
1.600 - ta_write_tile_entry( x, y, entry );
1.601 - }
1.602 - }
1.603 - ta_status.last_triangle_bounds.x1 = -1;
1.604 + for( y=polygon_bound.y1; y<=polygon_bound.y2; y++ ) {
1.605 + for( x=polygon_bound.x1; x<=polygon_bound.x2; x++ ) {
1.606 + uint32_t entry = tile_entry;
1.607 + for( i=0; i<ta_status.vertex_count-2; i++ ) {
1.608 + if( triangle_bound[i].x1 <= x && triangle_bound[i].x2 >= x &&
1.609 + triangle_bound[i].y1 <= y && triangle_bound[i].y2 >= y ) {
1.610 + entry |= (0x40000000>>i);
1.611 + }
1.612 + }
1.613 + ta_write_tile_entry( x, y, entry );
1.614 + }
1.615 + }
1.616 + ta_status.last_triangle_bounds.x1 = -1;
1.617 }
1.618 }
1.619
1.620 @@ -652,29 +652,29 @@
1.621 static void ta_split_polygon() {
1.622 ta_commit_polygon();
1.623 if( TA_IS_NORMAL_POLY() ) {
1.624 - /* This only applies to ordinary polys - Sprites + modifier lists are
1.625 - * handled differently
1.626 - */
1.627 - if( ta_status.vertex_count == 3 ) {
1.628 - /* Triangles use an odd/even scheme */
1.629 - if( ta_status.poly_parity == 0 ) {
1.630 - memcpy( &ta_status.poly_vertex[0], &ta_status.poly_vertex[2],
1.631 - sizeof(struct pvr2_ta_vertex) );
1.632 - ta_status.poly_parity = 1;
1.633 - } else {
1.634 - memcpy( &ta_status.poly_vertex[1], &ta_status.poly_vertex[2],
1.635 - sizeof(struct pvr2_ta_vertex) );
1.636 - ta_status.poly_parity = 0;
1.637 - }
1.638 - } else {
1.639 - /* Everything else just uses the last 2 vertexes in order */
1.640 - memcpy( &ta_status.poly_vertex[0], &ta_status.poly_vertex[ta_status.vertex_count-2],
1.641 - sizeof(struct pvr2_ta_vertex)*2 );
1.642 - ta_status.poly_parity = 0;
1.643 - }
1.644 - ta_status.vertex_count = 2;
1.645 + /* This only applies to ordinary polys - Sprites + modifier lists are
1.646 + * handled differently
1.647 + */
1.648 + if( ta_status.vertex_count == 3 ) {
1.649 + /* Triangles use an odd/even scheme */
1.650 + if( ta_status.poly_parity == 0 ) {
1.651 + memcpy( &ta_status.poly_vertex[0], &ta_status.poly_vertex[2],
1.652 + sizeof(struct pvr2_ta_vertex) );
1.653 + ta_status.poly_parity = 1;
1.654 + } else {
1.655 + memcpy( &ta_status.poly_vertex[1], &ta_status.poly_vertex[2],
1.656 + sizeof(struct pvr2_ta_vertex) );
1.657 + ta_status.poly_parity = 0;
1.658 + }
1.659 + } else {
1.660 + /* Everything else just uses the last 2 vertexes in order */
1.661 + memcpy( &ta_status.poly_vertex[0], &ta_status.poly_vertex[ta_status.vertex_count-2],
1.662 + sizeof(struct pvr2_ta_vertex)*2 );
1.663 + ta_status.poly_parity = 0;
1.664 + }
1.665 + ta_status.vertex_count = 2;
1.666 } else {
1.667 - ta_status.vertex_count = 0;
1.668 + ta_status.vertex_count = 0;
1.669 }
1.670 }
1.671
1.672 @@ -686,63 +686,63 @@
1.673 static void ta_parse_polygon_context( union ta_data *data ) {
1.674 int colourfmt = TA_POLYCMD_COLOURFMT(data[0].i);
1.675 if( TA_POLYCMD_USELENGTH(data[0].i) ) {
1.676 - ta_status.max_vertex = TA_POLYCMD_LENGTH(data[0].i);
1.677 + ta_status.max_vertex = TA_POLYCMD_LENGTH(data[0].i);
1.678 }
1.679 ta_status.clip_mode = TA_POLYCMD_CLIP(data[0].i);
1.680 if( ta_status.clip_mode == 1 ) { /* Reserved - treat as CLIP_INSIDE */
1.681 - ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;
1.682 + ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;
1.683 }
1.684 ta_status.vertex_count = 0;
1.685 ta_status.poly_context[0] =
1.686 - (data[1].i & 0xFC1FFFFF) | ((data[0].i & 0x0B) << 22);
1.687 + (data[1].i & 0xFC1FFFFF) | ((data[0].i & 0x0B) << 22);
1.688 ta_status.poly_context[1] = data[2].i;
1.689 ta_status.poly_context[3] = data[4].i;
1.690 ta_status.poly_parity = 0;
1.691 if( data[0].i & TA_POLYCMD_TEXTURED ) {
1.692 - ta_status.current_vertex_type = data[0].i & 0x0D;
1.693 - ta_status.poly_context[2] = data[3].i;
1.694 - ta_status.poly_context[4] = data[5].i;
1.695 - if( data[0].i & TA_POLYCMD_SPECULAR ) {
1.696 - ta_status.poly_context[0] |= 0x01000000;
1.697 - ta_status.poly_vertex_size = 4;
1.698 - } else {
1.699 - ta_status.poly_vertex_size = 3;
1.700 - }
1.701 - if( data[0].i & TA_POLYCMD_UV16 ) {
1.702 - ta_status.poly_vertex_size--;
1.703 - }
1.704 + ta_status.current_vertex_type = data[0].i & 0x0D;
1.705 + ta_status.poly_context[2] = data[3].i;
1.706 + ta_status.poly_context[4] = data[5].i;
1.707 + if( data[0].i & TA_POLYCMD_SPECULAR ) {
1.708 + ta_status.poly_context[0] |= 0x01000000;
1.709 + ta_status.poly_vertex_size = 4;
1.710 + } else {
1.711 + ta_status.poly_vertex_size = 3;
1.712 + }
1.713 + if( data[0].i & TA_POLYCMD_UV16 ) {
1.714 + ta_status.poly_vertex_size--;
1.715 + }
1.716 } else {
1.717 - ta_status.current_vertex_type = 0;
1.718 - ta_status.poly_vertex_size = 1;
1.719 - ta_status.poly_context[2] = 0;
1.720 - ta_status.poly_context[4] = 0;
1.721 + ta_status.current_vertex_type = 0;
1.722 + ta_status.poly_vertex_size = 1;
1.723 + ta_status.poly_context[2] = 0;
1.724 + ta_status.poly_context[4] = 0;
1.725 }
1.726
1.727 ta_status.poly_pointer = (ta_status.poly_vertex_size << 21);
1.728 ta_status.poly_context_size = 3;
1.729 if( data[0].i & TA_POLYCMD_MODIFIED ) {
1.730 - ta_status.poly_pointer |= 0x01000000;
1.731 - if( data[0].i & TA_POLYCMD_FULLMOD ) {
1.732 - ta_status.poly_context_size = 5;
1.733 - ta_status.poly_vertex_size <<= 1;
1.734 - ta_status.current_vertex_type |= 0x40;
1.735 - /* Modified/float not supported - behaves as per last intensity */
1.736 - if( colourfmt == TA_POLYCMD_COLOURFMT_FLOAT ) {
1.737 - colourfmt = TA_POLYCMD_COLOURFMT_LASTINT;
1.738 - }
1.739 - }
1.740 + ta_status.poly_pointer |= 0x01000000;
1.741 + if( data[0].i & TA_POLYCMD_FULLMOD ) {
1.742 + ta_status.poly_context_size = 5;
1.743 + ta_status.poly_vertex_size <<= 1;
1.744 + ta_status.current_vertex_type |= 0x40;
1.745 + /* Modified/float not supported - behaves as per last intensity */
1.746 + if( colourfmt == TA_POLYCMD_COLOURFMT_FLOAT ) {
1.747 + colourfmt = TA_POLYCMD_COLOURFMT_LASTINT;
1.748 + }
1.749 + }
1.750 }
1.751 -
1.752 +
1.753 if( colourfmt == TA_POLYCMD_COLOURFMT_INTENSITY ) {
1.754 - if( TA_POLYCMD_IS_FULLMOD(data[0].i) ||
1.755 - TA_POLYCMD_IS_SPECULAR(data[0].i) ) {
1.756 - ta_status.state = STATE_EXPECT_POLY_BLOCK2;
1.757 - } else {
1.758 - ta_status.intensity1 =
1.759 - parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
1.760 - }
1.761 + if( TA_POLYCMD_IS_FULLMOD(data[0].i) ||
1.762 + TA_POLYCMD_IS_SPECULAR(data[0].i) ) {
1.763 + ta_status.state = STATE_EXPECT_POLY_BLOCK2;
1.764 + } else {
1.765 + ta_status.intensity1 =
1.766 + parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
1.767 + }
1.768 } else if( colourfmt == TA_POLYCMD_COLOURFMT_LASTINT ) {
1.769 - colourfmt = TA_POLYCMD_COLOURFMT_INTENSITY;
1.770 + colourfmt = TA_POLYCMD_COLOURFMT_INTENSITY;
1.771 }
1.772
1.773 ta_status.current_vertex_type |= colourfmt;
1.774 @@ -758,13 +758,13 @@
1.775 ta_status.poly_vertex_size = 0;
1.776 ta_status.clip_mode = TA_POLYCMD_CLIP(data[0].i);
1.777 if( ta_status.clip_mode == 1 ) { /* Reserved - treat as CLIP_INSIDE */
1.778 - ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;
1.779 + ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;
1.780 }
1.781 ta_status.poly_context_size = 3;
1.782 ta_status.poly_context[0] = (data[1].i & 0xFC1FFFFF) |
1.783 - ((data[0].i & 0x0B)<<22);
1.784 + ((data[0].i & 0x0B)<<22);
1.785 if( TA_POLYCMD_IS_SPECULAR(data[0].i) ) {
1.786 - ta_status.poly_context[0] |= 0x01000000;
1.787 + ta_status.poly_context[0] |= 0x01000000;
1.788 }
1.789 ta_status.poly_context[1] = 0;
1.790 ta_status.poly_context[2] = 0;
1.791 @@ -781,24 +781,24 @@
1.792 static void ta_parse_sprite_context( union ta_data *data ) {
1.793 ta_status.poly_context_size = 3;
1.794 ta_status.poly_context[0] = (data[1].i & 0xFC1FFFFF) |
1.795 - ((data[0].i & 0x0B)<<22) | 0x00400000;
1.796 + ((data[0].i & 0x0B)<<22) | 0x00400000;
1.797 ta_status.clip_mode = TA_POLYCMD_CLIP(data[0].i);
1.798 if( ta_status.clip_mode == 1 ) { /* Reserved - treat as CLIP_INSIDE */
1.799 - ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;
1.800 + ta_status.clip_mode = TA_POLYCMD_CLIP_INSIDE;
1.801 }
1.802 if( TA_POLYCMD_IS_SPECULAR(data[0].i) ) {
1.803 - ta_status.poly_context[0] |= 0x01000000;
1.804 + ta_status.poly_context[0] |= 0x01000000;
1.805 }
1.806 ta_status.poly_context[1] = data[2].i;
1.807 ta_status.poly_context[2] = data[3].i;
1.808 if( data[0].i & TA_POLYCMD_TEXTURED ) {
1.809 - ta_status.poly_vertex_size = 2;
1.810 - ta_status.poly_vertex[2].detail[1] = data[4].i;
1.811 - ta_status.current_vertex_type = TA_VERTEX_TEX_SPRITE;
1.812 + ta_status.poly_vertex_size = 2;
1.813 + ta_status.poly_vertex[2].detail[1] = data[4].i;
1.814 + ta_status.current_vertex_type = TA_VERTEX_TEX_SPRITE;
1.815 } else {
1.816 - ta_status.poly_vertex_size = 1;
1.817 - ta_status.poly_vertex[2].detail[0] = data[4].i;
1.818 - ta_status.current_vertex_type = TA_VERTEX_SPRITE;
1.819 + ta_status.poly_vertex_size = 1;
1.820 + ta_status.poly_vertex[2].detail[0] = data[4].i;
1.821 + ta_status.current_vertex_type = TA_VERTEX_SPRITE;
1.822 }
1.823 ta_status.vertex_count = 0;
1.824 ta_status.max_vertex = 4;
1.825 @@ -812,8 +812,8 @@
1.826 static void ta_fill_vertexes( ) {
1.827 int i;
1.828 for( i=ta_status.vertex_count; i<ta_status.max_vertex; i++ ) {
1.829 - memcpy( &ta_status.poly_vertex[i], &ta_status.poly_vertex[ta_status.vertex_count-1],
1.830 - sizeof( struct pvr2_ta_vertex ) );
1.831 + memcpy( &ta_status.poly_vertex[i], &ta_status.poly_vertex[ta_status.vertex_count-1],
1.832 + sizeof( struct pvr2_ta_vertex ) );
1.833 }
1.834 }
1.835
1.836 @@ -825,117 +825,117 @@
1.837
1.838 switch( ta_status.current_vertex_type ) {
1.839 case TA_VERTEX_PACKED:
1.840 - vertex->detail[0] = data[6].i;
1.841 - break;
1.842 + vertex->detail[0] = data[6].i;
1.843 + break;
1.844 case TA_VERTEX_FLOAT:
1.845 - vertex->detail[0] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
1.846 - break;
1.847 + vertex->detail[0] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
1.848 + break;
1.849 case TA_VERTEX_INTENSITY:
1.850 - vertex->detail[0] = parse_intensity_colour( ta_status.intensity1, data[6].f );
1.851 - break;
1.852 + vertex->detail[0] = parse_intensity_colour( ta_status.intensity1, data[6].f );
1.853 + break;
1.854
1.855 case TA_VERTEX_TEX_SPEC_PACKED:
1.856 - vertex->detail[3] = data[7].i; /* ARGB */
1.857 - /* Fallthrough */
1.858 + vertex->detail[3] = data[7].i; /* ARGB */
1.859 + /* Fallthrough */
1.860 case TA_VERTEX_TEX_PACKED:
1.861 - vertex->detail[0] = data[4].i; /* U */
1.862 - vertex->detail[1] = data[5].i; /* V */
1.863 - vertex->detail[2] = data[6].i; /* ARGB */
1.864 - break;
1.865 + vertex->detail[0] = data[4].i; /* U */
1.866 + vertex->detail[1] = data[5].i; /* V */
1.867 + vertex->detail[2] = data[6].i; /* ARGB */
1.868 + break;
1.869 case TA_VERTEX_TEX_UV16_SPEC_PACKED:
1.870 - vertex->detail[2] = data[7].i; /* ARGB */
1.871 - /* Fallthrough */
1.872 + vertex->detail[2] = data[7].i; /* ARGB */
1.873 + /* Fallthrough */
1.874 case TA_VERTEX_TEX_UV16_PACKED:
1.875 - vertex->detail[0] = data[4].i; /* UV */
1.876 - vertex->detail[1] = data[6].i; /* ARGB */
1.877 - break;
1.878 + vertex->detail[0] = data[4].i; /* UV */
1.879 + vertex->detail[1] = data[6].i; /* ARGB */
1.880 + break;
1.881
1.882 case TA_VERTEX_TEX_FLOAT:
1.883 case TA_VERTEX_TEX_SPEC_FLOAT:
1.884 - vertex->detail[0] = data[4].i; /* U */
1.885 - vertex->detail[1] = data[5].i; /* UV */
1.886 - ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
1.887 - break;
1.888 + vertex->detail[0] = data[4].i; /* U */
1.889 + vertex->detail[1] = data[5].i; /* UV */
1.890 + ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
1.891 + break;
1.892 case TA_VERTEX_TEX_UV16_FLOAT:
1.893 case TA_VERTEX_TEX_UV16_SPEC_FLOAT:
1.894 - vertex->detail[0] = data[4].i; /* UV */
1.895 - ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
1.896 - break;
1.897 + vertex->detail[0] = data[4].i; /* UV */
1.898 + ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
1.899 + break;
1.900
1.901 case TA_VERTEX_TEX_SPEC_INTENSITY:
1.902 - vertex->detail[3] = parse_intensity_colour( ta_status.intensity2, data[7].f );
1.903 - /* Fallthrough */
1.904 + vertex->detail[3] = parse_intensity_colour( ta_status.intensity2, data[7].f );
1.905 + /* Fallthrough */
1.906 case TA_VERTEX_TEX_INTENSITY:
1.907 - vertex->detail[0] = data[4].i; /* U */
1.908 - vertex->detail[1] = data[5].i; /* V */
1.909 - vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[6].f );
1.910 - break;
1.911 + vertex->detail[0] = data[4].i; /* U */
1.912 + vertex->detail[1] = data[5].i; /* V */
1.913 + vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[6].f );
1.914 + break;
1.915 case TA_VERTEX_TEX_UV16_SPEC_INTENSITY:
1.916 - vertex->detail[2] = parse_intensity_colour( ta_status.intensity2, data[7].f );
1.917 - /* Fallthrough */
1.918 + vertex->detail[2] = parse_intensity_colour( ta_status.intensity2, data[7].f );
1.919 + /* Fallthrough */
1.920 case TA_VERTEX_TEX_UV16_INTENSITY:
1.921 - vertex->detail[0] = data[4].i; /* UV */
1.922 - vertex->detail[1] = parse_intensity_colour( ta_status.intensity1, data[6].f );
1.923 - break;
1.924 + vertex->detail[0] = data[4].i; /* UV */
1.925 + vertex->detail[1] = parse_intensity_colour( ta_status.intensity1, data[6].f );
1.926 + break;
1.927
1.928 case TA_VERTEX_PACKED_MOD:
1.929 - vertex->detail[0] = data[4].i; /* ARGB */
1.930 - vertex->detail[1] = data[5].i; /* ARGB */
1.931 - break;
1.932 + vertex->detail[0] = data[4].i; /* ARGB */
1.933 + vertex->detail[1] = data[5].i; /* ARGB */
1.934 + break;
1.935 case TA_VERTEX_INTENSITY_MOD:
1.936 - vertex->detail[0] = parse_intensity_colour( ta_status.intensity1, data[4].f );
1.937 - vertex->detail[1] = parse_intensity_colour( ta_status.intensity2, data[5].f );
1.938 - break;
1.939 + vertex->detail[0] = parse_intensity_colour( ta_status.intensity1, data[4].f );
1.940 + vertex->detail[1] = parse_intensity_colour( ta_status.intensity2, data[5].f );
1.941 + break;
1.942
1.943 case TA_VERTEX_TEX_SPEC_PACKED_MOD:
1.944 - vertex->detail[3] = data[7].i; /* ARGB0 */
1.945 - /* Fallthrough */
1.946 + vertex->detail[3] = data[7].i; /* ARGB0 */
1.947 + /* Fallthrough */
1.948 case TA_VERTEX_TEX_PACKED_MOD:
1.949 - vertex->detail[0] = data[4].i; /* U0 */
1.950 - vertex->detail[1] = data[5].i; /* V0 */
1.951 - vertex->detail[2] = data[6].i; /* ARGB0 */
1.952 - ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
1.953 - break;
1.954 + vertex->detail[0] = data[4].i; /* U0 */
1.955 + vertex->detail[1] = data[5].i; /* V0 */
1.956 + vertex->detail[2] = data[6].i; /* ARGB0 */
1.957 + ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
1.958 + break;
1.959 case TA_VERTEX_TEX_UV16_SPEC_PACKED_MOD:
1.960 - vertex->detail[2] = data[7].i; /* ARGB0 */
1.961 - /* Fallthrough */
1.962 + vertex->detail[2] = data[7].i; /* ARGB0 */
1.963 + /* Fallthrough */
1.964 case TA_VERTEX_TEX_UV16_PACKED_MOD:
1.965 - vertex->detail[0] = data[4].i; /* UV0 */
1.966 - vertex->detail[1] = data[6].i; /* ARGB0 */
1.967 - ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
1.968 - break;
1.969 + vertex->detail[0] = data[4].i; /* UV0 */
1.970 + vertex->detail[1] = data[6].i; /* ARGB0 */
1.971 + ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
1.972 + break;
1.973
1.974 case TA_VERTEX_TEX_SPEC_INTENSITY_MOD:
1.975 - vertex->detail[3] = parse_intensity_colour( ta_status.intensity1, data[7].f );
1.976 - /* Fallthrough */
1.977 + vertex->detail[3] = parse_intensity_colour( ta_status.intensity1, data[7].f );
1.978 + /* Fallthrough */
1.979 case TA_VERTEX_TEX_INTENSITY_MOD:
1.980 - vertex->detail[0] = data[4].i; /* U0 */
1.981 - vertex->detail[1] = data[5].i; /* V0 */
1.982 - vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[6].f );
1.983 - ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
1.984 - break;
1.985 + vertex->detail[0] = data[4].i; /* U0 */
1.986 + vertex->detail[1] = data[5].i; /* V0 */
1.987 + vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[6].f );
1.988 + ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
1.989 + break;
1.990 case TA_VERTEX_TEX_UV16_SPEC_INTENSITY_MOD:
1.991 - vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[7].f );
1.992 - /* Fallthrough */
1.993 + vertex->detail[2] = parse_intensity_colour( ta_status.intensity1, data[7].f );
1.994 + /* Fallthrough */
1.995 case TA_VERTEX_TEX_UV16_INTENSITY_MOD:
1.996 - vertex->detail[0] = data[4].i; /* UV0 */
1.997 - vertex->detail[1] = parse_intensity_colour( ta_status.intensity1, data[6].f );
1.998 - ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
1.999 - break;
1.1000 -
1.1001 + vertex->detail[0] = data[4].i; /* UV0 */
1.1002 + vertex->detail[1] = parse_intensity_colour( ta_status.intensity1, data[6].f );
1.1003 + ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
1.1004 + break;
1.1005 +
1.1006 case TA_VERTEX_SPRITE:
1.1007 case TA_VERTEX_TEX_SPRITE:
1.1008 case TA_VERTEX_MOD_VOLUME:
1.1009 case TA_VERTEX_LISTLESS:
1.1010 - vertex++;
1.1011 - vertex->x = data[4].f;
1.1012 - vertex->y = data[5].f;
1.1013 - vertex->z = data[6].f;
1.1014 - vertex++;
1.1015 - vertex->x = data[7].f;
1.1016 - ta_status.vertex_count += 2;
1.1017 - ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
1.1018 - break;
1.1019 + vertex++;
1.1020 + vertex->x = data[4].f;
1.1021 + vertex->y = data[5].f;
1.1022 + vertex->z = data[6].f;
1.1023 + vertex++;
1.1024 + vertex->x = data[7].f;
1.1025 + ta_status.vertex_count += 2;
1.1026 + ta_status.state = STATE_EXPECT_VERTEX_BLOCK2;
1.1027 + break;
1.1028 }
1.1029 ta_status.vertex_count++;
1.1030 }
1.1031 @@ -945,92 +945,92 @@
1.1032
1.1033 switch( ta_status.current_vertex_type ) {
1.1034 case TA_VERTEX_TEX_SPEC_FLOAT:
1.1035 - vertex->detail[3] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
1.1036 - /* Fallthrough */
1.1037 + vertex->detail[3] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
1.1038 + /* Fallthrough */
1.1039 case TA_VERTEX_TEX_FLOAT:
1.1040 - vertex->detail[2] = parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );
1.1041 - break;
1.1042 + vertex->detail[2] = parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );
1.1043 + break;
1.1044 case TA_VERTEX_TEX_UV16_SPEC_FLOAT:
1.1045 - vertex->detail[2] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
1.1046 - /* Fallthrough */
1.1047 + vertex->detail[2] = parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
1.1048 + /* Fallthrough */
1.1049 case TA_VERTEX_TEX_UV16_FLOAT:
1.1050 - vertex->detail[1] = parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );
1.1051 - break;
1.1052 + vertex->detail[1] = parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );
1.1053 + break;
1.1054 case TA_VERTEX_TEX_PACKED_MOD:
1.1055 - vertex->detail[3] = data[0].i; /* U1 */
1.1056 - vertex->detail[4] = data[1].i; /* V1 */
1.1057 - vertex->detail[5] = data[2].i; /* ARGB1 */
1.1058 - break;
1.1059 + vertex->detail[3] = data[0].i; /* U1 */
1.1060 + vertex->detail[4] = data[1].i; /* V1 */
1.1061 + vertex->detail[5] = data[2].i; /* ARGB1 */
1.1062 + break;
1.1063 case TA_VERTEX_TEX_SPEC_PACKED_MOD:
1.1064 - vertex->detail[4] = data[0].i; /* U1 */
1.1065 - vertex->detail[5] = data[1].i; /* V1 */
1.1066 - vertex->detail[6] = data[2].i; /* ARGB1 */
1.1067 - vertex->detail[7] = data[3].i; /* ARGB1 */
1.1068 - break;
1.1069 + vertex->detail[4] = data[0].i; /* U1 */
1.1070 + vertex->detail[5] = data[1].i; /* V1 */
1.1071 + vertex->detail[6] = data[2].i; /* ARGB1 */
1.1072 + vertex->detail[7] = data[3].i; /* ARGB1 */
1.1073 + break;
1.1074 case TA_VERTEX_TEX_UV16_PACKED_MOD:
1.1075 - vertex->detail[2] = data[0].i; /* UV1 */
1.1076 - vertex->detail[3] = data[2].i; /* ARGB1 */
1.1077 - break;
1.1078 + vertex->detail[2] = data[0].i; /* UV1 */
1.1079 + vertex->detail[3] = data[2].i; /* ARGB1 */
1.1080 + break;
1.1081 case TA_VERTEX_TEX_UV16_SPEC_PACKED_MOD:
1.1082 - vertex->detail[3] = data[0].i; /* UV1 */
1.1083 - vertex->detail[4] = data[2].i; /* ARGB1 */
1.1084 - vertex->detail[5] = data[3].i; /* ARGB1 */
1.1085 - break;
1.1086 + vertex->detail[3] = data[0].i; /* UV1 */
1.1087 + vertex->detail[4] = data[2].i; /* ARGB1 */
1.1088 + vertex->detail[5] = data[3].i; /* ARGB1 */
1.1089 + break;
1.1090
1.1091 case TA_VERTEX_TEX_INTENSITY_MOD:
1.1092 - vertex->detail[3] = data[0].i; /* U1 */
1.1093 - vertex->detail[4] = data[1].i; /* V1 */
1.1094 - vertex->detail[5] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */
1.1095 - break;
1.1096 + vertex->detail[3] = data[0].i; /* U1 */
1.1097 + vertex->detail[4] = data[1].i; /* V1 */
1.1098 + vertex->detail[5] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */
1.1099 + break;
1.1100 case TA_VERTEX_TEX_SPEC_INTENSITY_MOD:
1.1101 - vertex->detail[4] = data[0].i; /* U1 */
1.1102 - vertex->detail[5] = data[1].i; /* V1 */
1.1103 - vertex->detail[6] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */
1.1104 - vertex->detail[7] = parse_intensity_colour( ta_status.intensity2, data[3].f ); /* ARGB1 */
1.1105 - break;
1.1106 + vertex->detail[4] = data[0].i; /* U1 */
1.1107 + vertex->detail[5] = data[1].i; /* V1 */
1.1108 + vertex->detail[6] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */
1.1109 + vertex->detail[7] = parse_intensity_colour( ta_status.intensity2, data[3].f ); /* ARGB1 */
1.1110 + break;
1.1111 case TA_VERTEX_TEX_UV16_INTENSITY_MOD:
1.1112 - vertex->detail[2] = data[0].i; /* UV1 */
1.1113 - vertex->detail[3] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */
1.1114 - break;
1.1115 + vertex->detail[2] = data[0].i; /* UV1 */
1.1116 + vertex->detail[3] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */
1.1117 + break;
1.1118 case TA_VERTEX_TEX_UV16_SPEC_INTENSITY_MOD:
1.1119 - vertex->detail[3] = data[0].i; /* UV1 */
1.1120 - vertex->detail[4] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */
1.1121 - vertex->detail[5] = parse_intensity_colour( ta_status.intensity2, data[3].f ); /* ARGB1 */
1.1122 - break;
1.1123 + vertex->detail[3] = data[0].i; /* UV1 */
1.1124 + vertex->detail[4] = parse_intensity_colour( ta_status.intensity2, data[2].f ); /* ARGB1 */
1.1125 + vertex->detail[5] = parse_intensity_colour( ta_status.intensity2, data[3].f ); /* ARGB1 */
1.1126 + break;
1.1127
1.1128 case TA_VERTEX_SPRITE:
1.1129 - vertex->y = data[0].f;
1.1130 - vertex->z = data[1].f;
1.1131 - vertex++;
1.1132 - ta_status.vertex_count++;
1.1133 - vertex->x = data[2].f;
1.1134 - vertex->y = data[3].f;
1.1135 - vertex->z = 0;
1.1136 - vertex->detail[0] = 0;
1.1137 - ta_status.poly_vertex[0].detail[0] = 0;
1.1138 - ta_status.poly_vertex[1].detail[0] = 0;
1.1139 - break;
1.1140 + vertex->y = data[0].f;
1.1141 + vertex->z = data[1].f;
1.1142 + vertex++;
1.1143 + ta_status.vertex_count++;
1.1144 + vertex->x = data[2].f;
1.1145 + vertex->y = data[3].f;
1.1146 + vertex->z = 0;
1.1147 + vertex->detail[0] = 0;
1.1148 + ta_status.poly_vertex[0].detail[0] = 0;
1.1149 + ta_status.poly_vertex[1].detail[0] = 0;
1.1150 + break;
1.1151 case TA_VERTEX_TEX_SPRITE:
1.1152 - vertex->y = data[0].f;
1.1153 - vertex->z = data[1].f;
1.1154 - vertex++;
1.1155 - ta_status.vertex_count++;
1.1156 - vertex->x = data[2].f;
1.1157 - vertex->y = data[3].f;
1.1158 - vertex->z = 0;
1.1159 - vertex->detail[0] = 0;
1.1160 - vertex->detail[1] = 0;
1.1161 - ta_status.poly_vertex[0].detail[0] = data[5].i;
1.1162 - ta_status.poly_vertex[0].detail[1] = 0;
1.1163 - ta_status.poly_vertex[1].detail[0] = data[6].i;
1.1164 - ta_status.poly_vertex[1].detail[1] = 0;
1.1165 - ta_status.poly_vertex[2].detail[0] = data[7].i;
1.1166 - break;
1.1167 + vertex->y = data[0].f;
1.1168 + vertex->z = data[1].f;
1.1169 + vertex++;
1.1170 + ta_status.vertex_count++;
1.1171 + vertex->x = data[2].f;
1.1172 + vertex->y = data[3].f;
1.1173 + vertex->z = 0;
1.1174 + vertex->detail[0] = 0;
1.1175 + vertex->detail[1] = 0;
1.1176 + ta_status.poly_vertex[0].detail[0] = data[5].i;
1.1177 + ta_status.poly_vertex[0].detail[1] = 0;
1.1178 + ta_status.poly_vertex[1].detail[0] = data[6].i;
1.1179 + ta_status.poly_vertex[1].detail[1] = 0;
1.1180 + ta_status.poly_vertex[2].detail[0] = data[7].i;
1.1181 + break;
1.1182 case TA_VERTEX_MOD_VOLUME:
1.1183 case TA_VERTEX_LISTLESS:
1.1184 - vertex->y = data[0].f;
1.1185 - vertex->z = data[1].f;
1.1186 - break;
1.1187 + vertex->y = data[0].f;
1.1188 + vertex->z = data[1].f;
1.1189 + break;
1.1190 }
1.1191 ta_status.state = STATE_IN_POLYGON;
1.1192 }
1.1193 @@ -1043,120 +1043,120 @@
1.1194
1.1195 switch( ta_status.state ) {
1.1196 case STATE_ERROR:
1.1197 - /* Fatal error raised - stop processing until reset */
1.1198 - return;
1.1199 + /* Fatal error raised - stop processing until reset */
1.1200 + return;
1.1201
1.1202 case STATE_EXPECT_POLY_BLOCK2:
1.1203 - /* This is always a pair of floating-point colours */
1.1204 - ta_status.intensity1 =
1.1205 - parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );
1.1206 - ta_status.intensity2 =
1.1207 - parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
1.1208 - ta_status.state = STATE_IN_LIST;
1.1209 - break;
1.1210 + /* This is always a pair of floating-point colours */
1.1211 + ta_status.intensity1 =
1.1212 + parse_float_colour( data[0].f, data[1].f, data[2].f, data[3].f );
1.1213 + ta_status.intensity2 =
1.1214 + parse_float_colour( data[4].f, data[5].f, data[6].f, data[7].f );
1.1215 + ta_status.state = STATE_IN_LIST;
1.1216 + break;
1.1217
1.1218 case STATE_EXPECT_VERTEX_BLOCK2:
1.1219 - ta_parse_vertex_block2( data );
1.1220 - if( ta_status.vertex_count == ta_status.max_vertex ) {
1.1221 - ta_split_polygon();
1.1222 - }
1.1223 - break;
1.1224 + ta_parse_vertex_block2( data );
1.1225 + if( ta_status.vertex_count == ta_status.max_vertex ) {
1.1226 + ta_split_polygon();
1.1227 + }
1.1228 + break;
1.1229
1.1230 case STATE_EXPECT_END_VERTEX_BLOCK2:
1.1231 - ta_parse_vertex_block2( data );
1.1232 - if( ta_status.vertex_count < 3 ) {
1.1233 - ta_bad_input_error();
1.1234 - } else {
1.1235 - ta_commit_polygon();
1.1236 - }
1.1237 - ta_status.vertex_count = 0;
1.1238 - ta_status.poly_parity = 0;
1.1239 - ta_status.state = STATE_IN_LIST;
1.1240 - break;
1.1241 + ta_parse_vertex_block2( data );
1.1242 + if( ta_status.vertex_count < 3 ) {
1.1243 + ta_bad_input_error();
1.1244 + } else {
1.1245 + ta_commit_polygon();
1.1246 + }
1.1247 + ta_status.vertex_count = 0;
1.1248 + ta_status.poly_parity = 0;
1.1249 + ta_status.state = STATE_IN_LIST;
1.1250 + break;
1.1251 case STATE_IN_LIST:
1.1252 case STATE_IN_POLYGON:
1.1253 case STATE_IDLE:
1.1254 - switch( TA_CMD( data->i ) ) {
1.1255 - case TA_CMD_END_LIST:
1.1256 - if( ta_status.state == STATE_IN_POLYGON ) {
1.1257 - ta_bad_input_error();
1.1258 - ta_end_list();
1.1259 - ta_status.state = STATE_ERROR; /* Abort further processing */
1.1260 - } else {
1.1261 - ta_end_list();
1.1262 - }
1.1263 - break;
1.1264 - case TA_CMD_CLIP:
1.1265 - if( ta_status.state == STATE_IN_POLYGON ) {
1.1266 - ta_bad_input_error();
1.1267 - ta_status.accept_vertexes = FALSE;
1.1268 - /* Enter stuffed up mode */
1.1269 - }
1.1270 - ta_status.clip.x1 = data[4].i & 0x3F;
1.1271 - ta_status.clip.y1 = data[5].i & 0x0F;
1.1272 - ta_status.clip.x2 = data[6].i & 0x3F;
1.1273 - ta_status.clip.y2 = data[7].i & 0x0F;
1.1274 - if( ta_status.clip.x2 >= ta_status.width )
1.1275 - ta_status.clip.x2 = ta_status.width - 1;
1.1276 - if( ta_status.clip.y2 >= ta_status.height )
1.1277 - ta_status.clip.y2 = ta_status.height - 1;
1.1278 - break;
1.1279 - case TA_CMD_POLYGON_CONTEXT:
1.1280 - if( ta_status.state == STATE_IDLE ) {
1.1281 - ta_init_list( TA_POLYCMD_LISTTYPE( data->i ) );
1.1282 - }
1.1283 -
1.1284 - if( ta_status.vertex_count != 0 ) {
1.1285 - /* Error, and not a very well handled one either */
1.1286 - ta_bad_input_error();
1.1287 - ta_status.accept_vertexes = FALSE;
1.1288 - } else {
1.1289 - if( TA_IS_MODIFIER_LIST( ta_status.current_list_type ) ) {
1.1290 - ta_parse_modifier_context(data);
1.1291 - } else {
1.1292 - ta_parse_polygon_context(data);
1.1293 - }
1.1294 - }
1.1295 - break;
1.1296 - case TA_CMD_SPRITE_CONTEXT:
1.1297 - if( ta_status.state == STATE_IDLE ) {
1.1298 - ta_init_list( TA_POLYCMD_LISTTYPE( data->i ) );
1.1299 - }
1.1300 + switch( TA_CMD( data->i ) ) {
1.1301 + case TA_CMD_END_LIST:
1.1302 + if( ta_status.state == STATE_IN_POLYGON ) {
1.1303 + ta_bad_input_error();
1.1304 + ta_end_list();
1.1305 + ta_status.state = STATE_ERROR; /* Abort further processing */
1.1306 + } else {
1.1307 + ta_end_list();
1.1308 + }
1.1309 + break;
1.1310 + case TA_CMD_CLIP:
1.1311 + if( ta_status.state == STATE_IN_POLYGON ) {
1.1312 + ta_bad_input_error();
1.1313 + ta_status.accept_vertexes = FALSE;
1.1314 + /* Enter stuffed up mode */
1.1315 + }
1.1316 + ta_status.clip.x1 = data[4].i & 0x3F;
1.1317 + ta_status.clip.y1 = data[5].i & 0x0F;
1.1318 + ta_status.clip.x2 = data[6].i & 0x3F;
1.1319 + ta_status.clip.y2 = data[7].i & 0x0F;
1.1320 + if( ta_status.clip.x2 >= ta_status.width )
1.1321 + ta_status.clip.x2 = ta_status.width - 1;
1.1322 + if( ta_status.clip.y2 >= ta_status.height )
1.1323 + ta_status.clip.y2 = ta_status.height - 1;
1.1324 + break;
1.1325 + case TA_CMD_POLYGON_CONTEXT:
1.1326 + if( ta_status.state == STATE_IDLE ) {
1.1327 + ta_init_list( TA_POLYCMD_LISTTYPE( data->i ) );
1.1328 + }
1.1329
1.1330 - if( ta_status.vertex_count != 0 ) {
1.1331 - ta_fill_vertexes();
1.1332 - ta_commit_polygon();
1.1333 - }
1.1334 + if( ta_status.vertex_count != 0 ) {
1.1335 + /* Error, and not a very well handled one either */
1.1336 + ta_bad_input_error();
1.1337 + ta_status.accept_vertexes = FALSE;
1.1338 + } else {
1.1339 + if( TA_IS_MODIFIER_LIST( ta_status.current_list_type ) ) {
1.1340 + ta_parse_modifier_context(data);
1.1341 + } else {
1.1342 + ta_parse_polygon_context(data);
1.1343 + }
1.1344 + }
1.1345 + break;
1.1346 + case TA_CMD_SPRITE_CONTEXT:
1.1347 + if( ta_status.state == STATE_IDLE ) {
1.1348 + ta_init_list( TA_POLYCMD_LISTTYPE( data->i ) );
1.1349 + }
1.1350
1.1351 - ta_parse_sprite_context(data);
1.1352 - break;
1.1353 - case TA_CMD_VERTEX:
1.1354 - ta_status.state = STATE_IN_POLYGON;
1.1355 - ta_parse_vertex(data);
1.1356 -
1.1357 - if( ta_status.state == STATE_EXPECT_VERTEX_BLOCK2 ) {
1.1358 - if( TA_IS_END_VERTEX(data[0].i) ) {
1.1359 - ta_status.state = STATE_EXPECT_END_VERTEX_BLOCK2;
1.1360 - }
1.1361 - } else if( TA_IS_END_VERTEX(data->i) ) {
1.1362 - if( ta_status.vertex_count < 3 ) {
1.1363 - ta_bad_input_error();
1.1364 - } else {
1.1365 - ta_commit_polygon();
1.1366 - }
1.1367 - ta_status.vertex_count = 0;
1.1368 - ta_status.poly_parity = 0;
1.1369 - ta_status.state = STATE_IN_LIST;
1.1370 - } else if( ta_status.vertex_count == ta_status.max_vertex ) {
1.1371 - ta_split_polygon();
1.1372 - }
1.1373 - break;
1.1374 - default:
1.1375 - if( ta_status.state == STATE_IN_POLYGON ) {
1.1376 - ta_bad_input_error();
1.1377 - }
1.1378 - }
1.1379 - break;
1.1380 + if( ta_status.vertex_count != 0 ) {
1.1381 + ta_fill_vertexes();
1.1382 + ta_commit_polygon();
1.1383 + }
1.1384 +
1.1385 + ta_parse_sprite_context(data);
1.1386 + break;
1.1387 + case TA_CMD_VERTEX:
1.1388 + ta_status.state = STATE_IN_POLYGON;
1.1389 + ta_parse_vertex(data);
1.1390 +
1.1391 + if( ta_status.state == STATE_EXPECT_VERTEX_BLOCK2 ) {
1.1392 + if( TA_IS_END_VERTEX(data[0].i) ) {
1.1393 + ta_status.state = STATE_EXPECT_END_VERTEX_BLOCK2;
1.1394 + }
1.1395 + } else if( TA_IS_END_VERTEX(data->i) ) {
1.1396 + if( ta_status.vertex_count < 3 ) {
1.1397 + ta_bad_input_error();
1.1398 + } else {
1.1399 + ta_commit_polygon();
1.1400 + }
1.1401 + ta_status.vertex_count = 0;
1.1402 + ta_status.poly_parity = 0;
1.1403 + ta_status.state = STATE_IN_LIST;
1.1404 + } else if( ta_status.vertex_count == ta_status.max_vertex ) {
1.1405 + ta_split_polygon();
1.1406 + }
1.1407 + break;
1.1408 + default:
1.1409 + if( ta_status.state == STATE_IN_POLYGON ) {
1.1410 + ta_bad_input_error();
1.1411 + }
1.1412 + }
1.1413 + break;
1.1414 }
1.1415
1.1416 }
1.1417 @@ -1175,11 +1175,11 @@
1.1418 void pvr2_ta_write( unsigned char *buf, uint32_t length )
1.1419 {
1.1420 if( ta_status.debug_output ) {
1.1421 - fwrite_dump32( (uint32_t *)buf, length, stderr );
1.1422 + fwrite_dump32( (uint32_t *)buf, length, stderr );
1.1423 }
1.1424
1.1425 for( ; length >=32; length -= 32 ) {
1.1426 - pvr2_ta_process_block( buf );
1.1427 - buf += 32;
1.1428 + pvr2_ta_process_block( buf );
1.1429 + buf += 32;
1.1430 }
1.1431 }
.