Home :: PacmanEmulator :: Z80 classes

class Z80

? ^ 
Z80 software emulator.

Source:
z80.h:104
Author:
Alessandro Scotti
Version:
1.1

Contents

^ 
EntityTypeScopeShort Description
~Z80destructor publicDestructor.
Z80constructor publicCopy constructor: creates a copy of the specified Z80 object.
Z80constructor publicConstructor: creates a Z80 object with the specified environment.
$anonymous$enum publicCPU flags
Aattribute publicA register (accumulator)
A1attribute publicAlternate A register (A')
AFmethod publicReturns the 16 bit register AF.
Battribute publicB register
B1attribute publicAlternate B register (B')
BCmethod publicReturns the 16 bit register BC.
Cattribute publicC register
C1attribute publicAlternate C register (C')
Dattribute publicD register
D1attribute publicAlternate D register (D')
DEmethod publicReturns the 16 bit register DE.
Eattribute publicE register
E1attribute publicAlternate E register (E')
Fattribute publicFlags register
F1attribute publicAlternate flags register (F')
getCyclesmethod publicReturns the number of Z80 CPU cycles elapsed so far.
getInterruptModemethod publicReturns the current interrupt mode.
getSizeOfSnapshotBuffermethod publicReturns the size of the buffer needed to take a snapshot of the CPU.
Hattribute publicH register
H1attribute publicAlternate H register (H')
HLmethod publicReturns the 16 bit register HL.
Iattribute publicInterrupt register
interruptmethod publicInvokes an interrupt.
isHaltedmethod publicReturns non-zero if the CPU is halted, otherwise zero.
IXattribute publicIndex register X
IYattribute publicIndex register Y
Lattribute publicL register
L1attribute publicAlternate L register (L')
nmimethod publicForces a non-maskable interrupt.
operator =operator publicCopies CPU register from one object to another.
PCattribute publicProgram counter
Rattribute publicRefresh register
resetmethod publicResets the CPU to its initial state.
restoreSnapshotmethod publicRestores a snapshot taken with takeSnapshot().
runmethod publicRuns the CPU for the specified number of cycles.
setCyclesmethod publicSets the CPU cycle counter to the specified value.
setInterruptModemethod publicSets the interrupt mode to the specified value.
SPattribute publicStack pointer
stepmethod publicExecutes one instruction.
takeSnapshotmethod publicTakes a snapshot of the CPU.

destructor ~Z80

? ^  > 
Destructor.
Source:
z80.h:155
Code:
public virtual ~ Z80 ( )

constructor Z80

? ^  < > 
Copy constructor: creates a copy of the specified Z80 object.
Source:
z80.h:151
Code:
public Z80 ( const Z80 & )

constructor Z80

? ^  < > 
Constructor: creates a Z80 object with the specified environment.
Source:
z80.h:146
Code:
public Z80 ( Z80Environment & )

enum $anonymous$

? ^  < > 
CPU flags
Source:
z80.h:116
Code:
public enum { Carry = 0x01 ,
AddSub = 0x02 ,
Subtraction = AddSub ,
Parity = 0x04 ,
Overflow = Parity ,
Flag3 = 0x08 ,
Halfcarry = 0x10 ,
Flag5 = 0x20 ,
Zero = 0x40 ,
Sign = 0x80 }

attribute A

? ^  < > 
A register (accumulator)
Source:
z80.h:126
Code:
public unsigned char A

attribute A1

? ^  < > 
Alternate A register (A')
Source:
z80.h:134
Code:
public unsigned char A1

method AF

? ^  < > 
Returns the 16 bit register AF.
Source:
z80.h:203
Code:
public unsigned AF ( ) const

attribute B

? ^  < > 
B register
Source:
z80.h:120
Code:
public unsigned char B

attribute B1

? ^  < > 
Alternate B register (B')
Source:
z80.h:128
Code:
public unsigned char B1

method BC

? ^  < > 
Returns the 16 bit register BC.
Source:
z80.h:208
Code:
public unsigned BC ( ) const

attribute C

? ^  < > 
C register
Source:
z80.h:121
Code:
public unsigned char C

attribute C1

? ^  < > 
Alternate C register (C')
Source:
z80.h:129
Code:
public unsigned char C1

attribute D

? ^  < > 
D register
Source:
z80.h:122
Code:
public unsigned char D

attribute D1

? ^  < > 
Alternate D register (D')
Source:
z80.h:130
Code:
public unsigned char D1

method DE

? ^  < > 
Returns the 16 bit register DE.
Source:
z80.h:213
Code:
public unsigned DE ( ) const

attribute E

? ^  < > 
E register
Source:
z80.h:123
Code:
public unsigned char E

attribute E1

? ^  < > 
Alternate E register (E')
Source:
z80.h:131
Code:
public unsigned char E1

attribute F

? ^  < > 
Flags register
Source:
z80.h:127
Code:
public unsigned char F

attribute F1

? ^  < > 
Alternate flags register (F')
Source:
z80.h:135
Code:
public unsigned char F1

method getCycles

? ^  < > 
Returns the number of Z80 CPU cycles elapsed so far.

The cycle count is reset to zero when reset() is called, or it can be set to any value with setCycles(). It is updated after a CPU instruction is executed, for example by calling step() or interrupt().

Source:
z80.h:230
Code:
public unsigned getCycles ( ) const

method getInterruptMode

? ^  < > 
Returns the current interrupt mode.
Source:
z80.h:240
Code:
public unsigned getInterruptMode ( ) const

method getSizeOfSnapshotBuffer

? ^  < > 
Returns the size of the buffer needed to take a snapshot of the CPU.
Source:
z80.h:258
Code:
public unsigned getSizeOfSnapshotBuffer ( ) const

attribute H

? ^  < > 
H register
Source:
z80.h:124
Code:
public unsigned char H

attribute H1

? ^  < > 
Alternate H register (H')
Source:
z80.h:132
Code:
public unsigned char H1

method HL

? ^  < > 
Returns the 16 bit register HL.
Source:
z80.h:218
Code:
public unsigned HL ( ) const

attribute I

? ^  < > 
Interrupt register
Source:
z80.h:140
Code:
public unsigned char I

method interrupt

? ^  < > 
Invokes an interrupt.

If interrupts are enabled, the current program counter (PC) is saved on the stack and assigned the specified address. When the interrupt handler returns, execution resumes from the point where the interrupt occurred.

The actual interrupt address depends on the current interrupt mode and on the interrupt type. For maskable interrupts, data is as follows: - mode 0: data is an opcode that is executed (usually RST xxh); - mode 1: data is ignored and a call is made to address 0x38; - mode 2: a call is made to the 16 bit address given by (256*I + data).

Source:
z80.h:195
Code:
public void interrupt ( unsigned char data )

method isHalted

? ^  < > 
Returns non-zero if the CPU is halted, otherwise zero.
Source:
z80.h:248
Code:
public int isHalted ( ) const

attribute IX

? ^  < > 
Index register X
Source:
z80.h:136
Code:
public unsigned IX

attribute IY

? ^  < > 
Index register Y
Source:
z80.h:137
Code:
public unsigned IY

attribute L

? ^  < > 
L register
Source:
z80.h:125
Code:
public unsigned char L

attribute L1

? ^  < > 
Alternate L register (L')
Source:
z80.h:133
Code:
public unsigned char L1

method nmi

? ^  < > 
Forces a non-maskable interrupt.
Source:
z80.h:198
Code:
public void nmi ( )

operator =

? ^  < > 
Copies CPU register from one object to another.

Note that the environment is not copied, only registers.

Source:
z80.h:255
Code:
public Z80 & operator = ( const Z80 & )

attribute PC

? ^  < > 
Program counter
Source:
z80.h:138
Code:
public unsigned PC

attribute R

? ^  < > 
Refresh register
Source:
z80.h:141
Code:
public unsigned char R

method reset

? ^  < > 
Resets the CPU to its initial state.

The stack pointer (SP) is set to F000h, all other registers are cleared.

Source:
z80.h:162
Code:
public virtual void reset ( )

method restoreSnapshot

? ^  < > 
Restores a snapshot taken with takeSnapshot().

This function uses the data saved in the snapshot buffer to restore the CPU status.

Source:
z80.h:286
Param:
buffer buffer where the snapshot data is stored

Returns:
the number of bytes read from the buffer
Code:
public unsigned restoreSnapshot ( unsigned char * buffer )

method run

? ^  < > 
Runs the CPU for the specified number of cycles.

Note that the number of CPU cycles performed by this function may be actually a little more than the value specified. If that happens then the function returns the number of extra cycles executed.

Source:
z80.h:175
Param:
cycles number of cycles the CPU must execute

Returns:
the number of extra cycles executed by the last instruction
Code:
public virtual unsigned run ( unsigned cycles )

method setCycles

? ^  < > 
Sets the CPU cycle counter to the specified value.
Source:
z80.h:235
Code:
public void setCycles ( unsigned value )

method setInterruptMode

? ^  < > 
Sets the interrupt mode to the specified value.
Source:
z80.h:243
Code:
public void setInterruptMode ( unsigned mode )

attribute SP

? ^  < > 
Stack pointer
Source:
z80.h:139
Code:
public unsigned SP

method step

? ^  < > 
Executes one instruction.
Source:
z80.h:180
Code:
public virtual void step ( )

method takeSnapshot

? ^  < > 
Takes a snapshot of the CPU.

A snapshot saves all of the CPU registers and internals. It can be restored at any time to bring the CPU back to the exact status it had when the snapshot was taken.

Note: the size of the snapshot buffer must be no less than the size returned by the getSizeOfSnapshotBuffer() function.

Source:
z80.h:274
Param:
buffer buffer where the snapshot data is stored

Returns:
the number of bytes written into the buffer
Code:
public unsigned takeSnapshot ( unsigned char * buffer )

Copyright (c) 1997-2003,2004 Alessandro Scotti. All rights reserved.