Skip to content

Commit

Permalink
Remove USE_STRUCTS ifdef
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Mattello <[email protected]>
  • Loading branch information
JoeMatt committed Oct 13, 2021
1 parent 5119873 commit ab5f584
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 63 deletions.
27 changes: 2 additions & 25 deletions src/dsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,21 +394,16 @@ uint8_t DSPReadByte(uint32_t offset, uint32_t who/*=UNKNOWN*/)

uint16_t DSPReadWord(uint32_t offset, uint32_t who/*=UNKNOWN*/)
{
#ifdef USE_STRUCTS
Offset offsett;
offsett.LONG = offset;
offset = offsett.Members.offset;
#else
offset &= 0xFFFFFFFE;
#endif
if (offset >= DSP_WORK_RAM_BASE && offset <= DSP_WORK_RAM_BASE+0x1FFF)
{
offset -= DSP_WORK_RAM_BASE;
return GET16(dsp_ram_8, offset);
}
else if ((offset>=DSP_CONTROL_RAM_BASE)&&(offset<DSP_CONTROL_RAM_BASE+0x20))
{
#ifdef USE_STRUCTS
DSPLong data;
data.LONG = DSPReadLong(offset & 0xFFFFFFFC, who);

Expand All @@ -417,13 +412,6 @@ uint16_t DSPReadWord(uint32_t offset, uint32_t who/*=UNKNOWN*/)
} else {
return data.Data.UWORD;
}
#else
uint32_t data = DSPReadLong(offset & 0xFFFFFFFC, who);

if (offset & 0x03)
return data & 0xFFFF;
return data >> 16;
#endif
}

return JaguarReadWord(offset, who);
Expand Down Expand Up @@ -868,7 +856,6 @@ INLINE void DSPExec(int32_t cycles)
IMASKCleared = false;
}

#ifdef USE_STRUCTS
OpCode opcode;
opcode.WORD = DSPReadWord(dsp_pc, DSP);
uint8_t index = opcode.Codes.index;
Expand All @@ -878,18 +865,8 @@ INLINE void DSPExec(int32_t cycles)
dsp_opcode_second_parameter = sp;
dsp_pc += 2;
dsp_opcode[index]();
#else
uint16_t opcode;
uint32_t index;
opcode = DSPReadWord(dsp_pc, DSP);
index = opcode >> 10;
dsp_opcode_first_parameter = (opcode >> 5) & 0x1F;
dsp_opcode_second_parameter = opcode & 0x1F;
dsp_pc += 2;
dsp_opcode[index]();
dsp_opcode_use[index]++;
#endif
cycles -= dsp_opcode_cycles[index];

cycles -= dsp_opcode_cycles[index];
}

dsp_in_exec--;
Expand Down
35 changes: 1 addition & 34 deletions src/gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,11 @@ INLINE uint16_t GPUReadWord(uint32_t offset, uint32_t who/*=UNKNOWN*/)
if ((offset >= GPU_WORK_RAM_BASE) && (offset < GPU_WORK_RAM_BASE+0x1000))
{
offset &= 0xFFF;
#ifdef USE_STRUCTS

OpCode data;
data.Bytes.UBYTE = (uint16_t)gpu_ram_8[offset];
data.Bytes.LBYTE = (uint16_t)gpu_ram_8[offset+1];
return data.WORD;
#else
uint16_t data;
data = ((uint16_t)gpu_ram_8[offset] << 8) | (uint16_t)gpu_ram_8[offset+1];
return data;
#endif
}
else if ((offset >= GPU_CONTROL_RAM_BASE) && (offset < GPU_CONTROL_RAM_BASE+0x20))
{
Expand Down Expand Up @@ -1572,7 +1567,6 @@ INLINE static void gpu_opcode_abs(void)
}


#ifdef USE_STRUCTS
INLINE static void gpu_opcode_div(void) // RN / RM
{

Expand Down Expand Up @@ -1603,33 +1597,6 @@ INLINE static void gpu_opcode_div(void) // RN / RM
RN = q.WORD;
gpu_remain = r.WORD;
}
#else
INLINE static void gpu_opcode_div(void) // RN / RM
{
unsigned i;
// Real algorithm, courtesy of SCPCD: NYAN!
uint32_t q = RN;
uint32_t r = 0;

// If 16.16 division, stuff top 16 bits of RN into remainder and put the
// bottom 16 of RN in top 16 of quotient
if (gpu_div_control & 0x01)
q <<= 16, r = RN >> 16;

for(i=0; i<32; i++)
{
uint32_t sign = r & 0x80000000;
r = (r << 1) | ((q >> 31) & 0x01);
r += (sign ? RM : -RM);
q = (q << 1) | (((~r) >> 31) & 0x01);
}

RN = q;
gpu_remain = r;

}
#endif


INLINE static void gpu_opcode_imultn(void)
{
Expand Down
4 changes: 0 additions & 4 deletions src/vjag_memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ typedef union GPUControl {

} GPUControl;

#ifdef USE_STRUCTS
#pragma pack(push, 1)
typedef union OpCode {
uint16_t WORD;
Expand Down Expand Up @@ -198,9 +197,7 @@ typedef union GPUControl {
#pragma pack(pop)

typedef OpCode U16Union;
#endif //USE_STRUCTS

#ifdef USE_STRUCTS
typedef union Offset {
uint32_t LONG;
#pragma pack(push, 1)
Expand All @@ -215,7 +212,6 @@ typedef union Offset {
} Members;
#pragma pack(pop)
} Offset;
#endif //USE_STRUCTS

typedef union DSPLong {
uint32_t LONG;
Expand Down

0 comments on commit ab5f584

Please sign in to comment.