OpenCores
URL https://opencores.org/ocsvn/orsoc_graphics_accelerator/orsoc_graphics_accelerator/trunk

Subversion Repositories orsoc_graphics_accelerator

[/] [orsoc_graphics_accelerator/] [trunk/] [doc/] [src/] [specification.tex] - Blame information for rev 6

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 Orka
\documentclass[10pt,a4paper]{article}
2
\usepackage[latin1]{inputenc}
3
\usepackage{amsmath}
4
\usepackage{amsfonts}
5
\usepackage{amssymb}
6
\usepackage{hyperref}
7
 
8
\usepackage{graphicx}
9
\usepackage{listings}
10
 
11
\author{Per Lenander, Anton Fosselius}
12
\title{ORSoC Graphics accelerator Specification}
13
\begin{document}
14
 
15
\maketitle
16
 
17
\begin{center}
18
\includegraphics[scale=1.0]{../pictures/OpenCores}
19
\end{center}
20
 
21
\begin{center}
22
\includegraphics[scale=0.50]{../pictures/wb_compatible}
23
\end{center}
24
 
25
\newpage
26
 
27
\section*{Revision history}
28
\begin{tabular}{|p{1cm}|p{2cm}|p{3cm}|p{7cm}|}
29
\hline \textbf{Rev.} & \textbf{Date} & \textbf{Author} & \textbf{Description} \\
30
\hline
31
\hline 0.1.0 & 23/3/2012 & Per Lenander & Initial draft \\
32
\hline
33
\end{tabular}
34
\newpage
35
 
36
\tableofcontents
37
\newpage
38
 
39
\section{Introduction}
40
The ORSoC Graphics accelerator allows the user to do advanced vector rendering and 2D blitting to a memory area. The core supports operations such as drawing textures, lines, curves and filling rectangular and triangular areas with color.
41
 
42
This IP Core is designed to integrate with the OpenRISC processor through a Wishbone bus interface. The core itself has no means of displaying the information rendered, for this purpose it can work alongside a display component, such as the enhanced VGA/LCD IP core found on OpenCores.
43
 
44
\subsection{Features}
45
\begin{itemize}
46
\item 32-bit Wishbone bus interface
47
\item Integrates with enhanced VGA/LCD IP core
48
\item Support for 16 bit color depth
49
\item Support for variable resolution
50
\item Acceleration of line operations
51
\item Acceleration of rectangle and triangle rasterization
52
\item Acceleration of memory copy operations
53
\item Textures can be saved to video memory
54
\item Vector transformation and rasterization
55
\item Clipping/Scissoring
56
\item Alpha blending and colorkeying
57
\item Filled Bezier curves
58
\item Bitmap Fonts
59
\item Vector Fonts (ttf)
60
\item Interpolation of colors
61
\item UV-Mapping
62
\item Transformation (scaling and rotation)
63
\item 3D model support (3d degree .obj)
64
\item Z-Buffer (triangles drawn in order of appearance)
65
\item Requires ~10000 Slice LUTs (Xilinx ISE 13.4)
66
\end{itemize}
67
 
68
\subsection{IP Core directory structure}
69
A basic overview of the contents of the IP core source folder can be found in figure \ref{fig:directory}. The \textbf{rtl} folder also contains files for implementing the component in ORPSoCv2.
70
 
71
\begin{figure}
72
\begin{center}
73
\includegraphics[scale=0.5]{../pictures/directory}
74
\caption{Directory structure of the ORSoC graphics accelerator.}
75
\label{fig:directory}
76
\end{center}
77
\end{figure}
78
 
79
\section{Architecture}
80
\subsection{Overview}
81
A topology of how the orgfx is connected to the VGA driver and the OpenRisc core is shown in figure \ref{fig:topology}. The orgfx has three wishbone interfaces: one read/write port that is used to communicate with the host CPU. One read port that reads texture/alpha blending information from the RAM and one write port to write pixel information to the RAM.
82
 
