Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions port/boards/rv32emu/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void qembd_vidinit()
register int a7 asm("a7") = syscall_draw_frame;

asm volatile("scall"
: "+r"(a0) : "r"(a1), "r"(a2), "r"(a7));
: : "r"(a0), "r"(a1), "r"(a2), "r"(a7));
}

void qembd_fillrect(uint8_t *src, uint32_t *clut,
Expand All @@ -67,5 +67,5 @@ void qembd_refresh()
register int a7 asm("a7") = syscall_draw_frame;

asm volatile("scall"
: "+r"(a0) : "r"(a1), "r"(a2), "r"(a7));
: : "r"(a0), "r"(a1), "r"(a2), "r"(a7));
}
9 changes: 8 additions & 1 deletion port/boards/rv32emu/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void qembd_udelay(uint32_t us)
}

int main(int c, char **v)
{
{
return qembd_main(c, v);
}

Expand Down Expand Up @@ -214,3 +214,10 @@ int qembd_get_mouse_movement(mouse_movement_t *movement)
mouse_movement.y = 0;
return 0;
}

void qembd_set_relative_mode(bool enabled) {
register int a0 asm("a0") = enabled;
register int a7 asm("a7") = 0xfeed;

asm volatile("scall" : : "r"(a0), "r"(a7));
}
101 changes: 0 additions & 101 deletions winquake/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,78 +410,6 @@ float Q_atof (char *str)
}
#endif /* !defined(__riscv) */

/*
============================================================================
BYTE ORDER FUNCTIONS
============================================================================
*/

#ifdef SDL
#include "SDL_byteorder.h"
#endif

qboolean bigendien;

short (*BigShort) (short l);
short (*LittleShort) (short l);
int (*BigLong) (int l);
int (*LittleLong) (int l);
float (*BigFloat) (float l);
float (*LittleFloat) (float l);

short ShortSwap (short l)
{
byte b1,b2;

b1 = l&255;
b2 = (l>>8)&255;

return (b1<<8) + b2;
}

short ShortNoSwap (short l)
{
return l;
}

int LongSwap (int l)
{
byte b1,b2,b3,b4;

b1 = l&255;
b2 = (l>>8)&255;
b3 = (l>>16)&255;
b4 = (l>>24)&255;

return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
}

int LongNoSwap (int l)
{
return l;
}

float FloatSwap (float f)
{
union
{
float f;
byte b[4];
} dat1, dat2;


dat1.f = f;
dat2.b[0] = dat1.b[3];
dat2.b[1] = dat1.b[2];
dat2.b[2] = dat1.b[1];
dat2.b[3] = dat1.b[0];
return dat2.f;
}

float FloatNoSwap (float f)
{
return f;
}

