Changeset 17


Ignore:
Timestamp:
Nov 10, 2005, 9:41:13 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • absolute shitloads of 64 bit fixes.
Location:
abuse/trunk/src
Files:
87 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/cache.cpp

    r10 r17  
    6767  }
    6868
    69   fp->write_short(total);
     69  fp->write_uint16(total);
    7070  total=0;
    7171  for (i=0;i<total_files;i++)
    7272  {
    73     ulong crc;
     73    uint32_t crc;
    7474    int failed=0;
    7575    crc=get_crc(i,failed);
    7676    if (!failed)
    7777    {
    78       fp->write_long(crc);
    79       uchar len=strlen(get_filename(i))+1;
    80       fp->write_byte(len);
     78      fp->write_uint32(crc);
     79      uint8_t len=strlen(get_filename(i))+1;
     80      fp->write_uint8(len);
    8181      fp->write(get_filename(i),len);
    8282      total++;
     
    9696  } else
    9797  {
    98     short total=fp->read_short();
     98    short total=fp->read_uint16();
    9999    int i;
    100100    for (i=0;i<total;i++)
    101101    {
    102102      char name[256];
    103       ulong crc=fp->read_long();
    104       uchar len=fp->read_byte();
     103      uint32_t crc=fp->read_uint32();
     104      uint8_t len=fp->read_uint8();
    105105      fp->read(name,len);
    106106      set_crc(get_filenumber(name),crc);
     
    148148}
    149149
    150 char *crc_manager::get_filename(long filenumber)
     150char *crc_manager::get_filename(int32_t filenumber)
    151151{
    152152  CHECK(filenumber>=0 && filenumber<total_files);
     
    154154}
    155155
    156 ulong crc_manager::get_crc(long filenumber, int &failed)
     156uint32_t crc_manager::get_crc(int32_t filenumber, int &failed)
    157157{   
    158158  CHECK(filenumber>=0 && filenumber<total_files);
     
    166166}
    167167
    168 void crc_manager::set_crc(long filenumber, ulong crc)
     168void crc_manager::set_crc(int32_t filenumber, uint32_t crc)
    169169{
    170170  CHECK(filenumber>=0 && filenumber<total_files);
     
    248248    if (fp)
    249249    {
    250       fp->write_short(crc_man.total_filenames());
     250      fp->write_uint16(crc_man.total_filenames());
    251251      for (i=0;i<crc_man.total_filenames();i++)
    252252      {
    253253        int l=strlen(crc_man.get_filename(i))+1;
    254         fp->write_byte(l);
     254        fp->write_uint8(l);
    255255        fp->write(crc_man.get_filename(i),l);
    256256      }
     
    259259      for (i=0;i<total;i++)
    260260        if (list[i].last_access>0) tsaved++;
    261       fp->write_long(tsaved);
     261      fp->write_uint32(tsaved);
    262262
    263263      for (i=0;i<total;i++)
     
    266266        if (list[id].last_access>0)       // don't save unaccessed counts     
    267267        {
    268           fp->write_byte(list[id].type);    // save type, if type changed on reload
     268          fp->write_uint8(list[id].type);    // save type, if type changed on reload
    269269                                            // don't cache in-> its a different refrence
    270           fp->write_short(list[id].file_number);
    271           fp->write_long(list[id].offset);
     270          fp->write_uint16(list[id].file_number);
     271          fp->write_uint32(list[id].offset);
    272272        }
    273273      }     
     
    310310
    311311
    312 int cache_list::search(int *sarray, ushort filenum, long offset)
     312int cache_list::search(int *sarray, uint16_t filenum, int32_t offset)
    313313{
    314314  int x1=0,x2=total-1;
     
    423423
    424424  int j;
    425   ushort *fg_line;
     425  uint16_t *fg_line;
    426426  for (j=0;j<lev->foreground_height();j++)
    427427  {
     
    439439  }
    440440
    441   ushort *bg_line;
     441  uint16_t *bg_line;
    442442  for (j=0;j<lev->background_height();j++)
    443443  {
     
    481481      int *fnum_remap;    // remaps old filenumbers into current ones
    482482     
    483       tnames=fp->read_short();
     483      tnames=fp->read_uint16();
    484484      if (tnames)                     /// make sure there isn't bad info in the file
    485485      {
     
    489489        for (i=0;i<tnames;i++)
    490490        {
    491           fp->read(name,fp->read_byte());
     491          fp->read(name,fp->read_uint8());
    492492          fnum_remap[i]=-1;                    // initialize the map to no-map
    493493
     
    498498        }
    499499       
    500         long tsaved=fp->read_long();
     500        uint32_t tsaved=fp->read_uint32();
    501501
    502502
     
    511511        for (i=0;i<tsaved;i++)
    512512        {
    513           uchar type=fp->read_byte();
    514           short file_num=fp->read_short();
     513          uint8_t type=fp->read_uint8();
     514          short file_num=fp->read_uint16();
    515515          if (file_num>=tnames)  // bad data?
    516516            file_num=-1;
    517517          else file_num=fnum_remap[file_num];
    518518
    519           ulong offset=fp->read_long();
     519          uint32_t offset=fp->read_uint32();
    520520
    521521          // search for a match
     
    805805}
    806806
    807 long cache_list::alloc_id()
     807int32_t cache_list::alloc_id()
    808808{
    809809  int id;
     
    851851
    852852
    853 long cache_list::reg_lisp_block(Cell *block)
     853int32_t cache_list::reg_lisp_block(Cell *block)
    854854{
    855   long s;
     855  uint32_t s;
    856856  if (lcache_number==-1)
    857857    lcache_number=crc_man.get_filenumber(lfname);
     
    893893
    894894  s=block_size(block);
    895   cache_file->write_long(s);
     895  cache_file->write_uint32(s);
    896896  write_level(cache_file,block);
    897897  return id;   
    898898}
    899899
    900 long cache_list::reg_object(char *filename, void *object, int type, int rm_dups)
     900int32_t cache_list::reg_object(char *filename, void *object, int type, int rm_dups)
    901901{
    902902  char *name;
     
    912912extern int total_files_open;
    913913
    914 long cache_list::reg(char *filename, char *name, int type, int rm_dups)
     914int32_t cache_list::reg(char *filename, char *name, int type, int rm_dups)
    915915{
    916916        int id=alloc_id(),i,fn=crc_man.get_filenumber(filename);
     
    11691169      int cache_size=80*1024;                   // 80K
    11701170      cache_read_file->set_read_buffer_size(cache_size);
    1171       uchar mini_buf;
     1171      uint8_t mini_buf;
    11721172      cache_read_file->read(&mini_buf,1);       // prime the buffer
    11731173    }
     
    11771177    int sp=alloc_space; alloc_space=ALLOC_SPACE_CACHE;
    11781178
    1179     long size=cache_read_file->read_long();
     1179    uint32_t size=cache_read_file->read_uint32();
    11801180    void *space;
    11811181
     
    12061206void cache_list::free_oldest()
    12071207{
    1208   long i,old_time=last_access;
     1208  uint32_t i,old_time=last_access;
    12091209  cache_item *ci=list,*oldest=NULL;
    12101210  ful=1;
     
    12571257      printf("type=(%20s) file=(%20s) access=(%6ld)\n",spec_types[ci->type],
    12581258             crc_man.get_filename(ci->file_number),
    1259              ci->last_access);
     1259             (long int)ci->last_access);
    12601260    }
    12611261  } while (new_old);
  • abuse/trunk/src/clisp.cpp

    r16 r17  
    2020#include "netcfg.hpp"
    2121
    22 extern uchar major_version;
    23 extern uchar minor_version;
     22extern uint8_t major_version;
     23extern uint8_t minor_version;
    2424extern int has_joystick;
    2525
     
    6060
    6161            *l_statbar_logo_x,*l_statbar_logo_y;
    62 uchar chatting_enabled=0;
     62uint8_t chatting_enabled=0;
    6363
    6464extern void scatter_line(int x1, int y1, int x2, int y2, int c, int s);
     
    19091909    {
    19101910      palette *p=pal->copy();
    1911       uchar *addr=(uchar *)p->addr();
     1911      uint8_t *addr=(uint8_t *)p->addr();
    19121912      int r,g,b;
    19131913      int ra=lnumber_value(CAR(args)); args=CDR(args);
     
    19161916      for (int i=0;i<256;i++)
    19171917      {
    1918         r=(int)*addr+ra; if (r>255) r=255; else if (r<0) r=0; *addr=(uchar)r; addr++;
    1919         g=(int)*addr+ga; if (g>255) g=255; else if (g<0) g=0; *addr=(uchar)g; addr++;
    1920         b=(int)*addr+ba; if (b>255) b=255; else if (b<0) b=0; *addr=(uchar)b; addr++;
     1918        r=(int)*addr+ra; if (r>255) r=255; else if (r<0) r=0; *addr=(uint8_t)r; addr++;
     1919        g=(int)*addr+ga; if (g>255) g=255; else if (g<0) g=0; *addr=(uint8_t)g; addr++;
     1920        b=(int)*addr+ba; if (b>255) b=255; else if (b<0) b=0; *addr=(uint8_t)b; addr++;
    19211921      }
    19221922      p->load();
  • abuse/trunk/src/compiled.cpp

    r2 r17  
    66extern int total_objects;
    77
    8 uchar *bad_guy_array=NULL;    // list flaging each character saying they are a bad bug or not
     8uint8_t *bad_guy_array=NULL;  // list flaging each character saying they are a bad bug or not
    99                              // mainly used by the rocket to find targets
    1010
    11 long S_fall_start,S_falling,S_landing,S_pounce_wait,
     11int32_t S_fall_start,S_falling,S_landing,S_pounce_wait,
    1212     S_turn_around,S_fire_wait,S_ceil_fire,S_top_walk,
    1313     S_blown_back_dead,S_jump_up,S_hiding,S_weapon_fire,
     
    2828int compile_error=0;
    2929
    30 long c_state(char *name)
     30int32_t c_state(char *name)
    3131{
    3232  void *sym=find_symbol(name);
     
    114114  {
    115115    b=symbol_value(b);
    116     bad_guy_array=(uchar *)jmalloc(total_objects,"bad_guy_array");
     116    bad_guy_array=(uint8_t *)jmalloc(total_objects,"bad_guy_array");
    117117    memset(bad_guy_array,0,total_objects);
    118118    while (b)
    119119    {
    120       long x=lnumber_value(CAR(b));
     120      int32_t x=lnumber_value(CAR(b));
    121121      if (x>=0 && x<total_objects)
    122122        bad_guy_array[x]=1;
  • abuse/trunk/src/cop.cpp

    r16 r17  
    797797
    798798    palette *p=pal->copy();
    799     uchar *addr=(uchar *)p->addr();
     799    uint8_t *addr=(uint8_t *)p->addr();
    800800    int ra,ga,ba;
    801801   
    802802    for (int i=0;i<256;i++)
    803803    {
    804       ra=(int)*addr+r; if (ra>255) ra=255; else if (ra<0) r=0; *addr=(uchar)ra; addr++;
    805       ga=(int)*addr+g; if (ga>255) ga=255; else if (ga<0) g=0; *addr=(uchar)ga; addr++;
    806       ba=(int)*addr+b; if (ba>255) ba=255; else if (ba<0) b=0; *addr=(uchar)ba; addr++;
     804      ra=(int)*addr+r; if (ra>255) ra=255; else if (ra<0) r=0; *addr=(uint8_t)ra; addr++;
     805      ga=(int)*addr+g; if (ga>255) ga=255; else if (ga<0) g=0; *addr=(uint8_t)ga; addr++;
     806      ba=(int)*addr+b; if (ba>255) ba=255; else if (ba<0) b=0; *addr=(uint8_t)ba; addr++;
    807807    }
    808808    p->load();
  • abuse/trunk/src/crc.cpp

    r2 r17  
    11#include "crc.hpp"
    22
    3 unsigned short calc_crc(unsigned char *buf, long len)
     3uint16_t calc_crc(uint8_t *buf, int len)
    44{
    5   unsigned char c1=0,c2=0;
     5  uint8_t c1=0,c2=0;
    66  while (len)
    77  {
     
    1616
    1717 
    18 ulong crc_file(bFILE *fp)
     18uint32_t crc_file(bFILE *fp)
    1919{
    20   uchar crc1=0,crc2=0,crc3=0,crc4=0;
     20  uint8_t crc1=0,crc2=0,crc3=0,crc4=0;
    2121
    2222  int size=0x1000;
    23   uchar *buffer=(uchar *)jmalloc(size,"crc_buffer"),*c;
     23  uint8_t *buffer=(uint8_t *)jmalloc(size,"crc_buffer"),*c;
    2424  long l=fp->file_size();
    2525  long cur_pos=fp->tell();
  • abuse/trunk/src/demo.cpp

    r16 r17  
    6262  the_game->load_level(name);
    6363  record_file->write((void *)"DEMO,VERSION:2",14);
    64   record_file->write_byte(strlen(name)+1);
     64  record_file->write_uint8(strlen(name)+1);
    6565  record_file->write(name,strlen(name)+1);
    6666 
     
    6868  if (DEFINEDP(symbol_value(l_difficulty)))
    6969  {
    70     if (symbol_value(l_difficulty)==l_easy) record_file->write_byte(0);
    71     else if (symbol_value(l_difficulty)==l_medium) record_file->write_byte(1);
    72     else if (symbol_value(l_difficulty)==l_hard) record_file->write_byte(2);
    73     else record_file->write_byte(3);
    74   } else record_file->write_byte(3);
     70    if (symbol_value(l_difficulty)==l_easy) record_file->write_uint8(0);
     71    else if (symbol_value(l_difficulty)==l_medium) record_file->write_uint8(1);
     72    else if (symbol_value(l_difficulty)==l_hard) record_file->write_uint8(2);
     73    else record_file->write_uint8(3);
     74  } else record_file->write_uint8(3);
    7575 
    7676
     
    9494          p->get_input();
    9595
    96       base->packet.write_byte(SCMD_SYNC);
    97       base->packet.write_short(make_sync());
     96      base->packet.write_uint8(SCMD_SYNC);
     97      base->packet.write_uint16(make_sync());
    9898      demo_man.save_packet(base->packet.packet_data(),base->packet.packet_size());
    9999      process_packet_commands(base->packet.packet_data(),base->packet.packet_size());
     
    102102    case PLAYING :
    103103    {
    104       uchar buf[1500];
     104      uint8_t buf[1500];
    105105      int size;
    106106      if (get_packet(buf,size))              // get starting inputs
     
    138138int demo_manager::start_playing(char *filename)
    139139{
    140   uchar sig[15];
     140  uint8_t sig[15];
    141141  record_file=open_file(filename,"rb");
    142142  if (record_file->open_failure()) { delete record_file; return 0; } 
     
    232232  if (state==RECORDING)
    233233  {
    234     ushort ps=lstl(packet_size);
     234    uint16_t ps=lstl(packet_size);
    235235    if (record_file->write(&ps,2)!=2 ||
    236236        record_file->write(packet,packet_size)!=packet_size)
     
    247247  if (state==PLAYING)
    248248  {
    249     ushort ps;
     249    uint16_t ps;
    250250    if (record_file->read(&ps,2)!=2)
    251251    {
  • abuse/trunk/src/dev.cpp

    r16 r17  
    405405    new_height-=y+new_height-cy2;
    406406 
    407   uchar d;
     407  uint8_t d;
    408408  for (iy=iy_start;new_height>0;new_height--,y++,iy+=ystep)
    409409  {
     
    568568    jfree(ch);
    569569    char buf[100];
    570     sprintf(buf,"%8ld %8ld",j_allocated(),j_available());
     570    sprintf(buf,"%8ld %8ld",(long int)j_allocated(),(long int)j_available());
    571571    eh->font()->put_string(memprof->screen,memprof->x1(),memprof->y2()-eh->font()->height(),buf);
    572572
  • abuse/trunk/src/director.cpp

    r2 r17  
    2525
    2626
    27 int text_draw(int y, int x1, int y1, int x2, int y2, char *buf, JCFont *font, uchar *cmap, char color)
     27int text_draw(int y, int x1, int y1, int x2, int y2, char *buf, JCFont *font, uint8_t *cmap, char color)
    2828{
    2929  short cx1,cy1,cx2,cy2,word_size,word_len;
  • abuse/trunk/src/endgame.cpp

    r2 r17  
    2121{
    2222  int x,size;
    23   ushort *remap;
    24   uchar *light;
     23  uint16_t *remap;
     24  uint8_t *light;
    2525} ;
    2626
    2727
    28 int text_draw(int y, int x1, int y1, int x2, int y2, char *buf, JCFont *font, uchar *cmap, char color);
     28int text_draw(int y, int x1, int y1, int x2, int y2, char *buf, JCFont *font, uint8_t *cmap, char color);
    2929
    3030mask_line *make_mask_lines(image *mask, int map_width)
     
    3434  {
    3535    // find the start of the run..
    36     uchar *sl=mask->scan_line(y);   
     36    uint8_t *sl=mask->scan_line(y);   
    3737    int x=0;
    3838    while (*sl==0) { sl++; x++; }
     
    4242    // find the length of the run
    4343    int size=0;
    44     uchar *sl_start=sl;
     44    uint8_t *sl_start=sl;
    4545    while (*sl!=0 && x<mask->width()) { sl++; x++; size++; }
    4646    p[y].size=size;
    4747
    4848    // now calculate remap for line
    49     p[y].remap=(ushort *)jmalloc(size*2,"mask remap");
    50     p[y].light=(uchar *)jmalloc(size,"mask light");
    51     ushort *rem=p[y].remap;
    52     uchar *lrem=p[y].light;
     49    p[y].remap=(uint16_t *)jmalloc(size*2,"mask remap");
     50    p[y].light=(uint8_t *)jmalloc(size,"mask light");
     51    uint16_t *rem=p[y].remap;
     52    uint8_t *lrem=p[y].light;
    5353    for (x=0;x<size;x++,rem++)
    5454    {
     
    6969
    7070
    71 void scan_map(image *screen, int sx, int sy, image *im1, image *im2, int fade256, long *paddr, mask_line *p, int mask_height,
     71void scan_map(image *screen, int sx, int sy, image *im1, image *im2, int fade256, int32_t *paddr, mask_line *p, int mask_height,
    7272              int xoff, int coff)
    7373
    7474  int x1=10000,x2=0;
    7575  int iw=im1->width(); 
    76   ushort r,off;
     76  uint16_t r,off;
    7777  int y=0;
    78   uchar *l;
     78  uint8_t *l;
    7979
    8080  for (;y<mask_height;y++)
    8181  {
    8282    mask_line *n=p+y;
    83     uchar *sl=screen->scan_line(y+sy)+sx+n->x;
    84     uchar *sl2=im1->scan_line(y);
    85     uchar *sl3=im2->scan_line(y);
     83    uint8_t *sl=screen->scan_line(y+sy)+sx+n->x;
     84    uint8_t *sl2=im1->scan_line(y);
     85    uint8_t *sl3=im2->scan_line(y);
    8686    l=n->light;
    87     ushort *rem=n->remap;
     87    uint16_t *rem=n->remap;
    8888    if (sx+n->x<x1) x1=sx+n->x;   
    8989    int x=0;
     
    9595      if (off>=iw) off-=iw;
    9696
    97       long p1=*(paddr+sl2[off]);
    98       long p2=*(paddr+sl3[off]);
     97      int32_t p1=*(paddr+sl2[off]);
     98      int32_t p2=*(paddr+sl3[off]);
    9999
    100100      int r1=p1>>16,g1=(p1>>8)&0xff,b1=p1&0xff;
     
    104104          b3=b1+(b2-b1)*fade256/256;
    105105
    106       uchar c=color_table->lookup_color(r3>>3,g3>>3,b3>>3);
     106      uint8_t c=color_table->lookup_color(r3>>3,g3>>3,b3>>3);
    107107                               
    108108      *sl=*(white_light+((*l)/2+28+jrand()%4)*256+c);
     
    123123class ex_char {
    124124  public :
    125   uchar frame,char_num;
     125  uint8_t frame,char_num;
    126126  int x,y;
    127127  ex_char *next;
     
    175175            pal->find_closest(100,100,100),
    176176            pal->find_closest(64,64,64)};
    177   ushort sinfo[800*3],*si;
     177  uint16_t sinfo[800*3],*si;
    178178
    179179  for (si=sinfo,i=0;i<800;i++)
     
    184184    screen->putpixel(si[-3],si[-2],si[-1]);
    185185  }
    186   long paddr[256];
     186  int32_t paddr[256];
    187187  if (old_pal)
    188188  {
     
    354354
    355355
    356   uchar cmap[32];
     356  uint8_t cmap[32];
    357357  for (i=0;i<32;i++)
    358358    cmap[i]=pal->find_closest(i*256/32,i*256/32,i*256/32);
     
    428428  fade_in(NULL,32);
    429429
    430   uchar cmap[32];
     430  uint8_t cmap[32];
    431431  int i;
    432432  for (i=0;i<32;i++)
     
    480480  fade_in(im,32);
    481481
    482   uchar cmap[32];
     482  uint8_t cmap[32];
    483483  int i;
    484484  for (i=0;i<32;i++)
  • abuse/trunk/src/extend.cpp

    r2 r17  
    44
    55  Simple object             (power ups, non-moving objects)
    6     long x,y;
    7     schar direction;
    8     ushort otype,state
    9     ushort current_frame;
     6    int32_t x,y;
     7    int8_t direction;
     8    uint16_t otype,state
     9    uint16_t current_frame;
    1010    extension *
    1111
    1212
    1313  Moving object             (simple lisp controlled characters)
    14      uchar flags;
    15      long xvel,yvel,xacel,yacel;
    16      uchar fx,fy,fxvel,fyvel,fxacel,fyacel,aitype;
    17      ushort aistate,aistate_time;
    18      unsigned short hp,mp,
     14     uint8_t flags;
     15     int32_t xvel,yvel,xacel,yacel;
     16     uint8_t fx,fy,fxvel,fyvel,fxacel,fyacel,aitype;
     17     uint16_t aistate,aistate_time;
     18     uint16_t hp,mp,
    1919     extension *
    2020
    2121
    2222  Complex objects          (can controll lights, other characters, and have a neural net ai)
    23     uchar tobjs,tlights;
     23    uint8_t tobjs,tlights;
    2424    object_list *                       
    2525    light_list *
    2626    nnet_info *
    27     schar fade_dir, frame_dir;       
    28     unsigned char fade_count,fade_max;
     27    int8_t fade_dir, frame_dir;       
     28    uint8_t fade_count,fade_max;
    2929    morph_char *morph_status;
    3030
  • abuse/trunk/src/game.cpp

    r16 r17  
    7171
    7272int registered=0;
    73 extern uchar chatting_enabled;
     73extern uint8_t chatting_enabled;
    7474
    7575extern int confirm_quit();
     
    686686}
    687687
    688 void remap_area(image *screen, int x1, int y1, int x2, int y2, uchar *remap)
    689 {
    690   uchar *sl=(uchar *)screen->scan_line(y1)+x1;
     688void remap_area(image *screen, int x1, int y1, int x2, int y2, uint8_t *remap)
     689{
     690  uint8_t *sl=(uint8_t *)screen->scan_line(y1)+x1;
    691691  int x,y,a=screen->width()-(x2-x1+1);
    692   uchar c;
     692  uint8_t c;
    693693  for (y=y1;y<=y2;y++)
    694694  {
     
    826826   
    827827    int bh=current_level->background_height(),bw=current_level->background_width();
    828     ushort *bl;
     828    uint16_t *bl;
    829829    for (draw_y=yo,y=y1;y<=y2;y++,draw_y+=yinc)
    830830    {
     
    853853//    server_check();
    854854
    855   uchar rescan=0; 
     855  uint8_t rescan=0; 
    856856
    857857    int fw,fh;
     
    918918        if (!(draw_y<ncy1 ||draw_y+yinc>=ncy2))
    919919        {
    920           ushort *cl=current_level->get_fgline(y)+x1;
    921           uchar *sl1=screen->scan_line(draw_y)+xo;
     920          uint16_t *cl=current_level->get_fgline(y)+x1;
     921          uint8_t *sl1=screen->scan_line(draw_y)+xo;
    922922          for (x=x1,draw_x=xo;x<=x2;x++,cl++,sl1+=xinc,draw_x+=xinc)
    923923          {
     
    929929//            else fort_num=0;
    930930
    931               uchar *sl2=get_fg(fort_num)->micro_image->scan_line(0);
    932               uchar *sl3=sl1;
     931              uint8_t *sl2=get_fg(fort_num)->micro_image->scan_line(0);
     932              uint8_t *sl3=sl1;
    933933              memcpy(sl3,sl2,AUTOTILE_WIDTH); sl2+=AUTOTILE_WIDTH; sl3+=scr_w;
    934934              memcpy(sl3,sl2,AUTOTILE_WIDTH); sl2+=AUTOTILE_WIDTH; sl3+=scr_w;
     
    949949      {
    950950       
    951         ushort *cl;
     951        uint16_t *cl;
    952952        if (y<fg_h)
    953953          cl=current_level->get_fgline(y)+x1;
    954954        else cl=NULL;
    955         uchar *sl1=draw_y<ncy1 ? 0 : screen->scan_line(draw_y)+xo;
     955        uint8_t *sl1=draw_y<ncy1 ? 0 : screen->scan_line(draw_y)+xo;
    956956
    957957        for (x=x1,draw_x=xo;x<=x2;x++,draw_x+=xinc,cl++,sl1+=xinc)
     
    10071007      for (y=y1,draw_y=yo;y<=y2;y++,draw_y+=yinc)
    10081008      {
    1009         ushort *cl=current_level->get_fgline(y)+x1;
     1009        uint16_t *cl=current_level->get_fgline(y)+x1;
    10101010        for (x=x1,draw_x=xo;x<=x2;x++,draw_x+=xinc,cl++)
    10111011        {
     
    10411041      for (y=y1,draw_y=yo;y<=y2;y++,draw_y+=yinc)
    10421042      {
    1043         ushort *cl;
     1043        uint16_t *cl;
    10441044        if (y<fg_h)
    10451045          cl=current_level->get_fgline(y)+x1;
     
    10531053            {
    10541054              point_list *p=get_fg(fort_num)->points;
    1055               uchar *d=p->data;
     1055              uint8_t *d=p->data;       
    10561056              if (p->tot)
    10571057              {
     
    12021202  for (i=0;i<steps;i++)
    12031203  {
    1204     uchar *sl1=(uchar *)pal->addr();   
    1205     uchar *sl2=(uchar *)old_pal->addr();   
     1204    uint8_t *sl1=(uint8_t *)pal->addr();   
     1205    uint8_t *sl2=(uint8_t *)old_pal->addr();   
    12061206    int j;
    12071207    int v=(i+1)*256/steps;
     
    12261226  for (i=0;i<steps;i++)
    12271227  {
    1228     uchar *sl1=(uchar *)pal->addr();   
    1229     uchar *sl2=(uchar *)old_pal->addr();   
     1228    uint8_t *sl1=(uint8_t *)pal->addr();   
     1229    uint8_t *sl2=(uint8_t *)old_pal->addr();   
    12301230    int j;
    12311231    int v=(steps-i)*256/steps;
     
    12481248}
    12491249
    1250 int text_draw(int y, int x1, int y1, int x2, int y2, char *buf, JCFont *font, uchar *cmap, char color);
     1250int text_draw(int y, int x1, int y1, int x2, int y2, char *buf, JCFont *font, uint8_t *cmap, char color);
    12511251
    12521252void do_title()
     
    13111311
    13121312                        fade_in( NULL, 16 );
    1313                         uchar cmap[32];
     1313                        uint8_t cmap[32];
    13141314                        for( i = 0; i < 32; i++ )
    13151315                        cmap[i] = pal->find_closest( i * 256 / 32, i * 256 / 32, i * 256 / 32 );
     
    17331733                                        {
    17341734                                                if( chat && chat->chat_event( ev ) )
    1735                                                         base->packet.write_byte( SCMD_CHAT_KEYPRESS );
     1735                                                        base->packet.write_uint8( SCMD_CHAT_KEYPRESS );
    17361736                                                else
    1737                                                         base->packet.write_byte( SCMD_KEYPRESS );
     1737                                                        base->packet.write_uint8( SCMD_KEYPRESS );
    17381738                                        }
    17391739                                        else
    1740                                                 base->packet.write_byte( SCMD_EXT_KEYPRESS );
    1741                                         base->packet.write_byte( client_number() );
     1740                                                base->packet.write_uint8( SCMD_EXT_KEYPRESS );
     1741                                        base->packet.write_uint8( client_number() );
    17421742                                        if( ev.key > 256 )
    1743                                                 base->packet.write_byte( ev.key - 256 );
     1743                                                base->packet.write_uint8( ev.key - 256 );
    17441744                                        else
    1745                                                 base->packet.write_byte( ev.key );
     1745                                                base->packet.write_uint8( ev.key );
    17461746                                }
    17471747                        }
     
    17521752                                {
    17531753                                        if( ev.key < 256 )
    1754                                                 base->packet.write_byte( SCMD_KEYRELEASE );
     1754                                                base->packet.write_uint8( SCMD_KEYRELEASE );
    17551755                                        else
    1756                                                 base->packet.write_byte( SCMD_EXT_KEYRELEASE );
    1757                                         base->packet.write_byte( client_number() );
     1756                                                base->packet.write_uint8( SCMD_EXT_KEYRELEASE );
     1757                                        base->packet.write_uint8( client_number() );
    17581758                                        if( ev.key > 255 )
    1759                                                 base->packet.write_byte( ev.key - 256 );
     1759                                                base->packet.write_uint8( ev.key - 256 );
    17601760                                        else
    1761                                                 base->packet.write_byte( ev.key );
     1761                                                base->packet.write_uint8( ev.key );
    17621762                                }
    17631763                        }
     
    20322032
    20332033
    2034       base->packet.write_byte(SCMD_SYNC);
    2035       base->packet.write_short(make_sync());
     2034      base->packet.write_uint8(SCMD_SYNC);
     2035      base->packet.write_uint16(make_sync());
    20362036
    20372037      if (base->join_list)
    2038       base->packet.write_byte(SCMD_RELOAD);
     2038      base->packet.write_uint8(SCMD_RELOAD);
    20392039
    20402040      //      printf("save tick %d, pk size=%d, rand_on=%d, sync=%d\n",current_level->tick_counter(),
     
    20492049  if (!(dev&EDIT_MODE) && current_level)
    20502050  {
    2051     uchar buf[PACKET_MAX_SIZE+1];
     2051    uint8_t buf[PACKET_MAX_SIZE+1];
    20522052    int size;
    20532053
  • abuse/trunk/src/gamma.cpp

    r4 r17  
    220220        for( int i = 0; i < 256; i++ )
    221221        {
    222                 uchar oldr, oldg, oldb;
     222                uint8_t oldr, oldg, oldb;
    223223                old_pal->get( i, oldr, oldg, oldb );
    224224                pal->set( i, (int)( pow( oldr / 255.0, gamma ) * 255 ),
  • abuse/trunk/src/go.cpp

    r2 r17  
    6060{
    6161  load(fp,state_remap);
    62   allow_dir=read_short(fp);
     62  allow_dir=read_uint16(fp);
    6363}
    6464
     
    118118{
    119119  load(fp,state_remap); 
    120   dir=read_short(fp); 
    121   speed=read_short(fp); 
     120  dir=read_uint16(fp); 
     121  speed=read_uint16(fp); 
    122122}
    123123
     
    125125{
    126126  game_object::save(fp);
    127   write_short(fp,dir);   
    128   write_short(fp,speed);   
     127  write_uint16(fp,dir);   
     128  write_uint16(fp,speed);   
    129129}
    130130
     
    268268void sensor::save(FILE *fp)
    269269{ game_object::save(fp);
    270   write_short(fp,xrange);
    271   write_short(fp,yrange);
    272   write_short(fp,signal); 
    273 
    274   write_byte(fp,strlen(aname())+1);
     270  write_uint16(fp,xrange);
     271  write_uint16(fp,yrange);
     272  write_uint16(fp,signal); 
     273
     274  write_uint8(fp,strlen(aname())+1);
    275275  fwrite(aname(),strlen(aname())+1,1,fp); 
    276276}
     
    279279{
    280280  load(fp,state_remap);
    281   xrange=read_short(fp);
    282   yrange=read_short(fp);
    283   signal=read_short(fp); 
     281  xrange=read_uint16(fp);
     282  yrange=read_uint16(fp);
     283  signal=read_uint16(fp); 
    284284
    285285  char name[200];
    286   fread(name,read_byte(fp),1,fp);
     286  fread(name,read_uint8(fp),1,fp);
    287287  get_activate(name);
    288288}
  • abuse/trunk/src/imlib/filter.cpp

    r2 r17  
    172172{
    173173  fp->seek(e->offset,0);
    174   fp->read_short();
     174  fp->read_uint16();
    175175  int colors=32;
    176176  color_table=(unsigned char *)jmalloc(colors*colors*colors,"color_filter : loaded");
     
    187187{
    188188  int colors=32;
    189   fp->write_short(colors);
     189  fp->write_uint16(colors);
    190190  return fp->write(color_table,colors*colors*colors)==colors*colors*colors;
    191191}
     
    220220  screen->add_dirty(x,y,x+xl-1,y+yl-1);
    221221
    222   uchar *pg1=screen->scan_line(y),*source,*dest;
    223   uchar *pg2=im->scan_line(y1);
     222  uint8_t *pg1=screen->scan_line(y),*source,*dest;
     223  uint8_t *pg2=im->scan_line(y1);
    224224  int i;
    225225  for (int j=0;j<yl;j++)       
  • abuse/trunk/src/imlib/gifread.cpp

    r4 r17  
    1515
    1616struct {
    17         unsigned short int      Width;
    18         unsigned short int      Height;
    19         unsigned char   ColorMap[3][256];
    20         unsigned short int      BitPixel;
    21         unsigned short int      ColorResolution;
    22         unsigned short int      Background;
    23         unsigned short int      AspectRatio;
     17        uint16_t        Width;
     18        uint16_t        Height;
     19        uint8_t         ColorMap[3][256];
     20        uint16_t        BitPixel;
     21        uint16_t        ColorResolution;
     22        uint16_t        Background;
     23        uint16_t        AspectRatio;
    2424} GifScreen;
    2525
    2626struct {
    27   unsigned short int w,h;
    28   unsigned char color_info,background,reserved;
     27  uint16_t w,h;
     28  uint8_t color_info,background,reserved;
    2929} gif_screen;
    3030
    3131struct {
    32   unsigned short int xoff,yoff,w,h;
    33   unsigned char color_info;
     32  uint16_t xoff,yoff,w,h;
     33  uint8_t color_info;
    3434} gif_image;
    3535
     
    3737{
    3838  char buf[100],er;
    39   unsigned char sep;
     39  uint8_t sep;
    4040  unsigned int ncolors;
    4141  FILE *fp;
     
    5353      if (!strcmp("GIF87a",buf))
    5454      {
    55         fread((char *)&gif_screen.w,2,1,fp);
    56         gif_screen.w=int_to_local(gif_screen.w);
    57         fread((char *)&gif_screen.h,2,1,fp);
    58         gif_screen.h=int_to_local(gif_screen.h);
    59         fread((char *)&gif_screen.color_info,1,1,fp);
    60         fread((char *)&gif_screen.background,1,1,fp);
    61         if (fread((char *)&gif_screen.reserved,1,1,fp)==1)
     55        fread((uint8_t *)&gif_screen.w,2,1,fp);
     56        gif_screen.w=uint16_to_local(gif_screen.w);
     57        fread((uint8_t *)&gif_screen.h,2,1,fp);
     58        gif_screen.h=uint16_to_local(gif_screen.h);
     59        fread((uint8_t *)&gif_screen.color_info,1,1,fp);
     60        fread((uint8_t *)&gif_screen.background,1,1,fp);
     61        if (fread((uint8_t *)&gif_screen.reserved,1,1,fp)==1)
    6262        {
    6363          if (gif_screen.color_info&128)
     
    6969            if (pal)
    7070            { 
    71               if (fread((char *)pal->addr(),1,ncolors*3,fp)!=ncolors*3) er=imREAD_ERROR;
     71              if (fread((uint8_t *)pal->addr(),1,ncolors*3,fp)!=ncolors*3) er=imREAD_ERROR;
    7272            } else er=imMEMORY_ERROR;
    7373          }
     
    7575          { do
    7676            {
    77               if (fread((char *)&sep,1,1,fp)!=1)
     77              if (fread((uint8_t *)&sep,1,1,fp)!=1)
    7878                er=imREAD_ERROR;
    7979            } while (!er && sep!=',');
    80             fread((char *)&gif_image.xoff,2,1,fp);
    81             gif_image.xoff=int_to_local(gif_image.xoff);
    82             fread((char *)&gif_image.yoff,2,1,fp);
    83             gif_image.yoff=int_to_local(gif_image.yoff);
    84             fread((char *)&gif_image.w,2,1,fp);
    85             gif_image.w=int_to_local(gif_image.w);
    86             fread((char *)&gif_image.h,2,1,fp);
    87             gif_image.h=int_to_local(gif_image.h);
    88             if (!er && (fread((char *)&gif_image.color_info,1,1,fp)==1))
     80            fread((uint8_t *)&gif_image.xoff,2,1,fp);
     81            gif_image.xoff=uint16_to_local(gif_image.xoff);
     82            fread((uint8_t *)&gif_image.yoff,2,1,fp);
     83            gif_image.yoff=uint16_to_local(gif_image.yoff);
     84            fread((uint8_t *)&gif_image.w,2,1,fp);
     85            gif_image.w=uint16_to_local(gif_image.w);
     86            fread((uint8_t *)&gif_image.h,2,1,fp);
     87            gif_image.h=uint16_to_local(gif_image.h);
     88            if (!er && (fread((uint8_t *)&gif_image.color_info,1,1,fp)==1))
    8989            {
    9090              if (gif_image.color_info&128)
     
    9595                pal = new palette(ncolors);
    9696                if (pal)
    97                 { if (fread((char *)pal->addr(),1,ncolors*3,fp)!=ncolors*3) er=imREAD_ERROR;
     97                { if (fread((uint8_t *)pal->addr(),1,ncolors*3,fp)!=ncolors*3) er=imREAD_ERROR;
    9898                } else er=imMEMORY_ERROR;
    9999              }
  • abuse/trunk/src/imlib/glread.cpp

    r2 r17  
    99{
    1010  image *im,*sub;
    11   unsigned short length,y;
    12   unsigned char size,first,width,height,gsize,last;
     11  uint16_t length,y;
     12  uint8_t size,first,width,height,gsize,last;
    1313  FILE *fp;
    1414  fp=fopen(fn,"rb");
    1515  if (!fp) return NULL;
    16   fread(&length,1,2,fp);  length=int_to_local(length);
     16  fread(&length,1,2,fp);  length=uint16_to_local(length);
    1717  fread(&size,1,1,fp);
    1818  fread(&first,1,1,fp);
     
    4545  image *im;
    4646  char x[4],bpp;
    47   unsigned char *sl=NULL,esc,c,n,marker,vmode;
    48   unsigned short w,h,len,bufsize,blocks,sn,esize,edesc;
     47  uint8_t *sl=NULL,esc,c,n,marker,vmode;
     48  uint16_t w,h,len,bufsize,blocks,sn,esize,edesc;
    4949  int xx,yy;
    5050  FILE *fp;
     
    5555  fread(&w,1,2,fp);
    5656  fread(&h,1,2,fp);
    57   w=int_to_local(w);  h=int_to_local(h);
     57  w=uint16_to_local(w);  h=uint16_to_local(h);
    5858  fread(x,1,4,fp);
    5959  fread(&bpp,1,1,fp);
     
    6666  fread(&vmode,1,1,fp);
    6767  fread(&edesc,1,2,fp);
    68   edesc=int_to_local(edesc);
     68  edesc=uint16_to_local(edesc);
    6969  fread(&esize,1,2,fp);
    70   esize=int_to_local(esize);
     70  esize=uint16_to_local(esize);
    7171  if (esize==768 && !pal)
    7272  { pal=new palette(1<<bpp);
     
    7777    fseek(fp,esize,SEEK_CUR);
    7878  fread(&blocks,1,2,fp);
    79   blocks=int_to_local(blocks);
     79  blocks=uint16_to_local(blocks);
    8080
    8181  yy=h; xx=w;
     
    8484  {
    8585    fread(&bufsize,1,2,fp);
    86     bufsize=int_to_local(bufsize);
     86    bufsize=uint16_to_local(bufsize);
    8787    fread(&len,1,2,fp);
    88     len=int_to_local(len);
     88    len=uint16_to_local(len);
    8989    fread(&esc,1,1,fp);
    9090    while (yy>=0 && len)
     
    113113        {
    114114          fread(&sn,1,2,fp);
    115           sn=int_to_local(sn);
     115          sn=uint16_to_local(sn);
    116116          fread(&c,1,1,fp);
    117117          while (sn-- && yy>=0 && len)
  • abuse/trunk/src/imlib/image.cpp

    r2 r17  
    1212#include <stdlib.h>
    1313
    14 extern unsigned char current_background;
     14extern uint8_t current_background;
    1515char *imerr_messages[]={"No error",
    1616                        "Error occured while reading",
     
    2323                       
    2424                         
    25 short imerror=0;
    26 short swpfile_num=0;
    27 
    28 short current_error()
     25int16_t imerror=0;
     26int16_t swpfile_num=0;
     27
     28int16_t current_error()
    2929{ return imerror; }
    3030
     
    4848}
    4949
    50 void set_error(short x)
     50void set_error(int16_t x)
    5151{ imerror=x; }
    5252
    53 short last_error()
    54 {
    55   short ec;
     53int16_t last_error()
     54{
     55  int16_t ec;
    5656  ec=imerror;
    5757  imerror=0;
     
    6262
    6363
    64 image_descriptor::image_descriptor(short length, short height,
     64image_descriptor::image_descriptor(int16_t length, int16_t height,
    6565                                   int keep_dirties, int static_memory)
    6666
     
    7272}
    7373
    74 void image::change_size(short new_width, short new_height, unsigned char *page)
     74void image::change_size(int16_t new_width, int16_t new_height, uint8_t *page)
    7575{
    7676  delete_page();
     
    9797}
    9898
    99 unsigned char image::pixel(short x, short y)
     99uint8_t image::pixel(int16_t x, int16_t y)
    100100{
    101101  CONDITION(x>=0 && x<width() && y>=0 && y<height(),
     
    104104}
    105105
    106 void image::putpixel(short x, short y, char color)
     106void image::putpixel(int16_t x, int16_t y, char color)
    107107{
    108108  CONDITION(x>=0 && x<width() && y>=0 && y<height(),
     
    116116
    117117
    118 image::image(short width, short height, unsigned char *page_buffer, short create_descriptor)
     118image::image(int16_t width, int16_t height, uint8_t *page_buffer, int16_t create_descriptor)
    119119{
    120120  w=width;
     
    132132image::image(spec_entry *e, bFILE *fp)
    133133{
    134   short i;
     134  int16_t i;
    135135  fp->seek(e->offset,0);
    136   w=fp->read_short();
    137   h=fp->read_short();
     136  w=fp->read_uint16();
     137  h=fp->read_uint16();
    138138  special=NULL;
    139139  make_page(w,h,NULL);
     
    145145image::image(bFILE *fp)
    146146{
    147   short i;
    148   w=fp->read_short();
    149   h=fp->read_short();
     147  int16_t i;
     148  w=fp->read_uint16();
     149  h=fp->read_uint16();
    150150  special=NULL;
    151151  make_page(w,h,NULL);
     
    172172void image_init()
    173173{
    174   unsigned char bt[2];
    175   unsigned short wrd,*up;
     174  uint8_t bt[2];
     175  uint16_t wrd,*up;
    176176  bt[0]=1;
    177177  bt[1]=0;
    178   up=(unsigned short *)bt;
    179   wrd=int_to_intel(*up);
     178  up=(uint16_t *)bt;
     179  wrd=uint16_to_intel(*up);
    180180  if (wrd!=0x01)
    181181  { printf("Compiled under wrong ENDING-nes, edit system.h and try again\n");
     
    187187
    188188
    189 long image::total_pixels(unsigned char background)
    190 {
    191   short i,j;
    192   long co;
    193   unsigned char *c;
     189int32_t image::total_pixels(uint8_t background)
     190{
     191  int16_t i,j;
     192  int32_t co;
     193  uint8_t *c;
    194194  for (co=0,i=height()-1;i>=0;i--)
    195195  { c=scan_line(i);
     
    200200}
    201201
    202 void image::clear(short color)
    203 {
    204   short i;
     202void image::clear(int16_t color)
     203{
     204  int16_t i;
    205205  if (color==-1) color=current_background;
    206206  if (special)
     
    220220{
    221221  image *im;
    222   unsigned char *c,*dat;
     222  uint8_t *c,*dat;
    223223  int i;
    224   dat=(unsigned char *)jmalloc(width(),"image copy");
     224  dat=(uint8_t *)jmalloc(width(),"image copy");
    225225  im=new image(width(),height());
    226226  for (i=height()-1;i>=0;i--)
     
    236236
    237237
    238 void image::line(short x1, short y1,short x2, short y2, unsigned char color)
    239 {
    240   short i,xc,yc,er,n,m,xi,yi,xcxi,ycyi,xcyi;
     238void image::line(int16_t x1, int16_t y1,int16_t x2, int16_t y2, uint8_t color)
     239{
     240  int16_t i,xc,yc,er,n,m,xi,yi,xcxi,ycyi,xcyi;
    241241  unsigned dcy,dcx;
    242242  // check to make sure that both endpoint are on the screen
    243243
    244   short cx1,cy1,cx2,cy2;
     244  int16_t cx1,cy1,cx2,cy2;
    245245
    246246  // check to see if the line is completly clipped off
     
    378378
    379379
    380 void image::put_image(image *screen, short x, short y, char transparent)
    381 {
    382   short i,j,xl,yl;
    383   unsigned char *pg1,*pg2,*source,*dest;
     380void image::put_image(image *screen, int16_t x, int16_t y, char transparent)
     381{
     382  int16_t i,j,xl,yl;
     383  uint8_t *pg1,*pg2,*source,*dest;
    384384  if (screen->special)  // the screen is clipped then we onl want to put
    385385                    // part of the image
     
    417417}
    418418
    419 void image::fill_image(image *screen, short x1, short y1, short x2, short y2, short allign)
    420 {
    421   short i,j,w,xx,start,xl,starty;
    422   unsigned char *pg1,*pg2;
     419void image::fill_image(image *screen, int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t allign)
     420{
     421  int16_t i,j,w,xx,start,xl,starty;
     422  uint8_t *pg1,*pg2;
    423423  CHECK(x1<=x2 && y1<=y2);  // we should have gotten this
    424424
     
    467467
    468468
    469 void image::put_part(image *screen, short x, short y,
    470                 short x1, short y1, short x2, short y2, char transparent)
    471 {
    472   short xl,yl,j,i;
    473   short cx1,cy1,cx2,cy2;
    474   unsigned char *pg1,*pg2,*source,*dest;
     469void image::put_part(image *screen, int16_t x, int16_t y,
     470                int16_t x1, int16_t y1, int16_t x2, int16_t y2, char transparent)
     471{
     472  int16_t xl,yl,j,i;
     473  int16_t cx1,cy1,cx2,cy2;
     474  uint8_t *pg1,*pg2,*source,*dest;
    475475  CHECK(x1<=x2 && y1<=y2);
    476476
     
    533533}
    534534
    535 void image::put_part_xrev(image *screen, short x, short y,
    536                 short x1, short y1, short x2, short y2, char transparent)
    537 {
    538   short xl,yl,j,i;
    539   short cx1,cy1,cx2,cy2;
    540   unsigned char *pg1,*pg2,*source,*dest;
     535void image::put_part_xrev(image *screen, int16_t x, int16_t y,
     536                int16_t x1, int16_t y1, int16_t x2, int16_t y2, char transparent)
     537{
     538  int16_t xl,yl,j,i;
     539  int16_t cx1,cy1,cx2,cy2;
     540  uint8_t *pg1,*pg2,*source,*dest;
    541541  CHECK(x1<=x2 && y1<=y2);
    542542
     
    596596
    597597
    598 void image::put_part_masked(image *screen, image *mask, short x, short y,
    599                 short maskx, short masky,
    600                 short x1, short y1, short x2, short y2)
    601 {
    602   short xl,yl,j,i,ml,mh;
    603   short cx1,cy1,cx2,cy2;
    604   unsigned char *pg1,*pg2,*pg3;
     598void image::put_part_masked(image *screen, image *mask, int16_t x, int16_t y,
     599                int16_t maskx, int16_t masky,
     600                int16_t x1, int16_t y1, int16_t x2, int16_t y2)
     601{
     602  int16_t xl,yl,j,i,ml,mh;
     603  int16_t cx1,cy1,cx2,cy2;
     604  uint8_t *pg1,*pg2,*pg3;
    605605  CHECK(x1<=x2 && y1<=y2);
    606606
     
    658658
    659659
    660 unsigned char image::brightest_color(palette *pal)
    661 { unsigned char *p,r,g,b,bri;
    662   short i,j;
    663   long brv;
     660uint8_t image::brightest_color(palette *pal)
     661{ uint8_t *p,r,g,b,bri;
     662  int16_t i,j;
     663  int32_t brv;
    664664  brv=0; bri=0;
    665665  for (j=0;j<h;j++)
     
    668668    for (i=0;i<w;i++)
    669669    { pal->get(p[i],r,g,b);
    670       if ((long)r*(long)g*(long)b>brv)
    671       { brv=(long)r*(long)g*(long)b;
     670      if ((int32_t)r*(int32_t)g*(int32_t)b>brv)
     671      { brv=(int32_t)r*(int32_t)g*(int32_t)b;
    672672        bri=p[i];
    673673      }
     
    677677}
    678678
    679 unsigned char image::darkest_color(palette *pal, short noblack)
    680 { unsigned char *p,r,g,b,bri;
    681   short i,j;
    682   long brv,x;
    683   brv=(long)258*(long)258*(long)258; bri=0;
     679uint8_t image::darkest_color(palette *pal, int16_t noblack)
     680{ uint8_t *p,r,g,b,bri;
     681  int16_t i,j;
     682  int32_t brv,x;
     683  brv=(int32_t)258*(int32_t)258*(int32_t)258; bri=0;
    684684  for (j=0;j<h;j++)
    685685  {
     
    687687    for (i=0;i<w;i++)
    688688    { pal->get(p[i],r,g,b);
    689       x=(long)r*(long)g*(long)b;
     689      x=(int32_t)r*(int32_t)g*(int32_t)b;
    690690      if (x<brv && (x || !noblack))
    691691      { brv=x;
     
    697697}
    698698
    699 void image::rectangle(short x1, short y1,short x2, short y2, unsigned char color)
     699void image::rectangle(int16_t x1, int16_t y1,int16_t x2, int16_t y2, uint8_t color)
    700700{
    701701  line(x1,y1,x2,y1,color);
     
    705705}
    706706
    707 void image::set_clip(short x1, short y1, short x2, short y2)
     707void image::set_clip(int16_t x1, int16_t y1, int16_t x2, int16_t y2)
    708708{
    709709  // If the image does not already have an Image descriptor, allocate one.
     
    718718}
    719719
    720 void image::get_clip (short &x1, short &y1, short &x2, short &y2)
     720void image::get_clip (int16_t &x1, int16_t &y1, int16_t &x2, int16_t &y2)
    721721{
    722722  if (special)
     
    726726}
    727727
    728 void image::in_clip  (short x1, short y1, short x2, short y2)
     728void image::in_clip  (int16_t x1, int16_t y1, int16_t x2, int16_t y2)
    729729{
    730730  if (special)
     
    747747{
    748748  dirty_rect *p,*q;
    749   short x1,y1,x2,y2,nn;
     749  int16_t x1,y1,x2,y2,nn;
    750750  x1=6000; y1=6000;
    751751  x2=0; y2=0;
     
    769769void image_descriptor::delete_dirty(int x1, int y1, int x2, int y2)
    770770{
    771   short i,ax1,ay1,ax2,ay2;
     771  int16_t i,ax1,ay1,ax2,ay2;
    772772  dirty_rect *p,*next;
    773773  if (keep_dirt)
     
    869869void image_descriptor::add_dirty(int x1, int y1, int x2, int y2)
    870870{
    871   short i;
     871  int16_t i;
    872872  dirty_rect *p;
    873873  if (keep_dirt)
     
    941941}
    942942
    943 void image::bar      (short x1, short y1, short x2, short y2, unsigned char color)
    944 {
    945   short y;
     943void image::bar      (int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color)
     944{
     945  int16_t y;
    946946  if (x1>x2 || y1>y2) return ;
    947947  if (special)
     
    964964}
    965965
    966 void image::xor_bar  (short x1, short y1, short x2, short y2, unsigned char color)
    967 {
    968   short y,x;
     966void image::xor_bar  (int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color)
     967{
     968  int16_t y,x;
    969969  if (x1>x2 || y1>y2) return ;
    970970  if (special)
     
    983983    return ;
    984984
    985   unsigned char *sl=scan_line(y1)+x1;
     985  uint8_t *sl=scan_line(y1)+x1;
    986986  for (y=y1;y<=y2;y++)
    987987  {
    988     unsigned char *s=sl;
     988    uint8_t *s=sl;
    989989    for (x=x1;x<=x2;x++,s++)
    990990      *s=(*s)^color;
     
    996996
    997997
    998 void image::unpack_scanline(short line, char bitsperpixel)
    999 {
    1000   short x;
    1001   unsigned char *sl,*ex,mask,bt,sh;
    1002   ex=(unsigned char *)jmalloc(width(),"image::unpacked scanline");
     998void image::unpack_scanline(int16_t line, char bitsperpixel)
     999{
     1000  int16_t x;
     1001  uint8_t *sl,*ex,mask,bt,sh;
     1002  ex=(uint8_t *)jmalloc(width(),"image::unpacked scanline");
    10031003  sl=scan_line(line);
    10041004  memcpy(ex,sl,width());
     
    10181018void image::dither(palette *pal)
    10191019{
    1020   short x,y,i,j;
    1021   unsigned char dt_matrix[]={0,  136,24, 170,
     1020  int16_t x,y,i,j;
     1021  uint8_t dt_matrix[]={0,  136,24, 170,
    10221022                   68, 204,102,238,
    10231023                   51, 187, 17,153,
    10241024                   119,255, 85,221};
    10251025
    1026   unsigned char *sl;
     1026  uint8_t *sl;
    10271027  for (y=height()-1;y>=0;y--)
    10281028  {
     
    10491049}
    10501050
    1051 void image::resize(short new_width, short new_height)
     1051void image::resize(int16_t new_width, int16_t new_height)
    10521052{
    10531053  int old_width=width(),old_height=height();
    1054   unsigned char *im=(unsigned char *)jmalloc(width()*height(),"image::resized");
     1054  uint8_t *im=(uint8_t *)jmalloc(width()*height(),"image::resized");
    10551055  memcpy(im,scan_line(0),width()*height());
    10561056
     
    10601060  h=new_height;
    10611061
    1062   unsigned char *sl1,*sl2;
    1063   short y,y2,x2;
     1062  uint8_t *sl1,*sl2;
     1063  int16_t y,y2,x2;
    10641064  double yc,xc,yd,xd;
    10651065
     
    10801080}
    10811081
    1082 void image::scroll(short x1, short y1, short x2, short y2, short xd, short yd)
    1083 {
    1084   short cx1,cy1,cx2,cy2;
     1082void image::scroll(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t xd, int16_t yd)
     1083{
     1084  int16_t cx1,cy1,cx2,cy2;
    10851085  CHECK(x1>=0 && y1>=0 && x1<x2 && y1<y2 && x2<width() && y2<height());
    10861086  if (special)
     
    10891089    x1=max(x1,cx1); y1=max(cy1,y1); x2=min(x2,cx2); y2=min(y2,cy2);
    10901090  }
    1091   short xsrc,ysrc,xdst,ydst,xtot=x2-x1-abs(xd)+1,ytot,xt;
    1092   unsigned char *src,*dst;
     1091  int16_t xsrc,ysrc,xdst,ydst,xtot=x2-x1-abs(xd)+1,ytot,xt;
     1092  uint8_t *src,*dst;
    10931093  if (xd<0) { xsrc=x1-xd; xdst=x1; } else { xsrc=x2-xd; xdst=x2; }
    10941094  if (yd<0) { ysrc=y1-yd; ydst=y1; } else { ysrc=y2-yd; ydst=y2; }
     
    11071107
    11081108
    1109 image *image::create_smooth(short smoothness)
    1110 {
    1111   short i,j,k,l,t,d;
     1109image *image::create_smooth(int16_t smoothness)
     1110{
     1111  int16_t i,j,k,l,t,d;
    11121112  image *im;
    11131113  CHECK(smoothness>=0);
     
    11291129}
    11301130
    1131 void image::wiget_bar(short x1, short y1, short x2, short y2,
    1132         unsigned char light, unsigned char med, unsigned char dark)
     1131void image::wiget_bar(int16_t x1, int16_t y1, int16_t x2, int16_t y2,
     1132        uint8_t light, uint8_t med, uint8_t dark)
    11331133{
    11341134  line(x1,y1,x2,y1,light);
     
    11421142{
    11431143public :
    1144   short x,y;
     1144  int16_t x,y;
    11451145  fill_rec *last;
    1146   fill_rec(short X, short Y, fill_rec *Last)
     1146  fill_rec(int16_t X, int16_t Y, fill_rec *Last)
    11471147  { x=X; y=Y; last=Last; }
    11481148} ;
    11491149
    1150 void image::flood_fill(short x, short y, unsigned char color)
    1151 {
    1152   unsigned char *sl,*above,*below;
     1150void image::flood_fill(int16_t x, int16_t y, uint8_t color)
     1151{
     1152  uint8_t *sl,*above,*below;
    11531153  fill_rec *recs=NULL,*r;
    1154   unsigned char fcolor;
     1154  uint8_t fcolor;
    11551155  sl=scan_line(y);
    11561156  fcolor=sl[x];
     
    12311231#define LED_L 5
    12321232#define LED_H 5
    1233 void image::burn_led(short x, short y, long num, short color, short scale)
     1233void image::burn_led(int16_t x, int16_t y, int32_t num, int16_t color, int16_t scale)
    12341234{
    12351235  char st[100];
    1236   short ledx[]={1,2,1,2,3,3,3,3,1,2,0,0,0,0};
    1237   short ledy[]={3,3,0,0,1,2,4,6,7,7,4,6,1,2};
    1238 
    1239   short dig[]={2+4+8+16+32+64,4+8,2+4+1+32+16,2+4+1+8+16,64+1+4+8,
     1236  int16_t ledx[]={1,2,1,2,3,3,3,3,1,2,0,0,0,0};
     1237  int16_t ledy[]={3,3,0,0,1,2,4,6,7,7,4,6,1,2};
     1238
     1239  int16_t dig[]={2+4+8+16+32+64,4+8,2+4+1+32+16,2+4+1+8+16,64+1+4+8,
    12401240             2+64+1+8+16,64+32+1+8+16,2+4+8,1+2+4+8+16+32+64,64+2+4+1+8,1};
    1241   short xx,yy,zz;
    1242   sprintf(st,"%8ld",num);
     1241  int16_t xx,yy,zz;
     1242  sprintf(st,"%8ld",(long int)num);
    12431243  for (xx=0;xx<8;xx++)
    12441244  {
     
    12581258}
    12591259
    1260 unsigned char dither_matrix[]={0,  136,24, 170,
     1260uint8_t dither_matrix[]={0,  136,24, 170,
    12611261                     68, 204,102,238,
    12621262                     51, 187, 17,153,
    12631263                     119,255, 85,221};
    12641264
    1265 image *image::copy_part_dithered (short x1, short y1, short x2, short y2)
    1266 {
    1267   short x,y,cx1,cy1,cx2,cy2,ry,rx,bo,dity,ditx;
     1265image *image::copy_part_dithered (int16_t x1, int16_t y1, int16_t x2, int16_t y2)
     1266{
     1267  int16_t x,y,cx1,cy1,cx2,cy2,ry,rx,bo,dity,ditx;
    12681268  image *ret;
    1269   unsigned char *sl1,*sl2;
     1269  uint8_t *sl1,*sl2;
    12701270  get_clip(cx1,cy1,cx2,cy2);
    12711271  if (y1<cy1) y1=cy1;
     
    13041304void image::flip_x()
    13051305{
    1306   unsigned char *rev=(unsigned char *)jmalloc(width(),"image tmp::flipped_x"),*sl;
     1306  uint8_t *rev=(uint8_t *)jmalloc(width(),"image tmp::flipped_x"),*sl;
    13071307  CONDITION(rev,"memory allocation");
    13081308  int y,x,i;
     
    13181318void image::flip_y()
    13191319{
    1320   unsigned char *rev=(unsigned char *)jmalloc(width(),"image::flipped_y"),*sl;
     1320  uint8_t *rev=(uint8_t *)jmalloc(width(),"image::flipped_y"),*sl;
    13211321  CONDITION(rev,"memory allocation");
    13221322  int y;
     
    13291329}
    13301330
    1331 void image::make_color(unsigned char color)
    1332 {
    1333   unsigned char *sl;
     1331void image::make_color(uint8_t color)
     1332{
     1333  uint8_t *sl;
    13341334  int y,x;
    13351335  for (y=0;y<height();y++)
  • abuse/trunk/src/imlib/include/image.hpp

    r2 r17  
    1919#define imMAX_ERROR            7
    2020
    21 short current_error();
     21int16_t current_error();
    2222void clear_errors();
    23 void set_error(short x);
    24 short last_error();
     23void set_error(int16_t x);
     24int16_t last_error();
    2525void make_block(size_t size);
    2626void image_init();
     
    3030typedef struct image_color_t
    3131{
    32         unsigned short r;
    33         unsigned short g;
    34         unsigned short b;
     32        uint16_t r;
     33        uint16_t g;
     34        uint16_t b;
    3535} image_color;
    3636
     
    4141{
    4242public :
    43   short dx1,dy1,dx2,dy2;
    44   dirty_rect(short x1, short y1, short x2, short y2)
     43  int16_t dx1,dy1,dx2,dy2;
     44  dirty_rect(int16_t x1, int16_t y1, int16_t x2, int16_t y2)
    4545  { dx1=x1; dy1=y1; dx2=x2; dy2=y2;
    4646    if (x2<x1 || y2<y1)
    4747      printf("add inccorect dirty\n");
    4848  }
    49   virtual short compare(void *n1, short field)
     49  virtual int16_t compare(void *n1, int16_t field)
    5050  { return ((dirty_rect *)n1)->dy1>dy1; }
    5151} ;
     
    5353class image_descriptor
    5454{
    55   short l,h;
    56   short clipx1, clipy1, clipx2, clipy2;
     55  int16_t l,h;
     56  int16_t clipx1, clipy1, clipx2, clipy2;
    5757public : 
    58   unsigned char keep_dirt,
    59                 static_mem;      // if this flag is set then don't free memory on exit
     58  uint8_t keep_dirt,
     59          static_mem;      // if this flag is set then don't free memory on exit
    6060 
    6161  linked_list dirties;
    6262  void *extended_descriptor;              // type depends on current system
    6363
    64   image_descriptor(short length, short height,
     64  image_descriptor(int16_t length, int16_t height,
    6565                  int keep_dirties=1, int static_memory=0);
    66   short bound_x1(short x1)  { return x1<clipx1 ? clipx1 : x1; }
    67   short bound_y1(short y1)  { return y1<clipy1 ? clipy1 : y1; }
    68   short bound_x2(short x2)  { return x2>clipx2 ? clipx2 : x2; }
    69   short bound_y2(short y2)  { return y2>clipy2 ? clipy2 : y2; }
    70   short x1_clip() { return clipx1; }
    71   short y1_clip() { return clipy1; }
    72   short x2_clip() { return clipx2; }
    73   short y2_clip() { return clipy2; }
    74   void dirty_area(short x1, short y1, short x2, short y2) { ;}
    75   void clean_area(short x1, short y1, short x2, short y2) { ; }
     66  int16_t bound_x1(int16_t x1)  { return x1<clipx1 ? clipx1 : x1; }
     67  int16_t bound_y1(int16_t y1)  { return y1<clipy1 ? clipy1 : y1; }
     68  int16_t bound_x2(int16_t x2)  { return x2>clipx2 ? clipx2 : x2; }
     69  int16_t bound_y2(int16_t y2)  { return y2>clipy2 ? clipy2 : y2; }
     70  int16_t x1_clip() { return clipx1; }
     71  int16_t y1_clip() { return clipy1; }
     72  int16_t x2_clip() { return clipx2; }
     73  int16_t y2_clip() { return clipy2; }
     74  void dirty_area(int16_t x1, int16_t y1, int16_t x2, int16_t y2) { ;}
     75  void clean_area(int16_t x1, int16_t y1, int16_t x2, int16_t y2) { ; }
    7676  void clear_dirties();
    77   short get_dirty_area(short &x1, short &y1, short &x2, short &y2) { return 0; }
    78   void get_clip(short &x1, short &y1, short &x2, short &y2)
     77  int16_t get_dirty_area(int16_t &x1, int16_t &y1, int16_t &x2, int16_t &y2) { return 0; }
     78  void get_clip(int16_t &x1, int16_t &y1, int16_t &x2, int16_t &y2)
    7979    { x1=clipx1; y1=clipy1; x2=clipx2; y2=clipy2; }
    80   void set_clip(short x1, short y1, short x2, short y2)
     80  void set_clip(int16_t x1, int16_t y1, int16_t x2, int16_t y2)
    8181    { if (x2<x1) x2=x1;
    8282      if (y2<y1) y2=y1;
     
    8989  void add_dirty(int x1, int y1, int x2, int y2);
    9090  void delete_dirty(int x1, int y1, int x2, int y2);
    91   void resize(short length, short height)
     91  void resize(int16_t length, int16_t height)
    9292   { l=length; h=height; clipx1=0; clipy1=0; clipx2=l-1; clipy2=h-1; }
    9393} ;
     
    9595class image : public linked_node
    9696{
    97   unsigned char *data;
    98   short w,h;
    99   void make_page(short width, short height, unsigned char *page_buffer);
     97  uint8_t *data;
     98  int16_t w,h;
     99  void make_page(int16_t width, int16_t height, uint8_t *page_buffer);
    100100  void delete_page();
    101101public :
     
    103103  image(spec_entry *e, bFILE *fp);
    104104  image(bFILE *fp);
    105   image(short width, short height,                 // required
    106         unsigned char *page_buffer=NULL,
    107         short create_descriptor=0);        // 0=no, 1=yes, 2=yes & keep dirties
    108   unsigned char  pixel              (short x, short y);
    109   void           putpixel           (short x, short y, char color);
    110   unsigned char *scan_line          (short y) { return data+y*w; }
    111   unsigned char *next_line          (short lasty, unsigned char *last_scan)
     105  image(int16_t width, int16_t height,                 // required
     106        uint8_t *page_buffer=NULL,
     107        int16_t create_descriptor=0);        // 0=no, 1=yes, 2=yes & keep dirties
     108  uint8_t  pixel              (int16_t x, int16_t y);
     109  void     putpixel           (int16_t x, int16_t y, char color);
     110  uint8_t *scan_line          (int16_t y) { return data+y*w; }
     111  uint8_t *next_line          (int16_t lasty, uint8_t *last_scan)
    112112                                    { return last_scan+w; }         
    113   long           total_pixels       (unsigned char background=0);
    114   image         *copy               ();    // makes a copy of an image
    115   void           clear              (short color=-1);  // -1 is background color
    116   void           to_24bit           (palette &pal);
    117   short          width              () { return (short)w; }
    118   short          height             () { return (short)h; }
    119   void           scroll             (short x1, short y1, short x2, short y2, short xd, short yd);
    120   void           fill_image         (image *screen, short x1, short y1, short x2, short y2,
    121                                      short allign=1);
    122   void           put_image          (image *screen, short x, short y, char transparent=0);
    123   void           put_part           (image *screen, short x, short y, short x1, short y1,
    124                                      short x2, short y2, char transparent=0);
    125   void           put_part_xrev      (image *screen, short x, short y, short x1, short y1,
    126                                      short x2, short y2, char transparent=0);
    127   void           put_part_masked    (image *screen, image *mask, short x, short y,
    128                                      short maskx, short masky, short x1, short y1, short x2, short y2);
    129   image         *copy_part_dithered (short x1, short y1, short x2, short y2);
    130   void           bar                (short x1, short y1, short x2, short y2, unsigned char color);
    131   void           xor_bar            (short x1, short y1, short x2, short y2, unsigned char color);
    132   void           wiget_bar          (short x1, short y1, short x2, short y2,
    133                                      unsigned char light, unsigned char med, unsigned char dark);
    134   void           line               (short x1, short y1, short x2, short y2, unsigned char color);
    135   void           rectangle          (short x1, short y1, short x2, short y2, unsigned char color);
    136   void           burn_led           (short x, short y, long num, short color, short scale=1);
    137   void           set_clip           (short x1, short y1, short x2, short y2);
    138   void           get_clip           (short &x1,short &y1,short &x2,short &y2);
    139   void           in_clip            (short x1, short y1, short x2, short y2);
     113  int32_t  total_pixels       (uint8_t background=0);
     114  image    *copy               ();    // makes a copy of an image
     115  void     clear              (int16_t color=-1);  // -1 is background color
     116  void     to_24bit           (palette &pal);
     117  int16_t  width              () { return (int16_t)w; }
     118  int16_t  height             () { return (int16_t)h; }
     119  void     scroll             (int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t xd, int16_t yd);
     120  void     fill_image         (image *screen, int16_t x1, int16_t y1, int16_t x2, int16_t y2,
     121                              int16_t allign=1);
     122  void     put_image          (image *screen, int16_t x, int16_t y, char transparent=0);
     123  void     put_part           (image *screen, int16_t x, int16_t y, int16_t x1, int16_t y1,
     124                                     int16_t x2, int16_t y2, char transparent=0);
     125  void     put_part_xrev      (image *screen, int16_t x, int16_t y, int16_t x1, int16_t y1,
     126                                     int16_t x2, int16_t y2, char transparent=0);
     127  void     put_part_masked    (image *screen, image *mask, int16_t x, int16_t y,
     128                                     int16_t maskx, int16_t masky, int16_t x1, int16_t y1, int16_t x2, int16_t y2);
     129  image    *copy_part_dithered (int16_t x1, int16_t y1, int16_t x2, int16_t y2);
     130  void     bar                (int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color);
     131  void     xor_bar            (int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color);
     132  void     wiget_bar          (int16_t x1, int16_t y1, int16_t x2, int16_t y2,
     133                                     uint8_t light, uint8_t med, uint8_t dark);
     134  void     line               (int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color);
     135  void     rectangle          (int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t color);
     136  void     burn_led           (int16_t x, int16_t y, int32_t num, int16_t color, int16_t scale=1);
     137  void     set_clip           (int16_t x1, int16_t y1, int16_t x2, int16_t y2);
     138  void     get_clip           (int16_t &x1,int16_t &y1,int16_t &x2,int16_t &y2);
     139  void     in_clip            (int16_t x1, int16_t y1, int16_t x2, int16_t y2);
    140140
    141   void           dirt_off           () { if (special && special->keep_dirt) special->keep_dirt=0; }
    142   void           dirt_on            () { if (special) special->keep_dirt=1; }
     141  void     dirt_off           () { if (special && special->keep_dirt) special->keep_dirt=0; }
     142  void     dirt_on            () { if (special) special->keep_dirt=1; }
    143143
    144   void           add_dirty          (int x1, int y1, int x2, int y2)
     144  void     add_dirty          (int x1, int y1, int x2, int y2)
    145145                                    { if (special) special->add_dirty(x1,y1,x2,y2); }
    146   void           delete_dirty       (int x1, int y1, int x2, int y2)
     146  void     delete_dirty       (int x1, int y1, int x2, int y2)
    147147                                    { if (special) special->delete_dirty(x1,y1,x2,y2); }
    148   void           clear_dirties      () { if (special) special->clear_dirties(); }
    149   void           dither             (palette *pal); // use a b&w palette!
    150   void           resize             (short new_width, short new_height);
    151   void           change_size        (short new_width, short new_height, unsigned char *page=NULL);
    152   void           flood_fill         (short x, short y, unsigned char color);
    153   image         *create_smooth      (short smoothness=1); // 0 no smoothness
    154   void           unpack_scanline    (short line, char bitsperpixel=1);
    155   unsigned char  brightest_color    (palette *pal);
    156   void           flip_x             ();
    157   void           flip_y             ();
    158   void           make_color         (unsigned char color);
    159   unsigned char  darkest_color      (palette *pal, short noblack=0);
     148  void     clear_dirties      () { if (special) special->clear_dirties(); }
     149  void     dither             (palette *pal); // use a b&w palette!
     150  void     resize             (int16_t new_width, int16_t new_height);
     151  void     change_size        (int16_t new_width, int16_t new_height, uint8_t *page=NULL);
     152  void     flood_fill         (int16_t x, int16_t y, uint8_t color);
     153  image    *create_smooth     (int16_t smoothness=1); // 0 no smoothness
     154  void     unpack_scanline    (int16_t line, char bitsperpixel=1);
     155  uint8_t  brightest_color    (palette *pal);
     156  void     flip_x             ();
     157  void     flip_y             ();
     158  void     make_color         (uint8_t color);
     159  uint8_t  darkest_color      (palette *pal, int16_t noblack=0);
    160160
    161161  ~image();
  • abuse/trunk/src/imlib/include/jmalloc.hpp

    r2 r17  
    88enum {ALLOC_SPACE_STATIC,ALLOC_SPACE_CACHE};
    99extern int alloc_space;
    10 void *jmalloc(long size, char *what_for);
    11 void *jrealloc(void *ptr, long size, char *what_for);
     10void *jmalloc(int32_t size, char *what_for);
     11void *jrealloc(void *ptr, int32_t size, char *what_for);
    1212void jfree(void *ptr);
    1313void mem_report(char *filename);
    14 void jmalloc_init(long min_size);
     14void jmalloc_init(int32_t min_size);
    1515void jmalloc_uninit();
    16 long j_allocated();
    17 long j_available();
     16int32_t j_allocated();
     17int32_t j_available();
    1818extern void free_up_memory();
    1919#else
  • abuse/trunk/src/imlib/include/jwindow.hpp

    r2 r17  
    6969struct jwindow_properties
    7070{
    71   uchar moveable,
    72         hidden;
    73  
     71  uint8_t moveable,
     72          hidden;
    7473} ;
    7574
  • abuse/trunk/src/imlib/include/macs.hpp

    r2 r17  
    2424#endif
    2525
    26 #define uchar  unsigned char
    27 #define schar  signed char
     26//#define uchar  unsigned char
     27//#define schar  signed char
    2828//#define ushort unsigned short
    29 typedef unsigned short int ushort;
    30 #define sshort signed short
     29//typedef unsigned short int ushort;
     30//#define sshort signed short
    3131//#define ulong  unsigned long
    32 typedef unsigned long int ulong;
     32//typedef unsigned long int ulong;
    3333
    3434#endif
  • abuse/trunk/src/imlib/include/packet.hpp

    r2 r17  
    55{
    66  public :
    7   uchar *buf;
    8   long buf_size,ro,wo,rend;
     7  uint8_t *buf;
     8  int32_t buf_size,ro,wo,rend;
    99  int pre_size;
    1010  void make_bigger(int max);
     
    1212  int get_read_position() { return ro; }
    1313  void set_read_position(int x) { ro=x; }
    14   int read(uchar *buffer, int size);
    15   int write(uchar *buffer, int size);
     14  int read(uint8_t *buffer, int size);
     15  int write(uint8_t *buffer, int size);
    1616  int eop() { return ro>=rend; }
    1717  void reset();
    1818  packet(int prefix_size=2);
    1919  void get_string(char *st, int len);
    20   int advance(long offset);
     20  int advance(int32_t offset);
    2121
    22   void write_long(ulong x);      // writes can't fail...
    23   void write_short(ushort x);
    24   void write_byte(uchar x);
     22  void write_uint32(uint32_t x);      // writes can't fail...
     23  void write_uint16(uint16_t x);
     24  void write_uint8(uint8_t x);
    2525  void insert_into(packet &pk);
    2626  int size() { return rend-pre_size; }
  • abuse/trunk/src/imlib/include/scroller.hpp

    r2 r17  
    5151  protected :
    5252  int r,c,m,last_sel,cur_sel;
    53   uchar *select;
     53  uint8_t *select;
    5454  public :
    5555  spicker(int X, int Y, int ID, int Rows, int Cols, int Vert, int MultiSelect, ifield *Next);
  • abuse/trunk/src/imlib/include/specs.hpp

    r7 r17  
    9797
    9898  // these read and writes, allways read/write Intel endian-ness
    99   uint16_t read_short();
    100   uint32_t read_long();
    101   uint8_t read_byte();
     99  uint16_t read_uint16();
     100  uint32_t read_uint32();
     101  uint8_t read_uint8();
    102102  double read_double();
    103   void write_short(uint16_t x);
    104   void write_long(uint32_t x);
    105   void write_byte(uint8_t x);
     103  void write_uint16(uint16_t x);
     104  void write_uint32(uint32_t x);
     105  void write_uint8(uint8_t x);
    106106  void write_double(double x);
    107107  void set_read_buffer_size(long size);
     
    194194                         char *link_filename=NULL);*/
    195195
    196 uint16_t read_short(FILE *fp);
    197 uint32_t read_long(FILE *fp);
    198 uint32_t read_other_long(FILE *fp);
    199 uint16_t read_other_short(FILE *fp);
    200 uint8_t read_byte(FILE *fp);
    201 
    202 void write_short(FILE *fp, uint16_t x);
    203 void write_long(FILE *fp, uint32_t x);
    204 void write_other_short(FILE *fp, uint16_t x);
    205 void write_other_long(FILE *fp, uint32_t x);
    206 void write_byte(FILE *fp, uint8_t x);
     196uint16_t read_uint16(FILE *fp);
     197uint32_t read_uint32(FILE *fp);
     198uint32_t read_other_uint32(FILE *fp);
     199uint16_t read_other_uint16(FILE *fp);
     200uint8_t read_uint8(FILE *fp);
     201
     202void write_uint16(FILE *fp, uint16_t x);
     203void write_uint32(FILE *fp, uint32_t x);
     204void write_other_uint16(FILE *fp, uint16_t x);
     205void write_other_uint32(FILE *fp, uint32_t x);
     206void write_uint8(FILE *fp, uint8_t x);
    207207
    208208void set_spec_main_file(char *filename, int Search_order);
  • abuse/trunk/src/imlib/include/system.h

    r7 r17  
    3030
    3131
    32 #define short_swap(x) (((((uint16_t) (x)))<<8)|((((uint16_t) (x)))>>8))
    33 #define long_swap(x) \
     32#define uint16_swap(x) (((((uint16_t) (x)))<<8)|((((uint16_t) (x)))>>8))
     33#define uint32_swap(x) \
    3434   ((( ((uint32_t)(x)) )>>24)|((( ((uint32_t)(x)) )&0x00ff0000)>>8)| \
    3535   ((( ((uint32_t)(x)) )&0x0000ff00)<<8)|(( ((uint32_t)(x)) )<<24))
     
    3737#if defined BIG_ENDIANS
    3838#define LONG int32_t
    39 #define int_to_intel(x) short_swap(x)
    40 #define int_to_local(x) int_to_intel(x)
    41 #define big_long_to_local(x) (x)
    42 #define big_short_to_local(x) (x)
    43 #define long_to_intel(x) long_swap(x)
    44 #define long_to_local(x) long_to_intel(x)
     39#define uint16_to_intel(x) uint16_swap(x)
     40#define uint16_to_local(x) uint16_to_intel(x)
     41#define big_uint32_to_local(x) (x)
     42#define big_uint16_to_local(x) (x)
     43#define uint32_to_intel(x) uint32_swap(x)
     44#define uint32_to_local(x) uint32_to_intel(x)
    4545#else
    4646#define LONG int32_t
    47 #define int_to_intel(x) (x)
    48 #define int_to_local(x) (x)
    49 #define long_to_local(x) (x)
    50 #define long_to_intel(x) (x)
    51 #define big_long_to_local(x) long_swap(x)
    52 #define big_short_to_local(x) short_swap(x)
     47#define uint16_to_intel(x) (x)
     48#define uint16_to_local(x) (x)
     49#define uint32_to_local(x) (x)
     50#define uint32_to_intel(x) (x)
     51#define big_uint32_to_local(x) uint32_swap(x)
     52#define big_uint16_to_local(x) uint16_swap(x)
    5353#endif
    5454
    55 #define bltl(x) big_long_to_local(x)
    56 #define bstl(x) big_short_to_local(x)
    57 #define lltl(x) long_to_intel(x)
    58 #define lstl(x) int_to_intel(x)
     55#define bltl(x) big_uint32_to_local(x)
     56#define bstl(x) big_uint16_to_local(x)
     57#define lltl(x) uint32_to_intel(x)
     58#define lstl(x) uint16_to_intel(x)
    5959
    6060#endif
  • abuse/trunk/src/imlib/include/timage.hpp

    r2 r17  
    2828  // if screen x & y offset already calculated save a mul
    2929  // and no clipping, but fast use this
    30   void put_image_offseted(image *screen, uchar *s_off);   
     30  void put_image_offseted(image *screen, uint8_t *s_off);   
    3131  void put_image_filled(image *screen, int x, int y,
    32                         uchar fill_color);
     32                        uint8_t fill_color);
    3333  void put_fade(image *screen, int x, int y,
    3434                           int frame_on, int total_frames,
     
    3636  void put_fade_tint(image *screen, int x, int y,
    3737                     int frame_on, int total_frames,
    38                      uchar *tint,
     38                     uint8_t *tint,
    3939                     color_filter *f, palette *pal);
    4040  void put_color(image *screen, int x, int y, int color);
  • abuse/trunk/src/imlib/jmalloc.cpp

    r8 r17  
    1313
    1414#include "jmalloc.hpp"
    15 #define uchar unsigned char
    1615#define JM_SMALL_SIZE 128      // above 128 bytes is considered to be a big block and no hashing is done
    1716int alloc_space=ALLOC_SPACE_STATIC;
     
    2928struct memory_node
    3029{
    31   long size;
     30  int32_t size;
    3231#ifdef MEM_CHECK
    3332  char *name;                     // name is allocated on regular heap
     
    4039struct small_block
    4140
    42   unsigned long size;             // size of blocks...
     41  uint32_t size;             // size of blocks...
    4342  uint32_t alloc_list;            // bit field saying weither each block is allocated or not.
    4443  small_block *next;              // next small block of same size
     
    5453  public :
    5554
    56   long block_size;                             // size of this memory_block
     55  int32_t block_size;                             // size of this memory_block
    5756  small_block *sblocks[JM_SMALL_SIZE];
    5857  small_block *cblocks[JM_SMALL_SIZE];
     
    6160  memory_node *sfirst,*slast,
    6261              *cfirst;
    63   unsigned char block_type;
    64 
    65   void init(void *block, long Block_size, uchar type);
    66   void *static_alloc(long size, char *name);
    67   void *cache_alloc(long size, char *name);
     62  uint8_t block_type;
     63
     64  void init(void *block, int32_t Block_size, uint8_t type);
     65  void *static_alloc(int32_t size, char *name);
     66  void *cache_alloc(int32_t size, char *name);
    6867  void static_free(void *ptr);
    6968  void cache_free(void *ptr);
    70   long available();
    71   long allocated();
    72   long pointer_size(void *ptr);
     69  int32_t available();
     70  int32_t allocated();
     71  int32_t pointer_size(void *ptr);
    7372  void report(FILE *fp);
    7473  void inspect();
     
    9089int block_manager::valid_static_ptr(void *ptr)
    9190{
    92   void *next=(void *)(*(((long *)ptr)-1));
     91  void *next=(void *)(*(((int32_t *)ptr)-1));
    9392  if (next && ((small_block *)next)->size<JM_SMALL_SIZE)  // small allocation
    9493  {
     
    111110int block_manager::valid_cache_ptr(void *ptr)
    112111{
    113   void *next=(void *)(*(((long *)ptr)-1));
     112  void *next=(void *)(*(((int32_t *)ptr)-1));
    114113  if (next && ((small_block *)next)->size<JM_SMALL_SIZE)  // small allocation
    115114  {
     
    274273}
    275274
    276 long block_manager::pointer_size(void *ptr)
     275int32_t block_manager::pointer_size(void *ptr)
    277276{
    278277  void *next=(void *)(*(((intptr_t *)ptr)-1));
     
    282281}
    283282
    284 long block_manager::available()
    285 {
    286   long size=0;
     283int32_t block_manager::available()
     284{
     285  int32_t size=0;
    287286  memory_node *f;
    288287  for (f=sfirst;f;f=f->next)
     
    294293}
    295294
    296 long block_manager::allocated()
    297 {
    298   long size=0;
     295int32_t block_manager::allocated()
     296{
     297  int32_t size=0;
    299298  memory_node *f;
    300299  for (f=sfirst;f;f=f->next)
     
    306305}
    307306
    308 void block_manager::init(void *block, long Block_size, uchar type)
     307void block_manager::init(void *block, int32_t Block_size, uint8_t type)
    309308{
    310309  block_size=Block_size;
     
    326325}
    327326
    328 void *block_manager::static_alloc(long size, char *name)
     327void *block_manager::static_alloc(int32_t size, char *name)
    329328{
    330329  if (size<JM_SMALL_SIZE)
     
    345344        break_mem_fun();
    346345#endif     
    347       long *addr=(long *)(((char *)s)+sizeof(small_block));
    348       *addr=(long)s;
     346      intptr_t *addr=(intptr_t *)(((char *)s)+sizeof(small_block));
     347      *addr=(intptr_t)s;
    349348      return (void *)(addr+1);  // return first block
    350349    } else
     
    360359          s->name[i]=strcpy((char *)malloc(strlen(name)+1),name);
    361360#endif           
    362           *((long *)addr)=(long)s;
     361          *((intptr_t *)addr)=(intptr_t)s;
    363362
    364363#ifdef MEM_CHECK
     
    406405
    407406
    408 void *block_manager::cache_alloc(long size, char *name)
     407void *block_manager::cache_alloc(int32_t size, char *name)
    409408{
    410409  if (size<JM_SMALL_SIZE)
     
    424423
    425424#endif     
    426       long *addr=(long *)(((char *)s)+sizeof(small_block));
    427       *addr=(long)s;
     425      intptr_t *addr=(intptr_t *)(((char *)s)+sizeof(small_block));
     426      *addr=(intptr_t)s;
    428427#ifdef MEM_CHECK
    429428      if ((intptr_t)s==break_mem_point)
     
    445444            break_mem_fun();
    446445#endif           
    447           *((long *)addr)=(long)s;
     446          *((intptr_t *)addr)=(intptr_t)s;
    448447          return (void *)(addr+4);
    449448        }
     
    461460  if (!s) // no current cache space for object, see if we can enlarge the cache space
    462461  {
    463     long size_avail=-slast->size;
     462    int32_t size_avail=-slast->size;
    464463    size_avail-=sizeof(memory_node);
    465464
     
    491490  {
    492491    memory_node *p=s;    // store this position
    493     long psize=s->size-size-sizeof(memory_node);
     492    int32_t psize=s->size-size-sizeof(memory_node);
    494493    s=(memory_node *)(((char *)s)+psize+sizeof(memory_node));
    495494    p->size=-psize;
     
    515514{
    516515  // see if this was a small_block allocation
    517   void *next=(void *)(*(((long *)ptr)-1));
     516  void *next=(void *)(*(((int32_t *)ptr)-1));
    518517  if (next && ((small_block *)next)->size<JM_SMALL_SIZE)  // small allocation
    519518  {
     
    598597{
    599598  // see if this was a small_block allocation
    600   void *next=(void *)(*(((long *)ptr)-1));
     599  void *next=(void *)(*(((int32_t *)ptr)-1));
    601600  if (next && next<ptr)  // small allocation
    602601  {
     
    696695                                   "    - add memory to your system\n";
    697696
    698 void jmalloc_init(long min_size)
     697void jmalloc_init(int32_t min_size)
    699698{
    700699  fprintf(stderr,"Disabling memory manager, using libc instead\n");
     
    709708
    710709#ifdef __POWERPC__
    711     long size=jmalloc_max_size-0x10000;
     710    int32_t size=jmalloc_max_size-0x10000;
    712711    for (mem=NULL;!mem && size>0x10000;)
    713712    {
     
    718717    mem = malloc(size);
    719718#else
    720     long size=jmalloc_max_size;
     719    int32_t size=jmalloc_max_size;
    721720    for (mem=NULL;!mem && size>0x4000;)
    722721    {
     
    768767
    769768
    770 long j_available()
    771 {
    772   long size=0;
     769int32_t j_available()
     770{
     771  int32_t size=0;
    773772  for (int i=0;i<bmanage_total;i++)
    774773    size+=bmanage[i].available();
     
    776775}
    777776
    778 long j_allocated()
    779 {
    780   long size=0;
     777int32_t j_allocated()
     778{
     779  int32_t size=0;
    781780  for (int i=0;i<bmanage_total;i++)
    782781    size+=bmanage[i].allocated();
     
    785784
    786785
    787 void *jmalloc(long size, char *name)
     786void *jmalloc(int32_t size, char *name)
    788787
    789788  if (!bmanage_total)
     
    838837
    839838
    840 void *jrealloc(void *ptr, long size, char *name)
     839void *jrealloc(void *ptr, int32_t size, char *name)
    841840
    842841  if (!ptr) return jmalloc(size,name);
     
    845844  if (size==0) { jfree(ptr); return NULL; }
    846845
    847   long old_size=0;
     846  int32_t old_size=0;
    848847  for (int i=0;i<bmanage_total;i++)
    849848    if (ptr>=(void *)bmanage[i].sfirst &&
     
    912911
    913912
    914 long small_ptr_size(void *ptr)
    915 {
    916   return ((small_block *)(((long *)ptr)[-1]))->size;
     913int32_t small_ptr_size(void *ptr)
     914{
     915  return ((small_block *)(((int32_t *)ptr)[-1]))->size;
    917916}
    918917
  • abuse/trunk/src/imlib/lbmread.cpp

    r4 r17  
    2020  else
    2121  {
    22     long size=read_other_long(fp);
     22    int32_t size=read_other_uint32(fp);
    2323    fread(type,1,4,fp);   
    2424    if (memcmp(type,"PBM ",4))
     
    3030    else
    3131    {
    32       long ssize;   
     32      int32_t ssize;   
    3333      char stype[4];
    34       short w=0,h=0,x,y,tcolor,pagew,pageh;
     34      int16_t w=0,h=0,x,y,tcolor,pagew,pageh;
    3535      char planes,masking,compr=0,padl,xa,ya;
    3636     
     
    3838      {
    3939        fread(stype,1,4,fp);
    40         ssize=read_other_long(fp);
     40        ssize=read_other_uint32(fp);
    4141        if (ssize &1) ssize++;            // specs say all chunks are padded by 2
    4242        if (!memcmp(stype,"BMHD",4))
    4343        {
    44           w=read_other_short(fp);
    45           h=read_other_short(fp);
    46           x=read_other_short(fp);
    47           y=read_other_short(fp);
     44          w=read_other_uint16(fp);
     45          h=read_other_uint16(fp);
     46          x=read_other_uint16(fp);
     47          y=read_other_uint16(fp);
    4848          planes=fgetc(fp);
    4949          masking=fgetc(fp);
    5050          compr=fgetc(fp);
    5151          padl=fgetc(fp);
    52           tcolor=read_other_short(fp);
     52          tcolor=read_other_uint16(fp);
    5353          xa=fgetc(fp);
    5454          ya=fgetc(fp);
    55           pagew=read_other_short(fp);
    56           pageh=read_other_short(fp);
     55          pagew=read_other_uint16(fp);
     56          pageh=read_other_uint16(fp);
    5757        } else if (!memcmp(stype,"CMAP",4))
    5858        {
  • abuse/trunk/src/imlib/mdlread.cpp

    r2 r17  
    1111// images.  All images should be sized so they will fit on an mdl screen
    1212// but no checking of that is done hhere.
    13 void write_mdl(image **images, short total_images, palette *pal,char *fn,
    14                 short firstpage, short images_per_page)
     13void write_mdl(image **images, int16_t total_images, palette *pal,char *fn,
     14                int16_t firstpage, int16_t images_per_page)
    1515{
    1616  FILE *fp;
    1717  char buf[18];
    18   unsigned short xy[2],x;
     18  uint16_t xy[2],x;
    1919  char name[13],page;
    2020  unsigned char *c;
    21   short i;
     21  int16_t i;
    2222  palette *np;
    2323  clear_errors();
     
    4343      memset(buf,0,6);            // each image has 6 bytes of reserved 0
    4444      fwrite(buf,6,1,fp);
    45       xy[0]=int_to_intel(i%100+20); xy[1]=int_to_intel(30);  // the x and y position on the screen
     45      xy[0]=uint16_to_intel(i%100+20); xy[1]=uint16_to_intel(30);  // the x and y position on the screen
    4646      fwrite(xy,4,1,fp);
    4747      sprintf(name,"JC%-10d",i);  // set the name of the image
     
    5151
    5252      fwrite(&page,1,1,fp);         // put all of the image on the first page
    53       xy[0]=int_to_intel(images[i]->width()*images[i]->height()+4);  // calc the size of the image
     53      xy[0]=uint16_to_intel(images[i]->width()*images[i]->height()+4);  // calc the size of the image
    5454   
    5555      fwrite(xy,2,1,fp);
    56       xy[0]=int_to_intel(images[i]->width());
     56      xy[0]=uint16_to_intel(images[i]->width());
    5757      fwrite(xy,2,1,fp);
    58       xy[0]=int_to_intel(images[i]->height());
     58      xy[0]=uint16_to_intel(images[i]->height());
    5959      fwrite(xy,2,1,fp);
    60       for (x=0;x<(unsigned short)images[i]->height();x++)   // write all the scan_lines for the
     60      for (x=0;x<(uint16_t)images[i]->height();x++)   // write all the scan_lines for the
    6161      { c=images[i]->scan_line(x);            // image
    6262        fwrite(c,images[i]->width(),1,fp);
     
    6767}
    6868
    69 short mdl_total_images(char *fn)
     69int16_t mdl_total_images(char *fn)
    7070{
    7171  char buf[800];
    72   unsigned short xy[2],t;
     72  uint16_t xy[2],t;
    7373  FILE *fp;
    7474  fp=fopen(fn,"rb");
     
    9292    {
    9393      fread(xy,2,1,fp);
    94       xy[0]=int_to_local(xy[0]);
     94      xy[0]=uint16_to_local(xy[0]);
    9595      fseek(fp,xy[0],SEEK_CUR);
    9696      t++;
     
    104104// and a palette that is read form the file
    105105// to load image numbers 4 through 9 let start =4, end=9
    106 image **read_mdl(char *fn, palette *&pal, short startn, short endn, short &total)
     106image **read_mdl(char *fn, palette *&pal, int16_t startn, int16_t endn, int16_t &total)
    107107{
    108108  FILE *fp;
    109109  image **im;
    110110  char buf[50];
    111   unsigned short xy[2],i,j;
     111  uint16_t xy[2],i,j;
    112112  clear_errors();
    113113  make_block(sizeof(FILE));
     
    147147          set_error(imFILE_CORRUPTED);
    148148        fread(xy,2,1,fp);
    149         xy[0]=int_to_local(xy[0]);
     149        xy[0]=uint16_to_local(xy[0]);
    150150        fseek(fp,xy[0],SEEK_CUR);
    151151        startn--; if (endn>0) endn--;
     
    161161          else
    162162          {
    163             j=int_to_local(j);
     163            j=uint16_to_local(j);
    164164            j-=4;
    165165            xy[0]=5; xy[1]=5;
    166166            if (fread(xy,1,4,fp)!=4) set_error(imFILE_CORRUPTED);
    167167            make_block(sizeof(image));
    168             xy[0]=int_to_local(xy[0]);
    169             xy[1]=int_to_local(xy[1]);
     168            xy[0]=uint16_to_local(xy[0]);
     169            xy[1]=uint16_to_local(xy[1]);
    170170            im[startn]=new image(xy[0],xy[1]);
    171171            total++;
  • abuse/trunk/src/imlib/morph.cpp

    r2 r17  
    355355    for (i=0;i<total;i++)
    356356    {
    357       ((morph_point16 *)p+i)->x1=fp->read_short();
    358       ((morph_point16 *)p+i)->y1=fp->read_short();
    359       ((morph_point16 *)p+i)->x2=fp->read_short();
    360       ((morph_point16 *)p+i)->y2=fp->read_short();
     357      ((morph_point16 *)p+i)->x1=fp->read_uint16();
     358      ((morph_point16 *)p+i)->y1=fp->read_uint16();
     359      ((morph_point16 *)p+i)->x2=fp->read_uint16();
     360      ((morph_point16 *)p+i)->y2=fp->read_uint16();
    361361      fp->read( &((morph_point16 *)p+i)->start_color,1);
    362362      fp->read( &((morph_point16 *)p+i)->end_color,1);
     
    365365    small=0;
    366366  }
    367   w[0]=fp->read_short();
    368   h[0]=fp->read_short(); 
    369   w[1]=fp->read_short();
    370   h[1]=fp->read_short();
     367  w[0]=fp->read_uint16();
     368  h[0]=fp->read_uint16(); 
     369  w[1]=fp->read_uint16();
     370  h[1]=fp->read_uint16();
    371371}
    372372
     
    678678
    679679 
    680   fp->write_long(total); 
     680  fp->write_uint32(total); 
    681681  if (small)
    682682  {
     
    691691  {
    692692    for (i=0;i<total;i++)
    693     { fp->write_short(((morph_point16 *)p+i)->x1);
    694       fp->write_short(((morph_point16 *)p+i)->y1);
    695       fp->write_short(((morph_point16 *)p+i)->x2);
    696       fp->write_short(((morph_point16 *)p+i)->y2);
     693    { fp->write_uint16(((morph_point16 *)p+i)->x1);
     694      fp->write_uint16(((morph_point16 *)p+i)->y1);
     695      fp->write_uint16(((morph_point16 *)p+i)->x2);
     696      fp->write_uint16(((morph_point16 *)p+i)->y2);
    697697      fp->write( &((morph_point16 *)p+i)->start_color,1);
    698698      fp->write( &((morph_point16 *)p+i)->end_color,1);
    699699    }
    700700  }
    701   fp->write_short(w[0]);
    702   fp->write_short(h[0]);
    703   fp->write_short(w[1]);
    704   fp->write_short(h[1]);
     701  fp->write_uint16(w[0]);
     702  fp->write_uint16(h[0]);
     703  fp->write_uint16(w[1]);
     704  fp->write_uint16(h[1]);
    705705  return 1;
    706706}
     
    877877  int i;
    878878 
    879   patches=fp->read_short();
     879  patches=fp->read_uint16();
    880880  pats=(morph_patch *)jmalloc(sizeof(morph_patch)*patches,"patched_morph::points");
    881881 
    882882  for (i=0;i<patches;i++)
    883883  {
    884     pats[i].patches=fp->read_short();
     884    pats[i].patches=fp->read_uint16();
    885885    if (pats[i].patches)
    886886    {     
  • abuse/trunk/src/imlib/packet.cpp

    r2 r17  
    55
    66
    7 int packet::advance(long offset)
     7int packet::advance(int32_t offset)
    88{
    99  ro+=offset;
     
    1111}
    1212
    13 void packet::write_long(ulong x)
     13void packet::write_uint32(uint32_t x)
    1414{
    1515  x=lltl(x);
    16   write((uchar *)&x,4);
     16  write((uint8_t *)&x,4);
    1717}
    1818
    19 void packet::write_short(ushort x)
     19void packet::write_uint16(uint16_t x)
    2020{
    2121  x=lstl(x);
    22   write((uchar *)&x,2);
     22  write((uint8_t *)&x,2);
    2323}
    2424
    25 void packet::write_byte(uchar x)
     25void packet::write_uint8(uint8_t x)
    2626{
    2727  write(&x,1);
     
    4141
    4242  buf_size=1000;
    43   buf=(uchar *)jmalloc(buf_size,"packet buffer");
     43  buf=(uint8_t *)jmalloc(buf_size,"packet buffer");
    4444  reset();
    4545
     
    7272  {
    7373    buf_size=max;
    74     buf=(uchar *)jrealloc(buf,max,"packet buffer");
     74    buf=(uint8_t *)jrealloc(buf,max,"packet buffer");
    7575  }
    7676}
    7777
    78 int packet::read(uchar *buffer, int size)
     78int packet::read(uint8_t *buffer, int size)
    7979{
    8080  if (size>rend-ro)
     
    9090
    9191
    92 int packet::write(uchar *buffer, int size)
     92int packet::write(uint8_t *buffer, int size)
    9393{
    9494  if (size>buf_size-wo)
  • abuse/trunk/src/imlib/palette.cpp

    r15 r17  
    1212palette::palette(bFILE *fp)
    1313{
    14   ncolors=fp->read_short();
     14  ncolors=fp->read_uint16();
    1515  pal=(color *)jmalloc(sizeof(color)*ncolors,"palette");
    1616  usd=(unsigned char *)jmalloc(ncolors/8+1,"palette used array");
     
    2323{
    2424  fp->seek(e->offset,0);
    25   ncolors=fp->read_short();
     25  ncolors=fp->read_uint16();
    2626  pal=(color *)jmalloc(sizeof(color)*ncolors,"palette");
    2727  usd=(unsigned char *)jmalloc(ncolors/8+1,"palette used array");
     
    3838int palette::write(bFILE *fp)
    3939{
    40   fp->write_short(ncolors);
     40  fp->write_uint16(ncolors);
    4141  return fp->write(pal,sizeof(color)*ncolors)==ncolors;
    4242}
  • abuse/trunk/src/imlib/pcxread.cpp

    r2 r17  
    1818  if (!fread(&PCX_header.encoding,1,1,fp)) return 0; 
    1919  if (!fread(&PCX_header.bits_per_pixel,1,1,fp)) return 0; 
    20   PCX_header.xmin=read_short(fp);
    21   PCX_header.ymin=read_short(fp); 
    22   PCX_header.xmax=read_short(fp);
    23   PCX_header.ymax=read_short(fp);
    24   PCX_header.hres=read_short(fp);
    25   PCX_header.vres=read_short(fp);
     20  PCX_header.xmin=read_uint16(fp);
     21  PCX_header.ymin=read_uint16(fp); 
     22  PCX_header.xmax=read_uint16(fp);
     23  PCX_header.ymax=read_uint16(fp);
     24  PCX_header.hres=read_uint16(fp);
     25  PCX_header.vres=read_uint16(fp);
    2626  if (!fread(PCX_header.palette,1,48,fp)) return 0;
    2727  if (!fread(&PCX_header.reserved,1,1,fp)) return 0;
    2828  if (!fread(&PCX_header.color_planes,1,1,fp)) return 0;
    29   PCX_header.bytes_per_line=read_short(fp);
    30   PCX_header.palette_type=read_short(fp);
     29  PCX_header.bytes_per_line=read_uint16(fp);
     30  PCX_header.palette_type=read_uint16(fp);
    3131  if (!fread(PCX_header.filter,1,58,fp)) return 0;
    3232  return 1;
     
    3939  if (!fwrite(&PCX_header.encoding,1,1,fp)) return 0; 
    4040  if (!fwrite(&PCX_header.bits_per_pixel,1,1,fp)) return 0; 
    41   write_short(fp,PCX_header.xmin);
    42   write_short(fp,PCX_header.ymin); 
    43   write_short(fp,PCX_header.xmax);
    44   write_short(fp,PCX_header.ymax);
    45   write_short(fp,PCX_header.hres);
    46   write_short(fp,PCX_header.vres);
     41  write_uint16(fp,PCX_header.xmin);
     42  write_uint16(fp,PCX_header.ymin); 
     43  write_uint16(fp,PCX_header.xmax);
     44  write_uint16(fp,PCX_header.ymax);
     45  write_uint16(fp,PCX_header.hres);
     46  write_uint16(fp,PCX_header.vres);
    4747  if (!fwrite(PCX_header.palette,1,48,fp)) return 0;
    4848  if (!fwrite(&PCX_header.reserved,1,1,fp)) return 0;
    4949  if (!fwrite(&PCX_header.color_planes,1,1,fp)) return 0;
    50   write_short(fp,PCX_header.bytes_per_line);
    51   write_short(fp,PCX_header.palette_type);
     50  write_uint16(fp,PCX_header.bytes_per_line);
     51  write_uint16(fp,PCX_header.palette_type);
    5252  if (!fwrite(PCX_header.filter,1,58,fp)) return 0;
    5353  return 1;
  • abuse/trunk/src/imlib/readwav.cpp

    r2 r17  
    3838{
    3939  fp->read(&chunk.id,4);
    40   chunk.size=fp->read_long();
     40  chunk.size=fp->read_uint32();
    4141  fp->read(&chunk.type,4); 
    4242}
     
    4545{
    4646  fp->read(&tag.id,4);
    47   tag.size=fp->read_long();
     47  tag.size=fp->read_uint32();
    4848}
    4949
    5050void read_wav_format(wav_format &fmt, bFILE *fp)
    5151{
    52   fmt.fmt_tag=fp->read_short();
    53   fmt.channels=fp->read_short();
    54   fmt.samplesps=fp->read_long();
    55   fmt.avg_bytesps=fp->read_long(); 
    56   fmt.align=fp->read_short(); 
     52  fmt.fmt_tag=fp->read_uint16();
     53  fmt.channels=fp->read_uint16();
     54  fmt.samplesps=fp->read_uint32();
     55  fmt.avg_bytesps=fp->read_uint32(); 
     56  fmt.align=fp->read_uint16(); 
    5757}
    5858
     
    6161{
    6262  read_wav_format(pcm.wf,fp);
    63   pcm.bitsps=fp->read_short(); 
     63  pcm.bitsps=fp->read_uint16(); 
    6464}
    6565
     
    7878  /***************  Write the chunk ***************************/
    7979  fp->write((void *)"RIFF",4); 
    80   fp->write_long(data_size+36);
     80  fp->write_uint32(data_size+36);
    8181  fp->write((void *)"WAVE",4);
    8282
     
    8484  /************** Write the tag *******************************/
    8585  fp->write((void *)"fmt ",4);
    86   fp->write_long(16);
     86  fp->write_uint32(16);
    8787 
    8888 
    8989  /************** Write PCM ***********************************/
    90   fp->write_short(1);          // format_tag
    91   fp->write_short(1);          // mono recording
    92   fp->write_long(sample_rate);
    93   fp->write_long(sample_rate);   // average bytes per sec
    94   fp->write_short(1);    // allignment? Don't know what this does?
    95   fp->write_short(8);    // 8 bits per sample
     90  fp->write_uint16(1);          // format_tag
     91  fp->write_uint16(1);          // mono recording
     92  fp->write_uint32(sample_rate);
     93  fp->write_uint32(sample_rate);   // average bytes per sec
     94  fp->write_uint16(1);    // allignment? Don't know what this does?
     95  fp->write_uint16(8);    // 8 bits per sample
    9696 
    9797  /************* Write data tag ******************************/
    9898  fp->write((void *)"data",4);
    99   fp->write_long(data_size);
     99  fp->write_uint32(data_size);
    100100
    101101  /************ Now write sample data ************************/
  • abuse/trunk/src/imlib/readxwd.cpp

    r2 r17  
    106106
    107107
    108 int bs_int(int s);
    109 long bs_long(long s);
    110 short bs_short(short s );
     108int32_t bs_int32(int32_t s);
     109int16_t bs_int16(int16_t s );
    111110
    112111
     
    325324
    326325
    327 short bs_short(short s )
     326short bs_int16(short s )
    328327{
    329328  short ss;
     
    338337}
    339338
    340 int bs_int(int i )
    341 {
    342   int ii;
    343   unsigned char *bp, t;
     339int32_t bs_int32(int32_t l )
     340{
     341  int32_t ii;
     342  uint8_t *bp, t;
    344343
    345344  ii = i;
    346   bp = (unsigned char *) &ii;
     345  bp = (uint8_t *) &ii;
    347346  t = bp[0];
    348347  bp[0] = bp[3];
     
    352351  bp[2] = t;
    353352  return ii;
    354 }
    355 
    356 long bs_long(long l )
    357 {
    358   return bs_int( l );
    359353}
    360354
     
    374368  FILE *fp;
    375369  int i,bytes;
    376   unsigned char pal_quad[4];
     370  uint8_t pal_quad[4];
    377371//  fp=fopen("d:\\windows\\256color.bmp","rb");
    378372//  fread(&bmp,1,sizeof(bmp),fp);
     
    411405{
    412406  image *ni;
    413   unsigned char *sl1,*sl2;
     407  uint8_t *sl1,*sl2;
    414408  int i,x;
    415   unsigned char r,g,b;
     409  uint8_t r,g,b;
    416410  printf("Creating image size (%d, %d)\n",im->width()*3,im->height());
    417411  ni=new image(im->width()*3,im->height());
     
    429423}
    430424
    431 unsigned char addb(int n1, int n2)
     425uint8_t addb(int n1, int n2)
    432426{ int n3;
    433427  n3=n1+n2;
     
    441435{
    442436  image *i24;
    443   unsigned char min[3],max[3],mid[3],*ad,*sl,*sl2,crimp;
     437  uint8_t min[3],max[3],mid[3],*ad,*sl,*sl2,crimp;
    444438  int i,j,x,y,delta;
    445439  (void *)ad=pal->addr();
     
    523517  image *im,*i24;
    524518  palette *pal;
    525   unsigned char *sl;
     519  uint8_t *sl;
    526520  FILE *fp;
    527521  char def_name[10],*dev_name,*fname=NULL;
    528   unsigned char cp[500],mp[500],yp[500],kp[500];
     522  uint8_t cp[500],mp[500],yp[500],kp[500];
    529523  strcpy(def_name,"\\dev\\lp");  // set the default output device to /dev/lp
    530524                // since we are in vpix, however we will use the backslash
  • abuse/trunk/src/imlib/scroller.cpp

    r4 r17  
    44
    55
    6 unsigned char hs_left_arrow[10*8]={
     6uint8_t hs_left_arrow[10*8]={
    77    0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0,
    88    0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0,
     
    1313
    1414
    15 unsigned char hs_right_arrow[10*8]={
     15uint8_t hs_right_arrow[10*8]={
    1616    0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
    1717    0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0,
     
    2222
    2323
    24 unsigned char vs_up_arrow[8*10]={
     24uint8_t vs_up_arrow[8*10]={
    2525    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0,
    2626    0, 0, 0, 1, 1, 1, 1, 2, 0, 0, 1, 2, 1, 1, 2,
     
    3131
    3232
    33 unsigned char vs_down_arrow[8*10]={
     33uint8_t vs_down_arrow[8*10]={
    3434    0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 1, 1, 2, 0,
    3535    0, 0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 1, 1, 2,
     
    3939    0, 0, 0, 0, 0};
    4040
    41 void show_icon(image *screen, window_manager *wm, int x, int y, int icw, int ich, unsigned char *buf)
     41void show_icon(image *screen, window_manager *wm, int x, int y, int icw, int ich, uint8_t *buf)
    4242{
    4343  short cx1,cy1,cx2,cy2;
    4444  screen->get_clip(cx1,cy1,cx2,cy2);
    45   unsigned char remap[3];
     45  uint8_t remap[3];
    4646  remap[0]=wm->medium_color();
    4747  remap[1]=wm->bright_color();
     
    5252    if (y>=cy1 && y<=cy2)
    5353    {
    54       unsigned char *sl=screen->scan_line(y)+x;
     54      uint8_t *sl=screen->scan_line(y)+x;
    5555      for (int xc=icw,xo=x;xc;xc--,xo++,sl++,buf++)
    5656      {
     
    8888int scroller::bw() { if (vert) return 12; else return 14; }
    8989
    90 unsigned char *scroller::b1()
     90uint8_t *scroller::b1()
    9191{
    9292  if (vert) return vs_up_arrow;
     
    9494}
    9595
    96 unsigned char *scroller::b2()
     96uint8_t *scroller::b2()
    9797{
    9898  if (vert) return vs_down_arrow;
     
    553553  if (m)
    554554  {
    555     select=(uchar *)jmalloc((t+7)/8,"selection bit array");
     555    select=(uint8_t *)jmalloc((t+7)/8,"selection bit array");
    556556    memset(select,0,(t+7)/8);
    557557  } else cur_sel=0;
  • abuse/trunk/src/imlib/specs.cpp

    r7 r17  
    595595
    596596
    597 uint8_t bFILE::read_byte()
     597uint8_t bFILE::read_uint8()
    598598{ uint8_t x;
    599599  read(&x,1);
     
    601601}
    602602
    603 uint16_t bFILE::read_short()
     603uint16_t bFILE::read_uint16()
    604604{
    605605  uint16_t x;
    606606  read(&x,2);
    607   return int_to_local(x);
    608 }
    609 
    610 
    611 uint32_t bFILE::read_long()
     607  return uint16_to_local(x);
     608}
     609
     610
     611uint32_t bFILE::read_uint32()
    612612{
    613613  uint32_t x;
    614614  read(&x,4);
    615   return long_to_local(x);
    616 }
    617 
    618 void bFILE::write_byte(uint8_t x)
     615  return uint32_to_local(x);
     616}
     617
     618void bFILE::write_uint8(uint8_t x)
    619619{
    620620  write(&x,1);
    621621}
    622622
    623 void bFILE::write_short(uint16_t x)
     623void bFILE::write_uint16(uint16_t x)
    624624{
    625   x=int_to_local(x);
     625  x=uint16_to_local(x);
    626626  write(&x,2);
    627627}
    628628
    629629
    630 void bFILE::write_long(uint32_t x)
    631 {
    632   x=long_to_local(x);
     630void bFILE::write_uint32(uint32_t x)
     631{
     632  x=uint32_to_local(x);
    633633  write(&x,4);
    634634}
     
    637637{
    638638  double a;
    639   write_long((long)(modf(x,&a)*(double)(1<<32-1)));
    640   write_long((long)a);
     639  write_uint32((long)(modf(x,&a)*(double)(1<<32-1)));
     640  write_uint32((long)a);
    641641}
    642642
     
    644644{
    645645  long a,b;
    646   a=read_long();
    647   b=read_long();
     646  a=read_uint32();
     647  b=read_uint32();
    648648  return (double)b+a/(double)(1<<32-1);
    649649}
     
    762762  if (!strcmp(buf,SPEC_SIGNATURE))
    763763  {   
    764     total=fp->read_short();   
     764    total=fp->read_uint16();   
    765765    entries=(spec_entry **)jmalloc(sizeof(spec_entry *)*total,"spec_directory::entries");
    766766    long start=fp->tell();
     
    793793      fp->read(&flags,1);
    794794
    795       se->size=fp->read_long();
    796       se->offset=fp->read_long();
     795      se->size=fp->read_uint32();
     796      se->offset=fp->read_uint32();
    797797      dp+=((sizeof(spec_entry)+len)+3)&(~3);
    798798    }
     
    880880
    881881  if (fp->write(sig,sizeof(sig))!=sizeof(sig))    return 0;
    882   fp->write_short(total);
     882  fp->write_uint16(total);
    883883
    884884
     
    891891    if (fp->write(&flags,1)!=1)                     return 0;
    892892
    893     data_size=long_to_intel((*e)->size);
     893    data_size=uint32_to_intel((*e)->size);
    894894    if (fp->write((char *)&data_size,4)!=4)              return 0;
    895     offset=long_to_intel((*e)->offset);
     895    offset=uint32_to_intel((*e)->offset);
    896896    if (fp->write((char *)&offset,4)!=4)                  return 0;
    897897
     
    913913}
    914914
    915 uint16_t read_short(FILE *fp)
     915uint16_t read_uint16(FILE *fp)
    916916{
    917917  uint16_t x;
    918918  fread(&x,1,2,fp);
    919   return int_to_local(x);
    920 }
    921 
    922 uint32_t read_long(FILE *fp)
     919  return uint16_to_local(x);
     920}
     921
     922uint32_t read_uint32(FILE *fp)
    923923{
    924924  uint32_t x;
    925925  fread(&x,1,4,fp);
    926   return long_to_local(x);
    927 }
    928 void write_short(FILE *fp, uint16_t x)
    929 {
    930   x=int_to_local(x);
     926  return uint32_to_local(x);
     927}
     928void write_uint16(FILE *fp, uint16_t x)
     929{
     930  x=uint16_to_local(x);
    931931  fwrite(&x,1,2,fp);
    932932}
    933933
    934 void write_long(FILE *fp, uint32_t x)
    935 {
    936   x=long_to_local(x);
     934void write_uint32(FILE *fp, uint32_t x)
     935{
     936  x=uint32_to_local(x);
    937937  fwrite(&x,1,4,fp);
    938938}
    939939
    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)
     940uint8_t read_uint8(FILE *fp) { return fgetc(fp)&0xff; }
     941void write_uint8(FILE *fp, uint8_t x) { fputc((unsigned char)x,fp); }
     942
     943uint32_t read_other_int32(FILE *fp)
    944944{
    945945  uint32_t x;
    946946  fread(&x,1,4,fp);
    947   return big_long_to_local(x);
    948 }
    949 
    950 uint16_t read_other_short(FILE *fp)
     947  return big_uint32_to_local(x);
     948}
     949
     950uint16_t read_other_uint16(FILE *fp)
    951951{
    952952  uint16_t x;
    953953  fread(&x,1,2,fp);
    954   return big_short_to_local(x);
    955 }
    956 
    957 
    958 void write_other_short(FILE *fp, uint16_t x)
    959 {
    960   x=big_short_to_local(x);
     954  return big_uint16_to_local(x);
     955}
     956
     957
     958void write_other_uint16(FILE *fp, uint16_t x)
     959{
     960  x=big_uint16_to_local(x);
    961961  fwrite(&x,1,2,fp);
    962962}
    963963
    964 void write_other_long(FILE *fp, uint32_t x)
    965 {
    966   x=big_long_to_local(x);
     964void write_other_int32(FILE *fp, uint32_t x)
     965{
     966  x=big_uint32_to_local(x);
    967967  fwrite(&x,1,4,fp);
    968968}
  • abuse/trunk/src/imlib/targa.cpp

    r4 r17  
    1414  }
    1515 
    16   unsigned char id,color_map,im_type;
     16  uint8_t id,color_map,im_type;
    1717
    18   id=fp->read_byte();
    19   color_map=fp->read_byte();
    20   im_type=fp->read_byte();
     18  id=fp->read_uint8();
     19  color_map=fp->read_uint8();
     20  im_type=fp->read_uint8();
    2121
    2222  if (color_map!=0)
     
    3232  }
    3333
    34   fp->read_short();
    35   fp->read_short();
    36   fp->read_byte();
     34  fp->read_uint16();
     35  fp->read_uint16();
     36  fp->read_uint8();
    3737
    38   fp->read_short();
    39   fp->read_short();
     38  fp->read_uint16();
     39  fp->read_uint16();
    4040
    4141
    42   int w=fp->read_short();
    43   int h=fp->read_short();
    44   unsigned char bpp=fp->read_byte();
    45   unsigned char im_des=fp->read_byte();
     42  int w=fp->read_uint16();
     43  int h=fp->read_uint16();
     44  uint8_t bpp=fp->read_uint8();
     45  uint8_t im_des=fp->read_uint8();
    4646
    4747  if (bpp!=32)
     
    5454
    5555  int x,y;
    56   unsigned char ctrl;
    57   unsigned char bgra[4],*sl,c,lr=0,lg=0,lb=0,ll=0,lc=0;
     56  uint8_t ctrl;
     57  uint8_t bgra[4],*sl,c,lr=0,lg=0,lb=0,ll=0,lc=0;
    5858 
    5959 
     
    6868      for (x=0;x<w;)
    6969      {
    70         ctrl=fp->read_byte();
     70        ctrl=fp->read_uint8();
    7171        if (ctrl&0x80)
    7272        {
  • abuse/trunk/src/imlib/timage.cpp

    r2 r17  
    33void trans_image::make_color(int c)
    44{
    5   unsigned char *dp=data;
     5  uint8_t *dp=data;
    66  int y,x;
    77  for (y=0;y<h;y++)
     
    2525{
    2626  image *im=new image(w,h);
    27   unsigned char *d=im->scan_line(0),*dp=data,*dline;
     27  uint8_t *d=im->scan_line(0),*dp=data,*dline;
    2828  int y,x;
    2929  for (y=0;y<h;y++)
     
    5454{
    5555  int size=0,x,y;
    56   unsigned char *sl,*datap,*marker;
     56  uint8_t *sl,*datap,*marker;
    5757  w=im->width();
    5858  h=im->height();
     
    8484  char st[80];
    8585  sprintf(st,"trans_image::data (%s)",name);
    86   data=(unsigned char *)jmalloc(size,st);
     86  data=(uint8_t *)jmalloc(size,st);
    8787#else
    88   data=(unsigned char *)jmalloc(size,"");
     88  data=(uint8_t *)jmalloc(size,"");
    8989#endif
    9090  int ww=im->width(),hh=im->height();
     
    125125void trans_image::put_scan_line(image *screen, int x, int y, int line)   // always transparent   
    126126{
    127   short x1,y1,x2,y2;
     127  int16_t x1,y1,x2,y2;
    128128  screen->get_clip(x1,y1,x2,y2);
    129129  if (y+line<y1 || y+line>y2 || x>x2 || x+w-1<x1)            // clipped off completely?
    130130    return;
    131131
    132   unsigned char *datap=data;
     132  uint8_t *datap=data;
    133133  int ix; 
    134134  while (line)            // skip scan line data until we get to the line of interest
     
    151151 
    152152  // now slam this list of runs to the screen
    153   unsigned char *screen_line=screen->scan_line(y)+x;
     153  uint8_t *screen_line=screen->scan_line(y)+x;
    154154   
    155155  for (ix=0;ix<w;)             
     
    202202
    203203
    204 inline unsigned char *trans_image::clip_y(image *screen, int x1, int y1, int x2, int y2,
     204inline uint8_t *trans_image::clip_y(image *screen, int x1, int y1, int x2, int y2,
    205205                                   int x, int &y, int &ysteps)
    206206{
     
    209209    return NULL;
    210210
    211   register unsigned char *datap=data; 
     211  register uint8_t *datap=data; 
    212212
    213213
     
    245245
    246246void trans_image::put_image_filled(image *screen, int x, int y,
    247                                    uchar fill_color)
    248 {
    249  short x1,y1,x2,y2;
     247                                   uint8_t fill_color)
     248{
     249 int16_t x1,y1,x2,y2;
    250250  int chop_length,ysteps;
    251251
    252252  screen->get_clip(x1,y1,x2,y2);
    253   register unsigned char *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line;
     253  register uint8_t *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line;
    254254  if (!datap) return ;     // if clip_y says nothing to draw, return
    255255 
     
    316316}
    317317
    318 void trans_image::put_image_offseted(image *screen, uchar *s_off)   // if screen x & y offset already calculated save a mul
     318void trans_image::put_image_offseted(image *screen, uint8_t *s_off)   // if screen x & y offset already calculated save a mul
    319319{
    320320  int ix,ysteps=height();
    321321  int screen_skip=screen->width()-w;
    322   uchar skip,*datap=data;
     322  uint8_t skip,*datap=data;
    323323  for (;ysteps;ysteps--)
    324324  {
     
    353353void trans_image::put_image(image *screen, int x, int y)
    354354{
    355   short x1,y1,x2,y2;
     355  int16_t x1,y1,x2,y2;
    356356  int chop_length,ysteps;
    357357
    358358  screen->get_clip(x1,y1,x2,y2);
    359   register unsigned char *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line;
     359  register uint8_t *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line;
    360360  if (!datap) return ;     // if clip_y says nothing to draw, return
    361361 
     
    414414}
    415415
    416 void trans_image::put_remaped(image *screen, int x, int y, unsigned char *remap)
    417 {
    418   short x1,y1,x2,y2;
     416void trans_image::put_remaped(image *screen, int x, int y, uint8_t *remap)
     417{
     418  int16_t x1,y1,x2,y2;
    419419  int chop_length,ysteps;
    420420
    421421  screen->get_clip(x1,y1,x2,y2);
    422   register unsigned char *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line;
     422  register uint8_t *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line;
    423423  if (!datap) return ;     // if clip_y says nothing to draw, return
    424424 
     
    470470              counter=slam_length;
    471471
    472             register unsigned char *sl=screen_line+ix,*sl2=datap;
     472            register uint8_t *sl=screen_line+ix,*sl2=datap;
    473473            ix+=slam_length;       
    474474            datap+=slam_length;
     
    490490
    491491
    492 void trans_image::put_double_remaped(image *screen, int x, int y, unsigned char *remap, unsigned char *remap2)
    493 {
    494   short x1,y1,x2,y2;
     492void trans_image::put_double_remaped(image *screen, int x, int y, uint8_t *remap, uint8_t *remap2)
     493{
     494  int16_t x1,y1,x2,y2;
    495495  int chop_length,ysteps;
    496496
    497497  screen->get_clip(x1,y1,x2,y2);
    498   register unsigned char *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line;
     498  register uint8_t *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line;
    499499  if (!datap) return ;     // if clip_y says nothing to draw, return
    500500 
     
    546546              counter=slam_length;
    547547
    548             register unsigned char *sl=screen_line+ix,*sl2=datap;
     548            register uint8_t *sl=screen_line+ix,*sl2=datap;
    549549            ix+=slam_length;       
    550550            datap+=slam_length;
     
    570570                           color_filter *f, palette *pal)
    571571{
    572   short x1,y1,x2,y2;
     572  int16_t x1,y1,x2,y2;
    573573  int ix,slam_length,chop_length,ysteps;
    574574
    575575  screen->get_clip(x1,y1,x2,y2);
    576   unsigned char *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),
     576  uint8_t *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),
    577577                *screen_line;
    578578  if (!datap) return ;
    579579
    580   unsigned char *screen_run,*paddr=(unsigned char *)pal->addr(),
     580  uint8_t *screen_run,*paddr=(uint8_t *)pal->addr(),
    581581                *caddr1,*caddr2,r_dest,g_dest,b_dest;
    582582
     
    659659void trans_image::put_fade_tint(image *screen, int x, int y,
    660660                                int frame_on, int total_frames,
    661                                 uchar *tint,
     661                                uint8_t *tint,
    662662                                color_filter *f, palette *pal)
    663663{
    664   short x1,y1,x2,y2;
     664  int16_t x1,y1,x2,y2;
    665665  int ix,slam_length,chop_length,ysteps;
    666666
    667667  screen->get_clip(x1,y1,x2,y2);
    668   unsigned char *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),
     668  uint8_t *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),
    669669                *screen_line;
    670670  if (!datap) return ;
    671671
    672   unsigned char *screen_run,*paddr=(unsigned char *)pal->addr(),
     672  uint8_t *screen_run,*paddr=(uint8_t *)pal->addr(),
    673673                *caddr1,*caddr2,r_dest,g_dest,b_dest;
    674674
     
    753753void trans_image::put_color(image *screen, int x, int y, int color)
    754754{
    755   short x1,y1,x2,y2;
     755  int16_t x1,y1,x2,y2;
    756756  int ix,slam_length,chop_length,ysteps;
    757757 
    758758  screen->get_clip(x1,y1,x2,y2);
    759   unsigned char *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),
     759  uint8_t *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),
    760760                *screen_line;
    761761  if (!datap) return ;
     
    819819
    820820{
    821   short x1,y1,x2,y2;
     821  int16_t x1,y1,x2,y2;
    822822  int ix,slam_length,chop_length,ysteps;
    823   unsigned char *paddr=(unsigned char *)pal->addr(); 
     823  uint8_t *paddr=(uint8_t *)pal->addr(); 
    824824 
    825825  screen->get_clip(x1,y1,x2,y2);
    826   unsigned char *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),
     826  uint8_t *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),
    827827                *blend_line,*screen_line;
    828828  if (!datap) return ;
     
    876876            else chop_length=slam_length;
    877877
    878             unsigned char *screen_run=screen_line+x+ix,
     878            uint8_t *screen_run=screen_line+x+ix,
    879879                          *blend_run=blend_line+x+ix-blendx,
    880880                          *caddr1,*caddr2,r_dest,g_dest,b_dest;     
     
    918918void trans_image::put_predator(image *screen, int x, int y)
    919919{
    920   short x1,y1,x2,y2;
     920  int16_t x1,y1,x2,y2;
    921921  int chop_length,ysteps;
    922922
    923923  screen->get_clip(x1,y1,x2,y2);
    924   register unsigned char *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line;
     924  register uint8_t *datap=clip_y(screen,x1,y1,x2,y2,x,y,ysteps),*screen_line;
    925925  if (!datap) return ;     // if clip_y says nothing to draw, return
    926926
     
    10021002int trans_image::size()
    10031003{
    1004   uchar *d=data;
     1004  uint8_t *d=data;
    10051005  int t=0;
    10061006  for (int y=0;y<h;y++)
  • abuse/trunk/src/imlib/xwdread.cpp

    r4 r17  
    123123int bit_order, byte_swap;
    124124char buf[4];
    125 unsigned char *byteP;
    126 unsigned short *shortP;
    127 unsigned long *longP;
    128 
    129 
    130 int bs_int(int s);
    131 long bs_long(long s);
    132 short bs_short(short s );
     125uint8_t *byteP;
     126uint16_t *shortP;
     127uint32_t *longP;
     128
     129
     130uint32_t bs_uint32(uint32_t s);
     131uint16_t bs_uint16(uint16_t s );
    133132
    134133
     
    136135{
    137136  /* Assume X11 headers are larger than X10 ones. */
    138   unsigned char header[sizeof(X11WDFileHeader)];
     137  uint8_t header[sizeof(X11WDFileHeader)];
    139138  image *im;
    140139  X11WDFileHeader *h11P;
     
    142141  unsigned int i;
    143142  int dummy1, dummy2, dummy3;
    144   unsigned  short minred, maxred;
     143  uint16_t minred, maxred;
    145144  X11XColor x11col;
    146145
     
    275274  pixel_mask = ( 1 << bits_per_pixel ) - 1;
    276275
    277   byteP = (unsigned char *) buf;
    278   shortP = (unsigned short *) buf;
    279   longP = (unsigned long *) buf;
     276  byteP = (uint8_t *) buf;
     277  shortP = (uint16_t *) buf;
     278  longP = (uint32_t *) buf;
    280279  return im;
    281280}
     
    284283{
    285284  int i,j;
    286   unsigned char *sl;
     285  uint8_t *sl;
    287286#if BYTE_ORDER!=BIG_ENDIAN
    288287  printf("little guys\n");
     
    314313            break;
    315314
    316           case 16: *shortP=short_swap(*shortP); break;
    317 
    318           case 32: *longP=long_swap(*longP); break;
     315          case 16: *shortP=uint16_swap(*shortP); break;
     316
     317          case 32: *longP=uint32_swap(*longP); break;
    319318
    320319          default:
     
    357356
    358357
    359 short bs_short(short s )
    360 {
    361   short ss;
    362   unsigned char *bp, t;
     358uint16_t bs_uint16(uint16_t s )
     359{
     360  uint16_t ss;
     361  uint8_t *bp, t;
    363362
    364363  ss = s;
    365   bp = (unsigned char *) &ss;
     364  bp = (uint8_t *) &ss;
    366365  t = bp[0];
    367366  bp[0] = bp[1];
     
    370369}
    371370
    372 int bs_int(int i )
    373 {
    374   int ii;
    375   unsigned char *bp, t;
    376 
    377   ii = i;
    378   bp = (unsigned char *) &ii;
     371uint32_t bs_uint32(uint32_t l )
     372{
     373  uint32_t ii;
     374  uint8_t *bp, t;
     375
     376  ii = l;
     377  bp = (uint8_t *) &ii;
    379378  t = bp[0];
    380379  bp[0] = bp[3];
     
    386385}
    387386
    388 long bs_long(long l )
    389 {
    390   return bs_int( l );
    391 }
    392 
    393387struct BMP_header
    394388{
    395389  char id[2];
    396390  long filesize;
    397   short reserved[2];
     391  int16_t reserved[2];
    398392  long headersize,infosize,width,height;
    399   short biplanes,bits;
     393  int16_t biplanes,bits;
    400394  long bicompression, bisizeimage, bixpelspermeter, biypelspermeter,
    401395       biclrused,biclrimportant;
     
    405399{
    406400  if (!fread(&bmp.id,1,2,fp)) return 0;         // 2 0
    407   bmp.filesize=read_long(fp);                   // 4 4
     401  bmp.filesize=read_uint32(fp);                   // 4 4
    408402  if (!fread(bmp.reserved,1,4,fp)) return 0;    // 4 8
    409   bmp.headersize=read_long(fp);                 // 4 12
    410   bmp.infosize=read_long(fp);                   // 4 16
    411   bmp.width=read_long(fp);                      // 4 20
    412   bmp.height=read_long(fp);                     // 4 24
    413   bmp.biplanes=read_short(fp);                  // 2 26
    414   bmp.bits=read_short(fp);                      // 2 28
    415   bmp.bicompression=read_long(fp);              // 4 32
    416   bmp.bisizeimage=read_long(fp);                // 4 36
    417   bmp.bixpelspermeter=read_long(fp);            // 4 40
    418   bmp.biypelspermeter=read_long(fp);            // 4 44
    419   bmp.biclrused=read_long(fp);                  // 4 48
    420   bmp.biclrimportant=read_long(fp);             // 4 52
     403  bmp.headersize=read_uint32(fp);                 // 4 12
     404  bmp.infosize=read_uint32(fp);                   // 4 16
     405  bmp.width=read_uint32(fp);                      // 4 20
     406  bmp.height=read_uint32(fp);                     // 4 24
     407  bmp.biplanes=read_uint16(fp);                  // 2 26
     408  bmp.bits=read_uint16(fp);                      // 2 28
     409  bmp.bicompression=read_uint32(fp);              // 4 32
     410  bmp.bisizeimage=read_uint32(fp);                // 4 36
     411  bmp.bixpelspermeter=read_uint32(fp);            // 4 40
     412  bmp.biypelspermeter=read_uint32(fp);            // 4 44
     413  bmp.biclrused=read_uint32(fp);                  // 4 48
     414  bmp.biclrimportant=read_uint32(fp);             // 4 52
    421415  return 1;
    422416 
     
    460454    return NULL;
    461455 
    462   unsigned char *sl;
     456  uint8_t *sl;
    463457  int trailer=im->width()%4;
    464458  if (trailer==1) trailer=3;
    465459  else if (trailer==3) trailer=1;
    466   uchar buf[9];
     460  uint8_t buf[9];
    467461  for (i=im->height();i;i--)
    468462  {
     
    487481  image *im;
    488482  FILE *fp;
    489   unsigned char pal_quad[4];
     483  uint8_t pal_quad[4];
    490484  char *scrap;
    491485  int bytes,i;
     
    530524{
    531525  if (!fwrite(&bmp.id,1,2,fp)) return 0; 
    532   write_long(fp,bmp.filesize); 
     526  write_uint32(fp,bmp.filesize); 
    533527  if (!fwrite(bmp.reserved,1,4,fp)) return 0;   
    534   write_long(fp,bmp.headersize);
    535   write_long(fp,bmp.infosize); 
    536   write_long(fp,bmp.width);
    537   write_long(fp,bmp.height);
    538   write_short(fp,bmp.biplanes);
    539   write_short(fp,bmp.bits);
    540   write_long(fp,bmp.bicompression);
    541   write_long(fp,bmp.bisizeimage);
    542   write_long(fp,bmp.bixpelspermeter);
    543   write_long(fp,bmp.biypelspermeter);
    544   write_long(fp,bmp.biclrused);
    545   write_long(fp,bmp.biclrimportant);   
     528  write_uint32(fp,bmp.headersize);
     529  write_uint32(fp,bmp.infosize); 
     530  write_uint32(fp,bmp.width);
     531  write_uint32(fp,bmp.height);
     532  write_uint16(fp,bmp.biplanes);
     533  write_uint16(fp,bmp.bits);
     534  write_uint32(fp,bmp.bicompression);
     535  write_uint32(fp,bmp.bisizeimage);
     536  write_uint32(fp,bmp.bixpelspermeter);
     537  write_uint32(fp,bmp.biypelspermeter);
     538  write_uint32(fp,bmp.biclrused);
     539  write_uint32(fp,bmp.biclrimportant);   
    546540  return 1;
    547541 
     
    552546  FILE *fp;
    553547  int i,bytes;
    554   unsigned char pal_quad[4];
     548  uint8_t pal_quad[4];
    555549  fp=fopen(filename,"wb");
    556550  if (!fp)
  • abuse/trunk/src/include/cache.hpp

    r2 r17  
    2323{
    2424  void *data;
    25   long last_access;   
    26   unsigned char type;
    27   short file_number;
    28   long offset;
     25  int32_t last_access;   
     26  uint8_t type;
     27  int16_t file_number;
     28  int32_t offset;
    2929} ;
    3030
     
    3535  public :
    3636  int crc_calculated;
    37   ulong crc;
     37  uint32_t crc;
    3838  char *filename;
    3939  crced_file(char *name);
     
    4848  crc_manager();
    4949  int get_filenumber(char *filename);
    50   ulong get_crc(long filenumber, int &failed);
    51   void set_crc(long filenumber, ulong crc);
    52   char *get_filename(long filenumber);
     50  uint32_t get_crc(int32_t filenumber, int &failed);
     51  void set_crc(int32_t filenumber, uint32_t crc);
     52  char *get_filename(int32_t filenumber);
    5353  void clean_up();
    5454  int total_filenames() { return total_files; }
     
    6262{
    6363  cache_item *list;
    64   long total,last_registered,last_access,poll_start_access;
    65   short last_file;           // for speed leave the last file accessed open
     64  int32_t total,last_registered,last_access,poll_start_access;
     65  int16_t last_file;           // for speed leave the last file accessed open
    6666
    6767  bFILE *fp,*cache_file,*cache_read_file;
    6868  spec_directory *last_dir;
    69   long last_offset;          // store the last offset so we don't have to seek if
     69  int32_t last_offset;          // store the last offset so we don't have to seek if
    7070                             // we don't need to
    7171 
    7272
    73   short lcache_number;
    74   long alloc_id();
     73  int16_t lcache_number;
     74  int32_t alloc_id();
    7575  void locate(cache_item *i, int local_only=0);    // set up file and offset for this item
    7676  void normalize();
     
    8787  int in_use() { if (used) { used=0; return 1; } else return 0; }
    8888  int full() { if (ful) { ful=0; return 1; } else return 0; }
    89   long reg_object(char *filename, void *object, int type, int rm_dups);      // lisp object
    90   long reg(char *filename, char *name, int type=-1, int rm_dups=0);          // returns id to item
    91   long reg_lisp_block(Cell *block);
     89  int32_t reg_object(char *filename, void *object, int type, int rm_dups);      // lisp object
     90  int32_t reg(char *filename, char *name, int type=-1, int rm_dups=0);          // returns id to item
     91  int32_t reg_lisp_block(Cell *block);
    9292  int loaded(int id);
    9393  void unreg(int id);
     
    114114
    115115  void load_cache_prof_info(char *filename, level *lev);
    116   int search(int *sarray, ushort filenum, long offset);  // sarray is a index table sorted by offset/filenum
     116  int search(int *sarray, uint16_t filenum, int32_t offset);  // sarray is a index table sorted by offset/filenum
    117117
    118118  void show_accessed();
  • abuse/trunk/src/include/compiled.hpp

    r2 r17  
    2525void compiled_uninit();
    2626
    27 extern uchar *bad_guy_array;    // list flaging each character saying they are a bad bug or not
     27extern uint8_t *bad_guy_array;  // list flaging each character saying they are a bad bug or not
    2828                                // mainly used by the rocket to find targets
    2929
  • abuse/trunk/src/include/crc.hpp

    r2 r17  
    44#include "macs.hpp"
    55
    6 unsigned short calc_crc(unsigned char *buf, long len);
    7 ulong crc_file(bFILE *fp);
     6uint16_t calc_crc(uint8_t *buf, int len);
     7uint32_t crc_file(bFILE *fp);
    88
    99
  • abuse/trunk/src/include/extend.hpp

    r16 r17  
    2323{
    2424  public :
    25   schar Fade_dir;
    26   uchar Fade_count,Fade_max;
    27   uchar Flags,grav_on,targetable_on;
     25  int8_t Fade_dir;
     26  uint8_t Fade_count,Fade_max;
     27  uint8_t Flags,grav_on,targetable_on;
    2828  int32_t Xvel,Yvel,Xacel,Yacel;
    29   uchar Fx,Fy,Fxvel,Fyvel,Fxacel,Fyacel;
    30   uchar Aitype;
    31   ushort Aistate,Aistate_time;
    32   unsigned short Hp,Mp,Fmp;
    33   schar Frame_dir;       
     29  uint8_t Fx,Fy,Fxvel,Fyvel,Fxacel,Fyacel;
     30  uint8_t Aitype;
     31  uint16_t Aistate,Aistate_time;
     32  uint16_t Hp,Mp,Fmp;
     33  int8_t Frame_dir;       
    3434
    3535
    36   uchar tobjs,tlights;
     36  uint8_t tobjs,tlights;
    3737  game_object **objs,*link;
    3838  light_source **lights;
     
    5050  int32_t x,y,
    5151       last_x,last_y;              // used for frame interpolation on fast machines
    52   schar direction,active;
    53   ushort otype;
     52  int8_t direction,active;
     53  uint16_t otype;
    5454  character_state state;
    5555  short current_frame;
     
    6060
    6161  int keep_ai_info()         { return 1; }
    62   uchar flags()              { return Flags; }
     62  uint8_t flags()            { return Flags; }
    6363  int32_t xvel()             { return Xvel; }
    6464  int32_t yvel()             { return Yvel; }
     
    6666  int32_t yacel()            { return Yacel; }
    6767
    68   uchar fx()                 { return Fx; }
    69   uchar fy()                 { return Fy; }
    70   uchar fxvel()              { return Fxvel; }
    71   uchar fyvel()              { return Fyvel; }
    72   uchar fxacel()             { return Fxacel; }
    73   uchar fyacel()             { return Fyacel; }
     68  uint8_t fx()               { return Fx; }
     69  uint8_t fy()               { return Fy; }
     70  uint8_t fxvel()            { return Fxvel; }
     71  uint8_t fyvel()            { return Fyvel; }
     72  uint8_t fxacel()           { return Fxacel; }
     73  uint8_t fyacel()           { return Fyacel; }
    7474
    75   uchar sfx()                { return Fx; }  // x & y should always be positive
    76   uchar sfy()                { return Fy; }
    77   uchar sfxvel()             { if (Xvel>=0) return Fxvel; else return -Fxvel; }
    78   uchar sfyvel()             { if (Yvel>=0) return Fyvel; else return -Fyvel; }
    79   uchar sfxacel()            { if (Xacel>=0) return Fxacel; else return -Fxacel; }
    80   uchar sfyacel()            { if (Yacel>=0) return Fyacel; else return -Fyacel; }
     75  uint8_t sfx()              { return Fx; }  // x & y should always be positive
     76  uint8_t sfy()              { return Fy; }
     77  uint8_t sfxvel()           { if (Xvel>=0) return Fxvel; else return -Fxvel; }
     78  uint8_t sfyvel()           { if (Yvel>=0) return Fyvel; else return -Fyvel; }
     79  uint8_t sfxacel()          { if (Xacel>=0) return Fxacel; else return -Fxacel; }
     80  uint8_t sfyacel()          { if (Yacel>=0) return Fyacel; else return -Fyacel; }
    8181
    82   uchar aitype()             { return Aitype; }
    83   ushort aistate()           { return Aistate; }
    84   ushort aistate_time()      { return Aistate_time; }
    85   ushort hp()                { return Hp;         }
    86   ushort mp()                { return Mp;         }
    87   ushort fmp()               { return Fmp;        }
    88   schar fade_dir()           { return Fade_dir;   }
    89   schar frame_dir()          { return Frame_dir;  }
    90   uchar fade_count()         { return Fade_count; }
    91   uchar fade_max()           { return Fade_max;   }
    92   uchar total_objects()      { return tobjs;      }
    93   uchar total_lights()       { return tlights;    }
     82  uint8_t aitype()           { return Aitype; }
     83  uint16_t aistate()         { return Aistate; }
     84  uint16_t aistate_time()    { return Aistate_time; }
     85  uint16_t hp()              { return Hp;         }
     86  uint16_t mp()              { return Mp;         }
     87  uint16_t fmp()             { return Fmp;        }
     88  int8_t fade_dir()          { return Fade_dir;   }
     89  int8_t frame_dir()         { return Frame_dir;  }
     90  uint8_t fade_count()       { return Fade_count; }
     91  uint8_t fade_max()         { return Fade_max;   }
     92  uint8_t total_objects()    { return tobjs;      }
     93  uint8_t total_lights()     { return tlights;    }
    9494
    9595  morph_char *morph_status()     { return mc; }
     
    100100  view *controller()             { return Controller; }
    101101
    102   void set_targetable(uchar x)    { targetable_on=x; }
    103   void set_flags(uchar f)         { Flags=f; }
     102  void set_targetable(uint8_t x)  { targetable_on=x; }
     103  void set_flags(uint8_t f)       { Flags=f; }
    104104  void set_xvel(int32_t xv)       { Xvel=xv; }
    105105  void set_yvel(int32_t yv)       { Yvel=yv; }
    106106  void set_xacel(int32_t xa)      { Xacel=xa; }
    107107  void set_yacel(int32_t ya)      { Yacel=ya; }
    108   void set_fx(uchar x)            { Fx=x; }
    109   void set_fy(uchar y)            { Fy=y; }
    110   void set_fxvel(uchar xv)        { Fxvel=abs(xv); }
    111   void set_fyvel(uchar yv)        { Fyvel=abs(yv); }
    112   void set_fxacel(uchar xa)       { Fxacel=abs(xa); }
    113   void set_fyacel(uchar ya)       { Fyacel=abs(ya); }
    114   void set_aitype(uchar t)        { Aitype=t; }
    115   void set_aistate(ushort s)      { Aistate=s; }
    116   void set_aistate_time(ushort t) { Aistate_time=t; }
    117   void set_hp(ushort h)           { Hp=h; }
    118   void set_mp(ushort m)           { Mp=m; }
    119   void set_fmp(ushort m)          { Fmp=m; }
     108  void set_fx(uint8_t x)          { Fx=x; }
     109  void set_fy(uint8_t y)          { Fy=y; }
     110  void set_fxvel(uint8_t xv)      { Fxvel=abs(xv); }
     111  void set_fyvel(uint8_t yv)      { Fyvel=abs(yv); }
     112  void set_fxacel(uint8_t xa)     { Fxacel=abs(xa); }
     113  void set_fyacel(uint8_t ya)     { Fyacel=abs(ya); }
     114  void set_aitype(uint8_t t)      { Aitype=t; }
     115  void set_aistate(uint16_t s)      { Aistate=s; }
     116  void set_aistate_time(uint16_t t) { Aistate_time=t; }
     117  void set_hp(uint16_t h)           { Hp=h; }
     118  void set_mp(uint16_t m)           { Mp=m; }
     119  void set_fmp(uint16_t m)          { Fmp=m; }
    120120
    121121
    122122
    123   void set_fade_count(uchar f)          { Fade_count=f; }
    124   void set_fade_max(uchar m)            { Fade_max=m;  }
    125   void set_fade_dir(schar d)            { Fade_dir=d; }
     123  void set_fade_count(uint8_t f)        { Fade_count=f; }
     124  void set_fade_max(uint8_t m)          { Fade_max=m;  }
     125  void set_fade_dir(int8_t d)            { Fade_dir=d; }
    126126
    127   void set_frame_dir(schar d)           { Frame_dir=d; }
     127  void set_frame_dir(int8_t d)           { Frame_dir=d; }
    128128  void add_light(light_source *ls);
    129129  void add_object(game_object *o);
  • abuse/trunk/src/include/fakelib.hpp

    r2 r17  
    55#define jrealloc(x,y,z) realloc(x,y)
    66#define jfree(x) free(x)
    7 #define uchar  unsigned char
    8 #define schar  signed char
    9 #define sshort signed short
    107
    118#ifdef __sgi
    129#include <sys/bsd_types.h>
    1310#else
    14 #define ulong  unsigned long
    15 #define ushort unsigned short
     11#include <stdint.h>
    1612#endif
    1713
  • abuse/trunk/src/include/game.hpp

    r16 r17  
    6666  jwindow *top_menu,*joy_win,*last_input;
    6767  JCFont *game_font;
    68   uchar keymap[512/8];
     68  uint8_t keymap[512/8];
    6969
    7070public :
  • abuse/trunk/src/include/items.hpp

    r2 r17  
    1515public : 
    1616  boundary(bFILE *fp,char *er_name);
    17   unsigned char *inside;     // tells which side of the line is on the inside
     17  uint8_t *inside;     // tells which side of the line is on the inside
    1818  boundary(boundary *p);      // flips the *inside list
    1919  ~boundary() { if (tot) jfree(inside); }
     
    2323{
    2424public :
    25   unsigned short next;
     25  uint16_t next;
    2626  image *im;
    2727  backtile(spec_entry *e, bFILE *fp);
    2828  backtile(bFILE *fp);
    29   long size() { return 2+4+im->width()*im->height(); }
     29  int32_t size() { return 2+4+im->width()*im->height(); }
    3030  ~backtile() { delete im; }
    3131} ;
     
    3535public :
    3636  trans_image *im;
    37   unsigned short next;
    38   unsigned char damage;
    39   uchar ylevel;            // for fast intersections, this is the y level offset for the ground
     37  uint16_t next;
     38  uint8_t damage;
     39  uint8_t ylevel;            // for fast intersections, this is the y level offset for the ground
    4040                           // if ground is not level this is 255
    4141  boundary *points;
     
    4444
    4545  foretile(bFILE *fp);
    46   long size() { return im->width()*im->height()+4+2+1+points->size(); }
     46  int32_t size() { return im->width()*im->height()+4+2+1+points->size(); }
    4747  ~foretile() { delete im; delete points; delete micro_image; }
    4848} ;
     
    5252public :
    5353  trans_image *forward,*backward;
    54   unsigned char hit_damage,xcfg;
    55   signed char advance;
     54  uint8_t hit_damage,xcfg;
     55  int8_t advance;
    5656  point_list *hit;
    5757  boundary *f_damage,*b_damage;
     
    6262  int height() { return forward->height(); }
    6363
    64 /*  long size(int type)         // taken from spaint items
     64/*  int32_t size(int type)         // taken from spaint items
    6565  {
    6666    if
     
    8080{
    8181  public :
    82   uchar data[256];
     82  uint8_t data[256];
    8383  ~char_tint() { ; }
    8484  char_tint(bFILE *fp);               // should be a palette entry
  • abuse/trunk/src/include/level.hpp

    r16 r17  
    3838class level        // contain map info and objects
    3939{
    40   unsigned short *map_fg,        // just big 2d arrays
    41                  *map_bg,
    42                  bg_width,bg_height,
    43                  fg_width,fg_height; 
     40  uint16_t *map_fg,        // just big 2d arrays
     41           *map_bg,
     42           bg_width,bg_height,
     43           fg_width,fg_height; 
    4444  char *Name,*first_name;
    4545  int32_t total_objs;
     
    6464  int all_block_list_size,all_block_total;
    6565  void add_all_block(game_object *who);
    66   ulong ctick;
     66  uint32_t ctick;
    6767 
    6868public :
    6969  char *original_name() { if (first_name) return first_name; else return Name; }
    70   ulong tick_counter() { return ctick; }
    71   void set_tick_counter(ulong x);
     70  uint32_t tick_counter() { return ctick; }
     71  void set_tick_counter(uint32_t x);
    7272  area_controller *area_list;
    7373 
     
    8080  game_object *first_object() { return first; }
    8181  game_object *first_active_object() { return first_active; }
    82   unsigned short foreground_width() { return fg_width; }
    83   unsigned short foreground_height() { return fg_height; }
    84   unsigned short background_width() { return bg_width; }
    85   unsigned short background_height() { return bg_height; }
     82  uint16_t foreground_width() { return fg_width; }
     83  uint16_t foreground_height() { return fg_height; }
     84  uint16_t background_width() { return bg_width; }
     85  uint16_t background_height() { return bg_height; }
    8686  int load_failed() { return map_fg==NULL; }
    8787  level(spec_directory *sd, bFILE *fp, char *lev_name);
     
    9898                                 return (*(map_fg+x+y*fg_width))&0x4000; }
    9999  void fg_set_raised(int x, int y, int r) { CHECK(x>=0 && y>=0 && x<fg_width && y<fg_height);
    100                                             ushort v=(*(map_fg+x+y*fg_width))&(0xffff-0x4000);
     100                                            uint16_t v=(*(map_fg+x+y*fg_width))&(0xffff-0x4000);
    101101                                            if (r) (*(map_fg+x+y*fg_width))=v|0x4000;
    102102                                            else (*(map_fg+x+y*fg_width))=v;
     
    106106  void clear_fg(int32_t x, int32_t y) { *(map_fg+x+y*fg_width)&=0x7fff; }
    107107
    108   unsigned short *get_fgline(int y) { CHECK(y>=0 && y<fg_height); return map_fg+y*fg_width; }
    109   unsigned short *get_bgline(int y) { CHECK(y>=0 && y<bg_height); return map_bg+y*bg_width; }
    110   unsigned short get_fg(int x, int y) { if (x>=0 && y>=0 && x<fg_width && y<fg_height)
     108  uint16_t *get_fgline(int y) { CHECK(y>=0 && y<fg_height); return map_fg+y*fg_width; }
     109  uint16_t *get_bgline(int y) { CHECK(y>=0 && y<bg_height); return map_bg+y*bg_width; }
     110  uint16_t get_fg(int x, int y) { if (x>=0 && y>=0 && x<fg_width && y<fg_height)
    111111                                          return fgvalue(*(map_fg+x+y*fg_width));
    112112                                        else return 0;
    113113                                      }
    114   unsigned short get_bg(int x, int y) { if (x>=0 && y>=0 && x<bg_width && y<bg_height)
     114  uint16_t get_bg(int x, int y) { if (x>=0 && y>=0 && x<bg_width && y<bg_height)
    115115                                          return *(map_bg+x+y*bg_width);
    116116                                         else return 0;
    117117                                        }
    118   void put_fg(int x, int y, unsigned short tile) { *(map_fg+x+y*fg_width)=tile; }   
    119   void put_bg(int x, int y, unsigned short tile) { *(map_bg+x+y*bg_width)=tile; }
     118  void put_fg(int x, int y, uint16_t tile) { *(map_fg+x+y*fg_width)=tile; }   
     119  void put_bg(int x, int y, uint16_t tile) { *(map_bg+x+y*bg_width)=tile; }
    120120  void draw_objects(view *v);
    121121  void interpolate_draw_objects(view *v);
  • abuse/trunk/src/include/light.hpp

    r16 r17  
    88
    99#define TTINTS 9
    10 extern uchar *tints[TTINTS];
    11 extern unsigned char *white_light,*white_light_initial,*green_light,*trans_table;
    12 extern short ambient_ramp;
     10extern uint8_t *tints[TTINTS];
     11extern uint8_t *white_light,*white_light_initial,*green_light,*trans_table;
     12extern int16_t ambient_ramp;
    1313#define REVERSE_GREEN_TINT 8
    1414
    15 extern short shutdown_lighting_value,shutdown_lighting;
     15extern int16_t shutdown_lighting_value,shutdown_lighting;
    1616
    1717class light_source
     
    6363light_patch *find_patch(int screenx, int screeny, light_patch *list);
    6464int calc_light_value(int32_t x, int32_t y, light_patch *which);                       
    65 void light_screen(image *sc, int32_t screenx, int32_t screeny, uchar *light_lookup, ushort ambient);
    66 void double_light_screen(image *sc, int32_t screenx, int32_t screeny, uchar *light_lookup, ushort ambient,
     65void light_screen(image *sc, int32_t screenx, int32_t screeny, uint8_t *light_lookup, uint16_t ambient);
     66void double_light_screen(image *sc, int32_t screenx, int32_t screeny, uint8_t *light_lookup, uint16_t ambient,
    6767                         image *out, int32_t out_x, int32_t out_y);
    6868
  • abuse/trunk/src/include/netface.hpp

    r2 r17  
    9696struct net_packet
    9797{
    98   unsigned char data[PACKET_MAX_SIZE];
     98  uint8_t data[PACKET_MAX_SIZE];
    9999  int packet_prefix_size()                 { return 5; }    // 2 byte size, 2 byte check sum, 1 byte packet order
    100   unsigned short packet_size()             { unsigned short size=(*(unsigned short *)data); return lstl(size); }
    101   unsigned char tick_received()            { return data[4]; } 
    102   void set_tick_received(unsigned char x)  { data[4]=x; }
    103   unsigned char *packet_data()             { return data+packet_prefix_size(); }
    104   unsigned short get_checksum()            { unsigned short cs=*((unsigned short *)data+1); return lstl(cs); }
    105   unsigned short calc_checksum()
     100  uint16_t packet_size()             { uint16_t size=(*(uint16_t *)data); return lstl(size); }
     101  uint8_t tick_received()            { return data[4]; } 
     102  void set_tick_received(uint8_t x)  { data[4]=x; }
     103  uint8_t *packet_data()             { return data+packet_prefix_size(); }
     104  uint16_t get_checksum()            { uint16_t cs=*((uint16_t *)data+1); return lstl(cs); }
     105  uint16_t calc_checksum()
    106106  {
    107     *((unsigned short *)data+1)=0;
     107    *((uint16_t *)data+1)=0;
    108108    int i,size=packet_prefix_size()+packet_size();
    109     unsigned char c1=0,c2=0,*p=data;
     109    uint8_t c1=0,c2=0,*p=data;
    110110    for (i=0;i<size;i++,p++)
    111111    {
     
    113113      c2+=c1;
    114114    }
    115     unsigned short cs=( (((unsigned short)c1)<<8) | c2);
    116     *((unsigned short *)data+1)=lstl(cs);
     115    uint16_t cs=( (((uint16_t)c1)<<8) | c2);
     116    *((uint16_t *)data+1)=lstl(cs);
    117117    return cs;
    118118  }
     
    129129    }
    130130  }
    131   void write_byte(unsigned char x) { add_to_packet(&x,1); }
    132   void write_short(unsigned short x) { x=lstl(x); add_to_packet(&x,2); }
    133   void write_long(unsigned long x) { x=lltl(x); add_to_packet(&x,4); }
     131  void write_uint8(uint8_t x) { add_to_packet(&x,1); }
     132  void write_uint16(uint16_t x) { x=lstl(x); add_to_packet(&x,2); }
     133  void write_uint32(uint32_t x) { x=lltl(x); add_to_packet(&x,4); }
    134134
    135   void set_packet_size(unsigned short x) { *((unsigned short *)data)=lstl(x); }
     135  void set_packet_size(uint16_t x) { *((uint16_t *)data)=lstl(x); }
    136136
    137137
     
    143143             last_packet;                   // last tick data (in case a client misses input, we can resend)
    144144
    145   short mem_lock;
    146   short calc_crcs;
    147   short get_lsf;
    148   short wait_reload;
    149   short need_reload;
    150   short input_state;            // COLLECTING or PROCESSING
    151   short current_tick;           // set by engine, used by driver to confirm packet is not left over
     145  int16_t mem_lock;
     146  int16_t calc_crcs;
     147  int16_t get_lsf;
     148  int16_t wait_reload;
     149  int16_t need_reload;
     150  int16_t input_state;          // COLLECTING or PROCESSING
     151  int16_t current_tick;         // set by engine, used by driver to confirm packet is not left over
    152152 
    153153  join_struct *join_list;
  • abuse/trunk/src/include/particle.hpp

    r2 r17  
    1717{
    1818  short x,y;
    19   uchar color;
     19  uint8_t color;
    2020} ;
    2121
  • abuse/trunk/src/include/transp.hpp

    r2 r17  
    33#include "image.hpp"
    44#include "macs.hpp"
    5 void transp_put(image *im, image *screen, uchar *table, int x, int y);
     5void transp_put(image *im, image *screen, uint8_t *table, int x, int y);
    66
    77#endif
  • abuse/trunk/src/include/view.hpp

    r16 r17  
    1414  int32_t cx1,cy1,cx2,cy2,shift_down,shift_right,pan_x,pan_y;
    1515  int32_t new_weapon;
    16   uchar send_view,send_weapon_change;
     16  uint8_t send_view,send_weapon_change;
    1717} ;
    1818
     
    2323class view
    2424{
    25   uchar keymap[512/8];
     25  uint8_t keymap[512/8];
    2626  char chat_buf[60];
    2727  public :
     
    8080  view *next;                             // next viewable player (singly linked list) 
    8181  void get_input();
    82   int process_input(char cmd, uchar *&pk);
     82  int process_input(char cmd, uint8_t *&pk);
    8383
    8484  void add_ammo   (int weapon_type, int total);
     
    115115void recalc_local_view_space();
    116116
    117 void process_packet_commands(uchar *pk, int size);
     117void process_packet_commands(uint8_t *pk, int size);
    118118
    119119object_node *make_player_onodes(int player_num=-1);
  • abuse/trunk/src/innet.cpp

    r4 r17  
    210210
    211211    if (!sock) { printf("set_file_server::connect failed\n"); return 0; }
    212     uchar cmd=CLIENT_CRC_WAITER;
     212    uint8_t cmd=CLIENT_CRC_WAITER;
    213213    if ( (sock->write(&cmd,1)!=1 && printf("set_file_server::writefailed\n")) ||
    214214         (sock->read(&cmd,1)!=1  && printf("set_file_server::read failed\n")))        // wait for confirmation that crc's are written
     
    291291                                if (new_sock)
    292292                                {
    293                                   uchar client_type;
     293                                  uint8_t client_type;
    294294                                  if (new_sock->read(&client_type,1)!=1)
    295295                                  {
     
    316316                                      case CLIENT_LSF_WAITER :          // wants to know which .lsp file to start with
    317317                                      {
    318                                                                 uchar len=strlen(lsf);
     318                                                                uint8_t len=strlen(lsf);
    319319                                                                new_sock->write(&len,1);
    320320                                                                new_sock->write(lsf,len);
     
    352352    if (!sock) return 0;
    353353
    354     uchar ctype=CLIENT_LSF_WAITER;
    355     uchar len;
     354    uint8_t ctype=CLIENT_LSF_WAITER;
     355    uint8_t len;
    356356
    357357    if (sock->write(&ctype,1)!=1 ||
     
    391391    }
    392392
    393     uchar ctype=CLIENT_ABUSE;
    394     ushort port=lstl(main_net_cfg->port+1),cnum;
    395 
    396     uchar reg;
     393    uint8_t ctype=CLIENT_ABUSE;
     394    uint16_t port=lstl(main_net_cfg->port+1),cnum;
     395
     396    uint8_t reg;
    397397    if (sock->write(&ctype,1)!=1 ||   // send server out game port
    398398                                sock->read(&reg,1)!=1)        // is remote engine registered?
     
    427427      strcpy(uname,get_login());
    428428    else strcpy(uname,"unknown");
    429     uchar len=strlen(uname)+1;
     429    uint8_t len=strlen(uname)+1;
    430430    short nkills;
    431431
  • abuse/trunk/src/items.cpp

    r2 r17  
    1818    }
    1919
    20     inside=(unsigned char *)jmalloc(tot,"Boundary point list"); 
     20    inside=(uint8_t *)jmalloc(tot,"Boundary point list"); 
    2121  }
    2222
    23   unsigned char *point_on;
     23  uint8_t *point_on;
    2424 
    2525  for (i=0,point_on=data;i<tot-1;i++)
     
    3434
    3535    int j,xp1,yp1,xp2,yp2,maxx,maxy,minx,miny;   
    36     unsigned char *point2,segs_left=0,segs_right=0,segs_down=0;   
     36    uint8_t *point2,segs_left=0,segs_right=0,segs_down=0;   
    3737    int skip_next=0;   
    3838    int check_left=0,check_right=0,check_down=0;
     
    101101{
    102102  int x1,y1,x2,y2,checkx,checky,i; 
    103   unsigned char *point_on; 
     103  uint8_t *point_on; 
    104104  if (tot)
    105105  {
    106     inside=(unsigned char *)jmalloc(tot,"Boundary point list"); 
     106    inside=(uint8_t *)jmalloc(tot,"Boundary point list"); 
    107107  } else inside=NULL;
    108108  for (i=0,point_on=data;i<tot-1;i++)
     
    117117
    118118    int j,xp1,yp1,xp2,yp2,maxx,maxy,minx,miny;   
    119     unsigned char *point2,segs_left=0,segs_right=0,segs_down=0;   
     119    uint8_t *point2,segs_left=0,segs_right=0,segs_down=0;   
    120120    int skip_next=0;   
    121121    int check_left=0,check_right=0,check_down=0;
     
    186186{
    187187  im=load_image(fp);
    188   next=fp->read_short();
     188  next=fp->read_uint16();
    189189}
    190190
     
    192192{
    193193  im=load_image(e,fp);
    194   next=fp->read_short();
     194  next=fp->read_uint16();
    195195}
    196196
    197197foretile::foretile(bFILE *fp)
    198198{
    199   unsigned char *sl;
     199  uint8_t *sl;
    200200  image *img=load_image(fp);
    201201
     
    203203  // create the micro image of the fore tile by aveginging the color values in 2 x 2 space
    204204  // and storeing teh closest match
    205 //  unsigned char *buffer=(unsigned char *)&micro_image;
     205//  uint8_t *buffer=(uint8_t *)&micro_image;
    206206  int x,y,w=img->width(),h=img->height(),l;
    207207  int r[AUTOTILE_WIDTH*AUTOTILE_HEIGHT],
     
    250250  delete img;
    251251
    252   next=fp->read_short();
     252  next=fp->read_uint16();
    253253  fp->read(&damage,1);
    254254
     
    285285    point_list p(fp);
    286286    advance=0;
    287   } else advance=fp->read_byte();
     287  } else advance=fp->read_uint8();
    288288 
    289289  f_damage=new boundary(fp,"fig bound");
     
    296296{
    297297  palette *p=new palette(fp);
    298   uchar *t=data,*p_addr=(uchar *)p->addr();
     298  uint8_t *t=data,*p_addr=(uint8_t *)p->addr();
    299299  for (int i=0;i<256;i++,t++,p_addr+=3) 
    300300    *t=pal->find_closest(*p_addr,p_addr[1],p_addr[2]);
  • abuse/trunk/src/lcache.cpp

    r4 r17  
    4848{
    4949  int type=item_type(level);
    50   fp->write_byte(type);
     50  fp->write_uint8(type);
    5151
    5252
     
    5454  {
    5555    case L_NUMBER :
    56     { fp->write_long(lnumber_value(level)); } break;
     56    { fp->write_uint32(lnumber_value(level)); } break;
    5757    case L_CHARACTER :
    58     { fp->write_short(lcharacter_value(level)); } break;
     58    { fp->write_uint16(lcharacter_value(level)); } break;
    5959    case L_STRING :
    6060    { long l=strlen(lstring_value(level))+1;
    61       fp->write_long(l);
     61      fp->write_uint32(l);
    6262      fp->write(lstring_value(level),l);
    6363    } break;
    6464    case L_SYMBOL :
    65     { fp->write_long((long)level); } break;
     65    { fp->write_uint32((long)level); } break;
    6666    case L_CONS_CELL :
    6767    {
    68       if (!level) fp->write_long(0);
     68      if (!level) fp->write_uint32(0);
    6969      else
    7070      {
     
    7474        if (b)
    7575        {
    76           fp->write_long(-t);      // negative number means dotted list
     76          fp->write_uint32(-t);      // negative number means dotted list
    7777          write_level(fp,b);       // save end of dotted list     
    7878        }
    79         else fp->write_long(t);
     79        else fp->write_uint32(t);
    8080
    8181        for (b=level;b && item_type(b)==L_CONS_CELL;b=CDR(b))   
     
    8888Cell *load_block(bFILE *fp)
    8989{
    90   int type=fp->read_byte();
     90  int type=fp->read_uint8();
    9191  switch (type)
    9292  {   
    9393    case L_NUMBER :
    94     { return new_lisp_number(fp->read_long()); } break;
     94    { return new_lisp_number(fp->read_uint32()); } break;
    9595    case L_CHARACTER :
    96     { return new_lisp_character(fp->read_short()); } break;
     96    { return new_lisp_character(fp->read_uint16()); } break;
    9797    case L_STRING :
    98     { long l=fp->read_long();
     98    { long l=fp->read_uint32();
    9999      lisp_string *s=new_lisp_string(l);
    100100      fp->read(lstring_value(s),l);
     
    102102    } break;
    103103    case L_SYMBOL :
    104     { return (void *)fp->read_long(); } break;
     104    { return (void *)fp->read_uint32(); } break;
    105105    case L_CONS_CELL :
    106106    {
    107       long t=fp->read_long();
     107      long t=fp->read_uint32();
    108108      if (!t) return NULL;
    109109      else
  • abuse/trunk/src/level.cpp

    r16 r17  
    608608  {
    609609    if (!rcheck) rcheck=open_file("rcheck","rb");
    610     int32_t x=rcheck->read_long();
     610    int32_t x=rcheck->read_uint32();
    611611    if (x!=rand_on)
    612612      dprintf("off!\n");
     
    618618      rcheck_lp=open_file("rcheck.lp","wb");
    619619    }
    620     rcheck->write_long(rand_on);
     620    rcheck->write_uint32(rand_on);
    621621  } else
    622622  {
     
    761761}
    762762
    763 void level::set_tick_counter(ulong x)
     763void level::set_tick_counter(uint32_t x)
    764764{
    765765  ctick=x;
     
    867867  {
    868868    fp->seek(se->offset,0);
    869     if (RC_type_size(fp->read_byte())!=size)
     869    if (RC_type_size(fp->read_uint8())!=size)
    870870      return 0;
    871871    else return 1;
     
    886886    fp->seek(se->offset,0);
    887887    /******************************* Read debug info ******************************/
    888     int16_t old_tot=fp->read_short(); 
     888    int16_t old_tot=fp->read_uint16(); 
    889889    uint16_t *o_remap=(uint16_t *)jmalloc(old_tot*2,"obj remap array");   
    890890    char old_name[150];     
    891891    for (i=0;i<old_tot;i++)
    892892    {
    893       fp->read(old_name,fp->read_byte());    // read the name
     893      fp->read(old_name,fp->read_uint8());    // read the name
    894894      for (o_remap[i]=0xffff,j=0;j<total_objects;j++)  // check for matching current name
    895895      {
     
    901901
    902902    /***************************** Read state names *********************************/
    903     int old_stot=fp->read_short();
     903    int old_stot=fp->read_uint16();
    904904    unsigned char *s_remap=(unsigned char *)jmalloc(old_stot,"state remap array");
    905905    for (i=0;i<old_stot;i++)
    906906    {
    907       fp->read(old_name,fp->read_byte());
     907      fp->read(old_name,fp->read_uint8());
    908908      s_remap[i]=stopped;           // non exsitant states get mapped into stopped state
    909909      for (j=0;j<MAX_STATE;j++)                  // see if old state exist now
     
    911911         s_remap[i]=j;
    912912    }
    913     total_objs=fp->read_long();   
     913    total_objs=fp->read_uint32();   
    914914
    915915    se=sd->find("type");
     
    918918      fp->seek(se->offset,0);
    919919      last=NULL;
    920       if (fp->read_byte()==RC_S)    //  read type array, this should be type RC_S
     920      if (fp->read_uint8()==RC_S)    //  read type array, this should be type RC_S
    921921      {
    922922        for (i=0;i<total_objs;i++)
    923923        {
    924           ushort t=fp->read_short();
     924          uint16_t t=fp->read_uint16();
    925925          game_object *p=new game_object(o_remap[t],1);
    926926          clear_tmp();
     
    934934        {
    935935          fp->seek(se->offset,0);
    936           if (fp->read_byte()==RC_S)    //  read state array, this should be type RC_S
     936          if (fp->read_uint8()==RC_S)    //  read state array, this should be type RC_S
    937937          {
    938938            game_object *l=first;
    939939            for (i=0;i<total_objs;i++,l=l->next)
    940940            {
    941               character_state s=(character_state)s_remap[fp->read_short()];
     941              character_state s=(character_state)s_remap[fp->read_uint16()];
    942942              if (l->otype!=0xffff)
    943943              {
     
    965965            fp->seek(se->offset,0);
    966966            int t=object_descriptions[j].type;
    967             if (fp->read_byte()!=t)
     967            if (fp->read_uint8()!=t)
    968968              dprintf("Warning : load level -> var '%s' size changed\n");
    969969            else
     
    974974                switch (t)
    975975                {
    976                   case RC_C : f->set_var(j,fp->read_byte()); break;
    977                   case RC_S : f->set_var(j,fp->read_short()); break;
    978                   case RC_L : f->set_var(j,fp->read_long()); break;
     976                  case RC_C : f->set_var(j,fp->read_uint8()); break;
     977                  case RC_S : f->set_var(j,fp->read_uint16()); break;
     978                  case RC_L : f->set_var(j,fp->read_uint32()); break;
    979979                }
    980980
     
    10181018  {
    10191019    fp->seek(se->offset,0);
    1020     int16_t old_tot=fp->read_short();
     1020    int16_t old_tot=fp->read_uint16();
    10211021    se=sd->find("describe_names");
    10221022    if (!se || !old_tot)
     
    10291029    for (i=0;i<old_tot;i++)
    10301030    {
    1031       fp->read(old_name,fp->read_byte());    // read the name
     1031      fp->read(old_name,fp->read_uint8());    // read the name
    10321032      for (o_remap[i]=0xffff,j=0;j<total_objects;j++)  // check for matching current name
    10331033      {
     
    10481048    for (;i<old_tot;i++)
    10491049    {
    1050       int16_t t=fp->read_short();
     1050      int16_t t=fp->read_uint16();
    10511051      s_remap_totals[i]=t;
    10521052      if (t)
     
    10621062      for (;j<t;j++)
    10631063      {
    1064         fp->read(old_name,fp->read_byte());
     1064        fp->read(old_name,fp->read_uint8());
    10651065        int new_type=o_remap[i];       
    10661066        if (new_type<total_objects)     // make sure old object still exsist
     
    10901090      for (;i<old_tot;i++)
    10911091      {
    1092         int16_t t=fp->read_short();
     1092        int16_t t=fp->read_uint16();
    10931093        v_remap_totals[i]=t;
    10941094        if (t)
     
    11001100        for (;j<t;j++)
    11011101        {
    1102           fp->read(old_name,fp->read_byte());
     1102          fp->read(old_name,fp->read_uint8());
    11031103          int new_type=o_remap[i];
    11041104          if (new_type!=0xffff)        // make sure old object still exsist
     
    11221122    if (se)
    11231123    {
    1124       total_objs=fp->read_long();   
     1124      total_objs=fp->read_uint32();   
    11251125
    11261126      se=sd->find("type");
     
    11291129        fp->seek(se->offset,0);
    11301130        last=NULL;
    1131         if (fp->read_byte()==RC_S)    //  read type array, this should be type RC_S
     1131        if (fp->read_uint8()==RC_S)    //  read type array, this should be type RC_S
    11321132        {
    11331133          int i=0;
    11341134          for (;i<total_objs;i++)
    11351135          {
    1136             ushort t=fp->read_short();
     1136            uint16_t t=fp->read_uint16();
    11371137            game_object *p=new game_object(o_remap[t],1);
    11381138            clear_tmp();
     
    11451145          {
    11461146            fp->seek(se->offset,0);
    1147             if (fp->read_byte()==RC_S)    //  read state array, this should be type RC_S
     1147            if (fp->read_uint8()==RC_S)    //  read state array, this should be type RC_S
    11481148            {
    11491149              game_object *l=first;
    11501150              for (i=0;i<total_objs;i++,l=l->next)
    11511151              {
    1152                 int st=fp->read_short();
     1152                int st=fp->read_uint16();
    11531153                if (l->otype==0xffff)
    11541154                  l->state=stopped;
     
    11731173            for (;o && !abort;o=o->next)
    11741174            {
    1175               int16_t ot=fp->read_short();
     1175              int16_t ot=fp->read_uint16();
    11761176              int k=0;
    11771177              for (;k<ot;k++)
    11781178              {
    1179                 if (fp->read_byte()!=RC_L) abort=1;
     1179                if (fp->read_uint8()!=RC_L) abort=1;
    11801180                else
    11811181                {
    1182                   int32_t v=fp->read_long();
     1182                  int32_t v=fp->read_uint32();
    11831183                  if (o->otype!=0xffff)     // non-exstant object
    11841184                  {
     
    12081208              fp->seek(se->offset,0);
    12091209              int t=object_descriptions[j].type;
    1210               if (fp->read_byte()!=t)
     1210              if (fp->read_uint8()!=t)
    12111211                dprintf("Warning : load level -> var '%s' size changed\n");
    12121212              else
     
    12181218                  {
    12191219                    case RC_C :
    1220                     { f->set_var(j,fp->read_byte()); } break;
     1220                    { f->set_var(j,fp->read_uint8()); } break;
    12211221                    case RC_S :
    1222                     { f->set_var(j,fp->read_short()); } break;
     1222                    { f->set_var(j,fp->read_uint16()); } break;
    12231223                    case RC_L :
    1224                     { f->set_var(j,fp->read_long()); } break;
     1224                    { f->set_var(j,fp->read_uint32()); } break;
    12251225                  }
    12261226                 
     
    12931293  {
    12941294    fp->seek(e->offset,0);
    1295     int len=fp->read_byte();   // read the length of the string
     1295    int len=fp->read_uint8();   // read the length of the string
    12961296    first_name=(char *)jmalloc(len,"level first name");
    12971297    fp->read(first_name,len);    // read the string
     
    13081308  {   
    13091309    fp->seek(e->offset,0);
    1310     fg_width=fp->read_long();
    1311     fg_height=fp->read_long();
     1310    fg_width=fp->read_uint32();
     1311    fg_height=fp->read_uint32();
    13121312    map_fg=(uint16_t *)jmalloc(2*fg_width*fg_height,"Map fg : loaded");
    13131313    fp->read((char *)map_fg,2*fg_width*fg_height);
     
    13261326  {
    13271327    fp->seek(e->offset,0);
    1328     bg_width=fp->read_long();
    1329     bg_height=fp->read_long();
     1328    bg_width=fp->read_uint32();
     1329    bg_height=fp->read_uint32();
    13301330    map_bg=(uint16_t *)jmalloc(2*bg_width*bg_height,"Map bg : loaded");
    13311331    fp->read((char *)map_bg,2*bg_width*bg_height);
     
    16441644  eh->font()->put_string(i,80-strlen(buf)*eh->font()->width()/2,100+eh->font()->height(),buf);
    16451645
    1646   fp->write_short(i->width());
    1647   fp->write_short(i->height());
     1646  fp->write_uint16(i->width());
     1647  fp->write_uint16(i->height());
    16481648  int y=0;
    16491649  for (;y<i->height();y++)
     
    16581658  view *v=player_list;
    16591659  for (;v;v=v->next) t++;
    1660   fp->write_long(t);
     1660  fp->write_uint32(t);
    16611661
    16621662  for (v=player_list;v;v=v->next)
    1663     fp->write_long(object_to_number_in_list(v->focus,save_list));
     1663    fp->write_uint32(object_to_number_in_list(v->focus,save_list));
    16641664
    16651665  int tv=total_view_vars();
     
    16671667  for (;i<tv;i++)
    16681668  {
    1669     fp->write_byte(RC_L);
     1669    fp->write_uint8(RC_L);
    16701670    for (v=player_list;v;v=v->next)
    1671       fp->write_long(v->get_view_var_value(i));
    1672   }
    1673 
    1674   fp->write_byte(RC_L);
    1675   fp->write_long(rand_on);
    1676 
    1677   fp->write_byte(RC_L);
    1678   fp->write_long(total_weapons);
     1671      fp->write_uint32(v->get_view_var_value(i));
     1672  }
     1673
     1674  fp->write_uint8(RC_L);
     1675  fp->write_uint32(rand_on);
     1676
     1677  fp->write_uint8(RC_L);
     1678  fp->write_uint32(total_weapons);
    16791679  for (v=player_list;v;v=v->next)
    16801680    for (i=0;i<total_weapons;i++)
    1681       fp->write_long(v->weapons[i]);
     1681      fp->write_uint32(v->weapons[i]);
    16821682
    16831683  for (v=player_list;v;v=v->next)
    16841684  {
    16851685    int len=strlen(v->name)+1;
    1686     fp->write_byte(len);
     1686    fp->write_uint8(len);
    16871687    fp->write(v->name,len);
    16881688  }
     
    17261726    }
    17271727
    1728     int32_t total_players=fp->read_long();
     1728    int32_t total_players=fp->read_uint32();
    17291729    view *last=NULL;
    17301730    int i=0;
    17311731    for (;i<total_players;i++)   
    17321732    {
    1733       game_object *o=number_to_object_in_list(fp->read_long(),save_list);
     1733      game_object *o=number_to_object_in_list(fp->read_uint32(),save_list);
    17341734      v=new view(o,NULL,0);
    17351735      if (o) o->set_controller(v);
     
    17501750      {
    17511751        fp->seek(se->offset,0);
    1752         if (fp->read_byte()==RC_L)
     1752        if (fp->read_uint8()==RC_L)
    17531753        {
    17541754          for (v=player_list;v;v=v->next)
    1755             v->set_view_var_value(i,fp->read_long());
     1755            v->set_view_var_value(i,fp->read_uint32());
    17561756        }
    17571757      } else
     
    17661766    {
    17671767      fp->seek(se->offset,0);
    1768       if (fp->read_byte()==RC_L)
    1769         rand_on=fp->read_long();
     1768      if (fp->read_uint8()==RC_L)
     1769        rand_on=fp->read_uint32();
    17701770    } else rand_on=0;
    17711771
     
    17741774    {
    17751775      fp->seek(se->offset,0);
    1776       if (fp->read_byte()==RC_L)
    1777       {
    1778         int32_t m=fp->read_long();  // read how many weapons exsisted when last saved
     1776      if (fp->read_uint8()==RC_L)
     1777      {
     1778        int32_t m=fp->read_uint32();  // read how many weapons exsisted when last saved
    17791779        int i;
    17801780        for (v=player_list;v;v=v->next)   
     
    17821782          for (i=0;i<m;i++)
    17831783          {
    1784             int32_t x=fp->read_long();
     1784            int32_t x=fp->read_uint32();
    17851785            if (i<total_weapons)
    17861786            {
     
    18061806      for (v=player_list;v;v=v->next)     
    18071807      {
    1808         uchar len=fp->read_byte();
     1808        uint8_t len=fp->read_uint8();
    18091809        fp->read(v->name,len);
    18101810      }
     
    18541854  // record information in the file about what the data structures look like
    18551855  // right now, so if they change later, they don't get get screwed up
    1856   fp->write_short(total_objects);   // mark how many objects we know about right now 
     1856  fp->write_uint16(total_objects);   // mark how many objects we know about right now 
    18571857
    18581858  int i=0;
    18591859  for (;i<total_objects;i++)   // loop through all the object types we know of
    18601860  {   
    1861     fp->write_byte(strlen(object_names[i])+1);                    // sizeof name   
     1861    fp->write_uint8(strlen(object_names[i])+1);                    // sizeof name   
    18621862    fp->write(object_names[i],strlen(object_names[i])+1);      // write object name
    18631863  }
     
    18711871    for (;j<figures[i]->ts;j++)
    18721872      if (figures[i]->seq[j]) total++;
    1873     fp->write_short(total);
     1873    fp->write_uint16(total);
    18741874
    18751875    for (j=0;j<figures[i]->ts;j++)
     
    18771877      {
    18781878        char *state_name=lstring_value(symbol_name(figures[i]->seq_syms[j]));
    1879         fp->write_byte(strlen(state_name)+1);
     1879        fp->write_uint8(strlen(state_name)+1);
    18801880        fp->write(state_name,strlen(state_name)+1);
    18811881      }
     
    18861886  for (i=0;i<total_objects;i++)
    18871887  {
    1888     fp->write_short(figures[i]->tv);
     1888    fp->write_uint16(figures[i]->tv);
    18891889    int j,x;
    18901890   
     
    18961896        {
    18971897          char *var_name=lstring_value(symbol_name(figures[i]->vars[j]));
    1898           fp->write_byte(strlen(var_name)+1);
     1898          fp->write_uint8(strlen(var_name)+1);
    18991899          fp->write(var_name,strlen(var_name)+1);
    19001900        }
     
    19061906  object_node *o=save_list;
    19071907  for (;o;o=o->next) t++;
    1908   fp->write_long(t);
    1909 
    1910 
    1911   fp->write_byte(RC_S);                                    // save type info for each record
    1912   for (o=save_list;o;o=o->next) fp->write_short(o->me->type());   
    1913 
    1914   fp->write_byte(RC_S);                                    // save state info for each record
    1915   for (o=save_list;o;o=o->next) fp->write_short(o->me->reduced_state());
     1908  fp->write_uint32(t);
     1909
     1910
     1911  fp->write_uint8(RC_S);                                    // save type info for each record
     1912  for (o=save_list;o;o=o->next) fp->write_uint16(o->me->type());   
     1913
     1914  fp->write_uint8(RC_S);                                    // save state info for each record
     1915  for (o=save_list;o;o=o->next) fp->write_uint16(o->me->reduced_state());
    19161916
    19171917  for (o=save_list;o;o=o->next)                            // save lvars
    19181918  {
    1919     fp->write_short(figures[o->me->otype]->tv);
     1919    fp->write_uint16(figures[o->me->otype]->tv);
    19201920    for (i=0;i<figures[o->me->otype]->tv;i++)
    19211921    {
    1922       fp->write_byte(RC_L);                           // for now the only type allowed is int32_t
    1923       fp->write_long(o->me->lvars[i]);
     1922      fp->write_uint8(RC_L);                           // for now the only type allowed is int32_t
     1923      fp->write_uint32(o->me->lvars[i]);
    19241924    }
    19251925  }
     
    19281928  {
    19291929    int t=object_descriptions[i].type;
    1930     fp->write_byte(t);
     1930    fp->write_uint8(t);
    19311931    for (o=save_list;o;o=o->next)
    19321932    {
     
    19341934      {         
    19351935        case RC_C :
    1936         { fp->write_byte(o->me->get_var(i)); } break;
     1936        { fp->write_uint8(o->me->get_var(i)); } break;
    19371937        case RC_S :
    1938         { fp->write_short(o->me->get_var(i)); } break;
     1938        { fp->write_uint16(o->me->get_var(i)); } break;
    19391939        case RC_L :
    1940         { fp->write_long(o->me->get_var(i)); } break;
     1940        { fp->write_uint32(o->me->get_var(i)); } break;
    19411941      }
    19421942    }
     
    19631963void level::write_links(bFILE *fp, object_node *save_list, object_node *exclude_list)
    19641964{
    1965   fp->write_byte(RC_L); 
    1966   fp->write_long(total_object_links(save_list));
     1965  fp->write_uint8(RC_L); 
     1966  fp->write_uint32(total_object_links(save_list));
    19671967
    19681968  int x=1;
     
    19741974    for (;i<o->me->total_objects();i++)
    19751975    {
    1976       fp->write_long(x);
     1976      fp->write_uint32(x);
    19771977      int32_t x=object_to_number_in_list(o->me->get_object(i),save_list);
    19781978      if (x)
    1979         fp->write_long(x);
     1979        fp->write_uint32(x);
    19801980      else                            // save links to excluded items as negative
    1981         fp->write_long((int32_t)(-(object_to_number_in_list(o->me,exclude_list))));
    1982     }
    1983   }
    1984 
    1985   fp->write_byte(RC_L); 
    1986   fp->write_long(total_light_links(save_list));
     1981        fp->write_uint32((int32_t)(-(object_to_number_in_list(o->me,exclude_list))));
     1982    }
     1983  }
     1984
     1985  fp->write_uint8(RC_L); 
     1986  fp->write_uint32(total_light_links(save_list));
    19871987
    19881988  x=1;
     
    19921992    for (;i<o->me->total_lights();i++)
    19931993    {
    1994       fp->write_long(x);
    1995       fp->write_long(light_to_number(o->me->get_light(i)));
     1994      fp->write_uint32(x);
     1995      fp->write_uint32(light_to_number(o->me->get_light(i)));
    19961996    }
    19971997  }
     
    20072007  {
    20082008    fp->seek(se->offset,0);
    2009     if (fp->read_byte()==RC_L)
    2010     {
    2011       int32_t t=fp->read_long();
     2009    if (fp->read_uint8()==RC_L)
     2010    {
     2011      int32_t t=fp->read_uint32();
    20122012      while (t)
    20132013      {
    2014         int32_t x1=fp->read_long();
     2014        int32_t x1=fp->read_uint32();
    20152015        CONDITION(x1>=0,"expected x1 for object link to be > 0\n");
    2016         int32_t x2=fp->read_long();
     2016        int32_t x2=fp->read_uint32();
    20172017        game_object *p,*q=number_to_object_in_list(x1,save_list);
    20182018        if (x2>0)
     
    20322032  {
    20332033    fp->seek(se->offset,0);
    2034     if (fp->read_byte()==RC_L)
    2035     {
    2036       int32_t t=fp->read_long();
     2034    if (fp->read_uint8()==RC_L)
     2035    {
     2036      int32_t t=fp->read_uint32();
    20372037      while (t)
    20382038      {
    2039         int32_t x1=fp->read_long();
    2040         int32_t x2=fp->read_long();
     2039        int32_t x1=fp->read_uint32();
     2040        int32_t x2=fp->read_uint32();
    20412041        game_object *p=number_to_object_in_list(x1,save_list);
    20422042        if (p)
     
    20542054{
    20552055  // save background scroll rate
    2056   fp->write_byte(RC_L);
    2057   fp->write_long(bg_xmul);
    2058   fp->write_long(bg_xdiv);
    2059   fp->write_long(bg_ymul);
    2060   fp->write_long(bg_ydiv);
    2061 
    2062   fp->write_byte(RC_L);
     2056  fp->write_uint8(RC_L);
     2057  fp->write_uint32(bg_xmul);
     2058  fp->write_uint32(bg_xdiv);
     2059  fp->write_uint32(bg_ymul);
     2060  fp->write_uint32(bg_ydiv);
     2061
     2062  fp->write_uint8(RC_L);
    20632063  int ta=0;
    20642064  area_controller *a=area_list;
    20652065  for (;a;a=a->next) ta++;
    2066   fp->write_long(ta);
     2066  fp->write_uint32(ta);
    20672067  for (a=area_list;a;a=a->next)
    20682068  {
    2069     fp->write_long(a->x);
    2070     fp->write_long(a->y);
    2071     fp->write_long(a->w);
    2072     fp->write_long(a->h);
    2073     fp->write_long(a->active);
    2074 
    2075     fp->write_long(a->ambient);
    2076     fp->write_long(a->view_xoff);
    2077     fp->write_long(a->view_yoff);
    2078     fp->write_long(a->ambient_speed);
    2079     fp->write_long(a->view_xoff_speed);
    2080     fp->write_long(a->view_yoff_speed);
    2081   }
    2082   fp->write_byte(RC_L);
    2083   fp->write_long(tick_counter());
     2069    fp->write_uint32(a->x);
     2070    fp->write_uint32(a->y);
     2071    fp->write_uint32(a->w);
     2072    fp->write_uint32(a->h);
     2073    fp->write_uint32(a->active);
     2074
     2075    fp->write_uint32(a->ambient);
     2076    fp->write_uint32(a->view_xoff);
     2077    fp->write_uint32(a->view_yoff);
     2078    fp->write_uint32(a->ambient_speed);
     2079    fp->write_uint32(a->view_xoff_speed);
     2080    fp->write_uint32(a->view_yoff_speed);
     2081  }
     2082  fp->write_uint8(RC_L);
     2083  fp->write_uint32(tick_counter());
    20842084}
    20852085
     
    20902090  {
    20912091    fp->seek(se->offset,0);
    2092     if (fp->read_byte()!=RC_L)
     2092    if (fp->read_uint8()!=RC_L)
    20932093    { bg_xmul=bg_ymul=1; bg_xdiv=bg_ydiv=8; }
    20942094    else
    20952095    {