diff --git a/modules/NIGHTDLL/nt_msg.c b/modules/NIGHTDLL/nt_msg.c index 876d8f4..bb2b544 100644 --- a/modules/NIGHTDLL/nt_msg.c +++ b/modules/NIGHTDLL/nt_msg.c @@ -55,7 +55,7 @@ extern int ntsel_dosel(void); static void ntmsg_out(int wNum, int wSize, int wColorR, int wColorG, int wColorB, int wFont, int wSpeed, int wLineSpace); static void set_align(char *msg, sprite_t *sp, int wSize); -static BYTE *get_char(BYTE *msg, char *mbuf, int bufmax); +static uint8_t *get_char(uint8_t *msg, char *mbuf, int bufmax); static void cb_keyrelease(agsevent_t *e); static void cb_mousemove(agsevent_t *e); static void setup_hakanim(); @@ -177,7 +177,7 @@ void ntmsg_set_place(int type) { } void ntmsg_newline() { - BYTE buf[2] = {'\n', '\0'}; + uint8_t buf[2] = {'\n', '\0'}; ntmsg_add(buf); } @@ -371,14 +371,14 @@ static void set_align(char *msg, sprite_t *sp, int wSize) { } -static BYTE *get_char(BYTE *msg, char *mbuf, int bufmax) { +static uint8_t *get_char(uint8_t *msg, char *mbuf, int bufmax) { if (msg[0] == '\n') { mbuf[0] = '\n'; mbuf[1] = '\0'; return msg +1; } - BYTE *p = advance_char(msg, nact->encoding); + uint8_t *p = advance_char(msg, nact->encoding); while (msg < p) *mbuf++ = *msg++; *mbuf = '\0'; diff --git a/modules/NIGHTDLL/sactcg_stretch.c b/modules/NIGHTDLL/sactcg_stretch.c index 78b18a2..ccbad8d 100644 --- a/modules/NIGHTDLL/sactcg_stretch.c +++ b/modules/NIGHTDLL/sactcg_stretch.c @@ -5,7 +5,7 @@ static surface_t *stretch(surface_t *src, int dw, int dh, int mirror) { int sw, sh; int *row, *col; int x, y; - BYTE *sdata, *ddata; + uint8_t *sdata, *ddata; dst->width = dw; dst->height = dh; @@ -57,14 +57,14 @@ static surface_t *stretch(surface_t *src, int dw, int dh, int mirror) { #define SCALEDCOPYAREA(type) { \ int x, y; \ type *sl, *dl; \ - BYTE *_sl, *_dl; \ + uint8_t *_sl, *_dl; \ for (y = 0; y < dh; y++) { \ sl = (type *)(sdata + *(y + col) * src->bytes_per_line);\ dl = (type *)(ddata + y * dst->bytes_per_line);\ for (x = 0; x < dw; x++) { \ *(dl + x) = *(sl + *(row + x)); \ } \ - _dl = (BYTE *)dl; \ + _dl = (uint8_t *)dl; \ while(*(col + y) == *(col + y + 1)) { \ _sl = _dl; \ _dl += dst->bytes_per_line; \ @@ -75,29 +75,29 @@ static surface_t *stretch(surface_t *src, int dw, int dh, int mirror) { switch(dst->depth) { case 8: - SCALEDCOPYAREA(BYTE); break; + SCALEDCOPYAREA(uint8_t); break; case 16: - SCALEDCOPYAREA(WORD); break; + SCALEDCOPYAREA(uint16_t); break; case 24: case 32: - SCALEDCOPYAREA(DWORD); break; + SCALEDCOPYAREA(uint32_t); break; default: break; } if (src->alpha) { int x, y; - BYTE *sl, *dl; - BYTE *_sl, *_dl; + uint8_t *sl, *dl; + uint8_t *_sl, *_dl; sdata = GETOFFSET_ALPHA(src, 0, 0); ddata = GETOFFSET_ALPHA(dst, 0, 0); for (y = 0; y < dh; y++) { - sl = (BYTE *)(sdata + *(y + col) * src->width); - dl = (BYTE *)(ddata + y * dst->width); + sl = (uint8_t *)(sdata + *(y + col) * src->width); + dl = (uint8_t *)(ddata + y * dst->width); for (x = 0; x < dw; x++) { *(dl + x) = *(sl + *(row + x)); } - _dl = (BYTE *)dl; + _dl = (uint8_t *)dl; while(*(col + y) == *(col + y + 1)) { _sl = _dl; _dl += dst->width; diff --git a/modules/SACT/sactamask.c b/modules/SACT/sactamask.c index 354a28b..0160760 100644 --- a/modules/SACT/sactamask.c +++ b/modules/SACT/sactamask.c @@ -99,8 +99,8 @@ static surface_t *smask_get(int no) { // ベースになるマスクの alpha 値を拡大して取り出す static surface_t *smask_mul(surface_t *sf, int val) { surface_t *out = sf_create_alpha(sf->width, sf->height); - BYTE *src = sf->alpha; - BYTE *dst = out->alpha; + uint8_t *src = sf->alpha; + uint8_t *dst = out->alpha; int pix = sf->width * sf->height; while(pix--) { diff --git a/modules/SACT/sactcg_stretch.c b/modules/SACT/sactcg_stretch.c index 78b18a2..ccbad8d 100644 --- a/modules/SACT/sactcg_stretch.c +++ b/modules/SACT/sactcg_stretch.c @@ -5,7 +5,7 @@ static surface_t *stretch(surface_t *src, int dw, int dh, int mirror) { int sw, sh; int *row, *col; int x, y; - BYTE *sdata, *ddata; + uint8_t *sdata, *ddata; dst->width = dw; dst->height = dh; @@ -57,14 +57,14 @@ static surface_t *stretch(surface_t *src, int dw, int dh, int mirror) { #define SCALEDCOPYAREA(type) { \ int x, y; \ type *sl, *dl; \ - BYTE *_sl, *_dl; \ + uint8_t *_sl, *_dl; \ for (y = 0; y < dh; y++) { \ sl = (type *)(sdata + *(y + col) * src->bytes_per_line);\ dl = (type *)(ddata + y * dst->bytes_per_line);\ for (x = 0; x < dw; x++) { \ *(dl + x) = *(sl + *(row + x)); \ } \ - _dl = (BYTE *)dl; \ + _dl = (uint8_t *)dl; \ while(*(col + y) == *(col + y + 1)) { \ _sl = _dl; \ _dl += dst->bytes_per_line; \ @@ -75,29 +75,29 @@ static surface_t *stretch(surface_t *src, int dw, int dh, int mirror) { switch(dst->depth) { case 8: - SCALEDCOPYAREA(BYTE); break; + SCALEDCOPYAREA(uint8_t); break; case 16: - SCALEDCOPYAREA(WORD); break; + SCALEDCOPYAREA(uint16_t); break; case 24: case 32: - SCALEDCOPYAREA(DWORD); break; + SCALEDCOPYAREA(uint32_t); break; default: break; } if (src->alpha) { int x, y; - BYTE *sl, *dl; - BYTE *_sl, *_dl; + uint8_t *sl, *dl; + uint8_t *_sl, *_dl; sdata = GETOFFSET_ALPHA(src, 0, 0); ddata = GETOFFSET_ALPHA(dst, 0, 0); for (y = 0; y < dh; y++) { - sl = (BYTE *)(sdata + *(y + col) * src->width); - dl = (BYTE *)(ddata + y * dst->width); + sl = (uint8_t *)(sdata + *(y + col) * src->width); + dl = (uint8_t *)(ddata + y * dst->width); for (x = 0; x < dw; x++) { *(dl + x) = *(sl + *(row + x)); } - _dl = (BYTE *)dl; + _dl = (uint8_t *)dl; while(*(col + y) == *(col + y + 1)) { _sl = _dl; _dl += dst->width; diff --git a/modules/SACT/sprite.c b/modules/SACT/sprite.c index 3511ab9..dbf1168 100644 --- a/modules/SACT/sprite.c +++ b/modules/SACT/sprite.c @@ -728,10 +728,10 @@ int sp_sound_ob(int wNumWave) { * @return: TRUE:入っている, FALSE: 入っていない */ boolean sp_is_insprite(sprite_t *sp, int x, int y) { - BYTE *dp; + uint8_t *dp; if (x < 0 || y < 0 || x >= sf0->width || y >= sf0->height) return FALSE; dp = GETOFFSET_PIXEL(sact.dmap, x, y); - return (*(WORD *)dp == sp->no); + return (*(uint16_t *)dp == sp->no); } diff --git a/modules/SACT/sprite_draw.c b/modules/SACT/sprite_draw.c index ba97c7b..6b1a253 100644 --- a/modules/SACT/sprite_draw.c +++ b/modules/SACT/sprite_draw.c @@ -35,20 +35,20 @@ #include "ngraph.h" #include "sprite.h" -static void fill_dmap(int dx ,int dy, int w, int h, WORD val); -static void fill_dmap_mask(surface_t *src, int sx, int sy, int dx ,int dy, int w, int h, WORD val); +static void fill_dmap(int dx ,int dy, int w, int h, uint16_t val); +static void fill_dmap_mask(surface_t *src, int sx, int sy, int dx ,int dy, int w, int h, uint16_t val); // 矩形の depthmap を描画 -static void fill_dmap(int dx ,int dy, int w, int h, WORD val) { - BYTE *dp, *dp_; +static void fill_dmap(int dx ,int dy, int w, int h, uint16_t val) { + uint8_t *dp, *dp_; int x, y; dp = dp_ = (GETOFFSET_PIXEL(sact.dmap, dx, dy)); for (x = 0; x < w; x++) { - *((WORD *)dp + x) = val; + *((uint16_t *)dp + x) = val; } dp += sact.dmap->bytes_per_line; @@ -59,16 +59,16 @@ static void fill_dmap(int dx ,int dy, int w, int h, WORD val) { } // alphamapにしたがって、alpha値が0より大きいところを指定のdepthとする -static void fill_dmap_mask(surface_t *src, int sx, int sy, int dx ,int dy, int w, int h, WORD val) { - BYTE *sp, *dp; +static void fill_dmap_mask(surface_t *src, int sx, int sy, int dx ,int dy, int w, int h, uint16_t val) { + uint8_t *sp, *dp; int x, y; dp = GETOFFSET_PIXEL(sact.dmap, dx, dy); sp = GETOFFSET_ALPHA(src, sx, sy); for (y = 0; y < h; y++) { - BYTE *yls = (BYTE *)(sp + y * src->width); - WORD *yld = (WORD *)(dp + y * sact.dmap->bytes_per_line); + uint8_t *yls = (uint8_t *)(sp + y * src->width); + uint16_t *yld = (uint16_t *)(dp + y * sact.dmap->bytes_per_line); for (x = 0; x < w; x++) { if (*yls > 0) *yld = val; yls++; yld++; diff --git a/modules/SACT/sprite_msg.c b/modules/SACT/sprite_msg.c index 863d3af..8dae741 100644 --- a/modules/SACT/sprite_msg.c +++ b/modules/SACT/sprite_msg.c @@ -51,8 +51,8 @@ static void replacestr_cb(void* data, void* userdata); static char *replacestr(char *msg); static void update_mark(sprite_t *sp, cginfo_t *cg); static int setupmark(int wNum1, int wNum2, struct markinfo *minfo); -static int get_linelen(BYTE *msg); -static BYTE *get_char(BYTE *msg, char *mbuf, char *rbuf, int bufmax); +static int get_linelen(uint8_t *msg); +static uint8_t *get_char(uint8_t *msg, char *mbuf, char *rbuf, int bufmax); static void append_to_log(char *msg); static void sactlog_newline(); static void set_align(char *msg, sprite_t *sp, int wSize, int wAlign); @@ -210,7 +210,7 @@ void smsg_add(const char *msg) { @param size: 改行幅 */ void smsg_newline(int wNum, int size) { - BYTE buf[3]; + uint8_t buf[3]; if (!is_messagesprite(wNum)) return; @@ -468,7 +468,7 @@ int smsg_update(sprite_t *sp) { } // 改行を含む文字列バッファ中から、改行までの文字列の長さを取り出す -static int get_linelen(BYTE *msg) { +static int get_linelen(uint8_t *msg) { int c = 0; while (*msg) { @@ -494,7 +494,7 @@ static int get_linelen(BYTE *msg) { // 改行の場合 : 改行幅もいっしょに // ルビつき文字の場合: メッセージ本体と対応するルビ文字列 // それ以外 : 全角|半角文字1文字 -static BYTE *get_char(BYTE *msg, char *mbuf, char *rbuf, int bufmax) { +static uint8_t *get_char(uint8_t *msg, char *mbuf, char *rbuf, int bufmax) { if (msg[0] == '\n') { mbuf[0] = '\n'; mbuf[1] = msg[1]; @@ -515,7 +515,7 @@ static BYTE *get_char(BYTE *msg, char *mbuf, char *rbuf, int bufmax) { } msg++; rbuf[i] = '\0'; } else { - BYTE *p = advance_char(msg, nact->encoding); + uint8_t *p = advance_char(msg, nact->encoding); while (msg < p) *mbuf++ = *msg++; *mbuf = '\0'; diff --git a/modules/ShArray/ShArray.c b/modules/ShArray/ShArray.c index 87bff67..11c36b5 100644 --- a/modules/ShArray/ShArray.c +++ b/modules/ShArray/ShArray.c @@ -1270,7 +1270,7 @@ static void ChangeSecretArray(void) { /* 53 */ int cnt = getCaliValue(); int type = getCaliValue(); int *vResult = getCaliVariable(); - static WORD key[4] = { 0x7A7A, 0xADAD, 0xBCBC, 0xCECE }; /* key */ + static uint16_t key[4] = { 0x7A7A, 0xADAD, 0xBCBC, 0xCECE }; /* key */ DEBUG_COMMAND("ShArray.ChangeSecretArray %p,%d,%d,%p:", vAry, cnt, type, vResult); @@ -1301,7 +1301,7 @@ static void ChangeSecretArray(void) { /* 53 */ エンコードその1 */ int i, j = 0; - WORD ax = key[3] ^ 0x5a5a; + uint16_t ax = key[3] ^ 0x5a5a; for (i = 0; i < cnt; i++) { (*vAry) ^= ax; ax = (key[i&3] ^ *vAry); j ^= ax; @@ -1322,7 +1322,7 @@ static void ChangeSecretArray(void) { /* 53 */ エンコードその2 */ int i, j = 0, k; - WORD ax = key[3] ^ 0x5a5a; + uint16_t ax = key[3] ^ 0x5a5a; for (i = 0; i < cnt; i++) { k = *vAry; *vAry ^= ax; ax = (key[i&3] ^ k); diff --git a/modules/ShGraph/ShGraph.c b/modules/ShGraph/ShGraph.c index 975fad8..d0999cf 100644 --- a/modules/ShGraph/ShGraph.c +++ b/modules/ShGraph/ShGraph.c @@ -136,7 +136,7 @@ static void ChangeNotColor() { int p7 = getCaliValue(); /* ISurface */ agsurface_t *dib; int x, y; - BYTE *dp; + uint8_t *dp; DEBUG_COMMAND("ShGraph.ChangeNotColor %d,%d,%d,%d,%p,%p,%d:", x0, y0, width, height, src, dst, p7); @@ -148,12 +148,12 @@ static void ChangeNotColor() { switch(dib->depth) { case 16: { - WORD pic16s = PIX16(*src, *(src+1), *(src+2)); - WORD pic16d = PIX16(*dst, *(dst+1), *(dst+2)); - WORD *yl; + uint16_t pic16s = PIX16(*src, *(src+1), *(src+2)); + uint16_t pic16d = PIX16(*dst, *(dst+1), *(dst+2)); + uint16_t *yl; for (y = 0; y < height; y++) { - yl = (WORD *)(dp + y * dib->bytes_per_line); + yl = (uint16_t *)(dp + y * dib->bytes_per_line); for (x = 0; x < width; x++) { if (*yl != pic16s) { *yl = pic16d; @@ -166,12 +166,12 @@ static void ChangeNotColor() { case 24: case 32: { - DWORD pic24s = PIX24(*src, *(src+1), *(src+2)) & 0xf0f0f0; - DWORD pic24d = PIX24(*dst, *(dst+1), *(dst+2)) & 0xf0f0f0; - DWORD *yl; + uint32_t pic24s = PIX24(*src, *(src+1), *(src+2)) & 0xf0f0f0; + uint32_t pic24d = PIX24(*dst, *(dst+1), *(dst+2)) & 0xf0f0f0; + uint32_t *yl; for (y = 0; y < height; y++) { - yl = (DWORD *)(dp + y * dib->bytes_per_line); + yl = (uint32_t *)(dp + y * dib->bytes_per_line); for (x = 0; x < width; x++) { if ((*yl & 0xf0f0f0) != pic24s) { *yl = pic24d; @@ -551,7 +551,7 @@ static void PlayAnimeData() { static void copy_sprite(int sx, int sy, int width, int height, int dx, int dy, int r, int g, int b) { int x, y; - BYTE *sp, *dp; + uint8_t *sp, *dp; agsurface_t *dib; if (dx < 0 || dy < 0) return; @@ -567,12 +567,12 @@ static void copy_sprite(int sx, int sy, int width, int height, int dx, int dy, i switch(dib->depth) { case 16: { - WORD pic16 = PIX16(r, g, b); - WORD *yls, *yld; + uint16_t pic16 = PIX16(r, g, b); + uint16_t *yls, *yld; for (y = 0; y < height; y++) { - yls = (WORD *)(sp + y * dib->bytes_per_line); - yld = (WORD *)(dp + y * dib->bytes_per_line); + yls = (uint16_t *)(sp + y * dib->bytes_per_line); + yld = (uint16_t *)(dp + y * dib->bytes_per_line); for (x = 0; x < width; x++) { if (*yls != pic16) { *yld = *yls; @@ -585,12 +585,12 @@ static void copy_sprite(int sx, int sy, int width, int height, int dx, int dy, i case 24: case 32: { - DWORD pic24 = PIX24(r, g, b) & 0xf0f0f0; - DWORD *yls, *yld; + uint32_t pic24 = PIX24(r, g, b) & 0xf0f0f0; + uint32_t *yls, *yld; for (y = 0; y < height; y++) { - yls = (DWORD *)(sp + y * dib->bytes_per_line); - yld = (DWORD *)(dp + y * dib->bytes_per_line); + yls = (uint32_t *)(sp + y * dib->bytes_per_line); + yld = (uint32_t *)(dp + y * dib->bytes_per_line); for (x = 0; x < width; x++) { if ((*yls & 0xf0f0f0) != pic24) { *yld = *yls; diff --git a/modules/ShPort/ShPort.c b/modules/ShPort/ShPort.c index d45c563..0b07925 100644 --- a/modules/ShPort/ShPort.c +++ b/modules/ShPort/ShPort.c @@ -41,7 +41,7 @@ // キー変換テーブル #define KEYMAP_MAX 8 -static BYTE *keymap[KEYMAP_MAX]; +static uint8_t *keymap[KEYMAP_MAX]; static void OutputMessageBox(void) { /* 0 */ int p1 = getCaliValue(); @@ -82,7 +82,7 @@ static void InputListNum(void) { /* 1 */ if (ni_param.value < 0) { *res = 0; } else { - *val = (WORD)ni_param.value; + *val = (uint16_t)ni_param.value; *res = 1; } @@ -115,7 +115,7 @@ static void InitKeyStatus(void) { } if (keymap[no -1] == NULL) { - keymap[no -1] = calloc(256, sizeof(BYTE)); + keymap[no -1] = calloc(256, sizeof(uint8_t)); } else { memset(keymap[no -1], 0, 256); } diff --git a/modules/lib/cg.c b/modules/lib/cg.c index e4726c4..c717af0 100644 --- a/modules/lib/cg.c +++ b/modules/lib/cg.c @@ -46,7 +46,7 @@ * @param data: データ列 * @return CGの種類(QNT/PMS8/PMS16のいずれか) */ -static CG_TYPE check_cgformat(BYTE *data) { +static CG_TYPE check_cgformat(uint8_t *data) { if (qnt_checkfmt(data)) { return ALCG_QNT; } else if (pms256_checkfmt(data)) { diff --git a/modules/lib/graph.c b/modules/lib/graph.c index 43196bf..5b266b6 100644 --- a/modules/lib/graph.c +++ b/modules/lib/graph.c @@ -246,7 +246,7 @@ void gr_copy_stretch_blend_alpha_map(surface_t *dst, int dx, int dy, int dw, int float a1, a2, xd, yd; int *row, *col; int x, y; - BYTE *sp, *dp, *sa; + uint8_t *sp, *dp, *sa; if (!gr_clip_xywh(dst, &dx, &dy, &dw, &dh)) return; if (!gr_clip_xywh(src, &sx, &sy, &sw, &sh)) return; @@ -274,13 +274,13 @@ void gr_copy_stretch_blend_alpha_map(surface_t *dst, int dx, int dy, int dw, int switch(dst->depth) { case 16: { - WORD *yls, *yld; - BYTE *yla; + uint16_t *yls, *yld; + uint8_t *yla; for (y = 0; y < dh; y++) { - yls = (WORD *)(sp + *(y + col) * src->bytes_per_line); - yld = (WORD *)(dp + y * dst->bytes_per_line); - yla = (BYTE *)(sa + *(y + col) * src->width); + yls = (uint16_t *)(sp + *(y + col) * src->bytes_per_line); + yld = (uint16_t *)(dp + y * dst->bytes_per_line); + yla = (uint8_t *)(sa + *(y + col) * src->width); for (x = 0; x < dw; x++) { *(yld + x) = ALPHABLEND16(*(yls+ *(row + x)), *(yld+x), *(yla+*(row+x))); } @@ -297,13 +297,13 @@ void gr_copy_stretch_blend_alpha_map(surface_t *dst, int dx, int dy, int dw, int case 24: case 32: { - DWORD *yls, *yld; - BYTE *yla; + uint32_t *yls, *yld; + uint8_t *yla; for (y = 0; y < dh; y++) { - yls = (DWORD *)(sp + *(y + col) * src->bytes_per_line); - yld = (DWORD *)(dp + y * dst->bytes_per_line); - yla = (BYTE *)(sa + *(y + col) * src->width); + yls = (uint32_t *)(sp + *(y + col) * src->bytes_per_line); + yld = (uint32_t *)(dp + y * dst->bytes_per_line); + yla = (uint8_t *)(sa + *(y + col) * src->width); for (x = 0; x < dw; x++) { *(yld + x) = ALPHABLEND24(*(yls+ *(row + x)), *(yld+x), *(yla+*(row+x))); } diff --git a/modules/lib/graph2.c b/modules/lib/graph2.c index 25be2fb..2df1955 100644 --- a/modules/lib/graph2.c +++ b/modules/lib/graph2.c @@ -1,5 +1,5 @@ void gr_fill_alpha_overborder(surface_t *dst, int dx, int dy, int dw, int dh, int s, int d) { - BYTE *dp; + uint8_t *dp; int x, y; if (dst == NULL) return; @@ -10,14 +10,14 @@ void gr_fill_alpha_overborder(surface_t *dst, int dx, int dy, int dw, int dh, in for (y = 0; y < dh; y++) { for (x = 0; x < dw; x++) { - if (*(dp + x) >= (BYTE)s) *(dp + x) = (BYTE)d; + if (*(dp + x) >= (uint8_t)s) *(dp + x) = (uint8_t)d; } dp += dst->width; } } void gr_fill_alpha_underborder(surface_t *dst, int dx, int dy, int dw, int dh, int s, int d) { - BYTE *dp; + uint8_t *dp; int x, y; if (dst == NULL) return; @@ -28,14 +28,14 @@ void gr_fill_alpha_underborder(surface_t *dst, int dx, int dy, int dw, int dh, i for (y = 0; y < dh; y++) { for (x = 0; x < dw; x++) { - if (*(dp + x) <= (BYTE)s) *(dp + x) = (BYTE)d; + if (*(dp + x) <= (uint8_t)s) *(dp + x) = (uint8_t)d; } dp += dst->width; } } void gr_copy_alpha_map_sprite(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh, int cl) { - BYTE *sp, *dp; + uint8_t *sp, *dp; int x, y; if (!gr_clip(src, &sx, &sy, &sw, &sh, dst, &dx, &dy)) return; @@ -86,7 +86,7 @@ void gr_blend_alpha_wds_stretch2x2(surface_t *src1, int sx1, int sy1, surface_t void gr_blend_alpha_wds(surface_t *src1, int sx1, int sy1, surface_t *src2, int sx2, int sy2, int sw, int sh, surface_t *dst, int dx, int dy) { int x, y; - BYTE *sp1, *sp2, *dp, *sa; + uint8_t *sp1, *sp2, *dp, *sa; sp1 = GETOFFSET_PIXEL(src1, sx1, sy1); sp2 = GETOFFSET_PIXEL(src2, sx2, sy2); @@ -96,14 +96,14 @@ void gr_blend_alpha_wds(surface_t *src1, int sx1, int sy1, surface_t *src2, int switch(dst->depth) { case 16: { - WORD *yls1, *yls2, *yld; - BYTE *yla; + uint16_t *yls1, *yls2, *yld; + uint8_t *yla; for (y = 0; y < sh; y++) { - yls1 = (WORD *)(sp1 + y * src1->bytes_per_line); - yls2 = (WORD *)(sp2 + y * src2->bytes_per_line); - yld = (WORD *)(dp + y * dst->bytes_per_line); - yla = (BYTE *)(sa + y * src1->width); + yls1 = (uint16_t *)(sp1 + y * src1->bytes_per_line); + yls2 = (uint16_t *)(sp2 + y * src2->bytes_per_line); + yld = (uint16_t *)(dp + y * dst->bytes_per_line); + yla = (uint8_t *)(sa + y * src1->width); for (x = 0; x < sw; x++) { *yld = SUTURADD16(*yls1, ALPHABLEND16(*yls1, *yls2, *yla)); @@ -116,14 +116,14 @@ void gr_blend_alpha_wds(surface_t *src1, int sx1, int sy1, surface_t *src2, int case 24: case 32: { - DWORD *yls1, *yls2, *yld; - BYTE *yla; + uint32_t *yls1, *yls2, *yld; + uint8_t *yla; for (y = 0; y < sh; y++) { - yls1 = (DWORD *)(sp1 + y * src1->bytes_per_line); - yls2 = (DWORD *)(sp2 + y * src2->bytes_per_line); - yld = (DWORD *)(dp + y * dst->bytes_per_line); - yla = (BYTE *)(sa + y * src1->width); + yls1 = (uint32_t *)(sp1 + y * src1->bytes_per_line); + yls2 = (uint32_t *)(sp2 + y * src2->bytes_per_line); + yld = (uint32_t *)(dp + y * dst->bytes_per_line); + yla = (uint8_t *)(sa + y * src1->width); for (x = 0; x < sw; x++) { *yld = SUTURADD24(*yls1, ALPHABLEND24(*yls1, *yls2, *yla)); diff --git a/modules/lib/graph_cg.c b/modules/lib/graph_cg.c index b4a5f48..febd3ca 100644 --- a/modules/lib/graph_cg.c +++ b/modules/lib/graph_cg.c @@ -42,7 +42,7 @@ */ void gr_drawimage24(surface_t *ds, cgdata *cg, int x, int y) { int dx, dy, dw, dh; - BYTE *sp, *dp, r, g, b; + uint8_t *sp, *dp, r, g, b; dx = x; dy = y; @@ -53,16 +53,16 @@ void gr_drawimage24(surface_t *ds, cgdata *cg, int x, int y) { int data_offset = (abs(dy - y) * cg->width + abs(dx - x)) * 3; - sp = (BYTE *)(cg->pic + data_offset); + sp = (uint8_t *)(cg->pic + data_offset); dp = GETOFFSET_PIXEL(ds, dx, dy); switch(ds->depth) { case 16: { - WORD *yl; + uint16_t *yl; for (y = 0; y < dh; y++) { - yl = (WORD *)(dp + y * ds->bytes_per_line); + yl = (uint16_t *)(dp + y * ds->bytes_per_line); for (x = 0; x < dw; x++) { r = *sp; g = *(sp +1); @@ -78,10 +78,10 @@ void gr_drawimage24(surface_t *ds, cgdata *cg, int x, int y) { case 24: case 32: { - DWORD *yl; + uint32_t *yl; for (y = 0; y < dh; y++) { - yl = (DWORD *)(dp + y * ds->bytes_per_line); + yl = (uint32_t *)(dp + y * ds->bytes_per_line); for (x = 0; x < dw; x++) { r = *sp; g = *(sp +1); @@ -105,8 +105,8 @@ void gr_drawimage24(surface_t *ds, cgdata *cg, int x, int y) { */ void gr_drawimage16(surface_t *ds, cgdata *cg, int x, int y) { int dx, dy, dw, dh; - BYTE *dp; - WORD pic16, *sp; + uint8_t *dp; + uint16_t pic16, *sp; dx = x; dy = y; @@ -117,7 +117,7 @@ void gr_drawimage16(surface_t *ds, cgdata *cg, int x, int y) { int data_offset = (abs(dy - y) * cg->width + abs(dx - x)) * 2; - sp = (WORD *)(cg->pic + data_offset); + sp = (uint16_t *)(cg->pic + data_offset); dp = GETOFFSET_PIXEL(ds, dx, dy); switch(ds->depth) { @@ -134,10 +134,10 @@ void gr_drawimage16(surface_t *ds, cgdata *cg, int x, int y) { case 24: case 32: { - DWORD *yl; + uint32_t *yl; for (y = 0; y < dh; y++) { - yl = (DWORD *)(dp + y * ds->bytes_per_line); + yl = (uint32_t *)(dp + y * ds->bytes_per_line); for (x = 0; x < dw; x++) { pic16 = *sp; *yl = PIX24(PIXR16(pic16), PIXG16(pic16), PIXB16(pic16)); diff --git a/modules/lib/graph_copy.c b/modules/lib/graph_copy.c index 1890673..b240da1 100644 --- a/modules/lib/graph_copy.c +++ b/modules/lib/graph_copy.c @@ -42,7 +42,7 @@ * @param sh: 転送高さ */ int gr_copy(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh) { - BYTE *sp, *dp; + uint8_t *sp, *dp; if (src == NULL || dst == NULL) return NG; if (!gr_clip(src, &sx, &sy, &sw, &sh, dst, &dx, &dy)) return NG; diff --git a/modules/lib/graph_copy_amap.c b/modules/lib/graph_copy_amap.c index 58529d9..6f6f9d5 100644 --- a/modules/lib/graph_copy_amap.c +++ b/modules/lib/graph_copy_amap.c @@ -42,7 +42,7 @@ * @param sh: 転送高さ */ int gr_copy_alpha_map(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh) { - BYTE *sp, *dp; + uint8_t *sp, *dp; if (!gr_clip(src, &sx, &sy, &sw, &sh, dst, &dx, &dy)) return NG; diff --git a/modules/lib/graph_copy_bright.c b/modules/lib/graph_copy_bright.c index 306fd48..1b8edfc 100644 --- a/modules/lib/graph_copy_bright.c +++ b/modules/lib/graph_copy_bright.c @@ -9,7 +9,7 @@ void gr_copy_bright(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, int lv) { int x, y; - BYTE *sp, *dp; + uint8_t *sp, *dp; if (!gr_clip(src, &sx, &sy, &width, &height, dst, &dx, &dy)) return; @@ -21,11 +21,11 @@ void gr_copy_bright(surface_t *dst, int dx, int dy, surface_t *src, int sx, int switch(dst->depth) { case 16: { - WORD *yls, *yld; + uint16_t *yls, *yld; for (y = 0; y < height; y++) { - yls = (WORD *)(sp + y * src->bytes_per_line); - yld = (WORD *)(dp + y * dst->bytes_per_line); + yls = (uint16_t *)(sp + y * src->bytes_per_line); + yld = (uint16_t *)(dp + y * dst->bytes_per_line); for (x = 0; x < width; x++) { *yld = ALPHALEVEL16(*yls, lv); @@ -37,11 +37,11 @@ void gr_copy_bright(surface_t *dst, int dx, int dy, surface_t *src, int sx, int case 24: case 32: { - DWORD *yls, *yld; + uint32_t *yls, *yld; for (y = 0; y < height; y++) { - yls = (DWORD *)(sp + y * src->bytes_per_line); - yld = (DWORD *)(dp + y * dst->bytes_per_line); + yls = (uint32_t *)(sp + y * src->bytes_per_line); + yld = (uint32_t *)(dp + y * dst->bytes_per_line); for (x = 0; x < width; x++) { *yld = ALPHALEVEL24(*yls, lv); diff --git a/modules/lib/graph_draw_amap.c b/modules/lib/graph_draw_amap.c index 9a2f21e..a78f046 100644 --- a/modules/lib/graph_draw_amap.c +++ b/modules/lib/graph_draw_amap.c @@ -6,9 +6,9 @@ #include "ngraph.h" #include "ags.h" -int gr_draw_amap(surface_t *dst, int dx, int dy, BYTE *src, int width, int height, int scanline) { +int gr_draw_amap(surface_t *dst, int dx, int dy, uint8_t *src, int width, int height, int scanline) { int y; - BYTE *sp, *dp; + uint8_t *sp, *dp; sp = src; dp = GETOFFSET_ALPHA(dst, dx, dy); diff --git a/modules/lib/graph_expandcolor_blend.c b/modules/lib/graph_expandcolor_blend.c index 10b4a22..f4cb9f4 100644 --- a/modules/lib/graph_expandcolor_blend.c +++ b/modules/lib/graph_expandcolor_blend.c @@ -7,7 +7,7 @@ #include "ags.h" int gr_expandcolor_blend(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh, int r, int g, int b) { - BYTE *sp, *dp; + uint8_t *sp, *dp; int x, y; int col; @@ -22,14 +22,14 @@ int gr_expandcolor_blend(surface_t *dst, int dx, int dy, surface_t *src, int sx, case 16: col = PIX16(r, g, b); { - WORD *yd; - BYTE *ys; + uint16_t *yd; + uint8_t *ys; for (y = 0; y < sh; y++) { - ys = (BYTE *)(sp + y * src->bytes_per_line); - yd = (WORD *)(dp + y * dst->bytes_per_line); + ys = (uint8_t *)(sp + y * src->bytes_per_line); + yd = (uint16_t *)(dp + y * dst->bytes_per_line); for (x = 0; x < sw; x++) { if (*ys) { - *yd = ALPHABLEND16(col, *yd, (BYTE)*ys); + *yd = ALPHABLEND16(col, *yd, (uint8_t)*ys); } ys++; yd++; } @@ -38,15 +38,15 @@ int gr_expandcolor_blend(surface_t *dst, int dx, int dy, surface_t *src, int sx, break; case 32: case 24: { - DWORD *yd; - BYTE *ys; + uint32_t *yd; + uint8_t *ys; col = PIX24(r, g, b); for (y = 0; y < sh; y++) { - ys = (BYTE *)(sp + y * src->bytes_per_line); - yd = (DWORD *)(dp + y * dst->bytes_per_line); + ys = (uint8_t *)(sp + y * src->bytes_per_line); + yd = (uint32_t *)(dp + y * dst->bytes_per_line); for (x = 0; x < sw; x++) { if (*ys) { - *yd = ALPHABLEND24(col, *yd, (BYTE)*ys); + *yd = ALPHABLEND24(col, *yd, (uint8_t)*ys); } ys++; yd++; } diff --git a/modules/lib/graph_fillrect.c b/modules/lib/graph_fillrect.c index cd54661..11ae946 100644 --- a/modules/lib/graph_fillrect.c +++ b/modules/lib/graph_fillrect.c @@ -7,7 +7,7 @@ #include "ags.h" int gr_fill(surface_t *dst, int dx, int dy, int dw, int dh, int r, int g, int b) { - BYTE *dp, *dp_; + uint8_t *dp, *dp_; int x, y; if (!gr_clip_xywh(dst, &dx, &dy, &dw, &dh)) { @@ -23,10 +23,10 @@ int gr_fill(surface_t *dst, int dx, int dy, int dw, int dh, int r, int g, int b) case 16: { - WORD pic16 = PIX16(r, g, b); + uint16_t pic16 = PIX16(r, g, b); for (x = 0; x < dw; x++) { - *((WORD *)dp + x) = pic16; + *((uint16_t *)dp + x) = pic16; } break; @@ -34,10 +34,10 @@ int gr_fill(surface_t *dst, int dx, int dy, int dw, int dh, int r, int g, int b) case 24: case 32: { - DWORD pic24 = PIX24(r, g, b); + uint32_t pic24 = PIX24(r, g, b); for (x = 0; x < dw; x++) { - *((DWORD *)dp + x) = pic24; + *((uint32_t *)dp + x) = pic24; } break; diff --git a/modules/lib/graph_fillrect_acolor.c b/modules/lib/graph_fillrect_acolor.c index 8e72d41..e535607 100644 --- a/modules/lib/graph_fillrect_acolor.c +++ b/modules/lib/graph_fillrect_acolor.c @@ -9,7 +9,7 @@ int gr_fill_alpha_color(surface_t *dst, int dx, int dy, int dw, int dh, int r, int g, int b, int lv) { int x, y; - BYTE *dp; + uint8_t *dp; if (!gr_clip_xywh(dst, &dx, &dy, &dw, &dh)) { return NG; @@ -20,11 +20,11 @@ int gr_fill_alpha_color(surface_t *dst, int dx, int dy, int dw, int dh, int r, i switch(dst->depth) { case 16: { - WORD pic16 = PIX16(r, g, b); - WORD *yls; + uint16_t pic16 = PIX16(r, g, b); + uint16_t *yls; for (y = 0; y < dh; y++) { - yls = (WORD *)(dp + y * dst->bytes_per_line); + yls = (uint16_t *)(dp + y * dst->bytes_per_line); for (x = 0; x < dw; x++) { *yls = ALPHABLEND16(pic16, *yls, lv); yls++; @@ -35,11 +35,11 @@ int gr_fill_alpha_color(surface_t *dst, int dx, int dy, int dw, int dh, int r, i case 24: case 32: { - DWORD pic24 = PIX24(r, g, b); - DWORD *yls; + uint32_t pic24 = PIX24(r, g, b); + uint32_t *yls; for (y = 0; y < dh; y++) { - yls = (DWORD *)(dp + y * dst->bytes_per_line); + yls = (uint32_t *)(dp + y * dst->bytes_per_line); for (x = 0; x < dw; x++) { *yls = ALPHABLEND24(pic24, *yls, lv); yls++; diff --git a/modules/lib/graph_fillrect_amap.c b/modules/lib/graph_fillrect_amap.c index 8ce221b..70f89f3 100644 --- a/modules/lib/graph_fillrect_amap.c +++ b/modules/lib/graph_fillrect_amap.c @@ -7,7 +7,7 @@ #include "ags.h" int gr_fill_alpha_map(surface_t *dst, int dx, int dy, int dw, int dh, int lv) { - BYTE *a; + uint8_t *a; if (!gr_clip_xywh(dst, &dx, &dy, &dw, &dh)) { return NG; diff --git a/modules/lib/graph_rect.c b/modules/lib/graph_rect.c index 1c035d2..5fd2fb7 100644 --- a/modules/lib/graph_rect.c +++ b/modules/lib/graph_rect.c @@ -6,7 +6,7 @@ #include "ags.h" int gr_drawrect(surface_t *dst, int x, int y, int w, int h, int r, int g, int b) { - BYTE *dp; + uint8_t *dp; int i; int col = 0; @@ -30,41 +30,41 @@ int gr_drawrect(surface_t *dst, int x, int y, int w, int h, int r, int g, int b) case 8: /* top */ for (i = 0; i < w; i++) { - *((BYTE *)dp + i) = col; + *((uint8_t *)dp + i) = col; } /* side */ h-=2; for (i = 0; i < h; i++) { dp += dst->bytes_per_line; - *((BYTE *)dp) = col; - *((BYTE *)dp + w - 1) = col; + *((uint8_t *)dp) = col; + *((uint8_t *)dp + w - 1) = col; } /* bottom */ dp += dst->bytes_per_line; for (i = 0; i < w; i++) { - *((BYTE *)dp + i) = col; + *((uint8_t *)dp + i) = col; } break; case 16: /* top */ for (i = 0; i < w; i++) { - *((WORD *)dp + i) = col; + *((uint16_t *)dp + i) = col; } /* side */ h-=2; for (i = 0; i < h; i++) { dp += dst->bytes_per_line; - *((WORD *)dp) = col; - *((WORD *)dp + w - 1) = col; + *((uint16_t *)dp) = col; + *((uint16_t *)dp + w - 1) = col; } /* bottom */ dp += dst->bytes_per_line; for (i = 0; i < w; i++) { - *((WORD *)dp + i) = col; + *((uint16_t *)dp + i) = col; } break; @@ -72,21 +72,21 @@ int gr_drawrect(surface_t *dst, int x, int y, int w, int h, int r, int g, int b) case 32: /* top */ for (i = 0; i < w; i++) { - *((DWORD *)dp + i) = col; + *((uint32_t *)dp + i) = col; } /* side */ h-=2; for (i = 0; i < h; i++) { dp += dst->bytes_per_line; - *((DWORD *)dp) = col; - *((DWORD *)dp + w - 1) = col; + *((uint32_t *)dp) = col; + *((uint32_t *)dp + w - 1) = col; } /* bottom */ dp += dst->bytes_per_line; for (i = 0; i < w; i++) { - *((DWORD *)dp + i) = col; + *((uint32_t *)dp + i) = col; } break; diff --git a/modules/lib/graph_saturadd_amap.c b/modules/lib/graph_saturadd_amap.c index 9e60f41..4542f7a 100644 --- a/modules/lib/graph_saturadd_amap.c +++ b/modules/lib/graph_saturadd_amap.c @@ -9,7 +9,7 @@ #include "ags.h" int gr_saturadd_alpha_map(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh) { - BYTE *sp, *dp; + uint8_t *sp, *dp; int x, y; if (FALSE == gr_clip(src, &sx, &sy, &sw, &sh, dst, &dx, &dy)) { @@ -30,11 +30,11 @@ int gr_saturadd_alpha_map(surface_t *dst, int dx, int dy, surface_t *src, int sx dp = GETOFFSET_ALPHA(dst, dx, dy); for (y = 0; y < sh; y++) { - BYTE *yls = sp + y * src->width; - BYTE *yld = dp + y * dst->width; + uint8_t *yls = sp + y * src->width; + uint8_t *yld = dp + y * dst->width; for (x = 0; x < sw; x++) { int s = *yls, d = *yld; - *yld = (BYTE)(min(255, (s + d))); + *yld = (uint8_t)(min(255, (s + d))); yls++; yld++; } } diff --git a/modules/lib/graph_stretch.c b/modules/lib/graph_stretch.c index 5a1cded..77c3bc2 100644 --- a/modules/lib/graph_stretch.c +++ b/modules/lib/graph_stretch.c @@ -12,7 +12,7 @@ void gr_copy_stretch(surface_t *dst, int dx, int dy, int dw, int dh, surface_t * float a1, a2, xd, yd; int *row, *col; int x, y; - BYTE *sp, *dp; + uint8_t *sp, *dp; if (!gr_clip_xywh(dst, &dx, &dy, &dw, &dh)) return; if (!gr_clip_xywh(src, &sx, &sy, &sw, &sh)) return; @@ -40,16 +40,16 @@ void gr_copy_stretch(surface_t *dst, int dx, int dy, int dw, int dh, surface_t * switch(dst->depth) { case 16: { - WORD *yls, *yld; - BYTE *_yls, *_yld; + uint16_t *yls, *yld; + uint8_t *_yls, *_yld; for (y = 0; y < dh; y++) { - yls = (WORD *)(sp + *(y + col) * src->bytes_per_line); - yld = (WORD *)(dp + y * dst->bytes_per_line); + yls = (uint16_t *)(sp + *(y + col) * src->bytes_per_line); + yld = (uint16_t *)(dp + y * dst->bytes_per_line); for (x = 0; x < dw; x++) { *(yld + x) = *(yls + *(row + x)); } - _yld = (BYTE *)yld; + _yld = (uint8_t *)yld; while(*(col + y) == *(col + y + 1)) { _yls = _yld; _yld += dst->bytes_per_line; @@ -62,16 +62,16 @@ void gr_copy_stretch(surface_t *dst, int dx, int dy, int dw, int dh, surface_t * case 24: case 32: { - DWORD *yls, *yld; - BYTE *_yls, *_yld; + uint32_t *yls, *yld; + uint8_t *_yls, *_yld; for (y = 0; y < dh; y++) { - yls = (DWORD *)(sp + *(y + col) * src->bytes_per_line); - yld = (DWORD *)(dp + y * dst->bytes_per_line); + yls = (uint32_t *)(sp + *(y + col) * src->bytes_per_line); + yld = (uint32_t *)(dp + y * dst->bytes_per_line); for (x = 0; x < dw; x++) { *(yld + x) = *(yls+ *(row + x)); } - _yld = (BYTE *)yld; + _yld = (uint8_t *)yld; while(*(col + y) == *(col + y + 1)) { _yls = _yld; _yld += dst->bytes_per_line; diff --git a/modules/lib/gre_blend.c b/modules/lib/gre_blend.c index 4b0b2f3..28e606a 100644 --- a/modules/lib/gre_blend.c +++ b/modules/lib/gre_blend.c @@ -8,7 +8,7 @@ #include "ags.h" int gre_Blend(surface_t *write, int wx, int wy, surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, int lv) { - BYTE *sp, *dp, *wp; + uint8_t *sp, *dp, *wp; int x, y; wp = GETOFFSET_PIXEL(write, wx, wy); @@ -18,12 +18,12 @@ int gre_Blend(surface_t *write, int wx, int wy, surface_t *dst, int dx, int dy, switch(dst->depth) { case 16: { - WORD *yls, *yld, *ylw; + uint16_t *yls, *yld, *ylw; for (y = 0; y < height; y++) { - yls = (WORD *)(sp + y * src->bytes_per_line); - yld = (WORD *)(dp + y * dst->bytes_per_line); - ylw = (WORD *)(wp + y * write->bytes_per_line); + yls = (uint16_t *)(sp + y * src->bytes_per_line); + yld = (uint16_t *)(dp + y * dst->bytes_per_line); + ylw = (uint16_t *)(wp + y * write->bytes_per_line); for (x = 0; x < width; x++) { *ylw = ALPHABLEND16(*yls, *yld, lv); @@ -35,12 +35,12 @@ int gre_Blend(surface_t *write, int wx, int wy, surface_t *dst, int dx, int dy, case 24: case 32: { - DWORD *yls, *yld, *ylw; + uint32_t *yls, *yld, *ylw; for (y = 0; y < height; y++) { - yls = (DWORD *)(sp + y * src->bytes_per_line); - yld = (DWORD *)(dp + y * dst->bytes_per_line); - ylw = (DWORD *)(wp + y * write->bytes_per_line); + yls = (uint32_t *)(sp + y * src->bytes_per_line); + yld = (uint32_t *)(dp + y * dst->bytes_per_line); + ylw = (uint32_t *)(wp + y * write->bytes_per_line); for (x = 0; x < width; x++) { *ylw = ALPHABLEND24(*yls, *yld, lv); diff --git a/modules/lib/gre_blend_screen.c b/modules/lib/gre_blend_screen.c index 9d22b10..87f0d0b 100644 --- a/modules/lib/gre_blend_screen.c +++ b/modules/lib/gre_blend_screen.c @@ -7,7 +7,7 @@ #include "ags.h" int gre_BlendScreen(surface_t *write, int wx, int wy, surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height) { - BYTE *sp, *dp, *wp; + uint8_t *sp, *dp, *wp; int x, y; wp = GETOFFSET_PIXEL(write, wx, wy); @@ -17,12 +17,12 @@ int gre_BlendScreen(surface_t *write, int wx, int wy, surface_t *dst, int dx, in switch(dst->depth) { case 16: { - WORD *yls, *yld, *ylw; + uint16_t *yls, *yld, *ylw; for (y = 0; y < height; y++) { - yls = (WORD *)(sp + y * src->bytes_per_line); - yld = (WORD *)(dp + y * dst->bytes_per_line); - ylw = (WORD *)(wp + y * write->bytes_per_line); + yls = (uint16_t *)(sp + y * src->bytes_per_line); + yld = (uint16_t *)(dp + y * dst->bytes_per_line); + ylw = (uint16_t *)(wp + y * write->bytes_per_line); for (x = 0; x < width; x++) { *ylw = SUTURADD16(*yls, *yld); @@ -34,12 +34,12 @@ int gre_BlendScreen(surface_t *write, int wx, int wy, surface_t *dst, int dx, in case 32: case 24: { - DWORD *yls, *yld, *ylw; + uint32_t *yls, *yld, *ylw; for (y = 0; y < height; y++) { - yls = (DWORD *)(sp + y * src->bytes_per_line); - yld = (DWORD *)(dp + y * dst->bytes_per_line); - ylw = (DWORD *)(wp + y * write->bytes_per_line); + yls = (uint32_t *)(sp + y * src->bytes_per_line); + yld = (uint32_t *)(dp + y * dst->bytes_per_line); + ylw = (uint32_t *)(wp + y * write->bytes_per_line); for (x = 0; x < width; x++) { *ylw = SUTURADD24(*yls, *yld); diff --git a/modules/lib/gre_blend_useamap.c b/modules/lib/gre_blend_useamap.c index 61caa6a..78a194f 100644 --- a/modules/lib/gre_blend_useamap.c +++ b/modules/lib/gre_blend_useamap.c @@ -9,7 +9,7 @@ #include "ags.h" int gre_BlendUseAMap(surface_t *write, int wx, int wy, surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, surface_t *alpha, int ax, int ay, int lv) { - BYTE *sp, *dp, *wp, *ap; + uint8_t *sp, *dp, *wp, *ap; int x, y; wp = GETOFFSET_PIXEL(write, wx, wy); @@ -21,14 +21,14 @@ int gre_BlendUseAMap(surface_t *write, int wx, int wy, surface_t *dst, int dx, i switch(dst->depth) { case 16: { - WORD *yls, *yld, *ylw; - BYTE *yla; + uint16_t *yls, *yld, *ylw; + uint8_t *yla; for (y = 0; y < height; y++) { - yls = (WORD *)(sp + y * src->bytes_per_line); - yld = (WORD *)(dp + y * dst->bytes_per_line); - ylw = (WORD *)(wp + y * write->bytes_per_line); - yla = (BYTE *)(ap + y * alpha->width); + yls = (uint16_t *)(sp + y * src->bytes_per_line); + yld = (uint16_t *)(dp + y * dst->bytes_per_line); + ylw = (uint16_t *)(wp + y * write->bytes_per_line); + yla = (uint8_t *)(ap + y * alpha->width); for (x = 0; x < width; x++) { *ylw = ALPHABLEND16(*yls, *yld, *yla); @@ -40,14 +40,14 @@ int gre_BlendUseAMap(surface_t *write, int wx, int wy, surface_t *dst, int dx, i case 24: case 32: { - DWORD *yls, *yld, *ylw; - BYTE *yla; + uint32_t *yls, *yld, *ylw; + uint8_t *yla; for (y = 0; y < height; y++) { - yls = (DWORD *)(sp + y * src->bytes_per_line); - yld = (DWORD *)(dp + y * dst->bytes_per_line); - ylw = (DWORD *)(wp + y * write->bytes_per_line); - yla = (BYTE *)(ap + y * alpha->width); + yls = (uint32_t *)(sp + y * src->bytes_per_line); + yld = (uint32_t *)(dp + y * dst->bytes_per_line); + ylw = (uint32_t *)(wp + y * write->bytes_per_line); + yla = (uint8_t *)(ap + y * alpha->width); for (x = 0; x < width; x++) { *ylw = ALPHABLEND24(*yls, *yld, *yla); @@ -62,14 +62,14 @@ int gre_BlendUseAMap(surface_t *write, int wx, int wy, surface_t *dst, int dx, i switch(dst->depth) { case 16: { - WORD *yls, *yld, *ylw; - BYTE *yla; + uint16_t *yls, *yld, *ylw; + uint8_t *yla; for (y = 0; y < height; y++) { - yls = (WORD *)(sp + y * src->bytes_per_line); - yld = (WORD *)(dp + y * dst->bytes_per_line); - ylw = (WORD *)(wp + y * write->bytes_per_line); - yla = (BYTE *)(ap + y * alpha->width); + yls = (uint16_t *)(sp + y * src->bytes_per_line); + yld = (uint16_t *)(dp + y * dst->bytes_per_line); + ylw = (uint16_t *)(wp + y * write->bytes_per_line); + yla = (uint8_t *)(ap + y * alpha->width); for (x = 0; x < width; x++) { *ylw = ALPHABLEND16(*yls, *yld, (*yla * lv) / 255); @@ -81,14 +81,14 @@ int gre_BlendUseAMap(surface_t *write, int wx, int wy, surface_t *dst, int dx, i case 24: case 32: { - DWORD *yls, *yld, *ylw; - BYTE *yla; + uint32_t *yls, *yld, *ylw; + uint8_t *yla; for (y = 0; y < height; y++) { - yls = (DWORD *)(sp + y * src->bytes_per_line); - yld = (DWORD *)(dp + y * dst->bytes_per_line); - ylw = (DWORD *)(wp + y * write->bytes_per_line); - yla = (BYTE *)(ap + y * alpha->width); + yls = (uint32_t *)(sp + y * src->bytes_per_line); + yld = (uint32_t *)(dp + y * dst->bytes_per_line); + ylw = (uint32_t *)(wp + y * write->bytes_per_line); + yla = (uint8_t *)(ap + y * alpha->width); for (x = 0; x < width; x++) { *ylw = ALPHABLEND24(*yls, *yld, (*yla * lv) / 255); diff --git a/modules/lib/ngraph.h b/modules/lib/ngraph.h index cfe0ab6..1b0f0f3 100644 --- a/modules/lib/ngraph.h +++ b/modules/lib/ngraph.h @@ -49,7 +49,7 @@ extern int gr_blend_alpha_map(surface_t *dst, int dx, int dy, surface_t *src, in extern int gr_saturadd_alpha_map(surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int sw, int sh); /* in graph_draw_amap.c */ -extern int gr_draw_amap(surface_t *dst, int dx, int dy, BYTE *src, int width, int height, int scanline); +extern int gr_draw_amap(surface_t *dst, int dx, int dy, uint8_t *src, int width, int height, int scanline); // /* in graph_bright_dst_only.c */ #define gr_bright_dst_only(dst,dx,dy,w,h,lv) gr_copy_bright(dst,dx,dy,dst,dx,dy,w,h,lv) diff --git a/modules/lib/surface.c b/modules/lib/surface.c index 4ab240c..2c44461 100644 --- a/modules/lib/surface.c +++ b/modules/lib/surface.c @@ -21,18 +21,18 @@ static surface_t *create(int width, int height, int depth, boolean has_pixel, bo if (has_pixel) { switch (s->depth) { case 8: - s->pixel = calloc(width * (height +1), sizeof(BYTE)); + s->pixel = calloc(width * (height +1), sizeof(uint8_t)); s->bytes_per_line = width; s->bytes_per_pixel = 1; break; case 16: - s->pixel = calloc(width * (height +1) * 2, sizeof(BYTE)); + s->pixel = calloc(width * (height +1) * 2, sizeof(uint8_t)); s->bytes_per_line = width * 2; s->bytes_per_pixel = 2; break; case 24: case 32: - s->pixel = calloc(width * (height +1) * 4, sizeof(BYTE)); + s->pixel = calloc(width * (height +1) * 4, sizeof(uint8_t)); s->bytes_per_line = width * 4; s->bytes_per_pixel = 4; break; @@ -42,7 +42,7 @@ static surface_t *create(int width, int height, int depth, boolean has_pixel, bo } if (has_alpha) { - s->alpha = calloc(width * (height +1), sizeof(BYTE)); + s->alpha = calloc(width * (height +1), sizeof(uint8_t)); } return s; @@ -108,13 +108,13 @@ surface_t *sf_dup(surface_t *in) { if (in->pixel) { len = sf->bytes_per_line * sf->height; - sf->pixel = malloc(sizeof(BYTE) * (len + sf->bytes_per_line)); + sf->pixel = malloc(sizeof(uint8_t) * (len + sf->bytes_per_line)); memcpy(sf->pixel, in->pixel, len); } if (in->alpha) { len = sf->width * sf->height; - sf->alpha = malloc(sizeof(BYTE) * (len + sf->width)); + sf->alpha = malloc(sizeof(uint8_t) * (len + sf->width)); memcpy(sf->alpha, in->alpha, len); } @@ -167,7 +167,7 @@ surface_t *sf_dup2(surface_t *in, boolean copypixel, boolean copyalpha) { if (in->pixel) { len = sf->bytes_per_line * sf->height; - sf->pixel = malloc(sizeof(BYTE) * (len + sf->bytes_per_line)); + sf->pixel = malloc(sizeof(uint8_t) * (len + sf->bytes_per_line)); if (copypixel) { memcpy(sf->pixel, in->pixel, len); } @@ -175,7 +175,7 @@ surface_t *sf_dup2(surface_t *in, boolean copypixel, boolean copyalpha) { if (in->alpha) { len = sf->width * sf->height; - sf->alpha = malloc(sizeof(BYTE) * (len + sf->width)); + sf->alpha = malloc(sizeof(uint8_t) * (len + sf->width)); if (copyalpha) { memcpy(sf->alpha, in->alpha, len); } diff --git a/modules/oujimisc/oujimisc.c b/modules/oujimisc/oujimisc.c index d55a2a7..13d02f3 100644 --- a/modules/oujimisc/oujimisc.c +++ b/modules/oujimisc/oujimisc.c @@ -13,11 +13,11 @@ #define NUM_MAPS 16 #define NUM_LAYERS 3 -#define MAPDATASIZE (128 * 128 * sizeof(WORD) * NUM_LAYERS) +#define MAPDATASIZE (128 * 128 * sizeof(uint16_t) * NUM_LAYERS) typedef struct { - DWORD size; - DWORD map; + uint32_t size; + uint32_t map; } RecordHeader; static void *mapdata[NUM_MAPS]; @@ -181,7 +181,7 @@ static void TempMapLoadToShadow() { int *a1 = v_resolveRef(&r1); int *a2 = v_resolveRef(&r2); int *a3 = v_resolveRef(&r3); - WORD *p = mapdata[map]; + uint16_t *p = mapdata[map]; for (int i = 0; i < size; i++) *a1++ = SDL_SwapLE16(*p++); for (int i = 0; i < size; i++) @@ -210,7 +210,7 @@ static void TempMapSaveToShadow() { int *a1 = v_resolveRef(&r1); int *a2 = v_resolveRef(&r2); int *a3 = v_resolveRef(&r3); - WORD *p = mapdata[map]; + uint16_t *p = mapdata[map]; for (int i = 0; i < size; i++) *p++ = SDL_SwapLE16(*a1++); for (int i = 0; i < size; i++) diff --git a/src/LittleEndian.c b/src/LittleEndian.c index 3934aeb..6c13f02 100644 --- a/src/LittleEndian.c +++ b/src/LittleEndian.c @@ -25,7 +25,7 @@ #include "portab.h" -int LittleEndian_getDW(const BYTE *b,int index) { +int LittleEndian_getDW(const uint8_t *b,int index) { int c0, c1, c2, c3; int d0, d1; c0 = *(b + index + 0); @@ -34,10 +34,10 @@ int LittleEndian_getDW(const BYTE *b,int index) { c3 = *(b + index + 3); d0 = c0 + (c1 << 8); d1 = c2 + (c3 << 8); - return (DWORD)(d0 + (d1 << 16)); + return (uint32_t)(d0 + (d1 << 16)); } -int LittleEndian_get3B(const BYTE *b,int index) { +int LittleEndian_get3B(const uint8_t *b,int index) { int c0, c1, c2; c0 = *(b + index + 0); c1 = *(b + index + 1); @@ -45,14 +45,14 @@ int LittleEndian_get3B(const BYTE *b,int index) { return c0 + (c1 << 8) + (c2 << 16); } -int LittleEndian_getW(const BYTE *b,int index) { +int LittleEndian_getW(const uint8_t *b,int index) { int c0, c1; c0 = *(b + index + 0); c1 = *(b + index + 1); return c0 + (c1 << 8); } -void LittleEndian_putW(int num, BYTE *b, int index) { +void LittleEndian_putW(int num, uint8_t *b, int index) { int c0, c1; num %= 65536; c0 = num % 256; diff --git a/src/LittleEndian.h b/src/LittleEndian.h index aacd0e1..8a6a960 100644 --- a/src/LittleEndian.h +++ b/src/LittleEndian.h @@ -28,9 +28,9 @@ #include "portab.h" -extern int LittleEndian_getDW(const BYTE *b,int index); -extern int LittleEndian_get3B(const BYTE *b,int index); -extern int LittleEndian_getW(const BYTE *b,int index); -extern void LittleEndian_putW(int num, BYTE *b, int index); +extern int LittleEndian_getDW(const uint8_t *b,int index); +extern int LittleEndian_get3B(const uint8_t *b,int index); +extern int LittleEndian_getW(const uint8_t *b,int index); +extern void LittleEndian_putW(int num, uint8_t *b, int index); #endif /* !__LITTLEENDIAN__ */ diff --git a/src/ags.c b/src/ags.c index 290428a..c056fff 100644 --- a/src/ags.c +++ b/src/ags.c @@ -164,7 +164,7 @@ void ags_setViewArea(int x, int y, int width, int height) { void ags_setWindowTitle(const char *src) { #define TITLEHEAD "XSystem35 Version "VERSION":" - BYTE *utf, *d; + uint8_t *utf, *d; utf = toUTF8(src); if (NULL == (d = malloc(strlen(utf) + strlen(TITLEHEAD) + 1))) { @@ -301,13 +301,13 @@ void ags_getPixel(int x, int y, Palette *cell) { sdl_getPixel(x, y, cell); } -void ags_copyPaletteShift(int sx, int sy, int w, int h, int dx, int dy, BYTE sprite) { +void ags_copyPaletteShift(int sx, int sy, int w, int h, int dx, int dy, uint8_t sprite) { if (!ags_check_param(&sx, &sy, &w, &h)) return; if (!ags_check_param(&dx, &dy, &w, &h)) return; for (int y = 0; y < h; y++) { - BYTE *src = GETOFFSET_PIXEL(nact->ags.dib, sx, sy + y); - BYTE *dst = GETOFFSET_PIXEL(nact->ags.dib, dx, dy + y); + uint8_t *src = GETOFFSET_PIXEL(nact->ags.dib, sx, sy + y); + uint8_t *dst = GETOFFSET_PIXEL(nact->ags.dib, dx, dy + y); for (int x = 0; x < w; x++, src++, dst++) { if (*src != sprite) *dst = (*src & 0xf0) | (*dst & 0x0f); @@ -324,8 +324,8 @@ void ags_changeColorArea(int sx, int sy, int w, int h, int dst, int src, int cnt agsurface_t *dib = nact->ags.dib; int x, y; int src_last = src + cnt,dif = dst - src; - BYTE *yl; - BYTE *sdata = GETOFFSET_PIXEL(dib, sx, sy); + uint8_t *yl; + uint8_t *sdata = GETOFFSET_PIXEL(dib, sx, sy); for (y = 0; y < h; y++) { yl = sdata + y * dib->bytes_per_line; @@ -519,11 +519,11 @@ void ags_alpha_getPixel(int x, int y, int *pic) { if (!ags_check_param_xy(&x, &y)) { *pic = 0; } else { - alpha_get_pixel(nact->ags.dib, x, y, (BYTE *)pic); + alpha_get_pixel(nact->ags.dib, x, y, (uint8_t *)pic); } } -void ags_alpha_setPixel(int x, int y, int w, int h, BYTE *b) { +void ags_alpha_setPixel(int x, int y, int w, int h, uint8_t *b) { int savex, savey, savew, offset; savex = x; diff --git a/src/ags.h b/src/ags.h index e777d53..63239c8 100644 --- a/src/ags.h +++ b/src/ags.h @@ -67,8 +67,8 @@ struct agsurface { int bytes_per_line; /* bytes per line */ int bytes_per_pixel; /* bytes per pixel */ - BYTE *pixel; /* pixel data (can be NULL) */ - BYTE *alpha; /* alpha pixel data (can be NULL) */ + uint8_t *pixel; /* pixel data (can be NULL) */ + uint8_t *alpha; /* alpha pixel data (can be NULL) */ }; typedef struct agsurface agsurface_t; @@ -161,7 +161,7 @@ extern void ags_copyArea_shadow_withrate(int sx, int sy, int w, int h, int dx, i extern void ags_wrapColor(int x, int y, int w, int h, int p1, int p2); extern void ags_getPixel(int x, int y, Palette *cell); -extern void ags_copyPaletteShift(int sx, int sy, int w, int h, int dx, int dy, BYTE sprite); +extern void ags_copyPaletteShift(int sx, int sy, int w, int h, int dx, int dy, uint8_t sprite); extern void ags_changeColorArea(int x, int y, int w, int h, int dst, int src, int cnt); extern void* ags_saveRegion(int x, int y, int w, int h); @@ -188,7 +188,7 @@ extern void ags_alpha_lowercut(int sx, int sy, int w, int h, int s, int d); extern void ags_alpha_setLevel(int x, int y, int w, int h, int lv); extern void ags_alpha_copyArea(int sx, int sy, int w, int h, int dx, int dy); extern void ags_alpha_getPixel(int x, int y, int *pic); -extern void ags_alpha_setPixel(int x, int y, int w, int h, BYTE *b); +extern void ags_alpha_setPixel(int x, int y, int w, int h, uint8_t *b); /* fader */ extern void ags_fadeIn(int rate, boolean flg); @@ -226,15 +226,15 @@ void ags_runEffect(int duration_ms, boolean cancelable, ags_EffectStepFunc step, #define GMASK24 0x0000ff00 #define BMASK24 0x000000ff -#define PIXR16(pic) (BYTE)(((pic) & RMASK16) >> 8) -#define PIXG16(pic) (BYTE)(((pic) & GMASK16) >> 3) -#define PIXB16(pic) (BYTE)(((pic) & BMASK16) << 3) -#define PIX16(r,g,b) (WORD)((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | ((b ) >> 3)) +#define PIXR16(pic) (uint8_t)(((pic) & RMASK16) >> 8) +#define PIXG16(pic) (uint8_t)(((pic) & GMASK16) >> 3) +#define PIXB16(pic) (uint8_t)(((pic) & BMASK16) << 3) +#define PIX16(r,g,b) (uint16_t)((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | ((b ) >> 3)) -#define PIXR24(pic) (BYTE)(((pic) & RMASK24) >> 16) -#define PIXG24(pic) (BYTE)(((pic) & GMASK24) >> 8) -#define PIXB24(pic) (BYTE)(((pic) & BMASK24) ) -#define PIX24(r,g,b) (DWORD)((((r) << 16) | ((g) << 8) | (b) )) +#define PIXR24(pic) (uint8_t)(((pic) & RMASK24) >> 16) +#define PIXG24(pic) (uint8_t)(((pic) & GMASK24) >> 8) +#define PIXB24(pic) (uint8_t)(((pic) & BMASK24) ) +#define PIX24(r,g,b) (uint32_t)((((r) << 16) | ((g) << 8) | (b))) #define ALPHABLEND16(f, b, a) (PIX16((((PIXR16((f)) - PIXR16((b))) * (a)) >> 8)+ PIXR16((b)),\ (((PIXG16((f)) - PIXG16((b))) * (a)) >> 8)+ PIXG16((b)),\ diff --git a/src/alpha_plane.c b/src/alpha_plane.c index 11b46f9..0e35116 100644 --- a/src/alpha_plane.c +++ b/src/alpha_plane.c @@ -37,9 +37,9 @@ * src : source alpha plane pixel * src_pitch: soruce alpha plane pitch */ -void alpha_set_pixels(agsurface_t *dst, int dx, int dy, int w, int h, BYTE *src, int src_pitch) { - BYTE *ad = GETOFFSET_ALPHA(dst, dx, dy); - BYTE *as = src; +void alpha_set_pixels(agsurface_t *dst, int dx, int dy, int w, int h, uint8_t *src, int src_pitch) { + uint8_t *ad = GETOFFSET_ALPHA(dst, dx, dy); + uint8_t *as = src; int i; for (i = 0; i < h; i++) { @@ -56,7 +56,7 @@ void alpha_set_pixels(agsurface_t *dst, int dx, int dy, int w, int h, BYTE *src, * y : location y * pic: acired alpha pixel */ -void alpha_get_pixel(agsurface_t *suf, int x, int y, BYTE *pic) { +void alpha_get_pixel(agsurface_t *suf, int x, int y, uint8_t *pic) { *pic = *GETOFFSET_ALPHA(suf, x, y); } @@ -71,13 +71,13 @@ void alpha_get_pixel(agsurface_t *suf, int x, int y, BYTE *pic) { * d : setteled level */ void alpha_lowercut(agsurface_t *suf, int sx, int sy, int w, int h, int s, int d) { - BYTE *a = GETOFFSET_ALPHA(suf, sx, sy), *b; + uint8_t *a = GETOFFSET_ALPHA(suf, sx, sy), *b; int x, y; for (y = 0; y < h; y++) { b = a + y * suf->width; for (x = 0; x < w; x++) { - if (*b <= (BYTE)s) *b = (BYTE)d; + if (*b <= (uint8_t)s) *b = (uint8_t)d; b++; } } @@ -94,13 +94,13 @@ void alpha_lowercut(agsurface_t *suf, int sx, int sy, int w, int h, int s, int d * d : setteled level */ void alpha_uppercut(agsurface_t *suf, int sx, int sy, int w, int h, int s, int d) { - BYTE *dp = GETOFFSET_ALPHA(suf, sx, sy); + uint8_t *dp = GETOFFSET_ALPHA(suf, sx, sy); int x, y; for (y = 0; y < h; y++) { for (x = 0; x < w; x++) { - if (*(dp + x) >= (BYTE)s) { - *(dp + x) = (BYTE)d; + if (*(dp + x) >= (uint8_t)s) { + *(dp + x) = (uint8_t)d; } } dp += suf->width; @@ -117,7 +117,7 @@ void alpha_uppercut(agsurface_t *suf, int sx, int sy, int w, int h, int s, int d * lv : level to be set */ void alpha_set_level(agsurface_t *suf, int sx, int sy, int w, int h, int lv) { - BYTE *a = GETOFFSET_ALPHA(suf, sx, sy); + uint8_t *a = GETOFFSET_ALPHA(suf, sx, sy); while(h--){ memset(a, lv, w); @@ -136,8 +136,8 @@ void alpha_set_level(agsurface_t *suf, int sx, int sy, int w, int h, int lv) { * dy : destination y */ void alpha_copy_area(agsurface_t *suf, int sx, int sy, int w, int h, int dx, int dy) { - BYTE *src = GETOFFSET_ALPHA(suf, sx, sy); - BYTE *dst = GETOFFSET_ALPHA(suf, dx, dy); + uint8_t *src = GETOFFSET_ALPHA(suf, sx, sy); + uint8_t *dst = GETOFFSET_ALPHA(suf, dx, dy); if (sy <= dy && dy < (sy + h)) { src += (h-1) * suf->width; diff --git a/src/alpha_plane.h b/src/alpha_plane.h index 0a6a8b2..e8ef28a 100644 --- a/src/alpha_plane.h +++ b/src/alpha_plane.h @@ -27,8 +27,8 @@ #include "portab.h" #include "ags.h" -extern void alpha_set_pixels(agsurface_t *dst, int dx, int dy, int w, int h, BYTE *src, int src_pitch); -extern void alpha_get_pixel(agsurface_t *suf, int x, int y, BYTE *pic); +extern void alpha_set_pixels(agsurface_t *dst, int dx, int dy, int w, int h, uint8_t *src, int src_pitch); +extern void alpha_get_pixel(agsurface_t *suf, int x, int y, uint8_t *pic); extern void alpha_lowercut(agsurface_t *suf, int sx, int sy, int w, int h, int s, int d); extern void alpha_uppercut(agsurface_t *suf, int sx, int sy, int w, int h, int s, int d); extern void alpha_set_level(agsurface_t *suf, int sx, int sy, int w, int h, int lv); diff --git a/src/bmp.c b/src/bmp.c index 27618e4..1b06761 100644 --- a/src/bmp.c +++ b/src/bmp.c @@ -35,17 +35,17 @@ /* * static methods */ -static bmp_header *extract_header(BYTE *b); -static void getpal(Palette256 *pal, BYTE *b); -static void extract_8bit(bmp_header *bmp, BYTE *pic, BYTE *b); -static void extract_24bit(bmp_header *bmp, WORD *pic, BYTE *b); +static bmp_header *extract_header(uint8_t *b); +static void getpal(Palette256 *pal, uint8_t *b); +static void extract_8bit(bmp_header *bmp, uint8_t *pic, uint8_t *b); +static void extract_24bit(bmp_header *bmp, uint16_t *pic, uint8_t *b); /* * Get information from cg header * b: raw data (pointer to header) * return: acquired bmp information object */ -static bmp_header *extract_header(BYTE *b) { +static bmp_header *extract_header(uint8_t *b) { bmp_header *bmp = malloc(sizeof(bmp_header)); bmp->bmpSize = LittleEndian_getDW(b, 2); @@ -68,7 +68,7 @@ static bmp_header *extract_header(BYTE *b) { * pal: palette to be stored * b : raw data (pointer to palette) */ -static void getpal(Palette256 *pal, BYTE *b) { +static void getpal(Palette256 *pal, uint8_t *b) { int i; for (i = 0; i < 256; i++) { @@ -84,7 +84,7 @@ static void getpal(Palette256 *pal, BYTE *b) { * pic: pixel to be stored * b : raw data (pointer to pixel) */ -static void extract_8bit(bmp_header *bmp, BYTE *pic, BYTE *b) { +static void extract_8bit(bmp_header *bmp, uint8_t *pic, uint8_t *b) { int i, j; int pos; int LineNeed = (bmp->bmpXW * bmp->bmpBpp) / 8; @@ -94,7 +94,7 @@ static void extract_8bit(bmp_header *bmp, BYTE *pic, BYTE *b) { pos = LineNeed * (bmp->bmpYW); /* 最上行の位置 */ for (i = 0; i < bmp->bmpYW; i++) { - const BYTE* p; + const uint8_t* p; pos -= LineNeed; p = b + pos; for (j = 0; j < bmp->bmpXW; j++) @@ -108,7 +108,7 @@ static void extract_8bit(bmp_header *bmp, BYTE *pic, BYTE *b) { * pic: pixel to be stored (16 bit converted) * b : raw data (pointer to pixel) */ -static void extract_24bit(bmp_header *bmp, WORD *pic, BYTE *b) { +static void extract_24bit(bmp_header *bmp, uint16_t *pic, uint8_t *b) { int i, j; int pos; int LineNeed = (bmp->bmpXW * bmp->bmpBpp) / 8; @@ -118,12 +118,12 @@ static void extract_24bit(bmp_header *bmp, WORD *pic, BYTE *b) { pos = LineNeed * (bmp->bmpYW); /* 最上行の位置 */ for (i = 0; i < bmp->bmpYW; i++) { - const BYTE* p; + const uint8_t* p; pos -= LineNeed; p = b + pos; for (j = 0; j < bmp->bmpXW; j++) { - WORD r,g,b; + uint16_t r,g,b; b = (*p++); g = (*p++); r = (*p++); @@ -145,7 +145,7 @@ static void extract_24bit(bmp_header *bmp, WORD *pic, BYTE *b) { * data: raw data (pointer to data top) * return: TRUE if data is bmp */ -boolean bmp256_checkfmt(BYTE *data) { +boolean bmp256_checkfmt(uint8_t *data) { int w, h, bpp; if (data[0] != 'B' || data[1] != 'M') return FALSE; @@ -164,7 +164,7 @@ boolean bmp256_checkfmt(BYTE *data) { * data: raw data (pointer to data top) * return: extracted image data and information */ -cgdata *bmp256_extract(BYTE *data) { +cgdata *bmp256_extract(uint8_t *data) { bmp_header *bmp = extract_header(data); cgdata *cg = calloc(1, sizeof(cgdata)); @@ -172,7 +172,7 @@ cgdata *bmp256_extract(BYTE *data) { getpal(cg->pal, data + bmp->bmpPp); /* +10: margin for broken cg */ - cg->pic = malloc(sizeof(BYTE) * ((bmp->bmpXW + 10) * (bmp->bmpYW + 10))); + cg->pic = malloc(sizeof(uint8_t) * ((bmp->bmpXW + 10) * (bmp->bmpYW + 10))); extract_8bit(bmp, cg->pic, data + bmp->bmpDp); cg->type = ALCG_BMP8; @@ -193,7 +193,7 @@ cgdata *bmp256_extract(BYTE *data) { * data: raw data (pointer to data top) * return: TRUE if data is pms */ -boolean bmp16m_checkfmt(BYTE *data) { +boolean bmp16m_checkfmt(uint8_t *data) { int w, h, bpp; if (data[0] != 'B' || data[1] != 'M') return FALSE; @@ -213,13 +213,13 @@ boolean bmp16m_checkfmt(BYTE *data) { * data: raw data (pointer to data top) * return: extracted image data and information */ -cgdata *bmp16m_extract(BYTE *data) { +cgdata *bmp16m_extract(uint8_t *data) { cgdata *cg = calloc(1, sizeof(cgdata)); bmp_header *bmp = extract_header(data); /* +10: margin for broken cg */ - cg->pic = (BYTE *)malloc(sizeof(WORD) * (bmp->bmpXW + 10) * (bmp->bmpYW + 10)); - extract_24bit(bmp, (WORD *)cg->pic, data + bmp->bmpDp); + cg->pic = (uint8_t *)malloc(sizeof(uint16_t) * (bmp->bmpXW + 10) * (bmp->bmpYW + 10)); + extract_24bit(bmp, (uint16_t *)cg->pic, data + bmp->bmpDp); cg->type = ALCG_BMP24; cg->x = 0; diff --git a/src/bmp.h b/src/bmp.h index 0bd725a..4e179c0 100644 --- a/src/bmp.h +++ b/src/bmp.h @@ -46,9 +46,9 @@ typedef struct { BMP_Type bmpTp; /* bmp type */ } bmp_header; -extern boolean bmp256_checkfmt(BYTE *data); -extern cgdata *bmp256_extract(BYTE *data); -extern boolean bmp16m_checkfmt(BYTE *data); -extern cgdata *bmp16m_extract(BYTE *data); +extern boolean bmp256_checkfmt(uint8_t *data); +extern cgdata *bmp256_extract(uint8_t *data); +extern boolean bmp16m_checkfmt(uint8_t *data); +extern cgdata *bmp16m_extract(uint8_t *data); #endif /* !__BMP__ */ diff --git a/src/cg.c b/src/cg.c index d1f3b60..d226398 100644 --- a/src/cg.c +++ b/src/cg.c @@ -59,8 +59,8 @@ static MyPoint loc_where, loc_where0; static cacher *cacheid; /* static methods */ -static CG_TYPE check_cgformat(BYTE *data); -static void set_vspbank(BYTE *pic, int bank, int width, int height); +static CG_TYPE check_cgformat(uint8_t *data); +static void set_vspbank(uint8_t *pic, int bank, int width, int height); static MyPoint set_display_loc(cgdata *cg); static void clear_display_loc(); static void display_cg(cgdata *cg, int x, int y, int sprite_color, bool alpha_blend); @@ -72,7 +72,7 @@ static cgdata *loader(int no); * data: pointer to compressed data * return: cg type */ -static CG_TYPE check_cgformat(BYTE *data) { +static CG_TYPE check_cgformat(uint8_t *data) { if (qnt_checkfmt(data)) { return ALCG_QNT; } else if (pms256_checkfmt(data)) { @@ -99,11 +99,11 @@ static CG_TYPE check_cgformat(BYTE *data) { * width : image width * height: image height */ -static void set_vspbank(BYTE *pic, int bank, int width, int height) { +static void set_vspbank(uint8_t *pic, int bank, int width, int height) { int pixels = width * height; while (pixels--) { - *pic = (*pic & 0x0f) | (BYTE)bank; pic++; + *pic = (*pic & 0x0f) | (uint8_t)bank; pic++; } } @@ -401,7 +401,7 @@ void cg_load_with_alpha(int cgno, int shadowno) { int cg_load_with_filename(char *fname_utf8, int x, int y) { int status, type; long filesize; - BYTE *data; + uint8_t *data; cgdata *cg = NULL; MyPoint p; diff --git a/src/cg.h b/src/cg.h index d5c006d..6249789 100644 --- a/src/cg.h +++ b/src/cg.h @@ -53,8 +53,8 @@ typedef struct { int height; // image height int depth; // pixel depth (8, 16 or 24) - BYTE *pic; // extracted pixel data - BYTE *alpha; // extracted alpha data if exists + uint8_t *pic; // extracted pixel data + uint8_t *alpha; // extracted alpha data if exists Palette256 *pal; // extracted palette data if exists int vsp_bank; // palette bank for vsp diff --git a/src/cmd2F.c b/src/cmd2F.c index 21580c8..c78d5ea 100644 --- a/src/cmd2F.c +++ b/src/cmd2F.c @@ -1419,10 +1419,10 @@ void commands2F81() { int *vData = getCaliVariable(); int eNumof = getCaliValue(); int i; - WORD *p = (WORD *)nact->datatbl_addr; + uint16_t *p = (uint16_t *)nact->datatbl_addr; for (i = 0; i < eNumof; i++) { - *vData = LittleEndian_getW((BYTE *)p, 0); + *vData = LittleEndian_getW((uint8_t *)p, 0); p++; vData++; } @@ -1450,7 +1450,7 @@ void commands2F82() { void commands2F83() { int eNumof = getCaliValue(); - WORD *p = (WORD *)nact->datatbl_addr; + uint16_t *p = (uint16_t *)nact->datatbl_addr; p += eNumof; diff --git a/src/cmd_check.c b/src/cmd_check.c index f492481..e2828a9 100644 --- a/src/cmd_check.c +++ b/src/cmd_check.c @@ -59,11 +59,11 @@ static void letVar(int type) { case '!': *varno = val; break; case 0x10: /* += */ - *varno = (int)(WORD)(*varno + val); break; + *varno = (uint16_t)(*varno + val); break; case 0x11: /* -= */ *varno = max(0, *varno - val); break; case 0x12: /* *= */ - *varno = (int)(WORD)(*varno * val); break; + *varno = (uint16_t)(*varno * val); break; case 0x13: /* /= */ if (val == 0) *varno = 0; else *varno /= val; diff --git a/src/cmdf.c b/src/cmdf.c index 7a1d383..b311b99 100644 --- a/src/cmdf.c +++ b/src/cmdf.c @@ -95,11 +95,11 @@ static void commandF1() { static void commandF2() { int *read_var = getCaliVariable(); int skip = getCaliValue(); - WORD *p = (WORD *)nact->datatbl_addr; + uint16_t *p = (uint16_t *)nact->datatbl_addr; p += skip; - *read_var = LittleEndian_getW((BYTE *)p, 0); + *read_var = LittleEndian_getW((uint8_t *)p, 0); p++; nact->datatbl_addr = (void *)p; @@ -120,10 +120,10 @@ static void commandF4() { int *read_var = getCaliVariable(); int count = getCaliValue(); int i; - WORD *p = (WORD *)nact->datatbl_addr; + uint16_t *p = (uint16_t *)nact->datatbl_addr; for (i = 0; i < count; i++) { - *read_var = LittleEndian_getW((BYTE *)p, 0); + *read_var = LittleEndian_getW((uint8_t *)p, 0); p++; read_var++; } @@ -159,11 +159,11 @@ static void commandF7() { int data_width = getCaliValue(); int count = getCaliValue(); int i, j; - WORD *p = (WORD *)nact->datatbl_addr; + uint16_t *p = (uint16_t *)nact->datatbl_addr; for (i = 0; i < count; i++) { for (j = 0; j < data_width; j++) { - *(F6Index[j] + i) = LittleEndian_getW((BYTE *)p, 0); + *(F6Index[j] + i) = LittleEndian_getW((uint8_t *)p, 0); p++; } } diff --git a/src/cmdl.c b/src/cmdl.c index e4a09f6..8002ec7 100644 --- a/src/cmdl.c +++ b/src/cmdl.c @@ -142,7 +142,7 @@ void commandLL() { int *var, _var = 0; int num, i; dridata *dfile = ald_getdata(DRIFILE_DATA, link_no - 1); - WORD *data; + uint16_t *data; if (dfile == NULL) { getCaliValue(); @@ -151,7 +151,7 @@ void commandLL() { return; } - data = (WORD *)dfile->data; + data = (uint16_t *)dfile->data; switch(type) { case 0: /* T2 */ @@ -160,11 +160,11 @@ void commandLL() { DEBUG_COMMAND("LL %d,%d,%d,%d:",type, link_no, _var, num); - if (dfile->size < num * sizeof(WORD)) { - WARNING("data shortage (link_no = %d, requested %d, loaded %d)", link_no, num, dfile->size/ sizeof(WORD)); + if (dfile->size < num * sizeof(uint16_t)) { + WARNING("data shortage (link_no = %d, requested %d, loaded %d)", link_no, num, dfile->size/ sizeof(uint16_t)); /* sysVar[0] = 254; 大嘘*/ /* return; */ - num = dfile->size / sizeof(WORD); + num = dfile->size / sizeof(uint16_t); } for (i = 0; i < num; i++) { var[i] = SDL_SwapLE16(data[i]); diff --git a/src/cmdn.c b/src/cmdn.c index aa3a16c..5018dd6 100644 --- a/src/cmdn.c +++ b/src/cmdn.c @@ -87,7 +87,7 @@ void commandN_ADD() { DEBUG_COMMAND("N+ %d,%d,%d:", *var1, num, cnt); while(cnt--) { - *var1 = (int)((WORD)(*var1 + num)) ; var1++; + *var1 = (uint16_t)(*var1 + num); var1++; // *var1 += num; var1++; } } @@ -113,7 +113,7 @@ void commandN_MUL() { DEBUG_COMMAND("N* %d,%d,%d:", *var1, num, cnt); while(cnt--) { - *var1 = (int)((WORD)(*var1 * num)); var1++; + *var1 = (uint16_t)(*var1 * num); var1++; // *var1 *= num; var1++; } } diff --git a/src/cmdz.c b/src/cmdz.c index 1497df0..0313726 100644 --- a/src/cmdz.c +++ b/src/cmdz.c @@ -371,21 +371,21 @@ void commandZZ2() { /* 機種文字列を文字列領域 num に返す(MAX12文字)*/ int num = getCaliValue(); #if defined(linux) - static BYTE str[] = {0x82, 0x6B, 0x82, 0x89, 0x82, 0x8E, 0x82, 0x95, 0x82, 0x98, 0}; + static uint8_t str[] = {0x82, 0x6B, 0x82, 0x89, 0x82, 0x8E, 0x82, 0x95, 0x82, 0x98, 0}; #elif defined(__FreeBSD__) - static BYTE str[] = {0x82, 0x65, 0x82, 0x92, 0x82, 0x85, 0x82, 0x85, 0x82, 0x61, 0x82, 0x72, 0x82, 0x63, 0}; + static uint8_t str[] = {0x82, 0x65, 0x82, 0x92, 0x82, 0x85, 0x82, 0x85, 0x82, 0x61, 0x82, 0x72, 0x82, 0x63, 0}; #elif defined(__OpenBSD__) - static BYTE str[] = {0x82, 0x6E, 0x82, 0x90, 0x82, 0x85, 0x82, 0x8E, 0x82, 0x61, 0x82, 0x72, 0x82, 0x63, 0}; + static uint8_t str[] = {0x82, 0x6E, 0x82, 0x90, 0x82, 0x85, 0x82, 0x8E, 0x82, 0x61, 0x82, 0x72, 0x82, 0x63, 0}; #elif defined(__NetBSD__) - static BYTE str[] = {0x82, 0x6D, 0x82, 0x85, 0x82, 0x94, 0x82, 0x61, 0x82, 0x72, 0x82, 0x63, 0}; + static uint8_t str[] = {0x82, 0x6D, 0x82, 0x85, 0x82, 0x94, 0x82, 0x61, 0x82, 0x72, 0x82, 0x63, 0}; #elif defined(sun) - static BYTE str[] = {0x82, 0x72, 0x82, 0x95, 0x82, 0x8E, 0x82, 0x6E, 0x82, 0x72, 0}; + static uint8_t str[] = {0x82, 0x72, 0x82, 0x95, 0x82, 0x8E, 0x82, 0x6E, 0x82, 0x72, 0}; #elif defined(__osf__) - static BYTE str[] = {0x82, 0x63, 0x82, 0x89, 0x82, 0x87, 0x82, 0x89, 0x82, 0x94, 0x82, 0x81, 0x82, 0x8C, 0x82, 0x74, 0x82, 0x6D, 0x82, 0x68, 0x82, 0x77, 0}; + static uint8_t str[] = {0x82, 0x63, 0x82, 0x89, 0x82, 0x87, 0x82, 0x89, 0x82, 0x94, 0x82, 0x81, 0x82, 0x8C, 0x82, 0x74, 0x82, 0x6D, 0x82, 0x68, 0x82, 0x77, 0}; #elif defined(sgi) - static BYTE str[] = {0x82, 0x68, 0x82, 0x71, 0x82, 0x68, 0x82, 0x77, 0}; + static uint8_t str[] = {0x82, 0x68, 0x82, 0x71, 0x82, 0x68, 0x82, 0x77, 0}; #else - static BYTE str[] = {0x82, 0x74, 0x82, 0x8e, 0x82, 0x8b, 0x82, 0x8e, 0x82, 0x8f, 0x82, 0x97, 0x82, 0x8e, 0}; + static uint8_t str[] = {0x82, 0x74, 0x82, 0x8e, 0x82, 0x8b, 0x82, 0x8e, 0x82, 0x8f, 0x82, 0x97, 0x82, 0x8e, 0}; #endif svar_set(num, str); diff --git a/src/cursor.c b/src/cursor.c index 561ef49..6be0dc6 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -42,7 +42,7 @@ typedef struct RIFFchunk { char *data; } RIFFchunk_t; -static boolean search_chunk(BYTE *src, char *key1, char *key2, RIFFchunk_t *c) { +static boolean search_chunk(uint8_t *src, char *key1, char *key2, RIFFchunk_t *c) { if (0 == strncmp(src, key1, 4)) { c->size = LittleEndian_getW(src, 4); if (key2) { @@ -58,14 +58,14 @@ static boolean search_chunk(BYTE *src, char *key1, char *key2, RIFFchunk_t *c) { return FALSE; } -static boolean is_riff(BYTE *data) { +static boolean is_riff(uint8_t *data) { if (0 == strncmp(data, "RIFF", 4)) { return TRUE; } return FALSE; } -static boolean check_iconheader(BYTE *data) { +static boolean check_iconheader(uint8_t *data) { /* read Reserved bit, abort if not 0 */ cursorHeader.idReserved = LittleEndian_getW(data, 0); @@ -100,8 +100,8 @@ static boolean check_iconheader(BYTE *data) { return TRUE; } -static int read_direntries(BYTE* data) { - BYTE *p = data; +static int read_direntries(uint8_t* data) { + uint8_t *p = data; /* read Width, in pixels */ cursordirentry.bWidth = *data; @@ -155,8 +155,8 @@ static int read_direntries(BYTE* data) { return (int)(data - p); } -static int read_bitmapinfo(BYTE* data) { - BYTE* p = data; +static int read_bitmapinfo(uint8_t* data) { + uint8_t* p = data; #define ih cursorImage.icHeader /* read bitmap info an perform some primitive sanity checks */ @@ -226,10 +226,10 @@ static int read_bitmapinfo(BYTE* data) { return (int)(data - p); } -static int read_rgbquad(BYTE* data) { +static int read_rgbquad(uint8_t* data) { int j; const int colors=2; - BYTE* p = data; + uint8_t* p = data; free(cursorImage.icColors); cursorImage.icColors = malloc(sizeof(TRGBQuad) * colors); @@ -259,7 +259,7 @@ static int read_rgbquad(BYTE* data) { return (int)(data - p); } -static boolean cursor_load_mono(BYTE *d, int no) { +static boolean cursor_load_mono(uint8_t *d, int no) { int pos = 6, p1; /* check header information */ @@ -300,8 +300,8 @@ static boolean cursor_load_mono(BYTE *d, int no) { return TRUE; } -static boolean cursor_load_anim(BYTE *data, int no) { - BYTE *b = data; +static boolean cursor_load_anim(uint8_t *data, int no) { + uint8_t *b = data; int riffsize; RIFFchunk_t c; @@ -319,7 +319,7 @@ static boolean cursor_load_anim(BYTE *data, int no) { NOTICE("LIST(INFO) ignore size = %d", c.size); b += c.size + 8; } else if (search_chunk(b, "anih", NULL, &c)) { - BYTE *src = c.data; + uint8_t *src = c.data; NOTICE("anih size = %d", c.size); anicurHeader.cbSizeof = LittleEndian_getW(src, 0); anicurHeader.cFrames = LittleEndian_getW(src, 4); @@ -335,7 +335,7 @@ static boolean cursor_load_anim(BYTE *data, int no) { b += c.size + 8; } else if (search_chunk(b, "rate", NULL, &c)) { - BYTE *src = c.data; + uint8_t *src = c.data; NOTICE("rate size = %d", c.size); if (anicurHeader.fl & 0x01) { int i; diff --git a/src/debug_symbol.c b/src/debug_symbol.c index 47dc271..348c938 100644 --- a/src/debug_symbol.c +++ b/src/debug_symbol.c @@ -68,7 +68,7 @@ const char *fget4cc(FILE *fp) { } int fgetdw(FILE *fp) { - BYTE buf[4]; + uint8_t buf[4]; if (fread(buf, 4, 1, fp) != 1) { WARNING("fread: %s", strerror(errno)); return 0; diff --git a/src/debugger.c b/src/debugger.c index 278f2c8..8bbc8c6 100644 --- a/src/debugger.c +++ b/src/debugger.c @@ -359,7 +359,7 @@ void dbg_delete_breakpoints_in_page(int page) { } } -BYTE dbg_handle_breakpoint(int page, int addr) { +uint8_t dbg_handle_breakpoint(int page, int addr) { for (Breakpoint *bp = breakpoints; bp; bp = bp->next) { if (bp->phys->page != page || bp->phys->addr != addr) continue; @@ -369,7 +369,7 @@ BYTE dbg_handle_breakpoint(int page, int addr) { dbg_state = bp->no == INTERNAL_BREAKPOINT_NO ? DBG_STOPPED_NEXT : DBG_STOPPED_BREAKPOINT; - BYTE restore_op = bp->phys->restore_op; + uint8_t restore_op = bp->phys->restore_op; dbg_main(bp->no); // this may destroy bp return restore_op; } diff --git a/src/debugger.h b/src/debugger.h index f8a5c55..4e2e61e 100644 --- a/src/debugger.h +++ b/src/debugger.h @@ -45,7 +45,7 @@ void dbg_init(const char *symbols_path, boolean use_dap); void dbg_quit(void); void dbg_main(int bp_no); void dbg_onsleep(void); -BYTE dbg_handle_breakpoint(int page, int addr); +uint8_t dbg_handle_breakpoint(int page, int addr); boolean dbg_console_vprintf(int lv, const char *format, va_list ap); #else // ENABLE_DEBUGGER diff --git a/src/debugger_private.h b/src/debugger_private.h index 77acd16..f3abbde 100644 --- a/src/debugger_private.h +++ b/src/debugger_private.h @@ -29,7 +29,7 @@ typedef struct { int page; int addr; int refcnt; - BYTE restore_op; + uint8_t restore_op; } PhysicalBreakpoint; typedef struct breakpoint { diff --git a/src/dri.c b/src/dri.c index 7c12421..e5c3b82 100644 --- a/src/dri.c +++ b/src/dri.c @@ -54,7 +54,7 @@ static long getfilesize(FILE *fp) { * return: TRUE if it's dri file */ static boolean filecheck (FILE *fp) { - BYTE b[6]; + uint8_t b[6]; int mapsize, ptrsize; long filesize; @@ -86,7 +86,7 @@ static boolean filecheck (FILE *fp) { * fp: FILE object */ static void get_filemap(drifiles *d, FILE *fp) { - BYTE b[6], *_b; + uint8_t b[6], *_b; int mapsize, ptrsize, i; /* read top 6bytes */ @@ -214,7 +214,7 @@ drifiles *dri_init(const char **file, int cnt, boolean use_mmap) { * return: dridata obhect */ dridata *dri_getdata(drifiles *d, int no) { - BYTE *data; + uint8_t *data; dridata *dfile; int disk, ptr, dataptr, dataptr2, size; diff --git a/src/flood.h b/src/flood.h index a253636..97f3a29 100644 --- a/src/flood.h +++ b/src/flood.h @@ -19,7 +19,7 @@ #define CONCATENATE(x, y) x ## y #define CONCAT(x, y) CONCATENATE(x, y) -static SDL_Rect CONCAT(sdl_floodFill, TYPE)(int x, int y, Uint32 col) { +static SDL_Rect CONCAT(sdl_floodFill_, TYPE)(int x, int y, Uint32 col) { int old_color = *(TYPE *)PIXEL_AT(sdl_dib, x, y); if (old_color == col) return (SDL_Rect){}; @@ -37,8 +37,8 @@ static SDL_Rect CONCAT(sdl_floodFill, TYPE)(int x, int y, Uint32 col) { top--; TYPE *line = PIXEL_AT(sdl_dib, 0, y); - TYPE *prev_line = (TYPE *)((BYTE *)line - sdl_dib->pitch); - TYPE *next_line = (TYPE *)((BYTE *)line + sdl_dib->pitch); + TYPE *prev_line = (TYPE *)((uint8_t *)line - sdl_dib->pitch); + TYPE *next_line = (TYPE *)((uint8_t *)line + sdl_dib->pitch); while (x >= 0 && line[x] == old_color) x--; x++; minx = min(x, minx); diff --git a/src/font.c b/src/font.c index 25d0cb6..babdbd5 100644 --- a/src/font.c +++ b/src/font.c @@ -118,7 +118,7 @@ SDL_Surface *font_get_glyph(const char *str_utf8) { } // SDL can't blit ARGB to an indexed bitmap properly, so we do it ourselves. -static void sdl_drawAntiAlias_8bpp(int dstx, int dsty, SDL_Surface *src, BYTE col) +static void sdl_drawAntiAlias_8bpp(int dstx, int dsty, SDL_Surface *src, uint8_t col) { Uint8 cache[256*7]; memset(cache, 0, 256); @@ -126,8 +126,8 @@ static void sdl_drawAntiAlias_8bpp(int dstx, int dsty, SDL_Surface *src, BYTE co for (int y = 0; y < src->h && dsty + y < sdl_dib->h; y++) { if (dsty + y < 0) continue; - BYTE *sp = (BYTE*)src->pixels + y * src->pitch; - BYTE *dp = (BYTE*)sdl_dib->pixels + (dsty + y) * sdl_dib->pitch + dstx; + uint8_t *sp = (uint8_t*)src->pixels + y * src->pitch; + uint8_t *dp = (uint8_t*)sdl_dib->pixels + (dsty + y) * sdl_dib->pitch + dstx; for (int x = 0; x < src->w && dstx + x < sdl_dib->w; x++) { Uint8 r, g, b, alpha; SDL_GetRGBA(*((Uint32*)sp), src->format, &r, &g, &b, &alpha); @@ -154,7 +154,7 @@ static void sdl_drawAntiAlias_8bpp(int dstx, int dsty, SDL_Surface *src, BYTE co } } -SDL_Rect font_draw_glyph(int x, int y, const char *str_utf8, BYTE cl) { +SDL_Rect font_draw_glyph(int x, int y, const char *str_utf8, uint8_t cl) { SDL_Surface *fs; SDL_Rect r_src, r_dst = {}; int w, h; diff --git a/src/font.h b/src/font.h index ea8face..3d1cce3 100644 --- a/src/font.h +++ b/src/font.h @@ -37,7 +37,7 @@ extern void font_set_antialias(boolean enable); extern boolean font_get_antialias(void); extern void font_select(int type, int size); extern struct SDL_Surface *font_get_glyph(const char *str_utf8); -extern SDL_Rect font_draw_glyph(int x, int y, const char *str_utf8, BYTE col); +extern SDL_Rect font_draw_glyph(int x, int y, const char *str_utf8, uint8_t col); #ifdef __EMSCRIPTEN__ extern int load_mincho_font(void); diff --git a/src/graphics.h b/src/graphics.h index ae1e195..e3cd175 100644 --- a/src/graphics.h +++ b/src/graphics.h @@ -28,14 +28,14 @@ #include typedef struct { - BYTE red[256]; - BYTE green[256]; - BYTE blue[256]; + uint8_t red[256]; + uint8_t green[256]; + uint8_t blue[256]; } Palette256; typedef struct { - BYTE r,g,b; - DWORD pixel; + uint8_t r,g,b; + uint32_t pixel; } Palette; typedef SDL_Point MyPoint; diff --git a/src/hankaku.c b/src/hankaku.c index 37f370f..38bbe3e 100644 --- a/src/hankaku.c +++ b/src/hankaku.c @@ -30,7 +30,7 @@ #include "hankaku.h" #include "system.h" -static const BYTE hankakutable[3][192] = {{ +static const uint8_t hankakutable[3][192] = {{ // 0x8140 - 0x81ff ' ', 0xa4, 0xa1, ',', '.', 0xa5, ':', ';', '?', '!', 0xde, 0xdf, 0, '`', 0, '^', @@ -108,7 +108,7 @@ static const BYTE hankakutable[3][192] = {{ 0, 0, 0, 0, 0, 0, 0, 0, }}; -static const WORD kanatbl[] = { +static const uint16_t kanatbl[] = { 0x8140, 0x8142, 0x8175, 0x8176, 0x8141, 0x8145, 0x82f0, 0x829f, 0x82a1, 0x82a3, 0x82a5, 0x82a7, 0x82e1, 0x82e3, 0x82e5, 0x82c1, 0x815b, 0x82a0, 0x82a2, 0x82a4, 0x82a6, 0x82a8, 0x82a9, 0x82ab, @@ -133,8 +133,8 @@ static const char zenkaku_digits[][3] = { {0x81, 0x40, 0x00}, /* space */ }; -static BYTE *zen2han_sjis(const BYTE *src) { - BYTE c0, c1; +static uint8_t *zen2han_sjis(const uint8_t *src) { + uint8_t c0, c1; char *dst, *_dst; dst = _dst = malloc(strlen(src) + 1); @@ -146,7 +146,7 @@ static BYTE *zen2han_sjis(const BYTE *src) { *dst++ = c0; } else if (c0 <= 0x83) { c1 = *src++; - BYTE h = hankakutable[c0 - 0x81][c1 - 0x40]; + uint8_t h = hankakutable[c0 - 0x81][c1 - 0x40]; if (h) { *dst++ = h; } else { @@ -342,23 +342,23 @@ static char *zen2han_utf8(const char *src) { return _dst; } -BYTE *zen2han(const BYTE *src, CharacterEncoding enc) { +uint8_t *zen2han(const uint8_t *src, CharacterEncoding enc) { switch (enc) { case SHIFT_JIS: return zen2han_sjis(src); case UTF8: return zen2han_utf8(src); default: - return (BYTE *)src; + return (uint8_t *)src; } } -BYTE *han2zen(const BYTE *src, CharacterEncoding enc) { +uint8_t *han2zen(const uint8_t *src, CharacterEncoding enc) { if (enc != SHIFT_JIS) - return (BYTE *)src; // Not implemented + return (uint8_t *)src; // Not implemented - BYTE c0; - BYTE *dst, *_dst; + uint8_t c0; + uint8_t *dst, *_dst; dst = _dst = malloc(strlen(src) * 2 + 1); if (dst == NULL) @@ -372,7 +372,7 @@ BYTE *han2zen(const BYTE *src, CharacterEncoding enc) { } else if (c0 >= 0xe0) { *dst++ = (char)c0; *dst++ = *src++; } else if (c0 >= 0xa0) { - const WORD kana = kanatbl[c0 - 0xa0]; + const uint16_t kana = kanatbl[c0 - 0xa0]; *dst++ = kana >> 8; *dst++ = kana & 0xff; } else { *dst++ = (char)c0; *dst++ = *src++; diff --git a/src/hankaku.h b/src/hankaku.h index 9d74f79..28a6f3b 100644 --- a/src/hankaku.h +++ b/src/hankaku.h @@ -26,8 +26,8 @@ #include "portab.h" #include "utfsjis.h" -extern BYTE *zen2han(const BYTE *src, CharacterEncoding enc); -extern BYTE *han2zen(const BYTE *src, CharacterEncoding enc); +extern uint8_t *zen2han(const uint8_t *src, CharacterEncoding enc); +extern uint8_t *han2zen(const uint8_t *src, CharacterEncoding enc); extern char *format_number(int n, int width, char *buf); extern char *format_number_zenkaku(int n, int width, char *buf); diff --git a/src/image.c b/src/image.c index 655b95c..28d999b 100644 --- a/src/image.c +++ b/src/image.c @@ -33,43 +33,43 @@ #include "alpha_plane.h" #include "ags.h" -static void (*copy_from_alpha)(agsurface_t *, BYTE *, BYTE *, int, int, ALPHA_DIB_COPY_TYPE); -static void (*copy_to_alpha)(agsurface_t *, BYTE *, BYTE *, int, int, ALPHA_DIB_COPY_TYPE); +static void (*copy_from_alpha)(agsurface_t *, uint8_t *, uint8_t *, int, int, ALPHA_DIB_COPY_TYPE); +static void (*copy_to_alpha)(agsurface_t *, uint8_t *, uint8_t *, int, int, ALPHA_DIB_COPY_TYPE); /******************************************************************************/ /* private methods image操作 16bpp */ /******************************************************************************/ -static void image_copy_from_alpha16(agsurface_t *dib, BYTE *sdata, BYTE *ddata, int w, int h, ALPHA_DIB_COPY_TYPE flag) { +static void image_copy_from_alpha16(agsurface_t *dib, uint8_t *sdata, uint8_t *ddata, int w, int h, ALPHA_DIB_COPY_TYPE flag) { int x, y; - BYTE *yls; - WORD *yld; + uint8_t *yls; + uint16_t *yld; switch(flag) { case TO_16H: for (y = 0; y < h; y++) { - yls = (BYTE *)(sdata + y * dib->width); - yld = (WORD *)(ddata + y * dib->bytes_per_line); + yls = (uint8_t *)(sdata + y * dib->width); + yld = (uint16_t *)(ddata + y * dib->bytes_per_line); for (x = 0; x < w; x++) { - *yld = (WORD)(*yls << 8) | (*yld & 0xff); + *yld = (uint16_t)(*yls << 8) | (*yld & 0xff); yld++; yls++; } } break; case TO_16L: for (y = 0; y < h; y++) { - yls = (BYTE *)(sdata + y * dib->width); - yld = (WORD *)(ddata + y * dib->bytes_per_line); + yls = (uint8_t *)(sdata + y * dib->width); + yld = (uint16_t *)(ddata + y * dib->bytes_per_line); for (x = 0; x < w; x++) { - *yld = (WORD)(*yls) | (*yld & 0xff00); + *yld = (uint16_t)(*yls) | (*yld & 0xff00); yld++; yls++; } } break; case TO_24R: for (y = 0; y < h; y++) { - yls = (BYTE *)(sdata + y * dib->width); - yld = (WORD *)(ddata + y * dib->bytes_per_line); + yls = (uint8_t *)(sdata + y * dib->width); + yld = (uint16_t *)(ddata + y * dib->bytes_per_line); for (x = 0; x < w; x++) { *yld = PIX16(*yls, PIXG16(*yld), PIXB16(*yld)); yld++; yls++; @@ -78,8 +78,8 @@ static void image_copy_from_alpha16(agsurface_t *dib, BYTE *sdata, BYTE *ddata, break; case TO_24G: for (y = 0; y < h; y++) { - yls = (BYTE *)(sdata + y * dib->width); - yld = (WORD *)(ddata + y * dib->bytes_per_line); + yls = (uint8_t *)(sdata + y * dib->width); + yld = (uint16_t *)(ddata + y * dib->bytes_per_line); for (x = 0; x < w; x++) { *yld = PIX16(PIXR16(*yls), *yls, PIXB16(*yld)); yld++; yls++; @@ -88,8 +88,8 @@ static void image_copy_from_alpha16(agsurface_t *dib, BYTE *sdata, BYTE *ddata, break; case TO_24B: for (y = 0; y < h; y++) { - yls = (BYTE *)(sdata + y * dib->width); - yld = (WORD *)(ddata + y * dib->bytes_per_line); + yls = (uint8_t *)(sdata + y * dib->width); + yld = (uint16_t *)(ddata + y * dib->bytes_per_line); for (x = 0; x < w; x++) { *yld = PIX16(PIXR16(*yld), PIXG16(*yld), *yls); yld++; yls++; @@ -101,36 +101,36 @@ static void image_copy_from_alpha16(agsurface_t *dib, BYTE *sdata, BYTE *ddata, } } -static void image_copy_to_alpha16(agsurface_t *dib, BYTE *sdata, BYTE *ddata, int w, int h, ALPHA_DIB_COPY_TYPE flag) { +static void image_copy_to_alpha16(agsurface_t *dib, uint8_t *sdata, uint8_t *ddata, int w, int h, ALPHA_DIB_COPY_TYPE flag) { int x, y; - BYTE *yld; - WORD *yls; + uint8_t *yld; + uint16_t *yls; switch(flag) { case FROM_16H: for (y = 0; y < h; y++) { - yls = (WORD *)(sdata + y * dib->bytes_per_line); - yld = (BYTE *)(ddata + y * dib->width); + yls = (uint16_t *)(sdata + y * dib->bytes_per_line); + yld = (uint8_t *)(ddata + y * dib->width); for (x = 0; x < w; x++) { - *yld = (BYTE)(*yls >> 8); + *yld = (uint8_t)(*yls >> 8); yld++; yls++; } } break; case FROM_16L: for (y = 0; y < h; y++) { - yls = (WORD *)(sdata + y * dib->bytes_per_line); - yld = (BYTE *)(ddata + y * dib->width); + yls = (uint16_t *)(sdata + y * dib->bytes_per_line); + yld = (uint8_t *)(ddata + y * dib->width); for (x = 0; x < w; x++) { - *yld = (BYTE)(*yls); + *yld = (uint8_t)(*yls); yld++; yls++; } } break; case FROM_24R: for (y = 0; y < h; y++) { - yls = (WORD *)(sdata + y * dib->bytes_per_line); - yld = (BYTE *)(ddata + y * dib->width); + yls = (uint16_t *)(sdata + y * dib->bytes_per_line); + yld = (uint8_t *)(ddata + y * dib->width); for (x = 0; x < w; x++) { *yld = PIXR16(*yls); yld++; yls++; @@ -139,8 +139,8 @@ static void image_copy_to_alpha16(agsurface_t *dib, BYTE *sdata, BYTE *ddata, in break; case FROM_24G: for (y = 0; y < h; y++) { - yls = (WORD *)(sdata + y * dib->bytes_per_line); - yld = (BYTE *)(ddata + y * dib->width); + yls = (uint16_t *)(sdata + y * dib->bytes_per_line); + yld = (uint8_t *)(ddata + y * dib->width); for (x = 0; x < w; x++) { *yld = PIXG16(*yls); yld++; yls++; @@ -149,8 +149,8 @@ static void image_copy_to_alpha16(agsurface_t *dib, BYTE *sdata, BYTE *ddata, in break; case FROM_24B: for (y = 0; y < h; y++) { - yls = (WORD *)(sdata + y * dib->bytes_per_line); - yld = (BYTE *)(ddata + y * dib->width); + yls = (uint16_t *)(sdata + y * dib->bytes_per_line); + yld = (uint8_t *)(ddata + y * dib->width); for (x = 0; x < w; x++) { *yld = PIXB16(*yls); yld++; yls++; @@ -166,16 +166,16 @@ static void image_copy_to_alpha16(agsurface_t *dib, BYTE *sdata, BYTE *ddata, in /* private methods image操作 24/32bpp */ /******************************************************************************/ -static void image_copy_from_alpha24(agsurface_t *dib, BYTE *sdata, BYTE *ddata, int w, int h, ALPHA_DIB_COPY_TYPE flag) { +static void image_copy_from_alpha24(agsurface_t *dib, uint8_t *sdata, uint8_t *ddata, int w, int h, ALPHA_DIB_COPY_TYPE flag) { int x, y; - BYTE *yls; - DWORD *yld; + uint8_t *yls; + uint32_t *yld; switch(flag) { case TO_16H: for (y = 0; y < h; y++) { - yls = (BYTE *)(sdata + y * dib->width); - yld = (DWORD *)(ddata + y * dib->bytes_per_line); + yls = (uint8_t *)(sdata + y * dib->width); + yld = (uint32_t *)(ddata + y * dib->bytes_per_line); for (x = 0; x < w; x++) { /* *yld = */ yld++; yls++; @@ -184,18 +184,18 @@ static void image_copy_from_alpha24(agsurface_t *dib, BYTE *sdata, BYTE *ddata, break; case TO_16L: for (y = 0; y < h; y++) { - yls = (BYTE *)(sdata + y * dib->width); - yld = (DWORD *)(ddata + y * dib->bytes_per_line); + yls = (uint8_t *)(sdata + y * dib->width); + yld = (uint32_t *)(ddata + y * dib->bytes_per_line); for (x = 0; x < w; x++) { - /* *yld = (WORD)(*yls) | (*yld & 0xff00); */ + /* *yld = (uint16_t)(*yls) | (*yld & 0xff00); */ yld++; yls++; } } break; case TO_24R: for (y = 0; y < h; y++) { - yls = (BYTE *)(sdata + y * dib->width); - yld = (DWORD *)(ddata + y * dib->bytes_per_line); + yls = (uint8_t *)(sdata + y * dib->width); + yld = (uint32_t *)(ddata + y * dib->bytes_per_line); for (x = 0; x < w; x++) { *yld = PIX24(*yls, PIXG24(*yld), PIXB24(*yld)); yld++; yls++; @@ -204,8 +204,8 @@ static void image_copy_from_alpha24(agsurface_t *dib, BYTE *sdata, BYTE *ddata, break; case TO_24G: for (y = 0; y < h; y++) { - yls = (BYTE *)(sdata + y * dib->width); - yld = (DWORD *)(ddata + y * dib->bytes_per_line); + yls = (uint8_t *)(sdata + y * dib->width); + yld = (uint32_t *)(ddata + y * dib->bytes_per_line); for (x = 0; x < w; x++) { *yld = PIX24(PIXR24(*yls), *yls, PIXB24(*yld)); yld++; yls++; @@ -214,8 +214,8 @@ static void image_copy_from_alpha24(agsurface_t *dib, BYTE *sdata, BYTE *ddata, break; case TO_24B: for (y = 0; y < h; y++) { - yls = (BYTE *)(sdata + y * dib->width); - yld = (DWORD *)(ddata + y * dib->bytes_per_line); + yls = (uint8_t *)(sdata + y * dib->width); + yld = (uint32_t *)(ddata + y * dib->bytes_per_line); for (x = 0; x < w; x++) { *yld = PIX24(PIXR24(*yld), PIXG24(*yld), *yls); yld++; yls++; @@ -227,58 +227,58 @@ static void image_copy_from_alpha24(agsurface_t *dib, BYTE *sdata, BYTE *ddata, } } -static void image_copy_to_alpha24(agsurface_t *dib, BYTE *sdata, BYTE *ddata, int w, int h, ALPHA_DIB_COPY_TYPE flag) { +static void image_copy_to_alpha24(agsurface_t *dib, uint8_t *sdata, uint8_t *ddata, int w, int h, ALPHA_DIB_COPY_TYPE flag) { int x, y; - BYTE *yld; - DWORD *yls; + uint8_t *yld; + uint32_t *yls; switch(flag) { case FROM_16H: for (y = 0; y < h; y++) { - yls = (DWORD *)(sdata + y * dib->bytes_per_line); - yld = (BYTE *)(ddata + y * dib->width); + yls = (uint32_t *)(sdata + y * dib->bytes_per_line); + yld = (uint8_t *)(ddata + y * dib->width); for (x = 0; x < w; x++) { - *yld = (BYTE)(PIX16(PIXR24(*yls), PIXG24(*yls), PIXB24(*yls)) >> 8); + *yld = (uint8_t)(PIX16(PIXR24(*yls), PIXG24(*yls), PIXB24(*yls)) >> 8); yld++; yls++; } } break; case FROM_16L: for (y = 0; y < h; y++) { - yls = (DWORD *)(sdata + y * dib->bytes_per_line); - yld = (BYTE *)(ddata + y * dib->width); + yls = (uint32_t *)(sdata + y * dib->bytes_per_line); + yld = (uint8_t *)(ddata + y * dib->width); for (x = 0; x < w; x++) { - *yld = (BYTE)(PIX16(PIXR24(*yls), PIXG24(*yls), PIXB24(*yls))); + *yld = (uint8_t)(PIX16(PIXR24(*yls), PIXG24(*yls), PIXB24(*yls))); yld++; yls++; } } break; case FROM_24R: for (y = 0; y < h; y++) { - yls = (DWORD *)(sdata + y * dib->bytes_per_line); - yld = (BYTE *)(ddata + y * dib->width); + yls = (uint32_t *)(sdata + y * dib->bytes_per_line); + yld = (uint8_t *)(ddata + y * dib->width); for (x = 0; x < w; x++) { - *yld = (BYTE)PIXR24(*yls); + *yld = (uint8_t)PIXR24(*yls); yld++; yls++; } } break; case FROM_24G: for (y = 0; y < h; y++) { - yls = (DWORD *)(sdata + y * dib->bytes_per_line); - yld = (BYTE *)(ddata + y * dib->width); + yls = (uint32_t *)(sdata + y * dib->bytes_per_line); + yld = (uint8_t *)(ddata + y * dib->width); for (x = 0; x < w; x++) { - *yld = (BYTE)PIXG24(*yls); + *yld = (uint8_t)PIXG24(*yls); yld++; yls++; } } break; case FROM_24B: for (y = 0; y < h; y++) { - yls = (DWORD *)(sdata + y * dib->bytes_per_line); - yld = (BYTE *)(ddata + y * dib->width); + yls = (uint32_t *)(sdata + y * dib->bytes_per_line); + yld = (uint8_t *)(ddata + y * dib->width); for (x = 0; x < w; x++) { - *yld = (BYTE)PIXB24(*yls); + *yld = (uint8_t)PIXB24(*yls); yld++; yls++; } } @@ -312,15 +312,15 @@ void image_setdepth(int depth) { } void image_copy_from_alpha(agsurface_t *dib, int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag) { - BYTE *sdata = GETOFFSET_ALPHA(dib, sx, sy); - BYTE *ddata = GETOFFSET_PIXEL(dib, dx, dy); + uint8_t *sdata = GETOFFSET_ALPHA(dib, sx, sy); + uint8_t *ddata = GETOFFSET_PIXEL(dib, dx, dy); copy_from_alpha(dib, sdata, ddata, w, h, flag); } void image_copy_to_alpha(agsurface_t *dib, int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_COPY_TYPE flag) { - BYTE *sdata = GETOFFSET_PIXEL(dib, sx, sy); - BYTE *ddata = GETOFFSET_ALPHA(dib, dx, dy); + uint8_t *sdata = GETOFFSET_PIXEL(dib, sx, sy); + uint8_t *ddata = GETOFFSET_ALPHA(dib, dx, dy); copy_to_alpha(dib, sdata, ddata, w, h, flag); } diff --git a/src/jpeg.c b/src/jpeg.c index a647a6a..a26ead3 100644 --- a/src/jpeg.c +++ b/src/jpeg.c @@ -33,13 +33,13 @@ #include "system.h" #include "jpeg.h" -boolean jpeg_checkfmt(BYTE *data) { +boolean jpeg_checkfmt(uint8_t *data) { return data[0] == 0xff && data[1] == 0xd8; } -cgdata *jpeg_extract(BYTE *data, size_t size) { +cgdata *jpeg_extract(uint8_t *data, size_t size) { int width, height, channels; - BYTE *pixels = stbi_load_from_memory(data, size, &width, &height, &channels, 3); + uint8_t *pixels = stbi_load_from_memory(data, size, &width, &height, &channels, 3); if (!pixels) { WARNING("cannot decode jpeg: %s", stbi_failure_reason()); return NULL; diff --git a/src/jpeg.h b/src/jpeg.h index ccd211b..70e1c64 100644 --- a/src/jpeg.h +++ b/src/jpeg.h @@ -22,7 +22,7 @@ #include "cg.h" -extern boolean jpeg_checkfmt(BYTE *data); -extern cgdata *jpeg_extract(BYTE *data, size_t size); +extern boolean jpeg_checkfmt(uint8_t *data); +extern cgdata *jpeg_extract(uint8_t *data, size_t size); #endif // __JPEG_H__ diff --git a/src/midifile.c b/src/midifile.c index c5ab4f0..9ac5a56 100644 --- a/src/midifile.c +++ b/src/midifile.c @@ -53,7 +53,7 @@ static char *msg(); static int midigetc(); static long readvarinum(); static void read_playevent(); -static int read_header(BYTE *stream, off_t len); +static int read_header(uint8_t *stream, off_t len); static struct midiinfo *midi; @@ -482,9 +482,9 @@ static void read_playevent() { } } -static int read_header(BYTE *stream, off_t len) { +static int read_header(uint8_t *stream, off_t len) { int tracklen, i = 0; - BYTE *stream_top = stream; + uint8_t *stream_top = stream; while(i == 0 && stream < (stream_top + len)) { if (0 == strncmp(stream, "MThd", 4)) { @@ -557,7 +557,7 @@ static int read_header(BYTE *stream, off_t len) { return OK; } -struct midiinfo *mf_read_midifile(BYTE *stream, off_t len) { +struct midiinfo *mf_read_midifile(uint8_t *stream, off_t len) { midi = malloc(sizeof(struct midiinfo)); midi->msgsize = 128; /* Initial msg buffer size */ diff --git a/src/midifile.h b/src/midifile.h index 8362ba0..ad0d3a0 100644 --- a/src/midifile.h +++ b/src/midifile.h @@ -73,8 +73,8 @@ struct midiinfo { int division; /* division for delta time*/ int ntrks; /* number of track */ - BYTE *data; - BYTE *cdata; + uint8_t *data; + uint8_t *cdata; int length; int length_left; @@ -93,7 +93,7 @@ struct midiinfo { int marker; }; -extern struct midiinfo *mf_read_midifile(BYTE *stream, off_t len); +extern struct midiinfo *mf_read_midifile(uint8_t *stream, off_t len); extern void mf_remove_midifile(struct midiinfo *m); #endif /* __MIDIFILE_H__ */ diff --git a/src/pms.c b/src/pms.c index db952ca..745cb1d 100644 --- a/src/pms.c +++ b/src/pms.c @@ -43,17 +43,17 @@ /* * static methods */ -static pms_header *extract_header(BYTE *b); -static void getpal(Palette256 *pal, BYTE *b); -static void extract_8bit(pms_header *pms, BYTE *pic, BYTE *b); -static void extract_16bit(pms_header *pms, WORD *pic, BYTE *b); +static pms_header *extract_header(uint8_t *b); +static void getpal(Palette256 *pal, uint8_t *b); +static void extract_8bit(pms_header *pms, uint8_t *pic, uint8_t *b); +static void extract_16bit(pms_header *pms, uint16_t *pic, uint8_t *b); /* * Get information from cg header * b: raw data (pointer to header) * return: acquired pms information object */ -static pms_header *extract_header(BYTE *b) { +static pms_header *extract_header(uint8_t *b) { pms_header *pms = malloc(sizeof(pms_header)); pms->pmsVer = LittleEndian_getW(b, 2); @@ -78,7 +78,7 @@ static pms_header *extract_header(BYTE *b) { * pal: palette to be stored * b : raw data (pointer to palette) */ -static void getpal(Palette256 *pal, BYTE *b) { +static void getpal(Palette256 *pal, uint8_t *b) { int i; for (i = 0; i < 256; i++) { @@ -94,7 +94,7 @@ static void getpal(Palette256 *pal, BYTE *b) { * pic: pixel to be stored * b : raw data (pointer to pixel) */ -static void extract_8bit(pms_header *pms, BYTE *pic, BYTE *b) { +static void extract_8bit(pms_header *pms, uint8_t *pic, uint8_t *b) { int c0, c1; int x, y, loc, l, i; int scanline = pms->pmsXW; @@ -135,7 +135,7 @@ static void extract_8bit(pms_header *pms, BYTE *pic, BYTE *b) { * pic: pixel to be stored * b : raw data (pointer to pixel) */ -static void extract_16bit(pms_header *pms, WORD *pic, BYTE *b) { +static void extract_16bit(pms_header *pms, uint16_t *pic, uint8_t *b) { int c0, c1, pc0, pc1; int x, y, i, l, loc; int scanline = pms->pmsXW; @@ -202,7 +202,7 @@ static void extract_16bit(pms_header *pms, WORD *pic, BYTE *b) { * data: raw data (pointer to data top) * return: TRUE if data is pms */ -boolean pms256_checkfmt(BYTE *data) { +boolean pms256_checkfmt(uint8_t *data) { int x, y, w, h; if (data[0] != 0x50 || data[1] != 0x4d) return FALSE; @@ -223,7 +223,7 @@ boolean pms256_checkfmt(BYTE *data) { * data: raw data (pointer to data top) * return: extracted image data and information */ -cgdata *pms256_extract(BYTE *data) { +cgdata *pms256_extract(uint8_t *data) { cgdata *cg = calloc(1, sizeof(cgdata)); pms_header *pms = extract_header(data); @@ -231,7 +231,7 @@ cgdata *pms256_extract(BYTE *data) { getpal(cg->pal, data + pms->pmsPp); /* +10: margin for broken cg */ - cg->pic = malloc(sizeof(BYTE) * ((pms->pmsXW + 10) * (pms->pmsYW + 10))); + cg->pic = malloc(sizeof(uint8_t) * ((pms->pmsXW + 10) * (pms->pmsYW + 10))); extract_8bit(pms, cg->pic, data + pms->pmsDp); cg->type = ALCG_PMS8; @@ -253,7 +253,7 @@ cgdata *pms256_extract(BYTE *data) { * data: raw data (pointer to data top) * return: TRUE if data is pms */ -boolean pms64k_checkfmt(BYTE *data) { +boolean pms64k_checkfmt(uint8_t *data) { int x, y, w, h; if (data[0] != 0x50 || data[1] != 0x4d) return FALSE; @@ -274,17 +274,17 @@ boolean pms64k_checkfmt(BYTE *data) { * data: raw data (pointer to data top) * return: extracted image data and information */ -cgdata *pms64k_extract(BYTE *data) { +cgdata *pms64k_extract(uint8_t *data) { cgdata *cg = calloc(1, sizeof(cgdata)); pms_header *pms = extract_header(data); /* +10: margin for broken cg */ - cg->pic = (BYTE *)malloc(sizeof(WORD) * ((pms->pmsXW + 10) * (pms->pmsYW + 10))); - extract_16bit(pms, (WORD *)cg->pic, data + pms->pmsDp); + cg->pic = (uint8_t *)malloc(sizeof(uint16_t) * ((pms->pmsXW + 10) * (pms->pmsYW + 10))); + extract_16bit(pms, (uint16_t *)cg->pic, data + pms->pmsDp); cg->alpha = NULL; if (pms->pmsPp != 0) { - cg->alpha = malloc(sizeof(BYTE) * ((pms->pmsXW + 10) * (pms->pmsYW + 10))); + cg->alpha = malloc(sizeof(uint8_t) * ((pms->pmsXW + 10) * (pms->pmsYW + 10))); extract_8bit(pms, cg->alpha, data + pms->pmsPp); } diff --git a/src/pms.h b/src/pms.h index 2257fa8..ce069cb 100644 --- a/src/pms.h +++ b/src/pms.h @@ -59,10 +59,10 @@ typedef struct { * */ -extern boolean pms256_checkfmt(BYTE *data); -extern cgdata *pms256_extract(BYTE *data); -extern boolean pms64k_checkfmt(BYTE *data); -extern cgdata *pms64k_extract(BYTE *data); +extern boolean pms256_checkfmt(uint8_t *data); +extern cgdata *pms256_extract(uint8_t *data); +extern boolean pms64k_checkfmt(uint8_t *data); +extern cgdata *pms64k_extract(uint8_t *data); #endif /* !__PMS__ */ diff --git a/src/portab.h b/src/portab.h index 32e3f2e..b32a35a 100644 --- a/src/portab.h +++ b/src/portab.h @@ -40,23 +40,8 @@ #define min(x,y) ((x) < (y) ? (x) : (y)) #define max(x,y) ((x) > (y) ? (x) : (y)) -typedef uint8_t ___BYTE; -typedef uint16_t ___WORD; -typedef uint32_t ___DWORD; typedef bool ___boolean; -#ifndef BYTE -#define BYTE ___BYTE -#endif - -#ifndef WORD -#define WORD ___WORD -#endif - -#ifndef DWORD -#define DWORD ___DWORD -#endif - #ifndef boolean #define boolean ___boolean #endif diff --git a/src/qnt.c b/src/qnt.c index fc71376..372f534 100644 --- a/src/qnt.c +++ b/src/qnt.c @@ -52,7 +52,7 @@ b: raw data qnt: acquired qnt information object */ -static void extract_header(BYTE *b, qnt_header *qnt) { +static void extract_header(uint8_t *b, qnt_header *qnt) { int rsv0 = LittleEndian_getDW(b, 4); if (rsv0 == 0) { qnt->hdr_size = 48; @@ -84,10 +84,10 @@ static void extract_header(BYTE *b, qnt_header *qnt) { pic: pixel to be stored b : raw data (pointer to pixel) */ -static void extract_pixel(qnt_header *qnt, BYTE *pic, BYTE *b) { +static void extract_pixel(qnt_header *qnt, uint8_t *pic, uint8_t *b) { int i, j, x, y, w, h; long ucbuf = (qnt->width+1) * (qnt->height+1) * 3 + ZLIBBUF_MARGIN; - BYTE *raw = malloc(sizeof(BYTE) * ucbuf); + uint8_t *raw = malloc(sizeof(uint8_t) * ucbuf); if (Z_OK != uncompress(raw, &ucbuf, b, qnt->pixel_size)) { WARNING("uncompress failed"); @@ -166,10 +166,10 @@ static void extract_pixel(qnt_header *qnt, BYTE *pic, BYTE *b) { pic: pixel to be stored b : raw data (pointer to alpha pixel) */ -static void extract_alpha(qnt_header *qnt, BYTE *pic, BYTE *b) { +static void extract_alpha(qnt_header *qnt, uint8_t *pic, uint8_t *b) { int i, x, y, w, h; long ucbuf = (qnt->width+1) * (qnt->height+1) + ZLIBBUF_MARGIN; - BYTE *raw = malloc(sizeof(BYTE) * ucbuf); + uint8_t *raw = malloc(sizeof(uint8_t) * ucbuf); if (Z_OK != uncompress(raw, &ucbuf, b, qnt->alpha_size)) { WARNING("uncompress failed"); @@ -214,7 +214,7 @@ static void extract_alpha(qnt_header *qnt, BYTE *pic, BYTE *b) { return: TRUE if data is qnt */ -boolean qnt_checkfmt(BYTE *data) { +boolean qnt_checkfmt(uint8_t *data) { if (data[0] != 'Q' || data[1] != 'N' || data[2] != 'T') return FALSE; return TRUE; } @@ -226,17 +226,17 @@ boolean qnt_checkfmt(BYTE *data) { return: extracted image data and information */ -cgdata *qnt_extract(BYTE *data) { +cgdata *qnt_extract(uint8_t *data) { cgdata *cg = calloc(1, sizeof(cgdata)); qnt_header qnt; extract_header(data, &qnt); - cg->pic = malloc(sizeof(BYTE) * ((qnt.width+10) * (qnt.height+10) * 3)); + cg->pic = malloc(sizeof(uint8_t) * ((qnt.width+10) * (qnt.height+10) * 3)); extract_pixel(&qnt, cg->pic, data + qnt.hdr_size); if (qnt.alpha_size != 0) { - cg->alpha = malloc(sizeof(BYTE) * ((qnt.width+10) * (qnt.height+10))); - extract_alpha(&qnt, (BYTE *)cg->alpha, data + qnt.hdr_size + qnt.pixel_size); + cg->alpha = malloc(sizeof(uint8_t) * ((qnt.width+10) * (qnt.height+10))); + extract_alpha(&qnt, (uint8_t *)cg->alpha, data + qnt.hdr_size + qnt.pixel_size); } cg->type = ALCG_QNT; diff --git a/src/qnt.h b/src/qnt.h index 2c9f490..8f9a613 100644 --- a/src/qnt.h +++ b/src/qnt.h @@ -41,7 +41,7 @@ typedef struct { int alpha_size; /* compressed alpha pixel size */ } qnt_header; -extern boolean qnt_checkfmt(BYTE *data); -extern cgdata *qnt_extract(BYTE *data); +extern boolean qnt_checkfmt(uint8_t *data); +extern cgdata *qnt_extract(uint8_t *data); #endif /* __QNT_H__ */ diff --git a/src/savedata.c b/src/savedata.c index 9febdf9..2401879 100644 --- a/src/savedata.c +++ b/src/savedata.c @@ -105,14 +105,14 @@ int load_vars_from_file(char *fname_utf8, struct VarRef *dest, int cnt) { if (!fp) return SAVE_LOADERR; - WORD *tmp = malloc(cnt * sizeof(WORD)); + uint16_t *tmp = malloc(cnt * sizeof(uint16_t)); if (!tmp) { WARNING("Out of memory"); fclose(fp); return SAVE_LOADERR; } - size_t size = fread(tmp, sizeof(WORD), cnt, fp); + size_t size = fread(tmp, sizeof(uint16_t), cnt, fp); fclose(fp); if (size != cnt) { @@ -242,7 +242,7 @@ int save_copyAll(int dstno, int srcno) { int save_loadPartial(int no, struct VarRef *vref, int cnt) { Ald_baseHdr *save_base; char *vtop; - WORD *tmp; + uint16_t *tmp; int *var; char *saveTop = NULL; int i, status, filesize; @@ -272,7 +272,7 @@ int save_loadPartial(int no, struct VarRef *vref, int cnt) { goto errexit; } vtop = saveTop + save_base->varSys[vref->page] + sizeof(Ald_sysVarHdr); - tmp = (WORD *)vtop + vref->index; + tmp = (uint16_t *)vtop + vref->index; for (i = 0; i < cnt; i++) { *var = *tmp; tmp++; var++; } @@ -289,7 +289,7 @@ int save_loadPartial(int no, struct VarRef *vref, int cnt) { /* データの一部セーブ */ int save_savePartial(int no, struct VarRef *vref, int cnt) { Ald_baseHdr *save_base; - WORD *tmp; + uint16_t *tmp; char *vtop; int *var; char *saveTop = NULL; @@ -314,9 +314,9 @@ int save_savePartial(int no, struct VarRef *vref, int cnt) { goto errexit; } vtop = saveTop + save_base->varSys[vref->page] + sizeof(Ald_sysVarHdr); - tmp = (WORD *)vtop + vref->index; + tmp = (uint16_t *)vtop + vref->index; for (i = 0; i < cnt; i++) { - *tmp = (WORD)*var; tmp++; var++; + *tmp = (uint16_t)*var; tmp++; var++; } status = saveGameData(no, saveTop, filesize); free(saveTop); @@ -428,29 +428,29 @@ int save_saveAll(int no) { /* 各種データのセーブ */ strncpy(save_base->ID, SAVE_DATAID, 32); save_base->version = SAVE_DATAVERSION; - save_base->selMsgSize = (BYTE)nact->sel.MsgFontSize; - save_base->selMsgColor = (BYTE)nact->sel.MsgFontColor; - save_base->selBackColor = (BYTE)nact->sel.WinBackgroundColor; - save_base->selFrameColor = (BYTE)nact->sel.WinFrameColor; - save_base->msgMsgSize = (BYTE)nact->msg.MsgFontSize; - save_base->msgMsgColor = (BYTE)nact->msg.MsgFontColor; - save_base->msgBackColor = (BYTE)nact->msg.WinBackgroundColor; - save_base->msgFrameColor = (BYTE)nact->msg.WinFrameColor; + save_base->selMsgSize = (uint8_t)nact->sel.MsgFontSize; + save_base->selMsgColor = (uint8_t)nact->sel.MsgFontColor; + save_base->selBackColor = (uint8_t)nact->sel.WinBackgroundColor; + save_base->selFrameColor = (uint8_t)nact->sel.WinFrameColor; + save_base->msgMsgSize = (uint8_t)nact->msg.MsgFontSize; + save_base->msgMsgColor = (uint8_t)nact->msg.MsgFontColor; + save_base->msgBackColor = (uint8_t)nact->msg.WinBackgroundColor; + save_base->msgFrameColor = (uint8_t)nact->msg.WinFrameColor; save_base->scoPage = sl_getPage(); save_base->scoIndex = sl_getIndex(); for (i = 0; i < SELWINMAX; i++) { - save_base->selWinInfo[i].x = (WORD)nact->sel.wininfo[i].x; - save_base->selWinInfo[i].y = (WORD)nact->sel.wininfo[i].y; - save_base->selWinInfo[i].width = (WORD)nact->sel.wininfo[i].width; - save_base->selWinInfo[i].height = (WORD)nact->sel.wininfo[i].height; + save_base->selWinInfo[i].x = (uint16_t)nact->sel.wininfo[i].x; + save_base->selWinInfo[i].y = (uint16_t)nact->sel.wininfo[i].y; + save_base->selWinInfo[i].width = (uint16_t)nact->sel.wininfo[i].width; + save_base->selWinInfo[i].height = (uint16_t)nact->sel.wininfo[i].height; } for (i = 0; i < MSGWINMAX; i++) { - save_base->msgWinInfo[i].x = (WORD)nact->msg.wininfo[i].x; - save_base->msgWinInfo[i].y = (WORD)nact->msg.wininfo[i].y; - save_base->msgWinInfo[i].width = (WORD)nact->msg.wininfo[i].width; - save_base->msgWinInfo[i].height = (WORD)nact->msg.wininfo[i].height; + save_base->msgWinInfo[i].x = (uint16_t)nact->msg.wininfo[i].x; + save_base->msgWinInfo[i].y = (uint16_t)nact->msg.wininfo[i].y; + save_base->msgWinInfo[i].width = (uint16_t)nact->msg.wininfo[i].width; + save_base->msgWinInfo[i].height = (uint16_t)nact->msg.wininfo[i].height; } fseek(fp, sizeof(Ald_baseHdr), SEEK_SET); @@ -582,7 +582,7 @@ static void loadStrVar(char *buf) { static void *saveSysVar(Ald_sysVarHdr *head, int page) { int *var; int cnt, i; - WORD *tmp, *_tmp; + uint16_t *tmp, *_tmp; if (!varPage[page].saveflag) return NULL; cnt = varPage[page].size; @@ -591,15 +591,15 @@ static void *saveSysVar(Ald_sysVarHdr *head, int page) { var = varPage[page].value; if (var == NULL) return NULL; - head->size = cnt * sizeof(WORD); + head->size = cnt * sizeof(uint16_t); head->pageNo = page; - tmp = _tmp = (WORD *)malloc(cnt * sizeof(WORD)); + tmp = _tmp = (uint16_t *)malloc(cnt * sizeof(uint16_t)); if (tmp == NULL) { WARNING("Out of memory"); return NULL; } for (i = 0; i < cnt; i++) { - *tmp = (WORD)*var; var++; tmp++; + *tmp = (uint16_t)*var; var++; tmp++; } return _tmp; } @@ -608,11 +608,11 @@ static void *saveSysVar(Ald_sysVarHdr *head, int page) { static int loadSysVar(char *buf) { int i, cnt; int *var; - WORD *data; + uint16_t *data; Ald_sysVarHdr *head = (Ald_sysVarHdr *)buf; int page = head->pageNo; - cnt = head->size / sizeof(WORD); + cnt = head->size / sizeof(uint16_t); if (page == 0) savefile_sysvar_cnt = cnt; if (varPage[page].size < cnt || varPage[page].value == NULL) { @@ -624,7 +624,7 @@ static int loadSysVar(char *buf) { var = varPage[page].value; buf += sizeof(Ald_sysVarHdr); - data = (WORD *)buf; + data = (uint16_t *)buf; for (i = 0; i < cnt; i++) { *var++ = *data++; } @@ -690,10 +690,10 @@ static int saveGameData(int no, char *buf, int size) { } /* 指定ファイルからの画像の読み込み thanx tajiru@wizard */ -BYTE* load_cg_with_file(char *fname_utf8, int *status, long *filesize){ +uint8_t* load_cg_with_file(char *fname_utf8, int *status, long *filesize){ int size; FILE *fp; - static BYTE *tmp; + static uint8_t *tmp; *status = 0; diff --git a/src/savedata.h b/src/savedata.h index cfe24e1..8aa1616 100644 --- a/src/savedata.h +++ b/src/savedata.h @@ -47,32 +47,32 @@ typedef int emscripten_align1_int; #define SAVE_DATAVERSION 0x350200 typedef struct { - WORD x; - WORD y; - WORD width; - WORD height; + uint16_t x; + uint16_t y; + uint16_t width; + uint16_t height; } RectangleW; typedef struct { char ID[32]; int version; char gameName[28]; - BYTE selMsgSize; - BYTE selMsgColor; - BYTE selBackColor; - BYTE selFrameColor; - BYTE msgMsgSize; - BYTE msgMsgColor; - BYTE msgBackColor; - BYTE msgFrameColor; - BYTE rsvB1; - BYTE rsvB2; - BYTE rsvB3; - BYTE rsvB4; - BYTE rsvB5; - BYTE rsvB6; - BYTE rsvB7; - BYTE rsvB8; + uint8_t selMsgSize; + uint8_t selMsgColor; + uint8_t selBackColor; + uint8_t selFrameColor; + uint8_t msgMsgSize; + uint8_t msgMsgColor; + uint8_t msgBackColor; + uint8_t msgFrameColor; + uint8_t rsvB1; + uint8_t rsvB2; + uint8_t rsvB3; + uint8_t rsvB4; + uint8_t rsvB5; + uint8_t rsvB6; + uint8_t rsvB7; + uint8_t rsvB8; int scoPage; int scoIndex; int rsvI1; @@ -121,7 +121,7 @@ extern int save_vars_to_file(char *fname_utf8, struct VarRef *src, int cnt); extern int load_vars_from_file(char *fname_utf8, struct VarRef *dest, int cnt); extern int save_save_str_with_file(char *fname_utf8, int start, int cnt); extern int save_load_str_with_file(char *fname_utf8, int start, int cnt); -extern BYTE* load_cg_with_file(char *fname_utf8, int *status, long *filesize); +extern uint8_t* load_cg_with_file(char *fname_utf8, int *status, long *filesize); extern const char *save_get_file(int index); extern int save_delete_file(int index); diff --git a/src/scenario.c b/src/scenario.c index 8f5a308..cd74d3a 100644 --- a/src/scenario.c +++ b/src/scenario.c @@ -32,7 +32,7 @@ #include "LittleEndian.h" #include "xsystem35.h" -const BYTE *sl_sco; +const uint8_t *sl_sco; int sl_page; int sl_index; diff --git a/src/scenario.h b/src/scenario.h index 0b6295f..b908108 100644 --- a/src/scenario.h +++ b/src/scenario.h @@ -44,7 +44,7 @@ enum txx_type { }; // Use functions below instead of accessing these variables directly. -extern const BYTE *sl_sco; // scenario page buffer +extern const uint8_t *sl_sco; // scenario page buffer extern int sl_page; // current scenario page (0-based) extern int sl_index; // cureent scenario address diff --git a/src/sdl_core.h b/src/sdl_core.h index 8238c9e..350ddb5 100644 --- a/src/sdl_core.h +++ b/src/sdl_core.h @@ -57,16 +57,16 @@ extern void sdl_updateScreen(void); extern void sdl_setPalette(Palette256 *pal, int first, int count); /* 描画関係 */ -extern void sdl_drawRectangle(int x, int y, int w, int h, BYTE c); -extern void sdl_fillRectangle(int x, int y, int w, int h, BYTE c); -extern void sdl_fillRectangleRGB(int x, int y, int w, int h, BYTE r, BYTE g, BYTE b); -extern void sdl_fillCircle(int left, int top, int diameter, BYTE c); -extern void sdl_drawLine(int x1, int y1, int x2, int y2, BYTE c); +extern void sdl_drawRectangle(int x, int y, int w, int h, uint8_t c); +extern void sdl_fillRectangle(int x, int y, int w, int h, uint8_t c); +extern void sdl_fillRectangleRGB(int x, int y, int w, int h, uint8_t r, uint8_t g, uint8_t b); +extern void sdl_fillCircle(int left, int top, int diameter, uint8_t c); +extern void sdl_drawLine(int x1, int y1, int x2, int y2, uint8_t c); extern SDL_Rect sdl_floodFill(int x, int y, int col); -extern SDL_Rect sdl_drawString(int x, int y, const char *str_utf8, BYTE col); +extern SDL_Rect sdl_drawString(int x, int y, const char *str_utf8, uint8_t col); extern void sdl_copyArea(int sx,int sy, int w, int h, int dx, int dy); -extern void sdl_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, BYTE sp); -extern void sdl_wrapColor(int sx, int sy, int w, int h, BYTE cl, int rate); +extern void sdl_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, uint8_t sp); +extern void sdl_wrapColor(int sx, int sy, int w, int h, uint8_t cl, int rate); extern void sdl_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mirror); extern void sdl_drawImage8_fromData(cgdata *cg, int x, int y, int sprite_color); extern void sdl_drawImage16_fromData(cgdata *cg, int x, int y, int brightness, bool alpha_blend); @@ -95,7 +95,7 @@ void sdl_effect_finish(struct sdl_effect *eff); extern void sdl_setJoyDeviceIndex(int index); extern void sdl_setCursorLocation(int x, int y); extern void sdl_setCursorType(int type); -extern boolean sdl_cursorNew(BYTE* data, int no, CursorImage *cursorImage, TCursorDirEntry *cursordirentry); +extern boolean sdl_cursorNew(uint8_t* data, int no, CursorImage *cursorImage, TCursorDirEntry *cursordirentry); extern int sdl_getKeyInfo(); extern int sdl_getMouseInfo(MyPoint *p); extern void sdl_getWheelInfo(int *forward, int *back); diff --git a/src/sdl_cursor.c b/src/sdl_cursor.c index c8bc7f6..9334725 100644 --- a/src/sdl_cursor.c +++ b/src/sdl_cursor.c @@ -96,12 +96,12 @@ void sdl_cursor_init(void) { cursor[CURSOR_WAIT] = init_system_cursor(cursor_busy); } -boolean sdl_cursorNew(BYTE* data, int no, CursorImage *cursorImage, TCursorDirEntry *cursordirentry) { +boolean sdl_cursorNew(uint8_t* data, int no, CursorImage *cursorImage, TCursorDirEntry *cursordirentry) { int xormasklen, andmasklen, xornum; int i, j; int h = 0; - BYTE *buf1, *buf2, *buf3, *buf4; + uint8_t *buf1, *buf2, *buf3, *buf4; xornum = (cursordirentry->bWidth * cursordirentry->bHeight); xormasklen = (xornum * cursorImage->icHeader.biBitCount) / 8; @@ -111,10 +111,10 @@ boolean sdl_cursorNew(BYTE* data, int no, CursorImage *cursorImage, TCursorDirEn cursorImage->xormasklen = xormasklen; cursorImage->andmasklen = andmasklen; - buf1 = malloc(sizeof(BYTE) * xornum); - buf2 = malloc(sizeof(BYTE) * xornum); - buf3 = malloc(sizeof(BYTE) * xornum); - buf4 = malloc(sizeof(BYTE) * xornum); + buf1 = malloc(sizeof(uint8_t) * xornum); + buf2 = malloc(sizeof(uint8_t) * xornum); + buf3 = malloc(sizeof(uint8_t) * xornum); + buf4 = malloc(sizeof(uint8_t) * xornum); memcpy(buf1, data, min(xormasklen, xornum)); data += xormasklen; diff --git a/src/sdl_draw.c b/src/sdl_draw.c index 89a3120..4a7f6b5 100644 --- a/src/sdl_draw.c +++ b/src/sdl_draw.c @@ -49,7 +49,7 @@ static void sdl_pal_check(void) { } } -static Uint32 palette_color(BYTE c) { +static Uint32 palette_color(uint8_t c) { if (sdl_dib->format->BitsPerPixel == 8) return c; return SDL_MapRGB(sdl_dib->format, sdl_col[c].r, sdl_col[c].g, sdl_col[c].b); @@ -129,7 +129,7 @@ void sdl_setPalette(Palette256 *pal, int first, int count) { } /* 矩形の描画 */ -void sdl_drawRectangle(int x, int y, int w, int h, BYTE c) { +void sdl_drawRectangle(int x, int y, int w, int h, uint8_t c) { sdl_pal_check(); Uint32 col = palette_color(c); @@ -147,14 +147,14 @@ void sdl_drawRectangle(int x, int y, int w, int h, BYTE c) { } /* 矩形塗りつぶし */ -void sdl_fillRectangle(int x, int y, int w, int h, BYTE c) { +void sdl_fillRectangle(int x, int y, int w, int h, uint8_t c) { sdl_pal_check(); SDL_Rect rect = {x, y, w, h}; SDL_FillRect(sdl_dib, &rect, palette_color(c)); } -void sdl_fillRectangleRGB(int x, int y, int w, int h, BYTE r, BYTE g, BYTE b) { +void sdl_fillRectangleRGB(int x, int y, int w, int h, uint8_t r, uint8_t g, uint8_t b) { if (sdl_dib->format->BitsPerPixel == 8) return; @@ -162,7 +162,7 @@ void sdl_fillRectangleRGB(int x, int y, int w, int h, BYTE r, BYTE g, BYTE b) { SDL_FillRect(sdl_dib, &rect, SDL_MapRGB(sdl_dib->format, r, g, b)); } -void sdl_fillCircle(int left, int top, int diameter, BYTE c) { +void sdl_fillCircle(int left, int top, int diameter, uint8_t c) { diameter &= ~1; if (diameter <= 0) return; @@ -204,7 +204,7 @@ void sdl_copyArea(int sx, int sy, int w, int h, int dx, int dy) { /* * dib に指定のパレット sp を抜いてコピー */ -void sdl_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, BYTE sp) { +void sdl_copyAreaSP(int sx, int sy, int w, int h, int dx, int dy, uint8_t sp) { sdl_pal_check(); Uint32 col = sp; @@ -235,7 +235,7 @@ void sdl_drawImage8_fromData(cgdata *cg, int dx, int dy, int sprite_color) { if (sdl_dib->format->BitsPerPixel > 8 && cg->pal) { int i, i_st = 0, i_end = 256; SDL_Color *c = s->format->palette->colors; - BYTE *r = cg->pal->red, *g = cg->pal->green, *b = cg->pal->blue; + uint8_t *r = cg->pal->red, *g = cg->pal->green, *b = cg->pal->blue; if (cg->type == ALCG_VSP) { i_st = (cg->vsp_bank << 4); @@ -262,7 +262,7 @@ void sdl_drawImage8_fromData(cgdata *cg, int dx, int dy, int sprite_color) { } /* 直線描画 */ -void sdl_drawLine(int x1, int y1, int x2, int y2, BYTE c) { +void sdl_drawLine(int x1, int y1, int x2, int y2, uint8_t c) { sdl_pal_check(); SDL_Renderer *renderer = SDL_CreateSoftwareRenderer(sdl_dib); @@ -271,13 +271,13 @@ void sdl_drawLine(int x1, int y1, int x2, int y2, BYTE c) { SDL_DestroyRenderer(renderer); } -#define TYPE ___BYTE +#define TYPE uint8_t #include "flood.h" #undef TYPE -#define TYPE ___WORD +#define TYPE uint16_t #include "flood.h" #undef TYPE -#define TYPE ___DWORD +#define TYPE uint32_t #include "flood.h" #undef TYPE @@ -286,11 +286,11 @@ SDL_Rect sdl_floodFill(int x, int y, int c) { switch (sdl_dib->format->BytesPerPixel) { case 1: - return sdl_floodFill___BYTE(x, y, col); + return sdl_floodFill_uint8_t(x, y, col); case 2: - return sdl_floodFill___WORD(x, y, col); + return sdl_floodFill_uint16_t(x, y, col); case 4: - return sdl_floodFill___DWORD(x, y, col); + return sdl_floodFill_uint32_t(x, y, col); default: WARNING("sdl_floodFill: unsupported DIB format"); return (SDL_Rect){}; @@ -317,7 +317,7 @@ int sdl_nearest_color(int r, int g, int b) { return col; } -SDL_Rect sdl_drawString(int x, int y, const char *str_utf8, BYTE col) { +SDL_Rect sdl_drawString(int x, int y, const char *str_utf8, uint8_t col) { sdl_pal_check(); return font_draw_glyph(x, y, str_utf8, col); } @@ -325,7 +325,7 @@ SDL_Rect sdl_drawString(int x, int y, const char *str_utf8, BYTE col) { /* * 指定範囲にパレット col を rate の割合で重ねる CK1 */ -void sdl_wrapColor(int sx, int sy, int w, int h, BYTE c, int rate) { +void sdl_wrapColor(int sx, int sy, int w, int h, uint8_t c, int rate) { SDL_Surface *s = SDL_CreateRGBSurface(0, w, h, sdl_dib->format->BitsPerPixel, 0, 0, 0, 0); assert(s->format->BitsPerPixel > 8); diff --git a/src/sdl_image.c b/src/sdl_image.c index 4b9c28f..2894bc2 100644 --- a/src/sdl_image.c +++ b/src/sdl_image.c @@ -99,14 +99,14 @@ void sdl_scaledCopyArea(int sx, int sy, int sw, int sh, int dx, int dy, int dw, } switch(dst->format->BytesPerPixel) { case 1: - sccp(BYTE); + sccp(uint8_t); break; case 2: - sccp(WORD); + sccp(uint16_t); break; case 3: { - BYTE *p_ss=(BYTE *)(src->pixels+sx*src->format->BytesPerPixel+sy*src->pitch); - BYTE *p_src=p_ss,*p_dd=ss->pixels, *p_dst; + uint8_t *p_ss=(uint8_t *)(src->pixels+sx*src->format->BytesPerPixel+sy*src->pitch); + uint8_t *p_src=p_ss,*p_dd=ss->pixels, *p_dst; for (y = 0; y < dh; y++) { p_src = p_ss + col[y] * src->pitch; p_dst = p_dd + y * ss->pitch; @@ -144,10 +144,10 @@ void sdl_drawImage16_fromData(cgdata *cg, int dx, int dy, int brightness, bool a SDL_Surface *s; if (cg->alpha && alpha_blend) { - unsigned short *p_src = (WORD *)cg->pic; - DWORD *p_ds, *p_dst; - BYTE *a_src = cg->alpha; - BYTE *adata = GETOFFSET_ALPHA(sdl_dibinfo, dx, dy); + unsigned short *p_src = (uint16_t *)cg->pic; + uint32_t *p_ds, *p_dst; + uint8_t *a_src = cg->alpha; + uint8_t *adata = GETOFFSET_ALPHA(sdl_dibinfo, dx, dy); int x, y, l; s = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, SDL_PIXELFORMAT_ARGB8888); @@ -167,8 +167,8 @@ void sdl_drawImage16_fromData(cgdata *cg, int dx, int dy, int brightness, bool a s = SDL_CreateRGBSurfaceWithFormatFrom( cg->pic, cg->width, cg->height, 16, cg->width * 2, SDL_PIXELFORMAT_RGB565); if (cg->alpha) { - BYTE *a_src = cg->alpha; - BYTE *adata = GETOFFSET_ALPHA(sdl_dibinfo, dx, dy); + uint8_t *a_src = cg->alpha; + uint8_t *adata = GETOFFSET_ALPHA(sdl_dibinfo, dx, dy); for (int i = 0; i < h; i++) { memcpy(adata, a_src, w); @@ -218,8 +218,8 @@ void sdl_shadow_init(void) { } void sdl_copyAreaSP16_shadow(int sx, int sy, int w, int h, int dx, int dy, int lv) { - BYTE *adata = GETOFFSET_ALPHA(sdl_dibinfo, sx, sy); - BYTE *p_src, *p_dst, *p_ds; + uint8_t *adata = GETOFFSET_ALPHA(sdl_dibinfo, sx, sy); + uint8_t *p_src, *p_dst, *p_ds; SDL_Surface *s = SDL_CreateRGBSurfaceWithFormat(0, w, h, 32, SDL_PIXELFORMAT_ARGB8888); int x, y; @@ -299,7 +299,7 @@ void sdl_copy_to_alpha(int sx, int sy, int w, int h, int dx, int dy, ALPHA_DIB_C * dib のピクセル情報を取得 */ void sdl_getPixel(int x, int y, Palette *cell) { - BYTE *p = PIXEL_AT(sdl_dib, x, y); + uint8_t *p = PIXEL_AT(sdl_dib, x, y); if (sdl_dib->format->BitsPerPixel == 8) { cell->pixel = *p; } else { diff --git a/src/utfsjis.c b/src/utfsjis.c index 8f0e52c..e1ec000 100644 --- a/src/utfsjis.c +++ b/src/utfsjis.c @@ -45,9 +45,9 @@ char* codeconv(CharacterEncoding tocode, return NULL; } -BYTE *sjis2utf(const BYTE *src) { - BYTE* dst = malloc(strlen(src) * 3 + 1); - BYTE* dstp = dst; +uint8_t *sjis2utf(const uint8_t *src) { + uint8_t* dst = malloc(strlen(src) * 3 + 1); + uint8_t* dstp = dst; while (*src) { if (*src <= 0x7f) { @@ -96,9 +96,9 @@ static int unicode_to_sjis(int u) { return 0; } -BYTE *utf2sjis(const BYTE *src) { - BYTE* dst = malloc(strlen(src) + 1); - BYTE* dstp = dst; +uint8_t *utf2sjis(const uint8_t *src) { + uint8_t* dst = malloc(strlen(src) + 1); + uint8_t* dstp = dst; while (*src) { if (*src <= 0x7f) { @@ -136,7 +136,7 @@ BYTE *utf2sjis(const BYTE *src) { } /* src 内に半角カナもしくはASCII文字があるかどうか */ -boolean sjis_has_hankaku(const BYTE *src) { +boolean sjis_has_hankaku(const uint8_t *src) { while(*src) { if (CHECKSJIS1BYTE(*src)) { src++; @@ -149,7 +149,7 @@ boolean sjis_has_hankaku(const BYTE *src) { } /* src 内に 全角文字があるかどうか */ -boolean sjis_has_zenkaku(const BYTE *src) { +boolean sjis_has_zenkaku(const uint8_t *src) { while(*src) { if (CHECKSJIS1BYTE(*src)) { return TRUE; diff --git a/src/utfsjis.h b/src/utfsjis.h index c771d54..503bf13 100644 --- a/src/utfsjis.h +++ b/src/utfsjis.h @@ -44,10 +44,10 @@ extern char* codeconv(CharacterEncoding tocode, CharacterEncoding fromcode, const char *str); -extern BYTE* sjis2utf(const BYTE *src); -extern BYTE* utf2sjis(const BYTE *src); -extern boolean sjis_has_hankaku(const BYTE *src); -extern boolean sjis_has_zenkaku(const BYTE *src); +extern uint8_t* sjis2utf(const uint8_t *src); +extern uint8_t* utf2sjis(const uint8_t *src); +extern boolean sjis_has_hankaku(const uint8_t *src); +extern boolean sjis_has_zenkaku(const uint8_t *src); extern int utf8_next_codepoint(const char **msg); extern char *advance_char(const char *s, CharacterEncoding e); diff --git a/src/vsp.c b/src/vsp.c index f5b1471..7b91c44 100644 --- a/src/vsp.c +++ b/src/vsp.c @@ -41,16 +41,16 @@ /* * static methods */ -static vsp_header *extract_header(BYTE *b); -static void getpal(Palette256 *pal, BYTE *b); -static void extract(vsp_header *vsp, BYTE *pic, BYTE *b); +static vsp_header *extract_header(uint8_t *b); +static void getpal(Palette256 *pal, uint8_t *b); +static void extract(vsp_header *vsp, uint8_t *pic, uint8_t *b); /* * Get information from cg header * b: raw data (pointer to header) * return: acquired vsp information object */ -static vsp_header *extract_header(BYTE *b) { +static vsp_header *extract_header(uint8_t *b) { vsp_header *vsp = malloc(sizeof(vsp_header)); vsp->vspX0 = LittleEndian_getW(b, 0); @@ -69,7 +69,7 @@ static vsp_header *extract_header(BYTE *b) { * pal: palette to be stored * b : raw data (pointer to palette) */ -static void getpal(Palette256 *pal, BYTE *b) { +static void getpal(Palette256 *pal, uint8_t *b) { for (int i = 0; i < 16; i++) { pal->blue[i] = b[i * 3 + 0] * 17; pal->red[i] = b[i * 3 + 1] * 17; @@ -83,16 +83,16 @@ static void getpal(Palette256 *pal, BYTE *b) { * pic: pixel to be stored * b : raw data (pointer to pixel) */ -static void extract(vsp_header *vsp, BYTE *pic, BYTE *b) { +static void extract(vsp_header *vsp, uint8_t *pic, uint8_t *b) { int c0; - BYTE b0, b1, b2, b3, mask = 0; - BYTE *bt; + uint8_t b0, b1, b2, b3, mask = 0; + uint8_t *bt; int i, l, x, y, pl, loc; // Extraction buffers. - BYTE *buf = malloc(vsp->vspYW * 8); - BYTE *bc[4]; - BYTE *bp[4]; + uint8_t *buf = malloc(vsp->vspYW * 8); + uint8_t *bc[4]; + uint8_t *bp[4]; for (int i = 0; i < 4; i++) { bc[i] = buf + vsp->vspYW * (i * 2); bp[i] = buf + vsp->vspYW * (i * 2 + 1); @@ -174,7 +174,7 @@ static void extract(vsp_header *vsp, BYTE *pic, BYTE *b) { * data: raw data (pointer to data top) * return: TRUE if data is vsp */ -boolean vsp_checkfmt(BYTE *data) { +boolean vsp_checkfmt(uint8_t *data) { int x0 = LittleEndian_getW(data, 0); int y0 = LittleEndian_getW(data, 2); int w = LittleEndian_getW(data, 4) - x0; @@ -192,7 +192,7 @@ boolean vsp_checkfmt(BYTE *data) { * data: raw data (pointer to data top) * return: extracted image data and information */ -cgdata *vsp_extract(BYTE *data) { +cgdata *vsp_extract(uint8_t *data) { cgdata *cg = calloc(1, sizeof(cgdata)); vsp_header *vsp = extract_header(data); @@ -200,7 +200,7 @@ cgdata *vsp_extract(BYTE *data) { getpal(cg->pal, data + vsp->vspPp); /* +10: margin for broken cg */ - cg->pic = malloc(sizeof(BYTE) * ((vsp->vspXW * 8 + 10) * (vsp->vspYW + 10))); + cg->pic = malloc(sizeof(uint8_t) * ((vsp->vspXW * 8 + 10) * (vsp->vspYW + 10))); extract(vsp, cg->pic, data + vsp->vspDp); cg->type = ALCG_VSP; diff --git a/src/vsp.h b/src/vsp.h index ef2cd90..b64c541 100644 --- a/src/vsp.h +++ b/src/vsp.h @@ -45,7 +45,7 @@ typedef struct { * 16 palltes into pal[16] ~ pal[31]. */ -extern boolean vsp_checkfmt(BYTE *data); -extern cgdata *vsp_extract(BYTE *data); +extern boolean vsp_checkfmt(uint8_t *data); +extern cgdata *vsp_extract(uint8_t *data); #endif /* !__VSP__ */ diff --git a/src/webp.c b/src/webp.c index cd3147a..f1294d7 100644 --- a/src/webp.c +++ b/src/webp.c @@ -25,7 +25,7 @@ #include "ald_manager.h" #include "LittleEndian.h" -boolean webp_checkfmt(BYTE *data) { +boolean webp_checkfmt(uint8_t *data) { if (data[0] != 'R' || data[1] != 'I' || data[2] != 'F' || data[3] != 'F') return FALSE; if (data[8] != 'W' || data[9] != 'E' || data[10] != 'B' || data[11] != 'P') @@ -115,7 +115,7 @@ static void rgba_to_rgb_and_alpha(uint8_t *rgba, uint8_t *rgb, uint8_t *alpha, i } } -cgdata *webp_extract(BYTE *data, size_t size) { +cgdata *webp_extract(uint8_t *data, size_t size) { int width, height, has_alpha; uint8_t *rgba = webp_load(data, size, &width, &height, &has_alpha); if (!rgba) { diff --git a/src/webp.h b/src/webp.h index a0f9824..66b62dc 100644 --- a/src/webp.h +++ b/src/webp.h @@ -22,7 +22,7 @@ #include "cg.h" -boolean webp_checkfmt(BYTE *data); -cgdata *webp_extract(BYTE *data, size_t size); +boolean webp_checkfmt(uint8_t *data); +cgdata *webp_extract(uint8_t *data, size_t size); #endif // __WEBP_H__