/*
==============================================================================
Expand Down Expand Up @@ -1108,35 +1036,6 @@ COM_Init
*/
void COM_Init (char *basedir)
{
byte swaptest[2] = {1,0};

// set the byte swapping variables in a portable manner
#ifdef SDL
// This is necessary because egcs 1.1.1 mis-compiles swaptest with -O2
if ( SDL_BYTEORDER == SDL_LIL_ENDIAN )
#else
if ( *(short *)swaptest == 1)
#endif
{
bigendien = false;
BigShort = ShortSwap;
LittleShort = ShortNoSwap;
BigLong = LongSwap;
LittleLong = LongNoSwap;
BigFloat = FloatSwap;
LittleFloat = FloatNoSwap;
}
else
{
bigendien = true;
BigShort = ShortNoSwap;
LittleShort = ShortSwap;
BigLong = LongNoSwap;
LittleLong = LongSwap;
BigFloat = FloatNoSwap;
LittleFloat = FloatSwap;
}

Cvar_RegisterVariable (&registered);
Cvar_RegisterVariable (&cmdline);
Cmd_AddCommand ("path", COM_Path_f);
Expand Down
74 changes: 66 additions & 8 deletions winquake/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,72 @@ void InsertLinkAfter (link_t *l, link_t *after);

//============================================================================

extern qboolean bigendien;

extern short (*BigShort) (short l);
extern short (*LittleShort) (short l);
extern int (*BigLong) (int l);
extern int (*LittleLong) (int l);
extern float (*BigFloat) (float l);
extern float (*LittleFloat) (float l);
/*
* ========================================================================
* BYTE ORDER FUNCTIONS
* ========================================================================
*/

#undef MSB_FIRST
#undef LSB_FIRST
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define MSB_FIRST 1
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define LSB_FIRST 1
#else
#error "Invalid endianness macros"
#endif

static inline short bswap16(short s) {
return ((s & 255) << 8) | ((s >> 8) & 255);
}
static inline int bswap32(int l) {
return
(((l >> 0) & 255) << 24)
| (((l >> 8) & 255) << 16)
| (((l >> 16) & 255) << 8)
| (((l >> 24) & 255) << 0);
}

#ifdef MSB_FIRST
static inline short BigShort(short s) { return s; }
static inline int BigLong(int l) { return l; }
static inline float BigFloat(float f) { return f; }
static inline short LittleShort(short s) { return bswap16(s); }
static inline int LittleLong(int l) { return bswap32(l); }
static inline float LittleFloat(float f) {
union {
float f;
byte b[4];
} dat1, dat2;

dat1.f = f;
dat2.b[0] = dat1.b[3];
dat2.b[1] = dat1.b[2];
dat2.b[2] = dat1.b[1];
dat2.b[3] = dat1.b[0];
return dat2.f;
}
#else
static inline short BigShort(short s) { return bswap16(s); }
static inline int BigLong(int l) { return bswap32(l); }
static inline float BigFloat(float f) {
union {
float f;
byte b[4];
} dat1, dat2;

dat1.f = f;
dat2.b[0] = dat1.b[3];
dat2.b[1] = dat1.b[2];
dat2.b[2] = dat1.b[1];
dat2.b[3] = dat1.b[0];
return dat2.f;
}
static inline short LittleShort(short s) { return s; }
static inline int LittleLong(int l) { return l; }
static inline float LittleFloat(float f) { return f; }
#endif

//============================================================================

Expand Down
7 changes: 7 additions & 0 deletions winquake/mathlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ typedef int fixed4_t;
typedef int fixed8_t;
typedef int fixed16_t;

/* min and max macros with type checking */
#define qmax(a, b) ((a > b) ? a : b)
#define qmin(a, b) ((a < b) ? a : b)

/* clamp macro with type checking */
#define qclamp(var, min, max) qmax(qmin(var, max), min)

#ifdef M_PI
#undef M_PI
#endif
Expand Down
6 changes: 6 additions & 0 deletions winquake/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "winquake.h"
#endif

void qembd_set_relative_mode(bool enabled);

void (*vid_menudrawfn)(void);
void (*vid_menukeyfn)(int key);

Expand Down Expand Up @@ -287,6 +289,8 @@ int m_main_cursor;

void M_Menu_Main_f (void)
{
qembd_set_relative_mode(false);

if (key_dest != key_menu)
{
m_save_demonum = cls.demonum;
Expand Down Expand Up @@ -321,6 +325,7 @@ void M_Main_Key (int key)
cls.demonum = m_save_demonum;
if (cls.demonum != -1 && !cls.demoplayback && cls.state != ca_connected)
CL_NextDemo ();
qembd_set_relative_mode(true);
break;

case K_DOWNARROW:
Expand Down Expand Up @@ -425,6 +430,7 @@ void M_SinglePlayer_Key (int key)
Cbuf_AddText ("disconnect\n");
Cbuf_AddText ("maxplayers 1\n");
Cbuf_AddText ("map start\n");
qembd_set_relative_mode(true);
break;

case 1:
Expand Down
Loading