Commits

Anonymous committed eb2c73d

more work on the asm

Comments (0)

Files changed (13)

 #endif
 
 #define G64_VERSION "'Napalm non-WX' WIP "
+#define RELTIME "Date: " __DATE__// " Time: " __TIME__
 
 #ifdef EXT_LOGGING
 std::ofstream extlog;
 
 // HINSTANCE hInstance = NULL;
 
-int to_fullscreen = FALSE;
-int fullscreen = FALSE;
-int romopen = FALSE;
+BOOL to_fullscreen = FALSE;
+BOOL fullscreen = FALSE;
+BOOL romopen = FALSE;
 GrContext_t gfx_context = 0;
-int debugging = FALSE;
-int exception = FALSE;
+BOOL debugging = FALSE;
+BOOL exception = FALSE;
 
-int evoodoo = 0;
-int ev_fullscreen = 0;
+BOOL evoodoo = 0;
+BOOL ev_fullscreen = 0;
+
+// not sure if this works at all; nothing has been tested on Windows
+#ifdef __WINDOWS__
+#define WINPROC_OVERRIDE
+#endif
+
 
 #ifdef ALTTAB_FIX
 HHOOK hhkLowLevelKybd = NULL;
 wxUint32   offset_textures = 0;
 wxUint32   offset_texbuf1 = 0;
 
+
 BOOL    capture_screen = 0;
 char    capture_path[256];
 
   wxUint32 vstart = dwVStartReg >> 16;
   wxUint32 vend = dwVStartReg & 0xFFFF;
 
-  sprintf (out_buf, "hstart: %d, hend: %d, vstart: %d, vend: %d\n", hstart, hend, vstart, vend);
-  LOG (out_buf);
-
   rdp.vi_width = (hend - hstart) * fscale_x;
   rdp.vi_height = (vend - vstart) * fscale_y * 1.0126582f;
   float aspect = (settings.adjust_aspect && (fscale_y > fscale_x) && (rdp.vi_width > rdp.vi_height)) ? fscale_x/fscale_y : 1.0f;
 
+#ifdef LOGGING
+  sprintf (out_buf, "hstart: %d, hend: %d, vstart: %d, vend: %d\n", hstart, hend, vstart, vend);
+  LOG (out_buf);
   sprintf (out_buf, "size: %d x %d\n", (int)rdp.vi_width, (int)rdp.vi_height);
   LOG (out_buf);
+#endif
 
   rdp.scale_x = (float)settings.res_x / rdp.vi_width;
   if (region > 0 && settings.pal230)
   //	settings.res_y = settings.scr_res_y;
 }
 
-#include "cursor.h"
-
-
 GRTEXBUFFEREXT   grTextureBufferExt = NULL;
 GRTEXBUFFEREXT   grTextureAuxBufferExt = NULL;
 GRAUXBUFFEREXT   grAuxBufferExt = NULL;
 #endif
 
   fullscreen = TRUE;
-  //fullscreen = FALSE;
+
   if (evoodoo_using_window)
     ev_fullscreen = FALSE;
   else
   LOG("CALL ReadScreen2 ()\n");
   *width = settings.res_x;
   *height = settings.res_y;
-  //wxUint8 * buff = (wxUint8*)malloc(settings.res_x * settings.res_y * 3);
-  // wxUint8 * line = buff;
-  //*dest = (void*)buff;
   if (dest)
   {
     BYTE * line = (BYTE*)dest;
     FXFALSE,
     &info))
   {
-    wxUint32 offset_src=info.strideInBytes*(settings.scr_res_y-1);
-
     // Copy the screen, let's hope this works.
       for (wxUint32 y=0; y<settings.res_y; y++)
       {
 
   PluginInfo->Version = 0x0103;     // Set to 0x0103
   PluginInfo->Type  = PLUGIN_TYPE_GFX;  // Set to PLUGIN_TYPE_GFX
-  sprintf (PluginInfo->Name, "Glide64 "G64_VERSION);  // Name of the DLL
+  sprintf (PluginInfo->Name, "Glide64 "G64_VERSION RELTIME);  // Name of the DLL
 
   // If DLL supports memory these memory options then set them to TRUE or FALSE
   //  if it does not support it
   debug_init ();    // Initialize debugger
 
   gfx = Gfx_Info;
-  /*
-  
-//  char name[21] = "DEFAULT";
-//  ReadSpecialSettings (name);
 
-  char name[21];
+  #warning Why is this here / disabled in old version?
+  char name[21] = "DEFAULT";
+  ReadSpecialSettings (name);
+
   // get the name of the ROM
   for (int i=0; i<20; i++)
     name[i] = gfx.HEADER[(32+i)^3];
     name[strlen(name)-1] = 0;
 
   ReadSpecialSettings (name);
-  */
+
 #ifdef WINPROC_OVERRIDE
   if (!oldWndProc)
   {
   while (name[strlen(name)-1] == ' ')
     name[strlen(name)-1] = 0;
 
+  strncpy(rdp.RomName, name, sizeof(name));
   ReadSpecialSettings (name);
-  strncpy(rdp.RomName, name, sizeof(name));
   
 //  WriteLog(M64MSG_INFO, "fb_clear %d fb_smart %d\n", settings.fb_depth_clear, settings.fb_smart);
   
   // printf("Rendercallback is %p\n", renderCallback);
   LOG("CALL UpdateScreen()");
 #ifdef LOG_KEY
-  if (GetAsyncKeyState (VK_SPACE) & 0x0001)
+  if (CheckKeyPressed(G64_VK_SPACE, 0x0001))
   {
     LOG ("KEY!!!\n");
   }

src/Makefile.nowx

 
 AS = nasm
 ASM_OBJ =
-#ASM_OBJ = Texture.o
+ASM_OBJ = Texture.o
 ifeq ($(OS), Linux)
 ASFLAGS = -O6 -felf -D__linux__ 
 #ASM_OBJ = \
 //
 //****************************************************************
 
+// I think this one is ok -- balrog
+
 //****************************************************************
 // 16-bit Horizontal Mirror
 #include <stdint.h>
     if (mask_width >= max_width) return;
     int count = max_width - mask_width;
     if (count <= 0) return;
-    int line_full = real_width;
-    int line = line_full - count;
+    int line_full = real_width << 1;
+    int line = line_full - (count << 1);
     if (line < 0) return;
     unsigned short * start = (unsigned short *)(tex) + mask_width;
     
         *edi = *esi;
         ++edi;
         }
-        edi += line;
-        tex += line_full << 1;
+        edi += line >> 1;
+        tex += line_full;
     }
 }
 
     unsigned char * start = tex + (mask_width << 1);
     
     // values that can't be changed are height and count
