Search
lxdream.org :: lxdream/test/pvr.h
lxdream 0.9.1
released Jun 29
Download Now
filename test/pvr.h
changeset 561:533f6b478071
prev213:da6b1904f67b
author nkeynes
date Tue Jan 01 05:08:38 2008 +0000 (12 years ago)
branchlxdream-mmu
permissions -rw-r--r--
last change Enable Id keyword on all source files
file annotate diff log raw
nkeynes@185
     1
/**
nkeynes@561
     2
 * $Id$
nkeynes@185
     3
 * 
nkeynes@185
     4
 * PVR support code
nkeynes@185
     5
 *
nkeynes@185
     6
 * Copyright (c) 2006 Nathan Keynes.
nkeynes@185
     7
 *
nkeynes@185
     8
 * This program is free software; you can redistribute it and/or modify
nkeynes@185
     9
 * it under the terms of the GNU General Public License as published by
nkeynes@185
    10
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@185
    11
 * (at your option) any later version.
nkeynes@185
    12
 *
nkeynes@185
    13
 * This program is distributed in the hope that it will be useful,
nkeynes@185
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@185
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@185
    16
 * GNU General Public License for more details.
nkeynes@185
    17
 */
nkeynes@185
    18
nkeynes@185
    19
#define PVR_VRAM_BASE 0xA5000000
nkeynes@185
    20
#define PVR_VRAM64_BASE 0xA4000000
nkeynes@185
    21
nkeynes@185
    22
nkeynes@185
    23
#define TA_PIXFMT_RGB555   0
nkeynes@185
    24
#define TA_PIXFMT_RGB565   1
nkeynes@185
    25
#define TA_PIXFMT_ARGB4444 2
nkeynes@185
    26
#define TA_PIXFMT_ARGB1555 3
nkeynes@185
    27
#define TA_PIXFMT_RGB888   5
nkeynes@185
    28
#define TA_PIXFMT_ARGB8888 6
nkeynes@185
    29
#define TA_PIXFMT_DITHER   8
nkeynes@185
    30
nkeynes@185
    31
#define TA_CMD_POLYGON                    0x80000000
nkeynes@185
    32
#define TA_CMD_MODIFIER                   0x80000000
nkeynes@185
    33
#define TA_CMD_POLYGON_TYPE_OPAQUE        (0<<24)
nkeynes@185
    34
#define TA_CMD_MODIFIER_TYPE_OPAQUE       (1<<24)
nkeynes@185
    35
#define TA_CMD_POLYGON_TYPE_TRANSPARENT   (2<<24)
nkeynes@185
    36
#define TA_CMD_MODIFIER_TYPE_TRANSPARENT  (3<<24)
nkeynes@185
    37
#define TA_CMD_POLYGON_TYPE_PUNCHTHRU     (4<<24)
nkeynes@185
    38
#define TA_CMD_POLYGON_SUBLIST            0x00800000
nkeynes@185
    39
#define TA_CMD_POLYGON_STRIPLENGTH_1      (0<<18)
nkeynes@185
    40
#define TA_CMD_POLYGON_STRIPLENGTH_2      (1<<18)
nkeynes@185
    41
#define TA_CMD_POLYGON_STRIPLENGTH_4      (2<<18)
nkeynes@185
    42
#define TA_CMD_POLYGON_STRIPLENGTH_6      (3<<18)
nkeynes@185
    43
#define TA_CMD_POLYGON_USER_CLIP_INSIDE   0x00020000
nkeynes@185
    44
#define TA_CMD_POLYGON_USER_CLIP_OUTSIDE  0x00030000
nkeynes@185
    45
#define TA_CMD_POLYGON_AFFECTED_BY_MODIFIER  0x00000080
nkeynes@185
    46
#define TA_CMD_POLYGON_CHEAP_SHADOW_MODIFIER 0x00000000
nkeynes@185
    47
#define TA_CMD_POLYGON_NORMAL_MODIFIER       0x00000040
nkeynes@185
    48
#define TA_CMD_POLYGON_PACKED_COLOUR      (0<<4)
nkeynes@185
    49
#define TA_CMD_POLYGON_FLOAT_COLOUR       (1<<4)
nkeynes@185
    50
#define TA_CMD_POLYGON_INTENSITY          (2<<4)
nkeynes@185
    51
#define TA_CMD_POLYGON_PREVFACE_INTENSITY (3<<4)
nkeynes@185
    52
#define TA_CMD_POLYGON_TEXTURED           0x00000008
nkeynes@185
    53
#define TA_CMD_POLYGON_SPECULAR_HIGHLIGHT 0x00000004
nkeynes@185
    54
#define TA_CMD_POLYGON_GOURAUD_SHADING    0x00000002
nkeynes@185
    55
#define TA_CMD_POLYGON_16BIT_UV           0x00000001
nkeynes@185
    56
nkeynes@185
    57
#define TA_POLYMODE1_Z_NEVER        (0<<29)
nkeynes@185
    58
#define TA_POLYMODE1_Z_LESS         (1<<29)
nkeynes@185
    59
