Package libsidplay.components.mos656x
Klasse VIC
java.lang.Object
libsidplay.components.pla.Bank
libsidplay.components.mos656x.VIC
Implements the functionality of the C64's VIC II chip
For a good German documentation on the MOS 6567/6569 Videocontroller
(VIC-II), see
http://www.minet.uni-jena.de/~andreasg/c64/vic_artikel/vic_artikel_1.htm, http://cbmmuseum.kuto.de/zusatz_6569_vic2.html or http://unusedino.de/ec64/technical/misc/vic656x/vic656x-german.html. An English version of the documentation you can find at http://www.unusedino.de/ec64/technical/misc/vic656x/vic656x.html.
- Autor:
- Jörg Jahnke (joergjahnke@users.sourceforge.net), Antti S. Lankila (alankila@bel.fi)
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungprotected booleanare bad lines enabled for this frame?private final EventAEC state was updated.protected intbitmap memory base addressprivate intCurrent border colorprotected intcharacter memory base addressprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate static final byteprivate final byte[]contains the color data of the current characterprotected final EventSchedulerCPU's event context.private static final StringCreditsprotected final intNumber of cycles per line.protected static final intFirst line when we check for bad linesprotected booleanIs display rendering enabled?private static final byteraster IRQ flagprotected static final bytesprite-background collision IRQ flagprotected static final bytesprite-sprite collision IRQ flagprivate byteinternal IRQ flagsprivate bytemasks for the IRQ flagsprotected booleanis the current line a bad lineprotected booleanis the display active or idle?protected static final intLast line when we check for bad linesprivate byteprivate byteprotected intxscroll value within window region text columns 1 .. 39protected intCurrent visible lineprivate booleanIs CIA asserting lightpen?protected booleanHas light pen IRQ been triggered in this frame already?private byteLight pen coordinatesprivate byteLight pen coordinatesprivate final EventDisplay is enabled because badline condition was on for at least 1 clockstatic final intprotected final intNumber of raster linesstatic final intprivate booleanmulticolor flip-flop stateprivate static final byteLight-Pen IRQ flagprotected IPALEmulationprotected bytecontains the memory fetch dataprivate intxscroll-delayed phi1 dataprivate intPixel color being rendered.private final PLAPLA chipprotected intcurrent raster lineprotected booleanIs rasterYIRQ condition true?protected final EventRasterY IRQ edge detector.protected introw counter, a 3 bit counterprotected final byte[]memory for chip registersprivate booleanmain border flip-flopprotected booleanvertical border flip-flopprotected static final int[]protected final SpriteThe head of sprite linked list.protected final Sprite[]the 8 spritesprotected booleanSet when new frame starts.protected intvideo counter, a 10 bit counterprotected intvideo counter base, a 10 bit data registerprotected VideoDriverConsumer for VIC screen output as ARGB dataprotected intvideo matrix base addressprotected final byte[]contains the video matrix data for the current characterprivate static final byte[]private intprivate final byte[]Current dynamic colorsprotected bytehorizontal scrolling valueprivate intvertical scrolling value -
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungVIC(PLA pla, EventScheduler context, int cpl, int maxRasters) Creates a new instance of VIC6569 -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungprotected voidactivateIRQFlag(byte flag) Set an IRQ flag and trigger an IRQ if the corresponding IRQ mask is set.voidClears the lightpen usage flag.static Stringcredits()Gets the credit string.private voidGet the video memory base address, which is determined by the inverted bits 0-1 of port A on CIA 2, plus the video matrix base address plus the character data base address plus the bitmap memory base address.protected voidRead video matrix and color data for the next characterprotected voidThis monster method calculates: graphics sequencer output, sprite sequencer output, border sequencer output and combines all of them together.protected booleanprotected voidfetchSpriteData(int n) Fetch 1 byte of memory starting from the sprite address.protected voidfetchSpritePointer(int n) Get memory address of sprite data.abstract intintprivate intfinal byteIn certain cases, CPU sees the stale bus data from VIC.PAL emulationabstract intbyte[]intprivate voidSignal CPU interrupt if requested by VIC.private voidhandleSpriteVisibilityEvent(Sprite sprite) Schedule the rendering to beginprotected voidinterrupt(boolean b) protected voidHandle lightpen state changefinal byteread(int register) Read VIC register.private booleanreadCSEL()Read the CSEL flag which determines whether we display 38 or 40 columns of textprotected booleanreadDEN()Read the DEN flag which tells whether the display is enabledprotected intRead the value of the raster line IRQprotected booleanreadRSEL()Read the RSEL flag which determines whether we display 24 or 25 lines of textprivate intreadSpriteXCoordinate(int spriteNo) Read the x-coordinate of a spritevoidreset()Resets this VIC II Chip.protected voidsetBA(boolean b) voidsetPalEmulation(IPALEmulation palEmulation) private voidsetSpriteDataFromCPU(byte data) If CPU reads/writes to VIC at just the cycle VIC is supposed to do a PHI2 fetch for sprite data, the data fetched is set from the interaction with CPU.voidsetVideoDriver(VideoDriver videoDriver) Set consumer of VIC screen output as ARGB dataprotected final voidThis version just detects sprite-sprite collisions.voidTrigger the lightpen.protected bytevicReadColorMemoryPHI2(int address) protected bytevicReadMemoryPHI1(int address) protected bytevicReadMemoryPHI2(int address) final voidwrite(int register, byte data) Write to VIC register.
-
Felddetails
-
MAX_HEIGHT
public static final int MAX_HEIGHT- Siehe auch:
-
MAX_WIDTH
public static final int MAX_WIDTH- Siehe auch:
-
FIRST_DMA_LINE
protected static final int FIRST_DMA_LINEFirst line when we check for bad lines- Siehe auch:
-
LAST_DMA_LINE
protected static final int LAST_DMA_LINELast line when we check for bad lines- Siehe auch:
-
COL_D021
private static final byte COL_D021- Siehe auch:
-
COL_D022
private static final byte COL_D022- Siehe auch:
-
COL_D023
private static final byte COL_D023- Siehe auch:
-
COL_CBUF
private static final byte COL_CBUF- Siehe auch:
-
COL_CBUF_MC
private static final byte COL_CBUF_MC- Siehe auch:
-
COL_VBUF_L
private static final byte COL_VBUF_L- Siehe auch:
-
COL_VBUF_H
private static final byte COL_VBUF_H- Siehe auch:
-
COL_ECM
private static final byte COL_ECM- Siehe auch:
-
COL_NONE
private static final byte COL_NONE- Siehe auch:
-
videoModeColorDecoder
private static final byte[] videoModeColorDecoder -
videoModeColorDecoderOffset
private int videoModeColorDecoderOffset -
videoModeColors
private final byte[] videoModeColorsCurrent dynamic colors -
borderColor
private int borderColorCurrent border color -
phi1Data
protected byte phi1Datacontains the memory fetch data -
pixelColor
private int pixelColorPixel color being rendered. -
mcFlip
private boolean mcFlipmulticolor flip-flop state -
phi1DataPipe
private int phi1DataPipexscroll-delayed phi1 data -
palEmulation
-
pla
PLA chip -
credit
Credits- Siehe auch:
-
IRQ_RASTER
private static final byte IRQ_RASTERraster IRQ flag- Siehe auch:
-
IRQ_SPRITE_BACKGROUND_COLLISION
protected static final byte IRQ_SPRITE_BACKGROUND_COLLISIONsprite-background collision IRQ flag- Siehe auch:
-
IRQ_SPRITE_SPRITE_COLLISION
protected static final byte IRQ_SPRITE_SPRITE_COLLISIONsprite-sprite collision IRQ flag- Siehe auch:
-
MOS656X_INTERRUPT_LP
private static final byte MOS656X_INTERRUPT_LPLight-Pen IRQ flag- Siehe auch:
-
registers
protected final byte[] registersmemory for chip registers -
vc
protected int vcvideo counter, a 10 bit counter -
vcBase
protected int vcBasevideo counter base, a 10 bit data register -
rc
protected int rcrow counter, a 3 bit counter -
isDisplayActive
protected boolean isDisplayActiveis the display active or idle? -
areBadLinesEnabled
protected boolean areBadLinesEnabledare bad lines enabled for this frame? -
rasterY
protected int rasterYcurrent raster line -
rasterYIRQCondition
protected boolean rasterYIRQConditionIs rasterYIRQ condition true? -
sprites
the 8 sprites -
spriteLinkedListHead
The head of sprite linked list. The top is never rendered; it's just an anchor. -
colorData
private final byte[] colorDatacontains the color data of the current character -
videoMatrixData
protected final byte[] videoMatrixDatacontains the video matrix data for the current character -
showBorderVertical
protected boolean showBorderVerticalvertical border flip-flop -
showBorderMain
private boolean showBorderMainmain border flip-flop -
isBadLine
protected boolean isBadLineis the current line a bad line -
videoMatrixBase
protected int videoMatrixBasevideo matrix base address -
charMemBase
protected int charMemBasecharacter memory base address -
bitmapMemBase
protected int bitmapMemBasebitmap memory base address -
yscroll
private int yscrollvertical scrolling value -
xscroll
protected byte xscrollhorizontal scrolling value -
latchedXscroll
protected int latchedXscrollxscroll value within window region text columns 1 .. 39 -
irqFlags
private byte irqFlagsinternal IRQ flags -
irqMask
private byte irqMaskmasks for the IRQ flags -
lineCycle
protected int lineCycleCurrent visible line -
graphicsRendering
protected boolean graphicsRenderingIs display rendering enabled? -
context
CPU's event context. -
lpx
private byte lpxLight pen coordinates -
lpy
private byte lpyLight pen coordinates -
lpTriggered
protected boolean lpTriggeredHas light pen IRQ been triggered in this frame already? -
startOfFrame
protected boolean startOfFrameSet when new frame starts. -
CYCLES_PER_LINE
protected final int CYCLES_PER_LINENumber of cycles per line. -
MAX_RASTERS
protected final int MAX_RASTERSNumber of raster lines -
lpAsserted
private boolean lpAssertedIs CIA asserting lightpen? -
latchedColor
private byte latchedColor -
latchedVmd
private byte latchedVmd -
videoDriver
Consumer for VIC screen output as ARGB data -
singleColorLUT
protected static final int[] singleColorLUT -
makeDisplayActive
Display is enabled because badline condition was on for at least 1 clock -
badLineStateChange
AEC state was updated. -
rasterYIRQEdgeDetector
RasterY IRQ edge detector.
-
-
Konstruktordetails
-
VIC
Creates a new instance of VIC6569- Parameter:
pla-context-cpl-
-
-
Methodendetails
-
setVideoDriver
Set consumer of VIC screen output as ARGB data- Parameter:
videoDriver- consumer of C64 screen pixels as ARGB data
-
readSpriteXCoordinate
private int readSpriteXCoordinate(int spriteNo) Read the x-coordinate of a sprite- Parameter:
spriteNo- no of the sprite (0-7)- Gibt zurück:
- x-coordinate
-
readRSEL
protected boolean readRSEL()Read the RSEL flag which determines whether we display 24 or 25 lines of text- Gibt zurück:
- true if RSEL is set and we use 25 lines, otherwise false
-
readCSEL
private boolean readCSEL()Read the CSEL flag which determines whether we display 38 or 40 columns of text- Gibt zurück:
- true if CSEL is set and we use 40 columns, otherwise false
-
readDEN
protected boolean readDEN()Read the DEN flag which tells whether the display is enabled- Gibt zurück:
- true if DEN is set, otherwise false
-
readRasterLineIRQ
protected int readRasterLineIRQ()Read the value of the raster line IRQ- Gibt zurück:
- raster line when to trigger an IRQ
-
evaluateIsBadLine
protected boolean evaluateIsBadLine() -
handleIrqState
private void handleIrqState()Signal CPU interrupt if requested by VIC. -
determineVideoMemoryBaseAddresses
private void determineVideoMemoryBaseAddresses()Get the video memory base address, which is determined by the inverted bits 0-1 of port A on CIA 2, plus the video matrix base address plus the character data base address plus the bitmap memory base address. -
activateIRQFlag
protected void activateIRQFlag(byte flag) Set an IRQ flag and trigger an IRQ if the corresponding IRQ mask is set. The IRQ only gets activated, i.e. flag 0x80 gets set, if it was not active before. -
doVideoMatrixAccess
protected void doVideoMatrixAccess()Read video matrix and color data for the next character -
getVideoMatrixBase
public int getVideoMatrixBase() -
drawSpritesAndGraphics
protected void drawSpritesAndGraphics()This monster method calculates:- graphics sequencer output,
- sprite sequencer output,
- border sequencer output
-
spriteCollisionsOnly
protected final void spriteCollisionsOnly()This version just detects sprite-sprite collisions. It is appropriate to use outside renderable screen, where graphics sequencer is known to have quiesced. -
getLastReadByte
public final byte getLastReadByte()In certain cases, CPU sees the stale bus data from VIC. VIC reads on every cycle, and this describes what it reads. -
fetchSpritePointer
protected void fetchSpritePointer(int n) Get memory address of sprite data.- Parameter:
n- sprite number
-
fetchSpriteData
protected void fetchSpriteData(int n) Fetch 1 byte of memory starting from the sprite address.- Parameter:
n- sprite number
-
read
public final byte read(int register) Read VIC register. -
lightpenEdgeDetector
protected void lightpenEdgeDetector()Handle lightpen state change -
write
public final void write(int register, byte data) Write to VIC register. -
setSpriteDataFromCPU
private void setSpriteDataFromCPU(byte data) If CPU reads/writes to VIC at just the cycle VIC is supposed to do a PHI2 fetch for sprite data, the data fetched is set from the interaction with CPU.- Parameter:
data- TheSpritedata to set.
-
getCurrentSpriteCycle
private int getCurrentSpriteCycle() -
handleSpriteVisibilityEvent
Schedule the rendering to begin- Parameter:
sprite- TheSpriteto handle the visibility event of.
-
reset
public void reset()Resets this VIC II Chip. -
credits
Gets the credit string.- Gibt zurück:
- The credit string.
-
getPalEmulation
PAL emulation -
setPalEmulation
-
triggerLightpen
public void triggerLightpen()Trigger the lightpen. Sets the lightpen usage flag. -
clearLightpen
public void clearLightpen()Clears the lightpen usage flag. -
interrupt
protected void interrupt(boolean b) -
setBA
protected void setBA(boolean b) -
vicReadColorMemoryPHI2
protected byte vicReadColorMemoryPHI2(int address) -
vicReadMemoryPHI1
protected byte vicReadMemoryPHI1(int address) -
vicReadMemoryPHI2
protected byte vicReadMemoryPHI2(int address) -
getBorderWidth
public int getBorderWidth() -
getBorderHeight
public abstract int getBorderHeight() -
getRasterYMax
public abstract int getRasterYMax() -
getRegisters
public byte[] getRegisters()
-