Search
lxdream.org :: lxdream/src/pvr2/ta.c
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 (15 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
view annotate diff log raw
     1 /**
     2  * $Id: ta.c,v 1.1 2006-02-15 13:11:46 nkeynes Exp $
     3  *
     4  * PVR2 Tile Accelerator support. In principle this does a lot more work
     5  * than is currently implemented - we cheat. A lot.
     6  *
     7  * Copyright (c) 2005 Nathan Keynes.
     8  *
     9  * This program is free software; you can redistribute it and/or modify
    10  * it under the terms of the GNU General Public License as published by
    11  * the Free Software Foundation; either version 2 of the License, or
    12  * (at your option) any later version.
    13  *
    14  * This program is distributed in the hope that it will be useful,
    15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    17  * GNU General Public License for more details.
    18  */
    20 #include "pvr2/pvr2.h"
    21 #include "asic.h"
    22 #include "dream.h"
    24 /** Tile Accelerator */
    26 struct tacmd {
    27     uint32_t command;
    28     uint32_t param1;
    29     uint32_t param2;
    30     uint32_t texture;
    31     float alpha;
    32     float red;
    33     float green;
    34     float blue;
    35 };
    37 struct vertex_type1 {
    38     uint32_t command;
    39     float x, y, z;
    40     uint32_t blank, blank2;
    41     uint32_t col;
    42     float f;
    43 };
    45 /**
    46  * (Re)initialize the tile accelerator in preparation for the next scene.
    47  * Normally called immediately before commencing polygon transmission.
    48  */
    49 void pvr2_ta_init( void )
    50 {
    52 }
    54 char pvr2ta_remainder[8];
    55 unsigned int pvr2_last_poly_type = 0;
    57 /**
    58  * Write a block of data to the tile accelerator, adding the data to the 
    59  * current scene. We don't make any particular attempt to interpret the data
    60  * at this stage, deferring that until render time.
    61  */
    62 void pvr2_ta_write( char *buf, uint32_t length )
    63 {
    64     int i;
    65     struct tacmd *cmd_list = (struct tacmd *)buf;
    66     int count = length >> 5;
    67     for( i=0; i<count; i++ ){
    68 	unsigned int type = (cmd_list[i].command >> 24) & 0xFF;
    69 	if( type == 0xE0 || type == 0xF0 ) {
    70 	    struct vertex_type1 *vert = (struct vertex_type1 *)&cmd_list[i];
    71 	    DEBUG( "PVR2 vrt: %f %f %f %08X %08X %08X %f", vert->x, vert->y, vert->z, vert->blank, vert->blank2, vert->col, vert->f );
    72 	} else {
    73 	    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 );
    74 	}
    75 	if( type == 0 ) {
    76 	    /* End of list */
    77 	    switch( pvr2_last_poly_type ) {
    78 	    case 0x80: /* Opaque polys */
    79 		asic_event( EVENT_PVR_OPAQUE_DONE );
    80 		break;
    81 	    case 0x81: /* Opaque poly modifier */
    82 		asic_event( EVENT_PVR_OPAQUEMOD_DONE );
    83 		break;
    84 	    case 0x82: /* Transparent polys */
    85 		asic_event( EVENT_PVR_TRANS_DONE );
    86 		break;
    87 	    case 0x83: /* Transparent poly modifier */
    88 		asic_event( EVENT_PVR_TRANSMOD_DONE );
    89 		break;
    90 	    case 0x84: /* Punchthrough */
    91 		asic_event( EVENT_PVR_PUNCHOUT_DONE );
    92 		break;
    93 	    }
    94 	    pvr2_last_poly_type = 0;
    95 	} else if( type >= 0x80 && type <= 0x84 ) {
    96 	    pvr2_last_poly_type = type;
    97 	}
    98     }
    99 }
.