#ifndef INCLUDE_DRAW_BUF_H #define INCLUDE_DRAW_BUF_H #print "[include ]\n" #ifndef INCLUDE_KOLIBRI_H #include "../lib/kolibri.h" #endif unsigned buf_data; struct DrawBufer { unsigned bufx, bufy, bufw, bufh; byte zoom; bool Init(); void Show(); void Fill(); void Skew(); void DrawBar(); void PutPixel(); void AlignCenter(); void AlignRight(); }; bool DrawBufer::Init(int i_bufx, i_bufy, i_bufw, i_bufh) { dword alloc_size, free_ram_size; char error_str[256]; if (!zoom) zoom = 1; bufx = i_bufx; bufy = i_bufy; bufw = i_bufw * zoom; bufh = i_bufh * zoom; free(buf_data); $mov eax, 18 $mov ebx, 16 $int 0x40 free_ram_size = EAX * 1024; alloc_size = bufw * bufh * 4 + 8; if (alloc_size >= free_ram_size) { sprintf(#error_str, "'DrawBufer needs more memory than currenly available. Application could be unstable. Requested size: %i Kb. Free RAM: %i Kb' -E", alloc_size/1024, free_ram_size/1024); notify(#error_str); } buf_data = malloc(alloc_size); //debugval("buf_data",buf_data); if (!buf_data) return false; ESDWORD[buf_data] = bufw; ESDWORD[buf_data+4] = bufh; return true; } void DrawBufer::Fill(unsigned fill_color) { unsigned i; unsigned max_i = bufw * bufh * 4 + buf_data + 8; for (i=buf_data+8; iy+j*bufw+x+h-12*4 ; i-=4) ESDWORD[buf_data+i+8] = ESDWORD[-shift[j]+buf_data+i+8]; } } void DrawBufer::AlignRight(unsigned x,y,w,h, content_width) { int i, j, l; int content_left = w - content_width / 2; for (j=0; j=j*w+content_left*4) && (l>=j*w*4); i-=4, l-=4) { ESDWORD[buf_data+8+i] >< ESDWORD[buf_data+8+l]; } } } void DrawBufer::AlignCenter(unsigned x,y,w,h, content_width) { int i, j, l; int content_left = w - content_width / 2; for (j=0; j=j*w+content_left*4) && (l>=j*w*4); i-=4, l-=4) { ESDWORD[buf_data+8+i] >< ESDWORD[buf_data+8+l]; } } } /* void DrawBufer::Zoom2x() { int i, s; unsigned point_x, max_i, zline_w, s_inc; point_x = 0; max_i = bufw * bufh * 4 + buf_data+8; s_inc = zoom * 4; zline_w = zbufw * 4; for (i=buf_data+8, s=zbuf_data+8; i= bufw) { s += zoom - 1 * zline_w; point_x = 0; } } } */ void DrawBufer::Show() { PutPaletteImage(buf_data+8, bufw, bufh, bufx, bufy, 32, 0); } #endif