You are on page 1of 25

RCPDocumentationRev.

6
Oct.02,2010

RealityCoprocessor(RCP)
TheRCPistheworkhorseoftheNintendo64.ItcontainsasecondaryMIPSR4000
basedprocessorwithvectorcommandextensions,knownastheRealitySignalProcessor
(RSP).ItalsocontainsSGIsrasterizerhardware,knownastheRealityDisplay
Processor(RDP). TheRCPalsocontainsacollectionofregisterscontrollingvirtuallyall
peripheralaccessontheN64includingvideo,audioandserialamongotherthings.The
mainprocessorcommunicateswiththevariousRCPcomponentsusingmemorymapped
registers,separatedintodiscreteareasofmemorybasedonfunction.
NOTE: AllRCPregistersare32bitsunlessotherwisenoted.Allregistersarealsoread/writeenabled
unlessotherwisenoted.

RegisterMemoryMap
ThefollowingisahighlevelmemorymapoftheRCP.Sectionsofmemoryare
separatedbyfunctionasdetailedbelow. Every divisionisexactly1MBinsize,though
thevalidaddressspaceofaccessibleregistersisfarshorter.
MemoryRegion
0x04040000
0x04100000
0x04200000
0x04300000
0x04400000
0x04500000
0x04600000
0x04700000
0x04800000

Function
SPregisters
DPcommandregisters
DPspanregisters
MIregisters
VIregisters
AIregisters
PIregisters
RIregisters
SIregisters

VideoInterface(VI)
Thevideointerfaceisfoundatmemoryoffset0x04400000. TheVIregistersallow
precisecontrolofthevideooutputfromtheN64.Theycontrolhardwaresetupfor
timing,colordepthandresolutionamongotherthings. Itisimportanttonotethatall
registersmustbesetupproperlytoensurepropervideooutputusingtheN64. TheVI
doesnotincludeservicesfordrawingtothescreenasthisisdonetoaframebufferthatis
thenpassedtotheVIusingtheVI_ORIGIN_REG registerdetailedbelow. Allregisters
arelistedwiththeirmnemonicfirst,followedbytheiroffsetfromthevideointerfacebase
address.

Page 1of 25

RCPDocumentationRev.6
Oct.02,2010

Registers
VI_CONTROL_REG(0x00)
TheVI_CONTROL_REGregisterusesonlythebottom17bitsasmappedoutbelow.
Function
ColorDepth

Bits
Description
1:0 Setstheframebufferbitdepth:

GammaDither

GammaBoost
Divot

3
4

Reserved
Serrate
Diagnostic
AntiAliasMode

5
6
7
9:8

Undefined
Diagnostic
PixelAdvance
DitherFilter

00Blank(nodataorsync)
01Reserved
1016bitcolor(0bRRRRRGGGGGBBBBBA)
1132bitcolor(0xRRGGBBAA)
Enablesgammadither. Usuallyleftunset.Noeffectif
GammaBoostisunset.
Enablesgammaboost. Usuallyleftunset.
Enablesdivot.Usuallyusedinconjunctionwithanti
aliasing.
Alwayszero.
Setthisifrunningininterlacedmode.Clearotherwise.
Alwayszero.
Setstheantialiasmode:

00Antialiasingandresampling,alwaysfetchextralines
01Antialiasingandresampling,fetchwhenneeded
10Resamplingonly
11Neither(replicatepixels,nointerpolation)
10 Alwayszero.
11 Alwayszero.
15:12 Typicalobservedvalueis0x3.
16 Enableditherfilter. Usuallyusedinconjunctionwith16bit
colortosmoothoutgradients.

Thegammaditherandgammaboostbitsaresomewhatcurious.Itisrecommendedto
leavetheseon,butabetterpicturecolorwisecanbeproducedwhendisablingthem.
Manygamesleavethegammaboostbitoff.Disablinggammaboostgivesasmoother
gradientofcolors,whileenablingitproducesamuchbrighterbutmorewashedout
picture.Thegammaditherbitonlyaffectsthepicturewhengammaboostisenabled.
Thegammaditherbitwillslightlybrightenthedarkercolorswhileleavingthelighter
colorsunaffected.

Page 2of 25

RCPDocumentationRev.6
Oct.02,2010

Onecaveattobecarefulofisthatantialiasingmustbeenabledwhenrunningin320x240
16bppmode.Ifyoudonotatleastenableresamplingantialiasingwhenrunninginthis
mode,youwillgetcorruptedvideo.Allothermodesdonotseemtohavethisrestriction.
VI_DRAM_ADDR_REG(0x04)
TheVI_DRAM_ADDR_REGregisterallowsaframebufferinmemorytobeassignedas
thecurrentlyusedframebuffer.Thisallowsaprogrammertodesignasingle,doubleor
eventriplebufferedsystemwithoutrelyingonhardware.Thisshouldbeupdatedwhen
thesystemisinverticalblanktoswapbuffersforthesmoothestpossiblevideoupdate.
Framebufferscanbeanywhereinmemory,butitsagoodideatohavethemalignedona
boundarythatmakesitpossibletoDMAtothem.Also,besuretopasstheuncached
memoryaddresstotheVIbyoringwiththebitmask0xA0000000(MIPS kseg1) or
youwillhavetomanuallyinvalidatethecachebeforeswappingbuffers.
VI_H_WIDTH_REG(0x08)
TheVI_H_WIDTH_REGregistercontrolsthehorizontalwidthinpixelsoftheframe
buffer.Typicalvaluesare0x0140for320x240video,or 0x0280for640x480video.
Thisvalue,combinedwiththehorizontalandverticalscaling,allowsforthevideomode
widthandheighttobeset.
VI_V_INTR_REG(0x0C)
TheVI_V_INTR_REGregisterworksincombinationwiththeMItoassertaninterrupt
whenthevideohardwarehitsacertainline(usuallyusedtosetupavblankinterrupt).
DontforgettosettheassociatedmaskbitsintheMIoryouwillnotgetaninterrupt.To
cleartheinterruptonceitisasserted,writetotheVI_V_CURRENT_LINE_REGregister.
VI_V_CURRENT_LINE_REG(0x10)
TheVI_V_CURRENT_LINE_REGregisterisupdatedonceperverticallinetoreflect
thecurrentlinebeingdisplayed.Ininterlacedmode,theleastsignificantbitwillbe
constantforthecurrentfield.Awritetothisregisterdoesnotchangetheverticalline
currentlybeingdisplayed.Instead,itclearsanycurrentlyassertedinterruptcausedbythe
VI_V_INTR_REGregister.

