Path: blob/master/libmupen64plus/mupen64plus-video-glide64mk2/src/Glide64/rdp.h
2 views
/*1* Glide64 - Glide video plugin for Nintendo 64 emulators.2* Copyright (c) 2002 Dave20013* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to the Free Software17* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18*/1920//****************************************************************21//22// Glide64 - Glide Plugin for Nintendo 64 emulators23// Project started on December 29th, 200124//25// Authors:26// Dave2001, original author, founded the project in 2001, left it in 200227// Gugaman, joined the project in 2002, left it in 200228// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 200229// Hiroshi 'KoolSmoky' Morii, joined the project in 200730//31//****************************************************************32//33// To modify Glide64:34// * Write your name and (optional)email, commented by your work, so I know who did it, and so that you can find which parts you modified when it comes time to send it to me.35// * Do NOT send me the whole project or file that you modified. Take out your modified code sections, and tell me where to put them. If people sent the whole thing, I would have many different versions, but no idea how to combine them all.36//37//****************************************************************3839#ifndef RDP_H40#define RDP_H4142extern char out_buf[2048];4344extern wxUint32 frame_count; // frame counter4546//GlideHQ support47#ifdef TEXTURE_FILTER48#include "../GlideHQ/Ext_TxFilter.h"49#endif5051#define MAX_CACHE 1024*452#define MAX_TRI_CACHE 768 // this is actually # of vertices, not triangles53#define MAX_VTX 2565455#define MAX_TMU 25657#define TEXMEM_2MB_EDGE 20971525859// Supported flags60#define SUP_TEXMIRROR 0x000000016162// Clipping flags63#define CLIP_XMAX 0x0000000164#define CLIP_XMIN 0x0000000265#define CLIP_YMAX 0x0000000466#define CLIP_YMIN 0x0000000867#define CLIP_WMIN 0x0000001068#define CLIP_ZMAX 0x0000002069#define CLIP_ZMIN 0x000000407071// Flags72#define ZBUF_ENABLED 0x0000000173#define ZBUF_DECAL 0x0000000274#define ZBUF_COMPARE 0x0000000475#define ZBUF_UPDATE 0x0000000876#define ALPHA_COMPARE 0x0000001077#define FORCE_BL 0x0000002078#define CULL_FRONT 0x00001000 // * must be here79#define CULL_BACK 0x00002000 // * must be here80#define FOG_ENABLED 0x000100008182#define CULLMASK 0x0000300083#define CULLSHIFT 128485// Update flags86#define UPDATE_ZBUF_ENABLED 0x000000018788#define UPDATE_TEXTURE 0x00000002 // \ Same thing!89#define UPDATE_COMBINE 0x00000002 // /9091#define UPDATE_CULL_MODE 0x0000000492#define UPDATE_LIGHTS 0x0000001093#define UPDATE_BIASLEVEL 0x0000002094#define UPDATE_ALPHA_COMPARE 0x0000004095#define UPDATE_VIEWPORT 0x0000008096#define UPDATE_MULT_MAT 0x0000010097#define UPDATE_SCISSOR 0x0000020098#define UPDATE_FOG_ENABLED 0x0001000099100#define CMB_MULT 0x00000001101#define CMB_SET 0x00000002102#define CMB_SUB 0x00000004103#define CMB_ADD 0x00000008104#define CMB_A_MULT 0x00000010105#define CMB_A_SET 0x00000020106#define CMB_A_SUB 0x00000040107#define CMB_A_ADD 0x00000080108#define CMB_SETSHADE_SHADEALPHA 0x00000100109#define CMB_INTER 0x00000200110#define CMB_MULT_OWN_ALPHA 0x00000400111#define CMB_COL_SUB_OWN 0x00000800112113#define uc(x) coord[x<<1]114#define vc(x) coord[(x<<1)+1]115116#if defined(_MSC_VER)117#define DECLAREALIGN16VAR(var) __declspec(align(16)) float var118#elif defined(__GNUG__)119#define DECLAREALIGN16VAR(var) float (var) __attribute__ ((aligned(16)))120#endif121122// Vertex structure123typedef struct124{125float x, y, z, q;126float u0, v0, u1, v1;127float coord[4];128float w;129wxUint16 flags;130131wxUint8 b; // These values are arranged like this so that *(wxUint32*)(VERTEX+?) is132wxUint8 g; // ARGB format that glide can use.133wxUint8 r;134wxUint8 a;135136float f; //fog137138float vec[3]; // normal vector139140float sx, sy, sz;141float x_w, y_w, z_w, u0_w, v0_w, u1_w, v1_w, oow;142wxUint8 not_zclipped;143wxUint8 screen_translated;144wxUint8 uv_scaled;145wxUint32 uv_calculated; // like crc146wxUint32 shade_mod;147wxUint32 color_backup;148149float ou, ov;150151int number; // way to identify it152int scr_off, z_off; // off the screen?153} VERTEX;154155// Clipping (scissors)156typedef struct {157wxUint32 ul_x;158wxUint32 ul_y;159wxUint32 lr_x;160wxUint32 lr_y;161} SCISSOR;162163#ifdef TEXTURE_FILTER164extern wxUint32 texfltr[];165extern wxUint32 texenht[];166extern wxUint32 texcmpr[];167extern wxUint32 texhirs[];168169typedef struct {170wxUint16 tile_ul_s;171wxUint16 tile_ul_t;172wxUint16 tile_width;173wxUint16 tile_height;174wxUint16 tex_width;175wxUint16 tex_size;176wxUint32 dxt;177} LOAD_TILE_INFO;178#endif179180// #warning no screenshot support181/*182typedef struct {183const wxChar * format;184const wxChar * extension;185wxBitmapType type;186} SCREEN_SHOT_FORMAT;187188extern const int NumOfFormats;189extern SCREEN_SHOT_FORMAT ScreenShotFormats[];190*/191typedef struct {192int card_id;193int lang_id;194195wxUint32 res_x, scr_res_x;196wxUint32 res_y, scr_res_y;197wxUint32 res_data, res_data_org;198199int advanced_options;200int texenh_options;201int ssformat;202int vsync;203204int show_fps;205int clock;206int clock_24_hr;207208int filtering;209int fog;210int buff_clear;211int swapmode;212int lodmode;213int aspectmode;214int use_hotkeys;215216//Frame buffer emulation options217#define fb_emulation (1<<0) //frame buffer emulation218#define fb_hwfbe (1<<1) //hardware frame buffer emualtion219#define fb_motionblur (1<<2) //emulate motion blur220#define fb_ref (1<<3) //read every frame221#define fb_read_alpha (1<<4) //read alpha222#define fb_hwfbe_buf_clear (1<<5) //clear auxiliary texture frame buffers223#define fb_depth_render (1<<6) //enable software depth render224#define fb_optimize_texrect (1<<7) //fast texrect rendering with hwfbe225#define fb_ignore_aux_copy (1<<8) //do not copy auxiliary frame buffers226#define fb_useless_is_useless (1<<10) //227#define fb_get_info (1<<11) //get frame buffer info228#define fb_read_back_to_screen (1<<12) //render N64 frame buffer to screen229#define fb_read_back_to_screen2 (1<<13) //render N64 frame buffer to screen230#define fb_cpu_write_hack (1<<14) //show images writed directly by CPU231232#define fb_emulation_enabled ((settings.frame_buffer&fb_emulation)>0)233#define fb_hwfbe_enabled ((settings.frame_buffer&(fb_emulation|fb_hwfbe))==(fb_emulation|fb_hwfbe))234#define fb_depth_render_enabled ((settings.frame_buffer&fb_depth_render)>0)235236wxUint32 frame_buffer;237enum FBCRCMODE {238fbcrcNone = 0,239fbcrcFast = 1,240fbcrcSafe = 2} fb_crc_mode;241242#ifdef TEXTURE_FILTER243//Texture filtering options244int ghq_fltr;245int ghq_enht;246int ghq_cmpr;247int ghq_hirs;248int ghq_use;249int ghq_enht_cmpr;250int ghq_enht_tile;251int ghq_enht_f16bpp;252int ghq_enht_gz;253int ghq_enht_nobg;254int ghq_hirs_cmpr;255int ghq_hirs_tile;256int ghq_hirs_f16bpp;257int ghq_hirs_gz;258int ghq_hirs_altcrc;259int ghq_cache_save;260int ghq_cache_size;261int ghq_hirs_let_texartists_fly;262int ghq_hirs_dump;263#endif264265//Debug266int autodetect_ucode;267int ucode;268int logging;269int elogging;270int log_clear;271int run_in_window;272int filter_cache;273int unk_as_red;274int log_unk;275int unk_clear;276int wireframe;277int wfmode;278279// Special fixes280int offset_x, offset_y;281int scale_x, scale_y;282int fast_crc;283int alt_tex_size;284int use_sts1_only;285int flame_corona; //hack for zeldas flame's corona286int increase_texrect_edge; // add 1 to lower right corner coordinates of texrect287int decrease_fillrect_edge; // sub 1 from lower right corner coordinates of fillrect288int texture_correction; // enable perspective texture correction emulation. is on by default289int stipple_mode; //used for dithered alpha emulation290wxUint32 stipple_pattern; //used for dithered alpha emulation291int force_microcheck; //check microcode each frame, for mixed F3DEX-S2DEX games292int force_quad3d; //force 0xb5 command to be quad, not line 3d293int clip_zmin; //enable near z clipping294int clip_zmax; //enable far plane clipping;295int adjust_aspect; //adjust screen aspect for wide screen mode296int force_calc_sphere; //use spheric mapping only, Ridge Racer 64297int pal230; //set special scale for PAL games298int correct_viewport; //correct viewport values299int zmode_compare_less; //force GR_CMP_LESS for zmode=0 (opaque)and zmode=1 (interpenetrating)300int old_style_adither; //apply alpha dither regardless of alpha_dither_mode301int n64_z_scale; //scale vertex z value before writing to depth buffer, as N64 does.302303//Special game hacks304#define hack_ASB (1<<0) //All-Star Baseball games305#define hack_Banjo2 (1<<1) //Banjo Tooie306#define hack_BAR (1<<2) //Beetle Adventure Racing307#define hack_Chopper (1<<3) //Chopper Attack308#define hack_Diddy (1<<4) //diddy kong racing309#define hack_Fifa98 (1<<5) //FIFA - Road to World Cup 98310#define hack_Fzero (1<<6) //F-Zero311#define hack_GoldenEye (1<<7) //Golden Eye312#define hack_Hyperbike (1<<8) //Top Gear Hyper Bike313#define hack_ISS64 (1<<9) //International Superstar Soccer 64314#define hack_KI (1<<10) //Killer Instinct315#define hack_Knockout (1<<11) //Knockout Kings 2000316#define hack_Lego (1<<12) //LEGO Racers317#define hack_MK64 (1<<13) //Mario Kart318#define hack_Megaman (1<<14) //Megaman64319#define hack_Makers (1<<15) //Mischief-makers320#define hack_WCWnitro (1<<16) //WCW Nitro321#define hack_Ogre64 (1<<17) //Ogre Battle 64322#define hack_Pilotwings (1<<18) //Pilotwings323#define hack_PMario (1<<19) //Paper Mario324#define hack_PPL (1<<20) //pokemon puzzle league requires many special fixes325#define hack_RE2 (1<<21) //Resident Evil 2326#define hack_Starcraft (1<<22) //StarCraft64327#define hack_Supercross (1<<23) //Supercross 2000328#define hack_TGR (1<<24) //Top Gear Rally329#define hack_TGR2 (1<<25) //Top Gear Rally 2330#define hack_Tonic (1<<26) //tonic trouble331#define hack_Yoshi (1<<27) //Yoshi Story332#define hack_Zelda (1<<28) //zeldas hacks333wxUint32 hacks;334335//wrapper settings336int wrpResolution;337int wrpVRAM;338int wrpFBO;339int wrpAnisotropic;340341} SETTINGS;342343typedef struct344{345wxUint8 hk_ref;346wxUint8 hk_motionblur;347wxUint8 hk_filtering;348} HOTKEY_INFO;349350typedef struct351{352int num_tmu;353int max_tex_size;354int sup_large_tex;355int sup_mirroring;356int sup_32bit_tex;357int has_2mb_tex_boundary;358int tex_UMA;359int gamma_correction;360FxI32 gamma_table_size;361FxU32 *gamma_table_r;362FxU32 *gamma_table_g;363FxU32 *gamma_table_b;364wxUint32 tmem_ptr[MAX_TMU];365wxUint32 tex_min_addr[MAX_TMU];366wxUint32 tex_max_addr[MAX_TMU];367} VOODOO;368369// This structure is what is passed in by rdp:settextureimage370typedef struct {371wxUint8 format; // format: ARGB, IA, ...372wxUint8 size; // size: 4,8,16, or 32 bit373wxUint16 width; // used in settextureimage374wxUint32 addr; // address in RDRAM to load the texture from375int set_by; // 0-loadblock 1-loadtile376} TEXTURE_IMAGE;377378// This structure is a tile descriptor (as used by rdp:settile and rdp:settilesize)379typedef struct380{381// rdp:settile382wxUint8 format; // format: ARGB, IA, ...383wxUint8 size; // size: 4,8,16, or 32 bit384wxUint16 line; // size of one row (x axis) in 64 bit words385wxUint16 t_mem; // location in texture memory (in 64 bit words, max 512 (4MB))386wxUint8 palette; // palette # to use387wxUint8 clamp_t; // clamp or wrap (y axis)?388wxUint8 mirror_t; // mirroring on (y axis)?389wxUint8 mask_t; // mask to wrap around (ex: 5 would wrap around 32) (y axis)390wxUint8 shift_t; // ??? (scaling)391wxUint8 clamp_s; // clamp or wrap (x axis)?392wxUint8 mirror_s; // mirroring on (x axis)?393wxUint8 mask_s; // mask to wrap around (x axis)394wxUint8 shift_s; // ??? (scaling)395396// rdp:settilesize397wxUint16 ul_s; // upper left s coordinate398wxUint16 ul_t; // upper left t coordinate399wxUint16 lr_s; // lower right s coordinate400wxUint16 lr_t; // lower right t coordinate401402float f_ul_s;403float f_ul_t;404405// these are set by loadtile406wxUint16 t_ul_s; // upper left s coordinate407wxUint16 t_ul_t; // upper left t coordinate408wxUint16 t_lr_s; // lower right s coordinate409wxUint16 t_lr_t; // lower right t coordinate410411wxUint32 width;412wxUint32 height;413414// uc0:texture415wxUint8 on;416float s_scale;417float t_scale;418419wxUint16 org_s_scale;420wxUint16 org_t_scale;421} TILE;422423// This structure forms the lookup table for cached textures424typedef struct {425wxUint32 addr; // address in RDRAM426wxUint32 crc; // CRC check427wxUint32 palette; // Palette #428wxUint32 width; // width429wxUint32 height; // height430wxUint32 format; // format431wxUint32 size; // size432wxUint32 last_used; // what frame # was this texture last used (used for replacing)433434wxUint32 line;435436wxUint32 flags; // clamp/wrap/mirror flags437438wxUint32 realwidth; // width of actual texture439wxUint32 realheight; // height of actual texture440wxUint32 lod;441wxUint32 aspect;442443wxUint8 set_by;444wxUint8 texrecting;445446int f_mirror_s;447int f_mirror_t;448int f_wrap_s;449int f_wrap_t;450451float scale_x; // texture scaling452float scale_y;453float scale; // general scale to 256454455GrTexInfo t_info; // texture info (glide)456wxUint32 tmem_addr; // addres in texture memory (glide)457458int uses; // 1 triangle that uses this texture459460int splits; // number of splits461int splitheight;462463float c_off; // ul center texel offset (both x and y)464float c_scl_x; // scale to lower-right center-texel x465float c_scl_y; // scale to lower-right center-texel y466467wxUint32 mod, mod_color, mod_color1, mod_color2, mod_factor;468#ifdef TEXTURE_FILTER469uint64 ricecrc;470int is_hires_tex;471#endif472} CACHE_LUT;473474// Lights475typedef struct {476float r, g, b, a; // color477float dir_x, dir_y, dir_z; // direction towards the light source478float x, y, z, w; // light position479float ca, la, qa;480wxUint32 nonblack;481wxUint32 nonzero;482} LIGHT;483484typedef enum {485ci_main, //0, main color image486ci_zimg, //1, depth image487ci_unknown, //2, status is unknown488ci_useless, //3, status is unclear489ci_old_copy, //4, auxiliary color image, copy of last color image from previous frame490ci_copy, //5, auxiliary color image, copy of previous color image491ci_copy_self, //6, main color image, it's content will be used to draw into itself492ci_zcopy, //7, auxiliary color image, copy of depth image493ci_aux, //8, auxiliary color image494ci_aux_copy //9, auxiliary color image, partial copy of previous color image495} CI_STATUS;496497// Frame buffers498typedef struct499{500wxUint32 addr; //color image address501wxUint8 format;502wxUint8 size;503wxUint16 width;504wxUint16 height;505CI_STATUS status;506int changed;507} COLOR_IMAGE;508509typedef struct510{511GrChipID_t tmu;512wxUint32 addr; //address of color image513wxUint32 end_addr;514wxUint32 tex_addr; //address in video memory515wxUint32 width; //width of color image516wxUint32 height; //height of color image517wxUint8 format; //format of color image518wxUint8 size; //format of color image519wxUint8 clear; //flag. texture buffer must be cleared520wxUint8 drawn; //flag. if equal to 1, this image was already drawn in current frame521wxUint32 crc; //checksum of the color image522float scr_width; //width of rendered image523float scr_height; //height of rendered image524wxUint32 tex_width; //width of texture buffer525wxUint32 tex_height; //height of texture buffer526int tile; //527wxUint16 tile_uls; //shift from left bound of the texture528wxUint16 tile_ult; //shift from top of the texture529wxUint32 v_shift; //shift from top of the texture530wxUint32 u_shift; //shift from left of the texture531float lr_u;532float lr_v;533float u_scale; //used to map vertex u,v coordinates into hires texture534float v_scale; //used to map vertex u,v coordinates into hires texture535CACHE_LUT * cache; //pointer to texture cache item536GrTexInfo info;537wxUint16 t_mem;538} TBUFF_COLOR_IMAGE;539540typedef struct541{542GrChipID_t tmu;543wxUint32 begin; //start of the block in video memory544wxUint32 end; //end of the block in video memory545wxUint8 count; //number of allocated texture buffers546int clear_allowed; //stack of buffers can be cleared547TBUFF_COLOR_IMAGE images[256];548} TEXTURE_BUFFER;549550#define NUMTEXBUF 92551552struct RDP_Base{553float vi_width;554float vi_height;555556int window_changed;557558float offset_x, offset_y, offset_x_bak, offset_y_bak;559560float scale_x, scale_1024, scale_x_bak;561float scale_y, scale_768, scale_y_bak;562563float view_scale[3];564float view_trans[3];565float clip_min_x, clip_max_x, clip_min_y, clip_max_y;566float clip_ratio;567568int updatescreen;569570wxUint32 tri_n; // triangle counter571wxUint32 debug_n;572573// Program counter574wxUint32 pc[10]; // DList PC stack575wxUint32 pc_i; // current PC index in the stack576int dl_count; // number of instructions before returning577int LLE;578579// Segments580wxUint32 segment[16]; // Segment pointer581582// Marks the end of DList execution (done in uc?:enddl)583int halt;584585// Next command586wxUint32 cmd0;587wxUint32 cmd1;588wxUint32 cmd2;589wxUint32 cmd3;590591// Clipping592SCISSOR scissor_o;593SCISSOR scissor;594int scissor_set;595596// Colors597wxUint32 fog_color;598wxUint32 fill_color;599wxUint32 prim_color;600wxUint32 blend_color;601wxUint32 env_color;602wxUint32 SCALE;603wxUint32 CENTER;604wxUint32 prim_lodmin, prim_lodfrac;605wxUint16 prim_depth;606wxUint16 prim_dz;607wxUint8 K4;608wxUint8 K5;609enum {610noise_none,611noise_combine,612noise_texture613} noise;614615float col[4]; // color multiplier616float coladd[4]; // color add/subtract617float shade_factor;618619float col_2[4];620621wxUint32 cmb_flags, cmb_flags_2;622623// othermode_l flags624int acmp; // 0 = none, 1 = threshold, 2 = dither625int zsrc; // 0 = pixel, 1 = prim626wxUint8 alpha_dither_mode;627628// Matrices629DECLAREALIGN16VAR(model[4][4]);630DECLAREALIGN16VAR(proj[4][4]);631DECLAREALIGN16VAR(combined[4][4]);632DECLAREALIGN16VAR(dkrproj[3][4][4]);633634DECLAREALIGN16VAR(model_stack[32][4][4]); // 32 deep, will warn if overflow635int model_i; // index in the model matrix stack636int model_stack_size;637638// Textures639TEXTURE_IMAGE timg; // 1 for each tmem address640TILE tiles[8]; // 8 tile descriptors641wxUint8 tmem[4096]; // 4k tmem642wxUint32 addr[512]; // 512 addresses (used to determine address loaded from)643#ifdef TEXTURE_FILTER644LOAD_TILE_INFO load_info[512]; // 512 addresses. inforamation about tile loading.645#endif646647int cur_tile; // current tile648int mipmap_level;649int last_tile; // last tile set650int last_tile_size; // last tile size set651652int t0, t1;653int best_tex; // if no 2-tmus, which texture? (0 or 1)654int tex;655int filter_mode;656657// Texture palette658wxUint16 pal_8[256];659wxUint32 pal_8_crc[16];660wxUint32 pal_256_crc;661wxUint8 tlut_mode;662int LOD_en;663int Persp_en;664int persp_supported;665int force_wrap;666#ifdef TEXTURE_FILTER667wxUint16 pal_8_rice[512];668#endif669670// Lighting671wxUint32 num_lights;672LIGHT light[12];673float light_vector[12][3];674float lookat[2][3];675int use_lookat;676677// Combine modes678wxUint32 cycle1, cycle2, cycle_mode;679wxUint8 c_a0, c_b0, c_c0, c_d0, c_Aa0, c_Ab0, c_Ac0, c_Ad0;680wxUint8 c_a1, c_b1, c_c1, c_d1, c_Aa1, c_Ab1, c_Ac1, c_Ad1;681682wxUint8 fbl_a0, fbl_b0, fbl_c0, fbl_d0;683wxUint8 fbl_a1, fbl_b1, fbl_c1, fbl_d1;684685wxUint8 uncombined; // which is uncombined: 0x01=color 0x02=alpha 0x03=both686687// float YUV_C0, YUV_C1, YUV_C2, YUV_C3, YUV_C4; //YUV textures conversion coefficients688689// What needs updating690wxUint32 update;691wxUint32 flags;692693int first;694695wxUint32 tex_ctr; // incremented every time textures are updated696697int allow_combine; // allow combine updating?698699int s2dex_tex_loaded;700wxUint16 bg_image_height;701702// Debug stuff703wxUint32 rm; // use othermode_l instead, this just as a check for changes704wxUint32 render_mode_changed;705wxUint32 geom_mode;706707wxUint32 othermode_h;708wxUint32 othermode_l;709710// used to check if in texrect while loading texture711wxUint8 texrecting;712713//frame buffer related slots. Added by Gonetz714wxUint32 cimg, ocimg, zimg, tmpzimg, vi_org_reg;715COLOR_IMAGE maincimg[2];716wxUint32 last_drawn_ci_addr;717wxUint32 main_ci, main_ci_end, main_ci_bg, main_ci_last_tex_addr, zimg_end, last_bg;718wxUint32 ci_width, ci_height, ci_size, ci_end;719wxUint32 zi_width;720int zi_lrx, zi_lry;721wxUint8 ci_count, num_of_ci, main_ci_index, copy_ci_index, copy_zi_index;722int swap_ci_index, black_ci_index;723wxUint32 ci_upper_bound, ci_lower_bound;724int motionblur, fb_drawn, fb_drawn_front, read_previous_ci, read_whole_frame;725CI_STATUS ci_status;726TBUFF_COLOR_IMAGE * cur_image; //image currently being drawn727TBUFF_COLOR_IMAGE * tbuff_tex; //image, which corresponds to currently selected texture728TBUFF_COLOR_IMAGE * aTBuffTex[2];729wxUint8 cur_tex_buf;730wxUint8 acc_tex_buf;731int skip_drawing; //rendering is not required. used for frame buffer emulation732733//fog related slots. Added by Gonetz734float fog_multiplier, fog_offset;735enum {736fog_disabled,737fog_enabled,738fog_blend,739fog_blend_inverse740}741fog_mode;742};743744struct RDP : public RDP_Base745{746// Clipping747int clip; // clipping flags748VERTEX *vtx1; //[256] copy vertex buffer #1 (used for clipping)749VERTEX *vtx2; //[256] copy vertex buffer #2750VERTEX *vtxbuf; // current vertex buffer (reset to vtx, used to determine current vertex buffer)751VERTEX *vtxbuf2;752int n_global; // Used to pass the number of vertices from clip_z to clip_tri753int vtx_buffer;754755CACHE_LUT *cache[MAX_TMU]; //[MAX_CACHE]756CACHE_LUT *cur_cache[MAX_TMU];757wxUint32 cur_cache_n[MAX_TMU];758int n_cached[MAX_TMU];759760// Vertices761VERTEX *vtx; //[MAX_VTX]762int v0, vn;763764COLOR_IMAGE *frame_buffers; //[NUMTEXBUF+2]765TEXTURE_BUFFER texbufs[2];766767char RomName[21];768769RDP();770~RDP();771void Reset();772};773774775void SetWireframeCol ();776void ChangeSize ();777void GoToFullScreen();778779extern RDP rdp;780extern SETTINGS settings;781extern HOTKEY_INFO hotkey_info;782extern VOODOO voodoo;783784extern GrTexInfo fontTex;785extern GrTexInfo cursorTex;786extern wxUint32 offset_font;787extern wxUint32 offset_cursor;788extern wxUint32 offset_textures;789extern wxUint32 offset_texbuf1;790791extern int ucode_error_report;792793/*794extern wxString pluginPath;795extern wxString iniPath;796*/797// RDP functions798void rdp_reset ();799800extern const char *ACmp[];801extern const char *Mode0[];802extern const char *Mode1[];803extern const char *Mode2[];804extern const char *Mode3[];805extern const char *Alpha0[];806#define Alpha1 Alpha0807extern const char *Alpha2[];808#define Alpha3 Alpha0809extern const char *FBLa[];810extern const char *FBLb[];811extern const char *FBLc[];812extern const char *FBLd[];813extern const char *str_zs[];814extern const char *str_yn[];815extern const char *str_offon[];816extern const char *str_cull[];817// I=intensity probably818extern const char *str_format[];819extern const char *str_size[];820extern const char *str_cm[];821extern const char *str_lod[];822extern const char *str_aspect[];823extern const char *str_filter[];824extern const char *str_tlut[];825extern const char *CIStatus[];826827#define FBL_D_1 2828#define FBL_D_0 3829830#ifndef max831#define max(a,b) (((a) > (b)) ? (a) : (b))832#endif833#ifndef min834#define min(a,b) (((a) < (b)) ? (a) : (b))835#endif836#ifndef TRUE837#define TRUE 1838#endif839#ifndef FALSE840#define FALSE 0841#endif842#ifndef HIWORD843#define HIWORD(a) ((unsigned int)(a) >> 16)844#endif845#ifndef LOWORD846#define LOWORD(a) ((a) & 0xFFFF)847#endif848849// Convert from u0/v0/u1/v1 to the real coordinates without regard to tmu850__inline void ConvertCoordsKeep (VERTEX *v, int n)851{852for (int i=0; i<n; i++)853{854v[i].uc(0) = v[i].u0;855v[i].vc(0) = v[i].v0;856v[i].uc(1) = v[i].u1;857v[i].vc(1) = v[i].v1;858}859}860861// Convert from u0/v0/u1/v1 to the real coordinates based on the tmu they are on862__inline void ConvertCoordsConvert (VERTEX *v, int n)863{864for (int i=0; i<n; i++)865{866v[i].uc(rdp.t0) = v[i].u0;867v[i].vc(rdp.t0) = v[i].v0;868v[i].uc(rdp.t1) = v[i].u1;869v[i].vc(rdp.t1) = v[i].v1;870}871}872873__inline void AllowShadeMods (VERTEX *v, int n)874{875for (int i=0; i<n; i++)876{877v[i].shade_mod = 0;878}879}880881__inline void AddOffset (VERTEX *v, int n)882{883for (int i=0; i<n; i++)884{885v[i].x += rdp.offset_x;886v[i].y += rdp.offset_y;887}888}889890__inline void CalculateFog (VERTEX *v)891{892if (rdp.flags & FOG_ENABLED)893{894if (v->w < 0.0f)895v->f = 0.0f;896else897v->f = min(255.0f, max(0.0f, v->z_w * rdp.fog_multiplier + rdp.fog_offset));898v->a = (wxUint8)v->f;899}900else901{902v->f = 1.0f;903}904}905906void newSwapBuffers();907extern int SwapOK;908909// ** utility functions910void load_palette (wxUint32 addr, wxUint16 start, wxUint16 count);911void setTBufTex(wxUint16 t_mem, wxUint32 cnt);912913#endif // ifndef RDP_H914915916