shithub: duke3d

Download patch

ref: a07f39dff7742c963d107f84853d4d1c791d5858
parent: b8eaa16f172cd76e04bb5ee92c510d55d288f23b
author: Tanguy Fautre <[email protected]>
date: Tue Feb 11 16:31:12 EST 2020

64-bit: Fix rhlineasm4. "logo.anm" now plays without crashing.

--- a/Engine/src/draw.c
+++ b/Engine/src/draw.c
@@ -90,9 +90,10 @@
 static int32_t rmach_eax;
 static int32_t rmach_ebx;
 static int32_t rmach_ecx;
-static int32_t rmach_edx;
+static uint8_t* rmach_edx;
 static int32_t rmach_esi;
-void setuprhlineasm4(int32_t i1, int32_t i2, int32_t i3, int32_t i4, int32_t i5, int32_t i6)
+
+void setuprhlineasm4(int32_t i1, int32_t i2, int32_t i3, uint8_t* i4, int32_t i5, int32_t i6)
 {
     rmach_eax = i1;
     rmach_ebx = i2;
@@ -102,12 +103,13 @@
 } 
 
 
-void rhlineasm4(int32_t i1, uint8_t* texture, int32_t i3, uint32_t i4, uint32_t i5, int32_t dest)
+void rhlineasm4(int32_t i1, uint8_t* texture, int32_t i3, uint32_t i4, uint32_t i5, uint8_t* dest)
 {
     uint32_t ebp = dest - i1;
     uint32_t rmach6b = ebp-1;
     int32_t numPixels;
-    
+	int32_t offset = i1 + 1;
+	
     if (i1 <= 0) return;
 
     numPixels = i1;
@@ -126,10 +128,10 @@
             texture -= rmach_ecx;
         
 	    ebp &= rmach_esi;
-	    i1 = ((i1&0xffffff00)|(((uint8_t *)i3)[rmach_edx]));
+	    i1 = ((i1&0xffffff00)|rmach_edx[i3]);
 
 		if (pixelsAllowed-- > 0)
-			 ((uint8_t *)rmach6b)[numPixels] = (i1&0xff);
+			dest[numPixels - offset] = (i1&0xff);
 
 	    texture -= ebp;
 	    numPixels--;
--- a/Engine/src/draw.h
+++ b/Engine/src/draw.h
@@ -29,8 +29,8 @@
 
 
 void hlineasm4(int32_t,int32_t,uint32_t,uint32_t,uint8_t*);
-void setuprhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
-void rhlineasm4(int32_t,uint8_t*,int32_t,uint32_t,uint32_t,int32_t);
+void setuprhlineasm4(int32_t,int32_t,int32_t,uint8_t*,int32_t,int32_t);
+void rhlineasm4(int32_t,uint8_t*,int32_t,uint32_t,uint32_t,uint8_t*);
 void setuprmhlineasm4(int32_t,int32_t,int32_t,int32_t,int32_t,int32_t);
 void rmhlineasm4(int32_t,intptr_t,int32_t,int32_t,int32_t,int32_t);