Page 3of 25

RCPDocumentationRev.6
Oct.02,2010

VI_TIMING_REG(0x14)
TheVI_TIMING_REGregistercontrolsseveraltimingaspectsofthevideosignal.Itis
mappedoutintodifferentfieldsasdetailedbelow.
Function
HSyncWidth
BurstWidth
VSyncWidth
BurstStart

Bits
7:0
15:8
19:16
29:20

Description
Specifiesthehorizontalsyncwidthinpixels.
Specifiesthecolorburstwidthinpixels.
Specifiestheverticalsyncheightinlines.
Specifiesthecolorburststartasanoffsetinpixelsfromthe
horizontalsync.

VI_V_SYNC_REG(0x18)
TheVI_V_SYNC_REGregistercontrolsthenumberoflinesperframe(orthenumberof
halflinesperfield).ValuesaretypicallytakenstraightfromtheNTSCorPAL
specifications.ForNTSC,thisis0x20D(525lines).ForPAL,thisis0x271(625
lines).
VI_H_SYNC_REG(0x1C)
TheVI_H_SYNC_REGregisterissplitintotwofieldsasdetailedbelow.
Function
LineDuration
HSyncPeriod

Bits
Description
11:0 Durationofalinerepresentedinpixels.
20:16 LeappatternusedonlyinPALformats.

VI_H_SYNC_LEAP_REG(0x20)
TheVI_H_SYNC_LEAP_REGregisterissplitintotwoidenticalfields,settothesame
valueasthelinedurationintheVI_H_SYNC_REGregister.
Function
LineDuration
LineDuration

Bits
Description
11:0 Duplicateofdatarepresentedin11:0of
VI_H_SYNC_LEAP_REG.
27:16 Duplicateofdatarepresentedin11:0of
VI_H_SYNC_LEAP_REG.

Page 4of 25

RCPDocumentationRev.6
Oct.02,2010

VI_H_VIDEO_REG(0x24)
TheVI_H_VIDEO_REGregisterissplitintotwofieldsthatspecifythestartandendof
theactivehorizontalvideoinpixels. Thedifferencebetweenthesevaluesisnormally
640pixels.
Function
Horizontal End
Horizontal Start

Bits
Description
9:0 Endofactivevideomeasuredinpixels.
25:16 Startofactivevideomeasuredinpixels.

VI_V_VIDEO_REG(0x28)
TheVI_V_VIDEO_REGregisterissplitintotwofieldsthatspecifythestartandendof
theactiveverticalvideoinlines. Thedifferencebetweenthesevaluesisnormally474
lines.
Function
Bits
Description
Vertical End
9:0 Endofactivevideomeasuredinlines.
Vertical Start
25:16 Startofactivevideomeasuredinlines.
VI_V_BURST_REG(0x2C)
TheVI_V_BURST_REGregisterissplitintotwofieldsthatspecifythestartandendof
thecolorburstinverticallines. ThisincombinationwiththeVI_TIMING_REGregister
allowsforfullcontrolovervideotiming.
Function
ColorBurstEnd
ColorBurstStart

Bits
Description
9:0 Endofactivevideomeasuredinlines.
25:16 Startofactivevideomeasuredinlines.

VI_X_SCALE_REG(0x30)
TheVI_X_SCALE_REGregistercontrolsthehorizontal scalingupfactorbetweenthe
framebufferandthefinalimageasdisplayedonthescreen. Italsocontrolsthe
horizontalsubpixeloffset.Bothvaluesarespecifiedas2.10fixedpointintegers.
Function
HorizontalScale
SubpixelOffset

Bits
Description
11:0 Reciprocalofthehorizontalscalevalue.
27:16 Horizontalsubpixeloffset.

Page 5of 25

RCPDocumentationRev.6
Oct.02,2010

VI_Y_SCALE_REG(0x34)
TheVI_Y_SCALE_REGregistercontrolsthehorizontalscalingupfactorbetweenthe
framebufferandthefinalimageasdisplayedonthescreen.Italsocontrolsthevertical
subpixeloffset.Bothvaluesarespecifiedas2.10fixedpointintegers.
Function
VerticalScale
SubpixelOffset

Bits
Description
11:0 Reciprocaloftheverticalscalevalue.
27:16 Verticalsubpixeloffset.

SampleVIValues
Thefollowingistheregistersetupfora320x24016bit,resamplingonlyantialiased
videomodeforNTSC,PALandPALM.
Register
VI_CONTROL_REG
VI_DRAM_ADDR_REG
VI_H_WIDTH_REG
VI_V_INTR_REG
VI_V_CURRENT_LINE_REG
VI_TIMING_REG
VI_V_SYNC_REG
VI_H_SYNC_REG
VI_H_SYNC_LEAP_REG
VI_H_VIDEO_REG
VI_V_VIDEO_REG
VI_V_BURST_REG
VI_X_SCALE_REG
VI_Y_SCALE_REG

