Previous 15994 Revisions Next

r7677 Friday 2nd April, 2010 at 05:56:21 UTC by MooglyGuy
Sync with MAME
[src/mame/video]n64.c

src/mame/video/n64.c
r7676r7677
1/*
2    Nintendo 64 Video Hardware
1/******************************************************************************
32
4    Initial version by Ville Linde
5    Many improvements by Harmony
6    Many improvements by angrylion, Ziggy, Gonetz, Orkin
7*/
83
4    SGI/Nintendo Reality Display Processor
5    -------------------
6
7    Initial revision by Ville Linde
8    Many improvements by Harmony, angrylion, Ziggy, Gonetz and Orkin
9
10    Class re-write by Harmony
11
12
13*******************************************************************************
14
15STATUS:
16
17Much behavior needs verification against real hardware.  Many literal edge
18cases must be verified on real hardware as well.
19
20TODO:
21
22- Further re-work class structure to avoid dependencies
23
24*******************************************************************************/
25
926#include "emu.h"
1027#include "includes/n64.h"
1128#include "video/n64.h"
r7676r7677
2138// The functions in this file should be moved into the parent Processor class.
2239#include "rdpfiltr.c"
2340
24void N64::RDP::Processor::GetAlphaCvg(UINT8 *comb_alpha)
41namespace N64
2542{
43
44namespace RDP
45{
46
47void Processor::GetAlphaCvg(UINT8 *comb_alpha)
48{
2649   if(m_other_modes.cvg_times_alpha)
2750   {
2851      if(m_other_modes.alpha_cvg_select)
r7676r7677
83106
84107/*****************************************************************************/
85108
86void N64::RDP::Processor::VideoUpdate(bitmap_t *bitmap)
109void Processor::VideoUpdate(bitmap_t *bitmap)
87110{
88111   switch(n64_vi_control & 0x3)
89112   {
r7676r7677
101124   }
102125}
103126
104void N64::RDP::Processor::VideoUpdate16(bitmap_t *bitmap)
127void Processor::VideoUpdate16(bitmap_t *bitmap)
105128{
106129    int fsaa = (((n64_vi_control >> 8) & 3) < 2);
107130    int divot = (n64_vi_control >> 4) & 1;
r7676r7677
145168
146169         for(int i = 0; i < hres; i++)
147170         {
148            N64::RDP::Color c;
171            Color c;
149172            //int r, g, b;
150173
151174            UINT16 pix = frame_buffer[pixels ^ WORD_ADDR_XOR];
r7676r7677
236259   }
237260}
238261
239void N64::RDP::Processor::VideoUpdate32(bitmap_t *bitmap)
262void Processor::VideoUpdate32(bitmap_t *bitmap)
240263{
241264    int gamma = (n64_vi_control >> 3) & 1;
242265    int gamma_dither = (n64_vi_control >> 2) & 1;
r7676r7677
319342
320343/*****************************************************************************/
321344
322void N64::RDP::Processor::TCDiv(INT32 ss, INT32 st, INT32 sw, INT32* sss, INT32* sst)
345void Processor::TCDiv(INT32 ss, INT32 st, INT32 sw, INT32* sss, INT32* sst)
323346{
324347   int shift;
325348
r7676r7677
345368   }
346369}
347370
348void N64::RDP::Processor::SetSubAInputRGB(UINT8 **input_r, UINT8 **input_g, UINT8 **input_b, int code)
371void Processor::SetSubAInputRGB(UINT8 **input_r, UINT8 **input_g, UINT8 **input_b, int code)
349372{
350373   switch (code & 0xf)
351374   {
r7676r7677
364387   }
365388}
366389
367void N64::RDP::Processor::SetSubBInputRGB(UINT8 **input_r, UINT8 **input_g, UINT8 **input_b, int code)
390void Processor::SetSubBInputRGB(UINT8 **input_r, UINT8 **input_g, UINT8 **input_b, int code)
368391{
369392   switch (code & 0xf)
370393   {
r7676r7677
383406   }
384407}
385408
386void N64::RDP::Processor::SetMulInputRGB(UINT8 **input_r, UINT8 **input_g, UINT8 **input_b, int code)
409void Processor::SetMulInputRGB(UINT8 **input_r, UINT8 **input_g, UINT8 **input_b, int code)
387410{
388411   switch (code & 0x1f)
389412   {
r7676r7677
411434   }
412435}
413436
414void N64::RDP::Processor::SetAddInputRGB(UINT8 **input_r, UINT8 **input_g, UINT8 **input_b, int code)
437void Processor::SetAddInputRGB(UINT8 **input_r, UINT8 **input_g, UINT8 **input_b, int code)
415438{
416439   switch (code & 0x7)
417440   {
r7676r7677
426449   }
427450}
428451
429void N64::RDP::Processor::SetSubInputAlpha(UINT8 **input, int code)
452void Processor::SetSubInputAlpha(UINT8 **input, int code)
430453{
431454   switch (code & 0x7)
432455   {
r7676r7677
441464   }
442465}
443466
444void N64::RDP::Processor::SetMulInputAlpha(UINT8 **input, int code)
467void Processor::SetMulInputAlpha(UINT8 **input, int code)
445468{
446469   switch (code & 0x7)
447470   {
r7676r7677
456479   }
457480}
458481
459void N64::RDP::Processor::SetBlenderInput(int cycle, int which, UINT8 **input_r, UINT8 **input_g, UINT8 **input_b, UINT8 **input_a, int a, int b)
482void Processor::SetBlenderInput(int cycle, int which, UINT8 **input_r, UINT8 **input_g, UINT8 **input_b, UINT8 **input_a, int a, int b)
460483{
461484   switch (a & 0x3)
462485   {
r7676r7677
524547   }
525548}
526549
527const UINT8 N64::RDP::Processor::s_bayer_matrix[16] =
550const UINT8 Processor::s_bayer_matrix[16] =
528551{ /* Bayer matrix */
529552    0,  4,  1, 5,
530553    6,  2,  7, 3,
r7676r7677
532555    7,  3,  6, 2
533556};
534557
535const UINT8 N64::RDP::Processor::s_magic_matrix[16] =
558const UINT8 Processor::s_magic_matrix[16] =
536559{ /* Magic square matrix */
537560    0,  6,  1, 7,
538561    4,  2,  5, 3,
r7676r7677
540563    7,  1,  6, 0
541564};
542565
543const N64::RDP::Processor::ZDecompressEntry N64::RDP::Processor::m_z_decompress_table[8] =
566const Processor::ZDecompressEntry Processor::m_z_decompress_table[8] =
544567{
545568   { 6, 0x00000 },
546569   { 5, 0x20000 },
r7676r7677
554577
555578/*****************************************************************************/
556579
557void N64::RDP::Processor::BuildCompressedZTable()
580void Processor::BuildCompressedZTable()
558581{
559582   for(int j = 0; j < 0x40000; j++)
560583   {
r7676r7677
572595   }
573596}
574597
575void N64::RDP::Processor::ZStore(UINT16* zb, UINT8* zhb, UINT32 z, UINT32 deltaz)
598void Processor::ZStore(UINT16* zb, UINT8* zhb, UINT32 z, UINT32 deltaz)
576599{
577600   UINT8 deltazmem = 15;
578601   z &= 0x3ffff;
r7676r7677
596619   *zhb = (deltazmem & 3);
597620}
598621
599UINT32 N64::RDP::Processor::DecompressZ(UINT16 *zb)
622UINT32 Processor::DecompressZ(UINT16 *zb)
600623{
601624   UINT32 exponent = (*zb >> 13) & 7;
602625   UINT32 mantissa = (*zb >> 2) & 0x7ff;
603626   return ((mantissa << m_z_decompress_table[exponent].shift) + m_z_decompress_table[exponent].add);
604627}
605628
606UINT16 N64::RDP::Processor::DecompressDZ(UINT16* zb, UINT8* zhb)
629UINT16 Processor::DecompressDZ(UINT16* zb, UINT8* zhb)
607630{
608631   UINT32 dz_compressed = (((*zb & 3) << 2)|(*zhb & 3));
609632   return (1 << dz_compressed);
610633}
611634
612INT32 N64::RDP::Processor::NormalizeDZPix(INT32 sum)
635INT32 Processor::NormalizeDZPix(INT32 sum)
613636{
614637   if (sum & 0xc000)
615638   {
r7676r7677
629652    return 0;
630653}
631654
632bool N64::RDP::Processor::ZCompare(void* fb, UINT8* hb, UINT16* zb, UINT8* zhb, UINT32 sz, UINT16 dzpix)
655bool Processor::ZCompare(void* fb, UINT8* hb, UINT16* zb, UINT8* zhb, UINT32 sz, UINT16 dzpix)
633656{
634657   int force_coplanar = 0;
635658   UINT32 oz = DecompressZ(zb);
r7676r7677
738761   }
739762}
740763
741UINT32 N64::RDP::Processor::GetLog2(UINT32 lod_clamp)
764UINT32 Processor::GetLog2(UINT32 lod_clamp)
742765{
743766   if (lod_clamp < 2)
744767   {
r7676r7677
760783
761784/*****************************************************************************/
762785
763static void fill_rectangle_32bit(running_machine *machine, N64::RDP::Rectangle *rect)
764{
765   _n64_state *state = (_n64_state *)machine->driver_data;
766
767   UINT32 *fb = (UINT32*)&rdram[(state->m_rdp.GetMiscState()->m_fb_address / 4)];
768   int x1 = rect->m_xh;
769   int x2 = rect->m_xl;
770   int y1 = rect->m_yh;
771   int y2 = rect->m_yl;
772   int fill_cvg = 0;
773
774   // clip
775   if (x1 < state->m_rdp.GetScissor()->m_xh)
776   {
777      x1 = state->m_rdp.GetScissor()->m_xh;
778   }
779   if (y1 < state->m_rdp.GetScissor()->m_yh)
780   {
781      y1 = state->m_rdp.GetScissor()->m_yh;
782   }
783   if (x2 >= state->m_rdp.GetScissor()->m_xl)
784   {
785      x2 = state->m_rdp.GetScissor()->m_xl - 1;
786   }
787   if (y2 >= state->m_rdp.GetScissor()->m_yl)
788   {
789      y2 = state->m_rdp.GetScissor()->m_yl - 1;
790   }
791
792   state->m_rdp.GetShadeColor()->c = 0;
793
794   fill_cvg = ((state->m_rdp.GetFillColor32() >> 5) & 7) + 1;
795
796   if (state->m_rdp.GetOtherModes()->cycle_type == CYCLE_TYPE_FILL)
797   {
798      for (int j = y1; j <= y2; j++)
799      {
800         int index = j * state->m_rdp.GetMiscState()->m_fb_width;
801
802         for (int i = x1; i <= x2; i++)
803         {
804            fb[(index + i)^1] = state->m_rdp.GetFillColor32();
805         }
806      }
807   }
808   else if (state->m_rdp.GetOtherModes()->cycle_type == CYCLE_TYPE_1)
809   {
810      for (int j = y1; j <= y2; j++)
811      {
812         N64::RDP::Color c1;
813         int index = j * state->m_rdp.GetMiscState()->m_fb_width;
814         for (int i = x1; i <= x2; i++)
815         {
816            state->m_rdp.GetMiscState()->m_curpixel_cvg = fill_cvg;
817
818            c1.i.r = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_r[1],
819                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_r[1],
820                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_r[1],
821                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_r[1]);
822            c1.i.g = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_g[1],
823                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_g[1],
824                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_g[1],
825                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_g[1]);
826            c1.i.b = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_b[1],
827                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_b[1],
828                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_b[1],
829                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_b[1]);
830            c1.i.a = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_alphasub_a[1],
831                          *state->m_rdp.GetColorInputs()->combiner_alphasub_b[1],
832                          *state->m_rdp.GetColorInputs()->combiner_alphamul[1],
833                          *state->m_rdp.GetColorInputs()->combiner_alphaadd[1]);
834            state->m_rdp.GetAlphaCvg(&c1.i.a);
835
836            state->m_rdp.GetBlender()->Blend(&fb[(index + i)], NULL, c1, *state->m_rdp.GetZero(), 0);
837         }
838      }
839   }
840   else if (state->m_rdp.GetOtherModes()->cycle_type == CYCLE_TYPE_2)
841   {
842      for (int j = y1; j <= y2; j++)
843      {
844         N64::RDP::Color c1, c2;
845         int index = j * state->m_rdp.GetMiscState()->m_fb_width;
846         for (int i = x1; i <= x2; i++)
847         {
848            state->m_rdp.GetMiscState()->m_curpixel_cvg = fill_cvg;
849
850            c1.i.r = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_r[0],
851                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_r[0],
852                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_r[0],
853                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_r[0]);
854            c1.i.g = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_g[0],
855                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_g[0],
856                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_g[0],
857                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_g[0]);
858            c1.i.b = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_b[0],
859                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_b[0],
860                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_b[0],
861                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_b[0]);
862            c1.i.a = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_alphasub_a[0],
863                          *state->m_rdp.GetColorInputs()->combiner_alphasub_b[0],
864                          *state->m_rdp.GetColorInputs()->combiner_alphamul[0],
865                          *state->m_rdp.GetColorInputs()->combiner_alphaadd[0]);
866            state->m_rdp.GetCombinedColor()->c = c1.c;
867            c2.c = state->m_rdp.GetTexel0Color()->c;
868            state->m_rdp.GetTexel0Color()->c = state->m_rdp.GetTexel1Color()->c;
869            state->m_rdp.GetTexel1Color()->c = c2.c;
870            c2.i.r = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_r[1],
871                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_r[1],
872                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_r[1],
873                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_r[1]);
874            c2.i.g = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_g[1],
875                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_g[1],
876                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_g[1],
877                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_g[1]);
878            c2.i.b = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_b[1],
879                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_b[1],
880                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_b[1],
881                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_b[1]);
882            c2.i.a = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_alphasub_a[1],
883                          *state->m_rdp.GetColorInputs()->combiner_alphasub_b[1],
884                          *state->m_rdp.GetColorInputs()->combiner_alphamul[1],
885                          *state->m_rdp.GetColorInputs()->combiner_alphaadd[1]);
886            state->m_rdp.GetAlphaCvg(&c2.i.a);
887
888            state->m_rdp.GetBlender()->Blend(&fb[(index + i)], NULL, c1, c2, 0);
889            //BLENDER2_32(&fb[(index + i)], c1, c2);
890         }
891      }
892   }
893   else
894   {
895      fatalerror("fill_rectangle_32bit: cycle type copy");
896   }
897}
898
899INLINE void texture_rectangle_32bit(running_machine *machine, N64::RDP::TexRectangle *rect)
900{   // TODO: Z-compare and Z-update
901   _n64_state *state = (_n64_state *)machine->driver_data;
902
903   UINT32 *fb = (UINT32*)&rdram[(state->m_rdp.GetMiscState()->m_fb_address / 4)];
904
905   UINT32 tilenum = rect->m_tilenum;
906   UINT32 tilenum2 = 0;
907   N64::RDP::Tile *tex_tile = &state->m_rdp.GetTiles()[rect->m_tilenum];
908   N64::RDP::Tile *tex_tile2 = NULL;
909
910   int x1 = rect->m_xh;
911   int x2 = rect->m_xl;
912   int y1 = rect->m_yh;
913   int y2 = rect->m_yl;
914
915   if (state->m_rdp.GetOtherModes()->cycle_type == CYCLE_TYPE_FILL || state->m_rdp.GetOtherModes()->cycle_type == CYCLE_TYPE_COPY)
916   {
917      rect->m_dsdx /= 4;
918      x2 += 1;
919      y2 += 1;
920   }
921
922   // clip
923   if (x1 < state->m_rdp.GetScissor()->m_xh)
924   {
925      x1 = state->m_rdp.GetScissor()->m_xh;
926   }
927   if (y1 < state->m_rdp.GetScissor()->m_yh)
928   {
929      y1 = state->m_rdp.GetScissor()->m_yh;
930   }
931   if (x2 >= state->m_rdp.GetScissor()->m_xl)
932   {
933      x2 = state->m_rdp.GetScissor()->m_xl - 1;
934   }
935   if (y2 >= state->m_rdp.GetScissor()->m_yl)
936   {
937      y2 = state->m_rdp.GetScissor()->m_yl - 1;
938   }
939
940   state->m_rdp.GetTexPipe()->CalculateClampDiffs(tex_tile->num);
941
942   if (state->m_rdp.GetOtherModes()->cycle_type == CYCLE_TYPE_2)
943   {
944      if (!state->m_rdp.GetOtherModes()->tex_lod_en)
945      {
946         tilenum2 = (tilenum + 1) & 7;
947         tex_tile2 = &state->m_rdp.GetTiles()[tilenum2];
948      }
949      else
950      {
951         tilenum2 = (tilenum + 1) & 7;
952         tex_tile2 = &state->m_rdp.GetTiles()[tilenum2];
953      }
954   }
955
956   state->m_rdp.GetShadeColor()->c = 0;   // Needed by Pilotwings 64
957
958   int t = (int)(rect->m_t) << 5;
959
960   if (state->m_rdp.GetOtherModes()->cycle_type == CYCLE_TYPE_1)
961   {
962      for (int j = y1; j < y2; j++)
963      {
964         int fb_index = j * state->m_rdp.GetMiscState()->m_fb_width;
965
966         int s = (int)(rect->m_s) << 5;
967
968         for (int i = x1; i < x2; i++)
969         {
970            N64::RDP::Color c1;
971            int ss = s >> 5;
972            int st = t >> 5;
973
974            state->m_rdp.GetMiscState()->m_curpixel_cvg = 8;
975
976            if (rect->m_flip)
977            {
978               state->m_rdp.GetTexel0Color()->c = state->m_rdp.GetTexPipe()->Fetch(st, ss, tex_tile);
979            }
980            else
981            {
982               state->m_rdp.GetTexel0Color()->c = state->m_rdp.GetTexPipe()->Fetch(ss, st, tex_tile);
983            }
984
985            c1.i.r = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_r[1],
986                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_r[1],
987                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_r[1],
988                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_r[1]);
989            c1.i.g = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_g[1],
990                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_g[1],
991                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_g[1],
992                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_g[1]);
993            c1.i.b = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_b[1],
994                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_b[1],
995                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_b[1],
996                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_b[1]);
997            c1.i.a = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_alphasub_a[1],
998                          *state->m_rdp.GetColorInputs()->combiner_alphasub_b[1],
999                          *state->m_rdp.GetColorInputs()->combiner_alphamul[1],
1000                          *state->m_rdp.GetColorInputs()->combiner_alphaadd[1]);
1001            state->m_rdp.GetAlphaCvg(&c1.i.a);
1002
1003            state->m_rdp.GetBlender()->Blend(&fb[(fb_index + i)], NULL, c1, *state->m_rdp.GetZero(), 0);
1004
1005            s += rect->m_dsdx;
1006         }
1007
1008         t += rect->m_dtdy;
1009      }
1010   }
1011   else if (state->m_rdp.GetOtherModes()->cycle_type == CYCLE_TYPE_2)
1012   {
1013      for (int j = y1; j < y2; j++)
1014      {
1015         int fb_index = j * state->m_rdp.GetMiscState()->m_fb_width;
1016
1017         int s = (int)(rect->m_s) << 5;
1018
1019         for (int i = x1; i < x2; i++)
1020         {
1021            N64::RDP::Color c1, c2;
1022            int ss = s >> 5;
1023            int st = t >> 5;
1024
1025            state->m_rdp.GetMiscState()->m_curpixel_cvg = 8;
1026
1027            if (rect->m_flip)
1028            {
1029               state->m_rdp.GetTexel0Color()->c = state->m_rdp.GetTexPipe()->Fetch(st, ss, tex_tile);
1030               state->m_rdp.GetTexel1Color()->c = state->m_rdp.GetTexPipe()->Fetch(st, ss, tex_tile2);
1031            }
1032            else
1033            {
1034               state->m_rdp.GetTexel0Color()->c = state->m_rdp.GetTexPipe()->Fetch(ss, st, tex_tile);
1035               state->m_rdp.GetTexel1Color()->c = state->m_rdp.GetTexPipe()->Fetch(ss, st, tex_tile2);
1036            }
1037
1038            c1.i.r = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_r[0],
1039                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_r[0],
1040                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_r[0],
1041                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_r[0]);
1042            c1.i.g = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_g[0],
1043                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_g[0],
1044                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_g[0],
1045                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_g[0]);
1046            c1.i.b = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_b[0],
1047                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_b[0],
1048                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_b[0],
1049                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_b[0]);
1050            c1.i.a = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_alphasub_a[0],
1051                          *state->m_rdp.GetColorInputs()->combiner_alphasub_b[0],
1052                          *state->m_rdp.GetColorInputs()->combiner_alphamul[0],
1053                          *state->m_rdp.GetColorInputs()->combiner_alphaadd[0]);
1054            state->m_rdp.GetCombinedColor()->c = c1.c;
1055            c2.c = state->m_rdp.GetTexel0Color()->c;
1056            state->m_rdp.GetTexel0Color()->c = state->m_rdp.GetTexel1Color()->c;
1057            state->m_rdp.GetTexel1Color()->c = c2.c;
1058            c2.i.r = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_r[1],
1059                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_r[1],
1060                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_r[1],
1061                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_r[1]);
1062            c2.i.g = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_g[1],
1063                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_g[1],
1064                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_g[1],
1065                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_g[1]);
1066            c2.i.b = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_rgbsub_a_b[1],
1067                          *state->m_rdp.GetColorInputs()->combiner_rgbsub_b_b[1],
1068                          *state->m_rdp.GetColorInputs()->combiner_rgbmul_b[1],
1069                          *state->m_rdp.GetColorInputs()->combiner_rgbadd_b[1]);
1070            c2.i.a = LookUpCC(*state->m_rdp.GetColorInputs()->combiner_alphasub_a[1],
1071                          *state->m_rdp.GetColorInputs()->combiner_alphasub_b[1],
1072                          *state->m_rdp.GetColorInputs()->combiner_alphamul[1],
1073                          *state->m_rdp.GetColorInputs()->combiner_alphaadd[1]);
1074            state->m_rdp.GetAlphaCvg(&c2.i.a);
1075
1076            state->m_rdp.GetBlender()->Blend(&fb[(fb_index + i)], NULL, c1, c2, 0);
1077
1078            s += rect->m_dsdx;
1079         }
1080
1081         t += rect->m_dtdy;
1082      }
1083   }
1084   else if (state->m_rdp.GetOtherModes()->cycle_type == CYCLE_TYPE_COPY)
1085   {
1086      for (int j = y1; j < y2; j++)
1087      {
1088         int fb_index = j * state->m_rdp.GetMiscState()->m_fb_width;
1089
1090         int s = (int)(rect->m_s) << 5;
1091
1092         for (int i = x1; i < x2; i++)
1093         {
1094            int ss = s >> 5;
1095            int st = t >> 5;
1096            if (rect->m_flip)
1097            {
1098               state->m_rdp.GetTexel0Color()->c = state->m_rdp.GetTexPipe()->Fetch(st, ss, tex_tile);
1099            }
1100            else
1101            {
1102               state->m_rdp.GetTexel0Color()->c = state->m_rdp.GetTexPipe()->Fetch(ss, st, tex_tile);
1103            }
1104
1105            fb[fb_index + i] = (state->m_rdp.GetTexel0Color()->i.r << 24) | (state->m_rdp.GetTexel0Color()->i.g << 16) | (state->m_rdp.GetTexel0Color()->i.b << 8)|1;
1106
1107            s += rect->m_dsdx;
1108         }
1109
1110         t += rect->m_dtdy;
1111      }
1112   }
1113   else
1114   {
1115      fatalerror("texture_rectangle_32bit: unknown cycle type %d\n", state->m_rdp.GetOtherModes()->cycle_type);
1116   }
1117}
1118
1119/*****************************************************************************/
1120
1121786UINT32 N64::RDP::Processor::ReadData(UINT32 address)
1122787{
1123788   if (m_status & 0x1)      // XBUS_DMEM_DMA enabled
r7676r7677
21161781void N64::RDP::Processor::CmdTexRect(UINT32 w1, UINT32 w2)
21171782{
21181783   N64::RDP::TexRectangle rect(m_machine, m_cmd_data + m_cmd_cur, 0);
2119
2120   switch (m_misc_state.m_fb_size)
2121   {
2122      case PIXEL_SIZE_16BIT:
2123         rect.Draw();
2124         break;
2125      case PIXEL_SIZE_32BIT:
2126         texture_rectangle_32bit(m_machine, &rect);
2127         break;
2128   }
1784   rect.Draw();
21291785}
21301786
21311787void N64::RDP::Processor::CmdTexRectFlip(UINT32 w1, UINT32 w2)
21321788{
21331789   N64::RDP::TexRectangle rect(m_machine, m_cmd_data + m_cmd_cur, 1);
2134
2135   switch (m_misc_state.m_fb_size)
2136   {
2137      case PIXEL_SIZE_16BIT:      rect.Draw(); break;
2138      case PIXEL_SIZE_32BIT:      texture_rectangle_32bit(m_machine, &rect); break;
2139   }
1790   rect.Draw();
21401791}
21411792
21421793void N64::RDP::Processor::CmdSyncLoad(UINT32 w1, UINT32 w2)
r7676r7677
25422193{
25432194   N64::RDP::Rectangle rect(m_machine, m_cmd_data + m_cmd_cur);
25442195
2545   switch (m_misc_state.m_fb_size)
2546   {
2547      case PIXEL_SIZE_16BIT:
2548         rect.Draw();
2549         break;
2550      case PIXEL_SIZE_32BIT:
2551         fill_rectangle_32bit(m_machine, &rect);
2552         break;
2553   }
2196   rect.Draw();
25542197}
25552198
25562199void N64::RDP::Processor::CmdSetFogColor(UINT32 w1, UINT32 w2)
r7676r7677
28532496   m_start = m_current = m_end;
28542497}
28552498
2499} // namespace RDP
2500
2501} // namespace N64
2502
28562503/*****************************************************************************/
28572504
28582505VIDEO_START(n64)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team