FreeRTOS Tetris
TUM_Draw.h
1 
37 #ifndef __TUM_DRAW_H__
38 #define __TUM_DRAW_H__
39 
52 #include "EmulatorConfig.h"
53 
57 #ifndef WINDOW_TITLE
58 #define WINDOW_TITLE "FreeRTOS Emulator"
59 #endif //WINDOW_TITLE
60 
64 #ifndef SCREEN_WIDTH
65 #define SCREEN_WIDTH 640
66 #endif //SCREEN_WIDTH
67 
71 #ifndef SCREEN_HEIGHT
72 #define SCREEN_HEIGHT 480
73 #endif //SCREEN_HEIGHT
74 
83 #define TUMBlue (unsigned int)(0x0065bd)
84 #define Red (unsigned int)(0xFF0000)
85 #define Green (unsigned int)(0x00FF00)
86 #define Blue (unsigned int)(0x0000FF)
87 #define Yellow (unsigned int)(0xFFFF00)
88 #define Aqua (unsigned int)(0x00FFFF)
89 #define Fuchsia (unsigned int)(0xFF00FF)
90 #define White (unsigned int)(0xFFFFFF)
91 #define Black (unsigned int)(0x000000)
92 #define Gray (unsigned int)(0x808080)
93 #define Grey Gray
94 #define Magenta Fuchsia
95 #define Cyan Aqua
96 #define Lime (unsigned int)(0x00FF00)
97 #define Maroon (unsigned int)(0x800000)
98 #define Navy (unsigned int)(0x000080)
99 #define Olive (unsigned int)(0x808000)
100 #define Purple (unsigned int)(0x800080)
101 #define Silver (unsigned int)(0xC0C0C0)
102 #define Teal (unsigned int)(0x008080)
103 #define Orange (unsigned int)(0xFFA500)
104 #define Pink (unsigned int)(0xFFC0CB)
105 #define Skyblue (unsigned int)(0x87CEEB)
106 
112  SPRITE_SEQUENCE_HORIZONTAL_POS,
113  SPRITE_SEQUENCE_HORIZONTAL_NEG,
114  SPRITE_SEQUENCY_VERTICAL_POS,
115  SPRITE_SEQUENCY_VERTICAL_NEG,
116 };
117 
121 typedef struct coord {
122  signed short x;
123  signed short y;
124 } coord_t;
125 
130 typedef void *image_handle_t;
131 
141 typedef void *animation_handle_t;
142 
150 typedef void *sequence_handle_t;
151 
157 char *tumGetErrorMessage(void);
158 
166 int tumDrawInit(char *path);
167 
173 int tumDrawBindThread(void);
174 
180 void tumDrawExit(void);
181 
201 int tumDrawUpdateScreen(void);
202 
209 int tumDrawClear(unsigned int colour);
210 
211 /*
212  * @brief Copies a screenshot of the current frame to the next frame
213  *
214  * Experimental, performance can not be guarenteed.
215  */
216 void tumDrawDuplicateBuffer(void);
217 
228 int tumDrawEllipse(signed short x, signed short y, signed short rx,
229  signed short ry, unsigned int colour);
230 
245 int tumDrawArc(signed short x, signed short y, signed short radius,
246  signed short start, signed short end, unsigned int colour);
247 
260 int tumDrawText(char *str, signed short x, signed short y, unsigned int colour);
261 
270 int tumGetTextSize(char *str, int *width, int *height);
271 
282 int tumDrawBox(signed short x, signed short y, signed short w, signed short h,
283  unsigned int colour);
284 
295 int tumDrawFilledBox(signed short x, signed short y, signed short w,
296  signed short h, unsigned int colour);
297 
307 int tumDrawCircle(signed short x, signed short y, signed short radius,
308  unsigned int colour);
309 
321 int tumDrawLine(signed short x1, signed short y1, signed short x2,
322  signed short y2, unsigned char thickness, unsigned int colour);
323 
336 int tumDrawPoly(coord_t *points, int n, unsigned int colour);
337 
345 int tumDrawTriangle(coord_t *points, unsigned int colour);
346 
359 image_handle_t tumDrawLoadImage(char *filename);
360 
372 image_handle_t tumDrawLoadScaledImage(char *filename, float scale);
373 
381 
391 int tumDrawSetLoadedImageScale(image_handle_t img, float scale);
392 
401 
409 
417 
427 int tumDrawGetLoadedImageSize(image_handle_t img, int *w, int *h);
428 
437 int tumDrawLoadedImage(image_handle_t img, signed short x, signed short y);
438 
447 int tumDrawImage(char *filename, signed short x, signed short y);
448 
457 int tumGetImageSize(char *filename, int *w, int *h);
458 
468 int tumDrawScaledImage(char *filename, signed short x, signed short y,
469  float scale);
470 
483 int tumDrawArrow(signed short x1, signed short y1, signed short x2,
484  signed short y2, signed short head_length,
485  unsigned char thickness, unsigned int colour);
486 
497  unsigned sprite_cols, unsigned sprite_rows);
498 
518 int tumDrawAnimationAddSequence(animation_handle_t animation, char *name,
519  unsigned start_row, unsigned start_col,
520  enum sprite_sequence_direction sprite_step_direction,
521  unsigned frames);
534  char *sequence_name, unsigned frame_period_ms);
535 
554 int tumDrawAnimationDrawFrame(sequence_handle_t sequence, unsigned ms_timestep,
555  int x, int y);
556 
563 int tumDrawSetGlobalXOffset(int offset);
564 
571 int tumDrawSetGlobalYOffset(int offset);
572 
579 int tumDrawGetGlobalXOffset(int *offset);
580 
587 int tumDrawGetGlobalYOffset(int *offset);
588 
590 #endif
tumDrawGetLoadedImageSize
int tumDrawGetLoadedImageSize(image_handle_t img, int *w, int *h)
Retrieves bother the image's width and height when drawn to screen, ie. after scaling.
Definition: TUM_Draw.c:1500
tumDrawAnimationSequenceInstantiate
sequence_handle_t tumDrawAnimationSequenceInstantiate(animation_handle_t animation, char *sequence_name, unsigned frame_period_ms)
Creates an instance of an animation from a loaded animation object and a sequence name of a sequence ...
Definition: TUM_Draw.c:573
tumDrawAnimationDrawFrame
int tumDrawAnimationDrawFrame(sequence_handle_t sequence, unsigned ms_timestep, int x, int y)
Draws the target intantiated animation sequence at a given location.
Definition: TUM_Draw.c:1580
tumGetErrorMessage
char * tumGetErrorMessage(void)
Returns a string error message from the TUM Draw back end.
Definition: TUM_Draw.c:1023
coord::y
signed short y
Definition: TUM_Draw.h:123
coord_t
struct coord coord_t
Holds a pixel co-ordinate.
tumDrawLoadImage
image_handle_t tumDrawLoadImage(char *filename)
Loads an image file from disk, loaded image file can be closed using tumDrawFreeLoadedImage()
Definition: TUM_Draw.c:1426
tumDrawFreeLoadedImage
int tumDrawFreeLoadedImage(image_handle_t *img)
Closes a loaded image and frees all memory used by the image structure.
Definition: TUM_Draw.c:1431
tumDrawSetGlobalXOffset
int tumDrawSetGlobalXOffset(int offset)
Sets the global draw position offset's X axis value.
Definition: TUM_Draw.c:1659
tumDrawGetLoadedImageWidth
int tumDrawGetLoadedImageWidth(image_handle_t img)
Retrieves the image's width when drawn to screen, ie. after scaling.
Definition: TUM_Draw.c:1482
tumDrawBindThread
int tumDrawBindThread(void)
Transfers the drawing ability to the calling thread/taskd.
Definition: TUM_Draw.c:1108
tumDrawAnimationCreate
animation_handle_t tumDrawAnimationCreate(image_handle_t spritesheet, unsigned sprite_cols, unsigned sprite_rows)
Creates an animation object with an attached spritesheet that must be loaded prior as an image.
Definition: TUM_Draw.c:470
animation_handle_t
void * animation_handle_t
Handle used to reference a loaded animation spritesheet, an invalid spritesheet will have a NULL hand...
Definition: TUM_Draw.h:141
tumDrawEllipse
int tumDrawEllipse(signed short x, signed short y, signed short rx, signed short ry, unsigned int colour)
Draws an ellipse on the screen.
Definition: TUM_Draw.c:1208
tumDrawGetGlobalXOffset
int tumDrawGetGlobalXOffset(int *offset)
Retrieves a copy of the current global X axis drawing offset.
Definition: TUM_Draw.c:1689
coord::x
signed short x
Definition: TUM_Draw.h:122
tumGetImageSize
int tumGetImageSize(char *filename, int *w, int *h)
Gets the width and height of an image.
Definition: TUM_Draw.c:1535
tumDrawLoadedImage
int tumDrawLoadedImage(image_handle_t img, signed short x, signed short y)
Draws a loaded image to the screen.
Definition: TUM_Draw.c:1446
tumDrawBox
int tumDrawBox(signed short x, signed short y, signed short w, signed short h, unsigned int colour)
Draws a filled box on the screen.
Definition: TUM_Draw.c:1251
tumGetTextSize
int tumGetTextSize(char *str, int *width, int *height)
Finds the width and height of a strings bounding box.
Definition: TUM_Draw.c:1200
tumDrawInit
int tumDrawInit(char *path)
Initializes the TUM Draw backend.
Definition: TUM_Draw.c:1028
sequence_handle_t
void * sequence_handle_t
Returns an instance of an animation;.
Definition: TUM_Draw.h:150
tumDrawFilledBox
int tumDrawFilledBox(signed short x, signed short y, signed short w, signed short h, unsigned int colour)
Draws an unfilled box on the screen.
Definition: TUM_Draw.c:1237
tumDrawUpdateScreen
int tumDrawUpdateScreen(void)
Executes the queued draw jobs.
Definition: TUM_Draw.c:974
tumDrawLine
int tumDrawLine(signed short x1, signed short y1, signed short x2, signed short y2, unsigned char thickness, unsigned int colour)
Draws a line on the screen.
Definition: TUM_Draw.c:1309
tumDrawPoly
int tumDrawPoly(coord_t *points, int n, unsigned int colour)
Draws a polygon on the screen.
Definition: TUM_Draw.c:1324
tumDrawExit
void tumDrawExit(void)
Exits the TUM Draw backend.
Definition: TUM_Draw.c:1160
spritesheet
Definition: TUM_Draw.c:106
tumDrawArc
int tumDrawArc(signed short x, signed short y, signed short radius, signed short start, signed short end, unsigned int colour)
Draws an arc on the screen.
Definition: TUM_Draw.c:1222
tumDrawCircle
int tumDrawCircle(signed short x, signed short y, signed short radius, unsigned int colour)
Draws a filled circle on the screen.
Definition: TUM_Draw.c:1296
tumDrawSetGlobalYOffset
int tumDrawSetGlobalYOffset(int offset)
Sets the global draw position offset's Y axis value.
Definition: TUM_Draw.c:1674
sprite_sequence_direction
sprite_sequence_direction
Defines the direction that the animation appears on the spritesheet.
Definition: TUM_Draw.h:111
tumDrawTriangle
int tumDrawTriangle(coord_t *points, unsigned int colour)
Draws a triangle on the screen.
Definition: TUM_Draw.c:1342
tumDrawClear
int tumDrawClear(unsigned int colour)
Sets the screen to a solid colour.
Definition: TUM_Draw.c:1280
tumDrawImage
int tumDrawImage(char *filename, signed short x, signed short y)
Draws an image on the screen.
Definition: TUM_Draw.c:1516
tumDrawSetLoadedImageScale
int tumDrawSetLoadedImageScale(image_handle_t img, float scale)
Scales a loaded image, the scale is a value where, for example, 1.0 represents the original image's s...
Definition: TUM_Draw.c:1462
tumDrawGetLoadedImageHeight
int tumDrawGetLoadedImageHeight(image_handle_t img)
Retrieves the image's height when drawn to screen, ie. after scaling.
Definition: TUM_Draw.c:1491
tumDrawLoadScaledImage
image_handle_t tumDrawLoadScaledImage(char *filename, float scale)
Loads an image from disk and scales the image, loaded image file can be closed using tumDrawFreeLoade...
Definition: TUM_Draw.c:1359
coord
Holds a pixel co-ordinate.
Definition: TUM_Draw.h:121
tumDrawGetLoadedImageScale
float tumDrawGetLoadedImageScale(image_handle_t img)
Retrieves the current scaling factor of an image.
Definition: TUM_Draw.c:1473
image_handle_t
void * image_handle_t
Handle used to reference loaded images, an invalid image will have a NULL handle.
Definition: TUM_Draw.h:130
tumDrawText
int tumDrawText(char *str, signed short x, signed short y, unsigned int colour)
Prints a string to the screen.
Definition: TUM_Draw.c:1176
tumDrawGetGlobalYOffset
int tumDrawGetGlobalYOffset(int *offset)
Retrieves a copy of the current global X axis drawing offset.
Definition: TUM_Draw.c:1704
tumDrawArrow
int tumDrawArrow(signed short x1, signed short y1, signed short x2, signed short y2, signed short head_length, unsigned char thickness, unsigned int colour)
Draws an arrow on the screen.
Definition: TUM_Draw.c:1563
tumDrawAnimationAddSequence
int tumDrawAnimationAddSequence(animation_handle_t animation, char *name, unsigned start_row, unsigned start_col, enum sprite_sequence_direction sprite_step_direction, unsigned frames)
Adds an animation sequence to a previously created animation.
Definition: TUM_Draw.c:519
tumDrawScaledImage
int tumDrawScaledImage(char *filename, signed short x, signed short y, float scale)
Draws a scaled image on the screen.
Definition: TUM_Draw.c:1542
EmulatorConfig.h
File containing some configuration for the FreeRTOS Emulator.