1 /*---------------------------------------------------------------------------* 2 Project: TwlSDK - demos - CTRDG - backup-1 3 File: draw.h 4 5 Copyright 2008 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Date:: $ 14 $Rev: $ 15 $Author: $ 16 *---------------------------------------------------------------------------*/ 17 #if !defined(NITRO_DEMOS_CTRDG_BACKUP_1_DRAW_H_) 18 #define NITRO_DEMOS_CTRDG_BACKUP_1_DRAW_H_ 19 20 21 #include <nitro.h> 22 23 24 25 /* This is a function group used for direct rendering in bitmap mode */ 26 27 28 29 #if defined(__cplusplus) 30 extern "C" 31 { 32 #endif 33 34 35 /********************************************************************/ 36 /* structure */ 37 38 typedef u16 RGB555; 39 40 typedef struct Point 41 { 42 int x; 43 int y; 44 } 45 Point; 46 47 typedef struct Region 48 { 49 Point pos; 50 Point wid; 51 } 52 Region; 53 54 typedef struct Rect 55 { 56 Point o; 57 Point t; 58 } 59 Rect; 60 61 62 /********************************************************************/ 63 /* Constants */ 64 65 #define RGB555_(r, g, b) (RGB555)(((r) << 0) | ((g) << 5) | ((b) << 10)) 66 67 #define RGB555_CLEAR (RGB555)(1 << 15) 68 #define RGB555_BLACK RGB555_(0x00, 0x00, 0x00) 69 #define RGB555_WHITE RGB555_(0x1F, 0x1F, 0x1F) 70 #define RGB555_RED RGB555_(0x1F, 0x00, 0x00) 71 #define RGB555_GREEN RGB555_(0x00, 0xFF, 0x00) 72 #define RGB555_BLUE RGB555_(0x00, 0x00, 0x1F) 73 #define RGB555_PURPLE RGB555_(0x1F, 0x00, 0x1F) 74 #define RGB555_YELLOW RGB555_(0x1F, 0x1F, 0x00) 75 #define RGB555_GREY RGB555_(0x10, 0x10, 0x10) 76 #define RGB555_MILK RGB555_(0x18, 0x18, 0x18) 77 78 extern const u32 sampleCharData[8 * 0x100]; 79 80 81 /********************************************************************/ 82 /* Variables */ 83 84 /* current position (MoveTo, LineTo, ... use) */ 85 extern Point cur_pt; 86 /* current text color (DrawText uses) */ 87 extern RGB555 col_text; 88 /* current ground color (DrawText, TransRect, ... use) */ 89 extern RGB555 col_gnd; 90 /* current clear-frame color (if RGB555_CLEAR, keep prev-frame) */ 91 extern RGB555 col_clear; 92 93 94 /********************************************************************/ 95 /* Functions */ 96 97 void InitDraw(void); 98 void DrawBegin(void); 99 void DrawEnd(void); 100 101 void ClipWindow(int ox, int oy, int tx, int ty, Rect * p_bak); 102 void RestoreClipWindow(const Rect * p_bak); 103 SetTextColor(RGB555 col)104 static inline void SetTextColor(RGB555 col) 105 { 106 col_text = col; 107 } 108 SetGroundColor(RGB555 col)109 static inline void SetGroundColor(RGB555 col) 110 { 111 col_gnd = col; 112 } 113 SetClearColor(RGB555 col)114 static inline void SetClearColor(RGB555 col) 115 { 116 col_clear = col; 117 } 118 GetTextColor(void)119 static inline RGB555 GetTextColor(void) 120 { 121 return col_text; 122 } 123 GetGroundColor(void)124 static inline RGB555 GetGroundColor(void) 125 { 126 return col_gnd; 127 } 128 GetClearColor(void)129 static inline RGB555 GetClearColor(void) 130 { 131 return col_clear; 132 } 133 134 void ClearFrame(RGB555 col); 135 void FillRect(int x, int y, int wx, int wy, RGB555 col); 136 void BlitRect(int x, int y, int wx, int wy, RGB555 * src, int stroke); 137 void TransRect(int x, int y, int wx, int wy, RGB555 * src, int stroke); 138 void DrawLine(int sx, int sy, int tx, int ty, RGB555 col); 139 void DrawCircle(int ox, int oy, int r); 140 MoveTo(int x,int y)141 static inline void MoveTo(int x, int y) 142 { 143 cur_pt.x = x, cur_pt.y = y; 144 } 145 LineTo(int x,int y)146 static inline void LineTo(int x, int y) 147 { 148 DrawLine(cur_pt.x, cur_pt.y, x, y, col_text); 149 MoveTo(x, y); 150 } 151 152 void DrawTextLen(int x, int y, const char *s, int n); 153 154 void DrawText(int x, int y, const char *s, ...); 155 DrawChar(int x,int y,char c)156 static inline void DrawChar(int x, int y, char c) 157 { 158 DrawTextLen(x, y, &c, 1); 159 } 160 161 162 #if defined(__cplusplus) 163 } /* extern "C" */ 164 #endif 165 166 167 #endif /* NITRO_DEMOS_CTRDG_BACKUP_1_DRAW_H_ */ 168