LMMS
Loading...
Searching...
No Matches
Spc_Cpu.h File Reference

Go to the source code of this file.

Macros

#define SUSPICIOUS_OPCODE(name)
#define CPU_READ(time, offset, addr)
#define CPU_WRITE(time, offset, addr, data)
#define CPU_READ_TIMER(time, offset, addr_, out)
#define TIME_ADJ(n)
#define READ_TIMER(time, addr, out)
#define READ( time, addr)
#define WRITE(time, addr, data)
#define DP_ADDR(addr)
#define READ_DP_TIMER( time, addr, out)
#define READ_DP( time, addr)
#define WRITE_DP(time, addr, data)
#define READ_PROG16(addr)
#define SET_PC(n)
#define GET_PC()
#define READ_PC(pc)
#define READ_PC16(pc)
#define SET_SP(v)
#define GET_SP()
#define PUSH16(data)
#define PUSH(data)
#define POP(out)
#define MEM_BIT(rel)
#define GET_PSW(out)
#define SET_PSW(in)
#define BRANCH(cond)
#define CASE(n)
#define ADDR_MODES_(op)
#define ADDR_MODES_NO_DP(op)
#define ADDR_MODES(op)
#define LOGICAL_OP(op, func)
#define CASE(n)
#define INC_DEC_REG(reg, op)
#define CBRANCH(cond)

Functions

 SET_PC (m.cpu_regs.pc)
 SET_SP (m.cpu_regs.sp)
 SET_PSW (m.cpu_regs.psw)
 check ((unsigned) a< 0x100)
 if ((rel_time+=m.cycle_table[opcode]) > 0) goto out_of_time
 switch (opcode)
 assert (0)
 GET_PSW (temp)

Variables

int const n80 = 0x80
int const v40 = 0x40
int const p20 = 0x20
int const b10 = 0x10
int const h08 = 0x08
int const i04 = 0x04
int const z02 = 0x02
int const c01 = 0x01
int const nz_neg_mask = 0x880
 SPC_CPU_RUN_FUNC
uint8_t a = m.cpu_regs.a
uint8_t x = m.cpu_regs.x
uint8_t y = m.cpu_regs.y
uint16_t pc
uint8_t sp = ( uint8_t) GET_SP()
int psw = (uint8_t) temp
int c
int nz
int dp
goto loop
cbranch_taken_loop __pad0__
inc_pc_loop __pad1__
loop __pad2__
unsigned data = ram [pc]
 opcode = ram [pc]
out_of_time __pad3__
stop __pad4__

Macro Definition Documentation

◆ ADDR_MODES

#define ADDR_MODES ( op)
Value:
CASE( op - 0x04 ) /* dp */\
data += dp;\
end_##op:
int dp
Definition Spc_Cpu.h:149
#define ADDR_MODES_(op)
JSAMPIMAGE data
Definition jpeglib.h:945

◆ ADDR_MODES_

#define ADDR_MODES_ ( op)
Value:
CASE( op - 0x02 ) /* (X) */\
data = x + dp;\
pc--;\
goto end_##op;\
CASE( op + 0x0F ) /* (dp)+Y */\
data = READ_PROG16( data + dp ) + y;\
goto end_##op;\
CASE( op - 0x01 ) /* (dp+X) */\
data = READ_PROG16( ((uint8_t) (data + x)) + dp );\
goto end_##op;\
CASE( op + 0x0E ) /* abs+Y */\
data += y;\
goto abs_##op;\
CASE( op + 0x0D ) /* abs+X */\
data += x;\
CASE( op - 0x03 ) /* abs */\
abs_##op:\
data += 0x100 * READ_PC( ++pc );\
goto end_##op;\
CASE( op + 0x0C ) /* dp+X */\
data = (uint8_t) (data + x);
#define READ_PC(pc)
Definition Spc_Cpu.h:73
#define CASE(n)
uint16_t pc
Definition Spc_Cpu.h:144
#define READ_PROG16(addr)
Definition Spc_Cpu.h:69
int y
Definition inflate.c:1588
unsigned x[BMAX+1]
Definition inflate.c:1586
unsigned char uint8_t
Definition mid.cpp:98

◆ ADDR_MODES_NO_DP

#define ADDR_MODES_NO_DP ( op)
Value:
data += dp;\
end_##op:

◆ BRANCH

#define BRANCH ( cond)
Value:
{\
pc++;\
pc += (int8_t) data;\
if ( cond )\
goto loop;\
pc -= (int8_t) data;\
rel_time -= 2;\
goto loop;\
}
goto loop
Definition Spc_Cpu.h:155
signed char int8_t
Definition mid.cpp:95