#define TA_POLYMODE1_Z_EQUAL        (2<<29)
nkeynes@185
    60
#define TA_POLYMODE1_Z_LESSEQUAL    (3<<29)
nkeynes@185
    61
#define TA_POLYMODE1_Z_GREATER      (4<<29)
nkeynes@185
    62
#define TA_POLYMODE1_Z_NOTEQUAL     (5<<29)
nkeynes@185
    63
#define TA_POLYMODE1_Z_GREATEREQUAL (6<<29)
nkeynes@185
    64
#define TA_POLYMODE1_Z_ALWAYS       (7<<29)
nkeynes@185
    65
#define TA_POLYMODE1_CULL_SMALL     (1<<27)
nkeynes@185
    66
#define TA_POLYMODE1_CULL_CCW       (2<<27)
nkeynes@185
    67
#define TA_POLYMODE1_CULL_CW        (3<<27)
nkeynes@185
    68
#define TA_POLYMODE1_NO_Z_UPDATE    0x04000000
nkeynes@185
    69
nkeynes@185
    70
#define TA_POLYMODE2_BLEND_DEFAULT  (0x20<<24)
nkeynes@185
    71
#define TA_POLYMODE2_FOG_TABLE      (0<<22)
nkeynes@185
    72
#define TA_POLYMODE2_FOG_VERTEX     (1<<22)
nkeynes@185
    73
#define TA_POLYMODE2_FOG_DISABLED   (2<<22)
nkeynes@185
    74
#define TA_POLYMODE2_FOG_TABLE2     (3<<22)
nkeynes@185
    75
#define TA_POLYMODE2_CLAMP_COLOURS  0x00200000
nkeynes@185
    76
#define TA_POLYMODE2_ENABLE_ALPHA   0x00100000
nkeynes@185
    77
#define TA_POLYMODE2_DISABLE_TEXTURE_TRANSPARENCY 0x00080000
nkeynes@185
    78
#define TA_POLYMODE2_TEXTURE_FLIP_U   0x00080000
nkeynes@185
    79
#define TA_POLYMODE2_TEXTURE_FLIP_V   0x00040000
nkeynes@185
    80
#define TA_POLYMODE2_TEXTURE_CLAMP_U  0x00020000
nkeynes@185
    81
#define TA_POLYMODE2_TEXTURE_CLAMP_V  0x00010000
nkeynes@185
    82
#define TA_POLYMODE2_TRILINEAR_FILTER 0x00004000
nkeynes@185
    83
#define TA_POLYMODE2_BILINEAR_FILTER  0x00002000
nkeynes@185
    84
nkeynes@185
    85
#define TA_POLYMODE2_MIPMAP_D_0_25    (1<<8)
nkeynes@185
    86
#define TA_POLYMODE2_MIPMAP_D_0_50    (2<<8)
nkeynes@185
    87
#define TA_POLYMODE2_MIPMAP_D_0_75    (3<<8)
nkeynes@185
    88
#define TA_POLYMODE2_MIPMAP_D_1_00    (4<<8)
nkeynes@185
    89
#define TA_POLYMODE2_MIPMAP_D_1_25    (5<<8)
nkeynes@185
    90
#define TA_POLYMODE2_MIPMAP_D_1_50    (6<<8)
nkeynes@185
    91
#define TA_POLYMODE2_MIPMAP_D_1_75    (7<<8)
nkeynes@185
    92
#define TA_POLYMODE2_MIPMAP_D_2_00    (8<<8)
nkeynes@185
    93
#define TA_POLYMODE2_MIPMAP_D_2_25    (9<<8)
nkeynes@185
    94
#define TA_POLYMODE2_MIPMAP_D_2_50    (10<<8)
nkeynes@185
    95
#define TA_POLYMODE2_MIPMAP_D_2_75    (11<<8)
nkeynes@185
    96
#define TA_POLYMODE2_MIPMAP_D_3_00    (12<<8)
nkeynes@185
    97
#define TA_POLYMODE2_MIPMAP_D_3_25    (13<<8)
nkeynes@185
    98
#define TA_POLYMODE2_MIPMAP_D_3_50    (14<<8)
nkeynes@185
    99
#define TA_POLYMODE2_MIPMAP_D_3_75    (15<<8)
nkeynes@185
   100
#define TA_POLYMODE2_TEXTURE_REPLACE  (0<<6)
nkeynes@185
   101
#define TA_POLYMODE2_TEXTURE_MODULATE (1<<6)
nkeynes@185
   102
#define TA_POLYMODE2_TEXTURE_DECAL    (2<<6)
nkeynes@185
   103
#define TA_POLYMODE2_U_SIZE_8         (0<<3)
nkeynes@185
   104
#define TA_POLYMODE2_U_SIZE_16        (1<<3)
nkeynes@185
   105
#define TA_POLYMODE2_U_SIZE_32        (2<<3)
nkeynes@185
   106
#define TA_POLYMODE2_U_SIZE_64        (3<<3)
nkeynes@185
   107