NTSCValue
0x0000320e
Unspecified
0x00000140
0x00000200
Unspecified
0x03e52239
0x0000020d
0x00000c15
0x0c150c15
0x006c02ec
0x002501ff
0x000e0204
0x00000200
0x00000400

PALValue
0x0000320e
Unspecified
0x00000140
0x00000200
Unspecified
0x0404233a
0x00000271
0x00150c69
0x0c6f0c6e
0x00800300
0x005f0239
0x0009026b
0x00000200
0x00000400

MPALValue
0x0000320e
Unspecified
0x00000140
0x00000200
Unspecified
0x04651e39
0x0000020d
0x00040c11
0x0c190c1a
0x006c02ec
0x002501ff
0x000e0204
0x00000200
0x00000400

Page 6of 25

RCPDocumentationRev.6
Oct.02,2010

SetupandOperation
TheproperwaytosetupaframebufferontheN64issimple.Mostregistervaluescan
besimplycopiedfromthetableaboveastheyrelatetotheactualgenerationofthevideo
signalandnotsoftwareparametersrelatingtoabufferinmemory.The
VI_DRAM_ADDR_REGregisterisnormallyleftsettozerowhilesettingotherregisters
toavoidflickerorgarbageappearingonthescreen.TheN64willoutputvideoat
640x480regardlessoftheframebufferwidthorheight.TheVI_X_SCALE_REGand
VI_Y_SCALE_REGregistersallowonetoscaleanarbitrarybufferinmemorytofitin
the640x480region.TheVI_H_WIDTH_REGregisterallowstheframebuffertobeset
toarbitrarywidthandonly servestoallowtheN64todeterminewhereaparticularline
endsintheframebuffer.
Curiously,theN64treatstheverticalcomponentashalflinesandassuchascalingfactor
of1Xwillsettheverticalresolutionto240pixels. A horizontal scalingfactor of1Xwill
setthehorizontalresolutionto640pixelsasexpected.Thehorizontalandvertical
scalingfactorscanbesetindependentoftheVI_H_WIDTH_REGregister.Novertical
componentisspecifiedfortheframebufferastheN64hardwarewilluseasmanylinesin
theframebufferasareneededtorendertheimagetothescreen.
Doubleortriplebufferingisachievedinsoftwarebychangingthe
VI_DRAM_ADDR_REGregisterwhileintheverticalretraceperiod.Aninterruptis
generatedonthehalflinespecifiedbytheVI_V_INTR_REGregister.Thismeansthat
evenoninterlacedtelevisions,aninterruptwillonlyhappenoncetheentirescenehas
beendrawn(evenandoddlines).Itisrecommendedtopasstothe
VI_DRAM_ADDR_REGregistertheuncachedmemoryaddressoftheframebufferas
thispreventsartifactsduetocachingproblems.WhenusingtheRDPtorenderascene,
theColorImageBufferissettotheseaddresses.

SampleVideoModeConfigurations
320x240
Register
Setting
H_WIDTH 0x140 320
X_SCALE 0x200 2X
Y_SCALE 0x400 1X

640x240
Register
Setting
H_WIDTH 0x280 640
X_SCALE 0x400 1X
Y_SCALE 0x400 1X

640x480
Register
Setting
H_WIDTH 0x280 640
X_SCALE 0x400 1X
Y_SCALE 0x800 .5X

Page 7of 25

RCPDocumentationRev.6
Oct.02,2010

RasterizerInterface(DP)
TheRealityDisplayProcessorcontrolinterfaceisfoundat0x04100000.TheDP
registersallowcommandstobesenttotheRDPandforRDPsettingstobetoggled.The
RDPworksintandemwiththeVideoInterfacetoallowforhardwaredrawnpolygons.
TheRDPcontainsitsowntexturememory(4KB)fromwhichitcantexturerectanglesor
triangles.TheRDPalsohasthecapabilityofconvertingtexturesfromothercolormodes
aswellasdrawingshadedandzbufferedtriangles.Undernormalgameoperation,the
RDPisusuallycontrolledviatheRSPasthedrawingcommandsareverylowlevel.
However,itispossibletocontroltheRDPdirectlyfromarunningprogramontheN64
withoutcodingaspecializedprogramfortheRSP. SendingacommandtotheRDPis
doneinasimilarfashiontosendingaDMArequesttooneoftheDMAcontrollers
onboardtheN64.
DP_START_REG(0x00)
TheDP_START_REGregisterspecifiesthestartlocationinRDRAMorRSPDMEM
whereanRDPcommandcanbefound. TheRDPwillpullthecommandfromRDPAM
orRSPDMEMdependingonthestateoftheDMEMDMA bitinthe
DP_STATUS_REGregister.WheninRDRAMmode,theRDPcanhandleanyvalid
address,butbecarefulascachingissuesmayarisewithcachedareasofRDRAM.When
inRSPDMEMmode,theRDPexpectstheaddresstobeintherangeof 0x000to
0xFFF.ThisisidenticaltothevaliddatamemoryrangewithrespecttotheRSP. This
shouldbewrittentobeforetheDP_END_REG.
DP_END_REG(0x04)
TheDP_END_REGregisterspecifiestheendlocationinRDRAMorRSPDMEMwhere
anRDPcommandcanbefound.Thesamerestrictionsthatapplytotherangeof
addressespassedtoDP_START_REGapplyhereaswell.Writingtothisregisterwill
kickofftheprocessofloadingacommandfrommemoryandperformingit,so the
DP_END_REGshouldbewrittentoaftertheDP_START_REG.Commandsshouldbe
issuedoneatatimefrommemory,notasablockofcommands.
DP_CURRENT_REG(0x08)
TheDP_CURRENT_REGreflectsthecurrentlocationoftheRDPinloadingcommands
frommemory.

