4 uint Sheet16_Internal_SetBuffer(UI_Sheet *sheet, void *vram, uint xsize, uint ysize, uint bpp)
\r
6 if(xsize > SHEET_MAX_XSIZE){
\r
7 #ifdef CHNOSPROJECT_DEBUG_SHEET
\r
8 debug("Sheet16_Internal_SetBuffer:Too large xsize.\n");
\r
12 if(ysize > SHEET_MAX_YSIZE){
\r
13 #ifdef CHNOSPROJECT_DEBUG_SHEET
\r
14 debug("Sheet16_Internal_SetBuffer:Too large ysize.\n");
\r
19 sheet->size.x = xsize;
\r
20 sheet->size.y = ysize;
\r
23 if(sheet->flags.bit.vram_auto_allocated){
\r
24 System_Memory_Free(sheet->vram, sheet->vramsize);
\r
25 sheet->flags.bit.vram_auto_allocated = False;
\r
29 sheet->vram = System_Memory_Allocate(xsize * ysize * 2);
\r
30 sheet->flags.bit.vram_auto_allocated = True;
\r
31 #ifdef CHNOSPROJECT_DEBUG_SHEET
\r
32 debug("Sheet16_Internal_SetBuffer:Auto Allocation.\n");
\r
38 sheet->vramsize = xsize * ysize * 2;
\r
39 sheet->Config_Functions = &Sheet16_Config_Functions;
\r
40 sheet->IsVisiblePixel = &Sheet_Internal_IsVisiblePixel_Invalid;
\r
41 sheet->flags.bit.using_invcol = False;
\r
43 sheet->Drawing.Fill_Rectangle = &Sheet16_Drawing_Fill_Rectangle;
\r
44 sheet->Drawing.Put_String = &Sheet16_Drawing_Put_String;
\r
45 sheet->Drawing.Draw_Point = &Sheet16_Drawing_Draw_Point;
\r
47 sheet->flags.bit.buffer_configured = True;
\r
52 //set function address from parent's bpp and own bpp.
\r
53 uint Sheet16_Config_Functions(UI_Sheet *sheet)
\r
56 #ifdef CHNOSPROJECT_DEBUG_SHEET
\r
57 debug("Sheet16_Config_Functions:Null sheet.\n");
\r
61 if(sheet->parent == Null){
\r
62 #ifdef CHNOSPROJECT_DEBUG_SHEET
\r
63 debug("Sheet16_Config_Functions:Null parent.\n");
\r
68 if(sheet->parent->bpp == 16){
\r
69 sheet->RefreshSheet = &Sheet16_Internal_RefreshSheet_To_16;
\r
70 } else if(sheet->parent->bpp == 8){
\r
71 sheet->RefreshSheet = &Sheet16_Internal_RefreshSheet_To_08;
\r
72 } else if(sheet->parent->bpp == 32){
\r
73 sheet->RefreshSheet = &Sheet16_Internal_RefreshSheet_To_32;
\r
75 #ifdef CHNOSPROJECT_DEBUG_SHEET
\r
76 debug("Sheet16_Config_Functions:Not implemented refresh function to bpp %d.\n", sheet->parent->bpp);
\r
82 uint Sheet16_Internal_RefreshSheet_To_16(UI_Sheet *sheet, int px0, int py0, int px1, int py1)
\r
84 DATA_Location2D p, r;
\r
87 if(sheet->parent->map == Null){
\r
88 #ifdef CHNOSPROJECT_DEBUG_SHEET
\r
89 debug("Sheet16_Internal_RefreshSheet_To_16:Null map.\n");
\r
94 Sheet_Internal_GetLocationP(sheet, &p);
\r
95 Sheet_Internal_GetLocationR(sheet, &r);
\r
116 if(r.x >= (int)sheet->parent->size.x){
\r
117 r.x = (int)sheet->parent->size.x - 1;
\r
119 if(r.y >= (int)sheet->parent->size.y){
\r
120 r.y = (int)sheet->parent->size.y - 1;
\r
123 for(y = p.y; y <= r.y; y++){
\r
124 for(x = p.x; x <= r.x; x++){
\r
125 if(sheet->parent->map[y * sheet->parent->size.x + x] == (uint)sheet){
\r
126 ((ushort *)sheet->parent->vram)[y * sheet->parent->size.x + x] = ((ushort *)sheet->vram)[(y - sheet->location.y) * sheet->size.x + (x - sheet->location.x)];
\r
134 uint Sheet16_Internal_RefreshSheet_To_08(UI_Sheet *sheet, int px0, int py0, int px1, int py1)
\r
136 DATA_Location2D p, r;
\r
139 if(sheet->parent->map == Null){
\r
140 #ifdef CHNOSPROJECT_DEBUG_SHEET
\r
141 debug("Sheet16_Internal_RefreshSheet_To_08:Null map.\n");
\r
146 Sheet_Internal_GetLocationP(sheet, &p);
\r
147 Sheet_Internal_GetLocationR(sheet, &r);
\r
168 if(r.x >= (int)sheet->parent->size.x){
\r
169 r.x = (int)sheet->parent->size.x - 1;
\r
171 if(r.y >= (int)sheet->parent->size.y){
\r
172 r.y = (int)sheet->parent->size.y - 1;
\r
175 for(y = p.y; y <= r.y; y++){
\r
176 for(x = p.x; x <= r.x; x++){
\r
177 if(sheet->parent->map[y * sheet->parent->size.x + x] == (uint)sheet){
\r
178 ((uchar *)sheet->parent->vram)[y * sheet->parent->size.x + x] = RGB_16_To_08(((ushort *)sheet->vram)[(y - sheet->location.y) * sheet->size.x + (x - sheet->location.x)]);
\r
186 uint Sheet16_Internal_RefreshSheet_To_32(UI_Sheet *sheet, int px0, int py0, int px1, int py1)
\r
188 DATA_Location2D p, r;
\r
191 if(sheet->parent->map == Null){
\r
192 #ifdef CHNOSPROJECT_DEBUG_SHEET
\r
193 debug("Sheet16_Internal_RefreshSheet_To_32:Null map.\n");
\r
198 Sheet_Internal_GetLocationP(sheet, &p);
\r
199 Sheet_Internal_GetLocationR(sheet, &r);
\r
220 if(r.x >= (int)sheet->parent->size.x){
\r
221 r.x = (int)sheet->parent->size.x - 1;
\r
223 if(r.y >= (int)sheet->parent->size.y){
\r
224 r.y = (int)sheet->parent->size.y - 1;
\r
227 for(y = p.y; y <= r.y; y++){
\r
228 for(x = p.x; x <= r.x; x++){
\r
229 if(sheet->parent->map[y * sheet->parent->size.x + x] == (uint)sheet){
\r
230 ((uint *)sheet->parent->vram)[y * sheet->parent->size.x + x] = RGB_16_To_32(((ushort *)sheet->vram)[(y - sheet->location.y) * sheet->size.x + (x - sheet->location.x)]);
\r
238 bool Sheet16_Internal_IsVisiblePixel(UI_Sheet *sheet, int px, int py)
\r
240 if(((ushort *)(sheet->vram))[(py - sheet->location.y) * (int)sheet->size.x + (px - sheet->location.x)] == sheet->invcol){
\r