Sunteți pe pagina 1din 88

Gamedu|no keference Manua|

<<<to-uo: auu covei image>>>















Copyr|ght 2011 by Guy Garnett
guysphoLos aL me doL com



1hls work ls llcensed under Lhe CreaLlve Commons ALLrlbuLlon-
nonCommerclal-ShareAllke 3.0 unporLed Llcense. 1o vlew a copy
of Lhls llcense, vlslL hLLp://creaLlvecommons.org/llcenses/by-nc-
sa/3.0/ or send a leLLer Lo: !"#$%&'# !)**)+,- ./. 0#1)+2 0%"##%-
03&%# 455- 0$+ 6"$+1&,1)- !7 89.5:- ;07.
BRAFT uameuuino Refeience Nanual
ii
Contents
Acknow|edgements .................................................................................. 1
Introduct|on ............................................................................................. 1
Game rogramm|ng w|th Gamedu|no ....................................................... 2
uetting Staiteu ............................................................................................................................................................ 2
!"#$%"#& ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( )
*&+&,-./&01 20+3#-0/&01 (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( 4
Beveloping a uame ................................................................................................................................................... 4
Tools anu Techniques .............................................................................................................................................. S
50313", 6-%&#78. ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( 9
:"/&$;30- 6<1=-0 813,313&> ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( 9
?-0>&#+30@ A#$;30- B&/-#< (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( C
:"/&$;30- D&>-;#E& F3G#"#< ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( C
Cther App||cat|ons .................................................................................... 7
ueneial-Puipose Bisplay Auaptei ...................................................................................................................... 7
Inuustiial Piocess Contiol ..................................................................................................................................... 7
Advanced Gamedu|no rogramm|ng ......................................................... 8
V|deo 1|m|ng ............................................................................................ 8
Fiame Rate ................................................................................................................................................................... 8
Beam Synchionization .......................................................................................................................................... 1u
*-;G,& H;II&#30@ ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( JK
8.$"130@ LII7ME#&&0 LGN&E1> (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( JJ
O&#13E", H,"0P30@ (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( J)
D">1&# ?=">30@ (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( J4
Bitmappeu uiaphics ............................................................................................................................................... 1S
nardware nack|ng .................................................................................. 16
C|rcu|t 8oard Mod|f|cat|ons .................................................................... 16
uameuuino Nouifications .................................................................................................................................... 16
}oystick Shielu Nouifications .............................................................................................................................. 16
Do-It-ourse|f ro[ects ............................................................................ 17
Inputs anu Contiolleis .......................................................................................................................................... 17
Enclosuies anu Cases ............................................................................................................................................. 17
Gamedu|no 1echn|ca| keference ............................................................. 18
nardware Interface ................................................................................. 18
Baiuwaie Compatibility ....................................................................................................................................... 18
SPI Communication ................................................................................................................................................ 19
F3G#"#< M;..-#1 ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( )K
A,1&#0"1& M65 A$$#&>> (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( )K
Memory Map .......................................................................................... 20
uameuuino Nemoiy Nap ..................................................................................................................................... 21
BRAFT uameuuino Refeience Nanual
iii
Contiol Registeis ..................................................................................................................................................... 22
M="#&$ D&@3>1&#> (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( )4
V|deo D|sp|ay .......................................................................................... 28
Sciolling ....................................................................................................................................................................... 29
Q#"."#-;0$ (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( )R
M.,31 ME#&&0 ME#-,,30@ ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( 4K
Backgiounu Coloi .................................................................................................................................................... Su
Chaiactei uiaphics ................................................................................................................................................. Su
DABS65?T 6,"<I3&,$ 63E1;#& ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( 4J
DABS?!DT 6,"<I3&,$ ?="#"E1&# M&1 (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( 4J
DABS6AFT 6,"<I3&,$ ?="#"E1&# 6",&11&> (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( 4)
Spiites ........................................................................................................................................................................... 4S
M.#31& ?-01#-, (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( U4
M.#31& ?-,,3>3-0 *&1&E13-0 (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( UU
M.#31& 5/"@& *"1" ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( U9
M.#31& 6",&11&> ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( U9
Coloi .............................................................................................................................................................................. 47
F-@3E", ?-,-# ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( UV
!"#$%"#& ?-,-# ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( UV
L;1.;1 ?-,-# (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( UW
Aud|o ...................................................................................................... 49
Sounu Synthesis Registeis ................................................................................................................................... 49
O-3E& ?-01#-, ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( UR
D30@ B-$;,"1-# (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( 9J
Sample Registeis ...................................................................................................................................................... S1
I1 Coprocessor ........................................................................................ S3
Copiocessoi Inteiface ............................................................................................................................................ SS
?-.#-E&>>-# ?-01#-, ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( 94
?-.#-E&>>-# B3E#-E-$& ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( 94
?-.#-E&>>-# ?-//;03E"13-0> H,-EP ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( 94
?-.#-E&>>-#7L0,< D&@3>1&#> (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( 9U
}1 Aichitectuie anu Piogiamming ................................................................................................................... S6
X-#1=7H">&$ A>>&/G,< F"0@;"@& ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( 9W
8>30@ 1=& YJ A>>&/G,&# (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( CJ
YJ A>>&/G,< F"0@;"@& D&I&#&0E& ((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( CJ
Coue 0ptimization ................................................................................................................................................... 7S
YJ B3E#-E-$& (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((( VV
Screenshot Ieature ................................................................................. 78
Scieenshot Line Select Registei ........................................................................................................................ 78
Scieenshot Line Buffei .......................................................................................................................................... 79
G|ossary .................................................................................................. 80
Acionyms .................................................................................................................................................................... 8u
Time ............................................................................................................................................................................... 8u

BRAFT uameuuino Refeience Nanual
iv
Code
Sketch 1: Wait foi uameuuino Initialization .................................................................................. S
Sketch 2: Initialization with Splash Scieen .................................................................................... S
Sketch S: uame Loop using uB::waitvblank() ............................................................................. 1S
Sketch 4: SPI Initialization ................................................................................................................... 2u
Sketch S: }1 Assembly Piogiam Template .................................................................................... S6
Sketch 6: Example Subioutine ........................................................................................................... 7S
Sketch 7: Example Nultiple-Entiy Subioutine ........................................................................... 7S
Sketch 8: Inciementing Loop ............................................................................................................. 74
Sketch 9: Beciementing Loop ............................................................................................................ 74
BRAFT uameuuino Refeience Nanual
v

1ab|es
Table 1: 8uux6uu SvuA viueo 0utput .............................................................................................. 8
Table 2: viueo Fiame Rate .................................................................................................................... 9
Table S: veitical Blanking .................................................................................................................... 12
Table 4: Bost Inteiface .......................................................................................................................... 18
Table S: Baiuwaie Compatibility List ............................................................................................ 18
Table 6: uameuuino Nemoiy Nap ................................................................................................... 21
Table 7: IBENT Registei ....................................................................................................................... 24
Table 8: REv Registei ............................................................................................................................ 24
Table 9: FRANE Registei ...................................................................................................................... 24
Table 1u: vBLANK Registei ................................................................................................................ 24
Table 11: SCR0LL_X anu SCR0LL_Y Registeis ............................................................................ 2S
Table 12: }K_N0BE Registei ............................................................................................................... 26
Table 1S: }1_RESET Registei .............................................................................................................. 26
Table 14: SPR_BISABLE Registei ...................................................................................................... 26
Table 1S: SPR_PAuE Registei ............................................................................................................. 27
Table 16: I0N0BE Registei ................................................................................................................ 27
Table 17: Bu_C0L0R Registei ............................................................................................................ 27
Table 18: SANPLE_L anu SANPLE_R Registeis .......................................................................... 27
Table 19: SCREENSB0T_Y Registei ................................................................................................. 28
Table 2u: SCR0LL Registeis ................................................................................................................ 29
Table 21: Bu_C0L0R Registei ............................................................................................................ Su
Table 22: RAN_CBR Bitmap 0iganization ................................................................................... S1
Table 2S: Chaiactei Sets ....................................................................................................................... S2
Table 24: RAN_PAL Palette Foimat ................................................................................................ SS
Table 2S: RAN_PIC Nemoiy Nap ..................................................................................................... S4
Table 26: RAN_CBR Nemoiy Nap ................................................................................................... SS
Table 27: RAN_PAL Nemoiy Nap .................................................................................................... S9
Table 28: Spiite Contiol Woiu ........................................................................................................... 4S
Table 29: Spiite Palette Noues .......................................................................................................... 44
Table Su: Spiite Rotation ..................................................................................................................... 44
Table S1: Spiite Image Bitmap .......................................................................................................... 4S
Table S2: RAN_SPRPAL Nemoiy Nap ............................................................................................ 46
Table SS: PALETTE16 Nemoiy Nap ............................................................................................... 46
Table S4: 16-Coloi Spiite Palette ..................................................................................................... 46
Table SS: PALETTE4 Nemoiy Nap .................................................................................................. 47
Table SS: 4-Coloi Spiite Palette ........................................................................................................ 47
Table S6: Palette Entiy Foimat ......................................................................................................... 48
Table S7: Coloi Space ............................................................................................................................ 48
Table S9: v0ICES Nemoiy Nap ........................................................................................................ 49
Table 4u: SANPLE_L anu SANPLE_R Registeis .......................................................................... S2
Table S8: }1_RESET Registei .............................................................................................................. SS
Table S9: }1_C0BE Nemoiy Nap ...................................................................................................... SS
Table 4u: C0NN Nemoiy Nap .......................................................................................................... S4
BRAFT uameuuino Refeience Nanual
vi
Table 41: YLINE Registei ..................................................................................................................... S4
Table 42: FPuA ICAP Registeis .......................................................................................................... SS
Table 4S: FREQBZ anu FREQTICK Registeis ............................................................................... SS
Table 44: P2 I0 Registeis ................................................................................................................... SS
Table 4S: RANB0N Registei ............................................................................................................... S6
Table 46: CL0CK Registei .................................................................................................................... S6
Table 47: FLASB SPI Registeis .......................................................................................................... S6
Table 48: }1 Assembly Language Summaiy ................................................................................. S9
Table 49: }1 Assemblei Biiectives ................................................................................................... 61
Table Su: }1 Liteial Instiuctions ....................................................................................................... 62
Table S1: }1 ANS Foith Instiuctions ................................................................................................ 6S
Table S2: }1 Auuitional Instiuctions ............................................................................................... 66
Table SS: }1 Nulti-Woiu Instiuctions ............................................................................................. 66
Table S4: }1 Neigeu Instiuctions ..................................................................................................... 67
Table SS: }1 Assemblei Flow Contiol ............................................................................................. 71
Table S6: }1 Niciocoue Instiuctions ............................................................................................... 77
Table S7: AL0 0peiation Coues ........................................................................................................ 78
Table S8: Bata Stack Aujustment ..................................................................................................... 78
Table S9: Retuin Stack Aujustment ................................................................................................. 78
Table 6u: SCREENSB0T_Y Registei ................................................................................................. 78
Table 61: SCREENSB0T Nemoiy Nap ........................................................................................... 79

BRAFT uameuuino Refeience Nanual
vii

I|gures
Figuie 1: viueo Bisplay Layeis .......................................................................................................... 27
Figuie 2: Sciolling ................................................................................................................................... 27
Figuie S: Scioll Wiapaiounu .............................................................................................................. 28
Figuie 4: }1 Logical Aichitectuie ...................................................................................................... S6

BRAFT uameuuino Refeience Nanual
viii
kesources
Resouice 1: Baiuwaie Souices ........................................................................................................... 2
Resouice 2: Softwaie Bownloau Links ............................................................................................ S

BRAFT uameuuino Refeience Nanual
1

8-8|t Gam|ng w|th Ardu|no and Gamedu|no
Acknow|edgements
}ames Bowman cieateu the uameuuino, anu without his help, input, anu coiiections
this uocument woulu not exist. Any valuable infoimation in this manual ultimately
comes fiom }ames, anu any eiiois that weie intiouuceu in the piocess aie mine.

The membeis of the uameuuino-Beta mailing list, paiticulaily Colin Booley
pioviueu valuable feeuback anu encouiagement baseu on initial uiafts of this
manual.
Introduct|on
Nouein miciocontiolleis, like the Atmel AvR piocessois that powei the open-
souice Aiuuino boaius, aie at least as poweiful as the 8-bit CP0s that poweieu
aicaue viueo games in the "goluen age" of the 198u's. Foi example, the Zilog Z8u
was an auvanceu 8-bit CP0 that also featuieu limiteu 16-bit instiuctions. The Z8u
ian at speeus of up to a million instiuctions pei seconu, anu poweieu classic games
such as Pac Nan, Bonkey Kong, anu ualaxian. By compaiison, the ATmegaS28 that
is at the heait of the Aiuuino 0no executes up to 16 million 8-bit instiuctions pei
seconu.

The uameuuino is an Aiuuino shielu that pioviues vuA viueo anu steieo auuio
output suitable foi "classic" viueo gaming using custom FPuA haiuwaie. 0nlike
othei Aiuuino-baseu viueo game piojects, the uameuuino pioviues extensive
haiuwaie suppoit foi foiegiounu anu backgiounu coloi giaphics, collision
uetection, anu sounu geneiation. The uameuuino uses a simple SPI inteiface so it is
auaptable to many uiffeient miciocontiolleis, anu is poweiful anu flexible enough
that it can be useu foi significant non-game applications.
BRAFT uameuuino Refeience Nanual
2
Game rogramm|ng w|th Gamedu|no
!"##$%& (#)*#"+
nardware
To uo anything useful with a uameuuino, you will neeu a compatible
miciocontiollei, a uameuuino boaiu, as well as a monitoi, speakeis, anu some soit
of game contiollei oi othei input uevice. If you want to get staiteu with the example
coue anu sketches in this book, in auuition to youi computei, you will neeu:
An Aiuuino 0no oi Nega2S6u
A uameuuino shielu, anu
A SpaikFun joystick shielu; plus
Speakeis oi heauphones foi sounu output, anu
A monitoi that suppoits 8uux6uu 72Bz anu an analog vuA input.
The Baiuwaie Souices text box below suggests some places wheie you can obtain
the components mentioneu in this book. 0thei haiuwaie configuiations aie
ceitainly possible - since this is an Aiuuino pioject, cieative oi home-built solutions
aie encouiageu.

<<<To-uo: iefeience a section on builuing youi own inteiface haiuwaie>>>
!"#$%"#& ())&*+,-
Aiiange the monitoi anu speakeis in youi woik aiea so that they aie accessible but
out of the way. You will want to place the Aiuuino anu uameuuino haiuwaie
somewheie convenient, so that you can use the joystick boaiu to test youi game
sketches while keeping it connecteu to youi computei anu the monitoi anu
speakeis. Then put eveiything togethei:
1. Check the shielus foi bent pins, anu gently stiaighten any that aie out of
place.
2. Stack the uameuuino shielu on top of the Aiuuino, anu push the shielu's pins
into the heauei. Check foi bent pins anu make suie the shielu is secuiely
seateu.
Aiuuino boaius: http:aiuuino.ccenNainBuy

uameuuino shielu: To be ueteimineu!

}oystick shielu kit: http:www.spaikfun.compiouucts976u
Baie joystick shielu boaiu: http:www.spaikfun.compiouucts949u


!"#$%&'" )* +,&-.,&" /$%&'"#
BRAFT uameuuino Refeience Nanual
S
S. Stack the joystick shielu on top of the uameuuino, again checking foi bent
pins anu ensuiing that the shielu is fiimly seateu. It woulu not uo to have the
stack come apait while playing youi game sketch.
4. Connect the monitoi anu speakeis to the poits on the uameuuino.
.*/0& 1&)2
A "smoke test" is the initial test of a new haiuwaie system - the iuea is to make suie
that eveiything woiks (anu uoesn't have any shoit ciicuits oi othei show-stoppeis)
befoie uoing anything moie complicateu. To test youi haiuwaie:
1. Powei-on the monitoi anu speakeis.
2. Boot up youi computei. 0nce the computei is iunning,
S. Connect youi computei to the Aiuuino using a 0SB cable (oi optionally, you
can use a wall-powei auaptei suitable foi the Aiuuino).
4. Piess the ieset button on the joystick shielu.

You shoulu get some output fiom the uameuuino on the monitoi anu speakeis.
What you get will uepenu on what is loaueu onto the system, eithei:
The Asteioius game sketch will stait with the "ASTER0IBS" logo scioll, if
youi Aiuuino came with the uameuuino, it shoulu be pie-loaueu with this
sketch; oi
If you have a "stock" Aiuuino that uoesn't (yet) have any uameuuino-awaie
sketches loaueu onto it, you will get the uameuuino's boot scieen, featuiing
the uameuuino logo anu stait-up sounu.
If you uon't get output fiom the uameuuino, oi get something wiluly uiffeient, tiy
some of the tioubleshooting steps below to isolate the pioblem.
1#/3+,&)4//2567

<<<To-uo: auu tioubleshooting infoimation>>>
Deve|opment Lnv|ronment
Now that the haiuwaie is set up, you will also neeu a uevelopment enviionment
befoie you can stait cieating youi own viueo game sketches. The basic uameuuino
uevelopment enviionment consists of:
A computei iunning iecent veisions of eithei Winuows, Nac 0S X, oi Linux,
The Aiuuino integiateu uevelopment enviionment (IBE), anu
The uameuuino softwaie uevelopment kit (SBK).
visit the uownloau links listeu below to get the softwaie you neeu.
Aiuuino IBE: http:aiuuino.ccenNainSoftwaie
uameuuino SBK: http:excameia.comsphinxgameuuinosamplesinuex.html
!"#$%&'" 0* /$12.,&" 3$.45$,- 6748#
BRAFT uameuuino Refeience Nanual
4
86)2",,"25/6 "6$ .&29:;
0nce you have all of the pieces, you can set up youi uevelopment enviionment. The
exact steps will vaiy uepenuing on youi choice of opeiating system, but the
following steps shoulu seive to get you staiteu:
1. Install the Aiuuino IBE following the instiuctions that came with the binaiy
uistiibution foi youi platfoim.
2. veiify that the Aiuuino IBE is woiking coiiectly by launching the IBE anu
selecting an example sketch fiom the File menu. Bo not attempt to compile
oi iun this example; we aie just veiifying that the Aiuuino IBE is woiking.
S. 0npack the uameuuino SBK uistiibution by unzipping the uameuuino.ZIP
aichive file. This will cieate a "uameuuino" uiiectoiy with multiple files anu
subuiiectoiies insiue of it. Note the location of the uameuuino uiiectoiy foi
use in step 6 below.
4. Locate youi Aiuuino sketchbook uiiectoiy. The uefault location will vaiy
uepenuing on youi opeiating system, but shoulu be a subuiiectoiy of youi
usei oi home uiiectoiy. You can finu anu change the sketchbook location
using the Piefeiences option of the Aiuuino IBE.
S. If it uoesn't alieauy exist, cieate a uiiectoiy calleu "libiaiies" insiue of the
Aiuuino sketchbook uiiectoiy. If the uiiectoiy alieauy exists, skip this step.
6. Nove the uameuuino uiiectoiy fiom step S into the libiaiies uiiectoiy
cieateu in step S above.
8<= "6$ .<> 1&)2567
0nce eveiything is installeu, you shoulu test the uameuuino uevelopment
enviionment befoie staiting to woik on youi own sketches. To test the tool chain:
1. Quit the Aiuuino IBE if it is still iunning, then launch the Aiuuino IBE.
Quitting anu ie-staiting the IBE foices it to ie-scan the sketchbook anu
libiaiies.
2. Loau a uameuuino uemo piogiam: go to the File menu, anu using the
submenus pick Examples, uameuuino, 4.Bemo, anu finally "ball". The ball
sketch shoulu open in a new winuow.
S. Compile the sketch using the veiify button on the Aiuuino IBE. It shoulu
compile with no eiiois oi wainings.
4. 0ploau the sketch to the Aiuuino anu iun it, by using the 0ploau button on
the IBE. Aftei a biief pause, the bouncing-ball uemo shoulu be uisplayeu on
the monitoi with accompanying auuio output on the speakeis.
Congiatulations! You now have a functioning uameuuino uevelopment
enviionment, anu you aie ieauy to stait wiiting youi fiist game sketch.
,"-"./0$%& ) !)1"

<<<to-uo: auu infoimation as the TB0B game is uevelopeu>>>

BRAFT uameuuino Refeience Nanual
S
2//.3 )%+ 2"45%$67"3
In|t|a| ower-Up
Following a haiu ieset, such as initial powei-on, the uameuuino iequiies a shoit
amount of time to ieboot, loau the FPuA configuiation, anu initialize befoie it is
ieauy to accept commanus. This isn't noimally an issue when ueveloping coue in the
Aiuuino IBE, since uownloauing a new sketch oi iesetting the Aiuuino uoesn't foice
a uameuuino ieset. The uameuuino libiaiy noimally hanules this in the uB.begin()
methou by making suie that the uameuuino is ieauy to accept commanus befoie
initializing the boaiu anu ietuining.

If you aie not using the libiaiy, youi sketch will have to hanule this manually. It
takes the uameuuino between 17Sms anu 2Sums to complete its powei-on
initialization. The uameuuino may ignoie oi fail to fully iesponu to SPI commanus
that aiiive befoie this time, so sketches may have unpieuictable sounu anu giaphic
aitifacts until the Aiuuino is ieset. Resetting the Aiuuino fixes the pioblem, since
the ieset foices the Aiuuino to ie-iun its setup() methou without foicing a haiu
ieset of the uameuuino. Bowevei, this solution isn't veiy piactical foi final coue
that is going to be embeuueu in a uevice.

The best solution to the pioblem is to
ensuie that the uameuuino is
iesponuing to commanus befoie
senuing instiuctions to it. Sketch 1:
Wait foi uameuuino Initialization
shows one such appioach using uB libiaiy functions foi bievity anu claiity. This
coue fiagment iepeateuly wiites a known, non-uefault value to uameuuino RAN,
until attempting to ieau the RAN iesults in the value wiitten - uemonstiating that
the uameuuino has accepteu anu piocesseu both commanus.

Anothei appioach is to inseit a uelay
into the coue befoie attempting to
communicate with the uameuuino. A
uelay of at least 2Sums will allow the
uameuuino enough time to initialize
anu iesponu to commanus; a longei
uelay will allow the powei-on splash scieen to uisplay. As shown by, Sketch 2:
Initialization with Splash Scieeneven if you aie using the uameuuino libiaiy,
inseiting a uelay befoie calling uB.begin() will allow the splash scieen to appeai at
powei-up.
Gamedu|no ython Ut|||t|es

<<<to-uo: auu infoimation about the Python utility package>>>
do {
GD.wr(RAM_SPRIMG, 0xFF);
} while (GD.rd(RAM_SPRIMG) != 0xFF);
GD.wr(RAM_SPRIMG, 0x00);
/8"2'9 )* :,72 1$& ;,<"-%74$ =4727,57>,27$4
void setup() {
delay(2500);
GD.begin();
}
/8"2'9 0* =4727,57>,27$4 .729 /?5,#9 /'&""4
BRAFT uameuuino Refeience Nanual
6
Conserv|ng Ardu|no Memory

<<<to-uo: auu note about PR0uNEN fiom the cookbook page>>>
<<<to-uo: auu notes fiom uameuuino-Beta list about conseiving memoiy>>>
Gamedu|no kesource L|brary

<<<to-uo: auu uesciiption of the libiaiy anu how to access it>>>

BRAFT uameuuino Refeience Nanual
7
Cther App||cat|ons
The uameuuino has a numbei of poweiful non-game applications as a veisatile
viueo auaptei foi Aiuuino anu potentially othei miciocontiolleis. Since it uses
stanuaiu vuA monitois foi infoimation output, it is a cost-effective anu veisatile
uisplay auaptei. Compaieu to most othei Aiuuino output uevices, the uameuuino's
viueo uisplay can piesent a lot of infoimation. A uameuuino can piesent at least ten
times the chaiactei infoimation as a typical multi-line LCB uisplay, oi almost twice
as many on-scieen pixels as a QvuA scieen.
!"%"*).897*0/3" ,$30.): ;+)0#"*
As a geneial-puipose uisplay auaptei, the uameuuino vuA scieen can contain S7
lines of Su chaiacteis each, which compaies well to a typical seiial LCB. Seiial LCBs
commonly useu with the Aiuuino uisplay 1 to 4 lines of 8 to S2 chaiacteis. The two
uevices typically have similai inteiface iequiiements: an SPI oi seiial connection
uses a few Aiuino pins. Nany LCB contiolleis will also accept uownloauable
chaiactei sets, allowing the piogiammei to uefine application-specific glyphs.

0nlike seiial uisplay auapteis, the uameuuino iequiies moie initialization: a
complete chaiactei set (even the base ASCII glyphs) must be stoieu in the host
miciocontiollei's piogiam EEPR0N anu uownloaueu to the uameuuino befoie any
uata can be output. Nost LCB uisplays incluue a built-in extenueu ASCII chaiactei
set that can be useu immeuiately.

Spiite giaphics can be useu to implement cuisois oi pointeis. Alteinatively, the
uameuuino's spiite memoiy can be aiiangeu as a high-iesolution giaphics oveilay
that can be auuiesseu at the single pixel level, as uesciibeu in the section on
Bitmappeu uiaphics beginning on page 1S. This allows an aiea of aibitiaiy high-
iesolution giaphics on an otheiwise text-baseu scieen.
<%+73#*$). 9*/4"33 =/%#*/.
The uameuuino can also be useu foi inuustiial piocess-contiol anu systems status
monitoiing applications. Because it has a ielatively simple, SPI-baseu host inteiface,
it can be contiolleu by neaily any piocess contiollei oi automation miciocontiollei
that suppoits SPI communication. Because the entiie chaiactei set is customizable
on the uameuuino, specializeu symbols specific to the application can be
uownloaueu anu easily uisplayeu.

Chaiactei giaphics in combination with the uameuuino's spiite giaphics can be
useu to implement gauges anu pointeis, anu pioviue a unique way of piesenting
infoimation in an easy-to-unueistanu visual foimat. Foi example, a bai giaph scale
can be built fiom a small numbei (S oi 4) of chaiacteis, anu a spiite can be useu as
an inuicatoi to visually iepiesent the measuiement value.

<<<to-uo: inseit scieenshot anu example sketch showing gauges>>>
BRAFT uameuuino Refeience Nanual
8
Advanced Gamedu|no rogramm|ng
V|deo 1|m|ng
The uameuuino geneiates a SvuA viueo signal that confoims to the stanuaius foi
72Bz 8uux6uu viueo with a SuNhz uot clock. Table 1: 8uux6uu SvuA viueo 0utput
summaiizes the ciitical viueo timing paiameteis. See http:tinyvga.comvga-
timing8uux6uu72Bz foi uetaileu vESA vuA signal timing infoimation.

@,A5" )* BCCDECC /F;G F7-"$ H%2?%2
Boiizontal Timing
Pixel Clock Su.uNhz
Fiequency 48.u77kBz
Resolution 8uu pixels
|1j
Active viueo 16.us
Blanking 4.8s
veitical Timing
Fiequency 72Bz
Resolution 6uu lines
|2j
Active viueo 12.48ums
Blanking 1.S728ms
Notes:
|1j
uameuuino uoubles pixels foi a hoiizontal iesolution of 4uu uouble-size pixels.
|2j
uameuuino uoubles scan lines foi a veitical iesolution of Suu uouble-size pixels.

Theie aie two keys to achieving smooth viueo game animation: fiame iates anu
beam synchionization. Fiame iate iefeis to how often we upuate the scieen
infoimation, anu beam synchionization uictates when we upuate that infoimation.
>*)1" ?)#"
The uameuuino geneiates viueo at 72Bz, oi 72 fiames pei seconu (fps) no mattei
what oui game piogiamming is uoing. Bowevei, we can choose how often oui
piogiam upuates the scieen, iesulting in a logical fiame iate that uiffeis fiom the
72fps haiuwaie fiame iate. By upuating the uisplay eveiy 2
nu
, S
iu
, oi 4
th
fiame,
uameuuino softwaie can geneiate lowei-fiequency uisplays. The lowei uisplay
fiequencies allow the game piogiam moie computation time between upuates, anu
also ieuuce the amount of infoimation that has to be tiansfeiieu each seconu.

viueo uisplays uepenu on peisistence of vision to smooth out the flickei between
uiffeient fiames. The point wheie inuiviuual fiames smooth out vaiies between
peison to peison, changes with uiffeient lighting conuitions, anu can also uepenu on
the speeu of the game oi animation. A highei fiame iate means moie fiequent
(fastei) upuates mean that on-scieen objects appeai to move smoothly. A low fiame
iate makes on-scieen objects appeai to flickei oi jeik acioss the scieen. An
inconsistent oi vaiiable fiame iate may make things appeai to stuttei oi move
eiiatically. The point wheie things appeai to be smooth is usually somewheie
BRAFT uameuuino Refeience Nanual
9
between Sufps anu 6ufps, but uepenus gieatly on both the content of the scieen anu
the viewei. Foi example, movie theateis use a 24fps fiame iate foi most cinematic
ieleases, but still achieve the illusion of smooth continuous motion.

The uameuuino's 72fps haiuwaie viueo geneiation is comfoitably above this visual
limit. uames that can iun at this iate shoulu be smooth anu flickei-fiee, so most
game sketches shoulu stiive foi this goal. Softwaie may achieve highei upuate
fiequencies, but the haiuwaie that geneiates the vuA output signal only upuates the
scieen 72 times pei seconu.

A S6fps fiame iate, oi upuates eveiy othei fiame, is still fast enough to appeai
smooth unuei many conuitions. Fast-moving objects (like a piojectile) oi high-
contiast items (like white stais on a black backgiounu) may appeai to flickei oi
stuttei foi some vieweis. This iate is often a goou compiomise, since it allows twice
the computation time between fiames but is still smooth.

The 24fps fiame iate is the same as movie piojectois, anu is the slowest iate that
can appeai smooth to most vieweis. 0bjectionable flickei, jittei, oi othei visual
aitifacts may be appaient unuei some lighting conuitions, on fast-moving objects, oi
when theie is high contiast between sequential fiames.

Fiame iates of 18fps will appeai to flickei, stuttei, oi have noticeable visual aitifacts
to most vieweis. Bowevei, this fiame iate allows foi plenty of computation time
between fiames, anu may be suitable foi ceitain kinus of games, paiticulaily
stiategic games that uon't featuie fast-moving action.

Some kinus of games can benefit fiom selective upuates: fast-moving oi high
contiast poitions of the uisplay shoulu be upuateu moie fiequently, while othei
items aie upuateu less often. Foi example, a space game might upuate a sciolling
backgiounu at 72fps, but coulu use a S6fps fiame iate foi spiite animations to save
memoiy anu piocessoi time.