+
+//   asmWrap16bS (tex, start, height, mask_mask, line, line_full, count);
     
     wxUint32 *edi = (wxUint32 *)start;
 
     for(wxUint32 ecx = height; ecx; ecx--) {
       for(wxUint32 edx = 0; edx != count; edx++) {
         wxUint32 *esi = (wxUint32 *)tex;
-        tex += (edx & mask_mask);
+        esi += (edx & mask_mask);
         *edi = *esi;
         edi++;
       }
       edi += line >> 2;
-      tex += line_full >> 2;
+      tex += line_full;
     }
     
 }
   int line = line_full - (count); // << 2);
 	if (line < 0) return;
 	
-  unsigned int * start = (unsigned int *)(tex) + (mask_width); // << 2);
-	
-  // asmMirror32bS (tex, start, mask_width, height, mask_mask, line, line_full, count);
-
-	// ARGS in asm:   tex, start,      width, height, mask     , line,      full, count
+  unsigned int * start = (unsigned int *)(tex) + (mask_width);
 	
   unsigned int *edi = start;
+//     asmMirror32bS (tex, start, mask_width, height, mask_mask, line, line_full, count);
   
   for(unsigned int ecx = height; ecx; --ecx) {
     for(int edx = 0; edx != count; ++edx) {
   if (mask == 0) return;
 
   wxUint32 mask_width = (1 << mask);
-  wxUint32 mask_mask = (mask_width-1) >> 2;
+  wxUint32 mask_mask = (mask_width-1);
   if (mask_width >= max_width) return;
   int count = (max_width - mask_width);
   if (count <= 0) return;
 	wxUint32 *constant = dest-1;
 	
 	int count = clamp_to - width;
-
-  int line_full = real_width << 2;
-  int line = width << 2;
 	
 //    asmClamp32bS (dest, constant, real_height, line, line_full, count);	
 	
 	// converted asm portion begins here
   wxUint32 *esi = constant;
-  wxUint32 *edi = (wxUint32 *)dest;
+  wxUint32 *edi = dest;
   
   for(wxUint32 ecx = real_height; ecx; ecx--) {
     wxUint32 eax = *esi;
       *edi = eax;
       edi++;
     }
-    esi += line_full >> 2;
-    edi += line >> 2;
+    esi += real_width;
+    edi += width;
     
   }
 }
 //
 //****************************************************************
 
+// I am very confident I did this one right -- balrog
+
 //****************************************************************
 // 8-bit Horizontal Mirror
 
     int line = line_full - (count);
     if (line < 0) return;
     unsigned char * start = tex + (mask_width);
-#if !defined(__GNUC__) && !defined(NO_ASM)
-    __asm {
-        mov edi,dword ptr [start]
-
-        mov ecx,dword ptr [height]
-loop_y:
-
-        xor edx,edx
-loop_x:
-        mov esi,dword ptr [tex]
-        mov ebx,dword ptr [mask_width]
-        add ebx,edx
-        and ebx,dword ptr [mask_width]
-        jnz is_mirrored
-
-        mov eax,edx
-        and eax,dword ptr [mask_mask]
-        add esi,eax
-        mov al,byte ptr [esi]
-        mov byte ptr [edi],al
-        inc edi
-        jmp end_mirror_check
-is_mirrored:
-        add esi,dword ptr [mask_mask]
-        mov eax,edx
-        and eax,dword ptr [mask_mask]
-        sub esi,eax
-        mov al,byte ptr [esi]
-        mov byte ptr [edi],al
-        inc edi
-end_mirror_check:
-
-        inc edx
-        cmp edx,dword ptr [count]
-        jne loop_x
-
-        add edi,dword ptr [line]
-        mov eax,dword ptr [tex]
-        add eax,dword ptr [line_full]
-        mov dword ptr [tex],eax
-
-        dec ecx
-        jnz loop_y
+    
+    //   asmMirror8bS (tex, start, mask_width, height, mask_mask, line, line_full, count);
+    
+    unsigned char *edi = start;
+    
+    for(unsigned int ecx = height; ecx; --ecx) {
+      for(int edx = 0; edx != count; ++edx) {
+        
+        unsigned char *esi = tex;
+        if((mask_width + edx) & mask_width) {
+          esi += (mask_mask - (edx & mask_mask));
+        }
+        else
+        {
+          esi += (edx & mask_mask);
+        }
+        *edi = *esi;
+        edi++;
+      }
+      edi += line;
+      tex += line_full;
     }
-#elif !defined(NO_ASM)
-   //printf("Mirror8bS\n");
-    intptr_t fake_esi,fake_eax;
-   asm volatile (
-         "1:                        \n"  // loop_y3
-         
-         "xor %%edx, %%edx          \n"
-         "2:                        \n"  // loop_x3
-         "mov %[tex], %[S]        \n"
-         "mov %[mask_width], %%eax \n"
-         "add %%edx, %%eax          \n"
-         "and %[mask_width], %%eax \n"
-         "jnz 3f                   \n"  // is_mirrored2
-         
-         "mov %%edx, %%eax          \n"
-         "and %[mask_mask], %[a]    \n"
-         "add %[a], %[S]            \n"
-         "mov (%[S]), %%al          \n"
-         "mov %%al, (%[start])      \n"
-         "inc %[start]              \n"
-         "jmp 4f                    \n"  // end_mirror_check2
-         "3:                        \n"  // is_mirrored2
-         "add %[mask_mask], %[S]    \n"
-         "mov %%edx, %%eax          \n"
-         "and %[mask_mask], %[a]    \n"
-         "sub %[a], %[S]            \n"
-         "mov (%[S]), %%al          \n"
-         "mov %%al, (%[start])      \n"
-         "inc %[start]              \n"
-         "4:                        \n"  // end_mirror_check2
-         
-         "inc %%edx                 \n"
-         "cmp %[count], %%edx       \n"
-         "jne 2b                    \n"  // loop_x3
-         
-         "add %[line], %[start]     \n"
-         "add %[line_full], %[tex]  \n"
-         
-         "dec %%ecx                 \n"
-         "jnz 1b                    \n"  // loop_y3
-         : [S] "=&S" (fake_esi), [a]"=&a"(fake_eax), [start]"+D"(start), "+c"(height), [tex] "+r" (tex)
-         : [mask_width] "g" (mask_width), [mask_mask] "g" ((intptr_t)mask_mask), [count] "g" (count), [line] "g" ((intptr_t)line), [line_full] "g" ((intptr_t)line_full)
-         : "memory", "cc", "edx"
-         );
-#endif // _WIN32
 }
 
 //****************************************************************
 //****************************************************************
 // 8-bit Horizontal Wrap (like mirror) ** UNTESTED **
 
