LMMS
Loading...
Searching...
No Matches
Nes_Cpu.cpp File Reference
#include "Nes_Cpu.h"
#include "blargg_endian.h"
#include <limits.h>
#include "nes_cpu_io.h"
#include "blargg_source.h"

Macros

#define BLARGG_CPU_X86   1
#define FLUSH_TIME()
#define CACHE_TIME()
#define CPU_DONE(cpu, time, result_out)
#define CPU_READ_PPU(cpu, addr, out, time)
#define PAGE_OFFSET(addr)
#define TIME   (s_time + s.base)
#define READ_LIKELY_PPU(addr, out)
#define READ(addr)
#define WRITE(addr, data)
#define READ_LOW(addr)
#define WRITE_LOW(addr, data)
#define READ_PROG(addr)
#define SET_SP(v)
#define GET_SP()
#define PUSH(v)
#define IS_NEG   (nz & 0x8080)
#define CALC_STATUS(out)
#define SET_STATUS(in)
#define GET_MSB()
#define ADD_PAGE()
#define GET_ADDR()
#define NO_PAGE_CROSSING(lsb)
#define HANDLE_PAGE_CROSSING(lsb)
#define INC_DEC_XY(reg, n)
#define IND_Y(cross, out)
#define IND_X(out)
#define ARITH_ADDR_MODES(op)
#define BRANCH(cond)

Variables

int const st_n = 0x80
int const st_v = 0x40
int const st_r = 0x20
int const st_b = 0x10
int const st_d = 0x08
int const st_i = 0x04
int const st_z = 0x02
int const st_c = 0x01

Macro Definition Documentation

◆ ADD_PAGE

#define ADD_PAGE ( )
Value:
(pc++, data += 0x100 * GET_MSB())
#define GET_MSB()
uint16_t pc
Definition Spc_Cpu.h:144
JSAMPIMAGE data
Definition jpeglib.h:945

◆ ARITH_ADDR_MODES

#define ARITH_ADDR_MODES ( op)
Value:
case op - 0x04: /* (ind,x) */\
IND_X( data )\
goto ptr##op;\
case op + 0x0C: /* (ind),y */\
goto ptr##op;\
case op + 0x10: /* zp,X */\
data = uint8_t (data + x);\
case op + 0x00: /* zp */\
goto imm##op;\
case op + 0x14: /* abs,Y */\
data += y;\
goto ind##op;\
case op + 0x18: /* abs,X */\
data += x;\
ind##op:\
HANDLE_PAGE_CROSSING( data );\
case op + 0x08: /* abs */\
ADD_PAGE();\
ptr##op:\
FLUSH_TIME();\
data = READ( data );\
CACHE_TIME();\
case op + 0x04: /* imm */\
imm##op:
#define READ(addr)
Definition Ay_Cpu.cpp:92
#define READ_LOW(addr)
Definition Hes_Cpu.cpp:82
#define HANDLE_PAGE_CROSSING(lsb)
int y
Definition inflate.c:1588
unsigned x[BMAX+1]
Definition inflate.c:1586
unsigned char uint8_t
Definition mid.cpp:98

◆ BLARGG_CPU_X86

#define BLARGG_CPU_X86   1

◆ BRANCH

#define BRANCH ( cond)
Value:
{\
int16_t offset = (int8_t) data;\
uint16_t extra_clock = (++pc & 0xFF) + offset;\
if ( !(cond) ) goto dec_clock_loop;\
pc = uint16_t (pc + offset);\
s_time += extra_clock >> 8 & 1;\
goto loop;\
}
goto loop
Definition Spc_Cpu.h:155
unsigned short uint16_t
Definition mid.cpp:99
short int16_t
Definition mid.cpp:96
signed char int8_t
Definition mid.cpp:95

◆ CACHE_TIME

#define CACHE_TIME ( )
Value:
(void) (s_time = s.time)
unsigned s
Definition inflate.c:1555
#define void
Definition unzip.h:396

◆ CALC_STATUS

#define CALC_STATUS ( out)
Value:
do {\
out = status & (st_v | st_d | st_i);\
out |= ((nz >> 8) | nz) & st_n;\
out |= c >> 8 & st_c;\
if ( !(nz & 0xFF) ) out |= st_z;\
} while ( 0 )
int const st_c
Definition Hes_Cpu.cpp:47
int const st_i
Definition Hes_Cpu.cpp:45
int const st_n
Definition Hes_Cpu.cpp:40
int const st_z
Definition Hes_Cpu.cpp:46
int const st_v
Definition Hes_Cpu.cpp:41
int const st_d
Definition Hes_Cpu.cpp:44
int nz
Definition Spc_Cpu.h:148
float out
Definition lilv_test.c:1461
return c
Definition crypt.c:175

