[sw] Fix some 32-bit assembly issues

I'm not sure that the mismatch between refdef_t and the assembly defines
was a problem (many fields unused), but the main problem was due to
execute permission on the pages: one chunk of asm was in the data
section, and the patched code was not marked as being executable (due to
such a thing not existing when quake was written).
This commit is contained in:
Bill Currie 2021-04-02 22:17:32 +09:00
parent 37be6a23a2
commit 39103cc8a3
7 changed files with 22 additions and 23 deletions

View file

@ -161,9 +161,9 @@ typedef struct {
vec4f_t viewposition;
vec4f_t viewrotation;
float fov_x, fov_y;
int ambientlight;
float fov_x, fov_y;
} refdef_t;
// color shifts =============================================================

View file

@ -42,14 +42,14 @@
#define espan_t_v 4
#define espan_t_count 8
#define espan_t_pnext 12
#define espan_t_size 16
#define espan_t_size 16 // sizeof(espan_t)
// sspan_t structure
// !!! if this is changed, it must be changed in d_local.h too !!!
#define sspan_t_u 0
#define sspan_t_v 4
#define sspan_t_count 8
#define sspan_t_size 12
#define sspan_t_size 12 // sizeof(sspan_t)
// spanpackage_t structure
// !!! if this is changed, it must be changed in d_polyset.c too !!!
@ -61,7 +61,7 @@
#define spanpackage_t_tfrac 20
#define spanpackage_t_light 24
#define spanpackage_t_zi 28
#define spanpackage_t_size 32
#define spanpackage_t_size 32 // sizeof(spanpackage_t)
// edge_t structure
// !!! if this is changed, it must be changed in r_shared.h too !!!
@ -73,7 +73,7 @@
#define et_nextremove 20
#define et_nearzi 24
#define et_owner 28
#define et_size 32
#define et_size 32 // sizeof(edge_t)
// surf_t structure
// !!! if this is changed, it must be changed in r_shared.h too !!!
@ -93,7 +93,7 @@
#define st_d_zistepu 48
#define st_d_zistepv 52
#define st_pad 56
#define st_size 64
#define st_size 64 // sizeof (surf_t)
// clipplane_t structure
// !!! if this is changed, it must be changed in r_local.h too !!!
@ -103,18 +103,18 @@
#define cp_leftedge 20
#define cp_rightedge 21
#define cp_reserved 22
#define cp_size 24
#define cp_size 24 // sizeof (clipplane_t)
// medge_t structure
// !!! if this is changed, it must be changed in model.h too !!!
#define me_v 0
#define me_cachededgeoffset 8
#define me_size 12
#define me_size 12 // sizeof (medge_t)
// mvertex_t structure
// !!! if this is changed, it must be changed in model.h too !!!
#define mv_position 0
#define mv_size 12
#define mv_size 12 // sizeof (mvertex_t)
// refdef_t structure
// !!! if this is changed, it must be changed in render.h too !!!
@ -138,10 +138,12 @@
#define rd_horizontalFieldOfView 100
#define rd_xOrigin 104
#define rd_yOrigin 108
#define rd_vieworg 112
#define rd_viewangles 124
#define rd_ambientlight 136
#define rd_size 140
#define rd_viewposition 112
#define rd_viewrotation 128
#define rd_ambientlight 144
#defin rd_fov_x 148
#defin rd_fov_y 152
#define rd_size 156 // sizeof (refdef_t)
// mtriangle_t structure
// !!! if this is changed, it must be changed in model.h too !!!

View file

@ -59,8 +59,7 @@ typedef struct surfcache_s
} surfcache_t;
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct sspan_s
{
typedef struct sspan_s {
int u, v, count;
} sspan_t;

View file

@ -98,8 +98,7 @@ extern float cl_wateralpha;
#define DIST_NOT_SET 98765
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct clipplane_s
{
typedef struct clipplane_s {
vec3_t normal;
float dist;
struct clipplane_s *next;

View file

@ -81,16 +81,14 @@ extern struct entity_s *currententity;
#define MAXSPANS 3000
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct espan_s
{
typedef struct espan_s {
int u, v, count;
struct espan_s *pnext;
} espan_t;
// FIXME: compress, make a union if that will help
// insubmodel is only 1, flags is fewer than 32, spanstate could be a byte
typedef struct surf_s
{
typedef struct surf_s {
struct surf_s *next; // active surface stack in r_edge.c
struct surf_s *prev; // used in r_edge.c for active surf stack
struct espan_s *spans; // pointer to linked list of spans to draw

View file

@ -437,7 +437,7 @@ Sys_MakeCodeWriteable (uintptr_t startaddr, size_t length)
DWORD flOldProtect;
if (!VirtualProtect
((LPVOID) startaddr, length, PAGE_READWRITE, &flOldProtect))
((LPVOID) startaddr, length, PAGE_EXECUTE_READWRITE, &flOldProtect))
Sys_Error ("Protection change failed");
#else
# ifdef HAVE_MPROTECT

View file

@ -76,6 +76,7 @@ C(r_single_cw): .long 0
.globl C(r_bmodelactive)
C(r_bmodelactive): .long 0
.text
.global C(R_InitVars)
C(R_InitVars):
movl C(ceil_cw), %eax