aboutsummaryrefslogtreecommitdiff
path: root/source/sa1.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/sa1.c')
-rw-r--r--source/sa1.c158
1 files changed, 79 insertions, 79 deletions
diff --git a/source/sa1.c b/source/sa1.c
index 4171903..6ac3041 100644
--- a/source/sa1.c
+++ b/source/sa1.c
@@ -95,16 +95,16 @@
static void S9xSA1CharConv2();
static void S9xSA1DMA();
-static void S9xSA1ReadVariableLengthData(bool8 inc, bool8 no_shift);
+static void S9xSA1ReadVariableLengthData(bool inc, bool no_shift);
void S9xSA1Init()
{
- SA1.NMIActive = FALSE;
- SA1.IRQActive = FALSE;
- SA1.WaitingForInterrupt = FALSE;
- SA1.Waiting = FALSE;
+ SA1.NMIActive = false;
+ SA1.IRQActive = false;
+ SA1.WaitingForInterrupt = false;
+ SA1.Waiting = false;
SA1.Flags = 0;
- SA1.Executing = FALSE;
+ SA1.Executing = false;
memset(&Memory.FillRAM [0x2200], 0, 0x200);
Memory.FillRAM [0x2200] = 0x20;
Memory.FillRAM [0x2220] = 0x00;
@@ -116,7 +116,7 @@ void S9xSA1Init()
SA1.op2 = 0;
SA1.arithmetic_op = 0;
SA1.sum = 0;
- SA1.overflow = FALSE;
+ SA1.overflow = false;
SA1.S9xOpcodes = NULL;
}
@@ -138,7 +138,7 @@ void S9xSA1Reset()
SA1SetFlags(MemoryFlag | IndexFlag | IRQ | Emulation);
SA1ClearFlags(Decimal);
- SA1.WaitingForInterrupt = FALSE;
+ SA1.WaitingForInterrupt = false;
SA1.PC = NULL;
SA1.PCBase = NULL;
S9xSA1SetPCBase(SA1.Registers.PC);
@@ -146,12 +146,12 @@ void S9xSA1Reset()
S9xSA1UnpackStatus();
S9xSA1FixCycles();
- SA1.Executing = TRUE;
+ SA1.Executing = true;
SA1.BWRAM = Memory.SRAM;
Memory.FillRAM [0x2225] = 0;
}
-void S9xSA1SetBWRAMMemMap(uint8 val)
+void S9xSA1SetBWRAMMemMap(uint8_t val)
{
int c;
@@ -159,10 +159,10 @@ void S9xSA1SetBWRAMMemMap(uint8 val)
{
for (c = 0; c < 0x400; c += 16)
{
- SA1.Map [c + 6] = SA1.Map [c + 0x806] = (uint8*) MAP_BWRAM_BITMAP2;
- SA1.Map [c + 7] = SA1.Map [c + 0x807] = (uint8*) MAP_BWRAM_BITMAP2;
- SA1.WriteMap [c + 6] = SA1.WriteMap [c + 0x806] = (uint8*) MAP_BWRAM_BITMAP2;
- SA1.WriteMap [c + 7] = SA1.WriteMap [c + 0x807] = (uint8*) MAP_BWRAM_BITMAP2;
+ SA1.Map [c + 6] = SA1.Map [c + 0x806] = (uint8_t*) MAP_BWRAM_BITMAP2;
+ SA1.Map [c + 7] = SA1.Map [c + 0x807] = (uint8_t*) MAP_BWRAM_BITMAP2;
+ SA1.WriteMap [c + 6] = SA1.WriteMap [c + 0x806] = (uint8_t*) MAP_BWRAM_BITMAP2;
+ SA1.WriteMap [c + 7] = SA1.WriteMap [c + 0x807] = (uint8_t*) MAP_BWRAM_BITMAP2;
}
SA1.BWRAM = Memory.SRAM + (val & 0x7f) * 0x2000 / 4;
}
@@ -170,10 +170,10 @@ void S9xSA1SetBWRAMMemMap(uint8 val)
{
for (c = 0; c < 0x400; c += 16)
{
- SA1.Map [c + 6] = SA1.Map [c + 0x806] = (uint8*) MAP_BWRAM;
- SA1.Map [c + 7] = SA1.Map [c + 0x807] = (uint8*) MAP_BWRAM;
- SA1.WriteMap [c + 6] = SA1.WriteMap [c + 0x806] = (uint8*) MAP_BWRAM;
- SA1.WriteMap [c + 7] = SA1.WriteMap [c + 0x807] = (uint8*) MAP_BWRAM;
+ SA1.Map [c + 6] = SA1.Map [c + 0x806] = (uint8_t*) MAP_BWRAM;
+ SA1.Map [c + 7] = SA1.Map [c + 0x807] = (uint8_t*) MAP_BWRAM;
+ SA1.WriteMap [c + 6] = SA1.WriteMap [c + 0x806] = (uint8_t*) MAP_BWRAM;
+ SA1.WriteMap [c + 7] = SA1.WriteMap [c + 0x807] = (uint8_t*) MAP_BWRAM;
}
SA1.BWRAM = Memory.SRAM + (val & 7) * 0x2000;
}
@@ -181,8 +181,8 @@ void S9xSA1SetBWRAMMemMap(uint8 val)
void S9xFixSA1AfterSnapshotLoad()
{
- SA1.ShiftedPB = (uint32) SA1.Registers.PB << 16;
- SA1.ShiftedDB = (uint32) SA1.Registers.DB << 16;
+ SA1.ShiftedPB = (uint32_t) SA1.Registers.PB << 16;
+ SA1.ShiftedDB = (uint32_t) SA1.Registers.DB << 16;
S9xSA1SetPCBase(SA1.ShiftedPB + SA1.Registers.PC);
S9xSA1UnpackStatus();
@@ -195,10 +195,10 @@ void S9xFixSA1AfterSnapshotLoad()
SA1.Executing = !SA1.Waiting;
}
-uint8 S9xSA1GetByte(uint32 address)
+uint8_t S9xSA1GetByte(uint32_t address)
{
- uint8* GetAddress = SA1.Map [(address >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (GetAddress >= (uint8*) MAP_LAST)
+ uint8_t* GetAddress = SA1.Map [(address >> MEMMAP_SHIFT) & MEMMAP_MASK];
+ if (GetAddress >= (uint8_t*) MAP_LAST)
return (*(GetAddress + (address & 0xffff)));
switch ((intptr_t) GetAddress)
@@ -229,17 +229,17 @@ uint8 S9xSA1GetByte(uint32 address)
}
}
-uint16 S9xSA1GetWord(uint32 address)
+uint16_t S9xSA1GetWord(uint32_t address)
{
OpenBus = S9xSA1GetByte(address);
return (OpenBus | (S9xSA1GetByte(address + 1) << 8));
}
-void S9xSA1SetByte(uint8 byte, uint32 address)
+void S9xSA1SetByte(uint8_t byte, uint32_t address)
{
- uint8* Setaddress = SA1.WriteMap [(address >> MEMMAP_SHIFT) & MEMMAP_MASK];
+ uint8_t* Setaddress = SA1.WriteMap [(address >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (Setaddress >= (uint8*) MAP_LAST)
+ if (Setaddress >= (uint8_t*) MAP_LAST)
{
*(Setaddress + (address & 0xffff)) = byte;
return;
@@ -261,13 +261,13 @@ void S9xSA1SetByte(uint8 byte, uint32 address)
address -= 0x600000;
if (SA1.VirtualBitmapFormat == 2)
{
- uint8* ptr = &Memory.SRAM [(address >> 2) & 0xffff];
+ uint8_t* ptr = &Memory.SRAM [(address >> 2) & 0xffff];
*ptr &= ~(3 << ((address & 3) << 1));
*ptr |= (byte & 3) << ((address & 3) << 1);
}
else
{
- uint8* ptr = &Memory.SRAM [(address >> 1) & 0xffff];
+ uint8_t* ptr = &Memory.SRAM [(address >> 1) & 0xffff];
*ptr &= ~(15 << ((address & 1) << 2));
*ptr |= (byte & 15) << ((address & 1) << 2);
}
@@ -276,13 +276,13 @@ void S9xSA1SetByte(uint8 byte, uint32 address)
address = (address & 0xffff) - 0x6000;
if (SA1.VirtualBitmapFormat == 2)
{
- uint8* ptr = &SA1.BWRAM [(address >> 2) & 0xffff];
+ uint8_t* ptr = &SA1.BWRAM [(address >> 2) & 0xffff];
*ptr &= ~(3 << ((address & 3) << 1));
*ptr |= (byte & 3) << ((address & 3) << 1);
}
else
{
- uint8* ptr = &SA1.BWRAM [(address >> 1) & 0xffff];
+ uint8_t* ptr = &SA1.BWRAM [(address >> 1) & 0xffff];
*ptr &= ~(15 << ((address & 1) << 2));
*ptr |= (byte & 15) << ((address & 1) << 2);
}
@@ -291,16 +291,16 @@ void S9xSA1SetByte(uint8 byte, uint32 address)
}
}
-void S9xSA1SetWord(uint16 Word, uint32 address)
+void S9xSA1SetWord(uint16_t Word, uint32_t address)
{
- S9xSA1SetByte((uint8) Word, address);
- S9xSA1SetByte((uint8)(Word >> 8), address + 1);
+ S9xSA1SetByte((uint8_t) Word, address);
+ S9xSA1SetByte((uint8_t)(Word >> 8), address + 1);
}
-void S9xSA1SetPCBase(uint32 address)
+void S9xSA1SetPCBase(uint32_t address)
{
- uint8* GetAddress = SA1.Map [(address >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (GetAddress >= (uint8*) MAP_LAST)
+ uint8_t* GetAddress = SA1.Map [(address >> MEMMAP_SHIFT) & MEMMAP_MASK];
+ if (GetAddress >= (uint8_t*) MAP_LAST)
{
SA1.PCBase = GetAddress;
SA1.PC = GetAddress + (address & 0xffff);
@@ -363,7 +363,7 @@ void S9xSA1ExecuteDuringSleep()
#endif
}
-void S9xSetSA1MemMap(uint32 which1, uint8 map)
+void S9xSetSA1MemMap(uint32_t which1, uint8_t map)
{
int c;
int start = which1 * 0x100 + 0xc00;
@@ -374,7 +374,7 @@ void S9xSetSA1MemMap(uint32 which1, uint8 map)
for (c = 0; c < 0x100; c += 16)
{
- uint8* block = &Memory.ROM [(map & 7) * 0x100000 + (c << 12)];
+ uint8_t* block = &Memory.ROM [(map & 7) * 0x100000 + (c << 12)];
int i;
for (i = c; i < c + 16; i++)
@@ -383,7 +383,7 @@ void S9xSetSA1MemMap(uint32 which1, uint8 map)
for (c = 0; c < 0x200; c += 16)
{
- uint8* block = &Memory.ROM [(map & 7) * 0x100000 + (c << 11) - 0x8000];
+ uint8_t* block = &Memory.ROM [(map & 7) * 0x100000 + (c << 11) - 0x8000];
int i;
for (i = c + 8; i < c + 16; i++)
@@ -391,35 +391,35 @@ void S9xSetSA1MemMap(uint32 which1, uint8 map)
}
}
-uint8 S9xGetSA1(uint32 address)
+uint8_t S9xGetSA1(uint32_t address)
{
// printf ("R: %04x\n", address);
switch (address)
{
case 0x2300:
- return ((uint8)((Memory.FillRAM [0x2209] & 0x5f) |
+ return ((uint8_t)((Memory.FillRAM [0x2209] & 0x5f) |
(CPU.IRQActive & (SA1_IRQ_SOURCE | SA1_DMA_IRQ_SOURCE))));
case 0x2301:
return ((Memory.FillRAM [0x2200] & 0xf) |
(Memory.FillRAM [0x2301] & 0xf0));
case 0x2306:
- return ((uint8) SA1.sum);
+ return ((uint8_t) SA1.sum);
case 0x2307:
- return ((uint8)(SA1.sum >> 8));
+ return ((uint8_t)(SA1.sum >> 8));
case 0x2308:
- return ((uint8)(SA1.sum >> 16));
+ return ((uint8_t)(SA1.sum >> 16));
case 0x2309:
- return ((uint8)(SA1.sum >> 24));
+ return ((uint8_t)(SA1.sum >> 24));
case 0x230a:
- return ((uint8)(SA1.sum >> 32));
+ return ((uint8_t)(SA1.sum >> 32));
case 0x230c:
return (Memory.FillRAM [0x230c]);
case 0x230d:
{
- uint8 byte = Memory.FillRAM [0x230d];
+ uint8_t byte = Memory.FillRAM [0x230d];
if (Memory.FillRAM [0x2258] & 0x80)
- S9xSA1ReadVariableLengthData(TRUE, FALSE);
+ S9xSA1ReadVariableLengthData(true, false);
return (byte);
}
default:
@@ -429,7 +429,7 @@ uint8 S9xGetSA1(uint32 address)
return (Memory.FillRAM [address]);
}
-void S9xSetSA1(uint8 byte, uint32 address)
+void S9xSetSA1(uint8_t byte, uint32_t address)
{
//printf ("W: %02x -> %04x\n", byte, address);
switch (address)
@@ -642,7 +642,7 @@ void S9xSetSA1(uint8 byte, uint32 address)
break;
case 0x2231:
if (byte & 0x80)
- SA1.in_char_dma = FALSE;
+ SA1.in_char_dma = false;
#if 0
printf("CHDEND %s\n", (byte & 0x80) ? "complete" : "incomplete");
printf("DMA colour mode %d\n", byte & 3);
@@ -674,7 +674,7 @@ void S9xSetSA1(uint8 byte, uint32 address)
Memory.FillRAM [0x2300] |= 0x20;
if (Memory.FillRAM [0x2201] & 0x20)
S9xSetIRQ(SA1_DMA_IRQ_SOURCE);
- SA1.in_char_dma = TRUE;
+ SA1.in_char_dma = true;
}
break;
case 0x2237:
@@ -768,21 +768,21 @@ void S9xSetSA1(uint8 byte, uint32 address)
SA1.sum = SA1.op1 << 16;
else
{
- SA1.sum = (SA1.op1 / (int)((uint16) SA1.op2)) |
- ((SA1.op1 % (int)((uint16) SA1.op2)) << 16);
+ SA1.sum = (SA1.op1 / (int)((uint16_t) SA1.op2)) |
+ ((SA1.op1 % (int)((uint16_t) SA1.op2)) << 16);
}
break;
case 2:
default: // cumulative sum
SA1.sum += SA1.op1 * SA1.op2;
- if (SA1.sum & ((int64) 0xffffff << 32))
- SA1.overflow = TRUE;
+ if (SA1.sum & ((int64_t) 0xffffff << 32))
+ SA1.overflow = true;
break;
}
break;
case 0x2258: // Variable bit-field length/auto inc/start.
Memory.FillRAM [0x2258] = byte;
- S9xSA1ReadVariableLengthData(TRUE, FALSE);
+ S9xSA1ReadVariableLengthData(true, false);
return;
case 0x2259:
case 0x225a:
@@ -790,7 +790,7 @@ void S9xSetSA1(uint8 byte, uint32 address)
Memory.FillRAM [address] = byte;
// XXX: ???
SA1.variable_bit_pos = 0;
- S9xSA1ReadVariableLengthData(FALSE, TRUE);
+ S9xSA1ReadVariableLengthData(false, true);
return;
default:
// printf ("W: %02x->%04x\n", byte, address);
@@ -803,13 +803,13 @@ void S9xSetSA1(uint8 byte, uint32 address)
static void S9xSA1CharConv2()
{
int l, b;
- uint32 dest = Memory.FillRAM [0x2235] | (Memory.FillRAM [0x2236] << 8);
- uint32 offset = (SA1.in_char_dma & 7) ? 0 : 1;
+ uint32_t dest = Memory.FillRAM [0x2235] | (Memory.FillRAM [0x2236] << 8);
+ uint32_t offset = (SA1.in_char_dma & 7) ? 0 : 1;
int depth = (Memory.FillRAM [0x2231] & 3) == 0 ? 8 :
(Memory.FillRAM [0x2231] & 3) == 1 ? 4 : 2;
int bytes_per_char = 8 * depth;
- uint8* p = &Memory.FillRAM [0x3000] + dest + offset * bytes_per_char;
- uint8* q = &Memory.ROM [MAX_ROM_SIZE - 0x10000] + offset * 64;
+ uint8_t* p = &Memory.FillRAM [0x3000] + dest + offset * bytes_per_char;
+ uint8_t* q = &Memory.ROM [MAX_ROM_SIZE - 0x10000] + offset * 64;
switch (depth)
{
@@ -822,7 +822,7 @@ static void S9xSA1CharConv2()
{
for (b = 0; b < 8; b++)
{
- uint8 r = *(q + b);
+ uint8_t r = *(q + b);
*(p + 0) = (*(p + 0) << 1) | ((r >> 0) & 1);
*(p + 1) = (*(p + 1) << 1) | ((r >> 1) & 1);
*(p + 16) = (*(p + 16) << 1) | ((r >> 2) & 1);
@@ -840,23 +840,23 @@ static void S9xSA1CharConv2()
static void S9xSA1DMA()
{
- uint32 src = Memory.FillRAM [0x2232] |
+ uint32_t src = Memory.FillRAM [0x2232] |
(Memory.FillRAM [0x2233] << 8) |
(Memory.FillRAM [0x2234] << 16);
- uint32 dst = Memory.FillRAM [0x2235] |
+ uint32_t dst = Memory.FillRAM [0x2235] |
(Memory.FillRAM [0x2236] << 8) |
(Memory.FillRAM [0x2237] << 16);
- uint32 len = Memory.FillRAM [0x2238] |
+ uint32_t len = Memory.FillRAM [0x2238] |
(Memory.FillRAM [0x2239] << 8);
- uint8* s;
- uint8* d;
+ uint8_t* s;
+ uint8_t* d;
switch (Memory.FillRAM [0x2230] & 3)
{
case 0: // ROM
s = SA1.Map [(src >> MEMMAP_SHIFT) & MEMMAP_MASK];
- if (s >= (uint8*) MAP_LAST)
+ if (s >= (uint8_t*) MAP_LAST)
s += (src & 0xffff);
else
s = Memory.ROM + (src & 0xffff);
@@ -898,37 +898,37 @@ static void S9xSA1DMA()
}
}
-void S9xSA1ReadVariableLengthData(bool8 inc, bool8 no_shift)
+void S9xSA1ReadVariableLengthData(bool inc, bool no_shift)
{
- uint32 addr = Memory.FillRAM [0x2259] |
+ uint32_t addr = Memory.FillRAM [0x2259] |
(Memory.FillRAM [0x225a] << 8) |
(Memory.FillRAM [0x225b] << 16);
- uint8 shift = Memory.FillRAM [0x2258] & 15;
+ uint8_t shift = Memory.FillRAM [0x2258] & 15;
if (no_shift)
shift = 0;
else if (shift == 0)
shift = 16;
- uint8 s = shift + SA1.variable_bit_pos;
+ uint8_t s = shift + SA1.variable_bit_pos;
if (s >= 16)
{
addr += (s >> 4) << 1;
s &= 15;
}
- uint32 data = S9xSA1GetWord(addr) |
+ uint32_t data = S9xSA1GetWord(addr) |
(S9xSA1GetWord(addr + 2) << 16);
data >>= s;
- Memory.FillRAM [0x230c] = (uint8) data;
- Memory.FillRAM [0x230d] = (uint8)(data >> 8);
+ Memory.FillRAM [0x230c] = (uint8_t) data;
+ Memory.FillRAM [0x230d] = (uint8_t)(data >> 8);
if (inc)
{
SA1.variable_bit_pos = (SA1.variable_bit_pos + shift) & 15;
- Memory.FillRAM [0x2259] = (uint8) addr;
- Memory.FillRAM [0x225a] = (uint8)(addr >> 8);
- Memory.FillRAM [0x225b] = (uint8)(addr >> 16);
+ Memory.FillRAM [0x2259] = (uint8_t) addr;
+ Memory.FillRAM [0x225a] = (uint8_t)(addr >> 8);
+ Memory.FillRAM [0x225b] = (uint8_t)(addr >> 16);
}
}