Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libmupen64plus/mupen64plus-video-glide64mk2/src/Glide64/rdp.h
2 views
1
/*
2
* Glide64 - Glide video plugin for Nintendo 64 emulators.
3
* Copyright (c) 2002 Dave2001
4
* Copyright (c) 2003-2009 Sergey 'Gonetz' Lipski
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
*/
20
21
//****************************************************************
22
//
23
// Glide64 - Glide Plugin for Nintendo 64 emulators
24
// Project started on December 29th, 2001
25
//
26
// Authors:
27
// Dave2001, original author, founded the project in 2001, left it in 2002
28
// Gugaman, joined the project in 2002, left it in 2002
29
// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
30
// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
31
//
32
//****************************************************************
33
//
34
// To modify Glide64:
35
// * 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.
36
// * 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.
37
//
38
//****************************************************************
39
40
#ifndef RDP_H
41
#define RDP_H
42
43
extern char out_buf[2048];
44
45
extern wxUint32 frame_count; // frame counter
46
47
//GlideHQ support
48
#ifdef TEXTURE_FILTER
49
#include "../GlideHQ/Ext_TxFilter.h"
50
#endif
51
52
#define MAX_CACHE 1024*4
53
#define MAX_TRI_CACHE 768 // this is actually # of vertices, not triangles
54
#define MAX_VTX 256
55
56
#define MAX_TMU 2
57
58
#define TEXMEM_2MB_EDGE 2097152
59
60
// Supported flags
61
#define SUP_TEXMIRROR 0x00000001
62
63
// Clipping flags
64
#define CLIP_XMAX 0x00000001
65
#define CLIP_XMIN 0x00000002
66
#define CLIP_YMAX 0x00000004
67
#define CLIP_YMIN 0x00000008
68
#define CLIP_WMIN 0x00000010
69
#define CLIP_ZMAX 0x00000020
70
#define CLIP_ZMIN 0x00000040
71
72
// Flags
73
#define ZBUF_ENABLED 0x00000001
74
#define ZBUF_DECAL 0x00000002
75
#define ZBUF_COMPARE 0x00000004
76
#define ZBUF_UPDATE 0x00000008
77
#define ALPHA_COMPARE 0x00000010
78
#define FORCE_BL 0x00000020
79
#define CULL_FRONT 0x00001000 // * must be here
80
#define CULL_BACK 0x00002000 // * must be here
81
#define FOG_ENABLED 0x00010000
82
83
#define CULLMASK 0x00003000
84
#define CULLSHIFT 12
85
86
// Update flags
87
#define UPDATE_ZBUF_ENABLED 0x00000001
88
89
#define UPDATE_TEXTURE 0x00000002 // \ Same thing!
90
#define UPDATE_COMBINE 0x00000002 // /
91
92
#define UPDATE_CULL_MODE 0x00000004
93
#define UPDATE_LIGHTS 0x00000010
94
#define UPDATE_BIASLEVEL 0x00000020
95
#define UPDATE_ALPHA_COMPARE 0x00000040
96
#define UPDATE_VIEWPORT 0x00000080
97
#define UPDATE_MULT_MAT 0x00000100
98
#define UPDATE_SCISSOR 0x00000200
99
#define UPDATE_FOG_ENABLED 0x00010000
100
101
#define CMB_MULT 0x00000001
102
#define CMB_SET 0x00000002
103
#define CMB_SUB 0x00000004
104
#define CMB_ADD 0x00000008
105
#define CMB_A_MULT 0x00000010
106
#define CMB_A_SET 0x00000020
107
#define CMB_A_SUB 0x00000040
108
#define CMB_A_ADD 0x00000080
109
#define CMB_SETSHADE_SHADEALPHA 0x00000100
110
#define CMB_INTER 0x00000200
111
#define CMB_MULT_OWN_ALPHA 0x00000400
112
#define CMB_COL_SUB_OWN 0x00000800
113
114
#define uc(x) coord[x<<1]
115
#define vc(x) coord[(x<<1)+1]
116
117
#if defined(_MSC_VER)
118
#define DECLAREALIGN16VAR(var) __declspec(align(16)) float var
119
#elif defined(__GNUG__)
120
#define DECLAREALIGN16VAR(var) float (var) __attribute__ ((aligned(16)))
121
#endif
122
123
// Vertex structure
124
typedef struct
125
{
126
float x, y, z, q;
127
float u0, v0, u1, v1;
128
float coord[4];
129
float w;
130
wxUint16 flags;
131
132
wxUint8 b; // These values are arranged like this so that *(wxUint32*)(VERTEX+?) is
133
wxUint8 g; // ARGB format that glide can use.
134
wxUint8 r;
135
wxUint8 a;
136
137
float f; //fog
138
139
float vec[3]; // normal vector
140
141
float sx, sy, sz;
142
float x_w, y_w, z_w, u0_w, v0_w, u1_w, v1_w, oow;
143
wxUint8 not_zclipped;
144
wxUint8 screen_translated;
145
wxUint8 uv_scaled;
146
wxUint32 uv_calculated; // like crc
147
wxUint32 shade_mod;
148
wxUint32 color_backup;
149
150
float ou, ov;
151
152
int number; // way to identify it
153
int scr_off, z_off; // off the screen?
154
} VERTEX;
155
156
// Clipping (scissors)
157
typedef struct {
158
wxUint32 ul_x;
159
wxUint32 ul_y;
160
wxUint32 lr_x;
161
wxUint32 lr_y;
162
} SCISSOR;
163
164
#ifdef TEXTURE_FILTER
165
extern wxUint32 texfltr[];
166
extern wxUint32 texenht[];
167
extern wxUint32 texcmpr[];
168
extern wxUint32 texhirs[];
169
170
typedef struct {
171
wxUint16 tile_ul_s;
172
wxUint16 tile_ul_t;
173
wxUint16 tile_width;
174
wxUint16 tile_height;
175
wxUint16 tex_width;
176
wxUint16 tex_size;
177
wxUint32 dxt;
178
} LOAD_TILE_INFO;
179
#endif
180
181
// #warning no screenshot support
182
/*
183
typedef struct {
184
const wxChar * format;
185
const wxChar * extension;
186
wxBitmapType type;
187
} SCREEN_SHOT_FORMAT;
188
189
extern const int NumOfFormats;
190
extern SCREEN_SHOT_FORMAT ScreenShotFormats[];
191
*/
192
typedef struct {
193
int card_id;
194
int lang_id;
195
196
wxUint32 res_x, scr_res_x;
197
wxUint32 res_y, scr_res_y;
198
wxUint32 res_data, res_data_org;
199
200
int advanced_options;
201
int texenh_options;
202
int ssformat;
203
int vsync;
204
205
int show_fps;
206
int clock;
207
int clock_24_hr;
208
209
int filtering;
210
int fog;
211
int buff_clear;
212
int swapmode;
213
int lodmode;
214
int aspectmode;
215
int use_hotkeys;
216
217
//Frame buffer emulation options
218
#define fb_emulation (1<<0) //frame buffer emulation
219
#define fb_hwfbe (1<<1) //hardware frame buffer emualtion
220
#define fb_motionblur (1<<2) //emulate motion blur
221
#define fb_ref (1<<3) //read every frame
222
#define fb_read_alpha (1<<4) //read alpha
223
#define fb_hwfbe_buf_clear (1<<5) //clear auxiliary texture frame buffers
224
#define fb_depth_render (1<<6) //enable software depth render
225
#define fb_optimize_texrect (1<<7) //fast texrect rendering with hwfbe
226
#define fb_ignore_aux_copy (1<<8) //do not copy auxiliary frame buffers
227
#define fb_useless_is_useless (1<<10) //
228
#define fb_get_info (1<<11) //get frame buffer info
229
#define fb_read_back_to_screen (1<<12) //render N64 frame buffer to screen
230
#define fb_read_back_to_screen2 (1<<13) //render N64 frame buffer to screen
231
#define fb_cpu_write_hack (1<<14) //show images writed directly by CPU
232
233
#define fb_emulation_enabled ((settings.frame_buffer&fb_emulation)>0)
234
#define fb_hwfbe_enabled ((settings.frame_buffer&(fb_emulation|fb_hwfbe))==(fb_emulation|fb_hwfbe))
235
#define fb_depth_render_enabled ((settings.frame_buffer&fb_depth_render)>0)
236
237
wxUint32 frame_buffer;
238
enum FBCRCMODE {
239
fbcrcNone = 0,
240
fbcrcFast = 1,
241
fbcrcSafe = 2} fb_crc_mode;
242
243
#ifdef TEXTURE_FILTER
244
//Texture filtering options
245
int ghq_fltr;
246
int ghq_enht;
247
int ghq_cmpr;
248
int ghq_hirs;
249
int ghq_use;
250
int ghq_enht_cmpr;
251
int ghq_enht_tile;
252
int ghq_enht_f16bpp;
253
int ghq_enht_gz;
254
int ghq_enht_nobg;
255
int ghq_hirs_cmpr;
256
int ghq_hirs_tile;
257
int ghq_hirs_f16bpp;
258
int ghq_hirs_gz;
259
int ghq_hirs_altcrc;
260
int ghq_cache_save;
261
int ghq_cache_size;
262
int ghq_hirs_let_texartists_fly;
263
int ghq_hirs_dump;
264
#endif
265
266
//Debug
267
int autodetect_ucode;
268
int ucode;
269
int logging;
270
int elogging;
271
int log_clear;
272
int run_in_window;
273
int filter_cache;
274
int unk_as_red;
275
int log_unk;
276
int unk_clear;
277
int wireframe;
278
int wfmode;
279
280
// Special fixes
281
int offset_x, offset_y;
282
int scale_x, scale_y;
283
int fast_crc;
284
int alt_tex_size;
285
int use_sts1_only;
286
int flame_corona; //hack for zeldas flame's corona
287
int increase_texrect_edge; // add 1 to lower right corner coordinates of texrect
288
int decrease_fillrect_edge; // sub 1 from lower right corner coordinates of fillrect
289
int texture_correction; // enable perspective texture correction emulation. is on by default
290
int stipple_mode; //used for dithered alpha emulation
291
wxUint32 stipple_pattern; //used for dithered alpha emulation
292
int force_microcheck; //check microcode each frame, for mixed F3DEX-S2DEX games
293
int force_quad3d; //force 0xb5 command to be quad, not line 3d
294
int clip_zmin; //enable near z clipping
295
int clip_zmax; //enable far plane clipping;
296
int adjust_aspect; //adjust screen aspect for wide screen mode
297
int force_calc_sphere; //use spheric mapping only, Ridge Racer 64
298
int pal230; //set special scale for PAL games
299
int correct_viewport; //correct viewport values
300
int zmode_compare_less; //force GR_CMP_LESS for zmode=0 (opaque)and zmode=1 (interpenetrating)
301
int old_style_adither; //apply alpha dither regardless of alpha_dither_mode
302
int n64_z_scale; //scale vertex z value before writing to depth buffer, as N64 does.
303
304
//Special game hacks
305
#define hack_ASB (1<<0) //All-Star Baseball games
306
#define hack_Banjo2 (1<<1) //Banjo Tooie
307
#define hack_BAR (1<<2) //Beetle Adventure Racing
308
#define hack_Chopper (1<<3) //Chopper Attack
309
#define hack_Diddy (1<<4) //diddy kong racing
310
#define hack_Fifa98 (1<<5) //FIFA - Road to World Cup 98
311
#define hack_Fzero (1<<6) //F-Zero
312
#define hack_GoldenEye (1<<7) //Golden Eye
313
#define hack_Hyperbike (1<<8) //Top Gear Hyper Bike
314
#define hack_ISS64 (1<<9) //International Superstar Soccer 64
315
#define hack_KI (1<<10) //Killer Instinct
316
#define hack_Knockout (1<<11) //Knockout Kings 2000
317
#define hack_Lego (1<<12) //LEGO Racers
318
#define hack_MK64 (1<<13) //Mario Kart
319
#define hack_Megaman (1<<14) //Megaman64
320
#define hack_Makers (1<<15) //Mischief-makers
321
#define hack_WCWnitro (1<<16) //WCW Nitro
322
#define hack_Ogre64 (1<<17) //Ogre Battle 64
323
#define hack_Pilotwings (1<<18) //Pilotwings
324
#define hack_PMario (1<<19) //Paper Mario
325
#define hack_PPL (1<<20) //pokemon puzzle league requires many special fixes
326
#define hack_RE2 (1<<21) //Resident Evil 2
327
#define hack_Starcraft (1<<22) //StarCraft64
328
#define hack_Supercross (1<<23) //Supercross 2000
329
#define hack_TGR (1<<24) //Top Gear Rally
330
#define hack_TGR2 (1<<25) //Top Gear Rally 2
331
#define hack_Tonic (1<<26) //tonic trouble
332
#define hack_Yoshi (1<<27) //Yoshi Story
333
#define hack_Zelda (1<<28) //zeldas hacks
334
wxUint32 hacks;
335
336
//wrapper settings
337
int wrpResolution;
338
int wrpVRAM;
339
int wrpFBO;
340
int wrpAnisotropic;
341
342
} SETTINGS;
343
344
typedef struct
345
{
346
wxUint8 hk_ref;
347
wxUint8 hk_motionblur;
348
wxUint8 hk_filtering;
349
} HOTKEY_INFO;
350
351
typedef struct
352
{
353
int num_tmu;
354
int max_tex_size;
355
int sup_large_tex;
356
int sup_mirroring;
357
int sup_32bit_tex;
358
int has_2mb_tex_boundary;
359
int tex_UMA;
360
int gamma_correction;
361
FxI32 gamma_table_size;
362
FxU32 *gamma_table_r;
363
FxU32 *gamma_table_g;
364
FxU32 *gamma_table_b;
365
wxUint32 tmem_ptr[MAX_TMU];
366
wxUint32 tex_min_addr[MAX_TMU];
367
wxUint32 tex_max_addr[MAX_TMU];
368
} VOODOO;
369
370
// This structure is what is passed in by rdp:settextureimage
371
typedef struct {
372
wxUint8 format; // format: ARGB, IA, ...
373
wxUint8 size; // size: 4,8,16, or 32 bit
374
wxUint16 width; // used in settextureimage
375
wxUint32 addr; // address in RDRAM to load the texture from
376
int set_by; // 0-loadblock 1-loadtile
377
} TEXTURE_IMAGE;
378
379
// This structure is a tile descriptor (as used by rdp:settile and rdp:settilesize)
380
typedef struct
381
{
382
// rdp:settile
383
wxUint8 format; // format: ARGB, IA, ...
384
wxUint8 size; // size: 4,8,16, or 32 bit
385
wxUint16 line; // size of one row (x axis) in 64 bit words
386
wxUint16 t_mem; // location in texture memory (in 64 bit words, max 512 (4MB))
387
wxUint8 palette; // palette # to use
388
wxUint8 clamp_t; // clamp or wrap (y axis)?
389
wxUint8 mirror_t; // mirroring on (y axis)?
390
wxUint8 mask_t; // mask to wrap around (ex: 5 would wrap around 32) (y axis)
391
wxUint8 shift_t; // ??? (scaling)
392
wxUint8 clamp_s; // clamp or wrap (x axis)?
393
wxUint8 mirror_s; // mirroring on (x axis)?
394
wxUint8 mask_s; // mask to wrap around (x axis)
395
wxUint8 shift_s; // ??? (scaling)
396
397
// rdp:settilesize
398
wxUint16 ul_s; // upper left s coordinate
399
wxUint16 ul_t; // upper left t coordinate
400
wxUint16 lr_s; // lower right s coordinate
401
wxUint16 lr_t; // lower right t coordinate
402
403
float f_ul_s;
404
float f_ul_t;
405
406
// these are set by loadtile
407
wxUint16 t_ul_s; // upper left s coordinate
408
wxUint16 t_ul_t; // upper left t coordinate
409
wxUint16 t_lr_s; // lower right s coordinate
410
wxUint16 t_lr_t; // lower right t coordinate
411
412
wxUint32 width;
413
wxUint32 height;
414
415
// uc0:texture
416
wxUint8 on;
417
float s_scale;
418
float t_scale;
419
420
wxUint16 org_s_scale;
421
wxUint16 org_t_scale;
422
} TILE;
423
424
// This structure forms the lookup table for cached textures
425
typedef struct {
426
wxUint32 addr; // address in RDRAM
427
wxUint32 crc; // CRC check
428
wxUint32 palette; // Palette #
429
wxUint32 width; // width
430
wxUint32 height; // height
431
wxUint32 format; // format
432
wxUint32 size; // size
433
wxUint32 last_used; // what frame # was this texture last used (used for replacing)
434
435
wxUint32 line;
436
437
wxUint32 flags; // clamp/wrap/mirror flags
438
439
wxUint32 realwidth; // width of actual texture
440
wxUint32 realheight; // height of actual texture
441
wxUint32 lod;
442
wxUint32 aspect;
443
444
wxUint8 set_by;
445
wxUint8 texrecting;
446
447
int f_mirror_s;
448
int f_mirror_t;
449
int f_wrap_s;
450
int f_wrap_t;
451
452
float scale_x; // texture scaling
453
float scale_y;
454
float scale; // general scale to 256
455
456
GrTexInfo t_info; // texture info (glide)
457
wxUint32 tmem_addr; // addres in texture memory (glide)
458
459
int uses; // 1 triangle that uses this texture
460
461
int splits; // number of splits
462
int splitheight;
463
464
float c_off; // ul center texel offset (both x and y)
465
float c_scl_x; // scale to lower-right center-texel x
466
float c_scl_y; // scale to lower-right center-texel y
467
468
wxUint32 mod, mod_color, mod_color1, mod_color2, mod_factor;
469
#ifdef TEXTURE_FILTER
470
uint64 ricecrc;
471
int is_hires_tex;
472
#endif
473
} CACHE_LUT;
474
475
// Lights
476
typedef struct {
477
float r, g, b, a; // color
478
float dir_x, dir_y, dir_z; // direction towards the light source
479
float x, y, z, w; // light position
480
float ca, la, qa;
481
wxUint32 nonblack;
482
wxUint32 nonzero;
483
} LIGHT;
484
485
typedef enum {
486
ci_main, //0, main color image
487
ci_zimg, //1, depth image
488
ci_unknown, //2, status is unknown
489
ci_useless, //3, status is unclear
490
ci_old_copy, //4, auxiliary color image, copy of last color image from previous frame
491
ci_copy, //5, auxiliary color image, copy of previous color image
492
ci_copy_self, //6, main color image, it's content will be used to draw into itself
493
ci_zcopy, //7, auxiliary color image, copy of depth image
494
ci_aux, //8, auxiliary color image
495
ci_aux_copy //9, auxiliary color image, partial copy of previous color image
496
} CI_STATUS;
497
498
// Frame buffers
499
typedef struct
500
{
501
wxUint32 addr; //color image address
502
wxUint8 format;
503
wxUint8 size;
504
wxUint16 width;
505
wxUint16 height;
506
CI_STATUS status;
507
int changed;
508
} COLOR_IMAGE;
509
510
typedef struct
511
{
512
GrChipID_t tmu;
513
wxUint32 addr; //address of color image
514
wxUint32 end_addr;
515
wxUint32 tex_addr; //address in video memory
516
wxUint32 width; //width of color image
517
wxUint32 height; //height of color image
518
wxUint8 format; //format of color image
519
wxUint8 size; //format of color image
520
wxUint8 clear; //flag. texture buffer must be cleared
521
wxUint8 drawn; //flag. if equal to 1, this image was already drawn in current frame
522
wxUint32 crc; //checksum of the color image
523
float scr_width; //width of rendered image
524
float scr_height; //height of rendered image
525
wxUint32 tex_width; //width of texture buffer
526
wxUint32 tex_height; //height of texture buffer
527
int tile; //
528
wxUint16 tile_uls; //shift from left bound of the texture
529
wxUint16 tile_ult; //shift from top of the texture
530
wxUint32 v_shift; //shift from top of the texture
531
wxUint32 u_shift; //shift from left of the texture
532
float lr_u;
533
float lr_v;
534
float u_scale; //used to map vertex u,v coordinates into hires texture
535
float v_scale; //used to map vertex u,v coordinates into hires texture
536
CACHE_LUT * cache; //pointer to texture cache item
537
GrTexInfo info;
538
wxUint16 t_mem;
539
} TBUFF_COLOR_IMAGE;
540
541
typedef struct
542
{
543
GrChipID_t tmu;
544
wxUint32 begin; //start of the block in video memory
545
wxUint32 end; //end of the block in video memory
546
wxUint8 count; //number of allocated texture buffers
547
int clear_allowed; //stack of buffers can be cleared
548
TBUFF_COLOR_IMAGE images[256];
549
} TEXTURE_BUFFER;
550
551
#define NUMTEXBUF 92
552
553
struct RDP_Base{
554
float vi_width;
555
float vi_height;
556
557
int window_changed;
558
559
float offset_x, offset_y, offset_x_bak, offset_y_bak;
560
561
float scale_x, scale_1024, scale_x_bak;
562
float scale_y, scale_768, scale_y_bak;
563
564
float view_scale[3];
565
float view_trans[3];
566
float clip_min_x, clip_max_x, clip_min_y, clip_max_y;
567
float clip_ratio;
568
569
int updatescreen;
570
571
wxUint32 tri_n; // triangle counter
572
wxUint32 debug_n;
573
574
// Program counter
575
wxUint32 pc[10]; // DList PC stack
576
wxUint32 pc_i; // current PC index in the stack
577
int dl_count; // number of instructions before returning
578
int LLE;
579
580
// Segments
581
wxUint32 segment[16]; // Segment pointer
582
583
// Marks the end of DList execution (done in uc?:enddl)
584
int halt;
585
586
// Next command
587
wxUint32 cmd0;
588
wxUint32 cmd1;
589
wxUint32 cmd2;
590
wxUint32 cmd3;
591
592
// Clipping
593
SCISSOR scissor_o;
594
SCISSOR scissor;
595
int scissor_set;
596
597
// Colors
598
wxUint32 fog_color;
599
wxUint32 fill_color;
600
wxUint32 prim_color;
601
wxUint32 blend_color;
602
wxUint32 env_color;
603
wxUint32 SCALE;
604
wxUint32 CENTER;
605
wxUint32 prim_lodmin, prim_lodfrac;
606
wxUint16 prim_depth;
607
wxUint16 prim_dz;
608
wxUint8 K4;
609
wxUint8 K5;
610
enum {
611
noise_none,
612
noise_combine,
613
noise_texture
614
} noise;
615
616
float col[4]; // color multiplier
617
float coladd[4]; // color add/subtract
618
float shade_factor;
619
620
float col_2[4];
621
622
wxUint32 cmb_flags, cmb_flags_2;
623
624
// othermode_l flags
625
int acmp; // 0 = none, 1 = threshold, 2 = dither
626
int zsrc; // 0 = pixel, 1 = prim
627
wxUint8 alpha_dither_mode;
628
629
// Matrices
630
DECLAREALIGN16VAR(model[4][4]);
631
DECLAREALIGN16VAR(proj[4][4]);
632
DECLAREALIGN16VAR(combined[4][4]);
633
DECLAREALIGN16VAR(dkrproj[3][4][4]);
634
635
DECLAREALIGN16VAR(model_stack[32][4][4]); // 32 deep, will warn if overflow
636
int model_i; // index in the model matrix stack
637
int model_stack_size;
638
639
// Textures
640
TEXTURE_IMAGE timg; // 1 for each tmem address
641
TILE tiles[8]; // 8 tile descriptors
642
wxUint8 tmem[4096]; // 4k tmem
643
wxUint32 addr[512]; // 512 addresses (used to determine address loaded from)
644
#ifdef TEXTURE_FILTER
645
LOAD_TILE_INFO load_info[512]; // 512 addresses. inforamation about tile loading.
646
#endif
647
648
int cur_tile; // current tile
649
int mipmap_level;
650
int last_tile; // last tile set
651
int last_tile_size; // last tile size set
652
653
int t0, t1;
654
int best_tex; // if no 2-tmus, which texture? (0 or 1)
655
int tex;
656
int filter_mode;
657
658
// Texture palette
659
wxUint16 pal_8[256];
660
wxUint32 pal_8_crc[16];
661
wxUint32 pal_256_crc;
662
wxUint8 tlut_mode;
663
int LOD_en;
664
int Persp_en;
665
int persp_supported;
666
int force_wrap;
667
#ifdef TEXTURE_FILTER
668
wxUint16 pal_8_rice[512];
669
#endif
670
671
// Lighting
672
wxUint32 num_lights;
673
LIGHT light[12];
674
float light_vector[12][3];
675
float lookat[2][3];
676
int use_lookat;
677
678
// Combine modes
679
wxUint32 cycle1, cycle2, cycle_mode;
680
wxUint8 c_a0, c_b0, c_c0, c_d0, c_Aa0, c_Ab0, c_Ac0, c_Ad0;
681
wxUint8 c_a1, c_b1, c_c1, c_d1, c_Aa1, c_Ab1, c_Ac1, c_Ad1;
682
683
wxUint8 fbl_a0, fbl_b0, fbl_c0, fbl_d0;
684
wxUint8 fbl_a1, fbl_b1, fbl_c1, fbl_d1;
685
686
wxUint8 uncombined; // which is uncombined: 0x01=color 0x02=alpha 0x03=both
687
688
// float YUV_C0, YUV_C1, YUV_C2, YUV_C3, YUV_C4; //YUV textures conversion coefficients
689
690
// What needs updating
691
wxUint32 update;
692
wxUint32 flags;
693
694
int first;
695
696
wxUint32 tex_ctr; // incremented every time textures are updated
697
698
int allow_combine; // allow combine updating?
699
700
int s2dex_tex_loaded;
701
wxUint16 bg_image_height;
702
703
// Debug stuff
704
wxUint32 rm; // use othermode_l instead, this just as a check for changes
705
wxUint32 render_mode_changed;
706
wxUint32 geom_mode;
707
708
wxUint32 othermode_h;
709
wxUint32 othermode_l;
710
711
// used to check if in texrect while loading texture
712
wxUint8 texrecting;
713
714
//frame buffer related slots. Added by Gonetz
715
wxUint32 cimg, ocimg, zimg, tmpzimg, vi_org_reg;
716
COLOR_IMAGE maincimg[2];
717
wxUint32 last_drawn_ci_addr;
718
wxUint32 main_ci, main_ci_end, main_ci_bg, main_ci_last_tex_addr, zimg_end, last_bg;
719
wxUint32 ci_width, ci_height, ci_size, ci_end;
720
wxUint32 zi_width;
721
int zi_lrx, zi_lry;
722
wxUint8 ci_count, num_of_ci, main_ci_index, copy_ci_index, copy_zi_index;
723
int swap_ci_index, black_ci_index;
724
wxUint32 ci_upper_bound, ci_lower_bound;
725
int motionblur, fb_drawn, fb_drawn_front, read_previous_ci, read_whole_frame;
726
CI_STATUS ci_status;
727
TBUFF_COLOR_IMAGE * cur_image; //image currently being drawn
728
TBUFF_COLOR_IMAGE * tbuff_tex; //image, which corresponds to currently selected texture
729
TBUFF_COLOR_IMAGE * aTBuffTex[2];
730
wxUint8 cur_tex_buf;
731
wxUint8 acc_tex_buf;
732
int skip_drawing; //rendering is not required. used for frame buffer emulation
733
734
//fog related slots. Added by Gonetz
735
float fog_multiplier, fog_offset;
736
enum {
737
fog_disabled,
738
fog_enabled,
739
fog_blend,
740
fog_blend_inverse
741
}
742
fog_mode;
743
};
744
745
struct RDP : public RDP_Base
746
{
747
// Clipping
748
int clip; // clipping flags
749
VERTEX *vtx1; //[256] copy vertex buffer #1 (used for clipping)
750
VERTEX *vtx2; //[256] copy vertex buffer #2
751
VERTEX *vtxbuf; // current vertex buffer (reset to vtx, used to determine current vertex buffer)
752
VERTEX *vtxbuf2;
753
int n_global; // Used to pass the number of vertices from clip_z to clip_tri
754
int vtx_buffer;
755
756
CACHE_LUT *cache[MAX_TMU]; //[MAX_CACHE]
757
CACHE_LUT *cur_cache[MAX_TMU];
758
wxUint32 cur_cache_n[MAX_TMU];
759
int n_cached[MAX_TMU];
760
761
// Vertices
762
VERTEX *vtx; //[MAX_VTX]
763
int v0, vn;
764
765
COLOR_IMAGE *frame_buffers; //[NUMTEXBUF+2]
766
TEXTURE_BUFFER texbufs[2];
767
768
char RomName[21];
769
770
RDP();
771
~RDP();
772
void Reset();
773
};
774
775
776
void SetWireframeCol ();
777
void ChangeSize ();
778
void GoToFullScreen();
779
780
extern RDP rdp;
781
extern SETTINGS settings;
782
extern HOTKEY_INFO hotkey_info;
783
extern VOODOO voodoo;
784
785
extern GrTexInfo fontTex;
786
extern GrTexInfo cursorTex;
787
extern wxUint32 offset_font;
788
extern wxUint32 offset_cursor;
789
extern wxUint32 offset_textures;
790
extern wxUint32 offset_texbuf1;
791
792
extern int ucode_error_report;
793
794
/*
795
extern wxString pluginPath;
796
extern wxString iniPath;
797
*/
798
// RDP functions
799
void rdp_reset ();
800
801
extern const char *ACmp[];
802
extern const char *Mode0[];
803
extern const char *Mode1[];
804
extern const char *Mode2[];
805
extern const char *Mode3[];
806
extern const char *Alpha0[];
807
#define Alpha1 Alpha0
808
extern const char *Alpha2[];
809
#define Alpha3 Alpha0
810
extern const char *FBLa[];
811
extern const char *FBLb[];
812
extern const char *FBLc[];
813
extern const char *FBLd[];
814
extern const char *str_zs[];
815
extern const char *str_yn[];
816
extern const char *str_offon[];
817
extern const char *str_cull[];
818
// I=intensity probably
819
extern const char *str_format[];
820
extern const char *str_size[];
821
extern const char *str_cm[];
822
extern const char *str_lod[];
823
extern const char *str_aspect[];
824
extern const char *str_filter[];
825
extern const char *str_tlut[];
826
extern const char *CIStatus[];
827
828
#define FBL_D_1 2
829
#define FBL_D_0 3
830
831
#ifndef max
832
#define max(a,b) (((a) > (b)) ? (a) : (b))
833
#endif
834
#ifndef min
835
#define min(a,b) (((a) < (b)) ? (a) : (b))
836
#endif
837
#ifndef TRUE
838
#define TRUE 1
839
#endif
840
#ifndef FALSE
841
#define FALSE 0
842
#endif
843
#ifndef HIWORD
844
#define HIWORD(a) ((unsigned int)(a) >> 16)
845
#endif
846
#ifndef LOWORD
847
#define LOWORD(a) ((a) & 0xFFFF)
848
#endif
849
850
// Convert from u0/v0/u1/v1 to the real coordinates without regard to tmu
851
__inline void ConvertCoordsKeep (VERTEX *v, int n)
852
{
853
for (int i=0; i<n; i++)
854
{
855
v[i].uc(0) = v[i].u0;
856
v[i].vc(0) = v[i].v0;
857
v[i].uc(1) = v[i].u1;
858
v[i].vc(1) = v[i].v1;
859
}
860
}
861
862
// Convert from u0/v0/u1/v1 to the real coordinates based on the tmu they are on
863
__inline void ConvertCoordsConvert (VERTEX *v, int n)
864
{
865
for (int i=0; i<n; i++)
866
{
867
v[i].uc(rdp.t0) = v[i].u0;
868
v[i].vc(rdp.t0) = v[i].v0;
869
v[i].uc(rdp.t1) = v[i].u1;
870
v[i].vc(rdp.t1) = v[i].v1;
871
}
872
}
873
874
__inline void AllowShadeMods (VERTEX *v, int n)
875
{
876
for (int i=0; i<n; i++)
877
{
878
v[i].shade_mod = 0;
879
}
880
}
881
882
__inline void AddOffset (VERTEX *v, int n)
883
{
884
for (int i=0; i<n; i++)
885
{
886
v[i].x += rdp.offset_x;
887
v[i].y += rdp.offset_y;
888
}
889
}
890
891
__inline void CalculateFog (VERTEX *v)
892
{
893
if (rdp.flags & FOG_ENABLED)
894
{
895
if (v->w < 0.0f)
896
v->f = 0.0f;
897
else
898
v->f = min(255.0f, max(0.0f, v->z_w * rdp.fog_multiplier + rdp.fog_offset));
899
v->a = (wxUint8)v->f;
900
}
901
else
902
{
903
v->f = 1.0f;
904
}
905
}
906
907
void newSwapBuffers();
908
extern int SwapOK;
909
910
// ** utility functions
911
void load_palette (wxUint32 addr, wxUint16 start, wxUint16 count);
912
void setTBufTex(wxUint16 t_mem, wxUint32 cnt);
913
914
#endif // ifndef RDP_H
915
916