Changeset 518 for abuse/trunk
- Timestamp:
- Apr 20, 2011, 9:02:33 PM (11 years ago)
- Location:
- abuse/trunk/src
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/automap.cpp
r515 r518 59 59 draw_ystart=centery-(y*AUTOTILE_HEIGHT/f_hi-sy*AUTOTILE_HEIGHT); 60 60 61 // if view position hasn't changed, only update the b inking dot and return61 // if view position hasn't changed, only update the blinking dot and return 62 62 if (draw_xstart==old_dx && draw_ystart==old_dy) 63 63 { 64 64 automap_window->screen->Lock(); 65 automap_window->screen-> add_dirty(centerx,centery,centerx,centery);65 automap_window->screen->AddDirty(centerx,centery,centerx + 1,centery + 1); 66 66 if ((tick++)&4) 67 67 automap_window->screen->PutPixel(vec2i(centerx,centery),255); … … 96 96 // we are going to redraw the whole map, so make the dirty rect work easier by marking 97 97 // everything dirty 98 screen-> add_dirty(window_xstart,window_ystart,window_xend,window_yend);98 screen->AddDirty(window_xstart,window_ystart,window_xend+1,window_yend+1); 99 99 100 100 … … 105 105 // we will slam on as fast as possible 106 106 107 screen-> set_clip(window_xstart,window_ystart,window_xend,window_yend);107 screen->SetClip(window_xstart,window_ystart,window_xend+1,window_yend+1); 108 108 /* for (i=draw_xstart,j=draw_ystart,x=sx,y=sy; y<=ey; j+=AUTOTILE_HEIGHT,y++) 109 109 foretiles[cur_lev->get_fg(x,y)]->micro_image->put_image(screen,i,j,0); … … 149 149 150 150 // set the clip back to full window size because soemthing else could mess with the area 151 automap_window->screen-> set_clip(0,0,screen->Size().x-1,screen->Size().y-1);151 automap_window->screen->SetClip(0,0,screen->Size().x,screen->Size().y); 152 152 } 153 153 -
abuse/trunk/src/common.h
r509 r518 12 12 #define __COMMON_H__ 13 13 14 // 15 // Lol Engine 16 // 14 17 #include "lol/matrix.h" 15 18 using namespace lol; 16 19 20 // 21 // Custom utility functions 22 // 23 static inline int Min(int a, int b) { return a < b ? a : b; } 24 static inline int Max(int a, int b) { return a > b ? a : b; } 25 static inline float Min(float a, float b) { return a < b ? a : b; } 26 static inline float Max(float a, float b) { return a > b ? a : b; } 27 17 28 #endif // __COMMON_H__ 18 29 -
abuse/trunk/src/console.cpp
r512 r518 56 56 con_win=wm->new_window(lastx,lasty,screen_w(),screen_h(),NULL,name); 57 57 redraw(); 58 con_win->screen-> set_clip(con_win->x1(),con_win->y1(),con_win->x2(),con_win->y2());58 con_win->screen->SetClip(con_win->x1(),con_win->y1(),con_win->x2()+1,con_win->y2()+1); 59 59 } 60 60 } -
abuse/trunk/src/dev.cpp
r515 r518 371 371 int32_t xstep=(im->Size().x<<16)/new_width, 372 372 ystep=(im->Size().y<<16)/new_height,iy,ix,sx,ix_start,iy_start; 373 screen->add_dirty(x,y,x+new_width-1,y+new_height-1); 374 375 376 short cx1,cy1,cx2,cy2; 377 screen->get_clip(cx1,cy1,cx2,cy2); 378 if (cx1>cx2 || cy1>cy2 || x>cx2 || y>cy2 || x+new_width<=cx1 || y+new_height<=cy1) return ; 373 screen->AddDirty(x, y, x + new_width, y + new_height); 374 375 int cx1, cy1, cx2, cy2; 376 screen->GetClip(cx1, cy1, cx2, cy2); 377 if (cx1>cx2 || cy1>cy2 || x>cx2-1 || y>cy2-1 || x+new_width<=cx1 || y+new_height<=cy1) return ; 379 378 if (x<cx1) 380 379 { … … 383 382 x=cx1; 384 383 } else ix_start=0; 385 if (x+new_width> =cx2)386 new_width-=x+new_width- 1-cx2;384 if (x+new_width>cx2) 385 new_width-=x+new_width-cx2; 387 386 if (y<cy1) 388 387 { … … 413 412 int32_t xstep=(im->Size().x<<16)/new_width, 414 413 ystep=(im->Size().y<<16)/new_height,iy,ix,sx,ix_start,iy_start; 415 screen->add_dirty(x,y,x+new_width-1,y+new_height-1); 416 417 418 short cx1,cy1,cx2,cy2; 419 screen->get_clip(cx1,cy1,cx2,cy2); 420 if (cx1>cx2 || cy1>cy2 || x>cx2 || y>cy2 || x+new_width<=cx1 || y+new_height<=cy1) return ; 414 screen->AddDirty(x, y, x + new_width, y + new_height); 415 416 int cx1, cy1, cx2, cy2; 417 screen->GetClip(cx1, cy1, cx2, cy2); 418 if (cx1>cx2 || cy1>cy2 || x>cx2-1 || y>cy2-1 || x+new_width<=cx1 || y+new_height<=cy1) return ; 421 419 if (x<cx1) 422 420 { … … 425 423 x=cx1; 426 424 } else ix_start=0; 427 if (x+new_width> =cx2)428 new_width-=x+new_width- 1-cx2;425 if (x+new_width>cx2) 426 new_width-=x+new_width-cx2; 429 427 if (y<cy1) 430 428 { -
abuse/trunk/src/director.cpp
r512 r518 41 41 int text_draw(int y, int x1, int y1, int x2, int y2, char const *buf, JCFont *font, uint8_t *cmap, char color) 42 42 { 43 short cx1,cy1,cx2,cy2,word_size,word_len;44 screen-> get_clip(cx1,cy1,cx2,cy2);45 screen-> in_clip(x1,y1,x2,y2);43 int cx1, cy1, cx2, cy2, word_size, word_len; 44 screen->GetClip(cx1, cy1, cx2, cy2); 45 screen->InClip(x1,y1,x2+1,y2+1); 46 46 int h=font->height()+2,w=font->width(),x=x1,dist; 47 47 y+=y1; … … 113 113 114 114 } 115 screen-> set_clip(cx1,cy1,cx2,cy2);115 screen->SetClip(cx1,cy1,cx2,cy2); 116 116 return (y<=y1); 117 117 } 118 119 120 121 122 123 124 125 118 126 119 void director::wait(void *arg) -
abuse/trunk/src/endgame.cpp
r515 r518 127 127 128 128 } 129 screen->add_dirty(x1,sy,x2,sy+mask_height-1); 130 129 screen->AddDirty(x1, sy, x2 + 1, sy + mask_height); 131 130 } 132 133 131 134 132 -
abuse/trunk/src/game.cpp
r515 r518 573 573 if(xoff / ftile_width()>x || xoff / ftile_width()+(viewx2 - viewx1)/ftile_width()+1 < x || 574 574 yoff / ftile_height()>y || yoff / ftile_height()+(viewy2 - viewy1)/ftile_height()+1 < y) return; 575 short cx1, cy1, cx2, cy2;576 screen-> get_clip(cx1, cy1, cx2, cy2);577 screen-> set_clip(viewx1, viewy1, viewx2, viewy2);575 int cx1, cy1, cx2, cy2; 576 screen->GetClip(cx1, cy1, cx2, cy2); 577 screen->SetClip(viewx1, viewy1, viewx2 + 1, viewy2 + 1); 578 578 im->put_image(screen, (x - xoff / ftile_width())*ftile_width()+viewx1 - xoff % ftile_width(), 579 579 (y - yoff / ftile_height())*ftile_height()+viewy1 - yoff % ftile_height()); 580 screen-> set_clip(cx1, cy1, cx2, cy2);580 screen->SetClip(cx1, cy1, cx2, cy2); 581 581 } 582 582 } … … 595 595 if(xo / btile_width()>x || xo / btile_width()+(viewx2 - viewx1)/btile_width()+1 < x || 596 596 yo / btile_height()>y || yo / btile_height()+(viewy2 - viewy1)/btile_height()+1 < y) return; 597 short cx1, cy1, cx2, cy2;598 screen-> get_clip(cx1, cy1, cx2, cy2);599 screen-> set_clip(viewx1, viewy1, viewx2, viewy2);597 int cx1, cy1, cx2, cy2; 598 screen->GetClip(cx1, cy1, cx2, cy2); 599 screen->SetClip(viewx1, viewy1, viewx2 + 1, viewy2 + 1); 600 600 im->put_image(screen, (x - xo / btile_width())*btile_width()+viewx1 - xo % btile_width(), 601 601 (y - yo / btile_height())*btile_height()+viewy1 - yo % btile_height(), 0); 602 screen-> set_clip(cx1, cy1, cx2, cy2);602 screen->SetClip(cx1, cy1, cx2, cy2); 603 603 } 604 604 } … … 703 703 backtile *bt; 704 704 int x1, y1, x2, y2, x, y, xo, yo, nxoff, nyoff; 705 short cx1, cy1, cx2, cy2;706 screen-> get_clip(cx1, cy1, cx2, cy2);705 int cx1, cy1, cx2, cy2; 706 screen->GetClip(cx1, cy1, cx2, cy2); 707 707 708 708 if(!current_level || state == MENU_STATE) … … 711 711 { 712 712 if(state == SCENE_STATE) 713 screen-> set_clip(v->cx1, v->cy1, v->cx2, v->cy2);713 screen->SetClip(v->cx1, v->cy1, v->cx2 + 1, v->cy2 + 1); 714 714 image *tit = cache.img(title_screen); 715 715 tit->put_image(screen, screen->Size().x/2 - tit->Size().x/2, 716 716 screen->Size().y/2 - tit->Size().y/2); 717 717 if(state == SCENE_STATE) 718 screen-> set_clip(cx1, cy1, cx2, cy2);718 screen->SetClip(cx1, cy1, cx2, cy2); 719 719 wm->flush_screen(); 720 720 } … … 729 729 730 730 if(small_render) 731 screen-> add_dirty(v->cx1, v->cy1, (v->cx2 - v->cx1 + 1)*2 + v->cx1, v->cy1+(v->cy2 - v->cy1 + 1)*2);731 screen->AddDirty(v->cx1, v->cy1, (v->cx2 - v->cx1 + 1)*2 + v->cx1 + 1, v->cy1+(v->cy2 - v->cy1 + 1)*2 + 1); 732 732 else 733 screen-> add_dirty(v->cx1, v->cy1, v->cx2, v->cy2);733 screen->AddDirty(v->cx1, v->cy1, v->cx2 + 1, v->cy2 + 1); 734 734 735 735 if(v->draw_solid != -1) // fill the screen and exit.. … … 781 781 current_vyadd = yoff - v->cy1; 782 782 783 screen-> set_clip(v->cx1, v->cy1, v->cx2, v->cy2);783 screen->SetClip(v->cx1, v->cy1, v->cx2 + 1, v->cy2 + 1); 784 784 785 785 nxoff = xoff * bg_xmul / bg_xdiv; … … 882 882 if(dev & DRAW_FG_LAYER) 883 883 { 884 short ncx1, ncy1, ncx2, ncy2;885 screen-> get_clip(ncx1, ncy1, ncx2, ncy2);884 int ncx1, ncy1, ncx2, ncy2; 885 screen->GetClip(ncx1, ncy1, ncx2, ncy2); 886 886 887 887 int scr_w = screen->Size().x; … … 895 895 for(y = y1, draw_y = yo; y <= y2; y++, draw_y += yinc) 896 896 { 897 if(!(draw_y < ncy1 ||draw_y + yinc > =ncy2))897 if(!(draw_y < ncy1 ||draw_y + yinc > ncy2)) 898 898 { 899 899 uint16_t *cl = current_level->get_fgline(y)+x1; … … 901 901 for(x = x1, draw_x = xo; x <= x2; x++, cl++, sl1 += xinc, draw_x += xinc) 902 902 { 903 if(!(draw_x < ncx1 || draw_x + xinc > =ncx2))903 if(!(draw_x < ncx1 || draw_x + xinc > ncx2)) 904 904 { 905 905 int fort_num; … … 946 946 if(fort_num != BLACK) 947 947 { 948 if(draw_y < ncy1 || draw_y + yinc > = ncy2 || draw_x < ncx1 || draw_x + xinc >=ncx2)948 if(draw_y < ncy1 || draw_y + yinc > ncy2 || draw_x < ncx1 || draw_x + xinc > ncx2) 949 949 get_fg(fort_num)->im->put_image(screen, draw_x, draw_y); 950 950 else … … 1110 1110 post_render(); 1111 1111 1112 screen-> set_clip(cx1, cy1, cx2, cy2);1112 screen->SetClip(cx1, cy1, cx2 + 1, cy2 + 1); 1113 1113 1114 1114 … … 1887 1887 case EV_REDRAW: 1888 1888 { 1889 screen-> add_dirty(ev.redraw.x1, ev.redraw.y1,1890 ev.redraw.x2 , ev.redraw.y2);1889 screen->AddDirty(ev.redraw.x1, ev.redraw.y1, 1890 ev.redraw.x2 + 1, ev.redraw.y2 + 1); 1891 1891 } break; 1892 1892 case EV_MESSAGE: … … 2147 2147 void Game::draw(int scene_mode) 2148 2148 { 2149 screen-> add_dirty(0, 0, xres, yres);2149 screen->AddDirty(0, 0, xres + 1, yres + 1); 2150 2150 2151 2151 screen->clear(); -
abuse/trunk/src/imlib/filter.cpp
r515 r518 179 179 char transparent) 180 180 { 181 short cx1, cy1, cx2, cy2, x1 = 0, y1 = 0,182 x2 = im->Size().x - 1, y2 = im->Size().y - 1;183 screen-> get_clip(cx1,cy1,cx2,cy2);181 int cx1, cy1, cx2, cy2, x1 = 0, y1 = 0, 182 x2 = im->Size().x, y2 = im->Size().y; 183 screen->GetClip(cx1, cy1, cx2, cy2); 184 184 185 185 // see if the image gets clipped off the screen 186 if(x > cx2 || y > cy2 || x + (x2 - x1) < cx1 || y + (y2 - y1) <cy1)186 if(x >= cx2 || y >= cy2 || x + (x2 - x1) <= cx1 || y + (y2 - y1) <= cy1) 187 187 return; 188 188 … … 198 198 } 199 199 200 if(x + x2 - x1 + 1 >cx2)200 if(x + x2 - x1 >= cx2) 201 201 x2 = cx2 - x + x1; 202 202 203 if(y + y2 - y1 + 1 >cy2)203 if(y + y2 - y1 >= cy2) 204 204 y2 = cy2 - y + y1; 205 205 206 if(x1 > x2 || y1 >y2)206 if(x1 >= x2 || y1 >= y2) 207 207 return; 208 208 209 int xl = x2 - x1 + 1;210 int yl = y2 - y1 + 1;211 212 screen-> add_dirty(x, y, x + xl - 1, y + yl - 1);209 int xl = x2 - x1; 210 int yl = y2 - y1; 211 212 screen->AddDirty(x, y, x + xl, y + yl); 213 213 214 214 screen->Lock(); -
abuse/trunk/src/imlib/image.cpp
r515 r518 83 83 int keep_dirties, int static_memory) 84 84 { 85 clipx1 = 0;clipy1 = 0;86 l = size.x;h = size.y;87 clipx2 = l - 1; clipy2 = h - 1;85 m_clipx1 = 0; m_clipy1 = 0; 86 m_l = size.x; m_h = size.y; 87 m_clipx2 = m_l; m_clipy2 = m_h; 88 88 keep_dirt = keep_dirties; 89 89 static_mem = static_memory; … … 134 134 135 135 if (m_special && 136 pos.x >= m_special->x1_clip() && pos.x < =m_special->x2_clip() &&137 pos.y >= m_special->y1_clip() && pos.y < =m_special->y2_clip())136 pos.x >= m_special->x1_clip() && pos.x < m_special->x2_clip() && 137 pos.y >= m_special->y1_clip() && pos.y < m_special->y2_clip()) 138 138 return; 139 139 … … 261 261 if(m_special) 262 262 { 263 if(m_special->x1_clip() < =m_special->x2_clip())264 for(i = m_special->y2_clip() ; i >= m_special->y1_clip(); i--)263 if(m_special->x1_clip() < m_special->x2_clip()) 264 for(i = m_special->y2_clip() - 1; i >= m_special->y1_clip(); i--) 265 265 memset(scan_line(i) + m_special->x1_clip(), color, 266 m_special->x2_clip() - m_special->x1_clip() + 1);266 m_special->x2_clip() - m_special->x1_clip()); 267 267 } 268 268 else 269 269 for(i = m_size.y - 1; i >= 0; i--) 270 270 memset(scan_line(i), color, m_size.x); 271 add_dirty(0, 0, m_size.x - 1, m_size.y - 1);271 AddDirty(0, 0, m_size.x, m_size.y); 272 272 Unlock(); 273 273 } … … 291 291 // check to make sure that both endpoint are on the screen 292 292 293 int 16_tcx1, cy1, cx2, cy2;293 int cx1, cy1, cx2, cy2; 294 294 295 295 // check to see if the line is completly clipped off 296 get_clip(cx1, cy1, cx2, cy2);297 if ((x1 <cx1 && x2<cx1) || (x1>cx2 && x2>cx2) ||298 (y1 <cy1 && y2<cy1) || (y1>cy2 && y2>cy2))299 return 296 GetClip(cx1, cy1, cx2, cy2); 297 if ((x1 < cx1 && x2 < cx1) || (x1 >= cx2 && x2 >= cx2) || 298 (y1 < cy1 && y2 < cy1) || (y1 >= cy2 && y2 >= cy2)) 299 return; 300 300 301 301 if (x1>x2) // make sure that x1 is to the left … … 321 321 322 322 // clip the right side 323 if (x2 >cx2)323 if (x2 >= cx2) 324 324 { 325 325 int my=(y2-y1); … … 329 329 { 330 330 b=y1-(y2-y1)*x1/mx; 331 y2=my *cx2/mx+b;332 x2 =cx2;333 } 334 else x2 =cx2;331 y2=my * (cx2 - 1) / mx + b; 332 x2 = cx2 - 1; 333 } 334 else x2 = cx2 - 1; 335 335 } 336 336 … … 342 342 343 343 // clip the bottom 344 if (y2 >cy2)344 if (y2 >= cy2) 345 345 { 346 346 int mx=(x2-x1); … … 350 350 if (mx) 351 351 { 352 b =y1-(y2-y1)*x1/mx;353 x2 =(cy2-b)*mx/my;354 y2 =cy2;355 } 356 else y2 =cy2;352 b = y1 - (y2 - y1) * x1 / mx; 353 x2 = (cy2 - 1 - b) * mx / my; 354 y2 = cy2 - 1; 355 } 356 else y2 = cy2 - 1; 357 357 } 358 358 … … 374 374 375 375 // see if it got cliped into the box, out out 376 if (x1<cx1 || x2<cx1 || x1 >cx2 || x2>cx2 || y1<cy1 || y2 <cy1 || y1>cy2 || y2>cy2)377 return 376 if (x1<cx1 || x2<cx1 || x1 >= cx2 || x2 >= cx2 || y1<cy1 || y2 <cy1 || y1 >= cy2 || y2 >= cy2) 377 return; 378 378 379 379 … … 387 387 yi=y2; yc=y1; 388 388 389 add_dirty(xc, yc, xi, yi);389 AddDirty(xc, yc, xi + 1, yi + 1); 390 390 dcx=x1; dcy=y1; 391 391 xc=(x2-x1); yc=(y2-y1); … … 465 465 return; 466 466 467 screen-> add_dirty(x, y, x + xl - 1, y + yl - 1);467 screen->AddDirty(x, y, x + xl, y + yl); 468 468 screen->Lock(); 469 469 Lock(); … … 499 499 { x1=screen->m_special->bound_x1(x1); 500 500 y1=screen->m_special->bound_y1(y1); 501 x2=screen->m_special->bound_x2(x2 );502 y2=screen->m_special->bound_y2(y2 );501 x2=screen->m_special->bound_x2(x2+1)-1; 502 y2=screen->m_special->bound_y2(y2+1)-1; 503 503 } 504 504 else … … 510 510 if (x2<0 || y2<0 || x1>=screen->Size().x || y1>=screen->Size().y) 511 511 return ; 512 screen-> add_dirty(x1, y1, x2, y2);512 screen->AddDirty(x1, y1, x2 + 1, y2 + 1); 513 513 w=m_size.x; 514 514 if (align) … … 548 548 { 549 549 int16_t xlen, ylen, j, i; 550 int16_t cx1, cy1, cx2, cy2;551 550 uint8_t *pg1, *pg2, *source, *dest; 552 551 CHECK(x1<=x2 && y1<=y2); 553 552 554 screen->get_clip(cx1, cy1, cx2, cy2); 553 int cx1, cy1, cx2, cy2; 554 screen->GetClip(cx1, cy1, cx2, cy2); 555 555 556 556 … … 565 565 566 566 // see if the image gets clipped off the screen 567 if (x>cx2 || y>cy2 || x+(x2-x1)<cx1 || y+(y2-y1)<cy1) return ; 567 if (x >= cx2 || y >= cy2 || x + (x2 - x1) < cx1 || y + (y2 - y1) < cy1) 568 return ; 568 569 569 570 … … 573 574 { y1+=(cy1-y); y=cy1; } 574 575 575 if (x +x2-x1+1>cx2)576 { x2 =cx2-x+x1; }577 578 if (y +y2-y1+1>cy2)579 { y2 =cy2-y+y1; }576 if (x + x2 - x1 + 1 >= cx2) 577 { x2 = cx2 - 1 - x + x1; } 578 579 if (y + y2 - y1 + 1 >= cy2) 580 { y2 = cy2 - 1 - y + y1; } 580 581 if (x1>x2 || y1>y2) return ; 581 582 … … 586 587 ylen=y2-y1+1; 587 588 588 screen-> add_dirty(x, y, x+xlen-1, y+ylen-1);589 screen->AddDirty(x, y, x + xlen, y + ylen); 589 590 590 591 screen->Lock(); … … 618 619 { 619 620 int16_t xl, yl, j, i; 620 int16_t cx1, cy1, cx2, cy2;621 621 uint8_t *pg1, *pg2, *source, *dest; 622 622 CHECK(x1<=x2 && y1<=y2); … … 632 632 if (screen->m_special) 633 633 { 634 screen->m_special->get_clip(cx1, cy1, cx2, cy2); 635 if (x>cx2 || y>cy2 || x+(x2-x1)<0 || y+(y2-y1)<0) return ; 634 int cx1, cy1, cx2, cy2; 635 screen->m_special->GetClip(cx1, cy1, cx2, cy2); 636 // FIXME: don't we need < cx1 instead of < 0 here? 637 if (x >= cx2 || y >= cy2 || x + (x2 - x1) < 0 || y + (y2 - y1) < 0) 638 return; 636 639 if (x<cx1) 637 640 { x1+=(cx1-x); x=cx1; } 638 641 if (y<cy1) 639 642 { y1+=(cy1-y); y=cy1; } 640 if (x +x2-x1+1>cx2)641 { x2 =cx2-x+x1; }642 if (y +y2-y1+1>cy2)643 { y2 =cy2-y+y1; }643 if (x + x2 - x1 + 1 >= cx2) 644 { x2 = cx2 - 1 - x + x1; } 645 if (y + y2 - y1 + 1 >= cy2) 646 { y2 = cy2 - 1 - y + y1; } 644 647 } 645 648 else if (x>screen->Size().x || y>screen->Size().y || x+x2<0 || y+y2<0) … … 659 662 if (y+yl>screen->Size().y) 660 663 yl=screen->Size().y-y; 661 screen-> add_dirty(x, y, x+xl-1, y+yl-1);664 screen->AddDirty(x, y, x + xl, y + yl); 662 665 screen->Lock(); 663 666 Lock(); … … 686 689 { 687 690 int16_t xl, yl, j, i, ml, mh; 688 int16_t cx1, cy1, cx2, cy2;689 691 uint8_t *pg1, *pg2, *pg3; 690 692 CHECK(x1<=x2 && y1<=y2); … … 692 694 if (screen->m_special) 693 695 { 694 screen->m_special->get_clip(cx1, cy1, cx2, cy2); 695 if (x>cx2 || y>cy2 || x+(x2-x1)<0 || y+(y2-y1)<0) return ; 696 int cx1, cy1, cx2, cy2; 697 screen->m_special->GetClip(cx1, cy1, cx2, cy2); 698 if (x >= cx2 || y >= cy2 || x+(x2-x1)<0 || y+(y2-y1)<0) return ; 696 699 if (x<cx1) 697 700 { x1+=(cx1-x); x=cx1; } 698 701 if (y<cy1) 699 702 { y1+=(cy1-y); y=cy1; } 700 if (x +x2-x1>cx2)701 { x2 =cx2+x1-x; }702 if (y +y2-y1>cy2)703 { y2 =cy2+y1-y; }703 if (x + x2 - x1 >= cx2) 704 { x2 = cx2 - 1 + x1 - x; } 705 if (y + y2 - y1 >= cy2) 706 { y2 = cy2 - 1 + y1 - y; } 704 707 } 705 708 else if (x>screen->Size().x || y>screen->Size().y || x+x1<0 || y+y1<0) … … 722 725 if (y+yl>screen->Size().y) 723 726 yl=screen->Size().y-y-1; 724 screen-> add_dirty(x, y, x+xl-1, y+yl-1);727 screen->AddDirty(x, y, x + xl, y + yl); 725 728 screen->Lock(); 726 729 mask->Lock(); … … 800 803 } 801 804 802 void image:: set_clip(int16_t x1, int16_t y1, int16_t x2, int16_t y2)805 void image::SetClip(int x1, int y1, int x2, int y2) 803 806 { 804 807 // If the image does not already have an Image descriptor, allocate one … … 809 812 // set the image descriptor what the clip 810 813 // should be it will adjust to fit within the image. 811 m_special->set_clip(x1, y1, x2, y2); 812 } 813 814 void image::get_clip (int16_t &x1, int16_t &y1, int16_t &x2, int16_t &y2) 815 { 816 if (m_special) 817 m_special->get_clip(x1, y1, x2, y2); 818 else 819 { x1=0; y1=0; x2=m_size.x-1; y2=m_size.y-1; } 820 } 821 822 void image::in_clip (int16_t x1, int16_t y1, int16_t x2, int16_t y2) 823 { 824 if (m_special) 825 { 826 if (x1<m_special->x1_clip()) 827 x1=m_special->x1_clip(); 828 if (y1<m_special->y1_clip()) 829 y1=m_special->y1_clip(); 830 if (x2>m_special->x2_clip()) 831 x2=m_special->x2_clip(); 832 if (y2>m_special->y2_clip()) 833 y2=m_special->y2_clip(); 834 } 835 set_clip(x1, y1, x2, y2); 814 m_special->SetClip(x1, y1, x2, y2); 815 } 816 817 void image::GetClip(int &x1, int &y1, int &x2, int &y2) 818 { 819 if (m_special) 820 m_special->GetClip(x1, y1, x2, y2); 821 else 822 { 823 x1 = 0; y1 = 0; x2 = m_size.x; y2 = m_size.y; 824 } 825 } 826 827 void image::InClip(int x1, int y1, int x2, int y2) 828 { 829 if (m_special) 830 { 831 x1 = Min(x1, m_special->x1_clip()); 832 y1 = Min(y1, m_special->y1_clip()); 833 x2 = Max(x2, m_special->x2_clip()); 834 y2 = Max(y2, m_special->y2_clip()); 835 } 836 837 SetClip(x1, y1, x2, y2); 836 838 } 837 839 … … 840 842 // can contain all the rectangles and making this the new dirty area 841 843 // 842 void image_descriptor::reduce_dirties() 843 { 844 dirty_rect *p, *q; 845 int16_t x1, y1, x2, y2, nn; 846 x1=6000; y1=6000; 847 x2=0; y2=0; 848 p=(dirty_rect *)dirties.first(); 849 nn=dirties.number_nodes(); 850 while (nn>0) 851 { 852 if (p->dx1<x1) x1=p->dx1; 853 if (p->dy1<y1) y1=p->dy1; 854 if (p->dx2>x2) x2=p->dx2; 855 if (p->dy2>y2) y2=p->dy2; 856 q=p; 857 p=(dirty_rect *)p->next(); 858 dirties.unlink((linked_node *)q); 859 delete q; 860 nn--; 861 } 862 dirties.add_front((linked_node *) new dirty_rect(x1, y1, x2, y2)); 844 void image_descriptor::ReduceDirties() 845 { 846 dirty_rect *p = (dirty_rect *)dirties.first(); 847 int x1 = 6000, y1 = 6000, x2 = -1, y2 = -1; 848 849 for (int i = dirties.number_nodes(); i--; ) 850 { 851 x1 = Min(x1, p->dx1); y1 = Min(y1, p->dy1); 852 x2 = Max(x1, p->dx1); y2 = Max(y1, p->dy1); 853 dirty_rect *tmp = (dirty_rect *)p->next(); 854 dirties.unlink(p); 855 delete p; 856 p = tmp; 857 } 858 dirties.add_front(new dirty_rect(x1, y1, x2, y2)); 863 859 } 864 860 865 861 void image_descriptor::delete_dirty(int x1, int y1, int x2, int y2) 866 862 { 867 int16_t i, ax1, ay1, ax2, ay2; 868 dirty_rect *p, *next; 869 if (keep_dirt) 870 { 871 if (x1<0) x1=0; 872 if (y1<0) y1=0; 873 if (x2>=(int)l) x2=l-1; 874 if (y2>=(int)h) y2=h-1; 875 if (x1>x2) return; 876 if (y1>y2) return ; 877 878 i=dirties.number_nodes(); 863 int ax1, ay1, ax2, ay2; 864 dirty_rect *p, *next; 865 866 if (!keep_dirt) 867 return; 868 869 x1 = Max(0, x1); x2 = Min(m_l, x2); 870 y1 = Max(0, y1); y2 = Min(m_h, y2); 871 872 if (x1 >= x2 || y1 >= y2) 873 return; 874 875 int i = dirties.number_nodes(); 879 876 if (!i) 880 return;881 else 882 {883 for (p=(dirty_rect *)dirties.first(); i; i--, p=(dirty_rect *)next)884 {885 next=(dirty_rect *)p->next(); 877 return; 878 879 for (p = (dirty_rect *)dirties.first(); i; i--, p = next) 880 { 881 next = (dirty_rect *)p->next(); 882 886 883 // are the two touching? 887 if (!(x2<p->dx1 || y2<p->dy1 || x1>p->dx2 || y1>p->dy2)) 884 if (x2 <= p->dx1 || y2 <= p->dy1 || x1 > p->dx2 || y1 > p->dy2) 885 continue; 886 887 // does it take a x slice off? (across) 888 if (x2 >= p->dx2 + 1 && x1 <= p->dx1) 888 889 { 889 // does it take a x slice off? (across) 890 if (x2>=p->dx2 && x1<=p->dx1) 891 { 892 if (y2>=p->dy2 && y1<=p->dy1) 890 if (y2 >= p->dy2 + 1 && y1 <= p->dy1) 893 891 { 894 dirties.unlink((linked_node *)p);895 delete p;892 dirties.unlink(p); 893 delete p; 896 894 } 897 else if (y2 >=p->dy2)898 p->dy2=y1-1;899 else if (y1 <=p->dy1)900 p->dy1=y2+1;895 else if (y2 >= p->dy2 + 1) 896 p->dy2 = y1 - 1; 897 else if (y1 <= p->dy1) 898 p->dy1 = y2; 901 899 else 902 900 { 903 dirties.add_front((linked_node *)new dirty_rect(p->dx1, p->dy1, p->dx2, y1-1));904 p->dy1=y2+1;901 dirties.add_front(new dirty_rect(p->dx1, p->dy1, p->dx2, y1-1)); 902 p->dy1 = y2; 905 903 } 906 907 908 else if (y2>=p->dy2 && y1<=p->dy1)909 910 if (x2 >=p->dx2)911 p->dx2=x1-1;904 } 905 // does it take a y slice off (down) 906 else if (y2 - 1>=p->dy2 && y1<=p->dy1) 907 { 908 if (x2 - 1>=p->dx2) 909 p->dx2=x1-1; 912 910 else if (x1<=p->dx1) 913 p->dx1=x2+1;911 p->dx1=x2; 914 912 else 915 913 { 916 dirties.add_front((linked_node *)new dirty_rect(p->dx1, p->dy1, x1-1, p->dy2));917 p->dx1=x2+1;914 dirties.add_front(new dirty_rect(p->dx1, p->dy1, x1-1, p->dy2)); 915 p->dx1=x2; 918 916 } 919 920 921 922 923 if (x2 >=p->dx2) { ax1=p->dx1; ax2=x1-1; }924 else if (x1<=p->dx1) { ax1=x2 +1; ax2=p->dx2; }925 else { ax1=p->dx1; ax2=x1 -1; }926 if (y2 >=p->dy2) { ay1=y1; ay2=p->dy2; }917 } 918 // otherwise it just takes a little chunk off 919 else 920 { 921 if (x2 - 1>=p->dx2) { ax1=p->dx1; ax2=x1; } 922 else if (x1<=p->dx1) { ax1=x2; ax2=p->dx2+1; } 923 else { ax1=p->dx1; ax2=x1; } 924 if (y2 - 1>=p->dy2) { ay1=y1; ay2=p->dy2+1; } 927 925 else if (y1<=p->dy1) { ay1=p->dy1; ay2=y2; } 928 926 else { ay1=y1; ay2=y2; } 929 dirties.add_front( (linked_node *) new dirty_rect(ax1, ay1, ax2, ay2));930 931 if (x2 >=p->dx2 || x1<=p->dx1) { ax1=p->dx1; ax2=p->dx2; }932 else { ax1=x2 +1; ax2=p->dx2; }933 934 if (y2 >=p->dy2)935 { if (ax1==p->dx1) { ay1=p->dy1; ay2=y1 -1; }936 else { ay1=y1; ay2=p->dy2 ; } }937 else if (y1<=p->dy1) { if (ax1==p->dx1) { ay1=y2 +1; ay2=p->dy2; }927 dirties.add_front(new dirty_rect(ax1, ay1, ax2-1, ay2-1)); 928 929 if (x2 - 1>=p->dx2 || x1<=p->dx1) { ax1=p->dx1; ax2=p->dx2+1; } 930 else { ax1=x2; ax2=p->dx2+1; } 931 932 if (y2 - 1>=p->dy2) 933 { if (ax1==p->dx1) { ay1=p->dy1; ay2=y1; } 934 else { ay1=y1; ay2=p->dy2+1; } } 935 else if (y1<=p->dy1) { if (ax1==p->dx1) { ay1=y2; ay2=p->dy2+1; } 938 936 else { ay1=p->dy1; ay2=y2; } } 939 else { if (ax1==p->dx1) { ay1=p->dy1; ay2=y1 -1; }937 else { if (ax1==p->dx1) { ay1=p->dy1; ay2=y1; } 940 938 else { ay1=y1; ay2=y2; } } 941 dirties.add_front( (linked_node *) new dirty_rect(ax1, ay1, ax2, ay2));942 943 if (x1>p->dx1 && x2 <p->dx2)939 dirties.add_front(new dirty_rect(ax1, ay1, ax2 - 1, ay2 - 1)); 940 941 if (x1>p->dx1 && x2 - 1<p->dx2) 944 942 { 945 if (y1>p->dy1 && y2<p->dy2) 946 { 947 dirties.add_front((linked_node *) new dirty_rect(p->dx1, p->dy1, p->dx2, y1-1)); 948 dirties.add_front((linked_node *) new dirty_rect(p->dx1, y2+1, p->dx2, p->dy2)); 949 } else if (y1<=p->dy1) 950 dirties.add_front((linked_node *) new dirty_rect(p->dx1, y2+1, p->dx2, p->dy2)); 951 else 952 dirties.add_front((linked_node *) new dirty_rect(p->dx1, p->dy1, p->dx2, y1-1)); 953 } else if (y1>p->dy1 && y2<p->dy2) 954 dirties.add_front((linked_node *) new dirty_rect(p->dx1, y2+1, p->dx2, p->dy2)); 955 dirties.unlink((linked_node *) p); 943 if (y1>p->dy1 && y2 - 1<p->dy2) 944 { 945 dirties.add_front(new dirty_rect(p->dx1, p->dy1, p->dx2, y1-1)); 946 dirties.add_front(new dirty_rect(p->dx1, y2, p->dx2, p->dy2)); 947 } 948 else if (y1<=p->dy1) 949 dirties.add_front(new dirty_rect(p->dx1, y2, p->dx2, p->dy2)); 950 else 951 dirties.add_front(new dirty_rect(p->dx1, p->dy1, p->dx2, y1-1)); 952 } 953 else if (y1>p->dy1 && y2 - 1<p->dy2) 954 dirties.add_front(new dirty_rect(p->dx1, y2, p->dx2, p->dy2)); 955 dirties.unlink(p); 956 956 delete p; 957 }958 957 } 959 } 960 } 961 } 958 } 962 959 } 963 960 964 961 // specifies that an area is a dirty 965 void image_descriptor:: add_dirty(int x1, int y1, int x2, int y2)966 { 967 int16_t i;968 dirty_rect *p;969 if (keep_dirt)970 { 971 if (x1<0) x1=0;972 if (y1<0) y1=0;973 if (x2>=(int)l) x2=l-1; 974 if ( y2>=(int)h) y2=h-1;975 if (x1>x2)return;976 if (y1>y2) return ; 977 i =dirties.number_nodes();962 void image_descriptor::AddDirty(int x1, int y1, int x2, int y2) 963 { 964 dirty_rect *p; 965 if (!keep_dirt) 966 return; 967 968 x1 = Max(0, x1); x2 = Min(m_l, x2); 969 y1 = Max(0, y1); y2 = Min(m_h, y2); 970 971 if (x1 >= x2 || y1 >= y2) 972 return; 973 974 int i = dirties.number_nodes(); 978 975 if (!i) 979 dirties.add_front((linked_node *) new dirty_rect(x1, y1, x2, y2));980 else if (i >=MAX_DIRTY)981 { 982 dirties.add_front((linked_node *) new dirty_rect(x1, y1, x2, y2));983 reduce_dirties(); // reduce to one dirty rectangle, we have to many976 dirties.add_front(new dirty_rect(x1, y1, x2 - 1, y2 - 1)); 977 else if (i >= MAX_DIRTY) 978 { 979 dirties.add_front(new dirty_rect(x1, y1, x2 - 1, y2 - 1)); 980 ReduceDirties(); // reduce to one dirty rectangle, we have to many 984 981 } 985 982 else … … 989 986 990 987 // check to see if this new rectangle completly encloses the check rectangle 991 if (x1<=p->dx1 && y1<=p->dy1 && x2>=p->dx2 && y2>=p->dy2)992 {993 dirty_rect *tmp=(dirty_rect*) p->next();994 dirties.unlink((linked_node *)p);995 delete p;996 if (!dirties.first())997 i=0;998 else p=tmp;999 }1000 else if (!(x2<p->dx1 || y2<p->dy1 || x1>p->dx2 || y1>p->dy2))1001 {988 if (x1<=p->dx1 && y1<=p->dy1 && x2>=p->dx2+1 && y2>=p->dy2+1) 989 { 990 dirty_rect *tmp=(dirty_rect*) p->next(); 991 dirties.unlink(p); 992 delete p; 993 if (!dirties.first()) 994 i=0; 995 else p=tmp; 996 } 997 else if (!(x2 - 1 <p->dx1 || y2 - 1 <p->dy1 || x1>p->dx2 || y1>p->dy2)) 998 { 1002 999 1003 1000 … … 1005 1002 /* if (x1<=p->dx1) { a+=p->dx1-x1; ax1=x1; } else ax1=p->dx1; 1006 1003 if (y1<=p->dy1) { a+=p->dy1-y1; ay1=y1; } else ay1=p->dy1; 1007 if (x2 >=p->dx2) { a+=x2-p->dx2; ax2=x2; } else ax2=p->dx2;1008 if (y2 >=p->dy2) { a+=y2-p->dy2; ay2=y2; } else ay2=p->dy2;1004 if (x2 - 1 >=p->dx2) { a+=x2 - 1 -p->dx2; ax2=x2 - 1; } else ax2=p->dx2; 1005 if (y2 - 1 >=p->dy2) { a+=y2 - 1 -p->dy2; ay2=y2 - 1; } else ay2=p->dy2; 1009 1006 1010 1007 if (a<50) … … 1016 1013 } 1017 1014 else */ 1018 {1019 if (x1<p->dx1)1020 add_dirty(x1, Max(y1, p->dy1), p->dx1-1, Min(y2, p->dy2));1021 if (x2>p->dx2)1022 add_dirty(p->dx2+1, Max(y1, p->dy1), x2, Min(y2, p->dy2));1023 if (y1<p->dy1)1024 add_dirty(x1, y1, x2, p->dy1-1);1025 if (y2>p->dy2)1026 add_dirty(x1, p->dy2+1, x2, y2);1027 return ;1028 }1029 p=(dirty_rect *)p->next();1030 } else p=(dirty_rect *)p->next();1015 { 1016 if (x1<p->dx1) 1017 AddDirty(x1, Max(y1, p->dy1), p->dx1, Min(y2, p->dy2 + 1)); 1018 if (x2>p->dx2+1) 1019 AddDirty(p->dx2+1, Max(y1, p->dy1), x2, Min(y2, p->dy2 + 1)); 1020 if (y1<p->dy1) 1021 AddDirty(x1, y1, x2, p->dy1); 1022 if (y2 - 1>p->dy2) 1023 AddDirty(x1, p->dy2+1, x2, y2); 1024 return ; 1025 } 1026 p=(dirty_rect *)p->next(); 1027 } else p=(dirty_rect *)p->next(); 1031 1028 1032 1029 } 1033 CHECK(x1<=x2 && y1<=y2); 1034 dirties.add_end((linked_node *)new dirty_rect(x1, y1, x2, y2)); 1035 } 1036 } 1030 CHECK(x1 < x2 && y1 < y2); 1031 dirties.add_end(new dirty_rect(x1, y1, x2 - 1, y2 - 1)); 1032 } 1037 1033 } 1038 1034 … … 1044 1040 { x1=m_special->bound_x1(x1); 1045 1041 y1=m_special->bound_y1(y1); 1046 x2=m_special->bound_x2(x2 );1047 y2=m_special->bound_y2(y2 );1042 x2=m_special->bound_x2(x2+1)-1; 1043 y2=m_special->bound_y2(y2+1)-1; 1048 1044 } 1049 1045 else … … 1059 1055 memset(scan_line(y)+x1, color, (x2-x1+1)); 1060 1056 Unlock(); 1061 add_dirty(x1, y1, x2, y2);1057 AddDirty(x1, y1, x2 + 1, y2 + 1); 1062 1058 } 1063 1059 … … 1069 1065 { x1=m_special->bound_x1(x1); 1070 1066 y1=m_special->bound_y1(y1); 1071 x2=m_special->bound_x2(x2 );1072 y2=m_special->bound_y2(y2 );1067 x2=m_special->bound_x2(x2+1)-1; 1068 y2=m_special->bound_y2(y2+1)-1; 1073 1069 } 1074 1070 else … … 1092 1088 Unlock(); 1093 1089 1094 add_dirty(x1, y1, x2, y2);1090 AddDirty(x1, y1, x2 + 1, y2 + 1); 1095 1091 } 1096 1092 … … 1143 1139 } 1144 1140 1145 void image_descriptor:: clear_dirties()1146 { 1147 dirty_rect *dr;1148 dr=(dirty_rect *)dirties.first();1149 while (dr)1150 {dirties.unlink(dr);1151 delete dr;1152 dr=(dirty_rect *)dirties.first();1153 }1141 void image_descriptor::ClearDirties() 1142 { 1143 dirty_rect *dr = (dirty_rect *)dirties.first(); 1144 while (dr) 1145 { 1146 dirties.unlink(dr); 1147 delete dr; 1148 dr = (dirty_rect *)dirties.first(); 1149 } 1154 1150 } 1155 1151 … … 1181 1177 free(im); 1182 1178 if (m_special) 1183 m_special-> resize(new_size.x, new_size.y);1179 m_special->Resize(new_size); 1184 1180 Unlock(); 1185 1181 } … … 1187 1183 void image::scroll(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t xd, int16_t yd) 1188 1184 { 1189 int16_t cx1, cy1, cx2, cy2;1190 1185 CHECK(x1>=0 && y1>=0 && x1<x2 && y1<y2 && x2<m_size.x && y2<m_size.y); 1191 1186 if (m_special) 1192 1187 { 1193 m_special->get_clip(cx1, cy1, cx2, cy2); 1194 x1=Max(x1, cx1); y1=Max(cy1, y1); x2=Min(x2, cx2); y2=Min(y2, cy2); 1188 int cx1, cy1, cx2, cy2; 1189 m_special->GetClip(cx1, cy1, cx2, cy2); 1190 x1=Max(x1, cx1); y1=Max(cy1, y1); x2=Min(x2, cx2 - 1); y2=Min(y2, cy2 - 1); 1195 1191 } 1196 1192 int16_t xsrc, ysrc, xdst, ydst, xtot=x2-x1-abs(xd)+1, ytot, xt; … … 1208 1204 if (yd<0) { ysrc++; ydst++; } else { ysrc--; ydst--; } 1209 1205 } 1210 add_dirty(x1, y1, x2, y2);1206 AddDirty(x1, y1, x2 + 1, y2 + 1); 1211 1207 } 1212 1208 … … 1372 1368 image *image::copy_part_dithered (int16_t x1, int16_t y1, int16_t x2, int16_t y2) 1373 1369 { 1374 int 16_tx, y, cx1, cy1, cx2, cy2, ry, rx, bo, dity, ditx;1370 int x, y, cx1, cy1, cx2, cy2, ry, rx, bo, dity, ditx; 1375 1371 image *ret; 1376 1372 uint8_t *sl1, *sl2; 1377 get_clip(cx1, cy1, cx2, cy2);1373 GetClip(cx1, cy1, cx2, cy2); 1378 1374 if (y1<cy1) y1=cy1; 1379 1375 if (x1<cx1) x1=cx1; 1380 if (y2>cy2 ) y2=cy2;1381 if (x2>cx2 ) x2=cx2;1376 if (y2>cy2 - 1) y2=cy2 - 1; 1377 if (x2>cx2 - 1) x2=cx2 - 1; 1382 1378 CHECK(x2>=x1 && y2>=y1); 1383 1379 if (x2<x1 || y2<y1) return NULL; -
abuse/trunk/src/imlib/image.h
r515 r518 63 63 { 64 64 private: 65 int 16_t l,h;66 int 16_t clipx1, clipy1, clipx2,clipy2;65 int m_l, m_h; 66 int m_clipx1, m_clipy1, m_clipx2, m_clipy2; 67 67 68 68 public: … … 74 74 75 75 image_descriptor(vec2i size, int keep_dirties = 1, int static_memory = 0); 76 int16_t bound_x1(int16_t x1) { return x1 < clipx1 ? clipx1 : x1; } 77 int16_t bound_y1(int16_t y1) { return y1 < clipy1 ? clipy1 : y1; } 78 int16_t bound_x2(int16_t x2) { return x2 > clipx2 ? clipx2 : x2; } 79 int16_t bound_y2(int16_t y2) { return y2 > clipy2 ? clipy2 : y2; } 80 int16_t x1_clip() { return clipx1; } 81 int16_t y1_clip() { return clipy1; } 82 int16_t x2_clip() { return clipx2; } 83 int16_t y2_clip() { return clipy2; } 84 void dirty_area(int16_t x1, int16_t y1, int16_t x2, int16_t y2) { ; } 85 void clean_area(int16_t x1, int16_t y1, int16_t x2, int16_t y2) { ; } 86 void clear_dirties(); 87 int16_t get_dirty_area(int16_t &x1, int16_t &y1, int16_t &x2, int16_t &y2) 88 { 89 return 0; 90 } 91 void get_clip(int16_t &x1, int16_t &y1, int16_t &x2, int16_t &y2) 92 { 93 x1 = clipx1; y1 = clipy1; x2 = clipx2; y2 = clipy2; 94 } 95 void set_clip(int16_t x1, int16_t y1, int16_t x2, int16_t y2) 96 { 97 if(x2 < x1) x2 = x1; 98 if(y2 < y1) y2 = y1; 99 if(x1 < 0) clipx1 = 0; else clipx1 = x1; 100 if(y1 < 0) clipy1 = 0; else clipy1 = y1; 101 if(x2 >= l) clipx2 = l - 1; else clipx2 = x2; 102 if(y2 >= h) clipy2 = h - 1; else clipy2 = y2; 103 } 104 void reduce_dirties(); 105 void add_dirty(int x1, int y1, int x2, int y2); 76 int bound_x1(int x1) { return x1 < m_clipx1 ? m_clipx1 : x1; } 77 int bound_y1(int y1) { return y1 < m_clipy1 ? m_clipy1 : y1; } 78 int bound_x2(int x2) { return x2 > m_clipx2 ? m_clipx2 : x2; } 79 int bound_y2(int y2) { return y2 > m_clipy2 ? m_clipy2 : y2; } 80 inline int x1_clip() { return m_clipx1; } 81 inline int y1_clip() { return m_clipy1; } 82 inline int x2_clip() { return m_clipx2; } 83 inline int y2_clip() { return m_clipy2; } 84 void ClearDirties(); 85 void GetClip(int &x1, int &y1, int &x2, int &y2) 86 { 87 x1 = m_clipx1; y1 = m_clipy1; x2 = m_clipx2; y2 = m_clipy2; 88 } 89 void SetClip(int x1, int y1, int x2, int y2) 90 { 91 if(x2 < x1 + 1) x2 = x1 + 1; 92 if(y2 < y1 + 1) y2 = y1 + 1; 93 m_clipx1 = Max(x1, 0); m_clipy1 = Max(y1, 0); 94 m_clipx2 = Min(x2, m_l); m_clipy2 = Min(y2, m_h); 95 } 96 void ReduceDirties(); 97 void AddDirty(int x1, int y1, int x2, int y2); 106 98 void delete_dirty(int x1, int y1, int x2, int y2); 107 void resize(int16_t length, int16_t height)108 { 109 l = length; h = height;110 clipx1 = 0; clipy1 = 0; clipx2 = l - 1; clipy2 = h - 1;99 void Resize(vec2i size) 100 { 101 m_l = size.x; m_h = size.y; 102 m_clipx1 = 0; m_clipy1 = 0; m_clipx2 = m_l; m_clipy2 = m_h; 111 103 } 112 104 }; … … 174 166 void burn_led(int16_t x, int16_t y, int32_t num, int16_t color, 175 167 int16_t scale = 1); 176 void set_clip(int16_t x1, int16_t y1, int16_t x2, int16_t y2);177 void get_clip(int16_t &x1,int16_t &y1,int16_t &x2,int16_t &y2);178 void in_clip(int16_t x1, int16_t y1, int16_t x2, int16_t y2);168 void SetClip(int x1, int y1, int x2, int y2); 169 void GetClip(int &x1, int &y1, int &x2, int &y2); 170 void InClip(int x1, int y1, int x2, int y2); 179 171 180 172 void dirt_off() … … 187 179 } 188 180 189 void add_dirty(int x1, int y1, int x2, int y2)190 { 191 if (m_special) m_special->add_dirty(x1, y1, x2, y2);181 void AddDirty(int x1, int y1, int x2, int y2) 182 { 183 if (m_special) m_special->AddDirty(x1, y1, x2, y2); 192 184 } 193 185 void delete_dirty(int x1, int y1, int x2, int y2) … … 195 187 if(m_special) m_special->delete_dirty(x1, y1, x2, y2); 196 188 } 197 void clear_dirties()198 { 199 if (m_special) m_special->clear_dirties();189 void ClearDirties() 190 { 191 if (m_special) m_special->ClearDirties(); 200 192 } 201 193 void dither(palette *pal); // use a b&w palette! -
abuse/trunk/src/imlib/jwindow.cpp
r513 r518 66 66 void WindowManager::hide_windows() 67 67 { 68 Jwindow *p; 69 for (p=first; p; p=p->next) 70 { 71 if (!p->is_hidden()) 72 { 73 p->hide(); 74 screen->add_dirty(p->x,p->y,p->x+p->l-1,p->y+p->h-1); 75 } 76 } 68 for (Jwindow *p = first; p; p = p->next) 69 { 70 if (!p->is_hidden()) 71 { 72 p->hide(); 73 screen->AddDirty(p->x, p->y, p->x + p->l, p->y + p->h); 74 } 75 } 77 76 } 78 77 … … 87 86 void WindowManager::hide_window(Jwindow *j) 88 87 { 89 Jwindow *k;90 if (j==first)91 first=first->next;92 else93 {94 for (k=first; k->next!=j; k=k->next)95 k->screen->add_dirty(j->x-k->x,j->y-k->y,96 j->x+j->l-1-k->x,j->y+j->h-1-k->y);97 k->screen->add_dirty(j->x-k->x,j->y-k->y,98 j->x+j->l-1-k->x,j->y+j->h-1-k->y);99 k->next=j->next;100 }101 screen->add_dirty(j->x,j->y,j->x+j->l-1,j->y+j->h-1);102 j->hide();88 if (j == first) 89 first = first->next; 90 else 91 { 92 Jwindow *k; 93 for (k = first; k->next != j; k = k->next) 94 k->screen->AddDirty(j->x - k->x, j->y - k->y, 95 j->x + j->l - k->x, j->y + j->h - k->y); 96 k->screen->AddDirty(j->x - k->x, j->y - k->y, 97 j->x + j->l - k->x, j->y + j->h - k->y); 98 k->next = j->next; 99 } 100 screen->AddDirty(j->x, j->y, j->x + j->l, j->y + j->h); 101 j->hide(); 103 102 } 104 103 105 104 void WindowManager::show_window(Jwindow *j) 106 105 { 107 if (j->is_hidden())108 {109 j->show();110 j->screen->add_dirty(0,0,j->l-1,j->h-1);111 }106 if (j->is_hidden()) 107 { 108 j->show(); 109 j->screen->AddDirty(0, 0, j->l, j->h); 110 } 112 111 } 113 112 … … 179 178 { 180 179 Jwindow *j=ev.window; 181 /* screen-> add_dirty(j->x,j->y,j->x+j->l-1,j->y+j->h-1);180 /* screen->AddDirty(j->x,j->y,j->x+j->l,j->y+j->h); 182 181 for (p=first; p!=j; p=p->next) 183 p->screen-> add_dirty(j->x-p->x,j->y-p->y,j->x+j->l-1-p->x,j->y+j->h-1-p->y); */184 j->screen-> add_dirty(0,0,j->l-1,j->h-1);182 p->screen->AddDirty(j->x-p->x,j->y-p->y,j->x+j->l-p->x,j->y+j->h-p->y); */ 183 j->screen->AddDirty(0, 0, j->l, j->h); 185 184 flush_screen(); 186 185 } … … 210 209 } 211 210 } 212 if (ev.type ==EV_REDRAW)211 if (ev.type == EV_REDRAW) 213 212 { 214 213 for (j=first; j; j=j->next) 215 j->screen-> add_dirty(ev.redraw.x1-j->x,ev.redraw.y1-j->y,216 ev.redraw.x2-j->x,ev.redraw.y2-j->y);217 screen-> add_dirty(ev.redraw.x1,ev.redraw.y1,ev.redraw.x2,ev.redraw.y2);214 j->screen->AddDirty(ev.redraw.x1 - j->x, ev.redraw.y1 - j->y, 215 ev.redraw.x2 + 1 - j->x, ev.redraw.y2 + 1 - j->y); 216 screen->AddDirty(ev.redraw.x1, ev.redraw.y1, ev.redraw.x2 + 1, ev.redraw.y2 + 1); 218 217 flush_screen(); 219 218 ev.type=EV_SPURIOUS; // we took care of this one by ourselves. … … 230 229 { 231 230 Jwindow *p; 232 screen-> add_dirty(j->x,j->y,j->x+j->l-1,j->y+j->h-1);231 screen->AddDirty(j->x, j->y, j->x + j->l, j->y + j->h); 233 232 for (p=first; p!=j; p=p->next) 234 p->screen-> add_dirty(j->x-p->x,j->y-p->y,j->x+j->l-1-p->x,j->y+j->h-1-p->y);233 p->screen->AddDirty(j->x - p->x, j->y - p->y, j->x + j->l - p->x, j->y + j->h - p->y); 235 234 j->resize(l,h); 236 235 if (!frame_suppress) … … 240 239 void WindowManager::move_window(Jwindow *j, int x, int y) 241 240 { 242 screen-> add_dirty(j->x, j->y, j->x + j->l - 1, j->y + j->h - 1);241 screen->AddDirty(j->x, j->y, j->x + j->l, j->y + j->h); 243 242 for(Jwindow *p = first; p != j; p = p->next) 244 p->screen-> add_dirty(j->x - p->x, j->y - p->y, j->x + j->l - 1 - p->x,245 j->y + j->h - 1- p->y);243 p->screen->AddDirty(j->x - p->x, j->y - p->y, 244 j->x + j->l - p->x, j->y + j->h - p->y); 246 245 j->x = x; 247 246 j->y = y; 248 j->screen-> add_dirty(0, 0, j->l - 1, j->h - 1);247 j->screen->AddDirty(0, 0, j->l, j->h); 249 248 } 250 249 … … 299 298 Jwindow * search; 300 299 for(search = first; search->next != win; search = search->next) 301 search->screen-> add_dirty(win->x - search->x,302 303 win->x + win->l - 1- search->x,304 win->y + win->h - 1- search->y);305 search->screen-> add_dirty(win->x - search->x, win->y - search->y,306 win->x + win->l - 1- search->x,307 win->y + win->h - 1- search->y);300 search->screen->AddDirty(win->x - search->x, 301 win->y - search->y, 302 win->x + win->l - search->x, 303 win->y + win->h - search->y); 304 search->screen->AddDirty(win->x - search->x, win->y - search->y, 305 win->x + win->l - search->x, 306 win->y + win->h - search->y); 308 307 search->next = win->next; 309 308 } 310 309 311 screen->add_dirty(win->x, win->y, win->x + win->l - 1, 312 win->y + win->h - 1); 310 screen->AddDirty(win->x, win->y, win->x + win->l, win->y + win->h); 313 311 } 314 312 … … 349 347 for(p = first; p; p = p->next) 350 348 if(!p->is_hidden()) 351 screen->delete_dirty(p->x, p->y, p->x + p->l - 1, p->y + p->h - 1);349 screen->delete_dirty(p->x, p->y, p->x + p->l, p->y + p->h); 352 350 update_dirty(screen); 353 351 … … 369 367 } 370 368 371 // screen->delete_dirty(p->x, p->y, p->x+p->l -1, p->y+p->h-1);369 // screen->delete_dirty(p->x, p->y, p->x+p->l, p->y+p->h); 372 370 for(q = p->next; q; q = q->next) 373 371 if(!q->is_hidden()) 374 372 p->screen->delete_dirty(q->x - p->x, q->y - p->y, 375 q->x + q->l - 1 - p->x, 376 q->y + q->h - 1 - p->y); 373 q->x + q->l - p->x, q->y + q->h - p->y); 377 374 update_dirty(p->screen, p->x, p->y); 378 375 if(has_mouse()) -
abuse/trunk/src/imlib/jwindow.h
r494 r518 123 123 int x2() { return _x2; } 124 124 int y2() { return _y2; } 125 void clip_in() { screen-> set_clip(x1(), y1(), x2(), y2()); }126 void clip_out() { screen-> set_clip(0, 0, l - 1, h - 1); }125 void clip_in() { screen->SetClip(x1(), y1(), x2() + 1, y2() + 1); } 126 void clip_out() { screen->SetClip(0, 0, l, h); } 127 127 char *read(int id) { return inm->get(id)->read(); } 128 128 void local_close(); -
abuse/trunk/src/imlib/macs.h
r494 r518 26 26 #endif 27 27 28 static inline int Min(int a, int b) { return a < b ? a : b; }29 static inline int Max(int a, int b) { return a > b ? a : b; }30 static inline float Min(float a, float b) { return a < b ? a : b; }31 static inline float Max(float a, float b) { return a > b ? a : b; }32 33 28 #endif -
abuse/trunk/src/imlib/pmenu.cpp
r512 r518 27 27 active=NULL; 28 28 29 short cx1,cy1,cx2,cy2;30 screen-> get_clip(cx1,cy1,cx2,cy2);29 int cx1, cy1, cx2, cy2; 30 screen->GetClip(cx1, cy1, cx2, cy2); 31 31 if (cx1<X) cx1=X; 32 int w = cx2 - cx1 - Jwindow::left_border() - Jwindow::right_border() + 1;32 int w = cx2 - cx1 - Jwindow::left_border() - Jwindow::right_border(); 33 33 int h = Jwindow::top_border() + Jwindow::bottom_border(); 34 34 … … 145 145 int w,h; 146 146 calc_size(w,h); 147 short cx1,cy1,cx2,cy2; 148 screen->get_clip(cx1,cy1,cx2,cy2); 149 if (w+x>cx2) 150 x=cx2-w; 151 147 int cx1, cy1, cx2, cy2; 148 screen->GetClip(cx1, cy1, cx2, cy2); 149 // FIXME: is this correct? it looks like it used to be incorrect 150 // before the GetClip refactoring... 151 if (w+x>cx2-1) 152 x=cx2-1-w; 152 153 153 154 if (win) … … 187 188 int w,h,i=0; 188 189 calc_size(w,h); 189 short cx1,cy1,cx2,cy2;190 screen-> get_clip(cx1,cy1,cx2,cy2);191 if (parent->x+w+x> cx2)192 x=cx2- w-parent->x;193 if (h+y+parent->y> cy2)194 { 195 if (parent->y+parent->h+wm->font()->height()> cy2)190 int cx1, cy1, cx2, cy2; 191 screen->GetClip(cx1, cy1, cx2, cy2); 192 if (parent->x+w+x>=cx2) 193 x=cx2-1-w-parent->x; 194 if (h+y+parent->y>=cy2) 195 { 196 if (parent->y+parent->h+wm->font()->height()>=cy2) 196 197 y=-h; 197 198 else y=y-h+wm->font()->height()+5; … … 312 313 int w,h; 313 314 calc_size(w,h); 314 short cx1,cy1,cx2,cy2;315 screen-> get_clip(cx1,cy1,cx2,cy2);315 int cx1, cy1, cx2, cy2; 316 screen->GetClip(cx1, cy1, cx2, cy2); 316 317 317 318 x=win->x; … … 374 375 pmenu_item *pmenu::inarea(int mx, int my, image *screen) 375 376 { 376 short cx1,cy1,cx2,cy2;377 screen-> get_clip(cx1,cy1,cx2,cy2);377 int cx1, cy1, cx2, cy2; 378 screen->GetClip(cx1, cy1, cx2, cy2); 378 379 mx-=bar->x; 379 380 my-=bar->y; -
abuse/trunk/src/imlib/scroller.cpp
r515 r518 55 55 void show_icon(image *screen, int x, int y, int icw, int ich, uint8_t *buf) 56 56 { 57 short cx1,cy1,cx2,cy2;58 screen-> get_clip(cx1,cy1,cx2,cy2);57 int cx1, cy1, cx2, cy2; 58 screen->GetClip(cx1, cy1, cx2, cy2); 59 59 uint8_t remap[3]; 60 60 remap[0]=wm->medium_color(); … … 65 65 for (int yc=ich; yc; yc--,y++) 66 66 { 67 if (y >=cy1 && y<=cy2)67 if (y >= cy1 && y < cy2) 68 68 { 69 69 uint8_t *sl=screen->scan_line(y)+x; 70 70 for (int xc=icw,xo=x; xc; xc--,xo++,sl++,buf++) 71 71 { 72 if (xo >=cx1 && xo<=cx2)72 if (xo >= cx1 && xo < cx2) 73 73 *sl=remap[*buf]; 74 74 } 75 75 } 76 76 } 77 screen-> add_dirty(x,y,x+icw-1,y+ich-1);77 screen->AddDirty(x, y, x + icw, y + ich); 78 78 screen->Unlock(); 79 79 } … … 491 491 if (tex) 492 492 { 493 short cx1,cy1,cx2,cy2;494 screen-> get_clip(cx1,cy1,cx2,cy2);495 screen-> set_clip(x,y,x+l-1,y+h-1);493 int cx1, cy1, cx2, cy2; 494 screen->GetClip(cx1, cy1, cx2, cy2); 495 screen->SetClip(x,y,x+l,y+h); 496 496 int tw=(l+tex->Size().x-1)/tex->Size().x; 497 497 int th=(h+tex->Size().y-1)/tex->Size().y; … … 501 501 tex->put_image(screen,dx,dy); 502 502 503 screen-> set_clip(cx1,cy1,cx2,cy2);503 screen->SetClip(cx1, cy1, cx2, cy2); 504 504 } else screen->bar(x,y,x+l-1,y+h-1,wm->black()); 505 505 -
abuse/trunk/src/imlib/supmorph.cpp
r512 r518 263 263 { 264 264 int i,px,py,ix,iy; 265 short x1,y1,x2,y2;266 screen-> get_clip(x1,y1,x2,y2);267 screen-> add_dirty(x,y,x+w-1,y+h-1);265 int x1, y1, x2, y2; 266 screen->GetClip(x1, y1, x2, y2); 267 screen->AddDirty(x, y, x + w, y + h); 268 268 stepper *ss; 269 269 memset(hole,0,w*h); … … 275 275 px=ix+x; 276 276 py=iy+y; 277 if (px>=x1 && px <=x2 && py>=y1 && py<=y2)277 if (px>=x1 && px < x2 && py>=y1 && py < y2) 278 278 { 279 279 hole[ix+iy*w]=*(screen->scan_line(py)+px)=fil->lookup_color(ss->r>>(19), … … 296 296 for (ix=1; ix<w-1; ix++,ll++,tl++,nl++) 297 297 { 298 if (x+ix>=x1 && x+ix <=x2 && y+iy>=y1 && y+iy<=y2)298 if (x+ix>=x1 && x+ix < x2 && y+iy>=y1 && y+iy < y2) 299 299 { 300 300 int t=0; -
abuse/trunk/src/imlib/timage.cpp
r515 r518 139 139 void trans_image::put_scan_line(image *screen, int x, int y, int line) // always transparent 140 140 { 141 int 16_t x1,y1,x2,y2;142 screen-> get_clip(x1,y1,x2,y2);143 if (y +line<y1 || y+line>y2 || x>x2 || x+w-1<x1) // clipped off completely?144 return; 141 int x1, y1, x2, y2; 142 screen->GetClip(x1, y1, x2, y2); 143 if (y + line < y1 || y + line >= y2 || x >= x2 || x + w - 1 < x1) 144 return; // clipped off completely? 145 145 146 146 uint8_t *datap=data; … … 197 197 } 198 198 199 if (x +ix>x2) // clipped totally on the right?199 if (x + ix >= x2) // clipped totally on the right? 200 200 { 201 201 screen->Unlock(); 202 202 return ; // we are done, return! 203 203 } 204 else if (x +ix+run_length-1>x2) // partially clipped?205 { 206 memcpy(screen_line, datap,(x+ix+run_length-1)-x2);// slam what we can207 204 else if (x + ix + run_length > x2) // partially clipped? 205 { 206 memcpy(screen_line, datap, x + ix + run_length - x2); // slam what we can 207 screen->Unlock(); 208 208 return ; // and return 'cause we are done with the line 209 209 } else … … 259 259 ysteps-=(y+ysteps-y2-1); 260 260 261 screen-> add_dirty(Max(x,x1),y,Min(x+width()-1,x2),y+h-1);261 screen->AddDirty(Max(x, x1), y, Min(x + width(), x2 + 1), y + h); 262 262 return datap; 263 263 } … … 266 266 uint8_t fill_color) 267 267 { 268 int16_t x1,y1,x2,y2;268 int x1, y1, x2, y2; 269 269 int chop_length,ysteps; 270 270 271 screen->get_clip(x1,y1,x2,y2); 272 uint8_t *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line; 271 screen->GetClip(x1, y1, x2, y2); 272 uint8_t *datap = clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps), 273 *screen_line; 273 274 if (!datap) return ; // if clip_y says nothing to draw, return 274 275 … … 277 278 screen_line=screen->scan_line(y)+x; 278 279 int sw=screen->Size().x-w; 279 x1 -=x; x2-=x;280 x1 -= x; x2 -= x; 280 281 for (; ysteps>0; ysteps--) 281 282 { … … 293 294 slam_length=*datap; // find the length of this run 294 295 datap++; 295 if (ix +slam_length<x1 || ix>x2) // see if this run is totally clipped296 if (ix + slam_length < x1 || ix >= x2) // see if this run is totally clipped 296 297 { 297 298 datap+=slam_length; … … 322 323 if (slam_length) // see if there is anything left to slam 323 324 { 324 if (ix +slam_length>x2) // see if right side needs to be chopped off325 memcpy(screen_line, datap,x2-ix+1);325 if (ix + slam_length >= x2) // see if right side needs to be chopped off 326 memcpy(screen_line, datap, x2 - ix); 326 327 else 327 328 memcpy(screen_line,datap,slam_length); … … 379 380 void trans_image::put_image(image *screen, int x, int y) 380 381 { 381 int 16_t x1,y1,x2,y2;382 int x1, y1, x2, y2; 382 383 int chop_length,ysteps; 383 384 384 screen->get_clip(x1,y1,x2,y2); 385 uint8_t *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line; 385 screen->GetClip(x1, y1, x2, y2); 386 uint8_t *datap = clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps), 387 *screen_line; 386 388 if (!datap) return ; // if clip_y says nothing to draw, return 387 389 … … 389 391 screen_line=screen->scan_line(y)+x; 390 392 int sw=screen->Size().x; 391 x1 -=x; x2-=x;393 x1 -= x; x2 -= x; 392 394 for (; ysteps>0; ysteps--) 393 395 { … … 401 403 slam_length=*datap; // find the length of this run 402 404 datap++; 403 if (ix +slam_length<x1 || ix>x2) // see if this run is totally clipped405 if (ix + slam_length < x1 || ix >= x2) // see if this run is totally clipped 404 406 { 405 407 datap+=slam_length; … … 427 429 if (slam_length) // see if there is anything left to slam 428 430 { 429 if (ix +slam_length>x2) // see if right side needs to be chopped off430 memcpy(screen_line +ix,datap,x2-ix+1);431 if (ix + slam_length >= x2) // see if right side needs to be chopped off 432 memcpy(screen_line + ix, datap, x2 - ix); 431 433 else 432 434 memcpy(screen_line+ix,datap,slam_length); … … 444 446 void trans_image::put_remaped(image *screen, int x, int y, uint8_t *remap) 445 447 { 446 int16_t x1,y1,x2,y2; 447 int chop_length,ysteps; 448 449 screen->get_clip(x1,y1,x2,y2); 450 uint8_t *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line; 448 int x1, y1, x2, y2; 449 int chop_length, ysteps; 450 451 screen->GetClip(x1, y1, x2, y2); 452 uint8_t *datap = clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps), 453 *screen_line; 451 454 if (!datap) return ; // if clip_y says nothing to draw, return 452 455 … … 454 457 screen_line=screen->scan_line(y)+x; 455 458 int sw=screen->Size().x; 456 x1 -=x; x2-=x;459 x1 -= x; x2 -= x; 457 460 for (; ysteps>0; ysteps--) 458 461 { … … 466 469 slam_length=*datap; // find the length of this run 467 470 datap++; 468 if (ix +slam_length<x1 || ix>x2) // see if this run is totally clipped471 if (ix + slam_length < x1 || ix >= x2) // see if this run is totally clipped 469 472 { 470 473 datap+=slam_length; … … 494 497 { 495 498 int counter; 496 if (ix +slam_length>x2) // see if right side needs to be chopped off497 counter =x2-ix+1;499 if (ix + slam_length >= x2) // see if right side needs to be chopped off 500 counter = x2 - ix; 498 501 else 499 counter =slam_length;502 counter = slam_length; 500 503 501 504 uint8_t *sl=screen_line+ix,*sl2=datap; … … 522 525 void trans_image::put_double_remaped(image *screen, int x, int y, uint8_t *remap, uint8_t *remap2) 523 526 { 524 int16_t x1,y1,x2,y2; 525 int chop_length,ysteps; 526 527 screen->get_clip(x1,y1,x2,y2); 528 uint8_t *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line; 527 int x1, y1, x2, y2; 528 int chop_length, ysteps; 529 530 screen->GetClip(x1, y1, x2, y2); 531 uint8_t *datap = clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps), 532 *screen_line; 529 533 if (!datap) return ; // if clip_y says nothing to draw, return 530 534 … … 532 536 screen_line=screen->scan_line(y)+x; 533 537 int sw=screen->Size().x; 534 x1 -=x; x2-=x;538 x1 -= x; x2 -= x; 535 539 for (; ysteps>0; ysteps--) 536 540 { … … 544 548 slam_length=*datap; // find the length of this run 545 549 datap++; 546 if (ix +slam_length<x1 || ix>x2) // see if this run is totally clipped550 if (ix + slam_length < x1 || ix >= x2) // see if this run is totally clipped 547 551 { 548 552 datap+=slam_length; … … 572 576 { 573 577 int counter; 574 if (ix +slam_length>x2) // see if right side needs to be chopped off575 counter =x2-ix+1;578 if (ix + slam_length >= x2) // see if right side needs to be chopped off 579 counter = x2 - ix; 576 580 else 577 counter =slam_length;581 counter = slam_length; 578 582 579 583 uint8_t *sl=screen_line+ix,*sl2=datap; … … 602 606 color_filter *f, palette *pal) 603 607 { 604 int 16_t x1,y1,x2,y2;608 int x1, y1, x2, y2; 605 609 int ix,slam_length,chop_length,ysteps; 606 610 607 screen-> get_clip(x1,y1,x2,y2);608 uint8_t *datap =clip_y(screen,x1,y1,x2,y2,x,y,ysteps),609 611 screen->GetClip(x1, y1, x2, y2); 612 uint8_t *datap = clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps), 613 *screen_line; 610 614 if (!datap) return ; 611 615 … … 627 631 slam_length=*datap; // find the length of this run 628 632 datap++; 629 if (x +ix+slam_length<x1 || x+ix>x2) // see if this run is totally clipped633 if (x + ix + slam_length < x1 || x + ix >= x2) // see if this run is totally clipped 630 634 { 631 635 datap+=slam_length; … … 653 657 if (slam_length) // see if there is anything left to slam 654 658 { 655 if (x+ix+slam_length>x2) // see if right side needs to be chopped off 656 chop_length=x2-x-ix; 657 else chop_length=slam_length; 659 if (x + ix + slam_length >= x2) // see if right side needs to be chopped off 660 chop_length = x2 - 1 - x - ix; 661 else 662 chop_length = slam_length; 658 663 screen_run=screen_line+x+ix; 659 664 … … 696 701 color_filter *f, palette *pal) 697 702 { 698 int 16_t x1,y1,x2,y2;703 int x1, y1, x2, y2; 699 704 int ix,slam_length,chop_length,ysteps; 700 705 701 screen-> get_clip(x1,y1,x2,y2);702 uint8_t *datap =clip_y(screen,x1,y1,x2,y2,x,y,ysteps),703 706 screen->GetClip(x1, y1, x2, y2); 707 uint8_t *datap = clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps), 708 *screen_line; 704 709 if (!datap) return ; 705 710 … … 721 726 slam_length=*datap; // find the length of this run 722 727 datap++; 723 if (x +ix+slam_length<x1 || x+ix>x2) // see if this run is totally clipped728 if (x + ix + slam_length < x1 || x + ix >= x2) // see if this run is totally clipped 724 729 { 725 730 datap+=slam_length; … … 747 752 if (slam_length) // see if there is anything left to slam 748 753 { 749 if (x +ix+slam_length>x2) // see if right side needs to be chopped off750 chop_length =x2-x-ix;754 if (x + ix + slam_length >= x2) // see if right side needs to be chopped off 755 chop_length = x2 - 1 - x - ix; 751 756 else chop_length=slam_length; 752 757 screen_run=screen_line+x+ix; … … 784 789 void trans_image::put_color(image *screen, int x, int y, int color) 785 790 { 786 int 16_t x1,y1,x2,y2;791 int x1, y1, x2, y2; 787 792 int ix,slam_length,chop_length,ysteps; 788 793 789 screen-> get_clip(x1,y1,x2,y2);790 uint8_t *datap =clip_y(screen,x1,y1,x2,y2,x,y,ysteps),791 794 screen->GetClip(x1, y1, x2, y2); 795 uint8_t *datap = clip_y(screen, x1, y1, x2, y2, x, y, ysteps), 796 *screen_line; 792 797 if (!datap) return ; 793 798 … … 805 810 slam_length=*datap; // find the length of this run 806 811 datap++; 807 if (x +ix+slam_length<x1 || x+ix>x2) // see if this run is totally clipped812 if (x + ix + slam_length < x1 || x + ix >= x2) // see if this run is totally clipped 808 813 { 809 814 datap+=slam_length; … … 831 836 if (slam_length) // see if there is anything left to slam 832 837 { 833 if (x +ix+slam_length>x2) // see if right side needs to be chopped off834 memset(screen_line +x+ix,color,x2-x-ix+1);838 if (x + ix + slam_length >= x2) // see if right side needs to be chopped off 839 memset(screen_line + x + ix, color, x2 - x - ix); 835 840 else 836 memset(screen_line +x+ix,color,slam_length);841 memset(screen_line + x + ix, color, slam_length); 837 842 datap+=slam_length; 838 843 ix+=slam_length; … … 851 856 852 857 { 853 int 16_t x1,y1,x2,y2;858 int x1, y1, x2, y2; 854 859 int ix,slam_length,chop_length,ysteps; 855 860 uint8_t *paddr=(uint8_t *)pal->addr(); 856 861 857 screen-> get_clip(x1,y1,x2,y2);858 uint8_t *datap=clip_y(screen, x1,y1,x2,y2,x,y,ysteps),859 *blend_line,*screen_line;862 screen->GetClip(x1, y1, x2, y2); 863 uint8_t *datap=clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps), 864 *blend_line, *screen_line; 860 865 if (!datap) return ; 861 866 CONDITION(y>=blendy && y+ysteps<blendy+blend->Size().y+1,"Blend doesn't fit on trans_image"); … … 878 883 slam_length=*datap; // find the length of this run 879 884 datap++; 880 if (x +ix+slam_length<x1 || x+ix>x2) // see if this run is totally clipped885 if (x + ix + slam_length < x1 || x + ix >= x2) // see if this run is totally clipped 881 886 { 882 887 datap+=slam_length; … … 905 910 { 906 911 907 if (x+ix+slam_length>x2) // see if right side needs to be chopped off 908 chop_length=x2-x-ix; 909 else chop_length=slam_length; 912 if (x + ix + slam_length >= x2) // see if right side needs to be chopped off 913 chop_length = x2 - 1 - x - ix; 914 else 915 chop_length = slam_length; 910 916 911 917 uint8_t *screen_run=screen_line+x+ix, … … 951 957 void trans_image::put_predator(image *screen, int x, int y) 952 958 { 953 int 16_t x1,y1,x2,y2;959 int x1, y1, x2, y2; 954 960 int chop_length,ysteps; 955 961 956 screen->get_clip(x1,y1,x2,y2); 957 uint8_t *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line; 962 screen->GetClip(x1, y1, x2, y2); 963 uint8_t *datap = clip_y(screen, x1, y1, x2 - 1, y2 - 1, x, y, ysteps), 964 *screen_line; 958 965 if (!datap) return ; // if clip_y says nothing to draw, return 959 966 960 967 // see if the last scanline is clipped off 961 if (y +ysteps==y2) ysteps-=2;962 else if (y +ysteps==y2-1) ysteps--;968 if (y + ysteps == y2 - 1) ysteps -= 2; 969 else if (y + ysteps == y2 - 2) ysteps--; 963 970 /* { 964 971 for (int x=0; x<w; ) … … 973 980 } 974 981 } 975 if (y==y2 )982 if (y==y2 - 1) 976 983 return; 977 984 else … … 982 989 screen_line=screen->scan_line(y)+x; 983 990 int sw=screen->Size().x; 984 x1 -=x; x2-=x;991 x1 -= x; x2 -= x; 985 992 for (; ysteps>0; ysteps--) 986 993 { … … 994 1001 slam_length=*datap; // find the length of this run 995 1002 datap++; 996 if (ix +slam_length<x1 || ix>x2) // see if this run is totally clipped1003 if (ix + slam_length < x1 || ix >= x2) // see if this run is totally clipped 997 1004 { 998 1005 datap+=slam_length; … … 1020 1027 if (slam_length) // see if there is anything left to slam 1021 1028 { 1022 if (ix +slam_length>x2) // see if right side needs to be chopped off1023 memcpy(screen_line +ix,screen_line+sw+sw+ix,x2-ix+1);1029 if (ix + slam_length >= x2) // see if right side needs to be chopped off 1030 memcpy(screen_line + ix, screen_line + sw + sw + ix, x2 - ix); 1024 1031 else 1025 memcpy(screen_line +ix,screen_line+sw+sw+ix,slam_length);1032 memcpy(screen_line + ix, screen_line + sw + sw + ix, slam_length); 1026 1033 datap+=slam_length; 1027 1034 ix+=slam_length; -
abuse/trunk/src/light.cpp
r515 r518 774 774 775 775 if (ambient==63) return ; 776 short cx1,cy1,cx2,cy2;777 sc-> get_clip(cx1,cy1,cx2,cy2);778 779 light_patch *first =make_patch_list(cx2-cx1+1,cy2-cy1+1,screenx,screeny);776 int cx1, cy1, cx2, cy2; 777 sc->GetClip(cx1, cy1, cx2, cy2); 778 779 light_patch *first = make_patch_list(cx2 - cx1, cy2 - cy1, screenx, screeny); 780 780 781 781 int prefix_x=(screenx&7); … … 783 783 if (prefix) 784 784 prefix=8-prefix; 785 int suffix_x =cx2-cx1-(screenx&7);786 787 int suffix=(cx2 -cx1-prefix+1)&7;788 789 int32_t remap_size=((cx2 -cx1+1-prefix-suffix)>>lx_run);785 int suffix_x = cx2 - 1 - cx1 - (screenx & 7); 786 787 int suffix=(cx2 - cx1 - prefix) & 7; 788 789 int32_t remap_size=((cx2 - cx1 - prefix - suffix)>>lx_run); 790 790 791 791 uint8_t *remap_line=(uint8_t *)malloc(remap_size); … … 798 798 uint8_t *screen_line=screen->scan_line(cy1)+cx1; 799 799 800 for (int y =cy1; y<=cy2; )800 for (int y = cy1; y < cy2; ) 801 801 { 802 802 int x,count; … … 806 806 807 807 int todoy=4-((screeny+y)&3); 808 if (y +todoy>cy2)809 todoy =cy2-y+1;808 if (y + todoy >= cy2) 809 todoy = cy2 - y; 810 810 811 811 int calcy=((y+screeny)&(~3))-cy1; … … 817 817 for (; (lp->y1>y-cy1 || lp->y2<y-cy1 || 818 818 lp->x1>suffix_x || lp->x2<suffix_x); lp=lp->next); 819 uint8_t * caddr=(uint8_t *)screen_line +cx2-cx1+1-suffix;819 uint8_t * caddr=(uint8_t *)screen_line + cx2 - cx1 - suffix; 820 820 uint8_t *r=light_lookup+(((int32_t)calc_light_value(lp,suffix_x+screenx,calcy)<<8)); 821 821 switch (todoy) … … 924 924 else min_light_level=(int)ambient+ambient_ramp; 925 925 926 short cx1,cy1,cx2,cy2;927 sc-> get_clip(cx1,cy1,cx2,cy2);926 int cx1, cy1, cx2, cy2; 927 sc->GetClip(cx1, cy1, cx2, cy2); 928 928 929 929 … … 951 951 } 952 952 953 light_patch *first =make_patch_list(cx2-cx1+1,cy2-cy1+1,screenx,screeny);953 light_patch *first = make_patch_list(cx2 - cx1, cy2 - cy1, screenx, screeny); 954 954 955 955 int scr_w=sc->Size().x; … … 960 960 if (prefix) 961 961 prefix=8-prefix; 962 int suffix_x =cx2-cx1-(screenx&7);963 964 int suffix =(cx2-cx1-prefix+1)&7;965 966 int32_t remap_size =((cx2-cx1+1-prefix-suffix)>>lx_run);962 int suffix_x = cx2 - 1 - cx1 - (screenx & 7); 963 964 int suffix = (cx2 - cx1 - prefix) & 7; 965 966 int32_t remap_size = ((cx2 - cx1 - prefix - suffix)>>lx_run); 967 967 968 968 uint8_t *remap_line=(uint8_t *)malloc(remap_size); … … 973 973 974 974 975 for (int y =cy1; y<=cy2; )975 for (int y = cy1; y < cy2; ) 976 976 { 977 977 int x,count; … … 981 981 982 982 int todoy=4-((screeny+y)&3); 983 if (y +todoy>cy2)984 todoy =cy2-y+1;983 if (y + todoy >= cy2) 984 todoy = cy2 - y; 985 985 986 986 int calcy=((y+screeny)&(~3))-cy1; … … 992 992 for (; (lp->y1>y-cy1 || lp->y2<y-cy1 || 993 993 lp->x1>suffix_x || lp->x2<suffix_x); lp=lp->next); 994 uint8_t * caddr=(uint8_t *)in_line +cx2-cx1+1-suffix;995 uint8_t * daddr=(uint8_t *)out_line+(cx2 -cx1+1-suffix)*2;994 uint8_t * caddr=(uint8_t *)in_line + cx2 - cx1 - suffix; 995 uint8_t * daddr=(uint8_t *)out_line+(cx2 - cx1 - suffix)*2; 996 996 997 997 uint8_t *r=light_lookup+(((int32_t)calc_light_value(lp,suffix_x+screenx,calcy)<<8)); -
abuse/trunk/src/menu.cpp
r515 r518 45 45 { 46 46 int x,y; 47 short cx1,cy1,cx2,cy2;48 screen-> get_clip(cx1,cy1,cx2,cy2);47 int cx1, cy1, cx2, cy2; 48 screen->GetClip(cx1, cy1, cx2, cy2); 49 49 if (x1<cx1) x1=cx1; 50 50 if (y1<cy1) y1=cy1; 51 if (x2>cx2 ) x2=cx2;52 if (y2>cy2 ) y2=cy2;51 if (x2>cx2-1) x2=cx2-1; 52 if (y2>cy2-1) y2=cy2-1; 53 53 if (x2<x1 || y2<y1) return ; 54 54 … … 68 68 } 69 69 } 70 screen-> add_dirty(x1,y1,x2,y2);70 screen->AddDirty(x1, y1, x2 + 1, y2 + 1); 71 71 screen->Unlock(); 72 72 } … … 75 75 { 76 76 int x,y; 77 short cx1,cy1,cx2,cy2;78 screen-> get_clip(cx1,cy1,cx2,cy2);77 int cx1, cy1, cx2, cy2; 78 screen->GetClip(cx1, cy1, cx2, cy2); 79 79 if (x1<cx1) x1=cx1; 80 80 if (y1<cy1) y1=cy1; 81 if (x2>cx2 ) x2=cx2;82 if (y2>cy2 ) y2=cy2;81 if (x2>cx2-1) x2=cx2-1; 82 if (y2>cy2-1) y2=cy2-1; 83 83 if (x2<x1 || y2<y1) return ; 84 84 … … 96 96 } 97 97 } 98 screen-> add_dirty(x1,y1,x2,y2);98 screen->AddDirty(x1, y1, x2 + 1, y2 + 1); 99 99 screen->Unlock(); 100 100 } … … 102 102 void dark_widget(int x1, int y1, int x2, int y2, int br, int dr, int amount) 103 103 { 104 screen-> add_dirty(x1,y1,x2,y2);104 screen->AddDirty(x1, y1, x2 + 1, y2 + 1); 105 105 screen->line(x1,y1,x1,y2,br); 106 106 screen->line(x1+1,y1,x2,y1,br); … … 152 152 153 153 154 screen-> add_dirty(mx,my,mx+mw-1,my+mh-1);154 screen->AddDirty(mx, my, mx + mw, my + mh); 155 155 156 156 if (title) … … 659 659 inm->clear_current(); 660 660 661 screen-> add_dirty(0,0,319,199);661 screen->AddDirty(0, 0, 320, 200); 662 662 663 663 event ev; -
abuse/trunk/src/newlight.cpp
r494 r518 570 570 } 571 571 572 short cx1,cy1,cx2,cy2;573 sc-> get_clip(cx1,cy1,cx2,cy2);574 // sc-> add_dirty(cx1,cy1,cx2,cy2);575 u nsigned char *mint=light_lookup+min_light_level*256;572 int cx1, cy1, cx2, cy2; 573 sc->GetClip(cx1, cy1, cx2, cy2); 574 // sc->AddDirty(cx1, cy1, cx2, cy2); 575 uint8_t *mint = light_lookup + min_light_level * 256; 576 576 screenx-=cx1; 577 577 screeny-=cy1; 578 578 579 579 580 light_patch *first =make_patch_list(cx1,cy1,cx2,cy2,screenx,screeny);580 light_patch *first = make_patch_list(cx1, cy1, cx2 - 1, cy2 - 1, screenx, screeny); 581 581 582 582 -
abuse/trunk/src/particle.cpp
r515 r518 170 170 void part_frame::draw(image *screen, int x, int y, int dir) 171 171 { 172 int 16_t cx1,cy1,cx2,cy2;173 screen-> get_clip(cx1,cy1,cx2,cy2);174 if (x +x1>cx2 || x+x2<cx1 || y+y1>cy2 || y+y2<cy1) return;172 int cx1, cy1, cx2, cy2; 173 screen->GetClip(cx1, cy1, cx2, cy2); 174 if (x + x1 >= cx2 || x + x2 < cx1 || y + y1 >= cy2 || y + y2 < cy1) return; 175 175 176 176 part *pon=data; 177 cy1 -=y;178 cy2 -=y;177 cy1 -= y; 178 cy2 -= y; 179 179 180 180 int i=t; … … 184 184 if (dir>0) 185 185 { 186 while (i && pon->y <=cy2)186 while (i && pon->y < cy2) 187 187 { 188 188 long dx=x-pon->x; 189 if (dx >=cx1 && dx<=cx2)189 if (dx >= cx1 && dx < cx2) 190 190 *(screen->scan_line(pon->y+y)+dx)=pon->color; 191 191 i--; … … 194 194 } else 195 195 { 196 while (i && pon->y <=cy2)196 while (i && pon->y < cy2) 197 197 { 198 198 long dx=pon->x+x; 199 if (dx >=cx1 && dx<=cx2)199 if (dx >= cx1 && dx < cx2) 200 200 *(screen->scan_line(pon->y+y)+dx)=pon->color; 201 201 i--; … … 208 208 void scatter_line(int x1, int y1, int x2, int y2, int c, int s) 209 209 { 210 int 16_tcx1, cy1, cx2, cy2;211 screen-> get_clip( cx1, cy1, cx2, cy2);210 int cx1, cy1, cx2, cy2; 211 screen->GetClip(cx1, cy1, cx2, cy2); 212 212 213 213 int t = abs( x2 - x1 ) > abs( y2 - y1 ) ? abs( x2 - x1 ) + 1 : abs( y2 - y1 ) + 1; … … 223 223 x = ( xo >> 16 ) + ( jrand() >> s ) - xm; 224 224 y = ( yo >> 16 ) + ( jrand() >> s ) - ym; 225 if( !( x < cx1 || y < cy1 || x > cx2 || y >cy2 ) )225 if( !( x < cx1 || y < cy1 || x >= cx2 || y >= cy2 ) ) 226 226 { 227 227 *(screen->scan_line( y ) + x ) = c; … … 237 237 void ascatter_line(int x1, int y1, int x2, int y2, int c1, int c2, int s) 238 238 { 239 int 16_tcx1, cy1, cx2, cy2;240 screen-> get_clip( cx1, cy1, cx2, cy2);239 int cx1, cy1, cx2, cy2; 240 screen->GetClip(cx1, cy1, cx2, cy2); 241 241 242 242 int t = abs( x2 - x1 ) > abs( y2 - y1 ) ? abs( x2 - x1 ) + 1 : abs( y2 - y1 ) + 1; … … 256 256 x = ( xo >> 16 ) + ( jrand() >> s ) - xm; 257 257 y = ( yo >> 16 ) + ( jrand() >> s ) - ym; 258 if( !( x <= cx1 || y <= cy1 || x >= cx2 || y >= cy2 ) ) 258 // FIXME: these clip values seemed wrong to me before the GetClip 259 // refactoring. 260 if( !( x <= cx1 || y <= cy1 || x >= cx2 - 1 || y >= cy2 - 1) ) 259 261 { 260 262 addr = screen->scan_line( y ) + x; -
abuse/trunk/src/scene.cpp
r494 r518 380 380 text_blocker *first, JCFont *font) 381 381 { 382 short cx1,cy1,cx2,cy2,word_size,word_len;383 screen-> get_clip(cx1,cy1,cx2,cy2);384 screen-> in_clip(x1,y1,x2,y2);382 int cx1, cy1, cx2, cy2, word_size, word_len; 383 screen->GetClip(cx1, cy1, cx2, cy2); 384 screen->InClip(x1,y1,x2+1,y2+1); 385 385 int h=font->height()+2,w=font->width(),x=x1,dist; 386 386 y+=y1; … … 467 467 } 468 468 469 screen-> set_clip(cx1,cy1,cx2,cy2);469 screen->SetClip(cx1, cy1, cx2, cy2); 470 470 return (y<=y1); 471 471 } … … 495 495 text_loaded=0,frame_speed=100,scroll_speed=50,pan_speed=60,abort=0,text_step=-2; 496 496 497 short cx1,cy1,cx2,cy2;497 int cx1, cy1, cx2, cy2; 498 498 499 499 the_game->draw(1); 500 500 501 screen-> get_clip(cx1,cy1,cx2,cy2);502 screen-> set_clip(the_game->viewx1,the_game->viewy1,503 the_game->viewx2,the_game->viewy2);501 screen->GetClip(cx1, cy1, cx2, cy2); 502 screen->SetClip(the_game->viewx1, the_game->viewy1, 503 the_game->viewx2 + 1, the_game->viewy2 + 1); 504 504 505 505 … … 709 709 710 710 free(strng); 711 screen-> set_clip(cx1,cy1,cx2,cy2);711 screen->SetClip(cx1, cy1, cx2, cy2); 712 712 713 713 the_game->draw(0); 714 714 } 715 715 716 717 -
abuse/trunk/src/transp.cpp
r512 r518 17 17 void transp_put(image *im, image *screen, uint8_t *table, int x, int y) 18 18 { 19 short cx1,cy1,cx2,cy2;20 screen-> get_clip(cx1,cy1,cx2,cy2);19 int cx1, cy1, cx2, cy2; 20 screen->GetClip(cx1, cy1, cx2, cy2); 21 21 int xs=0,ys=0,xl=im->Size().x,yl=im->Size().y; 22 22 if (x<cx1) … … 34 34 y+=chop; 35 35 } 36 if (x +xl>cx2)37 xl =cx2-x;38 if (y +yl>cy2)39 yl =cy2-y;36 if (x + xl >= cx2) 37 xl = cx2 - 1 - x; 38 if (y + yl >= cy2) 39 yl = cy2 - 1 - y; 40 40 41 41 if (xl<0 || yl<0) return ; 42 screen-> add_dirty(x,y,x+xl-1,y+yl-1);42 screen->AddDirty(x, y, x + xl, y + yl); 43 43 44 44 int ye=ys+yl; … … 65 65 void transp_put(image *im, image *screen, uint8_t *table, int x, int y) 66 66 { 67 short cx1,cy1,cx2,cy2;68 screen-> get_clip(cx1,cy1,cx2,cy2);67 int cx1, cy1, cx2, cy2; 68 screen->GetClip(cx1, cy1, cx2, cy2); 69 69 int xs=0,ys=0,xl=im->width(),yl=im->height(); 70 70 if (x<cx1) … … 82 82 y+=chop; 83 83 } 84 if (x +xl>cx2)85 xl =cx2-x;86 if (y +yl>cy2)87 yl =cy2-y;84 if (x + xl >= cx2) 85 xl = cx2 - 1 - x; 86 if (y + yl >= cy2) 87 yl = cy2 - 1 - y; 88 88 89 89 if (xl<0 || yl<0) return ; 90 screen-> add_dirty(x,y,x+xl-1,y+yl-1);90 screen->AddDirty(x, y, x + xl - 1, y + yl); 91 91 92 92 int ye=ys+yl;
Note: See TracChangeset
for help on using the changeset viewer.