◆ CPU_DONE

#define CPU_DONE ( cpu,
time,
result_out )
Value:
{ result_out = -1; }

◆ CPU_READ_PPU

#define CPU_READ_PPU ( cpu,
addr,
out,
time )
Value:
{\
FLUSH_TIME();\
out = CPU_READ( cpu, addr, time );\
CACHE_TIME();\
}
#define CPU_READ(cpu, addr, time)
Definition gb_cpu_io.h:68

◆ FLUSH_TIME

#define FLUSH_TIME ( )
Value:
(void) (s.time = s_time)

◆ GET_ADDR

#define GET_ADDR ( )
Value:
GET_LE16( instr )
#define GET_LE16(addr)
Definition blargg_endian.h:154

◆ GET_MSB

#define GET_MSB ( )
Value:
(instr [1])

◆ GET_SP

#define GET_SP ( )
Value:
((sp - 1) & 0xFF)
uint8_t sp
Definition Spc_Cpu.h:145

◆ HANDLE_PAGE_CROSSING

#define HANDLE_PAGE_CROSSING ( lsb)
Value:
s_time += (lsb) >> 8;

◆ INC_DEC_XY

#define INC_DEC_XY ( reg,
n )
Value:
reg = uint8_t (nz = reg + n); goto loop;
int n
Definition crypt.c:458

◆ IND_X

#define IND_X ( out)
Value:
{\
uint16_t temp = data + x;\
out = 0x100 * READ_LOW( uint8_t (temp + 1) ) + READ_LOW( uint8_t (temp) );\
}

◆ IND_Y

#define IND_Y ( cross,
out )
Value:
{\
uint16_t temp = READ_LOW( data ) + y;\
out = temp + 0x100 * READ_LOW( uint8_t (data + 1) );\
cross( temp );\
}

◆ IS_NEG

#define IS_NEG   (nz & 0x8080)

◆ NO_PAGE_CROSSING

#define NO_PAGE_CROSSING ( lsb)

◆ PAGE_OFFSET

#define PAGE_OFFSET ( addr)
Value:
((addr) & (page_size - 1))

◆ PUSH

#define PUSH ( v)
Value:
((sp = (sp - 1) | 0x100), WRITE_LOW( sp, v ))
#define WRITE_LOW(addr, data)
Definition Hes_Cpu.cpp:83
unsigned v[N_MAX]
Definition inflate.c:1584

◆ READ

#define READ ( addr)
Value:
CPU_READ( this, (addr), TIME )
#define TIME
Definition Ay_Cpu.cpp:88

◆ READ_LIKELY_PPU

#define READ_LIKELY_PPU ( addr,
out )
Value:
{CPU_READ_PPU( this, (addr), out, TIME );}
#define CPU_READ_PPU(cpu, addr, out, time)
Definition Nes_Cpu.cpp:37

◆ READ_LOW

#define READ_LOW ( addr)
Value:
(low_mem [int (addr)])
typedef int(UZ_EXP MsgFn)()

◆ READ_PROG

#define READ_PROG ( addr)
Value:
(s.code_map [(addr) >> page_bits] [PAGE_OFFSET( addr )])
#define PAGE_OFFSET(addr)
Definition Gb_Cpu.cpp:47

◆ SET_SP

#define SET_SP ( v)
Value:
(sp = ((v) + 1) | 0x100)

◆ SET_STATUS

#define SET_STATUS ( in)
Value:
do {\
status = in & (st_v | st_d | st_i);\
nz = in << 8;\
c = nz;\
nz |= ~in & st_z;\
} while ( 0 )
float in
Definition lilv_test.c:1460

◆ TIME

#define TIME   (s_time + s.base)

◆ WRITE

#define WRITE ( addr,
data )
Value:
{CPU_WRITE( this, (addr), (data), TIME );}
#define CPU_WRITE(cpu, addr, data, time)
Definition gb_cpu_io.h:71

◆ WRITE_LOW

#define WRITE_LOW ( addr,
data )
Value:
(void) (READ_LOW( addr ) = (data))

Variable Documentation

◆ st_b

int const st_b = 0x10

◆ st_c

int const st_c = 0x01

◆ st_d

int const st_d = 0x08

◆ st_i

int const st_i = 0x04

◆ st_n

int const st_n = 0x80

◆ st_r

int const st_r = 0x20

◆ st_v

int const st_v = 0x40

◆ st_z

int const st_z = 0x02