summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/n64.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/machine/n64.cpp')
-rw-r--r--src/mame/machine/n64.cpp140
1 files changed, 70 insertions, 70 deletions
diff --git a/src/mame/machine/n64.cpp b/src/mame/machine/n64.cpp
index 3feebf44431..4c81a8e427e 100644
--- a/src/mame/machine/n64.cpp
+++ b/src/mame/machine/n64.cpp
@@ -12,7 +12,7 @@
// device type definition
const device_type N64PERIPH = &device_creator<n64_periphs>;
-n64_periphs::n64_periphs(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
+n64_periphs::n64_periphs(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, N64PERIPH, "N64 Periphal Chips", tag, owner, clock, "n64_periphs", __FILE__)
, device_video_interface(mconfig, *this)
, m_nvram_image(nullptr)
@@ -20,13 +20,13 @@ n64_periphs::n64_periphs(const machine_config &mconfig, const char *tag, device_
, disk_present(false)
, cart_present(false)
{
- for (INT32 i = 0; i < 256; i++)
+ for (int32_t i = 0; i < 256; i++)
{
m_gamma_table[i] = sqrt((float)(i << 6));
m_gamma_table[i] <<= 1;
}
- for (INT32 i = 0; i < 0x4000; i++)
+ for (int32_t i = 0; i < 0x4000; i++)
{
m_gamma_dither_table[i] = sqrt((float)i);
m_gamma_dither_table[i] <<= 1;
@@ -120,7 +120,7 @@ void n64_periphs::device_start()
void n64_periphs::device_reset()
{
- UINT32 *cart = (UINT32*)machine().root_device().memregion("user2")->base();
+ uint32_t *cart = (uint32_t*)machine().root_device().memregion("user2")->base();
m_vr4300 = machine().device<mips3_device>("maincpu");
m_rsp = machine().device<rsp_device>("rsp");
@@ -225,7 +225,7 @@ void n64_periphs::device_reset()
reset_timer->adjust(attotime::never);
// bootcode differs between CIC-chips, so we can use its checksum to detect the CIC-chip
- UINT64 boot_checksum = 0;
+ uint64_t boot_checksum = 0;
for(int i = 0x40; i < 0x1000; i+=4)
{
boot_checksum += cart[i/4]+i;
@@ -308,7 +308,7 @@ void n64_periphs::device_reset()
READ32_MEMBER( n64_periphs::mi_reg_r )
{
- UINT32 ret = 0;
+ uint32_t ret = 0;
switch (offset)
{
case 0x00/4: // MI_MODE_REG
@@ -501,7 +501,7 @@ WRITE32_MEMBER( n64_periphs::is64_w )
READ32_MEMBER( n64_periphs::open_r )
{
- UINT32 retval = (offset << 2) & 0x0000ffff;
+ uint32_t retval = (offset << 2) & 0x0000ffff;
retval = ((retval + 2) << 16) | retval;
return retval;
}
@@ -548,7 +548,7 @@ WRITE32_MEMBER( n64_periphs::rdram_reg_w )
void n64_periphs::sp_dma(int direction)
{
- UINT32 length = sp_dma_length + 1;
+ uint32_t length = sp_dma_length + 1;
if ((length & 7) != 0)
{
@@ -569,15 +569,15 @@ void n64_periphs::sp_dma(int direction)
length = 0x1000 - (sp_mem_addr & 0xfff);
}
- UINT32 *sp_mem[2] = { m_rsp_dmem, m_rsp_imem };
+ uint32_t *sp_mem[2] = { m_rsp_dmem, m_rsp_imem };
int sp_mem_page = (sp_mem_addr >> 12) & 1;
if(direction == 0)// RDRAM -> I/DMEM
{
for(int c = 0; c <= sp_dma_count; c++)
{
- UINT32 src = (sp_dram_addr & 0x007fffff) >> 2;
- UINT32 dst = (sp_mem_addr & 0xfff) >> 2;
+ uint32_t src = (sp_dram_addr & 0x007fffff) >> 2;
+ uint32_t dst = (sp_mem_addr & 0xfff) >> 2;
for(int i = 0; i < length / 4; i++)
{
@@ -594,8 +594,8 @@ void n64_periphs::sp_dma(int direction)
{
for(int c = 0; c <= sp_dma_count; c++)
{
- UINT32 src = (sp_mem_addr & 0xfff) >> 2;
- UINT32 dst = (sp_dram_addr & 0x007fffff) >> 2;
+ uint32_t src = (sp_mem_addr & 0xfff) >> 2;
+ uint32_t dst = (sp_dram_addr & 0x007fffff) >> 2;
for(int i = 0; i < length / 4; i++)
{
@@ -731,8 +731,8 @@ WRITE32_MEMBER(n64_periphs::sp_reg_w )
case 0x10/4: // RSP_STATUS_REG
{
- UINT32 oldstatus = m_rsp->state_int(RSP_SR);
- UINT32 newstatus = oldstatus;
+ uint32_t oldstatus = m_rsp->state_int(RSP_SR);
+ uint32_t newstatus = oldstatus;
if (data & 0x00000001) // clear halt
{
@@ -921,7 +921,7 @@ READ32_MEMBER( n64_periphs::dp_reg_r )
WRITE32_MEMBER( n64_periphs::dp_reg_w )
{
- UINT32 status = m_n64->rdp()->get_status();
+ uint32_t status = m_n64->rdp()->get_status();
switch (offset)
{
@@ -959,7 +959,7 @@ WRITE32_MEMBER( n64_periphs::dp_reg_w )
case 0x0c/4: // DP_STATUS_REG
{
- UINT32 current_status = m_n64->rdp()->get_status();
+ uint32_t current_status = m_n64->rdp()->get_status();
if (data & 0x00000001) current_status &= ~DP_STATUS_XBUS_DMA;
if (data & 0x00000002) current_status |= DP_STATUS_XBUS_DMA;
if (data & 0x00000004) current_status &= ~DP_STATUS_FREEZE;
@@ -1024,7 +1024,7 @@ void n64_periphs::vi_recalculate_resolution()
READ32_MEMBER( n64_periphs::vi_reg_r )
{
- UINT32 ret = 0;
+ uint32_t ret = 0;
switch (offset)
{
case 0x00/4: // VI_CONTROL_REG
@@ -1180,7 +1180,7 @@ WRITE32_MEMBER( n64_periphs::vi_reg_w )
// Audio Interface
-void n64_periphs::ai_fifo_push(UINT32 address, UINT32 length)
+void n64_periphs::ai_fifo_push(uint32_t address, uint32_t length)
{
if (ai_fifo_num == AUDIO_DMA_DEPTH)
{
@@ -1248,7 +1248,7 @@ n64_periphs::AUDIO_DMA *n64_periphs::ai_fifo_get_top()
void n64_periphs::ai_dma()
{
- INT16 *ram = (INT16*)m_rdram;
+ int16_t *ram = (int16_t*)m_rdram;
AUDIO_DMA *current = ai_fifo_get_top();
attotime period;
@@ -1295,7 +1295,7 @@ void n64_periphs::ai_timer_tick()
READ32_MEMBER( n64_periphs::ai_reg_r )
{
- UINT32 ret = 0;
+ uint32_t ret = 0;
switch (offset)
{
case 0x04/4: // AI_LEN_REG
@@ -1307,7 +1307,7 @@ READ32_MEMBER( n64_periphs::ai_reg_r )
else if (ai_status & 0x40000000)
{
double secs_left = (ai_timer->expire() - machine().time()).as_double();
- unsigned int samples_left = (UINT32)(secs_left * (double)DACRATE_NTSC / (double)(ai_dacrate + 1));
+ unsigned int samples_left = (uint32_t)(secs_left * (double)DACRATE_NTSC / (double)(ai_dacrate + 1));
ret = samples_left * 4;
}
else
@@ -1380,43 +1380,43 @@ TIMER_CALLBACK_MEMBER(n64_periphs::pi_dma_callback)
void n64_periphs::pi_dma_tick()
{
bool update_bm = false;
- UINT16 *cart16;
- UINT16 *dram16 = (UINT16*)m_rdram;
+ uint16_t *cart16;
+ uint16_t *dram16 = (uint16_t*)m_rdram;
- UINT32 cart_addr = (pi_cart_addr & 0x0fffffff) >> 1;
- UINT32 dram_addr = (pi_dram_addr & 0x007fffff) >> 1;
+ uint32_t cart_addr = (pi_cart_addr & 0x0fffffff) >> 1;
+ uint32_t dram_addr = (pi_dram_addr & 0x007fffff) >> 1;
if(pi_cart_addr == 0x05000000 && dd_present)
{
update_bm = true;
- cart16 = (UINT16*)dd_buffer;
+ cart16 = (uint16_t*)dd_buffer;
cart_addr = (pi_cart_addr & 0x000003ff) >> 1;
}
else if(pi_cart_addr == 0x05000400 && dd_present)
{
update_bm = true;
- cart16 = (UINT16*)dd_sector_data;
+ cart16 = (uint16_t*)dd_sector_data;
cart_addr = (pi_cart_addr & 0x000000ff) >> 1;
}
else if((cart_addr & 0x04000000) == 0x04000000)
{
- cart16 = (UINT16*)m_sram;
+ cart16 = (uint16_t*)m_sram;
cart_addr = (pi_cart_addr & 0x0001ffff) >> 1;
}
else if((cart_addr & 0x03000000) == 0x03000000 && dd_present)
{
- cart16 = (UINT16*)machine().root_device().memregion("ddipl")->base();
+ cart16 = (uint16_t*)machine().root_device().memregion("ddipl")->base();
cart_addr = (pi_cart_addr & 0x003fffff) >> 1;
}
else
{
- cart16 = (UINT16*)machine().root_device().memregion("user2")->base();
+ cart16 = (uint16_t*)machine().root_device().memregion("user2")->base();
cart_addr &= ((machine().root_device().memregion("user2")->bytes() >> 1) - 1);
}
if(pi_dma_dir == 1)
{
- UINT32 dma_length = pi_wr_len + 1 + 1; //Round Up Nearest 2
+ uint32_t dma_length = pi_wr_len + 1 + 1; //Round Up Nearest 2
//logerror("PI Write, %X, %X, %X\n", pi_cart_addr, pi_dram_addr, pi_wr_len);
if (pi_dram_addr != 0xffffffff)
@@ -1432,7 +1432,7 @@ void n64_periphs::pi_dma_tick()
}
else
{
- UINT32 dma_length = pi_rd_len + 1 + 1; //Round Up Nearest 2
+ uint32_t dma_length = pi_rd_len + 1 + 1; //Round Up Nearest 2
//logerror("PI Read, %X, %X, %X\n", pi_cart_addr, pi_dram_addr, pi_rd_len);
if (pi_dram_addr != 0xffffffff)
@@ -1460,7 +1460,7 @@ void n64_periphs::pi_dma_tick()
READ32_MEMBER( n64_periphs::pi_reg_r )
{
- UINT32 ret = 0;
+ uint32_t ret = 0;
switch (offset)
{
case 0x00/4: // PI_DRAM_ADDR_REG
@@ -1659,10 +1659,10 @@ WRITE32_MEMBER( n64_periphs::ri_reg_w )
}
// Serial Interface
-UINT8 n64_periphs::calc_mempak_crc(UINT8 *buffer, int length)
+uint8_t n64_periphs::calc_mempak_crc(uint8_t *buffer, int length)
{
- UINT32 crc = 0;
- UINT32 temp2 = 0;
+ uint32_t crc = 0;
+ uint32_t temp2 = 0;
for(int i = 0; i <= length; i++)
{
@@ -1698,14 +1698,14 @@ UINT8 n64_periphs::calc_mempak_crc(UINT8 *buffer, int length)
return crc;
}
-static inline UINT8 convert_to_bcd(int val)
+static inline uint8_t convert_to_bcd(int val)
{
return ((val / 10) << 4) | (val % 10);
}
-int n64_periphs::pif_channel_handle_command(int channel, int slength, UINT8 *sdata, int rlength, UINT8 *rdata)
+int n64_periphs::pif_channel_handle_command(int channel, int slength, uint8_t *sdata, int rlength, uint8_t *rdata)
{
- UINT8 command = sdata[0];
+ uint8_t command = sdata[0];
switch (command)
{
@@ -1760,7 +1760,7 @@ int n64_periphs::pif_channel_handle_command(int channel, int slength, UINT8 *sda
case 0x01: // Read button values
{
- UINT16 buttons = 0;
+ uint16_t buttons = 0;
int x = 0, y = 0;
static const char *const portnames[] = { "P1", "P1_ANALOG_X", "P1_ANALOG_Y", "P1_MOUSE_X", "P1_MOUSE_Y",
"P2", "P2_ANALOG_X", "P2_ANALOG_Y", "P2_MOUSE_X", "P2_MOUSE_Y",
@@ -1792,14 +1792,14 @@ int n64_periphs::pif_channel_handle_command(int channel, int slength, UINT8 *sda
rdata[0] = (buttons >> 8) & 0xff;
rdata[1] = (buttons >> 0) & 0xff;
- rdata[2] = (UINT8)(x);
- rdata[3] = (UINT8)(y);
+ rdata[2] = (uint8_t)(x);
+ rdata[3] = (uint8_t)(y);
return 0;
case 2: //MOUSE
buttons = machine().root_device().ioport(portnames[(channel*5) + 0])->read();
- x = (INT16)machine().root_device().ioport(portnames[(channel*5) + 1 + 2])->read();// - 128;
- y = (INT16)machine().root_device().ioport(portnames[(channel*5) + 2 + 2])->read();// - 128;
+ x = (int16_t)machine().root_device().ioport(portnames[(channel*5) + 1 + 2])->read();// - 128;
+ y = (int16_t)machine().root_device().ioport(portnames[(channel*5) + 2 + 2])->read();// - 128;
int mouse_dx = 0;
int mouse_dy = 0;
@@ -1846,8 +1846,8 @@ int n64_periphs::pif_channel_handle_command(int channel, int slength, UINT8 *sda
rdata[0] = (buttons >> 8) & 0xff;
rdata[1] = (buttons >> 0) & 0xff;
- rdata[2] = (UINT8)(mouse_dx);
- rdata[3] = (UINT8)(mouse_dy);
+ rdata[2] = (uint8_t)(mouse_dx);
+ rdata[3] = (uint8_t)(mouse_dy);
return 0;
}
@@ -1859,7 +1859,7 @@ int n64_periphs::pif_channel_handle_command(int channel, int slength, UINT8 *sda
case 0x02: // Read mempak
{
- UINT32 address;
+ uint32_t address;
address = (sdata[1] << 8) | (sdata[2]);
address &= ~0x1f;
@@ -1889,7 +1889,7 @@ int n64_periphs::pif_channel_handle_command(int channel, int slength, UINT8 *sda
}
case 0x03: // Write mempak
{
- UINT32 address = (sdata[1] << 8) | (sdata[2]);
+ uint32_t address = (sdata[1] << 8) | (sdata[2]);
address &= ~0x1f;
if (address < 0x8000)
@@ -1917,7 +1917,7 @@ int n64_periphs::pif_channel_handle_command(int channel, int slength, UINT8 *sda
fatalerror("handle_pif: write EEPROM (bytes to send %d, bytes to receive %d)\n", slength, rlength);
}
- UINT16 block_offset = sdata[1] * 8;
+ uint16_t block_offset = sdata[1] * 8;
for(int i=0; i < 8; i++)
{
@@ -1939,7 +1939,7 @@ int n64_periphs::pif_channel_handle_command(int channel, int slength, UINT8 *sda
fatalerror("handle_pif: write EEPROM (bytes to send %d, bytes to receive %d)\n", slength, rlength);
}
- UINT16 block_offset = sdata[1] * 8;
+ uint16_t block_offset = sdata[1] * 8;
for(int i = 0; i < 8; i++)
{
@@ -1999,7 +1999,7 @@ int n64_periphs::pif_channel_handle_command(int channel, int slength, UINT8 *sda
void n64_periphs::handle_pif()
{
- UINT8 *ram = (UINT8*)pif_ram;
+ uint8_t *ram = (uint8_t*)pif_ram;
if(pif_cmd[0x3f] == 0x1) // only handle the command if the last byte is 1
{
int channel = 0;
@@ -2008,7 +2008,7 @@ void n64_periphs::handle_pif()
while(cmd_ptr < 0x3f && !end)
{
- INT8 bytes_to_send = (INT8)pif_cmd[cmd_ptr++];
+ int8_t bytes_to_send = (int8_t)pif_cmd[cmd_ptr++];
if (bytes_to_send == -2)
{
@@ -2022,10 +2022,10 @@ void n64_periphs::handle_pif()
{
if(bytes_to_send > 0 && (bytes_to_send & 0xc0) == 0)
{
- UINT8 recv_buffer[0x40];
- UINT8 send_buffer[0x40];
+ uint8_t recv_buffer[0x40];
+ uint8_t send_buffer[0x40];
- INT8 bytes_to_recv = pif_cmd[cmd_ptr++];
+ int8_t bytes_to_recv = pif_cmd[cmd_ptr++];
if (bytes_to_recv == -2)
{
@@ -2098,11 +2098,11 @@ void n64_periphs::pif_dma(int direction)
if (direction) // RDRAM -> PIF RAM
{
- UINT32 *src = m_rdram + ((si_dram_addr & 0x1fffffff) / 4);
+ uint32_t *src = m_rdram + ((si_dram_addr & 0x1fffffff) / 4);
for(int i = 0; i < 64; i+=4)
{
- UINT32 d = *src++;
+ uint32_t d = *src++;
pif_ram[i+0] = (d >> 24) & 0xff;
pif_ram[i+1] = (d >> 16) & 0xff;
pif_ram[i+2] = (d >> 8) & 0xff;
@@ -2115,11 +2115,11 @@ void n64_periphs::pif_dma(int direction)
{
handle_pif();
- UINT32 *dst = m_rdram + ((si_dram_addr & 0x1fffffff) / 4);
+ uint32_t *dst = m_rdram + ((si_dram_addr & 0x1fffffff) / 4);
for(int i = 0; i < 64; i+=4)
{
- UINT32 d = 0;
+ uint32_t d = 0;
d |= pif_ram[i+0] << 24;
d |= pif_ram[i+1] << 16;
d |= pif_ram[i+2] << 8;
@@ -2132,7 +2132,7 @@ void n64_periphs::pif_dma(int direction)
READ32_MEMBER( n64_periphs::si_reg_r )
{
- UINT32 ret = 0;
+ uint32_t ret = 0;
switch (offset)
{
//case 0x00/4: // SI_DRAM_ADDR_REG
@@ -2194,9 +2194,9 @@ WRITE32_MEMBER( n64_periphs::si_reg_w )
void n64_periphs::dd_set_zone_and_track_offset()
{
- UINT16 head = (dd_track_reg & 0x1000) >> 9; // Head * 8
- UINT16 track = dd_track_reg & 0xFFF;
- UINT16 tr_off = 0;
+ uint16_t head = (dd_track_reg & 0x1000) >> 9; // Head * 8
+ uint16_t track = dd_track_reg & 0xFFF;
+ uint16_t tr_off = 0;
if(track >= 0x425)
{
@@ -2336,9 +2336,9 @@ void n64_periphs::dd_update_bm()
void n64_periphs::dd_write_sector()
{
- UINT8* sector;
+ uint8_t* sector;
- sector = (UINT8*)machine().root_device().memregion("disk")->base();
+ sector = (uint8_t*)machine().root_device().memregion("disk")->base();
sector += dd_track_offset;
sector += dd_start_block * SECTORS_PER_BLOCK * ddZoneSecSize[dd_zone];
sector += (dd_current_reg - 1) * ddZoneSecSize[dd_zone];
@@ -2357,9 +2357,9 @@ void n64_periphs::dd_write_sector()
void n64_periphs::dd_read_sector()
{
- UINT8* sector;
+ uint8_t* sector;
- sector = (UINT8*)machine().root_device().memregion("disk")->base();
+ sector = (uint8_t*)machine().root_device().memregion("disk")->base();
sector += dd_track_offset;
sector += dd_start_block * SECTORS_PER_BLOCK * ddZoneSecSize[dd_zone];
sector += (dd_current_reg) * (dd_sector_size + 1);
@@ -2401,7 +2401,7 @@ READ32_MEMBER( n64_periphs::dd_reg_r )
offset -= 0x500/4;
- UINT32 ret = 0;
+ uint32_t ret = 0;
switch(offset)
{
case 0x00/4: // DD Data
@@ -2711,7 +2711,7 @@ void n64_state::n64_machine_stop()
device_image_interface *image = dynamic_cast<device_image_interface *>(periphs->m_nvram_image);
- UINT8 data[0x30800];
+ uint8_t data[0x30800];
if (m_sram != nullptr)
{
memset(data, 0, 0x20000);