- Timestamp:
- 06/02/04 18:59:12 (21 years ago)
- Location:
- ps/trunk/source
- Files:
-
- 3 edited
-
graphics/ObjectEntry.cpp (modified) (1 diff)
-
lib/lib.cpp (modified) (3 diffs)
-
lib/lib.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/source/graphics/ObjectEntry.cpp
r322 r364 14 14 15 15 // Gee's custom error handler 16 #include <ps/XercesErrorHandler.h>16 #include "ps/XercesErrorHandler.h" 17 17 18 18 #ifdef _MSC_VER -
ps/trunk/source/lib/lib.cpp
r350 r364 20 20 #include "lib.h" 21 21 22 #include "sdl.h" // endian functions 23 22 24 23 25 // more powerful atexit, with 0 or 1 parameters. … … 292 294 } 293 295 294 int l = round(in * 255.0);296 int l = (int)(in * 255.0); 295 297 assert((unsigned int)l <= 255); 296 298 return (u8)l; … … 307 309 } 308 310 309 long l = round(in * 65535.0);311 long l = (long)(in * 65535.0); 310 312 assert((unsigned long)l <= 65535); 311 313 return (u16)l; 312 314 } 313 315 316 317 318 319 320 inline u16 read_le16(const void* p) 321 { 322 #if SDL_BYTE_ORDER == SDL_BIG_ENDIAN 323 const u8* _p = (const u8*)p; 324 return (u16)_p[0] | (u16)_p[1] << 8; 325 #else 326 return *(u16*)p; 327 #endif 328 } 329 330 331 inline u32 read_le32(const void* p) 332 { 333 #if SDL_BYTE_ORDER == SDL_BIG_ENDIAN 334 return SDL_Swap32(*(u32*)p); 335 #else 336 return *(u32*)p; 337 #endif 338 } 314 339 315 340 -
ps/trunk/source/lib/lib.h
r349 r364 200 200 inline int atexit2(void (*func)()) 201 201 { 202 atexit2((void *)func);202 return atexit2((void *)func); 203 203 } 204 204 … … 239 239 240 240 241 242 243 static inline u16 read_le16(const void* p) 244 { 245 #if __BYTE_ORDER == __BIG_ENDIAN 246 const u8* _p = (const u8*)p; 247 return (u16)_p[0] | (u16)_p[1] << 8; 248 #else 249 return *(u16*)p; 250 #endif 251 } 252 253 254 static inline u32 read_le32(const void* p) 255 { 256 #if __BYTE_ORDER == __BIG_ENDIAN 257 u32 t = 0; 258 for(int i = 0; i < 4; i++) 259 { 260 t <<= 8; 261 t |= *((const u8*)p)++; 262 } 263 return t; 264 #else 265 return *(u32*)p; 266 #endif 267 } 241 extern u16 read_le16(const void* p); 242 extern u32 read_le32(const void* p); 268 243 269 244
Note:
See TracChangeset
for help on using the changeset viewer.
