• R/O
  • SSH
  • HTTPS

chnosproject: コミット


コミットメタ情報

リビジョン311 (tree)
日時2012-01-01 10:28:37
作者hikarupsp

ログメッセージ

Drawing_Draw_CircleとDrawing_Fill_Circleを追加した。
全ての描画系低レベル関数に、31ビット目が1の時は処理を行わないように(計算結果がマイナスだった場合の誤動作を防ぐため)した。
また、例外や致命的エラー発生時の画面表示にも対応した。
前回作成した直線描画関数には、決定的なミスがあったので、(多分)修正された。
シートの実装はいつごろできるのやら…。

変更サマリ

差分

--- beta/tolset_chn_000/chnos_010/chnos/draw08.c (revision 310)
+++ beta/tolset_chn_000/chnos_010/chnos/draw08.c (revision 311)
@@ -59,6 +59,12 @@
5959 void Drawing08_Fill_Rectangle(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1)
6060 {
6161 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+
6268 c = RGB_32_To_08(c);
6369 for(y = y0; y <= y1; y++){
6470 for(x = x0; x <= x1; x++){
@@ -74,6 +80,11 @@
7480 uchar d;
7581 uchar *p;
7682
83+//if negative position
84+ if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){
85+ return;
86+ }
87+
7788 for (i = 0; i < 16; i++) {
7889 p = (uchar *)(vram + (y + i) * xsize + x);
7990 d = font[i];
@@ -91,6 +102,11 @@
91102
92103 void Drawing08_Put_String(void *vram, uint xsize, uint x, uint y, uint c, const uchar s[])
93104 {
105+//if negative position
106+ if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){
107+ return;
108+ }
109+
94110 c = RGB_32_To_08(c);
95111 for(; *s != 0x00; s++){
96112 if(x > xsize - 8){
@@ -104,77 +120,11 @@
104120
105121 void Drawing08_Draw_Point(void *vram, uint xsize, uint x, uint y, uint c)
106122 {
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){
138125 return;
139126 }
140127
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);
178129 return;
179130 }
180-
--- beta/tolset_chn_000/chnos_010/chnos/display.c (revision 310)
+++ beta/tolset_chn_000/chnos_010/chnos/display.c (revision 311)
@@ -43,7 +43,10 @@
4343 ctrl->vram = VGA_VRAM_ADR;
4444
4545 Drawing08_Initialise_Palette();
46+ Error_Set_Enable_Display_TextMode(false);
47+ Error_Set_Enable_Display_GraphicMode(true, ctrl->vram, ctrl->xsize, ctrl->ysize >> 4);
4648
49+
4750 //次に、VBEのBIOS情報を得る。
4851
4952 callbiosctrl->CallBIOS_Task->tss->eax = 0x4f00;
@@ -264,6 +267,8 @@
264267 }
265268 debug("\n");
266269 #endif
270+ Initialise_Drawing();
271+ Error_Set_Enable_Display_GraphicMode(true, ctrl->vram, ctrl->xsize, ctrl->ysize >> 4);
267272 return 0;
268273 }
269274
--- beta/tolset_chn_000/chnos_010/chnos/error.c (revision 310)
+++ beta/tolset_chn_000/chnos_010/chnos/error.c (revision 311)
@@ -3,7 +3,13 @@
33
44 bool Error_Output_Enable_SerialPort = false;
55 bool Error_Output_Enable_Display_TextMode = false;
6+uint Error_Output_Enable_Display_GraphicMode = false;
67
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+
713 uchar *cpu_exceptions[0x20] = {
814 "Divided by zero.",
915 "Reserved.",
@@ -66,7 +72,7 @@
6672 va_args = &error_no + 1;
6773
6874 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]);
7076 if(error_no == ERROR_CPU_EXCEPTION_00){
7177 Error_CPU_Exception_Put_Registers_Without_ErrorCode((uint *)*va_args);
7278 } else if(error_no == ERROR_CPU_EXCEPTION_01){
@@ -134,20 +140,20 @@
134140 }
135141 Error_Abort();
136142 } 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);
138144 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);
140146 Error_Abort();
141147 } 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));
143149 } 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));
145151 } 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);
147153 } 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));
149155 } else{
150- Error_Put_String("Unknown Error Number.\n");
156+ Error_Put_String("Unknown Error Number.");
151157 Error_Abort();
152158 }
153159 }
@@ -174,6 +180,16 @@
174180 return;
175181 }
176182
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+
177193 int Error_Put_String(const uchar format[], ...)
178194 {
179195 int i;
@@ -180,11 +196,20 @@
180196 uchar s[256];
181197
182198 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+ }
183206 if(Error_Output_Enable_SerialPort){
184207 SerialPort_Send(s);
208+ SerialPort_Send("\n");
185209 }
186210 if(Error_Output_Enable_Display_TextMode){
187211 TextMode_Put_String(s, white);
212+ TextMode_Put_String("\n", white);
188213 }
189214 return i;
190215 }
@@ -193,28 +218,28 @@
193218 {
194219 uint i;
195220
196- Error_Put_String("#PUSHAD by _asm_CPU_ExceptionHandler\n");
221+ Error_Put_String("#PUSHAD by _asm_CPU_ExceptionHandler");
197222 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]);
199224 }
200225
201- Error_Put_String("#PUSH by _asm_CPU_ExceptionHandler\n");
226+ Error_Put_String("#PUSH by _asm_CPU_ExceptionHandler");
202227 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]);
204229 }
205230
206231 Error_Put_String("#PUSH by CPU\n");
207232 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]);
209234 }
210235
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());
216241
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]);
218243 return;
219244 }
220245
@@ -222,26 +247,26 @@
222247 {
223248 uint i;
224249
225- Error_Put_String("#PUSHAD by _asm_CPU_ExceptionHandler\n");
250+ Error_Put_String("#PUSHAD by _asm_CPU_ExceptionHandler");
226251 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]);
228253 }
229254
230- Error_Put_String("#PUSH by _asm_CPU_ExceptionHandler\n");
255+ Error_Put_String("#PUSH by _asm_CPU_ExceptionHandler");
231256 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]);
233258 }
234259
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]);
237262 i++;
238263 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]);
240265 }
241266
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());
246271 return;
247272 }
--- beta/tolset_chn_000/chnos_010/chnos/drawing.c (revision 310)
+++ beta/tolset_chn_000/chnos_010/chnos/drawing.c (revision 311)
@@ -4,7 +4,6 @@
44 void (*Drawing_Fill_Rectangle)(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1);
55 void (*Drawing_Put_String)(void *vram, uint xsize, uint x, uint y, uint c, const uchar *s);
66 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);
87 //Drawingに含まれる低レベル描画関数は全て、座標は符号なし整数であり、vramの左上の座標を原点(0, 0)として、xは右方向、yは下方向に増加する。
98 //また、二点の座標をとる関数は、(基本的に)全て引数左側がx成分の小さい側(原点に近い)でなければならない。
109 //高レベル描画関数では、それらを上手くラップすべきである。
@@ -19,23 +18,19 @@
1918 Drawing_Fill_Rectangle = Drawing08_Fill_Rectangle;
2019 Drawing_Put_String = Drawing08_Put_String;
2120 Drawing_Draw_Point = Drawing08_Draw_Point;
22- Drawing_Draw_Line_PQ = Drawing08_Draw_Line_PQ;
2321 Drawing08_Initialise_Palette();
2422 } else if(dispctrl->bpp == 16){
2523 Drawing_Fill_Rectangle = Drawing16_Fill_Rectangle;
2624 Drawing_Put_String = Drawing16_Put_String;
2725 Drawing_Draw_Point = Drawing16_Draw_Point;
28- Drawing_Draw_Line_PQ = Drawing16_Draw_Line_PQ;
2926 } else if(dispctrl->bpp == 32){
3027 Drawing_Fill_Rectangle = Drawing32_Fill_Rectangle;
3128 Drawing_Put_String = Drawing32_Put_String;
3229 Drawing_Draw_Point = Drawing32_Draw_Point;
33- Drawing_Draw_Line_PQ = Drawing32_Draw_Line_PQ;
3430 } else{
3531 Drawing_Fill_Rectangle = Drawing_Invalid_Fill_Rectangle;
3632 Drawing_Put_String = Drawing_Invalid_Put_String;
3733 Drawing_Draw_Point = Drawing_Invalid_Draw_Point;
38- Drawing_Draw_Line_PQ = Drawing_Invalid_Draw_Line_PQ;
3934 #ifdef CHNOSPROJECT_DEBUG_DRAWING
4035 debug("Initalise_Drawing:Not implemented %d bpp.\n", dispctrl->bpp);
4136 #endif
@@ -67,14 +62,6 @@
6762 return;
6863 }
6964
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-
7865 uchar RGB_32_To_08(uint c32)
7966 {
8067 uchar c8;
@@ -137,3 +124,100 @@
137124 return c16;
138125 }
139126
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+
--- beta/tolset_chn_000/chnos_010/chnos/core.h (revision 310)
+++ beta/tolset_chn_000/chnos_010/chnos/core.h (revision 311)
@@ -22,6 +22,7 @@
2222 /*cfunc.c vsnprintfの独自実装等*/
2323 void srand(uint seed);
2424 uint rand(void);
25+uint isqrt(uint n);
2526 int snprintf(uchar s[], uint n, const uchar format[], ...);
2627 int vsnprintf(uchar s[], uint n, const uchar format[], uint vargs[]);
2728 //
@@ -48,7 +49,6 @@
4849 void Drawing08_Put_Font(void *vram, uint xsize, uint x, uint y, uint c, const uchar *font);
4950 void Drawing08_Put_String(void *vram, uint xsize, uint x, uint y, uint c, const uchar s[]);
5051 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);
5252
5353 /*draw16.c 16bit描画関連*/
5454 void Drawing16_Fill_Rectangle(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1);
@@ -55,7 +55,6 @@
5555 void Drawing16_Put_Font(void *vram, uint xsize, uint x, uint y, uint c, const uchar *font);
5656 void Drawing16_Put_String(void *vram, uint xsize, uint x, uint y, uint c, const uchar s[]);
5757 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);
5958
6059 /*draw32.c 32bit描画関連*/
6160 void Drawing32_Fill_Rectangle(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1);
@@ -62,13 +61,11 @@
6261 void Drawing32_Put_Font(void *vram, uint xsize, uint x, uint y, uint c, const uchar *font);
6362 void Drawing32_Put_String(void *vram, uint xsize, uint x, uint y, uint c, const uchar s[]);
6463 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);
6664
6765 /*drawing.c 描画関連*/
6866 extern void (*Drawing_Fill_Rectangle)(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1);
6967 extern void (*Drawing_Put_String)(void *vram, uint xsize, uint x, uint y, uint c, const uchar *s);
7068 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);
7269 void Drawing_Invalid_Put_String(void *vram, uint xsize, uint x, uint y, uint c, const uchar *s);
7370 void Drawing_Invalid_Fill_Rectangle(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1);
7471 void Drawing_Invalid_Draw_Point(void *vram, uint xsize, uint x, uint y, uint c);
@@ -77,6 +74,9 @@
7774 uchar RGB_32_To_08(uint c32);
7875 uchar RGB_32_To_08_xy(uint c32, int x, int y);
7976 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);
8080
8181 /*dsctbl.c セグメント・ゲートディスクリプタ関連*/
8282 void Initialise_GlobalDescriptorTable(void);
@@ -151,6 +151,7 @@
151151 void Error_Abort(void);
152152 void Error_Set_Enable_SerialPort(bool serial);
153153 void Error_Set_Enable_Display_TextMode(bool tdisp);
154+void Error_Set_Enable_Display_GraphicMode(bool gdisp, void *vram, uint xsize, uint lines);
154155 int Error_Put_String(const uchar format[], ...);
155156 void Error_CPU_Exception_Put_Registers_With_ErrorCode(uint *esp);
156157 void Error_CPU_Exception_Put_Registers_Without_ErrorCode(uint *esp);
--- beta/tolset_chn_000/chnos_010/chnos/cfunc.c (revision 310)
+++ beta/tolset_chn_000/chnos_010/chnos/cfunc.c (revision 311)
@@ -23,6 +23,103 @@
2323 return system_seed;
2424 }
2525
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+
26123 //引数(uchar s[], uint n, const uchar format[], ...)
27124 // s :結果を書き込む文字列の先頭アドレスを指定します。
28125 // n :s[]の大きさを指定します。(n - 1)番目以降の文字は書き込まれません。
@@ -65,13 +162,18 @@
65162 int CFunction_vsnprintf(uchar s[], uint n, const uchar format[], uint vargs[])
66163 {
67164 uchar c;
68- uint i;
165+ uint i, j;
69166 const uchar *d;
167+ uint flag_fill_zero;
168+ uint fill_length;
70169
71170 CFunction_vsnprintf_WorkArea work;
72171
73- CFunction_vsnprintf_Initialise_WorkArea(&work, s, format, n, vargs);
172+ CFunction_vsnprintf_Initialise_WorkArea(&work, s, format, n, vargs);
74173
174+ flag_fill_zero = False;
175+ fill_length = 0xffffffff;
176+
75177 for(;;){
76178 if(CFunction_vsnprintf_Check_FormatBuffer(&work) == -1){
77179 break;
@@ -136,13 +238,26 @@
136238 CFunction_vsnprintf_Write_DestinationBuffer(&work, work.temporary_data[i]);
137239 }
138240 } else if(c == 'X'){ /*データを16進数で出力します。X:アルファベット大文字。*/
241+ /*標準精度は一桁以上、ゼロフィルです。*/
242+ if(fill_length == 0xffffffff){
243+ fill_length = 1;
244+ flag_fill_zero = True;
245+ }
139246 CFunction_vsnprintf_To_String_From_Hex_Upper(&work, CFunction_vsnprintf_Get_NextArgument(&work));
140247 for(i = 0; i < 8; i++){
141248 if(work.temporary_data[i] != ' '){
142249 break;
143250 }
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+ }
146261 }
147262 }
148263 for(; i < 8; i++){
@@ -204,6 +319,17 @@
204319 } else if(c == 'p'){ /*データを何らかのポインタと解釈して、その指し示すアドレスを出力します。*/
205320 } else if(c == 'n'){ /*このフォーマット指定子を含むフォーマット指定に達するまで、今回出力した文字数を、データをuint *として解釈し、ポインタが指し示す先のuint型変数に代入します。*/
206321 } 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+ }
207333 } else{
208334 CFunction_vsnprintf_Write_DestinationBuffer(&work, c);
209335 work.format_phase = 0;
@@ -210,6 +336,8 @@
210336 }
211337 } else{ /*一般文字かも*/
212338 if(c == '%'){ /*次からは書式指定*/
339+ flag_fill_zero = False;
340+ fill_length = 0xffffffff;
213341 work.format_phase = 1;
214342 } else{ /*一般文字出力中*/
215343 CFunction_vsnprintf_Write_DestinationBuffer(&work, c);
--- beta/tolset_chn_000/chnos_010/chnos/bootpack.c (revision 310)
+++ beta/tolset_chn_000/chnos_010/chnos/bootpack.c (revision 311)
@@ -79,18 +79,15 @@
7979 }
8080 }
8181
82- Initialise_Drawing();
83-
8482 Drawing_Fill_Rectangle(disp_ctrl->vram, disp_ctrl->xsize, 0xffffff, 0, 0, disp_ctrl->xsize - 1, disp_ctrl->ysize - 1);
8583 Drawing_Put_String(disp_ctrl->vram, disp_ctrl->xsize, 10, 10, 0x000000, "Welcome to CHNOSProject!");
8684
8785 Format_BMP_DrawPicture(disp_ctrl->vram, disp_ctrl->xsize, 10, 26, 0, 0, chnlogo);
8886
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);
9290 }
93-
9491 for(;;){
9592
9693 }
--- beta/tolset_chn_000/chnos_010/chnos/draw32.c (revision 310)
+++ beta/tolset_chn_000/chnos_010/chnos/draw32.c (revision 311)
@@ -4,6 +4,12 @@
44 void Drawing32_Fill_Rectangle(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1)
55 {
66 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+
713 for(y = y0; y <= y1; y++){
814 for(x = x0; x <= x1; x++){
915 ((uint *)vram)[y * xsize + x] = c;
@@ -17,6 +23,12 @@
1723 int i;
1824 uchar d;
1925 uint *p;
26+
27+//if negative position
28+ if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){
29+ return;
30+ }
31+
2032 for (i = 0; i < 16; i++) {
2133 p = (uint *)vram + (y + i) * xsize + x;
2234 d = font[i];
@@ -34,6 +46,11 @@
3446
3547 void Drawing32_Put_String(void *vram, uint xsize, uint x, uint y, uint c, const uchar s[])
3648 {
49+//if negative position
50+ if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){
51+ return;
52+ }
53+
3754 for(; *s != 0x00; s++){
3855 if(x > xsize - 8){
3956 break;
@@ -46,74 +63,11 @@
4663
4764 void Drawing32_Draw_Point(void *vram, uint xsize, uint x, uint y, uint c)
4865 {
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){
7768 return;
7869 }
7970
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;
11772 return;
11873 }
119-
--- beta/tolset_chn_000/chnos_010/chnos/draw16.c (revision 310)
+++ beta/tolset_chn_000/chnos_010/chnos/draw16.c (revision 311)
@@ -4,6 +4,12 @@
44 void Drawing16_Fill_Rectangle(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1)
55 {
66 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+
713 c = RGB_32_To_16(c);
814 for(y = y0; y <= y1; y++){
915 for(x = x0; x <= x1; x++){
@@ -18,6 +24,12 @@
1824 int i;
1925 uchar d;
2026 ushort *p;
27+
28+//if negative position
29+ if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){
30+ return;
31+ }
32+
2133 for (i = 0; i < 16; i++) {
2234 p = (ushort *)vram + (y + i) * xsize + x;
2335 d = font[i];
@@ -35,6 +47,11 @@
3547
3648 void Drawing16_Put_String(void *vram, uint xsize, uint x, uint y, uint c, const uchar s[])
3749 {
50+//if negative position
51+ if((x & 0x80000000) != 0 || (y & 0x80000000) != 0){
52+ return;
53+ }
54+
3855 c = RGB_32_To_16(c);
3956 for(; *s != 0x00; s++){
4057 if(x > xsize - 8){
@@ -48,76 +65,11 @@
4865
4966 void Drawing16_Draw_Point(void *vram, uint xsize, uint x, uint y, uint c)
5067 {
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){
8270 return;
8371 }
8472
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);
12274 return;
12375 }
--- beta/tolset_chn_000/chnos_010/chnos/coredef0.h (revision 310)
+++ beta/tolset_chn_000/chnos_010/chnos/coredef0.h (revision 311)
@@ -5,12 +5,12 @@
55 #define CHNOSPROJECT_DEBUG /*定義するとデバッグモードで実行。それぞれのデバッグオプションも有効にする必要がある*/
66
77 #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
1414 #define CHNOSPROJECT_DEBUG_DRAWING
1515 #endif
1616
旧リポジトリブラウザで表示