ROLAND  0.70
Amstrad Emulator based on Caprice Source rewritten in C++.
Public Types | Public Member Functions | Private Attributes | List of all members
Ppi Class Referencefinal

#include <ppi.h>

Public Types

enum  FlagB {
  Triumph = 2, Saisho = 4, Solavox = 6, Awa = 8,
  Schneider = 10, Orion = 12, Amstrad = 14, VSyncOccured = 1,
  Refresh50Hz = 16, Expansion = 32, PrnterNotReady = 64, TapeRead = 128
}
 < (DIP-switch, do not combine manufacturer) More...
 

Public Member Functions

 Ppi ()
 
 ~Ppi () ROLAND_DEFAULT void init()
 set initial values More...
 
tUBYTE portA () const
 get Port A More...
 
tUBYTE portB () const
 get Port B More...
 
tUBYTE portC () const
 get Port C More...
 
tUBYTE control () const
 get control bits More...
 
tUBYTE jumpers () const
 get jumpers More...
 
void setA (tUBYTE val)
 set Port A More...
 
void setB (tUBYTE val)
 set Port B More...
 
void setC (tUBYTE val)
 set Port C More...
 
void setControl (tUBYTE val)
 set control bits More...
 
void setJumpers (tUBYTE val)
 set jumpers More...
 
void addB (tUBYTE flags)
 add a flag to Port B More...
 
void removeB (tUBYTE flags)
 remove a flag from Port B More...
 

Private Attributes

tUBYTE mPortA
 
tUBYTE mPortB
 
tUBYTE mPortC
 
tUBYTE mControl
 
tUBYTE mJumpers
 

Detailed Description

The 8255 Parallel Peripheral Interface Parallel Peripheral Interface

8255 PPI

8255 PPI

This can be tested with the following code:

The 8255 is a general purpose input/output IC. This document will describe it's role in the Amstrad CPC,CPC+ and KC compact systems. To understand it's full functions please read the datasheet.

In these systems it is connected to the AY-3-8912 Programmable Sound Generator (PSG), keyboard, cassette recorder, the VSYNC of the 6845 CRTC and the "busy" signal from the parallel port.

The PPI is selected when bit 11 of the I/O port address is set to "0", bits 9 and 8 then define the PPI function access as shown below:

Bit 9 Bit 8 PPI Function Read/Write status
0 0 Port A data Read/Write
0 1 Port B data Read/Write
1 0 Port C data Read/Write
1 1 Control Write Only

It is advised that the remaining bits of the I/O address are set to "1" to avoid conflict with other devices. The recommended I/O addressess are:

I/O address PPI Function
&F4xx Port A data
&F5xx Port B data
&F6xx Port C data
&F7xx Control

In the CPC+, the 8255 is integrated into the ASIC. The "emulation" is not complete and some functionality is not available. Please see the "Extra CPC+ documentation" for more information.

Port Usage

NOTE:

PPI Port A

Operating system settings:

NOTE:

Bit Description Usage
7 PSG databus Read data from PSG or Write data to PSG
6
5
4
3
2
1
0

PPI Port B

Operating system settings:

Bit Description Usage
7 Cassette read data  
6 Parallel/Printer port ready signal "1" = not ready, "0" = Ready
5 /EXP (note 6)
4 (note 5)
3 (note 1) (note 4)
2 (note 2)
1 (note 3)
0 6845 VSYNC State of VSYNC from 6845. "1" = VSYNC active, "0" = VSYNC inactive

Note:

  1. On CPC464,CPC664,CPC6128 and GX4000 this is LK3 on the PCB. On the CPC464+ and CPC6128+ this is LK103 on the PCB. On the KC compact this is "1".
  2. On CPC464,CPC664,CPC6128 and GX4000 this is LK2 on the PCB. On the CPC464+ and CPC6128+ this is LK102 on the PCB. On the KC compact this is "0".
  3. On CPC464,CPC664,CPC6128 and GX4000 this is LK1 on the PCB. On the CPC464+ and CPC6128+ this is LK101 on the PCB. On the KC compact this is /TEST signal from the expansion port.
  4. On the CPC464,CPC664,CPC6128,CPC464+,CPC6128+ and GX4000 bits 3,2 and 1 define the manufacturer name. See below to see the options available. The manufacturer name is defined on the PCB and cannot be changed through software.
  5. On the CPC464,CPC664,CPC6128,CPC464+,CPC6128+ and GX4000 bit 4 defines the Screen refresh frequency. "1" = 50Hz, "0" = 60Hz. This is defined on the PCB and cannot be changed with software. On the KC compact bit 4 is "1"
  6. This bit is connected to /EXP signal on the expansion port.
    • On the KC Compact this bit is used to define bit 7 of the printer data.
    • On the CPC, it is possible to use this bit to define bit 7 of the printer data, so a 8-bit printer port is made, with a hardware modification,
    • On the CPC this can be used by a expansion device to report it's presence. "1" = device connected, "0" = device not connected. This is not always used by all expansion devices.

Table showing manufacturer name on power-up (CPC and CPC+ only):

Bit 3 Bit 2 Bit 1 Manufacturer Name
000Isp
001Triumph
010Saisho
011Solavox
100Awa
101Schneider
110Orion
111Amstrad

PPI Port C

Operating system settings:

