amiga_imgv
diff src/image.c @ 7:4c36d0f44aa6
lbm loading
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 29 Oct 2017 13:21:11 +0200 |
parents | ae0ada629b03 |
children |
line diff
1.1 --- a/src/image.c Fri Oct 27 15:42:58 2017 +0300 1.2 +++ b/src/image.c Sun Oct 29 13:21:11 2017 +0200 1.3 @@ -4,17 +4,7 @@ 1.4 #include <errno.h> 1.5 #include "image.h" 1.6 #include "logger.h" 1.7 - 1.8 -#ifdef __unix__ 1.9 -#include <arpa/inet.h> 1.10 -#define HAVE_NTOHS 1.11 -#else 1.12 -static int bigendian(void); 1.13 -static uint16_t swap16(uint16_t x); 1.14 -static uint16_t nop16(uint16_t x); 1.15 -static uint16_t (*ntohs)(uint16_t); 1.16 -#endif 1.17 - 1.18 +#include "endian.h" 1.19 1.20 #ifdef __GNUC__ 1.21 #define PACKED __attribute__((packed)) 1.22 @@ -39,10 +29,6 @@ 1.23 struct palchange *tail = 0; 1.24 FILE *fp; 1.25 1.26 -#ifndef HAVE_NTOHS 1.27 - ntohs = bigendian() ? nop16 : swap16; 1.28 -#endif 1.29 - 1.30 logmsg("opening file: %s\n", fname); 1.31 if(!(fp = fopen(fname, "rb"))) { 1.32 logmsg("failed to open %s: %s\n", fname, strerror(errno)); 1.33 @@ -65,6 +51,7 @@ 1.34 img->width = ntohs(hdr.width); 1.35 img->height = ntohs(hdr.height); 1.36 img->nbitplanes = hdr.nbitplanes; 1.37 + img->ham = 1; 1.38 1.39 imgsz = img->width * img->height / 8 * img->nbitplanes; 1.40 1.41 @@ -174,21 +161,3 @@ 1.42 1.43 return img; 1.44 } 1.45 - 1.46 -#ifndef HAVE_NTOHS 1.47 -static int bigendian(void) 1.48 -{ 1.49 - static const uint16_t x = 0xaabb; 1.50 - return *(unsigned char*)&x == 0xaa; 1.51 -} 1.52 - 1.53 -static uint16_t swap16(uint16_t x) 1.54 -{ 1.55 - return (x << 8) | (x >> 8); 1.56 -} 1.57 - 1.58 -static uint16_t nop16(uint16_t x) 1.59 -{ 1.60 - return x; 1.61 -} 1.62 -#endif