Page 8of 25

RCPDocumentationRev.6
Oct.02,2010

DP_STATUS_REG(0x0C)
TheDP_STATUS_REGregisterallowsarbitrarymodestobesetontheRDP.Most
notably,thisishowonewouldtelltheRDPfromwhichprocessortopullitsdata.The
bitshavedifferentmeaningdependingonwhetheritisreadfromorwrittentoasdetailed
below.

Function
DMEMDMAStatus

FreezeStatus
FlushStatus
StartGCLK
TMEMBusy
PipeBusy
CommandBusy
CommandBuffer
Busy
DMABusy
EndValid
StartValid

ReadingfromDP_STATUS_REG
Bit
Description
0 ThisbitwillbesetifDMEMDMAmodeisset.Usethis
bittodeterminewheretheRDPwillexpectcommandsto
comefrom.
1 ThisbitwillbesetifFreezehasbeenset.
2 ThisbitwillbesetifFlushhasbeenset.
3 Unknown.
4 ThisbitwillbesetiftheTMEMisinuseontheRDP.
5 Thisbitwillbesetifthegraphicspipeisinuseonthe
RDP.
6 ThisbitwillbesetiftheRDPiscurrentlyexecutinga
command.
7 ThisbitwillbesetiftheRDPcommandbufferisinuse.
8

ThisbitwillbesetiftheRDPisintheprocessofcopying
acommandtothecommandbuffer.
9 Unknown. Normallysettozero.
10 Unknown. Normallysettozero.

PossiblytheonlybitsworthmentioningaretheDMEMDMAStatus,EndValidandStart
Validbits.TheDMEMDMAbitindicateswhethertheRDPisinthecorrectmodeto
receivecommandsfromtheRDRAM.WhiletheactualmeaningoftheEndValidand
StartValidbitsisunknown,theyareoftenusedincommercialgamestotellifitissafeto
issuethenextcommand.BeforeissuinganycommandtotheRDP,checktoseethatboth
theStartValidandEndValidbitsarecleared.Waitinguntilthesebitsarebothcleared
beforeissuinganothercommandensuresthatthenextcommandwontoverwhelmthe
RDPcommandbuffer. FailingtodosocouldcausetheN64tofreeze.

Page 9of 25

RCPDocumentationRev.6
Oct.02,2010

WritingtoDP_STATUS_REG
Function
Bit
Description
ClearDMEMDMA
0 Writinga1tothisbitwillsettheRDPtopullcommands
Mode
fromRDRAM.
SetDMEMDMA
1 Writinga1tothisbitwillsettheRDPtopullcommands
Mode
fromtheRSPDMEM.
ClearFreeze
2 Writinga1tothisbitwillcleartheRDPfreezebit.
SetFreeze
3 Writinga1tothisbitwillsettheRDPfreezebit.
ClearFlush
4 Writinga1tothisbitwillcleartheRDPflushbit.
SetFlush
5 Writinga1tothisbitwillsettheRDPflushbit.
ClearTMEMCounter 6 Writinga1tothisbitwillsettheDP_TMEM_REG
registerto0.
ClearPipeCounter
7 Writinga1tothisbitwillsettheDP_PIPEBUSY_REG
registerto0.
ClearCommand
8 Writinga1tothisbitwill settheDP_BUFBUSY_REG
Counter
registerto0.
ClearClockCounter
9 Writinga1tothisbitwillsettheDP_CLOCK_REG
registerto0.

DP_CLOCK_REG(0x10)
ThefunctionalityoftheDP_CLOCK_REGregisterisunknown.Itcanberesetusingthe
DP_STATUS_REG.
DP_BUFBUSY_REG(0x14)
ThefunctionalityoftheDP_BUFBUSY_REGregisterisunknown.Itcanberesetusing
theDP_STATUS_REG,andcountsuptoapredeterminedvalue.
DP_PIPEBUSY_REG(0x18)
ThefunctionalityoftheDP_PIPEBUSY_REGregisterisunknown.Itcan beresetusing
theDP_STATUS_REG,andcountsuptoapredeterminedvalue.
DP_TMEM_REG(0x1C)
ThefunctionalityoftheDP_TMEM_REGregisterisunknown.Itcanberesetusingthe
DP_STATUS_REG,andcountsuptoapredeterminedvalue.

Page 10 of 25

RCPDocumentationRev.6
Oct.02,2010

RasterizerCommandSet
Therasterizeriscontrolledbyasetof commands,mostofthem64bitsinlength.They
canbesplitintothreedifferentcategories:configuration,drawingandpipelinecontrol.
TheRDPiscapableofrasterizingrectangles(texturedoruntextured) andavarietyof
triangles.Coordinatesofgeometrytoberasterizedaregivenwithrespecttoavirtual
framebuffer(alsoknownasscreenspace)whichisfourtimeslargerinwidthandheight
tothescreenresolution.ItispossiblethatthisiscontrolledbythePixelAdvancebitsin
theVI_CONTROL_REGregisterbutthisisunverified.
Allcommandsarepresentedwiththeircommonname,followedbytheexpecteddata
formataspassedtotheRDPandfinallyadescriptionofthecommandanditsuse. Illegal
valuesforaparticularcommandarehighlightedinred.
ConfigurationCommands
ThesecommandsallowonetoconfiguretheRDPforvariousrasterizationoptionsaswell
assetupandloadtexturesintoTMEM.

Page 11 of 25

RCPDocumentationRev.6
Oct.02,2010