The main ieason foi choosing a logical fiame iate lowei than 72fps is to allow
piogiams that iequiie extensive computation between fiames to complete theii
woik anu upuate the scieen. The table below shows how much time is available.

@,A5" 0* F7-"$ I&,<" !,2"

Rate

Biv

Skip

Time
Cycles pei Fiame
Aiuuino SPI }1
72 fps 1 u 1S.88ms 222,222 1S,888 694,444
S6 fps 2 1 27.77ms 444,444 27,777 1,S88,888
24 fps S 2 41.66ms 666,666 41,666 2,u8S,SSS
18 fps 4 S SS.SSms 888,888 SS,SSS 2,777,777
D"1&: Logical fiame iate, in fiames pei seconu (fps).
*3+: Fiame iate uivisoi. Logical fiame iate = 72fps haiuwaie fiame iate - Biv.
MP3.: Numbei of fiames skippeu between upuates.
BRAFT uameuuino Refeience Nanual
1u
Z3/&: Elapseu time between upuates, in milliseconus (ms; 1ms = 11u
-S
seconus).
A#$;30-: Numbei of instiuction cycles between upuates assuming a 16Nhz ATmega8
piocessoi. Some AvR instiuctions take moie than one cycle.
M65: Numbei of SPI byte tiansfeis between upuates assuming a 16Nhz SPI bus clock.
The uameuuino SPI inteiface iequiies two auuiess bytes to set up a tiansfei, plus
one byte pei uata byte ieau oi wiitten to uameuuino memoiy.
YJ: Numbei of instiuction cycles between upuates foi the uameuuino's }1 copiocessoi.
Nost copiocessoi instiuctions take one cycle, although memoiy ieau anu wiite
instiuctions take two cycles.
@")1 (:%45*/%$A)#$/%
Although the uameuuino's uouble-poiteu RAN allows piogiams to upuate giaphics
uata without pieventing the viueo geneiatoi fiom fetching uata, upuating giaphics
uata that is cuiiently being uiawn on the scieen can cause teaiing oi othei glitches
in the viueo output. Foi example, if we upuate a spiite's Y position while it is being
uiawn on scieen, a few lines of the spiite will appeai at the olu location, anu the iest
will appeai at the new location, making the spiite look like it is toin in half.

<<<to-uo: inseit toin spiite image>>>

The solution is to upuate objects when they aie not being uiawn on the scieen. This
can be uone via uouble buffeiing, upuating off-scieen objects, by waiting foi veitical
blanking, anu by iastei chasing techniques.
Doub|e 8uffer|ng
0ne obvious solution to the pioblem is to keep two copies (buffeis) of eveiything:
one is useu to uiaw the uisplay while the othei is being upuateu. When the upuate is
uone, the two buffeis aie swappeu anu the newly upuateu copy is useu to uiaw the
next fiame of the uisplay. The big uiawback to uouble buffeiing is that it iequiies a
lot of memoiy, anu some way of quickly swapping the two buffeis. The uameuuino
haiuwaie suppoits tiue uouble buffeiing foi spiite contiol uata, anu limiteu uouble
buffeiing foi the spiite bitmaps anu chaiactei pictuie.

Bouble buffeiing foi spiites is contiolleu by the SPR_PAuE iegistei at ux28uB
(1u2S1 uecimal). When SPR_PAuE is u, spiite contiol uata page u is on scieen: the
uata in locations uxSuuu to uxSSFF (12288 to 1SS11 uecimal) is useu to geneiate
the uisplay. When page u is being uisplayeu, the spiite contiol uata stiuctuies on
page 1 at locations uxS4uu to uxS7FF (1SS12 to 14SSS uecimal) can be upuateu
without causing visual glitches. Setting SPR_PAuE to 1 ieveises the situation: page
1 uata is useu to uiaw the scieen uisplay, anu page u can be upuateu.

To implement spiite uouble buffeiing in youi sketches, assuming that youi sketch is
fast enough to upuate the spiites eveiy fiame:
1. Initialize spiite contiol uata pages u anu 1 with the same uata, uefining the
same spiites on each page.
2. Initialize SPR_PAuE to u.
S. Wait foi veitical blanking.
BRAFT uameuuino Refeience Nanual
11
4. Toggle SPR_PAuE: set it to 1 if it is cuiiently u, oi set it to u if it was 1.
S. 0puate spiite positions, bitmaps, anu othei attiibutes by changing values in
the non-uisplayeu page: if SPR_PAuE is u, upuate the spiites staiting at
uxS4uu; if SPR_PAuE is 1 upuate the spiites staiting at uxSuuu.
6. uo to Step S to uiaw the next fiame.

If youi game uoesn't use all of the spiite bitmap memoiy, you can also uouble buffei
spiite bitmaps. Without using this type of uouble buffeiing, the veitical blanking
peiiou is so shoit that it is uifficult to ieuefine spiite image uata in RAN_SPRINu
befoie the uisplay is uiawn. Because each bitmap is 2S6 bytes, theie is enough time
to upuate 4 oi S spiite bitmaps if the SPI bus isn't useu foi anything else uuiing
veitical blanking. Bowevei, by uouble buffeiing spiite bitmaps, changes can be
maue uuiing the entiie viueo fiame, allowing plenty of time to upuate S2 bitmaps.
Bitmaps that aien't cuiiently being useu can be changeu unuei piogiam contiol,
anu then the spiite souice image uata (bits 2S-Su of the spiite contiol uata
stiuctuie) can be changeu to point to the mouifieu bitmap. Foi example, a given
spiite coulu use souice images u anu S2. When souice image u is being useu by the
spiite, souice image S2 can be upuateu. The spiite's uata stiuctuie can be changeu
to swap souice image bitmaps uuiing the veitical blanking peiiou, iesulting in
glitch-fiee spiite bitmap animation. This scheme woiks best when theie aie few
enough spiites that two bitmaps can be allocateu to each spiite. That way, low-
numbeieu bitmaps (u to S1) can be upuateu while high-numbeieu bitmaps (S2 to
6S) aie on scieen, anu vice-veisa.

Similaily, sketches can ieuefine the chaiactei bitmaps. If the chaiactei being
ieuefineu isn't piesent on-scieen, the bitmap can be upuateu at any time. The same
lowhigh scheme can be useu with chaiactei bitmaps, but unlike spiites, each
chaiactei on the uisplay must be changeu inuiviuually uuiing the veitical blanking
peiiou to animate the bitmap, which seveiely limits the effectiveness of the
appioach.

When uesigning uouble-buffeiing schemes, it is a goou iuea to maximize SPI uata
tiansfei efficiency by keeping all of the uata to be upuateu in a contiguous block.
Foi example, upuating S2 spiite bitmaps in a single block takes 8194 SPI cycles (2 to
set up the auuiess anu 8192 to tiansfei S2 bitmaps of 2S6 bytes each). 0puating S2
spiite bitmaps inuiviuually iequiies 82S6 SPI cycles (S2 bitmaps, each of which
iequiies a 2-byte auuiess followeu by 2S6 uata bytes), so keeping the uata togethei
saves 62 SPI cycles.
Updat|ng Cff-Screen Cb[ects
The uameuuino has a logical S12S12 pixel uisplay, but can only show a 4uuSuu
pixel winuow on the monitoi. Infoimation that is not cuiiently visible within the
uisplay winuow can be upuateu without causing visual glitches. This technique is
fiequently useu by sciolling-scieen viueo games. Poitions of the playfielu that aie
cuiiently outsiue of the visible winuow aie upuateu, anu eventually scioll into the
BRAFT uameuuino Refeience Nanual
12
visible winuow. The game sketch constantly upuates the playfielu "aheau" of the
sciolling.
Vert|ca| 8|ank|ng
viueo uisplay timing is baseu aiounu the neeu to scan an election beam acioss a
cathoue-iay tube. Buiing pait of this scan, the beam is tuineu off anu ietuineu to
the top of the scieen so that it is be ieauy to uiaw a new fiame of uata. The peiiou
of time that the beam is tuineu off anu being ietuineu to the top of the scieen is the
veitical blanking inteival. While mouein LCB panels uon't use election beams, the
timing foi that veitical blanking inteival is still built into the vuA viueo stanuaiu.

Since no viueo is output uuiing the veitical blanking inteival, oui game softwaie can
use this time to upuate the scieen without causing visual glitches on the scieen. The
veitical blanking inteival is nominally 1.S728ms. In a single veitical blanking
inteival:
An Aiuuino's ATmega CP0 iunning at 16NBz can execute 21,964 machine
cycles. Nany AvR instiuctions take one cycle, but some take 2, S, oi 4 cycles.
The uameuuino's }1 copiocessoi can execute 68,64u machine cycles. Almost
all }1 instiuctions take one cycle, but some (incluuing memoiy ieaus anu
wiites) take 2 cycles.
The Aiuuino can use its SPI bus can tiansfei 1,S72 bytes, assuming the
maximum SPI clock speeu. SPI uata tiansfeis iequiie senuing 2 auuiess bytes
to set up a tiansfei plus 1 byte pei uata byte ieau fiom oi wiitten to the
uameuuino.
The woik that can be uone is summaiizeu in Table S: veitical Blanking.

@,A5" J* F"&27',5 K5,4874L
veitical Blanking 1.S728ms
Aiuuino CP0 21,964 cycles

}1 Copiocessoi 68,64u cycles
SPI tiansfei 1,S72 bytes

Although in theoiy all thiee types of activities can be going on at once, in piactice
theie aie some limitations. Fiist, the Aiuuino CP0 is iesponsible foi initiating SPI
tiansactions anu keeping the SPI bus busy, so the amount of auuitional woik that it
can get uone at the same is limiteu. Similaily, while the }1 copiocessoi can execute
its instiuctions inuepenuently of the Aiuuino, each SPI ieau oi wiite opeiation
steals a machine cycle fiom the }1, ieuucing its peifoimance by about 2%. Finally,
because of the way that the uameuuino's viueo-composition haiuwaie woiks, the
actual time wheie it is safe to upuate the scieen may vaiy by up to 2% fiom the
nominal figuie. See the uiscussion unuei Rastei Chasing below foi a moie
compiehensive uiscussion.
BRAFT uameuuino Refeience Nanual
1S
<&2&?2567 @&#25?", A,"60567
Aiuuino sketches anu copiocessoi coue can use the vBLANK iegistei to synchionize
theii upuates to the veitical blanking inteival. vBLANK will ieau 1 when the
uameuuino is geneiating a veitical blanking signal, oi u otheiwise.

The uB libiaiy pioviues a function, waitvblank() that will wait foi vBLANK to go
fiom u to 1 using a while
loop. The geneial stiuctuie
of a game sketch that uses
waitvblank() is illustiateu
in Sketch S: uame Loop
using uB::waitvblank() at
the iight. 0sing this
function guaiantees that
the Aiuuino has the
maximum amount of time to upuate the scieen: it waits foi vBLANK to change fiom
u to 1 befoie ietuining. If youi sketch calls waitvblank() in the miuule of a veitical
blanking inteival, it will wait foi the next veitical blanking inteival, skipping an
entiie fiame, to ensuie that youi sketch has the full time available.

While this appioach is sufficient foi many game sketches, it is somewhat wasteful:
the Aiuuino can uo nothing except iesponu to inteiiupts while it is waiting foi the
veitical blanking inteival to stait. 0n top of that, continuous SPI ieau cycles useu to
iepeateuly check vBLANK steal a few memoiy cycles fiom the copiocessoi, causing
it to iun slightly slowei. This can be an issue if youi copiocessoi coue uepenus on
piecise timing -foi example, if you aie also uoing iastei chasing.

Anothei way of synchionizing Aiuuino coue with veitical blanking is to have
copiocessoi miciocoue that allows the }1 copiocessoi inteiiupt the Aiuuino at the
stait of the veitical blanking inteival. An <<<example sketch>>> is shown at iight.
This sketch can be extenueu by auuition auuitional copiocessoi coue aftei the
inteiiupt is issueu that will be executeu uuiing veitical blanking.

<<<to-uo: inseit inteiiupt sketch>>>
kaster Chas|ng
}ust as the viueo beam neeus to be ietuineu to the top of the scieen befoie staiting
each fiame, it also neeus to be ietuineu to the left siue of the scieen piioi to each
line of viueo. Boiizontal blanking is the peiiou of time that the viueo signal is
tuineu off while it is being ietuineu to the left siue of the scieen. Since theie aie
hunuieus of lines pei fiame, the hoiizontal blanking time of 4.8s is much shoitei
than the veitical blanking inteival. If the action to be taken is baseu on the cuiient
line, then the technique is known as "iastei chasing". Foi example, a piogiam coulu
change the backgiounu coloi baseu on the cuiient line.

loop()
{
// Code that does game calculations here.
waitvblank()
// Code that updates the Gameduino screen here.
}
/8"2'9 J* ;,<" 6$$? %#74L ;3**.,72MA5,48NO
BRAFT uameuuino Refeience Nanual
14
Bowevei, the uameuuino uoesn't output vuA viueo uiiectly. Insteau, each pixel is
uoubleu hoiizontally anu veitically. To uo this, the uameuuino composes each line
of viueo into one of two buffeis by builuing it up fiom the backgiounu coloi,
chaiactei giaphics, anu spiites. 0nce the line is built up in the buffei, it is output to
the uisplay, anu the othei buffei is available to compose the next line. The
uameuuino outputs each pixel twice to uouble theii size hoiizontally, anu each line
is output twice to uouble it veitically. Theie is a biief pause to switch buffeis anu
synchionize the timing of the compositoi befoie the uameuuino begins composing
the next line.

So, insteau of a stanuaiu vuA hoiizontal ietiace, the uameuuino has a small time
winuow between composing successive lines of the uisplay. Buiing this winuow, it
is safe to upuate on-scieen infoimation, since no viueo composition is going on.
Since each line of viueo can take a uiffeient amount of time to composeu, baseu
mainly on the numbei of spiites piesent in that line, the size of the winuow can be
uiffeient fiom line to line: the winuow is at least 4S }1 cycles long, anu can be as long
as 1677 cycles. The time taken uepenus on the numbei of spiites that must be
compositeu onto the line: the minimum time of 4S cycles coiiesponus to the
maximum of 96 spiites pei line.

Theie is no uiiect equivalent to the VBLANK iegistei to inuicate when it is safe to
peifoim upuates, but theie 3> copiocessoi-only iegistei (YLINE, at ux8uuu) that
inuicates the cuiient hoiizontal line numbei. The uameuuino inciements YLINE
immeuiately aftei the iightmost pixel of a line is composeu. }1 piogiams that wait
foi YLINE to change aie guaianteeu to have at least 4S cycles, anu possibly longei,
to make changes to the viueo uata.

YLINE is a copiocessoi-only iegistei. Theie is no equivalent available to the
Aiuuino that inuicates when hoiizontal blanking is taking place - anu not enough
time to take auvantage of it even if theie weie: even a single-byte SPI tiansfei
iequiies 18u }1 cycles, so the winuow may well be closeu befoie the uata coulu be
wiitten. The copiocessoi coulu inteiiupt the Aiuuino when a change in YLINE is
uetecteu using a piogiam similai to the one uesciibeu above foi veitical blanking,
but theie is so little time available that it woulu be challenging to wiite an inteiiupt
seivice ioutine that uiu anything useful.

The best appioach foi is to wiite a copiocessoi ioutine that uetects a change in the
YLINE iegistei uoes the necessaiy woik. Theie is no inuication when viueo
compositing iesumes, so copiocessoi piogiams that upuate the scieen uuiing this
winuow shoulu uo theii woik quickly. The <<example sketch>> to the iight
illustiates iastei-chasing techniques that manipulate the BuC0L0R iegistei to
cieate a sky anu giounu backgiounu effect.

<<<to-uo: inseit iastei-chasing example>>>

BRAFT uameuuino Refeience Nanual
1S
BC8D= @",5$52-
When couing }1 ioutines that woik with YLINE, iemembei that the value of YLINE is
unuefineu uuiing the veitical blanking inteival. Copiocessoi coue can count on
YLINE going fiom u to 299 uuiing the visible poition of the uisplay, anu a value
gieatei than 299 uuiing veitical blanking. Bowevei, uuiing veitical blanking the
YLINE iegistei may take on unpieuictable anu aibitiaiy values above 299. Foi
example, it may count fiom u to 299 uuiing the visible fiame, anu then count Suu,
Su1, Su2, SuS, 482, 48S, etc. while the uisplay is blankeu foi veitical ietiace.
@$#1)00"+ !*)05$43

<<<to-uo: uesciibe how to use spiites to make a bitmap giaphics fielu>>>

BRAFT uameuuino Refeience Nanual
16
nardware nack|ng
C|rcu|t 8oard Mod|f|cat|ons
!)1"+7$%/ B/+$C$4)#$/%3
The uameuuino boaiu is uesigneu to use Aiuuino pin 9 as the select (SEL oi SS) pin
foi SPI communication. Bowevei, the uameuuino may neeu to co-exist with othei
haiuwaie that uses pin 9 foi its own puiposes. It has been uesigneu to enable this
to be changeu if neeueu by cutting a tiace on the ciicuit boaiu anu installing a
jumpei wiie.

Any available uigital pin can be useu as the new SPI SEL pin, but note that uigital
pins 11, 12, anu 1S aie useu by the uameuuino's SPI inteiface, anu uigital pin 2 may
also be in use by some sketches. To ieconfiguie the uameuuino to use a uiffeient
pin foi SPI SEL:

1. Bieak the ciicuit boaiu tiace at location X on the photogiaph, anu

2. Soluei a jumpei wiie fiom the thiough-hole at location A to the new SPI SEL
pin; the exact pin will uepenu on youi system's haiuwaie configuiation.

<<<To-uo: inseit photo heie>>>

D/:3#$4E (5$".+ B/+$C$4)#$/%3
The SpaikFun joystick shielu is as close as anything gets to a stanuaiu gaming input
uevice foi the Aiuuino. Fiom the point of view of using it with a uameuuino, it has
one significant uiawback: the joystick pushbutton is attacheu to Aiuuino uigital pin
2. This may be an issue because pin 2 can be useu by uameuuino copiocessoi coue
to inteiiupt the Aiuuino, oi pin 2 can be useu to access the uameuuino's onboaiu
Flash memoiy. Luckily, it is ielatively easy to mouify the joystick shielu to iemap
this button to a uiffeient input. We iecommenu iemapping the input to pin 7 with
the following pioceuuie:

1. Bieak the ciicuit boaiu tiace at location X in the photogiaph, anu

2. Soluei a jumpei wiie fiom location B to Aiuuino uigital pin 7 at location C.

<<<to-uo: inseit photo heie>>>
BRAFT uameuuino Refeience Nanual
17
Do-It-ourse|f ro[ects
<%07#3 )%+ =/%#*/.."*3

<<<to-uo: infoimation about builuing youi own contiollei>>>

F%4./37*"3 )%+ =)3"3

<<<to-uo: infoimation about builuing youi own box oi case>>>




BRAFT uameuuino Refeience Nanual
18
Gamedu|no 1echn|ca| keference
nardware Interface
Although uesigneu as an Aiuuino shielu, the haiuwaie is laigely self-containeu, anu
can be inteifaceu with any miciopiocessoi oi computei system that can pioviue
powei anu a SPI inteiface. An auuitional output fiom the uameuuino is connecteu to
Aiuuino uigital pin 2 foi use as an inteiiupt fiom the uameuuino to the host system.
These connections aie summaiizeu in Table 4: Bost Inteiface.

@,A5" P* +$#2 =42"&1,'"
Aiuuino Pin Function
uNB Signal uiounu
+S.Sv Supply voltage, S.SvBC
+Sv Supply voltage, S.uvBC, 2SmA
2 Inteiiupt (optional)
9 SPI SEL oi SS
11 SPI N0SI
12 SPI NIS0
1S SPI SCK
G)*+H)*" =/10)#$I$.$#:
The uameuuino is specifically intenueu foi use with the Aiuuino 0no. It is
physically anu electiically compatible with most Aiuuino boaius such as the
incluuing the Nega 2S6u, Buemilanove, Nega, anu Biecimila. ATmaga168-baseu
boaius like Biecimila anu eailiei ievisions of the Buemilanove may not have enough
Flash memoiy oi Static RAN (SRAN) foi many uameuuino sketches piesenteu in
this manual. Aiuuino-ueiiveu uesigns such as the Fieeuuino anu Seeeuuino that
incoipoiate an ATmegaS28, ATmega128u, oi ATmega2S6u shoulu also woik with
the uameuuino. 0thei uevelopment boaius with Aiuuino-compatible heaueis can
also suppoit the uameuuino; some of these like the Netuuino, FEZ Bomino, oi FEZ
Panua incoipoiate consiueiably moie computational powei than the stanuaiu
Aiuuino platfoim. The status of known host boaius foi the uameuuino is piesenteu
in Table S: Baiuwaie Compatibility List.

@,A5" Q* +,&-.,&" R$<?,27A7572S 67#2
Bost Boaiu Compatibility anu Suppoit
Name Piocessoi Nemoiy Baiuwaie Softwaie Active Note
Aiuuino 0no 16NBz ATmegaS28 S22 Yes Yes Yes
Aiuuino Nega2S6u 16NBz ATmaga2S6u 2S68 Yes Yes Yes
Aiuuino Buemilanove 16NBz ATmegaS28 S22 Yes Yes
Aiuuino Buemilanove 16NBz ATmega168 161 Yes Naybe 1
Aiuuino Biecimila 16NBz ATmega168 161 Yes Naybe 1
Aiuuino Nega 16NBz ATmega128u 1288 Yes Yes
Fieeuuino v2.2 16NBz ATmegaS28 S22 2
Seeuuino v2.2 16NBz ATmegaS28 S22 2
BRAFT uameuuino Refeience Nanual
19
Bost Boaiu Compatibility anu Suppoit
Name Piocessoi Nemoiy Baiuwaie Softwaie Active Note
LeafLabs Naple 72NBz ARN Coitex 12u2u Yes Yes Yes 4
Netuuino 48NBz ARN7 1296u No S
Netuuino Plus 48NBz ARN7 6428 No S
FEZ Bomino 72NBz ARN7 14862 No S
FEZ Panua 72NBz ARN7 14862 No S
FEZ Panua II 72NBz ARN7 14862 No S
Bost Boaiu: Name of the host boaiu.
Piocessoi: CP0 speeu anu uesignation, piogiam (Flash) anu ieauwiite (SRAN) memoiy in kbytes.
Compatibility anu Suppoit: Status of the uameuuino on each platfoim, see below.

!"#$%"#& E 6=<>3E", "0$ &,&E1#3E", E-/."13G3,31< %31= 1=& :"/&$;30-T
Yes = Fully compatible, connects to host boaiu as a shielu
Naybe = Can be maue to woik by mouifying boaius oi iunning wiies
No = Boes not woik
Blank = Not testeu, infoimation neeueu.
./F2%"#& [ ?-/."13G3,31< %31= >-;#E& E-$& 30E,;$&$ 30 1=3> G--PT
Yes = Compatible, full uB libiaiy suppoit anu all sketches woik
Naybe = Some sketches may not woik uue to memoiy oi timing constiaints,
see notes
No = Not Aiuuino souice-coue compatible, see notes.
Blank = Not testeu, infoimation neeueu
(?25G& [ A+"3,"G3,31< -I :* ,3G#"#< "0$ "E13+& E-//;031< >;..-#1T
Yes = veiy active community anu suppoiteu uB libiaiy
Some = Limiteu activity but some woik is being uone, see notes
Siu Paity = Active uevelopment community using a Siu-paity uB libiaiy, see
notes
No = No activity anu no libiaiy, piobably because of incompatibility
Blank = 0nknown, infoimation neeueu.
D/2& [ M<>1&/7>.&E3I3E E-/."13G3,31< 0-1&>T
1. These systems aie mechanically anu electiically compatible, but limiteu
piogiam stoiage anu SRAN may pievent many sketches fiom woiking.
0ntesteu at this time.
2. Believeu to be fully compatible, but untesteu at this time.
S. Boaius baseu on .Net Nicio Fiamewoik shoulu be haiuwaie compatible;
untesteu anu no community oi libiaiy suppoit at this time.
4. Boaius baseu on AiuuinoPiocessing IBE with ARN cioss-compilei.
Softwaie is souice-coue (but not object-coue) compatible.
(9< =/117%$4)#$/%
The uameuuino's piogiamming inteiface is a S2-kilobyte auuiess space that is
available to the host computei via an SPI inteiface. The uameuuino expects uata to
be sent NSB fiist (B0RB=u), using SPI Noue u foi a clock signal that's low when iule
(B0RB=u) anu sampleu on the iising euge (CPBA=u). While the uameuuino shoulu
BRAFT uameuuino Refeience Nanual
2u
be able to keep pace with an SPI clock up to 16.7NBz, it has only been testeu to the
Aiuuino's maximum clock speeu of 8NBz.
L|brary Support
The Aiuuino enviionment incluues a
stanuaiu libiaiy foi hanuling SPI
communications. Sketch 4: SPI
Initialization shows the Aiuuino coue to
set up the SPI libiaiy to communicate
with a uameuuino. The uB libiaiy foi
Aiuuino pioviues convenient wiappei functions aiounu the SPI libiaiy foi common
uameuuino opeiations.
A|ternate SI Address
1he Gamedu|no board |s des|gned to use Ardu|no p|n 9 as the
se|ect (SLL or SS) p|n for SI commun|cat|on. nowever, the
board has been des|gned to enab|e th|s to be changed |f needed,
for examp|e, to co-ex|st w|th other hardware that uses p|n 9 for
|ts own purposes. See C|rcu|t 8oard Mod|f|cat|ons
uameuuino Nouifications on page 16 in the Baiuwaie Backing section foi uetaileu
instiuctions.
Memory Map
These memoiy maps piesent the uameuuino auuiess space in ascenuing oiuei fiom
lowest auuiess to highest auuiess; the chaits show auuiesses incieasing fiom left to
iight anu top to bottom. This means that ASCII chaiactei stiings aie piesenteu in the
oiuei that they woulu be ieau as English text. Foi example, the stiing "BELL0
W0RLB" woulu be wiitten to the uppei-left coinei of the chaiactei pictuie as:

Auuiess Byte 0ffset anu Nemoiy Contents
(hex) (uec) +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +10
0x0000 0
0x48 0x45 0x4C 0x4C 0x4F 0x20 0x57 0x4F 0x52 0x4C 0x44
H E L L O W O R L D

Bowevei, when stoiing 16-bit binaiy numbeis, the uameuuino is a little-enuian
uevice: 16-bit values aie stoieu with the least-significant byte in the lowei auuiess.
Foi example, the 16-bit value ux2F8B woulu be stoieu in the 2-byte Bu_C0L0R
iegistei staiting at ux28uE as:

Symbol Auuiess Length Byte 0ffset anu Contents


(hex) (uec) (hex) (uec) +0 +1
BG_COLOR RW 0x280E 10254 0x2 2 0x8B 0x2F

#define GAMEDUINO_SS 9

pinMode(GAMEDUINO_SS,OUTPUT);
SPI.begin();
SPI.setClockDivider(SPI_CLOCK_DIV2);
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(MODE0);

/8"2'9 P* /T= =4727,57>,27$4
BRAFT uameuuino Refeience Nanual
21
Nany uameuuino memoiy locations aie bit-mappeu, with specific bits oi gioups of
bits within a woiu having uistinct functions. When mapping a byte oi woiu, the
inuiviuual bits aie piesenteu in as uigits of a numbei, with the most-significant bit
to the faithest left anu the less-significant bits to the iight. Inuiviuual bits within a
multi-bit fielu aie inuicateu with subsciipts, with zeio being the least-significant bit
anu highei numbeis inuicating piogiessively moie significant bits. Foi example, Bu
is the least-significant bit in fielu B, while B6 is the 7
th
anu most-significant bit in a 7-
bit fielu.
!)1"+7$%/ B"1/*: B)0
@,A5" E* ;,<"-%74$ U"<$&S U,?
Symbol Auuiess Length Puipose
RAM_PIC RW
0x0000
0x0FFF
4096
R9,&,'2"& T7'2%&"V chaiactei-mappeu playfielu
uiiu of 6464 1-byte chaiacteis
RAM_CHR RW
0x1000
0x1FFF
4096
R9,&,'2"& K72<,?#V 2S6 chaiacteis
88 pixels, 2 bits pei pixel (16 byteschaiactei)
RAM_PAL RW
0x2000
0x27FF
2048
R9,&,'2"& T,5"22"#V 2S6 palettes of 4 colois each
ARuB1SSS foimat (2 bytescoloi)
IDENT R 0x2800 1 ;,<"-%74$ =3V always ieaus ux6B
REV R 0x2801 1 +,&-.,&" !"M7#7$4V always ieaus ux1u
FRAME R 0x2802 1 F7-"$ I&,<" R$%42"&
VBLANK R 0x2803 1 F"&27',5 K5,4874L I5,LV 1 uuiing veitical blank
SCROLL_X RW
0x2804
0x2805
2
/'&$55 W, chaiactei pictuie hoiizontal scioll
Scioll offset, u to S11 pixels
SCROLL_Y RW
0x2806
0x2807
2
/'&$55 X, chaiactei pictuie veitical scioll
Scioll offset, u to S11 pixels
JK_MODE RW 0x2808 1 /?&72" YZ[ U$-", u to uisable, 1 to enable
J1_RESET RW 0x2809 1 R$?&$'"##$& !"#"2V 1 to ieset anu halt, u to iun
SPR_DISABLE RW 0x280A 1 /?&72" 37#,A5"V 1 to uisable spiints, u to enable
SPR_PAGE RW 0x280B 1 /?&72" T,L" /"5"'2V u foi uxSuuu, 1 foi uxS4uu
IOMODE RW 0x280C 1 T74 0 =ZH U$-"V uxuu=uisable, ux4S=SPI, ux4A=}1
R 0x280D 1 \4%#"- !"L7#2"& foi futuie use, always ieaus u
BG_COLOR RW
0x280E
0x280F
2
K,'8L&$%4- R$5$&V foi tianspaient playfielu pixels
ARuB1SSS foimat, high (alpha) bit is ignoieu
SAMPLE_L RW
0x2810
0x2811
2
G%-7$ /,<?5"V left channel
16-bit signeu auuio sample value
SAMPLE_R RW
0x2812
0x2813
2
G%-7$ /,<?5"V iight channel
16-bit signeu auuio sample value
RING_MOD RW 0x2814 1
!74L U$-%5,2$&, voice useu foi mouulation, affects
all lowei-numbeieu voices; 64 (uefault) to uisable.
R
0x2815
0x281D
9
\4%#"- !"L7#2"&#V ieseiveu foi futuie use
Always ieaus u
SCREENSHOT_Y RW
0x281E
0x281F
2
/'&""4#9$2 674" /"5"'2V u-S11
Selects iastei line to loau into scieenshot buffei
R
0x2820
0x283F
32
\4%#"- !"L7#2"&#V ieseiveu foi futuie use
Always ieaus u
PALETTE16A/B
RAM_SPRPAL16
RW
0x2840
0x287F
64
/?&72" T,5"22" )EV 2 palettes (A&B), 16 colois each
ARuB1SSS foimat (2 bytescoloi)
BRAFT uameuuino Refeience Nanual
22
Symbol Auuiess Length Puipose
PALETTE4A/B
RAM_SPRPAL4
RW
0x2880
0x288F
16
/?&72" T,5"22" P, 2 palettes (A&B), 4 colois each
ARuB1SSS foimat (2 bytescoloi)
COMM RW
0x2890
0x28BF
48
R$?&$'"##$& R$<<%47',27$4# K5$'8
Specific use to be ueteimineu by the piogiammei

0x28C0
0x28FF
64
\4%#"- G--&"## /?,'"
Always ieaus u
COLLISION R
0x2900
0x29FF
256
/?&72" R$557#7$4 3"2"'27$4V valiu when vBLANK=1
Spiite numbei of colliuing spiite, FF=no collision
VOICES RW
0x2A00
0x2AFF
256
F$7'" R$42&$5V auuio synthesis contiol
64 voices, 4 bytesvoice
J1_CODE RW
0x2B00
0x2BFF
256
R$?&$'"##$& U7'&$'$-"
128 instiuctions, 2 bytesinstiuction
SCREENSHOT R
0x2C00
0x2F1F
800
/'&""4#9$2 674" K%11"&, selecteu uisplay line uata
ARuB1SSS foimat (2 bytespixel), alpha always u
R
0x2F20
0x2FFF
224
\4%#"- G--&"## /?,'"
Always ieaus u
RAM_SPR RW
0x3000
0x37FF
2048
/?&72" R$42&$5V 2 pages of 2S6 spiites each
4 bytesspiite
RAM_SPRPAL
RAM_SPRPAL256
RW
0x3800
0x3FFF
2048
/?&72" T,5"22" 0QEV 4 palettes of 2S6 colois each
ARuB1SSS foimat (2 bytescoloi)
RAM_SPRIMG RW
0x4000
0x7FFF
16384
/?&72" =<,L" 3,2,
64 images, 1616 pixels, 1 bytepixel
YLINE R 0x8000 2 R%&&"42 !,#2"& 674"V u-299
ICAP_O R 0x8002 2 IT;G =RGT T$&2V 8-bit output
0x8004 2 \4%#"- G--&"## /?,'", always ieaus u
ICAP W 0x8006 2 IT;G =RGT T$&2V 8-bit input anu ICAP contiol bits
0x8008 2 \4%#"- G--&"## /?,'", always ieaus u
FREQHZ W 0x800A 2 @7<"& I&"]%"4'S, uBz to 6SSSSBz
FREQTICK R 0x800C 2 @7<"& @7'8, toggles between u anu 1 at FREQBZ
P2_V RW 0x800E 2 T74 0 F,5%", u oi 1
P2_DIR R 0x8010 2 T74 0 37&"'27$4V u=output, 1=input
RANDOM R 0x8012 2 )E^A72 !,4-$< F,5%"V fiom white-noise geneiatoi
CLOCK R 0x8014 2 )E^A72 R5$'8 F,5%", SuNBz machine cycles
FLASH_MISO R 0x8016 2 H4A$,&- /T= I5,#9V NIS0 line
FLASH_MOSI W 0x8018 2 H4A$,&- /T= I5,#9V N0SI line
FLASH_SCK W 0x801A 2 H4A$,&- /T= I5,#9V SCK line
FLASH_SSEL W 0x801C 2 H4A$,&- /T= I5,#9V SSEL line
Blue text inuicates unofficial infoimation (e.g. "RAN_SPRPAL4" is an unofficial label foi ux288u)
Lines shaueu in giey aie copiocessoi-only (cannot be accesseu by Aiuuino SPI inteiface).
=/%#*/. ?"&$3#"*3
The uameuuino is contiolleu thiough SPI ieaus anu wiites into its auuiess space.
This auuiess space can be classifieu as memoiy anu iegisteis, wheie iegisteis aie
one-byte oi two-byte memoiy auuiesses that have specific functions. In contiast,
memoiy aieas aie laige sections of the auuiess space that have the same function.
Foi example, the uameuuino IB anu haiuwaie ievision numbei aie iegisteis, while
playfielu image uata anu chaiactei bitmaps aie consiueieu memoiy.
BRAFT uameuuino Refeience Nanual
2S
Shared keg|sters
The uameuuino has two sets of iegisteis: a gioup of shaieu iegisteis at auuiesses
1u24u thiough 1uSuS (ux28uu - ux28SF) that is accessible to both the SPI inteiface
anu the }1 copiocessoi, anu anothei gioup staiting at S2768 (ux8uuu) that is only
accessible to the copiocessoi. The shaieu iegisteis aie uesciibeu below, while the
copiocessoi-only iegisteis aie uesciibeu in the
BRAFT uameuuino Refeience Nanual
24
}1 Copiocessoi chaptei, staiting on page SS.

