--- /dev/null
+\r
+#include "core.h"\r
+\r
+extern IO_MemoryControl sys_mem_ctrl;\r
+\r
+UI_Sheet_Control sys_sheet_ctrl;\r
+\r
+void Sheet_Initialise(UI_Sheet_Control *sheetctrl, IO_MemoryControl *memctrl, void *vram, uint xsize, uint ysize, uint bpp)\r
+{\r
+ uint x, y;\r
+\r
+ sheetctrl->memctrl = memctrl;\r
+\r
+ sheetctrl->mainvram = vram;\r
+ sheetctrl->map = MemoryBlock_Allocate_User(xsize * ysize * 4, sheetctrl->memctrl);\r
+ MemoryBlock_Write_Description(sheetctrl->map, "SHTCTRL_MAP");\r
+ for(y = 0; y < ysize; y++){\r
+ for(x = 0; x < xsize; x++){\r
+ sheetctrl->map[(y * xsize) + x] = 0;\r
+ }\r
+ }\r
+ sheetctrl->mainvramsize.x = xsize;\r
+ sheetctrl->mainvramsize.y = ysize;\r
+ sheetctrl->mainvrambpp = bpp;\r
+\r
+ sheetctrl->base.vram = 0;\r
+ sheetctrl->base.position.x = 0;\r
+ sheetctrl->base.position.y = 0;\r
+ sheetctrl->base.size.x = 0;\r
+ sheetctrl->base.size.y = 0;\r
+ sheetctrl->base.bpp = 0;\r
+ sheetctrl->base.invcol = 0;\r
+ sheetctrl->base.next = 0;\r
+ sheetctrl->base.before = 0;\r
+ sheetctrl->base.Refresh = 0;\r
+ sheetctrl->base.WriteMap = 0;\r
+ sheetctrl->base.visible = false;\r
+ sheetctrl->base.mouse_movable = false;\r
+ sheetctrl->base.myctrl = sheetctrl;\r
+ sheetctrl->base.fifo = 0;\r
+ sheetctrl->base.msignal_flags = 0;\r
+ sheetctrl->base.ksignal_flags = 0;\r
+\r
+ sheetctrl->sheets = 0;\r
+ return;\r
+}\r
+\r
+UI_Sheet *Sheet_Get(UI_Sheet_Control *ctrl, uint xsize, uint ysize, uint bpp, uint invcol)\r
+{\r
+ UI_Sheet *sheet;\r
+\r
+ if(bpp == 0){\r
+ bpp = ctrl->mainvrambpp;\r
+ }\r
+\r
+ sheet = MemoryBlock_Allocate_User(sizeof(UI_Sheet), ctrl->memctrl);\r
+ MemoryBlock_Write_Description(sheet, "UI_Sheet");\r
+ sheet->vram = MemoryBlock_Allocate_User(xsize * ysize * (bpp >> 3), ctrl->memctrl);\r
+ MemoryBlock_Write_Description(sheet->vram, "UI_Sheet_VRAM");\r
+ sheet->position.x = 0;\r
+ sheet->position.y = 0;\r
+ sheet->size.x = xsize;\r
+ sheet->size.y = ysize;\r
+ sheet->bpp = bpp;\r
+ sheet->invcol = invcol;\r
+ if(sheet->invcol == 0){\r
+ sheet->WriteMap = Sheet_Write_Map_NoInvisible;\r
+ } else if(sheet->bpp == 32){\r
+ sheet->WriteMap = Sheet_Write_Map_32;\r
+ } else if(sheet->bpp == 16){\r
+ sheet->WriteMap = Sheet_Write_Map_16;\r
+ sheet->invcol = RGB_32_To_16(sheet->invcol);\r
+ } else if(sheet->bpp == 8){\r
+ sheet->WriteMap = Sheet_Write_Map_08;\r
+ sheet->invcol = RGB_32_To_08(sheet->invcol);\r
+ }\r
+ sheet->next = 0;\r
+ sheet->before = 0;\r
+\r
+ sheet->Refresh = Sheet_Refresh_Invalid;\r
+ sheet->myctrl = ctrl;\r
+\r
+ sheet->visible = false;\r
+ sheet->mouse_movable = false;\r
+ sheet->MouseEventProcedure = 0;\r
+ sheet->fifo = 0;\r
+ sheet->msignal_flags = 0;\r
+ sheet->ksignal_flags = 0;\r
+\r
+ return sheet;\r
+}\r
+\r
+uint Sheet_Show(UI_Sheet *sheet, int px, int py, uint height)\r
+{\r
+ uint i;\r
+ UI_Sheet *now;\r
+ UI_Sheet_Control *ctrl;\r
+ uint eflags;\r
+\r
+ eflags = IO_Load_EFlags();\r
+ IO_CLI();\r
+\r
+ ctrl = sheet->myctrl;\r
+\r
+ now = &ctrl->base;\r
+ for(i = 0; i <= height; i++){\r
+ if(now->next == 0){\r
+ break;\r
+ }\r
+ if(i == height){\r
+ break;\r
+ }\r
+ now = now->next;\r
+ }\r
+ now->next->before = sheet;\r
+ sheet->next = now->next;\r
+ sheet->before = now;\r
+ now->next = sheet;\r
+\r
+ ctrl->sheets++;\r
+ sheet->position.x = px;\r
+ sheet->position.y = py;\r
+ sheet->visible = true;\r
+\r
+ if(ctrl->mainvrambpp == 32){\r
+ if(sheet->bpp == 32){\r
+ sheet->Refresh = Sheet_Refresh_32from32;\r
+// } else if(sheet->bpp == 16){\r
+\r
+// } else if(sheet->bpp == 8){\r
+\r
+ }\r
+ } else if(ctrl->mainvrambpp == 16){\r
+ if(sheet->bpp == 32){\r
+ sheet->Refresh = Sheet_Refresh_16from32;\r
+ } else if(sheet->bpp == 16){\r
+ sheet->Refresh = Sheet_Refresh_16from16;\r
+// } else if(sheet->bpp == 8){\r
+\r
+ }\r
+ } else if(ctrl->mainvrambpp == 8){\r
+ if(sheet->bpp == 32){\r
+ sheet->Refresh = Sheet_Refresh_08from32;\r
+// } else if(sheet->bpp == 16){\r
+\r
+ } else if(sheet->bpp == 8){\r
+ sheet->Refresh = Sheet_Refresh_08from08;\r
+ }\r
+ }\r
+ IO_Store_EFlags(eflags);\r
+\r
+ Sheet_Refresh_Map(sheet, sheet->position.x, sheet->position.y, sheet->position.x + sheet->size.x - 1, sheet->position.y + sheet->size.y - 1);\r
+ sheet->Refresh(sheet, 0, 0, sheet->size.x - 1, sheet->size.y - 1);\r
+\r
+ return i;\r
+}\r
+\r
+void Sheet_Set_Movable(UI_Sheet *sheet, bool movable)\r
+{\r
+ sheet->mouse_movable = movable;\r
+ return;\r
+}\r
+\r
+void Sheet_Set_MouseEventProcedure(UI_Sheet *sheet, void (*procedure)(UI_MouseEventArguments *e), uint flags)\r
+{\r
+ sheet->MouseEventProcedure = procedure;\r
+ sheet->msignal_flags = flags;\r
+ return;\r
+}\r
+\r
+void Sheet_Set_FIFO(UI_Sheet *sheet, DATA_FIFO *fifo, uint flags)\r
+{\r
+ sheet->fifo = fifo;\r
+ sheet->ksignal_flags = flags;\r
+ return;\r
+}\r
+\r
+void Sheet_Slide(UI_Sheet *sheet, int px, int py)\r
+{\r
+ int movex, movey;\r
+ DATA_Position2D target0, target1;\r
+ UI_Sheet_Control *ctrl;\r
+\r
+ ctrl = sheet->myctrl;\r
+ movex = px - sheet->position.x;\r
+ movey = py - sheet->position.y;\r
+\r
+ if(movex == 0 && movey == 0){ //\93®\82©\82È\82¢\r
+ return;\r
+ }\r
+ if(movey == 0){ //\89¡\82É\83X\83\89\83C\83h\82·\82é\82¾\82¯\r
+ target0.y = sheet->position.y;\r
+ target1.y = sheet->position.y + sheet->size.y - 1;\r
+ if(movex > 0){ //\89E\95û\8cü\r
+ target0.x = sheet->position.x;\r
+ target1.x = sheet->position.x + sheet->size.x - 1 + movex;\r
+ } else{ //\8d¶\95û\8cü\r
+ target0.x = sheet->position.x + movex;\r
+ target1.x = sheet->position.x + sheet->size.x - 1;\r
+ }\r
+ } else if(movex == 0){ //\8fc\82É\83X\83\89\83C\83h\82·\82é\82¾\82¯\r
+ target0.x = sheet->position.x;\r
+ target1.x = sheet->position.x + sheet->size.x - 1;\r
+ if(movey > 0){ //\89º\95û\8cü\r
+ target0.y = sheet->position.y;\r
+ target1.y = sheet->position.y + sheet->size.y - 1 + movey;\r
+ } else{ //\8fã\95û\8cü\r
+ target0.y = sheet->position.y + movey;\r
+ target1.y = sheet->position.y + sheet->size.y - 1;\r
+ }\r
+ } else if(movex > 0 && movey > 0){ //\89E\89º\82Ö\83X\83\89\83C\83h\r
+ target0.x = sheet->position.x;\r
+ target0.y = sheet->position.y;\r
+ target1.x = sheet->position.x + sheet->size.x - 1 + movex;\r
+ target1.y = sheet->position.y + sheet->size.y - 1 + movey;\r
+ } else if(movex > 0 && movey < 0){ //\89E\8fã\82Ö\83X\83\89\83C\83h\r
+ target0.x = sheet->position.x;\r
+ target0.y = sheet->position.y + movey;\r
+ target1.x = sheet->position.x + sheet->size.x - 1 + movex;\r
+ target1.y = sheet->position.y + sheet->size.y - 1;\r
+ } else if(movex < 0 && movey > 0){ //\8d¶\89º\82Ö\83X\83\89\83C\83h\r
+ target0.x = sheet->position.x + movex;\r
+ target0.y = sheet->position.y;\r
+ target1.x = sheet->position.x + sheet->size.x - 1;\r
+ target1.y = sheet->position.y + sheet->size.y - 1 + movey;\r
+ } else if(movex < 0 && movey < 0){ //\8d¶\8fã\82Ö\83X\83\89\83C\83h\r
+ target0.x = sheet->position.x + movex;\r
+ target0.y = sheet->position.y + movey;\r
+ target1.x = sheet->position.x + sheet->size.x - 1;\r
+ target1.y = sheet->position.y + sheet->size.y - 1;\r
+ }\r
+\r
+ sheet->visible = false;\r
+ Sheet_Refresh_Map(sheet, sheet->position.x, sheet->position.y, sheet->position.x + sheet->size.x - 1, sheet->position.y + sheet->size.y - 1);\r
+ sheet->position.x = px;\r
+ sheet->position.y = py;\r
+ sheet->visible = true;\r
+ Sheet_Refresh_Map(sheet, sheet->position.x, sheet->position.y, sheet->position.x + sheet->size.x - 1, sheet->position.y + sheet->size.y - 1);\r
+ Sheet_Refresh_All(ctrl->base.next, sheet->next, target0.x, target0.y, target1.x, target1.y);\r
+ return;\r
+}\r
+\r
+uint Sheet_UpDown(UI_Sheet *sheet, uint height)\r
+{\r
+ uint i;\r
+ UI_Sheet *now;\r
+\r
+ if(sheet->before == 0){\r
+ return 0;\r
+ }\r
+\r
+ now = &sheet->myctrl->base;\r
+\r
+ for(i = 0; now != sheet; i++){\r
+ now = now->next;\r
+ }\r
+ if(i == height){\r
+ return i;\r
+ }\r
+ Sheet_Remove(sheet);\r
+ return Sheet_Show(sheet, sheet->position.x, sheet->position.y, height - 1);\r
+}\r
+\r
+void Sheet_Remove(UI_Sheet *sheet)\r
+{\r
+ UI_Sheet_Control *ctrl;\r
+ uint eflags;\r
+\r
+ eflags = IO_Load_EFlags();\r
+ IO_CLI();\r
+\r
+ ctrl = sheet->myctrl;\r
+\r
+ ctrl->sheets--;\r
+ sheet->visible = false;\r
+ Sheet_Refresh_Map(sheet, sheet->position.x, sheet->position.y, sheet->position.x + sheet->size.x - 1, sheet->position.y + sheet->size.y - 1);\r
+ sheet->before->next = sheet->next;\r
+ sheet->next->before = sheet->before;\r
+ Sheet_Refresh_All(ctrl->base.next, sheet->next, sheet->position.x, sheet->position.y, sheet->position.x + sheet->size.x - 1, sheet->position.y + sheet->size.y - 1);\r
+ sheet->next = 0;\r
+ sheet->before = 0;\r
+\r
+ IO_Store_EFlags(eflags);\r
+ return;\r
+}\r
+\r
+void Sheet_Refresh_Map(UI_Sheet *sheet, int x0, int y0, int x1, int y1)\r
+{\r
+ UI_Sheet **before;\r
+ uint i, x, y;\r
+ DATA_Position2D target0, target1;\r
+ UI_Sheet_Control *ctrl;\r
+\r
+ ctrl = sheet->myctrl;\r
+ if(x0 >= ctrl->mainvramsize.x || y0 >= ctrl->mainvramsize.y || x1 < 0 || y1 < 0){\r
+ return;\r
+ }\r
+ if(x0 < 0){\r
+ x0 = 0;\r
+ }\r
+ if(y0 < 0){\r
+ y0 = 0;\r
+ }\r
+ if(x1 >= ctrl->mainvramsize.x){\r
+ x1 = ctrl->mainvramsize.x - 1;\r
+ }\r
+ if(y1 >= ctrl->mainvramsize.y){\r
+ y1 = ctrl->mainvramsize.y - 1;\r
+ }\r
+\r
+ before = &ctrl->base.next;\r
+ for(i = 0; i < ctrl->sheets; i++){\r
+ for(y = y0; y <= y1; y++){\r
+ for(x = x0; x <= x1; x++){\r
+ if(ctrl->map[(y * ctrl->mainvramsize.x) + x] == (uint)*before){\r
+ ctrl->map[(y * ctrl->mainvramsize.x) + x] = 0;\r
+ }\r
+ }\r
+ }\r
+ if(*before == sheet){\r
+ break;\r
+ }\r
+ before = &(*before)->next;\r
+ }\r
+\r
+ i++;\r
+\r
+ for(; i > 0; i--){\r
+ target0.x = (*before)->position.x;\r
+ target0.y = (*before)->position.y;\r
+ target1.x = (*before)->position.x + (*before)->size.x - 1;\r
+ target1.y = (*before)->position.y + (*before)->size.y - 1;\r
+\r
+ if(target0.x <= x1 && target0.y <= y1 && target1.x >= x0 && target1.y >= y0 && (*before)->visible){\r
+ if(target0.x < x0){\r
+ target0.x = x0;\r
+ }\r
+ if(target0.y < y0){\r
+ target0.y = y0;\r
+ }\r
+ if(target1.x > x1){\r
+ target1.x = x1;\r
+ }\r
+ if(target1.y > y1){\r
+ target1.y = y1;\r
+ }\r
+ (*before)->WriteMap(*before, target0.x, target0.y, target1.x, target1.y);\r
+ }\r
+ before = &(*before)->before;\r
+ }\r
+ return;\r
+}\r
+\r
+void Sheet_Write_Map_32(UI_Sheet *sheet, int x0, int y0, int x1, int y1)\r
+{\r
+ int x, y;\r
+ UI_Sheet_Control *ctrl;\r
+\r
+ ctrl = sheet->myctrl;\r
+ for(y = y0; y <= y1; y++){\r
+ for(x = x0; x <= x1; x++){\r
+ if(ctrl->map[(y * ctrl->mainvramsize.x) + x] == 0 && ((uint *)sheet->vram)[((y - sheet->position.y) * sheet->size.x) + (x - sheet->position.x)] != sheet->invcol){\r
+ ctrl->map[(y * ctrl->mainvramsize.x) + x] = (uint)sheet;\r
+ }\r
+ }\r
+ }\r
+ return;\r
+}\r
+\r
+void Sheet_Write_Map_16(UI_Sheet *sheet, int x0, int y0, int x1, int y1)\r
+{\r
+ int x, y;\r
+ UI_Sheet_Control *ctrl;\r
+\r
+ ctrl = sheet->myctrl;\r
+ for(y = y0; y <= y1; y++){\r
+ for(x = x0; x <= x1; x++){\r
+ if(ctrl->map[(y * ctrl->mainvramsize.x) + x] == 0 && ((ushort *)sheet->vram)[((y - sheet->position.y) * sheet->size.x) + (x - sheet->position.x)] != (ushort)sheet->invcol){\r
+ ctrl->map[(y * ctrl->mainvramsize.x) + x] = (uint)sheet;\r
+ }\r
+ }\r
+ }\r
+ return;\r
+}\r
+\r
+void Sheet_Write_Map_08(UI_Sheet *sheet, int x0, int y0, int x1, int y1)\r
+{\r
+ int x, y;\r
+ UI_Sheet_Control *ctrl;\r
+\r
+ ctrl = sheet->myctrl;\r
+ for(y = y0; y <= y1; y++){\r
+ for(x = x0; x <= x1; x++){\r
+ if(ctrl->map[(y * ctrl->mainvramsize.x) + x] == 0 && ((uchar *)sheet->vram)[((y - sheet->position.y) * sheet->size.x) + (x - sheet->position.x)] != (uchar)sheet->invcol){\r
+ ctrl->map[(y * ctrl->mainvramsize.x) + x] = (uint)sheet;\r
+ }\r
+ }\r
+ }\r
+ return;\r
+}\r
+\r
+void Sheet_Write_Map_NoInvisible(UI_Sheet *sheet, int x0, int y0, int x1, int y1)\r
+{\r
+ int x, y;\r
+ UI_Sheet_Control *ctrl;\r
+\r
+ ctrl = sheet->myctrl;\r
+ for(y = y0; y <= y1; y++){\r
+ for(x = x0; x <= x1; x++){\r
+ if(ctrl->map[(y * ctrl->mainvramsize.x) + x] == 0){\r
+ ctrl->map[(y * ctrl->mainvramsize.x) + x] = (uint)sheet;\r
+ }\r
+ }\r
+ }\r
+ return;\r
+}\r
+\r
+void Sheet_Refresh_All(UI_Sheet *sheet0, UI_Sheet *sheet1, int x0, int y0, int x1, int y1)\r
+{\r
+ UI_Sheet *now;\r
+ uint i;\r
+ DATA_Position2D target0, target1;\r
+ UI_Sheet_Control *ctrl;\r
+\r
+ ctrl = sheet0->myctrl;\r
+ now = sheet0;\r
+ for(i = 0; i < ctrl->sheets; i++){\r
+ target0.x = now->position.x;\r
+ target0.y = now->position.y;\r
+ target1.x = now->position.x + now->size.x - 1;\r
+ target1.y = now->position.y + now->size.y - 1;\r
+\r
+ if(target0.x <= x1 && target0.y <= y1 && target1.x >= x0 && target1.y >= y0 && now->visible){\r
+ if(target0.x < x0){\r
+ target0.x = x0;\r
+ }\r
+ if(target0.y < y0){\r
+ target0.y = y0;\r
+ }\r
+ if(target1.x > x1){\r
+ target1.x = x1;\r
+ }\r
+ if(target1.y > y1){\r
+ target1.y = y1;\r
+ }\r
+ now->Refresh(now, target0.x - now->position.x, target0.y - now->position.y, target1.x - now->position.x, target1.y - now->position.y);\r
+ }\r
+ if(now->next == sheet1 || now->next == 0){\r
+ break;\r
+ }\r
+ now = now->next;\r
+ }\r
+ return;\r
+}\r
+\r
+void Sheet_Refresh_32from32(UI_Sheet *sheet, int px0, int py0, int px1, int py1)\r
+{\r
+ int x, y;\r
+ UI_Sheet_Control *ctrl;\r
+\r
+ ctrl = sheet->myctrl;\r
+ px0 = px0 + sheet->position.x;\r
+ py0 = py0 + sheet->position.y;\r
+ px1 = px1 + sheet->position.x;\r
+ py1 = py1 + sheet->position.y;\r
+\r
+ if(px0 >= ctrl->mainvramsize.x || py0 >= ctrl->mainvramsize.y || px1 < 0 || py1 < 0){\r
+ return;\r
+ }\r
+ if(px0 < 0){\r
+ px0 = 0;\r
+ }\r
+ if(py0 < 0){\r
+ py0 = 0;\r
+ }\r
+ if(px1 >= ctrl->mainvramsize.x){\r
+ px1 = ctrl->mainvramsize.x - 1;\r
+ }\r
+ if(py1 >= ctrl->mainvramsize.y){\r
+ py1 = ctrl->mainvramsize.y - 1;\r
+ }\r
+\r
+ for(y = py0; y <= py1; y++){\r
+ for(x = px0; x <= px1; x++){\r
+ if(ctrl->map[(y * ctrl->mainvramsize.x) + x] == (uint)sheet){\r
+ ((uint *)ctrl->mainvram)[(y * ctrl->mainvramsize.x) + x] = ((uint *)sheet->vram)[((y - sheet->position.y) * sheet->size.x) + (x - sheet->position.x)];\r
+ }\r
+ }\r
+ }\r
+ return;\r
+}\r
+\r
+void Sheet_Refresh_16from32(UI_Sheet *sheet, int px0, int py0, int px1, int py1)\r
+{\r
+ int x, y;\r
+ UI_Sheet_Control *ctrl;\r
+\r
+ ctrl = sheet->myctrl;\r
+ px0 = px0 + sheet->position.x;\r
+ py0 = py0 + sheet->position.y;\r
+ px1 = px1 + sheet->position.x;\r
+ py1 = py1 + sheet->position.y;\r
+\r
+ if(px0 >= ctrl->mainvramsize.x || py0 >= ctrl->mainvramsize.y || px1 < 0 || py1 < 0){\r
+ return;\r
+ }\r
+ if(px0 < 0){\r
+ px0 = 0;\r
+ }\r
+ if(py0 < 0){\r
+ py0 = 0;\r
+ }\r
+ if(px1 >= ctrl->mainvramsize.x){\r
+ px1 = ctrl->mainvramsize.x - 1;\r
+ }\r
+ if(py1 >= ctrl->mainvramsize.y){\r
+ py1 = ctrl->mainvramsize.y - 1;\r
+ }\r
+\r
+ for(y = py0; y <= py1; y++){\r
+ for(x = px0; x <= px1; x++){\r
+ if(ctrl->map[(y * ctrl->mainvramsize.x) + x] == (uint)sheet){\r
+ ((ushort *)ctrl->mainvram)[(y * ctrl->mainvramsize.x) + x] = RGB_32_To_16(((uint *)sheet->vram)[((y - sheet->position.y) * sheet->size.x) + (x - sheet->position.x)]);\r
+ }\r
+ }\r
+ }\r
+ return;\r
+}\r
+\r
+void Sheet_Refresh_08from32(UI_Sheet *sheet, int px0, int py0, int px1, int py1)\r
+{\r
+ int x, y;\r
+ UI_Sheet_Control *ctrl;\r
+\r
+ ctrl = sheet->myctrl;\r
+ px0 = px0 + sheet->position.x;\r
+ py0 = py0 + sheet->position.y;\r
+ px1 = px1 + sheet->position.x;\r
+ py1 = py1 + sheet->position.y;\r
+\r
+ if(px0 >= ctrl->mainvramsize.x || py0 >= ctrl->mainvramsize.y || px1 < 0 || py1 < 0){\r
+ return;\r
+ }\r
+ if(px0 < 0){\r
+ px0 = 0;\r
+ }\r
+ if(py0 < 0){\r
+ py0 = 0;\r
+ }\r
+ if(px1 >= ctrl->mainvramsize.x){\r
+ px1 = ctrl->mainvramsize.x - 1;\r
+ }\r
+ if(py1 >= ctrl->mainvramsize.y){\r
+ py1 = ctrl->mainvramsize.y - 1;\r
+ }\r
+\r
+ for(y = py0; y <= py1; y++){\r
+ for(x = px0; x <= px1; x++){\r
+ if(ctrl->map[(y * ctrl->mainvramsize.x) + x] == (uint)sheet){\r
+ ((uchar *)ctrl->mainvram)[(y * ctrl->mainvramsize.x) + x] = RGB_32_To_08_xy(((uint *)sheet->vram)[((y - sheet->position.y) * sheet->size.x) + (x - sheet->position.x)], x, y);\r
+ }\r
+ }\r
+ }\r
+ return;\r
+}\r
+\r
+void Sheet_Refresh_16from16(UI_Sheet *sheet, int px0, int py0, int px1, int py1)\r
+{\r
+ int x, y;\r
+ UI_Sheet_Control *ctrl;\r
+\r
+ ctrl = sheet->myctrl;\r
+ px0 = px0 + sheet->position.x;\r
+ py0 = py0 + sheet->position.y;\r
+ px1 = px1 + sheet->position.x;\r
+ py1 = py1 + sheet->position.y;\r
+\r
+ if(px0 >= ctrl->mainvramsize.x || py0 >= ctrl->mainvramsize.y || px1 < 0 || py1 < 0){\r
+ return;\r
+ }\r
+ if(px0 < 0){\r
+ px0 = 0;\r
+ }\r
+ if(py0 < 0){\r
+ py0 = 0;\r
+ }\r
+ if(px1 >= ctrl->mainvramsize.x){\r
+ px1 = ctrl->mainvramsize.x - 1;\r
+ }\r
+ if(py1 >= ctrl->mainvramsize.y){\r
+ py1 = ctrl->mainvramsize.y - 1;\r
+ }\r
+\r
+ for(y = py0; y <= py1; y++){\r
+ for(x = px0; x <= px1; x++){\r
+ if(ctrl->map[(y * ctrl->mainvramsize.x) + x] == (uint)sheet){\r
+ ((ushort *)ctrl->mainvram)[(y * ctrl->mainvramsize.x) + x] = ((ushort *)sheet->vram)[((y - sheet->position.y) * sheet->size.x) + (x - sheet->position.x)];\r
+ }\r
+ }\r
+ }\r
+ return;\r
+}\r
+\r
+void Sheet_Refresh_08from08(UI_Sheet *sheet, int px0, int py0, int px1, int py1)\r
+{\r
+ int x, y;\r
+ UI_Sheet_Control *ctrl;\r
+\r
+ ctrl = sheet->myctrl;\r
+ px0 = px0 + sheet->position.x;\r
+ py0 = py0 + sheet->position.y;\r
+ px1 = px1 + sheet->position.x;\r
+ py1 = py1 + sheet->position.y;\r
+\r
+ if(px0 >= ctrl->mainvramsize.x || py0 >= ctrl->mainvramsize.y || px1 < 0 || py1 < 0){\r
+ return;\r
+ }\r
+ if(px0 < 0){\r
+ px0 = 0;\r
+ }\r
+ if(py0 < 0){\r
+ py0 = 0;\r
+ }\r
+ if(px1 >= ctrl->mainvramsize.x){\r
+ px1 = ctrl->mainvramsize.x - 1;\r
+ }\r
+ if(py1 >= ctrl->mainvramsize.y){\r
+ py1 = ctrl->mainvramsize.y - 1;\r
+ }\r
+\r
+ for(y = py0; y <= py1; y++){\r
+ for(x = px0; x <= px1; x++){\r
+ if(ctrl->map[(y * ctrl->mainvramsize.x) + x] == (uint)sheet){\r
+ ((uchar *)ctrl->mainvram)[(y * ctrl->mainvramsize.x) + x] = ((uchar *)sheet->vram)[((y - sheet->position.y) * sheet->size.x) + (x - sheet->position.x)];\r
+ }\r
+ }\r
+ }\r
+ return;\r
+}\r
+\r
+void Sheet_Refresh_Invalid(UI_Sheet *sheet, int px0, int py0, int px1, int py1)\r
+{\r
+ return;\r
+}\r
+\r
+void Sheet_Draw_Put_String(UI_Sheet *sheet, uint x, uint y, uint c, const uchar *s)\r
+{\r
+ uint i;\r
+\r
+ for(i = 0; s[i] != 0x00; i++){\r
+\r
+ }\r
+\r
+ if(y > sheet->size.y - 16){\r
+ return;\r
+ }\r
+\r
+ if(sheet->bpp == 32){\r
+ Draw_Put_String_32(sheet->vram, sheet->size.x, x, y, c, s);\r
+ } else if(sheet->bpp == 16){\r
+ Draw_Put_String_16(sheet->vram, sheet->size.x, x, y, c, s);\r
+ } else if(sheet->bpp == 8){\r
+ Draw_Put_String_08(sheet->vram, sheet->size.x, x, y, c, s);\r
+ }\r
+\r
+ sheet->Refresh(sheet, x, y, x + (i * 8), y + 16);\r
+ return;\r
+}\r
+\r
+void Sheet_Draw_Put_String_With_BackColor(UI_Sheet *sheet, uint x, uint y, uint c, uint bc, const uchar *s)\r
+{\r
+ uint i;\r
+\r
+ for(i = 0; s[i] != 0x00; i++){\r
+\r
+ }\r
+\r
+ Sheet_Draw_Fill_Rectangle(sheet, bc, x, y, x + (i * 8) - 1, y + 16 - 1);\r
+\r
+ if(y > sheet->size.y - 16){\r
+ return;\r
+ }\r
+\r
+ if(sheet->bpp == 32){\r
+ Draw_Put_String_32(sheet->vram, sheet->size.x, x, y, c, s);\r
+ } else if(sheet->bpp == 16){\r
+ Draw_Put_String_16(sheet->vram, sheet->size.x, x, y, c, s);\r
+ } else if(sheet->bpp == 8){\r
+ Draw_Put_String_08(sheet->vram, sheet->size.x, x, y, c, s);\r
+ }\r
+\r
+ sheet->Refresh(sheet, x, y, x + (i * 8), y + 16);\r
+ return;\r
+}\r
+\r
+void Sheet_Draw_Fill_Rectangle(UI_Sheet *sheet, uint c, uint x0, uint y0, uint x1, uint y1)\r
+{\r
+ if(x1 >= sheet->size.x || y1 >= sheet->size.y){\r
+ return;\r
+ }\r
+\r
+ if(sheet->bpp == 32){\r
+ Draw_Fill_Rectangle_32(sheet->vram, sheet->size.x, c, x0, y0, x1, y1);\r
+ } else if(sheet->bpp == 16){\r
+ Draw_Fill_Rectangle_16(sheet->vram, sheet->size.x, c, x0, y0, x1, y1);\r
+ } else if(sheet->bpp == 8){\r
+ Draw_Fill_Rectangle_08(sheet->vram, sheet->size.x, c, x0, y0, x1, y1);\r
+ }\r
+ sheet->Refresh(sheet, x0, y0, x1, y1);\r
+ return;\r
+}\r
+\r
+void Sheet_Draw_Fill_Rectangle_Gradation_Vertical(UI_Sheet *sheet, uint c0, uint c1, uint x0, uint y0, uint x1, uint y1)\r
+{\r
+ int nowcol, nowcol_R, nowcol_G, nowcol_B, add_R, add_G, add_B;\r
+ uint x, y;\r
+\r
+ if(x1 >= sheet->size.x || y1 >= sheet->size.y){\r
+ return;\r
+ }\r
+\r
+ if(y1 == y0){\r
+ return;\r
+ }\r
+\r
+ c0 &= 0x00ffffff;\r
+ c1 &= 0x00ffffff;\r
+\r
+ add_R = (((int)((c1 & 0x00ff0000) >> 16) << 10) - ((int)((c0 & 0x00ff0000) >> 16) << 10)) / (int)(y1 - y0);\r
+ add_G = (((int)((c1 & 0x0000ff00) >> 8) << 10) - ((int)((c0 & 0x0000ff00) >> 8) << 10)) / (int)(y1 - y0);\r
+ add_B = (((int)(c1 & 0x000000ff) << 10) - ((int)(c0 & 0x000000ff) << 10)) / (int)(y1 - y0);\r
+\r
+ nowcol_R = ((c0 & 0x00ff0000) >> 16) << 10;\r
+ nowcol_G = ((c0 & 0x0000ff00) >> 8) << 10;\r
+ nowcol_B = (c0 & 0x000000ff) << 10;\r
+\r
+ for(y = y0; y <= y1; y++){\r
+ nowcol = ((nowcol_R >> 10) << 16) | ((nowcol_G >> 10) << 8) | (nowcol_B >> 10);\r
+ for(x = x0; x <= x1; x++){\r
+ Sheet_Draw_Point(sheet, (uint)nowcol, x, y);\r
+ }\r
+ nowcol_R += add_R;\r
+ nowcol_G += add_G;\r
+ nowcol_B += add_B;\r
+ }\r
+\r
+ return;\r
+}\r
+void Sheet_Draw_Point(UI_Sheet *sheet, uint c, uint x, uint y)\r
+{\r
+ if(sheet->bpp == 32){\r
+ ((uint *)sheet->vram)[y * sheet->size.x + x] = c;\r
+ } else if(sheet->bpp == 16){\r
+ c = RGB_32_To_16(c);\r
+ ((ushort *)sheet->vram)[y * sheet->size.x + x] = (ushort)c;\r
+ } else if(sheet->bpp == 8){\r
+// c = RGB_32_To_08(c);\r
+ c = RGB_32_To_08_xy(c, x, y);\r
+ ((uchar *)sheet->vram)[y * sheet->size.x + x] = (uchar)c;\r
+ }\r
+ sheet->Refresh(sheet, x, y, x, y);\r
+ return;\r
+}\r
+\r
+void System_Sheet_Initialise(void *vram, uint xsize, uint ysize, uint bpp)\r
+{\r
+ Sheet_Initialise(&sys_sheet_ctrl, &sys_mem_ctrl, vram, xsize, ysize, bpp);\r
+ return;\r
+}\r
+\r
+UI_Sheet *System_Sheet_Get(uint xsize, uint ysize, uint bpp, uint invcol)\r
+{\r
+ return Sheet_Get(&sys_sheet_ctrl, xsize, ysize, bpp, invcol);\r
+}\r
+\r
+UI_Sheet *Sheet_Get_From_Position(UI_Sheet_Control *ctrl, int x, int y)\r
+{\r
+ if(x < 0 || y < 0 || x > ctrl->mainvramsize.x || y > ctrl->mainvramsize.y){\r
+ return 0;\r
+ }\r
+ return (UI_Sheet *)ctrl->map[(y * ctrl->mainvramsize.x) + x];\r
+}\r
+\r
+uint Sheet_Get_Top_Of_Height(UI_Sheet_Control *ctrl)\r
+{\r
+ if(ctrl->sheets < 1){\r
+ return 0;\r
+ }\r
+ return ctrl->sheets - 1;\r
+}\r
+\r
+uint System_Sheet_Get_Top_Of_Height(void)\r
+{\r
+ return Sheet_Get_Top_Of_Height(&sys_sheet_ctrl);\r
+}\r