SetColorImage(64bits)

Function
Opcode
ColorFormat

PixelSize

Width

DRAMAddress

Bits
Description
61:56 0x3f
55:53 Controlstheoutputformatoftherasterizedimage:
000RGBA
001YUV
010ColorIndex
011Intensity Alpha
011Intensity
52:51 Sizeofanindividualpixelintermsofbits:
004bits
018bits(ColorIndex)
1016bits(RGBA)
1132bits(RGBA)
41:32 Widthofframebufferinmemoryminusone.Thiswidth
shouldcorrespondtothewidthoftheframebuffergivento
theVI_H_WIDTH_REGregister.
25:0 Theaddressinmemory wheretheframebufferresides.

TheSetColorImagecommandsetsthelocationoftheframebufferinmemorywherethe
RDPshouldrasterizegeometry.TheColorFormatbitsarenormallysettoRGBAand
thePixelSizesettomatchthebitdepth specifiedintheVI_CONTROL_REGregister.
However,ifdesiredtheRDPcanbeusedtodrawtoacolorindexedframebufferwhich
canbelaterusedasatextureforanotherprimitive.TheDRAMAddresscanbemodified
atanytimeaslongasaSyncFulliscalledtoensureallgeometryhasbeenrenderedto
theframebuffer.Inthisway,itispossibletousedoubleortriplebufferingtechniques
thattakeadvantageoftheRDPforsomedrawing.

Page 12 of 25

RCPDocumentationRev.6
Oct.02,2010

SetTextureImage(64bits)

Function
Opcode
ColorFormat

PixelSize

Width

DRAMAddress

Bits
Description
61:56 0x3d
55:53 ControlstheinputformatofthetexturebufferinRDRAM:
000RGBA
001YUV
010ColorIndex
011IntensityAlpha
011Intensity
52:51 Sizeofanindividualpixelintermsofbits:
004bits(ColorIndex,IA,I)
018bits(ColorIndex,IA,I))
1016bits(RGBA,YUV,IA)
1132bits(RGBA)
41:32 Widthoftexturebufferinmemoryminusone.Thisis
providedmerelyforconvenience,soindividualtexturescan
beeasilycopiedoutofacompositeimagemap.
25:0 Theaddressinmemorywherethetexturebufferresides.

TheSetTextureImagecommandsetsthelocationofthecurrenttexturebufferin
memorywheresubsequentLoadTilecommandssourcetheirdata.Individualtextures
arenotloadedbythiscommandasitonlygivestheRDPinformationonwheretextures
appearinRDRAMandhowtointerpretthememory.Beforeatexturecanbeusedbya
primitive,itstillneedstobeloadedintotexturememory.Whenrenderingtoaframe
bufferthatwillbeusedasatexturebufferinthefuture,besuretoperformaSyncFullto
ensureallprimitivesarerenderedtothetexturememory.

Page 13 of 25

RCPDocumentationRev.6
Oct.02,2010

SetZImage(64bits)

Function
Opcode
DRAMAddress

Bits
Description
61:56 0x3e
25:0 Theaddressinmemorywherethezbufferresides.

TheSetZImagecommandsetsthelocationofthezbufferinmemorywheretheRDP
shouldreadandwritepixeldepths.Theformatisa16bitintegerperpixelwiththevalue
of0denotinginfinitelyfaraway.ItisrecommendedtoclearthezbufferusingtheRDP
itselfmanygameswillsetthezbufferasthecolorimageanddrawablackrectanglethe
sizeofthescreentozerothedepthateverypixel.Thewidthandheightofthezbufferin
memory shouldmatchthecolorimage.Thiscommandisnotrequiredunlesstriangles
withdeptharedesired.Ifnozbufferingisused,theRDPwilldrawgeometryinthe
orderreceivedonthepipeline.
SetScissor(64bits)

Function
Opcode
XH
YH
ScissorField

Bits
61:56
55:44
43:32
25

Odd/Even

24

XL
YL

Description
0x2d
Xcoordinateofthetopleftcornerofthescissorbox.
Ycoordinatesofthetopleftcornerofthescissorbox.
Settoenablescissoringofoddorevenlinesforinterlaced
displays.
Specifieswhichfieldlinestoskip:

0Skipalloddlines
1Skipallevenlines
23:12 Xcoordinateofthebottomrightcornerofthescissorbox.
11:0 Ycoordinateofthebottomrightcornerofthescissorbox.

TheSetScissorcommandtellstheRDPtorasterizegeometryfallinginsidethescissor
box.Coordinatesaregivenwithrespecttoscreenspace.Ifneeded,evenoroddfield
linescanbeskippedforagivenscene.Ifnoclippingisdesired,setthescissorbox
cornerstotheabsoluteminimumandmaximumvalidpixellocations.

Page 14 of 25

RCPDocumentationRev.6
Oct.02,2010

SetOtherModes(64bits)

Function
Opcode
AtomicPrimitive
Enable
CycleType

Bits
Description
61:56 0x2f
55 Forceprimitivetobewrittentotheframebufferbefore
processingnextprimitive.
53:52 Pipelinerasterizationmode:

Perspective
CorrectionEnable
DetailTexture
Enable
SharpenTexture
Enable
TextureLOD
Enable
TLUTEnable

51

001Cycle
012Cycle
10Copy
11Fill
Enableperspectivecorrectionontextures.

50

Enabledetailtexture.

49

Enablesharpentexture.

48

Enabletexturelevelofdetail(mipmapping).

47

TLUTType

46

Enabletexturelookuptable.Thisisusefulwhentextures
arecolormappedbutthedesiredoutputtotheframebuffer
isRGB.
Typeoftexels(texturecolorvalues)inTLUTtable:

