procedure cleargame; var ix,iy:integer; begin for ix:=0 to 255 do for iy:=0 to 127 do begin map[ix,iy]:=0; i_map[ix,iy]:=0; l_map[ix,iy]:=0; drop[ix].item_d:=0; drop[ix].x_d:=0; drop[ix].y_d:=0; drop[ix].vel_d:=0; end; for ix:=0 to 35 do begin inv[ix].item_i:=0; inv[ix].sum_i:=0; end; for ix:=0 to 31 do for iy:=0 to 26 do begin chest[ix,iy].item_i:=0; chest[ix,iy].sum_i:=0; end; invslot:=0; invcur:=0; invcur2:=0; invst:=0; toolus:=0; toolind:=0; x:=0; y:=0; camx:=0; camy:=0; posi:=0; curx:=0; cury:=0; r_ani:=0; vely:=0; jmp:=false; keymode:=0; end; function readint:integer; var b:integer; begin b:=b or (read_uns_byte<<24); b:=b or (read_uns_byte<<16); b:=b or (read_uns_byte<<8); b:=b or (read_uns_byte); readint:=b; end; procedure writeint(intt:integer); begin write_byte((intt>>24) and $FF); write_byte((intt>>16) and $FF); write_byte((intt>>8) and $FF); write_byte((intt) and $FF); end; procedure writebool(bo:boolean); begin if bo=true then write_byte(1); else write_byte(0); end; function readbool:boolean; begin if read_byte>0 then readbool:=true; else readbool:=false; end; function getSD:string; var str:string; i:integer; begin str:=get_roots; i:=pos(str,'|'); str:=copy(str,0,i); i:=pos(str,'|'); str:=copy(str,0,i); getSD:=str; end; procedure savegame; var ix,iy:integer; begin if file_exists('/'+sd+'/world.sav')<>1 then file_create('/'+sd+'/world.sav'); if open_file('/'+sd+'/world.sav')=1 then begin writeint(seed); for ix:=0 to 255 do for iy:=0 to 127 do begin write_byte(map[ix,iy]); write_byte(i_map[ix,iy]); end; writeint(x); writeint(y); writeint(camx); writeint(camy); write_byte(posi); writeint(curx); writeint(cury); writeint(r_ani); writeint(n_ani); writeint(velx); writeint(vely); writeint(acc); writeint(min_vely); writebool(jmp); writebool(fall); writebool(an_pr); writebool(osadki); writeint(osadki_ani); writeint(invslot); writeint(toolus); for ix:=0 to 35 do begin writeint(inv[ix].item_i); writeint(inv[ix].sum_i); end; for ix:=0 to 255 do begin writeint(drop[ix].item_d); writeint(drop[ix].x_d); writeint(drop[ix].y_d); writeint(drop[ix].vel_d); end; for ix:=0 to 31 do for iy:=0 to 26 do begin writeint(chest[ix,iy].item_i); writeint(chest[ix,iy].sum_i); end; write_byte(gamemode); flush; if close_file('/'+sd+'/world.sav')=1 then debug('OK'); end; end; procedure loadgame; var ix,iy:integer; begin if file_exists('/'+sd+'/world.sav')=1 then if open_file('/'+sd+'/world.sav')=1 then begin seed:=readint; for ix:=0 to 255 do for iy:=0 to 127 do begin map[ix,iy]:=read_byte; i_map[ix,iy]:=read_byte; end; x:=readint; y:=readint; camx:=readint; camy:=readint; posi:=read_byte; curx:=readint; cury:=readint; r_ani:=readint; n_ani:=readint; velx:=readint; vely:=readint; acc:=readint; min_vely:=readint; jmp:=readbool; fall:=readbool; an_pr:=readbool; osadki:=readbool; osadki_ani:=readint; invslot:=readint; toolus:=readint; for ix:=0 to 35 do begin inv[ix].item_i:=readint; inv[ix].sum_i:=readint; end; for ix:=0 to 255 do begin drop[ix].item_d:=readint; drop[ix].x_d:=readint; drop[ix].y_d:=readint; drop[ix].vel_d:=readint; end; for ix:=0 to 31 do for iy:=0 to 26 do begin chest[ix,iy].item_i:=readint; chest[ix,iy].sum_i:=readint; end; gamemode:=read_byte; if close_file('/'+sd+'/world.sav')=1 then debug('OK'); end; end;