Bit Description Usage
7 PSG BDIR PSG function selection
6 PSG BC1
5 Cassette Write data  
4 Cassette Motor Control set bit to "1" for motor on, or "0" for motor off
3 Keyboard line Select keyboard line to be scanned (0-15)
2
1
0

PSG function selection:

Bit 7 Bit 6 Function
0 0 Inactive
0 1 Read from selected PSG register
1 0 Write to selected PSG register
1 1 Select PSG register

Programming Examples

  1. Using the control byte
    • Setting bit 7 of port C to 1,
      LD B,&F7                ;8255 Control port
      LD A,%00001111          ;Bit Set/reset function
      OUT (C),A               ;Send it to 8255
      RET
      
    • Set port A to input, operating in mode 0, port B to output, operating in mode 0 and port C to input, operating in mode 0.
      LD B,&F7                ;8255 Control port
      LD A,%10011001          ;Configuration function
      OUT (C),A               ;Send it to 8255
      RET
      
  2. Using port A/B/C,

    In this example, port A is set to output, port B is set to input, and port C is set to output, and they are all operating in mode 0.

    We will only be using port A for these examples.

    • Reading from port A,
                              ;Set port A to input
      
      LD B,&F7                ;8255 Control port
      LD A,%10010010          ;Configuration function
      OUT (C),A               ;Send to 8255
      
      LD B,&F4                ;Port A port address
      IN E,(C)                ;Get byte from port
      
                              ;Register E holds value from port
      
                              ;Return port I/O status and operating modes
                              ;to previous settings.
      
      LD B,&F7                ;8255 Control port
      LD A,%10000010          ;Configuration function
      OUT (C),A               ;Send to 8255
      RET
      
    • Writing to port A,
                              ;Set port A to output
      
                              ;(Note the next few lines are not necessary
                              ;as port A is already acting as output, however
                              ;it is given here just to make the example
                              ;more understandable)
      
      LD B,&F7                ;8255 Control port
      LD A,%10000010          ;Configuration function
      OUT (C),A               ;Send to 8255
      
      LD B,&F4                ;port A port address
      
                              ;Register E holds value to put into port
      
      LD E,&FF                ;Data to put into port
      OUT (C),A               ;Send to port A
      
                              ;Return port I/O status and operating modes
                              ;to previous settings.
      
      LD B,&F7                ;8255 Control port
      LD A,%10000010          ;Configuration function
      OUT (C),A
      RET
      

Member Enumeration Documentation

enum FlagB

< (DIP-switch, do not combine manufacturer)

Enumerator
Triumph 

Manufacturer Triumph.

Saisho 

Manufacturer Saisho.

Solavox 

Manufacturer Solavox.

Awa 

Manufacturer Awa.

Schneider 

Manufacturer Schneider.

Orion 

Manufacturer Orion.

Amstrad 

Manufacturer Amstrad.

VSyncOccured 

VSync (internal)

Refresh50Hz 

50Hz instead of 60Hz refresh rate (DIP-switch)

Expansion 

No expansion Peripherals available (internal)

PrnterNotReady 

Printer is not ready (internal)

TapeRead 

Tape will be read (internal)

Constructor & Destructor Documentation

Ppi ( )
inline

References init(), ROLAND_DEFAULT, and Ppi::~Ppi().

~Ppi ( )

set initial values

Referenced by Ppi::Ppi().

Member Function Documentation

void addB ( tUBYTE  flags)
inline

add a flag to Port B

References Ppi::mPortB.

tUBYTE control ( ) const
inline

get control bits

References Ppi::mControl.

Referenced by Cpc::z80_in_handler(), and Cpc::z80_out_handler().

tUBYTE jumpers ( ) const
inline

get jumpers

References Ppi::mJumpers.

Referenced by Cpc::z80_in_handler().

tUBYTE portA ( ) const
inline

get Port A

References Ppi::mPortA.

Referenced by Cpc::z80_in_handler(), and Cpc::z80_out_handler().

tUBYTE portB ( ) const
inline

get Port B

References Ppi::mPortB.

Referenced by Cpc::z80_in_handler().

tUBYTE portC ( ) const
inline

get Port C

References Ppi::mPortC.

Referenced by Cpc::z80_in_handler(), and Cpc::z80_out_handler().

void removeB ( tUBYTE  flags)
inline

remove a flag from Port B

References Ppi::mPortB.

void setA ( tUBYTE  val)
inline

set Port A

References Ppi::mPortA.

Referenced by Cpc::z80_out_handler().

void setB ( tUBYTE  val)
inline

set Port B

References Ppi::mPortB.

Referenced by Cpc::z80_out_handler().

void setC ( tUBYTE  val)
inline

set Port C

References Ppi::mPortC.

Referenced by Cpc::z80_out_handler().

void setControl ( tUBYTE  val)
inline

set control bits

References Ppi::mControl.

Referenced by Cpc::z80_out_handler().

void setJumpers ( tUBYTE  val)
inline

set jumpers

References Ppi::mJumpers.

Member Data Documentation

tUBYTE mControl
private

Referenced by Ppi::control(), and Ppi::setControl().

tUBYTE mJumpers
private

Referenced by Ppi::jumpers(), and Ppi::setJumpers().

tUBYTE mPortA
private

Referenced by Ppi::portA(), and Ppi::setA().

tUBYTE mPortB
private
tUBYTE mPortC
private

Referenced by Ppi::portC(), and Ppi::setC().


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