• R/O
  • SSH
  • HTTPS

chnosproject: コミット


コミットメタ情報

リビジョン315 (tree)
日時2012-03-12 00:51:35
作者hikarupsp

ログメッセージ

多色対応完了。
高速化は全く行っていないので、少し遅い。
また、色変換の正確さはまだきちんと確認していないので、理論的には間違っているかもしれない。
ただ、目視では、それなりにきちんと変換できているようだ。
8, 16, 32各ビット数の相互変換が可能となっている。
また、testsheetに、メモリ総量と残量を表示するようにした。これは、Tick3のタイマーと連動しているので、自動で更新されるが、今はメモリの開放や確保を行っていないので、変化がない。

変更サマリ

差分

--- beta/tolset_chn_000/chnos_010/chnos/sht08.c (nonexistent)
+++ beta/tolset_chn_000/chnos_010/chnos/sht08.c (revision 315)
@@ -0,0 +1,226 @@
1+
2+#include "core.h"
3+
4+uint Sheet08_Internal_SetBuffer(UI_Sheet *sheet, void *vram, uint xsize, uint ysize, uint bpp)
5+{
6+ if(xsize > SHEET_MAX_XSIZE){
7+ #ifdef CHNOSPROJECT_DEBUG_SHEET
8+ debug("Sheet08_Internal_SetBuffer:Too large xsize.\n");
9+ #endif
10+ return 1;
11+ }
12+ if(ysize > SHEET_MAX_YSIZE){
13+ #ifdef CHNOSPROJECT_DEBUG_SHEET
14+ debug("Sheet08_Internal_SetBuffer:Too large ysize.\n");
15+ #endif
16+ return 2;
17+ }
18+
19+ sheet->size.x = xsize;
20+ sheet->size.y = ysize;
21+ sheet->bpp = bpp;
22+
23+ if(vram == Null){
24+ sheet->vram = System_Memory_Allocate(xsize * ysize * 1);
25+ sheet->flags.bit.vram_auto_allocated = True;
26+ #ifdef CHNOSPROJECT_DEBUG_SHEET
27+ debug("Sheet08_Internal_SetBuffer:Auto Allocation.\n");
28+ #endif
29+ } else{
30+ sheet->vram = vram;
31+ }
32+
33+ sheet->vramsize = xsize * ysize * 1;
34+ sheet->Config_Functions = &Sheet08_Config_Functions;
35+
36+ sheet->flags.bit.buffer_configured = True;
37+
38+ return 0;
39+}
40+
41+//set function address from parent's bpp and own bpp.
42+uint Sheet08_Config_Functions(UI_Sheet *sheet)
43+{
44+ if(sheet == Null){
45+ #ifdef CHNOSPROJECT_DEBUG_SHEET
46+ debug("Sheet08_Config_Functions:Null sheet.\n");
47+ #endif
48+ return 0;
49+ }
50+ if(sheet->parent == Null){
51+ #ifdef CHNOSPROJECT_DEBUG_SHEET
52+ debug("Sheet08_Config_Functions:Null parent.\n");
53+ #endif
54+ return 1;
55+ }
56+
57+ if(sheet->parent->bpp == 8){
58+ sheet->RefreshSheet = &Sheet08_Internal_RefreshSheet_To_08;
59+ } else if(sheet->parent->bpp == 16){
60+ sheet->RefreshSheet = &Sheet08_Internal_RefreshSheet_To_16;
61+ } else if(sheet->parent->bpp == 32){
62+ sheet->RefreshSheet = &Sheet08_Internal_RefreshSheet_To_32;
63+ } else{
64+ #ifdef CHNOSPROJECT_DEBUG_SHEET
65+ debug("Sheet08_Config_Functions:Not implemented refresh function to bpp %d.\n", sheet->parent->bpp);
66+ #endif
67+ }
68+ return 0;
69+}
70+
71+uint Sheet08_Internal_RefreshSheet_To_08(UI_Sheet *sheet, int px0, int py0, int px1, int py1)
72+{
73+ DATA_Location2D p, r;
74+ int x, y;
75+
76+ if(sheet->parent->map == Null){
77+ #ifdef CHNOSPROJECT_DEBUG_SHEET
78+ debug("Sheet08_Internal_RefreshSheet_To_08:Null map.\n");
79+ #endif
80+ return 1;
81+ }
82+
83+ Sheet_Internal_GetLocationP(sheet, &p);
84+ Sheet_Internal_GetLocationR(sheet, &r);
85+
86+ if(p.x < px0){
87+ p.x = px0;
88+ }
89+ if(p.y < py0){
90+ p.y = py0;
91+ }
92+ if(r.x > px1){
93+ r.x = px1;
94+ }
95+ if(r.y > py1){
96+ r.y = py1;
97+ }
98+
99+ if(p.x < 0){
100+ p.x = 0;
101+ }
102+ if(p.y < 0){
103+ p.y = 0;
104+ }
105+ if(r.x >= (int)sheet->parent->size.x){
106+ r.x = (int)sheet->parent->size.x - 1;
107+ }
108+ if(r.y >= (int)sheet->parent->size.y){
109+ r.y = (int)sheet->parent->size.y - 1;
110+ }
111+
112+ for(y = p.y; y <= r.y; y++){
113+ for(x = p.x; x <= r.x; x++){
114+ if(sheet->parent->map[y * sheet->parent->size.x + x] == (uint)sheet){
115+ ((uchar *)sheet->parent->vram)[y * sheet->parent->size.x + x] = ((uchar *)sheet->vram)[(y - sheet->location.y) * sheet->size.x + (x - sheet->location.x)];
116+ }
117+ }
118+ }
119+
120+ return 0;
121+}
122+
123+uint Sheet08_Internal_RefreshSheet_To_16(UI_Sheet *sheet, int px0, int py0, int px1, int py1)
124+{
125+ DATA_Location2D p, r;
126+ int x, y;
127+
128+ if(sheet->parent->map == Null){
129+ #ifdef CHNOSPROJECT_DEBUG_SHEET
130+ debug("Sheet08_Internal_RefreshSheet_To_16:Null map.\n");
131+ #endif
132+ return 1;
133+ }
134+
135+ Sheet_Internal_GetLocationP(sheet, &p);
136+ Sheet_Internal_GetLocationR(sheet, &r);
137+
138+ if(p.x < px0){
139+ p.x = px0;
140+ }
141+ if(p.y < py0){
142+ p.y = py0;
143+ }
144+ if(r.x > px1){
145+ r.x = px1;
146+ }
147+ if(r.y > py1){
148+ r.y = py1;
149+ }
150+
151+ if(p.x < 0){
152+ p.x = 0;
153+ }
154+ if(p.y < 0){
155+ p.y = 0;
156+ }
157+ if(r.x >= (int)sheet->parent->size.x){
158+ r.x = (int)sheet->parent->size.x - 1;
159+ }
160+ if(r.y >= (int)sheet->parent->size.y){
161+ r.y = (int)sheet->parent->size.y - 1;
162+ }
163+
164+ for(y = p.y; y <= r.y; y++){
165+ for(x = p.x; x <= r.x; x++){
166+ if(sheet->parent->map[y * sheet->parent->size.x + x] == (uint)sheet){
167+ ((ushort *)sheet->parent->vram)[y * sheet->parent->size.x + x] = RGB_08_To_16(((uchar *)sheet->vram)[(y - sheet->location.y) * sheet->size.x + (x - sheet->location.x)]);
168+ }
169+ }
170+ }
171+
172+ return 0;
173+}
174+
175+uint Sheet08_Internal_RefreshSheet_To_32(UI_Sheet *sheet, int px0, int py0, int px1, int py1)
176+{
177+ DATA_Location2D p, r;
178+ int x, y;
179+
180+ if(sheet->parent->map == Null){
181+ #ifdef CHNOSPROJECT_DEBUG_SHEET
182+ debug("Sheet08_Internal_RefreshSheet_To_32:Null map.\n");
183+ #endif
184+ return 1;
185+ }
186+
187+ Sheet_Internal_GetLocationP(sheet, &p);
188+ Sheet_Internal_GetLocationR(sheet, &r);
189+
190+ if(p.x < px0){
191+ p.x = px0;
192+ }
193+ if(p.y < py0){
194+ p.y = py0;
195+ }
196+ if(r.x > px1){
197+ r.x = px1;
198+ }
199+ if(r.y > py1){
200+ r.y = py1;
201+ }
202+
203+ if(p.x < 0){
204+ p.x = 0;
205+ }
206+ if(p.y < 0){
207+ p.y = 0;
208+ }
209+ if(r.x >= (int)sheet->parent->size.x){
210+ r.x = (int)sheet->parent->size.x - 1;
211+ }
212+ if(r.y >= (int)sheet->parent->size.y){
213+ r.y = (int)sheet->parent->size.y - 1;
214+ }
215+
216+ for(y = p.y; y <= r.y; y++){
217+ for(x = p.x; x <= r.x; x++){
218+ if(sheet->parent->map[y * sheet->parent->size.x + x] == (uint)sheet){
219+ ((uint *)sheet->parent->vram)[y * sheet->parent->size.x + x] = RGB_08_To_32(((uchar *)sheet->vram)[(y - sheet->location.y) * sheet->size.x + (x - sheet->location.x)]);
220+ }
221+ }
222+ }
223+
224+ return 0;
225+}
226+
--- beta/tolset_chn_000/chnos_010/chnos/sheet.c (revision 314)
+++ beta/tolset_chn_000/chnos_010/chnos/sheet.c (revision 315)
@@ -67,11 +67,20 @@
6767 }
6868 }
6969
70+ if(sheet->flags.bit.vram_auto_allocated){
71+ System_Memory_Free(sheet->vram, sheet->vramsize);
72+ }
73+
74+ System_Memory_Free(sheet, sizeof(UI_Sheet));
75+
7076 return 0;
7177 }
7278
79+//vram==Null:Auto allocate
7380 uint Sheet_SetBuffer(UI_Sheet *sheet, void *vram, uint xsize, uint ysize, uint bpp)
7481 {
82+ uint retv;
83+
7584 if(sheet == Null){
7685 #ifdef CHNOSPROJECT_DEBUG_SHEET
7786 debug("Sheet_SetBuffer:Null sheet.\n");
@@ -84,39 +93,28 @@
8493 #endif
8594 return 2;
8695 }
87- if(vram == Null){
96+
97+ retv = 0;
98+ if(bpp == 8){
99+ retv = Sheet08_Internal_SetBuffer(sheet, vram, xsize, ysize, bpp);
100+ } else if(bpp == 16){
101+ retv = Sheet16_Internal_SetBuffer(sheet, vram, xsize, ysize, bpp);
102+ } else if(bpp == 32){
103+ retv = Sheet32_Internal_SetBuffer(sheet, vram, xsize, ysize, bpp);
104+ } else{
88105 #ifdef CHNOSPROJECT_DEBUG_SHEET
89- debug("Sheet_SetBuffer:Null VRAM.\n");
106+ debug("Sheet_SetBuffer:Not implemented %d bpp. Abort.\n", bpp);
90107 #endif
91- return 3;
108+ INT_3();
92109 }
93- if(xsize > SHEET_MAX_XSIZE){
110+
111+ if(retv != 0){
94112 #ifdef CHNOSPROJECT_DEBUG_SHEET
95- debug("Sheet_SetBuffer:Too large xsize.\n");
113+ debug("Sheet_SetBuffer:Function Failed.\n");
96114 #endif
97- return 4;
115+ return 10 + retv;
98116 }
99- if(ysize > SHEET_MAX_YSIZE){
100- #ifdef CHNOSPROJECT_DEBUG_SHEET
101- debug("Sheet_SetBuffer:Too large ysize.\n");
102- #endif
103- return 5;
104- }
105- if(bpp != 8 && bpp != 16 && bpp != 32){
106- #ifdef CHNOSPROJECT_DEBUG_SHEET
107- debug("Sheet_SetBuffer:Not implemented %d bpp.\n", bpp);
108- #endif
109- return 6;
110- }
111117
112- sheet->size.x = xsize;
113- sheet->size.y = ysize;
114- sheet->bpp = bpp;
115- sheet->vram = vram;
116- sheet->vramsize = xsize * ysize * bpp;
117-
118- sheet->flags.bit.buffer_configured = True;
119-
120118 #ifdef CHNOSPROJECT_DEBUG_SHEET
121119 debug("Sheet_SetBuffer:[0x%08X]\n", sheet);
122120 debug("Sheet_SetBuffer:vram:[0x%08X] xsize:%d ysize:%d bpp:%d\n", vram, xsize, ysize, bpp);
@@ -127,6 +125,8 @@
127125
128126 uint Sheet_SetParent(UI_Sheet *sheet, UI_Sheet *parent)
129127 {
128+ uint retv;
129+
130130 if(sheet == Null){
131131 #ifdef CHNOSPROJECT_DEBUG_SHEET
132132 debug("Sheet_SetParent:Null sheet.\n");
@@ -164,6 +164,12 @@
164164 debug("Sheet_SetParent:[0x%08X] parent:[0x%08X]\n", sheet, parent);
165165 #endif
166166
167+ retv = sheet->Config_Functions(sheet);
168+
169+ if(retv != 0){
170+ return 10 + retv;
171+ }
172+
167173 return 0;
168174 }
169175
@@ -181,6 +187,12 @@
181187 #endif
182188 return 1;
183189 }
190+ if(!sheet->flags.bit.buffer_configured){
191+ #ifdef CHNOSPROJECT_DEBUG_SHEET
192+ debug("Sheet_Show:Not buffer_configured sheet.\n");
193+ #endif
194+ return 2;
195+ }
184196 if(sheet->parent == Null){
185197 #ifdef CHNOSPROJECT_DEBUG_SHEET
186198 debug("Sheet_Show:Null parent.\n");
@@ -192,10 +204,10 @@
192204 if(py != SHEET_LOCATION_NOCHANGE){
193205 sheet->location.y = py;
194206 }
195- return 2;
207+ return 3;
196208 }
197209 if(sheet->flags.bit.visible == True){
198- return 3;
210+ return 4;
199211 }
200212
201213 //At First, clear old height link.
@@ -246,7 +258,7 @@
246258 sheet->location.x = px;
247259 }
248260 if(py != SHEET_LOCATION_NOCHANGE){
249- sheet->location.y = px;
261+ sheet->location.y = py;
250262 }
251263 sheet->flags.bit.visible = True;
252264 Sheet_Internal_MapRefresh(sheet, sheet->location.x, sheet->location.y, sheet->location.x + sheet->size.x - 1, sheet->location.y + sheet->size.y - 1, False);
@@ -275,14 +287,18 @@
275287 #endif
276288 return 1;
277289 }
278-
290+ if(!sheet->flags.bit.buffer_configured){
291+ #ifdef CHNOSPROJECT_DEBUG_SHEET
292+ debug("Sheet_Slide_Absolute:Not buffer_configured sheet.\n");
293+ #endif
294+ return 2;
295+ }
279296 if(sheet->parent == Null){
280297 #ifdef CHNOSPROJECT_DEBUG_SHEET
281298 debug("Sheet_Slide_Absolute:Null parent.\n");
282299 #endif
283- return 2;
300+ return 3;
284301 }
285-
286302 if(!sheet->flags.bit.visible){
287303 sheet->location.x = apx;
288304 sheet->location.y = apy;
@@ -292,7 +308,7 @@
292308 retv = Sheet_Internal_SlideSub(sheet, apx - sheet->location.x, apy - sheet->location.y);
293309
294310 if(retv != 0){
295- return retv + 2;
311+ return 10 + retv;
296312 }
297313
298314 return 0;
@@ -308,14 +324,18 @@
308324 #endif
309325 return 1;
310326 }
311-
327+ if(!sheet->flags.bit.buffer_configured){
328+ #ifdef CHNOSPROJECT_DEBUG_SHEET
329+ debug("Sheet_Slide_Relative:Not buffer_configured sheet.\n");
330+ #endif
331+ return 2;
332+ }
312333 if(sheet->parent == Null){
313334 #ifdef CHNOSPROJECT_DEBUG_SHEET
314335 debug("Sheet_Slide_Relative:Null parent.\n");
315336 #endif
316- return 2;
337+ return 3;
317338 }
318-
319339 if(!sheet->flags.bit.visible){
320340 sheet->location.x += rpx;
321341 sheet->location.y += rpy;
@@ -325,7 +345,7 @@
325345 retv = Sheet_Internal_SlideSub(sheet, rpx, rpy);
326346
327347 if(retv != 0){
328- return retv + 2;
348+ return 10 + retv;
329349 }
330350
331351 return 0;
@@ -336,6 +356,13 @@
336356 uint i;
337357 UI_Sheet *search;
338358
359+ if(!parent->flags.bit.buffer_configured){
360+ #ifdef CHNOSPROJECT_DEBUG_SHEET
361+ debug("Sheet_RefreshAllInRange:Not buffer_configured sheet.\n");
362+ #endif
363+ return 1;
364+ }
365+
339366 search = parent->child;
340367 for(i = 0; i < SHEET_MAX_CHILDREN; i++){
341368 if(search == Null){
@@ -352,6 +379,13 @@
352379
353380 uint Sheet_RefreshSheet(UI_Sheet *sheet, int px0, int py0, int px1, int py1)
354381 {
382+ if(!sheet->flags.bit.buffer_configured){
383+ #ifdef CHNOSPROJECT_DEBUG_SHEET
384+ debug("Sheet_RefreshSheet:Not buffer_configured sheet.\n");
385+ #endif
386+ return 1;
387+ }
388+
355389 return Sheet_Internal_RefreshSheet(sheet, px0 + sheet->location.x, py0 + sheet->location.y, px1 + sheet->location.x, py1 + sheet->location.y);
356390 }
357391
--- beta/tolset_chn_000/chnos_010/chnos/shtfunc.c (revision 314)
+++ beta/tolset_chn_000/chnos_010/chnos/shtfunc.c (revision 315)
@@ -389,8 +389,7 @@
389389 //親グローバル座標でのシートvramリフレッシュ。
390390 uint Sheet_Internal_RefreshSheet(UI_Sheet *sheet, int px0, int py0, int px1, int py1)
391391 {
392- DATA_Location2D p, r;
393- int x, y;
392+ uint retv;
394393
395394 if(sheet->parent == Null){
396395 #ifdef CHNOSPROJECT_DEBUG_SHEET
@@ -399,54 +398,30 @@
399398 return 1;
400399 }
401400
402- if(sheet->parent->map == Null){
401+ if(!sheet->parent->flags.bit.buffer_configured){
403402 #ifdef CHNOSPROJECT_DEBUG_SHEET
404- debug("Sheet_Internal_RefreshSheet:Null map.\n");
403+ debug("Sheet_RefreshSheet:Not buffer_configured parent.\n");
405404 #endif
406405 return 2;
407406 }
408407
408+ if(sheet->RefreshSheet == Null){
409+ #ifdef CHNOSPROJECT_DEBUG_SHEET
410+ debug("Sheet_Internal_RefreshSheet:Null Refresh function.\n");
411+ #endif
412+ return 3;
413+ }
414+
409415 if(!sheet->flags.bit.visible){
410416 return 0;
411417 }
412418
413- Sheet_Internal_GetLocationP(sheet, &p);
414- Sheet_Internal_GetLocationR(sheet, &r);
419+ retv = sheet->RefreshSheet(sheet, px0, py0, px1, py1);
415420
416- if(p.x < px0){
417- p.x = px0;
421+ if(retv != 0){
422+ return 10 + retv;
418423 }
419- if(p.y < py0){
420- p.y = py0;
421- }
422- if(r.x > px1){
423- r.x = px1;
424- }
425- if(r.y > py1){
426- r.y = py1;
427- }
428424
429- if(p.x < 0){
430- p.x = 0;
431- }
432- if(p.y < 0){
433- p.y = 0;
434- }
435- if(r.x >= (int)sheet->parent->size.x){
436- r.x = (int)sheet->parent->size.x - 1;
437- }
438- if(r.y >= (int)sheet->parent->size.y){
439- r.y = (int)sheet->parent->size.y - 1;
440- }
441-
442- for(y = p.y; y <= r.y; y++){
443- for(x = p.x; x <= r.x; x++){
444- if(sheet->parent->map[y * sheet->parent->size.x + x] == (uint)sheet){
445- ((uchar *)sheet->parent->vram)[y * sheet->parent->size.x + x] = ((uchar *)sheet->vram)[(y - sheet->location.y) * sheet->size.x + (x - sheet->location.x)];
446- }
447- }
448- }
449-
450425 return 0;
451426 }
452427
--- beta/tolset_chn_000/chnos_010/chnos/system.c (revision 314)
+++ beta/tolset_chn_000/chnos_010/chnos/system.c (revision 315)
@@ -386,6 +386,11 @@
386386 return System.DisplayController;
387387 }
388388
389+uint System_Memory_Get_FreeSize(void)
390+{
391+ return Memory_Get_FreeSize(System.MemoryController);
392+}
393+
389394 //
390395 void System_Check_Memory(void)
391396 {
--- beta/tolset_chn_000/chnos_010/chnos/makeset.txt (revision 314)
+++ beta/tolset_chn_000/chnos_010/chnos/makeset.txt (revision 315)
@@ -1,3 +1,3 @@
11
2-OBJS_BOOTPACK = nasfunc0.obj nasfunc1.obj nasfunc2.obj hankaku.obj chnlogo.obj callbios.obj cfunc.obj display.obj draw08.obj draw16.obj draw32.obj drawing.obj dsctbl.obj emu86.obj emu86asm.obj error.obj fifo.obj fmt_bmp.obj intrpt.obj keyboard.obj memory.obj mtask.obj serial.obj sheet.obj shtfunc.obj system.obj timer.obj vgatmode.obj xception.obj bootpack.obj
2+OBJS_BOOTPACK = nasfunc0.obj nasfunc1.obj nasfunc2.obj hankaku.obj chnlogo.obj callbios.obj cfunc.obj color.obj display.obj draw08.obj draw16.obj draw32.obj drawing.obj dsctbl.obj emu86.obj emu86asm.obj error.obj fifo.obj fmt_bmp.obj intrpt.obj keyboard.obj memory.obj mtask.obj serial.obj sheet.obj sht08.obj sht16.obj sht32.obj shtfunc.obj system.obj timer.obj vgatmode.obj xception.obj bootpack.obj
33 HEADS_BOOTPACK = core.h coredef0.h coredef1.h coredef2.h coredef3.h keyid.h
--- beta/tolset_chn_000/chnos_010/chnos/drawing.c (revision 314)
+++ beta/tolset_chn_000/chnos_010/chnos/drawing.c (revision 315)
@@ -62,68 +62,6 @@
6262 return;
6363 }
6464
65-uchar RGB_32_To_08(uint c32)
66-{
67- uchar c8;
68- uchar c[4];
69-
70- c[3] = (c32 << 24) >> 24;
71- c[2] = (c32 << 16) >> 24;
72- c[1] = (c32 << 8) >> 24;
73- c[0] = (c32 >> 24);
74-
75- c[1] = c[1] / 51;
76- c[2] = c[2] / 51;
77- c[3] = c[3] / 51;
78-
79- c8 = (c[1] + c[2] * 6 + c[3] * 36) + 16;
80-
81- return c8;
82-}
83-
84-uchar RGB_32_To_08_xy(uint c32, int x, int y)
85-{
86- static int table[4] = { 3, 1, 0, 2 };
87- uchar c8;
88- uchar c[4];
89- int i;
90-
91- c[3] = (c32 << 24) >> 24;
92- c[2] = (c32 << 16) >> 24;
93- c[1] = (c32 << 8) >> 24;
94- c[0] = (c32 >> 24);
95-
96- x &= 1; /* 偶数か奇数か */
97- y &= 1;
98-
99- i = table[x + y * 2]; /* 中間色を作るための定数 */
100- c[1] = (c[1] * 21) / 256; /* これで 0〜20 になる */
101- c[2] = (c[2] * 21) / 256;
102- c[3] = (c[3] * 21) / 256;
103- c[1] = (c[1] + i) / 4; /* これで 0〜5 になる */
104- c[2] = (c[2] + i) / 4;
105- c[3] = (c[3] + i) / 4;
106-
107- c8 = 16 + c[1] + c[2] * 6 + c[3] * 36;
108-
109- return c8;
110-}
111-
112-ushort RGB_32_To_16(uint c32)
113-{
114- ushort c16;
115- uchar c[4];
116-
117- c[3] = (c32 << 24) >> 24;
118- c[2] = (c32 << 16) >> 24;
119- c[1] = (c32 << 8) >> 24;
120- c[0] = (c32 >> 24);
121-
122- c16 = ((c[1] >> 3) << 11 | (c[2] >> 2) << 5 | (c[3] >> 3));
123-
124- return c16;
125-}
126-
12765 void Drawing_Draw_Line_PQ(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1)
12866 {
12967 uint lx;
--- beta/tolset_chn_000/chnos_010/chnos/core.h (revision 314)
+++ beta/tolset_chn_000/chnos_010/chnos/core.h (revision 315)
@@ -38,6 +38,16 @@
3838 void CFunction_vsnprintf_To_String_From_Hex_Lower(CFunction_vsnprintf_WorkArea *work, uint hex);
3939 void CFunction_vsnprintf_To_String_From_Decimal_Unsigned(CFunction_vsnprintf_WorkArea *work, uint d);
4040
41+/*color.c 色関連*/
42+extern uint RGB_Table_08[16];
43+ushort RGB_08_To_16(uchar c8);
44+uint RGB_08_To_32(uchar c8);
45+uchar RGB_16_To_08(ushort c16);
46+uint RGB_16_To_32(ushort c16);
47+uchar RGB_32_To_08(uint c32);
48+uchar RGB_32_To_08_xy(uint c32, int x, int y);
49+ushort RGB_32_To_16(uint c32);
50+
4151 /*display.c ディスプレイ制御関連*/
4252 IO_DisplayControl *Initialise_Display(void);
4353 uint Display_VESA_Set_VideoMode(IO_DisplayControl *ctrl, uint index);
@@ -71,9 +81,6 @@
7181 void Drawing_Invalid_Draw_Point(void *vram, uint xsize, uint x, uint y, uint c);
7282 void Drawing_Invalid_Draw_Line_PQ(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1);
7383 void Initialise_Drawing(void);
74-uchar RGB_32_To_08(uint c32);
75-uchar RGB_32_To_08_xy(uint c32, int x, int y);
76-ushort RGB_32_To_16(uint c32);
7784 void Drawing_Draw_Line_PQ(void *vram, uint xsize, uint c, uint x0, uint y0, uint x1, uint y1);
7885 void Drawing_Draw_Circle(void *vram, uint xsize, uint x, uint y, uint c, uint r);
7986 void Drawing_Fill_Circle(void *vram, uint xsize, uint x, uint y, uint c, uint r);
@@ -219,6 +226,27 @@
219226 uint Sheet_RefreshAllInRange(UI_Sheet *parent, int px0, int py0, int px1, int py1);
220227 uint Sheet_RefreshSheet(UI_Sheet *sheet, int px0, int py0, int px1, int py1);
221228
229+/*sht08.c 8bitカラー シート関連*/
230+uint Sheet08_Internal_SetBuffer(UI_Sheet *sheet, void *vram, uint xsize, uint ysize, uint bpp);
231+uint Sheet08_Config_Functions(UI_Sheet *sheet);
232+uint Sheet08_Internal_RefreshSheet_To_08(UI_Sheet *sheet, int px0, int py0, int px1, int py1);
233+uint Sheet08_Internal_RefreshSheet_To_16(UI_Sheet *sheet, int px0, int py0, int px1, int py1);
234+uint Sheet08_Internal_RefreshSheet_To_32(UI_Sheet *sheet, int px0, int py0, int px1, int py1);
235+
236+/*sht16.c 16bitカラー シート関連*/
237+uint Sheet16_Internal_SetBuffer(UI_Sheet *sheet, void *vram, uint xsize, uint ysize, uint bpp);
238+uint Sheet16_Config_Functions(UI_Sheet *sheet);
239+uint Sheet16_Internal_RefreshSheet_To_16(UI_Sheet *sheet, int px0, int py0, int px1, int py1);
240+uint Sheet16_Internal_RefreshSheet_To_08(UI_Sheet *sheet, int px0, int py0, int px1, int py1);
241+uint Sheet16_Internal_RefreshSheet_To_32(UI_Sheet *sheet, int px0, int py0, int px1, int py1);
242+
243+/*sht32.c 32bitカラー シート関連*/
244+uint Sheet32_Internal_SetBuffer(UI_Sheet *sheet, void *vram, uint xsize, uint ysize, uint bpp);
245+uint Sheet32_Config_Functions(UI_Sheet *sheet);
246+uint Sheet32_Internal_RefreshSheet_To_32(UI_Sheet *sheet, int px0, int py0, int px1, int py1);
247+uint Sheet32_Internal_RefreshSheet_To_16(UI_Sheet *sheet, int px0, int py0, int px1, int py1);
248+uint Sheet32_Internal_RefreshSheet_To_08_xy(UI_Sheet *sheet, int px0, int py0, int px1, int py1);
249+
222250 /*shtfunc.c シート内部関数*/
223251 uint Sheet_Internal_GetLocationP(UI_Sheet *sheet, DATA_Location2D *dest);
224252 uint Sheet_Internal_GetLocationQ(UI_Sheet *sheet, DATA_Location2D *dest);
@@ -258,6 +286,7 @@
258286 DATA_FIFO32 *System_FIFO32_Initialise(uint size);
259287 uint System_Display_VESA_Set_VideoMode(uint index);
260288 IO_DisplayControl *System_Display_Get_Controller(void);
289+uint System_Memory_Get_FreeSize(void);
261290
262291 /*timer.c タイマー関連*/
263292 UI_TimerControl *Initialise_ProgrammableIntervalTimer(void);
--- beta/tolset_chn_000/chnos_010/chnos/bootpack.c (revision 314)
+++ beta/tolset_chn_000/chnos_010/chnos/bootpack.c (revision 315)
@@ -11,6 +11,7 @@
1111 uint i;
1212 IO_DisplayControl *disp_ctrl;
1313 UI_Sheet *vramsheet, *testsheet, *testsheet2, *sheet_desktop;
14+ UI_Sheet *sheet08, *sheet16, *sheet32;
1415 int x, y;
1516 UI_Timer *timer1, *timer2, *timer3;
1617 uint counter1, counter2, counter3;
@@ -97,21 +98,25 @@
9798 testsheet = Sheet_Initialise();
9899 testsheet2 = Sheet_Initialise();
99100 sheet_desktop = Sheet_Initialise();
101+ sheet08 = Sheet_Initialise();
102+ sheet16 = Sheet_Initialise();
103+ sheet32 = Sheet_Initialise();
100104
101105 Sheet_SetBuffer(vramsheet, disp_ctrl->vram, disp_ctrl->xsize, disp_ctrl->ysize, disp_ctrl->bpp);
102- Sheet_SetBuffer(testsheet, System_Memory_Allocate(256 * 128 * 1), 256, 128, 8);
103- Sheet_SetBuffer(testsheet2, System_Memory_Allocate(128 * 64 * 1), 128, 64, 8);
104- Sheet_SetBuffer(sheet_desktop, System_Memory_Allocate(disp_ctrl->xsize * disp_ctrl->ysize * (disp_ctrl->bpp >> 3)), disp_ctrl->xsize, disp_ctrl->ysize, disp_ctrl->bpp);
106+ Sheet_SetBuffer(testsheet, Null, 256, 128, 8);
107+ Sheet_SetBuffer(testsheet2, Null, 128, 64, 8);
108+ Sheet_SetBuffer(sheet_desktop, Null, disp_ctrl->xsize, disp_ctrl->ysize, disp_ctrl->bpp);
109+ Sheet_SetBuffer(sheet08, Null, 128, 128, 8);
110+ Sheet_SetBuffer(sheet16, Null, 128, 128, 16);
111+ Sheet_SetBuffer(sheet32, Null, 128, 128, 32);
105112
106- for(y = 0; y < disp_ctrl->ysize; y++){
107- for(x = 0; x < disp_ctrl->xsize; x++){
108- ((uchar*)sheet_desktop->vram)[y * sheet_desktop->size.x + x] = ((uchar *)disp_ctrl->vram)[y * disp_ctrl->xsize + x];
109- }
113+ for(i = 0; i < sheet_desktop->vramsize; i++){
114+ ((uchar *)sheet_desktop->vram)[i] = ((uchar *)disp_ctrl->vram)[i];
110115 }
111116
112117 for(y = 0; y < testsheet->size.y; y++){
113118 for(x = 0; x < testsheet->size.x; x++){
114- ((uchar*)testsheet->vram)[y * testsheet->size.x + x] = x * 2;
119+ ((uchar *)testsheet->vram)[y * testsheet->size.x + x] = x * 2;
115120 }
116121 }
117122 Drawing08_Fill_Rectangle(testsheet->vram, testsheet->size.x, 0xc6c6c6, 4, 24, testsheet->size.x - 4 - 1, testsheet->size.y - 4 - 1);
@@ -118,14 +123,36 @@
118123
119124 for(y = 0; y < testsheet2->size.y; y++){
120125 for(x = 0; x < testsheet2->size.x; x++){
121- ((uchar*)testsheet2->vram)[y * testsheet2->size.x + x] = y * 2 + x;
126+ ((uchar *)testsheet2->vram)[y * testsheet2->size.x + x] = y * 2 + x;
122127 }
123128 }
124129 Drawing08_Fill_Rectangle(testsheet2->vram, testsheet2->size.x, 0xc6c6c6, 4, 24, testsheet2->size.x - 4 - 1, testsheet2->size.y - 4 - 1);
125130
126131 Drawing08_Put_String(testsheet->vram, testsheet->size.x, 4, 4, 0xffffff, "TestSheet");
132+ snprintf(s, sizeof(s), "Memory:%d Bytes", System_Get_PhisycalMemorySize());
133+ Drawing08_Put_String(testsheet->vram, testsheet->size.x, 8, 24 + 16 * 4, 0xffffff, s);
134+
127135 Drawing08_Put_String(testsheet2->vram, testsheet2->size.x, 4, 4, 0xffffff, "TestSheet2");
128136
137+
138+ for(y = 0; y < sheet08->size.y; y++){
139+ for(x = 0; x < sheet08->size.x; x++){
140+ ((uchar *)sheet08->vram)[y * sheet08->size.x + x] = RGB_32_To_08(((x * 2) << 16) | ((y * 2) << 8) | (x + y));
141+ }
142+ }
143+
144+ for(y = 0; y < sheet16->size.y; y++){
145+ for(x = 0; x < sheet16->size.x; x++){
146+ ((ushort *)sheet16->vram)[y * sheet16->size.x + x] = RGB_32_To_16(((x * 2) << 16) | ((y * 2) << 8) | (x + y));
147+ }
148+ }
149+
150+ for(y = 0; y < sheet32->size.y; y++){
151+ for(x = 0; x < sheet32->size.x; x++){
152+ ((uint *)sheet32->vram)[y * sheet32->size.x + x] = ((x * 2) << 16) | ((y * 2) << 8) | (x + y);
153+ }
154+ }
155+
129156 Sheet_SetParent(sheet_desktop, vramsheet);
130157 Sheet_Show(sheet_desktop, 0, 0, 0);
131158
@@ -135,6 +162,15 @@
135162 Sheet_SetParent(testsheet2, vramsheet);
136163 Sheet_Show(testsheet2, 2, 80, 80);
137164
165+ Sheet_SetParent(sheet08, vramsheet);
166+ Sheet_Show(sheet08, 3, 20, vramsheet->size.y >> 1);
167+
168+ Sheet_SetParent(sheet16, vramsheet);
169+ Sheet_Show(sheet16, 2, 220, vramsheet->size.y >> 1);
170+
171+ Sheet_SetParent(sheet32, vramsheet);
172+ Sheet_Show(sheet32, 2, 420, vramsheet->size.y >> 1);
173+
138174 timer1 = Timer_Initialise();
139175 Timer_Config(timer1, 50, mytask->fifo, 11, True);
140176 counter1 = 0;
@@ -207,6 +243,11 @@
207243 Drawing08_Put_String(testsheet->vram, testsheet->size.x, 8, 24 + 16 * 3, 0xffffff, s);
208244 Sheet_RefreshSheet(testsheet, 8, 24 + 16 * 3, 8 + (20 * 8) - 1, 24 + (16 * 4) - 1);
209245 counter3++;
246+
247+ Drawing08_Fill_Rectangle(testsheet->vram, testsheet->size.x, 0xc6c6c6, 8, 24 + 16 * 5, 8 + (20 * 8) - 1, 24 + (16 * 6) - 1);
248+ snprintf(s, sizeof(s), "Free :%d Bytes", System_Memory_Get_FreeSize());
249+ Drawing08_Put_String(testsheet->vram, testsheet->size.x, 8, 24 + 16 * 5, 0xffffff, s);
250+ Sheet_RefreshSheet(testsheet, 8, 24 + 16 * 5, 8 + (20 * 8) - 1, 24 + (16 * 6) - 1);
210251 }
211252 }
212253 }
--- beta/tolset_chn_000/chnos_010/chnos/sht32.c (nonexistent)
+++ beta/tolset_chn_000/chnos_010/chnos/sht32.c (revision 315)
@@ -0,0 +1,226 @@
1+
2+#include "core.h"
3+
4+uint Sheet32_Internal_SetBuffer(UI_Sheet *sheet, void *vram, uint xsize, uint ysize, uint bpp)
5+{
6+ if(xsize > SHEET_MAX_XSIZE){
7+ #ifdef CHNOSPROJECT_DEBUG_SHEET
8+ debug("Sheet32_Internal_SetBuffer:Too large xsize.\n");
9+ #endif
10+ return 1;
11+ }
12+ if(ysize > SHEET_MAX_YSIZE){
13+ #ifdef CHNOSPROJECT_DEBUG_SHEET
14+ debug("Sheet32_Internal_SetBuffer:Too large ysize.\n");
15+ #endif
16+ return 2;
17+ }
18+
19+ sheet->size.x = xsize;
20+ sheet->size.y = ysize;
21+ sheet->bpp = bpp;
22+
23+ if(vram == Null){
24+ sheet->vram = System_Memory_Allocate(xsize * ysize * 4);
25+ sheet->flags.bit.vram_auto_allocated = True;
26+ #ifdef CHNOSPROJECT_DEBUG_SHEET
27+ debug("Sheet32_Internal_SetBuffer:Auto Allocation.\n");
28+ #endif
29+ } else{
30+ sheet->vram = vram;
31+ }
32+
33+ sheet->vramsize = xsize * ysize * 4;
34+ sheet->Config_Functions = &Sheet32_Config_Functions;
35+
36+ sheet->flags.bit.buffer_configured = True;
37+
38+ return 0;
39+}
40+
41+//set function address from parent's bpp and own bpp.
42+uint Sheet32_Config_Functions(UI_Sheet *sheet)
43+{
44+ if(sheet == Null){
45+ #ifdef CHNOSPROJECT_DEBUG_SHEET
46+ debug("Sheet32_Config_Functions:Null sheet.\n");
47+ #endif
48+ return 0;
49+ }
50+ if(sheet->parent == Null){
51+ #ifdef CHNOSPROJECT_DEBUG_SHEET
52+ debug("Sheet32_Config_Functions:Null parent.\n");
53+ #endif
54+ return 1;
55+ }
56+
57+ if(sheet->parent->bpp == 32){
58+ sheet->RefreshSheet = &Sheet32_Internal_RefreshSheet_To_32;
59+ } else if(sheet->parent->bpp == 16){
60+ sheet->RefreshSheet = &Sheet32_Internal_RefreshSheet_To_16;
61+ } else if(sheet->parent->bpp == 8){
62+ sheet->RefreshSheet = &Sheet32_Internal_RefreshSheet_To_08_xy;
63+ } else{
64+ #ifdef CHNOSPROJECT_DEBUG_SHEET
65+ debug("Sheet32_Config_Functions:Not implemented refresh function to bpp %d.\n", sheet->parent->bpp);
66+ #endif
67+ }
68+ return 0;
69+}
70+
71+uint Sheet32_Internal_RefreshSheet_To_32(UI_Sheet *sheet, int px0, int py0, int px1, int py1)
72+{
73+ DATA_Location2D p, r;
74+ int x, y;
75+
76+ if(sheet->parent->map == Null){
77+ #ifdef CHNOSPROJECT_DEBUG_SHEET
78+ debug("Sheet32_Internal_RefreshSheet_To_32:Null map.\n");
79+ #endif
80+ return 1;
81+ }
82+
83+ Sheet_Internal_GetLocationP(sheet, &p);
84+ Sheet_Internal_GetLocationR(sheet, &r);
85+
86+ if(p.x < px0){
87+ p.x = px0;
88+ }
89+ if(p.y < py0){
90+ p.y = py0;
91+ }
92+ if(r.x > px1){
93+ r.x = px1;
94+ }
95+ if(r.y > py1){
96+ r.y = py1;
97+ }
98+
99+ if(p.x < 0){
100+ p.x = 0;
101+ }
102+ if(p.y < 0){
103+ p.y = 0;
104+ }
105+ if(r.x >= (int)sheet->parent->size.x){
106+ r.x = (int)sheet->parent->size.x - 1;
107+ }
108+ if(r.y >= (int)sheet->parent->size.y){
109+ r.y = (int)sheet->parent->size.y - 1;
110+ }
111+
112+ for(y = p.y; y <= r.y; y++){
113+ for(x = p.x; x <= r.x; x++){
114+ if(sheet->parent->map[y * sheet->parent->size.x + x] == (uint)sheet){
115+ ((uint *)sheet->parent->vram)[y * sheet->parent->size.x + x] = ((uint *)sheet->vram)[(y - sheet->location.y) * sheet->size.x + (x - sheet->location.x)];
116+ }
117+ }
118+ }
119+
120+ return 0;
121+}
122+
123+uint Sheet32_Internal_RefreshSheet_To_16(UI_Sheet *sheet, int px0, int py0, int px1, int py1)
124+{
125+ DATA_Location2D p, r;
126+ int x, y;
127+
128+ if(sheet->parent->map == Null){
129+ #ifdef CHNOSPROJECT_DEBUG_SHEET
130+ debug("Sheet32_Internal_RefreshSheet_To_16:Null map.\n");
131+ #endif
132+ return 1;
133+ }
134+
135+ Sheet_Internal_GetLocationP(sheet, &p);
136+ Sheet_Internal_GetLocationR(sheet, &r);
137+
138+ if(p.x < px0){
139+ p.x = px0;
140+ }
141+ if(p.y < py0){
142+ p.y = py0;
143+ }
144+ if(r.x > px1){
145+ r.x = px1;
146+ }
147+ if(r.y > py1){
148+ r.y = py1;
149+ }
150+
151+ if(p.x < 0){
152+ p.x = 0;
153+ }
154+ if(p.y < 0){
155+ p.y = 0;
156+ }
157+ if(r.x >= (int)sheet->parent->size.x){
158+ r.x = (int)sheet->parent->size.x - 1;
159+ }
160+ if(r.y >= (int)sheet->parent->size.y){
161+ r.y = (int)sheet->parent->size.y - 1;
162+ }
163+
164+ for(y = p.y; y <= r.y; y++){
165+ for(x = p.x; x <= r.x; x++){
166+ if(sheet->parent->map[y * sheet->parent->size.x + x] == (uint)sheet){
167+ ((ushort *)sheet->parent->vram)[y * sheet->parent->size.x + x] = RGB_32_To_16(((uint *)sheet->vram)[(y - sheet->location.y) * sheet->size.x + (x - sheet->location.x)]);
168+ }
169+ }
170+ }
171+
172+ return 0;
173+}
174+
175+
176+uint Sheet32_Internal_RefreshSheet_To_08_xy(UI_Sheet *sheet, int px0, int py0, int px1, int py1)
177+{
178+ DATA_Location2D p, r;
179+ int x, y;
180+
181+ if(sheet->parent->map == Null){
182+ #ifdef CHNOSPROJECT_DEBUG_SHEET
183+ debug("Sheet32_Internal_RefreshSheet_To_08_xy:Null map.\n");
184+ #endif
185+ return 1;
186+ }
187+
188+ Sheet_Internal_GetLocationP(sheet, &p);
189+ Sheet_Internal_GetLocationR(sheet, &r);
190+
191+ if(p.x < px0){
192+ p.x = px0;
193+ }
194+ if(p.y < py0){
195+ p.y = py0;
196+ }
197+ if(r.x > px1){
198+ r.x = px1;
199+ }
200+ if(r.y > py1){
201+ r.y = py1;
202+ }
203+
204+ if(p.x < 0){
205+ p.x = 0;
206+ }
207+ if(p.y < 0){
208+ p.y = 0;
209+ }
210+ if(r.x >= (int)sheet->parent->size.x){
211+ r.x = (int)sheet->parent->size.x - 1;
212+ }
213+ if(r.y >= (int)sheet->parent->size.y){
214+ r.y = (int)sheet->parent->size.y - 1;
215+ }
216+
217+ for(y = p.y; y <= r.y; y++){
218+ for(x = p.x; x <= r.x; x++){
219+ if(sheet->parent->map[y * sheet->parent->size.x + x] == (uint)sheet){
220+ ((uchar *)sheet->parent->vram)[y * sheet->parent->size.x + x] = RGB_32_To_08_xy(((uint *)sheet->vram)[(y - sheet->location.y) * sheet->size.x + (x - sheet->location.x)], x, y);
221+ }
222+ }
223+ }
224+
225+ return 0;
226+}
--- beta/tolset_chn_000/chnos_010/chnos/sht16.c (nonexistent)
+++ beta/tolset_chn_000/chnos_010/chnos/sht16.c (revision 315)
@@ -0,0 +1,226 @@
1+
2+#include "core.h"
3+
4+uint Sheet16_Internal_SetBuffer(UI_Sheet *sheet, void *vram, uint xsize, uint ysize, uint bpp)
5+{
6+ if(xsize > SHEET_MAX_XSIZE){
7+ #ifdef CHNOSPROJECT_DEBUG_SHEET
8+ debug("Sheet16_Internal_SetBuffer:Too large xsize.\n");
9+ #endif
10+ return 1;
11+ }
12+ if(ysize > SHEET_MAX_YSIZE){
13+ #ifdef CHNOSPROJECT_DEBUG_SHEET
14+ debug("Sheet16_Internal_SetBuffer:Too large ysize.\n");
15+ #endif
16+ return 2;
17+ }
18+
19+ sheet->size.x = xsize;
20+ sheet->size.y = ysize;
21+ sheet->bpp = bpp;
22+
23+ if(vram == Null){
24+ sheet->vram = System_Memory_Allocate(xsize * ysize * 2);
25+ sheet->flags.bit.vram_auto_allocated = True;
26+ #ifdef CHNOSPROJECT_DEBUG_SHEET
27+ debug("Sheet16_Internal_SetBuffer:Auto Allocation.\n");
28+ #endif
29+ } else{
30+ sheet->vram = vram;
31+ }
32+
33+ sheet->vramsize = xsize * ysize * 2;
34+ sheet->Config_Functions = &Sheet16_Config_Functions;
35+
36+ sheet->flags.bit.buffer_configured = True;
37+
38+ return 0;
39+}
40+
41+//set function address from parent's bpp and own bpp.
42+uint Sheet16_Config_Functions(UI_Sheet *sheet)
43+{
44+ if(sheet == Null){
45+ #ifdef CHNOSPROJECT_DEBUG_SHEET
46+ debug("Sheet16_Config_Functions:Null sheet.\n");
47+ #endif
48+ return 0;
49+ }
50+ if(sheet->parent == Null){
51+ #ifdef CHNOSPROJECT_DEBUG_SHEET
52+ debug("Sheet16_Config_Functions:Null parent.\n");
53+ #endif
54+ return 1;
55+ }
56+
57+ if(sheet->parent->bpp == 16){
58+ sheet->RefreshSheet = &Sheet16_Internal_RefreshSheet_To_16;
59+ } else if(sheet->parent->bpp == 8){
60+ sheet->RefreshSheet = &Sheet16_Internal_RefreshSheet_To_08;
61+ } else if(sheet->parent->bpp == 32){
62+ sheet->RefreshSheet = &Sheet16_Internal_RefreshSheet_To_32;
63+ } else{
64+ #ifdef CHNOSPROJECT_DEBUG_SHEET
65+ debug("Sheet16_Config_Functions:Not implemented refresh function to bpp %d.\n", sheet->parent->bpp);
66+ #endif
67+ }
68+ return 0;
69+}
70+
71+uint Sheet16_Internal_RefreshSheet_To_16(UI_Sheet *sheet, int px0, int py0, int px1, int py1)
72+{
73+ DATA_Location2D p, r;
74+ int x, y;
75+
76+ if(sheet->parent->map == Null){
77+ #ifdef CHNOSPROJECT_DEBUG_SHEET
78+ debug("Sheet16_Internal_RefreshSheet_To_16:Null map.\n");
79+ #endif
80+ return 1;
81+ }
82+
83+ Sheet_Internal_GetLocationP(sheet, &p);
84+ Sheet_Internal_GetLocationR(sheet, &r);
85+
86+ if(p.x < px0){
87+ p.x = px0;
88+ }
89+ if(p.y < py0){
90+ p.y = py0;
91+ }
92+ if(r.x > px1){
93+ r.x = px1;
94+ }
95+ if(r.y > py1){
96+ r.y = py1;
97+ }
98+
99+ if(p.x < 0){
100+ p.x = 0;
101+ }
102+ if(p.y < 0){
103+ p.y = 0;
104+ }
105+ if(r.x >= (int)sheet->parent->size.x){
106+ r.x = (int)sheet->parent->size.x - 1;
107+ }
108+ if(r.y >= (int)sheet->parent->size.y){
109+ r.y = (int)sheet->parent->size.y - 1;
110+ }
111+
112+ for(y = p.y; y <= r.y; y++){
113+ for(x = p.x; x <= r.x; x++){
114+ if(sheet->parent->map[y * sheet->parent->size.x + x] == (uint)sheet){
115+ ((ushort *)sheet->parent->vram)[y * sheet->parent->size.x + x] = ((ushort *)sheet->vram)[(y - sheet->location.y) * sheet->size.x + (x - sheet->location.x)];
116+ }
117+ }
118+ }
119+
120+ return 0;
121+}
122+
123+uint Sheet16_Internal_RefreshSheet_To_08(UI_Sheet *sheet, int px0, int py0, int px1, int py1)
124+{
125+ DATA_Location2D p, r;
126+ int x, y;
127+
128+ if(sheet->parent->map == Null){
129+ #ifdef CHNOSPROJECT_DEBUG_SHEET
130+ debug("Sheet16_Internal_RefreshSheet_To_08:Null map.\n");
131+ #endif
132+ return 1;
133+ }
134+
135+ Sheet_Internal_GetLocationP(sheet, &p);
136+ Sheet_Internal_GetLocationR(sheet, &r);
137+
138+ if(p.x < px0){
139+ p.x = px0;
140+ }
141+ if(p.y < py0){
142+ p.y = py0;
143+ }
144+ if(r.x > px1){
145+ r.x = px1;
146+ }
147+ if(r.y > py1){
148+ r.y = py1;
149+ }
150+
151+ if(p.x < 0){
152+ p.x = 0;
153+ }
154+ if(p.y < 0){
155+ p.y = 0;
156+ }
157+ if(r.x >= (int)sheet->parent->size.x){
158+ r.x = (int)sheet->parent->size.x - 1;
159+ }
160+ if(r.y >= (int)sheet->parent->size.y){
161+ r.y = (int)sheet->parent->size.y - 1;
162+ }
163+
164+ for(y = p.y; y <= r.y; y++){
165+ for(x = p.x; x <= r.x; x++){
166+ if(sheet->parent->map[y * sheet->parent->size.x + x] == (uint)sheet){
167+ ((uchar *)sheet->parent->vram)[y * sheet->parent->size.x + x] = RGB_16_To_08(((ushort *)sheet->vram)[(y - sheet->location.y) * sheet->size.x + (x - sheet->location.x)]);
168+ }
169+ }
170+ }
171+
172+ return 0;
173+}
174+
175+uint Sheet16_Internal_RefreshSheet_To_32(UI_Sheet *sheet, int px0, int py0, int px1, int py1)
176+{
177+ DATA_Location2D p, r;
178+ int x, y;
179+
180+ if(sheet->parent->map == Null){
181+ #ifdef CHNOSPROJECT_DEBUG_SHEET
182+ debug("Sheet16_Internal_RefreshSheet_To_32:Null map.\n");
183+ #endif
184+ return 1;
185+ }
186+
187+ Sheet_Internal_GetLocationP(sheet, &p);
188+ Sheet_Internal_GetLocationR(sheet, &r);
189+
190+ if(p.x < px0){
191+ p.x = px0;
192+ }
193+ if(p.y < py0){
194+ p.y = py0;
195+ }
196+ if(r.x > px1){
197+ r.x = px1;
198+ }
199+ if(r.y > py1){
200+ r.y = py1;
201+ }
202+
203+ if(p.x < 0){
204+ p.x = 0;
205+ }
206+ if(p.y < 0){
207+ p.y = 0;
208+ }
209+ if(r.x >= (int)sheet->parent->size.x){
210+ r.x = (int)sheet->parent->size.x - 1;
211+ }
212+ if(r.y >= (int)sheet->parent->size.y){
213+ r.y = (int)sheet->parent->size.y - 1;
214+ }
215+
216+ for(y = p.y; y <= r.y; y++){
217+ for(x = p.x; x <= r.x; x++){
218+ if(sheet->parent->map[y * sheet->parent->size.x + x] == (uint)sheet){
219+ ((uint *)sheet->parent->vram)[y * sheet->parent->size.x + x] = RGB_16_To_32(((ushort *)sheet->vram)[(y - sheet->location.y) * sheet->size.x + (x - sheet->location.x)]);
220+ }
221+ }
222+ }
223+
224+ return 0;
225+}
226+
--- beta/tolset_chn_000/chnos_010/chnos/color.c (nonexistent)
+++ beta/tolset_chn_000/chnos_010/chnos/color.c (revision 315)
@@ -0,0 +1,159 @@
1+
2+#include "core.h"
3+
4+uint RGB_Table_08[16] = {
5+ 0x00000000, //黒
6+ 0x00ff0000, //赤
7+ 0x0000ff00, //緑
8+ 0x00ffff00, //黄
9+ 0x000000ff, //青
10+ 0x0000ffff, //水
11+ 0x00ffffff, //白
12+ 0x00c6c6c6, //明るい灰色
13+ 0x00840000, //暗い赤
14+ 0x00008400, //暗い緑
15+ 0x00848400, //暗い黄
16+ 0x00000084, //暗い青
17+ 0x00840084, //紫
18+ 0x00008484, //暗い水
19+ 0x00848484 //暗い灰色
20+};
21+
22+ushort RGB_08_To_16(uchar c8)
23+{
24+ RGB32 c32;
25+
26+ if(c8 < 16){
27+ c32.c32 = RGB_Table_08[c8];
28+ return ((c32.bit.r / 7) << 11) | ((c32.bit.g / 7) << (5 + 1) | (c32.bit.b / 7));
29+ }
30+
31+ if(c8 >= 16 + 216){
32+ return 0x0000;
33+ }
34+
35+ c8 -= 16;
36+
37+ c32.bit.b = c8 / 36;
38+ c8 -= c32.bit.b * 36;
39+ c32.bit.g = c8 / 6;
40+ c8 -= c32.bit.g * 6;
41+ c32.bit.r = c8;
42+ c32.bit.a = 0x00;
43+
44+ return ((c32.bit.r * 6) << 11) | ((c32.bit.g * 6) << (5 + 1) | (c32.bit.b * 6));
45+}
46+
47+uint RGB_08_To_32(uchar c8)
48+{
49+ RGB32 c32;
50+
51+ if(c8 < 16){
52+ return RGB_Table_08[c8];
53+ }
54+
55+ if(c8 >= 16 + 216){
56+ return 0x00000000;
57+ }
58+
59+ c8 -= 16;
60+
61+ c32.bit.b = c8 / 36;
62+ c8 -= c32.bit.b * 36;
63+ c32.bit.g = c8 / 6;
64+ c8 -= c32.bit.g * 6;
65+ c32.bit.r = c8;
66+ c32.bit.a = 0x00;
67+
68+ c32.bit.r *= 51;
69+ c32.bit.g *= 51;
70+ c32.bit.b *= 51;
71+
72+ return c32.c32;
73+}
74+
75+uchar RGB_16_To_08(ushort c16)
76+{
77+ uchar c[3];
78+
79+ c[0] = c16 >> (5 + 6);
80+ c[1] = (c16 & 0x7e0) >> 5;
81+ c[2] = c16 & 0x1f;
82+
83+ c[0] /= 6;
84+ c[1] /= 12;
85+ c[2] /= 6;
86+
87+ return 16 + c[0] + c[1] * 6 + c[2] * 36;
88+}
89+
90+uint RGB_16_To_32(ushort c16)
91+{
92+ uchar c[3];
93+
94+ c[0] = c16 >> (5 + 6);
95+ c[1] = (c16 & 0x7e0) >> 5;
96+ c[2] = c16 & 0x1f;
97+
98+ return (c[0] << (16 + 3)) | (c[1] << (8 + 2)) | (c[2] << 3);
99+}
100+
101+uchar RGB_32_To_08(uint c32)
102+{
103+ uchar c8;
104+ uchar c[4];
105+
106+ c[3] = (c32 << 24) >> 24;
107+ c[2] = (c32 << 16) >> 24;
108+ c[1] = (c32 << 8) >> 24;
109+
110+ c[1] = c[1] / 51;
111+ c[2] = c[2] / 51;
112+ c[3] = c[3] / 51;
113+
114+ c8 = (c[1] + c[2] * 6 + c[3] * 36) + 16;
115+
116+ return c8;
117+}
118+
119+uchar RGB_32_To_08_xy(uint c32, int x, int y)
120+{
121+ static int table[4] = { 3, 1, 0, 2 };
122+ uchar c8;
123+ uchar c[4];
124+ int i;
125+
126+ c[3] = (c32 << 24) >> 24;
127+ c[2] = (c32 << 16) >> 24;
128+ c[1] = (c32 << 8) >> 24;
129+
130+ x &= 1; /* 偶数か奇数か */
131+ y &= 1;
132+
133+ i = table[x + y * 2]; /* 中間色を作るための定数 */
134+ c[1] = (c[1] * 21) / 256; /* これで 0~20 になる */
135+ c[2] = (c[2] * 21) / 256;
136+ c[3] = (c[3] * 21) / 256;
137+ c[1] = (c[1] + i) / 4; /* これで 0~5 になる */
138+ c[2] = (c[2] + i) / 4;
139+ c[3] = (c[3] + i) / 4;
140+
141+ c8 = 16 + c[1] + c[2] * 6 + c[3] * 36;
142+
143+ return c8;
144+}
145+
146+ushort RGB_32_To_16(uint c32)
147+{
148+ ushort c16;
149+ uchar c[4];
150+
151+ c[3] = (c32 << 24) >> 24;
152+ c[2] = (c32 << 16) >> 24;
153+ c[1] = (c32 << 8) >> 24;
154+
155+ c16 = ((c[1] >> 3) << 11 | (c[2] >> 2) << 5 | (c[3] >> 3));
156+
157+ return c16;
158+}
159+
--- beta/tolset_chn_000/chnos_010/chnos/coredef0.h (revision 314)
+++ beta/tolset_chn_000/chnos_010/chnos/coredef0.h (revision 315)
@@ -13,7 +13,7 @@
1313 //#define CHNOSPROJECT_DEBUG_KBCT
1414 //#define CHNOSPROJECT_DEBUG_DISPLAY
1515 //#define CHNOSPROJECT_DEBUG_DRAWING
16- //#define CHNOSPROJECT_DEBUG_SHEET
16+ #define CHNOSPROJECT_DEBUG_SHEET
1717 //#define CHNOSPROJECT_DEBUG_TIMER
1818 //#define CHNOSPROJECT_DEBUG_MULTITASK
1919 #endif
--- beta/tolset_chn_000/chnos_010/chnos/coredef1.h (revision 314)
+++ beta/tolset_chn_000/chnos_010/chnos/coredef1.h (revision 315)
@@ -417,6 +417,7 @@
417417 unsigned buffer_configured : 1;
418418 unsigned visible : 1;
419419 unsigned using_map : 1;
420+ unsigned vram_auto_allocated : 1;
420421 } bit;
421422 } flags;
422423 void *vram;
@@ -423,6 +424,8 @@
423424 uint *map;
424425 uint vramsize;
425426 uint mapsize;
427+ uint (*Config_Functions)(struct UI_SHEET *sheet);
428+ uint (*RefreshSheet)(struct UI_SHEET *sheet, int px0, int py0, int px1, int py1);
426429 } UI_Sheet;
427430
428431 /*timer*/
@@ -450,5 +453,14 @@
450453 UI_Timer *timer_root;
451454 } UI_TimerControl;
452455
456+/*color*/
453457
454-
458+typedef union RGB_32BIT {
459+ uint c32;
460+ struct RGB_32BIT_RGBA {
461+ uchar b;
462+ uchar g;
463+ uchar r;
464+ uchar a;
465+ } bit;
466+} RGB32;
旧リポジトリブラウザで表示