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

#include <crtc.h>

Public Types

enum  Register : tUBYTE {
  HorizontalTotal = 0, HorizontalDisplayed = 1, HorizontalSyncPosition = 2, SyncWidth = 3,
  VerticalTotal = 4, VerticalTotalAdjust = 5, VerticalDisplayed = 6, VerticalSyncPosition = 7,
  InterlaceAndSkew = 8, MaximumRasterAddress = 9, CursorStartRaster = 10, CursorEndRaster = 11,
  StartAddressHigh = 12, StartAddressLow = 13, CursorHigh = 14, CursorLow = 15,
  LightPenHigh = 16, LightPenLow = 17
}
 
enum  Flags : tUWORD {
  VS = 1, HS = 2, HDT = 4, VDT = 8,
  HT = 16, VT = 32, MR = 64, VTadj = 128,
  VSf = 256
}
 

Public Member Functions

 Crtc ()
 
 ~Crtc () ROLAND_DEFAULT void init(Ppi *ppi
 
tUBYTE selected () const
 
tUBYTE read () const
 
tUBYTE read (tUBYTE num) const
 
void select (tUBYTE reg)
 
void write (tUBYTE reg, tUBYTE value)
 
void write (tUBYTE value)
 
uint flags ()
 
tUBYTE hsw ()
 
tBYTE hswVdu ()
 
tUBYTE hswActive ()
 
tUBYTE hswCount ()
 
tUBYTE vsw ()
 
tUBYTE vswCount ()
 
tUBYTE lastHDisp ()
 
tUBYTE skew ()
 
tUBYTE vtAdjust ()
 
tUBYTE vtAdjustCount ()
 
tUBYTE maxRaster ()
 
tUBYTE rasterCount ()
 
tUBYTE lineCount ()
 
tUBYTE charCount ()
 
uint requestedAddr ()
 
uint addr ()
 
void setFlags (uint flags)
 
void addFlags (uint flags)
 
void removeFlags (uint flags)
 
void setHswVdu (tUBYTE value)
 
void setHswActive (tUBYTE value)
 
void setHswCount (tUBYTE value)
 
void setAddr (uint value)
 
void setVtAdjust (tUBYTE value)
 
void setVtAdjustCount (tUBYTE value)
 
void setVswCount (tUBYTE value)
 
void setLastHDisp (tUBYTE value)
 
void setCharCount (tUBYTE value)
 
void setLineCount (tUBYTE value)
 
void setRasterCount (tUBYTE value)
 
void setSkew (tUBYTE value)
 
void incVswCount ()
 

Private Attributes

PpimPpi
 
tUBYTE mRegister [18]
 
tUBYTE mSelected
 
uint mFlags
 
tUBYTE mHsw
 
tBYTE mHswVdu
 
tUBYTE mHswCount
 
tUBYTE mHswActive
 
tUBYTE mVsw
 
tUBYTE mVswCount
 
tUBYTE mLastHDisp
 
tUBYTE mSkew
 
tUBYTE mVtAdjust
 
tUBYTE mVtAdjustCount
 
tUBYTE mMaxRaster
 
tUBYTE mRasterCount
 
tUBYTE mLineCount
 
tUBYTE mCharCount
 
uint mRequestedAddr
 
uint mAddr
 

Detailed Description

The CRTC6845 CRTC6845

The 6845 Cathode Ray Tube Controller (CRTC)

The 6845 Cathode Ray Tube Controller (CRTC)

Introduction

The 6845 Cathode Ray Tube Controller (CRTC) is a programmable IC used to generate video displays. This IC is used in a variety of computers including the Amstrad CPC, Amstrad CPC+ and KC Compact.

CRTC in the Amstrad CPC/CPC+ and KC Compact designs

The CRTC was a common part available from many different manufacturers. During the life of the CPC, Amstrad sourced the CRTC from various manufacturers.

All ICs used were based on the same design but have a different implementation. As a result they do not operate identically in all situations. This document highlights these differences.

This table lists the known ICs used, with their part number, manufacturer and type number.

Part number Manufacturer Type number (note 3)
UM6845 UMC 0
HD6845S Hitachi 0
UM6845R UMC 1
MC6845 Motorola 2
AMS40489 Amstrad 3 (note 1)
??? Amstrad? 4 (note 2)

NOTES:

  1. The CRTC functionality is integrated into the CPC+ ASIC. This type exists only in the CPC464+,CPC6128+ and GX4000.
  2. As far as I know, this type exists only in "cost-down" CPC6128 systems. In the "cost-down" CPC6128, the CRTC functionality is integrated into a single ASIC IC. This ASIC is often refered to as the "Pre-ASIC" because it preceeded the CPC+ ASIC.
  3. In the Amstrad community each 6845 implementation has been assigned a type number. This type identifies a group of implementations which operate in exactly the same way.

    As far as I know, the type number system was originally used by demo programmers.

    It is possible to detect the 6845 present using software methods, and this is done to:

    • warn that the software was not designed for the detected 6845 and may function incorrectly,
    • to adapt the software so that it will run with the detected 6845

    In most cases, the type of the detected 6845 is reported.

  4. As far as I know, the KC compact used HD6845S only.

The 6845 is selected when bit 14 of the I/O port address is set to "0". Bit 1 and 0 of the I/O port address define the function to access. The remaining bits can be any value, but it is adviseable to set these to "1" to avoid conflict with other devices in the system.

The recommended I/O port addressess are:

I/O port address Function Read/Write
&BCxx Select 6845 register Write only
&BDxx Write 6845 register data Write only
&BExx (note 1) Read only
&BFxx (note 1) Read only

NOTE:

  1. The function of these I/O ports is dependant on the CRTC type

Signals

The following table defines the generated memory address from the CRTC and Gate-Array signals.

Memory Address Signal Signal source Signal name
A15 6845 MA13
A15 6845 MA12
A14 6845 MA11
A13 6845 RA2
A12 6845 RA1
A11 6845 RA0
A10 6845 MA9
A9 6845 MA8
A8 6845 MA7
A7 6845 MA6
A6 6845 MA5
A5 6845 MA4
A4 6845 MA3
A3 6845 MA2
A2 6845 MA1
A1 6845 MA0
A0 Gate-Array CCLK
DISPTMG
DISPTMG signal defines the border. When DISPTMG is "1" the border colour is output to the display.
HSYNC and VSYNC
HSYNC and VSYNC from the CRTC are passed into the Gate-Array. The Gate-Array modifies the signals and then mixes these to form the Composite-Sync which is output to the display

The 6845 Design

Registers

The Internal registers of the 6845 are:

Register Index Register Name
0 Horizontal Total
1 Horizontal Displayed
2 Horizontal Sync Position
3 Horizontal and Vertical Sync Widths
4 Vertical Total
5 Vertical Total Adjust
6 Vertical Displayed
7 Vertical Sync position
8 Interlace and Skew
9 Maximum Raster Address
10 Cursor Start Raster
11 Cursor End Raster
12 Display Start Address (High)
13 Display Start Address (Low)
14 Cursor Address (High)
15 Cursor Address (High)
16 Light Pen Address (High)
17 Light Pen Address (High)

CRTC Differences

In this section I will attempt to identify all the differences between each CRTC.

The following tables list the functions that can be accessed for each type:

Type 0

b1 b0 Function Read/Write
0 0 Select internal 6845 register Write Only
0 1 Write to selected internal 6845 register Write Only
1 0 - -
1 1 Read from selected internal 6845 register Read only

Type 1

b1 b0 Function Read/Write
0 0 Select internal 6845 register Write Only
0 1 Write to selected internal 6845 register Write Only
1 0 Read Status Register Read Only
1 1 Read from selected internal 6845 register Read only

Type 2

b1 b0 Function Read/Write
0 0 Select internal 6845 register Write Only
0 1 Write to selected internal 6845 register Write Only
1 0 - -
1 1 Read from selected internal 6845 register Read only

Type 3 and 4

b1 b0 Function Read/Write
0 0 Select internal 6845 register Write Only
0 1 Write to selected internal 6845 register Write Only
1 0 Read from selected internal 6845 register Read Only
1 1 Read from selected internal 6845 register Read only

It is not possible to read from all the internal registers, this table shows the read/write status of each register for each type:

Register Index Register Name Type
0 1 2 3
0 Horizontal Total Write Only Write Only Write Only (note 2)
1 Horizontal Displayed Write Only Write Only Write Only (note 2)
2 Horizontal Sync Position Write Only Write Only Write Only (note 2)
3 Horizontal and Vertical Sync Widths Write Only Write Only Write Only (note 2)
4 Vertical Total Write Only Write Only Write Only (note 2)
5 Vertical Total Adjust Write Only Write Only Write Only (note 2)
6 Vertical Displayed Write Only Write Only Write Only (note 2)
7 Vertical Sync position Write Only Write Only Write Only (note 2)
8 Interlace and Skew Write Only Write Only Write Only (note 2)
9 Maximum Raster Address Write Only Write Only Write Only (note 2)
10 Cursor Start Raster Write Only Write Only Write Only (note 2)
11 Cursor End Raster Write Only Write Only Write Only (note 2)
12 Display Start Address (High) Read/Write Write Only Write Only Read/Write (note 2)
13 Display Start Address (Low) Read/Write Write Only Write Only Read/Write (note 2)
14 Cursor Address (High) Read/Write Read/Write Read/Write Read/Write (note 2) ***check
15 Cursor Address (Low) Read/Write Read/Write Read/Write Read/Write (note 2) **check
16 Light Pen Address (High) Read Only Read Only Read Only Read Only (note 2) **check
17 Light Pen Address (High) Read Only Read Only Read Only Read Only (note 2) **check

Notes:

  1. On type 0 and 1, if a Write Only register is read from, "0" is returned.
  2. See the document "Extra CPC Plus Hardware Information" for more details.

Member Enumeration Documentation

enum Flags : tUWORD
Enumerator
VS 

VSync.

HS 

HSync.

HDT 

HorizontalDisplayedTotal.

VDT 

VerticalDisplayedTotal.

HT 

HorizontalTotal.

VT 

VerticalTotal.

MR 

MaximumRasterAddress.

VTadj 

VerticalTotalAdjust.

VSf 

VerticalSyncPosition.

enum Register : tUBYTE
Enumerator
HorizontalTotal 

PAL SECAM NTSC.

63 63 63

HorizontalDisplayed 

40 40 40

HorizontalSyncPosition 

46 46 46

SyncWidth 

0x8E 0x8E 0x8E

VerticalTotal 

38 38 31

VerticalTotalAdjust 

0 0 6

VerticalDisplayed 

25 25 25

VerticalSyncPosition 

30 30 27

InterlaceAndSkew 

0 0 0

MaximumRasterAddress 

7 7 7

CursorStartRaster 

X X X.

CursorEndRaster 

X X X.

StartAddressHigh 

X X X.

StartAddressLow 

X X X.

CursorHigh 

X X X.

CursorLow 

X X X.

LightPenHigh 

X X X.

LightPenLow 

X X X.

Constructor & Destructor Documentation

Crtc ( )
inline

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

~Crtc ( )

Referenced by Crtc::Crtc().

Member Function Documentation

void addFlags ( uint  flags)
inline

References Crtc::flags(), and Crtc::mFlags.

Referenced by Vdu::access_video_memory().

uint addr ( )
inline

References Crtc::mAddr.

Referenced by Vdu::access_video_memory().

tUBYTE charCount ( )
inline

References Crtc::mCharCount.

Referenced by Vdu::access_video_memory().

uint flags ( )
inline
tUBYTE hsw ( )
inline

References Crtc::mHsw.

Referenced by Vdu::access_video_memory().

tUBYTE hswActive ( )
inline

References Crtc::mHswActive.

Referenced by Vdu::access_video_memory().

tUBYTE hswCount ( )
inline

References Crtc::mHswCount.

Referenced by Vdu::access_video_memory().

tBYTE hswVdu ( )
inline

References Crtc::mHswVdu.

Referenced by Vdu::access_video_memory().

void incVswCount ( )
inline

References Crtc::mVswCount.

Referenced by Vdu::access_video_memory().

tUBYTE lastHDisp ( )
inline

References Crtc::mLastHDisp.

Referenced by Vdu::access_video_memory().

tUBYTE lineCount ( )
inline

References Crtc::mLineCount.

Referenced by Vdu::access_video_memory().

tUBYTE maxRaster ( )
inline

References Crtc::mMaxRaster.

Referenced by Vdu::access_video_memory().

tUBYTE rasterCount ( )
inline

References Crtc::mRasterCount.

Referenced by Vdu::access_video_memory().

tUBYTE read ( ) const
inline
tUBYTE read ( tUBYTE  num) const
inline

References Crtc::mRegister.

void removeFlags ( uint  flags)
inline

References Crtc::mFlags.

Referenced by Vdu::access_video_memory().

uint requestedAddr ( )
inline
void select ( tUBYTE  reg)
inline

References Crtc::mSelected.

Referenced by Cpc::z80_out_handler().

tUBYTE selected ( ) const
inline
void setAddr ( uint  value)
inline

References Crtc::mAddr.

Referenced by Vdu::access_video_memory().

void setCharCount ( tUBYTE  value)
inline

References Crtc::mCharCount.

Referenced by Vdu::access_video_memory().

void setFlags ( uint  flags)
inline

References Crtc::flags(), and Crtc::mFlags.

void setHswActive ( tUBYTE  value)
inline

References Crtc::mHswActive.

Referenced by Vdu::access_video_memory().

void setHswCount ( tUBYTE  value)
inline

References Crtc::mHswCount.

Referenced by Vdu::access_video_memory().

void setHswVdu ( tUBYTE  value)
inline

References Crtc::mHswVdu.

void setLastHDisp ( tUBYTE  value)
inline

References Crtc::mLastHDisp.

Referenced by Vdu::access_video_memory().

void setLineCount ( tUBYTE  value)
inline

References Crtc::mLineCount.

Referenced by Vdu::access_video_memory().

void setRasterCount ( tUBYTE  value)
inline

References Crtc::mRasterCount.

Referenced by Vdu::access_video_memory().

void setSkew ( tUBYTE  value)
inline

References Crtc::mSkew.

Referenced by Vdu::access_video_memory().

void setVswCount ( tUBYTE  value)
inline

References Crtc::mVswCount.

Referenced by Vdu::access_video_memory().

void setVtAdjust ( tUBYTE  value)
inline

References Crtc::mVtAdjust.

void setVtAdjustCount ( tUBYTE  value)
inline
tUBYTE skew ( )
inline

References Crtc::mSkew.

Referenced by Vdu::access_video_memory().

tUBYTE vsw ( )
inline

References Crtc::mVsw.

Referenced by Vdu::access_video_memory().

tUBYTE vswCount ( )
inline

References Crtc::mVswCount.

Referenced by Vdu::access_video_memory().

tUBYTE vtAdjust ( )
inline

References Crtc::mVtAdjust.

Referenced by Vdu::access_video_memory().

tUBYTE vtAdjustCount ( )
inline
void write ( tUBYTE  reg,
tUBYTE  value 
)
inline

References Crtc::mRegister.

Referenced by Cpc::z80_out_handler().

void write ( tUBYTE  value)

Member Data Documentation

uint mAddr
private

Referenced by Crtc::addr(), and Crtc::setAddr().

tUBYTE mCharCount
private
uint mFlags
private
tUBYTE mHsw
private

Referenced by Crtc::hsw(), and Crtc::write().

tUBYTE mHswActive
private
tUBYTE mHswCount
private
tBYTE mHswVdu
private
tUBYTE mLastHDisp
private
tUBYTE mLineCount
private
tUBYTE mMaxRaster
private

Referenced by Crtc::maxRaster(), and Crtc::write().

Ppi* mPpi
private
tUBYTE mRasterCount
private
tUBYTE mRegister[18]
private

Referenced by Crtc::read(), and Crtc::write().

uint mRequestedAddr
private

Referenced by Crtc::requestedAddr(), and Crtc::write().

tUBYTE mSelected
private
tUBYTE mSkew
private
tUBYTE mVsw
private

Referenced by Crtc::vsw(), and Crtc::write().

tUBYTE mVswCount
private
tUBYTE mVtAdjust
private
tUBYTE mVtAdjustCount
private

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