• R/O
  • SSH
  • HTTPS

chnosproject: コミット


コミットメタ情報

リビジョン312 (tree)
日時2012-01-22 11:37:34
作者hikarupsp

ログメッセージ

シートを追加。
まだテスト段階だが、一応初期の、もっとも遅いシートのリフレッシュの方法で実装している。
カーソルキーで、テストシートが動く。画面外へはみ出しても大丈夫だが、背景はシート化していないので、表示が上書きされる。

変更サマリ

差分

--- beta/tolset_chn_000/chnos_010/chnos/sheet.c (nonexistent)
+++ beta/tolset_chn_000/chnos_010/chnos/sheet.c (revision 312)
@@ -0,0 +1,257 @@
1+
2+#include "core.h"
3+
4+UI_Sheet *Sheet_Initialise(void)
5+{
6+ UI_Sheet *sheet;
7+
8+ sheet = System_Memory_Allocate(sizeof(UI_Sheet));
9+
10+ sheet->flags.bit.initialized = True;
11+
12+ #ifdef CHNOSPROJECT_DEBUG_SHEET
13+ debug("Sheet_Initialise:[0x%08X]\n", sheet);
14+ #endif
15+
16+ return sheet;
17+}
18+
19+uint Sheet_SetBuffer(UI_Sheet *sheet, void *vram, uint xsize, uint ysize, uint bpp)
20+{
21+ if(sheet == Null){
22+ #ifdef CHNOSPROJECT_DEBUG_SHEET
23+ debug("Sheet_SetBuffer:Null sheet.\n");
24+ #endif
25+ return 1;
26+ }
27+ if(!sheet->flags.bit.initialized){
28+ #ifdef CHNOSPROJECT_DEBUG_SHEET
29+ debug("Sheet_SetBuffer:Not Initialised sheet.\n");
30+ #endif
31+ return 2;
32+ }
33+ if(vram == Null){
34+ #ifdef CHNOSPROJECT_DEBUG_SHEET
35+ debug("Sheet_SetBuffer:Null VRAM.\n");
36+ #endif
37+ return 3;
38+ }
39+ if(xsize > SHEET_MAX_XSIZE){
40+ #ifdef CHNOSPROJECT_DEBUG_SHEET
41+ debug("Sheet_SetBuffer:Too large xsize.\n");
42+ #endif
43+ return 4;
44+ }
45+ if(ysize > SHEET_MAX_YSIZE){
46+ #ifdef CHNOSPROJECT_DEBUG_SHEET
47+ debug("Sheet_SetBuffer:Too large ysize.\n");
48+ #endif
49+ return 5;
50+ }
51+ if(bpp != 8 && bpp != 16 && bpp != 32){
52+ #ifdef CHNOSPROJECT_DEBUG_SHEET
53+ debug("Sheet_SetBuffer:Not implemented %d bpp.\n", bpp);
54+ #endif
55+ return 6;
56+ }
57+
58+ sheet->size.x = xsize;
59+ sheet->size.y = ysize;
60+ sheet->bpp = bpp;
61+ sheet->vram = vram;
62+ sheet->vramsize = xsize * ysize * bpp;
63+
64+ sheet->flags.bit.buffer_configured = True;
65+
66+ #ifdef CHNOSPROJECT_DEBUG_SHEET
67+ debug("Sheet_SetBuffer:[0x%08X]\n", sheet);
68+ debug("Sheet_SetBuffer:vram:[0x%08X] xsize:%d ysize:%d bpp:%d\n", vram, xsize, ysize, bpp);
69+ #endif
70+
71+ return 0;
72+}
73+
74+uint Sheet_SetParent(UI_Sheet *sheet, UI_Sheet *parent)
75+{
76+ if(sheet == Null){
77+ #ifdef CHNOSPROJECT_DEBUG_SHEET
78+ debug("Sheet_SetParent:Null sheet.\n");
79+ #endif
80+ return 1;
81+ }
82+ if(!sheet->flags.bit.buffer_configured){
83+ #ifdef CHNOSPROJECT_DEBUG_SHEET
84+ debug("Sheet_SetParent:Not buffer_configured sheet.\n");
85+ #endif
86+ return 2;
87+ }
88+ if(parent == Null){
89+ #ifdef CHNOSPROJECT_DEBUG_SHEET
90+ debug("Sheet_SetParent:Null parent.\n");
91+ #endif
92+ sheet->parent = Null;
93+
94+ return 3;
95+ }
96+ if(!parent->flags.bit.buffer_configured){
97+ #ifdef CHNOSPROJECT_DEBUG_SHEET
98+ debug("Sheet_SetParent:Not buffer_configured parent.\n");
99+ #endif
100+ return 4;
101+ }
102+
103+ sheet->parent = parent;
104+
105+ #ifdef CHNOSPROJECT_DEBUG_SHEET
106+ debug("Sheet_SetParent:[0x%08X] parent:[0x%08X]\n", sheet, parent);
107+ #endif
108+
109+ return 0;
110+}
111+
112+uint Sheet_Show(UI_Sheet *sheet, uint height, int px, int py)
113+{
114+ UI_Sheet **search;
115+ uint i;
116+
117+ if(sheet == Null){
118+ #ifdef CHNOSPROJECT_DEBUG_SHEET
119+ debug("Sheet_Show:Null sheet.\n");
120+ #endif
121+ return 1;
122+ }
123+ if(sheet->parent == Null){
124+ #ifdef CHNOSPROJECT_DEBUG_SHEET
125+ debug("Sheet_Show:Null parent.\n");
126+ #endif
127+ sheet->flags.bit.visible = True;
128+ if(px != SHEET_LOCATION_NOCHANGE){
129+ sheet->location.x = px;
130+ }
131+ if(py != SHEET_LOCATION_NOCHANGE){
132+ sheet->location.y = py;
133+ }
134+ return 2;
135+ }
136+
137+//At First, clear old height link.
138+
139+ search = &sheet->parent->child;
140+ for(i = 0; i < SHEET_MAX_CHILDREN; i++){
141+ if(*search == sheet){
142+ *search = sheet->next;
143+ break;
144+ }
145+ search = &(*search)->next;
146+ }
147+
148+//Next, set new height link.
149+ search = &sheet->parent->child;
150+ for(i = 0; i < SHEET_MAX_CHILDREN; i++){
151+ if(i == height){
152+ #ifdef CHNOSPROJECT_DEBUG_SHEET
153+ debug("Sheet_Show:Search:Break(height).\n");
154+ #endif
155+ break;
156+ }
157+ if(*search == Null){
158+ #ifdef CHNOSPROJECT_DEBUG_SHEET
159+ debug("Sheet_Show:Search:Break(End of link).\n");
160+ #endif
161+ break;
162+ }
163+ search = &(*search)->next;
164+ }
165+ if(i == SHEET_MAX_CHILDREN){
166+ #ifdef CHNOSPROJECT_DEBUG_SHEET
167+ debug("Sheet_Show:Number of sheets is over SHEET_MAX_CHILDREN.\n");
168+ #endif
169+ return 3;
170+ }
171+
172+ sheet->next = *search;
173+ *search = sheet;
174+
175+ sheet->flags.bit.visible = True;
176+ if(px != SHEET_LOCATION_NOCHANGE){
177+ sheet->location.x = px;
178+ }
179+ if(py != SHEET_LOCATION_NOCHANGE){
180+ sheet->location.y = py;
181+ }
182+
183+ Sheet_Refresh_Sheet(sheet);
184+
185+ #ifdef CHNOSPROJECT_DEBUG_SHEET
186+ debug("Sheet_Show:[0x%08X] height:%d\n", sheet, i);
187+ #endif
188+
189+ return 0;
190+}
191+
192+uint Sheet_Refresh_Sheet(UI_Sheet *sheet)
193+{
194+ UI_Sheet *now;
195+ int x, y;
196+ int apx0, apy0;
197+ uchar *vram;
198+ int vxsize, vysize;
199+ int xsize, ysize;
200+
201+ if(sheet == Null){
202+ #ifdef CHNOSPROJECT_DEBUG_SHEET
203+ debug("Sheet_Refresh_Sheet:Null sheet.\n");
204+ #endif
205+ return 1;
206+ }
207+
208+ if(sheet->parent == Null){
209+ #ifdef CHNOSPROJECT_DEBUG_SHEET
210+ debug("Sheet_Refresh_Sheet:Null parent.\n");
211+ #endif
212+ return 2;
213+ }
214+
215+ vram = (uchar *)sheet->parent->vram;
216+ vxsize = (int)sheet->parent->size.x;
217+ vysize = (int)sheet->parent->size.y;
218+ for(now = sheet; now != Null; now = now->next){
219+ if(now->location.x < vxsize && now->location.y < vysize && now->location.x + (int)now->size.x > 0 && now->location.y + (int)now->size.y > 0 && now->flags.bit.visible){
220+ if((now->location.x + now->size.x) > vxsize){
221+ xsize = now->size.x - ((now->location.x + now->size.x) - vxsize);
222+ } else{
223+ xsize = now->size.x;
224+ }
225+ if((now->location.y + now->size.y) > vysize){
226+ ysize = now->size.y - ((now->location.y + now->size.y) - vysize);
227+ } else{
228+ ysize = now->size.y;
229+ }
230+ if(now->location.x < 0){
231+ xsize += now->location.x;
232+ apx0 = 0;
233+ } else{
234+ apx0 = now->location.x;
235+ }
236+ if(now->location.y < 0){
237+ ysize += now->location.y;
238+ apy0 = 0;
239+ } else{
240+ apy0 = now->location.y;
241+ }
242+
243+ #ifdef CHNOSPROJECT_DEBUG_SHEET
244+ debug("Sheet_Refresh_Sheet:[0x%08X]\n", sheet);
245+ debug("Sheet_Refresh_Sheet:apx0:%d apy0:%d xsize:%d ysize:%d\n", apx0, apy0, xsize, ysize);
246+ #endif
247+
248+ for(y = apy0; y < ysize + apy0; y++){
249+ for(x = apx0; x < xsize + apx0; x++){
250+ vram[y * vxsize + x] = ((uchar *)now->vram)[(y - now->location.y) * now->size.x + (x - now->location.x)];
251+ }
252+ }
253+ }
254+ }
255+
256+ return 0;
257+}
--- beta/tolset_chn_000/chnos_010/chnos/makeset.txt (revision 311)
+++ beta/tolset_chn_000/chnos_010/chnos/makeset.txt (revision 312)
@@ -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 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 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 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/core.h (revision 311)
+++ beta/tolset_chn_000/chnos_010/chnos/core.h (revision 312)
@@ -206,6 +206,13 @@
206206 void debug(const uchar format[], ...);
207207 #endif
208208
209+/*sheet.c シート関連*/
210+UI_Sheet *Sheet_Initialise(void);
211+uint Sheet_SetBuffer(UI_Sheet *sheet, void *vram, uint xsize, uint ysize, uint bpp);
212+uint Sheet_SetParent(UI_Sheet *sheet, UI_Sheet *parent);
213+uint Sheet_Show(UI_Sheet *sheet, uint height, int px, int py);
214+uint Sheet_Refresh_Sheet(UI_Sheet *sheet);
215+
209216 /*system.c システムデータ・初期化関連*/
210217 void Initialise_System(void);
211218 void System_Set_RunningPhase(uint phase);
@@ -329,6 +336,7 @@
329336 //=((dividend_high << 32) | dividend_low) / divisor
330337 uint MOD_64_32(uint dividend_low, uint dividend_high, uint divisor);
331338 //=((dividend_high << 32) | dividend_low) % divisor
339+void MOVSD_ZeroFill(void *addr, uint bytes); //4Byte単位でゼロフィルする。
332340 /*nasfunc1.nas 他の関数に依存するアセンブラ関数群*/
333341 void asm_CPU_ExceptionHandler00(void);
334342 void asm_CPU_ExceptionHandler01(void);
--- beta/tolset_chn_000/chnos_010/chnos/bootpack.c (revision 311)
+++ beta/tolset_chn_000/chnos_010/chnos/bootpack.c (revision 312)
@@ -10,6 +10,8 @@
1010 UI_Task *mytask;
1111 uint i;
1212 IO_DisplayControl *disp_ctrl;
13+ UI_Sheet *vramsheet, *testsheet, *testsheet2;
14+ int x, y;
1315
1416 Initialise_System();
1517
@@ -88,8 +90,61 @@
8890 for(i = 0; i < 50; i += 5){
8991 Drawing_Draw_Circle(disp_ctrl->vram, disp_ctrl->xsize, 100, 250, 0xc6c6c6, i);
9092 }
93+
94+ vramsheet = Sheet_Initialise();
95+ testsheet = Sheet_Initialise();
96+ testsheet2 = Sheet_Initialise();
97+
98+ Sheet_SetBuffer(vramsheet, disp_ctrl->vram, disp_ctrl->xsize, disp_ctrl->ysize, disp_ctrl->bpp);
99+ Sheet_SetBuffer(testsheet, System_Memory_Allocate(128 * 64 * 1), 128, 64, 8);
100+ Sheet_SetBuffer(testsheet2, System_Memory_Allocate(160 * 100 * 1), 160, 100, 8);
101+
102+ for(y = 0; y < testsheet->size.y; y++){
103+ for(x = 0; x < testsheet->size.x; x++){
104+ ((uchar*)testsheet->vram)[y * testsheet->size.x + x] = x * 2;
105+ }
106+ }
107+ for(y = 0; y < testsheet2->size.y; y++){
108+ for(x = 0; x < testsheet2->size.x; x++){
109+ ((uchar*)testsheet2->vram)[y * testsheet2->size.x + x] = y * 2 + x;
110+ }
111+ }
112+
113+ Drawing08_Put_String(testsheet->vram, testsheet->size.x, 4, 4, 0xffffff, "TestSheet");
114+ Drawing08_Put_String(testsheet2->vram, testsheet2->size.x, 4, 4, 0xffffff, "TestSheet2");
115+
116+ Sheet_SetParent(testsheet, vramsheet);
117+ Sheet_Show(testsheet, 0, 10, 10);
118+
119+ Sheet_SetParent(testsheet2, vramsheet);
120+ Sheet_Show(testsheet2, 1, 20, 20);
121+
91122 for(;;){
123+ if(FIFO32_MyTaskFIFO_Status() == 0){
92124
125+ } else{
126+ data = FIFO32_MyTaskFIFO_Get();
127+ if(MAIN_KEYBASE <= data && data <= (MAIN_KEYBASE + 0xFFFF)){
128+ data -= MAIN_KEYBASE;
129+ if(!(data & KEYID_MASK_BREAK) && (data & KEYID_MASK_EXTENDED)){
130+ if((data & KEYID_MASK_ID) == KEYID_CURSOR_U){
131+ testsheet->location.y -= 5;
132+ Sheet_Refresh_Sheet(testsheet);
133+ } else if((data & KEYID_MASK_ID) == KEYID_CURSOR_D){
134+ testsheet->location.y += 5;
135+ Sheet_Refresh_Sheet(testsheet);
136+ } else if((data & KEYID_MASK_ID) == KEYID_CURSOR_L){
137+ testsheet->location.x -= 5;
138+ Sheet_Refresh_Sheet(testsheet);
139+ } else if((data & KEYID_MASK_ID) == KEYID_CURSOR_R){
140+ testsheet->location.x += 5;
141+ Sheet_Refresh_Sheet(testsheet);
142+ } else if((data & KEYID_MASK_ID) == KEYID_ENTER){
143+
144+ }
145+ }
146+ }
147+ }
93148 }
94149 }
95150
--- beta/tolset_chn_000/chnos_010/chnos/memory.c (revision 311)
+++ beta/tolset_chn_000/chnos_010/chnos/memory.c (revision 312)
@@ -144,6 +144,10 @@
144144
145145 IO_Store_EFlags(eflags);
146146
147+ #ifdef CHNOSPROJECT_DEBUG_MEMORY_ALLOCATE_AND_FREE
148+ debug("Memory_Free:ctrl:[0x%X] addr:[0x%X] size:0x%X\n", ctrl, addr, size);
149+ #endif
150+
147151 return;
148152 }
149153
@@ -237,6 +241,13 @@
237241 ctrl[1].size -= size;
238242 }
239243 IO_Store_EFlags(eflags);
244+ //メモリをゼロクリア。
245+ MOVSD_ZeroFill(addr, size);
246+
247+ #ifdef CHNOSPROJECT_DEBUG_MEMORY_ALLOCATE_AND_FREE
248+ debug("Memory_Alloc:ctrl:[0x%X] addr:[0x%X] size:0x%X\n", ctrl, addr, size);
249+ #endif
250+
240251 return addr;
241252 }
242253 }
--- beta/tolset_chn_000/chnos_010/chnos/coredef0.h (revision 311)
+++ beta/tolset_chn_000/chnos_010/chnos/coredef0.h (revision 312)
@@ -5,7 +5,8 @@
55 #define CHNOSPROJECT_DEBUG /*定義するとデバッグモードで実行。それぞれのデバッグオプションも有効にする必要がある*/
66
77 #ifdef CHNOSPROJECT_DEBUG
8- //#define CHNOSPROJECT_DEBUG_MEMORY /*定義するとメモリ関連のデバッグをオンにする*/
8+ //#define CHNOSPROJECT_DEBUG_MEMORY
9+ #define CHNOSPROJECT_DEBUG_MEMORY_ALLOCATE_AND_FREE
910 //#define CHNOSPROJECT_DEBUG_EMULATOR_X86
1011 //#define CHNOSPROJECT_DEBUG_CALLBIOS
1112 //#define CHNOSPROJECT_DEBUG_FIFO
@@ -12,6 +13,7 @@
1213 //#define CHNOSPROJECT_DEBUG_KBCT
1314 //#define CHNOSPROJECT_DEBUG_DISPLAY
1415 #define CHNOSPROJECT_DEBUG_DRAWING
16+ #define CHNOSPROJECT_DEBUG_SHEET
1517 #endif
1618
1719 /*defines*/
@@ -19,6 +21,9 @@
1921 #define True 1
2022 #define False 0
2123
24+/*null*/
25+#define Null 0
26+
2227 /*descriptors*/
2328 #define AR_DATA32_RW 0x4092 //AR_32+AR_PRESENT+AR_CODE_OR_DATA+AR_TYPE_DATA_RW
2429 #define AR_CODE32_ER 0x409a //AR_32+AR_PRESENT+AR_CODE_OR_DATA+AR_TYPE_CODE_ER
@@ -311,4 +316,9 @@
311316 #define EXCEPTION_INFO_USER_ESP 0x0e
312317 #define EXCEPTION_INFO_USER_SS 0x0f
313318
319+/*sheet*/
320+#define SHEET_MAX_XSIZE 65535
321+#define SHEET_MAX_YSIZE 65535
322+#define SHEET_MAX_CHILDREN 255
323+#define SHEET_LOCATION_NOCHANGE 0x7ffffffe
314324
--- beta/tolset_chn_000/chnos_010/chnos/coredef1.h (revision 311)
+++ beta/tolset_chn_000/chnos_010/chnos/coredef1.h (revision 312)
@@ -399,3 +399,25 @@
399399 void *vram;
400400 DATA_FIFO32 *bios_signal;
401401 } IO_DisplayControl;
402+
403+/*sheet*/
404+typedef struct UI_SHEET {
405+ struct UI_SHEET *parent; //one sheet has one parent(if vramseet then:0)
406+ struct UI_SHEET *next; //same level sheet link
407+ struct UI_SHEET *child; //children lowest height
408+ DATA_Location2D location;
409+ DATA_Location2DU size;
410+ ushort bpp; //0:Text(16col) 1:8bit 2:16bit 3:32bit
411+ union UI_SHEET_FLAGS {
412+ ushort flags;
413+ struct UI_SHEET_FLAGS_BITS {
414+ unsigned initialized : 1;
415+ unsigned buffer_configured : 1;
416+ unsigned visible : 1;
417+ unsigned map : 1;
418+ } bit;
419+ } flags;
420+ void *vram;
421+ void *map;
422+ uint vramsize;
423+} UI_Sheet;
旧リポジトリブラウザで表示