?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. /* Example code segment for reading objects (add to playback lib)
  2.  * (C)2004 R Burrows
  3.  *
  4.  * You should be able to call these funcs from the MapLoad
  5.  * part of a playback lib
  6.  * MapGetchksz and MapGetlong should be in the playback lib
  7.  */
  8.  
  9. #define MAXOBJSTR 4096
  10. #define MAXIMGSTR 4096
  11.  
  12. typedef struct { /* Object structure */
  13. int xpos, ypos; /* pixel position in map to handle */
  14. int gfxid, tileid;
  15. int gxoff, gyoff; /* offset into graphic */
  16. int gwidth, gheight;
  17. int ghandlexoff, ghandleyoff; /* handle pos, from gxoff, gyoff */
  18. int show; /* display mode */
  19. int user1, user2, user3, user4, user5, user6, user7;
  20. int flags;
  21. } OBJSTR;
  22.  
  23. typedef struct { /* External image structure */
  24. char * fname;
  25. unsigned char * imgpt;
  26. int w, h, pitch;
  27. } OBJIMGSTR;
  28.  
  29. int curobj, numobjstr;
  30. OBJSTR * objstrpt = NULL;
  31. OBJIMGSTR * objimgpt = NULL;
  32.  
  33. int DecodeOBFNChunk (unsigned char * mdatpt)
  34. {
  35. int i, obfnsz;
  36. OBJIMGSTR * myobjimgpt;
  37.  
  38.         if (objimgpt != NULL) free (objimgpt);
  39.        
  40.         objimgpt = malloc (sizeof(OBJIMGSTR)*MAXIMGSTR);
  41.         memset (objimgpt, 0, sizeof(OBJIMGSTR)*MAXIMGSTR);
  42.         myobjimgpt = (OBJIMGSTR *) objimgpt;
  43.  
  44.         obfnsz = MapGetchksz (mdatpt+4);
  45.         mdatpt += 8;
  46.         i = 0; while (obfnsz > 2) {
  47.                 myobjimgpt[i].fname = malloc (strlen(mdatpt)+1);
  48.                 strcpy (myobjimgpt[i].fname, mdatpt);
  49.                 myobjimgpt[i].imgpt = NULL;
  50.                 obfnsz -= (strlen(mdatpt)+1);
  51.                 mdatpt += (strlen(mdatpt)+1);
  52.                 i++;
  53.         }
  54.        
  55.         return 0;
  56. }
  57.  
  58. int DecodeOBDTChunk (unsigned char * mdatpt)
  59. {
  60. int i, obstrsz;
  61.  
  62.         if (objstrpt != NULL) free (objstrpt);
  63.        
  64.         objstrpt = malloc (sizeof(OBJSTR)*MAXOBJSTR);
  65.         memset (objstrpt, 0, sizeof(OBJSTR)*MAXOBJSTR);
  66.         numobjstr = 1; curobj = 0;
  67.        
  68.         mdatpt += 8;
  69.         i = MapGetlong (mdatpt); /* Offset to OBJSTR */
  70.         if (i < 16) return -1;
  71.         numobjstr = MapGetlong (mdatpt+4);
  72.         curobj = MapGetlong (mdatpt+8);
  73.         obstrsz = MapGetlong (mdatpt+12);
  74.         mdatpt += i;
  75.        
  76.         for (i=0;i<numobjstr;i++) {
  77.                 ((OBJSTR *) objstrpt)[i].xpos = MapGetlong (mdatpt);
  78.                 ((OBJSTR *) objstrpt)[i].ypos = MapGetlong (mdatpt+4);
  79.                 ((OBJSTR *) objstrpt)[i].gfxid = MapGetlong (mdatpt+8);
  80.                 ((OBJSTR *) objstrpt)[i].tileid = MapGetlong (mdatpt+12);
  81.                 ((OBJSTR *) objstrpt)[i].gxoff = MapGetlong (mdatpt+16);
  82.                 ((OBJSTR *) objstrpt)[i].gyoff = MapGetlong (mdatpt+20);
  83.                 ((OBJSTR *) objstrpt)[i].gwidth = MapGetlong (mdatpt+24);
  84.                 ((OBJSTR *) objstrpt)[i].gheight = MapGetlong (mdatpt+28);
  85.                 ((OBJSTR *) objstrpt)[i].ghandlexoff = MapGetlong (mdatpt+32);
  86.                 ((OBJSTR *) objstrpt)[i].ghandleyoff = MapGetlong (mdatpt+36);
  87.                 ((OBJSTR *) objstrpt)[i].show = MapGetlong (mdatpt+40);
  88.                 ((OBJSTR *) objstrpt)[i].user1 = MapGetlong (mdatpt+44);
  89.                 ((OBJSTR *) objstrpt)[i].user2 = MapGetlong (mdatpt+48);
  90.                 ((OBJSTR *) objstrpt)[i].user3 = MapGetlong (mdatpt+52);
  91.                 ((OBJSTR *) objstrpt)[i].user4 = MapGetlong (mdatpt+56);
  92.                 ((OBJSTR *) objstrpt)[i].user5 = MapGetlong (mdatpt+60);
  93.                 ((OBJSTR *) objstrpt)[i].user6 = MapGetlong (mdatpt+64);
  94.                 ((OBJSTR *) objstrpt)[i].user7 = MapGetlong (mdatpt+68);
  95.                 ((OBJSTR *) objstrpt)[i].flags = MapGetlong (mdatpt+72);
  96.                 mdatpt += obstrsz;
  97.         }
  98.  
  99.         return 0;
  100. }
  101.