• R/O
  • SSH
  • HTTPS

haribote: Commit


Commit MetaInfo

Revision182 (tree)
Time2007-08-04 15:10:13
Authorbayside

Log Message

refactoring

Change Summary

Incremental Difference

--- haribote/trunk/bayos_exp/bootpack.cpp (revision 181)
+++ haribote/trunk/bayos_exp/bootpack.cpp (revision 182)
@@ -7,22 +7,22 @@
77
88 void keywin_off(Sheet *key_win);
99 void keywin_on(Sheet *key_win);
10-void close_console(Sheet *sht);
11-void close_constask(Task *task);
10+void close_console(Sheet *sheet);
11+void close_console_task(Task *task);
1212
1313 void HariMain(void)
1414 {
1515 SystemInfo *sysinfo = SystemInfo::get_instance();
16- SheetManager *shtctl;
16+ SheetManager *sheet_manager;
1717 char s[40];
18- Queue fifo, keycmd;
19- int fifobuf[128], keycmd_buf[32];
18+ Queue queue, keycmd;
19+ int queuebuf[128], keycmd_buf[32];
2020 int mx, my, i, new_mx = -1, new_my = 0, new_wx = 0x7fffffff, new_wy = 0;
2121 unsigned int memtotal;
22- Mouse mdec;
23- MemoryManager *memman = (MemoryManager *) MEMMAN_ADDR;
22+ Mouse mouse;
23+ MemoryManager *memory_manager = (MemoryManager *) MEMMAN_ADDR;
2424 unsigned short *buf_back, buf_mouse[256];
25- Sheet *sht_back, *sht_mouse;
25+ Sheet *sheet_back, *sheet_mouse;
2626 Task *task_a, *task;
2727 static char keytable0[0x80] = {
2828 0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '^', 0x08, 0,
@@ -46,7 +46,7 @@
4646 };
4747 int key_shift = 0, key_leds = (sysinfo->leds >> 4) & 7, keycmd_wait = -1;
4848 int j, x, y, mmx = -1, mmy = -1, mmx2 = 0;
49- Sheet *sht = 0, *key_win, *sht2;
49+ Sheet *sheet = 0, *key_win, *sheet2;
5050 int *fat;
5151 unsigned char *nihongo;
5252 FileInfo *finfo;
@@ -55,55 +55,55 @@
5555 Descriptor::init();
5656 PIC::init();
5757 io_sti(); /* IDT/PICの初期化が終わったのでCPUの割り込み禁止を解除 */
58- Queue::init(&fifo, 128, fifobuf, 0);
59- *((int *) 0x0fec) = (int) &fifo;
58+ Queue::init(&queue, 128, queuebuf, 0);
59+ *((int *) 0x0fec) = (int) &queue;
6060 PIT::init();
61- Keyboard::init(&fifo, 256);
62- Mouse::init(&fifo, 512, &mdec);
61+ Keyboard::init(&queue, 256);
62+ Mouse::init(&queue, 512, &mouse);
6363 io_out8(PIC0_IMR, 0xf8); /* PITとPIC1とキーボードを許可(11111000) */
6464 io_out8(PIC1_IMR, 0xef); /* マウスを許可(11101111) */
6565 Queue::init(&keycmd, 32, keycmd_buf, 0);
6666
6767 memtotal = MemoryManager::test(0x00400000, 0xbfffffff);
68- MemoryManager::init(memman);
69- MemoryManager::deallocate(memman, 0x00001000, 0x0009e000); /* 0x00001000 - 0x0009efff */
70- MemoryManager::deallocate(memman, 0x00400000, memtotal - 0x00400000);
68+ MemoryManager::init(memory_manager);
69+ MemoryManager::deallocate(memory_manager, 0x00001000, 0x0009e000); /* 0x00001000 - 0x0009efff */
70+ MemoryManager::deallocate(memory_manager, 0x00400000, memtotal - 0x00400000);
7171
7272 TimerManager::init();
7373 Palette::init();
74- shtctl = SheetManager::init(memman, sysinfo->vram, sysinfo->scrnx, sysinfo->scrny);
75- task_a = Task::init(memman);
76- fifo.task = task_a;
74+ sheet_manager = SheetManager::init(memory_manager, sysinfo->vram, sysinfo->scrnx, sysinfo->scrny);
75+ task_a = Task::init(memory_manager);
76+ queue.task = task_a;
7777 Task::run(task_a, 1, 2);
78- *((int *) 0x0fe4) = (int) shtctl;
78+ *((int *) 0x0fe4) = (int) sheet_manager;
7979 task_a->langmode = 0;
8080
8181 /* fat */
82- fat = (int *) MemoryManager::allocate_4k(memman, 4 * 2880);
82+ fat = (int *) MemoryManager::allocate_4k(memory_manager, 4 * 2880);
8383 File::read_fat(fat, (unsigned char *) (ADR_DISKIMG + 0x000200));
8484
85- /* sht_back */
86- sht_back = Sheet::allocate(shtctl);
87- buf_back = (unsigned short *) MemoryManager::allocate_4k(memman, sysinfo->scrnx * sysinfo->scrny * 2);
88- Sheet::set_buffer(sht_back, buf_back, sysinfo->scrnx, sysinfo->scrny, -1); /* 透明色なし */
89- Graphics::init(fat, buf_back, sysinfo->scrnx, sysinfo->scrny);
85+ /* sheet_back */
86+ sheet_back = SheetManager::allocate(sheet_manager);
87+ buf_back = (unsigned short *) MemoryManager::allocate_4k(memory_manager, sysinfo->scrnx * sysinfo->scrny * 2);
88+ Sheet::set_buffer(sheet_back, buf_back, sysinfo->scrnx, sysinfo->scrny, -1); /* 透明色なし */
89+ Graphics::init(buf_back, sysinfo->scrnx, sysinfo->scrny);
9090
91- /* sht_cons */
92- key_win = open_console(shtctl, memtotal);
91+ /* sheet_console */
92+ key_win = open_console(sheet_manager, memtotal);
9393
94- /* sht_mouse */
95- sht_mouse = Sheet::allocate(shtctl);
96- Sheet::set_buffer(sht_mouse, buf_mouse, 16, 16, 99);
94+ /* sheet_mouse */
95+ sheet_mouse = SheetManager::allocate(sheet_manager);
96+ Sheet::set_buffer(sheet_mouse, buf_mouse, 16, 16, 99);
9797 MouseCursor::init(buf_mouse, 99);
9898 mx = (sysinfo->scrnx - 16) / 2; /* 画面中央になるように座標計算 */
9999 my = (sysinfo->scrny - 28 - 16) / 2;
100100
101- Sheet::slide(sht_back, 0, 0);
101+ Sheet::slide(sheet_back, 0, 0);
102102 Sheet::slide(key_win, 32, 4);
103- Sheet::slide(sht_mouse, mx, my);
104- Sheet::up_down(sht_back, 0);
103+ Sheet::slide(sheet_mouse, mx, my);
104+ Sheet::up_down(sheet_back, 0);
105105 Sheet::up_down(key_win, 1);
106- Sheet::up_down(sht_mouse, 2);
106+ Sheet::up_down(sheet_mouse, 2);
107107 keywin_on(key_win);
108108
109109 /* 最初にキーボード状態との食い違いがないように、設定しておくことにする */
@@ -116,7 +116,7 @@
116116 i = finfo->size;
117117 nihongo = File::load_file2(finfo->clustno, &i, fat);
118118 } else {
119- nihongo = (unsigned char *) MemoryManager::allocate_4k(memman, 16 * 256 + 32 * 94 * 47);
119+ nihongo = (unsigned char *) MemoryManager::allocate_4k(memory_manager, 16 * 256 + 32 * 94 * 47);
120120 for (i = 0; i < 16 * 256; i++) {
121121 nihongo[i] = hankaku[i]; /* フォントがなかったので半角部分をコピー */
122122 }
@@ -125,7 +125,7 @@
125125 }
126126 }
127127 *((int *) 0x0fe8) = (int) nihongo;
128- MemoryManager::deallocate_4k(memman, (int) fat, 4 * 2880);
128+ MemoryManager::deallocate_4k(memory_manager, (int) fat, 4 * 2880);
129129
130130 for (;;) {
131131 if (Queue::status(&keycmd) > 0 && keycmd_wait < 0) {
@@ -135,15 +135,15 @@
135135 io_out8(PORT_KEYDAT, keycmd_wait);
136136 }
137137 io_cli();
138- if (Queue::status(&fifo) == 0) {
138+ if (Queue::status(&queue) == 0) {
139139 /* FIFOがからっぽになったので、保留している描画があれば実行する */
140140 if (new_mx >= 0) {
141141 io_sti();
142- Sheet::slide(sht_mouse, new_mx, new_my);
142+ Sheet::slide(sheet_mouse, new_mx, new_my);
143143 new_mx = -1;
144144 } else if (new_wx != 0x7fffffff) {
145145 io_sti();
146- Sheet::slide(sht, new_wx, new_wy);
146+ Sheet::slide(sheet, new_wx, new_wy);
147147 new_wx = 0x7fffffff;
148148 } else {
149149 Task::sleep(task_a);
@@ -150,13 +150,13 @@
150150 io_sti();
151151 }
152152 } else {
153- i = Queue::pop(&fifo);
153+ i = Queue::pop(&queue);
154154 io_sti();
155155 if (key_win != 0 && key_win->flags == 0) { /* ウィンドウが閉じられた */
156- if (shtctl->top == 1) { /* もうマウスと背景しかない */
156+ if (sheet_manager->top == 1) { /* もうマウスと背景しかない */
157157 key_win = 0;
158158 } else {
159- key_win = shtctl->sheets[shtctl->top - 1];
159+ key_win = sheet_manager->sheets[sheet_manager->top - 1];
160160 keywin_on(key_win);
161161 }
162162 }
@@ -177,15 +177,15 @@
177177 }
178178 }
179179 if (s[0] != 0 && key_win != 0) { /* 通常文字、バックスペース、Enter */
180- Queue::push(&key_win->task->fifo, s[0] + 256);
180+ Queue::push(&key_win->task->queue, s[0] + 256);
181181 }
182182 if (i == 256 + 0x0f && key_win != 0) { /* Tab */
183183 keywin_off(key_win);
184184 j = key_win->height - 1;
185185 if (j == 0) {
186- j = shtctl->top - 1;
186+ j = sheet_manager->top - 1;
187187 }
188- key_win = shtctl->sheets[j];
188+ key_win = sheet_manager->sheets[j];
189189 keywin_on(key_win);
190190 }
191191 if (i == 256 + 0x2a) { /* 左シフト ON */
@@ -218,7 +218,7 @@
218218 if (i == 256 + 0x3b && key_shift != 0 && key_win != 0) { /* Shift+F1 */
219219 task = key_win->task;
220220 if (task != 0 && task->tss.ss0 != 0) {
221- Console::put_str0(task->cons, "\nBreak(key) :\n");
221+ Console::put_str0(task->console, "\nBreak(key) :\n");
222222 io_cli(); /* 強制終了処理中にタスクが変わると困るから */
223223 task->tss.eax = (int) &(task->tss.esp0);
224224 task->tss.eip = (int) asm_end_app;
@@ -231,13 +231,13 @@
231231 if (key_win != 0) {
232232 keywin_off(key_win);
233233 }
234- key_win = open_console(shtctl, memtotal);
234+ key_win = open_console(sheet_manager, memtotal);
235235 Sheet::slide(key_win, 32, 4);
236- Sheet::up_down(key_win, shtctl->top);
236+ Sheet::up_down(key_win, sheet_manager->top);
237237 keywin_on(key_win);
238238 }
239239 if (i == 256 + 0x57) { /* F11 */
240- Sheet::up_down(shtctl->sheets[1], shtctl->top - 1);
240+ Sheet::up_down(sheet_manager->sheets[1], sheet_manager->top - 1);
241241 }
242242 if (i == 256 + 0xfa) { /* キーボードがデータを無事に受け取った */
243243 keycmd_wait = -1;
@@ -247,10 +247,10 @@
247247 io_out8(PORT_KEYDAT, keycmd_wait);
248248 }
249249 } else if (512 <= i && i <= 767) { /* マウスデータ */
250- if (Mouse::decode(&mdec, i - 512) != 0) {
250+ if (Mouse::decode(&mouse, i - 512) != 0) {
251251 /* マウスカーソルの移動 */
252- mx += mdec.x;
253- my += mdec.y;
252+ mx += mouse.x;
253+ my += mouse.y;
254254 if (mx < 0) {
255255 mx = 0;
256256 }
@@ -265,34 +265,34 @@
265265 }
266266 new_mx = mx;
267267 new_my = my;
268- if ((mdec.btn & 0x01) != 0) {
268+ if ((mouse.btn & 0x01) != 0) {
269269 /* 左ボタンを押している */
270270 if (mmx < 0) {
271271 /* 通常モードの場合 */
272272 /* 上の下じきから順番にマウスが指している下じきを探す */
273- for (j = shtctl->top - 1; j > 0; j--) {
274- sht = shtctl->sheets[j];
275- x = mx - sht->vx0;
276- y = my - sht->vy0;
277- if (0 <= x && x < sht->bxsize && 0 <= y && y < sht->bysize) {
278- if (sht->buf[y * sht->bxsize + x] != sht->col_inv) {
279- Sheet::up_down(sht, shtctl->top - 1);
280- if (sht != key_win) {
273+ for (j = sheet_manager->top - 1; j > 0; j--) {
274+ sheet = sheet_manager->sheets[j];
275+ x = mx - sheet->vx0;
276+ y = my - sheet->vy0;
277+ if (0 <= x && x < sheet->bxsize && 0 <= y && y < sheet->bysize) {
278+ if (sheet->buf[y * sheet->bxsize + x] != sheet->col_inv) {
279+ Sheet::up_down(sheet, sheet_manager->top - 1);
280+ if (sheet != key_win) {
281281 keywin_off(key_win);
282- key_win = sht;
282+ key_win = sheet;
283283 keywin_on(key_win);
284284 }
285- if (3 <= x && x < sht->bxsize - 3 && 3 <= y && y < 21) {
285+ if (3 <= x && x < sheet->bxsize - 3 && 3 <= y && y < 21) {
286286 mmx = mx; /* ウィンドウ移動モードへ */
287287 mmy = my;
288- mmx2 = sht->vx0;
289- new_wy = sht->vy0;
288+ mmx2 = sheet->vx0;
289+ new_wy = sheet->vy0;
290290 }
291- if (sht->bxsize - 21 <= x && x < sht->bxsize - 5 && 5 <= y && y < 19) {
291+ if (sheet->bxsize - 21 <= x && x < sheet->bxsize - 5 && 5 <= y && y < 19) {
292292 /* 「×」ボタンクリック */
293- if ((sht->flags & 0x10) != 0) { /* アプリが作ったウィンドウか? */
294- task = sht->task;
295- Console::put_str0(task->cons, "\nBreak(mouse) :\n");
293+ if ((sheet->flags & 0x10) != 0) { /* アプリが作ったウィンドウか? */
294+ task = sheet->task;
295+ Console::put_str0(task->console, "\nBreak(mouse) :\n");
296296 io_cli(); /* 強制終了処理中にタスクが変わると困るから */
297297 task->tss.eax = (int) &(task->tss.esp0);
298298 task->tss.eip = (int) asm_end_app;
@@ -299,13 +299,13 @@
299299 io_sti();
300300 Task::run(task, -1, 0);
301301 } else { /* コンソール */
302- task = sht->task;
303- Sheet::up_down(sht, -1); /* とりあえず非表示にしておく */
302+ task = sheet->task;
303+ Sheet::up_down(sheet, -1); /* とりあえず非表示にしておく */
304304 keywin_off(key_win);
305- key_win = shtctl->sheets[shtctl->top - 1];
305+ key_win = sheet_manager->sheets[sheet_manager->top - 1];
306306 keywin_on(key_win);
307307 io_cli();
308- Queue::push(&task->fifo, 4);
308+ Queue::push(&task->queue, 4);
309309 io_sti();
310310 }
311311 }
@@ -325,19 +325,19 @@
325325 /* 左ボタンを押していない */
326326 mmx = -1; /* 通常モードへ */
327327 if (new_wx != 0x7fffffff) {
328- Sheet::slide(sht, new_wx, new_wy); /* 一度確定させる */
328+ Sheet::slide(sheet, new_wx, new_wy); /* 一度確定させる */
329329 new_wx = 0x7fffffff;
330330 }
331331 }
332332 }
333333 } else if (768 <= i && i <= 1023) { /* コンソール終了処理 */
334- close_console(shtctl->sheets0 + (i - 768));
334+ close_console(sheet_manager->sheets0 + (i - 768));
335335 } else if (1024 <= i && i <= 2023) {
336- close_constask(taskctl->tasks0 + (i - 1024));
336+ close_console_task(task_manager->tasks0 + (i - 1024));
337337 } else if (2024 <= i && i <= 2279) { /* コンソールだけを閉じる */
338- sht2 = shtctl->sheets0 + (i - 2024);
339- MemoryManager::deallocate_4k(memman, (int) sht2->buf, 256 * 165);
340- Sheet::deallocate(sht2);
338+ sheet2 = sheet_manager->sheets0 + (i - 2024);
339+ MemoryManager::deallocate_4k(memory_manager, (int) sheet2->buf, 256 * 165);
340+ Sheet::deallocate(sheet2);
341341 }
342342 }
343343 }
@@ -347,7 +347,7 @@
347347 {
348348 Window::change_wtitle(key_win, 0);
349349 if ((key_win->flags & 0x20) != 0) {
350- Queue::push(&key_win->task->fifo, 3); /* コンソールのカーソルOFF */
350+ Queue::push(&key_win->task->queue, 3); /* コンソールのカーソルOFF */
351351 }
352352 return;
353353 }
@@ -356,18 +356,18 @@
356356 {
357357 Window::change_wtitle(key_win, 1);
358358 if ((key_win->flags & 0x20) != 0) {
359- Queue::push(&key_win->task->fifo, 2); /* コンソールのカーソルON */
359+ Queue::push(&key_win->task->queue, 2); /* コンソールのカーソルON */
360360 }
361361 return;
362362 }
363363
364-Task *open_constask(Sheet *sht, unsigned int memtotal)
364+Task *open_console_task(Sheet *sheet, unsigned int memtotal)
365365 {
366- MemoryManager *memman = (MemoryManager *) MEMMAN_ADDR;
366+ MemoryManager *memory_manager = (MemoryManager *) MEMMAN_ADDR;
367367 Task *task = Task::allocate();
368- int *cons_fifo = (int *) MemoryManager::allocate_4k(memman, 128 * 4);
369- task->cons_stack = MemoryManager::allocate_4k(memman, 64 * 1024);
370- task->tss.esp = task->cons_stack + 64 * 1024 - 12;
368+ int *console_queue = (int *) MemoryManager::allocate_4k(memory_manager, 128 * 4);
369+ task->console_stack = MemoryManager::allocate_4k(memory_manager, 64 * 1024);
370+ task->tss.esp = task->console_stack + 64 * 1024 - 12;
371371 task->tss.eip = (int) &console_task;
372372 task->tss.es = 1 * 8;
373373 task->tss.cs = 2 * 8;
@@ -375,47 +375,48 @@
375375 task->tss.ds = 1 * 8;
376376 task->tss.fs = 1 * 8;
377377 task->tss.gs = 1 * 8;
378- *((int *) (task->tss.esp + 4)) = (int) sht;
378+ *((int *) (task->tss.esp + 4)) = (int) sheet;
379379 *((int *) (task->tss.esp + 8)) = memtotal;
380380 Task::run(task, 2, 2); /* level=2, priority=2 */
381- Queue::init(&task->fifo, 128, cons_fifo, task);
381+ Queue::init(&task->queue, 128, console_queue, task);
382382 return task;
383383 }
384384
385-Sheet *open_console(SheetManager *shtctl, unsigned int memtotal)
385+Sheet *open_console(SheetManager *sheet_manager, unsigned int memtotal)
386386 {
387- MemoryManager *memman = (MemoryManager *) MEMMAN_ADDR;
388- Sheet *sht = Sheet::allocate(shtctl);
389- unsigned short *buf = (unsigned short *) MemoryManager::allocate_4k(memman, 256 * 165 * 2);
390- Sheet::set_buffer(sht, buf, 256, 165, -1); /* 透明色なし */
391- Window::make_window(buf, 256, 165, "console", 0);
392- Window::make_textbox(sht, 8, 28, 240, 128, COL8_000000);
393- sht->task = open_constask(sht, memtotal);
394- sht->flags |= 0x20; /* カーソルあり */
395- return sht;
387+ MemoryManager *memory_manager = (MemoryManager *) MEMMAN_ADDR;
388+ Sheet *sheet = SheetManager::allocate(sheet_manager);
389+ unsigned short *buf = (unsigned short *) MemoryManager::allocate_4k(memory_manager, 256 * 165 * 2);
390+ Sheet::set_buffer(sheet, buf, 256, 165, -1); /* 透明色なし */
391+ //Window::make_window(buf, 256, 165, "console", 0);
392+ //Window::make_textbox(sheet, 8, 28, 240, 128, COL8_000000);
393+ Gui::drawFrame(sheet, "console");
394+ sheet->task = open_console_task(sheet, memtotal);
395+ sheet->flags |= 0x20; /* カーソルあり */
396+ return sheet;
396397 }
397398
398-void close_constask(Task *task)
399+void close_console_task(Task *task)
399400 {
400- MemoryManager *memman = (MemoryManager *) MEMMAN_ADDR;
401+ MemoryManager *memory_manager = (MemoryManager *) MEMMAN_ADDR;
401402 Task::sleep(task);
402- MemoryManager::deallocate_4k(memman, task->cons_stack, 64 * 1024);
403- MemoryManager::deallocate_4k(memman, (int) task->fifo.buf, 128 * 4);
403+ MemoryManager::deallocate_4k(memory_manager, task->console_stack, 64 * 1024);
404+ MemoryManager::deallocate_4k(memory_manager, (int) task->queue.buf, 128 * 4);
404405 io_cli();
405406 task->flags = 0; /* task_free(task); の代わり */
406- if (taskctl->task_fpu == task) {
407- taskctl->task_fpu = 0;
407+ if (task_manager->task_fpu == task) {
408+ task_manager->task_fpu = 0;
408409 }
409410 io_sti();
410411 return;
411412 }
412413
413-void close_console(Sheet *sht)
414+void close_console(Sheet *sheet)
414415 {
415- MemoryManager *memman = (MemoryManager *) MEMMAN_ADDR;
416- Task *task = sht->task;
417- MemoryManager::deallocate_4k(memman, (int) sht->buf, 256 * 165);
418- Sheet::deallocate(sht);
419- close_constask(task);
416+ MemoryManager *memory_manager = (MemoryManager *) MEMMAN_ADDR;
417+ Task *task = sheet->task;
418+ MemoryManager::deallocate_4k(memory_manager, (int) sheet->buf, 256 * 165);
419+ Sheet::deallocate(sheet);
420+ close_console_task(task);
420421 return;
421422 }
--- haribote/trunk/bayos_exp/window.cpp (revision 181)
+++ haribote/trunk/bayos_exp/window.cpp (revision 182)
@@ -4,102 +4,102 @@
44
55 extern unsigned short table_8_565[256];
66
7-void Window::make_window(unsigned short *buf, int xsize, int ysize, char *title, char act)
8-{
9- Graphics::fill_rect(buf, xsize, COL8_C6C6C6, 0, 0, xsize - 1, 0 );
10- Graphics::fill_rect(buf, xsize, COL8_FFFFFF, 1, 1, xsize - 2, 1 );
11- Graphics::fill_rect(buf, xsize, COL8_C6C6C6, 0, 0, 0, ysize - 1);
12- Graphics::fill_rect(buf, xsize, COL8_FFFFFF, 1, 1, 1, ysize - 2);
13- Graphics::fill_rect(buf, xsize, COL8_848484, xsize - 2, 1, xsize - 2, ysize - 2);
14- Graphics::fill_rect(buf, xsize, COL8_000000, xsize - 1, 0, xsize - 1, ysize - 1);
15- Graphics::fill_rect(buf, xsize, COL8_C6C6C6, 2, 2, xsize - 3, ysize - 3);
16- Graphics::fill_rect(buf, xsize, COL8_848484, 1, ysize - 2, xsize - 2, ysize - 2);
17- Graphics::fill_rect(buf, xsize, COL8_000000, 0, ysize - 1, xsize - 1, ysize - 1);
18- Window::make_wtitle(buf, xsize, title, act);
19- return;
20-}
7+//void Window::make_window(unsigned short *buf, int xsize, int ysize, char *title, char act)
8+//{
9+// Graphics::fill_rect(buf, xsize, COL8_C6C6C6, 0, 0, xsize - 1, 0 );
10+// Graphics::fill_rect(buf, xsize, COL8_FFFFFF, 1, 1, xsize - 2, 1 );
11+// Graphics::fill_rect(buf, xsize, COL8_C6C6C6, 0, 0, 0, ysize - 1);
12+// Graphics::fill_rect(buf, xsize, COL8_FFFFFF, 1, 1, 1, ysize - 2);
13+// Graphics::fill_rect(buf, xsize, COL8_848484, xsize - 2, 1, xsize - 2, ysize - 2);
14+// Graphics::fill_rect(buf, xsize, COL8_000000, xsize - 1, 0, xsize - 1, ysize - 1);
15+// Graphics::fill_rect(buf, xsize, COL8_C6C6C6, 2, 2, xsize - 3, ysize - 3);
16+// Graphics::fill_rect(buf, xsize, COL8_848484, 1, ysize - 2, xsize - 2, ysize - 2);
17+// Graphics::fill_rect(buf, xsize, COL8_000000, 0, ysize - 1, xsize - 1, ysize - 1);
18+// Window::make_wtitle(buf, xsize, title, act);
19+// return;
20+//}
2121
22-void Window::make_wtitle(unsigned short *buf, int xsize, char *title, char act)
23-{
24- static char* closebtn[14]/*[16]*/ = {
25- "OOOOOOOOOOOOOOO@",
26- "OQQQQQQQQQQQQQ$@",
27- "OQQQQQQQQQQQQQ$@",
28- "OQQQ@@QQQQ@@QQ$@",
29- "OQQQQ@@QQ@@QQQ$@",
30- "OQQQQQ@@@@QQQQ$@",
31- "OQQQQQQ@@QQQQQ$@",
32- "OQQQQQ@@@@QQQQ$@",
33- "OQQQQ@@QQ@@QQQ$@",
34- "OQQQ@@QQQQ@@QQ$@",
35- "OQQQQQQQQQQQQQ$@",
36- "OQQQQQQQQQQQQQ$@",
37- "O$$$$$$$$$$$$$$@",
38- "@@@@@@@@@@@@@@@@"
39- };
40- int x, y;
41- char c, tc, tbc;
42- if (act != 0) {
43- tc = COL8_FFFFFF;
44- tbc = COL8_000084;
45- } else {
46- tc = COL8_C6C6C6;
47- tbc = COL8_848484;
48- }
49- Graphics::fill_rect(buf, xsize, tbc, 3, 3, xsize - 4, 20);
50- Graphics::draw_string(buf, xsize, 24, 4, tc, title);
51- for (y = 0; y < 14; y++) {
52- for (x = 0; x < 16; x++) {
53- c = closebtn[y][x];
54- if (c == '@') {
55- c = COL8_000000;
56- } else if (c == '$') {
57- c = COL8_848484;
58- } else if (c == 'Q') {
59- c = COL8_C6C6C6;
60- } else {
61- c = COL8_FFFFFF;
62- }
63- buf[(5 + y) * xsize + (xsize - 21 + x)] = table_8_565[c & 0xff];
64- }
65- }
66- return;
67-}
22+//void Window::make_wtitle(unsigned short *buf, int xsize, char *title, char act)
23+//{
24+// static char* closebtn[14]/*[16]*/ = {
25+// "OOOOOOOOOOOOOOO@",
26+// "OQQQQQQQQQQQQQ$@",
27+// "OQQQQQQQQQQQQQ$@",
28+// "OQQQ@@QQQQ@@QQ$@",
29+// "OQQQQ@@QQ@@QQQ$@",
30+// "OQQQQQ@@@@QQQQ$@",
31+// "OQQQQQQ@@QQQQQ$@",
32+// "OQQQQQ@@@@QQQQ$@",
33+// "OQQQQ@@QQ@@QQQ$@",
34+// "OQQQ@@QQQQ@@QQ$@",
35+// "OQQQQQQQQQQQQQ$@",
36+// "OQQQQQQQQQQQQQ$@",
37+// "O$$$$$$$$$$$$$$@",
38+// "@@@@@@@@@@@@@@@@"
39+// };
40+// int x, y;
41+// char c, tc, tbc;
42+// if (act != 0) {
43+// tc = COL8_FFFFFF;
44+// tbc = COL8_000084;
45+// } else {
46+// tc = COL8_C6C6C6;
47+// tbc = COL8_848484;
48+// }
49+// Graphics::fill_rect(buf, xsize, tbc, 3, 3, xsize - 4, 20);
50+// Graphics::draw_string(buf, xsize, 24, 4, tc, title);
51+// for (y = 0; y < 14; y++) {
52+// for (x = 0; x < 16; x++) {
53+// c = closebtn[y][x];
54+// if (c == '@') {
55+// c = COL8_000000;
56+// } else if (c == '$') {
57+// c = COL8_848484;
58+// } else if (c == 'Q') {
59+// c = COL8_C6C6C6;
60+// } else {
61+// c = COL8_FFFFFF;
62+// }
63+// buf[(5 + y) * xsize + (xsize - 21 + x)] = table_8_565[c & 0xff];
64+// }
65+// }
66+// return;
67+//}
6868
69-void Window::putfonts_asc_sht(Sheet *sht, int x, int y, int c, int b, char *s, int l)
69+void Window::putfonts_asc_sheet(Sheet *sheet, int x, int y, int c, int b, char *s, int l)
7070 {
7171 Task *task = Task::now();
72- Graphics::fill_rect(sht->buf, sht->bxsize, b, x, y, x + l * 8 - 1, y + 15);
72+ Graphics::fill_rect(sheet->buf, sheet->bxsize, b, x, y, x + l * 8 - 1, y + 15);
7373 if (task->langmode != 0 && task->langbyte1 != 0) {
74- Graphics::draw_string(sht->buf, sht->bxsize, x, y, c, s);
75- Sheet::refresh(sht, x - 8, y, x + l * 8, y + 16);
74+ Graphics::draw_string(sheet->buf, sheet->bxsize, x, y, c, s);
75+ Sheet::refresh(sheet, x - 8, y, x + l * 8, y + 16);
7676 } else {
77- Graphics::draw_string(sht->buf, sht->bxsize, x, y, c, s);
78- Sheet::refresh(sht, x, y, x + l * 8, y + 16);
77+ Graphics::draw_string(sheet->buf, sheet->bxsize, x, y, c, s);
78+ Sheet::refresh(sheet, x, y, x + l * 8, y + 16);
7979 }
8080 return;
8181 }
8282
83-void Window::make_textbox(Sheet *sht, int x0, int y0, int sx, int sy, int c)
84-{
85- int x1 = x0 + sx, y1 = y0 + sy;
86- Graphics::fill_rect(sht->buf, sht->bxsize, COL8_848484, x0 - 2, y0 - 3, x1 + 1, y0 - 3);
87- Graphics::fill_rect(sht->buf, sht->bxsize, COL8_848484, x0 - 3, y0 - 3, x0 - 3, y1 + 1);
88- Graphics::fill_rect(sht->buf, sht->bxsize, COL8_FFFFFF, x0 - 3, y1 + 2, x1 + 1, y1 + 2);
89- Graphics::fill_rect(sht->buf, sht->bxsize, COL8_FFFFFF, x1 + 2, y0 - 3, x1 + 2, y1 + 2);
90- Graphics::fill_rect(sht->buf, sht->bxsize, COL8_000000, x0 - 1, y0 - 2, x1 + 0, y0 - 2);
91- Graphics::fill_rect(sht->buf, sht->bxsize, COL8_000000, x0 - 2, y0 - 2, x0 - 2, y1 + 0);
92- Graphics::fill_rect(sht->buf, sht->bxsize, COL8_C6C6C6, x0 - 2, y1 + 1, x1 + 0, y1 + 1);
93- Graphics::fill_rect(sht->buf, sht->bxsize, COL8_C6C6C6, x1 + 1, y0 - 2, x1 + 1, y1 + 1);
94- Graphics::fill_rect(sht->buf, sht->bxsize, c, x0 - 1, y0 - 1, x1 + 0, y1 + 0);
95- return;
96-}
83+//void Window::make_textbox(Sheet *sheet, int x0, int y0, int sx, int sy, int c)
84+//{
85+// int x1 = x0 + sx, y1 = y0 + sy;
86+// Graphics::fill_rect(sheet->buf, sheet->bxsize, COL8_848484, x0 - 2, y0 - 3, x1 + 1, y0 - 3);
87+// Graphics::fill_rect(sheet->buf, sheet->bxsize, COL8_848484, x0 - 3, y0 - 3, x0 - 3, y1 + 1);
88+// Graphics::fill_rect(sheet->buf, sheet->bxsize, COL8_FFFFFF, x0 - 3, y1 + 2, x1 + 1, y1 + 2);
89+// Graphics::fill_rect(sheet->buf, sheet->bxsize, COL8_FFFFFF, x1 + 2, y0 - 3, x1 + 2, y1 + 2);
90+// Graphics::fill_rect(sheet->buf, sheet->bxsize, COL8_000000, x0 - 1, y0 - 2, x1 + 0, y0 - 2);
91+// Graphics::fill_rect(sheet->buf, sheet->bxsize, COL8_000000, x0 - 2, y0 - 2, x0 - 2, y1 + 0);
92+// Graphics::fill_rect(sheet->buf, sheet->bxsize, COL8_C6C6C6, x0 - 2, y1 + 1, x1 + 0, y1 + 1);
93+// Graphics::fill_rect(sheet->buf, sheet->bxsize, COL8_C6C6C6, x1 + 1, y0 - 2, x1 + 1, y1 + 1);
94+// Graphics::fill_rect(sheet->buf, sheet->bxsize, c, x0 - 1, y0 - 1, x1 + 0, y1 + 0);
95+// return;
96+//}
9797
98-void Window::change_wtitle(Sheet *sht, char act)
98+void Window::change_wtitle(Sheet *sheet, char act)
9999 {
100- int x, y, xsize = sht->bxsize;
100+ int x, y, xsize = sheet->bxsize;
101101 unsigned char tc_new, tbc_new, tc_old, tbc_old;
102- unsigned short c565, *buf = sht->buf;
102+ unsigned short c565, *buf = sheet->buf;
103103 if (act != 0) {
104104 tc_new = COL8_FFFFFF;
105105 tbc_new = COL8_000084;
@@ -122,6 +122,6 @@
122122 buf[y * xsize + x] = c565;
123123 }
124124 }
125- Sheet::refresh(sht, 3, 3, xsize, 21);
125+ Sheet::refresh(sheet, 3, 3, xsize, 21);
126126 return;
127127 }
--- haribote/trunk/bayos_exp/file.cpp (revision 181)
+++ haribote/trunk/bayos_exp/file.cpp (revision 182)
@@ -75,16 +75,16 @@
7575 unsigned char *File::load_file2(int clustno, int *psize, int *fat)
7676 {
7777 int size = *psize, size2;
78- MemoryManager *memman = (MemoryManager *) MEMMAN_ADDR;
78+ MemoryManager *memory_manager = (MemoryManager *) MEMMAN_ADDR;
7979 unsigned char *buf, *buf2;
80- buf = (unsigned char *) MemoryManager::allocate_4k(memman, size);
80+ buf = (unsigned char *) MemoryManager::allocate_4k(memory_manager, size);
8181 File::load_file(clustno, size, buf, fat, (unsigned char *) (ADR_DISKIMG + 0x003e00));
8282 if (size >= 17) {
8383 size2 = tek_getsize(buf);
8484 if (size2 > 0) { /* tek圧縮がかかっていた */
85- buf2 = (unsigned char *) MemoryManager::allocate_4k(memman, size2);
85+ buf2 = (unsigned char *) MemoryManager::allocate_4k(memory_manager, size2);
8686 tek_decomp(buf, buf2, size2);
87- MemoryManager::deallocate_4k(memman, (int) buf, size);
87+ MemoryManager::deallocate_4k(memory_manager, (int) buf, size);
8888 buf = buf2;
8989 *psize = size2;
9090 }
--- haribote/trunk/bayos_exp/timer.cpp (revision 181)
+++ haribote/trunk/bayos_exp/timer.cpp (revision 182)
@@ -5,7 +5,7 @@
55 #define PIT_CTRL 0x0043
66 #define PIT_CNT0 0x0040
77
8-TimerManager timerctl;
8+TimerManager timer_manager;
99
1010 #define TIMER_FLAGS_ALLOC 1 /* 確保した状態 */
1111 #define TIMER_FLAGS_USING 2 /* タイマ作動中 */
@@ -15,25 +15,25 @@
1515 io_out8(PIT_CTRL, 0x34);
1616 io_out8(PIT_CNT0, 0x9c);
1717 io_out8(PIT_CNT0, 0x2e);
18- timerctl.count = 0;
19- timerctl.next = 0xffffffff; /* 番兵しかいないので番兵の時刻 */
18+ timer_manager.count = 0;
19+ timer_manager.next = 0xffffffff; /* 番兵しかいないので番兵の時刻 */
2020 return;
2121 }
2222
2323 void TimerManager::init(void)
2424 {
25- MemoryManager *memman = (MemoryManager *) MEMMAN_ADDR;
25+ MemoryManager *memory_manager = (MemoryManager *) MEMMAN_ADDR;
2626 int i;
2727 Timer *t;
28- timerctl.timers0 = (Timer *) MemoryManager::allocate_4k(memman, MAX_TIMER * sizeof(Timer));
28+ timer_manager.timers0 = (Timer *) MemoryManager::allocate_4k(memory_manager, MAX_TIMER * sizeof(Timer));
2929 for (i = 0; i < MAX_TIMER; i++) {
30- timerctl.timers0[i].flags = 0; /* 未使用 */
30+ timer_manager.timers0[i].flags = 0; /* 未使用 */
3131 }
3232 t = Timer::allocate(); /* 一つもらってくる */
3333 t->timeout = 0xffffffff;
3434 t->flags = TIMER_FLAGS_USING;
3535 t->next = 0; /* 一番うしろ */
36- timerctl.t0 = t; /* 今は番兵しかいないので先頭でもある */
36+ timer_manager.t0 = t; /* 今は番兵しかいないので先頭でもある */
3737 return;
3838 }
3939
@@ -41,10 +41,10 @@
4141 {
4242 int i;
4343 for (i = 0; i < MAX_TIMER; i++) {
44- if (timerctl.timers0[i].flags == 0) {
45- timerctl.timers0[i].flags = TIMER_FLAGS_ALLOC;
46- timerctl.timers0[i].flags2 = 0;
47- return &timerctl.timers0[i];
44+ if (timer_manager.timers0[i].flags == 0) {
45+ timer_manager.timers0[i].flags = TIMER_FLAGS_ALLOC;
46+ timer_manager.timers0[i].flags2 = 0;
47+ return &timer_manager.timers0[i];
4848 }
4949 }
5050 return 0; /* 見つからなかった */
@@ -57,9 +57,9 @@
5757 return;
5858 }
5959
60-void Timer::init(Timer *timer, Queue *fifo, int data)
60+void Timer::init(Timer *timer, Queue *queue, int data)
6161 {
62- timer->fifo = fifo;
62+ timer->queue = queue;
6363 timer->data = data;
6464 return;
6565 }
@@ -68,16 +68,16 @@
6868 {
6969 int e;
7070 Timer *t, *s;
71- timer->timeout = timeout + timerctl.count;
71+ timer->timeout = timeout + timer_manager.count;
7272 timer->flags = TIMER_FLAGS_USING;
7373 e = io_load_eflags();
7474 io_cli();
75- t = timerctl.t0;
75+ t = timer_manager.t0;
7676 if (timer->timeout <= t->timeout) {
7777 /* 先頭に入れる場合 */
78- timerctl.t0 = timer;
78+ timer_manager.t0 = timer;
7979 timer->next = t; /* 次はt */
80- timerctl.next = timer->timeout;
80+ timer_manager.next = timer->timeout;
8181 io_store_eflags(e);
8282 return;
8383 }
@@ -100,27 +100,27 @@
100100 Timer *timer;
101101 char ts = 0;
102102 io_out8(PIC0_OCW2, 0x60); /* IRQ-00受付完了をPICに通知 */
103- timerctl.count++;
104- if (timerctl.next > timerctl.count) {
103+ timer_manager.count++;
104+ if (timer_manager.next > timer_manager.count) {
105105 return;
106106 }
107- timer = timerctl.t0; /* とりあえず先頭の番地をtimerに代入 */
107+ timer = timer_manager.t0; /* とりあえず先頭の番地をtimerに代入 */
108108 for (;;) {
109109 /* timersのタイマは全て動作中のものなので、flagsを確認しない */
110- if (timer->timeout > timerctl.count) {
110+ if (timer->timeout > timer_manager.count) {
111111 break;
112112 }
113113 /* タイムアウト */
114114 timer->flags = TIMER_FLAGS_ALLOC;
115115 if (timer != task_timer) {
116- Queue::push(timer->fifo, timer->data);
116+ Queue::push(timer->queue, timer->data);
117117 } else {
118118 ts = 1; /* task_timerがタイムアウトした */
119119 }
120120 timer = timer->next; /* 次のタイマの番地をtimerに代入 */
121121 }
122- timerctl.t0 = timer;
123- timerctl.next = timer->timeout;
122+ timer_manager.t0 = timer;
123+ timer_manager.next = timer->timeout;
124124 if (ts != 0) {
125125 Task::switcher();
126126 }
@@ -134,15 +134,15 @@
134134 e = io_load_eflags();
135135 io_cli(); /* 設定中にタイマの状態が変化しないようにするため */
136136 if (timer->flags == TIMER_FLAGS_USING) { /* 取り消し処理は必要か? */
137- if (timer == timerctl.t0) {
137+ if (timer == timer_manager.t0) {
138138 /* 先頭だった場合の取り消し処理 */
139139 t = timer->next;
140- timerctl.t0 = t;
141- timerctl.next = t->timeout;
140+ timer_manager.t0 = t;
141+ timer_manager.next = t->timeout;
142142 } else {
143143 /* 先頭以外の場合の取り消し処理 */
144144 /* timerの一つ前を探す */
145- t = timerctl.t0;
145+ t = timer_manager.t0;
146146 for (;;) {
147147 if (t->next == timer) {
148148 break;
@@ -159,7 +159,7 @@
159159 return 0; /* キャンセル処理は不要だった */
160160 }
161161
162-void Timer::cancel_all(Queue *fifo)
162+void Timer::cancel_all(Queue *queue)
163163 {
164164 int e, i;
165165 Timer *t;
@@ -166,8 +166,8 @@
166166 e = io_load_eflags();
167167 io_cli(); /* 設定中にタイマの状態が変化しないようにするため */
168168 for (i = 0; i < MAX_TIMER; i++) {
169- t = &timerctl.timers0[i];
170- if (t->flags != 0 && t->flags2 != 0 && t->fifo == fifo) {
169+ t = &timer_manager.timers0[i];
170+ if (t->flags != 0 && t->flags2 != 0 && t->queue == queue) {
171171 Timer::cancel(t);
172172 Timer::deallocate(t);
173173 }
--- haribote/trunk/bayos_exp/mouse.cpp (revision 181)
+++ haribote/trunk/bayos_exp/mouse.cpp (revision 182)
@@ -3,7 +3,7 @@
33 #include "bootpack.h"
44 #include <stdio.h>
55
6-Queue *mousefifo;
6+Queue *mousequeue;
77 int mousedata0;
88
99 void inthandler2c(int *esp)
@@ -13,7 +13,7 @@
1313 io_out8(PIC1_OCW2, 0x64); /* IRQ-12受付完了をPIC1に通知 */
1414 io_out8(PIC0_OCW2, 0x62); /* IRQ-02受付完了をPIC0に通知 */
1515 data = io_in8(PORT_KEYDAT);
16- Queue::push(mousefifo, data + mousedata0);
16+ Queue::push(mousequeue, data + mousedata0);
1717 return;
1818 }
1919
@@ -61,7 +61,7 @@
6161 #define KEYCMD_SENDTO_MOUSE 0xd4
6262 #define MOUSECMD_ENABLE 0xf4
6363
64-void Mouse::init(Queue *fifo, int data0, Mouse *mdec)
64+void Mouse::init(Queue *queue, int data0, Mouse *mouse)
6565 {
6666 int result, i;
6767 static unsigned char cmd[7] = {
@@ -75,7 +75,7 @@
7575 };
7676
7777 /* 書き込み先のFIFOバッファを記憶 */
78- mousefifo = fifo;
78+ mousequeue = queue;
7979 mousedata0 = data0;
8080
8181 /* ホイールマウス初期化 */
@@ -95,9 +95,9 @@
9595
9696 /* ホイールが有効かどうかチェック */
9797 if (result == 0x03) {
98- mdec->scrollmode = 1;
98+ mouse->scrollmode = 1;
9999 } else {
100- mdec->scrollmode = 0;
100+ mouse->scrollmode = 0;
101101 }
102102
103103 /* マウス有効 */
@@ -106,69 +106,69 @@
106106 Keyboard::sendready();
107107 io_out8(PORT_KEYDAT, MOUSECMD_ENABLE);
108108 /* うまくいくとACK(0xfa)が送信されてくる */
109- mdec->phase = 0; /* マウスの0xfaを待っている段階 */
109+ mouse->phase = 0; /* マウスの0xfaを待っている段階 */
110110 return;
111111 }
112112
113-int Mouse::decode(Mouse *mdec, unsigned char dat)
113+int Mouse::decode(Mouse *mouse, unsigned char dat)
114114 {
115- if (mdec->phase == 0) {
115+ if (mouse->phase == 0) {
116116 /* マウスの0xfaを待っている段階 */
117117 if (dat == 0xfa) {
118- mdec->phase = 1;
118+ mouse->phase = 1;
119119 }
120120 return 0;
121121 }
122- if (mdec->phase == 1) {
122+ if (mouse->phase == 1) {
123123 /* マウスの1バイト目を待っている段階 */
124124 if ((dat & 0xc8) == 0x08) {
125125 /* 正しい1バイト目だった */
126- mdec->buf[0] = dat;
127- mdec->phase = 2;
126+ mouse->buf[0] = dat;
127+ mouse->phase = 2;
128128 }
129129 return 0;
130130 }
131- if (mdec->phase == 2) {
131+ if (mouse->phase == 2) {
132132 /* マウスの2バイト目を待っている段階 */
133- mdec->buf[1] = dat;
134- mdec->phase = 3;
133+ mouse->buf[1] = dat;
134+ mouse->phase = 3;
135135 return 0;
136136 }
137- if (mdec->phase == 3) {
137+ if (mouse->phase == 3) {
138138 /* マウスの3バイト目を待っている段階 */
139- mdec->buf[2] = dat;
140- if (mdec->scrollmode != 0) {
141- mdec->phase = 4;
139+ mouse->buf[2] = dat;
140+ if (mouse->scrollmode != 0) {
141+ mouse->phase = 4;
142142 } else {
143- mdec->phase = 1;
143+ mouse->phase = 1;
144144 }
145- mdec->btn = mdec->buf[0] & 0x07;
146- mdec->x = mdec->buf[1];
147- mdec->y = mdec->buf[2];
148- if ((mdec->buf[0] & 0x10) != 0) {
149- mdec->x |= 0xffffff00;
145+ mouse->btn = mouse->buf[0] & 0x07;
146+ mouse->x = mouse->buf[1];
147+ mouse->y = mouse->buf[2];
148+ if ((mouse->buf[0] & 0x10) != 0) {
149+ mouse->x |= 0xffffff00;
150150 }
151- if ((mdec->buf[0] & 0x20) != 0) {
152- mdec->y |= 0xffffff00;
151+ if ((mouse->buf[0] & 0x20) != 0) {
152+ mouse->y |= 0xffffff00;
153153 }
154- mdec->y = - mdec->y; /* マウスではy方向の符号が画面と反対 */
155- if (mdec->scrollmode != 0) {
154+ mouse->y = - mouse->y; /* マウスではy方向の符号が画面と反対 */
155+ if (mouse->scrollmode != 0) {
156156 return 0;
157157 } else {
158158 return 1;
159159 }
160160 }
161- if (mdec->phase == 4) {
161+ if (mouse->phase == 4) {
162162 /* マウスの4バイト目を待っている段階 */
163- mdec->buf[3] = dat;
163+ mouse->buf[3] = dat;
164164 /* スクロール対応マウスのみスクロール */
165- mdec->phase = 1;
166- /* mdec.buf[3]は、下位4ビットだけが有効な値である */
165+ mouse->phase = 1;
166+ /* mouse.buf[3]は、下位4ビットだけが有効な値である */
167167 /* とりあえず解析せずに値をしまう */
168- mdec->scroll = mdec->buf[3] & 0x0f;
169- if (mdec->scroll & 0x08) {
168+ mouse->scroll = mouse->buf[3] & 0x0f;
169+ if (mouse->scroll & 0x08) {
170170 /* マイナスの値だった */
171- mdec->scroll |= 0xfffffff0;
171+ mouse->scroll |= 0xfffffff0;
172172 }
173173 return 1;
174174 }
--- haribote/trunk/bayos_exp/Makefile (revision 181)
+++ haribote/trunk/bayos_exp/Makefile (revision 182)
@@ -1,6 +1,6 @@
1-OBJS_BOOTPACK = bootpack.obj naskfunc.obj hankaku.obj graphic.obj dsctbl.obj \
2- int.obj fifo.obj keyboard.obj mouse.obj memory.obj sheet.obj timer.obj \
3- mtask.obj window.obj console.obj file.obj tek.obj jpeg.obj alloca.obj
1+OBJS_BOOTPACK = bootpack.obj naskfunc.obj hankaku.obj graphic.obj descriptor.obj \
2+ pic.obj queue.obj keyboard.obj mouse.obj memory.obj sheet.obj timer.obj \
3+ mtask.obj window.obj gui.obj console.obj file.obj tek.obj alloca.obj
44
55 TOOLPATH = ../z_tools/
66 INCPATH = ../z_tools/haribote/
--- haribote/trunk/bayos_exp/keyboard.cpp (revision 181)
+++ haribote/trunk/bayos_exp/keyboard.cpp (revision 182)
@@ -2,7 +2,7 @@
22
33 #include "bootpack.h"
44
5-Queue *keyfifo;
5+Queue *keyqueue;
66 int keydata0;
77
88 void inthandler21(int *esp)
@@ -10,7 +10,7 @@
1010 int data;
1111 io_out8(PIC0_OCW2, 0x61); /* IRQ-01受付完了をPICに通知 */
1212 data = io_in8(PORT_KEYDAT);
13- Queue::push(keyfifo, data + keydata0);
13+ Queue::push(keyqueue, data + keydata0);
1414 return;
1515 }
1616
@@ -30,10 +30,10 @@
3030 return;
3131 }
3232
33-void Keyboard::init(Queue *fifo, int data0)
33+void Keyboard::init(Queue *queue, int data0)
3434 {
3535 /* 書き込み先のFIFOバッファを記憶 */
36- keyfifo = fifo;
36+ keyqueue = queue;
3737 keydata0 = data0;
3838 /* キーボードコントローラの初期化 */
3939 Keyboard::sendready();
--- haribote/trunk/bayos_exp/console.cpp (revision 181)
+++ haribote/trunk/bayos_exp/console.cpp (revision 182)
@@ -9,24 +9,24 @@
99 void console_task(Sheet *sheet, int memtotal)
1010 {
1111 Task *task = Task::now();
12- MemoryManager *memman = (MemoryManager *) MEMMAN_ADDR;
13- int i, *fat = (int *) MemoryManager::allocate_4k(memman, 4 * 2880);
14- Console cons;
12+ MemoryManager *memory_manager = (MemoryManager *) MEMMAN_ADDR;
13+ int i, *fat = (int *) MemoryManager::allocate_4k(memory_manager, 4 * 2880);
14+ Console console;
1515 FileHandle fhandle[8];
1616 char cmdline[30];
1717 unsigned char *nihongo = (unsigned char *) *((int *) 0x0fe8);
1818
19- cons.sht = sheet;
20- cons.cur_x = 8;
21- cons.cur_y = 28;
22- cons.cur_c = -1;
23- task->cons = &cons;
19+ console.sheet = sheet;
20+ console.cur_x = 8;
21+ console.cur_y = 28;
22+ console.cur_c = -1;
23+ task->console = &console;
2424 task->cmdline = cmdline;
2525
26- if (cons.sht != 0) {
27- cons.timer = Timer::allocate();
28- Timer::init(cons.timer, &task->fifo, 1);
29- Timer::set_time(cons.timer, 50);
26+ if (console.sheet != 0) {
27+ console.timer = Timer::allocate();
28+ Timer::init(console.timer, &task->queue, 1);
29+ Timer::set_time(console.timer, 50);
3030 }
3131 File::read_fat(fat, (unsigned char *) (ADR_DISKIMG + 0x000200));
3232 for (i = 0; i < 8; i++) {
@@ -42,85 +42,85 @@
4242 task->langbyte1 = 0;
4343
4444 /* プロンプト表示 */
45- Console::put_char(&cons, '>', 1);
45+ Console::put_char(&console, '>', 1);
4646
4747 for (;;) {
4848 io_cli();
49- if (Queue::status(&task->fifo) == 0) {
49+ if (Queue::status(&task->queue) == 0) {
5050 Task::sleep(task);
5151 io_sti();
5252 } else {
53- i = Queue::pop(&task->fifo);
53+ i = Queue::pop(&task->queue);
5454 io_sti();
55- if (i <= 1 && cons.sht != 0) { /* カーソル用タイマ */
55+ if (i <= 1 && console.sheet != 0) { /* カーソル用タイマ */
5656 if (i != 0) {
57- Timer::init(cons.timer, &task->fifo, 0); /* 次は0を */
58- if (cons.cur_c >= 0) {
59- cons.cur_c = COL8_FFFFFF;
57+ Timer::init(console.timer, &task->queue, 0); /* 次は0を */
58+ if (console.cur_c >= 0) {
59+ console.cur_c = COL8_000000;
6060 }
6161 } else {
62- Timer::init(cons.timer, &task->fifo, 1); /* 次は1を */
63- if (cons.cur_c >= 0) {
64- cons.cur_c = COL8_000000;
62+ Timer::init(console.timer, &task->queue, 1); /* 次は1を */
63+ if (console.cur_c >= 0) {
64+ console.cur_c = COL8_C6C6C6;
6565 }
6666 }
67- Timer::set_time(cons.timer, 50);
67+ Timer::set_time(console.timer, 50);
6868 }
6969 if (i == 2) { /* カーソルON */
70- cons.cur_c = COL8_FFFFFF;
70+ console.cur_c = COL8_000000;
7171 }
7272 if (i == 3) { /* カーソルOFF */
73- if (cons.sht != 0) {
74- Graphics::fill_rect(cons.sht->buf, cons.sht->bxsize, COL8_000000,
75- cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15);
73+ if (console.sheet != 0) {
74+ Graphics::fill_rect(console.sheet->buf, console.sheet->bxsize, COL8_C6C6C6,
75+ console.cur_x, console.cur_y, console.cur_x + 7, console.cur_y + 15);
7676 }
77- cons.cur_c = -1;
77+ console.cur_c = -1;
7878 }
7979 if (i == 4) { /* コンソールの「×」ボタンクリック */
80- Console::command_exit(&cons, fat);
80+ Console::command_exit(&console, fat);
8181 }
8282 if (256 <= i && i <= 511) { /* キーボードデータ(タスクA経由) */
8383 if (i == 8 + 256) {
8484 /* バックスペース */
85- if (cons.cur_x > 16) {
85+ if (console.cur_x > 16) {
8686 /* カーソルをスペースで消してから、カーソルを1つ戻す */
87- Console::put_char(&cons, ' ', 0);
88- cons.cur_x -= 8;
87+ Console::put_char(&console, ' ', 0);
88+ console.cur_x -= 8;
8989 }
9090 } else if (i == 10 + 256) {
9191 /* Enter */
9292 /* カーソルをスペースで消してから改行する */
93- Console::put_char(&cons, ' ', 0);
94- cmdline[cons.cur_x / 8 - 2] = 0;
95- Console::new_line(&cons);
96- Console::run_command(cmdline, &cons, fat, memtotal); /* コマンド実行 */
97- if (cons.sht == 0) {
98- Console::command_exit(&cons, fat);
93+ Console::put_char(&console, ' ', 0);
94+ cmdline[console.cur_x / 8 - 2] = 0;
95+ Console::new_line(&console);
96+ Console::run_command(cmdline, &console, fat, memtotal); /* コマンド実行 */
97+ if (console.sheet == 0) {
98+ Console::command_exit(&console, fat);
9999 }
100100 /* プロンプト表示 */
101- Console::put_char(&cons, '>', 1);
101+ Console::put_char(&console, '>', 1);
102102 } else {
103103 /* 一般文字 */
104- if (cons.cur_x < 240) {
104+ if (console.cur_x < 240) {
105105 /* 一文字表示してから、カーソルを1つ進める */
106- cmdline[cons.cur_x / 8 - 2] = i - 256;
107- Console::put_char(&cons, i - 256, 1);
106+ cmdline[console.cur_x / 8 - 2] = i - 256;
107+ Console::put_char(&console, i - 256, 1);
108108 }
109109 }
110110 }
111111 /* カーソル再表示 */
112- if (cons.sht != 0) {
113- if (cons.cur_c >= 0) {
114- Graphics::fill_rect(cons.sht->buf, cons.sht->bxsize, cons.cur_c,
115- cons.cur_x, cons.cur_y, cons.cur_x + 7, cons.cur_y + 15);
112+ if (console.sheet != 0) {
113+ if (console.cur_c >= 0) {
114+ Graphics::fill_rect(console.sheet->buf, console.sheet->bxsize, console.cur_c,
115+ console.cur_x, console.cur_y, console.cur_x + 7, console.cur_y + 15);
116116 }
117- Sheet::refresh(cons.sht, cons.cur_x, cons.cur_y, cons.cur_x + 8, cons.cur_y + 16);
117+ Sheet::refresh(console.sheet, console.cur_x, console.cur_y, console.cur_x + 8, console.cur_y + 16);
118118 }
119119 }
120120 }
121121 }
122122
123-void Console::put_char(Console *cons, int chr, char move)
123+void Console::put_char(Console *console, int chr, char move)
124124 {
125125 char s[2];
126126 s[0] = chr;
@@ -127,30 +127,30 @@
127127 s[1] = 0;
128128 if (s[0] == 0x09) { /* タブ */
129129 for (;;) {
130- if (cons->sht != 0) {
131- Window::putfonts_asc_sht(cons->sht, cons->cur_x, cons->cur_y, COL8_FFFFFF, COL8_000000, " ", 1);
130+ if (console->sheet != 0) {
131+ Window::putfonts_asc_sheet(console->sheet, console->cur_x, console->cur_y, COL8_000000, COL8_C6C6C6, " ", 1);
132132 }
133- cons->cur_x += 8;
134- if (cons->cur_x == 8 + 240) {
135- Console::new_line(cons);
133+ console->cur_x += 8;
134+ if (console->cur_x == 8 + 240) {
135+ Console::new_line(console);
136136 }
137- if (((cons->cur_x - 8) & 0x1f) == 0) {
137+ if (((console->cur_x - 8) & 0x1f) == 0) {
138138 break; /* 32で割り切れたらbreak */
139139 }
140140 }
141141 } else if (s[0] == 0x0a) { /* 改行 */
142- Console::new_line(cons);
142+ Console::new_line(console);
143143 } else if (s[0] == 0x0d) { /* 復帰 */
144144 /* とりあえずなにもしない */
145145 } else { /* 普通の文字 */
146- if (cons->sht != 0) {
147- Window::putfonts_asc_sht(cons->sht, cons->cur_x, cons->cur_y, COL8_FFFFFF, COL8_000000, s, 1);
146+ if (console->sheet != 0) {
147+ Window::putfonts_asc_sheet(console->sheet, console->cur_x, console->cur_y, COL8_000000, COL8_C6C6C6, s, 1);
148148 }
149149 if (move != 0) {
150150 /* moveが0のときはカーソルを進めない */
151- cons->cur_x += 8;
152- if (cons->cur_x == 8 + 240) {
153- Console::new_line(cons);
151+ console->cur_x += 8;
152+ if (console->cur_x == 8 + 240) {
153+ Console::new_line(console);
154154 }
155155 }
156156 }
@@ -157,13 +157,13 @@
157157 return;
158158 }
159159
160-void Console::new_line(Console *cons)
160+void Console::new_line(Console *console)
161161 {
162162 int x, y;
163- Sheet *sheet = cons->sht;
163+ Sheet *sheet = console->sheet;
164164 Task *task = Task::now();
165- if (cons->cur_y < 28 + 112) {
166- cons->cur_y += 16; /* 次の行へ */
165+ if (console->cur_y < 28 + 112) {
166+ console->cur_y += 16; /* 次の行へ */
167167 } else {
168168 /* スクロール */
169169 if (sheet != 0) {
@@ -174,85 +174,85 @@
174174 }
175175 for (y = 28 + 112; y < 28 + 128; y++) {
176176 for (x = 8; x < 8 + 240; x++) {
177- sheet->buf[x + y * sheet->bxsize] = COL8_000000;
177+ sheet->buf[x + y * sheet->bxsize] = COL8_C6C6C6;
178178 }
179179 }
180180 Sheet::refresh(sheet, 8, 28, 8 + 240, 28 + 128);
181181 }
182182 }
183- cons->cur_x = 8;
183+ console->cur_x = 8;
184184 if (task->langmode == 1 && task->langbyte1 != 0) {
185- cons->cur_x = 16;
185+ console->cur_x = 16;
186186 }
187187 return;
188188 }
189189
190-void Console::put_str0(Console *cons, char *s)
190+void Console::put_str0(Console *console, char *s)
191191 {
192192 for (; *s != 0; s++) {
193- Console::put_char(cons, *s, 1);
193+ Console::put_char(console, *s, 1);
194194 }
195195 return;
196196 }
197197
198-void Console::put_str1(Console *cons, char *s, int l)
198+void Console::put_str1(Console *console, char *s, int l)
199199 {
200200 int i;
201201 for (i = 0; i < l; i++) {
202- Console::put_char(cons, s[i], 1);
202+ Console::put_char(console, s[i], 1);
203203 }
204204 return;
205205 }
206206
207-void Console::run_command(char *cmdline, Console *cons, int *fat, int memtotal)
207+void Console::run_command(char *cmdline, Console *console, int *fat, int memtotal)
208208 {
209- if (strcmp(cmdline, "mem") == 0 && cons->sht != 0) {
210- Console::command_mem(cons, memtotal);
211- } else if (strcmp(cmdline, "cls") == 0 && cons->sht != 0) {
212- Console::command_cls(cons);
213- } else if (strcmp(cmdline, "dir") == 0 && cons->sht != 0) {
214- Console::command_dir(cons);
209+ if (strcmp(cmdline, "mem") == 0 && console->sheet != 0) {
210+ Console::command_mem(console, memtotal);
211+ } else if (strcmp(cmdline, "cls") == 0 && console->sheet != 0) {
212+ Console::command_cls(console);
213+ } else if (strcmp(cmdline, "dir") == 0 && console->sheet != 0) {
214+ Console::command_dir(console);
215215 } else if (strcmp(cmdline, "exit") == 0) {
216- Console::command_exit(cons, fat);
216+ Console::command_exit(console, fat);
217217 } else if (strncmp(cmdline, "start ", 6) == 0) {
218- Console::command_start(cons, cmdline, memtotal);
218+ Console::command_start(console, cmdline, memtotal);
219219 } else if (strncmp(cmdline, "ncst ", 5) == 0) {
220- Console::command_ncst(cons, cmdline, memtotal);
220+ Console::command_ncst(console, cmdline, memtotal);
221221 } else if (strncmp(cmdline, "langmode ", 9) == 0) {
222- Console::command_langmode(cons, cmdline);
222+ Console::command_langmode(console, cmdline);
223223 } else if (cmdline[0] != 0) {
224- if (Console::command_app(cons, fat, cmdline) == 0) {
224+ if (Console::command_app(console, fat, cmdline) == 0) {
225225 /* コマンドではなく、アプリでもなく、さらに空行でもない */
226- Console::put_str0(cons, "Bad command.\n\n");
226+ Console::put_str0(console, "Bad command.\n\n");
227227 }
228228 }
229229 return;
230230 }
231231
232-void Console::command_mem(Console *cons, int memtotal)
232+void Console::command_mem(Console *console, int memtotal)
233233 {
234- MemoryManager *memman = (MemoryManager *) MEMMAN_ADDR;
234+ MemoryManager *memory_manager = (MemoryManager *) MEMMAN_ADDR;
235235 char s[60];
236- sprintf(s, "total %dMB\nfree %dKB\n\n", memtotal / (1024 * 1024), MemoryManager::total(memman) / 1024);
237- Console::put_str0(cons, s);
236+ sprintf(s, "total %dMB\nfree %dKB\n\n", memtotal / (1024 * 1024), MemoryManager::total(memory_manager) / 1024);
237+ Console::put_str0(console, s);
238238 return;
239239 }
240240
241-void Console::command_cls(Console *cons)
241+void Console::command_cls(Console *console)
242242 {
243243 int x, y;
244- Sheet *sheet = cons->sht;
244+ Sheet *sheet = console->sheet;
245245 for (y = 28; y < 28 + 128; y++) {
246246 for (x = 8; x < 8 + 240; x++) {
247- sheet->buf[x + y * sheet->bxsize] = COL8_000000;
247+ sheet->buf[x + y * sheet->bxsize] = table_8_565[COL8_C6C6C6];
248248 }
249249 }
250250 Sheet::refresh(sheet, 8, 28, 8 + 240, 28 + 128);
251- cons->cur_y = 28;
251+ console->cur_y = 28;
252252 return;
253253 }
254254
255-void Console::command_dir(Console *cons)
255+void Console::command_dir(Console *console)
256256 {
257257 FileInfo *finfo = (FileInfo *) (ADR_DISKIMG + 0x002600);
258258 int i, j;
@@ -270,29 +270,29 @@
270270 s[ 9] = finfo[i].ext[0];
271271 s[10] = finfo[i].ext[1];
272272 s[11] = finfo[i].ext[2];
273- Console::put_str0(cons, s);
273+ Console::put_str0(console, s);
274274 }
275275 }
276276 }
277- Console::new_line(cons);
277+ Console::new_line(console);
278278 return;
279279 }
280280
281-void Console::command_exit(Console *cons, int *fat)
281+void Console::command_exit(Console *console, int *fat)
282282 {
283- MemoryManager *memman = (MemoryManager *) MEMMAN_ADDR;
283+ MemoryManager *memory_manager = (MemoryManager *) MEMMAN_ADDR;
284284 Task *task = Task::now();
285- SheetManager *shtctl = (SheetManager *) *((int *) 0x0fe4);
286- Queue *fifo = (Queue *) *((int *) 0x0fec);
287- if (cons->sht != 0) {
288- Timer::cancel(cons->timer);
285+ SheetManager *sheet_manager = (SheetManager *) *((int *) 0x0fe4);
286+ Queue *queue = (Queue *) *((int *) 0x0fec);
287+ if (console->sheet != 0) {
288+ Timer::cancel(console->timer);
289289 }
290- MemoryManager::deallocate_4k(memman, (int) fat, 4 * 2880);
290+ MemoryManager::deallocate_4k(memory_manager, (int) fat, 4 * 2880);
291291 io_cli();
292- if (cons->sht != 0) {
293- Queue::push(fifo, cons->sht - shtctl->sheets0 + 768); /* 768〜1023 */
292+ if (console->sheet != 0) {
293+ Queue::push(queue, console->sheet - sheet_manager->sheets0 + 768); /* 768〜1023 */
294294 } else {
295- Queue::push(fifo, task - taskctl->tasks0 + 1024); /* 1024〜2023 */
295+ Queue::push(queue, task - task_manager->tasks0 + 1024); /* 1024〜2023 */
296296 }
297297 io_sti();
298298 for (;;) {
@@ -300,38 +300,38 @@
300300 }
301301 }
302302
303-void Console::command_start(Console *cons, char *cmdline, int memtotal)
303+void Console::command_start(Console *console, char *cmdline, int memtotal)
304304 {
305- SheetManager *shtctl = (SheetManager *) *((int *) 0x0fe4);
306- Sheet *sht = open_console(shtctl, memtotal);
307- Queue *fifo = &sht->task->fifo;
305+ SheetManager *sheet_manager = (SheetManager *) *((int *) 0x0fe4);
306+ Sheet *sheet = open_console(sheet_manager, memtotal);
307+ Queue *queue = &sheet->task->queue;
308308 int i;
309- Sheet::slide(sht, 32, 4);
310- Sheet::up_down(sht, shtctl->top);
309+ Sheet::slide(sheet, 32, 4);
310+ Sheet::up_down(sheet, sheet_manager->top);
311311 /* コマンドラインに入力された文字列を、一文字ずつ新しいコンソールに入力 */
312312 for (i = 6; cmdline[i] != 0; i++) {
313- Queue::push(fifo, cmdline[i] + 256);
313+ Queue::push(queue, cmdline[i] + 256);
314314 }
315- Queue::push(fifo, 10 + 256); /* Enter */
316- Console::new_line(cons);
315+ Queue::push(queue, 10 + 256); /* Enter */
316+ Console::new_line(console);
317317 return;
318318 }
319319
320-void Console::command_ncst(Console *cons, char *cmdline, int memtotal)
320+void Console::command_ncst(Console *console, char *cmdline, int memtotal)
321321 {
322- Task *task = open_constask(0, memtotal);
323- Queue *fifo = &task->fifo;
322+ Task *task = open_console_task(0, memtotal);
323+ Queue *queue = &task->queue;
324324 int i;
325325 /* コマンドラインに入力された文字列を、一文字ずつ新しいコンソールに入力 */
326326 for (i = 5; cmdline[i] != 0; i++) {
327- Queue::push(fifo, cmdline[i] + 256);
327+ Queue::push(queue, cmdline[i] + 256);
328328 }
329- Queue::push(fifo, 10 + 256); /* Enter */
330- Console::new_line(cons);
329+ Queue::push(queue, 10 + 256); /* Enter */
330+ Console::new_line(console);
331331 return;
332332 }
333333
334-void Console::command_langmode(Console *cons, char *cmdline)
334+void Console::command_langmode(Console *console, char *cmdline)
335335 {
336336 Task *task = Task::now();
337337 unsigned char mode = cmdline[9] - '0';
@@ -338,22 +338,22 @@
338338 if (mode <= 2) {
339339 task->langmode = mode;
340340 } else {
341- Console::put_str0(cons, "mode number error.\n");
341+ Console::put_str0(console, "mode number error.\n");
342342 }
343- Console::new_line(cons);
343+ Console::new_line(console);
344344 return;
345345 }
346346
347-int Console::command_app(Console *cons, int *fat, char *cmdline)
347+int Console::command_app(Console *console, int *fat, char *cmdline)
348348 {
349- MemoryManager *memman = (MemoryManager *) MEMMAN_ADDR;
349+ MemoryManager *memory_manager = (MemoryManager *) MEMMAN_ADDR;
350350 FileInfo *finfo;
351351 char name[13], *q;
352352 unsigned char *p;
353353 Task *task = Task::now();
354354 int i, segsiz, datsiz, esp, dathrb, appsiz;
355- SheetManager *shtctl;
356- Sheet *sht;
355+ SheetManager *sheet_manager;
356+ Sheet *sheet;
357357
358358 /* コマンドラインからファイル名を生成 */
359359 for (i = 0; i < 8; i++) {
@@ -385,7 +385,7 @@
385385 esp = *((int *) (p + 0x000c));
386386 datsiz = *((int *) (p + 0x0010));
387387 dathrb = *((int *) (p + 0x0014));
388- q = (char *) MemoryManager::allocate_4k(memman, segsiz);
388+ q = (char *) MemoryManager::allocate_4k(memory_manager, segsiz);
389389 task->ds_base = (int) q;
390390 SegmentDescriptor::set(task->ldt + 0, appsiz - 1, (int) p, AR_CODE32_ER + 0x60);
391391 SegmentDescriptor::set(task->ldt + 1, segsiz - 1, (int) q, AR_DATA32_RW + 0x60);
@@ -393,28 +393,28 @@
393393 q[esp + i] = p[dathrb + i];
394394 }
395395 start_app(0x1b, 0 * 8 + 4, esp, 1 * 8 + 4, &(task->tss.esp0));
396- shtctl = (SheetManager *) *((int *) 0x0fe4);
396+ sheet_manager = (SheetManager *) *((int *) 0x0fe4);
397397 for (i = 0; i < MAX_SHEETS; i++) {
398- sht = &(shtctl->sheets0[i]);
399- if ((sht->flags & 0x11) == 0x11 && sht->task == task) {
398+ sheet = &(sheet_manager->sheets0[i]);
399+ if ((sheet->flags & 0x11) == 0x11 && sheet->task == task) {
400400 /* アプリが開きっぱなしにした下じきを発見 */
401- Sheet::deallocate(sht); /* 閉じる */
401+ Sheet::deallocate(sheet); /* 閉じる */
402402 }
403403 }
404404 for (i = 0; i < 8; i++) { /* クローズしてないファイルをクローズ */
405405 if (task->fhandle[i].buf != 0) {
406- MemoryManager::deallocate(memman, (int) task->fhandle[i].buf, task->fhandle[i].size);
406+ MemoryManager::deallocate(memory_manager, (int) task->fhandle[i].buf, task->fhandle[i].size);
407407 task->fhandle[i].buf = 0;
408408 }
409409 }
410- Timer::cancel_all(&task->fifo);
411- MemoryManager::deallocate_4k(memman, (int) q, segsiz);
410+ Timer::cancel_all(&task->queue);
411+ MemoryManager::deallocate_4k(memory_manager, (int) q, segsiz);
412412 task->langbyte1 = 0;
413413 } else {
414- Console::put_str0(cons, ".hrb file format error.\n");
414+ Console::put_str0(console, ".hrb file format error.\n");
415415 }
416- MemoryManager::deallocate_4k(memman, (int) p, appsiz);
417- Console::new_line(cons);
416+ MemoryManager::deallocate_4k(memory_manager, (int) p, appsiz);
417+ Console::new_line(console);
418418 return 1;
419419 }
420420 /* ファイルが見つからなかった場合 */
@@ -425,10 +425,10 @@
425425 {
426426 Task *task = Task::now();
427427 int ds_base = task->ds_base;
428- Console *cons = task->cons;
429- SheetManager *shtctl = (SheetManager *) *((int *) 0x0fe4);
430- Sheet *sht;
431- Queue *sys_fifo = (Queue *) *((int *) 0x0fec);
428+ Console *console = task->console;
429+ SheetManager *sheet_manager = (SheetManager *) *((int *) 0x0fe4);
430+ Sheet *sheet;
431+ Queue *sys_queue = (Queue *) *((int *) 0x0fec);
432432 int *reg = &eax + 1; /* eaxの次の番地 */
433433 /* 保存のためのPUSHADを強引に書き換える */
434434 /* reg[0] : EDI, reg[1] : ESI, reg[2] : EBP, reg[3] : ESP */
@@ -436,36 +436,37 @@
436436 int i;
437437 FileInfo *finfo;
438438 FileHandle *fh;
439- MemoryManager *memman = (MemoryManager *) MEMMAN_ADDR;
439+ MemoryManager *memory_manager = (MemoryManager *) MEMMAN_ADDR;
440440
441441 if (edx == 1) {
442- Console::put_char(cons, eax & 0xff, 1);
442+ Console::put_char(console, eax & 0xff, 1);
443443 } else if (edx == 2) {
444- Console::put_str0(cons, (char *) ebx + ds_base);
444+ Console::put_str0(console, (char *) ebx + ds_base);
445445 } else if (edx == 3) {
446- Console::put_str1(cons, (char *) ebx + ds_base, ecx);
446+ Console::put_str1(console, (char *) ebx + ds_base, ecx);
447447 } else if (edx == 4) {
448448 return &(task->tss.esp0);
449449 } else if (edx == 5) {
450- sht = Sheet::allocate(shtctl);
451- sht->task = task;
452- sht->flags |= 0x10;
453- Sheet::set_buffer(sht, (unsigned short *) (ebx + ds_base), esi, edi, eax);
454- Window::make_window((unsigned short *) (ebx + ds_base), esi, edi, (char *) ecx + ds_base, 0);
455- Sheet::slide(sht, ((shtctl->xsize - esi) / 2) & ~3, (shtctl->ysize - edi) / 2);
456- Sheet::up_down(sht, shtctl->top); /* 今のマウスと同じ高さになるように指定: マウスはこの上になる */
457- reg[7] = (int) sht;
450+ sheet = SheetManager::allocate(sheet_manager);
451+ sheet->task = task;
452+ sheet->flags |= 0x10;
453+ Sheet::set_buffer(sheet, (unsigned short *) (ebx + ds_base), esi, edi, eax);
454+ //Window::make_window((unsigned short *) (ebx + ds_base), esi, edi, (char *) ecx + ds_base, 0);
455+ Gui::drawFrame(sheet, (char *) ecx + ds_base);
456+ Sheet::slide(sheet, ((sheet_manager->xsize - esi) / 2) & ~3, (sheet_manager->ysize - edi) / 2);
457+ Sheet::up_down(sheet, sheet_manager->top); /* 今のマウスと同じ高さになるように指定: マウスはこの上になる */
458+ reg[7] = (int) sheet;
458459 } else if (edx == 6) {
459- sht = (Sheet *) (ebx & 0xfffffffe);
460- Graphics::draw_string(sht->buf, sht->bxsize, esi, edi, eax, (char *) ebp + ds_base);
460+ sheet = (Sheet *) (ebx & 0xfffffffe);
461+ Graphics::draw_string(sheet->buf, sheet->bxsize, esi, edi, eax, (char *) ebp + ds_base);
461462 if ((ebx & 1) == 0) {
462- Sheet::refresh(sht, esi, edi, esi + ecx * 8, edi + 16);
463+ Sheet::refresh(sheet, esi, edi, esi + ecx * 8, edi + 16);
463464 }
464465 } else if (edx == 7) {
465- sht = (Sheet *) (ebx & 0xfffffffe);
466- Graphics::fill_rect(sht->buf, sht->bxsize, ebp, eax, ecx, esi, edi);
466+ sheet = (Sheet *) (ebx & 0xfffffffe);
467+ Graphics::fill_rect(sheet->buf, sheet->bxsize, ebp, eax, ecx, esi, edi);
467468 if ((ebx & 1) == 0) {
468- Sheet::refresh(sht, eax, ecx, esi + 1, edi + 1);
469+ Sheet::refresh(sheet, eax, ecx, esi + 1, edi + 1);
469470 }
470471 } else if (edx == 8) {
471472 MemoryManager::init((MemoryManager *) (ebx + ds_base));
@@ -478,17 +479,17 @@
478479 ecx = (ecx + 0x0f) & 0xfffffff0; /* 16バイト単位に切り上げ */
479480 MemoryManager::deallocate((MemoryManager *) (ebx + ds_base), eax, ecx);
480481 } else if (edx == 11) {
481- sht = (Sheet *) (ebx & 0xfffffffe);
482- sht->buf[sht->bxsize * edi + esi] = table_8_565[eax];
482+ sheet = (Sheet *) (ebx & 0xfffffffe);
483+ sheet->buf[sheet->bxsize * edi + esi] = table_8_565[eax];
483484 if ((ebx & 1) == 0) {
484- Sheet::refresh(sht, esi, edi, esi + 1, edi + 1);
485+ Sheet::refresh(sheet, esi, edi, esi + 1, edi + 1);
485486 }
486487 } else if (edx == 12) {
487- sht = (Sheet *) ebx;
488- Sheet::refresh(sht, eax, ecx, esi, edi);
488+ sheet = (Sheet *) ebx;
489+ Sheet::refresh(sheet, eax, ecx, esi, edi);
489490 } else if (edx == 13) {
490- sht = (Sheet *) (ebx & 0xfffffffe);
491- Console::hrb_api_linewin(sht, eax, ecx, esi, edi, table_8_565[ebp]);
491+ sheet = (Sheet *) (ebx & 0xfffffffe);
492+ Console::hrb_api_linewin(sheet, eax, ecx, esi, edi, table_8_565[ebp]);
492493 if ((ebx & 1) == 0) {
493494 if (eax > esi) {
494495 i = eax;
@@ -500,7 +501,7 @@
500501 ecx = edi;
501502 edi = i;
502503 }
503- Sheet::refresh(sht, eax, ecx, esi + 1, edi + 1);
504+ Sheet::refresh(sheet, eax, ecx, esi + 1, edi + 1);
504505 }
505506 } else if (edx == 14) {
506507 Sheet::deallocate((Sheet *) ebx);
@@ -507,7 +508,7 @@
507508 } else if (edx == 15) {
508509 for (;;) {
509510 io_cli();
510- if (Queue::status(&task->fifo) == 0) {
511+ if (Queue::status(&task->queue) == 0) {
511512 if (eax != 0) {
512513 Task::sleep(task); /* FIFOが空なので寝て待つ */
513514 } else {
@@ -516,24 +517,24 @@
516517 return 0;
517518 }
518519 }
519- i = Queue::pop(&task->fifo);
520+ i = Queue::pop(&task->queue);
520521 io_sti();
521- if (i <= 1 && cons->sht != 0) { /* カーソル用タイマ */
522+ if (i <= 1 && console->sheet != 0) { /* カーソル用タイマ */
522523 /* アプリ実行中はカーソルが出ないので、いつも次は表示用の1を注文しておく */
523- Timer::init(cons->timer, &task->fifo, 1); /* 次は1を */
524- Timer::set_time(cons->timer, 50);
524+ Timer::init(console->timer, &task->queue, 1); /* 次は1を */
525+ Timer::set_time(console->timer, 50);
525526 }
526527 if (i == 2) { /* カーソルON */
527- cons->cur_c = COL8_FFFFFF;
528+ console->cur_c = COL8_000000;
528529 }
529530 if (i == 3) { /* カーソルOFF */
530- cons->cur_c = -1;
531+ console->cur_c = -1;
531532 }
532533 if (i == 4) { /* コンソールだけを閉じる */
533- Timer::cancel(cons->timer);
534+ Timer::cancel(console->timer);
534535 io_cli();
535- Queue::push(sys_fifo, cons->sht - shtctl->sheets0 + 2024); /* 2024〜2279 */
536- cons->sht = 0;
536+ Queue::push(sys_queue, console->sheet - sheet_manager->sheets0 + 2024); /* 2024〜2279 */
537+ console->sheet = 0;
537538 io_sti();
538539 }
539540 if (i >= 256) { /* キーボードデータ(タスクA経由)など */
@@ -545,7 +546,7 @@
545546 reg[7] = (int) Timer::allocate();
546547 ((Timer *) reg[7])->flags2 = 1; /* 自動キャンセル有効 */
547548 } else if (edx == 17) {
548- Timer::init((Timer *) ebx, &task->fifo, eax + 256);
549+ Timer::init((Timer *) ebx, &task->queue, eax + 256);
549550 } else if (edx == 18) {
550551 Timer::set_time((Timer *) ebx, eax);
551552 } else if (edx == 19) {
@@ -582,7 +583,7 @@
582583 }
583584 } else if (edx == 22) {
584585 fh = (FileHandle *) eax;
585- MemoryManager::deallocate(memman, (int) fh->buf, fh->size);
586+ MemoryManager::deallocate(memory_manager, (int) fh->buf, fh->size);
586587 fh->buf = 0;
587588 } else if (edx == 23) {
588589 fh = (FileHandle *) eax;
@@ -640,11 +641,11 @@
640641 int *inthandler0c(int *esp)
641642 {
642643 Task *task = Task::now();
643- Console *cons = task->cons;
644+ Console *console = task->console;
644645 char s[30];
645- Console::put_str0(cons, "\nINT 0C :\n Stack Exception.\n");
646+ Console::put_str0(console, "\nINT 0C :\n Stack Exception.\n");
646647 sprintf(s, "EIP = %08X\n", esp[11]);
647- Console::put_str0(cons, s);
648+ Console::put_str0(console, s);
648649 return &(task->tss.esp0); /* 異常終了させる */
649650 }
650651
@@ -651,15 +652,15 @@
651652 int *inthandler0d(int *esp)
652653 {
653654 Task *task = Task::now();
654- Console *cons = task->cons;
655+ Console *console = task->console;
655656 char s[30];
656- Console::put_str0(cons, "\nINT 0D :\n General Protected Exception.\n");
657+ Console::put_str0(console, "\nINT 0D :\n General Protected Exception.\n");
657658 sprintf(s, "EIP = %08X\n", esp[11]);
658- Console::put_str0(cons, s);
659+ Console::put_str0(console, s);
659660 return &(task->tss.esp0); /* 異常終了させる */
660661 }
661662
662-void Console::hrb_api_linewin(Sheet *sht, int x0, int y0, int x1, int y1, int col)
663+void Console::hrb_api_linewin(Sheet *sheet, int x0, int y0, int x1, int y1, int col)
663664 {
664665 int i, x, y, len, dx, dy;
665666
@@ -700,7 +701,7 @@
700701 }
701702
702703 for (i = 0; i < len; i++) {
703- sht->buf[(y >> 10) * sht->bxsize + (x >> 10)] = col;
704+ sheet->buf[(y >> 10) * sheet->bxsize + (x >> 10)] = col;
704705 x += dx;
705706 y += dy;
706707 }
--- haribote/trunk/bayos_exp/bootpack.h (revision 181)
+++ haribote/trunk/bayos_exp/bootpack.h (revision 182)
@@ -39,7 +39,7 @@
3939 void start_app(int eip, int cs, int esp, int ds, int *tss_esp0);
4040 void asm_end_app(void);
4141
42-/* fifo.c */
42+/* queue.c */
4343
4444 /* graphic.c */
4545
@@ -141,17 +141,6 @@
141141 int tek_getsize(unsigned char *p);
142142 int tek_decomp(unsigned char *p, unsigned char *q, int size);
143143
144-/* jpeg.c */
145-
146-struct DLL_STRPICENV { /* 64KB */
147- int work[64 * 1024 / 4];
148-};
149-struct RGB {
150- unsigned char b, g, r, t;
151-};
152-int info_JPEG(struct DLL_STRPICENV *env, int *info, int size, unsigned char *fp);
153-int decode0_JPEG(struct DLL_STRPICENV *env, int size, unsigned char *fp, int b_type, unsigned char *buf, int skip);
154-
155144 /* bootpack.c */
156145
157146 void HariMain(void);
@@ -178,7 +167,7 @@
178167 }
179168 };
180169
181-/* fifo.cpp */
170+/* queue.cpp */
182171
183172 class Task;
184173 class Queue {
@@ -188,10 +177,10 @@
188177 Task *task;
189178
190179 public:
191- static void init(Queue *fifo, int size, int *buf, Task *task);
192- static int push(Queue *fifo, int data);
193- static int pop(Queue *fifo);
194- static int status(Queue *fifo);
180+ static void init(Queue *queue, int size, int *buf, Task *task);
181+ static int push(Queue *queue, int data);
182+ static int pop(Queue *queue);
183+ static int status(Queue *queue);
195184 };
196185
197186 /* graphic.cpp */
@@ -204,7 +193,7 @@
204193
205194 class Graphics {
206195 public:
207- static void init(int *fat, unsigned short *vram, int x, int y);
196+ static void init(unsigned short *vram, int x, int y);
208197 static void fill_rect(unsigned short *vram, int xsize, unsigned char c, int x0, int y0, int x1, int y1);
209198 static void draw_string(unsigned short *vram, int xsize, int x, int y, char c, char *s);
210199 private:
@@ -211,7 +200,7 @@
211200 static void draw_char(unsigned short *vram, int xsize, int x, int y, char c, char *font);
212201 };
213202
214-/* dsctbl.cpp */
203+/* descriptor.cpp */
215204
216205 class Descriptor {
217206 public:
@@ -238,7 +227,7 @@
238227 static void set(GateDescriptor *gd, int offset, int selector, int ar);
239228 };
240229
241-/* int.cpp */
230+/* pic.cpp */
242231
243232 class PIC {
244233 public:
@@ -249,7 +238,7 @@
249238
250239 class Keyboard {
251240 public:
252- static void init(Queue *fifo, int data0);
241+ static void init(Queue *queue, int data0);
253242 static void sendready(void);
254243 };
255244
@@ -266,8 +255,8 @@
266255 int x, y, btn, scroll, scrollmode;
267256
268257 public:
269- static void init(Queue *fifo, int data0, Mouse *mdec);
270- static int decode(Mouse *mdec, unsigned char dat);
258+ static void init(Queue *queue, int data0, Mouse *mouse);
259+ static int decode(Mouse *mouse, unsigned char dat);
271260 };
272261
273262 /* memory.cpp */
@@ -325,19 +314,18 @@
325314 public:
326315 unsigned short *buf;
327316 int bxsize, bysize, vx0, vy0, col_inv, height, flags;
328- SheetManager *ctl;
317+ SheetManager *sheet_manager;
329318 Task *task;
330319
331320 public:
332- static Sheet *allocate(SheetManager *ctl);
333- static void set_buffer(Sheet *sht, unsigned short *buf, int xsize, int ysize, int col_inv);
334- static void up_down(Sheet *sht, int height);
335- static void refresh(Sheet *sht, int bx0, int by0, int bx1, int by1);
336- static void slide(Sheet *sht, int vx0, int vy0);
337- static void deallocate(Sheet *sht);
321+ static void set_buffer(Sheet *sheet, unsigned short *buf, int xsize, int ysize, int col_inv);
322+ static void up_down(Sheet *sheet, int height);
323+ static void refresh(Sheet *sheet, int bx0, int by0, int bx1, int by1);
324+ static void slide(Sheet *sheet, int vx0, int vy0);
325+ static void deallocate(Sheet *sheet);
338326 private:
339- static void refresh_map(SheetManager *ctl, int vx0, int vy0, int vx1, int vy1, int h0);
340- static void refresh_sub(SheetManager *ctl, int vx0, int vy0, int vx1, int vy1, int h0, int h1);
327+ static void refresh_map(SheetManager *sheet_manager, int vx0, int vy0, int vx1, int vy1, int h0);
328+ static void refresh_sub(SheetManager *sheet_manager, int vx0, int vy0, int vx1, int vy1, int h0, int h1);
341329 };
342330
343331 class SheetManager {
@@ -348,9 +336,20 @@
348336 Sheet sheets0[MAX_SHEETS];
349337
350338 public:
351- static SheetManager *init(MemoryManager *memman, unsigned char *vram, int xsize, int ysize);
339+ static SheetManager *init(MemoryManager *memory_manager, unsigned char *vram, int xsize, int ysize);
340+ static Sheet *allocate(SheetManager *sheet_manager);
352341 };
353342
343+class Gui {
344+public:
345+ static void drawPixel(Sheet* sheet, int x, int y, unsigned short col);
346+ static void drawLine(Sheet* sheet, int x0, int y0, int x1, int y1, unsigned short col);
347+ static void drawRect(Sheet* sheet, int x, int y, int width, int height, unsigned short col);
348+ static void fillRect(Sheet* sheet, int x0, int y0, int x1, int y1, unsigned short col);
349+ static void drawString(Sheet* sheet, char* title, int x0, int y0, unsigned short col);
350+ static void drawFrame(Sheet* sheet, char* title);
351+};
352+
354353 /* timer.cpp */
355354
356355 class PIT {
@@ -363,16 +362,16 @@
363362 Timer *next;
364363 unsigned int timeout;
365364 char flags, flags2;
366- Queue *fifo;
365+ Queue *queue;
367366 int data;
368367
369368 public:
370369 static Timer *allocate(void);
371370 static void deallocate(Timer *timer);
372- static void init(Timer *timer, Queue *fifo, int data);
371+ static void init(Timer *timer, Queue *queue, int data);
373372 static void set_time(Timer *timer, unsigned int timeout);
374373 static int cancel(Timer *timer);
375- static void cancel_all(Queue *fifo);
374+ static void cancel_all(Queue *queue);
376375 };
377376
378377 class TimerManager {
@@ -385,8 +384,35 @@
385384 static void init(void);
386385 };
387386
388-extern TimerManager timerctl;
387+extern TimerManager timer_manager;
389388
389+/* console.c */
390+
391+class Console {
392+public:
393+ Sheet *sheet;
394+ int cur_x, cur_y, cur_c;
395+ Timer *timer;
396+
397+public:
398+ static void put_char(Console *console, int chr, char move);
399+ static void new_line(Console *console);
400+ static void put_str0(Console *console, char *s);
401+ static void put_str1(Console *console, char *s, int l);
402+ static void run_command(char *cmdline, Console *console, int *fat, int memtotal);
403+ static void command_mem(Console *console, int memtotal);
404+ static void command_cls(Console *console);
405+ static void command_dir(Console *console);
406+ static void command_exit(Console *console, int *fat);
407+ static void command_start(Console *console, char *cmdline, int memtotal);
408+ static void command_ncst(Console *console, char *cmdline, int memtotal);
409+ static void command_langmode(Console *console, char *cmdline);
410+ static int command_app(Console *console, int *fat, char *cmdline);
411+ static void hrb_api_linewin(Sheet *sheet, int x0, int y0, int x1, int y1, int col);
412+};
413+
414+void console_task(Sheet *sheet, int memtotal);
415+
390416 /* mtask.cpp */
391417
392418 class TSS32 {
@@ -397,17 +423,16 @@
397423 int ldtr, iomap;
398424 };
399425
400-class Console;
401426 class Task {
402427 public:
403428 int sel, flags; /* selはGDTの番号のこと */
404429 int level, priority;
405- Queue fifo;
430+ Queue queue;
406431 TSS32 tss;
407432 int fpu[108 / 4];
408433 SegmentDescriptor ldt[2];
409- Console *cons;
410- int ds_base, cons_stack;
434+ Console *console;
435+ int ds_base, console_stack;
411436 FileHandle *fhandle;
412437 int *fat;
413438 char *cmdline;
@@ -415,7 +440,7 @@
415440
416441 public:
417442 static Task *now(void);
418- static Task *init(MemoryManager *memman);
443+ static Task *init(MemoryManager *memory_manager);
419444 static Task *allocate(void);
420445 static void run(Task *task, int level, int priority);
421446 static void switcher(void);
@@ -442,7 +467,7 @@
442467 Task tasks0[MAX_TASKS];
443468 };
444469
445-extern TaskManager *taskctl;
470+extern TaskManager *task_manager;
446471 extern Timer *task_timer;
447472
448473 /* window.c */
@@ -449,42 +474,15 @@
449474
450475 class Window {
451476 public:
452- static void make_window(unsigned short *buf, int xsize, int ysize, char *title, char act);
453- static void putfonts_asc_sht(Sheet *sht, int x, int y, int c, int b, char *s, int l);
454- static void make_textbox(Sheet *sht, int x0, int y0, int sx, int sy, int c);
455- static void make_wtitle(unsigned short *buf, int xsize, char *title, char act);
456- static void change_wtitle(Sheet *sht, char act);
477+ //static void make_window(unsigned short *buf, int xsize, int ysize, char *title, char act);
478+ static void putfonts_asc_sheet(Sheet *sheet, int x, int y, int c, int b, char *s, int l);
479+ //static void make_textbox(Sheet *sheet, int x0, int y0, int sx, int sy, int c);
480+ //static void make_wtitle(unsigned short *buf, int xsize, char *title, char act);
481+ static void change_wtitle(Sheet *sheet, char act);
457482 };
458483
459-/* console.c */
460-
461-class Console {
462-public:
463- Sheet *sht;
464- int cur_x, cur_y, cur_c;
465- Timer *timer;
466-
467-public:
468- static void put_char(Console *cons, int chr, char move);
469- static void new_line(Console *cons);
470- static void put_str0(Console *cons, char *s);
471- static void put_str1(Console *cons, char *s, int l);
472- static void run_command(char *cmdline, Console *cons, int *fat, int memtotal);
473- static void command_mem(Console *cons, int memtotal);
474- static void command_cls(Console *cons);
475- static void command_dir(Console *cons);
476- static void command_exit(Console *cons, int *fat);
477- static void command_start(Console *cons, char *cmdline, int memtotal);
478- static void command_ncst(Console *cons, char *cmdline, int memtotal);
479- static void command_langmode(Console *cons, char *cmdline);
480- static int command_app(Console *cons, int *fat, char *cmdline);
481- static void hrb_api_linewin(Sheet *sht, int x0, int y0, int x1, int y1, int col);
482-};
483-
484-void console_task(Sheet *sheet, int memtotal);
485-
486484 /* bootpack.cpp */
487485
488-Task *open_constask(Sheet *sht, unsigned int memtotal);
489-Sheet *open_console(SheetManager *shtctl, unsigned int memtotal);
486+Task *open_console_task(Sheet *sheet, unsigned int memtotal);
487+Sheet *open_console(SheetManager *sheet_manager, unsigned int memtotal);
490488
--- haribote/trunk/bayos_exp/sheet.cpp (revision 181)
+++ haribote/trunk/bayos_exp/sheet.cpp (revision 182)
@@ -8,89 +8,89 @@
88
99 SheetManager *SheetManager::init(MemoryManager *memman, unsigned char *vram, int xsize, int ysize)
1010 {
11- SheetManager *ctl;
11+ SheetManager *sheet_manager;
1212 int i;
13- ctl = (SheetManager *) MemoryManager::allocate_4k(memman, sizeof (SheetManager));
14- if (ctl == 0) {
13+ sheet_manager = (SheetManager *) MemoryManager::allocate_4k(memman, sizeof (SheetManager));
14+ if (sheet_manager == 0) {
1515 goto err;
1616 }
17- ctl->map = (unsigned char *) MemoryManager::allocate_4k(memman, xsize * ysize);
18- if (ctl->map == 0) {
19- MemoryManager::deallocate_4k(memman, (int) ctl, sizeof (SheetManager));
17+ sheet_manager->map = (unsigned char *) MemoryManager::allocate_4k(memman, xsize * ysize);
18+ if (sheet_manager->map == 0) {
19+ MemoryManager::deallocate_4k(memman, (int) sheet_manager, sizeof (SheetManager));
2020 goto err;
2121 }
22- ctl->vram = vram;
23- ctl->xsize = xsize;
24- ctl->ysize = ysize;
25- ctl->top = -1; /* シートは一枚もない */
22+ sheet_manager->vram = vram;
23+ sheet_manager->xsize = xsize;
24+ sheet_manager->ysize = ysize;
25+ sheet_manager->top = -1; /* シートは一枚もない */
2626 for (i = 0; i < MAX_SHEETS; i++) {
27- ctl->sheets0[i].flags = 0; /* 未使用マーク */
28- ctl->sheets0[i].ctl = ctl; /* 所属を記録 */
27+ sheet_manager->sheets0[i].flags = 0; /* 未使用マーク */
28+ sheet_manager->sheets0[i].sheet_manager = sheet_manager; /* 所属を記録 */
2929 }
3030 err:
31- return ctl;
31+ return sheet_manager;
3232 }
3333
34-Sheet *Sheet::allocate(SheetManager *ctl)
34+Sheet *SheetManager::allocate(SheetManager *sheet_manager)
3535 {
36- Sheet *sht;
36+ Sheet *sheet;
3737 int i;
3838 for (i = 0; i < MAX_SHEETS; i++) {
39- if (ctl->sheets0[i].flags == 0) {
40- sht = &ctl->sheets0[i];
41- sht->flags = SHEET_USE; /* 使用中マーク */
42- sht->height = -1; /* 非表示中 */
43- sht->task = 0; /* 自動で閉じる機能を使わない */
44- return sht;
39+ if (sheet_manager->sheets0[i].flags == 0) {
40+ sheet = &sheet_manager->sheets0[i];
41+ sheet->flags = SHEET_USE; /* 使用中マーク */
42+ sheet->height = -1; /* 非表示中 */
43+ sheet->task = 0; /* 自動で閉じる機能を使わない */
44+ return sheet;
4545 }
4646 }
4747 return 0; /* 全てのシートが使用中だった */
4848 }
4949
50-void Sheet::set_buffer(Sheet *sht, unsigned short *buf, int xsize, int ysize, int col_inv)
50+void Sheet::set_buffer(Sheet *sheet, unsigned short *buf, int xsize, int ysize, int col_inv)
5151 {
52- sht->buf = buf;
53- sht->bxsize = xsize;
54- sht->bysize = ysize;
52+ sheet->buf = buf;
53+ sheet->bxsize = xsize;
54+ sheet->bysize = ysize;
5555 if (col_inv != -1) {
56- sht->col_inv = table_8_565[col_inv];
56+ sheet->col_inv = table_8_565[col_inv];
5757 } else {
58- sht->col_inv = -1;
58+ sheet->col_inv = -1;
5959 }
6060 return;
6161 }
6262
63-void Sheet::refresh_map(SheetManager *ctl, int vx0, int vy0, int vx1, int vy1, int h0)
63+void Sheet::refresh_map(SheetManager *sheet_manager, int vx0, int vy0, int vx1, int vy1, int h0)
6464 {
6565 int h, bx, by, vx, vy, bx0, by0, bx1, by1, sid4, *p;
6666 unsigned short *buf;
67- unsigned char sid, *map = ctl->map;
68- Sheet *sht;
67+ unsigned char sid, *map = sheet_manager->map;
68+ Sheet *sheet;
6969 if (vx0 < 0) { vx0 = 0; }
7070 if (vy0 < 0) { vy0 = 0; }
71- if (vx1 > ctl->xsize) { vx1 = ctl->xsize; }
72- if (vy1 > ctl->ysize) { vy1 = ctl->ysize; }
73- for (h = h0; h <= ctl->top; h++) {
74- sht = ctl->sheets[h];
75- sid = sht - ctl->sheets0; /* 番地を引き算してそれを下じき番号として利用 */
76- buf = sht->buf;
77- bx0 = vx0 - sht->vx0;
78- by0 = vy0 - sht->vy0;
79- bx1 = vx1 - sht->vx0;
80- by1 = vy1 - sht->vy0;
71+ if (vx1 > sheet_manager->xsize) { vx1 = sheet_manager->xsize; }
72+ if (vy1 > sheet_manager->ysize) { vy1 = sheet_manager->ysize; }
73+ for (h = h0; h <= sheet_manager->top; h++) {
74+ sheet = sheet_manager->sheets[h];
75+ sid = sheet - sheet_manager->sheets0; /* 番地を引き算してそれを下じき番号として利用 */
76+ buf = sheet->buf;
77+ bx0 = vx0 - sheet->vx0;
78+ by0 = vy0 - sheet->vy0;
79+ bx1 = vx1 - sheet->vx0;
80+ by1 = vy1 - sheet->vy0;
8181 if (bx0 < 0) { bx0 = 0; }
8282 if (by0 < 0) { by0 = 0; }
83- if (bx1 > sht->bxsize) { bx1 = sht->bxsize; }
84- if (by1 > sht->bysize) { by1 = sht->bysize; }
85- if (sht->col_inv == -1) {
86- if ((sht->vx0 & 3) == 0 && (bx0 & 3) == 0 && (bx1 & 3) == 0) {
83+ if (bx1 > sheet->bxsize) { bx1 = sheet->bxsize; }
84+ if (by1 > sheet->bysize) { by1 = sheet->bysize; }
85+ if (sheet->col_inv == -1) {
86+ if ((sheet->vx0 & 3) == 0 && (bx0 & 3) == 0 && (bx1 & 3) == 0) {
8787 /* 透明色なし専用の高速版(4バイト型) */
8888 bx1 = (bx1 - bx0) / 4; /* MOV回数 */
8989 sid4 = sid | sid << 8 | sid << 16 | sid << 24;
9090 for (by = by0; by < by1; by++) {
91- vy = sht->vy0 + by;
92- vx = sht->vx0 + bx0;
93- p = (int *) &map[vy * ctl->xsize + vx];
91+ vy = sheet->vy0 + by;
92+ vx = sheet->vx0 + bx0;
93+ p = (int *) &map[vy * sheet_manager->xsize + vx];
9494 for (bx = 0; bx < bx1; bx++) {
9595 p[bx] = sid4;
9696 }
@@ -98,10 +98,10 @@
9898 } else {
9999 /* 透明色なし専用の高速版(1バイト型) */
100100 for (by = by0; by < by1; by++) {
101- vy = sht->vy0 + by;
101+ vy = sheet->vy0 + by;
102102 for (bx = bx0; bx < bx1; bx++) {
103- vx = sht->vx0 + bx;
104- map[vy * ctl->xsize + vx] = sid;
103+ vx = sheet->vx0 + bx;
104+ map[vy * sheet_manager->xsize + vx] = sid;
105105 }
106106 }
107107 }
@@ -108,11 +108,11 @@
108108 } else {
109109 /* 透明色ありの一般版 */
110110 for (by = by0; by < by1; by++) {
111- vy = sht->vy0 + by;
111+ vy = sheet->vy0 + by;
112112 for (bx = bx0; bx < bx1; bx++) {
113- vx = sht->vx0 + bx;
114- if (buf[by * sht->bxsize + bx] != sht->col_inv) {
115- map[vy * ctl->xsize + vx] = sid;
113+ vx = sheet->vx0 + bx;
114+ if (buf[by * sheet->bxsize + bx] != sheet->col_inv) {
115+ map[vy * sheet_manager->xsize + vx] = sid;
116116 }
117117 }
118118 }
@@ -121,46 +121,46 @@
121121 return;
122122 }
123123
124-void Sheet::refresh_sub(SheetManager *ctl, int vx0, int vy0, int vx1, int vy1, int h0, int h1)
124+void Sheet::refresh_sub(SheetManager *sheet_manager, int vx0, int vy0, int vx1, int vy1, int h0, int h1)
125125 {
126126 SystemInfo *sysinfo = SystemInfo::get_instance();
127127 int h, bx, by, vx, vy, bx0, by0, bx1, by1, bx2, sid4, i, i1, *p, *q, *r;
128- unsigned char *vram = ctl->vram, *map = ctl->map, sid;
128+ unsigned char *vram = sheet_manager->vram, *map = sheet_manager->map, sid;
129129 unsigned short *buf, sid2, *o;
130- Sheet *sht;
130+ Sheet *sheet;
131131 /* refresh範囲が画面外にはみ出していたら補正 */
132132 if (vx0 < 0) { vx0 = 0; }
133133 if (vy0 < 0) { vy0 = 0; }
134- if (vx1 > ctl->xsize) { vx1 = ctl->xsize; }
135- if (vy1 > ctl->ysize) { vy1 = ctl->ysize; }
134+ if (vx1 > sheet_manager->xsize) { vx1 = sheet_manager->xsize; }
135+ if (vy1 > sheet_manager->ysize) { vy1 = sheet_manager->ysize; }
136136 for (h = h0; h <= h1; h++) {
137- sht = ctl->sheets[h];
138- buf = sht->buf;
139- sid = sht - ctl->sheets0;
137+ sheet = sheet_manager->sheets[h];
138+ buf = sheet->buf;
139+ sid = sheet - sheet_manager->sheets0;
140140 /* vx0〜vy1を使って、bx0〜by1を逆算する */
141- bx0 = vx0 - sht->vx0;
142- by0 = vy0 - sht->vy0;
143- bx1 = vx1 - sht->vx0;
144- by1 = vy1 - sht->vy0;
141+ bx0 = vx0 - sheet->vx0;
142+ by0 = vy0 - sheet->vy0;
143+ bx1 = vx1 - sheet->vx0;
144+ by1 = vy1 - sheet->vy0;
145145 if (bx0 < 0) { bx0 = 0; }
146146 if (by0 < 0) { by0 = 0; }
147- if (bx1 > sht->bxsize) { bx1 = sht->bxsize; }
148- if (by1 > sht->bysize) { by1 = sht->bysize; }
147+ if (bx1 > sheet->bxsize) { bx1 = sheet->bxsize; }
148+ if (by1 > sheet->bysize) { by1 = sheet->bysize; }
149149 if (sysinfo->vmode == 8) {
150150 /* 8ビットカラー */
151151 /* 1バイト型 */
152152 for (by = by0; by < by1; by++) {
153- vy = sht->vy0 + by;
153+ vy = sheet->vy0 + by;
154154 for (bx = bx0; bx < bx1; bx++) {
155- vx = sht->vx0 + bx;
156- if (map[vy * ctl->xsize + vx] == sid) {
157- vram[vy * ctl->xsize + vx] = buf[by * sht->bxsize + bx];
155+ vx = sheet->vx0 + bx;
156+ if (map[vy * sheet_manager->xsize + vx] == sid) {
157+ vram[vy * sheet_manager->xsize + vx] = buf[by * sheet->bxsize + bx];
158158 }
159159 }
160160 }
161161 } else {
162162 /* 16ビットカラー */
163- if ((sht->vx0 & 2) == 0) {
163+ if ((sheet->vx0 & 2) == 0) {
164164 /* 4バイト型 */
165165 i = (bx0 + 1) / 2; /* bx0を2で割ったもの(端数切り上げ) */
166166 i1 = bx1 / 2; /* bx1を2で割ったもの(端数切り捨て) */
@@ -167,39 +167,39 @@
167167 i1 = i1 - i;
168168 sid2 = sid | sid << 8;
169169 for (by = by0; by < by1; by++) {
170- vy = sht->vy0 + by;
170+ vy = sheet->vy0 + by;
171171 for (bx = bx0; bx < bx1 && (bx & 1) != 0; bx++) { /* 前の端数を1バイトずつ */
172- vx = sht->vx0 + bx;
173- if (map[vy * ctl->xsize + vx] == sid) {
174- *(unsigned short *) &vram[(vy * ctl->xsize + vx) * 2] =
175- buf[by * sht->bxsize + bx];
172+ vx = sheet->vx0 + bx;
173+ if (map[vy * sheet_manager->xsize + vx] == sid) {
174+ *(unsigned short *) &vram[(vy * sheet_manager->xsize + vx) * 2] =
175+ buf[by * sheet->bxsize + bx];
176176 }
177177 }
178- vx = sht->vx0 + bx;
179- o = (unsigned short *) &map[vy * ctl->xsize + vx];
180- q = (int *) &vram[(vy * ctl->xsize + vx) * 2];
181- r = (int *) &buf[by * sht->bxsize + bx];
178+ vx = sheet->vx0 + bx;
179+ o = (unsigned short *) &map[vy * sheet_manager->xsize + vx];
180+ q = (int *) &vram[(vy * sheet_manager->xsize + vx) * 2];
181+ r = (int *) &buf[by * sheet->bxsize + bx];
182182 for (i = 0; i < i1; i++) { /* 2の倍数部分 */
183183 if (o[i] == sid2) {
184184 q[i] = r[i];
185185 } else {
186186 bx2 = bx + i * 2;
187- vx = sht->vx0 + bx2;
188- if (map[vy * ctl->xsize + vx + 0] == sid) {
189- *(unsigned short *) &vram[(vy * ctl->xsize + vx + 0) * 2] =
190- buf[by * sht->bxsize + bx2 + 0];
187+ vx = sheet->vx0 + bx2;
188+ if (map[vy * sheet_manager->xsize + vx + 0] == sid) {
189+ *(unsigned short *) &vram[(vy * sheet_manager->xsize + vx + 0) * 2] =
190+ buf[by * sheet->bxsize + bx2 + 0];
191191 }
192- if (map[vy * ctl->xsize + vx + 1] == sid) {
193- *(unsigned short *) &vram[(vy * ctl->xsize + vx + 1) * 2] =
194- buf[by * sht->bxsize + bx2 + 1];
192+ if (map[vy * sheet_manager->xsize + vx + 1] == sid) {
193+ *(unsigned short *) &vram[(vy * sheet_manager->xsize + vx + 1) * 2] =
194+ buf[by * sheet->bxsize + bx2 + 1];
195195 }
196196 }
197197 }
198198 for (bx += i1 * 2; bx < bx1; bx++) { /* 後の端数を1バイトずつ */
199- vx = sht->vx0 + bx;
200- if (map[vy * ctl->xsize + vx] == sid) {
201- *(unsigned short *) &vram[(vy * ctl->xsize + vx) * 2] =
202- buf[by * sht->bxsize + bx];
199+ vx = sheet->vx0 + bx;
200+ if (map[vy * sheet_manager->xsize + vx] == sid) {
201+ *(unsigned short *) &vram[(vy * sheet_manager->xsize + vx) * 2] =
202+ buf[by * sheet->bxsize + bx];
203203 }
204204 }
205205 }
@@ -206,12 +206,12 @@
206206 } else {
207207 /* 2バイト型 */
208208 for (by = by0; by < by1; by++) {
209- vy = sht->vy0 + by;
209+ vy = sheet->vy0 + by;
210210 for (bx = bx0; bx < bx1; bx++) {
211- vx = sht->vx0 + bx;
212- if (map[vy * ctl->xsize + vx] == sid) {
213- *(unsigned short *) &vram[(vy * ctl->xsize + vx) * 2] =
214- buf[by * sht->bxsize + bx];
211+ vx = sheet->vx0 + bx;
212+ if (map[vy * sheet_manager->xsize + vx] == sid) {
213+ *(unsigned short *) &vram[(vy * sheet_manager->xsize + vx) * 2] =
214+ buf[by * sheet->bxsize + bx];
215215 }
216216 }
217217 }
@@ -221,19 +221,19 @@
221221 return;
222222 }
223223
224-void Sheet::up_down(Sheet *sht, int height)
224+void Sheet::up_down(Sheet *sheet, int height)
225225 {
226- SheetManager *ctl = sht->ctl;
227- int h, old = sht->height; /* 設定前の高さを記憶する */
226+ SheetManager *sheet_manager = sheet->sheet_manager;
227+ int h, old = sheet->height; /* 設定前の高さを記憶する */
228228
229229 /* 指定が低すぎや高すぎだったら、修正する */
230- if (height > ctl->top + 1) {
231- height = ctl->top + 1;
230+ if (height > sheet_manager->top + 1) {
231+ height = sheet_manager->top + 1;
232232 }
233233 if (height < -1) {
234234 height = -1;
235235 }
236- sht->height = height; /* 高さを設定 */
236+ sheet->height = height; /* 高さを設定 */
237237
238238 /* 以下は主にsheets[]の並べ替え */
239239 if (old > height) { /* 以前よりも低くなる */
@@ -240,75 +240,75 @@
240240 if (height >= 0) {
241241 /* 間のものを引き上げる */
242242 for (h = old; h > height; h--) {
243- ctl->sheets[h] = ctl->sheets[h - 1];
244- ctl->sheets[h]->height = h;
243+ sheet_manager->sheets[h] = sheet_manager->sheets[h - 1];
244+ sheet_manager->sheets[h]->height = h;
245245 }
246- ctl->sheets[height] = sht;
247- Sheet::refresh_map(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1);
248- Sheet::refresh_sub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height + 1, old);
246+ sheet_manager->sheets[height] = sheet;
247+ Sheet::refresh_map(sheet_manager, sheet->vx0, sheet->vy0, sheet->vx0 + sheet->bxsize, sheet->vy0 + sheet->bysize, height + 1);
248+ Sheet::refresh_sub(sheet_manager, sheet->vx0, sheet->vy0, sheet->vx0 + sheet->bxsize, sheet->vy0 + sheet->bysize, height + 1, old);
249249 } else { /* 非表示化 */
250- if (ctl->top > old) {
250+ if (sheet_manager->top > old) {
251251 /* 上になっているものをおろす */
252- for (h = old; h < ctl->top; h++) {
253- ctl->sheets[h] = ctl->sheets[h + 1];
254- ctl->sheets[h]->height = h;
252+ for (h = old; h < sheet_manager->top; h++) {
253+ sheet_manager->sheets[h] = sheet_manager->sheets[h + 1];
254+ sheet_manager->sheets[h]->height = h;
255255 }
256256 }
257- ctl->top--; /* 表示中の下じきが一つ減るので、一番上の高さが減る */
258- Sheet::refresh_map(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0);
259- Sheet::refresh_sub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, 0, old - 1);
257+ sheet_manager->top--; /* 表示中の下じきが一つ減るので、一番上の高さが減る */
258+ Sheet::refresh_map(sheet_manager, sheet->vx0, sheet->vy0, sheet->vx0 + sheet->bxsize, sheet->vy0 + sheet->bysize, 0);
259+ Sheet::refresh_sub(sheet_manager, sheet->vx0, sheet->vy0, sheet->vx0 + sheet->bxsize, sheet->vy0 + sheet->bysize, 0, old - 1);
260260 }
261261 } else if (old < height) { /* 以前よりも高くなる */
262262 if (old >= 0) {
263263 /* 間のものを押し下げる */
264264 for (h = old; h < height; h++) {
265- ctl->sheets[h] = ctl->sheets[h + 1];
266- ctl->sheets[h]->height = h;
265+ sheet_manager->sheets[h] = sheet_manager->sheets[h + 1];
266+ sheet_manager->sheets[h]->height = h;
267267 }
268- ctl->sheets[height] = sht;
268+ sheet_manager->sheets[height] = sheet;
269269 } else { /* 非表示状態から表示状態へ */
270270 /* 上になるものを持ち上げる */
271- for (h = ctl->top; h >= height; h--) {
272- ctl->sheets[h + 1] = ctl->sheets[h];
273- ctl->sheets[h + 1]->height = h + 1;
271+ for (h = sheet_manager->top; h >= height; h--) {
272+ sheet_manager->sheets[h + 1] = sheet_manager->sheets[h];
273+ sheet_manager->sheets[h + 1]->height = h + 1;
274274 }
275- ctl->sheets[height] = sht;
276- ctl->top++; /* 表示中の下じきが一つ増えるので、一番上の高さが増える */
275+ sheet_manager->sheets[height] = sheet;
276+ sheet_manager->top++; /* 表示中の下じきが一つ増えるので、一番上の高さが増える */
277277 }
278- Sheet::refresh_map(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height);
279- Sheet::refresh_sub(ctl, sht->vx0, sht->vy0, sht->vx0 + sht->bxsize, sht->vy0 + sht->bysize, height, height);
278+ Sheet::refresh_map(sheet_manager, sheet->vx0, sheet->vy0, sheet->vx0 + sheet->bxsize, sheet->vy0 + sheet->bysize, height);
279+ Sheet::refresh_sub(sheet_manager, sheet->vx0, sheet->vy0, sheet->vx0 + sheet->bxsize, sheet->vy0 + sheet->bysize, height, height);
280280 }
281281 return;
282282 }
283283
284-void Sheet::refresh(Sheet *sht, int bx0, int by0, int bx1, int by1)
284+void Sheet::refresh(Sheet *sheet, int bx0, int by0, int bx1, int by1)
285285 {
286- if (sht->height >= 0) { /* もしも表示中なら、新しい下じきの情報に沿って画面を描き直す */
287- Sheet::refresh_sub(sht->ctl, sht->vx0 + bx0, sht->vy0 + by0, sht->vx0 + bx1, sht->vy0 + by1, sht->height, sht->height);
286+ if (sheet->height >= 0) { /* もしも表示中なら、新しい下じきの情報に沿って画面を描き直す */
287+ Sheet::refresh_sub(sheet->sheet_manager, sheet->vx0 + bx0, sheet->vy0 + by0, sheet->vx0 + bx1, sheet->vy0 + by1, sheet->height, sheet->height);
288288 }
289289 return;
290290 }
291291
292-void Sheet::slide(Sheet *sht, int vx0, int vy0)
292+void Sheet::slide(Sheet *sheet, int vx0, int vy0)
293293 {
294- SheetManager *ctl = sht->ctl;
295- int old_vx0 = sht->vx0, old_vy0 = sht->vy0;
296- sht->vx0 = vx0;
297- sht->vy0 = vy0;
298- if (sht->height >= 0) { /* もしも表示中なら、新しい下じきの情報に沿って画面を描き直す */
299- Sheet::refresh_map(ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize, 0);
300- Sheet::refresh_map(ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize, sht->height);
301- Sheet::refresh_sub(ctl, old_vx0, old_vy0, old_vx0 + sht->bxsize, old_vy0 + sht->bysize, 0, sht->height - 1);
302- Sheet::refresh_sub(ctl, vx0, vy0, vx0 + sht->bxsize, vy0 + sht->bysize, sht->height, sht->height);
294+ SheetManager *sheet_manager = sheet->sheet_manager;
295+ int old_vx0 = sheet->vx0, old_vy0 = sheet->vy0;
296+ sheet->vx0 = vx0;
297+ sheet->vy0 = vy0;
298+ if (sheet->height >= 0) { /* もしも表示中なら、新しい下じきの情報に沿って画面を描き直す */
299+ Sheet::refresh_map(sheet_manager, old_vx0, old_vy0, old_vx0 + sheet->bxsize, old_vy0 + sheet->bysize, 0);
300+ Sheet::refresh_map(sheet_manager, vx0, vy0, vx0 + sheet->bxsize, vy0 + sheet->bysize, sheet->height);
301+ Sheet::refresh_sub(sheet_manager, old_vx0, old_vy0, old_vx0 + sheet->bxsize, old_vy0 + sheet->bysize, 0, sheet->height - 1);
302+ Sheet::refresh_sub(sheet_manager, vx0, vy0, vx0 + sheet->bxsize, vy0 + sheet->bysize, sheet->height, sheet->height);
303303 }
304304 return;
305305 }
306306
307-void Sheet::deallocate(Sheet *sht)
307+void Sheet::deallocate(Sheet *sheet)
308308 {
309- if (sht->height >= 0) {
310- Sheet::up_down(sht, -1); /* 表示中ならまず非表示にする */
309+ if (sheet->height >= 0) {
310+ Sheet::up_down(sheet, -1); /* 表示中ならまず非表示にする */
311311 }
312- sht->flags = 0; /* 未使用マーク */
312+ sheet->flags = 0; /* 未使用マーク */
313313 return;
314314 }
--- haribote/trunk/bayos_exp/graphic.cpp (revision 181)
+++ haribote/trunk/bayos_exp/graphic.cpp (revision 182)
@@ -85,56 +85,37 @@
8585 int x, y;
8686 for (y = y0; y <= y1; y++) {
8787 for (x = x0; x <= x1; x++)
88- vram[y * xsize + x] = table_8_565[c & 0xff];
88+ vram[y * xsize + x] = table_8_565[c];
8989 }
9090 return;
9191 }
9292
93-void Graphics::init(int *fat, unsigned short *vram, int x, int y)
93+void Graphics::init(unsigned short *vram, int x, int y)
9494 {
95- /* hrbwall.jpgの読み込み */
9695 SystemInfo *sysinfo = SystemInfo::get_instance();
97- MemoryManager *memman = (MemoryManager *) MEMMAN_ADDR;
98- unsigned char *filebuf, r, g, b;
99- struct DLL_STRPICENV env;
100- struct RGB *picbuf;
101- int info[4], fsize, xx, yy;
102- FileInfo *finfo = File::search("hrbwall.jpg", (FileInfo *) (ADR_DISKIMG + 0x002600), 224);
10396
104- if (sysinfo->vmode == 16 && finfo != 0) {
105- fsize = finfo->size;
106- filebuf = (unsigned char *) MemoryManager::allocate_4k(memman, fsize);
107- filebuf = File::load_file2(finfo->clustno, &fsize, fat);
108- info_JPEG(&env, info, fsize, filebuf);
109- picbuf = (struct RGB *) MemoryManager::allocate_4k(memman, info[2] * info[3] * sizeof(struct RGB));
110- decode0_JPEG(&env, fsize, filebuf, 4, (unsigned char *) picbuf, 0);
111- for (yy = 0; yy < info[3]; yy++) {
112- for (xx = 0; xx < info[2]; xx++) {
113- r = picbuf[yy * info[2] + xx].r;
114- g = picbuf[yy * info[2] + xx].g;
115- b = picbuf[yy * info[2] + xx].b;
116- vram[yy * x + xx] = (unsigned short)(((r << 8) & 0xf800) | ((g << 3) & 0x07e0) | (b >> 3));
117- }
97+ if (sysinfo->vmode == 16) {
98+ for (int i = 0; i < x * y; i++) {
99+ vram[i] = 0xDF1F;
118100 }
119101 } else {
120102 Graphics::fill_rect(vram, x, COL8_008484, 0, 0, x - 1, y - 29);
121- }
103+ Graphics::fill_rect(vram, x, COL8_C6C6C6, 0, y - 28, x - 1, y - 28);
104+ Graphics::fill_rect(vram, x, COL8_FFFFFF, 0, y - 27, x - 1, y - 27);
105+ Graphics::fill_rect(vram, x, COL8_C6C6C6, 0, y - 26, x - 1, y - 1);
122106
123- Graphics::fill_rect(vram, x, COL8_C6C6C6, 0, y - 28, x - 1, y - 28);
124- Graphics::fill_rect(vram, x, COL8_FFFFFF, 0, y - 27, x - 1, y - 27);
125- Graphics::fill_rect(vram, x, COL8_C6C6C6, 0, y - 26, x - 1, y - 1);
107+ Graphics::fill_rect(vram, x, COL8_FFFFFF, 3, y - 24, 59, y - 24);
108+ Graphics::fill_rect(vram, x, COL8_FFFFFF, 2, y - 24, 2, y - 4);
109+ Graphics::fill_rect(vram, x, COL8_848484, 3, y - 4, 59, y - 4);
110+ Graphics::fill_rect(vram, x, COL8_848484, 59, y - 23, 59, y - 5);
111+ Graphics::fill_rect(vram, x, COL8_000000, 2, y - 3, 59, y - 3);
112+ Graphics::fill_rect(vram, x, COL8_000000, 60, y - 24, 60, y - 3);
126113
127- Graphics::fill_rect(vram, x, COL8_FFFFFF, 3, y - 24, 59, y - 24);
128- Graphics::fill_rect(vram, x, COL8_FFFFFF, 2, y - 24, 2, y - 4);
129- Graphics::fill_rect(vram, x, COL8_848484, 3, y - 4, 59, y - 4);
130- Graphics::fill_rect(vram, x, COL8_848484, 59, y - 23, 59, y - 5);
131- Graphics::fill_rect(vram, x, COL8_000000, 2, y - 3, 59, y - 3);
132- Graphics::fill_rect(vram, x, COL8_000000, 60, y - 24, 60, y - 3);
133-
134- Graphics::fill_rect(vram, x, COL8_848484, x - 47, y - 24, x - 4, y - 24);
135- Graphics::fill_rect(vram, x, COL8_848484, x - 47, y - 23, x - 47, y - 4);
136- Graphics::fill_rect(vram, x, COL8_FFFFFF, x - 47, y - 3, x - 4, y - 3);
137- Graphics::fill_rect(vram, x, COL8_FFFFFF, x - 3, y - 24, x - 3, y - 3);
114+ Graphics::fill_rect(vram, x, COL8_848484, x - 47, y - 24, x - 4, y - 24);
115+ Graphics::fill_rect(vram, x, COL8_848484, x - 47, y - 23, x - 47, y - 4);
116+ Graphics::fill_rect(vram, x, COL8_FFFFFF, x - 47, y - 3, x - 4, y - 3);
117+ Graphics::fill_rect(vram, x, COL8_FFFFFF, x - 3, y - 24, x - 3, y - 3);
118+ }
138119 return;
139120 }
140121
--- haribote/trunk/bayos_exp/mtask.cpp (revision 181)
+++ haribote/trunk/bayos_exp/mtask.cpp (revision 182)
@@ -2,18 +2,18 @@
22
33 #include "bootpack.h"
44
5-TaskManager *taskctl;
5+TaskManager *task_manager;
66 Timer *task_timer;
77
88 Task *Task::now(void)
99 {
10- TaskLevel *tl = &taskctl->level[taskctl->now_lv];
10+ TaskLevel *tl = &task_manager->level[task_manager->now_lv];
1111 return tl->tasks[tl->now];
1212 }
1313
1414 void Task::add(Task *task)
1515 {
16- TaskLevel *tl = &taskctl->level[task->level];
16+ TaskLevel *tl = &task_manager->level[task->level];
1717 tl->tasks[tl->running] = task;
1818 tl->running++;
1919 task->flags = 2; /* 動作中 */
@@ -23,7 +23,7 @@
2323 void Task::remove(Task *task)
2424 {
2525 int i;
26- TaskLevel *tl = &taskctl->level[task->level];
26+ TaskLevel *tl = &task_manager->level[task->level];
2727
2828 /* taskがどこにいるかを探す */
2929 for (i = 0; i < tl->running; i++) {
@@ -56,12 +56,12 @@
5656 int i;
5757 /* 一番上のレベルを探す */
5858 for (i = 0; i < MAX_TASKLEVELS; i++) {
59- if (taskctl->level[i].running > 0) {
59+ if (task_manager->level[i].running > 0) {
6060 break; /* 見つかった */
6161 }
6262 }
63- taskctl->now_lv = i;
64- taskctl->lv_change = 0;
63+ task_manager->now_lv = i;
64+ task_manager->lv_change = 0;
6565 return;
6666 }
6767
@@ -72,23 +72,23 @@
7272 }
7373 }
7474
75-Task *Task::init(MemoryManager *memman)
75+Task *Task::init(MemoryManager *memory_manager)
7676 {
7777 int i;
7878 Task *task, *idle;
7979 SegmentDescriptor *gdt = (SegmentDescriptor *) ADR_GDT;
8080
81- taskctl = (TaskManager *) MemoryManager::allocate_4k(memman, sizeof (TaskManager));
81+ task_manager = (TaskManager *) MemoryManager::allocate_4k(memory_manager, sizeof (TaskManager));
8282 for (i = 0; i < MAX_TASKS; i++) {
83- taskctl->tasks0[i].flags = 0;
84- taskctl->tasks0[i].sel = (TASK_GDT0 + i) * 8;
85- taskctl->tasks0[i].tss.ldtr = (TASK_GDT0 + MAX_TASKS + i) * 8;
86- SegmentDescriptor::set(gdt + TASK_GDT0 + i, 103, (int) &taskctl->tasks0[i].tss, AR_TSS32);
87- SegmentDescriptor::set(gdt + TASK_GDT0 + MAX_TASKS + i, 15, (int) taskctl->tasks0[i].ldt, AR_LDT);
83+ task_manager->tasks0[i].flags = 0;
84+ task_manager->tasks0[i].sel = (TASK_GDT0 + i) * 8;
85+ task_manager->tasks0[i].tss.ldtr = (TASK_GDT0 + MAX_TASKS + i) * 8;
86+ SegmentDescriptor::set(gdt + TASK_GDT0 + i, 103, (int) &task_manager->tasks0[i].tss, AR_TSS32);
87+ SegmentDescriptor::set(gdt + TASK_GDT0 + MAX_TASKS + i, 15, (int) task_manager->tasks0[i].ldt, AR_LDT);
8888 }
8989 for (i = 0; i < MAX_TASKLEVELS; i++) {
90- taskctl->level[i].running = 0;
91- taskctl->level[i].now = 0;
90+ task_manager->level[i].running = 0;
91+ task_manager->level[i].now = 0;
9292 }
9393
9494 task = Task::allocate();
@@ -102,7 +102,7 @@
102102 Timer::set_time(task_timer, task->priority);
103103
104104 idle = Task::allocate();
105- idle->tss.esp = MemoryManager::allocate_4k(memman, 64 * 1024) + 64 * 1024;
105+ idle->tss.esp = MemoryManager::allocate_4k(memory_manager, 64 * 1024) + 64 * 1024;
106106 idle->tss.eip = (int) &task_idle;
107107 idle->tss.es = 1 * 8;
108108 idle->tss.cs = 2 * 8;
@@ -112,7 +112,7 @@
112112 idle->tss.gs = 1 * 8;
113113 Task::run(idle, MAX_TASKLEVELS - 1, 1);
114114
115- taskctl->task_fpu = 0;
115+ task_manager->task_fpu = 0;
116116
117117 return task;
118118 }
@@ -122,8 +122,8 @@
122122 int i;
123123 Task *task;
124124 for (i = 0; i < MAX_TASKS; i++) {
125- if (taskctl->tasks0[i].flags == 0) {
126- task = &taskctl->tasks0[i];
125+ if (task_manager->tasks0[i].flags == 0) {
126+ task = &task_manager->tasks0[i];
127127 task->flags = 1; /* 使用中マーク */
128128 task->tss.eflags = 0x00000202; /* IF = 1; */
129129 task->tss.eax = 0; /* とりあえず0にしておくことにする */
@@ -169,7 +169,7 @@
169169 Task::add(task);
170170 }
171171
172- taskctl->lv_change = 1; /* 次回タスクスイッチのときにレベルを見直す */
172+ task_manager->lv_change = 1; /* 次回タスクスイッチのときにレベルを見直す */
173173 return;
174174 }
175175
@@ -192,15 +192,15 @@
192192
193193 void Task::switcher(void)
194194 {
195- TaskLevel *tl = &taskctl->level[taskctl->now_lv];
195+ TaskLevel *tl = &task_manager->level[task_manager->now_lv];
196196 Task *new_task, *now_task = tl->tasks[tl->now];
197197 tl->now++;
198198 if (tl->now == tl->running) {
199199 tl->now = 0;
200200 }
201- if (taskctl->lv_change != 0) {
201+ if (task_manager->lv_change != 0) {
202202 Task::switch_sub();
203- tl = &taskctl->level[taskctl->now_lv];
203+ tl = &task_manager->level[task_manager->now_lv];
204204 }
205205 new_task = tl->tasks[tl->now];
206206 Timer::set_time(task_timer, new_task->priority);
@@ -215,12 +215,12 @@
215215 Task *now = Task::now();
216216 io_cli();
217217 clts();
218- if (taskctl->task_fpu != now) {
219- if (taskctl->task_fpu != 0) {
220- fnsave(taskctl->task_fpu->fpu);
218+ if (task_manager->task_fpu != now) {
219+ if (task_manager->task_fpu != 0) {
220+ fnsave(task_manager->task_fpu->fpu);
221221 }
222222 frstor(now->fpu);
223- taskctl->task_fpu = now;
223+ task_manager->task_fpu = now;
224224 }
225225 io_sti();
226226 return 0;
Show on old repository browser