Replace Bit8s with int8_t

This commit is contained in:
Emmanuel Gil Peyrot 2020-09-28 02:43:04 +02:00
parent 35f38f3ebe
commit 7d6fefeaed
46 changed files with 101 additions and 108 deletions

View File

@ -299,12 +299,6 @@ dnl Linux systems for ages now have had stdint.h to define uint8_t, etc.
AH_BOTTOM([
#include <cstdint>
#if SIZEOF_UNSIGNED_CHAR != 1
# error "sizeof (unsigned char) != 1"
#else
typedef signed char Bit8s;
#endif
#if SIZEOF_UNSIGNED_SHORT != 2
# error "sizeof (unsigned short) != 2"
#else

View File

@ -77,7 +77,6 @@ AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_STRUCT_TM
AC_CHECK_SIZEOF(unsigned char)
AC_CHECK_SIZEOF(unsigned short)
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned long)

View File

@ -26,7 +26,7 @@
** basic data types
*/
typedef uint8_t FxU8;
typedef Bit8s FxI8;
typedef int8_t FxI8;
typedef Bit16u FxU16;
typedef Bit16s FxI16;
typedef Bit32u FxU32;

View File

@ -73,8 +73,8 @@ public:
void finishSampleInterpolation(const Bitu upto);
void AddSamples_m8(Bitu len, const uint8_t * data);
void AddSamples_s8(Bitu len, const uint8_t * data);
void AddSamples_m8s(Bitu len, const Bit8s * data);
void AddSamples_s8s(Bitu len, const Bit8s * data);
void AddSamples_m8s(Bitu len, const int8_t * data);
void AddSamples_s8s(Bitu len, const int8_t * data);
void AddSamples_m16(Bitu len, const Bit16s * data);
void AddSamples_s16(Bitu len, const Bit16s * data);
void AddSamples_m16u(Bitu len, const Bit16u * data);

View File

@ -47,7 +47,7 @@ typedef union {
} ub;
struct {
Bit8s b0,b1,b2,b3,b4,b5,b6,b7;
int8_t b0,b1,b2,b3,b4,b5,b6,b7;
} sb;
#else
struct {
@ -81,7 +81,7 @@ extern MMX_reg * reg_mmx[8];
extern MMX_reg * lookupRMregMM[256];
Bit8s SaturateWordSToByteS(Bit16s value);
int8_t SaturateWordSToByteS(Bit16s value);
Bit16s SaturateDwordSToWordS(Bit32s value);
uint8_t SaturateWordSToByteU(Bit16s value);
Bit16u SaturateDwordSToWordU(Bit32s value);

View File

@ -285,7 +285,7 @@ restart_prefix:
dyn_push_word_imm(decode.big_op ? decode_fetchd() : decode_fetchw());
break;
case 0x6a:
dyn_push_byte_imm((Bit8s)decode_fetchb());
dyn_push_byte_imm((int8_t)decode_fetchb());
break;
// signed multiplication
@ -297,7 +297,7 @@ restart_prefix:
// short conditional jumps
case 0x70:case 0x71:case 0x72:case 0x73:case 0x74:case 0x75:case 0x76:case 0x77:
case 0x78:case 0x79:case 0x7a:case 0x7b:case 0x7c:case 0x7d:case 0x7e:case 0x7f:
dyn_branched_exit((BranchTypes)(opcode&0xf),(Bit8s)decode_fetchb());
dyn_branched_exit((BranchTypes)(opcode&0xf),(int8_t)decode_fetchb());
goto finish_block;
// 'op []/reg8,imm8'
@ -523,7 +523,7 @@ restart_prefix:
goto finish_block;
// 'jmp short imm8'
case 0xeb:
dyn_exit_link((Bit8s)decode_fetchb());
dyn_exit_link((int8_t)decode_fetchb());
goto finish_block;

View File

@ -910,7 +910,7 @@ static void dyn_fill_ea(HostReg ea_reg,bool addseg=true) {
Bits imm=0;
switch (decode.modrm.mod) {
case 0:imm=0;break;
case 1:imm=(Bit8s)decode_fetchb();break;
case 1:imm=(int8_t)decode_fetchb();break;
case 2:imm=(Bit16s)decode_fetchw();break;
}
switch (decode.modrm.rm) {
@ -1039,7 +1039,7 @@ skip_extend_word:
// basereg, maybe scalereg
switch (decode.modrm.mod) {
case 1:
imm=(Bit8s)decode_fetchb();
imm=(int8_t)decode_fetchb();
break;
case 2: {
Bitu val;
@ -1117,7 +1117,7 @@ skip_extend_word:
switch (decode.modrm.mod) {
case 1:
imm=(Bit8s)decode_fetchb();
imm=(int8_t)decode_fetchb();
break;
case 2: {
Bitu val;

View File

@ -427,7 +427,7 @@ static void dyn_pop_reg(uint8_t reg) {
MOV_REG_WORD_FROM_HOST_REG(FC_RETOP,reg,decode.big_op);
}
static void dyn_push_byte_imm(Bit8s imm) {
static void dyn_push_byte_imm(int8_t imm) {
gen_mov_dword_to_reg_imm(FC_OP1,(Bit32u)imm);
if (decode.big_op) gen_call_function_raw(dynrec_push_dword);
else gen_call_function_raw(dynrec_push_word);
@ -527,8 +527,8 @@ static void dyn_imul_gvev(Bitu immsize) {
MOV_REG_WORD_TO_HOST_REG(FC_OP2,decode.modrm.reg,decode.big_op);
break;
case 1:
if (decode.big_op) gen_mov_dword_to_reg_imm(FC_OP2,(Bit8s)decode_fetchb());
else gen_mov_word_to_reg_imm(FC_OP2,(Bit8s)decode_fetchb());
if (decode.big_op) gen_mov_dword_to_reg_imm(FC_OP2,(int8_t)decode_fetchb());
else gen_mov_word_to_reg_imm(FC_OP2,(int8_t)decode_fetchb());
break;
case 2:
if (decode.big_op) gen_mov_dword_to_reg_imm(FC_OP2,(Bit16s)decode_fetchw());
@ -600,7 +600,7 @@ static void dyn_grp1_ev_iv(bool withbyte) {
if (!withbyte) {
dyn_prep_word_imm(FC_OP2);
} else {
Bits imm=(Bit8s)decode_fetchb();
Bits imm=(int8_t)decode_fetchb();
if (decode.big_op) gen_mov_dword_to_reg_imm(FC_OP2,(Bit32u)imm);
else gen_mov_word_to_reg_imm(FC_OP2,(Bit16u)imm);
}
@ -615,7 +615,7 @@ static void dyn_grp1_ev_iv(bool withbyte) {
if (!withbyte) {
dyn_dop_word_imm(op,decode.modrm.rm);
} else {
Bits imm=withbyte ? (Bit8s)decode_fetchb() : (decode.big_op ? decode_fetchd(): decode_fetchw());
Bits imm=withbyte ? (int8_t)decode_fetchb() : (decode.big_op ? decode_fetchd(): decode_fetchw());
dyn_dop_word_imm_old(op,decode.modrm.rm,imm);
}
}
@ -1138,7 +1138,7 @@ static void dyn_set_byte_on_condition(BranchTypes btype) {
static void dyn_loop(LoopTypes type) {
dyn_reduce_cycles();
Bit8s eip_add=(Bit8s)decode_fetchb();
int8_t eip_add=(int8_t)decode_fetchb();
Bit32u eip_base=decode.code-decode.code_start;
DRC_PTR_SIZE_IM branch1=0;
DRC_PTR_SIZE_IM branch2=0;

View File

@ -1405,7 +1405,7 @@ static void DRC_CALL_CONV dynrec_mul_byte(uint8_t op) {
static void DRC_CALL_CONV dynrec_imul_byte(uint8_t op) DRC_FC;
static void DRC_CALL_CONV dynrec_imul_byte(uint8_t op) {
FillFlagsNoCFOF();
reg_ax=((Bit8s)reg_al) * ((Bit8s)op);
reg_ax=((int8_t)reg_al) * ((int8_t)op);
if ((reg_ax & 0xff80)==0xff80 || (reg_ax & 0xff80)==0x0000) {
SETFLAGBIT(CF,false);
SETFLAGBIT(OF,false);
@ -1496,11 +1496,11 @@ static bool DRC_CALL_CONV dynrec_div_byte(uint8_t op) {
static bool DRC_CALL_CONV dynrec_idiv_byte(uint8_t op) DRC_FC;
static bool DRC_CALL_CONV dynrec_idiv_byte(uint8_t op) {
Bits val=(Bit8s)op;
Bits val=(int8_t)op;
if (val==0) return CPU_PrepareException(0,0);
Bits quo=((Bit16s)reg_ax) / val;
Bit8s rem=(Bit8s)((Bit16s)reg_ax % val);
Bit8s quo8s=(Bit8s)(quo&0xff);
int8_t rem=(int8_t)((Bit16s)reg_ax % val);
int8_t quo8s=(int8_t)(quo&0xff);
if (quo!=(Bit16s)quo8s) return CPU_PrepareException(0,0);
reg_ah=rem;
reg_al=quo8s;
@ -1596,7 +1596,7 @@ static Bit32u DRC_CALL_CONV dynrec_dimul_dword(Bit32u op1,Bit32u op2) {
static Bit16u DRC_CALL_CONV dynrec_cbw(uint8_t op) DRC_FC;
static Bit16u DRC_CALL_CONV dynrec_cbw(uint8_t op) {
return (Bit8s)op;
return (int8_t)op;
}
static Bit32u DRC_CALL_CONV dynrec_cwde(Bit16u op) DRC_FC;

View File

@ -695,7 +695,7 @@ static void gen_add_direct_word(void* dest,Bit32u imm,bool dword) {
}
// add an 8bit constant value to a dword memory value
static void gen_add_direct_byte(void* dest,Bit8s imm) {
static void gen_add_direct_byte(void* dest,int8_t imm) {
gen_add_direct_word(dest, (Bit32s)imm, 1);
}
@ -742,7 +742,7 @@ static void gen_sub_direct_word(void* dest,Bit32u imm,bool dword) {
}
// subtract an 8bit constant value from a dword memory value
static void gen_sub_direct_byte(void* dest,Bit8s imm) {
static void gen_sub_direct_byte(void* dest,int8_t imm) {
gen_sub_direct_word(dest, (Bit32s)imm, 1);
}

View File

@ -746,7 +746,7 @@ static void gen_add_direct_word(void* dest,Bit32u imm,bool dword) {
}
// add an 8bit constant value to a dword memory value
static void gen_add_direct_byte(void* dest,Bit8s imm) {
static void gen_add_direct_byte(void* dest,int8_t imm) {
gen_add_direct_word(dest, (Bit32s)imm, 1);
}
@ -791,7 +791,7 @@ static void gen_sub_direct_word(void* dest,Bit32u imm,bool dword) {
}
// subtract an 8bit constant value from a dword memory value
static void gen_sub_direct_byte(void* dest,Bit8s imm) {
static void gen_sub_direct_byte(void* dest,int8_t imm) {
gen_sub_direct_word(dest, (Bit32s)imm, 1);
}

View File

@ -746,7 +746,7 @@ static void gen_add_direct_word(void* dest,Bit32u imm,bool dword) {
}
// add an 8bit constant value to a dword memory value
static void gen_add_direct_byte(void* dest,Bit8s imm) {
static void gen_add_direct_byte(void* dest,int8_t imm) {
gen_add_direct_word(dest, (Bit32s)imm, 1);
}
@ -791,7 +791,7 @@ static void gen_sub_direct_word(void* dest,Bit32u imm,bool dword) {
}
// subtract an 8bit constant value from a dword memory value
static void gen_sub_direct_byte(void* dest,Bit8s imm) {
static void gen_sub_direct_byte(void* dest,int8_t imm) {
gen_sub_direct_word(dest, (Bit32s)imm, 1);
}

View File

@ -595,7 +595,7 @@ static void gen_add_direct_word(void* dest,Bit32u imm,bool dword) {
}
// add an 8bit constant value to a dword memory value
static void gen_add_direct_byte(void* dest,Bit8s imm) {
static void gen_add_direct_byte(void* dest,int8_t imm) {
gen_add_direct_word(dest, (Bit32s)imm, 1);
}
@ -636,7 +636,7 @@ static void gen_sub_direct_word(void* dest,Bit32u imm,bool dword) {
}
// subtract an 8bit constant value from a dword memory value
static void gen_sub_direct_byte(void* dest,Bit8s imm) {
static void gen_sub_direct_byte(void* dest,int8_t imm) {
gen_sub_direct_word(dest, (Bit32s)imm, 1);
}

View File

@ -694,7 +694,7 @@ static void gen_add_direct_word(void* dest,Bit32u imm,bool dword) {
}
// add an 8bit constant value to a dword memory value
static void gen_add_direct_byte(void* dest,Bit8s imm) {
static void gen_add_direct_byte(void* dest,int8_t imm) {
gen_add_direct_word(dest, (Bit32s)imm, 1);
}
@ -734,7 +734,7 @@ static void gen_sub_direct_word(void* dest,Bit32u imm,bool dword) {
}
// subtract an 8bit constant value from a dword memory value
static void gen_sub_direct_byte(void* dest,Bit8s imm) {
static void gen_sub_direct_byte(void* dest,int8_t imm) {
gen_sub_direct_word(dest, (Bit32s)imm, 1);
}

View File

@ -345,12 +345,12 @@ static void INLINE gen_add_direct_word(void* dest,Bit32u imm,bool dword) {
}
// add an 8bit constant value to a dword memory value
static void INLINE gen_add_direct_byte(void* dest,Bit8s imm) {
static void INLINE gen_add_direct_byte(void* dest,int8_t imm) {
gen_add_direct_word(dest, (Bit32s)imm, 1);
}
// subtract an 8bit constant value from a dword memory value
static void INLINE gen_sub_direct_byte(void* dest,Bit8s imm) {
static void INLINE gen_sub_direct_byte(void* dest,int8_t imm) {
gen_add_direct_word(dest, -((Bit32s)imm), 1);
}

View File

@ -297,7 +297,7 @@ static void INLINE gen_mov_direct_ptr(void* dest,DRC_PTR_SIZE_IM imm) {
// add an 8bit constant value to a memory value
static void gen_add_direct_byte(void* dest,Bit8s imm) {
static void gen_add_direct_byte(void* dest,int8_t imm) {
if (!imm) return;
gen_memaddr(0x4,dest,1,imm,0x83); // add [data],imm
}
@ -306,14 +306,14 @@ static void gen_add_direct_byte(void* dest,Bit8s imm) {
static void gen_add_direct_word(void* dest,Bit32u imm,bool dword) {
if (!imm) return;
if ((imm<128) && dword) {
gen_add_direct_byte(dest,(Bit8s)imm);
gen_add_direct_byte(dest,(int8_t)imm);
return;
}
gen_memaddr(0x4,dest,(dword?4:2),imm,0x81,(dword?0:0x66)); // add [data],imm
}
// subtract an 8bit constant value from a memory value
static void gen_sub_direct_byte(void* dest,Bit8s imm) {
static void gen_sub_direct_byte(void* dest,int8_t imm) {
if (!imm) return;
gen_memaddr(0x2c,dest,1,imm,0x83);
}
@ -322,7 +322,7 @@ static void gen_sub_direct_byte(void* dest,Bit8s imm) {
static void gen_sub_direct_word(void* dest,Bit32u imm,bool dword) {
if (!imm) return;
if ((imm<128) && dword) {
gen_sub_direct_byte(dest,(Bit8s)imm);
gen_sub_direct_byte(dest,(int8_t)imm);
return;
}
gen_memaddr(0x2c,dest,(dword?4:2),imm,0x81,(dword?0:0x66)); // sub [data],imm

View File

@ -214,7 +214,7 @@ static void INLINE gen_mov_direct_ptr(void* dest,DRC_PTR_SIZE_IM imm) {
// add an 8bit constant value to a memory value
static void gen_add_direct_byte(void* dest,Bit8s imm) {
static void gen_add_direct_byte(void* dest,int8_t imm) {
cache_addw(0x0583); // add [data],imm
cache_addd((Bit32u)dest);
cache_addb(imm);
@ -223,7 +223,7 @@ static void gen_add_direct_byte(void* dest,Bit8s imm) {
// add a 32bit (dword==true) or 16bit (dword==false) constant value to a memory value
static void gen_add_direct_word(void* dest,Bit32u imm,bool dword) {
if ((imm<128) && dword) {
gen_add_direct_byte(dest,(Bit8s)imm);
gen_add_direct_byte(dest,(int8_t)imm);
return;
}
if (!dword) cache_addb(0x66);
@ -234,7 +234,7 @@ static void gen_add_direct_word(void* dest,Bit32u imm,bool dword) {
}
// subtract an 8bit constant value from a memory value
static void gen_sub_direct_byte(void* dest,Bit8s imm) {
static void gen_sub_direct_byte(void* dest,int8_t imm) {
cache_addw(0x2d83); // sub [data],imm
cache_addd((Bit32u)dest);
cache_addb(imm);
@ -243,7 +243,7 @@ static void gen_sub_direct_byte(void* dest,Bit8s imm) {
// subtract a 32bit (dword==true) or 16bit (dword==false) constant value from a memory value
static void gen_sub_direct_word(void* dest,Bit32u imm,bool dword) {
if ((imm<128) && dword) {
gen_sub_direct_byte(dest,(Bit8s)imm);
gen_sub_direct_byte(dest,(int8_t)imm);
return;
}
if (!dword) cache_addb(0x66);

View File

@ -39,7 +39,7 @@ typedef PhysPt EAPoint;
#define LoadMw(off) mem_readw_inline(off)
#define LoadMd(off) mem_readd_inline(off)
#define LoadMbs(off) (Bit8s)(LoadMb(off))
#define LoadMbs(off) (int8_t)(LoadMb(off))
#define LoadMws(off) (Bit16s)(LoadMw(off))
#define LoadMds(off) (Bit32s)(LoadMd(off))

View File

@ -45,8 +45,8 @@ l_MODRMswitch:
inst_op1_d=Fetchb();
break;
case M_Ebx:
if (inst.rm<0xc0) inst_op1_ds=(Bit8s)LoadMb(inst.rm_eaa);
else inst_op1_ds=(Bit8s)reg_8(inst.rm_eai);
if (inst.rm<0xc0) inst_op1_ds=(int8_t)LoadMb(inst.rm_eaa);
else inst_op1_ds=(int8_t)reg_8(inst.rm_eai);
break;
case M_EbIb:
inst_op2_d=Fetchb();
@ -426,7 +426,7 @@ l_M_Ed:
}
goto nextopcode;
case D_CBW:
reg_ax=(Bit16u)((Bit8s)reg_al);
reg_ax=(Bit16u)((int8_t)reg_al);
goto nextopcode;
case D_CWDE:
reg_eax=(Bit32u)((Bit16s)reg_ax);

View File

@ -46,7 +46,7 @@ static INLINE Bit32u the_Fetchd(EAPoint & loc) {
#define Fetchw() the_Fetchw(inst.cseip)
#define Fetchd() the_Fetchd(inst.cseip)
#define Fetchbs() (Bit8s)the_Fetchb(inst.cseip)
#define Fetchbs() (int8_t)the_Fetchb(inst.cseip)
#define Fetchws() (Bit16s)the_Fetchw(inst.cseip)
#define Fetchds() (Bit32s)the_Fetchd(inst.cseip)

View File

@ -194,11 +194,11 @@ struct FullData {
Bit16u word[2];
Bit16s words[2];
uint8_t byte[4];
Bit8s bytes[4];
int8_t bytes[4];
} blah1,blah2,blah_imm;
#else
union {
uint8_t b;Bit8s bs;
uint8_t b;int8_t bs;
Bit16u w;Bit16s ws;
Bit32u d;Bit32s ds;
} op1,op2,imm;

View File

@ -671,7 +671,7 @@
if (CPU_ArchitectureType<CPU_ARCHTYPE_386) goto illegal_opcode;
{
GetRMrw;
if (rm >= 0xc0 ) {GetEArb;*rmrw=(Bit16u)(*(Bit8s *)earb);}
if (rm >= 0xc0 ) {GetEArb;*rmrw=(Bit16u)(*(int8_t *)earb);}
else {GetEAa;*rmrw=(Bit16u)LoadMbs(eaa);}
break;
}

View File

@ -471,7 +471,7 @@
CASE_0F_D(0xbe) /* MOVSX Gd,Eb */
{
GetRMrd;
if (rm >= 0xc0 ) {GetEArb;*rmrd=(Bit32u)(*(Bit8s *)earb);}
if (rm >= 0xc0 ) {GetEArb;*rmrd=(Bit32u)(*(int8_t *)earb);}
else {GetEAa;*rmrd=(Bit32u)LoadMbs(eaa);}
break;
}

View File

@ -613,7 +613,7 @@
{ Bit16u temp=reg_ax;reg_ax=reg_di;reg_di=temp; }
break;
CASE_W(0x98) /* CBW */
reg_ax=(Bit16u)((Bit8s)reg_al);break;
reg_ax=(Bit16u)((int8_t)reg_al);break;
CASE_W(0x99) /* CWD */
if (reg_ax & 0x8000) reg_dx=0xffff;else reg_dx=0;
break;

View File

@ -17,7 +17,7 @@
*/
#define LoadMbs(off) (Bit8s)(LoadMb(off))
#define LoadMbs(off) (int8_t)(LoadMb(off))
#define LoadMws(off) (Bit16s)(LoadMw(off))
#define LoadMds(off) (Bit32s)(LoadMd(off))
@ -29,8 +29,8 @@
#define SaveRw(reg,val) reg=((Bit16u)(val))
#define SaveRd(reg,val) reg=((Bit32u)(val))
static INLINE Bit8s Fetchbs() {
return (Bit8s)Fetchb();
static INLINE int8_t Fetchbs() {
return (int8_t)Fetchb();
}
static INLINE Bit16s Fetchws() {
return (Bit16s)Fetchw();

View File

@ -1811,10 +1811,10 @@ call_code:
// catch pagefaults
if (call.saved.gate.paramcount&31) {
if (call.Type()==DESC_386_CALL_GATE) {
for (Bit8s i=(call.saved.gate.paramcount&31)-1;i>=0;i--)
for (int8_t i=(call.saved.gate.paramcount&31)-1;i>=0;i--)
mem_readd(o_stack+(uint8_t)i*4u);
} else {
for (Bit8s i=(call.saved.gate.paramcount&31)-1;i>=0;i--)
for (int8_t i=(call.saved.gate.paramcount&31)-1;i>=0;i--)
mem_readw(o_stack+(uint8_t)i*2u);
}
}
@ -1856,7 +1856,7 @@ call_code:
CPU_Push32(o_ss); //save old stack
CPU_Push32(o_esp);
if (call.saved.gate.paramcount&31)
for (Bit8s i=(call.saved.gate.paramcount&31)-1;i>=0;i--)
for (int8_t i=(call.saved.gate.paramcount&31)-1;i>=0;i--)
CPU_Push32(mem_readd(o_stack+(uint8_t)i*4u));
CPU_Push32(oldcs);
CPU_Push32(oldeip);
@ -1864,7 +1864,7 @@ call_code:
CPU_Push16(o_ss); //save old stack
CPU_Push16((Bit16u)o_esp);
if (call.saved.gate.paramcount&31)
for (Bit8s i=(call.saved.gate.paramcount&31)-1;i>=0;i--)
for (int8_t i=(call.saved.gate.paramcount&31)-1;i>=0;i--)
CPU_Push16(mem_readw(o_stack+(uint8_t)i*2u));
CPU_Push16(oldcs);
CPU_Push16(oldeip);

View File

@ -92,7 +92,7 @@ Bit32u get_CF(void) {
case t_DSHRd:
return (lf_var1d >> (lf_var2b - 1)) & 1;
case t_SARb:
return (((Bit8s) lf_var1b) >> (lf_var2b - 1)) & 1;
return (((int8_t) lf_var1b) >> (lf_var2b - 1)) & 1;
case t_SARw:
return (((Bit16s) lf_var1w) >> (lf_var2b - 1)) & 1;
case t_SARd:
@ -798,7 +798,7 @@ Bitu FillFlags(void) {
case t_SARb:
SET_FLAG(CF,(((Bit8s) lf_var1b) >> (lf_var2b - 1)) & 1);
SET_FLAG(CF,(((int8_t) lf_var1b) >> (lf_var2b - 1)) & 1);
DOFLAG_ZFb;
DOFLAG_SFb;
SET_FLAG(OF,false);

View File

@ -695,11 +695,11 @@ extern bool enable_fpu;
#define IDIVB(op1,load,save) \
{ \
Bits val=(Bit8s)(load(op1)); \
Bits val=(int8_t)(load(op1)); \
if (val==0) EXCEPTION(0); \
Bits quo=((Bit16s)reg_ax) / val; \
Bit8s rem=(Bit8s)((Bit16s)reg_ax % val); \
Bit8s quo8s=(Bit8s)(quo&0xff); \
int8_t rem=(int8_t)((Bit16s)reg_ax % val); \
int8_t quo8s=(int8_t)(quo&0xff); \
if (quo!=(Bit16s)quo8s) EXCEPTION(0); \
reg_ah=(uint8_t)rem; \
reg_al=(uint8_t)quo8s; \
@ -755,7 +755,7 @@ extern bool enable_fpu;
#define IMULB(op1,load,save) \
{ \
reg_ax=((Bit8s)reg_al) * ((Bit8s)(load(op1))); \
reg_ax=((int8_t)reg_al) * ((int8_t)(load(op1))); \
FillFlagsNoCFOF(); \
SETFLAGBIT(ZF,reg_al == 0); \
SETFLAGBIT(SF,reg_al & 0x80); \

View File

@ -87,11 +87,11 @@ MMX_reg * lookupRMregMM[256]={
};
Bit8s SaturateWordSToByteS(Bit16s value)
int8_t SaturateWordSToByteS(Bit16s value)
{
if(value < -128) return -128;
if(value > 127) return 127;
return (Bit8s) value;
return (int8_t) value;
}
Bit16s SaturateDwordSToWordS(Bit32s value)

View File

@ -75,7 +75,7 @@ typedef uint8_t UINT8;
typedef Bit16u UINT16;
typedef Bit32u UINT32;
typedef Bit8s INT8;
typedef int8_t INT8;
typedef Bit16s INT16;
typedef Bit32s INT32;

View File

@ -184,7 +184,7 @@ static Bit16u OpOffsetTable[64];
//The lower bits are the shift of the operator vibrato value
//The highest bit is right shifted to generate -1 or 0 for negation
//So taking the highest input value of 7 this gives 3, 7, 3, 0, -3, -7, -3, 0
static const Bit8s VibratoTable[ 8 ] = {
static const int8_t VibratoTable[ 8 ] = {
1 - 0x00, 0 - 0x00, 1 - 0x00, 30 - 0x00,
1 - 0x80, 0 - 0x80, 1 - 0x80, 30 - 0x80
};
@ -454,7 +454,7 @@ void Operator::Write20( const Chip* chip, uint8_t val ) {
return;
reg20 = val;
//Shift the tremolo bit over the entire register, saved a branch, YES!
tremoloMask = (Bit8s)(val) >> 7;
tremoloMask = (int8_t)(val) >> 7;
tremoloMask &= ~(( 1 << ENV_EXTRA ) -1);
//Update specific features based on changes
if ( change & MASK_KSR ) {

View File

@ -169,8 +169,8 @@ struct Channel {
uint8_t regC0;
//This should correspond with reg104, bit 6 indicates a Percussion channel, bit 7 indicates a silent channel
uint8_t fourMask;
Bit8s maskLeft; //Sign extended values for both channel's panning
Bit8s maskRight;
int8_t maskLeft; //Sign extended values for both channel's panning
int8_t maskRight;
//Forward the channel data to the operators of the channel
void SetChanData( const Chip* chip, Bit32u data );
@ -217,7 +217,7 @@ struct Chip {
uint8_t regBD;
uint8_t vibratoIndex = 0;
uint8_t tremoloIndex = 0;
Bit8s vibratoSign = 0;
int8_t vibratoSign = 0;
uint8_t vibratoShift = 0;
uint8_t tremoloValue = 0;
uint8_t vibratoStrength = 0;
@ -225,7 +225,7 @@ struct Chip {
//Mask for allowed wave forms
uint8_t waveFormMask = 0;
//0 or -1 when enabled
Bit8s opl3Active;
int8_t opl3Active;
//Return the maximum amount of samples before and LFO change
Bit32u ForwardLFO( Bit32u samples );

View File

@ -213,7 +213,7 @@ public:
}
INLINE Bit32s LoadSample8(const Bit32u addr/*memory address without fractional bits*/) const {
return (Bit8s)GUSRam[addr & 0xFFFFFu/*1MB*/] << Bit32s(8); /* typecast to sign extend 8-bit value */
return (int8_t)GUSRam[addr & 0xFFFFFu/*1MB*/] << Bit32s(8); /* typecast to sign extend 8-bit value */
}
INLINE Bit32s LoadSample16(const Bit32u addr/*memory address without fractional bits*/) const {

View File

@ -522,9 +522,9 @@ inline void MixerChannel::loadCurrentSample(Bitu &len, const Type* &data) {
const uint8_t xr = signeddata ? 0x00 : 0x80;
len--;
current[0] = ((Bit8s)((*data++) ^ xr)) << 8;
current[0] = ((int8_t)((*data++) ^ xr)) << 8;
if (stereo)
current[1] = ((Bit8s)((*data++) ^ xr)) << 8;
current[1] = ((int8_t)((*data++) ^ xr)) << 8;
else
current[1] = current[0];
}
@ -701,11 +701,11 @@ void MixerChannel::AddSamples_m8(Bitu len, const uint8_t * data) {
void MixerChannel::AddSamples_s8(Bitu len,const uint8_t * data) {
AddSamples<uint8_t,true,false,true>(len,data);
}
void MixerChannel::AddSamples_m8s(Bitu len,const Bit8s * data) {
AddSamples<Bit8s,false,true,true>(len,data);
void MixerChannel::AddSamples_m8s(Bitu len,const int8_t * data) {
AddSamples<int8_t,false,true,true>(len,data);
}
void MixerChannel::AddSamples_s8s(Bitu len,const Bit8s * data) {
AddSamples<Bit8s,true,true,true>(len,data);
void MixerChannel::AddSamples_s8s(Bitu len,const int8_t * data) {
AddSamples<int8_t,true,true,true>(len,data);
}
void MixerChannel::AddSamples_m16(Bitu len,const Bit16s * data) {
AddSamples<Bit16s,false,true,true>(len,data);

View File

@ -165,7 +165,7 @@ static const uint8_t eg_incstep[4][4] = {
// address decoding
//
static const Bit8s ad_slot[0x20] = {
static const int8_t ad_slot[0x20] = {
0, 1, 2, 3, 4, 5, -1, -1, 6, 7, 8, 9, 10, 11, -1, -1,
12, 13, 14, 15, 16, 17, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
};
@ -531,7 +531,7 @@ static void OPL3_PhaseGenerate(opl3_slot *slot)
f_num = slot->channel->f_num;
if (slot->reg_vib)
{
Bit8s range;
int8_t range;
uint8_t vibpos;
range = (f_num >> 7) & 7;

View File

@ -28,7 +28,7 @@
#define fltype double
/*
define Bits, Bitu, Bit32s, Bit32u, Bit16s, Bit16u, Bit8s, uint8_t here
define Bits, Bitu, Bit32s, Bit32u, Bit16s, Bit16u, int8_t, uint8_t here
*/
/*
#include <stdint.h>
@ -39,7 +39,7 @@ typedef int32_t Bit32s;
typedef uint16_t Bit16u;
typedef int16_t Bit16s;
typedef uint8_t uint8_t;
typedef int8_t Bit8s;
typedef int8_t int8_t;
*/

View File

@ -1959,7 +1959,7 @@ void CPrinter::fprintASCII85(FILE* f, Bit16u b)
else
{
char buffer[5];
for (Bit8s i = 4; i >= 0; i--)
for (int8_t i = 4; i >= 0; i--)
{
buffer[i] = (uint8_t)((Bit32u)num % (Bit32u)85);
buffer[i] += 33;

View File

@ -458,7 +458,7 @@ static void DSP_DMA_CallBack(DmaChannel * chan, DMAEvent event) {
#define DC_OFFSET_FADE 254
static INLINE uint8_t decode_ADPCM_4_sample(uint8_t sample,uint8_t & reference,Bits& scale) {
static const Bit8s scaleMap[64] = {
static const int8_t scaleMap[64] = {
0, 1, 2, 3, 4, 5, 6, 7, 0, -1, -2, -3, -4, -5, -6, -7,
1, 3, 5, 7, 9, 11, 13, 15, -1, -3, -5, -7, -9, -11, -13, -15,
2, 6, 10, 14, 18, 22, 26, 30, -2, -6, -10, -14, -18, -22, -26, -30,
@ -493,7 +493,7 @@ static INLINE uint8_t decode_ADPCM_4_sample(uint8_t sample,uint8_t & reference,B
}
static INLINE uint8_t decode_ADPCM_2_sample(uint8_t sample,uint8_t & reference,Bits& scale) {
static const Bit8s scaleMap[24] = {
static const int8_t scaleMap[24] = {
0, 1, 0, -1, 1, 3, -1, -3,
2, 6, -2, -6, 4, 12, -4, -12,
8, 24, -8, -24, 16, 48, -16, -48
@ -522,7 +522,7 @@ static INLINE uint8_t decode_ADPCM_2_sample(uint8_t sample,uint8_t & reference,B
}
INLINE uint8_t decode_ADPCM_3_sample(uint8_t sample,uint8_t & reference,Bits& scale) {
static const Bit8s scaleMap[40] = {
static const int8_t scaleMap[40] = {
0, 1, 2, 3, 0, -1, -2, -3,
1, 3, 5, 7, -1, -3, -5, -7,
2, 6, 10, 14, -2, -6, -10, -14,
@ -665,7 +665,7 @@ static void GenerateDMASound(Bitu size) {
read=sb.dma.chan->Read(size,&sb.dma.buf.b8[sb.dma.remain_size]);
Bitu total=read+sb.dma.remain_size;
if (!sb.dma.sign) sb.chan->AddSamples_s8(total>>1,sb.dma.buf.b8);
else sb.chan->AddSamples_s8s(total>>1,(Bit8s*)sb.dma.buf.b8);
else sb.chan->AddSamples_s8s(total>>1,(int8_t*)sb.dma.buf.b8);
if (total&1) {
sb.dma.remain_size=1;
sb.dma.buf.b8[0]=sb.dma.buf.b8[total-1];
@ -673,7 +673,7 @@ static void GenerateDMASound(Bitu size) {
} else {
read=sb.dma.chan->Read(size,sb.dma.buf.b8);
if (!sb.dma.sign) sb.chan->AddSamples_m8(read,sb.dma.buf.b8);
else sb.chan->AddSamples_m8s(read,(Bit8s *)sb.dma.buf.b8);
else sb.chan->AddSamples_m8s(read,(int8_t *)sb.dma.buf.b8);
}
break;
case DSP_DMA_16:

View File

@ -47,7 +47,7 @@
/* 8-bit values */
typedef uint8_t UINT8;
typedef Bit8s INT8;
typedef int8_t INT8;
/* 16-bit values */
typedef Bit16u UINT16;

View File

@ -93,10 +93,10 @@ Bitu INT10_Handler(void) {
else INT10_SetActivePage(reg_al);
break;
case 0x06: /* Scroll Up */
INT10_ScrollWindow(reg_ch,reg_cl,reg_dh,reg_dl,-(Bit8s)reg_al,reg_bh,0xFF);
INT10_ScrollWindow(reg_ch,reg_cl,reg_dh,reg_dl,-(int8_t)reg_al,reg_bh,0xFF);
break;
case 0x07: /* Scroll Down */
INT10_ScrollWindow(reg_ch,reg_cl,reg_dh,reg_dl,(Bit8s)reg_al,reg_bh,0xFF);
INT10_ScrollWindow(reg_ch,reg_cl,reg_dh,reg_dl,(int8_t)reg_al,reg_bh,0xFF);
break;
case 0x08: /* Read character & attribute at cursor */
INT10_ReadCharAttr(&reg_ax,reg_bh);

View File

@ -182,7 +182,7 @@ bool INT10_GetInsertState();
bool INT10_SetVideoMode(Bit16u mode);
void INT10_ScrollWindow(uint8_t rul,uint8_t cul,uint8_t rlr,uint8_t clr,Bit8s nlines,uint8_t attr,uint8_t page);
void INT10_ScrollWindow(uint8_t rul,uint8_t cul,uint8_t rlr,uint8_t clr,int8_t nlines,uint8_t attr,uint8_t page);
void INT10_SetActivePage(uint8_t page);
bool INT10_SetCurMode(void);

View File

@ -248,7 +248,7 @@ static void TEXT_FillRow(uint8_t cleft,uint8_t cright,uint8_t row,PhysPt base,ui
}
void INT10_ScrollWindow(uint8_t rul,uint8_t cul,uint8_t rlr,uint8_t clr,Bit8s nlines,uint8_t attr,uint8_t page) {
void INT10_ScrollWindow(uint8_t rul,uint8_t cul,uint8_t rlr,uint8_t clr,int8_t nlines,uint8_t attr,uint8_t page) {
/* Do some range checking */
if (CurMode->type!=M_TEXT) page=0xff;
BIOS_NCOLS;BIOS_NROWS;

View File

@ -55,12 +55,12 @@ enum {
static int calcBaseCutoff(const TimbreParam::PartialParam *partialParam, Bit32u basePitch, unsigned int key, bool quirkTVFBaseCutoffLimit) {
// This table matches the values used by a real LAPC-I.
static const Bit8s biasLevelToBiasMult[] = {85, 42, 21, 16, 10, 5, 2, 0, -2, -5, -10, -16, -21, -74, -85};
static const int8_t biasLevelToBiasMult[] = {85, 42, 21, 16, 10, 5, 2, 0, -2, -5, -10, -16, -21, -74, -85};
// These values represent unique options with no consistent pattern, so we have to use something like a table in any case.
// The table entries, when divided by 21, match approximately what the manual claims:
// -1, -1/2, -1/4, 0, 1/8, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8, 1, 5/4, 3/2, 2, s1, s2
// Note that the entry for 1/8 is rounded to 2 (from 1/8 * 21 = 2.625), which seems strangely inaccurate compared to the others.
static const Bit8s keyfollowMult21[] = {-21, -10, -5, 0, 2, 5, 8, 10, 13, 16, 18, 21, 26, 32, 42, 21, 21};
static const int8_t keyfollowMult21[] = {-21, -10, -5, 0, 2, 5, 8, 10, 13, 16, 18, 21, 26, 32, 42, 21, 21};
int baseCutoff = keyfollowMult21[partialParam->tvf.keyfollow] - keyfollowMult21[partialParam->wg.pitchKeyfollow];
// baseCutoff range now: -63 to 63
baseCutoff *= int(key) - 60;

View File

@ -47,7 +47,7 @@ private:
Bit16s lfoPitchOffset;
// In range -12 - 36
Bit8s timeKeyfollowSubtraction;
int8_t timeKeyfollowSubtraction;
Bit16s pitchOffsetChangePerBigTick;
Bit16u targetPitchOffsetReachedBigTick;

View File

@ -25,7 +25,7 @@ typedef signed int Bit32s;
typedef unsigned short int Bit16u;
typedef signed short int Bit16s;
typedef unsigned char uint8_t;
typedef signed char Bit8s;
typedef signed char int8_t;
}

View File

@ -178,7 +178,7 @@ public:
DWORD dwTexHeight = 0, dwTexWidth = 0;
bool square = false, pow2 = false, dynamic = false, bpp16; // Texture limitations
Bit8s aspect, autofit = 0;
int8_t aspect, autofit = 0;
// Pixel shader status
bool psActive;