diff --git a/engines/chamber/anim.cpp b/engines/chamber/anim.cpp index fddd60a1aac..7d07027fe97 100644 --- a/engines/chamber/anim.cpp +++ b/engines/chamber/anim.cpp @@ -31,29 +31,29 @@ namespace Chamber { -unsigned char *anima_end_ofs; +byte *anima_end_ofs; -unsigned char last_anim_y = 0; -unsigned char last_anim_x = 0; -unsigned char anim_shift_y = 0; -unsigned char anim_shift_x = 0; -unsigned char last_anim_height; -unsigned char last_anim_width; -unsigned char anim_cycle; -unsigned char anim_flags; -unsigned char anim_use_dot_effect; -unsigned int anim_draw_delay; -unsigned char dot_effect_step; -unsigned int dot_effect_delay; +byte last_anim_y = 0; +byte last_anim_x = 0; +byte anim_shift_y = 0; +byte anim_shift_x = 0; +byte last_anim_height; +byte last_anim_width; +byte anim_cycle; +byte anim_flags; +byte anim_use_dot_effect; +uint16 anim_draw_delay; +byte dot_effect_step; +uint16 dot_effect_delay; -extern unsigned short cpu_speed_delay; +extern uint16 cpu_speed_delay; -extern unsigned char *SeekToEntry(unsigned char *bank, unsigned int num, unsigned char **end); -extern void LoadLutinSprite(unsigned int lutidx); +extern byte *SeekToEntry(byte *bank, uint16 num, byte **end); +extern void LoadLutinSprite(uint16 lutidx); -void GetScratchBuffer(unsigned char mode) { - unsigned char *buffer = scratch_mem2; - unsigned int offs = 0; +void GetScratchBuffer(byte mode) { + byte *buffer = scratch_mem2; + uint16 offs = 0; if (mode & 0x80) offs += 3200; if (mode & 0x40) @@ -61,16 +61,16 @@ void GetScratchBuffer(unsigned char mode) { lutin_mem = buffer + offs; } -void AnimLoadSprite(unsigned char **panim) { - unsigned char mode; - unsigned char index; +void AnimLoadSprite(byte **panim) { + byte mode; + byte index; mode = *((*panim)++); index = *((*panim)++); GetScratchBuffer(mode); LoadLutinSprite(index); } -void ClipSprite(unsigned char *x, unsigned char *y, unsigned char *sprw, unsigned char *sprh, unsigned char **sprite, signed char dx, signed char dy) { +void ClipSprite(byte *x, byte *y, byte *sprw, byte *sprh, byte **sprite, int8 dx, int8 dy) { if (anim_flags == 7) return; if (anim_flags & 4) { @@ -106,20 +106,20 @@ void ClipSprite(unsigned char *x, unsigned char *y, unsigned char *sprw, unsigne } } -void CopyScreenBlockWithDotEffect(unsigned char *source, unsigned char x, unsigned char y, unsigned char width, unsigned char height, unsigned char *target) { - unsigned int offs; - unsigned int xx = x * 4; - unsigned int ww = width * 4; - unsigned int cur_image_end = ww * height; +void CopyScreenBlockWithDotEffect(byte *source, byte x, byte y, byte width, byte height, byte *target) { + uint16 offs; + uint16 xx = x * 4; + uint16 ww = width * 4; + uint16 cur_image_end = ww * height; for (offs = 0; offs != cur_image_end;) { - unsigned char mask = 0xC0 >> (((xx + offs % ww) % 4) * 2); - unsigned int ofs = CGA_CalcXY(xx + offs % ww, y + offs / ww); + byte mask = 0xC0 >> (((xx + offs % ww) % 4) * 2); + uint16 ofs = CGA_CalcXY(xx + offs % ww, y + offs / ww); target[ofs] = (target[ofs] & ~mask) | (source[ofs] & mask); if (dot_effect_delay / 4 != 0) { - unsigned int i; + uint16 i; for (i = 0; i < dot_effect_delay / 4; i++) ; /*TODO: weak delay*/ } @@ -129,10 +129,10 @@ void CopyScreenBlockWithDotEffect(unsigned char *source, unsigned char x, unsign } } -void AnimDrawSprite(unsigned char x, unsigned char y, unsigned char sprw, unsigned char sprh, unsigned char *pixels, unsigned int pitch) { - unsigned int delay, delay2; - unsigned char ex, ey, updx, updy, updw, updh; - unsigned int ofs = CGA_CalcXY_p(x, y); +void AnimDrawSprite(byte x, byte y, byte sprw, byte sprh, byte *pixels, uint16 pitch) { + uint16 delay, delay2; + byte ex, ey, updx, updy, updw, updh; + uint16 ofs = CGA_CalcXY_p(x, y); CGA_BackupImage(backbuffer, ofs, sprw, sprh, sprit_load_buffer); CGA_BlitSprite(pixels, pitch, sprw, sprh, backbuffer, ofs); ex = x + sprw; @@ -179,10 +179,10 @@ void AnimUndrawSprite(void) { last_anim_height = 0; } -void PlayAnimCore(unsigned char **panim) { - unsigned char mode; - unsigned int count, count2; - unsigned char *pframe; +void PlayAnimCore(byte **panim) { + byte mode; + uint16 count, count2; + byte *pframe; mode = *((*panim)++); anim_flags = mode & 7; count = mode >> 3; @@ -195,11 +195,11 @@ void PlayAnimCore(unsigned char **panim) { dot_effect_delay = 500; count2 = mode & 7; while (count2--) { - unsigned char *sprite; - unsigned char sprw, sprh; - unsigned char x, y; - signed char dx, dy; - unsigned int pitch; + byte *sprite; + byte sprw, sprh; + byte x, y; + int8 dx, dy; + uint16 pitch; mode = *pframe++; GetScratchBuffer(mode); dy = mode & 7; @@ -238,49 +238,49 @@ end: *panim += mode & 7; } -void Anim1(unsigned char **panim) { +void Anim1(byte **panim) { anim_cycle = 0xFF; anim_use_dot_effect = 0; PlayAnimCore(panim); } -void Anim2(unsigned char **panim) { +void Anim2(byte **panim) { anim_cycle = 1; anim_use_dot_effect = 0; PlayAnimCore(panim); } -void Anim3(unsigned char **panim) { +void Anim3(byte **panim) { anim_cycle = 1; anim_use_dot_effect = 0; PlayAnimCore(panim); } -void Anim4(unsigned char **panim) { +void Anim4(byte **panim) { anim_cycle = last_anim_width - 1; anim_use_dot_effect = 0; PlayAnimCore(panim); } -void Anim5(unsigned char **panim) { +void Anim5(byte **panim) { anim_cycle = last_anim_width - 1; anim_use_dot_effect = 0; PlayAnimCore(panim); } -void Anim6(unsigned char **panim) { +void Anim6(byte **panim) { anim_cycle = last_anim_height; anim_use_dot_effect = 0; PlayAnimCore(panim); } -void Anim7(unsigned char **panim) { +void Anim7(byte **panim) { anim_cycle = 0xFF; anim_use_dot_effect = 1; PlayAnimCore(panim); } -typedef void (*animhandler_t)(unsigned char **panim); +typedef void (*animhandler_t)(byte **panim); animhandler_t anim_handlers[] = { AnimLoadSprite, @@ -293,9 +293,9 @@ animhandler_t anim_handlers[] = { Anim7 }; -void PlayAnim(unsigned char index, unsigned char x, unsigned char y) { - unsigned char sound; - unsigned char *panim; +void PlayAnim(byte index, byte x, byte y) { + byte sound; + byte *panim; last_anim_width = 0; last_anim_height = 0; @@ -304,7 +304,7 @@ void PlayAnim(unsigned char index, unsigned char x, unsigned char y) { panim = SeekToEntry(anima_data, index - 1, &anima_end_ofs); while (panim != anima_end_ofs) { - unsigned char mode = *panim; + byte mode = *panim; switch (mode) { case 0xFE: /*set shift*/ panim++; diff --git a/engines/chamber/anim.h b/engines/chamber/anim.h index c9b5d746dbf..5efb915295f 100644 --- a/engines/chamber/anim.h +++ b/engines/chamber/anim.h @@ -25,11 +25,11 @@ namespace Chamber { -void PlayAnim(unsigned char index, unsigned char x, unsigned char y); -void CopyScreenBlockWithDotEffect(unsigned char *source, unsigned char x, unsigned char y, unsigned char width, unsigned char height, unsigned char *target); +void PlayAnim(byte index, byte x, byte y); +void CopyScreenBlockWithDotEffect(byte *source, byte x, byte y, byte width, byte height, byte *target); -extern unsigned char dot_effect_step; -extern unsigned int dot_effect_delay; +extern byte dot_effect_step; +extern uint16 dot_effect_delay; } // End of namespace Chamber diff --git a/engines/chamber/bkbuff.cpp b/engines/chamber/bkbuff.cpp index d533490466c..0127c296f4c 100644 --- a/engines/chamber/bkbuff.cpp +++ b/engines/chamber/bkbuff.cpp @@ -25,7 +25,7 @@ namespace Chamber { -unsigned char backbuffer[0x4000]; +byte backbuffer[0x4000]; } // End of namespace Chamber diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp index 65032805ed4..e5de7c8ca00 100644 --- a/engines/chamber/cga.cpp +++ b/engines/chamber/cga.cpp @@ -30,23 +30,23 @@ namespace Chamber { -extern unsigned char backbuffer[0x4000]; +extern byte backbuffer[0x4000]; byte CGA_SCREENBUFFER[0x4000]; byte scrbuffer[320*200]; -unsigned char carpc_data[RES_CARPC_MAX]; +byte carpc_data[RES_CARPC_MAX]; -extern unsigned char *scratch_mem2; +extern byte *scratch_mem2; -unsigned char char_draw_coords_x; -unsigned char char_draw_coords_y; -unsigned char *char_xlat_table; -unsigned char string_ended; -unsigned char char_draw_max_width; -unsigned char char_draw_max_height; +byte char_draw_coords_x; +byte char_draw_coords_y; +byte *char_xlat_table; +byte string_ended; +byte char_draw_max_width; +byte char_draw_max_height; /*pixels order reverse in a byte*/ -unsigned char cga_pixel_flip[256] = { +byte cga_pixel_flip[256] = { 0, 64, 128, 192, 16, 80, 144, 208, 32, 96, 160, 224, 48, 112, 176, 240, 4, 68, 132, 196, 20, 84, 148, 212, 36, 100, 164, 228, 52, 116, 180, 244, 8, 72, 136, 200, @@ -95,16 +95,16 @@ void SwitchToTextMode(void) { void WaitVBlank(void) { } -void CGA_ColorSelect(unsigned char csel) { +void CGA_ColorSelect(byte csel) { warning("STUB: CGA_ColorSelect(%d)", csel); //outportb(0x3D9, csel); } -void CGA_blitToScreen(int dx, int dy, int w, int h) { +void CGA_blitToScreen(int16 dx, int16 dy, int16 w, int16 h) { dx = dy = 0; w = 320; h = 200; // Align x by 4 - int align = dx & 0x3; + int16 align = dx & 0x3; dx -= align; w += align; @@ -117,14 +117,14 @@ void CGA_blitToScreen(int dx, int dy, int w, int h) { w = (w + 3) / 4; - for (int y = 0; y < h; y++) { + for (int16 y = 0; y < h; y++) { byte *src = CGA_SCREENBUFFER + CGA_CalcXY(dx, dy + y); byte *dst = scrbuffer + (y + dy) * 320 + dx; - for (int x = 0; x < w; x++) { + for (int16 x = 0; x < w; x++) { byte colors = *src++; - for (int c = 0; c < 4; c++) { + for (int16 c = 0; c < 4; c++) { byte color = (colors & 0xC0) >> 6; colors <<= 2; @@ -137,9 +137,9 @@ void CGA_blitToScreen(int dx, int dy, int w, int h) { g_system->updateScreen(); } -void CGA_blitToScreen(int ofs, int w, int h) { - int dy = ofs / 80; - int dx = (ofs % 80) * 4; +void CGA_blitToScreen(int16 ofs, int16 w, int16 h) { + int16 dy = ofs / 80; + int16 dx = (ofs % 80) * 4; CGA_blitToScreen(dx, dy, w, h); } @@ -156,9 +156,9 @@ void CGA_RealBufferToBackFull(void) { /*Copy interlaced screen data to another screen*/ /*NB! w is in bytes*/ -void CGA_CopyScreenBlock(unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs) { - uint oh = h; - uint oofs = ofs; +void CGA_CopyScreenBlock(byte *source, uint16 w, uint16 h, byte *target, uint16 ofs) { + uint16 oh = h; + uint16 oofs = ofs; while (h--) { memcpy(target + ofs, source + ofs, w); ofs ^= CGA_ODD_LINES_OFS; @@ -174,13 +174,13 @@ void CGA_CopyScreenBlock(unsigned char *source, unsigned int w, unsigned int h, Flip screen and backbuffer */ void CGA_SwapRealBackBuffer(void) { - unsigned int i; - unsigned short *s, *d; + uint16 i; + uint16 *s, *d; WaitVBlank(); - s = (unsigned short *)CGA_SCREENBUFFER; - d = (unsigned short *)backbuffer; + s = (uint16 *)CGA_SCREENBUFFER; + d = (uint16 *)backbuffer; for (i = 0; i < sizeof(backbuffer) / 2; i++) { - unsigned short t = *s; + uint16 t = *s; *s++ = *d; *d++ = t; } @@ -192,12 +192,12 @@ void CGA_SwapRealBackBuffer(void) { /* Copy current screen's pixels to scratch mem, put new pixels to screen */ -void CGA_SwapScreenRect(unsigned char *pixels, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) { - unsigned char *old = scratch_mem2; - uint oh = h; - uint oofs = ofs; +void CGA_SwapScreenRect(byte *pixels, uint16 w, uint16 h, byte *screen, uint16 ofs) { + byte *old = scratch_mem2; + uint16 oh = h; + uint16 oofs = ofs; while (h--) { - unsigned int i; + uint16 i; for (i = 0; i < w; i++) { *old++ = screen[ofs + i]; screen[ofs + i] = *pixels++; @@ -216,7 +216,7 @@ Calc screen offset from normal pixel coordinates Out: screen offset */ -unsigned int CGA_CalcXY(unsigned int x, unsigned int y) { +uint16 CGA_CalcXY(uint16 x, uint16 y) { return CGA_CalcXY_p(x / 4, y); } @@ -225,8 +225,8 @@ Calc screen offset from packed pixel coordinates Out: screen offset */ -unsigned int CGA_CalcXY_p(unsigned int x, unsigned int y) { - unsigned int ofs = 0; +uint16 CGA_CalcXY_p(uint16 x, uint16 y) { + uint16 ofs = 0; if (y & 1) ofs += CGA_ODD_LINES_OFS; ofs += CGA_BYTES_PER_LINE * (y / 2); @@ -239,9 +239,9 @@ backup screen rect to a buffer Out: next buffer ptr */ -unsigned char *CGA_BackupImage(unsigned char *screen, unsigned int ofs, unsigned int w, unsigned int h, unsigned char *buffer) { - *(unsigned char *)(buffer + 0) = h; - *(unsigned char *)(buffer + 1) = w; +byte *CGA_BackupImage(byte *screen, uint16 ofs, uint16 w, uint16 h, byte *buffer) { + *(byte *)(buffer + 0) = h; + *(byte *)(buffer + 1) = w; *(uint16 *)(buffer + 2) = ofs; buffer += 4; while (h--) { @@ -254,7 +254,7 @@ unsigned char *CGA_BackupImage(unsigned char *screen, unsigned int ofs, unsigned return buffer; } -unsigned char *CGA_BackupImageReal(unsigned int ofs, unsigned int w, unsigned int h) { +byte *CGA_BackupImageReal(uint16 ofs, uint16 w, uint16 h) { return CGA_BackupImage(CGA_SCREENBUFFER, ofs, w, h, scratch_mem2); } @@ -262,10 +262,10 @@ unsigned char *CGA_BackupImageReal(unsigned int ofs, unsigned int w, unsigned in Blit progressive image to interlaced screen buffer NB! width and pixelswidth specify a number of bytes, not count of pixels */ -void CGA_Blit(unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) { +void CGA_Blit(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs) { byte *src = pixels; - uint oofs = ofs; - for (int y = 0; y < h; y++) { + uint16 oofs = ofs; + for (int16 y = 0; y < h; y++) { memcpy(screen + ofs, src, w); src += pw; ofs ^= CGA_ODD_LINES_OFS; @@ -281,14 +281,14 @@ void CGA_Blit(unsigned char *pixels, unsigned int pw, unsigned int w, unsigned i Blit progressive image to interlaced screen buffer, then wait for VBlank NB! width and pixelswidth specify a number of bytes, not count of pixels */ -void CGA_BlitAndWait(unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) { +void CGA_BlitAndWait(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs) { CGA_Blit(pixels, pw, w, h, screen, ofs); WaitVBlank(); } -void CGA_Fill(unsigned char pixel, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) { - uint oofs = ofs; - for (int y = 0; y < h; y++) { +void CGA_Fill(byte pixel, uint16 w, uint16 h, byte *screen, uint16 ofs) { + uint16 oofs = ofs; + for (int16 y = 0; y < h; y++) { memset(screen + ofs, pixel, w); ofs ^= CGA_ODD_LINES_OFS; if ((ofs & CGA_ODD_LINES_OFS) == 0) @@ -299,7 +299,7 @@ void CGA_Fill(unsigned char pixel, unsigned int w, unsigned int h, unsigned char CGA_blitToScreen(oofs, w * 4, h); } -void CGA_FillAndWait(unsigned char pixel, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) { +void CGA_FillAndWait(byte pixel, uint16 w, uint16 h, byte *screen, uint16 ofs) { CGA_Fill(pixel, w, h, screen, ofs); WaitVBlank(); } @@ -307,15 +307,15 @@ void CGA_FillAndWait(unsigned char pixel, unsigned int w, unsigned int h, unsign /* Restore saved image to target screen buffer */ -void CGA_RestoreImage(unsigned char *buffer, unsigned char *target) { +void CGA_RestoreImage(byte *buffer, byte *target) { uint16 w, h; uint16 ofs; if (!buffer) return; - h = *(unsigned char *)(buffer + 0); - w = *(unsigned char *)(buffer + 1); + h = *(byte *)(buffer + 0); + w = *(byte *)(buffer + 1); ofs = *(uint16 *)(buffer + 2); buffer += 4; /*TODO: fix me for large int*/ @@ -325,22 +325,22 @@ void CGA_RestoreImage(unsigned char *buffer, unsigned char *target) { /* Restore saved image from scratch mem to target screen buffer */ -void CGA_RestoreBackupImage(unsigned char *target) { +void CGA_RestoreBackupImage(byte *target) { CGA_RestoreImage(scratch_mem2, target); } /* Copy image's real screen data to backbuffer */ -void CGA_RefreshImageData(unsigned char *buffer) { - unsigned int w, h; - unsigned int ofs; +void CGA_RefreshImageData(byte *buffer) { + uint16 w, h; + uint16 ofs; if (!buffer) return; - h = *(unsigned char *)(buffer + 0); - w = *(unsigned char *)(buffer + 1); + h = *(byte *)(buffer + 0); + w = *(byte *)(buffer + 1); ofs = *(uint16 *)(buffer + 2); CGA_CopyScreenBlock(CGA_SCREENBUFFER, w, h, backbuffer, ofs); @@ -350,18 +350,18 @@ void CGA_RefreshImageData(unsigned char *buffer) { Draw a vertical line with origin x:y and length l, using color NB! Line must not wrap around the edge */ -void CGA_DrawVLine(unsigned int x, unsigned int y, unsigned int l, unsigned char color, unsigned char *target) { - unsigned int ofs; +void CGA_DrawVLine(uint16 x, uint16 y, uint16 l, byte color, byte *target) { + uint16 ofs; /*pixels are starting from top bits of byte*/ - unsigned int mask = ~(3 << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL)); - unsigned char pixel = color << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL); + uint16 mask = ~(3 << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL)); + byte pixel = color << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL); mask >>= (x % CGA_PIXELS_PER_BYTE) * CGA_BITS_PER_PIXEL; pixel >>= (x % CGA_PIXELS_PER_BYTE) * CGA_BITS_PER_PIXEL; ofs = CGA_CalcXY_p(x / CGA_PIXELS_PER_BYTE, y); - uint ol = l; + uint16 ol = l; while (l--) { target[ofs] = (target[ofs] & mask) | pixel; ofs ^= CGA_ODD_LINES_OFS; @@ -377,17 +377,17 @@ void CGA_DrawVLine(unsigned int x, unsigned int y, unsigned int l, unsigned char Draw a horizontal line with origin x:y and length l, using color NB! Line must not wrap around the edge */ -void CGA_DrawHLine(unsigned int x, unsigned int y, unsigned int l, unsigned char color, unsigned char *target) { - unsigned int ofs; +void CGA_DrawHLine(uint16 x, uint16 y, uint16 l, byte color, byte *target) { + uint16 ofs; /*pixels are starting from top bits of byte*/ uint16 mask = ~(3 << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL)); - unsigned char pixel = color << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL); + byte pixel = color << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL); mask >>= (x % CGA_PIXELS_PER_BYTE) * CGA_BITS_PER_PIXEL; pixel >>= (x % CGA_PIXELS_PER_BYTE) * CGA_BITS_PER_PIXEL; ofs = CGA_CalcXY_p(x / CGA_PIXELS_PER_BYTE, y); - uint ol = l; + uint16 ol = l; while (l--) { target[ofs] = (target[ofs] & mask) | pixel; mask >>= CGA_BITS_PER_PIXEL; @@ -407,11 +407,11 @@ Draw horizontal line of length l with color, add surrounding pixels (bmask, bpix Return next line screen offset NB! Length specifies byte lenght of inner segment, not amount of pixels */ -unsigned int CGA_DrawHLineWithEnds(unsigned int bmask, unsigned int bpix, unsigned char color, unsigned int l, unsigned char *target, unsigned int ofs) { +uint16 CGA_DrawHLineWithEnds(uint16 bmask, uint16 bpix, byte color, uint16 l, byte *target, uint16 ofs) { target[ofs] = (target[ofs] & (bmask >> 8)) | (bpix >> 8); memset(target + ofs + 1, color, l); target[ofs + 1 + l] = (target[ofs + 1 + l] & (bmask & 255)) | (bpix & 255); - uint oofs = ofs + 1; + uint16 oofs = ofs + 1; ofs ^= CGA_ODD_LINES_OFS; if ((ofs & CGA_ODD_LINES_OFS) == 0) ofs += CGA_BYTES_PER_LINE; @@ -425,10 +425,10 @@ unsigned int CGA_DrawHLineWithEnds(unsigned int bmask, unsigned int bpix, unsign /* Print a character at current cursor pos, then advance */ -void CGA_PrintChar(unsigned char c, unsigned char *target) { - unsigned int i; - unsigned char *font = carpc_data + c * CGA_FONT_HEIGHT; - unsigned int ofs = CGA_CalcXY_p(char_draw_coords_x++, char_draw_coords_y); +void CGA_PrintChar(byte c, byte *target) { + uint16 i; + byte *font = carpc_data + c * CGA_FONT_HEIGHT; + uint16 ofs = CGA_CalcXY_p(char_draw_coords_x++, char_draw_coords_y); for (i = 0; i < CGA_FONT_HEIGHT; i++) { c = *font++; c = char_xlat_table[c]; @@ -448,11 +448,11 @@ Blit progressive sprite (mask+pixel) from scratch buffer to interlaced screen bu NB! width specify a number of bytes, not count of pixels TODO: generalize/merge me with BlitSprite */ -void CGA_BlitScratchBackSprite(unsigned int sprofs, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) { - unsigned char x; - unsigned char *pixels = scratch_mem2 + 2 + sprofs; - uint oh = h; - uint oofs = ofs; +void CGA_BlitScratchBackSprite(uint16 sprofs, uint16 w, uint16 h, byte *screen, uint16 ofs) { + byte x; + byte *pixels = scratch_mem2 + 2 + sprofs; + uint16 oh = h; + uint16 oofs = ofs; while (h--) { for (x = 0; x < w; x++) screen[ofs + x] = (backbuffer[ofs + x] & pixels[x * 2]) | pixels[x * 2 + 1]; @@ -466,7 +466,7 @@ void CGA_BlitScratchBackSprite(unsigned int sprofs, unsigned int w, unsigned int CGA_blitToScreen(oofs, w * 4, oh); } -void CGA_BlitFromBackBuffer(unsigned char w, unsigned char h, unsigned char *screen, unsigned int ofs) { +void CGA_BlitFromBackBuffer(byte w, byte h, byte *screen, uint16 ofs) { CGA_CopyScreenBlock(backbuffer, w, h, screen, ofs); } @@ -474,10 +474,10 @@ void CGA_BlitFromBackBuffer(unsigned char w, unsigned char h, unsigned char *scr Blit progressive sprite (mask+pixel) to interlaced screen buffer NB! width and pixelswidth specify a number of bytes, not count of pixels */ -void CGA_BlitSprite(unsigned char *pixels, signed int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) { - unsigned char x; - uint oh = h; - uint oofs = ofs; +void CGA_BlitSprite(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs) { + byte x; + uint16 oh = h; + uint16 oofs = ofs; while (h--) { for (x = 0; x < w; x++) screen[ofs + x] = (screen[ofs + x] & pixels[x * 2]) | pixels[x * 2 + 1]; @@ -495,10 +495,10 @@ void CGA_BlitSprite(unsigned char *pixels, signed int pw, unsigned int w, unsign Blit progressive sprite (mask+pixel) to interlaced screen buffer. Flip the sprite horizontally NB! width and pixelswidth specify a number of bytes, not count of pixels */ -void CGA_BlitSpriteFlip(unsigned char *pixels, signed int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) { - unsigned char x; - uint oh = h; - uint oofs = ofs; +void CGA_BlitSpriteFlip(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs) { + byte x; + uint16 oh = h; + uint16 oofs = ofs; while (h--) { for (x = 0; x < w; x++) screen[ofs - x] = (screen[ofs - x] & cga_pixel_flip[pixels[x * 2]]) | cga_pixel_flip[pixels[x * 2 + 1]]; @@ -520,10 +520,10 @@ Used to draw mouse cursor and backup what's under it NB! width and pixelswidth specify a number of bytes, not count of pixels NB! pixel+mask comes in reversed order, compared to regular BlitSprite */ -void CGA_BlitSpriteBak(unsigned char *pixels, signed int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs, unsigned char *backup, unsigned char mask) { - unsigned char x; - uint oh = h; - uint oofs = ofs; +void CGA_BlitSpriteBak(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs, byte *backup, byte mask) { + byte x; + uint16 oh = h; + uint16 oofs = ofs; while (h--) { for (x = 0; x < w; x++) { *backup++ = screen[ofs + x]; @@ -543,8 +543,8 @@ void CGA_BlitSpriteBak(unsigned char *pixels, signed int pw, unsigned int w, uns /* Blit progressive sprite (w+h+mask+pixel) to interlaced screen buffer */ -void DrawSprite(unsigned char *sprite, unsigned char *screen, unsigned int ofs) { - unsigned char w, h; +void DrawSprite(byte *sprite, byte *screen, uint16 ofs) { + byte w, h; w = *sprite++; h = *sprite++; CGA_BlitSprite(sprite, w * 2, w, h, screen, ofs); @@ -553,8 +553,8 @@ void DrawSprite(unsigned char *sprite, unsigned char *screen, unsigned int ofs) /* Blit progressive sprite (w+h+mask+pixel) to interlaced screen buffer, horizontally flipped */ -void DrawSpriteFlip(unsigned char *sprite, unsigned char *screen, unsigned int ofs) { - unsigned char w, h; +void DrawSpriteFlip(byte *sprite, byte *screen, uint16 ofs) { + byte w, h; w = *sprite++; h = *sprite++; CGA_BlitSpriteFlip(sprite, w * 2, w, h, screen, ofs); @@ -564,11 +564,11 @@ void DrawSpriteFlip(unsigned char *sprite, unsigned char *screen, unsigned int o Load and uncompress 2-bit sprite Return next ptr after the loaded sprite */ -unsigned char *LoadSprite(unsigned char index, unsigned char *bank, unsigned char *buffer, unsigned char header_only) { - unsigned char w, h; - unsigned int rsize; - unsigned char *sprite, *sprite_end; - unsigned char *bitmask; +byte *LoadSprite(byte index, byte *bank, byte *buffer, byte header_only) { + byte w, h; + uint16 rsize; + byte *sprite, *sprite_end; + byte *bitmask; sprite = SeekToEntryW(bank, index, &sprite_end); w = *sprite++; h = *sprite++; @@ -589,10 +589,10 @@ unsigned char *LoadSprite(unsigned char index, unsigned char *bank, unsigned cha } } else { /*with transparency*/ - unsigned char bi = 1; + byte bi = 1; while (rsize--) { - unsigned char pixels = *sprite++; - unsigned char mask = 0; + byte pixels = *sprite++; + byte mask = 0; if ((pixels & 0xC0) == 0) { bi >>= 1; @@ -641,16 +641,16 @@ unsigned char *LoadSprite(unsigned char index, unsigned char *bank, unsigned cha return buffer; } -extern unsigned char sprit_data[RES_SPRIT_MAX]; +extern byte sprit_data[RES_SPRIT_MAX]; -unsigned char sprit_load_buffer[1290]; +byte sprit_load_buffer[1290]; -unsigned char *LoadSprit(unsigned char index) { +byte *LoadSprit(byte index) { LoadSprite(index, sprit_data + 4, sprit_load_buffer, 0); return sprit_load_buffer; } -unsigned char *LoadPersSprit(unsigned char index) { +byte *LoadPersSprit(byte index) { #if 1 /*Use separate memory for pers1/pers2*/ if (index < 61) @@ -666,26 +666,26 @@ unsigned char *LoadPersSprit(unsigned char index) { } -void DrawSpriteN(unsigned char index, unsigned int x, unsigned int y, unsigned char *target) { - unsigned int ofs; - unsigned char *sprite; +void DrawSpriteN(byte index, uint16 x, uint16 y, byte *target) { + uint16 ofs; + byte *sprite; sprite = LoadSprit(index); ofs = CGA_CalcXY_p(x, y); DrawSprite(sprite, target, ofs); } -void DrawSpriteNFlip(unsigned char index, unsigned int x, unsigned int y, unsigned char *target) { - unsigned int ofs; - unsigned char *sprite; +void DrawSpriteNFlip(byte index, uint16 x, uint16 y, byte *target) { + uint16 ofs; + byte *sprite; sprite = LoadSprit(index); ofs = CGA_CalcXY_p(x, y); DrawSpriteFlip(sprite, target, ofs); } -void BackupAndShowSprite(unsigned char index, unsigned char x, unsigned char y) { - unsigned char w, h; - unsigned int ofs; - unsigned char *sprite = LoadSprit(index); +void BackupAndShowSprite(byte index, byte x, byte y) { + byte w, h; + uint16 ofs; + byte *sprite = LoadSprit(index); ofs = CGA_CalcXY_p(x, y); w = sprite[0]; h = sprite[1]; @@ -698,8 +698,8 @@ Blit progressive image to interlaced screen buffer, then wait for VBlank Push image from the top to down NB! width and pixelswidth specify a number of bytes, not count of pixels */ -void CGA_AnimLiftToDown(unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) { - unsigned int i; +void CGA_AnimLiftToDown(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs) { + uint16 i; pixels += pw * (h - 1); for (i = 1; i <= h; i++) { CGA_BlitAndWait(pixels, pw, w, i, screen, ofs); @@ -713,8 +713,8 @@ Pull and expand image from the right to left NB! width and pixelswidth specify a number of bytes, not count of pixels NB! ofs specifies top-right corner of the image */ -void CGA_AnimLiftToLeft(unsigned int n, unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) { - unsigned int i; +void CGA_AnimLiftToLeft(uint16 n, byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs) { + uint16 i; for (i = 0; i < n; i++) { CGA_BlitAndWait(pixels, pw, w + i, h, screen, ofs); ofs -= 1; @@ -726,8 +726,8 @@ Blit progressive image to interlaced screen buffer, then wait for VBlank Push image from the left to right NB! width and pixelswidth specify a number of bytes, not count of pixels */ -void CGA_AnimLiftToRight(unsigned int n, unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) { - unsigned int i; +void CGA_AnimLiftToRight(uint16 n, byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs) { + uint16 i; for (i = 0; i < n; i++) { CGA_BlitAndWait(pixels, pw, w + i, h, screen, ofs); pixels -= 1; @@ -740,8 +740,8 @@ Push image from the down to up NB! width and pixelswidth specify a number of bytes, not count of pixels NB! x:y specifies left-bottom coords */ -void CGA_AnimLiftToUp(unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int x, unsigned int y) { - unsigned int i; +void CGA_AnimLiftToUp(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 x, uint16 y) { + uint16 i; for (i = 1; i <= h; i++) { CGA_BlitAndWait(pixels, pw, w, i, screen, CGA_CalcXY_p(x, y)); y -= 1; @@ -752,10 +752,10 @@ void CGA_AnimLiftToUp(unsigned char *pixels, unsigned int pw, unsigned int w, un /*Fill gap with source screen data*/ /*offs points to block's bottom most line, data will be shifted to next line*/ /*NB! w is in bytes*/ -void CGA_HideScreenBlockLiftToDown(unsigned int n, unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs) { +void CGA_HideScreenBlockLiftToDown(uint16 n, byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs) { while (n--) { - int i; - unsigned int sofs, tofs; + int16 i; + uint16 sofs, tofs; sofs = ofs; tofs = ofs; @@ -798,10 +798,10 @@ void CGA_HideScreenBlockLiftToDown(unsigned int n, unsigned char *screen, unsign /*Fill gap with source screen data*/ /*offs points to block's top most line, data will be shifted to previous line*/ /*NB! w is in bytes*/ -void CGA_HideScreenBlockLiftToUp(unsigned int n, unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs) { +void CGA_HideScreenBlockLiftToUp(uint16 n, byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs) { while (n--) { - int i; - unsigned int sofs, tofs; + int16 i; + uint16 sofs, tofs; sofs = ofs; tofs = ofs; @@ -844,10 +844,10 @@ void CGA_HideScreenBlockLiftToUp(unsigned int n, unsigned char *screen, unsigned /*Fill gap with source screen data*/ /*offs points to block's left most column, data will be shifted to previous column*/ /*NB! w is in bytes*/ -void CGA_HideScreenBlockLiftToLeft(unsigned int n, unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs) { +void CGA_HideScreenBlockLiftToLeft(uint16 n, byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs) { while (n--) { - int i; - unsigned int sofs, tofs; + int16 i; + uint16 sofs, tofs; sofs = ofs; @@ -882,10 +882,10 @@ void CGA_HideScreenBlockLiftToLeft(unsigned int n, unsigned char *screen, unsign /*Fill gap with source screen data*/ /*offs points to block's right most column, data will be shifted to next column*/ /*NB! w is in bytes*/ -void CGA_HideScreenBlockLiftToRight(unsigned int n, unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs) { +void CGA_HideScreenBlockLiftToRight(uint16 n, byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs) { while (n--) { - int i; - unsigned int sofs, tofs; + int16 i; + uint16 sofs, tofs; sofs = ofs; @@ -918,15 +918,15 @@ void CGA_HideScreenBlockLiftToRight(unsigned int n, unsigned char *screen, unsig typedef struct scrpiece_t { - unsigned int offs; - unsigned char delay; /*speed in bits 1..0, delay in bits 7..2*/ - unsigned char pix0; - unsigned char pix2; - unsigned char pix1; - unsigned char pix3; + uint16 offs; + byte delay; /*speed in bits 1..0, delay in bits 7..2*/ + byte pix0; + byte pix2; + byte pix1; + byte pix3; } scrpiece_t; -static const unsigned char piecedelays[] = { +static const byte piecedelays[] = { 219, 182, 237, 187, 110, 219, 187, 120, 219, 109, 182, 219, 109, 182, 219, 104, 182, 214, 218, 219, 91, 107, 107, 104, 213, 107, 90, 214, 181, 182, 214, 216, 213, @@ -945,13 +945,13 @@ static const unsigned char piecedelays[] = { }; /*break screen area onto 4x4 pix pieces*/ -static void ScreenToPieces(unsigned char width, unsigned char height, unsigned char *screen, unsigned int offs, scrpiece_t *pieces) { - const unsigned char *delays = piecedelays; +static void ScreenToPieces(byte width, byte height, byte *screen, uint16 offs, scrpiece_t *pieces) { + const byte *delays = piecedelays; height = (height + 3) / 4; while (height--) { - unsigned int x; + uint16 x; for (x = 0; x < width; x++) { - unsigned int bofs = offs + x; + uint16 bofs = offs + x; pieces->offs = bofs; pieces->delay = *delays++; if (pieces->delay == 0) /*ensure piece is alive*/ @@ -971,15 +971,15 @@ static void ScreenToPieces(unsigned char width, unsigned char height, unsigned c pieces->offs = 0; /*end of list*/ } -static void FallPieces(scrpiece_t *pieces, unsigned char *source, unsigned char *target) { - unsigned char t = 1; - unsigned char again = 0; +static void FallPieces(scrpiece_t *pieces, byte *source, byte *target) { + byte t = 1; + byte again = 0; do { scrpiece_t *piece; for (piece = pieces, again = 0; piece->offs; piece++) { if ((piece->delay >> 2) < t) { - unsigned int offs = piece->offs; - unsigned int bofs = offs; + uint16 offs = piece->offs; + uint16 bofs = offs; if (target[bofs] == piece->pix0) target[bofs] = source[bofs]; if (target[bofs + CGA_BYTES_PER_LINE] == piece->pix2) @@ -1056,19 +1056,19 @@ static void FallPieces(scrpiece_t *pieces, unsigned char *source, unsigned char } while (again); } -void CGA_HideShatterFall(unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs) { +void CGA_HideShatterFall(byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs) { scrpiece_t *pieces = (scrpiece_t *)scratch_mem2; ScreenToPieces(w, h, screen, ofs, pieces); FallPieces(pieces, source, target); } -void CGA_TraceLine(unsigned int sx, unsigned int ex, unsigned int sy, unsigned int ey, unsigned char *source, unsigned char *target) { - unsigned char b0 = 0; - unsigned char b1 = 0; - unsigned char mask; - unsigned int ofs; - unsigned int count; - int w, h, dx, dy, val; +void CGA_TraceLine(uint16 sx, uint16 ex, uint16 sy, uint16 ey, byte *source, byte *target) { + byte b0 = 0; + byte b1 = 0; + byte mask; + uint16 ofs; + uint16 count; + int16 w, h, dx, dy, val; if (ex >= sx) w = ex - sx; diff --git a/engines/chamber/cga.h b/engines/chamber/cga.h index 48f106fcbcf..051ed836bdf 100644 --- a/engines/chamber/cga.h +++ b/engines/chamber/cga.h @@ -41,87 +41,87 @@ extern byte CGA_SCREENBUFFER[0x4000]; #define CGA_PREV_LINE(offs) ((CGA_ODD_LINES_OFS ^ (offs)) - (((offs) & CGA_ODD_LINES_OFS) ? CGA_BYTES_PER_LINE : 0)) #define frontbuffer CGA_SCREENBUFFER -extern unsigned char backbuffer[0x4000]; +extern byte backbuffer[0x4000]; -extern unsigned char sprit_load_buffer[1290]; +extern byte sprit_load_buffer[1290]; -extern unsigned char cga_pixel_flip[256]; +extern byte cga_pixel_flip[256]; -extern unsigned char char_draw_coords_x; -extern unsigned char char_draw_coords_y; -extern unsigned char *char_xlat_table; -extern unsigned char string_ended; -extern unsigned char char_draw_max_width; -extern unsigned char char_draw_max_height; +extern byte char_draw_coords_x; +extern byte char_draw_coords_y; +extern byte *char_xlat_table; +extern byte string_ended; +extern byte char_draw_max_width; +extern byte char_draw_max_height; void SwitchToGraphicsMode(void); void SwitchToTextMode(void); void WaitVBlank(void); -void CGA_ColorSelect(unsigned char csel); +void CGA_ColorSelect(byte csel); void CGA_BackBufferToRealFull(void); void CGA_RealBufferToBackFull(void); void CGA_SwapRealBackBuffer(void); -void CGA_SwapScreenRect(unsigned char *pixels, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs); +void CGA_SwapScreenRect(byte *pixels, uint16 w, uint16 h, byte *screen, uint16 ofs); -unsigned int CGA_CalcXY(unsigned int x, unsigned int y); -unsigned int CGA_CalcXY_p(unsigned int x, unsigned int y); +uint16 CGA_CalcXY(uint16 x, uint16 y); +uint16 CGA_CalcXY_p(uint16 x, uint16 y); -void CGA_CopyScreenBlock(unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs); +void CGA_CopyScreenBlock(byte *source, uint16 w, uint16 h, byte *target, uint16 ofs); -unsigned char *CGA_BackupImage(unsigned char *source, unsigned int ofs, unsigned int w, unsigned int h, unsigned char *buffer); -unsigned char *CGA_BackupImageReal(unsigned int ofs, unsigned int w, unsigned int h); +byte *CGA_BackupImage(byte *source, uint16 ofs, uint16 w, uint16 h, byte *buffer); +byte *CGA_BackupImageReal(uint16 ofs, uint16 w, uint16 h); -void CGA_RestoreImage(unsigned char *buffer, unsigned char *target); -void CGA_RefreshImageData(unsigned char *buffer); -void CGA_RestoreBackupImage(unsigned char *target); +void CGA_RestoreImage(byte *buffer, byte *target); +void CGA_RefreshImageData(byte *buffer); +void CGA_RestoreBackupImage(byte *target); -void CGA_Blit(unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs); -void CGA_BlitAndWait(unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs); -void CGA_FillAndWait(unsigned char pixel, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs); +void CGA_Blit(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs); +void CGA_BlitAndWait(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs); +void CGA_FillAndWait(byte pixel, uint16 w, uint16 h, byte *screen, uint16 ofs); -void CGA_DrawVLine(unsigned int x, unsigned int y, unsigned int l, unsigned char color, unsigned char *target); -void CGA_DrawHLine(unsigned int x, unsigned int y, unsigned int l, unsigned char color, unsigned char *target); -unsigned int CGA_DrawHLineWithEnds(unsigned int bmask, unsigned int bpix, unsigned char color, unsigned int l, unsigned char *target, unsigned int ofs); +void CGA_DrawVLine(uint16 x, uint16 y, uint16 l, byte color, byte *target); +void CGA_DrawHLine(uint16 x, uint16 y, uint16 l, byte color, byte *target); +uint16 CGA_DrawHLineWithEnds(uint16 bmask, uint16 bpix, byte color, uint16 l, byte *target, uint16 ofs); -void CGA_PrintChar(unsigned char c, unsigned char *target); +void CGA_PrintChar(byte c, byte *target); -void CGA_BlitScratchBackSprite(unsigned int sprofs, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs); -void CGA_BlitFromBackBuffer(unsigned char w, unsigned char h, unsigned char *screen, unsigned int ofs); +void CGA_BlitScratchBackSprite(uint16 sprofs, uint16 w, uint16 h, byte *screen, uint16 ofs); +void CGA_BlitFromBackBuffer(byte w, byte h, byte *screen, uint16 ofs); -void CGA_BlitSprite(unsigned char *pixels, signed int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs); -void CGA_BlitSpriteFlip(unsigned char *pixels, signed int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs); +void CGA_BlitSprite(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs); +void CGA_BlitSpriteFlip(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs); -void CGA_BlitSpriteBak(unsigned char *pixels, signed int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs, unsigned char *backup, unsigned char mask); +void CGA_BlitSpriteBak(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs, byte *backup, byte mask); -void DrawSprite(unsigned char *sprite, unsigned char *screen, unsigned int ofs); -void DrawSpriteFlip(unsigned char *sprite, unsigned char *screen, unsigned int ofs); +void DrawSprite(byte *sprite, byte *screen, uint16 ofs); +void DrawSpriteFlip(byte *sprite, byte *screen, uint16 ofs); -void DrawSpriteN(unsigned char index, unsigned int x, unsigned int y, unsigned char *target); -void DrawSpriteNFlip(unsigned char index, unsigned int x, unsigned int y, unsigned char *target); +void DrawSpriteN(byte index, uint16 x, uint16 y, byte *target); +void DrawSpriteNFlip(byte index, uint16 x, uint16 y, byte *target); -void BackupAndShowSprite(unsigned char index, unsigned char x, unsigned char y); +void BackupAndShowSprite(byte index, byte x, byte y); -unsigned char *LoadSprite(unsigned char index, unsigned char *bank, unsigned char *buffer, unsigned char header_only); +byte *LoadSprite(byte index, byte *bank, byte *buffer, byte header_only); -unsigned char *LoadSprit(unsigned char index); -unsigned char *LoadPersSprit(unsigned char index); +byte *LoadSprit(byte index); +byte *LoadPersSprit(byte index); -void CGA_AnimLiftToUp(unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int x, unsigned int y); -void CGA_AnimLiftToDown(unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs); -void CGA_AnimLiftToLeft(unsigned int n, unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs); -void CGA_AnimLiftToRight(unsigned int n, unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs); +void CGA_AnimLiftToUp(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 x, uint16 y); +void CGA_AnimLiftToDown(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs); +void CGA_AnimLiftToLeft(uint16 n, byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs); +void CGA_AnimLiftToRight(uint16 n, byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs); -void CGA_HideScreenBlockLiftToUp(unsigned int n, unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs); -void CGA_HideScreenBlockLiftToDown(unsigned int n, unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs); -void CGA_HideScreenBlockLiftToLeft(unsigned int n, unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs); -void CGA_HideScreenBlockLiftToRight(unsigned int n, unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs); +void CGA_HideScreenBlockLiftToUp(uint16 n, byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs); +void CGA_HideScreenBlockLiftToDown(uint16 n, byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs); +void CGA_HideScreenBlockLiftToLeft(uint16 n, byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs); +void CGA_HideScreenBlockLiftToRight(uint16 n, byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs); -void CGA_HideShatterFall(unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs); +void CGA_HideShatterFall(byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs); -void CGA_TraceLine(unsigned int sx, unsigned int ex, unsigned int sy, unsigned int ey, unsigned char *source, unsigned char *target); +void CGA_TraceLine(uint16 sx, uint16 ex, uint16 sy, uint16 ey, byte *source, byte *target); } // End of namespace Chamber diff --git a/engines/chamber/chamber.cpp b/engines/chamber/chamber.cpp index f5ad0eaca7f..aad13c8504a 100644 --- a/engines/chamber/chamber.cpp +++ b/engines/chamber/chamber.cpp @@ -76,7 +76,7 @@ Common::Error ChamberEngine::saveGameStream(Common::WriteStream *stream, bool is void ChamberEngine::syncGameStream(Common::Serializer &s) { // Use methods of Serializer to save/load fields - int dummy = 0; + int16 dummy = 0; s.syncAsUint16LE(dummy); } diff --git a/engines/chamber/common.h b/engines/chamber/common.h index 8858e8ebad0..64066cd8089 100644 --- a/engines/chamber/common.h +++ b/engines/chamber/common.h @@ -37,10 +37,10 @@ namespace Chamber { #include "common/pack-start.h" typedef struct rect_t { - unsigned char sx; - unsigned char ex; - unsigned char sy; - unsigned char ey; + byte sx; + byte ex; + byte sy; + byte ey; } rect_t; #include "common/pack-end.h" diff --git a/engines/chamber/cursor.cpp b/engines/chamber/cursor.cpp index 2c58cc3371a..7da000fa7ff 100644 --- a/engines/chamber/cursor.cpp +++ b/engines/chamber/cursor.cpp @@ -30,14 +30,14 @@ namespace Chamber { -unsigned char cursor_color = 0; +byte cursor_color = 0; -unsigned char *cursor_shape = NULL; -unsigned char cursor_anim_ticks; -unsigned char cursor_anim_phase; +byte *cursor_shape = NULL; +byte cursor_anim_ticks; +byte cursor_anim_phase; /*cursors hotspot offsets*/ -unsigned int cursor_shifts[CURSOR_MAX][2] = { +uint16 cursor_shifts[CURSOR_MAX][2] = { { 0, 0 }, { 7, 7 }, { 7, 7 }, @@ -49,19 +49,19 @@ unsigned int cursor_shifts[CURSOR_MAX][2] = { { 7, 7 } }; -unsigned int cursor_x_shift; -unsigned char cursor_y_shift; +uint16 cursor_x_shift; +byte cursor_y_shift; -unsigned int cursor_x; -unsigned char cursor_y; -unsigned char cursor_backup[CURSOR_WIDTH_SPR * CURSOR_HEIGHT / CGA_BITS_PER_PIXEL]; -unsigned int last_cursor_draw_ofs = 0; -unsigned int cursor_draw_ofs; +uint16 cursor_x; +byte cursor_y; +byte cursor_backup[CURSOR_WIDTH_SPR * CURSOR_HEIGHT / CGA_BITS_PER_PIXEL]; +uint16 last_cursor_draw_ofs = 0; +uint16 cursor_draw_ofs; /* Select cursor shape and its hotspot */ -void SelectCursor(unsigned int num) { +void SelectCursor(uint16 num) { cursor_x_shift = cursor_shifts[num][0]; cursor_y_shift = cursor_shifts[num][1]; cursor_shape = souri_data + num * CURSOR_WIDTH * CURSOR_HEIGHT * 2 / CGA_PIXELS_PER_BYTE; @@ -74,13 +74,13 @@ void UpdateCursor(void) { if (!cursor_shape) return; - unsigned char *cursor, *sprite, *spr; - unsigned char cursor_bit_shift; - unsigned int x, y; + byte *cursor, *sprite, *spr; + byte cursor_bit_shift; + uint16 x, y; x = cursor_x - cursor_x_shift; - if ((signed int)x < 0) x = 0; + if ((int16)x < 0) x = 0; y = cursor_y - cursor_y_shift; - if ((signed int)y < 0) y = 0; + if ((int16)y < 0) y = 0; cursor_bit_shift = (x % 4) * 2; cursor_draw_ofs = CGA_CalcXY_p(x / 4, y); @@ -93,7 +93,7 @@ void UpdateCursor(void) { spr = sprite; for (y = 0; y < CURSOR_HEIGHT; y++) { for (x = 0; x < CURSOR_WIDTH / 4; x++) { - unsigned char p = *cursor++; + byte p = *cursor++; spr[x * 2] = p; } spr[x * 2] = 0; @@ -104,7 +104,7 @@ void UpdateCursor(void) { spr = sprite + 1; for (y = 0; y < CURSOR_HEIGHT; y++) { for (x = 0; x < CURSOR_WIDTH / 4; x++) { - unsigned char p = *cursor++; + byte p = *cursor++; spr[x * 2] = p; } spr[x * 2] = 0xFF; @@ -113,12 +113,12 @@ void UpdateCursor(void) { } else { spr = sprite; for (y = 0; y < CURSOR_HEIGHT; y++) { - unsigned char i; - unsigned char p0 = *cursor++; - unsigned char p1 = *cursor++; - unsigned char p2 = *cursor++; - unsigned char p3 = *cursor++; - unsigned char p4 = 0; + byte i; + byte p0 = *cursor++; + byte p1 = *cursor++; + byte p2 = *cursor++; + byte p3 = *cursor++; + byte p4 = 0; for (i = 0; i < cursor_bit_shift; i++) { p4 = (p4 >> 1) | (p3 << 7); p3 = (p3 >> 1) | (p2 << 7); @@ -137,12 +137,12 @@ void UpdateCursor(void) { spr = sprite + 1; for (y = 0; y < CURSOR_HEIGHT; y++) { - unsigned char i; - unsigned char p0 = *cursor++; - unsigned char p1 = *cursor++; - unsigned char p2 = *cursor++; - unsigned char p3 = *cursor++; - unsigned char p4 = 0xFF; + byte i; + byte p0 = *cursor++; + byte p1 = *cursor++; + byte p2 = *cursor++; + byte p3 = *cursor++; + byte p4 = 0xFF; for (i = 0; i < cursor_bit_shift; i++) { p4 = (p4 >> 1) | (p3 << 7); p3 = (p3 >> 1) | (p2 << 7); @@ -163,7 +163,7 @@ void UpdateCursor(void) { /* Draw cursor sprite and backup background pixels */ -void DrawCursor(unsigned char *target) { +void DrawCursor(byte *target) { last_cursor_draw_ofs = cursor_draw_ofs; CGA_BlitSpriteBak(sprit_load_buffer, CURSOR_WIDTH_SPR / 4, CURSOR_WIDTH_SPR / 4, CURSOR_HEIGHT, target, cursor_draw_ofs, cursor_backup, cursor_color); } @@ -171,14 +171,14 @@ void DrawCursor(unsigned char *target) { /* Restore background pixels under cursor */ -void UndrawCursor(unsigned char *target) { +void UndrawCursor(byte *target) { CGA_Blit(cursor_backup, CURSOR_WIDTH_SPR / 4, CURSOR_WIDTH_SPR / 4, CURSOR_HEIGHT, target, last_cursor_draw_ofs); } /* Restore pixels under cursor and update cursor sprite */ -void UpdateUndrawCursor(unsigned char *target) { +void UpdateUndrawCursor(byte *target) { /*TODO: does this call order makes any sense?*/ UpdateCursor(); UndrawCursor(target); diff --git a/engines/chamber/cursor.h b/engines/chamber/cursor.h index 7c73ae04782..4f5a594a152 100644 --- a/engines/chamber/cursor.h +++ b/engines/chamber/cursor.h @@ -42,18 +42,18 @@ enum Cursors { CURSOR_MAX }; -extern unsigned int cursor_x; -extern unsigned char cursor_y; -extern unsigned char cursor_color; -extern unsigned char *cursor_shape; -extern unsigned char cursor_anim_ticks; -extern unsigned char cursor_anim_phase; +extern uint16 cursor_x; +extern byte cursor_y; +extern byte cursor_color; +extern byte *cursor_shape; +extern byte cursor_anim_ticks; +extern byte cursor_anim_phase; -void SelectCursor(unsigned int num); +void SelectCursor(uint16 num); void UpdateCursor(void); -void DrawCursor(unsigned char *target); -void UndrawCursor(unsigned char *target); -void UpdateUndrawCursor(unsigned char *target); +void DrawCursor(byte *target); +void UndrawCursor(byte *target); +void UpdateUndrawCursor(byte *target); } // End of namespace Chamber diff --git a/engines/chamber/decompr.cpp b/engines/chamber/decompr.cpp index b980311371d..92e30f1350b 100644 --- a/engines/chamber/decompr.cpp +++ b/engines/chamber/decompr.cpp @@ -26,16 +26,16 @@ namespace Chamber { static struct { - unsigned char codes[256]; - unsigned char prefix[256]; - unsigned char suffix[256]; - unsigned char coddict[256]; - unsigned char codlink[256]; - unsigned char stackpos; + byte codes[256]; + byte prefix[256]; + byte suffix[256]; + byte coddict[256]; + byte codlink[256]; + byte stackpos; } DecompCtx; -unsigned char decode_string(unsigned char code, unsigned char prev_n, unsigned char *stack) { - unsigned char n; +byte decode_string(byte code, byte prev_n, byte *stack) { + byte n; while ((n = DecompCtx.coddict[code]) != 0) { while (n >= prev_n) { n = DecompCtx.codlink[n]; @@ -49,13 +49,13 @@ unsigned char decode_string(unsigned char code, unsigned char prev_n, unsigned c return code; } -unsigned long decompress(unsigned char *data, unsigned char *result) { - unsigned char dict_size, more; - unsigned int compsize; - unsigned int i; - unsigned char code, n, suffix; - unsigned char stack[256]; - unsigned long decompsize = 0; +uint32 decompress(byte *data, byte *result) { + byte dict_size, more; + uint16 compsize; + uint16 i; + byte code, n, suffix; + byte stack[256]; + uint32 decompsize = 0; do { dict_size = *data++; diff --git a/engines/chamber/decompr.h b/engines/chamber/decompr.h index b795e74a2a3..502aa1e4199 100644 --- a/engines/chamber/decompr.h +++ b/engines/chamber/decompr.h @@ -24,7 +24,7 @@ #define CHAMBER_DECOMPR_H namespace Chamber { -unsigned long decompress(unsigned char *data, unsigned char *result); +uint32 decompress(byte *data, byte *result); } // End of namespace Chamber diff --git a/engines/chamber/dialog.cpp b/engines/chamber/dialog.cpp index 48a259e2f68..31e3e94a095 100644 --- a/engines/chamber/dialog.cpp +++ b/engines/chamber/dialog.cpp @@ -33,13 +33,13 @@ namespace Chamber { -unsigned int cur_str_index; -unsigned int cur_dlg_index; +uint16 cur_str_index; +uint16 cur_dlg_index; dirty_rect_t dirty_rects[MAX_DIRTY_RECT]; -void AddDirtyRect(unsigned char kind, unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned int offs) { - int i; +void AddDirtyRect(byte kind, byte x, byte y, byte w, byte h, uint16 offs) { + int16 i; dirty_rect_t *r = dirty_rects; for (i = 0; i < MAX_DIRTY_RECT; i++, r++) /*TODO: may go oob*/ if (r->kind == DirtyRectFree) @@ -53,7 +53,7 @@ void AddDirtyRect(unsigned char kind, unsigned char x, unsigned char y, unsigned script_byte_vars.dirty_rect_kind = dirty_rects[0].kind; } -void GetDirtyRect(int index, unsigned char *kind, unsigned char *x, unsigned char *y, unsigned char *w, unsigned char *h, unsigned int *offs, unsigned char newkind) { +void GetDirtyRect(int16 index, byte *kind, byte *x, byte *y, byte *w, byte *h, uint16 *offs, byte newkind) { *kind = dirty_rects[index].kind; *offs = dirty_rects[index].offs; *w = dirty_rects[index].width; @@ -65,16 +65,16 @@ void GetDirtyRect(int index, unsigned char *kind, unsigned char *x, unsigned cha script_byte_vars.dirty_rect_kind = dirty_rects[0].kind; } -void GetDirtyRectAndFree(int index, unsigned char *kind, unsigned char *x, unsigned char *y, unsigned char *w, unsigned char *h, unsigned int *offs) { +void GetDirtyRectAndFree(int16 index, byte *kind, byte *x, byte *y, byte *w, byte *h, uint16 *offs) { GetDirtyRect(index - 1, kind, x, y, w, h, offs, DirtyRectFree); } -void GetDirtyRectAndSetSprite(int index, unsigned char *kind, unsigned char *x, unsigned char *y, unsigned char *w, unsigned char *h, unsigned int *offs) { +void GetDirtyRectAndSetSprite(int16 index, byte *kind, byte *x, byte *y, byte *w, byte *h, uint16 *offs) { GetDirtyRect(index - 1, kind, x, y, w, h, offs, DirtyRectSprite); } -int FindDirtyRectAndFree(unsigned char kind, unsigned char *x, unsigned char *y, unsigned char *w, unsigned char *h, unsigned int *offs) { - int i; +int16 FindDirtyRectAndFree(byte kind, byte *x, byte *y, byte *w, byte *h, uint16 *offs) { + int16 i; for (i = 0; i < MAX_DIRTY_RECT; i++) { if (dirty_rects[i].kind == kind) { GetDirtyRect(i, &kind, x, y, w, h, offs, DirtyRectFree); @@ -85,10 +85,10 @@ int FindDirtyRectAndFree(unsigned char kind, unsigned char *x, unsigned char *y, } /*Restore screen data from back buffer as specified by dirty rects of kind*/ -void PopDirtyRects(unsigned char kind) { - unsigned char x, y; - unsigned char width, height; - unsigned int offs; +void PopDirtyRects(byte kind) { + byte x, y; + byte width, height; + uint16 offs; while (FindDirtyRectAndFree(kind, &x, &y, &width, &height, &offs)) { CGA_CopyScreenBlock(backbuffer, width, height, frontbuffer, offs); if (kind == DirtyRectBubble) { @@ -98,7 +98,7 @@ void PopDirtyRects(unsigned char kind) { } } -void DesciTextBox(unsigned int x, unsigned int y, unsigned int width, unsigned char *msg) { +void DesciTextBox(uint16 x, uint16 y, uint16 width, byte *msg) { draw_x = x; draw_y = y; char_draw_max_width = width; @@ -107,9 +107,9 @@ void DesciTextBox(unsigned int x, unsigned int y, unsigned int width, unsigned c } /*Draw dialog bubble with text and spike*/ -void DrawPersonBubble(unsigned char x, unsigned char y, unsigned char flags, unsigned char *msg) { - unsigned int ofs; - unsigned char w, h; +void DrawPersonBubble(byte x, byte y, byte flags, byte *msg) { + uint16 ofs; + byte w, h; char_draw_max_width = flags & 0x1F; char_xlat_table = chars_color_bonw; @@ -182,7 +182,7 @@ void PromptWait(void) { cursor_anim_phase = 0; do { - unsigned char ticks = script_byte_vars.timer_ticks; + byte ticks = script_byte_vars.timer_ticks; if ((ticks % 8) == 0 && ticks != cursor_anim_ticks) { cursor_anim_ticks = ticks; ShowPromptAnim(); @@ -203,9 +203,9 @@ void PromptWait(void) { /* Get string with index num from strings bank */ -unsigned char *SeekToString(unsigned char *bank, unsigned int num) { - unsigned char len; - unsigned char *p = bank; +byte *SeekToString(byte *bank, uint16 num) { + byte len; + byte *p = bank; cur_str_index = num; @@ -222,9 +222,9 @@ unsigned char *SeekToString(unsigned char *bank, unsigned int num) { /* Get string with index num from strings bank, with large string index support for scripts */ -unsigned char *SeekToStringScr(unsigned char *bank, unsigned int num, unsigned char **ptr) { - unsigned char len; - unsigned char *p = bank; +byte *SeekToStringScr(byte *bank, uint16 num, byte **ptr) { + byte len; + byte *p = bank; if (num < 4) { num = (num << 8) | *(++(*ptr)); diff --git a/engines/chamber/dialog.h b/engines/chamber/dialog.h index 23479e52410..11565c46d4c 100644 --- a/engines/chamber/dialog.h +++ b/engines/chamber/dialog.h @@ -25,8 +25,8 @@ namespace Chamber { -extern unsigned int cur_str_index; -extern unsigned int cur_dlg_index; +extern uint16 cur_str_index; +extern uint16 cur_dlg_index; enum DirtyRectKind { DirtyRectFree = 0, @@ -36,12 +36,12 @@ enum DirtyRectKind { }; typedef struct dirty_rect_t { - unsigned char kind; - unsigned int offs; - unsigned char height; - unsigned char width; - unsigned char y; /*for DirtyRectBubble this is spike offs*/ - unsigned char x; + byte kind; + uint16 offs; + byte height; + byte width; + byte y; /*for DirtyRectBubble this is spike offs*/ + byte x; } dirty_rect_t; #define MAX_DIRTY_RECT 10 @@ -56,18 +56,18 @@ extern dirty_rect_t dirty_rects[]; #define SPIKE_BUBRIGHT 0xC0 #define SPIKE_BUBLEFT 0xE0 -void AddDirtyRect(unsigned char kind, unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned int offs); -void GetDirtyRectAndFree(int index, unsigned char *kind, unsigned char *x, unsigned char *y, unsigned char *w, unsigned char *h, unsigned int *offs); -void GetDirtyRectAndSetSprite(int index, unsigned char *kind, unsigned char *x, unsigned char *y, unsigned char *w, unsigned char *h, unsigned int *offs); +void AddDirtyRect(byte kind, byte x, byte y, byte w, byte h, uint16 offs); +void GetDirtyRectAndFree(int16 index, byte *kind, byte *x, byte *y, byte *w, byte *h, uint16 *offs); +void GetDirtyRectAndSetSprite(int16 index, byte *kind, byte *x, byte *y, byte *w, byte *h, uint16 *offs); -void PopDirtyRects(unsigned char kind); -void DrawPersonBubble(unsigned char x, unsigned char y, unsigned char flags, unsigned char *msg); -void DesciTextBox(unsigned int x, unsigned int y, unsigned int width, unsigned char *msg); +void PopDirtyRects(byte kind); +void DrawPersonBubble(byte x, byte y, byte flags, byte *msg); +void DesciTextBox(uint16 x, uint16 y, uint16 width, byte *msg); void PromptWait(void); -unsigned char *SeekToString(unsigned char *bank, unsigned int num); -unsigned char *SeekToStringScr(unsigned char *bank, unsigned int num, unsigned char **ptr); +byte *SeekToString(byte *bank, uint16 num); +byte *SeekToStringScr(byte *bank, uint16 num, byte **ptr); } // End of namespace Chamber diff --git a/engines/chamber/input.cpp b/engines/chamber/input.cpp index 6fdc6dd009d..16b50ee3992 100644 --- a/engines/chamber/input.cpp +++ b/engines/chamber/input.cpp @@ -32,17 +32,17 @@ namespace Chamber { -unsigned char have_mouse; -unsigned char key_held; -volatile unsigned char key_direction; -volatile unsigned char key_code; -volatile unsigned char esc_pressed; -unsigned char buttons_repeat = 0; -unsigned char buttons; -unsigned char right_button; -unsigned char key_direction_old; -unsigned char accell_countdown; -unsigned int accelleration = 1; +byte have_mouse; +byte key_held; +volatile byte key_direction; +volatile byte key_code; +volatile byte esc_pressed; +byte buttons_repeat = 0; +byte buttons; +byte right_button; +byte key_direction_old; +byte accell_countdown; +uint16 accelleration = 1; byte mouseButtons = 0; byte ChamberEngine::readKeyboardChar() { @@ -72,7 +72,7 @@ byte ChamberEngine::readKeyboardChar() { void ClearKeyboard(void) { } -void SetInputButtons(unsigned char keys) { +void SetInputButtons(byte keys) { if (keys && buttons_repeat) { /*ignore buttons repeat*/ buttons = 0; @@ -86,14 +86,14 @@ void SetInputButtons(unsigned char keys) { buttons_repeat = keys; } -unsigned char PollMouse(void) { +byte PollMouse(void) { PollInput(); return buttons; } -unsigned char PollKeyboard(void) { - unsigned char direction = key_direction; +byte PollKeyboard(void) { + byte direction = key_direction; if (direction && direction == key_direction_old) { if (++accell_countdown == 10) { accelleration++; @@ -112,7 +112,7 @@ unsigned char PollKeyboard(void) { cursor_x = 304; } else { cursor_x -= accelleration; - if ((signed int)cursor_x < 0) + if ((int16)cursor_x < 0) cursor_x = 0; } } @@ -124,7 +124,7 @@ unsigned char PollKeyboard(void) { cursor_y = 184; } else { cursor_y -= accelleration; - if ((signed char)cursor_y < 0) + if ((int8)cursor_y < 0) cursor_y = 0; } } @@ -189,7 +189,7 @@ void ProcessInput(void) { void KeyboardIsr() { warning("STUB: KeyboardIsr()"); #if 0 - unsigned char scan, strobe; + byte scan, strobe; scan = inportb(0x60); /*consume scan from kbd. controller*/ strobe = inportb(0x61); diff --git a/engines/chamber/input.h b/engines/chamber/input.h index b7899b0db7b..6504dc14126 100644 --- a/engines/chamber/input.h +++ b/engines/chamber/input.h @@ -25,20 +25,20 @@ namespace Chamber { -extern unsigned char buttons; -extern unsigned char right_button; +extern byte buttons; +extern byte right_button; -extern unsigned char have_mouse; +extern byte have_mouse; -extern volatile unsigned char key_direction; -extern volatile unsigned char key_code; -extern unsigned char key_held; +extern volatile byte key_direction; +extern volatile byte key_code; +extern byte key_held; void ClearKeyboard(void); -unsigned char PollMouse(void); -unsigned char PollKeyboard(void); -void SetInputButtons(unsigned char keys); +byte PollMouse(void); +byte PollKeyboard(void); +void SetInputButtons(byte keys); void PollInput(void); void ProcessInput(void); diff --git a/engines/chamber/invent.cpp b/engines/chamber/invent.cpp index 4591b756a95..0e72f89db2d 100644 --- a/engines/chamber/invent.cpp +++ b/engines/chamber/invent.cpp @@ -35,15 +35,15 @@ namespace Chamber { #define INVENTORY_SPOTS_MAX (4 * 4) struct { - unsigned char sx; - unsigned char ex; - unsigned char sy; - unsigned char ey; - unsigned char name; - unsigned char unkn5; - unsigned short command; - unsigned char itemidx; - unsigned char unkn9; + byte sx; + byte ex; + byte sy; + byte ey; + byte name; + byte unkn5; + uint16 command; + byte itemidx; + byte unkn9; } inventory_spots[] = { {58, 62, 56, 72, 0, 0, 0, 0, 0}, {62, 66, 56, 72, 0, 0, 0, 0, 0}, @@ -64,15 +64,15 @@ struct { }; -unsigned char inv_count = 0; /*TODO: pass this as param?*/ -unsigned char inv_bgcolor = 0; /*TODO: pass this as param?*/ +byte inv_count = 0; /*TODO: pass this as param?*/ +byte inv_bgcolor = 0; /*TODO: pass this as param?*/ /*Filter items and put them inventory box, then draw it if non-empty*/ -void DrawInventoryBox(unsigned short filtermask, unsigned short filtervalue) { - int i; - unsigned char count = 0; +void DrawInventoryBox(uint16 filtermask, uint16 filtervalue) { + int16 i; + byte count = 0; for (i = 0; i < MAX_INV_ITEMS; i++) { - unsigned short flags = (inventory_items[i].flags2 << 8) | inventory_items[i].flags; + uint16 flags = (inventory_items[i].flags2 << 8) | inventory_items[i].flags; if ((flags & filtermask) != filtervalue) continue; if (count == 0) { @@ -89,8 +89,8 @@ void DrawInventoryBox(unsigned short filtermask, unsigned short filtervalue) { inv_count = count; } -void CheckInventoryItemHover(unsigned char count) { - int i; +void CheckInventoryItemHover(byte count) { + int16 i; for (i = 0; i < count; i++) { if (IsCursorInRect((rect_t *)&inventory_spots[i])) { the_command = inventory_spots[i].command; @@ -107,7 +107,7 @@ void CheckInventoryItemHover(unsigned char count) { the_command = 0; } -void OpenInventory(unsigned short filtermask, unsigned short filtervalue) { +void OpenInventory(uint16 filtermask, uint16 filtervalue) { the_command = 0; CGA_BackupImageReal(CGA_CalcXY_p(232 / 4, 56), 64 / 4, 64); DrawInventoryBox(filtermask, filtervalue); diff --git a/engines/chamber/invent.h b/engines/chamber/invent.h index a6abf9445bb..4e5cfcafabe 100644 --- a/engines/chamber/invent.h +++ b/engines/chamber/invent.h @@ -25,12 +25,12 @@ namespace Chamber { -extern unsigned char inv_count; -extern unsigned char inv_bgcolor; +extern byte inv_count; +extern byte inv_bgcolor; -void DrawInventoryBox(unsigned short filtermask, unsigned short filtervalue); +void DrawInventoryBox(uint16 filtermask, uint16 filtervalue); -void OpenInventory(unsigned short filtermask, unsigned short filtervalue); +void OpenInventory(uint16 filtermask, uint16 filtervalue); } // End of namespace Chamber diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp index ed7b6448651..62af40d5eaa 100644 --- a/engines/chamber/kult.cpp +++ b/engines/chamber/kult.cpp @@ -44,7 +44,7 @@ namespace Chamber { -unsigned short cpu_speed_delay; +uint16 cpu_speed_delay; /* Prompt user to insert disk #2 to any drive @@ -53,7 +53,7 @@ void AskDisk2(void) { DrawMessage(SeekToString(vepci_data, 179), frontbuffer); } -void SaveToFile(char *filename, void *data, unsigned int size) { +void SaveToFile(char *filename, void *data, uint16 size) { warning("STUB: SaveToFile(%s, data, %d)", filename, size); #if 0 FILE *f = fopen(filename, "wb"); @@ -62,16 +62,16 @@ void SaveToFile(char *filename, void *data, unsigned int size) { #endif } -int LoadSplash(const char *filename) { +int16 LoadSplash(const char *filename) { if (!LoadFile(filename, scratch_mem1)) return 0; decompress(scratch_mem1 + 8, backbuffer); /* skip compressed/decompressed size fields */ return 1; } -unsigned int BenchmarkCpu(void) { - unsigned char t; - unsigned int cycles = 0; +uint16 BenchmarkCpu(void) { + byte t; + uint16 cycles = 0; for (t = script_byte_vars.timer_ticks; t == script_byte_vars.timer_ticks;) ; for (t = script_byte_vars.timer_ticks; t == script_byte_vars.timer_ticks;) cycles++; return cycles; @@ -95,7 +95,7 @@ void TRAP() { } /* Main Game Loop */ -void GameLoop(unsigned char *target) { +void GameLoop(byte *target) { for (;;) { #if 1 AnimateSpots(target); @@ -202,7 +202,7 @@ Common::Error ChamberEngine::run() { SwitchToGraphicsMode(); - unsigned char c; + byte c; /* Load title screen */ if (!LoadSplash("PRES.BIN")) diff --git a/engines/chamber/menu.cpp b/engines/chamber/menu.cpp index 61aafc7d57f..b57db819b51 100644 --- a/engines/chamber/menu.cpp +++ b/engines/chamber/menu.cpp @@ -32,8 +32,8 @@ namespace Chamber { -unsigned char act_menu_x = 0; -unsigned char act_menu_y = 0; +byte act_menu_x = 0; +byte act_menu_y = 0; rect_t *act_dot_rects_cur; rect_t *act_dot_rects_end; @@ -41,7 +41,7 @@ rect_t *act_dot_rects_end; /*choice dots placement on actions menu*/ rect_t act_dot_rects[8 + 1]; struct { - unsigned char x, y; + byte x, y; } act_dot_coords[8] = { { 2, 0}, { 8, 32}, @@ -54,7 +54,7 @@ struct { }; /*Handle keyboard keys in actions menu (to cycle through choices with directional keys)*/ -unsigned char PollKeyboardInActionsMenu(void) { +byte PollKeyboardInActionsMenu(void) { if (!key_direction) { key_held = 0; return key_code; @@ -78,7 +78,7 @@ unsigned char PollKeyboardInActionsMenu(void) { /*Handle player input in actions menu*/ void PollInputInActionsMenu(void) { - unsigned char keys; + byte keys; if (have_mouse) keys = PollMouse(); else @@ -87,11 +87,11 @@ void PollInputInActionsMenu(void) { } /*Draw actions menu and process its choices*/ -void ActionsMenu(unsigned char **pinfo) { - unsigned char x, y; - unsigned char choices; - int i, choice, numchoices; - unsigned char *menurecs; +void ActionsMenu(byte **pinfo) { + byte x, y; + byte choices; + int16 i, choice, numchoices; + byte *menurecs; last_object_hint = object_hint; @@ -184,7 +184,7 @@ void ActionsMenu(unsigned char **pinfo) { } /*TODO: maybe rename to SpotsLoop*/ -void MenuLoop(unsigned char spotmask, unsigned char spotvalue) { +void MenuLoop(byte spotmask, byte spotvalue) { ProcessInput(); do { PollInput(); @@ -214,7 +214,7 @@ rect_t menu_buttons_rects[] = { }; void CheckMenuCommandHover(void) { - int i; + int16 i; for (i = 0; i < 8; i++) { if (IsCursorInRect(&menu_buttons_rects[i])) { the_command = 0xA001 + i; @@ -242,7 +242,7 @@ rect_t psi_buttons_rects[] = { void CheckPsiCommandHover(void) { /*TODO: maybe merge it with CheckMenuCommandHover()*/ - int i; + int16 i; for (i = 0; i < 8; i++) { if (IsCursorInRect(&psi_buttons_rects[i])) { the_command = 0xA00A + i; diff --git a/engines/chamber/menu.h b/engines/chamber/menu.h index 0fce6765067..907a7d4e88e 100644 --- a/engines/chamber/menu.h +++ b/engines/chamber/menu.h @@ -25,11 +25,11 @@ namespace Chamber { -extern unsigned char act_menu_x; -extern unsigned char act_menu_y; +extern byte act_menu_x; +extern byte act_menu_y; -void ActionsMenu(unsigned char **pinfo); -void MenuLoop(unsigned char spotmask, unsigned char spotvalue); +void ActionsMenu(byte **pinfo); +void MenuLoop(byte spotmask, byte spotvalue); void ProcessMenu(void); void CheckMenuCommandHover(void); diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp index dc9c8e74b8c..74256e7acb3 100644 --- a/engines/chamber/portrait.cpp +++ b/engines/chamber/portrait.cpp @@ -34,27 +34,27 @@ namespace Chamber { -extern unsigned short cpu_speed_delay; +extern uint16 cpu_speed_delay; -unsigned char *cur_image_pixels; -unsigned char cur_image_size_w; -unsigned char cur_image_size_h; -unsigned char cur_image_coords_x; -unsigned char cur_image_coords_y; -unsigned int cur_image_offs; -unsigned int cur_image_end; -unsigned char cur_image_idx; -unsigned char cur_image_anim1; -unsigned char cur_image_anim2; -unsigned int cur_frame_width; +byte *cur_image_pixels; +byte cur_image_size_w; +byte cur_image_size_h; +byte cur_image_coords_x; +byte cur_image_coords_y; +uint16 cur_image_offs; +uint16 cur_image_end; +byte cur_image_idx; +byte cur_image_anim1; +byte cur_image_anim2; +uint16 cur_frame_width; typedef struct persframe_t { - unsigned char height; - unsigned char width; - unsigned char topbot; /*border and fill colors*/ - unsigned char fill; - unsigned char left; - unsigned char right; + byte height; + byte width; + byte topbot; /*border and fill colors*/ + byte fill; + byte left; + byte right; } persframe_t; persframe_t pers_frames[] = { @@ -69,8 +69,8 @@ persframe_t pers_frames[] = { {27, 34, 0, 0, 0, 0} }; -void MakePortraitFrame(unsigned char index, unsigned char *target) { - unsigned int i; +void MakePortraitFrame(byte index, byte *target) { + uint16 i; persframe_t *pframe = &pers_frames[index]; *target++ = pframe->height; *target++ = pframe->width; @@ -90,11 +90,11 @@ void MakePortraitFrame(unsigned char index, unsigned char *target) { /* Superimpose source sprite data over target image data */ -void MergeImageAndSpriteData(unsigned char *target, signed int pitch, unsigned char *source, unsigned int w, unsigned int h) { - unsigned int x; +void MergeImageAndSpriteData(byte *target, int16 pitch, byte *source, uint16 w, uint16 h) { + uint16 x; while (h--) { for (x = 0; x < w; x++) { - unsigned char m = *source++; + byte m = *source++; *target &= m; *target++ |= *source++; } @@ -106,12 +106,12 @@ void MergeImageAndSpriteData(unsigned char *target, signed int pitch, unsigned c /* Superimpose horizontally-flipped source sprite data over target image data */ -void MergeImageAndSpriteDataFlip(unsigned char *target, signed int pitch, unsigned char *source, unsigned int w, unsigned int h) { - unsigned int x; +void MergeImageAndSpriteDataFlip(byte *target, int16 pitch, byte *source, uint16 w, uint16 h) { + uint16 x; target += w - 1; while (h--) { for (x = 0; x < w; x++) { - unsigned char m = cga_pixel_flip[*source++]; + byte m = cga_pixel_flip[*source++]; *target &= m; *target |= cga_pixel_flip[*source++]; target -= 1; @@ -124,13 +124,13 @@ void MergeImageAndSpriteDataFlip(unsigned char *target, signed int pitch, unsign /* Build portrait from multiple pers sprites */ -unsigned char *LoadPortrait(unsigned char **pinfo, unsigned char *end) { +byte *LoadPortrait(byte **pinfo, byte *end) { while (*pinfo != end) { - unsigned char index; - unsigned int flags; - signed int pitch; - unsigned char *buffer, *sprite; - unsigned char sprw, sprh; + byte index; + uint16 flags; + int16 pitch; + byte *buffer, *sprite; + byte sprw, sprh; index = *((*pinfo)++); flags = *((*pinfo)++); @@ -154,8 +154,8 @@ unsigned char *LoadPortrait(unsigned char **pinfo, unsigned char *end) { return sprit_load_buffer + 2; } -unsigned char *LoadPortraitWithFrame(unsigned char index) { - unsigned char *pinfo, *end; +byte *LoadPortraitWithFrame(byte index) { + byte *pinfo, *end; pinfo = SeekToEntry(icone_data, index, &end); MakePortraitFrame(*pinfo++, sprit_load_buffer + 2); return LoadPortrait(&pinfo, end); @@ -165,12 +165,12 @@ unsigned char *LoadPortraitWithFrame(unsigned char index) { #define STATIC_ANIMS_MAX 24 struct { - unsigned char index; - unsigned char image; - unsigned char x; - unsigned char y; - unsigned char anim1; - unsigned char anim2; + byte index; + byte image; + byte x; + byte y; + byte anim1; + byte anim2; } static_anims[] = { { 24, 13, 35, 10, 4, 5}, { 88, 42, 35, 10, 11, 12}, @@ -198,9 +198,9 @@ struct { {248, 117, 16, 2, 33, 33} }; -unsigned char SelectCurrentAnim(unsigned char *x, unsigned char *y, unsigned char *index) { - int i; - unsigned char aniidx = ((pers_t *)(script_vars[ScrPool8_CurrentPers]))->index & ~7; +byte SelectCurrentAnim(byte *x, byte *y, byte *index) { + int16 i; + byte aniidx = ((pers_t *)(script_vars[ScrPool8_CurrentPers]))->index & ~7; for (i = 0; i < STATIC_ANIMS_MAX; i++) { if (static_anims[i].index == aniidx) { *x = static_anims[i].x; @@ -216,10 +216,10 @@ unsigned char SelectCurrentAnim(unsigned char *x, unsigned char *y, unsigned cha } void DrawBoxAroundSpot(void) { - unsigned char *buffer; - unsigned int w, h; - unsigned int ofs; - unsigned int x, y; + byte *buffer; + uint16 w, h; + uint16 ofs; + uint16 x, y; if (*spot_sprite == 0) return; @@ -228,8 +228,8 @@ void DrawBoxAroundSpot(void) { buffer = *spot_sprite; - h = *(unsigned char *)(buffer + 0); - w = *(unsigned char *)(buffer + 1); + h = *(byte *)(buffer + 0); + w = *(byte *)(buffer + 1); ofs = *(uint16 *)(buffer + 2); /*decode ofs back to x:y*/ @@ -251,10 +251,10 @@ void DrawBoxAroundSpot(void) { /*Get on-screen image as specified by script to temp buffer and register it with dirty rect of kind 2 If rmb is pressed, draw it immediately and return 0 */ -int DrawPortrait(unsigned char **desc, unsigned char *x, unsigned char *y, unsigned char *width, unsigned char *height) { - unsigned char index; - unsigned char xx, yy; - unsigned char *image; +int16 DrawPortrait(byte **desc, byte *x, byte *y, byte *width, byte *height) { + byte index; + byte xx, yy; + byte *image; index = *((*desc)++); if (index == 0xFF) { @@ -292,7 +292,7 @@ int DrawPortrait(unsigned char **desc, unsigned char *x, unsigned char *y, unsig return 1; } -void BlinkWithSound(unsigned char color) { +void BlinkWithSound(byte color) { CGA_ColorSelect(color); PlaySound(144); SelectPalette(); @@ -306,9 +306,9 @@ void BlinkToWhite(void) { BlinkWithSound(0x3F); } -void AnimPortrait(unsigned char layer, unsigned char index, unsigned char delay) { - unsigned char *ani, *ani_end; - unsigned char temp; +void AnimPortrait(byte layer, byte index, byte delay) { + byte *ani, *ani_end; + byte temp; SelectCurrentAnim(&temp, &temp, &temp); @@ -321,12 +321,12 @@ void AnimPortrait(unsigned char layer, unsigned char index, unsigned char delay) cur_image_pixels = sprit_load_buffer + 2 + 2; while (ani != ani_end) { - unsigned char kind; - unsigned char x, y; - unsigned char width, height; - unsigned int offs; + byte kind; + byte x, y; + byte width, height; + uint16 offs; - unsigned char portrait = *ani++; + byte portrait = *ani++; LoadPortraitWithFrame(portrait - 1); if (*ani == 0xFF) { ani++; @@ -342,7 +342,7 @@ void AnimPortrait(unsigned char layer, unsigned char index, unsigned char delay) else BlinkToWhite(); } else { - int i; + int16 i; while (delay--) for (i = 0; i < cpu_speed_delay; i++) ; /*TODO: FIXME weak delay*/ } } diff --git a/engines/chamber/portrait.h b/engines/chamber/portrait.h index e7eb3919988..699f5847df9 100644 --- a/engines/chamber/portrait.h +++ b/engines/chamber/portrait.h @@ -25,25 +25,25 @@ namespace Chamber { -extern unsigned char *cur_image_pixels; -extern unsigned char cur_image_size_w; -extern unsigned char cur_image_size_h; -extern unsigned char cur_image_coords_x; -extern unsigned char cur_image_coords_y; -extern unsigned int cur_image_offs; -extern unsigned int cur_image_end; -extern unsigned char cur_image_idx; -extern unsigned char cur_image_anim1; -extern unsigned char cur_image_anim2; -extern unsigned int cur_frame_width; +extern byte *cur_image_pixels; +extern byte cur_image_size_w; +extern byte cur_image_size_h; +extern byte cur_image_coords_x; +extern byte cur_image_coords_y; +extern uint16 cur_image_offs; +extern uint16 cur_image_end; +extern byte cur_image_idx; +extern byte cur_image_anim1; +extern byte cur_image_anim2; +extern uint16 cur_frame_width; -int DrawPortrait(unsigned char **desc, unsigned char *x, unsigned char *y, unsigned char *width, unsigned char *height); -void AnimPortrait(unsigned char layer, unsigned char index, unsigned char delay); +int16 DrawPortrait(byte **desc, byte *x, byte *y, byte *width, byte *height); +void AnimPortrait(byte layer, byte index, byte delay); void DrawBoxAroundSpot(void); -void MergeImageAndSpriteData(unsigned char *target, signed int pitch, unsigned char *source, unsigned int w, unsigned int h); -void MergeImageAndSpriteDataFlip(unsigned char *target, signed int pitch, unsigned char *source, unsigned int w, unsigned int h); +void MergeImageAndSpriteData(byte *target, int16 pitch, byte *source, uint16 w, uint16 h); +void MergeImageAndSpriteDataFlip(byte *target, int16 pitch, byte *source, uint16 w, uint16 h); void BlinkToRed(void); void BlinkToWhite(void); diff --git a/engines/chamber/print.cpp b/engines/chamber/print.cpp index d6b896cbc5d..a83d916deca 100644 --- a/engines/chamber/print.cpp +++ b/engines/chamber/print.cpp @@ -29,18 +29,18 @@ namespace Chamber { -unsigned char *cur_str_end; +byte *cur_str_end; -unsigned char draw_x; -unsigned char draw_y; +byte draw_x; +byte draw_y; /* Calculate number of string's character until whitespace Return current word's characters count and the next word ptr */ -unsigned char *CalcStringWordWidth(unsigned char *str, unsigned int *w) { - unsigned int ww = 0; - unsigned char c; +byte *CalcStringWordWidth(byte *str, uint16 *w) { + uint16 ww = 0; + byte c; if ((*str & 0x3F) == 0) { str++; @@ -69,9 +69,9 @@ unsigned char *CalcStringWordWidth(unsigned char *str, unsigned int *w) { /* Calculate number of text's words and max word width (in chars) */ -void CalcStringSize(unsigned char *str, unsigned int *w, unsigned int *n) { - unsigned int ww = 0, nw = 0, lw; - unsigned char *s = str; +void CalcStringSize(byte *str, uint16 *w, uint16 *n) { + uint16 ww = 0, nw = 0, lw; + byte *s = str; do { s = CalcStringWordWidth(s, &lw); if (lw > ww) @@ -86,9 +86,9 @@ void CalcStringSize(unsigned char *str, unsigned int *w, unsigned int *n) { Calculate number of text's lines with respect to set max width If a line is longer, wrap it to the next line */ -unsigned int CalcTextLines(unsigned char *str) { - unsigned int lines = 1; - unsigned int w, left = char_draw_max_width; +uint16 CalcTextLines(byte *str) { + uint16 lines = 1; + uint16 w, left = char_draw_max_width; while (str != cur_str_end) { str = CalcStringWordWidth(str, &w); if (left > w) { @@ -102,18 +102,18 @@ unsigned int CalcTextLines(unsigned char *str) { } /*; translate 1-bit raster (4 columns per byte) to 4 2-bit color pixels*/ -unsigned char chars_color_bonw[] = {0xFF, 0xFC, 0xF3, 0xF0, 0xCF, 0xCC, 0xC3, 0xC0, 0x3F, 0x3C, 0x33, 0x30, 0x0F, 0x0C, 3, 0}; /*black on white*/ -unsigned char chars_color_bonc[] = {0x55, 0x54, 0x51, 0x50, 0x45, 0x44, 0x41, 0x40, 0x15, 0x14, 0x11, 0x10, 5, 4, 1, 0}; /*black on cyan*/ -unsigned char chars_color_wonb[] = { 0, 3, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F, 0xC0, 0xC3, 0xCC, 0xCF, 0xF0, 0xF3, 0xFC, 0xFF}; /*white on black*/ -unsigned char chars_color_wonc[] = {0x55, 0x57, 0x5D, 0x5F, 0x75, 0xF7, 0x7D, 0x7F, 0xD5, 0xD7, 0xDD, 0xDF, 0xF5, 0xF7, 0xFD, 0xFF}; /*white on cyan*/ +byte chars_color_bonw[] = {0xFF, 0xFC, 0xF3, 0xF0, 0xCF, 0xCC, 0xC3, 0xC0, 0x3F, 0x3C, 0x33, 0x30, 0x0F, 0x0C, 3, 0}; /*black on white*/ +byte chars_color_bonc[] = {0x55, 0x54, 0x51, 0x50, 0x45, 0x44, 0x41, 0x40, 0x15, 0x14, 0x11, 0x10, 5, 4, 1, 0}; /*black on cyan*/ +byte chars_color_wonb[] = { 0, 3, 0x0C, 0x0F, 0x30, 0x33, 0x3C, 0x3F, 0xC0, 0xC3, 0xCC, 0xCF, 0xF0, 0xF3, 0xFC, 0xFF}; /*white on black*/ +byte chars_color_wonc[] = {0x55, 0x57, 0x5D, 0x5F, 0x75, 0xF7, 0x7D, 0x7F, 0xD5, 0xD7, 0xDD, 0xDF, 0xF5, 0xF7, 0xFD, 0xFF}; /*white on cyan*/ -void PrintStringPad(unsigned int w, unsigned char *target) { +void PrintStringPad(uint16 w, byte *target) { while (w--) CGA_PrintChar(0, target); } -unsigned char *PrintWord(unsigned char *str, unsigned char *target) { - unsigned char c, f; +byte *PrintWord(byte *str, byte *target) { + byte c, f; if ((*str & 0x3F) == 0) goto skip_1st; while (str != cur_str_end) { @@ -143,10 +143,10 @@ skip_1st: return str; } -unsigned char *PrintStringLine(unsigned char *str, unsigned int *left, unsigned char *target) { - unsigned int mw = char_draw_max_width; +byte *PrintStringLine(byte *str, uint16 *left, byte *target) { + uint16 mw = char_draw_max_width; for (;;) { - unsigned int w; + uint16 w; CalcStringWordWidth(str, &w); if (mw < w) break; @@ -161,8 +161,8 @@ unsigned char *PrintStringLine(unsigned char *str, unsigned int *left, unsigned return str; } -unsigned char *PrintStringPadded(unsigned char *str, unsigned char *target) { - unsigned int w, n; +byte *PrintStringPadded(byte *str, byte *target) { + uint16 w, n; CalcStringSize(str, &w, &n); if (w + 2 >= char_draw_max_width) char_draw_max_width = w + 2; @@ -172,10 +172,10 @@ unsigned char *PrintStringPadded(unsigned char *str, unsigned char *target) { return str; } -void PrintStringCentered(unsigned char *str, unsigned char *target) { - unsigned char pad = 0; - unsigned int ww = 0, lw; - unsigned char *s = str; +void PrintStringCentered(byte *str, byte *target) { + byte pad = 0; + uint16 ww = 0, lw; + byte *s = str; do { s = CalcStringWordWidth(s, &lw); ww += lw; @@ -190,8 +190,8 @@ void PrintStringCentered(unsigned char *str, unsigned char *target) { PrintStringPadded(str, target); } -void CGA_DrawTextBox(unsigned char *msg, unsigned char *target) { - unsigned int x, y, w, i; +void CGA_DrawTextBox(byte *msg, byte *target) { + uint16 x, y, w, i; char_xlat_table = chars_color_bonc; @@ -226,9 +226,9 @@ void CGA_DrawTextBox(unsigned char *msg, unsigned char *target) { CGA_DrawVLine(x + w, y, 1, 0, target); /*bottom right corner*/ } -void DrawMessage(unsigned char *msg, unsigned char *target) { - unsigned int x, y; - unsigned int w, h; +void DrawMessage(byte *msg, byte *target) { + uint16 x, y; + uint16 w, h; CalcStringSize(msg, &w, &h); char_draw_max_width = (h < 5) ? (w + 2) : 20; char_draw_max_height = CalcTextLines(msg) * 6 + 7; @@ -254,9 +254,9 @@ void DrawMessage(unsigned char *msg, unsigned char *target) { #if 1 void DebugMessage(char *msg, ...) { - int i; - unsigned char c; - unsigned char m[256]; + int16 i; + byte c; + byte m[256]; va_list ap; va_start(ap, msg); diff --git a/engines/chamber/print.h b/engines/chamber/print.h index acd15cdb4ab..93f1e01adfa 100644 --- a/engines/chamber/print.h +++ b/engines/chamber/print.h @@ -25,22 +25,22 @@ namespace Chamber { -extern unsigned char *cur_str_end; +extern byte *cur_str_end; -extern unsigned char draw_x; -extern unsigned char draw_y; +extern byte draw_x; +extern byte draw_y; -extern unsigned char chars_color_bonw[]; -extern unsigned char chars_color_bonc[]; -extern unsigned char chars_color_wonb[]; -extern unsigned char chars_color_wonc[]; +extern byte chars_color_bonw[]; +extern byte chars_color_bonc[]; +extern byte chars_color_wonb[]; +extern byte chars_color_wonc[]; -void PrintStringCentered(unsigned char *str, unsigned char *target); -unsigned char *PrintStringPadded(unsigned char *str, unsigned char *target); +void PrintStringCentered(byte *str, byte *target); +byte *PrintStringPadded(byte *str, byte *target); -void DrawMessage(unsigned char *msg, unsigned char *target); +void DrawMessage(byte *msg, byte *target); -void CGA_DrawTextBox(unsigned char *msg, unsigned char *target); +void CGA_DrawTextBox(byte *msg, byte *target); } // End of namespace Chamber diff --git a/engines/chamber/r_other.cpp b/engines/chamber/r_other.cpp index 0fc95cf2c98..5075707c663 100644 --- a/engines/chamber/r_other.cpp +++ b/engines/chamber/r_other.cpp @@ -26,16 +26,16 @@ namespace Chamber { -unsigned char arpla_data[RES_ARPLA_MAX]; -unsigned char aleat_data[RES_ALEAT_MAX]; -unsigned char icone_data[RES_ICONE_MAX]; -unsigned char souco_data[RES_SOUCO_MAX]; -unsigned char souri_data[RES_SOURI_MAX]; -unsigned char mursm_data[RES_MURSM_MAX]; -unsigned char gauss_data[RES_GAUSS_MAX]; -unsigned char lutin_data[RES_LUTIN_MAX]; -unsigned char anima_data[RES_ANIMA_MAX]; -unsigned char anico_data[RES_ANICO_MAX]; -unsigned char zones_data[RES_ZONES_MAX]; +byte arpla_data[RES_ARPLA_MAX]; +byte aleat_data[RES_ALEAT_MAX]; +byte icone_data[RES_ICONE_MAX]; +byte souco_data[RES_SOUCO_MAX]; +byte souri_data[RES_SOURI_MAX]; +byte mursm_data[RES_MURSM_MAX]; +byte gauss_data[RES_GAUSS_MAX]; +byte lutin_data[RES_LUTIN_MAX]; +byte anima_data[RES_ANIMA_MAX]; +byte anico_data[RES_ANICO_MAX]; +byte zones_data[RES_ZONES_MAX]; } // End of namespace Chamber diff --git a/engines/chamber/r_pers.cpp b/engines/chamber/r_pers.cpp index ed68259a93b..bf6b87f2dbf 100644 --- a/engines/chamber/r_pers.cpp +++ b/engines/chamber/r_pers.cpp @@ -26,10 +26,10 @@ namespace Chamber { -unsigned char pers1_data[RES_PERS1_MAX]; -unsigned char pers2_data[RES_PERS2_MAX]; +byte pers1_data[RES_PERS1_MAX]; +byte pers2_data[RES_PERS2_MAX]; -unsigned char desci_data[RES_DESCI_MAX]; -unsigned char diali_data[RES_DIALI_MAX]; +byte desci_data[RES_DESCI_MAX]; +byte diali_data[RES_DIALI_MAX]; } // End of namespace Chamber diff --git a/engines/chamber/r_puzzl.cpp b/engines/chamber/r_puzzl.cpp index df72c7ae593..21b0d9c1e35 100644 --- a/engines/chamber/r_puzzl.cpp +++ b/engines/chamber/r_puzzl.cpp @@ -25,6 +25,6 @@ namespace Chamber { -unsigned char puzzl_data[RES_PUZZL_MAX]; +byte puzzl_data[RES_PUZZL_MAX]; } // End of namespace Chamber diff --git a/engines/chamber/r_sprit.cpp b/engines/chamber/r_sprit.cpp index 224476cf246..9b180998a5d 100644 --- a/engines/chamber/r_sprit.cpp +++ b/engines/chamber/r_sprit.cpp @@ -25,6 +25,6 @@ namespace Chamber { -unsigned char sprit_data[RES_SPRIT_MAX]; +byte sprit_data[RES_SPRIT_MAX]; } // End of namespace Chamber diff --git a/engines/chamber/r_templ.cpp b/engines/chamber/r_templ.cpp index 50829bea97a..fef91f635ac 100644 --- a/engines/chamber/r_templ.cpp +++ b/engines/chamber/r_templ.cpp @@ -25,6 +25,6 @@ namespace Chamber { -unsigned char templ_data[RES_TEMPL_MAX]; +byte templ_data[RES_TEMPL_MAX]; } // End of namespace Chamber diff --git a/engines/chamber/r_texts.cpp b/engines/chamber/r_texts.cpp index d8195e39f3f..1fba4c6cdc4 100644 --- a/engines/chamber/r_texts.cpp +++ b/engines/chamber/r_texts.cpp @@ -26,7 +26,7 @@ namespace Chamber { -unsigned char vepci_data[RES_VEPCI_MAX]; -unsigned char motsi_data[RES_MOTSI_MAX]; +byte vepci_data[RES_VEPCI_MAX]; +byte motsi_data[RES_MOTSI_MAX]; } // End of namespace Chamber diff --git a/engines/chamber/resdata.cpp b/engines/chamber/resdata.cpp index 9ab156beae3..c83b122e428 100644 --- a/engines/chamber/resdata.cpp +++ b/engines/chamber/resdata.cpp @@ -30,15 +30,15 @@ namespace Chamber { extern void AskDisk2(void); -extern int LoadSplash(const char *filename); +extern int16 LoadSplash(const char *filename); /* Get bank entry TODO: port SeekToString to this routine */ -unsigned char *SeekToEntry(unsigned char *bank, unsigned int num, unsigned char **end) { - unsigned char len; - unsigned char *p = bank; +byte *SeekToEntry(byte *bank, uint16 num, byte **end) { + byte len; + byte *p = bank; while (num--) { len = *p; @@ -49,9 +49,9 @@ unsigned char *SeekToEntry(unsigned char *bank, unsigned int num, unsigned char return p + 1; } -unsigned char *SeekToEntryW(unsigned char *bank, unsigned int num, unsigned char **end) { - unsigned int len; - unsigned char *p = bank; +byte *SeekToEntryW(byte *bank, uint16 num, byte **end) { + uint16 len; + byte *p = bank; while (num--) { len = p[0] | (p[1] << 8); @@ -62,7 +62,7 @@ unsigned char *SeekToEntryW(unsigned char *bank, unsigned int num, unsigned char return p + 2; } -unsigned int LoadFile(const char *filename, unsigned char *buffer) { +uint16 LoadFile(const char *filename, byte *buffer) { Common::File in; in.open(filename); @@ -73,12 +73,12 @@ unsigned int LoadFile(const char *filename, unsigned char *buffer) { return in.read(buffer, 0xFFFF0); } -unsigned int SaveFile(char *filename, unsigned char *buffer, unsigned int size) { +uint16 SaveFile(char *filename, byte *buffer, uint16 size) { warning("STUB: SaveFile(%s, buffer, %d)", filename, size); return 0; #if 0 - int f; - int wlen; + int16 f; + int16 wlen; f = open(filename, O_RDONLY | O_BINARY); if (f == -1) return 0; @@ -86,12 +86,12 @@ unsigned int SaveFile(char *filename, unsigned char *buffer, unsigned int size) close(f); if (wlen == -1) return 0; - return (unsigned int)wlen; + return (uint16)wlen; #endif } -int LoadFilesList(ResEntry_t *entries) { - int i; +int16 LoadFilesList(ResEntry_t *entries) { + int16 i; for (i = 0; entries[i].name[0] != '$'; i++) { if (!LoadFile(entries[i].name, (byte *)entries[i].buffer)) return 0; @@ -100,17 +100,17 @@ int LoadFilesList(ResEntry_t *entries) { } -unsigned char arpla_data[RES_ARPLA_MAX]; -unsigned char aleat_data[RES_ALEAT_MAX]; -unsigned char icone_data[RES_ICONE_MAX]; -unsigned char souco_data[RES_SOUCO_MAX]; -unsigned char souri_data[RES_SOURI_MAX]; -unsigned char mursm_data[RES_MURSM_MAX]; -unsigned char gauss_data[RES_GAUSS_MAX]; -unsigned char lutin_data[RES_LUTIN_MAX]; -unsigned char anima_data[RES_ANIMA_MAX]; -unsigned char anico_data[RES_ANICO_MAX]; -unsigned char zones_data[RES_ZONES_MAX]; +byte arpla_data[RES_ARPLA_MAX]; +byte aleat_data[RES_ALEAT_MAX]; +byte icone_data[RES_ICONE_MAX]; +byte souco_data[RES_SOUCO_MAX]; +byte souri_data[RES_SOURI_MAX]; +byte mursm_data[RES_MURSM_MAX]; +byte gauss_data[RES_GAUSS_MAX]; +byte lutin_data[RES_LUTIN_MAX]; +byte anima_data[RES_ANIMA_MAX]; +byte anico_data[RES_ANICO_MAX]; +byte zones_data[RES_ZONES_MAX]; ResEntry_t res_static[] = { {"ARPLA.BIN", arpla_data}, @@ -133,7 +133,7 @@ ResEntry_t res_static[] = { Load resident data files. Original game has all these data files embedded in the executable. NB! Static data includes the font file, don't use any text print routines before it's loaded. */ -int LoadStaticData() { +int16 LoadStaticData() { return LoadFilesList(res_static); } @@ -146,11 +146,11 @@ ResEntry_t res_texts[] = { /* Load strings data (commands/names) */ -int LoadVepciData() { +int16 LoadVepciData() { return LoadFilesList(res_texts); } -int LoadFond(void) { +int16 LoadFond(void) { return LoadSplash("FOND.BIN"); } @@ -160,7 +160,7 @@ ResEntry_t res_sprites[] = { {"$", NULL} }; -int LoadSpritesData(void) { +int16 LoadSpritesData(void) { return LoadFilesList(res_sprites); } @@ -170,7 +170,7 @@ ResEntry_t res_person[] = { {"$", NULL} }; -int LoadPersData(void) { +int16 LoadPersData(void) { /*Originally it tries to load pers1 + pers2 as a single contiguos resource, if have enough memory*/ /*If memory is low, neccessary file is loaded on demand, according to requested bank resource index*/ /*Here we load both parts to their own memory buffers then select one in LoadPersSprit()*/ @@ -185,7 +185,7 @@ ResEntry_t res_desci[] = { /* Load strings data (obj. descriptions) */ -int LoadDesciData(void) { +int16 LoadDesciData(void) { while (!LoadFilesList(res_desci)) AskDisk2(); return 1; @@ -199,7 +199,7 @@ ResEntry_t res_diali[] = { /* Load strings data (dialogs) */ -int LoadDialiData(void) { +int16 LoadDialiData(void) { while (!LoadFilesList(res_diali)) AskDisk2(); return 1; diff --git a/engines/chamber/resdata.h b/engines/chamber/resdata.h index ec57e31ac40..4c89631e0fe 100644 --- a/engines/chamber/resdata.h +++ b/engines/chamber/resdata.h @@ -53,52 +53,52 @@ typedef struct ResEntry_t { #define RES_MOTSI_MAX 1082 #define RES_VEPCI_MAX 1548 -extern unsigned char vepci_data[]; -extern unsigned char motsi_data[]; +extern byte vepci_data[]; +extern byte motsi_data[]; -extern unsigned char puzzl_data[]; -extern unsigned char sprit_data[]; +extern byte puzzl_data[]; +extern byte sprit_data[]; -extern unsigned char pers1_data[]; -extern unsigned char pers2_data[]; +extern byte pers1_data[]; +extern byte pers2_data[]; -extern unsigned char desci_data[]; -extern unsigned char diali_data[]; +extern byte desci_data[]; +extern byte diali_data[]; -extern unsigned char arpla_data[]; -extern unsigned char aleat_data[]; -extern unsigned char carpc_data[]; -extern unsigned char icone_data[]; -extern unsigned char souco_data[]; -extern unsigned char souri_data[]; -extern unsigned char templ_data[]; -extern unsigned char mursm_data[]; -extern unsigned char gauss_data[]; -extern unsigned char lutin_data[]; -extern unsigned char anima_data[]; -extern unsigned char anico_data[]; -extern unsigned char zones_data[]; +extern byte arpla_data[]; +extern byte aleat_data[]; +extern byte carpc_data[]; +extern byte icone_data[]; +extern byte souco_data[]; +extern byte souri_data[]; +extern byte templ_data[]; +extern byte mursm_data[]; +extern byte gauss_data[]; +extern byte lutin_data[]; +extern byte anima_data[]; +extern byte anico_data[]; +extern byte zones_data[]; -unsigned char *SeekToEntry(unsigned char *bank, unsigned int num, unsigned char **end); -unsigned char *SeekToEntryW(unsigned char *bank, unsigned int num, unsigned char **end); +byte *SeekToEntry(byte *bank, uint16 num, byte **end); +byte *SeekToEntryW(byte *bank, uint16 num, byte **end); -unsigned int LoadFile(const char *filename, unsigned char *buffer); -unsigned int SaveFile(char *filename, unsigned char *buffer, unsigned int size); -int LoadFilesList(ResEntry_t *entries); +uint16 LoadFile(const char *filename, byte *buffer); +uint16 SaveFile(char *filename, byte *buffer, uint16 size); +int16 LoadFilesList(ResEntry_t *entries); -int LoadStaticData(void); -int LoadFond(void); -int LoadSpritesData(void); -int LoadPersData(void); +int16 LoadStaticData(void); +int16 LoadFond(void); +int16 LoadSpritesData(void); +int16 LoadPersData(void); extern ResEntry_t res_texts[]; -int LoadVepciData(void); +int16 LoadVepciData(void); extern ResEntry_t res_desci[]; -int LoadDesciData(void); +int16 LoadDesciData(void); extern ResEntry_t res_diali[]; -int LoadDialiData(void); +int16 LoadDialiData(void); } // End of namespace Chamber diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp index b3073e4e564..e369c2c38db 100644 --- a/engines/chamber/room.cpp +++ b/engines/chamber/room.cpp @@ -37,26 +37,26 @@ namespace Chamber { -unsigned char scratch_mem1[8010]; -unsigned char *scratch_mem2 = scratch_mem1 + 1500; +byte scratch_mem1[8010]; +byte *scratch_mem2 = scratch_mem1 + 1500; rect_t room_bounds_rect = {0, 0, 0, 0}; -unsigned char last_object_hint = 0; -unsigned char object_hint = 0; -unsigned char command_hint = 0; -unsigned char zone_name = 0; -unsigned char room_hint_bar_width = 0; -unsigned char last_command_hint = 0; -unsigned char zone_spr_index = 0; -unsigned char zone_obj_count = 0; +byte last_object_hint = 0; +byte object_hint = 0; +byte command_hint = 0; +byte zone_name = 0; +byte room_hint_bar_width = 0; +byte last_command_hint = 0; +byte zone_spr_index = 0; +byte zone_obj_count = 0; -unsigned char cmd_hint_bar_width = 32; -unsigned char cmd_hint_bar_coords_x = 188 / 4; -unsigned char cmd_hint_bar_coords_y = 193; -unsigned char room_hint_bar_coords_x = 0; -unsigned char room_hint_bar_coords_y = 0; +byte cmd_hint_bar_width = 32; +byte cmd_hint_bar_coords_x = 188 / 4; +byte cmd_hint_bar_coords_y = 193; +byte room_hint_bar_coords_x = 0; +byte room_hint_bar_coords_y = 0; -unsigned char *sprites_list[MAX_SPRITES]; +byte *sprites_list[MAX_SPRITES]; spot_t *zone_spots; spot_t *zone_spots_end; @@ -67,27 +67,27 @@ turkeyanims_t *turkeyanims_ptr; pers_t *pers_ptr; spot_t *spot_ptr; spot_t *found_spot; -unsigned char **spot_sprite; +byte **spot_sprite; -unsigned char zone_palette; +byte zone_palette; -unsigned int zsprite_draw_ofs; -unsigned char zsprite_w; -unsigned char zsprite_h; +uint16 zsprite_draw_ofs; +byte zsprite_w; +byte zsprite_h; -unsigned char *lutin_mem; +byte *lutin_mem; -unsigned short inv_update_time = 0; +uint16 inv_update_time = 0; -unsigned char in_de_profundis = 0; /*TODO: useless?*/ +byte in_de_profundis = 0; /*TODO: useless?*/ -unsigned short next_command3 = 0; -unsigned short next_ticks3 = 0; -unsigned short next_command4 = 0; -unsigned short next_ticks4 = 0; -unsigned short next_ticks2 = 0; +uint16 next_command3 = 0; +uint16 next_ticks3 = 0; +uint16 next_command4 = 0; +uint16 next_ticks4 = 0; +uint16 next_ticks2 = 0; -unsigned char zone_drawn; +byte zone_drawn; #define VORTANIMS_MAX 25 @@ -137,11 +137,11 @@ turkeyanims_t turkeyanim_list[TURKEYANIMS_MAX] = { {61, {61, {{56, 141}}}, {62, {{56, 141}}}} }; -static const unsigned char cga_color_sels[] = { +static const byte cga_color_sels[] = { 0x30, 0x10, 0x30, 0x10, 0x30, 0x10, 0x10, 0x30, 0x10, 0x10, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x10, 0x10, 0x10 }; -void SelectSpecificPalette(unsigned char index) { +void SelectSpecificPalette(byte index) { CGA_ColorSelect(cga_color_sels[index]); } @@ -154,9 +154,9 @@ void SelectPalette(void) { Blit sprites to backbuffer */ void BlitSpritesToBackBuffer(void) { - int i; + int16 i; for (i = 0; i < MAX_SPRITES; i++) { - unsigned char *sprite = sprites_list[i]; + byte *sprite = sprites_list[i]; CGA_RestoreImage(sprite, backbuffer); } } @@ -165,9 +165,9 @@ void BlitSpritesToBackBuffer(void) { Copy data at sprite's rect from screen to backbuffer */ void RefreshSpritesData(void) { - int i; + int16 i; for (i = 0; i < MAX_SPRITES; i++) { - unsigned char *sprite = sprites_list[i]; + byte *sprite = sprites_list[i]; CGA_RefreshImageData(sprite); } } @@ -175,7 +175,7 @@ void RefreshSpritesData(void) { /* Check if packed x/y coordinates are in rect */ -int IsInRect(unsigned char x, unsigned char y, rect_t *rect) { +int16 IsInRect(byte x, byte y, rect_t *rect) { if (x < rect->sx) return 0; if (x >= rect->ex) return 0; if (y < rect->sy) return 0; @@ -186,7 +186,7 @@ int IsInRect(unsigned char x, unsigned char y, rect_t *rect) { /* Check if cursor is in rect */ -int IsCursorInRect(rect_t *rect) { +int16 IsCursorInRect(rect_t *rect) { return IsInRect(cursor_x / CGA_PIXELS_PER_BYTE, cursor_y, rect); } @@ -194,7 +194,7 @@ int IsCursorInRect(rect_t *rect) { Find person for a current spot */ void FindPerson(void) { - int i; + int16 i; pers_t *pers = pers_list; for (i = 0; i < PERS_MAX; i++, pers++) { if ((pers->flags & 15) == script_byte_vars.cur_spot_idx) { @@ -209,8 +209,8 @@ void FindPerson(void) { /* Select a spot under cursor if its flags are matched given criteria */ -void CheckHotspots(unsigned char m, unsigned char v) { - int i; +void CheckHotspots(byte m, byte v) { + int16 i; spot_t *spot = zone_spots; for (i = 0; spot != zone_spots_end; i++, spot++) { if (IsCursorInRect((rect_t *)spot) && (spot->flags & SPOTFLG_80) && ((spot->flags & m) == v)) { @@ -234,7 +234,7 @@ void CheckHotspots(unsigned char m, unsigned char v) { Select cursor shape for current spot */ void SelectSpotCursor(void) { - int curs = CURSOR_TARGET; + int16 curs = CURSOR_TARGET; CheckHotspots(script_byte_vars.spot_m, script_byte_vars.spot_v); if (cursor_color == 0xAA) { curs = CURSOR_BODY; @@ -251,7 +251,7 @@ void SelectSpotCursor(void) { #define kBgH 30 /*blocks draw order (clockwise inward spiral)*/ -static const signed int background_draw_steps[] = { +static const int16 background_draw_steps[] = { kBgW, kBgW, kBgW, kBgW, kBgW, kBgW, kBgW, kBgH / 2 * CGA_BYTES_PER_LINE, kBgH / 2 * CGA_BYTES_PER_LINE, kBgH / 2 * CGA_BYTES_PER_LINE, kBgH / 2 * CGA_BYTES_PER_LINE, kBgH / 2 * CGA_BYTES_PER_LINE, -kBgW, -kBgW, -kBgW, -kBgW, -kBgW, -kBgW, -kBgW, -kBgW, @@ -268,10 +268,10 @@ static const signed int background_draw_steps[] = { /* Draw main backgound pattern, in spiral-like order */ -void DrawBackground(unsigned char *target, unsigned char vblank) { - int i; - unsigned int offs = (2 / 2) * CGA_BYTES_PER_LINE + 8; /*TODO: calcxy?*/ - unsigned char *pixels = gauss_data + 0x3C8; /*TODO: better const*/ +void DrawBackground(byte *target, byte vblank) { + int16 i; + uint16 offs = (2 / 2) * CGA_BYTES_PER_LINE + 8; /*TODO: calcxy?*/ + byte *pixels = gauss_data + 0x3C8; /*TODO: better const*/ for (i = 0; i < 53; i++) { /*draw a tile, alternating between two variants*/ CGA_Blit(pixels + (i & 1 ? 0 : kBgW * kBgH), kBgW, kBgW, kBgH, target, offs); @@ -291,7 +291,7 @@ void DrawBackground(unsigned char *target, unsigned char vblank) { Load and initialize zone data */ void LoadZone(void) { - unsigned char *zptr, *zend; + byte *zptr, *zend; zptr = SeekToEntry(zones_data, script_byte_vars.zone_index - 1, &zend); script_byte_vars.zone_area = *zptr++; @@ -300,12 +300,12 @@ void LoadZone(void) { zone_palette = script_byte_vars.palette_index = *zptr++; zone_obj_count = *zptr++; if (zone_obj_count != 0) { - unsigned int i; - unsigned short *zcmds = script_word_vars.zone_obj_cmds; + uint16 i; + uint16 *zcmds = script_word_vars.zone_obj_cmds; memset(script_word_vars.zone_obj_cmds, 0, 15 * 5); /*half of list: TODO: bug? wipe whole list?*/ for (i = 0; i < zone_obj_count; i++) { /*load spot's reactions*/ - unsigned short flags = (*zptr++) << 8; + uint16 flags = (*zptr++) << 8; flags |= *zptr++; if (flags & 0x10) { zcmds[0] = zptr[0] | (zptr[1] << 8); /*TODO: big-endian, but loaded here as le and converted later*/ @@ -368,7 +368,7 @@ void ResetZone(void) { /* Load puzzl sprite to buffer, return next free buffer ptr */ -unsigned char *LoadPuzzl(unsigned char index, unsigned char *buffer) { +byte *LoadPuzzl(byte index, byte *buffer) { if (script_byte_vars.palette_index == 14) return LoadSprite(index, puzzl_data + 4, buffer, 1); else @@ -378,8 +378,8 @@ unsigned char *LoadPuzzl(unsigned char index, unsigned char *buffer) { /* Load puzzl sprite to scratch buffer, return sprite ptr */ -unsigned char *LoadPuzzlToScratch(unsigned char index) { - unsigned char *buffer = scratch_mem2; +byte *LoadPuzzlToScratch(byte index) { + byte *buffer = scratch_mem2; LoadPuzzl(index, buffer); return buffer; } @@ -387,29 +387,29 @@ unsigned char *LoadPuzzlToScratch(unsigned char index) { #define kNumDoorSprites 3 typedef struct doorinfo_t { - unsigned char flipped; + byte flipped; struct { - unsigned char width; - unsigned char height; - unsigned char *pixels; - unsigned int offs; + byte width; + byte height; + byte *pixels; + uint16 offs; } layer[kNumDoorSprites]; - unsigned char width; - unsigned char height; - unsigned int offs; - unsigned char sprites[1]; /*variable size*/ + byte width; + byte height; + uint16 offs; + byte sprites[1]; /*variable size*/ } doorinfo_t; -unsigned char *doors_list[MAX_DOORS]; -unsigned char arpla_y_step; +byte *doors_list[MAX_DOORS]; +byte arpla_y_step; /* Fill in sliding door animation information */ -void InitRoomDoorInfo(unsigned char index) { - int i; - unsigned char *aptr; - unsigned char *sprbuf; +void InitRoomDoorInfo(byte index) { + int16 i; + byte *aptr; + byte *sprbuf; doorinfo_t *info = (doorinfo_t *)scratch_mem2; rect_t bounds = {0xFF, 0, 0xFF, 0}; @@ -417,8 +417,8 @@ void InitRoomDoorInfo(unsigned char index) { info->flipped = (aptr[1] & 0x80) ? ~0 : 0; sprbuf = info->sprites; for (i = 0; i < kNumDoorSprites; i++) { - unsigned char x, y, w, h, ox; - unsigned char *sprite = sprbuf; + byte x, y, w, h, ox; + byte *sprite = sprbuf; sprbuf = LoadPuzzl(aptr[0], sprbuf); x = aptr[1]; @@ -462,13 +462,13 @@ void InitRoomDoorInfo(unsigned char index) { Draw sliding door */ void DrawRoomDoor(void) { - int i; + int16 i; doorinfo_t *info = (doorinfo_t *)scratch_mem2; for (i = 0; i < kNumDoorSprites; i++) { - unsigned char w = info->layer[i].width; - unsigned char h = info->layer[i].height; - unsigned char *pixels = info->layer[i].pixels; - unsigned int offs = info->layer[i].offs; + byte w = info->layer[i].width; + byte h = info->layer[i].height; + byte *pixels = info->layer[i].pixels; + uint16 offs = info->layer[i].offs; if (!info->flipped) CGA_BlitSprite(pixels, w * 2, w, h, backbuffer, offs); @@ -483,10 +483,10 @@ void DrawRoomDoor(void) { /* Animate sliding door open */ -void AnimRoomDoorOpen(unsigned char index) { - int i; +void AnimRoomDoorOpen(byte index) { + int16 i; - unsigned char oldheight; + byte oldheight; doorinfo_t *info = (doorinfo_t *)scratch_mem2; @@ -508,11 +508,11 @@ void AnimRoomDoorOpen(unsigned char index) { /* Animate sliding door close */ -void AnimRoomDoorClose(unsigned char index) { - int i; +void AnimRoomDoorClose(byte index) { + int16 i; - unsigned char oldheight; - unsigned char *oldpixels; + byte oldheight; + byte *oldpixels; doorinfo_t *info = (doorinfo_t *)scratch_mem2; InitRoomDoorInfo(index); @@ -539,10 +539,10 @@ void AnimRoomDoorClose(unsigned char index) { } /*Maybe FindRoomDoor?*/ -unsigned char FindInitialSpot(void) { +byte FindInitialSpot(void) { spot_t *spot; - unsigned char index; - unsigned char flags = script_byte_vars.byte_179B8; + byte index; + byte flags = script_byte_vars.byte_179B8; if (flags == 0) return 0; flags |= SPOTFLG_80 | SPOTFLG_8; @@ -556,9 +556,9 @@ unsigned char FindInitialSpot(void) { /* Find first spot index that matches given flags */ -unsigned char FindSpotByFlags(unsigned char mask, unsigned char value) { +byte FindSpotByFlags(byte mask, byte value) { spot_t *spot; - unsigned char index; + byte index; for (index = 1, spot = zone_spots; spot != zone_spots_end; spot++, index++) { if ((spot->flags & mask) == value) return index; @@ -570,9 +570,9 @@ unsigned char FindSpotByFlags(unsigned char mask, unsigned char value) { Find person's spot TODO: rename me */ -unsigned char FindAndSelectSpot(unsigned char offset) { +byte FindAndSelectSpot(byte offset) { /*TODO: replace offset arg with index?*/ - unsigned char index = offset / 5; /* / sizeof(pers_t) */ + byte index = offset / 5; /* / sizeof(pers_t) */ script_vars[ScrPool8_CurrentPers] = &pers_list[index]; @@ -590,7 +590,7 @@ unsigned char FindAndSelectSpot(unsigned char offset) { Play animation at the selected spot or specified coordinates */ void AnimateSpot(const animdesc_t *info) { - unsigned char *sprite = *spot_sprite; + byte *sprite = *spot_sprite; CGA_RestoreImage(sprite, backbuffer); if (info->index & ANIMFLG_USESPOT) { /*at selected spot*/ @@ -607,8 +607,8 @@ void AnimateSpot(const animdesc_t *info) { } typedef struct lutinanim_t { - unsigned char phase; - unsigned char sprites[8]; + byte phase; + byte sprites[8]; } lutinanim_t; lutinanim_t lutins_table[] = { @@ -647,8 +647,8 @@ lutinanim_t lutins_table[] = { {0, { 0, 0, 0, 0, 0, 0, 0, 0} } }; -void UpdateZoneSpot(unsigned char index) { - unsigned char oldspot; +void UpdateZoneSpot(byte index) { + byte oldspot; static const animdesc_t anim57 = {ANIMFLG_USESPOT | 57}; static const animdesc_t anim58 = {ANIMFLG_USESPOT | 58}; @@ -673,8 +673,8 @@ void UpdateZoneSpot(unsigned char index) { script_byte_vars.cur_spot_idx = oldspot; } -void ChangeZone(unsigned char index) { - unsigned char spridx = 0; +void ChangeZone(byte index) { + byte spridx = 0; script_byte_vars.prev_zone_index = script_byte_vars.zone_index; script_byte_vars.zone_index = index; @@ -687,7 +687,7 @@ void ChangeZone(unsigned char index) { spridx = 222; if (spridx != 0) { - int i; + int16 i; lutinanim_t *la = &lutins_table[31]; for (i = 0; i < 8; i++) la->sprites[i] = spridx; @@ -699,8 +699,8 @@ void ChangeZone(unsigned char index) { void DrawZoneObjs(void) { - int i; - unsigned char index, pidx; + int16 i; + byte index, pidx; spot_t *spot; for (spot = zone_spots; spot != zone_spots_end; spot++) { @@ -733,10 +733,10 @@ void DrawZoneObjs(void) { /* Draw room's static object to backbuffer */ -void DrawRoomStaticObject(unsigned char *aptr, unsigned char *rx, unsigned char *ry, unsigned char *rw, unsigned char *rh) { - unsigned char x, y, w, h; - signed int pitch; - unsigned char *sprite = LoadPuzzlToScratch(aptr[0]); +void DrawRoomStaticObject(byte *aptr, byte *rx, byte *ry, byte *rw, byte *rh) { + byte x, y, w, h; + int16 pitch; + byte *sprite = LoadPuzzlToScratch(aptr[0]); x = aptr[1]; y = aptr[2]; w = sprite[0]; @@ -784,10 +784,10 @@ Initialize room bounds rect to room's dimensions Draw room's name box and text */ void DrawRoomStatics(void) { - unsigned char *aptr, *aend; - unsigned char doorcount = 0; - unsigned char x, y, w, h; - unsigned int xx, ww; + byte *aptr, *aend; + byte doorcount = 0; + byte x, y, w, h; + uint16 xx, ww; DrawBackground(backbuffer, 0); arpla_y_step = script_byte_vars.byte_179E1; @@ -800,7 +800,7 @@ void DrawRoomStatics(void) { /*load and draw room decor*/ for (; aptr != aend; aptr += 3) { - unsigned char index = *aptr; + byte index = *aptr; /*a door ?*/ if (index >= 50 && index < 61) { doors_list[doorcount++] = aptr - 3; /*TODO: check for list overflow?*/ @@ -851,9 +851,9 @@ void DrawRoomStatics(void) { /* Redraw all room's static objects (decorations) to backbuffer */ -void RedrawRoomStatics(unsigned char index, unsigned char y_step) { - unsigned char *aptr, *aend; - unsigned char x, y, w, h; +void RedrawRoomStatics(byte index, byte y_step) { + byte *aptr, *aend; + byte x, y, w, h; arpla_y_step = y_step; aptr = SeekToEntry(arpla_data, index - 1, &aend); @@ -867,8 +867,8 @@ void RedrawRoomStatics(unsigned char index, unsigned char y_step) { Draw "some item in the room" icon */ void DrawRoomItemsIndicator(void) { - unsigned char spridx = 172; - int i; + byte spridx = 172; + int16 i; for (i = 0; i < MAX_INV_ITEMS; i++) { if (inventory_items[i].flags == ITEMFLG_40 && inventory_items[i].flags2 == script_byte_vars.zone_area) { @@ -890,7 +890,7 @@ void DrawZoneSpots(void) { static const animdesc_t anim59 = {ANIMFLG_USESPOT | 59}; static const animdesc_t anim60 = {ANIMFLG_USESPOT | 60}; - unsigned char oldspot = script_byte_vars.cur_spot_idx; + byte oldspot = script_byte_vars.cur_spot_idx; if (!script_byte_vars.need_draw_spots) return; @@ -955,7 +955,7 @@ void DrawObjectHint(void) { /* Copy object hint from backbuffer to screen */ -void ShowObjectHint(unsigned char *target) { +void ShowObjectHint(byte *target) { if (script_byte_vars.zone_index == 135) return; CGA_CopyScreenBlock(backbuffer, room_hint_bar_width + 2, 9, target, CGA_CalcXY_p(room_hint_bar_coords_x - 1, room_hint_bar_coords_y - 2)); @@ -975,19 +975,19 @@ void DrawCommandHint(void) { /* Copy command hint from backbuffer to screen */ -void ShowCommandHint(unsigned char *target) { +void ShowCommandHint(byte *target) { CGA_CopyScreenBlock(backbuffer, cmd_hint_bar_width + 2, 9, target, CGA_CalcXY_p(cmd_hint_bar_coords_x - 1, cmd_hint_bar_coords_y - 2)); } -void LoadLutinSprite(unsigned int lutidx) { - unsigned char spridx; - unsigned int flags; - unsigned char *lutin_entry, *lutin_entry_end; - unsigned char *buffer; - unsigned char *sprite; - unsigned char sprw, sprh; +void LoadLutinSprite(uint16 lutidx) { + byte spridx; + uint16 flags; + byte *lutin_entry, *lutin_entry_end; + byte *buffer; + byte *sprite; + byte sprw, sprh; - unsigned int i; + uint16 i; buffer = lutin_mem; @@ -1021,7 +1021,7 @@ void LoadLutinSprite(unsigned int lutidx) { /* Draw specific room's person idle sprite */ -void DrawCharacterSprite(unsigned char spridx, unsigned char x, unsigned char y, unsigned char *target) { +void DrawCharacterSprite(byte spridx, byte x, byte y, byte *target) { lutin_mem = scratch_mem2; LoadLutinSprite(spridx); @@ -1033,9 +1033,9 @@ void DrawCharacterSprite(unsigned char spridx, unsigned char x, unsigned char y, Draw room's person idle sprite and advance sprite's animation Return true if a sprite was drawn */ -char DrawZoneAniSprite(rect_t *rect, unsigned int index, unsigned char *target) { - int i; - unsigned char spridx; +char DrawZoneAniSprite(rect_t *rect, uint16 index, byte *target) { + int16 i; + byte spridx; pers_t *pers = pers_list; for (i = 0; i < PERS_MAX; i++, pers++) { if ((pers->flags & 15) == index) { @@ -1067,9 +1067,9 @@ void SetDelay5(void) { Aspirants AI */ void PrepareCommand1(void) { - unsigned char index; - unsigned char oldr, newr; - unsigned char flags; + byte index; + byte oldr, newr; + byte flags; if (script_byte_vars.zone_area == 55) { pers_list[1].area = 55; @@ -1172,7 +1172,7 @@ void PrepareCommand3(void) { for (spot = zone_spots; spot != zone_spots_end; spot++) { if ((spot->flags & ~SPOTFLG_80) == (SPOTFLG_40 | SPOTFLG_10)) { - int i; + int16 i; for (i = 0; i < VORTANIMS_MAX; i++) { if (vortsanim_list[i].room == script_byte_vars.zone_room) { vortanims_ptr = &vortsanim_list[i]; @@ -1223,7 +1223,7 @@ void PrepareCommand4(void) { for (spot = zone_spots; spot != zone_spots_end; spot++) { if ((spot->flags & ~SPOTFLG_80) == (SPOTFLG_40 | SPOTFLG_10 | SPOTFLG_1)) { - int i; + int16 i; for (i = 0; i < TURKEYANIMS_MAX; i++) { if (turkeyanim_list[i].room == script_byte_vars.zone_room) { @@ -1256,8 +1256,8 @@ void PrepareCommand4(void) { /* Load puzzl sprite to scratch and init draw params */ -unsigned int GetPuzzlSprite(unsigned char index, unsigned char x, unsigned char y, unsigned int *w, unsigned int *h, unsigned int *ofs) { - unsigned char *spr = LoadPuzzlToScratch(index); +uint16 GetPuzzlSprite(byte index, byte x, byte y, uint16 *w, uint16 *h, uint16 *ofs) { + byte *spr = LoadPuzzlToScratch(index); *w = spr[0]; *h = spr[1]; *ofs = CGA_CalcXY_p(x, y); @@ -1290,10 +1290,10 @@ void RestoreScreenOfSpecialRoom(void) { } } -unsigned char byte_17A1C = 0; +byte byte_17A1C = 0; -void SetAnim127Sprite(unsigned char flags, unsigned char spridx) { - unsigned char *lutin_entry, *lutin_entry_end; +void SetAnim127Sprite(byte flags, byte spridx) { + byte *lutin_entry, *lutin_entry_end; lutin_entry = SeekToEntry(lutin_data, 127, &lutin_entry_end); lutin_entry[2] = spridx; switch (spridx) { @@ -1308,7 +1308,7 @@ void SetAnim127Sprite(unsigned char flags, unsigned char spridx) { } } -void BounceCurrentItem(unsigned char flags, unsigned char y) { +void BounceCurrentItem(byte flags, byte y) { item_t *item = (item_t *)(script_vars[ScrPool3_CurrentItem]); SetAnim127Sprite(flags, item->sprite); @@ -1321,15 +1321,15 @@ void BounceCurrentItem(unsigned char flags, unsigned char y) { } -unsigned char *LoadMursmSprite(unsigned char index) { - unsigned char *pinfo, *end; +byte *LoadMursmSprite(byte index) { + byte *pinfo, *end; pinfo = SeekToEntry(mursm_data, index, &end); while (pinfo != end) { - unsigned int flags; - signed int pitch; - unsigned char *buffer, *sprite; - unsigned char sprw, sprh; + uint16 flags; + int16 pitch; + byte *buffer, *sprite; + byte sprw, sprh; index = *pinfo++; flags = *pinfo++; @@ -1358,8 +1358,8 @@ unsigned char *LoadMursmSprite(unsigned char index) { thewalldoor_t the_wall_doors[2]; -void TheWallOpenRightDoor(unsigned char x, unsigned char y, unsigned char width, unsigned char height, unsigned char limit) { - unsigned int offs = CGA_CalcXY_p(x + width - 2, y); +void TheWallOpenRightDoor(byte x, byte y, byte width, byte height, byte limit) { + uint16 offs = CGA_CalcXY_p(x + width - 2, y); while (--width) { CGA_HideScreenBlockLiftToRight(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs); @@ -1381,8 +1381,8 @@ void TheWallOpenRightDoor(unsigned char x, unsigned char y, unsigned char width, } } -void TheWallOpenLeftDoor(unsigned char x, unsigned char y, unsigned char width, unsigned char height, unsigned char limit) { - unsigned int offs = CGA_CalcXY_p(x + 1, y); +void TheWallOpenLeftDoor(byte x, byte y, byte width, byte height, byte limit) { + uint16 offs = CGA_CalcXY_p(x + 1, y); while (--width) { CGA_HideScreenBlockLiftToLeft(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs); @@ -1437,7 +1437,7 @@ Animate The Wall doors Phase 1: Opened -> Half closed */ void TheWallPhase1_DoorClose1(void) { - unsigned char *spr; + byte *spr; script_byte_vars.zone_index = (script_byte_vars.zone_index == 24) ? 9 : 102; LoadZone(); @@ -1459,7 +1459,7 @@ Animate The Wall doors Phase 2: Half closed -> Fully closed */ void TheWallPhase2_DoorClose2(void) { - unsigned char *spr; + byte *spr; script_byte_vars.zone_index = (script_byte_vars.zone_index == 9) ? 95 : 103; LoadZone(); @@ -1497,11 +1497,11 @@ void DrawTheWallDoors(void) { /* Superimpose source sprite data over target sprite data */ -void MergeSpritesData(unsigned char *target, unsigned int pitch, unsigned char *source, unsigned int w, unsigned int h) { - unsigned int x; +void MergeSpritesData(byte *target, uint16 pitch, byte *source, uint16 w, uint16 h) { + uint16 x; while (h--) { for (x = 0; x < w; x++) { - unsigned char m = *source++; + byte m = *source++; *target++ &= m; *target &= m; *target++ |= *source++; @@ -1514,12 +1514,12 @@ void MergeSpritesData(unsigned char *target, unsigned int pitch, unsigned char * /* Superimpose horizontally-flipped source sprite data over target sprite data */ -void MergeSpritesDataFlip(unsigned char *target, unsigned int pitch, unsigned char *source, unsigned int w, unsigned int h) { - unsigned int x; +void MergeSpritesDataFlip(byte *target, uint16 pitch, byte *source, uint16 w, uint16 h) { + uint16 x; target += w * 2 - 2; while (h--) { for (x = 0; x < w; x++) { - unsigned char m = cga_pixel_flip[*source++]; + byte m = cga_pixel_flip[*source++]; *target++ &= m; *target &= m; *target |= cga_pixel_flip[*source++]; @@ -1534,7 +1534,7 @@ void MergeSpritesDataFlip(unsigned char *target, unsigned int pitch, unsigned ch Save image at the rect to buffer Return current and next free buffer ptr */ -unsigned char *BackupSpotImage(spot_t *spot, unsigned char **spotback, unsigned char *buffer) { +byte *BackupSpotImage(spot_t *spot, byte **spotback, byte *buffer) { *spotback = buffer; buffer = CGA_BackupImage(backbuffer, CGA_CalcXY_p(spot->sx, spot->sy), spot->ex - spot->sx, spot->ey - spot->sy, buffer); return buffer; @@ -1545,8 +1545,8 @@ Save zone spot images to sprites list */ void BackupSpotsImages(void) { spot_t *spot = zone_spots; - unsigned char *buffer = scratch_mem1; - int i; + byte *buffer = scratch_mem1; + int16 i; for (i = 0; i < MAX_SPRITES; i++) sprites_list[i] = 0; for (i = 0; spot != zone_spots_end; spot++, i++) { /*TODO: maybe don't advance it if spot is skipped?*/ @@ -1559,9 +1559,9 @@ void BackupSpotsImages(void) { Animate all room's persons, one per call TODO: rename me */ -void DrawSpots(unsigned char *target) { +void DrawSpots(byte *target) { spot_t *spot = zone_spots_cur; - unsigned char spridx = zone_spr_index; + byte spridx = zone_spr_index; if (spot == zone_spots_end) { spot = zone_spots; spridx = 0; @@ -1594,7 +1594,7 @@ void DrawSpots(unsigned char *target) { Animate room's persons at fixed rate TODO: rename me */ -void AnimateSpots(unsigned char *target) { +void AnimateSpots(byte *target) { if (script_byte_vars.timer_ticks % 32 == 31) DrawSpots(target); } @@ -1602,7 +1602,7 @@ void AnimateSpots(unsigned char *target) { /* Draw cursor and hints text on screen */ -void DrawHintsAndCursor(unsigned char *target) { +void DrawHintsAndCursor(byte *target) { UpdateCursor(); WaitVBlank(); UndrawCursor(target); @@ -1619,20 +1619,20 @@ void DrawHintsAndCursor(unsigned char *target) { DrawCursor(target); } -void HideSpot(unsigned char offset) { +void HideSpot(byte offset) { FindAndSelectSpot(offset); found_spot->flags &= ~SPOTFLG_80; } -const unsigned char timed_seq[] = {56, 51, 44, 12, 10, 20, 18, 16, 14, 12, 44, 51}; -const unsigned char *timed_seq_ptr = timed_seq; +const byte timed_seq[] = {56, 51, 44, 12, 10, 20, 18, 16, 14, 12, 44, 51}; +const byte *timed_seq_ptr = timed_seq; /* Protozorq AI 1 TODO: rename this */ void UpdateTimedRects1(void) { - unsigned int elapsed; + uint16 elapsed; if (script_byte_vars.flag_179FB != 0) return; @@ -1774,7 +1774,7 @@ Protozorq AI 2 TODO: rename this */ void UpdateTimedRects2(void) { - unsigned int elapsed = Swap16(script_word_vars.timer_ticks2); + uint16 elapsed = Swap16(script_word_vars.timer_ticks2); if (elapsed < 60 * 60) return; @@ -1812,7 +1812,7 @@ void UpdateTimedRects2(void) { } void UpdateTimedInventoryItems(void) { - int i; + int16 i; if (Swap16(script_word_vars.timer_ticks2) - inv_update_time < 180) return; inv_update_time = Swap16(script_word_vars.timer_ticks2); @@ -1826,7 +1826,7 @@ void UpdateTimedInventoryItems(void) { } void ResetAllPersons(void) { - int i; + int16 i; for (i = 0; i < PERS_MAX; i++) pers_list[i].flags &= ~PERSFLG_80; script_byte_vars.dead_flag = 0; diff --git a/engines/chamber/room.h b/engines/chamber/room.h index 0d922ee290b..06e5babc2f9 100644 --- a/engines/chamber/room.h +++ b/engines/chamber/room.h @@ -37,13 +37,13 @@ namespace Chamber { /*TODO: manipulated from script, do not change*/ #include "common/pack-start.h" typedef struct spot_t { - unsigned char sx; - unsigned char ex; - unsigned char sy; - unsigned char ey; - unsigned char flags; - unsigned char hint; - unsigned short command; + byte sx; + byte ex; + byte sy; + byte ey; + byte flags; + byte hint; + uint16 command; } spot_t; #include "common/pack-end.h" @@ -57,28 +57,28 @@ typedef struct spot_t { /*TODO: manipulated from script, do not change*/ #include "common/pack-start.h" typedef struct pers_t { - unsigned char area; /*location*/ - unsigned char flags; /*flags in bits 7..4 and room index in bits 3..0*/ - unsigned char name; /*name index*/ - unsigned char index; /*animations index (in lutins_table) in bits 7..3 , spot index in bits 2..0*/ - unsigned char item; /*inventory item index (1-based)*/ + byte area; /*location*/ + byte flags; /*flags in bits 7..4 and room index in bits 3..0*/ + byte name; /*name index*/ + byte index; /*animations index (in lutins_table) in bits 7..3 , spot index in bits 2..0*/ + byte item; /*inventory item index (1-based)*/ } pers_t; #include "common/pack-end.h" #define ANIMFLG_USESPOT 0x80 typedef struct animdesc_t { - unsigned char index; /*flag in bit 7, animation index in bits 6..0*/ + byte index; /*flag in bit 7, animation index in bits 6..0*/ union { struct { - unsigned char x, y; + byte x, y; } coords; - unsigned short desc; + uint16 desc; } params; } animdesc_t; typedef struct vortanims_t { - unsigned char room; + byte room; animdesc_t field_1; animdesc_t field_4; animdesc_t field_7; @@ -86,36 +86,36 @@ typedef struct vortanims_t { } vortanims_t; typedef struct turkeyanims_t { - unsigned char room; + byte room; animdesc_t field_1; animdesc_t field_4; } turkeyanims_t; -extern unsigned char scratch_mem1[8010]; -extern unsigned char *scratch_mem2; +extern byte scratch_mem1[8010]; +extern byte *scratch_mem2; extern rect_t room_bounds_rect; -extern unsigned char last_object_hint; -extern unsigned char object_hint; -extern unsigned char command_hint; -extern unsigned char last_command_hint; +extern byte last_object_hint; +extern byte object_hint; +extern byte command_hint; +extern byte last_command_hint; -extern unsigned short next_ticks2; -extern unsigned short next_ticks3; -extern unsigned short next_command3; -extern unsigned short next_ticks4; -extern unsigned short next_command4; +extern uint16 next_ticks2; +extern uint16 next_ticks3; +extern uint16 next_command3; +extern uint16 next_ticks4; +extern uint16 next_command4; #define MAX_SPRITES 16 -extern unsigned char *sprites_list[MAX_SPRITES]; +extern byte *sprites_list[MAX_SPRITES]; #define MAX_DOORS 5 -extern unsigned char *doors_list[MAX_DOORS]; +extern byte *doors_list[MAX_DOORS]; -extern unsigned char zone_palette; +extern byte zone_palette; extern spot_t *zone_spots; extern spot_t *zone_spots_end; @@ -129,90 +129,90 @@ extern turkeyanims_t *turkeyanims_ptr; extern pers_t *pers_ptr; extern spot_t *spot_ptr; extern spot_t *found_spot; -extern unsigned char **spot_sprite; +extern byte **spot_sprite; -extern unsigned char *lutin_mem; +extern byte *lutin_mem; -extern unsigned char zone_drawn; +extern byte zone_drawn; -extern unsigned char in_de_profundis; +extern byte in_de_profundis; -extern unsigned char zone_name; -extern unsigned char room_hint_bar_width; -extern unsigned char zone_spr_index; -extern unsigned char zone_obj_count; -extern unsigned char room_hint_bar_coords_x; -extern unsigned char room_hint_bar_coords_y; +extern byte zone_name; +extern byte room_hint_bar_width; +extern byte zone_spr_index; +extern byte zone_obj_count; +extern byte room_hint_bar_coords_x; +extern byte room_hint_bar_coords_y; -extern unsigned short inv_update_time; +extern uint16 inv_update_time; -extern const unsigned char timed_seq[]; -extern const unsigned char *timed_seq_ptr; +extern const byte timed_seq[]; +extern const byte *timed_seq_ptr; typedef struct thewalldoor_t { - unsigned char height; - unsigned char width; - unsigned int pitch; - unsigned int offs; - unsigned char *pixels; + byte height; + byte width; + uint16 pitch; + uint16 offs; + byte *pixels; } thewalldoor_t; extern thewalldoor_t the_wall_doors[2]; -int IsInRect(unsigned char x, unsigned char y, rect_t *rect); -int IsCursorInRect(rect_t *rect); +int16 IsInRect(byte x, byte y, rect_t *rect); +int16 IsCursorInRect(rect_t *rect); void SelectSpotCursor(void); -void CheckHotspots(unsigned char m, unsigned char v); +void CheckHotspots(byte m, byte v); void AnimateSpot(const animdesc_t *info); -unsigned char *LoadPuzzlToScratch(unsigned char index); +byte *LoadPuzzlToScratch(byte index); void DrawObjectHint(void); -void ShowObjectHint(unsigned char *target); +void ShowObjectHint(byte *target); void DrawCommandHint(void); -void ShowCommandHint(unsigned char *target); +void ShowCommandHint(byte *target); -void DrawCharacterSprite(unsigned char spridx, unsigned char x, unsigned char y, unsigned char *target); -char DrawZoneAniSprite(rect_t *rect, unsigned int index, unsigned char *target); +void DrawCharacterSprite(byte spridx, byte x, byte y, byte *target); +char DrawZoneAniSprite(rect_t *rect, uint16 index, byte *target); -void DrawHintsAndCursor(unsigned char *target); +void DrawHintsAndCursor(byte *target); void DrawTheWallDoors(void); -void MergeSpritesData(unsigned char *target, unsigned int pitch, unsigned char *source, unsigned int w, unsigned int h); -void MergeSpritesDataFlip(unsigned char *target, unsigned int pitch, unsigned char *source, unsigned int w, unsigned int h); +void MergeSpritesData(byte *target, uint16 pitch, byte *source, uint16 w, uint16 h); +void MergeSpritesDataFlip(byte *target, uint16 pitch, byte *source, uint16 w, uint16 h); void RefreshSpritesData(void); void BlitSpritesToBackBuffer(void); void BackupSpotsImages(void); void SelectPalette(void); -void SelectSpecificPalette(unsigned char index); +void SelectSpecificPalette(byte index); -unsigned char FindSpotByFlags(unsigned char mask, unsigned char value); -unsigned char FindAndSelectSpot(unsigned char offset); +byte FindSpotByFlags(byte mask, byte value); +byte FindAndSelectSpot(byte offset); void FindPerson(void); -void UpdateZoneSpot(unsigned char index); +void UpdateZoneSpot(byte index); void DrawRoomItemsIndicator(void); -void DrawRoomStaticObject(unsigned char *aptr, unsigned char *rx, unsigned char *ry, unsigned char *rw, unsigned char *rh); +void DrawRoomStaticObject(byte *aptr, byte *rx, byte *ry, byte *rw, byte *rh); void DrawRoomStatics(void); -void RedrawRoomStatics(unsigned char index, unsigned char y_step); +void RedrawRoomStatics(byte index, byte y_step); void DrawZoneObjs(void); void RefreshZone(void); -void ChangeZone(unsigned char index); +void ChangeZone(byte index); -void DrawSpots(unsigned char *target); -void AnimateSpots(unsigned char *target); +void DrawSpots(byte *target); +void AnimateSpots(byte *target); -unsigned char FindInitialSpot(void); -void AnimRoomDoorOpen(unsigned char index); -void AnimRoomDoorClose(unsigned char index); +byte FindInitialSpot(void); +void AnimRoomDoorOpen(byte index); +void AnimRoomDoorClose(byte index); -unsigned int GetPuzzlSprite(unsigned char index, unsigned char x, unsigned char y, unsigned int *w, unsigned int *h, unsigned int *ofs); +uint16 GetPuzzlSprite(byte index, byte x, byte y, uint16 *w, uint16 *h, uint16 *ofs); -void BounceCurrentItem(unsigned char flags, unsigned char y); +void BounceCurrentItem(byte flags, byte y); void BackupScreenOfSpecialRoom(void); void RestoreScreenOfSpecialRoom(void); diff --git a/engines/chamber/savegame.cpp b/engines/chamber/savegame.cpp index 55af85dc494..fd90ecaa354 100644 --- a/engines/chamber/savegame.cpp +++ b/engines/chamber/savegame.cpp @@ -68,10 +68,10 @@ void RestartGame(void) { #define CGA_SAVE_TIMEDSEQ_OFS 0xA7C0 #define SAVEADDR(value, base, nativesize, origsize, origbase) \ - ((value) ? LE16(((((unsigned char*)(value)) - (unsigned char*)(base)) / nativesize) * origsize + origbase) : 0) + ((value) ? LE16(((((byte*)(value)) - (byte*)(base)) / nativesize) * origsize + origbase) : 0) #define LOADADDR(value, base, nativesize, origsize, origbase) \ - ((value) ? ((((LE16(value)) - (origbase)) / origsize) * nativesize + (unsigned char*)base) : 0) + ((value) ? ((((LE16(value)) - (origbase)) / origsize) * nativesize + (byte*)base) : 0) #define WRITE(buffer, size) \ wlen = write(f, buffer, size); if(wlen != size) goto error; @@ -79,17 +79,17 @@ void RestartGame(void) { #define READ(buffer, size) \ rlen = read(f, buffer, size); if(rlen != size) goto error; -int LoadScena(void) { +int16 LoadScena(void) { warning("STUB: LoadScena()"); return 1; #if 0 - int f; - int rlen; - unsigned short zero = 0; - unsigned char *p; - int i; + int16 f; + int16 rlen; + uint16 zero = 0; + byte *p; + int16 i; script_byte_vars.game_paused = 1; @@ -107,12 +107,12 @@ int LoadScena(void) { */ #define BYTES(buffer, size) READ(buffer, size) -#define UBYTE(variable) { unsigned char temp_v; READ(&temp_v, 1); variable = temp_v; } -#define SBYTE(variable) { signed char temp_v; READ(&temp_v, 1); variable = temp_v; } -#define USHORT(variable) { unsigned short temp_v; READ(&temp_v, 2); variable = temp_v; } -#define SSHORT(variable) { signed short temp_v; READ(&temp_v, 2); variable = temp_v; } +#define UBYTE(variable) { byte temp_v; READ(&temp_v, 1); variable = temp_v; } +#define SBYTE(variable) { int8 temp_v; READ(&temp_v, 1); variable = temp_v; } +#define USHORT(variable) { uint16 temp_v; READ(&temp_v, 2); variable = temp_v; } +#define SSHORT(variable) { int16 temp_v; READ(&temp_v, 2); variable = temp_v; } #define POINTER(variable, base, nativesize, origsize, origbase) \ - { signed short temp_v; READ(&temp_v, 2); variable = LOADADDR(temp_v, base, nativesize, origsize, origbase); } + { int16 temp_v; READ(&temp_v, 2); variable = LOADADDR(temp_v, base, nativesize, origsize, origbase); } /*script_vars pointers*/ POINTER(script_vars[ScrPool0_WordVars0], &script_word_vars, 2, 2, CGA_SAVE_WORD_VARS_OFS); @@ -136,17 +136,17 @@ int LoadScena(void) { } /* zone_spots */ - POINTER((unsigned char *)zone_spots, zones_data, 1, 1, CGA_SAVE_ZONES_OFS); + POINTER((byte *)zone_spots, zones_data, 1, 1, CGA_SAVE_ZONES_OFS); /* zone_spots_end */ - POINTER((unsigned char *)zone_spots_end, zones_data, 1, 1, CGA_SAVE_ZONES_OFS); + POINTER((byte *)zone_spots_end, zones_data, 1, 1, CGA_SAVE_ZONES_OFS); /* zone_spots_cur */ - POINTER((unsigned char *)zone_spots_cur, zones_data, 1, 1, CGA_SAVE_ZONES_OFS); + POINTER((byte *)zone_spots_cur, zones_data, 1, 1, CGA_SAVE_ZONES_OFS); /* script_stack_ptr */ /*TODO: FIX ME: original stack works in reverse order (from higher address to lower)*/ - POINTER((unsigned char *)script_stack_ptr, script_stack, 1, 1, CGA_SAVE_SCRSTACK_OFS); + POINTER((byte *)script_stack_ptr, script_stack, 1, 1, CGA_SAVE_SCRSTACK_OFS); /* script_stack */ /*TODO: FIX ME: original stack works in reverse order (from higher address to lower)*/ @@ -158,25 +158,25 @@ int LoadScena(void) { USHORT(zero); /* pers_vort_ptr */ - POINTER((unsigned char *)pers_vort_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS); + POINTER((byte *)pers_vort_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS); /* vortanims_ptr */ - POINTER((unsigned char *)vortanims_ptr, vortsanim_list, 1, 1, CGA_SAVE_VORTANIMS_OFS); + POINTER((byte *)vortanims_ptr, vortsanim_list, 1, 1, CGA_SAVE_VORTANIMS_OFS); /* turkeyanims_ptr */ - POINTER((unsigned char *)turkeyanims_ptr, turkeyanim_list, 1, 1, CGA_SAVE_TURKEYANIMS_OFS); + POINTER((byte *)turkeyanims_ptr, turkeyanim_list, 1, 1, CGA_SAVE_TURKEYANIMS_OFS); /* pers_ptr */ - POINTER((unsigned char *)pers_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS); + POINTER((byte *)pers_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS); /* spot_ptr */ - POINTER((unsigned char *)spot_ptr, zones_data, 1, 1, CGA_SAVE_ZONES_OFS); + POINTER((byte *)spot_ptr, zones_data, 1, 1, CGA_SAVE_ZONES_OFS); /* found_spot */ - POINTER((unsigned char *)found_spot, zones_data, 1, 1, CGA_SAVE_ZONES_OFS); + POINTER((byte *)found_spot, zones_data, 1, 1, CGA_SAVE_ZONES_OFS); /* spot_sprite */ - POINTER((unsigned char *)spot_sprite, sprites_list, sizeof(sprites_list[0]), 2, CGA_SAVE_SPRLIST_OFS); + POINTER((byte *)spot_sprite, sprites_list, sizeof(sprites_list[0]), 2, CGA_SAVE_SPRLIST_OFS); /* timed_seq_ptr */ POINTER(timed_seq_ptr, timed_seq, 1, 1, CGA_SAVE_TIMEDSEQ_OFS); @@ -354,16 +354,16 @@ error: #endif } -int SaveScena(void) { +int16 SaveScena(void) { warning("STUB: SaveScena()"); return 1; #if 0 - int f; - int wlen; - unsigned short zero = 0; - unsigned char *p; - int i; + int16 f; + int16 wlen; + uint16 zero = 0; + byte *p; + int16 i; script_byte_vars.game_paused = 1; BlitSpritesToBackBuffer(); @@ -375,12 +375,12 @@ int SaveScena(void) { } #define BYTES(buffer, size) WRITE(buffer, size) -#define UBYTE(variable) { unsigned char temp_v = variable; WRITE(&temp_v, 1); } -#define SBYTE(variable) { signed char temp_v = variable; WRITE(&temp_v, 1); } -#define USHORT(variable) { unsigned short temp_v = variable; WRITE(&temp_v, 2); } -#define SSHORT(variable) { signed short temp_v = variable; WRITE(&temp_v, 2); } +#define UBYTE(variable) { byte temp_v = variable; WRITE(&temp_v, 1); } +#define SBYTE(variable) { int8 temp_v = variable; WRITE(&temp_v, 1); } +#define USHORT(variable) { uint16 temp_v = variable; WRITE(&temp_v, 2); } +#define SSHORT(variable) { int16 temp_v = variable; WRITE(&temp_v, 2); } #define POINTER(variable, base, nativesize, origsize, origbase) \ - { signed short temp_v = SAVEADDR(variable, base, nativesize, origsize, origbase); WRITE(&temp_v, 2); } + { int16 temp_v = SAVEADDR(variable, base, nativesize, origsize, origbase); WRITE(&temp_v, 2); } /*script_vars pointers*/ POINTER(script_vars[ScrPool0_WordVars0], &script_word_vars, 2, 2, CGA_SAVE_WORD_VARS_OFS); diff --git a/engines/chamber/savegame.h b/engines/chamber/savegame.h index cea29569046..7c8feaf33b1 100644 --- a/engines/chamber/savegame.h +++ b/engines/chamber/savegame.h @@ -25,8 +25,8 @@ namespace Chamber { -int LoadScena(void); -int SaveScena(void); +int16 LoadScena(void); +int16 SaveScena(void); void SaveRestartGame(void); void RestartGame(void); diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp index 9097f2f321b..8c007e9f5e0 100644 --- a/engines/chamber/script.cpp +++ b/engines/chamber/script.cpp @@ -50,12 +50,12 @@ char DEBUG_SCRIPT_LOG[] = "!script.log"; namespace Chamber { -unsigned char rand_seed; -unsigned short the_command; -unsigned int script_res; -unsigned char *script_ptr, *script_end_ptr; -unsigned char *script_stack[5 * 2]; -unsigned char **script_stack_ptr = script_stack; +byte rand_seed; +uint16 the_command; +uint16 script_res; +byte *script_ptr, *script_end_ptr; +byte *script_stack[5 * 2]; +byte **script_stack_ptr = script_stack; void *script_vars[ScrPools_MAX] = { &script_word_vars, @@ -69,17 +69,17 @@ void *script_vars[ScrPools_MAX] = { pers_list }; -unsigned char Rand(void) { +byte Rand(void) { script_byte_vars.rand_value = aleat_data[++rand_seed]; return script_byte_vars.rand_value; } -unsigned int RandW(void) { - unsigned int r = Rand() << 8; +uint16 RandW(void) { + uint16 r = Rand() << 8; return r | Rand(); } -unsigned int Swap16(unsigned int x) { +uint16 Swap16(uint16 x) { return (x << 8) | (x >> 8); } @@ -90,14 +90,14 @@ enum CommandStatus { /*TODO: maybe define ScriptRestartGame to support game restart?*/ }; -unsigned int CMD_TRAP(void) { +uint16 CMD_TRAP(void) { printf("CMD TRAP\n"); PromptWait(); for (;;) ; return 0; } -unsigned int SCR_TRAP(void) { +uint16 SCR_TRAP(void) { printf("SCR TRAP 0x%02X @ 0x%X\n", *script_ptr, script_ptr - templ_data); PromptWait(); for (;;) ; @@ -106,15 +106,15 @@ unsigned int SCR_TRAP(void) { void ClaimTradedItems(void) { - int i; + int16 i; for (i = 0; i < MAX_INV_ITEMS; i++) { if (inventory_items[i].flags == (ITEMFLG_80 | 1)) inventory_items[i].flags = ITEMFLG_80; } } -unsigned int SCR_1_AspirantItemTrade(void) { - unsigned char *old_script, *old_script_end = script_end_ptr; +uint16 SCR_1_AspirantItemTrade(void) { + byte *old_script, *old_script_end = script_end_ptr; item_t *item1, *item2; @@ -190,8 +190,8 @@ unsigned int SCR_1_AspirantItemTrade(void) { return 0; } -unsigned int SCR_2_RudeAspirantTrade(void) { - unsigned char *old_script, *old_script_end = script_end_ptr; +uint16 SCR_2_RudeAspirantTrade(void) { + byte *old_script, *old_script_end = script_end_ptr; item_t *item1, *item2; @@ -280,8 +280,8 @@ unsigned int SCR_2_RudeAspirantTrade(void) { return 0; } -unsigned int SCR_4_StealZapstik(void) { - unsigned char *old_script; +uint16 SCR_4_StealZapstik(void) { + byte *old_script; pers_t *pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]); @@ -314,14 +314,14 @@ unsigned int SCR_4_StealZapstik(void) { } -unsigned char wait_delta = 0; +byte wait_delta = 0; -void Wait(unsigned char seconds) { +void Wait(byte seconds) { warning("STUB: Wait(%d)", seconds); #if 0 struct time t; - unsigned int endtime; + uint16 endtime; seconds += wait_delta; if (seconds > 127) /*TODO: is this a check for an unsigned value?*/ @@ -331,7 +331,7 @@ void Wait(unsigned char seconds) { endtime = t.ti_sec * 100 + t.ti_hund + seconds * 100; while (buttons == 0) { - unsigned int current; + uint16 current; gettime(&t); current = t.ti_sec * 100 + t.ti_hund; if (endtime >= 6000 && current < 2048) /*TODO: some kind of overflow check???*/ @@ -342,21 +342,21 @@ void Wait(unsigned char seconds) { #endif } -unsigned int SCR_2C_Wait4(void) { +uint16 SCR_2C_Wait4(void) { script_ptr++; Wait(4); return 0; } -unsigned int SCR_2D_Wait(void) { - unsigned char seconds; +uint16 SCR_2D_Wait(void) { + byte seconds; script_ptr++; seconds = *script_ptr++; Wait(4); /*TODO: looks like a bug?*/ return 0; } -unsigned int SCR_2E_PromptWait(void) { +uint16 SCR_2E_PromptWait(void) { script_ptr++; PromptWait(); return 0; @@ -371,27 +371,27 @@ unsigned int SCR_2E_PromptWait(void) { #define VARSIZE_BYTE 0 #define VARSIZE_WORD 1 -unsigned char var_size; +byte var_size; -unsigned short LoadVar(unsigned char **ptr, unsigned char **varptr) { - unsigned char vartype; - unsigned char *varbase; - unsigned short value = 0; +uint16 LoadVar(byte **ptr, byte **varptr) { + byte vartype; + byte *varbase; + uint16 value = 0; var_size = VARSIZE_BYTE; vartype = *((*ptr)++); if (vartype & VARTYPE_VAR) { /*variable*/ - unsigned char varoffs; - varbase = (unsigned char *)script_vars[vartype & VARTYPE_KIND]; + byte varoffs; + varbase = (byte *)script_vars[vartype & VARTYPE_KIND]; if (vartype & VARTYPE_BLOCK) { - unsigned char *end; - unsigned char index = *((*ptr)++); + byte *end; + byte index = *((*ptr)++); varbase = SeekToEntryW(varbase, index, &end); } varoffs = *((*ptr)++); #if 1 { - int maxoffs = 0; + int16 maxoffs = 0; switch (vartype & VARTYPE_KIND) { case ScrPool0_WordVars0: case ScrPool1_WordVars1: @@ -420,7 +420,7 @@ unsigned short LoadVar(unsigned char **ptr, unsigned char **varptr) { break; } if (varoffs >= maxoffs) { - printf("Scr var out of bounds @ %X (pool %d, ofs 0x%X, max 0x%X)\n", (unsigned int)(script_ptr - templ_data), vartype & VARTYPE_KIND, varoffs, maxoffs); + printf("Scr var out of bounds @ %X (pool %d, ofs 0x%X, max 0x%X)\n", (uint16)(script_ptr - templ_data), vartype & VARTYPE_KIND, varoffs, maxoffs); PromptWait(); } } @@ -465,7 +465,7 @@ unsigned short LoadVar(unsigned char **ptr, unsigned char **varptr) { #define MATHOP_LE 0x02 #define MATHOP_GE 0x01 -unsigned short MathOp(unsigned char op, unsigned short op1, unsigned short op2) { +uint16 MathOp(byte op, uint16 op1, uint16 op2) { if (op & MATHOP_CMP) { if (op & MATHOP_EQ) if (op1 == op2) return ~0; @@ -476,9 +476,9 @@ unsigned short MathOp(unsigned char op, unsigned short op1, unsigned short op2) if (op & MATHOP_NEQ) if (op1 != op2) return ~0; if (op & MATHOP_LE) - if ((signed short)op1 <= (signed short)op2) return ~0; + if ((int16)op1 <= (int16)op2) return ~0; if (op & MATHOP_GE) - if ((signed short)op1 >= (signed short)op2) return ~0; + if ((int16)op1 >= (int16)op2) return ~0; return 0; } else { if (op & MATHOP_ADD) @@ -495,10 +495,10 @@ unsigned short MathOp(unsigned char op, unsigned short op1, unsigned short op2) } } -unsigned short MathExpr(unsigned char **ptr) { - unsigned char op; - unsigned short op1, op2; - unsigned char *opptr; +uint16 MathExpr(byte **ptr) { + byte op; + uint16 op1, op2; + byte *opptr; op1 = LoadVar(ptr, &opptr); while (((op = *((*ptr)++)) & MATHOP_END) == 0) { op2 = LoadVar(ptr, &opptr); @@ -510,9 +510,9 @@ unsigned short MathExpr(unsigned char **ptr) { /* Math operations (assignment) on a variable */ -unsigned int SCR_3B_MathExpr(void) { - unsigned short op1, op2; - unsigned char *opptr; +uint16 SCR_3B_MathExpr(void) { + uint16 op1, op2; + byte *opptr; script_ptr++; @@ -530,7 +530,7 @@ unsigned int SCR_3B_MathExpr(void) { } /*Discard current callchain (the real one) and execute command*/ -unsigned int SCR_4D_PriorityCommand(void) { +uint16 SCR_4D_PriorityCommand(void) { script_ptr++; the_command = *script_ptr++; /*little-endian*/ the_command |= (*script_ptr++) << 8; @@ -539,7 +539,7 @@ unsigned int SCR_4D_PriorityCommand(void) { } /*Jump to routine*/ -unsigned int SCR_12_Chain(void) { +uint16 SCR_12_Chain(void) { script_ptr++; the_command = *script_ptr++; /*little-endian*/ the_command |= (*script_ptr++) << 8; @@ -551,8 +551,8 @@ unsigned int SCR_12_Chain(void) { Absolute jump Jumping past current routine ends the script */ -unsigned int SCR_33_Jump(void) { - unsigned short offs; +uint16 SCR_33_Jump(void) { + uint16 offs; script_ptr++; offs = *script_ptr++; /*little-endian*/ offs |= (*script_ptr++) << 8; @@ -563,7 +563,7 @@ unsigned int SCR_33_Jump(void) { /* Conditional jump (IF/ELSE block) */ -unsigned int SCR_3C_CondExpr(void) { +uint16 SCR_3C_CondExpr(void) { script_ptr++; if (MathExpr(&script_ptr)) { @@ -580,8 +580,8 @@ unsigned int SCR_3C_CondExpr(void) { /* Absolute subroutine call */ -unsigned int SCR_34_Call(void) { - unsigned short offs; +uint16 SCR_34_Call(void) { + uint16 offs; script_ptr++; offs = *script_ptr++; /*little-endian*/ offs |= (*script_ptr++) << 8; @@ -594,15 +594,15 @@ unsigned int SCR_34_Call(void) { /* Return from script subroutine */ -unsigned int SCR_35_Ret(void) { +uint16 SCR_35_Ret(void) { script_end_ptr = *(--script_stack_ptr); script_ptr = *(--script_stack_ptr); return 0; } /*Draw portrait, pushing it from left to right*/ -unsigned int SCR_5_DrawPortraitLiftRight(void) { - unsigned char x, y, width, height; +uint16 SCR_5_DrawPortraitLiftRight(void) { + byte x, y, width, height; script_ptr++; @@ -615,8 +615,8 @@ unsigned int SCR_5_DrawPortraitLiftRight(void) { } /*Draw portrait, pushing it from right to left*/ -unsigned int SCR_6_DrawPortraitLiftLeft(void) { - unsigned char x, y, width, height; +uint16 SCR_6_DrawPortraitLiftLeft(void) { + byte x, y, width, height; script_ptr++; @@ -629,8 +629,8 @@ unsigned int SCR_6_DrawPortraitLiftLeft(void) { } /*Draw portrait, pushing it from top to bottom*/ -unsigned int SCR_7_DrawPortraitLiftDown(void) { - unsigned char x, y, width, height; +uint16 SCR_7_DrawPortraitLiftDown(void) { + byte x, y, width, height; script_ptr++; @@ -643,8 +643,8 @@ unsigned int SCR_7_DrawPortraitLiftDown(void) { } /*Draw portrait, pushing it from bottom to top*/ -unsigned int SCR_8_DrawPortraitLiftUp(void) { - unsigned char x, y, width, height; +uint16 SCR_8_DrawPortraitLiftUp(void) { + byte x, y, width, height; script_ptr++; @@ -657,8 +657,8 @@ unsigned int SCR_8_DrawPortraitLiftUp(void) { } /*Draw portrait, no special effects*/ -unsigned int SCR_9_DrawPortrait(void) { - unsigned char x, y, width, height; +uint16 SCR_9_DrawPortrait(void) { + byte x, y, width, height; script_ptr++; @@ -670,9 +670,9 @@ unsigned int SCR_9_DrawPortrait(void) { } /*Draw screen pixels using 2-phase clockwise twist*/ -void TwistDraw(unsigned char x, unsigned char y, unsigned char width, unsigned char height, unsigned char *source, unsigned char *target) { - int i; - unsigned int sx, ex, sy, ey, t; +void TwistDraw(byte x, byte y, byte width, byte height, byte *source, byte *target) { + int16 i; + uint16 sx, ex, sy, ey, t; sx = x * 4; ex = x * 4 + width * 4 - 1; sy = y; @@ -702,9 +702,9 @@ void TwistDraw(unsigned char x, unsigned char y, unsigned char width, unsigned c } /*Draw image with twist-effect*/ -unsigned int SCR_B_DrawPortraitTwistEffect(void) { - unsigned char x, y, width, height; - unsigned int offs; +uint16 SCR_B_DrawPortraitTwistEffect(void) { + byte x, y, width, height; + uint16 offs; script_ptr++; @@ -721,9 +721,9 @@ unsigned int SCR_B_DrawPortraitTwistEffect(void) { } /*Draw screen pixels using arc-like sweep*/ -void ArcDraw(unsigned char x, unsigned char y, unsigned char width, unsigned char height, unsigned char *source, unsigned char *target) { - int i; - unsigned int sx, ex, sy, ey; +void ArcDraw(byte x, byte y, byte width, byte height, byte *source, byte *target) { + int16 i; + uint16 sx, ex, sy, ey; sx = x * 4; ex = x * 4 + width * 2 - 1; sy = y + height - 1; @@ -749,9 +749,9 @@ void ArcDraw(unsigned char x, unsigned char y, unsigned char width, unsigned cha } /*Draw image with arc-effect*/ -unsigned int SCR_C_DrawPortraitArcEffect(void) { - unsigned char x, y, width, height; - unsigned int offs; +uint16 SCR_C_DrawPortraitArcEffect(void) { + byte x, y, width, height; + uint16 offs; script_ptr++; @@ -768,11 +768,11 @@ unsigned int SCR_C_DrawPortraitArcEffect(void) { } /*Draw image with slow top-to-down reveal effect by repeatedly draw its every 17th pixel*/ -unsigned int SCR_D_DrawPortraitDotEffect(void) { - int i; - unsigned char x, y, width, height; - unsigned int offs, step = 17; - unsigned char *target = CGA_SCREENBUFFER; +uint16 SCR_D_DrawPortraitDotEffect(void) { + int16 i; + byte x, y, width, height; + uint16 offs, step = 17; + byte *target = CGA_SCREENBUFFER; script_ptr++; @@ -792,8 +792,8 @@ unsigned int SCR_D_DrawPortraitDotEffect(void) { } /*Draw image with slow zoom-in reveal effect*/ -unsigned int SCR_E_DrawPortraitZoomIn(void) { - unsigned char x, y, width, height; +uint16 SCR_E_DrawPortraitZoomIn(void) { + byte x, y, width, height; script_ptr++; @@ -809,12 +809,12 @@ unsigned int SCR_E_DrawPortraitZoomIn(void) { /*Hide portrait, pushing it from right to left*/ -unsigned int SCR_19_HidePortraitLiftLeft(void) { - unsigned char index; - unsigned char kind; - unsigned char x, y; - unsigned char width, height; - unsigned int offs; +uint16 SCR_19_HidePortraitLiftLeft(void) { + byte index; + byte kind; + byte x, y; + byte width, height; + uint16 offs; script_ptr++; index = *script_ptr++; @@ -850,12 +850,12 @@ unsigned int SCR_19_HidePortraitLiftLeft(void) { } /*Hide portrait, pushing it from left to right*/ -unsigned int SCR_1A_HidePortraitLiftRight(void) { - unsigned char index; - unsigned char kind; - unsigned char x, y; - unsigned char width, height; - unsigned int offs; +uint16 SCR_1A_HidePortraitLiftRight(void) { + byte index; + byte kind; + byte x, y; + byte width, height; + uint16 offs; script_ptr++; index = *script_ptr++; @@ -890,12 +890,12 @@ unsigned int SCR_1A_HidePortraitLiftRight(void) { } /*Hide portrait, pushing it from bottom to top*/ -unsigned int SCR_1B_HidePortraitLiftUp(void) { - unsigned char index; - unsigned char kind; - unsigned char x, y; - unsigned char width, height; - unsigned int offs; +uint16 SCR_1B_HidePortraitLiftUp(void) { + byte index; + byte kind; + byte x, y; + byte width, height; + uint16 offs; script_ptr++; index = *script_ptr++; @@ -923,12 +923,12 @@ unsigned int SCR_1B_HidePortraitLiftUp(void) { /*Hide portrait, pushing it from top to bottom*/ -unsigned int SCR_1C_HidePortraitLiftDown(void) { - unsigned char index; - unsigned char kind; - unsigned char x, y; - unsigned char width, height; - unsigned int offs; +uint16 SCR_1C_HidePortraitLiftDown(void) { + byte index; + byte kind; + byte x, y; + byte width, height; + uint16 offs; script_ptr++; index = *script_ptr++; @@ -956,12 +956,12 @@ unsigned int SCR_1C_HidePortraitLiftDown(void) { /*Hide portrait with twist effect*/ -unsigned int SCR_1E_HidePortraitTwist(void) { - unsigned char index; - unsigned char kind; - unsigned char x, y; - unsigned char width, height; - unsigned int offs; +uint16 SCR_1E_HidePortraitTwist(void) { + byte index; + byte kind; + byte x, y; + byte width, height; + uint16 offs; script_ptr++; index = *script_ptr++; @@ -978,12 +978,12 @@ unsigned int SCR_1E_HidePortraitTwist(void) { } /*Hide portrait with arc effect*/ -unsigned int SCR_1F_HidePortraitArc(void) { - unsigned char index; - unsigned char kind; - unsigned char x, y; - unsigned char width, height; - unsigned int offs; +uint16 SCR_1F_HidePortraitArc(void) { + byte index; + byte kind; + byte x, y; + byte width, height; + uint16 offs; script_ptr++; index = *script_ptr++; @@ -1000,12 +1000,12 @@ unsigned int SCR_1F_HidePortraitArc(void) { } /*Hide portrait with dots effect*/ -unsigned int SCR_20_HidePortraitDots(void) { - unsigned char index; - unsigned char kind; - unsigned char x, y; - unsigned char width, height; - unsigned int offs; +uint16 SCR_20_HidePortraitDots(void) { + byte index; + byte kind; + byte x, y; + byte width, height; + uint16 offs; script_ptr++; index = *script_ptr++; @@ -1024,8 +1024,8 @@ unsigned int SCR_20_HidePortraitDots(void) { } -unsigned int SCR_39_AnimRoomDoorOpen(void) { - unsigned char door; +uint16 SCR_39_AnimRoomDoorOpen(void) { + byte door; script_ptr++; door = *script_ptr++; @@ -1033,8 +1033,8 @@ unsigned int SCR_39_AnimRoomDoorOpen(void) { return 0; } -unsigned int SCR_3A_AnimRoomDoorClose(void) { - unsigned char door; +uint16 SCR_3A_AnimRoomDoorClose(void) { + byte door; script_ptr++; door = *script_ptr++; @@ -1042,9 +1042,9 @@ unsigned int SCR_3A_AnimRoomDoorClose(void) { return 0; } -unsigned int SCR_25_ChangeZoneOnly(void) { - unsigned char index; - unsigned char old = script_byte_vars.zone_room; +uint16 SCR_25_ChangeZoneOnly(void) { + byte index; + byte old = script_byte_vars.zone_room; script_ptr++; index = *script_ptr++; @@ -1067,7 +1067,7 @@ void AnimStarfield(void) { /*TODO*/ } -unsigned int SCR_26_GameOver(void) { +uint16 SCR_26_GameOver(void) { in_de_profundis = 0; script_byte_vars.game_paused = 1; memset(backbuffer, 0, sizeof(backbuffer) - 2); /*TODO: original bug?*/ @@ -1088,15 +1088,15 @@ unsigned int SCR_26_GameOver(void) { } -unsigned int SCR_4C_DrawZoneObjs(void) { +uint16 SCR_4C_DrawZoneObjs(void) { script_ptr++; DrawZoneObjs(); return 0; } -unsigned int SCR_13_RedrawRoomStatics(void) { - unsigned char index; +uint16 SCR_13_RedrawRoomStatics(void) { + byte index; script_ptr++; index = *script_ptr++; RedrawRoomStatics(index, 0); @@ -1106,8 +1106,8 @@ unsigned int SCR_13_RedrawRoomStatics(void) { /* Load and draw zone (to backbuffer) */ -unsigned int SCR_42_LoadZone(void) { - unsigned char index; +uint16 SCR_42_LoadZone(void) { + byte index; script_ptr++; index = *script_ptr++; @@ -1147,41 +1147,41 @@ unsigned int SCR_42_LoadZone(void) { return 0; } -unsigned int SCR_59_BlitSpritesToBackBuffer(void) { +uint16 SCR_59_BlitSpritesToBackBuffer(void) { script_ptr++; BlitSpritesToBackBuffer(); return 0; } -unsigned int SCR_5A_SelectPalette(void) { +uint16 SCR_5A_SelectPalette(void) { script_ptr++; SelectPalette(); return 0; } -unsigned int SCR_5E_SelectTempPalette(void) { - unsigned char index; +uint16 SCR_5E_SelectTempPalette(void) { + byte index; script_ptr++; index = *script_ptr++; SelectSpecificPalette(index); return 0; } -unsigned int SCR_43_RefreshZone(void) { +uint16 SCR_43_RefreshZone(void) { script_ptr++; RefreshZone(); return 0; } -unsigned int SCR_36_ChangeZone(void) { +uint16 SCR_36_ChangeZone(void) { SCR_42_LoadZone(); RefreshZone(); return 0; } -void SCR_DrawRoomObjectBack(unsigned char *x, unsigned char *y, unsigned char *w, unsigned char *h) { - unsigned char obj[3]; +void SCR_DrawRoomObjectBack(byte *x, byte *y, byte *w, byte *h) { + byte obj[3]; script_ptr++; obj[0] = *script_ptr++; /*spr*/ @@ -1191,14 +1191,14 @@ void SCR_DrawRoomObjectBack(unsigned char *x, unsigned char *y, unsigned char *w DrawRoomStaticObject(obj, x, y, w, h); } -unsigned int SCR_5F_DrawRoomObjectBack(void) { - unsigned char x, y, w, h; +uint16 SCR_5F_DrawRoomObjectBack(void) { + byte x, y, w, h; SCR_DrawRoomObjectBack(&x, &y, &w, &h); return 0; } -unsigned int SCR_11_DrawRoomObject(void) { - unsigned char x, y, w, h; +uint16 SCR_11_DrawRoomObject(void) { + byte x, y, w, h; SCR_DrawRoomObjectBack(&x, &y, &w, &h); CGA_CopyScreenBlock(backbuffer, w, h, CGA_SCREENBUFFER, CGA_CalcXY_p(x, y)); return 0; @@ -1207,12 +1207,12 @@ unsigned int SCR_11_DrawRoomObject(void) { /* Draw box with item sprite and its name */ -unsigned int SCR_3_DrawItemBox(void) { - unsigned char current; +uint16 SCR_3_DrawItemBox(void) { + byte current; item_t *item; - unsigned char x, y; - unsigned char *msg; + byte x, y; + byte *msg; script_ptr++; current = *script_ptr++; @@ -1233,9 +1233,9 @@ unsigned int SCR_3_DrawItemBox(void) { } /*Draw simple bubble with text*/ -unsigned int SCR_37_DesciTextBox(void) { - unsigned char x, y, w; - unsigned char *msg; +uint16 SCR_37_DesciTextBox(void) { + byte x, y, w; + byte *msg; script_ptr++; msg = SeekToStringScr(desci_data, *script_ptr, &script_ptr); script_ptr++; @@ -1248,8 +1248,8 @@ unsigned int SCR_37_DesciTextBox(void) { /*Play portrait animation*/ -unsigned int SCR_18_AnimPortrait(void) { - unsigned char layer, index, delay; +uint16 SCR_18_AnimPortrait(void) { + byte layer, index, delay; script_ptr++; layer = *script_ptr++; @@ -1262,8 +1262,8 @@ unsigned int SCR_18_AnimPortrait(void) { } /*Play animation*/ -unsigned int SCR_38_PlayAnim(void) { - unsigned char index, x, y; +uint16 SCR_38_PlayAnim(void) { + byte index, x, y; script_ptr++; index = *script_ptr++; x = *script_ptr++; @@ -1273,11 +1273,11 @@ unsigned int SCR_38_PlayAnim(void) { } /*Pop up the actions menu and handle its commands*/ -unsigned int SCR_3D_ActionsMenu(void) { - unsigned short cmd; +uint16 SCR_3D_ActionsMenu(void) { + uint16 cmd; - unsigned char *old_script = script_ptr; - unsigned char *old_script_end = script_end_ptr; + byte *old_script = script_ptr; + byte *old_script_end = script_end_ptr; act_menu_x = 0xFF; @@ -1312,7 +1312,7 @@ unsigned int SCR_3D_ActionsMenu(void) { } /*The Wall room puzzle*/ -unsigned int SCR_3E_TheWallAdvance(void) { +uint16 SCR_3E_TheWallAdvance(void) { script_ptr++; script_byte_vars.the_wall_phase = (script_byte_vars.the_wall_phase + 1) % 4; @@ -1337,9 +1337,9 @@ unsigned int SCR_3E_TheWallAdvance(void) { /* When playing cups with proto */ -unsigned int SCR_28_MenuLoop(void) { - unsigned char cursor; - unsigned char mask, value; +uint16 SCR_28_MenuLoop(void) { + byte cursor; + byte mask, value; script_ptr++; cursor = *script_ptr++; @@ -1357,12 +1357,12 @@ unsigned int SCR_28_MenuLoop(void) { /* Restore screen data from back buffer as specified by dirty rects of specified index */ -unsigned int SCR_2A_PopDialogRect(void) { - unsigned char index; - unsigned char kind; - unsigned char x, y; - unsigned char width, height; - unsigned int offs; +uint16 SCR_2A_PopDialogRect(void) { + byte index; + byte kind; + byte x, y; + byte width, height; + uint16 offs; script_ptr++; index = *script_ptr++; @@ -1379,7 +1379,7 @@ unsigned int SCR_2A_PopDialogRect(void) { /* Restore screen data from back buffer as specified by dirty rect of kind dialog bubble */ -unsigned int SCR_2B_PopAllBubbles(void) { +uint16 SCR_2B_PopAllBubbles(void) { script_ptr++; PopDirtyRects(DirtyRectBubble); return 0; @@ -1388,12 +1388,12 @@ unsigned int SCR_2B_PopAllBubbles(void) { /* Hide a portrait, with shatter effect */ -unsigned int SCR_22_HidePortraitShatter(void) { - unsigned char index; - unsigned char kind; - unsigned char x, y; - unsigned char width, height; - unsigned int offs; +uint16 SCR_22_HidePortraitShatter(void) { + byte index; + byte kind; + byte x, y; + byte width, height; + uint16 offs; script_ptr++; index = *script_ptr++; @@ -1412,12 +1412,12 @@ unsigned int SCR_22_HidePortraitShatter(void) { /* Hide a portrait, no special effects */ -unsigned int SCR_23_HidePortrait(void) { - unsigned char index; - unsigned char kind; - unsigned char x, y; - unsigned char width, height; - unsigned int offs; +uint16 SCR_23_HidePortrait(void) { + byte index; + byte kind; + byte x, y; + byte width, height; + uint16 offs; script_ptr++; index = *script_ptr++; @@ -1436,7 +1436,7 @@ unsigned int SCR_23_HidePortrait(void) { /* Restore screen data from back buffer for all portraits */ -unsigned int SCR_24_PopAllPortraits(void) { +uint16 SCR_24_PopAllPortraits(void) { script_ptr++; PopDirtyRects(DirtyRectSprite); return 0; @@ -1445,7 +1445,7 @@ unsigned int SCR_24_PopAllPortraits(void) { /* Restore screen data from back buffer for all text bubbles */ -unsigned int SCR_40_PopAllTextBoxes() { +uint16 SCR_40_PopAllTextBoxes() { script_ptr++; PopDirtyRects(DirtyRectText); return 0; @@ -1454,7 +1454,7 @@ unsigned int SCR_40_PopAllTextBoxes() { /* Move a Hand in Who Will Be Saved */ -unsigned int SCR_41_LiftHand(void) { +uint16 SCR_41_LiftHand(void) { script_ptr++; RedrawRoomStatics(92, script_byte_vars.byte_179E1); CGA_BackBufferToRealFull(); @@ -1462,18 +1462,18 @@ unsigned int SCR_41_LiftHand(void) { return 0; } -unsigned char fight_mode = 0; +byte fight_mode = 0; -unsigned int SCR_30_Fight(void) { - static unsigned char player_image[] = {26, 0, 0}; - unsigned char *image = player_image; +uint16 SCR_30_Fight(void) { + static byte player_image[] = {26, 0, 0}; + byte *image = player_image; - unsigned char x, y, width, height, kind; - unsigned int offs; - unsigned char *old_script, *old_script_end = script_end_ptr; + byte x, y, width, height, kind; + uint16 offs; + byte *old_script, *old_script_end = script_end_ptr; pers_t *pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]); - unsigned char strenght, win, rnd; + byte strenght, win, rnd; script_ptr++; old_script = script_ptr; @@ -1522,7 +1522,7 @@ unsigned int SCR_30_Fight(void) { script_byte_vars.byte_179F2 = 0; if (script_byte_vars.byte_179F3 == 0) { - static unsigned char character_strenght[] = {1, 3, 1, 1, 1, 1, 5, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1}; + static byte character_strenght[] = {1, 3, 1, 1, 1, 1, 5, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1}; strenght = character_strenght[pers->name - 42]; @@ -1574,11 +1574,11 @@ unsigned int SCR_30_Fight(void) { return 0; } -unsigned char prev_fight_mode = 0; -unsigned short fight_pers_ofs = 0; +byte prev_fight_mode = 0; +uint16 fight_pers_ofs = 0; typedef struct fightentry_t { - unsigned char room; + byte room; animdesc_t anim; } fightentry_t; @@ -1651,12 +1651,12 @@ fightentry_t fightlist3[] = { }; /*Draw defeated enemy*/ -unsigned int SCR_31_Fight2(void) { +uint16 SCR_31_Fight2(void) { script_ptr++; if (script_byte_vars.byte_179F9 != 18) { pers_t *pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]); - fight_pers_ofs = (unsigned char *)pers - (unsigned char *)pers_list; /*TODO check size*/ + fight_pers_ofs = (byte *)pers - (byte *)pers_list; /*TODO check size*/ pers->flags |= PERSFLG_40; pers->area = 0; found_spot->flags &= ~SPOTFLG_80; @@ -1684,10 +1684,10 @@ unsigned int SCR_31_Fight2(void) { && fight_mode == 0) { script_byte_vars.byte_179F2 &= ~1; } else { - unsigned int i; + uint16 i; fightentry_t *fightlist; - unsigned int fightlistsize; - unsigned char animidx; + uint16 fightlistsize; + byte animidx; prev_fight_mode = 0; switch (pers->name) { @@ -1746,7 +1746,7 @@ void FightWin(void) { script_byte_vars.byte_179F3 = 0; } -unsigned int SCR_32_FightWin(void) { +uint16 SCR_32_FightWin(void) { script_ptr++; @@ -1756,7 +1756,7 @@ unsigned int SCR_32_FightWin(void) { } void DrawDeathAnim(void) { - int i; + int16 i; /*remove existing cadaver if any*/ if (FindAndSelectSpot(38 * 5)) { @@ -1772,7 +1772,7 @@ void DrawDeathAnim(void) { } } -unsigned int SCR_16_DrawDeathAnim(void) { +uint16 SCR_16_DrawDeathAnim(void) { script_ptr++; DrawDeathAnim(); @@ -1780,7 +1780,7 @@ unsigned int SCR_16_DrawDeathAnim(void) { return 0; } -unsigned int SCR_60_ReviveCadaver(void) { +uint16 SCR_60_ReviveCadaver(void) { pers_t *pers; script_ptr++; @@ -1808,8 +1808,8 @@ unsigned int SCR_60_ReviveCadaver(void) { } -unsigned int SCR_57_ShowCharacterSprite(void) { - unsigned char index, x, y; +uint16 SCR_57_ShowCharacterSprite(void) { + byte index, x, y; script_ptr++; index = *script_ptr++; @@ -1821,8 +1821,8 @@ unsigned int SCR_57_ShowCharacterSprite(void) { return 0; } -unsigned int SCR_58_DrawCharacterSprite(void) { - unsigned char index, x, y; +uint16 SCR_58_DrawCharacterSprite(void) { + byte index, x, y; script_ptr++; index = *script_ptr++; @@ -1836,8 +1836,8 @@ unsigned int SCR_58_DrawCharacterSprite(void) { extern void ExitGame(void); -unsigned int SCR_15_SelectSpot(void) { - unsigned char mask, index; +uint16 SCR_15_SelectSpot(void) { + byte mask, index; script_ptr++; mask = *script_ptr++; @@ -1861,7 +1861,7 @@ unsigned int SCR_15_SelectSpot(void) { return 0; } -unsigned int SCR_44_BackBufferToScreen(void) { +uint16 SCR_44_BackBufferToScreen(void) { script_ptr++; CGA_BackBufferToRealFull(); return 0; @@ -1870,9 +1870,9 @@ unsigned int SCR_44_BackBufferToScreen(void) { /* Animate De Profundis room on entry */ -unsigned int SCR_45_DeProfundisRoomEntry(void) { - unsigned int w, h; - unsigned int sprofs, ofs; +uint16 SCR_45_DeProfundisRoomEntry(void) { + uint16 w, h; + uint16 sprofs, ofs; script_ptr++; @@ -1906,10 +1906,10 @@ unsigned int SCR_45_DeProfundisRoomEntry(void) { /* Animate De Profundis hook (lower) */ -unsigned int SCR_46_DeProfundisLowerHook(void) { - unsigned char y; - unsigned int w, h; - unsigned int sprofs, ofs; +uint16 SCR_46_DeProfundisLowerHook(void) { + byte y; + uint16 w, h; + uint16 sprofs, ofs; script_ptr++; @@ -1936,10 +1936,10 @@ unsigned int SCR_46_DeProfundisLowerHook(void) { /* Animate De Profundis monster (rise) */ -unsigned int SCR_47_DeProfundisRiseMonster(void) { - unsigned char y; - unsigned int w, h; - unsigned int sprofs, ofs; +uint16 SCR_47_DeProfundisRiseMonster(void) { + byte y; + uint16 w, h; + uint16 sprofs, ofs; script_ptr++; @@ -1967,10 +1967,10 @@ unsigned int SCR_47_DeProfundisRiseMonster(void) { /* Animate De Profundis monster (lower) */ -unsigned int SCR_48_DeProfundisLowerMonster(void) { - unsigned char y; - unsigned int w, h; - unsigned int sprofs, ofs; +uint16 SCR_48_DeProfundisLowerMonster(void) { + byte y; + uint16 w, h; + uint16 sprofs, ofs; script_ptr++; @@ -1997,10 +1997,10 @@ unsigned int SCR_48_DeProfundisLowerMonster(void) { /* Animate De Profundis hook (rise) */ -unsigned int SCR_49_DeProfundisRiseHook(void) { - unsigned char y; - unsigned int w, h; - unsigned int sprofs, ofs; +uint16 SCR_49_DeProfundisRiseHook(void) { + byte y; + uint16 w, h; + uint16 sprofs, ofs; script_ptr++; @@ -2029,11 +2029,11 @@ unsigned int SCR_49_DeProfundisRiseHook(void) { /* Animate De Profundis platform */ -unsigned int SCR_65_DeProfundisMovePlatform(void) { - unsigned char state; - unsigned char x, y; - unsigned int w, h; - unsigned int sprofs, ofs; +uint16 SCR_65_DeProfundisMovePlatform(void) { + byte state; + byte x, y; + uint16 w, h; + uint16 sprofs, ofs; script_ptr++; state = *script_ptr++; @@ -2074,9 +2074,9 @@ unsigned int SCR_65_DeProfundisMovePlatform(void) { /* Animate De Profundis monster ride to exit door */ -unsigned int SCR_66_DeProfundisRideToExit(void) { - unsigned int w, h; - unsigned int sprofs, ofs; +uint16 SCR_66_DeProfundisRideToExit(void) { + uint16 w, h; + uint16 sprofs, ofs; script_ptr++; @@ -2095,7 +2095,7 @@ unsigned int SCR_66_DeProfundisRideToExit(void) { /* Draw item bounce to room objects animation */ -unsigned int SCR_4E_BounceCurrentItemToRoom(void) { +uint16 SCR_4E_BounceCurrentItemToRoom(void) { script_ptr++; BounceCurrentItem(ITEMFLG_40, 43); return 0; @@ -2104,7 +2104,7 @@ unsigned int SCR_4E_BounceCurrentItemToRoom(void) { /* Draw item bounce to inventory animation */ -unsigned int SCR_4F_BounceCurrentItemToInventory(void) { +uint16 SCR_4F_BounceCurrentItemToInventory(void) { script_ptr++; BounceCurrentItem(ITEMFLG_80, 85); return 0; @@ -2113,8 +2113,8 @@ unsigned int SCR_4F_BounceCurrentItemToInventory(void) { /* Draw item bounce to inventory animation */ -unsigned int SCR_50_BounceItemToInventory(void) { - unsigned char itemidx; +uint16 SCR_50_BounceItemToInventory(void) { + byte itemidx; script_ptr++; itemidx = *script_ptr++; @@ -2127,7 +2127,7 @@ unsigned int SCR_50_BounceItemToInventory(void) { /* Take away Protozorq's zapstik and bounce it to room */ -unsigned int SCR_4B_ProtoDropZapstik(void) { +uint16 SCR_4B_ProtoDropZapstik(void) { pers_t *pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]); script_ptr++; @@ -2159,15 +2159,15 @@ void TakePersonsItem(void) { the_command = 0x9140; /*NOTHING ON HIM*/ } -unsigned int SCR_2F_TakePersonsItem() { +uint16 SCR_2F_TakePersonsItem() { script_ptr++; TakePersonsItem(); return ScriptRerun; } -unsigned int SCR_51_ItemTrade(void) { - unsigned char *old_script, *old_script_end = script_end_ptr; - unsigned char status; +uint16 SCR_51_ItemTrade(void) { + byte *old_script, *old_script_end = script_end_ptr; + byte status; if (script_byte_vars.byte_179DC >= 63) /*TODO: hang?*/ return 0; @@ -2212,14 +2212,14 @@ unsigned int SCR_51_ItemTrade(void) { return 0; } -unsigned int SCR_52_RefreshSpritesData(void) { +uint16 SCR_52_RefreshSpritesData(void) { script_ptr++; RefreshSpritesData(); return 0; } -unsigned int SCR_53_FindInvItem(void) { - unsigned char first, count, flags, i; +uint16 SCR_53_FindInvItem(void) { + byte first, count, flags, i; item_t *item; script_ptr++; first = *script_ptr++; @@ -2236,7 +2236,7 @@ unsigned int SCR_53_FindInvItem(void) { return 0; } -unsigned int SCR_55_DrawRoomItemsIndicator(void) { +uint16 SCR_55_DrawRoomItemsIndicator(void) { script_ptr++; DrawRoomItemsIndicator(); return 0; @@ -2245,8 +2245,8 @@ unsigned int SCR_55_DrawRoomItemsIndicator(void) { /* Discard all inventory items */ -unsigned int SCR_5C_ClearInventory(void) { - int i; +uint16 SCR_5C_ClearInventory(void) { + int16 i; script_ptr++; for (i = 0; i < MAX_INV_ITEMS; i++) { @@ -2262,8 +2262,8 @@ unsigned int SCR_5C_ClearInventory(void) { /* Drop group of items from inventory to room */ -void DropItems(int first, int count) { - int i; +void DropItems(int16 first, int16 count) { + int16 i; for (i = 0; i < count; i++) { if (inventory_items[first + i].flags == ITEMFLG_80) { @@ -2276,7 +2276,7 @@ void DropItems(int first, int count) { /* Drop weapon-like items from inventory to room */ -unsigned int SCR_5D_DropWeapons(void) { +uint16 SCR_5D_DropWeapons(void) { script_ptr++; DropItems(18, 4); /*DAGGER*/ @@ -2291,9 +2291,9 @@ unsigned int SCR_5D_DropWeapons(void) { /* React to Psi power */ -unsigned int SCR_62_PsiReaction(void) { - unsigned char power; - unsigned short cmd; +uint16 SCR_62_PsiReaction(void) { + byte power; + uint16 cmd; script_ptr++; power = *script_ptr++; @@ -2308,7 +2308,7 @@ unsigned int SCR_62_PsiReaction(void) { } /*TODO: rename me*/ -unsigned int SCR_63_LiftSpot6(void) { +uint16 SCR_63_LiftSpot6(void) { script_ptr++; BlitSpritesToBackBuffer(); @@ -2321,7 +2321,7 @@ unsigned int SCR_63_LiftSpot6(void) { return 0; } -unsigned int SCR_64_DrawBoxAroundSpot(void) { +uint16 SCR_64_DrawBoxAroundSpot(void) { script_ptr++; DrawBoxAroundSpot(); return 0; @@ -2330,8 +2330,8 @@ unsigned int SCR_64_DrawBoxAroundSpot(void) { /* Draw text box */ -unsigned int SCR_14_DrawDesc(void) { - unsigned char *msg; +uint16 SCR_14_DrawDesc(void) { + byte *msg; script_ptr++; msg = SeekToStringScr(desci_data, *script_ptr, &script_ptr); script_ptr++; @@ -2346,9 +2346,9 @@ unsigned int SCR_14_DrawDesc(void) { Draw dialog bubble with text for a person, wait for a key, then hide. Auto find bubble location Use "thought" spike */ -unsigned int SCR_17_DrawPersonThoughtBubbleDialog(void) { - unsigned char x, y; - unsigned char *msg; +uint16 SCR_17_DrawPersonThoughtBubbleDialog(void) { + byte x, y; + byte *msg; script_ptr++; msg = SeekToStringScr(diali_data, *script_ptr, &script_ptr); script_ptr++; @@ -2370,9 +2370,9 @@ unsigned int SCR_17_DrawPersonThoughtBubbleDialog(void) { Draw dialog bubble with text for a person, wait for a key, then hide. Auto find bubble location Use normal spike */ -unsigned int SCR_61_DrawPersonBubbleDialog(void) { - unsigned char x, y; - unsigned char *msg; +uint16 SCR_61_DrawPersonBubbleDialog(void) { + byte x, y; + byte *msg; script_ptr++; msg = SeekToStringScr(diali_data, *script_ptr, &script_ptr); script_ptr++; @@ -2391,10 +2391,10 @@ unsigned int SCR_61_DrawPersonBubbleDialog(void) { } #if 1 -unsigned char *DebugString(char *msg, ...) { - int i; - unsigned char c; - static unsigned char m[256]; +byte *DebugString(char *msg, ...) { + int16 i; + byte c; + static byte m[256]; va_list ap; va_start(ap, msg); @@ -2433,8 +2433,8 @@ unsigned char *DebugString(char *msg, ...) { /* Draw dialog bubble with text for gauss */ -unsigned int SCR_27_DrawGaussBubble(void) { - unsigned char *msg; +uint16 SCR_27_DrawGaussBubble(void) { + byte *msg; script_ptr++; msg = SeekToStringScr(diali_data, *script_ptr, &script_ptr); @@ -2447,9 +2447,9 @@ unsigned int SCR_27_DrawGaussBubble(void) { /* Draw dialog bubble with text */ -unsigned int SCR_29_DialiTextBox(void) { - unsigned char x, y, f; - unsigned char *msg; +uint16 SCR_29_DialiTextBox(void) { + byte x, y, f; + byte *msg; script_ptr++; msg = SeekToStringScr(diali_data, *script_ptr, &script_ptr); cur_dlg_index = cur_str_index; /*TODO: useless?*/ @@ -2466,7 +2466,7 @@ unsigned int SCR_29_DialiTextBox(void) { /* Do nothing in PC/CGA version */ -unsigned int SCR_67_Unused(void) { +uint16 SCR_67_Unused(void) { script_ptr++; script_ptr++; return 0; @@ -2475,7 +2475,7 @@ unsigned int SCR_67_Unused(void) { /* Do nothing in PC/CGA version */ -unsigned int SCR_68_Unused(void) { +uint16 SCR_68_Unused(void) { script_ptr++; script_ptr++; return 0; @@ -2484,8 +2484,8 @@ unsigned int SCR_68_Unused(void) { /* Play sound */ -unsigned int SCR_69_PlaySound(void) { - unsigned char index; +uint16 SCR_69_PlaySound(void) { + byte index; script_ptr++; index = *script_ptr++; script_ptr++; @@ -2497,7 +2497,7 @@ unsigned int SCR_69_PlaySound(void) { /* Do nothing in PC/CGA version */ -unsigned int SCR_6A_Unused(void) { +uint16 SCR_6A_Unused(void) { script_ptr++; return 0; } @@ -2505,7 +2505,7 @@ unsigned int SCR_6A_Unused(void) { /* Open room's items inventory */ -unsigned int CMD_1_RoomObjects(void) { +uint16 CMD_1_RoomObjects(void) { UpdateUndrawCursor(CGA_SCREENBUFFER); inv_bgcolor = 0xAA; OpenInventory((0xFF << 8) | ITEMFLG_40, (script_byte_vars.zone_area << 8) | ITEMFLG_40); @@ -2515,7 +2515,7 @@ unsigned int CMD_1_RoomObjects(void) { /* Open Psi Powers menu */ -unsigned int CMD_2_PsiPowers(void) { +uint16 CMD_2_PsiPowers(void) { /*Psi powers bar*/ BackupAndShowSprite(3, 280 / 4, 40); ProcessInput(); @@ -2537,7 +2537,7 @@ unsigned int CMD_2_PsiPowers(void) { /* Open normal inventory box */ -unsigned int CMD_3_Posessions(void) { +uint16 CMD_3_Posessions(void) { UpdateUndrawCursor(CGA_SCREENBUFFER); inv_bgcolor = 0x55; OpenInventory(ITEMFLG_80, ITEMFLG_80); @@ -2547,11 +2547,11 @@ unsigned int CMD_3_Posessions(void) { /* Show energy level */ -unsigned int CMD_4_EnergyLevel(void) { - static unsigned char energy_image[] = {130, 236 / 4, 71}; - unsigned char x, y, width, height; - unsigned char *image = energy_image; - unsigned char anim = 40; +uint16 CMD_4_EnergyLevel(void) { + static byte energy_image[] = {130, 236 / 4, 71}; + byte x, y, width, height; + byte *image = energy_image; + byte anim = 40; PopDirtyRects(DirtyRectSprite); PopDirtyRects(DirtyRectBubble); @@ -2577,7 +2577,7 @@ unsigned int CMD_4_EnergyLevel(void) { /* Advance time */ -unsigned int CMD_5_Wait(void) { +uint16 CMD_5_Wait(void) { script_byte_vars.byte_179DB++; script_word_vars.timer_ticks2 = Swap16(Swap16(script_word_vars.timer_ticks2) + 300); @@ -2609,7 +2609,7 @@ unsigned int CMD_5_Wait(void) { /* Load game (menu) */ -unsigned int CMD_6_Load(void) { +uint16 CMD_6_Load(void) { the_command = 0xC35C; return ScriptRerun; } @@ -2617,7 +2617,7 @@ unsigned int CMD_6_Load(void) { /* Save game (menu) */ -unsigned int CMD_7_Save(void) { +uint16 CMD_7_Save(void) { the_command = 0xC35D; return ScriptRerun; } @@ -2625,18 +2625,18 @@ unsigned int CMD_7_Save(void) { /* Show timer */ -unsigned int CMD_8_Timer(void) { - static unsigned char timer_image[] = {163, 244 / 4, 104}; - unsigned char x, y, width, height; - unsigned char *image = timer_image; +uint16 CMD_8_Timer(void) { + static byte timer_image[] = {163, 244 / 4, 104}; + byte x, y, width, height; + byte *image = timer_image; if (DrawPortrait(&image, &x, &y, &width, &height)) { CGA_BlitAndWait(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs); } do { - unsigned short timer = Swap16(script_word_vars.timer_ticks2); - unsigned short minutes = timer % (60 * 60); + uint16 timer = Swap16(script_word_vars.timer_ticks2); + uint16 minutes = timer % (60 * 60); char_draw_coords_x = 260 / 4; char_draw_coords_y = 120; @@ -2654,8 +2654,8 @@ unsigned int CMD_8_Timer(void) { return 0; } -int ConsumePsiEnergy(unsigned char amount) { - unsigned char current = script_byte_vars.psy_energy; +int16 ConsumePsiEnergy(byte amount) { + byte current = script_byte_vars.psy_energy; if (current < amount) { /*no energy left*/ @@ -2672,7 +2672,7 @@ int ConsumePsiEnergy(unsigned char amount) { return 1; } -unsigned int CMD_A_PsiSolarEyes(void) { +uint16 CMD_A_PsiSolarEyes(void) { if (!ConsumePsiEnergy(2)) return 0; @@ -2690,17 +2690,17 @@ unsigned int CMD_A_PsiSolarEyes(void) { } -unsigned short GetZoneObjCommand(unsigned int offs) { +uint16 GetZoneObjCommand(uint16 offs) { /*TODO: fix me: change offs/2 to index*/ the_command = Swap16(script_word_vars.zone_obj_cmds[(script_byte_vars.cur_spot_idx - 1) * 5 + offs / 2]); return the_command; } void DrawStickyNet(void) { - unsigned char x, y, w, h; + byte x, y, w, h; - unsigned int ofs; - unsigned char *sprite = LoadPuzzlToScratch(80); + uint16 ofs; + byte *sprite = LoadPuzzlToScratch(80); x = room_bounds_rect.sx; y = room_bounds_rect.sy; @@ -2712,14 +2712,14 @@ void DrawStickyNet(void) { /*16x30 is the net sprite size*/ for (; h; h -= 30) { - int i; + int16 i; for (i = 0; i < w; i += 16 / 4) DrawSprite(sprite, frontbuffer, ofs + i); ofs += CGA_BYTES_PER_LINE * 30 / 2; } } -unsigned int CMD_B_PsiStickyFingers(void) { +uint16 CMD_B_PsiStickyFingers(void) { if (!ConsumePsiEnergy(3)) return 0; @@ -2747,7 +2747,7 @@ unsigned int CMD_B_PsiStickyFingers(void) { return ScriptRerun; } -unsigned int CMD_C_PsiKnowMind(void) { +uint16 CMD_C_PsiKnowMind(void) { if (!ConsumePsiEnergy(1)) return 0; @@ -2764,7 +2764,7 @@ unsigned int CMD_C_PsiKnowMind(void) { return ScriptRerun; } -unsigned int CMD_D_PsiBrainwarp(void) { +uint16 CMD_D_PsiBrainwarp(void) { if (!ConsumePsiEnergy(2)) return 0; @@ -2806,9 +2806,9 @@ unsigned int CMD_D_PsiBrainwarp(void) { } -unsigned int CMD_E_PsiZoneScan(void) { - unsigned char x, y, w, h; - unsigned int offs; +uint16 CMD_E_PsiZoneScan(void) { + byte x, y, w, h; + uint16 offs; if (!ConsumePsiEnergy(1)) return 0; @@ -2852,7 +2852,7 @@ unsigned int CMD_E_PsiZoneScan(void) { } -unsigned int CMD_F_PsiPsiShift(void) { +uint16 CMD_F_PsiPsiShift(void) { if (!ConsumePsiEnergy(3)) return 0; @@ -2874,8 +2874,8 @@ unsigned int CMD_F_PsiPsiShift(void) { return ScriptRerun; } -unsigned int CMD_10_PsiExtremeViolence(void) { - unsigned short command; +uint16 CMD_10_PsiExtremeViolence(void) { + uint16 command; if (!ConsumePsiEnergy(8)) return 0; @@ -2907,9 +2907,9 @@ unsigned int CMD_10_PsiExtremeViolence(void) { return ScriptRerun; } -unsigned int CMD_11_PsiTuneIn(void) { - unsigned short command; - unsigned char *msg; +uint16 CMD_11_PsiTuneIn(void) { + uint16 command; + byte *msg; if (!ConsumePsiEnergy(4)) return 0; @@ -2940,12 +2940,12 @@ unsigned int CMD_11_PsiTuneIn(void) { return 0; } -void ActionForPersonChoice(unsigned short *actions) { +void ActionForPersonChoice(uint16 *actions) { ProcessMenu(); the_command = 0x9183; /*THERE`S NOBODY.*/ if (script_byte_vars.cur_spot_idx != 0 && script_byte_vars.cur_pers != 0) { pers_t *pers = (pers_t *)script_vars[ScrPool8_CurrentPers]; - unsigned char index = pers->name; + byte index = pers->name; if (index == 93) /*CADAVER*/ index = 19 + 42; else if (index == 133) /*SCI FI*/ @@ -2960,7 +2960,7 @@ void ActionForPersonChoice(unsigned short *actions) { } /*TODO: ensure these are never accessed/modified from the scripts*/ -unsigned short menu_commands_12[] = { +uint16 menu_commands_12[] = { 0xC0F0, 0xC0D7, 0x9019, @@ -2983,7 +2983,7 @@ unsigned short menu_commands_12[] = { 0x9007 }; -unsigned short menu_commands_22[] = { +uint16 menu_commands_22[] = { 0xC325, 0xC326, 0xC31B, @@ -3006,7 +3006,7 @@ unsigned short menu_commands_22[] = { 0xC324 }; -unsigned short menu_commands_24[] = { +uint16 menu_commands_24[] = { 0xC344, 0xC34A, 0xC343, @@ -3029,7 +3029,7 @@ unsigned short menu_commands_24[] = { 0xC343 }; -unsigned short menu_commands_23[] = { +uint16 menu_commands_23[] = { 0xC002, 0xC32A, 0x9019, @@ -3052,20 +3052,20 @@ unsigned short menu_commands_23[] = { 0xC32D }; -unsigned int CMD_12_(void) { +uint16 CMD_12_(void) { printf("cmd 12\n"); ActionForPersonChoice(menu_commands_12); return ScriptRerun; } -unsigned int CMD_13_ActivateFountain(void) { - static unsigned char water1[] = {125, 156 / 4, 58}; - static unsigned char water2[] = {126, 156 / 4, 58}; - static unsigned char headl[] = {88, 152 / 4, 52}; - static unsigned char headr[] = {88, (160 / 4) | 0x80, 52}; +uint16 CMD_13_ActivateFountain(void) { + static byte water1[] = {125, 156 / 4, 58}; + static byte water2[] = {126, 156 / 4, 58}; + static byte headl[] = {88, 152 / 4, 52}; + static byte headr[] = {88, (160 / 4) | 0x80, 52}; - unsigned char x, y, w, h; - unsigned int i, j; + byte x, y, w, h; + uint16 i, j; script_byte_vars.byte_17A20 = 1; for (i = 0; i < 10; i++) { @@ -3088,7 +3088,7 @@ unsigned int CMD_13_ActivateFountain(void) { } /*Vorts walking into the room*/ -unsigned int CMD_14_VortAppear(void) { +uint16 CMD_14_VortAppear(void) { /*TODO: check me*/ pers_list[0].area = script_byte_vars.zone_area; FindAndSelectSpot(0); @@ -3106,8 +3106,8 @@ pers_t *pers_vort_ptr; #define ADJACENT_AREAS_MAX 19 struct { - unsigned char zone; /* current zone */ - unsigned char area; /* area accessible from this zone */ + byte zone; /* current zone */ + byte area; /* area accessible from this zone */ } adjacent_areas[ADJACENT_AREAS_MAX] = { { 2, 5}, { 3, 8}, @@ -3131,10 +3131,10 @@ struct { }; /*Vorts walking out of the room*/ -unsigned int CMD_15_VortLeave(void) { +uint16 CMD_15_VortLeave(void) { /*TODO: check me*/ - unsigned int i; + uint16 i; animdesc_t *anim; pers_t *pers; @@ -3176,18 +3176,18 @@ unsigned int CMD_15_VortLeave(void) { /* Vorts left the room */ -unsigned int CMD_16_VortGone(void) { +uint16 CMD_16_VortGone(void) { pers_vort_ptr->area = 0; next_command3 = 0; return 0; } -unsigned int CMD_17_TakePersonsItem() { +uint16 CMD_17_TakePersonsItem() { TakePersonsItem(); return ScriptRerun; } -unsigned int CMD_18_AspirantLeave(void) { +uint16 CMD_18_AspirantLeave(void) { /*TODO: check me*/ static const animdesc_t anim33 = {ANIMFLG_USESPOT | 33}; @@ -3211,10 +3211,10 @@ unsigned int CMD_18_AspirantLeave(void) { /* Show Holo screen anim and speech */ -unsigned int CMD_1B_Holo(void) { - unsigned char x, y; - unsigned int num; - unsigned char *msg; +uint16 CMD_1B_Holo(void) { + byte x, y; + uint16 num; + byte *msg; x = found_spot->sx; y = found_spot->sy; @@ -3243,7 +3243,7 @@ unsigned int CMD_1B_Holo(void) { /* Turkey walking into the room */ -unsigned int CMD_1E_TurkeyAppear(void) { +uint16 CMD_1E_TurkeyAppear(void) { /*TODO: check me*/ pers_list[5].area = script_byte_vars.zone_area; FindAndSelectSpot(5 * 5); @@ -3259,8 +3259,8 @@ unsigned int CMD_1E_TurkeyAppear(void) { /* Turkey leaving the room */ -unsigned int CMD_1F_TurkeyLeave(void) { - unsigned int i; +uint16 CMD_1F_TurkeyLeave(void) { + uint16 i; animdesc_t *anim; pers_t *pers; @@ -3287,7 +3287,7 @@ unsigned int CMD_1F_TurkeyLeave(void) { /* Turkey left the room */ -unsigned int CMD_20_TurkeyGone(void) { +uint16 CMD_20_TurkeyGone(void) { pers_list[5].area = 0; next_command4 = 0; return 0; @@ -3296,10 +3296,10 @@ unsigned int CMD_20_TurkeyGone(void) { /* Talk to Vorts */ -unsigned int CMD_21_VortTalk(void) { - unsigned char x, y; - unsigned int num; - unsigned char *msg; +uint16 CMD_21_VortTalk(void) { + byte x, y; + uint16 num; + byte *msg; if (script_byte_vars.rand_value >= 85) num = 6; @@ -3325,22 +3325,22 @@ unsigned int CMD_21_VortTalk(void) { return 0; } -unsigned int CMD_22_(void) { +uint16 CMD_22_(void) { ActionForPersonChoice(menu_commands_22); return ScriptRerun; } -unsigned int CMD_23_(void) { +uint16 CMD_23_(void) { ActionForPersonChoice(menu_commands_23); return ScriptRerun; } -unsigned int CMD_24_(void) { +uint16 CMD_24_(void) { ActionForPersonChoice(menu_commands_24); return ScriptRerun; } -unsigned int CMD_25_LoadGame(void) { +uint16 CMD_25_LoadGame(void) { if (LoadScena()) the_command = 0x918F; /*error loading*/ else @@ -3348,7 +3348,7 @@ unsigned int CMD_25_LoadGame(void) { return ScriptRerun; } -unsigned int CMD_26_SaveGame(void) { +uint16 CMD_26_SaveGame(void) { if (SaveScena()) the_command = 0x9190; /*error saving*/ else @@ -3358,7 +3358,7 @@ unsigned int CMD_26_SaveGame(void) { -typedef unsigned int (*cmdhandler_t)(void); +typedef uint16 (*cmdhandler_t)(void); cmdhandler_t command_handlers[] = { 0, @@ -3515,12 +3515,12 @@ cmdhandler_t script_handlers[] = { #define MAX_SCR_HANDLERS (sizeof(script_handlers) / sizeof(script_handlers[0])) #ifdef DEBUG_SCRIPT -int runscr_reentr = 0; -int runcmd_reentr = 0; +int16 runscr_reentr = 0; +int16 runcmd_reentr = 0; #endif -unsigned int RunScript(unsigned char *code) { - unsigned int status = ScriptContinue; +uint16 RunScript(byte *code) { + uint16 status = ScriptContinue; #ifdef DEBUG_SCRIPT runscr_reentr += 1; @@ -3528,13 +3528,13 @@ unsigned int RunScript(unsigned char *code) { script_ptr = code; while (script_ptr != script_end_ptr) { - unsigned char opcode = *script_ptr; + byte opcode = *script_ptr; #ifdef DEBUG_SCRIPT { FILE *f = fopen(DEBUG_SCRIPT_LOG, "at"); if (f) { - unsigned int offs = (script_ptr - templ_data) & 0xFFFF; + uint16 offs = (script_ptr - templ_data) & 0xFFFF; fprintf(f, "%04X: %02X\n", offs, opcode); fclose(f); } @@ -3565,13 +3565,13 @@ unsigned int RunScript(unsigned char *code) { return status; } -unsigned char *GetScriptSubroutine(unsigned int index) { +byte *GetScriptSubroutine(uint16 index) { return SeekToEntry(templ_data, index, &script_end_ptr); } -unsigned int RunCommand(void) { - unsigned int res; - unsigned short cmd; +uint16 RunCommand(void) { + uint16 res; + uint16 cmd; again:; res = 0; @@ -3634,7 +3634,7 @@ again:; return res; } -unsigned int RunCommandKeepSp(void) { +uint16 RunCommandKeepSp(void) { /*keep_sp = sp;*/ return RunCommand(); } diff --git a/engines/chamber/script.h b/engines/chamber/script.h index de3e0c581e4..2a04e2762a0 100644 --- a/engines/chamber/script.h +++ b/engines/chamber/script.h @@ -43,134 +43,134 @@ enum ScriptPools { /*Byte-packed, members accessed from script code by hardcoded offsets*/ typedef struct script_byte_vars_t { - unsigned char zone_index; /* 0 */ - unsigned char zone_room; /* 1 */ - unsigned char byte_179B8; /* 2 */ - unsigned char cur_spot_idx; /* 3 */ - unsigned char the_wall_phase; /* 4 */ - unsigned char prev_zone_index; /* 5 */ - unsigned char unused_179BC; /* 6 */ - unsigned char unused_179BD; /* 7 */ - unsigned char byte_179BE; /* 8 */ - unsigned char unused_179BF; /* 9 */ - unsigned char unused_179C0; /* A */ - unsigned char byte_179C1; /* B */ - unsigned char zone_area; /* C */ - unsigned char dead_flag; /* D */ - volatile unsigned char timer_ticks; /* E */ - unsigned char gauss_phase; /* F */ - unsigned char unused_179C6; /* 10 */ - unsigned char rand_value; /* 11 */ - unsigned char load_flag; /* 12 */ - unsigned char spot_m; /* 13 */ - unsigned char spot_v; /* 14 */ - unsigned char unused_179CB; /* 15 */ - unsigned char unused_179CC; /* 16 */ - unsigned char unused_179CD; /* 17 */ - unsigned char unused_179CE; /* 18 */ - unsigned char unused_179CF; /* 19 */ - unsigned char unused_179D0; /* 1A */ - unsigned char unused_179D1; /* 1B */ - unsigned char unused_179D2; /* 1C */ - unsigned char unused_179D3; /* 1D */ - unsigned char unused_179D4; /* 1E */ - unsigned char unused_179D5; /* 1F */ - unsigned char cur_pers; /* 20 */ - unsigned char used_commands; /* 21 */ - unsigned char tries_left; /* 22 */ - unsigned char inv_item_index; /* 23 */ - unsigned char unused_179DA; /* 24 */ - unsigned char byte_179DB; /* 25 */ - unsigned char byte_179DC; /* 26 */ - unsigned char byte_179DD; /* 27 */ - unsigned char byte_179DE; /* 28 */ - unsigned char byte_179DF; /* 29 */ - unsigned char byte_179E0; /* 2A */ - unsigned char byte_179E1; /* 2B */ /*TODO: hand height*/ - unsigned char check_used_commands; /* 2C */ - unsigned char byte_179E3; /* 2D */ - unsigned char palette_index; /* 2E */ - unsigned char byte_179E5; /* 2F */ - unsigned char byte_179E6; /* 30 */ - unsigned char room_items; /* 31 */ - unsigned char byte_179E8; /* 32 */ - unsigned char byte_179E9; /* 33 */ - unsigned char byte_179EA; /* 34 */ - unsigned char byte_179EB; /* 35 */ - unsigned char byte_179EC; /* 36 */ - unsigned char byte_179ED; /* 37 */ - unsigned char zone_area_copy; /* 38 */ - unsigned char byte_179EF; /* 39 */ - unsigned char quest_item_ofs; /* 3A */ - unsigned char byte_179F1; /* 3B */ - unsigned char byte_179F2; /* 3C */ - unsigned char byte_179F3; /* 3D */ - unsigned char trade_done; /* 3E */ - unsigned char byte_179F5; /* 3F */ - unsigned char byte_179F6; /* 40 */ - unsigned char byte_179F7; /* 41 */ - unsigned char byte_179F8; /* 42 */ - unsigned char byte_179F9; /* 43 */ - unsigned char dirty_rect_kind; /* 44 */ - unsigned char flag_179FB; /* 45 */ - unsigned char byte_179FC; /* 46 */ - unsigned char game_paused; /* 47 */ - unsigned char trade_status; /* 48 */ - unsigned char cur_spot_flags; /* 49 */ - unsigned char byte_17A00; /* 4A */ - unsigned char byte_17A01; /* 4B */ - unsigned char byte_17A02; /* 4C */ - unsigned char byte_17A03; /* 4D */ - unsigned char byte_17A04; /* 4E */ - unsigned char byte_17A05; /* 4F */ - unsigned char byte_17A06; /* 50 */ - unsigned char byte_17A07; /* 51 */ - unsigned char byte_17A08; /* 52 */ - unsigned char byte_17A09; /* 53 */ - unsigned char byte_17A0A; /* 54 */ - unsigned char byte_17A0B; /* 55 */ - unsigned char byte_17A0C; /* 56 */ - unsigned char need_draw_spots; /* 57 */ - unsigned char byte_17A0E; /* 58 */ - unsigned char byte_17A0F; /* 59 */ - unsigned char psy_energy; /* 5A */ - unsigned char byte_17A11; /* 5B */ - unsigned char byte_17A12; /* 5C */ - unsigned char byte_17A13; /* 5D */ - unsigned char byte_17A14; /* 5E */ - unsigned char byte_17A15; /* 5F */ - unsigned char byte_17A16; /* 60 */ - unsigned char byte_17A17; /* 61 */ - unsigned char byte_17A18; /* 62 */ - unsigned char byte_17A19; /* 63 */ - unsigned char byte_17A1A; /* 64 */ - unsigned char byte_17A1B; /* 65 */ - unsigned char byte_17A1C; /* 66 */ - unsigned char byte_17A1D; /* 67 */ - unsigned char zapstik_stolen; /* 68 */ - unsigned char byte_17A1F; /* 69 */ - unsigned char byte_17A20; /* 6A */ - unsigned char byte_17A21; /* 6B */ - unsigned char byte_17A22; /* 6C */ - unsigned char byte_17A23[4]; /* 6D */ + byte zone_index; /* 0 */ + byte zone_room; /* 1 */ + byte byte_179B8; /* 2 */ + byte cur_spot_idx; /* 3 */ + byte the_wall_phase; /* 4 */ + byte prev_zone_index; /* 5 */ + byte unused_179BC; /* 6 */ + byte unused_179BD; /* 7 */ + byte byte_179BE; /* 8 */ + byte unused_179BF; /* 9 */ + byte unused_179C0; /* A */ + byte byte_179C1; /* B */ + byte zone_area; /* C */ + byte dead_flag; /* D */ + volatile byte timer_ticks; /* E */ + byte gauss_phase; /* F */ + byte unused_179C6; /* 10 */ + byte rand_value; /* 11 */ + byte load_flag; /* 12 */ + byte spot_m; /* 13 */ + byte spot_v; /* 14 */ + byte unused_179CB; /* 15 */ + byte unused_179CC; /* 16 */ + byte unused_179CD; /* 17 */ + byte unused_179CE; /* 18 */ + byte unused_179CF; /* 19 */ + byte unused_179D0; /* 1A */ + byte unused_179D1; /* 1B */ + byte unused_179D2; /* 1C */ + byte unused_179D3; /* 1D */ + byte unused_179D4; /* 1E */ + byte unused_179D5; /* 1F */ + byte cur_pers; /* 20 */ + byte used_commands; /* 21 */ + byte tries_left; /* 22 */ + byte inv_item_index; /* 23 */ + byte unused_179DA; /* 24 */ + byte byte_179DB; /* 25 */ + byte byte_179DC; /* 26 */ + byte byte_179DD; /* 27 */ + byte byte_179DE; /* 28 */ + byte byte_179DF; /* 29 */ + byte byte_179E0; /* 2A */ + byte byte_179E1; /* 2B */ /*TODO: hand height*/ + byte check_used_commands; /* 2C */ + byte byte_179E3; /* 2D */ + byte palette_index; /* 2E */ + byte byte_179E5; /* 2F */ + byte byte_179E6; /* 30 */ + byte room_items; /* 31 */ + byte byte_179E8; /* 32 */ + byte byte_179E9; /* 33 */ + byte byte_179EA; /* 34 */ + byte byte_179EB; /* 35 */ + byte byte_179EC; /* 36 */ + byte byte_179ED; /* 37 */ + byte zone_area_copy; /* 38 */ + byte byte_179EF; /* 39 */ + byte quest_item_ofs; /* 3A */ + byte byte_179F1; /* 3B */ + byte byte_179F2; /* 3C */ + byte byte_179F3; /* 3D */ + byte trade_done; /* 3E */ + byte byte_179F5; /* 3F */ + byte byte_179F6; /* 40 */ + byte byte_179F7; /* 41 */ + byte byte_179F8; /* 42 */ + byte byte_179F9; /* 43 */ + byte dirty_rect_kind; /* 44 */ + byte flag_179FB; /* 45 */ + byte byte_179FC; /* 46 */ + byte game_paused; /* 47 */ + byte trade_status; /* 48 */ + byte cur_spot_flags; /* 49 */ + byte byte_17A00; /* 4A */ + byte byte_17A01; /* 4B */ + byte byte_17A02; /* 4C */ + byte byte_17A03; /* 4D */ + byte byte_17A04; /* 4E */ + byte byte_17A05; /* 4F */ + byte byte_17A06; /* 50 */ + byte byte_17A07; /* 51 */ + byte byte_17A08; /* 52 */ + byte byte_17A09; /* 53 */ + byte byte_17A0A; /* 54 */ + byte byte_17A0B; /* 55 */ + byte byte_17A0C; /* 56 */ + byte need_draw_spots; /* 57 */ + byte byte_17A0E; /* 58 */ + byte byte_17A0F; /* 59 */ + byte psy_energy; /* 5A */ + byte byte_17A11; /* 5B */ + byte byte_17A12; /* 5C */ + byte byte_17A13; /* 5D */ + byte byte_17A14; /* 5E */ + byte byte_17A15; /* 5F */ + byte byte_17A16; /* 60 */ + byte byte_17A17; /* 61 */ + byte byte_17A18; /* 62 */ + byte byte_17A19; /* 63 */ + byte byte_17A1A; /* 64 */ + byte byte_17A1B; /* 65 */ + byte byte_17A1C; /* 66 */ + byte byte_17A1D; /* 67 */ + byte zapstik_stolen; /* 68 */ + byte byte_17A1F; /* 69 */ + byte byte_17A20; /* 6A */ + byte byte_17A21; /* 6B */ + byte byte_17A22; /* 6C */ + byte byte_17A23[4]; /* 6D */ } script_byte_vars_t; /*2-byte long vars, in BIG-endian order*/ typedef struct script_word_vars_t { - unsigned short psi_cmds[6]; /* 0 */ - unsigned short word_17850; /* C */ - unsigned short word_17852; /* E */ - unsigned short timer_ticks2; /* 10 */ - unsigned short zone_obj_cmds[15 * 5]; /* 12 */ - unsigned short next_command1; /* A8 */ - unsigned short word_178EE; /* AA */ - unsigned short word_178F0; /* AC */ - unsigned short word_178F2; /* AE */ - unsigned short word_178F4; /* B0 */ - unsigned short word_178F6; /* B2 */ - unsigned short word_178F8; /* B4 */ - unsigned short next_command2; /* B6 */ - unsigned short word_178FC; /* B8 */ + uint16 psi_cmds[6]; /* 0 */ + uint16 word_17850; /* C */ + uint16 word_17852; /* E */ + uint16 timer_ticks2; /* 10 */ + uint16 zone_obj_cmds[15 * 5]; /* 12 */ + uint16 next_command1; /* A8 */ + uint16 word_178EE; /* AA */ + uint16 word_178F0; /* AC */ + uint16 word_178F2; /* AE */ + uint16 word_178F4; /* B0 */ + uint16 word_178F6; /* B2 */ + uint16 word_178F8; /* B4 */ + uint16 next_command2; /* B6 */ + uint16 word_178FC; /* B8 */ } script_word_vars_t; extern void *script_vars[ScrPools_MAX]; @@ -189,11 +189,11 @@ extern script_byte_vars_t script_byte_vars; /*TODO: manipulated from script, do not change*/ #include "common/pack-start.h" typedef struct item_t { - unsigned char flags; - unsigned char flags2; - unsigned char sprite; /*item sprite index*/ - unsigned char name; /*item name index (relative)*/ - unsigned short command; /*TODO: warning! in native format, check if never accessed from scripts*/ + byte flags; + byte flags2; + byte sprite; /*item sprite index*/ + byte name; /*item name index (relative)*/ + uint16 command; /*TODO: warning! in native format, check if never accessed from scripts*/ } item_t; #include "common/pack-end.h" @@ -203,33 +203,33 @@ extern item_t inventory_items[MAX_INV_ITEMS]; #define PERS_MAX 41 extern pers_t pers_list[PERS_MAX]; -extern unsigned char *script_stack[5 * 2]; -extern unsigned char **script_stack_ptr; +extern byte *script_stack[5 * 2]; +extern byte **script_stack_ptr; extern pers_t *pers_vort_ptr; #define SPECIAL_COMMANDS_MAX 20 -extern unsigned short menu_commands_12[SPECIAL_COMMANDS_MAX]; -extern unsigned short menu_commands_22[SPECIAL_COMMANDS_MAX]; -extern unsigned short menu_commands_24[SPECIAL_COMMANDS_MAX]; -extern unsigned short menu_commands_23[SPECIAL_COMMANDS_MAX]; +extern uint16 menu_commands_12[SPECIAL_COMMANDS_MAX]; +extern uint16 menu_commands_22[SPECIAL_COMMANDS_MAX]; +extern uint16 menu_commands_24[SPECIAL_COMMANDS_MAX]; +extern uint16 menu_commands_23[SPECIAL_COMMANDS_MAX]; -extern unsigned short fight_pers_ofs; +extern uint16 fight_pers_ofs; -extern unsigned char wait_delta; +extern byte wait_delta; -extern unsigned char rand_seed; -unsigned char Rand(void); -unsigned int RandW(void); +extern byte rand_seed; +byte Rand(void); +uint16 RandW(void); -extern unsigned short the_command; +extern uint16 the_command; -unsigned char *GetScriptSubroutine(unsigned int index); +byte *GetScriptSubroutine(uint16 index); -unsigned int RunCommand(void); -unsigned int RunCommandKeepSp(void); +uint16 RunCommand(void); +uint16 RunCommandKeepSp(void); -unsigned int Swap16(unsigned int x); +uint16 Swap16(uint16 x); } // End of namespace Chamber diff --git a/engines/chamber/sound.cpp b/engines/chamber/sound.cpp index ae7c9630254..27127b3f1c8 100644 --- a/engines/chamber/sound.cpp +++ b/engines/chamber/sound.cpp @@ -27,7 +27,7 @@ namespace Chamber { -void PlaySound(unsigned char index) { +void PlaySound(byte index) { /*TODO*/ } diff --git a/engines/chamber/sound.h b/engines/chamber/sound.h index bbf397cb4cd..0c649bb52aa 100644 --- a/engines/chamber/sound.h +++ b/engines/chamber/sound.h @@ -25,7 +25,7 @@ namespace Chamber { -void PlaySound(unsigned char index); +void PlaySound(byte index); } // End of namespace Chamber diff --git a/engines/chamber/timer.cpp b/engines/chamber/timer.cpp index 05aed1fb9c9..b2900a910a6 100644 --- a/engines/chamber/timer.cpp +++ b/engines/chamber/timer.cpp @@ -32,9 +32,9 @@ namespace Chamber { -void AnimateGauss(unsigned char *target) { - unsigned char *sprite; - unsigned char phase = Rand() % 4; +void AnimateGauss(byte *target) { + byte *sprite; + byte phase = Rand() % 4; if (phase == script_byte_vars.gauss_phase) phase = (phase + 1) % 4; script_byte_vars.gauss_phase = phase;