void display_attempting_to_join_message(void) { if (LbScreenLock() == Lb_SUCCESS) { draw_text_box(get_string(GUIStr_NetAttemptingToJoin)); LbScreenUnlock(); } LbScreenRender(); }
long modem_connect_callback(void) { if (is_key_pressed(KC_ESCAPE, KMod_DONTCARE)) { clear_key_pressed(KC_ESCAPE); return -7; } if (LbScreenLock() == Lb_SUCCESS) { draw_text_box(get_string(GUIStr_NetConnectnModem)); LbScreenUnlock(); } LbScreenRender(); return 0; }
TbBool movie_record_frame(void) { short lock_mem; short result; lock_mem = LbScreenIsLocked(); if (!lock_mem) { if (LbScreenLock() != Lb_SUCCESS) return false; } LbPaletteGet(cap_palette); result=anim_record_frame(lbDisplay.WScreen, cap_palette); if (!lock_mem) LbScreenUnlock(); return result; }
void LbI_PointerHandler::OnBeginSwap(void) { LbSemaLock semlock(&sema_rel,0); if (!semlock.Lock(true)) return; if ( lbPointerAdvancedDraw ) { Backup(false); Draw(false); } else if (LbScreenLock() == Lb_SUCCESS) { PointerDraw(position->x - spr_offset->x, position->y - spr_offset->y, sprite, lbDisplay.WScreen, lbDisplay.GraphicsScreenWidth); LbScreenUnlock(); } }
void draw_out_of_sync_box(long a1, long a2, long box_width) { long min_width,max_width; long ornate_width,ornate_height; long x,y; long text_x,text_y,text_h; min_width = 2*a1; max_width = 2*a2; if (min_width > max_width) { min_width = max_width; } if (min_width < 0) { min_width = 0; } int units_per_px; units_per_px = units_per_pixel; if (LbScreenLock() == Lb_SUCCESS) { ornate_width = 200*units_per_px/16; ornate_height = 100*units_per_px/16; x = box_width + (MyScreenWidth-box_width-ornate_width) / 2; y = (MyScreenHeight-ornate_height) / 2; draw_ornate_slab64k(x, y, units_per_px, ornate_width, ornate_height); LbTextSetFont(winfont); lbDisplay.DrawFlags = Lb_TEXT_HALIGN_CENTER; LbTextSetWindow(x, y, ornate_width, ornate_height); int tx_units_per_px; tx_units_per_px = (22 * units_per_px) / LbTextLineHeight(); text_h = LbTextLineHeight()*tx_units_per_px/16; text_x = x + 100*units_per_px/16 - max_width; text_y = y + 58*units_per_px/16; LbTextDrawResized(0, 50*units_per_px/16 - text_h, tx_units_per_px, get_string(GUIStr_NetResyncing)); LbDrawBox(text_x, text_y, 2*max_width, 16*units_per_px/16, 0); LbDrawBox(text_x, text_y, 2*min_width, 16*units_per_px/16, 133); LbScreenUnlock(); LbScreenRender(); } }
long prepare_hsi_screenshot(unsigned char *buf,unsigned char *palette) { long pos,i; int w,h; short lock_mem; pos=0; w=MyScreenWidth/pixel_size; h=MyScreenHeight/pixel_size; write_int8_buf(buf+pos,'m'); pos++; write_int8_buf(buf+pos,'h'); pos++; write_int8_buf(buf+pos,'w'); pos++; write_int8_buf(buf+pos,'a'); pos++; write_int8_buf(buf+pos,'n'); pos++; write_int8_buf(buf+pos,'h'); pos++; // pos=6 write_int16_be_buf(buf+pos, 4); pos+=2; write_int16_be_buf(buf+pos, w); pos+=2; write_int16_be_buf(buf+pos, h); pos+=2; write_int16_be_buf(buf+pos, 256); pos+=2; // pos=14 write_int16_be_buf(buf+pos, 256); pos+=2; write_int16_be_buf(buf+pos, 256); pos+=2; write_int16_be_buf(buf+pos, 256); pos+=2; // pos=20 for (i=0; i<6; i++) { write_int16_be_buf(buf+pos, 0); pos+=2; } for (i=0; i<768; i+=3) { write_int8_buf(buf+pos,4*palette[i+0]); pos++; write_int8_buf(buf+pos,4*palette[i+1]); pos++; write_int8_buf(buf+pos,4*palette[i+2]); pos++; } lock_mem = LbScreenIsLocked(); if (!lock_mem) { if (LbScreenLock() != Lb_SUCCESS) { ERRORLOG("Can't lock canvas"); LbMemoryFree(buf); return 0; } } for (i=0; i<h; i++) { memcpy(buf+pos, lbDisplay.WScreen + lbDisplay.GraphicsScreenWidth*i, w); pos += w; } if (!lock_mem) LbScreenUnlock(); return pos; }
long prepare_bmp_screenshot(unsigned char *buf,unsigned char *palette) { long pos,i,j; int width,height; short lock_mem; long data_len,pal_len; pos=0; width=MyScreenWidth/pixel_size; height=MyScreenHeight/pixel_size; write_int8_buf(buf+pos,'B'); pos++; write_int8_buf(buf+pos,'M'); pos++; int padding_size=4-(width&3); data_len = (width+padding_size)*height; pal_len = 256*4; write_int32_le_buf(buf+pos, data_len+pal_len+0x36); pos+=4; write_int32_le_buf(buf+pos, 0); pos+=4; write_int32_le_buf(buf+pos, pal_len+0x36); pos+=4; write_int32_le_buf(buf+pos, 40); pos+=4; write_int32_le_buf(buf+pos, width); pos+=4; write_int32_le_buf(buf+pos, height); pos+=4; write_int16_le_buf(buf+pos, 1); pos+=2; write_int16_le_buf(buf+pos, 8); pos+=2; write_int32_le_buf(buf+pos, 0); pos+=4; write_int32_le_buf(buf+pos, 0); pos+=4; write_int32_le_buf(buf+pos, 0); pos+=4; write_int32_le_buf(buf+pos, 0); pos+=4; write_int32_le_buf(buf+pos, 0); pos+=4; write_int32_le_buf(buf+pos, 0); pos+=4; for (i=0; i<768; i+=3) { unsigned int cval; cval=4*(unsigned int)palette[i+2]; if (cval>255) cval=255; write_int8_buf(buf+pos,cval); pos++; cval=4*(unsigned int)palette[i+1]; if (cval>255) cval=255; write_int8_buf(buf+pos,cval); pos++; cval=4*(unsigned int)palette[i+0]; if (cval>255) cval=255; write_int8_buf(buf+pos,cval); pos++; write_int8_buf(buf+pos,0); pos++; } lock_mem = LbScreenIsLocked(); if (!lock_mem) { if (LbScreenLock() != Lb_SUCCESS) { ERRORLOG("Can't lock canvas"); LbMemoryFree(buf); return 0; } } for (i=0; i<height; i++) { memcpy(buf+pos, lbDisplay.WScreen + lbDisplay.GraphicsScreenWidth*(height-i-1), width); pos += width; if ((padding_size&3) > 0) for (j=0; j < padding_size; j++) { write_int8_buf(buf+pos,0); pos++; } } if (!lock_mem) LbScreenUnlock(); return pos; }
SLONG control_process() { SWORD temp; switch (game_state) { case NORMAL: if (lbKeyOn[KB_LALT]) { switch(lbInkey) { case KB_X: flow_control_flags |= QUIT_TO_DOS; lbInkey = 0; break; } } else if (lbKeyOn[KB_LSHIFT] || lbKeyOn[KB_RSHIFT]) { if (KeyOn[KB_LEFT]) scroll_tile(current_tile,1); if (KeyOn[KB_RIGHT]) scroll_tile(current_tile,2); if (KeyOn[KB_UP]) scroll_tile(current_tile,3); if (KeyOn[KB_DOWN]) scroll_tile(current_tile,4); } else { if (lbKeyOn[KB_LEFT]) { lbKeyOn[KB_LEFT] = 0; current_tile--; if (current_tile < 0) current_tile = num_tiles-1; anim_frame = 0; anim_direction = 0; } if (lbKeyOn[KB_RIGHT]) { lbKeyOn[KB_RIGHT] = 0; current_tile++; if (current_tile >= num_tiles) current_tile = 0; anim_frame = 0; anim_direction = 0; } if (lbKeyOn[KB_F1]) { lbKeyOn[KB_F1] = 0; if (flow_control_flags & SHOW_HELP) flow_control_flags &= ~SHOW_HELP; else flow_control_flags |= SHOW_HELP; } if (lbKeyOn[KB_F11]) { lbKeyOn[KB_F11] = 0; if (flow_control_flags & RUN_ANIM) flow_control_flags &= ~RUN_ANIM; else flow_control_flags |= RUN_ANIM; } if (lbKeyOn[KB_F12]) { lbKeyOn[KB_F12] = 0; if (LbScreenLock() != Lb_ERROR) { WritePBM("duke",Display.WScreen,palette); LbScreenUnlock(); } } if (lbKeyOn[KB_F2]) { lbKeyOn[KB_F2] = 0; game_state = ENTERING_LOAD1; } if (lbKeyOn[KB_F3]) { lbKeyOn[KB_F3] = 0; game_state = ENTERING_SAVE1; } if (lbKeyOn[KB_F4]) { lbKeyOn[KB_F4] = 0; game_state = ENTERING_LOAD3; } if (lbKeyOn[KB_F5]) { lbKeyOn[KB_F5] = 0; game_state = ENTERING_LOAD2; } if (lbKeyOn[KB_F6]) { lbKeyOn[KB_F6] = 0; game_state = ENTERING_LOAD4; } if (lbKeyOn[KB_A]) { UBYTE a; lbKeyOn[KB_A] = 0; a = ANIM_TYPE(local_tiles[current_tile].Attributes); a++; if (a > 3) a = 0; CLEAR_ANIM_TYPE(local_tiles[current_tile].Attributes); SET_ANIM_TYPE(local_tiles[current_tile].Attributes,a); } if (lbKeyOn[KB_COMMA]) { UBYTE a; lbKeyOn[KB_COMMA] = 0; a = ANIM_SPEED(local_tiles[current_tile].Attributes); if (a > 0) a--; CLEAR_ANIM_SPEED(local_tiles[current_tile].Attributes); SET_ANIM_SPEED(local_tiles[current_tile].Attributes,a); } if (lbKeyOn[KB_DOT]) { UBYTE a; lbKeyOn[KB_DOT] = 0; a = ANIM_SPEED(local_tiles[current_tile].Attributes); if (a < 15) a++; CLEAR_ANIM_SPEED(local_tiles[current_tile].Attributes); SET_ANIM_SPEED(local_tiles[current_tile].Attributes,a); } if (lbKeyOn[KB_LSBRACKET]) { UBYTE a; lbKeyOn[KB_LSBRACKET] = 0; a = ANIM_NUMBER(local_tiles[current_tile].Attributes); if (a > 0) a--; CLEAR_ANIM_NUMBER(local_tiles[current_tile].Attributes); SET_ANIM_NUMBER(local_tiles[current_tile].Attributes,a); } if (lbKeyOn[KB_RSBRACKET]) { UBYTE a; lbKeyOn[KB_RSBRACKET] = 0; a = ANIM_NUMBER(local_tiles[current_tile].Attributes); if (a < 63) a++; switch (ANIM_TYPE(local_tiles[current_tile].Attributes)) { case ANMFD: case OSCIL: if (current_tile+a >= num_tiles) a = num_tiles-current_tile-1; break; case ANMBK: if (current_tile-a < 0) a = current_tile; break; default: break; } CLEAR_ANIM_NUMBER(local_tiles[current_tile].Attributes); SET_ANIM_NUMBER(local_tiles[current_tile].Attributes,a); } if (lbKeyOn[KB_C]) { SWORD a, b; SBYTE x, y; lbKeyOn[KB_C] = 0; CLEAR_X_CENTRE(local_tiles[current_tile].Attributes); CLEAR_Y_CENTRE(local_tiles[current_tile].Attributes); a = Display.MMouseX - tile_x; b = Display.MMouseY - tile_y; if (a > 127) a = 127; if (a < -128) a = -128; if (b > 127) b = 127; if (b < -128) b = -128; x = a; y = b; SET_X_CENTRE(local_tiles[current_tile].Attributes,x); SET_Y_CENTRE(local_tiles[current_tile].Attributes,y); } if (lbKeyOn[KB_M]) { lbKeyOn[KB_M] = 0; if (flow_control_flags & CROSS_HAIRS) flow_control_flags &= ~CROSS_HAIRS; else flow_control_flags |= CROSS_HAIRS; } if (lbKeyOn[KB_N]) { lbKeyOn[KB_N] = 0; lbInkey = 0; game_state = NAMING_TILE; } if (lbKeyOn[KB_G]) { lbKeyOn[KB_G] = 0; lbInkey = 0; game_state = GOTO_TILE; } if (lbKeyOn[KB_O]) { lbKeyOn[KB_O] = 0; optimise_tile(current_tile); } if (lbKeyOn[KB_R]) { lbKeyOn[KB_R] = 0; rotate_tile(current_tile); } if (lbKeyOn[KB_X]) { lbKeyOn[KB_X] = 0; flip_tile(current_tile,0); } if (lbKeyOn[KB_Y]) { lbKeyOn[KB_Y] = 0; flip_tile(current_tile,1); } if (lbKeyOn[KB_SLASH]) { lbKeyOn[KB_SLASH] = 0; reset_tile(current_tile); } if (lbKeyOn[KB_RETURN]) { lbKeyOn[KB_RETURN] = 0; if (tile_inits[current_tile].Palette) { remap_tile_palette(current_tile,palette,palette2); tile_inits[current_tile].Palette = 0; } } } break; case ENTERING_LOAD1: if (edit_text(filename_text)) { load_art_file(filename_text); game_state = NORMAL; } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; game_state = NORMAL; } break; case ENTERING_SAVE1: if (edit_text(filename_text)) { save_art_file(filename_text); game_state = NORMAL; } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; game_state = NORMAL; } break; case ENTERING_LOAD2: if (edit_text(filename_text)) { load_sprite_file(filename_text); game_state = NORMAL; } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; game_state = NORMAL; } break; case ENTERING_LOAD4: if (edit_text(filename_text)) { read_grp_file(filename_text); game_state = VIEWING_GRP; } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; game_state = NORMAL; } break; case ENTERING_LOAD3: if (edit_text(filename_text)) { if (LbScreenLock() != Lb_ERROR) { if (ReadPBM(filename_text,palette2)) { game_state = SHOW_PIC; SetPalette(palette2); } else { game_state = NORMAL; } LbScreenUnlock(); } } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; game_state = NORMAL; } break; case SHOW_PIC: if (lbDisplay.LeftButton) { cut_x1 = lbDisplay.MouseX; cut_y1 = lbDisplay.MouseY; lbDisplay.LeftButton = 0; } if (cut_x1 != -1) { cut_x2 = lbDisplay.MMouseX; cut_y2 = lbDisplay.MMouseY; if (!lbDisplay.MLeftButton) { if (cut_x2 < cut_x1) { temp = cut_x1; cut_x1 = cut_x2; cut_x2 = temp; } if (cut_y2 < cut_y1) { temp = cut_y1; cut_y1 = cut_y2; cut_y2 = temp; } replace_tile(cut_x1,cut_y1,cut_x2,cut_y2,current_tile); SetPalette(palette); game_state = NORMAL; cut_x1 = cut_y1 = cut_x2 = cut_y2 = -1; if (!KeyOn[KB_LSHIFT] && !KeyOn[KB_RSHIFT]) { remap_tile_palette(current_tile,palette,palette2); tile_inits[current_tile].Palette = 0; } else tile_inits[current_tile].Palette = 1; } } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; SetPalette(palette); cut_x1 = cut_y1 = cut_x2 = cut_y2 = -1; game_state = NORMAL; } break; case NAMING_TILE: if (edit_text(tile_name_text)) { game_state = NORMAL; } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; game_state = NORMAL; } break; case GOTO_TILE: if (edit_text(gen_text)) { sscanf(gen_text,"%d",¤t_tile); if (current_tile >= num_tiles) current_tile = num_tiles-1; if (current_tile < 0) current_tile = 0; gen_text[0] = 0; game_state = NORMAL; } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; gen_text[0] = 0; game_state = NORMAL; } break; case VIEWING_GRP: if (KeyOn[KB_UP]) { KeyOn[KB_UP] = 0; if (groupfile.IdxOffset > 0) groupfile.IdxOffset--; } if (KeyOn[KB_DOWN]) { KeyOn[KB_DOWN] = 0; if (groupfile.IdxCount-groupfile.IdxOffset > 48*4) groupfile.IdxOffset++; } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; game_state = NORMAL; } break; } return(0); }