Search
lxdream.org :: lxdream/src/pvr2/ta.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/ta.c
changeset 100:995e42e96cc9
next103:9b9cfc5855e0
author nkeynes
date Wed Feb 15 13:11:50 2006 +0000 (17 years ago)
permissions -rw-r--r--
last change Split pvr2.c out to separate files for TA and renderer, minor renames
change pvrdma to use mem_copy_to_sh4
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/pvr2/ta.c Wed Feb 15 13:11:50 2006 +0000
1.3 @@ -0,0 +1,99 @@
1.4 +/**
1.5 + * $Id: ta.c,v 1.1 2006-02-15 13:11:46 nkeynes Exp $
1.6 + *
1.7 + * PVR2 Tile Accelerator support. In principle this does a lot more work
1.8 + * than is currently implemented - we cheat. A lot.
1.9 + *
1.10 + * Copyright (c) 2005 Nathan Keynes.
1.11 + *
1.12 + * This program is free software; you can redistribute it and/or modify
1.13 + * it under the terms of the GNU General Public License as published by
1.14 + * the Free Software Foundation; either version 2 of the License, or
1.15 + * (at your option) any later version.
1.16 + *
1.17 + * This program is distributed in the hope that it will be useful,
1.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.20 + * GNU General Public License for more details.
1.21 + */
1.22 +
1.23 +#include "pvr2/pvr2.h"
1.24 +#include "asic.h"
1.25 +#include "dream.h"
1.26 +
1.27 +/** Tile Accelerator */
1.28 +
1.29 +struct tacmd {
1.30 + uint32_t command;
1.31 + uint32_t param1;
1.32 + uint32_t param2;
1.33 + uint32_t texture;
1.34 + float alpha;
1.35 + float red;
1.36 + float green;
1.37 + float blue;
1.38 +};
1.39 +
1.40 +struct vertex_type1 {
1.41 + uint32_t command;
1.42 + float x, y, z;
1.43 + uint32_t blank, blank2;
1.44 + uint32_t col;
1.45 + float f;
1.46 +};
1.47 +
1.48 +/**
1.49 + * (Re)initialize the tile accelerator in preparation for the next scene.
1.50 + * Normally called immediately before commencing polygon transmission.
1.51 + */
1.52 +void pvr2_ta_init( void )
1.53 +{
1.54 +
1.55 +}
1.56 +
1.57 +char pvr2ta_remainder[8];
1.58 +unsigned int pvr2_last_poly_type = 0;
1.59 +
1.60 +/**
1.61 + * Write a block of data to the tile accelerator, adding the data to the
1.62 + * current scene. We don't make any particular attempt to interpret the data
1.63 + * at this stage, deferring that until render time.
1.64 + */
1.65 +void pvr2_ta_write( char *buf, uint32_t length )
1.66 +{
1.67 + int i;
1.68 + struct tacmd *cmd_list = (struct tacmd *)buf;
1.69 + int count = length >> 5;
1.70 + for( i=0; i<count; i++ ){
1.71 + unsigned int type = (cmd_list[i].command >> 24) & 0xFF;
1.72 + if( type == 0xE0 || type == 0xF0 ) {
1.73 + struct vertex_type1 *vert = (struct vertex_type1 *)&cmd_list[i];
1.74 + DEBUG( "PVR2 vrt: %f %f %f %08X %08X %08X %f", vert->x, vert->y, vert->z, vert->blank, vert->blank2, vert->col, vert->f );
1.75 + } else {
1.76 + DEBUG( "PVR2 cmd: %08X %08X %08X %08X %08X %08X %08X %08X", cmd_list[i].command, cmd_list[i].param1, cmd_list[i].param2, cmd_list[i].texture, cmd_list[i].alpha, cmd_list[i].red, cmd_list[i].green, cmd_list[i].blue );
1.77 + }
1.78 + if( type == 0 ) {
1.79 + /* End of list */
1.80 + switch( pvr2_last_poly_type ) {
1.81 + case 0x80: /* Opaque polys */
1.82 + asic_event( EVENT_PVR_OPAQUE_DONE );
1.83 + break;
1.84 + case 0x81: /* Opaque poly modifier */
1.85 + asic_event( EVENT_PVR_OPAQUEMOD_DONE );
1.86 + break;
1.87 + case 0x82: /* Transparent polys */
1.88 + asic_event( EVENT_PVR_TRANS_DONE );
1.89 + break;
1.90 + case 0x83: /* Transparent poly modifier */
1.91 + asic_event( EVENT_PVR_TRANSMOD_DONE );
1.92 + break;
1.93 + case 0x84: /* Punchthrough */
1.94 + asic_event( EVENT_PVR_PUNCHOUT_DONE );
1.95 + break;
1.96 + }
1.97 + pvr2_last_poly_type = 0;
1.98 + } else if( type >= 0x80 && type <= 0x84 ) {
1.99 + pvr2_last_poly_type = type;
1.100 + }
1.101 + }
1.102 +}
.