◆ CASE [1/2]

#define CASE ( n)
Value:
case n: case (n) + 0x20:
int n
Definition crypt.c:458

◆ CASE [2/2]

#define CASE ( n)
Value:
case n:

◆ CBRANCH

#define CBRANCH ( cond)
Value:
{\
pc++;\
if ( cond )\
goto cbranch_taken_loop;\
rel_time -= 2;\
goto inc_pc_loop;\
}

◆ CPU_READ

#define CPU_READ ( time,
offset,
addr )
Value:
cpu_read( addr, time + offset )

◆ CPU_READ_TIMER

#define CPU_READ_TIMER ( time,
offset,
addr_,
out )
Value:
{\
rel_time_t adj_time = time + offset;\
int dp_addr = addr_;\
int ti = dp_addr - (r_t0out + 0xF0);\
if ( (unsigned) ti < timer_count )\
{\
Timer* t = &m.timers [ti];\
if ( adj_time >= t->next_time )\
t = run_timer_( t, adj_time );\
out = t->counter;\
t->counter = 0;\
}\
else\
{\
out = ram [dp_addr];\
int i = dp_addr - 0xF0;\
if ( (unsigned) i < 0x10 )\
out = cpu_read_smp_reg( i, adj_time );\
}\
}
unsigned * m
Definition inflate.c:1559
struct huft * t
Definition inflate.c:943
register unsigned i
Definition inflate.c:1575
float out
Definition lilv_test.c:1461

◆ CPU_WRITE

#define CPU_WRITE ( time,
offset,
addr,
data )
Value:
cpu_write( data, addr, time + offset )

◆ DP_ADDR

#define DP_ADDR ( addr)
Value:
(dp + (addr))

◆ GET_PC

#define GET_PC ( )
Value:
(pc)

◆ GET_PSW

#define GET_PSW ( out)
Value:
{\
out = psw & ~(n80 | p20 | z02 | c01);\
out |= c >> 8 & c01;\
out |= dp >> 3 & p20;\
out |= ((nz >> 4) | nz) & n80;\
if ( !(uint8_t) nz ) out |= z02;\
}
int const z02
Definition Spc_Cpu.h:116
int psw
Definition Spc_Cpu.h:146
int const p20
Definition Spc_Cpu.h:112
int const c01
Definition Spc_Cpu.h:117
int nz
Definition Spc_Cpu.h:148
int const n80
Definition Spc_Cpu.h:110
return c
Definition crypt.c:175

◆ GET_SP

#define GET_SP ( )
Value:
((uint8_t) (sp))
uint8_t sp
Definition Spc_Cpu.h:145

◆ INC_DEC_REG

#define INC_DEC_REG ( reg,
op )
Value:
nz = reg op;\
reg = (uint8_t) nz;\
goto loop;

◆ LOGICAL_OP

#define LOGICAL_OP ( op,
func )
Value:
ADDR_MODES( op ) /* addr */\
data = READ( 0, data );\
case op: /* imm */\
nz = a func##= data;\
goto inc_pc_loop;\
{ unsigned addr;\
case op + 0x11: /* X,Y */\
data = READ_DP( -2, y );\
addr = x + dp;\
goto addr_##op;\
case op + 0x01: /* dp,dp */\
data = READ_DP( -3, data );\
case op + 0x10:{/*dp,imm*/\
uint16_t addr2 = pc + 1;\
pc += 2;\
addr = READ_PC( addr2 ) + dp;\
}\
addr_##op:\
nz = data func READ( -1, addr );\
WRITE( 0, addr, nz );\
goto loop;\
}
#define READ(addr)
Definition Ay_Cpu.cpp:92
uint8_t a
Definition Spc_Cpu.h:141
#define ADDR_MODES(op)
#define READ_DP( time, addr)
Definition Spc_Cpu.h:66
unsigned short uint16_t
Definition mid.cpp:99

◆ MEM_BIT

#define MEM_BIT ( rel)
Value:
CPU_mem_bit( pc, rel_time + rel )

◆ POP

#define POP ( out)
Value:
{\
++sp;\
out = ram [0x100 + sp];\
}

◆ PUSH

#define PUSH ( data)
Value:
{\
ram [0x100 + sp] = (uint8_t) (data);\
--sp;\
}

◆ PUSH16

#define PUSH16 ( data)
Value:
{\
PUSH( (data & 0xff00) >> 8 );\
PUSH( data & 0xff );\
}

◆ READ