45

016bitRGBA(0bRRRRRGGGGGBBBBBA)
116bitIA(0xIIAA)
Typeoftexturesampling:

SampleType

MidTexelEnable
BiLinear
Interpolation0
BiLinear
Interpolation1
ColorConvert

44
43

ChromaKey
Enable

40

42
41

01x1(pointsample)
12x2
Enable2x2halftexelsamplingfortexturefilter.
Enablesbilinearinterpolationforcycle0when1Cycleor
2Cyclemodeisenabled.
Enablesbilinearinterpolationforcycle1when1Cycleor
2Cyclemodeisenabled.
Colorconvertthetexeloutputtedbythetexturefilteron
cycle0.
Enablechromakeying.

Page 15 of 25

RCPDocumentationRev.6
Oct.02,2010

Function
Bits
Description
RGBDitherType 39:38 TypeofditheringdonetoRGBvaluesin1Cycleor2Cycle
modes:
00Magicsquarematrix
01Bayermatrix
10Noise
11Nodither
AlphaDitherType 37:36 Typeofditheringdonetoalphavaluesin1Cycleor2
Cyclemodes:

Blendm1a,0
Blendm1a,1
Blendm1b,0
Blendm1b,1
Blendm2a,0
Blendm2a,1
Blendm2b,0
Blendm2b,1
ForceBlend
CoverageEnable
AlphaMultiply
Enable

ZMode

CoverageMode

31:30
29:28
27:26
25:24
23:22
21:20
19:18
17:16
14
13
12

00Pattern
01~Pattern
10Noise
11Nodither
Multiplyblend1ainputincycle0.
Multiplyblend1ainputincycle1.
Multiplyblend1binputincycle0.
Multiplyblend1binputincycle1.
Multiplyblend2ainputincycle0.
Multiplyblend2ainputincycle1.
Multiplyblend2binputincycle0.
Multiplyblend2binputincycle1.
Enableforceblend.
Enableuseofcoveragebitsinalphacalculation.
Enablemultiplyingcoveragebitsbyalphavalueforfinal
pixel alpha:

0Alpha=CVG
1Alpha=CVG*A
11:10 ModeselectforZbuffer:

9:8

00Opaque
01Interpenetrating
10Transparent
11Decal
Modeselectforhandlingcoveragevalues:
00Clamp
01Wrap
10Forcetofullcoverage
11Dontwriteback

Page 16 of 25

RCPDocumentationRev.6
Oct.02,2010

Function
ColoronCoverage
ImageRead
Enable
UpdateZEnable
ZCompareEnable
AntialiasEnable
ZSource

AlphaCompare

AlphaCompare
Enable

Bits
Description
7
Onlyupdatecoloroncoverageoverflow.Usefulfor
transparentsurfaces.
6
Enablecoverageread/modify/writeaccesstoframebuffer.
5
4
3
2

EnablewritingnewZvalueifcolorwriteisenabled.
Enableconditionalcolorwritebasedondepthcomparison.
Enableantialiasingbasedoncoveragebitsifforceblendis
notenabled.
SelectthesourceoftheZvalue:

0PixelZ
1PrimitiveZ
Selectsourceforalphacompare:

0Randomnoise
1Blendalpha
Enableconditionalcolorwritebasedonalphacompare.

Manyofthesemodesarepurelyoptionalandonlyaffectthequalityofthefinalimagein
theframebuffer.However,aselectfewofthemodesmustbesettoaspecificvaluefor
certainRDPcommandstoworkproperly.Fortheseoptions,thecommandinquestion
willspecifywhichmodesneedtobesetintheSetOtherModescommandtooperate
properly.Thetexturefilterreferredtomultipletimesissimplythe1Cycleor2Cycle
pipelinemode.Thisisnotenabledwhendoingcertainsimplegeometrysuchas
untexturedrectangles. ThecoveragebitsareonlyaccessibletotheRDPandtheDAC
chipsdoingthevideoconversiontodisplaytothescreen.TheRDRAMintheN64is
actually9bitswide,butonlythelower8bitsareaccessibletosoftware.Onebitof
coverageisassignedtoeachbyteintheframebuffer.Thismeansthat16bitRGBA
bufferswillinclude2coveragebitsperpixel,and32bitRGBAbufferswillinclude4
coveragebitsperpixel.Unlesscertainmodesaresetasspecifiedabove,thesecoverage
bitswillnotbeusedinthefinalcalculationwhensendingpixelcolorstotheTV.

Page 17 of 25

RCPDocumentationRev.6
Oct.02,2010

SetTile(64bits)

Function
Opcode
ColorFormat

Pixel Size

Bits
Description
61:56 0x35
55:53 Controlstheoutputformatoftherasterizedimage:
000RGBA
001YUV
010ColorIndex
011IntensityAlpha
011Intensity
52:51 Sizeofanindividualpixelintermsofbits:

TileLineSize

49:41

TMEMAddress

40:32

Tile
Palette

26:24
23:20

ClampEnableT

19

MirrorEnableT

18

MaskT
ShiftT
ClampEnableS

17:14
13:10
9

MirrorEnableS

MaskS
ShiftS

7:4
3:0

004bits
018bits(ColorIndex)
1016bits(RGBA)
1132bits(RGBA)
Thewidthofthetexturetobestoredintermsof64bit
words.
Thelocationintexturememorytostorethetextureinterms
of64bitwords.Thisimpliesthattexturesmustbe8byte
alignedinTMEM.
ThetileIDtogivethistexture.
For4bitsprites,thisisthepalettenumber.Ineffect,thisis
theupper4bitstomakean8bitcolorindex pixelwhich
willthenbelookedupinapalette.
EnablesclampingintheTdirectionwhentexturing
primitives.
EnablemirroringintheTdirectionwhentexturing
primitives.
NumberofbitstomaskormirrorintheTdirection.
LevelofdetailshiftintheTdirection.
EnablesclampingintheSdirectionwhentexturing
primitives.
EnablemirroringintheSdirectionwhentexturing
primitives.
NumberofbitstomaskormirrorintheSdirection.
LevelofdetailshiftintheSdirection.