;,<"-%74$ =3* IBENT is a single-byte, ieau-only iegistei is useu to iuentify a
uameuuino when scanning SPI peiipheials. If a uameuuino is piesent, issuing a
ieau commanu foi auuiess 1u24u (ux28uu) will piouuce 1u9 (ux6B, ASCII "m").

@,A5" _* =3`a@ !"L7#2"&
Symbol Auuiess Length Contents


(hex) (uec) (hex) (uec) (hex) (uec)
IDENT R 0x2800 10240 0x01 1 0x6D 109

+,&-.,&" F"&#7$4* REv is a single-byte, ieau-only iegistei that contains the majoi
anu minoi ievision numbeis (R anu N iespectively in a R.N veision numbeiing
scheme) of the uameuuino haiuwaie anu on-boaiu fiimwaie. RS-Ru is the majoi
ievision numbei; NS-Nu is the minoi ievision numbei.

@,A5" B* !`F !"L7#2"&
Symbol Auuiess Length Contents


(hex) (uec) (hex) (uec) (hex) (uec)
REV R 0x2801 10241 0x01 1 R3R2R1R0 M3M2M1M0 R!16 + M

F7-"$ I&,<" R$%42"&* The FRANE iegistei contains a one-byte, ieau-only count of
viueo fiames geneiateu. The count staits at powei-on at u, counts up to 2SS, then
iesets to u. At the uameuuino's 72Bz fiame iate, the iegistei wiaps aiounu to u
ioughly eveiy S.S6 seconus.

@,A5" b* I!GU` !"L7#2"&
Symbol Auuiess Length Contents

(hex) (uec) (hex) (uec) (hex) (uec)
FRAME R 0x2802 10242 0x01 1 0x00-0xFF 0-255

F"&27',5 K5,4874L I5,L* vBLANK is a single-byte, ieau-only iegistei that is set to 1
uuiing the veitical blanking inteival, oi u otheiwise. The waitvblank() methou in
the uameuuino libiaiy uses this flag to ueteimine when to ietuin. Theie aie 72
veitical blanking inteivals pei seconu (one pei fiame of viueo geneiateu). Each one
lasts 1.S728ms. See the viueo Timing section staiting on page 8 foi moie on veitical
blanking anu to avoiu visible glitches when upuating the scieen.

@,A5" )C* FK6Ga[ !"L7#2"&
Symbol Auuiess Length Contents


(hex) (uec) (hex) (uec)
VBLANK R 0x2803 10243 0x01 1 X X X X X X X V0
vu: veitical blanking status: u=not in veitical blanking, 1=veitical blanking.

/'&""4 /'&$5574L* The uameuuino outputs a 4uuSuu pixel scieen uisplay winuow
onto a logical S12S12 pixel image. The SCR0LL_X anu SCR0LL_Y iegisteis set the
location of the uppei left coinei of the visible winuow ielative to the laigei logical
image. If the visible winuow extenus off of the iight oi bottom of the logical image,
BRAFT uameuuino Refeience Nanual
2S
it automatically wiaps aiounu to the left oi top (iespectively) of the logical image.
Foi moie infoimation on scieen sciolling, see the explanation of Sciolling that staits
on page 29 below.

@,A5" ))* /R!H66cW ,4- /R!H66cX !"L7#2"&#
Symbol Auuiess Length Byte 0ffset anu Registei Contents Befault


(hex) (uec) (hex) (uec) +0 +1

SCROLL_X RW 0x2804 10244 0x2 2 S7S6S5S4S3S2S1S0 X X X X X X X S8 0x0000
SCROLL_Y RW 0x2406 10246 0x2 2 S7S6S5S4S3S2S1S0 X X X X X X X S8 0x0000
X: 0nuseu bit position, ignoieu; shoulu be u foi compatibility ieasons.
Su-S8: Scioll offset in pixels, u-S11.

/?&72" YZ[ U$-"* The }K_N0BE iegistei is a one-byte, ieauwiite value that
contiols the behavioi of the uameuuino's spiite collision-uetection logic. When set
to u, }K moue is uisableu anu collisions aie uetecteu between all spiites. Wiiting a
1 to }K_N0BE enables gioupeu "}K" collision uetection. In this moue, the spiites
aie uiviueu into two gioups (labeleu } anu K foi convenience), anu collisions aie
only uetecteu between spiites in uiffeient gioups. Spiites that belong to the same
gioup aie consiueieu "fiienuly" with one anothei anu uon't colliue. Setting bit S1 of
the spiite contiol woiu to u oi 1 assigns the spiite to the } oi K gioup, iespectively.
See the
@,A5" 0b* /?&72" T,5"22" U$-"#
T,5"22" U$-" TC^TJ /"5"'2"- U$-" T7D"5
(bin) (dec) (hex) colors palette bits
0000 0 0x0 256 8 0 A 0-7
0001 1 0x1 256 8 1 B 0-7
0010 2 0x2 256 8 2 C 0-7
0011 3 0x3 256 8 3 D 0-7
0100 4 0x4 16 4 0 A 0-3
0101 5 0x5 16 4 1 B 0-3
0110 6 0x6 16 4 0 A 4-7
0111 7 0x7 16 4 1 B 4-7
1000 8 0x8 4 2 0 A 0-1
1001 9 0x9 4 2 1 B 0-1
1010 10 0xA 4 2 0 A 2-3
1011 11 0xB 4 2 1 B 2-3
1100 12 0xC 4 2 0 A 4-5
1101 13 0xD 4 2 1 B 4-5
1110 14 0xE 4 2 0 A 6-7
1111 15 0xF 4 2 1 B 6-7
Palette moue: The selecteu palette moue numbei in binaiy, uecimal, anu hexauecimal.
Colois: Numbei of colois anu bit uepth in selecteu palette moue.
Palette: The numbei anu lettei of the palette selecteu foi the spiite.
Pixel bits: The bit positions of the spiite image useu in the selecteu moue.

@,A5" JC* /?&72" !$2,27$4
!$2,27$4 !C^!0 /"5"'2"- U$-" `11"'2
(bin) (dec) (hex) Yflip Xflip XYswap
000 0 0x0 0 0 0 None
001 1 0x1 0 0 1 Niiioieu left-to-iight then iotateu 27u
010 2 0x2 0 1 0 Niiioieu left to iight
011 3 0x3 0 1 1 27u clockwise iotation
BRAFT uameuuino Refeience Nanual
26
100 4 0x4 1 0 0 Niiioieu left-to-iight then iotateu 18u
101 5 0x5 1 0 1 9u clockwise iotation
110 6 0x6 1 1 0 18u clockwise iotation
111 7 0x7 1 1 1 Niiioieu left-to-iight then iotateu 9u
Rotation: The selecteu iotation numbei in binaiy, uecimal, anu hexauecimal.
Y flip: Flip spiite image in Y uiiection (top-to-bottom), u=no, 1=yes.
X flip: Flip spiite image in X uiiection (left-to-iight), u=no, 1=yes.
XY swap: Swap spiite X anu Y axes, u=no, 1=yes.
Effect: Effect of selecteu iotation on the spiite image.
Spiite Collision Betection topic on page 44 foi moie infoimation.

@,A5" )0* Y[cUH3` !"L7#2"&
Symbol Auuiess Length Contents Befault

(hex) (uec) (hex) (uec)
JK_MODE RW 0x2808 10248 0x01 1 X X X X X X X J0 0x00
}u: Spiite }K moue collision uetection: u=uisableu (uetect all collisions), 1=enableu.

R$?&$'"##$& !"#"2* The }1_RESET is a one-byte, ieauwiite iegistei that allows the
Aiuuino (oi othei host miciocontiollei) to stop anu stait the }1 copiocessoi.
Wiiting uxu1 to this iegistei halts anu iesets the copiocessoi, while uxuu ieleases
the copiocessoi. Following a ieset, the }1 begins executing coue staiting at }1_C0BE,
ux2Buu (11uu8 uecimal).

@,A5" )J* Y)c!`/`@ !"L7#2"&
Symbol Auuiess Length Contents Befault
(hex) (uec) (hex) (uec)
J1_RESET RW 0x2809 10249 0x1 1 X X X X X X X R0 0x00
Ru: Copiocessoi contiol: u=halt anu ieset, 1=iun.



/?&72" 37#,A5"* SPR_BISABLE is a one-byte, ieauwiite iegistei that contiols the
uameuuino's spiite giaphics subsystem. The uefault of u allows spiite giaphics to
function noimally. When SPR_BISABLE is set to 1, spiite giaphics aie uisableu anu
uo not appeai on scieen.

@,A5" )P* /T!c3=/GK6` !"L7#2"&
Symbol Auuiess Length Contents Befault
(hex) (uec) (hex) (uec)
SPR_DISABLE RW 0x280A 10250 0x1 1 X X X X X X X D0 0x00
Bu: Spiite giaphics uisable: u=spiites enableu, 1=spiites uisableu.

/?&72" T,L" /"5"'2* The SPR_PAuE is a one-byte, ieauwiite iegistei useu to
implement uouble buffeiing foi spiite contiol uata. When SPR_PAuE is u, the spiite
giaphics system uses the spiite contiol woius at uxSuuu-uxSSFF (12288-1SS11
uecimal) to geneiate the spiite uisplay. When it is 1, the spiite contiol woius at
uxS4uu-uxS7FF (1SS12-14SSS uecimal) aie useu. See the section on Bouble
Buffeiing staiting on page 1u foi moie infoimation anu example coue.
BRAFT uameuuino Refeience Nanual
27

@,A5" )Q* /T!cTG;` !"L7#2"&
Symbol Auuiess Length Contents Befault
(hex) (uec) (hex) (uec)
SPR_PAGE RW 0x280B 10251 0x1 1 X X X X X X X P0 0x00
Pu: Spiite giaphics contiol page: u=uxSuuu-uxSSFF, 1=uxS4uu-uxS7FF.

T74 0 =ZH U$-"* The I0N0BE iegistei is useu to assign pin 2 to one of two
functions, oi to uisable it entiiely. The uefault value of uxuu causes the uameuuino
to ignoie pin 2. When set to ux46 (uecimal 7u oi ASCII "F"), pin 2 is connecteu to
the uameuuino's onboaiu SPI flash memoiy chip as the SEL oi SS signal. Finally,
when I0N0BE is set to ux4A (uecimal 74 oi ASCII "}"), the pin is contiolleu by the
copiocessoi-only P2_v anu P2_BIR iegisteis. 0thei values have no effect.

@,A5" )E* =HUH3` !"L7#2"&
Symbol Auuiess Length Contents Befault
(hex) (uec) (hex) (uec)
IOMODE RW 0x280C 10252 0x1 1 0x00, 0x46, or 0x4A 0x00
I0N0BE must be one of the following thiee values:
uxuu (u uecimal, ASCII "N0L") - Pin 2 is ignoieu.
ux46 (7u uecimal, ASCII "F") - Pin 2 is uameuuino SPI flash memoiy SEL.
ux4A (74 uecimal, ASCII "}") - Pin 2 is contiolleu by the uameuuino copiocessoi.

K,'8L&$%4- R$5$&* The Bu_C0L0R iegistei uefines a backgiounu coloi that
appeais behinu all of the othei viueo souices. 0n powei-up, the backgiounu coloi is
the only image uisplayeu, anu uefaults to uxuuuu (black). The Bu_C0L0R value is a
stanuaiu uameuuino 16-bit coloi value except that Bit 1S, the alpha (A) channel oi
tianspaiency bit, is ignoieu if set.

@,A5" )_* K;cRH6H! !"L7#2"&
Symbol Auuiess Length Byte 0ffset anu Registei Contents Befault


(hex) (uec) (hex) (uec) +0 +1

BG_COLOR RW 0x280E 10254 0x2 2 G2G1G0B4B3B2B1B0 X R4R3R2R1R0G4G3 0x0000
X: Alpha channel coloi infoimation, ignoieu.
R4-Ru: Reu channel coloi infoimation, u-S2.
B4-Bu: uieen channel coloi infoimation, u-S2.
B4-Bu: Blue channel coloi infoimation, u-S2.

6"12 ,4- !7L92 G%-7$ /,<?5"#* The uameuuino has the ability to play back steieo
auuio wave uata using the SANPLE_L anu SANPLE_R iegisteis. Each iegistei
accepts a signeu 16-bit integei ieflecting the sample. The uameuuino upuates auuio
samples eveiy 64 cycles of it's SuNBz clock, coiiesponuing to an upuate fiequency
of 781.2SkBz, so values loaueu into these iegisteis aie ieflecteu on the auuio output
channels within 1.28s.

@,A5" )B* /GUT6`c6 ,4- /GUT6`c! !"L7#2"&#
Symbol Auuiess Length Byte 0ffset anu Registei Contents Befault


(hex) (uec) (hex) (uec) +0 +1

SAMPLE_L RW 0x2810 10256 0x2 2 L7L6L5L4L3L2L1L0 L15L14L13L12L11L10L9L8 0x0000
BRAFT uameuuino Refeience Nanual
28
SCROLL_R RW 0x2812 10258 0x2 2 R7R6R5R4R3R2R1R0 R15R14R13R12R11R10R9R8 0x0000
Lu-L1S: Left auuio channel sample value, 16-bit signeu integei (L1S is the sign bit).
Ru-R1S: Right auuio channel sample value, 16-bit signeu integei (R1S is the sign bit).

/'&""4#9$2 674" /"5"'2* The SCREENSB0T_Y iegistei is useu to captuie a line of
iastei uata fiom the SCREENSB0T buffei at ux2Cuu (11264 uecimal). To take a
scieenshot, loau a value between ux8uuu anu ux812B (uecimal S2768 anu SSu67),
coiiesponuing to the flag bit F=1 anu the Su-S8 equal to the line numbei (u to 299) to
be captuieu. When the flag bit of the iegistei ieaus 1, the selecteu line of uata is
available in memoiy locations ux2Cuu-ux2F1F (11264-12u6S uecimal). Wiiting a u
uisables the scieenshot featuie, while the low bits Su-S8 will always ieau the cuiient
uameuuino scan line.

@,A5" )b* /R!``a/+H@cX !"L7#2"&
Symbol Auuiess Length Byte 0ffset anu Registei Contents Befault


(hex) (uec) (hex) (uec) +0 +1

SCREENSHOT_Y RW 0x2406 10246 0x2 2 S7S6S5S4S3S2S1S0 F X X X X X X S8 0x0000
X: 0nuseu bit position, ignoieu; shoulu be u foi compatibility ieasons.
Su-S8: Rastei line to captuie, u-299.
F: Scieenshot flag, u oi 1.

\4%#"- !"L7#2"&# anu \4%#"- G--&"## /?,'"* Seveial poitions of the uameuuino
memoiy map aie unuseu. These auuiesses have no function, anu aie not mappeu to
stoiage oi contiol. When wiitten, these locations have no effect anu the uata
wiitten is uiscaiueu. When ieau, the locations have no specifieu value anu shoulu
ieau u, but some auuiesses may ieau othei, unpieuictable values insteau. In
paiticulai, unuseu iegisteis anu unuseu auuiess space is not connecteu to RAN oi
othei sciatchpau stoiage.
V|deo D|sp|ay
The uameuuino piesents a 4uuSuu pixel
scieen uisplay at 72Bz (72 fiames pei
seconu). The pixels aie squaie on stanuaiu
uisplay uevices. The uameuuino geneiates
its 4uuSuu viueo uisplay by combining
image uata fiom a numbei of image souices:
backgiounu coloi, a chaiactei giaphics
playfielu, anu the spiites. Each image souice
has a uiffeient piioiity - that is, the viueo
souices aie aiiangeu in oiuei fiom back to
fiont, anu souices that closei to the fiont
can covei up infoimation fiom one that is
faithei to the back. The chaiactei giaphics
anu spiites may incluue tianspaient pixels
that allow lowei-piioiity pixels to show
thiough. The backgiounu uoesn't allow
B
a
c
k
g
ro
u
n
d
C
o
lo
r
C
h
a
ra
c
te
r G
ra
p
h
ic
s
S
p
rite
s
I7L%&" )* F7-"$ 37#?5,S 6,S"&#
BRAFT uameuuino Refeience Nanual
29
tianspaient pixels, since theie is no lowei-piioiity image to show thiough.

