GrafX2 2.9.3227
The ultimate 256-color painting program
M6502 Struct Reference

6502 emulator instance. More...

#include <6502.h>

+ Collaboration diagram for M6502:

Data Fields

zusize cycles
 Number of cycles executed in the current call to m6502_run. More...
 
void * context
 The value used as the first argument when calling a callback. More...
 
zuint8(* read )(void *context, zuint16 address)
 Callback: Called when the CPU needs to read 8 bits from memory. More...
 
void(* write )(void *context, zuint16 address, zuint8 value)
 Callback: Called when the CPU needs to write 8 bits to memory. More...
 
Z6502State state
 CPU registers and internal bits. More...
 
zuint8 opcode
 Temporary storage for memory address resolution. More...
 
zuint8 ea_cycles
 Temporary storage for the number of cycles consumed by instructions requiring memory address resolution. More...
 
zuint16 ea
 Temporary storage for the resolved memory address. More...
 

Detailed Description

6502 emulator instance.

This structure contains the state of the emulated CPU and callback pointers necessary to interconnect the emulator with external logic. There is no constructor function, so, before using an object of this type, some of its members must be initialized, in particular the following: context, read and write.

Field Documentation

◆ cycles

zusize M6502::cycles

Number of cycles executed in the current call to m6502_run.

m6502_run sets this variable to 0 before starting to execute instructions and its value persists after returning. The callbacks can use this variable to know during what cycle they are being called.

◆ context

void* M6502::context

The value used as the first argument when calling a callback.

This variable should be initialized before using the emulator and can be used to reference the context/instance of the machine being emulated.

◆ read

zuint8(* M6502::read) (void *context, zuint16 address)

Callback: Called when the CPU needs to read 8 bits from memory.

Parameters
contextThe value of the member context.
addressThe memory address to read from.
Returns
The 8 bits read from memory.

◆ write

void(* M6502::write) (void *context, zuint16 address, zuint8 value)

Callback: Called when the CPU needs to write 8 bits to memory.

Parameters
contextThe value of the member context.
addressThe memory address to write to.
valueThe value to write.

◆ state

Z6502State M6502::state

CPU registers and internal bits.

It contains the state of the registers and the interrupt flags. This is what a debugger should use as its data source.

◆ opcode

zuint8 M6502::opcode

Temporary storage for memory address resolution.

This is an internal private variable.

◆ ea_cycles

zuint8 M6502::ea_cycles

Temporary storage for the number of cycles consumed by instructions requiring memory address resolution.

This is an internal private variable.

◆ ea

zuint16 M6502::ea

Temporary storage for the resolved memory address.

This is an internal private variable.


The documentation for this struct was generated from the following file: