Drawing_Draw_CircleとDrawing_Fill_Circleを追加した。
全ての描画系低レベル関数に、31ビット目が1の時は処理を行わないように(計算結果がマイナスだった場合の誤動作を防ぐため)した。
また、例外や致命的エラー発生時の画面表示にも対応した。
前回作成した直線描画関数には、決定的なミスがあったので、(多分)修正された。
シートの実装はいつごろできるのやら…。
@@ -59,6 +59,12 @@ | ||
59 | 59 | void Drawing08_Fill_Rectangle(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1) |
60 | 60 | { |
61 | 61 | uint x, y; |
62 | + | |
63 | +//if negative position | |
64 | + if((x0 & 0x80000000) != 0 || (y0 & 0x80000000) != 0 || (x1 & 0x80000000) != 0 || (y1 & 0x80000000) != 0){ | |
65 | + return; | |
66 | + } | |
67 | + | |
62 | 68 | c = RGB_32_To_08(c); |
63 | 69 | for(y = y0; y <= y1; y++){ |
64 | 70 | for(x = x0; x <= x1; x++){ |
@@ -74,6 +80,11 @@ | ||
74 | 80 | uchar d; |
75 | 81 | uchar *p; |
76 | 82 | |
83 | +//if negative position | |
84 | + if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){ | |
85 | + return; | |
86 | + } | |
87 | + | |
77 | 88 | for (i = 0; i < 16; i++) { |
78 | 89 | p = (uchar *)(vram + (y + i) * xsize + x); |
79 | 90 | d = font[i]; |
@@ -91,6 +102,11 @@ | ||
91 | 102 | |
92 | 103 | void Drawing08_Put_String(void *vram, uint xsize, uint x, uint y, uint c, const uchar s[]) |
93 | 104 | { |
105 | +//if negative position | |
106 | + if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){ | |
107 | + return; | |
108 | + } | |
109 | + | |
94 | 110 | c = RGB_32_To_08(c); |
95 | 111 | for(; *s != 0x00; s++){ |
96 | 112 | if(x > xsize - 8){ |
@@ -104,77 +120,11 @@ | ||
104 | 120 | |
105 | 121 | void Drawing08_Draw_Point(void *vram, uint xsize, uint x, uint y, uint c) |
106 | 122 | { |
107 | - ((uchar *)vram)[y * xsize + x] = RGB_32_To_08_xy(c, x, y); | |
108 | - return; | |
109 | -} | |
110 | - | |
111 | -void Drawing08_Draw_Line_PQ(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1) | |
112 | -{ | |
113 | - uint lx; | |
114 | - uint i, j; | |
115 | - uint a; | |
116 | - uint c8; | |
117 | - | |
118 | - c8 = RGB_32_To_08(c); | |
119 | - | |
120 | - if(x1 < x0){ | |
121 | - lx = x0; | |
122 | - x0 = x1; | |
123 | - x1 = lx; | |
124 | - | |
125 | - lx = y0; | |
126 | - y0 = y1; | |
127 | - y1 = lx; | |
128 | - } else if(x1 == x0){ | |
129 | - if(y0 <= y1){ | |
130 | - for(i = 0; i < y1 - y0 + 1; i++){ | |
131 | - ((uchar *)vram)[(y0 + i) * xsize + x0] = c8; | |
132 | - } | |
133 | - } else{ | |
134 | - for(i = 0; i < y0 - y1 + 1; i++){ | |
135 | - ((uchar *)vram)[(y0 - i) * xsize + x0] = c8; | |
136 | - } | |
137 | - } | |
123 | +//if negative position | |
124 | + if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){ | |
138 | 125 | return; |
139 | 126 | } |
140 | 127 | |
141 | - lx = x1 - x0; | |
142 | - if(lx == 0){ | |
143 | - lx = 1; | |
144 | - } | |
145 | - | |
146 | - if(y0 <= y1){ //+a | |
147 | - a = ((y1 - y0) << 10) / lx; | |
148 | - for(i = 0; i < lx; i++){ | |
149 | - ((uchar *)vram)[(y0 + ((i * a) >> 10)) * xsize + (x0 + i)] = c8; | |
150 | - for(j = ((i * a) >> 10) + 1; j < ((i + 1) * a) >> 10; j++){ | |
151 | - ((uchar *)vram)[(y0 + j) * xsize + (x0 + i)] = c8; | |
152 | - } | |
153 | - } | |
154 | - for(j = ((i * a) >> 10) + 1; j < ((i + 1) * a) >> 10; j++){ | |
155 | - ((uchar *)vram)[(y0 + j) * xsize + (x0 + i)] = c8; | |
156 | - if(y1 >= y0 + j){ | |
157 | - break; | |
158 | - } | |
159 | - } | |
160 | - } else{ //-a | |
161 | - a = ((y0 - y1) << 10) / lx; | |
162 | - for(i = 0; i < lx; i++){ | |
163 | - ((uchar *)vram)[(y0 - ((i * a) >> 10)) * xsize + (x0 + i)] = c8; | |
164 | - for(j = ((i * a) >> 10) + 1; j < ((i + 1) * a) >> 10; j++){ | |
165 | - ((uchar *)vram)[(y0 - j) * xsize + (x0 + i)] = c8; | |
166 | - } | |
167 | - } | |
168 | - for(j = ((i * a) >> 10) + 1; j < ((i + 1) * a) >> 10; j++){ | |
169 | - ((uchar *)vram)[(y0 - j) * xsize + (x0 + i)] = c8; | |
170 | - if(y1 <= y0 - j){ | |
171 | - break; | |
172 | - } | |
173 | - } | |
174 | - } | |
175 | - | |
176 | - ((uchar *)vram)[y1 * xsize + x1] = c8; | |
177 | - | |
128 | + ((uchar *)vram)[y * xsize + x] = RGB_32_To_08_xy(c, x, y); | |
178 | 129 | return; |
179 | 130 | } |
180 | - |
@@ -43,7 +43,10 @@ | ||
43 | 43 | ctrl->vram = VGA_VRAM_ADR; |
44 | 44 | |
45 | 45 | Drawing08_Initialise_Palette(); |
46 | + Error_Set_Enable_Display_TextMode(false); | |
47 | + Error_Set_Enable_Display_GraphicMode(true, ctrl->vram, ctrl->xsize, ctrl->ysize >> 4); | |
46 | 48 | |
49 | + | |
47 | 50 | //次に、VBEのBIOS情報を得る。 |
48 | 51 | |
49 | 52 | callbiosctrl->CallBIOS_Task->tss->eax = 0x4f00; |
@@ -264,6 +267,8 @@ | ||
264 | 267 | } |
265 | 268 | debug("\n"); |
266 | 269 | #endif |
270 | + Initialise_Drawing(); | |
271 | + Error_Set_Enable_Display_GraphicMode(true, ctrl->vram, ctrl->xsize, ctrl->ysize >> 4); | |
267 | 272 | return 0; |
268 | 273 | } |
269 | 274 |
@@ -3,7 +3,13 @@ | ||
3 | 3 | |
4 | 4 | bool Error_Output_Enable_SerialPort = false; |
5 | 5 | bool Error_Output_Enable_Display_TextMode = false; |
6 | +uint Error_Output_Enable_Display_GraphicMode = false; | |
6 | 7 | |
8 | +void *Error_Output_Display_GraphicMode_VRAM = 0; | |
9 | +uint Error_Output_Display_GraphicMode_Lines = 0; | |
10 | +uint Error_Output_Display_GraphicMode_ResolutionX = 0; | |
11 | +uint Error_Output_Display_GraphicMode_UsedLines = 0; | |
12 | + | |
7 | 13 | uchar *cpu_exceptions[0x20] = { |
8 | 14 | "Divided by zero.", |
9 | 15 | "Reserved.", |
@@ -66,7 +72,7 @@ | ||
66 | 72 | va_args = &error_no + 1; |
67 | 73 | |
68 | 74 | if(error_no <= ERROR_CPU_EXCEPTIONS){ |
69 | - Error_Put_String("\nException 0x%02X:%s\n", error_no, cpu_exceptions[error_no]); | |
75 | + Error_Put_String("Exception 0x%02X:%s", error_no, cpu_exceptions[error_no]); | |
70 | 76 | if(error_no == ERROR_CPU_EXCEPTION_00){ |
71 | 77 | Error_CPU_Exception_Put_Registers_Without_ErrorCode((uint *)*va_args); |
72 | 78 | } else if(error_no == ERROR_CPU_EXCEPTION_01){ |
@@ -134,20 +140,20 @@ | ||
134 | 140 | } |
135 | 141 | Error_Abort(); |
136 | 142 | } else{ |
137 | - Error_Put_String("\n[0x%08X]Error:0x%08X ", *retaddr, error_no); | |
143 | + Error_Put_String("[0x%08X]Error:0x%08X ", *retaddr, error_no); | |
138 | 144 | if(error_no == ERROR_NO_MORE_SEGMENT){ |
139 | - Error_Put_String("No More Segment Descriptor(requested at 0x%08X).\n", *va_args); | |
145 | + Error_Put_String("No More Segment Descriptor(requested at 0x%08X).", *va_args); | |
140 | 146 | Error_Abort(); |
141 | 147 | } else if(error_no == ERROR_NOT_ENOUGH_FREE_MEMORY){ |
142 | - Error_Put_String("No More Free Memory(Control:0x%08X Request Size:0x%08X).\n", *va_args, *(va_args + 1)); | |
148 | + Error_Put_String("No More Free Memory(Control:0x%08X Request Size:0x%08X).", *va_args, *(va_args + 1)); | |
143 | 149 | } else if(error_no == ERROR_MEMORY_FREE_RANGE_OVERLAPPED){ |
144 | - Error_Put_String("Memory Free Range Overlapped(Control:0x%08X TagIndex:%u).\n", *va_args, *(va_args + 1)); | |
150 | + Error_Put_String("Memory Free Range Overlapped(Control:0x%08X TagIndex:%u).", *va_args, *(va_args + 1)); | |
145 | 151 | } else if(error_no == ERROR_NO_MORE_FREE_TAG){ |
146 | - Error_Put_String("No More Free Tag(Control:0x%08X).\n", *va_args); | |
152 | + Error_Put_String("No More Free Tag(Control:0x%08X).", *va_args); | |
147 | 153 | } else if(error_no == ERROR_INVALID_FREE_MEMORY_INDEX){ |
148 | - Error_Put_String("Invalid Free Memory Index(Control:0x%08X TagIndex:%u).\n", *va_args, *(va_args + 1)); | |
154 | + Error_Put_String("Invalid Free Memory Index(Control:0x%08X TagIndex:%u).", *va_args, *(va_args + 1)); | |
149 | 155 | } else{ |
150 | - Error_Put_String("Unknown Error Number.\n"); | |
156 | + Error_Put_String("Unknown Error Number."); | |
151 | 157 | Error_Abort(); |
152 | 158 | } |
153 | 159 | } |
@@ -174,6 +180,16 @@ | ||
174 | 180 | return; |
175 | 181 | } |
176 | 182 | |
183 | +void Error_Set_Enable_Display_GraphicMode(bool gdisp, void *vram, uint xsize, uint lines) | |
184 | +{ | |
185 | + Error_Output_Enable_Display_GraphicMode = gdisp; | |
186 | + Error_Output_Display_GraphicMode_VRAM = vram; | |
187 | + Error_Output_Display_GraphicMode_ResolutionX = xsize; | |
188 | + Error_Output_Display_GraphicMode_Lines = lines; | |
189 | + Error_Output_Display_GraphicMode_UsedLines = 0; | |
190 | + return; | |
191 | +} | |
192 | + | |
177 | 193 | int Error_Put_String(const uchar format[], ...) |
178 | 194 | { |
179 | 195 | int i; |
@@ -180,11 +196,20 @@ | ||
180 | 196 | uchar s[256]; |
181 | 197 | |
182 | 198 | i = vsnprintf(s, sizeof(s), format, (uint *)(&format + 1)); |
199 | + if(Error_Output_Enable_Display_GraphicMode){ | |
200 | + if(Error_Output_Display_GraphicMode_Lines > Error_Output_Display_GraphicMode_UsedLines){ | |
201 | + Drawing_Fill_Rectangle(Error_Output_Display_GraphicMode_VRAM, Error_Output_Display_GraphicMode_ResolutionX, 0xc6c6c6, 0, Error_Output_Display_GraphicMode_UsedLines << 4, Error_Output_Display_GraphicMode_ResolutionX - 1, (Error_Output_Display_GraphicMode_UsedLines << 4) + 16 - 1); | |
202 | + Drawing_Put_String(Error_Output_Display_GraphicMode_VRAM, Error_Output_Display_GraphicMode_ResolutionX, 0, Error_Output_Display_GraphicMode_UsedLines << 4, 0x000000, s); | |
203 | + Error_Output_Display_GraphicMode_UsedLines++; | |
204 | + } | |
205 | + } | |
183 | 206 | if(Error_Output_Enable_SerialPort){ |
184 | 207 | SerialPort_Send(s); |
208 | + SerialPort_Send("\n"); | |
185 | 209 | } |
186 | 210 | if(Error_Output_Enable_Display_TextMode){ |
187 | 211 | TextMode_Put_String(s, white); |
212 | + TextMode_Put_String("\n", white); | |
188 | 213 | } |
189 | 214 | return i; |
190 | 215 | } |
@@ -193,28 +218,28 @@ | ||
193 | 218 | { |
194 | 219 | uint i; |
195 | 220 | |
196 | - Error_Put_String("#PUSHAD by _asm_CPU_ExceptionHandler\n"); | |
221 | + Error_Put_String("#PUSHAD by _asm_CPU_ExceptionHandler"); | |
197 | 222 | for(i = 0; i < 4; i++){ |
198 | - Error_Put_String("%s:0x%08X %s:0x%08X\n", cpu_exception_infos[i << 1], esp[i << 1], cpu_exception_infos[(i << 1) + 1], esp[(i << 1) + 1]); | |
223 | + Error_Put_String("%s:0x%08X %s:0x%08X", cpu_exception_infos[i << 1], esp[i << 1], cpu_exception_infos[(i << 1) + 1], esp[(i << 1) + 1]); | |
199 | 224 | } |
200 | 225 | |
201 | - Error_Put_String("#PUSH by _asm_CPU_ExceptionHandler\n"); | |
226 | + Error_Put_String("#PUSH by _asm_CPU_ExceptionHandler"); | |
202 | 227 | for(; i < 5; i++){ |
203 | - Error_Put_String("%s:0x%08X %s:0x%08X\n", cpu_exception_infos[i << 1], esp[i << 1], cpu_exception_infos[(i << 1) + 1], esp[(i << 1) + 1]); | |
228 | + Error_Put_String("%s:0x%08X %s:0x%08X", cpu_exception_infos[i << 1], esp[i << 1], cpu_exception_infos[(i << 1) + 1], esp[(i << 1) + 1]); | |
204 | 229 | } |
205 | 230 | |
206 | 231 | Error_Put_String("#PUSH by CPU\n"); |
207 | 232 | for(; i < 8; i++){ |
208 | - Error_Put_String("%s:0x%08X %s:0x%08X\n", cpu_exception_infos[i << 1], esp[i << 1], cpu_exception_infos[(i << 1) + 1], esp[(i << 1) + 1]); | |
233 | + Error_Put_String("%s:0x%08X %s:0x%08X", cpu_exception_infos[i << 1], esp[i << 1], cpu_exception_infos[(i << 1) + 1], esp[(i << 1) + 1]); | |
209 | 234 | } |
210 | 235 | |
211 | - Error_Put_String("#Control Registers\n"); | |
212 | - Error_Put_String("CR0 = 0x%08X\n", Load_CR0()); | |
213 | - Error_Put_String("CR2 = 0x%08X\n", Load_CR2()); | |
214 | - Error_Put_String("CR3 = 0x%08X\n", Load_CR3()); | |
215 | - Error_Put_String("CR4 = 0x%08X\n", Load_CR4()); | |
236 | + Error_Put_String("#Control Registers"); | |
237 | + Error_Put_String("CR0 = 0x%08X", Load_CR0()); | |
238 | + Error_Put_String("CR2 = 0x%08X", Load_CR2()); | |
239 | + Error_Put_String("CR3 = 0x%08X", Load_CR3()); | |
240 | + Error_Put_String("CR4 = 0x%08X", Load_CR4()); | |
216 | 241 | |
217 | - Error_Put_String("Opcode[0x%X]:0x%X\n", esp[0x0b], ((uchar *)(esp[0x0b]))[0]); | |
242 | + Error_Put_String("Opcode[0x%X]:0x%X", esp[0x0b], ((uchar *)(esp[0x0b]))[0]); | |
218 | 243 | return; |
219 | 244 | } |
220 | 245 |
@@ -222,26 +247,26 @@ | ||
222 | 247 | { |
223 | 248 | uint i; |
224 | 249 | |
225 | - Error_Put_String("#PUSHAD by _asm_CPU_ExceptionHandler\n"); | |
250 | + Error_Put_String("#PUSHAD by _asm_CPU_ExceptionHandler"); | |
226 | 251 | for(i = 0; i < 4; i++){ |
227 | - Error_Put_String("%s:0x%08X %s:0x%08X\n", cpu_exception_infos[i << 1], esp[i << 1], cpu_exception_infos[(i << 1) + 1], esp[(i << 1) + 1]); | |
252 | + Error_Put_String("%s:0x%08X %s:0x%08X", cpu_exception_infos[i << 1], esp[i << 1], cpu_exception_infos[(i << 1) + 1], esp[(i << 1) + 1]); | |
228 | 253 | } |
229 | 254 | |
230 | - Error_Put_String("#PUSH by _asm_CPU_ExceptionHandler\n"); | |
255 | + Error_Put_String("#PUSH by _asm_CPU_ExceptionHandler"); | |
231 | 256 | for(; i < 5; i++){ |
232 | - Error_Put_String("%s:0x%08X %s:0x%08X\n", cpu_exception_infos[i << 1], esp[i << 1], cpu_exception_infos[(i << 1) + 1], esp[(i << 1) + 1]); | |
257 | + Error_Put_String("%s:0x%08X %s:0x%08X", cpu_exception_infos[i << 1], esp[i << 1], cpu_exception_infos[(i << 1) + 1], esp[(i << 1) + 1]); | |
233 | 258 | } |
234 | 259 | |
235 | - Error_Put_String("#PUSH by CPU\n"); | |
236 | - Error_Put_String("%s:0x%08X\n", cpu_exception_infos[(i << 1) + 1], esp[i << 1]); | |
260 | + Error_Put_String("#PUSH by CPU"); | |
261 | + Error_Put_String("%s:0x%08X", cpu_exception_infos[(i << 1) + 1], esp[i << 1]); | |
237 | 262 | i++; |
238 | 263 | for(; i < 8; i++){ |
239 | - Error_Put_String("%s:0x%08X %s:0x%08X\n", cpu_exception_infos[i << 1], esp[(i << 1) - 1], cpu_exception_infos[(i << 1) + 1], esp[i << 1]); | |
264 | + Error_Put_String("%s:0x%08X %s:0x%08X", cpu_exception_infos[i << 1], esp[(i << 1) - 1], cpu_exception_infos[(i << 1) + 1], esp[i << 1]); | |
240 | 265 | } |
241 | 266 | |
242 | - Error_Put_String("#Control Registers\n"); | |
243 | - Error_Put_String("CR0 = 0x%08X\n", Load_CR0()); | |
244 | - Error_Put_String("CR2 = 0x%08X\n", Load_CR2()); | |
245 | - Error_Put_String("CR3 = 0x%08X\n", Load_CR3()); | |
267 | + Error_Put_String("#Control Registers"); | |
268 | + Error_Put_String("CR0 = 0x%08X", Load_CR0()); | |
269 | + Error_Put_String("CR2 = 0x%08X", Load_CR2()); | |
270 | + Error_Put_String("CR3 = 0x%08X", Load_CR3()); | |
246 | 271 | return; |
247 | 272 | } |
@@ -4,7 +4,6 @@ | ||
4 | 4 | void (*Drawing_Fill_Rectangle)(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1); |
5 | 5 | void (*Drawing_Put_String)(void *vram, uint xsize, uint x, uint y, uint c, const uchar *s); |
6 | 6 | void (*Drawing_Draw_Point)(void *vram, uint xsize, uint x, uint y, uint c); |
7 | -void (*Drawing_Draw_Line_PQ)(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1); | |
8 | 7 | //Drawingに含まれる低レベル描画関数は全て、座標は符号なし整数であり、vramの左上の座標を原点(0, 0)として、xは右方向、yは下方向に増加する。 |
9 | 8 | //また、二点の座標をとる関数は、(基本的に)全て引数左側がx成分の小さい側(原点に近い)でなければならない。 |
10 | 9 | //高レベル描画関数では、それらを上手くラップすべきである。 |
@@ -19,23 +18,19 @@ | ||
19 | 18 | Drawing_Fill_Rectangle = Drawing08_Fill_Rectangle; |
20 | 19 | Drawing_Put_String = Drawing08_Put_String; |
21 | 20 | Drawing_Draw_Point = Drawing08_Draw_Point; |
22 | - Drawing_Draw_Line_PQ = Drawing08_Draw_Line_PQ; | |
23 | 21 | Drawing08_Initialise_Palette(); |
24 | 22 | } else if(dispctrl->bpp == 16){ |
25 | 23 | Drawing_Fill_Rectangle = Drawing16_Fill_Rectangle; |
26 | 24 | Drawing_Put_String = Drawing16_Put_String; |
27 | 25 | Drawing_Draw_Point = Drawing16_Draw_Point; |
28 | - Drawing_Draw_Line_PQ = Drawing16_Draw_Line_PQ; | |
29 | 26 | } else if(dispctrl->bpp == 32){ |
30 | 27 | Drawing_Fill_Rectangle = Drawing32_Fill_Rectangle; |
31 | 28 | Drawing_Put_String = Drawing32_Put_String; |
32 | 29 | Drawing_Draw_Point = Drawing32_Draw_Point; |
33 | - Drawing_Draw_Line_PQ = Drawing32_Draw_Line_PQ; | |
34 | 30 | } else{ |
35 | 31 | Drawing_Fill_Rectangle = Drawing_Invalid_Fill_Rectangle; |
36 | 32 | Drawing_Put_String = Drawing_Invalid_Put_String; |
37 | 33 | Drawing_Draw_Point = Drawing_Invalid_Draw_Point; |
38 | - Drawing_Draw_Line_PQ = Drawing_Invalid_Draw_Line_PQ; | |
39 | 34 | #ifdef CHNOSPROJECT_DEBUG_DRAWING |
40 | 35 | debug("Initalise_Drawing:Not implemented %d bpp.\n", dispctrl->bpp); |
41 | 36 | #endif |
@@ -67,14 +62,6 @@ | ||
67 | 62 | return; |
68 | 63 | } |
69 | 64 | |
70 | -void Drawing_Invalid_Draw_Line_PQ(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1) | |
71 | -{ | |
72 | - #ifdef CHNOSPROJECT_DEBUG_DRAWING | |
73 | - debug("Drawing_Invalid_Draw_Line_PQ:[0x%X] xsize:%d color:0x%X\nDrawing_Invalid_Draw_Line_PQ: (%d, %d) -> (%d, %d)\n", vram, xsize, c, x0, y0, x1, y1); | |
74 | - #endif | |
75 | - return; | |
76 | -} | |
77 | - | |
78 | 65 | uchar RGB_32_To_08(uint c32) |
79 | 66 | { |
80 | 67 | uchar c8; |
@@ -137,3 +124,100 @@ | ||
137 | 124 | return c16; |
138 | 125 | } |
139 | 126 | |
127 | +void Drawing_Draw_Line_PQ(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1) | |
128 | +{ | |
129 | + uint lx; | |
130 | + uint i; | |
131 | + uint a; | |
132 | + | |
133 | +//if negative position | |
134 | + if((x0 & 0x80000000) != 0 || (y0 & 0x80000000) != 0 || (x1 & 0x80000000) != 0 || (y1 & 0x80000000) != 0){ | |
135 | + return; | |
136 | + } | |
137 | + | |
138 | + if(x1 < x0){ | |
139 | + lx = x0; | |
140 | + x0 = x1; | |
141 | + x1 = lx; | |
142 | + | |
143 | + lx = y0; | |
144 | + y0 = y1; | |
145 | + y1 = lx; | |
146 | + } else if(x1 == x0){ | |
147 | + if(y0 <= y1){ | |
148 | + for(i = 0; i < y1 - y0 + 1; i++){ | |
149 | + Drawing_Draw_Point(vram, xsize, x0, y0 + i, c); | |
150 | + } | |
151 | + } else{ | |
152 | + for(i = 0; i < y0 - y1 + 1; i++){ | |
153 | + Drawing_Draw_Point(vram, xsize, x0, y1 + i, c); | |
154 | + } | |
155 | + } | |
156 | + return; | |
157 | + } | |
158 | + | |
159 | + lx = x1 - x0; | |
160 | + if(lx == 0){ | |
161 | + lx = 1; | |
162 | + } | |
163 | + | |
164 | + if(y0 <= y1){ //+a | |
165 | + a = ((y1 - y0) << 10) / lx; | |
166 | + for(i = 0; i < lx; i++){ | |
167 | + Drawing_Draw_Line_PQ(vram, xsize, c, x0 + i, y0 + ((i * a) >> 10), x0 + i, y0 + (((i + 1) * a) >> 10)); | |
168 | + } | |
169 | + } else{ //-a | |
170 | + a = ((y0 - y1) << 10) / lx; | |
171 | + for(i = 0; i < lx; i++){ | |
172 | + Drawing_Draw_Line_PQ(vram, xsize, c, x0 + i, y0 - ((i * a) >> 10), x0 + i, y0 - (((i + 1) * a) >> 10)); | |
173 | + } | |
174 | + } | |
175 | + | |
176 | + Drawing_Draw_Point(vram, xsize, x1, y1, c); | |
177 | + | |
178 | + return; | |
179 | +} | |
180 | + | |
181 | +void Drawing_Draw_Circle(void *vram, uint xsize, uint x, uint y, uint c, uint r) | |
182 | +{ | |
183 | + uint i, r2; | |
184 | + uint py0, py1; | |
185 | + | |
186 | + if(r > 0xfff){ | |
187 | + return; | |
188 | + } | |
189 | + | |
190 | + r2 = r * r; | |
191 | + | |
192 | + for(i = 0; i < r; i++){ | |
193 | + py0 = (isqrt((r2 - (i * i)) << 8) + (1 << 2)) >> 4; | |
194 | + py1 = (isqrt((r2 - ((i + 1) * (i + 1))) << 8) + (1 << 2)) >> 4; | |
195 | + Drawing_Draw_Line_PQ(vram, xsize, c, x + i, y + py0, x + i + 1, y + py1); | |
196 | + Drawing_Draw_Line_PQ(vram, xsize, c, x - i, y + py0, x - i - 1, y + py1); | |
197 | + Drawing_Draw_Line_PQ(vram, xsize, c, x - i, y - py0, x - i - 1, y - py1); | |
198 | + Drawing_Draw_Line_PQ(vram, xsize, c, x + i, y - py0, x + i + 1, y - py1); | |
199 | + } | |
200 | + return; | |
201 | +} | |
202 | + | |
203 | +void Drawing_Fill_Circle(void *vram, uint xsize, uint x, uint y, uint c, uint r) | |
204 | +{ | |
205 | + uint i, r2; | |
206 | + uint py0, py1; | |
207 | + | |
208 | + if(r > 0xfff){ | |
209 | + return; | |
210 | + } | |
211 | + | |
212 | + r2 = r * r; | |
213 | + | |
214 | + for(i = 0; i < r; i ++){ | |
215 | + py0 = (isqrt((r2 - (i * i)) << 8) + (1 << 2)) >> 4; | |
216 | + py1 = (isqrt((r2 - ((i + 1) * (i + 1))) << 8) + (1 << 2)) >> 4; | |
217 | + Drawing_Draw_Line_PQ(vram, xsize, c, x + i + 1, y - py1, x + i + 1, y + py1); | |
218 | + Drawing_Draw_Line_PQ(vram, xsize, c, x - i - 1, y - py1, x - i - 1, y + py1); | |
219 | + } | |
220 | + Drawing_Draw_Line_PQ(vram, xsize, c, x, y - r, x, y + r); | |
221 | + return; | |
222 | +} | |
223 | + |
@@ -22,6 +22,7 @@ | ||
22 | 22 | /*cfunc.c vsnprintfの独自実装等*/ |
23 | 23 | void srand(uint seed); |
24 | 24 | uint rand(void); |
25 | +uint isqrt(uint n); | |
25 | 26 | int snprintf(uchar s[], uint n, const uchar format[], ...); |
26 | 27 | int vsnprintf(uchar s[], uint n, const uchar format[], uint vargs[]); |
27 | 28 | // |
@@ -48,7 +49,6 @@ | ||
48 | 49 | void Drawing08_Put_Font(void *vram, uint xsize, uint x, uint y, uint c, const uchar *font); |
49 | 50 | void Drawing08_Put_String(void *vram, uint xsize, uint x, uint y, uint c, const uchar s[]); |
50 | 51 | void Drawing08_Draw_Point(void *vram, uint xsize, uint x, uint y, uint c); |
51 | -void Drawing08_Draw_Line_PQ(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1); | |
52 | 52 | |
53 | 53 | /*draw16.c 16bit描画関連*/ |
54 | 54 | void Drawing16_Fill_Rectangle(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1); |
@@ -55,7 +55,6 @@ | ||
55 | 55 | void Drawing16_Put_Font(void *vram, uint xsize, uint x, uint y, uint c, const uchar *font); |
56 | 56 | void Drawing16_Put_String(void *vram, uint xsize, uint x, uint y, uint c, const uchar s[]); |
57 | 57 | void Drawing16_Draw_Point(void *vram, uint xsize, uint x, uint y, uint c); |
58 | -void Drawing16_Draw_Line_PQ(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1); | |
59 | 58 | |
60 | 59 | /*draw32.c 32bit描画関連*/ |
61 | 60 | void Drawing32_Fill_Rectangle(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1); |
@@ -62,13 +61,11 @@ | ||
62 | 61 | void Drawing32_Put_Font(void *vram, uint xsize, uint x, uint y, uint c, const uchar *font); |
63 | 62 | void Drawing32_Put_String(void *vram, uint xsize, uint x, uint y, uint c, const uchar s[]); |
64 | 63 | void Drawing32_Draw_Point(void *vram, uint xsize, uint x, uint y, uint c); |
65 | -void Drawing32_Draw_Line_PQ(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1); | |
66 | 64 | |
67 | 65 | /*drawing.c 描画関連*/ |
68 | 66 | extern void (*Drawing_Fill_Rectangle)(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1); |
69 | 67 | extern void (*Drawing_Put_String)(void *vram, uint xsize, uint x, uint y, uint c, const uchar *s); |
70 | 68 | extern void (*Drawing_Draw_Point)(void *vram, uint xsize, uint x, uint y, uint c); |
71 | -extern void (*Drawing_Draw_Line_PQ)(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1); | |
72 | 69 | void Drawing_Invalid_Put_String(void *vram, uint xsize, uint x, uint y, uint c, const uchar *s); |
73 | 70 | void Drawing_Invalid_Fill_Rectangle(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1); |
74 | 71 | void Drawing_Invalid_Draw_Point(void *vram, uint xsize, uint x, uint y, uint c); |
@@ -77,6 +74,9 @@ | ||
77 | 74 | uchar RGB_32_To_08(uint c32); |
78 | 75 | uchar RGB_32_To_08_xy(uint c32, int x, int y); |
79 | 76 | ushort RGB_32_To_16(uint c32); |
77 | +void Drawing_Draw_Line_PQ(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1); | |
78 | +void Drawing_Draw_Circle(void *vram, uint xsize, uint x, uint y, uint c, uint r); | |
79 | +void Drawing_Fill_Circle(void *vram, uint xsize, uint x, uint y, uint c, uint r); | |
80 | 80 | |
81 | 81 | /*dsctbl.c セグメント・ゲートディスクリプタ関連*/ |
82 | 82 | void Initialise_GlobalDescriptorTable(void); |
@@ -151,6 +151,7 @@ | ||
151 | 151 | void Error_Abort(void); |
152 | 152 | void Error_Set_Enable_SerialPort(bool serial); |
153 | 153 | void Error_Set_Enable_Display_TextMode(bool tdisp); |
154 | +void Error_Set_Enable_Display_GraphicMode(bool gdisp, void *vram, uint xsize, uint lines); | |
154 | 155 | int Error_Put_String(const uchar format[], ...); |
155 | 156 | void Error_CPU_Exception_Put_Registers_With_ErrorCode(uint *esp); |
156 | 157 | void Error_CPU_Exception_Put_Registers_Without_ErrorCode(uint *esp); |
@@ -23,6 +23,103 @@ | ||
23 | 23 | return system_seed; |
24 | 24 | } |
25 | 25 | |
26 | +uint isqrt(uint n) | |
27 | +{ | |
28 | + uint x; | |
29 | + | |
30 | +//Overflow Check | |
31 | + if(n >= (uint)0xffff * (uint)0xffff){ | |
32 | + return 0xffff; | |
33 | + } | |
34 | + | |
35 | + x = (1 << 15); | |
36 | + | |
37 | + if(n > x * x){ | |
38 | + x += (1 << 14); | |
39 | + } else{ | |
40 | + x -= (1 << 14); | |
41 | + } | |
42 | + if(n > x * x){ | |
43 | + x += (1 << 13); | |
44 | + } else{ | |
45 | + x -= (1 << 13); | |
46 | + } | |
47 | + if(n > x * x){ | |
48 | + x += (1 << 12); | |
49 | + } else{ | |
50 | + x -= (1 << 12); | |
51 | + } | |
52 | + if(n > x * x){ | |
53 | + x += (1 << 11); | |
54 | + } else{ | |
55 | + x -= (1 << 11); | |
56 | + } | |
57 | + if(n > x * x){ | |
58 | + x += (1 << 10); | |
59 | + } else{ | |
60 | + x -= (1 << 10); | |
61 | + } | |
62 | + if(n > x * x){ | |
63 | + x += (1 << 9); | |
64 | + } else{ | |
65 | + x -= (1 << 9); | |
66 | + } | |
67 | + if(n > x * x){ | |
68 | + x += (1 << 8); | |
69 | + } else{ | |
70 | + x -= (1 << 8); | |
71 | + } | |
72 | + if(n > x * x){ | |
73 | + x += (1 << 7); | |
74 | + } else{ | |
75 | + x -= (1 << 7); | |
76 | + } | |
77 | + if(n > x * x){ | |
78 | + x += (1 << 6); | |
79 | + } else{ | |
80 | + x -= (1 << 6); | |
81 | + } | |
82 | + if(n > x * x){ | |
83 | + x += (1 << 5); | |
84 | + } else{ | |
85 | + x -= (1 << 5); | |
86 | + } | |
87 | + if(n > x * x){ | |
88 | + x += (1 << 4); | |
89 | + } else{ | |
90 | + x -= (1 << 4); | |
91 | + } | |
92 | + if(n > x * x){ | |
93 | + x += (1 << 3); | |
94 | + } else{ | |
95 | + x -= (1 << 3); | |
96 | + } | |
97 | + if(n > x * x){ | |
98 | + x += (1 << 2); | |
99 | + } else{ | |
100 | + x -= (1 << 2); | |
101 | + } | |
102 | + if(n > x * x){ | |
103 | + x += (1 << 1); | |
104 | + } else{ | |
105 | + x -= (1 << 1); | |
106 | + } | |
107 | + if(n > x * x){ | |
108 | + x += (1 << 0); | |
109 | + } else{ | |
110 | + x -= (1 << 0); | |
111 | + } | |
112 | + | |
113 | + if(n > x * x){ | |
114 | + x++; | |
115 | + } | |
116 | + if(n < x * x){ | |
117 | + x--; | |
118 | + } | |
119 | + | |
120 | + return x; | |
121 | +} | |
122 | + | |
26 | 123 | //引数(uchar s[], uint n, const uchar format[], ...) |
27 | 124 | // s :結果を書き込む文字列の先頭アドレスを指定します。 |
28 | 125 | // n :s[]の大きさを指定します。(n - 1)番目以降の文字は書き込まれません。 |
@@ -65,13 +162,18 @@ | ||
65 | 162 | int CFunction_vsnprintf(uchar s[], uint n, const uchar format[], uint vargs[]) |
66 | 163 | { |
67 | 164 | uchar c; |
68 | - uint i; | |
165 | + uint i, j; | |
69 | 166 | const uchar *d; |
167 | + uint flag_fill_zero; | |
168 | + uint fill_length; | |
70 | 169 | |
71 | 170 | CFunction_vsnprintf_WorkArea work; |
72 | 171 | |
73 | - CFunction_vsnprintf_Initialise_WorkArea(&work, s, format, n, vargs); | |
172 | + CFunction_vsnprintf_Initialise_WorkArea(&work, s, format, n, vargs); | |
74 | 173 | |
174 | + flag_fill_zero = False; | |
175 | + fill_length = 0xffffffff; | |
176 | + | |
75 | 177 | for(;;){ |
76 | 178 | if(CFunction_vsnprintf_Check_FormatBuffer(&work) == -1){ |
77 | 179 | break; |
@@ -136,13 +238,26 @@ | ||
136 | 238 | CFunction_vsnprintf_Write_DestinationBuffer(&work, work.temporary_data[i]); |
137 | 239 | } |
138 | 240 | } else if(c == 'X'){ /*データを16進数で出力します。X:アルファベット大文字。*/ |
241 | + /*標準精度は一桁以上、ゼロフィルです。*/ | |
242 | + if(fill_length == 0xffffffff){ | |
243 | + fill_length = 1; | |
244 | + flag_fill_zero = True; | |
245 | + } | |
139 | 246 | CFunction_vsnprintf_To_String_From_Hex_Upper(&work, CFunction_vsnprintf_Get_NextArgument(&work)); |
140 | 247 | for(i = 0; i < 8; i++){ |
141 | 248 | if(work.temporary_data[i] != ' '){ |
142 | 249 | break; |
143 | 250 | } |
144 | - if(i >= 8 - 1){ | |
145 | - CFunction_vsnprintf_Write_DestinationBuffer(&work, '0'); | |
251 | + } | |
252 | + if((8 - i) < fill_length && fill_length != 0xffffffff){ | |
253 | + if(flag_fill_zero){ | |
254 | + for(j = 0; j < (fill_length - (8 - i)); j++){ | |
255 | + CFunction_vsnprintf_Write_DestinationBuffer(&work, '0'); | |
256 | + } | |
257 | + } else{ | |
258 | + for(j = 0; j < (fill_length - (8 - i)); j++){ | |
259 | + CFunction_vsnprintf_Write_DestinationBuffer(&work, ' '); | |
260 | + } | |
146 | 261 | } |
147 | 262 | } |
148 | 263 | for(; i < 8; i++){ |
@@ -204,6 +319,17 @@ | ||
204 | 319 | } else if(c == 'p'){ /*データを何らかのポインタと解釈して、その指し示すアドレスを出力します。*/ |
205 | 320 | } else if(c == 'n'){ /*このフォーマット指定子を含むフォーマット指定に達するまで、今回出力した文字数を、データをuint *として解釈し、ポインタが指し示す先のuint型変数に代入します。*/ |
206 | 321 | } else if(0x30 <= c && c <= 0x39){ /*数字*/ |
322 | + c -= 0x30; | |
323 | + if(fill_length == 0xffffffff && c == 0){ /*最初のゼロ:ゼロ充填を要求*/ | |
324 | + flag_fill_zero = True; | |
325 | + fill_length = 0; | |
326 | + } else{ | |
327 | + if(fill_length == 0xffffffff){ | |
328 | + fill_length = c; | |
329 | + } else{ | |
330 | + fill_length = (fill_length * 10) + c; | |
331 | + } | |
332 | + } | |
207 | 333 | } else{ |
208 | 334 | CFunction_vsnprintf_Write_DestinationBuffer(&work, c); |
209 | 335 | work.format_phase = 0; |
@@ -210,6 +336,8 @@ | ||
210 | 336 | } |
211 | 337 | } else{ /*一般文字かも*/ |
212 | 338 | if(c == '%'){ /*次からは書式指定*/ |
339 | + flag_fill_zero = False; | |
340 | + fill_length = 0xffffffff; | |
213 | 341 | work.format_phase = 1; |
214 | 342 | } else{ /*一般文字出力中*/ |
215 | 343 | CFunction_vsnprintf_Write_DestinationBuffer(&work, c); |
@@ -79,18 +79,15 @@ | ||
79 | 79 | } |
80 | 80 | } |
81 | 81 | |
82 | - Initialise_Drawing(); | |
83 | - | |
84 | 82 | Drawing_Fill_Rectangle(disp_ctrl->vram, disp_ctrl->xsize, 0xffffff, 0, 0, disp_ctrl->xsize - 1, disp_ctrl->ysize - 1); |
85 | 83 | Drawing_Put_String(disp_ctrl->vram, disp_ctrl->xsize, 10, 10, 0x000000, "Welcome to CHNOSProject!"); |
86 | 84 | |
87 | 85 | Format_BMP_DrawPicture(disp_ctrl->vram, disp_ctrl->xsize, 10, 26, 0, 0, chnlogo); |
88 | 86 | |
89 | - srand(123456); | |
90 | - for(i = 0; i < 10; i++){ | |
91 | - Drawing_Draw_Line_PQ(disp_ctrl->vram, disp_ctrl->xsize, rand(), 100, 300 + (rand() % 50), 300, 220 + (rand() % 180)); | |
87 | + Drawing_Fill_Circle(disp_ctrl->vram, disp_ctrl->xsize, 100, 250, 0x00c600, 45); | |
88 | + for(i = 0; i < 50; i += 5){ | |
89 | + Drawing_Draw_Circle(disp_ctrl->vram, disp_ctrl->xsize, 100, 250, 0xc6c6c6, i); | |
92 | 90 | } |
93 | - | |
94 | 91 | for(;;){ |
95 | 92 | |
96 | 93 | } |
@@ -4,6 +4,12 @@ | ||
4 | 4 | void Drawing32_Fill_Rectangle(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1) |
5 | 5 | { |
6 | 6 | uint x, y; |
7 | + | |
8 | +//if negative position | |
9 | + if((x0 & 0x80000000) != 0 || (y0 & 0x80000000) != 0 || (x1 & 0x80000000) != 0 || (y1 & 0x80000000) != 0){ | |
10 | + return; | |
11 | + } | |
12 | + | |
7 | 13 | for(y = y0; y <= y1; y++){ |
8 | 14 | for(x = x0; x <= x1; x++){ |
9 | 15 | ((uint *)vram)[y * xsize + x] = c; |
@@ -17,6 +23,12 @@ | ||
17 | 23 | int i; |
18 | 24 | uchar d; |
19 | 25 | uint *p; |
26 | + | |
27 | +//if negative position | |
28 | + if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){ | |
29 | + return; | |
30 | + } | |
31 | + | |
20 | 32 | for (i = 0; i < 16; i++) { |
21 | 33 | p = (uint *)vram + (y + i) * xsize + x; |
22 | 34 | d = font[i]; |
@@ -34,6 +46,11 @@ | ||
34 | 46 | |
35 | 47 | void Drawing32_Put_String(void *vram, uint xsize, uint x, uint y, uint c, const uchar s[]) |
36 | 48 | { |
49 | +//if negative position | |
50 | + if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){ | |
51 | + return; | |
52 | + } | |
53 | + | |
37 | 54 | for(; *s != 0x00; s++){ |
38 | 55 | if(x > xsize - 8){ |
39 | 56 | break; |
@@ -46,74 +63,11 @@ | ||
46 | 63 | |
47 | 64 | void Drawing32_Draw_Point(void *vram, uint xsize, uint x, uint y, uint c) |
48 | 65 | { |
49 | - ((uint *)vram)[y * xsize + x] = c; | |
50 | - return; | |
51 | -} | |
52 | - | |
53 | -void Drawing32_Draw_Line_PQ(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1) | |
54 | -{ | |
55 | - uint lx; | |
56 | - uint i, j; | |
57 | - uint a; | |
58 | - | |
59 | - if(x1 < x0){ | |
60 | - lx = x0; | |
61 | - x0 = x1; | |
62 | - x1 = lx; | |
63 | - | |
64 | - lx = y0; | |
65 | - y0 = y1; | |
66 | - y1 = lx; | |
67 | - } else if(x1 == x0){ | |
68 | - if(y0 <= y1){ | |
69 | - for(i = 0; i < y1 - y0 + 1; i++){ | |
70 | - ((uint *)vram)[(y0 + i) * xsize + x0] = c; | |
71 | - } | |
72 | - } else{ | |
73 | - for(i = 0; i < y0 - y1 + 1; i++){ | |
74 | - ((uint *)vram)[(y0 - i) * xsize + x0] = c; | |
75 | - } | |
76 | - } | |
66 | +//if negative position | |
67 | + if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){ | |
77 | 68 | return; |
78 | 69 | } |
79 | 70 | |
80 | - lx = x1 - x0; | |
81 | - if(lx == 0){ | |
82 | - lx = 1; | |
83 | - } | |
84 | - | |
85 | - if(y0 <= y1){ //+a | |
86 | - a = ((y1 - y0) << 10) / lx; | |
87 | - for(i = 0; i < lx; i++){ | |
88 | - ((uint *)vram)[(y0 + ((i * a) >> 10)) * xsize + (x0 + i)] = c; | |
89 | - for(j = ((i * a) >> 10) + 1; j < ((i + 1) * a) >> 10; j++){ | |
90 | - ((uint *)vram)[(y0 + j) * xsize + (x0 + i)] = c; | |
91 | - } | |
92 | - } | |
93 | - for(j = ((i * a) >> 10) + 1; j < ((i + 1) * a) >> 10; j++){ | |
94 | - ((uint *)vram)[(y0 + j) * xsize + (x0 + i)] = c; | |
95 | - if(y1 >= y0 + j){ | |
96 | - break; | |
97 | - } | |
98 | - } | |
99 | - } else{ //-a | |
100 | - a = ((y0 - y1) << 10) / lx; | |
101 | - for(i = 0; i < lx; i++){ | |
102 | - ((uint *)vram)[(y0 - ((i * a) >> 10)) * xsize + (x0 + i)] = c; | |
103 | - for(j = ((i * a) >> 10) + 1; j < ((i + 1) * a) >> 10; j++){ | |
104 | - ((uint *)vram)[(y0 - j) * xsize + (x0 + i)] = c; | |
105 | - } | |
106 | - } | |
107 | - for(j = ((i * a) >> 10) + 1; j < ((i + 1) * a) >> 10; j++){ | |
108 | - ((uint *)vram)[(y0 - j) * xsize + (x0 + i)] = c; | |
109 | - if(y1 <= y0 - j){ | |
110 | - break; | |
111 | - } | |
112 | - } | |
113 | - } | |
114 | - | |
115 | - ((uint *)vram)[y1 * xsize + x1] = c; | |
116 | - | |
71 | + ((uint *)vram)[y * xsize + x] = c; | |
117 | 72 | return; |
118 | 73 | } |
119 | - |
@@ -4,6 +4,12 @@ | ||
4 | 4 | void Drawing16_Fill_Rectangle(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1) |
5 | 5 | { |
6 | 6 | uint x, y; |
7 | + | |
8 | +//if negative position | |
9 | + if((x0 & 0x80000000) != 0 || (y0 & 0x80000000) != 0 || (x1 & 0x80000000) != 0 || (y1 & 0x80000000) != 0){ | |
10 | + return; | |
11 | + } | |
12 | + | |
7 | 13 | c = RGB_32_To_16(c); |
8 | 14 | for(y = y0; y <= y1; y++){ |
9 | 15 | for(x = x0; x <= x1; x++){ |
@@ -18,6 +24,12 @@ | ||
18 | 24 | int i; |
19 | 25 | uchar d; |
20 | 26 | ushort *p; |
27 | + | |
28 | +//if negative position | |
29 | + if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){ | |
30 | + return; | |
31 | + } | |
32 | + | |
21 | 33 | for (i = 0; i < 16; i++) { |
22 | 34 | p = (ushort *)vram + (y + i) * xsize + x; |
23 | 35 | d = font[i]; |
@@ -35,6 +47,11 @@ | ||
35 | 47 | |
36 | 48 | void Drawing16_Put_String(void *vram, uint xsize, uint x, uint y, uint c, const uchar s[]) |
37 | 49 | { |
50 | +//if negative position | |
51 | + if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){ | |
52 | + return; | |
53 | + } | |
54 | + | |
38 | 55 | c = RGB_32_To_16(c); |
39 | 56 | for(; *s != 0x00; s++){ |
40 | 57 | if(x > xsize - 8){ |
@@ -48,76 +65,11 @@ | ||
48 | 65 | |
49 | 66 | void Drawing16_Draw_Point(void *vram, uint xsize, uint x, uint y, uint c) |
50 | 67 | { |
51 | - ((ushort *)vram)[y * xsize + x] = RGB_32_To_16(c); | |
52 | - return; | |
53 | -} | |
54 | - | |
55 | -void Drawing16_Draw_Line_PQ(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1) | |
56 | -{ | |
57 | - uint lx; | |
58 | - uint i, j; | |
59 | - uint a; | |
60 | - uint c16; | |
61 | - | |
62 | - c16 = RGB_32_To_16(c); | |
63 | - | |
64 | - if(x1 < x0){ | |
65 | - lx = x0; | |
66 | - x0 = x1; | |
67 | - x1 = lx; | |
68 | - | |
69 | - lx = y0; | |
70 | - y0 = y1; | |
71 | - y1 = lx; | |
72 | - } else if(x1 == x0){ | |
73 | - if(y0 <= y1){ | |
74 | - for(i = 0; i < y1 - y0 + 1; i++){ | |
75 | - ((ushort *)vram)[(y0 + i) * xsize + x0] = c16; | |
76 | - } | |
77 | - } else{ | |
78 | - for(i = 0; i < y0 - y1 + 1; i++){ | |
79 | - ((ushort *)vram)[(y0 - i) * xsize + x0] = c16; | |
80 | - } | |
81 | - } | |
68 | +//if negative position | |
69 | + if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){ | |
82 | 70 | return; |
83 | 71 | } |
84 | 72 | |
85 | - lx = x1 - x0; | |
86 | - if(lx == 0){ | |
87 | - lx = 1; | |
88 | - } | |
89 | - | |
90 | - if(y0 <= y1){ //+a | |
91 | - a = ((y1 - y0) << 10) / lx; | |
92 | - for(i = 0; i < lx; i++){ | |
93 | - ((ushort *)vram)[(y0 + ((i * a) >> 10)) * xsize + (x0 + i)] = c16; | |
94 | - for(j = ((i * a) >> 10) + 1; j < ((i + 1) * a) >> 10; j++){ | |
95 | - ((ushort *)vram)[(y0 + j) * xsize + (x0 + i)] = c16; | |
96 | - } | |
97 | - } | |
98 | - for(j = ((i * a) >> 10) + 1; j < ((i + 1) * a) >> 10; j++){ | |
99 | - ((ushort *)vram)[(y0 + j) * xsize + (x0 + i)] = c16; | |
100 | - if(y1 >= y0 + j){ | |
101 | - break; | |
102 | - } | |
103 | - } | |
104 | - } else{ //-a | |
105 | - a = ((y0 - y1) << 10) / lx; | |
106 | - for(i = 0; i < lx; i++){ | |
107 | - ((ushort *)vram)[(y0 - ((i * a) >> 10)) * xsize + (x0 + i)] = c16; | |
108 | - for(j = ((i * a) >> 10) + 1; j < ((i + 1) * a) >> 10; j++){ | |
109 | - ((ushort *)vram)[(y0 - j) * xsize + (x0 + i)] = c16; | |
110 | - } | |
111 | - } | |
112 | - for(j = ((i * a) >> 10) + 1; j < ((i + 1) * a) >> 10; j++){ | |
113 | - ((ushort *)vram)[(y0 - j) * xsize + (x0 + i)] = c16; | |
114 | - if(y1 <= y0 - j){ | |
115 | - break; | |
116 | - } | |
117 | - } | |
118 | - } | |
119 | - | |
120 | - ((ushort *)vram)[y1 * xsize + x1] = c16; | |
121 | - | |
73 | + ((ushort *)vram)[y * xsize + x] = RGB_32_To_16(c); | |
122 | 74 | return; |
123 | 75 | } |
@@ -5,12 +5,12 @@ | ||
5 | 5 | #define CHNOSPROJECT_DEBUG /*定義するとデバッグモードで実行。それぞれのデバッグオプションも有効にする必要がある*/ |
6 | 6 | |
7 | 7 | #ifdef CHNOSPROJECT_DEBUG |
8 | - #define CHNOSPROJECT_DEBUG_MEMORY /*定義するとメモリ関連のデバッグをオンにする*/ | |
9 | - #define CHNOSPROJECT_DEBUG_EMULATOR_X86 | |
10 | - #define CHNOSPROJECT_DEBUG_CALLBIOS | |
11 | - #define CHNOSPROJECT_DEBUG_FIFO | |
12 | - #define CHNOSPROJECT_DEBUG_KBCT | |
13 | - #define CHNOSPROJECT_DEBUG_DISPLAY | |
8 | + //#define CHNOSPROJECT_DEBUG_MEMORY /*定義するとメモリ関連のデバッグをオンにする*/ | |
9 | + //#define CHNOSPROJECT_DEBUG_EMULATOR_X86 | |
10 | + //#define CHNOSPROJECT_DEBUG_CALLBIOS | |
11 | + //#define CHNOSPROJECT_DEBUG_FIFO | |
12 | + //#define CHNOSPROJECT_DEBUG_KBCT | |
13 | + //#define CHNOSPROJECT_DEBUG_DISPLAY | |
14 | 14 | #define CHNOSPROJECT_DEBUG_DRAWING |
15 | 15 | #endif |
16 | 16 |