マウスを使用したシートの移動を実装。
ただし、移動禁止シートは未実装なので、デスクトップを動かす事も出来てしまう。
保存コミット。
@@ -544,3 +544,26 @@ | ||
544 | 544 | } |
545 | 545 | return 0; |
546 | 546 | } |
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 | +} |
@@ -254,6 +254,7 @@ | ||
254 | 254 | uint Sheet_Enable_InvisibleColor(UI_Sheet *sheet, uint invcol); |
255 | 255 | uint Sheet_Disable_InvisibleColor(UI_Sheet *sheet); |
256 | 256 | uint Sheet_SetTopmost(UI_Sheet *sheet, bool topmost); |
257 | +UI_Sheet *Sheet_GetSheetFromLocation(UI_Sheet *parent, int px, int py); | |
257 | 258 | |
258 | 259 | /*sht08.c 8bitカラー シート関連*/ |
259 | 260 | uint Sheet08_Internal_SetBuffer(UI_Sheet *sheet, void *vram, uint xsize, uint ysize, uint bpp); |
@@ -74,11 +74,14 @@ | ||
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
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); | |
79 | 79 | |
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!"); | |
81 | 82 | |
83 | + Format_BMP_DrawPicture(sheet_desktop->vram, sheet_desktop->size.x, 10, 26, 0, 0, chnlogo); | |
84 | + | |
82 | 85 | Drawing_Fill_Circle(disp_ctrl->vram, disp_ctrl->xsize, 100, 250, 0x00c600, 45); |
83 | 86 | for(i = 0; i < 50; i += 5){ |
84 | 87 | Drawing_Draw_Circle(disp_ctrl->vram, disp_ctrl->xsize, 100, 250, 0xc6c6c6, i); |
@@ -85,21 +88,16 @@ | ||
85 | 88 | } |
86 | 89 | |
87 | 90 | testsheet = Sheet_Initialise(); |
88 | - sheet_desktop = Sheet_Initialise(); | |
91 | + | |
89 | 92 | sheet08 = Sheet_Initialise(); |
90 | 93 | sheet16 = Sheet_Initialise(); |
91 | 94 | sheet32 = Sheet_Initialise(); |
92 | 95 | |
93 | 96 | Sheet_SetBuffer(testsheet, Null, 256, 128, 8); |
94 | - Sheet_SetBuffer(sheet_desktop, Null, disp_ctrl->xsize, disp_ctrl->ysize, disp_ctrl->bpp); | |
95 | 97 | Sheet_SetBuffer(sheet08, Null, 128, 128, 8); |
96 | 98 | Sheet_SetBuffer(sheet16, Null, 128, 128, 16); |
97 | 99 | Sheet_SetBuffer(sheet32, Null, 128, 128, 32); |
98 | 100 | |
99 | - for(i = 0; i < sheet_desktop->vramsize; i++){ | |
100 | - ((uchar *)sheet_desktop->vram)[i] = ((uchar *)disp_ctrl->vram)[i]; | |
101 | - } | |
102 | - | |
103 | 101 | for(y = 0; y < testsheet->size.y; y++){ |
104 | 102 | for(x = 0; x < testsheet->size.x; x++){ |
105 | 103 | ((uchar *)testsheet->vram)[y * testsheet->size.x + x] = x * 2; |
@@ -148,17 +146,17 @@ | ||
148 | 146 | timer1 = Timer_Initialise(); |
149 | 147 | Timer_Config(timer1, 50, mytask->fifo, 11, True); |
150 | 148 | counter1 = 0; |
151 | - Timer_Run(timer1); | |
149 | + //Timer_Run(timer1); | |
152 | 150 | |
153 | 151 | timer2 = Timer_Initialise(); |
154 | 152 | Timer_Config(timer2, 50, mytask->fifo, 12, False); |
155 | 153 | counter2 = 0; |
156 | - Timer_Run(timer2); | |
154 | + //Timer_Run(timer2); | |
157 | 155 | |
158 | 156 | timer3 = Timer_Initialise(); |
159 | 157 | Timer_Config(timer3, 200, mytask->fifo, 13, True); |
160 | 158 | counter3 = 0; |
161 | - Timer_Run(timer3); | |
159 | + //Timer_Run(timer3); | |
162 | 160 | |
163 | 161 | for(;;){ |
164 | 162 | if(FIFO32_MyTaskFIFO_Status() == 0){ |
@@ -266,12 +264,20 @@ | ||
266 | 264 | UI_Task *mytask; |
267 | 265 | uint data; |
268 | 266 | 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 | |
271 | 271 | int scroll; |
272 | 272 | |
273 | + DATA_Location2D moveorg_mfocus; | |
274 | + UI_Sheet *mfocus; | |
275 | + bool old_mouse_buttonL; | |
276 | + | |
273 | 277 | data = 0; |
274 | 278 | scroll = 0; |
279 | + mfocus = Null; | |
280 | + old_mouse_buttonL = False; | |
275 | 281 | |
276 | 282 | mytask = System_MultiTask_GetNowTask(); |
277 | 283 |
@@ -279,12 +285,14 @@ | ||
279 | 285 | debug("MCT:MouseControlTask Start Running.\nMCT:UI_Task=0x%X\n", mytask); |
280 | 286 | #endif |
281 | 287 | |
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 | |
288 | 296 | |
289 | 297 | mctrl = Initialise_Mouse(); |
290 | 298 |
@@ -292,7 +300,6 @@ | ||
292 | 300 | debug("MCT:Mouse Initialized.\n"); |
293 | 301 | #endif |
294 | 302 | |
295 | - MouseCursor_Show(mcursor); | |
296 | 303 | Mouse_Set_ReceiveFIFO(mytask->fifo, 0x100); |
297 | 304 | |
298 | 305 | Mouse_Decode(mctrl, 0x00); //Decode start. |
@@ -299,7 +306,13 @@ | ||
299 | 306 | |
300 | 307 | for(;;){ |
301 | 308 | 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 | + } | |
303 | 316 | } else{ |
304 | 317 | data = FIFO32_MyTaskFIFO_Get(); |
305 | 318 | #ifdef CHNOSPROJECT_DEBUG_MCT |
@@ -308,38 +321,71 @@ | ||
308 | 321 | if(0x100 <= data && data <= 0x1ff){ |
309 | 322 | if(Mouse_Decode(mctrl, data - 0x100)){ |
310 | 323 | 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 | +/* | |
319 | 335 | 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; | |
321 | 341 | } |
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 | + } | |
322 | 356 | if(mctrl->button.bit.R){ |
323 | - s[8] -= 0x20; | |
357 | + #ifdef CHNOSPROJECT_DEBUG_MCT | |
358 | + s[8] -= 0x20; | |
359 | + #endif | |
324 | 360 | } |
325 | 361 | if(mctrl->button.bit.C){ |
326 | - s[9] -= 0x20; | |
362 | + #ifdef CHNOSPROJECT_DEBUG_MCT | |
363 | + s[9] -= 0x20; | |
364 | + #endif | |
327 | 365 | } |
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 | |
329 | 369 | if(mctrl->flags.scroll){ |
330 | 370 | 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 | |
336 | 377 | } 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 | |
338 | 381 | } |
339 | 382 | } |
340 | 383 | } else if(data == TCM_INFO_DISPLAY_UPDATE_RESOLUTION){ |
341 | 384 | 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 | |
343 | 389 | } |
344 | 390 | } |
345 | 391 | } |
@@ -66,10 +66,6 @@ | ||
66 | 66 | mouse_retv = data; |
67 | 67 | } |
68 | 68 | |
69 | - #ifdef CHNOSPROJECT_DEBUG_MOUSE | |
70 | - debug("InterruptHandler2c:IRQ12:0x%02X\n", data); | |
71 | - #endif | |
72 | - | |
73 | 69 | return; |
74 | 70 | } |
75 | 71 |
@@ -343,12 +339,16 @@ | ||
343 | 339 | mctrl->decode_phase++; |
344 | 340 | break; |
345 | 341 | case 34: |
342 | + //はりぼて友の会などの資料には、スクロール情報は下位4バイトだけ有効であると書かれていたが、どうやら8バイト全て有効なようである。 | |
346 | 343 | mctrl->decode_buf[3] = data; |
347 | 344 | 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; | |
351 | 348 | } |
349 | + #ifdef CHNOSPROJECT_DEBUG_MOUSE | |
350 | + debug("Mouse_Decode:case34:data=0x%02X scroll=%d\n", data, mctrl->scroll); | |
351 | + #endif | |
352 | 352 | return True; |
353 | 353 | } |
354 | 354 |
@@ -12,7 +12,7 @@ | ||
12 | 12 | //#define CHNOSPROJECT_DEBUG_CALLBIOS |
13 | 13 | //#define CHNOSPROJECT_DEBUG_FIFO |
14 | 14 | //#define CHNOSPROJECT_DEBUG_KBCT |
15 | - #define CHNOSPROJECT_DEBUG_MCT | |
15 | + //#define CHNOSPROJECT_DEBUG_MCT | |
16 | 16 | #define CHNOSPROJECT_DEBUG_MOUSE |
17 | 17 | //#define CHNOSPROJECT_DEBUG_DISPLAY |
18 | 18 | //#define CHNOSPROJECT_DEBUG_DRAWING |