83
\begin{figure}
84
\begin{center}
85
\includegraphics[scale=0.60]{../pictures/topology}
86
\caption{Overview of the ORPSoCv2's wishbone interconnection.}
87
\label{fig:topology}
88
\end{center}
89
\end{figure}
90
 
91
\subsection{Concepts}
92
This section describes a few basic terms used in this document.
93
 
94
\textbf{Video memory} -- The orgfx component writes pixels one by one to an external memory, usually a SDRAM or DDR RAM chip. The CPU should also have access to this memory space to be able to write pixels directly (the easiest way to load textures).
95
 
96
\textbf{Render target} -- The render target, defined by the target base and size registers, describes the area to which all operations render pixels. It is possible to change the base address and size, enabling render-to-texture and double buffering.
97
 
98
\textbf{Surface/Texture} -- Any memory area that can be rendered to, including the render target, is considered a surface. A surface is defined by it's base address and size. There are two main surfaces that the orgfx device handles: the render target and the currently active texture. Swapping between different textures has to be done in software. The operation of setting the current render target or texture is referred to as \textit{binding}.
99
 
100
\textbf{Source, Destination and Clip rectangles} -- There are three sets of rectangles that affect rendering, each described by two points. The first point sets the beginning of the rectangle, while the second point sets the pixel after the end of the rectangle. This way, a rectangle exactly filling the screen would be (0,0,640,480) at 640x480 resolution. See figure \ref{fig:SrcClipDest};
101
 
102
\textbf{Source rectangle} -- The source rectangle defines what pixels should be read from a texture during textured operations. The points are defined in the coordinates of the currently bound texture. This way sections of a texture can be drawn (good for tile maps or bitmap fonts).
103
 
104
\textbf{Destination rectangle} -- The destination rectangle defines where operations such as draw pixel and draw line will draw pixels, in the coordinates of the render target.
105
 
106
\textbf{Clip rectangle} -- The clip rectangle defines an area within the current render target which is valid to draw to. Any pixels outside this rectangle are discarded in the rasterization step. Pixels outside of the render target are automatically discarded.
107
 
108
\begin{figure}
109
\begin{center}
110
\includegraphics[scale=0.50]{../pictures/SrcClipDest}
111
\caption{1. Texture, 2. Source, 3. Render target, 4. Clip, 5. Destination}
112
\label{fig:SrcClipDest}
113
\end{center}
114
\end{figure}
115
 
116
\subsection{Coordinate precision}
117
The orgfx core supports variable coordinate precision through two parameters, \textbf{point\_width} and \textbf{subpixel\_width}. Both parameters defaults to 16 bits width.
118
 
119
Target size, clip and source rects are defined as \textbf{point\_width} bit integers. Destination points are defined as fixed point numbers, with \textbf{point\_width} bit integer precision and \textbf{subpixel\_width} fractional precision. Internally many calculations are done with fixed point logic.
120
 
121
\subsection{Instruction FIFO}
122
All wishbone writes sent to the slave interface will pass through an instruction fifo. If the device is in the busy state (when the pipeline is active) the instruction will be queued instead of being set immediately. This is important to take into account when reading from registers, since an operation that changes the register being read might be queued. To find out if the device is busy, poll the status register and check if the busy bit is high.
123
 
124
\subsection{Pipeline}
125
The orgfx core uses a pipelined architecture to speed up operation. An overview of the pipeline can be seen in figure \ref{fig:pipeline}. Each module in the pipeline communicates with acknowledge and write signals. A module will not assert write to the next module unless it receives an ack first (or if the module was previously in a ready state, in which case the downstream pipeline is empty). All ack and write signals are always exactly one clock tick long, to prevent triggering multiple instances of the same instruction.
126
 
127
Each module in the pipeline may hold the upstream pipeline for several clock ticks. For example, the rasterizer will prevent incoming raster instructions until all the pixels for the current operation are generated. When the rasterizer is ready for new data, it will send an ack upstream.
128
 
129
% The pipeline begins with the \textbf{transformation processor}, it calculates transformations like rotations and scaling. There after the next step in the pipeline is the \textbf{vector processor}, if there is no vector operations to be done, this step is skipped. When the vector calculations is done (if needed) the next step is the   \textbf{rasterizer}, its purpose is to convert points into pixels. When there are a request to write a rectangle, the \textbf{rasterizer} receives two points and outputs all the pixels between those points. The pixels generated by the \textbf{rasterizer} is recieved by the \textbf{fragment processor}. In the \textbf{fragment processor} the pixel gets a color either by a pre-set color or from a texture (via the \textbf{wishbone read} from the \textbf{memory}). The colored pixel is then sent to the \textbf{blender} which handles alpha blending. If alpha is enabled, the \textbf{blender} will read from the address in the \textbf{memory} where the pixel is going to be drawn. Then the new color is calculated based on the pixel color and the alpha value. The pixel is then passed on to the \textbf{renderer} which calculates the address in the memory where the pixel is going to be written. The pixel is then passed on to the \textbf{wishbone write} interface and finally to the render target in the \textbf{memory}.
130
 
131
\begin{figure}
132
\begin{center}
133
\includegraphics[scale=0.35]{../pictures/pipeline}
134
\caption{Picture of the orgfx pipeline}
135
\label{fig:pipeline}
136
\end{center}
137
\end{figure}
138
 
139
\subsection{Description of core modules}
140
 
141
\subsubsection{Wishbone slave}
142
The wishbone slave handles all communication from the main OpenRISC processor (or other master cpu). This component holds all the registers, and the instruction fifo that sets them. This component can be in one of two states: \textit{busy} or \textit{wait}. It enters the busy state when a pipeline operation is initialized, and returns to the wait state when the operation is finished.
143
 
144
\subsubsection{Transformation processor}
145
The transformation processor handles rotations and scaling.
146
 
147
\subsubsection{Vector processor}
148
This module generates the B\'{e}zier curve and can be skipped if no vector graphics is drawn.
149
 
150
\subsubsection{Rasterizer}
151
This rasterizer generates pixel coordinates from points for several different operations.
152
 
153
\subsubsection{Clipper}
154
Discard generated pixel if clipping is enabled and pixel is out of bounds. Always discard pixels outside of the target area.
155
 
156
\subsubsection{Fragment processor}
157
The fragment processor adds color to the pixel generated by the rasterizer. If texturing is disabled, a color supplied from the color register is used. If texturing is enabled on the other hand, the u v coordinates supplied by the rasterizer are used to fetch a pixel from the active texture. If colorkeying is enabled and the fetched color matches the color key, the current pixel is discarded.
158
 
159
\subsubsection{Blender}
160
The blender module performs alpha blending if this is enabled. The module fetches the color of the pixel that the current operation will write to, and the mixes the value of the target color and the color from the fragment processor using the following algorithm:
161
 
162
\begin{quote}
163
$ alpha = alpha_{global} * alpha_{pixel} $
164
 
165
$ color_{out} = color_{in} * alpha + color_{target} * (1 - alpha) $
166
\end{quote}
167
 
168
Where alpha is a value between 0 (transparent) and 1 (opaque). If alpha blending is disabled the pixel is passed on unmodified. The alpha value can be interpolated over a triangle to create gradients. If this function is turned off (interpolation is disabled on triangle draws) then $alpha_{pixel}$ is set to 1.
169
 
170
\subsubsection{Wishbone arbiter}
171
Since two parts of the pipeline (fragment and blender) needs to access video memory, the arbiter makes certain only one of them can access the reader at once. The blender has the highest priority.
172
 
173
\subsubsection{Wishbone master read}
174
The wishbone reader handles all reads from video memory.
175
 
176
\subsubsection{Renderer}
177
The renderer calculates the memory address of the target pixel.
178
 
179
\subsubsection{Wishbone master write}
180
The wishbone master handles all writes to the video memory.
181
 
182
\section{IO Ports}
183
The Core has three wishbone interfaces:
184
 
185
\begin{itemize}
186
\item Wishbone slave -- connects to the data bus of the OpenRISC processor. In the case of ORPSoC, this bus is connected through an arbiter. Supports standard wishbone communications, not any burst modes.
187
\item Wishbone master read-only -- connects to a video memory port with read access. Used for fetching textures and during blending.
188
\item Wishbone master write-only -- connects to a video memory port with write access. Used for rendering pixels to the framebuffer.
189
\end{itemize}
190
 
191
There is an interrupt enabled that can be connected to the interrupt pins on the or1200 CPU (in the supplied orpsoc\_top it is connected to or1200\_pic\_ints[9]). For this interrupt to trigger, the correct bits in the control register has to be set.
192
 
193
\section{Registers}
194
\begin{tabular}{|l|l|l|l|l|}
195
\hline \textbf{Name} & \textbf{Addr} & \textbf{Width} & \textbf{Access} & \textbf{Description} \\
196
\hline
197
\hline CONTROL         & 0x00 & 32 & RW & Control register \\
198
\hline STATUS          & 0x04 & 32 & R  & Status register \\
199
\hline ALPHA           & 0x08 & 32 & RW & Global alpha register \\
200
\hline COLORKEY        & 0x0c & 32 & RW & Colorkey register \\
201
 
202
\hline TARGET\_BASE    & 0x10 & 32 & RW & Render target base \\
203
\hline TARGET\_SIZE\_X & 0x14 & 32 & RW & Render target width \\
204
\hline TARGET\_SIZE\_Y & 0x18 & 32 & RW & Render target height \\
205
 
206
\hline TEX0\_BASE      & 0x1c & 32 & RW & Texture 0 base \\
207
\hline TEX0\_SIZE\_X   & 0x20 & 32 & RW & Texture 0 width \\
208
\hline TEX0\_SIZE\_Y   & 0x24 & 32 & RW & Texture 0 height \\
209
 
210
\hline SRC\_P0\_X      & 0x28 & 32 & RW & Source pixel 0 x \\
211
\hline SRC\_P0\_Y      & 0x2c & 32 & RW & Source pixel 0 y \\
212
\hline SRC\_P1\_X      & 0x30 & 32 & RW & Source pixel 1 x \\
213
\hline SRC\_P1\_Y      & 0x34 & 32 & RW & Source pixel 1 y \\
214
 
215
\hline DEST\_X         & 0x38 & 32 & RW & Destination pixel x \\
216
\hline DEST\_Y         & 0x3c & 32 & RW & Destination pixel y \\
217
\hline DEST\_Z         & 0x40 & 32 & RW & Destination pixel z \\
218
 
219
\hline AA              & 0x44 & 32 & RW & Transformation matrix coefficient\\
220
\hline AB              & 0x48 & 32 & RW & Transformation matrix coefficient\\
221
\hline AC              & 0x4c & 32 & RW & Transformation matrix coefficient\\
222
\hline TX              & 0x50 & 32 & RW & Transformation matrix coefficient\\
223
\hline BA              & 0x54 & 32 & RW & Transformation matrix coefficient\\
224
\hline BB              & 0x58 & 32 & RW & Transformation matrix coefficient\\
225
\hline BC              & 0x5c & 32 & RW & Transformation matrix coefficient\\
226
\hline TY              & 0x60 & 32 & RW & Transformation matrix coefficient\\
227
\hline CA              & 0x64 & 32 & RW & Transformation matrix coefficient\\
228
\hline CB              & 0x68 & 32 & RW & Transformation matrix coefficient\\
229
\hline CC              & 0x6c & 32 & RW & Transformation matrix coefficient\\
230
\hline TZ              & 0x70 & 32 & RW & Transformation matrix coefficient\\
231
 
232
\hline CLIP\_P0\_X     & 0x74 & 32 & RW & Clip pixel 0 x \\
233
\hline CLIP\_P0\_Y     & 0x78 & 32 & RW & Clip pixel 0 y \\
234
\hline CLIP\_P1\_X     & 0x7c & 32 & RW & Clip pixel 1 x \\
235
\hline CLIP\_P1\_Y     & 0x80 & 32 & RW & Clip pixel 0 y \\
236
 
237
\hline COLOR0          & 0x84 & 32 & RW & Color 0 \\
238
\hline COLOR1          & 0x88 & 32 & RW & Color 1 \\
239
\hline COLOR2          & 0x8c & 32 & RW & Color 2 \\
240
 
241
\hline U0              & 0x90 & 32 & RW & Texture coordinate 0 \\
242
\hline V0              & 0x94 & 32 & RW & Texture coordinate 0 \\
243
\hline U1              & 0x98 & 32 & RW & Texture coordinate 1 \\
244
\hline V1              & 0x9c & 32 & RW & Texture coordinate 1 \\
245
\hline U2              & 0xa0 & 32 & RW & Texture coordinate 2 \\
246
\hline V2              & 0xa4 & 32 & RW & Texture coordinate 2 \\
247
 
248
\hline ZBUFFER\_BASE   & 0xa8 & 32 & RW & Depth buffer base address \\
249
 
250
\hline
251
\end{tabular}
252
\\\\
253
Each register is described in detail in the following sections, with information about what the purpose of each bit in the register is. The default value provided for each register is set when the device receives a reset signal.
254
 
255
\subsection{Control Register (CONTROL)}
256
\begin{tabular}{|l|l|l|}
257
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
258
\hline
259
\hline [31:20] & -  & Reserved \\
260
\hline [19]    & W  & Transform point \\
261
\hline [18]    & W  & Forward point \\
262
\hline [17:16] & RW & Active point \\
263
\hline [15:14] & -  & Reserved \\
264
\hline [13]    & W  & B\'{e}zier inside shape \\
265
\hline [12]    & W  & Interpolation \\
266
\hline [11]    & W  & Curve write \\
267
\hline [10]    & W  & Triangle write \\
268
\hline [9]     & W  & Line write \\
269
\hline [8]     & W  & Rect write \\
270
\hline [7]     & -  & Reserved \\
271
\hline [6]     & RW & Z-buffer enable \\
272
\hline [5]     & RW & Clipping enable \\
273
\hline [4]     & RW & Colorkey enable \\
274
\hline [3]     & RW & Blending enable \\
275
\hline [2]     & RW & Texture0 enable \\
276
\hline [1:0]   & RW & Color depth \\
277
\hline
278
\end{tabular}
279
\\\\
280
\textbf{Default value:} 0x00
281
 
282
Color depth is defined as follows:
283
 
284
\begin{tabular}{|l|l|}
285
\hline \textbf{Mode} & \textbf{Color depth}\\
286
\hline
287
\hline 00 & 8 bit \\
288
\hline 01 & 16 bit \\
289
\hline 10 & 24 bit (not supported) \\
290
\hline 11 & 32 bit \\
291
\hline
292
\end{tabular} \\
293
 
294
The active point is defined as follows:
295
 
296
\begin{tabular}{|l|l|}
297
\hline \textbf{Mode} & \textbf{Point id}\\
298
\hline
299
\hline 00 & p0 \\
300
\hline 01 & p1 \\
301
\hline 10 & p2 \\
302
\hline 11 & p3 \\
303
\hline
304
\end{tabular} \\
305
 
306
The operations \textbf{Forward point} and \textbf{Transform point} reads the current values of the active point and stores the x, y, z values in the correct register inside the device.
307
 
308
\subsection{Status Register (STATUS)}
309
\begin{tabular}{|l|l|l|}
310
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
311
\hline
312
\hline [31:16] & R & FIFO size \\
313
\hline [15:1]  & R & Reserved \\
314
\hline [0]     & R & Busy pin (high when busy) \\
315
\hline
316
\end{tabular}
317
\\\\
318
\textbf{Default value:} --
319
 
320
\subsection{Alpha (ALPHA)}
321
\begin{tabular}{|l|l|l|}
322
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
323
\hline
324
\hline [31:24] & RW & Point 0 alpha \\
325
\hline [23:16] & RW & Point 1 alpha \\
326
\hline [15:8] & RW & Point 2 alpha \\
327
\hline [7:0] & RW & Global alpha \\
328
\hline
329
\end{tabular}
330
\\\\
331
\textbf{Default value:} 0xffffffff
332
 
333
The global alpha value is used in all rendering when alpha blending is enabled. \textbf{0xff} is full opacity, while \textbf{0x00} is full transparency (nothing rendered). When interpolation of triangles is activated, the point alpha values are used to find an interpolated alpha value for each pixel. This value is then multiplied with the global alpha before being used for blending.
334
 
335
\subsection{Colorkey register (COLORKEY)}
336
\begin{tabular}{|l|l|l|}
337
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
338
\hline
339
\hline [31:0] & RW & Colorkey \\
340
\hline
341
\end{tabular}
342
\\\\
343
\textbf{Default value:} 0x00
344
 
345
By setting a colorkey certain pixels in a texture can be discarded in the fragment stage, providing a hard transparency. Depending on the color depth, a mask is applied to the color. Using 8 bit color, only the 8 least significant bits in the colorkey will be compared with the texture color during the check. The colorkey enable bit in the control register must be set to enable this functionality.
346
 
347
 
348
\subsection{Target base address Register (TARGET\_BASE)}
349
\begin{tabular}{|l|l|l|}
350
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
351
\hline
352
\hline [31:2] & RW & Video Memory Address \\
353
\hline [1:0] & - & Nothing \\
354
\hline
355
\end{tabular}
356
\\\\
357
\textbf{Default value:} 0x00
358
 
359
\subsection{Target size width Register (TARGET\_SIZE\_X)}
360
\begin{tabular}{|l|l|l|}
361
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
362
\hline
363
\hline [31:0] & RW & Integer Width \\
364
\hline
365
\end{tabular}
366
\\\\
367
\textbf{Default value:} 0x00
368
 
369
\subsection{Target size y Register (TARGET\_SIZE\_Y)}
370
\begin{tabular}{|l|l|l|}
371
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
372
\hline
373
\hline [31:0] & RW & Integer Height \\
374
\hline
375
\end{tabular}
376
\\\\
377
\textbf{Default value:} 0x00
378
 
379
\subsection{Texture 0 Base Register (TEX0\_BASE)}
380
\begin{tabular}{|l|l|l|}
381
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
382
\hline
383
\hline [31:2] & RW & Video Memory Address \\
384
\hline [1:0] & - & Nothing \\
385
\hline
386
\end{tabular}
387
\\\\
388
\textbf{Default value:} 0x00
389
 
390
\subsection{Texture 0 size x Register (TEX0\_SIZE\_X)}
391
\begin{tabular}{|l|l|l|}
392
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
393
\hline
394
\hline [31:0] & RW & Integer Width \\
395
\hline
396
\end{tabular}
397
\\\\
398
\textbf{Default value:} 0x00
399
 
400
\subsection{Texture 0 size y Register (TEX0\_SIZE\_Y)}
401
\begin{tabular}{|l|l|l|}
402
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
403
\hline
404
\hline [31:0] & RW & Integer Height \\
405
\hline
406
\end{tabular}
407
\\\\
408
\textbf{Default value:} 0x00
409
 
410
\subsection{Source Pixel position 0 x Register (SRC\_P0\_X)}
411
\begin{tabular}{|l|l|l|}
412
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
413
\hline
414
\hline [31:0] & RW & Integer x pos \\
415
\hline
416
\end{tabular}
417
\\\\
418
\textbf{Default value:} 0x00
419
 
420
The source pixels are used to define a specific area in a texture to draw.
421
 
422
\subsection{Source Pixel position 0 y Register (SRC\_P0\_Y)}
423
\begin{tabular}{|l|l|l|}
424
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
425
\hline
426
\hline [31:0] & RW & Integer y pos \\
427
\hline
428
\end{tabular}
429
\\\\
430
\textbf{Default value:} 0x00
431
 
432
 
433
\subsection{Source Pixel position 1 Register (SRC\_P1\_X)}
434
\begin{tabular}{|l|l|l|}
435
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
436
\hline
437
\hline [31:0] & RW & Integer x pos \\
438
\hline
439
\end{tabular}
440
\\\\
441
\textbf{Default value:} 0x00
442
 
443
\subsection{Source Pixel position 1 Register (SRC\_P1\_Y)}
444
\begin{tabular}{|l|l|l|}
445
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
446
\hline
447
\hline [31:0] & RW & Integer y pos \\
448
\hline
449
\end{tabular}
450
\\\\
451
\textbf{Default value:} 0x00
452
 
453
\subsection{Destination Pixel position Register (DEST\_X)}
454
\begin{tabular}{|l|l|l|}
455
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
456
\hline
457
\hline [31:16] & RW & Signed Integer part \\
458
\hline [15:0]  & RW & Fractional part \\
459
\hline
460
\end{tabular}
461
\\\\
462
\textbf{Default value:} 0x00
463
 
464
The control register flag active point decides the destination register inside the device. Points are pushed to the device by setting the forward or transform bit in the control register.
465
 
466
\subsection{Destination Pixel position Register (DEST\_Y)}
467
\begin{tabular}{|l|l|l|}
468
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
469
\hline
470
\hline [31:16] & RW & Signed Integer part \\
471
\hline [15:0]  & RW & Fractional part \\
472
\hline
473
\end{tabular}
474
\\\\
475
\textbf{Default value:} 0x00
476
 
477
\subsection{Destination Pixel position Register (DEST\_Z)}
478
\begin{tabular}{|l|l|l|}
479
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
480
\hline
481
\hline [31:16] & RW & Signed Integer part \\
482
\hline [15:0]  & RW & Fractional part \\
483
\hline
484
\end{tabular}
485
\\\\
486
\textbf{Default value:} 0x00
487
 
488
\subsection{Matrix coefficient registers}
489
The matrix coefficients are defined in the following way:
490
 
491
$
492
M
493
=
494
\left[
495
\begin{array}{cccc}
496
AA & AB & AC & TX \\
497
BA & BB & BC & TY \\
498
CA & CB & CC & TZ \\
499
\end{array}
500
\right]
501
$
502
 
503
Each coefficient has a register, where the bits are defined as:
504
 
505
\begin{tabular}{|l|l|l|}
506
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
507
\hline
508
\hline [31:16] & RW & Signed Integer part \\
509
\hline [15:0]  & RW & Fractional part \\
510
\hline
511
\end{tabular}
512
 
513
The default matrix is set to no scaling, no rotation, no translation:
514
 
515
$
516
M_{default}
517
=
518
\left[
519
\begin{array}{cccc}
520
1 & 0 & 0 & 0 \\
521
 
522
 
523
\end{array}
524
\right]
525
$
526
 
527
\subsection{Clip Pixel position 0 x Register (CLIP\_P0\_X)}
528
\begin{tabular}{|l|l|l|}
529
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
530
\hline
531
\hline [31:0] & RW & Integer x \\
532
\hline
533
\end{tabular}
534
\\\\
535
\textbf{Default value:} 0x00
536
 
537
\subsection{Clip Pixel position 0 y Register (CLIP\_P0\_Y)}
538
\begin{tabular}{|l|l|l|}
539
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
540
\hline
541
\hline [31:0] & RW & Integer y \\
542
\hline
543
\end{tabular}
544
\\\\
545
\textbf{Default value:} 0x00
546
 
547
\subsection{Clip Pixel position 1 x Register (CLIP\_P1\_X)}
548
\begin{tabular}{|l|l|l|}
549
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
550
\hline
551
\hline [31:0] & RW & Integer x \\
552
\hline
553
\end{tabular}
554
\\\\
555
\textbf{Default value:} 0x00
556
 
557
\subsection{Clip Pixel position 1 y Register (CLIP\_P1\_Y)}
558
\begin{tabular}{|l|l|l|}
559
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
560
\hline
561
\hline [31:0] & RW & Integer y \\
562
\hline
563
\end{tabular}
564
\\\\
565
\textbf{Default value:} 0x00
566
 
567
\subsection{Color Registers (COLOR0-2)}
568
\begin{tabular}{|l|l|l|}
569
\hline \textbf{Bit \#} & \textbf{Access} & \textbf{Description} \\
570
\hline
571
\hline [31:0] & RW & Color bits \\
572
\hline
573
\end{tabular}
574
\\\\
575
\textbf{Default value:} 0x00
576
 
577
There are several color modes available (set in \textit{video mode register}):
578
 
579
\begin{tabular}{|l|l|l|}
580
\hline \textbf{Mode} & \textbf{Format} \\
581
\hline
582
\hline 32bpp & [31:24] is alpha channel. [23:16] is R, [15:8] is G and [7:0] is B \\
583
%\hline 24bpp & [31:24] is unused. [23:16] is R, [15:8] is G and [7:0] is B \\
584
\hline 16bpp & [15:11] is R, [10:5] is B and [4:0] is G\\
585
\hline 8bpp gray & [7:0] sets both R, G and B values \\
586
\hline 8bpp palette & [7:0] sets the color index in the palette \\
587
\hline
588
\end{tabular}
589
\\\\
590
 
591
\section{Operation}
592
All hardware accelerated operations draw pixels to the currently active surface (defined by TADR\_REG and TSZE\_REG). These operations are all affected by clip\_p0 and clip\_p1. No pixels that fall outside the clipping rectangle will be rendered.
593
 
594
\subsection{Draw pixel}
595
\textbf{Input needed:} dest\_p0, color\\
596
Orgfx have no hardware-support for writing a single pixel to the video memory. However its possible to draw a line, rect or curve with the size of one pixel. The software API makes it possible to draw a pixel by writing directly to the memory (this is the most optimal way). Since the video memory can point to both the framebuffer and to textures, the same operation can be used to draw an arbitrary pixel to the screen and to load a texture into video memory.
597
 
598
\subsection{Fill rect}
599
\textbf{Input needed:} ctrl, dest\_p0, dest\_p1, color, [src\_p0, src\_p1]\\
600
Fill rect will fill the area of a rectangle created between the pixel dest\_p0 and  dest\_p1 with color. If texturing is enabled, color will be taken from the active texture in the area between src\_p0 and src\_p1. This operation is hardware accelerated, and is activated by setting the Rect write bit in the control register.
601
 
602
\subsection{Line}
603
\textbf{Input needed:} dest\_p0, dest\_p1, color\\
604
Line will draw a line between the pixels dest\_p0 and dest\_p1 with color. This operation is hardware accelerated.
605
 
606
\subsection{Fill triangle}
607
\textbf{Input needed:} ctrl, dest\_p0, dest\_p1, dest\_p2, color, [src\_p0, src\_p1]\\
608
Draw the pixels in the triangle created by dest\_p0, dest\_p1 and dest\_p2.
609
 
610
\subsection{Curve}
611
\textbf{Input needed:} ctrl, dest\_p0, dest\_p1, dest\_p2, dest\_p3, color, [src\_p0, src\_p1]\\
612
Draws a cubic b\'{e}zier curve. for a quadratic b\'{e}zier curve, use the same value for dest\_p1 and dest\_p2.
613
 
614
\subsection{Fill curve}
615
\textbf{Input needed:} ctrl, dest\_p0, dest\_p1, dest\_p2, dest\_p3, color, [src\_p0, src\_p1]\\
616
Draws a filled cubic b\'{e}zier curve. for a filled quadratic b\'{e}zier curve, use the same value for dest\_p1 and dest\_p2.
617
 
618
\section{Clocks}
619
The wishbone slave uses the system wishbone bus clock at 50 Mhz, while the rest of the pipeline and the wishbone interfaces to the memory runs at 100Mhz.
620
 
621
\section{Driver interface}
622
The ORSoC graphics accelerator offers three different APIs to code against, two for bare metal when coding directly against the processor, and a Linux kernel module. The extended bare metal interface is a wrapper around the basic bare metal API, and makes coding easier by reducing the number of calls. The drawback is lesser control over the graphics card.
623
 
624
\subsection{newlib}
625
The basic library is provided in \textbf{orgfx.h} and \textbf{orgfx.c}.
626
 
627
The bare metal library declares a structure that can hold surfaces (both framebuffers and textures). Many functions take a pointer to one of these structures.
628
\begin{lstlisting}
629
struct orgfx_surface
630
{
631
        unsigned int addr;
632
        unsigned int w;
633
        unsigned int h;
634
};
635
\end{lstlisting}
636
 
637
\subsubsection{orgfx\_init}
638
\textbf{Description:} The orgfx\_init must be called first to get other oc\_gfx commands to work properly.
639
\begin{lstlisting}
640
void orgfx_init(unsigned int memoryArea);
641
\end{lstlisting}
642
 
643
\subsubsection{orgfx\_vga\_set\_videomode}
644
\textbf{Description:} Sets the video mode, width, height, bpp.
645
\begin{lstlisting}
646
void orgfx_set_videomode(unsigned int width,
647
                         unsigned int height,
648
                         unsigned char bpp);
649
\end{lstlisting}
650
 
651
\subsubsection{orgfx\_vga\_set\_vbara}
652
\textbf{Description:} Assign a memory address to "Video Base Address Register A".
653
\begin{lstlisting}
654
void orgfx_vga_set_vbara(unsigned int addr);
655
\end{lstlisting}
656
 
657
\subsubsection{orgfx\_vga\_set\_vbarb}
658
\textbf{Description:} Assign a memory address to "Video Base Address Register B".
659
\begin{lstlisting}
660
void orgfx_vga_set_vbarb(unsigned int addr);
661
\end{lstlisting}
662
 
663
\subsubsection{orgfx\_vga\_bank\_switch}
664
\textbf{Description:} Switches the framebuffer.
665
\begin{lstlisting}
666
void orgfx_vga_bank_switch();
667
\end{lstlisting}
668
 
669
\subsubsection{orgfx\_init\_surface}
670
\textbf{Description:} Initialize a surface and return a control structure for it. This function increments an internal video memory stack pointer, so each surface will be allocated after the previous one in memory (starting at memoryArea set by orgfx\_init). There is currently no memory management in place to recycle surface memory once it is no longer in use. The first surface initialized will point to the same memory that the video controller reads from, so it should be initialized with the width and height of the screen.
671
\begin{lstlisting}
672
struct orgfx_surface
673
  orgfx_init_surface(unsigned int width,
674
                     unsigned int height);
675
\end{lstlisting}
676
 
677
\subsubsection{orgfx\_bind\_rendertarget}
678
\textbf{Description:} Binds a surface as the active render target. This function \textit{must} be called before any drawing operations can be performed.
679
\begin{lstlisting}
680
void orgfx_bind_rendertarget(struct orgfx_surface *surface);
681
\end{lstlisting}
682
 
683
\subsubsection{orgfx\_enable\_cliprect}
684
\textbf{Description:} Enables/disables clipping.
685
\begin{lstlisting}
686
inline void orgfx_enable_cliprect(unsigned int enable);
687
\end{lstlisting}
688
 
689
\subsubsection{orgfx\_cliprect}
690
\textbf{Description:} Sets the clipping rect. No pixels will be drawn outside of this rect (useful for restricting draws to a specific area of the render target). orgfx\_bind\_rendertarget will reset the clipping rect to the size of the surface.
691
\begin{lstlisting}
692
inline void orgfx_cliprect(unsigned int x0,
693
                           unsigned int y0,
694
                           unsigned int x1,
695
                           unsigned int y1);
696
\end{lstlisting}
697
 
698
\subsubsection{orgfx\_srcrect}
699
\textbf{Description:} Sets the source rectangle that will be used by texturing operations. This allows for only drawing a small part of a texture. orgfx\_bind\_tex0 will reset this to the size of the texture.
700
\begin{lstlisting}
701
inline void orgfx_srcrect(unsigned int x0,
702
                          unsigned int y0,
703
                          unsigned int x1,
704
                          unsigned int y1);
705
\end{lstlisting}
706
 
707
\subsubsection{orgfx\_set\_pixel}
708
\textbf{Description:} Set a pixel on coordinate x,y to color. This is done in software by direct memory writes. This operation is not affected by the clipping rect!
709
\begin{lstlisting}
710
inline void orgfx_set_pixel(unsigned int x,
711
                            unsigned int y,
712
                            unsigned int color);
713
\end{lstlisting}
714
 
715
\subsubsection{orgfx\_memcpy}
716
\textbf{Description:} Copies memory from the processor to the video memory. Size is in 32-bit words. This function is intended to work with the output array of the sprite converter utility to load images into memory. Remember to bind a texture as the render target first!
717
\begin{lstlisting}
718
void orgfx_memcpy(unsigned int mem[],
719
                  unsigned int size);
720
\end{lstlisting}
721
 
722
\subsubsection{orgfx\_set\_color}
723
\textbf{Description:} Sets the current drawing color.
724
\begin{lstlisting}
725
inline void orgfx_set_color(unsigned int color);
726
\end{lstlisting}
727
 
728
\subsubsection{orgfx\_rect}
729
\textbf{Description:} Draws a rect from (x0,y0) to (x1,y1) and fills it with the current drawing color. If texturing is enabled, the current texture will be drawn instead.
730
\begin{lstlisting}
731
inline void orgfx_rect(unsigned int x0,
732
                       unsigned int y0,
733
                       unsigned int x1,
734
                       unsigned int y1);
735
\end{lstlisting}
736
 
737
\subsubsection{orgfx\_line}
738
\textbf{Description:} Draws a line from (x0,y0) to (x1,y1) with the current drawing color. If texturing is enabled, the first pixel of the current texture will be drawn instead.
739
\begin{lstlisting}
740
inline void orgfx_line(unsigned int x0,
741
                       unsigned int y0,
742
                       unsigned int x1,
743
                       unsigned int y1);
744
\end{lstlisting}
745
 
746
\subsubsection{orgfx\_triangle}
747
\textbf{Description:} Draws a filled triangle of the space spanned by (x0,y0), (x1,y1) and (x2,y2). The order of the points is important, since triangles calculated to be counter clockwise will be discarded (backface culling). The interpolate flag indicates if flat coloring or interpolated coloring should be used. The interpolate flag \textit{has} to be enabled for interpolated alpha, texture coordinates or depth is desired (flat coloring can be obtained by setting all three color registers to the same color).
748
\begin{lstlisting}
749
inline void orgfx_triangle(unsigned int x0,
750
                           unsigned int y0,
751
                           unsigned int x1,
752
                           unsigned int y1,
753
                           unsigned int x2,
754
                           unsigned int y2,
755
                           unsigned int interpolate);
756
\end{lstlisting}
757
 
758
\subsubsection{orgfx\_triangle3d}
759
\textbf{Description:} This function works the same way as the triangle function, but the Z-values are set.
760
\begin{lstlisting}
761
inline void orgfx_triangle3d(unsigned int x0,
762
                             unsigned int y0,
763
                             unsigned int z0,
764
                             unsigned int x1,
765
                             unsigned int y1,
766
                             unsigned int z1,
767
                             unsigned int x2,
768
                             unsigned int y2,
769
                             unsigned int z2,
770
                             unsigned int interpolate);
771
\end{lstlisting}
772
 
773
\subsubsection{orgfx\_curve}
774
\textbf{Description:} Draws a Quadratic curve between the points (x0,y0) and (x2,y2) with the control points (x1,y1). The three points form a triangle. The \textit{inside} flag determines if the inside or outside of the curve is filled inside the triangle.
775
\begin{lstlisting}
776
inline void orgfx_curve(unsigned int x0,
777
                        unsigned int y0,
778
                        unsigned int x1,
779
                        unsigned int y1,
780
                        unsigned int x2,
781
                        unsigned int y2,
782
                        unsigned int inside);
783
\end{lstlisting}
784
 
785
\subsubsection{orgfx\_enable\_tex0}
786
\textbf{Description:} Enables or disables texturing.
787
\begin{lstlisting}
788
void orgfx_enable_tex0(unsigned int enable);
789
\end{lstlisting}
790
 
791
\subsubsection{orgfx\_bind\_tex0}
792
\textbf{Description:} Binds a surface as the current texture. Will reset the source rect.
793
\begin{lstlisting}
794
void orgfx_bind_tex0(struct orgfx_surface* surface);
795
\end{lstlisting}
796
 
797
 
798
\subsubsection{orgfx\_enable\_alpha}
799
\textbf{Description:} Enables or disables alpha blending.
800
\begin{lstlisting}
801
void orgfx_enable_alpha(unsigned int enable);
802
\end{lstlisting}
803
 
804
\subsubsection{orgfx\_set\_alpha}
805
\textbf{Description:} Sets the alpha blending value.
806
\begin{lstlisting}
807
void orgfx_set_alpha(unsigned int alpha);
808
\end{lstlisting}
809
 
810
\subsubsection{orgfx\_enable\_colorkey}
811
\textbf{Description:} Enables or disables colorkey.
812
\begin{lstlisting}
813
void orgfx_enable_colorkey(unsigned int enable);
814
\end{lstlisting}
815
 
816
\subsubsection{orgfx\_set\_colorkey}
817
\textbf{Description:} Sets the colorkey color.
818
\begin{lstlisting}
819
void orgfx_set_colorkey(unsigned int colorkey);
820
\end{lstlisting}
821
 
822
\subsection{Extended newlib}
823
The extended library is provided in \textbf{orgfx\_plus.h} and \textbf{orgfx\_plus.c}, but \textbf{orgfx.c} also has to be compiled for it to work.
824
 
825
Instead of using surface structs directly, the extended API hides surface management by returning id tags for each surface. The screen surface (defined by id -1) is handled as a single surface, even when double buffering is enabled.
826
 
827
The driver defines the number of available surfaces (not counting the screen) with a static define. Change this if the default value is too low for your application.
828
 
829
\subsubsection{orgfxplus\_init}
830
\textbf{Description:} Initializes the screen with the supplied video mode and returns an id for the screen.
831
\begin{lstlisting}
832
int orgfxplus_init(unsigned int width,
833
                   unsigned int height,
834
                   unsigned char bpp,
835
                   unsigned char doubleBuffering);
836
\end{lstlisting}
837
 
838
\subsubsection{orgfxplus\_init\_surface}
839
\textbf{Description:} Unlike the basic API, this function both initializes a surface and loads a prepared image to it in one function call. The return value is an id that can be used to bind the surface. It changes render target during operation, but switches back to the last render target on completion. Since the screen(s) are already initialized by a call to init, they do not need to be loaded using this function.
840
\begin{lstlisting}
841
int orgfxplus_init_surface(unsigned int width,
842
                           unsigned int height,
843
                           unsigned int mem[]);
844
\end{lstlisting}
845
 
846
\subsubsection{orgfxplus\_bind\_rendertarget}
847
\textbf{Description:} Binds a surface as the current render target.
848
\begin{lstlisting}
849
void orgfxplus_bind_rendertarget(int surface);
850
\end{lstlisting}
851
 
852
\subsubsection{orgfxplus\_flip}
853
\textbf{Description:} Swaps which buffer to draw on when using double buffering. Needs to be called once before anything shows up on screen!
854
\begin{lstlisting}
855
void orgfxplus_flip();
856
\end{lstlisting}
857
 
858
\subsubsection{orgfxplus\_clip}
859
\textbf{Description:} Sets the current clipping rect. This is reset to the size of the new render target when orgfxplus\_bind\_rendertarget is called.
860
\begin{lstlisting}
861
inline void orgfxplus_clip(unsigned int x0,
862
                           unsigned int y0,
863
                           unsigned int x1,
864
                           unsigned int y1,
865
                           unsigned int enable);
866
\end{lstlisting}
867
 
868
\subsubsection{orgfxplus\_fill}
869
\textbf{Description:} Draws a rectangle to the current render target with a flat color.
870
\begin{lstlisting}
871
void orgfxplus_fill(unsigned int x0,
872
                    unsigned int y0,
873
                    unsigned int x1,
874
                    unsigned int y1,
875
                    unsigned int color);
876
\end{lstlisting}
877
 
878
\subsubsection{orgfxplus\_line}
879
\textbf{Description:} Draws a line from (x0,y0) to (x1,y1) to the current render target with a flat color.
880
\begin{lstlisting}
881
void orgfxplus_line(unsigned int x0,
882
                    unsigned int y0,
883
                    unsigned int x1,
884
                    unsigned int y1,
885
                    unsigned int color);
886
\end{lstlisting}
887
 
888
\subsubsection{orgfxplus\_triangle}
889
\textbf{Description:} Draws a triangle between the points (x0,y0),(x1,y1) and (x2,y2) and fills it with a color.
890
\begin{lstlisting}
891
void orgfxplus_triangle(unsigned int x0,
892
                        unsigned int y0,
893
                        unsigned int x1,
894
                        unsigned int y1,
895
                        unsigned int x2,
896
                        unsigned int y2,
897
                        unsigned int color);
898
\end{lstlisting}
899
 
900
\subsubsection{orgfxplus\_curve}
901
\textbf{Description:} Draws a quadratic bézier curve from (x0,y0) to (x3,y3) with the control points (x1,y1) and (x2,y2).
902
\begin{lstlisting}
903
void orgfxplus_curve(unsigned int x0,
904
                     unsigned int y0,
905
                     unsigned int x1,
906
                     unsigned int y1,
907
                     unsigned int x2,
908
                     unsigned int y2,
909
                     unsigned int x3,
910
                     unsigned int y3,
911
                     unsigned int color);
912
\end{lstlisting}
913
 
914
\subsubsection{orgfxplus\_draw\_surface}
915
\textbf{Description:} Draws a texture to the current render target.
916
\begin{lstlisting}
917
void orgfxplus_draw_surface(unsigned int x0,
918
                            unsigned int y0,
919
                            unsigned int surface);
920
\end{lstlisting}
921
 
922
\subsubsection{orgfxplus\_draw\_surface\_section}
923
\textbf{Description:} Draws a section of a texture defined by src0, src1 to the current render target.
924
\begin{lstlisting}
925
void orgfxplus_draw_surface_section(unsigned int x0,
926
                                    unsigned int y0,
927
                                    unsigned int srcx0,
928
                                    unsigned int srcy0,
929
                                    unsigned int srcx1,
930
                                    unsigned int srcy1,
931
                                    unsigned int surface);
932
\end{lstlisting}
933
 
934
 
935
\subsubsection{orgfxplus\_colorkey}
936
\textbf{Description:} Sets the colorkey color and enables or disables the use of the colorkey.
937
\begin{lstlisting}
938
void orgfxplus_colorkey(unsigned int colorkey,
939
                        unsigned int enable);
940
\end{lstlisting}
941
 
942
\subsubsection{orgfxplus\_alpha}
943
\textbf{Description:} Sets the alpha value and enables or disables the use of the alpha blending.
944
\begin{lstlisting}
945
void orgfxplus_alpha(unsigned int alpha,
946
                     unsigned int enable);
947
\end{lstlisting}
948
 
949
\subsection{Bitmap Fonts}
950
 
951
\subsubsection{orgfx\_make\_bitmap\_font}
952
Creates a orgfx\_bitmap\_font from a image. glyphSpacing space between two glyphs in the string and spaceWidth is the size of the space character.
953
\begin{lstlisting}
954
orgfx_bitmap_font orgfx_make_bitmap_font(orgfx_tileset* glyphs,
955
                                         unsigned int glyphSpacing,
956
                                         unsigned int spaceWidth);
957
\end{lstlisting}
958
 
959
\subsubsection{orgfx\_put\_text}
960
Puts the text "str" on the screen with the specified "font" on position x0,y0.
961
\begin{lstlisting}
962
void orgfx_put_text(orgfx_font* font,
963
                    unsigned int x0, unsigned int y0,
964
                    const char *str);
965
\end{lstlisting}
966
 
967
\subsection{Vector Fonts}
968
 
969
\subsection{Linux}
970
The current version of the core does not have a Linux driver.
971
 
972
\subsection{Utilities}
973
\subsubsection{Sprite Maker}
974
Since there is no libraries for loading images in the bare metal driver, a utility program is provided that converts an image into a format that can be loaded to the graphics accelerator. The Sprite Maker utility uses SDL and SDL\_image to load images, and supports loading several basic formats, such as bmp, jpg, png, gif etc. The utility supports writing to 8-, 16-, 24- and 32-bits-per-pixel (must match the format set by orgfx\_set\_videomode). The width of the loaded image must be a multiple of 4 pixels (8 bpp), 2 pixels (16 bpp) or 1 bpp (24, 32 bpp) respectively.
975
 
976
The resulting output of the utility is a header file that can be included into your program. This header declares an array, which can be copied to memory and be used as a texture.
977
 
978
This is sample shows how the converter utility can be used:
979
 
980
\begin{lstlisting}
981
./spritemaker image.png [bpp]
982
\end{lstlisting}
983
 
984
If bpp is not provided, the utility uses 8 bits-per-pixel. For an example of how to use the output of the converter, see section \ref{sec:examples}.
985
 
986
\subsubsection{Mesh Maker}
987
Similar to the image loading utility, there is a simple program that converts Maya obj files into a mesh format that is easy to load into the bare metal driver.
988
 
989
\textbf{WRITE MORE}
990
\subsubsection{Fonter}
991
The fonter is a application that converts a ttf file into a .h file that can be included in the project. if no input is given the application tries to open font.ttf and convert it to font.h.
992
 
993
\begin{lstlisting}
994
./fonter [fontname.ttf] [output.h]
995
\end{lstlisting}
996
 
997
\subsubsection{Regger}
998
The regger is a application that keeps track of what register addresses is set in the RTL code and in the drivers.
999
 
1000
\section{Programming examples}
1001
\label{sec:examples}
1002
The following piece of code shows how to use the extended interface for a bare metal implementation on the ORPSoCv2 platform. Bahamut\_cc.png.h is a 186 by 248 pixel image with a pinkish background (rgb code ff00ff, or f81f in 16 bit). The header file is generated by the sprite maker utility at 16 bit color depth.
1003
 
1004
\begin{lstlisting}
1005
#include "orgfx_plus.h"
1006
 
1007
#include "Bahamut_cc.png.h"
1008
 
1009
int main(void)
1010
{
1011
    int i;
1012
 
1013
    // Initialize screen to 640x480-16@60
1014
    // No double buffering
1015
    int screen = orgfxplus_init(640, 480, 16, 0);
1016
 
1017
    // Initialize dragon sprite
1018
    int bahamut_sprite =
1019
        orgfxplus_init_surface(186, 248, Bahamut_cc);
1020
 
1021
    // Activate colorkeying
1022
    orgfxplus_colorkey(0xf81f, 1);
1023
 
1024
    // Clear screen, white color
1025
    orgfxplus_fill(0,0,640,480,0xffff);
1026
    // Draw a few lines with different colors
1027
    orgfxplus_line(200,100,10,10,0xf000);
1028
    orgfxplus_line(200,100,351,31,0x0ff0);
1029
    orgfxplus_line(200,100,121,231,0x00f0);
1030
    orgfxplus_line(200,100,321,231,0xf00f);
1031
 
1032
    // Draw the dragon at different alpha settings
1033
    orgfxplus_alpha(64,1);
1034
    orgfxplus_draw_surface(100, 100, bahamut_sprite);
1035
    orgfxplus_alpha(128,1);
1036
    orgfxplus_draw_surface(120, 102, bahamut_sprite);
1037
    orgfxplus_alpha(255,1);
1038
    orgfxplus_draw_surface(140, 104, bahamut_sprite);
1039
 
1040
    while(1);
1041
}
1042
\end{lstlisting}
1043
 
1044
\end{document}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.