TheSetTilecommandtellstheRDPaboutatexturethatistobeloadedoutofa
previouslyspecifiedTextureImage. TocalculatetheTileLineSizefield,multiplythe
widthofthetexturebythebitdepth(inbytes),rounduptothenextmultipleof8,and

Page 18 of 25

RCPDocumentationRev.6
Oct.02,2010

thendividetheresultingnumberby8. ForbothMaskSandMaskT,amaskvalueof2
wouldresultinthebitmaskof0x3.Ifmirrorenableisoffthecoordinateismaskedto
thismaskvalue,allowingtiling.Ifmirrorenableison tilingisenabledandthe
coordinateismirroredeveryothertile.Ifthisvalueis0thentheRDPdefaultsto
clampingforthecoordinate. Mirroring,tilingandclampingcanonlybedoneona
poweroftwoboundary,buttexturesthatdonotneedthesefeaturescanbeofarbitrary
sizeaslongastheyfitwithinTMEM.
LoadTile(64bits)

Function
Opcode
SLow
TLow
Tile
SHigh
THigh

Bits
61:56
55:44
43:32
26:24
23:12
11:0

Description
0x34
LowScoordinateoftexture (10.5fixedpointformat).
LowTcoordinateoftexture(10.5fixedpointformat).
ThetileIDtoloadthistextureinto.
HighScoordinateoftexture (10.5fixedpointformat).
HighTcoordinateoftexture (10.5fixedpointformat).

TheLoadTilecommandtellstheRDPtopullactualtexturedataoutofatexturesetby
SetTextureImageandplaceitinTMEMinatextureslotdefinedbySetTile. ThetileID
referencesatilethathasbeensetupbySetTile.S,TLow specifiesthelocationofthetop
leftcornerwheretexturecopyingshouldstart.S,THigh specifiesthelocationofthe
bottomrightcornerwheretexturecopyingshouldstop.Notethatatexturecopyincludes
therowandcolumnspecifiedbyS,THigh.ToloadsimpletexturesoutofRDRAMinto
TMEMonewoulduse0,0forS,TLow andS,THigh wouldbesettothewidthandheightof
thespriteminusone.NotethattheRDPstorestheS,TLow usedwhenloadingatexture
intoTMEMandcalculatesthemappingoftexturespacetoscreenspacerelativeto this
offset.

Page 19 of 25

RCPDocumentationRev.6
Oct.02,2010

SetFillColor(64bits)

Function
Opcode
PackedColor

Bits
Description
61:56 0x37
31:0 Colortofillnontexturedrectangleswith.

TheSetFillColorcommandtellstheRDPwhatcolortousewhenrasterizingaFill
Rectanglecommand.For32bitcolormode,thisistheRGBAvaluetoseteachpixelto.
For16bitcolormode,thisistwo16bitcolorspackedintoone32bitfield.Itispossible
torasterizeverticallystripedrectanglesbyspecifyingtwodifferent16bitcolorsinthe
SetFillColorcommand.

Page 20 of 25

RCPDocumentationRev.6
Oct.02,2010

DrawingCommands
ThedrawingcommandsaredependentonproperRDPsetupusingthecorrect
configuration commands.Effortwillbegiventoensurevalidsetupstepsarespecified
foreachofthedrawingcommands.
FillRectangle(64bits)

Function
Opcode
XLow
YLow
XHigh
YHigh

Bits
61:56
55:44
43:32
23:12
11:0

Description
0x36
LowXcoordinateofrectangle(10.2fixedpointformat).
LowYcoordinateofrectangle(10.2fixedpointformat).
HighXcoordinateofrectangle(10.2fixedpointformat).
HighYcoordinateofrectangle(10.2fixedpointformat).

TheFillRectanglecommandwilldrawarectangletotheframebufferusingthecolor
specifiedinaSetFillColorcommand. BeforeusingtheFillRectanglecommand,the
RDPmustbesetupinfillmodeusingtheCycleTypeparameterintheSetOtherModes
command.

Page 21 of 25

RCPDocumentationRev.6
Oct.02,2010

TextureRectangle(128bits)

Function
Opcode
XLow
YLow
Tile
XHigh
YHigh
S
T
DsDx
DtDy

Word Bits
Description
0x24
0
61:56
0
55:44 LowXcoordinateofrectangle(10.2fixedpoint
format).
0
43:32 LowYcoordinateofrectangle(10.2fixedpoint
format).
0
26:24 TileIDofthetexturetouse.
0
23:12 HighXcoordinateofrectangle(10.2fixedpoint
format).
0
11:0 HighYcoordinateofrectangle(10.2fixedpoint
format).
1
63:48 Scoordinateoftextureatthetopleftcornerofthe
rectangle(s.10.5fixedpointformat).
1
47:32 Tcoordinateoftextureatthetopleftcornerofthe
rectangle(s.10.5fixedpointformat).
1
31:16 ChangeinSperchangeinX(s.5.10fixedpoint
format).
1
15:0 ChangeinTperchangeinY(s.5.10fixedpoint
format).

