[Scummvm-git-logs] scummvm master -> b2e484418e5631df788683157239b08975d95074
sev-
noreply at scummvm.org
Sun Feb 19 22:52:11 UTC 2023
This automated email contains information about 86 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
007f121e04 CHAMBER: Added original code
278d742135 CHAMBER: Removed unnecessary files
b8ca670f20 CHAMBER: Rename *.c -> *.cpp
8a0da574ac CHAMBER: Renamed main file
a91cfbbedd CHAMBER: Run astyle
9d434a34fb CHAMBER: Renamed main file
0ac7c43573 CHAMBER: Add the engine skeleton
c6c4e2146c CHAMBER: Added standard ScummVM header and guard defines
ca9faedb64 CHAMBER: Sync with upstream f6bf08532a77c32f9539180e1bb51a147998a2d0
5cf12776be CHAMBER: Made anim.cpp compilable
c08e01cc19 CHAMBER: Fix compilation for [bc]*.cpp
8b82922f3f CHAMBER: More compilation fixes
a637c5a7d0 CHAMBER: Fix compilation for the rest of the files
4df1e71e3a CHAMBER: Plug in the engine
3811c9bd6f CHAMBER: Fix the main loop
2f503242a2 CHAMBER: Implement file loading
c5f7abf476 CHAMBER: Init palette and blit CGA buffer to screen
b8d465e8a7 CHAMBER: Fix image decoding
856ed7282b CHAMBER: Sync with upstream 7e5a12a20008eea4faa49e8a7fd5bec2b47e635b
9a120255e2 CHAMBER: Implemented input
73e2366c8b CHAMBER: Implemented timer
92e9f3d482 CHAMBER: Implement mouse input and proper quitting
949e278f53 CHAMBER: Fix room backround drawing
e9d9c74a84 CHAMBER: Fix resource data parsing
29c9ef30ed CHAMBER: Added code for CGA blitting
eaeb022e3d CHAMBER: Fix room drawing
64f69f38be CHAMBER: Implement even more script commands
00dffcc50f CHAMBER: Update screen when blit to CGA
8569c512b2 CHAMBER: Fix crash on startup when cursor is not yet defined
92ce4b3e9a CHAMBER: Unstub PollMouse()
31e8e16e27 CHAMBER: Refactor CGA blitting routines
c612ef1ce9 CHAMBER: Blit all CGA pixels
9116da279d CHAMBER: Fix CGA blitting
3fd9adf211 CHAMBER: Blit screen for sliding animations
f2ace8ad30 CHAMBER: Fixed blitting width and added delay to the animations
fe1deb5a8c CHAMBER: Furhter fixes to line blitting
f50556d1bf CHAMBER: Fix dialog box rendering
79078695aa CHAMBER: Replace data types with portable ones
b8d6281568 CHAMBER: Fix timer frequency
8c74647f1f CHAMBER: Fix animation delay
880657ed14 CHAMBER: Code cleanup
f4d1871345 CHAMBER: Use centralized delay and system yield
e553feba36 CHAMBER: Fix portrait dot effect
96e9729776 CHAMBER: Blit to screen in all places where CGA framebuffer is modified
0d05266afb CHAMBER: Implement CGA_ColorSelect()
e6d0644179 CHAMBER: Replace custom cursor code with the OSystem calls
27dbf320fd CHAMBER: Fix input and make animations more responsive
842b59541d CHAMBER: Fix out of bound access in ScreenToPieces()
78b4a690e1 CHAMBER: Fix CGA palette setting
1f23037dd1 CHAMBER: Implement PXI file parsing
00d0b741ae CHAMBER: Read resources directly from PXI and dynamically allocate memory
0429bc78be CHAMBER: Plug memory leaks
d5e416e773 CHAMBER: Implement remaining opcodes except ending and restart
cefbca0894 CHAMBER: Activate intro bypass cheat
362503b6cc CHAMBER: Play sounds
556d23b06f CHAMBER: Implement game over and restart
bd6e443555 CHAMBER: Play the ending cutscene
f912007113 CHAMBER: Support Fxxx command
2c179945a2 CHAMBER: Give unknown script vars more generic names
5c82720d48 CHAMBER: Replace many numbers with enums, add comments
a8a9dde2af CHAMBER: Initial code for PC Speaker sound
37b0e5209e CHAMBER: Fix CGA_DrawHLineWithEnds() blitting
61b4df8a8d CHAMBER: Finish sound implementation
21dbd72a41 CHAMBER: Clean up debugging code
737bef757a CHAMBER: Add missing commands, fix dead bodies
3ef7efdbcf CHAMBER: Merge the US release changes
dc5b18d751 CHAMBER: Fix compilation for EU version
977341c8a5 CHAMBER: Added detection for US version
12ca250553 CHAMBER: Implement getLanguage()
39c5791a4b CHAMBER: Switch to US version at run-time
37c366762f CHAMBER: Added Hercules constants
064781ae30 CHAMBER: Fix warnings
5a64266411 CHAMBER: Fix warnings
a8b5dea76a CHAMBER: Renames in timer.h and sound.h
4c192ca5c0 CHAMBER: Renames in anim.cpp
ac3bd85de3 CHAMBER: Renames in cga.cpp
d0eb47fe78 CHAMBER: Renames in cursor.cpp
7672a5632e CHAMBER: Renames in dialog.cpp
505459a8a3 CHAMBER: Renames in input.h and invent.h
885303ddea CHAMBER: Renames in portrait.h and print.h
4f009e3fa7 CHAMBER: Renames in resdata.h
ecec62da85 CHAMBER: Renames in room.h
2c949ea93d CHAMBER: Renames in savegame.h
eaaf84a4c1 CHAMBER: Rename rest of functions
3065512bd2 CHAMBER: Cleanup forbidden symbols
b2e484418e CHAMBER: Bump license to GPLv3+
Commit: 007f121e04e02d70da3fbe136b386b26bf09041e
https://github.com/scummvm/scummvm/commit/007f121e04e02d70da3fbe136b386b26bf09041e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Added original code
Changed paths:
A engines/chamber/!fix.txt
A engines/chamber/anim.c
A engines/chamber/anim.h
A engines/chamber/bkbuff.c
A engines/chamber/bld.bat
A engines/chamber/cga.c
A engines/chamber/cga.h
A engines/chamber/cln.bat
A engines/chamber/common.h
A engines/chamber/cursor.c
A engines/chamber/cursor.h
A engines/chamber/decompr.c
A engines/chamber/decompr.h
A engines/chamber/dialog.c
A engines/chamber/dialog.h
A engines/chamber/input.c
A engines/chamber/input.h
A engines/chamber/invent.c
A engines/chamber/invent.h
A engines/chamber/kult.c
A engines/chamber/kult.lnk
A engines/chamber/makefile
A engines/chamber/menu.c
A engines/chamber/menu.h
A engines/chamber/portrait.c
A engines/chamber/portrait.h
A engines/chamber/print.c
A engines/chamber/print.h
A engines/chamber/r_other.c
A engines/chamber/r_pers.c
A engines/chamber/r_puzzl.c
A engines/chamber/r_sprit.c
A engines/chamber/r_templ.c
A engines/chamber/r_texts.c
A engines/chamber/resdata.c
A engines/chamber/resdata.h
A engines/chamber/room.c
A engines/chamber/room.h
A engines/chamber/ru.cmd
A engines/chamber/rud.cmd
A engines/chamber/savegame.c
A engines/chamber/savegame.h
A engines/chamber/script.c
A engines/chamber/script.h
A engines/chamber/scrvars.h
A engines/chamber/sound.c
A engines/chamber/sound.h
A engines/chamber/timer.c
A engines/chamber/timer.h
A engines/chamber/turboc.cfg
A engines/chamber/utils.c
A engines/chamber/utils.h
diff --git a/engines/chamber/!fix.txt b/engines/chamber/!fix.txt
new file mode 100644
index 00000000000..86036f09804
--- /dev/null
+++ b/engines/chamber/!fix.txt
@@ -0,0 +1,43 @@
+Known bugs (not the original ones):
+1. Main hint box (location name) is wrongly positioned on x axis
+2. FIXED -- When actions menu shown, some garbage is left under cursor
+3. Moving cursor close to right edge of screen causes noticeable slowdown
+4. Doors open only half of their height
+5. In some rooms main hint box text is misplaced
+6. FIXED -- Junk under cursor when clicked on psi powers menu (maybe related to 2)
+7. FIXED -- Clicking on inventory item does nothing (should open actions menu)
+8. FIXED? -- Energy level is not animated
+9. FIXED -- Right guard is not properly drawn for a while after quest item bounce (bounce anim goes over the character)
+10. CANTREPRO -- Massive glitches on the right side when walking around the room (regression)
+11. Animation (esp. portraits) runs pretty slowly (maybe due to unoptimized code?)
+12. Closing door animation is played in wrong rooms, with trashed/invalid sprites
+13. FIXED -- CopyScreenBlockWithDotEffect (from AspirantLeave) does not fully remove sprite?
+14. FIXED -- DeProf puzzle is broken
+15. FIXED -- Wrong dialog lines when trade with Aspirant (before inventory opens)
+16. FIXED -- Zorq trader (at TMO) offers trade w/o skull at first try?
+17. Wait4/Wait command does not wait as intended?
+18. In Who Will Be Saved, Engraving opens incorrectly (maybe related to 4)
+19. Some junk is draw in The Wall
+20. Can't leave left Victory of The Faith room?
+21. Zorq trader at TMO is broken again. Now refuses to trade even when have a skull.
+
+Rooms done so far:
+DeProf - solvable (with a rope or psi)
+TheWall - missing open doors animation
+TheTwins - solvable
+TheNoose - solvable (trapdoor is glitchy, see bug 4)
+
+General TODOs:
+1. Change script vars access to proxy calls (GetByteVar(12) , SetWordVar(4, 1234))
+2. Replace CGA_SCREENBUFFER instances with frontbuffer (or screenbuffer?)
+3. Remove redundant target = frontbuffer argument in calls
+4. Move all remaining CGA low-level code to cga.c
+5. Replace CGA next/prev line calculations with a macro/func
+6. Add sound playback
+
+
+Original game bugs:
+1. Actions menu for rope in DeProf shows two "Inspect" choices with different actions
+2. SCR_2D_Wait ignores specified delay, always waits for 4 secs
+3. Trade with Skull Trader while having only a skull will cause lost of the skull?
+4. In Who Will Be Saved raised hand's part is not drawn after reentering the room?
diff --git a/engines/chamber/anim.c b/engines/chamber/anim.c
new file mode 100644
index 00000000000..6e72d67c453
--- /dev/null
+++ b/engines/chamber/anim.c
@@ -0,0 +1,343 @@
+#include "common.h"
+#include "resdata.h"
+#include "cga.h"
+#include "room.h"
+#include "sound.h"
+
+unsigned char far *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;
+
+extern unsigned short cpu_speed_delay;
+
+extern unsigned char * SeekToEntry(unsigned char far *bank, unsigned int num, unsigned char far **end);
+extern void LoadLutinSprite(unsigned int lutidx);
+
+void GetScratchBuffer(unsigned char mode)
+{
+ unsigned char *buffer = scratch_mem2;
+ unsigned int offs = 0;
+ if(mode & 0x80)
+ offs += 3200;
+ if(mode & 0x40)
+ offs += 1600;
+ lutin_mem = buffer + offs;
+}
+
+void AnimLoadSprite(unsigned char **panim)
+{
+ unsigned char mode;
+ unsigned char 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)
+{
+ if(anim_flags == 7)
+ return;
+ if(anim_flags & 4)
+ {
+ if(anim_cycle == 0)
+ return;
+ if(anim_flags & 2)
+ {
+ *sprh = anim_cycle;
+ if(anim_cycle >= dy)
+ anim_cycle -= dy;
+ else
+ anim_cycle = 0;
+ }
+ else if(anim_flags & 1)
+ {
+ *sprw = anim_cycle;
+ anim_cycle--;
+ }
+ else
+ {
+ *x -= dx;
+ *sprite += (*sprw - anim_cycle) * 2;
+ *sprw = anim_cycle;
+ anim_cycle--;
+ }
+ }
+ else if(anim_flags & 2)
+ {
+ if(*sprw == anim_cycle)
+ {
+ anim_cycle = 0;
+ }
+ else if(anim_flags & 1)
+ {
+ *sprw = anim_cycle;
+ anim_cycle++;
+ }
+ else
+ {
+ *x -= dx;
+ *sprite += (*sprw - anim_cycle) * 2;
+ *sprw = anim_cycle;
+ anim_cycle++;
+ }
+ }
+}
+
+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;
+
+ 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);
+
+ target[ofs] = (target[ofs] & ~mask) | (source[ofs] & mask);
+
+ if(dot_effect_delay / 4 != 0)
+ {
+ unsigned int i;
+ for(i = 0;i < dot_effect_delay / 4;i++) ; /*TODO: weak delay*/
+ }
+
+ offs += dot_effect_step;
+ if(offs > cur_image_end)
+ offs -= cur_image_end;
+ }
+}
+
+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);
+ CGA_BackupImage(backbuffer, ofs, sprw, sprh, sprit_load_buffer);
+ CGA_BlitSprite(pixels, pitch, sprw, sprh, backbuffer, ofs);
+ ex = x + sprw;
+ ey = y + sprh;
+ if(last_anim_height != 0)
+ {
+ if(last_anim_x + last_anim_width > ex)
+ ex = last_anim_x + last_anim_width;
+
+ if(last_anim_y + last_anim_height > ey)
+ ey = last_anim_y + last_anim_height;
+
+ updx = (x > last_anim_x) ? last_anim_x : x;
+ updy = (y > last_anim_y) ? last_anim_y : y;
+ }
+ else
+ {
+ updx = x;
+ updy = y;
+ }
+ updw = ex - updx;
+ updh = ey - updy;
+ ofs = CGA_CalcXY_p(updx, updy);
+ /*TODO looks like here was some code before*/
+ for(delay = 0;delay < anim_draw_delay;delay++)
+ {
+ for(delay2 = 0;delay2 < cpu_speed_delay;delay2++) ; /*TODO FIXME weak delay*/
+ }
+ WaitVBlank();
+
+ if(anim_use_dot_effect)
+ CopyScreenBlockWithDotEffect(backbuffer, updx, updy, updw, updh, frontbuffer);
+ else
+ {
+ CGA_CopyScreenBlock(backbuffer, updw, updh, frontbuffer, ofs);
+ }
+ CGA_RestoreImage(sprit_load_buffer, backbuffer);
+
+ last_anim_x = x;
+ last_anim_y = y;
+ last_anim_width = sprw;
+ last_anim_height = sprh;
+
+ anim_shift_x = anim_shift_y = 0;
+}
+
+void AnimUndrawSprite(void)
+{
+ CGA_CopyScreenBlock(backbuffer, last_anim_width, last_anim_height, CGA_SCREENBUFFER, CGA_CalcXY_p(last_anim_x, last_anim_y));
+ last_anim_height = 0;
+}
+
+void PlayAnimCore(unsigned char **panim)
+{
+ unsigned char mode;
+ unsigned int count, count2;
+ unsigned char *pframe;
+ mode = *((*panim)++);
+ anim_flags = mode & 7;
+ count = mode >> 3;
+
+ while(count--)
+ {
+ pframe = *panim;
+ mode = *pframe++;
+ anim_draw_delay = ((mode & ~7) >> 3) << 1;
+ dot_effect_step = (mode & ~7) >> 3;
+ dot_effect_delay = 500;
+ count2 = mode & 7;
+ while(count2--)
+ {
+ unsigned char far *sprite;
+ unsigned char sprw, sprh;
+ unsigned char x, y;
+ signed char dx, dy;
+ unsigned int pitch;
+ mode = *pframe++;
+ GetScratchBuffer(mode);
+ dy = mode & 7;
+ dx = (mode >> 3) & 7;
+
+ dx = (dx & 1) ? -(dx & ~1) : dx;
+ dx /= 2;
+ dy = (dy & 1) ? -(dy & ~1) : dy;
+
+ x = last_anim_x + dx + anim_shift_x;
+ y = last_anim_y + dy + anim_shift_y;
+
+ sprite = lutin_mem;
+ sprw = *sprite++;
+ sprh = *sprite++;
+
+ pitch = sprw * 2;
+ ClipSprite(&x, &y, &sprw, &sprh, &sprite, dx, dy);
+ AnimDrawSprite(x, y, sprw, sprh, sprite, pitch);
+
+ if(anim_flags & 4)
+ {
+ if(anim_cycle == 0)
+ {
+ AnimUndrawSprite();
+ goto end;
+ }
+ }
+ else if(anim_flags & 2)
+ {
+ if(anim_cycle == 0)
+ {
+ goto end;
+ }
+ }
+ }
+ }
+end:;
+ mode = *((*panim)++);
+ *panim += mode & 7;
+}
+
+void Anim1(unsigned char **panim)
+{
+ anim_cycle = 0xFF;
+ anim_use_dot_effect = 0;
+ PlayAnimCore(panim);
+}
+
+void Anim2(unsigned char **panim)
+{
+ anim_cycle = 1;
+ anim_use_dot_effect = 0;
+ PlayAnimCore(panim);
+}
+
+void Anim3(unsigned char **panim)
+{
+ anim_cycle = 1;
+ anim_use_dot_effect = 0;
+ PlayAnimCore(panim);
+}
+
+void Anim4(unsigned char **panim)
+{
+ anim_cycle = last_anim_width - 1;
+ anim_use_dot_effect = 0;
+ PlayAnimCore(panim);
+}
+
+void Anim5(unsigned char **panim)
+{
+ anim_cycle = last_anim_width - 1;
+ anim_use_dot_effect = 0;
+ PlayAnimCore(panim);
+}
+
+void Anim6(unsigned char **panim)
+{
+ anim_cycle = last_anim_height;
+ anim_use_dot_effect = 0;
+ PlayAnimCore(panim);
+}
+
+void Anim7(unsigned char **panim)
+{
+ anim_cycle = 0xFF;
+ anim_use_dot_effect = 1;
+ PlayAnimCore(panim);
+}
+
+typedef void (*animhandler_t)(unsigned char **panim);
+
+animhandler_t anim_handlers[] = {
+ AnimLoadSprite,
+ Anim1,
+ Anim2,
+ Anim3,
+ Anim4,
+ Anim5,
+ Anim6,
+ Anim7
+};
+
+void PlayAnim(unsigned char index, unsigned char x, unsigned char y)
+{
+ unsigned char sound;
+ unsigned char *panim;
+
+ last_anim_width = 0;
+ last_anim_height = 0;
+ last_anim_x = x;
+ last_anim_y = y;
+
+ panim = SeekToEntry(anima_data, index - 1, &anima_end_ofs);
+ while(panim != anima_end_ofs)
+ {
+ unsigned char mode = *panim;
+ switch(mode)
+ {
+ case 0xFE: /*set shift*/
+ panim++;
+ anim_shift_x = *panim++;
+ anim_shift_y = *panim++;
+ break;
+ case 0xFD: /*play sfx*/
+ panim++;
+ sound = *panim++;
+ panim++; /*unused*/
+ PlaySound(sound);
+ break;
+ case 0xFC: /*nothing*/
+ panim++;
+ break;
+ default:
+ anim_handlers[mode & 7](&panim);
+ }
+ }
+}
diff --git a/engines/chamber/anim.h b/engines/chamber/anim.h
new file mode 100644
index 00000000000..176fc0824a9
--- /dev/null
+++ b/engines/chamber/anim.h
@@ -0,0 +1,10 @@
+#ifndef _ANIM_H_
+#define _ANIM_H_
+
+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);
+
+extern unsigned char dot_effect_step;
+extern unsigned int dot_effect_delay;
+
+#endif
diff --git a/engines/chamber/bkbuff.c b/engines/chamber/bkbuff.c
new file mode 100644
index 00000000000..05874d4ce39
--- /dev/null
+++ b/engines/chamber/bkbuff.c
@@ -0,0 +1 @@
+unsigned char backbuffer[0x4000];
diff --git a/engines/chamber/bld.bat b/engines/chamber/bld.bat
new file mode 100644
index 00000000000..f723013b627
--- /dev/null
+++ b/engines/chamber/bld.bat
@@ -0,0 +1,6 @@
+ at echo off
+set path=..\bin\tc
+set CINC=..\bin\tc\include
+set CLIB=..\bin\tc\lib
+
+make
diff --git a/engines/chamber/cga.c b/engines/chamber/cga.c
new file mode 100644
index 00000000000..c5a0a5d9036
--- /dev/null
+++ b/engines/chamber/cga.c
@@ -0,0 +1,1066 @@
+#include <dos.h>
+#include <assert.h>
+#include <string.h>
+
+#include "common.h"
+#include "resdata.h"
+#include "cga.h"
+
+extern unsigned char backbuffer[0x4000];
+
+unsigned char carpc_data[RES_CARPC_MAX];
+
+extern unsigned char *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;
+
+/*pixels order reverse in a byte*/
+unsigned char 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,
+24, 88, 152, 216, 40, 104, 168, 232, 56, 120, 184, 248,
+12, 76, 140, 204, 28, 92, 156, 220, 44, 108, 172, 236,
+60, 124, 188, 252, 1, 65, 129, 193, 17, 81, 145, 209,
+33, 97, 161, 225, 49, 113, 177, 241, 5, 69, 133, 197,
+21, 85, 149, 213, 37, 101, 165, 229, 53, 117, 181, 245,
+9, 73, 137, 201, 25, 89, 153, 217, 41, 105, 169, 233,
+57, 121, 185, 249, 13, 77, 141, 205, 29, 93, 157, 221,
+45, 109, 173, 237, 61, 125, 189, 253, 2, 66, 130, 194,
+18, 82, 146, 210, 34, 98, 162, 226, 50, 114, 178, 242,
+6, 70, 134, 198, 22, 86, 150, 214, 38, 102, 166, 230,
+54, 118, 182, 246, 10, 74, 138, 202, 26, 90, 154, 218,
+42, 106, 170, 234, 58, 122, 186, 250, 14, 78, 142, 206,
+30, 94, 158, 222, 46, 110, 174, 238, 62, 126, 190, 254,
+3, 67, 131, 195, 19, 83, 147, 211, 35, 99, 163, 227,
+51, 115, 179, 243, 7, 71, 135, 199, 23, 87, 151, 215,
+39, 103, 167, 231, 55, 119, 183, 247, 11, 75, 139, 203,
+27, 91, 155, 219, 43, 107, 171, 235, 59, 123, 187, 251,
+15, 79, 143, 207, 31, 95, 159, 223, 47, 111, 175, 239,
+63, 127, 191, 255};
+
+/*
+ Switch to CGA 320x200x2bpp mode
+*/
+void SwitchToGraphicsMode(void)
+{
+ union REGS reg;
+
+ reg.x.ax = 4;
+ int86(0x10, ®, ®);
+}
+
+/*
+ Switch to text mode
+*/
+void SwitchToTextMode(void)
+{
+ union REGS reg;
+
+ reg.x.ax = 3;
+ int86(0x10, ®, ®);
+}
+
+void WaitVBlank(void)
+{
+ while((inportb(0x3DA) & 8) != 0) ;
+ while((inportb(0x3DA) & 8) == 0) ;
+}
+
+void CGA_ColorSelect(unsigned char csel)
+{
+ outportb(0x3D9, csel);
+}
+
+void CGA_BackBufferToRealFull(void)
+{
+ memcpy(CGA_SCREENBUFFER, backbuffer, sizeof(backbuffer));
+}
+
+void CGA_RealBufferToBackFull(void)
+{
+ memcpy(backbuffer, CGA_SCREENBUFFER, sizeof(backbuffer));
+}
+
+/*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)
+{
+ while(h--)
+ {
+ memcpy(target + ofs, source + ofs, w);
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+}
+
+/*
+Flip screen and backbuffer
+*/
+void CGA_SwapRealBackBuffer(void)
+{
+ unsigned int i;
+ unsigned short *s, *d;
+ WaitVBlank();
+ s = (unsigned short far*)CGA_SCREENBUFFER;
+ d = (unsigned short far*)backbuffer;
+ for(i = 0;i < sizeof(backbuffer) / 2;i++)
+ {
+ unsigned short t = *s;
+ *s++ = *d;
+ *d++ = t;
+ }
+}
+
+
+/*
+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;
+ while(h--)
+ {
+ unsigned int i;
+ for(i = 0;i < w;i++)
+ {
+ *old++ = screen[ofs + i];
+ screen[ofs + i] = *pixels++;
+ }
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+}
+
+/*
+Calc screen offset from normal pixel coordinates
+Out:
+ screen offset
+*/
+unsigned int CGA_CalcXY(unsigned int x, unsigned int y)
+{
+ return CGA_CalcXY_p(x / 4, y);
+}
+
+/*
+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;
+ if(y & 1)
+ ofs += CGA_ODD_LINES_OFS;
+ ofs += CGA_BYTES_PER_LINE * (y / 2);
+ ofs += x;
+ return ofs;
+}
+
+/*
+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;
+ *(unsigned int*)(buffer + 2) = ofs;
+ buffer += 4;
+ while(h--)
+ {
+ memcpy(buffer, screen + ofs, w);
+ buffer += w;
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+ return buffer;
+}
+
+unsigned char * CGA_BackupImageReal(unsigned int ofs, unsigned int w, unsigned int h)
+{
+ return CGA_BackupImage(MK_FP(CGA_BASE_SEG, 0), ofs, w, h, scratch_mem2);
+}
+
+/*
+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)
+{
+ while(h--)
+ {
+ memcpy(screen + ofs, pixels, w);
+ pixels += pw;
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+}
+
+/*
+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)
+{
+ 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)
+{
+ while(h--)
+ {
+ memset(screen + ofs, pixel, w);
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+}
+
+void CGA_FillAndWait(unsigned char pixel, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs)
+{
+ CGA_Fill(pixel, w, h, screen, ofs);
+ WaitVBlank();
+}
+
+/*
+Restore saved image to target screen buffer
+*/
+void CGA_RestoreImage(unsigned char *buffer, unsigned char *target)
+{
+ unsigned int w, h;
+ unsigned int ofs;
+
+ if(!buffer)
+ return;
+
+ h = *(unsigned char*)(buffer + 0);
+ w = *(unsigned char*)(buffer + 1);
+ ofs = *(unsigned int*)(buffer + 2);
+ buffer += 4; /*TODO: fix me for large int*/
+
+ CGA_Blit(buffer, w, w, h, target, ofs);
+}
+
+/*
+Restore saved image from scratch mem to target screen buffer
+*/
+void CGA_RestoreBackupImage(unsigned char *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;
+
+ if(!buffer)
+ return;
+
+ h = *(unsigned char*)(buffer + 0);
+ w = *(unsigned char*)(buffer + 1);
+ ofs = *(unsigned int*)(buffer + 2);
+
+ CGA_CopyScreenBlock(CGA_SCREENBUFFER, w, h, backbuffer, ofs);
+}
+
+/*
+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;
+ /*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);
+
+ 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);
+
+ while(l--)
+ {
+ target[ofs] = (target[ofs] & mask) | pixel;
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+}
+
+/*
+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;
+ /*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);
+
+ 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);
+ while(l--)
+ {
+ target[ofs] = (target[ofs] & mask) | pixel;
+ mask >>= CGA_BITS_PER_PIXEL;
+ pixel >>= CGA_BITS_PER_PIXEL;
+ if(mask == 0xFF)
+ {
+ ofs++;
+ mask = ~(3 << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL));
+ pixel = color << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL);
+ }
+ }
+}
+
+/*
+Draw horizontal line of length l with color, add surrounding pixels (bmask, bpix, left in high byte, right in low)
+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)
+{
+ 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);
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ return ofs;
+}
+
+/*
+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);
+ for(i = 0;i < CGA_FONT_HEIGHT;i++)
+ {
+ c = *font++;
+ c = char_xlat_table[c];
+ target[ofs] = c;
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+}
+
+
+/*
+Blit progressive sprite (mask+pixel) from scratch buffer to interlaced screen buffer, using backbuffer pixels for transparency
+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;
+ while(h--)
+ {
+ for(x = 0;x < w;x++)
+ screen[ofs + x] = (backbuffer[ofs + x] & pixels[x * 2]) | pixels[x * 2 + 1];
+ pixels += w * 2;
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+}
+
+void CGA_BlitFromBackBuffer(unsigned char w, unsigned char h, unsigned char *screen, unsigned int ofs)
+{
+ CGA_CopyScreenBlock(backbuffer, w, h, screen, ofs);
+}
+
+/*
+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;
+ while(h--)
+ {
+ for(x = 0;x < w;x++)
+ screen[ofs + x] = (screen[ofs + x] & pixels[x * 2]) | pixels[x * 2 + 1];
+ pixels += pw;
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+}
+
+/*
+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;
+ 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]];
+ pixels += pw;
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+}
+
+/*
+Blit progressive sprite (pixel+mask) to interlaced screen buffer
+Backup original screen data to buffer
+Apply extra mask to source pixels when drawing
+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;
+ while(h--)
+ {
+ for(x = 0;x < w;x++)
+ {
+ *backup++ = screen[ofs + x];
+ screen[ofs + x] = (screen[ofs + x] & pixels[x * 2 + 1]) | (pixels[x * 2] & mask);
+ }
+ pixels += pw * 2;
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+}
+
+
+/*
+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;
+ w = *sprite++;
+ h = *sprite++;
+ CGA_BlitSprite(sprite, w * 2, w, h, screen, 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;
+ w = *sprite++;
+ h = *sprite++;
+ CGA_BlitSpriteFlip(sprite, w * 2, w, h, screen, ofs);
+}
+
+/*
+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;
+ sprite = SeekToEntryW(bank, index, &sprite_end);
+ w = *sprite++;
+ h = *sprite++;
+ rsize = w * h; /*raster part size*/
+ bitmask = sprite + rsize;
+
+ *buffer++ = w;
+ *buffer++ = h;
+ if(header_only)
+ {
+ memset(buffer, 0, rsize * 2); /*wipe masks+pixels*/
+ buffer += rsize * 2;
+ }
+ else
+ {
+ if(*bitmask == 0)
+ {
+ /*solid sprite*/
+ while(rsize--)
+ {
+ *buffer++ = 0;
+ *buffer++ = *sprite++;
+ }
+ }
+ else
+ {
+ /*with transparency*/
+ unsigned char bi = 1;
+ while(rsize--)
+ {
+ unsigned char pixels = *sprite++;
+ unsigned char mask = 0;
+
+ if((pixels & 0xC0) == 0)
+ {
+ bi >>= 1; if(bi == 0) { bi = 0x80; bitmask++; }
+ if(*bitmask & bi)
+ mask |= 0xC0;
+ }
+
+ if((pixels & 0x30) == 0)
+ {
+ bi >>= 1; if(bi == 0) { bi = 0x80; bitmask++; }
+ if(*bitmask & bi)
+ mask |= 0x30;
+ }
+
+ if((pixels & 0xC) == 0)
+ {
+ bi >>= 1; if(bi == 0) { bi = 0x80; bitmask++; }
+ if(*bitmask & bi)
+ mask |= 0xC;
+ }
+
+ if((pixels & 0x3) == 0)
+ {
+ bi >>= 1; if(bi == 0) { bi = 0x80; bitmask++; }
+ if(*bitmask & bi)
+ mask |= 0x3;
+ }
+ *buffer++ = mask;
+ *buffer++ = pixels;
+ }
+ }
+ }
+ return buffer;
+}
+
+extern unsigned char sprit_data[RES_SPRIT_MAX];
+
+unsigned char sprit_load_buffer[1290];
+
+unsigned char *LoadSprit(unsigned char index)
+{
+ LoadSprite(index, sprit_data + 4, sprit_load_buffer, 0);
+ return sprit_load_buffer;
+}
+
+unsigned char *LoadPersSprit(unsigned char index)
+{
+#if 1
+/*Use separate memory for pers1/pers2*/
+ if(index < 61)
+ LoadSprite(index, pers1_data + 4, scratch_mem2, 0);
+ else
+ LoadSprite(index - 61, pers2_data + 4, scratch_mem2, 0);
+#else
+/*Use single large chunk for pers1+pers2*/
+ LoadSprite(index, pers1_data + 4, scratch_mem2, 0);
+#endif
+
+ return scratch_mem2;
+}
+
+
+void DrawSpriteN(unsigned char index, unsigned int x, unsigned int y, unsigned char *target)
+{
+ unsigned int ofs;
+ unsigned char *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;
+ 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);
+ ofs = CGA_CalcXY_p(x, y);
+ w = sprite[0];
+ h = sprite[1];
+ CGA_BackupImageReal(ofs, w, h);
+ DrawSprite(sprite, CGA_SCREENBUFFER, ofs); /*DrawSpriteN(index, x, y, CGA_SCREENBUFFER);*/
+}
+
+/*
+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;
+ pixels += pw * (h - 1);
+ for(i = 1;i <= h;i++)
+ {
+ CGA_BlitAndWait(pixels, pw, w, i, screen, ofs);
+ pixels -= pw;
+ }
+}
+
+/*
+Blit progressive image to interlaced screen buffer, then wait for VBlank
+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;
+ for(i = 0;i < n;i++)
+ {
+ CGA_BlitAndWait(pixels, pw, w + i, h, screen, ofs);
+ ofs -= 1;
+ }
+}
+
+/*
+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;
+ for(i = 0;i < n;i++)
+ {
+ CGA_BlitAndWait(pixels, pw, w + i, h, screen, ofs);
+ pixels -= 1;
+ }
+}
+
+/*
+Blit progressive image to interlaced screen buffer, then wait for VBlank
+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;
+ for(i = 1;i <= h;i++)
+ {
+ CGA_BlitAndWait(pixels, pw, w, i, screen, CGA_CalcXY_p(x, y));
+ y -= 1;
+ }
+}
+
+/*Copy interlaced screen data n lines down (with clipping)*/
+/*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)
+{
+ while(n--)
+ {
+ int i;
+ unsigned int sofs, tofs;
+
+ sofs = ofs;
+ tofs = ofs;
+
+ tofs ^= CGA_ODD_LINES_OFS;
+ if((tofs & CGA_ODD_LINES_OFS) == 0)
+ tofs += CGA_BYTES_PER_LINE;
+
+ /*shift whole block 1 line*/
+ for(i = 0;i < h;i++)
+ {
+ /*copy current line to next*/
+ memcpy(target + tofs, screen + sofs, w);
+
+ /*next = current*/
+ tofs = sofs;
+
+ /*go 1 line up*/
+ sofs ^= CGA_ODD_LINES_OFS;
+ if((sofs & CGA_ODD_LINES_OFS) != 0)
+ sofs -= CGA_BYTES_PER_LINE;
+ }
+
+ /*fill just freed line with new pixels*/
+ memcpy(target + tofs, source + tofs, w);
+ WaitVBlank();
+
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+}
+
+/*Copy interlaced screen data n lines up (with clipping)*/
+/*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)
+{
+ while(n--)
+ {
+ int i;
+ unsigned int sofs, tofs;
+
+ sofs = ofs;
+ tofs = ofs;
+
+ tofs ^= CGA_ODD_LINES_OFS;
+ if((tofs & CGA_ODD_LINES_OFS) != 0)
+ tofs -= CGA_BYTES_PER_LINE;
+
+ /*shift whole block 1 line*/
+ for(i = 0;i < h;i++)
+ {
+ /*copy current line to next*/
+ memcpy(target + tofs, screen + sofs, w);
+
+ /*next = current*/
+ tofs = sofs;
+
+ /*go 1 line down*/
+ sofs ^= CGA_ODD_LINES_OFS;
+ if((sofs & CGA_ODD_LINES_OFS) == 0)
+ sofs += CGA_BYTES_PER_LINE;
+ }
+
+ /*fill just freed line with new pixels*/
+ memcpy(target + tofs, source + tofs, w);
+ WaitVBlank();
+
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) != 0)
+ ofs -= CGA_BYTES_PER_LINE;
+ }
+}
+
+/*Copy interlaced screen data n lines left (with clipping)*/
+/*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)
+{
+ while(n--)
+ {
+ int i;
+ unsigned int sofs, tofs;
+
+ sofs = ofs;
+
+ /*shift whole block 1 column*/
+ for(i = 0;i < h;i++)
+ {
+ tofs = sofs - 1;
+ memcpy(target + tofs, screen + sofs, w);
+
+ /*fill freed column*/
+ memcpy(target + tofs + w, source + tofs + w, 1);
+
+ /*go 1 line down*/
+ sofs ^= CGA_ODD_LINES_OFS;
+ if((sofs & CGA_ODD_LINES_OFS) == 0)
+ sofs += CGA_BYTES_PER_LINE;
+ }
+
+ WaitVBlank();
+
+ ofs--;
+ }
+}
+
+/*Copy interlaced screen data n lines right (with clipping)*/
+/*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)
+{
+ /*TODO: check me if its ok*/
+ while(n--)
+ {
+ int i;
+ unsigned int sofs, tofs;
+
+ sofs = ofs;
+
+ /*shift whole block 1 column*/
+ for(i = 0;i < h;i++)
+ {
+ tofs = sofs + 1;
+ memcpy(target + tofs - w, screen + sofs - w, w);
+
+ /*fill freed column*/
+ memcpy(target + tofs - w, source + tofs - w, 1);
+
+ /*go 1 line down*/
+ sofs ^= CGA_ODD_LINES_OFS;
+ if((sofs & CGA_ODD_LINES_OFS) == 0)
+ sofs += CGA_BYTES_PER_LINE;
+ }
+
+ WaitVBlank();
+
+ ofs++;
+ }
+}
+
+
+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;
+} scrpiece_t;
+
+static const unsigned char 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,
+ 86, 214, 173, 91, 91, 85, 88, 170, 173, 85, 170, 181,
+ 85, 182, 168, 170, 170, 171, 85, 85, 90, 170, 168, 170,
+ 170, 170, 170, 170, 170, 170, 168, 213, 82, 170, 85,
+ 74, 170, 73, 88, 170, 169, 41, 82, 164, 164, 170, 168,
+ 170, 148, 165, 41, 74, 73, 41, 40, 201, 41, 37, 36,
+ 164, 148, 148, 152, 164, 146, 73, 36, 146, 73, 36, 152,
+ 164, 73, 18, 68, 145, 36, 68, 136, 145, 34, 36, 68,
+ 136, 145, 18, 40, 145, 16, 136, 136, 68, 68, 66, 24,
+ 136, 66, 16, 132, 33, 8, 66, 24, 132, 16, 65, 8, 32,
+ 132, 16, 72, 130, 4, 8, 8, 16, 32, 32, 72, 128, 128,
+ 64, 32, 8, 2, 1, 8, 128, 8, 0, 32, 0, 128, 8, 8, 128,
+ 0, 4, 0, 0, 4, 0, 8, 128, 0, 0, 0, 0, 0, 0, 8
+};
+
+/*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;
+ height = (height + 3) / 4;
+ while(height--)
+ {
+ unsigned int x;
+ for(x = 0;x < width;x++)
+ {
+ unsigned int bofs = offs + x;
+ pieces->offs = bofs;
+ pieces->delay = *delays++;
+ if(pieces->delay == 0) /*ensure piece is alive*/
+ pieces->delay = 1;
+ pieces->pix0 = screen[bofs];
+ pieces->pix2 = screen[bofs + CGA_BYTES_PER_LINE];
+
+ bofs ^= CGA_ODD_LINES_OFS;
+ if((bofs & CGA_ODD_LINES_OFS) == 0)
+ bofs += CGA_BYTES_PER_LINE;
+ pieces->pix1 = screen[bofs];
+ pieces->pix3 = screen[bofs + CGA_BYTES_PER_LINE];
+ pieces++;
+ }
+ offs += CGA_BYTES_PER_LINE * 2; /*4 lines down*/
+ }
+ 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;
+ 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;
+ if(target[bofs] == piece->pix0)
+ target[bofs] = source[bofs];
+ if(target[bofs+CGA_BYTES_PER_LINE] == piece->pix2)
+ target[bofs+CGA_BYTES_PER_LINE] = source[bofs+CGA_BYTES_PER_LINE];
+
+ bofs ^= CGA_ODD_LINES_OFS;
+ if((bofs & CGA_ODD_LINES_OFS) == 0)
+ bofs += CGA_BYTES_PER_LINE;
+
+ if(target[bofs] == piece->pix1)
+ target[bofs] = source[bofs];
+ if(target[bofs+CGA_BYTES_PER_LINE] == piece->pix3)
+ target[bofs+CGA_BYTES_PER_LINE] = source[bofs+CGA_BYTES_PER_LINE];
+
+ /*dead?*/
+ if(piece->delay == 0)
+ continue;
+
+ /*fall n lines*/
+ switch((piece->delay & 3) + 1)
+ {
+ case 1:
+ offs ^= CGA_ODD_LINES_OFS;
+ if((offs & CGA_ODD_LINES_OFS) == 0)
+ offs += CGA_BYTES_PER_LINE;
+ break;
+ case 2:
+ offs += CGA_BYTES_PER_LINE;
+ break;
+ case 3:
+ offs += CGA_BYTES_PER_LINE;
+ offs ^= CGA_ODD_LINES_OFS;
+ if((offs & CGA_ODD_LINES_OFS) == 0)
+ offs += CGA_BYTES_PER_LINE;
+ break;
+ case 4:
+ offs += CGA_BYTES_PER_LINE;
+ offs += CGA_BYTES_PER_LINE;
+ break;
+ }
+
+ /*extra 2 lines*/
+ offs += CGA_BYTES_PER_LINE;
+
+ piece->offs = offs;
+
+ /*past line 190?*/
+ if((offs | CGA_ODD_LINES_OFS) >= ((190 / 2 * CGA_BYTES_PER_LINE) | CGA_ODD_LINES_OFS))
+ {
+ piece->delay = 0;
+ continue;
+ }
+
+ bofs = offs;
+
+ target[bofs] = piece->pix0;
+ target[bofs+CGA_BYTES_PER_LINE] = piece->pix2;
+
+ bofs ^= CGA_ODD_LINES_OFS;
+ if((bofs & CGA_ODD_LINES_OFS) == 0)
+ bofs += CGA_BYTES_PER_LINE;
+
+ target[bofs] = piece->pix1;
+ target[bofs+CGA_BYTES_PER_LINE] = piece->pix3;
+ }
+ again = 1;
+ }
+ WaitVBlank();
+ t++;
+ }
+ while(again);
+}
+
+void CGA_HideShatterFall(unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int 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;
+
+ if(ex >= sx)
+ w = ex - sx;
+ else
+ {
+ w = sx - ex - 1;
+ b0 = 1;
+ }
+ dx = -(w * 2) - 1;
+
+
+ if(ey >= sy)
+ h = ey - sy;
+ else
+ {
+ h = sy - ey - 1;
+ b1 = 1;
+ }
+ dy = h * 2;
+
+ ofs = CGA_CalcXY_p(sx / 4, sy);
+ mask = 0xC0 >> ((sx % 4) * 2);
+
+ val = dy + dx;
+
+ target[ofs] = (target[ofs] & ~mask) | (source[ofs] & mask);
+
+ count = w + h;
+
+ while(count--)
+ {
+ if(val > 0)
+ {
+ if(b1 == 0)
+ {
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+ else
+ {
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) != 0)
+ ofs -= CGA_BYTES_PER_LINE;
+ }
+ val += dx;
+ }
+ else
+ {
+ if(b0 == 0)
+ {
+ mask >>= 2;
+ if(mask == 0)
+ {
+ mask = 0xC0;
+ ofs += 1;
+ }
+ }
+ else
+ {
+ mask <<= 2;
+ if(mask == 0)
+ {
+ mask = 0x03;
+ ofs -= 1;
+ }
+ }
+ val += dy;
+ if(val > 0)
+ continue;
+ }
+ target[ofs] = (target[ofs] & ~mask) | (source[ofs] & mask);
+ }
+}
diff --git a/engines/chamber/cga.h b/engines/chamber/cga.h
new file mode 100644
index 00000000000..68ee5f3a86b
--- /dev/null
+++ b/engines/chamber/cga.h
@@ -0,0 +1,104 @@
+#ifndef _CGA_H_
+#define _CGA_H_
+
+#include <dos.h>
+
+#define CGA_WIDTH 320
+#define CGA_HEIGHT 200
+#define CGA_BASE_SEG 0xB800
+#define CGA_ODD_LINES_OFS 0x2000
+#define CGA_BITS_PER_PIXEL 2
+#define CGA_PIXELS_PER_BYTE (8 / CGA_BITS_PER_PIXEL)
+#define CGA_BYTES_PER_LINE (CGA_WIDTH / CGA_PIXELS_PER_BYTE)
+
+#define CGA_SCREENBUFFER ((unsigned char*)MK_FP(CGA_BASE_SEG, 0))
+
+#define CGA_FONT_HEIGHT 6
+
+#define CGA_NEXT_LINE(offs) ((CGA_ODD_LINES_OFS ^ (offs)) + (((offs) & CGA_ODD_LINES_OFS) ? 0 : CGA_BYTES_PER_LINE))
+#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 unsigned char sprit_load_buffer[1290];
+
+extern unsigned char 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;
+
+void SwitchToGraphicsMode(void);
+void SwitchToTextMode(void);
+
+void WaitVBlank(void);
+
+void CGA_ColorSelect(unsigned char 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);
+
+unsigned int CGA_CalcXY(unsigned int x, unsigned int y);
+unsigned int CGA_CalcXY_p(unsigned int x, unsigned int y);
+
+void CGA_CopyScreenBlock(unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int 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);
+
+void CGA_RestoreImage(unsigned char *buffer, unsigned char *target);
+void CGA_RefreshImageData(unsigned char *buffer);
+void CGA_RestoreBackupImage(unsigned char *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_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_PrintChar(unsigned char c, unsigned char *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_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_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 DrawSprite(unsigned char *sprite, unsigned char *screen, unsigned int ofs);
+void DrawSpriteFlip(unsigned char *sprite, unsigned char *screen, unsigned int 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 BackupAndShowSprite(unsigned char index, unsigned char x, unsigned char y);
+
+unsigned char * LoadSprite(unsigned char index, unsigned char *bank, unsigned char *buffer, unsigned char header_only);
+
+unsigned char *LoadSprit(unsigned char index);
+unsigned char *LoadPersSprit(unsigned char 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_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_HideShatterFall(unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs);
+
+void CGA_TraceLine(unsigned int sx, unsigned int ex, unsigned int sy, unsigned int ey, unsigned char *source, unsigned char *target);
+
+#endif
diff --git a/engines/chamber/cln.bat b/engines/chamber/cln.bat
new file mode 100644
index 00000000000..004aa3b0950
--- /dev/null
+++ b/engines/chamber/cln.bat
@@ -0,0 +1,3 @@
+ at echo off
+
+..\bin\tc\make clean
diff --git a/engines/chamber/common.h b/engines/chamber/common.h
new file mode 100644
index 00000000000..61938be538a
--- /dev/null
+++ b/engines/chamber/common.h
@@ -0,0 +1,57 @@
+#ifndef _COMMON_H_
+#define _COMMON_H_
+
+#define BE(x) (((x) >> 8) | ((x) << 8))
+#define LE16(x) (x)
+
+#define TODO(s) \
+{ \
+ printf(s); \
+ PromptWait(); \
+ for(;;) ; \
+}
+
+typedef struct rect_t {
+ unsigned char sx;
+ unsigned char ex;
+ unsigned char sy;
+ unsigned char ey;
+} rect_t;
+
+#if sizeof(rect_t) != 4
+#error "rect_t must be 4 bytes long"
+#endif
+
+#if 0
+#define DEBUG
+#endif
+
+#if 1
+#define DEBUG_ZONE
+#endif
+
+#if 0
+/*Rope -> De Profundis*/
+#define DEBUG_QUEST 0x00
+#endif
+
+#if 0
+/*Knife -> The Wall*/
+#define DEBUG_QUEST 0x40
+#endif
+
+#if 1
+/*Goblet -> The Twins*/
+#define DEBUG_QUEST 0x80
+#endif
+
+#if 0
+/*Fly -> Scorpion's*/
+#define DEBUG_QUEST 0xC0
+#endif
+
+#if 0
+#define CHEAT
+#endif
+
+#endif
diff --git a/engines/chamber/cursor.c b/engines/chamber/cursor.c
new file mode 100644
index 00000000000..b5556405b6e
--- /dev/null
+++ b/engines/chamber/cursor.c
@@ -0,0 +1,170 @@
+#include "common.h"
+#include "cursor.h"
+#include "resdata.h"
+#include "cga.h"
+
+unsigned char cursor_color = 0;
+
+unsigned char *cursor_shape;
+unsigned char cursor_anim_ticks;
+unsigned char cursor_anim_phase;
+
+/*cursors hotspot offsets*/
+unsigned int cursor_shifts[CURSOR_MAX][2] = {
+ { 0, 0 },
+ { 7, 7 },
+ { 7, 7 },
+ { 0, 0 },
+ { 7, 7 },
+ { 0, 15 },
+ { 7, 7 },
+ { 7, 7 },
+ { 7, 7 }
+};
+
+unsigned int cursor_x_shift;
+unsigned char 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;
+unsigned char cursor_bit_shift;
+
+/*
+Select cursor shape and its hotspot
+*/
+void SelectCursor(unsigned int 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;
+}
+
+/*
+Build cursor sprite for its current pixel-grained position
+*/
+void UpdateCursor(void)
+{
+ unsigned char *cursor, *sprite, *spr;
+ unsigned char cursor_bit_shift;
+ unsigned int x, y;
+ x = cursor_x - cursor_x_shift; if((signed int)x < 0) x = 0;
+ y = cursor_y - cursor_y_shift; if((signed int)y < 0) y = 0;
+
+ cursor_bit_shift = (x % 4) * 2;
+ cursor_draw_ofs = CGA_CalcXY_p(x / 4, y);
+
+ cursor = cursor_shape;
+ sprite = sprit_load_buffer;
+
+ if(cursor_bit_shift == 0)
+ {
+ /*pixels*/
+ spr = sprite;
+ for(y = 0;y < CURSOR_HEIGHT;y++)
+ {
+ for(x = 0;x < CURSOR_WIDTH / 4;x++)
+ {
+ unsigned char p = *cursor++;
+ spr[x * 2] = p;
+ }
+ spr[x * 2] = 0;
+ spr += 5 * 2;
+ }
+
+ /*mask*/
+ spr = sprite + 1;
+ for(y = 0;y < CURSOR_HEIGHT;y++)
+ {
+ for(x = 0;x < CURSOR_WIDTH / 4;x++)
+ {
+ unsigned char p = *cursor++;
+ spr[x * 2] = p;
+ }
+ spr[x * 2] = 0xFF;
+ spr += 5 * 2;
+ }
+ }
+ 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;
+ for(i = 0;i < cursor_bit_shift;i++)
+ {
+ p4 = (p4 >> 1) | (p3 << 7);
+ p3 = (p3 >> 1) | (p2 << 7);
+ p2 = (p2 >> 1) | (p1 << 7);
+ p1 = (p1 >> 1) | (p0 << 7);
+ p0 = (p0 >> 1) | (0 << 7);
+ }
+ spr[0] = p0;
+ spr[2] = p1;
+ spr[4] = p2;
+ spr[6] = p3;
+ spr[8] = p4;
+
+ spr += 5 * 2;
+ }
+
+ 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;
+ for(i = 0;i < cursor_bit_shift;i++)
+ {
+ p4 = (p4 >> 1) | (p3 << 7);
+ p3 = (p3 >> 1) | (p2 << 7);
+ p2 = (p2 >> 1) | (p1 << 7);
+ p1 = (p1 >> 1) | (p0 << 7);
+ p0 = (p0 >> 1) | (1 << 7);
+ }
+ spr[0] = p0;
+ spr[2] = p1;
+ spr[4] = p2;
+ spr[6] = p3;
+ spr[8] = p4;
+ spr += 5 * 2;
+ }
+ }
+}
+
+/*
+Draw cursor sprite and backup background pixels
+*/
+void DrawCursor(unsigned char *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);
+}
+
+/*
+Restore background pixels under cursor
+*/
+void UndrawCursor(unsigned char *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)
+{
+ /*TODO: does this call order makes any sense?*/
+ UpdateCursor();
+ UndrawCursor(target);
+}
diff --git a/engines/chamber/cursor.h b/engines/chamber/cursor.h
new file mode 100644
index 00000000000..7f091b443d9
--- /dev/null
+++ b/engines/chamber/cursor.h
@@ -0,0 +1,34 @@
+#ifndef _CURSOR_H_
+#define _CURSOR_H_
+
+#define CURSOR_WIDTH 16
+#define CURSOR_HEIGHT 16
+#define CURSOR_WIDTH_SPR 20
+
+enum Cursors {
+ CURSOR_0,
+ CURSOR_1,
+ CURSOR_FLY,
+ CURSOR_3,
+ CURSOR_4,
+ CURSOR_5,
+ CURSOR_6,
+ CURSOR_7,
+ CURSOR_8,
+ 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;
+
+void SelectCursor(unsigned int num);
+void UpdateCursor(void);
+void DrawCursor(unsigned char *target);
+void UndrawCursor(unsigned char *target);
+void UpdateUndrawCursor(unsigned char *target);
+
+#endif
diff --git a/engines/chamber/decompr.c b/engines/chamber/decompr.c
new file mode 100644
index 00000000000..1c3220ecfc6
--- /dev/null
+++ b/engines/chamber/decompr.c
@@ -0,0 +1,106 @@
+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;
+} DecompCtx;
+
+unsigned char decode_string(unsigned char code, unsigned char prev_n, unsigned char *stack)
+{
+ unsigned char n;
+ while((n = DecompCtx.coddict[code]) != 0)
+ {
+ while(n >= prev_n)
+ {
+ n = DecompCtx.codlink[n];
+ if(n == 0)
+ return code;
+ }
+ /*if(DecompCtx.stackpos == 255) exit("stack exploded");*/
+ stack[DecompCtx.stackpos++] = prev_n = n;
+ code = DecompCtx.prefix[n];
+ }
+ return code;
+}
+
+unsigned long decompress(unsigned char huge *data, unsigned char huge *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;
+
+ do
+ {
+ dict_size = *data++;
+ more = *data++;
+ compsize = *data++;
+ compsize |= (*data++) << 8;
+
+ if(dict_size == 0)
+ {
+ /* uncompressed block */
+ decompsize += compsize;
+ while (compsize--)
+ *result++ = *data++;
+ }
+ else
+ {
+ /* compressed block */
+ /*
+ memcpy(DecompCtx.codes + 1, data, dict_size); data += dict_size;
+ memcpy(DecompCtx.prefix + 1, data, dict_size); data += dict_size;
+ memcpy(DecompCtx.suffix + 1, data, dict_size); data += dict_size;
+ */
+ for(n = 1, i = 0; i < dict_size;n++, i++) DecompCtx.codes[n] = *data++;
+ for(n = 1, i = 0; i < dict_size;n++, i++) DecompCtx.prefix[n] = *data++;
+ for(n = 1, i = 0; i < dict_size;n++, i++) DecompCtx.suffix[n] = *data++;
+
+ memset(DecompCtx.coddict, 0, 256);
+ for(n = 1, i = 0; i < dict_size;n++, i++)
+ {
+ code = DecompCtx.codes[n];
+ DecompCtx.codlink[n] = DecompCtx.coddict[code];
+ DecompCtx.coddict[code] = n;
+ }
+
+ while(compsize-- > 0)
+ {
+ code = *data++;
+
+ if(DecompCtx.coddict[code] == 0)
+ {
+ /* literal */
+ *result++ = code;
+ decompsize += 1;
+ }
+ else
+ {
+ /* string */
+ DecompCtx.stackpos = 0;
+
+ n = DecompCtx.coddict[code];
+
+ stack[DecompCtx.stackpos++] = n;
+
+ for(code = DecompCtx.prefix[n];;code = DecompCtx.suffix[n])
+ {
+ suffix = decode_string(code, n, stack);
+ *result++ = suffix;
+ decompsize += 1;
+ if(DecompCtx.stackpos == 0)
+ break;
+ n = stack[--DecompCtx.stackpos];
+ }
+ }
+ }
+ }
+ }
+ while(more != 0);
+
+ return decompsize;
+}
diff --git a/engines/chamber/decompr.h b/engines/chamber/decompr.h
new file mode 100644
index 00000000000..e0028a424d2
--- /dev/null
+++ b/engines/chamber/decompr.h
@@ -0,0 +1 @@
+unsigned long decompress(unsigned char huge *data, unsigned char huge *result);
diff --git a/engines/chamber/dialog.c b/engines/chamber/dialog.c
new file mode 100644
index 00000000000..b162c8c9d33
--- /dev/null
+++ b/engines/chamber/dialog.c
@@ -0,0 +1,234 @@
+#include "common.h"
+#include "dialog.h"
+#include "print.h"
+#include "cga.h"
+#include "script.h"
+#include "cursor.h"
+#include "input.h"
+
+unsigned int cur_str_index;
+unsigned int cur_dlg_index;
+
+#define MAX_DIRTY_RECT 10
+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;
+ dirty_rect_t *r = dirty_rects;
+ for(i = 0;i < MAX_DIRTY_RECT;i++, r++) /*TODO: may go oob*/
+ if(r->kind == DirtyRectFree)
+ break;
+ r->kind = kind;
+ r->offs = offs;
+ r->width = w;
+ r->height = h;
+ r->y = y;
+ r->x = x;
+ 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)
+{
+ *kind = dirty_rects[index].kind;
+ *offs = dirty_rects[index].offs;
+ *w = dirty_rects[index].width;
+ *h = dirty_rects[index].height;
+ *y = dirty_rects[index].y;
+ *x = dirty_rects[index].x;
+
+ dirty_rects[index].kind = newkind;
+ 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)
+{
+ 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)
+{
+ 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;
+ for(i = 0;i < MAX_DIRTY_RECT;i++)
+ {
+ if(dirty_rects[i].kind == kind)
+ {
+ GetDirtyRect(i, &kind, x, y, w, h, offs, DirtyRectFree);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+/*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;
+ while(FindDirtyRectAndFree(kind, &x, &y, &width, &height, &offs))
+ {
+ CGA_CopyScreenBlock(backbuffer, width, height, frontbuffer, offs);
+ if(kind == DirtyRectBubble)
+ {
+ /*pop bubble's spike*/
+ CGA_CopyScreenBlock(backbuffer, 2, 21, frontbuffer, offs = (x << 8) | y);
+ }
+ }
+}
+
+void DesciTextBox(unsigned int x, unsigned int y, unsigned int width, unsigned char *msg)
+{
+ draw_x = x;
+ draw_y = y;
+ char_draw_max_width = width;
+ CGA_DrawTextBox(msg, frontbuffer);
+ AddDirtyRect(DirtyRectText, draw_x, draw_y, char_draw_max_width + 2, char_draw_coords_y - draw_y + 8, CGA_CalcXY_p(draw_x, draw_y));
+}
+
+/*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;
+
+ char_draw_max_width = flags & 0x1F;
+ char_xlat_table = chars_color_bonw;
+
+ /*upper border*/
+ ofs = CGA_CalcXY_p(x, y);
+ ofs = CGA_DrawHLineWithEnds(0xF00F, 0, 0, char_draw_max_width, CGA_SCREENBUFFER, ofs);
+ ofs = CGA_DrawHLineWithEnds(0xC003, 0x0FF0, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
+ ofs = CGA_DrawHLineWithEnds( 0, 0x3FFC, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
+ ofs = CGA_DrawHLineWithEnds( 0, 0x3FFC, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
+
+ /*body*/
+ char_draw_coords_x = x;
+ char_draw_coords_y = y + 4;
+
+ for(string_ended = 0;!string_ended;char_draw_coords_y += 6)
+ {
+ CGA_PrintChar(0x3B, CGA_SCREENBUFFER);
+ msg = PrintStringPadded(msg, CGA_SCREENBUFFER);
+ CGA_PrintChar(0x3C, CGA_SCREENBUFFER);
+ char_draw_coords_x = x;
+ }
+
+ ofs = CGA_CalcXY_p(x, char_draw_coords_y);
+ ofs = CGA_DrawHLineWithEnds(0xC003, 0x0FF0, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
+ ofs = CGA_DrawHLineWithEnds(0xF00F, 0, 0, char_draw_max_width, CGA_SCREENBUFFER, ofs);
+
+ w = char_draw_max_width + 2;
+ h = char_draw_coords_y - y + 2;
+
+ /*draw spike*/
+ switch(flags & SPIKE_MASK)
+ {
+ case SPIKE_UPLEFT: /*upper-left spike*/
+ ofs = CGA_CalcXY_p(x + 1, y - 7);
+ DrawSpriteN(18, x + 1, y - 7, CGA_SCREENBUFFER);
+ break;
+ case SPIKE_UPRIGHT: /*upper-right spike*/
+ ofs = CGA_CalcXY_p(x + char_draw_max_width, y - 7) - 1;
+ DrawSpriteNFlip(18, x + char_draw_max_width, y - 7, CGA_SCREENBUFFER);
+ break;
+ case SPIKE_DNRIGHT: /*lower-right spike*/
+ ofs = CGA_CalcXY_p(x + char_draw_max_width, char_draw_coords_y + 1) - 1;
+ DrawSpriteNFlip(21, x + char_draw_max_width, char_draw_coords_y + 1, CGA_SCREENBUFFER);
+ break;
+ case SPIKE_DNLEFT: /*lower-left spike*/
+ ofs = CGA_CalcXY_p(x + 1, char_draw_coords_y + 1);
+ DrawSpriteN(21, x + 1, char_draw_coords_y + 1, CGA_SCREENBUFFER);
+ break;
+ case SPIKE_BUBRIGHT: /*lower-right bubbles*/
+ ofs = CGA_CalcXY_p(x + char_draw_max_width, char_draw_coords_y + 4);
+ DrawSpriteN(20, x + char_draw_max_width, char_draw_coords_y + 4, CGA_SCREENBUFFER);
+ break;
+ case SPIKE_BUBLEFT: /*lower-left bubbles*/
+ ofs = CGA_CalcXY_p(x + 1, char_draw_coords_y + 4);
+ DrawSpriteN(19, x + 1, char_draw_coords_y + 4, CGA_SCREENBUFFER);
+ break;
+ }
+
+ AddDirtyRect(DirtyRectBubble, ofs >> 8, ofs & 255, w, h, CGA_CalcXY_p(x, y));
+}
+
+void ShowPromptAnim(void)
+{
+ if(script_byte_vars.zone_index == 135)
+ return;
+ WaitVBlank();
+ DrawSpriteN(cursor_anim_phase ? 23 : 22, 300 / 4, 155, frontbuffer);
+ cursor_anim_phase = ~cursor_anim_phase;
+}
+
+void PromptWait(void)
+{
+ cursor_anim_phase = 0;
+
+ do
+ {
+ unsigned char ticks = script_byte_vars.timer_ticks;
+ if((ticks % 8) == 0 && ticks != cursor_anim_ticks)
+ {
+ cursor_anim_ticks = ticks;
+ ShowPromptAnim();
+ }
+ PollInput();
+ }
+ while(!buttons);
+
+ if(cursor_anim_phase)
+ ShowPromptAnim();
+}
+
+/*
+Get string with index num from strings bank
+*/
+unsigned char * SeekToString(unsigned char *bank, unsigned int num)
+{
+ unsigned char len;
+ unsigned char *p = bank;
+
+ cur_str_index = num;
+
+ num -= 4;
+ while(num--)
+ {
+ len = *p;
+ p += len;
+ }
+ len = *p;
+ cur_str_end = p + len;
+ return p + 1;
+}
+
+/*
+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;
+
+ if(num < 4)
+ {
+ num = (num << 8) | *(++(*ptr));
+ }
+ cur_str_index = num;
+
+ num -= 4;
+ while(num--)
+ {
+ len = *p;
+ p += len;
+ }
+ len = *p;
+ cur_str_end = p + len;
+ return p + 1;
+}
diff --git a/engines/chamber/dialog.h b/engines/chamber/dialog.h
new file mode 100644
index 00000000000..6d769833f06
--- /dev/null
+++ b/engines/chamber/dialog.h
@@ -0,0 +1,47 @@
+#ifndef _DIALOG_H_
+#define _DIALOG_H_
+
+extern unsigned int cur_str_index;
+extern unsigned int cur_dlg_index;
+
+enum DirtyRectKind {
+ DirtyRectFree = 0,
+ DirtyRectBubble = 1, /*bubble with spike*/
+ DirtyRectSprite = 2, /*portrait*/
+ DirtyRectText = 3 /*text bubble w/o spike*/
+};
+
+typedef struct dirty_rect_t {
+unsigned char kind;
+unsigned int offs;
+unsigned char width;
+unsigned char height;
+unsigned char y; /*for DirtyRectBubble this is spike offs*/
+unsigned char x;
+} dirty_rect_t;
+
+extern dirty_rect_t dirty_rects[];
+
+#define SPIKE_MASK 0xE0
+#define SPIKE_UPLEFT 0
+#define SPIKE_UPRIGHT 0x20
+#define SPIKE_DNRIGHT 0x80
+#define SPIKE_DNLEFT 0xA0
+#define SPIKE_BUBBLES 0x40
+#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 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 PromptWait(void);
+
+unsigned char * SeekToString(unsigned char *bank, unsigned int num);
+unsigned char * SeekToStringScr(unsigned char *bank, unsigned int num, unsigned char **ptr);
+
+#endif
diff --git a/engines/chamber/input.c b/engines/chamber/input.c
new file mode 100644
index 00000000000..563cf98fa99
--- /dev/null
+++ b/engines/chamber/input.c
@@ -0,0 +1,254 @@
+#include <dos.h>
+#include <conio.h>
+#include "common.h"
+#include "input.h"
+#include "cursor.h"
+#include "cga.h"
+
+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;
+
+void interrupt (*old_keyboard_isr)(void);
+
+unsigned char ReadKeyboardChar(void)
+{
+#ifdef DEBUG
+ if(old_keyboard_isr)
+ {
+ do
+ {
+ PollInput();
+ }
+ while(!buttons);
+ }
+ else
+#endif
+ return (unsigned char)getch();
+}
+
+void ClearKeyboard(void)
+{
+ while(kbhit())
+ {
+ getch();
+ }
+}
+
+void interrupt NullIsr(void)
+{
+ /*nothing*/
+}
+
+void SetInputButtons(unsigned char keys)
+{
+ if(keys && buttons_repeat)
+ {
+ /*ignore buttons repeat*/
+ buttons = 0;
+ return;
+ }
+ if(keys & 2)
+ right_button = ~0;
+ if(keys & 1)
+ right_button = 0;
+ buttons = keys;
+ buttons_repeat = keys;
+}
+
+unsigned char PollMouse(void)
+{
+ union REGS reg;
+ reg.x.ax = 3;
+ int86(0x33, ®, ®);
+ cursor_x = reg.x.cx;
+ cursor_y = reg.h.dl;
+ return reg.h.bl; /*buttons*/
+}
+
+unsigned char PollKeyboard(void)
+{
+ unsigned char direction = key_direction;
+ if(direction && direction == key_direction_old)
+ {
+ if(++accell_countdown == 10)
+ {
+ accelleration++;
+ accell_countdown = 0;
+ }
+ }
+ else
+ {
+ accelleration = 1;
+ accell_countdown = 0;
+ }
+ key_direction_old = direction;
+
+ if(direction & 0x0F)
+ {
+ if(direction == 1)
+ {
+ cursor_x += accelleration;
+ if(cursor_x >= 304) /*TODO: >*/
+ cursor_x = 304;
+ }
+ else
+ {
+ cursor_x -= accelleration;
+ if((signed int)cursor_x < 0)
+ cursor_x = 0;
+ }
+ }
+
+ if(direction & 0xF0)
+ {
+ if(direction == 0x10)
+ {
+ cursor_y += accelleration;
+ if(cursor_y >= 184) /*TODO: >*/
+ cursor_y = 184;
+ }
+ else
+ {
+ cursor_y -= accelleration;
+ if((signed char)cursor_y < 0)
+ cursor_y = 0;
+ }
+ }
+
+ return key_code;
+}
+
+void PollInput(void)
+{
+ unsigned char keys;
+ if(have_mouse)
+ keys = PollMouse();
+ else
+ keys = PollKeyboard();
+ SetInputButtons(keys);
+}
+
+void ProcessInput(void)
+{
+ PollInput();
+ UpdateCursor();
+ DrawCursor(frontbuffer);
+}
+
+void interrupt KeyboardIsr()
+{
+ unsigned char scan, strobe;
+ scan = inportb(0x60);
+ /*consume scan from kbd. controller*/
+ strobe = inportb(0x61);
+ outportb(0x61, strobe | 0x80);
+ outportb(0x61, strobe);
+
+ if(scan == 1) /*esc*/
+ {
+ esc_pressed = ~0;
+ }
+ else
+ {
+ if(scan & 0x80) /*key release?*/
+ {
+ key_code = 0;
+ key_direction = 0;
+ }
+ else
+ {
+ switch(scan)
+ {
+ case 0x39: /*space*/
+ key_code = scan;
+ key_direction = 0;
+ break;
+ case 0x48: /*up*/
+ key_code = 0;
+ key_direction = 0xF0;
+ break;
+ case 0x50: /*down*/
+ key_code = 0;
+ key_direction = 0x10;
+ break;
+ case 0x4B: /*left*/
+ key_code = 0;
+ key_direction = 0x0F;
+ break;
+ case 0x4D: /*right*/
+ key_code = 0;
+ key_direction = 0x01;
+ break;
+ }
+ }
+ }
+ outportb(0x20, 0x20);
+}
+
+void InitInput(void)
+{
+ /*disable critical errors handler*/
+ setvect(0x24, NullIsr);
+
+ /*is mouse present?*/
+ if(getvect(0x33))
+ {
+ union REGS reg;
+ reg.x.ax = 0;
+ int86(0x33, ®, ®);
+ if(reg.x.ax == 0xFFFF)
+ {
+ /*mouse detected*/
+
+ reg.x.ax = 0xF; /*set cursor speed*/
+ reg.x.cx = 16;
+ reg.x.dx = 16;
+ int86(0x33, ®, ®);
+
+ reg.x.ax = 7; /*set x range*/
+ reg.x.cx = 0;
+ reg.x.dx = 303;
+ int86(0x33, ®, ®);
+
+ reg.x.ax = 8; /*set y range*/
+ reg.x.cx = 0;
+ reg.x.dx = 183;
+ int86(0x33, ®, ®);
+
+ reg.x.ax = 4; /*set coords*/
+ cursor_x = reg.x.cx = 10;
+ cursor_y = reg.x.dx = 10;
+ int86(0x33, ®, ®);
+
+ have_mouse = ~0;
+ }
+ }
+
+ if(have_mouse)
+ return;
+
+ /*no mouse*/
+
+ old_keyboard_isr = getvect(9);
+ setvect(9, KeyboardIsr);
+}
+
+void UninitInput(void)
+{
+ if(have_mouse)
+ return;
+
+ setvect(9, old_keyboard_isr);
+#ifdef DEBUG
+ old_keyboard_isr = 0;
+#endif
+}
diff --git a/engines/chamber/input.h b/engines/chamber/input.h
new file mode 100644
index 00000000000..438c04030eb
--- /dev/null
+++ b/engines/chamber/input.h
@@ -0,0 +1,26 @@
+#ifndef _INPUT_H_
+#define _INPUT_H_
+
+extern unsigned char buttons;
+extern unsigned char right_button;
+
+extern unsigned char have_mouse;
+
+extern volatile unsigned char key_direction;
+extern volatile unsigned char key_code;
+extern unsigned char key_held;
+
+unsigned char ReadKeyboardChar(void);
+void ClearKeyboard(void);
+
+unsigned char PollMouse(void);
+unsigned char PollKeyboard(void);
+void SetInputButtons(unsigned char keys);
+
+void PollInput(void);
+void ProcessInput(void);
+
+void InitInput(void);
+void UninitInput(void);
+
+#endif
diff --git a/engines/chamber/invent.c b/engines/chamber/invent.c
new file mode 100644
index 00000000000..c356a541a36
--- /dev/null
+++ b/engines/chamber/invent.c
@@ -0,0 +1,123 @@
+#include "common.h"
+#include "invent.h"
+#include "script.h"
+#include "cga.h"
+#include "cursor.h"
+#include "input.h"
+#include "sound.h"
+
+/*inventory box cells*/
+#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;
+} inventory_spots[] = {
+ {58, 62, 56, 72, 0, 0, 0, 0, 0},
+ {62, 66, 56, 72, 0, 0, 0, 0, 0},
+ {66, 70, 56, 72, 0, 0, 0, 0, 0},
+ {70, 74, 56, 72, 0, 0, 0, 0, 0},
+ {58, 62, 72, 88, 0, 0, 0, 0, 0},
+ {62, 66, 72, 88, 0, 0, 0, 0, 0},
+ {66, 70, 72, 88, 0, 0, 0, 0, 0},
+ {70, 74, 72, 88, 0, 0, 0, 0, 0},
+ {58, 62, 88, 104, 0, 0, 0, 0, 0},
+ {62, 66, 88, 104, 0, 0, 0, 0, 0},
+ {66, 70, 88, 104, 0, 0, 0, 0, 0},
+ {70, 74, 88, 104, 0, 0, 0, 0, 0},
+ {58, 62, 104, 120, 0, 0, 0, 0, 0},
+ {62, 66, 104, 120, 0, 0, 0, 0, 0},
+ {66, 70, 104, 120, 0, 0, 0, 0, 0},
+ {70, 74, 104, 120, 0, 0, 0, 0, 0}
+};
+
+
+unsigned char inv_count = 0; /*TODO: pass this as param?*/
+unsigned char 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;
+ for(i = 0;i < MAX_INV_ITEMS;i++)
+ {
+ unsigned short flags = (inventory_items[i].flags2 << 8) | inventory_items[i].flags;
+ if((flags & filtermask) != filtervalue)
+ continue;
+ if(count == 0)
+ {
+ /*draw the box*/
+ CGA_FillAndWait(inv_bgcolor, 64/4, 64, CGA_SCREENBUFFER, CGA_CalcXY_p(232/4, 56));
+ PlaySound(20);
+ }
+ inventory_spots[count].name = inventory_items[i].name;
+ inventory_spots[count].command = inventory_items[i].command;
+ inventory_spots[count].itemidx = i + 1;
+ DrawSpriteN(inventory_items[i].sprite, inventory_spots[count].sx, inventory_spots[count].sy, CGA_SCREENBUFFER);
+ count++;
+ }
+ inv_count = count;
+}
+
+void CheckInventoryItemHover(unsigned char count)
+{
+ int i;
+ for(i = 0;i < count;i++)
+ {
+ if(IsCursorInRect((rect_t*)&inventory_spots[i]))
+ {
+ the_command = inventory_spots[i].command;
+ command_hint = inventory_spots[i].name;
+ cursor_color = 0xAA;
+ script_byte_vars.inv_item_index = inventory_spots[i].itemidx;
+ script_vars[ScrPool3_CurrentItem] = &inventory_items[script_byte_vars.inv_item_index - 1];
+ return;
+ }
+ }
+ /*nothing found*/
+ command_hint = 100;
+ cursor_color = 0xFF;
+ the_command = 0;
+}
+
+void OpenInventory(unsigned short filtermask, unsigned short filtervalue)
+{
+ the_command = 0;
+ CGA_BackupImageReal(CGA_CalcXY_p(232/4, 56), 64/4, 64);
+ DrawInventoryBox(filtermask, filtervalue);
+ if(inv_count != 0)
+ {
+ SelectCursor(CURSOR_0);
+ ProcessInput();
+ do
+ {
+ PollInput();
+ CheckInventoryItemHover(inv_count);
+ if(command_hint != last_command_hint)
+ DrawCommandHint();
+ DrawHintsAndCursor(frontbuffer);
+ }
+ while(buttons == 0);
+ UndrawCursor(frontbuffer);
+ }
+ CGA_RestoreImage(scratch_mem2, frontbuffer);
+ PlaySound(20);
+ switch(((item_t*)script_vars[ScrPool3_CurrentItem])->name)
+ {
+ case 108:
+ case 115:
+ case 117:
+ script_byte_vars.byte_17A19 = 1;
+ break;
+ default:
+ script_byte_vars.byte_17A19 = 0;
+ }
+}
diff --git a/engines/chamber/invent.h b/engines/chamber/invent.h
new file mode 100644
index 00000000000..9714ece9e7e
--- /dev/null
+++ b/engines/chamber/invent.h
@@ -0,0 +1,11 @@
+#ifndef _INVENT_H_
+#define _INVENT_H_
+
+extern unsigned char inv_count;
+extern unsigned char inv_bgcolor;
+
+void DrawInventoryBox(unsigned short filtermask, unsigned short filtervalue);
+
+void OpenInventory(unsigned short filtermask, unsigned short filtervalue);
+
+#endif
diff --git a/engines/chamber/kult.c b/engines/chamber/kult.c
new file mode 100644
index 00000000000..69bf91829b2
--- /dev/null
+++ b/engines/chamber/kult.c
@@ -0,0 +1,298 @@
+#include <stdio.h>
+#include <dos.h>
+#include <io.h>
+#include <fcntl.h>
+#include <assert.h>
+
+#include "common.h"
+#include "decompr.h"
+#include "cga.h"
+#include "anim.h"
+#include "cursor.h"
+#include "input.h"
+#include "timer.h"
+#include "portrait.h"
+#include "room.h"
+#include "savegame.h"
+#include "resdata.h"
+#include "script.h"
+#include "print.h"
+#include "dialog.h"
+#include "menu.h"
+
+unsigned short cpu_speed_delay;
+
+/*
+Prompt user to insert disk #2 to any drive
+*/
+void AskDisk2(void)
+{
+ DrawMessage(SeekToString(vepci_data, 179), frontbuffer);
+}
+
+void SaveToFile(char *filename, void *data, unsigned int size)
+{
+ FILE *f = fopen(filename, "wb");
+ fwrite(data, 1, size, f);
+ fclose(f);
+}
+
+int LoadSplash(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;
+ 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;
+}
+
+void Randomize(void)
+{
+ union REGS reg;
+
+ reg.h.ah = 0;
+ int86(0x1A, ®, ®);
+ rand_seed = reg.h.dl;
+ Rand();
+}
+
+void TRAP()
+{
+ PromptWait();
+ for(;;) ;
+}
+
+/* Main Game Loop */
+void GameLoop(unsigned char *target)
+{
+ for(;;)
+ {
+#if 1
+ AnimateSpots(target);
+#endif
+ /* Update/check live things */
+ UpdateTimedRects1();
+ UpdateTimedRects2();
+ UpdateTimedInventoryItems();
+
+ /* Get player input */
+ PollInput();
+
+ the_command = 0;
+ if(IsCursorInRect(&room_bounds_rect))
+ {
+ SelectCursor(CURSOR_1);
+ command_hint = 100;
+ SelectSpotCursor();
+ }
+ else
+ {
+ SelectCursor(CURSOR_0);
+ object_hint = 117;
+ CheckMenuCommandHover();
+ }
+
+ if(object_hint != last_object_hint)
+ DrawObjectHint();
+
+ if(command_hint != last_command_hint)
+ DrawCommandHint();
+
+ DrawHintsAndCursor(target);
+
+ if(!buttons || !the_command)
+ {
+ /*Pending / AI commands*/
+
+ if(script_byte_vars.check_used_commands < script_byte_vars.used_commands)
+ {
+ the_command = Swap16(script_word_vars.next_command1);
+ if(the_command)
+ goto process;
+ }
+
+ if(script_byte_vars.flag_179FB)
+ continue;
+
+ the_command = Swap16(script_word_vars.next_command2);
+ if(the_command)
+ goto process;
+
+ if(Swap16(next_ticks3) < script_word_vars.timer_ticks2) /*TODO: is this ok? ticks2 is BE, ticks3 is LE*/
+ {
+ the_command = next_command3;
+ if(the_command)
+ goto process;
+ }
+
+ if(Swap16(next_ticks4) < script_word_vars.timer_ticks2) /*TODO: is this ok? ticks2 is BE, ticks4 is LE*/
+ {
+ the_command = next_command4;
+ if(the_command)
+ goto process;
+ }
+
+ continue;
+
+process:;
+ UpdateUndrawCursor(target);
+ RefreshSpritesData();
+ RunCommand();
+ BlitSpritesToBackBuffer();
+ ProcessInput();
+ DrawSpots(target);
+ }
+ else
+ {
+ /*Player action*/
+
+ UpdateUndrawCursor(target);
+ RefreshSpritesData();
+ RunCommandKeepSp();
+ script_byte_vars.used_commands++;
+ if(script_byte_vars.dead_flag)
+ {
+ if(--script_byte_vars.tries_left == 0)
+ ResetAllPersons();
+ }
+ BlitSpritesToBackBuffer();
+ ProcessInput();
+ DrawSpots(target);
+ }
+ }
+}
+
+
+void ExitGame(void)
+{
+ SwitchToTextMode();
+ exit(0);
+}
+
+void main(void)
+{
+ unsigned char c;
+
+ SwitchToGraphicsMode();
+
+ /* Load title screen */
+ if(!LoadSplash("PRES.BIN"))
+ ExitGame();
+
+ /* Select intense cyan-mageta palette */
+ CGA_ColorSelect(0x30);
+
+ /* Show the title screen */
+ CGA_BackBufferToRealFull();
+
+#ifdef COPYPROT
+ /* Check if a valid floppy disk is present in any drive */
+ if(!CheckCopyProtection()) for(;;) ;
+#endif
+
+ /* Load language selection screen */
+ if(!LoadSplash("DRAP.BIN"))
+ ExitGame();
+
+ /* Wait for a keypress and show the language selection screen */
+ ClearKeyboard();
+ ReadKeyboardChar();
+ CGA_SwapRealBackBuffer();
+ ClearKeyboard();
+
+ /* Wait for a valid language choice */
+ do
+ {
+ c = ReadKeyboardChar();
+ if(c > 'F')
+ c -= ' ';
+ }
+ while(c < 'D' || c > 'F');
+
+ /* Patch resource names for choosen language */
+ res_texts[0].name[4] = c;
+ res_texts[1].name[4] = c;
+ res_desci[0].name[4] = c;
+ res_diali[0].name[4] = c;
+
+ CGA_BackBufferToRealFull();
+
+ /* Load script and other static resources */
+ /* Those are normally embedded in the executable, but here we load extracted ones*/
+ if(!LoadStaticData())
+ ExitGame();
+
+ /* Load text resources */
+ if(!LoadVepciData() || !LoadDesciData() || !LoadDialiData())
+ ExitGame();
+
+ /* Load graphics resources */
+ while(!LoadFond() || !LoadSpritesData() || !LoadPersData())
+ AskDisk2();
+
+ /* Detect/Initialize input device */
+ InitInput();
+
+ /*TODO: is this neccessary?*/
+ CGA_BackBufferToRealFull();
+
+ /* Create clean game state snapshot */
+ SaveRestartGame();
+
+ /* Install timer callback */
+ InitTimer();
+
+ /* Detect CPU speed for delay routines */
+ cpu_speed_delay = BenchmarkCpu() / 8;
+
+ /*restart game from here*/
+restart:;
+ Randomize();
+
+ /* Set start zone */
+ script_byte_vars.zone_index = 7;
+
+ /* Begin the game */
+ script_byte_vars.game_paused = 0;
+
+#ifdef DEBUG_SCRIPT
+ {
+ FILE *f = fopen(DEBUG_SCRIPT_LOG, "wt+");
+ if(f)
+ {
+ fclose(f);
+ }
+ }
+#endif
+
+#if 1
+ /* Play introduction sequence */
+ the_command = 0xC001;
+ RunCommand();
+#endif
+
+ /* Sync graphics */
+ BlitSpritesToBackBuffer();
+
+ /* Initialize cursor backup */
+ ProcessInput();
+
+ /* Main game loop */
+ GameLoop(frontbuffer);
+
+ /*TODO: the following code is never executed since GameLoop is infinite (or the whole game is restarted) */
+
+ /* Release hardware */
+ UninitInput();
+ UninitTimer();
+
+ ExitGame();
+}
diff --git a/engines/chamber/kult.lnk b/engines/chamber/kult.lnk
new file mode 100644
index 00000000000..f3394840dae
--- /dev/null
+++ b/engines/chamber/kult.lnk
@@ -0,0 +1,17 @@
+resdata.obj+
+cga.obj+
+anim.obj+
+decompr.obj+
+cursor.obj+
+input.obj+
+room.obj+
+invent.obj+
+print.obj+
+dialog.obj+
+portrait.obj+
+menu.obj+
+timer.obj+
+sound.obj+
+savegame.obj+
+kult.obj+
+script.obj
diff --git a/engines/chamber/makefile b/engines/chamber/makefile
new file mode 100644
index 00000000000..abfd35b16e5
--- /dev/null
+++ b/engines/chamber/makefile
@@ -0,0 +1,45 @@
+CC = tcc -mh -c -v -w
+LINK = tlink /c /x /v
+LIB = tlib
+OBJS = resdata.obj cga.obj anim.obj decompr.obj cursor.obj input.obj \
+ room.obj invent.obj print.obj dialog.obj portrait.obj menu.obj \
+ timer.obj sound.obj savegame.obj kult.obj script.obj
+
+kult.exe: alldata.lib $(OBJS)
+ $(LINK) $(CLIB)\c0h @kult.lnk,$*,,alldata $(CLIB)\ch
+
+alldata.lib: r_puzzl.obj r_sprit.obj r_templ.obj r_texts.obj bkbuff.obj r_pers.obj
+ $(LIB) alldata.lib /c +-r_puzzl +-r_sprit +-bkbuff +-r_texts +-r_pers +-r_templ
+
+r_puzzl.obj: r_puzzl.c resdata.h
+r_sprit.obj: r_sprit.c resdata.h
+r_texts.obj: r_texts.c resdata.h
+r_pers.obj: r_pers.c resdata.h
+r_templ.obj: r_templ.c resdata.h
+bkbuff.obj: bkbuff.c
+
+kult.obj: kult.c common.h cga.h decompr.h script.h resdata.h
+resdata.obj: resdata.c common.h resdata.h
+cga.obj: cga.c common.h cga.h
+anim.obj: anim.c common.h anim.h
+decompr.obj: decompr.c common.h
+cursor.obj: cursor.c common.h cursor.h cga.h resdata.h
+input.obj: input.c common.h input.h
+print.obj: print.c common.h print.h cga.h
+dialog.obj: dialog.c common.h dialog.h cga.h
+portrait.obj: portrait.c common.h portrait.h cga.h
+room.obj: room.c common.h room.h cga.h
+invent.obj: invent.c common.h invent.h cga.h script.h
+menu.obj: menu.c common.h cga.h script.h input.h
+sound.obj: sound.c common.h sound.h
+timer.obj: timer.c common.h timer.h cga.h
+script.obj: script.c common.h script.h cga.h resdata.h
+savegame.obj: savegame.c common.h savegame.h script.h
+
+.c.obj:
+ $(CC) $<
+
+clean:
+ -del *.exe
+ -del *.obj
+ -del *.lib
diff --git a/engines/chamber/menu.c b/engines/chamber/menu.c
new file mode 100644
index 00000000000..2455864cb9a
--- /dev/null
+++ b/engines/chamber/menu.c
@@ -0,0 +1,260 @@
+#include "common.h"
+#include "menu.h"
+#include "cga.h"
+#include "input.h"
+#include "cursor.h"
+#include "room.h"
+#include "sound.h"
+#include "script.h"
+
+unsigned char act_menu_x = 0;
+unsigned char act_menu_y = 0;
+
+rect_t *act_dot_rects_cur;
+rect_t *act_dot_rects_end;
+
+/*choice dots placement on actions menu*/
+rect_t act_dot_rects[8 + 1];
+struct {
+unsigned char x, y;
+} act_dot_coords[8] = {
+ { 2, 0},
+ { 8, 32},
+ { 2, 32},
+ {10, 8},
+ { 0, 24},
+ { 8, 0},
+ { 0, 8},
+ {10, 24}
+};
+
+unsigned char act_menu_x;
+unsigned char act_menu_y;
+
+/*Handle keyboard keys in actions menu (to cycle through choices with directional keys)*/
+unsigned char PollKeyboardInActionsMenu(void)
+{
+ if(!key_direction)
+ {
+ key_held = 0;
+ return key_code;
+ }
+
+ if(key_held)
+ return key_code;
+
+ key_held = 1;
+
+ /*cycle through menu choices*/
+
+ cursor_x = act_dot_rects_cur->sx * 4 + 1;
+ cursor_y = act_dot_rects_cur->sy + 4;
+
+ if(++act_dot_rects_cur == act_dot_rects_end)
+ act_dot_rects_cur = act_dot_rects;
+
+ return key_code;
+}
+
+/*Handle player input in actions menu*/
+void PollInputInActionsMenu(void)
+{
+ unsigned char keys;
+ if(have_mouse)
+ keys = PollMouse();
+ else
+ keys = PollKeyboardInActionsMenu();
+ SetInputButtons(keys);
+}
+
+/*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;
+
+ last_object_hint = object_hint;
+
+ if(act_menu_x == 0xFF)
+ {
+ /*recalc menu pos*/
+ x = cursor_x / 4;
+ if((int)(x + 48/4) >= 296/4)
+ x -= x + 48/4 - 296/4;
+ if(x < 32/4)
+ x = 32/4;
+ act_menu_x = x;
+
+ y = cursor_y;
+ if((int)(y + 45) >= 180)
+ y -= y + 45 - 180;
+ act_menu_y = y;
+ }
+
+ x = act_menu_x;
+ y = act_menu_y;
+
+ /*menu sprite*/
+ BackupAndShowSprite(0, x, y);
+ PlaySound(18);
+
+ choices = *((*pinfo)++);
+ menurecs = *pinfo;
+
+ numchoices = 0;
+ for(i = 0;i < 8;i++)
+ {
+ if(choices & (1 << i))
+ {
+ act_dot_rects[numchoices].sx = x + act_dot_coords[i].x;
+ act_dot_rects[numchoices].ex = act_dot_rects[numchoices].sx + 8/4;
+ act_dot_rects[numchoices].sy = y + act_dot_coords[i].y;
+ act_dot_rects[numchoices].ey = act_dot_rects[numchoices].sy + 8;
+ numchoices++;
+ }
+ }
+ act_dot_rects[numchoices].sx = x + 24/4;
+ act_dot_rects[numchoices].sy = y + 22;
+ /*TODO: no ex/ey?*/
+ act_dot_rects_end = act_dot_rects + numchoices + 1;
+
+ for(i = 0;i < numchoices;i++)
+ DrawSpriteN(1, act_dot_rects[i].sx, act_dot_rects[i].sy, CGA_SCREENBUFFER);
+
+ SelectCursor(CURSOR_0);
+ ProcessInput();
+
+ choice = 0;
+ act_dot_rects_cur = act_dot_rects;
+ do
+ {
+ PollInputInActionsMenu();
+
+ for(choice = 0;choice < numchoices;choice++)
+ {
+ if(IsCursorInRect(&act_dot_rects[choice]))
+ break;
+ }
+ if(choice < numchoices)
+ {
+ cursor_color = 0xAA;
+ command_hint = menurecs[choice * 3];
+ the_command = (menurecs[choice * 3 + 1] << 8) | menurecs[choice * 3 + 2];
+ }
+ else
+ {
+ cursor_color = 0xFF;
+ command_hint = 100;
+ the_command = 0xFFFF;
+ }
+
+ if(command_hint != last_command_hint)
+ DrawCommandHint(); /*to backbuffer*/
+ DrawHintsAndCursor(CGA_SCREENBUFFER);
+ }
+ while(buttons == 0);
+ UndrawCursor(CGA_SCREENBUFFER);
+
+ if(the_command != 0xFFFF)
+ {
+ PlaySound(19);
+ WaitVBlank();
+
+ /*draw dot explosion animation*/
+ DrawSpriteN(24, act_dot_rects[choice].sx, act_dot_rects[choice].sy, CGA_SCREENBUFFER);
+ for(i = 0;i < 0xFFF;i++) ; /*TODO: weak delay*/
+ DrawSpriteN(2, act_dot_rects[choice].sx, act_dot_rects[choice].sy, CGA_SCREENBUFFER);
+ for(i = 0;i < 0xFFF;i++) ; /*TODO: weak delay*/
+ DrawSpriteN(25, act_dot_rects[choice].sx, act_dot_rects[choice].sy, CGA_SCREENBUFFER);
+ for(i = 0;i < 0xFFF;i++) ; /*TODO: weak delay*/
+ }
+ CGA_RestoreBackupImage(CGA_SCREENBUFFER);
+
+ *pinfo += numchoices * 3;
+}
+
+/*TODO: maybe rename to SpotsLoop*/
+void MenuLoop(unsigned char spotmask, unsigned char spotvalue)
+{
+ ProcessInput();
+ do
+ {
+ PollInput();
+ CheckHotspots(spotmask, spotvalue);
+ if(object_hint != last_object_hint)
+ DrawObjectHint();
+ DrawHintsAndCursor(frontbuffer);
+ }
+ while(buttons == 0);
+ UndrawCursor(frontbuffer);
+}
+
+void ProcessMenu(void)
+{
+ SelectCursor(CURSOR_6);
+ MenuLoop(SPOTFLG_80 | SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8, SPOTFLG_80 | SPOTFLG_10);
+}
+
+
+rect_t menu_buttons_rects[] = {
+ {296 / 4, 312 / 4, 15, 30}, /*Room's Objects*/
+ {296 / 4, 312 / 4, 40, 56}, /*Psi Powers*/
+ {296 / 4, 312 / 4, 56, 72}, /*Posessions*/
+ {296 / 4, 312 / 4, 72, 88}, /*Energy Level*/
+ {296 / 4, 312 / 4, 88, 104}, /*Wait*/
+ {296 / 4, 312 / 4, 104, 120}, /*Load*/
+ {296 / 4, 312 / 4, 120, 136}, /*Save*/
+ {296 / 4, 312 / 4, 136, 152} /*Time*/
+};
+
+void CheckMenuCommandHover(void)
+{
+ int i;
+ for(i = 0;i < 8;i++)
+ {
+ if(IsCursorInRect(&menu_buttons_rects[i]))
+ {
+ the_command = 0xA001 + i;
+ command_hint = i ? (i + 3) : 101;
+ cursor_color = 0xAA;
+ return;
+ }
+ }
+ /*nothing found*/
+ command_hint = 100;
+ cursor_color = 0xFF;
+ the_command = 0;
+}
+
+rect_t psi_buttons_rects[] = {
+ {280 / 4, 296 / 4, 40, 56}, /*Solar Eyes*/
+ {280 / 4, 296 / 4, 56, 72}, /*Sticky Fingers*/
+ {280 / 4, 296 / 4, 72, 88}, /*Know Mind*/
+ {280 / 4, 296 / 4, 88, 104}, /*Brainwarp*/
+ {280 / 4, 296 / 4, 104, 120}, /*Zone Scan*/
+ {280 / 4, 296 / 4, 120, 136}, /*Psi Shift*/
+ {280 / 4, 296 / 4, 136, 152}, /*Extreme Violence*/
+ {280 / 4, 296 / 4, 152, 168} /*Tune In*/
+};
+
+void CheckPsiCommandHover(void)
+{
+/*TODO: maybe merge it with CheckMenuCommandHover()*/
+ int i;
+ for(i = 0;i < 8;i++)
+ {
+ if(IsCursorInRect(&psi_buttons_rects[i]))
+ {
+ the_command = 0xA00A + i;
+ command_hint = i + 12;
+ cursor_color = 0xAA;
+ return;
+ }
+ }
+ /*nothing found*/
+ command_hint = 100;
+ cursor_color = 0xFF;
+ the_command = 0;
+}
diff --git a/engines/chamber/menu.h b/engines/chamber/menu.h
new file mode 100644
index 00000000000..d2978775119
--- /dev/null
+++ b/engines/chamber/menu.h
@@ -0,0 +1,14 @@
+#ifndef _MENU_H_
+#define _MENU_H_
+
+extern unsigned char act_menu_x;
+extern unsigned char act_menu_y;
+
+void ActionsMenu(unsigned char **pinfo);
+void MenuLoop(unsigned char spotmask, unsigned char spotvalue);
+void ProcessMenu(void);
+
+void CheckMenuCommandHover(void);
+void CheckPsiCommandHover(void);
+
+#endif
diff --git a/engines/chamber/portrait.c b/engines/chamber/portrait.c
new file mode 100644
index 00000000000..177493d2aae
--- /dev/null
+++ b/engines/chamber/portrait.c
@@ -0,0 +1,355 @@
+#include <mem.h>
+#include <stdio.h>
+#include "common.h"
+#include "portrait.h"
+#include "resdata.h"
+#include "room.h"
+#include "cga.h"
+#include "script.h"
+#include "dialog.h"
+#include "input.h"
+#include "sound.h"
+
+extern unsigned short 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;
+
+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;
+} persframe_t;
+
+persframe_t pers_frames[] = {
+ {65, 16, 0xFF, 0xAA, 0xEA, 0xAB},
+ {70, 16, 0xFF, 0xAA, 0xEA, 0xAB},
+ {65, 17, 0xFF, 0xAA, 0xEA, 0xAB},
+ {75, 17, 0xFF, 0xAA, 0xEA, 0xAB},
+ {85, 16, 0xFF, 0xAA, 0xEA, 0xAB},
+ {47, 13, 0xFF, 0, 0xC0, 3},
+ {65, 18, 0xFF, 0xAA, 0xEA, 0xAB},
+ {38, 11, 0xFF, 0, 0xC0, 3},
+ {27, 34, 0, 0, 0, 0}
+};
+
+void MakePortraitFrame(unsigned char index, unsigned char *target)
+{
+ unsigned int i;
+ persframe_t *pframe = &pers_frames[index];
+ *target++ = pframe->height;
+ *target++ = pframe->width;
+ cur_frame_width = pframe->width;
+ memset(target, pframe->topbot, pframe->width); target += pframe->width;
+ for(i = 0;i < pframe->height - 2;i++)
+ {
+ *target++ = pframe->left;
+ memset(target, pframe->fill, pframe->width - 2); target += pframe->width - 2;
+ *target++ = pframe->right;
+ }
+ memset(target, pframe->topbot, pframe->width);
+}
+
+/*TODO: move this to CGA ?*/
+/*
+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;
+ while(h--)
+ {
+ for(x = 0;x < w;x++)
+ {
+ unsigned char m = *source++;
+ *target &= m;
+ *target++ |= *source++;
+ }
+ target -= w;
+ target += pitch;
+ }
+}
+
+/*
+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;
+ target += w - 1;
+ while(h--)
+ {
+ for(x = 0;x < w;x++)
+ {
+ unsigned char m = cga_pixel_flip[*source++];
+ *target &= m;
+ *target |= cga_pixel_flip[*source++];
+ target -= 1;
+ }
+ target += w;
+ target += pitch;
+ }
+}
+
+/*
+Build portrait from multiple pers sprites
+*/
+unsigned char *LoadPortrait(unsigned char **pinfo, unsigned char *end)
+{
+ while(*pinfo != end)
+ {
+ unsigned char index;
+ unsigned int flags;
+ signed int pitch;
+ unsigned char *buffer, *sprite;
+ unsigned char sprw, sprh;
+
+ index = *((*pinfo)++);
+ flags = *((*pinfo)++);
+ flags |= (*((*pinfo)++)) << 8;
+ buffer = sprit_load_buffer + 2 + 2 + (flags & 0x3FFF);
+ pitch = cur_frame_width;
+
+ sprite = LoadPersSprit(index);
+ sprw = *sprite++;
+ sprh = *sprite++;
+
+ if(flags & 0x8000) /*vertical flip*/
+ {
+ buffer += pitch * (sprh - 1);
+ pitch = -pitch;
+ }
+ if(flags & 0x4000) /*horizontal flip*/
+ MergeImageAndSpriteDataFlip(buffer, pitch, sprite, sprw, sprh);
+ else
+ MergeImageAndSpriteData(buffer, pitch, sprite, sprw, sprh);
+ }
+ return sprit_load_buffer + 2;
+}
+
+unsigned char *LoadPortraitWithFrame(unsigned char index)
+{
+ unsigned char *pinfo, *end;
+ pinfo = SeekToEntry(icone_data, index, &end);
+ MakePortraitFrame(*pinfo++, sprit_load_buffer + 2);
+ return LoadPortrait(&pinfo, end);
+}
+
+
+#define STATIC_ANIMS_MAX 24
+
+struct {
+unsigned char index;
+unsigned char image;
+unsigned char x;
+unsigned char y;
+unsigned char anim1;
+unsigned char anim2;
+} static_anims[] = {
+ { 24, 13, 35, 10, 4, 5},
+ { 88, 42, 35, 10, 11, 12},
+ {152, 50, 35, 10, 13, 14},
+ {216, 58, 35, 10, 15, 16},
+ { 40, 9, 30, 20, 3, 3},
+ { 48, 1, 35, 20, 1, 2},
+ { 32, 66, 35, 20, 17, 18},
+ {128, 21, 20, 10, 6, 6},
+ {192, 25, 2, 70, 7, 7},
+ { 56, 85, 25, 20, 26, 27},
+ { 64, 74, 56, 85, 23, 23},
+ { 72, 74, 56, 85, 23, 23},
+ { 80, 78, 27, 20, 24, 24},
+ {144, 80, 27, 20, 25, 25},
+ { 96, 100, 27, 20, 29, 29},
+ {104, 92, 27, 20, 28, 28},
+ {112, 100, 27, 20, 29, 53},
+ {224, 96, 27, 20, 48, 48},
+ {232, 92, 27, 20, 47, 47},
+ {184, 160, 27, 20, 50, 52},
+ {200, 78, 27, 20, 24, 24},
+ {160, 106, 33, 2, 49, 49},
+ {168, 147, 16, 2, 32, 32},
+ {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;
+ for(i = 0;i < STATIC_ANIMS_MAX;i++)
+ {
+ if(static_anims[i].index == aniidx)
+ {
+ *x = static_anims[i].x;
+ *y = static_anims[i].y;
+ *index = static_anims[i].image;
+ cur_image_anim1 = static_anims[i].anim1;
+ cur_image_anim2 = static_anims[i].anim2;
+ return 1;
+ }
+ }
+printf("SelectCurrentAnim: not found for %d\n", aniidx);
+ return 0;
+}
+
+void DrawBoxAroundSpot(void)
+{
+ unsigned char *buffer;
+ unsigned int w, h;
+ unsigned int ofs;
+ unsigned int x, y;
+
+ if(*spot_sprite == 0)
+ return;
+ zone_spots_cur = found_spot;
+ zone_spr_index = script_byte_vars.cur_spot_idx - 1;
+
+ buffer = *spot_sprite;
+
+ h = *(unsigned char*)(buffer + 0);
+ w = *(unsigned char*)(buffer + 1);
+ ofs = *(unsigned int*)(buffer + 2);
+
+ /*decode ofs back to x:y*/
+ /*TODO: this is CGA-only!*/
+ y = (ofs & CGA_ODD_LINES_OFS) ? 1 : 0;
+ ofs &= ~CGA_ODD_LINES_OFS;
+ x = (ofs % CGA_BYTES_PER_LINE) * CGA_PIXELS_PER_BYTE;
+ y += (ofs / CGA_BYTES_PER_LINE) * 2;
+ w *= CGA_PIXELS_PER_BYTE; /*TODO: this will overflow on large sprite*/
+
+ CGA_DrawVLine(x, y, h - 1, 0, CGA_SCREENBUFFER);
+ CGA_DrawHLine(x, y, w - 1, 0, CGA_SCREENBUFFER);
+ CGA_DrawVLine(x + w - 1, y, h - 1, 0, CGA_SCREENBUFFER);
+ CGA_DrawHLine(x, y + h - 1, w - 1, 0, CGA_SCREENBUFFER);
+
+ CGA_RefreshImageData(*spot_sprite);
+}
+
+/*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;
+
+ index = *((*desc)++);
+ if(index == 0xFF)
+ {
+ if(script_byte_vars.dirty_rect_kind != 0)
+ return 0;
+ DrawBoxAroundSpot();
+ if(!SelectCurrentAnim(&xx, &yy, &index))
+ return 0;
+ }
+ else
+ {
+ xx = *((*desc)++);
+ yy = *((*desc)++);
+ }
+ cur_image_coords_x = xx;
+ cur_image_coords_y = yy;
+ cur_image_idx = index;
+
+ image = LoadPortraitWithFrame(index - 1);
+ cur_image_size_h = *image++;
+ cur_image_size_w = *image++;
+ cur_image_pixels = image;
+ cur_image_offs = CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y);
+ AddDirtyRect(DirtyRectSprite, cur_image_coords_x, cur_image_coords_y, cur_image_size_w, cur_image_size_h, cur_image_offs);
+
+ /*TODO: remove and use only globals?*/
+ *x = cur_image_coords_x;
+ *y = cur_image_coords_y;
+ *width = cur_image_size_w;
+ *height = cur_image_size_h;
+
+ if(right_button)
+ {
+ CGA_BlitAndWait(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
+ return 0;
+ }
+
+ return 1;
+}
+
+void BlinkWithSound(unsigned char color)
+{
+ CGA_ColorSelect(color);
+ PlaySound(144);
+ SelectPalette();
+}
+
+void BlinkToRed(void)
+{
+ BlinkWithSound(0x3C);
+}
+
+void BlinkToWhite(void)
+{
+ BlinkWithSound(0x3F);
+}
+
+void AnimPortrait(unsigned char layer, unsigned char index, unsigned char delay)
+{
+ unsigned char *ani, *ani_end;
+ unsigned char temp;
+
+ SelectCurrentAnim(&temp, &temp, &temp);
+
+ if(index == 0xFF)
+ index = cur_image_anim1;
+ if(index == 0xFE)
+ index = cur_image_anim2;
+
+ ani = SeekToEntry(anico_data, index - 1, &ani_end);
+ 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;
+
+ unsigned char portrait = *ani++;
+ LoadPortraitWithFrame(portrait - 1);
+ if(*ani == 0xFF)
+ {
+ ani++;
+ LoadPortrait(&ani, ani + 3);
+ }
+ GetDirtyRectAndSetSprite(layer, &kind, &x, &y, &width, &height, &offs);
+ WaitVBlank();
+ CGA_BlitAndWait(cur_image_pixels, width, width, height, CGA_SCREENBUFFER, offs);
+ if(delay)
+ {
+ if(ani[-1] == 37) /*TODO: what is it?*/
+ {
+ if(script_byte_vars.byte_179F3)
+ BlinkToRed();
+ else
+ BlinkToWhite();
+ }
+ else
+ {
+ int 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
new file mode 100644
index 00000000000..867e9417377
--- /dev/null
+++ b/engines/chamber/portrait.h
@@ -0,0 +1,28 @@
+#ifndef _PORTRAIT_H_
+#define _PORTRAIT_H_
+
+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;
+
+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);
+
+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 BlinkToRed(void);
+void BlinkToWhite(void);
+
+
+#endif
diff --git a/engines/chamber/print.c b/engines/chamber/print.c
new file mode 100644
index 00000000000..9de41494a43
--- /dev/null
+++ b/engines/chamber/print.c
@@ -0,0 +1,292 @@
+#include "common.h"
+#include "cga.h"
+#include "cursor.h"
+#include "dialog.h"
+
+unsigned char *cur_str_end;
+
+unsigned char draw_x;
+unsigned char 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;
+
+ if((*str & 0x3F) == 0)
+ {
+ str++;
+ ww++;
+ }
+
+ while(str != cur_str_end)
+ {
+ if((*str & 0x3F) == 0)
+ break;
+ ww++;
+ c = *str & 0xC0;
+ if(c != 0)
+ {
+ if(c == 0x40) /*space?*/
+ {
+ str++;
+ break;
+ }
+ ww++;
+ }
+ str++;
+ }
+
+ *w = ww;
+ return str;
+}
+
+/*
+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;
+ do
+ {
+ s = CalcStringWordWidth(s, &lw);
+ if(lw > ww)
+ ww = lw;
+ nw += 1;
+ }
+ while(s != cur_str_end);
+ *w = ww;
+ *n = nw;
+}
+
+/*
+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;
+ while(str != cur_str_end)
+ {
+ str = CalcStringWordWidth(str, &w);
+ if(left > w)
+ {
+ left = left - w - 1;
+ }
+ else
+ {
+ lines++;
+ left = char_draw_max_width - w - 1;
+ }
+ }
+ return lines;
+}
+
+/*; 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*/
+
+void PrintStringPad(unsigned int w, unsigned char *target)
+{
+ while(w--)
+ CGA_PrintChar(0, target);
+}
+
+unsigned char * PrintWord(unsigned char *str, unsigned char *target)
+{
+ unsigned char c, f;
+ if((*str & 0x3F) == 0)
+ goto skip_1st;
+ while(str != cur_str_end)
+ {
+ f = *str;
+ c = f & 0x3F;
+ if(c == 0)
+ {
+ if((f & 0xC0) == 0)
+ str++;
+ return str;
+ }
+ CGA_PrintChar(c, target);
+
+skip_1st:;
+ f = *str & 0xC0;
+ str++;
+ if(f)
+ {
+ if(f == 0x80)
+ CGA_PrintChar(0x25, target);
+ else if(f != 0x40)
+ CGA_PrintChar(0x21, target);
+ else
+ return str;
+ }
+ }
+ string_ended = 1;
+ return str;
+}
+
+unsigned char * PrintStringLine(unsigned char *str, unsigned int *left, unsigned char *target)
+{
+ unsigned int mw = char_draw_max_width;
+ for(;;)
+ {
+ unsigned int w;
+ CalcStringWordWidth(str, &w);
+ if(mw < w)
+ break;
+ mw -= w;
+ str = PrintWord(str, target);
+ if(string_ended || (mw == 0))
+ break;
+ mw--;
+ CGA_PrintChar(0, target);
+ }
+ *left = mw;
+ return str;
+}
+
+unsigned char * PrintStringPadded(unsigned char *str, unsigned char *target)
+{
+ unsigned int w, n;
+ CalcStringSize(str, &w, &n);
+ if(w + 2 >= char_draw_max_width)
+ char_draw_max_width = w + 2;
+ str = PrintStringLine(str, &w, target);
+ if(w != 0)
+ PrintStringPad(w, target);
+ return str;
+}
+
+void PrintStringCentered(unsigned char *str, unsigned char *target)
+{
+ unsigned char pad = 0;
+ unsigned int ww = 0, lw;
+ unsigned char *s = str;
+ do
+ {
+ s = CalcStringWordWidth(s, &lw);
+ ww += lw;
+ }
+ while(s != cur_str_end);
+
+ pad = (char_draw_max_width - ww) / 2;
+ if(pad)
+ {
+ char_draw_max_width -= pad;
+ PrintStringPad(pad, target);
+ }
+ string_ended = 0; /*TODO: move me elsewhere*/
+ PrintStringPadded(str, target);
+}
+
+void CGA_DrawTextBox(unsigned char *msg, unsigned char *target)
+{
+ unsigned int x, y, w, i;
+
+ char_xlat_table = chars_color_bonc;
+
+ x = draw_x * 4;
+ y = draw_y;
+ w = (char_draw_max_width + 2) * 4 - 2;
+
+ CGA_DrawHLine(x + 2, y, w - 2, 0, target); /*box top*/
+ for(i = 0;i < 3;i++)
+ CGA_DrawHLine(x + 1, y + 1 + i, w, 1, target); /*top margin*/
+ CGA_DrawVLine(x, y + 2, 2, 0, target); /*left top corner 1*/
+ CGA_DrawVLine(x + 1, y + 1, 1, 0, target); /*left top corner 2*/
+ CGA_DrawVLine(x + w, y + 1, 1, 0, target); /*right top corner 1*/
+ CGA_DrawVLine(x + w + 1, y + 2, 2, 0, target); /*right top corner 2*/
+
+ char_draw_coords_y = draw_y + 4;
+ string_ended = 0;
+ do
+ {
+ char_draw_coords_x = draw_x;
+ CGA_PrintChar(0x3B, target);
+ msg = PrintStringPadded(msg, target);
+ CGA_PrintChar(0x3C, target);
+ char_draw_coords_y += 6;
+ }
+ while(!string_ended);
+
+ x = draw_x * 4;
+ y = char_draw_coords_y;
+ CGA_DrawHLine(x + 1, y, w, 1, target); /*bottom margin*/
+ CGA_DrawVLine(x + 1, y, 1, 0, target); /*bottom left corner 1*/
+ CGA_DrawHLine(x + 2, y + 1, w - 2, 0, target); /*box bottom*/
+ CGA_DrawVLine(x + 1, y, 1, 0, target); /*TODO: duplicated?*/
+ 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;
+ CalcStringSize(msg, &w, &h);
+ char_draw_max_width = (h < 5) ? (w + 2) : 20;
+ char_draw_max_height = CalcTextLines(msg) * 6 + 7;
+
+ x = cursor_x / 4;
+ if(x < 9)
+ x = 9;
+ if(x + char_draw_max_width + 2 >= 73)
+ x = 73 - (char_draw_max_width + 2);
+
+ y = cursor_y;
+ if(y + char_draw_max_height >= 200)
+ y = 200 - char_draw_max_height;
+
+ draw_x = x;
+ draw_y = y;
+
+ CGA_BackupImageReal(CGA_CalcXY_p(x, y), char_draw_max_width + 2, char_draw_max_height); /*backup orig. screen data*/
+ CGA_DrawTextBox(msg, target); /*draw box with text*/
+ PromptWait(); /*wait keypress*/
+ CGA_RestoreBackupImage(target); /*restore screen data*/
+}
+
+#if 1
+#include <stdio.h>
+void DebugMessage(char *msg, ...)
+{
+ int i;
+ unsigned char c;
+ unsigned char m[256];
+ va_list ap;
+
+ va_start(ap,msg);
+ vsprintf((char*)m,msg,ap);
+ va_end(ap);
+
+ for(i = 0;m[i];i++)
+ {
+ c = m[i];
+ if(c >= 'A' && c <= 'Z')
+ c = 0x21 + (c - 'A');
+ else if(c >= 'a' && c <= 'z')
+ c = 0x21 + (c - 'a');
+ else if(c >= '0' && c <= '9')
+ c = 0x10 + (c - '0');
+ else if(c == ' ')
+ c = 0x20;
+ else if(c == '\n')
+ c = 0x00;
+ else
+ c = 0x1F;
+ m[i] = c;
+ }
+
+ cur_str_end = m + i;
+
+ DrawMessage(m, frontbuffer);
+}
+#endif
diff --git a/engines/chamber/print.h b/engines/chamber/print.h
new file mode 100644
index 00000000000..d302cc68669
--- /dev/null
+++ b/engines/chamber/print.h
@@ -0,0 +1,21 @@
+#ifndef _PRINT_H_
+#define _PRINT_H_
+
+extern unsigned char *cur_str_end;
+
+extern unsigned char draw_x;
+extern unsigned char 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[];
+
+void PrintStringCentered(unsigned char *str, unsigned char *target);
+unsigned char * PrintStringPadded(unsigned char *str, unsigned char *target);
+
+void DrawMessage(unsigned char *msg, unsigned char *target);
+
+void CGA_DrawTextBox(unsigned char *msg, unsigned char *target);
+
+#endif
diff --git a/engines/chamber/r_other.c b/engines/chamber/r_other.c
new file mode 100644
index 00000000000..e50ee56f91e
--- /dev/null
+++ b/engines/chamber/r_other.c
@@ -0,0 +1,13 @@
+#include "resdata.h"
+
+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];
diff --git a/engines/chamber/r_pers.c b/engines/chamber/r_pers.c
new file mode 100644
index 00000000000..c57d84f0a99
--- /dev/null
+++ b/engines/chamber/r_pers.c
@@ -0,0 +1,7 @@
+#include "resdata.h"
+
+unsigned char pers1_data[RES_PERS1_MAX];
+unsigned char pers2_data[RES_PERS2_MAX];
+
+unsigned char desci_data[RES_DESCI_MAX];
+unsigned char diali_data[RES_DIALI_MAX];
diff --git a/engines/chamber/r_puzzl.c b/engines/chamber/r_puzzl.c
new file mode 100644
index 00000000000..0452492d9ea
--- /dev/null
+++ b/engines/chamber/r_puzzl.c
@@ -0,0 +1,3 @@
+#include "resdata.h"
+
+unsigned char puzzl_data[RES_PUZZL_MAX];
diff --git a/engines/chamber/r_sprit.c b/engines/chamber/r_sprit.c
new file mode 100644
index 00000000000..6341e0b8ebd
--- /dev/null
+++ b/engines/chamber/r_sprit.c
@@ -0,0 +1,3 @@
+#include "resdata.h"
+
+unsigned char sprit_data[RES_SPRIT_MAX];
diff --git a/engines/chamber/r_templ.c b/engines/chamber/r_templ.c
new file mode 100644
index 00000000000..cb6831b6d91
--- /dev/null
+++ b/engines/chamber/r_templ.c
@@ -0,0 +1,3 @@
+#include "resdata.h"
+
+unsigned char templ_data[RES_TEMPL_MAX];
diff --git a/engines/chamber/r_texts.c b/engines/chamber/r_texts.c
new file mode 100644
index 00000000000..86f71b54391
--- /dev/null
+++ b/engines/chamber/r_texts.c
@@ -0,0 +1,4 @@
+#include "resdata.h"
+
+unsigned char vepci_data[RES_VEPCI_MAX];
+unsigned char motsi_data[RES_MOTSI_MAX];
diff --git a/engines/chamber/resdata.c b/engines/chamber/resdata.c
new file mode 100644
index 00000000000..0a4c61a27d9
--- /dev/null
+++ b/engines/chamber/resdata.c
@@ -0,0 +1,189 @@
+#include <io.h>
+#include <fcntl.h>
+#include "common.h"
+#include "resdata.h"
+#include "decompr.h"
+
+/*
+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;
+
+ while(num--)
+ {
+ len = *p;
+ p += len;
+ }
+ len = *p;
+ *end = p + len;
+ return p + 1;
+}
+
+unsigned char * SeekToEntryW(unsigned char *bank, unsigned int num, unsigned char **end)
+{
+ unsigned int len;
+ unsigned char *p = bank;
+
+ while(num--)
+ {
+ len = p[0] | (p[1] << 8);
+ p += len;
+ }
+ len = p[0] | (p[1] << 8);
+ *end = p + len;
+ return p + 2;
+}
+
+unsigned int LoadFile(char *filename, unsigned char *buffer)
+{
+ int f;
+ int rlen;
+ f = open(filename, O_RDONLY | O_BINARY);
+ if(f == -1)
+ return 0;
+ rlen = read(f, buffer, 0xFFF0);
+ close(f);
+ if(rlen == -1)
+ return 0;
+ return (unsigned int)rlen;
+}
+
+unsigned int SaveFile(char *filename, unsigned char *buffer, unsigned int size)
+{
+ int f;
+ int wlen;
+ f = open(filename, O_RDONLY | O_BINARY);
+ if(f == -1)
+ return 0;
+ wlen = write(f, buffer, size);
+ close(f);
+ if(wlen == -1)
+ return 0;
+ return (unsigned int)wlen;
+}
+
+int LoadFilesList(ResEntry_t *entries)
+{
+ int i;
+ for(i = 0;entries[i].name[0] != '$';i++)
+ {
+ if(!LoadFile(entries[i].name, entries[i].buffer))
+ return 0;
+ }
+ return 1;
+}
+
+
+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];
+
+ResEntry_t res_static[] = {
+ {"ARPLA.BIN", arpla_data},
+ {"ALEAT.BIN", aleat_data},
+ {"ICONE.BIN", icone_data},
+ {"SOUCO.BIN", souco_data},
+ {"CARPC.BIN", carpc_data},
+ {"SOURI.BIN", souri_data},
+ {"TEMPL.BIN", templ_data},
+ {"MURSM.BIN", mursm_data},
+ {"GAUSS.BIN", gauss_data},
+ {"LUTIN.BIN", lutin_data},
+ {"ANIMA.BIN", anima_data},
+ {"ANICO.BIN", anico_data},
+ {"ZONES.BIN", zones_data},
+ {"$"}
+};
+
+/*
+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()
+{
+ return LoadFilesList(res_static);
+}
+
+ResEntry_t res_texts[] = {
+ {"VEPCI.BIN", vepci_data},
+ {"MOTSI.BIN", motsi_data},
+ {"$"}
+};
+
+/*
+Load strings data (commands/names)
+*/
+int LoadVepciData()
+{
+ return LoadFilesList(res_texts);
+}
+
+int LoadFond(void)
+{
+ return LoadSplash("FOND.BIN");
+}
+
+ResEntry_t res_sprites[] = {
+ {"PUZZL.BIN", puzzl_data},
+ {"SPRIT.BIN", sprit_data},
+ {"$"}
+};
+
+int LoadSpritesData(void)
+{
+ return LoadFilesList(res_sprites);
+}
+
+ResEntry_t res_person[] = {
+ {"PERS1.BIN", pers1_data},
+ {"PERS2.BIN", pers2_data},
+ {"$"}
+};
+
+int 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()*/
+ return LoadFilesList(res_person);
+}
+
+ResEntry_t res_desci[] = {
+ {"DESCI.BIN", desci_data},
+ {"$"}
+};
+
+/*
+Load strings data (obj. descriptions)
+*/
+int LoadDesciData(void)
+{
+ while(!LoadFilesList(res_desci))
+ AskDisk2();
+}
+
+ResEntry_t res_diali[] = {
+ {"DIALI.BIN", diali_data},
+ {"$"}
+};
+
+/*
+Load strings data (dialogs)
+*/
+int LoadDialiData(void)
+{
+ while(!LoadFilesList(res_diali))
+ AskDisk2();
+}
diff --git a/engines/chamber/resdata.h b/engines/chamber/resdata.h
new file mode 100644
index 00000000000..943a58ef58d
--- /dev/null
+++ b/engines/chamber/resdata.h
@@ -0,0 +1,79 @@
+#ifndef _RESDATA_H_
+#define _RESDATA_H_
+
+typedef struct ResEntry_t {
+char name[5 + 1 + 3 + 1];
+void *buffer;
+} ResEntry_t;
+
+/* Max resource file size among all languages */
+#define RES_ALEAT_MAX 256
+#define RES_ANICO_MAX 667
+#define RES_ANIMA_MAX 2046
+#define RES_ARPLA_MAX 7910
+#define RES_CARPC_MAX 384
+#define RES_GAUSS_MAX 1449
+#define RES_ICONE_MAX 2756
+#define RES_LUTIN_MAX 2800
+#define RES_MURSM_MAX 76
+#define RES_SOUCO_MAX 10838
+#define RES_SOURI_MAX 1152
+#define RES_TEMPL_MAX 27300
+#define RES_ZONES_MAX 9014
+#define RES_PUZZL_MAX 45671
+#define RES_SPRIT_MAX 23811
+#define RES_PERS1_MAX 14294
+#define RES_PERS2_MAX 10489
+#define RES_DESCI_MAX 10491
+#define RES_DIALI_MAX 10070
+#define RES_MOTSI_MAX 1082
+#define RES_VEPCI_MAX 1548
+
+extern unsigned char vepci_data[];
+extern unsigned char motsi_data[];
+
+extern unsigned char puzzl_data[];
+extern unsigned char sprit_data[];
+
+extern unsigned char pers1_data[];
+extern unsigned char pers2_data[];
+
+extern unsigned char desci_data[];
+extern unsigned char 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[];
+
+unsigned char * SeekToEntry(unsigned char *bank, unsigned int num, unsigned char **end);
+unsigned char * SeekToEntryW(unsigned char *bank, unsigned int num, unsigned char **end);
+
+unsigned int LoadFile(char *filename, unsigned char *buffer);
+unsigned int SaveFile(char *filename, unsigned char *buffer, unsigned int size);
+int LoadFilesList(ResEntry_t *entries);
+
+int LoadStaticData(void);
+int LoadFond(void);
+int LoadSpritesData(void);
+int LoadPersData(void);
+
+extern ResEntry_t res_texts[];
+int LoadVepciData(void);
+
+extern ResEntry_t res_desci[];
+int LoadDesciData(void);
+
+extern ResEntry_t res_diali[];
+int LoadDialiData(void);
+
+#endif
diff --git a/engines/chamber/room.c b/engines/chamber/room.c
new file mode 100644
index 00000000000..0df883dcfa5
--- /dev/null
+++ b/engines/chamber/room.c
@@ -0,0 +1,1874 @@
+#include <string.h>
+#include "common.h"
+#include "room.h"
+#include "resdata.h"
+#include "cga.h"
+#include "print.h"
+#include "anim.h"
+#include "cursor.h"
+#include "script.h"
+#include "print.h"
+#include "input.h"
+#include "dialog.h"
+#include "portrait.h"
+#include "sound.h"
+
+unsigned char scratch_mem1[8010];
+unsigned char *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;
+
+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;
+
+unsigned char *sprites_list[MAX_SPRITES];
+
+spot_t *zone_spots;
+spot_t *zone_spots_end;
+spot_t *zone_spots_cur;
+
+vortanims_t *vortanims_ptr;
+rec7_t *rec7_ptr;
+pers_t *pers_ptr;
+spot_t *spot_ptr;
+spot_t *found_spot;
+unsigned char **spot_sprite;
+
+unsigned char zone_palette;
+
+unsigned char zone_spr_index;
+
+unsigned int zsprite_draw_ofs;
+unsigned char zsprite_w;
+unsigned char zsprite_h;
+
+unsigned char *lutin_mem;
+
+unsigned short inv_update_time = 0;
+
+unsigned char 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;
+
+unsigned char zone_drawn;
+
+#define RECD_MAX 25
+
+/*
+Vorts room enter/leave animations
+*/
+vortanims_t vortsanim_list[RECD_MAX] = {
+ { 2, { 3, 52, 113}, { 8, 43, 113}, {12, 43, 113}, {16, 43, 113}},
+ { 3, { 6, 58, 120}, { 7, 33, 120}, {11, 33, 120}, {15, 33, 120}},
+ { 4, { 2, 26, 121}, { 9, 43, 121}, {13, 43, 121}, {17, 43, 121}},
+ { 5, { 1, 32, 119}, {10, 33, 119}, {14, 33, 119}, {18, 33, 119}},
+ { 6, { 3, 36, 115}, { 8, 27, 115}, {12, 27, 115}, {16, 27, 115}},
+ { 7, { 1, 40, 123}, {10, 41, 123}, {14, 41, 123}, {18, 41, 123}},
+ { 8, {21, 64, 132}, { 9, 33, 132}, {13, 33, 132}, {17, 33, 132}},
+ {90, { 1, 27, 129}, {10, 28, 129}, {14, 28, 129}, {18, 28, 129}},
+ {91, { 3, 44, 129}, { 8, 35, 129}, {12, 35, 129}, {16, 35, 129}},
+ {10, {29, 22, 156}, {30, 22, 156}, {31, 22, 156}, {32, 22, 156}},
+ {11, {29, 22, 156}, {30, 22, 156}, {31, 22, 156}, {32, 22, 156}},
+ {12, {29, 22, 156}, {30, 22, 156}, {31, 22, 156}, {32, 22, 156}},
+ {13, {29, 22, 156}, {30, 22, 156}, {31, 22, 156}, {32, 22, 156}},
+ {18, {29, 22, 156}, {30, 22, 156}, {31, 22, 156}, {32, 22, 156}},
+ {35, {29, 20, 156}, {30, 20, 156}, {31, 20, 156}, {32, 20, 156}},
+ {42, {29, 18, 156}, {30, 18, 156}, {31, 18, 156}, {32, 18, 156}},
+ {51, {29, 57, 144}, {30, 57, 144}, {31, 57, 144}, {32, 57, 144}},
+ {53, {29, 48, 156}, {30, 48, 156}, {31, 48, 156}, {32, 48, 156}},
+ {54, {29, 55, 139}, {30, 55, 139}, {31, 55, 139}, {32, 55, 139}},
+ {56, {29, 47, 115}, {30, 47, 115}, {31, 47, 115}, {32, 47, 115}},
+ {57, {29, 38, 136}, {30, 38, 136}, {31, 38, 136}, {32, 38, 136}},
+ {58, {29, 28, 125}, {30, 28, 125}, {31, 28, 125}, {32, 28, 125}},
+ {59, {29, 45, 132}, {30, 45, 132}, {31, 45, 132}, {32, 45, 132}},
+ {60, {29, 21, 150}, {30, 21, 150}, {31, 21, 150}, {32, 21, 150}},
+ {61, {29, 23, 123}, {30, 23, 123}, {31, 23, 123}, {32, 23, 123}}
+};
+
+#define RECS7_MAX 10
+
+rec7_t recs7_list[RECS7_MAX] = {
+ {50, {61, 14, 140}, {62, 14, 140}},
+ {51, {61, 14, 143}, {62, 14, 143}},
+ {53, {61, 20, 153}, {62, 20, 153}},
+ {54, {61, 16, 139}, {62, 16, 139}},
+ {56, {61, 24, 118}, {62, 24, 118}},
+ {57, {61, 27, 129}, {62, 27, 129}},
+ {58, {61, 39, 125}, {62, 39, 125}},
+ {59, {61, 29, 130}, {62, 29, 130}},
+ {60, {61, 49, 150}, {62, 49, 150}},
+ {61, {61, 56, 141}, {62, 56, 141}}
+};
+
+static const unsigned char 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 SelectPalette(void)
+{
+ CGA_ColorSelect(cga_color_sels[script_byte_vars.palette_index]);
+}
+
+/*
+Blit sprites to backbuffer
+*/
+void BlitSpritesToBackBuffer(void)
+{
+ int i;
+ for(i = 0;i < MAX_SPRITES;i++)
+ {
+ unsigned char *sprite = sprites_list[i];
+ CGA_RestoreImage(sprite, backbuffer);
+ }
+}
+
+/*
+Copy data at sprite's rect from screen to backbuffer
+*/
+void RefreshSpritesData(void)
+{
+ int i;
+ for(i = 0;i < MAX_SPRITES;i++)
+ {
+ unsigned char *sprite = sprites_list[i];
+ CGA_RefreshImageData(sprite);
+ }
+}
+
+int IsInRect(unsigned char x, unsigned char y, rect_t *rect)
+{
+ if(x < rect->sx) return 0;
+ if(x >= rect->ex) return 0;
+ if(y < rect->sy) return 0;
+ if(y >= rect->ey) return 0;
+ return 1;
+}
+
+int IsCursorInRect(rect_t *rect)
+{
+ return IsInRect(cursor_x / CGA_PIXELS_PER_BYTE, cursor_y, rect);
+}
+
+void FindPerson(void)
+{
+ int i;
+ pers_t *pers = pers_list;
+ for(i = 0;i < PERS_MAX;i++, pers++)
+ {
+ if((pers->flags & 15) == script_byte_vars.cur_spot_idx)
+ {
+ script_vars[ScrPool8_CurrentPers] = pers;
+ script_byte_vars.cur_pers = i + 1;
+ return;
+ }
+ }
+ script_byte_vars.cur_pers = 0;
+}
+
+void CheckHotspots(unsigned char m, unsigned char v)
+{
+ int 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))
+ {
+ script_byte_vars.cur_spot_idx = i + 1;
+ spot_sprite = sprites_list + i;
+ found_spot = spot;
+ script_byte_vars.cur_spot_flags = spot->flags;
+ object_hint = spot->hint;
+ cursor_color = 0xAA;
+ the_command = Swap16(spot->command);
+ FindPerson();
+ return;
+ }
+ }
+ cursor_color = 0xFF;
+ object_hint = zone_name; /*room name*/
+ script_byte_vars.cur_spot_idx = 0;
+}
+
+void SelectSpotCursor(void)
+{
+ int curs = 1;
+ CheckHotspots(script_byte_vars.spot_m, script_byte_vars.spot_v);
+ if(cursor_color == 0xAA)
+ {
+ curs = 6;
+ if((script_byte_vars.cur_spot_flags & (SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8)) != SPOTFLG_10)
+ {
+ curs = 7;
+ if((script_byte_vars.cur_spot_flags & SPOTFLG_20) != 0)
+ curs = 8;
+ }
+ }
+ cursor_shape = souri_data + curs * CURSOR_WIDTH * CURSOR_HEIGHT * 2 / CGA_PIXELS_PER_BYTE;
+}
+
+#define kBgW 8
+#define kBgH 30
+
+/*blocks draw order (clockwise inward spiral)*/
+static const signed int 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,
+ -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,
+ kBgH/2*CGA_BYTES_PER_LINE, kBgH/2*CGA_BYTES_PER_LINE, kBgH/2*CGA_BYTES_PER_LINE,
+ -kBgW, -kBgW, -kBgW, -kBgW, -kBgW, -kBgW,
+ -kBgH/2*CGA_BYTES_PER_LINE, -kBgH/2*CGA_BYTES_PER_LINE,
+ kBgW, kBgW, kBgW, kBgW, kBgW,
+ kBgH/2*CGA_BYTES_PER_LINE,
+ -kBgW, -kBgW, -kBgW, -kBgW};
+
+/*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*/
+ for(i = 0;i < 53;i++)
+ {
+ CGA_Blit(pixels + (i & 1 ? 0 : kBgW * kBgH), kBgW, kBgW, kBgH, target, offs);
+ if(vblank)
+ WaitVBlank();
+ offs += background_draw_steps[i];
+ }
+
+ offs = (182 / 2) * CGA_BYTES_PER_LINE; /*TODO: calcxy?*/
+ for(i = 0;i < 9;i++)
+ {
+ CGA_Blit(pixels, kBgW, kBgW, 9, target, offs);
+ offs += kBgW;
+ }
+}
+
+void LoadZone(void)
+{
+ unsigned char *zptr, *zend;
+
+ zptr = SeekToEntry(zones_data, script_byte_vars.zone_index - 1, &zend);
+ script_byte_vars.zone_area = *zptr++;
+ script_byte_vars.zone_room = *zptr++;
+ zone_name = object_hint = *zptr++;
+ 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;
+ 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++)
+ {
+ unsigned short 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*/
+ zptr += 2;
+ }
+ if(flags & 8)
+ {
+ zcmds[1] = zptr[0] | (zptr[1] << 8);
+ zptr += 2;
+ }
+ if(flags & 4)
+ {
+ zcmds[2] = zptr[0] | (zptr[1] << 8);
+ zptr += 2;
+ }
+ if(flags & 2)
+ {
+ zcmds[3] = zptr[0] | (zptr[1] << 8);
+ zptr += 2;
+ }
+ if(flags & 1)
+ {
+ zcmds[4] = zptr[0] | (zptr[1] << 8);
+ zptr += 2;
+ }
+ zcmds += 5;
+ }
+ }
+
+ zone_spots = script_vars[ScrPool4_ZoneSpots] = (spot_t*)zptr;
+ zone_spots_end = (spot_t*)zend;
+ zone_spots_cur = (spot_t*)zptr;
+ zone_spr_index = 0;
+ script_byte_vars.dead_flag = 0;
+ script_byte_vars.byte_179DB = 0;
+ script_word_vars.next_command1 = BE(0);
+ next_command4 = 0;
+ next_command3 = 0;
+ script_byte_vars.used_commands = 0;
+}
+
+void ResetZone(void)
+{
+ script_word_vars.word_178EE = 0;
+ script_word_vars.word_17852 = 0;
+ script_word_vars.word_17848 = 0;
+ script_byte_vars.byte_179F9 = 0;
+ script_byte_vars.byte_17A01 = 0;
+ script_byte_vars.byte_17A17 = 0;
+ script_byte_vars.flag_179FB = 0;
+ script_byte_vars.byte_179C1 = 0;
+ script_byte_vars.byte_179E9 = 0;
+ script_byte_vars.byte_179EA = 0;
+ script_byte_vars.byte_179BE = 0;
+ script_byte_vars.byte_179EF = 0;
+ script_word_vars.word_17850 = BE(0xA01C);
+ script_word_vars.word_1784A = BE(0x00F7);
+ script_word_vars.word_17844 = BE(0x9048);
+ script_word_vars.word_1784C = BE(0x9048);
+ script_word_vars.word_1784E = BE(0x9048);
+ script_word_vars.word_17846 = BE(0xA01D);
+}
+
+/*load puzzl sprite to buffer, return next free buffer ptr*/
+unsigned char * LoadPuzzl(unsigned char index, unsigned char *buffer)
+{
+ if(script_byte_vars.palette_index == 14)
+ return LoadSprite(index, puzzl_data + 4, buffer, 1);
+ else
+ return LoadSprite(index, puzzl_data + 4, buffer, 0);
+}
+
+/*load puzzl sprite to scratch buffer, return sprite ptr*/
+unsigned char * LoadPuzzlToScratch(unsigned char index)
+{
+ unsigned char * buffer = scratch_mem2;
+ LoadPuzzl(index, buffer);
+ return buffer;
+}
+
+#define kNumDoorSprites 3
+
+typedef struct doorinfo_t {
+ unsigned char flipped;
+ struct {
+ unsigned char width;
+ unsigned char height;
+ unsigned char *pixels;
+ unsigned int offs;
+ } layer[kNumDoorSprites];
+ unsigned char width;
+ unsigned char height;
+ unsigned int offs;
+ unsigned char sprites[1]; /*variable size*/
+} doorinfo_t;
+
+unsigned char *doors_list[5];
+unsigned char arpla_y_step;
+
+void InitRoomDoorInfo(unsigned char index)
+{
+ int i;
+ unsigned char *aptr;
+ unsigned char *sprbuf;
+ doorinfo_t *info = (doorinfo_t*)scratch_mem2;
+ rect_t bounds = {0xFF, 0, 0xFF, 0};
+
+ aptr = doors_list[index - 1];
+ 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;
+ sprbuf = LoadPuzzl(aptr[0], sprbuf);
+
+ x = aptr[1];
+ y = aptr[2];
+ w = sprite[0];
+ h = sprite[1];
+
+ ox = x;
+ if(x & 0x80)
+ {
+ /*horizontal flip*/
+ x = (x + w - 1) & 0x7F;
+ ox &= 0x7F;
+ }
+
+ y = (y * 2) & 0xFF; /*TODO: disregard vertical flip?*/
+
+ if(ox < bounds.sx)
+ bounds.sx = ox;
+ if(ox + w >= bounds.ex)
+ bounds.ex = ox + w;
+
+ if(y < bounds.sy)
+ bounds.sy = y;
+ if(y + h >= bounds.ey)
+ bounds.ey = y + h;
+
+ info->layer[i].width = w;
+ info->layer[i].height = h;
+ info->layer[i].pixels = sprite + 2;
+ info->layer[i].offs = CGA_CalcXY_p(x, y);
+
+ aptr += 3;
+ }
+
+ info->width = bounds.ex - bounds.sx;
+ info->height = bounds.ey - bounds.sy;
+ info->offs = CGA_CalcXY_p(bounds.sx, bounds.sy);
+}
+
+void DrawRoomDoor(void)
+{
+ int 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;
+
+ if(!info->flipped)
+ CGA_BlitSprite(pixels, w * 2, w, h, backbuffer, offs);
+ else
+ CGA_BlitSpriteFlip(pixels, w * 2, w, h, backbuffer, offs);
+ }
+ WaitVBlank();
+ WaitVBlank();
+ CGA_CopyScreenBlock(backbuffer, info->width, info->height, frontbuffer, info->offs);
+}
+
+void AnimRoomDoorOpen(unsigned char index)
+{
+ int i;
+
+ doorinfo_t *info = (doorinfo_t*)scratch_mem2;
+
+ InitRoomDoorInfo(index);
+
+ for(i = 0;i < info->layer[1].height / 2;i++)
+ {
+#if 1
+ DrawRoomDoor();
+#endif
+ info->layer[1].height -= 2;
+ info->layer[1].pixels += info->layer[1].width * 2 * 2;
+ }
+
+ PlaySound(31);
+}
+
+void AnimRoomDoorClose(unsigned char index)
+{
+ int i;
+
+ unsigned char oldheight;
+ unsigned char *oldpixels;
+
+ doorinfo_t *info = (doorinfo_t*)scratch_mem2;
+ InitRoomDoorInfo(index);
+
+ oldheight = info->layer[1].height;
+ oldpixels = info->layer[1].pixels;
+
+ info->layer[1].pixels += info->layer[1].width * 2 * (info->layer[1].height - 1);
+ info->layer[1].height = 1;
+
+ for(i = 0;i < oldheight / 2;i++)
+ {
+#if 0
+ DrawRoomDoor();
+#endif
+ info->layer[1].height += 2;
+ info->layer[1].pixels -= info->layer[1].width * 2 * 2;
+ }
+
+ info->layer[1].height = oldheight;
+ info->layer[1].pixels = oldpixels;
+ DrawRoomDoor();
+
+ PlaySound(31);
+}
+
+/*Maybe FindRoomDoor?*/
+unsigned char FindInitialSpot(void)
+{
+ spot_t *spot;
+ unsigned char index;
+ unsigned char flags = script_byte_vars.byte_179B8;
+ if(flags == 0)
+ return 0;
+ flags |= 0x80;
+ for(index = 1, spot = zone_spots;spot != zone_spots_end;index++, spot++)
+ {
+ if(spot->flags == flags)
+ return index;
+ }
+ return 0;
+}
+
+unsigned char FindSpotByFlags(unsigned char mask, unsigned char value)
+{
+ spot_t *spot;
+ unsigned char index;
+ for(index = 1, spot = zone_spots;spot != zone_spots_end;spot++, index++)
+ {
+ if((spot->flags & mask) == value)
+ return index;
+ }
+ return 0xFF;
+}
+
+unsigned char FindAndSelectSpot(unsigned char offset)
+{
+ /*TODO: replace offset arg with index?*/
+ unsigned char index = offset / 5; /* / sizeof(pers_t) */
+
+ script_vars[ScrPool8_CurrentPers] = &pers_list[index];
+
+ index = FindSpotByFlags(0x3F, (pers_list[index].index & 7) | SPOTFLG_10); /*TODO: return 0 if not found?*/
+ if(index == 0xFF)
+ return 0;
+
+ found_spot = &zone_spots[index - 1];
+ script_byte_vars.cur_spot_idx = index;
+ spot_sprite = &sprites_list[index - 1];
+ return 1;
+}
+
+void AnimateSpot(const animdesc_t *info)
+{
+ unsigned char *sprite = *spot_sprite;
+ CGA_RestoreImage(sprite, backbuffer);
+ if(info->index & ANIMFLG_USESPOT)
+ {
+ /*at object*/
+ cursor_x = found_spot->sx * 4;
+ cursor_y = found_spot->sy;
+ if(info->params.desc)
+ DrawMessage(SeekToString(desci_data, info->params.desc), frontbuffer);
+
+ PlayAnim(info->index & ~ANIMFLG_USESPOT, found_spot->sx, found_spot->sy);
+ }
+ else
+ {
+ /*at specified coords*/
+ PlayAnim(info->index, info->params.coords.x, info->params.coords.y);
+ }
+}
+
+typedef struct lutinanim_t {
+ unsigned char phase;
+ unsigned char sprites[8];
+} lutinanim_t;
+
+lutinanim_t lutins_table[] = {
+ {0, { 55, 55, 55, 55, 55, 55, 55, 55} },
+ {0, { 41, 41, 41, 41, 41, 41, 41, 41} },
+ {0, { 6, 6, 6, 6, 6, 6, 6, 6} },
+ {0, { 33, 34, 33, 35, 33, 36, 33, 35} },
+ {0, { 10, 11, 10, 13, 10, 12, 10, 14} },
+ {0, { 15, 16, 17, 18, 19, 15, 20, 21} },
+ {0, { 80, 81, 80, 83, 80, 82, 80, 84} },
+ {0, {139,140,141,142,139,140,141,142} },
+ {0, {133,134,133,135,133,134,133,135} },
+ {0, {136,137,136,138,136,137,136,138} },
+ {0, {144,145,144,145,144,145,144,145} },
+ {0, { 33, 34, 33, 35, 33, 36, 33, 35} },
+ {0, {181,182,181,183,181,182,181,183} },
+ {0, {178,179,178,180,178,179,178,180} },
+ {0, {181,182,181,183,181,182,181,183} },
+ {0, {185,186,187,188,185,186,187,188} },
+ {0, {185,186,187,188,185,186,187,188} },
+ {0, {164,132,164,132,164,132,164,132} },
+ {0, {144,145,144,145,144,145,144,145} },
+ {0, { 33, 34, 33, 35, 33, 36, 33, 35} },
+ {0, {199,200,201,202,199,200,201,202} },
+ {0, {195,196,197,198,195,196,197,198} },
+ {0, {203,203,203,203,203,203,203,203} },
+ {0, {148,148,148,148,148,148,148,148} },
+ {0, {185,186,187,188,185,186,187,188} },
+ {0, {193,193,193,193,193,193,193,193} },
+ {0, {165,166,167,168,165,166,167,168} },
+ {0, { 33, 34, 33, 35, 33, 36, 33, 35} },
+ {0, {181,182,181,183,181,182,181,183} },
+ {0, {178,179,178,180,178,179,178,180} },
+ {0, { 91, 91, 91, 91, 91, 91, 91, 91} },
+ {0, {221,221,221,221,221,221,221,221} },
+ {0, { 0, 0, 0, 0, 0, 0, 0, 0} }
+};
+
+void UpdateZoneSpot(unsigned char index)
+{
+ unsigned char oldspot;
+ static const animdesc_t anim57 = {ANIMFLG_USESPOT | 57};
+ static const animdesc_t anim58 = {ANIMFLG_USESPOT | 58};
+
+ script_byte_vars.need_draw_spots = 0;
+ if(pers_list[27].area != script_byte_vars.zone_area)
+ return;
+ if(index < 59 || index >= 63)
+ return;
+
+ oldspot = script_byte_vars.cur_spot_idx;
+
+ script_byte_vars.need_draw_spots = ~0;
+
+ FindAndSelectSpot(27 * 5);
+ AnimateSpot(&anim57);
+
+ if(pers_list[30].area != 0)
+ {
+ FindAndSelectSpot(30 * 5);
+ AnimateSpot(&anim58);
+ }
+
+ script_byte_vars.cur_spot_idx = oldspot;
+}
+
+void ChangeZone(unsigned char index)
+{
+ unsigned char spridx = 0;
+
+ script_byte_vars.prev_zone_index = script_byte_vars.zone_index;
+ script_byte_vars.zone_index = index;
+
+ if(script_byte_vars.byte_17A22 != 0)
+ spridx = 229;
+ else if(script_byte_vars.zone_index == 129)
+ spridx = 221;
+ else if(script_byte_vars.zone_index == 130)
+ spridx = 222;
+
+ if(spridx != 0)
+ {
+ int i;
+ lutinanim_t *la = &lutins_table[31];
+ for(i = 0;i < 8;i++)
+ la->sprites[i] = spridx;
+ }
+
+ LoadZone();
+ ResetZone();
+}
+
+
+void DrawZoneObjs(void)
+{
+ int i;
+ unsigned char index, pidx;
+ spot_t *spot;
+
+ for(spot = zone_spots;spot != zone_spots_end;spot++)
+ {
+ if((spot->flags & 0x38) == SPOTFLG_10)
+ spot->flags &= ~SPOTFLG_80;
+ }
+
+ for(i = 0;i < PERS_MAX;i++)
+ {
+ pers_list[i].flags &= ~0xF;
+
+ if(pers_list[i].area != script_byte_vars.zone_area)
+ continue;
+ if(pers_list[i].flags & PERSFLG_40)
+ continue;
+
+ pidx = (pers_list[i].index & 7) | SPOTFLG_10;
+ for(index = 1, spot = zone_spots;spot != zone_spots_end;spot++, index++)
+ {
+ if((spot->flags & ~SPOTFLG_40) == pidx)
+ {
+ spot->flags |= SPOTFLG_80;
+ spot->hint = pers_list[i].name;
+ pers_list[i].flags |= index;
+ if(spot->flags & SPOTFLG_40)
+ DrawZoneAniSprite((rect_t*)spot, index, backbuffer);
+ break;
+ }
+ }
+ }
+}
+
+/*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]);
+ x = aptr[1];
+ y = aptr[2];
+ w = sprite[0];
+ h = sprite[1];
+
+ sprite += 2;
+
+ *rx = x;
+ *ry = y;
+ *rw = w;
+ *rh = h;
+
+ pitch = w * 2;
+
+ if(x & 0x80)
+ {
+ /*horizontal flip*/
+ x = (x + w - 1) & 0x7F;
+ }
+
+ if(y & 0x80)
+ {
+ /*vertical flip*/
+ sprite += pitch * (h - 1);
+ pitch = -pitch;
+ }
+ y = (y * 2) & 0xFF;
+
+ if(aptr[0] == 83)
+ {
+ if(arpla_y_step & 1)
+ y -= 8;
+ arpla_y_step >>= 1;
+ }
+
+ if(aptr[1] & 0x80)
+ CGA_BlitSpriteFlip(sprite, pitch, w, h, backbuffer, CGA_CalcXY_p(x, y));
+ else
+ CGA_BlitSprite(sprite, pitch, w, h, backbuffer, CGA_CalcXY_p(x, y));
+}
+
+/*
+Draw all room's static objects (decorations) to backbuffer
+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;
+
+ DrawBackground(backbuffer, 0);
+ arpla_y_step = script_byte_vars.byte_179E1;
+
+ aptr = SeekToEntry(arpla_data, script_byte_vars.zone_room - 1, &aend);
+ room_bounds_rect.sx = 0xFF;
+ room_bounds_rect.ex = 0;
+ room_bounds_rect.sy = 0xFF;
+ room_bounds_rect.ey = 0;
+
+ /*load and draw room decor*/
+ for(;aptr != aend;aptr += 3)
+ {
+ unsigned char index = *aptr;
+ /*a door ?*/
+ if(index >= 50 && index < 61)
+ {
+ doors_list[doorcount++] = aptr - 3; /*TODO: check for list overflow?*/
+ if(doorcount == script_byte_vars.cur_spot_idx)
+ continue;
+ if(script_byte_vars.zone_room == 32 && index == 91 && (script_byte_vars.byte_179DD & 8))
+ continue; /*TODO: error? index may never be that high here*/
+ }
+ /*draw decor object*/
+ DrawRoomStaticObject(aptr, &x, &y, &w, &h);
+
+ /*update room's bounding rect*/
+ x &= 0x7F;
+ y = (y * 2) & 0xFF;
+ if(x < room_bounds_rect.sx)
+ room_bounds_rect.sx = x;
+ if(x + w > room_bounds_rect.ex)
+ room_bounds_rect.ex = x + w;
+ if(y < room_bounds_rect.sy)
+ room_bounds_rect.sy = y;
+ if(y + h > room_bounds_rect.ey)
+ room_bounds_rect.ey = y + h;
+ }
+
+ /*place object hint box right under the room*/
+ room_hint_bar_width = room_bounds_rect.ex - room_bounds_rect.sx - 2;
+ char_draw_coords_x = room_bounds_rect.sx;
+ room_hint_bar_coords_x = room_bounds_rect.sx + 1;
+ char_draw_coords_y = room_bounds_rect.ey + 2;
+ room_hint_bar_coords_y = room_bounds_rect.ey + 2;
+ char_xlat_table = chars_color_wonb;
+
+ /*print room name*/
+ CGA_PrintChar(0x3B, backbuffer);
+ DrawObjectHint(); /* area name */
+ CGA_PrintChar(0x3C, backbuffer);
+
+ /*draw border around hint text*/
+ xx = (room_hint_bar_coords_x - 1) * 4;
+ y = room_hint_bar_coords_y;
+ ww = (room_hint_bar_width + 2) * 4;
+
+ CGA_DrawHLine(xx, y - 2, ww, 2, backbuffer);
+ CGA_DrawHLine(xx, y - 1, ww, 0, backbuffer);
+ CGA_DrawHLine(xx, y + 6, ww, 2, backbuffer);
+ CGA_DrawVLine(xx, y - 2, 9, 2, backbuffer);
+ CGA_DrawVLine(xx + ww - 1, y - 2, 9, 2, backbuffer);
+}
+
+void RedrawRoomStatics(unsigned char index, unsigned char y_step)
+{
+ unsigned char *aptr, *aend;
+ unsigned char x, y, w, h;
+ arpla_y_step = y_step;
+
+ aptr = SeekToEntry(arpla_data, index - 1, &aend);
+ for(;aptr != aend;aptr += 3)
+ {
+ /*load room's bg objs*/
+ DrawRoomStaticObject(aptr, &x, &y, &w, &h);
+ }
+}
+
+/*
+Draw "some item in the room" icon
+*/
+void DrawRoomItemsIndicator(void)
+{
+ unsigned char spridx = 172;
+ int 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)
+ {
+ spridx = 173;
+ break;
+ }
+ }
+ DrawSpriteN(spridx, 296 / CGA_PIXELS_PER_BYTE, 14, CGA_SCREENBUFFER);
+ DrawSpriteN(spridx, 296 / CGA_PIXELS_PER_BYTE, 14, backbuffer);
+
+ script_byte_vars.room_items = 0;
+ for(i = 0;i < 14;i++)
+ {
+ if(inventory_items[i + 38].flags == ITEMFLG_80)
+ script_byte_vars.room_items++; /*TODO: probably should be named differently*/
+ }
+}
+
+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;
+
+ if(!script_byte_vars.need_draw_spots)
+ return;
+
+ FindAndSelectSpot(27 * 5);
+ AnimateSpot(&anim59);
+
+ pers_list[27].area = script_byte_vars.zone_area;
+
+ if(pers_list[30].area != 0)
+ {
+ pers_list[30].area = script_byte_vars.zone_area;
+ FindAndSelectSpot(30 * 5);
+ AnimateSpot(&anim60);
+ }
+
+ script_byte_vars.cur_spot_idx = oldspot;
+
+ DrawZoneObjs();
+}
+
+void RefreshZone(void)
+{
+ PopDirtyRects(DirtyRectSprite);
+ PopDirtyRects(DirtyRectBubble);
+ PopDirtyRects(DirtyRectText);
+
+ if(!zone_drawn && !right_button)
+ DrawBackground(CGA_SCREENBUFFER, 1);
+
+ CGA_BackBufferToRealFull();
+
+ in_de_profundis = script_byte_vars.zone_area == 22 ? 1 : 0;
+
+ DrawTheWallDoors();
+ SelectPalette();
+ DrawRoomItemsIndicator();
+ DrawZoneSpots();
+ if(script_byte_vars.cur_spot_idx != 0)
+ AnimRoomDoorClose(script_byte_vars.cur_spot_idx);
+ BlitSpritesToBackBuffer();
+}
+
+void DrawObjectHint(void)
+{
+ if(script_byte_vars.zone_index == 135)
+ return;
+ char_draw_max_width = room_hint_bar_width;
+ char_draw_coords_x = room_hint_bar_coords_x;
+ char_draw_coords_y = room_hint_bar_coords_y;
+ char_xlat_table = chars_color_wonb;
+ PrintStringCentered(SeekToString(motsi_data, object_hint), backbuffer);
+
+#ifdef DEBUG_ZONE
+ CGA_PrintChar(0x20, backbuffer);
+ CGA_PrintChar(0x10 + script_byte_vars.zone_index / 100, backbuffer);
+ CGA_PrintChar(0x10 + (script_byte_vars.zone_index / 10) % 10, backbuffer);
+ CGA_PrintChar(0x10 + script_byte_vars.zone_index % 10, backbuffer);
+#endif
+}
+
+void ShowObjectHint(unsigned char *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));
+}
+
+void DrawCommandHint(void)
+{
+ char_draw_max_width = cmd_hint_bar_width;
+ char_draw_coords_x = cmd_hint_bar_coords_x;
+ char_draw_coords_y = cmd_hint_bar_coords_y;
+ char_xlat_table = chars_color_wonb;
+ PrintStringCentered(SeekToString(vepci_data, command_hint), backbuffer);
+}
+
+void ShowCommandHint(unsigned char *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;
+
+ unsigned int i;
+
+ buffer = lutin_mem;
+
+ for(i = 0;i < 800;i++) /*TODO: fix size*/
+ {
+ buffer[i * 2] = 0xFF; /*mask*/
+ buffer[i * 2 + 1] = 0; /*pixels*/
+ }
+
+ lutin_entry = SeekToEntry(lutin_data, lutidx, &lutin_entry_end);
+
+ *buffer++ = *lutin_entry++; /*width*/
+ *buffer++ = *lutin_entry++; /*height*/
+
+ for(;lutin_entry != lutin_entry_end;)
+ {
+ spridx = *lutin_entry++;
+ flags = *lutin_entry++;
+ flags |= (*lutin_entry++) << 8;
+
+ sprite = LoadSprit(spridx);
+ sprw = *sprite++;
+ sprh = *sprite++;
+
+ buffer = lutin_mem + 2 + (flags & 0x7FFF) * 2;
+ if(flags & 0x8000)
+ MergeSpritesDataFlip(buffer, lutin_mem[0] * 2, sprite, sprw, sprh);
+ else
+ MergeSpritesData(buffer, lutin_mem[0] * 2, sprite, sprw, sprh);
+ }
+}
+
+/*Draw room's sprites and advance sprite's animation*/
+char DrawZoneAniSprite(rect_t *rect, unsigned int index, unsigned char *target)
+{
+ int i;
+ unsigned char spridx;
+ pers_t *pers = pers_list;
+ for(i = 0;i < PERS_MAX;i++, pers++)
+ {
+ if((pers->flags & 15) == index)
+ {
+ lutinanim_t *la = &lutins_table[pers->index >> 3];
+ spridx = la->sprites[la->phase];
+ la->phase = (la->phase + 1) % 8;
+
+ lutin_mem = scratch_mem2;
+
+ LoadLutinSprite(spridx);
+
+ zsprite_w = scratch_mem2[0];
+ zsprite_h = scratch_mem2[1];
+ zsprite_draw_ofs = CGA_CalcXY_p(rect->sx, rect->sy);
+
+ DrawSprite(scratch_mem2, target, zsprite_draw_ofs);
+
+ return ~0;
+ }
+ }
+ return 0;
+}
+
+void SetDelay5(void)
+{
+ next_ticks4 = Swap16(script_word_vars.timer_ticks2) + 5;
+}
+
+/*
+Pick random quest item
+*/
+void PrepareCommand1(void)
+{
+ unsigned char index;
+ unsigned char oldr, newr;
+ unsigned char flags;
+
+ if(script_byte_vars.zone_area == 55)
+ {
+ pers_list[1].area = 55;
+ pers_list[2].area = 55;
+ pers_list[3].area = 55;
+ pers_list[1].name = 50;
+ pers_list[2].name = 50;
+ pers_list[3].name = 50;
+ return;
+ }
+
+ pers_list[1].area = 0;
+ pers_list[2].area = 0;
+ pers_list[3].area = 0;
+ pers_list[4].area = 0;
+
+ if(script_byte_vars.byte_179DC >= 63)
+ return;
+ if(script_byte_vars.zone_area >= 44)
+ return;
+
+ index = FindSpotByFlags(0x3F, 17);
+ if(index == 0xFF)
+ return;
+ spot_ptr = &zone_spots[index - 1];
+
+ script_byte_vars.quest_item_ofs += 5; /*FIXME: this is sizeof(pers_t), but it's used in scripts, so hardcoded*/
+ if(script_byte_vars.quest_item_ofs >= 5 * 5)
+ script_byte_vars.quest_item_ofs = 1 * 5;
+ pers_ptr = &pers_list[script_byte_vars.quest_item_ofs / 5];
+
+ if(pers_ptr->flags & PERSFLG_40)
+ return;
+
+ oldr = script_byte_vars.rand_value;
+ newr = Rand();
+ flags = 0;
+
+ if(script_byte_vars.zone_area < 6)
+ {
+ if(oldr < 90)
+ {
+ /*TODO: merge/simplify these ifs*/
+ if(pers_ptr->item != 0)
+ {
+ if(pers_ptr->item >= 6 && pers_ptr->item < 27)
+ {
+ if(!(pers_ptr->item >= 19 && pers_ptr->item < 23))
+ flags = 1;
+ }
+ }
+ }
+ if(newr < 23)
+ {
+ pers_ptr->area = script_byte_vars.zone_area;
+ script_word_vars.next_command1 = BE(0xA018);
+ script_byte_vars.check_used_commands = 3;
+ script_byte_vars.byte_179EF = flags;
+ script_vars[ScrPool8_CurrentPers] = pers_ptr;
+ }
+ else if(newr < 52)
+ {
+ script_word_vars.next_command1 = BE(0xA019);
+ flags |= 4;
+ script_byte_vars.check_used_commands = 3;
+ script_byte_vars.byte_179EF = flags;
+ script_vars[ScrPool8_CurrentPers] = pers_ptr;
+ }
+ else
+ {
+ script_byte_vars.byte_179EF = 0;
+ return;
+ }
+ }
+ else
+ {
+ if(oldr < 39 && pers_ptr->item)
+ flags = 1;
+ if(oldr >= 166)
+ flags = 2;
+
+ if(newr < 26)
+ {
+ pers_ptr->area = script_byte_vars.zone_area;
+ script_word_vars.next_command1 = BE(0xA018);
+ script_byte_vars.check_used_commands = 3;
+ script_byte_vars.byte_179EF = flags;
+ script_vars[ScrPool8_CurrentPers] = pers_ptr;
+ }
+ else if(newr < 52)
+ {
+ script_word_vars.next_command1 = BE(0xA019);
+ flags |= 4;
+ script_byte_vars.check_used_commands = 3;
+ script_byte_vars.byte_179EF = flags;
+ script_vars[ScrPool8_CurrentPers] = pers_ptr;
+ }
+ else
+ {
+ script_byte_vars.byte_179EF = 0;
+ return;
+ }
+ }
+}
+
+/*Vorts AI*/
+void PrepareCommand3(void)
+{
+ spot_t *spot;
+
+ if((script_byte_vars.zone_area != 8) || !(script_byte_vars.byte_179EC & 0x80))
+ {
+ pers_list[0].flags &= ~PERSFLG_40;
+ pers_list[34].flags &= ~PERSFLG_40;
+ pers_list[35].flags &= ~PERSFLG_40;
+
+ for(spot = zone_spots;spot != zone_spots_end;spot++)
+ {
+ if((spot->flags & ~SPOTFLG_80) == (SPOTFLG_40 | SPOTFLG_10))
+ {
+ int i;
+ for(i = 0;i < RECD_MAX;i++)
+ {
+ if(vortsanim_list[i].room == script_byte_vars.zone_room)
+ {
+ vortanims_ptr = &vortsanim_list[i];
+ if(script_byte_vars.zone_area == pers_list[0].area
+ || script_byte_vars.zone_area == pers_list[34].area
+ || script_byte_vars.zone_area == pers_list[35].area)
+ {
+ next_command3 = 0xA015; /*VortLeave*/
+ }
+ else
+ {
+ pers_list[0].area = 0;
+ pers_list[34].area = 0;
+ pers_list[35].area = 0;
+ script_byte_vars.byte_179EC &= 0x80; /*TODO: is this correct? |= ?*/
+ if(script_byte_vars.rand_value < 39)
+ {
+ pers_list[0].area = script_byte_vars.zone_area;
+ next_command3 = 0xA015; /*VortLeave*/
+ }
+ else if(script_byte_vars.rand_value < 78)
+ next_command3 = 0xA014; /*VortAppear*/
+ else
+ return;
+ }
+ script_byte_vars.byte_179EC |= 1;
+ next_ticks3 = Swap16(script_word_vars.timer_ticks2) + 5;
+ return;
+ }
+ }
+ break;
+ }
+ }
+ }
+ pers_list[0].area = 0;
+ pers_list[34].area = 0;
+ pers_list[35].area = 0;
+ script_byte_vars.byte_179EC &= 0x80; /*TODO: is this correct? |= ?*/
+}
+
+void PrepareCommand4(void)
+{
+ spot_t *spot;
+
+ if(script_byte_vars.zone_area == 59 && script_byte_vars.byte_17A04 == 0)
+ {
+ pers_list[5].area = 59;
+ return;
+ }
+
+ pers_list[5].flags &= ~PERSFLG_40;
+
+ for(spot = zone_spots;spot != zone_spots_end;spot++)
+ {
+ if((spot->flags & ~SPOTFLG_80) == (SPOTFLG_40 | SPOTFLG_10 | SPOTFLG_1))
+ {
+ int i;
+
+ for(i = 0;i < RECS7_MAX;i++)
+ {
+ if(recs7_list[i].room == script_byte_vars.zone_room)
+ {
+ rec7_ptr = &recs7_list[i];
+ if(script_byte_vars.zone_area == pers_list[5].area)
+ {
+ next_command4 = 0xA01F;
+ SetDelay5();
+ }
+ else
+ {
+ pers_list[5].area = 0;
+ if(script_byte_vars.rand_value >= 217)
+ {
+ pers_list[5].area = script_byte_vars.zone_area;
+ next_command4 = 0xA01F;
+ SetDelay5();
+ }
+ else if(script_byte_vars.rand_value >= 178)
+ {
+ next_command4 = 0xA01E;
+ SetDelay5();
+ }
+ }
+ return;
+ }
+ }
+ break;
+ }
+ }
+
+ pers_list[5].area = 0;
+}
+
+
+/*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);
+ *w = spr[0];
+ *h = spr[1];
+ *ofs = CGA_CalcXY_p(x, y);
+ return 0; /*sprite offset in scratch buf*/
+}
+
+void BackupScreenOfSpecialRoom(void)
+{
+ switch(script_byte_vars.zone_room)
+ {
+ case 41:
+ case 22:
+ case 23:
+ case 24:
+ CGA_RealBufferToBackFull();
+ break;
+ }
+}
+
+void RestoreScreenOfSpecialRoom(void)
+{
+ switch(script_byte_vars.zone_room)
+ {
+ case 23:
+ case 24:
+ RedrawRoomStatics(script_byte_vars.zone_room, 0);
+ break;
+ }
+}
+
+unsigned char byte_17A1C = 0;
+
+void SetAnim127Sprite(unsigned char flags, unsigned char spridx)
+{
+ unsigned char *lutin_entry, *lutin_entry_end;
+ lutin_entry = SeekToEntry(lutin_data, 127, &lutin_entry_end);
+ lutin_entry[2] = spridx;
+ switch(spridx)
+ {
+ case 37:
+ case 58:
+ case 40:
+ if(flags == ITEMFLG_80)
+ byte_17A1C += 1;
+ else
+ byte_17A1C -= 1;
+ break;
+ }
+}
+
+void BounceCurrentItem(unsigned char flags, unsigned char y)
+{
+ item_t *item = (item_t*)(script_vars[ScrPool3_CurrentItem]);
+
+ SetAnim127Sprite(flags, item->sprite);
+ item->flags = flags;
+ item->flags2 = script_byte_vars.zone_area;
+ BackupScreenOfSpecialRoom();
+ PlayAnim(41, 176/4, y);
+ DrawRoomItemsIndicator();
+ RestoreScreenOfSpecialRoom();
+}
+
+
+unsigned char * LoadMursmSprite(unsigned char index)
+{
+ unsigned char *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;
+
+ index = *pinfo++;
+ flags = *pinfo++;
+ flags |= (*pinfo++) << 8;
+ buffer = sprit_load_buffer + (flags & 0x3FFF);
+ pitch = 20;
+
+ sprite = LoadPuzzlToScratch(index & 0x7F);
+ sprw = *sprite++;
+ sprh = *sprite++;
+
+ if(index & 0x80) /*horizontal flip*/
+ MergeImageAndSpriteDataFlip(buffer, pitch, sprite, sprw, sprh);
+ else
+ MergeImageAndSpriteData(buffer, pitch, sprite, sprw, sprh);
+ }
+
+ /*TODO: move this from globals to args/consts?*/
+ cur_frame_width = 20;
+ cur_image_coords_y = 32;
+ cur_image_size_w = 80 / 4;
+ cur_image_size_h = 59;
+
+ return sprit_load_buffer;
+}
+
+typedef struct thewall_t {
+unsigned char height;
+unsigned char width;
+unsigned int pitch;
+unsigned int offs;
+unsigned char *pixels;
+} thewall_t;
+
+thewall_t the_wall_wall_b, the_wall_wall_a;
+
+unsigned int cur_image_width_full;
+
+void TheWallOpenRightDoor(unsigned char x, unsigned char y, unsigned char w, unsigned char h)
+{
+ unsigned int ofs = CGA_CalcXY_p(x + w - 2, y);
+ unsigned char n = w - 1;
+ while(n)
+ {
+ CGA_HideScreenBlockLiftToRight(1, frontbuffer, backbuffer, n, h, frontbuffer, ofs);
+ n--;
+ if(n == cur_image_width_full)
+ {
+ /*ret n and ofs*/
+ return;
+ }
+ }
+ ofs += 1;
+
+
+}
+
+void DrawWallA(unsigned int n, unsigned int limit, unsigned int w, unsigned char h, unsigned int ofs)
+{
+ do
+ {
+ CGA_HideScreenBlockLiftToRight(1, frontbuffer, backbuffer, w, h, frontbuffer, ofs);
+ w--;
+ if(n == limit)
+ return;
+ }
+ while(n--);
+
+ ofs += 1;
+
+ while(h--)
+ {
+ memcpy(frontbuffer + ofs, backbuffer + ofs, 1);
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+}
+
+void DrawWallB(unsigned int n, unsigned int limit, unsigned int w, unsigned char h, unsigned int ofs)
+{
+ do
+ {
+ CGA_HideScreenBlockLiftToLeft(1, frontbuffer, backbuffer, w, h, frontbuffer, ofs);
+ w--;
+ if(n == limit)
+ return;
+ }
+ while(n--);
+
+ ofs -= 1;
+
+ while(h--)
+ {
+ memcpy(frontbuffer + ofs, backbuffer + ofs, 1);
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+}
+
+
+void TheWallPhase3(void)
+{
+ script_byte_vars.zone_index = (script_byte_vars.zone_index == 95) ? 9 : 102;
+ LoadZone();
+
+#if 0
+ cur_image_width_full = 40 / 4;
+ TheWallOpenRightDoor();
+#endif
+ /*TODO*/
+}
+
+void TheWallPhase0(void)
+{
+ script_byte_vars.zone_index = (script_byte_vars.zone_index == 9) ? 24 : 30;
+ LoadZone();
+ /*TODO*/
+
+ /*
+ DrawWallA(unsigned int n, 0, unsigned int w, unsigned char h, unsigned int ofs);
+ DrawWallB(unsigned int n, 0, unsigned int w, unsigned char h, unsigned int ofs);
+ */
+
+}
+
+/*Opened -> Half closed*/
+void TheWallPhase1_DoorClose1(void)
+{
+ unsigned char *spr;
+
+ script_byte_vars.zone_index = (script_byte_vars.zone_index == 24) ? 9 : 102;
+ LoadZone();
+
+ spr = LoadMursmSprite(0);
+ spr += cur_frame_width - 1;
+ cur_image_coords_x = 64 / 4;
+ CGA_AnimLiftToRight(10, spr, cur_frame_width, 1, cur_image_size_h, frontbuffer, CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y));
+
+ spr = LoadMursmSprite(1);
+ cur_image_coords_x = 220 / 4;
+ CGA_AnimLiftToLeft(10, spr, cur_frame_width, 1, cur_image_size_h, frontbuffer, CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y));
+}
+
+/*Half closed -> Fully closed*/
+void TheWallPhase2_DoorClose2(void)
+{
+ unsigned char *spr;
+
+ script_byte_vars.zone_index = (script_byte_vars.zone_index == 9) ? 95 : 103;
+ LoadZone();
+
+ spr = LoadMursmSprite(0);
+ spr += cur_frame_width - 1;
+ cur_image_coords_x = 64 / 4;
+ CGA_AnimLiftToRight(10, spr - 10, cur_frame_width, 1 + 10, cur_image_size_h, frontbuffer, CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y));
+
+ spr = LoadMursmSprite(1);
+ cur_image_coords_x = 220 / 4;
+ CGA_AnimLiftToLeft(10, spr, cur_frame_width, 1 + 10, cur_image_size_h, frontbuffer, CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y) - 10);
+}
+
+void DrawTheWallDoors(void)
+{
+ switch(script_byte_vars.zone_index)
+ {
+ case 9:
+ case 102:
+ CGA_Blit(LoadMursmSprite(0) + 10, 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(64/CGA_PIXELS_PER_BYTE, 32));
+ CGA_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(180/CGA_PIXELS_PER_BYTE, 32));
+ break;
+ case 95:
+ case 103:
+ CGA_Blit(LoadMursmSprite(0), 20, 20, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(64/CGA_PIXELS_PER_BYTE, 32));
+ CGA_Blit(LoadMursmSprite(1), 20, 20, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(144/CGA_PIXELS_PER_BYTE, 32));
+ break;
+ }
+}
+
+/*
+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;
+ while(h--)
+ {
+ for(x = 0;x < w;x++)
+ {
+ unsigned char m = *source++;
+ *target++ &= m;
+ *target &= m;
+ *target++ |= *source++;
+ }
+ target -= w * 2;
+ target += pitch;
+ }
+}
+
+/*
+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;
+ target += w * 2 - 2;
+ while(h--)
+ {
+ for(x = 0;x < w;x++)
+ {
+ unsigned char m = cga_pixel_flip[*source++];
+ *target++ &= m;
+ *target &= m;
+ *target |= cga_pixel_flip[*source++];
+ target -= 3;
+ }
+ target += w * 2;
+ target += pitch;
+ }
+}
+
+unsigned char * BackupSpotImage(spot_t *spot, unsigned char **spotback, unsigned char *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;
+}
+
+void BackupSpotsImages(void)
+{
+ spot_t *spot = zone_spots;
+ unsigned char *buffer = scratch_mem1;
+ int 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 i if spot is skipped?*/
+ {
+ if(spot->flags & SPOTFLG_40)
+ buffer = BackupSpotImage(spot, &sprites_list[i], buffer);
+ }
+}
+
+void DrawSpots(unsigned char *target)
+{
+ spot_t *spot = zone_spots_cur;
+ unsigned char spridx = zone_spr_index;
+ if(spot == zone_spots_end)
+ {
+ spot = zone_spots;
+ spridx = 0;
+ }
+
+ do
+ {
+ spridx++;
+ if((spot->flags & SPOTFLG_40) && ((spot->flags & ~7) == (SPOTFLG_80 | SPOTFLG_40 | SPOTFLG_10)))
+ {
+ zone_spots_cur = spot + 1;
+ zone_spr_index = spridx;
+ /*TODO: subclass spot_t from rect_t*/
+ if(DrawZoneAniSprite((rect_t*)spot, (spot - zone_spots) + 1, backbuffer))
+ {
+ UpdateCursor();
+ WaitVBlank();
+ UndrawCursor(target);
+ CGA_CopyScreenBlock(backbuffer, zsprite_w, zsprite_h, target, zsprite_draw_ofs);
+ DrawCursor(target);
+ CGA_RestoreImage(sprites_list[zone_spr_index - 1], backbuffer);
+ return;
+ }
+ spridx = zone_spr_index; /*TODO: not neded?*/
+ }
+ spot++;
+ }
+ while(spot != zone_spots_end);
+ zone_spots_cur = spot;
+ zone_spr_index = spridx;
+}
+
+void AnimateSpots(unsigned char *target)
+{
+ if(script_byte_vars.timer_ticks % 32 == 31)
+ DrawSpots(target);
+}
+
+void DrawHintsAndCursor(unsigned char *target)
+{
+ UpdateCursor();
+ WaitVBlank();
+ UndrawCursor(target);
+ if(object_hint != last_object_hint)
+ {
+ ShowObjectHint(target);
+ last_object_hint = object_hint;
+ }
+
+ if(command_hint != last_command_hint)
+ {
+ ShowCommandHint(target);
+ last_command_hint = command_hint;
+ }
+
+ DrawCursor(target);
+}
+
+void HideSpot(unsigned char offset)
+{
+ FindAndSelectSpot(offset);
+ found_spot->flags &= ~SPOTFLG_80;
+}
+
+static const unsigned char timed_seq[] = {56, 51, 44, 12, 10, 20, 18, 16, 14, 12, 44, 51};
+static const unsigned char *timed_seq_ptr = timed_seq;
+
+/*TODO: rename this*/
+void UpdateTimedRects1(void)
+{
+ unsigned int elapsed;
+
+ if(script_byte_vars.flag_179FB != 0)
+ return;
+
+ if(script_byte_vars.byte_179DC >= 63)
+ return;
+
+ script_word_vars.next_command2 = BE(0);
+
+ if(pers_list[13].flags & PERSFLG_40)
+ {
+ pers_list[13].area = 56;
+ pers_list[13].flags &= ~(PERSFLG_10 | PERSFLG_20 | PERSFLG_40 | PERSFLG_80);
+ pers_list[13].index = 52;
+ }
+
+ if(pers_list[22].flags & PERSFLG_20)
+ script_byte_vars.byte_179E6 |= 4;
+
+ elapsed = Swap16(script_word_vars.timer_ticks2);
+ if(elapsed < next_ticks2)
+ return;
+
+ next_ticks2 = elapsed + 30;
+
+ script_byte_vars.byte_179F5 = *timed_seq_ptr++;
+ if(timed_seq_ptr == timed_seq + sizeof(timed_seq))
+ timed_seq_ptr = timed_seq;
+ script_byte_vars.byte_179F6 = *timed_seq_ptr++;
+
+ if(script_byte_vars.byte_179F5 == 56)
+ {
+ script_byte_vars.byte_179E6 &= ~4;
+ pers_list[22].flags &= ~(PERSFLG_20 | PERSFLG_40 | PERSFLG_80);
+ pers_list[22].index = 55;
+ if(pers_list[13].area == 56)
+ {
+ pers_list[13].flags &= ~(PERSFLG_20 | PERSFLG_40 | PERSFLG_80);
+ script_byte_vars.byte_179F7 = 1;
+ }
+ }
+
+ if(script_byte_vars.byte_179F5 == 12 && script_byte_vars.byte_179F6 == 10)
+ {
+ script_byte_vars.byte_179F7 = 0;
+ if(pers_list[13].area == 56)
+ {
+ script_byte_vars.byte_179F6 = 44;
+ timed_seq_ptr = timed_seq + 4;
+ }
+
+ }
+
+ pers_list[22].area = script_byte_vars.byte_179F6;
+
+ if(script_byte_vars.byte_179F7 != 0)
+ {
+ pers_list[13].area = script_byte_vars.byte_179F6;
+ pers_list[20].area = script_byte_vars.byte_179F6;
+ pers_list[21].area = script_byte_vars.byte_179F6;
+
+ if(script_byte_vars.zone_area == script_byte_vars.byte_179F5)
+ {
+ static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35};
+ UpdateUndrawCursor(frontbuffer);
+ RefreshSpritesData();
+ HideSpot(22 * 5); /*dirct rec offset*/
+ HideSpot(13 * 5); /*dirct rec offset*/
+ HideSpot(20 * 5); /*dirct rec offset*/
+ HideSpot(21 * 5); /*dirct rec offset*/
+ AnimateSpot(&anim35);
+ BlitSpritesToBackBuffer();
+ DrawCursor(frontbuffer);
+ return;
+ }
+
+ if(script_byte_vars.zone_area == script_byte_vars.byte_179F6)
+ {
+ static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34};
+ UpdateUndrawCursor(frontbuffer);
+ RefreshSpritesData();
+
+ FindAndSelectSpot(22 * 5);
+ AnimateSpot(&anim34);
+
+ if(FindAndSelectSpot(20 * 5))
+ {
+ AnimateSpot(&anim34);
+
+ FindAndSelectSpot(13 * 5);
+ AnimateSpot(&anim34);
+
+ FindAndSelectSpot(21 * 5);
+ AnimateSpot(&anim34);
+ }
+
+ DrawZoneObjs();
+ CGA_BackBufferToRealFull();
+ BlitSpritesToBackBuffer();
+ DrawCursor(frontbuffer);
+
+ if(script_byte_vars.room_items != 0)
+ script_word_vars.next_command2 = BE(0xC1FD);
+ else if(pers_list[22].flags & 0x20)
+ script_word_vars.next_command2 = BE(0xC1E5);
+ else if(script_byte_vars.zone_area == 44)
+ script_word_vars.next_command2 = BE(0xC060);
+
+ return;
+ }
+
+ }
+ else
+ {
+ if(pers_list[22].flags & 0x40)
+ return;
+
+ if(script_byte_vars.zone_area == script_byte_vars.byte_179F5)
+ {
+ static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35};
+ UpdateUndrawCursor(frontbuffer);
+ RefreshSpritesData();
+ HideSpot(22 * 5); /*dirct rec offset*/
+ AnimateSpot(&anim35);
+ BlitSpritesToBackBuffer();
+ DrawCursor(frontbuffer);
+ return;
+ }
+
+ if(script_byte_vars.zone_area == script_byte_vars.byte_179F6)
+ {
+ static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34};
+ UpdateUndrawCursor(frontbuffer);
+ RefreshSpritesData();
+
+ FindAndSelectSpot(22 * 5);
+ AnimateSpot(&anim34);
+
+ DrawZoneObjs();
+ CGA_BackBufferToRealFull();
+ BlitSpritesToBackBuffer();
+ DrawCursor(frontbuffer);
+
+ return;
+ }
+ }
+}
+
+/*TODO: rename this*/
+void UpdateTimedRects2(void)
+{
+ unsigned int elapsed = Swap16(script_word_vars.timer_ticks2);
+
+ if(elapsed < 60 * 60)
+ return;
+
+ if(script_byte_vars.byte_179DC < 63)
+ {
+ script_byte_vars.byte_179ED = 3;
+ script_byte_vars.byte_179DC = (script_byte_vars.zone_area < 44) ? 255 : 63;
+ pers_list[13].area = 0;
+ pers_list[14].area = 0;
+ pers_list[15].area = 0;
+ pers_list[16].area = 0;
+ pers_list[18].area = 0;
+ pers_list[19].area = 56;
+ pers_list[20].area = 56;
+ pers_list[21].area = 56;
+ pers_list[22].area = 56;
+ if(script_byte_vars.zone_area < 22)
+ script_word_vars.next_command2 = BE(0xC012);
+ return;
+ }
+
+ if(elapsed < 105 * 60)
+ return;
+
+ if(elapsed < 120 * 60)
+ {
+ script_byte_vars.byte_179ED = 2;
+ script_byte_vars.byte_17A04 = 1;
+ if((script_byte_vars.zone_area != 61)
+ && (script_byte_vars.zone_area >= 59 && script_byte_vars.zone_area < 75))
+ script_word_vars.next_command2 = BE(0xC012);
+ return;
+ }
+
+ script_word_vars.next_command2 = BE(0xC318);
+}
+
+void UpdateTimedInventoryItems(void)
+{
+ int i;
+ if(Swap16(script_word_vars.timer_ticks2) - inv_update_time < 180)
+ return;
+ inv_update_time = Swap16(script_word_vars.timer_ticks2);
+
+ for(i = 0;i < MAX_INV_ITEMS;i++)
+ {
+ if(inventory_items[i].flags & ITEMFLG_40)
+ {
+ if(inventory_items[i].flags2 != script_byte_vars.zone_area && inventory_items[i].flags2 < 52)
+ inventory_items[i].flags &= ~ITEMFLG_40;
+ }
+ }
+}
+
+void ResetAllPersons(void)
+{
+ int 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
new file mode 100644
index 00000000000..7d8882f90e7
--- /dev/null
+++ b/engines/chamber/room.h
@@ -0,0 +1,184 @@
+#ifndef _ROOM_H_
+#define _ROOM_H_
+
+#define SPOTFLG_1 0x01
+#define SPOTFLG_8 0x08
+#define SPOTFLG_10 0x10
+#define SPOTFLG_20 0x20
+#define SPOTFLG_40 0x40
+#define SPOTFLG_80 0x80
+
+/*static room object*/
+/*TODO: manipulated from script, do not change*/
+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;
+} spot_t;
+
+#if sizeof(spot_t) != 8
+#error "spot_t must be 8 bytes long"
+#endif
+
+#define PERSFLAGS 0xF0
+#define PERSFLG_10 0x10
+#define PERSFLG_20 0x20
+#define PERSFLG_40 0x40
+#define PERSFLG_80 0x80
+
+/*person*/
+/*TODO: manipulated from script, do not change*/
+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)*/
+} pers_t;
+
+#if sizeof(pers_t) != 5
+#error "pers_t must be 5 bytes long"
+#endif
+
+#define ANIMFLG_USESPOT 0x80
+
+typedef struct animdesc_t {
+unsigned char index; /*flag in bit 7, animation index in bits 6..0*/
+union {
+ struct {
+ unsigned char x, y;
+ } coords;
+ unsigned short desc;
+} params;
+} animdesc_t;
+
+typedef struct vortanims_t {
+ unsigned char room;
+ animdesc_t field_1;
+ animdesc_t field_4;
+ animdesc_t field_7;
+ animdesc_t field_A;
+} vortanims_t;
+
+typedef struct rec7_t {
+ unsigned char room;
+ animdesc_t field_1;
+ animdesc_t field_4;
+} rec7_t;
+
+extern unsigned char scratch_mem1[8010];
+extern unsigned char *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 unsigned short next_ticks2;
+extern unsigned short next_ticks3;
+extern unsigned short next_command3;
+extern unsigned short next_ticks4;
+extern unsigned short next_command4;
+
+#define MAX_SPRITES 16
+
+extern unsigned char *sprites_list[MAX_SPRITES];
+
+extern unsigned char zone_palette;
+
+extern spot_t *zone_spots;
+extern spot_t *zone_spots_end;
+extern spot_t *zone_spots_cur;
+
+extern vortanims_t *vortanims_ptr;
+extern rec7_t *rec7_ptr;
+extern pers_t *pers_ptr;
+extern spot_t *spot_ptr;
+extern spot_t *found_spot;
+extern unsigned char **spot_sprite;
+
+extern unsigned char *lutin_mem;
+
+extern unsigned char zone_drawn;
+
+extern unsigned char in_de_profundis;
+
+extern unsigned char zone_spr_index;
+
+int IsInRect(unsigned char x, unsigned char y, rect_t *rect);
+int IsCursorInRect(rect_t *rect);
+void SelectSpotCursor(void);
+
+void CheckHotspots(unsigned char m, unsigned char v);
+
+void AnimateSpot(const animdesc_t *info);
+unsigned char * LoadPuzzlToScratch(unsigned char index);
+
+void DrawObjectHint(void);
+void ShowObjectHint(unsigned char *target);
+void DrawCommandHint(void);
+void ShowCommandHint(unsigned char *target);
+
+char DrawZoneAniSprite(rect_t *rect, unsigned int index, unsigned char *target);
+
+void DrawHintsAndCursor(unsigned char *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 RefreshSpritesData(void);
+void BlitSpritesToBackBuffer(void);
+void BackupSpotsImages(void);
+
+void SelectPalette(void);
+
+unsigned char FindSpotByFlags(unsigned char mask, unsigned char value);
+unsigned char FindAndSelectSpot(unsigned char offset);
+
+void FindPerson(void);
+
+void UpdateZoneSpot(unsigned char index);
+void DrawRoomStaticObject(unsigned char *aptr, unsigned char *rx, unsigned char *ry, unsigned char *rw, unsigned char *rh);
+void DrawRoomStatics(void);
+void RedrawRoomStatics(unsigned char index, unsigned char y_step);
+void DrawZoneObjs(void);
+void RefreshZone(void);
+void ChangeZone(unsigned char index);
+
+void DrawSpots(unsigned char *target);
+void AnimateSpots(unsigned char *target);
+
+unsigned char FindInitialSpot(void);
+void AnimRoomDoorOpen(unsigned char index);
+void AnimRoomDoorClose(unsigned char index);
+
+unsigned int GetPuzzlSprite(unsigned char index, unsigned char x, unsigned char y, unsigned int *w, unsigned int *h, unsigned int *ofs);
+
+void BounceCurrentItem(unsigned char flags, unsigned char y);
+
+void BackupScreenOfSpecialRoom(void);
+void RestoreScreenOfSpecialRoom(void);
+
+void TheWallPhase3(void);
+void TheWallPhase0(void);
+void TheWallPhase1_DoorClose1(void);
+void TheWallPhase2_DoorClose2(void);
+
+void PrepareCommand1(void);
+void PrepareCommand3(void);
+void PrepareCommand4(void);
+
+void UpdateTimedRects1(void);
+void UpdateTimedRects2(void);
+void UpdateTimedInventoryItems(void);
+
+void ResetAllPersons(void);
+
+#endif
diff --git a/engines/chamber/ru.cmd b/engines/chamber/ru.cmd
new file mode 100644
index 00000000000..962058a21f9
--- /dev/null
+++ b/engines/chamber/ru.cmd
@@ -0,0 +1,5 @@
+ at echo off
+copy /y KULT.EXE ..\..\..\dbx\disk\kure
+pushd ..\..\..\dbx
+dosbox -c "cd kure" -c kult.exe
+popd
diff --git a/engines/chamber/rud.cmd b/engines/chamber/rud.cmd
new file mode 100644
index 00000000000..12b2dfeba1c
--- /dev/null
+++ b/engines/chamber/rud.cmd
@@ -0,0 +1,5 @@
+ at echo off
+copy /y KULT.EXE ..\..\..\dbx\disk\kure
+pushd ..\..\..\dbx
+dosbox -c "cd kure" -c "td kult.exe"
+popd
diff --git a/engines/chamber/savegame.c b/engines/chamber/savegame.c
new file mode 100644
index 00000000000..6c6c4beba30
--- /dev/null
+++ b/engines/chamber/savegame.c
@@ -0,0 +1,158 @@
+#include <io.h>
+#include <fcntl.h>
+#include "common.h"
+#include "savegame.h"
+#include "resdata.h"
+#include "script.h"
+#include "cga.h"
+#include "room.h"
+
+void SaveRestartGame(void)
+{
+ /*TODO*/
+}
+
+void RestartGame(void)
+{
+ /*
+ while(!LoadFile("CLEAR.BIN", save_start))
+ AskDisk2();
+ */
+
+ script_byte_vars.cur_spot_flags = 0xFF;
+ script_byte_vars.load_flag = 2;
+ /*Restart();*/
+
+ /*TODO*/
+}
+
+#define CGA_SAVE_BEG_OFS 0x751E
+#define CGA_SAVE_END_OFS 0x9D5D
+
+#define CGA_SAVE_WORD_VARS_OFS 0x7844
+#define CGA_SAVE_BYTE_VARS_OFS 0x79B6
+#define CGA_SAVE_INVENTORY_OFS 0x75E5
+#define CGA_SAVE_ZONES_OFS 0x7A27
+#define CGA_SAVE_PERS_OFS 0x7765
+#define CGA_SAVE_STACK_OFS 0x7562
+
+int LoadScena(void)
+{
+ int f;
+ int rlen;
+
+ script_byte_vars.game_paused = 1;
+
+
+ f = open("SCENAx.BIN", O_RDONLY | O_BINARY);
+ if(f == -1)
+ {
+ script_byte_vars.game_paused = 0;
+ return 1; /*error*/
+ }
+ /*
+ Save format:
+ vars memory (751E-9D5D)
+ frontbuffer (0x3FFF bytes)
+ backbuffer (0x3FFF bytes)
+
+
+ */
+
+
+ /*TODO*/
+
+
+ rlen = read(f, backbuffer, 0x3FFF);
+ if(rlen != 0x3FFF)
+ goto error;
+
+ CGA_BackBufferToRealFull();
+ SelectPalette();
+
+ rlen = read(f, backbuffer, 0x3FFF);
+ if(rlen != 0x3FFF)
+ goto error;
+
+ /*re-initialize sprites list*/
+ BackupSpotsImages();
+
+ close(f);
+ script_byte_vars.game_paused = 0;
+ return 0;
+
+error:;
+ close(f);
+ script_byte_vars.game_paused = 0;
+ return 1;
+}
+
+#define SAVEADDR(value, base, nativesize, origsize, origbase) \
+ LE16(((((unsigned char*)(value)) - (unsigned char*)(base)) / nativesize) * origsize + origbase)
+
+int SaveScena(void)
+{
+ int f;
+ int wlen;
+ unsigned short ofs16;
+
+ script_byte_vars.game_paused = 1;
+ BlitSpritesToBackBuffer();
+
+ f = open("SCENAx.BIN", O_CREAT | O_WRONLY | O_BINARY);
+ if(f == -1)
+ {
+ script_byte_vars.game_paused = 0;
+ return 1; /*error*/
+ }
+
+ ofs16 = SAVEADDR(script_vars[ScrPool0_WordVars0], &script_word_vars, 2, 2, CGA_SAVE_WORD_VARS_OFS);
+ wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+
+ ofs16 = SAVEADDR(script_vars[ScrPool1_WordVars1], &script_word_vars, 2, 2, CGA_SAVE_WORD_VARS_OFS);
+ wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+
+ ofs16 = SAVEADDR(script_vars[ScrPool2_ByteVars], &script_byte_vars, 1, 1, CGA_SAVE_BYTE_VARS_OFS);
+ wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+
+ ofs16 = SAVEADDR(script_vars[ScrPool3_CurrentItem], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
+ wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+
+ ofs16 = SAVEADDR(script_vars[ScrPool4_ZoneSpots], zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
+ wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+
+ ofs16 = SAVEADDR(script_vars[ScrPool5_Persons], pers_list, 1, 1, CGA_SAVE_PERS_OFS);
+ wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+
+ ofs16 = SAVEADDR(script_vars[ScrPool6_Inventory], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
+ wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+
+ ofs16 = SAVEADDR(script_vars[ScrPool7_Inventory38], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
+ wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+
+ ofs16 = SAVEADDR(script_vars[ScrPool8_CurrentPers], pers_list, 1, 1, CGA_SAVE_PERS_OFS);
+ wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+
+
+ /*TODO*/
+
+
+
+
+ wlen = write(f, frontbuffer, 0x3FFF);
+ if(wlen != 0x3FFF)
+ goto error;
+
+ wlen = write(f, backbuffer, 0x3FFF);
+ if(wlen != 0x3FFF)
+ goto error;
+
+ close(f);
+ script_byte_vars.game_paused = 0;
+ return 0;
+
+error:;
+ close(f);
+ script_byte_vars.game_paused = 0;
+ return 1;
+}
diff --git a/engines/chamber/savegame.h b/engines/chamber/savegame.h
new file mode 100644
index 00000000000..6327c46cd6f
--- /dev/null
+++ b/engines/chamber/savegame.h
@@ -0,0 +1,9 @@
+#ifndef _SAVEGAME_H_
+#define _SAVEGAME_H_
+
+int LoadScena(void);
+int SaveScena(void);
+void SaveRestartGame(void);
+void RestartGame(void);
+
+#endif
diff --git a/engines/chamber/script.c b/engines/chamber/script.c
new file mode 100644
index 00000000000..11ac73b5a49
--- /dev/null
+++ b/engines/chamber/script.c
@@ -0,0 +1,3497 @@
+#include <stdio.h>
+#include <string.h>
+#include "common.h"
+#include "script.h"
+#include "resdata.h"
+#include "cga.h"
+#include "cursor.h"
+#include "portrait.h"
+#include "input.h"
+#include "menu.h"
+#include "room.h"
+#include "dialog.h"
+#include "print.h"
+#include "anim.h"
+#include "invent.h"
+#include "sound.h"
+#include "savegame.h"
+
+#if 1
+#define DEBUG_SCRIPT
+char DEBUG_SCRIPT_LOG[] = "!script.log";
+#endif
+
+#include "scrvars.h"
+
+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;
+
+void *script_vars[ScrPools_MAX] = {
+ &script_word_vars,
+ &script_word_vars,
+ &script_byte_vars,
+ inventory_items,
+ zones_data,
+ pers_list,
+ inventory_items,
+ inventory_items + 38,
+ pers_list
+};
+
+unsigned char 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;
+ return r | Rand();
+}
+
+unsigned int Swap16(unsigned int x)
+{
+ return (x << 8) | (x >> 8);
+}
+
+/*Script handlers exit codes*/
+enum CommandStatus {
+ ScriptContinue = 0, /*run next script command normally*/
+ ScriptRerun = 1, /*abort current script, execute new command*/
+ /*TODO: maybe define ScriptRestartGame to support game restart?*/
+};
+
+unsigned int CMD_TRAP(void)
+{
+ printf("CMD TRAP\n");
+ PromptWait();
+ for(;;) ;
+ return 0;
+}
+
+unsigned int SCR_TRAP(void)
+{
+ printf("SCR TRAP 0x%02X @ 0x%X\n", *script_ptr, script_ptr - templ_data);
+ PromptWait();
+ for(;;) ;
+ return 0;
+}
+
+
+void ClaimTradedItems(void)
+{
+ int 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;
+
+ item_t *item1, *item2;
+
+ script_ptr++;
+ old_script = script_ptr;
+
+ for(;;)
+ {
+ inv_bgcolor = 0xFF;
+ OpenInventory(0xFE, ITEMFLG_80);
+
+ if(inv_count == 0)
+ {
+ the_command = 0xC1BC;
+ RunCommand();
+ break;
+ }
+
+ if(the_command == 0)
+ {
+ the_command = 0xC1C0;
+ RunCommand();
+ break;
+ }
+
+ the_command = 0x9140;
+
+ if(pers_ptr->item == 0)
+ break;
+
+ item1 = &inventory_items[pers_ptr->item - 1];
+ item2 = (item_t*)(script_vars[ScrPool3_CurrentItem]);
+
+ if(item2->flags == (ITEMFLG_80 | 1) || item1->name == item2->name)
+ {
+ the_command = 0xC1C0;
+ RunCommand();
+ break;
+ }
+
+ if(item2->name == 109
+ || item2->name == 132
+ || item2->name == 108
+ || script_byte_vars.rand_value < 154)
+ {
+ item2->flags = ITEMFLG_20;
+ item1->flags = ITEMFLG_80;
+ pers_ptr->item = script_byte_vars.inv_item_index;
+ switch(item2->name)
+ {
+ case 132:
+ script_byte_vars.room_items--;
+ the_command = 0xC04B;
+ break;
+ case 104:
+ the_command = 0xC1BA;
+ break;
+ case 107:
+ the_command = 0xC1BB;
+ break;
+ default:
+ the_command = 0xC1BA;
+ }
+ RunCommand();
+ break;
+ }
+ else
+ {
+ item2->flags = ITEMFLG_80 | 1;
+ the_command = 0xC1BD;
+ RunCommand();
+ continue;
+ }
+ }
+
+ ClaimTradedItems();
+
+ script_ptr = old_script;
+ script_end_ptr = old_script_end;
+
+ return 0;
+}
+
+
+unsigned char wait_delta = 0;
+
+void Wait(unsigned char seconds)
+{
+ struct time t;
+ unsigned int endtime;
+
+ seconds += wait_delta;
+ if(seconds > 127) /*TODO: is this a check for an unsigned value?*/
+ seconds = 0;
+
+ gettime(&t);
+ endtime = t.ti_sec * 100 + t.ti_hund + seconds * 100;
+
+ while(buttons == 0)
+ {
+ unsigned int current;
+ gettime(&t);
+ current = t.ti_sec * 100 + t.ti_hund;
+ if(endtime >= 6000 && current < 2048) /*TODO: some kind of overflow check???*/
+ current += 6000;
+ if(current >= endtime)
+ break;
+ }
+}
+
+unsigned int SCR_2C_Wait4(void)
+{
+ script_ptr++;
+ Wait(4);
+ return 0;
+}
+
+unsigned int SCR_2D_Wait(void)
+{
+ unsigned char seconds;
+ script_ptr++;
+ seconds = *script_ptr++;
+ Wait(4); /*TODO: looks like a bug?*/
+ return 0;
+}
+
+unsigned int SCR_2E_PromptWait(void)
+{
+ script_ptr++;
+ PromptWait();
+ return 0;
+}
+
+
+#define VARTYPE_VAR 0x80
+#define VARTYPE_BLOCK 0x40
+#define VARTYPE_WORD 0x20
+#define VARTYPE_KIND 0x1F
+
+#define VARSIZE_BYTE 0
+#define VARSIZE_WORD 1
+
+unsigned char var_size;
+
+unsigned short LoadVar(unsigned char **ptr, unsigned char **varptr)
+{
+ unsigned char vartype;
+ unsigned char *varbase;
+ unsigned short value = 0;
+ var_size = VARSIZE_BYTE;
+ vartype = *((*ptr)++);
+ if(vartype & VARTYPE_VAR)
+ {
+ /*variable*/
+ unsigned char varoffs;
+ varbase = (unsigned char*)script_vars[vartype & VARTYPE_KIND];
+ if(vartype & VARTYPE_BLOCK)
+ {
+ unsigned char *end;
+ unsigned char index = *((*ptr)++);
+ varbase = SeekToEntryW(varbase, index, &end);
+ }
+ varoffs = *((*ptr)++);
+#if 1
+ {
+ int maxoffs = 0;
+ switch(vartype & VARTYPE_KIND)
+ {
+ case ScrPool0_WordVars0:
+ case ScrPool1_WordVars1:
+ maxoffs = sizeof(script_word_vars);
+ break;
+ case ScrPool2_ByteVars:
+ maxoffs = sizeof(script_byte_vars);
+ break;
+ case ScrPool3_CurrentItem:
+ maxoffs = sizeof(item_t);
+ break;
+ case ScrPool4_ZoneSpots:
+ maxoffs = RES_ZONES_MAX;
+ break;
+ case ScrPool5_Persons:
+ maxoffs = sizeof(pers_list);
+ break;
+ case ScrPool6_Inventory:
+ maxoffs = sizeof(inventory_items);
+ break;
+ case ScrPool7_Inventory38:
+ maxoffs = sizeof(inventory_items) - sizeof(item_t) * 38;
+ break;
+ case ScrPool8_CurrentPers:
+ maxoffs = sizeof(pers_t);
+ 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);
+ PromptWait();
+ }
+ }
+#endif
+ value = varbase[varoffs];
+ if(vartype & VARTYPE_WORD)
+ {
+ value = (value << 8) | varbase[varoffs + 1];
+ var_size = VARSIZE_WORD;
+ }
+ *varptr = &varbase[varoffs];
+
+#if 0
+/*TODO: debug stuff, remove me*/
+ if(varoffs == 0x48)
+ printf("Var 2.%X = %X\n", varoffs, value);
+#endif
+ }
+ else
+ {
+ /*immediate value*/
+ value = *((*ptr)++);
+ if(vartype & VARTYPE_WORD)
+ {
+ value = (value << 8) | *((*ptr)++);
+ var_size = VARSIZE_WORD;
+ }
+ *varptr = 0;
+ }
+ return value;
+}
+
+#define MATHOP_END 0x80
+#define MATHOP_CMP 0x40
+
+#define MATHOP_ADD 0x20
+#define MATHOP_SUB 0x10
+#define MATHOP_AND 0x08
+#define MATHOP_OR 0x04
+#define MATHOP_XOR 0x02
+
+#define MATHOP_EQ 0x20
+#define MATHOP_B 0x10
+#define MATHOP_A 0x08
+#define MATHOP_NEQ 0x04
+#define MATHOP_LE 0x02
+#define MATHOP_GE 0x01
+
+unsigned short MathOp(unsigned char op, unsigned short op1, unsigned short op2)
+{
+ if(op & MATHOP_CMP)
+ {
+ if(op & MATHOP_EQ)
+ if(op1 == op2) return ~0;
+ if(op & MATHOP_B)
+ if(op1 < op2) return ~0;
+ if(op & MATHOP_A)
+ if(op1 > op2) return ~0;
+ if(op & MATHOP_NEQ)
+ if(op1 != op2) return ~0;
+ if(op & MATHOP_LE)
+ if((signed short)op1 <= (signed short)op2) return ~0;
+ if(op & MATHOP_GE)
+ if((signed short)op1 >= (signed short)op2) return ~0;
+ return 0;
+ }
+ else
+ {
+ if(op & MATHOP_ADD)
+ op1 += op2;
+ if(op & MATHOP_SUB)
+ op1 -= op2;
+ if(op & MATHOP_AND)
+ op1 &= op2;
+ if(op & MATHOP_OR)
+ op1 |= op2;
+ if(op & MATHOP_XOR)
+ op1 ^= op2;
+ return op1;
+ }
+}
+
+unsigned short MathExpr(unsigned char **ptr)
+{
+ unsigned char op;
+ unsigned short op1, op2;
+ unsigned char *opptr;
+ op1 = LoadVar(ptr, &opptr);
+ while(((op = *((*ptr)++)) & MATHOP_END) == 0)
+ {
+ op2 = LoadVar(ptr, &opptr);
+ op1 = MathOp(op, op1, op2);
+ }
+ return op1;
+}
+
+/*
+Math operations (assignment) on a variable
+*/
+unsigned int SCR_3B_MathExpr(void)
+{
+ unsigned short op1, op2;
+ unsigned char *opptr;
+
+ script_ptr++;
+
+ op1 = LoadVar(&script_ptr, &opptr);
+ op2 = MathExpr(&script_ptr);
+ if(var_size == VARSIZE_BYTE)
+ *opptr = op2 & 255;
+ else
+ {
+ opptr[0] = op2 >> 8; /*store in big-endian*/
+ opptr[1] = op2 & 255;
+ }
+
+ /*return op1;*/ /*previous value, never used?*/
+ return 0;
+}
+
+/*Jump to routine*/
+unsigned int SCR_12_Chain(void)
+{
+ script_ptr++;
+ the_command = *script_ptr++; /*little-endian*/
+ the_command |= (*script_ptr++) << 8;
+ script_ptr = GetScriptSubroutine(the_command - 1);
+ return 0;
+}
+
+/*
+Absolute jump
+Jumping past current routine ends the script
+*/
+unsigned int SCR_33_Jump(void)
+{
+ unsigned short offs;
+ script_ptr++;
+ offs = *script_ptr++; /*little-endian*/
+ offs |= (*script_ptr++) << 8;
+ script_ptr = templ_data + offs;
+ return 0;
+}
+
+/*
+Conditional jump (IF/ELSE block)
+*/
+unsigned int SCR_3C_CondExpr(void)
+{
+ script_ptr++;
+
+ if(MathExpr(&script_ptr))
+ {
+ /*fall to IF block*/
+ script_ptr += 2;
+ }
+ else
+ {
+ /*branch to ELSE block*/
+ script_ptr -= 1; /*simulate opcode byte for Jump handler*/
+ return SCR_33_Jump();
+ }
+ return 0;
+}
+
+/*
+Absolute subroutine call
+*/
+unsigned int SCR_34_Call(void)
+{
+ unsigned short offs;
+ script_ptr++;
+ offs = *script_ptr++; /*little-endian*/
+ offs |= (*script_ptr++) << 8;
+ *script_stack_ptr++ = script_ptr;
+ *script_stack_ptr++ = script_end_ptr;
+ script_ptr = templ_data + offs;
+ return 0;
+}
+
+/*
+Return from script subroutine
+*/
+unsigned int 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;
+
+ script_ptr++;
+
+ if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ return 0;
+
+ /*TODO: use local args instead of globals*/
+ CGA_AnimLiftToRight(width, cur_image_pixels + width - 1, width, 1, height, CGA_SCREENBUFFER, CGA_CalcXY_p(x, y));
+ return 0;
+}
+
+/*Draw portrait, pushing it from right to left*/
+unsigned int SCR_6_DrawPortraitLiftLeft(void)
+{
+ unsigned char x, y, width, height;
+
+ script_ptr++;
+
+ if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ return 0;
+
+ /*TODO: use local args instead of globals*/
+ CGA_AnimLiftToLeft(width, cur_image_pixels, width, 1, height, CGA_SCREENBUFFER, CGA_CalcXY_p(x + width - 1, y));
+ return 0;
+}
+
+/*Draw portrait, pushing it from top to bottom*/
+unsigned int SCR_7_DrawPortraitLiftDown(void)
+{
+ unsigned char x, y, width, height;
+
+ script_ptr++;
+
+ if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ return 0;
+
+ /*TODO: use local args instead of globals*/
+ CGA_AnimLiftToDown(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
+ return 0;
+}
+
+/*Draw portrait, pushing it from bottom to top*/
+unsigned int SCR_8_DrawPortraitLiftUp(void)
+{
+ unsigned char x, y, width, height;
+
+ script_ptr++;
+
+ if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ return 0;
+
+ /*TODO: use local args instead of globals*/
+ CGA_AnimLiftToUp(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, x, y + height - 1);
+ return 0;
+}
+
+/*Draw portrait, no special effects*/
+unsigned int SCR_9_DrawPortrait(void)
+{
+ unsigned char x, y, width, height;
+
+ script_ptr++;
+
+ if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ return 0;
+
+ CGA_BlitAndWait(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
+ return 0;
+}
+
+/*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;
+ sx = x * 4;
+ ex = x * 4 + width * 4 - 1;
+ sy = y;
+ ey = y + height - 1;
+
+ for(i = 0;i < width * 4;i++)
+ {
+ CGA_TraceLine(sx, ex, sy, ey, source, target);
+ WaitVBlank();
+ sx += 1;
+ ex -= 1;
+ }
+
+ t = sx;
+ sx = ex + 1;
+ ex = t - 1;
+
+ t = sy;
+ sy = ey;
+ ey = t;
+
+ for(i = 0;i < height;i++)
+ {
+ CGA_TraceLine(sx, ex, sy, ey, source, target);
+ WaitVBlank();
+ sy -= 1;
+ ey += 1;
+ }
+}
+
+/*Draw image with twist-effect*/
+unsigned int SCR_B_DrawPortraitTwistEffect(void)
+{
+ unsigned char x, y, width, height;
+ unsigned int offs;
+
+ script_ptr++;
+
+ if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ return 0;
+
+ offs = CGA_CalcXY_p(x, y);
+
+ CGA_SwapScreenRect(cur_image_pixels, width, height, backbuffer, offs);
+ TwistDraw(x, y, width, height, backbuffer, frontbuffer);
+ CGA_BlitAndWait(scratch_mem2, width, width, height, backbuffer, offs);
+
+ return 0;
+}
+
+/*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;
+ sx = x * 4;
+ ex = x * 4 + width * 2 - 1;
+ sy = y + height - 1;
+ ey = y + height - 1;
+
+ for(i = 0;i < height;i++)
+ {
+ CGA_TraceLine(sx, ex, sy, ey, source, target);
+ WaitVBlank();
+ sy -= 1;
+ }
+
+ for(i = 0;i < width * 4;i++)
+ {
+ CGA_TraceLine(sx, ex, sy, ey, source, target);
+ WaitVBlank();
+ sx += 1;
+ }
+
+ for(i = 0;i < height + 1;i++)
+ {
+ CGA_TraceLine(sx, ex, sy, ey, source, target);
+ WaitVBlank();
+ sy += 1;
+ }
+}
+
+/*Draw image with arc-effect*/
+unsigned int SCR_C_DrawPortraitArcEffect(void)
+{
+ unsigned char x, y, width, height;
+ unsigned int offs;
+
+ script_ptr++;
+
+ if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ return 0;
+
+ offs = CGA_CalcXY_p(x, y);
+
+ CGA_SwapScreenRect(cur_image_pixels, width, height, backbuffer, offs);
+ ArcDraw(x, y, width, height, backbuffer, frontbuffer);
+ CGA_BlitAndWait(scratch_mem2, width, width, height, backbuffer, offs);
+
+ return 0;
+}
+
+/*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;
+
+ script_ptr++;
+
+ if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ return 0;
+
+ cur_image_end = width * height;
+
+ for(offs = 0;offs != cur_image_end;)
+ {
+ target[CGA_CalcXY_p(x + offs % cur_image_size_w, y + offs / cur_image_size_w)] = cur_image_pixels[offs];
+ for(i = 0;i < 255;i++) ; /*TODO FIXME weak delay*/
+ offs += step;
+ if(offs > cur_image_end)
+ offs -= cur_image_end;
+ }
+ return 0;
+}
+
+/*Draw image with slow zoom-in reveal effect*/
+unsigned int SCR_E_DrawPortraitZoomIn(void)
+{
+ unsigned char x, y, width, height;
+
+ script_ptr++;
+
+ if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ return 0;
+
+ /*TODO*/
+
+ CGA_BlitAndWait(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
+
+ return 0;
+}
+
+
+/*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;
+
+ script_ptr++;
+ index = *script_ptr++;
+
+ GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ if(right_button)
+ {
+ CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ return 0;
+ }
+
+ /*TODO: This originally was done by reusing door sliding routine*/
+
+ /*offs = CGA_CalcXY_p(x + 1, y);*/
+ offs++;
+
+ while(--width)
+ {
+ CGA_HideScreenBlockLiftToLeft(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ }
+
+ offs--;
+
+ /*hide leftmost line*/
+ /*TODO: move this to CGA?*/
+ while(height--)
+ {
+ memcpy(frontbuffer + offs, backbuffer + offs, 1);
+
+ offs ^= CGA_ODD_LINES_OFS;
+ if((offs & CGA_ODD_LINES_OFS) == 0)
+ offs += CGA_BYTES_PER_LINE;
+ }
+
+ return 0;
+}
+
+/*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;
+
+ script_ptr++;
+ index = *script_ptr++;
+
+ GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ if(right_button)
+ {
+ CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ return 0;
+ }
+
+ /*TODO: This originally was done by reusing door sliding routine*/
+
+ offs = CGA_CalcXY_p(x + width - 2, y);
+
+ while(--width)
+ {
+ CGA_HideScreenBlockLiftToRight(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ }
+
+ offs++;
+
+ /*hide leftmost line*/
+ /*TODO: move this to CGA?*/
+ while(height--)
+ {
+ memcpy(frontbuffer + offs, backbuffer + offs, 1);
+
+ offs ^= CGA_ODD_LINES_OFS;
+ if((offs & CGA_ODD_LINES_OFS) == 0)
+ offs += CGA_BYTES_PER_LINE;
+ }
+
+ return 0;
+}
+
+/*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;
+
+ script_ptr++;
+ index = *script_ptr++;
+
+ GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ if(right_button)
+ {
+ CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ return 0;
+ }
+
+ offs = CGA_CalcXY_p(x, y + 1);
+
+ while(--height)
+ {
+ CGA_HideScreenBlockLiftToUp(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ }
+
+ /*hide topmost line*/
+ /*TODO: move this to CGA?*/
+ offs ^= CGA_ODD_LINES_OFS;
+ if((offs & CGA_ODD_LINES_OFS) != 0)
+ offs -= CGA_BYTES_PER_LINE;
+ memcpy(CGA_SCREENBUFFER + offs, backbuffer + offs, width);
+ return 0;
+}
+
+
+/*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;
+
+ script_ptr++;
+ index = *script_ptr++;
+
+ GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ if(right_button)
+ {
+ CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ return 0;
+ }
+
+ offs = CGA_CalcXY_p(x, y + height - 2);
+
+ while(--height)
+ {
+ CGA_HideScreenBlockLiftToDown(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ }
+
+ /*hide bottommost line*/
+ /*TODO: move this to CGA?*/
+ offs ^= CGA_ODD_LINES_OFS;
+ if((offs & CGA_ODD_LINES_OFS) == 0)
+ offs += CGA_BYTES_PER_LINE;
+ memcpy(CGA_SCREENBUFFER + offs, backbuffer + offs, width);
+ return 0;
+}
+
+
+/*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;
+
+ script_ptr++;
+ index = *script_ptr++;
+
+ GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ if(right_button)
+ {
+ CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ return 0;
+ }
+
+ TwistDraw(x, y, width, height, backbuffer, frontbuffer);
+
+ return 0;
+}
+
+/*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;
+
+ script_ptr++;
+ index = *script_ptr++;
+
+ GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ if(right_button)
+ {
+ CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ return 0;
+ }
+
+ ArcDraw(x, y, width, height, backbuffer, frontbuffer);
+
+ return 0;
+}
+
+/*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;
+
+ script_ptr++;
+ index = *script_ptr++;
+
+ GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ if(right_button)
+ {
+ CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ return 0;
+ }
+
+ dot_effect_step = 17;
+ dot_effect_delay = 100;
+ CopyScreenBlockWithDotEffect(backbuffer, x, y, width, height, frontbuffer);
+
+ return 0;
+}
+
+
+unsigned int SCR_39_AnimRoomDoorOpen(void)
+{
+ unsigned char door;
+
+ script_ptr++;
+ door = *script_ptr++;
+ AnimRoomDoorOpen(door);
+ return 0;
+}
+
+unsigned int SCR_3A_AnimRoomDoorClose(void)
+{
+ unsigned char door;
+
+ script_ptr++;
+ door = *script_ptr++;
+ AnimRoomDoorClose(door);
+ return 0;
+}
+
+unsigned int SCR_25_ChangeZoneOnly(void)
+{
+ unsigned char index;
+ unsigned char old = script_byte_vars.zone_room;
+
+ script_ptr++;
+ index = *script_ptr++;
+
+ ChangeZone(index);
+ script_byte_vars.zone_room = old;
+ return 0;
+}
+
+
+void JaggedZoom(void)
+{
+ /*TODO*/
+}
+
+void InitStarfield(void)
+{
+ /*TODO*/
+}
+
+void AnimStarfield(void)
+{
+ /*TODO*/
+}
+
+unsigned int SCR_26_GameOver(void)
+{
+ in_de_profundis = 0;
+ script_byte_vars.game_paused = 1;
+ memset(backbuffer, 0, sizeof(backbuffer) - 2); /*TODO: original bug?*/
+ JaggedZoom();
+ CGA_BackBufferToRealFull();
+ CGA_ColorSelect(0x30);
+ InitStarfield();
+ AnimStarfield();
+ PlayAnim(44, 156/4, 95);
+ script_byte_vars.zone_index = 135;
+ JaggedZoom();
+ CGA_BackBufferToRealFull();
+ /*RestartGame();*/
+ /*TODO: this should shomehow abort all current scripts/calls and restart the game*/
+ TODO("Restart");
+
+ return 0;
+}
+
+
+unsigned int SCR_4C_DrawZoneObjs(void)
+{
+ script_ptr++;
+ DrawZoneObjs();
+ return 0;
+}
+
+
+unsigned int SCR_13_RedrawRoomStatics(void)
+{
+ unsigned char index;
+ script_ptr++;
+ index = *script_ptr++;
+ RedrawRoomStatics(index, 0);
+ return 0;
+}
+
+/*
+Load and draw zone (to backbuffer)
+*/
+unsigned int SCR_42_LoadZone(void)
+{
+ unsigned char index;
+
+ script_ptr++;
+ index = *script_ptr++;
+
+ zone_drawn = 0;
+ if(right_button)
+ script_byte_vars.byte_179B8 = 0;
+ else
+ {
+ if((script_byte_vars.cur_spot_flags & (SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8)) == 0)
+ script_byte_vars.byte_179B8 = script_byte_vars.cur_spot_flags & 7;
+ else if((script_byte_vars.cur_spot_flags & ((SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8))) == SPOTFLG_8)
+ {
+ zone_drawn = 1;
+ AnimRoomDoorOpen(script_byte_vars.cur_spot_idx);
+ script_byte_vars.byte_179B8 = script_byte_vars.cur_spot_flags & 7;
+ }
+ else
+ script_byte_vars.byte_179B8 = 0;
+ }
+ UpdateZoneSpot(index);
+ ChangeZone(index);
+ script_byte_vars.zone_area_copy = script_byte_vars.zone_area;
+ script_byte_vars.cur_spot_idx = FindInitialSpot();
+ zone_drawn |= script_byte_vars.cur_spot_idx;
+
+ DrawRoomStatics();
+
+ if(script_byte_vars.byte_17A15 != 0)
+ {
+ RedrawRoomStatics(script_byte_vars.byte_17A15, 0);
+ script_byte_vars.byte_17A15 = 0;
+ }
+
+ BackupSpotsImages();
+ PrepareCommand3();
+ PrepareCommand4();
+ PrepareCommand1();
+ DrawZoneObjs();
+ script_byte_vars.cur_spot_flags = 0;
+ return 0;
+}
+
+unsigned int SCR_59_BlitSpritesToBackBuffer(void)
+{
+ script_ptr++;
+ BlitSpritesToBackBuffer();
+ return 0;
+}
+
+unsigned int SCR_5A_SelectPalette(void)
+{
+ script_ptr++;
+ SelectPalette();
+ return 0;
+}
+
+unsigned int SCR_43_RefreshZone(void)
+{
+ script_ptr++;
+ RefreshZone();
+ return 0;
+}
+
+
+unsigned int 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];
+
+ script_ptr++;
+ obj[0] = *script_ptr++; /*spr*/
+ obj[1] = *script_ptr++; /*x*/
+ obj[2] = *script_ptr++; /*y*/
+
+ DrawRoomStaticObject(obj, x, y, w, h);
+}
+
+unsigned int SCR_5F_DrawRoomObjectBack(void)
+{
+ unsigned char x, y, w, h;
+ SCR_DrawRoomObjectBack(&x, &y, &w, &h);
+ return 0;
+}
+
+unsigned int SCR_11_DrawRoomObject(void)
+{
+ unsigned char x, y, w, h;
+ SCR_DrawRoomObjectBack(&x, &y, &w, &h);
+ CGA_CopyScreenBlock(backbuffer, w, h, CGA_SCREENBUFFER, CGA_CalcXY_p(x, y));
+ return 0;
+}
+
+/*
+Draw box with item sprite and its name
+*/
+unsigned int SCR_3_DrawItemBox(void)
+{
+ unsigned char current;
+
+ item_t *item;
+ unsigned char x, y;
+ unsigned char *msg;
+
+ script_ptr++;
+ current = *script_ptr++;
+
+ if(current)
+ item = (item_t*)script_vars[ScrPool3_CurrentItem];
+ else
+ item = &inventory_items[pers_ptr->item - 1];
+
+ x = dirty_rects[0].x;
+ y = dirty_rects[0].y + 70;
+ msg = SeekToString(desci_data, 274 + item->name);
+
+ DesciTextBox(x, y, 18, msg);
+ DrawSpriteN(item->sprite, x, y + 1, CGA_SCREENBUFFER);
+
+ return 0;
+}
+
+/*Draw simple bubble with text*/
+unsigned int SCR_37_DesciTextBox(void)
+{
+ unsigned char x, y, w;
+ unsigned char *msg;
+ script_ptr++;
+ msg = SeekToStringScr(desci_data, *script_ptr, &script_ptr);
+ script_ptr++;
+ x = *script_ptr++;
+ y = *script_ptr++;
+ w = *script_ptr++;
+ DesciTextBox(x, y, w, msg);
+ return 0;
+}
+
+
+/*Play portrait animation*/
+unsigned int SCR_18_AnimPortrait(void)
+{
+ unsigned char layer, index, delay;
+ script_ptr++;
+
+ layer = *script_ptr++;
+ index = *script_ptr++;
+ delay = *script_ptr++;
+
+ AnimPortrait(layer, index, delay);
+
+ return 0;
+}
+
+/*Play animation*/
+unsigned int SCR_38_PlayAnim(void)
+{
+ unsigned char index, x, y;
+ script_ptr++;
+ index = *script_ptr++;
+ x = *script_ptr++;
+ y = *script_ptr++;
+ PlayAnim(index, x, y);
+ return 0;
+}
+
+/*Pop up the actions menu and handle its commands*/
+unsigned int SCR_3D_ActionsMenu(void)
+{
+ unsigned short cmd;
+
+ unsigned char *old_script = script_ptr;
+ unsigned char *old_script_end = script_end_ptr;
+
+ act_menu_x = 0xFF;
+
+ for(;;)
+ {
+ script_ptr++;
+ ActionsMenu(&script_ptr);
+ if(the_command == 0xFFFF)
+ break;
+
+ cmd = the_command & 0xF000;
+ if(cmd == 0xC000 || cmd == 0xA000)
+ {
+ return ScriptRerun;
+ }
+
+ RunCommand();
+
+ script_byte_vars.used_commands++;
+
+ if(script_byte_vars.byte_179F9 == 0 && script_byte_vars.check_used_commands < script_byte_vars.used_commands)
+ {
+ the_command = Swap16(script_word_vars.next_command1);
+ if(the_command)
+ return ScriptRerun;
+ }
+
+ script_ptr = old_script;
+ if(--script_byte_vars.tries_left == 0)
+ ResetAllPersons();
+ }
+
+ script_end_ptr = old_script_end;
+ return ScriptContinue;
+}
+
+/*The Wall room puzzle*/
+unsigned int SCR_3E_TheWallAdvance(void)
+{
+ script_ptr++;
+
+ script_byte_vars.the_wall_phase = (script_byte_vars.the_wall_phase + 1) % 4;
+ switch(script_byte_vars.the_wall_phase)
+ {
+ default:
+ TheWallPhase3();
+ break;
+ case 0:
+ TheWallPhase0();
+ break;
+ case 1:
+ TheWallPhase1_DoorClose1();
+ break;
+ case 2:
+ TheWallPhase2_DoorClose2();
+ break;
+ }
+
+ return 0;
+}
+
+/*
+When playing cups with proto
+*/
+unsigned int SCR_28_MenuLoop(void)
+{
+ unsigned char cursor;
+ unsigned char mask, value;
+
+ script_ptr++;
+ cursor = *script_ptr++;
+ mask = *script_ptr++;
+ value = *script_ptr++;
+
+ SelectCursor(cursor);
+
+ MenuLoop(mask, value);
+
+ return 0;
+}
+
+
+/*
+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;
+
+ script_ptr++;
+ index = *script_ptr++;
+
+ GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs); /*TODO: implicit target*/
+ CGA_CopyScreenBlock(backbuffer, 2, 21, CGA_SCREENBUFFER, offs = (x << 8) | y); /*TODO: implicit target*/
+
+ cur_dlg_index = 0;
+
+ return 0;
+}
+
+/*
+Restore screen data from back buffer as specified by dirty rect of kind dialog bubble
+*/
+unsigned int SCR_2B_PopAllBubbles(void)
+{
+ script_ptr++;
+ PopDirtyRects(DirtyRectBubble);
+ return 0;
+}
+
+/*
+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;
+
+ script_ptr++;
+ index = *script_ptr++;
+
+ GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ if(right_button)
+ {
+ CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ return 0;
+ }
+
+ CGA_HideShatterFall(CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
+
+ return 0;
+}
+
+/*
+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;
+
+ script_ptr++;
+ index = *script_ptr++;
+
+ GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ if(right_button)
+ {
+ CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ return 0;
+ }
+
+ CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+
+ return 0;
+}
+
+/*
+Restore screen data from back buffer for all portraits
+*/
+unsigned int SCR_24_PopAllPortraits(void)
+{
+ script_ptr++;
+ PopDirtyRects(DirtyRectSprite);
+ return 0;
+}
+
+/*
+Restore screen data from back buffer for all text bubbles
+*/
+unsigned int SCR_40_PopAllTextBoxes()
+{
+ script_ptr++;
+ PopDirtyRects(DirtyRectText);
+ return 0;
+}
+
+/*
+Move a Hand in Who Will Be Saved
+*/
+unsigned int SCR_41_LiftHand(void)
+{
+ script_ptr++;
+ RedrawRoomStatics(92, script_byte_vars.byte_179E1);
+ CGA_BackBufferToRealFull();
+ PlaySound(31);
+ return 0;
+}
+
+unsigned char fight_mode = 0;
+
+unsigned int SCR_30_Fight(void)
+{
+ static unsigned char player_image[] = {26, 0, 0};
+ unsigned char *image = player_image;
+
+ unsigned char x, y, width, height, kind;
+ unsigned int offs;
+ unsigned char *old_script, *old_script_end = script_end_ptr;
+ pers_t *pers = (pers_t*)(script_vars[ScrPool8_CurrentPers]);
+
+ unsigned char strenght, win, rnd;
+
+ script_ptr++;
+ old_script = script_ptr;
+
+ x = 140 / 4;
+ y = 20;
+
+ fight_mode = 1;
+
+ if(pers->name != 44)
+ {
+ if(next_command3 == 0xA015)
+ {
+ the_command = 0xA015;
+ RunCommand();
+ FindAndSelectSpot((pers - pers_list) * 5); /*TODO: FindAndSelectSpot assumes plain offset, 5-byte records*/
+ }
+ if(Swap16(script_word_vars.next_command1) == 0xC357)
+ {
+ the_command = 0xC357;
+ RunCommand();
+ }
+
+ pers = (pers_t*)(script_vars[ScrPool8_CurrentPers]);
+ if(pers->name != 56 && pers->name != 51)
+ {
+ x = dirty_rects[0].x + 64 / 4;
+ y = dirty_rects[0].y;
+ fight_mode = 0;
+ }
+ }
+
+ /*draw player portrait*/
+ player_image[1] = x;
+ player_image[2] = y;
+ if(DrawPortrait(&image, &x, &y, &width, &height))
+ CGA_AnimLiftToLeft(width, cur_image_pixels, width, 1, height, CGA_SCREENBUFFER, CGA_CalcXY_p(x + width - 1, y));
+
+ BlinkToWhite();
+
+ if(pers->name != 44 && pers->name != 56 && pers->name != 51)
+ {
+ GetDirtyRectAndFree(1, &kind, &x, &y, &width, &height, &offs);
+ CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ }
+
+ /*check fight outcome*/
+
+ strenght = 0;
+
+ 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};
+
+ strenght = character_strenght[pers->name - 42];
+
+ /*check if can decrease*/
+ if(strenght != 1 && (pers->flags & PERSFLG_80))
+ strenght--;
+
+ if(script_byte_vars.room_items != 0 || script_byte_vars.byte_17A1C != 0)
+ strenght--;
+ }
+
+ /*check if can increase*/
+ if(strenght != 5)
+ {
+ if((pers->item >= 19 && pers->item < 23)
+ || (pers->item >= 39 && pers->item < 52)
+ || pers->item == 56 || pers->item == 57
+ || ((pers->index >> 3) == 6))
+ strenght++;
+ }
+
+ win = 1;
+ rnd = script_byte_vars.rand_value;
+
+#ifdef CHEAT
+ strenght = 1;
+#endif
+
+ if(strenght >= 2)
+ {
+ if(strenght == 2)
+ {
+ if(rnd >= 205)
+ win = Rand() < 128 ? 81 : 82;
+ }
+ else if(strenght == 4 && rnd < 100)
+ {
+ win = Rand() < 128 ? 81 : 82;
+ }
+ else
+ {
+ win = 2;
+ if(strenght == 3)
+ {
+ if(rnd < 128) /*TODO: check me, maybe original bug (checks against wrong reg?)*/
+ win = Rand() < 51 ? 145 : 146;
+ else
+ win = Rand() < 205 ? 49 : 50;
+ }
+ }
+ }
+
+ script_byte_vars.byte_179F2 = win;
+
+ script_ptr = old_script;
+ script_end_ptr = old_script_end;
+ return 0;
+}
+
+unsigned char prev_fight_mode = 0;
+unsigned short fight_pers_ofs = 0;
+
+typedef struct fightentry_t {
+unsigned char room;
+animdesc_t anim;
+} fightentry_t;
+
+fightentry_t fightlist1[] = {
+ {50, {47, 36, 153}},
+ {51, {47, 36, 153}},
+ {53, {47, 37, 160}},
+ {54, {47, 36, 153}},
+ {56, {47, 31, 128}},
+ {57, {47, 27, 161}},
+ {58, {47, 28, 152}},
+ {59, {47, 25, 153}},
+ {60, {47, 22, 155}},
+ {61, {47, 27, 160}}
+};
+
+fightentry_t fightlist2[] = {
+ { 1, {24, 42, 128}},
+ { 2, {24, 44, 126}},
+ { 3, {24, 47, 126}},
+ { 4, {24, 44, 126}},
+ { 5, {24, 47, 126}},
+ { 6, {24, 28, 126}},
+ { 7, {24, 55, 126}},
+ { 8, {24, 49, 126}},
+ {10, {24, 41, 147}},
+ {11, {24, 41, 147}},
+ {18, {24, 41, 147}},
+ {19, {24, 41, 147}},
+ {90, {24, 44, 121}},
+ {91, {28, 24, 123}},
+ {12, {24, 41, 147}},
+ {13, {24, 41, 147}},
+ {35, {24, 39, 147}},
+ {42, {24, 39, 147}},
+ {50, {55, 46, 130}},
+ {52, {24, 42, 121}},
+ {54, {55, 46, 130}},
+ {61, {67, 37, 125}},
+ {62, {55, 32, 133}},
+ {63, {55, 32, 133}},
+ {64, {55, 32, 133}},
+ {65, {55, 32, 133}}
+};
+
+fightentry_t fightlist3[] = {
+ { 2, {25, 35, 144}},
+ { 3, {25, 38, 144}},
+ { 4, {25, 35, 144}},
+ { 5, {25, 38, 144}},
+ { 6, {25, 19, 144}},
+ { 7, {25, 46, 144}},
+ { 8, {26, 64, 132}},
+ {10, {25, 32, 165}},
+ {11, {25, 32, 165}},
+ {12, {25, 32, 165}},
+ {13, {25, 32, 165}},
+ {18, {25, 32, 165}},
+ {19, {25, 32, 165}},
+ {90, {36, 27, 127}},
+ {91, {27, 44, 123}},
+ {35, {25, 30, 165}},
+ {42, {25, 30, 165}},
+ {50, {56, 36, 153}},
+ {54, {56, 36, 153}},
+ {62, {56, 22, 156}},
+ {63, {56, 22, 156}},
+ {64, {56, 22, 156}},
+ {65, {56, 22, 156}}
+};
+
+/*Draw defeated enemy*/
+unsigned int 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*/
+ pers->flags |= PERSFLG_40;
+ pers->area = 0;
+ found_spot->flags &= ~SPOTFLG_80;
+ if(pers->index == 16)
+ {
+ pers_list[34].area = script_byte_vars.zone_area;
+ pers_list[34].flags = pers->flags;
+ if(script_byte_vars.room_items == 0)
+ {
+ static const animdesc_t anim19 = {ANIMFLG_USESPOT | 19};
+ AnimateSpot(&anim19);
+ }
+ the_command = next_command3;
+ RunCommand();
+ }
+ else if(pers->index == 8)
+ {
+ pers_list[35].area = script_byte_vars.zone_area;
+ pers_list[35].flags = pers->flags;
+ if(script_byte_vars.room_items == 0)
+ {
+ static const animdesc_t anim20 = {ANIMFLG_USESPOT | 20};
+ AnimateSpot(&anim20);
+ }
+ the_command = next_command3;
+ RunCommand();
+ }
+ else
+ {
+ if(prev_fight_mode == 0
+ && script_byte_vars.room_items != 0
+ && fight_mode == 0)
+ {
+ script_byte_vars.byte_179F2 &= ~1;
+ }
+ else
+ {
+ unsigned int i;
+ fightentry_t *fightlist;
+ unsigned int fightlistsize;
+ unsigned char animidx;
+
+ prev_fight_mode = 0;
+ switch(pers->name)
+ {
+ case 56:
+ animidx = 47;
+ fightlist = fightlist1;
+ fightlistsize = 10;
+ break;
+ case 51:
+ next_command4 = 0;
+ animidx = 66;
+ fightlist = fightlist1;
+ fightlistsize = 10;
+ break;
+ default:
+ animidx = 0;
+ fightlist = fightlist3;
+ fightlistsize = 26;
+ }
+
+ for(i = 0;i < fightlistsize;i++)
+ {
+ if(fightlist[i].room == script_byte_vars.zone_room)
+ {
+ if(animidx != 0)
+ fightlist[i].anim.index = animidx;
+ if(fightlist[i].anim.index == 55)
+ PlaySound(151);
+ PlayAnim(fightlist[i].anim.index, fightlist[i].anim.params.coords.x, fightlist[i].anim.params.coords.y);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return 0;
+}
+
+unsigned int SCR_32_FightWin(void)
+{
+
+ script_ptr++;
+
+ script_byte_vars.byte_17A1D = 0;
+
+ if(script_byte_vars.byte_179F9 != 18 && *spot_sprite != 0)
+ {
+ CGA_RestoreImage(*spot_sprite, frontbuffer);
+ CGA_RestoreImage(*spot_sprite, backbuffer);
+
+ if(script_byte_vars.byte_179F3 == 0
+ && script_byte_vars.byte_17A16 == 0
+ && script_byte_vars.room_items != 0
+ && fight_mode == 0)
+ {
+ script_byte_vars.byte_17A1D = 1;
+ PlaySound(149);
+ PlayAnim(40, found_spot->sx, found_spot->sy);
+ }
+ }
+
+ prev_fight_mode = script_byte_vars.byte_179F3;
+ script_byte_vars.byte_179F3 = 0;
+
+ return 0;
+}
+
+extern void ExitGame(void);
+
+unsigned int SCR_15_SelectSpot(void)
+{
+ unsigned char mask, index;
+
+ script_ptr++;
+ mask = *script_ptr++;
+ index = *script_ptr++;
+ if(mask != 0)
+ {
+ index = FindSpotByFlags(mask, index); /*TODO: return 0 if not found?*/
+ if(index == 0xFF)
+ {
+ TODO("ERROR: SelectSpot: spot not found");
+ ExitGame(); /*hard abort*/
+ }
+ }
+ found_spot = &zone_spots[index - 1];
+ script_byte_vars.cur_spot_idx = index;
+ spot_sprite = &sprites_list[index - 1];
+
+ FindPerson();
+
+ if(script_byte_vars.cur_pers == 0)
+ script_vars[ScrPool8_CurrentPers] = &pers_list[20];
+
+ return 0;
+}
+
+unsigned int SCR_44_BackBufferToScreen(void)
+{
+ script_ptr++;
+ CGA_BackBufferToRealFull();
+ return 0;
+}
+
+/*
+Animate De Profundis room on entry
+*/
+unsigned int SCR_45_DeProfundisRoomEntry(void)
+{
+ unsigned int w, h;
+ unsigned int sprofs, ofs;
+
+ script_ptr++;
+
+ /*draw Platform*/
+ sprofs = GetPuzzlSprite(3, 140 / 4, 174, &w, &h, &ofs);
+ CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+
+ /*draw Granite Monster*/
+ sprofs = GetPuzzlSprite(119, 128 / 4, 94, &w, &h, &ofs);
+ CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+
+ PromptWait();
+
+ for(;h;h--)
+ {
+ WaitVBlank();
+ WaitVBlank();
+ CGA_BlitFromBackBuffer(w, 1, CGA_SCREENBUFFER, ofs);
+
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+
+ CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+ }
+
+ CGA_BlitFromBackBuffer(w, 1, CGA_SCREENBUFFER, ofs);
+
+ return 0;
+}
+
+/*
+Animate De Profundis hook (lower)
+*/
+unsigned int SCR_46_DeProfundisLowerHook(void)
+{
+ unsigned char y;
+ unsigned int w, h;
+ unsigned int sprofs, ofs;
+
+ script_ptr++;
+
+ /*draw Hook*/
+ sprofs = GetPuzzlSprite(96, 140 / 4, 18, &w, &h, &ofs);
+
+ h = 1;
+ y = 15;
+ sprofs = y * 20 / 4 * 2; /*TODO: 20 is the sprite width. replace with w?*/
+
+ for(;y;y--)
+ {
+ WaitVBlank();
+ CGA_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
+
+ h++;
+ sprofs -= 20 / 4 * 2;
+
+ CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+ }
+
+ return 0;
+}
+
+/*
+Animate De Profundis monster (rise)
+*/
+unsigned int SCR_47_DeProfundisRiseMonster(void)
+{
+ unsigned char y;
+ unsigned int w, h;
+ unsigned int sprofs, ofs;
+
+ script_ptr++;
+
+ /*draw Granite Monster head*/
+ sprofs = GetPuzzlSprite(118, 112 / 4, 174, &w, &h, &ofs);
+
+ h = 1;
+ y = 68;
+
+ for(;y;y--)
+ {
+ WaitVBlank();
+
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) != 0)
+ ofs -= CGA_BYTES_PER_LINE;
+
+ h++;
+
+ CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+ }
+
+ return 0;
+}
+
+/*
+Animate De Profundis monster (lower)
+*/
+unsigned int SCR_48_DeProfundisLowerMonster(void)
+{
+ unsigned char y;
+ unsigned int w, h;
+ unsigned int sprofs, ofs;
+
+ script_ptr++;
+
+ /*draw Hook*/
+ sprofs = GetPuzzlSprite(118, 112 / 4, 106, &w, &h, &ofs);
+
+ y = 34;
+
+ for(;y;y--)
+ {
+ WaitVBlank();
+ CGA_BlitFromBackBuffer(w, 1, CGA_SCREENBUFFER, ofs);
+
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+
+ h--;
+ CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+ }
+
+ return 0;
+}
+
+/*
+Animate De Profundis hook (rise)
+*/
+unsigned int SCR_49_DeProfundisRiseHook(void)
+{
+ unsigned char y;
+ unsigned int w, h;
+ unsigned int sprofs, ofs;
+
+ script_ptr++;
+
+ /*draw Hook*/
+ sprofs = GetPuzzlSprite(96, 140 / 4, 18, &w, &h, &ofs);
+
+ h = 16;
+ y = 15;
+
+ for(;y;y--)
+ {
+ WaitVBlank();
+ CGA_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
+
+ h--;
+ sprofs += 20 / 4 * 2;
+
+ CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+ }
+
+ CGA_BlitFromBackBuffer(w, 1, CGA_SCREENBUFFER, ofs);
+
+ return 0;
+}
+
+
+/*
+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;
+
+ script_ptr++;
+ state = *script_ptr++;
+
+ x = 140 / 4;
+ y = 174;
+ if(state != 0)
+ y += 4;
+
+ /*draw Platform*/
+ sprofs = GetPuzzlSprite(3, x, y, &w, &h, &ofs);
+
+ y = 4;
+ if(state)
+ {
+ h -= 4;
+ y--;
+ }
+
+ for(;y;y--)
+ {
+ WaitVBlank();
+ CGA_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
+
+ ofs ^= CGA_ODD_LINES_OFS;
+ if((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+
+ h--;
+
+ CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+ }
+
+ if(state)
+ CGA_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
+
+ return 0;
+}
+
+/*
+Animate De Profundis monster ride to exit door
+*/
+unsigned int SCR_66_DeProfundisRideToExit(void)
+{
+ unsigned int w, h;
+ unsigned int sprofs, ofs;
+
+ script_ptr++;
+
+ /*draw Granite Monster*/
+ sprofs = GetPuzzlSprite(119, 128 / 4, 139, &w, &h, &ofs);
+
+ CGA_BlitScratchBackSprite(sprofs, w, 20, backbuffer, ofs);
+
+ dot_effect_delay = 1;
+ dot_effect_step = 17;
+ CopyScreenBlockWithDotEffect(backbuffer, 112 / 4, 139, 72 / 4, 40, frontbuffer);
+
+ return 0;
+}
+
+/*
+Draw item bounce to room objects animation
+*/
+unsigned int SCR_4E_BounceCurrentItemToRoom(void)
+{
+ script_ptr++;
+ BounceCurrentItem(ITEMFLG_40, 43);
+ return 0;
+}
+
+/*
+Draw item bounce to inventory animation
+*/
+unsigned int SCR_4F_BounceCurrentItemToInventory(void)
+{
+ script_ptr++;
+ BounceCurrentItem(ITEMFLG_80, 85);
+ return 0;
+}
+
+/*
+Draw item bounce to inventory animation
+*/
+unsigned int SCR_50_BounceItemToInventory(void)
+{
+ unsigned char itemidx;
+
+ script_ptr++;
+ itemidx = *script_ptr++;
+ script_vars[ScrPool3_CurrentItem] = &inventory_items[itemidx - 1];
+
+ BounceCurrentItem(ITEMFLG_80, 85);
+ return 0;
+}
+
+unsigned int SCR_51_ItemTrade(void)
+{
+ unsigned char *old_script, *old_script_end = script_end_ptr;
+ unsigned char status;
+
+ if(script_byte_vars.byte_179DC >= 63) /*TODO: hang?*/
+ return 0;
+
+ script_ptr++;
+ old_script = script_ptr;
+
+ inv_bgcolor = 0xFF;
+ OpenInventory(0xFF, ITEMFLG_80);
+
+ status = 1;
+ if(inv_count != 0)
+ {
+ status = 2;
+ if(the_command != 0)
+ {
+ status = 3;
+ if(script_byte_vars.inv_item_index >= 6 && script_byte_vars.inv_item_index < 27)
+ {
+ the_command = 0xC204;
+ RunCommand();
+
+ ((item_t*)(script_vars[ScrPool3_CurrentItem]))->flags = 0;
+
+ OpenInventory(0xFF, ITEMFLG_10);
+
+ status = 4;
+ if(the_command != 0)
+ {
+ status = 5;
+ if(script_byte_vars.rand_value < 128)
+ {
+ status = 6;
+ ((item_t*)(script_vars[ScrPool3_CurrentItem]))[-1].flags = ITEMFLG_10; /*TODO: what's up with this index?*/
+ ((item_t*)(script_vars[ScrPool3_CurrentItem]))->flags = 0;
+ }
+ }
+ }
+ }
+ }
+
+ script_byte_vars.trade_status = status;
+
+ script_ptr = old_script;
+ script_end_ptr = old_script_end;
+
+ return 0;
+}
+
+unsigned int SCR_52_RefreshSpritesData(void)
+{
+ script_ptr++;
+ RefreshSpritesData();
+ return 0;
+}
+
+unsigned int SCR_53_FindInvItem(void)
+{
+ unsigned char first, count, flags, i;
+ item_t *item;
+ script_ptr++;
+ first = *script_ptr++;
+ count = *script_ptr++;
+ flags = *script_ptr++;
+ item = &inventory_items[first - 1];
+ for(i = 0;i < count;i++)
+ {
+ if(item[i].flags == flags)
+ {
+ script_vars[ScrPool3_CurrentItem] = &item[i];
+ return 0;
+ }
+ }
+ script_vars[ScrPool3_CurrentItem] = &item[count - 1];
+ return 0;
+}
+
+
+unsigned int SCR_64_DrawBoxAroundSpot(void)
+{
+ script_ptr++;
+ DrawBoxAroundSpot();
+ return 0;
+}
+
+/*
+Draw text box
+*/
+unsigned int SCR_14_DrawDesc(void)
+{
+ unsigned char *msg;
+ script_ptr++;
+ msg = SeekToStringScr(desci_data, *script_ptr, &script_ptr);
+ script_ptr++;
+
+ DrawMessage(msg, CGA_SCREENBUFFER);
+
+ return 0;
+}
+
+
+/*
+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;
+ script_ptr++;
+ msg = SeekToStringScr(diali_data, *script_ptr, &script_ptr);
+ script_ptr++;
+
+ x = found_spot->sx;
+ y = found_spot->sy;
+
+ if(x < 140/4)
+ DrawPersonBubble(found_spot->ex, y - 40, SPIKE_BUBLEFT | 20, msg);
+ else
+ DrawPersonBubble(x - 80/4, y - 40, SPIKE_BUBRIGHT | 20, msg);
+
+ PromptWait();
+ PopDirtyRects(DirtyRectBubble);
+ return 0;
+}
+
+/*
+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;
+ script_ptr++;
+ msg = SeekToStringScr(diali_data, *script_ptr, &script_ptr);
+ script_ptr++;
+
+ x = found_spot->sx;
+ y = found_spot->sy;
+
+ if(x < 140/4)
+ DrawPersonBubble(found_spot->ex, y - 40, SPIKE_DNLEFT | 20, msg);
+ else
+ DrawPersonBubble(x - 80/4, y - 40, SPIKE_DNRIGHT | 20, msg);
+
+ PromptWait();
+ PopDirtyRects(DirtyRectBubble);
+ return 0;
+}
+
+#if 1
+#include <stdio.h>
+unsigned char * DebugString(char *msg, ...)
+{
+ int i;
+ unsigned char c;
+ static unsigned char m[256];
+ va_list ap;
+
+ va_start(ap,msg);
+ vsprintf((char*)m,msg,ap);
+ va_end(ap);
+
+ for(i = 0;m[i];i++)
+ {
+ c = m[i];
+ if(c >= 'A' && c <= 'Z')
+ c = 0x21 + (c - 'A');
+ else if(c >= 'a' && c <= 'z')
+ c = 0x21 + (c - 'a');
+ else if(c >= '0' && c <= '9')
+ c = 0x10 + (c - '0');
+ else if(c == ' ')
+ c = 0x20;
+ else if(c == '!')
+ c = 0x01;
+ else if(c == ',')
+ c = 0x0C;
+ else if(c == '.')
+ c = 0x0E;
+ else if(c == '\n')
+ c = 0x00;
+ else
+ c = 0x1F;
+ m[i] = c;
+ }
+
+ cur_str_end = m + i;
+
+ return m;
+}
+#endif
+
+/*
+Draw dialog bubble with text for gauss
+*/
+unsigned int SCR_27_DrawGaussBubble(void)
+{
+ unsigned char *msg;
+
+ script_ptr++;
+ msg = SeekToStringScr(diali_data, *script_ptr, &script_ptr);
+ script_ptr++;
+
+ DrawPersonBubble(32/4, 20, 15, msg);
+ return 0;
+}
+
+/*
+Draw dialog bubble with text
+*/
+unsigned int SCR_29_DialiTextBox(void)
+{
+ unsigned char x, y, f;
+ unsigned char *msg;
+ script_ptr++;
+ msg = SeekToStringScr(diali_data, *script_ptr, &script_ptr);
+ cur_dlg_index = cur_str_index; /*TODO: useless?*/
+
+ script_ptr++;
+ x = *script_ptr++;
+ y = *script_ptr++;
+ f = *script_ptr++;
+
+ DrawPersonBubble(x, y, f, msg);
+ return 0;
+}
+
+/*
+Do nothing in PC/CGA version
+*/
+unsigned int SCR_67_Unused(void)
+{
+ script_ptr++;
+ script_ptr++;
+ return 0;
+}
+
+/*
+Do nothing in PC/CGA version
+*/
+unsigned int SCR_68_Unused(void)
+{
+ script_ptr++;
+ script_ptr++;
+ return 0;
+}
+
+/*
+Play sound
+*/
+unsigned int SCR_69_PlaySound(void)
+{
+ unsigned char index;
+ script_ptr++;
+ index = *script_ptr++;
+ script_ptr++;
+
+ PlaySound(index);
+ return 0;
+}
+
+/*
+Do nothing in PC/CGA version
+*/
+unsigned int SCR_6A_Unused(void)
+{
+ script_ptr++;
+ return 0;
+}
+
+/*
+Open room's items inventory
+*/
+unsigned int CMD_1_RoomObjects(void)
+{
+ UpdateUndrawCursor(CGA_SCREENBUFFER);
+ inv_bgcolor = 0xAA;
+ OpenInventory((0xFF << 8) | ITEMFLG_40, (script_byte_vars.zone_area << 8) | ITEMFLG_40);
+ return ScriptRerun;
+}
+
+/*
+Open Psi Powers menu
+*/
+unsigned int CMD_2_PsiPowers(void)
+{
+ /*Psi powers bar*/
+ BackupAndShowSprite(3, 280 / 4, 40);
+ ProcessInput();
+ do
+ {
+ PollInput();
+ SelectCursor(CURSOR_0);
+ CheckPsiCommandHover();
+ if(command_hint != 100)
+ command_hint += 109;
+ if(command_hint != last_command_hint)
+ DrawCommandHint();
+ DrawHintsAndCursor(CGA_SCREENBUFFER);
+ }
+ while(buttons == 0);
+ UndrawCursor(CGA_SCREENBUFFER);
+ CGA_RestoreBackupImage(CGA_SCREENBUFFER);
+ return ScriptRerun;
+}
+
+/*
+Open normal inventory box
+*/
+unsigned int CMD_3_Posessions(void)
+{
+ UpdateUndrawCursor(CGA_SCREENBUFFER);
+ inv_bgcolor = 0x55;
+ OpenInventory(ITEMFLG_80, ITEMFLG_80);
+ return ScriptRerun;
+}
+
+/*
+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;
+
+ PopDirtyRects(DirtyRectSprite);
+ PopDirtyRects(DirtyRectBubble);
+
+ if(script_byte_vars.psy_energy != 0)
+ anim = 41 + (script_byte_vars.psy_energy / 16);
+
+ 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
+ {
+ AnimPortrait(1, anim, 10);
+ AnimPortrait(1, anim + 14, 10);
+ PollInput();
+ }
+ while(buttons == 0);
+
+ PopDirtyRects(DirtyRectSprite);
+
+ return 0;
+}
+
+/*
+Advance time
+*/
+unsigned int CMD_5_Wait(void)
+{
+
+ script_byte_vars.byte_179DB++;
+ script_word_vars.timer_ticks2 = Swap16(Swap16(script_word_vars.timer_ticks2) + 300);
+
+ the_command = next_command3;
+ RunCommand();
+
+ the_command = next_command4;
+ RunCommand();
+
+ script_byte_vars.used_commands = script_byte_vars.check_used_commands;
+
+ the_command = Swap16(script_word_vars.word_17852);
+
+ if(the_command == 0)
+ {
+ if(script_word_vars.next_command1 == 0)
+ {
+ the_command = 0x9005;
+ RunCommand();
+ }
+ }
+ else
+ {
+ if(script_byte_vars.byte_179DC >= 63 && script_byte_vars.zone_area < 22 && script_byte_vars.zone_area != 1)
+ the_command = 0x9005;
+ return ScriptRerun;
+ }
+
+ return 0;
+}
+
+/*
+Load game (menu)
+*/
+unsigned int CMD_6_Load(void)
+{
+ the_command = 0xC35C;
+ return ScriptRerun;
+}
+
+/*
+Save game (menu)
+*/
+unsigned int CMD_7_Save(void)
+{
+ the_command = 0xC35D;
+ return ScriptRerun;
+}
+
+/*
+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;
+
+ 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);
+
+ char_draw_coords_x = 260/4;
+ char_draw_coords_y = 120;
+
+ WaitVBlank();
+ CGA_PrintChar(timer / (60 * 60) + 16, CGA_SCREENBUFFER);
+ CGA_PrintChar((minutes & 1) ? 26 : 0, CGA_SCREENBUFFER); /*colon*/
+ CGA_PrintChar(minutes / (60 * 10) + 16, CGA_SCREENBUFFER);
+ CGA_PrintChar(minutes / 60 + 16, CGA_SCREENBUFFER);
+ PollInput();
+ }
+ while(buttons == 0);
+
+ PopDirtyRects(DirtyRectSprite);
+
+ return 0;
+}
+
+int ConsumePsiEnergy(unsigned char amount)
+{
+ unsigned char current = script_byte_vars.psy_energy;
+
+ if(current < amount)
+ {
+ /*no energy left*/
+ PlayAnim(68, 296 / 4, 71);
+ return 0;
+ }
+
+ script_byte_vars.psy_energy = current - amount;
+
+ /*significantly changed?*/
+ if((current & 0xF0) != (script_byte_vars.psy_energy & 0xF0))
+ PlayAnim(68, 296 / 4, 71);
+
+ return 1;
+}
+
+unsigned int CMD_A_PsiSolarEyes(void)
+{
+ if(!ConsumePsiEnergy(2))
+ return 0;
+
+ if(zone_palette == 14)
+ {
+ RedrawRoomStatics(script_byte_vars.zone_room, zone_palette);
+ zone_palette = 0;
+ CGA_BackBufferToRealFull();
+ }
+
+ the_command = Swap16(script_word_vars.word_178EE);
+ RunCommand();
+ script_byte_vars.cur_spot_flags = 0xFF;
+
+ return 0;
+}
+
+
+unsigned short GetZoneObjCommand(unsigned int 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;
+
+ unsigned int ofs;
+ unsigned char *sprite = LoadPuzzlToScratch(80);
+
+ x = room_bounds_rect.sx;
+ y = room_bounds_rect.sy;
+ w = room_bounds_rect.ex - x;
+ h = room_bounds_rect.ey - y;
+
+ ofs = CGA_CalcXY_p(x, y);
+
+ /*16x30 is the net sprite size*/
+
+ for(;h;h -= 30)
+ {
+ int 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)
+{
+ if(!ConsumePsiEnergy(3))
+ return 0;
+
+ if(script_byte_vars.byte_179F9 != 0)
+ {
+ the_command = Swap16(script_word_vars.word_178F0);
+ return ScriptRerun;
+ }
+
+ BackupScreenOfSpecialRoom();
+ DrawStickyNet();
+ SelectCursor(CURSOR_FLY);
+ MenuLoop(0, 0);
+ PlaySound(224);
+ CGA_BackBufferToRealFull();
+ RestoreScreenOfSpecialRoom();
+
+ if(script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(0) == 0)
+ the_command = Swap16(script_word_vars.word_17844);
+
+ if(script_byte_vars.byte_179DC >= 63
+ && script_byte_vars.zone_area < 22
+ && script_byte_vars.zone_area != 1)
+ the_command = 0x9005;
+
+ return ScriptRerun;
+}
+
+unsigned int CMD_C_PsiKnowMind(void)
+{
+ if(!ConsumePsiEnergy(1))
+ return 0;
+
+ if(script_byte_vars.byte_179F9 != 0)
+ {
+ the_command = Swap16(script_word_vars.word_178F2);
+ return ScriptRerun;
+ }
+
+ ProcessMenu();
+
+ if(script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(4) == 0)
+ the_command = Swap16(script_word_vars.word_17846);
+
+ return ScriptRerun;
+}
+
+unsigned int CMD_D_PsiBrainwarp(void)
+{
+ if(!ConsumePsiEnergy(2))
+ return 0;
+
+ if(script_byte_vars.byte_179F9 == 0)
+ {
+ BackupScreenOfSpecialRoom();
+ ProcessMenu();
+
+ if(script_byte_vars.cur_spot_idx == 0)
+ {
+ the_command = Swap16(script_word_vars.word_17850);
+ script_byte_vars.dead_flag = 0;
+ return ScriptRerun;
+ }
+
+ if(GetZoneObjCommand(2) != 0)
+ {
+ PlayAnim(39, found_spot->sx + 8 / 4, found_spot->sy - 10);
+ RestoreScreenOfSpecialRoom();
+ return ScriptRerun;
+ }
+ }
+
+ if(script_byte_vars.byte_179F9 == 18)
+ {
+ script_byte_vars.dead_flag = 1;
+ script_byte_vars.tries_left = 2;
+ return 0;
+ }
+
+ ((pers_t*)script_vars[ScrPool8_CurrentPers])->flags |= PERSFLG_80;
+ script_byte_vars.dead_flag = script_byte_vars.cur_spot_idx;
+ script_byte_vars.tries_left = 2;
+ the_command = 0;
+ if(script_byte_vars.byte_179F9 == 0)
+ {
+ PlayAnim(39, found_spot->sx + 8 / 4, found_spot->sy - 10);
+ RestoreScreenOfSpecialRoom();
+ return ScriptRerun;
+ }
+
+ the_command = 0x90AA;
+ return ScriptRerun;
+}
+
+
+unsigned int CMD_E_PsiZoneScan(void)
+{
+ unsigned char x, y, w, h;
+ unsigned int offs;
+
+ if(!ConsumePsiEnergy(1))
+ return 0;
+
+ if(script_byte_vars.byte_179F9 != 0)
+ {
+ the_command = Swap16(script_word_vars.word_178FC);
+ return ScriptRerun;
+ }
+
+ BackupScreenOfSpecialRoom();
+
+ offs = CGA_CalcXY_p(room_bounds_rect.sx, room_bounds_rect.sy);
+ w = room_bounds_rect.ex - room_bounds_rect.sx;
+ h = room_bounds_rect.ey - room_bounds_rect.sy;
+
+ for(y = room_bounds_rect.sy;h;y++, h--)
+ {
+ spot_t *spot;
+ for(x = 0;x < w;x++) frontbuffer[offs + x] = ~frontbuffer[offs + x];
+ WaitVBlank();
+ for(x = 0;x < w;x++) frontbuffer[offs + x] = ~frontbuffer[offs + x];
+
+ for(spot = zone_spots;spot != zone_spots_end;spot++)
+ {
+ if((spot->flags & ~(SPOTFLG_40 | 7)) == (SPOTFLG_20 | SPOTFLG_8) && spot->sy == y)
+ {
+ PlaySound(27);
+ spot->flags |= SPOTFLG_80;
+ PlayAnim(38, spot->sx, spot->sy);
+ break;
+ }
+ }
+
+ offs ^= CGA_ODD_LINES_OFS;
+ if((offs & CGA_ODD_LINES_OFS) == 0)
+ offs += CGA_BYTES_PER_LINE;
+ }
+
+ RestoreScreenOfSpecialRoom();
+
+ the_command = Swap16(script_word_vars.word_17848);
+
+ return ScriptRerun;
+
+}
+
+unsigned int CMD_F_PsiPsiShift(void)
+{
+ if(!ConsumePsiEnergy(3))
+ return 0;
+
+ if(script_byte_vars.byte_179F9 != 0)
+ {
+ the_command = Swap16(script_word_vars.word_178F4);
+ return ScriptRerun;
+ }
+
+ SelectCursor(CURSOR_4);
+ MenuLoop(0, 0);
+ BackupScreenOfSpecialRoom();
+ PlaySound(25);
+ PlayAnim(39, cursor_x / 4, cursor_y);
+ RestoreScreenOfSpecialRoom();
+
+ if(script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(6) == 0)
+ the_command = Swap16(script_word_vars.word_1784E);
+
+ return ScriptRerun;
+}
+
+unsigned int CMD_10_PsiExtremeViolence(void)
+{
+ unsigned short command;
+
+ if(!ConsumePsiEnergy(8))
+ return 0;
+
+ script_byte_vars.byte_179F3 = 1;
+
+ if(script_byte_vars.byte_179F9 != 0)
+ {
+ the_command = Swap16(script_word_vars.word_178F6);
+ return ScriptRerun;
+ }
+
+ ProcessMenu();
+
+ if(script_byte_vars.cur_spot_idx == 0)
+ {
+ the_command = Swap16(script_word_vars.word_1784C);
+ script_byte_vars.byte_179F3 = 0;
+ return ScriptRerun;
+ }
+
+ command = GetZoneObjCommand(8);
+
+ if((command & 0xF000) == 0x9000)
+ script_byte_vars.byte_179F3 = 0;
+ else if(command == 0)
+ {
+ the_command = Swap16(script_word_vars.word_1784C);
+ script_byte_vars.byte_179F3 = 0;
+ }
+
+ return ScriptRerun;
+}
+
+unsigned int CMD_11_PsiTuneIn(void)
+{
+ unsigned short command;
+ unsigned char *msg;
+
+ if(!ConsumePsiEnergy(4))
+ return 0;
+
+ if(script_byte_vars.byte_179F9 != 0)
+ command = Swap16(script_word_vars.word_178F8);
+ else
+ {
+ if(script_byte_vars.byte_179DC < 63 || script_byte_vars.zone_area >= 22)
+ command = Swap16(script_word_vars.word_1784A);
+ else
+ command = 275;
+ }
+
+ /*TODO: is this really neccessary? Maybe it's always set when loaded from script vars?*/
+ if(command & 0x8000)
+ {
+ the_command = command;
+ return ScriptRerun;
+ }
+
+ msg = SeekToString(diali_data, command);
+ cur_dlg_index = cur_str_index; /*TODO: useless?*/
+
+ DrawPersonBubble(32/4, 20, 15, msg);
+
+ PromptWait();
+ PopDirtyRects(DirtyRectBubble);
+
+ return 0;
+}
+
+void ActionForPersonChoice(unsigned short *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;
+ if(index == 93) /*CADAVER*/
+ index = 19 + 42;
+ else if(index == 133) /*SCI FI*/
+ index = 18 + 42;
+
+ index -= 42; /*Person names: THE MASTER OF ORDEALS, etc*/
+
+ the_command = actions[index];
+
+ PlaySound(22);
+ }
+}
+
+/*TODO: ensure these are never accessed/modified from the scripts*/
+unsigned short menu_commands_12[] = {
+ 0xC0F0,
+ 0xC0D7,
+ 0x9019,
+ 0xC0DA,
+ 0x9019,
+ 0xC0F1,
+ 0x9007,
+ 0xC0D8,
+ 0x9007,
+ 0x9019,
+ 0x9007,
+ 0x9007,
+ 0xC34E,
+ 0xC34F,
+ 0x9019,
+ 0x9019,
+ 0x9019,
+ 0x9019,
+ 0xC319,
+ 0x9007
+};
+
+unsigned short menu_commands_22[] = {
+ 0xC325,
+ 0xC326,
+ 0xC31B,
+ 0xC31D,
+ 0xC31F,
+ 0xC31E,
+ 0xC320,
+ 0xC327,
+ 0x90EC,
+ 0xC31C,
+ 0xC328,
+ 0,
+ 0xC077,
+ 0xC077,
+ 0xC321,
+ 0xC322,
+ 0x9007,
+ 0xC323,
+ 0xC2A7,
+ 0xC324
+};
+
+unsigned short menu_commands_24[] = {
+ 0xC344,
+ 0xC34A,
+ 0xC343,
+ 0xC34D,
+ 0x9019,
+ 0xC0F1,
+ 0x9007,
+ 0xC354,
+ 0x90EC,
+ 0xC343,
+ 0xC345,
+ 0,
+ 0xC343,
+ 0xC343,
+ 0xC343,
+ 0x9019,
+ 0x9019,
+ 0x9019,
+ 0xC343,
+ 0xC343
+};
+
+unsigned short menu_commands_23[] = {
+ 0xC002,
+ 0xC32A,
+ 0x9019,
+ 0xC325,
+ 0xC114,
+ 0xC32B,
+ 0xC32C,
+ 0xC355,
+ 0x90EC,
+ 0x9019,
+ 0xC328,
+ 0,
+ 0xC077,
+ 0xC077,
+ 0x9019,
+ 0x9113,
+ 0,
+ 0xC323,
+ 0xC2A7,
+ 0xC32D
+};
+
+unsigned int 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};
+
+ unsigned char x, y, w, h;
+ unsigned int i, j;
+
+ script_byte_vars.byte_17A20 = 1;
+ for(i = 0;i < 10;i++)
+ {
+ DrawRoomStaticObject(water1, &x, &y, &w, &h);
+ WaitVBlank();
+ CGA_BackBufferToRealFull();
+ for(j = 0;j < 0x1FFF;j++) ; /*TODO: weak delay*/
+
+ DrawRoomStaticObject(water2, &x, &y, &w, &h);
+ WaitVBlank();
+ CGA_BackBufferToRealFull();
+ for(j = 0;j < 0x1FFF;j++) ; /*TODO: weak delay*/
+ }
+
+ DrawRoomStaticObject(headl, &x, &y, &w, &h);
+ DrawRoomStaticObject(headr, &x, &y, &w, &h);
+ CGA_BackBufferToRealFull();
+
+ return 0;
+}
+
+/*Vorts walking into the room*/
+unsigned int CMD_14_VortAppear(void)
+{
+ /*TODO: check me*/
+ pers_list[0].area = script_byte_vars.zone_area;
+ FindAndSelectSpot(0);
+ AnimateSpot(&vortanims_ptr->field_1);
+ next_command3 = 0xA015;
+ BlitSpritesToBackBuffer();
+ DrawZoneObjs();
+ CGA_BackBufferToRealFull();
+ next_ticks3 = Swap16(script_word_vars.timer_ticks2) + 5;
+ return 0;
+}
+
+pers_t *pers_vort_ptr;
+
+struct {
+unsigned char room;
+unsigned char field_1;
+} vortleave[] = {
+ { 2, 5},
+ { 3, 8},
+ { 4, 8},
+ { 5, 2},
+ {120, 3},
+ {121, 3},
+ { 8, 10},
+ { 10, 8},
+ { 60, 62},
+ { 62, 66},
+ { 68, 66},
+ { 69, 66},
+ { 67, 65},
+ { 65, 66},
+ { 70, 71},
+ { 71, 70},
+ { 59, 60},
+ { 60, 62},
+ { 63, 65}
+};
+
+/*Vorts walking out of the room*/
+unsigned int CMD_15_VortLeave(void)
+{
+ /*TODO: check me*/
+
+ unsigned int i;
+ animdesc_t *anim;
+ pers_t *pers;
+
+ if(pers_list[0].area != 0)
+ {
+ pers = &pers_list[0];
+ anim = &vortanims_ptr->field_4;
+ }
+ else if(pers_list[34].area != 0)
+ {
+ pers = &pers_list[34];
+ anim = &vortanims_ptr->field_7;
+ }
+ else
+ {
+ script_byte_vars.byte_179EC |= 0x80;
+
+ pers_list[35].area = 0;
+ pers_list[0].flags = pers_list[35].flags;
+
+ pers = &pers_list[0];
+ anim = &vortanims_ptr->field_A;
+ }
+
+ pers->area = 0;
+ next_command3 = 0;
+ for(i = 0;i < 19;i++)
+ {
+ if(vortleave[i].room == script_byte_vars.zone_index)
+ {
+ next_command3 = 0xA016;
+ next_ticks3 = Swap16(script_word_vars.timer_ticks2) + 5;
+ pers->area = vortleave[i].field_1;
+ }
+ }
+ pers_vort_ptr = pers;
+
+ zone_spots[(pers->flags & 15) - 1].flags &= ~SPOTFLG_80;
+
+ FindAndSelectSpot(0);
+ AnimateSpot(anim);
+ script_byte_vars.byte_179EC &= 0x80;
+ return 0;
+}
+
+/*
+Vorts left the room
+*/
+unsigned int CMD_16_VortGone(void)
+{
+ pers_vort_ptr->area = 0;
+ next_command3 = 0;
+ return 0;
+}
+
+unsigned int CMD_18_AspirantLeave(void)
+{
+ /*TODO: check me*/
+ static const animdesc_t anim33 = {ANIMFLG_USESPOT | 33};
+
+ PopDirtyRects(DirtyRectSprite);
+ PopDirtyRects(DirtyRectText);
+
+ pers_ptr->area = 0;
+ script_word_vars.next_command1 = BE(0);
+
+ if((pers_ptr->flags & PERSFLG_40) == 0)
+ {
+ spot_ptr->flags &= ~SPOTFLG_80;
+ FindAndSelectSpot(script_byte_vars.quest_item_ofs);
+ script_byte_vars.byte_179EF = 0;
+ AnimateSpot(&anim33);
+ }
+
+ return 0;
+}
+
+
+/*
+Show Holo screen anim and speech
+*/
+unsigned int CMD_1B_Holo(void)
+{
+ unsigned char x, y;
+ unsigned int num;
+ unsigned char *msg;
+
+ x = found_spot->sx;
+ y = found_spot->sy;
+
+ PlayAnim(42, x + 4/4, y + 6);
+
+ num = 321 + ((Swap16(script_word_vars.timer_ticks2) < 60*60) ? 0 : 4) + (script_byte_vars.rand_value % 4);
+ msg = SeekToString(diali_data, num);
+ cur_dlg_index = cur_str_index; /*TODO: useless?*/
+
+ if(x < 140/4)
+ DrawPersonBubble(x + 32/4, y - 40, SPIKE_DNLEFT | 20, msg);
+ else
+ DrawPersonBubble(x - 92/4, y - 40, SPIKE_DNRIGHT | 20, msg);
+
+ PlayAnim(43, x, y);
+
+ PromptWait();
+ PopDirtyRects(DirtyRectBubble);
+
+ PlayAnim(45, x, y);
+
+ return 0;
+}
+
+/*
+TODO: check me
+*/
+unsigned int CMD_20_(void)
+{
+ pers_list[5].area = 0;
+ next_command4 = 0;
+ return 0;
+}
+
+/*
+Talk to Vorts
+*/
+unsigned int CMD_21_VortTalk(void)
+{
+ unsigned char x, y;
+ unsigned int num;
+ unsigned char *msg;
+
+ if(script_byte_vars.rand_value >= 85)
+ num = 6;
+ else if(script_byte_vars.rand_value >= 170)
+ num = 7;
+ else
+ num = 35;
+
+ msg = SeekToString(diali_data, num);
+ cur_dlg_index = cur_str_index; /*TODO: useless?*/
+
+ x = found_spot->sx;
+ y = found_spot->sy;
+
+ if(x < 140/4)
+ DrawPersonBubble(found_spot->ex, y - 40, SPIKE_DNLEFT | 20, msg);
+ else
+ DrawPersonBubble(x - 80/4, y - 40, SPIKE_DNRIGHT | 20, msg);
+
+ PromptWait();
+ PopDirtyRects(DirtyRectBubble);
+
+ return 0;
+}
+
+unsigned int CMD_22_(void)
+{
+ ActionForPersonChoice(menu_commands_22);
+ return ScriptRerun;
+}
+
+unsigned int CMD_23_(void)
+{
+ ActionForPersonChoice(menu_commands_23);
+ return ScriptRerun;
+}
+
+unsigned int CMD_24_(void)
+{
+ ActionForPersonChoice(menu_commands_24);
+ return ScriptRerun;
+}
+
+unsigned int CMD_25_LoadGame(void)
+{
+ if(LoadScena())
+ the_command = 0x918F; /*error loading*/
+ else
+ the_command = 0x90AA;
+ return ScriptRerun;
+}
+
+unsigned int CMD_26_SaveGame(void)
+{
+ if(SaveScena())
+ the_command = 0x9190; /*error saving*/
+ else
+ the_command = 0x90AA;
+ return ScriptRerun;
+}
+
+
+
+typedef unsigned int (*cmdhandler_t)(void);
+
+cmdhandler_t command_handlers[] = {
+ 0,
+ CMD_1_RoomObjects,
+ CMD_2_PsiPowers,
+ CMD_3_Posessions,
+ CMD_4_EnergyLevel,
+ CMD_5_Wait,
+ CMD_6_Load,
+ CMD_7_Save,
+ CMD_8_Timer,
+ CMD_TRAP,
+ CMD_A_PsiSolarEyes,
+ CMD_B_PsiStickyFingers,
+ CMD_C_PsiKnowMind,
+ CMD_D_PsiBrainwarp,
+ CMD_E_PsiZoneScan,
+ CMD_F_PsiPsiShift,
+ CMD_10_PsiExtremeViolence, /*10*/
+ CMD_11_PsiTuneIn,
+ CMD_12_,
+ CMD_13_ActivateFountain,
+ CMD_14_VortAppear,
+ CMD_15_VortLeave,
+ CMD_16_VortGone,
+ CMD_TRAP,
+ CMD_18_AspirantLeave,
+ CMD_TRAP,
Commit: 278d742135bade22c911a64725b64e920fa93b21
https://github.com/scummvm/scummvm/commit/278d742135bade22c911a64725b64e920fa93b21
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Removed unnecessary files
Changed paths:
R engines/chamber/!fix.txt
R engines/chamber/bld.bat
R engines/chamber/cln.bat
R engines/chamber/kult.lnk
R engines/chamber/makefile
R engines/chamber/ru.cmd
R engines/chamber/rud.cmd
R engines/chamber/turboc.cfg
R engines/chamber/utils.c
R engines/chamber/utils.h
diff --git a/engines/chamber/!fix.txt b/engines/chamber/!fix.txt
deleted file mode 100644
index 86036f09804..00000000000
--- a/engines/chamber/!fix.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-Known bugs (not the original ones):
-1. Main hint box (location name) is wrongly positioned on x axis
-2. FIXED -- When actions menu shown, some garbage is left under cursor
-3. Moving cursor close to right edge of screen causes noticeable slowdown
-4. Doors open only half of their height
-5. In some rooms main hint box text is misplaced
-6. FIXED -- Junk under cursor when clicked on psi powers menu (maybe related to 2)
-7. FIXED -- Clicking on inventory item does nothing (should open actions menu)
-8. FIXED? -- Energy level is not animated
-9. FIXED -- Right guard is not properly drawn for a while after quest item bounce (bounce anim goes over the character)
-10. CANTREPRO -- Massive glitches on the right side when walking around the room (regression)
-11. Animation (esp. portraits) runs pretty slowly (maybe due to unoptimized code?)
-12. Closing door animation is played in wrong rooms, with trashed/invalid sprites
-13. FIXED -- CopyScreenBlockWithDotEffect (from AspirantLeave) does not fully remove sprite?
-14. FIXED -- DeProf puzzle is broken
-15. FIXED -- Wrong dialog lines when trade with Aspirant (before inventory opens)
-16. FIXED -- Zorq trader (at TMO) offers trade w/o skull at first try?
-17. Wait4/Wait command does not wait as intended?
-18. In Who Will Be Saved, Engraving opens incorrectly (maybe related to 4)
-19. Some junk is draw in The Wall
-20. Can't leave left Victory of The Faith room?
-21. Zorq trader at TMO is broken again. Now refuses to trade even when have a skull.
-
-Rooms done so far:
-DeProf - solvable (with a rope or psi)
-TheWall - missing open doors animation
-TheTwins - solvable
-TheNoose - solvable (trapdoor is glitchy, see bug 4)
-
-General TODOs:
-1. Change script vars access to proxy calls (GetByteVar(12) , SetWordVar(4, 1234))
-2. Replace CGA_SCREENBUFFER instances with frontbuffer (or screenbuffer?)
-3. Remove redundant target = frontbuffer argument in calls
-4. Move all remaining CGA low-level code to cga.c
-5. Replace CGA next/prev line calculations with a macro/func
-6. Add sound playback
-
-
-Original game bugs:
-1. Actions menu for rope in DeProf shows two "Inspect" choices with different actions
-2. SCR_2D_Wait ignores specified delay, always waits for 4 secs
-3. Trade with Skull Trader while having only a skull will cause lost of the skull?
-4. In Who Will Be Saved raised hand's part is not drawn after reentering the room?
diff --git a/engines/chamber/bld.bat b/engines/chamber/bld.bat
deleted file mode 100644
index f723013b627..00000000000
--- a/engines/chamber/bld.bat
+++ /dev/null
@@ -1,6 +0,0 @@
- at echo off
-set path=..\bin\tc
-set CINC=..\bin\tc\include
-set CLIB=..\bin\tc\lib
-
-make
diff --git a/engines/chamber/cln.bat b/engines/chamber/cln.bat
deleted file mode 100644
index 004aa3b0950..00000000000
--- a/engines/chamber/cln.bat
+++ /dev/null
@@ -1,3 +0,0 @@
- at echo off
-
-..\bin\tc\make clean
diff --git a/engines/chamber/kult.lnk b/engines/chamber/kult.lnk
deleted file mode 100644
index f3394840dae..00000000000
--- a/engines/chamber/kult.lnk
+++ /dev/null
@@ -1,17 +0,0 @@
-resdata.obj+
-cga.obj+
-anim.obj+
-decompr.obj+
-cursor.obj+
-input.obj+
-room.obj+
-invent.obj+
-print.obj+
-dialog.obj+
-portrait.obj+
-menu.obj+
-timer.obj+
-sound.obj+
-savegame.obj+
-kult.obj+
-script.obj
diff --git a/engines/chamber/makefile b/engines/chamber/makefile
deleted file mode 100644
index abfd35b16e5..00000000000
--- a/engines/chamber/makefile
+++ /dev/null
@@ -1,45 +0,0 @@
-CC = tcc -mh -c -v -w
-LINK = tlink /c /x /v
-LIB = tlib
-OBJS = resdata.obj cga.obj anim.obj decompr.obj cursor.obj input.obj \
- room.obj invent.obj print.obj dialog.obj portrait.obj menu.obj \
- timer.obj sound.obj savegame.obj kult.obj script.obj
-
-kult.exe: alldata.lib $(OBJS)
- $(LINK) $(CLIB)\c0h @kult.lnk,$*,,alldata $(CLIB)\ch
-
-alldata.lib: r_puzzl.obj r_sprit.obj r_templ.obj r_texts.obj bkbuff.obj r_pers.obj
- $(LIB) alldata.lib /c +-r_puzzl +-r_sprit +-bkbuff +-r_texts +-r_pers +-r_templ
-
-r_puzzl.obj: r_puzzl.c resdata.h
-r_sprit.obj: r_sprit.c resdata.h
-r_texts.obj: r_texts.c resdata.h
-r_pers.obj: r_pers.c resdata.h
-r_templ.obj: r_templ.c resdata.h
-bkbuff.obj: bkbuff.c
-
-kult.obj: kult.c common.h cga.h decompr.h script.h resdata.h
-resdata.obj: resdata.c common.h resdata.h
-cga.obj: cga.c common.h cga.h
-anim.obj: anim.c common.h anim.h
-decompr.obj: decompr.c common.h
-cursor.obj: cursor.c common.h cursor.h cga.h resdata.h
-input.obj: input.c common.h input.h
-print.obj: print.c common.h print.h cga.h
-dialog.obj: dialog.c common.h dialog.h cga.h
-portrait.obj: portrait.c common.h portrait.h cga.h
-room.obj: room.c common.h room.h cga.h
-invent.obj: invent.c common.h invent.h cga.h script.h
-menu.obj: menu.c common.h cga.h script.h input.h
-sound.obj: sound.c common.h sound.h
-timer.obj: timer.c common.h timer.h cga.h
-script.obj: script.c common.h script.h cga.h resdata.h
-savegame.obj: savegame.c common.h savegame.h script.h
-
-.c.obj:
- $(CC) $<
-
-clean:
- -del *.exe
- -del *.obj
- -del *.lib
diff --git a/engines/chamber/ru.cmd b/engines/chamber/ru.cmd
deleted file mode 100644
index 962058a21f9..00000000000
--- a/engines/chamber/ru.cmd
+++ /dev/null
@@ -1,5 +0,0 @@
- at echo off
-copy /y KULT.EXE ..\..\..\dbx\disk\kure
-pushd ..\..\..\dbx
-dosbox -c "cd kure" -c kult.exe
-popd
diff --git a/engines/chamber/rud.cmd b/engines/chamber/rud.cmd
deleted file mode 100644
index 12b2dfeba1c..00000000000
--- a/engines/chamber/rud.cmd
+++ /dev/null
@@ -1,5 +0,0 @@
- at echo off
-copy /y KULT.EXE ..\..\..\dbx\disk\kure
-pushd ..\..\..\dbx
-dosbox -c "cd kure" -c "td kult.exe"
-popd
diff --git a/engines/chamber/turboc.cfg b/engines/chamber/turboc.cfg
deleted file mode 100644
index 6026f9035c9..00000000000
--- a/engines/chamber/turboc.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
--I..\BIN\TC\INCLUDE
--L..\BIN\TC\LIB
diff --git a/engines/chamber/utils.c b/engines/chamber/utils.c
deleted file mode 100644
index 12828ba5f57..00000000000
--- a/engines/chamber/utils.c
+++ /dev/null
@@ -1,2 +0,0 @@
-#include "common.h"
-#include "utils.h"
diff --git a/engines/chamber/utils.h b/engines/chamber/utils.h
deleted file mode 100644
index e69de29bb2d..00000000000
Commit: b8ca670f2088fffda05d7cdd5871bd61c92468df
https://github.com/scummvm/scummvm/commit/b8ca670f2088fffda05d7cdd5871bd61c92468df
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Rename *.c -> *.cpp
Changed paths:
A engines/chamber/anim.cpp
A engines/chamber/bkbuff.cpp
A engines/chamber/cga.cpp
A engines/chamber/cursor.cpp
A engines/chamber/decompr.cpp
A engines/chamber/dialog.cpp
A engines/chamber/input.cpp
A engines/chamber/invent.cpp
A engines/chamber/kult.cpp
A engines/chamber/menu.cpp
A engines/chamber/portrait.cpp
A engines/chamber/print.cpp
A engines/chamber/r_other.cpp
A engines/chamber/r_pers.cpp
A engines/chamber/r_puzzl.cpp
A engines/chamber/r_sprit.cpp
A engines/chamber/r_templ.cpp
A engines/chamber/r_texts.cpp
A engines/chamber/resdata.cpp
A engines/chamber/room.cpp
A engines/chamber/savegame.cpp
A engines/chamber/script.cpp
A engines/chamber/sound.cpp
A engines/chamber/timer.cpp
R engines/chamber/anim.c
R engines/chamber/bkbuff.c
R engines/chamber/cga.c
R engines/chamber/cursor.c
R engines/chamber/decompr.c
R engines/chamber/dialog.c
R engines/chamber/input.c
R engines/chamber/invent.c
R engines/chamber/kult.c
R engines/chamber/menu.c
R engines/chamber/portrait.c
R engines/chamber/print.c
R engines/chamber/r_other.c
R engines/chamber/r_pers.c
R engines/chamber/r_puzzl.c
R engines/chamber/r_sprit.c
R engines/chamber/r_templ.c
R engines/chamber/r_texts.c
R engines/chamber/resdata.c
R engines/chamber/room.c
R engines/chamber/savegame.c
R engines/chamber/script.c
R engines/chamber/sound.c
R engines/chamber/timer.c
diff --git a/engines/chamber/anim.c b/engines/chamber/anim.cpp
similarity index 100%
rename from engines/chamber/anim.c
rename to engines/chamber/anim.cpp
diff --git a/engines/chamber/bkbuff.c b/engines/chamber/bkbuff.cpp
similarity index 100%
rename from engines/chamber/bkbuff.c
rename to engines/chamber/bkbuff.cpp
diff --git a/engines/chamber/cga.c b/engines/chamber/cga.cpp
similarity index 100%
rename from engines/chamber/cga.c
rename to engines/chamber/cga.cpp
diff --git a/engines/chamber/cursor.c b/engines/chamber/cursor.cpp
similarity index 100%
rename from engines/chamber/cursor.c
rename to engines/chamber/cursor.cpp
diff --git a/engines/chamber/decompr.c b/engines/chamber/decompr.cpp
similarity index 100%
rename from engines/chamber/decompr.c
rename to engines/chamber/decompr.cpp
diff --git a/engines/chamber/dialog.c b/engines/chamber/dialog.cpp
similarity index 100%
rename from engines/chamber/dialog.c
rename to engines/chamber/dialog.cpp
diff --git a/engines/chamber/input.c b/engines/chamber/input.cpp
similarity index 100%
rename from engines/chamber/input.c
rename to engines/chamber/input.cpp
diff --git a/engines/chamber/invent.c b/engines/chamber/invent.cpp
similarity index 100%
rename from engines/chamber/invent.c
rename to engines/chamber/invent.cpp
diff --git a/engines/chamber/kult.c b/engines/chamber/kult.cpp
similarity index 100%
rename from engines/chamber/kult.c
rename to engines/chamber/kult.cpp
diff --git a/engines/chamber/menu.c b/engines/chamber/menu.cpp
similarity index 100%
rename from engines/chamber/menu.c
rename to engines/chamber/menu.cpp
diff --git a/engines/chamber/portrait.c b/engines/chamber/portrait.cpp
similarity index 100%
rename from engines/chamber/portrait.c
rename to engines/chamber/portrait.cpp
diff --git a/engines/chamber/print.c b/engines/chamber/print.cpp
similarity index 100%
rename from engines/chamber/print.c
rename to engines/chamber/print.cpp
diff --git a/engines/chamber/r_other.c b/engines/chamber/r_other.cpp
similarity index 100%
rename from engines/chamber/r_other.c
rename to engines/chamber/r_other.cpp
diff --git a/engines/chamber/r_pers.c b/engines/chamber/r_pers.cpp
similarity index 100%
rename from engines/chamber/r_pers.c
rename to engines/chamber/r_pers.cpp
diff --git a/engines/chamber/r_puzzl.c b/engines/chamber/r_puzzl.cpp
similarity index 100%
rename from engines/chamber/r_puzzl.c
rename to engines/chamber/r_puzzl.cpp
diff --git a/engines/chamber/r_sprit.c b/engines/chamber/r_sprit.cpp
similarity index 100%
rename from engines/chamber/r_sprit.c
rename to engines/chamber/r_sprit.cpp
diff --git a/engines/chamber/r_templ.c b/engines/chamber/r_templ.cpp
similarity index 100%
rename from engines/chamber/r_templ.c
rename to engines/chamber/r_templ.cpp
diff --git a/engines/chamber/r_texts.c b/engines/chamber/r_texts.cpp
similarity index 100%
rename from engines/chamber/r_texts.c
rename to engines/chamber/r_texts.cpp
diff --git a/engines/chamber/resdata.c b/engines/chamber/resdata.cpp
similarity index 100%
rename from engines/chamber/resdata.c
rename to engines/chamber/resdata.cpp
diff --git a/engines/chamber/room.c b/engines/chamber/room.cpp
similarity index 100%
rename from engines/chamber/room.c
rename to engines/chamber/room.cpp
diff --git a/engines/chamber/savegame.c b/engines/chamber/savegame.cpp
similarity index 100%
rename from engines/chamber/savegame.c
rename to engines/chamber/savegame.cpp
diff --git a/engines/chamber/script.c b/engines/chamber/script.cpp
similarity index 100%
rename from engines/chamber/script.c
rename to engines/chamber/script.cpp
diff --git a/engines/chamber/sound.c b/engines/chamber/sound.cpp
similarity index 100%
rename from engines/chamber/sound.c
rename to engines/chamber/sound.cpp
diff --git a/engines/chamber/timer.c b/engines/chamber/timer.cpp
similarity index 100%
rename from engines/chamber/timer.c
rename to engines/chamber/timer.cpp
Commit: 8a0da574ac4670cc995a8f7052ba83ff28e3472c
https://github.com/scummvm/scummvm/commit/8a0da574ac4670cc995a8f7052ba83ff28e3472c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Renamed main file
Changed paths:
A engines/chamber/chamber.cpp
R engines/chamber/kult.cpp
diff --git a/engines/chamber/kult.cpp b/engines/chamber/chamber.cpp
similarity index 100%
rename from engines/chamber/kult.cpp
rename to engines/chamber/chamber.cpp
Commit: a91cfbbeddd423fbde807bfccd223d7a9df838bd
https://github.com/scummvm/scummvm/commit/a91cfbbeddd423fbde807bfccd223d7a9df838bd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Run astyle
Changed paths:
engines/chamber/anim.cpp
engines/chamber/cga.cpp
engines/chamber/cga.h
engines/chamber/chamber.cpp
engines/chamber/common.h
engines/chamber/cursor.cpp
engines/chamber/decompr.cpp
engines/chamber/dialog.cpp
engines/chamber/dialog.h
engines/chamber/input.cpp
engines/chamber/invent.cpp
engines/chamber/menu.cpp
engines/chamber/portrait.cpp
engines/chamber/print.cpp
engines/chamber/print.h
engines/chamber/resdata.cpp
engines/chamber/resdata.h
engines/chamber/room.cpp
engines/chamber/room.h
engines/chamber/savegame.cpp
engines/chamber/script.cpp
engines/chamber/script.h
engines/chamber/scrvars.h
engines/chamber/sound.cpp
engines/chamber/timer.cpp
diff --git a/engines/chamber/anim.cpp b/engines/chamber/anim.cpp
index 6e72d67c453..80c481e047b 100644
--- a/engines/chamber/anim.cpp
+++ b/engines/chamber/anim.cpp
@@ -21,22 +21,20 @@ unsigned int dot_effect_delay;
extern unsigned short cpu_speed_delay;
-extern unsigned char * SeekToEntry(unsigned char far *bank, unsigned int num, unsigned char far **end);
+extern unsigned char *SeekToEntry(unsigned char far *bank, unsigned int num, unsigned char far **end);
extern void LoadLutinSprite(unsigned int lutidx);
-void GetScratchBuffer(unsigned char mode)
-{
+void GetScratchBuffer(unsigned char mode) {
unsigned char *buffer = scratch_mem2;
unsigned int offs = 0;
- if(mode & 0x80)
+ if (mode & 0x80)
offs += 3200;
- if(mode & 0x40)
+ if (mode & 0x40)
offs += 1600;
lutin_mem = buffer + offs;
}
-void AnimLoadSprite(unsigned char **panim)
-{
+void AnimLoadSprite(unsigned char **panim) {
unsigned char mode;
unsigned char index;
mode = *((*panim)++);
@@ -45,48 +43,34 @@ void AnimLoadSprite(unsigned char **panim)
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)
-{
- if(anim_flags == 7)
+void ClipSprite(unsigned char *x, unsigned char *y, unsigned char *sprw, unsigned char *sprh, unsigned char **sprite, signed char dx, signed char dy) {
+ if (anim_flags == 7)
return;
- if(anim_flags & 4)
- {
- if(anim_cycle == 0)
+ if (anim_flags & 4) {
+ if (anim_cycle == 0)
return;
- if(anim_flags & 2)
- {
+ if (anim_flags & 2) {
*sprh = anim_cycle;
- if(anim_cycle >= dy)
+ if (anim_cycle >= dy)
anim_cycle -= dy;
else
anim_cycle = 0;
- }
- else if(anim_flags & 1)
- {
+ } else if (anim_flags & 1) {
*sprw = anim_cycle;
anim_cycle--;
- }
- else
- {
+ } else {
*x -= dx;
*sprite += (*sprw - anim_cycle) * 2;
*sprw = anim_cycle;
anim_cycle--;
}
- }
- else if(anim_flags & 2)
- {
- if(*sprw == anim_cycle)
- {
+ } else if (anim_flags & 2) {
+ if (*sprw == anim_cycle) {
anim_cycle = 0;
- }
- else if(anim_flags & 1)
- {
+ } else if (anim_flags & 1) {
*sprw = anim_cycle;
anim_cycle++;
- }
- else
- {
+ } else {
*x -= dx;
*sprite += (*sprw - anim_cycle) * 2;
*sprw = anim_cycle;
@@ -95,34 +79,30 @@ 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)
-{
+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;
- for(offs = 0;offs != cur_image_end;)
- {
+ 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);
target[ofs] = (target[ofs] & ~mask) | (source[ofs] & mask);
- if(dot_effect_delay / 4 != 0)
- {
+ if (dot_effect_delay / 4 != 0) {
unsigned int i;
- for(i = 0;i < dot_effect_delay / 4;i++) ; /*TODO: weak delay*/
+ for (i = 0; i < dot_effect_delay / 4; i++) ; /*TODO: weak delay*/
}
-
+
offs += dot_effect_step;
- if(offs > cur_image_end)
+ if (offs > cur_image_end)
offs -= cur_image_end;
}
}
-void AnimDrawSprite(unsigned char x, unsigned char y, unsigned char sprw, unsigned char sprh, unsigned char *pixels, unsigned int pitch)
-{
+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);
@@ -130,19 +110,16 @@ void AnimDrawSprite(unsigned char x, unsigned char y, unsigned char sprw, unsign
CGA_BlitSprite(pixels, pitch, sprw, sprh, backbuffer, ofs);
ex = x + sprw;
ey = y + sprh;
- if(last_anim_height != 0)
- {
- if(last_anim_x + last_anim_width > ex)
+ if (last_anim_height != 0) {
+ if (last_anim_x + last_anim_width > ex)
ex = last_anim_x + last_anim_width;
- if(last_anim_y + last_anim_height > ey)
+ if (last_anim_y + last_anim_height > ey)
ey = last_anim_y + last_anim_height;
updx = (x > last_anim_x) ? last_anim_x : x;
updy = (y > last_anim_y) ? last_anim_y : y;
- }
- else
- {
+ } else {
updx = x;
updy = y;
}
@@ -150,16 +127,14 @@ void AnimDrawSprite(unsigned char x, unsigned char y, unsigned char sprw, unsign
updh = ey - updy;
ofs = CGA_CalcXY_p(updx, updy);
/*TODO looks like here was some code before*/
- for(delay = 0;delay < anim_draw_delay;delay++)
- {
- for(delay2 = 0;delay2 < cpu_speed_delay;delay2++) ; /*TODO FIXME weak delay*/
+ for (delay = 0; delay < anim_draw_delay; delay++) {
+ for (delay2 = 0; delay2 < cpu_speed_delay; delay2++) ; /*TODO FIXME weak delay*/
}
WaitVBlank();
- if(anim_use_dot_effect)
+ if (anim_use_dot_effect)
CopyScreenBlockWithDotEffect(backbuffer, updx, updy, updw, updh, frontbuffer);
- else
- {
+ else {
CGA_CopyScreenBlock(backbuffer, updw, updh, frontbuffer, ofs);
}
CGA_RestoreImage(sprit_load_buffer, backbuffer);
@@ -172,14 +147,12 @@ void AnimDrawSprite(unsigned char x, unsigned char y, unsigned char sprw, unsign
anim_shift_x = anim_shift_y = 0;
}
-void AnimUndrawSprite(void)
-{
+void AnimUndrawSprite(void) {
CGA_CopyScreenBlock(backbuffer, last_anim_width, last_anim_height, CGA_SCREENBUFFER, CGA_CalcXY_p(last_anim_x, last_anim_y));
last_anim_height = 0;
}
-void PlayAnimCore(unsigned char **panim)
-{
+void PlayAnimCore(unsigned char **panim) {
unsigned char mode;
unsigned int count, count2;
unsigned char *pframe;
@@ -187,16 +160,14 @@ void PlayAnimCore(unsigned char **panim)
anim_flags = mode & 7;
count = mode >> 3;
- while(count--)
- {
- pframe = *panim;
+ while (count--) {
+ pframe = *panim;
mode = *pframe++;
anim_draw_delay = ((mode & ~7) >> 3) << 1;
dot_effect_step = (mode & ~7) >> 3;
dot_effect_delay = 500;
count2 = mode & 7;
- while(count2--)
- {
+ while (count2--) {
unsigned char far *sprite;
unsigned char sprw, sprh;
unsigned char x, y;
@@ -218,76 +189,65 @@ void PlayAnimCore(unsigned char **panim)
sprw = *sprite++;
sprh = *sprite++;
- pitch = sprw * 2;
+ pitch = sprw * 2;
ClipSprite(&x, &y, &sprw, &sprh, &sprite, dx, dy);
AnimDrawSprite(x, y, sprw, sprh, sprite, pitch);
- if(anim_flags & 4)
- {
- if(anim_cycle == 0)
- {
+ if (anim_flags & 4) {
+ if (anim_cycle == 0) {
AnimUndrawSprite();
goto end;
}
- }
- else if(anim_flags & 2)
- {
- if(anim_cycle == 0)
- {
+ } else if (anim_flags & 2) {
+ if (anim_cycle == 0) {
goto end;
}
}
}
}
-end:;
+end:
+ ;
mode = *((*panim)++);
*panim += mode & 7;
}
-void Anim1(unsigned char **panim)
-{
+void Anim1(unsigned char **panim) {
anim_cycle = 0xFF;
anim_use_dot_effect = 0;
PlayAnimCore(panim);
}
-void Anim2(unsigned char **panim)
-{
+void Anim2(unsigned char **panim) {
anim_cycle = 1;
anim_use_dot_effect = 0;
PlayAnimCore(panim);
}
-void Anim3(unsigned char **panim)
-{
+void Anim3(unsigned char **panim) {
anim_cycle = 1;
anim_use_dot_effect = 0;
PlayAnimCore(panim);
}
-void Anim4(unsigned char **panim)
-{
+void Anim4(unsigned char **panim) {
anim_cycle = last_anim_width - 1;
anim_use_dot_effect = 0;
PlayAnimCore(panim);
}
-void Anim5(unsigned char **panim)
-{
+void Anim5(unsigned char **panim) {
anim_cycle = last_anim_width - 1;
anim_use_dot_effect = 0;
PlayAnimCore(panim);
}
-void Anim6(unsigned char **panim)
-{
+void Anim6(unsigned char **panim) {
anim_cycle = last_anim_height;
anim_use_dot_effect = 0;
PlayAnimCore(panim);
}
-void Anim7(unsigned char **panim)
-{
+void Anim7(unsigned char **panim) {
anim_cycle = 0xFF;
anim_use_dot_effect = 1;
PlayAnimCore(panim);
@@ -306,8 +266,7 @@ animhandler_t anim_handlers[] = {
Anim7
};
-void PlayAnim(unsigned char index, unsigned char x, unsigned char y)
-{
+void PlayAnim(unsigned char index, unsigned char x, unsigned char y) {
unsigned char sound;
unsigned char *panim;
@@ -317,23 +276,21 @@ void PlayAnim(unsigned char index, unsigned char x, unsigned char y)
last_anim_y = y;
panim = SeekToEntry(anima_data, index - 1, &anima_end_ofs);
- while(panim != anima_end_ofs)
- {
+ while (panim != anima_end_ofs) {
unsigned char mode = *panim;
- switch(mode)
- {
- case 0xFE: /*set shift*/
+ switch (mode) {
+ case 0xFE: /*set shift*/
panim++;
anim_shift_x = *panim++;
anim_shift_y = *panim++;
break;
- case 0xFD: /*play sfx*/
+ case 0xFD: /*play sfx*/
panim++;
sound = *panim++;
- panim++; /*unused*/
+ panim++; /*unused*/
PlaySound(sound);
break;
- case 0xFC: /*nothing*/
+ case 0xFC: /*nothing*/
panim++;
break;
default:
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index c5a0a5d9036..b9b66cdcb6f 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -21,34 +21,34 @@ unsigned char char_draw_max_height;
/*pixels order reverse in a byte*/
unsigned char 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,
-24, 88, 152, 216, 40, 104, 168, 232, 56, 120, 184, 248,
-12, 76, 140, 204, 28, 92, 156, 220, 44, 108, 172, 236,
-60, 124, 188, 252, 1, 65, 129, 193, 17, 81, 145, 209,
-33, 97, 161, 225, 49, 113, 177, 241, 5, 69, 133, 197,
-21, 85, 149, 213, 37, 101, 165, 229, 53, 117, 181, 245,
-9, 73, 137, 201, 25, 89, 153, 217, 41, 105, 169, 233,
-57, 121, 185, 249, 13, 77, 141, 205, 29, 93, 157, 221,
-45, 109, 173, 237, 61, 125, 189, 253, 2, 66, 130, 194,
-18, 82, 146, 210, 34, 98, 162, 226, 50, 114, 178, 242,
-6, 70, 134, 198, 22, 86, 150, 214, 38, 102, 166, 230,
-54, 118, 182, 246, 10, 74, 138, 202, 26, 90, 154, 218,
-42, 106, 170, 234, 58, 122, 186, 250, 14, 78, 142, 206,
-30, 94, 158, 222, 46, 110, 174, 238, 62, 126, 190, 254,
-3, 67, 131, 195, 19, 83, 147, 211, 35, 99, 163, 227,
-51, 115, 179, 243, 7, 71, 135, 199, 23, 87, 151, 215,
-39, 103, 167, 231, 55, 119, 183, 247, 11, 75, 139, 203,
-27, 91, 155, 219, 43, 107, 171, 235, 59, 123, 187, 251,
-15, 79, 143, 207, 31, 95, 159, 223, 47, 111, 175, 239,
-63, 127, 191, 255};
+ 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,
+ 24, 88, 152, 216, 40, 104, 168, 232, 56, 120, 184, 248,
+ 12, 76, 140, 204, 28, 92, 156, 220, 44, 108, 172, 236,
+ 60, 124, 188, 252, 1, 65, 129, 193, 17, 81, 145, 209,
+ 33, 97, 161, 225, 49, 113, 177, 241, 5, 69, 133, 197,
+ 21, 85, 149, 213, 37, 101, 165, 229, 53, 117, 181, 245,
+ 9, 73, 137, 201, 25, 89, 153, 217, 41, 105, 169, 233,
+ 57, 121, 185, 249, 13, 77, 141, 205, 29, 93, 157, 221,
+ 45, 109, 173, 237, 61, 125, 189, 253, 2, 66, 130, 194,
+ 18, 82, 146, 210, 34, 98, 162, 226, 50, 114, 178, 242,
+ 6, 70, 134, 198, 22, 86, 150, 214, 38, 102, 166, 230,
+ 54, 118, 182, 246, 10, 74, 138, 202, 26, 90, 154, 218,
+ 42, 106, 170, 234, 58, 122, 186, 250, 14, 78, 142, 206,
+ 30, 94, 158, 222, 46, 110, 174, 238, 62, 126, 190, 254,
+ 3, 67, 131, 195, 19, 83, 147, 211, 35, 99, 163, 227,
+ 51, 115, 179, 243, 7, 71, 135, 199, 23, 87, 151, 215,
+ 39, 103, 167, 231, 55, 119, 183, 247, 11, 75, 139, 203,
+ 27, 91, 155, 219, 43, 107, 171, 235, 59, 123, 187, 251,
+ 15, 79, 143, 207, 31, 95, 159, 223, 47, 111, 175, 239,
+ 63, 127, 191, 255
+};
/*
Switch to CGA 320x200x2bpp mode
*/
-void SwitchToGraphicsMode(void)
-{
+void SwitchToGraphicsMode(void) {
union REGS reg;
reg.x.ax = 4;
@@ -58,44 +58,37 @@ void SwitchToGraphicsMode(void)
/*
Switch to text mode
*/
-void SwitchToTextMode(void)
-{
+void SwitchToTextMode(void) {
union REGS reg;
reg.x.ax = 3;
int86(0x10, ®, ®);
}
-void WaitVBlank(void)
-{
- while((inportb(0x3DA) & 8) != 0) ;
- while((inportb(0x3DA) & 8) == 0) ;
+void WaitVBlank(void) {
+ while ((inportb(0x3DA) & 8) != 0) ;
+ while ((inportb(0x3DA) & 8) == 0) ;
}
-void CGA_ColorSelect(unsigned char csel)
-{
+void CGA_ColorSelect(unsigned char csel) {
outportb(0x3D9, csel);
}
-void CGA_BackBufferToRealFull(void)
-{
+void CGA_BackBufferToRealFull(void) {
memcpy(CGA_SCREENBUFFER, backbuffer, sizeof(backbuffer));
}
-void CGA_RealBufferToBackFull(void)
-{
+void CGA_RealBufferToBackFull(void) {
memcpy(backbuffer, CGA_SCREENBUFFER, sizeof(backbuffer));
}
/*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)
-{
- while(h--)
- {
+void CGA_CopyScreenBlock(unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs) {
+ while (h--) {
memcpy(target + ofs, source + ofs, w);
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
}
@@ -103,15 +96,13 @@ void CGA_CopyScreenBlock(unsigned char *source, unsigned int w, unsigned int h,
/*
Flip screen and backbuffer
*/
-void CGA_SwapRealBackBuffer(void)
-{
+void CGA_SwapRealBackBuffer(void) {
unsigned int i;
unsigned short *s, *d;
WaitVBlank();
- s = (unsigned short far*)CGA_SCREENBUFFER;
- d = (unsigned short far*)backbuffer;
- for(i = 0;i < sizeof(backbuffer) / 2;i++)
- {
+ s = (unsigned short far *)CGA_SCREENBUFFER;
+ d = (unsigned short far *)backbuffer;
+ for (i = 0; i < sizeof(backbuffer) / 2; i++) {
unsigned short t = *s;
*s++ = *d;
*d++ = t;
@@ -122,19 +113,16 @@ 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)
-{
+void CGA_SwapScreenRect(unsigned char *pixels, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) {
unsigned char *old = scratch_mem2;
- while(h--)
- {
+ while (h--) {
unsigned int i;
- for(i = 0;i < w;i++)
- {
+ for (i = 0; i < w; i++) {
*old++ = screen[ofs + i];
screen[ofs + i] = *pixels++;
}
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
}
@@ -144,8 +132,7 @@ Calc screen offset from normal pixel coordinates
Out:
screen offset
*/
-unsigned int CGA_CalcXY(unsigned int x, unsigned int y)
-{
+unsigned int CGA_CalcXY(unsigned int x, unsigned int y) {
return CGA_CalcXY_p(x / 4, y);
}
@@ -154,10 +141,9 @@ Calc screen offset from packed pixel coordinates
Out:
screen offset
*/
-unsigned int CGA_CalcXY_p(unsigned int x, unsigned int y)
-{
+unsigned int CGA_CalcXY_p(unsigned int x, unsigned int y) {
unsigned int ofs = 0;
- if(y & 1)
+ if (y & 1)
ofs += CGA_ODD_LINES_OFS;
ofs += CGA_BYTES_PER_LINE * (y / 2);
ofs += x;
@@ -169,25 +155,22 @@ 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;
- *(unsigned int*)(buffer + 2) = ofs;
+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;
+ *(unsigned int *)(buffer + 2) = ofs;
buffer += 4;
- while(h--)
- {
+ while (h--) {
memcpy(buffer, screen + ofs, w);
buffer += w;
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
return buffer;
}
-unsigned char * CGA_BackupImageReal(unsigned int ofs, unsigned int w, unsigned int h)
-{
+unsigned char *CGA_BackupImageReal(unsigned int ofs, unsigned int w, unsigned int h) {
return CGA_BackupImage(MK_FP(CGA_BASE_SEG, 0), ofs, w, h, scratch_mem2);
}
@@ -195,14 +178,12 @@ unsigned char * CGA_BackupImageReal(unsigned int ofs, unsigned int w, unsigned i
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)
-{
- while(h--)
- {
+void CGA_Blit(unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) {
+ while (h--) {
memcpy(screen + ofs, pixels, w);
pixels += pw;
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
}
@@ -211,25 +192,21 @@ 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(unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int 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)
-{
- while(h--)
- {
+void CGA_Fill(unsigned char pixel, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) {
+ while (h--) {
memset(screen + ofs, pixel, w);
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
}
-void CGA_FillAndWait(unsigned char pixel, 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) {
CGA_Fill(pixel, w, h, screen, ofs);
WaitVBlank();
}
@@ -237,44 +214,41 @@ 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(unsigned char *buffer, unsigned char *target) {
unsigned int w, h;
unsigned int ofs;
- if(!buffer)
+ if (!buffer)
return;
- h = *(unsigned char*)(buffer + 0);
- w = *(unsigned char*)(buffer + 1);
- ofs = *(unsigned int*)(buffer + 2);
- buffer += 4; /*TODO: fix me for large int*/
+ h = *(unsigned char *)(buffer + 0);
+ w = *(unsigned char *)(buffer + 1);
+ ofs = *(unsigned int *)(buffer + 2);
+ buffer += 4; /*TODO: fix me for large int*/
- CGA_Blit(buffer, w, w, h, target, ofs);
+ CGA_Blit(buffer, w, w, h, target, ofs);
}
/*
Restore saved image from scratch mem to target screen buffer
*/
-void CGA_RestoreBackupImage(unsigned char *target)
-{
+void CGA_RestoreBackupImage(unsigned char *target) {
CGA_RestoreImage(scratch_mem2, target);
}
/*
Copy image's real screen data to backbuffer
*/
-void CGA_RefreshImageData(unsigned char *buffer)
-{
+void CGA_RefreshImageData(unsigned char *buffer) {
unsigned int w, h;
unsigned int ofs;
- if(!buffer)
+ if (!buffer)
return;
- h = *(unsigned char*)(buffer + 0);
- w = *(unsigned char*)(buffer + 1);
- ofs = *(unsigned int*)(buffer + 2);
+ h = *(unsigned char *)(buffer + 0);
+ w = *(unsigned char *)(buffer + 1);
+ ofs = *(unsigned int *)(buffer + 2);
CGA_CopyScreenBlock(CGA_SCREENBUFFER, w, h, backbuffer, ofs);
}
@@ -283,8 +257,7 @@ 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)
-{
+void CGA_DrawVLine(unsigned int x, unsigned int y, unsigned int l, unsigned char color, unsigned char *target) {
unsigned int ofs;
/*pixels are starting from top bits of byte*/
unsigned int mask = ~(3 << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL));
@@ -295,11 +268,10 @@ void CGA_DrawVLine(unsigned int x, unsigned int y, unsigned int l, unsigned char
ofs = CGA_CalcXY_p(x / CGA_PIXELS_PER_BYTE, y);
- while(l--)
- {
+ while (l--) {
target[ofs] = (target[ofs] & mask) | pixel;
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
}
@@ -308,8 +280,7 @@ 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)
-{
+void CGA_DrawHLine(unsigned int x, unsigned int y, unsigned int l, unsigned char color, unsigned char *target) {
unsigned int ofs;
/*pixels are starting from top bits of byte*/
unsigned int mask = ~(3 << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL));
@@ -319,13 +290,11 @@ void CGA_DrawHLine(unsigned int x, unsigned int y, unsigned int l, unsigned char
pixel >>= (x % CGA_PIXELS_PER_BYTE) * CGA_BITS_PER_PIXEL;
ofs = CGA_CalcXY_p(x / CGA_PIXELS_PER_BYTE, y);
- while(l--)
- {
+ while (l--) {
target[ofs] = (target[ofs] & mask) | pixel;
mask >>= CGA_BITS_PER_PIXEL;
pixel >>= CGA_BITS_PER_PIXEL;
- if(mask == 0xFF)
- {
+ if (mask == 0xFF) {
ofs++;
mask = ~(3 << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL));
pixel = color << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL);
@@ -338,32 +307,29 @@ 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)
-{
+unsigned int CGA_DrawHLineWithEnds(unsigned int bmask, unsigned int bpix, unsigned char color, unsigned int l, unsigned char *target, unsigned int 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);
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
- return ofs;
+ return ofs;
}
/*
Print a character at current cursor pos, then advance
*/
-void CGA_PrintChar(unsigned char c, unsigned char *target)
-{
+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);
- for(i = 0;i < CGA_FONT_HEIGHT;i++)
- {
+ for (i = 0; i < CGA_FONT_HEIGHT; i++) {
c = *font++;
c = char_xlat_table[c];
target[ofs] = c;
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
}
@@ -374,23 +340,20 @@ 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)
-{
+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;
- while(h--)
- {
- for(x = 0;x < w;x++)
+ while (h--) {
+ for (x = 0; x < w; x++)
screen[ofs + x] = (backbuffer[ofs + x] & pixels[x * 2]) | pixels[x * 2 + 1];
pixels += w * 2;
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
}
-void CGA_BlitFromBackBuffer(unsigned char w, unsigned char h, unsigned char *screen, unsigned int ofs)
-{
+void CGA_BlitFromBackBuffer(unsigned char w, unsigned char h, unsigned char *screen, unsigned int ofs) {
CGA_CopyScreenBlock(backbuffer, w, h, screen, ofs);
}
@@ -398,16 +361,14 @@ 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)
-{
+void CGA_BlitSprite(unsigned char *pixels, signed int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) {
unsigned char x;
- while(h--)
- {
- for(x = 0;x < w;x++)
+ while (h--) {
+ for (x = 0; x < w; x++)
screen[ofs + x] = (screen[ofs + x] & pixels[x * 2]) | pixels[x * 2 + 1];
pixels += pw;
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
}
@@ -416,16 +377,14 @@ 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)
-{
+void CGA_BlitSpriteFlip(unsigned char *pixels, signed int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) {
unsigned char x;
- while(h--)
- {
- for(x = 0;x < w;x++)
+ 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]];
pixels += pw;
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
}
@@ -438,19 +397,16 @@ 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)
-{
+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;
- while(h--)
- {
- for(x = 0;x < w;x++)
- {
+ while (h--) {
+ for (x = 0; x < w; x++) {
*backup++ = screen[ofs + x];
screen[ofs + x] = (screen[ofs + x] & pixels[x * 2 + 1]) | (pixels[x * 2] & mask);
}
pixels += pw * 2;
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
}
@@ -459,8 +415,7 @@ 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)
-{
+void DrawSprite(unsigned char *sprite, unsigned char *screen, unsigned int ofs) {
unsigned char w, h;
w = *sprite++;
h = *sprite++;
@@ -470,8 +425,7 @@ 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)
-{
+void DrawSpriteFlip(unsigned char *sprite, unsigned char *screen, unsigned int ofs) {
unsigned char w, h;
w = *sprite++;
h = *sprite++;
@@ -482,8 +436,7 @@ 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 *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;
@@ -491,61 +444,65 @@ unsigned char * LoadSprite(unsigned char index, unsigned char *bank, unsigned ch
sprite = SeekToEntryW(bank, index, &sprite_end);
w = *sprite++;
h = *sprite++;
- rsize = w * h; /*raster part size*/
+ rsize = w * h; /*raster part size*/
bitmask = sprite + rsize;
*buffer++ = w;
*buffer++ = h;
- if(header_only)
- {
- memset(buffer, 0, rsize * 2); /*wipe masks+pixels*/
+ if (header_only) {
+ memset(buffer, 0, rsize * 2); /*wipe masks+pixels*/
buffer += rsize * 2;
- }
- else
- {
- if(*bitmask == 0)
- {
+ } else {
+ if (*bitmask == 0) {
/*solid sprite*/
- while(rsize--)
- {
+ while (rsize--) {
*buffer++ = 0;
*buffer++ = *sprite++;
}
- }
- else
- {
+ } else {
/*with transparency*/
unsigned char bi = 1;
- while(rsize--)
- {
+ while (rsize--) {
unsigned char pixels = *sprite++;
unsigned char mask = 0;
- if((pixels & 0xC0) == 0)
- {
- bi >>= 1; if(bi == 0) { bi = 0x80; bitmask++; }
- if(*bitmask & bi)
+ if ((pixels & 0xC0) == 0) {
+ bi >>= 1;
+ if (bi == 0) {
+ bi = 0x80;
+ bitmask++;
+ }
+ if (*bitmask & bi)
mask |= 0xC0;
}
- if((pixels & 0x30) == 0)
- {
- bi >>= 1; if(bi == 0) { bi = 0x80; bitmask++; }
- if(*bitmask & bi)
+ if ((pixels & 0x30) == 0) {
+ bi >>= 1;
+ if (bi == 0) {
+ bi = 0x80;
+ bitmask++;
+ }
+ if (*bitmask & bi)
mask |= 0x30;
}
- if((pixels & 0xC) == 0)
- {
- bi >>= 1; if(bi == 0) { bi = 0x80; bitmask++; }
- if(*bitmask & bi)
+ if ((pixels & 0xC) == 0) {
+ bi >>= 1;
+ if (bi == 0) {
+ bi = 0x80;
+ bitmask++;
+ }
+ if (*bitmask & bi)
mask |= 0xC;
}
- if((pixels & 0x3) == 0)
- {
- bi >>= 1; if(bi == 0) { bi = 0x80; bitmask++; }
- if(*bitmask & bi)
+ if ((pixels & 0x3) == 0) {
+ bi >>= 1;
+ if (bi == 0) {
+ bi = 0x80;
+ bitmask++;
+ }
+ if (*bitmask & bi)
mask |= 0x3;
}
*buffer++ = mask;
@@ -560,22 +517,20 @@ extern unsigned char sprit_data[RES_SPRIT_MAX];
unsigned char sprit_load_buffer[1290];
-unsigned char *LoadSprit(unsigned char index)
-{
+unsigned char *LoadSprit(unsigned char index) {
LoadSprite(index, sprit_data + 4, sprit_load_buffer, 0);
return sprit_load_buffer;
}
-unsigned char *LoadPersSprit(unsigned char index)
-{
+unsigned char *LoadPersSprit(unsigned char index) {
#if 1
-/*Use separate memory for pers1/pers2*/
- if(index < 61)
+ /*Use separate memory for pers1/pers2*/
+ if (index < 61)
LoadSprite(index, pers1_data + 4, scratch_mem2, 0);
else
LoadSprite(index - 61, pers2_data + 4, scratch_mem2, 0);
#else
-/*Use single large chunk for pers1+pers2*/
+ /*Use single large chunk for pers1+pers2*/
LoadSprite(index, pers1_data + 4, scratch_mem2, 0);
#endif
@@ -583,26 +538,23 @@ unsigned char *LoadPersSprit(unsigned char index)
}
-void DrawSpriteN(unsigned char index, unsigned int x, unsigned int y, unsigned char *target)
-{
+void DrawSpriteN(unsigned char index, unsigned int x, unsigned int y, unsigned char *target) {
unsigned int ofs;
unsigned char *sprite;
- sprite = LoadSprit(index);
+ 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)
-{
+void DrawSpriteNFlip(unsigned char index, unsigned int x, unsigned int y, unsigned char *target) {
unsigned int ofs;
unsigned char *sprite;
- sprite = LoadSprit(index);
+ sprite = LoadSprit(index);
ofs = CGA_CalcXY_p(x, y);
DrawSpriteFlip(sprite, target, ofs);
}
-void BackupAndShowSprite(unsigned char index, unsigned char x, unsigned char y)
-{
+void BackupAndShowSprite(unsigned char index, unsigned char x, unsigned char y) {
unsigned char w, h;
unsigned int ofs;
unsigned char *sprite = LoadSprit(index);
@@ -610,7 +562,7 @@ void BackupAndShowSprite(unsigned char index, unsigned char x, unsigned char y)
w = sprite[0];
h = sprite[1];
CGA_BackupImageReal(ofs, w, h);
- DrawSprite(sprite, CGA_SCREENBUFFER, ofs); /*DrawSpriteN(index, x, y, CGA_SCREENBUFFER);*/
+ DrawSprite(sprite, CGA_SCREENBUFFER, ofs); /*DrawSpriteN(index, x, y, CGA_SCREENBUFFER);*/
}
/*
@@ -618,12 +570,10 @@ 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)
-{
+void CGA_AnimLiftToDown(unsigned char *pixels, unsigned int pw, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) {
unsigned int i;
pixels += pw * (h - 1);
- for(i = 1;i <= h;i++)
- {
+ for (i = 1; i <= h; i++) {
CGA_BlitAndWait(pixels, pw, w, i, screen, ofs);
pixels -= pw;
}
@@ -635,11 +585,9 @@ 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)
-{
+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;
- for(i = 0;i < n;i++)
- {
+ for (i = 0; i < n; i++) {
CGA_BlitAndWait(pixels, pw, w + i, h, screen, ofs);
ofs -= 1;
}
@@ -650,11 +598,9 @@ 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)
-{
+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;
- for(i = 0;i < n;i++)
- {
+ for (i = 0; i < n; i++) {
CGA_BlitAndWait(pixels, pw, w + i, h, screen, ofs);
pixels -= 1;
}
@@ -666,11 +612,9 @@ 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)
-{
+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;
- for(i = 1;i <= h;i++)
- {
+ for (i = 1; i <= h; i++) {
CGA_BlitAndWait(pixels, pw, w, i, screen, CGA_CalcXY_p(x, y));
y -= 1;
}
@@ -680,10 +624,8 @@ 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)
-{
- while(n--)
- {
+void CGA_HideScreenBlockLiftToDown(unsigned int n, unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs) {
+ while (n--) {
int i;
unsigned int sofs, tofs;
@@ -691,12 +633,11 @@ void CGA_HideScreenBlockLiftToDown(unsigned int n, unsigned char *screen, unsign
tofs = ofs;
tofs ^= CGA_ODD_LINES_OFS;
- if((tofs & CGA_ODD_LINES_OFS) == 0)
+ if ((tofs & CGA_ODD_LINES_OFS) == 0)
tofs += CGA_BYTES_PER_LINE;
- /*shift whole block 1 line*/
- for(i = 0;i < h;i++)
- {
+ /*shift whole block 1 line*/
+ for (i = 0; i < h; i++) {
/*copy current line to next*/
memcpy(target + tofs, screen + sofs, w);
@@ -705,7 +646,7 @@ void CGA_HideScreenBlockLiftToDown(unsigned int n, unsigned char *screen, unsign
/*go 1 line up*/
sofs ^= CGA_ODD_LINES_OFS;
- if((sofs & CGA_ODD_LINES_OFS) != 0)
+ if ((sofs & CGA_ODD_LINES_OFS) != 0)
sofs -= CGA_BYTES_PER_LINE;
}
@@ -714,7 +655,7 @@ void CGA_HideScreenBlockLiftToDown(unsigned int n, unsigned char *screen, unsign
WaitVBlank();
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
}
@@ -723,10 +664,8 @@ 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)
-{
- while(n--)
- {
+void CGA_HideScreenBlockLiftToUp(unsigned int n, unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs) {
+ while (n--) {
int i;
unsigned int sofs, tofs;
@@ -734,12 +673,11 @@ void CGA_HideScreenBlockLiftToUp(unsigned int n, unsigned char *screen, unsigned
tofs = ofs;
tofs ^= CGA_ODD_LINES_OFS;
- if((tofs & CGA_ODD_LINES_OFS) != 0)
+ if ((tofs & CGA_ODD_LINES_OFS) != 0)
tofs -= CGA_BYTES_PER_LINE;
- /*shift whole block 1 line*/
- for(i = 0;i < h;i++)
- {
+ /*shift whole block 1 line*/
+ for (i = 0; i < h; i++) {
/*copy current line to next*/
memcpy(target + tofs, screen + sofs, w);
@@ -748,7 +686,7 @@ void CGA_HideScreenBlockLiftToUp(unsigned int n, unsigned char *screen, unsigned
/*go 1 line down*/
sofs ^= CGA_ODD_LINES_OFS;
- if((sofs & CGA_ODD_LINES_OFS) == 0)
+ if ((sofs & CGA_ODD_LINES_OFS) == 0)
sofs += CGA_BYTES_PER_LINE;
}
@@ -757,7 +695,7 @@ void CGA_HideScreenBlockLiftToUp(unsigned int n, unsigned char *screen, unsigned
WaitVBlank();
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) != 0)
+ if ((ofs & CGA_ODD_LINES_OFS) != 0)
ofs -= CGA_BYTES_PER_LINE;
}
}
@@ -766,18 +704,15 @@ 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)
-{
- while(n--)
- {
+void CGA_HideScreenBlockLiftToLeft(unsigned int n, unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs) {
+ while (n--) {
int i;
unsigned int sofs, tofs;
sofs = ofs;
/*shift whole block 1 column*/
- for(i = 0;i < h;i++)
- {
+ for (i = 0; i < h; i++) {
tofs = sofs - 1;
memcpy(target + tofs, screen + sofs, w);
@@ -786,33 +721,30 @@ void CGA_HideScreenBlockLiftToLeft(unsigned int n, unsigned char *screen, unsign
/*go 1 line down*/
sofs ^= CGA_ODD_LINES_OFS;
- if((sofs & CGA_ODD_LINES_OFS) == 0)
+ if ((sofs & CGA_ODD_LINES_OFS) == 0)
sofs += CGA_BYTES_PER_LINE;
}
WaitVBlank();
ofs--;
- }
+ }
}
/*Copy interlaced screen data n lines right (with clipping)*/
/*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(unsigned int n, unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs) {
/*TODO: check me if its ok*/
- while(n--)
- {
+ while (n--) {
int i;
unsigned int sofs, tofs;
sofs = ofs;
/*shift whole block 1 column*/
- for(i = 0;i < h;i++)
- {
+ for (i = 0; i < h; i++) {
tofs = sofs + 1;
memcpy(target + tofs - w, screen + sofs - w, w);
@@ -821,111 +753,103 @@ void CGA_HideScreenBlockLiftToRight(unsigned int n, unsigned char *screen, unsig
/*go 1 line down*/
sofs ^= CGA_ODD_LINES_OFS;
- if((sofs & CGA_ODD_LINES_OFS) == 0)
+ if ((sofs & CGA_ODD_LINES_OFS) == 0)
sofs += CGA_BYTES_PER_LINE;
}
WaitVBlank();
ofs++;
- }
+ }
}
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;
+ 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;
} scrpiece_t;
static const unsigned char 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,
- 86, 214, 173, 91, 91, 85, 88, 170, 173, 85, 170, 181,
- 85, 182, 168, 170, 170, 171, 85, 85, 90, 170, 168, 170,
+ 86, 214, 173, 91, 91, 85, 88, 170, 173, 85, 170, 181,
+ 85, 182, 168, 170, 170, 171, 85, 85, 90, 170, 168, 170,
170, 170, 170, 170, 170, 170, 168, 213, 82, 170, 85,
- 74, 170, 73, 88, 170, 169, 41, 82, 164, 164, 170, 168,
+ 74, 170, 73, 88, 170, 169, 41, 82, 164, 164, 170, 168,
170, 148, 165, 41, 74, 73, 41, 40, 201, 41, 37, 36,
164, 148, 148, 152, 164, 146, 73, 36, 146, 73, 36, 152,
164, 73, 18, 68, 145, 36, 68, 136, 145, 34, 36, 68,
136, 145, 18, 40, 145, 16, 136, 136, 68, 68, 66, 24,
136, 66, 16, 132, 33, 8, 66, 24, 132, 16, 65, 8, 32,
132, 16, 72, 130, 4, 8, 8, 16, 32, 32, 72, 128, 128,
- 64, 32, 8, 2, 1, 8, 128, 8, 0, 32, 0, 128, 8, 8, 128,
- 0, 4, 0, 0, 4, 0, 8, 128, 0, 0, 0, 0, 0, 0, 8
+ 64, 32, 8, 2, 1, 8, 128, 8, 0, 32, 0, 128, 8, 8, 128,
+ 0, 4, 0, 0, 4, 0, 8, 128, 0, 0, 0, 0, 0, 0, 8
};
/*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)
-{
+static void ScreenToPieces(unsigned char width, unsigned char height, unsigned char *screen, unsigned int offs, scrpiece_t *pieces) {
const unsigned char *delays = piecedelays;
height = (height + 3) / 4;
- while(height--)
- {
+ while (height--) {
unsigned int x;
- for(x = 0;x < width;x++)
- {
+ for (x = 0; x < width; x++) {
unsigned int bofs = offs + x;
pieces->offs = bofs;
pieces->delay = *delays++;
- if(pieces->delay == 0) /*ensure piece is alive*/
+ if (pieces->delay == 0) /*ensure piece is alive*/
pieces->delay = 1;
pieces->pix0 = screen[bofs];
pieces->pix2 = screen[bofs + CGA_BYTES_PER_LINE];
bofs ^= CGA_ODD_LINES_OFS;
- if((bofs & CGA_ODD_LINES_OFS) == 0)
+ if ((bofs & CGA_ODD_LINES_OFS) == 0)
bofs += CGA_BYTES_PER_LINE;
pieces->pix1 = screen[bofs];
pieces->pix3 = screen[bofs + CGA_BYTES_PER_LINE];
pieces++;
}
- offs += CGA_BYTES_PER_LINE * 2; /*4 lines down*/
+ offs += CGA_BYTES_PER_LINE * 2; /*4 lines down*/
}
- pieces->offs = 0; /*end of list*/
+ pieces->offs = 0; /*end of list*/
}
-static void FallPieces(scrpiece_t *pieces, unsigned char *source, unsigned char *target)
-{
+static void FallPieces(scrpiece_t *pieces, unsigned char *source, unsigned char *target) {
unsigned char t = 1;
unsigned char again = 0;
- do
- {
+ do {
scrpiece_t *piece;
- for(piece = pieces, again = 0;piece->offs;piece++)
- {
- if((piece->delay >> 2) < t)
- {
+ for (piece = pieces, again = 0; piece->offs; piece++) {
+ if ((piece->delay >> 2) < t) {
unsigned int offs = piece->offs;
unsigned int bofs = offs;
- if(target[bofs] == piece->pix0)
+ if (target[bofs] == piece->pix0)
target[bofs] = source[bofs];
- if(target[bofs+CGA_BYTES_PER_LINE] == piece->pix2)
- target[bofs+CGA_BYTES_PER_LINE] = source[bofs+CGA_BYTES_PER_LINE];
+ if (target[bofs + CGA_BYTES_PER_LINE] == piece->pix2)
+ target[bofs + CGA_BYTES_PER_LINE] = source[bofs + CGA_BYTES_PER_LINE];
bofs ^= CGA_ODD_LINES_OFS;
- if((bofs & CGA_ODD_LINES_OFS) == 0)
+ if ((bofs & CGA_ODD_LINES_OFS) == 0)
bofs += CGA_BYTES_PER_LINE;
- if(target[bofs] == piece->pix1)
+ if (target[bofs] == piece->pix1)
target[bofs] = source[bofs];
- if(target[bofs+CGA_BYTES_PER_LINE] == piece->pix3)
- target[bofs+CGA_BYTES_PER_LINE] = source[bofs+CGA_BYTES_PER_LINE];
+ if (target[bofs + CGA_BYTES_PER_LINE] == piece->pix3)
+ target[bofs + CGA_BYTES_PER_LINE] = source[bofs + CGA_BYTES_PER_LINE];
/*dead?*/
- if(piece->delay == 0)
+ if (piece->delay == 0)
continue;
/*fall n lines*/
- switch((piece->delay & 3) + 1)
- {
+ switch ((piece->delay & 3) + 1) {
case 1:
offs ^= CGA_ODD_LINES_OFS;
- if((offs & CGA_ODD_LINES_OFS) == 0)
+ if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
break;
case 2:
@@ -934,7 +858,7 @@ static void FallPieces(scrpiece_t *pieces, unsigned char *source, unsigned char
case 3:
offs += CGA_BYTES_PER_LINE;
offs ^= CGA_ODD_LINES_OFS;
- if((offs & CGA_ODD_LINES_OFS) == 0)
+ if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
break;
case 4:
@@ -946,11 +870,10 @@ static void FallPieces(scrpiece_t *pieces, unsigned char *source, unsigned char
/*extra 2 lines*/
offs += CGA_BYTES_PER_LINE;
- piece->offs = offs;
+ piece->offs = offs;
/*past line 190?*/
- if((offs | CGA_ODD_LINES_OFS) >= ((190 / 2 * CGA_BYTES_PER_LINE) | CGA_ODD_LINES_OFS))
- {
+ if ((offs | CGA_ODD_LINES_OFS) >= ((190 / 2 * CGA_BYTES_PER_LINE) | CGA_ODD_LINES_OFS)) {
piece->delay = 0;
continue;
}
@@ -958,32 +881,29 @@ static void FallPieces(scrpiece_t *pieces, unsigned char *source, unsigned char
bofs = offs;
target[bofs] = piece->pix0;
- target[bofs+CGA_BYTES_PER_LINE] = piece->pix2;
+ target[bofs + CGA_BYTES_PER_LINE] = piece->pix2;
bofs ^= CGA_ODD_LINES_OFS;
- if((bofs & CGA_ODD_LINES_OFS) == 0)
+ if ((bofs & CGA_ODD_LINES_OFS) == 0)
bofs += CGA_BYTES_PER_LINE;
target[bofs] = piece->pix1;
- target[bofs+CGA_BYTES_PER_LINE] = piece->pix3;
+ target[bofs + CGA_BYTES_PER_LINE] = piece->pix3;
}
again = 1;
}
WaitVBlank();
t++;
- }
- while(again);
+ } while (again);
}
-void CGA_HideShatterFall(unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int ofs)
-{
- scrpiece_t *pieces = (scrpiece_t*)scratch_mem2;
+void CGA_HideShatterFall(unsigned char *screen, unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int 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)
-{
+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;
@@ -991,20 +911,18 @@ void CGA_TraceLine(unsigned int sx, unsigned int ex, unsigned int sy, unsigned i
unsigned int count;
int w, h, dx, dy, val;
- if(ex >= sx)
+ if (ex >= sx)
w = ex - sx;
- else
- {
+ else {
w = sx - ex - 1;
b0 = 1;
}
dx = -(w * 2) - 1;
- if(ey >= sy)
+ if (ey >= sy)
h = ey - sy;
- else
- {
+ else {
h = sy - ey - 1;
b1 = 1;
}
@@ -1019,46 +937,34 @@ void CGA_TraceLine(unsigned int sx, unsigned int ex, unsigned int sy, unsigned i
count = w + h;
- while(count--)
- {
- if(val > 0)
- {
- if(b1 == 0)
- {
+ while (count--) {
+ if (val > 0) {
+ if (b1 == 0) {
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
- }
- else
- {
+ } else {
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) != 0)
+ if ((ofs & CGA_ODD_LINES_OFS) != 0)
ofs -= CGA_BYTES_PER_LINE;
}
val += dx;
- }
- else
- {
- if(b0 == 0)
- {
+ } else {
+ if (b0 == 0) {
mask >>= 2;
- if(mask == 0)
- {
+ if (mask == 0) {
mask = 0xC0;
ofs += 1;
}
- }
- else
- {
+ } else {
mask <<= 2;
- if(mask == 0)
- {
+ if (mask == 0) {
mask = 0x03;
ofs -= 1;
}
}
val += dy;
- if(val > 0)
+ if (val > 0)
continue;
}
target[ofs] = (target[ofs] & ~mask) | (source[ofs] & mask);
diff --git a/engines/chamber/cga.h b/engines/chamber/cga.h
index 68ee5f3a86b..7e91711dd17 100644
--- a/engines/chamber/cga.h
+++ b/engines/chamber/cga.h
@@ -49,8 +49,8 @@ unsigned int CGA_CalcXY_p(unsigned int x, unsigned int y);
void CGA_CopyScreenBlock(unsigned char *source, unsigned int w, unsigned int h, unsigned char *target, unsigned int 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);
+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);
void CGA_RestoreImage(unsigned char *buffer, unsigned char *target);
void CGA_RefreshImageData(unsigned char *buffer);
@@ -82,7 +82,7 @@ void DrawSpriteNFlip(unsigned char index, unsigned int x, unsigned int y, unsign
void BackupAndShowSprite(unsigned char index, unsigned char x, unsigned char y);
-unsigned char * LoadSprite(unsigned char index, unsigned char *bank, unsigned char *buffer, unsigned char header_only);
+unsigned char *LoadSprite(unsigned char index, unsigned char *bank, unsigned char *buffer, unsigned char header_only);
unsigned char *LoadSprit(unsigned char index);
unsigned char *LoadPersSprit(unsigned char index);
diff --git a/engines/chamber/chamber.cpp b/engines/chamber/chamber.cpp
index 69bf91829b2..18dacefbf5f 100644
--- a/engines/chamber/chamber.cpp
+++ b/engines/chamber/chamber.cpp
@@ -25,37 +25,32 @@ unsigned short cpu_speed_delay;
/*
Prompt user to insert disk #2 to any drive
*/
-void AskDisk2(void)
-{
+void AskDisk2(void) {
DrawMessage(SeekToString(vepci_data, 179), frontbuffer);
}
-void SaveToFile(char *filename, void *data, unsigned int size)
-{
+void SaveToFile(char *filename, void *data, unsigned int size) {
FILE *f = fopen(filename, "wb");
fwrite(data, 1, size, f);
fclose(f);
}
-int LoadSplash(char *filename)
-{
- if(!LoadFile(filename, scratch_mem1))
+int LoadSplash(char *filename) {
+ if (!LoadFile(filename, scratch_mem1))
return 0;
- decompress(scratch_mem1 + 8, backbuffer); /* skip compressed/decompressed size fields */
+ decompress(scratch_mem1 + 8, backbuffer); /* skip compressed/decompressed size fields */
return 1;
}
-unsigned int BenchmarkCpu(void)
-{
+unsigned int BenchmarkCpu(void) {
unsigned char t;
unsigned int 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++;
+ 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;
}
-void Randomize(void)
-{
+void Randomize(void) {
union REGS reg;
reg.h.ah = 0;
@@ -64,17 +59,14 @@ void Randomize(void)
Rand();
}
-void TRAP()
-{
+void TRAP() {
PromptWait();
- for(;;) ;
+ for (;;) ;
}
/* Main Game Loop */
-void GameLoop(unsigned char *target)
-{
- for(;;)
- {
+void GameLoop(unsigned char *target) {
+ for (;;) {
#if 1
AnimateSpots(target);
#endif
@@ -87,80 +79,71 @@ void GameLoop(unsigned char *target)
PollInput();
the_command = 0;
- if(IsCursorInRect(&room_bounds_rect))
- {
+ if (IsCursorInRect(&room_bounds_rect)) {
SelectCursor(CURSOR_1);
command_hint = 100;
SelectSpotCursor();
- }
- else
- {
+ } else {
SelectCursor(CURSOR_0);
object_hint = 117;
CheckMenuCommandHover();
}
- if(object_hint != last_object_hint)
+ if (object_hint != last_object_hint)
DrawObjectHint();
- if(command_hint != last_command_hint)
+ if (command_hint != last_command_hint)
DrawCommandHint();
DrawHintsAndCursor(target);
- if(!buttons || !the_command)
- {
+ if (!buttons || !the_command) {
/*Pending / AI commands*/
- if(script_byte_vars.check_used_commands < script_byte_vars.used_commands)
- {
+ if (script_byte_vars.check_used_commands < script_byte_vars.used_commands) {
the_command = Swap16(script_word_vars.next_command1);
- if(the_command)
+ if (the_command)
goto process;
}
- if(script_byte_vars.flag_179FB)
+ if (script_byte_vars.flag_179FB)
continue;
the_command = Swap16(script_word_vars.next_command2);
- if(the_command)
+ if (the_command)
goto process;
- if(Swap16(next_ticks3) < script_word_vars.timer_ticks2) /*TODO: is this ok? ticks2 is BE, ticks3 is LE*/
- {
+ if (Swap16(next_ticks3) < script_word_vars.timer_ticks2) { /*TODO: is this ok? ticks2 is BE, ticks3 is LE*/
the_command = next_command3;
- if(the_command)
+ if (the_command)
goto process;
}
- if(Swap16(next_ticks4) < script_word_vars.timer_ticks2) /*TODO: is this ok? ticks2 is BE, ticks4 is LE*/
- {
+ if (Swap16(next_ticks4) < script_word_vars.timer_ticks2) { /*TODO: is this ok? ticks2 is BE, ticks4 is LE*/
the_command = next_command4;
- if(the_command)
+ if (the_command)
goto process;
}
continue;
-process:;
+process:
+ ;
UpdateUndrawCursor(target);
RefreshSpritesData();
RunCommand();
BlitSpritesToBackBuffer();
ProcessInput();
DrawSpots(target);
- }
- else
- {
+ } else {
/*Player action*/
UpdateUndrawCursor(target);
RefreshSpritesData();
RunCommandKeepSp();
script_byte_vars.used_commands++;
- if(script_byte_vars.dead_flag)
- {
- if(--script_byte_vars.tries_left == 0)
+ if (script_byte_vars.dead_flag) {
+ if (--script_byte_vars.tries_left == 0)
ResetAllPersons();
}
BlitSpritesToBackBuffer();
@@ -171,20 +154,18 @@ process:;
}
-void ExitGame(void)
-{
+void ExitGame(void) {
SwitchToTextMode();
exit(0);
}
-void main(void)
-{
+void main(void) {
unsigned char c;
SwitchToGraphicsMode();
/* Load title screen */
- if(!LoadSplash("PRES.BIN"))
+ if (!LoadSplash("PRES.BIN"))
ExitGame();
/* Select intense cyan-mageta palette */
@@ -195,11 +176,11 @@ void main(void)
#ifdef COPYPROT
/* Check if a valid floppy disk is present in any drive */
- if(!CheckCopyProtection()) for(;;) ;
+ if (!CheckCopyProtection()) for (;;) ;
#endif
/* Load language selection screen */
- if(!LoadSplash("DRAP.BIN"))
+ if (!LoadSplash("DRAP.BIN"))
ExitGame();
/* Wait for a keypress and show the language selection screen */
@@ -209,13 +190,11 @@ void main(void)
ClearKeyboard();
/* Wait for a valid language choice */
- do
- {
+ do {
c = ReadKeyboardChar();
- if(c > 'F')
+ if (c > 'F')
c -= ' ';
- }
- while(c < 'D' || c > 'F');
+ } while (c < 'D' || c > 'F');
/* Patch resource names for choosen language */
res_texts[0].name[4] = c;
@@ -227,15 +206,15 @@ void main(void)
/* Load script and other static resources */
/* Those are normally embedded in the executable, but here we load extracted ones*/
- if(!LoadStaticData())
+ if (!LoadStaticData())
ExitGame();
/* Load text resources */
- if(!LoadVepciData() || !LoadDesciData() || !LoadDialiData())
+ if (!LoadVepciData() || !LoadDesciData() || !LoadDialiData())
ExitGame();
/* Load graphics resources */
- while(!LoadFond() || !LoadSpritesData() || !LoadPersData())
+ while (!LoadFond() || !LoadSpritesData() || !LoadPersData())
AskDisk2();
/* Detect/Initialize input device */
@@ -254,7 +233,8 @@ void main(void)
cpu_speed_delay = BenchmarkCpu() / 8;
/*restart game from here*/
-restart:;
+restart:
+ ;
Randomize();
/* Set start zone */
@@ -266,8 +246,7 @@ restart:;
#ifdef DEBUG_SCRIPT
{
FILE *f = fopen(DEBUG_SCRIPT_LOG, "wt+");
- if(f)
- {
+ if (f) {
fclose(f);
}
}
diff --git a/engines/chamber/common.h b/engines/chamber/common.h
index 61938be538a..ed4ca3146fd 100644
--- a/engines/chamber/common.h
+++ b/engines/chamber/common.h
@@ -5,11 +5,11 @@
#define LE16(x) (x)
#define TODO(s) \
-{ \
- printf(s); \
- PromptWait(); \
- for(;;) ; \
-}
+ { \
+ printf(s); \
+ PromptWait(); \
+ for(;;) ; \
+ }
typedef struct rect_t {
unsigned char sx;
diff --git a/engines/chamber/cursor.cpp b/engines/chamber/cursor.cpp
index b5556405b6e..03e9a7a6a04 100644
--- a/engines/chamber/cursor.cpp
+++ b/engines/chamber/cursor.cpp
@@ -35,8 +35,7 @@ unsigned char cursor_bit_shift;
/*
Select cursor shape and its hotspot
*/
-void SelectCursor(unsigned int num)
-{
+void SelectCursor(unsigned int 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;
@@ -45,13 +44,14 @@ void SelectCursor(unsigned int num)
/*
Build cursor sprite for its current pixel-grained position
*/
-void UpdateCursor(void)
-{
+void UpdateCursor(void) {
unsigned char *cursor, *sprite, *spr;
unsigned char cursor_bit_shift;
unsigned int x, y;
- x = cursor_x - cursor_x_shift; if((signed int)x < 0) x = 0;
- y = cursor_y - cursor_y_shift; if((signed int)y < 0) y = 0;
+ x = cursor_x - cursor_x_shift;
+ if ((signed int)x < 0) x = 0;
+ y = cursor_y - cursor_y_shift;
+ if ((signed int)y < 0) y = 0;
cursor_bit_shift = (x % 4) * 2;
cursor_draw_ofs = CGA_CalcXY_p(x / 4, y);
@@ -59,14 +59,11 @@ void UpdateCursor(void)
cursor = cursor_shape;
sprite = sprit_load_buffer;
- if(cursor_bit_shift == 0)
- {
+ if (cursor_bit_shift == 0) {
/*pixels*/
spr = sprite;
- for(y = 0;y < CURSOR_HEIGHT;y++)
- {
- for(x = 0;x < CURSOR_WIDTH / 4;x++)
- {
+ for (y = 0; y < CURSOR_HEIGHT; y++) {
+ for (x = 0; x < CURSOR_WIDTH / 4; x++) {
unsigned char p = *cursor++;
spr[x * 2] = p;
}
@@ -76,30 +73,24 @@ void UpdateCursor(void)
/*mask*/
spr = sprite + 1;
- for(y = 0;y < CURSOR_HEIGHT;y++)
- {
- for(x = 0;x < CURSOR_WIDTH / 4;x++)
- {
+ for (y = 0; y < CURSOR_HEIGHT; y++) {
+ for (x = 0; x < CURSOR_WIDTH / 4; x++) {
unsigned char p = *cursor++;
spr[x * 2] = p;
}
spr[x * 2] = 0xFF;
spr += 5 * 2;
}
- }
- else
- {
+ } else {
spr = sprite;
- for(y = 0;y < CURSOR_HEIGHT;y++)
- {
+ 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;
- for(i = 0;i < cursor_bit_shift;i++)
- {
+ for (i = 0; i < cursor_bit_shift; i++) {
p4 = (p4 >> 1) | (p3 << 7);
p3 = (p3 >> 1) | (p2 << 7);
p2 = (p2 >> 1) | (p1 << 7);
@@ -116,16 +107,14 @@ void UpdateCursor(void)
}
spr = sprite + 1;
- for(y = 0;y < CURSOR_HEIGHT;y++)
- {
+ 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;
- for(i = 0;i < cursor_bit_shift;i++)
- {
+ for (i = 0; i < cursor_bit_shift; i++) {
p4 = (p4 >> 1) | (p3 << 7);
p3 = (p3 >> 1) | (p2 << 7);
p2 = (p2 >> 1) | (p1 << 7);
@@ -145,8 +134,7 @@ void UpdateCursor(void)
/*
Draw cursor sprite and backup background pixels
*/
-void DrawCursor(unsigned char *target)
-{
+void DrawCursor(unsigned char *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);
}
@@ -154,16 +142,14 @@ void DrawCursor(unsigned char *target)
/*
Restore background pixels under cursor
*/
-void UndrawCursor(unsigned char *target)
-{
+void UndrawCursor(unsigned char *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(unsigned char *target) {
/*TODO: does this call order makes any sense?*/
UpdateCursor();
UndrawCursor(target);
diff --git a/engines/chamber/decompr.cpp b/engines/chamber/decompr.cpp
index 1c3220ecfc6..195073a47f8 100644
--- a/engines/chamber/decompr.cpp
+++ b/engines/chamber/decompr.cpp
@@ -7,15 +7,12 @@ static struct {
unsigned char stackpos;
} DecompCtx;
-unsigned char decode_string(unsigned char code, unsigned char prev_n, unsigned char *stack)
-{
+unsigned char decode_string(unsigned char code, unsigned char prev_n, unsigned char *stack) {
unsigned char n;
- while((n = DecompCtx.coddict[code]) != 0)
- {
- while(n >= prev_n)
- {
+ while ((n = DecompCtx.coddict[code]) != 0) {
+ while (n >= prev_n) {
n = DecompCtx.codlink[n];
- if(n == 0)
+ if (n == 0)
return code;
}
/*if(DecompCtx.stackpos == 255) exit("stack exploded");*/
@@ -25,8 +22,7 @@ unsigned char decode_string(unsigned char code, unsigned char prev_n, unsigned c
return code;
}
-unsigned long decompress(unsigned char huge *data, unsigned char huge *result)
-{
+unsigned long decompress(unsigned char huge *data, unsigned char huge *result) {
unsigned char dict_size, more;
unsigned int compsize;
unsigned int i;
@@ -34,52 +30,43 @@ unsigned long decompress(unsigned char huge *data, unsigned char huge *result)
unsigned char stack[256];
unsigned long decompsize = 0;
- do
- {
+ do {
dict_size = *data++;
more = *data++;
compsize = *data++;
compsize |= (*data++) << 8;
- if(dict_size == 0)
- {
+ if (dict_size == 0) {
/* uncompressed block */
decompsize += compsize;
while (compsize--)
*result++ = *data++;
- }
- else
- {
+ } else {
/* compressed block */
/*
memcpy(DecompCtx.codes + 1, data, dict_size); data += dict_size;
memcpy(DecompCtx.prefix + 1, data, dict_size); data += dict_size;
memcpy(DecompCtx.suffix + 1, data, dict_size); data += dict_size;
*/
- for(n = 1, i = 0; i < dict_size;n++, i++) DecompCtx.codes[n] = *data++;
- for(n = 1, i = 0; i < dict_size;n++, i++) DecompCtx.prefix[n] = *data++;
- for(n = 1, i = 0; i < dict_size;n++, i++) DecompCtx.suffix[n] = *data++;
+ for (n = 1, i = 0; i < dict_size; n++, i++) DecompCtx.codes[n] = *data++;
+ for (n = 1, i = 0; i < dict_size; n++, i++) DecompCtx.prefix[n] = *data++;
+ for (n = 1, i = 0; i < dict_size; n++, i++) DecompCtx.suffix[n] = *data++;
memset(DecompCtx.coddict, 0, 256);
- for(n = 1, i = 0; i < dict_size;n++, i++)
- {
+ for (n = 1, i = 0; i < dict_size; n++, i++) {
code = DecompCtx.codes[n];
DecompCtx.codlink[n] = DecompCtx.coddict[code];
DecompCtx.coddict[code] = n;
}
- while(compsize-- > 0)
- {
+ while (compsize-- > 0) {
code = *data++;
- if(DecompCtx.coddict[code] == 0)
- {
+ if (DecompCtx.coddict[code] == 0) {
/* literal */
*result++ = code;
decompsize += 1;
- }
- else
- {
+ } else {
/* string */
DecompCtx.stackpos = 0;
@@ -87,20 +74,18 @@ unsigned long decompress(unsigned char huge *data, unsigned char huge *result)
stack[DecompCtx.stackpos++] = n;
- for(code = DecompCtx.prefix[n];;code = DecompCtx.suffix[n])
- {
+ for (code = DecompCtx.prefix[n];; code = DecompCtx.suffix[n]) {
suffix = decode_string(code, n, stack);
*result++ = suffix;
decompsize += 1;
- if(DecompCtx.stackpos == 0)
+ if (DecompCtx.stackpos == 0)
break;
n = stack[--DecompCtx.stackpos];
}
}
}
}
- }
- while(more != 0);
+ } while (more != 0);
return decompsize;
}
diff --git a/engines/chamber/dialog.cpp b/engines/chamber/dialog.cpp
index b162c8c9d33..2fd3f5b09aa 100644
--- a/engines/chamber/dialog.cpp
+++ b/engines/chamber/dialog.cpp
@@ -12,12 +12,11 @@ unsigned int cur_dlg_index;
#define MAX_DIRTY_RECT 10
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)
-{
+void AddDirtyRect(unsigned char kind, unsigned char x, unsigned char y, unsigned char w, unsigned char h, unsigned int offs) {
int i;
dirty_rect_t *r = dirty_rects;
- for(i = 0;i < MAX_DIRTY_RECT;i++, r++) /*TODO: may go oob*/
- if(r->kind == DirtyRectFree)
+ for (i = 0; i < MAX_DIRTY_RECT; i++, r++) /*TODO: may go oob*/
+ if (r->kind == DirtyRectFree)
break;
r->kind = kind;
r->offs = offs;
@@ -28,8 +27,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(int index, unsigned char *kind, unsigned char *x, unsigned char *y, unsigned char *w, unsigned char *h, unsigned int *offs, unsigned char newkind) {
*kind = dirty_rects[index].kind;
*offs = dirty_rects[index].offs;
*w = dirty_rects[index].width;
@@ -41,23 +39,18 @@ 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(int index, unsigned char *kind, unsigned char *x, unsigned char *y, unsigned char *w, unsigned char *h, unsigned int *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(int index, unsigned char *kind, unsigned char *x, unsigned char *y, unsigned char *w, unsigned char *h, unsigned int *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 FindDirtyRectAndFree(unsigned char kind, unsigned char *x, unsigned char *y, unsigned char *w, unsigned char *h, unsigned int *offs) {
int i;
- for(i = 0;i < MAX_DIRTY_RECT;i++)
- {
- if(dirty_rects[i].kind == kind)
- {
+ for (i = 0; i < MAX_DIRTY_RECT; i++) {
+ if (dirty_rects[i].kind == kind) {
GetDirtyRect(i, &kind, x, y, w, h, offs, DirtyRectFree);
return 1;
}
@@ -66,24 +59,20 @@ 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)
-{
+void PopDirtyRects(unsigned char kind) {
unsigned char x, y;
unsigned char width, height;
unsigned int offs;
- while(FindDirtyRectAndFree(kind, &x, &y, &width, &height, &offs))
- {
+ while (FindDirtyRectAndFree(kind, &x, &y, &width, &height, &offs)) {
CGA_CopyScreenBlock(backbuffer, width, height, frontbuffer, offs);
- if(kind == DirtyRectBubble)
- {
+ if (kind == DirtyRectBubble) {
/*pop bubble's spike*/
CGA_CopyScreenBlock(backbuffer, 2, 21, frontbuffer, offs = (x << 8) | y);
}
}
}
-void DesciTextBox(unsigned int x, unsigned int y, unsigned int width, unsigned char *msg)
-{
+void DesciTextBox(unsigned int x, unsigned int y, unsigned int width, unsigned char *msg) {
draw_x = x;
draw_y = y;
char_draw_max_width = width;
@@ -92,8 +81,7 @@ 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)
-{
+void DrawPersonBubble(unsigned char x, unsigned char y, unsigned char flags, unsigned char *msg) {
unsigned int ofs;
unsigned char w, h;
@@ -104,21 +92,20 @@ void DrawPersonBubble(unsigned char x, unsigned char y, unsigned char flags, uns
ofs = CGA_CalcXY_p(x, y);
ofs = CGA_DrawHLineWithEnds(0xF00F, 0, 0, char_draw_max_width, CGA_SCREENBUFFER, ofs);
ofs = CGA_DrawHLineWithEnds(0xC003, 0x0FF0, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
- ofs = CGA_DrawHLineWithEnds( 0, 0x3FFC, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
- ofs = CGA_DrawHLineWithEnds( 0, 0x3FFC, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
+ ofs = CGA_DrawHLineWithEnds(0, 0x3FFC, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
+ ofs = CGA_DrawHLineWithEnds(0, 0x3FFC, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
/*body*/
char_draw_coords_x = x;
char_draw_coords_y = y + 4;
- for(string_ended = 0;!string_ended;char_draw_coords_y += 6)
- {
+ for (string_ended = 0; !string_ended; char_draw_coords_y += 6) {
CGA_PrintChar(0x3B, CGA_SCREENBUFFER);
msg = PrintStringPadded(msg, CGA_SCREENBUFFER);
CGA_PrintChar(0x3C, CGA_SCREENBUFFER);
char_draw_coords_x = x;
}
-
+
ofs = CGA_CalcXY_p(x, char_draw_coords_y);
ofs = CGA_DrawHLineWithEnds(0xC003, 0x0FF0, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
ofs = CGA_DrawHLineWithEnds(0xF00F, 0, 0, char_draw_max_width, CGA_SCREENBUFFER, ofs);
@@ -127,29 +114,28 @@ void DrawPersonBubble(unsigned char x, unsigned char y, unsigned char flags, uns
h = char_draw_coords_y - y + 2;
/*draw spike*/
- switch(flags & SPIKE_MASK)
- {
- case SPIKE_UPLEFT: /*upper-left spike*/
+ switch (flags & SPIKE_MASK) {
+ case SPIKE_UPLEFT: /*upper-left spike*/
ofs = CGA_CalcXY_p(x + 1, y - 7);
DrawSpriteN(18, x + 1, y - 7, CGA_SCREENBUFFER);
break;
- case SPIKE_UPRIGHT: /*upper-right spike*/
+ case SPIKE_UPRIGHT: /*upper-right spike*/
ofs = CGA_CalcXY_p(x + char_draw_max_width, y - 7) - 1;
DrawSpriteNFlip(18, x + char_draw_max_width, y - 7, CGA_SCREENBUFFER);
break;
- case SPIKE_DNRIGHT: /*lower-right spike*/
+ case SPIKE_DNRIGHT: /*lower-right spike*/
ofs = CGA_CalcXY_p(x + char_draw_max_width, char_draw_coords_y + 1) - 1;
DrawSpriteNFlip(21, x + char_draw_max_width, char_draw_coords_y + 1, CGA_SCREENBUFFER);
break;
- case SPIKE_DNLEFT: /*lower-left spike*/
+ case SPIKE_DNLEFT: /*lower-left spike*/
ofs = CGA_CalcXY_p(x + 1, char_draw_coords_y + 1);
DrawSpriteN(21, x + 1, char_draw_coords_y + 1, CGA_SCREENBUFFER);
break;
- case SPIKE_BUBRIGHT: /*lower-right bubbles*/
+ case SPIKE_BUBRIGHT: /*lower-right bubbles*/
ofs = CGA_CalcXY_p(x + char_draw_max_width, char_draw_coords_y + 4);
DrawSpriteN(20, x + char_draw_max_width, char_draw_coords_y + 4, CGA_SCREENBUFFER);
break;
- case SPIKE_BUBLEFT: /*lower-left bubbles*/
+ case SPIKE_BUBLEFT: /*lower-left bubbles*/
ofs = CGA_CalcXY_p(x + 1, char_draw_coords_y + 4);
DrawSpriteN(19, x + 1, char_draw_coords_y + 4, CGA_SCREENBUFFER);
break;
@@ -158,48 +144,41 @@ void DrawPersonBubble(unsigned char x, unsigned char y, unsigned char flags, uns
AddDirtyRect(DirtyRectBubble, ofs >> 8, ofs & 255, w, h, CGA_CalcXY_p(x, y));
}
-void ShowPromptAnim(void)
-{
- if(script_byte_vars.zone_index == 135)
+void ShowPromptAnim(void) {
+ if (script_byte_vars.zone_index == 135)
return;
WaitVBlank();
DrawSpriteN(cursor_anim_phase ? 23 : 22, 300 / 4, 155, frontbuffer);
cursor_anim_phase = ~cursor_anim_phase;
}
-void PromptWait(void)
-{
+void PromptWait(void) {
cursor_anim_phase = 0;
- do
- {
+ do {
unsigned char ticks = script_byte_vars.timer_ticks;
- if((ticks % 8) == 0 && ticks != cursor_anim_ticks)
- {
+ if ((ticks % 8) == 0 && ticks != cursor_anim_ticks) {
cursor_anim_ticks = ticks;
ShowPromptAnim();
}
PollInput();
- }
- while(!buttons);
+ } while (!buttons);
- if(cursor_anim_phase)
+ if (cursor_anim_phase)
ShowPromptAnim();
}
/*
Get string with index num from strings bank
*/
-unsigned char * SeekToString(unsigned char *bank, unsigned int num)
-{
+unsigned char *SeekToString(unsigned char *bank, unsigned int num) {
unsigned char len;
unsigned char *p = bank;
cur_str_index = num;
num -= 4;
- while(num--)
- {
+ while (num--) {
len = *p;
p += len;
}
@@ -211,20 +190,17 @@ 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 *SeekToStringScr(unsigned char *bank, unsigned int num, unsigned char **ptr) {
unsigned char len;
unsigned char *p = bank;
- if(num < 4)
- {
+ if (num < 4) {
num = (num << 8) | *(++(*ptr));
}
cur_str_index = num;
num -= 4;
- while(num--)
- {
+ while (num--) {
len = *p;
p += len;
}
diff --git a/engines/chamber/dialog.h b/engines/chamber/dialog.h
index 6d769833f06..aa7488fa476 100644
--- a/engines/chamber/dialog.h
+++ b/engines/chamber/dialog.h
@@ -6,18 +6,18 @@ extern unsigned int cur_dlg_index;
enum DirtyRectKind {
DirtyRectFree = 0,
- DirtyRectBubble = 1, /*bubble with spike*/
- DirtyRectSprite = 2, /*portrait*/
- DirtyRectText = 3 /*text bubble w/o spike*/
+ DirtyRectBubble = 1, /*bubble with spike*/
+ DirtyRectSprite = 2, /*portrait*/
+ DirtyRectText = 3 /*text bubble w/o spike*/
};
typedef struct dirty_rect_t {
-unsigned char kind;
-unsigned int offs;
-unsigned char width;
-unsigned char height;
-unsigned char y; /*for DirtyRectBubble this is spike offs*/
-unsigned char x;
+ unsigned char kind;
+ unsigned int offs;
+ unsigned char width;
+ unsigned char height;
+ unsigned char y; /*for DirtyRectBubble this is spike offs*/
+ unsigned char x;
} dirty_rect_t;
extern dirty_rect_t dirty_rects[];
@@ -41,7 +41,7 @@ void DesciTextBox(unsigned int x, unsigned int y, unsigned int width, unsigned c
void PromptWait(void);
-unsigned char * SeekToString(unsigned char *bank, unsigned int num);
-unsigned char * SeekToStringScr(unsigned char *bank, unsigned int num, unsigned char **ptr);
+unsigned char *SeekToString(unsigned char *bank, unsigned int num);
+unsigned char *SeekToStringScr(unsigned char *bank, unsigned int num, unsigned char **ptr);
#endif
diff --git a/engines/chamber/input.cpp b/engines/chamber/input.cpp
index 563cf98fa99..917bf27cb57 100644
--- a/engines/chamber/input.cpp
+++ b/engines/chamber/input.cpp
@@ -17,109 +17,85 @@ unsigned char key_direction_old;
unsigned char accell_countdown;
unsigned int accelleration = 1;
-void interrupt (*old_keyboard_isr)(void);
+void interrupt(*old_keyboard_isr)(void);
-unsigned char ReadKeyboardChar(void)
-{
+unsigned char ReadKeyboardChar(void) {
#ifdef DEBUG
- if(old_keyboard_isr)
- {
- do
- {
+ if (old_keyboard_isr) {
+ do {
PollInput();
- }
- while(!buttons);
- }
- else
+ } while (!buttons);
+ } else
#endif
- return (unsigned char)getch();
+ return (unsigned char)getch();
}
-void ClearKeyboard(void)
-{
- while(kbhit())
- {
+void ClearKeyboard(void) {
+ while (kbhit()) {
getch();
}
}
-void interrupt NullIsr(void)
-{
+void interrupt NullIsr(void) {
/*nothing*/
}
-void SetInputButtons(unsigned char keys)
-{
- if(keys && buttons_repeat)
- {
+void SetInputButtons(unsigned char keys) {
+ if (keys && buttons_repeat) {
/*ignore buttons repeat*/
buttons = 0;
return;
}
- if(keys & 2)
+ if (keys & 2)
right_button = ~0;
- if(keys & 1)
+ if (keys & 1)
right_button = 0;
buttons = keys;
buttons_repeat = keys;
}
-unsigned char PollMouse(void)
-{
+unsigned char PollMouse(void) {
union REGS reg;
reg.x.ax = 3;
int86(0x33, ®, ®);
cursor_x = reg.x.cx;
cursor_y = reg.h.dl;
- return reg.h.bl; /*buttons*/
+ return reg.h.bl; /*buttons*/
}
-unsigned char PollKeyboard(void)
-{
+unsigned char PollKeyboard(void) {
unsigned char direction = key_direction;
- if(direction && direction == key_direction_old)
- {
- if(++accell_countdown == 10)
- {
+ if (direction && direction == key_direction_old) {
+ if (++accell_countdown == 10) {
accelleration++;
accell_countdown = 0;
}
- }
- else
- {
+ } else {
accelleration = 1;
accell_countdown = 0;
}
key_direction_old = direction;
- if(direction & 0x0F)
- {
- if(direction == 1)
- {
+ if (direction & 0x0F) {
+ if (direction == 1) {
cursor_x += accelleration;
- if(cursor_x >= 304) /*TODO: >*/
+ if (cursor_x >= 304) /*TODO: >*/
cursor_x = 304;
- }
- else
- {
+ } else {
cursor_x -= accelleration;
- if((signed int)cursor_x < 0)
+ if ((signed int)cursor_x < 0)
cursor_x = 0;
}
}
-
- if(direction & 0xF0)
- {
- if(direction == 0x10)
- {
+
+ if (direction & 0xF0) {
+ if (direction == 0x10) {
cursor_y += accelleration;
- if(cursor_y >= 184) /*TODO: >*/
+ if (cursor_y >= 184) /*TODO: >*/
cursor_y = 184;
- }
- else
- {
+ } else {
cursor_y -= accelleration;
- if((signed char)cursor_y < 0)
+ if ((signed char)cursor_y < 0)
cursor_y = 0;
}
}
@@ -127,25 +103,22 @@ unsigned char PollKeyboard(void)
return key_code;
}
-void PollInput(void)
-{
+void PollInput(void) {
unsigned char keys;
- if(have_mouse)
+ if (have_mouse)
keys = PollMouse();
else
keys = PollKeyboard();
SetInputButtons(keys);
}
-void ProcessInput(void)
-{
+void ProcessInput(void) {
PollInput();
UpdateCursor();
DrawCursor(frontbuffer);
}
-void interrupt KeyboardIsr()
-{
+void interrupt KeyboardIsr() {
unsigned char scan, strobe;
scan = inportb(0x60);
/*consume scan from kbd. controller*/
@@ -153,38 +126,31 @@ void interrupt KeyboardIsr()
outportb(0x61, strobe | 0x80);
outportb(0x61, strobe);
- if(scan == 1) /*esc*/
- {
+ if (scan == 1) { /*esc*/
esc_pressed = ~0;
- }
- else
- {
- if(scan & 0x80) /*key release?*/
- {
+ } else {
+ if (scan & 0x80) { /*key release?*/
key_code = 0;
key_direction = 0;
- }
- else
- {
- switch(scan)
- {
- case 0x39: /*space*/
+ } else {
+ switch (scan) {
+ case 0x39: /*space*/
key_code = scan;
key_direction = 0;
break;
- case 0x48: /*up*/
+ case 0x48: /*up*/
key_code = 0;
key_direction = 0xF0;
break;
- case 0x50: /*down*/
+ case 0x50: /*down*/
key_code = 0;
key_direction = 0x10;
break;
- case 0x4B: /*left*/
+ case 0x4B: /*left*/
key_code = 0;
key_direction = 0x0F;
break;
- case 0x4D: /*right*/
+ case 0x4D: /*right*/
key_code = 0;
key_direction = 0x01;
break;
@@ -194,37 +160,34 @@ void interrupt KeyboardIsr()
outportb(0x20, 0x20);
}
-void InitInput(void)
-{
+void InitInput(void) {
/*disable critical errors handler*/
setvect(0x24, NullIsr);
/*is mouse present?*/
- if(getvect(0x33))
- {
+ if (getvect(0x33)) {
union REGS reg;
reg.x.ax = 0;
int86(0x33, ®, ®);
- if(reg.x.ax == 0xFFFF)
- {
+ if (reg.x.ax == 0xFFFF) {
/*mouse detected*/
- reg.x.ax = 0xF; /*set cursor speed*/
+ reg.x.ax = 0xF; /*set cursor speed*/
reg.x.cx = 16;
reg.x.dx = 16;
int86(0x33, ®, ®);
- reg.x.ax = 7; /*set x range*/
+ reg.x.ax = 7; /*set x range*/
reg.x.cx = 0;
reg.x.dx = 303;
int86(0x33, ®, ®);
- reg.x.ax = 8; /*set y range*/
+ reg.x.ax = 8; /*set y range*/
reg.x.cx = 0;
reg.x.dx = 183;
int86(0x33, ®, ®);
- reg.x.ax = 4; /*set coords*/
+ reg.x.ax = 4; /*set coords*/
cursor_x = reg.x.cx = 10;
cursor_y = reg.x.dx = 10;
int86(0x33, ®, ®);
@@ -233,7 +196,7 @@ void InitInput(void)
}
}
- if(have_mouse)
+ if (have_mouse)
return;
/*no mouse*/
@@ -242,9 +205,8 @@ void InitInput(void)
setvect(9, KeyboardIsr);
}
-void UninitInput(void)
-{
- if(have_mouse)
+void UninitInput(void) {
+ if (have_mouse)
return;
setvect(9, old_keyboard_isr);
diff --git a/engines/chamber/invent.cpp b/engines/chamber/invent.cpp
index c356a541a36..6a401d42111 100644
--- a/engines/chamber/invent.cpp
+++ b/engines/chamber/invent.cpp
@@ -10,15 +10,15 @@
#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;
+ 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;
} inventory_spots[] = {
{58, 62, 56, 72, 0, 0, 0, 0, 0},
{62, 66, 56, 72, 0, 0, 0, 0, 0},
@@ -39,23 +39,20 @@ unsigned char unkn9;
};
-unsigned char inv_count = 0; /*TODO: pass this as param?*/
-unsigned char inv_bgcolor = 0; /*TODO: pass this as param?*/
+unsigned char inv_count = 0; /*TODO: pass this as param?*/
+unsigned char 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)
-{
+void DrawInventoryBox(unsigned short filtermask, unsigned short filtervalue) {
int i;
unsigned char count = 0;
- for(i = 0;i < MAX_INV_ITEMS;i++)
- {
+ for (i = 0; i < MAX_INV_ITEMS; i++) {
unsigned short flags = (inventory_items[i].flags2 << 8) | inventory_items[i].flags;
- if((flags & filtermask) != filtervalue)
+ if ((flags & filtermask) != filtervalue)
continue;
- if(count == 0)
- {
+ if (count == 0) {
/*draw the box*/
- CGA_FillAndWait(inv_bgcolor, 64/4, 64, CGA_SCREENBUFFER, CGA_CalcXY_p(232/4, 56));
+ CGA_FillAndWait(inv_bgcolor, 64 / 4, 64, CGA_SCREENBUFFER, CGA_CalcXY_p(232 / 4, 56));
PlaySound(20);
}
inventory_spots[count].name = inventory_items[i].name;
@@ -67,13 +64,10 @@ void DrawInventoryBox(unsigned short filtermask, unsigned short filtervalue)
inv_count = count;
}
-void CheckInventoryItemHover(unsigned char count)
-{
+void CheckInventoryItemHover(unsigned char count) {
int i;
- for(i = 0;i < count;i++)
- {
- if(IsCursorInRect((rect_t*)&inventory_spots[i]))
- {
+ for (i = 0; i < count; i++) {
+ if (IsCursorInRect((rect_t *)&inventory_spots[i])) {
the_command = inventory_spots[i].command;
command_hint = inventory_spots[i].name;
cursor_color = 0xAA;
@@ -88,30 +82,25 @@ void CheckInventoryItemHover(unsigned char count)
the_command = 0;
}
-void OpenInventory(unsigned short filtermask, unsigned short filtervalue)
-{
+void OpenInventory(unsigned short filtermask, unsigned short filtervalue) {
the_command = 0;
- CGA_BackupImageReal(CGA_CalcXY_p(232/4, 56), 64/4, 64);
+ CGA_BackupImageReal(CGA_CalcXY_p(232 / 4, 56), 64 / 4, 64);
DrawInventoryBox(filtermask, filtervalue);
- if(inv_count != 0)
- {
+ if (inv_count != 0) {
SelectCursor(CURSOR_0);
ProcessInput();
- do
- {
+ do {
PollInput();
CheckInventoryItemHover(inv_count);
- if(command_hint != last_command_hint)
+ if (command_hint != last_command_hint)
DrawCommandHint();
DrawHintsAndCursor(frontbuffer);
- }
- while(buttons == 0);
+ } while (buttons == 0);
UndrawCursor(frontbuffer);
}
CGA_RestoreImage(scratch_mem2, frontbuffer);
PlaySound(20);
- switch(((item_t*)script_vars[ScrPool3_CurrentItem])->name)
- {
+ switch (((item_t *)script_vars[ScrPool3_CurrentItem])->name) {
case 108:
case 115:
case 117:
diff --git a/engines/chamber/menu.cpp b/engines/chamber/menu.cpp
index 2455864cb9a..48882e6e5ca 100644
--- a/engines/chamber/menu.cpp
+++ b/engines/chamber/menu.cpp
@@ -16,7 +16,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;
+ unsigned char x, y;
} act_dot_coords[8] = {
{ 2, 0},
{ 8, 32},
@@ -32,15 +32,13 @@ unsigned char act_menu_x;
unsigned char act_menu_y;
/*Handle keyboard keys in actions menu (to cycle through choices with directional keys)*/
-unsigned char PollKeyboardInActionsMenu(void)
-{
- if(!key_direction)
- {
+unsigned char PollKeyboardInActionsMenu(void) {
+ if (!key_direction) {
key_held = 0;
return key_code;
}
- if(key_held)
+ if (key_held)
return key_code;
key_held = 1;
@@ -50,17 +48,16 @@ unsigned char PollKeyboardInActionsMenu(void)
cursor_x = act_dot_rects_cur->sx * 4 + 1;
cursor_y = act_dot_rects_cur->sy + 4;
- if(++act_dot_rects_cur == act_dot_rects_end)
+ if (++act_dot_rects_cur == act_dot_rects_end)
act_dot_rects_cur = act_dot_rects;
return key_code;
}
/*Handle player input in actions menu*/
-void PollInputInActionsMenu(void)
-{
+void PollInputInActionsMenu(void) {
unsigned char keys;
- if(have_mouse)
+ if (have_mouse)
keys = PollMouse();
else
keys = PollKeyboardInActionsMenu();
@@ -68,8 +65,7 @@ void PollInputInActionsMenu(void)
}
/*Draw actions menu and process its choices*/
-void ActionsMenu(unsigned char **pinfo)
-{
+void ActionsMenu(unsigned char **pinfo) {
unsigned char x, y;
unsigned char choices;
int i, choice, numchoices;
@@ -77,18 +73,17 @@ void ActionsMenu(unsigned char **pinfo)
last_object_hint = object_hint;
- if(act_menu_x == 0xFF)
- {
+ if (act_menu_x == 0xFF) {
/*recalc menu pos*/
x = cursor_x / 4;
- if((int)(x + 48/4) >= 296/4)
- x -= x + 48/4 - 296/4;
- if(x < 32/4)
- x = 32/4;
+ if ((int)(x + 48 / 4) >= 296 / 4)
+ x -= x + 48 / 4 - 296 / 4;
+ if (x < 32 / 4)
+ x = 32 / 4;
act_menu_x = x;
y = cursor_y;
- if((int)(y + 45) >= 180)
+ if ((int)(y + 45) >= 180)
y -= y + 45 - 180;
act_menu_y = y;
}
@@ -96,7 +91,7 @@ void ActionsMenu(unsigned char **pinfo)
x = act_menu_x;
y = act_menu_y;
- /*menu sprite*/
+ /*menu sprite*/
BackupAndShowSprite(0, x, y);
PlaySound(18);
@@ -104,23 +99,21 @@ void ActionsMenu(unsigned char **pinfo)
menurecs = *pinfo;
numchoices = 0;
- for(i = 0;i < 8;i++)
- {
- if(choices & (1 << i))
- {
+ for (i = 0; i < 8; i++) {
+ if (choices & (1 << i)) {
act_dot_rects[numchoices].sx = x + act_dot_coords[i].x;
- act_dot_rects[numchoices].ex = act_dot_rects[numchoices].sx + 8/4;
+ act_dot_rects[numchoices].ex = act_dot_rects[numchoices].sx + 8 / 4;
act_dot_rects[numchoices].sy = y + act_dot_coords[i].y;
act_dot_rects[numchoices].ey = act_dot_rects[numchoices].sy + 8;
numchoices++;
}
}
- act_dot_rects[numchoices].sx = x + 24/4;
+ act_dot_rects[numchoices].sx = x + 24 / 4;
act_dot_rects[numchoices].sy = y + 22;
/*TODO: no ex/ey?*/
act_dot_rects_end = act_dot_rects + numchoices + 1;
- for(i = 0;i < numchoices;i++)
+ for (i = 0; i < numchoices; i++)
DrawSpriteN(1, act_dot_rects[i].sx, act_dot_rects[i].sy, CGA_SCREENBUFFER);
SelectCursor(CURSOR_0);
@@ -128,47 +121,40 @@ void ActionsMenu(unsigned char **pinfo)
choice = 0;
act_dot_rects_cur = act_dot_rects;
- do
- {
+ do {
PollInputInActionsMenu();
- for(choice = 0;choice < numchoices;choice++)
- {
- if(IsCursorInRect(&act_dot_rects[choice]))
+ for (choice = 0; choice < numchoices; choice++) {
+ if (IsCursorInRect(&act_dot_rects[choice]))
break;
}
- if(choice < numchoices)
- {
+ if (choice < numchoices) {
cursor_color = 0xAA;
command_hint = menurecs[choice * 3];
the_command = (menurecs[choice * 3 + 1] << 8) | menurecs[choice * 3 + 2];
- }
- else
- {
+ } else {
cursor_color = 0xFF;
command_hint = 100;
- the_command = 0xFFFF;
+ the_command = 0xFFFF;
}
- if(command_hint != last_command_hint)
- DrawCommandHint(); /*to backbuffer*/
+ if (command_hint != last_command_hint)
+ DrawCommandHint(); /*to backbuffer*/
DrawHintsAndCursor(CGA_SCREENBUFFER);
- }
- while(buttons == 0);
+ } while (buttons == 0);
UndrawCursor(CGA_SCREENBUFFER);
- if(the_command != 0xFFFF)
- {
+ if (the_command != 0xFFFF) {
PlaySound(19);
WaitVBlank();
/*draw dot explosion animation*/
DrawSpriteN(24, act_dot_rects[choice].sx, act_dot_rects[choice].sy, CGA_SCREENBUFFER);
- for(i = 0;i < 0xFFF;i++) ; /*TODO: weak delay*/
+ for (i = 0; i < 0xFFF; i++) ; /*TODO: weak delay*/
DrawSpriteN(2, act_dot_rects[choice].sx, act_dot_rects[choice].sy, CGA_SCREENBUFFER);
- for(i = 0;i < 0xFFF;i++) ; /*TODO: weak delay*/
+ for (i = 0; i < 0xFFF; i++) ; /*TODO: weak delay*/
DrawSpriteN(25, act_dot_rects[choice].sx, act_dot_rects[choice].sy, CGA_SCREENBUFFER);
- for(i = 0;i < 0xFFF;i++) ; /*TODO: weak delay*/
+ for (i = 0; i < 0xFFF; i++) ; /*TODO: weak delay*/
}
CGA_RestoreBackupImage(CGA_SCREENBUFFER);
@@ -176,46 +162,39 @@ void ActionsMenu(unsigned char **pinfo)
}
/*TODO: maybe rename to SpotsLoop*/
-void MenuLoop(unsigned char spotmask, unsigned char spotvalue)
-{
+void MenuLoop(unsigned char spotmask, unsigned char spotvalue) {
ProcessInput();
- do
- {
+ do {
PollInput();
CheckHotspots(spotmask, spotvalue);
- if(object_hint != last_object_hint)
+ if (object_hint != last_object_hint)
DrawObjectHint();
DrawHintsAndCursor(frontbuffer);
- }
- while(buttons == 0);
+ } while (buttons == 0);
UndrawCursor(frontbuffer);
}
-void ProcessMenu(void)
-{
+void ProcessMenu(void) {
SelectCursor(CURSOR_6);
MenuLoop(SPOTFLG_80 | SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8, SPOTFLG_80 | SPOTFLG_10);
}
rect_t menu_buttons_rects[] = {
- {296 / 4, 312 / 4, 15, 30}, /*Room's Objects*/
- {296 / 4, 312 / 4, 40, 56}, /*Psi Powers*/
- {296 / 4, 312 / 4, 56, 72}, /*Posessions*/
- {296 / 4, 312 / 4, 72, 88}, /*Energy Level*/
- {296 / 4, 312 / 4, 88, 104}, /*Wait*/
- {296 / 4, 312 / 4, 104, 120}, /*Load*/
- {296 / 4, 312 / 4, 120, 136}, /*Save*/
- {296 / 4, 312 / 4, 136, 152} /*Time*/
+ {296 / 4, 312 / 4, 15, 30}, /*Room's Objects*/
+ {296 / 4, 312 / 4, 40, 56}, /*Psi Powers*/
+ {296 / 4, 312 / 4, 56, 72}, /*Posessions*/
+ {296 / 4, 312 / 4, 72, 88}, /*Energy Level*/
+ {296 / 4, 312 / 4, 88, 104}, /*Wait*/
+ {296 / 4, 312 / 4, 104, 120}, /*Load*/
+ {296 / 4, 312 / 4, 120, 136}, /*Save*/
+ {296 / 4, 312 / 4, 136, 152} /*Time*/
};
-void CheckMenuCommandHover(void)
-{
+void CheckMenuCommandHover(void) {
int i;
- for(i = 0;i < 8;i++)
- {
- if(IsCursorInRect(&menu_buttons_rects[i]))
- {
+ for (i = 0; i < 8; i++) {
+ if (IsCursorInRect(&menu_buttons_rects[i])) {
the_command = 0xA001 + i;
command_hint = i ? (i + 3) : 101;
cursor_color = 0xAA;
@@ -229,24 +208,21 @@ void CheckMenuCommandHover(void)
}
rect_t psi_buttons_rects[] = {
- {280 / 4, 296 / 4, 40, 56}, /*Solar Eyes*/
- {280 / 4, 296 / 4, 56, 72}, /*Sticky Fingers*/
- {280 / 4, 296 / 4, 72, 88}, /*Know Mind*/
- {280 / 4, 296 / 4, 88, 104}, /*Brainwarp*/
- {280 / 4, 296 / 4, 104, 120}, /*Zone Scan*/
- {280 / 4, 296 / 4, 120, 136}, /*Psi Shift*/
- {280 / 4, 296 / 4, 136, 152}, /*Extreme Violence*/
- {280 / 4, 296 / 4, 152, 168} /*Tune In*/
+ {280 / 4, 296 / 4, 40, 56}, /*Solar Eyes*/
+ {280 / 4, 296 / 4, 56, 72}, /*Sticky Fingers*/
+ {280 / 4, 296 / 4, 72, 88}, /*Know Mind*/
+ {280 / 4, 296 / 4, 88, 104}, /*Brainwarp*/
+ {280 / 4, 296 / 4, 104, 120}, /*Zone Scan*/
+ {280 / 4, 296 / 4, 120, 136}, /*Psi Shift*/
+ {280 / 4, 296 / 4, 136, 152}, /*Extreme Violence*/
+ {280 / 4, 296 / 4, 152, 168} /*Tune In*/
};
-void CheckPsiCommandHover(void)
-{
-/*TODO: maybe merge it with CheckMenuCommandHover()*/
+void CheckPsiCommandHover(void) {
+ /*TODO: maybe merge it with CheckMenuCommandHover()*/
int i;
- for(i = 0;i < 8;i++)
- {
- if(IsCursorInRect(&psi_buttons_rects[i]))
- {
+ for (i = 0; i < 8; i++) {
+ if (IsCursorInRect(&psi_buttons_rects[i])) {
the_command = 0xA00A + i;
command_hint = i + 12;
cursor_color = 0xAA;
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index 177493d2aae..cbe44a1b6c2 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -25,12 +25,12 @@ unsigned char cur_image_anim2;
unsigned int 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;
+ unsigned char height;
+ unsigned char width;
+ unsigned char topbot; /*border and fill colors*/
+ unsigned char fill;
+ unsigned char left;
+ unsigned char right;
} persframe_t;
persframe_t pers_frames[] = {
@@ -45,18 +45,18 @@ persframe_t pers_frames[] = {
{27, 34, 0, 0, 0, 0}
};
-void MakePortraitFrame(unsigned char index, unsigned char *target)
-{
+void MakePortraitFrame(unsigned char index, unsigned char *target) {
unsigned int i;
persframe_t *pframe = &pers_frames[index];
*target++ = pframe->height;
*target++ = pframe->width;
cur_frame_width = pframe->width;
- memset(target, pframe->topbot, pframe->width); target += pframe->width;
- for(i = 0;i < pframe->height - 2;i++)
- {
+ memset(target, pframe->topbot, pframe->width);
+ target += pframe->width;
+ for (i = 0; i < pframe->height - 2; i++) {
*target++ = pframe->left;
- memset(target, pframe->fill, pframe->width - 2); target += pframe->width - 2;
+ memset(target, pframe->fill, pframe->width - 2);
+ target += pframe->width - 2;
*target++ = pframe->right;
}
memset(target, pframe->topbot, pframe->width);
@@ -66,13 +66,10 @@ 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)
-{
+void MergeImageAndSpriteData(unsigned char *target, signed int pitch, unsigned char *source, unsigned int w, unsigned int h) {
unsigned int x;
- while(h--)
- {
- for(x = 0;x < w;x++)
- {
+ while (h--) {
+ for (x = 0; x < w; x++) {
unsigned char m = *source++;
*target &= m;
*target++ |= *source++;
@@ -85,14 +82,11 @@ 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)
-{
+void MergeImageAndSpriteDataFlip(unsigned char *target, signed int pitch, unsigned char *source, unsigned int w, unsigned int h) {
unsigned int x;
target += w - 1;
- while(h--)
- {
- for(x = 0;x < w;x++)
- {
+ while (h--) {
+ for (x = 0; x < w; x++) {
unsigned char m = cga_pixel_flip[*source++];
*target &= m;
*target |= cga_pixel_flip[*source++];
@@ -106,10 +100,8 @@ void MergeImageAndSpriteDataFlip(unsigned char *target, signed int pitch, unsign
/*
Build portrait from multiple pers sprites
*/
-unsigned char *LoadPortrait(unsigned char **pinfo, unsigned char *end)
-{
- while(*pinfo != end)
- {
+unsigned char *LoadPortrait(unsigned char **pinfo, unsigned char *end) {
+ while (*pinfo != end) {
unsigned char index;
unsigned int flags;
signed int pitch;
@@ -126,12 +118,11 @@ unsigned char *LoadPortrait(unsigned char **pinfo, unsigned char *end)
sprw = *sprite++;
sprh = *sprite++;
- if(flags & 0x8000) /*vertical flip*/
- {
+ if (flags & 0x8000) { /*vertical flip*/
buffer += pitch * (sprh - 1);
pitch = -pitch;
}
- if(flags & 0x4000) /*horizontal flip*/
+ if (flags & 0x4000) /*horizontal flip*/
MergeImageAndSpriteDataFlip(buffer, pitch, sprite, sprw, sprh);
else
MergeImageAndSpriteData(buffer, pitch, sprite, sprw, sprh);
@@ -139,8 +130,7 @@ unsigned char *LoadPortrait(unsigned char **pinfo, unsigned char *end)
return sprit_load_buffer + 2;
}
-unsigned char *LoadPortraitWithFrame(unsigned char index)
-{
+unsigned char *LoadPortraitWithFrame(unsigned char index) {
unsigned char *pinfo, *end;
pinfo = SeekToEntry(icone_data, index, &end);
MakePortraitFrame(*pinfo++, sprit_load_buffer + 2);
@@ -151,12 +141,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;
+ unsigned char index;
+ unsigned char image;
+ unsigned char x;
+ unsigned char y;
+ unsigned char anim1;
+ unsigned char anim2;
} static_anims[] = {
{ 24, 13, 35, 10, 4, 5},
{ 88, 42, 35, 10, 11, 12},
@@ -184,14 +174,11 @@ unsigned char anim2;
{248, 117, 16, 2, 33, 33}
};
-unsigned char SelectCurrentAnim(unsigned char *x, unsigned char *y, unsigned char *index)
-{
+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;
- for(i = 0;i < STATIC_ANIMS_MAX;i++)
- {
- if(static_anims[i].index == aniidx)
- {
+ unsigned char 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;
*y = static_anims[i].y;
*index = static_anims[i].image;
@@ -200,27 +187,26 @@ unsigned char SelectCurrentAnim(unsigned char *x, unsigned char *y, unsigned cha
return 1;
}
}
-printf("SelectCurrentAnim: not found for %d\n", aniidx);
+ printf("SelectCurrentAnim: not found for %d\n", aniidx);
return 0;
}
-void DrawBoxAroundSpot(void)
-{
+void DrawBoxAroundSpot(void) {
unsigned char *buffer;
unsigned int w, h;
unsigned int ofs;
unsigned int x, y;
- if(*spot_sprite == 0)
+ if (*spot_sprite == 0)
return;
zone_spots_cur = found_spot;
zone_spr_index = script_byte_vars.cur_spot_idx - 1;
buffer = *spot_sprite;
- h = *(unsigned char*)(buffer + 0);
- w = *(unsigned char*)(buffer + 1);
- ofs = *(unsigned int*)(buffer + 2);
+ h = *(unsigned char *)(buffer + 0);
+ w = *(unsigned char *)(buffer + 1);
+ ofs = *(unsigned int *)(buffer + 2);
/*decode ofs back to x:y*/
/*TODO: this is CGA-only!*/
@@ -228,36 +214,32 @@ void DrawBoxAroundSpot(void)
ofs &= ~CGA_ODD_LINES_OFS;
x = (ofs % CGA_BYTES_PER_LINE) * CGA_PIXELS_PER_BYTE;
y += (ofs / CGA_BYTES_PER_LINE) * 2;
- w *= CGA_PIXELS_PER_BYTE; /*TODO: this will overflow on large sprite*/
+ w *= CGA_PIXELS_PER_BYTE; /*TODO: this will overflow on large sprite*/
CGA_DrawVLine(x, y, h - 1, 0, CGA_SCREENBUFFER);
CGA_DrawHLine(x, y, w - 1, 0, CGA_SCREENBUFFER);
CGA_DrawVLine(x + w - 1, y, h - 1, 0, CGA_SCREENBUFFER);
CGA_DrawHLine(x, y + h - 1, w - 1, 0, CGA_SCREENBUFFER);
- CGA_RefreshImageData(*spot_sprite);
+ CGA_RefreshImageData(*spot_sprite);
}
/*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)
-{
+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;
index = *((*desc)++);
- if(index == 0xFF)
- {
- if(script_byte_vars.dirty_rect_kind != 0)
+ if (index == 0xFF) {
+ if (script_byte_vars.dirty_rect_kind != 0)
return 0;
DrawBoxAroundSpot();
- if(!SelectCurrentAnim(&xx, &yy, &index))
+ if (!SelectCurrentAnim(&xx, &yy, &index))
return 0;
- }
- else
- {
+ } else {
xx = *((*desc)++);
yy = *((*desc)++);
}
@@ -278,8 +260,7 @@ int DrawPortrait(unsigned char **desc, unsigned char *x, unsigned char *y, unsig
*width = cur_image_size_w;
*height = cur_image_size_h;
- if(right_button)
- {
+ if (right_button) {
CGA_BlitAndWait(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
return 0;
}
@@ -287,68 +268,58 @@ int DrawPortrait(unsigned char **desc, unsigned char *x, unsigned char *y, unsig
return 1;
}
-void BlinkWithSound(unsigned char color)
-{
+void BlinkWithSound(unsigned char color) {
CGA_ColorSelect(color);
PlaySound(144);
SelectPalette();
}
-void BlinkToRed(void)
-{
- BlinkWithSound(0x3C);
+void BlinkToRed(void) {
+ BlinkWithSound(0x3C);
}
-void BlinkToWhite(void)
-{
- BlinkWithSound(0x3F);
+void BlinkToWhite(void) {
+ BlinkWithSound(0x3F);
}
-void AnimPortrait(unsigned char layer, unsigned char index, unsigned char delay)
-{
+void AnimPortrait(unsigned char layer, unsigned char index, unsigned char delay) {
unsigned char *ani, *ani_end;
unsigned char temp;
SelectCurrentAnim(&temp, &temp, &temp);
- if(index == 0xFF)
+ if (index == 0xFF)
index = cur_image_anim1;
- if(index == 0xFE)
+ if (index == 0xFE)
index = cur_image_anim2;
ani = SeekToEntry(anico_data, index - 1, &ani_end);
cur_image_pixels = sprit_load_buffer + 2 + 2;
- while(ani != ani_end)
- {
+ while (ani != ani_end) {
unsigned char kind;
- unsigned char x, y;
- unsigned char width, height;
- unsigned int offs;
+ unsigned char x, y;
+ unsigned char width, height;
+ unsigned int offs;
unsigned char portrait = *ani++;
LoadPortraitWithFrame(portrait - 1);
- if(*ani == 0xFF)
- {
+ if (*ani == 0xFF) {
ani++;
LoadPortrait(&ani, ani + 3);
}
GetDirtyRectAndSetSprite(layer, &kind, &x, &y, &width, &height, &offs);
WaitVBlank();
- CGA_BlitAndWait(cur_image_pixels, width, width, height, CGA_SCREENBUFFER, offs);
- if(delay)
- {
- if(ani[-1] == 37) /*TODO: what is it?*/
- {
- if(script_byte_vars.byte_179F3)
+ CGA_BlitAndWait(cur_image_pixels, width, width, height, CGA_SCREENBUFFER, offs);
+ if (delay) {
+ if (ani[-1] == 37) { /*TODO: what is it?*/
+ if (script_byte_vars.byte_179F3)
BlinkToRed();
else
BlinkToWhite();
- }
- else
- {
+ } else {
int i;
- while(delay--) for(i = 0;i < cpu_speed_delay;i++) ; /*TODO: FIXME weak delay*/
+ while (delay--) for (i = 0; i < cpu_speed_delay; i++) ; /*TODO: FIXME weak delay*/
}
}
}
diff --git a/engines/chamber/print.cpp b/engines/chamber/print.cpp
index 9de41494a43..c35039a7b58 100644
--- a/engines/chamber/print.cpp
+++ b/engines/chamber/print.cpp
@@ -12,27 +12,22 @@ unsigned char 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 char *CalcStringWordWidth(unsigned char *str, unsigned int *w) {
unsigned int ww = 0;
unsigned char c;
- if((*str & 0x3F) == 0)
- {
+ if ((*str & 0x3F) == 0) {
str++;
ww++;
}
- while(str != cur_str_end)
- {
- if((*str & 0x3F) == 0)
+ while (str != cur_str_end) {
+ if ((*str & 0x3F) == 0)
break;
ww++;
c = *str & 0xC0;
- if(c != 0)
- {
- if(c == 0x40) /*space?*/
- {
+ if (c != 0) {
+ if (c == 0x40) { /*space?*/
str++;
break;
}
@@ -48,18 +43,15 @@ 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)
-{
+void CalcStringSize(unsigned char *str, unsigned int *w, unsigned int *n) {
unsigned int ww = 0, nw = 0, lw;
unsigned char *s = str;
- do
- {
+ do {
s = CalcStringWordWidth(s, &lw);
- if(lw > ww)
+ if (lw > ww)
ww = lw;
nw += 1;
- }
- while(s != cur_str_end);
+ } while (s != cur_str_end);
*w = ww;
*n = nw;
}
@@ -68,25 +60,20 @@ 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 CalcTextLines(unsigned char *str) {
unsigned int lines = 1;
unsigned int w, left = char_draw_max_width;
- while(str != cur_str_end)
- {
+ while (str != cur_str_end) {
str = CalcStringWordWidth(str, &w);
- if(left > w)
- {
+ if (left > w) {
left = left - w - 1;
- }
- else
- {
+ } else {
lines++;
left = char_draw_max_width - w - 1;
}
}
return lines;
-}
+}
/*; 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*/
@@ -94,37 +81,33 @@ unsigned char chars_color_bonc[] = {0x55, 0x54, 0x51, 0x50, 0x45, 0x44, 0x41, 0x
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*/
-void PrintStringPad(unsigned int w, unsigned char *target)
-{
- while(w--)
+void PrintStringPad(unsigned int w, unsigned char *target) {
+ while (w--)
CGA_PrintChar(0, target);
}
-unsigned char * PrintWord(unsigned char *str, unsigned char *target)
-{
+unsigned char *PrintWord(unsigned char *str, unsigned char *target) {
unsigned char c, f;
- if((*str & 0x3F) == 0)
+ if ((*str & 0x3F) == 0)
goto skip_1st;
- while(str != cur_str_end)
- {
+ while (str != cur_str_end) {
f = *str;
c = f & 0x3F;
- if(c == 0)
- {
- if((f & 0xC0) == 0)
+ if (c == 0) {
+ if ((f & 0xC0) == 0)
str++;
return str;
}
CGA_PrintChar(c, target);
-skip_1st:;
+skip_1st:
+ ;
f = *str & 0xC0;
str++;
- if(f)
- {
- if(f == 0x80)
+ if (f) {
+ if (f == 0x80)
CGA_PrintChar(0x25, target);
- else if(f != 0x40)
+ else if (f != 0x40)
CGA_PrintChar(0x21, target);
else
return str;
@@ -134,18 +117,16 @@ skip_1st:;
return str;
}
-unsigned char * PrintStringLine(unsigned char *str, unsigned int *left, unsigned char *target)
-{
+unsigned char *PrintStringLine(unsigned char *str, unsigned int *left, unsigned char *target) {
unsigned int mw = char_draw_max_width;
- for(;;)
- {
+ for (;;) {
unsigned int w;
CalcStringWordWidth(str, &w);
- if(mw < w)
+ if (mw < w)
break;
mw -= w;
str = PrintWord(str, target);
- if(string_ended || (mw == 0))
+ if (string_ended || (mw == 0))
break;
mw--;
CGA_PrintChar(0, target);
@@ -154,42 +135,36 @@ unsigned char * PrintStringLine(unsigned char *str, unsigned int *left, unsigned
return str;
}
-unsigned char * PrintStringPadded(unsigned char *str, unsigned char *target)
-{
+unsigned char *PrintStringPadded(unsigned char *str, unsigned char *target) {
unsigned int w, n;
CalcStringSize(str, &w, &n);
- if(w + 2 >= char_draw_max_width)
+ if (w + 2 >= char_draw_max_width)
char_draw_max_width = w + 2;
str = PrintStringLine(str, &w, target);
- if(w != 0)
+ if (w != 0)
PrintStringPad(w, target);
return str;
}
-void PrintStringCentered(unsigned char *str, unsigned char *target)
-{
+void PrintStringCentered(unsigned char *str, unsigned char *target) {
unsigned char pad = 0;
unsigned int ww = 0, lw;
unsigned char *s = str;
- do
- {
+ do {
s = CalcStringWordWidth(s, &lw);
ww += lw;
- }
- while(s != cur_str_end);
+ } while (s != cur_str_end);
pad = (char_draw_max_width - ww) / 2;
- if(pad)
- {
+ if (pad) {
char_draw_max_width -= pad;
PrintStringPad(pad, target);
}
- string_ended = 0; /*TODO: move me elsewhere*/
+ string_ended = 0; /*TODO: move me elsewhere*/
PrintStringPadded(str, target);
}
-void CGA_DrawTextBox(unsigned char *msg, unsigned char *target)
-{
+void CGA_DrawTextBox(unsigned char *msg, unsigned char *target) {
unsigned int x, y, w, i;
char_xlat_table = chars_color_bonc;
@@ -198,37 +173,34 @@ void CGA_DrawTextBox(unsigned char *msg, unsigned char *target)
y = draw_y;
w = (char_draw_max_width + 2) * 4 - 2;
- CGA_DrawHLine(x + 2, y, w - 2, 0, target); /*box top*/
- for(i = 0;i < 3;i++)
- CGA_DrawHLine(x + 1, y + 1 + i, w, 1, target); /*top margin*/
- CGA_DrawVLine(x, y + 2, 2, 0, target); /*left top corner 1*/
- CGA_DrawVLine(x + 1, y + 1, 1, 0, target); /*left top corner 2*/
- CGA_DrawVLine(x + w, y + 1, 1, 0, target); /*right top corner 1*/
- CGA_DrawVLine(x + w + 1, y + 2, 2, 0, target); /*right top corner 2*/
+ CGA_DrawHLine(x + 2, y, w - 2, 0, target); /*box top*/
+ for (i = 0; i < 3; i++)
+ CGA_DrawHLine(x + 1, y + 1 + i, w, 1, target); /*top margin*/
+ CGA_DrawVLine(x, y + 2, 2, 0, target); /*left top corner 1*/
+ CGA_DrawVLine(x + 1, y + 1, 1, 0, target); /*left top corner 2*/
+ CGA_DrawVLine(x + w, y + 1, 1, 0, target); /*right top corner 1*/
+ CGA_DrawVLine(x + w + 1, y + 2, 2, 0, target); /*right top corner 2*/
char_draw_coords_y = draw_y + 4;
string_ended = 0;
- do
- {
+ do {
char_draw_coords_x = draw_x;
CGA_PrintChar(0x3B, target);
msg = PrintStringPadded(msg, target);
CGA_PrintChar(0x3C, target);
char_draw_coords_y += 6;
- }
- while(!string_ended);
+ } while (!string_ended);
x = draw_x * 4;
y = char_draw_coords_y;
- CGA_DrawHLine(x + 1, y, w, 1, target); /*bottom margin*/
- CGA_DrawVLine(x + 1, y, 1, 0, target); /*bottom left corner 1*/
- CGA_DrawHLine(x + 2, y + 1, w - 2, 0, target); /*box bottom*/
- CGA_DrawVLine(x + 1, y, 1, 0, target); /*TODO: duplicated?*/
- CGA_DrawVLine(x + w, y, 1, 0, target); /*bottom right corner*/
+ CGA_DrawHLine(x + 1, y, w, 1, target); /*bottom margin*/
+ CGA_DrawVLine(x + 1, y, 1, 0, target); /*bottom left corner 1*/
+ CGA_DrawHLine(x + 2, y + 1, w - 2, 0, target); /*box bottom*/
+ CGA_DrawVLine(x + 1, y, 1, 0, target); /*TODO: duplicated?*/
+ CGA_DrawVLine(x + w, y, 1, 0, target); /*bottom right corner*/
}
-void DrawMessage(unsigned char *msg, unsigned char *target)
-{
+void DrawMessage(unsigned char *msg, unsigned char *target) {
unsigned int x, y;
unsigned int w, h;
CalcStringSize(msg, &w, &h);
@@ -236,49 +208,47 @@ void DrawMessage(unsigned char *msg, unsigned char *target)
char_draw_max_height = CalcTextLines(msg) * 6 + 7;
x = cursor_x / 4;
- if(x < 9)
+ if (x < 9)
x = 9;
- if(x + char_draw_max_width + 2 >= 73)
+ if (x + char_draw_max_width + 2 >= 73)
x = 73 - (char_draw_max_width + 2);
y = cursor_y;
- if(y + char_draw_max_height >= 200)
+ if (y + char_draw_max_height >= 200)
y = 200 - char_draw_max_height;
draw_x = x;
draw_y = y;
- CGA_BackupImageReal(CGA_CalcXY_p(x, y), char_draw_max_width + 2, char_draw_max_height); /*backup orig. screen data*/
- CGA_DrawTextBox(msg, target); /*draw box with text*/
- PromptWait(); /*wait keypress*/
- CGA_RestoreBackupImage(target); /*restore screen data*/
+ CGA_BackupImageReal(CGA_CalcXY_p(x, y), char_draw_max_width + 2, char_draw_max_height); /*backup orig. screen data*/
+ CGA_DrawTextBox(msg, target); /*draw box with text*/
+ PromptWait(); /*wait keypress*/
+ CGA_RestoreBackupImage(target); /*restore screen data*/
}
#if 1
#include <stdio.h>
-void DebugMessage(char *msg, ...)
-{
+void DebugMessage(char *msg, ...) {
int i;
unsigned char c;
unsigned char m[256];
- va_list ap;
+ va_list ap;
- va_start(ap,msg);
- vsprintf((char*)m,msg,ap);
+ va_start(ap, msg);
+ vsprintf((char *)m, msg, ap);
va_end(ap);
- for(i = 0;m[i];i++)
- {
+ for (i = 0; m[i]; i++) {
c = m[i];
- if(c >= 'A' && c <= 'Z')
+ if (c >= 'A' && c <= 'Z')
c = 0x21 + (c - 'A');
- else if(c >= 'a' && c <= 'z')
+ else if (c >= 'a' && c <= 'z')
c = 0x21 + (c - 'a');
- else if(c >= '0' && c <= '9')
+ else if (c >= '0' && c <= '9')
c = 0x10 + (c - '0');
- else if(c == ' ')
+ else if (c == ' ')
c = 0x20;
- else if(c == '\n')
+ else if (c == '\n')
c = 0x00;
else
c = 0x1F;
diff --git a/engines/chamber/print.h b/engines/chamber/print.h
index d302cc68669..cc360ae1225 100644
--- a/engines/chamber/print.h
+++ b/engines/chamber/print.h
@@ -12,7 +12,7 @@ extern unsigned char chars_color_wonb[];
extern unsigned char chars_color_wonc[];
void PrintStringCentered(unsigned char *str, unsigned char *target);
-unsigned char * PrintStringPadded(unsigned char *str, unsigned char *target);
+unsigned char *PrintStringPadded(unsigned char *str, unsigned char *target);
void DrawMessage(unsigned char *msg, unsigned char *target);
diff --git a/engines/chamber/resdata.cpp b/engines/chamber/resdata.cpp
index 0a4c61a27d9..f74f00ed33e 100644
--- a/engines/chamber/resdata.cpp
+++ b/engines/chamber/resdata.cpp
@@ -8,13 +8,11 @@
Get bank entry
TODO: port SeekToString to this routine
*/
-unsigned char * SeekToEntry(unsigned char *bank, unsigned int num, unsigned char **end)
-{
+unsigned char *SeekToEntry(unsigned char *bank, unsigned int num, unsigned char **end) {
unsigned char len;
unsigned char *p = bank;
- while(num--)
- {
+ while (num--) {
len = *p;
p += len;
}
@@ -23,13 +21,11 @@ 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 char *SeekToEntryW(unsigned char *bank, unsigned int num, unsigned char **end) {
unsigned int len;
unsigned char *p = bank;
- while(num--)
- {
+ while (num--) {
len = p[0] | (p[1] << 8);
p += len;
}
@@ -38,40 +34,36 @@ unsigned char * SeekToEntryW(unsigned char *bank, unsigned int num, unsigned cha
return p + 2;
}
-unsigned int LoadFile(char *filename, unsigned char *buffer)
-{
+unsigned int LoadFile(char *filename, unsigned char *buffer) {
int f;
int rlen;
f = open(filename, O_RDONLY | O_BINARY);
- if(f == -1)
+ if (f == -1)
return 0;
rlen = read(f, buffer, 0xFFF0);
close(f);
- if(rlen == -1)
+ if (rlen == -1)
return 0;
return (unsigned int)rlen;
}
-unsigned int SaveFile(char *filename, unsigned char *buffer, unsigned int size)
-{
+unsigned int SaveFile(char *filename, unsigned char *buffer, unsigned int size) {
int f;
int wlen;
f = open(filename, O_RDONLY | O_BINARY);
- if(f == -1)
+ if (f == -1)
return 0;
wlen = write(f, buffer, size);
close(f);
- if(wlen == -1)
+ if (wlen == -1)
return 0;
return (unsigned int)wlen;
}
-int LoadFilesList(ResEntry_t *entries)
-{
+int LoadFilesList(ResEntry_t *entries) {
int i;
- for(i = 0;entries[i].name[0] != '$';i++)
- {
- if(!LoadFile(entries[i].name, entries[i].buffer))
+ for (i = 0; entries[i].name[0] != '$'; i++) {
+ if (!LoadFile(entries[i].name, entries[i].buffer))
return 0;
}
return 1;
@@ -111,8 +103,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()
-{
+int LoadStaticData() {
return LoadFilesList(res_static);
}
@@ -125,13 +116,11 @@ ResEntry_t res_texts[] = {
/*
Load strings data (commands/names)
*/
-int LoadVepciData()
-{
+int LoadVepciData() {
return LoadFilesList(res_texts);
}
-int LoadFond(void)
-{
+int LoadFond(void) {
return LoadSplash("FOND.BIN");
}
@@ -141,8 +130,7 @@ ResEntry_t res_sprites[] = {
{"$"}
};
-int LoadSpritesData(void)
-{
+int LoadSpritesData(void) {
return LoadFilesList(res_sprites);
}
@@ -152,11 +140,10 @@ ResEntry_t res_person[] = {
{"$"}
};
-int 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()*/
+int 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()*/
return LoadFilesList(res_person);
}
@@ -168,9 +155,8 @@ ResEntry_t res_desci[] = {
/*
Load strings data (obj. descriptions)
*/
-int LoadDesciData(void)
-{
- while(!LoadFilesList(res_desci))
+int LoadDesciData(void) {
+ while (!LoadFilesList(res_desci))
AskDisk2();
}
@@ -182,8 +168,7 @@ ResEntry_t res_diali[] = {
/*
Load strings data (dialogs)
*/
-int LoadDialiData(void)
-{
- while(!LoadFilesList(res_diali))
+int LoadDialiData(void) {
+ while (!LoadFilesList(res_diali))
AskDisk2();
}
diff --git a/engines/chamber/resdata.h b/engines/chamber/resdata.h
index 943a58ef58d..783fae7dd15 100644
--- a/engines/chamber/resdata.h
+++ b/engines/chamber/resdata.h
@@ -2,8 +2,8 @@
#define _RESDATA_H_
typedef struct ResEntry_t {
-char name[5 + 1 + 3 + 1];
-void *buffer;
+ char name[5 + 1 + 3 + 1];
+ void *buffer;
} ResEntry_t;
/* Max resource file size among all languages */
@@ -55,8 +55,8 @@ extern unsigned char anima_data[];
extern unsigned char anico_data[];
extern unsigned char 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);
+unsigned char *SeekToEntry(unsigned char *bank, unsigned int num, unsigned char **end);
+unsigned char *SeekToEntryW(unsigned char *bank, unsigned int num, unsigned char **end);
unsigned int LoadFile(char *filename, unsigned char *buffer);
unsigned int SaveFile(char *filename, unsigned char *buffer, unsigned int size);
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index 0df883dcfa5..97c68288ced 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -16,7 +16,7 @@
unsigned char scratch_mem1[8010];
unsigned char *scratch_mem2 = scratch_mem1 + 1500;
-rect_t room_bounds_rect = {0,0,0,0};
+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;
@@ -57,7 +57,7 @@ unsigned char *lutin_mem;
unsigned short inv_update_time = 0;
-unsigned char in_de_profundis = 0; /*TODO: useless?*/
+unsigned char in_de_profundis = 0; /*TODO: useless?*/
unsigned short next_command3 = 0;
unsigned short next_ticks3 = 0;
@@ -116,22 +116,19 @@ rec7_t recs7_list[RECS7_MAX] = {
};
static const unsigned char cga_color_sels[] = {
- 0x30,0x10,0x30,0x10,0x30,0x10,0x10,0x30,0x10,0x10,0x10,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x10,0x10,0x10
+ 0x30, 0x10, 0x30, 0x10, 0x30, 0x10, 0x10, 0x30, 0x10, 0x10, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x10, 0x10, 0x10
};
-void SelectPalette(void)
-{
+void SelectPalette(void) {
CGA_ColorSelect(cga_color_sels[script_byte_vars.palette_index]);
}
/*
Blit sprites to backbuffer
*/
-void BlitSpritesToBackBuffer(void)
-{
+void BlitSpritesToBackBuffer(void) {
int i;
- for(i = 0;i < MAX_SPRITES;i++)
- {
+ for (i = 0; i < MAX_SPRITES; i++) {
unsigned char *sprite = sprites_list[i];
CGA_RestoreImage(sprite, backbuffer);
}
@@ -140,38 +137,31 @@ void BlitSpritesToBackBuffer(void)
/*
Copy data at sprite's rect from screen to backbuffer
*/
-void RefreshSpritesData(void)
-{
+void RefreshSpritesData(void) {
int i;
- for(i = 0;i < MAX_SPRITES;i++)
- {
+ for (i = 0; i < MAX_SPRITES; i++) {
unsigned char *sprite = sprites_list[i];
CGA_RefreshImageData(sprite);
}
}
-int IsInRect(unsigned char x, unsigned char y, rect_t *rect)
-{
- if(x < rect->sx) return 0;
- if(x >= rect->ex) return 0;
- if(y < rect->sy) return 0;
- if(y >= rect->ey) return 0;
- return 1;
+int IsInRect(unsigned char x, unsigned char y, rect_t *rect) {
+ if (x < rect->sx) return 0;
+ if (x >= rect->ex) return 0;
+ if (y < rect->sy) return 0;
+ if (y >= rect->ey) return 0;
+ return 1;
}
-int IsCursorInRect(rect_t *rect)
-{
+int IsCursorInRect(rect_t *rect) {
return IsInRect(cursor_x / CGA_PIXELS_PER_BYTE, cursor_y, rect);
}
-void FindPerson(void)
-{
+void FindPerson(void) {
int i;
pers_t *pers = pers_list;
- for(i = 0;i < PERS_MAX;i++, pers++)
- {
- if((pers->flags & 15) == script_byte_vars.cur_spot_idx)
- {
+ for (i = 0; i < PERS_MAX; i++, pers++) {
+ if ((pers->flags & 15) == script_byte_vars.cur_spot_idx) {
script_vars[ScrPool8_CurrentPers] = pers;
script_byte_vars.cur_pers = i + 1;
return;
@@ -180,14 +170,11 @@ void FindPerson(void)
script_byte_vars.cur_pers = 0;
}
-void CheckHotspots(unsigned char m, unsigned char v)
-{
+void CheckHotspots(unsigned char m, unsigned char v) {
int 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))
- {
+ for (i = 0; spot != zone_spots_end; i++, spot++) {
+ if (IsCursorInRect((rect_t *)spot) && (spot->flags & SPOTFLG_80) && ((spot->flags & m) == v)) {
script_byte_vars.cur_spot_idx = i + 1;
spot_sprite = sprites_list + i;
found_spot = spot;
@@ -200,25 +187,22 @@ void CheckHotspots(unsigned char m, unsigned char v)
}
}
cursor_color = 0xFF;
- object_hint = zone_name; /*room name*/
+ object_hint = zone_name; /*room name*/
script_byte_vars.cur_spot_idx = 0;
}
-void SelectSpotCursor(void)
-{
+void SelectSpotCursor(void) {
int curs = 1;
CheckHotspots(script_byte_vars.spot_m, script_byte_vars.spot_v);
- if(cursor_color == 0xAA)
- {
+ if (cursor_color == 0xAA) {
curs = 6;
- if((script_byte_vars.cur_spot_flags & (SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8)) != SPOTFLG_10)
- {
+ if ((script_byte_vars.cur_spot_flags & (SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8)) != SPOTFLG_10) {
curs = 7;
- if((script_byte_vars.cur_spot_flags & SPOTFLG_20) != 0)
+ if ((script_byte_vars.cur_spot_flags & SPOTFLG_20) != 0)
curs = 8;
}
}
- cursor_shape = souri_data + curs * CURSOR_WIDTH * CURSOR_HEIGHT * 2 / CGA_PIXELS_PER_BYTE;
+ cursor_shape = souri_data + curs * CURSOR_WIDTH * CURSOR_HEIGHT * 2 / CGA_PIXELS_PER_BYTE;
}
#define kBgW 8
@@ -226,42 +210,39 @@ void SelectSpotCursor(void)
/*blocks draw order (clockwise inward spiral)*/
static const signed int 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,
+ 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,
- -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, -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,
- 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, kBgH / 2 * CGA_BYTES_PER_LINE,
-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,
kBgW, kBgW, kBgW, kBgW, kBgW,
- kBgH/2*CGA_BYTES_PER_LINE,
- -kBgW, -kBgW, -kBgW, -kBgW};
+ kBgH / 2 * CGA_BYTES_PER_LINE,
+ -kBgW, -kBgW, -kBgW, -kBgW
+};
/*Draw main backgound pattern, in spiral-like order*/
-void DrawBackground(unsigned char *target, unsigned char vblank)
-{
+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*/
- for(i = 0;i < 53;i++)
- {
+ unsigned int offs = (2 / 2) * CGA_BYTES_PER_LINE + 8; /*TODO: calcxy?*/
+ unsigned char *pixels = gauss_data + 0x3C8; /*TODO: better const*/
+ for (i = 0; i < 53; i++) {
CGA_Blit(pixels + (i & 1 ? 0 : kBgW * kBgH), kBgW, kBgW, kBgH, target, offs);
- if(vblank)
+ if (vblank)
WaitVBlank();
offs += background_draw_steps[i];
}
- offs = (182 / 2) * CGA_BYTES_PER_LINE; /*TODO: calcxy?*/
- for(i = 0;i < 9;i++)
- {
+ offs = (182 / 2) * CGA_BYTES_PER_LINE; /*TODO: calcxy?*/
+ for (i = 0; i < 9; i++) {
CGA_Blit(pixels, kBgW, kBgW, 9, target, offs);
offs += kBgW;
}
}
-void LoadZone(void)
-{
+void LoadZone(void) {
unsigned char *zptr, *zend;
zptr = SeekToEntry(zones_data, script_byte_vars.zone_index - 1, &zend);
@@ -270,37 +251,30 @@ void LoadZone(void)
zone_name = object_hint = *zptr++;
zone_palette = script_byte_vars.palette_index = *zptr++;
zone_obj_count = *zptr++;
- if(zone_obj_count != 0)
- {
+ if (zone_obj_count != 0) {
unsigned int i;
unsigned short *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++)
- {
+ 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++) {
unsigned short 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*/
+ if (flags & 0x10) {
+ zcmds[0] = zptr[0] | (zptr[1] << 8); /*TODO: big-endian, but loaded here as le and converted later*/
zptr += 2;
}
- if(flags & 8)
- {
+ if (flags & 8) {
zcmds[1] = zptr[0] | (zptr[1] << 8);
zptr += 2;
}
- if(flags & 4)
- {
+ if (flags & 4) {
zcmds[2] = zptr[0] | (zptr[1] << 8);
zptr += 2;
}
- if(flags & 2)
- {
+ if (flags & 2) {
zcmds[3] = zptr[0] | (zptr[1] << 8);
zptr += 2;
}
- if(flags & 1)
- {
+ if (flags & 1) {
zcmds[4] = zptr[0] | (zptr[1] << 8);
zptr += 2;
}
@@ -308,9 +282,9 @@ void LoadZone(void)
}
}
- zone_spots = script_vars[ScrPool4_ZoneSpots] = (spot_t*)zptr;
- zone_spots_end = (spot_t*)zend;
- zone_spots_cur = (spot_t*)zptr;
+ zone_spots = script_vars[ScrPool4_ZoneSpots] = (spot_t *)zptr;
+ zone_spots_end = (spot_t *)zend;
+ zone_spots_cur = (spot_t *)zptr;
zone_spr_index = 0;
script_byte_vars.dead_flag = 0;
script_byte_vars.byte_179DB = 0;
@@ -320,8 +294,7 @@ void LoadZone(void)
script_byte_vars.used_commands = 0;
}
-void ResetZone(void)
-{
+void ResetZone(void) {
script_word_vars.word_178EE = 0;
script_word_vars.word_17852 = 0;
script_word_vars.word_17848 = 0;
@@ -343,18 +316,16 @@ void ResetZone(void)
}
/*load puzzl sprite to buffer, return next free buffer ptr*/
-unsigned char * LoadPuzzl(unsigned char index, unsigned char *buffer)
-{
- if(script_byte_vars.palette_index == 14)
+unsigned char *LoadPuzzl(unsigned char index, unsigned char *buffer) {
+ if (script_byte_vars.palette_index == 14)
return LoadSprite(index, puzzl_data + 4, buffer, 1);
else
return LoadSprite(index, puzzl_data + 4, buffer, 0);
}
/*load puzzl sprite to scratch buffer, return sprite ptr*/
-unsigned char * LoadPuzzlToScratch(unsigned char index)
-{
- unsigned char * buffer = scratch_mem2;
+unsigned char *LoadPuzzlToScratch(unsigned char index) {
+ unsigned char *buffer = scratch_mem2;
LoadPuzzl(index, buffer);
return buffer;
}
@@ -372,25 +343,23 @@ typedef struct doorinfo_t {
unsigned char width;
unsigned char height;
unsigned int offs;
- unsigned char sprites[1]; /*variable size*/
+ unsigned char sprites[1]; /*variable size*/
} doorinfo_t;
unsigned char *doors_list[5];
unsigned char arpla_y_step;
-void InitRoomDoorInfo(unsigned char index)
-{
+void InitRoomDoorInfo(unsigned char index) {
int i;
unsigned char *aptr;
unsigned char *sprbuf;
- doorinfo_t *info = (doorinfo_t*)scratch_mem2;
+ doorinfo_t *info = (doorinfo_t *)scratch_mem2;
rect_t bounds = {0xFF, 0, 0xFF, 0};
aptr = doors_list[index - 1];
info->flipped = (aptr[1] & 0x80) ? ~0 : 0;
sprbuf = info->sprites;
- for(i = 0;i < kNumDoorSprites;i++)
- {
+ for (i = 0; i < kNumDoorSprites; i++) {
unsigned char x, y, w, h, ox;
unsigned char *sprite = sprbuf;
sprbuf = LoadPuzzl(aptr[0], sprbuf);
@@ -401,23 +370,22 @@ void InitRoomDoorInfo(unsigned char index)
h = sprite[1];
ox = x;
- if(x & 0x80)
- {
+ if (x & 0x80) {
/*horizontal flip*/
x = (x + w - 1) & 0x7F;
ox &= 0x7F;
}
- y = (y * 2) & 0xFF; /*TODO: disregard vertical flip?*/
+ y = (y * 2) & 0xFF; /*TODO: disregard vertical flip?*/
- if(ox < bounds.sx)
+ if (ox < bounds.sx)
bounds.sx = ox;
- if(ox + w >= bounds.ex)
+ if (ox + w >= bounds.ex)
bounds.ex = ox + w;
- if(y < bounds.sy)
+ if (y < bounds.sy)
bounds.sy = y;
- if(y + h >= bounds.ey)
+ if (y + h >= bounds.ey)
bounds.ey = y + h;
info->layer[i].width = w;
@@ -433,18 +401,16 @@ void InitRoomDoorInfo(unsigned char index)
info->offs = CGA_CalcXY_p(bounds.sx, bounds.sy);
}
-void DrawRoomDoor(void)
-{
+void DrawRoomDoor(void) {
int i;
- doorinfo_t *info = (doorinfo_t*)scratch_mem2;
- for(i = 0;i < kNumDoorSprites;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;
- if(!info->flipped)
+ if (!info->flipped)
CGA_BlitSprite(pixels, w * 2, w, h, backbuffer, offs);
else
CGA_BlitSpriteFlip(pixels, w * 2, w, h, backbuffer, offs);
@@ -454,16 +420,14 @@ void DrawRoomDoor(void)
CGA_CopyScreenBlock(backbuffer, info->width, info->height, frontbuffer, info->offs);
}
-void AnimRoomDoorOpen(unsigned char index)
-{
+void AnimRoomDoorOpen(unsigned char index) {
int i;
- doorinfo_t *info = (doorinfo_t*)scratch_mem2;
+ doorinfo_t *info = (doorinfo_t *)scratch_mem2;
InitRoomDoorInfo(index);
- for(i = 0;i < info->layer[1].height / 2;i++)
- {
+ for (i = 0; i < info->layer[1].height / 2; i++) {
#if 1
DrawRoomDoor();
#endif
@@ -474,14 +438,13 @@ void AnimRoomDoorOpen(unsigned char index)
PlaySound(31);
}
-void AnimRoomDoorClose(unsigned char index)
-{
+void AnimRoomDoorClose(unsigned char index) {
int i;
unsigned char oldheight;
unsigned char *oldpixels;
- doorinfo_t *info = (doorinfo_t*)scratch_mem2;
+ doorinfo_t *info = (doorinfo_t *)scratch_mem2;
InitRoomDoorInfo(index);
oldheight = info->layer[1].height;
@@ -489,9 +452,8 @@ void AnimRoomDoorClose(unsigned char index)
info->layer[1].pixels += info->layer[1].width * 2 * (info->layer[1].height - 1);
info->layer[1].height = 1;
-
- for(i = 0;i < oldheight / 2;i++)
- {
+
+ for (i = 0; i < oldheight / 2; i++) {
#if 0
DrawRoomDoor();
#endif
@@ -507,43 +469,38 @@ void AnimRoomDoorClose(unsigned char index)
}
/*Maybe FindRoomDoor?*/
-unsigned char FindInitialSpot(void)
-{
+unsigned char FindInitialSpot(void) {
spot_t *spot;
unsigned char index;
unsigned char flags = script_byte_vars.byte_179B8;
- if(flags == 0)
+ if (flags == 0)
return 0;
flags |= 0x80;
- for(index = 1, spot = zone_spots;spot != zone_spots_end;index++, spot++)
- {
- if(spot->flags == flags)
+ for (index = 1, spot = zone_spots; spot != zone_spots_end; index++, spot++) {
+ if (spot->flags == flags)
return index;
}
return 0;
}
-unsigned char FindSpotByFlags(unsigned char mask, unsigned char value)
-{
+unsigned char FindSpotByFlags(unsigned char mask, unsigned char value) {
spot_t *spot;
unsigned char index;
- for(index = 1, spot = zone_spots;spot != zone_spots_end;spot++, index++)
- {
- if((spot->flags & mask) == value)
+ for (index = 1, spot = zone_spots; spot != zone_spots_end; spot++, index++) {
+ if ((spot->flags & mask) == value)
return index;
}
return 0xFF;
}
-unsigned char FindAndSelectSpot(unsigned char offset)
-{
+unsigned char FindAndSelectSpot(unsigned char offset) {
/*TODO: replace offset arg with index?*/
- unsigned char index = offset / 5; /* / sizeof(pers_t) */
+ unsigned char index = offset / 5; /* / sizeof(pers_t) */
script_vars[ScrPool8_CurrentPers] = &pers_list[index];
- index = FindSpotByFlags(0x3F, (pers_list[index].index & 7) | SPOTFLG_10); /*TODO: return 0 if not found?*/
- if(index == 0xFF)
+ index = FindSpotByFlags(0x3F, (pers_list[index].index & 7) | SPOTFLG_10); /*TODO: return 0 if not found?*/
+ if (index == 0xFF)
return 0;
found_spot = &zone_spots[index - 1];
@@ -552,22 +509,18 @@ unsigned char FindAndSelectSpot(unsigned char offset)
return 1;
}
-void AnimateSpot(const animdesc_t *info)
-{
+void AnimateSpot(const animdesc_t *info) {
unsigned char *sprite = *spot_sprite;
CGA_RestoreImage(sprite, backbuffer);
- if(info->index & ANIMFLG_USESPOT)
- {
+ if (info->index & ANIMFLG_USESPOT) {
/*at object*/
cursor_x = found_spot->sx * 4;
cursor_y = found_spot->sy;
- if(info->params.desc)
- DrawMessage(SeekToString(desci_data, info->params.desc), frontbuffer);
+ if (info->params.desc)
+ DrawMessage(SeekToString(desci_data, info->params.desc), frontbuffer);
PlayAnim(info->index & ~ANIMFLG_USESPOT, found_spot->sx, found_spot->sy);
- }
- else
- {
+ } else {
/*at specified coords*/
PlayAnim(info->index, info->params.coords.x, info->params.coords.y);
}
@@ -579,51 +532,50 @@ typedef struct lutinanim_t {
} lutinanim_t;
lutinanim_t lutins_table[] = {
- {0, { 55, 55, 55, 55, 55, 55, 55, 55} },
- {0, { 41, 41, 41, 41, 41, 41, 41, 41} },
- {0, { 6, 6, 6, 6, 6, 6, 6, 6} },
+ {0, { 55, 55, 55, 55, 55, 55, 55, 55} },
+ {0, { 41, 41, 41, 41, 41, 41, 41, 41} },
+ {0, { 6, 6, 6, 6, 6, 6, 6, 6} },
{0, { 33, 34, 33, 35, 33, 36, 33, 35} },
{0, { 10, 11, 10, 13, 10, 12, 10, 14} },
{0, { 15, 16, 17, 18, 19, 15, 20, 21} },
{0, { 80, 81, 80, 83, 80, 82, 80, 84} },
- {0, {139,140,141,142,139,140,141,142} },
- {0, {133,134,133,135,133,134,133,135} },
- {0, {136,137,136,138,136,137,136,138} },
- {0, {144,145,144,145,144,145,144,145} },
+ {0, {139, 140, 141, 142, 139, 140, 141, 142} },
+ {0, {133, 134, 133, 135, 133, 134, 133, 135} },
+ {0, {136, 137, 136, 138, 136, 137, 136, 138} },
+ {0, {144, 145, 144, 145, 144, 145, 144, 145} },
{0, { 33, 34, 33, 35, 33, 36, 33, 35} },
- {0, {181,182,181,183,181,182,181,183} },
- {0, {178,179,178,180,178,179,178,180} },
- {0, {181,182,181,183,181,182,181,183} },
- {0, {185,186,187,188,185,186,187,188} },
- {0, {185,186,187,188,185,186,187,188} },
- {0, {164,132,164,132,164,132,164,132} },
- {0, {144,145,144,145,144,145,144,145} },
+ {0, {181, 182, 181, 183, 181, 182, 181, 183} },
+ {0, {178, 179, 178, 180, 178, 179, 178, 180} },
+ {0, {181, 182, 181, 183, 181, 182, 181, 183} },
+ {0, {185, 186, 187, 188, 185, 186, 187, 188} },
+ {0, {185, 186, 187, 188, 185, 186, 187, 188} },
+ {0, {164, 132, 164, 132, 164, 132, 164, 132} },
+ {0, {144, 145, 144, 145, 144, 145, 144, 145} },
{0, { 33, 34, 33, 35, 33, 36, 33, 35} },
- {0, {199,200,201,202,199,200,201,202} },
- {0, {195,196,197,198,195,196,197,198} },
- {0, {203,203,203,203,203,203,203,203} },
- {0, {148,148,148,148,148,148,148,148} },
- {0, {185,186,187,188,185,186,187,188} },
- {0, {193,193,193,193,193,193,193,193} },
- {0, {165,166,167,168,165,166,167,168} },
+ {0, {199, 200, 201, 202, 199, 200, 201, 202} },
+ {0, {195, 196, 197, 198, 195, 196, 197, 198} },
+ {0, {203, 203, 203, 203, 203, 203, 203, 203} },
+ {0, {148, 148, 148, 148, 148, 148, 148, 148} },
+ {0, {185, 186, 187, 188, 185, 186, 187, 188} },
+ {0, {193, 193, 193, 193, 193, 193, 193, 193} },
+ {0, {165, 166, 167, 168, 165, 166, 167, 168} },
{0, { 33, 34, 33, 35, 33, 36, 33, 35} },
- {0, {181,182,181,183,181,182,181,183} },
- {0, {178,179,178,180,178,179,178,180} },
+ {0, {181, 182, 181, 183, 181, 182, 181, 183} },
+ {0, {178, 179, 178, 180, 178, 179, 178, 180} },
{0, { 91, 91, 91, 91, 91, 91, 91, 91} },
- {0, {221,221,221,221,221,221,221,221} },
+ {0, {221, 221, 221, 221, 221, 221, 221, 221} },
{0, { 0, 0, 0, 0, 0, 0, 0, 0} }
};
-void UpdateZoneSpot(unsigned char index)
-{
+void UpdateZoneSpot(unsigned char index) {
unsigned char oldspot;
static const animdesc_t anim57 = {ANIMFLG_USESPOT | 57};
static const animdesc_t anim58 = {ANIMFLG_USESPOT | 58};
script_byte_vars.need_draw_spots = 0;
- if(pers_list[27].area != script_byte_vars.zone_area)
+ if (pers_list[27].area != script_byte_vars.zone_area)
return;
- if(index < 59 || index >= 63)
+ if (index < 59 || index >= 63)
return;
oldspot = script_byte_vars.cur_spot_idx;
@@ -633,8 +585,7 @@ void UpdateZoneSpot(unsigned char index)
FindAndSelectSpot(27 * 5);
AnimateSpot(&anim57);
- if(pers_list[30].area != 0)
- {
+ if (pers_list[30].area != 0) {
FindAndSelectSpot(30 * 5);
AnimateSpot(&anim58);
}
@@ -642,25 +593,23 @@ void UpdateZoneSpot(unsigned char index)
script_byte_vars.cur_spot_idx = oldspot;
}
-void ChangeZone(unsigned char index)
-{
+void ChangeZone(unsigned char index) {
unsigned char spridx = 0;
script_byte_vars.prev_zone_index = script_byte_vars.zone_index;
script_byte_vars.zone_index = index;
- if(script_byte_vars.byte_17A22 != 0)
+ if (script_byte_vars.byte_17A22 != 0)
spridx = 229;
- else if(script_byte_vars.zone_index == 129)
+ else if (script_byte_vars.zone_index == 129)
spridx = 221;
- else if(script_byte_vars.zone_index == 130)
+ else if (script_byte_vars.zone_index == 130)
spridx = 222;
- if(spridx != 0)
- {
+ if (spridx != 0) {
int i;
lutinanim_t *la = &lutins_table[31];
- for(i = 0;i < 8;i++)
+ for (i = 0; i < 8; i++)
la->sprites[i] = spridx;
}
@@ -669,37 +618,32 @@ void ChangeZone(unsigned char index)
}
-void DrawZoneObjs(void)
-{
+void DrawZoneObjs(void) {
int i;
unsigned char index, pidx;
spot_t *spot;
- for(spot = zone_spots;spot != zone_spots_end;spot++)
- {
- if((spot->flags & 0x38) == SPOTFLG_10)
+ for (spot = zone_spots; spot != zone_spots_end; spot++) {
+ if ((spot->flags & 0x38) == SPOTFLG_10)
spot->flags &= ~SPOTFLG_80;
}
- for(i = 0;i < PERS_MAX;i++)
- {
+ for (i = 0; i < PERS_MAX; i++) {
pers_list[i].flags &= ~0xF;
- if(pers_list[i].area != script_byte_vars.zone_area)
+ if (pers_list[i].area != script_byte_vars.zone_area)
continue;
- if(pers_list[i].flags & PERSFLG_40)
+ if (pers_list[i].flags & PERSFLG_40)
continue;
pidx = (pers_list[i].index & 7) | SPOTFLG_10;
- for(index = 1, spot = zone_spots;spot != zone_spots_end;spot++, index++)
- {
- if((spot->flags & ~SPOTFLG_40) == pidx)
- {
+ for (index = 1, spot = zone_spots; spot != zone_spots_end; spot++, index++) {
+ if ((spot->flags & ~SPOTFLG_40) == pidx) {
spot->flags |= SPOTFLG_80;
spot->hint = pers_list[i].name;
pers_list[i].flags |= index;
- if(spot->flags & SPOTFLG_40)
- DrawZoneAniSprite((rect_t*)spot, index, backbuffer);
+ if (spot->flags & SPOTFLG_40)
+ DrawZoneAniSprite((rect_t *)spot, index, backbuffer);
break;
}
}
@@ -707,8 +651,7 @@ 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)
-{
+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]);
@@ -726,28 +669,25 @@ void DrawRoomStaticObject(unsigned char *aptr, unsigned char *rx, unsigned char
pitch = w * 2;
- if(x & 0x80)
- {
+ if (x & 0x80) {
/*horizontal flip*/
x = (x + w - 1) & 0x7F;
}
- if(y & 0x80)
- {
+ if (y & 0x80) {
/*vertical flip*/
sprite += pitch * (h - 1);
pitch = -pitch;
}
y = (y * 2) & 0xFF;
- if(aptr[0] == 83)
- {
- if(arpla_y_step & 1)
+ if (aptr[0] == 83) {
+ if (arpla_y_step & 1)
y -= 8;
arpla_y_step >>= 1;
}
- if(aptr[1] & 0x80)
+ if (aptr[1] & 0x80)
CGA_BlitSpriteFlip(sprite, pitch, w, h, backbuffer, CGA_CalcXY_p(x, y));
else
CGA_BlitSprite(sprite, pitch, w, h, backbuffer, CGA_CalcXY_p(x, y));
@@ -758,8 +698,7 @@ Draw all room's static objects (decorations) to backbuffer
Initialize room bounds rect to room's dimensions
Draw room's name box and text
*/
-void DrawRoomStatics(void)
-{
+void DrawRoomStatics(void) {
unsigned char *aptr, *aend;
unsigned char doorcount = 0;
unsigned char x, y, w, h;
@@ -775,17 +714,15 @@ void DrawRoomStatics(void)
room_bounds_rect.ey = 0;
/*load and draw room decor*/
- for(;aptr != aend;aptr += 3)
- {
+ for (; aptr != aend; aptr += 3) {
unsigned char index = *aptr;
/*a door ?*/
- if(index >= 50 && index < 61)
- {
- doors_list[doorcount++] = aptr - 3; /*TODO: check for list overflow?*/
- if(doorcount == script_byte_vars.cur_spot_idx)
+ if (index >= 50 && index < 61) {
+ doors_list[doorcount++] = aptr - 3; /*TODO: check for list overflow?*/
+ if (doorcount == script_byte_vars.cur_spot_idx)
continue;
- if(script_byte_vars.zone_room == 32 && index == 91 && (script_byte_vars.byte_179DD & 8))
- continue; /*TODO: error? index may never be that high here*/
+ if (script_byte_vars.zone_room == 32 && index == 91 && (script_byte_vars.byte_179DD & 8))
+ continue; /*TODO: error? index may never be that high here*/
}
/*draw decor object*/
DrawRoomStaticObject(aptr, &x, &y, &w, &h);
@@ -793,13 +730,13 @@ void DrawRoomStatics(void)
/*update room's bounding rect*/
x &= 0x7F;
y = (y * 2) & 0xFF;
- if(x < room_bounds_rect.sx)
+ if (x < room_bounds_rect.sx)
room_bounds_rect.sx = x;
- if(x + w > room_bounds_rect.ex)
+ if (x + w > room_bounds_rect.ex)
room_bounds_rect.ex = x + w;
- if(y < room_bounds_rect.sy)
+ if (y < room_bounds_rect.sy)
room_bounds_rect.sy = y;
- if(y + h > room_bounds_rect.ey)
+ if (y + h > room_bounds_rect.ey)
room_bounds_rect.ey = y + h;
}
@@ -813,7 +750,7 @@ void DrawRoomStatics(void)
/*print room name*/
CGA_PrintChar(0x3B, backbuffer);
- DrawObjectHint(); /* area name */
+ DrawObjectHint(); /* area name */
CGA_PrintChar(0x3C, backbuffer);
/*draw border around hint text*/
@@ -828,32 +765,27 @@ void DrawRoomStatics(void)
CGA_DrawVLine(xx + ww - 1, y - 2, 9, 2, backbuffer);
}
-void RedrawRoomStatics(unsigned char index, unsigned char y_step)
-{
+void RedrawRoomStatics(unsigned char index, unsigned char y_step) {
unsigned char *aptr, *aend;
unsigned char x, y, w, h;
arpla_y_step = y_step;
aptr = SeekToEntry(arpla_data, index - 1, &aend);
- for(;aptr != aend;aptr += 3)
- {
+ for (; aptr != aend; aptr += 3) {
/*load room's bg objs*/
DrawRoomStaticObject(aptr, &x, &y, &w, &h);
- }
+ }
}
/*
Draw "some item in the room" icon
*/
-void DrawRoomItemsIndicator(void)
-{
+void DrawRoomItemsIndicator(void) {
unsigned char spridx = 172;
int 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)
- {
+ for (i = 0; i < MAX_INV_ITEMS; i++) {
+ if (inventory_items[i].flags == ITEMFLG_40
+ && inventory_items[i].flags2 == script_byte_vars.zone_area) {
spridx = 173;
break;
}
@@ -862,21 +794,19 @@ void DrawRoomItemsIndicator(void)
DrawSpriteN(spridx, 296 / CGA_PIXELS_PER_BYTE, 14, backbuffer);
script_byte_vars.room_items = 0;
- for(i = 0;i < 14;i++)
- {
- if(inventory_items[i + 38].flags == ITEMFLG_80)
- script_byte_vars.room_items++; /*TODO: probably should be named differently*/
+ for (i = 0; i < 14; i++) {
+ if (inventory_items[i + 38].flags == ITEMFLG_80)
+ script_byte_vars.room_items++; /*TODO: probably should be named differently*/
}
}
-void DrawZoneSpots(void)
-{
+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;
- if(!script_byte_vars.need_draw_spots)
+ if (!script_byte_vars.need_draw_spots)
return;
FindAndSelectSpot(27 * 5);
@@ -884,8 +814,7 @@ void DrawZoneSpots(void)
pers_list[27].area = script_byte_vars.zone_area;
- if(pers_list[30].area != 0)
- {
+ if (pers_list[30].area != 0) {
pers_list[30].area = script_byte_vars.zone_area;
FindAndSelectSpot(30 * 5);
AnimateSpot(&anim60);
@@ -893,16 +822,15 @@ void DrawZoneSpots(void)
script_byte_vars.cur_spot_idx = oldspot;
- DrawZoneObjs();
+ DrawZoneObjs();
}
-void RefreshZone(void)
-{
+void RefreshZone(void) {
PopDirtyRects(DirtyRectSprite);
PopDirtyRects(DirtyRectBubble);
PopDirtyRects(DirtyRectText);
- if(!zone_drawn && !right_button)
+ if (!zone_drawn && !right_button)
DrawBackground(CGA_SCREENBUFFER, 1);
CGA_BackBufferToRealFull();
@@ -913,14 +841,13 @@ void RefreshZone(void)
SelectPalette();
DrawRoomItemsIndicator();
DrawZoneSpots();
- if(script_byte_vars.cur_spot_idx != 0)
+ if (script_byte_vars.cur_spot_idx != 0)
AnimRoomDoorClose(script_byte_vars.cur_spot_idx);
BlitSpritesToBackBuffer();
}
-void DrawObjectHint(void)
-{
- if(script_byte_vars.zone_index == 135)
+void DrawObjectHint(void) {
+ if (script_byte_vars.zone_index == 135)
return;
char_draw_max_width = room_hint_bar_width;
char_draw_coords_x = room_hint_bar_coords_x;
@@ -936,15 +863,13 @@ void DrawObjectHint(void)
#endif
}
-void ShowObjectHint(unsigned char *target)
-{
- if(script_byte_vars.zone_index == 135)
+void ShowObjectHint(unsigned char *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));
}
-void DrawCommandHint(void)
-{
+void DrawCommandHint(void) {
char_draw_max_width = cmd_hint_bar_width;
char_draw_coords_x = cmd_hint_bar_coords_x;
char_draw_coords_y = cmd_hint_bar_coords_y;
@@ -952,13 +877,11 @@ void DrawCommandHint(void)
PrintStringCentered(SeekToString(vepci_data, command_hint), backbuffer);
}
-void ShowCommandHint(unsigned char *target)
-{
+void ShowCommandHint(unsigned char *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)
-{
+void LoadLutinSprite(unsigned int lutidx) {
unsigned char spridx;
unsigned int flags;
unsigned char *lutin_entry, *lutin_entry_end;
@@ -970,19 +893,17 @@ void LoadLutinSprite(unsigned int lutidx)
buffer = lutin_mem;
- for(i = 0;i < 800;i++) /*TODO: fix size*/
- {
- buffer[i * 2] = 0xFF; /*mask*/
- buffer[i * 2 + 1] = 0; /*pixels*/
+ for (i = 0; i < 800; i++) { /*TODO: fix size*/
+ buffer[i * 2] = 0xFF; /*mask*/
+ buffer[i * 2 + 1] = 0; /*pixels*/
}
lutin_entry = SeekToEntry(lutin_data, lutidx, &lutin_entry_end);
- *buffer++ = *lutin_entry++; /*width*/
- *buffer++ = *lutin_entry++; /*height*/
+ *buffer++ = *lutin_entry++; /*width*/
+ *buffer++ = *lutin_entry++; /*height*/
- for(;lutin_entry != lutin_entry_end;)
- {
+ for (; lutin_entry != lutin_entry_end;) {
spridx = *lutin_entry++;
flags = *lutin_entry++;
flags |= (*lutin_entry++) << 8;
@@ -992,7 +913,7 @@ void LoadLutinSprite(unsigned int lutidx)
sprh = *sprite++;
buffer = lutin_mem + 2 + (flags & 0x7FFF) * 2;
- if(flags & 0x8000)
+ if (flags & 0x8000)
MergeSpritesDataFlip(buffer, lutin_mem[0] * 2, sprite, sprw, sprh);
else
MergeSpritesData(buffer, lutin_mem[0] * 2, sprite, sprw, sprh);
@@ -1000,15 +921,12 @@ void LoadLutinSprite(unsigned int lutidx)
}
/*Draw room's sprites and advance sprite's animation*/
-char DrawZoneAniSprite(rect_t *rect, unsigned int index, unsigned char *target)
-{
+char DrawZoneAniSprite(rect_t *rect, unsigned int index, unsigned char *target) {
int i;
unsigned char spridx;
pers_t *pers = pers_list;
- for(i = 0;i < PERS_MAX;i++, pers++)
- {
- if((pers->flags & 15) == index)
- {
+ for (i = 0; i < PERS_MAX; i++, pers++) {
+ if ((pers->flags & 15) == index) {
lutinanim_t *la = &lutins_table[pers->index >> 3];
spridx = la->sprites[la->phase];
la->phase = (la->phase + 1) % 8;
@@ -1020,31 +938,28 @@ char DrawZoneAniSprite(rect_t *rect, unsigned int index, unsigned char *target)
zsprite_w = scratch_mem2[0];
zsprite_h = scratch_mem2[1];
zsprite_draw_ofs = CGA_CalcXY_p(rect->sx, rect->sy);
-
+
DrawSprite(scratch_mem2, target, zsprite_draw_ofs);
-
+
return ~0;
}
}
return 0;
}
-void SetDelay5(void)
-{
+void SetDelay5(void) {
next_ticks4 = Swap16(script_word_vars.timer_ticks2) + 5;
}
/*
Pick random quest item
*/
-void PrepareCommand1(void)
-{
+void PrepareCommand1(void) {
unsigned char index;
unsigned char oldr, newr;
unsigned char flags;
- if(script_byte_vars.zone_area == 55)
- {
+ if (script_byte_vars.zone_area == 55) {
pers_list[1].area = 55;
pers_list[2].area = 55;
pers_list[3].area = 55;
@@ -1059,89 +974,73 @@ void PrepareCommand1(void)
pers_list[3].area = 0;
pers_list[4].area = 0;
- if(script_byte_vars.byte_179DC >= 63)
+ if (script_byte_vars.byte_179DC >= 63)
return;
- if(script_byte_vars.zone_area >= 44)
+ if (script_byte_vars.zone_area >= 44)
return;
index = FindSpotByFlags(0x3F, 17);
- if(index == 0xFF)
+ if (index == 0xFF)
return;
spot_ptr = &zone_spots[index - 1];
- script_byte_vars.quest_item_ofs += 5; /*FIXME: this is sizeof(pers_t), but it's used in scripts, so hardcoded*/
- if(script_byte_vars.quest_item_ofs >= 5 * 5)
+ script_byte_vars.quest_item_ofs += 5; /*FIXME: this is sizeof(pers_t), but it's used in scripts, so hardcoded*/
+ if (script_byte_vars.quest_item_ofs >= 5 * 5)
script_byte_vars.quest_item_ofs = 1 * 5;
pers_ptr = &pers_list[script_byte_vars.quest_item_ofs / 5];
- if(pers_ptr->flags & PERSFLG_40)
+ if (pers_ptr->flags & PERSFLG_40)
return;
oldr = script_byte_vars.rand_value;
newr = Rand();
flags = 0;
- if(script_byte_vars.zone_area < 6)
- {
- if(oldr < 90)
- {
+ if (script_byte_vars.zone_area < 6) {
+ if (oldr < 90) {
/*TODO: merge/simplify these ifs*/
- if(pers_ptr->item != 0)
- {
- if(pers_ptr->item >= 6 && pers_ptr->item < 27)
- {
- if(!(pers_ptr->item >= 19 && pers_ptr->item < 23))
+ if (pers_ptr->item != 0) {
+ if (pers_ptr->item >= 6 && pers_ptr->item < 27) {
+ if (!(pers_ptr->item >= 19 && pers_ptr->item < 23))
flags = 1;
}
}
}
- if(newr < 23)
- {
+ if (newr < 23) {
pers_ptr->area = script_byte_vars.zone_area;
script_word_vars.next_command1 = BE(0xA018);
script_byte_vars.check_used_commands = 3;
script_byte_vars.byte_179EF = flags;
script_vars[ScrPool8_CurrentPers] = pers_ptr;
- }
- else if(newr < 52)
- {
+ } else if (newr < 52) {
script_word_vars.next_command1 = BE(0xA019);
flags |= 4;
script_byte_vars.check_used_commands = 3;
script_byte_vars.byte_179EF = flags;
script_vars[ScrPool8_CurrentPers] = pers_ptr;
- }
- else
- {
+ } else {
script_byte_vars.byte_179EF = 0;
return;
}
- }
- else
- {
- if(oldr < 39 && pers_ptr->item)
+ } else {
+ if (oldr < 39 && pers_ptr->item)
flags = 1;
- if(oldr >= 166)
+ if (oldr >= 166)
flags = 2;
- if(newr < 26)
- {
+ if (newr < 26) {
pers_ptr->area = script_byte_vars.zone_area;
script_word_vars.next_command1 = BE(0xA018);
script_byte_vars.check_used_commands = 3;
script_byte_vars.byte_179EF = flags;
script_vars[ScrPool8_CurrentPers] = pers_ptr;
- }
- else if(newr < 52)
- {
+ } else if (newr < 52) {
script_word_vars.next_command1 = BE(0xA019);
flags |= 4;
script_byte_vars.check_used_commands = 3;
script_byte_vars.byte_179EF = flags;
script_vars[ScrPool8_CurrentPers] = pers_ptr;
- }
- else
- {
+ } else {
script_byte_vars.byte_179EF = 0;
return;
}
@@ -1149,45 +1048,34 @@ void PrepareCommand1(void)
}
/*Vorts AI*/
-void PrepareCommand3(void)
-{
+void PrepareCommand3(void) {
spot_t *spot;
- if((script_byte_vars.zone_area != 8) || !(script_byte_vars.byte_179EC & 0x80))
- {
+ if ((script_byte_vars.zone_area != 8) || !(script_byte_vars.byte_179EC & 0x80)) {
pers_list[0].flags &= ~PERSFLG_40;
pers_list[34].flags &= ~PERSFLG_40;
pers_list[35].flags &= ~PERSFLG_40;
- for(spot = zone_spots;spot != zone_spots_end;spot++)
- {
- if((spot->flags & ~SPOTFLG_80) == (SPOTFLG_40 | SPOTFLG_10))
- {
+ for (spot = zone_spots; spot != zone_spots_end; spot++) {
+ if ((spot->flags & ~SPOTFLG_80) == (SPOTFLG_40 | SPOTFLG_10)) {
int i;
- for(i = 0;i < RECD_MAX;i++)
- {
- if(vortsanim_list[i].room == script_byte_vars.zone_room)
- {
+ for (i = 0; i < RECD_MAX; i++) {
+ if (vortsanim_list[i].room == script_byte_vars.zone_room) {
vortanims_ptr = &vortsanim_list[i];
- if(script_byte_vars.zone_area == pers_list[0].area
- || script_byte_vars.zone_area == pers_list[34].area
- || script_byte_vars.zone_area == pers_list[35].area)
- {
- next_command3 = 0xA015; /*VortLeave*/
- }
- else
- {
+ if (script_byte_vars.zone_area == pers_list[0].area
+ || script_byte_vars.zone_area == pers_list[34].area
+ || script_byte_vars.zone_area == pers_list[35].area) {
+ next_command3 = 0xA015; /*VortLeave*/
+ } else {
pers_list[0].area = 0;
pers_list[34].area = 0;
pers_list[35].area = 0;
- script_byte_vars.byte_179EC &= 0x80; /*TODO: is this correct? |= ?*/
- if(script_byte_vars.rand_value < 39)
- {
+ script_byte_vars.byte_179EC &= 0x80; /*TODO: is this correct? |= ?*/
+ if (script_byte_vars.rand_value < 39) {
pers_list[0].area = script_byte_vars.zone_area;
- next_command3 = 0xA015; /*VortLeave*/
- }
- else if(script_byte_vars.rand_value < 78)
- next_command3 = 0xA014; /*VortAppear*/
+ next_command3 = 0xA015; /*VortLeave*/
+ } else if (script_byte_vars.rand_value < 78)
+ next_command3 = 0xA014; /*VortAppear*/
else
return;
}
@@ -1203,48 +1091,36 @@ void PrepareCommand3(void)
pers_list[0].area = 0;
pers_list[34].area = 0;
pers_list[35].area = 0;
- script_byte_vars.byte_179EC &= 0x80; /*TODO: is this correct? |= ?*/
+ script_byte_vars.byte_179EC &= 0x80; /*TODO: is this correct? |= ?*/
}
-void PrepareCommand4(void)
-{
+void PrepareCommand4(void) {
spot_t *spot;
- if(script_byte_vars.zone_area == 59 && script_byte_vars.byte_17A04 == 0)
- {
+ if (script_byte_vars.zone_area == 59 && script_byte_vars.byte_17A04 == 0) {
pers_list[5].area = 59;
return;
}
pers_list[5].flags &= ~PERSFLG_40;
- for(spot = zone_spots;spot != zone_spots_end;spot++)
- {
- if((spot->flags & ~SPOTFLG_80) == (SPOTFLG_40 | SPOTFLG_10 | SPOTFLG_1))
- {
+ for (spot = zone_spots; spot != zone_spots_end; spot++) {
+ if ((spot->flags & ~SPOTFLG_80) == (SPOTFLG_40 | SPOTFLG_10 | SPOTFLG_1)) {
int i;
- for(i = 0;i < RECS7_MAX;i++)
- {
- if(recs7_list[i].room == script_byte_vars.zone_room)
- {
+ for (i = 0; i < RECS7_MAX; i++) {
+ if (recs7_list[i].room == script_byte_vars.zone_room) {
rec7_ptr = &recs7_list[i];
- if(script_byte_vars.zone_area == pers_list[5].area)
- {
+ if (script_byte_vars.zone_area == pers_list[5].area) {
next_command4 = 0xA01F;
SetDelay5();
- }
- else
- {
+ } else {
pers_list[5].area = 0;
- if(script_byte_vars.rand_value >= 217)
- {
+ if (script_byte_vars.rand_value >= 217) {
pers_list[5].area = script_byte_vars.zone_area;
next_command4 = 0xA01F;
SetDelay5();
- }
- else if(script_byte_vars.rand_value >= 178)
- {
+ } else if (script_byte_vars.rand_value >= 178) {
next_command4 = 0xA01E;
SetDelay5();
}
@@ -1261,19 +1137,16 @@ 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 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);
*w = spr[0];
*h = spr[1];
*ofs = CGA_CalcXY_p(x, y);
- return 0; /*sprite offset in scratch buf*/
+ return 0; /*sprite offset in scratch buf*/
}
-void BackupScreenOfSpecialRoom(void)
-{
- switch(script_byte_vars.zone_room)
- {
+void BackupScreenOfSpecialRoom(void) {
+ switch (script_byte_vars.zone_room) {
case 41:
case 22:
case 23:
@@ -1283,10 +1156,8 @@ void BackupScreenOfSpecialRoom(void)
}
}
-void RestoreScreenOfSpecialRoom(void)
-{
- switch(script_byte_vars.zone_room)
- {
+void RestoreScreenOfSpecialRoom(void) {
+ switch (script_byte_vars.zone_room) {
case 23:
case 24:
RedrawRoomStatics(script_byte_vars.zone_room, 0);
@@ -1296,17 +1167,15 @@ void RestoreScreenOfSpecialRoom(void)
unsigned char byte_17A1C = 0;
-void SetAnim127Sprite(unsigned char flags, unsigned char spridx)
-{
+void SetAnim127Sprite(unsigned char flags, unsigned char spridx) {
unsigned char *lutin_entry, *lutin_entry_end;
lutin_entry = SeekToEntry(lutin_data, 127, &lutin_entry_end);
lutin_entry[2] = spridx;
- switch(spridx)
- {
+ switch (spridx) {
case 37:
case 58:
case 40:
- if(flags == ITEMFLG_80)
+ if (flags == ITEMFLG_80)
byte_17A1C += 1;
else
byte_17A1C -= 1;
@@ -1314,27 +1183,24 @@ void SetAnim127Sprite(unsigned char flags, unsigned char spridx)
}
}
-void BounceCurrentItem(unsigned char flags, unsigned char y)
-{
- item_t *item = (item_t*)(script_vars[ScrPool3_CurrentItem]);
+void BounceCurrentItem(unsigned char flags, unsigned char y) {
+ item_t *item = (item_t *)(script_vars[ScrPool3_CurrentItem]);
SetAnim127Sprite(flags, item->sprite);
item->flags = flags;
item->flags2 = script_byte_vars.zone_area;
BackupScreenOfSpecialRoom();
- PlayAnim(41, 176/4, y);
+ PlayAnim(41, 176 / 4, y);
DrawRoomItemsIndicator();
RestoreScreenOfSpecialRoom();
}
-unsigned char * LoadMursmSprite(unsigned char index)
-{
+unsigned char *LoadMursmSprite(unsigned char index) {
unsigned char *pinfo, *end;
pinfo = SeekToEntry(mursm_data, index, &end);
- while(pinfo != end)
- {
+ while (pinfo != end) {
unsigned int flags;
signed int pitch;
unsigned char *buffer, *sprite;
@@ -1350,7 +1216,7 @@ unsigned char * LoadMursmSprite(unsigned char index)
sprw = *sprite++;
sprh = *sprite++;
- if(index & 0x80) /*horizontal flip*/
+ if (index & 0x80) /*horizontal flip*/
MergeImageAndSpriteDataFlip(buffer, pitch, sprite, sprw, sprh);
else
MergeImageAndSpriteData(buffer, pitch, sprite, sprw, sprh);
@@ -1366,83 +1232,71 @@ unsigned char * LoadMursmSprite(unsigned char index)
}
typedef struct thewall_t {
-unsigned char height;
-unsigned char width;
-unsigned int pitch;
-unsigned int offs;
-unsigned char *pixels;
+ unsigned char height;
+ unsigned char width;
+ unsigned int pitch;
+ unsigned int offs;
+ unsigned char *pixels;
} thewall_t;
thewall_t the_wall_wall_b, the_wall_wall_a;
unsigned int cur_image_width_full;
-void TheWallOpenRightDoor(unsigned char x, unsigned char y, unsigned char w, unsigned char h)
-{
+void TheWallOpenRightDoor(unsigned char x, unsigned char y, unsigned char w, unsigned char h) {
unsigned int ofs = CGA_CalcXY_p(x + w - 2, y);
unsigned char n = w - 1;
- while(n)
- {
+ while (n) {
CGA_HideScreenBlockLiftToRight(1, frontbuffer, backbuffer, n, h, frontbuffer, ofs);
n--;
- if(n == cur_image_width_full)
- {
+ if (n == cur_image_width_full) {
/*ret n and ofs*/
return;
}
}
ofs += 1;
-
+
}
-void DrawWallA(unsigned int n, unsigned int limit, unsigned int w, unsigned char h, unsigned int ofs)
-{
- do
- {
+void DrawWallA(unsigned int n, unsigned int limit, unsigned int w, unsigned char h, unsigned int ofs) {
+ do {
CGA_HideScreenBlockLiftToRight(1, frontbuffer, backbuffer, w, h, frontbuffer, ofs);
w--;
- if(n == limit)
+ if (n == limit)
return;
- }
- while(n--);
+ } while (n--);
ofs += 1;
- while(h--)
- {
+ while (h--) {
memcpy(frontbuffer + ofs, backbuffer + ofs, 1);
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
}
-void DrawWallB(unsigned int n, unsigned int limit, unsigned int w, unsigned char h, unsigned int ofs)
-{
- do
- {
+void DrawWallB(unsigned int n, unsigned int limit, unsigned int w, unsigned char h, unsigned int ofs) {
+ do {
CGA_HideScreenBlockLiftToLeft(1, frontbuffer, backbuffer, w, h, frontbuffer, ofs);
w--;
- if(n == limit)
+ if (n == limit)
return;
- }
- while(n--);
+ } while (n--);
ofs -= 1;
- while(h--)
- {
+ while (h--) {
memcpy(frontbuffer + ofs, backbuffer + ofs, 1);
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
}
-void TheWallPhase3(void)
-{
+void TheWallPhase3(void) {
script_byte_vars.zone_index = (script_byte_vars.zone_index == 95) ? 9 : 102;
LoadZone();
@@ -1453,13 +1307,12 @@ void TheWallPhase3(void)
/*TODO*/
}
-void TheWallPhase0(void)
-{
+void TheWallPhase0(void) {
script_byte_vars.zone_index = (script_byte_vars.zone_index == 9) ? 24 : 30;
LoadZone();
/*TODO*/
- /*
+ /*
DrawWallA(unsigned int n, 0, unsigned int w, unsigned char h, unsigned int ofs);
DrawWallB(unsigned int n, 0, unsigned int w, unsigned char h, unsigned int ofs);
*/
@@ -1467,8 +1320,7 @@ void TheWallPhase0(void)
}
/*Opened -> Half closed*/
-void TheWallPhase1_DoorClose1(void)
-{
+void TheWallPhase1_DoorClose1(void) {
unsigned char *spr;
script_byte_vars.zone_index = (script_byte_vars.zone_index == 24) ? 9 : 102;
@@ -1485,8 +1337,7 @@ void TheWallPhase1_DoorClose1(void)
}
/*Half closed -> Fully closed*/
-void TheWallPhase2_DoorClose2(void)
-{
+void TheWallPhase2_DoorClose2(void) {
unsigned char *spr;
script_byte_vars.zone_index = (script_byte_vars.zone_index == 9) ? 95 : 103;
@@ -1502,19 +1353,17 @@ void TheWallPhase2_DoorClose2(void)
CGA_AnimLiftToLeft(10, spr, cur_frame_width, 1 + 10, cur_image_size_h, frontbuffer, CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y) - 10);
}
-void DrawTheWallDoors(void)
-{
- switch(script_byte_vars.zone_index)
- {
+void DrawTheWallDoors(void) {
+ switch (script_byte_vars.zone_index) {
case 9:
case 102:
- CGA_Blit(LoadMursmSprite(0) + 10, 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(64/CGA_PIXELS_PER_BYTE, 32));
- CGA_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(180/CGA_PIXELS_PER_BYTE, 32));
+ CGA_Blit(LoadMursmSprite(0) + 10, 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(64 / CGA_PIXELS_PER_BYTE, 32));
+ CGA_Blit(LoadMursmSprite(1), 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(180 / CGA_PIXELS_PER_BYTE, 32));
break;
case 95:
case 103:
- CGA_Blit(LoadMursmSprite(0), 20, 20, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(64/CGA_PIXELS_PER_BYTE, 32));
- CGA_Blit(LoadMursmSprite(1), 20, 20, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(144/CGA_PIXELS_PER_BYTE, 32));
+ CGA_Blit(LoadMursmSprite(0), 20, 20, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(64 / CGA_PIXELS_PER_BYTE, 32));
+ CGA_Blit(LoadMursmSprite(1), 20, 20, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(144 / CGA_PIXELS_PER_BYTE, 32));
break;
}
}
@@ -1522,13 +1371,10 @@ 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)
-{
+void MergeSpritesData(unsigned char *target, unsigned int pitch, unsigned char *source, unsigned int w, unsigned int h) {
unsigned int x;
- while(h--)
- {
- for(x = 0;x < w;x++)
- {
+ while (h--) {
+ for (x = 0; x < w; x++) {
unsigned char m = *source++;
*target++ &= m;
*target &= m;
@@ -1542,14 +1388,11 @@ 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)
-{
+void MergeSpritesDataFlip(unsigned char *target, unsigned int pitch, unsigned char *source, unsigned int w, unsigned int h) {
unsigned int x;
target += w * 2 - 2;
- while(h--)
- {
- for(x = 0;x < w;x++)
- {
+ while (h--) {
+ for (x = 0; x < w; x++) {
unsigned char m = cga_pixel_flip[*source++];
*target++ &= m;
*target &= m;
@@ -1561,47 +1404,39 @@ void MergeSpritesDataFlip(unsigned char *target, unsigned int pitch, unsigned ch
}
}
-unsigned char * BackupSpotImage(spot_t *spot, unsigned char **spotback, unsigned char *buffer)
-{
+unsigned char *BackupSpotImage(spot_t *spot, unsigned char **spotback, unsigned char *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;
}
-void BackupSpotsImages(void)
-{
+void BackupSpotsImages(void) {
spot_t *spot = zone_spots;
unsigned char *buffer = scratch_mem1;
int i;
- for(i = 0;i < MAX_SPRITES;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 i if spot is skipped?*/
- {
- if(spot->flags & SPOTFLG_40)
+ for (i = 0; spot != zone_spots_end; spot++, i++) { /*TODO: maybe don't advance i if spot is skipped?*/
+ if (spot->flags & SPOTFLG_40)
buffer = BackupSpotImage(spot, &sprites_list[i], buffer);
}
}
-void DrawSpots(unsigned char *target)
-{
+void DrawSpots(unsigned char *target) {
spot_t *spot = zone_spots_cur;
unsigned char spridx = zone_spr_index;
- if(spot == zone_spots_end)
- {
+ if (spot == zone_spots_end) {
spot = zone_spots;
spridx = 0;
}
- do
- {
+ do {
spridx++;
- if((spot->flags & SPOTFLG_40) && ((spot->flags & ~7) == (SPOTFLG_80 | SPOTFLG_40 | SPOTFLG_10)))
- {
+ if ((spot->flags & SPOTFLG_40) && ((spot->flags & ~7) == (SPOTFLG_80 | SPOTFLG_40 | SPOTFLG_10))) {
zone_spots_cur = spot + 1;
zone_spr_index = spridx;
/*TODO: subclass spot_t from rect_t*/
- if(DrawZoneAniSprite((rect_t*)spot, (spot - zone_spots) + 1, backbuffer))
- {
+ if (DrawZoneAniSprite((rect_t *)spot, (spot - zone_spots) + 1, backbuffer)) {
UpdateCursor();
WaitVBlank();
UndrawCursor(target);
@@ -1610,34 +1445,29 @@ void DrawSpots(unsigned char *target)
CGA_RestoreImage(sprites_list[zone_spr_index - 1], backbuffer);
return;
}
- spridx = zone_spr_index; /*TODO: not neded?*/
+ spridx = zone_spr_index; /*TODO: not neded?*/
}
spot++;
- }
- while(spot != zone_spots_end);
+ } while (spot != zone_spots_end);
zone_spots_cur = spot;
zone_spr_index = spridx;
}
-void AnimateSpots(unsigned char *target)
-{
- if(script_byte_vars.timer_ticks % 32 == 31)
+void AnimateSpots(unsigned char *target) {
+ if (script_byte_vars.timer_ticks % 32 == 31)
DrawSpots(target);
}
-void DrawHintsAndCursor(unsigned char *target)
-{
+void DrawHintsAndCursor(unsigned char *target) {
UpdateCursor();
WaitVBlank();
UndrawCursor(target);
- if(object_hint != last_object_hint)
- {
+ if (object_hint != last_object_hint) {
ShowObjectHint(target);
last_object_hint = object_hint;
}
- if(command_hint != last_command_hint)
- {
+ if (command_hint != last_command_hint) {
ShowCommandHint(target);
last_command_hint = command_hint;
}
@@ -1645,8 +1475,7 @@ void DrawHintsAndCursor(unsigned char *target)
DrawCursor(target);
}
-void HideSpot(unsigned char offset)
-{
+void HideSpot(unsigned char offset) {
FindAndSelectSpot(offset);
found_spot->flags &= ~SPOTFLG_80;
}
@@ -1655,87 +1484,78 @@ static const unsigned char timed_seq[] = {56, 51, 44, 12, 10, 20, 18, 16, 14, 12
static const unsigned char *timed_seq_ptr = timed_seq;
/*TODO: rename this*/
-void UpdateTimedRects1(void)
-{
+void UpdateTimedRects1(void) {
unsigned int elapsed;
- if(script_byte_vars.flag_179FB != 0)
+ if (script_byte_vars.flag_179FB != 0)
return;
- if(script_byte_vars.byte_179DC >= 63)
+ if (script_byte_vars.byte_179DC >= 63)
return;
script_word_vars.next_command2 = BE(0);
- if(pers_list[13].flags & PERSFLG_40)
- {
+ if (pers_list[13].flags & PERSFLG_40) {
pers_list[13].area = 56;
pers_list[13].flags &= ~(PERSFLG_10 | PERSFLG_20 | PERSFLG_40 | PERSFLG_80);
pers_list[13].index = 52;
}
-
- if(pers_list[22].flags & PERSFLG_20)
+
+ if (pers_list[22].flags & PERSFLG_20)
script_byte_vars.byte_179E6 |= 4;
elapsed = Swap16(script_word_vars.timer_ticks2);
- if(elapsed < next_ticks2)
+ if (elapsed < next_ticks2)
return;
next_ticks2 = elapsed + 30;
script_byte_vars.byte_179F5 = *timed_seq_ptr++;
- if(timed_seq_ptr == timed_seq + sizeof(timed_seq))
+ if (timed_seq_ptr == timed_seq + sizeof(timed_seq))
timed_seq_ptr = timed_seq;
script_byte_vars.byte_179F6 = *timed_seq_ptr++;
- if(script_byte_vars.byte_179F5 == 56)
- {
+ if (script_byte_vars.byte_179F5 == 56) {
script_byte_vars.byte_179E6 &= ~4;
pers_list[22].flags &= ~(PERSFLG_20 | PERSFLG_40 | PERSFLG_80);
pers_list[22].index = 55;
- if(pers_list[13].area == 56)
- {
+ if (pers_list[13].area == 56) {
pers_list[13].flags &= ~(PERSFLG_20 | PERSFLG_40 | PERSFLG_80);
script_byte_vars.byte_179F7 = 1;
}
}
- if(script_byte_vars.byte_179F5 == 12 && script_byte_vars.byte_179F6 == 10)
- {
+ if (script_byte_vars.byte_179F5 == 12 && script_byte_vars.byte_179F6 == 10) {
script_byte_vars.byte_179F7 = 0;
- if(pers_list[13].area == 56)
- {
+ if (pers_list[13].area == 56) {
script_byte_vars.byte_179F6 = 44;
timed_seq_ptr = timed_seq + 4;
}
-
+
}
pers_list[22].area = script_byte_vars.byte_179F6;
- if(script_byte_vars.byte_179F7 != 0)
- {
+ if (script_byte_vars.byte_179F7 != 0) {
pers_list[13].area = script_byte_vars.byte_179F6;
pers_list[20].area = script_byte_vars.byte_179F6;
pers_list[21].area = script_byte_vars.byte_179F6;
- if(script_byte_vars.zone_area == script_byte_vars.byte_179F5)
- {
+ if (script_byte_vars.zone_area == script_byte_vars.byte_179F5) {
static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
- HideSpot(22 * 5); /*dirct rec offset*/
- HideSpot(13 * 5); /*dirct rec offset*/
- HideSpot(20 * 5); /*dirct rec offset*/
- HideSpot(21 * 5); /*dirct rec offset*/
+ HideSpot(22 * 5); /*dirct rec offset*/
+ HideSpot(13 * 5); /*dirct rec offset*/
+ HideSpot(20 * 5); /*dirct rec offset*/
+ HideSpot(21 * 5); /*dirct rec offset*/
AnimateSpot(&anim35);
BlitSpritesToBackBuffer();
DrawCursor(frontbuffer);
return;
}
- if(script_byte_vars.zone_area == script_byte_vars.byte_179F6)
- {
+ if (script_byte_vars.zone_area == script_byte_vars.byte_179F6) {
static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
@@ -1743,8 +1563,7 @@ void UpdateTimedRects1(void)
FindAndSelectSpot(22 * 5);
AnimateSpot(&anim34);
- if(FindAndSelectSpot(20 * 5))
- {
+ if (FindAndSelectSpot(20 * 5)) {
AnimateSpot(&anim34);
FindAndSelectSpot(13 * 5);
@@ -1759,36 +1578,32 @@ void UpdateTimedRects1(void)
BlitSpritesToBackBuffer();
DrawCursor(frontbuffer);
- if(script_byte_vars.room_items != 0)
+ if (script_byte_vars.room_items != 0)
script_word_vars.next_command2 = BE(0xC1FD);
- else if(pers_list[22].flags & 0x20)
+ else if (pers_list[22].flags & 0x20)
script_word_vars.next_command2 = BE(0xC1E5);
- else if(script_byte_vars.zone_area == 44)
+ else if (script_byte_vars.zone_area == 44)
script_word_vars.next_command2 = BE(0xC060);
return;
}
- }
- else
- {
- if(pers_list[22].flags & 0x40)
+ } else {
+ if (pers_list[22].flags & 0x40)
return;
- if(script_byte_vars.zone_area == script_byte_vars.byte_179F5)
- {
+ if (script_byte_vars.zone_area == script_byte_vars.byte_179F5) {
static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
- HideSpot(22 * 5); /*dirct rec offset*/
+ HideSpot(22 * 5); /*dirct rec offset*/
AnimateSpot(&anim35);
BlitSpritesToBackBuffer();
DrawCursor(frontbuffer);
return;
}
- if(script_byte_vars.zone_area == script_byte_vars.byte_179F6)
- {
+ if (script_byte_vars.zone_area == script_byte_vars.byte_179F6) {
static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
@@ -1807,15 +1622,13 @@ void UpdateTimedRects1(void)
}
/*TODO: rename this*/
-void UpdateTimedRects2(void)
-{
+void UpdateTimedRects2(void) {
unsigned int elapsed = Swap16(script_word_vars.timer_ticks2);
- if(elapsed < 60 * 60)
+ if (elapsed < 60 * 60)
return;
- if(script_byte_vars.byte_179DC < 63)
- {
+ if (script_byte_vars.byte_179DC < 63) {
script_byte_vars.byte_179ED = 3;
script_byte_vars.byte_179DC = (script_byte_vars.zone_area < 44) ? 255 : 63;
pers_list[13].area = 0;
@@ -1827,20 +1640,19 @@ void UpdateTimedRects2(void)
pers_list[20].area = 56;
pers_list[21].area = 56;
pers_list[22].area = 56;
- if(script_byte_vars.zone_area < 22)
+ if (script_byte_vars.zone_area < 22)
script_word_vars.next_command2 = BE(0xC012);
return;
}
- if(elapsed < 105 * 60)
+ if (elapsed < 105 * 60)
return;
- if(elapsed < 120 * 60)
- {
+ if (elapsed < 120 * 60) {
script_byte_vars.byte_179ED = 2;
- script_byte_vars.byte_17A04 = 1;
- if((script_byte_vars.zone_area != 61)
- && (script_byte_vars.zone_area >= 59 && script_byte_vars.zone_area < 75))
+ script_byte_vars.byte_17A04 = 1;
+ if ((script_byte_vars.zone_area != 61)
+ && (script_byte_vars.zone_area >= 59 && script_byte_vars.zone_area < 75))
script_word_vars.next_command2 = BE(0xC012);
return;
}
@@ -1848,27 +1660,23 @@ void UpdateTimedRects2(void)
script_word_vars.next_command2 = BE(0xC318);
}
-void UpdateTimedInventoryItems(void)
-{
+void UpdateTimedInventoryItems(void) {
int i;
- if(Swap16(script_word_vars.timer_ticks2) - inv_update_time < 180)
+ if (Swap16(script_word_vars.timer_ticks2) - inv_update_time < 180)
return;
inv_update_time = Swap16(script_word_vars.timer_ticks2);
- for(i = 0;i < MAX_INV_ITEMS;i++)
- {
- if(inventory_items[i].flags & ITEMFLG_40)
- {
- if(inventory_items[i].flags2 != script_byte_vars.zone_area && inventory_items[i].flags2 < 52)
+ for (i = 0; i < MAX_INV_ITEMS; i++) {
+ if (inventory_items[i].flags & ITEMFLG_40) {
+ if (inventory_items[i].flags2 != script_byte_vars.zone_area && inventory_items[i].flags2 < 52)
inventory_items[i].flags &= ~ITEMFLG_40;
}
}
}
-void ResetAllPersons(void)
-{
+void ResetAllPersons(void) {
int i;
- for(i = 0;i < PERS_MAX;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 7d8882f90e7..2b833bdcd08 100644
--- a/engines/chamber/room.h
+++ b/engines/chamber/room.h
@@ -33,11 +33,11 @@ typedef struct spot_t {
/*person*/
/*TODO: manipulated from script, do not change*/
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)*/
+ 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)*/
} pers_t;
#if sizeof(pers_t) != 5
@@ -47,13 +47,13 @@ typedef struct pers_t {
#define ANIMFLG_USESPOT 0x80
typedef struct animdesc_t {
-unsigned char index; /*flag in bit 7, animation index in bits 6..0*/
-union {
- struct {
- unsigned char x, y;
- } coords;
- unsigned short desc;
-} params;
+ unsigned char index; /*flag in bit 7, animation index in bits 6..0*/
+ union {
+ struct {
+ unsigned char x, y;
+ } coords;
+ unsigned short desc;
+ } params;
} animdesc_t;
typedef struct vortanims_t {
@@ -118,7 +118,7 @@ void SelectSpotCursor(void);
void CheckHotspots(unsigned char m, unsigned char v);
void AnimateSpot(const animdesc_t *info);
-unsigned char * LoadPuzzlToScratch(unsigned char index);
+unsigned char *LoadPuzzlToScratch(unsigned char index);
void DrawObjectHint(void);
void ShowObjectHint(unsigned char *target);
@@ -170,7 +170,7 @@ void TheWallPhase3(void);
void TheWallPhase0(void);
void TheWallPhase1_DoorClose1(void);
void TheWallPhase2_DoorClose2(void);
-
+
void PrepareCommand1(void);
void PrepareCommand3(void);
void PrepareCommand4(void);
diff --git a/engines/chamber/savegame.cpp b/engines/chamber/savegame.cpp
index 6c6c4beba30..8eb9966da39 100644
--- a/engines/chamber/savegame.cpp
+++ b/engines/chamber/savegame.cpp
@@ -7,16 +7,14 @@
#include "cga.h"
#include "room.h"
-void SaveRestartGame(void)
-{
+void SaveRestartGame(void) {
/*TODO*/
}
-void RestartGame(void)
-{
+void RestartGame(void) {
/*
while(!LoadFile("CLEAR.BIN", save_start))
- AskDisk2();
+ AskDisk2();
*/
script_byte_vars.cur_spot_flags = 0xFF;
@@ -36,8 +34,7 @@ void RestartGame(void)
#define CGA_SAVE_PERS_OFS 0x7765
#define CGA_SAVE_STACK_OFS 0x7562
-int LoadScena(void)
-{
+int LoadScena(void) {
int f;
int rlen;
@@ -45,16 +42,15 @@ int LoadScena(void)
f = open("SCENAx.BIN", O_RDONLY | O_BINARY);
- if(f == -1)
- {
+ if (f == -1) {
script_byte_vars.game_paused = 0;
- return 1; /*error*/
+ return 1; /*error*/
}
/*
Save format:
vars memory (751E-9D5D)
frontbuffer (0x3FFF bytes)
- backbuffer (0x3FFF bytes)
+ backbuffer (0x3FFF bytes)
*/
@@ -64,14 +60,14 @@ int LoadScena(void)
rlen = read(f, backbuffer, 0x3FFF);
- if(rlen != 0x3FFF)
+ if (rlen != 0x3FFF)
goto error;
CGA_BackBufferToRealFull();
SelectPalette();
rlen = read(f, backbuffer, 0x3FFF);
- if(rlen != 0x3FFF)
+ if (rlen != 0x3FFF)
goto error;
/*re-initialize sprites list*/
@@ -81,17 +77,17 @@ int LoadScena(void)
script_byte_vars.game_paused = 0;
return 0;
-error:;
+error:
+ ;
close(f);
script_byte_vars.game_paused = 0;
return 1;
}
-#define SAVEADDR(value, base, nativesize, origsize, origbase) \
+#define SAVEADDR(value, base, nativesize, origsize, origbase) \
LE16(((((unsigned char*)(value)) - (unsigned char*)(base)) / nativesize) * origsize + origbase)
-int SaveScena(void)
-{
+int SaveScena(void) {
int f;
int wlen;
unsigned short ofs16;
@@ -100,38 +96,46 @@ int SaveScena(void)
BlitSpritesToBackBuffer();
f = open("SCENAx.BIN", O_CREAT | O_WRONLY | O_BINARY);
- if(f == -1)
- {
+ if (f == -1) {
script_byte_vars.game_paused = 0;
- return 1; /*error*/
+ return 1; /*error*/
}
ofs16 = SAVEADDR(script_vars[ScrPool0_WordVars0], &script_word_vars, 2, 2, CGA_SAVE_WORD_VARS_OFS);
- wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+ wlen = write(f, &ofs16, 2);
+ if (wlen != 2) goto error;
ofs16 = SAVEADDR(script_vars[ScrPool1_WordVars1], &script_word_vars, 2, 2, CGA_SAVE_WORD_VARS_OFS);
- wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+ wlen = write(f, &ofs16, 2);
+ if (wlen != 2) goto error;
ofs16 = SAVEADDR(script_vars[ScrPool2_ByteVars], &script_byte_vars, 1, 1, CGA_SAVE_BYTE_VARS_OFS);
- wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+ wlen = write(f, &ofs16, 2);
+ if (wlen != 2) goto error;
ofs16 = SAVEADDR(script_vars[ScrPool3_CurrentItem], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
- wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+ wlen = write(f, &ofs16, 2);
+ if (wlen != 2) goto error;
ofs16 = SAVEADDR(script_vars[ScrPool4_ZoneSpots], zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
- wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+ wlen = write(f, &ofs16, 2);
+ if (wlen != 2) goto error;
ofs16 = SAVEADDR(script_vars[ScrPool5_Persons], pers_list, 1, 1, CGA_SAVE_PERS_OFS);
- wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+ wlen = write(f, &ofs16, 2);
+ if (wlen != 2) goto error;
ofs16 = SAVEADDR(script_vars[ScrPool6_Inventory], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
- wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+ wlen = write(f, &ofs16, 2);
+ if (wlen != 2) goto error;
ofs16 = SAVEADDR(script_vars[ScrPool7_Inventory38], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
- wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+ wlen = write(f, &ofs16, 2);
+ if (wlen != 2) goto error;
ofs16 = SAVEADDR(script_vars[ScrPool8_CurrentPers], pers_list, 1, 1, CGA_SAVE_PERS_OFS);
- wlen = write(f, &ofs16, 2); if(wlen != 2) goto error;
+ wlen = write(f, &ofs16, 2);
+ if (wlen != 2) goto error;
/*TODO*/
@@ -140,18 +144,19 @@ int SaveScena(void)
wlen = write(f, frontbuffer, 0x3FFF);
- if(wlen != 0x3FFF)
+ if (wlen != 0x3FFF)
goto error;
wlen = write(f, backbuffer, 0x3FFF);
- if(wlen != 0x3FFF)
+ if (wlen != 0x3FFF)
goto error;
close(f);
script_byte_vars.game_paused = 0;
return 0;
-error:;
+error:
+ ;
close(f);
script_byte_vars.game_paused = 0;
return 1;
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 11ac73b5a49..b29599457d6 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -42,59 +42,51 @@ void *script_vars[ScrPools_MAX] = {
pers_list
};
-unsigned char Rand(void)
-{
+unsigned char Rand(void) {
script_byte_vars.rand_value = aleat_data[++rand_seed];
return script_byte_vars.rand_value;
}
-unsigned int RandW(void)
-{
+unsigned int RandW(void) {
unsigned int r = Rand() << 8;
return r | Rand();
}
-unsigned int Swap16(unsigned int x)
-{
+unsigned int Swap16(unsigned int x) {
return (x << 8) | (x >> 8);
}
/*Script handlers exit codes*/
enum CommandStatus {
- ScriptContinue = 0, /*run next script command normally*/
+ ScriptContinue = 0, /*run next script command normally*/
ScriptRerun = 1, /*abort current script, execute new command*/
/*TODO: maybe define ScriptRestartGame to support game restart?*/
};
-unsigned int CMD_TRAP(void)
-{
+unsigned int CMD_TRAP(void) {
printf("CMD TRAP\n");
PromptWait();
- for(;;) ;
+ for (;;) ;
return 0;
}
-unsigned int SCR_TRAP(void)
-{
+unsigned int SCR_TRAP(void) {
printf("SCR TRAP 0x%02X @ 0x%X\n", *script_ptr, script_ptr - templ_data);
PromptWait();
- for(;;) ;
+ for (;;) ;
return 0;
}
-void ClaimTradedItems(void)
-{
+void ClaimTradedItems(void) {
int i;
- for(i = 0;i < MAX_INV_ITEMS;i++)
- {
- if(inventory_items[i].flags == (ITEMFLG_80 | 1))
+ 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 int SCR_1_AspirantItemTrade(void) {
unsigned char *old_script, *old_script_end = script_end_ptr;
item_t *item1, *item2;
@@ -102,20 +94,17 @@ unsigned int SCR_1_AspirantItemTrade(void)
script_ptr++;
old_script = script_ptr;
- for(;;)
- {
+ for (;;) {
inv_bgcolor = 0xFF;
OpenInventory(0xFE, ITEMFLG_80);
- if(inv_count == 0)
- {
+ if (inv_count == 0) {
the_command = 0xC1BC;
RunCommand();
break;
}
- if(the_command == 0)
- {
+ if (the_command == 0) {
the_command = 0xC1C0;
RunCommand();
break;
@@ -123,29 +112,26 @@ unsigned int SCR_1_AspirantItemTrade(void)
the_command = 0x9140;
- if(pers_ptr->item == 0)
+ if (pers_ptr->item == 0)
break;
item1 = &inventory_items[pers_ptr->item - 1];
- item2 = (item_t*)(script_vars[ScrPool3_CurrentItem]);
+ item2 = (item_t *)(script_vars[ScrPool3_CurrentItem]);
- if(item2->flags == (ITEMFLG_80 | 1) || item1->name == item2->name)
- {
+ if (item2->flags == (ITEMFLG_80 | 1) || item1->name == item2->name) {
the_command = 0xC1C0;
RunCommand();
break;
}
- if(item2->name == 109
- || item2->name == 132
- || item2->name == 108
- || script_byte_vars.rand_value < 154)
- {
+ if (item2->name == 109
+ || item2->name == 132
+ || item2->name == 108
+ || script_byte_vars.rand_value < 154) {
item2->flags = ITEMFLG_20;
item1->flags = ITEMFLG_80;
pers_ptr->item = script_byte_vars.inv_item_index;
- switch(item2->name)
- {
+ switch (item2->name) {
case 132:
script_byte_vars.room_items--;
the_command = 0xC04B;
@@ -161,9 +147,7 @@ unsigned int SCR_1_AspirantItemTrade(void)
}
RunCommand();
break;
- }
- else
- {
+ } else {
item2->flags = ITEMFLG_80 | 1;
the_command = 0xC1BD;
RunCommand();
@@ -182,48 +166,43 @@ unsigned int SCR_1_AspirantItemTrade(void)
unsigned char wait_delta = 0;
-void Wait(unsigned char seconds)
-{
+void Wait(unsigned char seconds) {
struct time t;
unsigned int endtime;
seconds += wait_delta;
- if(seconds > 127) /*TODO: is this a check for an unsigned value?*/
+ if (seconds > 127) /*TODO: is this a check for an unsigned value?*/
seconds = 0;
gettime(&t);
endtime = t.ti_sec * 100 + t.ti_hund + seconds * 100;
- while(buttons == 0)
- {
+ while (buttons == 0) {
unsigned int current;
gettime(&t);
current = t.ti_sec * 100 + t.ti_hund;
- if(endtime >= 6000 && current < 2048) /*TODO: some kind of overflow check???*/
+ if (endtime >= 6000 && current < 2048) /*TODO: some kind of overflow check???*/
current += 6000;
- if(current >= endtime)
+ if (current >= endtime)
break;
}
}
-unsigned int SCR_2C_Wait4(void)
-{
+unsigned int SCR_2C_Wait4(void) {
script_ptr++;
Wait(4);
return 0;
}
-unsigned int SCR_2D_Wait(void)
-{
+unsigned int SCR_2D_Wait(void) {
unsigned char seconds;
script_ptr++;
seconds = *script_ptr++;
- Wait(4); /*TODO: looks like a bug?*/
+ Wait(4); /*TODO: looks like a bug?*/
return 0;
}
-unsigned int SCR_2E_PromptWait(void)
-{
+unsigned int SCR_2E_PromptWait(void) {
script_ptr++;
PromptWait();
return 0;
@@ -240,20 +219,17 @@ unsigned int SCR_2E_PromptWait(void)
unsigned char var_size;
-unsigned short LoadVar(unsigned char **ptr, unsigned char **varptr)
-{
+unsigned short LoadVar(unsigned char **ptr, unsigned char **varptr) {
unsigned char vartype;
unsigned char *varbase;
unsigned short value = 0;
var_size = VARSIZE_BYTE;
vartype = *((*ptr)++);
- if(vartype & VARTYPE_VAR)
- {
+ if (vartype & VARTYPE_VAR) {
/*variable*/
unsigned char varoffs;
- varbase = (unsigned char*)script_vars[vartype & VARTYPE_KIND];
- if(vartype & VARTYPE_BLOCK)
- {
+ varbase = (unsigned char *)script_vars[vartype & VARTYPE_KIND];
+ if (vartype & VARTYPE_BLOCK) {
unsigned char *end;
unsigned char index = *((*ptr)++);
varbase = SeekToEntryW(varbase, index, &end);
@@ -262,8 +238,7 @@ unsigned short LoadVar(unsigned char **ptr, unsigned char **varptr)
#if 1
{
int maxoffs = 0;
- switch(vartype & VARTYPE_KIND)
- {
+ switch (vartype & VARTYPE_KIND) {
case ScrPool0_WordVars0:
case ScrPool1_WordVars1:
maxoffs = sizeof(script_word_vars);
@@ -290,33 +265,28 @@ unsigned short LoadVar(unsigned char **ptr, unsigned char **varptr)
maxoffs = sizeof(pers_t);
break;
}
- if(varoffs >= maxoffs)
- {
+ 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);
PromptWait();
}
}
#endif
value = varbase[varoffs];
- if(vartype & VARTYPE_WORD)
- {
+ if (vartype & VARTYPE_WORD) {
value = (value << 8) | varbase[varoffs + 1];
var_size = VARSIZE_WORD;
}
*varptr = &varbase[varoffs];
#if 0
-/*TODO: debug stuff, remove me*/
- if(varoffs == 0x48)
+ /*TODO: debug stuff, remove me*/
+ if (varoffs == 0x48)
printf("Var 2.%X = %X\n", varoffs, value);
#endif
- }
- else
- {
+ } else {
/*immediate value*/
value = *((*ptr)++);
- if(vartype & VARTYPE_WORD)
- {
+ if (vartype & VARTYPE_WORD) {
value = (value << 8) | *((*ptr)++);
var_size = VARSIZE_WORD;
}
@@ -341,48 +311,42 @@ 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)
-{
- if(op & MATHOP_CMP)
- {
- if(op & MATHOP_EQ)
- if(op1 == op2) return ~0;
- if(op & MATHOP_B)
- if(op1 < op2) return ~0;
- if(op & MATHOP_A)
- if(op1 > op2) return ~0;
- if(op & MATHOP_NEQ)
- if(op1 != op2) return ~0;
- if(op & MATHOP_LE)
- if((signed short)op1 <= (signed short)op2) return ~0;
- if(op & MATHOP_GE)
- if((signed short)op1 >= (signed short)op2) return ~0;
+unsigned short MathOp(unsigned char op, unsigned short op1, unsigned short op2) {
+ if (op & MATHOP_CMP) {
+ if (op & MATHOP_EQ)
+ if (op1 == op2) return ~0;
+ if (op & MATHOP_B)
+ if (op1 < op2) return ~0;
+ if (op & MATHOP_A)
+ if (op1 > op2) return ~0;
+ if (op & MATHOP_NEQ)
+ if (op1 != op2) return ~0;
+ if (op & MATHOP_LE)
+ if ((signed short)op1 <= (signed short)op2) return ~0;
+ if (op & MATHOP_GE)
+ if ((signed short)op1 >= (signed short)op2) return ~0;
return 0;
- }
- else
- {
- if(op & MATHOP_ADD)
+ } else {
+ if (op & MATHOP_ADD)
op1 += op2;
- if(op & MATHOP_SUB)
+ if (op & MATHOP_SUB)
op1 -= op2;
- if(op & MATHOP_AND)
+ if (op & MATHOP_AND)
op1 &= op2;
- if(op & MATHOP_OR)
+ if (op & MATHOP_OR)
op1 |= op2;
- if(op & MATHOP_XOR)
+ if (op & MATHOP_XOR)
op1 ^= op2;
return op1;
}
}
-unsigned short MathExpr(unsigned char **ptr)
-{
+unsigned short MathExpr(unsigned char **ptr) {
unsigned char op;
unsigned short op1, op2;
unsigned char *opptr;
op1 = LoadVar(ptr, &opptr);
- while(((op = *((*ptr)++)) & MATHOP_END) == 0)
- {
+ while (((op = *((*ptr)++)) & MATHOP_END) == 0) {
op2 = LoadVar(ptr, &opptr);
op1 = MathOp(op, op1, op2);
}
@@ -392,8 +356,7 @@ unsigned short MathExpr(unsigned char **ptr)
/*
Math operations (assignment) on a variable
*/
-unsigned int SCR_3B_MathExpr(void)
-{
+unsigned int SCR_3B_MathExpr(void) {
unsigned short op1, op2;
unsigned char *opptr;
@@ -401,21 +364,19 @@ unsigned int SCR_3B_MathExpr(void)
op1 = LoadVar(&script_ptr, &opptr);
op2 = MathExpr(&script_ptr);
- if(var_size == VARSIZE_BYTE)
+ if (var_size == VARSIZE_BYTE)
*opptr = op2 & 255;
- else
- {
- opptr[0] = op2 >> 8; /*store in big-endian*/
+ else {
+ opptr[0] = op2 >> 8; /*store in big-endian*/
opptr[1] = op2 & 255;
}
- /*return op1;*/ /*previous value, never used?*/
+ /*return op1;*/ /*previous value, never used?*/
return 0;
}
/*Jump to routine*/
-unsigned int SCR_12_Chain(void)
-{
+unsigned int SCR_12_Chain(void) {
script_ptr++;
the_command = *script_ptr++; /*little-endian*/
the_command |= (*script_ptr++) << 8;
@@ -427,8 +388,7 @@ unsigned int SCR_12_Chain(void)
Absolute jump
Jumping past current routine ends the script
*/
-unsigned int SCR_33_Jump(void)
-{
+unsigned int SCR_33_Jump(void) {
unsigned short offs;
script_ptr++;
offs = *script_ptr++; /*little-endian*/
@@ -440,19 +400,15 @@ unsigned int SCR_33_Jump(void)
/*
Conditional jump (IF/ELSE block)
*/
-unsigned int SCR_3C_CondExpr(void)
-{
+unsigned int SCR_3C_CondExpr(void) {
script_ptr++;
- if(MathExpr(&script_ptr))
- {
+ if (MathExpr(&script_ptr)) {
/*fall to IF block*/
script_ptr += 2;
- }
- else
- {
+ } else {
/*branch to ELSE block*/
- script_ptr -= 1; /*simulate opcode byte for Jump handler*/
+ script_ptr -= 1; /*simulate opcode byte for Jump handler*/
return SCR_33_Jump();
}
return 0;
@@ -461,8 +417,7 @@ unsigned int SCR_3C_CondExpr(void)
/*
Absolute subroutine call
*/
-unsigned int SCR_34_Call(void)
-{
+unsigned int SCR_34_Call(void) {
unsigned short offs;
script_ptr++;
offs = *script_ptr++; /*little-endian*/
@@ -476,8 +431,7 @@ unsigned int SCR_34_Call(void)
/*
Return from script subroutine
*/
-unsigned int SCR_35_Ret(void)
-{
+unsigned int SCR_35_Ret(void) {
script_end_ptr = *(--script_stack_ptr);
script_ptr = *(--script_stack_ptr);
return 0;
@@ -485,13 +439,12 @@ unsigned int SCR_35_Ret(void)
/*Draw portrait, pushing it from left to right*/
-unsigned int SCR_5_DrawPortraitLiftRight(void)
-{
+unsigned int SCR_5_DrawPortraitLiftRight(void) {
unsigned char x, y, width, height;
script_ptr++;
- if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
/*TODO: use local args instead of globals*/
@@ -500,13 +453,12 @@ unsigned int SCR_5_DrawPortraitLiftRight(void)
}
/*Draw portrait, pushing it from right to left*/
-unsigned int SCR_6_DrawPortraitLiftLeft(void)
-{
+unsigned int SCR_6_DrawPortraitLiftLeft(void) {
unsigned char x, y, width, height;
script_ptr++;
- if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
/*TODO: use local args instead of globals*/
@@ -515,13 +467,12 @@ unsigned int SCR_6_DrawPortraitLiftLeft(void)
}
/*Draw portrait, pushing it from top to bottom*/
-unsigned int SCR_7_DrawPortraitLiftDown(void)
-{
+unsigned int SCR_7_DrawPortraitLiftDown(void) {
unsigned char x, y, width, height;
script_ptr++;
- if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
/*TODO: use local args instead of globals*/
@@ -530,13 +481,12 @@ unsigned int SCR_7_DrawPortraitLiftDown(void)
}
/*Draw portrait, pushing it from bottom to top*/
-unsigned int SCR_8_DrawPortraitLiftUp(void)
-{
+unsigned int SCR_8_DrawPortraitLiftUp(void) {
unsigned char x, y, width, height;
script_ptr++;
- if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
/*TODO: use local args instead of globals*/
@@ -545,13 +495,12 @@ unsigned int SCR_8_DrawPortraitLiftUp(void)
}
/*Draw portrait, no special effects*/
-unsigned int SCR_9_DrawPortrait(void)
-{
+unsigned int SCR_9_DrawPortrait(void) {
unsigned char x, y, width, height;
- script_ptr++;
+ script_ptr++;
- if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
CGA_BlitAndWait(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
@@ -559,17 +508,15 @@ 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)
-{
+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;
sx = x * 4;
ex = x * 4 + width * 4 - 1;
sy = y;
ey = y + height - 1;
-
- for(i = 0;i < width * 4;i++)
- {
+
+ for (i = 0; i < width * 4; i++) {
CGA_TraceLine(sx, ex, sy, ey, source, target);
WaitVBlank();
sx += 1;
@@ -584,8 +531,7 @@ void TwistDraw(unsigned char x, unsigned char y, unsigned char width, unsigned c
sy = ey;
ey = t;
- for(i = 0;i < height;i++)
- {
+ for (i = 0; i < height; i++) {
CGA_TraceLine(sx, ex, sy, ey, source, target);
WaitVBlank();
sy -= 1;
@@ -594,14 +540,13 @@ 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 int SCR_B_DrawPortraitTwistEffect(void) {
unsigned char x, y, width, height;
unsigned int offs;
script_ptr++;
- if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
offs = CGA_CalcXY_p(x, y);
@@ -614,8 +559,7 @@ 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)
-{
+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;
sx = x * 4;
@@ -623,22 +567,19 @@ void ArcDraw(unsigned char x, unsigned char y, unsigned char width, unsigned cha
sy = y + height - 1;
ey = y + height - 1;
- for(i = 0;i < height;i++)
- {
+ for (i = 0; i < height; i++) {
CGA_TraceLine(sx, ex, sy, ey, source, target);
WaitVBlank();
sy -= 1;
}
- for(i = 0;i < width * 4;i++)
- {
+ for (i = 0; i < width * 4; i++) {
CGA_TraceLine(sx, ex, sy, ey, source, target);
WaitVBlank();
sx += 1;
}
- for(i = 0;i < height + 1;i++)
- {
+ for (i = 0; i < height + 1; i++) {
CGA_TraceLine(sx, ex, sy, ey, source, target);
WaitVBlank();
sy += 1;
@@ -646,14 +587,13 @@ 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 int SCR_C_DrawPortraitArcEffect(void) {
unsigned char x, y, width, height;
unsigned int offs;
script_ptr++;
- if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
offs = CGA_CalcXY_p(x, y);
@@ -666,8 +606,7 @@ 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)
-{
+unsigned int SCR_D_DrawPortraitDotEffect(void) {
int i;
unsigned char x, y, width, height;
unsigned int offs, step = 17;
@@ -675,30 +614,28 @@ unsigned int SCR_D_DrawPortraitDotEffect(void)
script_ptr++;
- if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
cur_image_end = width * height;
- for(offs = 0;offs != cur_image_end;)
- {
+ for (offs = 0; offs != cur_image_end;) {
target[CGA_CalcXY_p(x + offs % cur_image_size_w, y + offs / cur_image_size_w)] = cur_image_pixels[offs];
- for(i = 0;i < 255;i++) ; /*TODO FIXME weak delay*/
+ for (i = 0; i < 255; i++) ; /*TODO FIXME weak delay*/
offs += step;
- if(offs > cur_image_end)
+ if (offs > cur_image_end)
offs -= cur_image_end;
}
return 0;
}
/*Draw image with slow zoom-in reveal effect*/
-unsigned int SCR_E_DrawPortraitZoomIn(void)
-{
+unsigned int SCR_E_DrawPortraitZoomIn(void) {
unsigned char x, y, width, height;
script_ptr++;
- if(!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
/*TODO*/
@@ -710,8 +647,7 @@ unsigned int SCR_E_DrawPortraitZoomIn(void)
/*Hide portrait, pushing it from right to left*/
-unsigned int SCR_19_HidePortraitLiftLeft(void)
-{
+unsigned int SCR_19_HidePortraitLiftLeft(void) {
unsigned char index;
unsigned char kind;
unsigned char x, y;
@@ -722,8 +658,7 @@ unsigned int SCR_19_HidePortraitLiftLeft(void)
index = *script_ptr++;
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
- if(right_button)
- {
+ if (right_button) {
CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
@@ -733,8 +668,7 @@ unsigned int SCR_19_HidePortraitLiftLeft(void)
/*offs = CGA_CalcXY_p(x + 1, y);*/
offs++;
- while(--width)
- {
+ while (--width) {
CGA_HideScreenBlockLiftToLeft(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
}
@@ -742,12 +676,11 @@ unsigned int SCR_19_HidePortraitLiftLeft(void)
/*hide leftmost line*/
/*TODO: move this to CGA?*/
- while(height--)
- {
+ while (height--) {
memcpy(frontbuffer + offs, backbuffer + offs, 1);
offs ^= CGA_ODD_LINES_OFS;
- if((offs & CGA_ODD_LINES_OFS) == 0)
+ if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
}
@@ -755,8 +688,7 @@ unsigned int SCR_19_HidePortraitLiftLeft(void)
}
/*Hide portrait, pushing it from left to right*/
-unsigned int SCR_1A_HidePortraitLiftRight(void)
-{
+unsigned int SCR_1A_HidePortraitLiftRight(void) {
unsigned char index;
unsigned char kind;
unsigned char x, y;
@@ -767,8 +699,7 @@ unsigned int SCR_1A_HidePortraitLiftRight(void)
index = *script_ptr++;
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
- if(right_button)
- {
+ if (right_button) {
CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
@@ -777,8 +708,7 @@ unsigned int SCR_1A_HidePortraitLiftRight(void)
offs = CGA_CalcXY_p(x + width - 2, y);
- while(--width)
- {
+ while (--width) {
CGA_HideScreenBlockLiftToRight(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
}
@@ -786,12 +716,11 @@ unsigned int SCR_1A_HidePortraitLiftRight(void)
/*hide leftmost line*/
/*TODO: move this to CGA?*/
- while(height--)
- {
+ while (height--) {
memcpy(frontbuffer + offs, backbuffer + offs, 1);
offs ^= CGA_ODD_LINES_OFS;
- if((offs & CGA_ODD_LINES_OFS) == 0)
+ if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
}
@@ -799,8 +728,7 @@ unsigned int SCR_1A_HidePortraitLiftRight(void)
}
/*Hide portrait, pushing it from bottom to top*/
-unsigned int SCR_1B_HidePortraitLiftUp(void)
-{
+unsigned int SCR_1B_HidePortraitLiftUp(void) {
unsigned char index;
unsigned char kind;
unsigned char x, y;
@@ -811,23 +739,21 @@ unsigned int SCR_1B_HidePortraitLiftUp(void)
index = *script_ptr++;
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
- if(right_button)
- {
+ if (right_button) {
CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
offs = CGA_CalcXY_p(x, y + 1);
- while(--height)
- {
+ while (--height) {
CGA_HideScreenBlockLiftToUp(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
}
/*hide topmost line*/
/*TODO: move this to CGA?*/
offs ^= CGA_ODD_LINES_OFS;
- if((offs & CGA_ODD_LINES_OFS) != 0)
+ if ((offs & CGA_ODD_LINES_OFS) != 0)
offs -= CGA_BYTES_PER_LINE;
memcpy(CGA_SCREENBUFFER + offs, backbuffer + offs, width);
return 0;
@@ -835,8 +761,7 @@ unsigned int SCR_1B_HidePortraitLiftUp(void)
/*Hide portrait, pushing it from top to bottom*/
-unsigned int SCR_1C_HidePortraitLiftDown(void)
-{
+unsigned int SCR_1C_HidePortraitLiftDown(void) {
unsigned char index;
unsigned char kind;
unsigned char x, y;
@@ -847,23 +772,21 @@ unsigned int SCR_1C_HidePortraitLiftDown(void)
index = *script_ptr++;
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
- if(right_button)
- {
+ if (right_button) {
CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
offs = CGA_CalcXY_p(x, y + height - 2);
- while(--height)
- {
+ while (--height) {
CGA_HideScreenBlockLiftToDown(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
}
/*hide bottommost line*/
/*TODO: move this to CGA?*/
offs ^= CGA_ODD_LINES_OFS;
- if((offs & CGA_ODD_LINES_OFS) == 0)
+ if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
memcpy(CGA_SCREENBUFFER + offs, backbuffer + offs, width);
return 0;
@@ -871,8 +794,7 @@ unsigned int SCR_1C_HidePortraitLiftDown(void)
/*Hide portrait with twist effect*/
-unsigned int SCR_1E_HidePortraitTwist(void)
-{
+unsigned int SCR_1E_HidePortraitTwist(void) {
unsigned char index;
unsigned char kind;
unsigned char x, y;
@@ -883,8 +805,7 @@ unsigned int SCR_1E_HidePortraitTwist(void)
index = *script_ptr++;
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
- if(right_button)
- {
+ if (right_button) {
CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
@@ -895,8 +816,7 @@ unsigned int SCR_1E_HidePortraitTwist(void)
}
/*Hide portrait with arc effect*/
-unsigned int SCR_1F_HidePortraitArc(void)
-{
+unsigned int SCR_1F_HidePortraitArc(void) {
unsigned char index;
unsigned char kind;
unsigned char x, y;
@@ -907,8 +827,7 @@ unsigned int SCR_1F_HidePortraitArc(void)
index = *script_ptr++;
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
- if(right_button)
- {
+ if (right_button) {
CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
@@ -919,8 +838,7 @@ unsigned int SCR_1F_HidePortraitArc(void)
}
/*Hide portrait with dots effect*/
-unsigned int SCR_20_HidePortraitDots(void)
-{
+unsigned int SCR_20_HidePortraitDots(void) {
unsigned char index;
unsigned char kind;
unsigned char x, y;
@@ -931,8 +849,7 @@ unsigned int SCR_20_HidePortraitDots(void)
index = *script_ptr++;
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
- if(right_button)
- {
+ if (right_button) {
CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
@@ -945,8 +862,7 @@ unsigned int SCR_20_HidePortraitDots(void)
}
-unsigned int SCR_39_AnimRoomDoorOpen(void)
-{
+unsigned int SCR_39_AnimRoomDoorOpen(void) {
unsigned char door;
script_ptr++;
@@ -955,8 +871,7 @@ unsigned int SCR_39_AnimRoomDoorOpen(void)
return 0;
}
-unsigned int SCR_3A_AnimRoomDoorClose(void)
-{
+unsigned int SCR_3A_AnimRoomDoorClose(void) {
unsigned char door;
script_ptr++;
@@ -965,8 +880,7 @@ unsigned int SCR_3A_AnimRoomDoorClose(void)
return 0;
}
-unsigned int SCR_25_ChangeZoneOnly(void)
-{
+unsigned int SCR_25_ChangeZoneOnly(void) {
unsigned char index;
unsigned char old = script_byte_vars.zone_room;
@@ -979,32 +893,28 @@ unsigned int SCR_25_ChangeZoneOnly(void)
}
-void JaggedZoom(void)
-{
+void JaggedZoom(void) {
/*TODO*/
}
-void InitStarfield(void)
-{
+void InitStarfield(void) {
/*TODO*/
}
-void AnimStarfield(void)
-{
+void AnimStarfield(void) {
/*TODO*/
}
-unsigned int SCR_26_GameOver(void)
-{
+unsigned int SCR_26_GameOver(void) {
in_de_profundis = 0;
script_byte_vars.game_paused = 1;
- memset(backbuffer, 0, sizeof(backbuffer) - 2); /*TODO: original bug?*/
+ memset(backbuffer, 0, sizeof(backbuffer) - 2); /*TODO: original bug?*/
JaggedZoom();
CGA_BackBufferToRealFull();
CGA_ColorSelect(0x30);
InitStarfield();
AnimStarfield();
- PlayAnim(44, 156/4, 95);
+ PlayAnim(44, 156 / 4, 95);
script_byte_vars.zone_index = 135;
JaggedZoom();
CGA_BackBufferToRealFull();
@@ -1016,16 +926,14 @@ unsigned int SCR_26_GameOver(void)
}
-unsigned int SCR_4C_DrawZoneObjs(void)
-{
+unsigned int SCR_4C_DrawZoneObjs(void) {
script_ptr++;
DrawZoneObjs();
return 0;
}
-unsigned int SCR_13_RedrawRoomStatics(void)
-{
+unsigned int SCR_13_RedrawRoomStatics(void) {
unsigned char index;
script_ptr++;
index = *script_ptr++;
@@ -1036,27 +944,23 @@ unsigned int SCR_13_RedrawRoomStatics(void)
/*
Load and draw zone (to backbuffer)
*/
-unsigned int SCR_42_LoadZone(void)
-{
+unsigned int SCR_42_LoadZone(void) {
unsigned char index;
script_ptr++;
index = *script_ptr++;
zone_drawn = 0;
- if(right_button)
+ if (right_button)
script_byte_vars.byte_179B8 = 0;
- else
- {
- if((script_byte_vars.cur_spot_flags & (SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8)) == 0)
+ else {
+ if ((script_byte_vars.cur_spot_flags & (SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8)) == 0)
script_byte_vars.byte_179B8 = script_byte_vars.cur_spot_flags & 7;
- else if((script_byte_vars.cur_spot_flags & ((SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8))) == SPOTFLG_8)
- {
+ else if ((script_byte_vars.cur_spot_flags & ((SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8))) == SPOTFLG_8) {
zone_drawn = 1;
AnimRoomDoorOpen(script_byte_vars.cur_spot_idx);
script_byte_vars.byte_179B8 = script_byte_vars.cur_spot_flags & 7;
- }
- else
+ } else
script_byte_vars.byte_179B8 = 0;
}
UpdateZoneSpot(index);
@@ -1067,8 +971,7 @@ unsigned int SCR_42_LoadZone(void)
DrawRoomStatics();
- if(script_byte_vars.byte_17A15 != 0)
- {
+ if (script_byte_vars.byte_17A15 != 0) {
RedrawRoomStatics(script_byte_vars.byte_17A15, 0);
script_byte_vars.byte_17A15 = 0;
}
@@ -1082,56 +985,49 @@ unsigned int SCR_42_LoadZone(void)
return 0;
}
-unsigned int SCR_59_BlitSpritesToBackBuffer(void)
-{
+unsigned int SCR_59_BlitSpritesToBackBuffer(void) {
script_ptr++;
BlitSpritesToBackBuffer();
return 0;
}
-unsigned int SCR_5A_SelectPalette(void)
-{
+unsigned int SCR_5A_SelectPalette(void) {
script_ptr++;
SelectPalette();
return 0;
}
-unsigned int SCR_43_RefreshZone(void)
-{
+unsigned int SCR_43_RefreshZone(void) {
script_ptr++;
RefreshZone();
return 0;
}
-unsigned int SCR_36_ChangeZone(void)
-{
+unsigned int 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)
-{
+void SCR_DrawRoomObjectBack(unsigned char *x, unsigned char *y, unsigned char *w, unsigned char *h) {
unsigned char obj[3];
script_ptr++;
- obj[0] = *script_ptr++; /*spr*/
- obj[1] = *script_ptr++; /*x*/
- obj[2] = *script_ptr++; /*y*/
+ obj[0] = *script_ptr++; /*spr*/
+ obj[1] = *script_ptr++; /*x*/
+ obj[2] = *script_ptr++; /*y*/
DrawRoomStaticObject(obj, x, y, w, h);
}
-unsigned int SCR_5F_DrawRoomObjectBack(void)
-{
+unsigned int SCR_5F_DrawRoomObjectBack(void) {
unsigned char x, y, w, h;
SCR_DrawRoomObjectBack(&x, &y, &w, &h);
return 0;
}
-unsigned int SCR_11_DrawRoomObject(void)
-{
+unsigned int SCR_11_DrawRoomObject(void) {
unsigned char x, y, w, h;
SCR_DrawRoomObjectBack(&x, &y, &w, &h);
CGA_CopyScreenBlock(backbuffer, w, h, CGA_SCREENBUFFER, CGA_CalcXY_p(x, y));
@@ -1141,8 +1037,7 @@ unsigned int SCR_11_DrawRoomObject(void)
/*
Draw box with item sprite and its name
*/
-unsigned int SCR_3_DrawItemBox(void)
-{
+unsigned int SCR_3_DrawItemBox(void) {
unsigned char current;
item_t *item;
@@ -1152,8 +1047,8 @@ unsigned int SCR_3_DrawItemBox(void)
script_ptr++;
current = *script_ptr++;
- if(current)
- item = (item_t*)script_vars[ScrPool3_CurrentItem];
+ if (current)
+ item = (item_t *)script_vars[ScrPool3_CurrentItem];
else
item = &inventory_items[pers_ptr->item - 1];
@@ -1168,8 +1063,7 @@ unsigned int SCR_3_DrawItemBox(void)
}
/*Draw simple bubble with text*/
-unsigned int SCR_37_DesciTextBox(void)
-{
+unsigned int SCR_37_DesciTextBox(void) {
unsigned char x, y, w;
unsigned char *msg;
script_ptr++;
@@ -1184,8 +1078,7 @@ unsigned int SCR_37_DesciTextBox(void)
/*Play portrait animation*/
-unsigned int SCR_18_AnimPortrait(void)
-{
+unsigned int SCR_18_AnimPortrait(void) {
unsigned char layer, index, delay;
script_ptr++;
@@ -1195,12 +1088,11 @@ unsigned int SCR_18_AnimPortrait(void)
AnimPortrait(layer, index, delay);
- return 0;
+ return 0;
}
/*Play animation*/
-unsigned int SCR_38_PlayAnim(void)
-{
+unsigned int SCR_38_PlayAnim(void) {
unsigned char index, x, y;
script_ptr++;
index = *script_ptr++;
@@ -1211,8 +1103,7 @@ unsigned int SCR_38_PlayAnim(void)
}
/*Pop up the actions menu and handle its commands*/
-unsigned int SCR_3D_ActionsMenu(void)
-{
+unsigned int SCR_3D_ActionsMenu(void) {
unsigned short cmd;
unsigned char *old_script = script_ptr;
@@ -1220,16 +1111,14 @@ unsigned int SCR_3D_ActionsMenu(void)
act_menu_x = 0xFF;
- for(;;)
- {
+ for (;;) {
script_ptr++;
ActionsMenu(&script_ptr);
- if(the_command == 0xFFFF)
+ if (the_command == 0xFFFF)
break;
cmd = the_command & 0xF000;
- if(cmd == 0xC000 || cmd == 0xA000)
- {
+ if (cmd == 0xC000 || cmd == 0xA000) {
return ScriptRerun;
}
@@ -1237,15 +1126,14 @@ unsigned int SCR_3D_ActionsMenu(void)
script_byte_vars.used_commands++;
- if(script_byte_vars.byte_179F9 == 0 && script_byte_vars.check_used_commands < script_byte_vars.used_commands)
- {
+ if (script_byte_vars.byte_179F9 == 0 && script_byte_vars.check_used_commands < script_byte_vars.used_commands) {
the_command = Swap16(script_word_vars.next_command1);
- if(the_command)
+ if (the_command)
return ScriptRerun;
}
script_ptr = old_script;
- if(--script_byte_vars.tries_left == 0)
+ if (--script_byte_vars.tries_left == 0)
ResetAllPersons();
}
@@ -1254,13 +1142,11 @@ unsigned int SCR_3D_ActionsMenu(void)
}
/*The Wall room puzzle*/
-unsigned int SCR_3E_TheWallAdvance(void)
-{
+unsigned int SCR_3E_TheWallAdvance(void) {
script_ptr++;
script_byte_vars.the_wall_phase = (script_byte_vars.the_wall_phase + 1) % 4;
- switch(script_byte_vars.the_wall_phase)
- {
+ switch (script_byte_vars.the_wall_phase) {
default:
TheWallPhase3();
break;
@@ -1281,8 +1167,7 @@ unsigned int SCR_3E_TheWallAdvance(void)
/*
When playing cups with proto
*/
-unsigned int SCR_28_MenuLoop(void)
-{
+unsigned int SCR_28_MenuLoop(void) {
unsigned char cursor;
unsigned char mask, value;
@@ -1295,15 +1180,14 @@ unsigned int SCR_28_MenuLoop(void)
MenuLoop(mask, value);
- return 0;
+ return 0;
}
/*
Restore screen data from back buffer as specified by dirty rects of specified index
*/
-unsigned int SCR_2A_PopDialogRect(void)
-{
+unsigned int SCR_2A_PopDialogRect(void) {
unsigned char index;
unsigned char kind;
unsigned char x, y;
@@ -1314,8 +1198,8 @@ unsigned int SCR_2A_PopDialogRect(void)
index = *script_ptr++;
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
- CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs); /*TODO: implicit target*/
- CGA_CopyScreenBlock(backbuffer, 2, 21, CGA_SCREENBUFFER, offs = (x << 8) | y); /*TODO: implicit target*/
+ CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs); /*TODO: implicit target*/
+ CGA_CopyScreenBlock(backbuffer, 2, 21, CGA_SCREENBUFFER, offs = (x << 8) | y); /*TODO: implicit target*/
cur_dlg_index = 0;
@@ -1325,8 +1209,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)
-{
+unsigned int SCR_2B_PopAllBubbles(void) {
script_ptr++;
PopDirtyRects(DirtyRectBubble);
return 0;
@@ -1335,8 +1218,7 @@ unsigned int SCR_2B_PopAllBubbles(void)
/*
Hide a portrait, with shatter effect
*/
-unsigned int SCR_22_HidePortraitShatter(void)
-{
+unsigned int SCR_22_HidePortraitShatter(void) {
unsigned char index;
unsigned char kind;
unsigned char x, y;
@@ -1347,8 +1229,7 @@ unsigned int SCR_22_HidePortraitShatter(void)
index = *script_ptr++;
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
- if(right_button)
- {
+ if (right_button) {
CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
@@ -1361,8 +1242,7 @@ unsigned int SCR_22_HidePortraitShatter(void)
/*
Hide a portrait, no special effects
*/
-unsigned int SCR_23_HidePortrait(void)
-{
+unsigned int SCR_23_HidePortrait(void) {
unsigned char index;
unsigned char kind;
unsigned char x, y;
@@ -1373,8 +1253,7 @@ unsigned int SCR_23_HidePortrait(void)
index = *script_ptr++;
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
- if(right_button)
- {
+ if (right_button) {
CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
@@ -1387,8 +1266,7 @@ unsigned int SCR_23_HidePortrait(void)
/*
Restore screen data from back buffer for all portraits
*/
-unsigned int SCR_24_PopAllPortraits(void)
-{
+unsigned int SCR_24_PopAllPortraits(void) {
script_ptr++;
PopDirtyRects(DirtyRectSprite);
return 0;
@@ -1397,8 +1275,7 @@ unsigned int SCR_24_PopAllPortraits(void)
/*
Restore screen data from back buffer for all text bubbles
*/
-unsigned int SCR_40_PopAllTextBoxes()
-{
+unsigned int SCR_40_PopAllTextBoxes() {
script_ptr++;
PopDirtyRects(DirtyRectText);
return 0;
@@ -1407,8 +1284,7 @@ unsigned int SCR_40_PopAllTextBoxes()
/*
Move a Hand in Who Will Be Saved
*/
-unsigned int SCR_41_LiftHand(void)
-{
+unsigned int SCR_41_LiftHand(void) {
script_ptr++;
RedrawRoomStatics(92, script_byte_vars.byte_179E1);
CGA_BackBufferToRealFull();
@@ -1418,15 +1294,14 @@ unsigned int SCR_41_LiftHand(void)
unsigned char fight_mode = 0;
-unsigned int SCR_30_Fight(void)
-{
+unsigned int SCR_30_Fight(void) {
static unsigned char player_image[] = {26, 0, 0};
unsigned char *image = player_image;
unsigned char x, y, width, height, kind;
unsigned int offs;
unsigned char *old_script, *old_script_end = script_end_ptr;
- pers_t *pers = (pers_t*)(script_vars[ScrPool8_CurrentPers]);
+ pers_t *pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]);
unsigned char strenght, win, rnd;
@@ -1438,23 +1313,19 @@ unsigned int SCR_30_Fight(void)
fight_mode = 1;
- if(pers->name != 44)
- {
- if(next_command3 == 0xA015)
- {
+ if (pers->name != 44) {
+ if (next_command3 == 0xA015) {
the_command = 0xA015;
RunCommand();
- FindAndSelectSpot((pers - pers_list) * 5); /*TODO: FindAndSelectSpot assumes plain offset, 5-byte records*/
+ FindAndSelectSpot((pers - pers_list) * 5); /*TODO: FindAndSelectSpot assumes plain offset, 5-byte records*/
}
- if(Swap16(script_word_vars.next_command1) == 0xC357)
- {
+ if (Swap16(script_word_vars.next_command1) == 0xC357) {
the_command = 0xC357;
RunCommand();
}
- pers = (pers_t*)(script_vars[ScrPool8_CurrentPers]);
- if(pers->name != 56 && pers->name != 51)
- {
+ pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]);
+ if (pers->name != 56 && pers->name != 51) {
x = dirty_rects[0].x + 64 / 4;
y = dirty_rects[0].y;
fight_mode = 0;
@@ -1464,13 +1335,12 @@ unsigned int SCR_30_Fight(void)
/*draw player portrait*/
player_image[1] = x;
player_image[2] = y;
- if(DrawPortrait(&image, &x, &y, &width, &height))
- CGA_AnimLiftToLeft(width, cur_image_pixels, width, 1, height, CGA_SCREENBUFFER, CGA_CalcXY_p(x + width - 1, y));
+ if (DrawPortrait(&image, &x, &y, &width, &height))
+ CGA_AnimLiftToLeft(width, cur_image_pixels, width, 1, height, CGA_SCREENBUFFER, CGA_CalcXY_p(x + width - 1, y));
BlinkToWhite();
- if(pers->name != 44 && pers->name != 56 && pers->name != 51)
- {
+ if (pers->name != 44 && pers->name != 56 && pers->name != 51) {
GetDirtyRectAndFree(1, &kind, &x, &y, &width, &height, &offs);
CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
}
@@ -1481,29 +1351,27 @@ unsigned int SCR_30_Fight(void)
script_byte_vars.byte_179F2 = 0;
- if(script_byte_vars.byte_179F3 == 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};
strenght = character_strenght[pers->name - 42];
/*check if can decrease*/
- if(strenght != 1 && (pers->flags & PERSFLG_80))
+ if (strenght != 1 && (pers->flags & PERSFLG_80))
strenght--;
- if(script_byte_vars.room_items != 0 || script_byte_vars.byte_17A1C != 0)
+ if (script_byte_vars.room_items != 0 || script_byte_vars.byte_17A1C != 0)
strenght--;
}
/*check if can increase*/
- if(strenght != 5)
- {
- if((pers->item >= 19 && pers->item < 23)
- || (pers->item >= 39 && pers->item < 52)
- || pers->item == 56 || pers->item == 57
- || ((pers->index >> 3) == 6))
+ if (strenght != 5) {
+ if ((pers->item >= 19 && pers->item < 23)
+ || (pers->item >= 39 && pers->item < 52)
+ || pers->item == 56 || pers->item == 57
+ || ((pers->index >> 3) == 6))
strenght++;
- }
+ }
win = 1;
rnd = script_byte_vars.rand_value;
@@ -1512,23 +1380,16 @@ unsigned int SCR_30_Fight(void)
strenght = 1;
#endif
- if(strenght >= 2)
- {
- if(strenght == 2)
- {
- if(rnd >= 205)
+ if (strenght >= 2) {
+ if (strenght == 2) {
+ if (rnd >= 205)
win = Rand() < 128 ? 81 : 82;
- }
- else if(strenght == 4 && rnd < 100)
- {
+ } else if (strenght == 4 && rnd < 100) {
win = Rand() < 128 ? 81 : 82;
- }
- else
- {
+ } else {
win = 2;
- if(strenght == 3)
- {
- if(rnd < 128) /*TODO: check me, maybe original bug (checks against wrong reg?)*/
+ if (strenght == 3) {
+ if (rnd < 128) /*TODO: check me, maybe original bug (checks against wrong reg?)*/
win = Rand() < 51 ? 145 : 146;
else
win = Rand() < 205 ? 49 : 50;
@@ -1547,8 +1408,8 @@ unsigned char prev_fight_mode = 0;
unsigned short fight_pers_ofs = 0;
typedef struct fightentry_t {
-unsigned char room;
-animdesc_t anim;
+ unsigned char room;
+ animdesc_t anim;
} fightentry_t;
fightentry_t fightlist1[] = {
@@ -1620,59 +1481,46 @@ fightentry_t fightlist3[] = {
};
/*Draw defeated enemy*/
-unsigned int SCR_31_Fight2(void)
-{
+unsigned int 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*/
+ 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*/
pers->flags |= PERSFLG_40;
pers->area = 0;
found_spot->flags &= ~SPOTFLG_80;
- if(pers->index == 16)
- {
+ if (pers->index == 16) {
pers_list[34].area = script_byte_vars.zone_area;
pers_list[34].flags = pers->flags;
- if(script_byte_vars.room_items == 0)
- {
+ if (script_byte_vars.room_items == 0) {
static const animdesc_t anim19 = {ANIMFLG_USESPOT | 19};
AnimateSpot(&anim19);
}
the_command = next_command3;
RunCommand();
- }
- else if(pers->index == 8)
- {
+ } else if (pers->index == 8) {
pers_list[35].area = script_byte_vars.zone_area;
pers_list[35].flags = pers->flags;
- if(script_byte_vars.room_items == 0)
- {
+ if (script_byte_vars.room_items == 0) {
static const animdesc_t anim20 = {ANIMFLG_USESPOT | 20};
AnimateSpot(&anim20);
}
the_command = next_command3;
RunCommand();
- }
- else
- {
- if(prev_fight_mode == 0
- && script_byte_vars.room_items != 0
- && fight_mode == 0)
- {
+ } else {
+ if (prev_fight_mode == 0
+ && script_byte_vars.room_items != 0
+ && fight_mode == 0) {
script_byte_vars.byte_179F2 &= ~1;
- }
- else
- {
+ } else {
unsigned int i;
fightentry_t *fightlist;
unsigned int fightlistsize;
unsigned char animidx;
prev_fight_mode = 0;
- switch(pers->name)
- {
+ switch (pers->name) {
case 56:
animidx = 47;
fightlist = fightlist1;
@@ -1690,13 +1538,11 @@ unsigned int SCR_31_Fight2(void)
fightlistsize = 26;
}
- for(i = 0;i < fightlistsize;i++)
- {
- if(fightlist[i].room == script_byte_vars.zone_room)
- {
- if(animidx != 0)
+ for (i = 0; i < fightlistsize; i++) {
+ if (fightlist[i].room == script_byte_vars.zone_room) {
+ if (animidx != 0)
fightlist[i].anim.index = animidx;
- if(fightlist[i].anim.index == 55)
+ if (fightlist[i].anim.index == 55)
PlaySound(151);
PlayAnim(fightlist[i].anim.index, fightlist[i].anim.params.coords.x, fightlist[i].anim.params.coords.y);
break;
@@ -1709,23 +1555,20 @@ unsigned int SCR_31_Fight2(void)
return 0;
}
-unsigned int SCR_32_FightWin(void)
-{
+unsigned int SCR_32_FightWin(void) {
script_ptr++;
script_byte_vars.byte_17A1D = 0;
- if(script_byte_vars.byte_179F9 != 18 && *spot_sprite != 0)
- {
+ if (script_byte_vars.byte_179F9 != 18 && *spot_sprite != 0) {
CGA_RestoreImage(*spot_sprite, frontbuffer);
CGA_RestoreImage(*spot_sprite, backbuffer);
- if(script_byte_vars.byte_179F3 == 0
- && script_byte_vars.byte_17A16 == 0
- && script_byte_vars.room_items != 0
- && fight_mode == 0)
- {
+ if (script_byte_vars.byte_179F3 == 0
+ && script_byte_vars.byte_17A16 == 0
+ && script_byte_vars.room_items != 0
+ && fight_mode == 0) {
script_byte_vars.byte_17A1D = 1;
PlaySound(149);
PlayAnim(40, found_spot->sx, found_spot->sy);
@@ -1740,20 +1583,17 @@ unsigned int SCR_32_FightWin(void)
extern void ExitGame(void);
-unsigned int SCR_15_SelectSpot(void)
-{
+unsigned int SCR_15_SelectSpot(void) {
unsigned char mask, index;
script_ptr++;
mask = *script_ptr++;
index = *script_ptr++;
- if(mask != 0)
- {
- index = FindSpotByFlags(mask, index); /*TODO: return 0 if not found?*/
- if(index == 0xFF)
- {
+ if (mask != 0) {
+ index = FindSpotByFlags(mask, index); /*TODO: return 0 if not found?*/
+ if (index == 0xFF) {
TODO("ERROR: SelectSpot: spot not found");
- ExitGame(); /*hard abort*/
+ ExitGame(); /*hard abort*/
}
}
found_spot = &zone_spots[index - 1];
@@ -1762,14 +1602,13 @@ unsigned int SCR_15_SelectSpot(void)
FindPerson();
- if(script_byte_vars.cur_pers == 0)
+ if (script_byte_vars.cur_pers == 0)
script_vars[ScrPool8_CurrentPers] = &pers_list[20];
return 0;
}
-unsigned int SCR_44_BackBufferToScreen(void)
-{
+unsigned int SCR_44_BackBufferToScreen(void) {
script_ptr++;
CGA_BackBufferToRealFull();
return 0;
@@ -1778,8 +1617,7 @@ unsigned int SCR_44_BackBufferToScreen(void)
/*
Animate De Profundis room on entry
*/
-unsigned int SCR_45_DeProfundisRoomEntry(void)
-{
+unsigned int SCR_45_DeProfundisRoomEntry(void) {
unsigned int w, h;
unsigned int sprofs, ofs;
@@ -1795,16 +1633,15 @@ unsigned int SCR_45_DeProfundisRoomEntry(void)
PromptWait();
- for(;h;h--)
- {
+ for (; h; h--) {
WaitVBlank();
WaitVBlank();
CGA_BlitFromBackBuffer(w, 1, CGA_SCREENBUFFER, ofs);
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
-
+
CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
}
@@ -1816,8 +1653,7 @@ unsigned int SCR_45_DeProfundisRoomEntry(void)
/*
Animate De Profundis hook (lower)
*/
-unsigned int SCR_46_DeProfundisLowerHook(void)
-{
+unsigned int SCR_46_DeProfundisLowerHook(void) {
unsigned char y;
unsigned int w, h;
unsigned int sprofs, ofs;
@@ -1829,10 +1665,9 @@ unsigned int SCR_46_DeProfundisLowerHook(void)
h = 1;
y = 15;
- sprofs = y * 20 / 4 * 2; /*TODO: 20 is the sprite width. replace with w?*/
+ sprofs = y * 20 / 4 * 2; /*TODO: 20 is the sprite width. replace with w?*/
- for(;y;y--)
- {
+ for (; y; y--) {
WaitVBlank();
CGA_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
@@ -1848,8 +1683,7 @@ unsigned int SCR_46_DeProfundisLowerHook(void)
/*
Animate De Profundis monster (rise)
*/
-unsigned int SCR_47_DeProfundisRiseMonster(void)
-{
+unsigned int SCR_47_DeProfundisRiseMonster(void) {
unsigned char y;
unsigned int w, h;
unsigned int sprofs, ofs;
@@ -1862,12 +1696,11 @@ unsigned int SCR_47_DeProfundisRiseMonster(void)
h = 1;
y = 68;
- for(;y;y--)
- {
+ for (; y; y--) {
WaitVBlank();
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) != 0)
+ if ((ofs & CGA_ODD_LINES_OFS) != 0)
ofs -= CGA_BYTES_PER_LINE;
h++;
@@ -1881,8 +1714,7 @@ unsigned int SCR_47_DeProfundisRiseMonster(void)
/*
Animate De Profundis monster (lower)
*/
-unsigned int SCR_48_DeProfundisLowerMonster(void)
-{
+unsigned int SCR_48_DeProfundisLowerMonster(void) {
unsigned char y;
unsigned int w, h;
unsigned int sprofs, ofs;
@@ -1894,13 +1726,12 @@ unsigned int SCR_48_DeProfundisLowerMonster(void)
y = 34;
- for(;y;y--)
- {
+ for (; y; y--) {
WaitVBlank();
CGA_BlitFromBackBuffer(w, 1, CGA_SCREENBUFFER, ofs);
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
h--;
@@ -1913,8 +1744,7 @@ unsigned int SCR_48_DeProfundisLowerMonster(void)
/*
Animate De Profundis hook (rise)
*/
-unsigned int SCR_49_DeProfundisRiseHook(void)
-{
+unsigned int SCR_49_DeProfundisRiseHook(void) {
unsigned char y;
unsigned int w, h;
unsigned int sprofs, ofs;
@@ -1927,8 +1757,7 @@ unsigned int SCR_49_DeProfundisRiseHook(void)
h = 16;
y = 15;
- for(;y;y--)
- {
+ for (; y; y--) {
WaitVBlank();
CGA_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
@@ -1947,8 +1776,7 @@ unsigned int SCR_49_DeProfundisRiseHook(void)
/*
Animate De Profundis platform
*/
-unsigned int SCR_65_DeProfundisMovePlatform(void)
-{
+unsigned int SCR_65_DeProfundisMovePlatform(void) {
unsigned char state;
unsigned char x, y;
unsigned int w, h;
@@ -1959,26 +1787,24 @@ unsigned int SCR_65_DeProfundisMovePlatform(void)
x = 140 / 4;
y = 174;
- if(state != 0)
+ if (state != 0)
y += 4;
/*draw Platform*/
sprofs = GetPuzzlSprite(3, x, y, &w, &h, &ofs);
y = 4;
- if(state)
- {
+ if (state) {
h -= 4;
y--;
}
- for(;y;y--)
- {
+ for (; y; y--) {
WaitVBlank();
CGA_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
ofs ^= CGA_ODD_LINES_OFS;
- if((ofs & CGA_ODD_LINES_OFS) == 0)
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
h--;
@@ -1986,7 +1812,7 @@ unsigned int SCR_65_DeProfundisMovePlatform(void)
CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
}
- if(state)
+ if (state)
CGA_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
return 0;
@@ -1995,8 +1821,7 @@ unsigned int SCR_65_DeProfundisMovePlatform(void)
/*
Animate De Profundis monster ride to exit door
*/
-unsigned int SCR_66_DeProfundisRideToExit(void)
-{
+unsigned int SCR_66_DeProfundisRideToExit(void) {
unsigned int w, h;
unsigned int sprofs, ofs;
@@ -2017,8 +1842,7 @@ unsigned int SCR_66_DeProfundisRideToExit(void)
/*
Draw item bounce to room objects animation
*/
-unsigned int SCR_4E_BounceCurrentItemToRoom(void)
-{
+unsigned int SCR_4E_BounceCurrentItemToRoom(void) {
script_ptr++;
BounceCurrentItem(ITEMFLG_40, 43);
return 0;
@@ -2027,8 +1851,7 @@ unsigned int SCR_4E_BounceCurrentItemToRoom(void)
/*
Draw item bounce to inventory animation
*/
-unsigned int SCR_4F_BounceCurrentItemToInventory(void)
-{
+unsigned int SCR_4F_BounceCurrentItemToInventory(void) {
script_ptr++;
BounceCurrentItem(ITEMFLG_80, 85);
return 0;
@@ -2037,24 +1860,22 @@ unsigned int SCR_4F_BounceCurrentItemToInventory(void)
/*
Draw item bounce to inventory animation
*/
-unsigned int SCR_50_BounceItemToInventory(void)
-{
+unsigned int SCR_50_BounceItemToInventory(void) {
unsigned char itemidx;
script_ptr++;
itemidx = *script_ptr++;
- script_vars[ScrPool3_CurrentItem] = &inventory_items[itemidx - 1];
+ script_vars[ScrPool3_CurrentItem] = &inventory_items[itemidx - 1];
BounceCurrentItem(ITEMFLG_80, 85);
return 0;
}
-unsigned int SCR_51_ItemTrade(void)
-{
+unsigned int SCR_51_ItemTrade(void) {
unsigned char *old_script, *old_script_end = script_end_ptr;
unsigned char status;
- if(script_byte_vars.byte_179DC >= 63) /*TODO: hang?*/
+ if (script_byte_vars.byte_179DC >= 63) /*TODO: hang?*/
return 0;
script_ptr++;
@@ -2064,30 +1885,25 @@ unsigned int SCR_51_ItemTrade(void)
OpenInventory(0xFF, ITEMFLG_80);
status = 1;
- if(inv_count != 0)
- {
+ if (inv_count != 0) {
status = 2;
- if(the_command != 0)
- {
+ if (the_command != 0) {
status = 3;
- if(script_byte_vars.inv_item_index >= 6 && script_byte_vars.inv_item_index < 27)
- {
+ if (script_byte_vars.inv_item_index >= 6 && script_byte_vars.inv_item_index < 27) {
the_command = 0xC204;
RunCommand();
- ((item_t*)(script_vars[ScrPool3_CurrentItem]))->flags = 0;
+ ((item_t *)(script_vars[ScrPool3_CurrentItem]))->flags = 0;
OpenInventory(0xFF, ITEMFLG_10);
-
+
status = 4;
- if(the_command != 0)
- {
+ if (the_command != 0) {
status = 5;
- if(script_byte_vars.rand_value < 128)
- {
+ if (script_byte_vars.rand_value < 128) {
status = 6;
- ((item_t*)(script_vars[ScrPool3_CurrentItem]))[-1].flags = ITEMFLG_10; /*TODO: what's up with this index?*/
- ((item_t*)(script_vars[ScrPool3_CurrentItem]))->flags = 0;
+ ((item_t *)(script_vars[ScrPool3_CurrentItem]))[-1].flags = ITEMFLG_10; /*TODO: what's up with this index?*/
+ ((item_t *)(script_vars[ScrPool3_CurrentItem]))->flags = 0;
}
}
}
@@ -2102,15 +1918,13 @@ unsigned int SCR_51_ItemTrade(void)
return 0;
}
-unsigned int SCR_52_RefreshSpritesData(void)
-{
+unsigned int SCR_52_RefreshSpritesData(void) {
script_ptr++;
RefreshSpritesData();
return 0;
}
-unsigned int SCR_53_FindInvItem(void)
-{
+unsigned int SCR_53_FindInvItem(void) {
unsigned char first, count, flags, i;
item_t *item;
script_ptr++;
@@ -2118,10 +1932,8 @@ unsigned int SCR_53_FindInvItem(void)
count = *script_ptr++;
flags = *script_ptr++;
item = &inventory_items[first - 1];
- for(i = 0;i < count;i++)
- {
- if(item[i].flags == flags)
- {
+ for (i = 0; i < count; i++) {
+ if (item[i].flags == flags) {
script_vars[ScrPool3_CurrentItem] = &item[i];
return 0;
}
@@ -2131,8 +1943,7 @@ unsigned int SCR_53_FindInvItem(void)
}
-unsigned int SCR_64_DrawBoxAroundSpot(void)
-{
+unsigned int SCR_64_DrawBoxAroundSpot(void) {
script_ptr++;
DrawBoxAroundSpot();
return 0;
@@ -2141,8 +1952,7 @@ unsigned int SCR_64_DrawBoxAroundSpot(void)
/*
Draw text box
*/
-unsigned int SCR_14_DrawDesc(void)
-{
+unsigned int SCR_14_DrawDesc(void) {
unsigned char *msg;
script_ptr++;
msg = SeekToStringScr(desci_data, *script_ptr, &script_ptr);
@@ -2158,8 +1968,7 @@ 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 int SCR_17_DrawPersonThoughtBubbleDialog(void) {
unsigned char x, y;
unsigned char *msg;
script_ptr++;
@@ -2169,10 +1978,10 @@ unsigned int SCR_17_DrawPersonThoughtBubbleDialog(void)
x = found_spot->sx;
y = found_spot->sy;
- if(x < 140/4)
+ if (x < 140 / 4)
DrawPersonBubble(found_spot->ex, y - 40, SPIKE_BUBLEFT | 20, msg);
else
- DrawPersonBubble(x - 80/4, y - 40, SPIKE_BUBRIGHT | 20, msg);
+ DrawPersonBubble(x - 80 / 4, y - 40, SPIKE_BUBRIGHT | 20, msg);
PromptWait();
PopDirtyRects(DirtyRectBubble);
@@ -2183,8 +1992,7 @@ 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 int SCR_61_DrawPersonBubbleDialog(void) {
unsigned char x, y;
unsigned char *msg;
script_ptr++;
@@ -2194,10 +2002,10 @@ unsigned int SCR_61_DrawPersonBubbleDialog(void)
x = found_spot->sx;
y = found_spot->sy;
- if(x < 140/4)
+ if (x < 140 / 4)
DrawPersonBubble(found_spot->ex, y - 40, SPIKE_DNLEFT | 20, msg);
else
- DrawPersonBubble(x - 80/4, y - 40, SPIKE_DNRIGHT | 20, msg);
+ DrawPersonBubble(x - 80 / 4, y - 40, SPIKE_DNRIGHT | 20, msg);
PromptWait();
PopDirtyRects(DirtyRectBubble);
@@ -2206,35 +2014,33 @@ unsigned int SCR_61_DrawPersonBubbleDialog(void)
#if 1
#include <stdio.h>
-unsigned char * DebugString(char *msg, ...)
-{
+unsigned char *DebugString(char *msg, ...) {
int i;
unsigned char c;
static unsigned char m[256];
- va_list ap;
+ va_list ap;
- va_start(ap,msg);
- vsprintf((char*)m,msg,ap);
+ va_start(ap, msg);
+ vsprintf((char *)m, msg, ap);
va_end(ap);
- for(i = 0;m[i];i++)
- {
+ for (i = 0; m[i]; i++) {
c = m[i];
- if(c >= 'A' && c <= 'Z')
+ if (c >= 'A' && c <= 'Z')
c = 0x21 + (c - 'A');
- else if(c >= 'a' && c <= 'z')
+ else if (c >= 'a' && c <= 'z')
c = 0x21 + (c - 'a');
- else if(c >= '0' && c <= '9')
+ else if (c >= '0' && c <= '9')
c = 0x10 + (c - '0');
- else if(c == ' ')
+ else if (c == ' ')
c = 0x20;
- else if(c == '!')
+ else if (c == '!')
c = 0x01;
- else if(c == ',')
+ else if (c == ',')
c = 0x0C;
- else if(c == '.')
+ else if (c == '.')
c = 0x0E;
- else if(c == '\n')
+ else if (c == '\n')
c = 0x00;
else
c = 0x1F;
@@ -2250,28 +2056,26 @@ unsigned char * DebugString(char *msg, ...)
/*
Draw dialog bubble with text for gauss
*/
-unsigned int SCR_27_DrawGaussBubble(void)
-{
+unsigned int SCR_27_DrawGaussBubble(void) {
unsigned char *msg;
script_ptr++;
msg = SeekToStringScr(diali_data, *script_ptr, &script_ptr);
script_ptr++;
- DrawPersonBubble(32/4, 20, 15, msg);
+ DrawPersonBubble(32 / 4, 20, 15, msg);
return 0;
}
/*
Draw dialog bubble with text
*/
-unsigned int SCR_29_DialiTextBox(void)
-{
+unsigned int SCR_29_DialiTextBox(void) {
unsigned char x, y, f;
unsigned char *msg;
script_ptr++;
msg = SeekToStringScr(diali_data, *script_ptr, &script_ptr);
- cur_dlg_index = cur_str_index; /*TODO: useless?*/
+ cur_dlg_index = cur_str_index; /*TODO: useless?*/
script_ptr++;
x = *script_ptr++;
@@ -2285,8 +2089,7 @@ unsigned int SCR_29_DialiTextBox(void)
/*
Do nothing in PC/CGA version
*/
-unsigned int SCR_67_Unused(void)
-{
+unsigned int SCR_67_Unused(void) {
script_ptr++;
script_ptr++;
return 0;
@@ -2295,8 +2098,7 @@ unsigned int SCR_67_Unused(void)
/*
Do nothing in PC/CGA version
*/
-unsigned int SCR_68_Unused(void)
-{
+unsigned int SCR_68_Unused(void) {
script_ptr++;
script_ptr++;
return 0;
@@ -2305,8 +2107,7 @@ unsigned int SCR_68_Unused(void)
/*
Play sound
*/
-unsigned int SCR_69_PlaySound(void)
-{
+unsigned int SCR_69_PlaySound(void) {
unsigned char index;
script_ptr++;
index = *script_ptr++;
@@ -2319,8 +2120,7 @@ unsigned int SCR_69_PlaySound(void)
/*
Do nothing in PC/CGA version
*/
-unsigned int SCR_6A_Unused(void)
-{
+unsigned int SCR_6A_Unused(void) {
script_ptr++;
return 0;
}
@@ -2328,8 +2128,7 @@ unsigned int SCR_6A_Unused(void)
/*
Open room's items inventory
*/
-unsigned int CMD_1_RoomObjects(void)
-{
+unsigned int CMD_1_RoomObjects(void) {
UpdateUndrawCursor(CGA_SCREENBUFFER);
inv_bgcolor = 0xAA;
OpenInventory((0xFF << 8) | ITEMFLG_40, (script_byte_vars.zone_area << 8) | ITEMFLG_40);
@@ -2339,23 +2138,20 @@ unsigned int CMD_1_RoomObjects(void)
/*
Open Psi Powers menu
*/
-unsigned int CMD_2_PsiPowers(void)
-{
+unsigned int CMD_2_PsiPowers(void) {
/*Psi powers bar*/
BackupAndShowSprite(3, 280 / 4, 40);
ProcessInput();
- do
- {
+ do {
PollInput();
SelectCursor(CURSOR_0);
CheckPsiCommandHover();
- if(command_hint != 100)
+ if (command_hint != 100)
command_hint += 109;
- if(command_hint != last_command_hint)
+ if (command_hint != last_command_hint)
DrawCommandHint();
DrawHintsAndCursor(CGA_SCREENBUFFER);
- }
- while(buttons == 0);
+ } while (buttons == 0);
UndrawCursor(CGA_SCREENBUFFER);
CGA_RestoreBackupImage(CGA_SCREENBUFFER);
return ScriptRerun;
@@ -2364,8 +2160,7 @@ unsigned int CMD_2_PsiPowers(void)
/*
Open normal inventory box
*/
-unsigned int CMD_3_Posessions(void)
-{
+unsigned int CMD_3_Posessions(void) {
UpdateUndrawCursor(CGA_SCREENBUFFER);
inv_bgcolor = 0x55;
OpenInventory(ITEMFLG_80, ITEMFLG_80);
@@ -2375,9 +2170,8 @@ 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 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;
@@ -2385,21 +2179,18 @@ unsigned int CMD_4_EnergyLevel(void)
PopDirtyRects(DirtyRectSprite);
PopDirtyRects(DirtyRectBubble);
- if(script_byte_vars.psy_energy != 0)
+ if (script_byte_vars.psy_energy != 0)
anim = 41 + (script_byte_vars.psy_energy / 16);
- 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);
+ 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
- {
+ do {
AnimPortrait(1, anim, 10);
AnimPortrait(1, anim + 14, 10);
PollInput();
- }
- while(buttons == 0);
+ } while (buttons == 0);
PopDirtyRects(DirtyRectSprite);
@@ -2409,8 +2200,7 @@ unsigned int CMD_4_EnergyLevel(void)
/*
Advance time
*/
-unsigned int CMD_5_Wait(void)
-{
+unsigned int CMD_5_Wait(void) {
script_byte_vars.byte_179DB++;
script_word_vars.timer_ticks2 = Swap16(Swap16(script_word_vars.timer_ticks2) + 300);
@@ -2425,17 +2215,13 @@ unsigned int CMD_5_Wait(void)
the_command = Swap16(script_word_vars.word_17852);
- if(the_command == 0)
- {
- if(script_word_vars.next_command1 == 0)
- {
+ if (the_command == 0) {
+ if (script_word_vars.next_command1 == 0) {
the_command = 0x9005;
RunCommand();
}
- }
- else
- {
- if(script_byte_vars.byte_179DC >= 63 && script_byte_vars.zone_area < 22 && script_byte_vars.zone_area != 1)
+ } else {
+ if (script_byte_vars.byte_179DC >= 63 && script_byte_vars.zone_area < 22 && script_byte_vars.zone_area != 1)
the_command = 0x9005;
return ScriptRerun;
}
@@ -2446,8 +2232,7 @@ unsigned int CMD_5_Wait(void)
/*
Load game (menu)
*/
-unsigned int CMD_6_Load(void)
-{
+unsigned int CMD_6_Load(void) {
the_command = 0xC35C;
return ScriptRerun;
}
@@ -2455,8 +2240,7 @@ unsigned int CMD_6_Load(void)
/*
Save game (menu)
*/
-unsigned int CMD_7_Save(void)
-{
+unsigned int CMD_7_Save(void) {
the_command = 0xC35D;
return ScriptRerun;
}
@@ -2464,66 +2248,58 @@ unsigned int CMD_7_Save(void)
/*
Show timer
*/
-unsigned int CMD_8_Timer(void)
-{
- static unsigned char timer_image[] = {163, 244/4, 104};
+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;
- 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);
+ 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
- {
+ do {
unsigned short timer = Swap16(script_word_vars.timer_ticks2);
unsigned short minutes = timer % (60 * 60);
- char_draw_coords_x = 260/4;
+ char_draw_coords_x = 260 / 4;
char_draw_coords_y = 120;
WaitVBlank();
CGA_PrintChar(timer / (60 * 60) + 16, CGA_SCREENBUFFER);
- CGA_PrintChar((minutes & 1) ? 26 : 0, CGA_SCREENBUFFER); /*colon*/
+ CGA_PrintChar((minutes & 1) ? 26 : 0, CGA_SCREENBUFFER); /*colon*/
CGA_PrintChar(minutes / (60 * 10) + 16, CGA_SCREENBUFFER);
CGA_PrintChar(minutes / 60 + 16, CGA_SCREENBUFFER);
PollInput();
- }
- while(buttons == 0);
+ } while (buttons == 0);
PopDirtyRects(DirtyRectSprite);
return 0;
}
-int ConsumePsiEnergy(unsigned char amount)
-{
+int ConsumePsiEnergy(unsigned char amount) {
unsigned char current = script_byte_vars.psy_energy;
- if(current < amount)
- {
+ if (current < amount) {
/*no energy left*/
PlayAnim(68, 296 / 4, 71);
return 0;
}
-
+
script_byte_vars.psy_energy = current - amount;
/*significantly changed?*/
- if((current & 0xF0) != (script_byte_vars.psy_energy & 0xF0))
+ if ((current & 0xF0) != (script_byte_vars.psy_energy & 0xF0))
PlayAnim(68, 296 / 4, 71);
return 1;
}
-unsigned int CMD_A_PsiSolarEyes(void)
-{
- if(!ConsumePsiEnergy(2))
+unsigned int CMD_A_PsiSolarEyes(void) {
+ if (!ConsumePsiEnergy(2))
return 0;
- if(zone_palette == 14)
- {
+ if (zone_palette == 14) {
RedrawRoomStatics(script_byte_vars.zone_room, zone_palette);
zone_palette = 0;
CGA_BackBufferToRealFull();
@@ -2537,15 +2313,13 @@ unsigned int CMD_A_PsiSolarEyes(void)
}
-unsigned short GetZoneObjCommand(unsigned int offs)
-{
+unsigned short GetZoneObjCommand(unsigned int 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)
-{
+void DrawStickyNet(void) {
unsigned char x, y, w, h;
unsigned int ofs;
@@ -2560,22 +2334,19 @@ void DrawStickyNet(void)
/*16x30 is the net sprite size*/
- for(;h;h -= 30)
- {
+ for (; h; h -= 30) {
int i;
- for(i = 0;i < w;i += 16 / 4)
+ 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)
-{
- if(!ConsumePsiEnergy(3))
+unsigned int CMD_B_PsiStickyFingers(void) {
+ if (!ConsumePsiEnergy(3))
return 0;
- if(script_byte_vars.byte_179F9 != 0)
- {
+ if (script_byte_vars.byte_179F9 != 0) {
the_command = Swap16(script_word_vars.word_178F0);
return ScriptRerun;
}
@@ -2588,74 +2359,66 @@ unsigned int CMD_B_PsiStickyFingers(void)
CGA_BackBufferToRealFull();
RestoreScreenOfSpecialRoom();
- if(script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(0) == 0)
+ if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(0) == 0)
the_command = Swap16(script_word_vars.word_17844);
- if(script_byte_vars.byte_179DC >= 63
- && script_byte_vars.zone_area < 22
- && script_byte_vars.zone_area != 1)
+ if (script_byte_vars.byte_179DC >= 63
+ && script_byte_vars.zone_area < 22
+ && script_byte_vars.zone_area != 1)
the_command = 0x9005;
-
+
return ScriptRerun;
}
-unsigned int CMD_C_PsiKnowMind(void)
-{
- if(!ConsumePsiEnergy(1))
+unsigned int CMD_C_PsiKnowMind(void) {
+ if (!ConsumePsiEnergy(1))
return 0;
- if(script_byte_vars.byte_179F9 != 0)
- {
+ if (script_byte_vars.byte_179F9 != 0) {
the_command = Swap16(script_word_vars.word_178F2);
return ScriptRerun;
}
ProcessMenu();
- if(script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(4) == 0)
+ if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(4) == 0)
the_command = Swap16(script_word_vars.word_17846);
return ScriptRerun;
}
-unsigned int CMD_D_PsiBrainwarp(void)
-{
- if(!ConsumePsiEnergy(2))
+unsigned int CMD_D_PsiBrainwarp(void) {
+ if (!ConsumePsiEnergy(2))
return 0;
- if(script_byte_vars.byte_179F9 == 0)
- {
+ if (script_byte_vars.byte_179F9 == 0) {
BackupScreenOfSpecialRoom();
ProcessMenu();
- if(script_byte_vars.cur_spot_idx == 0)
- {
+ if (script_byte_vars.cur_spot_idx == 0) {
the_command = Swap16(script_word_vars.word_17850);
script_byte_vars.dead_flag = 0;
return ScriptRerun;
}
- if(GetZoneObjCommand(2) != 0)
- {
+ if (GetZoneObjCommand(2) != 0) {
PlayAnim(39, found_spot->sx + 8 / 4, found_spot->sy - 10);
RestoreScreenOfSpecialRoom();
return ScriptRerun;
}
}
- if(script_byte_vars.byte_179F9 == 18)
- {
+ if (script_byte_vars.byte_179F9 == 18) {
script_byte_vars.dead_flag = 1;
script_byte_vars.tries_left = 2;
return 0;
}
- ((pers_t*)script_vars[ScrPool8_CurrentPers])->flags |= PERSFLG_80;
+ ((pers_t *)script_vars[ScrPool8_CurrentPers])->flags |= PERSFLG_80;
script_byte_vars.dead_flag = script_byte_vars.cur_spot_idx;
script_byte_vars.tries_left = 2;
the_command = 0;
- if(script_byte_vars.byte_179F9 == 0)
- {
+ if (script_byte_vars.byte_179F9 == 0) {
PlayAnim(39, found_spot->sx + 8 / 4, found_spot->sy - 10);
RestoreScreenOfSpecialRoom();
return ScriptRerun;
@@ -2666,16 +2429,14 @@ unsigned int CMD_D_PsiBrainwarp(void)
}
-unsigned int CMD_E_PsiZoneScan(void)
-{
+unsigned int CMD_E_PsiZoneScan(void) {
unsigned char x, y, w, h;
unsigned int offs;
- if(!ConsumePsiEnergy(1))
+ if (!ConsumePsiEnergy(1))
return 0;
- if(script_byte_vars.byte_179F9 != 0)
- {
+ if (script_byte_vars.byte_179F9 != 0) {
the_command = Swap16(script_word_vars.word_178FC);
return ScriptRerun;
}
@@ -2686,17 +2447,14 @@ unsigned int CMD_E_PsiZoneScan(void)
w = room_bounds_rect.ex - room_bounds_rect.sx;
h = room_bounds_rect.ey - room_bounds_rect.sy;
- for(y = room_bounds_rect.sy;h;y++, h--)
- {
+ for (y = room_bounds_rect.sy; h; y++, h--) {
spot_t *spot;
- for(x = 0;x < w;x++) frontbuffer[offs + x] = ~frontbuffer[offs + x];
+ for (x = 0; x < w; x++) frontbuffer[offs + x] = ~frontbuffer[offs + x];
WaitVBlank();
- for(x = 0;x < w;x++) frontbuffer[offs + x] = ~frontbuffer[offs + x];
+ for (x = 0; x < w; x++) frontbuffer[offs + x] = ~frontbuffer[offs + x];
- for(spot = zone_spots;spot != zone_spots_end;spot++)
- {
- if((spot->flags & ~(SPOTFLG_40 | 7)) == (SPOTFLG_20 | SPOTFLG_8) && spot->sy == y)
- {
+ for (spot = zone_spots; spot != zone_spots_end; spot++) {
+ if ((spot->flags & ~(SPOTFLG_40 | 7)) == (SPOTFLG_20 | SPOTFLG_8) && spot->sy == y) {
PlaySound(27);
spot->flags |= SPOTFLG_80;
PlayAnim(38, spot->sx, spot->sy);
@@ -2705,25 +2463,23 @@ unsigned int CMD_E_PsiZoneScan(void)
}
offs ^= CGA_ODD_LINES_OFS;
- if((offs & CGA_ODD_LINES_OFS) == 0)
+ if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
- }
+ }
RestoreScreenOfSpecialRoom();
the_command = Swap16(script_word_vars.word_17848);
-
+
return ScriptRerun;
}
-unsigned int CMD_F_PsiPsiShift(void)
-{
- if(!ConsumePsiEnergy(3))
+unsigned int CMD_F_PsiPsiShift(void) {
+ if (!ConsumePsiEnergy(3))
return 0;
- if(script_byte_vars.byte_179F9 != 0)
- {
+ if (script_byte_vars.byte_179F9 != 0) {
the_command = Swap16(script_word_vars.word_178F4);
return ScriptRerun;
}
@@ -2735,31 +2491,28 @@ unsigned int CMD_F_PsiPsiShift(void)
PlayAnim(39, cursor_x / 4, cursor_y);
RestoreScreenOfSpecialRoom();
- if(script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(6) == 0)
+ if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(6) == 0)
the_command = Swap16(script_word_vars.word_1784E);
-
+
return ScriptRerun;
}
-unsigned int CMD_10_PsiExtremeViolence(void)
-{
+unsigned int CMD_10_PsiExtremeViolence(void) {
unsigned short command;
- if(!ConsumePsiEnergy(8))
+ if (!ConsumePsiEnergy(8))
return 0;
script_byte_vars.byte_179F3 = 1;
- if(script_byte_vars.byte_179F9 != 0)
- {
+ if (script_byte_vars.byte_179F9 != 0) {
the_command = Swap16(script_word_vars.word_178F6);
return ScriptRerun;
}
ProcessMenu();
- if(script_byte_vars.cur_spot_idx == 0)
- {
+ if (script_byte_vars.cur_spot_idx == 0) {
the_command = Swap16(script_word_vars.word_1784C);
script_byte_vars.byte_179F3 = 0;
return ScriptRerun;
@@ -2767,10 +2520,9 @@ unsigned int CMD_10_PsiExtremeViolence(void)
command = GetZoneObjCommand(8);
- if((command & 0xF000) == 0x9000)
+ if ((command & 0xF000) == 0x9000)
script_byte_vars.byte_179F3 = 0;
- else if(command == 0)
- {
+ else if (command == 0) {
the_command = Swap16(script_word_vars.word_1784C);
script_byte_vars.byte_179F3 = 0;
}
@@ -2778,27 +2530,24 @@ unsigned int CMD_10_PsiExtremeViolence(void)
return ScriptRerun;
}
-unsigned int CMD_11_PsiTuneIn(void)
-{
+unsigned int CMD_11_PsiTuneIn(void) {
unsigned short command;
unsigned char *msg;
- if(!ConsumePsiEnergy(4))
+ if (!ConsumePsiEnergy(4))
return 0;
- if(script_byte_vars.byte_179F9 != 0)
+ if (script_byte_vars.byte_179F9 != 0)
command = Swap16(script_word_vars.word_178F8);
- else
- {
- if(script_byte_vars.byte_179DC < 63 || script_byte_vars.zone_area >= 22)
+ else {
+ if (script_byte_vars.byte_179DC < 63 || script_byte_vars.zone_area >= 22)
command = Swap16(script_word_vars.word_1784A);
else
command = 275;
}
/*TODO: is this really neccessary? Maybe it's always set when loaded from script vars?*/
- if(command & 0x8000)
- {
+ if (command & 0x8000) {
the_command = command;
return ScriptRerun;
}
@@ -2806,7 +2555,7 @@ unsigned int CMD_11_PsiTuneIn(void)
msg = SeekToString(diali_data, command);
cur_dlg_index = cur_str_index; /*TODO: useless?*/
- DrawPersonBubble(32/4, 20, 15, msg);
+ DrawPersonBubble(32 / 4, 20, 15, msg);
PromptWait();
PopDirtyRects(DirtyRectBubble);
@@ -2814,20 +2563,18 @@ unsigned int CMD_11_PsiTuneIn(void)
return 0;
}
-void ActionForPersonChoice(unsigned short *actions)
-{
+void ActionForPersonChoice(unsigned short *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];
+ 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;
- if(index == 93) /*CADAVER*/
+ if (index == 93) /*CADAVER*/
index = 19 + 42;
- else if(index == 133) /*SCI FI*/
+ else if (index == 133) /*SCI FI*/
index = 18 + 42;
- index -= 42; /*Person names: THE MASTER OF ORDEALS, etc*/
+ index -= 42; /*Person names: THE MASTER OF ORDEALS, etc*/
the_command = actions[index];
@@ -2928,15 +2675,13 @@ unsigned short menu_commands_23[] = {
0xC32D
};
-unsigned int CMD_12_(void)
-{
+unsigned int CMD_12_(void) {
printf("cmd 12\n");
ActionForPersonChoice(menu_commands_12);
return ScriptRerun;
}
-unsigned int CMD_13_ActivateFountain(void)
-{
+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};
@@ -2946,17 +2691,16 @@ unsigned int CMD_13_ActivateFountain(void)
unsigned int i, j;
script_byte_vars.byte_17A20 = 1;
- for(i = 0;i < 10;i++)
- {
+ for (i = 0; i < 10; i++) {
DrawRoomStaticObject(water1, &x, &y, &w, &h);
WaitVBlank();
CGA_BackBufferToRealFull();
- for(j = 0;j < 0x1FFF;j++) ; /*TODO: weak delay*/
+ for (j = 0; j < 0x1FFF; j++) ; /*TODO: weak delay*/
DrawRoomStaticObject(water2, &x, &y, &w, &h);
WaitVBlank();
CGA_BackBufferToRealFull();
- for(j = 0;j < 0x1FFF;j++) ; /*TODO: weak delay*/
+ for (j = 0; j < 0x1FFF; j++) ; /*TODO: weak delay*/
}
DrawRoomStaticObject(headl, &x, &y, &w, &h);
@@ -2967,8 +2711,7 @@ unsigned int CMD_13_ActivateFountain(void)
}
/*Vorts walking into the room*/
-unsigned int CMD_14_VortAppear(void)
-{
+unsigned int CMD_14_VortAppear(void) {
/*TODO: check me*/
pers_list[0].area = script_byte_vars.zone_area;
FindAndSelectSpot(0);
@@ -2984,8 +2727,8 @@ unsigned int CMD_14_VortAppear(void)
pers_t *pers_vort_ptr;
struct {
-unsigned char room;
-unsigned char field_1;
+ unsigned char room;
+ unsigned char field_1;
} vortleave[] = {
{ 2, 5},
{ 3, 8},
@@ -3009,26 +2752,20 @@ unsigned char field_1;
};
/*Vorts walking out of the room*/
-unsigned int CMD_15_VortLeave(void)
-{
+unsigned int CMD_15_VortLeave(void) {
/*TODO: check me*/
unsigned int i;
animdesc_t *anim;
pers_t *pers;
- if(pers_list[0].area != 0)
- {
+ if (pers_list[0].area != 0) {
pers = &pers_list[0];
anim = &vortanims_ptr->field_4;
- }
- else if(pers_list[34].area != 0)
- {
+ } else if (pers_list[34].area != 0) {
pers = &pers_list[34];
anim = &vortanims_ptr->field_7;
- }
- else
- {
+ } else {
script_byte_vars.byte_179EC |= 0x80;
pers_list[35].area = 0;
@@ -3040,10 +2777,8 @@ unsigned int CMD_15_VortLeave(void)
pers->area = 0;
next_command3 = 0;
- for(i = 0;i < 19;i++)
- {
- if(vortleave[i].room == script_byte_vars.zone_index)
- {
+ for (i = 0; i < 19; i++) {
+ if (vortleave[i].room == script_byte_vars.zone_index) {
next_command3 = 0xA016;
next_ticks3 = Swap16(script_word_vars.timer_ticks2) + 5;
pers->area = vortleave[i].field_1;
@@ -3051,7 +2786,7 @@ unsigned int CMD_15_VortLeave(void)
}
pers_vort_ptr = pers;
- zone_spots[(pers->flags & 15) - 1].flags &= ~SPOTFLG_80;
+ zone_spots[(pers->flags & 15) - 1].flags &= ~SPOTFLG_80;
FindAndSelectSpot(0);
AnimateSpot(anim);
@@ -3062,15 +2797,13 @@ unsigned int CMD_15_VortLeave(void)
/*
Vorts left the room
*/
-unsigned int CMD_16_VortGone(void)
-{
+unsigned int CMD_16_VortGone(void) {
pers_vort_ptr->area = 0;
next_command3 = 0;
return 0;
}
-unsigned int CMD_18_AspirantLeave(void)
-{
+unsigned int CMD_18_AspirantLeave(void) {
/*TODO: check me*/
static const animdesc_t anim33 = {ANIMFLG_USESPOT | 33};
@@ -3080,8 +2813,7 @@ unsigned int CMD_18_AspirantLeave(void)
pers_ptr->area = 0;
script_word_vars.next_command1 = BE(0);
- if((pers_ptr->flags & PERSFLG_40) == 0)
- {
+ if ((pers_ptr->flags & PERSFLG_40) == 0) {
spot_ptr->flags &= ~SPOTFLG_80;
FindAndSelectSpot(script_byte_vars.quest_item_ofs);
script_byte_vars.byte_179EF = 0;
@@ -3095,8 +2827,7 @@ unsigned int CMD_18_AspirantLeave(void)
/*
Show Holo screen anim and speech
*/
-unsigned int CMD_1B_Holo(void)
-{
+unsigned int CMD_1B_Holo(void) {
unsigned char x, y;
unsigned int num;
unsigned char *msg;
@@ -3104,16 +2835,16 @@ unsigned int CMD_1B_Holo(void)
x = found_spot->sx;
y = found_spot->sy;
- PlayAnim(42, x + 4/4, y + 6);
+ PlayAnim(42, x + 4 / 4, y + 6);
- num = 321 + ((Swap16(script_word_vars.timer_ticks2) < 60*60) ? 0 : 4) + (script_byte_vars.rand_value % 4);
+ num = 321 + ((Swap16(script_word_vars.timer_ticks2) < 60 * 60) ? 0 : 4) + (script_byte_vars.rand_value % 4);
msg = SeekToString(diali_data, num);
cur_dlg_index = cur_str_index; /*TODO: useless?*/
- if(x < 140/4)
- DrawPersonBubble(x + 32/4, y - 40, SPIKE_DNLEFT | 20, msg);
+ if (x < 140 / 4)
+ DrawPersonBubble(x + 32 / 4, y - 40, SPIKE_DNLEFT | 20, msg);
else
- DrawPersonBubble(x - 92/4, y - 40, SPIKE_DNRIGHT | 20, msg);
+ DrawPersonBubble(x - 92 / 4, y - 40, SPIKE_DNRIGHT | 20, msg);
PlayAnim(43, x, y);
@@ -3128,8 +2859,7 @@ unsigned int CMD_1B_Holo(void)
/*
TODO: check me
*/
-unsigned int CMD_20_(void)
-{
+unsigned int CMD_20_(void) {
pers_list[5].area = 0;
next_command4 = 0;
return 0;
@@ -3138,15 +2868,14 @@ unsigned int CMD_20_(void)
/*
Talk to Vorts
*/
-unsigned int CMD_21_VortTalk(void)
-{
+unsigned int CMD_21_VortTalk(void) {
unsigned char x, y;
unsigned int num;
unsigned char *msg;
- if(script_byte_vars.rand_value >= 85)
+ if (script_byte_vars.rand_value >= 85)
num = 6;
- else if(script_byte_vars.rand_value >= 170)
+ else if (script_byte_vars.rand_value >= 170)
num = 7;
else
num = 35;
@@ -3157,10 +2886,10 @@ unsigned int CMD_21_VortTalk(void)
x = found_spot->sx;
y = found_spot->sy;
- if(x < 140/4)
+ if (x < 140 / 4)
DrawPersonBubble(found_spot->ex, y - 40, SPIKE_DNLEFT | 20, msg);
else
- DrawPersonBubble(x - 80/4, y - 40, SPIKE_DNRIGHT | 20, msg);
+ DrawPersonBubble(x - 80 / 4, y - 40, SPIKE_DNRIGHT | 20, msg);
PromptWait();
PopDirtyRects(DirtyRectBubble);
@@ -3168,37 +2897,32 @@ unsigned int CMD_21_VortTalk(void)
return 0;
}
-unsigned int CMD_22_(void)
-{
+unsigned int CMD_22_(void) {
ActionForPersonChoice(menu_commands_22);
return ScriptRerun;
}
-unsigned int CMD_23_(void)
-{
+unsigned int CMD_23_(void) {
ActionForPersonChoice(menu_commands_23);
return ScriptRerun;
}
-unsigned int CMD_24_(void)
-{
+unsigned int CMD_24_(void) {
ActionForPersonChoice(menu_commands_24);
return ScriptRerun;
}
-unsigned int CMD_25_LoadGame(void)
-{
- if(LoadScena())
- the_command = 0x918F; /*error loading*/
+unsigned int CMD_25_LoadGame(void) {
+ if (LoadScena())
+ the_command = 0x918F; /*error loading*/
else
the_command = 0x90AA;
return ScriptRerun;
}
-unsigned int CMD_26_SaveGame(void)
-{
- if(SaveScena())
- the_command = 0x9190; /*error saving*/
+unsigned int CMD_26_SaveGame(void) {
+ if (SaveScena())
+ the_command = 0x9190; /*error saving*/
else
the_command = 0x90AA;
return ScriptRerun;
@@ -3225,7 +2949,7 @@ cmdhandler_t command_handlers[] = {
CMD_D_PsiBrainwarp,
CMD_E_PsiZoneScan,
CMD_F_PsiPsiShift,
- CMD_10_PsiExtremeViolence, /*10*/
+ CMD_10_PsiExtremeViolence, /*10*/
CMD_11_PsiTuneIn,
CMD_12_,
CMD_13_ActivateFountain,
@@ -3241,14 +2965,14 @@ cmdhandler_t command_handlers[] = {
CMD_TRAP,
CMD_TRAP,
CMD_TRAP,
- CMD_TRAP, /*20*/
+ CMD_TRAP, /*20*/
CMD_21_VortTalk,
CMD_22_,
CMD_23_,
CMD_24_,
CMD_25_LoadGame,
CMD_26_SaveGame
- };
+};
#define MAX_CMD_HANDLERS (sizeof(command_handlers) / sizeof(command_handlers[0]))
cmdhandler_t script_handlers[] = {
@@ -3268,7 +2992,7 @@ cmdhandler_t script_handlers[] = {
SCR_D_DrawPortraitDotEffect,
SCR_E_DrawPortraitZoomIn,
SCR_TRAP,
- SCR_TRAP, /*10*/
+ SCR_TRAP, /*10*/
SCR_11_DrawRoomObject,
SCR_12_Chain,
SCR_13_RedrawRoomStatics,
@@ -3281,11 +3005,11 @@ cmdhandler_t script_handlers[] = {
SCR_1A_HidePortraitLiftRight,
SCR_1B_HidePortraitLiftUp,
SCR_1C_HidePortraitLiftDown,
- SCR_TRAP, /*TODO: same as SCR_23_HidePortrait , unused*/
+ SCR_TRAP, /*TODO: same as SCR_23_HidePortrait , unused*/
SCR_1E_HidePortraitTwist,
SCR_1F_HidePortraitArc,
- SCR_20_HidePortraitDots, /*20*/
- SCR_TRAP, /*TODO: same as SCR_23_HidePortrait , unused*/
+ SCR_20_HidePortraitDots, /*20*/
+ SCR_TRAP, /*TODO: same as SCR_23_HidePortrait , unused*/
SCR_22_HidePortraitShatter,
SCR_23_HidePortrait,
SCR_24_PopAllPortraits,
@@ -3300,7 +3024,7 @@ cmdhandler_t script_handlers[] = {
SCR_2D_Wait,
SCR_2E_PromptWait,
SCR_TRAP,
- SCR_30_Fight, /*30*/
+ SCR_30_Fight, /*30*/
SCR_31_Fight2,
SCR_32_FightWin,
SCR_33_Jump,
@@ -3316,7 +3040,7 @@ cmdhandler_t script_handlers[] = {
SCR_3D_ActionsMenu,
SCR_3E_TheWallAdvance,
SCR_TRAP,
- SCR_40_PopAllTextBoxes, /*40*/
+ SCR_40_PopAllTextBoxes, /*40*/
SCR_41_LiftHand,
SCR_42_LoadZone,
SCR_43_RefreshZone,
@@ -3332,7 +3056,7 @@ cmdhandler_t script_handlers[] = {
SCR_TRAP,
SCR_4E_BounceCurrentItemToRoom,
SCR_4F_BounceCurrentItemToInventory,
- SCR_50_BounceItemToInventory, /*50*/
+ SCR_50_BounceItemToInventory, /*50*/
SCR_51_ItemTrade,
SCR_52_RefreshSpritesData,
SCR_53_FindInvItem,
@@ -3348,7 +3072,7 @@ cmdhandler_t script_handlers[] = {
SCR_TRAP,
SCR_TRAP,
SCR_5F_DrawRoomObjectBack,
- SCR_TRAP, /*60*/
+ SCR_TRAP, /*60*/
SCR_61_DrawPersonBubbleDialog,
SCR_TRAP,
SCR_TRAP,
@@ -3359,7 +3083,7 @@ cmdhandler_t script_handlers[] = {
SCR_68_Unused,
SCR_69_PlaySound,
SCR_6A_Unused,
- };
+};
#define MAX_SCR_HANDLERS (sizeof(script_handlers) / sizeof(script_handlers[0]))
#ifdef DEBUG_SCRIPT
@@ -3367,8 +3091,7 @@ int runscr_reentr = 0;
int runcmd_reentr = 0;
#endif
-unsigned int RunScript(unsigned char *code)
-{
+unsigned int RunScript(unsigned char *code) {
unsigned int status = ScriptContinue;
#ifdef DEBUG_SCRIPT
@@ -3376,15 +3099,13 @@ unsigned int RunScript(unsigned char *code)
#endif
script_ptr = code;
- while(script_ptr != script_end_ptr)
- {
+ while (script_ptr != script_end_ptr) {
unsigned char opcode = *script_ptr;
#ifdef DEBUG_SCRIPT
{
FILE *f = fopen(DEBUG_SCRIPT_LOG, "at");
- if(f)
- {
+ if (f) {
unsigned int offs = (script_ptr - templ_data) & 0xFFFF;
fprintf(f, "%04X: %02X\n", offs, opcode);
fclose(f);
@@ -3393,20 +3114,19 @@ unsigned int RunScript(unsigned char *code)
#endif
#ifdef DEBUG_QUEST
- if(script_ptr - templ_data == 0x4F)
- {
+ if (script_ptr - templ_data == 0x4F) {
/*manipulate rand_value to get a quest item we need*/
script_byte_vars.rand_value = DEBUG_QUEST;
}
#endif
- if(opcode == 0 || opcode >= 107)
+ if (opcode == 0 || opcode >= 107)
break;
status = script_handlers[opcode]();
- if(status != ScriptContinue)
+ if (status != ScriptContinue)
break;
}
@@ -3417,26 +3137,24 @@ unsigned int RunScript(unsigned char *code)
return status;
}
-unsigned char * GetScriptSubroutine(unsigned int index)
-{
+unsigned char *GetScriptSubroutine(unsigned int index) {
return SeekToEntry(templ_data, index, &script_end_ptr);
}
-unsigned int RunCommand(void)
-{
+unsigned int RunCommand(void) {
unsigned int res;
unsigned short cmd;
-again:;
+again:
+ ;
res = 0;
- if(the_command == 0)
+ if (the_command == 0)
return 0;
#ifdef DEBUG_SCRIPT
{
FILE *f = fopen(DEBUG_SCRIPT_LOG, "at");
- if(f)
- {
+ if (f) {
fprintf(f, "\nRunCommand 0x%04X rc: %d rs: %d\n", the_command, runcmd_reentr, runscr_reentr);
fclose(f);
}
@@ -3447,10 +3165,9 @@ again:;
#endif
cmd = the_command & 0x3FF;
-
- switch(the_command & 0xF000)
- {
- case 0: /*TODO what kind of call is this?*/
+
+ switch (the_command & 0xF000) {
+ case 0: /*TODO what kind of call is this?*/
res = RunScript(templ_data + the_command);
break;
case 0x9000:
@@ -3475,8 +3192,7 @@ again:;
#ifdef DEBUG_SCRIPT
{
FILE *f = fopen(DEBUG_SCRIPT_LOG, "at");
- if(f)
- {
+ if (f) {
fprintf(f, "\n");
fclose(f);
}
@@ -3484,14 +3200,13 @@ again:;
#endif
/*TODO: this is pretty hacky, original code manipulates the stack to discard old script invocation*/
- if(res == ScriptRerun)
+ if (res == ScriptRerun)
goto again;
return res;
}
-unsigned int RunCommandKeepSp(void)
-{
+unsigned int RunCommandKeepSp(void) {
/*keep_sp = sp;*/
return RunCommand();
}
diff --git a/engines/chamber/script.h b/engines/chamber/script.h
index f84523a9cad..d9de5dd59d3 100644
--- a/engines/chamber/script.h
+++ b/engines/chamber/script.h
@@ -19,139 +19,139 @@ 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 byte_179F4; /* 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 byte_17A1E; /* 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 */
+ 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 byte_179F4; /* 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 byte_17A1E; /* 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 */
} script_byte_vars_t;
/*2-byte long vars, in BIG-endian order*/
typedef struct script_word_vars_t {
-unsigned short word_17844; /* 0 */
-unsigned short word_17846; /* 2 */
-unsigned short word_17848; /* 4 */
-unsigned short word_1784A; /* 6 */
-unsigned short word_1784C; /* 8 */
-unsigned short word_1784E; /* A */
-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 */
+ unsigned short word_17844; /* 0 */
+ unsigned short word_17846; /* 2 */
+ unsigned short word_17848; /* 4 */
+ unsigned short word_1784A; /* 6 */
+ unsigned short word_1784C; /* 8 */
+ unsigned short word_1784E; /* A */
+ 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 */
} script_word_vars_t;
extern void *script_vars[ScrPools_MAX];
@@ -171,9 +171,9 @@ extern script_byte_vars_t script_byte_vars;
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*/
+ 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*/
} item_t;
#if sizeof(item_t) != 6
@@ -192,7 +192,7 @@ unsigned int RandW(void);
extern unsigned short the_command;
-unsigned char * GetScriptSubroutine(unsigned int index);
+unsigned char *GetScriptSubroutine(unsigned int index);
unsigned int RunCommand(void);
unsigned int RunCommandKeepSp(void);
diff --git a/engines/chamber/scrvars.h b/engines/chamber/scrvars.h
index 884a403a16a..bb12eafb686 100644
--- a/engines/chamber/scrvars.h
+++ b/engines/chamber/scrvars.h
@@ -1,142 +1,142 @@
script_byte_vars_t script_byte_vars = {
- 135, /* 0 */
- 0, /* 1 */
- 0, /* 2 */
- 0, /* 3 */
- 0, /* 4 */
- 0, /* 5 */
- 1, /* 6 */
- 0, /* 7 */
- 0, /* 8 */
- 0, /* 9 */
- 0, /* A */
- 0, /* B */
- 0, /* C */
- 0, /* D */
- 0, /* E */
- 0, /* F */
+ 135, /* 0 */
+ 0, /* 1 */
+ 0, /* 2 */
+ 0, /* 3 */
+ 0, /* 4 */
+ 0, /* 5 */
+ 1, /* 6 */
+ 0, /* 7 */
+ 0, /* 8 */
+ 0, /* 9 */
+ 0, /* A */
+ 0, /* B */
+ 0, /* C */
+ 0, /* D */
+ 0, /* E */
+ 0, /* F */
- 0, /* 10 */
- 0, /* 11 */
- 0, /* 12 */
- 0, /* 13 */
- 0, /* 14 */
- 0, /* 15 */
- 0, /* 16 */
- 0, /* 17 */
- 0, /* 18 */
- 0, /* 19 */
- 0, /* 1A */
- 0, /* 1B */
- 0, /* 1C */
- 0, /* 1D */
- 0, /* 1E */
- 0, /* 1F */
+ 0, /* 10 */
+ 0, /* 11 */
+ 0, /* 12 */
+ 0, /* 13 */
+ 0, /* 14 */
+ 0, /* 15 */
+ 0, /* 16 */
+ 0, /* 17 */
+ 0, /* 18 */
+ 0, /* 19 */
+ 0, /* 1A */
+ 0, /* 1B */
+ 0, /* 1C */
+ 0, /* 1D */
+ 0, /* 1E */
+ 0, /* 1F */
- 0, /* 20 */
- 0, /* 21 */
- 0, /* 22 */
- 0, /* 23 */
- 0xB, /* 24 */
- 0, /* 25 */
- 0, /* 26 */
- 0, /* 27 */
- 0, /* 28 */
- 0, /* 29 */
- 0, /* 2A */
- 0, /* 2B */
- 0, /* 2C */
- 0, /* 2D */
- 0, /* 2E */
- 0, /* 2F */
+ 0, /* 20 */
+ 0, /* 21 */
+ 0, /* 22 */
+ 0, /* 23 */
+ 0xB, /* 24 */
+ 0, /* 25 */
+ 0, /* 26 */
+ 0, /* 27 */
+ 0, /* 28 */
+ 0, /* 29 */
+ 0, /* 2A */
+ 0, /* 2B */
+ 0, /* 2C */
+ 0, /* 2D */
+ 0, /* 2E */
+ 0, /* 2F */
- 0, /* 30 */
- 0, /* 31 */
- 0, /* 32 */
- 0, /* 33 */
- 0, /* 34 */
- 0, /* 35 */
- 0, /* 36 */
- 0, /* 37 */
- 0, /* 38 */
- 0, /* 39 */
- 0, /* 3A */
- 0, /* 3B */
- 0, /* 3C */
- 0, /* 3D */
- 0, /* 3E */
- 0, /* 3F */
+ 0, /* 30 */
+ 0, /* 31 */
+ 0, /* 32 */
+ 0, /* 33 */
+ 0, /* 34 */
+ 0, /* 35 */
+ 0, /* 36 */
+ 0, /* 37 */
+ 0, /* 38 */
+ 0, /* 39 */
+ 0, /* 3A */
+ 0, /* 3B */
+ 0, /* 3C */
+ 0, /* 3D */
+ 0, /* 3E */
+ 0, /* 3F */
- 0, /* 40 */
- 0, /* 41 */
- 0, /* 42 */
- 0, /* 43 */
- 0, /* 44 */
- 0, /* 45 */
- 0, /* 46 */
- 1, /* 47 */
- 0, /* 48 */
- 0xFF, /* 49 */
- 0, /* 4A */
- 0, /* 4B */
- 0, /* 4C */
- 0, /* 4D */
- 0, /* 4E */
- 0, /* 4F */
+ 0, /* 40 */
+ 0, /* 41 */
+ 0, /* 42 */
+ 0, /* 43 */
+ 0, /* 44 */
+ 0, /* 45 */
+ 0, /* 46 */
+ 1, /* 47 */
+ 0, /* 48 */
+ 0xFF, /* 49 */
+ 0, /* 4A */
+ 0, /* 4B */
+ 0, /* 4C */
+ 0, /* 4D */
+ 0, /* 4E */
+ 0, /* 4F */
- 0, /* 50 */
- 0, /* 51 */
- 0, /* 52 */
- 0, /* 53 */
- 2, /* 54 */
- 1, /* 55 */
- 0, /* 56 */
- 0, /* 57 */
- 0, /* 58 */
- 0, /* 59 */
- 63, /* 5A */
- 0, /* 5B */
- 0, /* 5C */
- 0, /* 5D */
- 0, /* 5E */
- 0, /* 5F */
+ 0, /* 50 */
+ 0, /* 51 */
+ 0, /* 52 */
+ 0, /* 53 */
+ 2, /* 54 */
+ 1, /* 55 */
+ 0, /* 56 */
+ 0, /* 57 */
+ 0, /* 58 */
+ 0, /* 59 */
+ 63, /* 5A */
+ 0, /* 5B */
+ 0, /* 5C */
+ 0, /* 5D */
+ 0, /* 5E */
+ 0, /* 5F */
- 0, /* 60 */
- 0, /* 61 */
- 1, /* 62 */
- 0, /* 63 */
- 0, /* 64 */
- 0, /* 65 */
- 0, /* 66 */
- 0, /* 67 */
- 0, /* 68 */
- 0, /* 69 */
- 0, /* 6A */
- 0, /* 6B */
- 0, /* 6C */
- /*{0,0,0,0}*/ /* 6D..70 */
+ 0, /* 60 */
+ 0, /* 61 */
+ 1, /* 62 */
+ 0, /* 63 */
+ 0, /* 64 */
+ 0, /* 65 */
+ 0, /* 66 */
+ 0, /* 67 */
+ 0, /* 68 */
+ 0, /* 69 */
+ 0, /* 6A */
+ 0, /* 6B */
+ 0, /* 6C */
+ /*{0,0,0,0}*/ /* 6D..70 */
};
script_word_vars_t script_word_vars = {
- BE(0x9007), /* 00 */
- BE(0x9007), /* 02 */
- BE(0x9007), /* 04 */
- BE(0x9007), /* 06 */
- BE(0x9007), /* 08 */
- BE(0x9007), /* 0A */
- BE( 0), /* 0C */
- BE( 0), /* 0E */
- BE( 0), /* 10 */
+ BE(0x9007), /* 00 */
+ BE(0x9007), /* 02 */
+ BE(0x9007), /* 04 */
+ BE(0x9007), /* 06 */
+ BE(0x9007), /* 08 */
+ BE(0x9007), /* 0A */
+ BE(0), /* 0C */
+ BE(0), /* 0E */
+ BE(0), /* 10 */
{0}, /* 12 */
- BE( 0), /* A8 */
- BE( 0), /* AA */
- BE( 0), /* AC */
- BE( 0), /* AE */
- BE( 0), /* B0 */
- BE( 0), /* B2 */
- BE( 0), /* B4 */
- BE( 0), /* B6 */
- BE( 0) /* B8 */
+ BE(0), /* A8 */
+ BE(0), /* AA */
+ BE(0), /* AC */
+ BE(0), /* AE */
+ BE(0), /* B0 */
+ BE(0), /* B2 */
+ BE(0), /* B4 */
+ BE(0), /* B6 */
+ BE(0) /* B8 */
};
item_t inventory_items[MAX_INV_ITEMS] = {
diff --git a/engines/chamber/sound.cpp b/engines/chamber/sound.cpp
index c4f111add02..52aa687779d 100644
--- a/engines/chamber/sound.cpp
+++ b/engines/chamber/sound.cpp
@@ -1,7 +1,6 @@
#include "common.h"
#include "sound.h"
-void PlaySound(unsigned char index)
-{
+void PlaySound(unsigned char index) {
/*TODO*/
}
diff --git a/engines/chamber/timer.cpp b/engines/chamber/timer.cpp
index f70d38c2f9f..2f9140a3fe1 100644
--- a/engines/chamber/timer.cpp
+++ b/engines/chamber/timer.cpp
@@ -4,46 +4,40 @@
#include "script.h"
#include "resdata.h"
-void AnimateGauss(unsigned char *target)
-{
+void AnimateGauss(unsigned char *target) {
unsigned char *sprite;
unsigned char phase = Rand() % 4;
- if(phase == script_byte_vars.gauss_phase)
+ if (phase == script_byte_vars.gauss_phase)
phase = (phase + 1) % 4;
script_byte_vars.gauss_phase = phase;
sprite = gauss_data + 8 + phase * (8 * 30);
- CGA_Blit(sprite, 8, 8, 30, target, 80); /*draw to 0:4*/
+ CGA_Blit(sprite, 8, 8, 30, target, 80); /*draw to 0:4*/
}
-void interrupt (*old_timer_isr)();
+void interrupt(*old_timer_isr)();
-void interrupt TimerIsr()
-{
+void interrupt TimerIsr() {
disable();
script_byte_vars.timer_ticks++;
- if(!script_byte_vars.game_paused)
- {
- if(script_byte_vars.timer_ticks % 16 == 0)
- {
+ if (!script_byte_vars.game_paused) {
+ if (script_byte_vars.timer_ticks % 16 == 0) {
script_word_vars.timer_ticks2 = Swap16(Swap16(script_word_vars.timer_ticks2) + 1);
#if 1
- AnimateGauss(frontbuffer);
+ AnimateGauss(frontbuffer);
#endif
}
}
enable();
}
-void InitTimer(void)
-{
+void InitTimer(void) {
disable();
old_timer_isr = getvect(0x1C);
setvect(0x1C, TimerIsr);
enable();
}
-void UninitTimer(void)
-{
+void UninitTimer(void) {
disable();
setvect(0x1C, old_timer_isr);
enable();
Commit: 9d434a34fb33ce51d61c4be7a4a85afc2abd8284
https://github.com/scummvm/scummvm/commit/9d434a34fb33ce51d61c4be7a4a85afc2abd8284
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Renamed main file
Changed paths:
A engines/chamber/kult.cpp
R engines/chamber/chamber.cpp
diff --git a/engines/chamber/chamber.cpp b/engines/chamber/kult.cpp
similarity index 100%
rename from engines/chamber/chamber.cpp
rename to engines/chamber/kult.cpp
Commit: 0ac7c435737a296dc930c899b395c91a52c9d926
https://github.com/scummvm/scummvm/commit/0ac7c435737a296dc930c899b395c91a52c9d926
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Add the engine skeleton
Changed paths:
A engines/chamber/chamber.cpp
A engines/chamber/chamber.h
A engines/chamber/configure.engine
A engines/chamber/credits.pl
A engines/chamber/detection.cpp
A engines/chamber/metaengine.cpp
A engines/chamber/module.mk
diff --git a/engines/chamber/chamber.cpp b/engines/chamber/chamber.cpp
new file mode 100644
index 00000000000..fa76e0eb706
--- /dev/null
+++ b/engines/chamber/chamber.cpp
@@ -0,0 +1,101 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "common/config-manager.h"
+#include "common/debug.h"
+#include "common/error.h"
+#include "common/events.h"
+#include "common/file.h"
+#include "common/fs.h"
+#include "common/system.h"
+
+#include "engines/util.h"
+
+#include "chamber/chamber.h"
+
+namespace Chamber {
+
+ChamberEngine::ChamberEngine(OSystem *syst)
+ : Engine(syst) {
+ const Common::FSNode gameDataDir(ConfMan.get("path"));
+
+ // Don't forget to register your random source
+ _rnd = new Common::RandomSource("chamber");
+
+ debug("ChamberEngine::ChamberEngine");
+}
+
+ChamberEngine::~ChamberEngine() {
+ debug("ChamberEngine::~ChamberEngine");
+
+ // Dispose your resources here
+ delete _rnd;
+}
+
+Common::Error ChamberEngine::run() {
+ // Initialize graphics using following:
+ initGraphics(320, 200);
+
+ // Additional setup.
+ debug("ChamberEngine::init");
+
+ // Your main even loop should be (invoked from) here.
+ debug("ChamberEngine::go: Hello, World!");
+
+ // Simple main event loop
+ Common::Event evt;
+ while (!shouldQuit()) {
+ g_system->getEventManager()->pollEvent(evt);
+ g_system->delayMillis(10);
+ }
+
+ return Common::kNoError;
+}
+
+bool ChamberEngine::hasFeature(EngineFeature f) const {
+ return
+ (f == kSupportsReturnToLauncher) ||
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime);
+}
+
+Common::Error ChamberEngine::loadGameStream(Common::SeekableReadStream *stream) {
+ Common::Serializer s(stream, nullptr);
+ syncGameStream(s);
+ return Common::kNoError;
+}
+
+Common::Error ChamberEngine::saveGameStream(Common::WriteStream *stream, bool isAutosave) {
+ Common::Serializer s(nullptr, stream);
+ syncGameStream(s);
+ return Common::kNoError;
+}
+
+void ChamberEngine::syncGameStream(Common::Serializer &s) {
+ // Use methods of Serializer to save/load fields
+ int dummy = 0;
+ s.syncAsUint16LE(dummy);
+}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/chamber.h b/engines/chamber/chamber.h
new file mode 100644
index 00000000000..59621f40cf8
--- /dev/null
+++ b/engines/chamber/chamber.h
@@ -0,0 +1,54 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_H
+#define CHAMBER_H
+
+#include "common/random.h"
+#include "common/serializer.h"
+#include "engines/engine.h"
+#include "gui/debugger.h"
+
+namespace Chamber {
+
+class Console;
+
+class ChamberEngine : public Engine {
+private:
+ // We need random numbers
+ Common::RandomSource *_rnd;
+public:
+ ChamberEngine(OSystem *syst);
+ ~ChamberEngine();
+
+ Common::Error run() override;
+ bool hasFeature(EngineFeature f) const override;
+ bool canLoadGameStateCurrently() override { return true; }
+ bool canSaveGameStateCurrently() override { return true; }
+ Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
+ Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
+ void syncGameStream(Common::Serializer &s);
+};
+
+} // End of namespace Chamber
+
+#endif
diff --git a/engines/chamber/configure.engine b/engines/chamber/configure.engine
new file mode 100644
index 00000000000..77c195434e8
--- /dev/null
+++ b/engines/chamber/configure.engine
@@ -0,0 +1,3 @@
+# This file is included from the main "configure" script
+# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps]
+add_engine chamber "Chamber" no
diff --git a/engines/chamber/credits.pl b/engines/chamber/credits.pl
new file mode 100644
index 00000000000..f8601f38f53
--- /dev/null
+++ b/engines/chamber/credits.pl
@@ -0,0 +1,4 @@
+begin_section("Chamber");
+ add_person("Retro-Junk;", "bambarbee", "");
+ add_person("Eugene Sandulenko", "sev", "");
+end_section();
diff --git a/engines/chamber/detection.cpp b/engines/chamber/detection.cpp
new file mode 100644
index 00000000000..ebab5644510
--- /dev/null
+++ b/engines/chamber/detection.cpp
@@ -0,0 +1,66 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "base/plugins.h"
+#include "engines/advancedDetector.h"
+
+namespace Chamber {
+static const PlainGameDescriptor ChamberGames[] = {
+ {"chamber", "Chamber of the Sci-Mutant Priestess"},
+ { 0, 0 }
+};
+
+
+static const ADGameDescription gameDescriptions[] = {
+ {
+ "chamber",
+ "",
+ AD_ENTRY1s("desce.bin", "d6b2b07bbb6b6d5a292c17536ad7dd44", 10419),
+ Common::EN_ANY,
+ Common::kPlatformDOS,
+ ADGF_UNSTABLE,
+ GUIO0()
+ },
+
+ AD_TABLE_END_MARKER
+};
+} // End of namespace Chamber
+
+class ChamberMetaEngineDetection : public AdvancedMetaEngineDetection {
+public:
+ ChamberMetaEngineDetection() : AdvancedMetaEngineDetection(Chamber::gameDescriptions, sizeof(ADGameDescription), Chamber::ChamberGames) {
+ }
+
+ const char *getName() const override {
+ return "chamber";
+ }
+
+ const char *getEngineName() const override {
+ return "chamber";
+ }
+
+ const char *getOriginalCopyright() const override {
+ return "Chamber (C) 1989 ERE Informatique";
+ }
+};
+
+REGISTER_PLUGIN_STATIC(CHAMBER_DETECTION, PLUGIN_TYPE_ENGINE_DETECTION, ChamberMetaEngineDetection);
diff --git a/engines/chamber/metaengine.cpp b/engines/chamber/metaengine.cpp
new file mode 100644
index 00000000000..d2ce107dfbf
--- /dev/null
+++ b/engines/chamber/metaengine.cpp
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "engines/advancedDetector.h"
+
+class ChamberMetaEngine : public AdvancedMetaEngine {
+public:
+ const char *getName() const override {
+ return "chamber";
+ }
+
+ Common::Error createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override;
+};
+
+Common::Error ChamberMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
+ *engine = new Chamber::ChamberEngine(syst);
+ return Common::kNoError;
+}
+
+#if PLUGIN_ENABLED_DYNAMIC(CHAMBER)
+REGISTER_PLUGIN_DYNAMIC(CHAMBER, PLUGIN_TYPE_ENGINE, ChamberMetaEngine);
+#else
+REGISTER_PLUGIN_STATIC(CHAMBER, PLUGIN_TYPE_ENGINE, ChamberMetaEngine);
+#endif
diff --git a/engines/chamber/module.mk b/engines/chamber/module.mk
new file mode 100644
index 00000000000..7e089ed9c41
--- /dev/null
+++ b/engines/chamber/module.mk
@@ -0,0 +1,19 @@
+MODULE := engines/chamber
+
+MODULE_OBJS := \
+ metaengine.o \
+ chamber.o
+
+MODULE_DIRS += \
+ engines/chamber
+
+# This module can be built as a plugin
+ifeq ($(ENABLE_CHAMBER), DYNAMIC_PLUGIN)
+PLUGIN := 1
+endif
+
+# Include common rules
+include $(srcdir)/rules.mk
+
+# Detection objects
+DETECT_OBJS += $(MODULE)/detection.o
Commit: c6c4e2146ce71db2928b125199f1ee4e15ac3321
https://github.com/scummvm/scummvm/commit/c6c4e2146ce71db2928b125199f1ee4e15ac3321
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Added standard ScummVM header and guard defines
Changed paths:
engines/chamber/anim.cpp
engines/chamber/anim.h
engines/chamber/bkbuff.cpp
engines/chamber/cga.cpp
engines/chamber/cga.h
engines/chamber/common.h
engines/chamber/cursor.cpp
engines/chamber/cursor.h
engines/chamber/decompr.cpp
engines/chamber/decompr.h
engines/chamber/dialog.cpp
engines/chamber/dialog.h
engines/chamber/input.cpp
engines/chamber/input.h
engines/chamber/invent.cpp
engines/chamber/invent.h
engines/chamber/kult.cpp
engines/chamber/menu.cpp
engines/chamber/menu.h
engines/chamber/portrait.cpp
engines/chamber/portrait.h
engines/chamber/print.cpp
engines/chamber/print.h
engines/chamber/r_other.cpp
engines/chamber/r_pers.cpp
engines/chamber/r_puzzl.cpp
engines/chamber/r_sprit.cpp
engines/chamber/r_templ.cpp
engines/chamber/r_texts.cpp
engines/chamber/resdata.cpp
engines/chamber/resdata.h
engines/chamber/room.cpp
engines/chamber/room.h
engines/chamber/savegame.cpp
engines/chamber/savegame.h
engines/chamber/script.cpp
engines/chamber/script.h
engines/chamber/scrvars.h
engines/chamber/sound.cpp
engines/chamber/sound.h
engines/chamber/timer.cpp
engines/chamber/timer.h
diff --git a/engines/chamber/anim.cpp b/engines/chamber/anim.cpp
index 80c481e047b..37e0a9d0ec4 100644
--- a/engines/chamber/anim.cpp
+++ b/engines/chamber/anim.cpp
@@ -1,8 +1,35 @@
-#include "common.h"
-#include "resdata.h"
-#include "cga.h"
-#include "room.h"
-#include "sound.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+
+#include "chamber/common.h"
+#include "chamber/resdata.h"
+#include "chamber/cga.h"
+#include "chamber/room.h"
+#include "chamber/sound.h"
+
+namespace Chamber {
+
unsigned char far *anima_end_ofs;
@@ -298,3 +325,5 @@ void PlayAnim(unsigned char index, unsigned char x, unsigned char y) {
}
}
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/anim.h b/engines/chamber/anim.h
index 176fc0824a9..c9b5d746dbf 100644
--- a/engines/chamber/anim.h
+++ b/engines/chamber/anim.h
@@ -1,5 +1,29 @@
-#ifndef _ANIM_H_
-#define _ANIM_H_
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_ANIM_H
+#define CHAMBER_ANIM_H
+
+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);
@@ -7,4 +31,6 @@ void CopyScreenBlockWithDotEffect(unsigned char *source, unsigned char x, unsign
extern unsigned char dot_effect_step;
extern unsigned int dot_effect_delay;
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/bkbuff.cpp b/engines/chamber/bkbuff.cpp
index 05874d4ce39..d533490466c 100644
--- a/engines/chamber/bkbuff.cpp
+++ b/engines/chamber/bkbuff.cpp
@@ -1 +1,31 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+
+namespace Chamber {
+
+
unsigned char backbuffer[0x4000];
+
+} // End of namespace Chamber
+
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index b9b66cdcb6f..c31df1c487f 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -1,10 +1,33 @@
-#include <dos.h>
-#include <assert.h>
-#include <string.h>
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+
+#include "chamber/common.h"
+#include "chamber/resdata.h"
+#include "chamber/cga.h"
+
+namespace Chamber {
-#include "common.h"
-#include "resdata.h"
-#include "cga.h"
extern unsigned char backbuffer[0x4000];
@@ -970,3 +993,5 @@ void CGA_TraceLine(unsigned int sx, unsigned int ex, unsigned int sy, unsigned i
target[ofs] = (target[ofs] & ~mask) | (source[ofs] & mask);
}
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/cga.h b/engines/chamber/cga.h
index 7e91711dd17..c043536a545 100644
--- a/engines/chamber/cga.h
+++ b/engines/chamber/cga.h
@@ -1,7 +1,29 @@
-#ifndef _CGA_H_
-#define _CGA_H_
-
-#include <dos.h>
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_CGA_H
+#define CHAMBER_CGA_H
+
+namespace Chamber {
#define CGA_WIDTH 320
#define CGA_HEIGHT 200
@@ -101,4 +123,6 @@ void CGA_HideShatterFall(unsigned char *screen, unsigned char *source, unsigned
void CGA_TraceLine(unsigned int sx, unsigned int ex, unsigned int sy, unsigned int ey, unsigned char *source, unsigned char *target);
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/common.h b/engines/chamber/common.h
index ed4ca3146fd..e4ae62840c4 100644
--- a/engines/chamber/common.h
+++ b/engines/chamber/common.h
@@ -1,5 +1,29 @@
-#ifndef _COMMON_H_
-#define _COMMON_H_
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_COMMON_H
+#define CHAMBER_COMMON_H
+
+namespace Chamber {
#define BE(x) (((x) >> 8) | ((x) << 8))
#define LE16(x) (x)
@@ -54,4 +78,6 @@ typedef struct rect_t {
#define CHEAT
#endif
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/cursor.cpp b/engines/chamber/cursor.cpp
index 03e9a7a6a04..80972691afc 100644
--- a/engines/chamber/cursor.cpp
+++ b/engines/chamber/cursor.cpp
@@ -1,7 +1,34 @@
-#include "common.h"
-#include "cursor.h"
-#include "resdata.h"
-#include "cga.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/cursor.h"
+#include "chamber/resdata.h"
+#include "chamber/cga.h"
+
+
+namespace Chamber {
+
unsigned char cursor_color = 0;
@@ -154,3 +181,5 @@ void UpdateUndrawCursor(unsigned char *target) {
UpdateCursor();
UndrawCursor(target);
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/cursor.h b/engines/chamber/cursor.h
index 7f091b443d9..748be23702e 100644
--- a/engines/chamber/cursor.h
+++ b/engines/chamber/cursor.h
@@ -1,5 +1,29 @@
-#ifndef _CURSOR_H_
-#define _CURSOR_H_
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_CURSOR_H
+#define CHAMBER_CURSOR_H
+
+namespace Chamber {
#define CURSOR_WIDTH 16
#define CURSOR_HEIGHT 16
@@ -31,4 +55,6 @@ void DrawCursor(unsigned char *target);
void UndrawCursor(unsigned char *target);
void UpdateUndrawCursor(unsigned char *target);
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/decompr.cpp b/engines/chamber/decompr.cpp
index 195073a47f8..3f4366fd787 100644
--- a/engines/chamber/decompr.cpp
+++ b/engines/chamber/decompr.cpp
@@ -1,3 +1,30 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+
+namespace Chamber {
+
+
static struct {
unsigned char codes[256];
unsigned char prefix[256];
@@ -89,3 +116,6 @@ unsigned long decompress(unsigned char huge *data, unsigned char huge *result) {
return decompsize;
}
+
+} // End of namespace Chamber
+
diff --git a/engines/chamber/decompr.h b/engines/chamber/decompr.h
index e0028a424d2..0b3263ec39b 100644
--- a/engines/chamber/decompr.h
+++ b/engines/chamber/decompr.h
@@ -1 +1,31 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_DECOMPR_H
+#define CHAMBER_DECOMPR_H
+
+namespace Chamber {
unsigned long decompress(unsigned char huge *data, unsigned char huge *result);
+
+} // End of namespace Chamber
+
+#endif
diff --git a/engines/chamber/dialog.cpp b/engines/chamber/dialog.cpp
index 2fd3f5b09aa..ec1d8c9010c 100644
--- a/engines/chamber/dialog.cpp
+++ b/engines/chamber/dialog.cpp
@@ -1,10 +1,35 @@
-#include "common.h"
-#include "dialog.h"
-#include "print.h"
-#include "cga.h"
-#include "script.h"
-#include "cursor.h"
-#include "input.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/dialog.h"
+#include "chamber/print.h"
+#include "chamber/cga.h"
+#include "chamber/script.h"
+#include "chamber/cursor.h"
+#include "chamber/input.h"
+
+namespace Chamber {
unsigned int cur_str_index;
unsigned int cur_dlg_index;
@@ -208,3 +233,5 @@ unsigned char *SeekToStringScr(unsigned char *bank, unsigned int num, unsigned c
cur_str_end = p + len;
return p + 1;
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/dialog.h b/engines/chamber/dialog.h
index aa7488fa476..6e6effac5a8 100644
--- a/engines/chamber/dialog.h
+++ b/engines/chamber/dialog.h
@@ -1,5 +1,29 @@
-#ifndef _DIALOG_H_
-#define _DIALOG_H_
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_DIALOG_H
+#define CHAMBER_DIALOG_H
+
+namespace Chamber {
extern unsigned int cur_str_index;
extern unsigned int cur_dlg_index;
@@ -44,4 +68,6 @@ void PromptWait(void);
unsigned char *SeekToString(unsigned char *bank, unsigned int num);
unsigned char *SeekToStringScr(unsigned char *bank, unsigned int num, unsigned char **ptr);
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/input.cpp b/engines/chamber/input.cpp
index 917bf27cb57..4d75b0773d5 100644
--- a/engines/chamber/input.cpp
+++ b/engines/chamber/input.cpp
@@ -1,9 +1,33 @@
-#include <dos.h>
-#include <conio.h>
-#include "common.h"
-#include "input.h"
-#include "cursor.h"
-#include "cga.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/input.h"
+#include "chamber/cursor.h"
+#include "chamber/cga.h"
+
+namespace Chamber {
+
unsigned char have_mouse;
unsigned char key_held;
@@ -214,3 +238,5 @@ void UninitInput(void) {
old_keyboard_isr = 0;
#endif
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/input.h b/engines/chamber/input.h
index 438c04030eb..d0ebbda8526 100644
--- a/engines/chamber/input.h
+++ b/engines/chamber/input.h
@@ -1,5 +1,29 @@
-#ifndef _INPUT_H_
-#define _INPUT_H_
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_INPUT_H
+#define CHAMBER_INPUT_H
+
+namespace Chamber {
extern unsigned char buttons;
extern unsigned char right_button;
@@ -23,4 +47,6 @@ void ProcessInput(void);
void InitInput(void);
void UninitInput(void);
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/invent.cpp b/engines/chamber/invent.cpp
index 6a401d42111..d435395134d 100644
--- a/engines/chamber/invent.cpp
+++ b/engines/chamber/invent.cpp
@@ -1,10 +1,36 @@
-#include "common.h"
-#include "invent.h"
-#include "script.h"
-#include "cga.h"
-#include "cursor.h"
-#include "input.h"
-#include "sound.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/invent.h"
+#include "chamber/script.h"
+#include "chamber/cga.h"
+#include "chamber/cursor.h"
+#include "chamber/input.h"
+#include "chamber/sound.h"
+
+namespace Chamber {
+
/*inventory box cells*/
#define INVENTORY_SPOTS_MAX (4 * 4)
@@ -110,3 +136,5 @@ void OpenInventory(unsigned short filtermask, unsigned short filtervalue) {
script_byte_vars.byte_17A19 = 0;
}
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/invent.h b/engines/chamber/invent.h
index 9714ece9e7e..a6abf9445bb 100644
--- a/engines/chamber/invent.h
+++ b/engines/chamber/invent.h
@@ -1,5 +1,29 @@
-#ifndef _INVENT_H_
-#define _INVENT_H_
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_INVENT_H
+#define CHAMBER_INVENT_H
+
+namespace Chamber {
extern unsigned char inv_count;
extern unsigned char inv_bgcolor;
@@ -8,4 +32,6 @@ void DrawInventoryBox(unsigned short filtermask, unsigned short filtervalue);
void OpenInventory(unsigned short filtermask, unsigned short filtervalue);
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 18dacefbf5f..a9c46163aaf 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -1,24 +1,44 @@
-#include <stdio.h>
-#include <dos.h>
-#include <io.h>
-#include <fcntl.h>
-#include <assert.h>
-
-#include "common.h"
-#include "decompr.h"
-#include "cga.h"
-#include "anim.h"
-#include "cursor.h"
-#include "input.h"
-#include "timer.h"
-#include "portrait.h"
-#include "room.h"
-#include "savegame.h"
-#include "resdata.h"
-#include "script.h"
-#include "print.h"
-#include "dialog.h"
-#include "menu.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/decompr.h"
+#include "chamber/cga.h"
+#include "chamber/anim.h"
+#include "chamber/cursor.h"
+#include "chamber/input.h"
+#include "chamber/timer.h"
+#include "chamber/portrait.h"
+#include "chamber/room.h"
+#include "chamber/savegame.h"
+#include "chamber/resdata.h"
+#include "chamber/script.h"
+#include "chamber/print.h"
+#include "chamber/dialog.h"
+#include "chamber/menu.h"
+
+namespace Chamber {
+
unsigned short cpu_speed_delay;
@@ -275,3 +295,5 @@ restart:
ExitGame();
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/menu.cpp b/engines/chamber/menu.cpp
index 48882e6e5ca..ce021a3b4fc 100644
--- a/engines/chamber/menu.cpp
+++ b/engines/chamber/menu.cpp
@@ -1,11 +1,37 @@
-#include "common.h"
-#include "menu.h"
-#include "cga.h"
-#include "input.h"
-#include "cursor.h"
-#include "room.h"
-#include "sound.h"
-#include "script.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/menu.h"
+#include "chamber/cga.h"
+#include "chamber/input.h"
+#include "chamber/cursor.h"
+#include "chamber/room.h"
+#include "chamber/sound.h"
+#include "chamber/script.h"
+
+namespace Chamber {
+
unsigned char act_menu_x = 0;
unsigned char act_menu_y = 0;
@@ -234,3 +260,5 @@ void CheckPsiCommandHover(void) {
cursor_color = 0xFF;
the_command = 0;
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/menu.h b/engines/chamber/menu.h
index d2978775119..0fce6765067 100644
--- a/engines/chamber/menu.h
+++ b/engines/chamber/menu.h
@@ -1,5 +1,29 @@
-#ifndef _MENU_H_
-#define _MENU_H_
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_MENU_H
+#define CHAMBER_MENU_H
+
+namespace Chamber {
extern unsigned char act_menu_x;
extern unsigned char act_menu_y;
@@ -11,4 +35,6 @@ void ProcessMenu(void);
void CheckMenuCommandHover(void);
void CheckPsiCommandHover(void);
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index cbe44a1b6c2..4b760286a82 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -1,14 +1,38 @@
-#include <mem.h>
-#include <stdio.h>
-#include "common.h"
-#include "portrait.h"
-#include "resdata.h"
-#include "room.h"
-#include "cga.h"
-#include "script.h"
-#include "dialog.h"
-#include "input.h"
-#include "sound.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/portrait.h"
+#include "chamber/resdata.h"
+#include "chamber/room.h"
+#include "chamber/cga.h"
+#include "chamber/script.h"
+#include "chamber/dialog.h"
+#include "chamber/input.h"
+#include "chamber/sound.h"
+
+namespace Chamber {
+
extern unsigned short cpu_speed_delay;
@@ -324,3 +348,5 @@ void AnimPortrait(unsigned char layer, unsigned char index, unsigned char delay)
}
}
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/portrait.h b/engines/chamber/portrait.h
index 867e9417377..e7eb3919988 100644
--- a/engines/chamber/portrait.h
+++ b/engines/chamber/portrait.h
@@ -1,5 +1,29 @@
-#ifndef _PORTRAIT_H_
-#define _PORTRAIT_H_
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_PORTRAIT_H
+#define CHAMBER_PORTRAIT_H
+
+namespace Chamber {
extern unsigned char *cur_image_pixels;
extern unsigned char cur_image_size_w;
@@ -25,4 +49,6 @@ void BlinkToRed(void);
void BlinkToWhite(void);
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/print.cpp b/engines/chamber/print.cpp
index c35039a7b58..d6b896cbc5d 100644
--- a/engines/chamber/print.cpp
+++ b/engines/chamber/print.cpp
@@ -1,7 +1,33 @@
-#include "common.h"
-#include "cga.h"
-#include "cursor.h"
-#include "dialog.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/cga.h"
+#include "chamber/cursor.h"
+#include "chamber/dialog.h"
+
+namespace Chamber {
+
unsigned char *cur_str_end;
@@ -227,7 +253,6 @@ void DrawMessage(unsigned char *msg, unsigned char *target) {
}
#if 1
-#include <stdio.h>
void DebugMessage(char *msg, ...) {
int i;
unsigned char c;
@@ -260,3 +285,5 @@ void DebugMessage(char *msg, ...) {
DrawMessage(m, frontbuffer);
}
#endif
+
+} // End of namespace Chamber
diff --git a/engines/chamber/print.h b/engines/chamber/print.h
index cc360ae1225..acd15cdb4ab 100644
--- a/engines/chamber/print.h
+++ b/engines/chamber/print.h
@@ -1,5 +1,29 @@
-#ifndef _PRINT_H_
-#define _PRINT_H_
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_PRINT_H
+#define CHAMBER_PRINT_H
+
+namespace Chamber {
extern unsigned char *cur_str_end;
@@ -18,4 +42,6 @@ void DrawMessage(unsigned char *msg, unsigned char *target);
void CGA_DrawTextBox(unsigned char *msg, unsigned char *target);
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/r_other.cpp b/engines/chamber/r_other.cpp
index e50ee56f91e..0fc95cf2c98 100644
--- a/engines/chamber/r_other.cpp
+++ b/engines/chamber/r_other.cpp
@@ -1,4 +1,30 @@
-#include "resdata.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/resdata.h"
+
+namespace Chamber {
+
unsigned char arpla_data[RES_ARPLA_MAX];
unsigned char aleat_data[RES_ALEAT_MAX];
@@ -11,3 +37,5 @@ 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];
+
+} // End of namespace Chamber
diff --git a/engines/chamber/r_pers.cpp b/engines/chamber/r_pers.cpp
index c57d84f0a99..ed68259a93b 100644
--- a/engines/chamber/r_pers.cpp
+++ b/engines/chamber/r_pers.cpp
@@ -1,7 +1,35 @@
-#include "resdata.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/resdata.h"
+
+namespace Chamber {
+
unsigned char pers1_data[RES_PERS1_MAX];
unsigned char pers2_data[RES_PERS2_MAX];
unsigned char desci_data[RES_DESCI_MAX];
unsigned char diali_data[RES_DIALI_MAX];
+
+} // End of namespace Chamber
diff --git a/engines/chamber/r_puzzl.cpp b/engines/chamber/r_puzzl.cpp
index 0452492d9ea..df72c7ae593 100644
--- a/engines/chamber/r_puzzl.cpp
+++ b/engines/chamber/r_puzzl.cpp
@@ -1,3 +1,30 @@
-#include "resdata.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/resdata.h"
+
+namespace Chamber {
unsigned char puzzl_data[RES_PUZZL_MAX];
+
+} // End of namespace Chamber
diff --git a/engines/chamber/r_sprit.cpp b/engines/chamber/r_sprit.cpp
index 6341e0b8ebd..224476cf246 100644
--- a/engines/chamber/r_sprit.cpp
+++ b/engines/chamber/r_sprit.cpp
@@ -1,3 +1,30 @@
-#include "resdata.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/resdata.h"
+
+namespace Chamber {
unsigned char sprit_data[RES_SPRIT_MAX];
+
+} // End of namespace Chamber
diff --git a/engines/chamber/r_templ.cpp b/engines/chamber/r_templ.cpp
index cb6831b6d91..50829bea97a 100644
--- a/engines/chamber/r_templ.cpp
+++ b/engines/chamber/r_templ.cpp
@@ -1,3 +1,30 @@
-#include "resdata.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/resdata.h"
+
+namespace Chamber {
unsigned char templ_data[RES_TEMPL_MAX];
+
+} // End of namespace Chamber
diff --git a/engines/chamber/r_texts.cpp b/engines/chamber/r_texts.cpp
index 86f71b54391..d8195e39f3f 100644
--- a/engines/chamber/r_texts.cpp
+++ b/engines/chamber/r_texts.cpp
@@ -1,4 +1,32 @@
-#include "resdata.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/resdata.h"
+
+namespace Chamber {
+
unsigned char vepci_data[RES_VEPCI_MAX];
unsigned char motsi_data[RES_MOTSI_MAX];
+
+} // End of namespace Chamber
diff --git a/engines/chamber/resdata.cpp b/engines/chamber/resdata.cpp
index f74f00ed33e..61c1d4b7f74 100644
--- a/engines/chamber/resdata.cpp
+++ b/engines/chamber/resdata.cpp
@@ -1,8 +1,31 @@
-#include <io.h>
-#include <fcntl.h>
-#include "common.h"
-#include "resdata.h"
-#include "decompr.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/resdata.h"
+#include "chamber/decompr.h"
+
+namespace Chamber {
/*
Get bank entry
@@ -172,3 +195,5 @@ int LoadDialiData(void) {
while (!LoadFilesList(res_diali))
AskDisk2();
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/resdata.h b/engines/chamber/resdata.h
index 783fae7dd15..5f7d51e2007 100644
--- a/engines/chamber/resdata.h
+++ b/engines/chamber/resdata.h
@@ -1,5 +1,29 @@
-#ifndef _RESDATA_H_
-#define _RESDATA_H_
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_RESDATA_H
+#define CHAMBER_RESDATA_H
+
+namespace Chamber {
typedef struct ResEntry_t {
char name[5 + 1 + 3 + 1];
@@ -76,4 +100,6 @@ int LoadDesciData(void);
extern ResEntry_t res_diali[];
int LoadDialiData(void);
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index 97c68288ced..db6802541e9 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -1,17 +1,42 @@
-#include <string.h>
-#include "common.h"
-#include "room.h"
-#include "resdata.h"
-#include "cga.h"
-#include "print.h"
-#include "anim.h"
-#include "cursor.h"
-#include "script.h"
-#include "print.h"
-#include "input.h"
-#include "dialog.h"
-#include "portrait.h"
-#include "sound.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/room.h"
+#include "chamber/resdata.h"
+#include "chamber/cga.h"
+#include "chamber/print.h"
+#include "chamber/anim.h"
+#include "chamber/cursor.h"
+#include "chamber/script.h"
+#include "chamber/print.h"
+#include "chamber/input.h"
+#include "chamber/dialog.h"
+#include "chamber/portrait.h"
+#include "chamber/sound.h"
+
+namespace Chamber {
+
unsigned char scratch_mem1[8010];
unsigned char *scratch_mem2 = scratch_mem1 + 1500;
@@ -1680,3 +1705,5 @@ void ResetAllPersons(void) {
pers_list[i].flags &= ~PERSFLG_80;
script_byte_vars.dead_flag = 0;
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/room.h b/engines/chamber/room.h
index 2b833bdcd08..bb8072eafcf 100644
--- a/engines/chamber/room.h
+++ b/engines/chamber/room.h
@@ -1,5 +1,29 @@
-#ifndef _ROOM_H_
-#define _ROOM_H_
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_ROOM_H
+#define CHAMBER_ROOM_H
+
+namespace Chamber {
#define SPOTFLG_1 0x01
#define SPOTFLG_8 0x08
@@ -181,4 +205,6 @@ void UpdateTimedInventoryItems(void);
void ResetAllPersons(void);
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/savegame.cpp b/engines/chamber/savegame.cpp
index 8eb9966da39..0cd9af81b8f 100644
--- a/engines/chamber/savegame.cpp
+++ b/engines/chamber/savegame.cpp
@@ -1,11 +1,35 @@
-#include <io.h>
-#include <fcntl.h>
-#include "common.h"
-#include "savegame.h"
-#include "resdata.h"
-#include "script.h"
-#include "cga.h"
-#include "room.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/savegame.h"
+#include "chamber/resdata.h"
+#include "chamber/script.h"
+#include "chamber/cga.h"
+#include "chamber/room.h"
+
+namespace Chamber {
+
void SaveRestartGame(void) {
/*TODO*/
@@ -161,3 +185,5 @@ error:
script_byte_vars.game_paused = 0;
return 1;
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/savegame.h b/engines/chamber/savegame.h
index 6327c46cd6f..cea29569046 100644
--- a/engines/chamber/savegame.h
+++ b/engines/chamber/savegame.h
@@ -1,9 +1,35 @@
-#ifndef _SAVEGAME_H_
-#define _SAVEGAME_H_
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_SAVEGAME_H
+#define CHAMBER_SAVEGAME_H
+
+namespace Chamber {
int LoadScena(void);
int SaveScena(void);
void SaveRestartGame(void);
void RestartGame(void);
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index b29599457d6..2f85ac1f0b9 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -1,27 +1,51 @@
-#include <stdio.h>
-#include <string.h>
-#include "common.h"
-#include "script.h"
-#include "resdata.h"
-#include "cga.h"
-#include "cursor.h"
-#include "portrait.h"
-#include "input.h"
-#include "menu.h"
-#include "room.h"
-#include "dialog.h"
-#include "print.h"
-#include "anim.h"
-#include "invent.h"
-#include "sound.h"
-#include "savegame.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/script.h"
+#include "chamber/resdata.h"
+#include "chamber/cga.h"
+#include "chamber/cursor.h"
+#include "chamber/portrait.h"
+#include "chamber/input.h"
+#include "chamber/menu.h"
+#include "chamber/room.h"
+#include "chamber/dialog.h"
+#include "chamber/print.h"
+#include "chamber/anim.h"
+#include "chamber/invent.h"
+#include "chamber/sound.h"
+#include "chamber/savegame.h"
+
#if 1
#define DEBUG_SCRIPT
char DEBUG_SCRIPT_LOG[] = "!script.log";
#endif
-#include "scrvars.h"
+#include "chamber/scrvars.h"
+
+namespace Chamber {
unsigned char rand_seed;
unsigned short the_command;
@@ -2013,7 +2037,6 @@ unsigned int SCR_61_DrawPersonBubbleDialog(void) {
}
#if 1
-#include <stdio.h>
unsigned char *DebugString(char *msg, ...) {
int i;
unsigned char c;
@@ -3210,3 +3233,5 @@ unsigned int RunCommandKeepSp(void) {
/*keep_sp = sp;*/
return RunCommand();
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/script.h b/engines/chamber/script.h
index d9de5dd59d3..e1df96d5b62 100644
--- a/engines/chamber/script.h
+++ b/engines/chamber/script.h
@@ -1,8 +1,32 @@
-#ifndef _SCRIPT_H_
-#define _SCRIPT_H_
-
-#include "common.h"
-#include "room.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_SCRIPT_H
+#define CHAMBER_SCRIPT_H
+
+#include "chamber/common.h"
+#include "chamber/room.h"
+
+namespace Chamber {
enum ScriptPools {
ScrPool0_WordVars0,
@@ -199,4 +223,6 @@ unsigned int RunCommandKeepSp(void);
unsigned int Swap16(unsigned int x);
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/scrvars.h b/engines/chamber/scrvars.h
index bb12eafb686..da9a4a89a0d 100644
--- a/engines/chamber/scrvars.h
+++ b/engines/chamber/scrvars.h
@@ -1,3 +1,30 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_SCRVARS_H
+#define CHAMBER_SCRVARS_H
+
+namespace Chamber {
+
script_byte_vars_t script_byte_vars = {
135, /* 0 */
0, /* 1 */
@@ -248,3 +275,7 @@ pers_t pers_list[PERS_MAX] = {
{59, 0, 51, 209, 0}, /* 39 : TURKEY */
{59, 0, 51, 209, 0}, /* 40 : TURKEY */
};
+
+} // End of namespace Chamber
+
+#endif
diff --git a/engines/chamber/sound.cpp b/engines/chamber/sound.cpp
index 52aa687779d..ae7c9630254 100644
--- a/engines/chamber/sound.cpp
+++ b/engines/chamber/sound.cpp
@@ -1,6 +1,34 @@
-#include "common.h"
-#include "sound.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/sound.h"
+
+namespace Chamber {
+
void PlaySound(unsigned char index) {
/*TODO*/
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/sound.h b/engines/chamber/sound.h
index 1ca7f7c7d7f..bbf397cb4cd 100644
--- a/engines/chamber/sound.h
+++ b/engines/chamber/sound.h
@@ -1,6 +1,32 @@
-#ifndef _SOUND_H_
-#define _SOUND_H_
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_SOUND_H
+#define CHAMBER_SOUND_H
+
+namespace Chamber {
void PlaySound(unsigned char index);
+} // End of namespace Chamber
+
#endif
diff --git a/engines/chamber/timer.cpp b/engines/chamber/timer.cpp
index 2f9140a3fe1..925f37920b5 100644
--- a/engines/chamber/timer.cpp
+++ b/engines/chamber/timer.cpp
@@ -1,8 +1,33 @@
-#include <dos.h>
-#include "common.h"
-#include "cga.h"
-#include "script.h"
-#include "resdata.h"
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/cga.h"
+#include "chamber/script.h"
+#include "chamber/resdata.h"
+
+namespace Chamber {
+
void AnimateGauss(unsigned char *target) {
unsigned char *sprite;
@@ -42,3 +67,5 @@ void UninitTimer(void) {
setvect(0x1C, old_timer_isr);
enable();
}
+
+} // End of namespace Chamber
diff --git a/engines/chamber/timer.h b/engines/chamber/timer.h
index faaeb7a230a..22755557201 100644
--- a/engines/chamber/timer.h
+++ b/engines/chamber/timer.h
@@ -1,7 +1,33 @@
-#ifndef _TIMER_H_
-#define _TIMER_H_
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_TIMER_H
+#define CHAMBER_TIMER_H
+
+namespace Chamber {
void InitTimer(void);
void UninitTimer(void);
+} // End of namespace Chamber
+
#endif
Commit: ca9faedb64d3b2b4441e27557bbcdbcca172fb0e
https://github.com/scummvm/scummvm/commit/ca9faedb64d3b2b4441e27557bbcdbcca172fb0e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Sync with upstream f6bf08532a77c32f9539180e1bb51a147998a2d0
Changed paths:
engines/chamber/cga.cpp
engines/chamber/cursor.h
engines/chamber/dialog.cpp
engines/chamber/dialog.h
engines/chamber/invent.cpp
engines/chamber/kult.cpp
engines/chamber/menu.cpp
engines/chamber/resdata.cpp
engines/chamber/room.cpp
engines/chamber/room.h
engines/chamber/savegame.cpp
engines/chamber/script.cpp
engines/chamber/script.h
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index c31df1c487f..2ac36b65c1f 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -21,14 +21,12 @@
*/
#include "chamber/chamber.h"
-
#include "chamber/common.h"
#include "chamber/resdata.h"
#include "chamber/cga.h"
namespace Chamber {
-
extern unsigned char backbuffer[0x4000];
unsigned char carpc_data[RES_CARPC_MAX];
@@ -737,7 +735,9 @@ void CGA_HideScreenBlockLiftToLeft(unsigned int n, unsigned char *screen, unsign
/*shift whole block 1 column*/
for (i = 0; i < h; i++) {
tofs = sofs - 1;
- memcpy(target + tofs, screen + sofs, w);
+
+ /*use memmove since buffers may overlap*/
+ memmove(target + tofs, screen + sofs, w);
/*fill freed column*/
memcpy(target + tofs + w, source + tofs + w, 1);
@@ -759,7 +759,6 @@ void CGA_HideScreenBlockLiftToLeft(unsigned int n, unsigned char *screen, unsign
/*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) {
- /*TODO: check me if its ok*/
while (n--) {
int i;
unsigned int sofs, tofs;
@@ -769,7 +768,9 @@ void CGA_HideScreenBlockLiftToRight(unsigned int n, unsigned char *screen, unsig
/*shift whole block 1 column*/
for (i = 0; i < h; i++) {
tofs = sofs + 1;
- memcpy(target + tofs - w, screen + sofs - w, w);
+
+ /*use memmove since buffers may overlap*/
+ memmove(target + tofs - w, screen + sofs - w, w);
/*fill freed column*/
memcpy(target + tofs - w, source + tofs - w, 1);
diff --git a/engines/chamber/cursor.h b/engines/chamber/cursor.h
index 748be23702e..7c73ae04782 100644
--- a/engines/chamber/cursor.h
+++ b/engines/chamber/cursor.h
@@ -30,15 +30,15 @@ namespace Chamber {
#define CURSOR_WIDTH_SPR 20
enum Cursors {
- CURSOR_0,
- CURSOR_1,
+ CURSOR_FINGER,
+ CURSOR_TARGET,
CURSOR_FLY,
- CURSOR_3,
- CURSOR_4,
- CURSOR_5,
- CURSOR_6,
- CURSOR_7,
- CURSOR_8,
+ CURSOR_SNAKE,
+ CURSOR_GRAB,
+ CURSOR_POUR,
+ CURSOR_BODY,
+ CURSOR_ARROWS,
+ CURSOR_CROSSHAIR,
CURSOR_MAX
};
diff --git a/engines/chamber/dialog.cpp b/engines/chamber/dialog.cpp
index ec1d8c9010c..62f4c807b83 100644
--- a/engines/chamber/dialog.cpp
+++ b/engines/chamber/dialog.cpp
@@ -34,7 +34,6 @@ namespace Chamber {
unsigned int cur_str_index;
unsigned int cur_dlg_index;
-#define MAX_DIRTY_RECT 10
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) {
diff --git a/engines/chamber/dialog.h b/engines/chamber/dialog.h
index 6e6effac5a8..23479e52410 100644
--- a/engines/chamber/dialog.h
+++ b/engines/chamber/dialog.h
@@ -38,12 +38,13 @@ enum DirtyRectKind {
typedef struct dirty_rect_t {
unsigned char kind;
unsigned int offs;
- unsigned char width;
unsigned char height;
+ unsigned char width;
unsigned char y; /*for DirtyRectBubble this is spike offs*/
unsigned char x;
} dirty_rect_t;
+#define MAX_DIRTY_RECT 10
extern dirty_rect_t dirty_rects[];
#define SPIKE_MASK 0xE0
diff --git a/engines/chamber/invent.cpp b/engines/chamber/invent.cpp
index d435395134d..4591b756a95 100644
--- a/engines/chamber/invent.cpp
+++ b/engines/chamber/invent.cpp
@@ -31,7 +31,6 @@
namespace Chamber {
-
/*inventory box cells*/
#define INVENTORY_SPOTS_MAX (4 * 4)
@@ -113,7 +112,7 @@ void OpenInventory(unsigned short filtermask, unsigned short filtervalue) {
CGA_BackupImageReal(CGA_CalcXY_p(232 / 4, 56), 64 / 4, 64);
DrawInventoryBox(filtermask, filtervalue);
if (inv_count != 0) {
- SelectCursor(CURSOR_0);
+ SelectCursor(CURSOR_FINGER);
ProcessInput();
do {
PollInput();
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index a9c46163aaf..1f22ddc2cca 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -39,7 +39,6 @@
namespace Chamber {
-
unsigned short cpu_speed_delay;
/*
@@ -100,11 +99,11 @@ void GameLoop(unsigned char *target) {
the_command = 0;
if (IsCursorInRect(&room_bounds_rect)) {
- SelectCursor(CURSOR_1);
+ SelectCursor(CURSOR_TARGET);
command_hint = 100;
SelectSpotCursor();
} else {
- SelectCursor(CURSOR_0);
+ SelectCursor(CURSOR_FINGER);
object_hint = 117;
CheckMenuCommandHover();
}
diff --git a/engines/chamber/menu.cpp b/engines/chamber/menu.cpp
index ce021a3b4fc..2a7e41ff5bc 100644
--- a/engines/chamber/menu.cpp
+++ b/engines/chamber/menu.cpp
@@ -32,7 +32,6 @@
namespace Chamber {
-
unsigned char act_menu_x = 0;
unsigned char act_menu_y = 0;
@@ -142,7 +141,7 @@ void ActionsMenu(unsigned char **pinfo) {
for (i = 0; i < numchoices; i++)
DrawSpriteN(1, act_dot_rects[i].sx, act_dot_rects[i].sy, CGA_SCREENBUFFER);
- SelectCursor(CURSOR_0);
+ SelectCursor(CURSOR_FINGER);
ProcessInput();
choice = 0;
@@ -201,7 +200,7 @@ void MenuLoop(unsigned char spotmask, unsigned char spotvalue) {
}
void ProcessMenu(void) {
- SelectCursor(CURSOR_6);
+ SelectCursor(CURSOR_BODY);
MenuLoop(SPOTFLG_80 | SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8, SPOTFLG_80 | SPOTFLG_10);
}
diff --git a/engines/chamber/resdata.cpp b/engines/chamber/resdata.cpp
index 61c1d4b7f74..5bd4f6ce85f 100644
--- a/engines/chamber/resdata.cpp
+++ b/engines/chamber/resdata.cpp
@@ -27,6 +27,9 @@
namespace Chamber {
+extern void AskDisk2(void);
+extern int LoadSplash(char *filename);
+
/*
Get bank entry
TODO: port SeekToString to this routine
@@ -181,6 +184,7 @@ Load strings data (obj. descriptions)
int LoadDesciData(void) {
while (!LoadFilesList(res_desci))
AskDisk2();
+ return 1;
}
ResEntry_t res_diali[] = {
@@ -194,6 +198,7 @@ Load strings data (dialogs)
int LoadDialiData(void) {
while (!LoadFilesList(res_diali))
AskDisk2();
+ return 1;
}
} // End of namespace Chamber
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index db6802541e9..2c85ae14c0c 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -37,7 +37,6 @@
namespace Chamber {
-
unsigned char scratch_mem1[8010];
unsigned char *scratch_mem2 = scratch_mem1 + 1500;
@@ -92,12 +91,12 @@ unsigned short next_ticks2 = 0;
unsigned char zone_drawn;
-#define RECD_MAX 25
+#define VORTANIMS_MAX 25
/*
Vorts room enter/leave animations
*/
-vortanims_t vortsanim_list[RECD_MAX] = {
+vortanims_t vortsanim_list[VORTANIMS_MAX] = {
{ 2, { 3, 52, 113}, { 8, 43, 113}, {12, 43, 113}, {16, 43, 113}},
{ 3, { 6, 58, 120}, { 7, 33, 120}, {11, 33, 120}, {15, 33, 120}},
{ 4, { 2, 26, 121}, { 9, 43, 121}, {13, 43, 121}, {17, 43, 121}},
@@ -170,6 +169,9 @@ void RefreshSpritesData(void) {
}
}
+/*
+Check if packed x/y coordinates are in rect
+*/
int IsInRect(unsigned char x, unsigned char y, rect_t *rect) {
if (x < rect->sx) return 0;
if (x >= rect->ex) return 0;
@@ -178,10 +180,16 @@ int IsInRect(unsigned char x, unsigned char y, rect_t *rect) {
return 1;
}
+/*
+Check if cursor is in rect
+*/
int IsCursorInRect(rect_t *rect) {
return IsInRect(cursor_x / CGA_PIXELS_PER_BYTE, cursor_y, rect);
}
+/*
+Find person for a current spot
+*/
void FindPerson(void) {
int i;
pers_t *pers = pers_list;
@@ -195,6 +203,9 @@ void FindPerson(void) {
script_byte_vars.cur_pers = 0;
}
+/*
+Select a spot under cursor if its flags are matched given criteria
+*/
void CheckHotspots(unsigned char m, unsigned char v) {
int i;
spot_t *spot = zone_spots;
@@ -216,15 +227,18 @@ void CheckHotspots(unsigned char m, unsigned char v) {
script_byte_vars.cur_spot_idx = 0;
}
+/*
+Select cursor shape for current spot
+*/
void SelectSpotCursor(void) {
- int curs = 1;
+ int curs = CURSOR_TARGET;
CheckHotspots(script_byte_vars.spot_m, script_byte_vars.spot_v);
if (cursor_color == 0xAA) {
- curs = 6;
+ curs = CURSOR_BODY;
if ((script_byte_vars.cur_spot_flags & (SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8)) != SPOTFLG_10) {
- curs = 7;
+ curs = CURSOR_ARROWS;
if ((script_byte_vars.cur_spot_flags & SPOTFLG_20) != 0)
- curs = 8;
+ curs = CURSOR_CROSSHAIR;
}
}
cursor_shape = souri_data + curs * CURSOR_WIDTH * CURSOR_HEIGHT * 2 / CGA_PIXELS_PER_BYTE;
@@ -248,12 +262,15 @@ static const signed int background_draw_steps[] = {
-kBgW, -kBgW, -kBgW, -kBgW
};
-/*Draw main backgound pattern, in spiral-like order*/
+/*
+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*/
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);
if (vblank)
WaitVBlank();
@@ -267,6 +284,9 @@ void DrawBackground(unsigned char *target, unsigned char vblank) {
}
}
+/*
+Load and initialize zone data
+*/
void LoadZone(void) {
unsigned char *zptr, *zend;
@@ -281,6 +301,7 @@ void LoadZone(void) {
unsigned short *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;
flags |= *zptr++;
if (flags & 0x10) {
@@ -340,7 +361,9 @@ void ResetZone(void) {
script_word_vars.word_17846 = BE(0xA01D);
}
-/*load puzzl sprite to buffer, return next free buffer ptr*/
+/*
+Load puzzl sprite to buffer, return next free buffer ptr
+*/
unsigned char *LoadPuzzl(unsigned char index, unsigned char *buffer) {
if (script_byte_vars.palette_index == 14)
return LoadSprite(index, puzzl_data + 4, buffer, 1);
@@ -348,7 +371,9 @@ unsigned char *LoadPuzzl(unsigned char index, unsigned char *buffer) {
return LoadSprite(index, puzzl_data + 4, buffer, 0);
}
-/*load puzzl sprite to scratch buffer, return sprite ptr*/
+/*
+Load puzzl sprite to scratch buffer, return sprite ptr
+*/
unsigned char *LoadPuzzlToScratch(unsigned char index) {
unsigned char *buffer = scratch_mem2;
LoadPuzzl(index, buffer);
@@ -371,9 +396,12 @@ typedef struct doorinfo_t {
unsigned char sprites[1]; /*variable size*/
} doorinfo_t;
-unsigned char *doors_list[5];
+unsigned char *doors_list[MAX_DOORS];
unsigned char arpla_y_step;
+/*
+Fill in sliding door animation information
+*/
void InitRoomDoorInfo(unsigned char index) {
int i;
unsigned char *aptr;
@@ -426,6 +454,9 @@ void InitRoomDoorInfo(unsigned char index) {
info->offs = CGA_CalcXY_p(bounds.sx, bounds.sy);
}
+/*
+Draw sliding door
+*/
void DrawRoomDoor(void) {
int i;
doorinfo_t *info = (doorinfo_t *)scratch_mem2;
@@ -445,14 +476,21 @@ void DrawRoomDoor(void) {
CGA_CopyScreenBlock(backbuffer, info->width, info->height, frontbuffer, info->offs);
}
+/*
+Animate sliding door open
+*/
void AnimRoomDoorOpen(unsigned char index) {
int i;
+ unsigned char oldheight;
+
doorinfo_t *info = (doorinfo_t *)scratch_mem2;
InitRoomDoorInfo(index);
- for (i = 0; i < info->layer[1].height / 2; i++) {
+ oldheight = info->layer[1].height;
+
+ for (i = 0; i < oldheight / 2; i++) {
#if 1
DrawRoomDoor();
#endif
@@ -463,6 +501,9 @@ void AnimRoomDoorOpen(unsigned char index) {
PlaySound(31);
}
+/*
+Animate sliding door close
+*/
void AnimRoomDoorClose(unsigned char index) {
int i;
@@ -479,7 +520,7 @@ void AnimRoomDoorClose(unsigned char index) {
info->layer[1].height = 1;
for (i = 0; i < oldheight / 2; i++) {
-#if 0
+#if 1
DrawRoomDoor();
#endif
info->layer[1].height += 2;
@@ -500,7 +541,7 @@ unsigned char FindInitialSpot(void) {
unsigned char flags = script_byte_vars.byte_179B8;
if (flags == 0)
return 0;
- flags |= 0x80;
+ flags |= SPOTFLG_80 | SPOTFLG_8;
for (index = 1, spot = zone_spots; spot != zone_spots_end; index++, spot++) {
if (spot->flags == flags)
return index;
@@ -508,6 +549,9 @@ unsigned char FindInitialSpot(void) {
return 0;
}
+/*
+Find first spot index that matches given flags
+*/
unsigned char FindSpotByFlags(unsigned char mask, unsigned char value) {
spot_t *spot;
unsigned char index;
@@ -518,6 +562,10 @@ unsigned char FindSpotByFlags(unsigned char mask, unsigned char value) {
return 0xFF;
}
+/*
+Find person's spot
+TODO: rename me
+*/
unsigned char FindAndSelectSpot(unsigned char offset) {
/*TODO: replace offset arg with index?*/
unsigned char index = offset / 5; /* / sizeof(pers_t) */
@@ -534,11 +582,14 @@ unsigned char FindAndSelectSpot(unsigned char offset) {
return 1;
}
+/*
+Play animation at the selected spot or specified coordinates
+*/
void AnimateSpot(const animdesc_t *info) {
unsigned char *sprite = *spot_sprite;
CGA_RestoreImage(sprite, backbuffer);
if (info->index & ANIMFLG_USESPOT) {
- /*at object*/
+ /*at selected spot*/
cursor_x = found_spot->sx * 4;
cursor_y = found_spot->sy;
if (info->params.desc)
@@ -675,7 +726,9 @@ void DrawZoneObjs(void) {
}
}
-/*Draw room's static object to backbuffer*/
+/*
+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;
@@ -687,8 +740,8 @@ void DrawRoomStaticObject(unsigned char *aptr, unsigned char *rx, unsigned char
sprite += 2;
- *rx = x;
- *ry = y;
+ *rx = x & 0x7F;
+ *ry = (y & 0x7F) * 2;
*rw = w;
*rh = h;
@@ -706,12 +759,15 @@ void DrawRoomStaticObject(unsigned char *aptr, unsigned char *rx, unsigned char
}
y = (y * 2) & 0xFF;
- if (aptr[0] == 83) {
+ if (aptr[0] == 83) { /*Hand sprite from Who Will Be Saved room*/
if (arpla_y_step & 1)
y -= 8;
arpla_y_step >>= 1;
}
+ /*TODO: adjust ry accordingly? SCR_11_DrawRoomObject uses offs from adjusted y, but DrawRoomStatics relies on original y*/
+ /*TODO: check if this results in any glitches in Who Will Be Saved*/
+
if (aptr[1] & 0x80)
CGA_BlitSpriteFlip(sprite, pitch, w, h, backbuffer, CGA_CalcXY_p(x, y));
else
@@ -753,8 +809,6 @@ void DrawRoomStatics(void) {
DrawRoomStaticObject(aptr, &x, &y, &w, &h);
/*update room's bounding rect*/
- x &= 0x7F;
- y = (y * 2) & 0xFF;
if (x < room_bounds_rect.sx)
room_bounds_rect.sx = x;
if (x + w > room_bounds_rect.ex)
@@ -790,6 +844,9 @@ void DrawRoomStatics(void) {
CGA_DrawVLine(xx + ww - 1, y - 2, 9, 2, backbuffer);
}
+/*
+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;
@@ -871,6 +928,9 @@ void RefreshZone(void) {
BlitSpritesToBackBuffer();
}
+/*
+Draw object hint or zone name text to backbuffer
+*/
void DrawObjectHint(void) {
if (script_byte_vars.zone_index == 135)
return;
@@ -888,12 +948,18 @@ void DrawObjectHint(void) {
#endif
}
+/*
+Copy object hint from backbuffer to screen
+*/
void ShowObjectHint(unsigned char *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));
}
+/*
+Draw command hint text to backbuffer
+*/
void DrawCommandHint(void) {
char_draw_max_width = cmd_hint_bar_width;
char_draw_coords_x = cmd_hint_bar_coords_x;
@@ -902,6 +968,9 @@ void DrawCommandHint(void) {
PrintStringCentered(SeekToString(vepci_data, command_hint), backbuffer);
}
+/*
+Copy command hint from backbuffer to screen
+*/
void ShowCommandHint(unsigned char *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));
}
@@ -945,7 +1014,10 @@ void LoadLutinSprite(unsigned int lutidx) {
}
}
-/*Draw room's sprites and advance sprite's animation*/
+/*
+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;
@@ -977,7 +1049,7 @@ void SetDelay5(void) {
}
/*
-Pick random quest item
+Aspirants AI
*/
void PrepareCommand1(void) {
unsigned char index;
@@ -988,7 +1060,7 @@ void PrepareCommand1(void) {
pers_list[1].area = 55;
pers_list[2].area = 55;
pers_list[3].area = 55;
- pers_list[1].name = 50;
+ pers_list[1].name = 50; /*DIVO*/
pers_list[2].name = 50;
pers_list[3].name = 50;
return;
@@ -1072,7 +1144,9 @@ void PrepareCommand1(void) {
}
}
-/*Vorts AI*/
+/*
+Vorts AI
+*/
void PrepareCommand3(void) {
spot_t *spot;
@@ -1084,7 +1158,7 @@ void PrepareCommand3(void) {
for (spot = zone_spots; spot != zone_spots_end; spot++) {
if ((spot->flags & ~SPOTFLG_80) == (SPOTFLG_40 | SPOTFLG_10)) {
int i;
- for (i = 0; i < RECD_MAX; i++) {
+ for (i = 0; i < VORTANIMS_MAX; i++) {
if (vortsanim_list[i].room == script_byte_vars.zone_room) {
vortanims_ptr = &vortsanim_list[i];
if (script_byte_vars.zone_area == pers_list[0].area
@@ -1119,6 +1193,9 @@ void PrepareCommand3(void) {
script_byte_vars.byte_179EC &= 0x80; /*TODO: is this correct? |= ?*/
}
+/*
+Turkey AI
+*/
void PrepareCommand4(void) {
spot_t *spot;
@@ -1161,7 +1238,9 @@ void PrepareCommand4(void) {
}
-/*Load puzzl sprite to scratch and init draw params*/
+/*
+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);
*w = spr[0];
@@ -1170,21 +1249,27 @@ unsigned int GetPuzzlSprite(unsigned char index, unsigned char x, unsigned char
return 0; /*sprite offset in scratch buf*/
}
+/*
+Save specific fully drawn rooms to backbuffer
+*/
void BackupScreenOfSpecialRoom(void) {
switch (script_byte_vars.zone_room) {
- case 41:
- case 22:
- case 23:
- case 24:
+ case 41: /* THE POWERS OF THE ABYSS */
+ case 22: /* DE PROFUNDIS */
+ case 23: /* DE PROFUNDIS */
+ case 24: /* THE WALL */
CGA_RealBufferToBackFull();
break;
}
}
+/*
+Fully redraw specific rooms
+*/
void RestoreScreenOfSpecialRoom(void) {
switch (script_byte_vars.zone_room) {
- case 23:
- case 24:
+ case 23: /* DE PROFUNDIS */
+ case 24: /* DE PROFUNDIS */
RedrawRoomStatics(script_byte_vars.zone_room, 0);
break;
}
@@ -1256,95 +1341,84 @@ unsigned char *LoadMursmSprite(unsigned char index) {
return sprit_load_buffer;
}
-typedef struct thewall_t {
- unsigned char height;
- unsigned char width;
- unsigned int pitch;
- unsigned int offs;
- unsigned char *pixels;
-} thewall_t;
-
-thewall_t the_wall_wall_b, the_wall_wall_a;
+thewalldoor_t the_wall_doors[2];
-unsigned int cur_image_width_full;
+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(unsigned char x, unsigned char y, unsigned char w, unsigned char h) {
- unsigned int ofs = CGA_CalcXY_p(x + w - 2, y);
- unsigned char n = w - 1;
- while (n) {
- CGA_HideScreenBlockLiftToRight(1, frontbuffer, backbuffer, n, h, frontbuffer, ofs);
- n--;
- if (n == cur_image_width_full) {
- /*ret n and ofs*/
+ while (--width) {
+ CGA_HideScreenBlockLiftToRight(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ if (width == limit)
return;
- }
}
- ofs += 1;
+ offs++;
-}
+ /*hide remaining column*/
+ /*TODO: move this to CGA?*/
+ while (height--) {
+ memcpy(frontbuffer + offs, backbuffer + offs, 1);
-void DrawWallA(unsigned int n, unsigned int limit, unsigned int w, unsigned char h, unsigned int ofs) {
- do {
- CGA_HideScreenBlockLiftToRight(1, frontbuffer, backbuffer, w, h, frontbuffer, ofs);
- w--;
- if (n == limit)
- return;
- } while (n--);
-
- ofs += 1;
-
- while (h--) {
- memcpy(frontbuffer + ofs, backbuffer + ofs, 1);
- ofs ^= CGA_ODD_LINES_OFS;
- if ((ofs & CGA_ODD_LINES_OFS) == 0)
- ofs += CGA_BYTES_PER_LINE;
+ offs ^= CGA_ODD_LINES_OFS;
+ if ((offs & CGA_ODD_LINES_OFS) == 0)
+ offs += CGA_BYTES_PER_LINE;
}
}
-void DrawWallB(unsigned int n, unsigned int limit, unsigned int w, unsigned char h, unsigned int ofs) {
- do {
- CGA_HideScreenBlockLiftToLeft(1, frontbuffer, backbuffer, w, h, frontbuffer, ofs);
- w--;
- if (n == limit)
+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);
+
+ while (--width) {
+ CGA_HideScreenBlockLiftToLeft(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ if (width == limit)
return;
- } while (n--);
+ }
- ofs -= 1;
+ offs--;
- while (h--) {
- memcpy(frontbuffer + ofs, backbuffer + ofs, 1);
- ofs ^= CGA_ODD_LINES_OFS;
- if ((ofs & CGA_ODD_LINES_OFS) == 0)
- ofs += CGA_BYTES_PER_LINE;
+ /*hide remaining column*/
+ /*TODO: move this to CGA?*/
+ while (height--) {
+ memcpy(frontbuffer + offs, backbuffer + offs, 1);
+
+ offs ^= CGA_ODD_LINES_OFS;
+ if ((offs & CGA_ODD_LINES_OFS) == 0)
+ offs += CGA_BYTES_PER_LINE;
}
}
-
-void TheWallPhase3(void) {
+/*
+Animate The Wall doors
+Phase 3: Fully closed -> Half opened
+*/
+void TheWallPhase3_DoorOpen1(void) {
script_byte_vars.zone_index = (script_byte_vars.zone_index == 95) ? 9 : 102;
LoadZone();
-#if 0
- cur_image_width_full = 40 / 4;
- TheWallOpenRightDoor();
-#endif
- /*TODO*/
+ TheWallOpenRightDoor(144 / 4, 32, 80 / 4, 59, 40 / 4);
+ TheWallOpenLeftDoor(64 / 4, 32, 80 / 4, 59, 40 / 4);
+
+ /*TODO: fill in the_wall_door_* structures, as they are used by the original code and appear in savefile*/
}
-void TheWallPhase0(void) {
+/*
+Animate The Wall doors
+Phase 0: Half opened -> Fully opened
+*/
+void TheWallPhase0_DoorOpen2(void) {
script_byte_vars.zone_index = (script_byte_vars.zone_index == 9) ? 24 : 30;
LoadZone();
- /*TODO*/
- /*
- DrawWallA(unsigned int n, 0, unsigned int w, unsigned char h, unsigned int ofs);
- DrawWallB(unsigned int n, 0, unsigned int w, unsigned char h, unsigned int ofs);
- */
+ TheWallOpenRightDoor((144 + 40) / 4, 32, (80 - 40) / 4, 59, 0);
+ TheWallOpenLeftDoor(64 / 4, 32, (80 - 40) / 4, 59, 0);
+ /*TODO: fill in the_wall_door_* structures, as they are used by the original code and appear in savefile*/
}
-/*Opened -> Half closed*/
+/*
+Animate The Wall doors
+Phase 1: Opened -> Half closed
+*/
void TheWallPhase1_DoorClose1(void) {
unsigned char *spr;
@@ -1359,9 +1433,14 @@ void TheWallPhase1_DoorClose1(void) {
spr = LoadMursmSprite(1);
cur_image_coords_x = 220 / 4;
CGA_AnimLiftToLeft(10, spr, cur_frame_width, 1, cur_image_size_h, frontbuffer, CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y));
+
+ /*TODO: fill in the_wall_door_* structures, as they are used by the original code and appear in savefile*/
}
-/*Half closed -> Fully closed*/
+/*
+Animate The Wall doors
+Phase 2: Half closed -> Fully closed
+*/
void TheWallPhase2_DoorClose2(void) {
unsigned char *spr;
@@ -1376,8 +1455,13 @@ void TheWallPhase2_DoorClose2(void) {
spr = LoadMursmSprite(1);
cur_image_coords_x = 220 / 4;
CGA_AnimLiftToLeft(10, spr, cur_frame_width, 1 + 10, cur_image_size_h, frontbuffer, CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y) - 10);
+
+ /*TODO: fill in the_wall_door_* structures, as they are used by the original code and appear in savefile*/
}
+/*
+Draw default The Wall doors
+*/
void DrawTheWallDoors(void) {
switch (script_byte_vars.zone_index) {
case 9:
@@ -1429,24 +1513,35 @@ 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) {
*spotback = buffer;
buffer = CGA_BackupImage(backbuffer, CGA_CalcXY_p(spot->sx, spot->sy), spot->ex - spot->sx, spot->ey - spot->sy, buffer);
return buffer;
}
+/*
+Save zone spot images to sprites list
+*/
void BackupSpotsImages(void) {
spot_t *spot = zone_spots;
unsigned char *buffer = scratch_mem1;
int 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 i if spot is skipped?*/
+ for (i = 0; spot != zone_spots_end; spot++, i++) { /*TODO: maybe don't advance it if spot is skipped?*/
if (spot->flags & SPOTFLG_40)
buffer = BackupSpotImage(spot, &sprites_list[i], buffer);
}
}
+/*
+Animate all room's persons, one per call
+TODO: rename me
+*/
void DrawSpots(unsigned char *target) {
spot_t *spot = zone_spots_cur;
unsigned char spridx = zone_spr_index;
@@ -1478,11 +1573,18 @@ void DrawSpots(unsigned char *target) {
zone_spr_index = spridx;
}
+/*
+Animate room's persons at fixed rate
+TODO: rename me
+*/
void AnimateSpots(unsigned char *target) {
if (script_byte_vars.timer_ticks % 32 == 31)
DrawSpots(target);
}
+/*
+Draw cursor and hints text on screen
+*/
void DrawHintsAndCursor(unsigned char *target) {
UpdateCursor();
WaitVBlank();
@@ -1505,10 +1607,13 @@ void HideSpot(unsigned char offset) {
found_spot->flags &= ~SPOTFLG_80;
}
-static const unsigned char timed_seq[] = {56, 51, 44, 12, 10, 20, 18, 16, 14, 12, 44, 51};
-static const unsigned char *timed_seq_ptr = timed_seq;
+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;
-/*TODO: rename this*/
+/*
+Protozorq AI 1
+TODO: rename this
+*/
void UpdateTimedRects1(void) {
unsigned int elapsed;
@@ -1646,7 +1751,11 @@ void UpdateTimedRects1(void) {
}
}
-/*TODO: rename this*/
+
+/*
+Protozorq AI 2
+TODO: rename this
+*/
void UpdateTimedRects2(void) {
unsigned int elapsed = Swap16(script_word_vars.timer_ticks2);
diff --git a/engines/chamber/room.h b/engines/chamber/room.h
index bb8072eafcf..c1982c185d5 100644
--- a/engines/chamber/room.h
+++ b/engines/chamber/room.h
@@ -114,13 +114,20 @@ extern unsigned short next_command4;
extern unsigned char *sprites_list[MAX_SPRITES];
+#define MAX_DOORS 5
+
+extern unsigned char *doors_list[MAX_DOORS];
+
extern unsigned char zone_palette;
extern spot_t *zone_spots;
extern spot_t *zone_spots_end;
extern spot_t *zone_spots_cur;
+extern vortanims_t vortsanim_list[];
extern vortanims_t *vortanims_ptr;
+
+extern rec7_t recs7_list[];
extern rec7_t *rec7_ptr;
extern pers_t *pers_ptr;
extern spot_t *spot_ptr;
@@ -133,7 +140,27 @@ extern unsigned char zone_drawn;
extern unsigned char 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 unsigned short inv_update_time;
+
+extern const unsigned char timed_seq[];
+extern const unsigned char *timed_seq_ptr;
+
+typedef struct thewalldoor_t {
+ unsigned char height;
+ unsigned char width;
+ unsigned int pitch;
+ unsigned int offs;
+ unsigned char *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);
@@ -190,8 +217,8 @@ void BounceCurrentItem(unsigned char flags, unsigned char y);
void BackupScreenOfSpecialRoom(void);
void RestoreScreenOfSpecialRoom(void);
-void TheWallPhase3(void);
-void TheWallPhase0(void);
+void TheWallPhase3_DoorOpen1(void);
+void TheWallPhase0_DoorOpen2(void);
void TheWallPhase1_DoorClose1(void);
void TheWallPhase2_DoorClose2(void);
diff --git a/engines/chamber/savegame.cpp b/engines/chamber/savegame.cpp
index 0cd9af81b8f..e06c9d7eb77 100644
--- a/engines/chamber/savegame.cpp
+++ b/engines/chamber/savegame.cpp
@@ -27,10 +27,10 @@
#include "chamber/script.h"
#include "chamber/cga.h"
#include "chamber/room.h"
+#include "chamber/dialog.h"
namespace Chamber {
-
void SaveRestartGame(void) {
/*TODO*/
}
@@ -57,10 +57,34 @@ void RestartGame(void) {
#define CGA_SAVE_ZONES_OFS 0x7A27
#define CGA_SAVE_PERS_OFS 0x7765
#define CGA_SAVE_STACK_OFS 0x7562
+#define CGA_SAVE_SPRITES_OFS 0x5264
+#define CGA_SAVE_SPRLIST_OFS 0x7530
+#define CGA_SAVE_SPRBUFF_OFS 0x4C68
+#define CGA_SAVE_ARPLA_OFS 0x26F6
+#define CGA_SAVE_SCRSTACK_OFS 0x7562
+#define CGA_SAVE_TEMPL_OFS 0x182C
+#define CGA_SAVE_VORTANIMS_OFS 0xA609
+#define CGA_SAVE_RECS7_OFS 0xA74E
+#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)
+
+#define LOADADDR(value, base, nativesize, origsize, origbase) \
+ ((value) ? ((((LE16(value)) - (origbase)) / origsize) * nativesize + (unsigned char*)base) : 0)
+
+#define WRITE(buffer, size) \
+ wlen = write(f, buffer, size); if(wlen != size) goto error;
+
+#define READ(buffer, size) \
+ rlen = read(f, buffer, size); if(rlen != size) goto error;
int LoadScena(void) {
int f;
int rlen;
+ unsigned short zero = 0;
+ unsigned char *p;
+ int i;
script_byte_vars.game_paused = 1;
@@ -75,24 +99,239 @@ int LoadScena(void) {
vars memory (751E-9D5D)
frontbuffer (0x3FFF bytes)
backbuffer (0x3FFF bytes)
+ */
+#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 POINTER(variable, base, nativesize, origsize, origbase) \
+ { signed short 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);
+ POINTER(script_vars[ScrPool1_WordVars1], &script_word_vars, 2, 2, CGA_SAVE_WORD_VARS_OFS);
+ POINTER(script_vars[ScrPool2_ByteVars], &script_byte_vars, 1, 1, CGA_SAVE_BYTE_VARS_OFS);
+ POINTER(script_vars[ScrPool3_CurrentItem], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
+ POINTER(script_vars[ScrPool4_ZoneSpots], zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
+ POINTER(script_vars[ScrPool5_Persons], pers_list, 1, 1, CGA_SAVE_PERS_OFS);
+ POINTER(script_vars[ScrPool6_Inventory], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
+ POINTER(script_vars[ScrPool7_Inventory38], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
+ POINTER(script_vars[ScrPool8_CurrentPers], pers_list, 1, 1, CGA_SAVE_PERS_OFS);
+
+ /* sprites_list */
+ for (i = 0; i < MAX_SPRITES; i++) {
+ POINTER(sprites_list[i], scratch_mem1, 1, 1, CGA_SAVE_SPRITES_OFS);
+ }
- */
+ /* doors list */
+ for (i = 0; i < MAX_DOORS; i++) {
+ POINTER(doors_list[i], arpla_data, 1, 1, CGA_SAVE_ARPLA_OFS);
+ }
+ /* zone_spots */
+ POINTER((unsigned char *)zone_spots, zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
- /*TODO*/
+ /* zone_spots_end */
+ POINTER((unsigned char *)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);
+
+ /* 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);
+
+ /* script_stack */
+ /*TODO: FIX ME: original stack works in reverse order (from higher address to lower)*/
+ for (i = 0; i < 5 * 2; i++) {
+ POINTER(script_stack[i], templ_data, 1, 1, CGA_SAVE_TEMPL_OFS);
+ }
+
+ /* padding */
+ USHORT(zero);
+
+ /* pers_vort_ptr */
+ POINTER((unsigned char *)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);
+
+ /* rec7_ptr */
+ POINTER((unsigned char *)rec7_ptr, recs7_list, 1, 1, CGA_SAVE_RECS7_OFS);
+
+ /* pers_ptr */
+ POINTER((unsigned char *)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);
+
+ /* found_spot */
+ POINTER((unsigned char *)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);
+
+ /* timed_seq_ptr */
+ POINTER(timed_seq_ptr, timed_seq, 1, 1, CGA_SAVE_TIMEDSEQ_OFS);
+
+ /* keep_sp */
+ /* TODO: how to save it? but it's probably useless anyway */
+ USHORT(zero);
+
+ /* unused ptr to script code */
+ p = templ_data;
+ POINTER(p, templ_data, 1, 1, CGA_SAVE_TEMPL_OFS);
+
+ /* padding */
+ UBYTE(zero);
+
+ /* the wall doors state */
+ for (i = 0; i < 2; i++) {
+ thewalldoor_t *door = &the_wall_doors[i];
+ UBYTE(door->height);
+ UBYTE(door->width);
+ USHORT(door->pitch);
+ USHORT(door->offs);
+ POINTER(door->pixels, sprit_load_buffer, 1, 1, CGA_SAVE_SPRBUFF_OFS);
+ }
+
+ /* wait_delta */
+ UBYTE(wait_delta);
+
+ /* padding */
+ UBYTE(zero);
+
+ /* dirty_rects */
+ for (i = 0; i < MAX_DIRTY_RECT; i++) {
+ dirty_rect_t *dr = &dirty_rects[i];
+ UBYTE(dr->kind);
+ USHORT(dr->offs);
+ UBYTE(dr->height);
+ UBYTE(dr->width);
+ UBYTE(dr->y);
+ UBYTE(dr->x);
+ }
+
+ /* inventory_items */
+ for (i = 0; i < MAX_INV_ITEMS; i++) {
+ /*TODO: properly serialize this*/
+ BYTES(&inventory_items[i], sizeof(item_t));
+ }
+
+ /* room_hint_bar_coords_y */
+ UBYTE(room_hint_bar_coords_y);
+
+ /* room_hint_bar_coords_x */
+ UBYTE(room_hint_bar_coords_x);
+
+ /* padding */
+ USHORT(zero);
+
+ /* fight_pers_ofs */
+ /* NB! raw offset */
+ USHORT(fight_pers_ofs);
+
+ /* pers_list */
+ for (i = 0; i < PERS_MAX; i++) {
+ /*TODO: properly serialize this*/
+ BYTES(&pers_list[i], sizeof(pers_t));
+ }
+
+ /* inv_update_time */
+ USHORT(inv_update_time);
+
+ /* room_bounds_rect */
+ /*TODO: properly serialize this*/
+ BYTES(&room_bounds_rect, sizeof(rect_t));
+
+ /* last_object_hint */
+ UBYTE(last_object_hint);
+
+ /* object_hint */
+ UBYTE(object_hint);
+
+ /* command_hint */
+ UBYTE(command_hint);
+
+ /* zone_name */
+ UBYTE(zone_name);
+
+ /* room_hint_bar_width */
+ UBYTE(room_hint_bar_width);
+
+ /* last_command_hint */
+ UBYTE(last_command_hint);
+
+ /* zone_spr_index */
+ UBYTE(zone_spr_index);
+
+ /* zone_obj_count */
+ UBYTE(zone_obj_count);
+
+ /* padding */
+ USHORT(zero);
+
+ /* padding */
+ UBYTE(zero);
+
+ /* in_de_profundis */
+ UBYTE(in_de_profundis);
+
+ /* script_word_vars */
+ BYTES(&script_word_vars, sizeof(script_word_vars));
+
+ /* menu_commands_12 */
+ BYTES(menu_commands_12, sizeof(menu_commands_12));
+
+ /* menu_commands_22 */
+ BYTES(menu_commands_22, sizeof(menu_commands_22));
+
+ /* menu_commands_24 */
+ BYTES(menu_commands_24, sizeof(menu_commands_24));
+
+ /* menu_commands_23 */
+ BYTES(menu_commands_23, sizeof(menu_commands_23));
+ /* next_command3 */
+ USHORT(next_command3);
- rlen = read(f, backbuffer, 0x3FFF);
- if (rlen != 0x3FFF)
- goto error;
+ /* next_ticks3 */
+ USHORT(next_ticks3);
+
+ /* next_command4 */
+ USHORT(next_command4);
+
+ /* next_ticks4 */
+ USHORT(next_ticks4);
+
+ /* next_ticks2 */
+ USHORT(next_ticks2);
+
+ /* padding */
+ for (i = 0; i < 7; i++) USHORT(zero);
+
+ /* script_byte_vars */
+ BYTES(&script_byte_vars, sizeof(script_byte_vars));
+
+ /* zones_data */
+ BYTES(zones_data, RES_ZONES_MAX);
+
+ /* screen data */
+ BYTES(backbuffer, 0x3FFF);
CGA_BackBufferToRealFull();
SelectPalette();
- rlen = read(f, backbuffer, 0x3FFF);
- if (rlen != 0x3FFF)
- goto error;
+ BYTES(backbuffer, 0x3FFF);
+
+#undef BYTES
+#undef UBYTE
+#undef SBYTE
+#undef USHORT
+#undef SSHORT
+#undef POINTER
/*re-initialize sprites list*/
BackupSpotsImages();
@@ -108,13 +347,12 @@ error:
return 1;
}
-#define SAVEADDR(value, base, nativesize, origsize, origbase) \
- LE16(((((unsigned char*)(value)) - (unsigned char*)(base)) / nativesize) * origsize + origbase)
-
int SaveScena(void) {
int f;
int wlen;
- unsigned short ofs16;
+ unsigned short zero = 0;
+ unsigned char *p;
+ int i;
script_byte_vars.game_paused = 1;
BlitSpritesToBackBuffer();
@@ -125,55 +363,233 @@ int SaveScena(void) {
return 1; /*error*/
}
- ofs16 = SAVEADDR(script_vars[ScrPool0_WordVars0], &script_word_vars, 2, 2, CGA_SAVE_WORD_VARS_OFS);
- wlen = write(f, &ofs16, 2);
- if (wlen != 2) goto error;
+#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 POINTER(variable, base, nativesize, origsize, origbase) \
+ { signed short 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);
+ POINTER(script_vars[ScrPool1_WordVars1], &script_word_vars, 2, 2, CGA_SAVE_WORD_VARS_OFS);
+ POINTER(script_vars[ScrPool2_ByteVars], &script_byte_vars, 1, 1, CGA_SAVE_BYTE_VARS_OFS);
+ POINTER(script_vars[ScrPool3_CurrentItem], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
+ POINTER(script_vars[ScrPool4_ZoneSpots], zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
+ POINTER(script_vars[ScrPool5_Persons], pers_list, 1, 1, CGA_SAVE_PERS_OFS);
+ POINTER(script_vars[ScrPool6_Inventory], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
+ POINTER(script_vars[ScrPool7_Inventory38], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
+ POINTER(script_vars[ScrPool8_CurrentPers], pers_list, 1, 1, CGA_SAVE_PERS_OFS);
+
+ /* sprites_list */
+ for (i = 0; i < MAX_SPRITES; i++) {
+ POINTER(sprites_list[i], scratch_mem1, 1, 1, CGA_SAVE_SPRITES_OFS);
+ }
- ofs16 = SAVEADDR(script_vars[ScrPool1_WordVars1], &script_word_vars, 2, 2, CGA_SAVE_WORD_VARS_OFS);
- wlen = write(f, &ofs16, 2);
- if (wlen != 2) goto error;
+ /* doors list */
+ for (i = 0; i < MAX_DOORS; i++) {
+ POINTER(doors_list[i], arpla_data, 1, 1, CGA_SAVE_ARPLA_OFS);
+ }
- ofs16 = SAVEADDR(script_vars[ScrPool2_ByteVars], &script_byte_vars, 1, 1, CGA_SAVE_BYTE_VARS_OFS);
- wlen = write(f, &ofs16, 2);
- if (wlen != 2) goto error;
+ /* zone_spots */
+ POINTER(zone_spots, zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
- ofs16 = SAVEADDR(script_vars[ScrPool3_CurrentItem], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
- wlen = write(f, &ofs16, 2);
- if (wlen != 2) goto error;
+ /* zone_spots_end */
+ POINTER(zone_spots_end, zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
- ofs16 = SAVEADDR(script_vars[ScrPool4_ZoneSpots], zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
- wlen = write(f, &ofs16, 2);
- if (wlen != 2) goto error;
+ /* zone_spots_cur */
+ POINTER(zone_spots_cur, zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
- ofs16 = SAVEADDR(script_vars[ScrPool5_Persons], pers_list, 1, 1, CGA_SAVE_PERS_OFS);
- wlen = write(f, &ofs16, 2);
- if (wlen != 2) goto error;
+ /* script_stack_ptr */
+ /*TODO: FIX ME: original stack works in reverse order (from higher address to lower)*/
+ POINTER(script_stack_ptr, script_stack, 1, 1, CGA_SAVE_SCRSTACK_OFS);
- ofs16 = SAVEADDR(script_vars[ScrPool6_Inventory], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
- wlen = write(f, &ofs16, 2);
- if (wlen != 2) goto error;
+ /* script_stack */
+ /*TODO: FIX ME: original stack works in reverse order (from higher address to lower)*/
+ for (i = 0; i < 5 * 2; i++) {
+ POINTER(script_stack[i], templ_data, 1, 1, CGA_SAVE_TEMPL_OFS);
+ }
- ofs16 = SAVEADDR(script_vars[ScrPool7_Inventory38], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
- wlen = write(f, &ofs16, 2);
- if (wlen != 2) goto error;
+ /* padding */
+ USHORT(zero);
- ofs16 = SAVEADDR(script_vars[ScrPool8_CurrentPers], pers_list, 1, 1, CGA_SAVE_PERS_OFS);
- wlen = write(f, &ofs16, 2);
- if (wlen != 2) goto error;
+ /* pers_vort_ptr */
+ POINTER(pers_vort_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS);
+ /* vortanims_ptr */
+ POINTER(vortanims_ptr, vortsanim_list, 1, 1, CGA_SAVE_VORTANIMS_OFS);
- /*TODO*/
+ /* rec7_ptr */
+ POINTER(rec7_ptr, recs7_list, 1, 1, CGA_SAVE_RECS7_OFS);
+
+ /* pers_ptr */
+ POINTER(pers_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS);
+
+ /* spot_ptr */
+ POINTER(spot_ptr, zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
+
+ /* found_spot */
+ POINTER(found_spot, zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
+
+ /* spot_sprite */
+ POINTER(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);
+
+ /* keep_sp */
+ /* TODO: how to save it? but it's probably useless anyway */
+ USHORT(zero);
+
+ /* unused ptr to script code */
+ p = templ_data;
+ POINTER(p, templ_data, 1, 1, CGA_SAVE_TEMPL_OFS);
+
+ /* padding */
+ UBYTE(zero);
+
+ /* the wall doors state */
+ for (i = 0; i < 2; i++) {
+ thewalldoor_t *door = &the_wall_doors[i];
+ UBYTE(door->height);
+ UBYTE(door->width);
+ USHORT(door->pitch);
+ USHORT(door->offs);
+ POINTER(door->pixels, sprit_load_buffer, 1, 1, CGA_SAVE_SPRBUFF_OFS);
+ }
+
+ /* wait_delta */
+ UBYTE(wait_delta);
+
+ /* padding */
+ UBYTE(zero);
+
+ /* dirty_rects */
+ for (i = 0; i < MAX_DIRTY_RECT; i++) {
+ dirty_rect_t *dr = &dirty_rects[i];
+ UBYTE(dr->kind);
+ USHORT(dr->offs);
+ UBYTE(dr->height);
+ UBYTE(dr->width);
+ UBYTE(dr->y);
+ UBYTE(dr->x);
+ }
+
+ /* inventory_items */
+ for (i = 0; i < MAX_INV_ITEMS; i++) {
+ /*TODO: properly serialize this*/
+ BYTES(&inventory_items[i], sizeof(item_t));
+ }
+
+ /* room_hint_bar_coords_y */
+ UBYTE(room_hint_bar_coords_y);
+
+ /* room_hint_bar_coords_x */
+ UBYTE(room_hint_bar_coords_x);
+
+ /* padding */
+ USHORT(zero);
+
+ /* fight_pers_ofs */
+ /* NB! raw offset */
+ USHORT(fight_pers_ofs);
+
+ /* pers_list */
+ for (i = 0; i < PERS_MAX; i++) {
+ /*TODO: properly serialize this*/
+ BYTES(&pers_list[i], sizeof(pers_t));
+ }
+
+ /* inv_update_time */
+ USHORT(inv_update_time);
+
+ /* room_bounds_rect */
+ /*TODO: properly serialize this*/
+ BYTES(&room_bounds_rect, sizeof(rect_t));
+
+ /* last_object_hint */
+ UBYTE(last_object_hint);
+
+ /* object_hint */
+ UBYTE(object_hint);
+
+ /* command_hint */
+ UBYTE(command_hint);
+
+ /* zone_name */
+ UBYTE(zone_name);
+
+ /* room_hint_bar_width */
+ UBYTE(room_hint_bar_width);
+
+ /* last_command_hint */
+ UBYTE(last_command_hint);
+
+ /* zone_spr_index */
+ UBYTE(zone_spr_index);
+
+ /* zone_obj_count */
+ UBYTE(zone_obj_count);
+
+ /* padding */
+ USHORT(zero);
+
+ /* padding */
+ UBYTE(zero);
+
+ /* in_de_profundis */
+ UBYTE(in_de_profundis);
+
+ /* script_word_vars */
+ BYTES(&script_word_vars, sizeof(script_word_vars));
+
+ /* menu_commands_12 */
+ BYTES(menu_commands_12, sizeof(menu_commands_12));
+
+ /* menu_commands_22 */
+ BYTES(menu_commands_22, sizeof(menu_commands_22));
+
+ /* menu_commands_24 */
+ BYTES(menu_commands_24, sizeof(menu_commands_24));
+
+ /* menu_commands_23 */
+ BYTES(menu_commands_23, sizeof(menu_commands_23));
+
+ /* next_command3 */
+ USHORT(next_command3);
+
+ /* next_ticks3 */
+ USHORT(next_ticks3);
+
+ /* next_command4 */
+ USHORT(next_command4);
+
+ /* next_ticks4 */
+ USHORT(next_ticks4);
+
+ /* next_ticks2 */
+ USHORT(next_ticks2);
+ /* padding */
+ for (i = 0; i < 7; i++) USHORT(zero);
+ /* script_byte_vars */
+ BYTES(&script_byte_vars, sizeof(script_byte_vars));
+ /* zones_data */
+ BYTES(zones_data, RES_ZONES_MAX);
- wlen = write(f, frontbuffer, 0x3FFF);
- if (wlen != 0x3FFF)
- goto error;
+ /* screen data */
+ BYTES(frontbuffer, 0x3FFF);
+ BYTES(backbuffer, 0x3FFF);
- wlen = write(f, backbuffer, 0x3FFF);
- if (wlen != 0x3FFF)
- goto error;
+#undef BYTES
+#undef UBYTE
+#undef SBYTE
+#undef USHORT
+#undef SSHORT
+#undef POINTER
close(f);
script_byte_vars.game_paused = 0;
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 2f85ac1f0b9..77ab9fb0a4d 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -37,15 +37,14 @@
#include "chamber/sound.h"
#include "chamber/savegame.h"
+namespace Chamber {
#if 1
#define DEBUG_SCRIPT
char DEBUG_SCRIPT_LOG[] = "!script.log";
#endif
-#include "chamber/scrvars.h"
-
-namespace Chamber {
+#include "scrvars.h"
unsigned char rand_seed;
unsigned short the_command;
@@ -1172,10 +1171,10 @@ unsigned int SCR_3E_TheWallAdvance(void) {
script_byte_vars.the_wall_phase = (script_byte_vars.the_wall_phase + 1) % 4;
switch (script_byte_vars.the_wall_phase) {
default:
- TheWallPhase3();
+ TheWallPhase3_DoorOpen1();
break;
case 0:
- TheWallPhase0();
+ TheWallPhase0_DoorOpen2();
break;
case 1:
TheWallPhase1_DoorClose1();
@@ -2167,7 +2166,7 @@ unsigned int CMD_2_PsiPowers(void) {
ProcessInput();
do {
PollInput();
- SelectCursor(CURSOR_0);
+ SelectCursor(CURSOR_FINGER);
CheckPsiCommandHover();
if (command_hint != 100)
command_hint += 109;
@@ -2507,7 +2506,7 @@ unsigned int CMD_F_PsiPsiShift(void) {
return ScriptRerun;
}
- SelectCursor(CURSOR_4);
+ SelectCursor(CURSOR_GRAB);
MenuLoop(0, 0);
BackupScreenOfSpecialRoom();
PlaySound(25);
diff --git a/engines/chamber/script.h b/engines/chamber/script.h
index e1df96d5b62..5803a8959bf 100644
--- a/engines/chamber/script.h
+++ b/engines/chamber/script.h
@@ -210,6 +210,21 @@ 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 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 unsigned short fight_pers_ofs;
+
+extern unsigned char wait_delta;
+
extern unsigned char rand_seed;
unsigned char Rand(void);
unsigned int RandW(void);
Commit: 5cf12776bee29b7a59dce930bd028838eb631c4e
https://github.com/scummvm/scummvm/commit/5cf12776bee29b7a59dce930bd028838eb631c4e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Made anim.cpp compilable
Changed paths:
engines/chamber/anim.cpp
engines/chamber/cga.h
engines/chamber/chamber.h
engines/chamber/common.h
engines/chamber/module.mk
engines/chamber/room.h
diff --git a/engines/chamber/anim.cpp b/engines/chamber/anim.cpp
index 37e0a9d0ec4..fddd60a1aac 100644
--- a/engines/chamber/anim.cpp
+++ b/engines/chamber/anim.cpp
@@ -31,7 +31,7 @@
namespace Chamber {
-unsigned char far *anima_end_ofs;
+unsigned char *anima_end_ofs;
unsigned char last_anim_y = 0;
unsigned char last_anim_x = 0;
@@ -48,7 +48,7 @@ unsigned int dot_effect_delay;
extern unsigned short cpu_speed_delay;
-extern unsigned char *SeekToEntry(unsigned char far *bank, unsigned int num, unsigned char far **end);
+extern unsigned char *SeekToEntry(unsigned char *bank, unsigned int num, unsigned char **end);
extern void LoadLutinSprite(unsigned int lutidx);
void GetScratchBuffer(unsigned char mode) {
@@ -195,7 +195,7 @@ void PlayAnimCore(unsigned char **panim) {
dot_effect_delay = 500;
count2 = mode & 7;
while (count2--) {
- unsigned char far *sprite;
+ unsigned char *sprite;
unsigned char sprw, sprh;
unsigned char x, y;
signed char dx, dy;
diff --git a/engines/chamber/cga.h b/engines/chamber/cga.h
index c043536a545..6b720093f6d 100644
--- a/engines/chamber/cga.h
+++ b/engines/chamber/cga.h
@@ -33,7 +33,7 @@ namespace Chamber {
#define CGA_PIXELS_PER_BYTE (8 / CGA_BITS_PER_PIXEL)
#define CGA_BYTES_PER_LINE (CGA_WIDTH / CGA_PIXELS_PER_BYTE)
-#define CGA_SCREENBUFFER ((unsigned char*)MK_FP(CGA_BASE_SEG, 0))
+#define CGA_SCREENBUFFER NULL
#define CGA_FONT_HEIGHT 6
diff --git a/engines/chamber/chamber.h b/engines/chamber/chamber.h
index 59621f40cf8..fd4f96696a0 100644
--- a/engines/chamber/chamber.h
+++ b/engines/chamber/chamber.h
@@ -23,6 +23,8 @@
#ifndef CHAMBER_H
#define CHAMBER_H
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
#include "common/random.h"
#include "common/serializer.h"
#include "engines/engine.h"
diff --git a/engines/chamber/common.h b/engines/chamber/common.h
index e4ae62840c4..a8c9a8df905 100644
--- a/engines/chamber/common.h
+++ b/engines/chamber/common.h
@@ -35,16 +35,14 @@ namespace Chamber {
for(;;) ; \
}
+#include "common/pack-start.h"
typedef struct rect_t {
unsigned char sx;
unsigned char ex;
unsigned char sy;
unsigned char ey;
} rect_t;
-
-#if sizeof(rect_t) != 4
-#error "rect_t must be 4 bytes long"
-#endif
+#include "common/pack-end.h"
#if 0
#define DEBUG
diff --git a/engines/chamber/module.mk b/engines/chamber/module.mk
index 7e089ed9c41..0c0ffc79b1c 100644
--- a/engines/chamber/module.mk
+++ b/engines/chamber/module.mk
@@ -1,8 +1,9 @@
MODULE := engines/chamber
MODULE_OBJS := \
- metaengine.o \
- chamber.o
+ anim.o \
+ chamber.o \
+ metaengine.o
MODULE_DIRS += \
engines/chamber
diff --git a/engines/chamber/room.h b/engines/chamber/room.h
index c1982c185d5..2cd48eb15c6 100644
--- a/engines/chamber/room.h
+++ b/engines/chamber/room.h
@@ -34,6 +34,7 @@ namespace Chamber {
/*static room object*/
/*TODO: manipulated from script, do not change*/
+#include "common/pack-start.h"
typedef struct spot_t {
unsigned char sx;
unsigned char ex;
@@ -43,10 +44,7 @@ typedef struct spot_t {
unsigned char hint;
unsigned short command;
} spot_t;
-
-#if sizeof(spot_t) != 8
-#error "spot_t must be 8 bytes long"
-#endif
+#include "common/pack-end.h"
#define PERSFLAGS 0xF0
#define PERSFLG_10 0x10
@@ -56,6 +54,7 @@ typedef struct spot_t {
/*person*/
/*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*/
@@ -63,10 +62,7 @@ typedef struct pers_t {
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)*/
} pers_t;
-
-#if sizeof(pers_t) != 5
-#error "pers_t must be 5 bytes long"
-#endif
+#include "common/pack-end.h"
#define ANIMFLG_USESPOT 0x80
Commit: c08e01cc19d2f93944ce56a75bf7d99cadd5514d
https://github.com/scummvm/scummvm/commit/c08e01cc19d2f93944ce56a75bf7d99cadd5514d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix compilation for [bc]*.cpp
Changed paths:
engines/chamber/cga.cpp
engines/chamber/cursor.cpp
engines/chamber/module.mk
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 2ac36b65c1f..67a13512405 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -70,29 +70,22 @@ unsigned char cga_pixel_flip[256] = {
Switch to CGA 320x200x2bpp mode
*/
void SwitchToGraphicsMode(void) {
- union REGS reg;
-
- reg.x.ax = 4;
- int86(0x10, ®, ®);
+ warning("STUB: SwitchToGraphicsMode()");
}
/*
Switch to text mode
*/
void SwitchToTextMode(void) {
- union REGS reg;
-
- reg.x.ax = 3;
- int86(0x10, ®, ®);
+ warning("STUB: SwitchToTextMode()");
}
void WaitVBlank(void) {
- while ((inportb(0x3DA) & 8) != 0) ;
- while ((inportb(0x3DA) & 8) == 0) ;
}
void CGA_ColorSelect(unsigned char csel) {
- outportb(0x3D9, csel);
+ warning("STUB: CGA_ColorSelect(%d)", csel);
+ //outportb(0x3D9, csel);
}
void CGA_BackBufferToRealFull(void) {
@@ -121,8 +114,8 @@ void CGA_SwapRealBackBuffer(void) {
unsigned int i;
unsigned short *s, *d;
WaitVBlank();
- s = (unsigned short far *)CGA_SCREENBUFFER;
- d = (unsigned short far *)backbuffer;
+ s = (unsigned short *)CGA_SCREENBUFFER;
+ d = (unsigned short *)backbuffer;
for (i = 0; i < sizeof(backbuffer) / 2; i++) {
unsigned short t = *s;
*s++ = *d;
@@ -192,7 +185,10 @@ unsigned char *CGA_BackupImage(unsigned char *screen, unsigned int ofs, unsigned
}
unsigned char *CGA_BackupImageReal(unsigned int ofs, unsigned int w, unsigned int h) {
- return CGA_BackupImage(MK_FP(CGA_BASE_SEG, 0), ofs, w, h, scratch_mem2);
+ warning("STUB: CGA_BackupImageReal()");
+
+ return NULL;
+ //return CGA_BackupImage(MK_FP(CGA_BASE_SEG, 0), ofs, w, h, scratch_mem2);
}
/*
diff --git a/engines/chamber/cursor.cpp b/engines/chamber/cursor.cpp
index 80972691afc..d9c2a020e27 100644
--- a/engines/chamber/cursor.cpp
+++ b/engines/chamber/cursor.cpp
@@ -57,7 +57,6 @@ 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;
-unsigned char cursor_bit_shift;
/*
Select cursor shape and its hotspot
diff --git a/engines/chamber/module.mk b/engines/chamber/module.mk
index 0c0ffc79b1c..e7255e199d0 100644
--- a/engines/chamber/module.mk
+++ b/engines/chamber/module.mk
@@ -2,7 +2,10 @@ MODULE := engines/chamber
MODULE_OBJS := \
anim.o \
+ bkbuff.o \
+ cga.o \
chamber.o \
+ cursor.o \
metaengine.o
MODULE_DIRS += \
Commit: 8b82922f3f08e6fae2f296a61a082e11892e0877
https://github.com/scummvm/scummvm/commit/8b82922f3f08e6fae2f296a61a082e11892e0877
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: More compilation fixes
Changed paths:
engines/chamber/decompr.cpp
engines/chamber/decompr.h
engines/chamber/input.cpp
engines/chamber/kult.cpp
engines/chamber/menu.cpp
engines/chamber/module.mk
engines/chamber/resdata.cpp
engines/chamber/room.cpp
engines/chamber/script.h
diff --git a/engines/chamber/decompr.cpp b/engines/chamber/decompr.cpp
index 3f4366fd787..b980311371d 100644
--- a/engines/chamber/decompr.cpp
+++ b/engines/chamber/decompr.cpp
@@ -49,7 +49,7 @@ unsigned char decode_string(unsigned char code, unsigned char prev_n, unsigned c
return code;
}
-unsigned long decompress(unsigned char huge *data, unsigned char huge *result) {
+unsigned long decompress(unsigned char *data, unsigned char *result) {
unsigned char dict_size, more;
unsigned int compsize;
unsigned int i;
@@ -118,4 +118,3 @@ unsigned long decompress(unsigned char huge *data, unsigned char huge *result) {
}
} // End of namespace Chamber
-
diff --git a/engines/chamber/decompr.h b/engines/chamber/decompr.h
index 0b3263ec39b..b795e74a2a3 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 huge *data, unsigned char huge *result);
+unsigned long decompress(unsigned char *data, unsigned char *result);
} // End of namespace Chamber
diff --git a/engines/chamber/input.cpp b/engines/chamber/input.cpp
index 4d75b0773d5..de4f72c2f87 100644
--- a/engines/chamber/input.cpp
+++ b/engines/chamber/input.cpp
@@ -41,27 +41,15 @@ unsigned char key_direction_old;
unsigned char accell_countdown;
unsigned int accelleration = 1;
-void interrupt(*old_keyboard_isr)(void);
-
unsigned char ReadKeyboardChar(void) {
-#ifdef DEBUG
- if (old_keyboard_isr) {
- do {
- PollInput();
- } while (!buttons);
- } else
-#endif
- return (unsigned char)getch();
-}
+ warning("STUB: ReadKeyboardChar()");
-void ClearKeyboard(void) {
- while (kbhit()) {
- getch();
- }
+ return 0;
+
+ //return (unsigned char)getch();
}
-void interrupt NullIsr(void) {
- /*nothing*/
+void ClearKeyboard(void) {
}
void SetInputButtons(unsigned char keys) {
@@ -79,12 +67,18 @@ void SetInputButtons(unsigned char keys) {
}
unsigned char PollMouse(void) {
+ warning("STUB: PollMouse()");
+
+ return 0;
+
+#if 0
union REGS reg;
reg.x.ax = 3;
int86(0x33, ®, ®);
cursor_x = reg.x.cx;
cursor_y = reg.h.dl;
return reg.h.bl; /*buttons*/
+#endif
}
unsigned char PollKeyboard(void) {
@@ -142,7 +136,9 @@ void ProcessInput(void) {
DrawCursor(frontbuffer);
}
-void interrupt KeyboardIsr() {
+void KeyboardIsr() {
+ warning("STUB: KeyboardIsr()");
+#if 0
unsigned char scan, strobe;
scan = inportb(0x60);
/*consume scan from kbd. controller*/
@@ -182,9 +178,13 @@ void interrupt KeyboardIsr() {
}
}
outportb(0x20, 0x20);
+#endif
}
void InitInput(void) {
+ warning("STUB: InitInput()");
+
+#if 0
/*disable critical errors handler*/
setvect(0x24, NullIsr);
@@ -227,16 +227,10 @@ void InitInput(void) {
old_keyboard_isr = getvect(9);
setvect(9, KeyboardIsr);
+#endif
}
void UninitInput(void) {
- if (have_mouse)
- return;
-
- setvect(9, old_keyboard_isr);
-#ifdef DEBUG
- old_keyboard_isr = 0;
-#endif
}
} // End of namespace Chamber
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 1f22ddc2cca..4525882d3d9 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -70,12 +70,15 @@ unsigned int BenchmarkCpu(void) {
}
void Randomize(void) {
+ warning("STUB: Randomize()");
+#if 0
union REGS reg;
reg.h.ah = 0;
int86(0x1A, ®, ®);
rand_seed = reg.h.dl;
Rand();
+#endif
}
void TRAP() {
diff --git a/engines/chamber/menu.cpp b/engines/chamber/menu.cpp
index 2a7e41ff5bc..61aafc7d57f 100644
--- a/engines/chamber/menu.cpp
+++ b/engines/chamber/menu.cpp
@@ -53,9 +53,6 @@ struct {
{10, 24}
};
-unsigned char act_menu_x;
-unsigned char act_menu_y;
-
/*Handle keyboard keys in actions menu (to cycle through choices with directional keys)*/
unsigned char PollKeyboardInActionsMenu(void) {
if (!key_direction) {
diff --git a/engines/chamber/module.mk b/engines/chamber/module.mk
index e7255e199d0..408ee4ea321 100644
--- a/engines/chamber/module.mk
+++ b/engines/chamber/module.mk
@@ -6,7 +6,24 @@ MODULE_OBJS := \
cga.o \
chamber.o \
cursor.o \
- metaengine.o
+ decompr.o \
+ dialog.o \
+ input.o \
+ invent.o \
+ kult.o \
+ menu.o \
+ metaengine.o \
+ portrait.o \
+ print.o \
+ r_other.o \
+ r_pers.o \
+ r_puzzl.o \
+ r_sprit.o \
+ r_templ.o \
+ r_texts.o \
+ resdata.o \
+ room.o \
+ sound.o
MODULE_DIRS += \
engines/chamber
diff --git a/engines/chamber/resdata.cpp b/engines/chamber/resdata.cpp
index 5bd4f6ce85f..1285d206da7 100644
--- a/engines/chamber/resdata.cpp
+++ b/engines/chamber/resdata.cpp
@@ -61,6 +61,10 @@ unsigned char *SeekToEntryW(unsigned char *bank, unsigned int num, unsigned char
}
unsigned int LoadFile(char *filename, unsigned char *buffer) {
+ warning("STUB: LoadFile(%s, buffer)", filename);
+ return 0;
+
+#if 0
int f;
int rlen;
f = open(filename, O_RDONLY | O_BINARY);
@@ -71,9 +75,13 @@ unsigned int LoadFile(char *filename, unsigned char *buffer) {
if (rlen == -1)
return 0;
return (unsigned int)rlen;
+#endif
}
unsigned int SaveFile(char *filename, unsigned char *buffer, unsigned int size) {
+ warning("STUB: SaveFile(%s, buffer, %d)", filename, size);
+ return 0;
+#if 0
int f;
int wlen;
f = open(filename, O_RDONLY | O_BINARY);
@@ -84,12 +92,13 @@ unsigned int SaveFile(char *filename, unsigned char *buffer, unsigned int size)
if (wlen == -1)
return 0;
return (unsigned int)wlen;
+#endif
}
int LoadFilesList(ResEntry_t *entries) {
int i;
for (i = 0; entries[i].name[0] != '$'; i++) {
- if (!LoadFile(entries[i].name, entries[i].buffer))
+ if (!LoadFile(entries[i].name, (byte *)entries[i].buffer))
return 0;
}
return 1;
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index 2c85ae14c0c..ca2e7a4e811 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -71,8 +71,6 @@ unsigned char **spot_sprite;
unsigned char zone_palette;
-unsigned char zone_spr_index;
-
unsigned int zsprite_draw_ofs;
unsigned char zsprite_w;
unsigned char zsprite_h;
@@ -97,46 +95,46 @@ unsigned char zone_drawn;
Vorts room enter/leave animations
*/
vortanims_t vortsanim_list[VORTANIMS_MAX] = {
- { 2, { 3, 52, 113}, { 8, 43, 113}, {12, 43, 113}, {16, 43, 113}},
- { 3, { 6, 58, 120}, { 7, 33, 120}, {11, 33, 120}, {15, 33, 120}},
- { 4, { 2, 26, 121}, { 9, 43, 121}, {13, 43, 121}, {17, 43, 121}},
- { 5, { 1, 32, 119}, {10, 33, 119}, {14, 33, 119}, {18, 33, 119}},
- { 6, { 3, 36, 115}, { 8, 27, 115}, {12, 27, 115}, {16, 27, 115}},
- { 7, { 1, 40, 123}, {10, 41, 123}, {14, 41, 123}, {18, 41, 123}},
- { 8, {21, 64, 132}, { 9, 33, 132}, {13, 33, 132}, {17, 33, 132}},
- {90, { 1, 27, 129}, {10, 28, 129}, {14, 28, 129}, {18, 28, 129}},
- {91, { 3, 44, 129}, { 8, 35, 129}, {12, 35, 129}, {16, 35, 129}},
- {10, {29, 22, 156}, {30, 22, 156}, {31, 22, 156}, {32, 22, 156}},
- {11, {29, 22, 156}, {30, 22, 156}, {31, 22, 156}, {32, 22, 156}},
- {12, {29, 22, 156}, {30, 22, 156}, {31, 22, 156}, {32, 22, 156}},
- {13, {29, 22, 156}, {30, 22, 156}, {31, 22, 156}, {32, 22, 156}},
- {18, {29, 22, 156}, {30, 22, 156}, {31, 22, 156}, {32, 22, 156}},
- {35, {29, 20, 156}, {30, 20, 156}, {31, 20, 156}, {32, 20, 156}},
- {42, {29, 18, 156}, {30, 18, 156}, {31, 18, 156}, {32, 18, 156}},
- {51, {29, 57, 144}, {30, 57, 144}, {31, 57, 144}, {32, 57, 144}},
- {53, {29, 48, 156}, {30, 48, 156}, {31, 48, 156}, {32, 48, 156}},
- {54, {29, 55, 139}, {30, 55, 139}, {31, 55, 139}, {32, 55, 139}},
- {56, {29, 47, 115}, {30, 47, 115}, {31, 47, 115}, {32, 47, 115}},
- {57, {29, 38, 136}, {30, 38, 136}, {31, 38, 136}, {32, 38, 136}},
- {58, {29, 28, 125}, {30, 28, 125}, {31, 28, 125}, {32, 28, 125}},
- {59, {29, 45, 132}, {30, 45, 132}, {31, 45, 132}, {32, 45, 132}},
- {60, {29, 21, 150}, {30, 21, 150}, {31, 21, 150}, {32, 21, 150}},
- {61, {29, 23, 123}, {30, 23, 123}, {31, 23, 123}, {32, 23, 123}}
+ { 2, { 3, {{52, 113}}}, { 8, {{43, 113}}}, {12, {{43, 113}}}, {16, {{43, 113}}}},
+ { 3, { 6, {{58, 120}}}, { 7, {{33, 120}}}, {11, {{33, 120}}}, {15, {{33, 120}}}},
+ { 4, { 2, {{26, 121}}}, { 9, {{43, 121}}}, {13, {{43, 121}}}, {17, {{43, 121}}}},
+ { 5, { 1, {{32, 119}}}, {10, {{33, 119}}}, {14, {{33, 119}}}, {18, {{33, 119}}}},
+ { 6, { 3, {{36, 115}}}, { 8, {{27, 115}}}, {12, {{27, 115}}}, {16, {{27, 115}}}},
+ { 7, { 1, {{40, 123}}}, {10, {{41, 123}}}, {14, {{41, 123}}}, {18, {{41, 123}}}},
+ { 8, {21, {{64, 132}}}, { 9, {{33, 132}}}, {13, {{33, 132}}}, {17, {{33, 132}}}},
+ {90, { 1, {{27, 129}}}, {10, {{28, 129}}}, {14, {{28, 129}}}, {18, {{28, 129}}}},
+ {91, { 3, {{44, 129}}}, { 8, {{35, 129}}}, {12, {{35, 129}}}, {16, {{35, 129}}}},
+ {10, {29, {{22, 156}}}, {30, {{22, 156}}}, {31, {{22, 156}}}, {32, {{22, 156}}}},
+ {11, {29, {{22, 156}}}, {30, {{22, 156}}}, {31, {{22, 156}}}, {32, {{22, 156}}}},
+ {12, {29, {{22, 156}}}, {30, {{22, 156}}}, {31, {{22, 156}}}, {32, {{22, 156}}}},
+ {13, {29, {{22, 156}}}, {30, {{22, 156}}}, {31, {{22, 156}}}, {32, {{22, 156}}}},
+ {18, {29, {{22, 156}}}, {30, {{22, 156}}}, {31, {{22, 156}}}, {32, {{22, 156}}}},
+ {35, {29, {{20, 156}}}, {30, {{20, 156}}}, {31, {{20, 156}}}, {32, {{20, 156}}}},
+ {42, {29, {{18, 156}}}, {30, {{18, 156}}}, {31, {{18, 156}}}, {32, {{18, 156}}}},
+ {51, {29, {{57, 144}}}, {30, {{57, 144}}}, {31, {{57, 144}}}, {32, {{57, 144}}}},
+ {53, {29, {{48, 156}}}, {30, {{48, 156}}}, {31, {{48, 156}}}, {32, {{48, 156}}}},
+ {54, {29, {{55, 139}}}, {30, {{55, 139}}}, {31, {{55, 139}}}, {32, {{55, 139}}}},
+ {56, {29, {{47, 115}}}, {30, {{47, 115}}}, {31, {{47, 115}}}, {32, {{47, 115}}}},
+ {57, {29, {{38, 136}}}, {30, {{38, 136}}}, {31, {{38, 136}}}, {32, {{38, 136}}}},
+ {58, {29, {{28, 125}}}, {30, {{28, 125}}}, {31, {{28, 125}}}, {32, {{28, 125}}}},
+ {59, {29, {{45, 132}}}, {30, {{45, 132}}}, {31, {{45, 132}}}, {32, {{45, 132}}}},
+ {60, {29, {{21, 150}}}, {30, {{21, 150}}}, {31, {{21, 150}}}, {32, {{21, 150}}}},
+ {61, {29, {{23, 123}}}, {30, {{23, 123}}}, {31, {{23, 123}}}, {32, {{23, 123}}}}
};
#define RECS7_MAX 10
rec7_t recs7_list[RECS7_MAX] = {
- {50, {61, 14, 140}, {62, 14, 140}},
- {51, {61, 14, 143}, {62, 14, 143}},
- {53, {61, 20, 153}, {62, 20, 153}},
- {54, {61, 16, 139}, {62, 16, 139}},
- {56, {61, 24, 118}, {62, 24, 118}},
- {57, {61, 27, 129}, {62, 27, 129}},
- {58, {61, 39, 125}, {62, 39, 125}},
- {59, {61, 29, 130}, {62, 29, 130}},
- {60, {61, 49, 150}, {62, 49, 150}},
- {61, {61, 56, 141}, {62, 56, 141}}
+ {50, {61, {{14, 140}}}, {62, {{14, 140}}}},
+ {51, {61, {{14, 143}}}, {62, {{14, 143}}}},
+ {53, {61, {{20, 153}}}, {62, {{20, 153}}}},
+ {54, {61, {{16, 139}}}, {62, {{16, 139}}}},
+ {56, {61, {{24, 118}}}, {62, {{24, 118}}}},
+ {57, {61, {{27, 129}}}, {62, {{27, 129}}}},
+ {58, {61, {{39, 125}}}, {62, {{39, 125}}}},
+ {59, {61, {{29, 130}}}, {62, {{29, 130}}}},
+ {60, {61, {{49, 150}}}, {62, {{49, 150}}}},
+ {61, {61, {{56, 141}}}, {62, {{56, 141}}}}
};
static const unsigned char cga_color_sels[] = {
@@ -328,7 +326,8 @@ void LoadZone(void) {
}
}
- zone_spots = script_vars[ScrPool4_ZoneSpots] = (spot_t *)zptr;
+ zone_spots = (spot_t *)zptr;
+ script_vars[ScrPool4_ZoneSpots] = (spot_t *)zptr;
zone_spots_end = (spot_t *)zend;
zone_spots_cur = (spot_t *)zptr;
zone_spr_index = 0;
@@ -1357,7 +1356,8 @@ void TheWallOpenRightDoor(unsigned char x, unsigned char y, unsigned char width,
/*hide remaining column*/
/*TODO: move this to CGA?*/
while (height--) {
- memcpy(frontbuffer + offs, backbuffer + offs, 1);
+ warning("STUB: TheWallOpenRightDoor()");
+ //memcpy(frontbuffer + offs, backbuffer + offs, 1);
offs ^= CGA_ODD_LINES_OFS;
if ((offs & CGA_ODD_LINES_OFS) == 0)
@@ -1379,7 +1379,8 @@ void TheWallOpenLeftDoor(unsigned char x, unsigned char y, unsigned char width,
/*hide remaining column*/
/*TODO: move this to CGA?*/
while (height--) {
- memcpy(frontbuffer + offs, backbuffer + offs, 1);
+ warning("STUB: TheWallOpenLeftDoor()");
+ //memcpy(frontbuffer + offs, backbuffer + offs, 1);
offs ^= CGA_ODD_LINES_OFS;
if ((offs & CGA_ODD_LINES_OFS) == 0)
diff --git a/engines/chamber/script.h b/engines/chamber/script.h
index 5803a8959bf..6924b1df303 100644
--- a/engines/chamber/script.h
+++ b/engines/chamber/script.h
@@ -192,6 +192,7 @@ extern script_byte_vars_t script_byte_vars;
#define ITEMFLG_80 0x80
/*TODO: manipulated from script, do not change*/
+#include "common/pack-start.h"
typedef struct item_t {
unsigned char flags;
unsigned char flags2;
@@ -199,10 +200,7 @@ typedef struct item_t {
unsigned char name; /*item name index (relative)*/
unsigned short command; /*TODO: warning! in native format, check if never accessed from scripts*/
} item_t;
-
-#if sizeof(item_t) != 6
-#error "item_t must be 6 bytes long"
-#endif
+#include "common/pack-end.h"
#define MAX_INV_ITEMS 63
extern item_t inventory_items[MAX_INV_ITEMS];
Commit: a637c5a7d0741f261e83c651203df761262a8372
https://github.com/scummvm/scummvm/commit/a637c5a7d0741f261e83c651203df761262a8372
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix compilation for the rest of the files
Changed paths:
engines/chamber/cga.cpp
engines/chamber/cga.h
engines/chamber/common.h
engines/chamber/module.mk
engines/chamber/savegame.cpp
engines/chamber/script.cpp
engines/chamber/timer.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 67a13512405..85aa5c111ce 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -28,6 +28,7 @@
namespace Chamber {
extern unsigned char backbuffer[0x4000];
+byte CGA_SCREENBUFFER[0x4000];
unsigned char carpc_data[RES_CARPC_MAX];
diff --git a/engines/chamber/cga.h b/engines/chamber/cga.h
index 6b720093f6d..48f106fcbcf 100644
--- a/engines/chamber/cga.h
+++ b/engines/chamber/cga.h
@@ -33,7 +33,7 @@ namespace Chamber {
#define CGA_PIXELS_PER_BYTE (8 / CGA_BITS_PER_PIXEL)
#define CGA_BYTES_PER_LINE (CGA_WIDTH / CGA_PIXELS_PER_BYTE)
-#define CGA_SCREENBUFFER NULL
+extern byte CGA_SCREENBUFFER[0x4000];
#define CGA_FONT_HEIGHT 6
diff --git a/engines/chamber/common.h b/engines/chamber/common.h
index a8c9a8df905..8858e8ebad0 100644
--- a/engines/chamber/common.h
+++ b/engines/chamber/common.h
@@ -25,7 +25,7 @@
namespace Chamber {
-#define BE(x) (((x) >> 8) | ((x) << 8))
+#define BE(x) ((((x) >> 8) | ((x) << 8)) & 0xffff)
#define LE16(x) (x)
#define TODO(s) \
diff --git a/engines/chamber/module.mk b/engines/chamber/module.mk
index 408ee4ea321..70957f555d8 100644
--- a/engines/chamber/module.mk
+++ b/engines/chamber/module.mk
@@ -23,7 +23,10 @@ MODULE_OBJS := \
r_texts.o \
resdata.o \
room.o \
- sound.o
+ savegame.o \
+ script.o \
+ sound.o \
+ timer.o
MODULE_DIRS += \
engines/chamber
diff --git a/engines/chamber/savegame.cpp b/engines/chamber/savegame.cpp
index e06c9d7eb77..27b0613740a 100644
--- a/engines/chamber/savegame.cpp
+++ b/engines/chamber/savegame.cpp
@@ -80,6 +80,11 @@ void RestartGame(void) {
rlen = read(f, buffer, size); if(rlen != size) goto error;
int LoadScena(void) {
+ warning("STUB: LoadScena()");
+
+ return 1;
+
+#if 0
int f;
int rlen;
unsigned short zero = 0;
@@ -345,9 +350,15 @@ error:
close(f);
script_byte_vars.game_paused = 0;
return 1;
+
+#endif
}
int SaveScena(void) {
+ warning("STUB: SaveScena()");
+ return 1;
+
+#if 0
int f;
int wlen;
unsigned short zero = 0;
@@ -600,6 +611,7 @@ error:
close(f);
script_byte_vars.game_paused = 0;
return 1;
+#endif
}
} // End of namespace Chamber
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 77ab9fb0a4d..2365d12bb45 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -190,6 +190,9 @@ unsigned int SCR_1_AspirantItemTrade(void) {
unsigned char wait_delta = 0;
void Wait(unsigned char seconds) {
+ warning("STUB: Wait(%d)", seconds);
+
+#if 0
struct time t;
unsigned int endtime;
@@ -209,6 +212,7 @@ void Wait(unsigned char seconds) {
if (current >= endtime)
break;
}
+#endif
}
unsigned int SCR_2C_Wait4(void) {
@@ -1436,71 +1440,71 @@ typedef struct fightentry_t {
} fightentry_t;
fightentry_t fightlist1[] = {
- {50, {47, 36, 153}},
- {51, {47, 36, 153}},
- {53, {47, 37, 160}},
- {54, {47, 36, 153}},
- {56, {47, 31, 128}},
- {57, {47, 27, 161}},
- {58, {47, 28, 152}},
- {59, {47, 25, 153}},
- {60, {47, 22, 155}},
- {61, {47, 27, 160}}
+ {50, {47, {{36, 153}}}},
+ {51, {47, {{36, 153}}}},
+ {53, {47, {{37, 160}}}},
+ {54, {47, {{36, 153}}}},
+ {56, {47, {{31, 128}}}},
+ {57, {47, {{27, 161}}}},
+ {58, {47, {{28, 152}}}},
+ {59, {47, {{25, 153}}}},
+ {60, {47, {{22, 155}}}},
+ {61, {47, {{27, 160}}}}
};
fightentry_t fightlist2[] = {
- { 1, {24, 42, 128}},
- { 2, {24, 44, 126}},
- { 3, {24, 47, 126}},
- { 4, {24, 44, 126}},
- { 5, {24, 47, 126}},
- { 6, {24, 28, 126}},
- { 7, {24, 55, 126}},
- { 8, {24, 49, 126}},
- {10, {24, 41, 147}},
- {11, {24, 41, 147}},
- {18, {24, 41, 147}},
- {19, {24, 41, 147}},
- {90, {24, 44, 121}},
- {91, {28, 24, 123}},
- {12, {24, 41, 147}},
- {13, {24, 41, 147}},
- {35, {24, 39, 147}},
- {42, {24, 39, 147}},
- {50, {55, 46, 130}},
- {52, {24, 42, 121}},
- {54, {55, 46, 130}},
- {61, {67, 37, 125}},
- {62, {55, 32, 133}},
- {63, {55, 32, 133}},
- {64, {55, 32, 133}},
- {65, {55, 32, 133}}
+ { 1, {24, {{42, 128}}}},
+ { 2, {24, {{44, 126}}}},
+ { 3, {24, {{47, 126}}}},
+ { 4, {24, {{44, 126}}}},
+ { 5, {24, {{47, 126}}}},
+ { 6, {24, {{28, 126}}}},
+ { 7, {24, {{55, 126}}}},
+ { 8, {24, {{49, 126}}}},
+ {10, {24, {{41, 147}}}},
+ {11, {24, {{41, 147}}}},
+ {18, {24, {{41, 147}}}},
+ {19, {24, {{41, 147}}}},
+ {90, {24, {{44, 121}}}},
+ {91, {28, {{24, 123}}}},
+ {12, {24, {{41, 147}}}},
+ {13, {24, {{41, 147}}}},
+ {35, {24, {{39, 147}}}},
+ {42, {24, {{39, 147}}}},
+ {50, {55, {{46, 130}}}},
+ {52, {24, {{42, 121}}}},
+ {54, {55, {{46, 130}}}},
+ {61, {67, {{37, 125}}}},
+ {62, {55, {{32, 133}}}},
+ {63, {55, {{32, 133}}}},
+ {64, {55, {{32, 133}}}},
+ {65, {55, {{32, 133}}}}
};
fightentry_t fightlist3[] = {
- { 2, {25, 35, 144}},
- { 3, {25, 38, 144}},
- { 4, {25, 35, 144}},
- { 5, {25, 38, 144}},
- { 6, {25, 19, 144}},
- { 7, {25, 46, 144}},
- { 8, {26, 64, 132}},
- {10, {25, 32, 165}},
- {11, {25, 32, 165}},
- {12, {25, 32, 165}},
- {13, {25, 32, 165}},
- {18, {25, 32, 165}},
- {19, {25, 32, 165}},
- {90, {36, 27, 127}},
- {91, {27, 44, 123}},
- {35, {25, 30, 165}},
- {42, {25, 30, 165}},
- {50, {56, 36, 153}},
- {54, {56, 36, 153}},
- {62, {56, 22, 156}},
- {63, {56, 22, 156}},
- {64, {56, 22, 156}},
- {65, {56, 22, 156}}
+ { 2, {25, {{35, 144}}}},
+ { 3, {25, {{38, 144}}}},
+ { 4, {25, {{35, 144}}}},
+ { 5, {25, {{38, 144}}}},
+ { 6, {25, {{19, 144}}}},
+ { 7, {25, {{46, 144}}}},
+ { 8, {26, {{64, 132}}}},
+ {10, {25, {{32, 165}}}},
+ {11, {25, {{32, 165}}}},
+ {12, {25, {{32, 165}}}},
+ {13, {25, {{32, 165}}}},
+ {18, {25, {{32, 165}}}},
+ {19, {25, {{32, 165}}}},
+ {90, {36, {{27, 127}}}},
+ {91, {27, {{44, 123}}}},
+ {35, {25, {{30, 165}}}},
+ {42, {25, {{30, 165}}}},
+ {50, {56, {{36, 153}}}},
+ {54, {56, {{36, 153}}}},
+ {62, {56, {{22, 156}}}},
+ {63, {56, {{22, 156}}}},
+ {64, {56, {{22, 156}}}},
+ {65, {56, {{22, 156}}}}
};
/*Draw defeated enemy*/
diff --git a/engines/chamber/timer.cpp b/engines/chamber/timer.cpp
index 925f37920b5..e883de3c810 100644
--- a/engines/chamber/timer.cpp
+++ b/engines/chamber/timer.cpp
@@ -39,6 +39,7 @@ void AnimateGauss(unsigned char *target) {
CGA_Blit(sprite, 8, 8, 30, target, 80); /*draw to 0:4*/
}
+#if 0
void interrupt(*old_timer_isr)();
void interrupt TimerIsr() {
@@ -55,17 +56,25 @@ void interrupt TimerIsr() {
enable();
}
+#endif
+
void InitTimer(void) {
+ warning("STUB: InitTimer()");
+#if 0
disable();
old_timer_isr = getvect(0x1C);
setvect(0x1C, TimerIsr);
enable();
+#endif
}
void UninitTimer(void) {
+ warning("STUB: UninitTimer()");
+#if 0
disable();
setvect(0x1C, old_timer_isr);
enable();
+#endif
}
} // End of namespace Chamber
Commit: 4df1e71e3a3b5e107d26f90fa2a7d38c39c9e611
https://github.com/scummvm/scummvm/commit/4df1e71e3a3b5e107d26f90fa2a7d38c39c9e611
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Plug in the engine
Changed paths:
engines/chamber/chamber.cpp
engines/chamber/chamber.h
diff --git a/engines/chamber/chamber.cpp b/engines/chamber/chamber.cpp
index fa76e0eb706..8767e1e9f31 100644
--- a/engines/chamber/chamber.cpp
+++ b/engines/chamber/chamber.cpp
@@ -63,6 +63,8 @@ Common::Error ChamberEngine::run() {
// Your main even loop should be (invoked from) here.
debug("ChamberEngine::go: Hello, World!");
+ run();
+
// Simple main event loop
Common::Event evt;
while (!shouldQuit()) {
diff --git a/engines/chamber/chamber.h b/engines/chamber/chamber.h
index fd4f96696a0..9acf5540b2f 100644
--- a/engines/chamber/chamber.h
+++ b/engines/chamber/chamber.h
@@ -51,6 +51,8 @@ public:
void syncGameStream(Common::Serializer &s);
};
+void run(void);
+
} // End of namespace Chamber
#endif
Commit: 3811c9bd6fddc54026c2989f710d2db04968b074
https://github.com/scummvm/scummvm/commit/3811c9bd6fddc54026c2989f710d2db04968b074
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix the main loop
Changed paths:
engines/chamber/chamber.cpp
engines/chamber/chamber.h
engines/chamber/kult.cpp
engines/chamber/script.cpp
diff --git a/engines/chamber/chamber.cpp b/engines/chamber/chamber.cpp
index 8767e1e9f31..7d674b69b31 100644
--- a/engines/chamber/chamber.cpp
+++ b/engines/chamber/chamber.cpp
@@ -53,28 +53,6 @@ ChamberEngine::~ChamberEngine() {
delete _rnd;
}
-Common::Error ChamberEngine::run() {
- // Initialize graphics using following:
- initGraphics(320, 200);
-
- // Additional setup.
- debug("ChamberEngine::init");
-
- // Your main even loop should be (invoked from) here.
- debug("ChamberEngine::go: Hello, World!");
-
- run();
-
- // Simple main event loop
- Common::Event evt;
- while (!shouldQuit()) {
- g_system->getEventManager()->pollEvent(evt);
- g_system->delayMillis(10);
- }
-
- return Common::kNoError;
-}
-
bool ChamberEngine::hasFeature(EngineFeature f) const {
return
(f == kSupportsReturnToLauncher) ||
diff --git a/engines/chamber/chamber.h b/engines/chamber/chamber.h
index 9acf5540b2f..fc184618aa9 100644
--- a/engines/chamber/chamber.h
+++ b/engines/chamber/chamber.h
@@ -51,7 +51,7 @@ public:
void syncGameStream(Common::Serializer &s);
};
-void run(void);
+void init(void);
} // End of namespace Chamber
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 4525882d3d9..4ac769cfba9 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -20,6 +20,11 @@
*
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
+#include "common/error.h"
+#include "engines/util.h"
+
#include "chamber/chamber.h"
#include "chamber/common.h"
#include "chamber/decompr.h"
@@ -181,10 +186,11 @@ void ExitGame(void) {
exit(0);
}
-void main(void) {
- unsigned char c;
+Common::Error ChamberEngine::run() {
+ // Initialize graphics using following:
+ initGraphics(320, 200);
- SwitchToGraphicsMode();
+ unsigned char c;
/* Load title screen */
if (!LoadSplash("PRES.BIN"))
@@ -296,6 +302,8 @@ restart:
UninitTimer();
ExitGame();
+
+ return Common::kNoError;
}
} // End of namespace Chamber
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 2365d12bb45..af43028787e 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -37,14 +37,14 @@
#include "chamber/sound.h"
#include "chamber/savegame.h"
-namespace Chamber {
-
#if 1
#define DEBUG_SCRIPT
char DEBUG_SCRIPT_LOG[] = "!script.log";
#endif
-#include "scrvars.h"
+#include "chamber/scrvars.h"
+
+namespace Chamber {
unsigned char rand_seed;
unsigned short the_command;
Commit: 2f503242a23560be49fa244520fcb052978f7216
https://github.com/scummvm/scummvm/commit/2f503242a23560be49fa244520fcb052978f7216
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Implement file loading
Changed paths:
engines/chamber/kult.cpp
engines/chamber/resdata.cpp
engines/chamber/resdata.h
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 4ac769cfba9..61a46713ca0 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -59,7 +59,7 @@ void SaveToFile(char *filename, void *data, unsigned int size) {
fclose(f);
}
-int LoadSplash(char *filename) {
+int LoadSplash(const char *filename) {
if (!LoadFile(filename, scratch_mem1))
return 0;
decompress(scratch_mem1 + 8, backbuffer); /* skip compressed/decompressed size fields */
diff --git a/engines/chamber/resdata.cpp b/engines/chamber/resdata.cpp
index 1285d206da7..9ab156beae3 100644
--- a/engines/chamber/resdata.cpp
+++ b/engines/chamber/resdata.cpp
@@ -20,6 +20,8 @@
*
*/
+#include "common/file.h"
+
#include "chamber/chamber.h"
#include "chamber/common.h"
#include "chamber/resdata.h"
@@ -28,7 +30,7 @@
namespace Chamber {
extern void AskDisk2(void);
-extern int LoadSplash(char *filename);
+extern int LoadSplash(const char *filename);
/*
Get bank entry
@@ -60,22 +62,15 @@ unsigned char *SeekToEntryW(unsigned char *bank, unsigned int num, unsigned char
return p + 2;
}
-unsigned int LoadFile(char *filename, unsigned char *buffer) {
- warning("STUB: LoadFile(%s, buffer)", filename);
- return 0;
+unsigned int LoadFile(const char *filename, unsigned char *buffer) {
+ Common::File in;
-#if 0
- int f;
- int rlen;
- f = open(filename, O_RDONLY | O_BINARY);
- if (f == -1)
- return 0;
- rlen = read(f, buffer, 0xFFF0);
- close(f);
- if (rlen == -1)
+ in.open(filename);
+
+ if (!in.isOpen())
return 0;
- return (unsigned int)rlen;
-#endif
+
+ return in.read(buffer, 0xFFFF0);
}
unsigned int SaveFile(char *filename, unsigned char *buffer, unsigned int size) {
@@ -131,7 +126,7 @@ ResEntry_t res_static[] = {
{"ANIMA.BIN", anima_data},
{"ANICO.BIN", anico_data},
{"ZONES.BIN", zones_data},
- {"$"}
+ {"$", NULL}
};
/*
@@ -145,7 +140,7 @@ int LoadStaticData() {
ResEntry_t res_texts[] = {
{"VEPCI.BIN", vepci_data},
{"MOTSI.BIN", motsi_data},
- {"$"}
+ {"$", NULL}
};
/*
@@ -162,7 +157,7 @@ int LoadFond(void) {
ResEntry_t res_sprites[] = {
{"PUZZL.BIN", puzzl_data},
{"SPRIT.BIN", sprit_data},
- {"$"}
+ {"$", NULL}
};
int LoadSpritesData(void) {
@@ -172,7 +167,7 @@ int LoadSpritesData(void) {
ResEntry_t res_person[] = {
{"PERS1.BIN", pers1_data},
{"PERS2.BIN", pers2_data},
- {"$"}
+ {"$", NULL}
};
int LoadPersData(void) {
@@ -184,7 +179,7 @@ int LoadPersData(void) {
ResEntry_t res_desci[] = {
{"DESCI.BIN", desci_data},
- {"$"}
+ {"$", NULL}
};
/*
@@ -198,7 +193,7 @@ int LoadDesciData(void) {
ResEntry_t res_diali[] = {
{"DIALI.BIN", diali_data},
- {"$"}
+ {"$", NULL}
};
/*
diff --git a/engines/chamber/resdata.h b/engines/chamber/resdata.h
index 5f7d51e2007..ec57e31ac40 100644
--- a/engines/chamber/resdata.h
+++ b/engines/chamber/resdata.h
@@ -82,7 +82,7 @@ extern unsigned char 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);
-unsigned int LoadFile(char *filename, unsigned char *buffer);
+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);
Commit: c5f7abf4763cb7b4346da6597cce5a35589ec84c
https://github.com/scummvm/scummvm/commit/c5f7abf4763cb7b4346da6597cce5a35589ec84c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Init palette and blit CGA buffer to screen
Changed paths:
engines/chamber/cga.cpp
engines/chamber/kult.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 85aa5c111ce..7ae33c69819 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -20,6 +20,9 @@
*
*/
+#include "common/system.h"
+#include "graphics/palette.h"
+
#include "chamber/chamber.h"
#include "chamber/common.h"
#include "chamber/resdata.h"
@@ -29,6 +32,7 @@ namespace Chamber {
extern unsigned char backbuffer[0x4000];
byte CGA_SCREENBUFFER[0x4000];
+byte scrbuffer[320*200];
unsigned char carpc_data[RES_CARPC_MAX];
@@ -67,11 +71,18 @@ unsigned char cga_pixel_flip[256] = {
63, 127, 191, 255
};
+static const uint8 PALETTE_CGA[4 * 3] = {
+ 0x00, 0x00, 0x00, // black
+ 0x55, 0xff, 0xff, // cyan
+ 0xff, 0x55, 0xff, // magenta
+ 0xff, 0xff, 0xff
+};
+
/*
Switch to CGA 320x200x2bpp mode
*/
void SwitchToGraphicsMode(void) {
- warning("STUB: SwitchToGraphicsMode()");
+ g_system->getPaletteManager()->setPalette(PALETTE_CGA, 0, 4);
}
/*
@@ -91,6 +102,25 @@ void CGA_ColorSelect(unsigned char csel) {
void CGA_BackBufferToRealFull(void) {
memcpy(CGA_SCREENBUFFER, backbuffer, sizeof(backbuffer));
+
+ byte *ptr = CGA_SCREENBUFFER;
+ byte *dst = scrbuffer;
+
+ for (int y = 0; y < 200; y++) {
+ for (int x = 0; x < 320 / 4; x++) {
+ byte colors = *ptr++;
+
+ for (int c = 0; c < 4; c++) {
+ byte color = (colors & 0xC0) >> 6;
+ colors >>= 2;
+
+ *dst++ = color;
+ }
+ }
+ }
+
+ g_system->copyRectToScreen(scrbuffer, 320, 0, 0, 320, 200);
+ g_system->updateScreen();
}
void CGA_RealBufferToBackFull(void) {
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 61a46713ca0..761c9326d8e 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -190,6 +190,8 @@ Common::Error ChamberEngine::run() {
// Initialize graphics using following:
initGraphics(320, 200);
+ SwitchToGraphicsMode();
+
unsigned char c;
/* Load title screen */
Commit: b8d465e8a7e02b3e6e32f42e2992db329eaee28e
https://github.com/scummvm/scummvm/commit/b8d465e8a7e02b3e6e32f42e2992db329eaee28e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix image decoding
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 7ae33c69819..618de8b8fa6 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -103,16 +103,19 @@ void CGA_ColorSelect(unsigned char csel) {
void CGA_BackBufferToRealFull(void) {
memcpy(CGA_SCREENBUFFER, backbuffer, sizeof(backbuffer));
- byte *ptr = CGA_SCREENBUFFER;
byte *dst = scrbuffer;
for (int y = 0; y < 200; y++) {
+ byte *ptr = CGA_SCREENBUFFER + (y >> 1) * 80;
+ if (y & 1)
+ ptr += 0x2000;
+
for (int x = 0; x < 320 / 4; x++) {
byte colors = *ptr++;
for (int c = 0; c < 4; c++) {
byte color = (colors & 0xC0) >> 6;
- colors >>= 2;
+ colors <<= 2;
*dst++ = color;
}
Commit: 856ed7282becf2c703505ddd87eca5bd8fb3dba8
https://github.com/scummvm/scummvm/commit/856ed7282becf2c703505ddd87eca5bd8fb3dba8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Sync with upstream 7e5a12a20008eea4faa49e8a7fd5bec2b47e635b
Changed paths:
engines/chamber/room.cpp
engines/chamber/room.h
engines/chamber/savegame.cpp
engines/chamber/script.cpp
engines/chamber/script.h
engines/chamber/scrvars.h
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index ca2e7a4e811..2da5c14845a 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -63,7 +63,7 @@ spot_t *zone_spots_end;
spot_t *zone_spots_cur;
vortanims_t *vortanims_ptr;
-rec7_t *rec7_ptr;
+turkeyanims_t *turkeyanims_ptr;
pers_t *pers_ptr;
spot_t *spot_ptr;
spot_t *found_spot;
@@ -122,9 +122,9 @@ vortanims_t vortsanim_list[VORTANIMS_MAX] = {
{61, {29, {{23, 123}}}, {30, {{23, 123}}}, {31, {{23, 123}}}, {32, {{23, 123}}}}
};
-#define RECS7_MAX 10
+#define TURKEYANIMS_MAX 10
-rec7_t recs7_list[RECS7_MAX] = {
+turkeyanims_t turkeyanim_list[TURKEYANIMS_MAX] = {
{50, {61, {{14, 140}}}, {62, {{14, 140}}}},
{51, {61, {{14, 143}}}, {62, {{14, 143}}}},
{53, {61, {{20, 153}}}, {62, {{20, 153}}}},
@@ -141,6 +141,11 @@ static const unsigned char 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) {
+ CGA_ColorSelect(cga_color_sels[index]);
+}
+
+
void SelectPalette(void) {
CGA_ColorSelect(cga_color_sels[script_byte_vars.palette_index]);
}
@@ -340,9 +345,6 @@ void LoadZone(void) {
}
void ResetZone(void) {
- script_word_vars.word_178EE = 0;
- script_word_vars.word_17852 = 0;
- script_word_vars.word_17848 = 0;
script_byte_vars.byte_179F9 = 0;
script_byte_vars.byte_17A01 = 0;
script_byte_vars.byte_17A17 = 0;
@@ -352,12 +354,15 @@ void ResetZone(void) {
script_byte_vars.byte_179EA = 0;
script_byte_vars.byte_179BE = 0;
script_byte_vars.byte_179EF = 0;
+ script_word_vars.psi_cmds[0] = BE(0x9048);
+ script_word_vars.psi_cmds[1] = BE(0xA01D);
+ script_word_vars.psi_cmds[2] = BE(0);
+ script_word_vars.psi_cmds[3] = BE(0x00F7);
+ script_word_vars.psi_cmds[4] = BE(0x9048);
+ script_word_vars.psi_cmds[5] = BE(0x9048);
script_word_vars.word_17850 = BE(0xA01C);
- script_word_vars.word_1784A = BE(0x00F7);
- script_word_vars.word_17844 = BE(0x9048);
- script_word_vars.word_1784C = BE(0x9048);
- script_word_vars.word_1784E = BE(0x9048);
- script_word_vars.word_17846 = BE(0xA01D);
+ script_word_vars.word_17852 = BE(0);
+ script_word_vars.word_178EE = BE(0);
}
/*
@@ -1013,6 +1018,17 @@ 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) {
+ lutin_mem = scratch_mem2;
+
+ LoadLutinSprite(spridx);
+
+ DrawSprite(scratch_mem2, target, CGA_CalcXY_p(x, y));
+}
+
/*
Draw room's person idle sprite and advance sprite's animation
Return true if a sprite was drawn
@@ -1209,9 +1225,9 @@ void PrepareCommand4(void) {
if ((spot->flags & ~SPOTFLG_80) == (SPOTFLG_40 | SPOTFLG_10 | SPOTFLG_1)) {
int i;
- for (i = 0; i < RECS7_MAX; i++) {
- if (recs7_list[i].room == script_byte_vars.zone_room) {
- rec7_ptr = &recs7_list[i];
+ for (i = 0; i < TURKEYANIMS_MAX; i++) {
+ if (turkeyanim_list[i].room == script_byte_vars.zone_room) {
+ turkeyanims_ptr = &turkeyanim_list[i];
if (script_byte_vars.zone_area == pers_list[5].area) {
next_command4 = 0xA01F;
SetDelay5();
@@ -1468,7 +1484,7 @@ void DrawTheWallDoors(void) {
case 9:
case 102:
CGA_Blit(LoadMursmSprite(0) + 10, 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(64 / CGA_PIXELS_PER_BYTE, 32));
- CGA_Blit(LoadMursmSprite(1), 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(180 / CGA_PIXELS_PER_BYTE, 32));
+ CGA_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(180 / CGA_PIXELS_PER_BYTE, 32));
break;
case 95:
case 103:
diff --git a/engines/chamber/room.h b/engines/chamber/room.h
index 2cd48eb15c6..bf8b1b4f9fa 100644
--- a/engines/chamber/room.h
+++ b/engines/chamber/room.h
@@ -84,11 +84,11 @@ typedef struct vortanims_t {
animdesc_t field_A;
} vortanims_t;
-typedef struct rec7_t {
+typedef struct turkeyanims_t {
unsigned char room;
animdesc_t field_1;
animdesc_t field_4;
-} rec7_t;
+} turkeyanims_t;
extern unsigned char scratch_mem1[8010];
extern unsigned char *scratch_mem2;
@@ -123,8 +123,8 @@ extern spot_t *zone_spots_cur;
extern vortanims_t vortsanim_list[];
extern vortanims_t *vortanims_ptr;
-extern rec7_t recs7_list[];
-extern rec7_t *rec7_ptr;
+extern turkeyanims_t turkeyanim_list[];
+extern turkeyanims_t *turkeyanims_ptr;
extern pers_t *pers_ptr;
extern spot_t *spot_ptr;
extern spot_t *found_spot;
@@ -172,6 +172,7 @@ void ShowObjectHint(unsigned char *target);
void DrawCommandHint(void);
void ShowCommandHint(unsigned char *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 DrawHintsAndCursor(unsigned char *target);
@@ -185,6 +186,7 @@ void BlitSpritesToBackBuffer(void);
void BackupSpotsImages(void);
void SelectPalette(void);
+void SelectSpecificPalette(unsigned char index);
unsigned char FindSpotByFlags(unsigned char mask, unsigned char value);
unsigned char FindAndSelectSpot(unsigned char offset);
@@ -192,6 +194,7 @@ unsigned char FindAndSelectSpot(unsigned char offset);
void FindPerson(void);
void UpdateZoneSpot(unsigned char index);
+void DrawRoomItemsIndicator(void);
void DrawRoomStaticObject(unsigned char *aptr, unsigned char *rx, unsigned char *ry, unsigned char *rw, unsigned char *rh);
void DrawRoomStatics(void);
void RedrawRoomStatics(unsigned char index, unsigned char y_step);
diff --git a/engines/chamber/savegame.cpp b/engines/chamber/savegame.cpp
index 27b0613740a..55af85dc494 100644
--- a/engines/chamber/savegame.cpp
+++ b/engines/chamber/savegame.cpp
@@ -64,7 +64,7 @@ void RestartGame(void) {
#define CGA_SAVE_SCRSTACK_OFS 0x7562
#define CGA_SAVE_TEMPL_OFS 0x182C
#define CGA_SAVE_VORTANIMS_OFS 0xA609
-#define CGA_SAVE_RECS7_OFS 0xA74E
+#define CGA_SAVE_TURKEYANIMS_OFS 0xA74E
#define CGA_SAVE_TIMEDSEQ_OFS 0xA7C0
#define SAVEADDR(value, base, nativesize, origsize, origbase) \
@@ -163,8 +163,8 @@ int LoadScena(void) {
/* vortanims_ptr */
POINTER((unsigned char *)vortanims_ptr, vortsanim_list, 1, 1, CGA_SAVE_VORTANIMS_OFS);
- /* rec7_ptr */
- POINTER((unsigned char *)rec7_ptr, recs7_list, 1, 1, CGA_SAVE_RECS7_OFS);
+ /* turkeyanims_ptr */
+ POINTER((unsigned char *)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);
@@ -431,8 +431,8 @@ int SaveScena(void) {
/* vortanims_ptr */
POINTER(vortanims_ptr, vortsanim_list, 1, 1, CGA_SAVE_VORTANIMS_OFS);
- /* rec7_ptr */
- POINTER(rec7_ptr, recs7_list, 1, 1, CGA_SAVE_RECS7_OFS);
+ /* turkeyanims_ptr */
+ POINTER(turkeyanims_ptr, turkeyanim_list, 1, 1, CGA_SAVE_TURKEYANIMS_OFS);
/* pers_ptr */
POINTER(pers_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS);
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index af43028787e..eb3c645f2a9 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -402,6 +402,15 @@ unsigned int SCR_3B_MathExpr(void) {
return 0;
}
+/*Discard current callchain (the real one) and execute command*/
+unsigned int SCR_4D_PriorityCommand(void) {
+ script_ptr++;
+ the_command = *script_ptr++; /*little-endian*/
+ the_command |= (*script_ptr++) << 8;
+ the_command |= 0xF000;
+ return ScriptRerun;
+}
+
/*Jump to routine*/
unsigned int SCR_12_Chain(void) {
script_ptr++;
@@ -464,7 +473,6 @@ unsigned int SCR_35_Ret(void) {
return 0;
}
-
/*Draw portrait, pushing it from left to right*/
unsigned int SCR_5_DrawPortraitLiftRight(void) {
unsigned char x, y, width, height;
@@ -1024,6 +1032,14 @@ unsigned int SCR_5A_SelectPalette(void) {
return 0;
}
+unsigned int SCR_5E_SelectTempPalette(void) {
+ unsigned char index;
+ script_ptr++;
+ index = *script_ptr++;
+ SelectSpecificPalette(index);
+ return 0;
+}
+
unsigned int SCR_43_RefreshZone(void) {
script_ptr++;
RefreshZone();
@@ -1608,6 +1624,57 @@ unsigned int SCR_32_FightWin(void) {
return 0;
}
+void DrawDeathAnim(void) {
+ int i;
+
+ /*remove existing cadaver if any*/
+ if (FindAndSelectSpot(38 * 5)) {
+ found_spot->flags &= ~SPOTFLG_80;
+ CGA_RestoreImage(*spot_sprite, backbuffer);
+ }
+
+ for (i = 0; i < 23; i++) {
+ if (fightlist3[i].room == script_byte_vars.zone_room) {
+ PlayAnim(fightlist3[i].anim.index, fightlist3[i].anim.params.coords.x, fightlist3[i].anim.params.coords.y);
+ break;
+ }
+ }
+}
+
+unsigned int SCR_16_DrawDeathAnim(void) {
+ script_ptr++;
+
+ DrawDeathAnim();
+
+ return 0;
+}
+
+unsigned int SCR_57_ShowCharacterSprite(void) {
+ unsigned char index, x, y;
+
+ script_ptr++;
+ index = *script_ptr++;
+ x = *script_ptr++;
+ y = *script_ptr++;
+
+ DrawCharacterSprite(index, x, y, frontbuffer);
+
+ return 0;
+}
+
+unsigned int SCR_58_DrawCharacterSprite(void) {
+ unsigned char index, x, y;
+
+ script_ptr++;
+ index = *script_ptr++;
+ x = *script_ptr++;
+ y = *script_ptr++;
+
+ DrawCharacterSprite(index, x, y, backbuffer);
+
+ return 0;
+}
+
extern void ExitGame(void);
unsigned int SCR_15_SelectSpot(void) {
@@ -1898,6 +1965,47 @@ unsigned int SCR_50_BounceItemToInventory(void) {
return 0;
}
+/*
+Take away Protozorq's zapstik and bounce it to room
+*/
+unsigned int SCR_4B_ProtoDropZapstik(void) {
+ pers_t *pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]);
+
+ script_ptr++;
+
+ if ((pers->index & 0x38) != 0x30)
+ return 0;
+
+ pers->index &= ~0x18;
+
+ script_vars[ScrPool3_CurrentItem] = &inventory_items[38 + (script_byte_vars.cur_pers - 1) - 9];
+
+ BounceCurrentItem(ITEMFLG_40, 43);
+
+ return 0;
+}
+
+/*Take away a person's item*/
+void TakePersonsItem(void) {
+ if (pers_ptr->item != 0) {
+ item_t *item = &inventory_items[pers_ptr->item - 1];
+ pers_ptr->item = 0;
+
+ script_vars[ScrPool3_CurrentItem] = item;
+ script_byte_vars.byte_179F1++;
+ script_byte_vars.byte_17A23[pers_ptr->index >> 6] = item->name; /*TODO: check these index bits*/
+ BounceCurrentItem(ITEMFLG_80, 85);
+ the_command = 0x90AA; /*OK*/
+ } else
+ the_command = 0x9140; /*NOTHING ON HIM*/
+}
+
+unsigned int 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;
@@ -1969,6 +2077,80 @@ unsigned int SCR_53_FindInvItem(void) {
return 0;
}
+unsigned int SCR_55_DrawRoomItemsIndicator(void) {
+ script_ptr++;
+ DrawRoomItemsIndicator();
+ return 0;
+}
+
+/*
+Discard all inventory items
+*/
+unsigned int SCR_5C_ClearInventory(void) {
+ int i;
+ script_ptr++;
+
+ for (i = 0; i < MAX_INV_ITEMS; i++) {
+ if (inventory_items[i].flags == ITEMFLG_80)
+ inventory_items[i].flags = 0;
+ }
+
+ script_byte_vars.room_items = 0;
+
+ return 0;
+}
+
+/*
+Drop group of items from inventory to room
+*/
+void DropItems(int first, int count) {
+ int i;
+
+ for (i = 0; i < count; i++) {
+ if (inventory_items[first + i].flags == ITEMFLG_80) {
+ inventory_items[first + i].flags = ITEMFLG_40;
+ inventory_items[first + i].flags2 = script_byte_vars.zone_area;
+ }
+ }
+}
+
+/*
+Drop weapon-like items from inventory to room
+*/
+unsigned int SCR_5D_DropWeapons(void) {
+ script_ptr++;
+
+ DropItems(18, 4); /*DAGGER*/
+ DropItems(38, 14); /*ZAPSTIK*/
+ DropItems(55, 2); /*SACRIFICIAL BLADE , CHOPPER*/
+
+ script_byte_vars.room_items = 0;
+
+ return 0;
+}
+
+/*
+React to Psi power
+*/
+unsigned int SCR_62_PsiReaction(void) {
+ unsigned char power;
+ unsigned short cmd;
+
+ script_ptr++;
+ power = *script_ptr++;
+
+ cmd = script_word_vars.zone_obj_cmds[(script_byte_vars.cur_spot_idx - 1) * 5 + power];
+ if (cmd == 0)
+ cmd = script_word_vars.psi_cmds[power]; /*TODO: is this consistent with zone_obj_cmds?*/
+
+ the_command = Swap16(cmd);
+
+ return 0;
+}
+
+
+
+
unsigned int SCR_64_DrawBoxAroundSpot(void) {
script_ptr++;
@@ -2385,8 +2567,8 @@ unsigned int CMD_B_PsiStickyFingers(void) {
CGA_BackBufferToRealFull();
RestoreScreenOfSpecialRoom();
- if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(0) == 0)
- the_command = Swap16(script_word_vars.word_17844);
+ if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(0 * 2) == 0)
+ the_command = Swap16(script_word_vars.psi_cmds[0]);
if (script_byte_vars.byte_179DC >= 63
&& script_byte_vars.zone_area < 22
@@ -2407,8 +2589,8 @@ unsigned int CMD_C_PsiKnowMind(void) {
ProcessMenu();
- if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(4) == 0)
- the_command = Swap16(script_word_vars.word_17846);
+ if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(2 * 2) == 0)
+ the_command = Swap16(script_word_vars.psi_cmds[1]);
return ScriptRerun;
}
@@ -2427,7 +2609,7 @@ unsigned int CMD_D_PsiBrainwarp(void) {
return ScriptRerun;
}
- if (GetZoneObjCommand(2) != 0) {
+ if (GetZoneObjCommand(1 * 2) != 0) {
PlayAnim(39, found_spot->sx + 8 / 4, found_spot->sy - 10);
RestoreScreenOfSpecialRoom();
return ScriptRerun;
@@ -2495,7 +2677,7 @@ unsigned int CMD_E_PsiZoneScan(void) {
RestoreScreenOfSpecialRoom();
- the_command = Swap16(script_word_vars.word_17848);
+ the_command = Swap16(script_word_vars.psi_cmds[2]);
return ScriptRerun;
@@ -2517,8 +2699,8 @@ unsigned int CMD_F_PsiPsiShift(void) {
PlayAnim(39, cursor_x / 4, cursor_y);
RestoreScreenOfSpecialRoom();
- if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(6) == 0)
- the_command = Swap16(script_word_vars.word_1784E);
+ if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(3 * 2) == 0)
+ the_command = Swap16(script_word_vars.psi_cmds[5]);
return ScriptRerun;
}
@@ -2539,17 +2721,17 @@ unsigned int CMD_10_PsiExtremeViolence(void) {
ProcessMenu();
if (script_byte_vars.cur_spot_idx == 0) {
- the_command = Swap16(script_word_vars.word_1784C);
+ the_command = Swap16(script_word_vars.psi_cmds[4]);
script_byte_vars.byte_179F3 = 0;
return ScriptRerun;
}
- command = GetZoneObjCommand(8);
+ command = GetZoneObjCommand(4 * 2);
if ((command & 0xF000) == 0x9000)
script_byte_vars.byte_179F3 = 0;
else if (command == 0) {
- the_command = Swap16(script_word_vars.word_1784C);
+ the_command = Swap16(script_word_vars.psi_cmds[4]);
script_byte_vars.byte_179F3 = 0;
}
@@ -2567,7 +2749,7 @@ unsigned int CMD_11_PsiTuneIn(void) {
command = Swap16(script_word_vars.word_178F8);
else {
if (script_byte_vars.byte_179DC < 63 || script_byte_vars.zone_area >= 22)
- command = Swap16(script_word_vars.word_1784A);
+ command = Swap16(script_word_vars.psi_cmds[3]);
else
command = 275;
}
@@ -2752,10 +2934,12 @@ unsigned int CMD_14_VortAppear(void) {
pers_t *pers_vort_ptr;
+#define ADJACENT_AREAS_MAX 19
+
struct {
- unsigned char room;
- unsigned char field_1;
-} vortleave[] = {
+ unsigned char zone; /* current zone */
+ unsigned char area; /* area accessible from this zone */
+} adjacent_areas[ADJACENT_AREAS_MAX] = {
{ 2, 5},
{ 3, 8},
{ 4, 8},
@@ -2803,11 +2987,11 @@ unsigned int CMD_15_VortLeave(void) {
pers->area = 0;
next_command3 = 0;
- for (i = 0; i < 19; i++) {
- if (vortleave[i].room == script_byte_vars.zone_index) {
+ for (i = 0; i < ADJACENT_AREAS_MAX; i++) {
+ if (adjacent_areas[i].zone == script_byte_vars.zone_index) {
next_command3 = 0xA016;
next_ticks3 = Swap16(script_word_vars.timer_ticks2) + 5;
- pers->area = vortleave[i].field_1;
+ pers->area = adjacent_areas[i].area;
}
}
pers_vort_ptr = pers;
@@ -2829,6 +3013,11 @@ unsigned int CMD_16_VortGone(void) {
return 0;
}
+unsigned int CMD_17_TakePersonsItem() {
+ TakePersonsItem();
+ return ScriptRerun;
+}
+
unsigned int CMD_18_AspirantLeave(void) {
/*TODO: check me*/
static const animdesc_t anim33 = {ANIMFLG_USESPOT | 33};
@@ -2883,9 +3072,53 @@ unsigned int CMD_1B_Holo(void) {
}
/*
-TODO: check me
+Turkey walking into the room
+*/
+unsigned int CMD_1E_TurkeyAppear(void) {
+ /*TODO: check me*/
+ pers_list[5].area = script_byte_vars.zone_area;
+ FindAndSelectSpot(5 * 5);
+ AnimateSpot(&turkeyanims_ptr->field_1);
+ next_command4 = 0xA01F;
+ BlitSpritesToBackBuffer();
+ DrawZoneObjs();
+ CGA_BackBufferToRealFull();
+ next_ticks4 = Swap16(script_word_vars.timer_ticks2) + 5;
+ return 0;
+}
+
+/*
+Turkey leaving the room
+*/
+unsigned int CMD_1F_TurkeyLeave(void) {
+ unsigned int i;
+ animdesc_t *anim;
+ pers_t *pers;
+
+ pers = &pers_list[5];
+ anim = &turkeyanims_ptr->field_4;
+
+ pers->area = 0;
+ next_command4 = 0;
+ for (i = 0; i < ADJACENT_AREAS_MAX; i++) {
+ if (adjacent_areas[i].zone == script_byte_vars.zone_index) {
+ next_command4 = 0xA020;
+ next_ticks4 = Swap16(script_word_vars.timer_ticks2) + 5;
+ pers->area = adjacent_areas[i].area;
+ }
+ }
+
+ zone_spots[(pers->flags & 15) - 1].flags &= ~SPOTFLG_80;
+
+ FindAndSelectSpot(5 * 5);
+ AnimateSpot(anim);
+ return 0;
+}
+
+/*
+Turkey left the room
*/
-unsigned int CMD_20_(void) {
+unsigned int CMD_20_TurkeyGone(void) {
pers_list[5].area = 0;
next_command4 = 0;
return 0;
@@ -2982,16 +3215,16 @@ cmdhandler_t command_handlers[] = {
CMD_14_VortAppear,
CMD_15_VortLeave,
CMD_16_VortGone,
- CMD_TRAP,
+ CMD_17_TakePersonsItem,
CMD_18_AspirantLeave,
CMD_TRAP,
CMD_TRAP,
CMD_1B_Holo,
CMD_TRAP,
CMD_TRAP,
- CMD_TRAP,
- CMD_TRAP,
- CMD_TRAP, /*20*/
+ CMD_1E_TurkeyAppear,
+ CMD_1F_TurkeyLeave,
+ CMD_20_TurkeyGone, /*20*/
CMD_21_VortTalk,
CMD_22_,
CMD_23_,
@@ -3024,7 +3257,7 @@ cmdhandler_t script_handlers[] = {
SCR_13_RedrawRoomStatics,
SCR_14_DrawDesc,
SCR_15_SelectSpot,
- SCR_TRAP,
+ SCR_16_DrawDeathAnim,
SCR_17_DrawPersonThoughtBubbleDialog,
SCR_18_AnimPortrait,
SCR_19_HidePortraitLiftLeft,
@@ -3049,7 +3282,7 @@ cmdhandler_t script_handlers[] = {
SCR_2C_Wait4,
SCR_2D_Wait,
SCR_2E_PromptWait,
- SCR_TRAP,
+ SCR_2F_TakePersonsItem,
SCR_30_Fight, /*30*/
SCR_31_Fight2,
SCR_32_FightWin,
@@ -3077,9 +3310,9 @@ cmdhandler_t script_handlers[] = {
SCR_48_DeProfundisLowerMonster,
SCR_49_DeProfundisRiseHook,
SCR_TRAP,
- SCR_TRAP,
+ SCR_4B_ProtoDropZapstik,
SCR_4C_DrawZoneObjs,
- SCR_TRAP,
+ SCR_4D_PriorityCommand,
SCR_4E_BounceCurrentItemToRoom,
SCR_4F_BounceCurrentItemToInventory,
SCR_50_BounceItemToInventory, /*50*/
@@ -3087,20 +3320,20 @@ cmdhandler_t script_handlers[] = {
SCR_52_RefreshSpritesData,
SCR_53_FindInvItem,
SCR_TRAP,
+ SCR_55_DrawRoomItemsIndicator,
SCR_TRAP,
- SCR_TRAP,
- SCR_TRAP,
- SCR_TRAP,
+ SCR_57_ShowCharacterSprite,
+ SCR_58_DrawCharacterSprite,
SCR_59_BlitSpritesToBackBuffer,
SCR_5A_SelectPalette,
SCR_TRAP,
- SCR_TRAP,
- SCR_TRAP,
- SCR_TRAP,
+ SCR_5C_ClearInventory,
+ SCR_5D_DropWeapons,
+ SCR_5E_SelectTempPalette,
SCR_5F_DrawRoomObjectBack,
SCR_TRAP, /*60*/
SCR_61_DrawPersonBubbleDialog,
- SCR_TRAP,
+ SCR_62_PsiReaction,
SCR_TRAP,
SCR_64_DrawBoxAroundSpot,
SCR_65_DeProfundisMovePlatform,
@@ -3170,8 +3403,8 @@ unsigned char *GetScriptSubroutine(unsigned int index) {
unsigned int RunCommand(void) {
unsigned int res;
unsigned short cmd;
-again:
- ;
+
+again:;
res = 0;
if (the_command == 0)
@@ -3205,7 +3438,7 @@ again:
res = command_handlers[cmd]();
break;
case 0xF000:
- /*restore sp from keep_sp*/
+ /*restore sp from keep_sp then run script*/
TODO("SCR_RESTORE\n");
default:
res = RunScript(GetScriptSubroutine(cmd - 1));
diff --git a/engines/chamber/script.h b/engines/chamber/script.h
index 6924b1df303..3b08ac74562 100644
--- a/engines/chamber/script.h
+++ b/engines/chamber/script.h
@@ -157,12 +157,7 @@ typedef struct script_byte_vars_t {
/*2-byte long vars, in BIG-endian order*/
typedef struct script_word_vars_t {
- unsigned short word_17844; /* 0 */
- unsigned short word_17846; /* 2 */
- unsigned short word_17848; /* 4 */
- unsigned short word_1784A; /* 6 */
- unsigned short word_1784C; /* 8 */
- unsigned short word_1784E; /* A */
+ unsigned short psi_cmds[6]; /* 0 */
unsigned short word_17850; /* C */
unsigned short word_17852; /* E */
unsigned short timer_ticks2; /* 10 */
diff --git a/engines/chamber/scrvars.h b/engines/chamber/scrvars.h
index da9a4a89a0d..9003db3e666 100644
--- a/engines/chamber/scrvars.h
+++ b/engines/chamber/scrvars.h
@@ -145,12 +145,7 @@ script_byte_vars_t script_byte_vars = {
};
script_word_vars_t script_word_vars = {
- BE(0x9007), /* 00 */
- BE(0x9007), /* 02 */
- BE(0x9007), /* 04 */
- BE(0x9007), /* 06 */
- BE(0x9007), /* 08 */
- BE(0x9007), /* 0A */
+ {BE(0x9007), BE(0x9007), BE(0x9007), BE(0x9007), BE(0x9007), BE(0x9007)}, /* 00 .. 0B */
BE(0), /* 0C */
BE(0), /* 0E */
BE(0), /* 10 */
Commit: 9a120255e29ef2963275c6e3c671b860bdb5fa35
https://github.com/scummvm/scummvm/commit/9a120255e29ef2963275c6e3c671b860bdb5fa35
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Implemented input
Changed paths:
engines/chamber/chamber.cpp
engines/chamber/chamber.h
engines/chamber/input.cpp
engines/chamber/input.h
engines/chamber/kult.cpp
diff --git a/engines/chamber/chamber.cpp b/engines/chamber/chamber.cpp
index 7d674b69b31..a41f93ac9f9 100644
--- a/engines/chamber/chamber.cpp
+++ b/engines/chamber/chamber.cpp
@@ -43,12 +43,10 @@ ChamberEngine::ChamberEngine(OSystem *syst)
// Don't forget to register your random source
_rnd = new Common::RandomSource("chamber");
- debug("ChamberEngine::ChamberEngine");
+ _shouldQuit = false;
}
ChamberEngine::~ChamberEngine() {
- debug("ChamberEngine::~ChamberEngine");
-
// Dispose your resources here
delete _rnd;
}
diff --git a/engines/chamber/chamber.h b/engines/chamber/chamber.h
index fc184618aa9..7397485bf94 100644
--- a/engines/chamber/chamber.h
+++ b/engines/chamber/chamber.h
@@ -38,6 +38,8 @@ class ChamberEngine : public Engine {
private:
// We need random numbers
Common::RandomSource *_rnd;
+ bool _shouldQuit;
+
public:
ChamberEngine(OSystem *syst);
~ChamberEngine();
@@ -49,6 +51,8 @@ public:
Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
void syncGameStream(Common::Serializer &s);
+
+ byte readKeyboardChar();
};
void init(void);
diff --git a/engines/chamber/input.cpp b/engines/chamber/input.cpp
index de4f72c2f87..f68a4e2df1d 100644
--- a/engines/chamber/input.cpp
+++ b/engines/chamber/input.cpp
@@ -20,6 +20,9 @@
*
*/
+#include "common/events.h"
+#include "common/system.h"
+
#include "chamber/chamber.h"
#include "chamber/common.h"
#include "chamber/input.h"
@@ -41,12 +44,28 @@ unsigned char key_direction_old;
unsigned char accell_countdown;
unsigned int accelleration = 1;
-unsigned char ReadKeyboardChar(void) {
- warning("STUB: ReadKeyboardChar()");
+byte ChamberEngine::readKeyboardChar() {
+ Common::Event event;
- return 0;
+ while (true) {
+ while (g_system->getEventManager()->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ return event.kbd.ascii;
+
+ case Common::EVENT_RETURN_TO_LAUNCHER:
+ case Common::EVENT_QUIT:
+ _shouldQuit = true;
+ return 0;
- //return (unsigned char)getch();
+ default:
+ break;
+ }
+
+ g_system->updateScreen();
+ g_system->delayMillis(10);
+ }
+ }
}
void ClearKeyboard(void) {
@@ -182,52 +201,7 @@ void KeyboardIsr() {
}
void InitInput(void) {
- warning("STUB: InitInput()");
-
-#if 0
- /*disable critical errors handler*/
- setvect(0x24, NullIsr);
-
- /*is mouse present?*/
- if (getvect(0x33)) {
- union REGS reg;
- reg.x.ax = 0;
- int86(0x33, ®, ®);
- if (reg.x.ax == 0xFFFF) {
- /*mouse detected*/
-
- reg.x.ax = 0xF; /*set cursor speed*/
- reg.x.cx = 16;
- reg.x.dx = 16;
- int86(0x33, ®, ®);
-
- reg.x.ax = 7; /*set x range*/
- reg.x.cx = 0;
- reg.x.dx = 303;
- int86(0x33, ®, ®);
-
- reg.x.ax = 8; /*set y range*/
- reg.x.cx = 0;
- reg.x.dx = 183;
- int86(0x33, ®, ®);
-
- reg.x.ax = 4; /*set coords*/
- cursor_x = reg.x.cx = 10;
- cursor_y = reg.x.dx = 10;
- int86(0x33, ®, ®);
-
- have_mouse = ~0;
- }
- }
-
- if (have_mouse)
- return;
-
- /*no mouse*/
-
- old_keyboard_isr = getvect(9);
- setvect(9, KeyboardIsr);
-#endif
+ have_mouse = 1;
}
void UninitInput(void) {
diff --git a/engines/chamber/input.h b/engines/chamber/input.h
index d0ebbda8526..b7899b0db7b 100644
--- a/engines/chamber/input.h
+++ b/engines/chamber/input.h
@@ -34,7 +34,6 @@ extern volatile unsigned char key_direction;
extern volatile unsigned char key_code;
extern unsigned char key_held;
-unsigned char ReadKeyboardChar(void);
void ClearKeyboard(void);
unsigned char PollMouse(void);
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 761c9326d8e..c46edc4f757 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -215,17 +215,24 @@ Common::Error ChamberEngine::run() {
/* Wait for a keypress and show the language selection screen */
ClearKeyboard();
- ReadKeyboardChar();
- CGA_SwapRealBackBuffer();
+ readKeyboardChar();
+
+ if (_shouldQuit)
+ return Common::kNoError;
+
+ CGA_BackBufferToRealFull();
ClearKeyboard();
/* Wait for a valid language choice */
do {
- c = ReadKeyboardChar();
+ c = readKeyboardChar();
if (c > 'F')
c -= ' ';
} while (c < 'D' || c > 'F');
+ if (_shouldQuit)
+ return Common::kNoError;
+
/* Patch resource names for choosen language */
res_texts[0].name[4] = c;
res_texts[1].name[4] = c;
Commit: 73e2366c8ba43cb9aaf07093dad732740a4ab26a
https://github.com/scummvm/scummvm/commit/73e2366c8ba43cb9aaf07093dad732740a4ab26a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Implemented timer
Changed paths:
engines/chamber/timer.cpp
diff --git a/engines/chamber/timer.cpp b/engines/chamber/timer.cpp
index e883de3c810..b444b6c8662 100644
--- a/engines/chamber/timer.cpp
+++ b/engines/chamber/timer.cpp
@@ -20,6 +20,9 @@
*
*/
+#include "common/system.h"
+#include "common/timer.h"
+
#include "chamber/chamber.h"
#include "chamber/common.h"
#include "chamber/cga.h"
@@ -37,44 +40,26 @@ void AnimateGauss(unsigned char *target) {
script_byte_vars.gauss_phase = phase;
sprite = gauss_data + 8 + phase * (8 * 30);
CGA_Blit(sprite, 8, 8, 30, target, 80); /*draw to 0:4*/
-}
-#if 0
-void interrupt(*old_timer_isr)();
+ warning("Blit");
+}
-void interrupt TimerIsr() {
- disable();
+void timerCallback(void *refCon) {
script_byte_vars.timer_ticks++;
if (!script_byte_vars.game_paused) {
- if (script_byte_vars.timer_ticks % 16 == 0) {
- script_word_vars.timer_ticks2 = Swap16(Swap16(script_word_vars.timer_ticks2) + 1);
+ script_word_vars.timer_ticks2 = Swap16(Swap16(script_word_vars.timer_ticks2) + 1);
#if 1
- AnimateGauss(frontbuffer);
+ AnimateGauss(frontbuffer);
#endif
- }
}
- enable();
}
-#endif
-
void InitTimer(void) {
- warning("STUB: InitTimer()");
-#if 0
- disable();
- old_timer_isr = getvect(0x1C);
- setvect(0x1C, TimerIsr);
- enable();
-#endif
+ g_system->getTimerManager()->installTimerProc(&timerCallback, 1000000, NULL, "mainTimer");
}
void UninitTimer(void) {
- warning("STUB: UninitTimer()");
-#if 0
- disable();
- setvect(0x1C, old_timer_isr);
- enable();
-#endif
+ g_system->getTimerManager()->removeTimerProc(&timerCallback);
}
} // End of namespace Chamber
Commit: 92e9f3d482e3b2fa85dd0dd1a176a91d6c5d9c4a
https://github.com/scummvm/scummvm/commit/92e9f3d482e3b2fa85dd0dd1a176a91d6c5d9c4a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Implement mouse input and proper quitting
Changed paths:
engines/chamber/chamber.cpp
engines/chamber/chamber.h
engines/chamber/dialog.cpp
engines/chamber/input.cpp
engines/chamber/kult.cpp
engines/chamber/script.cpp
engines/chamber/timer.cpp
diff --git a/engines/chamber/chamber.cpp b/engines/chamber/chamber.cpp
index a41f93ac9f9..f5ad0eaca7f 100644
--- a/engines/chamber/chamber.cpp
+++ b/engines/chamber/chamber.cpp
@@ -36,8 +36,12 @@
namespace Chamber {
+ChamberEngine *g_vm;
+
ChamberEngine::ChamberEngine(OSystem *syst)
: Engine(syst) {
+ g_vm = this;
+
const Common::FSNode gameDataDir(ConfMan.get("path"));
// Don't forget to register your random source
diff --git a/engines/chamber/chamber.h b/engines/chamber/chamber.h
index 7397485bf94..bf608b95263 100644
--- a/engines/chamber/chamber.h
+++ b/engines/chamber/chamber.h
@@ -38,7 +38,6 @@ class ChamberEngine : public Engine {
private:
// We need random numbers
Common::RandomSource *_rnd;
- bool _shouldQuit;
public:
ChamberEngine(OSystem *syst);
@@ -53,10 +52,15 @@ public:
void syncGameStream(Common::Serializer &s);
byte readKeyboardChar();
+
+public:
+ bool _shouldQuit;
};
void init(void);
+extern ChamberEngine *g_vm;
+
} // End of namespace Chamber
#endif
diff --git a/engines/chamber/dialog.cpp b/engines/chamber/dialog.cpp
index 62f4c807b83..48a259e2f68 100644
--- a/engines/chamber/dialog.cpp
+++ b/engines/chamber/dialog.cpp
@@ -20,6 +20,8 @@
*
*/
+#include "common/system.h"
+
#include "chamber/chamber.h"
#include "chamber/common.h"
#include "chamber/dialog.h"
@@ -186,6 +188,12 @@ void PromptWait(void) {
ShowPromptAnim();
}
PollInput();
+
+ if (g_vm->_shouldQuit)
+ break;
+
+ g_system->updateScreen();
+ g_system->delayMillis(10);
} while (!buttons);
if (cursor_anim_phase)
diff --git a/engines/chamber/input.cpp b/engines/chamber/input.cpp
index f68a4e2df1d..a4f11f0ee49 100644
--- a/engines/chamber/input.cpp
+++ b/engines/chamber/input.cpp
@@ -43,6 +43,7 @@ unsigned char right_button;
unsigned char key_direction_old;
unsigned char accell_countdown;
unsigned int accelleration = 1;
+byte mouseButtons = 0;
byte ChamberEngine::readKeyboardChar() {
Common::Event event;
@@ -141,12 +142,51 @@ unsigned char PollKeyboard(void) {
}
void PollInput(void) {
- unsigned char keys;
- if (have_mouse)
- keys = PollMouse();
- else
- keys = PollKeyboard();
- SetInputButtons(keys);
+ Common::Event event;
+ while (g_system->getEventManager()->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ if (event.kbd.keycode == Common::KEYCODE_SPACE)
+ mouseButtons |= 1;
+ break;
+
+ case Common::EVENT_KEYUP:
+ if (event.kbd.keycode == Common::KEYCODE_SPACE)
+ mouseButtons &= ~1;
+ break;
+
+ case Common::EVENT_RETURN_TO_LAUNCHER:
+ case Common::EVENT_QUIT:
+ g_vm->_shouldQuit = true;
+ break;
+
+ case Common::EVENT_MOUSEMOVE:
+ cursor_x = event.mouse.x;
+ cursor_y = event.mouse.y;
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ mouseButtons |= 1;
+ break;
+
+ case Common::EVENT_LBUTTONUP:
+ mouseButtons &= ~1;
+ break;
+
+ case Common::EVENT_RBUTTONDOWN:
+ mouseButtons |= 2;
+ break;
+
+ case Common::EVENT_RBUTTONUP:
+ mouseButtons &= ~2;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ SetInputButtons(mouseButtons);
}
void ProcessInput(void) {
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index c46edc4f757..ed7b6448651 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -20,9 +20,9 @@
*
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
#include "common/error.h"
+#include "common/system.h"
#include "engines/util.h"
#include "chamber/chamber.h"
@@ -54,9 +54,12 @@ void AskDisk2(void) {
}
void SaveToFile(char *filename, void *data, unsigned int size) {
+ warning("STUB: SaveToFile(%s, data, %d)", filename, size);
+#if 0
FILE *f = fopen(filename, "wb");
fwrite(data, 1, size, f);
fclose(f);
+#endif
}
int LoadSplash(const char *filename) {
@@ -105,6 +108,9 @@ void GameLoop(unsigned char *target) {
/* Get player input */
PollInput();
+ if (g_vm->_shouldQuit)
+ return;
+
the_command = 0;
if (IsCursorInRect(&room_bounds_rect)) {
SelectCursor(CURSOR_TARGET);
@@ -152,6 +158,9 @@ void GameLoop(unsigned char *target) {
goto process;
}
+ g_system->updateScreen();
+ g_system->delayMillis(10);
+
continue;
process:
@@ -177,13 +186,14 @@ process:
ProcessInput();
DrawSpots(target);
}
+ g_system->updateScreen();
+ g_system->delayMillis(10);
}
}
void ExitGame(void) {
SwitchToTextMode();
- exit(0);
}
Common::Error ChamberEngine::run() {
@@ -295,6 +305,9 @@ restart:
RunCommand();
#endif
+ if (_shouldQuit)
+ return Common::kNoError;
+
/* Sync graphics */
BlitSpritesToBackBuffer();
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index eb3c645f2a9..110e52d7db3 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -20,6 +20,10 @@
*
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
+#include "common/system.h"
+
#include "chamber/chamber.h"
#include "chamber/common.h"
#include "chamber/script.h"
@@ -3385,7 +3389,7 @@ unsigned int RunScript(unsigned char *code) {
status = script_handlers[opcode]();
- if (status != ScriptContinue)
+ if (status != ScriptContinue || g_vm->_shouldQuit)
break;
}
diff --git a/engines/chamber/timer.cpp b/engines/chamber/timer.cpp
index b444b6c8662..05aed1fb9c9 100644
--- a/engines/chamber/timer.cpp
+++ b/engines/chamber/timer.cpp
@@ -40,8 +40,6 @@ void AnimateGauss(unsigned char *target) {
script_byte_vars.gauss_phase = phase;
sprite = gauss_data + 8 + phase * (8 * 30);
CGA_Blit(sprite, 8, 8, 30, target, 80); /*draw to 0:4*/
-
- warning("Blit");
}
void timerCallback(void *refCon) {
Commit: 949e278f53ab8686d5b07b057220516978d0b56d
https://github.com/scummvm/scummvm/commit/949e278f53ab8686d5b07b057220516978d0b56d
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix room backround drawing
Changed paths:
engines/chamber/room.cpp
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index 2da5c14845a..78a68c1ed26 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -272,7 +272,7 @@ 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*/
- for (i = 0; i < 53; i++) {
+ for (i = 0; i < 52; i++) {
/*draw a tile, alternating between two variants*/
CGA_Blit(pixels + (i & 1 ? 0 : kBgW * kBgH), kBgW, kBgW, kBgH, target, offs);
if (vblank)
Commit: e9d9c74a842a44b660d4ad1d70e48ea0db7689a1
https://github.com/scummvm/scummvm/commit/e9d9c74a842a44b660d4ad1d70e48ea0db7689a1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix resource data parsing
Changed paths:
engines/chamber/cga.cpp
engines/chamber/portrait.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 618de8b8fa6..5fecc0a188e 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -206,7 +206,7 @@ Out:
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;
- *(unsigned int *)(buffer + 2) = ofs;
+ *(uint16 *)(buffer + 2) = ofs;
buffer += 4;
while (h--) {
memcpy(buffer, screen + ofs, w);
@@ -266,15 +266,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) {
- unsigned int w, h;
- unsigned int ofs;
+ uint16 w, h;
+ uint16 ofs;
if (!buffer)
return;
h = *(unsigned char *)(buffer + 0);
w = *(unsigned char *)(buffer + 1);
- ofs = *(unsigned int *)(buffer + 2);
+ ofs = *(uint16 *)(buffer + 2);
buffer += 4; /*TODO: fix me for large int*/
CGA_Blit(buffer, w, w, h, target, ofs);
@@ -299,7 +299,7 @@ void CGA_RefreshImageData(unsigned char *buffer) {
h = *(unsigned char *)(buffer + 0);
w = *(unsigned char *)(buffer + 1);
- ofs = *(unsigned int *)(buffer + 2);
+ ofs = *(uint16 *)(buffer + 2);
CGA_CopyScreenBlock(CGA_SCREENBUFFER, w, h, backbuffer, ofs);
}
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index 4b760286a82..dc9c8e74b8c 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -230,7 +230,7 @@ void DrawBoxAroundSpot(void) {
h = *(unsigned char *)(buffer + 0);
w = *(unsigned char *)(buffer + 1);
- ofs = *(unsigned int *)(buffer + 2);
+ ofs = *(uint16 *)(buffer + 2);
/*decode ofs back to x:y*/
/*TODO: this is CGA-only!*/
Commit: 29c9ef30ed1667851d51525e26ded8725d9fdfdf
https://github.com/scummvm/scummvm/commit/29c9ef30ed1667851d51525e26ded8725d9fdfdf
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Added code for CGA blitting
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 5fecc0a188e..40c1b538401 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -230,13 +230,45 @@ 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) {
- while (h--) {
- memcpy(screen + ofs, pixels, w);
- pixels += pw;
- ofs ^= CGA_ODD_LINES_OFS;
- if ((ofs & CGA_ODD_LINES_OFS) == 0)
- ofs += CGA_BYTES_PER_LINE;
+ byte *src = pixels;
+ uint ofs1 = ofs;
+ for (int y = 0; y < h; y++) {
+ memcpy(screen + ofs1, src, w);
+ src += pw;
+ ofs1 ^= CGA_ODD_LINES_OFS;
+ if ((ofs1 & CGA_ODD_LINES_OFS) == 0)
+ ofs1 += CGA_BYTES_PER_LINE;
}
+
+ // Now copy pixels to our screen
+ src = pixels;
+ int dy = ofs / 80;
+ int dx = (ofs % 80) * 4;
+
+ if (dy + h >= 200)
+ h = 199 - dy;
+
+ if (dx + w * 4 >= 320)
+ w = (320 - dx) / 4;
+
+ for (int y = 0; y < h; y++) {
+ byte *dst = scrbuffer + (y + dy) * 320 + dx;
+ byte *src1 = src;
+
+ for (int x = 0; x < w; x++) {
+ byte colors = *src1++;
+
+ for (int c = 0; c < 4; c++) {
+ byte color = (colors & 0xC0) >> 6;
+ colors <<= 2;
+
+ *dst++ = color;
+ }
+ }
+ src += pw;
+ }
+
+ g_system->copyRectToScreen(scrbuffer, 320, dx, dy, w * 4, h);
}
/*
@@ -249,12 +281,35 @@ void CGA_BlitAndWait(unsigned char *pixels, unsigned int pw, unsigned int w, uns
}
void CGA_Fill(unsigned char pixel, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) {
- while (h--) {
- memset(screen + ofs, pixel, w);
- ofs ^= CGA_ODD_LINES_OFS;
- if ((ofs & CGA_ODD_LINES_OFS) == 0)
- ofs += CGA_BYTES_PER_LINE;
+ uint ofs1 = ofs;
+ for (int y = 0; y < h; y++) {
+ memset(screen + ofs1, pixel, w);
+ ofs1 ^= CGA_ODD_LINES_OFS;
+ if ((ofs1 & CGA_ODD_LINES_OFS) == 0)
+ ofs1 += CGA_BYTES_PER_LINE;
+ }
+
+ // Now copy pixels to our screen
+ int dy = ofs / 80;
+ int dx = (ofs % 80) * 4;
+
+ if (dy + h >= 200)
+ h = 199 - dy;
+
+ w *= 4;
+
+ if (dx + w >= 320)
+ w = 320 - dx;
+
+ for (int y = 0; y < h; y++) {
+ byte *dst = screen + (y + dy) * 320 + dx;
+
+ for (int x = 0; x < w; x++) {
+ *dst++ = pixel;
+ }
}
+
+ g_system->copyRectToScreen(scrbuffer, 320, dx, dy, w * 4, h);
}
void CGA_FillAndWait(unsigned char pixel, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) {
Commit: eaeb022e3dc54c3878524083347bd4ad2bd3f079
https://github.com/scummvm/scummvm/commit/eaeb022e3dc54c3878524083347bd4ad2bd3f079
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix room drawing
Changed paths:
engines/chamber/room.cpp
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index 78a68c1ed26..b3073e4e564 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -262,7 +262,7 @@ static const signed int background_draw_steps[] = {
-kBgH / 2 * CGA_BYTES_PER_LINE, -kBgH / 2 * CGA_BYTES_PER_LINE,
kBgW, kBgW, kBgW, kBgW, kBgW,
kBgH / 2 * CGA_BYTES_PER_LINE,
- -kBgW, -kBgW, -kBgW, -kBgW
+ -kBgW, -kBgW, -kBgW, -kBgW, 0
};
/*
@@ -272,7 +272,7 @@ 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*/
- for (i = 0; i < 52; i++) {
+ 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);
if (vblank)
Commit: 64f69f38bef0a1044c7f640ee2cf420f15d6e70a
https://github.com/scummvm/scummvm/commit/64f69f38bef0a1044c7f640ee2cf420f15d6e70a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Implement even more script commands
Changed paths:
engines/chamber/room.h
engines/chamber/script.cpp
engines/chamber/script.h
diff --git a/engines/chamber/room.h b/engines/chamber/room.h
index bf8b1b4f9fa..0d922ee290b 100644
--- a/engines/chamber/room.h
+++ b/engines/chamber/room.h
@@ -26,6 +26,7 @@
namespace Chamber {
#define SPOTFLG_1 0x01
+#define SPOTFLG_2 0x02
#define SPOTFLG_8 0x08
#define SPOTFLG_10 0x10
#define SPOTFLG_20 0x20
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 110e52d7db3..9097f2f321b 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -190,6 +190,129 @@ unsigned int SCR_1_AspirantItemTrade(void) {
return 0;
}
+unsigned int SCR_2_RudeAspirantTrade(void) {
+ unsigned char *old_script, *old_script_end = script_end_ptr;
+
+ item_t *item1, *item2;
+
+ script_ptr++;
+ old_script = script_ptr;
+
+ the_command = 0x9099; /*WHAT DO YOU WANT TO EXCHANGE?*/
+ RunCommand();
+
+ for (;;) {
+ inv_bgcolor = 0xFF;
+ OpenInventory(0xFE, ITEMFLG_80);
+
+ if (inv_count == 0) {
+ the_command = 0xC1C5;
+ RunCommand();
+ break;
+ }
+
+ if (the_command == 0)
+ break;
+
+ the_command = 0x9140; /*NOTHING ON HIM*/
+
+ if (pers_ptr->item == 0) {
+ RunCommand();
+ break;
+ }
+
+ item1 = &inventory_items[pers_ptr->item - 1];
+ item2 = (item_t *)(script_vars[ScrPool3_CurrentItem]);
+
+ if (item2->flags == (ITEMFLG_80 | 1)) {
+ the_command = 0xC1C0;
+ RunCommand();
+ break;
+ }
+
+ if (item1->name < 104 || item1->name >= 108) {
+ RunCommand();
+ break;
+ }
+
+ if ((item1->name != item2->name)
+ && (item2->name == 109
+ || item2->name == 132
+ || item2->name == 108
+ || script_byte_vars.rand_value < 154)) {
+ script_byte_vars.trade_done = 0;
+ the_command = 0xC1C6;
+ RunCommand();
+ if (script_byte_vars.trade_done == 0)
+ break;
+ item2->flags = ITEMFLG_20;
+ item1->flags = ITEMFLG_80;
+ pers_ptr->item = script_byte_vars.inv_item_index;
+ switch (item2->name) {
+ case 132:
+ script_byte_vars.room_items--;
+ the_command = 0xC04B;
+ break;
+ case 104:
+ the_command = 0xC1BA;
+ break;
+ case 107:
+ the_command = 0xC1BB;
+ break;
+ default:
+ the_command = 0xC1B9;
+ }
+ RunCommand();
+ break;
+ } else {
+ item2->flags = ITEMFLG_80 | 1;
+ the_command = 0xC1BD; /*not interested*/
+ RunCommand();
+ continue;
+ }
+ }
+
+ ClaimTradedItems();
+
+ script_ptr = old_script;
+ script_end_ptr = old_script_end;
+
+ return 0;
+}
+
+unsigned int SCR_4_StealZapstik(void) {
+ unsigned char *old_script;
+
+ pers_t *pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]);
+
+ script_ptr++;
+ old_script = script_ptr;
+
+ if ((pers->index & ~7) != 0x30) {
+ the_command = 0x9148; /*YOU`VE ALREADY GOT IT*/
+ RunCommand();
+ } else {
+ pers->index &= ~0x18;
+
+ script_vars[ScrPool3_CurrentItem] = &inventory_items[38 + (script_byte_vars.cur_pers - 1) - 9];
+ script_byte_vars.byte_179F1++;
+
+ BounceCurrentItem(ITEMFLG_80, 85); /*bounce to inventory*/
+
+ the_command = 0x9147; /*YOU GET HIS ZAPSTIK*/
+ if (script_byte_vars.zapstik_stolen == 0) {
+ RunCommand();
+ script_byte_vars.zapstik_stolen = 1;
+ the_command = 0x9032; /*THIS SHOULD GIVE YOU THE EDGE IN MOST COMBATS!*/
+ }
+ RunCommand();
+ }
+
+ script_ptr = old_script;
+
+ return 0;
+}
+
unsigned char wait_delta = 0;
@@ -1602,10 +1725,7 @@ unsigned int SCR_31_Fight2(void) {
return 0;
}
-unsigned int SCR_32_FightWin(void) {
-
- script_ptr++;
-
+void FightWin(void) {
script_byte_vars.byte_17A1D = 0;
if (script_byte_vars.byte_179F9 != 18 && *spot_sprite != 0) {
@@ -1624,6 +1744,13 @@ unsigned int SCR_32_FightWin(void) {
prev_fight_mode = script_byte_vars.byte_179F3;
script_byte_vars.byte_179F3 = 0;
+}
+
+unsigned int SCR_32_FightWin(void) {
+
+ script_ptr++;
+
+ FightWin();
return 0;
}
@@ -1653,6 +1780,34 @@ unsigned int SCR_16_DrawDeathAnim(void) {
return 0;
}
+unsigned int SCR_60_ReviveCadaver(void) {
+ pers_t *pers;
+ script_ptr++;
+
+ BlitSpritesToBackBuffer();
+
+ FindAndSelectSpot(38 * 5);
+
+ script_byte_vars.byte_17A16 = 1;
+ FightWin();
+ script_byte_vars.byte_17A16 = 0;
+ pers_list[38].area = 0;
+
+ FindAndSelectSpot(fight_pers_ofs);
+ zone_spots[5].flags = SPOTFLG_40 | SPOTFLG_10 | SPOTFLG_2 | SPOTFLG_1;
+ found_spot->flags |= SPOTFLG_80;
+
+ pers = (pers_t *)script_vars[ScrPool8_CurrentPers];
+ pers->flags &= ~PERSFLG_40;
+ pers->area = script_byte_vars.zone_area;
+
+ DrawZoneObjs();
+ CGA_BackBufferToRealFull();
+
+ return 0;
+}
+
+
unsigned int SCR_57_ShowCharacterSprite(void) {
unsigned char index, x, y;
@@ -2152,9 +2307,19 @@ unsigned int SCR_62_PsiReaction(void) {
return 0;
}
+/*TODO: rename me*/
+unsigned int SCR_63_LiftSpot6(void) {
+ script_ptr++;
+ BlitSpritesToBackBuffer();
+ zone_spots[6].sy -= 5;
+ zone_spots[6].ey -= 5;
+ BackupSpotsImages();
+ DrawZoneObjs();
+ CGA_BackBufferToRealFull();
-
+ return 0;
+}
unsigned int SCR_64_DrawBoxAroundSpot(void) {
script_ptr++;
@@ -3241,9 +3406,9 @@ cmdhandler_t command_handlers[] = {
cmdhandler_t script_handlers[] = {
0,
SCR_1_AspirantItemTrade,
- SCR_TRAP,
+ SCR_2_RudeAspirantTrade,
SCR_3_DrawItemBox,
- SCR_TRAP,
+ SCR_4_StealZapstik,
SCR_5_DrawPortraitLiftRight,
SCR_6_DrawPortraitLiftLeft,
SCR_7_DrawPortraitLiftDown,
@@ -3335,10 +3500,10 @@ cmdhandler_t script_handlers[] = {
SCR_5D_DropWeapons,
SCR_5E_SelectTempPalette,
SCR_5F_DrawRoomObjectBack,
- SCR_TRAP, /*60*/
+ SCR_60_ReviveCadaver, /*60*/
SCR_61_DrawPersonBubbleDialog,
SCR_62_PsiReaction,
- SCR_TRAP,
+ SCR_63_LiftSpot6,
SCR_64_DrawBoxAroundSpot,
SCR_65_DeProfundisMovePlatform,
SCR_66_DeProfundisRideToExit,
diff --git a/engines/chamber/script.h b/engines/chamber/script.h
index 3b08ac74562..de3e0c581e4 100644
--- a/engines/chamber/script.h
+++ b/engines/chamber/script.h
@@ -105,7 +105,7 @@ typedef struct script_byte_vars_t {
unsigned char byte_179F1; /* 3B */
unsigned char byte_179F2; /* 3C */
unsigned char byte_179F3; /* 3D */
- unsigned char byte_179F4; /* 3E */
+ unsigned char trade_done; /* 3E */
unsigned char byte_179F5; /* 3F */
unsigned char byte_179F6; /* 40 */
unsigned char byte_179F7; /* 41 */
@@ -147,7 +147,7 @@ typedef struct script_byte_vars_t {
unsigned char byte_17A1B; /* 65 */
unsigned char byte_17A1C; /* 66 */
unsigned char byte_17A1D; /* 67 */
- unsigned char byte_17A1E; /* 68 */
+ unsigned char zapstik_stolen; /* 68 */
unsigned char byte_17A1F; /* 69 */
unsigned char byte_17A20; /* 6A */
unsigned char byte_17A21; /* 6B */
Commit: 00dffcc50f4c415352483559258ff28a4a50cb36
https://github.com/scummvm/scummvm/commit/00dffcc50f4c415352483559258ff28a4a50cb36
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Update screen when blit to CGA
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 40c1b538401..8cac53efb65 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -269,6 +269,9 @@ void CGA_Blit(unsigned char *pixels, unsigned int pw, unsigned int w, unsigned i
}
g_system->copyRectToScreen(scrbuffer, 320, dx, dy, w * 4, h);
+
+ if (screen == CGA_SCREENBUFFER)
+ g_system->updateScreen();
}
/*
@@ -310,6 +313,9 @@ void CGA_Fill(unsigned char pixel, unsigned int w, unsigned int h, unsigned char
}
g_system->copyRectToScreen(scrbuffer, 320, dx, dy, w * 4, h);
+
+ if (screen == CGA_SCREENBUFFER)
+ g_system->updateScreen();
}
void CGA_FillAndWait(unsigned char pixel, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) {
Commit: 8569c512b21829950fced59d76347eb9719526b0
https://github.com/scummvm/scummvm/commit/8569c512b21829950fced59d76347eb9719526b0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix crash on startup when cursor is not yet defined
Changed paths:
engines/chamber/cursor.cpp
diff --git a/engines/chamber/cursor.cpp b/engines/chamber/cursor.cpp
index d9c2a020e27..2c58cc3371a 100644
--- a/engines/chamber/cursor.cpp
+++ b/engines/chamber/cursor.cpp
@@ -32,7 +32,7 @@ namespace Chamber {
unsigned char cursor_color = 0;
-unsigned char *cursor_shape;
+unsigned char *cursor_shape = NULL;
unsigned char cursor_anim_ticks;
unsigned char cursor_anim_phase;
@@ -71,6 +71,9 @@ void SelectCursor(unsigned int num) {
Build cursor sprite for its current pixel-grained position
*/
void UpdateCursor(void) {
+ if (!cursor_shape)
+ return;
+
unsigned char *cursor, *sprite, *spr;
unsigned char cursor_bit_shift;
unsigned int x, y;
Commit: 92ce4b3e9a7dcd62ad14b6f46eb9c6de265342d6
https://github.com/scummvm/scummvm/commit/92ce4b3e9a7dcd62ad14b6f46eb9c6de265342d6
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Unstub PollMouse()
Changed paths:
engines/chamber/input.cpp
diff --git a/engines/chamber/input.cpp b/engines/chamber/input.cpp
index a4f11f0ee49..6fdc6dd009d 100644
--- a/engines/chamber/input.cpp
+++ b/engines/chamber/input.cpp
@@ -87,18 +87,9 @@ void SetInputButtons(unsigned char keys) {
}
unsigned char PollMouse(void) {
- warning("STUB: PollMouse()");
-
- return 0;
+ PollInput();
-#if 0
- union REGS reg;
- reg.x.ax = 3;
- int86(0x33, ®, ®);
- cursor_x = reg.x.cx;
- cursor_y = reg.h.dl;
- return reg.h.bl; /*buttons*/
-#endif
+ return buttons;
}
unsigned char PollKeyboard(void) {
Commit: 31e8e16e275f784b446b1ba0c77e250667a10ee8
https://github.com/scummvm/scummvm/commit/31e8e16e275f784b446b1ba0c77e250667a10ee8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Refactor CGA blitting routines
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 8cac53efb65..d2cc0186cf2 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -100,18 +100,26 @@ void CGA_ColorSelect(unsigned char csel) {
//outportb(0x3D9, csel);
}
-void CGA_BackBufferToRealFull(void) {
- memcpy(CGA_SCREENBUFFER, backbuffer, sizeof(backbuffer));
+void CGA_blitToScreen(int dx, int dy, int w, int h) {
+ if (dy + h >= 200)
+ h = 199 - dy;
- byte *dst = scrbuffer;
+ if (dx + w >= 320)
+ w = 319 - dx;
- for (int y = 0; y < 200; y++) {
- byte *ptr = CGA_SCREENBUFFER + (y >> 1) * 80;
- if (y & 1)
- ptr += 0x2000;
+ byte *src = CGA_SCREENBUFFER;
- for (int x = 0; x < 320 / 4; x++) {
- byte colors = *ptr++;
+ w = w / 4;
+
+ for (int y = 0; y < h; y++) {
+ byte *dst = scrbuffer + (y + dy) * 320 + dx;
+ byte *src1 = src;
+
+ if ((y + dy) & 1)
+ src1 += 0x2000;
+
+ for (int x = 0; x < w; x++) {
+ byte colors = *src1++;
for (int c = 0; c < 4; c++) {
byte color = (colors & 0xC0) >> 6;
@@ -120,12 +128,28 @@ void CGA_BackBufferToRealFull(void) {
*dst++ = color;
}
}
+
+ if ((y + dy) & 1)
+ src += 320 / 4;
}
- g_system->copyRectToScreen(scrbuffer, 320, 0, 0, 320, 200);
+ g_system->copyRectToScreen(scrbuffer, 320, dx, dy, w * 4, h);
g_system->updateScreen();
}
+void CGA_blitToScreen(int ofs, int w, int h) {
+ int dy = ofs / 80;
+ int dx = (ofs % 80) * 4;
+
+ CGA_blitToScreen(dx, dy, w, h);
+}
+
+void CGA_BackBufferToRealFull(void) {
+ memcpy(CGA_SCREENBUFFER, backbuffer, sizeof(backbuffer));
+
+ CGA_blitToScreen(0, 0, 320, 200);
+}
+
void CGA_RealBufferToBackFull(void) {
memcpy(backbuffer, CGA_SCREENBUFFER, sizeof(backbuffer));
}
@@ -240,38 +264,8 @@ void CGA_Blit(unsigned char *pixels, unsigned int pw, unsigned int w, unsigned i
ofs1 += CGA_BYTES_PER_LINE;
}
- // Now copy pixels to our screen
- src = pixels;
- int dy = ofs / 80;
- int dx = (ofs % 80) * 4;
-
- if (dy + h >= 200)
- h = 199 - dy;
-
- if (dx + w * 4 >= 320)
- w = (320 - dx) / 4;
-
- for (int y = 0; y < h; y++) {
- byte *dst = scrbuffer + (y + dy) * 320 + dx;
- byte *src1 = src;
-
- for (int x = 0; x < w; x++) {
- byte colors = *src1++;
-
- for (int c = 0; c < 4; c++) {
- byte color = (colors & 0xC0) >> 6;
- colors <<= 2;
-
- *dst++ = color;
- }
- }
- src += pw;
- }
-
- g_system->copyRectToScreen(scrbuffer, 320, dx, dy, w * 4, h);
-
if (screen == CGA_SCREENBUFFER)
- g_system->updateScreen();
+ CGA_blitToScreen(ofs, w * 4, h);
}
/*
@@ -292,30 +286,8 @@ void CGA_Fill(unsigned char pixel, unsigned int w, unsigned int h, unsigned char
ofs1 += CGA_BYTES_PER_LINE;
}
- // Now copy pixels to our screen
- int dy = ofs / 80;
- int dx = (ofs % 80) * 4;
-
- if (dy + h >= 200)
- h = 199 - dy;
-
- w *= 4;
-
- if (dx + w >= 320)
- w = 320 - dx;
-
- for (int y = 0; y < h; y++) {
- byte *dst = screen + (y + dy) * 320 + dx;
-
- for (int x = 0; x < w; x++) {
- *dst++ = pixel;
- }
- }
-
- g_system->copyRectToScreen(scrbuffer, 320, dx, dy, w * 4, h);
-
if (screen == CGA_SCREENBUFFER)
- g_system->updateScreen();
+ CGA_blitToScreen(ofs, w * 4, h);
}
void CGA_FillAndWait(unsigned char pixel, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) {
Commit: c612ef1ce9d7f5a4ef6897b30b62b89379f58b5f
https://github.com/scummvm/scummvm/commit/c612ef1ce9d7f5a4ef6897b30b62b89379f58b5f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Blit all CGA pixels
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index d2cc0186cf2..22f6e743a70 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -101,15 +101,21 @@ void CGA_ColorSelect(unsigned char csel) {
}
void CGA_blitToScreen(int dx, int dy, int w, int h) {
+ // Align x by 4
+ int align = dx & 0x3;
+
+ dx -= align;
+ w += align;
+
if (dy + h >= 200)
- h = 199 - dy;
+ h = 200 - dy;
if (dx + w >= 320)
- w = 319 - dx;
+ w = 320 - dx;
byte *src = CGA_SCREENBUFFER;
- w = w / 4;
+ w = (w + 3) / 4;
for (int y = 0; y < h; y++) {
byte *dst = scrbuffer + (y + dy) * 320 + dx;
@@ -352,12 +358,17 @@ void CGA_DrawVLine(unsigned int x, unsigned int y, unsigned int l, unsigned char
ofs = CGA_CalcXY_p(x / CGA_PIXELS_PER_BYTE, y);
+ uint ol = l;
+
while (l--) {
target[ofs] = (target[ofs] & mask) | pixel;
ofs ^= CGA_ODD_LINES_OFS;
if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
+
+ if (target == CGA_SCREENBUFFER)
+ CGA_blitToScreen(x, y, 1, ol);
}
/*
@@ -374,6 +385,7 @@ void CGA_DrawHLine(unsigned int x, unsigned int y, unsigned int l, unsigned char
pixel >>= (x % CGA_PIXELS_PER_BYTE) * CGA_BITS_PER_PIXEL;
ofs = CGA_CalcXY_p(x / CGA_PIXELS_PER_BYTE, y);
+ uint ol = l;
while (l--) {
target[ofs] = (target[ofs] & mask) | pixel;
mask >>= CGA_BITS_PER_PIXEL;
@@ -384,6 +396,8 @@ void CGA_DrawHLine(unsigned int x, unsigned int y, unsigned int l, unsigned char
pixel = color << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL);
}
}
+ if (target == CGA_SCREENBUFFER)
+ CGA_blitToScreen(x, y, ol, 1);
}
/*
@@ -398,6 +412,10 @@ unsigned int CGA_DrawHLineWithEnds(unsigned int bmask, unsigned int bpix, unsign
ofs ^= CGA_ODD_LINES_OFS;
if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
+
+ if (target == CGA_SCREENBUFFER)
+ CGA_blitToScreen(ofs, l, 1);
+
return ofs;
}
@@ -416,6 +434,9 @@ void CGA_PrintChar(unsigned char c, unsigned char *target) {
if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
+
+ if (target == CGA_SCREENBUFFER)
+ CGA_blitToScreen((char_draw_coords_x - 1) * 4, char_draw_coords_y, 4, CGA_FONT_HEIGHT);
}
@@ -427,6 +448,7 @@ 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;
while (h--) {
for (x = 0; x < w; x++)
screen[ofs + x] = (backbuffer[ofs + x] & pixels[x * 2]) | pixels[x * 2 + 1];
@@ -435,6 +457,9 @@ void CGA_BlitScratchBackSprite(unsigned int sprofs, unsigned int w, unsigned int
if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
+
+ if (screen == CGA_SCREENBUFFER)
+ CGA_blitToScreen(ofs, w, oh);
}
void CGA_BlitFromBackBuffer(unsigned char w, unsigned char h, unsigned char *screen, unsigned int ofs) {
@@ -447,6 +472,7 @@ 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;
while (h--) {
for (x = 0; x < w; x++)
screen[ofs + x] = (screen[ofs + x] & pixels[x * 2]) | pixels[x * 2 + 1];
@@ -455,6 +481,9 @@ void CGA_BlitSprite(unsigned char *pixels, signed int pw, unsigned int w, unsign
if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
+
+ if (screen == CGA_SCREENBUFFER)
+ CGA_blitToScreen(ofs, w, oh);
}
/*
@@ -463,6 +492,7 @@ 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;
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]];
@@ -471,6 +501,9 @@ void CGA_BlitSpriteFlip(unsigned char *pixels, signed int pw, unsigned int w, un
if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
+
+ if (screen == CGA_SCREENBUFFER)
+ CGA_blitToScreen(ofs, w, oh);
}
/*
@@ -483,6 +516,7 @@ 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;
while (h--) {
for (x = 0; x < w; x++) {
*backup++ = screen[ofs + x];
@@ -493,6 +527,9 @@ void CGA_BlitSpriteBak(unsigned char *pixels, signed int pw, unsigned int w, uns
if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
+
+ if (screen == CGA_SCREENBUFFER)
+ CGA_blitToScreen(ofs, w, oh);
}
Commit: 9116da279d480d0114ef39c4541c45ae781ffae8
https://github.com/scummvm/scummvm/commit/9116da279d480d0114ef39c4541c45ae781ffae8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix CGA blitting
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 22f6e743a70..90c22efbced 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -113,19 +113,14 @@ void CGA_blitToScreen(int dx, int dy, int w, int h) {
if (dx + w >= 320)
w = 320 - dx;
- byte *src = CGA_SCREENBUFFER;
-
w = (w + 3) / 4;
for (int y = 0; y < h; y++) {
+ byte *src = CGA_SCREENBUFFER + CGA_CalcXY(dx, dy + y);
byte *dst = scrbuffer + (y + dy) * 320 + dx;
- byte *src1 = src;
-
- if ((y + dy) & 1)
- src1 += 0x2000;
for (int x = 0; x < w; x++) {
- byte colors = *src1++;
+ byte colors = *src++;
for (int c = 0; c < 4; c++) {
byte color = (colors & 0xC0) >> 6;
@@ -134,12 +129,9 @@ void CGA_blitToScreen(int dx, int dy, int w, int h) {
*dst++ = color;
}
}
-
- if ((y + dy) & 1)
- src += 320 / 4;
}
- g_system->copyRectToScreen(scrbuffer, 320, dx, dy, w * 4, h);
+ g_system->copyRectToScreen(scrbuffer + dy * 320 + dx, 320, dx, dy, w * 4, h);
g_system->updateScreen();
}
Commit: 3fd9adf2111f02d2f5190fafd5a8c377f5e71bee
https://github.com/scummvm/scummvm/commit/3fd9adf2111f02d2f5190fafd5a8c377f5e71bee
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Blit screen for sliding animations
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 90c22efbced..4c014db0b12 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -177,6 +177,8 @@ void CGA_SwapRealBackBuffer(void) {
*s++ = *d;
*d++ = t;
}
+
+ CGA_blitToScreen(0, 0, 320, 200);
}
@@ -185,6 +187,7 @@ 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;
while (h--) {
unsigned int i;
for (i = 0; i < w; i++) {
@@ -195,6 +198,9 @@ void CGA_SwapScreenRect(unsigned char *pixels, unsigned int w, unsigned int h, u
if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
+
+ if (screen == CGA_SCREENBUFFER)
+ CGA_blitToScreen(ofs, w * 4, oh);
}
/*
@@ -765,6 +771,10 @@ void CGA_HideScreenBlockLiftToDown(unsigned int n, unsigned char *screen, unsign
/*fill just freed line with new pixels*/
memcpy(target + tofs, source + tofs, w);
+
+ if (screen == CGA_SCREENBUFFER)
+ CGA_blitToScreen(0, 0, 320, 200);
+
WaitVBlank();
ofs ^= CGA_ODD_LINES_OFS;
@@ -805,6 +815,10 @@ void CGA_HideScreenBlockLiftToUp(unsigned int n, unsigned char *screen, unsigned
/*fill just freed line with new pixels*/
memcpy(target + tofs, source + tofs, w);
+
+ if (screen == CGA_SCREENBUFFER)
+ CGA_blitToScreen(0, 0, 320, 200);
+
WaitVBlank();
ofs ^= CGA_ODD_LINES_OFS;
@@ -840,6 +854,9 @@ void CGA_HideScreenBlockLiftToLeft(unsigned int n, unsigned char *screen, unsign
sofs += CGA_BYTES_PER_LINE;
}
+ if (screen == CGA_SCREENBUFFER)
+ CGA_blitToScreen(0, 0, 320, 200);
+
WaitVBlank();
ofs--;
@@ -873,6 +890,9 @@ void CGA_HideScreenBlockLiftToRight(unsigned int n, unsigned char *screen, unsig
sofs += CGA_BYTES_PER_LINE;
}
+ if (screen == CGA_SCREENBUFFER)
+ CGA_blitToScreen(0, 0, 320, 200);
+
WaitVBlank();
ofs++;
@@ -1008,6 +1028,10 @@ static void FallPieces(scrpiece_t *pieces, unsigned char *source, unsigned char
}
again = 1;
}
+
+ if (target == CGA_SCREENBUFFER)
+ CGA_blitToScreen(0, 0, 320, 200);
+
WaitVBlank();
t++;
} while (again);
@@ -1085,6 +1109,9 @@ void CGA_TraceLine(unsigned int sx, unsigned int ex, unsigned int sy, unsigned i
}
target[ofs] = (target[ofs] & ~mask) | (source[ofs] & mask);
}
+
+ if (target == CGA_SCREENBUFFER)
+ CGA_blitToScreen(0, 0, 320, 200);
}
} // End of namespace Chamber
Commit: f2ace8ad30b70e9fc57153e6e01df6099e77c90e
https://github.com/scummvm/scummvm/commit/f2ace8ad30b70e9fc57153e6e01df6099e77c90e
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fixed blitting width and added delay to the animations
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 4c014db0b12..2859ca69375 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -101,6 +101,8 @@ void CGA_ColorSelect(unsigned char csel) {
}
void CGA_blitToScreen(int dx, int dy, int w, int h) {
+ dx = dy = 0;
+ w = 320; h = 200;
// Align x by 4
int align = dx & 0x3;
@@ -155,12 +157,17 @@ 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;
while (h--) {
memcpy(target + ofs, source + ofs, w);
ofs ^= CGA_ODD_LINES_OFS;
if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
}
+
+ if (target == CGA_SCREENBUFFER)
+ CGA_blitToScreen(oofs, w * 4, oh);
}
/*
@@ -188,6 +195,7 @@ 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;
while (h--) {
unsigned int i;
for (i = 0; i < w; i++) {
@@ -200,7 +208,7 @@ void CGA_SwapScreenRect(unsigned char *pixels, unsigned int w, unsigned int h, u
}
if (screen == CGA_SCREENBUFFER)
- CGA_blitToScreen(ofs, w * 4, oh);
+ CGA_blitToScreen(oofs, w * 4, oh);
}
/*
@@ -247,10 +255,7 @@ unsigned char *CGA_BackupImage(unsigned char *screen, unsigned int ofs, unsigned
}
unsigned char *CGA_BackupImageReal(unsigned int ofs, unsigned int w, unsigned int h) {
- warning("STUB: CGA_BackupImageReal()");
-
- return NULL;
- //return CGA_BackupImage(MK_FP(CGA_BASE_SEG, 0), ofs, w, h, scratch_mem2);
+ return CGA_BackupImage(CGA_SCREENBUFFER, ofs, w, h, scratch_mem2);
}
/*
@@ -259,17 +264,17 @@ 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) {
byte *src = pixels;
- uint ofs1 = ofs;
+ uint oofs = ofs;
for (int y = 0; y < h; y++) {
- memcpy(screen + ofs1, src, w);
+ memcpy(screen + ofs, src, w);
src += pw;
- ofs1 ^= CGA_ODD_LINES_OFS;
- if ((ofs1 & CGA_ODD_LINES_OFS) == 0)
- ofs1 += CGA_BYTES_PER_LINE;
+ ofs ^= CGA_ODD_LINES_OFS;
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
}
if (screen == CGA_SCREENBUFFER)
- CGA_blitToScreen(ofs, w * 4, h);
+ CGA_blitToScreen(oofs, w * 4, h);
}
/*
@@ -282,16 +287,16 @@ void CGA_BlitAndWait(unsigned char *pixels, unsigned int pw, unsigned int w, uns
}
void CGA_Fill(unsigned char pixel, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) {
- uint ofs1 = ofs;
+ uint oofs = ofs;
for (int y = 0; y < h; y++) {
- memset(screen + ofs1, pixel, w);
- ofs1 ^= CGA_ODD_LINES_OFS;
- if ((ofs1 & CGA_ODD_LINES_OFS) == 0)
- ofs1 += CGA_BYTES_PER_LINE;
+ memset(screen + ofs, pixel, w);
+ ofs ^= CGA_ODD_LINES_OFS;
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
}
if (screen == CGA_SCREENBUFFER)
- CGA_blitToScreen(ofs, w * 4, h);
+ CGA_blitToScreen(oofs, w * 4, h);
}
void CGA_FillAndWait(unsigned char pixel, unsigned int w, unsigned int h, unsigned char *screen, unsigned int ofs) {
@@ -357,7 +362,6 @@ void CGA_DrawVLine(unsigned int x, unsigned int y, unsigned int l, unsigned char
ofs = CGA_CalcXY_p(x / CGA_PIXELS_PER_BYTE, y);
uint ol = l;
-
while (l--) {
target[ofs] = (target[ofs] & mask) | pixel;
ofs ^= CGA_ODD_LINES_OFS;
@@ -395,7 +399,7 @@ void CGA_DrawHLine(unsigned int x, unsigned int y, unsigned int l, unsigned char
}
}
if (target == CGA_SCREENBUFFER)
- CGA_blitToScreen(x, y, ol, 1);
+ CGA_blitToScreen(x, y, ol * 4, 1);
}
/*
@@ -407,12 +411,13 @@ unsigned int CGA_DrawHLineWithEnds(unsigned int bmask, unsigned int bpix, unsign
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;
ofs ^= CGA_ODD_LINES_OFS;
if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
if (target == CGA_SCREENBUFFER)
- CGA_blitToScreen(ofs, l, 1);
+ CGA_blitToScreen(oofs, l * 4, 1);
return ofs;
}
@@ -447,6 +452,7 @@ void CGA_BlitScratchBackSprite(unsigned int sprofs, unsigned int w, unsigned int
unsigned char x;
unsigned char *pixels = scratch_mem2 + 2 + sprofs;
uint oh = h;
+ uint oofs = ofs;
while (h--) {
for (x = 0; x < w; x++)
screen[ofs + x] = (backbuffer[ofs + x] & pixels[x * 2]) | pixels[x * 2 + 1];
@@ -457,7 +463,7 @@ void CGA_BlitScratchBackSprite(unsigned int sprofs, unsigned int w, unsigned int
}
if (screen == CGA_SCREENBUFFER)
- CGA_blitToScreen(ofs, w, oh);
+ CGA_blitToScreen(oofs, w * 4, oh);
}
void CGA_BlitFromBackBuffer(unsigned char w, unsigned char h, unsigned char *screen, unsigned int ofs) {
@@ -471,6 +477,7 @@ 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;
while (h--) {
for (x = 0; x < w; x++)
screen[ofs + x] = (screen[ofs + x] & pixels[x * 2]) | pixels[x * 2 + 1];
@@ -481,7 +488,7 @@ void CGA_BlitSprite(unsigned char *pixels, signed int pw, unsigned int w, unsign
}
if (screen == CGA_SCREENBUFFER)
- CGA_blitToScreen(ofs, w, oh);
+ CGA_blitToScreen(oofs, w * 4, oh);
}
/*
@@ -491,6 +498,7 @@ 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;
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]];
@@ -501,7 +509,7 @@ void CGA_BlitSpriteFlip(unsigned char *pixels, signed int pw, unsigned int w, un
}
if (screen == CGA_SCREENBUFFER)
- CGA_blitToScreen(ofs, w, oh);
+ CGA_blitToScreen(oofs, w * 4, oh);
}
/*
@@ -515,6 +523,7 @@ 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;
while (h--) {
for (x = 0; x < w; x++) {
*backup++ = screen[ofs + x];
@@ -527,7 +536,7 @@ void CGA_BlitSpriteBak(unsigned char *pixels, signed int pw, unsigned int w, uns
}
if (screen == CGA_SCREENBUFFER)
- CGA_blitToScreen(ofs, w, oh);
+ CGA_blitToScreen(oofs, w * 4, oh);
}
@@ -772,8 +781,10 @@ void CGA_HideScreenBlockLiftToDown(unsigned int n, unsigned char *screen, unsign
/*fill just freed line with new pixels*/
memcpy(target + tofs, source + tofs, w);
- if (screen == CGA_SCREENBUFFER)
+ if (screen == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
+ g_system->delayMillis(10);
+ }
WaitVBlank();
@@ -816,8 +827,10 @@ void CGA_HideScreenBlockLiftToUp(unsigned int n, unsigned char *screen, unsigned
/*fill just freed line with new pixels*/
memcpy(target + tofs, source + tofs, w);
- if (screen == CGA_SCREENBUFFER)
+ if (screen == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
+ g_system->delayMillis(10);
+ }
WaitVBlank();
@@ -854,8 +867,10 @@ void CGA_HideScreenBlockLiftToLeft(unsigned int n, unsigned char *screen, unsign
sofs += CGA_BYTES_PER_LINE;
}
- if (screen == CGA_SCREENBUFFER)
+ if (screen == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
+ g_system->delayMillis(10);
+ }
WaitVBlank();
@@ -890,8 +905,10 @@ void CGA_HideScreenBlockLiftToRight(unsigned int n, unsigned char *screen, unsig
sofs += CGA_BYTES_PER_LINE;
}
- if (screen == CGA_SCREENBUFFER)
+ if (screen == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
+ g_system->delayMillis(10);
+ }
WaitVBlank();
@@ -1029,8 +1046,10 @@ static void FallPieces(scrpiece_t *pieces, unsigned char *source, unsigned char
again = 1;
}
- if (target == CGA_SCREENBUFFER)
+ if (target == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
+ g_system->delayMillis(10);
+ }
WaitVBlank();
t++;
Commit: fe1deb5a8cee2ef5a64aab4ecdc866d7eedd49fc
https://github.com/scummvm/scummvm/commit/fe1deb5a8cee2ef5a64aab4ecdc866d7eedd49fc
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Furhter fixes to line blitting
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 2859ca69375..d84a1ced0a7 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -399,7 +399,7 @@ void CGA_DrawHLine(unsigned int x, unsigned int y, unsigned int l, unsigned char
}
}
if (target == CGA_SCREENBUFFER)
- CGA_blitToScreen(x, y, ol * 4, 1);
+ CGA_blitToScreen(x, y, ol, 1);
}
/*
@@ -411,7 +411,7 @@ unsigned int CGA_DrawHLineWithEnds(unsigned int bmask, unsigned int bpix, unsign
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;
+ uint oofs = ofs + 1;
ofs ^= CGA_ODD_LINES_OFS;
if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
Commit: f50556d1bf3dd65907b0df10666c33c103fdff1f
https://github.com/scummvm/scummvm/commit/f50556d1bf3dd65907b0df10666c33c103fdff1f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix dialog box rendering
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index d84a1ced0a7..65032805ed4 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -380,7 +380,7 @@ 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;
/*pixels are starting from top bits of byte*/
- unsigned int mask = ~(3 << ((CGA_PIXELS_PER_BYTE - 1) * CGA_BITS_PER_PIXEL));
+ 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);
mask >>= (x % CGA_PIXELS_PER_BYTE) * CGA_BITS_PER_PIXEL;
Commit: 79078695aa2f0c8b904181b3ecdfad9975ff893a
https://github.com/scummvm/scummvm/commit/79078695aa2f0c8b904181b3ecdfad9975ff893a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Replace data types with portable ones
Changed paths:
engines/chamber/anim.cpp
engines/chamber/anim.h
engines/chamber/bkbuff.cpp
engines/chamber/cga.cpp
engines/chamber/cga.h
engines/chamber/chamber.cpp
engines/chamber/common.h
engines/chamber/cursor.cpp
engines/chamber/cursor.h
engines/chamber/decompr.cpp
engines/chamber/decompr.h
engines/chamber/dialog.cpp
engines/chamber/dialog.h
engines/chamber/input.cpp
engines/chamber/input.h
engines/chamber/invent.cpp
engines/chamber/invent.h
engines/chamber/kult.cpp
engines/chamber/menu.cpp
engines/chamber/menu.h
engines/chamber/portrait.cpp
engines/chamber/portrait.h
engines/chamber/print.cpp
engines/chamber/print.h
engines/chamber/r_other.cpp
engines/chamber/r_pers.cpp
engines/chamber/r_puzzl.cpp
engines/chamber/r_sprit.cpp
engines/chamber/r_templ.cpp
engines/chamber/r_texts.cpp
engines/chamber/resdata.cpp
engines/chamber/resdata.h
engines/chamber/room.cpp
engines/chamber/room.h
engines/chamber/savegame.cpp
engines/chamber/savegame.h
engines/chamber/script.cpp
engines/chamber/script.h
engines/chamber/sound.cpp
engines/chamber/sound.h
engines/chamber/timer.cpp
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;
-
-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;
-
-extern unsigned short cpu_speed_delay;
-
-extern unsigned char *SeekToEntry(unsigned char *bank, unsigned int num, unsigned char **end);
-extern void LoadLutinSprite(unsigned int lutidx);
-
-void GetScratchBuffer(unsigned char mode) {
- unsigned char *buffer = scratch_mem2;
- unsigned int offs = 0;
+byte *anima_end_ofs;
+
+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 uint16 cpu_speed_delay;
+
+extern byte *SeekToEntry(byte *bank, uint16 num, byte **end);
+extern void LoadLutinSprite(uint16 lutidx);
+
+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;
-
-void SelectCursor(unsigned int num);
+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(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;
-
-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;
+extern uint16 cpu_speed_delay;
+
+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;
-
-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);
+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;
+
+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 unsigned char puzzl_data[];
-extern unsigned char sprit_data[];
-
-extern unsigned char pers1_data[];
-extern unsigned char pers2_data[];
-
-extern unsigned char desci_data[];
-extern unsigned char 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[];
-
-unsigned char *SeekToEntry(unsigned char *bank, unsigned int num, unsigned char **end);
-unsigned char *SeekToEntryW(unsigned char *bank, unsigned int num, unsigned char **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);
-
-int LoadStaticData(void);
-int LoadFond(void);
-int LoadSpritesData(void);
-int LoadPersData(void);
+extern byte vepci_data[];
+extern byte motsi_data[];
+
+extern byte puzzl_data[];
+extern byte sprit_data[];
+
+extern byte pers1_data[];
+extern byte pers2_data[];
+
+extern byte desci_data[];
+extern byte diali_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[];
+
+byte *SeekToEntry(byte *bank, uint16 num, byte **end);
+byte *SeekToEntryW(byte *bank, uint16 num, byte **end);
+
+uint16 LoadFile(const char *filename, byte *buffer);
+uint16 SaveFile(char *filename, byte *buffer, uint16 size);
+int16 LoadFilesList(ResEntry_t *entries);
+
+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;
-
-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;
-
-unsigned char *sprites_list[MAX_SPRITES];
+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;
+
+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;
+
+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;
Commit: b8d6281568b712319573757fd8697667e4d1a2b5
https://github.com/scummvm/scummvm/commit/b8d6281568b712319573757fd8697667e4d1a2b5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix timer frequency
Changed paths:
engines/chamber/timer.cpp
diff --git a/engines/chamber/timer.cpp b/engines/chamber/timer.cpp
index b2900a910a6..c1e778e8e2b 100644
--- a/engines/chamber/timer.cpp
+++ b/engines/chamber/timer.cpp
@@ -45,15 +45,17 @@ void AnimateGauss(byte *target) {
void timerCallback(void *refCon) {
script_byte_vars.timer_ticks++;
if (!script_byte_vars.game_paused) {
- script_word_vars.timer_ticks2 = Swap16(Swap16(script_word_vars.timer_ticks2) + 1);
+ if (script_byte_vars.timer_ticks % 16 == 0) {
+ script_word_vars.timer_ticks2 = Swap16(Swap16(script_word_vars.timer_ticks2) + 1);
#if 1
- AnimateGauss(frontbuffer);
+ AnimateGauss(frontbuffer);
#endif
+ }
}
}
void InitTimer(void) {
- g_system->getTimerManager()->installTimerProc(&timerCallback, 1000000, NULL, "mainTimer");
+ g_system->getTimerManager()->installTimerProc(&timerCallback, 1000000 / 16, NULL, "mainTimer");
}
void UninitTimer(void) {
Commit: 8c74647f1f3d891edb0245982cd692dfb82c0b34
https://github.com/scummvm/scummvm/commit/8c74647f1f3d891edb0245982cd692dfb82c0b34
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix animation delay
Changed paths:
engines/chamber/anim.cpp
diff --git a/engines/chamber/anim.cpp b/engines/chamber/anim.cpp
index 7d07027fe97..f9edc3cb2bf 100644
--- a/engines/chamber/anim.cpp
+++ b/engines/chamber/anim.cpp
@@ -20,6 +20,8 @@
*
*/
+#include "common/system.h"
+
#include "chamber/chamber.h"
#include "chamber/common.h"
@@ -155,7 +157,7 @@ void AnimDrawSprite(byte x, byte y, byte sprw, byte sprh, byte *pixels, uint16 p
ofs = CGA_CalcXY_p(updx, updy);
/*TODO looks like here was some code before*/
for (delay = 0; delay < anim_draw_delay; delay++) {
- for (delay2 = 0; delay2 < cpu_speed_delay; delay2++) ; /*TODO FIXME weak delay*/
+ g_system->delayMillis(1000 / 16 / 25);
}
WaitVBlank();
Commit: 880657ed1433c0c33993b2e62a44aae35fea1382
https://github.com/scummvm/scummvm/commit/880657ed1433c0c33993b2e62a44aae35fea1382
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Code cleanup
Changed paths:
engines/chamber/anim.cpp
engines/chamber/cga.cpp
diff --git a/engines/chamber/anim.cpp b/engines/chamber/anim.cpp
index f9edc3cb2bf..d7293626ff6 100644
--- a/engines/chamber/anim.cpp
+++ b/engines/chamber/anim.cpp
@@ -132,7 +132,7 @@ void CopyScreenBlockWithDotEffect(byte *source, byte x, byte y, byte width, byte
}
void AnimDrawSprite(byte x, byte y, byte sprw, byte sprh, byte *pixels, uint16 pitch) {
- uint16 delay, delay2;
+ uint16 delay;
byte ex, ey, updx, updy, updw, updh;
uint16 ofs = CGA_CalcXY_p(x, y);
CGA_BackupImage(backbuffer, ofs, sprw, sprh, sprit_load_buffer);
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index e5de7c8ca00..66b7f3e87a8 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -30,6 +30,8 @@
namespace Chamber {
+#define ANIM_DELAY 10
+
extern byte backbuffer[0x4000];
byte CGA_SCREENBUFFER[0x4000];
byte scrbuffer[320*200];
@@ -783,7 +785,7 @@ void CGA_HideScreenBlockLiftToDown(uint16 n, byte *screen, byte *source, uint16
if (screen == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
- g_system->delayMillis(10);
+ g_system->delayMillis(ANIM_DELAY);
}
WaitVBlank();
@@ -829,7 +831,7 @@ void CGA_HideScreenBlockLiftToUp(uint16 n, byte *screen, byte *source, uint16 w,
if (screen == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
- g_system->delayMillis(10);
+ g_system->delayMillis(ANIM_DELAY);
}
WaitVBlank();
@@ -869,7 +871,7 @@ void CGA_HideScreenBlockLiftToLeft(uint16 n, byte *screen, byte *source, uint16
if (screen == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
- g_system->delayMillis(10);
+ g_system->delayMillis(ANIM_DELAY);
}
WaitVBlank();
@@ -907,7 +909,7 @@ void CGA_HideScreenBlockLiftToRight(uint16 n, byte *screen, byte *source, uint16
if (screen == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
- g_system->delayMillis(10);
+ g_system->delayMillis(ANIM_DELAY);
}
WaitVBlank();
@@ -1048,7 +1050,7 @@ static void FallPieces(scrpiece_t *pieces, byte *source, byte *target) {
if (target == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
- g_system->delayMillis(10);
+ g_system->delayMillis(ANIM_DELAY);
}
WaitVBlank();
Commit: f4d187134583c4a33a40ec5ff836c78730cf5d25
https://github.com/scummvm/scummvm/commit/f4d187134583c4a33a40ec5ff836c78730cf5d25
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Use centralized delay and system yield
Changed paths:
engines/chamber/cga.cpp
engines/chamber/kult.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 66b7f3e87a8..90be29a19b3 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -30,8 +30,6 @@
namespace Chamber {
-#define ANIM_DELAY 10
-
extern byte backbuffer[0x4000];
byte CGA_SCREENBUFFER[0x4000];
byte scrbuffer[320*200];
@@ -95,6 +93,7 @@ void SwitchToTextMode(void) {
}
void WaitVBlank(void) {
+ g_system->delayMillis(10);
}
void CGA_ColorSelect(byte csel) {
@@ -785,7 +784,6 @@ void CGA_HideScreenBlockLiftToDown(uint16 n, byte *screen, byte *source, uint16
if (screen == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
- g_system->delayMillis(ANIM_DELAY);
}
WaitVBlank();
@@ -831,7 +829,6 @@ void CGA_HideScreenBlockLiftToUp(uint16 n, byte *screen, byte *source, uint16 w,
if (screen == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
- g_system->delayMillis(ANIM_DELAY);
}
WaitVBlank();
@@ -871,7 +868,6 @@ void CGA_HideScreenBlockLiftToLeft(uint16 n, byte *screen, byte *source, uint16
if (screen == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
- g_system->delayMillis(ANIM_DELAY);
}
WaitVBlank();
@@ -909,7 +905,6 @@ void CGA_HideScreenBlockLiftToRight(uint16 n, byte *screen, byte *source, uint16
if (screen == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
- g_system->delayMillis(ANIM_DELAY);
}
WaitVBlank();
@@ -1050,7 +1045,6 @@ static void FallPieces(scrpiece_t *pieces, byte *source, byte *target) {
if (target == CGA_SCREENBUFFER) {
CGA_blitToScreen(0, 0, 320, 200);
- g_system->delayMillis(ANIM_DELAY);
}
WaitVBlank();
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 62af40d5eaa..5a9c1256fb2 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -158,9 +158,6 @@ void GameLoop(byte *target) {
goto process;
}
- g_system->updateScreen();
- g_system->delayMillis(10);
-
continue;
process:
@@ -186,8 +183,6 @@ process:
ProcessInput();
DrawSpots(target);
}
- g_system->updateScreen();
- g_system->delayMillis(10);
}
}
Commit: e553feba369c3cefe5c8d6ebdc3592537d9b7030
https://github.com/scummvm/scummvm/commit/e553feba369c3cefe5c8d6ebdc3592537d9b7030
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix portrait dot effect
Changed paths:
engines/chamber/cga.h
engines/chamber/script.cpp
diff --git a/engines/chamber/cga.h b/engines/chamber/cga.h
index 051ed836bdf..c04eab789d5 100644
--- a/engines/chamber/cga.h
+++ b/engines/chamber/cga.h
@@ -58,6 +58,8 @@ void SwitchToGraphicsMode(void);
void SwitchToTextMode(void);
void WaitVBlank(void);
+void CGA_blitToScreen(int16 dx, int16 dy, int16 w, int16 h);
+void CGA_blitToScreen(int16 ofs, int16 w, int16 h);
void CGA_ColorSelect(byte csel);
void CGA_BackBufferToRealFull(void);
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 8c007e9f5e0..1c02268021b 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -780,13 +780,19 @@ uint16 SCR_D_DrawPortraitDotEffect(void) {
return 0;
cur_image_end = width * height;
+ int16 count = 0;
for (offs = 0; offs != cur_image_end;) {
target[CGA_CalcXY_p(x + offs % cur_image_size_w, y + offs / cur_image_size_w)] = cur_image_pixels[offs];
- for (i = 0; i < 255; i++) ; /*TODO FIXME weak delay*/
+
+ if (count % 5 == 0)
+ CGA_blitToScreen(offs, 4, 1);
+
offs += step;
if (offs > cur_image_end)
offs -= cur_image_end;
+
+ count++;
}
return 0;
}
Commit: 96e97297769b839aedf307ab21f323035bfe87e1
https://github.com/scummvm/scummvm/commit/96e97297769b839aedf307ab21f323035bfe87e1
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Blit to screen in all places where CGA framebuffer is modified
Changed paths:
engines/chamber/room.cpp
engines/chamber/script.cpp
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index e369c2c38db..9a8059cd759 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -1371,14 +1371,17 @@ void TheWallOpenRightDoor(byte x, byte y, byte width, byte height, byte limit) {
/*hide remaining column*/
/*TODO: move this to CGA?*/
+ uint16 ooffs = offs;
+ byte oh = height;
while (height--) {
- warning("STUB: TheWallOpenRightDoor()");
- //memcpy(frontbuffer + offs, backbuffer + offs, 1);
+ memcpy(frontbuffer + offs, backbuffer + offs, 1);
offs ^= CGA_ODD_LINES_OFS;
if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
}
+
+ CGA_blitToScreen(ooffs, 1, oh);
}
void TheWallOpenLeftDoor(byte x, byte y, byte width, byte height, byte limit) {
@@ -1394,14 +1397,16 @@ void TheWallOpenLeftDoor(byte x, byte y, byte width, byte height, byte limit) {
/*hide remaining column*/
/*TODO: move this to CGA?*/
+ uint16 ooffs = offs;
+ byte oh = height;
while (height--) {
- warning("STUB: TheWallOpenLeftDoor()");
- //memcpy(frontbuffer + offs, backbuffer + offs, 1);
+ memcpy(frontbuffer + offs, backbuffer + offs, 1);
offs ^= CGA_ODD_LINES_OFS;
if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
}
+ CGA_blitToScreen(ooffs, 1, oh);
}
/*
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 1c02268021b..05493a68e1a 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -844,6 +844,8 @@ uint16 SCR_19_HidePortraitLiftLeft(void) {
/*hide leftmost line*/
/*TODO: move this to CGA?*/
+ uint16 ooffs = offs;
+ byte oh = height;
while (height--) {
memcpy(frontbuffer + offs, backbuffer + offs, 1);
@@ -851,6 +853,7 @@ uint16 SCR_19_HidePortraitLiftLeft(void) {
if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
}
+ CGA_blitToScreen(ooffs, 1, oh);
return 0;
}
@@ -884,6 +887,8 @@ uint16 SCR_1A_HidePortraitLiftRight(void) {
/*hide leftmost line*/
/*TODO: move this to CGA?*/
+ uint16 ooffs = offs;
+ byte oh = height;
while (height--) {
memcpy(frontbuffer + offs, backbuffer + offs, 1);
@@ -891,6 +896,7 @@ uint16 SCR_1A_HidePortraitLiftRight(void) {
if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
}
+ CGA_blitToScreen(ooffs, 1, oh);
return 0;
}
@@ -924,6 +930,7 @@ uint16 SCR_1B_HidePortraitLiftUp(void) {
if ((offs & CGA_ODD_LINES_OFS) != 0)
offs -= CGA_BYTES_PER_LINE;
memcpy(CGA_SCREENBUFFER + offs, backbuffer + offs, width);
+ CGA_blitToScreen(offs, width, 1);
return 0;
}
@@ -957,6 +964,7 @@ uint16 SCR_1C_HidePortraitLiftDown(void) {
if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
memcpy(CGA_SCREENBUFFER + offs, backbuffer + offs, width);
+ CGA_blitToScreen(offs, width, 1);
return 0;
}
@@ -2833,8 +2841,10 @@ uint16 CMD_E_PsiZoneScan(void) {
for (y = room_bounds_rect.sy; h; y++, h--) {
spot_t *spot;
for (x = 0; x < w; x++) frontbuffer[offs + x] = ~frontbuffer[offs + x];
+ CGA_blitToScreen(offs, w, 1);
WaitVBlank();
for (x = 0; x < w; x++) frontbuffer[offs + x] = ~frontbuffer[offs + x];
+ CGA_blitToScreen(offs, w, 1);
for (spot = zone_spots; spot != zone_spots_end; spot++) {
if ((spot->flags & ~(SPOTFLG_40 | 7)) == (SPOTFLG_20 | SPOTFLG_8) && spot->sy == y) {
Commit: 0d05266afb26ecfbf877de97eb423a9eb79ecdea
https://github.com/scummvm/scummvm/commit/0d05266afb26ecfbf877de97eb423a9eb79ecdea
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Implement CGA_ColorSelect()
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 90be29a19b3..9f8bd101550 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -72,10 +72,17 @@ byte cga_pixel_flip[256] = {
};
static const uint8 PALETTE_CGA[4 * 3] = {
- 0x00, 0x00, 0x00, // black
- 0x55, 0xff, 0xff, // cyan
- 0xff, 0x55, 0xff, // magenta
- 0xff, 0xff, 0xff
+ 0x00, 0x00, 0x00, // black
+ 0x55, 0xff, 0xff, // cyan
+ 0xff, 0x55, 0xff, // magenta
+ 0xff, 0xff, 0xff
+};
+
+static const uint8 PALETTE_CGA2[4 * 3] = {
+ 0x00, 0x00, 0x00, // black
+ 0x55, 0xff, 0x55, // green
+ 0xff, 0x55, 0x55, // red
+ 0xff, 0xff, 0x55 // yellow
};
/*
@@ -97,8 +104,10 @@ void WaitVBlank(void) {
}
void CGA_ColorSelect(byte csel) {
- warning("STUB: CGA_ColorSelect(%d)", csel);
- //outportb(0x3D9, csel);
+ if (csel & 0x20)
+ g_system->getPaletteManager()->setPalette(PALETTE_CGA, 0, 4);
+ else
+ g_system->getPaletteManager()->setPalette(PALETTE_CGA2, 0, 4);
}
void CGA_blitToScreen(int16 dx, int16 dy, int16 w, int16 h) {
Commit: e6d0644179e43549fe8ad63870b35b0fca40f575
https://github.com/scummvm/scummvm/commit/e6d0644179e43549fe8ad63870b35b0fca40f575
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Replace custom cursor code with the OSystem calls
Changed paths:
engines/chamber/cga.cpp
engines/chamber/cursor.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 9f8bd101550..6a0dd789d9f 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -104,10 +104,14 @@ void WaitVBlank(void) {
}
void CGA_ColorSelect(byte csel) {
+ const byte *pal;
if (csel & 0x20)
- g_system->getPaletteManager()->setPalette(PALETTE_CGA, 0, 4);
+ pal = PALETTE_CGA;
else
- g_system->getPaletteManager()->setPalette(PALETTE_CGA2, 0, 4);
+ pal = PALETTE_CGA2;
+
+ g_system->getPaletteManager()->setPalette(pal, 0, 4);
+ g_system->setCursorPalette(pal, 0, 4);
}
void CGA_blitToScreen(int16 dx, int16 dy, int16 w, int16 h) {
diff --git a/engines/chamber/cursor.cpp b/engines/chamber/cursor.cpp
index 7da000fa7ff..fd99920be6f 100644
--- a/engines/chamber/cursor.cpp
+++ b/engines/chamber/cursor.cpp
@@ -20,6 +20,8 @@
*
*/
+#include "common/system.h"
+
#include "chamber/chamber.h"
#include "chamber/common.h"
#include "chamber/cursor.h"
@@ -57,6 +59,7 @@ 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;
+byte cursorImage[CURSOR_WIDTH * CURSOR_HEIGHT];
/*
Select cursor shape and its hotspot
@@ -65,114 +68,50 @@ 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;
+
+ byte *src = cursor_shape;
+ byte *dst = cursorImage;
+ for (int16 y = 0; y < CURSOR_HEIGHT; y++) {
+ for (int16 x = 0; x < CURSOR_HEIGHT / 4; x++) {
+ byte colors = *src;
+ byte masks = *(src++ + CURSOR_HEIGHT * CURSOR_WIDTH / 4);
+
+ for (int16 c = 0; c < 4; c++) {
+ byte color = (colors & 0xC0) >> 6;
+ byte mask = (masks & 0xC0) >> 6;
+ colors <<= 2;
+ masks <<= 2;
+
+ if (!mask)
+ *dst++ = color;
+ else {
+ *dst++ = 255;
+ }
+ }
+ }
+ }
+
+ g_system->setMouseCursor(cursorImage, CURSOR_WIDTH, CURSOR_HEIGHT, cursor_x_shift, cursor_y_shift, 255);
+ g_system->showMouse(true);
}
/*
Build cursor sprite for its current pixel-grained position
*/
void UpdateCursor(void) {
- if (!cursor_shape)
- return;
-
- byte *cursor, *sprite, *spr;
- byte cursor_bit_shift;
- uint16 x, y;
- x = cursor_x - cursor_x_shift;
- if ((int16)x < 0) x = 0;
- y = cursor_y - cursor_y_shift;
- if ((int16)y < 0) y = 0;
-
- cursor_bit_shift = (x % 4) * 2;
- cursor_draw_ofs = CGA_CalcXY_p(x / 4, y);
-
- cursor = cursor_shape;
- sprite = sprit_load_buffer;
-
- if (cursor_bit_shift == 0) {
- /*pixels*/
- spr = sprite;
- for (y = 0; y < CURSOR_HEIGHT; y++) {
- for (x = 0; x < CURSOR_WIDTH / 4; x++) {
- byte p = *cursor++;
- spr[x * 2] = p;
- }
- spr[x * 2] = 0;
- spr += 5 * 2;
- }
-
- /*mask*/
- spr = sprite + 1;
- for (y = 0; y < CURSOR_HEIGHT; y++) {
- for (x = 0; x < CURSOR_WIDTH / 4; x++) {
- byte p = *cursor++;
- spr[x * 2] = p;
- }
- spr[x * 2] = 0xFF;
- spr += 5 * 2;
- }
- } else {
- spr = sprite;
- for (y = 0; y < CURSOR_HEIGHT; y++) {
- 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);
- p2 = (p2 >> 1) | (p1 << 7);
- p1 = (p1 >> 1) | (p0 << 7);
- p0 = (p0 >> 1) | (0 << 7);
- }
- spr[0] = p0;
- spr[2] = p1;
- spr[4] = p2;
- spr[6] = p3;
- spr[8] = p4;
-
- spr += 5 * 2;
- }
-
- spr = sprite + 1;
- for (y = 0; y < CURSOR_HEIGHT; y++) {
- 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);
- p2 = (p2 >> 1) | (p1 << 7);
- p1 = (p1 >> 1) | (p0 << 7);
- p0 = (p0 >> 1) | (1 << 7);
- }
- spr[0] = p0;
- spr[2] = p1;
- spr[4] = p2;
- spr[6] = p3;
- spr[8] = p4;
- spr += 5 * 2;
- }
- }
}
/*
Draw cursor sprite and backup background pixels
*/
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);
+ g_system->updateScreen();
}
/*
Restore background pixels under cursor
*/
void UndrawCursor(byte *target) {
- CGA_Blit(cursor_backup, CURSOR_WIDTH_SPR / 4, CURSOR_WIDTH_SPR / 4, CURSOR_HEIGHT, target, last_cursor_draw_ofs);
}
/*
Commit: 27dbf320fd1e2240c850bde40e7e23a945eeaef4
https://github.com/scummvm/scummvm/commit/27dbf320fd1e2240c850bde40e7e23a945eeaef4
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix input and make animations more responsive
Changed paths:
engines/chamber/cga.cpp
engines/chamber/input.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 6a0dd789d9f..6780d04a760 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -25,6 +25,7 @@
#include "chamber/chamber.h"
#include "chamber/common.h"
+#include "chamber/input.h"
#include "chamber/resdata.h"
#include "chamber/cga.h"
@@ -100,6 +101,7 @@ void SwitchToTextMode(void) {
}
void WaitVBlank(void) {
+ PollInput();
g_system->delayMillis(10);
}
diff --git a/engines/chamber/input.cpp b/engines/chamber/input.cpp
index 16b50ee3992..ba36d3882ab 100644
--- a/engines/chamber/input.cpp
+++ b/engines/chamber/input.cpp
@@ -73,11 +73,6 @@ void ClearKeyboard(void) {
}
void SetInputButtons(byte keys) {
- if (keys && buttons_repeat) {
- /*ignore buttons repeat*/
- buttons = 0;
- return;
- }
if (keys & 2)
right_button = ~0;
if (keys & 1)
Commit: 842b59541d9a81c0a250f8bd8b8afb13eeae9cba
https://github.com/scummvm/scummvm/commit/842b59541d9a81c0a250f8bd8b8afb13eeae9cba
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix out of bound access in ScreenToPieces()
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 6780d04a760..03ff9d54551 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -977,6 +977,9 @@ static void ScreenToPieces(byte width, byte height, byte *screen, uint16 offs, s
pieces->pix1 = screen[bofs];
pieces->pix3 = screen[bofs + CGA_BYTES_PER_LINE];
pieces++;
+
+ if (delays >= piecedelays + ARRAYSIZE(piecedelays))
+ delays = piecedelays;
}
offs += CGA_BYTES_PER_LINE * 2; /*4 lines down*/
}
Commit: 78b4a690e1dc7d1d12996e4ef66a5934aa1d661a
https://github.com/scummvm/scummvm/commit/78b4a690e1dc7d1d12996e4ef66a5934aa1d661a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix CGA palette setting
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 03ff9d54551..0d47b4df1e5 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -107,7 +107,7 @@ void WaitVBlank(void) {
void CGA_ColorSelect(byte csel) {
const byte *pal;
- if (csel & 0x20)
+ if (csel & 0x10)
pal = PALETTE_CGA;
else
pal = PALETTE_CGA2;
Commit: 1f23037dd184c7c20da64b8f0cb35a0fd274876f
https://github.com/scummvm/scummvm/commit/1f23037dd184c7c20da64b8f0cb35a0fd274876f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Implement PXI file parsing
Changed paths:
engines/chamber/resdata.cpp
diff --git a/engines/chamber/resdata.cpp b/engines/chamber/resdata.cpp
index c83b122e428..fcd8696f1df 100644
--- a/engines/chamber/resdata.cpp
+++ b/engines/chamber/resdata.cpp
@@ -134,6 +134,78 @@ Load resident data files. Original game has all these data files embedded in the
NB! Static data includes the font file, don't use any text print routines before it's loaded.
*/
int16 LoadStaticData() {
+ Common::File pxi;
+
+ pxi.open("ere.pxi");
+
+ uint numMods = pxi.readUint16BE();
+ uint modBase = 2 + numMods * 4;
+
+ uint32 *modOffs = new uint32[numMods];
+
+ for (int i = 0; i < numMods; i++)
+ modOffs[i] = modBase + pxi.readUint32BE();
+
+ for (int m = 0; m < numMods; m++) {
+ uint32 modOfs = modOffs[m];
+ pxi.seek(modOfs);
+
+ uint32 modPsize = pxi.readUint32BE();
+ uint32 modUsize = pxi.readUint32BE();
+
+ byte *modData = new byte[modPsize];
+
+ pxi.read(modData, modPsize);
+
+ warning("Module %d : at 0x%6X, psize = %6d, usize = %6d", m, modOfs, modPsize, modUsize);
+
+ byte *rawData = new byte[modUsize];
+ uint32 rawSize = decompress(modData, rawData);
+ warning("decoded to %d bytes", rawSize);
+
+ Common::DumpFile out;
+ out.open("zzdump");
+ out.write(rawData, rawSize);
+ out.close();
+
+ if (rawData[0] != 'M' || rawData[1] != 'Z')
+ error("Module decompressed, but is not an EXE file");
+
+ uint16 hdrparas = READ_LE_UINT16(rawData + 8);
+ uint32 off = hdrparas * 16;
+
+ warning("hdrparas: 0x%x, off: 0x%x", hdrparas, off);
+
+ const char *firstRes = "ARPLA.";
+ int32 resOffs = -1;
+
+ for (int i = off; i < rawSize; i++)
+ if (!strncmp((char *)rawData + i, firstRes, strlen(firstRes))) {
+ resOffs = i;
+ break;
+ }
+
+ if (resOffs == -1)
+ error("No internal resources table found");
+
+ warning("Found resources table at 0x%X", resOffs - off);
+
+ while (rawData[resOffs] != '$') {
+ Common::String resName((char *)rawData + resOffs);
+
+ resOffs += MAX(resName.size() + 1, 10U);
+
+ uint16 reso = READ_LE_UINT16(rawData + resOffs);
+ resOffs += 2;
+ uint16 ress = READ_LE_UINT16(rawData + resOffs);
+ resOffs += 2;
+
+ warning("%s : %X", resName.c_str(), ress * 16 + reso);
+ }
+
+ }
+
+
return LoadFilesList(res_static);
}
Commit: 00d0b741ae4bfd181b3db4ee1151bad19433f6ac
https://github.com/scummvm/scummvm/commit/00d0b741ae4bfd181b3db4ee1151bad19433f6ac
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Read resources directly from PXI and dynamically allocate memory
Changed paths:
R engines/chamber/r_other.cpp
R engines/chamber/r_templ.cpp
engines/chamber/cga.cpp
engines/chamber/chamber.cpp
engines/chamber/chamber.h
engines/chamber/module.mk
engines/chamber/resdata.cpp
engines/chamber/resdata.h
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 0d47b4df1e5..76a3c7eea57 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -35,8 +35,6 @@ extern byte backbuffer[0x4000];
byte CGA_SCREENBUFFER[0x4000];
byte scrbuffer[320*200];
-byte carpc_data[RES_CARPC_MAX];
-
extern byte *scratch_mem2;
byte char_draw_coords_x;
diff --git a/engines/chamber/chamber.cpp b/engines/chamber/chamber.cpp
index aad13c8504a..819e6cda64b 100644
--- a/engines/chamber/chamber.cpp
+++ b/engines/chamber/chamber.cpp
@@ -48,11 +48,13 @@ ChamberEngine::ChamberEngine(OSystem *syst)
_rnd = new Common::RandomSource("chamber");
_shouldQuit = false;
+ _pxiData = NULL;
}
ChamberEngine::~ChamberEngine() {
// Dispose your resources here
delete _rnd;
+ delete _pxiData;
}
bool ChamberEngine::hasFeature(EngineFeature f) const {
diff --git a/engines/chamber/chamber.h b/engines/chamber/chamber.h
index bf608b95263..5ee78dce4ae 100644
--- a/engines/chamber/chamber.h
+++ b/engines/chamber/chamber.h
@@ -55,6 +55,8 @@ public:
public:
bool _shouldQuit;
+
+ byte *_pxiData;
};
void init(void);
diff --git a/engines/chamber/module.mk b/engines/chamber/module.mk
index 70957f555d8..373146262a1 100644
--- a/engines/chamber/module.mk
+++ b/engines/chamber/module.mk
@@ -15,11 +15,9 @@ MODULE_OBJS := \
metaengine.o \
portrait.o \
print.o \
- r_other.o \
r_pers.o \
r_puzzl.o \
r_sprit.o \
- r_templ.o \
r_texts.o \
resdata.o \
room.o \
diff --git a/engines/chamber/r_other.cpp b/engines/chamber/r_other.cpp
deleted file mode 100644
index 5075707c663..00000000000
--- a/engines/chamber/r_other.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "chamber/chamber.h"
-#include "chamber/resdata.h"
-
-namespace Chamber {
-
-
-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_templ.cpp b/engines/chamber/r_templ.cpp
deleted file mode 100644
index fef91f635ac..00000000000
--- a/engines/chamber/r_templ.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "chamber/chamber.h"
-#include "chamber/resdata.h"
-
-namespace Chamber {
-
-byte templ_data[RES_TEMPL_MAX];
-
-} // End of namespace Chamber
diff --git a/engines/chamber/resdata.cpp b/engines/chamber/resdata.cpp
index fcd8696f1df..16b3b20fccc 100644
--- a/engines/chamber/resdata.cpp
+++ b/engines/chamber/resdata.cpp
@@ -100,32 +100,34 @@ int16 LoadFilesList(ResEntry_t *entries) {
}
-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},
- {"ALEAT.BIN", aleat_data},
- {"ICONE.BIN", icone_data},
- {"SOUCO.BIN", souco_data},
- {"CARPC.BIN", carpc_data},
- {"SOURI.BIN", souri_data},
- {"TEMPL.BIN", templ_data},
- {"MURSM.BIN", mursm_data},
- {"GAUSS.BIN", gauss_data},
- {"LUTIN.BIN", lutin_data},
- {"ANIMA.BIN", anima_data},
- {"ANICO.BIN", anico_data},
- {"ZONES.BIN", zones_data},
+byte *arpla_data = NULL;
+byte *aleat_data = NULL;
+byte *icone_data = NULL;
+byte *souco_data = NULL;
+byte *carpc_data = NULL;
+byte *souri_data = NULL;
+byte *templ_data = NULL;
+byte *mursm_data = NULL;
+byte *gauss_data = NULL;
+byte *lutin_data = NULL;
+byte *anima_data = NULL;
+byte *anico_data = NULL;
+byte *zones_data = NULL;
+
+ResEntry_tp res_static[] = {
+ {"ARPLA.BIN", &arpla_data},
+ {"ALEAT.BIN", &aleat_data},
+ {"ICONE.BIN", &icone_data},
+ {"SOUCO.BIN", &souco_data},
+ {"CARPC.BIN", &carpc_data},
+ {"SOURI.BIN", &souri_data},
+ {"TEMPL.BIN", &templ_data},
+ {"MURSM.BIN", &mursm_data},
+ {"GAUSS.BIN", &gauss_data},
+ {"LUTIN.BIN", &lutin_data},
+ {"ANIMA.BIN", &anima_data},
+ {"ANICO.BIN", &anico_data},
+ {"ZONES.BIN", &zones_data},
{"$", NULL}
};
@@ -146,67 +148,86 @@ int16 LoadStaticData() {
for (int i = 0; i < numMods; i++)
modOffs[i] = modBase + pxi.readUint32BE();
- for (int m = 0; m < numMods; m++) {
- uint32 modOfs = modOffs[m];
- pxi.seek(modOfs);
+ // So far, take only resource 0. Additional selection is required
+ uint32 modOfs = modOffs[0];
+ pxi.seek(modOfs);
- uint32 modPsize = pxi.readUint32BE();
- uint32 modUsize = pxi.readUint32BE();
+ uint32 modPsize = pxi.readUint32BE();
+ uint32 modUsize = pxi.readUint32BE();
- byte *modData = new byte[modPsize];
+ byte *modData = new byte[modPsize];
- pxi.read(modData, modPsize);
+ pxi.read(modData, modPsize);
- warning("Module %d : at 0x%6X, psize = %6d, usize = %6d", m, modOfs, modPsize, modUsize);
+ warning("Module %d : at 0x%6X, psize = %6d, usize = %6d", 0, modOfs, modPsize, modUsize);
- byte *rawData = new byte[modUsize];
- uint32 rawSize = decompress(modData, rawData);
- warning("decoded to %d bytes", rawSize);
+ byte *rawData = new byte[modUsize];
+ g_vm->_pxiData = rawData;
- Common::DumpFile out;
- out.open("zzdump");
- out.write(rawData, rawSize);
- out.close();
+ uint32 rawSize = decompress(modData, rawData);
+ warning("decoded to %d bytes", rawSize);
- if (rawData[0] != 'M' || rawData[1] != 'Z')
- error("Module decompressed, but is not an EXE file");
+ Common::DumpFile out;
+ out.open("zzdump");
+ out.write(rawData, rawSize);
+ out.close();
- uint16 hdrparas = READ_LE_UINT16(rawData + 8);
- uint32 off = hdrparas * 16;
+ if (rawData[0] != 'M' || rawData[1] != 'Z')
+ error("Module decompressed, but is not an EXE file");
- warning("hdrparas: 0x%x, off: 0x%x", hdrparas, off);
+ uint16 hdrparas = READ_LE_UINT16(rawData + 8);
+ uint32 off = hdrparas * 16;
- const char *firstRes = "ARPLA.";
- int32 resOffs = -1;
+ warning("hdrparas: 0x%x, off: 0x%x", hdrparas, off);
- for (int i = off; i < rawSize; i++)
- if (!strncmp((char *)rawData + i, firstRes, strlen(firstRes))) {
- resOffs = i;
- break;
- }
+ const char *firstRes = "ARPLA.";
+ int32 resOffs = -1;
+
+ for (int i = off; i < rawSize; i++)
+ if (!strncmp((char *)rawData + i, firstRes, strlen(firstRes))) {
+ resOffs = i;
+ break;
+ }
+
+ if (resOffs == -1)
+ error("No internal resources table found");
- if (resOffs == -1)
- error("No internal resources table found");
+ warning("Found resources table at 0x%X", resOffs - off);
- warning("Found resources table at 0x%X", resOffs - off);
+ while (rawData[resOffs] != '$') {
+ Common::String resName((char *)rawData + resOffs);
- while (rawData[resOffs] != '$') {
- Common::String resName((char *)rawData + resOffs);
+ resOffs += MAX(resName.size() + 1, 10U); // work around malformed resource entry in the US release
- resOffs += MAX(resName.size() + 1, 10U);
+ uint16 reso = READ_LE_UINT16(rawData + resOffs);
+ resOffs += 2;
+ uint16 ress = READ_LE_UINT16(rawData + resOffs);
+ resOffs += 2;
- uint16 reso = READ_LE_UINT16(rawData + resOffs);
- resOffs += 2;
- uint16 ress = READ_LE_UINT16(rawData + resOffs);
- resOffs += 2;
+ warning("%s : %X", resName.c_str(), ress * 16 + reso);
- warning("%s : %X", resName.c_str(), ress * 16 + reso);
+ int i;
+ for (i = 0; res_static[i].name[0] != '$'; i++) { // Yeah, linear search
+ if (!strcmp(res_static[i].name, resName.c_str())) {
+ *res_static[i].buffer = rawData + off + ress * 16 + reso;
+ break;
+ }
}
+ if (res_static[i].name[0] == '$')
+ warning("LoadStaticData(): Extra resource %s", resName.c_str());
}
+ // And now check that everything was loaded
+ bool missing = false;
+ for (int i = 0; res_static[i].name[0] != '$'; i++) {
+ if (*res_static[i].buffer == NULL) {
+ warning("LoadStaticData(): Resource %s is not present", res_static[i].name);
+ missing = true;
+ }
+ }
- return LoadFilesList(res_static);
+ return !missing;
}
ResEntry_t res_texts[] = {
diff --git a/engines/chamber/resdata.h b/engines/chamber/resdata.h
index 4c89631e0fe..f094c4cd6e0 100644
--- a/engines/chamber/resdata.h
+++ b/engines/chamber/resdata.h
@@ -30,6 +30,12 @@ typedef struct ResEntry_t {
void *buffer;
} ResEntry_t;
+typedef struct ResEntry_tp {
+ char name[5 + 1 + 3 + 1];
+ byte **buffer;
+} ResEntry_tp;
+
+
/* Max resource file size among all languages */
#define RES_ALEAT_MAX 256
#define RES_ANICO_MAX 667
@@ -65,19 +71,19 @@ extern byte pers2_data[];
extern byte desci_data[];
extern byte diali_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[];
+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;
byte *SeekToEntry(byte *bank, uint16 num, byte **end);
byte *SeekToEntryW(byte *bank, uint16 num, byte **end);
Commit: 0429bc78bef56e6eb17db33f3fcffb8cf8c41739
https://github.com/scummvm/scummvm/commit/0429bc78bef56e6eb17db33f3fcffb8cf8c41739
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Plug memory leaks
Changed paths:
engines/chamber/chamber.cpp
engines/chamber/resdata.cpp
diff --git a/engines/chamber/chamber.cpp b/engines/chamber/chamber.cpp
index 819e6cda64b..78b29857d68 100644
--- a/engines/chamber/chamber.cpp
+++ b/engines/chamber/chamber.cpp
@@ -54,7 +54,7 @@ ChamberEngine::ChamberEngine(OSystem *syst)
ChamberEngine::~ChamberEngine() {
// Dispose your resources here
delete _rnd;
- delete _pxiData;
+ delete[] _pxiData;
}
bool ChamberEngine::hasFeature(EngineFeature f) const {
diff --git a/engines/chamber/resdata.cpp b/engines/chamber/resdata.cpp
index 16b3b20fccc..b8bbcd0b6f4 100644
--- a/engines/chamber/resdata.cpp
+++ b/engines/chamber/resdata.cpp
@@ -167,10 +167,7 @@ int16 LoadStaticData() {
uint32 rawSize = decompress(modData, rawData);
warning("decoded to %d bytes", rawSize);
- Common::DumpFile out;
- out.open("zzdump");
- out.write(rawData, rawSize);
- out.close();
+ delete[] modData;
if (rawData[0] != 'M' || rawData[1] != 'Z')
error("Module decompressed, but is not an EXE file");
@@ -227,6 +224,8 @@ int16 LoadStaticData() {
}
}
+ delete[] modOffs;
+
return !missing;
}
Commit: d5e416e7730c2657545bd5e9c29d027e9a6e7803
https://github.com/scummvm/scummvm/commit/d5e416e7730c2657545bd5e9c29d027e9a6e7803
Author: Retro-Junk (rj at localhost)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Implement remaining opcodes except ending and restart
Changed paths:
engines/chamber/cga.cpp
engines/chamber/cga.h
engines/chamber/dialog.cpp
engines/chamber/dialog.h
engines/chamber/room.h
engines/chamber/script.cpp
engines/chamber/script.h
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 76a3c7eea57..e6f4a31dc3f 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -1145,4 +1145,277 @@ void CGA_TraceLine(uint16 sx, uint16 ex, uint16 sy, uint16 ey, byte *source, byt
CGA_blitToScreen(0, 0, 320, 200);
}
+/*TODO: get rid of this structure and pass everything relevant as arguments?*/
+typedef struct zoom_t {
+ byte ybase;
+ byte xbase; /*IN: original x shift in pixels*/
+ byte xval_l;
+ byte xval_h;
+ byte xstep_l;
+ byte xstep_h;
+ byte yval_l;
+ byte yval_h;
+ byte ystep_l;
+ byte ystep_h;
+ byte ew; /*IN: original width/height in pixels*/
+ byte eh;
+ byte scale_x;
+ byte scale_y;
+ byte oh; /*IN: original width/height in bytes*/
+ byte ow;
+ byte *pixels; /*IN: image pixels*/
+ byte fw;
+} zoom_t;
+
+/*
+Divide two normal values and return 8.8 quotient
+*/
+static uint16 FPDiv(uint16 a, byte b) {
+ byte hi = a / b;
+ byte lo = ((a % b) << 8) / b;
+ return (hi << 8) + lo;
+ /*is it really any better than (uint32)(a << 8) / b ?*/
+}
+
+/*
+Draw scaled image
+NB! tw/th specify target width/height in pixels
+*/
+static void CGA_Zoom(zoom_t *params, byte tw, byte th, byte *source, byte *target, uint16 ofs) {
+ byte x, y;
+ uint16 finofs = ofs;
+ byte *temp = scratch_mem2;
+
+ /*calc old/new ratio*/
+ params->scale_x = tw + 1;
+ params->xstep_l = params->ew / params->scale_x;
+ params->xstep_h = (params->ew % params->scale_x) * 256 / params->scale_x;
+
+ params->scale_y = th + 1;
+ params->ystep_l = params->eh / params->scale_y;
+ params->ystep_h = (params->eh % params->scale_y) * 256 / params->scale_y;
+
+ params->yval_l = 0;
+ params->yval_h = 0;
+
+ for (y = params->scale_y;;) {
+ uint16 oofs = ofs;
+ byte *pixels = params->pixels + params->yval_l * params->ow;
+ byte sc = 4 - params->xbase;
+ /*left partial pixel*/
+ byte pix = source[ofs] >> (sc * 2);
+
+ params->xval_l = 0;
+ params->xval_h = 0;
+ params->fw = 0;
+
+ for (x = params->scale_x;;) {
+ byte p = pixels[params->xval_l / 4] << ((params->xval_l % 4) * 2);
+ pix = (pix << 2) | (p >> 6);
+ if (--sc == 0) {
+ /*inner full pixel*/
+ *temp++ = pix;
+ ofs++;
+ params->fw++;
+ sc = 4;
+ }
+ params->xval_l += params->xstep_l + ((params->xval_h + params->xstep_h) >> 8);
+ params->xval_h += params->xstep_h;
+
+ if (x == 0)
+ break;
+ if (--x == 0)
+ params->xval_l = params->ew;
+ }
+
+ /*right partial pixel*/
+ *temp++ = (source[ofs] & ~(0xFF << (sc * 2))) | (pix << (sc * 2));
+ ofs++;
+ params->fw++;
+
+ /*ofs -= params->fw;*/
+ ofs = oofs;
+
+ ofs ^= CGA_ODD_LINES_OFS;
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+
+ params->yval_l += params->ystep_l + ((params->yval_h + params->ystep_h) >> 8);
+ params->yval_h += params->ystep_h;
+
+ if (y == 0)
+ break;
+ if (--y == 0)
+ params->yval_l = params->eh;
+ }
+
+ CGA_BlitAndWait(scratch_mem2, params->fw, params->fw, th + 2, target, finofs);
+}
+
+/*
+Draw scaled image
+NB! tw/th specify target width/height in pixels
+This is slightly simplified version, but should work identical to the code above
+*/
+static void CGA_ZoomOpt(zoom_t *params, byte tw, byte th, byte *source, byte *target, uint16 ofs) {
+ byte x, y;
+ uint16 finofs = ofs;
+ byte *temp = scratch_mem2;
+
+ /*calc old/new ratio*/
+ uint16 target_w = tw + 1;
+ uint16 xstep = (params->ew << 8) / target_w; /*fixed-point 8.8 value*/
+ uint16 target_h = th + 1;
+ uint16 ystep = (params->eh << 8) / target_h; /*fixed-point 8.8 value*/
+
+ uint16 yval = 0;
+
+ for (y = target_h;;) {
+ byte *pixels = params->pixels + (yval >> 8) * params->ow;
+ byte sc = 4 - params->xbase;
+ /*left partial pixel*/
+ byte pix = source[ofs] >> (sc * 2);
+
+ uint16 xval = 0;
+ params->fw = 0;
+
+ for (x = target_w;;) {
+ byte p = pixels[(xval >> 8) / 4] << (((xval >> 8) % 4) * 2);
+ pix = (pix << 2) | (p >> 6);
+ if (--sc == 0) {
+ /*inner full pixel*/
+ *temp++ = pix;
+ ofs++;
+ params->fw++;
+ sc = 4;
+ }
+ xval += xstep;
+
+ if (x == 0)
+ break;
+ if (--x == 0)
+ xval = params->ew << 8;
+ }
+
+ /*right partial pixel*/
+ *temp++ = (source[ofs] & ~(0xFF << (sc * 2))) | (pix << (sc * 2));
+ ofs++;
+ params->fw++;
+
+ ofs -= params->fw;
+
+ ofs ^= CGA_ODD_LINES_OFS;
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+
+ yval += ystep;
+
+ if (y == 0)
+ break;
+ if (--y == 0)
+ yval = params->eh << 8;
+ }
+
+ CGA_BlitAndWait(scratch_mem2, params->fw, params->fw, th + 2, target, finofs);
+}
+
+/*
+Draw image zoomed from w:h to nw:nx to target at specified ofs
+Use backbuffer pixels to fill sides
+NB! w/nw are the number of bytes, not pixels
+*/
+void CGA_ZoomImage(byte *pixels, byte w, byte h, byte nw, byte nh, byte *target, uint16 ofs) {
+ zoom_t zoom;
+
+ zoom.pixels = pixels;
+ zoom.ow = w;
+ zoom.oh = h;
+ zoom.ew = (w * 4) - 1;
+ zoom.eh = h - 1;
+ zoom.xbase = ((w * 4 / 2) - 1) % 4;
+
+ /*TODO: why this nw/nh order? maybe bug*/
+#if 0
+ CGA_Zoom(&zoom, nh - 2, nw * 4 - 2, backbuffer, target, ofs);
+#else
+ CGA_ZoomOpt(&zoom, nh - 2, nw * 4 - 2, backbuffer, target, ofs);
+#endif
+}
+
+/*
+Animate image zooming-in from origin ofs to final size w:h in specified number of steps
+Use backbuffer pixels to fill sides
+Ofs specifies zoom origin
+NB! w is the number of bytes, not pixels
+*/
+void CGA_AnimZoomOpt(zoom_t *zoom, uint16 w, uint16 h, byte steps, byte *target, uint16 ofs) {
+ uint16 xstep = FPDiv(w, steps); /*fixed-point 8.8 value*/
+ uint16 ystep = FPDiv(h, steps); /*fixed-point 8.8 value*/
+
+ uint16 xval = 0x200;
+ uint16 yval = 0x200;
+
+ for (steps = steps / 2 - 2; steps; steps--) {
+ uint16 prev;
+
+ CGA_ZoomOpt(zoom, xval >> 8, yval >> 8, backbuffer, target, ofs);
+
+ prev = yval;
+ yval += ystep;
+ if (((prev ^ yval) & 0xFF00) || ((yval & 0x100) == 0)) {
+ ofs ^= CGA_ODD_LINES_OFS;
+ if ((ofs & CGA_ODD_LINES_OFS) != 0)
+ ofs -= CGA_BYTES_PER_LINE;
+ }
+
+ prev = xval;
+ xval += xstep;
+ if (((prev ^ xval) & 0xFF00) || ((xval & 0x100) == 0)) {
+ if (zoom->xbase-- == 0) {
+ ofs -= 1;
+ zoom->xbase = 3;
+ }
+ }
+ }
+}
+
+
+/*
+Animate image zooming-in from its center to final size w:h to target at specified ofs
+Use backbuffer pixels to fill sides
+NB! w is the number of bytes, not pixels
+NB! ofs is the final image top left corner, not the zoom origin
+*/
+void CGA_AnimZoomIn(byte *pixels, byte w, byte h, byte *target, uint16 ofs) {
+ uint16 finofs = ofs;
+ byte x, y, maxside;
+
+ zoom_t zoom;
+ zoom.pixels = pixels;
+ zoom.ow = w;
+ zoom.oh = h;
+ zoom.ew = (w * 4) - 1;
+ zoom.eh = h - 1;
+ zoom.xbase = ((w * 4 / 2) - 1) % 4;
+
+ /*set zoom origin*/
+ x = (w * 4 / 2) - 1;
+ y = (h / 2) - 1;
+ ofs += x / 4;
+ if (y & 1) {
+ ofs ^= CGA_ODD_LINES_OFS;
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+ }
+ ofs += (y / 2) * CGA_BYTES_PER_LINE;
+
+ maxside = w * 4;
+ if (maxside < h)
+ maxside = h;
+
+ CGA_AnimZoomOpt(&zoom, w * 4 * 2, h * 2, maxside, target, ofs);
+
+ CGA_BlitAndWait(pixels, w, w, h, target, finofs);
+}
+
} // End of namespace Chamber
diff --git a/engines/chamber/cga.h b/engines/chamber/cga.h
index c04eab789d5..28e63c53c6f 100644
--- a/engines/chamber/cga.h
+++ b/engines/chamber/cga.h
@@ -125,6 +125,9 @@ void CGA_HideShatterFall(byte *screen, byte *source, uint16 w, uint16 h, byte *t
void CGA_TraceLine(uint16 sx, uint16 ex, uint16 sy, uint16 ey, byte *source, byte *target);
+void CGA_ZoomImage(byte *pixels, byte w, byte h, byte nw, byte nh, byte *target, uint16 ofs);
+void CGA_AnimZoomIn(byte *pixels, byte w, byte h, byte *target, uint16 ofs);
+
} // End of namespace Chamber
#endif
diff --git a/engines/chamber/dialog.cpp b/engines/chamber/dialog.cpp
index 31e3e94a095..ce6e806d556 100644
--- a/engines/chamber/dialog.cpp
+++ b/engines/chamber/dialog.cpp
@@ -37,6 +37,7 @@ uint16 cur_str_index;
uint16 cur_dlg_index;
dirty_rect_t dirty_rects[MAX_DIRTY_RECT];
+dirty_rect_t *last_dirty_rect = dirty_rects;
void AddDirtyRect(byte kind, byte x, byte y, byte w, byte h, uint16 offs) {
int16 i;
@@ -51,6 +52,7 @@ void AddDirtyRect(byte kind, byte x, byte y, byte w, byte h, uint16 offs) {
r->y = y;
r->x = x;
script_byte_vars.dirty_rect_kind = dirty_rects[0].kind;
+ last_dirty_rect = r;
}
void GetDirtyRect(int16 index, byte *kind, byte *x, byte *y, byte *w, byte *h, uint16 *offs, byte newkind) {
diff --git a/engines/chamber/dialog.h b/engines/chamber/dialog.h
index 11565c46d4c..93bde9aca6e 100644
--- a/engines/chamber/dialog.h
+++ b/engines/chamber/dialog.h
@@ -46,6 +46,7 @@ typedef struct dirty_rect_t {
#define MAX_DIRTY_RECT 10
extern dirty_rect_t dirty_rects[];
+extern dirty_rect_t *last_dirty_rect;
#define SPIKE_MASK 0xE0
#define SPIKE_UPLEFT 0
diff --git a/engines/chamber/room.h b/engines/chamber/room.h
index 06e5babc2f9..9f6eeb484bd 100644
--- a/engines/chamber/room.h
+++ b/engines/chamber/room.h
@@ -184,6 +184,7 @@ void MergeSpritesDataFlip(byte *target, uint16 pitch, byte *source, uint16 w, ui
void RefreshSpritesData(void);
void BlitSpritesToBackBuffer(void);
+byte *BackupSpotImage(spot_t *spot, byte **spotback, byte *buffer);
void BackupSpotsImages(void);
void SelectPalette(void);
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 05493a68e1a..19611f638f4 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -669,6 +669,11 @@ uint16 SCR_9_DrawPortrait(void) {
return 0;
}
+/*Draw portrait, no special effects*/
+uint16 SCR_A_DrawPortrait(void) {
+ return SCR_9_DrawPortrait();
+}
+
/*Draw screen pixels using 2-phase clockwise twist*/
void TwistDraw(byte x, byte y, byte width, byte height, byte *source, byte *target) {
int16 i;
@@ -797,7 +802,9 @@ uint16 SCR_D_DrawPortraitDotEffect(void) {
return 0;
}
-/*Draw image with slow zoom-in reveal effect*/
+/*
+Draw image with slow zoom-in reveal effect
+*/
uint16 SCR_E_DrawPortraitZoomIn(void) {
byte x, y, width, height;
@@ -806,14 +813,41 @@ uint16 SCR_E_DrawPortraitZoomIn(void) {
if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
- /*TODO*/
+ CGA_AnimZoomIn(cur_image_pixels, cur_image_size_w, cur_image_size_h, frontbuffer, cur_image_offs);
+ return 0;
+}
- CGA_BlitAndWait(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
+
+/*
+Draw image with specified w/h zoom
+*/
+uint16 SCR_10_DrawPortraitZoomed(void) {
+ byte x, y, width, height;
+ byte zwidth, zheight;
+
+ script_ptr++;
+
+ right_button = 0; /*prevent cancel or zoom parameters won't be consumed*/
+ if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ return 0; /*TODO: maybe just remove the if/return instead?*/
+
+ zwidth = *script_ptr++;
+ zheight = *script_ptr++;
+
+ /*adjust the rect for new size*/
+ last_dirty_rect->width = zwidth + 2;
+ last_dirty_rect->height = zheight;
+
+ CGA_ZoomImage(cur_image_pixels, cur_image_size_w, cur_image_size_h, zwidth, zheight, frontbuffer, cur_image_offs);
+
+#if 0
+ /*TODO: debug wait*/
+ PromptWait();
+#endif
return 0;
}
-
/*Hide portrait, pushing it from right to left*/
uint16 SCR_19_HidePortraitLiftLeft(void) {
byte index;
@@ -1447,6 +1481,27 @@ uint16 SCR_23_HidePortrait(void) {
return 0;
}
+/*
+Hide a portrait, no special effects
+*/
+uint16 SCR_1D_HidePortrait(void) {
+ return SCR_23_HidePortrait();
+}
+
+/*
+Hide a portrait, no special effects
+*/
+uint16 SCR_21_HidePortrait(void) {
+ return SCR_23_HidePortrait();
+}
+
+/*
+Hide a portrait, no special effects
+*/
+uint16 SCR_3F_HidePortrait(void) {
+ return SCR_23_HidePortrait();
+}
+
/*
Restore screen data from back buffer for all portraits
*/
@@ -1533,7 +1588,7 @@ uint16 SCR_30_Fight(void) {
strenght = 0;
- script_byte_vars.byte_179F2 = 0;
+ script_byte_vars.fight_status = 0;
if (script_byte_vars.byte_179F3 == 0) {
static byte character_strenght[] = {1, 3, 1, 1, 1, 1, 5, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1};
@@ -1557,6 +1612,15 @@ uint16 SCR_30_Fight(void) {
strenght++;
}
+ /*
+ win flags:
+ 1 - player won
+ 2 - player dead
+ 0x20 - "TU NUH RAY VUN IN FAY VRABLE SIT YOU AISHUN."
+ 0x40 - "OUT KUM UNSER TUN."
+ 0x80 - "SIT YOU ASHUN KRITI KAL FOR TOONUH RAY VUN."
+ */
+
win = 1;
rnd = script_byte_vars.rand_value;
@@ -1567,21 +1631,21 @@ uint16 SCR_30_Fight(void) {
if (strenght >= 2) {
if (strenght == 2) {
if (rnd >= 205)
- win = Rand() < 128 ? 81 : 82;
+ win = Rand() < 128 ? (0x40 | 0x10 | 1) : (0x40 | 0x10 | 2);
} else if (strenght == 4 && rnd < 100) {
- win = Rand() < 128 ? 81 : 82;
+ win = Rand() < 128 ? (0x40 | 0x10 | 1) : (0x40 | 0x10 | 2);
} else {
win = 2;
if (strenght == 3) {
if (rnd < 128) /*TODO: check me, maybe original bug (checks against wrong reg?)*/
- win = Rand() < 51 ? 145 : 146;
+ win = Rand() < 51 ? (0x80 | 0x10 | 1) : (0x80 | 0x10 | 2);
else
- win = Rand() < 205 ? 49 : 50;
+ win = Rand() < 205 ? (0x20 | 0x10 | 1) : (0x20 | 0x10 | 2);
}
}
}
- script_byte_vars.byte_179F2 = win;
+ script_byte_vars.fight_status = win;
script_ptr = old_script;
script_end_ptr = old_script_end;
@@ -1696,7 +1760,7 @@ uint16 SCR_31_Fight2(void) {
if (prev_fight_mode == 0
&& script_byte_vars.room_items != 0
&& fight_mode == 0) {
- script_byte_vars.byte_179F2 &= ~1;
+ script_byte_vars.fight_status &= ~1;
} else {
uint16 i;
fightentry_t *fightlist;
@@ -2250,12 +2314,83 @@ uint16 SCR_53_FindInvItem(void) {
return 0;
}
+/*
+Restore whole room from backbuffer, with dot effect
+*/
+uint16 SCR_54_DotFadeRoom(void) {
+ script_ptr++;
+
+ dot_effect_delay = 1;
+ dot_effect_step = 17;
+ CopyScreenBlockWithDotEffect(backbuffer, room_bounds_rect.sx, room_bounds_rect.sy, room_bounds_rect.ex - room_bounds_rect.sx, room_bounds_rect.ey - room_bounds_rect.sy, frontbuffer);
+
+ return 0;
+}
+
uint16 SCR_55_DrawRoomItemsIndicator(void) {
script_ptr++;
DrawRoomItemsIndicator();
return 0;
}
+/*
+TODO: check and rename me
+*/
+uint16 SCR_56_MorphRoom98(void) {
+ int16 h;
+ uint16 ofs;
+ script_ptr++;
+
+ RedrawRoomStatics(98, 0);
+
+ ofs = CGA_CalcXY(0, 136);
+ for (h = 60; h; h--) {
+ memcpy(frontbuffer + ofs, backbuffer + ofs, CGA_BYTES_PER_LINE);
+ WaitVBlank();
+ ofs ^= CGA_ODD_LINES_OFS;
+ if ((ofs & CGA_ODD_LINES_OFS) != 0)
+ ofs -= CGA_BYTES_PER_LINE;
+ }
+
+ BackupSpotImage(&zone_spots[3], &sprites_list[3], sprites_list[3]);
+
+ return 0;
+}
+
+extern void AskDisk2(void);
+extern int16 LoadSplash(const char *filename);
+
+/*
+TODO: check me
+*/
+uint16 SCR_5B_TheEnd(void) {
+ static byte image1[] = {167, 0, 146};
+ byte *pimage1 = image1;
+ byte *sequence = souco_data;
+
+ byte x, y, width, height;
+
+ /*script_ptr++; Useless since this handler never returns*/
+
+ script_byte_vars.game_paused = 5;
+ memset(backbuffer, 0, sizeof(backbuffer) - 2); /*TODO: original bug?*/
+ CGA_BackBufferToRealFull();
+ CGA_ColorSelect(0x30);
+
+ right_button = 0;
+ if (!DrawPortrait(&pimage1, &x, &y, &width, &height))
+ return 0;
+
+ /*TODO*/
+
+ while (!LoadSplash("PRES.BIN"))
+ AskDisk2();
+ CGA_BackBufferToRealFull();
+
+ for (;;) ; /*HANG*/
+ return 0;
+}
+
/*
Discard all inventory items
*/
@@ -2477,6 +2612,25 @@ uint16 SCR_29_DialiTextBox(void) {
return 0;
}
+/*
+Do nothing in PC/CGA version
+*/
+uint16 SCR_F_Unused(void) {
+ script_ptr++;
+ script_ptr++;
+ script_ptr++;
+ script_ptr++;
+ return 0;
+}
+
+/*
+Do nothing in PC/CGA version
+*/
+uint16 SCR_4A_Unused(void) {
+ script_ptr++;
+ return 0;
+}
+
/*
Do nothing in PC/CGA version
*/
@@ -3430,13 +3584,13 @@ cmdhandler_t script_handlers[] = {
SCR_7_DrawPortraitLiftDown,
SCR_8_DrawPortraitLiftUp,
SCR_9_DrawPortrait,
- SCR_TRAP,
+ SCR_A_DrawPortrait, /*TODO: same as SCR_9_DrawPortrait , unused*/
SCR_B_DrawPortraitTwistEffect,
SCR_C_DrawPortraitArcEffect,
SCR_D_DrawPortraitDotEffect,
SCR_E_DrawPortraitZoomIn,
- SCR_TRAP,
- SCR_TRAP, /*10*/
+ SCR_F_Unused,
+ SCR_10_DrawPortraitZoomed, /*10*/
SCR_11_DrawRoomObject,
SCR_12_Chain,
SCR_13_RedrawRoomStatics,
@@ -3449,11 +3603,11 @@ cmdhandler_t script_handlers[] = {
SCR_1A_HidePortraitLiftRight,
SCR_1B_HidePortraitLiftUp,
SCR_1C_HidePortraitLiftDown,
- SCR_TRAP, /*TODO: same as SCR_23_HidePortrait , unused*/
+ SCR_1D_HidePortrait, /*TODO: same as SCR_23_HidePortrait , unused*/
SCR_1E_HidePortraitTwist,
SCR_1F_HidePortraitArc,
SCR_20_HidePortraitDots, /*20*/
- SCR_TRAP, /*TODO: same as SCR_23_HidePortrait , unused*/
+ SCR_21_HidePortrait, /*TODO: same as SCR_23_HidePortrait , unused*/
SCR_22_HidePortraitShatter,
SCR_23_HidePortrait,
SCR_24_PopAllPortraits,
@@ -3483,7 +3637,7 @@ cmdhandler_t script_handlers[] = {
SCR_3C_CondExpr,
SCR_3D_ActionsMenu,
SCR_3E_TheWallAdvance,
- SCR_TRAP,
+ SCR_3F_HidePortrait, /*TODO: same as SCR_23_HidePortrait , unused*/
SCR_40_PopAllTextBoxes, /*40*/
SCR_41_LiftHand,
SCR_42_LoadZone,
@@ -3494,7 +3648,7 @@ cmdhandler_t script_handlers[] = {
SCR_47_DeProfundisRiseMonster,
SCR_48_DeProfundisLowerMonster,
SCR_49_DeProfundisRiseHook,
- SCR_TRAP,
+ SCR_4A_Unused,
SCR_4B_ProtoDropZapstik,
SCR_4C_DrawZoneObjs,
SCR_4D_PriorityCommand,
@@ -3504,14 +3658,14 @@ cmdhandler_t script_handlers[] = {
SCR_51_ItemTrade,
SCR_52_RefreshSpritesData,
SCR_53_FindInvItem,
- SCR_TRAP,
+ SCR_54_DotFadeRoom,
SCR_55_DrawRoomItemsIndicator,
- SCR_TRAP,
+ SCR_56_MorphRoom98,
SCR_57_ShowCharacterSprite,
SCR_58_DrawCharacterSprite,
SCR_59_BlitSpritesToBackBuffer,
SCR_5A_SelectPalette,
- SCR_TRAP,
+ SCR_5B_TheEnd,
SCR_5C_ClearInventory,
SCR_5D_DropWeapons,
SCR_5E_SelectTempPalette,
diff --git a/engines/chamber/script.h b/engines/chamber/script.h
index 2a04e2762a0..7c1b29e98e6 100644
--- a/engines/chamber/script.h
+++ b/engines/chamber/script.h
@@ -103,7 +103,7 @@ typedef struct script_byte_vars_t {
byte byte_179EF; /* 39 */
byte quest_item_ofs; /* 3A */
byte byte_179F1; /* 3B */
- byte byte_179F2; /* 3C */
+ byte fight_status; /* 3C */
byte byte_179F3; /* 3D */
byte trade_done; /* 3E */
byte byte_179F5; /* 3F */
Commit: cefbca089451098400587d64b6005c0e450dcf3b
https://github.com/scummvm/scummvm/commit/cefbca089451098400587d64b6005c0e450dcf3b
Author: Retro-Junk (rj at localhost)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Activate intro bypass cheat
Changed paths:
engines/chamber/common.h
engines/chamber/kult.cpp
diff --git a/engines/chamber/common.h b/engines/chamber/common.h
index 64066cd8089..f42e2ea5965 100644
--- a/engines/chamber/common.h
+++ b/engines/chamber/common.h
@@ -48,6 +48,13 @@ typedef struct rect_t {
#define DEBUG
#endif
+#if 1
+/*0 - play intro*/
+/*0xFF - skip intro, quest item and teleport*/
+/*other - skip intro, play quest item seq, teleport to room*/
+#define DEBUG_SKIP_INTRO 0xFF
+#endif
+
#if 1
#define DEBUG_ZONE
#endif
@@ -72,7 +79,7 @@ typedef struct rect_t {
#define DEBUG_QUEST 0xC0
#endif
-#if 0
+#if 1
#define CHEAT
#endif
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 5a9c1256fb2..97a854d48da 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -294,11 +294,14 @@ restart:
}
#endif
-#if 1
- /* Play introduction sequence */
+#ifdef DEBUG_SKIP_INTRO
+ /*bypass characters introduction*/
+ script_byte_vars.load_flag = DEBUG_SKIP_INTRO;
+#endif
+
+ /* Play introduction sequence and initialize game */
the_command = 0xC001;
RunCommand();
-#endif
if (_shouldQuit)
return Common::kNoError;
Commit: 362503b6cc946e08596d80217aac4cbd08bdfc91
https://github.com/scummvm/scummvm/commit/362503b6cc946e08596d80217aac4cbd08bdfc91
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Play sounds
Changed paths:
engines/chamber/sound.cpp
diff --git a/engines/chamber/sound.cpp b/engines/chamber/sound.cpp
index 27127b3f1c8..2ef5f20e9c6 100644
--- a/engines/chamber/sound.cpp
+++ b/engines/chamber/sound.cpp
@@ -26,9 +26,109 @@
namespace Chamber {
+typedef struct pcsample_t {
+ unsigned short repeat;
+ unsigned short delay1;
+ unsigned short delay1sweep;
+ unsigned short delay2;
+ unsigned short delay2sweep;
+ unsigned short freq;
+ unsigned short freqsweep;
+} pcsample_t;
-void PlaySound(byte index) {
- /*TODO*/
+#define N(x) (0xF000|x)
+
+pcsample_t pc_samples[] = {
+ { 64, 32, 0, 32, 0, 256, 0},
+ { 1, 2560, 0, 2560, 0, 0, 0},
+ { 8, 2048, 0, 256, 256, 0, 0},
+ { 11, 2816, N(256), 2816, N(256), 256, 256},
+ { 1, 768, 0, 768, 0, 256, 0},
+ {128, 48, 1, 48, 0, 61440u, 1},
+ {128, 80, 1, 80, 0, 1, 1},
+ {128, 128, 1, 128, 1, 16, 1},
+ {128, 128, 1, 128, 0, 256, 16},
+ {128, 128, 1, 128, 1, 61440u, N(16)},
+ { 16, 1536, 0, 1536, 0, 0, 0},
+ { 3, 768, 0, 768, N(256), 256, N(256)},
+};
+
+#undef N
+
+static void SpeakerPlay(pcsample_t *sample) {
+ warning("STUB: SpeakerPlay()");
+
+#if 0
+ unsigned short rep, freq, delay1, delay2, delay;
+ unsigned char ppi;
+
+ freq = sample->freq;
+ delay1 = sample->delay1;
+ delay2 = sample->delay2;
+
+ disable();
+ ppi = inportb(0x61);
+
+ for (rep = 0; rep < sample->repeat; rep++) {
+ outportb(0x43, 0xB6);
+ outportb(0x42, freq & 255);
+ outportb(0x42, freq >> 8);
+ /*speaker off*/
+ outportb(0x61, ppi & ~3);
+ for (delay = delay1; delay--;) ; /*TODO: weak delay*/
+ /*speaker on*/
+ outportb(0x61, ppi | 3);
+ for (delay = delay2; delay--;) ; /*TODO: weak delay*/
+
+ if (sample->delay1sweep & 0xF000)
+ delay1 -= sample->delay1sweep & 0xFFF;
+ else
+ delay1 += sample->delay1sweep;
+
+ if (sample->delay2sweep & 0xF000)
+ delay2 -= sample->delay2sweep & 0xFFF;
+ else
+ delay2 += sample->delay2sweep;
+
+ if (sample->freqsweep & 0xF000)
+ freq -= sample->freqsweep & 0xFFF;
+ else
+ freq += sample->freqsweep;
+ }
+
+ /*turn off the speaker*/
+ outportb(0x61, ppi & ~3);
+ enable();
+#endif
+}
+
+#define kMaxSounds 12
+
+unsigned char sounds_table[kMaxSounds][3] = {
+ {20, 0, 0},
+ {19, 0, 0},
+ {176, 0, 0},
+ {144, 145, 146},
+ {243, 0, 0},
+ {18, 0, 0},
+ {149, 21, 0},
+ {27, 0, 0},
+ {241, 25, 151},
+ {22, 0, 0},
+ {224, 0, 0},
+ {31, 0, 0}
+};
+
+void PlaySound(unsigned char index) {
+ int i;
+ for (i = 0; i < kMaxSounds; i++) {
+ if (sounds_table[i][0] == index
+ || sounds_table[i][1] == index
+ || sounds_table[i][2] == index) {
+ SpeakerPlay(&pc_samples[i]);
+ break;
+ }
+ }
}
} // End of namespace Chamber
Commit: 556d23b06f53759be5a41e4c6e567e046571eb0a
https://github.com/scummvm/scummvm/commit/556d23b06f53759be5a41e4c6e567e046571eb0a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Implement game over and restart
Changed paths:
engines/chamber/kult.cpp
engines/chamber/savegame.cpp
engines/chamber/script.cpp
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 97a854d48da..4d100449956 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -20,6 +20,9 @@
*
*/
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
+#include <setjmp.h>
#include "common/error.h"
#include "common/system.h"
@@ -191,6 +194,8 @@ void ExitGame(void) {
SwitchToTextMode();
}
+jmp_buf restart_jmp;
+
Common::Error ChamberEngine::run() {
// Initialize graphics using following:
initGraphics(320, 200);
@@ -275,8 +280,9 @@ Common::Error ChamberEngine::run() {
cpu_speed_delay = BenchmarkCpu() / 8;
/*restart game from here*/
-restart:
- ;
+restart:;
+ setjmp(restart_jmp);
+
Randomize();
/* Set start zone */
@@ -286,12 +292,7 @@ restart:
script_byte_vars.game_paused = 0;
#ifdef DEBUG_SCRIPT
- {
- FILE *f = fopen(DEBUG_SCRIPT_LOG, "wt+");
- if (f) {
- fclose(f);
- }
- }
+ unlink(DEBUG_SCRIPT_LOG);
#endif
#ifdef DEBUG_SKIP_INTRO
diff --git a/engines/chamber/savegame.cpp b/engines/chamber/savegame.cpp
index fd90ecaa354..2ad2eba7a6a 100644
--- a/engines/chamber/savegame.cpp
+++ b/engines/chamber/savegame.cpp
@@ -31,23 +31,6 @@
namespace Chamber {
-void SaveRestartGame(void) {
- /*TODO*/
-}
-
-void RestartGame(void) {
- /*
- while(!LoadFile("CLEAR.BIN", save_start))
- AskDisk2();
- */
-
- script_byte_vars.cur_spot_flags = 0xFF;
- script_byte_vars.load_flag = 2;
- /*Restart();*/
-
- /*TODO*/
-}
-
#define CGA_SAVE_BEG_OFS 0x751E
#define CGA_SAVE_END_OFS 0x9D5D
@@ -79,33 +62,13 @@ void RestartGame(void) {
#define READ(buffer, size) \
rlen = read(f, buffer, size); if(rlen != size) goto error;
-int16 LoadScena(void) {
- warning("STUB: LoadScena()");
-
- return 1;
-
#if 0
- int16 f;
+int16 ReadSaveData(int16 f, int16 clean) {
int16 rlen;
uint16 zero = 0;
byte *p;
int16 i;
- script_byte_vars.game_paused = 1;
-
-
- f = open("SCENAx.BIN", O_RDONLY | O_BINARY);
- if (f == -1) {
- script_byte_vars.game_paused = 0;
- return 1; /*error*/
- }
- /*
- Save format:
- vars memory (751E-9D5D)
- frontbuffer (0x3FFF bytes)
- backbuffer (0x3FFF bytes)
- */
-
#define BYTES(buffer, size) READ(buffer, size)
#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; }
@@ -323,13 +286,15 @@ int16 LoadScena(void) {
/* zones_data */
BYTES(zones_data, RES_ZONES_MAX);
- /* screen data */
- BYTES(backbuffer, 0x3FFF);
+ if (clean == 0) {
+ /* screen data */
+ BYTES(backbuffer, 0x3FFF);
- CGA_BackBufferToRealFull();
- SelectPalette();
+ CGA_BackBufferToRealFull();
+ SelectPalette();
- BYTES(backbuffer, 0x3FFF);
+ BYTES(backbuffer, 0x3FFF);
+ }
#undef BYTES
#undef UBYTE
@@ -338,42 +303,18 @@ int16 LoadScena(void) {
#undef SSHORT
#undef POINTER
- /*re-initialize sprites list*/
- BackupSpotsImages();
-
- close(f);
- script_byte_vars.game_paused = 0;
return 0;
-error:
- ;
- close(f);
- script_byte_vars.game_paused = 0;
+error:;
return 1;
-
-#endif
}
-int16 SaveScena(void) {
- warning("STUB: SaveScena()");
- return 1;
-
-#if 0
- int16 f;
+int16 WriteSaveData(int16 f, int16 clean) {
int16 wlen;
uint16 zero = 0;
byte *p;
int16 i;
- script_byte_vars.game_paused = 1;
- BlitSpritesToBackBuffer();
-
- f = open("SCENAx.BIN", O_CREAT | O_WRONLY | O_BINARY);
- if (f == -1) {
- script_byte_vars.game_paused = 0;
- return 1; /*error*/
- }
-
#define BYTES(buffer, size) WRITE(buffer, size)
#define UBYTE(variable) { byte temp_v = variable; WRITE(&temp_v, 1); }
#define SBYTE(variable) { int8 temp_v = variable; WRITE(&temp_v, 1); }
@@ -591,9 +532,11 @@ int16 SaveScena(void) {
/* zones_data */
BYTES(zones_data, RES_ZONES_MAX);
- /* screen data */
- BYTES(frontbuffer, 0x3FFF);
- BYTES(backbuffer, 0x3FFF);
+ if (clean == 0) {
+ /* screen data */
+ BYTES(frontbuffer, 0x3FFF);
+ BYTES(backbuffer, 0x3FFF);
+ }
#undef BYTES
#undef UBYTE
@@ -602,15 +545,112 @@ int16 SaveScena(void) {
#undef SSHORT
#undef POINTER
- close(f);
- script_byte_vars.game_paused = 0;
return 0;
-error:
- ;
+error:;
+ return 1;
+}
+#endif
+
+int16 LoadScena(void) {
+ warning("STUB: LoadScena()");
+ return 1;
+#if 0
+ int16 f;
+ int16 res;
+
+ script_byte_vars.game_paused = 1;
+
+ f = open("SCENAx.BIN", O_RDONLY | O_BINARY);
+ if (f == -1) {
+ script_byte_vars.game_paused = 0;
+ return 1; /*error*/
+ }
+ /*
+ Save format:
+ vars memory (751E-9D5D)
+ frontbuffer (0x3FFF bytes)
+ backbuffer (0x3FFF bytes)
+ */
+
+ res = ReadSaveData(f, 0);
+
+ if (res == 0) {
+ /*re-initialize sprites list*/
+ BackupSpotsImages();
+ }
+
close(f);
script_byte_vars.game_paused = 0;
+ return res;
+#endif
+}
+
+int16 SaveScena(void) {
+ warning("STUB: SaveScena()");
return 1;
+#if 0
+ int16 f;
+ int16 res;
+
+ script_byte_vars.game_paused = 1;
+ BlitSpritesToBackBuffer();
+
+ f = open("SCENAx.BIN", O_CREAT | O_WRONLY | O_BINARY);
+ if (f == -1) {
+ script_byte_vars.game_paused = 0;
+ return 1; /*error*/
+ }
+
+ res = WriteSaveData(f, 0);
+
+ close(f);
+ script_byte_vars.game_paused = 0;
+ return res;
+#endif
+}
+
+void SaveRestartGame(void) {
+ warning("STUB: SaveRestartGame()");
+#if 0
+ int16 f;
+
+ f = open("CLEARx.BIN", O_CREAT | O_WRONLY | O_BINARY);
+ if (f == -1) {
+ return; /*error*/
+ }
+
+ WriteSaveData(f, 1);
+
+ close(f);
+ return;
+#endif
+}
+
+//extern jmp_buf restart_jmp;
+extern void AskDisk2(void);
+
+void RestartGame(void) {
+ warning("STUB: RestartGame()");
+
+#if 0
+ int16 f;
+ int16 res;
+
+ for (;; AskDisk2()) {
+ f = open("CLEARx.BIN", O_RDONLY | O_BINARY);
+ if (f != -1) {
+ res = ReadSaveData(f, 1);
+ close(f);
+ if (res == 0)
+ break;
+ }
+ }
+
+ script_byte_vars.cur_spot_flags = 0xFF;
+ script_byte_vars.load_flag = 2;
+
+ longjmp(restart_jmp, 1);
#endif
}
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 19611f638f4..be45a2da24b 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -69,6 +69,8 @@ void *script_vars[ScrPools_MAX] = {
pers_list
};
+extern void AskDisk2(void);
+
byte Rand(void) {
script_byte_vars.rand_value = aleat_data[++rand_seed];
return script_byte_vars.rand_value;
@@ -1102,36 +1104,182 @@ uint16 SCR_25_ChangeZoneOnly(void) {
return 0;
}
+#define JCOUNT 16
+
+typedef struct jpoint_t {
+ signed short x;
+ signed short y;
+} jpoint_t;
+
+static jpoint_t jdeltas[JCOUNT] = {
+ {0, -2},
+ {1, -2},
+ {2, -2},
+ {2, -1},
+ {2, 0},
+ {2, 1},
+ {2, 2},
+ {1, 2},
+ {0, 2},
+ { -1, 2},
+ { -2, 2},
+ { -2, 1},
+ { -2, 0},
+ { -2, -1},
+ { -2, -2},
+ { -1, -2}
+};
+
+void JaggedZoom(byte *source, byte *target) {
+ int16 i;
+ jpoint_t points[JCOUNT + 1];
+ uint16 outside = 0;
+ uint16 cycle = 0;
+ uint16 choices = 0;
-void JaggedZoom(void) {
- /*TODO*/
+ for (i = 0; i < JCOUNT; i++) {
+ points[i].x = 320;
+ points[i].y = 200;
+ }
+ points[i].x = 0;
+ points[i].y = 0;
+
+ for (;;) {
+ cycle++;
+ if (cycle % 8 == 0)
+ choices = RandW();
+
+ for (i = 0; i < JCOUNT; i++) {
+ signed short t;
+ if (choices & (1 << i)) {
+ t = points[i].x + jdeltas[i].x;
+ if (t < 0 || t >= 600) { /*TODO: 640?*/
+ outside |= 0x8000; /*TODO: should this mask be rotated?*/
+ t = points[i].x;
+ }
+ points[i].x = t;
+
+ t = points[i].y + jdeltas[i].y;
+ if (t < 0 || t >= 400) {
+ outside |= 0x8000;
+ t = points[i].y;
+ }
+ points[i].y = t;
+ }
+ }
+
+ if (outside)
+ break;
+
+ for (i = 0; i < JCOUNT; i++) {
+ uint16 sx = points[i].x;
+ uint16 sy = points[i].y;
+ uint16 ex = points[i + 1].x;
+ uint16 ey = points[i + 1].y;
+ if (ex == 0 && ey == 0) {
+ ex = points[0].x;
+ ey = points[0].y;
+ }
+ CGA_TraceLine(sx / 2, ex / 2, sy / 2, ey / 2, source, target);
+ /*TODO: WaitVBlank(); maybe?*/
+ }
+ }
}
-void InitStarfield(void) {
- /*TODO*/
+typedef struct star_t {
+ uint16 ofs;
+ byte pixel;
+ byte mask;
+ signed short x;
+ signed short y;
+ uint16 z;
+} star_t;
+
+void RandomStar(star_t *star) {
+ star->x = RandW();
+ star->y = RandW();
+ star->z = RandW() & 0xFFF;
}
-void AnimStarfield(void) {
- /*TODO*/
+star_t *InitStarfield(void) {
+ int16 i;
+ star_t *stars = (star_t *)scratch_mem2;
+ for (i = 0; i < 300; i++) {
+ stars[i].ofs = 0;
+ stars[i].pixel = 0;
+ stars[i].mask = 0;
+ RandomStar(&stars[i]);
+ }
+ return stars;
+}
+
+void DrawStars(star_t *stars, int16 iter, byte *target) {
+ int16 i;
+ /*TODO: bug? initialized 300 stars, but animated only 256?*/
+ for (i = 0; i < 256; i++, stars++) {
+ short z, x, y;
+ byte pixel, mask;
+
+ target[stars->ofs] &= stars->mask;
+ if (stars->z < 328) {
+ if (iter >= 30) {
+ RandomStar(stars);
+ stars->z |= 0x1800;
+ }
+ continue;
+ }
+
+ stars->z -= 328;
+ z = 0xCFFFFul / (stars->z + 16);
+ x = ((long)z * stars->x) >> 16;
+ y = ((long)z * stars->y) >> 16;
+
+ x += 320 / 2;
+ y += 200 / 2;
+ if (x < 0 || x >= 320 || y < 0 || y >= 200) {
+ stars->z = 0;
+ continue;
+ }
+
+ stars->ofs = CGA_CalcXY(x, y);
+
+ pixel = (stars->z < 0xE00) ? 0xC0 : 0x40;
+ pixel >>= (x % 4) * 2;
+ mask = 0xC0;
+ mask = ~(mask >> (x % 4) * 2);
+ stars->pixel = pixel;
+ stars->mask = mask;
+
+ target[stars->ofs] &= mask;
+ target[stars->ofs] |= pixel;
+ }
+}
+
+void AnimStarfield(star_t *stars, byte *target) {
+ int16 i;
+ for (i = 100; i; i--)
+ DrawStars(stars, i, target);
}
uint16 SCR_26_GameOver(void) {
in_de_profundis = 0;
script_byte_vars.game_paused = 1;
memset(backbuffer, 0, sizeof(backbuffer) - 2); /*TODO: original bug?*/
- JaggedZoom();
+ JaggedZoom(backbuffer, frontbuffer);
CGA_BackBufferToRealFull();
CGA_ColorSelect(0x30);
- InitStarfield();
- AnimStarfield();
+ AnimStarfield(InitStarfield(), frontbuffer);
PlayAnim(44, 156 / 4, 95);
script_byte_vars.zone_index = 135;
- JaggedZoom();
- CGA_BackBufferToRealFull();
- /*RestartGame();*/
- /*TODO: this should shomehow abort all current scripts/calls and restart the game*/
- TODO("Restart");
+ /*reload background*/
+ while (!LoadFond())
+ AskDisk2();
+
+ JaggedZoom(backbuffer, frontbuffer);
+
+ CGA_BackBufferToRealFull();
+ RestartGame();
return 0;
}
Commit: bd6e4435552f4dca51ef0e533b35200116cd1233
https://github.com/scummvm/scummvm/commit/bd6e4435552f4dca51ef0e533b35200116cd1233
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Play the ending cutscene
Changed paths:
engines/chamber/cga.cpp
engines/chamber/cga.h
engines/chamber/kult.cpp
engines/chamber/script.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index e6f4a31dc3f..262a1f3a5c4 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -1418,4 +1418,88 @@ void CGA_AnimZoomIn(byte *pixels, byte w, byte h, byte *target, uint16 ofs) {
CGA_BlitAndWait(pixels, w, w, h, target, finofs);
}
+/*
+Draw scaled image
+NB! tw/th specify target width/height in pixels
+*/
+void CGA_ZoomInplace(zoom_t *params, byte tw, byte th, byte *source, byte *target, uint16 ofs) {
+ byte x, y;
+
+ /*calc old/new ratio*/
+ params->scale_x = tw + 1;
+ params->xstep_l = (uint16)params->ew / params->scale_x;
+ params->xstep_h = (uint16)(((uint16)params->ew % params->scale_x) << 8) / params->scale_x;
+
+ params->scale_y = th + 1;
+ params->ystep_l = (uint16)params->eh / params->scale_y;
+ params->ystep_h = (uint16)(((uint16)params->eh % params->scale_y) << 8) / params->scale_y;
+
+ params->yval_l = 0;
+ params->yval_h = 0;
+
+ for (y = params->scale_y;;) {
+ uint16 oofs = ofs;
+ byte *pixels = params->pixels + params->yval_l * params->ow;
+ byte sc = 4 - params->xbase;
+ /*left partial pixel*/
+ byte pix = source[ofs] >> (sc * 2);
+
+ params->xval_l = 0;
+ params->xval_h = 0;
+ params->fw = 0;
+
+ for (x = params->scale_x;;) {
+ byte p = pixels[params->xval_l / 4] << ((params->xval_l % 4) * 2);
+ pix = (pix << 2) | (p >> 6);
+ if (--sc == 0) {
+ /*inner full pixel*/
+ target[ofs] = pix;
+ ofs++;
+ params->fw++;
+ sc = 4;
+ }
+ params->xval_l += params->xstep_l + ((params->xval_h + params->xstep_h) >> 8);
+ params->xval_h += params->xstep_h;
+
+ if (x == 0)
+ break;
+ if (--x == 0)
+ params->xval_l = params->ew;
+ }
+
+ /*right partial pixel*/
+ target[ofs] = (source[ofs] & ~(0xFF << (sc * 2))) | (pix << (sc * 2));
+ ofs++;
+ params->fw++;
+
+ /*ofs -= params->fw;*/
+ ofs = oofs;
+
+ ofs ^= CGA_ODD_LINES_OFS;
+ if ((ofs & CGA_ODD_LINES_OFS) == 0)
+ ofs += CGA_BYTES_PER_LINE;
+
+ params->yval_l += params->ystep_l + ((params->yval_h + params->ystep_h) >> 8);
+ params->yval_h += params->ystep_h;
+
+ if (y == 0)
+ break;
+ if (--y == 0)
+ params->yval_l = params->eh;
+ }
+}
+
+void CGA_ZoomInplaceXY(byte *pixels, byte w, byte h, byte nw, byte nh, uint16 x, uint16 y, byte *target) {
+ zoom_t zoom;
+
+ zoom.pixels = pixels;
+ zoom.ow = w;
+ zoom.oh = h;
+ zoom.ew = (w * 4) - 1;
+ zoom.eh = h - 1;
+ zoom.xbase = x % 4;
+
+ CGA_ZoomInplace(&zoom, nw, nh, target, target, CGA_CalcXY(x, y));
+}
+
} // End of namespace Chamber
diff --git a/engines/chamber/cga.h b/engines/chamber/cga.h
index 28e63c53c6f..e867f6d6849 100644
--- a/engines/chamber/cga.h
+++ b/engines/chamber/cga.h
@@ -128,6 +128,8 @@ void CGA_TraceLine(uint16 sx, uint16 ex, uint16 sy, uint16 ey, byte *source, byt
void CGA_ZoomImage(byte *pixels, byte w, byte h, byte nw, byte nh, byte *target, uint16 ofs);
void CGA_AnimZoomIn(byte *pixels, byte w, byte h, byte *target, uint16 ofs);
+void CGA_ZoomInplaceXY(byte *pixels, byte w, byte h, byte nw, byte nh, uint16 x, uint16 y, byte *target);
+
} // End of namespace Chamber
#endif
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 4d100449956..eb7458c1170 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -196,6 +196,10 @@ void ExitGame(void) {
jmp_buf restart_jmp;
+#ifdef DEBUG_ENDING
+extern TheEnd(void);
+#endif
+
Common::Error ChamberEngine::run() {
// Initialize graphics using following:
initGraphics(320, 200);
@@ -313,6 +317,12 @@ restart:;
/* Initialize cursor backup */
ProcessInput();
+#ifdef DEBUG_ENDING
+ script_byte_vars.game_paused = 5;
+ TheEnd();
+ for (;;) ;
+#endif
+
/* Main game loop */
GameLoop(frontbuffer);
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index be45a2da24b..70610b708b0 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -2505,40 +2505,185 @@ uint16 SCR_56_MorphRoom98(void) {
return 0;
}
-extern void AskDisk2(void);
-extern int16 LoadSplash(const char *filename);
-
/*
-TODO: check me
+Copy backbuffer to screen, with added vertical mirror
*/
-uint16 SCR_5B_TheEnd(void) {
+void ShowMirrored(uint16 h, uint16 ofs) {
+ uint16 x, ofs2 = ofs;
+
+ /*move 1 line up*/
+ ofs2 ^= CGA_ODD_LINES_OFS;
+ if ((ofs2 & CGA_ODD_LINES_OFS) != 0)
+ ofs2 -= CGA_BYTES_PER_LINE;
+
+ while (h--) {
+
+ for (x = 0; x < CGA_BYTES_PER_LINE; x++) {
+ frontbuffer[ofs2 + x] = frontbuffer[ofs + x] = backbuffer[ofs + x];
+ backbuffer[ofs + x] = 0;
+ }
+
+ /*move 1 line down*/
+ ofs += CGA_BYTES_PER_LINE;
+ ofs ^= CGA_ODD_LINES_OFS;
+ if ((ofs & CGA_ODD_LINES_OFS) != 0)
+ ofs -= CGA_BYTES_PER_LINE;
+
+ /*move 1 line up*/
+ ofs2 ^= CGA_ODD_LINES_OFS;
+ if ((ofs2 & CGA_ODD_LINES_OFS) != 0)
+ ofs2 -= CGA_BYTES_PER_LINE;
+ }
+}
+
+void LiftLines(int16 n, byte *source, uint16 sofs, byte *target, uint16 tofs) {
+ while (n--) {
+ memcpy(target + tofs, source + sofs, CGA_BYTES_PER_LINE);
+
+ sofs += CGA_BYTES_PER_LINE;
+ sofs ^= CGA_ODD_LINES_OFS;
+ if ((sofs & CGA_ODD_LINES_OFS) != 0)
+ sofs -= CGA_BYTES_PER_LINE;
+
+ tofs += CGA_BYTES_PER_LINE;
+ tofs ^= CGA_ODD_LINES_OFS;
+ if ((tofs & CGA_ODD_LINES_OFS) != 0)
+ tofs -= CGA_BYTES_PER_LINE;
+ }
+}
+
+#define kSaucerAnimFrames 53
+
+static void AnimSaucer(void) {
static byte image1[] = {167, 0, 146};
byte *pimage1 = image1;
byte *sequence = souco_data;
-
byte x, y, width, height;
+ uint16 xx, yy, ww, hh;
+ byte height_new, height_prev;
+ uint16 delay;
+ byte scroll_done = 0;
- /*script_ptr++; Useless since this handler never returns*/
-
- script_byte_vars.game_paused = 5;
memset(backbuffer, 0, sizeof(backbuffer) - 2); /*TODO: original bug?*/
CGA_BackBufferToRealFull();
CGA_ColorSelect(0x30);
right_button = 0;
if (!DrawPortrait(&pimage1, &x, &y, &width, &height))
- return 0;
+ return;
+
+ height_prev = 200 - 1;
+ delay = 10000;
+
+ xx = x; /*TODO: is it ok? maybe need *4*/
+ yy = y;
+ ww = 254;
+ hh = 107;
+
+ for (; sequence < souco_data + kSaucerAnimFrames * 8; sequence += 8) {
+ uint16 i, ofs, ofs2, baseofs;
+
+ if (sequence != souco_data) {
+ /*reuse portrait's params for initial state*/
+ xx = (sequence[0] << 8) | sequence[1];
+ yy = (sequence[2] << 8) | sequence[3];
+ ww = (sequence[4] << 8) | sequence[5];
+ hh = (sequence[6] << 8) | sequence[7];
+ }
+
+ hh >>= 1;
+
+ height_new = yy + hh;
+ height_prev -= (yy - 1);
- /*TODO*/
+ /*scale the saucer*/
+ CGA_ZoomInplaceXY(cur_image_pixels, width, height, ww, hh, xx, yy, backbuffer);
+
+ baseofs = CGA_CalcXY(0, yy);
+
+ if (!scroll_done) {
+ /*scroll the saucer*/
+ scroll_done = 1;
+
+ ofs2 = ofs = baseofs;
+
+ /*previous line*/
+ ofs ^= CGA_ODD_LINES_OFS;
+ if ((ofs & CGA_ODD_LINES_OFS) != 0)
+ ofs -= CGA_BYTES_PER_LINE;
+
+ for (i = 0; i < 55; i++) {
+ memcpy(backbuffer + ofs, backbuffer + ofs2, CGA_BYTES_PER_LINE);
+
+ /*next line*/
+ ofs2 += CGA_BYTES_PER_LINE;
+ ofs2 ^= CGA_ODD_LINES_OFS;
+ if ((ofs2 & CGA_ODD_LINES_OFS) != 0)
+ ofs2 -= CGA_BYTES_PER_LINE;
+
+ /*previous line line*/
+ ofs ^= CGA_ODD_LINES_OFS;
+ if ((ofs & CGA_ODD_LINES_OFS) != 0)
+ ofs -= CGA_BYTES_PER_LINE;
+ }
+
+ ofs2 = CGA_CalcXY(0, 200 - 1);
+
+ for (i = 0; i < 108; i++) {
+ LiftLines(i + 1, backbuffer, ofs, frontbuffer, ofs2);
+
+ ofs2 ^= CGA_ODD_LINES_OFS;
+ if ((ofs2 & CGA_ODD_LINES_OFS) != 0)
+ ofs2 -= CGA_BYTES_PER_LINE;
+
+ WaitVBlank();
+ WaitVBlank();
+ }
+
+ /*wipe 56 lines*/
+ memset(backbuffer + ofs2, 0, 56 / 2 * CGA_BYTES_PER_LINE);
+ ofs2 ^= CGA_ODD_LINES_OFS;
+ if ((ofs2 & CGA_ODD_LINES_OFS) == 0)
+ ofs2 += CGA_BYTES_PER_LINE;
+ memset(backbuffer + ofs2, 0, 54 / 2 * CGA_BYTES_PER_LINE);
+
+ for (i = 0xFFFF; i--;) ; /*TODO: weak delay*/
+ }
+
+ /*draw the full saucer on screen*/
+ ShowMirrored(height_prev + 1, baseofs);
+ height_prev = height_new;
+
+ WaitVBlank();
+ for (i = delay; i--;) ; /*TODO: weak delay*/
+ delay += 500;
+ }
+};
+
+extern int16 LoadSplash(const char *filename);
+
+/*
+TODO: check me
+*/
+void TheEnd(void) {
+ AnimSaucer();
while (!LoadSplash("PRES.BIN"))
AskDisk2();
CGA_BackBufferToRealFull();
+}
+
+uint16 SCR_5B_TheEnd(void) {
+ script_ptr++; /*Useless since this handler never returns*/
+ script_byte_vars.game_paused = 5;
+
+ TheEnd();
for (;;) ; /*HANG*/
return 0;
}
+
/*
Discard all inventory items
*/
Commit: f9120071134c51289d01714e556ba35c1c886939
https://github.com/scummvm/scummvm/commit/f9120071134c51289d01714e556ba35c1c886939
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Support Fxxx command
Changed paths:
engines/chamber/script.cpp
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 70610b708b0..9eeb68f4bc8 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -22,6 +22,8 @@
#define FORBIDDEN_SYMBOL_ALLOW_ALL
+#include <setjmp.h>
+
#include "common/system.h"
#include "chamber/chamber.h"
@@ -50,6 +52,8 @@ char DEBUG_SCRIPT_LOG[] = "!script.log";
namespace Chamber {
+jmp_buf script_jmp;
+
byte rand_seed;
uint16 the_command;
uint16 script_res;
@@ -537,6 +541,14 @@ uint16 SCR_4D_PriorityCommand(void) {
the_command = *script_ptr++; /*little-endian*/
the_command |= (*script_ptr++) << 8;
the_command |= 0xF000;
+
+ /*TODO: normally this should be called from the RunCommand() itself,
+ because command Fxxx may be issued from the other places as well (maybe it's not the case)
+ But that would require some sort of synchronization to avoid infinite loop
+ So jump to top interepter's loop directly from here for now
+ */
+ longjmp(script_jmp, 1);
+
return ScriptRerun;
}
@@ -4071,7 +4083,10 @@ again:;
break;
case 0xF000:
/*restore sp from keep_sp then run script*/
- TODO("SCR_RESTORE\n");
+ /*currently only supposed to work correctly from the SCR_4D_PriorityCommand handler*/
+ printf("Restore: $%X 0x%X\n", the_command, cmd);
+ /*TODO("SCR_RESTORE\n");*/
+ /*fall through*/
default:
res = RunScript(GetScriptSubroutine(cmd - 1));
}
@@ -4099,6 +4114,7 @@ again:;
uint16 RunCommandKeepSp(void) {
/*keep_sp = sp;*/
+ setjmp(script_jmp);
return RunCommand();
}
Commit: 2c179945a28f7af7e8b482f672774d3119ba8970
https://github.com/scummvm/scummvm/commit/2c179945a28f7af7e8b482f672774d3119ba8970
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Give unknown script vars more generic names
Changed paths:
engines/chamber/invent.cpp
engines/chamber/kult.cpp
engines/chamber/portrait.cpp
engines/chamber/room.cpp
engines/chamber/script.cpp
engines/chamber/script.h
diff --git a/engines/chamber/invent.cpp b/engines/chamber/invent.cpp
index 0e72f89db2d..7afd5e0097b 100644
--- a/engines/chamber/invent.cpp
+++ b/engines/chamber/invent.cpp
@@ -129,10 +129,10 @@ void OpenInventory(uint16 filtermask, uint16 filtervalue) {
case 108:
case 115:
case 117:
- script_byte_vars.byte_17A19 = 1;
+ script_byte_vars.bvar_63 = 1;
break;
default:
- script_byte_vars.byte_17A19 = 0;
+ script_byte_vars.bvar_63 = 0;
}
}
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index eb7458c1170..7e9803fc79e 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -142,7 +142,7 @@ void GameLoop(byte *target) {
goto process;
}
- if (script_byte_vars.flag_179FB)
+ if (script_byte_vars.bvar_45)
continue;
the_command = Swap16(script_word_vars.next_command2);
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index 74256e7acb3..f0ccff369b8 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -337,7 +337,7 @@ void AnimPortrait(byte layer, byte index, byte delay) {
CGA_BlitAndWait(cur_image_pixels, width, width, height, CGA_SCREENBUFFER, offs);
if (delay) {
if (ani[-1] == 37) { /*TODO: what is it?*/
- if (script_byte_vars.byte_179F3)
+ if (script_byte_vars.bvar_3D)
BlinkToRed();
else
BlinkToWhite();
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index 9a8059cd759..40e195717c8 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -337,7 +337,7 @@ void LoadZone(void) {
zone_spots_cur = (spot_t *)zptr;
zone_spr_index = 0;
script_byte_vars.dead_flag = 0;
- script_byte_vars.byte_179DB = 0;
+ script_byte_vars.bvar_25 = 0;
script_word_vars.next_command1 = BE(0);
next_command4 = 0;
next_command3 = 0;
@@ -345,24 +345,24 @@ void LoadZone(void) {
}
void ResetZone(void) {
- script_byte_vars.byte_179F9 = 0;
- script_byte_vars.byte_17A01 = 0;
- script_byte_vars.byte_17A17 = 0;
- script_byte_vars.flag_179FB = 0;
- script_byte_vars.byte_179C1 = 0;
- script_byte_vars.byte_179E9 = 0;
- script_byte_vars.byte_179EA = 0;
- script_byte_vars.byte_179BE = 0;
- script_byte_vars.byte_179EF = 0;
+ script_byte_vars.bvar_43 = 0;
+ script_byte_vars.bvar_4B = 0;
+ script_byte_vars.bvar_61 = 0;
+ script_byte_vars.bvar_45 = 0;
+ script_byte_vars.bvar_0B = 0;
+ script_byte_vars.bvar_33 = 0;
+ script_byte_vars.bvar_34 = 0;
+ script_byte_vars.bvar_08 = 0;
+ script_byte_vars.bvar_39 = 0;
script_word_vars.psi_cmds[0] = BE(0x9048);
script_word_vars.psi_cmds[1] = BE(0xA01D);
script_word_vars.psi_cmds[2] = BE(0);
script_word_vars.psi_cmds[3] = BE(0x00F7);
script_word_vars.psi_cmds[4] = BE(0x9048);
script_word_vars.psi_cmds[5] = BE(0x9048);
- script_word_vars.word_17850 = BE(0xA01C);
- script_word_vars.word_17852 = BE(0);
- script_word_vars.word_178EE = BE(0);
+ script_word_vars.wvar_0C = BE(0xA01C);
+ script_word_vars.wvar_0E = BE(0);
+ script_word_vars.wvar_AA = BE(0);
}
/*
@@ -542,7 +542,7 @@ void AnimRoomDoorClose(byte index) {
byte FindInitialSpot(void) {
spot_t *spot;
byte index;
- byte flags = script_byte_vars.byte_179B8;
+ byte flags = script_byte_vars.bvar_02;
if (flags == 0)
return 0;
flags |= SPOTFLG_80 | SPOTFLG_8;
@@ -679,7 +679,7 @@ void ChangeZone(byte index) {
script_byte_vars.prev_zone_index = script_byte_vars.zone_index;
script_byte_vars.zone_index = index;
- if (script_byte_vars.byte_17A22 != 0)
+ if (script_byte_vars.bvar_6C != 0)
spridx = 229;
else if (script_byte_vars.zone_index == 129)
spridx = 221;
@@ -790,7 +790,7 @@ void DrawRoomStatics(void) {
uint16 xx, ww;
DrawBackground(backbuffer, 0);
- arpla_y_step = script_byte_vars.byte_179E1;
+ arpla_y_step = script_byte_vars.bvar_2B;
aptr = SeekToEntry(arpla_data, script_byte_vars.zone_room - 1, &aend);
room_bounds_rect.sx = 0xFF;
@@ -806,7 +806,7 @@ void DrawRoomStatics(void) {
doors_list[doorcount++] = aptr - 3; /*TODO: check for list overflow?*/
if (doorcount == script_byte_vars.cur_spot_idx)
continue;
- if (script_byte_vars.zone_room == 32 && index == 91 && (script_byte_vars.byte_179DD & 8))
+ if (script_byte_vars.zone_room == 32 && index == 91 && (script_byte_vars.bvar_27 & 8))
continue; /*TODO: error? index may never be that high here*/
}
/*draw decor object*/
@@ -1086,7 +1086,7 @@ void PrepareCommand1(void) {
pers_list[3].area = 0;
pers_list[4].area = 0;
- if (script_byte_vars.byte_179DC >= 63)
+ if (script_byte_vars.bvar_26 >= 63)
return;
if (script_byte_vars.zone_area >= 44)
return;
@@ -1122,16 +1122,16 @@ void PrepareCommand1(void) {
pers_ptr->area = script_byte_vars.zone_area;
script_word_vars.next_command1 = BE(0xA018);
script_byte_vars.check_used_commands = 3;
- script_byte_vars.byte_179EF = flags;
+ script_byte_vars.bvar_39 = flags;
script_vars[ScrPool8_CurrentPers] = pers_ptr;
} else if (newr < 52) {
script_word_vars.next_command1 = BE(0xA019);
flags |= 4;
script_byte_vars.check_used_commands = 3;
- script_byte_vars.byte_179EF = flags;
+ script_byte_vars.bvar_39 = flags;
script_vars[ScrPool8_CurrentPers] = pers_ptr;
} else {
- script_byte_vars.byte_179EF = 0;
+ script_byte_vars.bvar_39 = 0;
return;
}
} else {
@@ -1144,16 +1144,16 @@ void PrepareCommand1(void) {
pers_ptr->area = script_byte_vars.zone_area;
script_word_vars.next_command1 = BE(0xA018);
script_byte_vars.check_used_commands = 3;
- script_byte_vars.byte_179EF = flags;
+ script_byte_vars.bvar_39 = flags;
script_vars[ScrPool8_CurrentPers] = pers_ptr;
} else if (newr < 52) {
script_word_vars.next_command1 = BE(0xA019);
flags |= 4;
script_byte_vars.check_used_commands = 3;
- script_byte_vars.byte_179EF = flags;
+ script_byte_vars.bvar_39 = flags;
script_vars[ScrPool8_CurrentPers] = pers_ptr;
} else {
- script_byte_vars.byte_179EF = 0;
+ script_byte_vars.bvar_39 = 0;
return;
}
}
@@ -1165,7 +1165,7 @@ Vorts AI
void PrepareCommand3(void) {
spot_t *spot;
- if ((script_byte_vars.zone_area != 8) || !(script_byte_vars.byte_179EC & 0x80)) {
+ if ((script_byte_vars.zone_area != 8) || !(script_byte_vars.bvar_36 & 0x80)) {
pers_list[0].flags &= ~PERSFLG_40;
pers_list[34].flags &= ~PERSFLG_40;
pers_list[35].flags &= ~PERSFLG_40;
@@ -1184,7 +1184,7 @@ void PrepareCommand3(void) {
pers_list[0].area = 0;
pers_list[34].area = 0;
pers_list[35].area = 0;
- script_byte_vars.byte_179EC &= 0x80; /*TODO: is this correct? |= ?*/
+ script_byte_vars.bvar_36 &= 0x80; /*TODO: is this correct? |= ?*/
if (script_byte_vars.rand_value < 39) {
pers_list[0].area = script_byte_vars.zone_area;
next_command3 = 0xA015; /*VortLeave*/
@@ -1193,7 +1193,7 @@ void PrepareCommand3(void) {
else
return;
}
- script_byte_vars.byte_179EC |= 1;
+ script_byte_vars.bvar_36 |= 1;
next_ticks3 = Swap16(script_word_vars.timer_ticks2) + 5;
return;
}
@@ -1205,7 +1205,7 @@ void PrepareCommand3(void) {
pers_list[0].area = 0;
pers_list[34].area = 0;
pers_list[35].area = 0;
- script_byte_vars.byte_179EC &= 0x80; /*TODO: is this correct? |= ?*/
+ script_byte_vars.bvar_36 &= 0x80; /*TODO: is this correct? |= ?*/
}
/*
@@ -1214,7 +1214,7 @@ Turkey AI
void PrepareCommand4(void) {
spot_t *spot;
- if (script_byte_vars.zone_area == 59 && script_byte_vars.byte_17A04 == 0) {
+ if (script_byte_vars.zone_area == 59 && script_byte_vars.bvar_4E == 0) {
pers_list[5].area = 59;
return;
}
@@ -1290,8 +1290,6 @@ void RestoreScreenOfSpecialRoom(void) {
}
}
-byte byte_17A1C = 0;
-
void SetAnim127Sprite(byte flags, byte spridx) {
byte *lutin_entry, *lutin_entry_end;
lutin_entry = SeekToEntry(lutin_data, 127, &lutin_entry_end);
@@ -1301,9 +1299,9 @@ void SetAnim127Sprite(byte flags, byte spridx) {
case 58:
case 40:
if (flags == ITEMFLG_80)
- byte_17A1C += 1;
+ script_byte_vars.bvar_66 += 1;
else
- byte_17A1C -= 1;
+ script_byte_vars.bvar_66 -= 1;
break;
}
}
@@ -1639,10 +1637,10 @@ TODO: rename this
void UpdateTimedRects1(void) {
uint16 elapsed;
- if (script_byte_vars.flag_179FB != 0)
+ if (script_byte_vars.bvar_45 != 0)
return;
- if (script_byte_vars.byte_179DC >= 63)
+ if (script_byte_vars.bvar_26 >= 63)
return;
script_word_vars.next_command2 = BE(0);
@@ -1654,7 +1652,7 @@ void UpdateTimedRects1(void) {
}
if (pers_list[22].flags & PERSFLG_20)
- script_byte_vars.byte_179E6 |= 4;
+ script_byte_vars.bvar_30 |= 4;
elapsed = Swap16(script_word_vars.timer_ticks2);
if (elapsed < next_ticks2)
@@ -1662,38 +1660,38 @@ void UpdateTimedRects1(void) {
next_ticks2 = elapsed + 30;
- script_byte_vars.byte_179F5 = *timed_seq_ptr++;
+ script_byte_vars.bvar_3F = *timed_seq_ptr++;
if (timed_seq_ptr == timed_seq + sizeof(timed_seq))
timed_seq_ptr = timed_seq;
- script_byte_vars.byte_179F6 = *timed_seq_ptr++;
+ script_byte_vars.bvar_40 = *timed_seq_ptr++;
- if (script_byte_vars.byte_179F5 == 56) {
- script_byte_vars.byte_179E6 &= ~4;
+ if (script_byte_vars.bvar_3F == 56) {
+ script_byte_vars.bvar_30 &= ~4;
pers_list[22].flags &= ~(PERSFLG_20 | PERSFLG_40 | PERSFLG_80);
pers_list[22].index = 55;
if (pers_list[13].area == 56) {
pers_list[13].flags &= ~(PERSFLG_20 | PERSFLG_40 | PERSFLG_80);
- script_byte_vars.byte_179F7 = 1;
+ script_byte_vars.bvar_41 = 1;
}
}
- if (script_byte_vars.byte_179F5 == 12 && script_byte_vars.byte_179F6 == 10) {
- script_byte_vars.byte_179F7 = 0;
+ if (script_byte_vars.bvar_3F == 12 && script_byte_vars.bvar_40 == 10) {
+ script_byte_vars.bvar_41 = 0;
if (pers_list[13].area == 56) {
- script_byte_vars.byte_179F6 = 44;
+ script_byte_vars.bvar_40 = 44;
timed_seq_ptr = timed_seq + 4;
}
}
- pers_list[22].area = script_byte_vars.byte_179F6;
+ pers_list[22].area = script_byte_vars.bvar_40;
- if (script_byte_vars.byte_179F7 != 0) {
- pers_list[13].area = script_byte_vars.byte_179F6;
- pers_list[20].area = script_byte_vars.byte_179F6;
- pers_list[21].area = script_byte_vars.byte_179F6;
+ if (script_byte_vars.bvar_41 != 0) {
+ pers_list[13].area = script_byte_vars.bvar_40;
+ pers_list[20].area = script_byte_vars.bvar_40;
+ pers_list[21].area = script_byte_vars.bvar_40;
- if (script_byte_vars.zone_area == script_byte_vars.byte_179F5) {
+ if (script_byte_vars.zone_area == script_byte_vars.bvar_3F) {
static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
@@ -1707,7 +1705,7 @@ void UpdateTimedRects1(void) {
return;
}
- if (script_byte_vars.zone_area == script_byte_vars.byte_179F6) {
+ if (script_byte_vars.zone_area == script_byte_vars.bvar_40) {
static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
@@ -1744,7 +1742,7 @@ void UpdateTimedRects1(void) {
if (pers_list[22].flags & 0x40)
return;
- if (script_byte_vars.zone_area == script_byte_vars.byte_179F5) {
+ if (script_byte_vars.zone_area == script_byte_vars.bvar_3F) {
static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
@@ -1755,7 +1753,7 @@ void UpdateTimedRects1(void) {
return;
}
- if (script_byte_vars.zone_area == script_byte_vars.byte_179F6) {
+ if (script_byte_vars.zone_area == script_byte_vars.bvar_40) {
static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
@@ -1784,9 +1782,9 @@ void UpdateTimedRects2(void) {
if (elapsed < 60 * 60)
return;
- if (script_byte_vars.byte_179DC < 63) {
- script_byte_vars.byte_179ED = 3;
- script_byte_vars.byte_179DC = (script_byte_vars.zone_area < 44) ? 255 : 63;
+ if (script_byte_vars.bvar_26 < 63) {
+ script_byte_vars.bvar_37 = 3;
+ script_byte_vars.bvar_26 = (script_byte_vars.zone_area < 44) ? 255 : 63;
pers_list[13].area = 0;
pers_list[14].area = 0;
pers_list[15].area = 0;
@@ -1805,8 +1803,8 @@ void UpdateTimedRects2(void) {
return;
if (elapsed < 120 * 60) {
- script_byte_vars.byte_179ED = 2;
- script_byte_vars.byte_17A04 = 1;
+ script_byte_vars.bvar_37 = 2;
+ script_byte_vars.bvar_4E = 1;
if ((script_byte_vars.zone_area != 61)
&& (script_byte_vars.zone_area >= 59 && script_byte_vars.zone_area < 75))
script_word_vars.next_command2 = BE(0xC012);
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 9eeb68f4bc8..ed77b3a6336 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -301,7 +301,7 @@ uint16 SCR_4_StealZapstik(void) {
pers->index &= ~0x18;
script_vars[ScrPool3_CurrentItem] = &inventory_items[38 + (script_byte_vars.cur_pers - 1) - 9];
- script_byte_vars.byte_179F1++;
+ script_byte_vars.bvar_3B++;
BounceCurrentItem(ITEMFLG_80, 85); /*bounce to inventory*/
@@ -1322,16 +1322,16 @@ uint16 SCR_42_LoadZone(void) {
zone_drawn = 0;
if (right_button)
- script_byte_vars.byte_179B8 = 0;
+ script_byte_vars.bvar_02 = 0;
else {
if ((script_byte_vars.cur_spot_flags & (SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8)) == 0)
- script_byte_vars.byte_179B8 = script_byte_vars.cur_spot_flags & 7;
+ script_byte_vars.bvar_02 = script_byte_vars.cur_spot_flags & 7;
else if ((script_byte_vars.cur_spot_flags & ((SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8))) == SPOTFLG_8) {
zone_drawn = 1;
AnimRoomDoorOpen(script_byte_vars.cur_spot_idx);
- script_byte_vars.byte_179B8 = script_byte_vars.cur_spot_flags & 7;
+ script_byte_vars.bvar_02 = script_byte_vars.cur_spot_flags & 7;
} else
- script_byte_vars.byte_179B8 = 0;
+ script_byte_vars.bvar_02 = 0;
}
UpdateZoneSpot(index);
ChangeZone(index);
@@ -1341,9 +1341,9 @@ uint16 SCR_42_LoadZone(void) {
DrawRoomStatics();
- if (script_byte_vars.byte_17A15 != 0) {
- RedrawRoomStatics(script_byte_vars.byte_17A15, 0);
- script_byte_vars.byte_17A15 = 0;
+ if (script_byte_vars.bvar_5F != 0) {
+ RedrawRoomStatics(script_byte_vars.bvar_5F, 0);
+ script_byte_vars.bvar_5F = 0;
}
BackupSpotsImages();
@@ -1504,7 +1504,7 @@ uint16 SCR_3D_ActionsMenu(void) {
script_byte_vars.used_commands++;
- if (script_byte_vars.byte_179F9 == 0 && script_byte_vars.check_used_commands < script_byte_vars.used_commands) {
+ if (script_byte_vars.bvar_43 == 0 && script_byte_vars.check_used_commands < script_byte_vars.used_commands) {
the_command = Swap16(script_word_vars.next_command1);
if (the_command)
return ScriptRerun;
@@ -1685,7 +1685,7 @@ Move a Hand in Who Will Be Saved
*/
uint16 SCR_41_LiftHand(void) {
script_ptr++;
- RedrawRoomStatics(92, script_byte_vars.byte_179E1);
+ RedrawRoomStatics(92, script_byte_vars.bvar_2B);
CGA_BackBufferToRealFull();
PlaySound(31);
return 0;
@@ -1750,7 +1750,7 @@ uint16 SCR_30_Fight(void) {
script_byte_vars.fight_status = 0;
- if (script_byte_vars.byte_179F3 == 0) {
+ if (script_byte_vars.bvar_3D == 0) {
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];
@@ -1759,7 +1759,7 @@ uint16 SCR_30_Fight(void) {
if (strenght != 1 && (pers->flags & PERSFLG_80))
strenght--;
- if (script_byte_vars.room_items != 0 || script_byte_vars.byte_17A1C != 0)
+ if (script_byte_vars.room_items != 0 || script_byte_vars.bvar_66 != 0)
strenght--;
}
@@ -1892,7 +1892,7 @@ fightentry_t fightlist3[] = {
uint16 SCR_31_Fight2(void) {
script_ptr++;
- if (script_byte_vars.byte_179F9 != 18) {
+ if (script_byte_vars.bvar_43 != 18) {
pers_t *pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]);
fight_pers_ofs = (byte *)pers - (byte *)pers_list; /*TODO check size*/
pers->flags |= PERSFLG_40;
@@ -1964,24 +1964,24 @@ uint16 SCR_31_Fight2(void) {
}
void FightWin(void) {
- script_byte_vars.byte_17A1D = 0;
+ script_byte_vars.bvar_67 = 0;
- if (script_byte_vars.byte_179F9 != 18 && *spot_sprite != 0) {
+ if (script_byte_vars.bvar_43 != 18 && *spot_sprite != 0) {
CGA_RestoreImage(*spot_sprite, frontbuffer);
CGA_RestoreImage(*spot_sprite, backbuffer);
- if (script_byte_vars.byte_179F3 == 0
- && script_byte_vars.byte_17A16 == 0
+ if (script_byte_vars.bvar_3D == 0
+ && script_byte_vars.bvar_60 == 0
&& script_byte_vars.room_items != 0
&& fight_mode == 0) {
- script_byte_vars.byte_17A1D = 1;
+ script_byte_vars.bvar_67 = 1;
PlaySound(149);
PlayAnim(40, found_spot->sx, found_spot->sy);
}
}
- prev_fight_mode = script_byte_vars.byte_179F3;
- script_byte_vars.byte_179F3 = 0;
+ prev_fight_mode = script_byte_vars.bvar_3D;
+ script_byte_vars.bvar_3D = 0;
}
uint16 SCR_32_FightWin(void) {
@@ -2026,9 +2026,9 @@ uint16 SCR_60_ReviveCadaver(void) {
FindAndSelectSpot(38 * 5);
- script_byte_vars.byte_17A16 = 1;
+ script_byte_vars.bvar_60 = 1;
FightWin();
- script_byte_vars.byte_17A16 = 0;
+ script_byte_vars.bvar_60 = 0;
pers_list[38].area = 0;
FindAndSelectSpot(fight_pers_ofs);
@@ -2366,48 +2366,48 @@ uint16 SCR_50_BounceItemToInventory(void) {
Take away Protozorq's zapstik and bounce it to room
*/
uint16 SCR_4B_ProtoDropZapstik(void) {
- pers_t *pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]);
+ pers_t *pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]);
- script_ptr++;
+ script_ptr++;
- if ((pers->index & 0x38) != 0x30)
- return 0;
+ if ((pers->index & 0x38) != 0x30)
+ return 0;
- pers->index &= ~0x18;
+ pers->index &= ~0x18;
- script_vars[ScrPool3_CurrentItem] = &inventory_items[38 + (script_byte_vars.cur_pers - 1) - 9];
+ script_vars[ScrPool3_CurrentItem] = &inventory_items[38 + (script_byte_vars.cur_pers - 1) - 9];
- BounceCurrentItem(ITEMFLG_40, 43);
+ BounceCurrentItem(ITEMFLG_40, 43);
- return 0;
+ return 0;
}
/*Take away a person's item*/
void TakePersonsItem(void) {
- if (pers_ptr->item != 0) {
- item_t *item = &inventory_items[pers_ptr->item - 1];
- pers_ptr->item = 0;
-
- script_vars[ScrPool3_CurrentItem] = item;
- script_byte_vars.byte_179F1++;
- script_byte_vars.byte_17A23[pers_ptr->index >> 6] = item->name; /*TODO: check these index bits*/
- BounceCurrentItem(ITEMFLG_80, 85);
- the_command = 0x90AA; /*OK*/
- } else
- the_command = 0x9140; /*NOTHING ON HIM*/
+ if (pers_ptr->item != 0) {
+ item_t *item = &inventory_items[pers_ptr->item - 1];
+ pers_ptr->item = 0;
+
+ script_vars[ScrPool3_CurrentItem] = item;
+ script_byte_vars.bvar_3B++;
+ script_byte_vars.bvar_6D[pers_ptr->index >> 6] = item->name; /*TODO: check these index bits*/
+ BounceCurrentItem(ITEMFLG_80, 85);
+ the_command = 0x90AA; /*OK*/
+ } else
+ the_command = 0x9140; /*NOTHING ON HIM*/
}
uint16 SCR_2F_TakePersonsItem() {
- script_ptr++;
- TakePersonsItem();
- return ScriptRerun;
+ script_ptr++;
+ TakePersonsItem();
+ return ScriptRerun;
}
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?*/
+ if (script_byte_vars.bvar_26 >= 63) /*TODO: hang?*/
return 0;
script_ptr++;
@@ -3052,7 +3052,7 @@ Advance time
*/
uint16 CMD_5_Wait(void) {
- script_byte_vars.byte_179DB++;
+ script_byte_vars.bvar_25++;
script_word_vars.timer_ticks2 = Swap16(Swap16(script_word_vars.timer_ticks2) + 300);
the_command = next_command3;
@@ -3063,7 +3063,7 @@ uint16 CMD_5_Wait(void) {
script_byte_vars.used_commands = script_byte_vars.check_used_commands;
- the_command = Swap16(script_word_vars.word_17852);
+ the_command = Swap16(script_word_vars.wvar_0E);
if (the_command == 0) {
if (script_word_vars.next_command1 == 0) {
@@ -3071,7 +3071,7 @@ uint16 CMD_5_Wait(void) {
RunCommand();
}
} else {
- if (script_byte_vars.byte_179DC >= 63 && script_byte_vars.zone_area < 22 && script_byte_vars.zone_area != 1)
+ if (script_byte_vars.bvar_26 >= 63 && script_byte_vars.zone_area < 22 && script_byte_vars.zone_area != 1)
the_command = 0x9005;
return ScriptRerun;
}
@@ -3155,7 +3155,7 @@ uint16 CMD_A_PsiSolarEyes(void) {
CGA_BackBufferToRealFull();
}
- the_command = Swap16(script_word_vars.word_178EE);
+ the_command = Swap16(script_word_vars.wvar_AA);
RunCommand();
script_byte_vars.cur_spot_flags = 0xFF;
@@ -3196,8 +3196,8 @@ uint16 CMD_B_PsiStickyFingers(void) {
if (!ConsumePsiEnergy(3))
return 0;
- if (script_byte_vars.byte_179F9 != 0) {
- the_command = Swap16(script_word_vars.word_178F0);
+ if (script_byte_vars.bvar_43 != 0) {
+ the_command = Swap16(script_word_vars.wvar_AC);
return ScriptRerun;
}
@@ -3212,7 +3212,7 @@ uint16 CMD_B_PsiStickyFingers(void) {
if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(0 * 2) == 0)
the_command = Swap16(script_word_vars.psi_cmds[0]);
- if (script_byte_vars.byte_179DC >= 63
+ if (script_byte_vars.bvar_26 >= 63
&& script_byte_vars.zone_area < 22
&& script_byte_vars.zone_area != 1)
the_command = 0x9005;
@@ -3224,8 +3224,8 @@ uint16 CMD_C_PsiKnowMind(void) {
if (!ConsumePsiEnergy(1))
return 0;
- if (script_byte_vars.byte_179F9 != 0) {
- the_command = Swap16(script_word_vars.word_178F2);
+ if (script_byte_vars.bvar_43 != 0) {
+ the_command = Swap16(script_word_vars.wvar_AE);
return ScriptRerun;
}
@@ -3241,12 +3241,12 @@ uint16 CMD_D_PsiBrainwarp(void) {
if (!ConsumePsiEnergy(2))
return 0;
- if (script_byte_vars.byte_179F9 == 0) {
+ if (script_byte_vars.bvar_43 == 0) {
BackupScreenOfSpecialRoom();
ProcessMenu();
if (script_byte_vars.cur_spot_idx == 0) {
- the_command = Swap16(script_word_vars.word_17850);
+ the_command = Swap16(script_word_vars.wvar_0C);
script_byte_vars.dead_flag = 0;
return ScriptRerun;
}
@@ -3258,7 +3258,7 @@ uint16 CMD_D_PsiBrainwarp(void) {
}
}
- if (script_byte_vars.byte_179F9 == 18) {
+ if (script_byte_vars.bvar_43 == 18) {
script_byte_vars.dead_flag = 1;
script_byte_vars.tries_left = 2;
return 0;
@@ -3268,7 +3268,7 @@ uint16 CMD_D_PsiBrainwarp(void) {
script_byte_vars.dead_flag = script_byte_vars.cur_spot_idx;
script_byte_vars.tries_left = 2;
the_command = 0;
- if (script_byte_vars.byte_179F9 == 0) {
+ if (script_byte_vars.bvar_43 == 0) {
PlayAnim(39, found_spot->sx + 8 / 4, found_spot->sy - 10);
RestoreScreenOfSpecialRoom();
return ScriptRerun;
@@ -3286,8 +3286,8 @@ uint16 CMD_E_PsiZoneScan(void) {
if (!ConsumePsiEnergy(1))
return 0;
- if (script_byte_vars.byte_179F9 != 0) {
- the_command = Swap16(script_word_vars.word_178FC);
+ if (script_byte_vars.bvar_43 != 0) {
+ the_command = Swap16(script_word_vars.wvar_B8);
return ScriptRerun;
}
@@ -3331,8 +3331,8 @@ uint16 CMD_F_PsiPsiShift(void) {
if (!ConsumePsiEnergy(3))
return 0;
- if (script_byte_vars.byte_179F9 != 0) {
- the_command = Swap16(script_word_vars.word_178F4);
+ if (script_byte_vars.bvar_43 != 0) {
+ the_command = Swap16(script_word_vars.wvar_B0);
return ScriptRerun;
}
@@ -3355,10 +3355,10 @@ uint16 CMD_10_PsiExtremeViolence(void) {
if (!ConsumePsiEnergy(8))
return 0;
- script_byte_vars.byte_179F3 = 1;
+ script_byte_vars.bvar_3D = 1;
- if (script_byte_vars.byte_179F9 != 0) {
- the_command = Swap16(script_word_vars.word_178F6);
+ if (script_byte_vars.bvar_43 != 0) {
+ the_command = Swap16(script_word_vars.wvar_B2);
return ScriptRerun;
}
@@ -3366,17 +3366,17 @@ uint16 CMD_10_PsiExtremeViolence(void) {
if (script_byte_vars.cur_spot_idx == 0) {
the_command = Swap16(script_word_vars.psi_cmds[4]);
- script_byte_vars.byte_179F3 = 0;
+ script_byte_vars.bvar_3D = 0;
return ScriptRerun;
}
command = GetZoneObjCommand(4 * 2);
if ((command & 0xF000) == 0x9000)
- script_byte_vars.byte_179F3 = 0;
+ script_byte_vars.bvar_3D = 0;
else if (command == 0) {
the_command = Swap16(script_word_vars.psi_cmds[4]);
- script_byte_vars.byte_179F3 = 0;
+ script_byte_vars.bvar_3D = 0;
}
return ScriptRerun;
@@ -3389,10 +3389,10 @@ uint16 CMD_11_PsiTuneIn(void) {
if (!ConsumePsiEnergy(4))
return 0;
- if (script_byte_vars.byte_179F9 != 0)
- command = Swap16(script_word_vars.word_178F8);
+ if (script_byte_vars.bvar_43 != 0)
+ command = Swap16(script_word_vars.wvar_B4);
else {
- if (script_byte_vars.byte_179DC < 63 || script_byte_vars.zone_area >= 22)
+ if (script_byte_vars.bvar_26 < 63 || script_byte_vars.zone_area >= 22)
command = Swap16(script_word_vars.psi_cmds[3]);
else
command = 275;
@@ -3542,7 +3542,7 @@ uint16 CMD_13_ActivateFountain(void) {
byte x, y, w, h;
uint16 i, j;
- script_byte_vars.byte_17A20 = 1;
+ script_byte_vars.bvar_6A = 1;
for (i = 0; i < 10; i++) {
DrawRoomStaticObject(water1, &x, &y, &w, &h);
WaitVBlank();
@@ -3620,7 +3620,7 @@ uint16 CMD_15_VortLeave(void) {
pers = &pers_list[34];
anim = &vortanims_ptr->field_7;
} else {
- script_byte_vars.byte_179EC |= 0x80;
+ script_byte_vars.bvar_36 |= 0x80;
pers_list[35].area = 0;
pers_list[0].flags = pers_list[35].flags;
@@ -3644,7 +3644,7 @@ uint16 CMD_15_VortLeave(void) {
FindAndSelectSpot(0);
AnimateSpot(anim);
- script_byte_vars.byte_179EC &= 0x80;
+ script_byte_vars.bvar_36 &= 0x80;
return 0;
}
@@ -3675,7 +3675,7 @@ uint16 CMD_18_AspirantLeave(void) {
if ((pers_ptr->flags & PERSFLG_40) == 0) {
spot_ptr->flags &= ~SPOTFLG_80;
FindAndSelectSpot(script_byte_vars.quest_item_ofs);
- script_byte_vars.byte_179EF = 0;
+ script_byte_vars.bvar_39 = 0;
AnimateSpot(&anim33);
}
diff --git a/engines/chamber/script.h b/engines/chamber/script.h
index 7c1b29e98e6..d89e257bede 100644
--- a/engines/chamber/script.h
+++ b/engines/chamber/script.h
@@ -45,132 +45,138 @@ enum ScriptPools {
typedef struct script_byte_vars_t {
byte zone_index; /* 0 */
byte zone_room; /* 1 */
- byte byte_179B8; /* 2 */
+ byte bvar_02; /* 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 bvar_06; /* 6 */
+ byte bvar_07; /* 7 */
+ byte bvar_08; /* 8 */
+ byte bvar_09; /* 9 */
+ byte bvar_0A; /* A */
+ byte bvar_0B; /* B */
byte zone_area; /* C */
byte dead_flag; /* D */
volatile byte timer_ticks; /* E */
byte gauss_phase; /* F */
- byte unused_179C6; /* 10 */
+
+ byte bvar_10; /* 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 bvar_15; /* 15 */
+ byte bvar_16; /* 16 */
+ byte bvar_17; /* 17 */
+ byte bvar_18; /* 18 */
+ byte bvar_19; /* 19 */
+ byte bvar_1A; /* 1A */
+ byte bvar_1B; /* 1B */
+ byte bvar_1C; /* 1C */
+ byte bvar_1D; /* 1D */
+ byte bvar_1E; /* 1E */
+ byte bvar_1F; /* 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 bvar_24; /* 24 */
+ byte bvar_25; /* 25 */
+ byte bvar_26; /* 26 */
+ byte bvar_27; /* 27 */
+ byte bvar_28; /* 28 */
+ byte bvar_29; /* 29 */
+ byte bvar_2A; /* 2A */
+ byte bvar_2B; /* 2B */ /*TODO: hand height*/
byte check_used_commands; /* 2C */
- byte byte_179E3; /* 2D */
+ byte bvar_2D; /* 2D */
byte palette_index; /* 2E */
- byte byte_179E5; /* 2F */
- byte byte_179E6; /* 30 */
+ byte bvar_2F; /* 2F */
+
+ byte bvar_30; /* 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 bvar_32; /* 32 */
+ byte bvar_33; /* 33 */
+ byte bvar_34; /* 34 */
+ byte bvar_35; /* 35 */
+ byte bvar_36; /* 36 */
+ byte bvar_37; /* 37 */
byte zone_area_copy; /* 38 */
- byte byte_179EF; /* 39 */
+ byte bvar_39; /* 39 */
byte quest_item_ofs; /* 3A */
- byte byte_179F1; /* 3B */
+ byte bvar_3B; /* 3B */
byte fight_status; /* 3C */
- byte byte_179F3; /* 3D */
+ byte bvar_3D; /* 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 bvar_3F; /* 3F */
+
+ byte bvar_40; /* 40 */
+ byte bvar_41; /* 41 */
+ byte bvar_42; /* 42 */
+ byte bvar_43; /* 43 */
byte dirty_rect_kind; /* 44 */
- byte flag_179FB; /* 45 */
- byte byte_179FC; /* 46 */
+ byte bvar_45; /* 45 */
+ byte bvar_46; /* 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 bvar_4A; /* 4A */
+ byte bvar_4B; /* 4B */
+ byte bvar_4C; /* 4C */
+ byte bvar_4D; /* 4D */
+ byte bvar_4E; /* 4E */
+ byte bvar_4F; /* 4F */
+
+ byte bvar_50; /* 50 */
+ byte bvar_51; /* 51 */
+ byte bvar_52; /* 52 */
+ byte bvar_53; /* 53 */
+ byte bvar_54; /* 54 */
+ byte bvar_55; /* 55 */
+ byte bvar_56; /* 56 */
byte need_draw_spots; /* 57 */
- byte byte_17A0E; /* 58 */
- byte byte_17A0F; /* 59 */
+ byte bvar_58; /* 58 */
+ byte bvar_59; /* 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 bvar_5B; /* 5B */
+ byte bvar_5C; /* 5C */
+ byte bvar_5D; /* 5D */
+ byte bvar_5E; /* 5E */
+ byte bvar_5F; /* 5F */
+
+ byte bvar_60; /* 60 */
+ byte bvar_61; /* 61 */
+ byte bvar_62; /* 62 */
+ byte bvar_63; /* 63 */
+ byte bvar_64; /* 64 */
+ byte bvar_65; /* 65 */
+ byte bvar_66; /* 66 */
+ byte bvar_67; /* 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 */
+ byte bvar_69; /* 69 */
+ byte bvar_6A; /* 6A */
+ byte bvar_6B; /* 6B */
+ byte bvar_6C; /* 6C */
+ byte bvar_6D[4]; /* 6D */
} script_byte_vars_t;
/*2-byte long vars, in BIG-endian order*/
typedef struct script_word_vars_t {
- uint16 psi_cmds[6]; /* 0 */
- uint16 word_17850; /* C */
- uint16 word_17852; /* E */
+ uint16 psi_cmds[6]; /* 0 */
+ uint16 wvar_0C; /* C */
+ uint16 wvar_0E; /* 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 wvar_AA; /* AA */
+ uint16 wvar_AC; /* AC */
+ uint16 wvar_AE; /* AE */
+ uint16 wvar_B0; /* B0 */
+ uint16 wvar_B2; /* B2 */
+ uint16 wvar_B4; /* B4 */
uint16 next_command2; /* B6 */
- uint16 word_178FC; /* B8 */
+ uint16 wvar_B8; /* B8 */
} script_word_vars_t;
extern void *script_vars[ScrPools_MAX];
Commit: 5c82720d489ca6cd7c4f709d233d3c3045fad97a
https://github.com/scummvm/scummvm/commit/5c82720d489ca6cd7c4f709d233d3c3045fad97a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Replace many numbers with enums, add comments
Changed paths:
A engines/chamber/enums.h
engines/chamber/common.h
engines/chamber/invent.cpp
engines/chamber/kult.cpp
engines/chamber/portrait.cpp
engines/chamber/room.cpp
engines/chamber/room.h
engines/chamber/savegame.cpp
engines/chamber/script.cpp
engines/chamber/script.h
engines/chamber/scrvars.h
diff --git a/engines/chamber/common.h b/engines/chamber/common.h
index f42e2ea5965..42e9a0c3b9d 100644
--- a/engines/chamber/common.h
+++ b/engines/chamber/common.h
@@ -80,9 +80,15 @@ typedef struct rect_t {
#endif
#if 1
+/*win in fights*/
#define CHEAT
#endif
+#if 1
+/*never lose to the Skull Trader*/
+#define CHEAT_TRADER
+#endif
+
} // End of namespace Chamber
#endif
diff --git a/engines/chamber/enums.h b/engines/chamber/enums.h
new file mode 100644
index 00000000000..3a2707395aa
--- /dev/null
+++ b/engines/chamber/enums.h
@@ -0,0 +1,241 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_ENUMS_H
+#define CHAMBER_ENUMS_H
+
+namespace Chamber {
+
+/*game items, mirrors inventory_items (except kItemNone)*/
+enum Items {
+ kItemNone = 0,
+
+ kItemSkull1 = 1,
+ kItemSkull2 = 2,
+ kItemSkull3 = 3,
+ kItemSkull4 = 4,
+ kItemSkull5 = 5,
+
+ kItemRope1 = 6,
+ kItemRope2 = 7,
+ kItemRope3 = 8,
+ kItemRope4 = 9,
+ kItemRope5 = 10,
+
+ kItemFly1 = 11,
+ kItemFly2 = 12,
+ kItemFly3 = 13,
+ kItemFly4 = 14,
+
+ kItemGoblet1 = 15,
+ kItemGoblet2 = 16,
+ kItemGoblet3 = 17,
+ kItemGoblet4 = 18,
+
+ kItemDagger1 = 19,
+ kItemDagger2 = 20,
+ kItemDagger3 = 21,
+ kItemDagger4 = 22,
+
+ kItemLantern1 = 23,
+ kItemLantern2 = 24,
+ kItemLantern3 = 25,
+ kItemLantern4 = 26,
+
+ kItemBlueSpider1 = 27,
+ kItemBlueSpider2 = 28,
+ kItemBlueSpider3 = 29,
+ kItemBlueSpider4 = 30,
+
+ kItemRedSpider1 = 31,
+ kItemRedSpider2 = 32,
+ kItemRedSpider3 = 33,
+ kItemRedSpider4 = 34,
+
+ kItemDie1 = 35,
+ kItemDie2 = 36,
+ kItemDie3 = 37,
+ kItemDie4 = 38,
+
+ kItemZapstik1 = 39,
+ kItemZapstik2 = 40,
+ kItemZapstik3 = 41,
+ kItemZapstik4 = 42,
+ kItemZapstik5 = 43,
+ kItemZapstik6 = 44,
+ kItemZapstik7 = 45,
+ kItemZapstik8 = 46,
+ kItemZapstik9 = 47,
+ kItemZapstik10 = 48,
+ kItemZapstik11 = 49,
+ kItemZapstik12 = 50,
+ kItemZapstik13 = 51,
+ kItemZapstik14 = 52,
+
+ kItemMask = 53,
+ kItemWhistle = 54,
+ kItemEgg1 = 55,
+ kItemBlade = 56,
+ kItemChopper = 57,
+ kItemZorq = 58,
+ kItemSaura = 59,
+ kItemFlask = 60,
+ kItemBean = 61,
+ kItemEgg2 = 62,
+ kItemEgg3 = 63
+};
+
+/*game persons, mirrors pers_list*/
+enum Persons {
+ kPersVort = 0,
+
+ kPersAspirant1 = 1,
+ kPersAspirant2 = 2,
+ kPersAspirant3 = 3,
+ kPersAspirant4 = 4,
+
+ kPersTurkey = 5,
+
+ kPersPriestess1 = 6,
+ kPersPriestess2 = 7,
+
+ kPersMaster = 8,
+
+ kPersProtozorq1 = 9,
+ kPersProtozorq2 = 10,
+ kPersProtozorq3 = 11,
+ kPersProtozorq4 = 12,
+ kPersProtozorq5 = 13,
+ kPersProtozorq6 = 14,
+ kPersProtozorq7 = 15,
+ kPersProtozorq8 = 16,
+ kPersProtozorq9 = 17,
+ kPersProtozorq10 = 18,
+ kPersProtozorq11 = 19,
+ kPersProtozorq12 = 20,
+ kPersProtozorq13 = 21,
+ kPersProtozorq14 = 22,
+
+ kPersPoormouth = 23,
+ kPersKhele = 24,
+ kPersMistress = 25,
+ kPersDeilos = 26,
+ kPersScifi = 27,
+ kPersNormajeen = 28,
+ kPersAsh = 29,
+ kPersMonkey = 30,
+ kPersHarssk = 31,
+ kPersZorq = 32,
+ kPersQriich = 33,
+
+ kPersVort2 = 34,
+ kPersVort3 = 35,
+
+ kPersPriestess3 = 36,
+ kPersPriestess4 = 37,
+
+ kPersCadaver = 38,
+
+ kPersTurkey1 = 39,
+ kPersTurkey2 = 40
+};
+
+#define PersonOffset(p) ((p) * 5)
+
+enum Areas {
+ kAreaNone = 0,
+ kAreaTheMastersEye = 1,
+ kAreaTheMastersOrbit1 = 2,
+ kAreaTheMastersOrbit2 = 3,
+ kAreaTheMastersOrbit3 = 5,
+ kAreaTheReturn = 8,
+ kAreaTheRing1 = 10,
+ kAreaTheRing2 = 12,
+ kAreaTheRing3 = 14,
+ kAreaTheRing4 = 16,
+ kAreaTheRing5 = 18,
+ kAreaTheRing6 = 20,
+ kAreaDeProfundis = 22,
+ kAreaTheWall = 24,
+ kAreaTheInfidelsTomb1 = 25,
+ kAreaTheInfidelsTomb2 = 26,
+ kAreaVictoryOfTheFaith1 = 25,
+ kAreaVictoryOfTheFaith2 = 26,
+ kAreaDeadEnd = 29,
+ kAreaTheWall2 = 30,
+ kAreaTheInfidelsTomb3 = 31,
+ kAreaTheInfidelsTomb4 = 32,
+ kAreaVictoryOfTheFaith3 = 31,
+ kAreaVictoryOfTheFaith4 = 32,
+ kAreaDeadEnd2 = 35,
+ kAreaTheNoose = 36,
+ kAreaTheSource = 37,
+ kAreaTheTwins = 38,
+ kAreaWhoWillBeSaved = 39,
+ kAreaInTheScorpionsPresence = 40,
+ kAreaTheWeb = 41,
+ kAreaPassage1 = 44,
+ kAreaPassage2 = 46,
+ kAreaPassage3 = 48,
+ kAreaThePowersOfTheAbyss = 50,
+ kAreaTheConcourse = 51,
+ kAreaPassage4 = 52,
+ kAreaPassage5 = 54,
+ kAreaDreamsOfSlime = 55,
+ kAreaGuardRoom = 56,
+ kAreaAHiddenPlace = 57,
+ kAreaAnteChamber = 58,
+ kAreaPlacatingThePowers = 59,
+ kAreaInThePresenceOfGod = 60,
+ kAreaBirthOfADivineRace = 61,
+ kAreaSaurasRepose = 62,
+ kAreaTheThresholdOfTruth = 63,
+ kAreaTheScriptures = 63,
+ kAreaRefectory = 65,
+ kAreaPassage6 = 66,
+ kAreaPassage7 = 68,
+ kAreaAblutions = 70,
+ kAreaCell1 = 71,
+ kAreaCell2 = 72,
+ kAreaCell3 = 73,
+ kAreaCell4 = 74,
+ kAreaUpwardGallery = 75,
+ kAreaGallery1 = 75,
+ kAreaCavern = 77,
+ kAreaGallery2 = 78,
+ kAreaGallery3 = 79,
+ kAreaGallery4 = 82,
+ kAreaDownwardGallery = 83,
+ kAreaGallery5 = 83,
+ kAreaGallery6 = 85,
+ kAreaPinkGallery1 = 87,
+ kAreaGallery7 = 88,
+ kAreaPinkGallery2 = 90,
+ kAreaPinkGallery3 = 91,
+ kAreaTube = 93,
+ kAreaUnderwater = 94,
+ kAreaObscurity = 101
+};
+
+} // End of namespace Chamber
+
+#endif
diff --git a/engines/chamber/invent.cpp b/engines/chamber/invent.cpp
index 7afd5e0097b..54e52dbc451 100644
--- a/engines/chamber/invent.cpp
+++ b/engines/chamber/invent.cpp
@@ -67,16 +67,19 @@ struct {
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*/
+/*
+Filter items and put them inventory box, then draw it if non-empty
+filtermask/filtervalue specify area (in high 8 bits) and flags (in lower 8 bits)
+*/
void DrawInventoryBox(uint16 filtermask, uint16 filtervalue) {
int16 i;
byte count = 0;
for (i = 0; i < MAX_INV_ITEMS; i++) {
- uint16 flags = (inventory_items[i].flags2 << 8) | inventory_items[i].flags;
+ uint16 flags = (inventory_items[i].area << 8) | inventory_items[i].flags;
if ((flags & filtermask) != filtervalue)
continue;
if (count == 0) {
- /*draw the box*/
+ /*once first valid item found, draw the box*/
CGA_FillAndWait(inv_bgcolor, 64 / 4, 64, CGA_SCREENBUFFER, CGA_CalcXY_p(232 / 4, 56));
PlaySound(20);
}
@@ -126,9 +129,9 @@ void OpenInventory(uint16 filtermask, uint16 filtervalue) {
CGA_RestoreImage(scratch_mem2, frontbuffer);
PlaySound(20);
switch (((item_t *)script_vars[ScrPool3_CurrentItem])->name) {
- case 108:
- case 115:
- case 117:
+ case 108: /*DAGGER*/
+ case 115: /*SACRIFICIAL BLADE*/
+ case 117: /*CHOPPER*/
script_byte_vars.bvar_63 = 1;
break;
default:
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 7e9803fc79e..dc4303ac3a1 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -100,13 +100,12 @@ void TRAP() {
/* Main Game Loop */
void GameLoop(byte *target) {
for (;;) {
-#if 1
AnimateSpots(target);
-#endif
+
/* Update/check live things */
- UpdateTimedRects1();
- UpdateTimedRects2();
- UpdateTimedInventoryItems();
+ UpdateProtozorqs();
+ CheckGameTimeLimit();
+ CleanupDroppedItems();
/* Get player input */
PollInput();
@@ -137,7 +136,7 @@ void GameLoop(byte *target) {
/*Pending / AI commands*/
if (script_byte_vars.check_used_commands < script_byte_vars.used_commands) {
- the_command = Swap16(script_word_vars.next_command1);
+ the_command = Swap16(script_word_vars.next_aspirant_cmd);
if (the_command)
goto process;
}
@@ -145,18 +144,18 @@ void GameLoop(byte *target) {
if (script_byte_vars.bvar_45)
continue;
- the_command = Swap16(script_word_vars.next_command2);
+ the_command = Swap16(script_word_vars.next_protozorqs_cmd);
if (the_command)
goto process;
- if (Swap16(next_ticks3) < script_word_vars.timer_ticks2) { /*TODO: is this ok? ticks2 is BE, ticks3 is LE*/
- the_command = next_command3;
+ if (Swap16(next_vorts_ticks) < script_word_vars.timer_ticks2) { /*TODO: is this ok? ticks2 is BE, ticks3 is LE*/
+ the_command = next_vorts_cmd;
if (the_command)
goto process;
}
- if (Swap16(next_ticks4) < script_word_vars.timer_ticks2) { /*TODO: is this ok? ticks2 is BE, ticks4 is LE*/
- the_command = next_command4;
+ if (Swap16(next_turkey_ticks) < script_word_vars.timer_ticks2) { /*TODO: is this ok? ticks2 is BE, ticks4 is LE*/
+ the_command = next_turkey_cmd;
if (the_command)
goto process;
}
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index f0ccff369b8..ff9ead1576b 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -337,7 +337,7 @@ void AnimPortrait(byte layer, byte index, byte delay) {
CGA_BlitAndWait(cur_image_pixels, width, width, height, CGA_SCREENBUFFER, offs);
if (delay) {
if (ani[-1] == 37) { /*TODO: what is it?*/
- if (script_byte_vars.bvar_3D)
+ if (script_byte_vars.extreme_violence)
BlinkToRed();
else
BlinkToWhite();
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index 40e195717c8..3ebe77492b1 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -23,6 +23,7 @@
#include "chamber/chamber.h"
#include "chamber/common.h"
#include "chamber/room.h"
+#include "chamber/enums.h"
#include "chamber/resdata.h"
#include "chamber/cga.h"
#include "chamber/print.h"
@@ -64,8 +65,8 @@ spot_t *zone_spots_cur;
vortanims_t *vortanims_ptr;
turkeyanims_t *turkeyanims_ptr;
-pers_t *pers_ptr;
-spot_t *spot_ptr;
+pers_t *aspirant_ptr;
+spot_t *aspirant_spot;
spot_t *found_spot;
byte **spot_sprite;
@@ -77,17 +78,17 @@ byte zsprite_h;
byte *lutin_mem;
-uint16 inv_update_time = 0;
+uint16 drops_cleanup_time = 0;
byte in_de_profundis = 0; /*TODO: useless?*/
-uint16 next_command3 = 0;
-uint16 next_ticks3 = 0;
-uint16 next_command4 = 0;
-uint16 next_ticks4 = 0;
-uint16 next_ticks2 = 0;
+uint16 next_vorts_cmd = 0;
+uint16 next_vorts_ticks = 0;
+uint16 next_turkey_cmd = 0;
+uint16 next_turkey_ticks = 0;
+uint16 next_protozorqs_ticks = 0;
-byte zone_drawn;
+byte skip_zone_transition;
#define VORTANIMS_MAX 25
@@ -338,9 +339,9 @@ void LoadZone(void) {
zone_spr_index = 0;
script_byte_vars.dead_flag = 0;
script_byte_vars.bvar_25 = 0;
- script_word_vars.next_command1 = BE(0);
- next_command4 = 0;
- next_command3 = 0;
+ script_word_vars.next_aspirant_cmd = BE(0);
+ next_turkey_cmd = 0;
+ next_vorts_cmd = 0;
script_byte_vars.used_commands = 0;
}
@@ -353,7 +354,7 @@ void ResetZone(void) {
script_byte_vars.bvar_33 = 0;
script_byte_vars.bvar_34 = 0;
script_byte_vars.bvar_08 = 0;
- script_byte_vars.bvar_39 = 0;
+ script_byte_vars.aspirant_flags = 0;
script_word_vars.psi_cmds[0] = BE(0x9048);
script_word_vars.psi_cmds[1] = BE(0xA01D);
script_word_vars.psi_cmds[2] = BE(0);
@@ -542,7 +543,7 @@ void AnimRoomDoorClose(byte index) {
byte FindInitialSpot(void) {
spot_t *spot;
byte index;
- byte flags = script_byte_vars.bvar_02;
+ byte flags = script_byte_vars.last_door;
if (flags == 0)
return 0;
flags |= SPOTFLG_80 | SPOTFLG_8;
@@ -567,10 +568,9 @@ byte FindSpotByFlags(byte mask, byte value) {
}
/*
-Find person's spot
-TODO: rename me
+Select person and its spot (if available)
*/
-byte FindAndSelectSpot(byte offset) {
+byte SelectPerson(byte offset) {
/*TODO: replace offset arg with index?*/
byte index = offset / 5; /* / sizeof(pers_t) */
@@ -647,13 +647,13 @@ lutinanim_t lutins_table[] = {
{0, { 0, 0, 0, 0, 0, 0, 0, 0} }
};
-void UpdateZoneSpot(byte index) {
+void BeforeChangeZone(byte index) {
byte oldspot;
static const animdesc_t anim57 = {ANIMFLG_USESPOT | 57};
static const animdesc_t anim58 = {ANIMFLG_USESPOT | 58};
script_byte_vars.need_draw_spots = 0;
- if (pers_list[27].area != script_byte_vars.zone_area)
+ if (pers_list[kPersScifi].area != script_byte_vars.zone_area)
return;
if (index < 59 || index >= 63)
return;
@@ -662,11 +662,11 @@ void UpdateZoneSpot(byte index) {
script_byte_vars.need_draw_spots = ~0;
- FindAndSelectSpot(27 * 5);
+ SelectPerson(PersonOffset(kPersScifi));
AnimateSpot(&anim57);
- if (pers_list[30].area != 0) {
- FindAndSelectSpot(30 * 5);
+ if (pers_list[kPersMonkey].area != 0) {
+ SelectPerson(PersonOffset(kPersMonkey));
AnimateSpot(&anim58);
}
@@ -698,7 +698,7 @@ void ChangeZone(byte index) {
}
-void DrawZoneObjs(void) {
+void DrawPersons(void) {
int16 i;
byte index, pidx;
spot_t *spot;
@@ -790,7 +790,7 @@ void DrawRoomStatics(void) {
uint16 xx, ww;
DrawBackground(backbuffer, 0);
- arpla_y_step = script_byte_vars.bvar_2B;
+ arpla_y_step = script_byte_vars.hands;
aptr = SeekToEntry(arpla_data, script_byte_vars.zone_room - 1, &aend);
room_bounds_rect.sx = 0xFF;
@@ -870,8 +870,8 @@ void DrawRoomItemsIndicator(void) {
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) {
+ if (inventory_items[i].flags == ITEMFLG_ROOM
+ && inventory_items[i].area == script_byte_vars.zone_area) {
spridx = 173;
break;
}
@@ -879,10 +879,11 @@ void DrawRoomItemsIndicator(void) {
DrawSpriteN(spridx, 296 / CGA_PIXELS_PER_BYTE, 14, CGA_SCREENBUFFER);
DrawSpriteN(spridx, 296 / CGA_PIXELS_PER_BYTE, 14, backbuffer);
- script_byte_vars.room_items = 0;
+ /*recalculate the number of zapstiks we have*/
+ script_byte_vars.zapstiks_owned = 0;
for (i = 0; i < 14; i++) {
- if (inventory_items[i + 38].flags == ITEMFLG_80)
- script_byte_vars.room_items++; /*TODO: probably should be named differently*/
+ if (inventory_items[i + kItemZapstik1 - 1].flags == ITEMFLG_OWNED)
+ script_byte_vars.zapstiks_owned++;
}
}
@@ -895,20 +896,20 @@ void DrawZoneSpots(void) {
if (!script_byte_vars.need_draw_spots)
return;
- FindAndSelectSpot(27 * 5);
+ SelectPerson(PersonOffset(kPersScifi));
AnimateSpot(&anim59);
- pers_list[27].area = script_byte_vars.zone_area;
+ pers_list[kPersScifi].area = script_byte_vars.zone_area;
- if (pers_list[30].area != 0) {
- pers_list[30].area = script_byte_vars.zone_area;
- FindAndSelectSpot(30 * 5);
+ if (pers_list[kPersMonkey].area != 0) {
+ pers_list[kPersMonkey].area = script_byte_vars.zone_area;
+ SelectPerson(PersonOffset(kPersMonkey));
AnimateSpot(&anim60);
}
script_byte_vars.cur_spot_idx = oldspot;
- DrawZoneObjs();
+ DrawPersons();
}
void RefreshZone(void) {
@@ -916,7 +917,7 @@ void RefreshZone(void) {
PopDirtyRects(DirtyRectBubble);
PopDirtyRects(DirtyRectText);
- if (!zone_drawn && !right_button)
+ if (!skip_zone_transition && !right_button)
DrawBackground(CGA_SCREENBUFFER, 1);
CGA_BackBufferToRealFull();
@@ -1059,116 +1060,123 @@ char DrawZoneAniSprite(rect_t *rect, uint16 index, byte *target) {
return 0;
}
-void SetDelay5(void) {
- next_ticks4 = Swap16(script_word_vars.timer_ticks2) + 5;
-}
-
/*
-Aspirants AI
+Initialize Aspirant
*/
-void PrepareCommand1(void) {
+void PrepareAspirant(void) {
byte index;
- byte oldr, newr;
+ byte hostility, appearance;
byte flags;
- if (script_byte_vars.zone_area == 55) {
- pers_list[1].area = 55;
- pers_list[2].area = 55;
- pers_list[3].area = 55;
- pers_list[1].name = 50; /*DIVO*/
- pers_list[2].name = 50;
- pers_list[3].name = 50;
+ if (script_byte_vars.zone_area == kAreaDreamsOfSlime) {
+ pers_list[kPersAspirant1].area = kAreaDreamsOfSlime;
+ pers_list[kPersAspirant2].area = kAreaDreamsOfSlime;
+ pers_list[kPersAspirant3].area = kAreaDreamsOfSlime;
+ pers_list[kPersAspirant1].name = 50; /*DIVO*/
+ pers_list[kPersAspirant2].name = 50;
+ pers_list[kPersAspirant3].name = 50;
return;
}
- pers_list[1].area = 0;
- pers_list[2].area = 0;
- pers_list[3].area = 0;
- pers_list[4].area = 0;
+ pers_list[kPersAspirant1].area = kAreaNone;
+ pers_list[kPersAspirant2].area = kAreaNone;
+ pers_list[kPersAspirant3].area = kAreaNone;
+ pers_list[kPersAspirant4].area = kAreaNone;
if (script_byte_vars.bvar_26 >= 63)
return;
- if (script_byte_vars.zone_area >= 44)
+
+ if (script_byte_vars.zone_area >= kAreaPassage1)
return;
index = FindSpotByFlags(0x3F, 17);
if (index == 0xFF)
return;
- spot_ptr = &zone_spots[index - 1];
+ aspirant_spot = &zone_spots[index - 1];
- script_byte_vars.quest_item_ofs += 5; /*FIXME: this is sizeof(pers_t), but it's used in scripts, so hardcoded*/
- if (script_byte_vars.quest_item_ofs >= 5 * 5)
- script_byte_vars.quest_item_ofs = 1 * 5;
- pers_ptr = &pers_list[script_byte_vars.quest_item_ofs / 5];
+ script_byte_vars.aspirant_pers_ofs += 5; /*FIXME: this is sizeof(pers_t), but it's used in scripts, so hardcoded*/
+ if (script_byte_vars.aspirant_pers_ofs >= PersonOffset(kPersAspirant4 + 1))
+ script_byte_vars.aspirant_pers_ofs = PersonOffset(kPersAspirant1);
+ aspirant_ptr = &pers_list[script_byte_vars.aspirant_pers_ofs / 5];
- if (pers_ptr->flags & PERSFLG_40)
+ if (aspirant_ptr->flags & PERSFLG_40)
return;
- oldr = script_byte_vars.rand_value;
- newr = Rand();
+ hostility = script_byte_vars.rand_value;
+ appearance = Rand();
flags = 0;
-
- if (script_byte_vars.zone_area < 6) {
- if (oldr < 90) {
- /*TODO: merge/simplify these ifs*/
- if (pers_ptr->item != 0) {
- if (pers_ptr->item >= 6 && pers_ptr->item < 27) {
- if (!(pers_ptr->item >= 19 && pers_ptr->item < 23))
- flags = 1;
- }
- }
+ /*
+ flags values:
+ 0 - passive
+ 1 - willing to trade
+ 2 - hostile
+ |4 - ?
+ */
+
+ if (script_byte_vars.zone_area <= kAreaTheMastersOrbit3) {
+ /*at The Master's Orbit*/
+ if (hostility < 90 && aspirant_ptr->item) {
+ /* ROPE, STONE FLY, GOBLET, LANTERN, but not DAGGER*/
+ if ((aspirant_ptr->item >= kItemRope1 && aspirant_ptr->item <= kItemLantern4)
+ && !(aspirant_ptr->item >= kItemDagger1 && aspirant_ptr->item <= kItemDagger4))
+ flags = 1; /*willing to trade*/
}
- if (newr < 23) {
- pers_ptr->area = script_byte_vars.zone_area;
- script_word_vars.next_command1 = BE(0xA018);
- script_byte_vars.check_used_commands = 3;
- script_byte_vars.bvar_39 = flags;
- script_vars[ScrPool8_CurrentPers] = pers_ptr;
- } else if (newr < 52) {
- script_word_vars.next_command1 = BE(0xA019);
+ if (appearance < 23) {
+ /*spawn in this room*/
+ aspirant_ptr->area = script_byte_vars.zone_area;
+ script_word_vars.next_aspirant_cmd = BE(0xA018); /*leave*/
+ script_byte_vars.check_used_commands = 3; /*after 3 actions*/
+ script_byte_vars.aspirant_flags = flags;
+ script_vars[ScrPool8_CurrentPers] = aspirant_ptr;
+ } else if (appearance < 52) {
+ script_word_vars.next_aspirant_cmd = BE(0xA019);
flags |= 4;
script_byte_vars.check_used_commands = 3;
- script_byte_vars.bvar_39 = flags;
- script_vars[ScrPool8_CurrentPers] = pers_ptr;
+ script_byte_vars.aspirant_flags = flags;
+ script_vars[ScrPool8_CurrentPers] = aspirant_ptr;
} else {
- script_byte_vars.bvar_39 = 0;
+ /*do not spawn*/
+ script_byte_vars.aspirant_flags = 0;
return;
}
} else {
- if (oldr < 39 && pers_ptr->item)
- flags = 1;
- if (oldr >= 166)
- flags = 2;
-
- if (newr < 26) {
- pers_ptr->area = script_byte_vars.zone_area;
- script_word_vars.next_command1 = BE(0xA018);
- script_byte_vars.check_used_commands = 3;
- script_byte_vars.bvar_39 = flags;
- script_vars[ScrPool8_CurrentPers] = pers_ptr;
- } else if (newr < 52) {
- script_word_vars.next_command1 = BE(0xA019);
+ /*at other places*/
+ if (hostility < 39 && aspirant_ptr->item)
+ flags = 1; /*willing to trade*/
+ if (hostility >= 166)
+ flags = 2; /*hostile*/
+
+ if (appearance < 26) {
+ /*spawn in this room*/
+ aspirant_ptr->area = script_byte_vars.zone_area;
+ script_word_vars.next_aspirant_cmd = BE(0xA018); /*leave*/
+ script_byte_vars.check_used_commands = 3; /*after 3 actions*/
+ script_byte_vars.aspirant_flags = flags;
+ script_vars[ScrPool8_CurrentPers] = aspirant_ptr;
+ } else if (appearance < 52) {
+ script_word_vars.next_aspirant_cmd = BE(0xA019);
flags |= 4;
script_byte_vars.check_used_commands = 3;
- script_byte_vars.bvar_39 = flags;
- script_vars[ScrPool8_CurrentPers] = pers_ptr;
+ script_byte_vars.aspirant_flags = flags;
+ script_vars[ScrPool8_CurrentPers] = aspirant_ptr;
} else {
- script_byte_vars.bvar_39 = 0;
+ /*do not spawn*/
+ script_byte_vars.aspirant_flags = 0;
return;
}
}
}
/*
-Vorts AI
+Initialize Vorts
*/
-void PrepareCommand3(void) {
+void PrepareVorts(void) {
spot_t *spot;
- if ((script_byte_vars.zone_area != 8) || !(script_byte_vars.bvar_36 & 0x80)) {
- pers_list[0].flags &= ~PERSFLG_40;
- pers_list[34].flags &= ~PERSFLG_40;
- pers_list[35].flags &= ~PERSFLG_40;
+ if ((script_byte_vars.zone_area != kAreaTheReturn) || !(script_byte_vars.bvar_36 & 0x80)) {
+ pers_list[kPersVort].flags &= ~PERSFLG_40;
+ pers_list[kPersVort2].flags &= ~PERSFLG_40;
+ pers_list[kPersVort3].flags &= ~PERSFLG_40;
for (spot = zone_spots; spot != zone_spots_end; spot++) {
if ((spot->flags & ~SPOTFLG_80) == (SPOTFLG_40 | SPOTFLG_10)) {
@@ -1176,25 +1184,25 @@ void PrepareCommand3(void) {
for (i = 0; i < VORTANIMS_MAX; i++) {
if (vortsanim_list[i].room == script_byte_vars.zone_room) {
vortanims_ptr = &vortsanim_list[i];
- if (script_byte_vars.zone_area == pers_list[0].area
- || script_byte_vars.zone_area == pers_list[34].area
- || script_byte_vars.zone_area == pers_list[35].area) {
- next_command3 = 0xA015; /*VortLeave*/
+ if (script_byte_vars.zone_area == pers_list[kPersVort].area
+ || script_byte_vars.zone_area == pers_list[kPersVort2].area
+ || script_byte_vars.zone_area == pers_list[kPersVort3].area) {
+ next_vorts_cmd = 0xA015; /*VortLeave*/
} else {
- pers_list[0].area = 0;
- pers_list[34].area = 0;
- pers_list[35].area = 0;
+ pers_list[kPersVort].area = 0;
+ pers_list[kPersVort2].area = 0;
+ pers_list[kPersVort3].area = 0;
script_byte_vars.bvar_36 &= 0x80; /*TODO: is this correct? |= ?*/
if (script_byte_vars.rand_value < 39) {
- pers_list[0].area = script_byte_vars.zone_area;
- next_command3 = 0xA015; /*VortLeave*/
+ pers_list[kPersVort].area = script_byte_vars.zone_area;
+ next_vorts_cmd = 0xA015; /*VortLeave*/
} else if (script_byte_vars.rand_value < 78)
- next_command3 = 0xA014; /*VortAppear*/
+ next_vorts_cmd = 0xA014; /*VortAppear*/
else
return;
}
script_byte_vars.bvar_36 |= 1;
- next_ticks3 = Swap16(script_word_vars.timer_ticks2) + 5;
+ next_vorts_ticks = Swap16(script_word_vars.timer_ticks2) + 5;
return;
}
}
@@ -1202,24 +1210,24 @@ void PrepareCommand3(void) {
}
}
}
- pers_list[0].area = 0;
- pers_list[34].area = 0;
- pers_list[35].area = 0;
+ pers_list[kPersVort].area = 0;
+ pers_list[kPersVort2].area = 0;
+ pers_list[kPersVort3].area = 0;
script_byte_vars.bvar_36 &= 0x80; /*TODO: is this correct? |= ?*/
}
/*
-Turkey AI
+Initialize Turkey
*/
-void PrepareCommand4(void) {
+void PrepareTurkey(void) {
spot_t *spot;
- if (script_byte_vars.zone_area == 59 && script_byte_vars.bvar_4E == 0) {
- pers_list[5].area = 59;
+ if (script_byte_vars.zone_area == kAreaPlacatingThePowers && script_byte_vars.bvar_4E == 0) {
+ pers_list[kPersTurkey].area = kAreaPlacatingThePowers;
return;
}
- pers_list[5].flags &= ~PERSFLG_40;
+ pers_list[kPersTurkey].flags &= ~PERSFLG_40;
for (spot = zone_spots; spot != zone_spots_end; spot++) {
if ((spot->flags & ~SPOTFLG_80) == (SPOTFLG_40 | SPOTFLG_10 | SPOTFLG_1)) {
@@ -1228,18 +1236,18 @@ void PrepareCommand4(void) {
for (i = 0; i < TURKEYANIMS_MAX; i++) {
if (turkeyanim_list[i].room == script_byte_vars.zone_room) {
turkeyanims_ptr = &turkeyanim_list[i];
- if (script_byte_vars.zone_area == pers_list[5].area) {
- next_command4 = 0xA01F;
- SetDelay5();
+ if (script_byte_vars.zone_area == pers_list[kPersTurkey].area) {
+ next_turkey_cmd = 0xA01F; /*leave*/
+ next_turkey_ticks = Swap16(script_word_vars.timer_ticks2) + 5;
} else {
- pers_list[5].area = 0;
+ pers_list[kPersTurkey].area = 0;
if (script_byte_vars.rand_value >= 217) {
- pers_list[5].area = script_byte_vars.zone_area;
- next_command4 = 0xA01F;
- SetDelay5();
+ pers_list[kPersTurkey].area = script_byte_vars.zone_area;
+ next_turkey_cmd = 0xA01F; /*leave*/
+ next_turkey_ticks = Swap16(script_word_vars.timer_ticks2) + 5;
} else if (script_byte_vars.rand_value >= 178) {
- next_command4 = 0xA01E;
- SetDelay5();
+ next_turkey_cmd = 0xA01E; /*appear*/
+ next_turkey_ticks = Swap16(script_word_vars.timer_ticks2) + 5;
}
}
return;
@@ -1249,7 +1257,7 @@ void PrepareCommand4(void) {
}
}
- pers_list[5].area = 0;
+ pers_list[kPersTurkey].area = 0;
}
@@ -1290,15 +1298,18 @@ void RestoreScreenOfSpecialRoom(void) {
}
}
+/*
+Modify anim sprite 127
+*/
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) {
- case 37:
- case 58:
- case 40:
- if (flags == ITEMFLG_80)
+ case 37: /*DAGGER*/
+ case 58: /*CHOPPER*/
+ case 40: /*SACRIFICIAL BLADE*/
+ if (flags == ITEMFLG_OWNED)
script_byte_vars.bvar_66 += 1;
else
script_byte_vars.bvar_66 -= 1;
@@ -1306,19 +1317,24 @@ void SetAnim127Sprite(byte flags, byte spridx) {
}
}
+/*
+Bounce current item to the room/inventory
+*/
void BounceCurrentItem(byte flags, byte y) {
item_t *item = (item_t *)(script_vars[ScrPool3_CurrentItem]);
SetAnim127Sprite(flags, item->sprite);
item->flags = flags;
- item->flags2 = script_byte_vars.zone_area;
+ item->area = script_byte_vars.zone_area;
BackupScreenOfSpecialRoom();
PlayAnim(41, 176 / 4, y);
DrawRoomItemsIndicator();
RestoreScreenOfSpecialRoom();
}
-
+/*
+Load The Wall gate sprites
+*/
byte *LoadMursmSprite(byte index) {
byte *pinfo, *end;
pinfo = SeekToEntry(mursm_data, index, &end);
@@ -1356,6 +1372,10 @@ byte *LoadMursmSprite(byte index) {
thewalldoor_t the_wall_doors[2];
+/*
+Open The Wall's right gate
+TODO: move this to CGA?
+*/
void TheWallOpenRightDoor(byte x, byte y, byte width, byte height, byte limit) {
uint16 offs = CGA_CalcXY_p(x + width - 2, y);
@@ -1368,7 +1388,6 @@ void TheWallOpenRightDoor(byte x, byte y, byte width, byte height, byte limit) {
offs++;
/*hide remaining column*/
- /*TODO: move this to CGA?*/
uint16 ooffs = offs;
byte oh = height;
while (height--) {
@@ -1382,6 +1401,10 @@ void TheWallOpenRightDoor(byte x, byte y, byte width, byte height, byte limit) {
CGA_blitToScreen(ooffs, 1, oh);
}
+/*
+Open The Wall's left gate
+TODO: move this to CGA?
+*/
void TheWallOpenLeftDoor(byte x, byte y, byte width, byte height, byte limit) {
uint16 offs = CGA_CalcXY_p(x + 1, y);
@@ -1394,7 +1417,6 @@ void TheWallOpenLeftDoor(byte x, byte y, byte width, byte height, byte limit) {
offs--;
/*hide remaining column*/
- /*TODO: move this to CGA?*/
uint16 ooffs = offs;
byte oh = height;
while (height--) {
@@ -1622,19 +1644,27 @@ void DrawHintsAndCursor(byte *target) {
DrawCursor(target);
}
-void HideSpot(byte offset) {
- FindAndSelectSpot(offset);
+/*
+Hide a person
+*/
+void HidePerson(byte offset) {
+ SelectPerson(offset);
found_spot->flags &= ~SPOTFLG_80;
}
-const byte timed_seq[] = {56, 51, 44, 12, 10, 20, 18, 16, 14, 12, 44, 51};
-const byte *timed_seq_ptr = timed_seq;
+const byte patrol_route[] = {
+ kAreaGuardRoom, kAreaTheConcourse,
+ kAreaPassage1, kAreaTheRing2,
+ kAreaTheRing1, kAreaTheRing6,
+ kAreaTheRing5, kAreaTheRing4,
+ kAreaTheRing3, kAreaTheRing2,
+ kAreaPassage1, kAreaTheConcourse};
+const byte *timed_seq_ptr = patrol_route;
/*
-Protozorq AI 1
-TODO: rename this
+Update Protozorqs locations
*/
-void UpdateTimedRects1(void) {
+void UpdateProtozorqs(void) {
uint16 elapsed;
if (script_byte_vars.bvar_45 != 0)
@@ -1643,62 +1673,62 @@ void UpdateTimedRects1(void) {
if (script_byte_vars.bvar_26 >= 63)
return;
- script_word_vars.next_command2 = BE(0);
+ script_word_vars.next_protozorqs_cmd = BE(0);
- if (pers_list[13].flags & PERSFLG_40) {
- pers_list[13].area = 56;
- pers_list[13].flags &= ~(PERSFLG_10 | PERSFLG_20 | PERSFLG_40 | PERSFLG_80);
- pers_list[13].index = 52;
+ if (pers_list[kPersProtozorq5].flags & PERSFLG_40) {
+ pers_list[kPersProtozorq5].area = kAreaGuardRoom;
+ pers_list[kPersProtozorq5].flags &= ~(PERSFLG_10 | PERSFLG_20 | PERSFLG_40 | PERSFLG_80);
+ pers_list[kPersProtozorq5].index = 52;
}
- if (pers_list[22].flags & PERSFLG_20)
+ if (pers_list[kPersProtozorq14].flags & PERSFLG_20)
script_byte_vars.bvar_30 |= 4;
elapsed = Swap16(script_word_vars.timer_ticks2);
- if (elapsed < next_ticks2)
+ if (elapsed < next_protozorqs_ticks)
return;
- next_ticks2 = elapsed + 30;
+ next_protozorqs_ticks = elapsed + 30;
script_byte_vars.bvar_3F = *timed_seq_ptr++;
- if (timed_seq_ptr == timed_seq + sizeof(timed_seq))
- timed_seq_ptr = timed_seq;
+ if (timed_seq_ptr == patrol_route + sizeof(patrol_route))
+ timed_seq_ptr = patrol_route;
script_byte_vars.bvar_40 = *timed_seq_ptr++;
- if (script_byte_vars.bvar_3F == 56) {
+ if (script_byte_vars.bvar_3F == kAreaGuardRoom) {
script_byte_vars.bvar_30 &= ~4;
- pers_list[22].flags &= ~(PERSFLG_20 | PERSFLG_40 | PERSFLG_80);
- pers_list[22].index = 55;
- if (pers_list[13].area == 56) {
- pers_list[13].flags &= ~(PERSFLG_20 | PERSFLG_40 | PERSFLG_80);
+ pers_list[kPersProtozorq14].flags &= ~(PERSFLG_20 | PERSFLG_40 | PERSFLG_80);
+ pers_list[kPersProtozorq14].index = 55;
+ if (pers_list[kPersProtozorq5].area == kAreaGuardRoom) {
+ pers_list[kPersProtozorq5].flags &= ~(PERSFLG_20 | PERSFLG_40 | PERSFLG_80);
script_byte_vars.bvar_41 = 1;
}
}
- if (script_byte_vars.bvar_3F == 12 && script_byte_vars.bvar_40 == 10) {
+ if (script_byte_vars.bvar_3F == kAreaTheRing2 && script_byte_vars.bvar_40 == kAreaTheRing1) {
script_byte_vars.bvar_41 = 0;
- if (pers_list[13].area == 56) {
- script_byte_vars.bvar_40 = 44;
- timed_seq_ptr = timed_seq + 4;
+ if (pers_list[kPersProtozorq5].area == kAreaGuardRoom) {
+ script_byte_vars.bvar_40 = kAreaPassage1;
+ timed_seq_ptr = patrol_route + 4;
}
}
- pers_list[22].area = script_byte_vars.bvar_40;
+ pers_list[kPersProtozorq14].area = script_byte_vars.bvar_40;
if (script_byte_vars.bvar_41 != 0) {
- pers_list[13].area = script_byte_vars.bvar_40;
- pers_list[20].area = script_byte_vars.bvar_40;
- pers_list[21].area = script_byte_vars.bvar_40;
+ pers_list[kPersProtozorq5].area = script_byte_vars.bvar_40;
+ pers_list[kPersProtozorq12].area = script_byte_vars.bvar_40;
+ pers_list[kPersProtozorq13].area = script_byte_vars.bvar_40;
if (script_byte_vars.zone_area == script_byte_vars.bvar_3F) {
static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
- HideSpot(22 * 5); /*dirct rec offset*/
- HideSpot(13 * 5); /*dirct rec offset*/
- HideSpot(20 * 5); /*dirct rec offset*/
- HideSpot(21 * 5); /*dirct rec offset*/
+ HidePerson(PersonOffset(kPersProtozorq14));
+ HidePerson(PersonOffset(kPersProtozorq5));
+ HidePerson(PersonOffset(kPersProtozorq12));
+ HidePerson(PersonOffset(kPersProtozorq13));
AnimateSpot(&anim35);
BlitSpritesToBackBuffer();
DrawCursor(frontbuffer);
@@ -1710,43 +1740,43 @@ void UpdateTimedRects1(void) {
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
- FindAndSelectSpot(22 * 5);
+ SelectPerson(PersonOffset(kPersProtozorq14));
AnimateSpot(&anim34);
- if (FindAndSelectSpot(20 * 5)) {
+ if (SelectPerson(PersonOffset(kPersProtozorq12))) {
AnimateSpot(&anim34);
- FindAndSelectSpot(13 * 5);
+ SelectPerson(PersonOffset(kPersProtozorq5));
AnimateSpot(&anim34);
- FindAndSelectSpot(21 * 5);
+ SelectPerson(PersonOffset(kPersProtozorq13));
AnimateSpot(&anim34);
}
- DrawZoneObjs();
+ DrawPersons();
CGA_BackBufferToRealFull();
BlitSpritesToBackBuffer();
DrawCursor(frontbuffer);
- if (script_byte_vars.room_items != 0)
- script_word_vars.next_command2 = BE(0xC1FD);
- else if (pers_list[22].flags & 0x20)
- script_word_vars.next_command2 = BE(0xC1E5);
- else if (script_byte_vars.zone_area == 44)
- script_word_vars.next_command2 = BE(0xC060);
+ if (script_byte_vars.zapstiks_owned != 0)
+ script_word_vars.next_protozorqs_cmd = BE(0xC1FD);
+ else if (pers_list[kPersProtozorq14].flags & PERSFLG_20)
+ script_word_vars.next_protozorqs_cmd = BE(0xC1E5);
+ else if (script_byte_vars.zone_area == kAreaPassage1)
+ script_word_vars.next_protozorqs_cmd = BE(0xC060);
return;
}
} else {
- if (pers_list[22].flags & 0x40)
+ if (pers_list[kPersProtozorq14].flags & PERSFLG_40)
return;
if (script_byte_vars.zone_area == script_byte_vars.bvar_3F) {
static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
- HideSpot(22 * 5); /*dirct rec offset*/
+ HidePerson(PersonOffset(kPersProtozorq14));
AnimateSpot(&anim35);
BlitSpritesToBackBuffer();
DrawCursor(frontbuffer);
@@ -1758,10 +1788,10 @@ void UpdateTimedRects1(void) {
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
- FindAndSelectSpot(22 * 5);
+ SelectPerson(PersonOffset(kPersProtozorq14));
AnimateSpot(&anim34);
- DrawZoneObjs();
+ DrawPersons();
CGA_BackBufferToRealFull();
BlitSpritesToBackBuffer();
DrawCursor(frontbuffer);
@@ -1771,12 +1801,10 @@ void UpdateTimedRects1(void) {
}
}
-
/*
-Protozorq AI 2
-TODO: rename this
+Check how many time have passed and call the guards
*/
-void UpdateTimedRects2(void) {
+void CheckGameTimeLimit(void) {
uint16 elapsed = Swap16(script_word_vars.timer_ticks2);
if (elapsed < 60 * 60)
@@ -1784,18 +1812,18 @@ void UpdateTimedRects2(void) {
if (script_byte_vars.bvar_26 < 63) {
script_byte_vars.bvar_37 = 3;
- script_byte_vars.bvar_26 = (script_byte_vars.zone_area < 44) ? 255 : 63;
- pers_list[13].area = 0;
- pers_list[14].area = 0;
- pers_list[15].area = 0;
- pers_list[16].area = 0;
- pers_list[18].area = 0;
- pers_list[19].area = 56;
- pers_list[20].area = 56;
- pers_list[21].area = 56;
- pers_list[22].area = 56;
- if (script_byte_vars.zone_area < 22)
- script_word_vars.next_command2 = BE(0xC012);
+ script_byte_vars.bvar_26 = (script_byte_vars.zone_area < kAreaPassage1) ? 255 : 63;
+ pers_list[kPersProtozorq5].area = 0;
+ pers_list[kPersProtozorq6].area = 0;
+ pers_list[kPersProtozorq7].area = 0;
+ pers_list[kPersProtozorq8].area = 0;
+ pers_list[kPersProtozorq10].area = 0;
+ pers_list[kPersProtozorq11].area = kAreaGuardRoom;
+ pers_list[kPersProtozorq12].area = kAreaGuardRoom;
+ pers_list[kPersProtozorq13].area = kAreaGuardRoom;
+ pers_list[kPersProtozorq14].area = kAreaGuardRoom;
+ if (script_byte_vars.zone_area < kAreaDeProfundis)
+ script_word_vars.next_protozorqs_cmd = BE(0xC012);
return;
}
@@ -1805,25 +1833,29 @@ void UpdateTimedRects2(void) {
if (elapsed < 120 * 60) {
script_byte_vars.bvar_37 = 2;
script_byte_vars.bvar_4E = 1;
- if ((script_byte_vars.zone_area != 61)
- && (script_byte_vars.zone_area >= 59 && script_byte_vars.zone_area < 75))
- script_word_vars.next_command2 = BE(0xC012);
+ if ((script_byte_vars.zone_area != kAreaBirthOfADivineRace)
+ && (script_byte_vars.zone_area >= kAreaPlacatingThePowers && script_byte_vars.zone_area <= kAreaCell4))
+ script_word_vars.next_protozorqs_cmd = BE(0xC012);
return;
}
- script_word_vars.next_command2 = BE(0xC318);
+ script_word_vars.next_protozorqs_cmd = BE(0xC318); /*game over*/
}
-void UpdateTimedInventoryItems(void) {
+/*
+Clean up dropped items after some time
+*/
+void CleanupDroppedItems(void) {
int16 i;
- if (Swap16(script_word_vars.timer_ticks2) - inv_update_time < 180)
+
+ if (Swap16(script_word_vars.timer_ticks2) - drops_cleanup_time < 180)
return;
- inv_update_time = Swap16(script_word_vars.timer_ticks2);
+ drops_cleanup_time = Swap16(script_word_vars.timer_ticks2);
for (i = 0; i < MAX_INV_ITEMS; i++) {
- if (inventory_items[i].flags & ITEMFLG_40) {
- if (inventory_items[i].flags2 != script_byte_vars.zone_area && inventory_items[i].flags2 < 52)
- inventory_items[i].flags &= ~ITEMFLG_40;
+ if (inventory_items[i].flags & ITEMFLG_ROOM) {
+ if (inventory_items[i].area != script_byte_vars.zone_area && inventory_items[i].area < kAreaPassage4)
+ inventory_items[i].flags &= ~ITEMFLG_ROOM;
}
}
}
diff --git a/engines/chamber/room.h b/engines/chamber/room.h
index 9f6eeb484bd..91073bf8448 100644
--- a/engines/chamber/room.h
+++ b/engines/chamber/room.h
@@ -101,11 +101,11 @@ extern byte object_hint;
extern byte command_hint;
extern byte last_command_hint;
-extern uint16 next_ticks2;
-extern uint16 next_ticks3;
-extern uint16 next_command3;
-extern uint16 next_ticks4;
-extern uint16 next_command4;
+extern uint16 next_protozorqs_ticks;
+extern uint16 next_vorts_ticks;
+extern uint16 next_vorts_cmd;
+extern uint16 next_turkey_ticks;
+extern uint16 next_turkey_cmd;
#define MAX_SPRITES 16
@@ -126,14 +126,14 @@ extern vortanims_t *vortanims_ptr;
extern turkeyanims_t turkeyanim_list[];
extern turkeyanims_t *turkeyanims_ptr;
-extern pers_t *pers_ptr;
-extern spot_t *spot_ptr;
+extern pers_t *aspirant_ptr;
+extern spot_t *aspirant_spot;
extern spot_t *found_spot;
extern byte **spot_sprite;
extern byte *lutin_mem;
-extern byte zone_drawn;
+extern byte skip_zone_transition;
extern byte in_de_profundis;
@@ -144,9 +144,9 @@ extern byte zone_obj_count;
extern byte room_hint_bar_coords_x;
extern byte room_hint_bar_coords_y;
-extern uint16 inv_update_time;
+extern uint16 drops_cleanup_time;
-extern const byte timed_seq[];
+extern const byte patrol_route[];
extern const byte *timed_seq_ptr;
typedef struct thewalldoor_t {
@@ -191,16 +191,16 @@ void SelectPalette(void);
void SelectSpecificPalette(byte index);
byte FindSpotByFlags(byte mask, byte value);
-byte FindAndSelectSpot(byte offset);
+byte SelectPerson(byte offset);
void FindPerson(void);
-void UpdateZoneSpot(byte index);
+void BeforeChangeZone(byte index);
void DrawRoomItemsIndicator(void);
void DrawRoomStaticObject(byte *aptr, byte *rx, byte *ry, byte *rw, byte *rh);
void DrawRoomStatics(void);
void RedrawRoomStatics(byte index, byte y_step);
-void DrawZoneObjs(void);
+void DrawPersons(void);
void RefreshZone(void);
void ChangeZone(byte index);
@@ -223,13 +223,13 @@ void TheWallPhase0_DoorOpen2(void);
void TheWallPhase1_DoorClose1(void);
void TheWallPhase2_DoorClose2(void);
-void PrepareCommand1(void);
-void PrepareCommand3(void);
-void PrepareCommand4(void);
+void PrepareAspirant(void);
+void PrepareVorts(void);
+void PrepareTurkey(void);
-void UpdateTimedRects1(void);
-void UpdateTimedRects2(void);
-void UpdateTimedInventoryItems(void);
+void UpdateProtozorqs(void);
+void CheckGameTimeLimit(void);
+void CleanupDroppedItems(void);
void ResetAllPersons(void);
diff --git a/engines/chamber/savegame.cpp b/engines/chamber/savegame.cpp
index 2ad2eba7a6a..b82627b248e 100644
--- a/engines/chamber/savegame.cpp
+++ b/engines/chamber/savegame.cpp
@@ -85,7 +85,7 @@ int16 ReadSaveData(int16 f, int16 clean) {
POINTER(script_vars[ScrPool4_ZoneSpots], zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
POINTER(script_vars[ScrPool5_Persons], pers_list, 1, 1, CGA_SAVE_PERS_OFS);
POINTER(script_vars[ScrPool6_Inventory], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
- POINTER(script_vars[ScrPool7_Inventory38], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
+ POINTER(script_vars[ScrPool7_Zapstiks], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
POINTER(script_vars[ScrPool8_CurrentPers], pers_list, 1, 1, CGA_SAVE_PERS_OFS);
/* sprites_list */
@@ -120,8 +120,8 @@ int16 ReadSaveData(int16 f, int16 clean) {
/* padding */
USHORT(zero);
- /* pers_vort_ptr */
- POINTER((byte *)pers_vort_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS);
+ /* vort_ptr */
+ POINTER((byte *)vort_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS);
/* vortanims_ptr */
POINTER((byte *)vortanims_ptr, vortsanim_list, 1, 1, CGA_SAVE_VORTANIMS_OFS);
@@ -129,11 +129,11 @@ int16 ReadSaveData(int16 f, int16 clean) {
/* turkeyanims_ptr */
POINTER((byte *)turkeyanims_ptr, turkeyanim_list, 1, 1, CGA_SAVE_TURKEYANIMS_OFS);
- /* pers_ptr */
- POINTER((byte *)pers_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS);
+ /* aspirant_ptr */
+ POINTER((byte *)aspirant_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS);
- /* spot_ptr */
- POINTER((byte *)spot_ptr, zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
+ /* aspirant_spot */
+ POINTER((byte *)aspirant_spot, zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
/* found_spot */
POINTER((byte *)found_spot, zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
@@ -142,7 +142,7 @@ int16 ReadSaveData(int16 f, int16 clean) {
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);
+ POINTER(timed_seq_ptr, patrol_route, 1, 1, CGA_SAVE_TIMEDSEQ_OFS);
/* keep_sp */
/* TODO: how to save it? but it's probably useless anyway */
@@ -207,8 +207,8 @@ int16 ReadSaveData(int16 f, int16 clean) {
BYTES(&pers_list[i], sizeof(pers_t));
}
- /* inv_update_time */
- USHORT(inv_update_time);
+ /* drops_cleanup_time */
+ USHORT(drops_cleanup_time);
/* room_bounds_rect */
/*TODO: properly serialize this*/
@@ -262,20 +262,20 @@ int16 ReadSaveData(int16 f, int16 clean) {
/* menu_commands_23 */
BYTES(menu_commands_23, sizeof(menu_commands_23));
- /* next_command3 */
- USHORT(next_command3);
+ /* next_vorts_cmd */
+ USHORT(next_vorts_cmd);
- /* next_ticks3 */
- USHORT(next_ticks3);
+ /* next_vorts_ticks */
+ USHORT(next_vorts_ticks);
- /* next_command4 */
- USHORT(next_command4);
+ /* next_turkey_cmd */
+ USHORT(next_turkey_cmd);
- /* next_ticks4 */
- USHORT(next_ticks4);
+ /* next_turkey_ticks */
+ USHORT(next_turkey_ticks);
- /* next_ticks2 */
- USHORT(next_ticks2);
+ /* next_protozorqs_ticks */
+ USHORT(next_protozorqs_ticks);
/* padding */
for (i = 0; i < 7; i++) USHORT(zero);
@@ -331,7 +331,7 @@ int16 WriteSaveData(int16 f, int16 clean) {
POINTER(script_vars[ScrPool4_ZoneSpots], zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
POINTER(script_vars[ScrPool5_Persons], pers_list, 1, 1, CGA_SAVE_PERS_OFS);
POINTER(script_vars[ScrPool6_Inventory], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
- POINTER(script_vars[ScrPool7_Inventory38], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
+ POINTER(script_vars[ScrPool7_Zapstiks], inventory_items, sizeof(item_t), sizeof(item_t), CGA_SAVE_INVENTORY_OFS);
POINTER(script_vars[ScrPool8_CurrentPers], pers_list, 1, 1, CGA_SAVE_PERS_OFS);
/* sprites_list */
@@ -366,8 +366,8 @@ int16 WriteSaveData(int16 f, int16 clean) {
/* padding */
USHORT(zero);
- /* pers_vort_ptr */
- POINTER(pers_vort_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS);
+ /* vort_ptr */
+ POINTER(vort_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS);
/* vortanims_ptr */
POINTER(vortanims_ptr, vortsanim_list, 1, 1, CGA_SAVE_VORTANIMS_OFS);
@@ -375,11 +375,11 @@ int16 WriteSaveData(int16 f, int16 clean) {
/* turkeyanims_ptr */
POINTER(turkeyanims_ptr, turkeyanim_list, 1, 1, CGA_SAVE_TURKEYANIMS_OFS);
- /* pers_ptr */
- POINTER(pers_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS);
+ /* aspirant_ptr */
+ POINTER(aspirant_ptr, pers_list, 1, 1, CGA_SAVE_PERS_OFS);
- /* spot_ptr */
- POINTER(spot_ptr, zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
+ /* aspirant_spot */
+ POINTER(aspirant_spot, zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
/* found_spot */
POINTER(found_spot, zones_data, 1, 1, CGA_SAVE_ZONES_OFS);
@@ -388,7 +388,7 @@ int16 WriteSaveData(int16 f, int16 clean) {
POINTER(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);
+ POINTER(timed_seq_ptr, patrol_route, 1, 1, CGA_SAVE_TIMEDSEQ_OFS);
/* keep_sp */
/* TODO: how to save it? but it's probably useless anyway */
@@ -453,8 +453,8 @@ int16 WriteSaveData(int16 f, int16 clean) {
BYTES(&pers_list[i], sizeof(pers_t));
}
- /* inv_update_time */
- USHORT(inv_update_time);
+ /* drops_cleanup_time */
+ USHORT(drops_cleanup_time);
/* room_bounds_rect */
/*TODO: properly serialize this*/
@@ -508,20 +508,20 @@ int16 WriteSaveData(int16 f, int16 clean) {
/* menu_commands_23 */
BYTES(menu_commands_23, sizeof(menu_commands_23));
- /* next_command3 */
- USHORT(next_command3);
+ /* next_vorts_cmd */
+ USHORT(next_vorts_cmd);
- /* next_ticks3 */
- USHORT(next_ticks3);
+ /* next_vorts_ticks */
+ USHORT(next_vorts_ticks);
- /* next_command4 */
- USHORT(next_command4);
+ /* next_turkey_cmd */
+ USHORT(next_turkey_cmd);
- /* next_ticks4 */
- USHORT(next_ticks4);
+ /* next_turkey_ticks */
+ USHORT(next_turkey_ticks);
- /* next_ticks2 */
- USHORT(next_ticks2);
+ /* next_protozorqs_ticks */
+ USHORT(next_protozorqs_ticks);
/* padding */
for (i = 0; i < 7; i++) USHORT(zero);
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index ed77b3a6336..34ecb9fe5de 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -29,6 +29,7 @@
#include "chamber/chamber.h"
#include "chamber/common.h"
#include "chamber/script.h"
+#include "chamber/enums.h"
#include "chamber/resdata.h"
#include "chamber/cga.h"
#include "chamber/cursor.h"
@@ -69,17 +70,23 @@ void *script_vars[ScrPools_MAX] = {
zones_data,
pers_list,
inventory_items,
- inventory_items + 38,
+ inventory_items + kItemZapstik1 - 1,
pers_list
};
extern void AskDisk2(void);
+/*
+Get next random byte value
+*/
byte Rand(void) {
script_byte_vars.rand_value = aleat_data[++rand_seed];
return script_byte_vars.rand_value;
}
+/*
+Get next random word value
+*/
uint16 RandW(void) {
uint16 r = Rand() << 8;
return r | Rand();
@@ -89,7 +96,9 @@ uint16 Swap16(uint16 x) {
return (x << 8) | (x >> 8);
}
-/*Script handlers exit codes*/
+/*
+Script handlers exit codes
+*/
enum CommandStatus {
ScriptContinue = 0, /*run next script command normally*/
ScriptRerun = 1, /*abort current script, execute new command*/
@@ -110,15 +119,20 @@ uint16 SCR_TRAP(void) {
return 0;
}
-
-void ClaimTradedItems(void) {
+/*
+Remove "not interested in that" tag from owned items
+*/
+void ReclaimRefusedItems(void) {
int16 i;
for (i = 0; i < MAX_INV_ITEMS; i++) {
- if (inventory_items[i].flags == (ITEMFLG_80 | 1))
- inventory_items[i].flags = ITEMFLG_80;
+ if (inventory_items[i].flags == (ITEMFLG_OWNED | ITEMFLG_DONTWANT))
+ inventory_items[i].flags = ITEMFLG_OWNED;
}
}
+/*
+Trade with a fellow Aspirant (the one that offers to swap an item)
+*/
uint16 SCR_1_AspirantItemTrade(void) {
byte *old_script, *old_script_end = script_end_ptr;
@@ -129,7 +143,7 @@ uint16 SCR_1_AspirantItemTrade(void) {
for (;;) {
inv_bgcolor = 0xFF;
- OpenInventory(0xFE, ITEMFLG_80);
+ OpenInventory(0xFE, ITEMFLG_OWNED);
if (inv_count == 0) {
the_command = 0xC1BC;
@@ -145,50 +159,52 @@ uint16 SCR_1_AspirantItemTrade(void) {
the_command = 0x9140;
- if (pers_ptr->item == 0)
+ if (aspirant_ptr->item == 0)
break;
- item1 = &inventory_items[pers_ptr->item - 1];
- item2 = (item_t *)(script_vars[ScrPool3_CurrentItem]);
+ item1 = &inventory_items[aspirant_ptr->item - 1]; /*aspirant's item*/
+ item2 = (item_t *)(script_vars[ScrPool3_CurrentItem]); /*our offer*/
- if (item2->flags == (ITEMFLG_80 | 1) || item1->name == item2->name) {
+ if (item2->flags == (ITEMFLG_OWNED | ITEMFLG_DONTWANT) || item1->name == item2->name) {
the_command = 0xC1C0;
RunCommand();
break;
}
- if (item2->name == 109
- || item2->name == 132
- || item2->name == 108
+ if (item2->name == 109 /*SKULL*/
+ || item2->name == 132 /*ZAPSTIK*/
+ || item2->name == 108 /*DAGGER*/
|| script_byte_vars.rand_value < 154) {
- item2->flags = ITEMFLG_20;
- item1->flags = ITEMFLG_80;
- pers_ptr->item = script_byte_vars.inv_item_index;
+ /*accept*/
+ item2->flags = ITEMFLG_ASPIR;
+ item1->flags = ITEMFLG_OWNED;
+ aspirant_ptr->item = script_byte_vars.inv_item_index;
switch (item2->name) {
- case 132:
- script_byte_vars.room_items--;
+ case 132: /*ZAPSTIK*/
+ script_byte_vars.zapstiks_owned--;
the_command = 0xC04B;
break;
- case 104:
+ case 104: /*ROPE*/
the_command = 0xC1BA;
break;
- case 107:
+ case 107: /*GOBLET*/
the_command = 0xC1BB;
break;
- default:
- the_command = 0xC1BA;
+ default: /*STONE FLY*/
+ the_command = 0xC1B9;
}
RunCommand();
break;
} else {
- item2->flags = ITEMFLG_80 | 1;
+ /*not interested*/
+ item2->flags = ITEMFLG_OWNED | ITEMFLG_DONTWANT;
the_command = 0xC1BD;
RunCommand();
continue;
}
}
- ClaimTradedItems();
+ ReclaimRefusedItems();
script_ptr = old_script;
script_end_ptr = old_script_end;
@@ -196,6 +212,9 @@ uint16 SCR_1_AspirantItemTrade(void) {
return 0;
}
+/*
+Trade with a rude/passive Aspirant (the one that says nasty words about you)
+*/
uint16 SCR_2_RudeAspirantTrade(void) {
byte *old_script, *old_script_end = script_end_ptr;
@@ -209,7 +228,7 @@ uint16 SCR_2_RudeAspirantTrade(void) {
for (;;) {
inv_bgcolor = 0xFF;
- OpenInventory(0xFE, ITEMFLG_80);
+ OpenInventory(0xFE, ITEMFLG_OWNED);
if (inv_count == 0) {
the_command = 0xC1C5;
@@ -222,63 +241,68 @@ uint16 SCR_2_RudeAspirantTrade(void) {
the_command = 0x9140; /*NOTHING ON HIM*/
- if (pers_ptr->item == 0) {
+ if (aspirant_ptr->item == 0) {
RunCommand();
break;
}
- item1 = &inventory_items[pers_ptr->item - 1];
- item2 = (item_t *)(script_vars[ScrPool3_CurrentItem]);
+ item1 = &inventory_items[aspirant_ptr->item - 1]; /*aspirant's item*/
+ item2 = (item_t *)(script_vars[ScrPool3_CurrentItem]); /*our offer*/
- if (item2->flags == (ITEMFLG_80 | 1)) {
+ if (item2->flags == (ITEMFLG_OWNED | ITEMFLG_DONTWANT)) {
the_command = 0xC1C0;
RunCommand();
break;
}
+ /*only trade for ROPE, LANTERN, STONE FLY, GOBLET*/
if (item1->name < 104 || item1->name >= 108) {
RunCommand();
break;
}
if ((item1->name != item2->name)
- && (item2->name == 109
- || item2->name == 132
- || item2->name == 108
+ && (item2->name == 109 /*SKULL*/
+ || item2->name == 132 /*ZAPSTIK*/
+ || item2->name == 108 /*DAGGER*/
|| script_byte_vars.rand_value < 154)) {
- script_byte_vars.trade_done = 0;
+
+ /*show confirmation menu*/
+ script_byte_vars.trade_accepted = 0;
the_command = 0xC1C6;
RunCommand();
- if (script_byte_vars.trade_done == 0)
+ if (script_byte_vars.trade_accepted == 0)
break;
- item2->flags = ITEMFLG_20;
- item1->flags = ITEMFLG_80;
- pers_ptr->item = script_byte_vars.inv_item_index;
+
+ item2->flags = ITEMFLG_ASPIR;
+ item1->flags = ITEMFLG_OWNED;
+ aspirant_ptr->item = script_byte_vars.inv_item_index;
switch (item2->name) {
- case 132:
- script_byte_vars.room_items--;
+ case 132: /*ZAPSTIK*/
+ script_byte_vars.zapstiks_owned--;
the_command = 0xC04B;
break;
- case 104:
+ case 104: /*ROPE*/
the_command = 0xC1BA;
break;
- case 107:
+ case 107: /*GOBLET*/
the_command = 0xC1BB;
break;
- default:
+ default: /*STONE FLY*/
the_command = 0xC1B9;
}
RunCommand();
break;
} else {
- item2->flags = ITEMFLG_80 | 1;
- the_command = 0xC1BD; /*not interested*/
+ /*not interested*/
+ item2->flags = ITEMFLG_OWNED | ITEMFLG_DONTWANT;
+ the_command = 0xC1BD;
RunCommand();
continue;
}
}
- ClaimTradedItems();
+ ReclaimRefusedItems();
script_ptr = old_script;
script_end_ptr = old_script_end;
@@ -286,6 +310,9 @@ uint16 SCR_2_RudeAspirantTrade(void) {
return 0;
}
+/*
+Steal a Zapstik form Protozorq
+*/
uint16 SCR_4_StealZapstik(void) {
byte *old_script;
@@ -300,10 +327,10 @@ uint16 SCR_4_StealZapstik(void) {
} else {
pers->index &= ~0x18;
- script_vars[ScrPool3_CurrentItem] = &inventory_items[38 + (script_byte_vars.cur_pers - 1) - 9];
- script_byte_vars.bvar_3B++;
+ script_vars[ScrPool3_CurrentItem] = &inventory_items[kItemZapstik1 - 1 + (script_byte_vars.cur_pers - 1) - kPersProtozorq1];
+ script_byte_vars.steals_count++;
- BounceCurrentItem(ITEMFLG_80, 85); /*bounce to inventory*/
+ BounceCurrentItem(ITEMFLG_OWNED, 85); /*bounce to inventory*/
the_command = 0x9147; /*YOU GET HIS ZAPSTIK*/
if (script_byte_vars.zapstik_stolen == 0) {
@@ -322,6 +349,9 @@ uint16 SCR_4_StealZapstik(void) {
byte wait_delta = 0;
+/*
+Wait for a specified number of seconds (real time) or a keypress
+*/
void Wait(byte seconds) {
warning("STUB: Wait(%d)", seconds);
@@ -330,7 +360,7 @@ void Wait(byte seconds) {
uint16 endtime;
seconds += wait_delta;
- if (seconds > 127) /*TODO: is this a check for an unsigned value?*/
+ if (seconds > 127) /*TODO: is this a check for a negative value?*/
seconds = 0;
gettime(&t);
@@ -348,12 +378,19 @@ void Wait(byte seconds) {
#endif
}
+/*
+Wait for a 4 seconds or a keypress
+*/
uint16 SCR_2C_Wait4(void) {
script_ptr++;
Wait(4);
return 0;
}
+/*
+Wait for a specified number of seconds or a keypress
+TODO: Always waits for a 4 seconds due to a bug?
+*/
uint16 SCR_2D_Wait(void) {
byte seconds;
script_ptr++;
@@ -362,6 +399,9 @@ uint16 SCR_2D_Wait(void) {
return 0;
}
+/*
+Show blinking prompt indicator and wait for a keypress
+*/
uint16 SCR_2E_PromptWait(void) {
script_ptr++;
PromptWait();
@@ -379,6 +419,9 @@ uint16 SCR_2E_PromptWait(void) {
byte var_size;
+/*
+Fetch variable's value and address
+*/
uint16 LoadVar(byte **ptr, byte **varptr) {
byte vartype;
byte *varbase;
@@ -418,8 +461,8 @@ uint16 LoadVar(byte **ptr, byte **varptr) {
case ScrPool6_Inventory:
maxoffs = sizeof(inventory_items);
break;
- case ScrPool7_Inventory38:
- maxoffs = sizeof(inventory_items) - sizeof(item_t) * 38;
+ case ScrPool7_Zapstiks:
+ maxoffs = sizeof(inventory_items) - sizeof(item_t) * (kItemZapstik1 - 1);
break;
case ScrPool8_CurrentPers:
maxoffs = sizeof(pers_t);
@@ -471,6 +514,9 @@ uint16 LoadVar(byte **ptr, byte **varptr) {
#define MATHOP_LE 0x02
#define MATHOP_GE 0x01
+/*
+Perform math/logic operation on two operands
+*/
uint16 MathOp(byte op, uint16 op1, uint16 op2) {
if (op & MATHOP_CMP) {
if (op & MATHOP_EQ)
@@ -501,6 +547,9 @@ uint16 MathOp(byte op, uint16 op1, uint16 op2) {
}
}
+/*
+Evaluate an expression
+*/
uint16 MathExpr(byte **ptr) {
byte op;
uint16 op1, op2;
@@ -514,7 +563,7 @@ uint16 MathExpr(byte **ptr) {
}
/*
-Math operations (assignment) on a variable
+Evaluate an expression and assign result to a variable
*/
uint16 SCR_3B_MathExpr(void) {
uint16 op1, op2;
@@ -522,8 +571,13 @@ uint16 SCR_3B_MathExpr(void) {
script_ptr++;
+ /*get result variable pointer*/
op1 = LoadVar(&script_ptr, &opptr);
+
+ /*evaluate*/
op2 = MathExpr(&script_ptr);
+
+ /*store result*/
if (var_size == VARSIZE_BYTE)
*opptr = op2 & 255;
else {
@@ -535,7 +589,9 @@ uint16 SCR_3B_MathExpr(void) {
return 0;
}
-/*Discard current callchain (the real one) and execute command*/
+/*
+Discard current callchain (the real one) and execute command
+*/
uint16 SCR_4D_PriorityCommand(void) {
script_ptr++;
the_command = *script_ptr++; /*little-endian*/
@@ -552,7 +608,9 @@ uint16 SCR_4D_PriorityCommand(void) {
return ScriptRerun;
}
-/*Jump to routine*/
+/*
+Jump to routine
+*/
uint16 SCR_12_Chain(void) {
script_ptr++;
the_command = *script_ptr++; /*little-endian*/
@@ -614,7 +672,9 @@ uint16 SCR_35_Ret(void) {
return 0;
}
-/*Draw portrait, pushing it from left to right*/
+/*
+Draw portrait, pushing it from left to right
+*/
uint16 SCR_5_DrawPortraitLiftRight(void) {
byte x, y, width, height;
@@ -628,7 +688,9 @@ uint16 SCR_5_DrawPortraitLiftRight(void) {
return 0;
}
-/*Draw portrait, pushing it from right to left*/
+/*
+Draw portrait, pushing it from right to left
+*/
uint16 SCR_6_DrawPortraitLiftLeft(void) {
byte x, y, width, height;
@@ -642,7 +704,9 @@ uint16 SCR_6_DrawPortraitLiftLeft(void) {
return 0;
}
-/*Draw portrait, pushing it from top to bottom*/
+/*
+Draw portrait, pushing it from top to bottom
+*/
uint16 SCR_7_DrawPortraitLiftDown(void) {
byte x, y, width, height;
@@ -656,7 +720,9 @@ uint16 SCR_7_DrawPortraitLiftDown(void) {
return 0;
}
-/*Draw portrait, pushing it from bottom to top*/
+/*
+Draw portrait, pushing it from bottom to top
+*/
uint16 SCR_8_DrawPortraitLiftUp(void) {
byte x, y, width, height;
@@ -670,7 +736,9 @@ uint16 SCR_8_DrawPortraitLiftUp(void) {
return 0;
}
-/*Draw portrait, no special effects*/
+/*
+Draw portrait, no special effects
+*/
uint16 SCR_9_DrawPortrait(void) {
byte x, y, width, height;
@@ -683,12 +751,16 @@ uint16 SCR_9_DrawPortrait(void) {
return 0;
}
-/*Draw portrait, no special effects*/
+/*
+Draw portrait, no special effects
+*/
uint16 SCR_A_DrawPortrait(void) {
return SCR_9_DrawPortrait();
}
-/*Draw screen pixels using 2-phase clockwise twist*/
+/*
+Draw screen pixels using 2-phase clockwise twist
+*/
void TwistDraw(byte x, byte y, byte width, byte height, byte *source, byte *target) {
int16 i;
uint16 sx, ex, sy, ey, t;
@@ -720,7 +792,9 @@ void TwistDraw(byte x, byte y, byte width, byte height, byte *source, byte *targ
}
}
-/*Draw image with twist-effect*/
+/*
+Draw image with twist-effect
+*/
uint16 SCR_B_DrawPortraitTwistEffect(void) {
byte x, y, width, height;
uint16 offs;
@@ -739,7 +813,9 @@ uint16 SCR_B_DrawPortraitTwistEffect(void) {
return 0;
}
-/*Draw screen pixels using arc-like sweep*/
+/*
+Draw screen pixels using arc-like sweep
+*/
void ArcDraw(byte x, byte y, byte width, byte height, byte *source, byte *target) {
int16 i;
uint16 sx, ex, sy, ey;
@@ -767,7 +843,9 @@ void ArcDraw(byte x, byte y, byte width, byte height, byte *source, byte *target
}
}
-/*Draw image with arc-effect*/
+/*
+Draw image with arc-effect
+*/
uint16 SCR_C_DrawPortraitArcEffect(void) {
byte x, y, width, height;
uint16 offs;
@@ -786,7 +864,9 @@ uint16 SCR_C_DrawPortraitArcEffect(void) {
return 0;
}
-/*Draw image with slow top-to-down reveal effect by repeatedly draw its every 17th pixel*/
+/*
+Draw image with slow top-to-down reveal effect by repeatedly draw its every 17th pixel
+*/
uint16 SCR_D_DrawPortraitDotEffect(void) {
int16 i;
byte x, y, width, height;
@@ -862,7 +942,9 @@ uint16 SCR_10_DrawPortraitZoomed(void) {
return 0;
}
-/*Hide portrait, pushing it from right to left*/
+/*
+Hide portrait, pushing it from right to left
+*/
uint16 SCR_19_HidePortraitLiftLeft(void) {
byte index;
byte kind;
@@ -906,7 +988,9 @@ uint16 SCR_19_HidePortraitLiftLeft(void) {
return 0;
}
-/*Hide portrait, pushing it from left to right*/
+/*
+Hide portrait, pushing it from left to right
+*/
uint16 SCR_1A_HidePortraitLiftRight(void) {
byte index;
byte kind;
@@ -949,7 +1033,9 @@ uint16 SCR_1A_HidePortraitLiftRight(void) {
return 0;
}
-/*Hide portrait, pushing it from bottom to top*/
+/*
+Hide portrait, pushing it from bottom to top
+*/
uint16 SCR_1B_HidePortraitLiftUp(void) {
byte index;
byte kind;
@@ -983,7 +1069,9 @@ uint16 SCR_1B_HidePortraitLiftUp(void) {
}
-/*Hide portrait, pushing it from top to bottom*/
+/*
+Hide portrait, pushing it from top to bottom
+*/
uint16 SCR_1C_HidePortraitLiftDown(void) {
byte index;
byte kind;
@@ -1017,7 +1105,9 @@ uint16 SCR_1C_HidePortraitLiftDown(void) {
}
-/*Hide portrait with twist effect*/
+/*
+Hide portrait with twist effect
+*/
uint16 SCR_1E_HidePortraitTwist(void) {
byte index;
byte kind;
@@ -1039,7 +1129,9 @@ uint16 SCR_1E_HidePortraitTwist(void) {
return 0;
}
-/*Hide portrait with arc effect*/
+/*
+Hide portrait with arc effect
+*/
uint16 SCR_1F_HidePortraitArc(void) {
byte index;
byte kind;
@@ -1061,7 +1153,9 @@ uint16 SCR_1F_HidePortraitArc(void) {
return 0;
}
-/*Hide portrait with dots effect*/
+/*
+Hide portrait with dots effect
+*/
uint16 SCR_20_HidePortraitDots(void) {
byte index;
byte kind;
@@ -1085,7 +1179,9 @@ uint16 SCR_20_HidePortraitDots(void) {
return 0;
}
-
+/*
+Play room's door open animation
+*/
uint16 SCR_39_AnimRoomDoorOpen(void) {
byte door;
@@ -1095,6 +1191,9 @@ uint16 SCR_39_AnimRoomDoorOpen(void) {
return 0;
}
+/*
+Play room's door close animation
+*/
uint16 SCR_3A_AnimRoomDoorClose(void) {
byte door;
@@ -1142,6 +1241,9 @@ static jpoint_t jdeltas[JCOUNT] = {
{ -1, -2}
};
+/*
+Play exploding zoom animation
+*/
void JaggedZoom(byte *source, byte *target) {
int16 i;
jpoint_t points[JCOUNT + 1];
@@ -1207,12 +1309,18 @@ typedef struct star_t {
uint16 z;
} star_t;
+/*
+Generate random star
+*/
void RandomStar(star_t *star) {
star->x = RandW();
star->y = RandW();
star->z = RandW() & 0xFFF;
}
+/*
+Generate a bunch of random stars
+*/
star_t *InitStarfield(void) {
int16 i;
star_t *stars = (star_t *)scratch_mem2;
@@ -1225,6 +1333,9 @@ star_t *InitStarfield(void) {
return stars;
}
+/*
+Draw a frame of starfield animation and update stars
+*/
void DrawStars(star_t *stars, int16 iter, byte *target) {
int16 i;
/*TODO: bug? initialized 300 stars, but animated only 256?*/
@@ -1267,12 +1378,18 @@ void DrawStars(star_t *stars, int16 iter, byte *target) {
}
}
+/*
+Play starfield animation
+*/
void AnimStarfield(star_t *stars, byte *target) {
int16 i;
for (i = 100; i; i--)
DrawStars(stars, i, target);
}
+/*
+Play Game Over sequence and restart the game
+*/
uint16 SCR_26_GameOver(void) {
in_de_profundis = 0;
script_byte_vars.game_paused = 1;
@@ -1295,14 +1412,18 @@ uint16 SCR_26_GameOver(void) {
return 0;
}
-
-uint16 SCR_4C_DrawZoneObjs(void) {
+/*
+Draw all active room's persons
+*/
+uint16 SCR_4C_DrawPersons(void) {
script_ptr++;
- DrawZoneObjs();
+ DrawPersons();
return 0;
}
-
+/*
+Redraw all room's static objects
+*/
uint16 SCR_13_RedrawRoomStatics(void) {
byte index;
script_ptr++;
@@ -1312,7 +1433,8 @@ uint16 SCR_13_RedrawRoomStatics(void) {
}
/*
-Load and draw zone (to backbuffer)
+Go to a new zone
+If go through a door, play door's opening animation
*/
uint16 SCR_42_LoadZone(void) {
byte index;
@@ -1320,24 +1442,24 @@ uint16 SCR_42_LoadZone(void) {
script_ptr++;
index = *script_ptr++;
- zone_drawn = 0;
+ skip_zone_transition = 0;
if (right_button)
- script_byte_vars.bvar_02 = 0;
+ script_byte_vars.last_door = 0;
else {
if ((script_byte_vars.cur_spot_flags & (SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8)) == 0)
- script_byte_vars.bvar_02 = script_byte_vars.cur_spot_flags & 7;
+ script_byte_vars.last_door = script_byte_vars.cur_spot_flags & 7;
else if ((script_byte_vars.cur_spot_flags & ((SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8))) == SPOTFLG_8) {
- zone_drawn = 1;
+ skip_zone_transition = 1;
AnimRoomDoorOpen(script_byte_vars.cur_spot_idx);
- script_byte_vars.bvar_02 = script_byte_vars.cur_spot_flags & 7;
+ script_byte_vars.last_door = script_byte_vars.cur_spot_flags & 7;
} else
- script_byte_vars.bvar_02 = 0;
+ script_byte_vars.last_door = 0;
}
- UpdateZoneSpot(index);
+ BeforeChangeZone(index);
ChangeZone(index);
script_byte_vars.zone_area_copy = script_byte_vars.zone_area;
script_byte_vars.cur_spot_idx = FindInitialSpot();
- zone_drawn |= script_byte_vars.cur_spot_idx;
+ skip_zone_transition |= script_byte_vars.cur_spot_idx;
DrawRoomStatics();
@@ -1347,26 +1469,35 @@ uint16 SCR_42_LoadZone(void) {
}
BackupSpotsImages();
- PrepareCommand3();
- PrepareCommand4();
- PrepareCommand1();
- DrawZoneObjs();
+ PrepareVorts();
+ PrepareTurkey();
+ PrepareAspirant();
+ DrawPersons();
script_byte_vars.cur_spot_flags = 0;
return 0;
}
+/*
+Draw current sprites
+*/
uint16 SCR_59_BlitSpritesToBackBuffer(void) {
script_ptr++;
BlitSpritesToBackBuffer();
return 0;
}
+/*
+Apply current palette
+*/
uint16 SCR_5A_SelectPalette(void) {
script_ptr++;
SelectPalette();
return 0;
}
+/*
+Apply specific palette
+*/
uint16 SCR_5E_SelectTempPalette(void) {
byte index;
script_ptr++;
@@ -1375,19 +1506,27 @@ uint16 SCR_5E_SelectTempPalette(void) {
return 0;
}
+/*
+Draw new zone
+*/
uint16 SCR_43_RefreshZone(void) {
script_ptr++;
RefreshZone();
return 0;
}
-
+/*
+Go to new zone and draw it
+*/
uint16 SCR_36_ChangeZone(void) {
SCR_42_LoadZone();
RefreshZone();
return 0;
}
+/*
+Draw a static sprite in the room
+*/
void SCR_DrawRoomObjectBack(byte *x, byte *y, byte *w, byte *h) {
byte obj[3];
@@ -1399,16 +1538,22 @@ void SCR_DrawRoomObjectBack(byte *x, byte *y, byte *w, byte *h) {
DrawRoomStaticObject(obj, x, y, w, h);
}
+/*
+Draw a static sprite in the room (to backbuffer)
+*/
uint16 SCR_5F_DrawRoomObjectBack(void) {
byte x, y, w, h;
SCR_DrawRoomObjectBack(&x, &y, &w, &h);
return 0;
}
+/*
+Display a static sprite in the room (to screen)
+*/
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));
+ CGA_CopyScreenBlock(backbuffer, w, h, frontbuffer, CGA_CalcXY_p(x, y));
return 0;
}
@@ -1428,19 +1573,21 @@ uint16 SCR_3_DrawItemBox(void) {
if (current)
item = (item_t *)script_vars[ScrPool3_CurrentItem];
else
- item = &inventory_items[pers_ptr->item - 1];
+ item = &inventory_items[aspirant_ptr->item - 1];
x = dirty_rects[0].x;
y = dirty_rects[0].y + 70;
msg = SeekToString(desci_data, 274 + item->name);
DesciTextBox(x, y, 18, msg);
- DrawSpriteN(item->sprite, x, y + 1, CGA_SCREENBUFFER);
+ DrawSpriteN(item->sprite, x, y + 1, frontbuffer);
return 0;
}
-/*Draw simple bubble with text*/
+/*
+Draw simple bubble with text
+*/
uint16 SCR_37_DesciTextBox(void) {
byte x, y, w;
byte *msg;
@@ -1455,7 +1602,9 @@ uint16 SCR_37_DesciTextBox(void) {
}
-/*Play portrait animation*/
+/*
+Play portrait animation
+*/
uint16 SCR_18_AnimPortrait(void) {
byte layer, index, delay;
script_ptr++;
@@ -1469,7 +1618,9 @@ uint16 SCR_18_AnimPortrait(void) {
return 0;
}
-/*Play animation*/
+/*
+Play animation
+*/
uint16 SCR_38_PlayAnim(void) {
byte index, x, y;
script_ptr++;
@@ -1480,7 +1631,9 @@ uint16 SCR_38_PlayAnim(void) {
return 0;
}
-/*Pop up the actions menu and handle its commands*/
+/*
+Pop up the actions menu and handle its commands
+*/
uint16 SCR_3D_ActionsMenu(void) {
uint16 cmd;
@@ -1503,9 +1656,8 @@ uint16 SCR_3D_ActionsMenu(void) {
RunCommand();
script_byte_vars.used_commands++;
-
- if (script_byte_vars.bvar_43 == 0 && script_byte_vars.check_used_commands < script_byte_vars.used_commands) {
- the_command = Swap16(script_word_vars.next_command1);
+ if (script_byte_vars.bvar_43 == 0 && script_byte_vars.used_commands > script_byte_vars.check_used_commands) {
+ the_command = Swap16(script_word_vars.next_aspirant_cmd);
if (the_command)
return ScriptRerun;
}
@@ -1519,7 +1671,9 @@ uint16 SCR_3D_ActionsMenu(void) {
return ScriptContinue;
}
-/*The Wall room puzzle*/
+/*
+The Wall room puzzle
+*/
uint16 SCR_3E_TheWallAdvance(void) {
script_ptr++;
@@ -1681,11 +1835,11 @@ uint16 SCR_40_PopAllTextBoxes() {
}
/*
-Move a Hand in Who Will Be Saved
+Draw updated Hands in Who Will Be Saved
*/
uint16 SCR_41_LiftHand(void) {
script_ptr++;
- RedrawRoomStatics(92, script_byte_vars.bvar_2B);
+ RedrawRoomStatics(92, script_byte_vars.hands);
CGA_BackBufferToRealFull();
PlaySound(31);
return 0;
@@ -1712,19 +1866,19 @@ uint16 SCR_30_Fight(void) {
fight_mode = 1;
- if (pers->name != 44) {
- if (next_command3 == 0xA015) {
+ if (pers->name != 44) { /*VORT*/
+ if (next_vorts_cmd == 0xA015) {
the_command = 0xA015;
RunCommand();
- FindAndSelectSpot((pers - pers_list) * 5); /*TODO: FindAndSelectSpot assumes plain offset, 5-byte records*/
+ SelectPerson(PersonOffset(pers - pers_list));
}
- if (Swap16(script_word_vars.next_command1) == 0xC357) {
+ if (Swap16(script_word_vars.next_aspirant_cmd) == 0xC357) {
the_command = 0xC357;
RunCommand();
}
pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]);
- if (pers->name != 56 && pers->name != 51) {
+ if (pers->name != 56 && pers->name != 51) { /*MONKEY, TURKEY*/
x = dirty_rects[0].x + 64 / 4;
y = dirty_rects[0].y;
fight_mode = 0;
@@ -1739,7 +1893,7 @@ uint16 SCR_30_Fight(void) {
BlinkToWhite();
- if (pers->name != 44 && pers->name != 56 && pers->name != 51) {
+ if (pers->name != 44 && pers->name != 56 && pers->name != 51) { /*VORT, MONKEY, TURKEY*/
GetDirtyRectAndFree(1, &kind, &x, &y, &width, &height, &offs);
CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
}
@@ -1750,8 +1904,26 @@ uint16 SCR_30_Fight(void) {
script_byte_vars.fight_status = 0;
- if (script_byte_vars.bvar_3D == 0) {
- static byte character_strenght[] = {1, 3, 1, 1, 1, 1, 5, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1};
+ if (script_byte_vars.extreme_violence == 0) {
+ static byte character_strenght[] = {
+ 1, /*THE MASTER OF ORDEALS*/
+ 3, /*PROTOZORQ*/
+ 1, /*VORT*/
+ 1, /*THE POORMOUTH*/
+ 1, /*KHELE*/
+ 1, /*THE MISTRESS*/
+ 5, /*DEILOS*/
+ 3, /*ASPIRANT*/
+ 2, /*DIVO*/
+ 1, /*TURKEY*/
+ 1, /*PRIESTESS*/
+ 1, /*SCI FI*/
+ 1, /*NORMAJEEN*/
+ 1, /*ASH*/
+ 1, /*MONKEY*/
+ 1, /*HARSSK*/
+ 1 /*ZORQ*/
+ };
strenght = character_strenght[pers->name - 42];
@@ -1759,23 +1931,23 @@ uint16 SCR_30_Fight(void) {
if (strenght != 1 && (pers->flags & PERSFLG_80))
strenght--;
- if (script_byte_vars.room_items != 0 || script_byte_vars.bvar_66 != 0)
+ if (script_byte_vars.zapstiks_owned != 0 || script_byte_vars.bvar_66 != 0)
strenght--;
}
/*check if can increase*/
if (strenght != 5) {
- if ((pers->item >= 19 && pers->item < 23)
- || (pers->item >= 39 && pers->item < 52)
- || pers->item == 56 || pers->item == 57
+ if ((pers->item >= kItemDagger1 && pers->item <= kItemDagger4)
+ || (pers->item >= kItemZapstik1 && pers->item <= kItemZapstik13) /*TODO: ignore kItemZapstik14?*/
+ || pers->item == kItemBlade || pers->item == kItemChopper
|| ((pers->index >> 3) == 6))
strenght++;
}
/*
win flags:
- 1 - player won
- 2 - player dead
+ 1 - player win
+ 2 - player lose
0x20 - "TU NUH RAY VUN IN FAY VRABLE SIT YOU AISHUN."
0x40 - "OUT KUM UNSER TUN."
0x80 - "SIT YOU ASHUN KRITI KAL FOR TOONUH RAY VUN."
@@ -1899,26 +2071,26 @@ uint16 SCR_31_Fight2(void) {
pers->area = 0;
found_spot->flags &= ~SPOTFLG_80;
if (pers->index == 16) {
- pers_list[34].area = script_byte_vars.zone_area;
- pers_list[34].flags = pers->flags;
- if (script_byte_vars.room_items == 0) {
+ pers_list[kPersVort2].area = script_byte_vars.zone_area;
+ pers_list[kPersVort2].flags = pers->flags;
+ if (script_byte_vars.zapstiks_owned == 0) {
static const animdesc_t anim19 = {ANIMFLG_USESPOT | 19};
AnimateSpot(&anim19);
}
- the_command = next_command3;
+ the_command = next_vorts_cmd;
RunCommand();
} else if (pers->index == 8) {
- pers_list[35].area = script_byte_vars.zone_area;
- pers_list[35].flags = pers->flags;
- if (script_byte_vars.room_items == 0) {
+ pers_list[kPersVort3].area = script_byte_vars.zone_area;
+ pers_list[kPersVort3].flags = pers->flags;
+ if (script_byte_vars.zapstiks_owned == 0) {
static const animdesc_t anim20 = {ANIMFLG_USESPOT | 20};
AnimateSpot(&anim20);
}
- the_command = next_command3;
+ the_command = next_vorts_cmd;
RunCommand();
} else {
if (prev_fight_mode == 0
- && script_byte_vars.room_items != 0
+ && script_byte_vars.zapstiks_owned != 0
&& fight_mode == 0) {
script_byte_vars.fight_status &= ~1;
} else {
@@ -1929,13 +2101,13 @@ uint16 SCR_31_Fight2(void) {
prev_fight_mode = 0;
switch (pers->name) {
- case 56:
+ case 56: /*MONKEY*/
animidx = 47;
fightlist = fightlist1;
fightlistsize = 10;
break;
- case 51:
- next_command4 = 0;
+ case 51: /*TURKEY*/
+ next_turkey_cmd = 0;
animidx = 66;
fightlist = fightlist1;
fightlistsize = 10;
@@ -1970,9 +2142,9 @@ void FightWin(void) {
CGA_RestoreImage(*spot_sprite, frontbuffer);
CGA_RestoreImage(*spot_sprite, backbuffer);
- if (script_byte_vars.bvar_3D == 0
+ if (script_byte_vars.extreme_violence == 0
&& script_byte_vars.bvar_60 == 0
- && script_byte_vars.room_items != 0
+ && script_byte_vars.zapstiks_owned != 0
&& fight_mode == 0) {
script_byte_vars.bvar_67 = 1;
PlaySound(149);
@@ -1980,8 +2152,8 @@ void FightWin(void) {
}
}
- prev_fight_mode = script_byte_vars.bvar_3D;
- script_byte_vars.bvar_3D = 0;
+ prev_fight_mode = script_byte_vars.extreme_violence;
+ script_byte_vars.extreme_violence = 0;
}
uint16 SCR_32_FightWin(void) {
@@ -1997,7 +2169,7 @@ void DrawDeathAnim(void) {
int16 i;
/*remove existing cadaver if any*/
- if (FindAndSelectSpot(38 * 5)) {
+ if (SelectPerson(PersonOffset(kPersCadaver))) {
found_spot->flags &= ~SPOTFLG_80;
CGA_RestoreImage(*spot_sprite, backbuffer);
}
@@ -2024,14 +2196,14 @@ uint16 SCR_60_ReviveCadaver(void) {
BlitSpritesToBackBuffer();
- FindAndSelectSpot(38 * 5);
+ SelectPerson(PersonOffset(kPersCadaver));
script_byte_vars.bvar_60 = 1;
FightWin();
script_byte_vars.bvar_60 = 0;
- pers_list[38].area = 0;
+ pers_list[kPersCadaver].area = 0;
- FindAndSelectSpot(fight_pers_ofs);
+ SelectPerson(fight_pers_ofs);
zone_spots[5].flags = SPOTFLG_40 | SPOTFLG_10 | SPOTFLG_2 | SPOTFLG_1;
found_spot->flags |= SPOTFLG_80;
@@ -2039,7 +2211,7 @@ uint16 SCR_60_ReviveCadaver(void) {
pers->flags &= ~PERSFLG_40;
pers->area = script_byte_vars.zone_area;
- DrawZoneObjs();
+ DrawPersons();
CGA_BackBufferToRealFull();
return 0;
@@ -2094,7 +2266,7 @@ uint16 SCR_15_SelectSpot(void) {
FindPerson();
if (script_byte_vars.cur_pers == 0)
- script_vars[ScrPool8_CurrentPers] = &pers_list[20];
+ script_vars[ScrPool8_CurrentPers] = &pers_list[kPersProtozorq12];
return 0;
}
@@ -2263,7 +2435,6 @@ uint16 SCR_49_DeProfundisRiseHook(void) {
return 0;
}
-
/*
Animate De Profundis platform
*/
@@ -2335,7 +2506,7 @@ Draw item bounce to room objects animation
*/
uint16 SCR_4E_BounceCurrentItemToRoom(void) {
script_ptr++;
- BounceCurrentItem(ITEMFLG_40, 43);
+ BounceCurrentItem(ITEMFLG_ROOM, 43);
return 0;
}
@@ -2344,7 +2515,7 @@ Draw item bounce to inventory animation
*/
uint16 SCR_4F_BounceCurrentItemToInventory(void) {
script_ptr++;
- BounceCurrentItem(ITEMFLG_80, 85);
+ BounceCurrentItem(ITEMFLG_OWNED, 85);
return 0;
}
@@ -2358,7 +2529,7 @@ uint16 SCR_50_BounceItemToInventory(void) {
itemidx = *script_ptr++;
script_vars[ScrPool3_CurrentItem] = &inventory_items[itemidx - 1];
- BounceCurrentItem(ITEMFLG_80, 85);
+ BounceCurrentItem(ITEMFLG_OWNED, 85);
return 0;
}
@@ -2375,35 +2546,43 @@ uint16 SCR_4B_ProtoDropZapstik(void) {
pers->index &= ~0x18;
- script_vars[ScrPool3_CurrentItem] = &inventory_items[38 + (script_byte_vars.cur_pers - 1) - 9];
+ script_vars[ScrPool3_CurrentItem] = &inventory_items[kItemZapstik1 - 1 + (script_byte_vars.cur_pers - 1) - kPersProtozorq1];
- BounceCurrentItem(ITEMFLG_40, 43);
+ BounceCurrentItem(ITEMFLG_ROOM, 43);
return 0;
}
-/*Take away a person's item*/
-void TakePersonsItem(void) {
- if (pers_ptr->item != 0) {
- item_t *item = &inventory_items[pers_ptr->item - 1];
- pers_ptr->item = 0;
+/*
+Take away Aspirant's item and bounce it to the inventory
+*/
+void LootAspirantsItem(void) {
+ if (aspirant_ptr->item != 0) {
+ item_t *item = &inventory_items[aspirant_ptr->item - 1];
+ aspirant_ptr->item = 0;
script_vars[ScrPool3_CurrentItem] = item;
- script_byte_vars.bvar_3B++;
- script_byte_vars.bvar_6D[pers_ptr->index >> 6] = item->name; /*TODO: check these index bits*/
- BounceCurrentItem(ITEMFLG_80, 85);
+ script_byte_vars.steals_count++;
+ script_byte_vars.bvar_6D[aspirant_ptr->index >> 6] = item->name; /*TODO: check these index bits*/
+ BounceCurrentItem(ITEMFLG_OWNED, 85);
the_command = 0x90AA; /*OK*/
} else
the_command = 0x9140; /*NOTHING ON HIM*/
}
-uint16 SCR_2F_TakePersonsItem() {
+/*
+Take away Aspirant's item and bounce it to the inventory
+*/
+uint16 SCR_2F_LootAspirantsItem() {
script_ptr++;
- TakePersonsItem();
+ LootAspirantsItem();
return ScriptRerun;
}
-uint16 SCR_51_ItemTrade(void) {
+/*
+Trade with Skull Trader
+*/
+uint16 SCR_51_SkullTraderItemTrade(void) {
byte *old_script, *old_script_end = script_end_ptr;
byte status;
@@ -2414,35 +2593,40 @@ uint16 SCR_51_ItemTrade(void) {
old_script = script_ptr;
inv_bgcolor = 0xFF;
- OpenInventory(0xFF, ITEMFLG_80);
+ OpenInventory(0xFF, ITEMFLG_OWNED);
status = 1;
if (inv_count != 0) {
status = 2;
if (the_command != 0) {
status = 3;
- if (script_byte_vars.inv_item_index >= 6 && script_byte_vars.inv_item_index < 27) {
- the_command = 0xC204;
+ if (script_byte_vars.inv_item_index >= kItemRope1 && script_byte_vars.inv_item_index <= kItemLantern4) {
+ the_command = 0xC204; /*WHICH ONE DO YOU WANT?*/
RunCommand();
((item_t *)(script_vars[ScrPool3_CurrentItem]))->flags = 0;
- OpenInventory(0xFF, ITEMFLG_10);
+ OpenInventory(0xFF, ITEMFLG_TRADER);
status = 4;
if (the_command != 0) {
- status = 5;
+ /*50% chance to win the item*/
+ status = 5; /*lose*/
+#ifdef CHEAT_TRADER
+ { /*always win at the Skull Trader*/
+#else
if (script_byte_vars.rand_value < 128) {
- status = 6;
- ((item_t *)(script_vars[ScrPool3_CurrentItem]))[-1].flags = ITEMFLG_10; /*TODO: what's up with this index?*/
- ((item_t *)(script_vars[ScrPool3_CurrentItem]))->flags = 0;
+#endif
+ status = 6; /*win*/
+ ((item_t *)(script_vars[ScrPool3_CurrentItem]))[-1].flags = ITEMFLG_TRADER; /*offer previous item copy for next trade*/
+ ((item_t *)(script_vars[ScrPool3_CurrentItem]))->flags = 0; /*consume selected item*/
}
}
}
}
}
- script_byte_vars.trade_status = status;
+ script_byte_vars.skull_trader_status = status;
script_ptr = old_script;
script_end_ptr = old_script_end;
@@ -2704,11 +2888,11 @@ uint16 SCR_5C_ClearInventory(void) {
script_ptr++;
for (i = 0; i < MAX_INV_ITEMS; i++) {
- if (inventory_items[i].flags == ITEMFLG_80)
+ if (inventory_items[i].flags == ITEMFLG_OWNED)
inventory_items[i].flags = 0;
}
- script_byte_vars.room_items = 0;
+ script_byte_vars.zapstiks_owned = 0;
return 0;
}
@@ -2720,9 +2904,9 @@ void DropItems(int16 first, int16 count) {
int16 i;
for (i = 0; i < count; i++) {
- if (inventory_items[first + i].flags == ITEMFLG_80) {
- inventory_items[first + i].flags = ITEMFLG_40;
- inventory_items[first + i].flags2 = script_byte_vars.zone_area;
+ if (inventory_items[first + i].flags == ITEMFLG_OWNED) {
+ inventory_items[first + i].flags = ITEMFLG_ROOM;
+ inventory_items[first + i].area = script_byte_vars.zone_area;
}
}
}
@@ -2733,11 +2917,11 @@ Drop weapon-like items from inventory to room
uint16 SCR_5D_DropWeapons(void) {
script_ptr++;
- DropItems(18, 4); /*DAGGER*/
- DropItems(38, 14); /*ZAPSTIK*/
- DropItems(55, 2); /*SACRIFICIAL BLADE , CHOPPER*/
+ DropItems(kItemDagger1 - 1, 4); /*DAGGER*/
+ DropItems(kItemZapstik1 - 1, 14); /*ZAPSTIK*/
+ DropItems(kItemBlade - 1, 2); /*SACRIFICIAL BLADE , CHOPPER*/
- script_byte_vars.room_items = 0;
+ script_byte_vars.zapstiks_owned = 0;
return 0;
}
@@ -2769,7 +2953,7 @@ uint16 SCR_63_LiftSpot6(void) {
zone_spots[6].sy -= 5;
zone_spots[6].ey -= 5;
BackupSpotsImages();
- DrawZoneObjs();
+ DrawPersons();
CGA_BackBufferToRealFull();
return 0;
@@ -2981,7 +3165,7 @@ Open room's items inventory
uint16 CMD_1_RoomObjects(void) {
UpdateUndrawCursor(CGA_SCREENBUFFER);
inv_bgcolor = 0xAA;
- OpenInventory((0xFF << 8) | ITEMFLG_40, (script_byte_vars.zone_area << 8) | ITEMFLG_40);
+ OpenInventory((0xFF << 8) | ITEMFLG_ROOM, (script_byte_vars.zone_area << 8) | ITEMFLG_ROOM);
return ScriptRerun;
}
@@ -3013,7 +3197,7 @@ Open normal inventory box
uint16 CMD_3_Posessions(void) {
UpdateUndrawCursor(CGA_SCREENBUFFER);
inv_bgcolor = 0x55;
- OpenInventory(ITEMFLG_80, ITEMFLG_80);
+ OpenInventory(ITEMFLG_OWNED, ITEMFLG_OWNED);
return ScriptRerun;
}
@@ -3055,10 +3239,10 @@ uint16 CMD_5_Wait(void) {
script_byte_vars.bvar_25++;
script_word_vars.timer_ticks2 = Swap16(Swap16(script_word_vars.timer_ticks2) + 300);
- the_command = next_command3;
+ the_command = next_vorts_cmd;
RunCommand();
- the_command = next_command4;
+ the_command = next_turkey_cmd;
RunCommand();
script_byte_vars.used_commands = script_byte_vars.check_used_commands;
@@ -3066,7 +3250,7 @@ uint16 CMD_5_Wait(void) {
the_command = Swap16(script_word_vars.wvar_0E);
if (the_command == 0) {
- if (script_word_vars.next_command1 == 0) {
+ if (script_word_vars.next_aspirant_cmd == 0) {
the_command = 0x9005;
RunCommand();
}
@@ -3355,7 +3539,7 @@ uint16 CMD_10_PsiExtremeViolence(void) {
if (!ConsumePsiEnergy(8))
return 0;
- script_byte_vars.bvar_3D = 1;
+ script_byte_vars.extreme_violence = 1;
if (script_byte_vars.bvar_43 != 0) {
the_command = Swap16(script_word_vars.wvar_B2);
@@ -3366,17 +3550,17 @@ uint16 CMD_10_PsiExtremeViolence(void) {
if (script_byte_vars.cur_spot_idx == 0) {
the_command = Swap16(script_word_vars.psi_cmds[4]);
- script_byte_vars.bvar_3D = 0;
+ script_byte_vars.extreme_violence = 0;
return ScriptRerun;
}
command = GetZoneObjCommand(4 * 2);
if ((command & 0xF000) == 0x9000)
- script_byte_vars.bvar_3D = 0;
+ script_byte_vars.extreme_violence = 0;
else if (command == 0) {
the_command = Swap16(script_word_vars.psi_cmds[4]);
- script_byte_vars.bvar_3D = 0;
+ script_byte_vars.extreme_violence = 0;
}
return ScriptRerun;
@@ -3565,18 +3749,18 @@ uint16 CMD_13_ActivateFountain(void) {
/*Vorts walking into the room*/
uint16 CMD_14_VortAppear(void) {
/*TODO: check me*/
- pers_list[0].area = script_byte_vars.zone_area;
- FindAndSelectSpot(0);
+ pers_list[kPersVort].area = script_byte_vars.zone_area;
+ SelectPerson(0);
AnimateSpot(&vortanims_ptr->field_1);
- next_command3 = 0xA015;
+ next_vorts_cmd = 0xA015;
BlitSpritesToBackBuffer();
- DrawZoneObjs();
+ DrawPersons();
CGA_BackBufferToRealFull();
- next_ticks3 = Swap16(script_word_vars.timer_ticks2) + 5;
+ next_vorts_ticks = Swap16(script_word_vars.timer_ticks2) + 5;
return 0;
}
-pers_t *pers_vort_ptr;
+pers_t *vort_ptr;
#define ADJACENT_AREAS_MAX 19
@@ -3605,7 +3789,9 @@ struct {
{ 63, 65}
};
-/*Vorts walking out of the room*/
+/*
+Vorts walking out of the room
+*/
uint16 CMD_15_VortLeave(void) {
/*TODO: check me*/
@@ -3613,36 +3799,36 @@ uint16 CMD_15_VortLeave(void) {
animdesc_t *anim;
pers_t *pers;
- if (pers_list[0].area != 0) {
- pers = &pers_list[0];
+ if (pers_list[kPersVort].area != 0) {
+ pers = &pers_list[kPersVort];
anim = &vortanims_ptr->field_4;
- } else if (pers_list[34].area != 0) {
- pers = &pers_list[34];
+ } else if (pers_list[kPersVort2].area != 0) {
+ pers = &pers_list[kPersVort2];
anim = &vortanims_ptr->field_7;
} else {
script_byte_vars.bvar_36 |= 0x80;
- pers_list[35].area = 0;
- pers_list[0].flags = pers_list[35].flags;
+ pers_list[kPersVort3].area = 0;
+ pers_list[kPersVort].flags = pers_list[kPersVort3].flags;
- pers = &pers_list[0];
+ pers = &pers_list[kPersVort];
anim = &vortanims_ptr->field_A;
}
pers->area = 0;
- next_command3 = 0;
+ next_vorts_cmd = 0;
for (i = 0; i < ADJACENT_AREAS_MAX; i++) {
if (adjacent_areas[i].zone == script_byte_vars.zone_index) {
- next_command3 = 0xA016;
- next_ticks3 = Swap16(script_word_vars.timer_ticks2) + 5;
+ next_vorts_cmd = 0xA016;
+ next_vorts_ticks = Swap16(script_word_vars.timer_ticks2) + 5;
pers->area = adjacent_areas[i].area;
}
}
- pers_vort_ptr = pers;
+ vort_ptr = pers;
zone_spots[(pers->flags & 15) - 1].flags &= ~SPOTFLG_80;
- FindAndSelectSpot(0);
+ SelectPerson(0);
AnimateSpot(anim);
script_byte_vars.bvar_36 &= 0x80;
return 0;
@@ -3652,16 +3838,22 @@ uint16 CMD_15_VortLeave(void) {
Vorts left the room
*/
uint16 CMD_16_VortGone(void) {
- pers_vort_ptr->area = 0;
- next_command3 = 0;
+ vort_ptr->area = 0;
+ next_vorts_cmd = 0;
return 0;
}
-uint16 CMD_17_TakePersonsItem() {
- TakePersonsItem();
- return ScriptRerun;
+/*
+Take away Aspirant's item and bounce it to the inventory
+*/
+uint16 CMD_17_LootAspirantsItem() {
+ LootAspirantsItem();
+ return ScriptRerun;
}
+/*
+Aspirant walking out of the room
+*/
uint16 CMD_18_AspirantLeave(void) {
/*TODO: check me*/
static const animdesc_t anim33 = {ANIMFLG_USESPOT | 33};
@@ -3669,13 +3861,13 @@ uint16 CMD_18_AspirantLeave(void) {
PopDirtyRects(DirtyRectSprite);
PopDirtyRects(DirtyRectText);
- pers_ptr->area = 0;
- script_word_vars.next_command1 = BE(0);
+ aspirant_ptr->area = 0;
+ script_word_vars.next_aspirant_cmd = BE(0);
- if ((pers_ptr->flags & PERSFLG_40) == 0) {
- spot_ptr->flags &= ~SPOTFLG_80;
- FindAndSelectSpot(script_byte_vars.quest_item_ofs);
- script_byte_vars.bvar_39 = 0;
+ if ((aspirant_ptr->flags & PERSFLG_40) == 0) {
+ aspirant_spot->flags &= ~SPOTFLG_80;
+ SelectPerson(script_byte_vars.aspirant_pers_ofs);
+ script_byte_vars.aspirant_flags = 0;
AnimateSpot(&anim33);
}
@@ -3719,52 +3911,52 @@ uint16 CMD_1B_Holo(void) {
Turkey walking into the room
*/
uint16 CMD_1E_TurkeyAppear(void) {
- /*TODO: check me*/
- pers_list[5].area = script_byte_vars.zone_area;
- FindAndSelectSpot(5 * 5);
- AnimateSpot(&turkeyanims_ptr->field_1);
- next_command4 = 0xA01F;
- BlitSpritesToBackBuffer();
- DrawZoneObjs();
- CGA_BackBufferToRealFull();
- next_ticks4 = Swap16(script_word_vars.timer_ticks2) + 5;
- return 0;
+ /*TODO: check me*/
+ pers_list[kPersTurkey].area = script_byte_vars.zone_area;
+ SelectPerson(PersonOffset(kPersTurkey));
+ AnimateSpot(&turkeyanims_ptr->field_1);
+ next_turkey_cmd = 0xA01F;
+ BlitSpritesToBackBuffer();
+ DrawPersons();
+ CGA_BackBufferToRealFull();
+ next_turkey_ticks = Swap16(script_word_vars.timer_ticks2) + 5;
+ return 0;
}
/*
Turkey leaving the room
*/
uint16 CMD_1F_TurkeyLeave(void) {
- uint16 i;
- animdesc_t *anim;
- pers_t *pers;
+ uint16 i;
+ animdesc_t *anim;
+ pers_t *pers;
- pers = &pers_list[5];
- anim = &turkeyanims_ptr->field_4;
+ pers = &pers_list[kPersTurkey];
+ anim = &turkeyanims_ptr->field_4;
- pers->area = 0;
- next_command4 = 0;
- for (i = 0; i < ADJACENT_AREAS_MAX; i++) {
- if (adjacent_areas[i].zone == script_byte_vars.zone_index) {
- next_command4 = 0xA020;
- next_ticks4 = Swap16(script_word_vars.timer_ticks2) + 5;
- pers->area = adjacent_areas[i].area;
- }
- }
+ pers->area = 0;
+ next_turkey_cmd = 0;
+ for (i = 0; i < ADJACENT_AREAS_MAX; i++) {
+ if (adjacent_areas[i].zone == script_byte_vars.zone_index) {
+ next_turkey_cmd = 0xA020;
+ next_turkey_ticks = Swap16(script_word_vars.timer_ticks2) + 5;
+ pers->area = adjacent_areas[i].area;
+ }
+ }
- zone_spots[(pers->flags & 15) - 1].flags &= ~SPOTFLG_80;
+ zone_spots[(pers->flags & 15) - 1].flags &= ~SPOTFLG_80;
- FindAndSelectSpot(5 * 5);
- AnimateSpot(anim);
- return 0;
+ SelectPerson(PersonOffset(kPersTurkey));
+ AnimateSpot(anim);
+ return 0;
}
/*
Turkey left the room
*/
uint16 CMD_20_TurkeyGone(void) {
- pers_list[5].area = 0;
- next_command4 = 0;
+ pers_list[kPersTurkey].area = 0;
+ next_turkey_cmd = 0;
return 0;
}
@@ -3815,6 +4007,9 @@ uint16 CMD_24_(void) {
return ScriptRerun;
}
+/*
+Load save file
+*/
uint16 CMD_25_LoadGame(void) {
if (LoadScena())
the_command = 0x918F; /*error loading*/
@@ -3823,6 +4018,9 @@ uint16 CMD_25_LoadGame(void) {
return ScriptRerun;
}
+/*
+Write save file
+*/
uint16 CMD_26_SaveGame(void) {
if (SaveScena())
the_command = 0x9190; /*error saving*/
@@ -3859,7 +4057,7 @@ cmdhandler_t command_handlers[] = {
CMD_14_VortAppear,
CMD_15_VortLeave,
CMD_16_VortGone,
- CMD_17_TakePersonsItem,
+ CMD_17_LootAspirantsItem,
CMD_18_AspirantLeave,
CMD_TRAP,
CMD_TRAP,
@@ -3926,7 +4124,7 @@ cmdhandler_t script_handlers[] = {
SCR_2C_Wait4,
SCR_2D_Wait,
SCR_2E_PromptWait,
- SCR_2F_TakePersonsItem,
+ SCR_2F_LootAspirantsItem,
SCR_30_Fight, /*30*/
SCR_31_Fight2,
SCR_32_FightWin,
@@ -3955,12 +4153,12 @@ cmdhandler_t script_handlers[] = {
SCR_49_DeProfundisRiseHook,
SCR_4A_Unused,
SCR_4B_ProtoDropZapstik,
- SCR_4C_DrawZoneObjs,
+ SCR_4C_DrawPersons,
SCR_4D_PriorityCommand,
SCR_4E_BounceCurrentItemToRoom,
SCR_4F_BounceCurrentItemToInventory,
SCR_50_BounceItemToInventory, /*50*/
- SCR_51_ItemTrade,
+ SCR_51_SkullTraderItemTrade,
SCR_52_RefreshSpritesData,
SCR_53_FindInvItem,
SCR_54_DotFadeRoom,
@@ -3994,6 +4192,9 @@ int16 runscr_reentr = 0;
int16 runcmd_reentr = 0;
#endif
+/*
+Run script routine
+*/
uint16 RunScript(byte *code) {
uint16 status = ScriptContinue;
@@ -4040,10 +4241,16 @@ uint16 RunScript(byte *code) {
return status;
}
+/*
+Get script routine
+*/
byte *GetScriptSubroutine(uint16 index) {
return SeekToEntry(templ_data, index, &script_end_ptr);
}
+/*
+Run script command
+*/
uint16 RunCommand(void) {
uint16 res;
uint16 cmd;
diff --git a/engines/chamber/script.h b/engines/chamber/script.h
index d89e257bede..50c45a8bbd8 100644
--- a/engines/chamber/script.h
+++ b/engines/chamber/script.h
@@ -36,7 +36,7 @@ enum ScriptPools {
ScrPool4_ZoneSpots,
ScrPool5_Persons,
ScrPool6_Inventory,
- ScrPool7_Inventory38,
+ ScrPool7_Zapstiks,
ScrPool8_CurrentPers,
ScrPools_MAX
};
@@ -45,7 +45,7 @@ enum ScriptPools {
typedef struct script_byte_vars_t {
byte zone_index; /* 0 */
byte zone_room; /* 1 */
- byte bvar_02; /* 2 */
+ byte last_door; /* 2 */
byte cur_spot_idx; /* 3 */
byte the_wall_phase; /* 4 */
byte prev_zone_index; /* 5 */
@@ -88,27 +88,27 @@ typedef struct script_byte_vars_t {
byte bvar_28; /* 28 */
byte bvar_29; /* 29 */
byte bvar_2A; /* 2A */
- byte bvar_2B; /* 2B */ /*TODO: hand height*/
+ byte hands; /* 2B */
byte check_used_commands; /* 2C */
byte bvar_2D; /* 2D */
byte palette_index; /* 2E */
byte bvar_2F; /* 2F */
byte bvar_30; /* 30 */
- byte room_items; /* 31 */
+ byte zapstiks_owned; /* 31 */
byte bvar_32; /* 32 */
byte bvar_33; /* 33 */
byte bvar_34; /* 34 */
- byte bvar_35; /* 35 */
+ byte skulls_submitted; /* 35 */
byte bvar_36; /* 36 */
byte bvar_37; /* 37 */
byte zone_area_copy; /* 38 */
- byte bvar_39; /* 39 */
- byte quest_item_ofs; /* 3A */
- byte bvar_3B; /* 3B */
+ byte aspirant_flags; /* 39 */
+ byte aspirant_pers_ofs;/* 3A */
+ byte steals_count; /* 3B */
byte fight_status; /* 3C */
- byte bvar_3D; /* 3D */
- byte trade_done; /* 3E */
+ byte extreme_violence; /* 3D */
+ byte trade_accepted; /* 3E */
byte bvar_3F; /* 3F */
byte bvar_40; /* 40 */
@@ -119,7 +119,7 @@ typedef struct script_byte_vars_t {
byte bvar_45; /* 45 */
byte bvar_46; /* 46 */
byte game_paused; /* 47 */
- byte trade_status; /* 48 */
+ byte skull_trader_status;/* 48 */
byte cur_spot_flags; /* 49 */
byte bvar_4A; /* 4A */
byte bvar_4B; /* 4B */
@@ -168,14 +168,14 @@ typedef struct script_word_vars_t {
uint16 wvar_0E; /* E */
uint16 timer_ticks2; /* 10 */
uint16 zone_obj_cmds[15 * 5]; /* 12 */
- uint16 next_command1; /* A8 */
+ uint16 next_aspirant_cmd; /* A8 */
uint16 wvar_AA; /* AA */
uint16 wvar_AC; /* AC */
uint16 wvar_AE; /* AE */
uint16 wvar_B0; /* B0 */
uint16 wvar_B2; /* B2 */
uint16 wvar_B4; /* B4 */
- uint16 next_command2; /* B6 */
+ uint16 next_protozorqs_cmd; /* B6 */
uint16 wvar_B8; /* B8 */
} script_word_vars_t;
@@ -183,20 +183,24 @@ extern void *script_vars[ScrPools_MAX];
extern script_word_vars_t script_word_vars;
extern script_byte_vars_t script_byte_vars;
-/*Trader's item*/
-#define ITEMFLG_10 0x10
+/*Don't trade this item*/
+#define ITEMFLG_DONTWANT 1
+#define ITEMFLG_04 0x04
+#define ITEMFLG_08 0x08
+/*Skull Trader's item*/
+#define ITEMFLG_TRADER 0x10
/*Aspirant's item*/
-#define ITEMFLG_20 0x20
+#define ITEMFLG_ASPIR 0x20
/*In a room?*/
-#define ITEMFLG_40 0x40
+#define ITEMFLG_ROOM 0x40
/*In pocket?*/
-#define ITEMFLG_80 0x80
+#define ITEMFLG_OWNED 0x80
/*TODO: manipulated from script, do not change*/
#include "common/pack-start.h"
typedef struct item_t {
byte flags;
- byte flags2;
+ byte area; /*item location*/
byte sprite; /*item sprite index*/
byte name; /*item name index (relative)*/
uint16 command; /*TODO: warning! in native format, check if never accessed from scripts*/
@@ -212,7 +216,7 @@ extern pers_t pers_list[PERS_MAX];
extern byte *script_stack[5 * 2];
extern byte **script_stack_ptr;
-extern pers_t *pers_vort_ptr;
+extern pers_t *vort_ptr;
#define SPECIAL_COMMANDS_MAX 20
extern uint16 menu_commands_12[SPECIAL_COMMANDS_MAX];
diff --git a/engines/chamber/scrvars.h b/engines/chamber/scrvars.h
index 9003db3e666..e351bdbcaa2 100644
--- a/engines/chamber/scrvars.h
+++ b/engines/chamber/scrvars.h
@@ -149,7 +149,7 @@ script_word_vars_t script_word_vars = {
BE(0), /* 0C */
BE(0), /* 0E */
BE(0), /* 10 */
- {0}, /* 12 */
+ {0}, /* 12 */
BE(0), /* A8 */
BE(0), /* AA */
BE(0), /* AC */
@@ -162,113 +162,113 @@ script_word_vars_t script_word_vars = {
};
item_t inventory_items[MAX_INV_ITEMS] = {
- {0x00, 0, 26, 109, 0xC0D9}, /* 0 : SKULL */
- {0x00, 0, 26, 109, 0xC0D9}, /* 1 : SKULL */
- {0x00, 0, 26, 109, 0xC0D9}, /* 2 : SKULL */
- {0x18, 0, 26, 109, 0xC0D9}, /* 3 : SKULL */
- {0x00, 0, 26, 109, 0xC0D9}, /* 4 : SKULL */
- {0x00, 0, 32, 104, 0xC0ED}, /* 5 : ROPE */
- {0x00, 0, 32, 104, 0xC0ED}, /* 6 : ROPE */
- {0x00, 0, 32, 104, 0xC0ED}, /* 7 : ROPE */
- {0x10, 0, 32, 104, 0xC0ED}, /* 8 : ROPE */
- {0x00, 0, 32, 104, 0xC0ED}, /* 9 : ROPE */
- {0x00, 0, 33, 106, 0xC0EE}, /* 10 : STONE FLY */
- {0x00, 0, 33, 106, 0xC0EE}, /* 11 : STONE FLY */
- {0x00, 0, 33, 106, 0xC0EE}, /* 12 : STONE FLY */
- {0x10, 0, 33, 106, 0xC0EE}, /* 13 : STONE FLY */
- {0x00, 0, 36, 107, 0xC0EC}, /* 14 : GOBLET */
- {0x00, 0, 36, 107, 0xC0EC}, /* 15 : GOBLET */
- {0x00, 0, 36, 107, 0xC0EC}, /* 16 : GOBLET */
- {0x10, 0, 36, 107, 0xC0EC}, /* 17 : GOBLET */
- {0x00, 0, 37, 108, 0xC0D3}, /* 18 : DAGGER */
- {0x00, 0, 37, 108, 0xC0D3}, /* 19 : DAGGER */
- {0x00, 0, 37, 108, 0xC0D3}, /* 20 : DAGGER */
- {0x10, 0, 37, 108, 0xC0D3}, /* 21 : DAGGER */
- {0x00, 0, 39, 105, 0xC0D6}, /* 22 : LANTERN */
- {0x00, 0, 39, 105, 0xC0D6}, /* 23 : LANTERN */
- {0x00, 0, 39, 105, 0xC0D6}, /* 24 : LANTERN */
- {0x10, 0, 39, 105, 0xC0D6}, /* 25 : LANTERN */
- {0x01, 0, 30, 136, 0xC126}, /* 26 : BLUE SPIDER */
- {0x01, 0, 30, 136, 0xC126}, /* 27 : BLUE SPIDER */
- {0x01, 0, 30, 136, 0xC126}, /* 28 : BLUE SPIDER */
- {0x01, 0, 30, 136, 0xC126}, /* 29 : BLUE SPIDER */
- {0x01, 0, 31, 135, 0xC126}, /* 30 : RED SPIDER */
- {0x01, 0, 31, 135, 0xC126}, /* 31 : RED SPIDER */
- {0x01, 0, 31, 135, 0xC126}, /* 32 : RED SPIDER */
- {0x01, 0, 31, 135, 0xC126}, /* 33 : RED SPIDER */
- {0x01, 38, 38, 120, 0xC132}, /* 34 : DIE */
- {0x01, 38, 38, 120, 0xC132}, /* 35 : DIE */
- {0x01, 38, 38, 120, 0xC132}, /* 36 : DIE */
- {0x01, 38, 38, 120, 0xC132}, /* 37 : DIE */
- {0x00, 0, 28, 132, 0xC0EF}, /* 38 : ZAPSTIK */
- {0x00, 0, 28, 132, 0xC0EF}, /* 39 : ZAPSTIK */
- {0x00, 0, 28, 132, 0xC0EF}, /* 40 : ZAPSTIK */
- {0x00, 0, 28, 132, 0xC0EF}, /* 41 : ZAPSTIK */
- {0x00, 0, 28, 132, 0xC0EF}, /* 42 : ZAPSTIK */
- {0x00, 0, 28, 132, 0xC0EF}, /* 43 : ZAPSTIK */
- {0x00, 0, 28, 132, 0xC0EF}, /* 44 : ZAPSTIK */
- {0x00, 0, 28, 132, 0xC0EF}, /* 45 : ZAPSTIK */
- {0x00, 0, 28, 132, 0xC0EF}, /* 46 : ZAPSTIK */
- {0x00, 0, 28, 132, 0xC0EF}, /* 47 : ZAPSTIK */
- {0x00, 0, 28, 132, 0xC0EF}, /* 48 : ZAPSTIK */
- {0x00, 0, 28, 132, 0xC0EF}, /* 49 : ZAPSTIK */
- {0x00, 0, 28, 132, 0xC0EF}, /* 50 : ZAPSTIK */
- {0x00, 0, 28, 132, 0xC0EF}, /* 51 : ZAPSTIK */
- {0x00, 0, 106, 142, 0xC2C0}, /* 52 : MASK */
- {0x00, 0, 34, 111, 0xC315}, /* 53 : WHISTLE */
- {0x00, 0, 35, 110, 0xC27E}, /* 54 : EGG */
- {0x00, 0, 40, 115, 0xC0D3}, /* 55 : SACRIFICIAL BLADE */
- {0x40, 65, 58, 117, 0xC127}, /* 56 : CHOPPER */
- {0x19, 0, 59, 116, 0xC2BD}, /* 57 : STATUE OF ZORQ */
- {0x00, 0, 105, 167, 0xC2BD}, /* 58 : STATUE OF SAURA */
- {0x00, 0, 107, 118, 0xC245}, /* 59 : FLASK */
- {0x00, 0, 108, 119, 0xC244}, /* 60 : BEAN */
- {0x35, 0, 35, 110, 0xC27E}, /* 61 : EGG */
- {0x35, 0, 35, 110, 0xC27E}, /* 62 : EGG */
+ {0x00, 0, 26, 109, 0xC0D9}, /* 0 : SKULL */
+ {0x00, 0, 26, 109, 0xC0D9}, /* 1 : SKULL */
+ {0x00, 0, 26, 109, 0xC0D9}, /* 2 : SKULL */
+ {ITEMFLG_TRADER|ITEMFLG_08, 0, 26, 109, 0xC0D9}, /* 3 : SKULL */
+ {0x00, 0, 26, 109, 0xC0D9}, /* 4 : SKULL */
+ {0x00, 0, 32, 104, 0xC0ED}, /* 5 : ROPE */
+ {0x00, 0, 32, 104, 0xC0ED}, /* 6 : ROPE */
+ {0x00, 0, 32, 104, 0xC0ED}, /* 7 : ROPE */
+ {ITEMFLG_TRADER, 0, 32, 104, 0xC0ED}, /* 8 : ROPE */
+ {0x00, 0, 32, 104, 0xC0ED}, /* 9 : ROPE */
+ {0x00, 0, 33, 106, 0xC0EE}, /* 10 : STONE FLY */
+ {0x00, 0, 33, 106, 0xC0EE}, /* 11 : STONE FLY */
+ {0x00, 0, 33, 106, 0xC0EE}, /* 12 : STONE FLY */
+ {ITEMFLG_TRADER, 0, 33, 106, 0xC0EE}, /* 13 : STONE FLY */
+ {0x00, 0, 36, 107, 0xC0EC}, /* 14 : GOBLET */
+ {0x00, 0, 36, 107, 0xC0EC}, /* 15 : GOBLET */
+ {0x00, 0, 36, 107, 0xC0EC}, /* 16 : GOBLET */
+ {ITEMFLG_TRADER, 0, 36, 107, 0xC0EC}, /* 17 : GOBLET */
+ {0x00, 0, 37, 108, 0xC0D3}, /* 18 : DAGGER */
+ {0x00, 0, 37, 108, 0xC0D3}, /* 19 : DAGGER */
+ {0x00, 0, 37, 108, 0xC0D3}, /* 20 : DAGGER */
+ {ITEMFLG_TRADER, 0, 37, 108, 0xC0D3}, /* 21 : DAGGER */
+ {0x00, 0, 39, 105, 0xC0D6}, /* 22 : LANTERN */
+ {0x00, 0, 39, 105, 0xC0D6}, /* 23 : LANTERN */
+ {0x00, 0, 39, 105, 0xC0D6}, /* 24 : LANTERN */
+ {ITEMFLG_TRADER, 0, 39, 105, 0xC0D6}, /* 25 : LANTERN */
+ {ITEMFLG_DONTWANT, 0, 30, 136, 0xC126}, /* 26 : BLUE SPIDER */
+ {ITEMFLG_DONTWANT, 0, 30, 136, 0xC126}, /* 27 : BLUE SPIDER */
+ {ITEMFLG_DONTWANT, 0, 30, 136, 0xC126}, /* 28 : BLUE SPIDER */
+ {ITEMFLG_DONTWANT, 0, 30, 136, 0xC126}, /* 29 : BLUE SPIDER */
+ {ITEMFLG_DONTWANT, 0, 31, 135, 0xC126}, /* 30 : RED SPIDER */
+ {ITEMFLG_DONTWANT, 0, 31, 135, 0xC126}, /* 31 : RED SPIDER */
+ {ITEMFLG_DONTWANT, 0, 31, 135, 0xC126}, /* 32 : RED SPIDER */
+ {ITEMFLG_DONTWANT, 0, 31, 135, 0xC126}, /* 33 : RED SPIDER */
+ {ITEMFLG_DONTWANT, kAreaTheTwins, 38, 120, 0xC132}, /* 34 : DIE */
+ {ITEMFLG_DONTWANT, kAreaTheTwins, 38, 120, 0xC132}, /* 35 : DIE */
+ {ITEMFLG_DONTWANT, kAreaTheTwins, 38, 120, 0xC132}, /* 36 : DIE */
+ {ITEMFLG_DONTWANT, kAreaTheTwins, 38, 120, 0xC132}, /* 37 : DIE */
+ {0x00, 0, 28, 132, 0xC0EF}, /* 38 : ZAPSTIK */
+ {0x00, 0, 28, 132, 0xC0EF}, /* 39 : ZAPSTIK */
+ {0x00, 0, 28, 132, 0xC0EF}, /* 40 : ZAPSTIK */
+ {0x00, 0, 28, 132, 0xC0EF}, /* 41 : ZAPSTIK */
+ {0x00, 0, 28, 132, 0xC0EF}, /* 42 : ZAPSTIK */
+ {0x00, 0, 28, 132, 0xC0EF}, /* 43 : ZAPSTIK */
+ {0x00, 0, 28, 132, 0xC0EF}, /* 44 : ZAPSTIK */
+ {0x00, 0, 28, 132, 0xC0EF}, /* 45 : ZAPSTIK */
+ {0x00, 0, 28, 132, 0xC0EF}, /* 46 : ZAPSTIK */
+ {0x00, 0, 28, 132, 0xC0EF}, /* 47 : ZAPSTIK */
+ {0x00, 0, 28, 132, 0xC0EF}, /* 48 : ZAPSTIK */
+ {0x00, 0, 28, 132, 0xC0EF}, /* 49 : ZAPSTIK */
+ {0x00, 0, 28, 132, 0xC0EF}, /* 50 : ZAPSTIK */
+ {0x00, 0, 28, 132, 0xC0EF}, /* 51 : ZAPSTIK */
+ {0x00, 0, 106, 142, 0xC2C0}, /* 52 : MASK */
+ {0x00, 0, 34, 111, 0xC315}, /* 53 : WHISTLE */
+ {0x00, 0, 35, 110, 0xC27E}, /* 54 : EGG */
+ {0x00, 0, 40, 115, 0xC0D3}, /* 55 : SACRIFICIAL BLADE */
+ {ITEMFLG_ROOM, kAreaRefectory, 58, 117, 0xC127}, /* 56 : CHOPPER */
+ {ITEMFLG_TRADER|ITEMFLG_08|ITEMFLG_DONTWANT, 0, 59, 116, 0xC2BD}, /* 57 : STATUE OF ZORQ */
+ {0x00, 0, 105, 167, 0xC2BD}, /* 58 : STATUE OF SAURA */
+ {0x00, 0, 107, 118, 0xC245}, /* 59 : FLASK */
+ {0x00, 0, 108, 119, 0xC244}, /* 60 : BEAN */
+ {0x35, 0, 35, 110, 0xC27E}, /* 61 : EGG */
+ {0x35, 0, 35, 110, 0xC27E}, /* 62 : EGG */
};
pers_t pers_list[PERS_MAX] = {
- { 0, 0, 44, 16, 0}, /* 0 : VORT */
- { 5, 0, 49, 25, 6}, /* 1 : ASPIRANT */
- { 0, 0, 49, 89, 19}, /* 2 : ASPIRANT */
- { 0, 0, 49, 153, 15}, /* 3 : ASPIRANT */
- { 0, 0, 49, 217, 11}, /* 4 : ASPIRANT */
- {59, 0, 51, 209, 0}, /* 5 : TURKEY */
- {70, 0, 52, 186, 0}, /* 6 : PRIESTESS */
- {71, 0, 52, 202, 0}, /* 7 : PRIESTESS */
- { 2, 0, 42, 42, 0}, /* 8 : THE MASTER OF ORDEALS */
- {51, 0, 43, 52, 0}, /* 9 : PROTOZORQ */
- {51, 0, 43, 52, 0}, /* 10 : PROTOZORQ */
- {51, 0, 43, 52, 0}, /* 11 : PROTOZORQ */
- {51, 0, 43, 52, 0}, /* 12 : PROTOZORQ */
- {12, 0, 43, 52, 0}, /* 13 : PROTOZORQ */
- { 5, 0, 43, 52, 0}, /* 14 : PROTOZORQ */
- { 2, 0, 43, 52, 0}, /* 15 : PROTOZORQ */
- { 2, 0, 43, 53, 0}, /* 16 : PROTOZORQ */
- { 2, 0, 43, 54, 0}, /* 17 : PROTOZORQ */
- { 5, 0, 43, 53, 0}, /* 18 : PROTOZORQ */
- {55, 0, 43, 36, 0}, /* 19 : PROTOZORQ */
- {56, 0, 43, 53, 0}, /* 20 : PROTOZORQ */
- {56, 0, 43, 54, 0}, /* 21 : PROTOZORQ */
- { 0, 0, 43, 55, 0}, /* 22 : PROTOZORQ */
- {36, 0, 45, 130, 0}, /* 23 : THE POORMOUTH */
- {40, 0, 46, 2, 0}, /* 24 : KHELE */
- {41, 0, 47, 194, 0}, /* 25 : THE MISTRESS */
- {50, 0, 48, 138, 0}, /* 26 : DEILOS */
- {99, 0, 53, 236, 0}, /* 27 : SCI FI */
- {77, 0, 54, 58, 0}, /* 28 : NORMAJEEN */
- {77, 0, 55, 65, 0}, /* 29 : ASH */
- {59, 0, 56, 125, 0}, /* 30 : MONKEY */
- { 0, 0, 57, 166, 0}, /* 31 : HARSSK */
- { 0, 0, 58, 175, 0}, /* 32 : ZORQ */
- { 0, 0, 59, 183, 0}, /* 33 : QRIICH */
- { 0, 0, 44, 8, 0}, /* 34 : VORT */
- { 0, 0, 44, 0, 0}, /* 35 : VORT */
- {59, 0, 52, 146, 0}, /* 36 : PRIESTESS */
- {63, 0, 52, 82, 0}, /* 37 : PRIESTESS */
- { 0, 0, 93, 243, 0}, /* 38 : CADAVER */
- {59, 0, 51, 209, 0}, /* 39 : TURKEY */
- {59, 0, 51, 209, 0}, /* 40 : TURKEY */
+ { 0, 0, 44, 16, 0}, /* 0 : VORT */
+ { kAreaTheMastersOrbit3, 0, 49, 25, kItemRope1}, /* 1 : ASPIRANT */
+ { 0, 0, 49, 89, kItemDagger1}, /* 2 : ASPIRANT */
+ { 0, 0, 49, 153, kItemGoblet1}, /* 3 : ASPIRANT */
+ { 0, 0, 49, 217, kItemFly1}, /* 4 : ASPIRANT */
+ { kAreaPlacatingThePowers, 0, 51, 209, 0}, /* 5 : TURKEY */
+ { kAreaAblutions, 0, 52, 186, 0}, /* 6 : PRIESTESS */
+ { kAreaCell1, 0, 52, 202, 0}, /* 7 : PRIESTESS */
+ { kAreaTheMastersOrbit1, 0, 42, 42, 0}, /* 8 : THE MASTER OF ORDEALS */
+ { kAreaTheConcourse, 0, 43, 52, 0}, /* 9 : PROTOZORQ */
+ { kAreaTheConcourse, 0, 43, 52, 0}, /* 10 : PROTOZORQ */
+ { kAreaTheConcourse, 0, 43, 52, 0}, /* 11 : PROTOZORQ */
+ { kAreaTheConcourse, 0, 43, 52, 0}, /* 12 : PROTOZORQ */
+ { kAreaTheRing2, 0, 43, 52, 0}, /* 13 : PROTOZORQ */
+ { kAreaTheMastersOrbit3, 0, 43, 52, 0}, /* 14 : PROTOZORQ */
+ { kAreaTheMastersOrbit1, 0, 43, 52, 0}, /* 15 : PROTOZORQ */
+ { kAreaTheMastersOrbit1, 0, 43, 53, 0}, /* 16 : PROTOZORQ */
+ { kAreaTheMastersOrbit1, 0, 43, 54, 0}, /* 17 : PROTOZORQ */
+ { kAreaTheMastersOrbit3, 0, 43, 53, 0}, /* 18 : PROTOZORQ */
+ { kAreaDreamsOfSlime, 0, 43, 36, 0}, /* 19 : PROTOZORQ */
+ { kAreaGuardRoom, 0, 43, 53, 0}, /* 20 : PROTOZORQ */
+ { kAreaGuardRoom, 0, 43, 54, 0}, /* 21 : PROTOZORQ */
+ { 0, 0, 43, 55, 0}, /* 22 : PROTOZORQ */
+ { kAreaTheNoose, 0, 45, 130, 0}, /* 23 : THE POORMOUTH */
+ {kAreaInTheScorpionsPresence, 0, 46, 2, 0}, /* 24 : KHELE */
+ { kAreaTheWeb, 0, 47, 194, 0}, /* 25 : THE MISTRESS */
+ { kAreaThePowersOfTheAbyss, 0, 48, 138, 0}, /* 26 : DEILOS */
+ { 99, 0, 53, 236, 0}, /* 27 : SCI FI */
+ { kAreaCavern, 0, 54, 58, 0}, /* 28 : NORMAJEEN */
+ { kAreaCavern, 0, 55, 65, 0}, /* 29 : ASH */
+ { kAreaPlacatingThePowers, 0, 56, 125, 0}, /* 30 : MONKEY */
+ { 0, 0, 57, 166, 0}, /* 31 : HARSSK */
+ { 0, 0, 58, 175, 0}, /* 32 : ZORQ */
+ { 0, 0, 59, 183, 0}, /* 33 : QRIICH */
+ { 0, 0, 44, 8, 0}, /* 34 : VORT */
+ { 0, 0, 44, 0, 0}, /* 35 : VORT */
+ { kAreaPlacatingThePowers, 0, 52, 146, 0}, /* 36 : PRIESTESS */
+ { kAreaTheThresholdOfTruth, 0, 52, 82, 0}, /* 37 : PRIESTESS */
+ { 0, 0, 93, 243, 0}, /* 38 : CADAVER */
+ { kAreaPlacatingThePowers, 0, 51, 209, 0}, /* 39 : TURKEY */
+ { kAreaPlacatingThePowers, 0, 51, 209, 0}, /* 40 : TURKEY */
};
} // End of namespace Chamber
Commit: a8a9dde2af0bdb00bd535ff1834b83d34a55dbd8
https://github.com/scummvm/scummvm/commit/a8a9dde2af0bdb00bd535ff1834b83d34a55dbd8
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Initial code for PC Speaker sound
Changed paths:
engines/chamber/chamber.cpp
engines/chamber/chamber.h
engines/chamber/kult.cpp
engines/chamber/sound.cpp
diff --git a/engines/chamber/chamber.cpp b/engines/chamber/chamber.cpp
index 78b29857d68..a30f6715997 100644
--- a/engines/chamber/chamber.cpp
+++ b/engines/chamber/chamber.cpp
@@ -49,12 +49,17 @@ ChamberEngine::ChamberEngine(OSystem *syst)
_shouldQuit = false;
_pxiData = NULL;
+
+ _speakerHandle = NULL;
+ _speakerStream = NULL;
}
ChamberEngine::~ChamberEngine() {
// Dispose your resources here
delete _rnd;
delete[] _pxiData;
+
+ deinitSound();
}
bool ChamberEngine::hasFeature(EngineFeature f) const {
diff --git a/engines/chamber/chamber.h b/engines/chamber/chamber.h
index 5ee78dce4ae..0131c468fbc 100644
--- a/engines/chamber/chamber.h
+++ b/engines/chamber/chamber.h
@@ -30,9 +30,12 @@
#include "engines/engine.h"
#include "gui/debugger.h"
-namespace Chamber {
+namespace Audio {
+class SoundHandle;
+class PCSpeaker;
+}
-class Console;
+namespace Chamber {
class ChamberEngine : public Engine {
private:
@@ -53,10 +56,16 @@ public:
byte readKeyboardChar();
+ void initSound();
+ void deinitSound();
+
public:
bool _shouldQuit;
byte *_pxiData;
+
+ Audio::PCSpeaker *_speakerStream;
+ Audio::SoundHandle *_speakerHandle;
};
void init(void);
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index dc4303ac3a1..fa2e38f266c 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -205,6 +205,8 @@ Common::Error ChamberEngine::run() {
SwitchToGraphicsMode();
+ initSound();
+
byte c;
/* Load title screen */
diff --git a/engines/chamber/sound.cpp b/engines/chamber/sound.cpp
index 2ef5f20e9c6..4b3b1a898bf 100644
--- a/engines/chamber/sound.cpp
+++ b/engines/chamber/sound.cpp
@@ -20,6 +20,9 @@
*
*/
+#include "audio/mixer.h"
+#include "audio/softsynth/pcspk.h"
+
#include "chamber/chamber.h"
#include "chamber/common.h"
#include "chamber/sound.h"
@@ -56,29 +59,21 @@ pcsample_t pc_samples[] = {
#undef N
static void SpeakerPlay(pcsample_t *sample) {
- warning("STUB: SpeakerPlay()");
-
-#if 0
- unsigned short rep, freq, delay1, delay2, delay;
- unsigned char ppi;
+ uint16 rep, freq, delay1, delay2;
freq = sample->freq;
delay1 = sample->delay1;
delay2 = sample->delay2;
- disable();
- ppi = inportb(0x61);
-
for (rep = 0; rep < sample->repeat; rep++) {
- outportb(0x43, 0xB6);
- outportb(0x42, freq & 255);
- outportb(0x42, freq >> 8);
- /*speaker off*/
- outportb(0x61, ppi & ~3);
- for (delay = delay1; delay--;) ; /*TODO: weak delay*/
- /*speaker on*/
- outportb(0x61, ppi | 3);
- for (delay = delay2; delay--;) ; /*TODO: weak delay*/
+ uint32 frequency = 1193180 / freq;
+ uint32 delayOff = delay1 * 300;
+ uint32 delayOn = delay2 * 300;
+
+ warning("freq: %d delayOff: %d delayOn: %d", frequency, delayOff, delayOn);
+
+ g_vm->_speakerStream->play(Audio::PCSpeaker::kWaveFormSquare, 1, delayOff);
+ g_vm->_speakerStream->play(Audio::PCSpeaker::kWaveFormSquare, frequency, delayOn);
if (sample->delay1sweep & 0xF000)
delay1 -= sample->delay1sweep & 0xFFF;
@@ -95,11 +90,6 @@ static void SpeakerPlay(pcsample_t *sample) {
else
freq += sample->freqsweep;
}
-
- /*turn off the speaker*/
- outportb(0x61, ppi & ~3);
- enable();
-#endif
}
#define kMaxSounds 12
@@ -120,6 +110,9 @@ unsigned char sounds_table[kMaxSounds][3] = {
};
void PlaySound(unsigned char index) {
+ SpeakerPlay(&pc_samples[index]);
+
+#if 0
int i;
for (i = 0; i < kMaxSounds; i++) {
if (sounds_table[i][0] == index
@@ -129,6 +122,23 @@ void PlaySound(unsigned char index) {
break;
}
}
+#endif
+}
+
+void ChamberEngine::initSound() {
+ // Setup mixer
+ syncSoundSettings();
+
+ _speakerHandle = new Audio::SoundHandle();
+ _speakerStream = new Audio::PCSpeaker(_mixer->getOutputRate());
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, _speakerHandle,
+ _speakerStream, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
+}
+
+void ChamberEngine::deinitSound() {
+ _mixer->stopHandle(*_speakerHandle);
+ delete g_vm->_speakerHandle;
+ delete g_vm->_speakerStream;
}
} // End of namespace Chamber
Commit: 37b0e5209e5e63d3fa23391c6473290ef3170ded
https://github.com/scummvm/scummvm/commit/37b0e5209e5e63d3fa23391c6473290ef3170ded
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix CGA_DrawHLineWithEnds() blitting
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 262a1f3a5c4..dfd81b1d4a9 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -425,13 +425,13 @@ uint16 CGA_DrawHLineWithEnds(uint16 bmask, uint16 bpix, byte color, uint16 l, by
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);
- uint16 oofs = ofs + 1;
+ uint16 oofs = ofs;
ofs ^= CGA_ODD_LINES_OFS;
if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
if (target == CGA_SCREENBUFFER)
- CGA_blitToScreen(oofs, l * 4, 1);
+ CGA_blitToScreen(oofs, l * 4 + 2, 1);
return ofs;
}
Commit: 61b4df8a8d1a5c206ebcbc3da1a4073980c92295
https://github.com/scummvm/scummvm/commit/61b4df8a8d1a5c206ebcbc3da1a4073980c92295
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Finish sound implementation
Changed paths:
engines/chamber/sound.cpp
diff --git a/engines/chamber/sound.cpp b/engines/chamber/sound.cpp
index 4b3b1a898bf..a8b834aaced 100644
--- a/engines/chamber/sound.cpp
+++ b/engines/chamber/sound.cpp
@@ -66,14 +66,12 @@ static void SpeakerPlay(pcsample_t *sample) {
delay2 = sample->delay2;
for (rep = 0; rep < sample->repeat; rep++) {
- uint32 frequency = 1193180 / freq;
- uint32 delayOff = delay1 * 300;
- uint32 delayOn = delay2 * 300;
+ uint32 frequency = 1193180 / (freq ? freq : 1);
+ uint32 delayOff = delay1 * 16; // Around 335 ticks per second
+ uint32 delayOn = delay2 * 16;
- warning("freq: %d delayOff: %d delayOn: %d", frequency, delayOff, delayOn);
-
- g_vm->_speakerStream->play(Audio::PCSpeaker::kWaveFormSquare, 1, delayOff);
- g_vm->_speakerStream->play(Audio::PCSpeaker::kWaveFormSquare, frequency, delayOn);
+ g_vm->_speakerStream->playQueue(Audio::PCSpeaker::kWaveFormSilence, frequency, delayOff);
+ g_vm->_speakerStream->playQueue(Audio::PCSpeaker::kWaveFormSquare, frequency, delayOn);
if (sample->delay1sweep & 0xF000)
delay1 -= sample->delay1sweep & 0xFFF;
Commit: 21dbd72a4148a62a38165da4bdd788311f4e3e74
https://github.com/scummvm/scummvm/commit/21dbd72a4148a62a38165da4bdd788311f4e3e74
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Clean up debugging code
Changed paths:
engines/chamber/sound.cpp
diff --git a/engines/chamber/sound.cpp b/engines/chamber/sound.cpp
index a8b834aaced..6871ca7400a 100644
--- a/engines/chamber/sound.cpp
+++ b/engines/chamber/sound.cpp
@@ -108,9 +108,6 @@ unsigned char sounds_table[kMaxSounds][3] = {
};
void PlaySound(unsigned char index) {
- SpeakerPlay(&pc_samples[index]);
-
-#if 0
int i;
for (i = 0; i < kMaxSounds; i++) {
if (sounds_table[i][0] == index
@@ -120,7 +117,6 @@ void PlaySound(unsigned char index) {
break;
}
}
-#endif
}
void ChamberEngine::initSound() {
Commit: 737bef757a3bd59af31b59c51bdfcaba73d74209
https://github.com/scummvm/scummvm/commit/737bef757a3bd59af31b59c51bdfcaba73d74209
Author: Retro-Junk (rj at localhost)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Add missing commands, fix dead bodies
Changed paths:
engines/chamber/script.cpp
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 34ecb9fe5de..5df59b89af7 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -1948,6 +1948,8 @@ uint16 SCR_30_Fight(void) {
win flags:
1 - player win
2 - player lose
+ 4 - "YOU RUN..."
+ 8 - "THE ASPIRANT STEALS EVERYTHING YOU HAVE!"
0x20 - "TU NUH RAY VUN IN FAY VRABLE SIT YOU AISHUN."
0x40 - "OUT KUM UNSER TUN."
0x80 - "SIT YOU ASHUN KRITI KAL FOR TOONUH RAY VUN."
@@ -2070,7 +2072,7 @@ uint16 SCR_31_Fight2(void) {
pers->flags |= PERSFLG_40;
pers->area = 0;
found_spot->flags &= ~SPOTFLG_80;
- if (pers->index == 16) {
+ if (pers->index == 16) { /*Vort trio*/
pers_list[kPersVort2].area = script_byte_vars.zone_area;
pers_list[kPersVort2].flags = pers->flags;
if (script_byte_vars.zapstiks_owned == 0) {
@@ -2079,7 +2081,7 @@ uint16 SCR_31_Fight2(void) {
}
the_command = next_vorts_cmd;
RunCommand();
- } else if (pers->index == 8) {
+ } else if (pers->index == 8) { /*Vort duo*/
pers_list[kPersVort3].area = script_byte_vars.zone_area;
pers_list[kPersVort3].flags = pers->flags;
if (script_byte_vars.zapstiks_owned == 0) {
@@ -2114,7 +2116,7 @@ uint16 SCR_31_Fight2(void) {
break;
default:
animidx = 0;
- fightlist = fightlist3;
+ fightlist = fightlist2;
fightlistsize = 26;
}
@@ -3746,7 +3748,9 @@ uint16 CMD_13_ActivateFountain(void) {
return 0;
}
-/*Vorts walking into the room*/
+/*
+Vorts walking into the room
+*/
uint16 CMD_14_VortAppear(void) {
/*TODO: check me*/
pers_list[kPersVort].area = script_byte_vars.zone_area;
@@ -3874,6 +3878,47 @@ uint16 CMD_18_AspirantLeave(void) {
return 0;
}
+/*
+Aspirant walking into the room
+*/
+uint16 CMD_19_AspirantAppear(void) {
+ /*TODO: check me*/
+ static const animdesc_t anim23 = {ANIMFLG_USESPOT | 23};
+
+ PopDirtyRects(DirtyRectSprite);
+ aspirant_ptr->area = script_byte_vars.zone_area;
+ script_word_vars.next_aspirant_cmd = BE(0xA018); /*leave*/
+ script_byte_vars.check_used_commands = 3;
+ script_byte_vars.used_commands = 0;
+ SelectPerson(script_byte_vars.aspirant_pers_ofs);
+ AnimateSpot(&anim23);
+ BlitSpritesToBackBuffer();
+ DrawPersons();
+ CGA_BackBufferToRealFull();
+ if (script_byte_vars.aspirant_flags == 5) {
+ the_command = 0xC029;
+ script_byte_vars.aspirant_flags = 0;
+ return ScriptRerun;
+ }
+ if (script_byte_vars.aspirant_flags == 6) {
+ the_command = 0xC165;
+ script_byte_vars.aspirant_flags = 0;
+ return ScriptRerun;
+ }
+ return 0;
+}
+
+/*
+Aspirant is dead
+*/
+uint16 CMD_1A_AspirantDie(void) {
+ /*TODO: check me, unused in game?*/
+ script_byte_vars.bvar_45 = 0;
+ zone_spots[5].flags = SPOTFLG_40 | SPOTFLG_10 | SPOTFLG_2 | SPOTFLG_1;
+ script_word_vars.next_aspirant_cmd = 0;
+ DrawDeathAnim();
+ return 0;
+}
/*
Show Holo screen anim and speech
@@ -4059,8 +4104,8 @@ cmdhandler_t command_handlers[] = {
CMD_16_VortGone,
CMD_17_LootAspirantsItem,
CMD_18_AspirantLeave,
- CMD_TRAP,
- CMD_TRAP,
+ CMD_19_AspirantAppear,
+ CMD_1A_AspirantDie,
CMD_1B_Holo,
CMD_TRAP,
CMD_TRAP,
Commit: 3ef7efdbcfd54ca9f4f7ea38269c1277f27aad93
https://github.com/scummvm/scummvm/commit/3ef7efdbcfd54ca9f4f7ea38269c1277f27aad93
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Merge the US release changes
Changed paths:
A engines/chamber/ifgm.cpp
A engines/chamber/ifgm.h
engines/chamber/cga.cpp
engines/chamber/common.h
engines/chamber/dialog.cpp
engines/chamber/input.cpp
engines/chamber/input.h
engines/chamber/kult.cpp
engines/chamber/menu.cpp
engines/chamber/module.mk
engines/chamber/portrait.cpp
engines/chamber/portrait.h
engines/chamber/print.cpp
engines/chamber/print.h
engines/chamber/resdata.h
engines/chamber/room.cpp
engines/chamber/savegame.cpp
engines/chamber/script.cpp
engines/chamber/sound.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index dfd81b1d4a9..87b2d3d88ac 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -1332,7 +1332,11 @@ void CGA_ZoomImage(byte *pixels, byte w, byte h, byte nw, byte nh, byte *target,
zoom.oh = h;
zoom.ew = (w * 4) - 1;
zoom.eh = h - 1;
+#ifdef VERSION_USA
+ zoom.xbase = 0;
+#else
zoom.xbase = ((w * 4 / 2) - 1) % 4;
+#endif
/*TODO: why this nw/nh order? maybe bug*/
#if 0
diff --git a/engines/chamber/common.h b/engines/chamber/common.h
index 42e9a0c3b9d..bd330bff9c1 100644
--- a/engines/chamber/common.h
+++ b/engines/chamber/common.h
@@ -25,6 +25,8 @@
namespace Chamber {
+#define VERSION_USA
+
#define BE(x) ((((x) >> 8) | ((x) << 8)) & 0xffff)
#define LE16(x) (x)
@@ -44,11 +46,15 @@ typedef struct rect_t {
} rect_t;
#include "common/pack-end.h"
+#if 0
+#define DEBUG_ENDING
+#endif
+
#if 0
#define DEBUG
#endif
-#if 1
+#if 0
/*0 - play intro*/
/*0xFF - skip intro, quest item and teleport*/
/*other - skip intro, play quest item seq, teleport to room*/
@@ -69,7 +75,7 @@ typedef struct rect_t {
#define DEBUG_QUEST 0x40
#endif
-#if 1
+#if 0
/*Goblet -> The Twins*/
#define DEBUG_QUEST 0x80
#endif
@@ -79,12 +85,12 @@ typedef struct rect_t {
#define DEBUG_QUEST 0xC0
#endif
-#if 1
+#if 0
/*win in fights*/
#define CHEAT
#endif
-#if 1
+#if 0
/*never lose to the Skull Trader*/
#define CHEAT_TRADER
#endif
diff --git a/engines/chamber/dialog.cpp b/engines/chamber/dialog.cpp
index ce6e806d556..2a3fcd061b6 100644
--- a/engines/chamber/dialog.cpp
+++ b/engines/chamber/dialog.cpp
@@ -112,10 +112,17 @@ void DesciTextBox(uint16 x, uint16 y, uint16 width, byte *msg) {
void DrawPersonBubble(byte x, byte y, byte flags, byte *msg) {
uint16 ofs;
byte w, h;
+ uint16 ww, nw;
char_draw_max_width = flags & 0x1F;
char_xlat_table = chars_color_bonw;
+#ifdef VERSION_USA
+ CalcStringSize(msg, &ww, &nw);
+ if (ww >= char_draw_max_width)
+ char_draw_max_width = ww;
+#endif
+
/*upper border*/
ofs = CGA_CalcXY_p(x, y);
ofs = CGA_DrawHLineWithEnds(0xF00F, 0, 0, char_draw_max_width, CGA_SCREENBUFFER, ofs);
@@ -189,7 +196,7 @@ void PromptWait(void) {
cursor_anim_ticks = ticks;
ShowPromptAnim();
}
- PollInput();
+ PollInputButtonsOnly();
if (g_vm->_shouldQuit)
break;
diff --git a/engines/chamber/ifgm.cpp b/engines/chamber/ifgm.cpp
new file mode 100644
index 00000000000..b0142a025c3
--- /dev/null
+++ b/engines/chamber/ifgm.cpp
@@ -0,0 +1,93 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "chamber/chamber.h"
+#include "chamber/common.h"
+#include "chamber/ifgm.h"
+#include "chamber/dialog.h"
+#include "chamber/sound.h"
+
+namespace Chamber {
+
+byte ifgm_loaded = 0;
+byte ifgm_flag2;
+
+void IFGM_Init(void) {
+#ifdef VERSION_USA
+ /*TODO*/
+#else
+ ifgm_loaded = 0;
+#endif
+}
+
+void IFGM_Shutdown(void) {
+
+}
+
+void IFGM_Poll(void) {
+ if(!ifgm_loaded)
+ return;
+/*
+xor ax, ax
+int 0F0h
+*/
+
+}
+
+
+/*
+Load and play a sound sample.
+Return 0 if playback is unavailable
+*/
+int16 IFGM_PlaySound(byte index) {
+ if (!ifgm_loaded)
+ return 0;
+
+ /*TODO*/
+
+ return 0;
+}
+
+void IFGM_PlaySample(byte index) {
+ if (!ifgm_loaded)
+ return;
+ IFGM_PlaySound(index);
+}
+
+void IFGM_StopSample(void) {
+ if (!ifgm_loaded)
+ return;
+}
+
+static byte sfx_sounds[] = {
+ 0, 5, 10, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+void IFGM_PlaySfx(byte index) {
+ if (!ifgm_loaded)
+ return;
+ if (cur_dlg_index == 0)
+ return;
+ PlaySound(sfx_sounds[index % 16]);
+}
+
+} // end of namespace Chamber
diff --git a/engines/chamber/ifgm.h b/engines/chamber/ifgm.h
new file mode 100644
index 00000000000..af84bd7c2e4
--- /dev/null
+++ b/engines/chamber/ifgm.h
@@ -0,0 +1,47 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef CHAMBER_IFGM_H
+#define CHAMBER_IFGM_H
+
+namespace Chamber {
+
+extern byte ifgm_loaded;
+
+extern uint16 ifgm_flag1;
+extern byte ifgm_flag2;
+
+void IFGM_Init(void);
+
+void IFGM_Shutdown(void);
+
+void IFGM_Poll(void);
+
+void IFGM_PlaySample(byte index);
+void IFGM_StopSample(void);
+
+int16 IFGM_PlaySound(byte index);
+void IFGM_PlaySfx(byte index);
+
+} // end of namespace Chamber
+
+#endif
diff --git a/engines/chamber/input.cpp b/engines/chamber/input.cpp
index ba36d3882ab..7545fe7aaa5 100644
--- a/engines/chamber/input.cpp
+++ b/engines/chamber/input.cpp
@@ -25,18 +25,28 @@
#include "chamber/chamber.h"
#include "chamber/common.h"
+#include "chamber/dialog.h"
#include "chamber/input.h"
#include "chamber/cursor.h"
+#include "chamber/print.h"
+#include "chamber/resdata.h"
#include "chamber/cga.h"
+#include "chamber/timer.h"
+#include "chamber/ifgm.h"
namespace Chamber {
-
-byte have_mouse;
+byte have_mouse = 0;
+byte have_joystick = 0;
byte key_held;
volatile byte key_direction;
volatile byte key_code;
-volatile byte esc_pressed;
+
+volatile byte keyboard_scan;
+volatile byte keyboard_specials;
+volatile byte keyboard_arrows;
+volatile byte keyboard_buttons;
+
byte buttons_repeat = 0;
byte buttons;
byte right_button;
@@ -45,6 +55,8 @@ byte accell_countdown;
uint16 accelleration = 1;
byte mouseButtons = 0;
+void PollDiscrete(void);
+
byte ChamberEngine::readKeyboardChar() {
Common::Event event;
@@ -72,6 +84,10 @@ byte ChamberEngine::readKeyboardChar() {
void ClearKeyboard(void) {
}
+#ifdef VERSION_USA
+extern int16 AskQuitGame(void);
+#endif
+
void SetInputButtons(byte keys) {
if (keys & 2)
right_button = ~0;
@@ -127,6 +143,49 @@ byte PollKeyboard(void) {
return key_code;
}
+/*
+Show game exit confirmation dialog and get user's input
+*/
+int16 AskQuitGame(void) {
+ int16 quit = -1;
+#ifdef VERSION_USA
+ byte *msg = SeekToString(desci_data, 411); /*DO YOU WANT TO QUIT ? (Y OR N).*/
+ char_draw_max_width = 32;
+ draw_x = 1;
+ draw_y = 188;
+ CGA_DrawTextBox(msg, frontbuffer);
+
+ Common::Event event;
+
+ while (quit == -1) {
+ while (g_system->getEventManager()->pollEvent(event)) {
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ if (event.kbd.keycode == Common::KEYCODE_y)
+ quit = 1;
+ else if (event.kbd.keycode == Common::KEYCODE_n)
+ quit = 0;
+ break;
+
+ case Common::EVENT_RETURN_TO_LAUNCHER:
+ case Common::EVENT_QUIT:
+ quit = 1;
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ CGA_CopyScreenBlock(backbuffer, char_draw_max_width + 2, char_draw_coords_y - draw_y + 8, frontbuffer, CGA_CalcXY_p(draw_x, draw_y));
+#endif
+ /*EU version comes without requited text string*/
+ return quit == 1;
+}
+
+void PollInputButtonsOnly() {
+ PollInput();
+}
+
void PollInput(void) {
Common::Event event;
while (g_system->getEventManager()->pollEvent(event)) {
@@ -134,6 +193,12 @@ void PollInput(void) {
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode == Common::KEYCODE_SPACE)
mouseButtons |= 1;
+ else if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
+#ifdef VERSION_USA
+ if (AskQuitGame() != 0)
+ g_vm->_shouldQuit = true;
+#endif
+ }
break;
case Common::EVENT_KEYUP:
diff --git a/engines/chamber/input.h b/engines/chamber/input.h
index 6504dc14126..2964fef63df 100644
--- a/engines/chamber/input.h
+++ b/engines/chamber/input.h
@@ -34,14 +34,18 @@ extern volatile byte key_direction;
extern volatile byte key_code;
extern byte key_held;
+byte ReadKeyboardChar(void);
void ClearKeyboard(void);
+byte GetKeyScan(void);
-byte PollMouse(void);
+byte PollMouse(uint16 *curs_x, uint8 *curs_y);
byte PollKeyboard(void);
void SetInputButtons(byte keys);
void PollInput(void);
void ProcessInput(void);
+void PollInputButtonsOnly(void);
+void ResetInput(void);
void InitInput(void);
void UninitInput(void);
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index fa2e38f266c..44b338061cd 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -44,6 +44,7 @@
#include "chamber/print.h"
#include "chamber/dialog.h"
#include "chamber/menu.h"
+#include "chamber/ifgm.h"
namespace Chamber {
@@ -191,6 +192,7 @@ process:
void ExitGame(void) {
SwitchToTextMode();
+ UninitTimer();
}
jmp_buf restart_jmp;
@@ -200,18 +202,34 @@ extern TheEnd(void);
#endif
Common::Error ChamberEngine::run() {
+ byte c;
+
// Initialize graphics using following:
initGraphics(320, 200);
+ initSound();
+
+ /*TODO: DetectCPU*/
+
+ IFGM_Init();
SwitchToGraphicsMode();
- initSound();
+ /* Install timer callback */
+ InitTimer();
- byte c;
+#ifdef VERSION_USA
+ /* Load title screen */
+ if (!LoadSplash("PRESCGA.BIN"))
+ ExitGame();
+ if (ifgm_loaded) {
+ /*TODO*/
+ }
+#else
/* Load title screen */
if (!LoadSplash("PRES.BIN"))
ExitGame();
+#endif
/* Select intense cyan-mageta palette */
CGA_ColorSelect(0x30);
@@ -219,11 +237,14 @@ Common::Error ChamberEngine::run() {
/* Show the title screen */
CGA_BackBufferToRealFull();
-#ifdef COPYPROT
- /* Check if a valid floppy disk is present in any drive */
- if (!CheckCopyProtection()) for (;;) ;
-#endif
+#ifdef VERSION_USA
+ if (ifgm_loaded) {
+ /*TODO*/
+ }
+ /* Force English language */
+ c = 'E';
+#else
/* Load language selection screen */
if (!LoadSplash("DRAP.BIN"))
ExitGame();
@@ -244,6 +265,7 @@ Common::Error ChamberEngine::run() {
if (c > 'F')
c -= ' ';
} while (c < 'D' || c > 'F');
+#endif
if (_shouldQuit)
return Common::kNoError;
@@ -254,7 +276,9 @@ Common::Error ChamberEngine::run() {
res_desci[0].name[4] = c;
res_diali[0].name[4] = c;
+#ifndef VERSION_USA
CGA_BackBufferToRealFull();
+#endif
/* Load script and other static resources */
/* Those are normally embedded in the executable, but here we load extracted ones*/
@@ -265,25 +289,28 @@ Common::Error ChamberEngine::run() {
if (!LoadVepciData() || !LoadDesciData() || !LoadDialiData())
ExitGame();
+ /* Detect/Initialize input device */
+ InitInput();
+
/* Load graphics resources */
while (!LoadFond() || !LoadSpritesData() || !LoadPersData())
AskDisk2();
- /* Detect/Initialize input device */
- InitInput();
-
/*TODO: is this neccessary?*/
CGA_BackBufferToRealFull();
/* Create clean game state snapshot */
SaveRestartGame();
- /* Install timer callback */
- InitTimer();
-
/* Detect CPU speed for delay routines */
cpu_speed_delay = BenchmarkCpu() / 8;
+#ifdef VERSION_USA
+ if (ifgm_loaded) {
+ /*TODO*/
+ }
+#endif
+
/*restart game from here*/
restart:;
setjmp(restart_jmp);
@@ -305,6 +332,9 @@ restart:;
script_byte_vars.load_flag = DEBUG_SKIP_INTRO;
#endif
+ /* Discard all pending input */
+ //ResetInput();
+
/* Play introduction sequence and initialize game */
the_command = 0xC001;
RunCommand();
@@ -331,7 +361,6 @@ restart:;
/* Release hardware */
UninitInput();
- UninitTimer();
ExitGame();
diff --git a/engines/chamber/menu.cpp b/engines/chamber/menu.cpp
index b57db819b51..caa56be7533 100644
--- a/engines/chamber/menu.cpp
+++ b/engines/chamber/menu.cpp
@@ -55,7 +55,8 @@ struct {
/*Handle keyboard keys in actions menu (to cycle through choices with directional keys)*/
byte PollKeyboardInActionsMenu(void) {
- if (!key_direction) {
+ PollInput();
+ if (!(key_direction & 0xF)) {
key_held = 0;
return key_code;
}
@@ -78,12 +79,7 @@ byte PollKeyboardInActionsMenu(void) {
/*Handle player input in actions menu*/
void PollInputInActionsMenu(void) {
- byte keys;
- if (have_mouse)
- keys = PollMouse();
- else
- keys = PollKeyboardInActionsMenu();
- SetInputButtons(keys);
+ PollInput();
}
/*Draw actions menu and process its choices*/
diff --git a/engines/chamber/module.mk b/engines/chamber/module.mk
index 373146262a1..7aa82d1fd21 100644
--- a/engines/chamber/module.mk
+++ b/engines/chamber/module.mk
@@ -8,6 +8,7 @@ MODULE_OBJS := \
cursor.o \
decompr.o \
dialog.o \
+ ifgm.o \
input.o \
invent.o \
kult.o \
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index ff9ead1576b..f1053a0fa1d 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -30,6 +30,7 @@
#include "chamber/dialog.h"
#include "chamber/input.h"
#include "chamber/sound.h"
+#include "chamber/ifgm.h"
namespace Chamber {
@@ -292,9 +293,16 @@ int16 DrawPortrait(byte **desc, byte *x, byte *y, byte *width, byte *height) {
return 1;
}
+void PlayHurtSound() {
+ if (!ifgm_loaded)
+ PlaySound(144);
+ else
+ PlaySound(144 + (Rand() / 4) % 4);
+}
+
void BlinkWithSound(byte color) {
CGA_ColorSelect(color);
- PlaySound(144);
+ PlayHurtSound();
SelectPalette();
}
@@ -303,9 +311,23 @@ void BlinkToRed(void) {
}
void BlinkToWhite(void) {
+#ifdef VERSION_USA
+ PlayHurtSound(); /*TODO: play here and later? looks like a bug, original code will trash palette selection if pcspeaker is used*/
+#endif
BlinkWithSound(0x3F);
}
+volatile byte vblank_ticks;
+
+void WaitVBlankTimer(void) {
+#ifdef VERSION_USA
+ /*A crude attempt to fix the animation speed...*/
+ while (vblank_ticks < 3) ;
+ vblank_ticks = 0;
+#endif
+ WaitVBlank();
+}
+
void AnimPortrait(byte layer, byte index, byte delay) {
byte *ani, *ani_end;
byte temp;
@@ -317,6 +339,8 @@ void AnimPortrait(byte layer, byte index, byte delay) {
if (index == 0xFE)
index = cur_image_anim2;
+ IFGM_PlaySfx(index);
+
ani = SeekToEntry(anico_data, index - 1, &ani_end);
cur_image_pixels = sprit_load_buffer + 2 + 2;
@@ -335,6 +359,7 @@ void AnimPortrait(byte layer, byte index, byte delay) {
GetDirtyRectAndSetSprite(layer, &kind, &x, &y, &width, &height, &offs);
WaitVBlank();
CGA_BlitAndWait(cur_image_pixels, width, width, height, CGA_SCREENBUFFER, offs);
+ WaitVBlankTimer();
if (delay) {
if (ani[-1] == 37) { /*TODO: what is it?*/
if (script_byte_vars.extreme_violence)
diff --git a/engines/chamber/portrait.h b/engines/chamber/portrait.h
index 699f5847df9..ca186a3ee59 100644
--- a/engines/chamber/portrait.h
+++ b/engines/chamber/portrait.h
@@ -37,6 +37,8 @@ extern byte cur_image_anim1;
extern byte cur_image_anim2;
extern uint16 cur_frame_width;
+extern volatile byte vblank_ticks;
+
int16 DrawPortrait(byte **desc, byte *x, byte *y, byte *width, byte *height);
void AnimPortrait(byte layer, byte index, byte delay);
diff --git a/engines/chamber/print.cpp b/engines/chamber/print.cpp
index a83d916deca..61242753c48 100644
--- a/engines/chamber/print.cpp
+++ b/engines/chamber/print.cpp
@@ -162,10 +162,12 @@ byte *PrintStringLine(byte *str, uint16 *left, byte *target) {
}
byte *PrintStringPadded(byte *str, byte *target) {
- uint16 w, n;
+ uint16 w;
+#ifndef VERSION_USA
CalcStringSize(str, &w, &n);
if (w + 2 >= char_draw_max_width)
char_draw_max_width = w + 2;
+#endif
str = PrintStringLine(str, &w, target);
if (w != 0)
PrintStringPad(w, target);
@@ -192,9 +194,16 @@ void PrintStringCentered(byte *str, byte *target) {
void CGA_DrawTextBox(byte *msg, byte *target) {
uint16 x, y, w, i;
+ uint16 ww, nw;
char_xlat_table = chars_color_bonc;
+#ifdef VERSION_USA
+ CalcStringSize(msg, &ww, &nw);
+ if (ww >= char_draw_max_width)
+ char_draw_max_width = ww;
+#endif
+
x = draw_x * 4;
y = draw_y;
w = (char_draw_max_width + 2) * 4 - 2;
diff --git a/engines/chamber/print.h b/engines/chamber/print.h
index 93f1e01adfa..1106ff7f1c3 100644
--- a/engines/chamber/print.h
+++ b/engines/chamber/print.h
@@ -42,6 +42,8 @@ void DrawMessage(byte *msg, byte *target);
void CGA_DrawTextBox(byte *msg, byte *target);
+void CalcStringSize(byte *str, uint16 *w, uint16 *n);
+
} // End of namespace Chamber
#endif
diff --git a/engines/chamber/resdata.h b/engines/chamber/resdata.h
index f094c4cd6e0..72773caedb7 100644
--- a/engines/chamber/resdata.h
+++ b/engines/chamber/resdata.h
@@ -35,8 +35,8 @@ typedef struct ResEntry_tp {
byte **buffer;
} ResEntry_tp;
-
/* Max resource file size among all languages */
+#ifdef VERSION_USA
#define RES_ALEAT_MAX 256
#define RES_ANICO_MAX 667
#define RES_ANIMA_MAX 2046
@@ -46,18 +46,41 @@ typedef struct ResEntry_tp {
#define RES_ICONE_MAX 2756
#define RES_LUTIN_MAX 2800
#define RES_MURSM_MAX 76
-#define RES_SOUCO_MAX 10838
+#define RES_SOUCO_MAX 424
#define RES_SOURI_MAX 1152
-#define RES_TEMPL_MAX 27300
+#define RES_TEMPL_MAX 27337
#define RES_ZONES_MAX 9014
#define RES_PUZZL_MAX 45671
#define RES_SPRIT_MAX 23811
#define RES_PERS1_MAX 14294
-#define RES_PERS2_MAX 10489
-#define RES_DESCI_MAX 10491
-#define RES_DIALI_MAX 10070
+#define RES_PERS2_MAX 10587
+#define RES_DESCI_MAX 10515
+#define RES_DIALI_MAX 9636
#define RES_MOTSI_MAX 1082
-#define RES_VEPCI_MAX 1548
+#define RES_VEPCI_MAX 1345
+#else
+#define RES_ALEAT_MAX 256
+#define RES_ANICO_MAX 667
+#define RES_ANIMA_MAX 2046
+#define RES_ARPLA_MAX 7910
+#define RES_CARPC_MAX 384
+#define RES_GAUSS_MAX 1449
+#define RES_ICONE_MAX 2756
+#define RES_LUTIN_MAX 2800
+#define RES_MURSM_MAX 76
+#define RES_SOUCO_MAX 424
+#define RES_SOURI_MAX 1152
+#define RES_TEMPL_MAX 27337
+#define RES_ZONES_MAX 9014
+#define RES_PUZZL_MAX 45671
+#define RES_SPRIT_MAX 23811
+#define RES_PERS1_MAX 14294
+#define RES_PERS2_MAX 10587
+#define RES_DESCI_MAX 10515
+#define RES_DIALI_MAX 9636
+#define RES_MOTSI_MAX 1082
+#define RES_VEPCI_MAX 1345
+#endif
extern byte vepci_data[];
extern byte motsi_data[];
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index 3ebe77492b1..ea52c9d0376 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -35,6 +35,7 @@
#include "chamber/dialog.h"
#include "chamber/portrait.h"
#include "chamber/sound.h"
+#include "chamber/ifgm.h"
namespace Chamber {
@@ -493,6 +494,8 @@ void AnimRoomDoorOpen(byte index) {
InitRoomDoorInfo(index);
+ IFGM_PlaySample(29);
+
oldheight = info->layer[1].height;
for (i = 0; i < oldheight / 2; i++) {
@@ -518,6 +521,8 @@ void AnimRoomDoorClose(byte index) {
doorinfo_t *info = (doorinfo_t *)scratch_mem2;
InitRoomDoorInfo(index);
+ IFGM_PlaySample(29);
+
oldheight = info->layer[1].height;
oldpixels = info->layer[1].pixels;
@@ -922,7 +927,12 @@ void RefreshZone(void) {
CGA_BackBufferToRealFull();
- in_de_profundis = script_byte_vars.zone_area == 22 ? 1 : 0;
+ in_de_profundis = 0;
+ IFGM_StopSample();
+ if (script_byte_vars.zone_area == 22) {
+ IFGM_PlaySample(131);
+ in_de_profundis = 1;
+ }
DrawTheWallDoors();
SelectPalette();
@@ -1440,6 +1450,8 @@ void TheWallPhase3_DoorOpen1(void) {
TheWallOpenRightDoor(144 / 4, 32, 80 / 4, 59, 40 / 4);
TheWallOpenLeftDoor(64 / 4, 32, 80 / 4, 59, 40 / 4);
+ IFGM_StopSample();
+
/*TODO: fill in the_wall_door_* structures, as they are used by the original code and appear in savefile*/
}
@@ -1454,6 +1466,8 @@ void TheWallPhase0_DoorOpen2(void) {
TheWallOpenRightDoor((144 + 40) / 4, 32, (80 - 40) / 4, 59, 0);
TheWallOpenLeftDoor(64 / 4, 32, (80 - 40) / 4, 59, 0);
+ IFGM_StopSample();
+
/*TODO: fill in the_wall_door_* structures, as they are used by the original code and appear in savefile*/
}
@@ -1476,6 +1490,8 @@ void TheWallPhase1_DoorClose1(void) {
cur_image_coords_x = 220 / 4;
CGA_AnimLiftToLeft(10, spr, cur_frame_width, 1, cur_image_size_h, frontbuffer, CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y));
+ IFGM_StopSample();
+
/*TODO: fill in the_wall_door_* structures, as they are used by the original code and appear in savefile*/
}
@@ -1498,6 +1514,8 @@ void TheWallPhase2_DoorClose2(void) {
cur_image_coords_x = 220 / 4;
CGA_AnimLiftToLeft(10, spr, cur_frame_width, 1 + 10, cur_image_size_h, frontbuffer, CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y) - 10);
+ IFGM_PlaySample(30);
+
/*TODO: fill in the_wall_door_* structures, as they are used by the original code and appear in savefile*/
}
@@ -1509,7 +1527,12 @@ void DrawTheWallDoors(void) {
case 9:
case 102:
CGA_Blit(LoadMursmSprite(0) + 10, 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(64 / CGA_PIXELS_PER_BYTE, 32));
+#ifdef VERSION_USA
+ /*This fixes odd black patch on the right gate door*/
+ CGA_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(184 / CGA_PIXELS_PER_BYTE, 32));
+#else
CGA_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(180 / CGA_PIXELS_PER_BYTE, 32));
+#endif
break;
case 95:
case 103:
diff --git a/engines/chamber/savegame.cpp b/engines/chamber/savegame.cpp
index b82627b248e..e7c02f7c67e 100644
--- a/engines/chamber/savegame.cpp
+++ b/engines/chamber/savegame.cpp
@@ -28,9 +28,41 @@
#include "chamber/cga.h"
#include "chamber/room.h"
#include "chamber/dialog.h"
+#include "chamber/room.h"
namespace Chamber {
+static const char restart_name[] = "CLEARx.BIN";
+
+#ifdef VERSION_USA
+static const char savegame_name[] = "SCENACx.BIN";
+#else
+static const char savegame_name[] = "SCENAx.BIN";
+#endif
+
+#ifdef VERSION_USA
+
+#define CGA_SAVE_BEG_OFS 0x769B
+#define CGA_SAVE_END_OFS 0x9EDA
+
+#define CGA_SAVE_WORD_VARS_OFS 0x79C1
+#define CGA_SAVE_BYTE_VARS_OFS 0x7B33
+#define CGA_SAVE_INVENTORY_OFS 0x7762
+#define CGA_SAVE_ZONES_OFS 0x7BA4
+#define CGA_SAVE_PERS_OFS 0x78E2
+#define CGA_SAVE_STACK_OFS 0x76DF
+#define CGA_SAVE_SPRITES_OFS 0x5264
+#define CGA_SAVE_SPRLIST_OFS 0x76AD
+#define CGA_SAVE_SPRBUFF_OFS 0x4C68
+#define CGA_SAVE_ARPLA_OFS 0x26F6
+#define CGA_SAVE_SCRSTACK_OFS 0x76DF
+#define CGA_SAVE_TEMPL_OFS 0x1AC7
+#define CGA_SAVE_VORTANIMS_OFS 0xA7B7
+#define CGA_SAVE_TURKEYANIMS_OFS 0xA8FC
+#define CGA_SAVE_TIMEDSEQ_OFS 0xA96E
+
+#else
+
#define CGA_SAVE_BEG_OFS 0x751E
#define CGA_SAVE_END_OFS 0x9D5D
@@ -50,6 +82,8 @@ namespace Chamber {
#define CGA_SAVE_TURKEYANIMS_OFS 0xA74E
#define CGA_SAVE_TIMEDSEQ_OFS 0xA7C0
+#endif
+
#define SAVEADDR(value, base, nativesize, origsize, origbase) \
((value) ? LE16(((((byte*)(value)) - (byte*)(base)) / nativesize) * origsize + origbase) : 0)
@@ -561,7 +595,7 @@ int16 LoadScena(void) {
script_byte_vars.game_paused = 1;
- f = open("SCENAx.BIN", O_RDONLY | O_BINARY);
+ f = open(savegame_name, O_RDONLY | O_BINARY);
if (f == -1) {
script_byte_vars.game_paused = 0;
return 1; /*error*/
@@ -595,8 +629,11 @@ int16 SaveScena(void) {
script_byte_vars.game_paused = 1;
BlitSpritesToBackBuffer();
+ command_hint = 100;
+ DrawCommandHint();
+ ShowCommandHint(frontbuffer);
- f = open("SCENAx.BIN", O_CREAT | O_WRONLY | O_BINARY);
+ f = open(savegame_name, O_CREAT | O_WRONLY | O_BINARY);
if (f == -1) {
script_byte_vars.game_paused = 0;
return 1; /*error*/
@@ -605,6 +642,10 @@ int16 SaveScena(void) {
res = WriteSaveData(f, 0);
close(f);
+
+ if (res != 0)
+ unlink(savegame_name);
+
script_byte_vars.game_paused = 0;
return res;
#endif
@@ -615,7 +656,7 @@ void SaveRestartGame(void) {
#if 0
int16 f;
- f = open("CLEARx.BIN", O_CREAT | O_WRONLY | O_BINARY);
+ f = open(restart_name, O_CREAT | O_WRONLY | O_BINARY);
if (f == -1) {
return; /*error*/
}
@@ -638,7 +679,7 @@ void RestartGame(void) {
int16 res;
for (;; AskDisk2()) {
- f = open("CLEARx.BIN", O_RDONLY | O_BINARY);
+ f = open(restart_name, O_RDONLY | O_BINARY);
if (f != -1) {
res = ReadSaveData(f, 1);
close(f);
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 5df59b89af7..88f4384a976 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -43,6 +43,7 @@
#include "chamber/invent.h"
#include "chamber/sound.h"
#include "chamber/savegame.h"
+#include "chamber/ifgm.h"
#if 1
#define DEBUG_SCRIPT
@@ -578,6 +579,7 @@ uint16 SCR_3B_MathExpr(void) {
op2 = MathExpr(&script_ptr);
/*store result*/
+ /*TODO: original bug? MathExpr may overwrite global var_size, so mixed-size expressions will produce errorneous results*/
if (var_size == VARSIZE_BYTE)
*opptr = op2 & 255;
else {
@@ -912,27 +914,31 @@ uint16 SCR_E_DrawPortraitZoomIn(void) {
}
-/*
-Draw image with specified w/h zoom
-*/
-uint16 SCR_10_DrawPortraitZoomed(void) {
+uint16 DrawPortraitZoomed(byte **params) {
byte x, y, width, height;
byte zwidth, zheight;
- script_ptr++;
-
right_button = 0; /*prevent cancel or zoom parameters won't be consumed*/
- if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!DrawPortrait(params, &x, &y, &width, &height))
return 0; /*TODO: maybe just remove the if/return instead?*/
- zwidth = *script_ptr++;
- zheight = *script_ptr++;
+ zwidth = *((*params)++);
+ zheight = *((*params)++);
/*adjust the rect for new size*/
last_dirty_rect->width = zwidth + 2;
last_dirty_rect->height = zheight;
CGA_ZoomImage(cur_image_pixels, cur_image_size_w, cur_image_size_h, zwidth, zheight, frontbuffer, cur_image_offs);
+ return 0;
+}
+
+/*
+Draw image with specified w/h zoom
+*/
+uint16 SCR_10_DrawPortraitZoomed(void) {
+ script_ptr++;
+ DrawPortraitZoomed(&script_ptr);
#if 0
/*TODO: debug wait*/
@@ -1391,6 +1397,7 @@ void AnimStarfield(star_t *stars, byte *target) {
Play Game Over sequence and restart the game
*/
uint16 SCR_26_GameOver(void) {
+ IFGM_PlaySample(160);
in_de_profundis = 0;
script_byte_vars.game_paused = 1;
memset(backbuffer, 0, sizeof(backbuffer) - 2); /*TODO: original bug?*/
@@ -1677,6 +1684,7 @@ The Wall room puzzle
uint16 SCR_3E_TheWallAdvance(void) {
script_ptr++;
+ IFGM_PlaySample(29);
script_byte_vars.the_wall_phase = (script_byte_vars.the_wall_phase + 1) % 4;
switch (script_byte_vars.the_wall_phase) {
default:
@@ -2122,8 +2130,10 @@ uint16 SCR_31_Fight2(void) {
for (i = 0; i < fightlistsize; i++) {
if (fightlist[i].room == script_byte_vars.zone_room) {
- if (animidx != 0)
+ if (animidx != 0) {
fightlist[i].anim.index = animidx;
+ IFGM_PlaySample(150);
+ }
if (fightlist[i].anim.index == 55)
PlaySound(151);
PlayAnim(fightlist[i].anim.index, fightlist[i].anim.params.coords.x, fightlist[i].anim.params.coords.y);
@@ -2687,6 +2697,8 @@ uint16 SCR_56_MorphRoom98(void) {
uint16 ofs;
script_ptr++;
+ IFGM_PlaySample(242);
+
RedrawRoomStatics(98, 0);
ofs = CGA_CalcXY(0, 136);
@@ -2700,6 +2712,8 @@ uint16 SCR_56_MorphRoom98(void) {
BackupSpotImage(&zone_spots[3], &sprites_list[3], sprites_list[3]);
+ IFGM_StopSample();
+
return 0;
}
@@ -2846,6 +2860,8 @@ static void AnimSaucer(void) {
memset(backbuffer + ofs2, 0, 54 / 2 * CGA_BYTES_PER_LINE);
for (i = 0xFFFF; i--;) ; /*TODO: weak delay*/
+
+ IFGM_PlaySample(240);
}
/*draw the full saucer on screen*/
@@ -2864,11 +2880,31 @@ extern int16 LoadSplash(const char *filename);
TODO: check me
*/
void TheEnd(void) {
+ static byte image2[] = {168, 28, 85, 22, 15};
+ byte *pimage2 = image2;
+
AnimSaucer();
+#ifdef VERSION_USA
+ DrawPortraitZoomed(&pimage2);
+
+ script_byte_vars.zone_index = 135;
+
+ do
+ {
+ PollInputButtonsOnly();
+ }
+ while(buttons == 0);
+
+ while (!LoadFond())
+ AskDisk2();
+ JaggedZoom(backbuffer, frontbuffer);
+ CGA_BackBufferToRealFull();
+#else
while (!LoadSplash("PRES.BIN"))
AskDisk2();
CGA_BackBufferToRealFull();
+#endif
}
uint16 SCR_5B_TheEnd(void) {
@@ -2877,7 +2913,11 @@ uint16 SCR_5B_TheEnd(void) {
TheEnd();
+#ifdef VERSION_USA
+ RestartGame();
+#else
for (;;) ; /*HANG*/
+#endif
return 0;
}
@@ -3132,11 +3172,15 @@ uint16 SCR_67_Unused(void) {
}
/*
-Do nothing in PC/CGA version
+Play Sfx
+NB! Do nothing in EU PC/CGA version
*/
-uint16 SCR_68_Unused(void) {
+uint16 SCR_68_PlaySfx(void) {
+ byte index;
script_ptr++;
+ index = *script_ptr++;
script_ptr++;
+ IFGM_PlaySfx(index);
return 0;
}
@@ -3215,6 +3259,9 @@ uint16 CMD_4_EnergyLevel(void) {
PopDirtyRects(DirtyRectSprite);
PopDirtyRects(DirtyRectBubble);
+ cur_dlg_index = 0;
+ ifgm_flag2 = ~0;
+
if (script_byte_vars.psy_energy != 0)
anim = 41 + (script_byte_vars.psy_energy / 16);
@@ -3223,13 +3270,17 @@ uint16 CMD_4_EnergyLevel(void) {
}
do {
+ IFGM_PlaySample(28);
AnimPortrait(1, anim, 10);
AnimPortrait(1, anim + 14, 10);
- PollInput();
+ PollInputButtonsOnly();
} while (buttons == 0);
PopDirtyRects(DirtyRectSprite);
+ ifgm_flag2 = 0;
+ IFGM_StopSample();
+
return 0;
}
@@ -3305,7 +3356,7 @@ uint16 CMD_8_Timer(void) {
CGA_PrintChar((minutes & 1) ? 26 : 0, CGA_SCREENBUFFER); /*colon*/
CGA_PrintChar(minutes / (60 * 10) + 16, CGA_SCREENBUFFER);
CGA_PrintChar(minutes / 60 + 16, CGA_SCREENBUFFER);
- PollInput();
+ PollInputButtonsOnly();
} while (buttons == 0);
PopDirtyRects(DirtyRectSprite);
@@ -3479,6 +3530,8 @@ uint16 CMD_E_PsiZoneScan(void) {
BackupScreenOfSpecialRoom();
+ IFGM_PlaySample(26);
+
offs = CGA_CalcXY_p(room_bounds_rect.sx, room_bounds_rect.sy);
w = room_bounds_rect.ex - room_bounds_rect.sx;
h = room_bounds_rect.ey - room_bounds_rect.sy;
@@ -3507,6 +3560,8 @@ uint16 CMD_E_PsiZoneScan(void) {
RestoreScreenOfSpecialRoom();
+ IFGM_StopSample();
+
the_command = Swap16(script_word_vars.psi_cmds[2]);
return ScriptRerun;
@@ -3756,6 +3811,7 @@ uint16 CMD_14_VortAppear(void) {
pers_list[kPersVort].area = script_byte_vars.zone_area;
SelectPerson(0);
AnimateSpot(&vortanims_ptr->field_1);
+ IFGM_StopSample();
next_vorts_cmd = 0xA015;
BlitSpritesToBackBuffer();
DrawPersons();
@@ -3834,6 +3890,7 @@ uint16 CMD_15_VortLeave(void) {
SelectPerson(0);
AnimateSpot(anim);
+ IFGM_StopSample();
script_byte_vars.bvar_36 &= 0x80;
return 0;
}
@@ -3928,6 +3985,8 @@ uint16 CMD_1B_Holo(void) {
uint16 num;
byte *msg;
+ IFGM_PlaySample(225);
+
x = found_spot->sx;
y = found_spot->sy;
@@ -3942,11 +4001,15 @@ uint16 CMD_1B_Holo(void) {
else
DrawPersonBubble(x - 92 / 4, y - 40, SPIKE_DNRIGHT | 20, msg);
+ IFGM_PlaySfx(0);
+
PlayAnim(43, x, y);
PromptWait();
PopDirtyRects(DirtyRectBubble);
+ IFGM_PlaySample(225);
+
PlayAnim(45, x, y);
return 0;
@@ -4031,6 +4094,8 @@ uint16 CMD_21_VortTalk(void) {
else
DrawPersonBubble(x - 80 / 4, y - 40, SPIKE_DNRIGHT | 20, msg);
+ IFGM_PlaySfx(0);
+
PromptWait();
PopDirtyRects(DirtyRectBubble);
@@ -4056,6 +4121,7 @@ uint16 CMD_24_(void) {
Load save file
*/
uint16 CMD_25_LoadGame(void) {
+ IFGM_StopSample();
if (LoadScena())
the_command = 0x918F; /*error loading*/
else
@@ -4226,7 +4292,7 @@ cmdhandler_t script_handlers[] = {
SCR_65_DeProfundisMovePlatform,
SCR_66_DeProfundisRideToExit,
SCR_67_Unused,
- SCR_68_Unused,
+ SCR_68_PlaySfx,
SCR_69_PlaySound,
SCR_6A_Unused,
};
diff --git a/engines/chamber/sound.cpp b/engines/chamber/sound.cpp
index 6871ca7400a..63f88477545 100644
--- a/engines/chamber/sound.cpp
+++ b/engines/chamber/sound.cpp
@@ -26,6 +26,7 @@
#include "chamber/chamber.h"
#include "chamber/common.h"
#include "chamber/sound.h"
+#include "chamber/ifgm.h"
namespace Chamber {
@@ -92,7 +93,7 @@ static void SpeakerPlay(pcsample_t *sample) {
#define kMaxSounds 12
-unsigned char sounds_table[kMaxSounds][3] = {
+byte sounds_table[kMaxSounds][3] = {
{20, 0, 0},
{19, 0, 0},
{176, 0, 0},
@@ -107,8 +108,11 @@ unsigned char sounds_table[kMaxSounds][3] = {
{31, 0, 0}
};
-void PlaySound(unsigned char index) {
- int i;
+void PlaySound(byte index) {
+ int16 i;
+ if (IFGM_PlaySound(index))
+ return;
+
for (i = 0; i < kMaxSounds; i++) {
if (sounds_table[i][0] == index
|| sounds_table[i][1] == index
Commit: dc5b18d75183eb3e76abd0cf1f8b23791cfe6290
https://github.com/scummvm/scummvm/commit/dc5b18d75183eb3e76abd0cf1f8b23791cfe6290
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix compilation for EU version
Changed paths:
engines/chamber/print.cpp
diff --git a/engines/chamber/print.cpp b/engines/chamber/print.cpp
index 61242753c48..d31c8c0f553 100644
--- a/engines/chamber/print.cpp
+++ b/engines/chamber/print.cpp
@@ -164,6 +164,7 @@ byte *PrintStringLine(byte *str, uint16 *left, byte *target) {
byte *PrintStringPadded(byte *str, byte *target) {
uint16 w;
#ifndef VERSION_USA
+ uint16 n;
CalcStringSize(str, &w, &n);
if (w + 2 >= char_draw_max_width)
char_draw_max_width = w + 2;
Commit: 977341c8a5aff47e18b06a018c97c99635d47dab
https://github.com/scummvm/scummvm/commit/977341c8a5aff47e18b06a018c97c99635d47dab
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Added detection for US version
Changed paths:
engines/chamber/detection.cpp
diff --git a/engines/chamber/detection.cpp b/engines/chamber/detection.cpp
index ebab5644510..bb4bd7ba76d 100644
--- a/engines/chamber/detection.cpp
+++ b/engines/chamber/detection.cpp
@@ -34,8 +34,18 @@ static const ADGameDescription gameDescriptions[] = {
{
"chamber",
"",
- AD_ENTRY1s("desce.bin", "d6b2b07bbb6b6d5a292c17536ad7dd44", 10419),
- Common::EN_ANY,
+ AD_ENTRY1s("kult1.pxi", "fc0bd31a3c380338f76ff53e421e47b6", 140537),
+ Common::UNK_LANG, // EN/FR/DE
+ Common::kPlatformDOS,
+ ADGF_UNSTABLE,
+ GUIO0()
+ },
+
+ {
+ "chamber",
+ "",
+ AD_ENTRY1s("ere.pxi", "5aa5bd2d79eefde70675b0b6734944f2", 134358),
+ Common::EN_USA,
Common::kPlatformDOS,
ADGF_UNSTABLE,
GUIO0()
Commit: 12ca250553df44de89dd7e0c7b17bef901224bbe
https://github.com/scummvm/scummvm/commit/12ca250553df44de89dd7e0c7b17bef901224bbe
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Implement getLanguage()
Changed paths:
engines/chamber/chamber.cpp
engines/chamber/chamber.h
engines/chamber/metaengine.cpp
diff --git a/engines/chamber/chamber.cpp b/engines/chamber/chamber.cpp
index a30f6715997..88a3693d2de 100644
--- a/engines/chamber/chamber.cpp
+++ b/engines/chamber/chamber.cpp
@@ -38,9 +38,10 @@ namespace Chamber {
ChamberEngine *g_vm;
-ChamberEngine::ChamberEngine(OSystem *syst)
+ChamberEngine::ChamberEngine(OSystem *syst, const ADGameDescription *desc)
: Engine(syst) {
g_vm = this;
+ _gameDescription = desc;
const Common::FSNode gameDataDir(ConfMan.get("path"));
diff --git a/engines/chamber/chamber.h b/engines/chamber/chamber.h
index 0131c468fbc..58dd0b8ec36 100644
--- a/engines/chamber/chamber.h
+++ b/engines/chamber/chamber.h
@@ -35,6 +35,8 @@ class SoundHandle;
class PCSpeaker;
}
+struct ADGameDescription;
+
namespace Chamber {
class ChamberEngine : public Engine {
@@ -43,9 +45,11 @@ private:
Common::RandomSource *_rnd;
public:
- ChamberEngine(OSystem *syst);
+ ChamberEngine(OSystem *syst, const ADGameDescription *desc);
~ChamberEngine();
+ Common::Language getLanguage() const;
+
Common::Error run() override;
bool hasFeature(EngineFeature f) const override;
bool canLoadGameStateCurrently() override { return true; }
@@ -66,6 +70,9 @@ public:
Audio::PCSpeaker *_speakerStream;
Audio::SoundHandle *_speakerHandle;
+
+private:
+ const ADGameDescription *_gameDescription;
};
void init(void);
diff --git a/engines/chamber/metaengine.cpp b/engines/chamber/metaengine.cpp
index d2ce107dfbf..1f2d556db43 100644
--- a/engines/chamber/metaengine.cpp
+++ b/engines/chamber/metaengine.cpp
@@ -23,6 +23,14 @@
#include "chamber/chamber.h"
#include "engines/advancedDetector.h"
+namespace Chamber {
+
+Common::Language ChamberEngine::getLanguage() const {
+ return _gameDescription->language;
+}
+
+} // end of namespace Chamber
+
class ChamberMetaEngine : public AdvancedMetaEngine {
public:
const char *getName() const override {
@@ -33,7 +41,7 @@ public:
};
Common::Error ChamberMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
- *engine = new Chamber::ChamberEngine(syst);
+ *engine = new Chamber::ChamberEngine(syst, desc);
return Common::kNoError;
}
Commit: 39c5791a4bf7056d6b27e940084ec68d0819c7ce
https://github.com/scummvm/scummvm/commit/39c5791a4bf7056d6b27e940084ec68d0819c7ce
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Switch to US version at run-time
Changed paths:
engines/chamber/cga.cpp
engines/chamber/common.h
engines/chamber/detection.cpp
engines/chamber/dialog.cpp
engines/chamber/ifgm.cpp
engines/chamber/input.cpp
engines/chamber/kult.cpp
engines/chamber/portrait.cpp
engines/chamber/print.cpp
engines/chamber/resdata.cpp
engines/chamber/resdata.h
engines/chamber/room.cpp
engines/chamber/script.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 87b2d3d88ac..37878849416 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -1332,11 +1332,11 @@ void CGA_ZoomImage(byte *pixels, byte w, byte h, byte nw, byte nh, byte *target,
zoom.oh = h;
zoom.ew = (w * 4) - 1;
zoom.eh = h - 1;
-#ifdef VERSION_USA
- zoom.xbase = 0;
-#else
- zoom.xbase = ((w * 4 / 2) - 1) % 4;
-#endif
+
+ if (g_vm->getLanguage() == Common::EN_USA)
+ zoom.xbase = 0;
+ else
+ zoom.xbase = ((w * 4 / 2) - 1) % 4;
/*TODO: why this nw/nh order? maybe bug*/
#if 0
diff --git a/engines/chamber/common.h b/engines/chamber/common.h
index bd330bff9c1..4f9d4d1ffc4 100644
--- a/engines/chamber/common.h
+++ b/engines/chamber/common.h
@@ -25,8 +25,6 @@
namespace Chamber {
-#define VERSION_USA
-
#define BE(x) ((((x) >> 8) | ((x) << 8)) & 0xffff)
#define LE16(x) (x)
diff --git a/engines/chamber/detection.cpp b/engines/chamber/detection.cpp
index bb4bd7ba76d..9f060e2f9bb 100644
--- a/engines/chamber/detection.cpp
+++ b/engines/chamber/detection.cpp
@@ -34,7 +34,7 @@ static const ADGameDescription gameDescriptions[] = {
{
"chamber",
"",
- AD_ENTRY1s("kult1.pxi", "fc0bd31a3c380338f76ff53e421e47b6", 140537),
+ AD_ENTRY1s("ere.pxi", "5aa5bd2d79eefde70675b0b6734944f2", 134358),
Common::UNK_LANG, // EN/FR/DE
Common::kPlatformDOS,
ADGF_UNSTABLE,
@@ -44,7 +44,7 @@ static const ADGameDescription gameDescriptions[] = {
{
"chamber",
"",
- AD_ENTRY1s("ere.pxi", "5aa5bd2d79eefde70675b0b6734944f2", 134358),
+ AD_ENTRY1s("kult1.pxi", "fc0bd31a3c380338f76ff53e421e47b6", 140537),
Common::EN_USA,
Common::kPlatformDOS,
ADGF_UNSTABLE,
diff --git a/engines/chamber/dialog.cpp b/engines/chamber/dialog.cpp
index 2a3fcd061b6..ad2eaefa25a 100644
--- a/engines/chamber/dialog.cpp
+++ b/engines/chamber/dialog.cpp
@@ -117,11 +117,11 @@ void DrawPersonBubble(byte x, byte y, byte flags, byte *msg) {
char_draw_max_width = flags & 0x1F;
char_xlat_table = chars_color_bonw;
-#ifdef VERSION_USA
- CalcStringSize(msg, &ww, &nw);
- if (ww >= char_draw_max_width)
- char_draw_max_width = ww;
-#endif
+ if (g_vm->getLanguage() == Common::EN_USA) {
+ CalcStringSize(msg, &ww, &nw);
+ if (ww >= char_draw_max_width)
+ char_draw_max_width = ww;
+ }
/*upper border*/
ofs = CGA_CalcXY_p(x, y);
diff --git a/engines/chamber/ifgm.cpp b/engines/chamber/ifgm.cpp
index b0142a025c3..0b63039d4a0 100644
--- a/engines/chamber/ifgm.cpp
+++ b/engines/chamber/ifgm.cpp
@@ -32,11 +32,12 @@ byte ifgm_loaded = 0;
byte ifgm_flag2;
void IFGM_Init(void) {
-#ifdef VERSION_USA
- /*TODO*/
-#else
- ifgm_loaded = 0;
-#endif
+ if (g_vm->getLanguage() == Common::EN_USA) {
+ /*TODO*/
+ } else {
+ ifgm_loaded = 0;
+ }
+
}
void IFGM_Shutdown(void) {
diff --git a/engines/chamber/input.cpp b/engines/chamber/input.cpp
index 7545fe7aaa5..1c4eec27e4c 100644
--- a/engines/chamber/input.cpp
+++ b/engines/chamber/input.cpp
@@ -84,10 +84,6 @@ byte ChamberEngine::readKeyboardChar() {
void ClearKeyboard(void) {
}
-#ifdef VERSION_USA
-extern int16 AskQuitGame(void);
-#endif
-
void SetInputButtons(byte keys) {
if (keys & 2)
right_button = ~0;
@@ -147,8 +143,12 @@ byte PollKeyboard(void) {
Show game exit confirmation dialog and get user's input
*/
int16 AskQuitGame(void) {
+ /*EU version comes without requited text string*/
+ if (g_vm->getLanguage() != Common::EN_USA)
+ return 0;
+
int16 quit = -1;
-#ifdef VERSION_USA
+
byte *msg = SeekToString(desci_data, 411); /*DO YOU WANT TO QUIT ? (Y OR N).*/
char_draw_max_width = 32;
draw_x = 1;
@@ -177,9 +177,8 @@ int16 AskQuitGame(void) {
}
}
CGA_CopyScreenBlock(backbuffer, char_draw_max_width + 2, char_draw_coords_y - draw_y + 8, frontbuffer, CGA_CalcXY_p(draw_x, draw_y));
-#endif
- /*EU version comes without requited text string*/
- return quit == 1;
+
+ return quit;
}
void PollInputButtonsOnly() {
@@ -194,10 +193,10 @@ void PollInput(void) {
if (event.kbd.keycode == Common::KEYCODE_SPACE)
mouseButtons |= 1;
else if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
-#ifdef VERSION_USA
- if (AskQuitGame() != 0)
- g_vm->_shouldQuit = true;
-#endif
+ if (g_vm->getLanguage() == Common::EN_USA) {
+ if (AskQuitGame() != 0)
+ g_vm->_shouldQuit = true;
+ }
}
break;
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 44b338061cd..deceb0d7da8 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -217,19 +217,19 @@ Common::Error ChamberEngine::run() {
/* Install timer callback */
InitTimer();
-#ifdef VERSION_USA
- /* Load title screen */
- if (!LoadSplash("PRESCGA.BIN"))
- ExitGame();
+ if (g_vm->getLanguage() == Common::EN_USA) {
+ /* Load title screen */
+ if (!LoadSplash("PRESCGA.BIN"))
+ ExitGame();
- if (ifgm_loaded) {
- /*TODO*/
+ if (ifgm_loaded) {
+ /*TODO*/
+ }
+ } else {
+ /* Load title screen */
+ if (!LoadSplash("PRES.BIN"))
+ ExitGame();
}
-#else
- /* Load title screen */
- if (!LoadSplash("PRES.BIN"))
- ExitGame();
-#endif
/* Select intense cyan-mageta palette */
CGA_ColorSelect(0x30);
@@ -237,35 +237,35 @@ Common::Error ChamberEngine::run() {
/* Show the title screen */
CGA_BackBufferToRealFull();
-#ifdef VERSION_USA
- if (ifgm_loaded) {
- /*TODO*/
- }
-
- /* Force English language */
- c = 'E';
-#else
- /* Load language selection screen */
- if (!LoadSplash("DRAP.BIN"))
- ExitGame();
-
- /* Wait for a keypress and show the language selection screen */
- ClearKeyboard();
- readKeyboardChar();
-
- if (_shouldQuit)
- return Common::kNoError;
+ if (g_vm->getLanguage() == Common::EN_USA) {
+ if (ifgm_loaded) {
+ /*TODO*/
+ }
- CGA_BackBufferToRealFull();
- ClearKeyboard();
-
- /* Wait for a valid language choice */
- do {
- c = readKeyboardChar();
- if (c > 'F')
- c -= ' ';
- } while (c < 'D' || c > 'F');
-#endif
+ /* Force English language */
+ c = 'E';
+ } else {
+ /* Load language selection screen */
+ if (!LoadSplash("DRAP.BIN"))
+ ExitGame();
+
+ /* Wait for a keypress and show the language selection screen */
+ ClearKeyboard();
+ readKeyboardChar();
+
+ if (_shouldQuit)
+ return Common::kNoError;
+
+ CGA_BackBufferToRealFull();
+ ClearKeyboard();
+
+ /* Wait for a valid language choice */
+ do {
+ c = readKeyboardChar();
+ if (c > 'F')
+ c -= ' ';
+ } while (c < 'D' || c > 'F');
+ }
if (_shouldQuit)
return Common::kNoError;
@@ -276,9 +276,8 @@ Common::Error ChamberEngine::run() {
res_desci[0].name[4] = c;
res_diali[0].name[4] = c;
-#ifndef VERSION_USA
- CGA_BackBufferToRealFull();
-#endif
+ if (g_vm->getLanguage() != Common::EN_USA)
+ CGA_BackBufferToRealFull();
/* Load script and other static resources */
/* Those are normally embedded in the executable, but here we load extracted ones*/
@@ -305,11 +304,11 @@ Common::Error ChamberEngine::run() {
/* Detect CPU speed for delay routines */
cpu_speed_delay = BenchmarkCpu() / 8;
-#ifdef VERSION_USA
- if (ifgm_loaded) {
- /*TODO*/
+ if (g_vm->getLanguage() == Common::EN_USA) {
+ if (ifgm_loaded) {
+ /*TODO*/
+ }
}
-#endif
/*restart game from here*/
restart:;
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index f1053a0fa1d..791445409ea 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -311,20 +311,20 @@ void BlinkToRed(void) {
}
void BlinkToWhite(void) {
-#ifdef VERSION_USA
- PlayHurtSound(); /*TODO: play here and later? looks like a bug, original code will trash palette selection if pcspeaker is used*/
-#endif
+ if (g_vm->getLanguage() == Common::EN_USA)
+ PlayHurtSound(); /*TODO: play here and later? looks like a bug, original code will trash palette selection if pcspeaker is used*/
+
BlinkWithSound(0x3F);
}
volatile byte vblank_ticks;
void WaitVBlankTimer(void) {
-#ifdef VERSION_USA
- /*A crude attempt to fix the animation speed...*/
- while (vblank_ticks < 3) ;
- vblank_ticks = 0;
-#endif
+ if (g_vm->getLanguage() == Common::EN_USA) {
+ /*A crude attempt to fix the animation speed...*/
+ while (vblank_ticks < 3) ;
+ vblank_ticks = 0;
+ }
WaitVBlank();
}
diff --git a/engines/chamber/print.cpp b/engines/chamber/print.cpp
index d31c8c0f553..0458c862710 100644
--- a/engines/chamber/print.cpp
+++ b/engines/chamber/print.cpp
@@ -163,12 +163,14 @@ byte *PrintStringLine(byte *str, uint16 *left, byte *target) {
byte *PrintStringPadded(byte *str, byte *target) {
uint16 w;
-#ifndef VERSION_USA
- uint16 n;
- CalcStringSize(str, &w, &n);
- if (w + 2 >= char_draw_max_width)
- char_draw_max_width = w + 2;
-#endif
+
+ if (g_vm->getLanguage() != Common::EN_USA) {
+ uint16 n;
+ CalcStringSize(str, &w, &n);
+ if (w + 2 >= char_draw_max_width)
+ char_draw_max_width = w + 2;
+ }
+
str = PrintStringLine(str, &w, target);
if (w != 0)
PrintStringPad(w, target);
@@ -199,11 +201,11 @@ void CGA_DrawTextBox(byte *msg, byte *target) {
char_xlat_table = chars_color_bonc;
-#ifdef VERSION_USA
- CalcStringSize(msg, &ww, &nw);
- if (ww >= char_draw_max_width)
- char_draw_max_width = ww;
-#endif
+ if (g_vm->getLanguage() == Common::EN_USA) {
+ CalcStringSize(msg, &ww, &nw);
+ if (ww >= char_draw_max_width)
+ char_draw_max_width = ww;
+ }
x = draw_x * 4;
y = draw_y;
diff --git a/engines/chamber/resdata.cpp b/engines/chamber/resdata.cpp
index b8bbcd0b6f4..91cfd6b5441 100644
--- a/engines/chamber/resdata.cpp
+++ b/engines/chamber/resdata.cpp
@@ -138,7 +138,10 @@ NB! Static data includes the font file, don't use any text print routines before
int16 LoadStaticData() {
Common::File pxi;
- pxi.open("ere.pxi");
+ if (g_vm->getLanguage() == Common::EN_USA)
+ pxi.open("kult1.pxi");
+ else
+ pxi.open("ere.pxi");
uint numMods = pxi.readUint16BE();
uint modBase = 2 + numMods * 4;
diff --git a/engines/chamber/resdata.h b/engines/chamber/resdata.h
index 72773caedb7..f5adfc91a0a 100644
--- a/engines/chamber/resdata.h
+++ b/engines/chamber/resdata.h
@@ -36,7 +36,6 @@ typedef struct ResEntry_tp {
} ResEntry_tp;
/* Max resource file size among all languages */
-#ifdef VERSION_USA
#define RES_ALEAT_MAX 256
#define RES_ANICO_MAX 667
#define RES_ANIMA_MAX 2046
@@ -58,29 +57,6 @@ typedef struct ResEntry_tp {
#define RES_DIALI_MAX 9636
#define RES_MOTSI_MAX 1082
#define RES_VEPCI_MAX 1345
-#else
-#define RES_ALEAT_MAX 256
-#define RES_ANICO_MAX 667
-#define RES_ANIMA_MAX 2046
-#define RES_ARPLA_MAX 7910
-#define RES_CARPC_MAX 384
-#define RES_GAUSS_MAX 1449
-#define RES_ICONE_MAX 2756
-#define RES_LUTIN_MAX 2800
-#define RES_MURSM_MAX 76
-#define RES_SOUCO_MAX 424
-#define RES_SOURI_MAX 1152
-#define RES_TEMPL_MAX 27337
-#define RES_ZONES_MAX 9014
-#define RES_PUZZL_MAX 45671
-#define RES_SPRIT_MAX 23811
-#define RES_PERS1_MAX 14294
-#define RES_PERS2_MAX 10587
-#define RES_DESCI_MAX 10515
-#define RES_DIALI_MAX 9636
-#define RES_MOTSI_MAX 1082
-#define RES_VEPCI_MAX 1345
-#endif
extern byte vepci_data[];
extern byte motsi_data[];
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index ea52c9d0376..7e7b91d932f 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -1527,12 +1527,12 @@ void DrawTheWallDoors(void) {
case 9:
case 102:
CGA_Blit(LoadMursmSprite(0) + 10, 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(64 / CGA_PIXELS_PER_BYTE, 32));
-#ifdef VERSION_USA
- /*This fixes odd black patch on the right gate door*/
- CGA_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(184 / CGA_PIXELS_PER_BYTE, 32));
-#else
- CGA_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(180 / CGA_PIXELS_PER_BYTE, 32));
-#endif
+ if (g_vm->getLanguage() == Common::EN_USA) {
+ /*This fixes odd black patch on the right gate door*/
+ CGA_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(184 / CGA_PIXELS_PER_BYTE, 32));
+ } else {
+ CGA_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(180 / CGA_PIXELS_PER_BYTE, 32));
+ }
break;
case 95:
case 103:
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 88f4384a976..4433e92ae5c 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -2885,26 +2885,25 @@ void TheEnd(void) {
AnimSaucer();
-#ifdef VERSION_USA
- DrawPortraitZoomed(&pimage2);
+ if (g_vm->getLanguage() == Common::EN_USA) {
+ DrawPortraitZoomed(&pimage2);
- script_byte_vars.zone_index = 135;
+ script_byte_vars.zone_index = 135;
- do
- {
- PollInputButtonsOnly();
- }
- while(buttons == 0);
+ do {
+ PollInputButtonsOnly();
+ }
+ while(buttons == 0);
- while (!LoadFond())
- AskDisk2();
- JaggedZoom(backbuffer, frontbuffer);
- CGA_BackBufferToRealFull();
-#else
- while (!LoadSplash("PRES.BIN"))
- AskDisk2();
- CGA_BackBufferToRealFull();
-#endif
+ while (!LoadFond())
+ AskDisk2();
+ JaggedZoom(backbuffer, frontbuffer);
+ CGA_BackBufferToRealFull();
+ } else {
+ while (!LoadSplash("PRES.BIN"))
+ AskDisk2();
+ CGA_BackBufferToRealFull();
+ }
}
uint16 SCR_5B_TheEnd(void) {
@@ -2913,11 +2912,11 @@ uint16 SCR_5B_TheEnd(void) {
TheEnd();
-#ifdef VERSION_USA
- RestartGame();
-#else
- for (;;) ; /*HANG*/
-#endif
+ if (g_vm->getLanguage() == Common::EN_USA)
+ RestartGame();
+ else
+ for (;;) ; /*HANG*/
+
return 0;
}
Commit: 37c366762fb5cb0feebfc74f342a44290bee7ced
https://github.com/scummvm/scummvm/commit/37c366762fb5cb0feebfc74f342a44290bee7ced
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Added Hercules constants
Changed paths:
engines/chamber/cga.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 37878849416..58d91fce12d 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -31,6 +31,57 @@
namespace Chamber {
+#if 0
+#define HGA_WIDTH 720
+#define HGA_HEIGHT 348
+#define HGA_BASE_SEG 0xB000
+#define HGA_PAGE2_SEG 0xB800
+#define HGA_NEXT_LINES_OFS 0x2000
+#define HGA_BITS_PER_PIXEL 1
+#define HGA_PIXELS_PER_BYTE (8 / HGA_BITS_PER_PIXEL)
+#define HGA_BYTES_PER_LINE (HGA_WIDTH / HGA_PIXELS_PER_BYTE)
+#define HGA_CALCXY_RAW(x, y) ( ((y) % 4) * HGA_NEXT_LINES_OFS + ((y) / 4) * HGA_BYTES_PER_LINE + (x) / HGA_PIXELS_PER_BYTE )
+#define HGA_CENTERED_BASE_OFS HGA_CALCXY_RAW(32, 76)
+#ifdef __386__
+#define HGA_SCREENBUFFER ((byte*)(HGA_BASE_SEG * 16))
+#define HGA_BACKBUFFER ((byte*)(HGA_PAGE2_SEG * 16))
+#else
+#define HGA_SCREENBUFFER ((byte*)MK_FP(HGA_BASE_SEG, 0))
+#define HGA_BACKBUFFER ((byte*)MK_FP(HGA_PAGE2_SEG, 0))
+#endif
+#define HGA_FONT_HEIGHT 6
+#define frontbuffer HGA_SCREENBUFFER
+#define backbuffer HGA_BACKBUFFER
+/* Calc screen offset from normal pixel coordinates
+Out:
+ screen offset
+*/
+uint16 HGA_CalcXY(uint16 x, uint16 y) {
+ return HGA_CalcXY_p(x / 4, y);
+}
+
+/* Calc screen offset from packed pixel coordinates
+Out:
+ screen offset
+*/
+uint16 HGA_CalcXY_p(uint16 x, uint16 y) {
+ uint16 ofs = HGA_CENTERED_BASE_OFS; /*initial offset for centering*/
+#if 0
+ ofs += HGA_CALCXY_RAW(x * 4 * 2, y);
+#else
+ /*optimized version of the above*/
+ if (y & 1)
+ ofs |= HGA_NEXT_LINES_OFS;
+ if (y & 2)
+ ofs |= HGA_NEXT_LINES_OFS * 2;
+ y /= 4;
+ ofs += y * HGA_BYTES_PER_LINE;
+ ofs += x; /*one unit of x represent 4 pixels, but one unit of ofs is 8 pixels, so x is implicitly multiplied by 2 here*/
+#endif
+ return ofs;
+}
+#endif
+
extern byte backbuffer[0x4000];
byte CGA_SCREENBUFFER[0x4000];
byte scrbuffer[320*200];
Commit: 064781ae303fd7c01ab68c0dc5346257f9d1e100
https://github.com/scummvm/scummvm/commit/064781ae303fd7c01ab68c0dc5346257f9d1e100
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix warnings
Changed paths:
engines/chamber/room.cpp
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index 7e7b91d932f..d21ef1daa00 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -654,8 +654,8 @@ lutinanim_t lutins_table[] = {
void BeforeChangeZone(byte index) {
byte oldspot;
- static const animdesc_t anim57 = {ANIMFLG_USESPOT | 57};
- static const animdesc_t anim58 = {ANIMFLG_USESPOT | 58};
+ static const animdesc_t anim57 = {ANIMFLG_USESPOT | 57, 0};
+ static const animdesc_t anim58 = {ANIMFLG_USESPOT | 58, 0};
script_byte_vars.need_draw_spots = 0;
if (pers_list[kPersScifi].area != script_byte_vars.zone_area)
@@ -893,8 +893,8 @@ void DrawRoomItemsIndicator(void) {
}
void DrawZoneSpots(void) {
- static const animdesc_t anim59 = {ANIMFLG_USESPOT | 59};
- static const animdesc_t anim60 = {ANIMFLG_USESPOT | 60};
+ static const animdesc_t anim59 = {ANIMFLG_USESPOT | 59, 0};
+ static const animdesc_t anim60 = {ANIMFLG_USESPOT | 60, 0};
byte oldspot = script_byte_vars.cur_spot_idx;
@@ -1745,7 +1745,7 @@ void UpdateProtozorqs(void) {
pers_list[kPersProtozorq13].area = script_byte_vars.bvar_40;
if (script_byte_vars.zone_area == script_byte_vars.bvar_3F) {
- static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35};
+ static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35, 0};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
HidePerson(PersonOffset(kPersProtozorq14));
@@ -1759,7 +1759,7 @@ void UpdateProtozorqs(void) {
}
if (script_byte_vars.zone_area == script_byte_vars.bvar_40) {
- static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34};
+ static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34, 0};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
@@ -1796,7 +1796,7 @@ void UpdateProtozorqs(void) {
return;
if (script_byte_vars.zone_area == script_byte_vars.bvar_3F) {
- static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35};
+ static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35, 0};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
HidePerson(PersonOffset(kPersProtozorq14));
@@ -1807,7 +1807,7 @@ void UpdateProtozorqs(void) {
}
if (script_byte_vars.zone_area == script_byte_vars.bvar_40) {
- static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34};
+ static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34, 0};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
Commit: 5a642664117d5f2094a94c64e2148864862d913a
https://github.com/scummvm/scummvm/commit/5a642664117d5f2094a94c64e2148864862d913a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Fix warnings
Changed paths:
engines/chamber/kult.cpp
engines/chamber/print.cpp
engines/chamber/room.cpp
engines/chamber/script.cpp
engines/chamber/scrvars.h
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index deceb0d7da8..dc3b892235b 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -311,7 +311,7 @@ Common::Error ChamberEngine::run() {
}
/*restart game from here*/
-restart:;
+//restart:;
setjmp(restart_jmp);
Randomize();
diff --git a/engines/chamber/print.cpp b/engines/chamber/print.cpp
index 0458c862710..0fc21419950 100644
--- a/engines/chamber/print.cpp
+++ b/engines/chamber/print.cpp
@@ -272,7 +272,7 @@ void DebugMessage(char *msg, ...) {
va_list ap;
va_start(ap, msg);
- vsprintf((char *)m, msg, ap);
+ vsnprintf((char *)m, 256, msg, ap);
va_end(ap);
for (i = 0; m[i]; i++) {
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index d21ef1daa00..6c7ea228c18 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -654,8 +654,8 @@ lutinanim_t lutins_table[] = {
void BeforeChangeZone(byte index) {
byte oldspot;
- static const animdesc_t anim57 = {ANIMFLG_USESPOT | 57, 0};
- static const animdesc_t anim58 = {ANIMFLG_USESPOT | 58, 0};
+ static const animdesc_t anim57 = {ANIMFLG_USESPOT | 57, { { 0, 0 } }};
+ static const animdesc_t anim58 = {ANIMFLG_USESPOT | 58, { { 0, 0 } }};
script_byte_vars.need_draw_spots = 0;
if (pers_list[kPersScifi].area != script_byte_vars.zone_area)
@@ -893,8 +893,8 @@ void DrawRoomItemsIndicator(void) {
}
void DrawZoneSpots(void) {
- static const animdesc_t anim59 = {ANIMFLG_USESPOT | 59, 0};
- static const animdesc_t anim60 = {ANIMFLG_USESPOT | 60, 0};
+ static const animdesc_t anim59 = {ANIMFLG_USESPOT | 59, { { 0, 0 } }};
+ static const animdesc_t anim60 = {ANIMFLG_USESPOT | 60, { { 0, 0 } }};
byte oldspot = script_byte_vars.cur_spot_idx;
@@ -1745,7 +1745,7 @@ void UpdateProtozorqs(void) {
pers_list[kPersProtozorq13].area = script_byte_vars.bvar_40;
if (script_byte_vars.zone_area == script_byte_vars.bvar_3F) {
- static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35, 0};
+ static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35, { { 0, 0 } }};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
HidePerson(PersonOffset(kPersProtozorq14));
@@ -1759,7 +1759,7 @@ void UpdateProtozorqs(void) {
}
if (script_byte_vars.zone_area == script_byte_vars.bvar_40) {
- static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34, 0};
+ static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34, { { 0, 0 } }};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
@@ -1796,7 +1796,7 @@ void UpdateProtozorqs(void) {
return;
if (script_byte_vars.zone_area == script_byte_vars.bvar_3F) {
- static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35, 0};
+ static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35, { { 0, 0 } }};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
HidePerson(PersonOffset(kPersProtozorq14));
@@ -1807,7 +1807,7 @@ void UpdateProtozorqs(void) {
}
if (script_byte_vars.zone_area == script_byte_vars.bvar_40) {
- static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34, 0};
+ static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34, { { 0, 0 } }};
UpdateUndrawCursor(frontbuffer);
RefreshSpritesData();
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 4433e92ae5c..2c39a964cac 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -114,7 +114,7 @@ uint16 CMD_TRAP(void) {
}
uint16 SCR_TRAP(void) {
- printf("SCR TRAP 0x%02X @ 0x%X\n", *script_ptr, script_ptr - templ_data);
+ printf("SCR TRAP 0x%02X @ 0x%lX\n", *script_ptr, script_ptr - templ_data);
PromptWait();
for (;;) ;
return 0;
@@ -396,6 +396,7 @@ uint16 SCR_2D_Wait(void) {
byte seconds;
script_ptr++;
seconds = *script_ptr++;
+ (void)seconds;
Wait(4); /*TODO: looks like a bug?*/
return 0;
}
@@ -587,6 +588,7 @@ uint16 SCR_3B_MathExpr(void) {
opptr[1] = op2 & 255;
}
+ (void)op1;
/*return op1;*/ /*previous value, never used?*/
return 0;
}
@@ -870,7 +872,7 @@ uint16 SCR_C_DrawPortraitArcEffect(void) {
Draw image with slow top-to-down reveal effect by repeatedly draw its every 17th pixel
*/
uint16 SCR_D_DrawPortraitDotEffect(void) {
- int16 i;
+ //int16 i;
byte x, y, width, height;
uint16 offs, step = 17;
byte *target = CGA_SCREENBUFFER;
@@ -2084,7 +2086,7 @@ uint16 SCR_31_Fight2(void) {
pers_list[kPersVort2].area = script_byte_vars.zone_area;
pers_list[kPersVort2].flags = pers->flags;
if (script_byte_vars.zapstiks_owned == 0) {
- static const animdesc_t anim19 = {ANIMFLG_USESPOT | 19};
+ static const animdesc_t anim19 = {ANIMFLG_USESPOT | 19, { { 0, 0 } }};
AnimateSpot(&anim19);
}
the_command = next_vorts_cmd;
@@ -2093,7 +2095,7 @@ uint16 SCR_31_Fight2(void) {
pers_list[kPersVort3].area = script_byte_vars.zone_area;
pers_list[kPersVort3].flags = pers->flags;
if (script_byte_vars.zapstiks_owned == 0) {
- static const animdesc_t anim20 = {ANIMFLG_USESPOT | 20};
+ static const animdesc_t anim20 = {ANIMFLG_USESPOT | 20, { { 0, 0 } }};
AnimateSpot(&anim20);
}
the_command = next_vorts_cmd;
@@ -3077,7 +3079,7 @@ byte *DebugString(char *msg, ...) {
va_list ap;
va_start(ap, msg);
- vsprintf((char *)m, msg, ap);
+ vsnprintf((char *)m, 256, msg, ap);
va_end(ap);
for (i = 0; m[i]; i++) {
@@ -3916,7 +3918,7 @@ Aspirant walking out of the room
*/
uint16 CMD_18_AspirantLeave(void) {
/*TODO: check me*/
- static const animdesc_t anim33 = {ANIMFLG_USESPOT | 33};
+ static const animdesc_t anim33 = {ANIMFLG_USESPOT | 33, { { 0, 0 } }};
PopDirtyRects(DirtyRectSprite);
PopDirtyRects(DirtyRectText);
@@ -3939,7 +3941,7 @@ Aspirant walking into the room
*/
uint16 CMD_19_AspirantAppear(void) {
/*TODO: check me*/
- static const animdesc_t anim23 = {ANIMFLG_USESPOT | 23};
+ static const animdesc_t anim23 = {ANIMFLG_USESPOT | 23, { { 0, 0 } }};
PopDirtyRects(DirtyRectSprite);
aspirant_ptr->area = script_byte_vars.zone_area;
diff --git a/engines/chamber/scrvars.h b/engines/chamber/scrvars.h
index e351bdbcaa2..be0329aa534 100644
--- a/engines/chamber/scrvars.h
+++ b/engines/chamber/scrvars.h
@@ -141,7 +141,7 @@ script_byte_vars_t script_byte_vars = {
0, /* 6A */
0, /* 6B */
0, /* 6C */
- /*{0,0,0,0}*/ /* 6D..70 */
+ {0,0,0,0} /* 6D..70 */
};
script_word_vars_t script_word_vars = {
Commit: a8b5dea76abac3fa34d80676a7435170b57a65ed
https://github.com/scummvm/scummvm/commit/a8b5dea76abac3fa34d80676a7435170b57a65ed
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Renames in timer.h and sound.h
Changed paths:
engines/chamber/anim.cpp
engines/chamber/ifgm.cpp
engines/chamber/invent.cpp
engines/chamber/kult.cpp
engines/chamber/menu.cpp
engines/chamber/portrait.cpp
engines/chamber/room.cpp
engines/chamber/script.cpp
engines/chamber/sound.cpp
engines/chamber/sound.h
engines/chamber/timer.cpp
engines/chamber/timer.h
diff --git a/engines/chamber/anim.cpp b/engines/chamber/anim.cpp
index d7293626ff6..b490456cce4 100644
--- a/engines/chamber/anim.cpp
+++ b/engines/chamber/anim.cpp
@@ -317,7 +317,7 @@ void PlayAnim(byte index, byte x, byte y) {
panim++;
sound = *panim++;
panim++; /*unused*/
- PlaySound(sound);
+ playSound(sound);
break;
case 0xFC: /*nothing*/
panim++;
diff --git a/engines/chamber/ifgm.cpp b/engines/chamber/ifgm.cpp
index 0b63039d4a0..e47562b76b1 100644
--- a/engines/chamber/ifgm.cpp
+++ b/engines/chamber/ifgm.cpp
@@ -88,7 +88,7 @@ void IFGM_PlaySfx(byte index) {
return;
if (cur_dlg_index == 0)
return;
- PlaySound(sfx_sounds[index % 16]);
+ playSound(sfx_sounds[index % 16]);
}
} // end of namespace Chamber
diff --git a/engines/chamber/invent.cpp b/engines/chamber/invent.cpp
index 54e52dbc451..b1a47776329 100644
--- a/engines/chamber/invent.cpp
+++ b/engines/chamber/invent.cpp
@@ -81,7 +81,7 @@ void DrawInventoryBox(uint16 filtermask, uint16 filtervalue) {
if (count == 0) {
/*once first valid item found, draw the box*/
CGA_FillAndWait(inv_bgcolor, 64 / 4, 64, CGA_SCREENBUFFER, CGA_CalcXY_p(232 / 4, 56));
- PlaySound(20);
+ playSound(20);
}
inventory_spots[count].name = inventory_items[i].name;
inventory_spots[count].command = inventory_items[i].command;
@@ -127,7 +127,7 @@ void OpenInventory(uint16 filtermask, uint16 filtervalue) {
UndrawCursor(frontbuffer);
}
CGA_RestoreImage(scratch_mem2, frontbuffer);
- PlaySound(20);
+ playSound(20);
switch (((item_t *)script_vars[ScrPool3_CurrentItem])->name) {
case 108: /*DAGGER*/
case 115: /*SACRIFICIAL BLADE*/
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index dc3b892235b..a89d0d55970 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -192,7 +192,7 @@ process:
void ExitGame(void) {
SwitchToTextMode();
- UninitTimer();
+ uninitTimer();
}
jmp_buf restart_jmp;
@@ -215,7 +215,7 @@ Common::Error ChamberEngine::run() {
SwitchToGraphicsMode();
/* Install timer callback */
- InitTimer();
+ initTimer();
if (g_vm->getLanguage() == Common::EN_USA) {
/* Load title screen */
diff --git a/engines/chamber/menu.cpp b/engines/chamber/menu.cpp
index caa56be7533..9d9e1a36e40 100644
--- a/engines/chamber/menu.cpp
+++ b/engines/chamber/menu.cpp
@@ -111,7 +111,7 @@ void ActionsMenu(byte **pinfo) {
/*menu sprite*/
BackupAndShowSprite(0, x, y);
- PlaySound(18);
+ playSound(18);
choices = *((*pinfo)++);
menurecs = *pinfo;
@@ -163,7 +163,7 @@ void ActionsMenu(byte **pinfo) {
UndrawCursor(CGA_SCREENBUFFER);
if (the_command != 0xFFFF) {
- PlaySound(19);
+ playSound(19);
WaitVBlank();
/*draw dot explosion animation*/
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index 791445409ea..4d640600095 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -295,9 +295,9 @@ int16 DrawPortrait(byte **desc, byte *x, byte *y, byte *width, byte *height) {
void PlayHurtSound() {
if (!ifgm_loaded)
- PlaySound(144);
+ playSound(144);
else
- PlaySound(144 + (Rand() / 4) % 4);
+ playSound(144 + (Rand() / 4) % 4);
}
void BlinkWithSound(byte color) {
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index 6c7ea228c18..c8bbe11cf1d 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -506,7 +506,7 @@ void AnimRoomDoorOpen(byte index) {
info->layer[1].pixels += info->layer[1].width * 2 * 2;
}
- PlaySound(31);
+ playSound(31);
}
/*
@@ -541,7 +541,7 @@ void AnimRoomDoorClose(byte index) {
info->layer[1].pixels = oldpixels;
DrawRoomDoor();
- PlaySound(31);
+ playSound(31);
}
/*Maybe FindRoomDoor?*/
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 2c39a964cac..6cc98d54e72 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -1851,7 +1851,7 @@ uint16 SCR_41_LiftHand(void) {
script_ptr++;
RedrawRoomStatics(92, script_byte_vars.hands);
CGA_BackBufferToRealFull();
- PlaySound(31);
+ playSound(31);
return 0;
}
@@ -2137,7 +2137,7 @@ uint16 SCR_31_Fight2(void) {
IFGM_PlaySample(150);
}
if (fightlist[i].anim.index == 55)
- PlaySound(151);
+ playSound(151);
PlayAnim(fightlist[i].anim.index, fightlist[i].anim.params.coords.x, fightlist[i].anim.params.coords.y);
break;
}
@@ -2161,7 +2161,7 @@ void FightWin(void) {
&& script_byte_vars.zapstiks_owned != 0
&& fight_mode == 0) {
script_byte_vars.bvar_67 = 1;
- PlaySound(149);
+ playSound(149);
PlayAnim(40, found_spot->sx, found_spot->sy);
}
}
@@ -3188,13 +3188,13 @@ uint16 SCR_68_PlaySfx(void) {
/*
Play sound
*/
-uint16 SCR_69_PlaySound(void) {
+uint16 SCR_69_playSound(void) {
byte index;
script_ptr++;
index = *script_ptr++;
script_ptr++;
- PlaySound(index);
+ playSound(index);
return 0;
}
@@ -3443,7 +3443,7 @@ uint16 CMD_B_PsiStickyFingers(void) {
DrawStickyNet();
SelectCursor(CURSOR_FLY);
MenuLoop(0, 0);
- PlaySound(224);
+ playSound(224);
CGA_BackBufferToRealFull();
RestoreScreenOfSpecialRoom();
@@ -3547,7 +3547,7 @@ uint16 CMD_E_PsiZoneScan(void) {
for (spot = zone_spots; spot != zone_spots_end; spot++) {
if ((spot->flags & ~(SPOTFLG_40 | 7)) == (SPOTFLG_20 | SPOTFLG_8) && spot->sy == y) {
- PlaySound(27);
+ playSound(27);
spot->flags |= SPOTFLG_80;
PlayAnim(38, spot->sx, spot->sy);
break;
@@ -3581,7 +3581,7 @@ uint16 CMD_F_PsiPsiShift(void) {
SelectCursor(CURSOR_GRAB);
MenuLoop(0, 0);
BackupScreenOfSpecialRoom();
- PlaySound(25);
+ playSound(25);
PlayAnim(39, cursor_x / 4, cursor_y);
RestoreScreenOfSpecialRoom();
@@ -3672,7 +3672,7 @@ void ActionForPersonChoice(uint16 *actions) {
the_command = actions[index];
- PlaySound(22);
+ playSound(22);
}
}
@@ -4294,7 +4294,7 @@ cmdhandler_t script_handlers[] = {
SCR_66_DeProfundisRideToExit,
SCR_67_Unused,
SCR_68_PlaySfx,
- SCR_69_PlaySound,
+ SCR_69_playSound,
SCR_6A_Unused,
};
#define MAX_SCR_HANDLERS (sizeof(script_handlers) / sizeof(script_handlers[0]))
diff --git a/engines/chamber/sound.cpp b/engines/chamber/sound.cpp
index 63f88477545..9d6bd48daee 100644
--- a/engines/chamber/sound.cpp
+++ b/engines/chamber/sound.cpp
@@ -59,7 +59,7 @@ pcsample_t pc_samples[] = {
#undef N
-static void SpeakerPlay(pcsample_t *sample) {
+static void speakerPlay(pcsample_t *sample) {
uint16 rep, freq, delay1, delay2;
freq = sample->freq;
@@ -108,7 +108,7 @@ byte sounds_table[kMaxSounds][3] = {
{31, 0, 0}
};
-void PlaySound(byte index) {
+void playSound(byte index) {
int16 i;
if (IFGM_PlaySound(index))
return;
@@ -117,7 +117,7 @@ void PlaySound(byte index) {
if (sounds_table[i][0] == index
|| sounds_table[i][1] == index
|| sounds_table[i][2] == index) {
- SpeakerPlay(&pc_samples[i]);
+ speakerPlay(&pc_samples[i]);
break;
}
}
diff --git a/engines/chamber/sound.h b/engines/chamber/sound.h
index 0c649bb52aa..99518964c58 100644
--- a/engines/chamber/sound.h
+++ b/engines/chamber/sound.h
@@ -25,7 +25,7 @@
namespace Chamber {
-void PlaySound(byte index);
+void playSound(byte index);
} // End of namespace Chamber
diff --git a/engines/chamber/timer.cpp b/engines/chamber/timer.cpp
index c1e778e8e2b..8bd182b4c48 100644
--- a/engines/chamber/timer.cpp
+++ b/engines/chamber/timer.cpp
@@ -32,7 +32,7 @@
namespace Chamber {
-void AnimateGauss(byte *target) {
+void animateGauss(byte *target) {
byte *sprite;
byte phase = Rand() % 4;
if (phase == script_byte_vars.gauss_phase)
@@ -48,17 +48,17 @@ void timerCallback(void *refCon) {
if (script_byte_vars.timer_ticks % 16 == 0) {
script_word_vars.timer_ticks2 = Swap16(Swap16(script_word_vars.timer_ticks2) + 1);
#if 1
- AnimateGauss(frontbuffer);
+ animateGauss(frontbuffer);
#endif
}
}
}
-void InitTimer(void) {
+void initTimer(void) {
g_system->getTimerManager()->installTimerProc(&timerCallback, 1000000 / 16, NULL, "mainTimer");
}
-void UninitTimer(void) {
+void uninitTimer(void) {
g_system->getTimerManager()->removeTimerProc(&timerCallback);
}
diff --git a/engines/chamber/timer.h b/engines/chamber/timer.h
index 22755557201..e204bdd8551 100644
--- a/engines/chamber/timer.h
+++ b/engines/chamber/timer.h
@@ -25,8 +25,8 @@
namespace Chamber {
-void InitTimer(void);
-void UninitTimer(void);
+void initTimer(void);
+void uninitTimer(void);
} // End of namespace Chamber
Commit: 4c192ca5c0a5db8e0c428ce438df1c317ef2b218
https://github.com/scummvm/scummvm/commit/4c192ca5c0a5db8e0c428ce438df1c317ef2b218
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Renames in anim.cpp
Changed paths:
engines/chamber/anim.cpp
engines/chamber/anim.h
engines/chamber/room.cpp
engines/chamber/script.cpp
diff --git a/engines/chamber/anim.cpp b/engines/chamber/anim.cpp
index b490456cce4..5beb43a9aee 100644
--- a/engines/chamber/anim.cpp
+++ b/engines/chamber/anim.cpp
@@ -53,7 +53,7 @@ extern uint16 cpu_speed_delay;
extern byte *SeekToEntry(byte *bank, uint16 num, byte **end);
extern void LoadLutinSprite(uint16 lutidx);
-void GetScratchBuffer(byte mode) {
+void getScratchBuffer(byte mode) {
byte *buffer = scratch_mem2;
uint16 offs = 0;
if (mode & 0x80)
@@ -63,16 +63,16 @@ void GetScratchBuffer(byte mode) {
lutin_mem = buffer + offs;
}
-void AnimLoadSprite(byte **panim) {
+void animLoadSprite(byte **panim) {
byte mode;
byte index;
mode = *((*panim)++);
index = *((*panim)++);
- GetScratchBuffer(mode);
+ getScratchBuffer(mode);
LoadLutinSprite(index);
}
-void ClipSprite(byte *x, byte *y, byte *sprw, byte *sprh, byte **sprite, int8 dx, int8 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) {
@@ -108,7 +108,7 @@ void ClipSprite(byte *x, byte *y, byte *sprw, byte *sprh, byte **sprite, int8 dx
}
}
-void CopyScreenBlockWithDotEffect(byte *source, byte x, byte y, byte width, byte height, byte *target) {
+void copyScreenBlockWithDotEffect(byte *source, byte x, byte y, byte width, byte height, byte *target) {
uint16 offs;
uint16 xx = x * 4;
uint16 ww = width * 4;
@@ -131,7 +131,7 @@ void CopyScreenBlockWithDotEffect(byte *source, byte x, byte y, byte width, byte
}
}
-void AnimDrawSprite(byte x, byte y, byte sprw, byte sprh, byte *pixels, uint16 pitch) {
+void animDrawSprite(byte x, byte y, byte sprw, byte sprh, byte *pixels, uint16 pitch) {
uint16 delay;
byte ex, ey, updx, updy, updw, updh;
uint16 ofs = CGA_CalcXY_p(x, y);
@@ -162,7 +162,7 @@ void AnimDrawSprite(byte x, byte y, byte sprw, byte sprh, byte *pixels, uint16 p
WaitVBlank();
if (anim_use_dot_effect)
- CopyScreenBlockWithDotEffect(backbuffer, updx, updy, updw, updh, frontbuffer);
+ copyScreenBlockWithDotEffect(backbuffer, updx, updy, updw, updh, frontbuffer);
else {
CGA_CopyScreenBlock(backbuffer, updw, updh, frontbuffer, ofs);
}
@@ -176,12 +176,12 @@ void AnimDrawSprite(byte x, byte y, byte sprw, byte sprh, byte *pixels, uint16 p
anim_shift_x = anim_shift_y = 0;
}
-void AnimUndrawSprite(void) {
+void animUndrawSprite(void) {
CGA_CopyScreenBlock(backbuffer, last_anim_width, last_anim_height, CGA_SCREENBUFFER, CGA_CalcXY_p(last_anim_x, last_anim_y));
last_anim_height = 0;
}
-void PlayAnimCore(byte **panim) {
+void playAnimCore(byte **panim) {
byte mode;
uint16 count, count2;
byte *pframe;
@@ -203,7 +203,7 @@ void PlayAnimCore(byte **panim) {
int8 dx, dy;
uint16 pitch;
mode = *pframe++;
- GetScratchBuffer(mode);
+ getScratchBuffer(mode);
dy = mode & 7;
dx = (mode >> 3) & 7;
@@ -219,12 +219,12 @@ void PlayAnimCore(byte **panim) {
sprh = *sprite++;
pitch = sprw * 2;
- ClipSprite(&x, &y, &sprw, &sprh, &sprite, dx, dy);
- AnimDrawSprite(x, y, sprw, sprh, sprite, pitch);
+ clipSprite(&x, &y, &sprw, &sprh, &sprite, dx, dy);
+ animDrawSprite(x, y, sprw, sprh, sprite, pitch);
if (anim_flags & 4) {
if (anim_cycle == 0) {
- AnimUndrawSprite();
+ animUndrawSprite();
goto end;
}
} else if (anim_flags & 2) {
@@ -240,62 +240,62 @@ end:
*panim += mode & 7;
}
-void Anim1(byte **panim) {
+void anim1(byte **panim) {
anim_cycle = 0xFF;
anim_use_dot_effect = 0;
- PlayAnimCore(panim);
+ playAnimCore(panim);
}
-void Anim2(byte **panim) {
+void anim2(byte **panim) {
anim_cycle = 1;
anim_use_dot_effect = 0;
- PlayAnimCore(panim);
+ playAnimCore(panim);
}
-void Anim3(byte **panim) {
+void anim3(byte **panim) {
anim_cycle = 1;
anim_use_dot_effect = 0;
- PlayAnimCore(panim);
+ playAnimCore(panim);
}
-void Anim4(byte **panim) {
+void anim4(byte **panim) {
anim_cycle = last_anim_width - 1;
anim_use_dot_effect = 0;
- PlayAnimCore(panim);
+ playAnimCore(panim);
}
-void Anim5(byte **panim) {
+void anim5(byte **panim) {
anim_cycle = last_anim_width - 1;
anim_use_dot_effect = 0;
- PlayAnimCore(panim);
+ playAnimCore(panim);
}
-void Anim6(byte **panim) {
+void anim6(byte **panim) {
anim_cycle = last_anim_height;
anim_use_dot_effect = 0;
- PlayAnimCore(panim);
+ playAnimCore(panim);
}
-void Anim7(byte **panim) {
+void anim7(byte **panim) {
anim_cycle = 0xFF;
anim_use_dot_effect = 1;
- PlayAnimCore(panim);
+ playAnimCore(panim);
}
typedef void (*animhandler_t)(byte **panim);
animhandler_t anim_handlers[] = {
- AnimLoadSprite,
- Anim1,
- Anim2,
- Anim3,
- Anim4,
- Anim5,
- Anim6,
- Anim7
+ animLoadSprite,
+ anim1,
+ anim2,
+ anim3,
+ anim4,
+ anim5,
+ anim6,
+ anim7
};
-void PlayAnim(byte index, byte x, byte y) {
+void playAnim(byte index, byte x, byte y) {
byte sound;
byte *panim;
diff --git a/engines/chamber/anim.h b/engines/chamber/anim.h
index 5efb915295f..2a2ed7967ea 100644
--- a/engines/chamber/anim.h
+++ b/engines/chamber/anim.h
@@ -25,8 +25,8 @@
namespace Chamber {
-void PlayAnim(byte index, byte x, byte y);
-void CopyScreenBlockWithDotEffect(byte *source, byte x, byte y, byte width, byte height, byte *target);
+void playAnim(byte index, byte x, byte y);
+void copyScreenBlockWithDotEffect(byte *source, byte x, byte y, byte width, byte height, byte *target);
extern byte dot_effect_step;
extern uint16 dot_effect_delay;
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index c8bbe11cf1d..1a5052bf997 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -604,10 +604,10 @@ void AnimateSpot(const animdesc_t *info) {
if (info->params.desc)
DrawMessage(SeekToString(desci_data, info->params.desc), frontbuffer);
- PlayAnim(info->index & ~ANIMFLG_USESPOT, found_spot->sx, found_spot->sy);
+ playAnim(info->index & ~ANIMFLG_USESPOT, found_spot->sx, found_spot->sy);
} else {
/*at specified coords*/
- PlayAnim(info->index, info->params.coords.x, info->params.coords.y);
+ playAnim(info->index, info->params.coords.x, info->params.coords.y);
}
}
@@ -1337,7 +1337,7 @@ void BounceCurrentItem(byte flags, byte y) {
item->flags = flags;
item->area = script_byte_vars.zone_area;
BackupScreenOfSpecialRoom();
- PlayAnim(41, 176 / 4, y);
+ playAnim(41, 176 / 4, y);
DrawRoomItemsIndicator();
RestoreScreenOfSpecialRoom();
}
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 6cc98d54e72..af6abbc8101 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -1182,7 +1182,7 @@ uint16 SCR_20_HidePortraitDots(void) {
dot_effect_step = 17;
dot_effect_delay = 100;
- CopyScreenBlockWithDotEffect(backbuffer, x, y, width, height, frontbuffer);
+ copyScreenBlockWithDotEffect(backbuffer, x, y, width, height, frontbuffer);
return 0;
}
@@ -1407,7 +1407,7 @@ uint16 SCR_26_GameOver(void) {
CGA_BackBufferToRealFull();
CGA_ColorSelect(0x30);
AnimStarfield(InitStarfield(), frontbuffer);
- PlayAnim(44, 156 / 4, 95);
+ playAnim(44, 156 / 4, 95);
script_byte_vars.zone_index = 135;
/*reload background*/
@@ -1636,7 +1636,7 @@ uint16 SCR_38_PlayAnim(void) {
index = *script_ptr++;
x = *script_ptr++;
y = *script_ptr++;
- PlayAnim(index, x, y);
+ playAnim(index, x, y);
return 0;
}
@@ -2138,7 +2138,7 @@ uint16 SCR_31_Fight2(void) {
}
if (fightlist[i].anim.index == 55)
playSound(151);
- PlayAnim(fightlist[i].anim.index, fightlist[i].anim.params.coords.x, fightlist[i].anim.params.coords.y);
+ playAnim(fightlist[i].anim.index, fightlist[i].anim.params.coords.x, fightlist[i].anim.params.coords.y);
break;
}
}
@@ -2162,7 +2162,7 @@ void FightWin(void) {
&& fight_mode == 0) {
script_byte_vars.bvar_67 = 1;
playSound(149);
- PlayAnim(40, found_spot->sx, found_spot->sy);
+ playAnim(40, found_spot->sx, found_spot->sy);
}
}
@@ -2190,7 +2190,7 @@ void DrawDeathAnim(void) {
for (i = 0; i < 23; i++) {
if (fightlist3[i].room == script_byte_vars.zone_room) {
- PlayAnim(fightlist3[i].anim.index, fightlist3[i].anim.params.coords.x, fightlist3[i].anim.params.coords.y);
+ playAnim(fightlist3[i].anim.index, fightlist3[i].anim.params.coords.x, fightlist3[i].anim.params.coords.y);
break;
}
}
@@ -2510,7 +2510,7 @@ uint16 SCR_66_DeProfundisRideToExit(void) {
dot_effect_delay = 1;
dot_effect_step = 17;
- CopyScreenBlockWithDotEffect(backbuffer, 112 / 4, 139, 72 / 4, 40, frontbuffer);
+ copyScreenBlockWithDotEffect(backbuffer, 112 / 4, 139, 72 / 4, 40, frontbuffer);
return 0;
}
@@ -2680,7 +2680,7 @@ uint16 SCR_54_DotFadeRoom(void) {
dot_effect_delay = 1;
dot_effect_step = 17;
- CopyScreenBlockWithDotEffect(backbuffer, room_bounds_rect.sx, room_bounds_rect.sy, room_bounds_rect.ex - room_bounds_rect.sx, room_bounds_rect.ey - room_bounds_rect.sy, frontbuffer);
+ copyScreenBlockWithDotEffect(backbuffer, room_bounds_rect.sx, room_bounds_rect.sy, room_bounds_rect.ex - room_bounds_rect.sx, room_bounds_rect.ey - room_bounds_rect.sy, frontbuffer);
return 0;
}
@@ -3370,7 +3370,7 @@ int16 ConsumePsiEnergy(byte amount) {
if (current < amount) {
/*no energy left*/
- PlayAnim(68, 296 / 4, 71);
+ playAnim(68, 296 / 4, 71);
return 0;
}
@@ -3378,7 +3378,7 @@ int16 ConsumePsiEnergy(byte amount) {
/*significantly changed?*/
if ((current & 0xF0) != (script_byte_vars.psy_energy & 0xF0))
- PlayAnim(68, 296 / 4, 71);
+ playAnim(68, 296 / 4, 71);
return 1;
}
@@ -3490,7 +3490,7 @@ uint16 CMD_D_PsiBrainwarp(void) {
}
if (GetZoneObjCommand(1 * 2) != 0) {
- PlayAnim(39, found_spot->sx + 8 / 4, found_spot->sy - 10);
+ playAnim(39, found_spot->sx + 8 / 4, found_spot->sy - 10);
RestoreScreenOfSpecialRoom();
return ScriptRerun;
}
@@ -3507,7 +3507,7 @@ uint16 CMD_D_PsiBrainwarp(void) {
script_byte_vars.tries_left = 2;
the_command = 0;
if (script_byte_vars.bvar_43 == 0) {
- PlayAnim(39, found_spot->sx + 8 / 4, found_spot->sy - 10);
+ playAnim(39, found_spot->sx + 8 / 4, found_spot->sy - 10);
RestoreScreenOfSpecialRoom();
return ScriptRerun;
}
@@ -3549,7 +3549,7 @@ uint16 CMD_E_PsiZoneScan(void) {
if ((spot->flags & ~(SPOTFLG_40 | 7)) == (SPOTFLG_20 | SPOTFLG_8) && spot->sy == y) {
playSound(27);
spot->flags |= SPOTFLG_80;
- PlayAnim(38, spot->sx, spot->sy);
+ playAnim(38, spot->sx, spot->sy);
break;
}
}
@@ -3582,7 +3582,7 @@ uint16 CMD_F_PsiPsiShift(void) {
MenuLoop(0, 0);
BackupScreenOfSpecialRoom();
playSound(25);
- PlayAnim(39, cursor_x / 4, cursor_y);
+ playAnim(39, cursor_x / 4, cursor_y);
RestoreScreenOfSpecialRoom();
if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(3 * 2) == 0)
@@ -3991,7 +3991,7 @@ uint16 CMD_1B_Holo(void) {
x = found_spot->sx;
y = found_spot->sy;
- PlayAnim(42, x + 4 / 4, y + 6);
+ playAnim(42, x + 4 / 4, y + 6);
num = 321 + ((Swap16(script_word_vars.timer_ticks2) < 60 * 60) ? 0 : 4) + (script_byte_vars.rand_value % 4);
msg = SeekToString(diali_data, num);
@@ -4004,14 +4004,14 @@ uint16 CMD_1B_Holo(void) {
IFGM_PlaySfx(0);
- PlayAnim(43, x, y);
+ playAnim(43, x, y);
PromptWait();
PopDirtyRects(DirtyRectBubble);
IFGM_PlaySample(225);
- PlayAnim(45, x, y);
+ playAnim(45, x, y);
return 0;
}
Commit: ac3bd85de37277c2de7f2ed5322b6be99768e0f3
https://github.com/scummvm/scummvm/commit/ac3bd85de37277c2de7f2ed5322b6be99768e0f3
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Renames in cga.cpp
Changed paths:
engines/chamber/anim.cpp
engines/chamber/cga.cpp
engines/chamber/cga.h
engines/chamber/dialog.cpp
engines/chamber/input.cpp
engines/chamber/invent.cpp
engines/chamber/kult.cpp
engines/chamber/menu.cpp
engines/chamber/portrait.cpp
engines/chamber/print.cpp
engines/chamber/print.h
engines/chamber/room.cpp
engines/chamber/script.cpp
engines/chamber/timer.cpp
diff --git a/engines/chamber/anim.cpp b/engines/chamber/anim.cpp
index 5beb43a9aee..8220aa30056 100644
--- a/engines/chamber/anim.cpp
+++ b/engines/chamber/anim.cpp
@@ -116,7 +116,7 @@ void copyScreenBlockWithDotEffect(byte *source, byte x, byte y, byte width, byte
for (offs = 0; offs != cur_image_end;) {
byte mask = 0xC0 >> (((xx + offs % ww) % 4) * 2);
- uint16 ofs = CGA_CalcXY(xx + offs % ww, y + offs / ww);
+ uint16 ofs = cga_CalcXY(xx + offs % ww, y + offs / ww);
target[ofs] = (target[ofs] & ~mask) | (source[ofs] & mask);
@@ -134,9 +134,9 @@ void copyScreenBlockWithDotEffect(byte *source, byte x, byte y, byte width, byte
void animDrawSprite(byte x, byte y, byte sprw, byte sprh, byte *pixels, uint16 pitch) {
uint16 delay;
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);
+ 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;
ey = y + sprh;
if (last_anim_height != 0) {
@@ -154,19 +154,19 @@ void animDrawSprite(byte x, byte y, byte sprw, byte sprh, byte *pixels, uint16 p
}
updw = ex - updx;
updh = ey - updy;
- ofs = CGA_CalcXY_p(updx, updy);
+ ofs = cga_CalcXY_p(updx, updy);
/*TODO looks like here was some code before*/
for (delay = 0; delay < anim_draw_delay; delay++) {
g_system->delayMillis(1000 / 16 / 25);
}
- WaitVBlank();
+ waitVBlank();
if (anim_use_dot_effect)
copyScreenBlockWithDotEffect(backbuffer, updx, updy, updw, updh, frontbuffer);
else {
- CGA_CopyScreenBlock(backbuffer, updw, updh, frontbuffer, ofs);
+ cga_CopyScreenBlock(backbuffer, updw, updh, frontbuffer, ofs);
}
- CGA_RestoreImage(sprit_load_buffer, backbuffer);
+ cga_RestoreImage(sprit_load_buffer, backbuffer);
last_anim_x = x;
last_anim_y = y;
@@ -177,7 +177,7 @@ void animDrawSprite(byte x, byte y, byte sprw, byte sprh, byte *pixels, uint16 p
}
void animUndrawSprite(void) {
- CGA_CopyScreenBlock(backbuffer, last_anim_width, last_anim_height, CGA_SCREENBUFFER, CGA_CalcXY_p(last_anim_x, last_anim_y));
+ cga_CopyScreenBlock(backbuffer, last_anim_width, last_anim_height, CGA_SCREENBUFFER, cga_CalcXY_p(last_anim_x, last_anim_y));
last_anim_height = 0;
}
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 58d91fce12d..57acfbef458 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -138,23 +138,23 @@ static const uint8 PALETTE_CGA2[4 * 3] = {
/*
Switch to CGA 320x200x2bpp mode
*/
-void SwitchToGraphicsMode(void) {
+void switchToGraphicsMode(void) {
g_system->getPaletteManager()->setPalette(PALETTE_CGA, 0, 4);
}
/*
Switch to text mode
*/
-void SwitchToTextMode(void) {
- warning("STUB: SwitchToTextMode()");
+void switchToTextMode(void) {
+ warning("STUB: switchToTextMode()");
}
-void WaitVBlank(void) {
+void waitVBlank(void) {
PollInput();
g_system->delayMillis(10);
}
-void CGA_ColorSelect(byte csel) {
+void cga_ColorSelect(byte csel) {
const byte *pal;
if (csel & 0x10)
pal = PALETTE_CGA;
@@ -165,7 +165,7 @@ void CGA_ColorSelect(byte csel) {
g_system->setCursorPalette(pal, 0, 4);
}
-void CGA_blitToScreen(int16 dx, int16 dy, int16 w, int16 h) {
+void cga_blitToScreen(int16 dx, int16 dy, int16 w, int16 h) {
dx = dy = 0;
w = 320; h = 200;
// Align x by 4
@@ -183,7 +183,7 @@ void CGA_blitToScreen(int16 dx, int16 dy, int16 w, int16 h) {
w = (w + 3) / 4;
for (int16 y = 0; y < h; y++) {
- byte *src = CGA_SCREENBUFFER + CGA_CalcXY(dx, dy + y);
+ byte *src = CGA_SCREENBUFFER + cga_CalcXY(dx, dy + y);
byte *dst = scrbuffer + (y + dy) * 320 + dx;
for (int16 x = 0; x < w; x++) {
@@ -202,26 +202,26 @@ void CGA_blitToScreen(int16 dx, int16 dy, int16 w, int16 h) {
g_system->updateScreen();
}
-void CGA_blitToScreen(int16 ofs, int16 w, int16 h) {
+void cga_blitToScreen(int16 ofs, int16 w, int16 h) {
int16 dy = ofs / 80;
int16 dx = (ofs % 80) * 4;
- CGA_blitToScreen(dx, dy, w, h);
+ cga_blitToScreen(dx, dy, w, h);
}
-void CGA_BackBufferToRealFull(void) {
+void cga_BackBufferToRealFull(void) {
memcpy(CGA_SCREENBUFFER, backbuffer, sizeof(backbuffer));
- CGA_blitToScreen(0, 0, 320, 200);
+ cga_blitToScreen(0, 0, 320, 200);
}
-void CGA_RealBufferToBackFull(void) {
+void cga_RealBufferToBackFull(void) {
memcpy(backbuffer, CGA_SCREENBUFFER, sizeof(backbuffer));
}
/*Copy interlaced screen data to another screen*/
/*NB! w is in bytes*/
-void CGA_CopyScreenBlock(byte *source, uint16 w, uint16 h, byte *target, uint16 ofs) {
+void cga_CopyScreenBlock(byte *source, uint16 w, uint16 h, byte *target, uint16 ofs) {
uint16 oh = h;
uint16 oofs = ofs;
while (h--) {
@@ -232,16 +232,16 @@ void CGA_CopyScreenBlock(byte *source, uint16 w, uint16 h, byte *target, uint16
}
if (target == CGA_SCREENBUFFER)
- CGA_blitToScreen(oofs, w * 4, oh);
+ cga_blitToScreen(oofs, w * 4, oh);
}
/*
Flip screen and backbuffer
*/
-void CGA_SwapRealBackBuffer(void) {
+void cga_SwapRealBackBuffer(void) {
uint16 i;
uint16 *s, *d;
- WaitVBlank();
+ waitVBlank();
s = (uint16 *)CGA_SCREENBUFFER;
d = (uint16 *)backbuffer;
for (i = 0; i < sizeof(backbuffer) / 2; i++) {
@@ -250,14 +250,14 @@ void CGA_SwapRealBackBuffer(void) {
*d++ = t;
}
- CGA_blitToScreen(0, 0, 320, 200);
+ cga_blitToScreen(0, 0, 320, 200);
}
/*
Copy current screen's pixels to scratch mem, put new pixels to screen
*/
-void CGA_SwapScreenRect(byte *pixels, uint16 w, uint16 h, byte *screen, uint16 ofs) {
+void cga_SwapScreenRect(byte *pixels, uint16 w, uint16 h, byte *screen, uint16 ofs) {
byte *old = scratch_mem2;
uint16 oh = h;
uint16 oofs = ofs;
@@ -273,7 +273,7 @@ void CGA_SwapScreenRect(byte *pixels, uint16 w, uint16 h, byte *screen, uint16 o
}
if (screen == CGA_SCREENBUFFER)
- CGA_blitToScreen(oofs, w * 4, oh);
+ cga_blitToScreen(oofs, w * 4, oh);
}
/*
@@ -281,8 +281,8 @@ Calc screen offset from normal pixel coordinates
Out:
screen offset
*/
-uint16 CGA_CalcXY(uint16 x, uint16 y) {
- return CGA_CalcXY_p(x / 4, y);
+uint16 cga_CalcXY(uint16 x, uint16 y) {
+ return cga_CalcXY_p(x / 4, y);
}
/*
@@ -290,7 +290,7 @@ Calc screen offset from packed pixel coordinates
Out:
screen offset
*/
-uint16 CGA_CalcXY_p(uint16 x, uint16 y) {
+uint16 cga_CalcXY_p(uint16 x, uint16 y) {
uint16 ofs = 0;
if (y & 1)
ofs += CGA_ODD_LINES_OFS;
@@ -304,7 +304,7 @@ backup screen rect to a buffer
Out:
next buffer ptr
*/
-byte *CGA_BackupImage(byte *screen, uint16 ofs, uint16 w, uint16 h, byte *buffer) {
+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;
@@ -319,15 +319,15 @@ byte *CGA_BackupImage(byte *screen, uint16 ofs, uint16 w, uint16 h, byte *buffer
return buffer;
}
-byte *CGA_BackupImageReal(uint16 ofs, uint16 w, uint16 h) {
- return CGA_BackupImage(CGA_SCREENBUFFER, ofs, w, h, scratch_mem2);
+byte *cga_BackupImageReal(uint16 ofs, uint16 w, uint16 h) {
+ return cga_BackupImage(CGA_SCREENBUFFER, ofs, w, h, scratch_mem2);
}
/*
Blit progressive image to interlaced screen buffer
NB! width and pixelswidth specify a number of bytes, not count of pixels
*/
-void CGA_Blit(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs) {
+void cga_Blit(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs) {
byte *src = pixels;
uint16 oofs = ofs;
for (int16 y = 0; y < h; y++) {
@@ -339,19 +339,19 @@ void CGA_Blit(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16
}
if (screen == CGA_SCREENBUFFER)
- CGA_blitToScreen(oofs, w * 4, h);
+ cga_blitToScreen(oofs, w * 4, h);
}
/*
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(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs) {
- CGA_Blit(pixels, pw, w, h, screen, ofs);
- WaitVBlank();
+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(byte pixel, uint16 w, uint16 h, byte *screen, uint16 ofs) {
+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);
@@ -361,18 +361,18 @@ void CGA_Fill(byte pixel, uint16 w, uint16 h, byte *screen, uint16 ofs) {
}
if (screen == CGA_SCREENBUFFER)
- CGA_blitToScreen(oofs, w * 4, h);
+ cga_blitToScreen(oofs, w * 4, h);
}
-void CGA_FillAndWait(byte pixel, uint16 w, uint16 h, byte *screen, uint16 ofs) {
- CGA_Fill(pixel, w, h, screen, ofs);
- WaitVBlank();
+void cga_FillAndWait(byte pixel, uint16 w, uint16 h, byte *screen, uint16 ofs) {
+ cga_Fill(pixel, w, h, screen, ofs);
+ waitVBlank();
}
/*
Restore saved image to target screen buffer
*/
-void CGA_RestoreImage(byte *buffer, byte *target) {
+void cga_RestoreImage(byte *buffer, byte *target) {
uint16 w, h;
uint16 ofs;
@@ -384,20 +384,20 @@ void CGA_RestoreImage(byte *buffer, byte *target) {
ofs = *(uint16 *)(buffer + 2);
buffer += 4; /*TODO: fix me for large int*/
- CGA_Blit(buffer, w, w, h, target, ofs);
+ cga_Blit(buffer, w, w, h, target, ofs);
}
/*
Restore saved image from scratch mem to target screen buffer
*/
-void CGA_RestoreBackupImage(byte *target) {
- CGA_RestoreImage(scratch_mem2, target);
+void cga_RestoreBackupImage(byte *target) {
+ cga_RestoreImage(scratch_mem2, target);
}
/*
Copy image's real screen data to backbuffer
*/
-void CGA_RefreshImageData(byte *buffer) {
+void cga_RefreshImageData(byte *buffer) {
uint16 w, h;
uint16 ofs;
@@ -408,14 +408,14 @@ void CGA_RefreshImageData(byte *buffer) {
w = *(byte *)(buffer + 1);
ofs = *(uint16 *)(buffer + 2);
- CGA_CopyScreenBlock(CGA_SCREENBUFFER, w, h, backbuffer, ofs);
+ cga_CopyScreenBlock(CGA_SCREENBUFFER, w, h, backbuffer, ofs);
}
/*
Draw a vertical line with origin x:y and length l, using color
NB! Line must not wrap around the edge
*/
-void CGA_DrawVLine(uint16 x, uint16 y, uint16 l, byte color, byte *target) {
+void cga_DrawVLine(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));
@@ -424,7 +424,7 @@ void CGA_DrawVLine(uint16 x, uint16 y, uint16 l, byte color, byte *target) {
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);
+ ofs = cga_CalcXY_p(x / CGA_PIXELS_PER_BYTE, y);
uint16 ol = l;
while (l--) {
@@ -435,14 +435,14 @@ void CGA_DrawVLine(uint16 x, uint16 y, uint16 l, byte color, byte *target) {
}
if (target == CGA_SCREENBUFFER)
- CGA_blitToScreen(x, y, 1, ol);
+ cga_blitToScreen(x, y, 1, ol);
}
/*
Draw a horizontal line with origin x:y and length l, using color
NB! Line must not wrap around the edge
*/
-void CGA_DrawHLine(uint16 x, uint16 y, uint16 l, byte color, byte *target) {
+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));
@@ -451,7 +451,7 @@ void CGA_DrawHLine(uint16 x, uint16 y, uint16 l, byte color, byte *target) {
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);
+ ofs = cga_CalcXY_p(x / CGA_PIXELS_PER_BYTE, y);
uint16 ol = l;
while (l--) {
target[ofs] = (target[ofs] & mask) | pixel;
@@ -464,7 +464,7 @@ void CGA_DrawHLine(uint16 x, uint16 y, uint16 l, byte color, byte *target) {
}
}
if (target == CGA_SCREENBUFFER)
- CGA_blitToScreen(x, y, ol, 1);
+ cga_blitToScreen(x, y, ol, 1);
}
/*
@@ -472,7 +472,7 @@ 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
*/
-uint16 CGA_DrawHLineWithEnds(uint16 bmask, uint16 bpix, byte color, uint16 l, byte *target, uint16 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);
@@ -482,7 +482,7 @@ uint16 CGA_DrawHLineWithEnds(uint16 bmask, uint16 bpix, byte color, uint16 l, by
ofs += CGA_BYTES_PER_LINE;
if (target == CGA_SCREENBUFFER)
- CGA_blitToScreen(oofs, l * 4 + 2, 1);
+ cga_blitToScreen(oofs, l * 4 + 2, 1);
return ofs;
}
@@ -490,10 +490,10 @@ uint16 CGA_DrawHLineWithEnds(uint16 bmask, uint16 bpix, byte color, uint16 l, by
/*
Print a character at current cursor pos, then advance
*/
-void CGA_PrintChar(byte c, byte *target) {
+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);
+ 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];
@@ -504,7 +504,7 @@ void CGA_PrintChar(byte c, byte *target) {
}
if (target == CGA_SCREENBUFFER)
- CGA_blitToScreen((char_draw_coords_x - 1) * 4, char_draw_coords_y, 4, CGA_FONT_HEIGHT);
+ cga_blitToScreen((char_draw_coords_x - 1) * 4, char_draw_coords_y, 4, CGA_FONT_HEIGHT);
}
@@ -513,7 +513,7 @@ 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(uint16 sprofs, uint16 w, uint16 h, byte *screen, uint16 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;
@@ -528,18 +528,18 @@ void CGA_BlitScratchBackSprite(uint16 sprofs, uint16 w, uint16 h, byte *screen,
}
if (screen == CGA_SCREENBUFFER)
- CGA_blitToScreen(oofs, w * 4, oh);
+ cga_blitToScreen(oofs, w * 4, oh);
}
-void CGA_BlitFromBackBuffer(byte w, byte h, byte *screen, uint16 ofs) {
- CGA_CopyScreenBlock(backbuffer, w, h, screen, ofs);
+void cga_BlitFromBackBuffer(byte w, byte h, byte *screen, uint16 ofs) {
+ cga_CopyScreenBlock(backbuffer, w, h, screen, ofs);
}
/*
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(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs) {
+void cga_BlitSprite(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs) {
byte x;
uint16 oh = h;
uint16 oofs = ofs;
@@ -553,14 +553,14 @@ void CGA_BlitSprite(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, ui
}
if (screen == CGA_SCREENBUFFER)
- CGA_blitToScreen(oofs, w * 4, oh);
+ cga_blitToScreen(oofs, w * 4, oh);
}
/*
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(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) {
byte x;
uint16 oh = h;
uint16 oofs = ofs;
@@ -574,7 +574,7 @@ void CGA_BlitSpriteFlip(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen
}
if (screen == CGA_SCREENBUFFER)
- CGA_blitToScreen(oofs, w * 4, oh);
+ cga_blitToScreen(oofs, w * 4, oh);
}
/*
@@ -585,7 +585,7 @@ 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(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs, byte *backup, byte mask) {
+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;
@@ -601,7 +601,7 @@ void CGA_BlitSpriteBak(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen,
}
if (screen == CGA_SCREENBUFFER)
- CGA_blitToScreen(oofs, w * 4, oh);
+ cga_blitToScreen(oofs, w * 4, oh);
}
@@ -612,7 +612,7 @@ void DrawSprite(byte *sprite, byte *screen, uint16 ofs) {
byte w, h;
w = *sprite++;
h = *sprite++;
- CGA_BlitSprite(sprite, w * 2, w, h, screen, ofs);
+ cga_BlitSprite(sprite, w * 2, w, h, screen, ofs);
}
/*
@@ -622,7 +622,7 @@ void DrawSpriteFlip(byte *sprite, byte *screen, uint16 ofs) {
byte w, h;
w = *sprite++;
h = *sprite++;
- CGA_BlitSpriteFlip(sprite, w * 2, w, h, screen, ofs);
+ cga_BlitSpriteFlip(sprite, w * 2, w, h, screen, ofs);
}
/*
@@ -735,7 +735,7 @@ void DrawSpriteN(byte index, uint16 x, uint16 y, byte *target) {
uint16 ofs;
byte *sprite;
sprite = LoadSprit(index);
- ofs = CGA_CalcXY_p(x, y);
+ ofs = cga_CalcXY_p(x, y);
DrawSprite(sprite, target, ofs);
}
@@ -743,7 +743,7 @@ void DrawSpriteNFlip(byte index, uint16 x, uint16 y, byte *target) {
uint16 ofs;
byte *sprite;
sprite = LoadSprit(index);
- ofs = CGA_CalcXY_p(x, y);
+ ofs = cga_CalcXY_p(x, y);
DrawSpriteFlip(sprite, target, ofs);
}
@@ -751,10 +751,10 @@ void BackupAndShowSprite(byte index, byte x, byte y) {
byte w, h;
uint16 ofs;
byte *sprite = LoadSprit(index);
- ofs = CGA_CalcXY_p(x, y);
+ ofs = cga_CalcXY_p(x, y);
w = sprite[0];
h = sprite[1];
- CGA_BackupImageReal(ofs, w, h);
+ cga_BackupImageReal(ofs, w, h);
DrawSprite(sprite, CGA_SCREENBUFFER, ofs); /*DrawSpriteN(index, x, y, CGA_SCREENBUFFER);*/
}
@@ -763,11 +763,11 @@ 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(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs) {
+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);
+ cga_BlitAndWait(pixels, pw, w, i, screen, ofs);
pixels -= pw;
}
}
@@ -778,10 +778,10 @@ 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(uint16 n, 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) {
uint16 i;
for (i = 0; i < n; i++) {
- CGA_BlitAndWait(pixels, pw, w + i, h, screen, ofs);
+ cga_BlitAndWait(pixels, pw, w + i, h, screen, ofs);
ofs -= 1;
}
}
@@ -791,10 +791,10 @@ 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(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) {
uint16 i;
for (i = 0; i < n; i++) {
- CGA_BlitAndWait(pixels, pw, w + i, h, screen, ofs);
+ cga_BlitAndWait(pixels, pw, w + i, h, screen, ofs);
pixels -= 1;
}
}
@@ -805,10 +805,10 @@ 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(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen, uint16 x, uint16 y) {
+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));
+ cga_BlitAndWait(pixels, pw, w, i, screen, cga_CalcXY_p(x, y));
y -= 1;
}
}
@@ -817,7 +817,7 @@ void CGA_AnimLiftToUp(byte *pixels, uint16 pw, uint16 w, uint16 h, byte *screen,
/*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(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) {
while (n--) {
int16 i;
uint16 sofs, tofs;
@@ -847,10 +847,10 @@ void CGA_HideScreenBlockLiftToDown(uint16 n, byte *screen, byte *source, uint16
memcpy(target + tofs, source + tofs, w);
if (screen == CGA_SCREENBUFFER) {
- CGA_blitToScreen(0, 0, 320, 200);
+ cga_blitToScreen(0, 0, 320, 200);
}
- WaitVBlank();
+ waitVBlank();
ofs ^= CGA_ODD_LINES_OFS;
if ((ofs & CGA_ODD_LINES_OFS) == 0)
@@ -862,7 +862,7 @@ void CGA_HideScreenBlockLiftToDown(uint16 n, byte *screen, byte *source, uint16
/*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(uint16 n, byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs) {
+void cga_HideScreenBlockLiftToUp(uint16 n, byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs) {
while (n--) {
int16 i;
uint16 sofs, tofs;
@@ -892,10 +892,10 @@ void CGA_HideScreenBlockLiftToUp(uint16 n, byte *screen, byte *source, uint16 w,
memcpy(target + tofs, source + tofs, w);
if (screen == CGA_SCREENBUFFER) {
- CGA_blitToScreen(0, 0, 320, 200);
+ cga_blitToScreen(0, 0, 320, 200);
}
- WaitVBlank();
+ waitVBlank();
ofs ^= CGA_ODD_LINES_OFS;
if ((ofs & CGA_ODD_LINES_OFS) != 0)
@@ -907,7 +907,7 @@ void CGA_HideScreenBlockLiftToUp(uint16 n, byte *screen, byte *source, uint16 w,
/*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(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) {
while (n--) {
int16 i;
uint16 sofs, tofs;
@@ -931,10 +931,10 @@ void CGA_HideScreenBlockLiftToLeft(uint16 n, byte *screen, byte *source, uint16
}
if (screen == CGA_SCREENBUFFER) {
- CGA_blitToScreen(0, 0, 320, 200);
+ cga_blitToScreen(0, 0, 320, 200);
}
- WaitVBlank();
+ waitVBlank();
ofs--;
}
@@ -944,7 +944,7 @@ void CGA_HideScreenBlockLiftToLeft(uint16 n, byte *screen, byte *source, uint16
/*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(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) {
while (n--) {
int16 i;
uint16 sofs, tofs;
@@ -968,10 +968,10 @@ void CGA_HideScreenBlockLiftToRight(uint16 n, byte *screen, byte *source, uint16
}
if (screen == CGA_SCREENBUFFER) {
- CGA_blitToScreen(0, 0, 320, 200);
+ cga_blitToScreen(0, 0, 320, 200);
}
- WaitVBlank();
+ waitVBlank();
ofs++;
}
@@ -1111,21 +1111,21 @@ static void FallPieces(scrpiece_t *pieces, byte *source, byte *target) {
}
if (target == CGA_SCREENBUFFER) {
- CGA_blitToScreen(0, 0, 320, 200);
+ cga_blitToScreen(0, 0, 320, 200);
}
- WaitVBlank();
+ waitVBlank();
t++;
} while (again);
}
-void CGA_HideShatterFall(byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 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(uint16 sx, uint16 ex, uint16 sy, uint16 ey, byte *source, byte *target) {
+void cga_TraceLine(uint16 sx, uint16 ex, uint16 sy, uint16 ey, byte *source, byte *target) {
byte b0 = 0;
byte b1 = 0;
byte mask;
@@ -1150,7 +1150,7 @@ void CGA_TraceLine(uint16 sx, uint16 ex, uint16 sy, uint16 ey, byte *source, byt
}
dy = h * 2;
- ofs = CGA_CalcXY_p(sx / 4, sy);
+ ofs = cga_CalcXY_p(sx / 4, sy);
mask = 0xC0 >> ((sx % 4) * 2);
val = dy + dx;
@@ -1193,7 +1193,7 @@ void CGA_TraceLine(uint16 sx, uint16 ex, uint16 sy, uint16 ey, byte *source, byt
}
if (target == CGA_SCREENBUFFER)
- CGA_blitToScreen(0, 0, 320, 200);
+ cga_blitToScreen(0, 0, 320, 200);
}
/*TODO: get rid of this structure and pass everything relevant as arguments?*/
@@ -1232,7 +1232,7 @@ static uint16 FPDiv(uint16 a, byte b) {
Draw scaled image
NB! tw/th specify target width/height in pixels
*/
-static void CGA_Zoom(zoom_t *params, byte tw, byte th, byte *source, byte *target, uint16 ofs) {
+static void cga_Zoom(zoom_t *params, byte tw, byte th, byte *source, byte *target, uint16 ofs) {
byte x, y;
uint16 finofs = ofs;
byte *temp = scratch_mem2;
@@ -1300,7 +1300,7 @@ static void CGA_Zoom(zoom_t *params, byte tw, byte th, byte *source, byte *targe
params->yval_l = params->eh;
}
- CGA_BlitAndWait(scratch_mem2, params->fw, params->fw, th + 2, target, finofs);
+ cga_BlitAndWait(scratch_mem2, params->fw, params->fw, th + 2, target, finofs);
}
/*
@@ -1308,7 +1308,7 @@ Draw scaled image
NB! tw/th specify target width/height in pixels
This is slightly simplified version, but should work identical to the code above
*/
-static void CGA_ZoomOpt(zoom_t *params, byte tw, byte th, byte *source, byte *target, uint16 ofs) {
+static void cga_ZoomOpt(zoom_t *params, byte tw, byte th, byte *source, byte *target, uint16 ofs) {
byte x, y;
uint16 finofs = ofs;
byte *temp = scratch_mem2;
@@ -1367,7 +1367,7 @@ static void CGA_ZoomOpt(zoom_t *params, byte tw, byte th, byte *source, byte *ta
yval = params->eh << 8;
}
- CGA_BlitAndWait(scratch_mem2, params->fw, params->fw, th + 2, target, finofs);
+ cga_BlitAndWait(scratch_mem2, params->fw, params->fw, th + 2, target, finofs);
}
/*
@@ -1375,7 +1375,7 @@ Draw image zoomed from w:h to nw:nx to target at specified ofs
Use backbuffer pixels to fill sides
NB! w/nw are the number of bytes, not pixels
*/
-void CGA_ZoomImage(byte *pixels, byte w, byte h, byte nw, byte nh, byte *target, uint16 ofs) {
+void cga_ZoomImage(byte *pixels, byte w, byte h, byte nw, byte nh, byte *target, uint16 ofs) {
zoom_t zoom;
zoom.pixels = pixels;
@@ -1391,9 +1391,9 @@ void CGA_ZoomImage(byte *pixels, byte w, byte h, byte nw, byte nh, byte *target,
/*TODO: why this nw/nh order? maybe bug*/
#if 0
- CGA_Zoom(&zoom, nh - 2, nw * 4 - 2, backbuffer, target, ofs);
+ cga_Zoom(&zoom, nh - 2, nw * 4 - 2, backbuffer, target, ofs);
#else
- CGA_ZoomOpt(&zoom, nh - 2, nw * 4 - 2, backbuffer, target, ofs);
+ cga_ZoomOpt(&zoom, nh - 2, nw * 4 - 2, backbuffer, target, ofs);
#endif
}
@@ -1403,7 +1403,7 @@ Use backbuffer pixels to fill sides
Ofs specifies zoom origin
NB! w is the number of bytes, not pixels
*/
-void CGA_AnimZoomOpt(zoom_t *zoom, uint16 w, uint16 h, byte steps, byte *target, uint16 ofs) {
+void cga_AnimZoomOpt(zoom_t *zoom, uint16 w, uint16 h, byte steps, byte *target, uint16 ofs) {
uint16 xstep = FPDiv(w, steps); /*fixed-point 8.8 value*/
uint16 ystep = FPDiv(h, steps); /*fixed-point 8.8 value*/
@@ -1413,7 +1413,7 @@ void CGA_AnimZoomOpt(zoom_t *zoom, uint16 w, uint16 h, byte steps, byte *target,
for (steps = steps / 2 - 2; steps; steps--) {
uint16 prev;
- CGA_ZoomOpt(zoom, xval >> 8, yval >> 8, backbuffer, target, ofs);
+ cga_ZoomOpt(zoom, xval >> 8, yval >> 8, backbuffer, target, ofs);
prev = yval;
yval += ystep;
@@ -1441,7 +1441,7 @@ Use backbuffer pixels to fill sides
NB! w is the number of bytes, not pixels
NB! ofs is the final image top left corner, not the zoom origin
*/
-void CGA_AnimZoomIn(byte *pixels, byte w, byte h, byte *target, uint16 ofs) {
+void cga_AnimZoomIn(byte *pixels, byte w, byte h, byte *target, uint16 ofs) {
uint16 finofs = ofs;
byte x, y, maxside;
@@ -1468,16 +1468,16 @@ void CGA_AnimZoomIn(byte *pixels, byte w, byte h, byte *target, uint16 ofs) {
if (maxside < h)
maxside = h;
- CGA_AnimZoomOpt(&zoom, w * 4 * 2, h * 2, maxside, target, ofs);
+ cga_AnimZoomOpt(&zoom, w * 4 * 2, h * 2, maxside, target, ofs);
- CGA_BlitAndWait(pixels, w, w, h, target, finofs);
+ cga_BlitAndWait(pixels, w, w, h, target, finofs);
}
/*
Draw scaled image
NB! tw/th specify target width/height in pixels
*/
-void CGA_ZoomInplace(zoom_t *params, byte tw, byte th, byte *source, byte *target, uint16 ofs) {
+void cga_ZoomInplace(zoom_t *params, byte tw, byte th, byte *source, byte *target, uint16 ofs) {
byte x, y;
/*calc old/new ratio*/
@@ -1544,7 +1544,7 @@ void CGA_ZoomInplace(zoom_t *params, byte tw, byte th, byte *source, byte *targe
}
}
-void CGA_ZoomInplaceXY(byte *pixels, byte w, byte h, byte nw, byte nh, uint16 x, uint16 y, byte *target) {
+void cga_ZoomInplaceXY(byte *pixels, byte w, byte h, byte nw, byte nh, uint16 x, uint16 y, byte *target) {
zoom_t zoom;
zoom.pixels = pixels;
@@ -1554,7 +1554,7 @@ void CGA_ZoomInplaceXY(byte *pixels, byte w, byte h, byte nw, byte nh, uint16 x,
zoom.eh = h - 1;
zoom.xbase = x % 4;
- CGA_ZoomInplace(&zoom, nw, nh, target, target, CGA_CalcXY(x, y));
+ cga_ZoomInplace(&zoom, nw, nh, target, target, cga_CalcXY(x, y));
}
} // End of namespace Chamber
diff --git a/engines/chamber/cga.h b/engines/chamber/cga.h
index e867f6d6849..bf9a3a09576 100644
--- a/engines/chamber/cga.h
+++ b/engines/chamber/cga.h
@@ -20,8 +20,8 @@
*
*/
-#ifndef CHAMBER_CGA_H
-#define CHAMBER_CGA_H
+#ifndef CHAMBER_cga_H
+#define CHAMBER_cga_H
namespace Chamber {
@@ -54,49 +54,49 @@ extern byte string_ended;
extern byte char_draw_max_width;
extern byte char_draw_max_height;
-void SwitchToGraphicsMode(void);
-void SwitchToTextMode(void);
+void switchToGraphicsMode(void);
+void switchToTextMode(void);
-void WaitVBlank(void);
-void CGA_blitToScreen(int16 dx, int16 dy, int16 w, int16 h);
-void CGA_blitToScreen(int16 ofs, int16 w, int16 h);
+void waitVBlank(void);
+void cga_blitToScreen(int16 dx, int16 dy, int16 w, int16 h);
+void cga_blitToScreen(int16 ofs, int16 w, int16 h);
-void CGA_ColorSelect(byte csel);
-void CGA_BackBufferToRealFull(void);
-void CGA_RealBufferToBackFull(void);
-void CGA_SwapRealBackBuffer(void);
+void cga_ColorSelect(byte csel);
+void cga_BackBufferToRealFull(void);
+void cga_RealBufferToBackFull(void);
+void cga_SwapRealBackBuffer(void);
-void CGA_SwapScreenRect(byte *pixels, uint16 w, uint16 h, byte *screen, uint16 ofs);
+void cga_SwapScreenRect(byte *pixels, uint16 w, uint16 h, byte *screen, uint16 ofs);
-uint16 CGA_CalcXY(uint16 x, uint16 y);
-uint16 CGA_CalcXY_p(uint16 x, uint16 y);
+uint16 cga_CalcXY(uint16 x, uint16 y);
+uint16 cga_CalcXY_p(uint16 x, uint16 y);
-void CGA_CopyScreenBlock(byte *source, uint16 w, uint16 h, byte *target, uint16 ofs);
+void cga_CopyScreenBlock(byte *source, uint16 w, uint16 h, byte *target, uint16 ofs);
-byte *CGA_BackupImage(byte *source, uint16 ofs, uint16 w, uint16 h, byte *buffer);
-byte *CGA_BackupImageReal(uint16 ofs, uint16 w, uint16 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(byte *buffer, byte *target);
-void CGA_RefreshImageData(byte *buffer);
-void CGA_RestoreBackupImage(byte *target);
+void cga_RestoreImage(byte *buffer, byte *target);
+void cga_RefreshImageData(byte *buffer);
+void cga_RestoreBackupImage(byte *target);
-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_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(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_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(byte c, byte *target);
+void cga_PrintChar(byte c, byte *target);
-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_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(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_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(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs, byte *backup, byte mask);
+void cga_BlitSpriteBak(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs, byte *backup, byte mask);
void DrawSprite(byte *sprite, byte *screen, uint16 ofs);
void DrawSpriteFlip(byte *sprite, byte *screen, uint16 ofs);
@@ -111,24 +111,24 @@ byte *LoadSprite(byte index, byte *bank, byte *buffer, byte header_only);
byte *LoadSprit(byte index);
byte *LoadPersSprit(byte index);
-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_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(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_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(byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs);
+void cga_HideShatterFall(byte *screen, byte *source, uint16 w, uint16 h, byte *target, uint16 ofs);
-void CGA_TraceLine(uint16 sx, uint16 ex, uint16 sy, uint16 ey, byte *source, byte *target);
+void cga_TraceLine(uint16 sx, uint16 ex, uint16 sy, uint16 ey, byte *source, byte *target);
-void CGA_ZoomImage(byte *pixels, byte w, byte h, byte nw, byte nh, byte *target, uint16 ofs);
-void CGA_AnimZoomIn(byte *pixels, byte w, byte h, byte *target, uint16 ofs);
+void cga_ZoomImage(byte *pixels, byte w, byte h, byte nw, byte nh, byte *target, uint16 ofs);
+void cga_AnimZoomIn(byte *pixels, byte w, byte h, byte *target, uint16 ofs);
-void CGA_ZoomInplaceXY(byte *pixels, byte w, byte h, byte nw, byte nh, uint16 x, uint16 y, byte *target);
+void cga_ZoomInplaceXY(byte *pixels, byte w, byte h, byte nw, byte nh, uint16 x, uint16 y, byte *target);
} // End of namespace Chamber
diff --git a/engines/chamber/dialog.cpp b/engines/chamber/dialog.cpp
index ad2eaefa25a..c2a6e748c78 100644
--- a/engines/chamber/dialog.cpp
+++ b/engines/chamber/dialog.cpp
@@ -92,10 +92,10 @@ void PopDirtyRects(byte kind) {
byte width, height;
uint16 offs;
while (FindDirtyRectAndFree(kind, &x, &y, &width, &height, &offs)) {
- CGA_CopyScreenBlock(backbuffer, width, height, frontbuffer, offs);
+ cga_CopyScreenBlock(backbuffer, width, height, frontbuffer, offs);
if (kind == DirtyRectBubble) {
/*pop bubble's spike*/
- CGA_CopyScreenBlock(backbuffer, 2, 21, frontbuffer, offs = (x << 8) | y);
+ cga_CopyScreenBlock(backbuffer, 2, 21, frontbuffer, offs = (x << 8) | y);
}
}
}
@@ -104,8 +104,8 @@ void DesciTextBox(uint16 x, uint16 y, uint16 width, byte *msg) {
draw_x = x;
draw_y = y;
char_draw_max_width = width;
- CGA_DrawTextBox(msg, frontbuffer);
- AddDirtyRect(DirtyRectText, draw_x, draw_y, char_draw_max_width + 2, char_draw_coords_y - draw_y + 8, CGA_CalcXY_p(draw_x, draw_y));
+ cga_DrawTextBox(msg, frontbuffer);
+ AddDirtyRect(DirtyRectText, draw_x, draw_y, char_draw_max_width + 2, char_draw_coords_y - draw_y + 8, cga_CalcXY_p(draw_x, draw_y));
}
/*Draw dialog bubble with text and spike*/
@@ -124,26 +124,26 @@ void DrawPersonBubble(byte x, byte y, byte flags, byte *msg) {
}
/*upper border*/
- ofs = CGA_CalcXY_p(x, y);
- ofs = CGA_DrawHLineWithEnds(0xF00F, 0, 0, char_draw_max_width, CGA_SCREENBUFFER, ofs);
- ofs = CGA_DrawHLineWithEnds(0xC003, 0x0FF0, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
- ofs = CGA_DrawHLineWithEnds(0, 0x3FFC, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
- ofs = CGA_DrawHLineWithEnds(0, 0x3FFC, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
+ ofs = cga_CalcXY_p(x, y);
+ ofs = cga_DrawHLineWithEnds(0xF00F, 0, 0, char_draw_max_width, CGA_SCREENBUFFER, ofs);
+ ofs = cga_DrawHLineWithEnds(0xC003, 0x0FF0, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
+ ofs = cga_DrawHLineWithEnds(0, 0x3FFC, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
+ ofs = cga_DrawHLineWithEnds(0, 0x3FFC, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
/*body*/
char_draw_coords_x = x;
char_draw_coords_y = y + 4;
for (string_ended = 0; !string_ended; char_draw_coords_y += 6) {
- CGA_PrintChar(0x3B, CGA_SCREENBUFFER);
+ cga_PrintChar(0x3B, CGA_SCREENBUFFER);
msg = PrintStringPadded(msg, CGA_SCREENBUFFER);
- CGA_PrintChar(0x3C, CGA_SCREENBUFFER);
+ cga_PrintChar(0x3C, CGA_SCREENBUFFER);
char_draw_coords_x = x;
}
- ofs = CGA_CalcXY_p(x, char_draw_coords_y);
- ofs = CGA_DrawHLineWithEnds(0xC003, 0x0FF0, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
- ofs = CGA_DrawHLineWithEnds(0xF00F, 0, 0, char_draw_max_width, CGA_SCREENBUFFER, ofs);
+ ofs = cga_CalcXY_p(x, char_draw_coords_y);
+ ofs = cga_DrawHLineWithEnds(0xC003, 0x0FF0, 0xFF, char_draw_max_width, CGA_SCREENBUFFER, ofs);
+ ofs = cga_DrawHLineWithEnds(0xF00F, 0, 0, char_draw_max_width, CGA_SCREENBUFFER, ofs);
w = char_draw_max_width + 2;
h = char_draw_coords_y - y + 2;
@@ -151,38 +151,38 @@ void DrawPersonBubble(byte x, byte y, byte flags, byte *msg) {
/*draw spike*/
switch (flags & SPIKE_MASK) {
case SPIKE_UPLEFT: /*upper-left spike*/
- ofs = CGA_CalcXY_p(x + 1, y - 7);
+ ofs = cga_CalcXY_p(x + 1, y - 7);
DrawSpriteN(18, x + 1, y - 7, CGA_SCREENBUFFER);
break;
case SPIKE_UPRIGHT: /*upper-right spike*/
- ofs = CGA_CalcXY_p(x + char_draw_max_width, y - 7) - 1;
+ ofs = cga_CalcXY_p(x + char_draw_max_width, y - 7) - 1;
DrawSpriteNFlip(18, x + char_draw_max_width, y - 7, CGA_SCREENBUFFER);
break;
case SPIKE_DNRIGHT: /*lower-right spike*/
- ofs = CGA_CalcXY_p(x + char_draw_max_width, char_draw_coords_y + 1) - 1;
+ ofs = cga_CalcXY_p(x + char_draw_max_width, char_draw_coords_y + 1) - 1;
DrawSpriteNFlip(21, x + char_draw_max_width, char_draw_coords_y + 1, CGA_SCREENBUFFER);
break;
case SPIKE_DNLEFT: /*lower-left spike*/
- ofs = CGA_CalcXY_p(x + 1, char_draw_coords_y + 1);
+ ofs = cga_CalcXY_p(x + 1, char_draw_coords_y + 1);
DrawSpriteN(21, x + 1, char_draw_coords_y + 1, CGA_SCREENBUFFER);
break;
case SPIKE_BUBRIGHT: /*lower-right bubbles*/
- ofs = CGA_CalcXY_p(x + char_draw_max_width, char_draw_coords_y + 4);
+ ofs = cga_CalcXY_p(x + char_draw_max_width, char_draw_coords_y + 4);
DrawSpriteN(20, x + char_draw_max_width, char_draw_coords_y + 4, CGA_SCREENBUFFER);
break;
case SPIKE_BUBLEFT: /*lower-left bubbles*/
- ofs = CGA_CalcXY_p(x + 1, char_draw_coords_y + 4);
+ ofs = cga_CalcXY_p(x + 1, char_draw_coords_y + 4);
DrawSpriteN(19, x + 1, char_draw_coords_y + 4, CGA_SCREENBUFFER);
break;
}
- AddDirtyRect(DirtyRectBubble, ofs >> 8, ofs & 255, w, h, CGA_CalcXY_p(x, y));
+ AddDirtyRect(DirtyRectBubble, ofs >> 8, ofs & 255, w, h, cga_CalcXY_p(x, y));
}
void ShowPromptAnim(void) {
if (script_byte_vars.zone_index == 135)
return;
- WaitVBlank();
+ waitVBlank();
DrawSpriteN(cursor_anim_phase ? 23 : 22, 300 / 4, 155, frontbuffer);
cursor_anim_phase = ~cursor_anim_phase;
}
diff --git a/engines/chamber/input.cpp b/engines/chamber/input.cpp
index 1c4eec27e4c..bfceb75714a 100644
--- a/engines/chamber/input.cpp
+++ b/engines/chamber/input.cpp
@@ -153,7 +153,7 @@ int16 AskQuitGame(void) {
char_draw_max_width = 32;
draw_x = 1;
draw_y = 188;
- CGA_DrawTextBox(msg, frontbuffer);
+ cga_DrawTextBox(msg, frontbuffer);
Common::Event event;
@@ -176,7 +176,7 @@ int16 AskQuitGame(void) {
}
}
}
- CGA_CopyScreenBlock(backbuffer, char_draw_max_width + 2, char_draw_coords_y - draw_y + 8, frontbuffer, CGA_CalcXY_p(draw_x, draw_y));
+ cga_CopyScreenBlock(backbuffer, char_draw_max_width + 2, char_draw_coords_y - draw_y + 8, frontbuffer, cga_CalcXY_p(draw_x, draw_y));
return quit;
}
diff --git a/engines/chamber/invent.cpp b/engines/chamber/invent.cpp
index b1a47776329..016c7049a70 100644
--- a/engines/chamber/invent.cpp
+++ b/engines/chamber/invent.cpp
@@ -80,7 +80,7 @@ void DrawInventoryBox(uint16 filtermask, uint16 filtervalue) {
continue;
if (count == 0) {
/*once first valid item found, draw the box*/
- CGA_FillAndWait(inv_bgcolor, 64 / 4, 64, CGA_SCREENBUFFER, CGA_CalcXY_p(232 / 4, 56));
+ cga_FillAndWait(inv_bgcolor, 64 / 4, 64, CGA_SCREENBUFFER, cga_CalcXY_p(232 / 4, 56));
playSound(20);
}
inventory_spots[count].name = inventory_items[i].name;
@@ -112,7 +112,7 @@ void CheckInventoryItemHover(byte count) {
void OpenInventory(uint16 filtermask, uint16 filtervalue) {
the_command = 0;
- CGA_BackupImageReal(CGA_CalcXY_p(232 / 4, 56), 64 / 4, 64);
+ cga_BackupImageReal(cga_CalcXY_p(232 / 4, 56), 64 / 4, 64);
DrawInventoryBox(filtermask, filtervalue);
if (inv_count != 0) {
SelectCursor(CURSOR_FINGER);
@@ -126,7 +126,7 @@ void OpenInventory(uint16 filtermask, uint16 filtervalue) {
} while (buttons == 0);
UndrawCursor(frontbuffer);
}
- CGA_RestoreImage(scratch_mem2, frontbuffer);
+ cga_RestoreImage(scratch_mem2, frontbuffer);
playSound(20);
switch (((item_t *)script_vars[ScrPool3_CurrentItem])->name) {
case 108: /*DAGGER*/
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index a89d0d55970..8efbc25182f 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -191,7 +191,7 @@ process:
void ExitGame(void) {
- SwitchToTextMode();
+ switchToTextMode();
uninitTimer();
}
@@ -212,7 +212,7 @@ Common::Error ChamberEngine::run() {
IFGM_Init();
- SwitchToGraphicsMode();
+ switchToGraphicsMode();
/* Install timer callback */
initTimer();
@@ -232,10 +232,10 @@ Common::Error ChamberEngine::run() {
}
/* Select intense cyan-mageta palette */
- CGA_ColorSelect(0x30);
+ cga_ColorSelect(0x30);
/* Show the title screen */
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
if (g_vm->getLanguage() == Common::EN_USA) {
if (ifgm_loaded) {
@@ -256,7 +256,7 @@ Common::Error ChamberEngine::run() {
if (_shouldQuit)
return Common::kNoError;
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
ClearKeyboard();
/* Wait for a valid language choice */
@@ -277,7 +277,7 @@ Common::Error ChamberEngine::run() {
res_diali[0].name[4] = c;
if (g_vm->getLanguage() != Common::EN_USA)
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
/* Load script and other static resources */
/* Those are normally embedded in the executable, but here we load extracted ones*/
@@ -296,7 +296,7 @@ Common::Error ChamberEngine::run() {
AskDisk2();
/*TODO: is this neccessary?*/
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
/* Create clean game state snapshot */
SaveRestartGame();
diff --git a/engines/chamber/menu.cpp b/engines/chamber/menu.cpp
index 9d9e1a36e40..455c30721b8 100644
--- a/engines/chamber/menu.cpp
+++ b/engines/chamber/menu.cpp
@@ -164,7 +164,7 @@ void ActionsMenu(byte **pinfo) {
if (the_command != 0xFFFF) {
playSound(19);
- WaitVBlank();
+ waitVBlank();
/*draw dot explosion animation*/
DrawSpriteN(24, act_dot_rects[choice].sx, act_dot_rects[choice].sy, CGA_SCREENBUFFER);
@@ -174,7 +174,7 @@ void ActionsMenu(byte **pinfo) {
DrawSpriteN(25, act_dot_rects[choice].sx, act_dot_rects[choice].sy, CGA_SCREENBUFFER);
for (i = 0; i < 0xFFF; i++) ; /*TODO: weak delay*/
}
- CGA_RestoreBackupImage(CGA_SCREENBUFFER);
+ cga_RestoreBackupImage(CGA_SCREENBUFFER);
*pinfo += numchoices * 3;
}
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index 4d640600095..63af42f4ad4 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -241,12 +241,12 @@ void DrawBoxAroundSpot(void) {
y += (ofs / CGA_BYTES_PER_LINE) * 2;
w *= CGA_PIXELS_PER_BYTE; /*TODO: this will overflow on large sprite*/
- CGA_DrawVLine(x, y, h - 1, 0, CGA_SCREENBUFFER);
- CGA_DrawHLine(x, y, w - 1, 0, CGA_SCREENBUFFER);
- CGA_DrawVLine(x + w - 1, y, h - 1, 0, CGA_SCREENBUFFER);
- CGA_DrawHLine(x, y + h - 1, w - 1, 0, CGA_SCREENBUFFER);
+ cga_DrawVLine(x, y, h - 1, 0, CGA_SCREENBUFFER);
+ cga_DrawHLine(x, y, w - 1, 0, CGA_SCREENBUFFER);
+ cga_DrawVLine(x + w - 1, y, h - 1, 0, CGA_SCREENBUFFER);
+ cga_DrawHLine(x, y + h - 1, w - 1, 0, CGA_SCREENBUFFER);
- CGA_RefreshImageData(*spot_sprite);
+ cga_RefreshImageData(*spot_sprite);
}
/*Get on-screen image as specified by script to temp buffer and register it with dirty rect of kind 2
@@ -276,7 +276,7 @@ int16 DrawPortrait(byte **desc, byte *x, byte *y, byte *width, byte *height) {
cur_image_size_h = *image++;
cur_image_size_w = *image++;
cur_image_pixels = image;
- cur_image_offs = CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y);
+ cur_image_offs = cga_CalcXY_p(cur_image_coords_x, cur_image_coords_y);
AddDirtyRect(DirtyRectSprite, cur_image_coords_x, cur_image_coords_y, cur_image_size_w, cur_image_size_h, cur_image_offs);
/*TODO: remove and use only globals?*/
@@ -286,7 +286,7 @@ int16 DrawPortrait(byte **desc, byte *x, byte *y, byte *width, byte *height) {
*height = cur_image_size_h;
if (right_button) {
- CGA_BlitAndWait(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
+ cga_BlitAndWait(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
return 0;
}
@@ -301,7 +301,7 @@ void PlayHurtSound() {
}
void BlinkWithSound(byte color) {
- CGA_ColorSelect(color);
+ cga_ColorSelect(color);
PlayHurtSound();
SelectPalette();
}
@@ -319,13 +319,13 @@ void BlinkToWhite(void) {
volatile byte vblank_ticks;
-void WaitVBlankTimer(void) {
+void waitVBlankTimer(void) {
if (g_vm->getLanguage() == Common::EN_USA) {
/*A crude attempt to fix the animation speed...*/
while (vblank_ticks < 3) ;
vblank_ticks = 0;
}
- WaitVBlank();
+ waitVBlank();
}
void AnimPortrait(byte layer, byte index, byte delay) {
@@ -357,9 +357,9 @@ void AnimPortrait(byte layer, byte index, byte delay) {
LoadPortrait(&ani, ani + 3);
}
GetDirtyRectAndSetSprite(layer, &kind, &x, &y, &width, &height, &offs);
- WaitVBlank();
- CGA_BlitAndWait(cur_image_pixels, width, width, height, CGA_SCREENBUFFER, offs);
- WaitVBlankTimer();
+ waitVBlank();
+ cga_BlitAndWait(cur_image_pixels, width, width, height, CGA_SCREENBUFFER, offs);
+ waitVBlankTimer();
if (delay) {
if (ani[-1] == 37) { /*TODO: what is it?*/
if (script_byte_vars.extreme_violence)
diff --git a/engines/chamber/print.cpp b/engines/chamber/print.cpp
index 0fc21419950..5142c8cfb90 100644
--- a/engines/chamber/print.cpp
+++ b/engines/chamber/print.cpp
@@ -109,7 +109,7 @@ byte chars_color_wonc[] = {0x55, 0x57, 0x5D, 0x5F, 0x75, 0xF7, 0x7D, 0x7F, 0xD5,
void PrintStringPad(uint16 w, byte *target) {
while (w--)
- CGA_PrintChar(0, target);
+ cga_PrintChar(0, target);
}
byte *PrintWord(byte *str, byte *target) {
@@ -124,7 +124,7 @@ byte *PrintWord(byte *str, byte *target) {
str++;
return str;
}
- CGA_PrintChar(c, target);
+ cga_PrintChar(c, target);
skip_1st:
;
@@ -132,9 +132,9 @@ skip_1st:
str++;
if (f) {
if (f == 0x80)
- CGA_PrintChar(0x25, target);
+ cga_PrintChar(0x25, target);
else if (f != 0x40)
- CGA_PrintChar(0x21, target);
+ cga_PrintChar(0x21, target);
else
return str;
}
@@ -155,7 +155,7 @@ byte *PrintStringLine(byte *str, uint16 *left, byte *target) {
if (string_ended || (mw == 0))
break;
mw--;
- CGA_PrintChar(0, target);
+ cga_PrintChar(0, target);
}
*left = mw;
return str;
@@ -195,7 +195,7 @@ void PrintStringCentered(byte *str, byte *target) {
PrintStringPadded(str, target);
}
-void CGA_DrawTextBox(byte *msg, byte *target) {
+void cga_DrawTextBox(byte *msg, byte *target) {
uint16 x, y, w, i;
uint16 ww, nw;
@@ -211,31 +211,31 @@ void CGA_DrawTextBox(byte *msg, byte *target) {
y = draw_y;
w = (char_draw_max_width + 2) * 4 - 2;
- CGA_DrawHLine(x + 2, y, w - 2, 0, target); /*box top*/
+ cga_DrawHLine(x + 2, y, w - 2, 0, target); /*box top*/
for (i = 0; i < 3; i++)
- CGA_DrawHLine(x + 1, y + 1 + i, w, 1, target); /*top margin*/
- CGA_DrawVLine(x, y + 2, 2, 0, target); /*left top corner 1*/
- CGA_DrawVLine(x + 1, y + 1, 1, 0, target); /*left top corner 2*/
- CGA_DrawVLine(x + w, y + 1, 1, 0, target); /*right top corner 1*/
- CGA_DrawVLine(x + w + 1, y + 2, 2, 0, target); /*right top corner 2*/
+ cga_DrawHLine(x + 1, y + 1 + i, w, 1, target); /*top margin*/
+ cga_DrawVLine(x, y + 2, 2, 0, target); /*left top corner 1*/
+ cga_DrawVLine(x + 1, y + 1, 1, 0, target); /*left top corner 2*/
+ cga_DrawVLine(x + w, y + 1, 1, 0, target); /*right top corner 1*/
+ cga_DrawVLine(x + w + 1, y + 2, 2, 0, target); /*right top corner 2*/
char_draw_coords_y = draw_y + 4;
string_ended = 0;
do {
char_draw_coords_x = draw_x;
- CGA_PrintChar(0x3B, target);
+ cga_PrintChar(0x3B, target);
msg = PrintStringPadded(msg, target);
- CGA_PrintChar(0x3C, target);
+ cga_PrintChar(0x3C, target);
char_draw_coords_y += 6;
} while (!string_ended);
x = draw_x * 4;
y = char_draw_coords_y;
- CGA_DrawHLine(x + 1, y, w, 1, target); /*bottom margin*/
- CGA_DrawVLine(x + 1, y, 1, 0, target); /*bottom left corner 1*/
- CGA_DrawHLine(x + 2, y + 1, w - 2, 0, target); /*box bottom*/
- CGA_DrawVLine(x + 1, y, 1, 0, target); /*TODO: duplicated?*/
- CGA_DrawVLine(x + w, y, 1, 0, target); /*bottom right corner*/
+ cga_DrawHLine(x + 1, y, w, 1, target); /*bottom margin*/
+ cga_DrawVLine(x + 1, y, 1, 0, target); /*bottom left corner 1*/
+ cga_DrawHLine(x + 2, y + 1, w - 2, 0, target); /*box bottom*/
+ cga_DrawVLine(x + 1, y, 1, 0, target); /*TODO: duplicated?*/
+ cga_DrawVLine(x + w, y, 1, 0, target); /*bottom right corner*/
}
void DrawMessage(byte *msg, byte *target) {
@@ -258,10 +258,10 @@ void DrawMessage(byte *msg, byte *target) {
draw_x = x;
draw_y = y;
- CGA_BackupImageReal(CGA_CalcXY_p(x, y), char_draw_max_width + 2, char_draw_max_height); /*backup orig. screen data*/
- CGA_DrawTextBox(msg, target); /*draw box with text*/
+ cga_BackupImageReal(cga_CalcXY_p(x, y), char_draw_max_width + 2, char_draw_max_height); /*backup orig. screen data*/
+ cga_DrawTextBox(msg, target); /*draw box with text*/
PromptWait(); /*wait keypress*/
- CGA_RestoreBackupImage(target); /*restore screen data*/
+ cga_RestoreBackupImage(target); /*restore screen data*/
}
#if 1
diff --git a/engines/chamber/print.h b/engines/chamber/print.h
index 1106ff7f1c3..bdcc39a289a 100644
--- a/engines/chamber/print.h
+++ b/engines/chamber/print.h
@@ -40,7 +40,7 @@ byte *PrintStringPadded(byte *str, byte *target);
void DrawMessage(byte *msg, byte *target);
-void CGA_DrawTextBox(byte *msg, byte *target);
+void cga_DrawTextBox(byte *msg, byte *target);
void CalcStringSize(byte *str, uint16 *w, uint16 *n);
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index 1a5052bf997..46daa96041c 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -144,12 +144,12 @@ static const byte cga_color_sels[] = {
};
void SelectSpecificPalette(byte index) {
- CGA_ColorSelect(cga_color_sels[index]);
+ cga_ColorSelect(cga_color_sels[index]);
}
void SelectPalette(void) {
- CGA_ColorSelect(cga_color_sels[script_byte_vars.palette_index]);
+ cga_ColorSelect(cga_color_sels[script_byte_vars.palette_index]);
}
/*
@@ -159,7 +159,7 @@ void BlitSpritesToBackBuffer(void) {
int16 i;
for (i = 0; i < MAX_SPRITES; i++) {
byte *sprite = sprites_list[i];
- CGA_RestoreImage(sprite, backbuffer);
+ cga_RestoreImage(sprite, backbuffer);
}
}
@@ -170,7 +170,7 @@ void RefreshSpritesData(void) {
int16 i;
for (i = 0; i < MAX_SPRITES; i++) {
byte *sprite = sprites_list[i];
- CGA_RefreshImageData(sprite);
+ cga_RefreshImageData(sprite);
}
}
@@ -276,15 +276,15 @@ void DrawBackground(byte *target, byte vblank) {
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);
+ cga_Blit(pixels + (i & 1 ? 0 : kBgW * kBgH), kBgW, kBgW, kBgH, target, offs);
if (vblank)
- WaitVBlank();
+ waitVBlank();
offs += background_draw_steps[i];
}
offs = (182 / 2) * CGA_BYTES_PER_LINE; /*TODO: calcxy?*/
for (i = 0; i < 9; i++) {
- CGA_Blit(pixels, kBgW, kBgW, 9, target, offs);
+ cga_Blit(pixels, kBgW, kBgW, 9, target, offs);
offs += kBgW;
}
}
@@ -450,14 +450,14 @@ void InitRoomDoorInfo(byte index) {
info->layer[i].width = w;
info->layer[i].height = h;
info->layer[i].pixels = sprite + 2;
- info->layer[i].offs = CGA_CalcXY_p(x, y);
+ info->layer[i].offs = cga_CalcXY_p(x, y);
aptr += 3;
}
info->width = bounds.ex - bounds.sx;
info->height = bounds.ey - bounds.sy;
- info->offs = CGA_CalcXY_p(bounds.sx, bounds.sy);
+ info->offs = cga_CalcXY_p(bounds.sx, bounds.sy);
}
/*
@@ -473,13 +473,13 @@ void DrawRoomDoor(void) {
uint16 offs = info->layer[i].offs;
if (!info->flipped)
- CGA_BlitSprite(pixels, w * 2, w, h, backbuffer, offs);
+ cga_BlitSprite(pixels, w * 2, w, h, backbuffer, offs);
else
- CGA_BlitSpriteFlip(pixels, w * 2, w, h, backbuffer, offs);
+ cga_BlitSpriteFlip(pixels, w * 2, w, h, backbuffer, offs);
}
- WaitVBlank();
- WaitVBlank();
- CGA_CopyScreenBlock(backbuffer, info->width, info->height, frontbuffer, info->offs);
+ waitVBlank();
+ waitVBlank();
+ cga_CopyScreenBlock(backbuffer, info->width, info->height, frontbuffer, info->offs);
}
/*
@@ -596,7 +596,7 @@ Play animation at the selected spot or specified coordinates
*/
void AnimateSpot(const animdesc_t *info) {
byte *sprite = *spot_sprite;
- CGA_RestoreImage(sprite, backbuffer);
+ cga_RestoreImage(sprite, backbuffer);
if (info->index & ANIMFLG_USESPOT) {
/*at selected spot*/
cursor_x = found_spot->sx * 4;
@@ -778,9 +778,9 @@ void DrawRoomStaticObject(byte *aptr, byte *rx, byte *ry, byte *rw, byte *rh) {
/*TODO: check if this results in any glitches in Who Will Be Saved*/
if (aptr[1] & 0x80)
- CGA_BlitSpriteFlip(sprite, pitch, w, h, backbuffer, CGA_CalcXY_p(x, y));
+ cga_BlitSpriteFlip(sprite, pitch, w, h, backbuffer, cga_CalcXY_p(x, y));
else
- CGA_BlitSprite(sprite, pitch, w, h, backbuffer, CGA_CalcXY_p(x, y));
+ cga_BlitSprite(sprite, pitch, w, h, backbuffer, cga_CalcXY_p(x, y));
}
/*
@@ -837,20 +837,20 @@ void DrawRoomStatics(void) {
char_xlat_table = chars_color_wonb;
/*print room name*/
- CGA_PrintChar(0x3B, backbuffer);
+ cga_PrintChar(0x3B, backbuffer);
DrawObjectHint(); /* area name */
- CGA_PrintChar(0x3C, backbuffer);
+ cga_PrintChar(0x3C, backbuffer);
/*draw border around hint text*/
xx = (room_hint_bar_coords_x - 1) * 4;
y = room_hint_bar_coords_y;
ww = (room_hint_bar_width + 2) * 4;
- CGA_DrawHLine(xx, y - 2, ww, 2, backbuffer);
- CGA_DrawHLine(xx, y - 1, ww, 0, backbuffer);
- CGA_DrawHLine(xx, y + 6, ww, 2, backbuffer);
- CGA_DrawVLine(xx, y - 2, 9, 2, backbuffer);
- CGA_DrawVLine(xx + ww - 1, y - 2, 9, 2, backbuffer);
+ cga_DrawHLine(xx, y - 2, ww, 2, backbuffer);
+ cga_DrawHLine(xx, y - 1, ww, 0, backbuffer);
+ cga_DrawHLine(xx, y + 6, ww, 2, backbuffer);
+ cga_DrawVLine(xx, y - 2, 9, 2, backbuffer);
+ cga_DrawVLine(xx + ww - 1, y - 2, 9, 2, backbuffer);
}
/*
@@ -925,7 +925,7 @@ void RefreshZone(void) {
if (!skip_zone_transition && !right_button)
DrawBackground(CGA_SCREENBUFFER, 1);
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
in_de_profundis = 0;
IFGM_StopSample();
@@ -956,10 +956,10 @@ void DrawObjectHint(void) {
PrintStringCentered(SeekToString(motsi_data, object_hint), backbuffer);
#ifdef DEBUG_ZONE
- CGA_PrintChar(0x20, backbuffer);
- CGA_PrintChar(0x10 + script_byte_vars.zone_index / 100, backbuffer);
- CGA_PrintChar(0x10 + (script_byte_vars.zone_index / 10) % 10, backbuffer);
- CGA_PrintChar(0x10 + script_byte_vars.zone_index % 10, backbuffer);
+ cga_PrintChar(0x20, backbuffer);
+ cga_PrintChar(0x10 + script_byte_vars.zone_index / 100, backbuffer);
+ cga_PrintChar(0x10 + (script_byte_vars.zone_index / 10) % 10, backbuffer);
+ cga_PrintChar(0x10 + script_byte_vars.zone_index % 10, backbuffer);
#endif
}
@@ -969,7 +969,7 @@ Copy object hint from backbuffer to screen
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));
+ 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));
}
/*
@@ -987,7 +987,7 @@ void DrawCommandHint(void) {
Copy command hint from backbuffer to screen
*/
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));
+ 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(uint16 lutidx) {
@@ -1037,7 +1037,7 @@ void DrawCharacterSprite(byte spridx, byte x, byte y, byte *target) {
LoadLutinSprite(spridx);
- DrawSprite(scratch_mem2, target, CGA_CalcXY_p(x, y));
+ DrawSprite(scratch_mem2, target, cga_CalcXY_p(x, y));
}
/*
@@ -1060,7 +1060,7 @@ char DrawZoneAniSprite(rect_t *rect, uint16 index, byte *target) {
zsprite_w = scratch_mem2[0];
zsprite_h = scratch_mem2[1];
- zsprite_draw_ofs = CGA_CalcXY_p(rect->sx, rect->sy);
+ zsprite_draw_ofs = cga_CalcXY_p(rect->sx, rect->sy);
DrawSprite(scratch_mem2, target, zsprite_draw_ofs);
@@ -1278,7 +1278,7 @@ uint16 GetPuzzlSprite(byte index, byte x, byte y, uint16 *w, uint16 *h, uint16 *
byte *spr = LoadPuzzlToScratch(index);
*w = spr[0];
*h = spr[1];
- *ofs = CGA_CalcXY_p(x, y);
+ *ofs = cga_CalcXY_p(x, y);
return 0; /*sprite offset in scratch buf*/
}
@@ -1291,7 +1291,7 @@ void BackupScreenOfSpecialRoom(void) {
case 22: /* DE PROFUNDIS */
case 23: /* DE PROFUNDIS */
case 24: /* THE WALL */
- CGA_RealBufferToBackFull();
+ cga_RealBufferToBackFull();
break;
}
}
@@ -1387,10 +1387,10 @@ Open The Wall's right gate
TODO: move this to CGA?
*/
void TheWallOpenRightDoor(byte x, byte y, byte width, byte height, byte limit) {
- uint16 offs = CGA_CalcXY_p(x + width - 2, y);
+ uint16 offs = cga_CalcXY_p(x + width - 2, y);
while (--width) {
- CGA_HideScreenBlockLiftToRight(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_HideScreenBlockLiftToRight(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
if (width == limit)
return;
}
@@ -1408,7 +1408,7 @@ void TheWallOpenRightDoor(byte x, byte y, byte width, byte height, byte limit) {
offs += CGA_BYTES_PER_LINE;
}
- CGA_blitToScreen(ooffs, 1, oh);
+ cga_blitToScreen(ooffs, 1, oh);
}
/*
@@ -1416,10 +1416,10 @@ Open The Wall's left gate
TODO: move this to CGA?
*/
void TheWallOpenLeftDoor(byte x, byte y, byte width, byte height, byte limit) {
- uint16 offs = CGA_CalcXY_p(x + 1, y);
+ uint16 offs = cga_CalcXY_p(x + 1, y);
while (--width) {
- CGA_HideScreenBlockLiftToLeft(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_HideScreenBlockLiftToLeft(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
if (width == limit)
return;
}
@@ -1436,7 +1436,7 @@ void TheWallOpenLeftDoor(byte x, byte y, byte width, byte height, byte limit) {
if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
}
- CGA_blitToScreen(ooffs, 1, oh);
+ cga_blitToScreen(ooffs, 1, oh);
}
/*
@@ -1484,11 +1484,11 @@ void TheWallPhase1_DoorClose1(void) {
spr = LoadMursmSprite(0);
spr += cur_frame_width - 1;
cur_image_coords_x = 64 / 4;
- CGA_AnimLiftToRight(10, spr, cur_frame_width, 1, cur_image_size_h, frontbuffer, CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y));
+ cga_AnimLiftToRight(10, spr, cur_frame_width, 1, cur_image_size_h, frontbuffer, cga_CalcXY_p(cur_image_coords_x, cur_image_coords_y));
spr = LoadMursmSprite(1);
cur_image_coords_x = 220 / 4;
- CGA_AnimLiftToLeft(10, spr, cur_frame_width, 1, cur_image_size_h, frontbuffer, CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y));
+ cga_AnimLiftToLeft(10, spr, cur_frame_width, 1, cur_image_size_h, frontbuffer, cga_CalcXY_p(cur_image_coords_x, cur_image_coords_y));
IFGM_StopSample();
@@ -1508,11 +1508,11 @@ void TheWallPhase2_DoorClose2(void) {
spr = LoadMursmSprite(0);
spr += cur_frame_width - 1;
cur_image_coords_x = 64 / 4;
- CGA_AnimLiftToRight(10, spr - 10, cur_frame_width, 1 + 10, cur_image_size_h, frontbuffer, CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y));
+ cga_AnimLiftToRight(10, spr - 10, cur_frame_width, 1 + 10, cur_image_size_h, frontbuffer, cga_CalcXY_p(cur_image_coords_x, cur_image_coords_y));
spr = LoadMursmSprite(1);
cur_image_coords_x = 220 / 4;
- CGA_AnimLiftToLeft(10, spr, cur_frame_width, 1 + 10, cur_image_size_h, frontbuffer, CGA_CalcXY_p(cur_image_coords_x, cur_image_coords_y) - 10);
+ cga_AnimLiftToLeft(10, spr, cur_frame_width, 1 + 10, cur_image_size_h, frontbuffer, cga_CalcXY_p(cur_image_coords_x, cur_image_coords_y) - 10);
IFGM_PlaySample(30);
@@ -1526,18 +1526,18 @@ void DrawTheWallDoors(void) {
switch (script_byte_vars.zone_index) {
case 9:
case 102:
- CGA_Blit(LoadMursmSprite(0) + 10, 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(64 / CGA_PIXELS_PER_BYTE, 32));
+ cga_Blit(LoadMursmSprite(0) + 10, 20, 10, 59, CGA_SCREENBUFFER, cga_CalcXY_p(64 / CGA_PIXELS_PER_BYTE, 32));
if (g_vm->getLanguage() == Common::EN_USA) {
/*This fixes odd black patch on the right gate door*/
- CGA_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(184 / CGA_PIXELS_PER_BYTE, 32));
+ cga_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, cga_CalcXY_p(184 / CGA_PIXELS_PER_BYTE, 32));
} else {
- CGA_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(180 / CGA_PIXELS_PER_BYTE, 32));
+ cga_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, cga_CalcXY_p(180 / CGA_PIXELS_PER_BYTE, 32));
}
break;
case 95:
case 103:
- CGA_Blit(LoadMursmSprite(0), 20, 20, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(64 / CGA_PIXELS_PER_BYTE, 32));
- CGA_Blit(LoadMursmSprite(1), 20, 20, 59, CGA_SCREENBUFFER, CGA_CalcXY_p(144 / CGA_PIXELS_PER_BYTE, 32));
+ cga_Blit(LoadMursmSprite(0), 20, 20, 59, CGA_SCREENBUFFER, cga_CalcXY_p(64 / CGA_PIXELS_PER_BYTE, 32));
+ cga_Blit(LoadMursmSprite(1), 20, 20, 59, CGA_SCREENBUFFER, cga_CalcXY_p(144 / CGA_PIXELS_PER_BYTE, 32));
break;
}
}
@@ -1584,7 +1584,7 @@ Return current and next free buffer ptr
*/
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);
+ buffer = cga_BackupImage(backbuffer, cga_CalcXY_p(spot->sx, spot->sy), spot->ex - spot->sx, spot->ey - spot->sy, buffer);
return buffer;
}
@@ -1623,11 +1623,11 @@ void DrawSpots(byte *target) {
/*TODO: subclass spot_t from rect_t*/
if (DrawZoneAniSprite((rect_t *)spot, (spot - zone_spots) + 1, backbuffer)) {
UpdateCursor();
- WaitVBlank();
+ waitVBlank();
UndrawCursor(target);
- CGA_CopyScreenBlock(backbuffer, zsprite_w, zsprite_h, target, zsprite_draw_ofs);
+ cga_CopyScreenBlock(backbuffer, zsprite_w, zsprite_h, target, zsprite_draw_ofs);
DrawCursor(target);
- CGA_RestoreImage(sprites_list[zone_spr_index - 1], backbuffer);
+ cga_RestoreImage(sprites_list[zone_spr_index - 1], backbuffer);
return;
}
spridx = zone_spr_index; /*TODO: not neded?*/
@@ -1652,7 +1652,7 @@ Draw cursor and hints text on screen
*/
void DrawHintsAndCursor(byte *target) {
UpdateCursor();
- WaitVBlank();
+ waitVBlank();
UndrawCursor(target);
if (object_hint != last_object_hint) {
ShowObjectHint(target);
@@ -1777,7 +1777,7 @@ void UpdateProtozorqs(void) {
}
DrawPersons();
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
BlitSpritesToBackBuffer();
DrawCursor(frontbuffer);
@@ -1815,7 +1815,7 @@ void UpdateProtozorqs(void) {
AnimateSpot(&anim34);
DrawPersons();
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
BlitSpritesToBackBuffer();
DrawCursor(frontbuffer);
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index af6abbc8101..7a1fec3b4c6 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -688,7 +688,7 @@ uint16 SCR_5_DrawPortraitLiftRight(void) {
return 0;
/*TODO: use local args instead of globals*/
- CGA_AnimLiftToRight(width, cur_image_pixels + width - 1, width, 1, height, CGA_SCREENBUFFER, CGA_CalcXY_p(x, y));
+ cga_AnimLiftToRight(width, cur_image_pixels + width - 1, width, 1, height, CGA_SCREENBUFFER, cga_CalcXY_p(x, y));
return 0;
}
@@ -704,7 +704,7 @@ uint16 SCR_6_DrawPortraitLiftLeft(void) {
return 0;
/*TODO: use local args instead of globals*/
- CGA_AnimLiftToLeft(width, cur_image_pixels, width, 1, height, CGA_SCREENBUFFER, CGA_CalcXY_p(x + width - 1, y));
+ cga_AnimLiftToLeft(width, cur_image_pixels, width, 1, height, CGA_SCREENBUFFER, cga_CalcXY_p(x + width - 1, y));
return 0;
}
@@ -720,7 +720,7 @@ uint16 SCR_7_DrawPortraitLiftDown(void) {
return 0;
/*TODO: use local args instead of globals*/
- CGA_AnimLiftToDown(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
+ cga_AnimLiftToDown(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
return 0;
}
@@ -736,7 +736,7 @@ uint16 SCR_8_DrawPortraitLiftUp(void) {
return 0;
/*TODO: use local args instead of globals*/
- CGA_AnimLiftToUp(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, x, y + height - 1);
+ cga_AnimLiftToUp(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, x, y + height - 1);
return 0;
}
@@ -751,7 +751,7 @@ uint16 SCR_9_DrawPortrait(void) {
if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
- CGA_BlitAndWait(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
+ cga_BlitAndWait(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
return 0;
}
@@ -774,8 +774,8 @@ void TwistDraw(byte x, byte y, byte width, byte height, byte *source, byte *targ
ey = y + height - 1;
for (i = 0; i < width * 4; i++) {
- CGA_TraceLine(sx, ex, sy, ey, source, target);
- WaitVBlank();
+ cga_TraceLine(sx, ex, sy, ey, source, target);
+ waitVBlank();
sx += 1;
ex -= 1;
}
@@ -789,8 +789,8 @@ void TwistDraw(byte x, byte y, byte width, byte height, byte *source, byte *targ
ey = t;
for (i = 0; i < height; i++) {
- CGA_TraceLine(sx, ex, sy, ey, source, target);
- WaitVBlank();
+ cga_TraceLine(sx, ex, sy, ey, source, target);
+ waitVBlank();
sy -= 1;
ey += 1;
}
@@ -808,11 +808,11 @@ uint16 SCR_B_DrawPortraitTwistEffect(void) {
if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
- offs = CGA_CalcXY_p(x, y);
+ offs = cga_CalcXY_p(x, y);
- CGA_SwapScreenRect(cur_image_pixels, width, height, backbuffer, offs);
+ cga_SwapScreenRect(cur_image_pixels, width, height, backbuffer, offs);
TwistDraw(x, y, width, height, backbuffer, frontbuffer);
- CGA_BlitAndWait(scratch_mem2, width, width, height, backbuffer, offs);
+ cga_BlitAndWait(scratch_mem2, width, width, height, backbuffer, offs);
return 0;
}
@@ -829,20 +829,20 @@ void ArcDraw(byte x, byte y, byte width, byte height, byte *source, byte *target
ey = y + height - 1;
for (i = 0; i < height; i++) {
- CGA_TraceLine(sx, ex, sy, ey, source, target);
- WaitVBlank();
+ cga_TraceLine(sx, ex, sy, ey, source, target);
+ waitVBlank();
sy -= 1;
}
for (i = 0; i < width * 4; i++) {
- CGA_TraceLine(sx, ex, sy, ey, source, target);
- WaitVBlank();
+ cga_TraceLine(sx, ex, sy, ey, source, target);
+ waitVBlank();
sx += 1;
}
for (i = 0; i < height + 1; i++) {
- CGA_TraceLine(sx, ex, sy, ey, source, target);
- WaitVBlank();
+ cga_TraceLine(sx, ex, sy, ey, source, target);
+ waitVBlank();
sy += 1;
}
}
@@ -859,11 +859,11 @@ uint16 SCR_C_DrawPortraitArcEffect(void) {
if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
- offs = CGA_CalcXY_p(x, y);
+ offs = cga_CalcXY_p(x, y);
- CGA_SwapScreenRect(cur_image_pixels, width, height, backbuffer, offs);
+ cga_SwapScreenRect(cur_image_pixels, width, height, backbuffer, offs);
ArcDraw(x, y, width, height, backbuffer, frontbuffer);
- CGA_BlitAndWait(scratch_mem2, width, width, height, backbuffer, offs);
+ cga_BlitAndWait(scratch_mem2, width, width, height, backbuffer, offs);
return 0;
}
@@ -886,10 +886,10 @@ uint16 SCR_D_DrawPortraitDotEffect(void) {
int16 count = 0;
for (offs = 0; offs != cur_image_end;) {
- target[CGA_CalcXY_p(x + offs % cur_image_size_w, y + offs / cur_image_size_w)] = cur_image_pixels[offs];
+ target[cga_CalcXY_p(x + offs % cur_image_size_w, y + offs / cur_image_size_w)] = cur_image_pixels[offs];
if (count % 5 == 0)
- CGA_blitToScreen(offs, 4, 1);
+ cga_blitToScreen(offs, 4, 1);
offs += step;
if (offs > cur_image_end)
@@ -911,7 +911,7 @@ uint16 SCR_E_DrawPortraitZoomIn(void) {
if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
- CGA_AnimZoomIn(cur_image_pixels, cur_image_size_w, cur_image_size_h, frontbuffer, cur_image_offs);
+ cga_AnimZoomIn(cur_image_pixels, cur_image_size_w, cur_image_size_h, frontbuffer, cur_image_offs);
return 0;
}
@@ -931,7 +931,7 @@ uint16 DrawPortraitZoomed(byte **params) {
last_dirty_rect->width = zwidth + 2;
last_dirty_rect->height = zheight;
- CGA_ZoomImage(cur_image_pixels, cur_image_size_w, cur_image_size_h, zwidth, zheight, frontbuffer, cur_image_offs);
+ cga_ZoomImage(cur_image_pixels, cur_image_size_w, cur_image_size_h, zwidth, zheight, frontbuffer, cur_image_offs);
return 0;
}
@@ -965,17 +965,17 @@ uint16 SCR_19_HidePortraitLiftLeft(void) {
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
- CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
/*TODO: This originally was done by reusing door sliding routine*/
- /*offs = CGA_CalcXY_p(x + 1, y);*/
+ /*offs = cga_CalcXY_p(x + 1, y);*/
offs++;
while (--width) {
- CGA_HideScreenBlockLiftToLeft(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_HideScreenBlockLiftToLeft(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
}
offs--;
@@ -991,7 +991,7 @@ uint16 SCR_19_HidePortraitLiftLeft(void) {
if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
}
- CGA_blitToScreen(ooffs, 1, oh);
+ cga_blitToScreen(ooffs, 1, oh);
return 0;
}
@@ -1011,16 +1011,16 @@ uint16 SCR_1A_HidePortraitLiftRight(void) {
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
- CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
/*TODO: This originally was done by reusing door sliding routine*/
- offs = CGA_CalcXY_p(x + width - 2, y);
+ offs = cga_CalcXY_p(x + width - 2, y);
while (--width) {
- CGA_HideScreenBlockLiftToRight(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_HideScreenBlockLiftToRight(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
}
offs++;
@@ -1036,7 +1036,7 @@ uint16 SCR_1A_HidePortraitLiftRight(void) {
if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
}
- CGA_blitToScreen(ooffs, 1, oh);
+ cga_blitToScreen(ooffs, 1, oh);
return 0;
}
@@ -1056,14 +1056,14 @@ uint16 SCR_1B_HidePortraitLiftUp(void) {
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
- CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
- offs = CGA_CalcXY_p(x, y + 1);
+ offs = cga_CalcXY_p(x, y + 1);
while (--height) {
- CGA_HideScreenBlockLiftToUp(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_HideScreenBlockLiftToUp(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
}
/*hide topmost line*/
@@ -1072,7 +1072,7 @@ uint16 SCR_1B_HidePortraitLiftUp(void) {
if ((offs & CGA_ODD_LINES_OFS) != 0)
offs -= CGA_BYTES_PER_LINE;
memcpy(CGA_SCREENBUFFER + offs, backbuffer + offs, width);
- CGA_blitToScreen(offs, width, 1);
+ cga_blitToScreen(offs, width, 1);
return 0;
}
@@ -1092,14 +1092,14 @@ uint16 SCR_1C_HidePortraitLiftDown(void) {
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
- CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
- offs = CGA_CalcXY_p(x, y + height - 2);
+ offs = cga_CalcXY_p(x, y + height - 2);
while (--height) {
- CGA_HideScreenBlockLiftToDown(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_HideScreenBlockLiftToDown(1, CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
}
/*hide bottommost line*/
@@ -1108,7 +1108,7 @@ uint16 SCR_1C_HidePortraitLiftDown(void) {
if ((offs & CGA_ODD_LINES_OFS) == 0)
offs += CGA_BYTES_PER_LINE;
memcpy(CGA_SCREENBUFFER + offs, backbuffer + offs, width);
- CGA_blitToScreen(offs, width, 1);
+ cga_blitToScreen(offs, width, 1);
return 0;
}
@@ -1128,7 +1128,7 @@ uint16 SCR_1E_HidePortraitTwist(void) {
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
- CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
@@ -1152,7 +1152,7 @@ uint16 SCR_1F_HidePortraitArc(void) {
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
- CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
@@ -1176,7 +1176,7 @@ uint16 SCR_20_HidePortraitDots(void) {
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
- CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
@@ -1302,8 +1302,8 @@ void JaggedZoom(byte *source, byte *target) {
ex = points[0].x;
ey = points[0].y;
}
- CGA_TraceLine(sx / 2, ex / 2, sy / 2, ey / 2, source, target);
- /*TODO: WaitVBlank(); maybe?*/
+ cga_TraceLine(sx / 2, ex / 2, sy / 2, ey / 2, source, target);
+ /*TODO: waitVBlank(); maybe?*/
}
}
}
@@ -1372,7 +1372,7 @@ void DrawStars(star_t *stars, int16 iter, byte *target) {
continue;
}
- stars->ofs = CGA_CalcXY(x, y);
+ stars->ofs = cga_CalcXY(x, y);
pixel = (stars->z < 0xE00) ? 0xC0 : 0x40;
pixel >>= (x % 4) * 2;
@@ -1404,8 +1404,8 @@ uint16 SCR_26_GameOver(void) {
script_byte_vars.game_paused = 1;
memset(backbuffer, 0, sizeof(backbuffer) - 2); /*TODO: original bug?*/
JaggedZoom(backbuffer, frontbuffer);
- CGA_BackBufferToRealFull();
- CGA_ColorSelect(0x30);
+ cga_BackBufferToRealFull();
+ cga_ColorSelect(0x30);
AnimStarfield(InitStarfield(), frontbuffer);
playAnim(44, 156 / 4, 95);
script_byte_vars.zone_index = 135;
@@ -1416,7 +1416,7 @@ uint16 SCR_26_GameOver(void) {
JaggedZoom(backbuffer, frontbuffer);
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
RestartGame();
return 0;
}
@@ -1562,7 +1562,7 @@ Display a static sprite in the room (to screen)
uint16 SCR_11_DrawRoomObject(void) {
byte x, y, w, h;
SCR_DrawRoomObjectBack(&x, &y, &w, &h);
- CGA_CopyScreenBlock(backbuffer, w, h, frontbuffer, CGA_CalcXY_p(x, y));
+ cga_CopyScreenBlock(backbuffer, w, h, frontbuffer, cga_CalcXY_p(x, y));
return 0;
}
@@ -1740,8 +1740,8 @@ uint16 SCR_2A_PopDialogRect(void) {
index = *script_ptr++;
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
- CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs); /*TODO: implicit target*/
- CGA_CopyScreenBlock(backbuffer, 2, 21, CGA_SCREENBUFFER, offs = (x << 8) | y); /*TODO: implicit target*/
+ cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs); /*TODO: implicit target*/
+ cga_CopyScreenBlock(backbuffer, 2, 21, CGA_SCREENBUFFER, offs = (x << 8) | y); /*TODO: implicit target*/
cur_dlg_index = 0;
@@ -1772,11 +1772,11 @@ uint16 SCR_22_HidePortraitShatter(void) {
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
- CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
- CGA_HideShatterFall(CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_HideShatterFall(CGA_SCREENBUFFER, backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
@@ -1796,11 +1796,11 @@ uint16 SCR_23_HidePortrait(void) {
GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
- CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
- CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
}
@@ -1850,7 +1850,7 @@ Draw updated Hands in Who Will Be Saved
uint16 SCR_41_LiftHand(void) {
script_ptr++;
RedrawRoomStatics(92, script_byte_vars.hands);
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
playSound(31);
return 0;
}
@@ -1899,13 +1899,13 @@ uint16 SCR_30_Fight(void) {
player_image[1] = x;
player_image[2] = y;
if (DrawPortrait(&image, &x, &y, &width, &height))
- CGA_AnimLiftToLeft(width, cur_image_pixels, width, 1, height, CGA_SCREENBUFFER, CGA_CalcXY_p(x + width - 1, y));
+ cga_AnimLiftToLeft(width, cur_image_pixels, width, 1, height, CGA_SCREENBUFFER, cga_CalcXY_p(x + width - 1, y));
BlinkToWhite();
if (pers->name != 44 && pers->name != 56 && pers->name != 51) { /*VORT, MONKEY, TURKEY*/
GetDirtyRectAndFree(1, &kind, &x, &y, &width, &height, &offs);
- CGA_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
+ cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
}
/*check fight outcome*/
@@ -2153,8 +2153,8 @@ void FightWin(void) {
script_byte_vars.bvar_67 = 0;
if (script_byte_vars.bvar_43 != 18 && *spot_sprite != 0) {
- CGA_RestoreImage(*spot_sprite, frontbuffer);
- CGA_RestoreImage(*spot_sprite, backbuffer);
+ cga_RestoreImage(*spot_sprite, frontbuffer);
+ cga_RestoreImage(*spot_sprite, backbuffer);
if (script_byte_vars.extreme_violence == 0
&& script_byte_vars.bvar_60 == 0
@@ -2185,7 +2185,7 @@ void DrawDeathAnim(void) {
/*remove existing cadaver if any*/
if (SelectPerson(PersonOffset(kPersCadaver))) {
found_spot->flags &= ~SPOTFLG_80;
- CGA_RestoreImage(*spot_sprite, backbuffer);
+ cga_RestoreImage(*spot_sprite, backbuffer);
}
for (i = 0; i < 23; i++) {
@@ -2226,7 +2226,7 @@ uint16 SCR_60_ReviveCadaver(void) {
pers->area = script_byte_vars.zone_area;
DrawPersons();
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
return 0;
}
@@ -2287,7 +2287,7 @@ uint16 SCR_15_SelectSpot(void) {
uint16 SCR_44_BackBufferToScreen(void) {
script_ptr++;
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
return 0;
}
@@ -2302,27 +2302,27 @@ uint16 SCR_45_DeProfundisRoomEntry(void) {
/*draw Platform*/
sprofs = GetPuzzlSprite(3, 140 / 4, 174, &w, &h, &ofs);
- CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+ cga_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
/*draw Granite Monster*/
sprofs = GetPuzzlSprite(119, 128 / 4, 94, &w, &h, &ofs);
- CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+ cga_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
PromptWait();
for (; h; h--) {
- WaitVBlank();
- WaitVBlank();
- CGA_BlitFromBackBuffer(w, 1, CGA_SCREENBUFFER, ofs);
+ waitVBlank();
+ waitVBlank();
+ cga_BlitFromBackBuffer(w, 1, CGA_SCREENBUFFER, ofs);
ofs ^= CGA_ODD_LINES_OFS;
if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
- CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+ cga_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
}
- CGA_BlitFromBackBuffer(w, 1, CGA_SCREENBUFFER, ofs);
+ cga_BlitFromBackBuffer(w, 1, CGA_SCREENBUFFER, ofs);
return 0;
}
@@ -2345,13 +2345,13 @@ uint16 SCR_46_DeProfundisLowerHook(void) {
sprofs = y * 20 / 4 * 2; /*TODO: 20 is the sprite width. replace with w?*/
for (; y; y--) {
- WaitVBlank();
- CGA_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
+ waitVBlank();
+ cga_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
h++;
sprofs -= 20 / 4 * 2;
- CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+ cga_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
}
return 0;
@@ -2374,7 +2374,7 @@ uint16 SCR_47_DeProfundisRiseMonster(void) {
y = 68;
for (; y; y--) {
- WaitVBlank();
+ waitVBlank();
ofs ^= CGA_ODD_LINES_OFS;
if ((ofs & CGA_ODD_LINES_OFS) != 0)
@@ -2382,7 +2382,7 @@ uint16 SCR_47_DeProfundisRiseMonster(void) {
h++;
- CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+ cga_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
}
return 0;
@@ -2404,15 +2404,15 @@ uint16 SCR_48_DeProfundisLowerMonster(void) {
y = 34;
for (; y; y--) {
- WaitVBlank();
- CGA_BlitFromBackBuffer(w, 1, CGA_SCREENBUFFER, ofs);
+ waitVBlank();
+ cga_BlitFromBackBuffer(w, 1, CGA_SCREENBUFFER, ofs);
ofs ^= CGA_ODD_LINES_OFS;
if ((ofs & CGA_ODD_LINES_OFS) == 0)
ofs += CGA_BYTES_PER_LINE;
h--;
- CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+ cga_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
}
return 0;
@@ -2435,16 +2435,16 @@ uint16 SCR_49_DeProfundisRiseHook(void) {
y = 15;
for (; y; y--) {
- WaitVBlank();
- CGA_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
+ waitVBlank();
+ cga_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
h--;
sprofs += 20 / 4 * 2;
- CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+ cga_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
}
- CGA_BlitFromBackBuffer(w, 1, CGA_SCREENBUFFER, ofs);
+ cga_BlitFromBackBuffer(w, 1, CGA_SCREENBUFFER, ofs);
return 0;
}
@@ -2476,8 +2476,8 @@ uint16 SCR_65_DeProfundisMovePlatform(void) {
}
for (; y; y--) {
- WaitVBlank();
- CGA_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
+ waitVBlank();
+ cga_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
ofs ^= CGA_ODD_LINES_OFS;
if ((ofs & CGA_ODD_LINES_OFS) == 0)
@@ -2485,11 +2485,11 @@ uint16 SCR_65_DeProfundisMovePlatform(void) {
h--;
- CGA_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
+ cga_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
}
if (state)
- CGA_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
+ cga_BlitFromBackBuffer(w, h, CGA_SCREENBUFFER, ofs);
return 0;
}
@@ -2506,7 +2506,7 @@ uint16 SCR_66_DeProfundisRideToExit(void) {
/*draw Granite Monster*/
sprofs = GetPuzzlSprite(119, 128 / 4, 139, &w, &h, &ofs);
- CGA_BlitScratchBackSprite(sprofs, w, 20, backbuffer, ofs);
+ cga_BlitScratchBackSprite(sprofs, w, 20, backbuffer, ofs);
dot_effect_delay = 1;
dot_effect_step = 17;
@@ -2703,10 +2703,10 @@ uint16 SCR_56_MorphRoom98(void) {
RedrawRoomStatics(98, 0);
- ofs = CGA_CalcXY(0, 136);
+ ofs = cga_CalcXY(0, 136);
for (h = 60; h; h--) {
memcpy(frontbuffer + ofs, backbuffer + ofs, CGA_BYTES_PER_LINE);
- WaitVBlank();
+ waitVBlank();
ofs ^= CGA_ODD_LINES_OFS;
if ((ofs & CGA_ODD_LINES_OFS) != 0)
ofs -= CGA_BYTES_PER_LINE;
@@ -2779,8 +2779,8 @@ static void AnimSaucer(void) {
byte scroll_done = 0;
memset(backbuffer, 0, sizeof(backbuffer) - 2); /*TODO: original bug?*/
- CGA_BackBufferToRealFull();
- CGA_ColorSelect(0x30);
+ cga_BackBufferToRealFull();
+ cga_ColorSelect(0x30);
right_button = 0;
if (!DrawPortrait(&pimage1, &x, &y, &width, &height))
@@ -2811,9 +2811,9 @@ static void AnimSaucer(void) {
height_prev -= (yy - 1);
/*scale the saucer*/
- CGA_ZoomInplaceXY(cur_image_pixels, width, height, ww, hh, xx, yy, backbuffer);
+ cga_ZoomInplaceXY(cur_image_pixels, width, height, ww, hh, xx, yy, backbuffer);
- baseofs = CGA_CalcXY(0, yy);
+ baseofs = cga_CalcXY(0, yy);
if (!scroll_done) {
/*scroll the saucer*/
@@ -2841,7 +2841,7 @@ static void AnimSaucer(void) {
ofs -= CGA_BYTES_PER_LINE;
}
- ofs2 = CGA_CalcXY(0, 200 - 1);
+ ofs2 = cga_CalcXY(0, 200 - 1);
for (i = 0; i < 108; i++) {
LiftLines(i + 1, backbuffer, ofs, frontbuffer, ofs2);
@@ -2850,8 +2850,8 @@ static void AnimSaucer(void) {
if ((ofs2 & CGA_ODD_LINES_OFS) != 0)
ofs2 -= CGA_BYTES_PER_LINE;
- WaitVBlank();
- WaitVBlank();
+ waitVBlank();
+ waitVBlank();
}
/*wipe 56 lines*/
@@ -2870,7 +2870,7 @@ static void AnimSaucer(void) {
ShowMirrored(height_prev + 1, baseofs);
height_prev = height_new;
- WaitVBlank();
+ waitVBlank();
for (i = delay; i--;) ; /*TODO: weak delay*/
delay += 500;
}
@@ -2900,11 +2900,11 @@ void TheEnd(void) {
while (!LoadFond())
AskDisk2();
JaggedZoom(backbuffer, frontbuffer);
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
} else {
while (!LoadSplash("PRES.BIN"))
AskDisk2();
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
}
}
@@ -2997,7 +2997,7 @@ uint16 SCR_63_LiftSpot6(void) {
zone_spots[6].ey -= 5;
BackupSpotsImages();
DrawPersons();
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
return 0;
}
@@ -3234,7 +3234,7 @@ uint16 CMD_2_PsiPowers(void) {
DrawHintsAndCursor(CGA_SCREENBUFFER);
} while (buttons == 0);
UndrawCursor(CGA_SCREENBUFFER);
- CGA_RestoreBackupImage(CGA_SCREENBUFFER);
+ cga_RestoreBackupImage(CGA_SCREENBUFFER);
return ScriptRerun;
}
@@ -3267,7 +3267,7 @@ uint16 CMD_4_EnergyLevel(void) {
anim = 41 + (script_byte_vars.psy_energy / 16);
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);
+ cga_BlitAndWait(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
}
do {
@@ -3342,7 +3342,7 @@ uint16 CMD_8_Timer(void) {
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);
+ cga_BlitAndWait(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
}
do {
@@ -3352,11 +3352,11 @@ uint16 CMD_8_Timer(void) {
char_draw_coords_x = 260 / 4;
char_draw_coords_y = 120;
- WaitVBlank();
- CGA_PrintChar(timer / (60 * 60) + 16, CGA_SCREENBUFFER);
- CGA_PrintChar((minutes & 1) ? 26 : 0, CGA_SCREENBUFFER); /*colon*/
- CGA_PrintChar(minutes / (60 * 10) + 16, CGA_SCREENBUFFER);
- CGA_PrintChar(minutes / 60 + 16, CGA_SCREENBUFFER);
+ waitVBlank();
+ cga_PrintChar(timer / (60 * 60) + 16, CGA_SCREENBUFFER);
+ cga_PrintChar((minutes & 1) ? 26 : 0, CGA_SCREENBUFFER); /*colon*/
+ cga_PrintChar(minutes / (60 * 10) + 16, CGA_SCREENBUFFER);
+ cga_PrintChar(minutes / 60 + 16, CGA_SCREENBUFFER);
PollInputButtonsOnly();
} while (buttons == 0);
@@ -3390,7 +3390,7 @@ uint16 CMD_A_PsiSolarEyes(void) {
if (zone_palette == 14) {
RedrawRoomStatics(script_byte_vars.zone_room, zone_palette);
zone_palette = 0;
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
}
the_command = Swap16(script_word_vars.wvar_AA);
@@ -3418,7 +3418,7 @@ void DrawStickyNet(void) {
w = room_bounds_rect.ex - x;
h = room_bounds_rect.ey - y;
- ofs = CGA_CalcXY_p(x, y);
+ ofs = cga_CalcXY_p(x, y);
/*16x30 is the net sprite size*/
@@ -3444,7 +3444,7 @@ uint16 CMD_B_PsiStickyFingers(void) {
SelectCursor(CURSOR_FLY);
MenuLoop(0, 0);
playSound(224);
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
RestoreScreenOfSpecialRoom();
if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(0 * 2) == 0)
@@ -3533,17 +3533,17 @@ uint16 CMD_E_PsiZoneScan(void) {
IFGM_PlaySample(26);
- offs = CGA_CalcXY_p(room_bounds_rect.sx, room_bounds_rect.sy);
+ offs = cga_CalcXY_p(room_bounds_rect.sx, room_bounds_rect.sy);
w = room_bounds_rect.ex - room_bounds_rect.sx;
h = room_bounds_rect.ey - room_bounds_rect.sy;
for (y = room_bounds_rect.sy; h; y++, h--) {
spot_t *spot;
for (x = 0; x < w; x++) frontbuffer[offs + x] = ~frontbuffer[offs + x];
- CGA_blitToScreen(offs, w, 1);
- WaitVBlank();
+ cga_blitToScreen(offs, w, 1);
+ waitVBlank();
for (x = 0; x < w; x++) frontbuffer[offs + x] = ~frontbuffer[offs + x];
- CGA_blitToScreen(offs, w, 1);
+ cga_blitToScreen(offs, w, 1);
for (spot = zone_spots; spot != zone_spots_end; spot++) {
if ((spot->flags & ~(SPOTFLG_40 | 7)) == (SPOTFLG_20 | SPOTFLG_8) && spot->sy == y) {
@@ -3787,19 +3787,19 @@ uint16 CMD_13_ActivateFountain(void) {
script_byte_vars.bvar_6A = 1;
for (i = 0; i < 10; i++) {
DrawRoomStaticObject(water1, &x, &y, &w, &h);
- WaitVBlank();
- CGA_BackBufferToRealFull();
+ waitVBlank();
+ cga_BackBufferToRealFull();
for (j = 0; j < 0x1FFF; j++) ; /*TODO: weak delay*/
DrawRoomStaticObject(water2, &x, &y, &w, &h);
- WaitVBlank();
- CGA_BackBufferToRealFull();
+ waitVBlank();
+ cga_BackBufferToRealFull();
for (j = 0; j < 0x1FFF; j++) ; /*TODO: weak delay*/
}
DrawRoomStaticObject(headl, &x, &y, &w, &h);
DrawRoomStaticObject(headr, &x, &y, &w, &h);
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
return 0;
}
@@ -3816,7 +3816,7 @@ uint16 CMD_14_VortAppear(void) {
next_vorts_cmd = 0xA015;
BlitSpritesToBackBuffer();
DrawPersons();
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
next_vorts_ticks = Swap16(script_word_vars.timer_ticks2) + 5;
return 0;
}
@@ -3952,7 +3952,7 @@ uint16 CMD_19_AspirantAppear(void) {
AnimateSpot(&anim23);
BlitSpritesToBackBuffer();
DrawPersons();
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
if (script_byte_vars.aspirant_flags == 5) {
the_command = 0xC029;
script_byte_vars.aspirant_flags = 0;
@@ -4027,7 +4027,7 @@ uint16 CMD_1E_TurkeyAppear(void) {
next_turkey_cmd = 0xA01F;
BlitSpritesToBackBuffer();
DrawPersons();
- CGA_BackBufferToRealFull();
+ cga_BackBufferToRealFull();
next_turkey_ticks = Swap16(script_word_vars.timer_ticks2) + 5;
return 0;
}
diff --git a/engines/chamber/timer.cpp b/engines/chamber/timer.cpp
index 8bd182b4c48..a5bcf3be5a5 100644
--- a/engines/chamber/timer.cpp
+++ b/engines/chamber/timer.cpp
@@ -39,7 +39,7 @@ void animateGauss(byte *target) {
phase = (phase + 1) % 4;
script_byte_vars.gauss_phase = phase;
sprite = gauss_data + 8 + phase * (8 * 30);
- CGA_Blit(sprite, 8, 8, 30, target, 80); /*draw to 0:4*/
+ cga_Blit(sprite, 8, 8, 30, target, 80); /*draw to 0:4*/
}
void timerCallback(void *refCon) {
Commit: d0eb47fe785b70f24c804651092b0a6fd4c38f9c
https://github.com/scummvm/scummvm/commit/d0eb47fe785b70f24c804651092b0a6fd4c38f9c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Renames in cursor.cpp
Changed paths:
engines/chamber/cursor.cpp
engines/chamber/cursor.h
engines/chamber/input.cpp
engines/chamber/invent.cpp
engines/chamber/kult.cpp
engines/chamber/menu.cpp
engines/chamber/room.cpp
engines/chamber/script.cpp
diff --git a/engines/chamber/cursor.cpp b/engines/chamber/cursor.cpp
index fd99920be6f..dfec23e32ff 100644
--- a/engines/chamber/cursor.cpp
+++ b/engines/chamber/cursor.cpp
@@ -64,7 +64,7 @@ byte cursorImage[CURSOR_WIDTH * CURSOR_HEIGHT];
/*
Select cursor shape and its hotspot
*/
-void SelectCursor(uint16 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;
@@ -98,29 +98,29 @@ void SelectCursor(uint16 num) {
/*
Build cursor sprite for its current pixel-grained position
*/
-void UpdateCursor(void) {
+void updateCursor(void) {
}
/*
Draw cursor sprite and backup background pixels
*/
-void DrawCursor(byte *target) {
+void drawCursor(byte *target) {
g_system->updateScreen();
}
/*
Restore background pixels under cursor
*/
-void UndrawCursor(byte *target) {
+void undrawCursor(byte *target) {
}
/*
Restore pixels under cursor and update cursor sprite
*/
-void UpdateUndrawCursor(byte *target) {
+void updateUndrawCursor(byte *target) {
/*TODO: does this call order makes any sense?*/
- UpdateCursor();
- UndrawCursor(target);
+ updateCursor();
+ undrawCursor(target);
}
} // End of namespace Chamber
diff --git a/engines/chamber/cursor.h b/engines/chamber/cursor.h
index 4f5a594a152..c69633e6cc1 100644
--- a/engines/chamber/cursor.h
+++ b/engines/chamber/cursor.h
@@ -49,11 +49,11 @@ extern byte *cursor_shape;
extern byte cursor_anim_ticks;
extern byte cursor_anim_phase;
-void SelectCursor(uint16 num);
-void UpdateCursor(void);
-void DrawCursor(byte *target);
-void UndrawCursor(byte *target);
-void UpdateUndrawCursor(byte *target);
+void selectCursor(uint16 num);
+void updateCursor(void);
+void drawCursor(byte *target);
+void undrawCursor(byte *target);
+void updateUndrawCursor(byte *target);
} // End of namespace Chamber
diff --git a/engines/chamber/input.cpp b/engines/chamber/input.cpp
index bfceb75714a..59c8d5d995c 100644
--- a/engines/chamber/input.cpp
+++ b/engines/chamber/input.cpp
@@ -241,8 +241,8 @@ void PollInput(void) {
void ProcessInput(void) {
PollInput();
- UpdateCursor();
- DrawCursor(frontbuffer);
+ updateCursor();
+ drawCursor(frontbuffer);
}
void KeyboardIsr() {
diff --git a/engines/chamber/invent.cpp b/engines/chamber/invent.cpp
index 016c7049a70..7dc4df7e67e 100644
--- a/engines/chamber/invent.cpp
+++ b/engines/chamber/invent.cpp
@@ -115,7 +115,7 @@ void OpenInventory(uint16 filtermask, uint16 filtervalue) {
cga_BackupImageReal(cga_CalcXY_p(232 / 4, 56), 64 / 4, 64);
DrawInventoryBox(filtermask, filtervalue);
if (inv_count != 0) {
- SelectCursor(CURSOR_FINGER);
+ selectCursor(CURSOR_FINGER);
ProcessInput();
do {
PollInput();
@@ -124,7 +124,7 @@ void OpenInventory(uint16 filtermask, uint16 filtervalue) {
DrawCommandHint();
DrawHintsAndCursor(frontbuffer);
} while (buttons == 0);
- UndrawCursor(frontbuffer);
+ undrawCursor(frontbuffer);
}
cga_RestoreImage(scratch_mem2, frontbuffer);
playSound(20);
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 8efbc25182f..46a4402c16f 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -116,11 +116,11 @@ void GameLoop(byte *target) {
the_command = 0;
if (IsCursorInRect(&room_bounds_rect)) {
- SelectCursor(CURSOR_TARGET);
+ selectCursor(CURSOR_TARGET);
command_hint = 100;
SelectSpotCursor();
} else {
- SelectCursor(CURSOR_FINGER);
+ selectCursor(CURSOR_FINGER);
object_hint = 117;
CheckMenuCommandHover();
}
@@ -165,7 +165,7 @@ void GameLoop(byte *target) {
process:
;
- UpdateUndrawCursor(target);
+ updateUndrawCursor(target);
RefreshSpritesData();
RunCommand();
BlitSpritesToBackBuffer();
@@ -174,7 +174,7 @@ process:
} else {
/*Player action*/
- UpdateUndrawCursor(target);
+ updateUndrawCursor(target);
RefreshSpritesData();
RunCommandKeepSp();
script_byte_vars.used_commands++;
diff --git a/engines/chamber/menu.cpp b/engines/chamber/menu.cpp
index 455c30721b8..015c0a20126 100644
--- a/engines/chamber/menu.cpp
+++ b/engines/chamber/menu.cpp
@@ -134,7 +134,7 @@ void ActionsMenu(byte **pinfo) {
for (i = 0; i < numchoices; i++)
DrawSpriteN(1, act_dot_rects[i].sx, act_dot_rects[i].sy, CGA_SCREENBUFFER);
- SelectCursor(CURSOR_FINGER);
+ selectCursor(CURSOR_FINGER);
ProcessInput();
choice = 0;
@@ -160,7 +160,7 @@ void ActionsMenu(byte **pinfo) {
DrawCommandHint(); /*to backbuffer*/
DrawHintsAndCursor(CGA_SCREENBUFFER);
} while (buttons == 0);
- UndrawCursor(CGA_SCREENBUFFER);
+ undrawCursor(CGA_SCREENBUFFER);
if (the_command != 0xFFFF) {
playSound(19);
@@ -189,11 +189,11 @@ void MenuLoop(byte spotmask, byte spotvalue) {
DrawObjectHint();
DrawHintsAndCursor(frontbuffer);
} while (buttons == 0);
- UndrawCursor(frontbuffer);
+ undrawCursor(frontbuffer);
}
void ProcessMenu(void) {
- SelectCursor(CURSOR_BODY);
+ selectCursor(CURSOR_BODY);
MenuLoop(SPOTFLG_80 | SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8, SPOTFLG_80 | SPOTFLG_10);
}
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index 46daa96041c..31154fe120f 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -1622,11 +1622,11 @@ void DrawSpots(byte *target) {
zone_spr_index = spridx;
/*TODO: subclass spot_t from rect_t*/
if (DrawZoneAniSprite((rect_t *)spot, (spot - zone_spots) + 1, backbuffer)) {
- UpdateCursor();
+ updateCursor();
waitVBlank();
- UndrawCursor(target);
+ undrawCursor(target);
cga_CopyScreenBlock(backbuffer, zsprite_w, zsprite_h, target, zsprite_draw_ofs);
- DrawCursor(target);
+ drawCursor(target);
cga_RestoreImage(sprites_list[zone_spr_index - 1], backbuffer);
return;
}
@@ -1651,9 +1651,9 @@ void AnimateSpots(byte *target) {
Draw cursor and hints text on screen
*/
void DrawHintsAndCursor(byte *target) {
- UpdateCursor();
+ updateCursor();
waitVBlank();
- UndrawCursor(target);
+ undrawCursor(target);
if (object_hint != last_object_hint) {
ShowObjectHint(target);
last_object_hint = object_hint;
@@ -1664,7 +1664,7 @@ void DrawHintsAndCursor(byte *target) {
last_command_hint = command_hint;
}
- DrawCursor(target);
+ drawCursor(target);
}
/*
@@ -1746,7 +1746,7 @@ void UpdateProtozorqs(void) {
if (script_byte_vars.zone_area == script_byte_vars.bvar_3F) {
static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35, { { 0, 0 } }};
- UpdateUndrawCursor(frontbuffer);
+ updateUndrawCursor(frontbuffer);
RefreshSpritesData();
HidePerson(PersonOffset(kPersProtozorq14));
HidePerson(PersonOffset(kPersProtozorq5));
@@ -1754,13 +1754,13 @@ void UpdateProtozorqs(void) {
HidePerson(PersonOffset(kPersProtozorq13));
AnimateSpot(&anim35);
BlitSpritesToBackBuffer();
- DrawCursor(frontbuffer);
+ drawCursor(frontbuffer);
return;
}
if (script_byte_vars.zone_area == script_byte_vars.bvar_40) {
static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34, { { 0, 0 } }};
- UpdateUndrawCursor(frontbuffer);
+ updateUndrawCursor(frontbuffer);
RefreshSpritesData();
SelectPerson(PersonOffset(kPersProtozorq14));
@@ -1779,7 +1779,7 @@ void UpdateProtozorqs(void) {
DrawPersons();
cga_BackBufferToRealFull();
BlitSpritesToBackBuffer();
- DrawCursor(frontbuffer);
+ drawCursor(frontbuffer);
if (script_byte_vars.zapstiks_owned != 0)
script_word_vars.next_protozorqs_cmd = BE(0xC1FD);
@@ -1797,18 +1797,18 @@ void UpdateProtozorqs(void) {
if (script_byte_vars.zone_area == script_byte_vars.bvar_3F) {
static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35, { { 0, 0 } }};
- UpdateUndrawCursor(frontbuffer);
+ updateUndrawCursor(frontbuffer);
RefreshSpritesData();
HidePerson(PersonOffset(kPersProtozorq14));
AnimateSpot(&anim35);
BlitSpritesToBackBuffer();
- DrawCursor(frontbuffer);
+ drawCursor(frontbuffer);
return;
}
if (script_byte_vars.zone_area == script_byte_vars.bvar_40) {
static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34, { { 0, 0 } }};
- UpdateUndrawCursor(frontbuffer);
+ updateUndrawCursor(frontbuffer);
RefreshSpritesData();
SelectPerson(PersonOffset(kPersProtozorq14));
@@ -1817,7 +1817,7 @@ void UpdateProtozorqs(void) {
DrawPersons();
cga_BackBufferToRealFull();
BlitSpritesToBackBuffer();
- DrawCursor(frontbuffer);
+ drawCursor(frontbuffer);
return;
}
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 7a1fec3b4c6..0f19a3d4428 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -1718,7 +1718,7 @@ uint16 SCR_28_MenuLoop(void) {
mask = *script_ptr++;
value = *script_ptr++;
- SelectCursor(cursor);
+ selectCursor(cursor);
MenuLoop(mask, value);
@@ -3210,7 +3210,7 @@ uint16 SCR_6A_Unused(void) {
Open room's items inventory
*/
uint16 CMD_1_RoomObjects(void) {
- UpdateUndrawCursor(CGA_SCREENBUFFER);
+ updateUndrawCursor(CGA_SCREENBUFFER);
inv_bgcolor = 0xAA;
OpenInventory((0xFF << 8) | ITEMFLG_ROOM, (script_byte_vars.zone_area << 8) | ITEMFLG_ROOM);
return ScriptRerun;
@@ -3225,7 +3225,7 @@ uint16 CMD_2_PsiPowers(void) {
ProcessInput();
do {
PollInput();
- SelectCursor(CURSOR_FINGER);
+ selectCursor(CURSOR_FINGER);
CheckPsiCommandHover();
if (command_hint != 100)
command_hint += 109;
@@ -3233,7 +3233,7 @@ uint16 CMD_2_PsiPowers(void) {
DrawCommandHint();
DrawHintsAndCursor(CGA_SCREENBUFFER);
} while (buttons == 0);
- UndrawCursor(CGA_SCREENBUFFER);
+ undrawCursor(CGA_SCREENBUFFER);
cga_RestoreBackupImage(CGA_SCREENBUFFER);
return ScriptRerun;
}
@@ -3242,7 +3242,7 @@ uint16 CMD_2_PsiPowers(void) {
Open normal inventory box
*/
uint16 CMD_3_Posessions(void) {
- UpdateUndrawCursor(CGA_SCREENBUFFER);
+ updateUndrawCursor(CGA_SCREENBUFFER);
inv_bgcolor = 0x55;
OpenInventory(ITEMFLG_OWNED, ITEMFLG_OWNED);
return ScriptRerun;
@@ -3441,7 +3441,7 @@ uint16 CMD_B_PsiStickyFingers(void) {
BackupScreenOfSpecialRoom();
DrawStickyNet();
- SelectCursor(CURSOR_FLY);
+ selectCursor(CURSOR_FLY);
MenuLoop(0, 0);
playSound(224);
cga_BackBufferToRealFull();
@@ -3578,7 +3578,7 @@ uint16 CMD_F_PsiPsiShift(void) {
return ScriptRerun;
}
- SelectCursor(CURSOR_GRAB);
+ selectCursor(CURSOR_GRAB);
MenuLoop(0, 0);
BackupScreenOfSpecialRoom();
playSound(25);
Commit: 7672a5632e3691c931925dfd9013d3ab9fbdd282
https://github.com/scummvm/scummvm/commit/7672a5632e3691c931925dfd9013d3ab9fbdd282
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Renames in dialog.cpp
Changed paths:
engines/chamber/common.h
engines/chamber/dialog.cpp
engines/chamber/dialog.h
engines/chamber/input.cpp
engines/chamber/kult.cpp
engines/chamber/portrait.cpp
engines/chamber/print.cpp
engines/chamber/room.cpp
engines/chamber/script.cpp
diff --git a/engines/chamber/common.h b/engines/chamber/common.h
index 4f9d4d1ffc4..a26a3dda328 100644
--- a/engines/chamber/common.h
+++ b/engines/chamber/common.h
@@ -31,7 +31,7 @@ namespace Chamber {
#define TODO(s) \
{ \
printf(s); \
- PromptWait(); \
+ promptWait(); \
for(;;) ; \
}
diff --git a/engines/chamber/dialog.cpp b/engines/chamber/dialog.cpp
index c2a6e748c78..fdd01473ce4 100644
--- a/engines/chamber/dialog.cpp
+++ b/engines/chamber/dialog.cpp
@@ -39,7 +39,7 @@ uint16 cur_dlg_index;
dirty_rect_t dirty_rects[MAX_DIRTY_RECT];
dirty_rect_t *last_dirty_rect = dirty_rects;
-void AddDirtyRect(byte kind, byte x, byte y, byte w, byte h, uint16 offs) {
+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*/
@@ -55,7 +55,7 @@ void AddDirtyRect(byte kind, byte x, byte y, byte w, byte h, uint16 offs) {
last_dirty_rect = r;
}
-void GetDirtyRect(int16 index, byte *kind, byte *x, byte *y, byte *w, byte *h, uint16 *offs, byte 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;
@@ -67,19 +67,19 @@ void GetDirtyRect(int16 index, byte *kind, byte *x, byte *y, byte *w, byte *h, u
script_byte_vars.dirty_rect_kind = dirty_rects[0].kind;
}
-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 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(int16 index, byte *kind, byte *x, byte *y, byte *w, byte *h, uint16 *offs) {
- GetDirtyRect(index - 1, kind, x, y, w, h, offs, DirtyRectSprite);
+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);
}
-int16 FindDirtyRectAndFree(byte kind, byte *x, byte *y, byte *w, byte *h, uint16 *offs) {
+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);
+ getDirtyRect(i, &kind, x, y, w, h, offs, DirtyRectFree);
return 1;
}
}
@@ -87,11 +87,11 @@ int16 FindDirtyRectAndFree(byte kind, byte *x, byte *y, byte *w, byte *h, uint16
}
/*Restore screen data from back buffer as specified by dirty rects of kind*/
-void PopDirtyRects(byte kind) {
+void popDirtyRects(byte kind) {
byte x, y;
byte width, height;
uint16 offs;
- while (FindDirtyRectAndFree(kind, &x, &y, &width, &height, &offs)) {
+ while (findDirtyRectAndFree(kind, &x, &y, &width, &height, &offs)) {
cga_CopyScreenBlock(backbuffer, width, height, frontbuffer, offs);
if (kind == DirtyRectBubble) {
/*pop bubble's spike*/
@@ -100,16 +100,16 @@ void PopDirtyRects(byte kind) {
}
}
-void DesciTextBox(uint16 x, uint16 y, uint16 width, byte *msg) {
+void desciTextBox(uint16 x, uint16 y, uint16 width, byte *msg) {
draw_x = x;
draw_y = y;
char_draw_max_width = width;
cga_DrawTextBox(msg, frontbuffer);
- AddDirtyRect(DirtyRectText, draw_x, draw_y, char_draw_max_width + 2, char_draw_coords_y - draw_y + 8, cga_CalcXY_p(draw_x, draw_y));
+ addDirtyRect(DirtyRectText, draw_x, draw_y, char_draw_max_width + 2, char_draw_coords_y - draw_y + 8, cga_CalcXY_p(draw_x, draw_y));
}
/*Draw dialog bubble with text and spike*/
-void DrawPersonBubble(byte x, byte y, byte flags, byte *msg) {
+void drawPersonBubble(byte x, byte y, byte flags, byte *msg) {
uint16 ofs;
byte w, h;
uint16 ww, nw;
@@ -176,10 +176,10 @@ void DrawPersonBubble(byte x, byte y, byte flags, byte *msg) {
break;
}
- AddDirtyRect(DirtyRectBubble, ofs >> 8, ofs & 255, w, h, cga_CalcXY_p(x, y));
+ addDirtyRect(DirtyRectBubble, ofs >> 8, ofs & 255, w, h, cga_CalcXY_p(x, y));
}
-void ShowPromptAnim(void) {
+void showPromptAnim(void) {
if (script_byte_vars.zone_index == 135)
return;
waitVBlank();
@@ -187,14 +187,14 @@ void ShowPromptAnim(void) {
cursor_anim_phase = ~cursor_anim_phase;
}
-void PromptWait(void) {
+void promptWait(void) {
cursor_anim_phase = 0;
do {
byte ticks = script_byte_vars.timer_ticks;
if ((ticks % 8) == 0 && ticks != cursor_anim_ticks) {
cursor_anim_ticks = ticks;
- ShowPromptAnim();
+ showPromptAnim();
}
PollInputButtonsOnly();
@@ -206,13 +206,13 @@ void PromptWait(void) {
} while (!buttons);
if (cursor_anim_phase)
- ShowPromptAnim();
+ showPromptAnim();
}
/*
Get string with index num from strings bank
*/
-byte *SeekToString(byte *bank, uint16 num) {
+byte *seekToString(byte *bank, uint16 num) {
byte len;
byte *p = bank;
@@ -231,7 +231,7 @@ byte *SeekToString(byte *bank, uint16 num) {
/*
Get string with index num from strings bank, with large string index support for scripts
*/
-byte *SeekToStringScr(byte *bank, uint16 num, byte **ptr) {
+byte *seekToStringScr(byte *bank, uint16 num, byte **ptr) {
byte len;
byte *p = bank;
diff --git a/engines/chamber/dialog.h b/engines/chamber/dialog.h
index 93bde9aca6e..1e11d90e202 100644
--- a/engines/chamber/dialog.h
+++ b/engines/chamber/dialog.h
@@ -57,18 +57,18 @@ extern dirty_rect_t *last_dirty_rect;
#define SPIKE_BUBRIGHT 0xC0
#define SPIKE_BUBLEFT 0xE0
-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 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(byte kind);
-void DrawPersonBubble(byte x, byte y, byte flags, byte *msg);
-void DesciTextBox(uint16 x, uint16 y, uint16 width, byte *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);
+void promptWait(void);
-byte *SeekToString(byte *bank, uint16 num);
-byte *SeekToStringScr(byte *bank, uint16 num, byte **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 59c8d5d995c..d35babded3c 100644
--- a/engines/chamber/input.cpp
+++ b/engines/chamber/input.cpp
@@ -149,7 +149,7 @@ int16 AskQuitGame(void) {
int16 quit = -1;
- byte *msg = SeekToString(desci_data, 411); /*DO YOU WANT TO QUIT ? (Y OR N).*/
+ byte *msg = seekToString(desci_data, 411); /*DO YOU WANT TO QUIT ? (Y OR N).*/
char_draw_max_width = 32;
draw_x = 1;
draw_y = 188;
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 46a4402c16f..5364f637cfb 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -54,7 +54,7 @@ uint16 cpu_speed_delay;
Prompt user to insert disk #2 to any drive
*/
void AskDisk2(void) {
- DrawMessage(SeekToString(vepci_data, 179), frontbuffer);
+ DrawMessage(seekToString(vepci_data, 179), frontbuffer);
}
void SaveToFile(char *filename, void *data, uint16 size) {
@@ -94,7 +94,7 @@ void Randomize(void) {
}
void TRAP() {
- PromptWait();
+ promptWait();
for (;;) ;
}
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index 63af42f4ad4..88198602ca9 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -277,7 +277,7 @@ int16 DrawPortrait(byte **desc, byte *x, byte *y, byte *width, byte *height) {
cur_image_size_w = *image++;
cur_image_pixels = image;
cur_image_offs = cga_CalcXY_p(cur_image_coords_x, cur_image_coords_y);
- AddDirtyRect(DirtyRectSprite, cur_image_coords_x, cur_image_coords_y, cur_image_size_w, cur_image_size_h, cur_image_offs);
+ addDirtyRect(DirtyRectSprite, cur_image_coords_x, cur_image_coords_y, cur_image_size_w, cur_image_size_h, cur_image_offs);
/*TODO: remove and use only globals?*/
*x = cur_image_coords_x;
@@ -356,7 +356,7 @@ void AnimPortrait(byte layer, byte index, byte delay) {
ani++;
LoadPortrait(&ani, ani + 3);
}
- GetDirtyRectAndSetSprite(layer, &kind, &x, &y, &width, &height, &offs);
+ getDirtyRectAndSetSprite(layer, &kind, &x, &y, &width, &height, &offs);
waitVBlank();
cga_BlitAndWait(cur_image_pixels, width, width, height, CGA_SCREENBUFFER, offs);
waitVBlankTimer();
diff --git a/engines/chamber/print.cpp b/engines/chamber/print.cpp
index 5142c8cfb90..be04d46d517 100644
--- a/engines/chamber/print.cpp
+++ b/engines/chamber/print.cpp
@@ -260,7 +260,7 @@ void DrawMessage(byte *msg, byte *target) {
cga_BackupImageReal(cga_CalcXY_p(x, y), char_draw_max_width + 2, char_draw_max_height); /*backup orig. screen data*/
cga_DrawTextBox(msg, target); /*draw box with text*/
- PromptWait(); /*wait keypress*/
+ promptWait(); /*wait keypress*/
cga_RestoreBackupImage(target); /*restore screen data*/
}
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index 31154fe120f..c2b153bad12 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -602,7 +602,7 @@ void AnimateSpot(const animdesc_t *info) {
cursor_x = found_spot->sx * 4;
cursor_y = found_spot->sy;
if (info->params.desc)
- DrawMessage(SeekToString(desci_data, info->params.desc), frontbuffer);
+ DrawMessage(seekToString(desci_data, info->params.desc), frontbuffer);
playAnim(info->index & ~ANIMFLG_USESPOT, found_spot->sx, found_spot->sy);
} else {
@@ -918,9 +918,9 @@ void DrawZoneSpots(void) {
}
void RefreshZone(void) {
- PopDirtyRects(DirtyRectSprite);
- PopDirtyRects(DirtyRectBubble);
- PopDirtyRects(DirtyRectText);
+ popDirtyRects(DirtyRectSprite);
+ popDirtyRects(DirtyRectBubble);
+ popDirtyRects(DirtyRectText);
if (!skip_zone_transition && !right_button)
DrawBackground(CGA_SCREENBUFFER, 1);
@@ -953,7 +953,7 @@ void DrawObjectHint(void) {
char_draw_coords_x = room_hint_bar_coords_x;
char_draw_coords_y = room_hint_bar_coords_y;
char_xlat_table = chars_color_wonb;
- PrintStringCentered(SeekToString(motsi_data, object_hint), backbuffer);
+ PrintStringCentered(seekToString(motsi_data, object_hint), backbuffer);
#ifdef DEBUG_ZONE
cga_PrintChar(0x20, backbuffer);
@@ -980,7 +980,7 @@ void DrawCommandHint(void) {
char_draw_coords_x = cmd_hint_bar_coords_x;
char_draw_coords_y = cmd_hint_bar_coords_y;
char_xlat_table = chars_color_wonb;
- PrintStringCentered(SeekToString(vepci_data, command_hint), backbuffer);
+ PrintStringCentered(seekToString(vepci_data, command_hint), backbuffer);
}
/*
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 0f19a3d4428..d6db3ce3db1 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -108,14 +108,14 @@ enum CommandStatus {
uint16 CMD_TRAP(void) {
printf("CMD TRAP\n");
- PromptWait();
+ promptWait();
for (;;) ;
return 0;
}
uint16 SCR_TRAP(void) {
printf("SCR TRAP 0x%02X @ 0x%lX\n", *script_ptr, script_ptr - templ_data);
- PromptWait();
+ promptWait();
for (;;) ;
return 0;
}
@@ -404,9 +404,9 @@ uint16 SCR_2D_Wait(void) {
/*
Show blinking prompt indicator and wait for a keypress
*/
-uint16 SCR_2E_PromptWait(void) {
+uint16 SCR_2E_promptWait(void) {
script_ptr++;
- PromptWait();
+ promptWait();
return 0;
}
@@ -472,7 +472,7 @@ uint16 LoadVar(byte **ptr, byte **varptr) {
}
if (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();
+ promptWait();
}
}
#endif
@@ -944,7 +944,7 @@ uint16 SCR_10_DrawPortraitZoomed(void) {
#if 0
/*TODO: debug wait*/
- PromptWait();
+ promptWait();
#endif
return 0;
@@ -963,7 +963,7 @@ uint16 SCR_19_HidePortraitLiftLeft(void) {
script_ptr++;
index = *script_ptr++;
- GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ getDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
@@ -1009,7 +1009,7 @@ uint16 SCR_1A_HidePortraitLiftRight(void) {
script_ptr++;
index = *script_ptr++;
- GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ getDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
@@ -1054,7 +1054,7 @@ uint16 SCR_1B_HidePortraitLiftUp(void) {
script_ptr++;
index = *script_ptr++;
- GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ getDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
@@ -1090,7 +1090,7 @@ uint16 SCR_1C_HidePortraitLiftDown(void) {
script_ptr++;
index = *script_ptr++;
- GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ getDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
@@ -1126,7 +1126,7 @@ uint16 SCR_1E_HidePortraitTwist(void) {
script_ptr++;
index = *script_ptr++;
- GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ getDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
@@ -1150,7 +1150,7 @@ uint16 SCR_1F_HidePortraitArc(void) {
script_ptr++;
index = *script_ptr++;
- GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ getDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
@@ -1174,7 +1174,7 @@ uint16 SCR_20_HidePortraitDots(void) {
script_ptr++;
index = *script_ptr++;
- GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ getDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
@@ -1586,9 +1586,9 @@ uint16 SCR_3_DrawItemBox(void) {
x = dirty_rects[0].x;
y = dirty_rects[0].y + 70;
- msg = SeekToString(desci_data, 274 + item->name);
+ msg = seekToString(desci_data, 274 + item->name);
- DesciTextBox(x, y, 18, msg);
+ desciTextBox(x, y, 18, msg);
DrawSpriteN(item->sprite, x, y + 1, frontbuffer);
return 0;
@@ -1597,16 +1597,16 @@ uint16 SCR_3_DrawItemBox(void) {
/*
Draw simple bubble with text
*/
-uint16 SCR_37_DesciTextBox(void) {
+uint16 SCR_37_desciTextBox(void) {
byte x, y, w;
byte *msg;
script_ptr++;
- msg = SeekToStringScr(desci_data, *script_ptr, &script_ptr);
+ msg = seekToStringScr(desci_data, *script_ptr, &script_ptr);
script_ptr++;
x = *script_ptr++;
y = *script_ptr++;
w = *script_ptr++;
- DesciTextBox(x, y, w, msg);
+ desciTextBox(x, y, w, msg);
return 0;
}
@@ -1739,7 +1739,7 @@ uint16 SCR_2A_PopDialogRect(void) {
script_ptr++;
index = *script_ptr++;
- GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ getDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs); /*TODO: implicit target*/
cga_CopyScreenBlock(backbuffer, 2, 21, CGA_SCREENBUFFER, offs = (x << 8) | y); /*TODO: implicit target*/
@@ -1753,7 +1753,7 @@ Restore screen data from back buffer as specified by dirty rect of kind dialog b
*/
uint16 SCR_2B_PopAllBubbles(void) {
script_ptr++;
- PopDirtyRects(DirtyRectBubble);
+ popDirtyRects(DirtyRectBubble);
return 0;
}
@@ -1770,7 +1770,7 @@ uint16 SCR_22_HidePortraitShatter(void) {
script_ptr++;
index = *script_ptr++;
- GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ getDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
@@ -1794,7 +1794,7 @@ uint16 SCR_23_HidePortrait(void) {
script_ptr++;
index = *script_ptr++;
- GetDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
+ getDirtyRectAndFree(index, &kind, &x, &y, &width, &height, &offs);
if (right_button) {
cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
return 0;
@@ -1831,7 +1831,7 @@ Restore screen data from back buffer for all portraits
*/
uint16 SCR_24_PopAllPortraits(void) {
script_ptr++;
- PopDirtyRects(DirtyRectSprite);
+ popDirtyRects(DirtyRectSprite);
return 0;
}
@@ -1840,7 +1840,7 @@ Restore screen data from back buffer for all text bubbles
*/
uint16 SCR_40_PopAllTextBoxes() {
script_ptr++;
- PopDirtyRects(DirtyRectText);
+ popDirtyRects(DirtyRectText);
return 0;
}
@@ -1904,7 +1904,7 @@ uint16 SCR_30_Fight(void) {
BlinkToWhite();
if (pers->name != 44 && pers->name != 56 && pers->name != 51) { /*VORT, MONKEY, TURKEY*/
- GetDirtyRectAndFree(1, &kind, &x, &y, &width, &height, &offs);
+ getDirtyRectAndFree(1, &kind, &x, &y, &width, &height, &offs);
cga_CopyScreenBlock(backbuffer, width, height, CGA_SCREENBUFFER, offs);
}
@@ -2308,7 +2308,7 @@ uint16 SCR_45_DeProfundisRoomEntry(void) {
sprofs = GetPuzzlSprite(119, 128 / 4, 94, &w, &h, &ofs);
cga_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
- PromptWait();
+ promptWait();
for (; h; h--) {
waitVBlank();
@@ -3014,7 +3014,7 @@ Draw text box
uint16 SCR_14_DrawDesc(void) {
byte *msg;
script_ptr++;
- msg = SeekToStringScr(desci_data, *script_ptr, &script_ptr);
+ msg = seekToStringScr(desci_data, *script_ptr, &script_ptr);
script_ptr++;
DrawMessage(msg, CGA_SCREENBUFFER);
@@ -3031,19 +3031,19 @@ uint16 SCR_17_DrawPersonThoughtBubbleDialog(void) {
byte x, y;
byte *msg;
script_ptr++;
- msg = SeekToStringScr(diali_data, *script_ptr, &script_ptr);
+ msg = seekToStringScr(diali_data, *script_ptr, &script_ptr);
script_ptr++;
x = found_spot->sx;
y = found_spot->sy;
if (x < 140 / 4)
- DrawPersonBubble(found_spot->ex, y - 40, SPIKE_BUBLEFT | 20, msg);
+ drawPersonBubble(found_spot->ex, y - 40, SPIKE_BUBLEFT | 20, msg);
else
- DrawPersonBubble(x - 80 / 4, y - 40, SPIKE_BUBRIGHT | 20, msg);
+ drawPersonBubble(x - 80 / 4, y - 40, SPIKE_BUBRIGHT | 20, msg);
- PromptWait();
- PopDirtyRects(DirtyRectBubble);
+ promptWait();
+ popDirtyRects(DirtyRectBubble);
return 0;
}
@@ -3051,23 +3051,23 @@ uint16 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
*/
-uint16 SCR_61_DrawPersonBubbleDialog(void) {
+uint16 SCR_61_drawPersonBubbleDialog(void) {
byte x, y;
byte *msg;
script_ptr++;
- msg = SeekToStringScr(diali_data, *script_ptr, &script_ptr);
+ msg = seekToStringScr(diali_data, *script_ptr, &script_ptr);
script_ptr++;
x = found_spot->sx;
y = found_spot->sy;
if (x < 140 / 4)
- DrawPersonBubble(found_spot->ex, y - 40, SPIKE_DNLEFT | 20, msg);
+ drawPersonBubble(found_spot->ex, y - 40, SPIKE_DNLEFT | 20, msg);
else
- DrawPersonBubble(x - 80 / 4, y - 40, SPIKE_DNRIGHT | 20, msg);
+ drawPersonBubble(x - 80 / 4, y - 40, SPIKE_DNRIGHT | 20, msg);
- PromptWait();
- PopDirtyRects(DirtyRectBubble);
+ promptWait();
+ popDirtyRects(DirtyRectBubble);
return 0;
}
@@ -3118,10 +3118,10 @@ uint16 SCR_27_DrawGaussBubble(void) {
byte *msg;
script_ptr++;
- msg = SeekToStringScr(diali_data, *script_ptr, &script_ptr);
+ msg = seekToStringScr(diali_data, *script_ptr, &script_ptr);
script_ptr++;
- DrawPersonBubble(32 / 4, 20, 15, msg);
+ drawPersonBubble(32 / 4, 20, 15, msg);
return 0;
}
@@ -3132,7 +3132,7 @@ uint16 SCR_29_DialiTextBox(void) {
byte x, y, f;
byte *msg;
script_ptr++;
- msg = SeekToStringScr(diali_data, *script_ptr, &script_ptr);
+ msg = seekToStringScr(diali_data, *script_ptr, &script_ptr);
cur_dlg_index = cur_str_index; /*TODO: useless?*/
script_ptr++;
@@ -3140,7 +3140,7 @@ uint16 SCR_29_DialiTextBox(void) {
y = *script_ptr++;
f = *script_ptr++;
- DrawPersonBubble(x, y, f, msg);
+ drawPersonBubble(x, y, f, msg);
return 0;
}
@@ -3257,8 +3257,8 @@ uint16 CMD_4_EnergyLevel(void) {
byte *image = energy_image;
byte anim = 40;
- PopDirtyRects(DirtyRectSprite);
- PopDirtyRects(DirtyRectBubble);
+ popDirtyRects(DirtyRectSprite);
+ popDirtyRects(DirtyRectBubble);
cur_dlg_index = 0;
ifgm_flag2 = ~0;
@@ -3277,7 +3277,7 @@ uint16 CMD_4_EnergyLevel(void) {
PollInputButtonsOnly();
} while (buttons == 0);
- PopDirtyRects(DirtyRectSprite);
+ popDirtyRects(DirtyRectSprite);
ifgm_flag2 = 0;
IFGM_StopSample();
@@ -3360,7 +3360,7 @@ uint16 CMD_8_Timer(void) {
PollInputButtonsOnly();
} while (buttons == 0);
- PopDirtyRects(DirtyRectSprite);
+ popDirtyRects(DirtyRectSprite);
return 0;
}
@@ -3646,13 +3646,13 @@ uint16 CMD_11_PsiTuneIn(void) {
return ScriptRerun;
}
- msg = SeekToString(diali_data, command);
+ msg = seekToString(diali_data, command);
cur_dlg_index = cur_str_index; /*TODO: useless?*/
- DrawPersonBubble(32 / 4, 20, 15, msg);
+ drawPersonBubble(32 / 4, 20, 15, msg);
- PromptWait();
- PopDirtyRects(DirtyRectBubble);
+ promptWait();
+ popDirtyRects(DirtyRectBubble);
return 0;
}
@@ -3920,8 +3920,8 @@ uint16 CMD_18_AspirantLeave(void) {
/*TODO: check me*/
static const animdesc_t anim33 = {ANIMFLG_USESPOT | 33, { { 0, 0 } }};
- PopDirtyRects(DirtyRectSprite);
- PopDirtyRects(DirtyRectText);
+ popDirtyRects(DirtyRectSprite);
+ popDirtyRects(DirtyRectText);
aspirant_ptr->area = 0;
script_word_vars.next_aspirant_cmd = BE(0);
@@ -3943,7 +3943,7 @@ uint16 CMD_19_AspirantAppear(void) {
/*TODO: check me*/
static const animdesc_t anim23 = {ANIMFLG_USESPOT | 23, { { 0, 0 } }};
- PopDirtyRects(DirtyRectSprite);
+ popDirtyRects(DirtyRectSprite);
aspirant_ptr->area = script_byte_vars.zone_area;
script_word_vars.next_aspirant_cmd = BE(0xA018); /*leave*/
script_byte_vars.check_used_commands = 3;
@@ -3994,20 +3994,20 @@ uint16 CMD_1B_Holo(void) {
playAnim(42, x + 4 / 4, y + 6);
num = 321 + ((Swap16(script_word_vars.timer_ticks2) < 60 * 60) ? 0 : 4) + (script_byte_vars.rand_value % 4);
- msg = SeekToString(diali_data, num);
+ msg = seekToString(diali_data, num);
cur_dlg_index = cur_str_index; /*TODO: useless?*/
if (x < 140 / 4)
- DrawPersonBubble(x + 32 / 4, y - 40, SPIKE_DNLEFT | 20, msg);
+ drawPersonBubble(x + 32 / 4, y - 40, SPIKE_DNLEFT | 20, msg);
else
- DrawPersonBubble(x - 92 / 4, y - 40, SPIKE_DNRIGHT | 20, msg);
+ drawPersonBubble(x - 92 / 4, y - 40, SPIKE_DNRIGHT | 20, msg);
IFGM_PlaySfx(0);
playAnim(43, x, y);
- PromptWait();
- PopDirtyRects(DirtyRectBubble);
+ promptWait();
+ popDirtyRects(DirtyRectBubble);
IFGM_PlaySample(225);
@@ -4084,21 +4084,21 @@ uint16 CMD_21_VortTalk(void) {
else
num = 35;
- msg = SeekToString(diali_data, num);
+ msg = seekToString(diali_data, num);
cur_dlg_index = cur_str_index; /*TODO: useless?*/
x = found_spot->sx;
y = found_spot->sy;
if (x < 140 / 4)
- DrawPersonBubble(found_spot->ex, y - 40, SPIKE_DNLEFT | 20, msg);
+ drawPersonBubble(found_spot->ex, y - 40, SPIKE_DNLEFT | 20, msg);
else
- DrawPersonBubble(x - 80 / 4, y - 40, SPIKE_DNRIGHT | 20, msg);
+ drawPersonBubble(x - 80 / 4, y - 40, SPIKE_DNRIGHT | 20, msg);
IFGM_PlaySfx(0);
- PromptWait();
- PopDirtyRects(DirtyRectBubble);
+ promptWait();
+ popDirtyRects(DirtyRectBubble);
return 0;
}
@@ -4235,7 +4235,7 @@ cmdhandler_t script_handlers[] = {
SCR_2B_PopAllBubbles,
SCR_2C_Wait4,
SCR_2D_Wait,
- SCR_2E_PromptWait,
+ SCR_2E_promptWait,
SCR_2F_LootAspirantsItem,
SCR_30_Fight, /*30*/
SCR_31_Fight2,
@@ -4244,7 +4244,7 @@ cmdhandler_t script_handlers[] = {
SCR_34_Call,
SCR_35_Ret,
SCR_36_ChangeZone,
- SCR_37_DesciTextBox,
+ SCR_37_desciTextBox,
SCR_38_PlayAnim,
SCR_39_AnimRoomDoorOpen,
SCR_3A_AnimRoomDoorClose,
@@ -4286,7 +4286,7 @@ cmdhandler_t script_handlers[] = {
SCR_5E_SelectTempPalette,
SCR_5F_DrawRoomObjectBack,
SCR_60_ReviveCadaver, /*60*/
- SCR_61_DrawPersonBubbleDialog,
+ SCR_61_drawPersonBubbleDialog,
SCR_62_PsiReaction,
SCR_63_LiftSpot6,
SCR_64_DrawBoxAroundSpot,
@@ -4393,7 +4393,7 @@ again:;
res = RunScript(templ_data + the_command);
break;
case 0x9000:
- DrawMessage(SeekToString(desci_data, cmd), CGA_SCREENBUFFER);
+ DrawMessage(seekToString(desci_data, cmd), CGA_SCREENBUFFER);
break;
case 0xA000:
case 0xB000:
Commit: 505459a8a3a46d7dfa4125cb8ef00a8a64c7c504
https://github.com/scummvm/scummvm/commit/505459a8a3a46d7dfa4125cb8ef00a8a64c7c504
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Renames in input.h and invent.h
Changed paths:
engines/chamber/cga.cpp
engines/chamber/dialog.cpp
engines/chamber/input.cpp
engines/chamber/input.h
engines/chamber/invent.cpp
engines/chamber/invent.h
engines/chamber/kult.cpp
engines/chamber/menu.cpp
engines/chamber/script.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 57acfbef458..9fc97f8dba6 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -150,7 +150,7 @@ void switchToTextMode(void) {
}
void waitVBlank(void) {
- PollInput();
+ pollInput();
g_system->delayMillis(10);
}
diff --git a/engines/chamber/dialog.cpp b/engines/chamber/dialog.cpp
index fdd01473ce4..42b1fa711e2 100644
--- a/engines/chamber/dialog.cpp
+++ b/engines/chamber/dialog.cpp
@@ -196,7 +196,7 @@ void promptWait(void) {
cursor_anim_ticks = ticks;
showPromptAnim();
}
- PollInputButtonsOnly();
+ pollInputButtonsOnly();
if (g_vm->_shouldQuit)
break;
diff --git a/engines/chamber/input.cpp b/engines/chamber/input.cpp
index d35babded3c..1589c6258b0 100644
--- a/engines/chamber/input.cpp
+++ b/engines/chamber/input.cpp
@@ -55,7 +55,7 @@ byte accell_countdown;
uint16 accelleration = 1;
byte mouseButtons = 0;
-void PollDiscrete(void);
+void pollDiscrete(void);
byte ChamberEngine::readKeyboardChar() {
Common::Event event;
@@ -81,10 +81,10 @@ byte ChamberEngine::readKeyboardChar() {
}
}
-void ClearKeyboard(void) {
+void clearKeyboard(void) {
}
-void SetInputButtons(byte keys) {
+void setInputButtons(byte keys) {
if (keys & 2)
right_button = ~0;
if (keys & 1)
@@ -93,13 +93,13 @@ void SetInputButtons(byte keys) {
buttons_repeat = keys;
}
-byte PollMouse(void) {
- PollInput();
+byte pollMouse(void) {
+ pollInput();
return buttons;
}
-byte PollKeyboard(void) {
+byte pollKeyboard(void) {
byte direction = key_direction;
if (direction && direction == key_direction_old) {
if (++accell_countdown == 10) {
@@ -142,7 +142,7 @@ byte PollKeyboard(void) {
/*
Show game exit confirmation dialog and get user's input
*/
-int16 AskQuitGame(void) {
+int16 askQuitGame(void) {
/*EU version comes without requited text string*/
if (g_vm->getLanguage() != Common::EN_USA)
return 0;
@@ -181,11 +181,11 @@ int16 AskQuitGame(void) {
return quit;
}
-void PollInputButtonsOnly() {
- PollInput();
+void pollInputButtonsOnly() {
+ pollInput();
}
-void PollInput(void) {
+void pollInput(void) {
Common::Event event;
while (g_system->getEventManager()->pollEvent(event)) {
switch (event.type) {
@@ -194,7 +194,7 @@ void PollInput(void) {
mouseButtons |= 1;
else if (event.kbd.keycode == Common::KEYCODE_ESCAPE) {
if (g_vm->getLanguage() == Common::EN_USA) {
- if (AskQuitGame() != 0)
+ if (askQuitGame() != 0)
g_vm->_shouldQuit = true;
}
}
@@ -236,16 +236,16 @@ void PollInput(void) {
}
}
- SetInputButtons(mouseButtons);
+ setInputButtons(mouseButtons);
}
-void ProcessInput(void) {
- PollInput();
+void processInput(void) {
+ pollInput();
updateCursor();
drawCursor(frontbuffer);
}
-void KeyboardIsr() {
+void keyboardIsr() {
warning("STUB: KeyboardIsr()");
#if 0
byte scan, strobe;
@@ -290,11 +290,11 @@ void KeyboardIsr() {
#endif
}
-void InitInput(void) {
+void initInput(void) {
have_mouse = 1;
}
-void UninitInput(void) {
+void uninitInput(void) {
}
} // End of namespace Chamber
diff --git a/engines/chamber/input.h b/engines/chamber/input.h
index 2964fef63df..68a483f4026 100644
--- a/engines/chamber/input.h
+++ b/engines/chamber/input.h
@@ -34,21 +34,21 @@ extern volatile byte key_direction;
extern volatile byte key_code;
extern byte key_held;
-byte ReadKeyboardChar(void);
-void ClearKeyboard(void);
-byte GetKeyScan(void);
+byte readKeyboardChar(void);
+void clearKeyboard(void);
+byte getKeyScan(void);
-byte PollMouse(uint16 *curs_x, uint8 *curs_y);
-byte PollKeyboard(void);
-void SetInputButtons(byte keys);
+byte pollMouse(uint16 *curs_x, uint8 *curs_y);
+byte pollKeyboard(void);
+void setInputButtons(byte keys);
-void PollInput(void);
-void ProcessInput(void);
-void PollInputButtonsOnly(void);
-void ResetInput(void);
+void pollInput(void);
+void processInput(void);
+void pollInputButtonsOnly(void);
+void resetInput(void);
-void InitInput(void);
-void UninitInput(void);
+void initInput(void);
+void uninitInput(void);
} // End of namespace Chamber
diff --git a/engines/chamber/invent.cpp b/engines/chamber/invent.cpp
index 7dc4df7e67e..3a575d44cda 100644
--- a/engines/chamber/invent.cpp
+++ b/engines/chamber/invent.cpp
@@ -71,7 +71,7 @@ byte inv_bgcolor = 0; /*TODO: pass this as param?*/
Filter items and put them inventory box, then draw it if non-empty
filtermask/filtervalue specify area (in high 8 bits) and flags (in lower 8 bits)
*/
-void DrawInventoryBox(uint16 filtermask, uint16 filtervalue) {
+void drawInventoryBox(uint16 filtermask, uint16 filtervalue) {
int16 i;
byte count = 0;
for (i = 0; i < MAX_INV_ITEMS; i++) {
@@ -92,7 +92,7 @@ void DrawInventoryBox(uint16 filtermask, uint16 filtervalue) {
inv_count = count;
}
-void CheckInventoryItemHover(byte count) {
+void checkInventoryItemHover(byte count) {
int16 i;
for (i = 0; i < count; i++) {
if (IsCursorInRect((rect_t *)&inventory_spots[i])) {
@@ -110,16 +110,16 @@ void CheckInventoryItemHover(byte count) {
the_command = 0;
}
-void OpenInventory(uint16 filtermask, uint16 filtervalue) {
+void openInventory(uint16 filtermask, uint16 filtervalue) {
the_command = 0;
cga_BackupImageReal(cga_CalcXY_p(232 / 4, 56), 64 / 4, 64);
- DrawInventoryBox(filtermask, filtervalue);
+ drawInventoryBox(filtermask, filtervalue);
if (inv_count != 0) {
selectCursor(CURSOR_FINGER);
- ProcessInput();
+ processInput();
do {
- PollInput();
- CheckInventoryItemHover(inv_count);
+ pollInput();
+ checkInventoryItemHover(inv_count);
if (command_hint != last_command_hint)
DrawCommandHint();
DrawHintsAndCursor(frontbuffer);
diff --git a/engines/chamber/invent.h b/engines/chamber/invent.h
index 4e5cfcafabe..c9cf2326dec 100644
--- a/engines/chamber/invent.h
+++ b/engines/chamber/invent.h
@@ -28,9 +28,9 @@ namespace Chamber {
extern byte inv_count;
extern byte inv_bgcolor;
-void DrawInventoryBox(uint16 filtermask, uint16 filtervalue);
+void drawInventoryBox(uint16 filtermask, uint16 filtervalue);
-void OpenInventory(uint16 filtermask, uint16 filtervalue);
+void openInventory(uint16 filtermask, uint16 filtervalue);
} // End of namespace Chamber
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 5364f637cfb..0392a61a248 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -109,7 +109,7 @@ void GameLoop(byte *target) {
CleanupDroppedItems();
/* Get player input */
- PollInput();
+ pollInput();
if (g_vm->_shouldQuit)
return;
@@ -169,7 +169,7 @@ process:
RefreshSpritesData();
RunCommand();
BlitSpritesToBackBuffer();
- ProcessInput();
+ processInput();
DrawSpots(target);
} else {
/*Player action*/
@@ -183,7 +183,7 @@ process:
ResetAllPersons();
}
BlitSpritesToBackBuffer();
- ProcessInput();
+ processInput();
DrawSpots(target);
}
}
@@ -250,14 +250,14 @@ Common::Error ChamberEngine::run() {
ExitGame();
/* Wait for a keypress and show the language selection screen */
- ClearKeyboard();
+ clearKeyboard();
readKeyboardChar();
if (_shouldQuit)
return Common::kNoError;
cga_BackBufferToRealFull();
- ClearKeyboard();
+ clearKeyboard();
/* Wait for a valid language choice */
do {
@@ -289,7 +289,7 @@ Common::Error ChamberEngine::run() {
ExitGame();
/* Detect/Initialize input device */
- InitInput();
+ initInput();
/* Load graphics resources */
while (!LoadFond() || !LoadSpritesData() || !LoadPersData())
@@ -345,7 +345,7 @@ Common::Error ChamberEngine::run() {
BlitSpritesToBackBuffer();
/* Initialize cursor backup */
- ProcessInput();
+ processInput();
#ifdef DEBUG_ENDING
script_byte_vars.game_paused = 5;
@@ -359,7 +359,7 @@ Common::Error ChamberEngine::run() {
/*TODO: the following code is never executed since GameLoop is infinite (or the whole game is restarted) */
/* Release hardware */
- UninitInput();
+ uninitInput();
ExitGame();
diff --git a/engines/chamber/menu.cpp b/engines/chamber/menu.cpp
index 015c0a20126..ef42ac76c68 100644
--- a/engines/chamber/menu.cpp
+++ b/engines/chamber/menu.cpp
@@ -55,7 +55,7 @@ struct {
/*Handle keyboard keys in actions menu (to cycle through choices with directional keys)*/
byte PollKeyboardInActionsMenu(void) {
- PollInput();
+ pollInput();
if (!(key_direction & 0xF)) {
key_held = 0;
return key_code;
@@ -78,8 +78,8 @@ byte PollKeyboardInActionsMenu(void) {
}
/*Handle player input in actions menu*/
-void PollInputInActionsMenu(void) {
- PollInput();
+void pollInputInActionsMenu(void) {
+ pollInput();
}
/*Draw actions menu and process its choices*/
@@ -135,12 +135,12 @@ void ActionsMenu(byte **pinfo) {
DrawSpriteN(1, act_dot_rects[i].sx, act_dot_rects[i].sy, CGA_SCREENBUFFER);
selectCursor(CURSOR_FINGER);
- ProcessInput();
+ processInput();
choice = 0;
act_dot_rects_cur = act_dot_rects;
do {
- PollInputInActionsMenu();
+ pollInputInActionsMenu();
for (choice = 0; choice < numchoices; choice++) {
if (IsCursorInRect(&act_dot_rects[choice]))
@@ -181,9 +181,9 @@ void ActionsMenu(byte **pinfo) {
/*TODO: maybe rename to SpotsLoop*/
void MenuLoop(byte spotmask, byte spotvalue) {
- ProcessInput();
+ processInput();
do {
- PollInput();
+ pollInput();
CheckHotspots(spotmask, spotvalue);
if (object_hint != last_object_hint)
DrawObjectHint();
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index d6db3ce3db1..73e0a2ba21c 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -144,7 +144,7 @@ uint16 SCR_1_AspirantItemTrade(void) {
for (;;) {
inv_bgcolor = 0xFF;
- OpenInventory(0xFE, ITEMFLG_OWNED);
+ openInventory(0xFE, ITEMFLG_OWNED);
if (inv_count == 0) {
the_command = 0xC1BC;
@@ -229,7 +229,7 @@ uint16 SCR_2_RudeAspirantTrade(void) {
for (;;) {
inv_bgcolor = 0xFF;
- OpenInventory(0xFE, ITEMFLG_OWNED);
+ openInventory(0xFE, ITEMFLG_OWNED);
if (inv_count == 0) {
the_command = 0xC1C5;
@@ -2607,7 +2607,7 @@ uint16 SCR_51_SkullTraderItemTrade(void) {
old_script = script_ptr;
inv_bgcolor = 0xFF;
- OpenInventory(0xFF, ITEMFLG_OWNED);
+ openInventory(0xFF, ITEMFLG_OWNED);
status = 1;
if (inv_count != 0) {
@@ -2620,7 +2620,7 @@ uint16 SCR_51_SkullTraderItemTrade(void) {
((item_t *)(script_vars[ScrPool3_CurrentItem]))->flags = 0;
- OpenInventory(0xFF, ITEMFLG_TRADER);
+ openInventory(0xFF, ITEMFLG_TRADER);
status = 4;
if (the_command != 0) {
@@ -2893,7 +2893,7 @@ void TheEnd(void) {
script_byte_vars.zone_index = 135;
do {
- PollInputButtonsOnly();
+ pollInputButtonsOnly();
}
while(buttons == 0);
@@ -3212,7 +3212,7 @@ Open room's items inventory
uint16 CMD_1_RoomObjects(void) {
updateUndrawCursor(CGA_SCREENBUFFER);
inv_bgcolor = 0xAA;
- OpenInventory((0xFF << 8) | ITEMFLG_ROOM, (script_byte_vars.zone_area << 8) | ITEMFLG_ROOM);
+ openInventory((0xFF << 8) | ITEMFLG_ROOM, (script_byte_vars.zone_area << 8) | ITEMFLG_ROOM);
return ScriptRerun;
}
@@ -3222,9 +3222,9 @@ Open Psi Powers menu
uint16 CMD_2_PsiPowers(void) {
/*Psi powers bar*/
BackupAndShowSprite(3, 280 / 4, 40);
- ProcessInput();
+ processInput();
do {
- PollInput();
+ pollInput();
selectCursor(CURSOR_FINGER);
CheckPsiCommandHover();
if (command_hint != 100)
@@ -3244,7 +3244,7 @@ Open normal inventory box
uint16 CMD_3_Posessions(void) {
updateUndrawCursor(CGA_SCREENBUFFER);
inv_bgcolor = 0x55;
- OpenInventory(ITEMFLG_OWNED, ITEMFLG_OWNED);
+ openInventory(ITEMFLG_OWNED, ITEMFLG_OWNED);
return ScriptRerun;
}
@@ -3274,7 +3274,7 @@ uint16 CMD_4_EnergyLevel(void) {
IFGM_PlaySample(28);
AnimPortrait(1, anim, 10);
AnimPortrait(1, anim + 14, 10);
- PollInputButtonsOnly();
+ pollInputButtonsOnly();
} while (buttons == 0);
popDirtyRects(DirtyRectSprite);
@@ -3357,7 +3357,7 @@ uint16 CMD_8_Timer(void) {
cga_PrintChar((minutes & 1) ? 26 : 0, CGA_SCREENBUFFER); /*colon*/
cga_PrintChar(minutes / (60 * 10) + 16, CGA_SCREENBUFFER);
cga_PrintChar(minutes / 60 + 16, CGA_SCREENBUFFER);
- PollInputButtonsOnly();
+ pollInputButtonsOnly();
} while (buttons == 0);
popDirtyRects(DirtyRectSprite);
Commit: 885303ddea89457f776f444ddc303caea2be3cd9
https://github.com/scummvm/scummvm/commit/885303ddea89457f776f444ddc303caea2be3cd9
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Renames in portrait.h and print.h
Changed paths:
engines/chamber/dialog.cpp
engines/chamber/kult.cpp
engines/chamber/menu.cpp
engines/chamber/menu.h
engines/chamber/portrait.cpp
engines/chamber/portrait.h
engines/chamber/print.cpp
engines/chamber/print.h
engines/chamber/resdata.cpp
engines/chamber/room.cpp
engines/chamber/script.cpp
diff --git a/engines/chamber/dialog.cpp b/engines/chamber/dialog.cpp
index 42b1fa711e2..8bbfba0c0bb 100644
--- a/engines/chamber/dialog.cpp
+++ b/engines/chamber/dialog.cpp
@@ -118,7 +118,7 @@ void drawPersonBubble(byte x, byte y, byte flags, byte *msg) {
char_xlat_table = chars_color_bonw;
if (g_vm->getLanguage() == Common::EN_USA) {
- CalcStringSize(msg, &ww, &nw);
+ calcStringSize(msg, &ww, &nw);
if (ww >= char_draw_max_width)
char_draw_max_width = ww;
}
@@ -136,7 +136,7 @@ void drawPersonBubble(byte x, byte y, byte flags, byte *msg) {
for (string_ended = 0; !string_ended; char_draw_coords_y += 6) {
cga_PrintChar(0x3B, CGA_SCREENBUFFER);
- msg = PrintStringPadded(msg, CGA_SCREENBUFFER);
+ msg = printStringPadded(msg, CGA_SCREENBUFFER);
cga_PrintChar(0x3C, CGA_SCREENBUFFER);
char_draw_coords_x = x;
}
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 0392a61a248..1dc32f8aeb6 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -53,11 +53,11 @@ uint16 cpu_speed_delay;
/*
Prompt user to insert disk #2 to any drive
*/
-void AskDisk2(void) {
- DrawMessage(seekToString(vepci_data, 179), frontbuffer);
+void askDisk2(void) {
+ drawMessage(seekToString(vepci_data, 179), frontbuffer);
}
-void SaveToFile(char *filename, void *data, uint16 size) {
+void saveToFile(char *filename, void *data, uint16 size) {
warning("STUB: SaveToFile(%s, data, %d)", filename, size);
#if 0
FILE *f = fopen(filename, "wb");
@@ -66,14 +66,14 @@ void SaveToFile(char *filename, void *data, uint16 size) {
#endif
}
-int16 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;
}
-uint16 BenchmarkCpu(void) {
+uint16 benchmarkCpu(void) {
byte t;
uint16 cycles = 0;
for (t = script_byte_vars.timer_ticks; t == script_byte_vars.timer_ticks;) ;
@@ -81,7 +81,7 @@ uint16 BenchmarkCpu(void) {
return cycles;
}
-void Randomize(void) {
+void randomize(void) {
warning("STUB: Randomize()");
#if 0
union REGS reg;
@@ -99,7 +99,7 @@ void TRAP() {
}
/* Main Game Loop */
-void GameLoop(byte *target) {
+void gameLoop(byte *target) {
for (;;) {
AnimateSpots(target);
@@ -122,7 +122,7 @@ void GameLoop(byte *target) {
} else {
selectCursor(CURSOR_FINGER);
object_hint = 117;
- CheckMenuCommandHover();
+ checkMenuCommandHover();
}
if (object_hint != last_object_hint)
@@ -190,7 +190,7 @@ process:
}
-void ExitGame(void) {
+void exitGame(void) {
switchToTextMode();
uninitTimer();
}
@@ -219,16 +219,16 @@ Common::Error ChamberEngine::run() {
if (g_vm->getLanguage() == Common::EN_USA) {
/* Load title screen */
- if (!LoadSplash("PRESCGA.BIN"))
- ExitGame();
+ if (!loadSplash("PRESCGA.BIN"))
+ exitGame();
if (ifgm_loaded) {
/*TODO*/
}
} else {
/* Load title screen */
- if (!LoadSplash("PRES.BIN"))
- ExitGame();
+ if (!loadSplash("PRES.BIN"))
+ exitGame();
}
/* Select intense cyan-mageta palette */
@@ -246,8 +246,8 @@ Common::Error ChamberEngine::run() {
c = 'E';
} else {
/* Load language selection screen */
- if (!LoadSplash("DRAP.BIN"))
- ExitGame();
+ if (!loadSplash("DRAP.BIN"))
+ exitGame();
/* Wait for a keypress and show the language selection screen */
clearKeyboard();
@@ -282,18 +282,18 @@ Common::Error ChamberEngine::run() {
/* Load script and other static resources */
/* Those are normally embedded in the executable, but here we load extracted ones*/
if (!LoadStaticData())
- ExitGame();
+ exitGame();
/* Load text resources */
if (!LoadVepciData() || !LoadDesciData() || !LoadDialiData())
- ExitGame();
+ exitGame();
/* Detect/Initialize input device */
initInput();
/* Load graphics resources */
while (!LoadFond() || !LoadSpritesData() || !LoadPersData())
- AskDisk2();
+ askDisk2();
/*TODO: is this neccessary?*/
cga_BackBufferToRealFull();
@@ -302,7 +302,7 @@ Common::Error ChamberEngine::run() {
SaveRestartGame();
/* Detect CPU speed for delay routines */
- cpu_speed_delay = BenchmarkCpu() / 8;
+ cpu_speed_delay = benchmarkCpu() / 8;
if (g_vm->getLanguage() == Common::EN_USA) {
if (ifgm_loaded) {
@@ -314,7 +314,7 @@ Common::Error ChamberEngine::run() {
//restart:;
setjmp(restart_jmp);
- Randomize();
+ randomize();
/* Set start zone */
script_byte_vars.zone_index = 7;
@@ -354,14 +354,14 @@ Common::Error ChamberEngine::run() {
#endif
/* Main game loop */
- GameLoop(frontbuffer);
+ gameLoop(frontbuffer);
- /*TODO: the following code is never executed since GameLoop is infinite (or the whole game is restarted) */
+ /*TODO: the following code is never executed since gameLoop is infinite (or the whole game is restarted) */
/* Release hardware */
uninitInput();
- ExitGame();
+ exitGame();
return Common::kNoError;
}
diff --git a/engines/chamber/menu.cpp b/engines/chamber/menu.cpp
index ef42ac76c68..c1418c9fab6 100644
--- a/engines/chamber/menu.cpp
+++ b/engines/chamber/menu.cpp
@@ -54,7 +54,7 @@ struct {
};
/*Handle keyboard keys in actions menu (to cycle through choices with directional keys)*/
-byte PollKeyboardInActionsMenu(void) {
+byte pollKeyboardInActionsMenu(void) {
pollInput();
if (!(key_direction & 0xF)) {
key_held = 0;
@@ -83,7 +83,7 @@ void pollInputInActionsMenu(void) {
}
/*Draw actions menu and process its choices*/
-void ActionsMenu(byte **pinfo) {
+void actionsMenu(byte **pinfo) {
byte x, y;
byte choices;
int16 i, choice, numchoices;
@@ -180,7 +180,7 @@ void ActionsMenu(byte **pinfo) {
}
/*TODO: maybe rename to SpotsLoop*/
-void MenuLoop(byte spotmask, byte spotvalue) {
+void menuLoop(byte spotmask, byte spotvalue) {
processInput();
do {
pollInput();
@@ -192,9 +192,9 @@ void MenuLoop(byte spotmask, byte spotvalue) {
undrawCursor(frontbuffer);
}
-void ProcessMenu(void) {
+void processMenu(void) {
selectCursor(CURSOR_BODY);
- MenuLoop(SPOTFLG_80 | SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8, SPOTFLG_80 | SPOTFLG_10);
+ menuLoop(SPOTFLG_80 | SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8, SPOTFLG_80 | SPOTFLG_10);
}
@@ -209,7 +209,7 @@ rect_t menu_buttons_rects[] = {
{296 / 4, 312 / 4, 136, 152} /*Time*/
};
-void CheckMenuCommandHover(void) {
+void checkMenuCommandHover(void) {
int16 i;
for (i = 0; i < 8; i++) {
if (IsCursorInRect(&menu_buttons_rects[i])) {
@@ -236,7 +236,7 @@ rect_t psi_buttons_rects[] = {
{280 / 4, 296 / 4, 152, 168} /*Tune In*/
};
-void CheckPsiCommandHover(void) {
+void checkPsiCommandHover(void) {
/*TODO: maybe merge it with CheckMenuCommandHover()*/
int16 i;
for (i = 0; i < 8; i++) {
diff --git a/engines/chamber/menu.h b/engines/chamber/menu.h
index 907a7d4e88e..9ac12e30c9e 100644
--- a/engines/chamber/menu.h
+++ b/engines/chamber/menu.h
@@ -28,12 +28,12 @@ namespace Chamber {
extern byte act_menu_x;
extern byte act_menu_y;
-void ActionsMenu(byte **pinfo);
-void MenuLoop(byte spotmask, byte spotvalue);
-void ProcessMenu(void);
+void actionsMenu(byte **pinfo);
+void menuLoop(byte spotmask, byte spotvalue);
+void processMenu(void);
-void CheckMenuCommandHover(void);
-void CheckPsiCommandHover(void);
+void checkMenuCommandHover(void);
+void checkPsiCommandHover(void);
} // End of namespace Chamber
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index 88198602ca9..8949d0faa2a 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -70,7 +70,7 @@ persframe_t pers_frames[] = {
{27, 34, 0, 0, 0, 0}
};
-void MakePortraitFrame(byte index, byte *target) {
+void makePortraitFrame(byte index, byte *target) {
uint16 i;
persframe_t *pframe = &pers_frames[index];
*target++ = pframe->height;
@@ -91,7 +91,7 @@ void MakePortraitFrame(byte index, byte *target) {
/*
Superimpose source sprite data over target image data
*/
-void MergeImageAndSpriteData(byte *target, int16 pitch, byte *source, uint16 w, uint16 h) {
+void mergeImageAndSpriteData(byte *target, int16 pitch, byte *source, uint16 w, uint16 h) {
uint16 x;
while (h--) {
for (x = 0; x < w; x++) {
@@ -107,7 +107,7 @@ void MergeImageAndSpriteData(byte *target, int16 pitch, byte *source, uint16 w,
/*
Superimpose horizontally-flipped source sprite data over target image data
*/
-void MergeImageAndSpriteDataFlip(byte *target, int16 pitch, byte *source, uint16 w, uint16 h) {
+void mergeImageAndSpriteDataFlip(byte *target, int16 pitch, byte *source, uint16 w, uint16 h) {
uint16 x;
target += w - 1;
while (h--) {
@@ -125,7 +125,7 @@ void MergeImageAndSpriteDataFlip(byte *target, int16 pitch, byte *source, uint16
/*
Build portrait from multiple pers sprites
*/
-byte *LoadPortrait(byte **pinfo, byte *end) {
+byte *loadPortrait(byte **pinfo, byte *end) {
while (*pinfo != end) {
byte index;
uint16 flags;
@@ -148,18 +148,18 @@ byte *LoadPortrait(byte **pinfo, byte *end) {
pitch = -pitch;
}
if (flags & 0x4000) /*horizontal flip*/
- MergeImageAndSpriteDataFlip(buffer, pitch, sprite, sprw, sprh);
+ mergeImageAndSpriteDataFlip(buffer, pitch, sprite, sprw, sprh);
else
- MergeImageAndSpriteData(buffer, pitch, sprite, sprw, sprh);
+ mergeImageAndSpriteData(buffer, pitch, sprite, sprw, sprh);
}
return sprit_load_buffer + 2;
}
-byte *LoadPortraitWithFrame(byte index) {
+byte *loadPortraitWithFrame(byte index) {
byte *pinfo, *end;
pinfo = SeekToEntry(icone_data, index, &end);
- MakePortraitFrame(*pinfo++, sprit_load_buffer + 2);
- return LoadPortrait(&pinfo, end);
+ makePortraitFrame(*pinfo++, sprit_load_buffer + 2);
+ return loadPortrait(&pinfo, end);
}
@@ -199,7 +199,7 @@ struct {
{248, 117, 16, 2, 33, 33}
};
-byte SelectCurrentAnim(byte *x, byte *y, byte *index) {
+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++) {
@@ -216,7 +216,7 @@ byte SelectCurrentAnim(byte *x, byte *y, byte *index) {
return 0;
}
-void DrawBoxAroundSpot(void) {
+void drawBoxAroundSpot(void) {
byte *buffer;
uint16 w, h;
uint16 ofs;
@@ -252,7 +252,7 @@ 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
*/
-int16 DrawPortrait(byte **desc, byte *x, byte *y, byte *width, byte *height) {
+int16 drawPortrait(byte **desc, byte *x, byte *y, byte *width, byte *height) {
byte index;
byte xx, yy;
byte *image;
@@ -261,8 +261,8 @@ int16 DrawPortrait(byte **desc, byte *x, byte *y, byte *width, byte *height) {
if (index == 0xFF) {
if (script_byte_vars.dirty_rect_kind != 0)
return 0;
- DrawBoxAroundSpot();
- if (!SelectCurrentAnim(&xx, &yy, &index))
+ drawBoxAroundSpot();
+ if (!selectCurrentAnim(&xx, &yy, &index))
return 0;
} else {
xx = *((*desc)++);
@@ -272,7 +272,7 @@ int16 DrawPortrait(byte **desc, byte *x, byte *y, byte *width, byte *height) {
cur_image_coords_y = yy;
cur_image_idx = index;
- image = LoadPortraitWithFrame(index - 1);
+ image = loadPortraitWithFrame(index - 1);
cur_image_size_h = *image++;
cur_image_size_w = *image++;
cur_image_pixels = image;
@@ -293,28 +293,28 @@ int16 DrawPortrait(byte **desc, byte *x, byte *y, byte *width, byte *height) {
return 1;
}
-void PlayHurtSound() {
+void playHurtSound() {
if (!ifgm_loaded)
playSound(144);
else
playSound(144 + (Rand() / 4) % 4);
}
-void BlinkWithSound(byte color) {
+void blinkWithSound(byte color) {
cga_ColorSelect(color);
- PlayHurtSound();
+ playHurtSound();
SelectPalette();
}
-void BlinkToRed(void) {
- BlinkWithSound(0x3C);
+void blinkToRed(void) {
+ blinkWithSound(0x3C);
}
-void BlinkToWhite(void) {
+void blinkToWhite(void) {
if (g_vm->getLanguage() == Common::EN_USA)
- PlayHurtSound(); /*TODO: play here and later? looks like a bug, original code will trash palette selection if pcspeaker is used*/
+ playHurtSound(); /*TODO: play here and later? looks like a bug, original code will trash palette selection if pcspeaker is used*/
- BlinkWithSound(0x3F);
+ blinkWithSound(0x3F);
}
volatile byte vblank_ticks;
@@ -328,11 +328,11 @@ void waitVBlankTimer(void) {
waitVBlank();
}
-void AnimPortrait(byte layer, byte index, byte delay) {
+void animPortrait(byte layer, byte index, byte delay) {
byte *ani, *ani_end;
byte temp;
- SelectCurrentAnim(&temp, &temp, &temp);
+ selectCurrentAnim(&temp, &temp, &temp);
if (index == 0xFF)
index = cur_image_anim1;
@@ -351,10 +351,10 @@ void AnimPortrait(byte layer, byte index, byte delay) {
uint16 offs;
byte portrait = *ani++;
- LoadPortraitWithFrame(portrait - 1);
+ loadPortraitWithFrame(portrait - 1);
if (*ani == 0xFF) {
ani++;
- LoadPortrait(&ani, ani + 3);
+ loadPortrait(&ani, ani + 3);
}
getDirtyRectAndSetSprite(layer, &kind, &x, &y, &width, &height, &offs);
waitVBlank();
@@ -363,9 +363,9 @@ void AnimPortrait(byte layer, byte index, byte delay) {
if (delay) {
if (ani[-1] == 37) { /*TODO: what is it?*/
if (script_byte_vars.extreme_violence)
- BlinkToRed();
+ blinkToRed();
else
- BlinkToWhite();
+ blinkToWhite();
} else {
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 ca186a3ee59..40d7303a91e 100644
--- a/engines/chamber/portrait.h
+++ b/engines/chamber/portrait.h
@@ -39,16 +39,16 @@ extern uint16 cur_frame_width;
extern volatile byte vblank_ticks;
-int16 DrawPortrait(byte **desc, byte *x, byte *y, byte *width, byte *height);
-void AnimPortrait(byte layer, byte index, byte 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 drawBoxAroundSpot(void);
-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 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);
+void blinkToRed(void);
+void blinkToWhite(void);
} // End of namespace Chamber
diff --git a/engines/chamber/print.cpp b/engines/chamber/print.cpp
index be04d46d517..3a675367132 100644
--- a/engines/chamber/print.cpp
+++ b/engines/chamber/print.cpp
@@ -38,7 +38,7 @@ byte draw_y;
Calculate number of string's character until whitespace
Return current word's characters count and the next word ptr
*/
-byte *CalcStringWordWidth(byte *str, uint16 *w) {
+byte *calcStringWordWidth(byte *str, uint16 *w) {
uint16 ww = 0;
byte c;
@@ -69,11 +69,11 @@ byte *CalcStringWordWidth(byte *str, uint16 *w) {
/*
Calculate number of text's words and max word width (in chars)
*/
-void CalcStringSize(byte *str, uint16 *w, uint16 *n) {
+void calcStringSize(byte *str, uint16 *w, uint16 *n) {
uint16 ww = 0, nw = 0, lw;
byte *s = str;
do {
- s = CalcStringWordWidth(s, &lw);
+ s = calcStringWordWidth(s, &lw);
if (lw > ww)
ww = lw;
nw += 1;
@@ -86,11 +86,11 @@ void CalcStringSize(byte *str, uint16 *w, uint16 *n) {
Calculate number of text's lines with respect to set max width
If a line is longer, wrap it to the next line
*/
-uint16 CalcTextLines(byte *str) {
+uint16 calcTextLines(byte *str) {
uint16 lines = 1;
uint16 w, left = char_draw_max_width;
while (str != cur_str_end) {
- str = CalcStringWordWidth(str, &w);
+ str = calcStringWordWidth(str, &w);
if (left > w) {
left = left - w - 1;
} else {
@@ -107,12 +107,12 @@ byte chars_color_bonc[] = {0x55, 0x54, 0x51, 0x50, 0x45, 0x44, 0x41, 0x40, 0x15,
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(uint16 w, byte *target) {
+void printStringPad(uint16 w, byte *target) {
while (w--)
cga_PrintChar(0, target);
}
-byte *PrintWord(byte *str, byte *target) {
+byte *printWord(byte *str, byte *target) {
byte c, f;
if ((*str & 0x3F) == 0)
goto skip_1st;
@@ -143,15 +143,15 @@ skip_1st:
return str;
}
-byte *PrintStringLine(byte *str, uint16 *left, byte *target) {
+byte *printStringLine(byte *str, uint16 *left, byte *target) {
uint16 mw = char_draw_max_width;
for (;;) {
uint16 w;
- CalcStringWordWidth(str, &w);
+ calcStringWordWidth(str, &w);
if (mw < w)
break;
mw -= w;
- str = PrintWord(str, target);
+ str = printWord(str, target);
if (string_ended || (mw == 0))
break;
mw--;
@@ -161,38 +161,38 @@ byte *PrintStringLine(byte *str, uint16 *left, byte *target) {
return str;
}
-byte *PrintStringPadded(byte *str, byte *target) {
+byte *printStringPadded(byte *str, byte *target) {
uint16 w;
if (g_vm->getLanguage() != Common::EN_USA) {
uint16 n;
- CalcStringSize(str, &w, &n);
+ calcStringSize(str, &w, &n);
if (w + 2 >= char_draw_max_width)
char_draw_max_width = w + 2;
}
- str = PrintStringLine(str, &w, target);
+ str = printStringLine(str, &w, target);
if (w != 0)
- PrintStringPad(w, target);
+ printStringPad(w, target);
return str;
}
-void PrintStringCentered(byte *str, byte *target) {
+void printStringCentered(byte *str, byte *target) {
byte pad = 0;
uint16 ww = 0, lw;
byte *s = str;
do {
- s = CalcStringWordWidth(s, &lw);
+ s = calcStringWordWidth(s, &lw);
ww += lw;
} while (s != cur_str_end);
pad = (char_draw_max_width - ww) / 2;
if (pad) {
char_draw_max_width -= pad;
- PrintStringPad(pad, target);
+ printStringPad(pad, target);
}
string_ended = 0; /*TODO: move me elsewhere*/
- PrintStringPadded(str, target);
+ printStringPadded(str, target);
}
void cga_DrawTextBox(byte *msg, byte *target) {
@@ -202,7 +202,7 @@ void cga_DrawTextBox(byte *msg, byte *target) {
char_xlat_table = chars_color_bonc;
if (g_vm->getLanguage() == Common::EN_USA) {
- CalcStringSize(msg, &ww, &nw);
+ calcStringSize(msg, &ww, &nw);
if (ww >= char_draw_max_width)
char_draw_max_width = ww;
}
@@ -224,7 +224,7 @@ void cga_DrawTextBox(byte *msg, byte *target) {
do {
char_draw_coords_x = draw_x;
cga_PrintChar(0x3B, target);
- msg = PrintStringPadded(msg, target);
+ msg = printStringPadded(msg, target);
cga_PrintChar(0x3C, target);
char_draw_coords_y += 6;
} while (!string_ended);
@@ -238,12 +238,12 @@ void cga_DrawTextBox(byte *msg, byte *target) {
cga_DrawVLine(x + w, y, 1, 0, target); /*bottom right corner*/
}
-void DrawMessage(byte *msg, byte *target) {
+void drawMessage(byte *msg, byte *target) {
uint16 x, y;
uint16 w, h;
- CalcStringSize(msg, &w, &h);
+ calcStringSize(msg, &w, &h);
char_draw_max_width = (h < 5) ? (w + 2) : 20;
- char_draw_max_height = CalcTextLines(msg) * 6 + 7;
+ char_draw_max_height = calcTextLines(msg) * 6 + 7;
x = cursor_x / 4;
if (x < 9)
@@ -265,7 +265,7 @@ void DrawMessage(byte *msg, byte *target) {
}
#if 1
-void DebugMessage(char *msg, ...) {
+void debugMessage(char *msg, ...) {
int16 i;
byte c;
byte m[256];
@@ -294,7 +294,7 @@ void DebugMessage(char *msg, ...) {
cur_str_end = m + i;
- DrawMessage(m, frontbuffer);
+ drawMessage(m, frontbuffer);
}
#endif
diff --git a/engines/chamber/print.h b/engines/chamber/print.h
index bdcc39a289a..f36ccccc67b 100644
--- a/engines/chamber/print.h
+++ b/engines/chamber/print.h
@@ -35,14 +35,14 @@ extern byte chars_color_bonc[];
extern byte chars_color_wonb[];
extern byte chars_color_wonc[];
-void PrintStringCentered(byte *str, byte *target);
-byte *PrintStringPadded(byte *str, byte *target);
+void printStringCentered(byte *str, byte *target);
+byte *printStringPadded(byte *str, byte *target);
-void DrawMessage(byte *msg, byte *target);
+void drawMessage(byte *msg, byte *target);
void cga_DrawTextBox(byte *msg, byte *target);
-void CalcStringSize(byte *str, uint16 *w, uint16 *n);
+void calcStringSize(byte *str, uint16 *w, uint16 *n);
} // End of namespace Chamber
diff --git a/engines/chamber/resdata.cpp b/engines/chamber/resdata.cpp
index 91cfd6b5441..265b9dd2f26 100644
--- a/engines/chamber/resdata.cpp
+++ b/engines/chamber/resdata.cpp
@@ -29,8 +29,8 @@
namespace Chamber {
-extern void AskDisk2(void);
-extern int16 LoadSplash(const char *filename);
+extern void askDisk2(void);
+extern int16 loadSplash(const char *filename);
/*
Get bank entry
@@ -246,7 +246,7 @@ int16 LoadVepciData() {
}
int16 LoadFond(void) {
- return LoadSplash("FOND.BIN");
+ return loadSplash("FOND.BIN");
}
ResEntry_t res_sprites[] = {
@@ -282,7 +282,7 @@ Load strings data (obj. descriptions)
*/
int16 LoadDesciData(void) {
while (!LoadFilesList(res_desci))
- AskDisk2();
+ askDisk2();
return 1;
}
@@ -296,7 +296,7 @@ Load strings data (dialogs)
*/
int16 LoadDialiData(void) {
while (!LoadFilesList(res_diali))
- AskDisk2();
+ askDisk2();
return 1;
}
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index c2b153bad12..6b6618f7a18 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -602,7 +602,7 @@ void AnimateSpot(const animdesc_t *info) {
cursor_x = found_spot->sx * 4;
cursor_y = found_spot->sy;
if (info->params.desc)
- DrawMessage(seekToString(desci_data, info->params.desc), frontbuffer);
+ drawMessage(seekToString(desci_data, info->params.desc), frontbuffer);
playAnim(info->index & ~ANIMFLG_USESPOT, found_spot->sx, found_spot->sy);
} else {
@@ -953,7 +953,7 @@ void DrawObjectHint(void) {
char_draw_coords_x = room_hint_bar_coords_x;
char_draw_coords_y = room_hint_bar_coords_y;
char_xlat_table = chars_color_wonb;
- PrintStringCentered(seekToString(motsi_data, object_hint), backbuffer);
+ printStringCentered(seekToString(motsi_data, object_hint), backbuffer);
#ifdef DEBUG_ZONE
cga_PrintChar(0x20, backbuffer);
@@ -980,7 +980,7 @@ void DrawCommandHint(void) {
char_draw_coords_x = cmd_hint_bar_coords_x;
char_draw_coords_y = cmd_hint_bar_coords_y;
char_xlat_table = chars_color_wonb;
- PrintStringCentered(seekToString(vepci_data, command_hint), backbuffer);
+ printStringCentered(seekToString(vepci_data, command_hint), backbuffer);
}
/*
@@ -1366,9 +1366,9 @@ byte *LoadMursmSprite(byte index) {
sprh = *sprite++;
if (index & 0x80) /*horizontal flip*/
- MergeImageAndSpriteDataFlip(buffer, pitch, sprite, sprw, sprh);
+ mergeImageAndSpriteDataFlip(buffer, pitch, sprite, sprw, sprh);
else
- MergeImageAndSpriteData(buffer, pitch, sprite, sprw, sprh);
+ mergeImageAndSpriteData(buffer, pitch, sprite, sprw, sprh);
}
/*TODO: move this from globals to args/consts?*/
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 73e0a2ba21c..687b5ce9540 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -75,7 +75,7 @@ void *script_vars[ScrPools_MAX] = {
pers_list
};
-extern void AskDisk2(void);
+extern void askDisk2(void);
/*
Get next random byte value
@@ -684,7 +684,7 @@ uint16 SCR_5_DrawPortraitLiftRight(void) {
script_ptr++;
- if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!drawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
/*TODO: use local args instead of globals*/
@@ -700,7 +700,7 @@ uint16 SCR_6_DrawPortraitLiftLeft(void) {
script_ptr++;
- if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!drawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
/*TODO: use local args instead of globals*/
@@ -716,7 +716,7 @@ uint16 SCR_7_DrawPortraitLiftDown(void) {
script_ptr++;
- if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!drawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
/*TODO: use local args instead of globals*/
@@ -732,7 +732,7 @@ uint16 SCR_8_DrawPortraitLiftUp(void) {
script_ptr++;
- if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!drawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
/*TODO: use local args instead of globals*/
@@ -748,7 +748,7 @@ uint16 SCR_9_DrawPortrait(void) {
script_ptr++;
- if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!drawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
cga_BlitAndWait(cur_image_pixels, cur_image_size_w, cur_image_size_w, cur_image_size_h, CGA_SCREENBUFFER, cur_image_offs);
@@ -805,7 +805,7 @@ uint16 SCR_B_DrawPortraitTwistEffect(void) {
script_ptr++;
- if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!drawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
offs = cga_CalcXY_p(x, y);
@@ -856,7 +856,7 @@ uint16 SCR_C_DrawPortraitArcEffect(void) {
script_ptr++;
- if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!drawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
offs = cga_CalcXY_p(x, y);
@@ -879,7 +879,7 @@ uint16 SCR_D_DrawPortraitDotEffect(void) {
script_ptr++;
- if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!drawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
cur_image_end = width * height;
@@ -908,7 +908,7 @@ uint16 SCR_E_DrawPortraitZoomIn(void) {
script_ptr++;
- if (!DrawPortrait(&script_ptr, &x, &y, &width, &height))
+ if (!drawPortrait(&script_ptr, &x, &y, &width, &height))
return 0;
cga_AnimZoomIn(cur_image_pixels, cur_image_size_w, cur_image_size_h, frontbuffer, cur_image_offs);
@@ -916,12 +916,12 @@ uint16 SCR_E_DrawPortraitZoomIn(void) {
}
-uint16 DrawPortraitZoomed(byte **params) {
+uint16 drawPortraitZoomed(byte **params) {
byte x, y, width, height;
byte zwidth, zheight;
right_button = 0; /*prevent cancel or zoom parameters won't be consumed*/
- if (!DrawPortrait(params, &x, &y, &width, &height))
+ if (!drawPortrait(params, &x, &y, &width, &height))
return 0; /*TODO: maybe just remove the if/return instead?*/
zwidth = *((*params)++);
@@ -940,7 +940,7 @@ Draw image with specified w/h zoom
*/
uint16 SCR_10_DrawPortraitZoomed(void) {
script_ptr++;
- DrawPortraitZoomed(&script_ptr);
+ drawPortraitZoomed(&script_ptr);
#if 0
/*TODO: debug wait*/
@@ -1412,7 +1412,7 @@ uint16 SCR_26_GameOver(void) {
/*reload background*/
while (!LoadFond())
- AskDisk2();
+ askDisk2();
JaggedZoom(backbuffer, frontbuffer);
@@ -1622,7 +1622,7 @@ uint16 SCR_18_AnimPortrait(void) {
index = *script_ptr++;
delay = *script_ptr++;
- AnimPortrait(layer, index, delay);
+ animPortrait(layer, index, delay);
return 0;
}
@@ -1653,7 +1653,7 @@ uint16 SCR_3D_ActionsMenu(void) {
for (;;) {
script_ptr++;
- ActionsMenu(&script_ptr);
+ actionsMenu(&script_ptr);
if (the_command == 0xFFFF)
break;
@@ -1720,7 +1720,7 @@ uint16 SCR_28_MenuLoop(void) {
selectCursor(cursor);
- MenuLoop(mask, value);
+ menuLoop(mask, value);
return 0;
}
@@ -1898,10 +1898,10 @@ uint16 SCR_30_Fight(void) {
/*draw player portrait*/
player_image[1] = x;
player_image[2] = y;
- if (DrawPortrait(&image, &x, &y, &width, &height))
+ if (drawPortrait(&image, &x, &y, &width, &height))
cga_AnimLiftToLeft(width, cur_image_pixels, width, 1, height, CGA_SCREENBUFFER, cga_CalcXY_p(x + width - 1, y));
- BlinkToWhite();
+ blinkToWhite();
if (pers->name != 44 && pers->name != 56 && pers->name != 51) { /*VORT, MONKEY, TURKEY*/
getDirtyRectAndFree(1, &kind, &x, &y, &width, &height, &offs);
@@ -2783,7 +2783,7 @@ static void AnimSaucer(void) {
cga_ColorSelect(0x30);
right_button = 0;
- if (!DrawPortrait(&pimage1, &x, &y, &width, &height))
+ if (!drawPortrait(&pimage1, &x, &y, &width, &height))
return;
height_prev = 200 - 1;
@@ -2876,7 +2876,7 @@ static void AnimSaucer(void) {
}
};
-extern int16 LoadSplash(const char *filename);
+extern int16 loadSplash(const char *filename);
/*
TODO: check me
@@ -2888,7 +2888,7 @@ void TheEnd(void) {
AnimSaucer();
if (g_vm->getLanguage() == Common::EN_USA) {
- DrawPortraitZoomed(&pimage2);
+ drawPortraitZoomed(&pimage2);
script_byte_vars.zone_index = 135;
@@ -2898,12 +2898,12 @@ void TheEnd(void) {
while(buttons == 0);
while (!LoadFond())
- AskDisk2();
+ askDisk2();
JaggedZoom(backbuffer, frontbuffer);
cga_BackBufferToRealFull();
} else {
- while (!LoadSplash("PRES.BIN"))
- AskDisk2();
+ while (!loadSplash("PRES.BIN"))
+ askDisk2();
cga_BackBufferToRealFull();
}
}
@@ -3004,7 +3004,7 @@ uint16 SCR_63_LiftSpot6(void) {
uint16 SCR_64_DrawBoxAroundSpot(void) {
script_ptr++;
- DrawBoxAroundSpot();
+ drawBoxAroundSpot();
return 0;
}
@@ -3017,7 +3017,7 @@ uint16 SCR_14_DrawDesc(void) {
msg = seekToStringScr(desci_data, *script_ptr, &script_ptr);
script_ptr++;
- DrawMessage(msg, CGA_SCREENBUFFER);
+ drawMessage(msg, CGA_SCREENBUFFER);
return 0;
}
@@ -3226,7 +3226,7 @@ uint16 CMD_2_PsiPowers(void) {
do {
pollInput();
selectCursor(CURSOR_FINGER);
- CheckPsiCommandHover();
+ checkPsiCommandHover();
if (command_hint != 100)
command_hint += 109;
if (command_hint != last_command_hint)
@@ -3266,14 +3266,14 @@ uint16 CMD_4_EnergyLevel(void) {
if (script_byte_vars.psy_energy != 0)
anim = 41 + (script_byte_vars.psy_energy / 16);
- if (DrawPortrait(&image, &x, &y, &width, &height)) {
+ 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 {
IFGM_PlaySample(28);
- AnimPortrait(1, anim, 10);
- AnimPortrait(1, anim + 14, 10);
+ animPortrait(1, anim, 10);
+ animPortrait(1, anim + 14, 10);
pollInputButtonsOnly();
} while (buttons == 0);
@@ -3341,7 +3341,7 @@ uint16 CMD_8_Timer(void) {
byte x, y, width, height;
byte *image = timer_image;
- if (DrawPortrait(&image, &x, &y, &width, &height)) {
+ 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);
}
@@ -3442,7 +3442,7 @@ uint16 CMD_B_PsiStickyFingers(void) {
BackupScreenOfSpecialRoom();
DrawStickyNet();
selectCursor(CURSOR_FLY);
- MenuLoop(0, 0);
+ menuLoop(0, 0);
playSound(224);
cga_BackBufferToRealFull();
RestoreScreenOfSpecialRoom();
@@ -3467,7 +3467,7 @@ uint16 CMD_C_PsiKnowMind(void) {
return ScriptRerun;
}
- ProcessMenu();
+ processMenu();
if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(2 * 2) == 0)
the_command = Swap16(script_word_vars.psi_cmds[1]);
@@ -3481,7 +3481,7 @@ uint16 CMD_D_PsiBrainwarp(void) {
if (script_byte_vars.bvar_43 == 0) {
BackupScreenOfSpecialRoom();
- ProcessMenu();
+ processMenu();
if (script_byte_vars.cur_spot_idx == 0) {
the_command = Swap16(script_word_vars.wvar_0C);
@@ -3579,7 +3579,7 @@ uint16 CMD_F_PsiPsiShift(void) {
}
selectCursor(CURSOR_GRAB);
- MenuLoop(0, 0);
+ menuLoop(0, 0);
BackupScreenOfSpecialRoom();
playSound(25);
playAnim(39, cursor_x / 4, cursor_y);
@@ -3604,7 +3604,7 @@ uint16 CMD_10_PsiExtremeViolence(void) {
return ScriptRerun;
}
- ProcessMenu();
+ processMenu();
if (script_byte_vars.cur_spot_idx == 0) {
the_command = Swap16(script_word_vars.psi_cmds[4]);
@@ -3658,7 +3658,7 @@ uint16 CMD_11_PsiTuneIn(void) {
}
void ActionForPersonChoice(uint16 *actions) {
- ProcessMenu();
+ 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];
@@ -4393,7 +4393,7 @@ again:;
res = RunScript(templ_data + the_command);
break;
case 0x9000:
- DrawMessage(seekToString(desci_data, cmd), CGA_SCREENBUFFER);
+ drawMessage(seekToString(desci_data, cmd), CGA_SCREENBUFFER);
break;
case 0xA000:
case 0xB000:
Commit: 4f009e3fa7ab0342b676c7e4c71f7575e30fd9ba
https://github.com/scummvm/scummvm/commit/4f009e3fa7ab0342b676c7e4c71f7575e30fd9ba
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Renames in resdata.h
Changed paths:
engines/chamber/anim.cpp
engines/chamber/cga.cpp
engines/chamber/kult.cpp
engines/chamber/portrait.cpp
engines/chamber/resdata.cpp
engines/chamber/resdata.h
engines/chamber/room.cpp
engines/chamber/script.cpp
diff --git a/engines/chamber/anim.cpp b/engines/chamber/anim.cpp
index 8220aa30056..d45c088467e 100644
--- a/engines/chamber/anim.cpp
+++ b/engines/chamber/anim.cpp
@@ -50,7 +50,7 @@ uint16 dot_effect_delay;
extern uint16 cpu_speed_delay;
-extern byte *SeekToEntry(byte *bank, uint16 num, byte **end);
+extern byte *seekToEntry(byte *bank, uint16 num, byte **end);
extern void LoadLutinSprite(uint16 lutidx);
void getScratchBuffer(byte mode) {
@@ -304,7 +304,7 @@ void playAnim(byte index, byte x, byte y) {
last_anim_x = x;
last_anim_y = y;
- panim = SeekToEntry(anima_data, index - 1, &anima_end_ofs);
+ panim = seekToEntry(anima_data, index - 1, &anima_end_ofs);
while (panim != anima_end_ofs) {
byte mode = *panim;
switch (mode) {
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 9fc97f8dba6..df135ea96b8 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -634,7 +634,7 @@ byte *LoadSprite(byte index, byte *bank, byte *buffer, byte header_only) {
uint16 rsize;
byte *sprite, *sprite_end;
byte *bitmask;
- sprite = SeekToEntryW(bank, index, &sprite_end);
+ sprite = seekToEntryW(bank, index, &sprite_end);
w = *sprite++;
h = *sprite++;
rsize = w * h; /*raster part size*/
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 1dc32f8aeb6..52c8e24e376 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -67,7 +67,7 @@ void saveToFile(char *filename, void *data, uint16 size) {
}
int16 loadSplash(const char *filename) {
- if (!LoadFile(filename, scratch_mem1))
+ if (!loadFile(filename, scratch_mem1))
return 0;
decompress(scratch_mem1 + 8, backbuffer); /* skip compressed/decompressed size fields */
return 1;
@@ -281,18 +281,18 @@ Common::Error ChamberEngine::run() {
/* Load script and other static resources */
/* Those are normally embedded in the executable, but here we load extracted ones*/
- if (!LoadStaticData())
+ if (!loadStaticData())
exitGame();
/* Load text resources */
- if (!LoadVepciData() || !LoadDesciData() || !LoadDialiData())
+ if (!loadVepciData() || !loadDesciData() || !loadDialiData())
exitGame();
/* Detect/Initialize input device */
initInput();
/* Load graphics resources */
- while (!LoadFond() || !LoadSpritesData() || !LoadPersData())
+ while (!loadFond() || !loadSpritesData() || !loadPersData())
askDisk2();
/*TODO: is this neccessary?*/
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index 8949d0faa2a..8467f54b3b7 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -157,7 +157,7 @@ byte *loadPortrait(byte **pinfo, byte *end) {
byte *loadPortraitWithFrame(byte index) {
byte *pinfo, *end;
- pinfo = SeekToEntry(icone_data, index, &end);
+ pinfo = seekToEntry(icone_data, index, &end);
makePortraitFrame(*pinfo++, sprit_load_buffer + 2);
return loadPortrait(&pinfo, end);
}
@@ -341,7 +341,7 @@ void animPortrait(byte layer, byte index, byte delay) {
IFGM_PlaySfx(index);
- ani = SeekToEntry(anico_data, index - 1, &ani_end);
+ ani = seekToEntry(anico_data, index - 1, &ani_end);
cur_image_pixels = sprit_load_buffer + 2 + 2;
while (ani != ani_end) {
diff --git a/engines/chamber/resdata.cpp b/engines/chamber/resdata.cpp
index 265b9dd2f26..fcd49d322c9 100644
--- a/engines/chamber/resdata.cpp
+++ b/engines/chamber/resdata.cpp
@@ -36,7 +36,7 @@ extern int16 loadSplash(const char *filename);
Get bank entry
TODO: port SeekToString to this routine
*/
-byte *SeekToEntry(byte *bank, uint16 num, byte **end) {
+byte *seekToEntry(byte *bank, uint16 num, byte **end) {
byte len;
byte *p = bank;
@@ -49,7 +49,7 @@ byte *SeekToEntry(byte *bank, uint16 num, byte **end) {
return p + 1;
}
-byte *SeekToEntryW(byte *bank, uint16 num, byte **end) {
+byte *seekToEntryW(byte *bank, uint16 num, byte **end) {
uint16 len;
byte *p = bank;
@@ -62,7 +62,7 @@ byte *SeekToEntryW(byte *bank, uint16 num, byte **end) {
return p + 2;
}
-uint16 LoadFile(const char *filename, byte *buffer) {
+uint16 loadFile(const char *filename, byte *buffer) {
Common::File in;
in.open(filename);
@@ -73,7 +73,7 @@ uint16 LoadFile(const char *filename, byte *buffer) {
return in.read(buffer, 0xFFFF0);
}
-uint16 SaveFile(char *filename, byte *buffer, uint16 size) {
+uint16 saveFile(char *filename, byte *buffer, uint16 size) {
warning("STUB: SaveFile(%s, buffer, %d)", filename, size);
return 0;
#if 0
@@ -90,10 +90,10 @@ uint16 SaveFile(char *filename, byte *buffer, uint16 size) {
#endif
}
-int16 LoadFilesList(ResEntry_t *entries) {
+int16 loadFilesList(ResEntry_t *entries) {
int16 i;
for (i = 0; entries[i].name[0] != '$'; i++) {
- if (!LoadFile(entries[i].name, (byte *)entries[i].buffer))
+ if (!loadFile(entries[i].name, (byte *)entries[i].buffer))
return 0;
}
return 1;
@@ -135,7 +135,7 @@ ResEntry_tp 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.
*/
-int16 LoadStaticData() {
+int16 loadStaticData() {
Common::File pxi;
if (g_vm->getLanguage() == Common::EN_USA)
@@ -215,14 +215,14 @@ int16 LoadStaticData() {
}
if (res_static[i].name[0] == '$')
- warning("LoadStaticData(): Extra resource %s", resName.c_str());
+ warning("loadStaticData(): Extra resource %s", resName.c_str());
}
// And now check that everything was loaded
bool missing = false;
for (int i = 0; res_static[i].name[0] != '$'; i++) {
if (*res_static[i].buffer == NULL) {
- warning("LoadStaticData(): Resource %s is not present", res_static[i].name);
+ warning("loadStaticData(): Resource %s is not present", res_static[i].name);
missing = true;
}
}
@@ -241,11 +241,11 @@ ResEntry_t res_texts[] = {
/*
Load strings data (commands/names)
*/
-int16 LoadVepciData() {
- return LoadFilesList(res_texts);
+int16 loadVepciData() {
+ return loadFilesList(res_texts);
}
-int16 LoadFond(void) {
+int16 loadFond(void) {
return loadSplash("FOND.BIN");
}
@@ -255,8 +255,8 @@ ResEntry_t res_sprites[] = {
{"$", NULL}
};
-int16 LoadSpritesData(void) {
- return LoadFilesList(res_sprites);
+int16 loadSpritesData(void) {
+ return loadFilesList(res_sprites);
}
ResEntry_t res_person[] = {
@@ -265,11 +265,11 @@ ResEntry_t res_person[] = {
{"$", NULL}
};
-int16 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()*/
- return LoadFilesList(res_person);
+ return loadFilesList(res_person);
}
ResEntry_t res_desci[] = {
@@ -280,8 +280,8 @@ ResEntry_t res_desci[] = {
/*
Load strings data (obj. descriptions)
*/
-int16 LoadDesciData(void) {
- while (!LoadFilesList(res_desci))
+int16 loadDesciData(void) {
+ while (!loadFilesList(res_desci))
askDisk2();
return 1;
}
@@ -294,8 +294,8 @@ ResEntry_t res_diali[] = {
/*
Load strings data (dialogs)
*/
-int16 LoadDialiData(void) {
- while (!LoadFilesList(res_diali))
+int16 loadDialiData(void) {
+ while (!loadFilesList(res_diali))
askDisk2();
return 1;
}
diff --git a/engines/chamber/resdata.h b/engines/chamber/resdata.h
index f5adfc91a0a..0edba5e7075 100644
--- a/engines/chamber/resdata.h
+++ b/engines/chamber/resdata.h
@@ -84,26 +84,26 @@ extern byte *anima_data;
extern byte *anico_data;
extern byte *zones_data;
-byte *SeekToEntry(byte *bank, uint16 num, byte **end);
-byte *SeekToEntryW(byte *bank, uint16 num, byte **end);
+byte *seekToEntry(byte *bank, uint16 num, byte **end);
+byte *seekToEntryW(byte *bank, uint16 num, byte **end);
-uint16 LoadFile(const char *filename, byte *buffer);
-uint16 SaveFile(char *filename, byte *buffer, uint16 size);
-int16 LoadFilesList(ResEntry_t *entries);
+uint16 loadFile(const char *filename, byte *buffer);
+uint16 saveFile(char *filename, byte *buffer, uint16 size);
+int16 loadFilesList(ResEntry_t *entries);
-int16 LoadStaticData(void);
-int16 LoadFond(void);
-int16 LoadSpritesData(void);
-int16 LoadPersData(void);
+int16 loadStaticData(void);
+int16 loadFond(void);
+int16 loadSpritesData(void);
+int16 loadPersData(void);
extern ResEntry_t res_texts[];
-int16 LoadVepciData(void);
+int16 loadVepciData(void);
extern ResEntry_t res_desci[];
-int16 LoadDesciData(void);
+int16 loadDesciData(void);
extern ResEntry_t res_diali[];
-int16 LoadDialiData(void);
+int16 loadDialiData(void);
} // End of namespace Chamber
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index 6b6618f7a18..bb5982a40b6 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -295,7 +295,7 @@ Load and initialize zone data
void LoadZone(void) {
byte *zptr, *zend;
- zptr = SeekToEntry(zones_data, script_byte_vars.zone_index - 1, &zend);
+ zptr = seekToEntry(zones_data, script_byte_vars.zone_index - 1, &zend);
script_byte_vars.zone_area = *zptr++;
script_byte_vars.zone_room = *zptr++;
zone_name = object_hint = *zptr++;
@@ -797,7 +797,7 @@ void DrawRoomStatics(void) {
DrawBackground(backbuffer, 0);
arpla_y_step = script_byte_vars.hands;
- aptr = SeekToEntry(arpla_data, script_byte_vars.zone_room - 1, &aend);
+ aptr = seekToEntry(arpla_data, script_byte_vars.zone_room - 1, &aend);
room_bounds_rect.sx = 0xFF;
room_bounds_rect.ex = 0;
room_bounds_rect.sy = 0xFF;
@@ -861,7 +861,7 @@ void RedrawRoomStatics(byte index, byte y_step) {
byte x, y, w, h;
arpla_y_step = y_step;
- aptr = SeekToEntry(arpla_data, index - 1, &aend);
+ aptr = seekToEntry(arpla_data, index - 1, &aend);
for (; aptr != aend; aptr += 3) {
/*load room's bg objs*/
DrawRoomStaticObject(aptr, &x, &y, &w, &h);
@@ -1007,7 +1007,7 @@ void LoadLutinSprite(uint16 lutidx) {
buffer[i * 2 + 1] = 0; /*pixels*/
}
- lutin_entry = SeekToEntry(lutin_data, lutidx, &lutin_entry_end);
+ lutin_entry = seekToEntry(lutin_data, lutidx, &lutin_entry_end);
*buffer++ = *lutin_entry++; /*width*/
*buffer++ = *lutin_entry++; /*height*/
@@ -1313,7 +1313,7 @@ Modify anim sprite 127
*/
void SetAnim127Sprite(byte flags, byte spridx) {
byte *lutin_entry, *lutin_entry_end;
- lutin_entry = SeekToEntry(lutin_data, 127, &lutin_entry_end);
+ lutin_entry = seekToEntry(lutin_data, 127, &lutin_entry_end);
lutin_entry[2] = spridx;
switch (spridx) {
case 37: /*DAGGER*/
@@ -1347,7 +1347,7 @@ Load The Wall gate sprites
*/
byte *LoadMursmSprite(byte index) {
byte *pinfo, *end;
- pinfo = SeekToEntry(mursm_data, index, &end);
+ pinfo = seekToEntry(mursm_data, index, &end);
while (pinfo != end) {
uint16 flags;
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 687b5ce9540..945b484dc0c 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -437,7 +437,7 @@ uint16 LoadVar(byte **ptr, byte **varptr) {
if (vartype & VARTYPE_BLOCK) {
byte *end;
byte index = *((*ptr)++);
- varbase = SeekToEntryW(varbase, index, &end);
+ varbase = seekToEntryW(varbase, index, &end);
}
varoffs = *((*ptr)++);
#if 1
@@ -1411,7 +1411,7 @@ uint16 SCR_26_GameOver(void) {
script_byte_vars.zone_index = 135;
/*reload background*/
- while (!LoadFond())
+ while (!loadFond())
askDisk2();
JaggedZoom(backbuffer, frontbuffer);
@@ -2897,7 +2897,7 @@ void TheEnd(void) {
}
while(buttons == 0);
- while (!LoadFond())
+ while (!loadFond())
askDisk2();
JaggedZoom(backbuffer, frontbuffer);
cga_BackBufferToRealFull();
@@ -4357,7 +4357,7 @@ uint16 RunScript(byte *code) {
Get script routine
*/
byte *GetScriptSubroutine(uint16 index) {
- return SeekToEntry(templ_data, index, &script_end_ptr);
+ return seekToEntry(templ_data, index, &script_end_ptr);
}
/*
Commit: ecec62da85830d4201d263da86d3abfb96037919
https://github.com/scummvm/scummvm/commit/ecec62da85830d4201d263da86d3abfb96037919
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Renames in room.h
Changed paths:
engines/chamber/anim.cpp
engines/chamber/invent.cpp
engines/chamber/kult.cpp
engines/chamber/menu.cpp
engines/chamber/portrait.cpp
engines/chamber/room.cpp
engines/chamber/room.h
engines/chamber/script.cpp
diff --git a/engines/chamber/anim.cpp b/engines/chamber/anim.cpp
index d45c088467e..aca613ddd26 100644
--- a/engines/chamber/anim.cpp
+++ b/engines/chamber/anim.cpp
@@ -51,7 +51,7 @@ uint16 dot_effect_delay;
extern uint16 cpu_speed_delay;
extern byte *seekToEntry(byte *bank, uint16 num, byte **end);
-extern void LoadLutinSprite(uint16 lutidx);
+extern void loadLutinSprite(uint16 lutidx);
void getScratchBuffer(byte mode) {
byte *buffer = scratch_mem2;
@@ -69,7 +69,7 @@ void animLoadSprite(byte **panim) {
mode = *((*panim)++);
index = *((*panim)++);
getScratchBuffer(mode);
- LoadLutinSprite(index);
+ loadLutinSprite(index);
}
void clipSprite(byte *x, byte *y, byte *sprw, byte *sprh, byte **sprite, int8 dx, int8 dy) {
diff --git a/engines/chamber/invent.cpp b/engines/chamber/invent.cpp
index 3a575d44cda..05eb42dc068 100644
--- a/engines/chamber/invent.cpp
+++ b/engines/chamber/invent.cpp
@@ -95,7 +95,7 @@ void drawInventoryBox(uint16 filtermask, uint16 filtervalue) {
void checkInventoryItemHover(byte count) {
int16 i;
for (i = 0; i < count; i++) {
- if (IsCursorInRect((rect_t *)&inventory_spots[i])) {
+ if (isCursorInRect((rect_t *)&inventory_spots[i])) {
the_command = inventory_spots[i].command;
command_hint = inventory_spots[i].name;
cursor_color = 0xAA;
@@ -121,8 +121,8 @@ void openInventory(uint16 filtermask, uint16 filtervalue) {
pollInput();
checkInventoryItemHover(inv_count);
if (command_hint != last_command_hint)
- DrawCommandHint();
- DrawHintsAndCursor(frontbuffer);
+ drawCommandHint();
+ drawHintsAndCursor(frontbuffer);
} while (buttons == 0);
undrawCursor(frontbuffer);
}
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 52c8e24e376..711852b7f76 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -101,12 +101,12 @@ void TRAP() {
/* Main Game Loop */
void gameLoop(byte *target) {
for (;;) {
- AnimateSpots(target);
+ animateSpots(target);
/* Update/check live things */
- UpdateProtozorqs();
- CheckGameTimeLimit();
- CleanupDroppedItems();
+ updateProtozorqs();
+ checkGameTimeLimit();
+ cleanupDroppedItems();
/* Get player input */
pollInput();
@@ -115,10 +115,10 @@ void gameLoop(byte *target) {
return;
the_command = 0;
- if (IsCursorInRect(&room_bounds_rect)) {
+ if (isCursorInRect(&room_bounds_rect)) {
selectCursor(CURSOR_TARGET);
command_hint = 100;
- SelectSpotCursor();
+ selectSpotCursor();
} else {
selectCursor(CURSOR_FINGER);
object_hint = 117;
@@ -126,12 +126,12 @@ void gameLoop(byte *target) {
}
if (object_hint != last_object_hint)
- DrawObjectHint();
+ drawObjectHint();
if (command_hint != last_command_hint)
- DrawCommandHint();
+ drawCommandHint();
- DrawHintsAndCursor(target);
+ drawHintsAndCursor(target);
if (!buttons || !the_command) {
/*Pending / AI commands*/
@@ -166,25 +166,25 @@ void gameLoop(byte *target) {
process:
;
updateUndrawCursor(target);
- RefreshSpritesData();
+ refreshSpritesData();
RunCommand();
- BlitSpritesToBackBuffer();
+ blitSpritesToBackBuffer();
processInput();
- DrawSpots(target);
+ drawSpots(target);
} else {
/*Player action*/
updateUndrawCursor(target);
- RefreshSpritesData();
+ refreshSpritesData();
RunCommandKeepSp();
script_byte_vars.used_commands++;
if (script_byte_vars.dead_flag) {
if (--script_byte_vars.tries_left == 0)
- ResetAllPersons();
+ resetAllPersons();
}
- BlitSpritesToBackBuffer();
+ blitSpritesToBackBuffer();
processInput();
- DrawSpots(target);
+ drawSpots(target);
}
}
}
@@ -342,7 +342,7 @@ Common::Error ChamberEngine::run() {
return Common::kNoError;
/* Sync graphics */
- BlitSpritesToBackBuffer();
+ blitSpritesToBackBuffer();
/* Initialize cursor backup */
processInput();
diff --git a/engines/chamber/menu.cpp b/engines/chamber/menu.cpp
index c1418c9fab6..a45c89342cc 100644
--- a/engines/chamber/menu.cpp
+++ b/engines/chamber/menu.cpp
@@ -143,7 +143,7 @@ void actionsMenu(byte **pinfo) {
pollInputInActionsMenu();
for (choice = 0; choice < numchoices; choice++) {
- if (IsCursorInRect(&act_dot_rects[choice]))
+ if (isCursorInRect(&act_dot_rects[choice]))
break;
}
if (choice < numchoices) {
@@ -157,8 +157,8 @@ void actionsMenu(byte **pinfo) {
}
if (command_hint != last_command_hint)
- DrawCommandHint(); /*to backbuffer*/
- DrawHintsAndCursor(CGA_SCREENBUFFER);
+ drawCommandHint(); /*to backbuffer*/
+ drawHintsAndCursor(CGA_SCREENBUFFER);
} while (buttons == 0);
undrawCursor(CGA_SCREENBUFFER);
@@ -184,10 +184,10 @@ void menuLoop(byte spotmask, byte spotvalue) {
processInput();
do {
pollInput();
- CheckHotspots(spotmask, spotvalue);
+ checkHotspots(spotmask, spotvalue);
if (object_hint != last_object_hint)
- DrawObjectHint();
- DrawHintsAndCursor(frontbuffer);
+ drawObjectHint();
+ drawHintsAndCursor(frontbuffer);
} while (buttons == 0);
undrawCursor(frontbuffer);
}
@@ -212,7 +212,7 @@ rect_t menu_buttons_rects[] = {
void checkMenuCommandHover(void) {
int16 i;
for (i = 0; i < 8; i++) {
- if (IsCursorInRect(&menu_buttons_rects[i])) {
+ if (isCursorInRect(&menu_buttons_rects[i])) {
the_command = 0xA001 + i;
command_hint = i ? (i + 3) : 101;
cursor_color = 0xAA;
@@ -240,7 +240,7 @@ void checkPsiCommandHover(void) {
/*TODO: maybe merge it with CheckMenuCommandHover()*/
int16 i;
for (i = 0; i < 8; i++) {
- if (IsCursorInRect(&psi_buttons_rects[i])) {
+ if (isCursorInRect(&psi_buttons_rects[i])) {
the_command = 0xA00A + i;
command_hint = i + 12;
cursor_color = 0xAA;
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index 8467f54b3b7..b9c785287f3 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -303,7 +303,7 @@ void playHurtSound() {
void blinkWithSound(byte color) {
cga_ColorSelect(color);
playHurtSound();
- SelectPalette();
+ selectPalette();
}
void blinkToRed(void) {
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index bb5982a40b6..a7d187056d9 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -143,19 +143,19 @@ 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(byte index) {
+void selectSpecificPalette(byte index) {
cga_ColorSelect(cga_color_sels[index]);
}
-void SelectPalette(void) {
+void selectPalette(void) {
cga_ColorSelect(cga_color_sels[script_byte_vars.palette_index]);
}
/*
Blit sprites to backbuffer
*/
-void BlitSpritesToBackBuffer(void) {
+void blitSpritesToBackBuffer(void) {
int16 i;
for (i = 0; i < MAX_SPRITES; i++) {
byte *sprite = sprites_list[i];
@@ -166,7 +166,7 @@ void BlitSpritesToBackBuffer(void) {
/*
Copy data at sprite's rect from screen to backbuffer
*/
-void RefreshSpritesData(void) {
+void refreshSpritesData(void) {
int16 i;
for (i = 0; i < MAX_SPRITES; i++) {
byte *sprite = sprites_list[i];
@@ -177,7 +177,7 @@ void RefreshSpritesData(void) {
/*
Check if packed x/y coordinates are in rect
*/
-int16 IsInRect(byte x, byte 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;
@@ -188,14 +188,14 @@ int16 IsInRect(byte x, byte y, rect_t *rect) {
/*
Check if cursor is in rect
*/
-int16 IsCursorInRect(rect_t *rect) {
- return IsInRect(cursor_x / CGA_PIXELS_PER_BYTE, cursor_y, rect);
+int16 isCursorInRect(rect_t *rect) {
+ return isInRect(cursor_x / CGA_PIXELS_PER_BYTE, cursor_y, rect);
}
/*
Find person for a current spot
*/
-void FindPerson(void) {
+void findPerson(void) {
int16 i;
pers_t *pers = pers_list;
for (i = 0; i < PERS_MAX; i++, pers++) {
@@ -211,11 +211,11 @@ void FindPerson(void) {
/*
Select a spot under cursor if its flags are matched given criteria
*/
-void CheckHotspots(byte m, byte v) {
+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)) {
+ if (isCursorInRect((rect_t *)spot) && (spot->flags & SPOTFLG_80) && ((spot->flags & m) == v)) {
script_byte_vars.cur_spot_idx = i + 1;
spot_sprite = sprites_list + i;
found_spot = spot;
@@ -223,7 +223,7 @@ void CheckHotspots(byte m, byte v) {
object_hint = spot->hint;
cursor_color = 0xAA;
the_command = Swap16(spot->command);
- FindPerson();
+ findPerson();
return;
}
}
@@ -235,9 +235,9 @@ void CheckHotspots(byte m, byte v) {
/*
Select cursor shape for current spot
*/
-void SelectSpotCursor(void) {
+void selectSpotCursor(void) {
int16 curs = CURSOR_TARGET;
- CheckHotspots(script_byte_vars.spot_m, script_byte_vars.spot_v);
+ checkHotspots(script_byte_vars.spot_m, script_byte_vars.spot_v);
if (cursor_color == 0xAA) {
curs = CURSOR_BODY;
if ((script_byte_vars.cur_spot_flags & (SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8)) != SPOTFLG_10) {
@@ -270,7 +270,7 @@ static const int16 background_draw_steps[] = {
/*
Draw main backgound pattern, in spiral-like order
*/
-void DrawBackground(byte *target, byte vblank) {
+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*/
@@ -292,7 +292,7 @@ void DrawBackground(byte *target, byte vblank) {
/*
Load and initialize zone data
*/
-void LoadZone(void) {
+void loadZone(void) {
byte *zptr, *zend;
zptr = seekToEntry(zones_data, script_byte_vars.zone_index - 1, &zend);
@@ -346,7 +346,7 @@ void LoadZone(void) {
script_byte_vars.used_commands = 0;
}
-void ResetZone(void) {
+void resetZone(void) {
script_byte_vars.bvar_43 = 0;
script_byte_vars.bvar_4B = 0;
script_byte_vars.bvar_61 = 0;
@@ -370,7 +370,7 @@ void ResetZone(void) {
/*
Load puzzl sprite to buffer, return next free buffer ptr
*/
-byte *LoadPuzzl(byte index, byte *buffer) {
+byte *loadPuzzl(byte index, byte *buffer) {
if (script_byte_vars.palette_index == 14)
return LoadSprite(index, puzzl_data + 4, buffer, 1);
else
@@ -380,9 +380,9 @@ byte *LoadPuzzl(byte index, byte *buffer) {
/*
Load puzzl sprite to scratch buffer, return sprite ptr
*/
-byte *LoadPuzzlToScratch(byte index) {
+byte *loadPuzzlToScratch(byte index) {
byte *buffer = scratch_mem2;
- LoadPuzzl(index, buffer);
+ loadPuzzl(index, buffer);
return buffer;
}
@@ -408,7 +408,7 @@ byte arpla_y_step;
/*
Fill in sliding door animation information
*/
-void InitRoomDoorInfo(byte index) {
+void initRoomDoorInfo(byte index) {
int16 i;
byte *aptr;
byte *sprbuf;
@@ -421,7 +421,7 @@ void InitRoomDoorInfo(byte index) {
for (i = 0; i < kNumDoorSprites; i++) {
byte x, y, w, h, ox;
byte *sprite = sprbuf;
- sprbuf = LoadPuzzl(aptr[0], sprbuf);
+ sprbuf = loadPuzzl(aptr[0], sprbuf);
x = aptr[1];
y = aptr[2];
@@ -463,7 +463,7 @@ void InitRoomDoorInfo(byte index) {
/*
Draw sliding door
*/
-void DrawRoomDoor(void) {
+void drawRoomDoor(void) {
int16 i;
doorinfo_t *info = (doorinfo_t *)scratch_mem2;
for (i = 0; i < kNumDoorSprites; i++) {
@@ -485,14 +485,14 @@ void DrawRoomDoor(void) {
/*
Animate sliding door open
*/
-void AnimRoomDoorOpen(byte index) {
+void animRoomDoorOpen(byte index) {
int16 i;
byte oldheight;
doorinfo_t *info = (doorinfo_t *)scratch_mem2;
- InitRoomDoorInfo(index);
+ initRoomDoorInfo(index);
IFGM_PlaySample(29);
@@ -500,7 +500,7 @@ void AnimRoomDoorOpen(byte index) {
for (i = 0; i < oldheight / 2; i++) {
#if 1
- DrawRoomDoor();
+ drawRoomDoor();
#endif
info->layer[1].height -= 2;
info->layer[1].pixels += info->layer[1].width * 2 * 2;
@@ -512,14 +512,14 @@ void AnimRoomDoorOpen(byte index) {
/*
Animate sliding door close
*/
-void AnimRoomDoorClose(byte index) {
+void animRoomDoorClose(byte index) {
int16 i;
byte oldheight;
byte *oldpixels;
doorinfo_t *info = (doorinfo_t *)scratch_mem2;
- InitRoomDoorInfo(index);
+ initRoomDoorInfo(index);
IFGM_PlaySample(29);
@@ -531,7 +531,7 @@ void AnimRoomDoorClose(byte index) {
for (i = 0; i < oldheight / 2; i++) {
#if 1
- DrawRoomDoor();
+ drawRoomDoor();
#endif
info->layer[1].height += 2;
info->layer[1].pixels -= info->layer[1].width * 2 * 2;
@@ -539,13 +539,13 @@ void AnimRoomDoorClose(byte index) {
info->layer[1].height = oldheight;
info->layer[1].pixels = oldpixels;
- DrawRoomDoor();
+ drawRoomDoor();
playSound(31);
}
/*Maybe FindRoomDoor?*/
-byte FindInitialSpot(void) {
+byte findInitialSpot(void) {
spot_t *spot;
byte index;
byte flags = script_byte_vars.last_door;
@@ -562,7 +562,7 @@ byte FindInitialSpot(void) {
/*
Find first spot index that matches given flags
*/
-byte FindSpotByFlags(byte mask, byte value) {
+byte findSpotByFlags(byte mask, byte value) {
spot_t *spot;
byte index;
for (index = 1, spot = zone_spots; spot != zone_spots_end; spot++, index++) {
@@ -575,13 +575,13 @@ byte FindSpotByFlags(byte mask, byte value) {
/*
Select person and its spot (if available)
*/
-byte SelectPerson(byte offset) {
+byte selectPerson(byte offset) {
/*TODO: replace offset arg with index?*/
byte index = offset / 5; /* / sizeof(pers_t) */
script_vars[ScrPool8_CurrentPers] = &pers_list[index];
- index = FindSpotByFlags(0x3F, (pers_list[index].index & 7) | SPOTFLG_10); /*TODO: return 0 if not found?*/
+ index = findSpotByFlags(0x3F, (pers_list[index].index & 7) | SPOTFLG_10); /*TODO: return 0 if not found?*/
if (index == 0xFF)
return 0;
@@ -594,7 +594,7 @@ byte SelectPerson(byte offset) {
/*
Play animation at the selected spot or specified coordinates
*/
-void AnimateSpot(const animdesc_t *info) {
+void animateSpot(const animdesc_t *info) {
byte *sprite = *spot_sprite;
cga_RestoreImage(sprite, backbuffer);
if (info->index & ANIMFLG_USESPOT) {
@@ -652,7 +652,7 @@ lutinanim_t lutins_table[] = {
{0, { 0, 0, 0, 0, 0, 0, 0, 0} }
};
-void BeforeChangeZone(byte index) {
+void beforeChangeZone(byte index) {
byte oldspot;
static const animdesc_t anim57 = {ANIMFLG_USESPOT | 57, { { 0, 0 } }};
static const animdesc_t anim58 = {ANIMFLG_USESPOT | 58, { { 0, 0 } }};
@@ -667,18 +667,18 @@ void BeforeChangeZone(byte index) {
script_byte_vars.need_draw_spots = ~0;
- SelectPerson(PersonOffset(kPersScifi));
- AnimateSpot(&anim57);
+ selectPerson(PersonOffset(kPersScifi));
+ animateSpot(&anim57);
if (pers_list[kPersMonkey].area != 0) {
- SelectPerson(PersonOffset(kPersMonkey));
- AnimateSpot(&anim58);
+ selectPerson(PersonOffset(kPersMonkey));
+ animateSpot(&anim58);
}
script_byte_vars.cur_spot_idx = oldspot;
}
-void ChangeZone(byte index) {
+void changeZone(byte index) {
byte spridx = 0;
script_byte_vars.prev_zone_index = script_byte_vars.zone_index;
@@ -698,12 +698,12 @@ void ChangeZone(byte index) {
la->sprites[i] = spridx;
}
- LoadZone();
- ResetZone();
+ loadZone();
+ resetZone();
}
-void DrawPersons(void) {
+void drawPersons(void) {
int16 i;
byte index, pidx;
spot_t *spot;
@@ -728,7 +728,7 @@ void DrawPersons(void) {
spot->hint = pers_list[i].name;
pers_list[i].flags |= index;
if (spot->flags & SPOTFLG_40)
- DrawZoneAniSprite((rect_t *)spot, index, backbuffer);
+ drawZoneAniSprite((rect_t *)spot, index, backbuffer);
break;
}
}
@@ -738,10 +738,10 @@ void DrawPersons(void) {
/*
Draw room's static object to backbuffer
*/
-void DrawRoomStaticObject(byte *aptr, byte *rx, byte *ry, byte *rw, byte *rh) {
+void drawRoomStaticObject(byte *aptr, byte *rx, byte *ry, byte *rw, byte *rh) {
byte x, y, w, h;
int16 pitch;
- byte *sprite = LoadPuzzlToScratch(aptr[0]);
+ byte *sprite = loadPuzzlToScratch(aptr[0]);
x = aptr[1];
y = aptr[2];
w = sprite[0];
@@ -788,13 +788,13 @@ Draw all room's static objects (decorations) to backbuffer
Initialize room bounds rect to room's dimensions
Draw room's name box and text
*/
-void DrawRoomStatics(void) {
+void drawRoomStatics(void) {
byte *aptr, *aend;
byte doorcount = 0;
byte x, y, w, h;
uint16 xx, ww;
- DrawBackground(backbuffer, 0);
+ drawBackground(backbuffer, 0);
arpla_y_step = script_byte_vars.hands;
aptr = seekToEntry(arpla_data, script_byte_vars.zone_room - 1, &aend);
@@ -815,7 +815,7 @@ void DrawRoomStatics(void) {
continue; /*TODO: error? index may never be that high here*/
}
/*draw decor object*/
- DrawRoomStaticObject(aptr, &x, &y, &w, &h);
+ drawRoomStaticObject(aptr, &x, &y, &w, &h);
/*update room's bounding rect*/
if (x < room_bounds_rect.sx)
@@ -838,7 +838,7 @@ void DrawRoomStatics(void) {
/*print room name*/
cga_PrintChar(0x3B, backbuffer);
- DrawObjectHint(); /* area name */
+ drawObjectHint(); /* area name */
cga_PrintChar(0x3C, backbuffer);
/*draw border around hint text*/
@@ -856,7 +856,7 @@ void DrawRoomStatics(void) {
/*
Redraw all room's static objects (decorations) to backbuffer
*/
-void RedrawRoomStatics(byte index, byte y_step) {
+void redrawRoomStatics(byte index, byte y_step) {
byte *aptr, *aend;
byte x, y, w, h;
arpla_y_step = y_step;
@@ -864,14 +864,14 @@ void RedrawRoomStatics(byte index, byte y_step) {
aptr = seekToEntry(arpla_data, index - 1, &aend);
for (; aptr != aend; aptr += 3) {
/*load room's bg objs*/
- DrawRoomStaticObject(aptr, &x, &y, &w, &h);
+ drawRoomStaticObject(aptr, &x, &y, &w, &h);
}
}
/*
Draw "some item in the room" icon
*/
-void DrawRoomItemsIndicator(void) {
+void drawRoomItemsIndicator(void) {
byte spridx = 172;
int16 i;
for (i = 0; i < MAX_INV_ITEMS; i++) {
@@ -892,7 +892,7 @@ void DrawRoomItemsIndicator(void) {
}
}
-void DrawZoneSpots(void) {
+void drawZoneSpots(void) {
static const animdesc_t anim59 = {ANIMFLG_USESPOT | 59, { { 0, 0 } }};
static const animdesc_t anim60 = {ANIMFLG_USESPOT | 60, { { 0, 0 } }};
@@ -901,29 +901,29 @@ void DrawZoneSpots(void) {
if (!script_byte_vars.need_draw_spots)
return;
- SelectPerson(PersonOffset(kPersScifi));
- AnimateSpot(&anim59);
+ selectPerson(PersonOffset(kPersScifi));
+ animateSpot(&anim59);
pers_list[kPersScifi].area = script_byte_vars.zone_area;
if (pers_list[kPersMonkey].area != 0) {
pers_list[kPersMonkey].area = script_byte_vars.zone_area;
- SelectPerson(PersonOffset(kPersMonkey));
- AnimateSpot(&anim60);
+ selectPerson(PersonOffset(kPersMonkey));
+ animateSpot(&anim60);
}
script_byte_vars.cur_spot_idx = oldspot;
- DrawPersons();
+ drawPersons();
}
-void RefreshZone(void) {
+void refreshZone(void) {
popDirtyRects(DirtyRectSprite);
popDirtyRects(DirtyRectBubble);
popDirtyRects(DirtyRectText);
if (!skip_zone_transition && !right_button)
- DrawBackground(CGA_SCREENBUFFER, 1);
+ drawBackground(CGA_SCREENBUFFER, 1);
cga_BackBufferToRealFull();
@@ -934,19 +934,19 @@ void RefreshZone(void) {
in_de_profundis = 1;
}
- DrawTheWallDoors();
- SelectPalette();
- DrawRoomItemsIndicator();
- DrawZoneSpots();
+ drawTheWallDoors();
+ selectPalette();
+ drawRoomItemsIndicator();
+ drawZoneSpots();
if (script_byte_vars.cur_spot_idx != 0)
- AnimRoomDoorClose(script_byte_vars.cur_spot_idx);
- BlitSpritesToBackBuffer();
+ animRoomDoorClose(script_byte_vars.cur_spot_idx);
+ blitSpritesToBackBuffer();
}
/*
Draw object hint or zone name text to backbuffer
*/
-void DrawObjectHint(void) {
+void drawObjectHint(void) {
if (script_byte_vars.zone_index == 135)
return;
char_draw_max_width = room_hint_bar_width;
@@ -966,7 +966,7 @@ void DrawObjectHint(void) {
/*
Copy object hint from backbuffer to screen
*/
-void ShowObjectHint(byte *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,7 +975,7 @@ void ShowObjectHint(byte *target) {
/*
Draw command hint text to backbuffer
*/
-void DrawCommandHint(void) {
+void drawCommandHint(void) {
char_draw_max_width = cmd_hint_bar_width;
char_draw_coords_x = cmd_hint_bar_coords_x;
char_draw_coords_y = cmd_hint_bar_coords_y;
@@ -986,11 +986,11 @@ void DrawCommandHint(void) {
/*
Copy command hint from backbuffer to screen
*/
-void ShowCommandHint(byte *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(uint16 lutidx) {
+void loadLutinSprite(uint16 lutidx) {
byte spridx;
uint16 flags;
byte *lutin_entry, *lutin_entry_end;
@@ -1023,19 +1023,19 @@ void LoadLutinSprite(uint16 lutidx) {
buffer = lutin_mem + 2 + (flags & 0x7FFF) * 2;
if (flags & 0x8000)
- MergeSpritesDataFlip(buffer, lutin_mem[0] * 2, sprite, sprw, sprh);
+ mergeSpritesDataFlip(buffer, lutin_mem[0] * 2, sprite, sprw, sprh);
else
- MergeSpritesData(buffer, lutin_mem[0] * 2, sprite, sprw, sprh);
+ mergeSpritesData(buffer, lutin_mem[0] * 2, sprite, sprw, sprh);
}
}
/*
Draw specific room's person idle sprite
*/
-void DrawCharacterSprite(byte spridx, byte x, byte y, byte *target) {
+void drawCharacterSprite(byte spridx, byte x, byte y, byte *target) {
lutin_mem = scratch_mem2;
- LoadLutinSprite(spridx);
+ loadLutinSprite(spridx);
DrawSprite(scratch_mem2, target, cga_CalcXY_p(x, y));
}
@@ -1044,7 +1044,7 @@ void DrawCharacterSprite(byte spridx, byte x, byte y, byte *target) {
Draw room's person idle sprite and advance sprite's animation
Return true if a sprite was drawn
*/
-char DrawZoneAniSprite(rect_t *rect, uint16 index, byte *target) {
+char drawZoneAniSprite(rect_t *rect, uint16 index, byte *target) {
int16 i;
byte spridx;
pers_t *pers = pers_list;
@@ -1056,7 +1056,7 @@ char DrawZoneAniSprite(rect_t *rect, uint16 index, byte *target) {
lutin_mem = scratch_mem2;
- LoadLutinSprite(spridx);
+ loadLutinSprite(spridx);
zsprite_w = scratch_mem2[0];
zsprite_h = scratch_mem2[1];
@@ -1073,7 +1073,7 @@ char DrawZoneAniSprite(rect_t *rect, uint16 index, byte *target) {
/*
Initialize Aspirant
*/
-void PrepareAspirant(void) {
+void prepareAspirant(void) {
byte index;
byte hostility, appearance;
byte flags;
@@ -1099,7 +1099,7 @@ void PrepareAspirant(void) {
if (script_byte_vars.zone_area >= kAreaPassage1)
return;
- index = FindSpotByFlags(0x3F, 17);
+ index = findSpotByFlags(0x3F, 17);
if (index == 0xFF)
return;
aspirant_spot = &zone_spots[index - 1];
@@ -1180,7 +1180,7 @@ void PrepareAspirant(void) {
/*
Initialize Vorts
*/
-void PrepareVorts(void) {
+void prepareVorts(void) {
spot_t *spot;
if ((script_byte_vars.zone_area != kAreaTheReturn) || !(script_byte_vars.bvar_36 & 0x80)) {
@@ -1229,7 +1229,7 @@ void PrepareVorts(void) {
/*
Initialize Turkey
*/
-void PrepareTurkey(void) {
+void prepareTurkey(void) {
spot_t *spot;
if (script_byte_vars.zone_area == kAreaPlacatingThePowers && script_byte_vars.bvar_4E == 0) {
@@ -1274,8 +1274,8 @@ void PrepareTurkey(void) {
/*
Load puzzl sprite to scratch and init draw params
*/
-uint16 GetPuzzlSprite(byte index, byte x, byte y, uint16 *w, uint16 *h, uint16 *ofs) {
- byte *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);
@@ -1285,7 +1285,7 @@ uint16 GetPuzzlSprite(byte index, byte x, byte y, uint16 *w, uint16 *h, uint16 *
/*
Save specific fully drawn rooms to backbuffer
*/
-void BackupScreenOfSpecialRoom(void) {
+void backupScreenOfSpecialRoom(void) {
switch (script_byte_vars.zone_room) {
case 41: /* THE POWERS OF THE ABYSS */
case 22: /* DE PROFUNDIS */
@@ -1299,11 +1299,11 @@ void BackupScreenOfSpecialRoom(void) {
/*
Fully redraw specific rooms
*/
-void RestoreScreenOfSpecialRoom(void) {
+void restoreScreenOfSpecialRoom(void) {
switch (script_byte_vars.zone_room) {
case 23: /* DE PROFUNDIS */
case 24: /* DE PROFUNDIS */
- RedrawRoomStatics(script_byte_vars.zone_room, 0);
+ redrawRoomStatics(script_byte_vars.zone_room, 0);
break;
}
}
@@ -1311,7 +1311,7 @@ void RestoreScreenOfSpecialRoom(void) {
/*
Modify anim sprite 127
*/
-void SetAnim127Sprite(byte flags, byte spridx) {
+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;
@@ -1330,22 +1330,22 @@ void SetAnim127Sprite(byte flags, byte spridx) {
/*
Bounce current item to the room/inventory
*/
-void BounceCurrentItem(byte flags, byte y) {
+void bounceCurrentItem(byte flags, byte y) {
item_t *item = (item_t *)(script_vars[ScrPool3_CurrentItem]);
- SetAnim127Sprite(flags, item->sprite);
+ setAnim127Sprite(flags, item->sprite);
item->flags = flags;
item->area = script_byte_vars.zone_area;
- BackupScreenOfSpecialRoom();
+ backupScreenOfSpecialRoom();
playAnim(41, 176 / 4, y);
- DrawRoomItemsIndicator();
- RestoreScreenOfSpecialRoom();
+ drawRoomItemsIndicator();
+ restoreScreenOfSpecialRoom();
}
/*
Load The Wall gate sprites
*/
-byte *LoadMursmSprite(byte index) {
+byte *loadMursmSprite(byte index) {
byte *pinfo, *end;
pinfo = seekToEntry(mursm_data, index, &end);
@@ -1361,7 +1361,7 @@ byte *LoadMursmSprite(byte index) {
buffer = sprit_load_buffer + (flags & 0x3FFF);
pitch = 20;
- sprite = LoadPuzzlToScratch(index & 0x7F);
+ sprite = loadPuzzlToScratch(index & 0x7F);
sprw = *sprite++;
sprh = *sprite++;
@@ -1386,7 +1386,7 @@ thewalldoor_t the_wall_doors[2];
Open The Wall's right gate
TODO: move this to CGA?
*/
-void TheWallOpenRightDoor(byte x, byte y, byte width, byte height, byte limit) {
+void theWallOpenRightDoor(byte x, byte y, byte width, byte height, byte limit) {
uint16 offs = cga_CalcXY_p(x + width - 2, y);
while (--width) {
@@ -1415,7 +1415,7 @@ void TheWallOpenRightDoor(byte x, byte y, byte width, byte height, byte limit) {
Open The Wall's left gate
TODO: move this to CGA?
*/
-void TheWallOpenLeftDoor(byte x, byte y, byte width, byte height, byte limit) {
+void theWallOpenLeftDoor(byte x, byte y, byte width, byte height, byte limit) {
uint16 offs = cga_CalcXY_p(x + 1, y);
while (--width) {
@@ -1443,12 +1443,12 @@ void TheWallOpenLeftDoor(byte x, byte y, byte width, byte height, byte limit) {
Animate The Wall doors
Phase 3: Fully closed -> Half opened
*/
-void TheWallPhase3_DoorOpen1(void) {
+void theWallPhase3_DoorOpen1(void) {
script_byte_vars.zone_index = (script_byte_vars.zone_index == 95) ? 9 : 102;
- LoadZone();
+ loadZone();
- TheWallOpenRightDoor(144 / 4, 32, 80 / 4, 59, 40 / 4);
- TheWallOpenLeftDoor(64 / 4, 32, 80 / 4, 59, 40 / 4);
+ theWallOpenRightDoor(144 / 4, 32, 80 / 4, 59, 40 / 4);
+ theWallOpenLeftDoor(64 / 4, 32, 80 / 4, 59, 40 / 4);
IFGM_StopSample();
@@ -1459,12 +1459,12 @@ void TheWallPhase3_DoorOpen1(void) {
Animate The Wall doors
Phase 0: Half opened -> Fully opened
*/
-void TheWallPhase0_DoorOpen2(void) {
+void theWallPhase0_DoorOpen2(void) {
script_byte_vars.zone_index = (script_byte_vars.zone_index == 9) ? 24 : 30;
- LoadZone();
+ loadZone();
- TheWallOpenRightDoor((144 + 40) / 4, 32, (80 - 40) / 4, 59, 0);
- TheWallOpenLeftDoor(64 / 4, 32, (80 - 40) / 4, 59, 0);
+ theWallOpenRightDoor((144 + 40) / 4, 32, (80 - 40) / 4, 59, 0);
+ theWallOpenLeftDoor(64 / 4, 32, (80 - 40) / 4, 59, 0);
IFGM_StopSample();
@@ -1475,18 +1475,18 @@ void TheWallPhase0_DoorOpen2(void) {
Animate The Wall doors
Phase 1: Opened -> Half closed
*/
-void TheWallPhase1_DoorClose1(void) {
+void theWallPhase1_DoorClose1(void) {
byte *spr;
script_byte_vars.zone_index = (script_byte_vars.zone_index == 24) ? 9 : 102;
- LoadZone();
+ loadZone();
- spr = LoadMursmSprite(0);
+ spr = loadMursmSprite(0);
spr += cur_frame_width - 1;
cur_image_coords_x = 64 / 4;
cga_AnimLiftToRight(10, spr, cur_frame_width, 1, cur_image_size_h, frontbuffer, cga_CalcXY_p(cur_image_coords_x, cur_image_coords_y));
- spr = LoadMursmSprite(1);
+ spr = loadMursmSprite(1);
cur_image_coords_x = 220 / 4;
cga_AnimLiftToLeft(10, spr, cur_frame_width, 1, cur_image_size_h, frontbuffer, cga_CalcXY_p(cur_image_coords_x, cur_image_coords_y));
@@ -1499,18 +1499,18 @@ void TheWallPhase1_DoorClose1(void) {
Animate The Wall doors
Phase 2: Half closed -> Fully closed
*/
-void TheWallPhase2_DoorClose2(void) {
+void theWallPhase2_DoorClose2(void) {
byte *spr;
script_byte_vars.zone_index = (script_byte_vars.zone_index == 9) ? 95 : 103;
- LoadZone();
+ loadZone();
- spr = LoadMursmSprite(0);
+ spr = loadMursmSprite(0);
spr += cur_frame_width - 1;
cur_image_coords_x = 64 / 4;
cga_AnimLiftToRight(10, spr - 10, cur_frame_width, 1 + 10, cur_image_size_h, frontbuffer, cga_CalcXY_p(cur_image_coords_x, cur_image_coords_y));
- spr = LoadMursmSprite(1);
+ spr = loadMursmSprite(1);
cur_image_coords_x = 220 / 4;
cga_AnimLiftToLeft(10, spr, cur_frame_width, 1 + 10, cur_image_size_h, frontbuffer, cga_CalcXY_p(cur_image_coords_x, cur_image_coords_y) - 10);
@@ -1522,22 +1522,22 @@ void TheWallPhase2_DoorClose2(void) {
/*
Draw default The Wall doors
*/
-void DrawTheWallDoors(void) {
+void drawTheWallDoors(void) {
switch (script_byte_vars.zone_index) {
case 9:
case 102:
- cga_Blit(LoadMursmSprite(0) + 10, 20, 10, 59, CGA_SCREENBUFFER, cga_CalcXY_p(64 / CGA_PIXELS_PER_BYTE, 32));
+ cga_Blit(loadMursmSprite(0) + 10, 20, 10, 59, CGA_SCREENBUFFER, cga_CalcXY_p(64 / CGA_PIXELS_PER_BYTE, 32));
if (g_vm->getLanguage() == Common::EN_USA) {
/*This fixes odd black patch on the right gate door*/
- cga_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, cga_CalcXY_p(184 / CGA_PIXELS_PER_BYTE, 32));
+ cga_Blit(loadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, cga_CalcXY_p(184 / CGA_PIXELS_PER_BYTE, 32));
} else {
- cga_Blit(LoadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, cga_CalcXY_p(180 / CGA_PIXELS_PER_BYTE, 32));
+ cga_Blit(loadMursmSprite(1) , 20, 10, 59, CGA_SCREENBUFFER, cga_CalcXY_p(180 / CGA_PIXELS_PER_BYTE, 32));
}
break;
case 95:
case 103:
- cga_Blit(LoadMursmSprite(0), 20, 20, 59, CGA_SCREENBUFFER, cga_CalcXY_p(64 / CGA_PIXELS_PER_BYTE, 32));
- cga_Blit(LoadMursmSprite(1), 20, 20, 59, CGA_SCREENBUFFER, cga_CalcXY_p(144 / CGA_PIXELS_PER_BYTE, 32));
+ cga_Blit(loadMursmSprite(0), 20, 20, 59, CGA_SCREENBUFFER, cga_CalcXY_p(64 / CGA_PIXELS_PER_BYTE, 32));
+ cga_Blit(loadMursmSprite(1), 20, 20, 59, CGA_SCREENBUFFER, cga_CalcXY_p(144 / CGA_PIXELS_PER_BYTE, 32));
break;
}
}
@@ -1545,7 +1545,7 @@ void DrawTheWallDoors(void) {
/*
Superimpose source sprite data over target sprite data
*/
-void MergeSpritesData(byte *target, uint16 pitch, byte *source, uint16 w, uint16 h) {
+void mergeSpritesData(byte *target, uint16 pitch, byte *source, uint16 w, uint16 h) {
uint16 x;
while (h--) {
for (x = 0; x < w; x++) {
@@ -1562,7 +1562,7 @@ void MergeSpritesData(byte *target, uint16 pitch, byte *source, uint16 w, uint16
/*
Superimpose horizontally-flipped source sprite data over target sprite data
*/
-void MergeSpritesDataFlip(byte *target, uint16 pitch, byte *source, uint16 w, uint16 h) {
+void mergeSpritesDataFlip(byte *target, uint16 pitch, byte *source, uint16 w, uint16 h) {
uint16 x;
target += w * 2 - 2;
while (h--) {
@@ -1582,7 +1582,7 @@ void MergeSpritesDataFlip(byte *target, uint16 pitch, byte *source, uint16 w, ui
Save image at the rect to buffer
Return current and next free buffer ptr
*/
-byte *BackupSpotImage(spot_t *spot, byte **spotback, byte *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;
@@ -1591,7 +1591,7 @@ byte *BackupSpotImage(spot_t *spot, byte **spotback, byte *buffer) {
/*
Save zone spot images to sprites list
*/
-void BackupSpotsImages(void) {
+void backupSpotsImages(void) {
spot_t *spot = zone_spots;
byte *buffer = scratch_mem1;
int16 i;
@@ -1599,7 +1599,7 @@ void BackupSpotsImages(void) {
sprites_list[i] = 0;
for (i = 0; spot != zone_spots_end; spot++, i++) { /*TODO: maybe don't advance it if spot is skipped?*/
if (spot->flags & SPOTFLG_40)
- buffer = BackupSpotImage(spot, &sprites_list[i], buffer);
+ buffer = backupSpotImage(spot, &sprites_list[i], buffer);
}
}
@@ -1607,7 +1607,7 @@ void BackupSpotsImages(void) {
Animate all room's persons, one per call
TODO: rename me
*/
-void DrawSpots(byte *target) {
+void drawSpots(byte *target) {
spot_t *spot = zone_spots_cur;
byte spridx = zone_spr_index;
if (spot == zone_spots_end) {
@@ -1621,7 +1621,7 @@ void DrawSpots(byte *target) {
zone_spots_cur = spot + 1;
zone_spr_index = spridx;
/*TODO: subclass spot_t from rect_t*/
- if (DrawZoneAniSprite((rect_t *)spot, (spot - zone_spots) + 1, backbuffer)) {
+ if (drawZoneAniSprite((rect_t *)spot, (spot - zone_spots) + 1, backbuffer)) {
updateCursor();
waitVBlank();
undrawCursor(target);
@@ -1642,25 +1642,25 @@ void DrawSpots(byte *target) {
Animate room's persons at fixed rate
TODO: rename me
*/
-void AnimateSpots(byte *target) {
+void animateSpots(byte *target) {
if (script_byte_vars.timer_ticks % 32 == 31)
- DrawSpots(target);
+ drawSpots(target);
}
/*
Draw cursor and hints text on screen
*/
-void DrawHintsAndCursor(byte *target) {
+void drawHintsAndCursor(byte *target) {
updateCursor();
waitVBlank();
undrawCursor(target);
if (object_hint != last_object_hint) {
- ShowObjectHint(target);
+ showObjectHint(target);
last_object_hint = object_hint;
}
if (command_hint != last_command_hint) {
- ShowCommandHint(target);
+ showCommandHint(target);
last_command_hint = command_hint;
}
@@ -1670,8 +1670,8 @@ void DrawHintsAndCursor(byte *target) {
/*
Hide a person
*/
-void HidePerson(byte offset) {
- SelectPerson(offset);
+void hidePerson(byte offset) {
+ selectPerson(offset);
found_spot->flags &= ~SPOTFLG_80;
}
@@ -1687,7 +1687,7 @@ const byte *timed_seq_ptr = patrol_route;
/*
Update Protozorqs locations
*/
-void UpdateProtozorqs(void) {
+void updateProtozorqs(void) {
uint16 elapsed;
if (script_byte_vars.bvar_45 != 0)
@@ -1747,13 +1747,13 @@ void UpdateProtozorqs(void) {
if (script_byte_vars.zone_area == script_byte_vars.bvar_3F) {
static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35, { { 0, 0 } }};
updateUndrawCursor(frontbuffer);
- RefreshSpritesData();
- HidePerson(PersonOffset(kPersProtozorq14));
- HidePerson(PersonOffset(kPersProtozorq5));
- HidePerson(PersonOffset(kPersProtozorq12));
- HidePerson(PersonOffset(kPersProtozorq13));
- AnimateSpot(&anim35);
- BlitSpritesToBackBuffer();
+ refreshSpritesData();
+ hidePerson(PersonOffset(kPersProtozorq14));
+ hidePerson(PersonOffset(kPersProtozorq5));
+ hidePerson(PersonOffset(kPersProtozorq12));
+ hidePerson(PersonOffset(kPersProtozorq13));
+ animateSpot(&anim35);
+ blitSpritesToBackBuffer();
drawCursor(frontbuffer);
return;
}
@@ -1761,24 +1761,24 @@ void UpdateProtozorqs(void) {
if (script_byte_vars.zone_area == script_byte_vars.bvar_40) {
static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34, { { 0, 0 } }};
updateUndrawCursor(frontbuffer);
- RefreshSpritesData();
+ refreshSpritesData();
- SelectPerson(PersonOffset(kPersProtozorq14));
- AnimateSpot(&anim34);
+ selectPerson(PersonOffset(kPersProtozorq14));
+ animateSpot(&anim34);
- if (SelectPerson(PersonOffset(kPersProtozorq12))) {
- AnimateSpot(&anim34);
+ if (selectPerson(PersonOffset(kPersProtozorq12))) {
+ animateSpot(&anim34);
- SelectPerson(PersonOffset(kPersProtozorq5));
- AnimateSpot(&anim34);
+ selectPerson(PersonOffset(kPersProtozorq5));
+ animateSpot(&anim34);
- SelectPerson(PersonOffset(kPersProtozorq13));
- AnimateSpot(&anim34);
+ selectPerson(PersonOffset(kPersProtozorq13));
+ animateSpot(&anim34);
}
- DrawPersons();
+ drawPersons();
cga_BackBufferToRealFull();
- BlitSpritesToBackBuffer();
+ blitSpritesToBackBuffer();
drawCursor(frontbuffer);
if (script_byte_vars.zapstiks_owned != 0)
@@ -1798,10 +1798,10 @@ void UpdateProtozorqs(void) {
if (script_byte_vars.zone_area == script_byte_vars.bvar_3F) {
static const animdesc_t anim35 = {ANIMFLG_USESPOT | 35, { { 0, 0 } }};
updateUndrawCursor(frontbuffer);
- RefreshSpritesData();
- HidePerson(PersonOffset(kPersProtozorq14));
- AnimateSpot(&anim35);
- BlitSpritesToBackBuffer();
+ refreshSpritesData();
+ hidePerson(PersonOffset(kPersProtozorq14));
+ animateSpot(&anim35);
+ blitSpritesToBackBuffer();
drawCursor(frontbuffer);
return;
}
@@ -1809,14 +1809,14 @@ void UpdateProtozorqs(void) {
if (script_byte_vars.zone_area == script_byte_vars.bvar_40) {
static const animdesc_t anim34 = {ANIMFLG_USESPOT | 34, { { 0, 0 } }};
updateUndrawCursor(frontbuffer);
- RefreshSpritesData();
+ refreshSpritesData();
- SelectPerson(PersonOffset(kPersProtozorq14));
- AnimateSpot(&anim34);
+ selectPerson(PersonOffset(kPersProtozorq14));
+ animateSpot(&anim34);
- DrawPersons();
+ drawPersons();
cga_BackBufferToRealFull();
- BlitSpritesToBackBuffer();
+ blitSpritesToBackBuffer();
drawCursor(frontbuffer);
return;
@@ -1827,7 +1827,7 @@ void UpdateProtozorqs(void) {
/*
Check how many time have passed and call the guards
*/
-void CheckGameTimeLimit(void) {
+void checkGameTimeLimit(void) {
uint16 elapsed = Swap16(script_word_vars.timer_ticks2);
if (elapsed < 60 * 60)
@@ -1868,7 +1868,7 @@ void CheckGameTimeLimit(void) {
/*
Clean up dropped items after some time
*/
-void CleanupDroppedItems(void) {
+void cleanupDroppedItems(void) {
int16 i;
if (Swap16(script_word_vars.timer_ticks2) - drops_cleanup_time < 180)
@@ -1883,7 +1883,7 @@ void CleanupDroppedItems(void) {
}
}
-void ResetAllPersons(void) {
+void resetAllPersons(void) {
int16 i;
for (i = 0; i < PERS_MAX; i++)
pers_list[i].flags &= ~PERSFLG_80;
diff --git a/engines/chamber/room.h b/engines/chamber/room.h
index 91073bf8448..80a964a5f75 100644
--- a/engines/chamber/room.h
+++ b/engines/chamber/room.h
@@ -159,79 +159,79 @@ typedef struct thewalldoor_t {
extern thewalldoor_t the_wall_doors[2];
-int16 IsInRect(byte x, byte y, rect_t *rect);
-int16 IsCursorInRect(rect_t *rect);
-void SelectSpotCursor(void);
+int16 isInRect(byte x, byte y, rect_t *rect);
+int16 isCursorInRect(rect_t *rect);
+void selectSpotCursor(void);
-void CheckHotspots(byte m, byte v);
+void checkHotspots(byte m, byte v);
-void AnimateSpot(const animdesc_t *info);
-byte *LoadPuzzlToScratch(byte index);
+void animateSpot(const animdesc_t *info);
+byte *loadPuzzlToScratch(byte index);
-void DrawObjectHint(void);
-void ShowObjectHint(byte *target);
-void DrawCommandHint(void);
-void ShowCommandHint(byte *target);
+void drawObjectHint(void);
+void showObjectHint(byte *target);
+void drawCommandHint(void);
+void showCommandHint(byte *target);
-void DrawCharacterSprite(byte spridx, byte x, byte y, byte *target);
-char DrawZoneAniSprite(rect_t *rect, uint16 index, byte *target);
+void drawCharacterSprite(byte spridx, byte x, byte y, byte *target);
+char drawZoneAniSprite(rect_t *rect, uint16 index, byte *target);
-void DrawHintsAndCursor(byte *target);
+void drawHintsAndCursor(byte *target);
-void DrawTheWallDoors(void);
-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 drawTheWallDoors(void);
+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);
-byte *BackupSpotImage(spot_t *spot, byte **spotback, byte *buffer);
-void BackupSpotsImages(void);
+void refreshSpritesData(void);
+void blitSpritesToBackBuffer(void);
+byte *backupSpotImage(spot_t *spot, byte **spotback, byte *buffer);
+void backupSpotsImages(void);
-void SelectPalette(void);
-void SelectSpecificPalette(byte index);
+void selectPalette(void);
+void selectSpecificPalette(byte index);
-byte FindSpotByFlags(byte mask, byte value);
-byte SelectPerson(byte offset);
+byte findSpotByFlags(byte mask, byte value);
+byte selectPerson(byte offset);
-void FindPerson(void);
+void findPerson(void);
-void BeforeChangeZone(byte index);
-void DrawRoomItemsIndicator(void);
-void DrawRoomStaticObject(byte *aptr, byte *rx, byte *ry, byte *rw, byte *rh);
-void DrawRoomStatics(void);
-void RedrawRoomStatics(byte index, byte y_step);
-void DrawPersons(void);
-void RefreshZone(void);
-void ChangeZone(byte index);
+void beforeChangeZone(byte index);
+void drawRoomItemsIndicator(void);
+void drawRoomStaticObject(byte *aptr, byte *rx, byte *ry, byte *rw, byte *rh);
+void drawRoomStatics(void);
+void redrawRoomStatics(byte index, byte y_step);
+void drawPersons(void);
+void refreshZone(void);
+void changeZone(byte index);
-void DrawSpots(byte *target);
-void AnimateSpots(byte *target);
+void drawSpots(byte *target);
+void animateSpots(byte *target);
-byte FindInitialSpot(void);
-void AnimRoomDoorOpen(byte index);
-void AnimRoomDoorClose(byte index);
+byte findInitialSpot(void);
+void animRoomDoorOpen(byte index);
+void animRoomDoorClose(byte index);
-uint16 GetPuzzlSprite(byte index, byte x, byte y, uint16 *w, uint16 *h, uint16 *ofs);
+uint16 getPuzzlSprite(byte index, byte x, byte y, uint16 *w, uint16 *h, uint16 *ofs);
-void BounceCurrentItem(byte flags, byte y);
+void bounceCurrentItem(byte flags, byte y);
-void BackupScreenOfSpecialRoom(void);
-void RestoreScreenOfSpecialRoom(void);
+void backupScreenOfSpecialRoom(void);
+void restoreScreenOfSpecialRoom(void);
-void TheWallPhase3_DoorOpen1(void);
-void TheWallPhase0_DoorOpen2(void);
-void TheWallPhase1_DoorClose1(void);
-void TheWallPhase2_DoorClose2(void);
+void theWallPhase3_DoorOpen1(void);
+void theWallPhase0_DoorOpen2(void);
+void theWallPhase1_DoorClose1(void);
+void theWallPhase2_DoorClose2(void);
-void PrepareAspirant(void);
-void PrepareVorts(void);
-void PrepareTurkey(void);
+void prepareAspirant(void);
+void prepareVorts(void);
+void prepareTurkey(void);
-void UpdateProtozorqs(void);
-void CheckGameTimeLimit(void);
-void CleanupDroppedItems(void);
+void updateProtozorqs(void);
+void checkGameTimeLimit(void);
+void cleanupDroppedItems(void);
-void ResetAllPersons(void);
+void resetAllPersons(void);
} // End of namespace Chamber
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 945b484dc0c..dd0d22ed089 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -331,7 +331,7 @@ uint16 SCR_4_StealZapstik(void) {
script_vars[ScrPool3_CurrentItem] = &inventory_items[kItemZapstik1 - 1 + (script_byte_vars.cur_pers - 1) - kPersProtozorq1];
script_byte_vars.steals_count++;
- BounceCurrentItem(ITEMFLG_OWNED, 85); /*bounce to inventory*/
+ bounceCurrentItem(ITEMFLG_OWNED, 85); /*bounce to inventory*/
the_command = 0x9147; /*YOU GET HIS ZAPSTIK*/
if (script_byte_vars.zapstik_stolen == 0) {
@@ -1195,7 +1195,7 @@ uint16 SCR_39_AnimRoomDoorOpen(void) {
script_ptr++;
door = *script_ptr++;
- AnimRoomDoorOpen(door);
+ animRoomDoorOpen(door);
return 0;
}
@@ -1207,7 +1207,7 @@ uint16 SCR_3A_AnimRoomDoorClose(void) {
script_ptr++;
door = *script_ptr++;
- AnimRoomDoorClose(door);
+ animRoomDoorClose(door);
return 0;
}
@@ -1218,7 +1218,7 @@ uint16 SCR_25_ChangeZoneOnly(void) {
script_ptr++;
index = *script_ptr++;
- ChangeZone(index);
+ changeZone(index);
script_byte_vars.zone_room = old;
return 0;
}
@@ -1426,7 +1426,7 @@ Draw all active room's persons
*/
uint16 SCR_4C_DrawPersons(void) {
script_ptr++;
- DrawPersons();
+ drawPersons();
return 0;
}
@@ -1437,7 +1437,7 @@ uint16 SCR_13_RedrawRoomStatics(void) {
byte index;
script_ptr++;
index = *script_ptr++;
- RedrawRoomStatics(index, 0);
+ redrawRoomStatics(index, 0);
return 0;
}
@@ -1459,29 +1459,29 @@ uint16 SCR_42_LoadZone(void) {
script_byte_vars.last_door = script_byte_vars.cur_spot_flags & 7;
else if ((script_byte_vars.cur_spot_flags & ((SPOTFLG_20 | SPOTFLG_10 | SPOTFLG_8))) == SPOTFLG_8) {
skip_zone_transition = 1;
- AnimRoomDoorOpen(script_byte_vars.cur_spot_idx);
+ animRoomDoorOpen(script_byte_vars.cur_spot_idx);
script_byte_vars.last_door = script_byte_vars.cur_spot_flags & 7;
} else
script_byte_vars.last_door = 0;
}
- BeforeChangeZone(index);
- ChangeZone(index);
+ beforeChangeZone(index);
+ changeZone(index);
script_byte_vars.zone_area_copy = script_byte_vars.zone_area;
- script_byte_vars.cur_spot_idx = FindInitialSpot();
+ script_byte_vars.cur_spot_idx = findInitialSpot();
skip_zone_transition |= script_byte_vars.cur_spot_idx;
- DrawRoomStatics();
+ drawRoomStatics();
if (script_byte_vars.bvar_5F != 0) {
- RedrawRoomStatics(script_byte_vars.bvar_5F, 0);
+ redrawRoomStatics(script_byte_vars.bvar_5F, 0);
script_byte_vars.bvar_5F = 0;
}
- BackupSpotsImages();
- PrepareVorts();
- PrepareTurkey();
- PrepareAspirant();
- DrawPersons();
+ backupSpotsImages();
+ prepareVorts();
+ prepareTurkey();
+ prepareAspirant();
+ drawPersons();
script_byte_vars.cur_spot_flags = 0;
return 0;
}
@@ -1489,9 +1489,9 @@ uint16 SCR_42_LoadZone(void) {
/*
Draw current sprites
*/
-uint16 SCR_59_BlitSpritesToBackBuffer(void) {
+uint16 SCR_59_blitSpritesToBackBuffer(void) {
script_ptr++;
- BlitSpritesToBackBuffer();
+ blitSpritesToBackBuffer();
return 0;
}
@@ -1500,7 +1500,7 @@ Apply current palette
*/
uint16 SCR_5A_SelectPalette(void) {
script_ptr++;
- SelectPalette();
+ selectPalette();
return 0;
}
@@ -1511,7 +1511,7 @@ uint16 SCR_5E_SelectTempPalette(void) {
byte index;
script_ptr++;
index = *script_ptr++;
- SelectSpecificPalette(index);
+ selectSpecificPalette(index);
return 0;
}
@@ -1520,7 +1520,7 @@ Draw new zone
*/
uint16 SCR_43_RefreshZone(void) {
script_ptr++;
- RefreshZone();
+ refreshZone();
return 0;
}
@@ -1529,7 +1529,7 @@ Go to new zone and draw it
*/
uint16 SCR_36_ChangeZone(void) {
SCR_42_LoadZone();
- RefreshZone();
+ refreshZone();
return 0;
}
@@ -1544,7 +1544,7 @@ void SCR_DrawRoomObjectBack(byte *x, byte *y, byte *w, byte *h) {
obj[1] = *script_ptr++; /*x*/
obj[2] = *script_ptr++; /*y*/
- DrawRoomStaticObject(obj, x, y, w, h);
+ drawRoomStaticObject(obj, x, y, w, h);
}
/*
@@ -1673,7 +1673,7 @@ uint16 SCR_3D_ActionsMenu(void) {
script_ptr = old_script;
if (--script_byte_vars.tries_left == 0)
- ResetAllPersons();
+ resetAllPersons();
}
script_end_ptr = old_script_end;
@@ -1690,16 +1690,16 @@ uint16 SCR_3E_TheWallAdvance(void) {
script_byte_vars.the_wall_phase = (script_byte_vars.the_wall_phase + 1) % 4;
switch (script_byte_vars.the_wall_phase) {
default:
- TheWallPhase3_DoorOpen1();
+ theWallPhase3_DoorOpen1();
break;
case 0:
- TheWallPhase0_DoorOpen2();
+ theWallPhase0_DoorOpen2();
break;
case 1:
- TheWallPhase1_DoorClose1();
+ theWallPhase1_DoorClose1();
break;
case 2:
- TheWallPhase2_DoorClose2();
+ theWallPhase2_DoorClose2();
break;
}
@@ -1849,7 +1849,7 @@ Draw updated Hands in Who Will Be Saved
*/
uint16 SCR_41_LiftHand(void) {
script_ptr++;
- RedrawRoomStatics(92, script_byte_vars.hands);
+ redrawRoomStatics(92, script_byte_vars.hands);
cga_BackBufferToRealFull();
playSound(31);
return 0;
@@ -1880,7 +1880,7 @@ uint16 SCR_30_Fight(void) {
if (next_vorts_cmd == 0xA015) {
the_command = 0xA015;
RunCommand();
- SelectPerson(PersonOffset(pers - pers_list));
+ selectPerson(PersonOffset(pers - pers_list));
}
if (Swap16(script_word_vars.next_aspirant_cmd) == 0xC357) {
the_command = 0xC357;
@@ -2087,7 +2087,7 @@ uint16 SCR_31_Fight2(void) {
pers_list[kPersVort2].flags = pers->flags;
if (script_byte_vars.zapstiks_owned == 0) {
static const animdesc_t anim19 = {ANIMFLG_USESPOT | 19, { { 0, 0 } }};
- AnimateSpot(&anim19);
+ animateSpot(&anim19);
}
the_command = next_vorts_cmd;
RunCommand();
@@ -2096,7 +2096,7 @@ uint16 SCR_31_Fight2(void) {
pers_list[kPersVort3].flags = pers->flags;
if (script_byte_vars.zapstiks_owned == 0) {
static const animdesc_t anim20 = {ANIMFLG_USESPOT | 20, { { 0, 0 } }};
- AnimateSpot(&anim20);
+ animateSpot(&anim20);
}
the_command = next_vorts_cmd;
RunCommand();
@@ -2183,7 +2183,7 @@ void DrawDeathAnim(void) {
int16 i;
/*remove existing cadaver if any*/
- if (SelectPerson(PersonOffset(kPersCadaver))) {
+ if (selectPerson(PersonOffset(kPersCadaver))) {
found_spot->flags &= ~SPOTFLG_80;
cga_RestoreImage(*spot_sprite, backbuffer);
}
@@ -2208,16 +2208,16 @@ uint16 SCR_60_ReviveCadaver(void) {
pers_t *pers;
script_ptr++;
- BlitSpritesToBackBuffer();
+ blitSpritesToBackBuffer();
- SelectPerson(PersonOffset(kPersCadaver));
+ selectPerson(PersonOffset(kPersCadaver));
script_byte_vars.bvar_60 = 1;
FightWin();
script_byte_vars.bvar_60 = 0;
pers_list[kPersCadaver].area = 0;
- SelectPerson(fight_pers_ofs);
+ selectPerson(fight_pers_ofs);
zone_spots[5].flags = SPOTFLG_40 | SPOTFLG_10 | SPOTFLG_2 | SPOTFLG_1;
found_spot->flags |= SPOTFLG_80;
@@ -2225,7 +2225,7 @@ uint16 SCR_60_ReviveCadaver(void) {
pers->flags &= ~PERSFLG_40;
pers->area = script_byte_vars.zone_area;
- DrawPersons();
+ drawPersons();
cga_BackBufferToRealFull();
return 0;
@@ -2240,7 +2240,7 @@ uint16 SCR_57_ShowCharacterSprite(void) {
x = *script_ptr++;
y = *script_ptr++;
- DrawCharacterSprite(index, x, y, frontbuffer);
+ drawCharacterSprite(index, x, y, frontbuffer);
return 0;
}
@@ -2253,12 +2253,12 @@ uint16 SCR_58_DrawCharacterSprite(void) {
x = *script_ptr++;
y = *script_ptr++;
- DrawCharacterSprite(index, x, y, backbuffer);
+ drawCharacterSprite(index, x, y, backbuffer);
return 0;
}
-extern void ExitGame(void);
+extern void exitGame(void);
uint16 SCR_15_SelectSpot(void) {
byte mask, index;
@@ -2267,17 +2267,17 @@ uint16 SCR_15_SelectSpot(void) {
mask = *script_ptr++;
index = *script_ptr++;
if (mask != 0) {
- index = FindSpotByFlags(mask, index); /*TODO: return 0 if not found?*/
+ index = findSpotByFlags(mask, index); /*TODO: return 0 if not found?*/
if (index == 0xFF) {
TODO("ERROR: SelectSpot: spot not found");
- ExitGame(); /*hard abort*/
+ exitGame(); /*hard abort*/
}
}
found_spot = &zone_spots[index - 1];
script_byte_vars.cur_spot_idx = index;
spot_sprite = &sprites_list[index - 1];
- FindPerson();
+ findPerson();
if (script_byte_vars.cur_pers == 0)
script_vars[ScrPool8_CurrentPers] = &pers_list[kPersProtozorq12];
@@ -2301,11 +2301,11 @@ uint16 SCR_45_DeProfundisRoomEntry(void) {
script_ptr++;
/*draw Platform*/
- sprofs = GetPuzzlSprite(3, 140 / 4, 174, &w, &h, &ofs);
+ sprofs = getPuzzlSprite(3, 140 / 4, 174, &w, &h, &ofs);
cga_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
/*draw Granite Monster*/
- sprofs = GetPuzzlSprite(119, 128 / 4, 94, &w, &h, &ofs);
+ sprofs = getPuzzlSprite(119, 128 / 4, 94, &w, &h, &ofs);
cga_BlitScratchBackSprite(sprofs, w, h, CGA_SCREENBUFFER, ofs);
promptWait();
@@ -2338,7 +2338,7 @@ uint16 SCR_46_DeProfundisLowerHook(void) {
script_ptr++;
/*draw Hook*/
- sprofs = GetPuzzlSprite(96, 140 / 4, 18, &w, &h, &ofs);
+ sprofs = getPuzzlSprite(96, 140 / 4, 18, &w, &h, &ofs);
h = 1;
y = 15;
@@ -2368,7 +2368,7 @@ uint16 SCR_47_DeProfundisRiseMonster(void) {
script_ptr++;
/*draw Granite Monster head*/
- sprofs = GetPuzzlSprite(118, 112 / 4, 174, &w, &h, &ofs);
+ sprofs = getPuzzlSprite(118, 112 / 4, 174, &w, &h, &ofs);
h = 1;
y = 68;
@@ -2399,7 +2399,7 @@ uint16 SCR_48_DeProfundisLowerMonster(void) {
script_ptr++;
/*draw Hook*/
- sprofs = GetPuzzlSprite(118, 112 / 4, 106, &w, &h, &ofs);
+ sprofs = getPuzzlSprite(118, 112 / 4, 106, &w, &h, &ofs);
y = 34;
@@ -2429,7 +2429,7 @@ uint16 SCR_49_DeProfundisRiseHook(void) {
script_ptr++;
/*draw Hook*/
- sprofs = GetPuzzlSprite(96, 140 / 4, 18, &w, &h, &ofs);
+ sprofs = getPuzzlSprite(96, 140 / 4, 18, &w, &h, &ofs);
h = 16;
y = 15;
@@ -2467,7 +2467,7 @@ uint16 SCR_65_DeProfundisMovePlatform(void) {
y += 4;
/*draw Platform*/
- sprofs = GetPuzzlSprite(3, x, y, &w, &h, &ofs);
+ sprofs = getPuzzlSprite(3, x, y, &w, &h, &ofs);
y = 4;
if (state) {
@@ -2504,7 +2504,7 @@ uint16 SCR_66_DeProfundisRideToExit(void) {
script_ptr++;
/*draw Granite Monster*/
- sprofs = GetPuzzlSprite(119, 128 / 4, 139, &w, &h, &ofs);
+ sprofs = getPuzzlSprite(119, 128 / 4, 139, &w, &h, &ofs);
cga_BlitScratchBackSprite(sprofs, w, 20, backbuffer, ofs);
@@ -2520,7 +2520,7 @@ Draw item bounce to room objects animation
*/
uint16 SCR_4E_BounceCurrentItemToRoom(void) {
script_ptr++;
- BounceCurrentItem(ITEMFLG_ROOM, 43);
+ bounceCurrentItem(ITEMFLG_ROOM, 43);
return 0;
}
@@ -2529,7 +2529,7 @@ Draw item bounce to inventory animation
*/
uint16 SCR_4F_BounceCurrentItemToInventory(void) {
script_ptr++;
- BounceCurrentItem(ITEMFLG_OWNED, 85);
+ bounceCurrentItem(ITEMFLG_OWNED, 85);
return 0;
}
@@ -2543,7 +2543,7 @@ uint16 SCR_50_BounceItemToInventory(void) {
itemidx = *script_ptr++;
script_vars[ScrPool3_CurrentItem] = &inventory_items[itemidx - 1];
- BounceCurrentItem(ITEMFLG_OWNED, 85);
+ bounceCurrentItem(ITEMFLG_OWNED, 85);
return 0;
}
@@ -2562,7 +2562,7 @@ uint16 SCR_4B_ProtoDropZapstik(void) {
script_vars[ScrPool3_CurrentItem] = &inventory_items[kItemZapstik1 - 1 + (script_byte_vars.cur_pers - 1) - kPersProtozorq1];
- BounceCurrentItem(ITEMFLG_ROOM, 43);
+ bounceCurrentItem(ITEMFLG_ROOM, 43);
return 0;
}
@@ -2578,7 +2578,7 @@ void LootAspirantsItem(void) {
script_vars[ScrPool3_CurrentItem] = item;
script_byte_vars.steals_count++;
script_byte_vars.bvar_6D[aspirant_ptr->index >> 6] = item->name; /*TODO: check these index bits*/
- BounceCurrentItem(ITEMFLG_OWNED, 85);
+ bounceCurrentItem(ITEMFLG_OWNED, 85);
the_command = 0x90AA; /*OK*/
} else
the_command = 0x9140; /*NOTHING ON HIM*/
@@ -2650,7 +2650,7 @@ uint16 SCR_51_SkullTraderItemTrade(void) {
uint16 SCR_52_RefreshSpritesData(void) {
script_ptr++;
- RefreshSpritesData();
+ refreshSpritesData();
return 0;
}
@@ -2687,7 +2687,7 @@ uint16 SCR_54_DotFadeRoom(void) {
uint16 SCR_55_DrawRoomItemsIndicator(void) {
script_ptr++;
- DrawRoomItemsIndicator();
+ drawRoomItemsIndicator();
return 0;
}
@@ -2701,7 +2701,7 @@ uint16 SCR_56_MorphRoom98(void) {
IFGM_PlaySample(242);
- RedrawRoomStatics(98, 0);
+ redrawRoomStatics(98, 0);
ofs = cga_CalcXY(0, 136);
for (h = 60; h; h--) {
@@ -2712,7 +2712,7 @@ uint16 SCR_56_MorphRoom98(void) {
ofs -= CGA_BYTES_PER_LINE;
}
- BackupSpotImage(&zone_spots[3], &sprites_list[3], sprites_list[3]);
+ backupSpotImage(&zone_spots[3], &sprites_list[3], sprites_list[3]);
IFGM_StopSample();
@@ -2992,11 +2992,11 @@ uint16 SCR_62_PsiReaction(void) {
uint16 SCR_63_LiftSpot6(void) {
script_ptr++;
- BlitSpritesToBackBuffer();
+ blitSpritesToBackBuffer();
zone_spots[6].sy -= 5;
zone_spots[6].ey -= 5;
- BackupSpotsImages();
- DrawPersons();
+ backupSpotsImages();
+ drawPersons();
cga_BackBufferToRealFull();
return 0;
@@ -3230,8 +3230,8 @@ uint16 CMD_2_PsiPowers(void) {
if (command_hint != 100)
command_hint += 109;
if (command_hint != last_command_hint)
- DrawCommandHint();
- DrawHintsAndCursor(CGA_SCREENBUFFER);
+ drawCommandHint();
+ drawHintsAndCursor(CGA_SCREENBUFFER);
} while (buttons == 0);
undrawCursor(CGA_SCREENBUFFER);
cga_RestoreBackupImage(CGA_SCREENBUFFER);
@@ -3388,7 +3388,7 @@ uint16 CMD_A_PsiSolarEyes(void) {
return 0;
if (zone_palette == 14) {
- RedrawRoomStatics(script_byte_vars.zone_room, zone_palette);
+ redrawRoomStatics(script_byte_vars.zone_room, zone_palette);
zone_palette = 0;
cga_BackBufferToRealFull();
}
@@ -3411,7 +3411,7 @@ void DrawStickyNet(void) {
byte x, y, w, h;
uint16 ofs;
- byte *sprite = LoadPuzzlToScratch(80);
+ byte *sprite = loadPuzzlToScratch(80);
x = room_bounds_rect.sx;
y = room_bounds_rect.sy;
@@ -3439,13 +3439,13 @@ uint16 CMD_B_PsiStickyFingers(void) {
return ScriptRerun;
}
- BackupScreenOfSpecialRoom();
+ backupScreenOfSpecialRoom();
DrawStickyNet();
selectCursor(CURSOR_FLY);
menuLoop(0, 0);
playSound(224);
cga_BackBufferToRealFull();
- RestoreScreenOfSpecialRoom();
+ restoreScreenOfSpecialRoom();
if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(0 * 2) == 0)
the_command = Swap16(script_word_vars.psi_cmds[0]);
@@ -3480,7 +3480,7 @@ uint16 CMD_D_PsiBrainwarp(void) {
return 0;
if (script_byte_vars.bvar_43 == 0) {
- BackupScreenOfSpecialRoom();
+ backupScreenOfSpecialRoom();
processMenu();
if (script_byte_vars.cur_spot_idx == 0) {
@@ -3491,7 +3491,7 @@ uint16 CMD_D_PsiBrainwarp(void) {
if (GetZoneObjCommand(1 * 2) != 0) {
playAnim(39, found_spot->sx + 8 / 4, found_spot->sy - 10);
- RestoreScreenOfSpecialRoom();
+ restoreScreenOfSpecialRoom();
return ScriptRerun;
}
}
@@ -3508,7 +3508,7 @@ uint16 CMD_D_PsiBrainwarp(void) {
the_command = 0;
if (script_byte_vars.bvar_43 == 0) {
playAnim(39, found_spot->sx + 8 / 4, found_spot->sy - 10);
- RestoreScreenOfSpecialRoom();
+ restoreScreenOfSpecialRoom();
return ScriptRerun;
}
@@ -3529,7 +3529,7 @@ uint16 CMD_E_PsiZoneScan(void) {
return ScriptRerun;
}
- BackupScreenOfSpecialRoom();
+ backupScreenOfSpecialRoom();
IFGM_PlaySample(26);
@@ -3559,7 +3559,7 @@ uint16 CMD_E_PsiZoneScan(void) {
offs += CGA_BYTES_PER_LINE;
}
- RestoreScreenOfSpecialRoom();
+ restoreScreenOfSpecialRoom();
IFGM_StopSample();
@@ -3580,10 +3580,10 @@ uint16 CMD_F_PsiPsiShift(void) {
selectCursor(CURSOR_GRAB);
menuLoop(0, 0);
- BackupScreenOfSpecialRoom();
+ backupScreenOfSpecialRoom();
playSound(25);
playAnim(39, cursor_x / 4, cursor_y);
- RestoreScreenOfSpecialRoom();
+ restoreScreenOfSpecialRoom();
if (script_byte_vars.cur_spot_idx == 0 || GetZoneObjCommand(3 * 2) == 0)
the_command = Swap16(script_word_vars.psi_cmds[5]);
@@ -3786,19 +3786,19 @@ uint16 CMD_13_ActivateFountain(void) {
script_byte_vars.bvar_6A = 1;
for (i = 0; i < 10; i++) {
- DrawRoomStaticObject(water1, &x, &y, &w, &h);
+ drawRoomStaticObject(water1, &x, &y, &w, &h);
waitVBlank();
cga_BackBufferToRealFull();
for (j = 0; j < 0x1FFF; j++) ; /*TODO: weak delay*/
- DrawRoomStaticObject(water2, &x, &y, &w, &h);
+ drawRoomStaticObject(water2, &x, &y, &w, &h);
waitVBlank();
cga_BackBufferToRealFull();
for (j = 0; j < 0x1FFF; j++) ; /*TODO: weak delay*/
}
- DrawRoomStaticObject(headl, &x, &y, &w, &h);
- DrawRoomStaticObject(headr, &x, &y, &w, &h);
+ drawRoomStaticObject(headl, &x, &y, &w, &h);
+ drawRoomStaticObject(headr, &x, &y, &w, &h);
cga_BackBufferToRealFull();
return 0;
@@ -3810,12 +3810,12 @@ Vorts walking into the room
uint16 CMD_14_VortAppear(void) {
/*TODO: check me*/
pers_list[kPersVort].area = script_byte_vars.zone_area;
- SelectPerson(0);
- AnimateSpot(&vortanims_ptr->field_1);
+ selectPerson(0);
+ animateSpot(&vortanims_ptr->field_1);
IFGM_StopSample();
next_vorts_cmd = 0xA015;
- BlitSpritesToBackBuffer();
- DrawPersons();
+ blitSpritesToBackBuffer();
+ drawPersons();
cga_BackBufferToRealFull();
next_vorts_ticks = Swap16(script_word_vars.timer_ticks2) + 5;
return 0;
@@ -3889,8 +3889,8 @@ uint16 CMD_15_VortLeave(void) {
zone_spots[(pers->flags & 15) - 1].flags &= ~SPOTFLG_80;
- SelectPerson(0);
- AnimateSpot(anim);
+ selectPerson(0);
+ animateSpot(anim);
IFGM_StopSample();
script_byte_vars.bvar_36 &= 0x80;
return 0;
@@ -3928,9 +3928,9 @@ uint16 CMD_18_AspirantLeave(void) {
if ((aspirant_ptr->flags & PERSFLG_40) == 0) {
aspirant_spot->flags &= ~SPOTFLG_80;
- SelectPerson(script_byte_vars.aspirant_pers_ofs);
+ selectPerson(script_byte_vars.aspirant_pers_ofs);
script_byte_vars.aspirant_flags = 0;
- AnimateSpot(&anim33);
+ animateSpot(&anim33);
}
return 0;
@@ -3948,10 +3948,10 @@ uint16 CMD_19_AspirantAppear(void) {
script_word_vars.next_aspirant_cmd = BE(0xA018); /*leave*/
script_byte_vars.check_used_commands = 3;
script_byte_vars.used_commands = 0;
- SelectPerson(script_byte_vars.aspirant_pers_ofs);
- AnimateSpot(&anim23);
- BlitSpritesToBackBuffer();
- DrawPersons();
+ selectPerson(script_byte_vars.aspirant_pers_ofs);
+ animateSpot(&anim23);
+ blitSpritesToBackBuffer();
+ drawPersons();
cga_BackBufferToRealFull();
if (script_byte_vars.aspirant_flags == 5) {
the_command = 0xC029;
@@ -4022,11 +4022,11 @@ Turkey walking into the room
uint16 CMD_1E_TurkeyAppear(void) {
/*TODO: check me*/
pers_list[kPersTurkey].area = script_byte_vars.zone_area;
- SelectPerson(PersonOffset(kPersTurkey));
- AnimateSpot(&turkeyanims_ptr->field_1);
+ selectPerson(PersonOffset(kPersTurkey));
+ animateSpot(&turkeyanims_ptr->field_1);
next_turkey_cmd = 0xA01F;
- BlitSpritesToBackBuffer();
- DrawPersons();
+ blitSpritesToBackBuffer();
+ drawPersons();
cga_BackBufferToRealFull();
next_turkey_ticks = Swap16(script_word_vars.timer_ticks2) + 5;
return 0;
@@ -4055,8 +4055,8 @@ uint16 CMD_1F_TurkeyLeave(void) {
zone_spots[(pers->flags & 15) - 1].flags &= ~SPOTFLG_80;
- SelectPerson(PersonOffset(kPersTurkey));
- AnimateSpot(anim);
+ selectPerson(PersonOffset(kPersTurkey));
+ animateSpot(anim);
return 0;
}
@@ -4278,7 +4278,7 @@ cmdhandler_t script_handlers[] = {
SCR_56_MorphRoom98,
SCR_57_ShowCharacterSprite,
SCR_58_DrawCharacterSprite,
- SCR_59_BlitSpritesToBackBuffer,
+ SCR_59_blitSpritesToBackBuffer,
SCR_5A_SelectPalette,
SCR_5B_TheEnd,
SCR_5C_ClearInventory,
Commit: 2c949ea93d03818c3d5c5ec9e37948fab2d4d24c
https://github.com/scummvm/scummvm/commit/2c949ea93d03818c3d5c5ec9e37948fab2d4d24c
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Renames in savegame.h
Changed paths:
engines/chamber/kult.cpp
engines/chamber/savegame.cpp
engines/chamber/savegame.h
engines/chamber/script.cpp
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 711852b7f76..c87d7f08c95 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -299,7 +299,7 @@ Common::Error ChamberEngine::run() {
cga_BackBufferToRealFull();
/* Create clean game state snapshot */
- SaveRestartGame();
+ saveRestartGame();
/* Detect CPU speed for delay routines */
cpu_speed_delay = benchmarkCpu() / 8;
diff --git a/engines/chamber/savegame.cpp b/engines/chamber/savegame.cpp
index e7c02f7c67e..29b1ae95e8f 100644
--- a/engines/chamber/savegame.cpp
+++ b/engines/chamber/savegame.cpp
@@ -97,7 +97,7 @@ static const char savegame_name[] = "SCENAx.BIN";
rlen = read(f, buffer, size); if(rlen != size) goto error;
#if 0
-int16 ReadSaveData(int16 f, int16 clean) {
+int16 readSaveData(int16 f, int16 clean) {
int16 rlen;
uint16 zero = 0;
byte *p;
@@ -343,7 +343,7 @@ error:;
return 1;
}
-int16 WriteSaveData(int16 f, int16 clean) {
+int16 writeSaveData(int16 f, int16 clean) {
int16 wlen;
uint16 zero = 0;
byte *p;
@@ -586,8 +586,8 @@ error:;
}
#endif
-int16 LoadScena(void) {
- warning("STUB: LoadScena()");
+int16 loadScena(void) {
+ warning("STUB: loadScena()");
return 1;
#if 0
int16 f;
@@ -620,8 +620,8 @@ int16 LoadScena(void) {
#endif
}
-int16 SaveScena(void) {
- warning("STUB: SaveScena()");
+int16 saveScena(void) {
+ warning("STUB: saveScena()");
return 1;
#if 0
int16 f;
@@ -651,8 +651,8 @@ int16 SaveScena(void) {
#endif
}
-void SaveRestartGame(void) {
- warning("STUB: SaveRestartGame()");
+void saveRestartGame(void) {
+ warning("STUB: saveRestartGame()");
#if 0
int16 f;
@@ -669,19 +669,19 @@ void SaveRestartGame(void) {
}
//extern jmp_buf restart_jmp;
-extern void AskDisk2(void);
+extern void askDisk2(void);
-void RestartGame(void) {
- warning("STUB: RestartGame()");
+void restartGame(void) {
+ warning("STUB: restartGame()");
#if 0
int16 f;
int16 res;
- for (;; AskDisk2()) {
+ for (;; askDisk2()) {
f = open(restart_name, O_RDONLY | O_BINARY);
if (f != -1) {
- res = ReadSaveData(f, 1);
+ res = readSaveData(f, 1);
close(f);
if (res == 0)
break;
diff --git a/engines/chamber/savegame.h b/engines/chamber/savegame.h
index 7c8feaf33b1..b49ef48f974 100644
--- a/engines/chamber/savegame.h
+++ b/engines/chamber/savegame.h
@@ -25,10 +25,10 @@
namespace Chamber {
-int16 LoadScena(void);
-int16 SaveScena(void);
-void SaveRestartGame(void);
-void RestartGame(void);
+int16 loadScena(void);
+int16 saveScena(void);
+void saveRestartGame(void);
+void restartGame(void);
} // End of namespace Chamber
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index dd0d22ed089..a13df075a22 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -1417,7 +1417,7 @@ uint16 SCR_26_GameOver(void) {
JaggedZoom(backbuffer, frontbuffer);
cga_BackBufferToRealFull();
- RestartGame();
+ restartGame();
return 0;
}
@@ -2915,7 +2915,7 @@ uint16 SCR_5B_TheEnd(void) {
TheEnd();
if (g_vm->getLanguage() == Common::EN_USA)
- RestartGame();
+ restartGame();
else
for (;;) ; /*HANG*/
@@ -4123,7 +4123,7 @@ Load save file
*/
uint16 CMD_25_LoadGame(void) {
IFGM_StopSample();
- if (LoadScena())
+ if (loadScena())
the_command = 0x918F; /*error loading*/
else
the_command = 0x90AA;
@@ -4134,7 +4134,7 @@ uint16 CMD_25_LoadGame(void) {
Write save file
*/
uint16 CMD_26_SaveGame(void) {
- if (SaveScena())
+ if (saveScena())
the_command = 0x9190; /*error saving*/
else
the_command = 0x90AA;
Commit: eaaf84a4c100a90fbecdd124f1e955cd127d5a9b
https://github.com/scummvm/scummvm/commit/eaaf84a4c100a90fbecdd124f1e955cd127d5a9b
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Rename rest of functions
Changed paths:
engines/chamber/cga.cpp
engines/chamber/cga.h
engines/chamber/dialog.cpp
engines/chamber/invent.cpp
engines/chamber/kult.cpp
engines/chamber/menu.cpp
engines/chamber/portrait.cpp
engines/chamber/room.cpp
engines/chamber/script.cpp
engines/chamber/script.h
engines/chamber/timer.cpp
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index df135ea96b8..244fc96eea3 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -608,7 +608,7 @@ void cga_BlitSpriteBak(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen,
/*
Blit progressive sprite (w+h+mask+pixel) to interlaced screen buffer
*/
-void DrawSprite(byte *sprite, byte *screen, uint16 ofs) {
+void drawSprite(byte *sprite, byte *screen, uint16 ofs) {
byte w, h;
w = *sprite++;
h = *sprite++;
@@ -618,7 +618,7 @@ void DrawSprite(byte *sprite, byte *screen, uint16 ofs) {
/*
Blit progressive sprite (w+h+mask+pixel) to interlaced screen buffer, horizontally flipped
*/
-void DrawSpriteFlip(byte *sprite, byte *screen, uint16 ofs) {
+void drawSpriteFlip(byte *sprite, byte *screen, uint16 ofs) {
byte w, h;
w = *sprite++;
h = *sprite++;
@@ -629,7 +629,7 @@ void DrawSpriteFlip(byte *sprite, byte *screen, uint16 ofs) {
Load and uncompress 2-bit sprite
Return next ptr after the loaded sprite
*/
-byte *LoadSprite(byte index, byte *bank, byte *buffer, byte header_only) {
+byte *loadSprite(byte index, byte *bank, byte *buffer, byte header_only) {
byte w, h;
uint16 rsize;
byte *sprite, *sprite_end;
@@ -710,52 +710,52 @@ extern byte sprit_data[RES_SPRIT_MAX];
byte sprit_load_buffer[1290];
-byte *LoadSprit(byte index) {
- LoadSprite(index, sprit_data + 4, sprit_load_buffer, 0);
+byte *loadSprit(byte index) {
+ loadSprite(index, sprit_data + 4, sprit_load_buffer, 0);
return sprit_load_buffer;
}
-byte *LoadPersSprit(byte index) {
+byte *loadPersSprit(byte index) {
#if 1
/*Use separate memory for pers1/pers2*/
if (index < 61)
- LoadSprite(index, pers1_data + 4, scratch_mem2, 0);
+ loadSprite(index, pers1_data + 4, scratch_mem2, 0);
else
- LoadSprite(index - 61, pers2_data + 4, scratch_mem2, 0);
+ loadSprite(index - 61, pers2_data + 4, scratch_mem2, 0);
#else
/*Use single large chunk for pers1+pers2*/
- LoadSprite(index, pers1_data + 4, scratch_mem2, 0);
+ loadSprite(index, pers1_data + 4, scratch_mem2, 0);
#endif
return scratch_mem2;
}
-void DrawSpriteN(byte index, uint16 x, uint16 y, byte *target) {
+void drawSpriteN(byte index, uint16 x, uint16 y, byte *target) {
uint16 ofs;
byte *sprite;
- sprite = LoadSprit(index);
+ sprite = loadSprit(index);
ofs = cga_CalcXY_p(x, y);
- DrawSprite(sprite, target, ofs);
+ drawSprite(sprite, target, ofs);
}
-void DrawSpriteNFlip(byte index, uint16 x, uint16 y, byte *target) {
+void drawSpriteNFlip(byte index, uint16 x, uint16 y, byte *target) {
uint16 ofs;
byte *sprite;
- sprite = LoadSprit(index);
+ sprite = loadSprit(index);
ofs = cga_CalcXY_p(x, y);
- DrawSpriteFlip(sprite, target, ofs);
+ drawSpriteFlip(sprite, target, ofs);
}
-void BackupAndShowSprite(byte index, byte x, byte y) {
+void backupAndShowSprite(byte index, byte x, byte y) {
byte w, h;
uint16 ofs;
- byte *sprite = LoadSprit(index);
+ byte *sprite = loadSprit(index);
ofs = cga_CalcXY_p(x, y);
w = sprite[0];
h = sprite[1];
cga_BackupImageReal(ofs, w, h);
- DrawSprite(sprite, CGA_SCREENBUFFER, ofs); /*DrawSpriteN(index, x, y, CGA_SCREENBUFFER);*/
+ drawSprite(sprite, CGA_SCREENBUFFER, ofs); /*DrawSpriteN(index, x, y, CGA_SCREENBUFFER);*/
}
/*
@@ -1006,7 +1006,7 @@ static const byte piecedelays[] = {
};
/*break screen area onto 4x4 pix pieces*/
-static void ScreenToPieces(byte width, byte height, byte *screen, uint16 offs, scrpiece_t *pieces) {
+static void screenToPieces(byte width, byte height, byte *screen, uint16 offs, scrpiece_t *pieces) {
const byte *delays = piecedelays;
height = (height + 3) / 4;
while (height--) {
@@ -1035,7 +1035,7 @@ static void ScreenToPieces(byte width, byte height, byte *screen, uint16 offs, s
pieces->offs = 0; /*end of list*/
}
-static void FallPieces(scrpiece_t *pieces, byte *source, byte *target) {
+static void fallPieces(scrpiece_t *pieces, byte *source, byte *target) {
byte t = 1;
byte again = 0;
do {
@@ -1121,8 +1121,8 @@ static void FallPieces(scrpiece_t *pieces, byte *source, byte *target) {
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);
+ screenToPieces(w, h, screen, ofs, pieces);
+ fallPieces(pieces, source, target);
}
void cga_TraceLine(uint16 sx, uint16 ex, uint16 sy, uint16 ey, byte *source, byte *target) {
diff --git a/engines/chamber/cga.h b/engines/chamber/cga.h
index bf9a3a09576..e8e838f65b1 100644
--- a/engines/chamber/cga.h
+++ b/engines/chamber/cga.h
@@ -98,18 +98,18 @@ void cga_BlitSpriteFlip(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen
void cga_BlitSpriteBak(byte *pixels, int16 pw, uint16 w, uint16 h, byte *screen, uint16 ofs, byte *backup, byte mask);
-void DrawSprite(byte *sprite, byte *screen, uint16 ofs);
-void DrawSpriteFlip(byte *sprite, byte *screen, uint16 ofs);
+void drawSprite(byte *sprite, byte *screen, uint16 ofs);
+void drawSpriteFlip(byte *sprite, byte *screen, uint16 ofs);
-void DrawSpriteN(byte index, uint16 x, uint16 y, byte *target);
-void DrawSpriteNFlip(byte index, uint16 x, uint16 y, byte *target);
+void drawSpriteN(byte index, uint16 x, uint16 y, byte *target);
+void drawSpriteNFlip(byte index, uint16 x, uint16 y, byte *target);
-void BackupAndShowSprite(byte index, byte x, byte y);
+void backupAndShowSprite(byte index, byte x, byte y);
-byte *LoadSprite(byte index, byte *bank, byte *buffer, byte header_only);
+byte *loadSprite(byte index, byte *bank, byte *buffer, byte header_only);
-byte *LoadSprit(byte index);
-byte *LoadPersSprit(byte index);
+byte *loadSprit(byte index);
+byte *loadPersSprit(byte index);
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);
diff --git a/engines/chamber/dialog.cpp b/engines/chamber/dialog.cpp
index 8bbfba0c0bb..a112abec678 100644
--- a/engines/chamber/dialog.cpp
+++ b/engines/chamber/dialog.cpp
@@ -152,27 +152,27 @@ void drawPersonBubble(byte x, byte y, byte flags, byte *msg) {
switch (flags & SPIKE_MASK) {
case SPIKE_UPLEFT: /*upper-left spike*/
ofs = cga_CalcXY_p(x + 1, y - 7);
- DrawSpriteN(18, x + 1, y - 7, CGA_SCREENBUFFER);
+ drawSpriteN(18, x + 1, y - 7, CGA_SCREENBUFFER);
break;
case SPIKE_UPRIGHT: /*upper-right spike*/
ofs = cga_CalcXY_p(x + char_draw_max_width, y - 7) - 1;
- DrawSpriteNFlip(18, x + char_draw_max_width, y - 7, CGA_SCREENBUFFER);
+ drawSpriteNFlip(18, x + char_draw_max_width, y - 7, CGA_SCREENBUFFER);
break;
case SPIKE_DNRIGHT: /*lower-right spike*/
ofs = cga_CalcXY_p(x + char_draw_max_width, char_draw_coords_y + 1) - 1;
- DrawSpriteNFlip(21, x + char_draw_max_width, char_draw_coords_y + 1, CGA_SCREENBUFFER);
+ drawSpriteNFlip(21, x + char_draw_max_width, char_draw_coords_y + 1, CGA_SCREENBUFFER);
break;
case SPIKE_DNLEFT: /*lower-left spike*/
ofs = cga_CalcXY_p(x + 1, char_draw_coords_y + 1);
- DrawSpriteN(21, x + 1, char_draw_coords_y + 1, CGA_SCREENBUFFER);
+ drawSpriteN(21, x + 1, char_draw_coords_y + 1, CGA_SCREENBUFFER);
break;
case SPIKE_BUBRIGHT: /*lower-right bubbles*/
ofs = cga_CalcXY_p(x + char_draw_max_width, char_draw_coords_y + 4);
- DrawSpriteN(20, x + char_draw_max_width, char_draw_coords_y + 4, CGA_SCREENBUFFER);
+ drawSpriteN(20, x + char_draw_max_width, char_draw_coords_y + 4, CGA_SCREENBUFFER);
break;
case SPIKE_BUBLEFT: /*lower-left bubbles*/
ofs = cga_CalcXY_p(x + 1, char_draw_coords_y + 4);
- DrawSpriteN(19, x + 1, char_draw_coords_y + 4, CGA_SCREENBUFFER);
+ drawSpriteN(19, x + 1, char_draw_coords_y + 4, CGA_SCREENBUFFER);
break;
}
@@ -183,7 +183,7 @@ void showPromptAnim(void) {
if (script_byte_vars.zone_index == 135)
return;
waitVBlank();
- DrawSpriteN(cursor_anim_phase ? 23 : 22, 300 / 4, 155, frontbuffer);
+ drawSpriteN(cursor_anim_phase ? 23 : 22, 300 / 4, 155, frontbuffer);
cursor_anim_phase = ~cursor_anim_phase;
}
diff --git a/engines/chamber/invent.cpp b/engines/chamber/invent.cpp
index 05eb42dc068..b3b0e1f6147 100644
--- a/engines/chamber/invent.cpp
+++ b/engines/chamber/invent.cpp
@@ -86,7 +86,7 @@ void drawInventoryBox(uint16 filtermask, uint16 filtervalue) {
inventory_spots[count].name = inventory_items[i].name;
inventory_spots[count].command = inventory_items[i].command;
inventory_spots[count].itemidx = i + 1;
- DrawSpriteN(inventory_items[i].sprite, inventory_spots[count].sx, inventory_spots[count].sy, CGA_SCREENBUFFER);
+ drawSpriteN(inventory_items[i].sprite, inventory_spots[count].sx, inventory_spots[count].sy, CGA_SCREENBUFFER);
count++;
}
inv_count = count;
@@ -100,7 +100,7 @@ void checkInventoryItemHover(byte count) {
command_hint = inventory_spots[i].name;
cursor_color = 0xAA;
script_byte_vars.inv_item_index = inventory_spots[i].itemidx;
- script_vars[ScrPool3_CurrentItem] = &inventory_items[script_byte_vars.inv_item_index - 1];
+ script_vars[kScrPool3_CurrentItem] = &inventory_items[script_byte_vars.inv_item_index - 1];
return;
}
}
@@ -128,7 +128,7 @@ void openInventory(uint16 filtermask, uint16 filtervalue) {
}
cga_RestoreImage(scratch_mem2, frontbuffer);
playSound(20);
- switch (((item_t *)script_vars[ScrPool3_CurrentItem])->name) {
+ switch (((item_t *)script_vars[kScrPool3_CurrentItem])->name) {
case 108: /*DAGGER*/
case 115: /*SACRIFICIAL BLADE*/
case 117: /*CHOPPER*/
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index c87d7f08c95..697a35fe316 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -167,7 +167,7 @@ process:
;
updateUndrawCursor(target);
refreshSpritesData();
- RunCommand();
+ runCommand();
blitSpritesToBackBuffer();
processInput();
drawSpots(target);
@@ -176,7 +176,7 @@ process:
updateUndrawCursor(target);
refreshSpritesData();
- RunCommandKeepSp();
+ runCommandKeepSp();
script_byte_vars.used_commands++;
if (script_byte_vars.dead_flag) {
if (--script_byte_vars.tries_left == 0)
@@ -198,7 +198,7 @@ void exitGame(void) {
jmp_buf restart_jmp;
#ifdef DEBUG_ENDING
-extern TheEnd(void);
+extern theEnd(void);
#endif
Common::Error ChamberEngine::run() {
@@ -336,7 +336,7 @@ Common::Error ChamberEngine::run() {
/* Play introduction sequence and initialize game */
the_command = 0xC001;
- RunCommand();
+ runCommand();
if (_shouldQuit)
return Common::kNoError;
@@ -349,7 +349,7 @@ Common::Error ChamberEngine::run() {
#ifdef DEBUG_ENDING
script_byte_vars.game_paused = 5;
- TheEnd();
+ theEnd();
for (;;) ;
#endif
diff --git a/engines/chamber/menu.cpp b/engines/chamber/menu.cpp
index a45c89342cc..db79f535bf0 100644
--- a/engines/chamber/menu.cpp
+++ b/engines/chamber/menu.cpp
@@ -110,7 +110,7 @@ void actionsMenu(byte **pinfo) {
y = act_menu_y;
/*menu sprite*/
- BackupAndShowSprite(0, x, y);
+ backupAndShowSprite(0, x, y);
playSound(18);
choices = *((*pinfo)++);
@@ -132,7 +132,7 @@ void actionsMenu(byte **pinfo) {
act_dot_rects_end = act_dot_rects + numchoices + 1;
for (i = 0; i < numchoices; i++)
- DrawSpriteN(1, act_dot_rects[i].sx, act_dot_rects[i].sy, CGA_SCREENBUFFER);
+ drawSpriteN(1, act_dot_rects[i].sx, act_dot_rects[i].sy, CGA_SCREENBUFFER);
selectCursor(CURSOR_FINGER);
processInput();
@@ -167,11 +167,11 @@ void actionsMenu(byte **pinfo) {
waitVBlank();
/*draw dot explosion animation*/
- DrawSpriteN(24, act_dot_rects[choice].sx, act_dot_rects[choice].sy, CGA_SCREENBUFFER);
+ drawSpriteN(24, act_dot_rects[choice].sx, act_dot_rects[choice].sy, CGA_SCREENBUFFER);
for (i = 0; i < 0xFFF; i++) ; /*TODO: weak delay*/
- DrawSpriteN(2, act_dot_rects[choice].sx, act_dot_rects[choice].sy, CGA_SCREENBUFFER);
+ drawSpriteN(2, act_dot_rects[choice].sx, act_dot_rects[choice].sy, CGA_SCREENBUFFER);
for (i = 0; i < 0xFFF; i++) ; /*TODO: weak delay*/
- DrawSpriteN(25, act_dot_rects[choice].sx, act_dot_rects[choice].sy, CGA_SCREENBUFFER);
+ drawSpriteN(25, act_dot_rects[choice].sx, act_dot_rects[choice].sy, CGA_SCREENBUFFER);
for (i = 0; i < 0xFFF; i++) ; /*TODO: weak delay*/
}
cga_RestoreBackupImage(CGA_SCREENBUFFER);
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index b9c785287f3..4d90c2c2ffb 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -139,7 +139,7 @@ byte *loadPortrait(byte **pinfo, byte *end) {
buffer = sprit_load_buffer + 2 + 2 + (flags & 0x3FFF);
pitch = cur_frame_width;
- sprite = LoadPersSprit(index);
+ sprite = loadPersSprit(index);
sprw = *sprite++;
sprh = *sprite++;
@@ -201,7 +201,7 @@ struct {
byte selectCurrentAnim(byte *x, byte *y, byte *index) {
int16 i;
- byte aniidx = ((pers_t *)(script_vars[ScrPool8_CurrentPers]))->index & ~7;
+ byte aniidx = ((pers_t *)(script_vars[kScrPool8_CurrentPers]))->index & ~7;
for (i = 0; i < STATIC_ANIMS_MAX; i++) {
if (static_anims[i].index == aniidx) {
*x = static_anims[i].x;
@@ -297,7 +297,7 @@ void playHurtSound() {
if (!ifgm_loaded)
playSound(144);
else
- playSound(144 + (Rand() / 4) % 4);
+ playSound(144 + (getRand() / 4) % 4);
}
void blinkWithSound(byte color) {
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index a7d187056d9..a81d5a930ee 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -200,7 +200,7 @@ void findPerson(void) {
pers_t *pers = pers_list;
for (i = 0; i < PERS_MAX; i++, pers++) {
if ((pers->flags & 15) == script_byte_vars.cur_spot_idx) {
- script_vars[ScrPool8_CurrentPers] = pers;
+ script_vars[kScrPool8_CurrentPers] = pers;
script_byte_vars.cur_pers = i + 1;
return;
}
@@ -334,7 +334,7 @@ void loadZone(void) {
}
zone_spots = (spot_t *)zptr;
- script_vars[ScrPool4_ZoneSpots] = (spot_t *)zptr;
+ script_vars[kScrPool4_ZoneSpots] = (spot_t *)zptr;
zone_spots_end = (spot_t *)zend;
zone_spots_cur = (spot_t *)zptr;
zone_spr_index = 0;
@@ -372,9 +372,9 @@ Load puzzl sprite to buffer, return next free buffer ptr
*/
byte *loadPuzzl(byte index, byte *buffer) {
if (script_byte_vars.palette_index == 14)
- return LoadSprite(index, puzzl_data + 4, buffer, 1);
+ return loadSprite(index, puzzl_data + 4, buffer, 1);
else
- return LoadSprite(index, puzzl_data + 4, buffer, 0);
+ return loadSprite(index, puzzl_data + 4, buffer, 0);
}
/*
@@ -579,7 +579,7 @@ byte selectPerson(byte offset) {
/*TODO: replace offset arg with index?*/
byte index = offset / 5; /* / sizeof(pers_t) */
- script_vars[ScrPool8_CurrentPers] = &pers_list[index];
+ script_vars[kScrPool8_CurrentPers] = &pers_list[index];
index = findSpotByFlags(0x3F, (pers_list[index].index & 7) | SPOTFLG_10); /*TODO: return 0 if not found?*/
if (index == 0xFF)
@@ -881,8 +881,8 @@ void drawRoomItemsIndicator(void) {
break;
}
}
- DrawSpriteN(spridx, 296 / CGA_PIXELS_PER_BYTE, 14, CGA_SCREENBUFFER);
- DrawSpriteN(spridx, 296 / CGA_PIXELS_PER_BYTE, 14, backbuffer);
+ drawSpriteN(spridx, 296 / CGA_PIXELS_PER_BYTE, 14, CGA_SCREENBUFFER);
+ drawSpriteN(spridx, 296 / CGA_PIXELS_PER_BYTE, 14, backbuffer);
/*recalculate the number of zapstiks we have*/
script_byte_vars.zapstiks_owned = 0;
@@ -1017,7 +1017,7 @@ void loadLutinSprite(uint16 lutidx) {
flags = *lutin_entry++;
flags |= (*lutin_entry++) << 8;
- sprite = LoadSprit(spridx);
+ sprite = loadSprit(spridx);
sprw = *sprite++;
sprh = *sprite++;
@@ -1037,7 +1037,7 @@ void drawCharacterSprite(byte spridx, byte x, byte y, byte *target) {
loadLutinSprite(spridx);
- DrawSprite(scratch_mem2, target, cga_CalcXY_p(x, y));
+ drawSprite(scratch_mem2, target, cga_CalcXY_p(x, y));
}
/*
@@ -1062,7 +1062,7 @@ char drawZoneAniSprite(rect_t *rect, uint16 index, byte *target) {
zsprite_h = scratch_mem2[1];
zsprite_draw_ofs = cga_CalcXY_p(rect->sx, rect->sy);
- DrawSprite(scratch_mem2, target, zsprite_draw_ofs);
+ drawSprite(scratch_mem2, target, zsprite_draw_ofs);
return ~0;
}
@@ -1113,7 +1113,7 @@ void prepareAspirant(void) {
return;
hostility = script_byte_vars.rand_value;
- appearance = Rand();
+ appearance = getRand();
flags = 0;
/*
flags values:
@@ -1137,13 +1137,13 @@ void prepareAspirant(void) {
script_word_vars.next_aspirant_cmd = BE(0xA018); /*leave*/
script_byte_vars.check_used_commands = 3; /*after 3 actions*/
script_byte_vars.aspirant_flags = flags;
- script_vars[ScrPool8_CurrentPers] = aspirant_ptr;
+ script_vars[kScrPool8_CurrentPers] = aspirant_ptr;
} else if (appearance < 52) {
script_word_vars.next_aspirant_cmd = BE(0xA019);
flags |= 4;
script_byte_vars.check_used_commands = 3;
script_byte_vars.aspirant_flags = flags;
- script_vars[ScrPool8_CurrentPers] = aspirant_ptr;
+ script_vars[kScrPool8_CurrentPers] = aspirant_ptr;
} else {
/*do not spawn*/
script_byte_vars.aspirant_flags = 0;
@@ -1162,13 +1162,13 @@ void prepareAspirant(void) {
script_word_vars.next_aspirant_cmd = BE(0xA018); /*leave*/
script_byte_vars.check_used_commands = 3; /*after 3 actions*/
script_byte_vars.aspirant_flags = flags;
- script_vars[ScrPool8_CurrentPers] = aspirant_ptr;
+ script_vars[kScrPool8_CurrentPers] = aspirant_ptr;
} else if (appearance < 52) {
script_word_vars.next_aspirant_cmd = BE(0xA019);
flags |= 4;
script_byte_vars.check_used_commands = 3;
script_byte_vars.aspirant_flags = flags;
- script_vars[ScrPool8_CurrentPers] = aspirant_ptr;
+ script_vars[kScrPool8_CurrentPers] = aspirant_ptr;
} else {
/*do not spawn*/
script_byte_vars.aspirant_flags = 0;
@@ -1331,7 +1331,7 @@ void setAnim127Sprite(byte flags, byte spridx) {
Bounce current item to the room/inventory
*/
void bounceCurrentItem(byte flags, byte y) {
- item_t *item = (item_t *)(script_vars[ScrPool3_CurrentItem]);
+ item_t *item = (item_t *)(script_vars[kScrPool3_CurrentItem]);
setAnim127Sprite(flags, item->sprite);
item->flags = flags;
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index a13df075a22..56853d85e70 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -63,7 +63,7 @@ byte *script_ptr, *script_end_ptr;
byte *script_stack[5 * 2];
byte **script_stack_ptr = script_stack;
-void *script_vars[ScrPools_MAX] = {
+void *script_vars[kScrPools_MAX] = {
&script_word_vars,
&script_word_vars,
&script_byte_vars,
@@ -80,7 +80,7 @@ extern void askDisk2(void);
/*
Get next random byte value
*/
-byte Rand(void) {
+byte getRand(void) {
script_byte_vars.rand_value = aleat_data[++rand_seed];
return script_byte_vars.rand_value;
}
@@ -88,9 +88,9 @@ byte Rand(void) {
/*
Get next random word value
*/
-uint16 RandW(void) {
- uint16 r = Rand() << 8;
- return r | Rand();
+uint16 getRandW(void) {
+ uint16 r = getRand() << 8;
+ return r | getRand();
}
uint16 Swap16(uint16 x) {
@@ -123,7 +123,7 @@ uint16 SCR_TRAP(void) {
/*
Remove "not interested in that" tag from owned items
*/
-void ReclaimRefusedItems(void) {
+void reclaimRefusedItems(void) {
int16 i;
for (i = 0; i < MAX_INV_ITEMS; i++) {
if (inventory_items[i].flags == (ITEMFLG_OWNED | ITEMFLG_DONTWANT))
@@ -148,13 +148,13 @@ uint16 SCR_1_AspirantItemTrade(void) {
if (inv_count == 0) {
the_command = 0xC1BC;
- RunCommand();
+ runCommand();
break;
}
if (the_command == 0) {
the_command = 0xC1C0;
- RunCommand();
+ runCommand();
break;
}
@@ -164,11 +164,11 @@ uint16 SCR_1_AspirantItemTrade(void) {
break;
item1 = &inventory_items[aspirant_ptr->item - 1]; /*aspirant's item*/
- item2 = (item_t *)(script_vars[ScrPool3_CurrentItem]); /*our offer*/
+ item2 = (item_t *)(script_vars[kScrPool3_CurrentItem]); /*our offer*/
if (item2->flags == (ITEMFLG_OWNED | ITEMFLG_DONTWANT) || item1->name == item2->name) {
the_command = 0xC1C0;
- RunCommand();
+ runCommand();
break;
}
@@ -194,18 +194,18 @@ uint16 SCR_1_AspirantItemTrade(void) {
default: /*STONE FLY*/
the_command = 0xC1B9;
}
- RunCommand();
+ runCommand();
break;
} else {
/*not interested*/
item2->flags = ITEMFLG_OWNED | ITEMFLG_DONTWANT;
the_command = 0xC1BD;
- RunCommand();
+ runCommand();
continue;
}
}
- ReclaimRefusedItems();
+ reclaimRefusedItems();
script_ptr = old_script;
script_end_ptr = old_script_end;
@@ -225,7 +225,7 @@ uint16 SCR_2_RudeAspirantTrade(void) {
old_script = script_ptr;
the_command = 0x9099; /*WHAT DO YOU WANT TO EXCHANGE?*/
- RunCommand();
+ runCommand();
for (;;) {
inv_bgcolor = 0xFF;
@@ -233,7 +233,7 @@ uint16 SCR_2_RudeAspirantTrade(void) {
if (inv_count == 0) {
the_command = 0xC1C5;
- RunCommand();
+ runCommand();
break;
}
@@ -243,22 +243,22 @@ uint16 SCR_2_RudeAspirantTrade(void) {
the_command = 0x9140; /*NOTHING ON HIM*/
if (aspirant_ptr->item == 0) {
- RunCommand();
+ runCommand();
break;
}
item1 = &inventory_items[aspirant_ptr->item - 1]; /*aspirant's item*/
- item2 = (item_t *)(script_vars[ScrPool3_CurrentItem]); /*our offer*/
+ item2 = (item_t *)(script_vars[kScrPool3_CurrentItem]); /*our offer*/
if (item2->flags == (ITEMFLG_OWNED | ITEMFLG_DONTWANT)) {
the_command = 0xC1C0;
- RunCommand();
+ runCommand();
break;
}
/*only trade for ROPE, LANTERN, STONE FLY, GOBLET*/
if (item1->name < 104 || item1->name >= 108) {
- RunCommand();
+ runCommand();
break;
}
@@ -271,7 +271,7 @@ uint16 SCR_2_RudeAspirantTrade(void) {
/*show confirmation menu*/
script_byte_vars.trade_accepted = 0;
the_command = 0xC1C6;
- RunCommand();
+ runCommand();
if (script_byte_vars.trade_accepted == 0)
break;
@@ -292,18 +292,18 @@ uint16 SCR_2_RudeAspirantTrade(void) {
default: /*STONE FLY*/
the_command = 0xC1B9;
}
- RunCommand();
+ runCommand();
break;
} else {
/*not interested*/
item2->flags = ITEMFLG_OWNED | ITEMFLG_DONTWANT;
the_command = 0xC1BD;
- RunCommand();
+ runCommand();
continue;
}
}
- ReclaimRefusedItems();
+ reclaimRefusedItems();
script_ptr = old_script;
script_end_ptr = old_script_end;
@@ -317,29 +317,29 @@ Steal a Zapstik form Protozorq
uint16 SCR_4_StealZapstik(void) {
byte *old_script;
- pers_t *pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]);
+ pers_t *pers = (pers_t *)(script_vars[kScrPool8_CurrentPers]);
script_ptr++;
old_script = script_ptr;
if ((pers->index & ~7) != 0x30) {
the_command = 0x9148; /*YOU`VE ALREADY GOT IT*/
- RunCommand();
+ runCommand();
} else {
pers->index &= ~0x18;
- script_vars[ScrPool3_CurrentItem] = &inventory_items[kItemZapstik1 - 1 + (script_byte_vars.cur_pers - 1) - kPersProtozorq1];
+ script_vars[kScrPool3_CurrentItem] = &inventory_items[kItemZapstik1 - 1 + (script_byte_vars.cur_pers - 1) - kPersProtozorq1];
script_byte_vars.steals_count++;
bounceCurrentItem(ITEMFLG_OWNED, 85); /*bounce to inventory*/
the_command = 0x9147; /*YOU GET HIS ZAPSTIK*/
if (script_byte_vars.zapstik_stolen == 0) {
- RunCommand();
+ runCommand();
script_byte_vars.zapstik_stolen = 1;
the_command = 0x9032; /*THIS SHOULD GIVE YOU THE EDGE IN MOST COMBATS!*/
}
- RunCommand();
+ runCommand();
}
script_ptr = old_script;
@@ -353,7 +353,7 @@ byte wait_delta = 0;
/*
Wait for a specified number of seconds (real time) or a keypress
*/
-void Wait(byte seconds) {
+void wait(byte seconds) {
warning("STUB: Wait(%d)", seconds);
#if 0
@@ -384,7 +384,7 @@ Wait for a 4 seconds or a keypress
*/
uint16 SCR_2C_Wait4(void) {
script_ptr++;
- Wait(4);
+ wait(4);
return 0;
}
@@ -397,7 +397,7 @@ uint16 SCR_2D_Wait(void) {
script_ptr++;
seconds = *script_ptr++;
(void)seconds;
- Wait(4); /*TODO: looks like a bug?*/
+ wait(4); /*TODO: looks like a bug?*/
return 0;
}
@@ -424,7 +424,7 @@ byte var_size;
/*
Fetch variable's value and address
*/
-uint16 LoadVar(byte **ptr, byte **varptr) {
+uint16 loadVar(byte **ptr, byte **varptr) {
byte vartype;
byte *varbase;
uint16 value = 0;
@@ -444,29 +444,29 @@ uint16 LoadVar(byte **ptr, byte **varptr) {
{
int16 maxoffs = 0;
switch (vartype & VARTYPE_KIND) {
- case ScrPool0_WordVars0:
- case ScrPool1_WordVars1:
+ case kScrPool0_WordVars0:
+ case kScrPool1_WordVars1:
maxoffs = sizeof(script_word_vars);
break;
- case ScrPool2_ByteVars:
+ case kScrPool2_ByteVars:
maxoffs = sizeof(script_byte_vars);
break;
- case ScrPool3_CurrentItem:
+ case kScrPool3_CurrentItem:
maxoffs = sizeof(item_t);
break;
- case ScrPool4_ZoneSpots:
+ case kScrPool4_ZoneSpots:
maxoffs = RES_ZONES_MAX;
break;
- case ScrPool5_Persons:
+ case kScrPool5_Persons:
maxoffs = sizeof(pers_list);
break;
- case ScrPool6_Inventory:
+ case kScrPool6_Inventory:
maxoffs = sizeof(inventory_items);
break;
- case ScrPool7_Zapstiks:
+ case kScrPool7_Zapstiks:
maxoffs = sizeof(inventory_items) - sizeof(item_t) * (kItemZapstik1 - 1);
break;
- case ScrPool8_CurrentPers:
+ case kScrPool8_CurrentPers:
maxoffs = sizeof(pers_t);
break;
}
@@ -519,7 +519,7 @@ uint16 LoadVar(byte **ptr, byte **varptr) {
/*
Perform math/logic operation on two operands
*/
-uint16 MathOp(byte op, uint16 op1, uint16 op2) {
+uint16 mathOp(byte op, uint16 op1, uint16 op2) {
if (op & MATHOP_CMP) {
if (op & MATHOP_EQ)
if (op1 == op2) return ~0;
@@ -552,14 +552,14 @@ uint16 MathOp(byte op, uint16 op1, uint16 op2) {
/*
Evaluate an expression
*/
-uint16 MathExpr(byte **ptr) {
+uint16 mathExpr(byte **ptr) {
byte op;
uint16 op1, op2;
byte *opptr;
- op1 = LoadVar(ptr, &opptr);
+ op1 = loadVar(ptr, &opptr);
while (((op = *((*ptr)++)) & MATHOP_END) == 0) {
- op2 = LoadVar(ptr, &opptr);
- op1 = MathOp(op, op1, op2);
+ op2 = loadVar(ptr, &opptr);
+ op1 = mathOp(op, op1, op2);
}
return op1;
}
@@ -574,10 +574,10 @@ uint16 SCR_3B_MathExpr(void) {
script_ptr++;
/*get result variable pointer*/
- op1 = LoadVar(&script_ptr, &opptr);
+ op1 = loadVar(&script_ptr, &opptr);
/*evaluate*/
- op2 = MathExpr(&script_ptr);
+ op2 = mathExpr(&script_ptr);
/*store result*/
/*TODO: original bug? MathExpr may overwrite global var_size, so mixed-size expressions will produce errorneous results*/
@@ -602,7 +602,7 @@ uint16 SCR_4D_PriorityCommand(void) {
the_command |= (*script_ptr++) << 8;
the_command |= 0xF000;
- /*TODO: normally this should be called from the RunCommand() itself,
+ /*TODO: normally this should be called from the runCommand() itself,
because command Fxxx may be issued from the other places as well (maybe it's not the case)
But that would require some sort of synchronization to avoid infinite loop
So jump to top interepter's loop directly from here for now
@@ -619,7 +619,7 @@ uint16 SCR_12_Chain(void) {
script_ptr++;
the_command = *script_ptr++; /*little-endian*/
the_command |= (*script_ptr++) << 8;
- script_ptr = GetScriptSubroutine(the_command - 1);
+ script_ptr = getScriptSubroutine(the_command - 1);
return 0;
}
@@ -642,7 +642,7 @@ Conditional jump (IF/ELSE block)
uint16 SCR_3C_CondExpr(void) {
script_ptr++;
- if (MathExpr(&script_ptr)) {
+ if (mathExpr(&script_ptr)) {
/*fall to IF block*/
script_ptr += 2;
} else {
@@ -765,7 +765,7 @@ uint16 SCR_A_DrawPortrait(void) {
/*
Draw screen pixels using 2-phase clockwise twist
*/
-void TwistDraw(byte x, byte y, byte width, byte height, byte *source, byte *target) {
+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;
@@ -811,7 +811,7 @@ uint16 SCR_B_DrawPortraitTwistEffect(void) {
offs = cga_CalcXY_p(x, y);
cga_SwapScreenRect(cur_image_pixels, width, height, backbuffer, offs);
- TwistDraw(x, y, width, height, backbuffer, frontbuffer);
+ twistDraw(x, y, width, height, backbuffer, frontbuffer);
cga_BlitAndWait(scratch_mem2, width, width, height, backbuffer, offs);
return 0;
@@ -820,7 +820,7 @@ uint16 SCR_B_DrawPortraitTwistEffect(void) {
/*
Draw screen pixels using arc-like sweep
*/
-void ArcDraw(byte x, byte y, byte width, byte height, byte *source, byte *target) {
+void arcDraw(byte x, byte y, byte width, byte height, byte *source, byte *target) {
int16 i;
uint16 sx, ex, sy, ey;
sx = x * 4;
@@ -862,7 +862,7 @@ uint16 SCR_C_DrawPortraitArcEffect(void) {
offs = cga_CalcXY_p(x, y);
cga_SwapScreenRect(cur_image_pixels, width, height, backbuffer, offs);
- ArcDraw(x, y, width, height, backbuffer, frontbuffer);
+ arcDraw(x, y, width, height, backbuffer, frontbuffer);
cga_BlitAndWait(scratch_mem2, width, width, height, backbuffer, offs);
return 0;
@@ -1132,7 +1132,7 @@ uint16 SCR_1E_HidePortraitTwist(void) {
return 0;
}
- TwistDraw(x, y, width, height, backbuffer, frontbuffer);
+ twistDraw(x, y, width, height, backbuffer, frontbuffer);
return 0;
}
@@ -1156,7 +1156,7 @@ uint16 SCR_1F_HidePortraitArc(void) {
return 0;
}
- ArcDraw(x, y, width, height, backbuffer, frontbuffer);
+ arcDraw(x, y, width, height, backbuffer, frontbuffer);
return 0;
}
@@ -1252,7 +1252,7 @@ static jpoint_t jdeltas[JCOUNT] = {
/*
Play exploding zoom animation
*/
-void JaggedZoom(byte *source, byte *target) {
+void jaggedZoom(byte *source, byte *target) {
int16 i;
jpoint_t points[JCOUNT + 1];
uint16 outside = 0;
@@ -1269,7 +1269,7 @@ void JaggedZoom(byte *source, byte *target) {
for (;;) {
cycle++;
if (cycle % 8 == 0)
- choices = RandW();
+ choices = getRandW();
for (i = 0; i < JCOUNT; i++) {
signed short t;
@@ -1320,23 +1320,23 @@ typedef struct star_t {
/*
Generate random star
*/
-void RandomStar(star_t *star) {
- star->x = RandW();
- star->y = RandW();
- star->z = RandW() & 0xFFF;
+void randomStar(star_t *star) {
+ star->x = getRandW();
+ star->y = getRandW();
+ star->z = getRandW() & 0xFFF;
}
/*
Generate a bunch of random stars
*/
-star_t *InitStarfield(void) {
+star_t *initStarfield(void) {
int16 i;
star_t *stars = (star_t *)scratch_mem2;
for (i = 0; i < 300; i++) {
stars[i].ofs = 0;
stars[i].pixel = 0;
stars[i].mask = 0;
- RandomStar(&stars[i]);
+ randomStar(&stars[i]);
}
return stars;
}
@@ -1344,7 +1344,7 @@ star_t *InitStarfield(void) {
/*
Draw a frame of starfield animation and update stars
*/
-void DrawStars(star_t *stars, int16 iter, byte *target) {
+void drawStars(star_t *stars, int16 iter, byte *target) {
int16 i;
/*TODO: bug? initialized 300 stars, but animated only 256?*/
for (i = 0; i < 256; i++, stars++) {
@@ -1354,7 +1354,7 @@ void DrawStars(star_t *stars, int16 iter, byte *target) {
target[stars->ofs] &= stars->mask;
if (stars->z < 328) {
if (iter >= 30) {
- RandomStar(stars);
+ randomStar(stars);
stars->z |= 0x1800;
}
continue;
@@ -1389,10 +1389,10 @@ void DrawStars(star_t *stars, int16 iter, byte *target) {
/*
Play starfield animation
*/
-void AnimStarfield(star_t *stars, byte *target) {
+void animStarfield(star_t *stars, byte *target) {
int16 i;
for (i = 100; i; i--)
- DrawStars(stars, i, target);
+ drawStars(stars, i, target);
}
/*
@@ -1403,10 +1403,10 @@ uint16 SCR_26_GameOver(void) {
in_de_profundis = 0;
script_byte_vars.game_paused = 1;
memset(backbuffer, 0, sizeof(backbuffer) - 2); /*TODO: original bug?*/
- JaggedZoom(backbuffer, frontbuffer);
+ jaggedZoom(backbuffer, frontbuffer);
cga_BackBufferToRealFull();
cga_ColorSelect(0x30);
- AnimStarfield(InitStarfield(), frontbuffer);
+ animStarfield(initStarfield(), frontbuffer);
playAnim(44, 156 / 4, 95);
script_byte_vars.zone_index = 135;
@@ -1414,7 +1414,7 @@ uint16 SCR_26_GameOver(void) {
while (!loadFond())
askDisk2();
- JaggedZoom(backbuffer, frontbuffer);
+ jaggedZoom(backbuffer, frontbuffer);
cga_BackBufferToRealFull();
restartGame();
@@ -1580,7 +1580,7 @@ uint16 SCR_3_DrawItemBox(void) {
current = *script_ptr++;
if (current)
- item = (item_t *)script_vars[ScrPool3_CurrentItem];
+ item = (item_t *)script_vars[kScrPool3_CurrentItem];
else
item = &inventory_items[aspirant_ptr->item - 1];
@@ -1589,7 +1589,7 @@ uint16 SCR_3_DrawItemBox(void) {
msg = seekToString(desci_data, 274 + item->name);
desciTextBox(x, y, 18, msg);
- DrawSpriteN(item->sprite, x, y + 1, frontbuffer);
+ drawSpriteN(item->sprite, x, y + 1, frontbuffer);
return 0;
}
@@ -1662,7 +1662,7 @@ uint16 SCR_3D_ActionsMenu(void) {
return ScriptRerun;
}
- RunCommand();
+ runCommand();
script_byte_vars.used_commands++;
if (script_byte_vars.bvar_43 == 0 && script_byte_vars.used_commands > script_byte_vars.check_used_commands) {
@@ -1864,7 +1864,7 @@ uint16 SCR_30_Fight(void) {
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]);
+ pers_t *pers = (pers_t *)(script_vars[kScrPool8_CurrentPers]);
byte strenght, win, rnd;
@@ -1879,15 +1879,15 @@ uint16 SCR_30_Fight(void) {
if (pers->name != 44) { /*VORT*/
if (next_vorts_cmd == 0xA015) {
the_command = 0xA015;
- RunCommand();
+ runCommand();
selectPerson(PersonOffset(pers - pers_list));
}
if (Swap16(script_word_vars.next_aspirant_cmd) == 0xC357) {
the_command = 0xC357;
- RunCommand();
+ runCommand();
}
- pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]);
+ pers = (pers_t *)(script_vars[kScrPool8_CurrentPers]);
if (pers->name != 56 && pers->name != 51) { /*MONKEY, TURKEY*/
x = dirty_rects[0].x + 64 / 4;
y = dirty_rects[0].y;
@@ -1975,16 +1975,16 @@ uint16 SCR_30_Fight(void) {
if (strenght >= 2) {
if (strenght == 2) {
if (rnd >= 205)
- win = Rand() < 128 ? (0x40 | 0x10 | 1) : (0x40 | 0x10 | 2);
+ win = getRand() < 128 ? (0x40 | 0x10 | 1) : (0x40 | 0x10 | 2);
} else if (strenght == 4 && rnd < 100) {
- win = Rand() < 128 ? (0x40 | 0x10 | 1) : (0x40 | 0x10 | 2);
+ win = getRand() < 128 ? (0x40 | 0x10 | 1) : (0x40 | 0x10 | 2);
} else {
win = 2;
if (strenght == 3) {
if (rnd < 128) /*TODO: check me, maybe original bug (checks against wrong reg?)*/
- win = Rand() < 51 ? (0x80 | 0x10 | 1) : (0x80 | 0x10 | 2);
+ win = getRand() < 51 ? (0x80 | 0x10 | 1) : (0x80 | 0x10 | 2);
else
- win = Rand() < 205 ? (0x20 | 0x10 | 1) : (0x20 | 0x10 | 2);
+ win = getRand() < 205 ? (0x20 | 0x10 | 1) : (0x20 | 0x10 | 2);
}
}
}
@@ -2077,7 +2077,7 @@ uint16 SCR_31_Fight2(void) {
script_ptr++;
if (script_byte_vars.bvar_43 != 18) {
- pers_t *pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]);
+ pers_t *pers = (pers_t *)(script_vars[kScrPool8_CurrentPers]);
fight_pers_ofs = (byte *)pers - (byte *)pers_list; /*TODO check size*/
pers->flags |= PERSFLG_40;
pers->area = 0;
@@ -2090,7 +2090,7 @@ uint16 SCR_31_Fight2(void) {
animateSpot(&anim19);
}
the_command = next_vorts_cmd;
- RunCommand();
+ runCommand();
} else if (pers->index == 8) { /*Vort duo*/
pers_list[kPersVort3].area = script_byte_vars.zone_area;
pers_list[kPersVort3].flags = pers->flags;
@@ -2099,7 +2099,7 @@ uint16 SCR_31_Fight2(void) {
animateSpot(&anim20);
}
the_command = next_vorts_cmd;
- RunCommand();
+ runCommand();
} else {
if (prev_fight_mode == 0
&& script_byte_vars.zapstiks_owned != 0
@@ -2221,7 +2221,7 @@ uint16 SCR_60_ReviveCadaver(void) {
zone_spots[5].flags = SPOTFLG_40 | SPOTFLG_10 | SPOTFLG_2 | SPOTFLG_1;
found_spot->flags |= SPOTFLG_80;
- pers = (pers_t *)script_vars[ScrPool8_CurrentPers];
+ pers = (pers_t *)script_vars[kScrPool8_CurrentPers];
pers->flags &= ~PERSFLG_40;
pers->area = script_byte_vars.zone_area;
@@ -2280,7 +2280,7 @@ uint16 SCR_15_SelectSpot(void) {
findPerson();
if (script_byte_vars.cur_pers == 0)
- script_vars[ScrPool8_CurrentPers] = &pers_list[kPersProtozorq12];
+ script_vars[kScrPool8_CurrentPers] = &pers_list[kPersProtozorq12];
return 0;
}
@@ -2541,7 +2541,7 @@ uint16 SCR_50_BounceItemToInventory(void) {
script_ptr++;
itemidx = *script_ptr++;
- script_vars[ScrPool3_CurrentItem] = &inventory_items[itemidx - 1];
+ script_vars[kScrPool3_CurrentItem] = &inventory_items[itemidx - 1];
bounceCurrentItem(ITEMFLG_OWNED, 85);
return 0;
@@ -2551,7 +2551,7 @@ uint16 SCR_50_BounceItemToInventory(void) {
Take away Protozorq's zapstik and bounce it to room
*/
uint16 SCR_4B_ProtoDropZapstik(void) {
- pers_t *pers = (pers_t *)(script_vars[ScrPool8_CurrentPers]);
+ pers_t *pers = (pers_t *)(script_vars[kScrPool8_CurrentPers]);
script_ptr++;
@@ -2560,7 +2560,7 @@ uint16 SCR_4B_ProtoDropZapstik(void) {
pers->index &= ~0x18;
- script_vars[ScrPool3_CurrentItem] = &inventory_items[kItemZapstik1 - 1 + (script_byte_vars.cur_pers - 1) - kPersProtozorq1];
+ script_vars[kScrPool3_CurrentItem] = &inventory_items[kItemZapstik1 - 1 + (script_byte_vars.cur_pers - 1) - kPersProtozorq1];
bounceCurrentItem(ITEMFLG_ROOM, 43);
@@ -2575,7 +2575,7 @@ void LootAspirantsItem(void) {
item_t *item = &inventory_items[aspirant_ptr->item - 1];
aspirant_ptr->item = 0;
- script_vars[ScrPool3_CurrentItem] = item;
+ script_vars[kScrPool3_CurrentItem] = item;
script_byte_vars.steals_count++;
script_byte_vars.bvar_6D[aspirant_ptr->index >> 6] = item->name; /*TODO: check these index bits*/
bounceCurrentItem(ITEMFLG_OWNED, 85);
@@ -2616,9 +2616,9 @@ uint16 SCR_51_SkullTraderItemTrade(void) {
status = 3;
if (script_byte_vars.inv_item_index >= kItemRope1 && script_byte_vars.inv_item_index <= kItemLantern4) {
the_command = 0xC204; /*WHICH ONE DO YOU WANT?*/
- RunCommand();
+ runCommand();
- ((item_t *)(script_vars[ScrPool3_CurrentItem]))->flags = 0;
+ ((item_t *)(script_vars[kScrPool3_CurrentItem]))->flags = 0;
openInventory(0xFF, ITEMFLG_TRADER);
@@ -2632,8 +2632,8 @@ uint16 SCR_51_SkullTraderItemTrade(void) {
if (script_byte_vars.rand_value < 128) {
#endif
status = 6; /*win*/
- ((item_t *)(script_vars[ScrPool3_CurrentItem]))[-1].flags = ITEMFLG_TRADER; /*offer previous item copy for next trade*/
- ((item_t *)(script_vars[ScrPool3_CurrentItem]))->flags = 0; /*consume selected item*/
+ ((item_t *)(script_vars[kScrPool3_CurrentItem]))[-1].flags = ITEMFLG_TRADER; /*offer previous item copy for next trade*/
+ ((item_t *)(script_vars[kScrPool3_CurrentItem]))->flags = 0; /*consume selected item*/
}
}
}
@@ -2664,11 +2664,11 @@ uint16 SCR_53_FindInvItem(void) {
item = &inventory_items[first - 1];
for (i = 0; i < count; i++) {
if (item[i].flags == flags) {
- script_vars[ScrPool3_CurrentItem] = &item[i];
+ script_vars[kScrPool3_CurrentItem] = &item[i];
return 0;
}
}
- script_vars[ScrPool3_CurrentItem] = &item[count - 1];
+ script_vars[kScrPool3_CurrentItem] = &item[count - 1];
return 0;
}
@@ -2881,7 +2881,7 @@ extern int16 loadSplash(const char *filename);
/*
TODO: check me
*/
-void TheEnd(void) {
+void theEnd(void) {
static byte image2[] = {168, 28, 85, 22, 15};
byte *pimage2 = image2;
@@ -2899,7 +2899,7 @@ void TheEnd(void) {
while (!loadFond())
askDisk2();
- JaggedZoom(backbuffer, frontbuffer);
+ jaggedZoom(backbuffer, frontbuffer);
cga_BackBufferToRealFull();
} else {
while (!loadSplash("PRES.BIN"))
@@ -2912,7 +2912,7 @@ uint16 SCR_5B_TheEnd(void) {
script_ptr++; /*Useless since this handler never returns*/
script_byte_vars.game_paused = 5;
- TheEnd();
+ theEnd();
if (g_vm->getLanguage() == Common::EN_USA)
restartGame();
@@ -3221,7 +3221,7 @@ Open Psi Powers menu
*/
uint16 CMD_2_PsiPowers(void) {
/*Psi powers bar*/
- BackupAndShowSprite(3, 280 / 4, 40);
+ backupAndShowSprite(3, 280 / 4, 40);
processInput();
do {
pollInput();
@@ -3294,10 +3294,10 @@ uint16 CMD_5_Wait(void) {
script_word_vars.timer_ticks2 = Swap16(Swap16(script_word_vars.timer_ticks2) + 300);
the_command = next_vorts_cmd;
- RunCommand();
+ runCommand();
the_command = next_turkey_cmd;
- RunCommand();
+ runCommand();
script_byte_vars.used_commands = script_byte_vars.check_used_commands;
@@ -3306,7 +3306,7 @@ uint16 CMD_5_Wait(void) {
if (the_command == 0) {
if (script_word_vars.next_aspirant_cmd == 0) {
the_command = 0x9005;
- RunCommand();
+ runCommand();
}
} else {
if (script_byte_vars.bvar_26 >= 63 && script_byte_vars.zone_area < 22 && script_byte_vars.zone_area != 1)
@@ -3394,7 +3394,7 @@ uint16 CMD_A_PsiSolarEyes(void) {
}
the_command = Swap16(script_word_vars.wvar_AA);
- RunCommand();
+ runCommand();
script_byte_vars.cur_spot_flags = 0xFF;
return 0;
@@ -3425,7 +3425,7 @@ void DrawStickyNet(void) {
for (; h; h -= 30) {
int16 i;
for (i = 0; i < w; i += 16 / 4)
- DrawSprite(sprite, frontbuffer, ofs + i);
+ drawSprite(sprite, frontbuffer, ofs + i);
ofs += CGA_BYTES_PER_LINE * 30 / 2;
}
}
@@ -3502,7 +3502,7 @@ uint16 CMD_D_PsiBrainwarp(void) {
return 0;
}
- ((pers_t *)script_vars[ScrPool8_CurrentPers])->flags |= PERSFLG_80;
+ ((pers_t *)script_vars[kScrPool8_CurrentPers])->flags |= PERSFLG_80;
script_byte_vars.dead_flag = script_byte_vars.cur_spot_idx;
script_byte_vars.tries_left = 2;
the_command = 0;
@@ -3661,7 +3661,7 @@ 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];
+ pers_t *pers = (pers_t *)script_vars[kScrPool8_CurrentPers];
byte index = pers->name;
if (index == 93) /*CADAVER*/
index = 19 + 42;
@@ -4356,14 +4356,14 @@ uint16 RunScript(byte *code) {
/*
Get script routine
*/
-byte *GetScriptSubroutine(uint16 index) {
+byte *getScriptSubroutine(uint16 index) {
return seekToEntry(templ_data, index, &script_end_ptr);
}
/*
Run script command
*/
-uint16 RunCommand(void) {
+uint16 runCommand(void) {
uint16 res;
uint16 cmd;
@@ -4377,7 +4377,7 @@ again:;
{
FILE *f = fopen(DEBUG_SCRIPT_LOG, "at");
if (f) {
- fprintf(f, "\nRunCommand 0x%04X rc: %d rs: %d\n", the_command, runcmd_reentr, runscr_reentr);
+ fprintf(f, "\nrunCommand 0x%04X rc: %d rs: %d\n", the_command, runcmd_reentr, runscr_reentr);
fclose(f);
}
}
@@ -4407,7 +4407,7 @@ again:;
/*TODO("SCR_RESTORE\n");*/
/*fall through*/
default:
- res = RunScript(GetScriptSubroutine(cmd - 1));
+ res = RunScript(getScriptSubroutine(cmd - 1));
}
#ifdef DEBUG_SCRIPT
@@ -4431,10 +4431,10 @@ again:;
return res;
}
-uint16 RunCommandKeepSp(void) {
+uint16 runCommandKeepSp(void) {
/*keep_sp = sp;*/
setjmp(script_jmp);
- return RunCommand();
+ return runCommand();
}
} // End of namespace Chamber
diff --git a/engines/chamber/script.h b/engines/chamber/script.h
index 50c45a8bbd8..b56d1fa79ae 100644
--- a/engines/chamber/script.h
+++ b/engines/chamber/script.h
@@ -29,16 +29,16 @@
namespace Chamber {
enum ScriptPools {
- ScrPool0_WordVars0,
- ScrPool1_WordVars1,
- ScrPool2_ByteVars,
- ScrPool3_CurrentItem,
- ScrPool4_ZoneSpots,
- ScrPool5_Persons,
- ScrPool6_Inventory,
- ScrPool7_Zapstiks,
- ScrPool8_CurrentPers,
- ScrPools_MAX
+ kScrPool0_WordVars0,
+ kScrPool1_WordVars1,
+ kScrPool2_ByteVars,
+ kScrPool3_CurrentItem,
+ kScrPool4_ZoneSpots,
+ kScrPool5_Persons,
+ kScrPool6_Inventory,
+ kScrPool7_Zapstiks,
+ kScrPool8_CurrentPers,
+ kScrPools_MAX
};
/*Byte-packed, members accessed from script code by hardcoded offsets*/
@@ -179,7 +179,7 @@ typedef struct script_word_vars_t {
uint16 wvar_B8; /* B8 */
} script_word_vars_t;
-extern void *script_vars[ScrPools_MAX];
+extern void *script_vars[kScrPools_MAX];
extern script_word_vars_t script_word_vars;
extern script_byte_vars_t script_byte_vars;
@@ -229,15 +229,15 @@ extern uint16 fight_pers_ofs;
extern byte wait_delta;
extern byte rand_seed;
-byte Rand(void);
-uint16 RandW(void);
+byte getRand(void);
+uint16 getRandW(void);
extern uint16 the_command;
-byte *GetScriptSubroutine(uint16 index);
+byte *getScriptSubroutine(uint16 index);
-uint16 RunCommand(void);
-uint16 RunCommandKeepSp(void);
+uint16 runCommand(void);
+uint16 runCommandKeepSp(void);
uint16 Swap16(uint16 x);
diff --git a/engines/chamber/timer.cpp b/engines/chamber/timer.cpp
index a5bcf3be5a5..99713b8431c 100644
--- a/engines/chamber/timer.cpp
+++ b/engines/chamber/timer.cpp
@@ -34,7 +34,7 @@ namespace Chamber {
void animateGauss(byte *target) {
byte *sprite;
- byte phase = Rand() % 4;
+ byte phase = getRand() % 4;
if (phase == script_byte_vars.gauss_phase)
phase = (phase + 1) % 4;
script_byte_vars.gauss_phase = phase;
Commit: 3065512bd2a8925183bf8bf942b703b257f6c74a
https://github.com/scummvm/scummvm/commit/3065512bd2a8925183bf8bf942b703b257f6c74a
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Cleanup forbidden symbols
Changed paths:
engines/chamber/chamber.h
engines/chamber/common.h
engines/chamber/kult.cpp
engines/chamber/portrait.cpp
engines/chamber/script.cpp
diff --git a/engines/chamber/chamber.h b/engines/chamber/chamber.h
index 58dd0b8ec36..3437fb56d74 100644
--- a/engines/chamber/chamber.h
+++ b/engines/chamber/chamber.h
@@ -23,8 +23,6 @@
#ifndef CHAMBER_H
#define CHAMBER_H
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
-
#include "common/random.h"
#include "common/serializer.h"
#include "engines/engine.h"
diff --git a/engines/chamber/common.h b/engines/chamber/common.h
index a26a3dda328..119dfc1fb5a 100644
--- a/engines/chamber/common.h
+++ b/engines/chamber/common.h
@@ -30,7 +30,7 @@ namespace Chamber {
#define TODO(s) \
{ \
- printf(s); \
+ warning("%s", s); \
promptWait(); \
for(;;) ; \
}
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 697a35fe316..7071d0ec445 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -20,7 +20,7 @@
*
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
+#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp
#include <setjmp.h>
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index 4d90c2c2ffb..b87e4631b63 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -212,7 +212,7 @@ byte selectCurrentAnim(byte *x, byte *y, byte *index) {
return 1;
}
}
- printf("SelectCurrentAnim: not found for %d\n", aniidx);
+ warning("SelectCurrentAnim: not found for %d", aniidx);
return 0;
}
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 56853d85e70..896ce790b35 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -20,11 +20,13 @@
*
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
+#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp
+#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp
#include <setjmp.h>
#include "common/system.h"
+#include "common/debug.h"
#include "chamber/chamber.h"
#include "chamber/common.h"
@@ -45,7 +47,7 @@
#include "chamber/savegame.h"
#include "chamber/ifgm.h"
-#if 1
+#if 0
#define DEBUG_SCRIPT
char DEBUG_SCRIPT_LOG[] = "!script.log";
#endif
@@ -107,14 +109,14 @@ enum CommandStatus {
};
uint16 CMD_TRAP(void) {
- printf("CMD TRAP\n");
+ warning("CMD TRAP");
promptWait();
for (;;) ;
return 0;
}
uint16 SCR_TRAP(void) {
- printf("SCR TRAP 0x%02X @ 0x%lX\n", *script_ptr, script_ptr - templ_data);
+ warning("SCR TRAP 0x%02X @ 0x%lX", *script_ptr, script_ptr - templ_data);
promptWait();
for (;;) ;
return 0;
@@ -471,7 +473,7 @@ uint16 loadVar(byte **ptr, byte **varptr) {
break;
}
if (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);
+ warning("Scr var out of bounds @ %X (pool %d, ofs 0x%X, max 0x%X)", (uint16)(script_ptr - templ_data), vartype & VARTYPE_KIND, varoffs, maxoffs);
promptWait();
}
}
@@ -486,7 +488,7 @@ uint16 loadVar(byte **ptr, byte **varptr) {
#if 0
/*TODO: debug stuff, remove me*/
if (varoffs == 0x48)
- printf("Var 2.%X = %X\n", varoffs, value);
+ warning("Var 2.%X = %X", varoffs, value);
#endif
} else {
/*immediate value*/
@@ -3770,7 +3772,7 @@ uint16 menu_commands_23[] = {
};
uint16 CMD_12_(void) {
- printf("cmd 12\n");
+ warning("cmd 12");
ActionForPersonChoice(menu_commands_12);
return ScriptRerun;
}
@@ -4397,13 +4399,13 @@ again:;
break;
case 0xA000:
case 0xB000:
- printf("Command: $%X 0x%X\n", the_command, cmd);
+ debug("Command: $%X 0x%X", the_command, cmd);
res = command_handlers[cmd]();
break;
case 0xF000:
/*restore sp from keep_sp then run script*/
/*currently only supposed to work correctly from the SCR_4D_PriorityCommand handler*/
- printf("Restore: $%X 0x%X\n", the_command, cmd);
+ debug("Restore: $%X 0x%X", the_command, cmd);
/*TODO("SCR_RESTORE\n");*/
/*fall through*/
default:
Commit: b2e484418e5631df788683157239b08975d95074
https://github.com/scummvm/scummvm/commit/b2e484418e5631df788683157239b08975d95074
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2023-02-19T23:51:30+01:00
Commit Message:
CHAMBER: Bump license to GPLv3+
Changed paths:
engines/chamber/anim.cpp
engines/chamber/anim.h
engines/chamber/bkbuff.cpp
engines/chamber/cga.cpp
engines/chamber/cga.h
engines/chamber/chamber.cpp
engines/chamber/chamber.h
engines/chamber/common.h
engines/chamber/cursor.cpp
engines/chamber/cursor.h
engines/chamber/decompr.cpp
engines/chamber/decompr.h
engines/chamber/detection.cpp
engines/chamber/dialog.cpp
engines/chamber/dialog.h
engines/chamber/enums.h
engines/chamber/ifgm.cpp
engines/chamber/ifgm.h
engines/chamber/input.cpp
engines/chamber/input.h
engines/chamber/invent.cpp
engines/chamber/invent.h
engines/chamber/kult.cpp
engines/chamber/menu.cpp
engines/chamber/menu.h
engines/chamber/metaengine.cpp
engines/chamber/portrait.cpp
engines/chamber/portrait.h
engines/chamber/print.cpp
engines/chamber/print.h
engines/chamber/r_pers.cpp
engines/chamber/r_puzzl.cpp
engines/chamber/r_sprit.cpp
engines/chamber/r_texts.cpp
engines/chamber/resdata.cpp
engines/chamber/resdata.h
engines/chamber/room.cpp
engines/chamber/room.h
engines/chamber/savegame.cpp
engines/chamber/savegame.h
engines/chamber/script.cpp
engines/chamber/script.h
engines/chamber/scrvars.h
engines/chamber/sound.cpp
engines/chamber/sound.h
engines/chamber/timer.cpp
engines/chamber/timer.h
diff --git a/engines/chamber/anim.cpp b/engines/chamber/anim.cpp
index aca613ddd26..ac01454876e 100644
--- a/engines/chamber/anim.cpp
+++ b/engines/chamber/anim.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/anim.h b/engines/chamber/anim.h
index 2a2ed7967ea..001079022ea 100644
--- a/engines/chamber/anim.h
+++ b/engines/chamber/anim.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/bkbuff.cpp b/engines/chamber/bkbuff.cpp
index 0127c296f4c..db6b7057b97 100644
--- a/engines/chamber/bkbuff.cpp
+++ b/engines/chamber/bkbuff.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/cga.cpp b/engines/chamber/cga.cpp
index 244fc96eea3..44b5828299d 100644
--- a/engines/chamber/cga.cpp
+++ b/engines/chamber/cga.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/cga.h b/engines/chamber/cga.h
index e8e838f65b1..2abea7dde57 100644
--- a/engines/chamber/cga.h
+++ b/engines/chamber/cga.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/chamber.cpp b/engines/chamber/chamber.cpp
index 88a3693d2de..8c8fa04e744 100644
--- a/engines/chamber/chamber.cpp
+++ b/engines/chamber/chamber.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/chamber.h b/engines/chamber/chamber.h
index 3437fb56d74..1b68026754f 100644
--- a/engines/chamber/chamber.h
+++ b/engines/chamber/chamber.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/common.h b/engines/chamber/common.h
index 119dfc1fb5a..a2314c736b9 100644
--- a/engines/chamber/common.h
+++ b/engines/chamber/common.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/cursor.cpp b/engines/chamber/cursor.cpp
index dfec23e32ff..e773e257405 100644
--- a/engines/chamber/cursor.cpp
+++ b/engines/chamber/cursor.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/cursor.h b/engines/chamber/cursor.h
index c69633e6cc1..b0388e55523 100644
--- a/engines/chamber/cursor.h
+++ b/engines/chamber/cursor.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/decompr.cpp b/engines/chamber/decompr.cpp
index 92e30f1350b..8e06fd6c5c8 100644
--- a/engines/chamber/decompr.cpp
+++ b/engines/chamber/decompr.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/decompr.h b/engines/chamber/decompr.h
index 502aa1e4199..9be282ed9af 100644
--- a/engines/chamber/decompr.h
+++ b/engines/chamber/decompr.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/detection.cpp b/engines/chamber/detection.cpp
index 9f060e2f9bb..596a6e40473 100644
--- a/engines/chamber/detection.cpp
+++ b/engines/chamber/detection.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/dialog.cpp b/engines/chamber/dialog.cpp
index a112abec678..b3ddf5cc1f2 100644
--- a/engines/chamber/dialog.cpp
+++ b/engines/chamber/dialog.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/dialog.h b/engines/chamber/dialog.h
index 1e11d90e202..5d6904ba816 100644
--- a/engines/chamber/dialog.h
+++ b/engines/chamber/dialog.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/enums.h b/engines/chamber/enums.h
index 3a2707395aa..f990c853049 100644
--- a/engines/chamber/enums.h
+++ b/engines/chamber/enums.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/ifgm.cpp b/engines/chamber/ifgm.cpp
index e47562b76b1..b47fc7e5b3d 100644
--- a/engines/chamber/ifgm.cpp
+++ b/engines/chamber/ifgm.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/ifgm.h b/engines/chamber/ifgm.h
index af84bd7c2e4..5ee9169efca 100644
--- a/engines/chamber/ifgm.h
+++ b/engines/chamber/ifgm.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/input.cpp b/engines/chamber/input.cpp
index 1589c6258b0..189991034ef 100644
--- a/engines/chamber/input.cpp
+++ b/engines/chamber/input.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/input.h b/engines/chamber/input.h
index 68a483f4026..46954490d36 100644
--- a/engines/chamber/input.h
+++ b/engines/chamber/input.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/invent.cpp b/engines/chamber/invent.cpp
index b3b0e1f6147..3cfe14d0949 100644
--- a/engines/chamber/invent.cpp
+++ b/engines/chamber/invent.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/invent.h b/engines/chamber/invent.h
index c9cf2326dec..0c7ff3d6145 100644
--- a/engines/chamber/invent.h
+++ b/engines/chamber/invent.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/kult.cpp b/engines/chamber/kult.cpp
index 7071d0ec445..27592d410af 100644
--- a/engines/chamber/kult.cpp
+++ b/engines/chamber/kult.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/menu.cpp b/engines/chamber/menu.cpp
index db79f535bf0..7d9df040c1a 100644
--- a/engines/chamber/menu.cpp
+++ b/engines/chamber/menu.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/menu.h b/engines/chamber/menu.h
index 9ac12e30c9e..d84be0c7212 100644
--- a/engines/chamber/menu.h
+++ b/engines/chamber/menu.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/metaengine.cpp b/engines/chamber/metaengine.cpp
index 1f2d556db43..d39465ab1f9 100644
--- a/engines/chamber/metaengine.cpp
+++ b/engines/chamber/metaengine.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/portrait.cpp b/engines/chamber/portrait.cpp
index b87e4631b63..e9df8322a66 100644
--- a/engines/chamber/portrait.cpp
+++ b/engines/chamber/portrait.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/portrait.h b/engines/chamber/portrait.h
index 40d7303a91e..8df9dcda552 100644
--- a/engines/chamber/portrait.h
+++ b/engines/chamber/portrait.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/print.cpp b/engines/chamber/print.cpp
index 3a675367132..ad3c3e5a4b6 100644
--- a/engines/chamber/print.cpp
+++ b/engines/chamber/print.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/print.h b/engines/chamber/print.h
index f36ccccc67b..614e6ee5d8b 100644
--- a/engines/chamber/print.h
+++ b/engines/chamber/print.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/r_pers.cpp b/engines/chamber/r_pers.cpp
index bf6b87f2dbf..88793a9f232 100644
--- a/engines/chamber/r_pers.cpp
+++ b/engines/chamber/r_pers.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/r_puzzl.cpp b/engines/chamber/r_puzzl.cpp
index 21b0d9c1e35..eb4935fd839 100644
--- a/engines/chamber/r_puzzl.cpp
+++ b/engines/chamber/r_puzzl.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/r_sprit.cpp b/engines/chamber/r_sprit.cpp
index 9b180998a5d..86f242732be 100644
--- a/engines/chamber/r_sprit.cpp
+++ b/engines/chamber/r_sprit.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/r_texts.cpp b/engines/chamber/r_texts.cpp
index 1fba4c6cdc4..c65fea2e2cc 100644
--- a/engines/chamber/r_texts.cpp
+++ b/engines/chamber/r_texts.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/resdata.cpp b/engines/chamber/resdata.cpp
index fcd49d322c9..e86845bdba3 100644
--- a/engines/chamber/resdata.cpp
+++ b/engines/chamber/resdata.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/resdata.h b/engines/chamber/resdata.h
index 0edba5e7075..fba3bffc11b 100644
--- a/engines/chamber/resdata.h
+++ b/engines/chamber/resdata.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/room.cpp b/engines/chamber/room.cpp
index a81d5a930ee..86a0b7bedf3 100644
--- a/engines/chamber/room.cpp
+++ b/engines/chamber/room.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/room.h b/engines/chamber/room.h
index 80a964a5f75..8211089e028 100644
--- a/engines/chamber/room.h
+++ b/engines/chamber/room.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/savegame.cpp b/engines/chamber/savegame.cpp
index 29b1ae95e8f..41ec3855b8c 100644
--- a/engines/chamber/savegame.cpp
+++ b/engines/chamber/savegame.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/savegame.h b/engines/chamber/savegame.h
index b49ef48f974..54eee5d5098 100644
--- a/engines/chamber/savegame.h
+++ b/engines/chamber/savegame.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/script.cpp b/engines/chamber/script.cpp
index 896ce790b35..c775b55e399 100644
--- a/engines/chamber/script.cpp
+++ b/engines/chamber/script.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/script.h b/engines/chamber/script.h
index b56d1fa79ae..9be50c3de2c 100644
--- a/engines/chamber/script.h
+++ b/engines/chamber/script.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/scrvars.h b/engines/chamber/scrvars.h
index be0329aa534..9c7b1e75b88 100644
--- a/engines/chamber/scrvars.h
+++ b/engines/chamber/scrvars.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/sound.cpp b/engines/chamber/sound.cpp
index 9d6bd48daee..17130d4a9ff 100644
--- a/engines/chamber/sound.cpp
+++ b/engines/chamber/sound.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/sound.h b/engines/chamber/sound.h
index 99518964c58..9bf9e395896 100644
--- a/engines/chamber/sound.h
+++ b/engines/chamber/sound.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/timer.cpp b/engines/chamber/timer.cpp
index 99713b8431c..a37472ca93f 100644
--- a/engines/chamber/timer.cpp
+++ b/engines/chamber/timer.cpp
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
diff --git a/engines/chamber/timer.h b/engines/chamber/timer.h
index e204bdd8551..0ec476e6318 100644
--- a/engines/chamber/timer.h
+++ b/engines/chamber/timer.h
@@ -4,10 +4,10 @@
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,8 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
More information about the Scummvm-git-logs
mailing list