#define READ ( time,
addr )
Value:
CPU_READ ( rel_time, TIME_ADJ(time), (addr) )
#define TIME_ADJ(n)
Definition Spc_Cpu.h:57
#define CPU_READ(cpu, addr, time)
Definition gb_cpu_io.h:68

◆ READ_DP

#define READ_DP ( time,
addr )
Value:
READ ( time, DP_ADDR( addr ) )
#define DP_ADDR(addr)
Definition Spc_Cpu.h:63

◆ READ_DP_TIMER

#define READ_DP_TIMER ( time,
addr,
out )
Value:
CPU_READ_TIMER( rel_time, TIME_ADJ(time), DP_ADDR( addr ), out )
#define CPU_READ_TIMER(time, offset, addr_, out)
Definition Spc_Cpu.h:34

◆ READ_PC

#define READ_PC ( pc)
Value:
(ram [pc])

◆ READ_PC16

#define READ_PC16 ( pc)
Value:

◆ READ_PROG16

#define READ_PROG16 ( addr)
Value:
(RAM [(addr) & 0xffff] | (RAM [((addr) + 1) & 0xffff] << 8))
#define RAM
Definition Snes_Spc.cpp:22

◆ READ_TIMER

#define READ_TIMER ( time,
addr,
out )
Value:
CPU_READ_TIMER( rel_time, TIME_ADJ(time), (addr), out )

◆ SET_PC

#define SET_PC ( n)
Value:
(pc = n)

◆ SET_PSW

#define SET_PSW ( in)
Value:
{\
psw = in;\
c = in << 8;\
dp = in << 3 & 0x100;\
nz = (in << 4 & 0x800) | (~in & z02);\
}
float in
Definition lilv_test.c:1460

◆ SET_SP

#define SET_SP ( v)
Value:
(sp = v)
unsigned v[N_MAX]
Definition inflate.c:1584

◆ SUSPICIOUS_OPCODE

#define SUSPICIOUS_OPCODE ( name)
Value:
debug_printf( "SPC: suspicious opcode: " name "\n" )
#define debug_printf
Definition blargg_source.h:26
static const char * name
Definition pugl.h:1582

◆ TIME_ADJ

#define TIME_ADJ ( n)
Value:
(n)

◆ WRITE

#define WRITE ( time,
addr,
data )
Value:
CPU_WRITE( rel_time, TIME_ADJ(time), (addr), (data) )
#define CPU_WRITE(cpu, addr, data, time)
Definition gb_cpu_io.h:71

◆ WRITE_DP

#define WRITE_DP ( time,
addr,
data )
Value:
WRITE( time, DP_ADDR( addr ), data )
#define WRITE(addr, data)
Definition Ay_Cpu.cpp:93

Function Documentation

◆ assert()

assert ( 0 )

◆ check()

check ( )

◆ GET_PSW()

GET_PSW ( temp )

◆ if()

if ( (rel_time+=m.cycle_table[opcode]) ,
0  )

◆ SET_PC()

SET_PC ( m.cpu_regs. pc)

◆ SET_PSW()

SET_PSW ( m.cpu_regs. psw)

◆ SET_SP()

SET_SP ( m.cpu_regs. sp)

◆ switch()

switch ( opcode )

Variable Documentation

◆ __pad0__

cbranch_taken_loop __pad0__

◆ __pad1__

inc_pc_loop __pad1__

◆ __pad2__

loop __pad2__

◆ __pad3__

out_of_time __pad3__

◆ __pad4__

stop __pad4__

◆ a

m cpu_regs a = m.cpu_regs.a

◆ b10

int const b10 = 0x10

◆ c

int c

◆ c01

int const c01 = 0x01

◆ data

data = ram [pc]

◆ dp

int dp

◆ h08

int const h08 = 0x08

◆ i04

int const i04 = 0x04

◆ loop

goto loop

◆ n80

int const n80 = 0x80

◆ nz

int nz

◆ nz_neg_mask

int const nz_neg_mask = 0x880

◆ opcode

opcode = ram [pc]

◆ p20

int const p20 = 0x20

◆ pc

pc

◆ psw

m cpu_regs psw = (uint8_t) temp

◆ sp

m cpu_regs sp = ( uint8_t) GET_SP()

◆ SPC_CPU_RUN_FUNC

SPC_CPU_RUN_FUNC
Initial value:
{
uint8_t* const ram = RAM

◆ v40

int const v40 = 0x40

◆ x

m cpu_regs x = m.cpu_regs.x

◆ y

m cpu_regs y = m.cpu_regs.y

◆ z02

int const z02 = 0x02