static void _win_set_rect(Raster *wndo, Pixel color, Coor x, Coor y, Ucoor width, Ucoor height) /* set a rectangle to a color */ { Wndo *w = (Wndo *)wndo; SHORT xmax, ymax; SHORT nextx, nexty; LONG firstx; LONG dheight; SHORT osy; UBYTE *ydots; int rastid; Raster *rast; assert(x >= 0 && y >= 0); xmax = x + width; ymax = y + height; firstx = x; for(;;) { osy = y + w->behind.y; if((nexty = w->vchanges[y]) > ymax) dheight = ymax - y; else dheight = nexty - y; ydots = w->ydots[x]; rastid = ydots[y]; for(;;) { nextx = NEXTX(ydots); if(nextx >= xmax) { rast = w->rasts[rastid]; SET_RECT(rast,color,x + w->behind.x - rast->x, osy - rast->y,xmax - x,dheight); if(nexty >= ymax) return; break; /* break for nextx loop */ } ydots = w->ydots[nextx]; /* get next ydots for nextx and rastid */ if(rastid == ydots[y]) /* if same continue and check next one */ continue; rast = w->rasts[rastid]; rastid = ydots[y]; SET_RECT(rast,color,x + w->behind.x - rast->x, osy - rast->y,nextx - x,dheight); x = nextx; } x = firstx; y = nexty; } }
static void pj__cbox_set_rect(Raster *clipbox, Pixel color, Coor x, Coor y, Ucoor width,Ucoor height) { Clipbox *cb = (Clipbox *)clipbox; SET_RECT(cb->root,color,x+cb->x,y+cb->y,width,height); }
void set_pointerpos(CARD16 x, CARD16 y) { SET_RECT(&s_pos_rect, x, y, 0, 0); s_curs_x = x; s_curs_y = y; if (!s_has_pos) s_has_pos = 1; rf_host_pointerpos(); }
static void _wr1os_set_rect(Wndo *w,Pixel color,Coor x,Coor y, Ucoor width,Ucoor height) { Raster *r = w->rasts[w->onerast]; SET_RECT(r,color, x + w->behind.x - r->x,y + w->behind.y - r->y, width,height); }
void WidgetSkin::rebuildRects() { #ifdef MOBILEAUTHOR int temp; if(startX>endX) { temp = startX; startX = endX; endX = temp; } if(startY>endY) { temp = startY; startY = endY; endY = temp; } if(startX<0) startX = 0; if(startY<0) startY = 0; if(endX<0) endX = 0; if(endY<0) endY = 0; if(startX>imageWidth) startX = imageWidth; if(endX>imageWidth) endX = imageWidth; if(startY>imageHeight) startY = imageHeight; if(endY>imageHeight) endY = imageHeight; #else if(startX>endX) maPanic(0, "WidgetSkin::rebuildRects startX>endX"); if(startY>endY) maPanic(0, "WidgetSkin::rebuildRects startY>endY"); if(startX<0) maPanic(0, "WidgetSkin::rebuildRects startX<0"); if(startY<0) maPanic(0, "WidgetSkin::rebuildRects startY<0"); if(endX<0) maPanic(0, "WidgetSkin::rebuildRects endX<0"); if(endY<0) maPanic(0, "WidgetSkin::rebuildRects endY<0"); if(startX>imageWidth) maPanic(0, "WidgetSkin::rebuildRects startX>imageWidth"); if(endX>imageWidth) maPanic(0, "WidgetSkin::rebuildRects endX>imageWidth"); if(startY>imageHeight) maPanic(0, "WidgetSkin::rebuildRects startY>imageHeight"); if(endY>imageHeight) maPanic(0, "WidgetSkin::rebuildRects endY>imageHeight"); #endif SET_RECT(topLeft, 0, 0, startX, startY); SET_RECT(top, startX, 0, endX, startY); SET_RECT(topRight, endX, 0, imageWidth, startY); SET_RECT(left, 0, startY, startX, endY); SET_RECT(center, startX, startY, endX, endY); SET_RECT(right, endX, startY, imageWidth, endY); SET_RECT(bottomLeft, 0, endY, startX, imageHeight); SET_RECT(bottom, startX, endY, endX, imageHeight); SET_RECT(bottomRight, endX, endY, imageWidth, imageHeight); }
void pj__set_rect(Raster *r, Pixel col, Coor x, Coor y, Ucoor w, Ucoor h) { SET_RECT(r, col, x, y, w, h); }
static void game_tick(int paint) { int i, j, k; int yoff, xoff; int bx, by; SDL_Rect rect; SDL_Rect rect2; xoff = 30, yoff = 40; p.angle += p.right * 90 * time_step; if(p.angle < -85) p.angle = -85; else if(p.angle > 85) p.angle = 85; if(level == 255) { k = 0; for(i = 0; i < field_height; ++i) { for(j = 0; j < WIDTH(i); ++j) { if(p.field[i][j]) ++k; } } for(i = 0; i < sizeof(p.mbubbles) / sizeof(p.mbubbles[0]); ++i) { if(p.mbubbles[i].color && !p.mbubbles[i].falling) ++k; } k += p.evil_bubble_count; if(k < 20) { for(i = 0; i < 5; ++i) p.evil_bubbles[p.evil_bubble_count++] = (rand() % 8) + 1; } } for(k = 0; k < sizeof(p.mbubbles) / sizeof(p.mbubbles[0]); ++k) { struct moving_bubble* b = &p.mbubbles[k]; if(!b->color) continue; if(b->y > 480) b->color = 0; if(!b->falling) { b->x += b->velx * time_step; b->y += b->vely * time_step; if(level < sizeof(levels) / sizeof(levels[0])) { if(levels[level].mode == GM_GRAVITY) b->vely += 1; else if(levels[level].mode == GM_INV_GRAVITY) b->vely -= 3; } if(b->x < 0) { b->x = -b->x; b->velx = -b->velx; if(sound_enable) sounds[2].pos = 0; } else if(b->x > max_x) { b->x = 2 * max_x - b->x; b->velx = -b->velx; if(sound_enable) sounds[2].pos = 0; } for(i = -1; i < field_height; ++i) { for(j = 0; j < WIDTH(i); ++j) { float posx, posy; float dirx, diry; if(i != -1 && !p.field[i][j]) continue; posx = j * 32.0f + ((i & 1) ? 32.0f : 16.0f); posy = i * 28.0f + 16.0f; dirx = posx - (b->x + 16.0f); diry = posy - (b->y + 16.0f); float minrage = 784.0f; if(level < sizeof(levels) / sizeof(levels[0]) && levels[level].mode == GM_GRAVITY) minrage = 32 * 32; if(dirx * dirx + diry * diry < minrage) { if(fabs(dirx) > fabs(diry)) { by = i; if(dirx > 0) bx = j - 1; else bx = j + 1; } else // fabs(dirx) <= fabs(diry) { if(diry > 0) by = i - 1; else by = i + 1; if(by & 1) { if(dirx > 0) bx = j - 1; else bx = j; } else { if(dirx > 0) bx = j; else bx = j + 1; } } if(by > 11) { int a, b; for(a = 0; a < field_height; ++a) for(b = 0; b < WIDTH(a); ++b) remove_bubble(&p, b, a, 0); state = GS_PINK; for(a = 0; a < sizeof(p.mbubbles) / sizeof(p.mbubbles[0]); ++a) p.mbubbles[a].falling = 1; } else { if(stick(&p, bx, by, b->color)) { int a; if(level != 255) state = GS_SHINE_GET; for(a = 0; a < sizeof(p.mbubbles) / sizeof(p.mbubbles[0]); ++a) p.mbubbles[a].falling = 1; } b->color = 0; } goto collide; } } } collide:; } else { b->vely += 1500.0f * time_step; b->x += b->velx * time_step; b->y += b->vely * time_step; } } if(paint) { int draw_anyway = 0; if(p.bubble > 7 || p.next_bubble > 7) draw_anyway = 1; if(p.dirty_minx < p.dirty_maxx) { SET_RECT(rect, xoff + p.dirty_minx, yoff + p.dirty_miny, p.dirty_maxx - p.dirty_minx, p.dirty_maxy - p.dirty_miny); SDL_BlitSurface(spbg, &rect, screen, &rect); } for(i = 0; i < sizeof(p.mbubbles) / sizeof(p.mbubbles[0]); ++i) { if(p.mbubbles[i].lastpaintx == INT_MIN) continue; SET_RECT(rect, p.mbubbles[i].lastpaintx + xoff, p.mbubbles[i].lastpainty + yoff, 32, 32); SDL_BlitSurface(spbg, &rect, screen, &rect); mark_dirty(&p, p.mbubbles[i].lastpaintx, p.mbubbles[i].lastpainty, 32, 32); p.mbubbles[i].lastpaintx = INT_MIN; } if(p.dirty_minx < p.dirty_maxx || (level < sizeof(levels) / sizeof(levels[0]) && levels[level].has_joker)) { for(i = 0; i < 10; ++i) { for(j = 0; j < WIDTH(i); ++j) { if(!p.field[i][j]) continue; rect.x = xoff + j * 32 + ((i & 1) ? 16 : 0); rect.y = yoff + i * 28; rect.w = 32; rect.h = 32; int color = p.field[i][j] - 1; if(color < 8) cond_blit(&p, bubbles[color], 0, screen, &rect); else { mark_dirty(&p, rect.x - xoff, rect.y - yoff, rect.w, rect.h); cond_blit(&p, bubbles[(now / 100) % 8], 0, screen, &rect); } } } } if(p.last_angle != p.angle || ( 78 <= p.dirty_maxx && 178 >= p.dirty_minx && 316 <= p.dirty_maxy && 432 >= p.dirty_miny)) { mark_dirty(&p, 78, 316, 100, 100); p.last_angle = p.angle; } if(p.dirty_minx < p.dirty_maxx || draw_anyway) { rect.x = xoff + 78; rect.y = yoff + 316; rect.w = 100; rect.h = 100; if(draw_anyway) mark_dirty(&p, rect.x - xoff, rect.y - yoff, 100, 100); cond_blit(&p, spbg, &rect, screen, &rect); for(i = 10; i < field_height; ++i) { for(j = 0; j < WIDTH(i); ++j) { if(!p.field[i][j]) continue; rect2.x = xoff + j * 32 + ((i & 1) ? 16 : 0); rect2.y = yoff + i * 28; rect2.w = 32; rect2.h = 32; int color = p.field[i][j] - 1; if(color < 8) cond_blit(&p, bubbles[color], 0, screen, &rect2); else cond_blit(&p, bubbles[(now / 100) % 8], 0, screen, &rect2); } } if((78 <= p.dirty_maxx && 178 >= p.dirty_minx && 316 <= p.dirty_maxy && 432 >= p.dirty_miny) || draw_anyway) { rect2.x = xoff + 112; rect2.y = yoff + 350; rect2.w = 32; rect2.h = 32; if(p.bubble < 8) SDL_BlitSurface(bubbles[p.bubble], 0, screen, &rect2); else SDL_BlitSurface(bubbles[(now / 100) % 8], 0, screen, &rect2); SDL_BlitSurface(base[(int) ((p.angle + 90.0f) * 128 / 180.0f)], 0, screen, &rect); rect2.x = xoff + 112; rect2.y = yoff + 400; if(p.next_bubble < 8) SDL_BlitSurface(bubbles[p.next_bubble], 0, screen, &rect2); else SDL_BlitSurface(bubbles[(now / 100) % 8], 0, screen, &rect2); } } p.dirty_minx = max_field_width * 32; p.dirty_miny = 440; p.dirty_maxx = 0; p.dirty_maxy = 0; for(i = 0; i < sizeof(p.mbubbles) / sizeof(p.mbubbles[0]); ++i) { if(!p.mbubbles[i].color) continue; SET_RECT(rect, (int) p.mbubbles[i].x + xoff, (int) p.mbubbles[i].y + yoff, 32, 32); int color = p.mbubbles[i].color - 1; if(color < 8) SDL_BlitSurface(bubbles[color], 0, screen, &rect); else { mark_dirty(&p, rect.x - xoff, rect.y - yoff, rect.w, rect.h); SDL_BlitSurface(bubbles[(now / 100) % 8], 0, screen, &rect); } p.mbubbles[i].lastpaintx = rect.x - xoff; p.mbubbles[i].lastpainty = rect.y - yoff; } if(level < sizeof(levels) / sizeof(levels[0]) && levels[level].mode == GM_TIME_ATTACK) { wchar_t buf[256]; int remaining = levels[level].time - (now - first_tick) / 1000 + bonus; if(remaining <= 0) { if(levels[level].shoot_bonus) { bonus += levels[level].shoot_bonus; shoot(&p, random_bubble(&p), -1); remaining = bonus; } else { state = GS_PINK; remaining = 0; } } #ifndef WIN32 swprintf(buf, sizeof(buf), L"%u", remaining); #else swprintf(buf, L"%u", remaining); #endif SET_RECT(rect, 355, 104, 256, 128); SDL_BlitSurface(spbg, &rect, screen, &rect); print_string(0, 483, 144, L"Time remaining", 1); print_string(0, 483, 184, buf, 1); } else if(level < sizeof(levels) / sizeof(levels[0]) && levels[level].mode == GM_AVALANCHE) { if(now - last_avalanche > levels[level].time * 1000) { p.evil_bubbles[p.evil_bubble_count++] = random_bubble(&p) + 1; last_avalanche = now; } } { wchar_t buf[256]; SET_RECT(rect, 355, 232, 256, 80); SDL_BlitSurface(spbg, &rect, screen, &rect); if(level != 255) { #ifndef WIN32 swprintf(buf, sizeof(buf), L"Level %u", level + 1); #else swprintf(buf, L"Level %u", level + 1); #endif print_string(0, 483, 264, buf, 1); } else { print_string(0, 483, 264, L"Infinity", 1); } } } }
static void pj__cbox_set_rect(Clipbox *cb,Pixel color,Coor x,Coor y, Ucoor width,Ucoor height) { SET_RECT(cb->root,color,x+cb->x,y+cb->y,width,height); }
static void grc_set_rast(Raster *v, Pixel color) /* Set entire raster to a solid color. */ { SET_RECT(v,color,0,0,v->width,v->height); }