Changeset 7 for abuse/trunk/src/imlib/specs.cpp
- Timestamp:
- Nov 6, 2005, 7:07:59 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/imlib/specs.cpp
r4 r7 4 4 #include <stdio.h> 5 5 #include <stdlib.h> 6 #include <stdint.h> 6 7 #include <ctype.h> 7 8 #include <fcntl.h> … … 24 25 "Invalid Type", // 3 25 26 "Image", // 4 26 27 "Fore Tile", 27 28 "Back Tile", 28 29 "Character", 29 30 "8 Morph", 30 31 "16 Morph", 31 32 33 34 35 36 37 38 39 40 41 42 43 44 32 "Grue objs", 33 "Extern WAV", 34 "DMX MUS", 35 "Patched morph", 36 "Normal file", 37 "Compress1 file", 38 "Vector Image", 39 "Light list", 40 "Grue fgmap", 41 "Grue bgmap", 42 "Data array", 43 "Character2", 44 "Particle", 45 "Extern lcache" 45 46 }; 46 47 … … 420 421 if (se) 421 422 { 422 423 424 425 423 start_offset=se->offset; 424 current_offset = 0; 425 file_length=se->size; 426 rbuf_start=rbuf_end=0; 426 427 } else 427 428 { 428 429 429 close(fd); 430 fd=-1; 430 431 } 431 432 } … … 548 549 int jFILE::unbuffered_seek(long offset, int whence) // whence=SEEK_SET, SEEK_CUR, SEEK_END, ret=0=success 549 550 { 550 551 552 553 554 555 551 long ret; 552 553 if (fast_load_mode == 2) 554 { 555 switch (whence) 556 { 556 557 case SEEK_SET : 557 558 558 current_offset = start_offset+offset; 559 break; 559 560 case SEEK_END : 560 561 561 current_offset = start_offset+file_length-offset; 562 break; 562 563 case SEEK_CUR : 563 564 564 current_offset += offset; 565 break; 565 566 default: 566 567 567 ret = -1; 568 break; 568 569 } 569 570 571 570 return current_offset; 571 } 572 572 573 switch (whence) 573 574 { … … 584 585 if (ret>=0) 585 586 { 586 587 588 589 587 current_offset = ret - start_offset; 588 if (spec_main_fd == fd) 589 spec_main_offset = ret; 590 return ret; 590 591 } 591 592 else 592 593 } 594 595 596 u nsigned charbFILE::read_byte()597 { u nsigned charx;593 return -1; // if a bad whence, then failure 594 } 595 596 597 uint8_t bFILE::read_byte() 598 { uint8_t x; 598 599 read(&x,1); 599 600 return x; 600 601 } 601 602 602 u nsigned short bFILE::read_short()603 uint16_t bFILE::read_short() 603 604 { 604 u nsigned short x;605 uint16_t x; 605 606 read(&x,2); 606 607 return int_to_local(x); … … 608 609 609 610 610 u nsigned longbFILE::read_long()611 uint32_t bFILE::read_long() 611 612 { 612 u nsigned longx;613 uint32_t x; 613 614 read(&x,4); 614 615 return long_to_local(x); 615 616 } 616 617 617 void bFILE::write_byte(u nsigned charx)618 void bFILE::write_byte(uint8_t x) 618 619 { 619 620 write(&x,1); 620 621 } 621 622 622 void bFILE::write_short(u nsigned short x)623 void bFILE::write_short(uint16_t x) 623 624 { 624 625 x=int_to_local(x); … … 627 628 628 629 629 void bFILE::write_long(u nsigned longx)630 void bFILE::write_long(uint32_t x) 630 631 { 631 632 x=long_to_local(x); … … 912 913 } 913 914 914 u nsigned short read_short(FILE *fp)915 { 916 u nsigned short x;915 uint16_t read_short(FILE *fp) 916 { 917 uint16_t x; 917 918 fread(&x,1,2,fp); 918 919 return int_to_local(x); 919 920 } 920 921 921 u nsigned longread_long(FILE *fp)922 { 923 u nsigned longx;922 uint32_t read_long(FILE *fp) 923 { 924 uint32_t x; 924 925 fread(&x,1,4,fp); 925 return (long)long_to_local(x);926 } 927 void write_short(FILE *fp, u nsigned short x)926 return long_to_local(x); 927 } 928 void write_short(FILE *fp, uint16_t x) 928 929 { 929 930 x=int_to_local(x); … … 931 932 } 932 933 933 void write_long(FILE *fp, u nsigned longx)934 void write_long(FILE *fp, uint32_t x) 934 935 { 935 936 x=long_to_local(x); … … 937 938 } 938 939 939 u nsigned charread_byte(FILE *fp) { return fgetc(fp)&0xff; }940 void write_byte(FILE *fp, u nsigned char x) { fputc(x,fp); }941 942 u nsigned short read_other_long(FILE *fp)943 { 944 u nsigned longx;940 uint8_t read_byte(FILE *fp) { return fgetc(fp)&0xff; } 941 void write_byte(FILE *fp, uint8_t x) { fputc((unsigned char)x,fp); } 942 943 uint32_t read_other_long(FILE *fp) 944 { 945 uint32_t x; 945 946 fread(&x,1,4,fp); 946 947 return big_long_to_local(x); 947 948 } 948 949 949 u nsigned longread_other_short(FILE *fp)950 { 951 u nsigned short x;950 uint16_t read_other_short(FILE *fp) 951 { 952 uint16_t x; 952 953 fread(&x,1,2,fp); 953 954 return big_short_to_local(x); … … 955 956 956 957 957 void write_other_short(FILE *fp, u nsigned short x)958 void write_other_short(FILE *fp, uint16_t x) 958 959 { 959 960 x=big_short_to_local(x); … … 961 962 } 962 963 963 void write_other_long(FILE *fp, u nsigned longx)964 void write_other_long(FILE *fp, uint32_t x) 964 965 { 965 966 x=big_long_to_local(x);
Note: See TracChangeset
for help on using the changeset viewer.