#ifndef INCLUDE_DRAW_BUF_H #define INCLUDE_DRAW_BUF_H #print "[include ]\n" #ifndef INCLUDE_KOLIBRI_H #include "../lib/kolibri.h" #endif dword buf_data; dword zbuf_data; struct DrawBufer { int bufx, bufy, bufw, bufh; int zbufx, zbufy, zbufw, zbufh; byte zoomf; void Init(); void Show(); void Fill(); void Skew(); void DrawBar(); void PutPixel(); void AlignCenter(); void AlignRight(); void Zoom2x(); }; void DrawBufer::Init(int i_bufx, i_bufy, i_bufw, i_bufh) { bufx = i_bufx; bufy = i_bufy; bufw = i_bufw; bufh = i_bufh; free(buf_data); buf_data = malloc(bufw * bufh * 4 + 8); ESDWORD[buf_data] = bufw; ESDWORD[buf_data+4] = bufh; if (zoomf != 1) { zbufx = bufx; zbufy = bufy; zbufw = bufw * zoomf; zbufh = bufh * zoomf; free(zbuf_data); zbuf_data = malloc(zbufw * zbufh * 4 + 8); ESDWORD[zbuf_data] = zbufw; ESDWORD[zbuf_data+4] = zbufh; } } void DrawBufer::Fill(dword fill_color) { int i; int 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(dword 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(dword 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; dword point_x, max_i, zline_w, s_inc; point_x = 0; max_i = bufw * bufh * 4 + buf_data+8; s_inc = zoomf * 4; zline_w = zbufw * 4; for (i=buf_data+8, s=zbuf_data+8; i= bufw) { s += zoomf - 1 * zline_w; point_x = 0; } } } void DrawBufer::Show() { if (zoomf == 1) { PutPaletteImage(buf_data+8, bufw, bufh, bufx, bufy, 32, 0); } else { Zoom2x(); PutPaletteImage(zbuf_data+8, zbufw, zbufh, zbufx, zbufy, 32, 0); } } #endif