TheTextureRectanglecommandwilldrawarectangletotheframebufferusingatexture
loadedwiththeLoadTexturecommand.BeforeusingtheFillRectanglecommand,the
RDPmustbesetupin copy modeusingtheCycleTypeparameterintheSetOther
Modescommand. TheS,TcoordinateistheS,TcoordinateofthetextureinRDRAM,
notinTMEM.Forexample,considerthefollowingsetup.Thereisa40x40texturein
RDRAMthatispointedtowiththeSetTextureImagecommand.A20x20textureis
loadedintomemoryusingaLoadTilecommandwithparametersS,TLow equalto20,20
andS,THighequalto39,39. A20x20texturedrectangleisdrawnusingaTexture
RectanglecommandwithparametersX,YLow equalto100,100andX,YHigh equalto119,
119. TheS,Tparametersinthiscasewouldbe20,20,not0,0.ThisisbecauseS,Tis
specifiedrelativetotheoriginaltexture,notthelocallycopiedoutportioninTMEM. To
displaysprites,onewouldnormallysetDsDxto4.0andDtDyto1.0.Itissuspectedthat
DsDxneedstobe4.0duetothePixelAdvanceparametergivenintheVIsetup.
Effectively,DsDxandDtDycanbeviewedastheinverseofthescalingvaluedesiredfor
horizontalandverticaltexturescaling.

Page 22 of 25

RCPDocumentationRev.6
Oct.02,2010

PipelineCommands
Thepipelinecommandsdonothaveanyparameters.Theysimplyinstructthegraphics
pipelinetostalluntilaparticularevent.Thisisusefulforsuchoperationsasensuring
primitivesareaffectedbytextureloadsandforcingrasterizationofallprimitivesbefore
swappingbuffers.
SyncLoad(64bits)

Function
Opcode

Bits
61:56 0x31

Description

SyncLoadwillstallanysubsequenttextureloadcommandsuntilallprecedinggeometry
hasbeenrasterized.Thisshouldbeplacedbeforealoadtexturecommandthatis
overwritingatextureorTLUTusedbyuptotwoprecedingprimitives.
SyncTile(64bits)

Function
Opcode

Bits
61:56 0x28

Description

SyncTilewillstallanytileloadoperationsuntilanyprecedingcommandfinishesreading
from texturememory.ItisunclearhowthisdifferssignificantlyfromSyncLoad.

Page 23 of 25

RCPDocumentationRev.6
Oct.02,2010

SyncPipe(64bits)

Function
Opcode

Bits
61:56 0x27

Description

SyncPipewillstallthepipelineuntilanyprimitiveonthepipelineisfinishedusing
previouslyissuedconfigurationcommands.ThisencompassesallstallsinSyncLoadas
wellasseveralotherconfigurationcommands. ThePrimitiveColorandPrimitiveDepth
commandsareexemptfromneedingaSyncPipe. IfoneiscarefultoorderRDP
commandsproperly,thiscanbeleftout.Forexample,settextureimagedoesnotaffect
therasterizationoftrianglesorrectangles,soitcanbecalledimmediatelyaftera
rectangleortrianglecommandwithouttheneedofaSyncPipetoseparate. Notethat
callingthisspuriouslywillcauserenderingartifactssuchastheRDPrenderinggeometry
tothewrongframebuffer. Inessence,donotcallSyncPipewhenthereisnothingthat
needstobewaitedon.
SyncFull(64bits)

Function
Opcode

Bits
61:56 0x29

Description

SyncFullwillstallthepipelineuntilthelastcommandthatreadsorwritesfromthe
framebufferfinishes.Thisisusefulforensuringanentiresceneisfullydrawnbefore
swappingframebuffersorreusingaframebufferasatextureimage. Beforepointingthe
VIattheframebufferinmemory,ensurethatthiscommandiscalledsothatallgeometry
appearsonthescreenwithoutflicker. Duetothefactthatoftenaprogrammustknow
whentheRDPhasfinishedprocessing,SyncFullwillcauseaDPinterruptwhenthe
RDPcompletesprocessingandencounterstheSyncFull.Thisistheonlycommandthat
causesaDPinterruptandthuscanbeusefulforprogramsthatmustwaitforrasterization
tocompletebeforecontinuing.SeetheMIPSInterface(MI)registersformoredetails.

Page 24 of 25

RCPDocumentationRev.6
Oct.02,2010

Glossary
FixedPointFormatAformatusedtorepresentfractionswithoutresultingtoa
floatingpointvalue.UsuallyspecifiedasM.NwhereMisthenumberofbitsinthe
wholenumberandNisthenumberofbitsinthefraction.AM.Nfixedpointnumber
isinterpretedasMN*2N. Sometimesrepresentedass.M.NwhichsignifiesaM.N
fixedpointnumberwithaleadingsignbit.As.M.Nfixedpointnumberisinterpreted
as1s *MN*2N
HalfLineUsedtorefertoaverticallinewithrespecttointerlacedvideomodes.
Forallintentsandpurposes,ahalflinecanbethoughtofasasinglerowofpixelsto
bedisplayedonthescreen.Inaninterlacedsetup,oddhalflineswillbedisplayed
oneframe,followedbyevenframesonthenext.
RDRAMMainmemoryoftheNintendo64.
ScreenCoordinatesCoordinatesystemusedtoreferencepixelsasrenderedonthe
screen.UsuallydenotedinX,Yfashionand0,0isthetopleftpixelonthescreen.
TextureCoordinatesCoordinatesystemusedtoreferencepixelsasfoundina
texture.UsuallydenotedinS,Tfashionand0,0isthetopleftpixelinaparticular
texture.
TMEM Texturememory.TheRDPhas4KBandusesthebottom2KBfortextures
andthetop2KBforpaletteentries.Insomecases,texturescanspanall4KB.

Page 25 of 25

You might also like