#define TA_POLYMODE2_U_SIZE_128       (4<<3)
nkeynes@185
   108
#define TA_POLYMODE2_U_SIZE_256       (5<<3)
nkeynes@185
   109
#define TA_POLYMODE2_U_SIZE_512       (6<<3)
nkeynes@185
   110
#define TA_POLYMODE2_U_SIZE_1024      (7<<3)
nkeynes@185
   111
#define TA_POLYMODE2_V_SIZE_8         (0<<0)
nkeynes@185
   112
#define TA_POLYMODE2_V_SIZE_16        (1<<0)
nkeynes@185
   113
#define TA_POLYMODE2_V_SIZE_32        (2<<0)
nkeynes@185
   114
#define TA_POLYMODE2_V_SIZE_64        (3<<0)
nkeynes@185
   115
#define TA_POLYMODE2_V_SIZE_128       (4<<0)
nkeynes@185
   116
#define TA_POLYMODE2_V_SIZE_256       (5<<0)
nkeynes@185
   117
#define TA_POLYMODE2_V_SIZE_512       (6<<0)
nkeynes@185
   118
#define TA_POLYMODE2_V_SIZE_1024      (7<<0)
nkeynes@185
   119
#define TA_TEXTUREMODE_MIPMAP       0x80000000
nkeynes@185
   120
#define TA_TEXTUREMODE_VQ_COMPRESSION 0x40000000
nkeynes@185
   121
#define TA_TEXTUREMODE_ARGB1555     (0<<27)
nkeynes@185
   122
#define TA_TEXTUREMODE_RGB565       (1<<27)
nkeynes@185
   123
#define TA_TEXTUREMODE_ARGB4444     (2<<27)
nkeynes@185
   124
#define TA_TEXTUREMODE_YUV422       (3<<27)
nkeynes@185
   125
#define TA_TEXTUREMODE_BUMPMAP      (4<<27)
nkeynes@185
   126
#define TA_TEXTUREMODE_CLUT4        (5<<27)
nkeynes@185
   127
#define TA_TEXTUREMODE_CLUT8        (6<<27)
nkeynes@185
   128
#define TA_TEXTUREMODE_CLUTBANK8(n) ((n)<<25) /* 0-3  */
nkeynes@185
   129
#define TA_TEXTUREMODE_CLUTBANK4(n) ((n)<<21) /* 0-63 */
nkeynes@185
   130
#define TA_TEXTUREMODE_TWIDDLED     0x00000000
nkeynes@185
   131
#define TA_TEXTUREMODE_NON_TWIDDLED 0x04000000
nkeynes@185
   132
#define TA_TEXTUREMODE_ADDRESS(a)   ((((unsigned long)(void*)(a))&0x7fffff)>>3)
nkeynes@185
   133
#define TA_CMD_VERTEX     0xe0000000
nkeynes@185
   134
#define TA_CMD_VERTEX_LAST 0xF0000000  /* end of strip */
nkeynes@185
   135
nkeynes@190
   136
#define GRID_SIZE( hres, vres ) (((((vres+31) / 32)-1)<<16)|((((hres+31) / 32)-1)))
nkeynes@185
   137
nkeynes@190
   138
struct ta_config {
nkeynes@190
   139
    unsigned int ta_cfg;
nkeynes@190
   140
    unsigned int grid_size;
nkeynes@190
   141
    unsigned int obj_start;
nkeynes@190
   142
    unsigned int obj_end;
nkeynes@190
   143
    unsigned int tile_start;
nkeynes@190
   144
    unsigned int tile_end;
nkeynes@190
   145
    unsigned int plist_start;
nkeynes@190
   146
};
nkeynes@185
   147
nkeynes@213
   148
struct render_config {
nkeynes@213
   149
    unsigned int polybuf;
nkeynes@213
   150
    unsigned int tilemap;
nkeynes@213
   151
    unsigned int render_addr;
nkeynes@213
   152
    unsigned int width, height;
nkeynes@213
   153
    unsigned int mode;
nkeynes@213
   154
    float farclip, nearclip;
nkeynes@213
   155
};
nkeynes@213
   156
nkeynes@190
   157
void ta_init( struct ta_config *config );
nkeynes@213
   158
void ta_reinit();
nkeynes@185
   159
void pvr_dump_objbuf( FILE *f );
nkeynes@185
   160
void pvr_dump_tilebuf( FILE *f );
nkeynes@185
   161
int pvr_get_objbuf_size();
nkeynes@213
   162
int pvr_get_objbuf_posn();
nkeynes@190
   163
int pvr_get_plist_posn();
nkeynes@213
   164
void render_set_backplane( unsigned int mode );
nkeynes@213
   165
void render_start( struct render_config *config );
nkeynes@213
   166
void display_render( struct render_config *config );
nkeynes@213
   167
void pvr_build_tilemap1( unsigned int addr, struct ta_config *config, unsigned int control_word );
nkeynes@213
   168
nkeynes@213
   169
void pvr_build_tilemap2( unsigned int addr, struct ta_config *config, unsigned int control_word );
.