+
 void Wrap8bS (unsigned char * tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
 {
     if (mask == 0) return;
     int line = line_full - (count << 2);
     if (line < 0) return;
     unsigned char * start = tex + (mask_width);
-#if !defined(__GNUC__) && !defined(NO_ASM)
-    __asm {
-        mov edi,dword ptr [start]
-
-        mov ecx,dword ptr [height]
-loop_y:
-
-        xor edx,edx
-loop_x:
-
-        mov esi,dword ptr [tex]
-        mov eax,edx
-        and eax,dword ptr [mask_mask]
-        shl eax,2
-        add esi,eax
-        mov eax,dword ptr [esi]
-        mov dword ptr [edi],eax
-        add edi,4
-
-        inc edx
-        cmp edx,dword ptr [count]
-        jne loop_x
-
-        add edi,dword ptr [line]
-        mov eax,dword ptr [tex]
-        add eax,dword ptr [line_full]
-        mov dword ptr [tex],eax
-
-        dec ecx
-        jnz loop_y
+    
+    wxUint32 *edi = (wxUint32 *)start;
+    
+    for(wxUint32 ecx = height; ecx; ecx--) {
+      for(wxUint32 edx = 0; edx != count; edx++) {
+        wxUint32 *esi = (wxUint32 *)tex;
+        esi += (edx & mask_mask);
+        *edi = *esi;
+        edi++;
+      }
+      edi += line >> 2;
+      tex += line_full >> 2;
     }
-#elif !defined(NO_ASM)
-   //printf("wrap8bS\n");
-    intptr_t fake_esi,fake_eax;
-   asm volatile (
-         "1:                       \n"  // loop_y4
-
-         "xor %%edx, %%edx         \n"
-         "2:                       \n"  // loop_x4
-         
-         "mov %[tex], %[S]       \n"
-         "mov %%edx, %%eax         \n"
-         "and %[mask_mask], %%eax \n"
-         "shl $2, %%eax            \n"
-         "add %[a], %[S]         \n"
-         "mov (%[S]), %%eax       \n"
-         "mov %%eax, (%[start])       \n"
-         "add $4, %[start]            \n"
-         
-         "inc %%edx                \n"
-         "cmp %[count], %%edx     \n"
-         "jne 2b                     \n"  // loop_x4
-
-         "add %[line], %[start]      \n"
-         "add %[line_full], %[tex] \n"
-         
-         "dec %%ecx                \n"
-         "jnz 1b                   \n"  // loop_y4
-         : [S] "=&S" (fake_esi), [a]"=&a"(fake_eax), [start]"+D"(start), [tex] "+r" (tex), "+c"(height)
-         : [mask_mask] "g" (mask_mask), [count] "g" (count), [line] "g" ((intptr_t)line), [line_full] "g" ((intptr_t)line_full)
-         : "memory", "cc", "edx"
-         );
-#endif
 }
 
 //****************************************************************
 //****************************************************************
 // 8-bit Horizontal Clamp
 
+
 void Clamp8bS (unsigned char * tex, wxUint32 width, wxUint32 clamp_to, wxUint32 real_width, wxUint32 real_height)
 {
     if (real_width <= width) return;
 
     int line_full = real_width;
     int line = width;
-#if !defined(__GNUC__) && !defined(NO_ASM)
-    __asm {
-        mov esi,dword ptr [constant]
-        mov edi,dword ptr [dest]
+    
+//   asmClamp8bS (dest, constant, real_height, line, line_full, count);
 
-        mov ecx,real_height
-y_loop:
-
-        mov al,byte ptr [esi]
-
-        mov edx,dword ptr [count]
-x_loop:
-
-        mov byte ptr [edi],al       // don't unroll or make dword, it may go into next line (doesn't have to be multiple of two)
-        inc edi
-
-        dec edx
-        jnz x_loop
-
-        add esi,dword ptr [line_full]
-        add edi,dword ptr [line]
-
-        dec ecx
-        jnz y_loop
+    for(wxUint32 ecx = real_height; ecx; ecx--) {
+      for(wxUint32 edx = count; edx; edx--) {
+        *dest = *constant;
+        dest++;
+      }
+      constant += line_full;
+      dest += line;
     }
-#elif !defined(NO_ASM)
-   //printf("clamp8bs\n");
-   asm volatile (
-         "0: \n"
-         
-         "mov (%[constant]), %%al        \n"
-
-         "mov %[count], %%edx     \n"
-         "1: \n"
-         
-         "mov %%al, (%[dest])        \n"        // don't unroll or make dword, it may go into next line (doesn't have to be multiple of two)
-         "inc %[dest]                \n"
-         
-         "dec %%edx                \n"
-         "jnz 1b \n"
-         
-         "add %[line_full], %[constant] \n"
-         "add %[line], %[dest]      \n"
-         
-         "dec %%ecx                \n"
-         "jnz 0b \n"
-         : [constant]"+S"(constant), [dest]"+D"(dest), "+c"(real_height)
-         : [count] "g" (count), [line] "g" ((uintptr_t)line), [line_full] "g" ((intptr_t)line_full)
-         : "memory", "cc", "eax", "edx"
-         );
-#endif
 }
 
 //****************************************************************

src/MiClWr_old/MiClWr16b.h

 //****************************************************************
 // 16-bit Horizontal Mirror
 
-void Mirror16bS (wxUint32 tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
+void Mirror16bS (unsigned char * tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
 {
   if (mask == 0) return;
 
   int line_full = real_width << 1;
   int line = line_full - (count << 1);
   if (line < 0) return;
-  wxUint32 start = tex + (mask_width << 1);
-  asmMirror16bS (tex, start, mask_width, height, mask_mask, line, line_full, count);
+  wxUint32 start = (uintptr_t)tex + (mask_width << 1);
+  asmMirror16bS ((uintptr_t)tex, start, mask_width, height, mask_mask, line, line_full, count);
 }
 
 //****************************************************************
 // 16-bit Horizontal Wrap (like mirror)
 
-void Wrap16bS (wxUint32 tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
+void Wrap16bS (unsigned char * tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
 {
   if (mask == 0) return;
 
   int line_full = real_width << 1;
   int line = line_full - (count << 2);
   if (line < 0) return;
-  wxUint32 start = tex + (mask_width << 1);
-  asmWrap16bS (tex, start, height, mask_mask, line, line_full, count);
+  wxUint32 start = (uintptr_t)tex + (mask_width << 1);
+  asmWrap16bS ((uintptr_t)tex, start, height, mask_mask, line, line_full, count);
 }
 
 //****************************************************************
 // 16-bit Horizontal Clamp
 
-void Clamp16bS (wxUint32 tex, wxUint32 width, wxUint32 clamp_to, wxUint32 real_width, wxUint32 real_height)
+void Clamp16bS (unsigned char * tex, wxUint32 width, wxUint32 clamp_to, wxUint32 real_width, wxUint32 real_height)
 {
   if (real_width <= width) return;
 
-  wxUint32 dest = tex + (width << 1);
+  wxUint32 dest = (uintptr_t)tex + (width << 1);
   wxUint32 constant = dest-2;
   int count = clamp_to - width;
 
 //****************************************************************
 // 16-bit Vertical Mirror
 
-void Mirror16bT (wxUint32 tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
+void Mirror16bT (unsigned char * tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
 {
   if (mask == 0) return;
 
   if (max_height <= mask_height) return;
   int line_full = real_width << 1;
 
-  wxUint32 dst = tex + mask_height * line_full;
+  wxUint32 dst = (uintptr_t)tex + mask_height * line_full;
 
   for (wxUint32 y=mask_height; y<max_height; y++)
   {
     if (y & mask_height)
     {
       // mirrored
-      memcpy ((void*)dst, (void*)(tex + (mask_mask - (y & mask_mask)) * line_full), line_full);
+      memcpy ((void*)dst, (void*)((uintptr_t)tex + (mask_mask - (y & mask_mask)) * line_full), line_full);
     }
     else
     {
       // not mirrored
-      memcpy ((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
+      memcpy ((void*)dst, (void*)((uintptr_t)tex + (y & mask_mask) * line_full), line_full);
     }
 
     dst += line_full;
 //****************************************************************
 // 16-bit Vertical Wrap
 
-void Wrap16bT (wxUint32 tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
+void Wrap16bT (unsigned char * tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
 {
   if (mask == 0) return;
 
   if (max_height <= mask_height) return;
   int line_full = real_width << 1;
 
-  wxUint32 dst = tex + mask_height * line_full;
+  wxUint32 dst = (uintptr_t)tex + mask_height * line_full;
 
   for (wxUint32 y=mask_height; y<max_height; y++)
   {
     // not mirrored
-    memcpy ((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
+    memcpy ((void*)dst, (void*)((uintptr_t)tex + (y & mask_mask) * line_full), line_full);
 
     dst += line_full;
   }
 //****************************************************************
 // 16-bit Vertical Clamp
 
-void Clamp16bT (wxUint32 tex, wxUint32 height, wxUint32 real_width, wxUint32 clamp_to)
+void Clamp16bT (unsigned char * tex, wxUint32 height, wxUint32 real_width, wxUint32 clamp_to)
 {
   int line_full = real_width << 1;
-  wxUint32 dst = tex + height * line_full;
+  wxUint32 dst = (uintptr_t)tex + height * line_full;
   wxUint32 const_line = dst - line_full;
 
   for (wxUint32 y=height; y<clamp_to; y++)

src/MiClWr_old/MiClWr32b.h

 //****************************************************************
 // 32-bit Horizontal Mirror
 
-void Mirror32bS (wxUint32 tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
+void Mirror32bS (unsigned char * tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
 {
 	if (mask == 0) return;
 
 	int line_full = real_width << 2;
 	int line = line_full - (count << 2);
 	if (line < 0) return;
-	wxUint32 start = tex + (mask_width << 2);
-    asmMirror32bS (tex, start, mask_width, height, mask_mask, line, line_full, count);
+	wxUint32 start = (uintptr_t)tex + (mask_width << 2);
+    asmMirror32bS ((uintptr_t)tex, start, mask_width, height, mask_mask, line, line_full, count);
 }
 
 //****************************************************************
 // 32-bit Horizontal Wrap 
 
-void Wrap32bS (wxUint32 tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
+void Wrap32bS (unsigned char * tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
 {
 	if (mask == 0) return;
 
 	int line_full = real_width << 2;
 	int line = line_full - (count << 2);
 	if (line < 0) return;
-	wxUint32 start = tex + (mask_width << 2);
-    asmWrap32bS (tex, start, height, mask_mask, line, line_full, count);
+	wxUint32 start = (uintptr_t)tex + (mask_width << 2);
+    asmWrap32bS ((uintptr_t)tex, start, height, mask_mask, line, line_full, count);
 }
 
 //****************************************************************
 // 32-bit Horizontal Clamp
 
-void Clamp32bS (wxUint32 tex, wxUint32 width, wxUint32 clamp_to, wxUint32 real_width, wxUint32 real_height)
+void Clamp32bS (unsigned char * tex, wxUint32 width, wxUint32 clamp_to, wxUint32 real_width, wxUint32 real_height)
 {
 	if (real_width <= width) return;
 
-	wxUint32 dest = tex + (width << 2);
+	wxUint32 dest = (uintptr_t)tex + (width << 2);
 	wxUint32 constant = dest-4;
 	int count = clamp_to - width;
 
 //****************************************************************
 // 32-bit Vertical Mirror
 
-void Mirror32bT (wxUint32 tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
+void Mirror32bT (unsigned char * tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
 {
 	if (mask == 0) return;
 
 	if (max_height <= mask_height) return;
 	int line_full = real_width << 2;
 
-	wxUint32 dst = tex + mask_height * line_full;
+	wxUint32 dst = (uintptr_t)tex + mask_height * line_full;
 
 	for (wxUint32 y=mask_height; y<max_height; y++)
 	{
 		if (y & mask_height)
 		{
 			// mirrored
-			memcpy ((void*)dst, (void*)(tex + (mask_mask - (y & mask_mask)) * line_full), line_full);
+			memcpy ((void*)dst, (void*)((uintptr_t)tex + (mask_mask - (y & mask_mask)) * line_full), line_full);
 		}
 		else
 		{
 			// not mirrored
-			memcpy ((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
+			memcpy ((void*)dst, (void*)((uintptr_t)tex + (y & mask_mask) * line_full), line_full);
 		}
 
 		dst += line_full;
 //****************************************************************
 // 32-bit Vertical Wrap
 
-void Wrap32bT (wxUint32 tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
+void Wrap32bT (unsigned char * tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
 {
 	if (mask == 0) return;
 
 	if (max_height <= mask_height) return;
 	int line_full = real_width << 2;
 
-	wxUint32 dst = tex + mask_height * line_full;
+	wxUint32 dst = (uintptr_t)tex + mask_height * line_full;
 
 	for (wxUint32 y=mask_height; y<max_height; y++)
 	{
 		// not mirrored
-		memcpy ((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
+		memcpy ((void*)dst, (void*)((uintptr_t)tex + (y & mask_mask) * line_full), line_full);
 
 		dst += line_full;
 	}
 //****************************************************************
 // 32-bit Vertical Clamp
 
-void Clamp32bT (wxUint32 tex, wxUint32 height, wxUint32 real_width, wxUint32 clamp_to)
+void Clamp32bT (unsigned char * tex, wxUint32 height, wxUint32 real_width, wxUint32 clamp_to)
 {
 	int line_full = real_width << 2;
-	wxUint32 dst = tex + height * line_full;
+	wxUint32 dst = (uintptr_t)tex + height * line_full;
 	wxUint32 const_line = dst - line_full;
 
 	for (wxUint32 y=height; y<clamp_to; y++)

src/MiClWr_old/MiClWr8b.h

 extern "C" void asmWrap8bS (int tex, int start, int height, int mask, int line, int full, int count);
 extern "C" void asmClamp8bS (int tex, int constant, int height,int line, int full, int count);
 
-void Mirror8bS (wxUint32 tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
+void Mirror8bS (unsigned char * tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
 {
   if (mask == 0) return;
 
   int line_full = real_width;
   int line = line_full - (count);
   if (line < 0) return;
-  wxUint32 start = tex + (mask_width);
-  asmMirror8bS (tex, start, mask_width, height, mask_mask, line, line_full, count);
+  wxUint32 start = (uintptr_t)tex + (mask_width);
+  asmMirror8bS ((uintptr_t)tex, start, mask_width, height, mask_mask, line, line_full, count);
 }
 
 //****************************************************************
 // 8-bit Horizontal Wrap (like mirror) ** UNTESTED **
 
-void Wrap8bS (wxUint32 tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
+void Wrap8bS (unsigned char * tex, wxUint32 mask, wxUint32 max_width, wxUint32 real_width, wxUint32 height)
 {
   if (mask == 0) return;
 
   int line_full = real_width;
   int line = line_full - (count << 2);
   if (line < 0) return;
-  wxUint32 start = tex + (mask_width);
-  asmWrap8bS (tex, start, height, mask_mask, line, line_full, count);
+  wxUint32 start = (uintptr_t)tex + (mask_width);
+  asmWrap8bS ((uintptr_t)tex, start, height, mask_mask, line, line_full, count);
 }
 
 //****************************************************************
 // 8-bit Horizontal Clamp
 
-void Clamp8bS (wxUint32 tex, wxUint32 width, wxUint32 clamp_to, wxUint32 real_width, wxUint32 real_height)
+void Clamp8bS (unsigned char * tex, wxUint32 width, wxUint32 clamp_to, wxUint32 real_width, wxUint32 real_height)
 {
   if (real_width <= width) return;
 
-  wxUint32 dest = tex + (width);
+  wxUint32 dest = (uintptr_t)tex + (width);
   wxUint32 constant = dest-1;
   int count = clamp_to - width;
 
 //****************************************************************
 // 8-bit Vertical Mirror
 
-void Mirror8bT (wxUint32 tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
+void Mirror8bT (unsigned char * tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
 {
   if (mask == 0) return;
 
   if (max_height <= mask_height) return;
   int line_full = real_width;
 
-  wxUint32 dst = tex + mask_height * line_full;
+  wxUint32 dst = (uintptr_t)tex + mask_height * line_full;
 
   for (wxUint32 y=mask_height; y<max_height; y++)
   {
     if (y & mask_height)
     {
       // mirrored
-      memcpy ((void*)dst, (void*)(tex + (mask_mask - (y & mask_mask)) * line_full), line_full);
+      memcpy ((void*)dst, (void*)((uintptr_t)tex + (mask_mask - (y & mask_mask)) * line_full), line_full);
     }
     else
     {
       // not mirrored
-      memcpy ((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
+      memcpy ((void*)dst, (void*)((uintptr_t)tex + (y & mask_mask) * line_full), line_full);
     }
 
     dst += line_full;
 //****************************************************************
 // 8-bit Vertical Wrap
 
-void Wrap8bT (wxUint32 tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
+void Wrap8bT (unsigned char * tex, wxUint32 mask, wxUint32 max_height, wxUint32 real_width)
 {
   if (mask == 0) return;
 
   if (max_height <= mask_height) return;
   int line_full = real_width;
 
-  wxUint32 dst = tex + mask_height * line_full;
+  wxUint32 dst = (uintptr_t)tex + mask_height * line_full;
 
   for (wxUint32 y=mask_height; y<max_height; y++)
   {
     // not mirrored
-    memcpy ((void*)dst, (void*)(tex + (y & mask_mask) * line_full), line_full);
+    memcpy ((void*)dst, (void*)((uintptr_t)tex + (y & mask_mask) * line_full), line_full);
 
     dst += line_full;
   }
 //****************************************************************
 // 8-bit Vertical Clamp
 
-void Clamp8bT (wxUint32 tex, wxUint32 height, wxUint32 real_width, wxUint32 clamp_to)
+void Clamp8bT (unsigned char * tex, wxUint32 height, wxUint32 real_width, wxUint32 clamp_to)
 {
   int line_full = real_width;
-  wxUint32 dst = tex + height * line_full;
+  wxUint32 dst = (uintptr_t)tex + height * line_full;
   wxUint32 const_line = dst - line_full;
 
   for (wxUint32 y=height; y<clamp_to; y++)

src/MiClWr_old/TexConv.h

-/*
-* Glide64 - Glide video plugin for Nintendo 64 emulators.
-* Copyright (c) 2002  Dave2001
-* Copyright (c) 2003-2009  Sergey 'Gonetz' Lipski
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-//****************************************************************
-//
-// Glide64 - Glide Plugin for Nintendo 64 emulators
-// Project started on December 29th, 2001
-//
-// Authors:
-// Dave2001, original author, founded the project in 2001, left it in 2002
-// Gugaman, joined the project in 2002, left it in 2002
-// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
-// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
-//
-//****************************************************************
-//
-// To modify Glide64:
-// * 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.
-// * 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.
-//
-//****************************************************************
-
-extern "C" void asmTexConv_ARGB1555_ARGB4444(wxUIntPtr src, wxUIntPtr dst, int size);
-extern "C" void asmTexConv_AI88_ARGB4444(wxUIntPtr src, wxUIntPtr dst, int size);
-extern "C" void asmTexConv_AI44_ARGB4444(wxUIntPtr src, wxUIntPtr dst, int size);
-extern "C" void asmTexConv_A8_ARGB4444(wxUIntPtr src, wxUIntPtr dst, int size);
-
-void TexConv_ARGB1555_ARGB4444 (wxUIntPtr src, wxUIntPtr dst, int width, int height)
-{
-  int size = (width * height) >> 1;	// Hiroshi Morii <koolsmoky@users.sourceforge.net>
-  // 2 pixels are converted in one loop
-  // NOTE: width * height must be a multiple of 2
-  asmTexConv_ARGB1555_ARGB4444(src, dst, size);
-}
-
-void TexConv_AI88_ARGB4444 (wxUIntPtr src, wxUIntPtr dst, int width, int height)
-{
-  int size = (width * height) >> 1;	// Hiroshi Morii <koolsmoky@users.sourceforge.net>
-  // 2 pixels are converted in one loop
-  // NOTE: width * height must be a multiple of 2
-  asmTexConv_AI88_ARGB4444(src, dst, size);
-}
-
-void TexConv_AI44_ARGB4444 (wxUIntPtr src, wxUIntPtr dst, int width, int height)
-{
-  int size = (width * height) >> 2;	// Hiroshi Morii <koolsmoky@users.sourceforge.net>
-  // 4 pixels are converted in one loop
-  // NOTE: width * height must be a multiple of 4
-  asmTexConv_AI44_ARGB4444(src, dst, size);
-}
-
-void TexConv_A8_ARGB4444 (wxUIntPtr src, wxUIntPtr dst, int width, int height)
-{
-  int size = (width * height) >> 2;	// Hiroshi Morii <koolsmoky@users.sourceforge.net>
-  // 4 pixels are converted in one loop
-  // NOTE: width * height must be a multiple of 4
-  asmTexConv_A8_ARGB4444(src, dst, size);
-}

src/MiClWr_old/TexLoad16b.h

-/*
-* Glide64 - Glide video plugin for Nintendo 64 emulators.
-* Copyright (c) 2002  Dave2001
-* Copyright (c) 2003-2009  Sergey 'Gonetz' Lipski
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-//****************************************************************
-//
-// Glide64 - Glide Plugin for Nintendo 64 emulators
-// Project started on December 29th, 2001
-//
-// Authors:
-// Dave2001, original author, founded the project in 2001, left it in 2002
-// Gugaman, joined the project in 2002, left it in 2002
-// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
-// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
-//
-//****************************************************************
-//
-// To modify Glide64:
-// * 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.
-// * 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.
-//
-//****************************************************************
-
-extern "C" void asmLoad16bRGBA (wxUIntPtr src, wxUIntPtr dst, int wid_64, int height, int line, int ext);
-extern "C" void asmLoad16bIA (wxUIntPtr src, wxUIntPtr dst, int wid_64, int height, int line, int ext);
-
-
-//****************************************************************
-// Size: 2, Format: 0
-//
-
-wxUint32 Load16bRGBA (wxUIntPtr dst, wxUIntPtr src, int wid_64, int height, int line, int real_width, int tile)
-{
-  if (wid_64 < 1) wid_64 = 1;
-  if (height < 1) height = 1;
-  int ext = (real_width - (wid_64 << 2)) << 1;
-
-  asmLoad16bRGBA(src, dst, wid_64, height, line, ext);
-
-  return (1 << 16) | GR_TEXFMT_ARGB_1555;
-}
-
-//****************************************************************
-// Size: 2, Format: 3
-//
-
-wxUint32 Load16bIA (wxUIntPtr dst, wxUIntPtr src, int wid_64, int height, int line, int real_width, int tile)
-{
-  if (wid_64 < 1) wid_64 = 1;
-  if (height < 1) height = 1;
-  int ext = (real_width - (wid_64 << 2)) << 1;
-
-  asmLoad16bIA(src, dst, wid_64, height, line, ext);
-
-  return (1 << 16) | GR_TEXFMT_ALPHA_INTENSITY_88;
-}
-
-//****************************************************************
-// Size: 2, Format: 1
-//
-
-wxUint16 yuv_to_rgb565(wxUint8 y, wxUint8 u, wxUint8 v)
-{
-  //*
-  float r = y + (1.370705f * (v-128));
-  float g = y - (0.698001f * (v-128)) - (0.337633f * (u-128));
-  float b = y + (1.732446f * (u-128));
-  r *= 0.125f;
-  g *= 0.25f;
-  b *= 0.125f;
-  //clipping the result
-  if (r > 31) r = 31;
-  if (g > 63) g = 63;
-  if (b > 31) b = 31;
-  if (r < 0) r = 0;
-  if (g < 0) g = 0;
-  if (b < 0) b = 0;
-  wxUint16 c = (wxUint16)(((wxUint16)(r) << 11) |
-    ((wxUint16)(g) << 5) |
-    (wxUint16)(b) );
-  return c;
-  //*/
-  /*
-  const wxUint32 c = y - 16;
-  const wxUint32 d = u - 128;
-  const wxUint32 e = v - 128;
-
-  wxUint32 r =  (298 * c           + 409 * e + 128) & 0xf800;
-  wxUint32 g = ((298 * c - 100 * d - 208 * e + 128) >> 5) & 0x7e0;
-  wxUint32 b = ((298 * c + 516 * d           + 128) >> 11) & 0x1f;
-
-  WORD texel = (WORD)(r | g | b);
-
-  return texel;
-  */
-}
-
-//****************************************************************
-// Size: 2, Format: 1
-//
-
-wxUint32 Load16bYUV (wxUIntPtr dst, wxUIntPtr src, int wid_64, int height, int line, int real_width, int tile)
-{
-  wxUint32 * mb = (wxUint32*)(gfx.RDRAM+rdp.addr[rdp.tiles[tile].t_mem]); //pointer to the macro block
-  wxUint16 * tex = (wxUint16*)dst;
-  wxUint16 i;
-  for (i = 0; i < 128; i++)
-  {
-    wxUint32 t = mb[i]; //each wxUint32 contains 2 pixels
-    wxUint8 y1 = (wxUint8)t&0xFF;
-    wxUint8 v  = (wxUint8)(t>>8)&0xFF;
-    wxUint8 y0 = (wxUint8)(t>>16)&0xFF;
-    wxUint8 u  = (wxUint8)(t>>24)&0xFF;
-    wxUint16 c = yuv_to_rgb565(y0, u, v);
-    *(tex++) = c;
-    c = yuv_to_rgb565(y1, u, v);
-    *(tex++) = c;
-  }
-  return (1 << 16) | GR_TEXFMT_RGB_565;
-}

src/MiClWr_old/TexLoad32b.h

-/*
-* Glide64 - Glide video plugin for Nintendo 64 emulators.
-* Copyright (c) 2002  Dave2001
-* Copyright (c) 2003-2009  Sergey 'Gonetz' Lipski
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-//****************************************************************
-//
-// Glide64 - Glide Plugin for Nintendo 64 emulators
-// Project started on December 29th, 2001
-//
-// Authors:
-// Dave2001, original author, founded the project in 2001, left it in 2002
-// Gugaman, joined the project in 2002, left it in 2002
-// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
-// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
-//
-//****************************************************************
-//
-// To modify Glide64:
-// * 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.
-// * 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.
-//
-//****************************************************************
-
-//****************************************************************
-// Size: 2, Format: 0
-//
-// Load 32bit RGBA texture
-// Based on sources of angrylion's software plugin.
-//
-wxUint32 Load32bRGBA (wxUIntPtr dst, wxUIntPtr src, int wid_64, int height, int line, int real_width, int tile)
-{
-  if (height < 1) height = 1;
-  const wxUint16 *tmem16 = (wxUint16*)rdp.tmem;
-  const wxUint32 tbase = (src - (wxUIntPtr)rdp.tmem) >> 1;
-  const wxUint32 width = max(1, wid_64 << 1);
-  const int ext = real_width - width;
-  line = width + (line>>2);
-  wxUint32 s, t, c;
-  wxUint32 * tex = (wxUint32*)dst;
-  wxUint16 rg, ba;
-  for (t = 0; t < (wxUint32)height; t++)
-  {
-    wxUint32 tline = tbase + line * t;
-    wxUint32 xorval = (t & 1) ? 3 : 1;
-    for (s = 0; s < width; s++)
-    {
-      wxUint32 taddr = ((tline + s) ^ xorval) & 0x3ff;
-      rg = tmem16[taddr];
-      ba = tmem16[taddr|0x400];
-      c = ((ba&0xFF)<<24) | (rg << 8) | (ba>>8);
-      *tex++ = c;
-    }
-    tex += ext;
-  }
-  int id = tile - rdp.cur_tile;
-  wxUint32 mod = (id == 0) ? cmb.mod_0 : cmb.mod_1;
-  if (mod || !voodoo.sup_32bit_tex)
-  {
-    //convert to ARGB_4444
-    const wxUint32 tex_size = real_width * height;
-    tex = (wxUint32 *)dst;
-    wxUint16 *tex16 = (wxUint16*)dst;
-    wxUint16 a, r, g, b;
-    for (wxUint32 i = 0; i < tex_size; i++) {
-      c = tex[i];
-      a = (c >> 28) & 0xF;
-      r = (c >> 20) & 0xF;
-      g = (c >> 12) & 0xF;
-      b = (c >> 4)  & 0xF;
-      tex16[i] = (a <<12) | (r << 8) | (g << 4) | b;
-    }
-    return (1 << 16) | GR_TEXFMT_ARGB_4444;
-  }
-  return (2 << 16) | GR_TEXFMT_ARGB_8888;
-}
-
-//****************************************************************
-// LoadTile for 32bit RGBA texture
-// Based on sources of angrylion's software plugin.
-//
-void LoadTile32b (wxUint32 tile, wxUint32 ul_s, wxUint32 ul_t, wxUint32 width, wxUint32 height)
-{
-  const wxUint32 line = rdp.tiles[tile].line << 2;
-  const wxUint32 tbase = rdp.tiles[tile].t_mem << 2;
-  const wxUint32 addr = rdp.timg.addr >> 2;
-  const wxUint32* src = (const wxUint32*)gfx.RDRAM;
-  wxUint16 *tmem16 = (wxUint16*)rdp.tmem;
-  wxUint32 c, ptr, tline, s, xorval;
-
-  for (wxUint32 j = 0; j < height; j++)
-  {
-    tline = tbase + line * j;
-    s = ((j + ul_t) * rdp.timg.width) + ul_s;
-    xorval = (j & 1) ? 3 : 1;				
-    for (wxUint32 i = 0; i < width; i++)
-    {
-      c = src[addr + s + i];
-      ptr = ((tline + i) ^ xorval) & 0x3ff;
-      tmem16[ptr] = c >> 16;
-      tmem16[ptr|0x400] = c & 0xffff;
-    }
-  }
-}
-
-//****************************************************************
-// LoadBlock for 32bit RGBA texture
-// Based on sources of angrylion's software plugin.
-//
-void LoadBlock32b(wxUint32 tile, wxUint32 ul_s, wxUint32 ul_t, wxUint32 lr_s, wxUint32 dxt)
-{
-  const wxUint32 * src = (const wxUint32*)gfx.RDRAM;
-  const wxUint32 tb = rdp.tiles[tile].t_mem << 2;
-  const wxUint32 tiwindwords = rdp.timg.width;
-  const wxUint32 slindwords = ul_s;
-  const wxUint32 line = rdp.tiles[tile].line << 2;
-
-  wxUint16 *tmem16 = (wxUint16*)rdp.tmem;
-  wxUint32 addr = rdp.timg.addr >> 2;
-  wxUint32 width = (lr_s - ul_s + 1) << 2;
-  if (width & 7)
-    width = (width & (~7)) + 8;
-
-  if (dxt != 0)
-  {
-    wxUint32 j= 0;
-    wxUint32 t = 0;
-    wxUint32 oldt = 0;
-    wxUint32 ptr;
-
-    addr += (ul_t * tiwindwords) + slindwords;
-    wxUint32 c = 0;
-    for (wxUint32 i = 0; i < width; i += 2)
-    {
-      oldt = t;
-      t = ((j >> 11) & 1) ? 3 : 1;
-      if (t != oldt)
-        i += line;
-      ptr = ((tb + i) ^ t) & 0x3ff;
-      c = src[addr + i];
-      tmem16[ptr] = c >> 16;
-      tmem16[ptr|0x400] = c & 0xffff;
-      ptr = ((tb+ i + 1) ^ t) & 0x3ff;
-      c = src[addr + i + 1];
-      tmem16[ptr] = c >> 16;
-      tmem16[ptr|0x400] = c & 0xffff;
-      j += dxt;
-    }
-  }
-  else
-  {
-    addr += (ul_t * tiwindwords) + slindwords;
-    wxUint32 c, ptr;
-    for (wxUint32 i = 0; i < width; i ++)
-    {
-      ptr = ((tb + i) ^ 1) & 0x3ff;
-      c = src[addr + i];
-      tmem16[ptr] = c >> 16;
-      tmem16[ptr|0x400] = c & 0xffff;
-    }
-  }
-}

src/MiClWr_old/TexLoad4b.h

-/*
-* Glide64 - Glide video plugin for Nintendo 64 emulators.
-* Copyright (c) 2002  Dave2001
-* Copyright (c) 2003-2009  Sergey 'Gonetz' Lipski
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-//****************************************************************
-//
-// Glide64 - Glide Plugin for Nintendo 64 emulators
-// Project started on December 29th, 2001
-//
-// Authors:
-// Dave2001, original author, founded the project in 2001, left it in 2002
-// Gugaman, joined the project in 2002, left it in 2002
-// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
-// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
-//
-//****************************************************************
-//
-// To modify Glide64:
-// * 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.
-// * 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.
-//
-//****************************************************************
-
-extern "C" void asmLoad4bCI (wxUIntPtr src, wxUIntPtr dst, int wid_64, int height, int line, int ext, wxUIntPtr pal);
-extern "C" void asmLoad4bIAPal (wxUIntPtr src, wxUIntPtr dst, int wid_64, int height, int line, int ext, wxUIntPtr pal);
-extern "C" void asmLoad4bIA (wxUIntPtr src, wxUIntPtr dst, int wid_64, int height, int line, int ext);
-extern "C" void asmLoad4bI (wxUIntPtr src, int dst, wxUIntPtr wid_64, int height, int line, int ext);
-
-//****************************************************************
-// Size: 0, Format: 2
-
-wxUint32 Load4bCI (wxUIntPtr dst, wxUIntPtr src, int wid_64, int height, int line, int real_width, int tile)
-{
-  if (wid_64 < 1) wid_64 = 1;
-  if (height < 1) height = 1;
-  int ext = (real_width - (wid_64 << 4)) << 1;
-
-  if (rdp.tlut_mode == 0) 
-  {
-    //in tlut DISABLE mode load CI texture as plain intensity texture instead of palette dereference. 
-    //Thanks to angrylion for the advice
-    asmLoad4bI (src, dst, wid_64, height, line, ext);	
-    return /*(0 << 16) | */GR_TEXFMT_ALPHA_INTENSITY_44;
-  }
-
-  wxUIntPtr pal = wxPtrToUInt(rdp.pal_8 + (rdp.tiles[tile].palette << 4));
-  if (rdp.tlut_mode == 2) 
-  {
-    asmLoad4bCI (src, dst, wid_64, height, line, ext, pal);
-    return (1 << 16) | GR_TEXFMT_ARGB_1555;
-  }
-
-  asmLoad4bIAPal (src, dst, wid_64, height, line, ext, pal);
-  return (1 << 16) | GR_TEXFMT_ALPHA_INTENSITY_88;
-}
-
-//****************************************************************
-// Size: 0, Format: 3
-//
-// ** BY GUGAMAN **
-
-wxUint32 Load4bIA (wxUIntPtr dst, wxUIntPtr src, int wid_64, int height, int line, int real_width, int tile)
-{
-  if (rdp.tlut_mode != 0)
-    return Load4bCI (dst, src, wid_64, height, line, real_width, tile);
-
-  if (wid_64 < 1) wid_64 = 1;
-  if (height < 1) height = 1;
-  int ext = (real_width - (wid_64 << 4));
-  asmLoad4bIA (src, dst, wid_64, height, line, ext);	
-  return /*(0 << 16) | */GR_TEXFMT_ALPHA_INTENSITY_44;
-}
-
-//****************************************************************
-// Size: 0, Format: 4
-
-wxUint32 Load4bI (wxUIntPtr dst, wxUIntPtr src, int wid_64, int height, int line, int real_width, int tile)
-{
-  if (rdp.tlut_mode != 0)
-    return Load4bCI (dst, src, wid_64, height, line, real_width, tile);
-
-  if (wid_64 < 1) wid_64 = 1;
-  if (height < 1) height = 1;
-  int ext = (real_width - (wid_64 << 4));
-  asmLoad4bI (src, dst, wid_64, height, line, ext);
-  return /*(0 << 16) | */GR_TEXFMT_ALPHA_INTENSITY_44;
-}
-
-//****************************************************************
-// Size: 0, Format: 0
-
-wxUint32 Load4bSelect (wxUIntPtr dst, wxUIntPtr src, int wid_64, int height, int line, int real_width, int tile)
-{
-  if (rdp.tlut_mode == 0)
-    return Load4bI (dst, src, wid_64, height, line, real_width, tile);
-
-  return Load4bCI (dst, src, wid_64, height, line, real_width, tile);
-}

src/MiClWr_old/TexLoad8b.h

-/*
-* Glide64 - Glide video plugin for Nintendo 64 emulators.
-* Copyright (c) 2002  Dave2001
-* Copyright (c) 2003-2009  Sergey 'Gonetz' Lipski
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-//****************************************************************
-//
-// Glide64 - Glide Plugin for Nintendo 64 emulators
-// Project started on December 29th, 2001
-//
-// Authors:
-// Dave2001, original author, founded the project in 2001, left it in 2002
-// Gugaman, joined the project in 2002, left it in 2002
-// Sergey 'Gonetz' Lipski, joined the project in 2002, main author since fall of 2002
-// Hiroshi 'KoolSmoky' Morii, joined the project in 2007
-//
-//****************************************************************
-//
-// To modify Glide64:
-// * 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.
-// * 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.
-//
-//****************************************************************
-
-extern "C" void asmLoad8bCI (wxUIntPtr src, wxUIntPtr dst, int wid_64, int height, int line, int ext, wxUIntPtr pal);
-extern "C" void asmLoad8bIA8 (wxUIntPtr src, wxUIntPtr dst, int wid_64, int height, int line, int ext, wxUIntPtr pal);
-extern "C" void asmLoad8bIA4 (wxUIntPtr src, wxUIntPtr dst, int wid_64, int height, int line, int ext);
-extern "C" void asmLoad8bI (wxUIntPtr src, int dst, wxUIntPtr wid_64, int height, int line, int ext);
-
-//****************************************************************
-// Size: 1, Format: 2
-//
-
-wxUint32 Load8bCI (wxUIntPtr dst, wxUIntPtr src, int wid_64, int height, int line, int real_width, int tile)
-{
-  if (wid_64 < 1) wid_64 = 1;
-  if (height < 1) height = 1;
-  int ext = (real_width - (wid_64 << 3));
-  wxUIntPtr pal = wxPtrToUInt(rdp.pal_8);
-
-  switch (rdp.tlut_mode) {
-    case 0: //palette is not used
-      //in tlut DISABLE mode load CI texture as plain intensity texture instead of palette dereference. 
-      //Thanks to angrylion for the advice
-      asmLoad8bI (src, dst, wid_64, height, line, ext);	
-      return /*(0 << 16) | */GR_TEXFMT_ALPHA_8;
-    case 2: //color palette
-      ext <<= 1;
-      asmLoad8bCI (src, dst, wid_64, height, line, ext, pal);
-      return (1 << 16) | GR_TEXFMT_ARGB_1555;
-    default: //IA palette
-      ext <<= 1;
-      asmLoad8bIA8 (src, dst, wid_64, height, line, ext, pal);
-      return (1 << 16) | GR_TEXFMT_ALPHA_INTENSITY_88;
-  }
-}
-
-//****************************************************************
-// Size: 1, Format: 3
-//
-
-wxUint32 Load8bIA (wxUIntPtr dst, wxUIntPtr src, int wid_64, int height, int line, int real_width, int tile)  
-{ 
-  if (rdp.tlut_mode != 0)
-    return Load8bCI (dst, src, wid_64, height, line, real_width, tile);
-
-  if (wid_64 < 1) wid_64 = 1;  
-  if (height < 1) height = 1;  
-  int ext = (real_width - (wid_64 << 3));  
-  asmLoad8bIA4 (src, dst, wid_64, height, line, ext);
-  return /*(0 << 16) | */GR_TEXFMT_ALPHA_INTENSITY_44;  
-} 
-
-//****************************************************************
-// Size: 1, Format: 4
-//
-
-wxUint32 Load8bI (wxUIntPtr dst, wxUIntPtr src, int wid_64, int height, int line, int real_width, int tile)  
-{ 
-  if (rdp.tlut_mode != 0)
-    return Load8bCI (dst, src, wid_64, height, line, real_width, tile);
-
-  if (wid_64 < 1) wid_64 = 1;  
-  if (height < 1) height = 1;  
-  int ext = (real_width - (wid_64 << 3));  
-  asmLoad8bI (src, dst, wid_64, height, line, ext);	
-  return /*(0 << 16) | */GR_TEXFMT_ALPHA_8;  
-}