The souices foi the uameuuino's viueo uisplay, in oiuei fiom back to fiont, aie:
Backgiounu coloi,
Chaiactei giaphics, anu
Spiites in numeiic oiuei.
Foi example, image uata on the playfielu coveis up the backgiounu coloi, anu spiite
u image uata woulu in tuin covei up the playfielu. Spiite 2SS woulu covei up pixels
fiom any lowei-numbeieu spiite (incluuing spiite u) as well as playfielu anu
backgiounu pixels.
(4*/..$%&
Each image souice is a logical S12S12 pixel
image. Bowevei, the uameuuino's vuA
output is limiteu to a 4uuxSuu pixel winuow.
The SCR0LL_X anu SCR0LL_Y iegisteis aie
useu to uefine wheie the 4uuSuu uisplay
winuow staits within the backgiounu image.
This is position of the top-left coinei of the
visible winuow, as measuieu in pixels fiom
the top-left coinei of the logical image.
Wraparound
SCR0LL_X anu SCR0LL_Y can stoie any
scioll value fiom u to S11. When SCR0LL_X
anu SCR0LL_Y aie both u (the uefault), the
uisplay winuow staits at the top coinei of
the logical image; the iight-most 212 pixels
anu the bottom 112 pixels aie off scieen
anu invisible. Scioll values of 112 anu 212
(foi X anu Y iespectively) woulu align the
visible scieen with the bottom-iight coinei
of the logical image. Laigei scioll values
woulu cause the visible winuow to wiap
aiounu the logical image: once pixel S11 of the logical image is output, the
subsequent pixels begin with pixel u of the same line. Similaily, once iow S11 has
been output to the vuA scieen, the next iow to be output will be iow u of the logical
image.

@,A5" 0C* /R!H66 !"L7#2"&#
Symbol Auuiess Length Byte 0ffset anu Registei Contents Befault


(hex) (uec) (hex) (uec) +0 +1

SCROLL_X RW 0x2804 10244 0x2 2 S7S6S5S4S3S2S1S0 X X X X X X X S8 0x0000
SCROLL_Y RW 0x2406 10246 0x2 2 S7S6S5S4S3S2S1S0 X X X X X X X S8 0x0000
X: 0nuseu bit position, ignoieu; shoulu be u foi compatibility ieasons.
SCROLL_X
SCROLL_Y
SCROLL_Y
SCROLL_X
I7L%&" 0* /'&$5574L
I7L%&" J* /'&$55 :&,?,&$%4-
BRAFT uameuuino Refeience Nanual
Su
Su-S8: Scioll offset in pixels, u-S11.

Piogiammeis can take auvantage of this wiap-aiounu featuie to implement
continuously sciolling images. Chaiacteis anu spiites that aie cuiiently off-scieen
(the gieyeu-out aieas of the figuies above) can be upuateu while the scieen sciolls,
giving the illusion of an infinite playfielu.

<<<to-uo: inseit example coue heie>>>

Sp||t Screen Scro|||ng
The scioll iegisteis affect the entiie fiame, so changing the scioll values in the
miuule of geneiating a fiame on the uisplay will cause paits of the uisplay to scioll
inuepenuently of the iest of the uisplay. The uameuuino's }1 copiocessoi can ieloau
the scioll iegisteis in the miuule of viueo geneiation to cieate a split-scieen oi
multi-pane sciolling effect.

<<<to-uo: inseit example coue heie>>>
@)4E&*/7%+ =/./*
The backgiounu coloi is uefineu by the contents of the 16-bit Bu_C0L0R iegistei.
This coloi appeais behinu all of the othei viueo souices. 0n powei-up, the
backgiounu coloi is the only image uisplayeu, anu uefaults to uxuuuu (black).

The Bu_C0L0R value is a stanuaiu uameuuino 16-bit coloi value (see the section on
Coloi), except that Bit 1S, the alpha (A) channel oi tianspaiency bit, is ignoieu if set.
The backgiounu can nevei be tianspaient, since theie aie no lowei-piioiity pixels
to show thiough. The backgiounu is noimally a soliu coloi, but see the section on
iastei chasing foi examples involving multicoloieu backgiounus.

@,A5" 0)* K;cRH6H! !"L7#2"&
Symbol Auuiess Length Byte 0ffset anu Registei Contents Befault


(hex) (uec) (hex) (uec) +0 +1

BG_COLOR RW 0x280E 10254 0x2 2 G2G1G0B4B3B2B1B0 X R4R3R2R1R0G4G3 0x0000
X: Alpha channel coloi infoimation, ignoieu.
R4-Ru: Reu channel coloi infoimation, u-S2.
B4-Bu: uieen channel coloi infoimation, u-S2.
B4-Bu: Blue channel coloi infoimation, u-S2.
=5)*)4#"* !*)05$43
Togethei, the memoiy aieas RAN_PIC, RAN_CBR, anu RAN_PAL uefine the
chaiactei giaphics pictuie that is uisplayeu behinu the game spiites anu in fiont of
the backgiounu coloi. This pictuie consists of a logical S12S12 pixel image, but a
full bitmap of 2-byte colois woulu occupy a half-megabyte - obviously an issue foi a
uevice with only S2kbytes of auuiess space. Insteau, RAN_PIC contains a 6464 giiu
of one-byte chaiacteis, wheie each chaiactei in the giiu iepiesents one of 2S6 88
BRAFT uameuuino Refeience Nanual
S1
pixel bitmaps stoieu in RAN_CBR. Each chaiactei in the giiu also has its own 4-coloi
palette in RAN_PAL.
kAM_IC: |ayf|e|d |cture
RAN_PIC contains a 6464 giiu of chaiacteis that uefines the chaiactei giaphics
pictuie. Each byte in RAN_PIC iepiesents a chaiactei bitmap to be lookeu up in
RAN_CBR. Chaiactei bitmaps aie 88 pixels anu can select one of foui colois; coloi
infoimation foi each pixel is uiawn fiom RAN_PAL. Chaiactei giaphics pixels may
be tianspaient, allowing the backgiounu coloi to show thiough. The iesult is a
S12S12 pixel chaiactei giaphics pictuie that foims the playfielu foi game sketches.
The oiganization of the playfielu is shown in Table 2S: RAN_PIC Nemoiy Nap.

A 4uuSuu pixel (SuS7V chaiactei) winuow of this pictuie is visible on scieen.
The winuow may be sciolleu aiounu the pictuie on a single-pixel basis, so that paits
of as many as S1S9 chaiacteis may be fully oi paitially visible. The uameuuino's
memoiy is uual-poiteu, so chaiacteis that aie not cuiiently on scieen can be
upuateu by the Aiuuino SPI inteiface oi by the }1 copiocessoi without causing
visible aitifacts.
kAM_Cnk: |ayf|e|d Character Set
Each chaiactei coue in RAN_PIC is lookeu up in RAN_CBR to ueteimine the
coiiesponuing 88 pixel chaiactei bitmap that shoulu be uisplayeu at the chaiactei
position. Theie aie 2S6 bitmaps, one foi each possible chaiactei coue stoieu in
RAN_PIC. Table 26: RAN_CBR Nemoiy Nap shows the oiganization of the
chaiactei set memoiy. Chaiactei coues aie listeu in hexauecimal anu uecimal, along
with the ASCII glyph foi chaiacteis SS thiough 126 (uxS1 thiough ux7F). ulyphs
that aie not piintable ASCII chaiacteis aie shaueu giey.

The RAN_CBR bitmaps ueteimine the giaphic that is uisplayeu at each chaiactei
location. Chaiactei bitmaps contain 4 colois anu aie theiefoie 2 bits ueep; each
chaiactei bitmap occupies 16 bytes. The foimat of each chaiactei bitmap is shown
in Table 22: RAN_CBR Bitmap 0iganization. Pixels in the chaiactei bitmap have
cooiuinates staiting at (u,u) foi the uppei left-hanu coinei of the bitmap, to (7,7) at
the lowei iight. Each pixel is two bits, the value u-S selects one of the foui colois
stoieu in the coiiesponuing chaiactei palette in RAN_PAL.

@,A5" 00* !GUcR+! K72<,? H&L,47>,27$4
Row 0ffset Byte 0ffset anu Bitmap Contents
(hex) (uec) +0 +1
+0x00 +0 P001P000 P101P100 P201P200 P301P300 P401P400 P501P500 P601P600 P701P700
+0x02 +2 P011P010 P111P110 P211P210 P311P310 P411P410 P511P510 P611P610 P711P710
+0x04 +4 P021P020 P121P120 P221P220 P321P320 P421P420 P521P520 P621P620 P721P720
+0x06 +6 P031P030 P131P130 P231P230 P331P330 P431P430 P531P530 P631P630 P731P730
+0x08 +8 P041P040 P141P140 P241P240 P341P340 P441P440 P541P540 P641P640 P741P740
+0x0A +10 P051P050 P151P150 P251P250 P351P350 P451P450 P551P550 P651P650 P751P750
+0x0C +12 P061P060 P161P160 P261P260 P361P360 P461P460 P561P560 P661P660 P761P760
+0x0D +14 P071P070 P171P170 P271P270 P371P370 P471P470 P571P570 P671P670 P771P770
Pxy1Pxyu: Pixel value at bitmap location (x,y), u-S.
BRAFT uameuuino Refeience Nanual
S2

H4"#"?2&# .&2)I Table 26: RAN_CBR Nemoiy Nap shows ASCII glyphs foi
convenience. In ASCII, the contiol chaiacteis at u thiough S1 (uxuu thiough ux1F)
anu 127 (ux7F) aien't piintable ASCII chaiacteis, while chaiactei coues 128
thiough 2SS (ux8u thiough uxFF) aie unuefineu. This makes these chaiacteis goou
canuiuates foi use as playfielu giaphics insteau of alphabetic anu numeiic symbols.

ASCII is a ielatively olu stanuaiu; seveial moie mouein stanuaius exist, anu all aie
supeisets of the ASCII stanuaiu. Table 2S: Chaiactei Sets shows the ielationship
between six populai coue pages. All shaie the same uefinition foi chaiacteis (coue
points) between u anu 127 (uxuu anu ux7F) with ASCII.

@,A5" 0J* R9,&,'2"& /"2#
Chaiactei Set
Chaiactei Coues
0x00-0x1F 0x20-0x7E 0x7F 0x80-0x9F 0xA0-0xFF
ASCII Contiol Piintable Contiol 0nuefineu 0nuefineu
Winuows-12S2 Contiol Piintable Contiol Piintable Piintable
Nac 0S Roman Contiol Piintable Contiol Piintable Piintable
IS0-88S9-1 Contiol Piintable Contiol Contiol Piintable
IS0-88S9-1S Contiol Piintable Contiol Contiol Piintable
0TF-8 Contiol Piintable Contiol Nulti-byte Nulti-byte

Nost Winuows systems configuieu foi a Westein alphabet uses the Winuows-12S2
chaiactei set. Apple piouucts use Nac 0S Roman foi the same puipose. The two
chaiactei sets of couise uiffei on the chaiacteis above coue 127 (ux7F); aftei all,
when have Reumonu anu Cupeitino been able to completely agiee on anything.

The ielevant stanuaius aie IS0-88S9-1 anu its upuateu veision, IS0-88S9-1S (which
incluues the Euio chaiactei anu a few othei mouifications). 0TF-8 is an 8-bit
encouing foi 0nicoue that maximizes ASCII compatibility: coues u thiough 127
(uxuu thiough ux7F) match ASCII, while the highei coues aie only encounteieu as
pait of multi-byte sequences that encoue the iest of the 0nicoue chaiactei set.
kAM_AL: |ayf|e|d Character a|ettes
Each chaiactei on the playfielu has its own 4-coloi palette in RAN_PAL. This means
that each chaiactei has its own coloi palette, anu also that chaiacteis that have
iuentical bitmaps but iequiie uiffeient colois must be stoieu as sepaiate chaiacteis.
Coloi uata is stoieu in stanuaiu ARuB1SSS foimat, iesulting in 2S6 chaiactei
palettes, each palette occupying 8 bytes. The oveiall stiuctuie of RAN_PAL is shown
in Table 27: RAN_PAL Nemoiy Nap.

The inuiviuual palettes aie composeu of 4 coloi entiies, numbeieu u thiough 4 as
shown in Table 24: RAN_PAL Palette Foimat. Chaiactei bitmap pixels map uiiectly
to the palette entiies: bitmap pixel values of u aie uisplayeu in the coloi entiy u,
pixel value 1 is uisplayeu using coloi entiy 1, anu so on. Tianspaiency can be set foi
BRAFT uameuuino Refeience Nanual
SS
any coloi oi colois in the palette. It is customaiy to coue chaiactei sets so that coloi
entiy u (pixel value u) coiiesponus to the backgiounu oi tianspaient coloi.

@,A5" 0P* !GUcTG6 T,5"22" I$&<,2
Coloi
Entiy
Entiy
0ffset
Byte 0ffset
+u +1
u +u G2G1G0B4B3B2B1B0 A R4R3R2R1R0G4G3
1 +2 G2G1G0B4B3B2B1B0 A R4R3R2R1R0G4G3
2 +4 G2G1G0B4B3B2B1B0 A R4R3R2R1R0G4G3
S +6 G2G1G0B4B3B2B1B0 A R4R3R2R1R0G4G3
A: Alpha channel coloi infoimation, u=opaque, 1=tianspaient.
Ru-R4: Reu channel coloi infoimation, u-S2; ignoieu when A=1.
Bu-B4: uieen channel coloi infoimation, u-S2; ignoieu when A=1.
Bu-B4: Blue channel coloi infoimation, u-S2; ignoieu when A=1.


B
R
A
F
T

u
a
m
e
u
u
i
n
o

R
e
f
e
i
e
n
c
e

N
a
n
u
a
l


S
4

!
"
#
$
%

'
(
)

*
+
,
-
.
/
0

,
%
1
2
3
4

,
"
5

R
o
w

N
u
m
b
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

B
e
f
a
u
l
t

(
h
e
x
)

(
u
e
c
)


(
h
e
x
)

(
u
e
c
)




0
x
0
0

0


0
x
0
0
0
0

0


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
1

1


0
x
0
0
4
0

6
4


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
2

2


0
x
0
0
8
0

1
2
8


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
3

3


0
x
0
0
C
0

1
9
2


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
4

4


0
x
0
1
0
0

2
5
6


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
5

5


0
x
0
1
4
0

3
2
0


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
6

6


0
x
0
1
8
0

3
8
4


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
7

7


0
x
0
1
C
0

4
4
8


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
8

8


0
x
0
2
0
0

5
1
2


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
9

9


0
x
0
2
4
0

5
7
6


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
A

1
0


0
x
0
2
8
0

6
4
0


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
B

1
1


0
x
0
2
C
0

7
0
4


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
C

1
2


0
x
0
3
0
0

7
6
8


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
D

1
3


0
x
0
3
4
0

8
3
2


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
E

1
4


0
x
0
3
8
0

8
9
6


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
0
F

1
5


0
x
0
3
C
0

9
6
0


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
0

1
6


0
x
0
4
0
0

1
0
2
4


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
1

1
7


0
x
0
4
4
0

1
0
8
8


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
2

1
8


0
x
0
4
8
0

1
1
5
2


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
3

1
9


0
x
0
4
C
0

1
2
1
6


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
4

2
0


0
x
0
5
0
0

1
2
8
0


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
5

2
1


0
x
0
5
4
0

1
3
4
4


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
6

2
2


0
x
0
5
8
0

1
4
0
8


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
7

2
3


0
x
0
5
C
0

1
4
7
2


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
8

2
4


0
x
0
6
0
0

1
5
3
6


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
9

2
5


0
x
0
6
4
0

1
6
0
0


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
A

2
6


0
x
0
6
8
0

1
6
6
4


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
B

2
7


0
x
0
6
C
0

1
7
2
8


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
C

2
8


0
x
0
7
0
0

1
7
9
2


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
D

2
9


0
x
0
7
4
0

1
8
5
6


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
E

3
0


0
x
0
7
8
0

1
9
2
0


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
1
F

3
1


0
x
0
7
C
0

1
9
8
4


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

R
o
w

N
u
m
b
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

B
e
f
a
u
l
t

(
h
e
x
)

(
u
e
c
)


(
h
e
x
)

(
u
e
c
)




0
x
2
0

3
2


0
x
0
8
0
0

2
0
4
8


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
1

3
3


0
x
0
8
4
0

2
1
1
2


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
2

3
4


0
x
0
8
8
0

2
1
7
6


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
3

3
5


0
x
0
8
C
0

2
2
4
0


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
4

3
6


0
x
0
9
0
0

2
3
0
4


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
5

3
7


0
x
0
9
4
0

2
3
6
8


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
6

3
8


0
x
0
9
8
0

2
4
3
2


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
7

3
9


0
x
0
9
C
0

2
4
9
6


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
8

4
0


0
x
0
A
0
0

2
5
6
0


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
9

4
1


0
x
0
A
4
0

2
6
2
4


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
A

4
2


0
x
0
A
8
0

2
6
8
8


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
B

4
3


0
x
0
A
C
0

2
7
5
2


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
C

4
4


0
x
0
B
0
0

2
8
1
6


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
D

4
5


0
x
0
B
4
0

2
8
8
0


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
E

4
6


0
x
0
B
8
0

2
9
4
4


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
2
F

4
7


0
x
0
B
C
0

3
0
0
8


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
0

4
8


0
x
0
C
0
0

3
0
7
2


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
1

4
9


0
x
0
C
4
0

3
1
3
6


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
2

5
0


0
x
0
C
8
0

3
2
0
0


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
3

5
1


0
x
0
C
C
0

3
2
6
4


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
4

5
2


0
x
0
D
0
0

3
3
2
8


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
5

5
3


0
x
0
D
4
0

3
3
9
2


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
6

5
4


0
x
0
D
8
0

3
4
5
6


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
7

5
5


0
x
0
D
C
0

3
5
2
0


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
8

5
6


0
x
0
E
0
0

3
5
8
4


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
9

5
7


0
x
0
E
4
0

3
6
4
8


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
A

5
8


0
x
0
E
8
0

3
7
1
2


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
B

5
9


0
x
0
E
C
0

3
7
7
6


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
C

6
0


0
x
0
F
0
0

3
8
4
0


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
D

6
1


0
x
0
F
4
0

3
9
0
4


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
E

6
2


0
x
0
F
8
0

3
9
6
8


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

0
x
3
F

6
3


0
x
0
F
C
0

4
0
3
2


6
4

c
h
a
i
a
c
t
e
i

c
o
u
e
s

0
x
0
0

B
R
A
F
T

u
a
m
e
u
u
i
n
o

R
e
f
e
i
e
n
c
e

N
a
n
u
a
l


S
S

!
"
#
$
%

'
6
)

*
+
,
-
0
7
*

,
%
1
2
3
4

,
"
5

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
0
0

0



0
x
1
0
0
0

4
0
9
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
1

1



0
x
1
0
1
0

4
1
1
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
2

2



0
x
1
0
2
0

4
1
2
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
3

3



0
x
1
0
3
0

4
1
4
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
4

4



0
x
1
0
4
0

4
1
6
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
5

5



0
x
1
0
5
0

4
1
7
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
6

6



0
x
1
0
6
0

4
1
9
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
7

7



0
x
1
0
7
0

4
2
0
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
8

8



0
x
1
0
8
0

4
2
2
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
9

9



0
x
1
0
9
0

4
2
4
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
A

1
0



0
x
1
0
A
0

4
2
5
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
B

1
1



0
x
1
0
B
0

4
2
7
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
C

1
2



0
x
1
0
C
0

4
2
8
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
D

1
3



0
x
1
0
D
0

4
3
0
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
E

1
4



0
x
1
0
E
0

4
3
2
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
0
F

1
5



0
x
1
0
F
0

4
3
3
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
0

1
6



0
x
1
1
0
0

4
3
5
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
1

1
7



0
x
1
1
1
0

4
3
6
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
2

1
8



0
x
1
1
2
0

4
3
8
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
3

1
9



0
x
1
1
3
0

4
4
0
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
4

2
0



0
x
1
1
4
0

4
4
1
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
5

2
1



0
x
1
1
5
0

4
4
3
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
6

2
2



0
x
1
1
6
0

4
4
4
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
7

2
3



0
x
1
1
7
0

4
4
6
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
8

2
4



0
x
1
1
8
0

4
4
8
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
9

2
5



0
x
1
1
9
0

4
4
9
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
A

2
6



0
x
1
1
A
0

4
5
1
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
B

2
7



0
x
1
1
B
0

4
5
2
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
C

2
8



0
x
1
1
C
0

4
5
4
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
D

2
9



0
x
1
1
D
0

4
5
6
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
E

3
0



0
x
1
1
E
0

4
5
7
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
1
F

3
1



0
x
1
1
F
0

4
5
9
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
2
0

3
2



0
x
1
2
0
0

4
6
0
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
1

3
3

!


0
x
1
2
1
0

4
6
2
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
2

3
4

"


0
x
1
2
2
0

4
6
4
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
3

3
5

#


0
x
1
2
3
0

4
6
5
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
4

3
6

$


0
x
1
2
4
0

4
6
7
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
5

3
7

%


0
x
1
2
5
0

4
6
8
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
6

3
8

&


0
x
1
2
6
0

4
7
0
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
7

3
9

'


0
x
1
2
7
0

4
7
2
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
8

4
0

(


0
x
1
2
8
0

4
7
3
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
9

4
1

)


0
x
1
2
9
0

4
7
5
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
A

4
2

*


0
x
1
2
A
0

4
7
6
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
B

4
3

+


0
x
1
2
B
0

4
7
8
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
C

4
4

,


0
x
1
2
C
0

4
8
0
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
D

4
5

-


0
x
1
2
D
0

4
8
1
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
E

4
6

.


0
x
1
2
E
0

4
8
3
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
2
F

4
7



0
x
1
2
F
0

4
8
4
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
0

4
8

u


0
x
1
3
0
0

4
8
6
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
1

4
9

1


0
x
1
3
1
0

4
8
8
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
2

5
0

2


0
x
1
3
2
0

4
8
9
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
3

5
1

S


0
x
1
3
3
0

4
9
1
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
4

5
2

4


0
x
1
3
4
0

4
9
2
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
5

5
3

S


0
x
1
3
5
0

4
9
4
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
6

5
4

6


0
x
1
3
6
0

4
9
6
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
7

5
5

7


0
x
1
3
7
0

4
9
7
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
8

5
6

8


0
x
1
3
8
0

4
9
9
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
9

5
7

9


0
x
1
3
9
0

5
0
0
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
A

5
8

:


0
x
1
3
A
0

5
0
2
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
B

5
9

;


0
x
1
3
B
0

5
0
4
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
C

6
0

<


0
x
1
3
C
0

5
0
5
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
D

6
1

=


0
x
1
3
D
0

5
0
7
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
E

6
2

>


0
x
1
3
E
0

5
0
8
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
3
F

6
3

.


0
x
1
3
F
0

5
1
0
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

B
R
A
F
T

u
a
m
e
u
u
i
n
o

R
e
f
e
i
e
n
c
e

N
a
n
u
a
l


S
6

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
4
0

6
4



0
x
1
4
0
0

5
1
2
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
1

6
5

A


0
x
1
4
1
0

5
1
3
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
2

6
6

B


0
x
1
4
2
0

5
1
5
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
3

6
7

C


0
x
1
4
3
0

5
1
6
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
4

6
8

B


0
x
1
4
4
0

5
1
8
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
5

6
9

E


0
x
1
4
5
0

5
2
0
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
6

7
0

F


0
x
1
4
6
0

5
2
1
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
7

7
1

u


0
x
1
4
7
0

5
2
3
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
8

7
2

B


0
x
1
4
8
0

5
2
4
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
9

7
3

I


0
x
1
4
9
0

5
2
6
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
A

7
4

}


0
x
1
4
A
0

5
2
8
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
B

7
5

K


0
x
1
4
B
0

5
2
9
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
C

7
6

L


0
x
1
4
C
0

5
3
1
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
D

7
7

N


0
x
1
4
D
0

5
3
2
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
E

7
8

N


0
x
1
4
E
0

5
3
4
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
4
F

7
9

0


0
x
1
4
F
0

5
3
6
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
0

8
0

P


0
x
1
5
0
0

5
3
7
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
1

8
1

Q


0
x
1
5
1
0

5
3
9
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
2

8
2

R


0
x
1
5
2
0

5
4
0
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
3

8
3

S


0
x
1
5
3
0

5
4
2
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
4

8
4

T


0
x
1
5
4
0

5
4
4
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
5

8
5

0


0
x
1
5
5
0

5
4
5
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
6

8
6

v


0
x
1
5
6
0

5
4
7
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
7

8
7

W


0
x
1
5
7
0

5
4
8
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
8

8
8

X


0
x
1
5
8
0

5
5
0
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
9

8
9

Y


0
x
1
5
9
0

5
5
2
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
A

9
0

Z


0
x
1
5
A
0

5
5
3
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
B

9
1

|


0
x
1
5
B
0

5
5
5
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
C

9
2

\


0
x
1
5
C
0

5
5
6
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
D

9
3

j


0
x
1
5
D
0

5
5
8
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
E

9
4

^


0
x
1
5
E
0

5
6
0
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
5
F

9
5

_


0
x
1
5
F
0

5
6
1
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
6
0

9
6

`


0
x
1
6
0
0

5
6
3
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
1

9
7

a


0
x
1
6
1
0

5
6
4
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
2

9
8

b


0
x
1
6
2
0

5
6
6
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
3

9
9

c


0
x
1
6
3
0

5
6
8
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
4

1
0
0

u


0
x
1
6
4
0

5
6
9
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
5

1
0
1

e


0
x
1
6
5
0

5
7
1
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
6

1
0
2

f


0
x
1
6
6
0

5
7
2
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
7

1
0
3

g


0
x
1
6
7
0

5
7
4
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
8

1
0
4

h


0
x
1
6
8
0

5
7
6
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
9

1
0
5

i


0
x
1
6
9
0

5
7
7
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
A

1
0
6

j


0
x
1
6
A
0

5
7
9
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
B

1
0
7

k


0
x
1
6
B
0

5
8
0
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
C

1
0
8

l


0
x
1
6
C
0

5
8
2
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
D

1
0
9

m


0
x
1
6
D
0

5
8
4
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
E

1
1
0

n


0
x
1
6
E
0

5
8
5
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
6
F

1
1
1

o


0
x
1
6
F
0

5
8
7
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
0

1
1
2

p


0
x
1
7
0
0

5
8
8
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
1

1
1
3

q


0
x
1
7
1
0

5
9
0
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
2

1
1
4

i


0
x
1
7
2
0

5
9
2
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
3

1
1
5

s


0
x
1
7
3
0

5
9
3
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
4

1
1
6

t


0
x
1
7
4
0

5
9
5
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
5

1
1
7

u


0
x
1
7
5
0

5
9
6
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
6

1
1
8

v


0
x
1
7
6
0

5
9
8
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
7

1
1
9

w


0
x
1
7
7
0

6
0
0
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
8

1
2
0

x


0
x
1
7
8
0

6
0
1
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
9

1
2
1

y


0
x
1
7
9
0

6
0
3
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
A

1
2
2

z


0
x
1
7
A
0

6
0
4
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
B

1
2
3

{


0
x
1
7
B
0

6
0
6
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
C

1
2
4

|


0
x
1
7
C
0

6
0
8
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
D

1
2
5



0
x
1
7
D
0

6
0
9
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
E

1
2
6



0
x
1
7
E
0

6
1
1
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
7
F

1
2
7



0
x
1
7
F
0

6
1
2
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

B
R
A
F
T

u
a
m
e
u
u
i
n
o

R
e
f
e
i
e
n
c
e

N
a
n
u
a
l


S
7

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
8
0

1
2
8



0
x
1
8
0
0

6
1
4
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
1

1
2
9



0
x
1
8
1
0

6
1
6
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
2

1
3
0



0
x
1
8
2
0

6
1
7
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
3

1
3
1



0
x
1
8
3
0

6
1
9
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
4

1
3
2



0
x
1
8
4
0

6
2
0
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
5

1
3
3



0
x
1
8
5
0

6
2
2
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
6

1
3
4



0
x
1
8
6
0

6
2
4
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
7

1
3
5



0
x
1
8
7
0

6
2
5
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
8

1
3
6



0
x
1
8
8
0

6
2
7
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
9

1
3
7



0
x
1
8
9
0

6
2
8
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
A

1
3
8



0
x
1
8
A
0

6
3
0
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
B

1
3
9



0
x
1
8
B
0

6
3
2
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
C

1
4
0



0
x
1
8
C
0

6
3
3
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
D

1
4
1



0
x
1
8
D
0

6
3
5
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
E

1
4
2



0
x
1
8
E
0

6
3
6
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
8
F

1
4
3



0
x
1
8
F
0

6
3
8
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
0

1
4
4



0
x
1
9
0
0

6
4
0
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
1

1
4
5



0
x
1
9
1
0

6
4
1
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
2

1
4
6



0
x
1
9
2
0

6
4
3
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
3

1
4
7



0
x
1
9
3
0

6
4
4
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
4

1
4
8



0
x
1
9
4
0

6
4
6
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
5

1
4
9



0
x
1
9
5
0

6
4
8
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
6

1
5
0



0
x
1
9
6
0

6
4
9
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
7

1
5
1



0
x
1
9
7
0

6
5
1
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
8

1
5
2



0
x
1
9
8
0

6
5
2
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
9

1
5
3



0
x
1
9
9
0

6
5
4
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
A

1
5
4



0
x
1
9
A
0

6
5
6
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
B

1
5
5



0
x
1
9
B
0

6
5
7
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
C

1
5
6



0
x
1
9
C
0

6
5
9
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
D

1
5
7



0
x
1
9
D
0

6
6
0
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
E

1
5
8



0
x
1
9
E
0

6
6
2
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
9
F

1
5
9



0
x
1
9
F
0

6
6
4
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
A
0

1
6
0



0
x
1
A
0
0

6
6
5
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
1

1
6
1



0
x
1
A
1
0

6
6
7
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
2

1
6
2



0
x
1
A
2
0

6
6
8
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
3

1
6
3



0
x
1
A
3
0

6
7
0
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
4

1
6
4



0
x
1
A
4
0

6
7
2
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
5

1
6
5



0
x
1
A
5
0

6
7
3
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
6

1
6
6



0
x
1
A
6
0

6
7
5
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
7

1
6
7



0
x
1
A
7
0

6
7
6
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
8

1
6
8



0
x
1
A
8
0

6
7
8
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
9

1
6
9



0
x
1
A
9
0

6
8
0
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
A

1
7
0



0
x
1
A
A
0

6
8
1
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
B

1
7
1



0
x
1
A
B
0

6
8
3
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
C

1
7
2



0
x
1
A
C
0

6
8
4
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
D

1
7
3



0
x
1
A
D
0

6
8
6
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
E

1
7
4



0
x
1
A
E
0

6
8
8
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
A
F

1
7
5



0
x
1
A
F
0

6
8
9
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
0

1
7
6



0
x
1
B
0
0

6
9
1
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
1

1
7
7



0
x
1
B
1
0

6
9
2
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
2

1
7
8



0
x
1
B
2
0

6
9
4
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
3

1
7
9



0
x
1
B
3
0

6
9
6
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
4

1
8
0



0
x
1
B
4
0

6
9
7
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
5

1
8
1



0
x
1
B
5
0

6
9
9
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
6

1
8
2



0
x
1
B
6
0

7
0
0
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
7

1
8
3



0
x
1
B
7
0

7
0
2
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
8

1
8
4



0
x
1
B
8
0

7
0
4
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
9

1
8
5



0
x
1
B
9
0

7
0
5
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
A

1
8
6



0
x
1
B
A
0

7
0
7
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
B

1
8
7



0
x
1
B
B
0

7
0
8
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
C

1
8
8



0
x
1
B
C
0

7
1
0
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
D

1
8
9



0
x
1
B
D
0

7
1
2
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
E

1
9
0



0
x
1
B
E
0

7
1
3
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
B
F

1
9
1



0
x
1
B
F
0

7
1
5
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

B
R
A
F
T

u
a
m
e
u
u
i
n
o

R
e
f
e
i
e
n
c
e

N
a
n
u
a
l


S
8

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
C
0

1
9
2



0
x
1
C
0
0

7
1
6
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
1

1
9
3



0
x
1
C
1
0

7
1
8
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
2

1
9
4



0
x
1
C
2
0

7
2
0
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
3

1
9
5



0
x
1
C
3
0

7
2
1
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
4

1
9
6



0
x
1
C
4
0

7
2
3
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
5

1
9
7



0
x
1
C
5
0

7
2
4
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
6

1
9
8



0
x
1
C
6
0

7
2
6
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
7

1
9
9



0
x
1
C
7
0

7
2
8
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
8

2
0
0



0
x
1
C
8
0

7
2
9
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
9

2
0
1



0
x
1
C
9
0

7
3
1
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
A

2
0
2



0
x
1
C
A
0

7
3
2
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
B

2
0
3



0
x
1
C
B
0

7
3
4
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
C

2
0
4



0
x
1
C
C
0

7
3
6
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
D

2
0
5



0
x
1
C
D
0

7
3
7
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
E

2
0
6



0
x
1
C
E
0

7
3
9
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
C
F

2
0
7



0
x
1
C
F
0

7
4
0
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
0

2
0
8



0
x
1
D
0
0

7
4
2
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
1

2
0
9



0
x
1
D
1
0

7
4
4
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
2

2
1
0



0
x
1
D
2
0

7
4
5
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
3

2
1
1



0
x
1
D
3
0

7
4
7
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
4

2
1
2



0
x
1
D
4
0

7
4
8
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
5

2
1
3



0
x
1
D
5
0

7
5
0
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
6

2
1
4



0
x
1
D
6
0

7
5
2
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
7

2
1
5



0
x
1
D
7
0

7
5
3
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
8

2
1
6



0
x
1
D
8
0

7
5
5
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
9

2
1
7



0
x
1
D
9
0

7
5
6
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
A

2
1
8



0
x
1
D
A
0

7
5
8
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
B

2
1
9



0
x
1
D
B
0

7
6
0
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
C

2
2
0



0
x
1
D
C
0

7
6
1
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
D

2
2
1



0
x
1
D
D
0

7
6
3
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
E

2
2
2



0
x
1
D
E
0

7
6
4
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
D
F

2
2
3



0
x
1
D
F
0

7
6
6
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
E
0

2
2
4



0
x
1
E
0
0

7
6
8
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
1

2
2
5



0
x
1
E
1
0

7
6
9
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
2

2
2
6



0
x
1
E
2
0

7
7
1
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
3

2
2
7



0
x
1
E
3
0

7
7
2
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
4

2
2
8



0
x
1
E
4
0

7
7
4
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
5

2
2
9



0
x
1
E
5
0

7
7
6
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
6

2
3
0



0
x
1
E
6
0

7
7
7
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
7

2
3
1



0
x
1
E
7
0

7
7
9
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
8

2
3
2



0
x
1
E
8
0

7
8
0
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
9

2
3
3



0
x
1
E
9
0

7
8
2
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
A

2
3
4



0
x
1
E
A
0

7
8
4
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
B

2
3
5



0
x
1
E
B
0

7
8
5
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
C

2
3
6



0
x
1
E
C
0

7
8
7
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
D

2
3
7



0
x
1
E
D
0

7
8
8
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
E

2
3
8



0
x
1
E
E
0

7
9
0
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
E
F

2
3
9



0
x
1
E
F
0

7
9
2
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
0

2
4
0



0
x
1
F
0
0

7
9
3
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
1

2
4
1



0
x
1
F
1
0

7
9
5
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
2

2
4
2



0
x
1
F
2
0

7
9
6
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
3

2
4
3



0
x
1
F
3
0

7
9
8
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
4

2
4
4



0
x
1
F
4
0

8
0
0
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
5

2
4
5



0
x
1
F
5
0

8
0
1
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
6

2
4
6



0
x
1
F
6
0

8
0
3
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
7

2
4
7



0
x
1
F
7
0

8
0
4
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
8

2
4
8



0
x
1
F
8
0

8
0
6
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
9

2
4
9



0
x
1
F
9
0

8
0
8
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
A

2
5
0



0
x
1
F
A
0

8
0
9
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
B

2
5
1



0
x
1
F
B
0

8
1
1
2


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
C

2
5
2



0
x
1
F
C
0

8
1
2
8


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
D

2
5
3



0
x
1
F
D
0

8
1
4
4


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
E

2
5
4



0
x
1
F
E
0

8
1
6
0


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

0
x
F
F

2
5
5



0
x
1
F
F
0

8
1
7
6


8

2

b
i
t
m
a
p
,

1
6

b
y
t
e
s

B
R
A
F
T

u
a
m
e
u
u
i
n
o

R
e
f
e
i
e
n
c
e

N
a
n
u
a
l


S
9

!
"
#
$
%

'
8
)

*
+
,
-
.
+
9

,
%
1
2
3
4

,
"
5

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
0
0

0



0
x
2
0
0
0

8
1
9
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
1

1



0
x
2
0
0
8

8
2
0
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
2

2



0
x
2
0
1
0

8
2
0
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
3

3



0
x
2
0
1
8

8
2
1
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
4

4



0
x
2
0
2
0

8
2
2
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
5

5



0
x
2
0
2
8

8
2
3
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
6

6



0
x
2
0
3
0

8
2
4
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
7

7



0
x
2
0
3
8

8
2
4
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
8

8



0
x
2
0
4
0

8
2
5
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
9

9



0
x
2
0
4
8

8
2
6
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
A

1
0



0
x
2
0
5
0

8
2
7
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
B

1
1



0
x
2
0
5
8

8
2
8
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
C

1
2



0
x
2
0
6
0

8
2
8
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
D

1
3



0
x
2
0
6
8

8
2
9
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
E

1
4



0
x
2
0
7
0

8
3
0
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
0
F

1
5



0
x
2
0
7
8

8
3
1
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
0

1
6



0
x
2
0
8
0

8
3
2
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
1

1
7



0
x
2
0
8
8

8
3
2
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
2

1
8



0
x
2
0
9
0

8
3
3
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
3

1
9



0
x
2
0
9
8

8
3
4
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
4

2
0



0
x
2
0
A
0

8
3
5
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
5

2
1



0
x
2
0
A
8

8
3
6
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
6

2
2



0
x
2
0
B
0

8
3
6
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
7

2
3



0
x
2
0
B
8

8
3
7
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
8

2
4



0
x
2
0
C
0

8
3
8
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
9

2
5



0
x
2
0
C
8

8
3
9
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
A

2
6



0
x
2
0
D
0

8
4
0
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
B

2
7



0
x
2
0
D
8

8
4
0
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
C

2
8



0
x
2
0
E
0

8
4
1
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
D

2
9



0
x
2
0
E
8

8
4
2
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
E

3
0



0
x
2
0
F
0

8
4
3
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
1
F

3
1



0
x
2
0
F
8

8
4
4
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
2
0

3
2



0
x
2
1
0
0

8
4
4
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
1

3
3

!


0
x
2
1
0
8

8
4
5
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
2

3
4

"


0
x
2
1
1
0

8
4
6
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
3

3
5

#


0
x
2
1
1
8

8
4
7
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
4

3
6

$


0
x
2
1
2
0

8
4
8
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
5

3
7

%


0
x
2
1
2
8

8
4
8
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
6

3
8

&


0
x
2
1
3
0

8
4
9
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
7

3
9

'


0
x
2
1
3
8

8
5
0
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
8

4
0

(


0
x
2
1
4
0

8
5
1
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
9

4
1

)


0
x
2
1
4
8

8
5
2
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
A

4
2

*


0
x
2
1
5
0

8
5
2
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
B

4
3

+


0
x
2
1
5
8

8
5
3
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
C

4
4

,


0
x
2
1
6
0

8
5
4
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
D

4
5

-


0
x
2
1
6
8

8
5
5
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
E

4
6

.


0
x
2
1
7
0

8
5
6
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
2
F

4
7



0
x
2
1
7
8

8
5
6
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
0

4
8

u


0
x
2
1
8
0

8
5
7
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
1

4
9

1


0
x
2
1
8
8

8
5
8
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
2

5
0

2


0
x
2
1
9
0

8
5
9
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
3

5
1

S


0
x
2
1
9
8

8
6
0
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
4

5
2

4


0
x
2
1
A
0

8
6
0
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
5

5
3

S


0
x
2
1
A
8

8
6
1
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
6

5
4

6


0
x
2
1
B
0

8
6
2
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
7

5
5

7


0
x
2
1
B
8

8
6
3
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
8

5
6

8


0
x
2
1
C
0

8
6
4
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
9

5
7

9


0
x
2
1
C
8

8
6
4
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
A

5
8

:


0
x
2
1
D
0

8
6
5
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
B

5
9

;


0
x
2
1
D
8

8
6
6
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
C

6
0

<


0
x
2
1
E
0

8
6
7
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
D

6
1

=


0
x
2
1
E
8

8
6
8
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
E

6
2

>


0
x
2
1
F
0

8
6
8
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
3
F

6
3

.


0
x
2
1
F
8

8
6
9
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

B
R
A
F
T

u
a
m
e
u
u
i
n
o

R
e
f
e
i
e
n
c
e

N
a
n
u
a
l


4
u

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
4
0

6
4



0
x
2
2
0
0

8
7
0
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
1

6
5

A


0
x
2
2
0
8

8
7
1
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
2

6
6

B


0
x
2
2
1
0

8
7
2
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
3

6
7

C


0
x
2
2
1
8

8
7
2
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
4

6
8

B


0
x
2
2
2
0

8
7
3
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
5

6
9

E


0
x
2
2
2
8

8
7
4
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
6

7
0

F


0
x
2
2
3
0

8
7
5
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
7

7
1

u


0
x
2
2
3
8

8
7
6
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
8

7
2

B


0
x
2
2
4
0

8
7
6
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
9

7
3

I


0
x
2
2
4
8

8
7
7
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
A

7
4

}


0
x
2
2
5
0

8
7
8
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
B

7
5

K


0
x
2
2
5
8

8
7
9
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
C

7
6

L


0
x
2
2
6
0

8
8
0
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
D

7
7

N


0
x
2
2
6
8

8
8
0
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
E

7
8

N


0
x
2
2
7
0

8
8
1
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
4
F

7
9

0


0
x
2
2
7
8

8
8
2
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
0

8
0

P


0
x
2
2
8
0

8
8
3
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
1

8
1

Q


0
x
2
2
8
8

8
8
4
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
2

8
2

R


0
x
2
2
9
0

8
8
4
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
3

8
3

S


0
x
2
2
9
8

8
8
5
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
4

8
4

T


0
x
2
2
A
0

8
8
6
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
5

8
5

0


0
x
2
2
A
8

8
8
7
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
6

8
6

v


0
x
2
2
B
0

8
8
8
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
7

8
7

W


0
x
2
2
B
8

8
8
8
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
8

8
8

X


0
x
2
2
C
0

8
8
9
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
9

8
9

Y


0
x
2
2
C
8

8
9
0
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
A

9
0

Z


0
x
2
2
D
0

8
9
1
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
B

9
1

|


0
x
2
2
D
8

8
9
2
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
C

9
2

\


0
x
2
2
E
0

8
9
2
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
D

9
3

j


0
x
2
2
E
8

8
9
3
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
E

9
4

^


0
x
2
2
F
0

8
9
4
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
5
F

9
5

_


0
x
2
2
F
8

8
9
5
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
6
0

9
6

`


0
x
2
3
0
0

8
9
6
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
1

9
7

a


0
x
2
3
0
8

8
9
6
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
2

9
8

b


0
x
2
3
1
0

8
9
7
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
3

9
9

c


0
x
2
3
1
8

8
9
8
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
4

1
0
0

u


0
x
2
3
2
0

8
9
9
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
5

1
0
1

e


0
x
2
3
2
8

9
0
0
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
6

1
0
2

f


0
x
2
3
3
0

9
0
0
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
7

1
0
3

g


0
x
2
3
3
8

9
0
1
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
8

1
0
4

h


0
x
2
3
4
0

9
0
2
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
9

1
0
5

i


0
x
2
3
4
8

9
0
3
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
A

1
0
6

j


0
x
2
3
5
0

9
0
4
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
B

1
0
7

k


0
x
2
3
5
8

9
0
4
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
C

1
0
8

l


0
x
2
3
6
0

9
0
5
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
D

1
0
9

m


0
x
2
3
6
8

9
0
6
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
E

1
1
0

n


0
x
2
3
7
0

9
0
7
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
6
F

1
1
1

o


0
x
2
3
7
8

9
0
8
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
0

1
1
2

p


0
x
2
3
8
0

9
0
8
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
1

1
1
3

q


0
x
2
3
8
8

9
0
9
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
2

1
1
4

i


0
x
2
3
9
0

9
1
0
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
3

1
1
5

s


0
x
2
3
9
8

9
1
1
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
4

1
1
6

t


0
x
2
3
A
0

9
1
2
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
5

1
1
7

u


0
x
2
3
A
8

9
1
2
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
6

1
1
8

v


0
x
2
3
B
0

9
1
3
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
7

1
1
9

w


0
x
2
3
B
8

9
1
4
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
8

1
2
0

x


0
x
2
3
C
0

9
1
5
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
9

1
2
1

y


0
x
2
3
C
8

9
1
6
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
A

1
2
2

z


0
x
2
3
D
0

9
1
6
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
B

1
2
3

{


0
x
2
3
D
8

9
1
7
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
C

1
2
4

|


0
x
2
3
E
0

9
1
8
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
D

1
2
5



0
x
2
3
E
8

9
1
9
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
E

1
2
6



0
x
2
3
F
0

9
2
0
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
7
F

1
2
7



0
x
2
3
F
8

9
2
0
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

B
R
A
F
T

u
a
m
e
u
u
i
n
o

R
e
f
e
i
e
n
c
e

N
a
n
u
a
l


4
1

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
8
0

1
2
8



0
x
2
4
0
0

9
2
1
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
1

1
2
9



0
x
2
4
0
8

9
2
2
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
2

1
3
0



0
x
2
4
1
0

9
2
3
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
3

1
3
1



0
x
2
4
1
8

9
2
4
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
4

1
3
2



0
x
2
4
2
0

9
2
4
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
5

1
3
3



0
x
2
4
2
8

9
2
5
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
6

1
3
4



0
x
2
4
3
0

9
2
6
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
7

1
3
5



0
x
2
4
3
8

9
2
7
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
8

1
3
6



0
x
2
4
4
0

9
2
8
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
9

1
3
7



0
x
2
4
4
8

9
2
8
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
A

1
3
8



0
x
2
4
5
0

9
2
9
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
B

1
3
9



0
x
2
4
5
8

9
3
0
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
C

1
4
0



0
x
2
4
6
0

9
3
1
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
D

1
4
1



0
x
2
4
6
8

9
3
2
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
E

1
4
2



0
x
2
4
7
0

9
3
2
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
8
F

1
4
3



0
x
2
4
7
8

9
3
3
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
0

1
4
4



0
x
2
4
8
0

9
3
4
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
1

1
4
5



0
x
2
4
8
8

9
3
5
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
2

1
4
6



0
x
2
4
9
0

9
3
6
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
3

1
4
7



0
x
2
4
9
8

9
3
6
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
4

1
4
8



0
x
2
4
A
0

9
3
7
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
5

1
4
9



0
x
2
4
A
8

9
3
8
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
6

1
5
0



0
x
2
4
B
0

9
3
9
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
7

1
5
1



0
x
2
4
B
8

9
4
0
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
8

1
5
2



0
x
2
4
C
0

9
4
0
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
9

1
5
3



0
x
2
4
C
8

9
4
1
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
A

1
5
4



0
x
2
4
D
0

9
4
2
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
B

1
5
5



0
x
2
4
D
8

9
4
3
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
C

1
5
6



0
x
2
4
E
0

9
4
4
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
D

1
5
7



0
x
2
4
E
8

9
4
4
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
E

1
5
8



0
x
2
4
F
0

9
4
5
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
9
F

1
5
9



0
x
2
4
F
8

9
4
6
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
A
0

1
6
0



0
x
2
5
0
0

9
4
7
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
1

1
6
1



0
x
2
5
0
8

9
4
8
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
2

1
6
2



0
x
2
5
1
0

9
4
8
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
3

1
6
3



0
x
2
5
1
8

9
4
9
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
4

1
6
4



0
x
2
5
2
0

9
5
0
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
5

1
6
5



0
x
2
5
2
8

9
5
1
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
6

1
6
6



0
x
2
5
3
0

9
5
2
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
7

1
6
7



0
x
2
5
3
8

9
5
2
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
8

1
6
8



0
x
2
5
4
0

9
5
3
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
9

1
6
9



0
x
2
5
4
8

9
5
4
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
A

1
7
0



0
x
2
5
5
0

9
5
5
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
B

1
7
1



0
x
2
5
5
8

9
5
6
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
C

1
7
2



0
x
2
5
6
0

9
5
6
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
D

1
7
3



0
x
2
5
6
8

9
5
7
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
E

1
7
4



0
x
2
5
7
0

9
5
8
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
A
F

1
7
5



0
x
2
5
7
8

9
5
9
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
0

1
7
6



0
x
2
5
8
0

9
6
0
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
1

1
7
7



0
x
2
5
8
8

9
6
0
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
2

1
7
8



0
x
2
5
9
0

9
6
1
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
3

1
7
9



0
x
2
5
9
8

9
6
2
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
4

1
8
0



0
x
2
5
A
0

9
6
3
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
5

1
8
1



0
x
2
5
A
8

9
6
4
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
6

1
8
2



0
x
2
5
B
0

9
6
4
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
7

1
8
3



0
x
2
5
B
8

9
6
5
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
8

1
8
4



0
x
2
5
C
0

9
6
6
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
9

1
8
5



0
x
2
5
C
8

9
6
7
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
A

1
8
6



0
x
2
5
D
0

9
6
8
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
B

1
8
7



0
x
2
5
D
8

9
6
8
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
C

1
8
8



0
x
2
5
E
0

9
6
9
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
D

1
8
9



0
x
2
5
E
8

9
7
0
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
E

1
9
0



0
x
2
5
F
0

9
7
1
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
B
F

1
9
1



0
x
2
5
F
8

9
7
2
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

B
R
A
F
T

u
a
m
e
u
u
i
n
o

R
e
f
e
i
e
n
c
e

N
a
n
u
a
l


4
2

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
C
0

1
9
2



0
x
2
6
0
0

9
7
2
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
1

1
9
3



0
x
2
6
0
8

9
7
3
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
2

1
9
4



0
x
2
6
1
0

9
7
4
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
3

1
9
5



0
x
2
6
1
8

9
7
5
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
4

1
9
6



0
x
2
6
2
0

9
7
6
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
5

1
9
7



0
x
2
6
2
8

9
7
6
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
6

1
9
8



0
x
2
6
3
0

9
7
7
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
7

1
9
9



0
x
2
6
3
8

9
7
8
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
8

2
0
0



0
x
2
6
4
0

9
7
9
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
9

2
0
1



0
x
2
6
4
8

9
8
0
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
A

2
0
2



0
x
2
6
5
0

9
8
0
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
B

2
0
3



0
x
2
6
5
8

9
8
1
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
C

2
0
4



0
x
2
6
6
0

9
8
2
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
D

2
0
5



0
x
2
6
6
8

9
8
3
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
E

2
0
6



0
x
2
6
7
0

9
8
4
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
C
F

2
0
7



0
x
2
6
7
8

9
8
4
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
0

2
0
8



0
x
2
6
8
0

9
8
5
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
1

2
0
9



0
x
2
6
8
8

9
8
6
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
2

2
1
0



0
x
2
6
9
0

9
8
7
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
3

2
1
1



0
x
2
6
9
8

9
8
8
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
4

2
1
2



0
x
2
6
A
0

9
8
8
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
5

2
1
3



0
x
2
6
A
8

9
8
9
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
6

2
1
4



0
x
2
6
B
0

9
9
0
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
7

2
1
5



0
x
2
6
B
8

9
9
1
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
8

2
1
6



0
x
2
6
C
0

9
9
2
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
9

2
1
7



0
x
2
6
C
8

9
9
2
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
A

2
1
8



0
x
2
6
D
0

9
9
3
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
B

2
1
9



0
x
2
6
D
8

9
9
4
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
C

2
2
0



0
x
2
6
E
0

9
9
5
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
D

2
2
1



0
x
2
6
E
8

9
9
6
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
E

2
2
2



0
x
2
6
F
0

9
9
6
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
D
F

2
2
3



0
x
2
6
F
8

9
9
7
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

C
h
a
i
a
c
t
e
i


A
u
u
i
e
s
s


C
o
n
t
e
n
t
s

(
h
e
x
)

(
u
e
c
)

(
g
)


(
h
e
x
)

(
u
e
c
)



0
x
E
0

2
2
4



0
x
2
7
0
0

9
9
8
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
1

2
2
5



0
x
2
7
0
8

9
9
9
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
2

2
2
6



0
x
2
7
1
0

1
0
0
0
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
3

2
2
7



0
x
2
7
1
8

1
0
0
0
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
4

2
2
8



0
x
2
7
2
0

1
0
0
1
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
5

2
2
9



0
x
2
7
2
8

1
0
0
2
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
6

2
3
0



0
x
2
7
3
0

1
0
0
3
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
7

2
3
1



0
x
2
7
3
8

1
0
0
4
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
8

2
3
2



0
x
2
7
4
0

1
0
0
4
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
9

2
3
3



0
x
2
7
4
8

1
0
0
5
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
A

2
3
4



0
x
2
7
5
0

1
0
0
6
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
B

2
3
5



0
x
2
7
5
8

1
0
0
7
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
C

2
3
6



0
x
2
7
6
0

1
0
0
8
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
D

2
3
7



0
x
2
7
6
8

1
0
0
8
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
E

2
3
8



0
x
2
7
7
0

1
0
0
9
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
E
F

2
3
9



0
x
2
7
7
8

1
0
1
0
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
0

2
4
0



0
x
2
7
8
0

1
0
1
1
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
1

2
4
1



0
x
2
7
8
8

1
0
1
2
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
2

2
4
2



0
x
2
7
9
0

1
0
1
2
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
3

2
4
3



0
x
2
7
9
8

1
0
1
3
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
4

2
4
4



0
x
2
7
A
0

1
0
1
4
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
5

2
4
5



0
x
2
7
A
8

1
0
1
5
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
6

2
4
6



0
x
2
7
B
0

1
0
1
6
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
7

2
4
7



0
x
2
7
B
8

1
0
1
6
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
8

2
4
8



0
x
2
7
C
0

1
0
1
7
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
9

2
4
9



0
x
2
7
C
8

1
0
1
8
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
A

2
5
0



0
x
2
7
D
0

1
0
1
9
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
B

2
5
1



0
x
2
7
D
8

1
0
2
0
0


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
C

2
5
2



0
x
2
7
E
0

1
0
2
0
8


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
D

2
5
3



0
x
2
7
E
8

1
0
2
1
6


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
E

2
5
4



0
x
2
7
F
0

1
0
2
2
4


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

0
x
F
F

2
5
5



0
x
2
7
F
8

1
0
2
3
2


4

c
o
l
o
i

p
a
l
e
t
t
e
,

8

b
y
t
e
s

BRAFT uameuuino Refeience Nanual
4S
!"#$%&'
Spiites aie giaphical objects with theii own bitmaps anu palettes that can be
positioneu anywheie ovei the unueilying chaiactei giaphics playfielu. They the
most complex pait of the uameuuino's viueo subsystem, using six uistinct aieas of
memoiy foi contiol, collision uetection, image uata, anu coloi palettes.

Spiites aie visually positioneu above the othei elements of the viueo uisplay, so that
opaque pixels of a spiite will obscuie chaiactei giaphics playfielu anu backgiounu
pixel infoimation unueineath. Spiite pixels may be tianspaient, allowing the
unueilying giaphical layeis to show thiough. Each spiite is numbeieu fiom u to 2SS
(uxuu to uxFF hexauecimal), anu aie ienueieu in oiuei, so that spiite u is visually
beneath spiite 1, anu so on to spiite 2SS, which is the highest-piioiity visual
element on the uisplay.

The uameuuino haiuwaie suppoits 2S6 spiites, with some limitations:
!"#$%&' "&# )$*&+ Theie is a limit of 96 spiites on a single hoiizontal line. If too
many spiites occupy the same line, the uameuuino haiuwaie iuns out of time to
compose the line, anu some spiites may not be uiawn.
!"#$%& ,$%-." /&-0#1+ RAN_SPRINu contains enough memoiy to stoie 64
spiite images at the full 8-bit (2S6-coloi) pixel uepth. Bowevei, two spiites can
shaie one bitmap in 4-bit (16-coloi) moue: one spiite uses the uppei nybble of
the byte, while the othei spiite uses the lowei nybble. Similaily, in 2-bit (4-
coloi) moue, a total of 4 spiites can shaie one bitmap.
!"#$%& ()*%#)+
Each spiite is contiolleu by a S2-bit spiite contiol woiu, uiagiammeu in Table 28:
Spiite Contiol Woiu. The haiuwaie suppoits a maximum of 2S6 spiites, so spiite
contiol uata occupies 1u24 bytes of memoiy. The uameuuino has two pages of
spiite contiol uata: one at uxSuuu to uxSSFF (1228 to 1SS11 uecimal) anu one at
uxS4uu to uxS7FF (1SS12 to 14SSS uecimal) to suppoit uouble buffeiing. The
active page is set by the SPR_PAuE iegistei at ux28uB (1u2S1 uecimal). If
SPR_PAuE is u, the lowei bank of spiite contiol uata is useu; the uppei bank is useu
when SPR_PAuE is 1. The inactive page can be mouifieu without affecting the scieen
uisplay.

2.34& 56+ !"#$%& 70*%#04 80#9
!"#$%& 70*%#04 ,1%& :;;'&% .*9 70*%#04 80#9 70*%&*%'
+0 +1 +2 +3
Spiite Contiol X7X6X5X4X3X2X1X0 P3P2P1P0 R2R1R0 X8 Y7Y6Y5Y4Y3Y2Y1Y0 C S5S4S3S2S1S0 Y8
Xu-X8: Spiite X position, u-S11 (uxuuu-ux1FF hexauecimal).
Pu-RS: Palette moue select, u-1S (uxu-uxF hexauecimal), see Table 29: Spiite Palette Noues.
Ru-R2: Spiite iotation, u-8; see Table Su: Spiite Rotation.
Yu-Y8: Spiite Y position, u-S11 (uxuuu-ux1FF hexauecimal).
C: Collision class foi }K moue, u=} 1=K.
Su-SS: Souice image bitmap, u-6S (uxuu-uxSF hexauecimal).
BRAFT uameuuino Refeience Nanual
44

2.34& 5<+ !"#$%& =.4&%%& /09&'
=.4&%%& /09& =>?=@ !&4&A%&9 /09& =$B&4
(bin) (dec) (hex) colors palette bits
0000 0 0x0 256 8 0 A 0-7
0001 1 0x1 256 8 1 B 0-7
0010 2 0x2 256 8 2 C 0-7
0011 3 0x3 256 8 3 D 0-7
0100 4 0x4 16 4 0 A 0-3
0101 5 0x5 16 4 1 B 0-3
0110 6 0x6 16 4 0 A 4-7
0111 7 0x7 16 4 1 B 4-7
1000 8 0x8 4 2 0 A 0-1
1001 9 0x9 4 2 1 B 0-1
1010 10 0xA 4 2 0 A 2-3
1011 11 0xB 4 2 1 B 2-3
1100 12 0xC 4 2 0 A 4-5
1101 13 0xD 4 2 1 B 4-5
1110 14 0xE 4 2 0 A 6-7
1111 15 0xF 4 2 1 B 6-7
Palette moue: The selecteu palette moue numbei in binaiy, uecimal, anu hexauecimal.
Colois: Numbei of colois anu bit uepth in selecteu palette moue.
Palette: The numbei anu lettei of the palette selecteu foi the spiite.
Pixel bits: The bit positions of the spiite image useu in the selecteu moue.

2.34& @>+ !"#$%& C0%.%$0*
C0%.%$0* C>?C5 !&4&A%&9 /09& D;;&A%
(bin) (dec) (hex) Yflip Xflip XYswap
000 0 0x0 0 0 0 None
001 1 0x1 0 0 1 Niiioieu left-to-iight then iotateu 27u
010 2 0x2 0 1 0 Niiioieu left to iight
011 3 0x3 0 1 1 27u clockwise iotation
100 4 0x4 1 0 0 Niiioieu left-to-iight then iotateu 18u
101 5 0x5 1 0 1 9u clockwise iotation
110 6 0x6 1 1 0 18u clockwise iotation
111 7 0x7 1 1 1 Niiioieu left-to-iight then iotateu 9u
Rotation: The selecteu iotation numbei in binaiy, uecimal, anu hexauecimal.
Y flip: Flip spiite image in Y uiiection (top-to-bottom), u=no, 1=yes.
X flip: Flip spiite image in X uiiection (left-to-iight), u=no, 1=yes.
XY swap: Swap spiite X anu Y axes, u=no, 1=yes.
Effect: Effect of selecteu iotation on the spiite image.
!"#$%& ()++$,$)* -&%&.%$)*
The uameuuino spiite engine uetects collisions while the on-scieen uisplay is being
scanneu out. If a given spiite coveieu up (obscuieu pixels fiom) anothei spiite, then
a collision is uetecteu. The iesults aie available in C0LLISI0N, a 2S6-byte aiea of
memoiy fiom ux29uu-ux29FF (1u496-1u7S1 uecimal). This aiea of memoiy is
valiu only uuiing veitical blanking (vBLANK=1) anu will ieau uxFF (uecimal 2SS) at
all othei times.

Each byte of C0LLISI0N iepiesents the collision status of the coiiesponuing spiite.
The byte is uxFF (2SS uecimal) if the spiite uiu not colliue with any othei spiite, oi
BRAFT uameuuino Refeience Nanual
4S
contains the spiite numbei, uxuu-uxFE (u to 2S4) of the spiite that was obscuieu.
Since spiite 2SS (uxFF hexauecimal) is the highest-piioiity spiite, it can nevei be
obscuieu by anothei spiite. 0nly one collision is iepoiteu pei spiite; if a spiite
colliues with multiple othei spiites, one of the collisions will be iepoiteu, anu the
otheis aie uiscaiueu.

If }K collision moue is enableu, by setting the }K_N0BE iegistei to 1, collisions will
only be uetecteu between spiites belonging to uiffeient collision classes. Foi
example, in }K moue, if two spiites belong to class } (C=u), they cannot colliue even
if one spiite obscuies pixels fiom the othei. 0nly spiites with class bits can colliue.
If }K moue is uisableu, all collisions will be iepoiteu iegaiuless of class
membeiship.
!"#$%& /012& -1%1
Spiite images aie stoieu in 16kbytes of RAN beginning at ux4uuu (16S84 uecimal).
This is enough stoiage foi 64 image bitmaps: each spiite image is a 1616 bitmap
wheie each pixel occupies a single byte. The iesulting bitmap is 2S6 bytes, anu is
uiagiammeu in Table S1: Spiite Image Bitmap.

2.34& @E+ !"#$%& F-.G& ,$%-."
C0H ,1%& :;;'&% .*9 ,$%-." 70*%&*%'
(h) (u) +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F
+0x00 +0 P01 P02 P00 P03 P04 P05 P06 P07 P08 P09 P0A P0B P0C P0D P0E P0F
+0x10 +0 P11 P12 P11 P13 P14 P15 P16 P17 P18 P19 P1A P1B P1C P1D P1E P1F
+0x20 +0 P21 P22 P22 P23 P24 P25 P26 P27 P28 P29 P2A P2B P2C P2D P2E P2F
+0x30 +0 P31 P32 P33 P33 P34 P35 P36 P37 P38 P39 P3A P3B P3C P3D P3E P3F
+0x40 +0 P41 P42 P40 P43 P44 P45 P46 P47 P48 P49 P4A P4B P4C P4D P4E P4F
+0x50 +0 P51 P52 P50 P53 P54 P55 P56 P57 P58 P59 P5A P5B P5C P5D P5E P5F
+0x60 +0 P61 P62 P60 P63 P64 P65 P66 P67 P68 P69 P6A P6B P6C P6D P6E P6F
+0x70 +0 P71 P72 P70 P73 P74 P75 P76 P77 P78 P79 P7A P7B P7C P7D P7E P7F
+0x80 +0 P81 P82 P80 P83 P84 P85 P86 P87 P88 P89 P8A P8B P8C P8D P8E P8F
+0x90 +0 P91 P92 P90 P93 P94 P95 P96 P97 P98 P99 P9A P9B P9C P9D P9E P9F
+0xA0 +0 PA1 PA2 PA0 PA3 PA4 PA5 PA6 PA7 PA8 PA9 PAA PAB PAC PAD PAE PAF
+0xB0 +0 PB1 PB2 PB0 PB3 PB4 PB5 PB6 PB7 PB8 PB9 PBA PBB PBC PBD PBE PBF
+0xC0 +0 PC1 PC2 PC0 PC3 PC4 PC5 PC6 PC7 PC8 PC9 PCA PCB PCC PCD PCE PCF
+0xD0 +0 PD1 PD2 PD0 PD3 PD4 PD5 PD6 PD7 PD8 PD9 PDA PDB PDC PDD PDE PDF
+0xE0 +0 PE1 PE2 PE0 PE3 PE4 PE5 PE6 PE7 PE8 PE9 PEA PEB PEC PED PEE PEF
+0xF0 +0 PF1 PF2 PF0 PF3 PF4 PF5 PF6 PF7 PF8 PF9 PFA PFB PFC PFD PFE PFF
PXY: Pixel uata foi position X,Y, wheie X anu Y aie uxu-uxF (u to 1S uecimal).

0p to 2S6 uiffeient spiite images aie suppoiteu, by allowing spiites to shaie a
bitmap. In 16-coloi (4 bit pei pixel) moue, each spiite bitmap can contain two
complete spiite images, one in the high nybble (bits 4-7) anu one in the low nybble
(bits u-S). In 4-coloi (2 bit pei pixel) moue, each spiite bitmap can contain foui
complete spiite images. Each image occupies 2 of the 8 bits. See Table 28: Spiite
Contiol Woiu anu Table 29: Spiite Palette Noues foi moie infoimation.
!"#$%& 31+&%%&,
Theie aie a total of eight spiite palettes available on the uameuuino: 4 2S6-coloi
palettes, plus 2 16-coloi anu 2 4-coloi palettes. All eight palettes aie fully
BRAFT uameuuino Refeience Nanual
46
inuepenuent, anu theie is no iestiiction, othei than available spiite image uata
memoiy, on mixing spiite moues oi palettes.

5IJ?7040# =.4&%%&'+ The foui 2S6-coloi palettes aie each S12 bytes long, anu aie
locateu at RAN_SPRPAL staiting at uxS8uu (14SS6 uecimal). The stiuctuie of
RAN_SPRPAL is uiagiammeu in Table S2: RAN_SPRPAL Nemoiy Nap, while each
palette consists of 2S6 coloi entiies as uesciibeu in Table S7: Palette Entiy Foimat.

2.34& @5+ CK/L!=C=K) /&-0#1 /."
Symbol Palette Auuiess Length Contents
alteinate (hex) (uec) (hex) (uec)
RAM_SPRPAL PALETTE256A 0 A 0x3800 14336 0x200 512 2S6-coloi palette A
PALETTE256B 1 B 0x3A00 14848 0x200 512 2S6-coloi palette B
PALETTE256C 2 C 0x3C00 15360 0x200 512 2S6-Coloi palette C
PALETTE256C 3 D 0x3F00 15872 0x200 512 2S6-Coloi palette B

EJ?7040# =.4&%%&'+ Theie aie two 16-coloi palettes, each S2 bytes long, locateu at
PALETTE16 staiting at ux284u (1uSu4 uecimal). The stiuctuie of PALETTE16 is
uiagiammeu in Table SS: PALETTE16 Nemoiy Nap, while each palette consists of
16 coloi entiies as uesciibeu in Table S7: Palette Entiy Foimat, anu uetaileu in
Table S4: 16-Coloi Spiite Palette.

2.34& @@+ =K)D22DEJ /&-0#1 /."
Symbol Palette Auuiess Length Contents
(hex) (uec) (hex) (uec)
PALETTE16A 0 A 0x2840 10304 0x20 32 16-Coloi spiite palette A
PALETTE16B 1 B 0x2860 10336 0x20 32 16-Coloi spiite palette B

2.34& @M+ EJ?7040# !"#$%& =.4&%%&
Coloi
Entiy
Entiy 0ffset Byte 0ffset
(hex) (uec) +u +1
u
+0x00 +0
G2G1G0B4B3B2B1B0 A R4R3R2R1R0G4G3
1
+0x02 +2
G2G1G0B4B3B2B1B0 A R4R3R2R1R0G4G3
2
+0x04 +4
G2G1G0B4B3B2B1B0 A R4R3R2R1R0G4G3
S
+0x06 +6
G2G1G0B4B3B2B1B0 A R4R3R2R1R0G4G3
4
+0x08 +8
G2G1G0B4B3B2B1B0
A R4R3R2R1R0G4G3
S
+0x0A +10
G2G1G0B4B3B2B1B0
A R4R3R2R1R0G4G3
6
+0x0C +12
G2G1G0B4B3B2B1B0
A R4R3R2R1R0G4G3
7
+0x0E +14
G2G1G0B4B3B2B1B0
A R4R3R2R1R0G4G3
8
+0x10 +16
G2G1G0B4B3B2B1B0
A R4R3R2R1R0G4G3
9
+0x12 +18
G2G1G0B4B3B2B1B0
A R4R3R2R1R0G4G3
1u
+0x14 +20
G2G1G0B4B3B2B1B0
A R4R3R2R1R0G4G3
11
+0x16 +22
G2G1G0B4B3B2B1B0
A R4R3R2R1R0G4G3
12
+0x18 +24
G2G1G0B4B3B2B1B0
A R4R3R2R1R0G4G3
1S
+0x1A +26
G2G1G0B4B3B2B1B0
A R4R3R2R1R0G4G3
14
+0x1C +28
G2G1G0B4B3B2B1B0
A R4R3R2R1R0G4G3
1S
+0x1E +30
G2G1G0B4B3B2B1B0
A R4R3R2R1R0G4G3
BRAFT uameuuino Refeience Nanual
47
A: Alpha channel coloi infoimation, u=opaque, 1=tianspaient.
Ru-R4: Reu channel coloi infoimation, u-S2; ignoieu when A=1.
Bu-B4: uieen channel coloi infoimation, u-S2; ignoieu when A=1.
Bu-B4: Blue channel coloi infoimation, u-S2; ignoieu when A=1.

M?7040# =.4&%%&'+ Theie aie two 4-coloi palettes, each 8 bytes long, locateu at
PALETTE4 staiting at ux288u (1uS68 uecimal). The stiuctuie of PALETTE4 is
uiagiammeu in Table SS: PALETTE4 Nemoiy Nap, while each palette consists of 16
coloi entiies as uesciibeu in Table S7: Palette Entiy Foimat, anu uetaileu in Table
S6: 4-Coloi Spiite Palette.

2.34& @I+ =K)D22DM /&-0#1 /."
Symbol Palette Auuiess Length Contents
(hex) (uec) (hex) (uec)
PALETTE4A 0 A 0x2880 10368 0x8 8 4-Coloi spiite palette A
PALETTE4B 1 B 0x2888 10376 0x8 8 4-Coloi spiite palette B

2.34& @J+ M?7040# !"#$%& =.4&%%&
Coloi
Entiy
Entiy
0ffset
Byte 0ffset
+u +1
u +u G2G1G0B4B3B2B1B0 A R4R3R2R1R0G4G3
1 +2 G2G1G0B4B3B2B1B0 A R4R3R2R1R0G4G3
2 +4 G2G1G0B4B3B2B1B0 A R4R3R2R1R0G4G3
S +6 G2G1G0B4B3B2B1B0 A R4R3R2R1R0G4G3
A: Alpha channel coloi infoimation, u=opaque, 1=tianspaient.
Ru-R4: Reu channel coloi infoimation, u-S2; ignoieu when A=1.
Bu-B4: uieen channel coloi infoimation, u-S2; ignoieu when A=1.
Bu-B4: Blue channel coloi infoimation, u-S2; ignoieu when A=1.
)*+*#
The uameuuino uses a numbei of uiffeient foimats to iepiesent coloi values: 8-bit
logical coloi space values useu by the uB Libiaiy, S-bit coloi values useu by the
haiuwaie, anu S-bit coloi values combineu with uitheiing to geneiate viueo output
to the uisplay. Table S8: Coloi Space shows the ielationship between these thiee
coloi spaces.
4)2$.1+ ()+)#
The uB Libiaiy implements a 24-bit RuB888 logical coloi space. It pioviues 8 bits
pei channel via an RuB() macio that accepts one byte of coloi uata foi each channel.
The macio uiscaius the least significant S bits of each coloi channel, anu ietuins a
1S-bit haiuwaie iepiesentation of the coloi, with the alpha channel set to u
(opaque).
51#671#& ()+)#
Inteinally, the uameuuino uses an ARuB1SSS coloi foimat in its palettes anu coloi
iegisteis. Coloi values aie stoieu in a single 16-bit woiu, with one bit of alpha
(tianspaiency) infoimation, anu S bits each of ieu, gieen, anu blue channel
BRAFT uameuuino Refeience Nanual
48
infoimation. The lowei (least significant) byte of the woiu contains the blue
channel uata anu the least significant bits of the gieen channel, while the uppei byte
contains the most significant bits of the gieen channel, all of the ieu channel, anu the
alpha channel. A stanuaiu coloi value is uiagiammeu below:

2.34& @N+ =.4&%%& D*%#1 O0#-.%
Auuiess +u +1
ARuB1SSS Coloi Bata Template G2G1G0B4B3B2B1B0 A R4R3R2R1R0G4G3
ARuB1SSS Bisplay Colois G2G1G0B4B3B2B1B0 0 R4R3R2R1R0G4G3
ARuB1SSS Tianspaient X X X X X X X X 1 X X X X X X X
A: Alpha channel coloi infoimation, u=opaque, 1=tianspaient.
Ru-R4: Reu channel coloi infoimation, u-S2; ignoieu when A=1.
Bu-B4: uieen channel coloi infoimation, u-S2; ignoieu when A=1.
Bu-B4: Blue channel coloi infoimation, u-S2; ignoieu when A=1.

As shown above, the uameuuino implements an alpha (tianspaiency) coloi channel
in haiuwaie. Tianspaient values aie a special case of the stanuaiu coloi value:
when the most significant bit is set, the low 1S bits containing the ieu, gieen, anu
blue channels in the coloi value aie ignoieu. The iesult is values of ux8uuu-uxFFFF
(uecimal S2768 thiough 6SSSS), aie tianspaient.

By convention, ux8uuu is the stanuaiu tianspaient coloi value. Bowevei, stoiing
ux8u (uecimal 128) in the high byte of a coloi woiu is sufficient to make a coloi
entiy tianspaient, iegaiuless of the contents of the low byte.

The Bu_C0L0R iegistei ignoies alpha channel infoimation, because the backgiounu
coloi is the bottom-most coloi plane. Theie is no lowei-piioiity viueo infoimation
to show thiough a tianspaient backgiounu coloi, so all coloi values aie tieateu as
opaque. Similaily, pixel uata ieau back thiough the SCREENSB0T memoiy aiea aie
always opaque, since they iepiesent the final coloi values output to the uisplay.
89%"9% ()+)#
The uameuuino uisplay output has only S bits of iesolution pei channel. 0nly the
colois wheie the thiee least significant bits aie all zeio aie output uiiectly. The
othei colois, wheie the least significant bits aie nonzeio, aie appioximateu using a
22 uitheiing algoiithm in the viueo output haiuwaie.

2.34& @6+ 7040# !".A&
8-bit Logical Coloi S-bit Baiuwaie Coloi S-bit 0utput Coloi
(hex) (uec) (bin) (hex) (uec) (bin) (hex) (uec) (bin)
0x00 0 00000000 0x00 0 00000 0x00 0 000
0x08 8 00001000 0x01 1 00001 0x00 0 000
0x10 16 00010000 0x02 2 00010 0x00 0 000
0x18 24 00011000 0x03 3 00011 0x00 0 000
0x20 32 00100000 0x04 4 00100 0x01 1 001
0x28 40 00101000 0x05 5 00101 0x01 1 001
0x30 48 00110000 0x06 6 00110 0x01 1 001
0x38 56 00111000 0x07 7 00111 0x01 1 001
0x40 64 01000000 0x08 8 01000 0x02 2 010
BRAFT uameuuino Refeience Nanual
49
8-bit Logical Coloi S-bit Baiuwaie Coloi S-bit 0utput Coloi
(hex) (uec) (bin) (hex) (uec) (bin) (hex) (uec) (bin)
0x48 72 01001000 0x09 9 01001 0x02 2 010
0x50 80 01010000 0x0A 10 01010 0x02 2 010
0x58 88 01011000 0x0B 11 01011 0x02 2 010
0x60 96 01100000 0x0C 12 01100 0x03 3 011
0x68 104 01101000 0x0D 13 01101 0x03 3 011
0x70 112 01110000 0x0E 14 01110 0x03 3 011
0x78 120 01111000 0x0F 15 01111 0x03 3 011
0x80 128 10000000 0x10 16 10000 0x04 4 100
0x88 136 10001000 0x11 17 10001 0x04 4 100
0x90 144 10010000 0x12 18 10010 0x04 4 100
0x98 152 10011000 0x13 19 10011 0x04 4 100
0xA0 160 10100000 0x14 20 10100 0x05 5 101
0xA8 168 10101000 0x15 21 10101 0x05 5 101
0xB0 176 10110000 0x16 22 10110 0x05 5 101
0xB8 184 10111000 0x17 23 10111 0x05 5 101
0xC0 192 11000000 0x18 24 11000 0x06 6 110
0xC8 200 11001000 0x19 25 11001 0x06 6 110
0xD0 208 11010000 0x1A 26 11010 0x06 6 110
0xD8 216 11011000 0x1B 27 11011 0x06 6 110
0xE0 224 11100000 0x1C 28 11100 0x07 7 111
0xE8 232 11101000 0x1D 29 11101 0x07 7 111
0xF0 240 11110000 0x1E 30 11110 0x07 7 111
0xF8 248 11111000 0x1F 31 11111 0x07 7 111
Lines shaueu in giey aie uitheieu on output.
!"#$%
The uameuuino implements two inuepenuent auuio systems: an auuitive synthesis
baseu on the summation of sepaiate wavefoims, anu a sample playback mechanism.
!*,-. !/-%0&'$' 1&2$'%&#'
The uameuuino auuitive sounu synthesis system is baseu on 64 sounu contiol
woius anu is supplementeu by a iing mouulation system.
:)$.& ()*%#)+
Sounu contiol uata is locateu at v0ICES, ux2Auu (1u7S2 uecimal). Each sounu
contiol woiu consists of S2 bits that specify one component of the final sounu to be
output.

2.34& @<+ P:F7D! /&-0#1 /."
P K99#&'' ,1%& :;;'&% .*9 70*%#04 80#9 70*%&*%'
(hex) (dec) +0 +1 +2 +3
!
0x2A00 10752 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
#
0x2A04 10756 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
$ 0x2A08 10760 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
% 0x2A0C 10764 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
& 0x2A10 10768 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
' 0x2A14 10772 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
(
0x2A18 10776 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
BRAFT uameuuino Refeience Nanual
Su
P K99#&'' ,1%& :;;'&% .*9 70*%#04 80#9 70*%&*%'
(hex) (dec) +0 +1 +2 +3
) 0x2A1C 10780 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
* 0x2A20 10784 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
+ 0x2A24 10788 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
#!
0x2A28 10792 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
##
0x2A2C 10796 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
#$
0x2A30 10800 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
#%
0x2A34 10804 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
#&
0x2A38 10808 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
#' 0x2A3C 10812 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
#( 0x2A40 10816 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
#) 0x2A44 10820 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
#* 0x2A48 10824 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
#+
0x2A4C 10828 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
$!
0x2A50 10832 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
$#
0x2A54 10836 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
$$
0x2A58 10840 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
$%
0x2A5C 10844 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
$& 0x2A60 10848 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
$' 0x2A64 10852 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
$( 0x2A68 10856 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
$)
0x2A6C 10860 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
$*
0x2A70 10864 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
$+
0x2A74 10868 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
%!
0x2A78 10872 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
%#
0x2A7C 10876 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
%$ 0x2A80 10880 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
%% 0x2A84 10884 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
%& 0x2A88 10888 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
%' 0x2A8C 10892 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
%(
0x2A90 10896 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
%)
0x2A94 10900 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
%*
0x2A98 10904 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
%+
0x2A9C 10908 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
&! 0x2AA0 10912 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
&# 0x2AA4 10916 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
&$ 0x2AA8 10920 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
&% 0x2AAC 10924 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
&&
0x2AB0 10928 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
&'
0x2AB4 10932 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
&(
0x2AB8 10936 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
&)
0x2ABC 10940 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
BRAFT uameuuino Refeience Nanual
S1
P K99#&'' ,1%& :;;'&% .*9 70*%#04 80#9 70*%&*%'
(hex) (dec) +0 +1 +2 +3
&* 0x2AC0 10944 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
&+ 0x2AC4 10948 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
'! 0x2AC8 10952 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
'#
0x2ACC 10956 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
'$
0x2AD0 10960 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
'%
0x2AD4 10964 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
'&
0x2AD8 10968 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
''
0x2ADC 10972 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
'( 0x2AE0 10976 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
') 0x2AE4 10980 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
'* 0x2AE8 10984 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
'+ 0x2AEC 10988 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
(!
0x2AF0 10992 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
(#
0x2AF4 10996 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
($
0x2AF8 11000 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
(%
0x2AFC 11004 F7F6F5F4F3F2F1F0 W FEFDFCFBFAF9F8 L7L6L5L4L3L2L1L0 R7R6R5R4R3R2R1R0
v: voice numbei, u-64 (uxuu-ux4u hexauecimal).
Fu-FE: Fiequency, in units of Bz (so 4=1Bz oi 176u=44uBz).
W: Wavefoim, u=sine, 1=noise.
Lu-L7: Left volume, u-2SS (uxuu-uxFF hexauecimal).
Ru-R7: Right volume, u-2SS (uxuu-uxFF hexauecimal).
;$*2 <)69+1%)#
In auuition to simple auuitive synthesis, the uameuuino's auuio output system
implements a iing mouulatoi. Wiiting values to the RINu_N0B iegistei at ux2814
(1u26u uecimal) contiol the iing mouulatoi. Wiiting 64 (ux4u) to the RINu_N0B
iegistei uisables the featuie. Wiiting any lowei value enables the iing mouulatoi.
The value stoieu in RINu_N0B ueteimines which voice contiol iegistei is useu as
the iing mouulatoi contiol. All lowei-numbeieu voices aie mouulateu, while
highei-numbeieu voices aie unaffecteu. Foi example, wiiting S2 (ux2u
hexauecimal) to RINu_N0B enables the iing mouulatoi. voice contiol woiu S2
contiols the mouulatoi, anu voices u-S1 aie mouulateu, while voices SS-64 aie not.

!1-304 K99#&'' ) C&G$'%&# 70*%&*%' .*9 OQ*A%$0* R&;.Q4%
(hex) (uec)
RING_MOD RW 0x2814 10260 1 Nouulatoi voice, affects all lowei voices 0x40
!34"+& 1&2$'%&#'
The uameuuino has the ability to play back steieo auuio wave uata using the
SANPLE_L anu SANPLE_R iegisteis. Each iegistei accepts a signeu 16-bit integei
ieflecting the sample. The uameuuino upuates auuio samples eveiy 64 cycles of it's
SuNBz clock, coiiesponuing to an upuate fiequency of 781.2SkBz, so values loaueu
into these iegisteis aie ieflecteu on the auuio output channels within 1.28s.
BRAFT uameuuino Refeience Nanual
S2

2.34& M>+ !K/=)DL) .*9 !K/=)DLC C&G$'%&#'
Symbol Auuiess Length Byte 0ffset anu Registei Contents Befault


(hex) (uec) (hex) (uec) +0 +1

SAMPLE_L RW 0x2810 10256 0x2 2 L7L6L5L4L3L2L1L0 L15L14L13L12L11L10L9L8 0x0000
SCROLL_R RW 0x2812 10258 0x2 2 R7R6R5R4R3R2R1R0 R15R14R13R12R11R10R9R8 0x0000
Lu-L1S: Left auuio channel sample value, 16-bit signeu integei (L1S is the sign bit).
Ru-R1S: Right auuio channel sample value, 16-bit signeu integei (R1S is the sign bit).
BRAFT uameuuino Refeience Nanual
SS
!! !"#$"%&''"$
The uameuuino incluues a }1 Foith-baseu CP0 as a copiocessoi. The }1 is a
minimalist but fully functional piocessoi that has full access to the uameuuino's
auuiess space, anu a few auuitional iegisteis that aie not accessible to the Aiuuino.
The }1 CP0 also executes much fastei than the Aiuuino, anu can move consiueiably
moie uata than can fit thiough the SPI inteiface.
)*"#*5&''*# 6-%&#735&
The uameuuino copiocessoi inteiface consists of a contiol iegistei, a miciocoue
block, anu a communications block that aie shaieu between the Aiuuino anu the
copiocessoi.
()"#).&,,)# ()*%#)+
The }1_RESET iegistei allows the Aiuuino (oi othei host miciocontiollei) to stop
anu stait the }1 copiocessoi. Wiiting uxu1 to this iegistei halts anu iesets the
copiocessoi, while uxuu ieleases the copiocessoi. Following a ieset, the }1 begins
executing coue staiting at }1_C0BE, ux2Buu (11uu8 uecimal). The iemaining seven
bits of the iegistei aie unuseu anu shoulu be set to u foi compatibility.

2.34& ME+ SELCD!D2 C&G$'%&#
Symbol Auuiess Length Contents Befault
(hex) (uec) (hex) (uec)
J1_RESET RW 0x2809 10249 0x1 1 X X X X X X X R0 0x0000
Ru: Copiocessoi contiol: 1=iun, u=halt anu ieset.
()"#).&,,)# <$.#).)6&
}1_C0BE, a 2S6-byte block of uameuuino RAN fiom ux2Buu-ux2BFF (uecimal
11uu8 thiough 1126S) is set asiue foi }1 instiuctions. This is the only aiea of
memoiy that the }1 can use to fetch instiuctions. }1 instiuctions aie 16-bit woius,
so }1_C0BE can contain only 128 instiuctions. Bowevei the copiocessoi can ieau
anu wiite uata fiom any location in the uameuuino auuiess space, so clevei
piogiams can copy oveilays fiom othei aieas of the }1 auuiess space into }1_C0BE.
0nuseu spiite bitmap memoiy in the 16 kbyte RAN_SPRINu block is a goou place to
locate }1 oveilays.

2.34& M5+ SEL7:RD /&-0#1 /."
Symbol Auuiess Length Contents Befault
(hex) (uec) (hex) (uec)
J1_CODE RW 0x2B00 11008 0x0100 256 128 2-byte }1 instiuctions 128 ! 0x0000
()"#).&,,)# ()009*$.1%$)*, =+).>
An otheiwise-unuseu 48-byte block of RAN is set asiue foi use as a intei-piocessoi
communications aiea so that Aiuuino anu }1 coue can exchange uata. The block is
labeleu C0NN anu iuns fiom ux289u to ux28BF (1uS84 to 1u4S1 uecimal). Theie
BRAFT uameuuino Refeience Nanual
S4
is no stanuaiu stiuctuie to C0NN - it is fiee to be uefineu by usei piogiams, anu
may incluue uata that is shaieu between the Aiuuino sketch anu the }1 coue, oi
piivate uata stiuctuies manipulateu by the }1. Bowevei, 48 bytes is not a lot of
space foi uata stiuctuies. 0nuseu spiite bitmap memoiy in the 16-kbyte
RAN_SPRINu block is a goou place to locate laige uata stiuctuies that uon't fit into
C0NN.

2.34& M@+ 7:// /&-0#1 /."
Symbol Auuiess Length Contents Befault
(hex) (uec) (hex) (uec)
COMM RW 0x2890 10384 0x30 48 48 bytes shaieu memoiy 0x00
()"#).&,,)#?8*+@ ;&2$,%&#,
A few uameuuino iegisteis aie only available to }1 piogiams - they cannot be ieau
oi wiitten by the host miciocontiollei via the SPI inteiface. Because they aie so
tightly tieu to the }1 copiocessoi, these iegisteis can also be ieau anu wiitten via a
16-bit uata path, so that loau anu stoie instiuctions wiite entiie woius (iathei than
wiiting just one byte, as is the case with loaus oi stoies to oiuinaiy uameuuino
iegisteis).

7Q##&*% C.'%&# )$*&+ This is a ieau-only countei that inciements as the scieen
uisplay is geneiateu. The iegistei is inciementeu immeuiately aftei the last pixel of
the line is compositeu, so changes in YLINE can be useu to uetect when it is safe to
mouify on-scieen objects anu contiol iegisteis without causing visual glitches. }1
coue has at least 4S cycles long, anu up to 1677 cycles, befoie composition of the
next iastei line begins. The time taken uepenus on the numbei of spiites that must
be compositeu onto the line: the minimum time of 4S cycles coiiesponus to the
maximum of 96 spiites pei line. Rastei line u is the top-most visible line of the
uisplay, anu line 299 is the bottom-most visible line. Waiting foi YLINE>299 will
uetect the stait of veitical blanking. Bowevei, YLINE is unuefineu uuiing veitical
blanking, anu may take on unpieuictable values, so YLINE uata can be useu to
estimate the amount of time left in the veitical blanking inteival.

2.34& MM+ T)FUD C&G$'%&#
Symbol Auuiess Length Registei Contents
(hex) (uec) (hex) (uec)
YLINE R 0x8000 32768 0x2 2 X X X X X X X Y8Y7Y6Y5Y4Y3Y2Y1Y0
Yu-Y8: Cuiient iastei line, uxuuuu to ux14C (u to SS2).

O=VK F7K= =0#%+ A set of 6 iegisteis that allow }1 piogiams to uiiectly access the
inteinal configuiation access poit (ICAP) of the Xilinx fielu-piogiammable gate
aiiay (FPuA) useu to implement the uameuuino. The ICAP poit is not noimally useu
foi game piogiamming, anu use of these iegisteis coulu altei the uameuuino's
opeiation. Consult the Xilinx 0sei uuiue foi uetails on how to use this poit. The
manual can be founu on the Xilinx site at:
http:www.xilinx.comsuppoituocumentationusei_guiuesugSS2.puf
BRAFT uameuuino Refeience Nanual
SS

2.34& MI+ O=VK F7K= C&G$'%&#'
Symbol Auuiess Length Registei Contents
(hex) (uec) (hex) (uec)
ICAP_O R 0x8002 32770 0x2 2 X X X X X X X X O7O6O5O4O3O2O1O0
ICAP W 0x8006 32774 0x2 2 X X X X X W0 E0 C0 I7I6I5I4I3I2I1I0
0u-07: ICAP output byte, uxuu-uxFF (u to 2SS uecimal).
Iu-I7: ICAP input byte, uxuu-uxFF (u to 2SS uecimal).
Wu: ICAP wiite enable, u=wiite anu 1=ieau.
Eu: ICAP select (chip enable): u=enable anu 1=uisable.
Cu: ICAP inteiface clock.

=#0G#.--.34& O#&WQ&*A1 V&*&#.%0#+ A piogiammable fiequency geneiatoi is
available to the }1 copiocessoi using the FREQBZ anu FREQTICK iegisteis. The
FREQBZ iegistei sets the uesiieu fiequency, fiom 1Bz (uxuuu1) to 6S,SSSBz
(uxFFFF); 8uuuBz (ux1F4u) is the uefault. The FREQTICK iegistei inciements by
one at the specifieu fiequency, allowing the }1 to count at a piecise iate. Theie is no
way to set oi ieset FREQTICK, it meiely counts up at the specifieu iate. When
FREQTICK ieaches uxFF, it iolls ovei to uxuu the next time it inciements. Setting
FREQBZ to uxuuuu piogiams uBz anu stops inciementing FREQTICK.

2.34& MJ+ OCDXYZ .*9 OCDX2F7[ C&G$'%&#'
Symbol Auuiess Length Registei Contents Befault
(hex) (uec) (hex) (uec)

FREQHZ W 0x800A 32778 0x2 2 Fiequency setting, 1Bz to 6SSSSBz ux1F4u
FREQTICK R 0x800C 32780 0x1 1 Countei inciements at CL0CKBZ uxuu

=$* 5 70*%#04+ Two copiocessoi-only iegisteis, in combination with the shaiu
I0N0BE iegistei, contiol pin 2 of the uameuuino's Aiuuino haiuwaie inteiface. The
shaieu I0N0BE iegistei is useu to assign pin 2 to one of two functions, oi to uisable
it entiiely. When I0N0BE is set to ux4A (uecimal 74 oi ASCII "}"), the pin is
contiolleu by the copiocessoi-only P2_v anu P2_BIR iegisteis.

2.34& MN+ =5 F\: C&G$'%&#'
Symbol Auuiess Length Registei Contents
(hex) (uec) (hex) (uec)
P2_V RW 0x800E 32782 0x2 2 X X X X X X X X X X X X X X X V0
P2_DIR R 0x8010 32784 0x2 2 X X X X X X X X X X X X X X X D0
vu: Aiuuino inteiface pin 2 value, u=low anu 1=high.
Bu: Pin 2 uiiection, u=output, 1=input.

When useu as an output, }1 coue iunning on the uameuuino can signal the host
miciocontiollei on pin 2 of the inteiface. This is a uigital pin on Aiuuino boaius,
anu it can be useu as an inteiiupt. }1 coue on the uameuuino can use this inteiiupt
to tiiggei Aiuuino coue that must iun synchionously with the uamuuino state. Foi
example, the }1 can tiiggei an inteiiupt when veitical blanking is uetecteu, anu the
Aiuiuno's inteiiupt seivice ioutine can upuate on-scieen objects without causing
visual glitches in the viueo output.

BRAFT uameuuino Refeience Nanual
S6
When useu as an input, pin 2 can eithei be connecteu uiiectly to a uigital signal that
the }1 coue monitois, oi it can be useu as an alteinate signaling path between the
host miciocontiollei anu the uameuuino. The }1 piocessoi uoesn't suppoit
inteiiupts, so coue that monitois pin 2 will neeu to poll the state of the pin to uetect
signals.

C.*90- UQ-3&#+ The }1 can access a high-quality ianuom numbei geneiatoi via
the RANB0N iegistei. The value in this ieau-only iegistei is baseu on the
uameuuino's built-in white noise geneiatoi. The haiuwaie continuously upuates
this value so that eveiy time it is ieau, the iegistei piouuces a new ianuom value.

2.34& M6+ CKUR:/ C&G$'%&#
Symbol Auuiess Length Registei Contents
(hex) (uec) (hex) (uec)
RANDOM R 0x8012 32786 0x2 2 16-bit ianuom numbei

740A]+ A clock cycle countei is available in the CL0CK iegistei. This iegistei counts
the numbei of SuNBz }1 clock cycles since the uameuuino was ieset. When the
count ieaches uxFFFF (6SSSS uecimal) it wiaps aiounu to uxuuuu.

2.34& M<+ 7):7[ C&G$'%&#
Symbol Auuiess Length Registei Contents
(hex) (uec) (hex) (uec)
CLOCK R 0x8014 32788 0x2 2 Clock cycle count, uxuuuu to uxFFFF

!=F O4.'^ /&-0#1+ When the shaieu I0N0BE iegistei is set to ux46 (uecimal 7u oi
ASCII "F"), the }1 CP0 can use the FLASB iegisteis to access the uameuuino's
onboaiu flash memoiy. By uiiectly manipulating a foui-line bus, the }1 can initiate
SPI tiansactions to ieau oi wiite memoiy locations unuei piogiam contiol.
This memoiy stoies configuiation uata that is loaueu into the Xilinx FPuA at boot-up
time; changing uata stoieu in this memoiy coulu peimanently altei the functioning
of the uameuuino.

2.34& I>+ O)K!Y !=F C&G$'%&#'
Symbol Auuiess Length Registei Contents
(hex) (uec) (hex) (uec)
FLASH_MISO R 0x8016 32790 0x2 2 X X X X X X X X X X X X X X X O0
FLASH_MOSI W 0x8018 32792 0x2 2 X X X X X X X X X X X X X X X I0
FLASH_SCK W 0x801A 32794 0x2 2 X X X X X X X X X X X X X X X C0
FLASH_SSEL W 0x801C 32796 0x2 2 X X X X X X X X X X X X X X X S0
0u: SPI NIS0 (mastei-inslave-out) line input, u=low anu 1=high.
Iu: SPI N0SI (mastei-outslave-in) signal to output, u=low anu 1=high.
Cu: SPI SCK (seiial clock) signal to output, u=low anu 1=high.
Su: SPI SSEL (slave select, also SS oi SEL) signal to output, u=low anu 1=high.
89 :#50$%&5%,#& 3-. ;#*2#344$-2
The }1 is a stack-baseu miciopiocessoi optimizeu to execute Foith coue; in fact its
instiuction set incluues 21 instiuctions that uiiectly implement ANS Foith woius.
BRAFT uameuuino Refeience Nanual
S7
The logical aichitectuie of the piocessoi is shown in D##0#_ C&;&#&*A& '0Q#A& *0%
;0Q*9`. It is uesigneu to execute Foith-like stack-baseu languages, anu the most
piominent featuies of the }1 aie its two stacks: a uata stack that is useu by AL0
opeiations, anu a ietuin stack that is piimaiily useu to holu subioutine ietuin
auuiesses. Each stack can holu up to S2 entiies, each entiy containing a 16-bit
woiu. A few stack entiies have specific names, that aie useu to uesciibe }1
opeiations: the top of the uata stack is T (top of stack), while the next item on the
uata stack is N (next on stack); the top of the ietuin stack is R (ietuin auuiess).

The basic stack opeiations aie push anu pop.
=Q'^+ Pushing a value onto a stack saves it foi latei use. When woius aie
pusheu onto a stack, the new uata becomes the top of the stack, anu each
element of the stack moves uown. Foi example, when pushing a value onto the
uata stack, the value pusheu becomes the new T, while the pievious value of T
becomes the new N, anu so on.
=0"+ Popping an element fiom the stack is the exact ieveise of a push. Popping
a value iemoves it fiom the stack, anu the iest of the elements move up. values
useu in a computation aie typically poppeu piioi to computing the iesult.
The }1 stacks aie finite, anu can only stoie S2 elements, but the }1 uoes not check foi
oveiflow oi unueiflow. If a stack alieauy contains S2 elements, pushing a new
element on the stack will not cause an exception; insteau, the bottom-most element
is uiscaiueu to make ioom. Popping a value fiom an empty stack will not cause an
exception; the value of unuseu stack elements is unuefineu anu may be ianuom.
Similaily, peifoiming two-opeianu instiuctions on a uata stack containing only one
value will not iesult in an eiioi, but the iesults of the computation aie unuefineu,
anu will likely vaiy uepenuing on the pievious contents of the stack.

The }1 incluues an AL0 that can peifoim 16 logical opeiations, incluuing auuition,
multiplication, compaiison anu bitwise logic opeiations. Inputs to the AL0 aie the
values stoieu in T anu N (foi binaiy opeiatois), anu may be poppeu fiom the stack
aftei use. Results aie pusheu back on the uata stack. Instiuctions aie also available
to loau anu stoie the uata stack fiom memoiy, anu tiansfei values between the uata
stack anu the ietuin stack. All opeiations aie peifoimeu on 16-bit woius, foi a
computational iange of u to 6SSSS (uxuuuu to uxFFFF). Signeu compaiison
opeiatois aie available, allowing signeu 16-bit integeis in the iange -S2767 to
S2767 to be iepiesenteu. Boolean FALSE is iepiesenteu as uxuuuu, anu while any
non-zeio value is TR0E, uxuuu1 is useu by convention.

Although the }1 aichitectuie logically suppoits a 16-bit piogiam countei (PC), the
uameuuino implementation is limiteu to fetching instiuctions fiom the 2S6 bytes of
RAN at }1_C0BE. }1 instiuctions aie always 2-byte woius, so in effect the least-
significant bit anu the most significant byte of the }1 PC aie haiu coueu to u anu
ux2B (uecimal 4S) iespectively. The }1 implements a conuitional bianch on T=u, an
unconuitional bianch, as well as an unconuitional subioutine call. Subioutine call
instiuctions push the piogiam countei onto the ietuin stack. 0ne unique featuie of
BRAFT uameuuino Refeience Nanual
S8
the }1 is that subioutine ietuins typically uo not iequiie an instiuction, because any
AL0 instiuction can be coueu to also peifoim a subioutine ietuin. Togethei with
some of the }1's othei featuies, this enables suipiisingly compact coue to be cieateu.

Because the uameuuino's auuiess space is byte-oiienteu, loau anu stoie opeiations
only tiansfei one byte of uata, uespite the fact that the }1 is a 16-bit CP0. values
loaueu fiom the uameuuino memoiy occupy the low 8 bits of a }1 woiu while the
uppei bits aie set to zeio. Wiites fiom the }1 to uameuuino auuiess space ignoie
the high byte, anu stoie only the low byte. The only exception to this is when
accessing the copiocessoi-only iegisteis,
which aie 16 bits wiue; loau anu stoie
opeiations to these iegisteis tiansfei an
entiie woiu.
A)#%B?=1,&6 C,,&0D+@ 41*2912&
The stanuaiu way of piogiamming the }1 is to
use its Foith-baseu assembly language. An
assemblei is pioviueu as pait of the
start-microcode example
/ subroutine definitions go here
: main
/ main program code goes here
begin again
;
end-microcode
!]&%A^ I+ SE K''&-341 =#0G#.- 2&-"4.%&
X X X X X X X X X X X X X X X X T
X X X X X X X X X X X X X X X X N
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X R
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
X X X X X X X X X X X X X X X X
Data Stack Return Stack
X X X X X X X X
X X X X X X X X
Gameduino Memory
0x0002
0x0003
X X X X X X X X 0x27FE
X X X X X X X X 0x27FF
... ...
X X X X X X X X 0x2AFE
X X X X X X X X 0x7FFE
... ...
X X X X X X X X 0x2BFF
... ...
X X X X X X X X X X X X X X X X 0x8000
... ...
X X X X X X X X X X X X X X X X 0x801C
X X X X X X X X 0x7FFF
X X X X X X X X 0x2C00
X X X X X X X X 0x2C01
X X X X X X X X 0x2BFE
X X X X X X X X 0x2AFF
X X X X X X X X 0x2B00
X X X X X X X X 0x2B01
... ...
X X X X X X X X 0x2800
X X X X X X X X 0x2801
... ...
X X X X X X X X 0x283E
X X X X X X X X 0x283F
X X X X X X X X 0x2840
X X X X X X X X 0x2841
X X X X X X X X X X X X X X X X 0x8002
X X X X X X X X X X X X X X X X 0x801A
J
1

C
o
p
r
o
c
e
s
s
o
r
C
o
d
e

S
p
a
c
e
G
a
m
e
d
u
i
n
o
R
e
g
i
s
t
e
r
s
C
o
p
r
o
c
e
s
s
o
r
-
O
n
l
y
R
e
g
i
s
t
e
r
s
A
c
c
e
s
s
i
b
l
e

t
o

A
r
d
u
i
n
o

v
i
a

S
P
I

B
u
s
0x0001
0x0000
X X X X X X X X
X X X X X X X X
PC 1 0 1 0 1 1 0 0 A A A A A A A 0
ALU
O$GQ#& M+ SE )0G$A.4 K#A^$%&A%Q#&
BRAFT uameuuino Refeience Nanual
S9
uameuuino copiocessoi softwaie uevelopment kit. A valiu }1 assembly piogiam
must contain a subioutine nameu "main", which will be the piimaiy entiy point of
the piogiam. This ioutine must not ietuin to the callei - it shoulu eithei loop
inuefinitely itself, oi enu with an empty infinite loop ("begin again"). 0ptionally, the
piogiam may contain auuitional subioutines befoie main. The shell of a }1
assembly language piogiam is piesenteu as Sketch S: }1 Assembly Piogiam
Template. A summaiy of the }1 assembly language is pioviueu as Table S1: }1
Assembly Language Summaiy.



2.34& IE+ SE K''&-341 ).*GQ.G& !Q--.#1
F*'%#QA%$0* =0"' =Q'^&' OQ*A%$0*
Assemblei Biiectives
start-microprogram symbol --- ---
end-microprogram --- ---
nnnnn constant symbol --- --- Befines symbol
Liteial Instiuctions
d# nnnnn --- nnnnn Pushes constant nnnn
h# hhhh --- hhhh Pushes constant hhhh
[char]c --- c Pushes constant c
symbol --- value Pushes value of symbol
ANS Foith Instiuctions
+ N, T N+T Auu
1- T T-1 Beciement
= N, T N=T Bitwise equality
< N, T N<T 0nsigneu less-than
u< N, T N<T Signeu less-than
xor N, T N!T Bitwise exclusive oi
and N, T N"T Bitwise anu
or N, T N#T Bitwise oi
invert T ~T Bitwise negation
swap N, T T, N Swaps T anu N
dup --- T Buplicates T
drop T --- Biscaius T
over --- N Pushes a copy of N
nip N --- Biscaius N (pieseiving T)
>r T R Noves T to R
r> R T Noves R to T
r@ --- R Pushes a copy of R
rshift N, T N>>T Logical iight shift
* N, T N T Nultiply
Auuitional Instiuctions
swab
T T' Swap bytes within T
noop
--- --- No opeiation
Nulti-Woiu ANS Foith Instiuctions
c@
T |Tj Loau byte at memoiy auuiess T
c!
N, T --- Stoie N to memoiy auuiess T
BRAFT uameuuino Refeience Nanual
6u
F*'%#QA%$0* =0"' =Q'^&' OQ*A%$0*
Neigeu Instiuctions
2dup+
--- N+T ovei ovei +
over+
T N+T ovei +
2dup=
--- N=T ovei ovei =
over=
T N=T ovei =
2dup<
--- N<T ovei ovei <
over>
T N>T ovei >
2dupu<
--- N<T ovei ovei u<
overu>
T N>T ovei u>
2dupxor
--- N!T ovei ovei xoi
overxor
T N!T ovei xoi
2dupand
--- N"T ovei ovei anu
overand
T N"T ovei anu
2dupor
--- N#T ovei ovei oi
overor
T N#T ovei oi
dup>r
--- R uup i>
2duprshift
--- N>>T ovei ovei ishift
2dup*
--- N T ovei ovei *
over*
T N T ovei *
dupswab
--- T' uup swab
dupc@
--- |Tj uup c
Flow Contiol
: symbol
--- --- Befine subioutine
;
R --- Retuin, pop R to PC
;fallthru
--- --- Enu subioutine without ietuin
symbol
R Call subioutine, push PC to R
if
T --- Conuitional bianch
else
--- --- Conuitional bianch sepaiatoi
then
--- --- Conuitional bianch teiminatoi
begin
--- -- Begin loop
again
--- --- Retuin to "begin", infinite loop
until
T --- Bottom-exit, loop when false
while
T --- Niuule-exit, loop when tiue
repeat
--- --- Retuin to "begin"

Each subioutine begins with a uefinition, incluues multiple instiuctions, anu enus
with a ietuin. A subioutine uefinition is a colon, followeu by the name of the
subioutine being uefineu. Foith woius within each subioutine aie assembleu into }1
instiuctions, anu aie executeu in the oiuei that they aie encounteieu. Bue to the
}1's stack-oiienteu aichitectuie, aiithmetic is executeu in postfix fashion: piogiams
must fiist push the appiopiiate values onto the uata stack piioi to couing aiithmetic
oi logic instiuctions that will opeiate on them Finally, the subioutine enus with a
semicolon.
BRAFT uameuuino Refeience Nanual
61
E,$*2 %B& FG C,,&0D+&#
The }1 assemblei is not integiateu into the Aiuuino IBE. Insteau, a sepaiate }1
assemblei, wiitten in the gfoith piogiamming language, is useu to assemble }1 coue
into binaiy foimat. 0ne of the outputs of the }1 assemblei is a heauei file that can be
incluueu into Aiuuino sketches. The heauei incluues the assembleu }1 coue as an
aiiay of bytes stoieu in piogiam memoiy.

<<<to-uo: inseit uiiections foi assembling piogiams>>>

FG C,,&0D+@ 41*2912& ;&H&#&*.&
}1 instiuctions incluue liteials, which push values onto the uata stack, ANS Foith
instiuctions anu auuitional instiuctions that peifoim aiithmetic, logical anu uata
opeiations, anu flow-contiol statements. These instiuctions aie uesciibeu in the
tables below.

K''&-34&# R$#&A%$a&'+ The assemblei suppoits thiee uiiectives: stait- anu enu-
uiiectives foi maiking the beginning anu enu of }1 assembly coue, plus an assemblei
constant facility. The uiiectives aie summaiizeu in Table S2: }1 Assemblei
Biiectives, below.

2.34& I5+ SE K''&-34&# R$#&A%$a&'
Instiuction Explanation
start-microprogram symbol
!%.#% =#0G#.-
OQ*A%$0*+ Naiks the stait of a }1 miciopiogiam foi
the assemblei.
!1*%.B+ The stait-miciopiogiam uiiective must be
followeu by a valiu alphanumeiic symbol. All
miciopiogiams shoulu contain a "main"
subioutine containing one oi moie instiuctions,
anu close with the "enu-miciopiogiam" uiiective.
Niciopiogiams may optionally contain auuitional
subioutine uefinitions.
DB.-"4&+ start-microprogram example1
end-microprogram
D*9 =#0G#.-
OQ*A%$0*+ Naiks the enu of a }1 miciopiogiam to the
assemblei.
!1*%.B+ None.
DB.-"4&+ end-microprogram
BRAFT uameuuino Refeience Nanual
62
Instiuction Explanation
nnnnn constant symbol
R&;$*& 70*'%.*%
OQ*A%$0*+ Befines an assemblei constant nameu
!"#$%& with the value (((((.
!1*%.B+ The "constant" uiiective must be pieceueu by
a valiu uecimal integei, (((((, in the iange u to
6SSSS, oi a piepiocesoi uefinition that evaluates
to a uecimal integei. It must be followeu by a
valiu symbol, the name of the constant.
DB.-"4&+ 10386 constant fillchar
Befines an assemblei constant nameu "fillchai"
with the value 1uS86 (ux2892).


)$%&#.4 F*'%#QA%$0*'+ As shown in Table SS: }1 Liteial Instiuctions, a vaiiety of
liteial values can be pusheu onto the }1's stack. Liteials can incluue 16-bit values,
anu aie assembleu into one oi two instiuctions. A single instiuction is useu foi
values of u thiough S2767 (uxuuu thiough ux7FFF), while two instiuctions aie
neeueu foi values of S2768 thiough 6SSSS (ux8uuu thiough uxFFFF).

2.34& I@+ SE )$%&#.4 F*'%#QA%$0*'
Instiuction Explanation
d# nnnnn
R&A$-.4 UQ-3&#+ ***** ! 2
OQ*A%$0*+ Pushes a uecimal liteial onto the uata stack.
!1*%.B+ The "u#" uiiective must be followeu by a valiu uecimal integei,
(((((, in the iange u to 6SSSS.
U0%&+ Assembles to a single instiuction foi values in the iange u to S2767;
two instiuctions anu two }1 CP0 cycles aie iequiieu foi values in the
iange S2768 to 6SSSS.
DB.-"4&+ d# 128
uxuu8u ! T
h# hhhh
Y&B.9&A$-.4 UQ-3&#+ >B^^^^ ! 2
OQ*A%$0*+ Pushes a hexauecimal liteial onto the uata stack.
!1*%.B+ The "h#" uiiective must be followeu by a valiu hexauecimal
integei, )))), in the iange uxuuuu to uxFFFF.
U0%&+ Assembles to a single instiuction foi values in the iange uxuuuu to
ux7FFF; two instiuctions anu two }1 CP0 cycles aie iequiieu foi
values in the iange ux8uuu to uxFFFF.
DB.-"4&+ h# 2B80
ux2B8u ! T
[char]c
7^.#.A%&#+ A ! 2
OQ*A%$0*+ Pushes a one-byte chaiactei liteial, c, onto the uata stack.
!1*%.B+ The "|chaij" uiiective must be followeu by a single one-byte
chaiactei, *.
DB.-"4&+ [char] Z
uxuuSA ! T
BRAFT uameuuino Refeience Nanual
6S
Instiuction Explanation
symbol
F*'&#% 70*'%.*%
OQ*A%$0*+ Inseits the nameu assemblei constant as a liteial; functionally
equivalent to the "u#" uiiective above.
!1*%.B+ "!"#$%&+ is the name of any uefineu assemblei constant. An
assemblei eiioi is ietuineu if the name is invaliu oi unuefineu.
DB.-"4&+ fillchar
ux2892 ! T

KU! O0#%^ F*'%#QA%$0*'+ The following Foith piimitives aie assembleu as single
instiuctions. Foi the examples, note that liteial instiuctions aie useu to loau the
uata stack, so T=uxuu29 anu if neeueu N=uxuuuS (uecimal 41 anu S iespectively).
Assume that uameuuino memoiy locations in RAN_PIC (incluuing both uxuu29 anu
uxuuuS) contain an ASCII blanks (ux2u, uecimal S2).

2.34& IM+ SE KU! O0#%^ F*'%#QA%$0*'
Instiuction Explanation
+
=4Q'+ U b 2 ! 2
OQ*A%$0*+ Pops two values (N anu T) fiom the uata stack anu pushes the
sum N+T onto the uata stack, ieuucing the net stack uepth by one.
!1*%.B+ The "+" opeiatoi iequiies two opeianus on the uata stack.
Aiithmetic oveiflow uoes not cause an exception; insteau, the caiiy
bit (most significant bit) of the iesult is uiscaiueu.
DB.-"4&+ d# 3 h# 0029 +
N=uxuuuS + T=uxuu29 = uxuu2C ! T
1-
R&A#&-&*%+ cc2 ! 2
OQ*A%$0*+ Subtiacts one fiom T; uoes not change the stack uepth.
!1*%.B+ The "1-" opeiatoi iequiies one opeianu on the uata stack.
Aiithmetic unueiflow uoes not cause an exception; ueciementing
uxuuuu iesults in uxFFFF.
DB.-"4&+ h# 0029 1-
T=uxuu29 - 1 = uxuu28 ! T
=
DWQ.4'+ U dd 2 ! 2
OQ*A%$0*+ Pops two values (N anu T) fiom the uata stack anu pushes a
Boolean flag onto the stack, ieuucing the net stack uepth by one. The
flag is tiue (uxuuu1) if T anu N aie bit-foi-bit iuentical, oi false
(uxuuuu) otheiwise.
!1*%.B+ The "=" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 =
N=uxuuuS == T=uxuu29 = uxuuuu ! T
<
)&'' 2^.*+ U e 2 ! 2
OQ*A%$0*+ Pops two values (N anu T) fiom the uata stack anu pushes a
Boolean flag onto the stack, ieuucing the net stack uepth by one. The
flag is tiue (uxuuu1) if N < T when N anu T aie tieateu as signeu two's
complement 16-bit integeis, oi false (uxuuuu) otheiwise.
!1*%.B+ The "<" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 <
N=uxuuuS < T=uxuu29 = uxuuu1 ! T
BRAFT uameuuino Refeience Nanual
64
Instiuction Explanation
u<
f*'$G*&9 )&'' 2^.*+ U e 2 ! 2
OQ*A%$0*+ Pops two values (N anu T) fiom the uata stack anu pushes a
Boolean flag onto the stack, ieuucing the net stack uepth by one. The
flag is tiue (uxuuu1) if N < T when N anu T aie tieateu as unsigneu
16-bit integeis, oi false (uxuuuu) otheiwise.
!1*%.B+ The "u<" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 u<
N=uxuuuS < T=uxuu29 = uxuuu1 ! T
xor
DBA4Q'$a& :#+ U ! 2 ! 2
OQ*A%$0*+ Pops two values (N anu T) fiom the uata stack anu pushes the
iesult of a bit-by-bit exclusive-oi between N anu T onto the stack,
ieuucing the net stack uepth by one.
!1*%.B+ The "xoi" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 xor
N=uxuuuS ! T=uxuu29 = uxuu2A ! T
and
K*9+ U " 2 ! 2
OQ*A%$0*+ Pops two values (N anu T) fiom the uata stack anu pushes the
iesult of a bit-by-bit anu between N anu T onto the stack, ieuucing the
net stack uepth by one.
!1*%.B+ The "anu" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 and
N=uxuuuS " T=uxuu29 = uxuuu1 ! T
or
:#+ U # 2 ! 2
OQ*A%$0*+ Pops two values (N anu T) fiom the uata stack anu pushes the
iesult of a bit-by-bit inclusive-oi between N anu T onto the stack,
ieuucing the net stack uepth by one.
!1*%.B+ The "oi" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 or
N=uxuuuS # T=uxuu29 = uxuu2B ! T
invert
F*a&#%+ g2 ! 2
OQ*A%$0*+ Peifoims a bitwise inveision of T; all one bits become zeio anu
vice-veisa. Boes not change the stack uepth.
!1*%.B+ The "inveit" opeiatoi iequiies one opeianu on the uata stack.
DB.-"4&+ h# 0029 invert
~ T=uxuu29 = uxFFB6 ! T
swap
!H."+ U " 2
OQ*A%$0*+ Exchanges the values of N anu T on the uata stack. Boes not
change the stack uepth.
!1*%.B+ The "swap" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 swap
N=uxuuuS T=uxuu29 ! N=uxuu29 T=uxuuuS
dup
RQ"4$A.%&+ 2 ! hbb9'%.A]i
OQ*A%$0*+ Pushes the value of T onto the stack, effectively uuplicating T;
incieases the stack uepth by one.
!1*%.B+ The "uup" opeiatoi iequiies one opeianu on the uata stack.
DB.-"4&+ h# 0029 dup
T=uxuu29 ! T
BRAFT uameuuino Refeience Nanual
6S
Instiuction Explanation
drop
R#0"
OQ*A%$0*+ Biscaius the top element of the uata stack, uecieasing the stack
uepth by one anu piomoting N to the new top of stack.
!1*%.B+ The "uiop" opeiatoi iequiies one opeianu on the uata stack.
DB.-"4&+ drop
over
:a&#+ U ! 2
OQ*A%$0*+ Pushes a copy of N onto the uata stack, incieasing stack uepth
by one.
!1*%.B+ The "ovei" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 over
N=uxuuuS ! T
nip
U$"
OQ*A%$0*+ Removes N fiom the uata stack, pieseiving T anu uecieasing
stack uepth by one.
!1*%.B+ The "nip" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 nip
>r
=Q%?#!%.A]+ 2 ! C
OQ*A%$0*+ Pops T fiom the uata stack anu pushes it onto the ietuin stack,
uecieasing uata stack uepth by one anu incieasing ietuin stack uepth
by one.
!1*%.B+ The ">i" opeiatoi iequiies one opeianu on the uata stack. Since
the ietuin stack is also useu to stoie subioutine ietuin auuiesses, any
items pusheu onto the ietuin stack must be iemoveu befoie
attempting to ietuin via ";".
DB.-"4&+ h# 0029 >r
T=uxuu29 ! R
r>
#!%.A]?V&%+ C ! 2
OQ*A%$0*+ Pops R fiom the ietuin stack anu pushes it onto the uata stack,
uecieasing ietuin stack uepth by one anu incieasing uata stack uepth
by one.
!1*%.B+ The "i>" opeiatoi iequiies one opeianu on the ietuin stack. 0sei
piogiams must take caie not to uistuib existing ietuin auuiesses
when manipulating the ietuin stack.
DB.-"4&+ r>
R=uxuu29 ! T
r@
#!%.A]?O&%A^+ C ! h2
OQ*A%$0*+ Copies R fiom the ietuin stack anu pushes it onto the uata
stack, incieasing uata stack uepth by one. Retuin stack uepth is not
affecteu.
!1*%.B+ The "i" opeiatoi iequiies one opeianu on the ietuin stack.
DB.-"4&+ r@
R=uxuu29 ! T
BRAFT uameuuino Refeience Nanual
66
Instiuction Explanation
rshift
C$G^% !^$;%+ U jj 2 ! 2
OQ*A%$0*+ Pops two values (N anu T) fiom the uata stack, logically shifts N
to the iight by T bit places, inseiting zeios into the most significant
places vacateu by the shift. The iesult is pusheu onto the uata stack;
"ishift" ieuuces the net stack uepth by one.
!1*%.B+ The "ishift" opeiatoi iequiies two opeianus on the uata stack.
The iesult of the opeiation is unuefineu if T >= 16.
DB.-"4&+ h# 1A3C h# 0003 rshift
N=ux1ASC >> T=uxuuuS = uxuS47 ! T
*
/Q4%$"41+ U k 2 ! 2
OQ*A%$0*+ Pops two values (N anu T) fiom the uata stack anu pushes the
piouuct TN onto the uata stack, ieuucing the net stack uepth by one.
!1*%.B+ The "*" opeiatoi iequiies two opeianus on the uata stack.
Aiithmetic oveiflow uoes not cause an exception; insteau, the caiiy
bit (most significant bit) of the iesult is uiscaiueu.
DB.-"4&+ d# 3 h# 0029 *
N=uxuuuS T=uxuu29 = uxuu7B ! T

K99$%$0*.4 F*'%#QA%$0*'+ In auuition to the ANS Foith instiuctions, the }1
copiocessoi implements two instiuctions that aie not piesent in the stanuaiu Foith
language, as uesciibeu in Table SS: }1 Auuitional Instiuctions below. These
opeiations aie also implementeu as single instiuctions on the uameuuino's }1 CP0:

2.34& II+ SE K99$%$0*.4 F*'%#QA%$0*'
Instiuction Explanation
swab
!H." ,1%&'+ 2l ! 2
OQ*A%$0*+ Swaps the high anu low bytes of T. Boes not change the
stack uepth.
!1*%.B+ The "swab" opeiatoi iequiies one opeianu on the uata
stack.
DB.-"4&+ h# 0029 swab
T=uxuu29 swab = ux29uu ! T
noop
U0 :"&#.%$0*
OQ*A%$0*+ Peifoims no opeiation, uoes not change any stack.
!1*%.B+ None.
DB.-"4&+ noop

/Q4%$?H0#9 F*'%#QA%$0*'+ In auuition to some liteial instiuctions, a few auuitional
ANS Foith base woius iequiie multiple }1 instiuctions foi implementation, as
uesciibeu in Table S6: }1 Nulti-Woiu Instiuctions. In paiticulai, memoiy access
timing iequiies that memoiy access take two }1 machine cycles to complete, so
Foith woius that iequiie memoiy access aie assembleu into two machine
instiuctions to pioviue sufficient time.

2.34& IJ+ SE /Q4%$?80#9 F*'%#QA%$0*'
Instiuction Explanation
BRAFT uameuuino Refeience Nanual
67
Instiuction Explanation
c@
7^.#.A%&# O&%A^+ h2i ! 2
OQ*A%$0*+ Fetches an 8-bit byte oi a 16-bit woiu fiom memoiy, uepenuing
on context:
If T is between uxuuuu anu ux7FFF (u to S2767 uecimal), ieaus
the byte at memoiy auuiess T anu paus the uppei 8 bits with
zeios.
If T is an even numbei between ux8uuu anu ux8u1C (S2768 to
S2796 uecimal), ieaus the 16-bit woiu at memoiy auuiess.
In eithei case, the top of the uata stack is ieplaceu with the value ieau;
net uata stack uepth is not affecteu.
!1*%.B+ The "c" opeiatoi iequiies one opeianu on the uata stack. The
opeiation of "c" is unuefineu when T contains an ouu numbei
between ux8uu1 anu ux8u1B, oi when T contains a value gieatei than
ux8u1C.
U0%&+ Assembleu as "noop c" to ensuie coiiect memoiy access timing.
DB.-"4&+ h# 0x0029 c@
|T=uxuu29j=uxuu2u ! T
c!
7^.#.A%&# !%0#&+ U ! h2i
OQ*A%$0*+ Wiites an 8-bit oi a 16-bit value to memoiy, uepenuing on
context:
If T is between uxuuuu anu ux7FFF (u to S2767 uecimal), wiites
the low (least-significant) byte of N to the memoiy auuiess T.
If T is an even numbei between ux8uuu anu ux8u1C (S2768 to
S2796 uecimal), wiites all 16 bits of N to the woiu at memoiy
auuiess T anu T+1.
In eithei case, "c!" pops two values (N anu T) fiom the uata stack,
ieuucing uata stack uepth by two.
!1*%.B+ The "c!" opeiatoi iequiies two opeianus on the uata stack. The
opeiation of "c!" is unuefineu when T contains an ouu numbei between
ux8uu1 anu ux8u1B. Bata is uiscaiueu without waining if the
opeiation attempts to wiite uata to non-existent oi ieau-only memoiy
auuiesses.
U0%&+ Assembles as two instiuctions (one that wiites to memoiy but only
iemoves N fiom the stack, followeu by uiop) to ensuie coiiect memoiy
access timing.
DB.-"4&+ d# 3 h# 0x0029 c!
N=uxuuuS ! |T=uxuu29j

/&#G&9 F*'%#QA%$0*'+ The }1 CP0 can execute a numbei of single instiuctions that
peifoim the equivalent of two ANS Foith piimitives in sequence. In each case, the
meigeu instiuction is nameu foi its components: foi example, executing "oveianu"
is the same as executing the coue fiagment "ovei anu". Neigeu instiuctions
iepiesent a significant oppoitunity to save coue size anu execution time by taking
auvantage of featuies unique to the }1 CP0 aichitectuie. Table S7: }1 Neigeu
Instiuctions uesciibes these instiuctions.

2.34& IN+ SE /&#G&9 F*'%#QA%$0*'
Instiuction Explanation
BRAFT uameuuino Refeience Nanual
68
Instiuction Explanation
2dup+
59Q" =4Q'+ U b 2 ! 2
OQ*A%$0*+ Pushes the sum N+T onto the uata stack, incieasing the net
stack uepth by one.
!1*%.B+ The "2uup+" opeiatoi iequiies two opeianus on the uata stack.
Aiithmetic oveiflow uoes not cause an exception; insteau, the caiiy
bit (most significant bit) of the iesult is uiscaiueu.
DB.-"4&+ d# 3 h# 0029 2dup+
N=uxuuuS + T=uxuu29 = uxuu2C ! T
over+
59Q" =4Q'+ U b 2 ! 2
OQ*A%$0*+ Pops one value (T) fiom the uata stack, anu pushes the sum
N+T onto the uata stack, leaving the net stack uepth unchangeu.
!1*%.B+ The "ovei+" opeiatoi iequiies two opeianus on the uata stack.
Aiithmetic oveiflow uoes not cause an exception; insteau, the caiiy
bit (most significant bit) of the iesult is uiscaiueu.
DB.-"4&+ d# 3 h# 0029 over+
N=uxuuuS + T=uxuu29 = uxuu2C ! T
2dup=
5RQ" DWQ.4'+ U dd 2 ! 2
OQ*A%$0*+ Pushes a Boolean flag onto the uata stack, incieasing the net
stack uepth by one. The flag is tiue (uxuuu1) if T anu N aie bit-foi-bit
iuentical, oi false (uxuuuu) otheiwise.
!1*%.B+ The "2uup=" opeiatoi iequiies two opeianus on the uata stack.
Stack unueiflow uoes not iaise an exception; iesults of a computation
involving an unueiflow aie unuefineu.
DB.-"4&+ d# 3 h# 0x0029 2dup=
N=uxuuuS == T=uxuu29 = uxuuuu ! T
over=
:a&# DWQ.4'+ U dd 2 ! 2
OQ*A%$0*+ Pops one value (T) fiom the uata stack, anu pushes a Boolean
flag onto the uata stack, leaving the net stack uepth unchangeu. The
flag is tiue (uxuuu1) if T anu N aie bit-foi-bit iuentical, oi false
(uxuuuu) otheiwise.
!1*%.B+ The "ovei=" opeiatoi iequiies two opeianus on the uata stack.
Stack unueiflow uoes not iaise an exception; iesults of a computation
involving an unueiflow aie unuefineu.
DB.-"4&+ d# 3 h# 0x0029 over=
N=uxuuuS == T=uxuu29 = uxuuuu ! T
2dup<
59Q" )&'' 2^.*+ U e 2 ! 2
OQ*A%$0*+ Pushes a Boolean flag onto the uata stack, incieasing the net
stack uepth by one. The flag is tiue (uxuuu1) if N < T when N anu T
aie tieateu as signeu two's complement 16-bit integeis, oi false
(uxuuuu) otheiwise.
!1*%.B+ The "2uup<" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 2dup<
N=uxuuuS < T=uxuu29 = uxuuu1 ! T
BRAFT uameuuino Refeience Nanual
69
Instiuction Explanation
over>
59Q" V#&.%&# 2^.*+ U j 2 ! 2
OQ*A%$0*+ Pops one value (T) fiom the uata stack anu pushes a Boolean
flag onto the stack, leaving the net stack uepth unchangeu. The flag is
tiue (uxuuu1) if N > T when N anu T aie tieateu as signeu two's
complement 16-bit integeis, oi false (uxuuuu) otheiwise.
!1*%.B+ The "ovei>" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 over>
N=uxuuuS > T=uxuu29 = uxuuuu ! T
2dupu<
59Q" f*'$G*&9 )&'' 2^.*+ U e 2 ! 2
OQ*A%$0*+ Pushes a Boolean flag onto the uata stack, incieasing the net
stack uepth by one. The flag is tiue (uxuuu1) if N < T when N anu T
aie tieateu as unsigneu 16-bit integeis, oi false (uxuuuu) otheiwise.
!1*%.B+ The "2uupu<" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 2dupu<
N=uxuuuS < T=uxuu29 = uxuuu1 ! T
overu>
:a&# f*'$G*&9 V#&.%&# 2^.*+ U j 2 ! 2
OQ*A%$0*+ Pops one value (T) fiom the uata stack, anu pushes a Boolean
flag onto the stack, leaving the net stack uepth by unchangeu. The flag
is tiue (uxuuu1) if N > T when N anu T aie tieateu as unsigneu 16-bit
integeis, oi false (uxuuuu) otheiwise.
!1*%.B+ The "oveiu>" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 overu>
N=uxuuuS > T=uxuu29 = uxuuuu ! T
2dupxor
5RQ" DBA4Q'$a& :#+ U ! 2 ! 2
OQ*A%$0*+ Pushes the iesult of a bit-by-bit exclusive-oi between N anu T
onto the uata stack, incieasing the net stack uepth by one.
!1*%.B+ The "2uupxoi" opeiatoi iequiies two opeianus on the uata stack.
Stack unueiflow uoes not iaise an exception; iesults of a computation
involving an unueiflow aie unuefineu.
DB.-"4&+ d# 3 h# 0x0029 2dupxor
N=uxuuuS ! T=uxuu29 = uxuu2A ! T
overxor
:a&# DBA4Q'$a& :#+ U ! 2 ! 2
OQ*A%$0*+ Pops one value (T) fiom the uata stack, anu pushes the iesult of
a bit-by-bit exclusive-oi between N anu T onto the uata stack, leaving
the net stack uepth unchangeu.
!1*%.B+ The "oveixoi" opeiatoi iequiies two opeianus on the uata stack.
Stack unueiflow uoes not iaise an exception; iesults of a computation
involving an unueiflow aie unuefineu.
DB.-"4&+ d# 3 h# 0x0029 overxor
N=uxuuuS ! T=uxuu29 = uxuu2A ! T
2dupand
59Q" K*9+ U " 2 ! 2
OQ*A%$0*+ Pushes the iesult of a bit-by-bit anu between N anu T onto the
stack, incieasing the net stack uepth by one.
!1*%.B+ The "2uupanu" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 2dupand
N=uxuuuS " T=uxuu29 = uxuuu1 ! T
BRAFT uameuuino Refeience Nanual
7u
Instiuction Explanation
overand
:a&# K*9+ U " 2 ! 2
OQ*A%$0*+ Pops one value (T) fiom the uata stack anu pushes the iesult of
a bit-by-bit anu between N anu T onto the uata stack, leaving the net
stack uepth unchangeu.
!1*%.B+ The "oveianu" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 overand
N=uxuuuS " T=uxuu29 = uxuuu1 ! T
2dupor
59Q" :#+ U # 2 ! 2
OQ*A%$0*+ Pushes the iesult of a bit-by-bit inclusive-oi between N anu T
onto the uata stack, incieasing the net stack uepth by one.
!1*%.B+ The "2uupoi" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 2dupor
N=uxuuuS # T=uxuu29 = uxuu2B ! T
overor
:a&# :#+ U # 2 ! 2
OQ*A%$0*+ Pops one values (T) fiom the uata stack anu pushes the iesult of
a bit-by-bit inclusive-oi between N anu T onto the stack, leaving the
net stack uepth unchangeu.
!1*%.B+ The "oveioi" opeiatoi iequiies two opeianus on the uata stack.
DB.-"4&+ d# 3 h# 0029 overor
N=uxuuuS # T=uxuu29 = uxuu2B ! T
dup>r
RQ" =Q%?#!%.A]+ 2 ! C
OQ*A%$0*+ Copies T fiom the uata stack to the ietuin stack, incieasing
ietuin stack uepth by one but leaving the uata stack uepth unchangeu.
!1*%.B+ The "uup>i" opeiatoi iequiies one opeianu on the uata stack.
Since the ietuin stack is also useu to stoie subioutine ietuin
auuiesses, any items pusheu onto the ietuin stack must be iemoveu
befoie attempting to ietuin via ";".
DB.-"4&+ h# 0x0029 >r
T=uxuu29 ! R
2duprshift
59Q" C$G^% !^$;%+ U jj 2 ! 2
OQ*A%$0*+ Logically shifts N to the iight by T bit places, inseiting zeios
into the most significant places vacateu by the shift. The iesult is
pusheu onto the uata stack; "2uupishift" incieases the net stack uepth
by one.
!1*%.B+ The "2uupishift" opeiatoi iequiies two opeianus on the uata
stack. The iesult of the opeiation is unuefineu if T >= 16.
DB.-"4&+ h# 1A3C h# 0003 2duprshift
N=ux1ASC >> T=uxuuuS = uxuS47 ! T
2dup*
59Q" /Q4%$"41+ U k 2 ! 2
OQ*A%$0*+ Pushes the piouuct TN onto the uata stack, incieasing the net
stack uepth by one.
!1*%.B+ The "2uup*" opeiatoi iequiies two opeianus on the uata stack.
Aiithmetic oveiflow uoes not cause an exception; insteau, the caiiy
bit (most significant bit) of the iesult is uiscaiueu.
DB.-"4&+ d# 3 h# 0029 2dup*
N=uxuuuS T=uxuu29 = uxuu7B ! T
BRAFT uameuuino Refeience Nanual
71
Instiuction Explanation
over*
:a&# /Q4%$"41+ U k 2 ! 2
OQ*A%$0*+ Pops one value (T) fiom the uata stack anu pushes the piouuct
TN onto the uata stack, leaving the net stack uepth unchangeu.
!1*%.B+ The "ovei*" opeiatoi iequiies two opeianus on the uata stack.
Aiithmetic oveiflow uoes not cause an exception; insteau, the caiiy
bit (most significant bit) of the iesult is uiscaiueu.
DB.-"4&+ d# 3 h# 0029 over*
N=uxuuuS T=uxuu29 = uxuu7B ! T
dupswab
RQ" !H." ,1%&'+ 2l ! 2
OQ*A%$0*+ Swaps the high anu low bytes of T anu pushes the iesult onto
the uata stack, incieasing the stack uepth by one.
!1*%.B+ The "swab" opeiatoi iequiies one opeianu on the uata stack.
DB.-"4&+ h# 0029 dupswab
T=uxuu29 swab = ux29uu ! T
dupc@
RQ" 7^.#.A%&# O&%A^+ h2i ! 2
OQ*A%$0*+ Fetches an 8-bit byte oi a 16-bit woiu fiom memoiy, uepenuing
on context, anu pushes it onto the uata stack:
If T is between uxuuuu anu ux7FFF (u to S2767 uecimal),
ieaus the byte at memoiy auuiess T anu paus the uppei 8 bits
with zeios.
If T is an even numbei between ux8uuu anu ux8u1C (S2768 to
S2796 uecimal), ieaus the 16-bit woiu at memoiy auuiess T.
In eithei case, the iesulting value is pusheu onto the uata stack,
incieasing the net stack uepth by one.
!1*%.B+ The "uupc" opeiatoi iequiies one opeianu on the uata stack.
The opeiation of "uupc" is unuefineu when T contains an ouu
numbei between ux8uu1 anu ux8u1B, oi when T contains a value
gieatei than ux8u1C.
U0%&+ Assembleu as "uup c" to ensuie coiiect memoiy access timing.
DB.-"4&+ h# 0x0029 dupc@
|T=uxuu29j=uxuu2u ! T

O40H 70*%#04+ The assemblei also iecognizes a numbei of that useu to ueteimine
how pieceuing anu subsequent instiuctions shoulu be assembleu, oi that implement
flow contiol such as bianching anu subioutines. Nost of the uiiectives will
assemble into one }1 instiuction, typically a bianch oi call. Some uiiectives,
incluuing ":", "then", anu "begin" maik bianch oi call auuiesses insteau. Subioutine
ietuins via ";" uo not iequiie a sepaiate instiuction in most cases.

2.34& I6+ SE K''&-34&# O40H 70*%#04
Instiuction Explanation
BRAFT uameuuino Refeience Nanual
72
Instiuction Explanation
: symbol
R&;$*& !Q3#0Q%$*&
OQ*A%$0*+ Befines a subioutine entiy point nameu "symbol". Coue
following the subioutine name up to the next semicolon will be
assembleu into a subioutine anu calleu when the symbol is invokeu.
!1*%.B+ The ":" uiiective must be followeu by a valiu symbol (the name of
the subioutine) anu zeio oi moie instiuctions. Subioutine uefinitions
may not be nesteu: eveiy subioutine must be closeu with ";" oi
";fallthiu" uiiective befoie anothei subioutine can be uefineu.
DB.-"4&+ : > swap < ;
Befines a subioutine entiy point nameu ">" that will execute "swap <"
whenevei it is calleu.
;
C&%Q#* ;#0- !Q3#0Q%$*&+ C ! =7
OQ*A%$0*+ Completes the uefinition of a subioutine anu assembles a
ietuin instiuction: the top-most value of the ietuin stack is iemoveu
anu loaueu into the piogiam countei. Reuuces the ietuin stack uepth
by one; the uata stack uepth is unaffecteu.
!1*%.B+ The ";" uiiective must be pieceueu by a valiu subioutine
uefinition consisting of the ":" uiiective, a symbol, anu zeio oi moie
instiuctions.
U0%&+ The }1 aichitectuie often allows a "fiee" ietuin: AL0 instiuctions
can be coueu to also ietuin fiom a subioutine, making subioutines
paiticulaily efficient at ieuucing the oveiall coue size of a piogiam.
DB.-"4&+ ;
R ! PC
;fallthru
D*9 !Q3#0Q%$*& H$%^0Q% C&%Q#*
OQ*A%$0*+ Completes the uefinition of a subioutine, but uoes not assemble
a ietuin instiuction. This allows subioutines with multiple entiy
points. Execution continues with the next instiuction following the
";fallthiu" uiiective.
!1*%.B+ The ";fallthiu" uiiective must be pieceueu by a valiu subioutine
uefinition beginning with the ":" uiiective, a symbol, anu zeio oi moie
executable instiuctions. It must be followeu by anothei subioutine
uefinition.
DB.-"4&+ : 0> d# 0 ;fallthru : > swap < ;
Befines a subioutine with two entiy points, "u>" anu ">". When "u>"
is calleu, the instiuction stieam "u# u swap <" is executeu; when ">"
is calleu, only "swap <" is executeu.
symbol
7.44 !Q3#0Q%$*&+ =7 ! Cm !"#$%& ! ()
OQ*A%$0*+ Pushes the location of the following instiuction onto the ietuin
stack anu calls the nameu subioutine. Retuin stack uepth incieases
by one.
!1*%.B+ The name of any uefineu subioutine, sepaiateu by white space.
An assemblei eiioi is ietuineu if the name is invaliu oi if a
subioutine with the given name can't be founu.
DB.-"4&+ 0>
Calls the subioutine uefineu as an example above; the instiuction
stieam "u# u swap <" is executeu.
BRAFT uameuuino Refeience Nanual
7S
Instiuction Explanation
if
70*9$%$0*.4 ,#.*A^
OQ*A%$0*+ Pops T fiom the uata stack anu tieats it as a Boolean flag.
When the flag is false (uxuuuu), the coue between "else" anu "then" is
executeu. 0theiwise, the coue between "if" anu "else" is executeu. In
eithei case, execution iesumes with the instiuction following "then".
"If" ieuuces the uata stack uepth by one.
!1*%.B+ A conuitional bianch begins with "if", may optionally contain
"else", anu must close with "then"; each is sepaiateu by zeio oi moie
woius. The execution path is unuefineu if the stack is empty.
Conuitional bianches may be nesteu to an unspecifieu uepth.
DB.-"4&+ 2dup < if nip else drop then
Compaies T anu N, anu iemoves the smallei value fiom the stack
pieseiving the laigei as the new top of stack: max(N,T) ! T.
else
70*9$%$0*.4 ,#.*A^ !&".#.%0#
OQ*A%$0*+ Sepaiates the two alteinatives coue paths in a conuitional
bianch. If theie is no coue between "else" anu "then", the "else" may
also be omitteu. See "if" above.
!1*%.B+ A conuitional bianch begins with "if", may optionally contain
"else", anu must close with "then"; each is sepaiateu by zeio oi moie
woius. Conuitional bianches may be nesteu to an unspecifieu uepth.
DB.-"4&+ 2dup < if nip else drop then
Compaies T anu N, anu iemoves the smallei value fiom the stack
pieseiving the laigei as the new top of stack: max(N,T) ! T.
then
70*9$%$0*.4 ,#.*A^ 2&#-$*.%0#
OQ*A%$0*+ Enus a conuitional bianch; noimal execution iesumes with the
instiuction following "then". See if above.
!1*%.B+ A conuitional bianch begins with "if", may optionally contain
"else", anu must close with "then"; each is sepaiateu by zeio oi moie
executable instiuctions. Conuitional bianches may be nesteu to an
unspecifieu uepth.
DB.-"4&+ 2dup < if nip else drop then
Compaies T anu N, anu iemoves the smallei value fiom the stack
pieseiving the laigei as the new top of stack: max(N,T) ! T.
begin
,&G$* )00"
OQ*A%$0*+ Staits a looping constiuct; aftei ieaching the bottom of the
loop, execution will iesume with the instiuction following "begin".
Boes not change uata oi ietuin stack uepth.
!1*%.B+ A loop may take one of thiee foims:
An infinite loop consisting of "begin" followeu by zeio oi moie
woius anu completeu by "again",
A bottom-exit loop consisting of "begin" followeu by zeio oi
moie woius enuing with "until", oi
A miuule-exit loop consisting of "begin", "while", anu "iepeat",
with zeio oi moie woius between each.
Loops may be nesteu to an unspecifieu uepth.
DB.-"4&+ begin d# 1 + again
Loops foievei, auuing 1 to the top of the stack.
BRAFT uameuuino Refeience Nanual
74
Instiuction Explanation
again
F*;$*$%& )00"
OQ*A%$0*+ Retuins execution to the instiuction following the pieceuing
"begin". Any coue following "again" is nevei executeu. Boes not affect
uata oi ietuin stack uepth.
!1*%.B+ An infinite loop consists of "begin" followeu by zeio oi moie
woius anu teiminateu by "again". Loops may be nesteu to an
unspecifieu uepth: a "begin" . "again" loop may itself contain any
numbei anu types of loop constiuct.
DB.-"4&+ begin d# 1 + again
Loops foievei, auuing 1 to the top of the stack.
until
,0%%0-?DB$% )00"
OQ*A%$0*+ Completes a bottom-exit loop: pops T fiom the uata stack anu
tieats it as a Boolean flag. If false (uxuuuu), ietuins execution to the
instiuction following the pieceuing "begin". 0theiwise, continues
execution with the instiuction following "until". Reuuces uata stack
uepth by one.
!1*%.B+ A bottom-exit loop consists of "begin" followeu by zeio oi moie
woius, enuing with "until". Loops may be nesteu to an unspecifieu
uepth: a "begin" . "until" loop may itself contain any numbei anu
types of loop constiucts.
DB.-"4&+ d# 45 d# 1 begin d# 1 + 2dup= until
Count up fiom 1 to 4S by auuing one to the top of stack until the
iesulting value equals 4S.
while
/$994&?DB$% )00" DB$%
OQ*A%$0*+ Pops T fiom the uata stack anu tieats it as a Boolean flag. If
false (uxuuuu), exits the loop by ietuining execution to the
instiuction following the subsequent "iepeat". 0theiwise, execution
continues with the instiuction aftei "while". Reuuces uata stack uepth
by one.
!1*%.B+ A miuule-exit loop consists of "begin", "while", anu "iepeat", with
zeio oi moie executable instiuctions between each. Loops may be
nesteu to an unspecifieu uepth: a "begin" . "while" . "iepeat" loop
may contain any numbei anu types of loop constiucts.
DB.-"4&+ d# 0 d# 4 begin 1- 2dup= while foo repeat
Counts uown fiom 4 to u, executing the "foo" subioutine foui times.
repeat
/$994&?DB$% )00" ,0Q*9.#1
OQ*A%$0*+ Retuins execution to the instiuction following the matching
"begin".
!1*%.B+ A miuule-exit loop consists of "begin", "while", anu "iepeat", with
zeio oi moie executable instiuctions between each. Loops may be
nesteu to an unspecifieu uepth: a "begin" . "while" . "iepeat" loop
may contain any numbei anu types of loop constiucts.
DB.-"4&: d# 0 d# 4 begin 1- 2dup= while foo repeat
Counts uown fiom 4 to u, executing the "foo" subioutine foui times.

f'&;Q4 !Q3#0Q%$*&'+ The following subioutines aie useful in a wiue vaiiety of
piogiams, eithei because they uefine auuitional ANS Foith woius, oi peifoim
fiequently-useu coue sequences.
BRAFT uameuuino Refeience Nanual
7S

<<<to-uo: inseit a table of useful subioutines>>>
)*.& <"%$4$=3%$*-
Although the }1 copiocessoi only has 2S6 bytes (128 instiuctions) of piogiam
memoiy, it also has a numbei of featuies that a clevei piogiammei can use to wiite
efficient coue that occupies as little space as possible. These techniques incluue:

1. O.A%0# A0--0* A09& $*%0 'Q3#0Q%$*&'+ A }1 subioutine call is a single
instiuction, anu the ietuin is almost always fiee in teims of coue space anu
execution time, since a ietuin fiom subioutine can be coueu into any AL0
instiuction. This means that even shoit sequences of instiuctions can be maue
into subioutines to save space. Factoi out:
Sequences of 2 instiuctions that aie useu S oi moie times in youi coue, anu
Sequences of S oi moie instiuctions that aie useu at least twice in youi coue.

Foi example, if the subioutine in Sketch 6: Example Subioutine ieplaces S
instances wheie the thiee-instiuction
sequence "u# 2 * 2uup=" woulu be useu
in youi coue, the net savings is 7
instiuctions (14 bytes).

2. f'& -Q4%$"4& &*%#1 'Q3#0Q%$*&'+ The }1 assemblei allows subioutines to have
multiple entiy points. This allows the clevei piogiammei to factoi moie coue
into subioutines. Aftei factoiing iepeateu instiuction sequences into
subioutines, look foi instances wheie the same instiuction oi sequence of
instiuctions pieceues a subioutine call multiple times in youi coue. Factoi these
out into an auuitional subioutine entiy point pieceuing the oiiginal subioutine
using ;fallthiu.

Foi example, aftei factoiing youi coue
into subioutines as uesciibeu above,
you finu S instances wheie youi coue
ieaus "+ 2*2uup=", anu two othei
instances that aie unique. You can then uefine a multiple-entiy subioutine using
;fallthiou as in Sketch 7: Example Nultiple-Entiy Subioutine to save an
auuitional S instiuctions (6 bytes) - a total of 1u instiuctions (2u bytes) savings.

S. f'& -&#G&9 $*'%#QA%$0*'+ The }1 Foith instiuction set incluues two meigeu
instiuctions, 2uup= anu 2uupxoi, that meige the function of the Foith 2uup
opeiation with quality oi logical exclusive-oi (iespectively). In the }1, these
meigeu instiuctions implement common sequences of opeiations into a single
instiuction. These two instiuctions aie paiticulaily useful foi piogiamming
loops, because they leave both of theii aiguments on the stack aftei execution,
leaving the stack piopeily set up foi anothei iteiation of the loop.
: 2*2dup= d# 2 * 2dup= ;
: +2*2dup= + ;fallthru
: 2*2dup= d# 2 * 2dup= ;
!]&%A^ J+ DB.-"4& !Q3#0Q%$*&
!]&%A^ N+ DB.-"4& /Q4%$"4&?D*%#1 !Q3#0Q%$*&
BRAFT uameuuino Refeience Nanual
76

If you aie piogiamming uiiectly in }1 miciocoue iathei than assemblei, many
auuitional meigeu instiuctions aie possible by manipulating the }1 stack
pointeis: any AL0 instiuction that iemoves values fiom eithei stack can be
coueu to ietain the opeianus on the stack insteau. This effectively meiges the
instiuction with uup oi 2uup (foi one-opeianu anu two-opeianu instiuctions,
iespectively), saving instiuction space. Possible meigeu instiuctions incluue
2uup+, uup1-, 2uup<, uupu<, 2uupanu, 2uupoi, uupinveit, 2uupishift, anu
2uup*.

4. 709& %0 ;.A$4$%.%& ;#&& #&%Q#*'+ Subioutines shoulu enu with AL0 instiuctions.
AL0 instiuctions aie those in Table S4: }1 ANS Foith Instiuctions oi Table SS: }1
Auuitional Instiuctions. This allows the ietuin to be coueu uiiectly into the last
instiuction in the subioutine. If this isn't possible, enuing a subioutine with a
call to a uiffeient subioutine will allow the assemblei to ieplace the call with a
jump, also iesulting in a fiee ietuin. Avoiu enuing a subioutine with an
instiuction fiom Table SS: }1 Liteial Instiuctions, since these can't be conveiteu
into fiee ietuins.

S. f'& 0*&?$*'%#QA%$0* 4$%&#.4'+ When possible, avoiu liteial values gieatei than
ux7FFF (S2,767 uecimal). Liteials between uxuuuu anu ux7FFFF can be
assembleu into a single loau instiuction. Liteials ux8uuu (uecimal S2,768) must
be assembleu into two instiuctions, a liteial followeu by inveit.

6. 70Q*% 90H* $*'%&.9 0; Q": The }1 instiuction set incluues a single instiuction
ueciement (1-), but uoes not incluue an inciement instiuction. Inciementing a
countei typically takes two instiuctions (u# 1 +).
It often saves an instiuction to ueciement
thiough a loop woiking fiom a highei memoiy
auuiess to a lowei one oi to ueciement a loop
countei towaius zeio, iathei than inciementing
fiom lowei auuiesses to highei ones oi
inciementing a countei towaius a limit. Foi
example, Sketch 8: Inciementing Loop anu
Sketch 9: Beciementing Loop both peifoim the
same function (a logical "anu" of spiite image
memoiy with uxCF to cleai one of the sets of 4-
coloi spiite images). Bowevei, the ueciement
veision is foui bytes (two instiuctions) shoitei:
the use of the single-instiuction ueciement (1-)
insteau of the two instiuction liteial anu auu (u#
1 +) saves one, anu the elimination of the two-
instiuction liteial (ux8uuu) in favoi of a one-
instiuction value (ux7FFF) saves anothei.
h# cf >r
h# 8000 h# 4000
begin
dup c@ r@ and
over c!
d# 1 + 2dup=
until
h# cf >r
h# 3FFF h# 7FFF
begin
dup c@ r@ and
over c!
1- 2dup=
until
!]&%A^ 6+ F*A#&-&*%$*G )00"
!]&%A^ <+ R&A#&-&*%$*G )00"
BRAFT uameuuino Refeience Nanual
77
FG <$.#).)6&
The }1 machine language is poweiful, anu contains a laige numbei of instiuctions
that aie not uiiectly implementeu in the assemblei language. The haiuwaie
aichitectuie of the }1 uiffeis somewhat fiom the logical aichitectuie uesciibeu
above.

<<<to-uo: inseit uiagiam of }1 haiuwaie aichitectuie>>>

}1 miciocoue is bit-fielu coueu, as uesciibeu in the following tables. Theie aie S
oveiall types of instiuctions: liteials, conuitional anu unconuitional jumps, a
subioutine call, anu AL0 instiuctions:
)$%&#.4: Loaus a liteial value v into T, inciements the uata stack pointei, anu
copies the pievious value of T to this location as the new value of N: v ! T, T !
|++ustackj.
f*A0*9$%$0*.4 SQ-": Loaus a new value N into the piogiam countei. The olu
value is uiscaiueu, anu neithei stack is mouifieu. Because }1 instiuctions aie 16-
bit woius, N must be an even numbei.
70*9$%$0*.4 SQ-": Removes T fiom the stack by ueciementing ustack. If T=u,
jumps to N by loauing it into the piogiam countei. The olu value PC value is
uiscaiueu, anu the ietuin stack is not mouifieu. Because }1 instiuctions aie 16-
bit woius, N must be an even numbei
!Q3#0Q%$*& 7.44: Loaus a new value N into the piogiam countei. The olu value
is pusheu onto the ietuin stack, incieasing the ietuin stack uepth by one. The
uata stack is not mouifieu. Because }1 instiuctions aie 16-bit woius, N must be
an even numbei.
K)f :"&#.%$0*: AL0 opeiations aie multi-puipose instiuctions that can incluue
a ietuin fiom a subioutine, stoie the iesult of a computation onto the uata stack,
copy T into N oi R, wiite to memoiy, anu aujust the uata anu ietuin stack
pointeis - oi potentially all of these opeiations in a single instiuction.

Couing of }1 micioinstiuctions is uesciibeu in Table S9: }1 Niciocoue Instiuctions.
The bit fielus foi AL0 opeiations aie fuithei explaineu in the auuitional tables
below.

2.34& I<+ SE /$A#0A09& F*'%#QA%$0*'
Instiuction Foimat
Liteial 1 V14V13V12V11V10V09V08V07V06V05V04V03V02V01V00
0nconuitional }ump 0 0 0 0 1 1 0 0 N7 N6 N5 N4 N3 N2 N1 N0
}ump on T=u 0 0 1 0 1 1 0 0 N7 N6 N5 N4 N3 N2 N1 N0
Subioutine Call 0 1 0 0 1 1 0 0 N7 N6 N5 N4 N3 N2 N1 N0
AL0 0peiation 0 1 1 P O3 O2 O1 O0 S A W X D1 D0 R1 R0
vuu-v14: Immeuiate value to loau, uxuuuu to ux7FFF (u to S2767 uecimal).
X: 0nuseu bit, set to u foi compatibility
Nu-N7: Taiget auuiess foi jump oi call, uxuu to uxFE (u to 2S4 uecimal); must be even.
P: Pop piogiam countei fiom ietuin stack, |istack--j!PC; u=no anu 1=yes.
BRAFT uameuuino Refeience Nanual
78
:>c:@+ K)f 0"&#.%$0* %0 &B&AQ%&n '&& 2.34& J>+ K)f :"&#.%$0* 709&'`
S: Copy T!N , u=no anu 1=yes.
A: Copy T!R, u=no anu 1=yes.
W: Wiite N!|Tj, u=no anu 1=yes.
Bu-B1: Bata stack pointei (ustack) aujustment, see Table 61: Bata Stack Aujustment.
Ru-R1: Retuin stack pointei (istack) aujustment, see Table 62: Retuin Stack Aujustment.

2.34& J>+ K)f :"&#.%$0* 709&'
AL0 0utput 0u-0S
T 0x0
N 0x1
N + T 0x2
N " T
0x3
N # T
0x4
N ! T
0x5
~T 0x6
N==T 0x7
N < T 0x8
N >> T 0x9
T - 1 0xA
R 0xB
|Tj 0xC
N T 0xD
swab T 0xE
N < T 0xF
2.34& JE+ R.%. !%.A] K9oQ'%-&*%
ustack Bu-B1
No aujustment
0 0
ustack + 1
0 1
0nuefineu
1 0
ustack - 1
1 1

2.34& J5+ C&%Q#* !%.A] K9oQ'%-&*%
istack Bu-B1
No aujustment
0 0
istack + 1
0 1
istack - 2
1 0
istack - 1
1 1

<<<to-uo: bettei uesciiption of }1 miciopiogiamming!>>>

!"#$$%&'() +$,)-#$
The uameuuino haiuwaie composes each iastei line in a memoiy buffei befoie
outputting it to the scieen. The scieenshot featuie makes this buffei available at the
SCREENSB0T memoiy locations, ux2Cuu-ux2F1F (11264-12u6S uecimal) so that
the host miciocontiollei can ieau it via the SPI inteiface.
!5#&&-'0*% >$-& !&+&5% 1&2$'%&#
To captuie a iow of viueo uata, loau SCREENSB0T_Y with a value between ux8uuu
anu ux812B (uecimal S2768 anu SSu67), coiiesponuing to the flag bit F=1 anu the
Su-S8 equal to the line numbei uxuuu-ux12B (u to 299 uecimal) to be captuieu.
Wiiting a u uisables the scieenshot featuie. The low bits of the SCREENSB0T_Y
iegistei always ieflect the cuiient iastei line being geneiateu. When the flag bit of
the iegistei ieaus 1, the selecteu line of uata is available in memoiy locations
ux2Cuu-ux2F1F (11264-12u6S uecimal).

2.34& J@+ !7CDDU!Y:2LT C&G$'%&#
Symbol Auuiess Length Byte 0ffset anu Registei Contents Befault


(hex) (uec) (hex) (uec) +0 +1

BRAFT uameuuino Refeience Nanual
79
SCREENSHOT_Y RW 0x2406 10246 0x2 2 S7S6S5S4S3S2S1S0 F X X X X X X S8 0x0000
X: 0nuseu bit position, ignoieu; shoulu be u foi compatibility ieasons.
Su-S8: Rastei line to captuie, uxuuu-ux12B (u-299 uecimal).
F: Scieenshot flag, u=uisableu oi not ieauy, oi 1=enableu oi uata ieauy.
!5#&&-'0*% >$-& ?,77&#
The scieenshot line buffei, SCREENSB0T, contains coloi infoimation foi 4uu pixels
anu occupies 8uu bytes beginning at auuiess ux2Cuu (11264 uecimal). Eveiy pixel
is composeu of a 2-byte uameuuino coloi value. Because pixels output to the viueo
haiuwaie cannot be tianspaient, the alpha channel uata is always zeio.

2.34& JM+ !7CDDU!Y:2 /&-0#1 /."
Pixel Auuiess Length Byte 0ffset anu Registei Contents


(hex) (uec) (hex) (uec) +0 +1
000 R 0x2C00 11264 0x2 2 G2G1G0B4B3B2B1B0 X R4R3R2R1R0G4G3
001 R 0x2C01 11265 0x2 2 G2G1G0B4B3B2B1B0 X R4R3R2R1R0G4G3

398 R 0x2F1E 12062 0x2 2 G2G1G0B4B3B2B1B0 X R4R3R2R1R0G4G3
399 R 0x2F1F 12063 0x2 2 G2G1G0B4B3B2B1B0 X R4R3R2R1R0G4G3
X: Alpha channel coloi infoimation, always u.
R4-Ru: Reu channel coloi infoimation, u-S2.
B4-Bu: uieen channel coloi infoimation, u-S2.
B4-Bu: Blue channel coloi infoimation, u-S2.

BRAFT uameuuino Refeience Nanual
8u
!"#$$%&'
:5#*-/4'
/F!:: Nastei InSlave 0ut, the SPI line useu to senu uata fiom the uameuuino to
the host miciocontiollei. The uameuuino uses Aiuuino pin 11 foi NIS0. See
SPI.
/:!F: Nastei 0utSlave In, the SPI line useu to senu uata fiom the host
miciocontiollei to the uameuuino. Aiuuino pin 12 is N0SI on the
uameuuino boaiu. See SPI.
!7[: Seiial Clock, the SPI line useu to senu clock pulses that synchionize uata
tiansfeis. The uameuuino uses Aiuuino pin 1S foi SCK. See SPI.
!D): Select, the SPI pin useu to select the taiget uevice foi SPI communication. By
uefault, the uameuuino uses Aiuuino uigital pin 9 foi SEL. See SPI.
!=F: Seiial Peiipheial Inteiface, a synchionous seiial uata link piotocol. The SPI
inteiface uses 4 uigital lines: SEL, NIS0, N0SI, anu SCK. See NIS0, N0SI, SCK,
anu SEL.
!!: Slave select, an alteinate teim foi SEL. See SEL.
@$4&
-'n -$44$'&A0*9: 0ne thousanuth (11u
-S
) of a seconu.
p'n -$A#0'&A0*9: 0ne millionth (11u
-6
) of a seconu.
*'n *.*0'&A0*9: 0ne billionth (11u
-6
) of a seconu.
1ms = 1uuus = 1,uuu,uuuns

S-ar putea să vă placă și