diff options
author | 2019-10-27 02:16:50 +1100 | |
---|---|---|
committer | 2019-10-27 02:16:50 +1100 | |
commit | d80e7f95eb1ae276b86f8bd1dc818de1a1f887f7 (patch) | |
tree | f20c5a5de05b83ba8612ebea2dada155a1ad3439 | |
parent | 236c87cfea79d94062768a0d69923cf58fef4403 (diff) |
cpu/saturn: clean up a little (nw)
-rw-r--r-- | scripts/src/cpu.lua | 4 | ||||
-rw-r--r-- | src/devices/cpu/saturn/satops.ipp (renamed from src/devices/cpu/saturn/satops.hxx) | 559 | ||||
-rw-r--r-- | src/devices/cpu/saturn/sattable.ipp (renamed from src/devices/cpu/saturn/sattable.hxx) | 246 | ||||
-rw-r--r-- | src/devices/cpu/saturn/saturn.cpp | 25 | ||||
-rw-r--r-- | src/devices/cpu/saturn/saturn.h | 244 |
5 files changed, 524 insertions, 554 deletions
diff --git a/scripts/src/cpu.lua b/scripts/src/cpu.lua index ceb6fb6f27f..ecfa4c58882 100644 --- a/scripts/src/cpu.lua +++ b/scripts/src/cpu.lua @@ -2031,8 +2031,8 @@ if (CPUS["SATURN"]~=null) then files { MAME_DIR .. "src/devices/cpu/saturn/saturn.cpp", MAME_DIR .. "src/devices/cpu/saturn/saturn.h", - MAME_DIR .. "src/devices/cpu/saturn/satops.hxx", - MAME_DIR .. "src/devices/cpu/saturn/sattable.hxx", + MAME_DIR .. "src/devices/cpu/saturn/satops.ipp", + MAME_DIR .. "src/devices/cpu/saturn/sattable.ipp", } end diff --git a/src/devices/cpu/saturn/satops.hxx b/src/devices/cpu/saturn/satops.ipp index 8a1ecfe1c1d..87632ca859b 100644 --- a/src/devices/cpu/saturn/satops.hxx +++ b/src/devices/cpu/saturn/satops.ipp @@ -1,171 +1,158 @@ // license:BSD-3-Clause // copyright-holders:Peter Trauner,Antoine Mine -#define IRQ_ADDRESS 0xf +#ifndef MAME_CPU_SATURN_SATOPS_IPP +#define MAME_CPU_SATURN_SATOPS_IPP + +#pragma once + +#include "saturn.h" + #define saturn_assert(x) \ - do { if (!(x)) logerror("SATURN assertion failed: %s at %s:%i, pc=%05x\n", #x, __FILE__, __LINE__, m_pc); } while (0) + do { if (!(x)) logerror("SATURN assertion failed: %s at %s:%i, pc=%05x\n", #x, __FILE__, __LINE__, m_pc); } while (false) -int saturn_device::READ_OP() +inline int saturn_device::READ_OP() { - uint8_t data; m_icount-=3; - data=m_cache->read_byte(m_pc); + const uint8_t data=m_cache->read_byte(m_pc); saturn_assert(data<0x10); m_pc=(m_pc+1)&0xfffff; return data; } -int saturn_device::READ_OP_ARG() +inline int saturn_device::READ_OP_ARG() { - uint8_t data; m_icount-=3; - data=m_cache->read_byte(m_pc); + const uint8_t data=m_cache->read_byte(m_pc); saturn_assert(data<0x10); m_pc=(m_pc+1)&0xfffff; return data; } -int saturn_device::READ_OP_ARG8() +inline int saturn_device::READ_OP_ARG8() { - int n0=READ_OP_ARG(); - int n1=READ_OP_ARG(); + const int n0=READ_OP_ARG(); + const int n1=READ_OP_ARG(); return n0|(n1<<4); } -int8_t saturn_device::READ_OP_DIS8() +inline int8_t saturn_device::READ_OP_DIS8() { return (int8_t)READ_OP_ARG8(); } -int saturn_device::READ_OP_ARG12() +inline int saturn_device::READ_OP_ARG12() { - int n0=READ_OP_ARG(); - int n1=READ_OP_ARG(); - int n2=READ_OP_ARG(); + const int n0=READ_OP_ARG(); + const int n1=READ_OP_ARG(); + const int n2=READ_OP_ARG(); return n0|(n1<<4)|(n2<<8); } -int saturn_device::READ_OP_DIS12() +inline int saturn_device::READ_OP_DIS12() { int temp=READ_OP_ARG12(); if (temp&0x800) temp-=0x1000; return temp; } -int saturn_device::READ_OP_ARG16() +inline int saturn_device::READ_OP_ARG16() { - int n0=READ_OP_ARG(); - int n1=READ_OP_ARG(); - int n2=READ_OP_ARG(); - int n3=READ_OP_ARG(); + const int n0=READ_OP_ARG(); + const int n1=READ_OP_ARG(); + const int n2=READ_OP_ARG(); + const int n3=READ_OP_ARG(); return n0|(n1<<4)|(n2<<8)|(n3<<12); } -int16_t saturn_device::READ_OP_DIS16() +inline int16_t saturn_device::READ_OP_DIS16() { return (int16_t)READ_OP_ARG16(); } -int saturn_device::READ_OP_ARG20() +inline int saturn_device::READ_OP_ARG20() { - int n0=READ_OP_ARG(); - int n1=READ_OP_ARG(); - int n2=READ_OP_ARG(); - int n3=READ_OP_ARG(); - int n4=READ_OP_ARG(); + const int n0=READ_OP_ARG(); + const int n1=READ_OP_ARG(); + const int n2=READ_OP_ARG(); + const int n3=READ_OP_ARG(); + const int n4=READ_OP_ARG(); return n0|(n1<<4)|(n2<<8)|(n3<<12)|(n4<<16); } -int saturn_device::READ_NIBBLE(uint32_t adr) +inline int saturn_device::READ_NIBBLE(uint32_t adr) { - uint8_t data; m_icount-=3; - data=m_program->read_byte(adr&0xfffff); + const uint8_t data=m_program->read_byte(adr&0xfffff); saturn_assert(data<0x10); m_crc_func(adr&0xfffff, data, 0xffffffff); return data; } -int saturn_device::READ_8(uint32_t adr) +inline int saturn_device::READ_8(uint32_t adr) { - int n0=READ_NIBBLE(adr); - int n1=READ_NIBBLE(adr+1); + const int n0=READ_NIBBLE(adr); + const int n1=READ_NIBBLE(adr+1); return n0|(n1<<4); } -int saturn_device::READ_12(uint32_t adr) +inline int saturn_device::READ_12(uint32_t adr) { - int n0=READ_NIBBLE(adr); - int n1=READ_NIBBLE(adr+1); - int n2=READ_NIBBLE(adr+2); + const int n0=READ_NIBBLE(adr); + const int n1=READ_NIBBLE(adr+1); + const int n2=READ_NIBBLE(adr+2); return n0|(n1<<4)|(n2<<8); } -int saturn_device::READ_16(uint32_t adr) +inline int saturn_device::READ_16(uint32_t adr) { - int n0=READ_NIBBLE(adr); - int n1=READ_NIBBLE(adr+1); - int n2=READ_NIBBLE(adr+2); - int n3=READ_NIBBLE(adr+3); + const int n0=READ_NIBBLE(adr); + const int n1=READ_NIBBLE(adr+1); + const int n2=READ_NIBBLE(adr+2); + const int n3=READ_NIBBLE(adr+3); return n0|(n1<<4)|(n2<<8)|(n3<<12); } -int saturn_device::READ_20(uint32_t adr) +inline int saturn_device::READ_20(uint32_t adr) { - int n0=READ_NIBBLE(adr); - int n1=READ_NIBBLE(adr+1); - int n2=READ_NIBBLE(adr+2); - int n3=READ_NIBBLE(adr+3); - int n4=READ_NIBBLE(adr+4); + const int n0=READ_NIBBLE(adr); + const int n1=READ_NIBBLE(adr+1); + const int n2=READ_NIBBLE(adr+2); + const int n3=READ_NIBBLE(adr+3); + const int n4=READ_NIBBLE(adr+4); return n0|(n1<<4)|(n2<<8)|(n3<<12)|(n4<<16); } -void saturn_device::WRITE_NIBBLE(uint32_t adr, uint8_t nib) +inline void saturn_device::WRITE_NIBBLE(uint32_t adr, uint8_t nib) { m_icount-=3; saturn_assert(nib<0x10); m_program->write_byte(adr&0xfffff,nib); } -#define BEGIN_B 0 -#define COUNT_B 2 -#define BEGIN_X 0 -#define COUNT_X 3 -#define BEGIN_XS 2 -#define COUNT_XS 1 -#define BEGIN_A 0 -#define COUNT_A 5 -#define BEGIN_M 3 -#define COUNT_M 12 -#define BEGIN_S 15 -#define COUNT_S 1 -#define BEGIN_W 0 -#define COUNT_W 16 - - -int saturn_device::S64_READ_X(int r) +inline int saturn_device::S64_READ_X(int r) { return m_reg[r][0]|(m_reg[r][1]<<4)|(m_reg[r][2]<<8); } -int saturn_device::S64_READ_WORD(int r) +inline int saturn_device::S64_READ_WORD(int r) { return m_reg[r][0]|(m_reg[r][1]<<4)|(m_reg[r][2]<<8)|(m_reg[r][3]<<12); } -int saturn_device::S64_READ_A(int r) +inline int saturn_device::S64_READ_A(int r) { return m_reg[r][0]|(m_reg[r][1]<<4)|(m_reg[r][2]<<8)|(m_reg[r][3]<<12)|(m_reg[r][4]<<16); } -void saturn_device::S64_WRITE_X(int r, int v) +inline void saturn_device::S64_WRITE_X(int r, int v) { m_reg[r][0]=v&0xf; m_reg[r][1]=(v>>4)&0xf; m_reg[r][2]=(v>>8)&0xf; } -void saturn_device::S64_WRITE_WORD(int r, int v) +inline void saturn_device::S64_WRITE_WORD(int r, int v) { m_reg[r][0]=v&0xf; m_reg[r][1]=(v>>4)&0xf; @@ -173,7 +160,7 @@ void saturn_device::S64_WRITE_WORD(int r, int v) m_reg[r][3]=(v>>12)&0xf; } -void saturn_device::S64_WRITE_A(int r, int v) +inline void saturn_device::S64_WRITE_A(int r, int v) { m_reg[r][0]=v&0xf; m_reg[r][1]=(v>>4)&0xf; @@ -184,146 +171,140 @@ void saturn_device::S64_WRITE_A(int r, int v) - - -uint32_t saturn_device::saturn_pop() +inline uint32_t saturn_device::saturn_pop() { - uint32_t temp=m_rstk[0]; + const uint32_t temp=m_rstk[0]; memmove(m_rstk, m_rstk+1, sizeof(m_rstk)-sizeof(m_rstk[0])); m_rstk[7]=0; return temp; } -void saturn_device::saturn_push(uint32_t adr) +inline void saturn_device::saturn_push(uint32_t adr) { memmove(m_rstk+1, m_rstk, sizeof(m_rstk)-sizeof(m_rstk[0])); m_rstk[0]=adr; } -void saturn_device::saturn_interrupt_on() +inline void saturn_device::saturn_interrupt_on() { LOG("SATURN at %05x: INTON\n", m_pc-4); m_irq_enable=1; - if (m_irq_state) - { + if (m_irq_state) { LOG("SATURN set_irq_line(ASSERT)\n"); m_pending_irq=1; } } -void saturn_device::saturn_interrupt_off() +inline void saturn_device::saturn_interrupt_off() { LOG("SATURN at %05x: INTOFF\n", m_pc-4); m_irq_enable=0; } -void saturn_device::saturn_reset_interrupt() +inline void saturn_device::saturn_reset_interrupt() { LOG("SATURN at %05x: RSI\n", m_pc-5); m_rsi_func(ASSERT_LINE); } -void saturn_device::saturn_mem_reset() +inline void saturn_device::saturn_mem_reset() { m_reset_func(ASSERT_LINE); } -void saturn_device::saturn_mem_config() +inline void saturn_device::saturn_mem_config() { m_config_func(S64_READ_A(C)); } -void saturn_device::saturn_mem_unconfig() +inline void saturn_device::saturn_mem_unconfig() { m_unconfig_func(S64_READ_A(C)); } -void saturn_device::saturn_mem_id() +inline void saturn_device::saturn_mem_id() { - int id=0; - id = m_id_func(); + const int id = m_id_func(); S64_WRITE_A(C,id); m_monitor_id = id; } -void saturn_device::saturn_shutdown() +inline void saturn_device::saturn_shutdown() { m_sleeping=1; m_irq_enable=1; LOG("SATURN at %05x: SHUTDN\n", m_pc-3); } -void saturn_device::saturn_bus_command_b() +inline void saturn_device::saturn_bus_command_b() { - logerror( "SATURN '%s' at %05x: BUSCB opcode not handled\n", tag(), m_pc-4 ); + logerror("SATURN at %05x: BUSCB opcode not handled\n", m_pc-4); } -void saturn_device::saturn_bus_command_c() +inline void saturn_device::saturn_bus_command_c() { - logerror( "SATURN '%s' at %05x: BUSCC opcode not handled\n", tag(), m_pc-3 ); + logerror("SATURN at %05x: BUSCC opcode not handled\n", m_pc-3); } -void saturn_device::saturn_bus_command_d() +inline void saturn_device::saturn_bus_command_d() { - logerror( "SATURN '%s' at %05x: BUSCD opcode not handled\n", tag(), m_pc-4 ); + logerror("SATURN at %05x: BUSCD opcode not handled\n", m_pc-4); } -void saturn_device::saturn_serial_request() +inline void saturn_device::saturn_serial_request() { - logerror( "SATURN '%s' at %05x: SREQ? opcode not handled\n", tag(), m_pc-3 ); + logerror("SATURN at %05x: SREQ? opcode not handled\n", m_pc-3); } -void saturn_device::saturn_out_c() +inline void saturn_device::saturn_out_c() { m_out=S64_READ_X(C); m_out_func(m_out); } -void saturn_device::saturn_out_cs() +inline void saturn_device::saturn_out_cs() { m_out=(m_out&0xff0)|m_reg[C][0]; m_out_func(m_out); } -void saturn_device::saturn_in(int reg) +inline void saturn_device::saturn_in(int reg) { - int in = 0; saturn_assert(reg>=0 && reg<9); if (!(m_pc&1)) - logerror( "SATURN '%s' at %05x: reg=IN opcode at odd addresse\n", - tag(), m_pc-3 ); - in = m_in_func(); + logerror("SATURN at %05x: reg=IN opcode at odd addresse\n", m_pc-3); + const int in = m_in_func(); S64_WRITE_WORD(reg,in); m_monitor_in = in; } -/* st related */ -void saturn_device::saturn_clear_st() +// st related +inline void saturn_device::saturn_clear_st() { m_st&=0xf000; } -void saturn_device::saturn_st_to_c() +inline void saturn_device::saturn_st_to_c() { S64_WRITE_X(C,m_st); } -void saturn_device::saturn_c_to_st() +inline void saturn_device::saturn_c_to_st() { m_st=(m_st&0xf000)|(S64_READ_X(C)); } -void saturn_device::saturn_exchange_c_st() +inline void saturn_device::saturn_exchange_c_st() { - int t=m_st; + const int t=m_st; m_st=(t&0xf000)|(S64_READ_X(C)); S64_WRITE_X(C,t); } -void saturn_device::saturn_jump_after_test() +inline void saturn_device::saturn_jump_after_test() { - int adr=READ_OP_DIS8(); + const int adr=READ_OP_DIS8(); if (m_carry) { if (adr==0) { m_pc=saturn_pop(); @@ -332,107 +313,108 @@ void saturn_device::saturn_jump_after_test() } } } -void saturn_device::saturn_st_clear_bit() + +inline void saturn_device::saturn_st_clear_bit() { m_st &= ~(1<<(READ_OP_ARG())); } -void saturn_device::saturn_st_set_bit() +inline void saturn_device::saturn_st_set_bit() { m_st |= (1<<(READ_OP_ARG())); } -void saturn_device::saturn_st_jump_bit_clear() +inline void saturn_device::saturn_st_jump_bit_clear() { m_carry=!((m_st>>(READ_OP_ARG()))&1); saturn_jump_after_test(); } -void saturn_device::saturn_st_jump_bit_set() +inline void saturn_device::saturn_st_jump_bit_set() { m_carry=(m_st>>(READ_OP_ARG()))&1; saturn_jump_after_test(); } -void saturn_device::saturn_hst_clear_bits() +inline void saturn_device::saturn_hst_clear_bits() { m_hst&=~(READ_OP_ARG()); } -void saturn_device::saturn_hst_bits_cleared() +inline void saturn_device::saturn_hst_bits_cleared() { m_carry=!(m_hst&(READ_OP_ARG())); saturn_jump_after_test(); } -/* p related */ -void saturn_device::saturn_exchange_p() +// p related +inline void saturn_device::saturn_exchange_p() { - int nr=READ_OP_ARG(); - int t=m_p; + const int nr=READ_OP_ARG(); + const int t=m_p; m_p=m_reg[C][nr]; m_reg[C][nr]=t; } -void saturn_device::saturn_p_to_c() +inline void saturn_device::saturn_p_to_c() { - int nr=READ_OP_ARG(); + const int nr=READ_OP_ARG(); m_reg[C][nr]=m_p; } -void saturn_device::saturn_c_to_p() +inline void saturn_device::saturn_c_to_p() { - int nr=READ_OP_ARG(); + const int nr=READ_OP_ARG(); m_p=m_reg[C][nr]; } -void saturn_device::saturn_dec_p() +inline void saturn_device::saturn_dec_p() { m_carry=m_p==0; m_p=(m_p-1)&0xf; } -void saturn_device::saturn_inc_p() +inline void saturn_device::saturn_inc_p() { m_p=(m_p+1)&0xf; m_carry=m_p==0; } -void saturn_device::saturn_load_p() +inline void saturn_device::saturn_load_p() { m_p=READ_OP_ARG(); } -void saturn_device::saturn_p_equals() +inline void saturn_device::saturn_p_equals() { m_carry=m_p==(READ_OP_ARG()); saturn_jump_after_test(); } -void saturn_device::saturn_p_not_equals() +inline void saturn_device::saturn_p_not_equals() { m_carry=m_p!=(READ_OP_ARG()); saturn_jump_after_test(); } -void saturn_device::saturn_ca_p_1() +inline void saturn_device::saturn_ca_p_1() { - int a=(S64_READ_A(C))+1+m_p; + const int a=(S64_READ_A(C))+1+m_p; m_carry=a>=0x100000; S64_WRITE_A(C,a&0xfffff); } -void saturn_device::saturn_load_reg(int reg) +inline void saturn_device::saturn_load_reg(int reg) { int count=READ_OP_ARG(); int pos=m_p; saturn_assert(reg>=0 && reg<9); - for (; count>=0; count--, pos=(pos+1)&0xf ) { + for (; count>=0; count--, pos=(pos+1)&0xf) { m_reg[reg][pos]=READ_OP_ARG(); } } -void saturn_device::saturn_jump(int adr, int jump) +inline void saturn_device::saturn_jump(int adr, int jump) { saturn_assert(adr>=0 && adr<0x100000); if (jump) { @@ -441,137 +423,132 @@ void saturn_device::saturn_jump(int adr, int jump) } } -void saturn_device::saturn_call(int adr) +inline void saturn_device::saturn_call(int adr) { saturn_assert(adr>=0 && adr<0x100000); saturn_push(m_pc); m_pc=adr; -// m_icount-=10; + //m_icount-=10; } -void saturn_device::saturn_return(int yes) +inline void saturn_device::saturn_return(int yes) { if (yes) { m_pc=saturn_pop(); -// m_icount-=10; + //m_icount-=10; } } -void saturn_device::saturn_return_carry_set() +inline void saturn_device::saturn_return_carry_set() { m_pc=saturn_pop(); -// m_icount-=10; + //m_icount-=10; m_carry=1; } -void saturn_device::saturn_return_carry_clear() +inline void saturn_device::saturn_return_carry_clear() { m_pc=saturn_pop(); -// m_icount-=10; + //m_icount-=10; m_carry=0; } -void saturn_device::saturn_return_interrupt() +inline void saturn_device::saturn_return_interrupt() { - LOG("SATURN at %05x: RTI\n", tag(), m_pc-2); - m_in_irq=0; /* set to 1 when an IRQ is taken */ + LOG("SATURN at %05x: RTI\n", m_pc-2); + m_in_irq=0; // set to 1 when an IRQ is taken m_pc=saturn_pop(); -// m_icount-=10; + //m_icount-=10; } -void saturn_device::saturn_return_xm_set() +inline void saturn_device::saturn_return_xm_set() { m_pc=saturn_pop(); m_hst|=XM; -// m_icount-=10; + //m_icount-=10; } -void saturn_device::saturn_pop_c() +inline void saturn_device::saturn_pop_c() { S64_WRITE_A(C,saturn_pop()); } -void saturn_device::saturn_push_c() +inline void saturn_device::saturn_push_c() { saturn_push(S64_READ_A(C)); } -void saturn_device::saturn_indirect_jump(int reg) +inline void saturn_device::saturn_indirect_jump(int reg) { saturn_assert(reg>=0 && reg<9); m_pc=READ_20(S64_READ_A(reg)); } -void saturn_device::saturn_equals_zero(int reg, int begin, int count) +inline void saturn_device::saturn_equals_zero(int reg, int begin, int count) { - int i, t; saturn_assert(reg>=0 && reg<9); saturn_assert(begin>=0 && begin<16 && count>0 && begin+count<=16); m_carry=1; - for (i=0; i<count; i++) { - t=m_reg[reg][begin+i]; + for (int i=0; i<count; i++) { + const int t=m_reg[reg][begin+i]; if (t!=0) { m_carry=0; break; } m_icount-=2; } saturn_jump_after_test(); } -void saturn_device::saturn_equals(int reg, int begin, int count, int right) +inline void saturn_device::saturn_equals(int reg, int begin, int count, int right) { - int i, t,t2; saturn_assert(reg>=0 && reg<9); saturn_assert(right>=0 && right<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); m_carry=1; - for (i=0; i<count; i++) { - t=m_reg[reg][begin+i]; - t2=m_reg[right][begin+i]; + for (int i=0; i<count; i++) { + const int t=m_reg[reg][begin+i]; + const int t2=m_reg[right][begin+i]; if (t!=t2) { m_carry=0; break; } m_icount-=2; } saturn_jump_after_test(); } -void saturn_device::saturn_not_equals_zero(int reg, int begin, int count) +inline void saturn_device::saturn_not_equals_zero(int reg, int begin, int count) { - int i, t; saturn_assert(reg>=0 && reg<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); m_carry=0; - for (i=0; i<count; i++) { - t=m_reg[reg][begin+i]; + for (int i=0; i<count; i++) { + const int t=m_reg[reg][begin+i]; if (t!=0) { m_carry=1; break; } m_icount-=2; } saturn_jump_after_test(); } -void saturn_device::saturn_not_equals(int reg, int begin, int count, int right) +inline void saturn_device::saturn_not_equals(int reg, int begin, int count, int right) { - int i, t,t2; saturn_assert(reg>=0 && reg<9); saturn_assert(right>=0 && right<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); m_carry=0; - for (i=0; i<count; i++) { - t=m_reg[reg][begin+i]; - t2=m_reg[right][begin+i]; + for (int i=0; i<count; i++) { + const int t=m_reg[reg][begin+i]; + const int t2=m_reg[right][begin+i]; if (t!=t2) { m_carry=1; break; } m_icount-=2; } saturn_jump_after_test(); } -void saturn_device::saturn_greater(int reg, int begin, int count, int right) +inline void saturn_device::saturn_greater(int reg, int begin, int count, int right) { - int i, t,t2; saturn_assert(reg>=0 && reg<9); saturn_assert(right>=0 && right<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); m_carry=0; - for (i=count-1; i>=0; i--) { - t=m_reg[reg][begin+i]; - t2=m_reg[right][begin+i]; + for (int i=count-1; i>=0; i--) { + const int t=m_reg[reg][begin+i]; + const int t2=m_reg[right][begin+i]; if (t>t2) { m_carry=1; break; } if (t<t2) break; m_icount-=2; @@ -579,16 +556,15 @@ void saturn_device::saturn_greater(int reg, int begin, int count, int right) saturn_jump_after_test(); } -void saturn_device::saturn_greater_equals(int reg, int begin, int count, int right) +inline void saturn_device::saturn_greater_equals(int reg, int begin, int count, int right) { - int i, t,t2; saturn_assert(reg>=0 && reg<9); saturn_assert(right>=0 && right<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); m_carry=1; - for (i=count-1; i>=0; i--) { - t=m_reg[reg][begin+i]; - t2=m_reg[right][begin+i]; + for (int i=count-1; i>=0; i--) { + const int t=m_reg[reg][begin+i]; + const int t2=m_reg[right][begin+i]; if (t<t2) { m_carry=0; break; } if (t>t2) break; m_icount-=2; @@ -596,16 +572,15 @@ void saturn_device::saturn_greater_equals(int reg, int begin, int count, int rig saturn_jump_after_test(); } -void saturn_device::saturn_smaller_equals(int reg, int begin, int count, int right) +inline void saturn_device::saturn_smaller_equals(int reg, int begin, int count, int right) { - int i, t,t2; saturn_assert(reg>=0 && reg<9); saturn_assert(right>=0 && right<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); m_carry=1; - for (i=count-1; i>=0; i--) { - t=m_reg[reg][begin+i]; - t2=m_reg[right][begin+i]; + for (int i=count-1; i>=0; i--) { + const int t=m_reg[reg][begin+i]; + const int t2=m_reg[right][begin+i]; if (t>t2) { m_carry=0; break; } if (t<t2) break; m_icount-=2; @@ -613,16 +588,15 @@ void saturn_device::saturn_smaller_equals(int reg, int begin, int count, int rig saturn_jump_after_test(); } -void saturn_device::saturn_smaller(int reg, int begin, int count, int right) +inline void saturn_device::saturn_smaller(int reg, int begin, int count, int right) { - int i, t,t2; saturn_assert(reg>=0 && reg<9); saturn_assert(right>=0 && right<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); m_carry=0; - for (i=count-1; i>=0; i--) { - t=m_reg[reg][begin+i]; - t2=m_reg[right][begin+i]; + for (int i=count-1; i>=0; i--) { + const int t=m_reg[reg][begin+i]; + const int t2=m_reg[right][begin+i]; if (t<t2) { m_carry=1; break; } if (t>t2) break; m_icount-=2; @@ -630,37 +604,37 @@ void saturn_device::saturn_smaller(int reg, int begin, int count, int right) saturn_jump_after_test(); } -void saturn_device::saturn_jump_bit_clear(int reg) +inline void saturn_device::saturn_jump_bit_clear(int reg) { - int op=READ_OP_ARG(); + const int op=READ_OP_ARG(); saturn_assert(reg>=0 && reg<9); m_carry=!((m_reg[reg][op>>2]>>(op&3))&1); saturn_jump_after_test(); } -void saturn_device::saturn_jump_bit_set(int reg) +inline void saturn_device::saturn_jump_bit_set(int reg) { - int op=READ_OP_ARG(); + const int op=READ_OP_ARG(); saturn_assert(reg>=0 && reg<9); m_carry=(m_reg[reg][op>>2]>>(op&3))&1; saturn_jump_after_test(); } -void saturn_device::saturn_load_pc(int reg) +inline void saturn_device::saturn_load_pc(int reg) { saturn_assert(reg>=0 && reg<9); m_pc=S64_READ_A(reg); } -void saturn_device::saturn_store_pc(int reg) +inline void saturn_device::saturn_store_pc(int reg) { saturn_assert(reg>=0 && reg<9); S64_WRITE_A(reg,m_pc); } -void saturn_device::saturn_exchange_pc(int reg) +inline void saturn_device::saturn_exchange_pc(int reg) { - int temp=m_pc; + const int temp=m_pc; saturn_assert(reg>=0 && reg<9); m_pc=S64_READ_A(reg); S64_WRITE_A(reg, temp); @@ -669,7 +643,7 @@ void saturn_device::saturn_exchange_pc(int reg) /************************************************************************************* address register related *************************************************************************************/ -void saturn_device::saturn_load_adr(int reg, int nibbles) +inline void saturn_device::saturn_load_adr(int reg, int nibbles) { saturn_assert(reg>=0 && reg<2); saturn_assert(nibbles==2 || nibbles==4 || nibbles==5); @@ -686,102 +660,100 @@ void saturn_device::saturn_load_adr(int reg, int nibbles) } } -void saturn_device::saturn_add_adr(int reg) +inline void saturn_device::saturn_add_adr(int reg) { - int t=m_d[reg]+READ_OP_ARG()+1; + const int t=m_d[reg]+READ_OP_ARG()+1; saturn_assert(reg>=0 && reg<2); m_d[reg]=t&0xfffff; m_carry=t>=0x100000; } -void saturn_device::saturn_sub_adr(int reg) +inline void saturn_device::saturn_sub_adr(int reg) { - int t=m_d[reg]-READ_OP_ARG()-1; + const int t=m_d[reg]-READ_OP_ARG()-1; saturn_assert(reg>=0 && reg<2); m_d[reg]=t&0xfffff; m_carry=t<0; } -void saturn_device::saturn_adr_to_reg(int adr, int reg) +inline void saturn_device::saturn_adr_to_reg(int adr, int reg) { saturn_assert(reg>=0 && reg<9); saturn_assert(adr>=0 && adr<2); S64_WRITE_A(reg,m_d[adr]); } -void saturn_device::saturn_reg_to_adr(int reg, int adr) +inline void saturn_device::saturn_reg_to_adr(int reg, int adr) { saturn_assert(reg>=0 && reg<9); saturn_assert(adr>=0 && adr<2); m_d[adr]=S64_READ_A(reg); } -void saturn_device::saturn_adr_to_reg_word(int adr, int reg) +inline void saturn_device::saturn_adr_to_reg_word(int adr, int reg) { saturn_assert(reg>=0 && reg<9); saturn_assert(adr>=0 && adr<2); S64_WRITE_WORD(reg,m_d[adr]&0xffff); } -void saturn_device::saturn_reg_to_adr_word(int reg, int adr) +inline void saturn_device::saturn_reg_to_adr_word(int reg, int adr) { saturn_assert(reg>=0 && reg<9); saturn_assert(adr>=0 && adr<2); m_d[adr]=(m_d[adr]&0xf0000)|S64_READ_WORD(reg); } -void saturn_device::saturn_exchange_adr_reg(int adr, int reg) +inline void saturn_device::saturn_exchange_adr_reg(int adr, int reg) { - int temp=m_d[adr]; + const int temp=m_d[adr]; saturn_assert(reg>=0 && reg<9); saturn_assert(adr>=0 && adr<2); m_d[adr]=S64_READ_A(reg); S64_WRITE_A(reg,temp); } -void saturn_device::saturn_exchange_adr_reg_word(int adr, int reg) +inline void saturn_device::saturn_exchange_adr_reg_word(int adr, int reg) { - int temp=m_d[adr]&0xffff; + const int temp=m_d[adr]&0xffff; saturn_assert(reg>=0 && reg<9); saturn_assert(adr>=0 && adr<2); m_d[adr]=(m_d[adr]&0xf0000)|S64_READ_WORD(reg); S64_WRITE_WORD(reg,temp); } -void saturn_device::saturn_load_nibbles(int reg, int begin, int count, int adr) +inline void saturn_device::saturn_load_nibbles(int reg, int begin, int count, int adr) { - int i; saturn_assert(reg>=0 && reg<9); saturn_assert(adr>=0 && adr<2); saturn_assert(begin>=0 && count>0 && begin+count<=16); - for (i=0; i<count; i++) { + for (int i=0; i<count; i++) { m_reg[reg][begin+i]=READ_NIBBLE(m_d[adr]+i); m_icount-=2; } } -void saturn_device::saturn_store_nibbles(int reg, int begin, int count, int adr) +inline void saturn_device::saturn_store_nibbles(int reg, int begin, int count, int adr) { - int i; saturn_assert(reg>=0 && reg<9); saturn_assert(adr>=0 && adr<2); saturn_assert(begin>=0 && count>0 && begin+count<=16); - for (i=0; i<count; i++) { + for (int i=0; i<count; i++) { WRITE_NIBBLE((m_d[adr]+i)&0xfffff,m_reg[reg][begin+i]); m_icount-=2; } } -void saturn_device::saturn_clear_bit(int reg) +inline void saturn_device::saturn_clear_bit(int reg) { - int arg=READ_OP_ARG(); + const int arg=READ_OP_ARG(); saturn_assert(reg>=0 && reg<9); m_reg[reg][arg>>2]&=~(1<<(arg&3)); } -void saturn_device::saturn_set_bit(int reg) +inline void saturn_device::saturn_set_bit(int reg) { - int arg=READ_OP_ARG(); + const int arg=READ_OP_ARG(); saturn_assert(reg>=0 && reg<9); m_reg[reg][arg>>2]|=1<<(arg&3); } @@ -789,12 +761,11 @@ void saturn_device::saturn_set_bit(int reg) /**************************************************************************** clear opers ****************************************************************************/ -void saturn_device::saturn_clear(int reg, int begin, int count) +inline void saturn_device::saturn_clear(int reg, int begin, int count) { - int i; saturn_assert(reg>=0 && reg<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); - for (i=0; i<count; i++) { + for (int i=0; i<count; i++) { m_reg[reg][begin+i]=0; m_icount-=2; } @@ -803,15 +774,13 @@ void saturn_device::saturn_clear(int reg, int begin, int count) /**************************************************************************** exchange opers ****************************************************************************/ -void saturn_device::saturn_exchange(int left, int begin, int count, int right) +inline void saturn_device::saturn_exchange(int left, int begin, int count, int right) { - int i; - uint8_t temp; saturn_assert(left>=0 && left<9); saturn_assert(right>=0 && right<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); - for (i=0; i<count; i++) { - temp=m_reg[left][begin+i]; + for (int i=0; i<count; i++) { + const uint8_t temp=m_reg[left][begin+i]; m_reg[left][begin+i]=m_reg[right][begin+i]; m_reg[right][begin+i]=temp; m_icount-=2; @@ -821,13 +790,12 @@ void saturn_device::saturn_exchange(int left, int begin, int count, int right) /**************************************************************************** copy opers ****************************************************************************/ -void saturn_device::saturn_copy(int dest, int begin, int count, int src) +inline void saturn_device::saturn_copy(int dest, int begin, int count, int src) { - int i; saturn_assert(dest>=0 && dest<9); saturn_assert(src>=0 && src<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); - for (i=0; i<count; i++) { + for (int i=0; i<count; i++) { m_reg[dest][begin+i]=m_reg[src][begin+i]; m_icount-=2; } @@ -836,16 +804,15 @@ void saturn_device::saturn_copy(int dest, int begin, int count, int src) /**************************************************************************** add opers ****************************************************************************/ -void saturn_device::saturn_add(int reg, int begin, int count, int right) +inline void saturn_device::saturn_add(int reg, int begin, int count, int right) { - int i, t; - int base=m_decimal?10:16; + const int base=m_decimal?10:16; saturn_assert(reg>=0 && reg<9); saturn_assert(right>=0 && right<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); m_carry=0; - for (i=0; i<count; i++) { - t=m_reg[reg][begin+i]; + for (int i=0; i<count; i++) { + int t=m_reg[reg][begin+i]; t+=m_reg[right][begin+i]; t+=m_carry; if (t>=base) { @@ -859,15 +826,14 @@ void saturn_device::saturn_add(int reg, int begin, int count, int right) } } -void saturn_device::saturn_add_const(int reg, int begin, int count, uint8_t right) +inline void saturn_device::saturn_add_const(int reg, int begin, int count, uint8_t right) { - int i, t; - int base=m_decimal?10:16; + const int base=m_decimal?10:16; saturn_assert(reg>=0 && reg<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); saturn_assert(count>1 || !m_decimal); /* SATURN bug */ - for (i=0; i<count; i++) { - t=m_reg[reg][begin+i]; + for (int i=0; i<count; i++) { + int t=m_reg[reg][begin+i]; t+=(right&0xf); right>>=4; if (t>=base) { @@ -885,16 +851,15 @@ void saturn_device::saturn_add_const(int reg, int begin, int count, uint8_t righ /**************************************************************************** sub opers ****************************************************************************/ -void saturn_device::saturn_sub(int reg, int begin, int count, int right) +inline void saturn_device::saturn_sub(int reg, int begin, int count, int right) { - int i, t; - int base=m_decimal?10:16; + const int base=m_decimal?10:16; saturn_assert(reg>=0 && reg<9); saturn_assert(right>=0 && right<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); m_carry=0; - for (i=0; i<count; i++) { - t=m_reg[reg][begin+i]; + for (int i=0; i<count; i++) { + int t=m_reg[reg][begin+i]; t-=m_reg[right][begin+i]; t-=m_carry; if (t<0) { @@ -908,15 +873,14 @@ void saturn_device::saturn_sub(int reg, int begin, int count, int right) } } -void saturn_device::saturn_sub_const(int reg, int begin, int count, int right) +inline void saturn_device::saturn_sub_const(int reg, int begin, int count, int right) { - int i, t; - int base=m_decimal?10:16; + const int base=m_decimal?10:16; saturn_assert(reg>=0 && reg<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); - saturn_assert(count>1 || !m_decimal); /* SATURN bug */ - for (i=0; i<count; i++) { - t=m_reg[reg][begin+i]; + saturn_assert(count>1 || !m_decimal); // SATURN bug + for (int i=0; i<count; i++) { + int t=m_reg[reg][begin+i]; t-=(right&0xf); right>>=4; if (t<0) { @@ -934,16 +898,15 @@ void saturn_device::saturn_sub_const(int reg, int begin, int count, int right) /**************************************************************************** sub2 opers (a=b-a) ****************************************************************************/ -void saturn_device::saturn_sub2(int reg, int begin, int count, int right) +inline void saturn_device::saturn_sub2(int reg, int begin, int count, int right) { - int i, t; - int base=m_decimal?10:16; + const int base=m_decimal?10:16; saturn_assert(reg>=0 && reg<9); saturn_assert(right>=0 && right<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); m_carry=0; - for (i=0; i<count; i++) { - t=m_reg[right][begin+i]; + for (int i=0; i<count; i++) { + int t=m_reg[right][begin+i]; t-=m_reg[reg][begin+i]; t-=m_carry; if (t<0) { @@ -960,13 +923,13 @@ void saturn_device::saturn_sub2(int reg, int begin, int count, int right) /**************************************************************************** increment opers ****************************************************************************/ -void saturn_device::saturn_increment(int reg, int begin, int count) +inline void saturn_device::saturn_increment(int reg, int begin, int count) { - int i, t=0; - int base=m_decimal?10:16; + int t=0; + const int base=m_decimal?10:16; saturn_assert(reg>=0 && reg<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); - for (i=0; i<count; i++) { + for (int i=0; i<count; i++) { m_icount-=2; t=m_reg[reg][begin+i]; t++; @@ -979,13 +942,13 @@ void saturn_device::saturn_increment(int reg, int begin, int count) /**************************************************************************** decrement opers ****************************************************************************/ -void saturn_device::saturn_decrement(int reg, int begin, int count) +inline void saturn_device::saturn_decrement(int reg, int begin, int count) { - int i, t=0; - int base=m_decimal?10:16; + int t=0; + const int base=m_decimal?10:16; saturn_assert(reg>=0 && reg<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); - for (i=0; i<count; i++) { + for (int i=0; i<count; i++) { m_icount-=2; t=m_reg[reg][begin+i]; t--; @@ -998,14 +961,13 @@ void saturn_device::saturn_decrement(int reg, int begin, int count) /**************************************************************************** invert (1 complement) opers ****************************************************************************/ -void saturn_device::saturn_invert(int reg, int begin, int count) +inline void saturn_device::saturn_invert(int reg, int begin, int count) { - int i; - int max=m_decimal?9:15; + const int max=m_decimal?9:15; saturn_assert(reg>=0 && reg<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); m_carry=0; - for (i=0; i<count; i++) { + for (int i=0; i<count; i++) { m_reg[reg][begin+i]=(max-m_reg[reg][begin+i])&0xf; m_icount-=2; } @@ -1014,16 +976,15 @@ void saturn_device::saturn_invert(int reg, int begin, int count) /**************************************************************************** negate (2 complement) opers ****************************************************************************/ -void saturn_device::saturn_negate(int reg, int begin, int count) +inline void saturn_device::saturn_negate(int reg, int begin, int count) { - int i, n, c; - int max=m_decimal?9:15; + const int max=m_decimal?9:15; saturn_assert(reg>=0 && reg<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); - c=1; + int c=1; m_carry=0; - for (i=0; i<count; i++) { - n=m_reg[reg][begin+i]; + for (int i=0; i<count; i++) { + int n=m_reg[reg][begin+i]; if (n) m_carry=1; n=max+c-n; if (n>max) n-=max+1; @@ -1037,13 +998,12 @@ void saturn_device::saturn_negate(int reg, int begin, int count) /**************************************************************************** or opers ****************************************************************************/ -void saturn_device::saturn_or(int dest, int begin, int count, int src) +inline void saturn_device::saturn_or(int dest, int begin, int count, int src) { - int i; saturn_assert(dest>=0 && dest<9); saturn_assert(src>=0 && src<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); - for (i=0; i<count; i++) { + for (int i=0; i<count; i++) { m_reg[dest][begin+i]|=m_reg[src][begin+i]; m_icount-=2; } @@ -1052,13 +1012,12 @@ void saturn_device::saturn_or(int dest, int begin, int count, int src) /**************************************************************************** and opers ****************************************************************************/ -void saturn_device::saturn_and(int dest, int begin, int count, int src) +inline void saturn_device::saturn_and(int dest, int begin, int count, int src) { - int i; saturn_assert(dest>=0 && dest<9); saturn_assert(src>=0 && src<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); - for (i=0; i<count; i++) { + for (int i=0; i<count; i++) { m_reg[dest][begin+i]&=m_reg[src][begin+i]; m_icount-=2; } @@ -1067,13 +1026,12 @@ void saturn_device::saturn_and(int dest, int begin, int count, int src) /**************************************************************************** shift nibbles left opers ****************************************************************************/ -void saturn_device::saturn_shift_nibble_left(int reg, int begin, int count) +inline void saturn_device::saturn_shift_nibble_left(int reg, int begin, int count) { - int i; saturn_assert(reg>=0 && reg<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); if (m_reg[reg][begin+count-1]) m_hst|=SB; - for (i=count-1; i>=1; i--) { + for (int i=count-1; i>=1; i--) { m_reg[reg][begin+i]=m_reg[reg][begin+i-1]; m_icount-=2; } @@ -1084,13 +1042,12 @@ void saturn_device::saturn_shift_nibble_left(int reg, int begin, int count) /**************************************************************************** shift nibbles right opers ****************************************************************************/ -void saturn_device::saturn_shift_nibble_right(int reg, int begin, int count) +inline void saturn_device::saturn_shift_nibble_right(int reg, int begin, int count) { - int i; saturn_assert(reg>=0 && reg<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); if (m_reg[reg][begin]) m_hst|=SB; - for (i=1; i<count; i++) { + for (int i=1; i<count; i++) { m_reg[reg][begin+i-1]=m_reg[reg][begin+i]; m_icount-=2; } @@ -1102,11 +1059,11 @@ void saturn_device::saturn_shift_nibble_right(int reg, int begin, int count) /**************************************************************************** rotate nibbles left opers ****************************************************************************/ -void saturn_device::saturn_rotate_nibble_left_w(int reg) +inline void saturn_device::saturn_rotate_nibble_left_w(int reg) { - int i, x=m_reg[reg][15]; + const int x=m_reg[reg][15]; saturn_assert(reg>=0 && reg<9); - for (i=15; i>=1; i--) { + for (int i=15; i>=1; i--) { m_reg[reg][i]=m_reg[reg][i-1]; m_icount-=2; } @@ -1117,11 +1074,11 @@ void saturn_device::saturn_rotate_nibble_left_w(int reg) /**************************************************************************** rotate nibbles right opers ****************************************************************************/ -void saturn_device::saturn_rotate_nibble_right_w(int reg) +inline void saturn_device::saturn_rotate_nibble_right_w(int reg) { - int i, x=m_reg[reg][0]; + const int x=m_reg[reg][0]; saturn_assert(reg>=0 && reg<9); - for (i=1; i<16; i++) { + for (int i=1; i<16; i++) { m_reg[reg][i-1]=m_reg[reg][i]; m_icount-=2; } @@ -1134,13 +1091,13 @@ void saturn_device::saturn_rotate_nibble_right_w(int reg) /**************************************************************************** shift right opers ****************************************************************************/ -void saturn_device::saturn_shift_right(int reg, int begin, int count) +inline void saturn_device::saturn_shift_right(int reg, int begin, int count) { - int i, t, c=0; + int c=0; saturn_assert(reg>=0 && reg<9); saturn_assert(begin>=0 && count>0 && begin+count<=16); - for (i=count-1; i>=0; i--) { - t=m_reg[reg][begin+i]; + for (int i=count-1; i>=0; i--) { + int t=m_reg[reg][begin+i]; t|=(c<<4); c=t&1; m_reg[reg][begin+i]=t>>1; @@ -1149,3 +1106,5 @@ void saturn_device::saturn_shift_right(int reg, int begin, int count) if (c) m_hst|=SB; m_icount-=2; } + +#endif // MAME_CPU_SATURN_SATOPS_IPP diff --git a/src/devices/cpu/saturn/sattable.hxx b/src/devices/cpu/saturn/sattable.ipp index f8b5398973c..18b534da069 100644 --- a/src/devices/cpu/saturn/sattable.hxx +++ b/src/devices/cpu/saturn/sattable.ipp @@ -1,34 +1,46 @@ // license:BSD-3-Clause // copyright-holders:Peter Trauner,Antoine Mine +#define IRQ_ADDRESS 0xf + +#define BEGIN_B 0 +#define COUNT_B 2 +#define BEGIN_X 0 +#define COUNT_X 3 +#define BEGIN_XS 2 +#define COUNT_XS 1 +#define BEGIN_A 0 +#define COUNT_A 5 +#define BEGIN_M 3 +#define COUNT_M 12 +#define BEGIN_S 15 +#define COUNT_S 1 +#define BEGIN_W 0 +#define COUNT_W 16 + + static const int adr_a_begin[]={ --1, -1, BEGIN_XS, BEGIN_X, BEGIN_S, BEGIN_M, BEGIN_B, BEGIN_W, --1, -1, -1, -1, -1, -1, -1, -1, -}; + -1, -1, BEGIN_XS, BEGIN_X, BEGIN_S, BEGIN_M, BEGIN_B, BEGIN_W, + -1, -1, -1, -1, -1, -1, -1, -1, }; static const int adr_a_count[]={ --1, -1, COUNT_XS, COUNT_X, COUNT_S, COUNT_M, COUNT_B, COUNT_W, --1, -1, -1, -1, -1, -1, -1, -1, -}; + -1, -1, COUNT_XS, COUNT_X, COUNT_S, COUNT_M, COUNT_B, COUNT_W, + -1, -1, -1, -1, -1, -1, -1, -1, }; static const int adr_b_begin[]={ --1, -1, -1, -1, -1, -1, -1, -1, --1, -1, BEGIN_XS, BEGIN_X, BEGIN_S, BEGIN_M, BEGIN_B, BEGIN_W, -}; + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, BEGIN_XS, BEGIN_X, BEGIN_S, BEGIN_M, BEGIN_B, BEGIN_W, }; static const int adr_b_count[]={ --1, -1, -1, -1, -1, -1, -1, -1, --1, -1, COUNT_XS, COUNT_X, COUNT_S, COUNT_M, COUNT_B, COUNT_W, -}; + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, COUNT_XS, COUNT_X, COUNT_S, COUNT_M, COUNT_B, COUNT_W, }; static const int adr_af_begin[]={ --1, -1, BEGIN_XS, BEGIN_X, BEGIN_S, BEGIN_M, BEGIN_B, BEGIN_W, --1, -1, -1, -1, -1, -1, -1, BEGIN_A -}; + -1, -1, BEGIN_XS, BEGIN_X, BEGIN_S, BEGIN_M, BEGIN_B, BEGIN_W, + -1, -1, -1, -1, -1, -1, -1, BEGIN_A }; static const int adr_af_count[]={ --1, -1, COUNT_XS, COUNT_X, COUNT_S, COUNT_M, COUNT_B, COUNT_W, --1, -1, -1, -1, -1, -1, -1, COUNT_A -}; + -1, -1, COUNT_XS, COUNT_X, COUNT_S, COUNT_M, COUNT_B, COUNT_W, + -1, -1, -1, -1, -1, -1, -1, COUNT_A }; static const int reg_left[] ={A,B,C,D, B,C,A,C, I,I,I,I, I,I,I,I}; static const int reg_right[]={B,C,A,C, A,B,C,D, I,I,I,I, I,I,I,I}; @@ -37,28 +49,24 @@ static const int add_right[]={B,C,A,C, I,I,I,I, A,B,C,D, I,I,I,I}; static const int sub_left[] ={A,B,C,D, I,I,I,I, B,C,A,C, A,B,C,D}; static const int sub_right[]={B,C,A,C, I,I,I,I, A,B,C,D, B,C,A,C}; -void saturn_device::saturn_invalid3( int op1, int op2, int op3 ) +void saturn_device::saturn_invalid3(int op1, int op2, int op3) { - logerror( "SATURN '%s' invalid opcode %x%x%x at %05x\n", - tag(), op1, op2, op3, m_pc-3 ); + logerror("SATURN invalid opcode %x%x%x at %05x\n", op1, op2, op3, m_pc-3); } -void saturn_device::saturn_invalid4( int op1, int op2, int op3, int op4 ) +void saturn_device::saturn_invalid4(int op1, int op2, int op3, int op4) { - logerror( "SATURN '%s' invalid opcode %x%x%x%x at %05x\n", - tag(), op1, op2, op3, op4, m_pc-4 ); + logerror("SATURN invalid opcode %x%x%x%x at %05x\n", op1, op2, op3, op4, m_pc-4); } -void saturn_device::saturn_invalid5( int op1, int op2, int op3, int op4, int op5 ) +void saturn_device::saturn_invalid5(int op1, int op2, int op3, int op4, int op5) { - logerror( "SATURN '%s' invalid opcode %x%x%x%x%x at %05x\n", - tag(), op1, op2, op3, op4, op5, m_pc-5 ); + logerror("SATURN invalid opcode %x%x%x%x%x at %05x\n", op1, op2, op3, op4, op5, m_pc-5); } -void saturn_device::saturn_invalid6( int op1, int op2, int op3, int op4, int op5, int op6 ) +void saturn_device::saturn_invalid6(int op1, int op2, int op3, int op4, int op5, int op6) { - logerror( "SATURN '%s' invalid opcode %x%x%x%x%x%x at %05x\n", - tag(), op1, op2, op3, op4, op5, op6, m_pc-6 ); + logerror("SATURN invalid opcode %x%x%x%x%x%x at %05x\n", op1, op2, op3, op4, op5, op6, m_pc-6); } @@ -66,9 +74,9 @@ void saturn_device::saturn_instruction_0e() { int reg, adr; - switch(adr=READ_OP()) { + switch (adr=READ_OP()) { case 0: - switch(reg=READ_OP()){ + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: saturn_and(reg_left[reg], m_p, 1, reg_right[reg]); break; //A=A&B p @@ -78,7 +86,7 @@ void saturn_device::saturn_instruction_0e() } break; case 1: - switch(reg=READ_OP()){ + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3:case 4: case 5: case 6: case 7: saturn_and(reg_left[reg], 0, m_p+1, reg_right[reg]); break; //A=A&B wp @@ -88,7 +96,7 @@ void saturn_device::saturn_instruction_0e() } break; case 2: case 3: case 4: case 5: case 6: case 7: case 0xf: - switch(reg=READ_OP()){ + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: saturn_and(reg_left[reg], adr_af_begin[adr], adr_af_count[adr], reg_right[reg]); break; //A=A&B xs @@ -98,7 +106,7 @@ void saturn_device::saturn_instruction_0e() } break; default: - saturn_invalid3( 0, 0xe, adr ); + saturn_invalid3(0, 0xe, adr); break; } } @@ -117,7 +125,7 @@ void saturn_device::saturn_instruction_1() saturn_copy(R0+(reg&7), BEGIN_W, COUNT_W, C); break; // r0=c w default: - saturn_invalid3( 1, adr, reg ); + saturn_invalid3(1, adr, reg); break; } break; @@ -130,7 +138,7 @@ void saturn_device::saturn_instruction_1() saturn_copy(C, BEGIN_W, COUNT_W, R0+(reg&7)); break; // c=r0 w default: - saturn_invalid3( 1, adr, reg ); + saturn_invalid3(1, adr, reg); break; } break; @@ -143,7 +151,7 @@ void saturn_device::saturn_instruction_1() saturn_exchange(C, BEGIN_W, COUNT_W, R0+(reg&7)); break; // cr0ex w default: - saturn_invalid3( 2, adr, reg ); + saturn_invalid3(2, adr, reg); break; } break; @@ -201,7 +209,7 @@ void saturn_device::saturn_instruction_1() saturn_store_nibbles(oper&4?C:A,adr_a_begin[adr],adr_a_count[adr],oper&1); break; default: - saturn_invalid4( 1, 5, oper, adr ); + saturn_invalid4(1, 5, oper, adr); break; } break; @@ -217,7 +225,7 @@ void saturn_device::saturn_instruction_1() saturn_load_nibbles(oper&4?C:A,adr_a_begin[adr],adr_a_count[adr],oper&1); break; default: - saturn_invalid4( 1, 5, oper, adr ); + saturn_invalid4(1, 5, oper, adr); break; } break; @@ -247,7 +255,7 @@ void saturn_device::saturn_instruction_1() void saturn_device::saturn_instruction_80() { int op; - switch(READ_OP()) { + switch (READ_OP()) { case 0: saturn_out_cs();break; case 1: saturn_out_c();break; case 2: saturn_in(A);break; @@ -257,12 +265,12 @@ void saturn_device::saturn_instruction_80() case 6: saturn_mem_id();break; case 7: saturn_shutdown();break; case 8: - switch(READ_OP()) { + switch (READ_OP()) { case 0: saturn_interrupt_on();break; case 1: - switch(op=READ_OP()) { + switch (op=READ_OP()) { case 0: saturn_reset_interrupt();break; - default: saturn_invalid5( 8, 0, 8, 1, op ); break; + default: saturn_invalid5(8, 0, 8, 1, op); break; } break; case 2: saturn_load_reg(A);break; //la @@ -294,11 +302,11 @@ void saturn_device::saturn_instruction_80() void saturn_device::saturn_instruction_81a() { int reg, adr,op; - switch(adr=READ_OP()) { + switch (adr=READ_OP()) { case 0: - switch(op=READ_OP()) { + switch (op=READ_OP()) { case 0: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: case 4: saturn_copy(R0+reg,m_p,1,A); break; //r0=a p @@ -306,12 +314,12 @@ void saturn_device::saturn_instruction_81a() saturn_copy(R0+(reg&7),m_p,1,C); break; //r0=c p default: - saturn_invalid6( 8, 1, 0xa, adr, op, reg); + saturn_invalid6(8, 1, 0xa, adr, op, reg); break; } break; case 1: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: case 4: saturn_copy(A,m_p,1,R0+reg); break; //a=r0 p @@ -319,7 +327,7 @@ void saturn_device::saturn_instruction_81a() saturn_copy(C,m_p,1,R0+(reg&7)); break; //c=r0 p default: - saturn_invalid6( 8, 1, 0xa, adr, op, reg); + saturn_invalid6(8, 1, 0xa, adr, op, reg); break; } break; @@ -332,19 +340,19 @@ void saturn_device::saturn_instruction_81a() saturn_exchange(C, m_p,1,R0+(reg&7)); break; // cr0ex p default: - saturn_invalid6( 8, 1, 0xa, adr, op, reg); + saturn_invalid6(8, 1, 0xa, adr, op, reg); break; } break; default: - saturn_invalid5( 8, 1, 0xa, adr, op ); + saturn_invalid5(8, 1, 0xa, adr, op); break; } break; case 1: - switch(op=READ_OP()) { + switch (op=READ_OP()) { case 0: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: case 4: saturn_copy(R0+reg,0,m_p+1,A); break; //r0=a wp @@ -352,12 +360,12 @@ void saturn_device::saturn_instruction_81a() saturn_copy(R0+(reg&7),0,m_p+1,C); break; //r0=c wp default: - saturn_invalid6( 8, 1, 0xa, adr, op, reg); + saturn_invalid6(8, 1, 0xa, adr, op, reg); break; } break; case 1: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: case 4: saturn_copy(A,0,m_p+1,R0+reg); break; //a=r0 wp @@ -365,7 +373,7 @@ void saturn_device::saturn_instruction_81a() saturn_copy(C,0,m_p+1,R0+(reg&7)); break; //c=r0 wp default: - saturn_invalid6( 8, 1, 0xa, adr, op, reg); + saturn_invalid6(8, 1, 0xa, adr, op, reg); break; } break; @@ -378,19 +386,19 @@ void saturn_device::saturn_instruction_81a() saturn_exchange(C, 0, m_p+1, R0+(reg&7)); break; // cr0ex wp default: - saturn_invalid6( 8, 1, 0xa, adr, op, reg); + saturn_invalid6(8, 1, 0xa, adr, op, reg); break; } break; default: - saturn_invalid5( 8, 1, 0xa, adr, op ); + saturn_invalid5(8, 1, 0xa, adr, op); break; } break; case 2: case 3: case 4: case 5: case 6: case 7: case 0xf: - switch(op=READ_OP()) { + switch (op=READ_OP()) { case 0: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: case 4: saturn_copy(R0+reg,adr_af_begin[adr],adr_af_count[adr],A); break; //r0=a xs @@ -398,12 +406,12 @@ void saturn_device::saturn_instruction_81a() saturn_copy(R0+(reg&7),adr_af_begin[adr], adr_af_count[adr],C); break; //r0=c xs default: - saturn_invalid6( 8, 1, 0xa, adr, op, reg); + saturn_invalid6(8, 1, 0xa, adr, op, reg); break; } break; case 1: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: case 4: saturn_copy(A,adr_af_begin[adr],adr_af_count[adr],R0+reg); break; //a=r0 xs @@ -411,7 +419,7 @@ void saturn_device::saturn_instruction_81a() saturn_copy(C,adr_af_begin[adr],adr_af_count[adr],R0+(reg&7)); break; //c=r0 xs default: - saturn_invalid6( 8, 1, 0xa, adr, op, reg); + saturn_invalid6(8, 1, 0xa, adr, op, reg); break; } break; @@ -424,17 +432,17 @@ void saturn_device::saturn_instruction_81a() saturn_exchange(C, adr_af_begin[adr], adr_af_count[adr], R0+(reg&7)); break; // cr0ex xs default: - saturn_invalid6( 8, 1, 0xa, adr, op, reg); + saturn_invalid6(8, 1, 0xa, adr, op, reg); break; } break; default: - saturn_invalid5( 8, 1, 0xa, adr, op ); + saturn_invalid5(8, 1, 0xa, adr, op); break; } break; default: - saturn_invalid4( 8, 1, 0xa, adr ); + saturn_invalid4(8, 1, 0xa, adr); break; } } @@ -443,13 +451,13 @@ void saturn_device::saturn_instruction_81() { int reg, adr; - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: saturn_rotate_nibble_left_w(A+reg); break; // aslc w case 4: case 5: case 6: case 7: saturn_rotate_nibble_right_w(A+(reg&3)); break; // asrc w case 8: - switch(adr=READ_OP()) { + switch (adr=READ_OP()) { case 0: switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: @@ -459,7 +467,7 @@ void saturn_device::saturn_instruction_81() saturn_sub_const(A+(reg&3), m_p, 1, READ_OP()+1); break; default: - saturn_invalid5( 8, 1, 8, adr, reg ); + saturn_invalid5(8, 1, 8, adr, reg); break; } break; @@ -472,7 +480,7 @@ void saturn_device::saturn_instruction_81() saturn_sub_const(A+(reg&3), 0, m_p+1, READ_OP()+1); break; default: - saturn_invalid5( 8, 1, 8, adr, reg ); + saturn_invalid5(8, 1, 8, adr, reg); break; } break; @@ -485,49 +493,49 @@ void saturn_device::saturn_instruction_81() saturn_sub_const(A+(reg&3), adr_af_begin[adr], adr_af_count[adr], READ_OP()+1); break; default: - saturn_invalid5( 8, 1, 8, adr, reg ); + saturn_invalid5(8, 1, 8, adr, reg); break; } break; default: - saturn_invalid4( 8, 1, 8, adr ); + saturn_invalid4(8, 1, 8, adr); break; } break; case 9: - switch(adr=READ_OP()) { + switch (adr=READ_OP()) { case 0: - switch(reg=READ_OP()){ + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: saturn_shift_right(A+reg,m_p,1); break; // asrb p default: - saturn_invalid5( 8, 1, 9, adr, reg ); + saturn_invalid5(8, 1, 9, adr, reg); break; } break; case 1: - switch(reg=READ_OP()){ + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: saturn_shift_right(A+reg, 0,m_p+1); break; // asrb wp default: - saturn_invalid5( 8, 1, 9, adr, reg ); + saturn_invalid5(8, 1, 9, adr, reg); break; } break; case 2: case 3: case 4: case 5: case 6: case 7: case 0xf: - switch(reg=READ_OP()){ + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: saturn_shift_right(A+reg, adr_af_begin[adr], adr_af_count[adr]); break; // asrb xs default: - saturn_invalid5( 8, 1, 9, adr, reg ); + saturn_invalid5(8, 1, 9, adr, reg); break; } break; default: - saturn_invalid4( 8, 1, 9, adr ); + saturn_invalid4(8, 1, 9, adr); break; } break; @@ -535,14 +543,14 @@ void saturn_device::saturn_instruction_81() saturn_instruction_81a(); break; case 0xb: - switch(adr=READ_OP()) { + switch (adr=READ_OP()) { case 2: saturn_load_pc(A);break; case 3: saturn_load_pc(C);break; case 4: saturn_store_pc(A);break; case 5: saturn_store_pc(C);break; case 6: saturn_exchange_pc(A);break; case 7: saturn_exchange_pc(C);break; - default: saturn_invalid4( 8, 1, reg, adr ); break; + default: saturn_invalid4(8, 1, reg, adr); break; } break; case 0xc: case 0xd: case 0xe: case 0xf: @@ -555,7 +563,7 @@ void saturn_device::saturn_instruction_8() { int oper, adr; - switch(READ_OP()) { + switch (READ_OP()) { case 0: saturn_instruction_80(); break; @@ -571,7 +579,7 @@ void saturn_device::saturn_instruction_8() case 8: saturn_p_not_equals(); break; case 9: saturn_p_equals(); break; case 0xa: - switch(oper=READ_OP()) { + switch (oper=READ_OP()) { case 0: case 1: case 2: case 3: saturn_equals(reg_left[oper&3] , BEGIN_A, COUNT_A, reg_right[oper&3]); break; @@ -587,7 +595,7 @@ void saturn_device::saturn_instruction_8() } break; case 0xb: - switch(oper=READ_OP()) { + switch (oper=READ_OP()) { case 0: case 1: case 2: case 3: saturn_greater(reg_left[oper&3] , BEGIN_A, COUNT_A, reg_right[oper&3]); break; @@ -625,9 +633,9 @@ void saturn_device::saturn_instruction_9() { int adr, oper; - switch(adr=READ_OP()) { + switch (adr=READ_OP()) { case 0: - switch(oper=READ_OP()) { + switch (oper=READ_OP()) { case 0: case 1: case 2: case 3: saturn_equals(reg_left[oper&3] , m_p, 1, reg_right[oper&3]); break; @@ -643,7 +651,7 @@ void saturn_device::saturn_instruction_9() } break; case 1: - switch(oper=READ_OP()) { + switch (oper=READ_OP()) { case 0: case 1: case 2: case 3: saturn_equals(reg_left[oper&3] , 0, m_p+1, reg_right[oper&3]); break; @@ -659,7 +667,7 @@ void saturn_device::saturn_instruction_9() } break; case 2: case 3: case 4: case 5: case 6: case 7: - switch(oper=READ_OP()) { + switch (oper=READ_OP()) { case 0: case 1: case 2: case 3: saturn_equals(reg_left[oper&3] ,adr_a_begin[adr], adr_a_count[adr], reg_right[oper&3]); break; @@ -675,7 +683,7 @@ void saturn_device::saturn_instruction_9() } break; case 8: - switch(oper=READ_OP()) { + switch (oper=READ_OP()) { case 0: case 1: case 2: case 3: saturn_greater(reg_left[oper&3] ,m_p, 1, reg_right[oper&3]); break; @@ -691,7 +699,7 @@ void saturn_device::saturn_instruction_9() } break; case 9: - switch(oper=READ_OP()) { + switch (oper=READ_OP()) { case 0: case 1: case 2: case 3: saturn_greater(reg_left[oper&3] , 0, m_p+1, reg_right[oper&3]); break; @@ -707,7 +715,7 @@ void saturn_device::saturn_instruction_9() } break; case 0xa: case 0xb: case 0xc: case 0xd: case 0xe: case 0xf: - switch(oper=READ_OP()) { + switch (oper=READ_OP()) { case 0: case 1: case 2: case 3: saturn_greater(reg_left[oper&3] ,adr_b_begin[adr], adr_b_count[adr], reg_right[oper&3]); break; @@ -729,7 +737,7 @@ void saturn_device::saturn_instruction_a() { int reg, adr; - switch(adr=READ_OP()) { + switch (adr=READ_OP()) { case 0: switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: @@ -773,7 +781,7 @@ void saturn_device::saturn_instruction_a() } break; case 8: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: saturn_clear(A+reg, m_p,1); break; // a=0 p @@ -787,7 +795,7 @@ void saturn_device::saturn_instruction_a() } break; case 9: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: saturn_clear(A+reg,0,m_p+1); break; // a=0 wp @@ -801,7 +809,7 @@ void saturn_device::saturn_instruction_a() } break; case 0xa: case 0xb: case 0xc: case 0xd: case 0xe: case 0xf: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: saturn_clear(A+reg, adr_b_begin[adr], adr_b_count[adr]); break; // a=0 xs @@ -821,9 +829,9 @@ void saturn_device::saturn_instruction_b() { int adr, reg; - switch(adr=READ_OP()) { + switch (adr=READ_OP()) { case 0: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: case 8: case 9: case 0xa: case 0xb: saturn_sub(sub_left[reg], m_p, 1, sub_right[reg]); @@ -836,7 +844,7 @@ void saturn_device::saturn_instruction_b() } break; case 1: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: case 8: case 9: case 0xa: case 0xb: saturn_sub(sub_left[reg], 0, m_p+1, sub_right[reg]); @@ -849,7 +857,7 @@ void saturn_device::saturn_instruction_b() } break; case 2: case 3: case 4: case 5: case 6: case 7: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: case 8: case 9: case 0xa: case 0xb: saturn_sub(sub_left[reg], adr_a_begin[adr], adr_a_count[adr], sub_right[reg]); @@ -864,7 +872,7 @@ void saturn_device::saturn_instruction_b() } break; case 8: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: saturn_shift_nibble_left(A+reg, m_p, 1); break; // asl p case 4: case 5: case 6: case 7: @@ -876,7 +884,7 @@ void saturn_device::saturn_instruction_b() } break; case 9: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: saturn_shift_nibble_left(A+reg,0,m_p+1); break; // asl wp case 4: case 5: case 6: case 7: @@ -888,7 +896,7 @@ void saturn_device::saturn_instruction_b() } break; case 0xa: case 0xb: case 0xc: case 0xd: case 0xe: case 0xf: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: saturn_shift_nibble_left(A+reg,adr_b_begin[adr], adr_b_count[adr]); break; @@ -911,19 +919,19 @@ void saturn_device::saturn_instruction() { int reg, adr; - switch(READ_OP()) { + switch (READ_OP()) { case 0: - switch(READ_OP()) { - case 0: saturn_return_xm_set();break; - case 1: saturn_return(1);break; - case 2: saturn_return_carry_set();break; - case 3: saturn_return_carry_clear();break; - case 4: saturn_sethex();break; - case 5: saturn_setdec();break; - case 6: saturn_push_c();break; - case 7: saturn_pop_c();break; - case 8: saturn_clear_st();break; - case 9: saturn_st_to_c();break; + switch (READ_OP()) { + case 0x0: saturn_return_xm_set();break; + case 0x1: saturn_return(1);break; + case 0x2: saturn_return_carry_set();break; + case 0x3: saturn_return_carry_clear();break; + case 0x4: saturn_sethex();break; + case 0x5: saturn_setdec();break; + case 0x6: saturn_push_c();break; + case 0x7: saturn_pop_c();break; + case 0x8: saturn_clear_st();break; + case 0x9: saturn_st_to_c();break; case 0xa: saturn_c_to_st();break; case 0xb: saturn_exchange_c_st();break; case 0xc: saturn_inc_p();break; @@ -992,7 +1000,7 @@ void saturn_device::saturn_instruction() } break; case 0xd: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: saturn_clear(A+reg, BEGIN_A, COUNT_A); break; // a=0 a @@ -1006,7 +1014,7 @@ void saturn_device::saturn_instruction() } break; case 0xe: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: case 8: case 9: case 0xa: case 0xb: saturn_sub(sub_left[reg], BEGIN_A, COUNT_A, sub_right[reg]); @@ -1020,7 +1028,7 @@ void saturn_device::saturn_instruction() } break; case 0xf: - switch(reg=READ_OP()) { + switch (reg=READ_OP()) { case 0: case 1: case 2: case 3: saturn_shift_nibble_left(A+reg,BEGIN_A, COUNT_A); break; // asl a diff --git a/src/devices/cpu/saturn/saturn.cpp b/src/devices/cpu/saturn/saturn.cpp index 14b05baf3dd..004c0c09994 100644 --- a/src/devices/cpu/saturn/saturn.cpp +++ b/src/devices/cpu/saturn/saturn.cpp @@ -15,6 +15,10 @@ #include "debugger.h" +//#define VERBOSE 1 +#include "logmacro.h" + + #define R0 0 #define R1 1 #define R2 2 @@ -27,10 +31,6 @@ #define I 9 // invalid -//#define VERBOSE 1 -#include "logmacro.h" - - // Hardware status bits #define XM 1 // external Modules missing #define SB 2 // Sticky bit @@ -52,16 +52,19 @@ saturn_device::saturn_device(const machine_config &mconfig, const char *tag, dev , m_unconfig_func(*this) , m_id_func(*this) , m_crc_func(*this) - , m_rsi_func(*this), m_pc(0), m_oldpc(0), m_p(0), m_out(0), m_carry(0), m_decimal(0), m_st(0), m_hst(0), m_nmi_state(0), m_irq_state(0), m_irq_enable(0), m_in_irq(0), - m_pending_irq(0), m_sleeping(0), m_monitor_id(0), m_monitor_in(0), m_program(nullptr), m_cache(nullptr), m_icount(0), m_debugger_temp(0) + , m_rsi_func(*this) + , m_pc(0), m_oldpc(0), m_p(0), m_out(0), m_carry(0), m_decimal(0), m_st(0), m_hst(0) + , m_nmi_state(0), m_irq_state(0), m_irq_enable(0), m_in_irq(0), m_pending_irq(0) + , m_sleeping(0), m_monitor_id(0), m_monitor_in(0) + , m_program(nullptr), m_cache(nullptr) + , m_icount(0) + , m_debugger_temp(0) { } device_memory_interface::space_config_vector saturn_device::memory_space_config() const { - return space_config_vector { - std::make_pair(AS_PROGRAM, &m_program_config) - }; + return space_config_vector{ std::make_pair(AS_PROGRAM, &m_program_config) }; } bool saturn_device::get_nonstandard_mnemonics_mode() const @@ -81,8 +84,8 @@ std::unique_ptr<util::disasm_interface> saturn_device::create_disassembler() * include the opcode macros, functions and tables ***************************************************************/ -#include "satops.hxx" -#include "sattable.hxx" +#include "satops.ipp" +#include "sattable.ipp" /***************************************************************************** * diff --git a/src/devices/cpu/saturn/saturn.h b/src/devices/cpu/saturn/saturn.h index a476d6ce677..bb520181450 100644 --- a/src/devices/cpu/saturn/saturn.h +++ b/src/devices/cpu/saturn/saturn.h @@ -114,8 +114,8 @@ private: devcb_write32 m_crc_func; devcb_write_line m_rsi_func; -// 64 bit, unpacked (one nibble per byte) -typedef uint8_t Saturn64[16]; + // 64 bit, unpacked (one nibble per byte) + typedef uint8_t Saturn64[16]; Saturn64 m_reg[9]; //r0,r1,r2,r3,r4,a,b,c,d @@ -146,126 +146,126 @@ typedef uint8_t Saturn64[16]; void IntReg64(Saturn64 r, int64_t d); int64_t Reg64Int(Saturn64 r); - inline int READ_OP(); - inline int READ_OP_ARG(); - inline int READ_OP_ARG8(); - inline int8_t READ_OP_DIS8(); - inline int READ_OP_ARG12(); - inline int READ_OP_DIS12(); - inline int READ_OP_ARG16(); - inline int16_t READ_OP_DIS16(); - inline int READ_OP_ARG20(); - inline int READ_NIBBLE(uint32_t adr); - inline int READ_8(uint32_t adr); - inline int READ_12(uint32_t adr); - inline int READ_16(uint32_t adr); - inline int READ_20(uint32_t adr); - inline void WRITE_NIBBLE(uint32_t adr, uint8_t nib); - inline int S64_READ_X(int r); - inline int S64_READ_WORD(int r); - inline int S64_READ_A(int r); - inline void S64_WRITE_X(int r, int v); - inline void S64_WRITE_WORD(int r, int v); - inline void S64_WRITE_A(int r, int v); - inline uint32_t saturn_pop(); - inline void saturn_push(uint32_t adr); - inline void saturn_interrupt_on(); - inline void saturn_interrupt_off(); - inline void saturn_reset_interrupt(); - inline void saturn_mem_reset(); - inline void saturn_mem_config(); - inline void saturn_mem_unconfig(); - inline void saturn_mem_id(); - inline void saturn_shutdown(); - inline void saturn_bus_command_b(); - inline void saturn_bus_command_c(); - inline void saturn_bus_command_d(); - inline void saturn_serial_request(); - inline void saturn_out_c(); - inline void saturn_out_cs(); - inline void saturn_in(int reg); - inline void saturn_sethex() { m_decimal=0; } - inline void saturn_setdec() { m_decimal=1; } - inline void saturn_clear_st(); - inline void saturn_st_to_c(); - inline void saturn_c_to_st(); - inline void saturn_exchange_c_st(); - inline void saturn_jump_after_test(); - inline void saturn_st_clear_bit(); - inline void saturn_st_set_bit(); - inline void saturn_st_jump_bit_clear(); - inline void saturn_st_jump_bit_set(); - inline void saturn_hst_clear_bits(); - inline void saturn_hst_bits_cleared(); - inline void saturn_exchange_p(); - inline void saturn_p_to_c(); - inline void saturn_c_to_p(); - inline void saturn_dec_p(); - inline void saturn_inc_p(); - inline void saturn_load_p(); - inline void saturn_p_equals(); - inline void saturn_p_not_equals(); - inline void saturn_ca_p_1(); - inline void saturn_load_reg(int reg); - inline void saturn_jump(int adr, int jump); - inline void saturn_call(int adr); - inline void saturn_return(int yes); - inline void saturn_return_carry_set(); - inline void saturn_return_carry_clear(); - inline void saturn_return_interrupt(); - inline void saturn_return_xm_set(); - inline void saturn_pop_c(); - inline void saturn_push_c(); - inline void saturn_indirect_jump(int reg); - inline void saturn_equals_zero(int reg, int begin, int count); - inline void saturn_equals(int reg, int begin, int count, int right); - inline void saturn_not_equals_zero(int reg, int begin, int count); - inline void saturn_not_equals(int reg, int begin, int count, int right); - inline void saturn_greater(int reg, int begin, int count, int right); - inline void saturn_greater_equals(int reg, int begin, int count, int right); - inline void saturn_smaller_equals(int reg, int begin, int count, int right); - inline void saturn_smaller(int reg, int begin, int count, int right); - inline void saturn_jump_bit_clear(int reg); - inline void saturn_jump_bit_set(int reg); - inline void saturn_load_pc(int reg); - inline void saturn_store_pc(int reg); - inline void saturn_exchange_pc(int reg); - inline void saturn_load_adr(int reg, int nibbles); - inline void saturn_add_adr(int reg); - inline void saturn_sub_adr(int reg); - inline void saturn_adr_to_reg(int adr, int reg); - inline void saturn_reg_to_adr(int reg, int adr); - inline void saturn_adr_to_reg_word(int adr, int reg); - inline void saturn_reg_to_adr_word(int reg, int adr); - inline void saturn_exchange_adr_reg(int adr, int reg); - inline void saturn_exchange_adr_reg_word(int adr, int reg); - inline void saturn_load_nibbles(int reg, int begin, int count, int adr); - inline void saturn_store_nibbles(int reg, int begin, int count, int adr); - inline void saturn_clear_bit(int reg); - inline void saturn_set_bit(int reg); - inline void saturn_clear(int reg, int begin, int count); - inline void saturn_exchange(int left, int begin, int count, int right); - inline void saturn_copy(int dest, int begin, int count, int src); - inline void saturn_add(int reg, int begin, int count, int right); - inline void saturn_add_const(int reg, int begin, int count, uint8_t right); - inline void saturn_sub(int reg, int begin, int count, int right); - inline void saturn_sub_const(int reg, int begin, int count, int right); - inline void saturn_sub2(int reg, int begin, int count, int right); - inline void saturn_increment(int reg, int begin, int count); - inline void saturn_decrement(int reg, int begin, int count); - inline void saturn_invert(int reg, int begin, int count); - inline void saturn_negate(int reg, int begin, int count); - inline void saturn_or(int dest, int begin, int count, int src); - inline void saturn_and(int dest, int begin, int count, int src); - inline void saturn_shift_nibble_left(int reg, int begin, int count); - inline void saturn_shift_nibble_right(int reg, int begin, int count); - inline void saturn_rotate_nibble_left_w(int reg); - inline void saturn_rotate_nibble_right_w(int reg); - inline void saturn_shift_right(int reg, int begin, int count); - void saturn_invalid3( int op1, int op2, int op3 ); - void saturn_invalid4( int op1, int op2, int op3, int op4 ); - void saturn_invalid5( int op1, int op2, int op3, int op4, int op5 ); - void saturn_invalid6( int op1, int op2, int op3, int op4, int op5, int op6 ); + int READ_OP(); + int READ_OP_ARG(); + int READ_OP_ARG8(); + int8_t READ_OP_DIS8(); + int READ_OP_ARG12(); + int READ_OP_DIS12(); + int READ_OP_ARG16(); + int16_t READ_OP_DIS16(); + int READ_OP_ARG20(); + int READ_NIBBLE(uint32_t adr); + int READ_8(uint32_t adr); + int READ_12(uint32_t adr); + int READ_16(uint32_t adr); + int READ_20(uint32_t adr); + void WRITE_NIBBLE(uint32_t adr, uint8_t nib); + int S64_READ_X(int r); + int S64_READ_WORD(int r); + int S64_READ_A(int r); + void S64_WRITE_X(int r, int v); + void S64_WRITE_WORD(int r, int v); + void S64_WRITE_A(int r, int v); + uint32_t saturn_pop(); + void saturn_push(uint32_t adr); + void saturn_interrupt_on(); + void saturn_interrupt_off(); + void saturn_reset_interrupt(); + void saturn_mem_reset(); + void saturn_mem_config(); + void saturn_mem_unconfig(); + void saturn_mem_id(); + void saturn_shutdown(); + void saturn_bus_command_b(); + void saturn_bus_command_c(); + void saturn_bus_command_d(); + void saturn_serial_request(); + void saturn_out_c(); + void saturn_out_cs(); + void saturn_in(int reg); + void saturn_sethex() { m_decimal=0; } + void saturn_setdec() { m_decimal=1; } + void saturn_clear_st(); + void saturn_st_to_c(); + void saturn_c_to_st(); + void saturn_exchange_c_st(); + void saturn_jump_after_test(); + void saturn_st_clear_bit(); + void saturn_st_set_bit(); + void saturn_st_jump_bit_clear(); + void saturn_st_jump_bit_set(); + void saturn_hst_clear_bits(); + void saturn_hst_bits_cleared(); + void saturn_exchange_p(); + void saturn_p_to_c(); + void saturn_c_to_p(); + void saturn_dec_p(); + void saturn_inc_p(); + void saturn_load_p(); + void saturn_p_equals(); + void saturn_p_not_equals(); + void saturn_ca_p_1(); + void saturn_load_reg(int reg); + void saturn_jump(int adr, int jump); + void saturn_call(int adr); + void saturn_return(int yes); + void saturn_return_carry_set(); + void saturn_return_carry_clear(); + void saturn_return_interrupt(); + void saturn_return_xm_set(); + void saturn_pop_c(); + void saturn_push_c(); + void saturn_indirect_jump(int reg); + void saturn_equals_zero(int reg, int begin, int count); + void saturn_equals(int reg, int begin, int count, int right); + void saturn_not_equals_zero(int reg, int begin, int count); + void saturn_not_equals(int reg, int begin, int count, int right); + void saturn_greater(int reg, int begin, int count, int right); + void saturn_greater_equals(int reg, int begin, int count, int right); + void saturn_smaller_equals(int reg, int begin, int count, int right); + void saturn_smaller(int reg, int begin, int count, int right); + void saturn_jump_bit_clear(int reg); + void saturn_jump_bit_set(int reg); + void saturn_load_pc(int reg); + void saturn_store_pc(int reg); + void saturn_exchange_pc(int reg); + void saturn_load_adr(int reg, int nibbles); + void saturn_add_adr(int reg); + void saturn_sub_adr(int reg); + void saturn_adr_to_reg(int adr, int reg); + void saturn_reg_to_adr(int reg, int adr); + void saturn_adr_to_reg_word(int adr, int reg); + void saturn_reg_to_adr_word(int reg, int adr); + void saturn_exchange_adr_reg(int adr, int reg); + void saturn_exchange_adr_reg_word(int adr, int reg); + void saturn_load_nibbles(int reg, int begin, int count, int adr); + void saturn_store_nibbles(int reg, int begin, int count, int adr); + void saturn_clear_bit(int reg); + void saturn_set_bit(int reg); + void saturn_clear(int reg, int begin, int count); + void saturn_exchange(int left, int begin, int count, int right); + void saturn_copy(int dest, int begin, int count, int src); + void saturn_add(int reg, int begin, int count, int right); + void saturn_add_const(int reg, int begin, int count, uint8_t right); + void saturn_sub(int reg, int begin, int count, int right); + void saturn_sub_const(int reg, int begin, int count, int right); + void saturn_sub2(int reg, int begin, int count, int right); + void saturn_increment(int reg, int begin, int count); + void saturn_decrement(int reg, int begin, int count); + void saturn_invert(int reg, int begin, int count); + void saturn_negate(int reg, int begin, int count); + void saturn_or(int dest, int begin, int count, int src); + void saturn_and(int dest, int begin, int count, int src); + void saturn_shift_nibble_left(int reg, int begin, int count); + void saturn_shift_nibble_right(int reg, int begin, int count); + void saturn_rotate_nibble_left_w(int reg); + void saturn_rotate_nibble_right_w(int reg); + void saturn_shift_right(int reg, int begin, int count); + void saturn_invalid3(int op1, int op2, int op3); + void saturn_invalid4(int op1, int op2, int op3, int op4); + void saturn_invalid5(int op1, int op2, int op3, int op4, int op5); + void saturn_invalid6(int op1, int op2, int op3, int op4, int op5, int op6); void saturn_instruction_0e(); void saturn_instruction_1(); void saturn_instruction_80(); |