• R/O
  • SSH
  • HTTPS

chnosproject: 提交


Commit MetaInfo

修订版321 (tree)
时间2012-04-30 18:09:38
作者hikarupsp

Log Message

マウスを使用したシートの移動を実装。
ただし、移動禁止シートは未実装なので、デスクトップを動かす事も出来てしまう。
保存コミット。

更改概述

差异

--- beta/tolset_chn_000/chnos_010/chnos/sheet.c (revision 320)
+++ beta/tolset_chn_000/chnos_010/chnos/sheet.c (revision 321)
@@ -544,3 +544,26 @@
544544 }
545545 return 0;
546546 }
547+
548+//use map
549+UI_Sheet *Sheet_GetSheetFromLocation(UI_Sheet *parent, int px, int py)
550+{
551+ if(parent == Null){
552+ #ifdef CHNOSPROJECT_DEBUG_SHEET
553+ debug("Sheet_GetSheetFromLocation:Null parent.\n");
554+ #endif
555+ return Null;
556+ }
557+ if(parent->map == Null){
558+ #ifdef CHNOSPROJECT_DEBUG_SHEET
559+ debug("Sheet_GetSheetFromLocation:Null map.\n");
560+ #endif
561+ return Null;
562+ }
563+
564+ if(px < 0 || py < 0 || px >= (int)parent->size.x || py >= (int)parent->size.y){
565+ return Null;
566+ }
567+
568+ return (UI_Sheet *)parent->map[py * parent->size.x + px];
569+}
--- beta/tolset_chn_000/chnos_010/chnos/core.h (revision 320)
+++ beta/tolset_chn_000/chnos_010/chnos/core.h (revision 321)
@@ -254,6 +254,7 @@
254254 uint Sheet_Enable_InvisibleColor(UI_Sheet *sheet, uint invcol);
255255 uint Sheet_Disable_InvisibleColor(UI_Sheet *sheet);
256256 uint Sheet_SetTopmost(UI_Sheet *sheet, bool topmost);
257+UI_Sheet *Sheet_GetSheetFromLocation(UI_Sheet *parent, int px, int py);
257258
258259 /*sht08.c 8bitカラー シート関連*/
259260 uint Sheet08_Internal_SetBuffer(UI_Sheet *sheet, void *vram, uint xsize, uint ysize, uint bpp);
--- beta/tolset_chn_000/chnos_010/chnos/bootpack.c (revision 320)
+++ beta/tolset_chn_000/chnos_010/chnos/bootpack.c (revision 321)
@@ -74,11 +74,14 @@
7474 }
7575 }
7676
77- Sheet_Drawing_Fill_Rectangle(vramsheet, 0xffffff, 0, 0, disp_ctrl->xsize - 1, disp_ctrl->ysize - 1);
78- Sheet_Drawing_Put_String(vramsheet, 10, 10, 0x000000, "Welcome to CHNOSProject!");
77+ sheet_desktop = Sheet_Initialise();
78+ Sheet_SetBuffer(sheet_desktop, Null, disp_ctrl->xsize, disp_ctrl->ysize, disp_ctrl->bpp);
7979
80- Format_BMP_DrawPicture(disp_ctrl->vram, disp_ctrl->xsize, 10, 26, 0, 0, chnlogo);
80+ Sheet_Drawing_Fill_Rectangle(sheet_desktop, 0xffffff, 0, 0, disp_ctrl->xsize - 1, disp_ctrl->ysize - 1);
81+ Sheet_Drawing_Put_String(sheet_desktop, 10, 10, 0x000000, "Welcome to CHNOSProject!");
8182
83+ Format_BMP_DrawPicture(sheet_desktop->vram, sheet_desktop->size.x, 10, 26, 0, 0, chnlogo);
84+
8285 Drawing_Fill_Circle(disp_ctrl->vram, disp_ctrl->xsize, 100, 250, 0x00c600, 45);
8386 for(i = 0; i < 50; i += 5){
8487 Drawing_Draw_Circle(disp_ctrl->vram, disp_ctrl->xsize, 100, 250, 0xc6c6c6, i);
@@ -85,21 +88,16 @@
8588 }
8689
8790 testsheet = Sheet_Initialise();
88- sheet_desktop = Sheet_Initialise();
91+
8992 sheet08 = Sheet_Initialise();
9093 sheet16 = Sheet_Initialise();
9194 sheet32 = Sheet_Initialise();
9295
9396 Sheet_SetBuffer(testsheet, Null, 256, 128, 8);
94- Sheet_SetBuffer(sheet_desktop, Null, disp_ctrl->xsize, disp_ctrl->ysize, disp_ctrl->bpp);
9597 Sheet_SetBuffer(sheet08, Null, 128, 128, 8);
9698 Sheet_SetBuffer(sheet16, Null, 128, 128, 16);
9799 Sheet_SetBuffer(sheet32, Null, 128, 128, 32);
98100
99- for(i = 0; i < sheet_desktop->vramsize; i++){
100- ((uchar *)sheet_desktop->vram)[i] = ((uchar *)disp_ctrl->vram)[i];
101- }
102-
103101 for(y = 0; y < testsheet->size.y; y++){
104102 for(x = 0; x < testsheet->size.x; x++){
105103 ((uchar *)testsheet->vram)[y * testsheet->size.x + x] = x * 2;
@@ -148,17 +146,17 @@
148146 timer1 = Timer_Initialise();
149147 Timer_Config(timer1, 50, mytask->fifo, 11, True);
150148 counter1 = 0;
151- Timer_Run(timer1);
149+ //Timer_Run(timer1);
152150
153151 timer2 = Timer_Initialise();
154152 Timer_Config(timer2, 50, mytask->fifo, 12, False);
155153 counter2 = 0;
156- Timer_Run(timer2);
154+ //Timer_Run(timer2);
157155
158156 timer3 = Timer_Initialise();
159157 Timer_Config(timer3, 200, mytask->fifo, 13, True);
160158 counter3 = 0;
161- Timer_Run(timer3);
159+ //Timer_Run(timer3);
162160
163161 for(;;){
164162 if(FIFO32_MyTaskFIFO_Status() == 0){
@@ -266,12 +264,20 @@
266264 UI_Task *mytask;
267265 uint data;
268266 IO_MouseControl *mctrl;
269- UI_Sheet *mouseinfosheet;
270- uchar s[16];
267+ #ifdef CHNOSPROJECT_DEBUG_MCT
268+ UI_Sheet *mouseinfosheet;
269+ uchar s[16];
270+ #endif
271271 int scroll;
272272
273+ DATA_Location2D moveorg_mfocus;
274+ UI_Sheet *mfocus;
275+ bool old_mouse_buttonL;
276+
273277 data = 0;
274278 scroll = 0;
279+ mfocus = Null;
280+ old_mouse_buttonL = False;
275281
276282 mytask = System_MultiTask_GetNowTask();
277283
@@ -279,12 +285,14 @@
279285 debug("MCT:MouseControlTask Start Running.\nMCT:UI_Task=0x%X\n", mytask);
280286 #endif
281287
282- mouseinfosheet = Sheet_Initialise();
283- Sheet_SetBuffer(mouseinfosheet, Null, (4 * 2) + (8 * 16), 4 + 16 + (4 * 2) + (16 * 4), 8);
284- System_Sheet_SetParentToVRAM(mouseinfosheet);
285- Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0x99cc33, 0, 0, mouseinfosheet->size.x - 1, mouseinfosheet->size.y - 1);
286- Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24, mouseinfosheet->size.x - 1 - 4, mouseinfosheet->size.y - 1 - 4);
287- Sheet_Drawing_Put_String(mouseinfosheet, 4, 4, 0xffffff, "MouseInfo");
288+ #ifdef CHNOSPROJECT_DEBUG_MCT
289+ mouseinfosheet = Sheet_Initialise();
290+ Sheet_SetBuffer(mouseinfosheet, Null, (4 * 2) + (8 * 16), 4 + 16 + (4 * 2) + (16 * 4), 8);
291+ System_Sheet_SetParentToVRAM(mouseinfosheet);
292+ Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0x99cc33, 0, 0, mouseinfosheet->size.x - 1, mouseinfosheet->size.y - 1);
293+ Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24, mouseinfosheet->size.x - 1 - 4, mouseinfosheet->size.y - 1 - 4);
294+ Sheet_Drawing_Put_String(mouseinfosheet, 4, 4, 0xffffff, "MouseInfo");
295+ #endif
288296
289297 mctrl = Initialise_Mouse();
290298
@@ -292,7 +300,6 @@
292300 debug("MCT:Mouse Initialized.\n");
293301 #endif
294302
295- MouseCursor_Show(mcursor);
296303 Mouse_Set_ReceiveFIFO(mytask->fifo, 0x100);
297304
298305 Mouse_Decode(mctrl, 0x00); //Decode start.
@@ -299,7 +306,13 @@
299306
300307 for(;;){
301308 if(FIFO32_MyTaskFIFO_Status() == 0){
302- System_MultiTask_Task_Sleep(mytask);
309+ if(mfocus != Null && ((mcursor->cursor_sheet->location.x - moveorg_mfocus.x) != 0 || (mcursor->cursor_sheet->location.y - moveorg_mfocus.y) != 0)){
310+ Sheet_Slide_Relative(mfocus, mcursor->cursor_sheet->location.x - moveorg_mfocus.x, mcursor->cursor_sheet->location.y - moveorg_mfocus.y);
311+ moveorg_mfocus.x = mcursor->cursor_sheet->location.x;
312+ moveorg_mfocus.y = mcursor->cursor_sheet->location.y;
313+ } else{
314+ System_MultiTask_Task_Sleep(mytask);
315+ }
303316 } else{
304317 data = FIFO32_MyTaskFIFO_Get();
305318 #ifdef CHNOSPROJECT_DEBUG_MCT
@@ -308,38 +321,71 @@
308321 if(0x100 <= data && data <= 0x1ff){
309322 if(Mouse_Decode(mctrl, data - 0x100)){
310323 MouseCursor_Move_Relative(mcursor, mctrl->move.x, mctrl->move.y);
311- Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24 + (16 * 0), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 0) + 15);
312- snprintf(s, sizeof(s), "X:%d", mcursor->cursor_sheet->location.x);
313- Sheet_Drawing_Put_String(mouseinfosheet, 4, 24 + (16 * 0), 0x000000, s);
314- Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24 + (16 * 1), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 1) + 15);
315- snprintf(s, sizeof(s), "Y:%d", mcursor->cursor_sheet->location.y);
316- Sheet_Drawing_Put_String(mouseinfosheet, 4, 24 + (16 * 1), 0x000000, s);
317- Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24 + (16 * 2), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 2) + 15);
318- snprintf(s, sizeof(s), "Button:lrc");
324+ #ifdef CHNOSPROJECT_DEBUG_MCT
325+ Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24 + (16 * 0), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 0) + 15);
326+ snprintf(s, sizeof(s), "X:%d", mcursor->cursor_sheet->location.x);
327+ Sheet_Drawing_Put_String(mouseinfosheet, 4, 24 + (16 * 0), 0x000000, s);
328+ Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24 + (16 * 1), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 1) + 15);
329+ snprintf(s, sizeof(s), "Y:%d", mcursor->cursor_sheet->location.y);
330+ Sheet_Drawing_Put_String(mouseinfosheet, 4, 24 + (16 * 1), 0x000000, s);
331+ Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24 + (16 * 2), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 2) + 15);
332+ snprintf(s, sizeof(s), "Button:lrc");
333+ #endif
334+/*
319335 if(mctrl->button.bit.L){
320- s[7] -= 0x20;
336+ #ifdef CHNOSPROJECT_DEBUG_MCT
337+ s[7] -= 0x20;
338+ #endif
339+ moveorg_mfocus.x += mctrl->move.x;
340+ moveorg_mfocus.y += mctrl->move.y;
321341 }
342+*/
343+ if(old_mouse_buttonL != mctrl->button.bit.L){
344+ if(old_mouse_buttonL){ //up
345+ if(mfocus != Null){
346+ Sheet_Slide_Relative(mfocus, mcursor->cursor_sheet->location.x - moveorg_mfocus.x, mcursor->cursor_sheet->location.y - moveorg_mfocus.y);
347+ }
348+ mfocus = Null;
349+ } else{ //down
350+ moveorg_mfocus.x = mcursor->cursor_sheet->location.x;
351+ moveorg_mfocus.y = mcursor->cursor_sheet->location.y;
352+ mfocus = Sheet_GetSheetFromLocation(mcursor->cursor_sheet->parent, mcursor->cursor_sheet->location.x, mcursor->cursor_sheet->location.y);
353+ }
354+ old_mouse_buttonL = mctrl->button.bit.L;
355+ }
322356 if(mctrl->button.bit.R){
323- s[8] -= 0x20;
357+ #ifdef CHNOSPROJECT_DEBUG_MCT
358+ s[8] -= 0x20;
359+ #endif
324360 }
325361 if(mctrl->button.bit.C){
326- s[9] -= 0x20;
362+ #ifdef CHNOSPROJECT_DEBUG_MCT
363+ s[9] -= 0x20;
364+ #endif
327365 }
328- Sheet_Drawing_Put_String(mouseinfosheet, 4, 24 + (16 * 2), 0x000000, s);
366+ #ifdef CHNOSPROJECT_DEBUG_MCT
367+ Sheet_Drawing_Put_String(mouseinfosheet, 4, 24 + (16 * 2), 0x000000, s);
368+ #endif
329369 if(mctrl->flags.scroll){
330370 scroll += mctrl->scroll;
331- Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24 + (16 * 3), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 3) + 15);
332- snprintf(s, sizeof(s), "Scroll:%d", scroll);
333- Sheet_Drawing_Put_String(mouseinfosheet, 4, 24 + (16 * 3), 0x000000, s);
334-
335- Sheet_RefreshSheet(mouseinfosheet, 4, 24 + (16 * 0), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 3) + 15);
371+ #ifdef CHNOSPROJECT_DEBUG_MCT
372+ Sheet_Drawing_Fill_Rectangle(mouseinfosheet, 0xccffff, 4, 24 + (16 * 3), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 3) + 15);
373+ snprintf(s, sizeof(s), "Scroll:%d", scroll);
374+ Sheet_Drawing_Put_String(mouseinfosheet, 4, 24 + (16 * 3), 0x000000, s);
375+ Sheet_RefreshSheet(mouseinfosheet, 4, 24 + (16 * 0), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 3) + 15);
376+ #endif
336377 } else{
337- Sheet_RefreshSheet(mouseinfosheet, 4, 24 + (16 * 0), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 2) + 15);
378+ #ifdef CHNOSPROJECT_DEBUG_MCT
379+ Sheet_RefreshSheet(mouseinfosheet, 4, 24 + (16 * 0), mouseinfosheet->size.x - 1 - 4, 24 + (16 * 2) + 15);
380+ #endif
338381 }
339382 }
340383 } else if(data == TCM_INFO_DISPLAY_UPDATE_RESOLUTION){
341384 MouseCursor_Move_Absolute(mcursor, mcursor->cursor_sheet->parent->size.x >> 1, mcursor->cursor_sheet->parent->size.y >> 1);
342- Sheet_Show(mouseinfosheet, 2, 200, 200);
385+ MouseCursor_Show(mcursor);
386+ #ifdef CHNOSPROJECT_DEBUG_MCT
387+ Sheet_Show(mouseinfosheet, 2, 200, 200);
388+ #endif
343389 }
344390 }
345391 }
--- beta/tolset_chn_000/chnos_010/chnos/mouse.c (revision 320)
+++ beta/tolset_chn_000/chnos_010/chnos/mouse.c (revision 321)
@@ -66,10 +66,6 @@
6666 mouse_retv = data;
6767 }
6868
69- #ifdef CHNOSPROJECT_DEBUG_MOUSE
70- debug("InterruptHandler2c:IRQ12:0x%02X\n", data);
71- #endif
72-
7369 return;
7470 }
7571
@@ -343,12 +339,16 @@
343339 mctrl->decode_phase++;
344340 break;
345341 case 34:
342+ //はりぼて友の会などの資料には、スクロール情報は下位4バイトだけ有効であると書かれていたが、どうやら8バイト全て有効なようである。
346343 mctrl->decode_buf[3] = data;
347344 mctrl->decode_phase = 31;
348- mctrl->scroll = mctrl->decode_buf[3] & 0x0f;
349- if(mctrl->scroll & 0x08){
350- mctrl->scroll |= 0xfffffff0;
345+ mctrl->scroll = mctrl->decode_buf[3];
346+ if(mctrl->scroll & 0x80){
347+ mctrl->scroll |= 0xffffff00;
351348 }
349+ #ifdef CHNOSPROJECT_DEBUG_MOUSE
350+ debug("Mouse_Decode:case34:data=0x%02X scroll=%d\n", data, mctrl->scroll);
351+ #endif
352352 return True;
353353 }
354354
--- beta/tolset_chn_000/chnos_010/chnos/coredef0.h (revision 320)
+++ beta/tolset_chn_000/chnos_010/chnos/coredef0.h (revision 321)
@@ -12,7 +12,7 @@
1212 //#define CHNOSPROJECT_DEBUG_CALLBIOS
1313 //#define CHNOSPROJECT_DEBUG_FIFO
1414 //#define CHNOSPROJECT_DEBUG_KBCT
15- #define CHNOSPROJECT_DEBUG_MCT
15+ //#define CHNOSPROJECT_DEBUG_MCT
1616 #define CHNOSPROJECT_DEBUG_MOUSE
1717 //#define CHNOSPROJECT_DEBUG_DISPLAY
1818 //#define CHNOSPROJECT_DEBUG_DRAWING
Show on old repository browser