$NetBSD$ --- mgldraw.C.orig Tue Nov 3 00:25:14 1998 +++ mgldraw.C Mon Jul 31 17:02:32 2000 @@ -13,14 +13,58 @@ #define SKY_SIZE (1<w, pixmap->h, NULL, MGL2_DE_KIND, 0); + + /* + 4COLOR あたりの draw_engine だと BLT_MASKING 時のマスク色の判別に失敗す + る(?)ので、マスク色として mask_color (COLOR_DARKGRAY) を使うようにす + る。こちらならそういう draw_engine でも確実に mask できる(と思う)。 + */ + push_screen(s); + set_color(mask_color); + clear_screen(); + pop_screen(); + + ptr = pixmap->data; + for(i = 0; i < pixmap->h; i++) { + for(j = 0; j < pixmap->w; j++) { + pixel = (*ptr++ & 0xff) << 8; + pixel |= (*ptr++ & 0xff); + if(pixel == xkp_mask_color) + pixel = mask_color; + + /* + ドローエンジンごとの色変換でややこしい事になるから、 + put_pixstream() は使わない。put_pixel() にお願いする。 + */ + mgl2_put_pixel(s, j, i, pixel); + } + } + return s; +} + void draw_chip(int cx, int cy, int sx, int sy, int x, int y) { int x0, y0, x1, y1, i, j, a1, a2, b; + int buf1[100], buf2[100], buf3[100]; x0 = (x - current_x + SCREEN_SIZEX) % SCREEN_SIZEX; y0 = (y - current_y + SCREEN_SIZEY) % SCREEN_SIZEY; @@ -29,22 +73,13 @@ x1 = ((x0+64)/4-16)*4; b = (x0+64) % 4; y1 = y0; - a1 = y1 * scroll->wbytes + x1/4; - a2 = cy * chips[b]->wbytes + cx/16*5; - for (i = 0; i < sy; i++) { - for (j = 0; j < 5; j++) { - scroll->bitmap[a1+j] = - (scroll->bitmap[a1+j] & chips_mask[b]->bitmap[a2+j]) - | chips[b]->bitmap[a2+j]; - } - a1 += scroll->wbytes; - a2 += chips[b]->wbytes; - } + + bitblt(scroll, x1, y1, chips[b], cx/16*20, cy, 20, sy, BLT_MASKING + mask_color); } } void draw_chip_r(int cx, int cy, int sx, int sy, int x, int y) { - bitblt(NULL, x, y, &chip, cx, cy, sx, sy, 0); + bitblt(NULL, x, y, chip_dt, cx, cy, sx, sy, BLT_MASKING + COLOR_BLACK); } void clear_main() { @@ -66,29 +101,25 @@ void init_screens() { int x, y, c, i, j; + chip_dt = create_chip_screen(&chip); for (i=0; i<4; i++) { - chips[i] = create_memscreen(320, 128, NULL); - chips_mask[i] = create_memscreen(320, 128, NULL); - push_screen(chips[i]); clear_screen(); pop_screen(); - push_screen(chips_mask[i]); - set_color(COLOR_BLACK); - fill_rect(0, 0, 320, 128); - pop_screen(); + chips[i] = create_memscreen(320, 128, NULL, MGL2_DE_KIND, 0); + push_screen(chips[i]); set_color(mask_color); clear_screen(); pop_screen(); set_color(COLOR_WHITE); for(x=0; x < 256; x += 16) { - bitblt(chips[i], x*5/4+i, 0, &chip, x, 0, 16, 128, 0); - bitblt(chips_mask[i], x*5/4+i, 0, &chip_mask, x, 0, 16, 128, 0); + bitblt(chips[i], x*5/4+i, 0, chip_dt, x, 0, 16, 128, 0); } } scroll = create_memscreen(WSIZE + 2*SCROLL_MARGIN, WSIZE + 2*SCROLL_MARGIN, - NULL); - bg = create_memscreen(BG_SIZE, BG_SIZE, NULL); - push_screen(bg); clear_screen(); pop_screen(); + NULL, MGL2_DE_KIND, 0); + bg = create_memscreen(BG_SIZE, BG_SIZE, NULL, MGL2_DE_KIND, 0); + push_screen(bg); set_color(COLOR_WHITE); clear_screen(); pop_screen(); for(i=0; i<4; i++) { - sky[i] = create_memscreen(SKY_SIZE*2+4, SKY_SIZE*2+4, NULL); + sky[i] = create_memscreen(SKY_SIZE*2+4, SKY_SIZE*2+4, NULL, MGL2_DE_KIND, 0); push_screen(sky[i]); + set_color(COLOR_BLACK); clear_screen(); pop_screen(); } @@ -99,6 +130,7 @@ y = rand_num.get(SKY_SIZE_LOG2); for(i=0; i<4; i++) { push_screen(sky[i]); + set_color(COLOR_WHITE); fill_rect((x+4-i)%256, y, 2, 2); pop_screen(); } @@ -119,7 +151,7 @@ } void draw_string_w(win *w, int x, int y, char* s) { - draw_string(w->x + x, w->y + y, s); + draw_string(w->x + x, w->y + y, s, 0); } void draw_pixel_w(win *w, int x, int y) {