+void mapstyles(int num, void(*callback)(void*))
+{
+ u16 count;
+ int t;
+ resetbits();
+ count = readu8();
+ if(count == 0xff && num>1) // defineshape2,3 only
+ count = readu16();
+
+// printf("%d fillstyles\n", count);
+ for(t=0;t<count;t++)
+ {
+ int type;
+ u8*pos;
+ pos=getinputpos();
+// printf("%02x %02x %02x %02x %02x %02x %02x %02x\n",
+// pos[0],pos[1],pos[2],pos[3],pos[4],pos[5],pos[6],pos[7]);
+ resetbits();
+ type = readu8(); //type
+// printf("fillstyle %d is type 0x%02x\n", t, type);
+ if(type == 0) {
+// printf("solid fill\n");
+ if(num == 3)
+ readRGBA();
+ else
+ readRGB();
+ }
+ else if(type == 0x10 || type == 0x12)
+ {
+// printf("gradient fill\n");
+ resetbits();
+ readMATRIX();
+ resetbits();
+ readGRADIENT(num);
+ }
+ else if(type == 0x40 || type == 0x41)
+ {
+ resetbits();
+ // we made it.
+// printf("bitmap fill:%04x\n", *(u16*)getinputpos());
+ if(*(u16*)getinputpos() != 65535)
+ (callback)(getinputpos());
+
+ readu16();
+ resetbits();
+ readMATRIX();
+ }
+ else {
+ logf("<error> Unknown fillstyle:0x%02x\n",type);
+ }
+ }
+ resetbits();
+ count = readu8(); // line style array
+// printf("%d linestyles\n", count);
+ if(count == 0xff)
+ count = readu16();
+ for(t=0;t<count;t++)
+ {
+ readu16();
+ if(num == 3)
+ readRGBA();
+ else
+ readRGB();
+ }
+}
+