TWINE: started to refactor the main loop
This commit is contained in:
parent
3fbb55b76e
commit
60e7cbfe11
5 changed files with 128 additions and 144 deletions
|
@ -48,19 +48,12 @@ int32 Interface::checkClipping(int32 x, int32 y) {
|
||||||
|
|
||||||
// TODO: check if Graphics::drawLine() works here
|
// TODO: check if Graphics::drawLine() works here
|
||||||
void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, int32 endHeight, int32 lineColor) {
|
void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, int32 endHeight, int32 lineColor) {
|
||||||
int32 temp;
|
|
||||||
int32 flag2;
|
|
||||||
uint8 *out;
|
|
||||||
int16 color;
|
|
||||||
int16 var2;
|
|
||||||
int16 xchg;
|
|
||||||
int32 outcode0, outcode1;
|
|
||||||
int32 x, y, outcodeOut;
|
|
||||||
int32 currentLineColor = lineColor;
|
int32 currentLineColor = lineColor;
|
||||||
|
uint8 *out;
|
||||||
|
|
||||||
// draw line from left to right
|
// draw line from left to right
|
||||||
if (startWidth > endWidth) {
|
if (startWidth > endWidth) {
|
||||||
temp = endWidth;
|
int32 temp = endWidth;
|
||||||
endWidth = startWidth;
|
endWidth = startWidth;
|
||||||
startWidth = temp;
|
startWidth = temp;
|
||||||
|
|
||||||
|
@ -70,16 +63,18 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform proper clipping (CohenSutherland algorithm)
|
// Perform proper clipping (CohenSutherland algorithm)
|
||||||
outcode0 = checkClipping(startWidth, startHeight);
|
int32 outcode0 = checkClipping(startWidth, startHeight);
|
||||||
outcode1 = checkClipping(endWidth, endHeight);
|
int32 outcode1 = checkClipping(endWidth, endHeight);
|
||||||
|
|
||||||
while ((outcode0 | outcode1) != 0) {
|
while ((outcode0 | outcode1) != 0) {
|
||||||
if (((outcode0 & outcode1) != 0) && (outcode0 != INSIDE))
|
if (((outcode0 & outcode1) != 0) && (outcode0 != INSIDE))
|
||||||
return; // Reject lines which are behind one clipping plane
|
return; // Reject lines which are behind one clipping plane
|
||||||
|
|
||||||
// At least one endpoint is outside the clip rectangle; pick it.
|
// At least one endpoint is outside the clip rectangle; pick it.
|
||||||
outcodeOut = outcode0 ? outcode0 : outcode1;
|
int32 outcodeOut = outcode0 ? outcode0 : outcode1;
|
||||||
|
|
||||||
|
int32 x = 0;
|
||||||
|
int32 y = 0;
|
||||||
if (outcodeOut & TOP) { // point is above the clip rectangle
|
if (outcodeOut & TOP) { // point is above the clip rectangle
|
||||||
x = startWidth + (int)((endWidth - startWidth) * (float)(textWindowTop - startHeight) / (float)(endHeight - startHeight));
|
x = startWidth + (int)((endWidth - startWidth) * (float)(textWindowTop - startHeight) / (float)(endHeight - startHeight));
|
||||||
y = textWindowTop;
|
y = textWindowTop;
|
||||||
|
@ -106,7 +101,7 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
flag2 = 640; //SCREEN_WIDTH;
|
int32 flag2 = DEFAULT_SCREEN_WIDTH;
|
||||||
endWidth -= startWidth;
|
endWidth -= startWidth;
|
||||||
endHeight -= startHeight;
|
endHeight -= startHeight;
|
||||||
if (endHeight < 0) {
|
if (endHeight < 0) {
|
||||||
|
@ -116,12 +111,12 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
|
||||||
|
|
||||||
out = (uint8*)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[startHeight] + startWidth;
|
out = (uint8*)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[startHeight] + startWidth;
|
||||||
|
|
||||||
color = currentLineColor;
|
int16 color = currentLineColor;
|
||||||
if (endWidth < endHeight) { // significant slope
|
if (endWidth < endHeight) { // significant slope
|
||||||
xchg = endWidth;
|
int16 xchg = endWidth;
|
||||||
endWidth = endHeight;
|
endWidth = endHeight;
|
||||||
endHeight = xchg;
|
endHeight = xchg;
|
||||||
var2 = endWidth;
|
int16 var2 = endWidth;
|
||||||
var2 <<= 1;
|
var2 <<= 1;
|
||||||
startHeight = endWidth;
|
startHeight = endWidth;
|
||||||
endHeight <<= 1;
|
endHeight <<= 1;
|
||||||
|
@ -137,7 +132,7 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
|
||||||
}
|
}
|
||||||
} while (--endWidth);
|
} while (--endWidth);
|
||||||
} else { // reduced slope
|
} else { // reduced slope
|
||||||
var2 = endWidth;
|
int16 var2 = endWidth;
|
||||||
var2 <<= 1;
|
var2 <<= 1;
|
||||||
startHeight = endWidth;
|
startHeight = endWidth;
|
||||||
endHeight <<= 1;
|
endHeight <<= 1;
|
||||||
|
@ -155,29 +150,20 @@ void Interface::drawLine(int32 startWidth, int32 startHeight, int32 endWidth, in
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interface::blitBox(int32 left, int32 top, int32 right, int32 bottom, const int8 *source, int32 leftDest, int32 topDest, int8 *dest) {
|
void Interface::blitBox(int32 left, int32 top, int32 right, int32 bottom, const int8 *source, int32 leftDest, int32 topDest, int8 *dest) {
|
||||||
int32 width;
|
const int8 *s = _engine->screenLookupTable[top] + source + left;
|
||||||
int32 height;
|
int8 *d = _engine->screenLookupTable[topDest] + dest + leftDest;
|
||||||
const int8 *s;
|
|
||||||
int8 *d;
|
|
||||||
int32 insideLine;
|
|
||||||
int32 temp3;
|
|
||||||
int32 i;
|
|
||||||
int32 j;
|
|
||||||
|
|
||||||
s = _engine->screenLookupTable[top] + source + left;
|
int32 width = right - left + 1;
|
||||||
d = _engine->screenLookupTable[topDest] + dest + leftDest;
|
int32 height = bottom - top + 1;
|
||||||
|
|
||||||
width = right - left + 1;
|
int32 insideLine = SCREEN_WIDTH - width;
|
||||||
height = bottom - top + 1;
|
int32 temp3 = left;
|
||||||
|
|
||||||
insideLine = SCREEN_WIDTH - width;
|
|
||||||
temp3 = left;
|
|
||||||
|
|
||||||
left >>= 2;
|
left >>= 2;
|
||||||
temp3 &= 3;
|
temp3 &= 3;
|
||||||
|
|
||||||
for (j = 0; j < height; j++) {
|
for (int32 j = 0; j < height; j++) {
|
||||||
for (i = 0; i < width; i++) {
|
for (int32 i = 0; i < width; i++) {
|
||||||
*(d++) = *(s++);
|
*(d++) = *(s++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,16 +173,6 @@ void Interface::blitBox(int32 left, int32 top, int32 right, int32 bottom, const
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interface::drawTransparentBox(int32 left, int32 top, int32 right, int32 bottom, int32 colorAdj) {
|
void Interface::drawTransparentBox(int32 left, int32 top, int32 right, int32 bottom, int32 colorAdj) {
|
||||||
uint8 *pos;
|
|
||||||
int32 width;
|
|
||||||
int32 height;
|
|
||||||
int32 height2;
|
|
||||||
int32 temp;
|
|
||||||
int32 localMode;
|
|
||||||
int32 var1;
|
|
||||||
int8 color;
|
|
||||||
int8 color2;
|
|
||||||
|
|
||||||
if (left > SCREEN_TEXTLIMIT_RIGHT)
|
if (left > SCREEN_TEXTLIMIT_RIGHT)
|
||||||
return;
|
return;
|
||||||
if (right < SCREEN_TEXTLIMIT_LEFT)
|
if (right < SCREEN_TEXTLIMIT_LEFT)
|
||||||
|
@ -215,42 +191,33 @@ void Interface::drawTransparentBox(int32 left, int32 top, int32 right, int32 bot
|
||||||
if (bottom > SCREEN_TEXTLIMIT_BOTTOM)
|
if (bottom > SCREEN_TEXTLIMIT_BOTTOM)
|
||||||
bottom = SCREEN_TEXTLIMIT_BOTTOM;
|
bottom = SCREEN_TEXTLIMIT_BOTTOM;
|
||||||
|
|
||||||
pos = _engine->screenLookupTable[top] + (uint8*)_engine->frontVideoBuffer.getPixels() + left;
|
uint8 *pos = (uint8*)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[top] + left;
|
||||||
height2 = height = bottom - top;
|
int32 height = bottom - top;
|
||||||
height2++;
|
int32 height2 = height + 1;
|
||||||
|
int32 width = right - left + 1;
|
||||||
width = right - left + 1;
|
int32 pitch = DEFAULT_SCREEN_WIDTH - width;
|
||||||
|
int32 localMode = colorAdj;
|
||||||
temp = 640 - width; // SCREEN_WIDTH
|
|
||||||
localMode = colorAdj;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
var1 = width;
|
int32 var1 = width;
|
||||||
do {
|
do {
|
||||||
color2 = color = *pos;
|
int8 color = *pos & 0x0F;
|
||||||
color2 &= 0xF0;
|
const int8 color2 = *pos & 0xF0;
|
||||||
color &= 0x0F;
|
|
||||||
color -= localMode;
|
color -= localMode;
|
||||||
if (color < 0)
|
if (color < 0) {
|
||||||
color = color2;
|
color = color2;
|
||||||
else
|
} else {
|
||||||
color += color2;
|
color += color2;
|
||||||
|
}
|
||||||
*pos++ = color;
|
*pos++ = color;
|
||||||
var1--;
|
var1--;
|
||||||
} while (var1 > 0);
|
} while (var1 > 0);
|
||||||
pos += temp;
|
pos += pitch;
|
||||||
height2--;
|
height2--;
|
||||||
} while (height2 > 0);
|
} while (height2 > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interface::drawSplittedBox(int32 left, int32 top, int32 right, int32 bottom, uint8 e) { // Box
|
void Interface::drawSplittedBox(int32 left, int32 top, int32 right, int32 bottom, uint8 e) { // Box
|
||||||
uint8 *ptr;
|
|
||||||
|
|
||||||
int32 offset;
|
|
||||||
|
|
||||||
int32 x;
|
|
||||||
int32 y;
|
|
||||||
|
|
||||||
if (left > SCREEN_TEXTLIMIT_RIGHT)
|
if (left > SCREEN_TEXTLIMIT_RIGHT)
|
||||||
return;
|
return;
|
||||||
if (right < SCREEN_TEXTLIMIT_LEFT)
|
if (right < SCREEN_TEXTLIMIT_LEFT)
|
||||||
|
@ -261,12 +228,12 @@ void Interface::drawSplittedBox(int32 left, int32 top, int32 right, int32 bottom
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// cropping
|
// cropping
|
||||||
offset = -((right - left) - SCREEN_WIDTH);
|
int32 offset = -((right - left) - SCREEN_WIDTH);
|
||||||
|
|
||||||
ptr = (uint8*)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[top] + left;
|
uint8 *ptr = (uint8*)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[top] + left;
|
||||||
|
|
||||||
for (x = top; x < bottom; x++) {
|
for (int32 x = top; x < bottom; x++) {
|
||||||
for (y = left; y < right; y++) {
|
for (int32 y = left; y < right; y++) {
|
||||||
*(ptr++) = e;
|
*(ptr++) = e;
|
||||||
}
|
}
|
||||||
ptr += offset;
|
ptr += offset;
|
||||||
|
|
|
@ -230,7 +230,7 @@ void Menu::plasmaEffectRenderFrame() {
|
||||||
|
|
||||||
for (j = 1; j < PLASMA_HEIGHT - 1; j++) {
|
for (j = 1; j < PLASMA_HEIGHT - 1; j++) {
|
||||||
for (i = 1; i < PLASMA_WIDTH - 1; i++) {
|
for (i = 1; i < PLASMA_WIDTH - 1; i++) {
|
||||||
/*Here we calculate the average of all 8 neighbour pixel values*/
|
/* Here we calculate the average of all 8 neighbour pixel values */
|
||||||
|
|
||||||
c = plasmaEffectPtr[(i - 1) + (j - 1) * PLASMA_WIDTH]; //top-left
|
c = plasmaEffectPtr[(i - 1) + (j - 1) * PLASMA_WIDTH]; //top-left
|
||||||
c += plasmaEffectPtr[(i + 0) + (j - 1) * PLASMA_WIDTH]; //top
|
c += plasmaEffectPtr[(i + 0) + (j - 1) * PLASMA_WIDTH]; //top
|
||||||
|
@ -243,8 +243,9 @@ void Menu::plasmaEffectRenderFrame() {
|
||||||
c += plasmaEffectPtr[(i + 0) + (j + 1) * PLASMA_WIDTH]; // bottom
|
c += plasmaEffectPtr[(i + 0) + (j + 1) * PLASMA_WIDTH]; // bottom
|
||||||
c += plasmaEffectPtr[(i + 1) + (j + 1) * PLASMA_WIDTH]; // bottom-right
|
c += plasmaEffectPtr[(i + 1) + (j + 1) * PLASMA_WIDTH]; // bottom-right
|
||||||
|
|
||||||
c = (c >> 3) | ((c & 0x0003) << 13); /* And the 2 least significant bits are used as a
|
/* And the 2 least significant bits are used as a
|
||||||
randomizing parameter for statistically fading the flames */
|
* randomizing parameter for statistically fading the flames */
|
||||||
|
c = (c >> 3) | ((c & 0x0003) << 13);
|
||||||
|
|
||||||
if (!(c & 0x6500) &&
|
if (!(c & 0x6500) &&
|
||||||
(j >= (PLASMA_HEIGHT - 4) || c > 0)) {
|
(j >= (PLASMA_HEIGHT - 4) || c > 0)) {
|
||||||
|
@ -264,25 +265,21 @@ void Menu::plasmaEffectRenderFrame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::processPlasmaEffect(int32 top, int32 color) {
|
void Menu::processPlasmaEffect(int32 top, int32 color) {
|
||||||
uint8 *in;
|
const uint8 max_value = color + 15;
|
||||||
uint8 *out;
|
|
||||||
int32 i, j, target;
|
|
||||||
uint8 c;
|
|
||||||
uint8 max_value = color + 15;
|
|
||||||
|
|
||||||
plasmaEffectRenderFrame();
|
plasmaEffectRenderFrame();
|
||||||
|
|
||||||
in = plasmaEffectPtr + 5 * PLASMA_WIDTH;
|
uint8 *in = plasmaEffectPtr + 5 * PLASMA_WIDTH;
|
||||||
out = (uint8 *)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[top];
|
uint8 *out = (uint8 *)_engine->frontVideoBuffer.getPixels() + _engine->screenLookupTable[top];
|
||||||
|
|
||||||
for (i = 0; i < 25; i++) {
|
for (int32 i = 0; i < 25; i++) {
|
||||||
for (j = 0; j < kMainMenuButtonWidth; j++) {
|
for (int32 j = 0; j < kMainMenuButtonWidth; j++) {
|
||||||
c = in[i * kMainMenuButtonWidth + j] / 2 + color;
|
uint8 c = in[i * kMainMenuButtonWidth + j] / 2 + color;
|
||||||
if (c > max_value)
|
if (c > max_value)
|
||||||
c = max_value;
|
c = max_value;
|
||||||
|
|
||||||
/* 2x2 squares sharing the same pixel color: */
|
/* 2x2 squares sharing the same pixel color: */
|
||||||
target = 2 * (i * SCREEN_W + j);
|
int32 target = 2 * (i * SCREEN_W + j);
|
||||||
out[target] = c;
|
out[target] = c;
|
||||||
out[target + 1] = c;
|
out[target + 1] = c;
|
||||||
out[target + SCREEN_W] = c;
|
out[target + SCREEN_W] = c;
|
||||||
|
@ -300,16 +297,19 @@ void Menu::drawBox(int32 left, int32 top, int32 right, int32 bottom) {
|
||||||
|
|
||||||
void Menu::drawButtonGfx(int32 width, int32 topheight, int32 id, int32 value, int32 mode) {
|
void Menu::drawButtonGfx(int32 width, int32 topheight, int32 id, int32 value, int32 mode) {
|
||||||
/*
|
/*
|
||||||
* int CDvolumeRemaped; int musicVolumeRemaped; int masterVolumeRemaped; int lineVolumeRemaped;
|
* int CDvolumeRemaped;
|
||||||
|
* int musicVolumeRemaped;
|
||||||
|
* int masterVolumeRemaped;
|
||||||
|
* int lineVolumeRemaped;
|
||||||
* int waveVolumeRemaped;
|
* int waveVolumeRemaped;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int32 left = width - kMainMenuButtonSpan / 2;
|
int32 left = width - kMainMenuButtonSpan / 2;
|
||||||
int32 right = width + kMainMenuButtonSpan / 2;
|
int32 right = width + kMainMenuButtonSpan / 2;
|
||||||
|
|
||||||
// topheigh is the center Y pos of the button
|
// topheight is the center Y pos of the button
|
||||||
int32 top = topheight - 25; // this makes the button be 50 height
|
int32 top = topheight - 25; // this makes the button be 50 height
|
||||||
int32 bottom = topheight + 25; // ||
|
int32 bottom = topheight + 25;
|
||||||
int32 bottom2 = bottom;
|
int32 bottom2 = bottom;
|
||||||
|
|
||||||
if (mode != 0) {
|
if (mode != 0) {
|
||||||
|
@ -423,12 +423,11 @@ void Menu::drawButton(const int16 *menuSettings, int32 mode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 Menu::processMenu(int16 *menuSettings) {
|
int32 Menu::processMenu(int16 *menuSettings) {
|
||||||
int16 *localData = menuSettings;
|
int16 currentButton = menuSettings[MenuSettings_CurrentLoadedButton];
|
||||||
int16 currentButton = 0; // localData[0];
|
|
||||||
bool buttonReleased = true;
|
bool buttonReleased = true;
|
||||||
bool buttonNeedRedraw = true;
|
bool buttonNeedRedraw = true;
|
||||||
bool musicChanged = false;
|
bool musicChanged = false;
|
||||||
int32 numEntry = localData[1];
|
const int32 numEntry = menuSettings[MenuSettings_NumberOfButtons];
|
||||||
int32 localTime = _engine->lbaTime;
|
int32 localTime = _engine->lbaTime;
|
||||||
int32 maxButton = numEntry - 1;
|
int32 maxButton = numEntry - 1;
|
||||||
|
|
||||||
|
@ -436,7 +435,7 @@ int32 Menu::processMenu(int16 *menuSettings) {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
// if its on main menu
|
// if its on main menu
|
||||||
if (localData == MainMenuSettings) {
|
if (menuSettings == MainMenuSettings) {
|
||||||
if (_engine->lbaTime - localTime > 11650) {
|
if (_engine->lbaTime - localTime > 11650) {
|
||||||
return kBackground;
|
return kBackground;
|
||||||
}
|
}
|
||||||
|
@ -455,6 +454,7 @@ int32 Menu::processMenu(int16 *menuSettings) {
|
||||||
_engine->_keyboard.key = _engine->_keyboard.pressedKey;
|
_engine->_keyboard.key = _engine->_keyboard.pressedKey;
|
||||||
|
|
||||||
if (((uint8)_engine->_keyboard.key & 2)) { // on arrow key down
|
if (((uint8)_engine->_keyboard.key & 2)) { // on arrow key down
|
||||||
|
debug("pressed down");
|
||||||
currentButton++;
|
currentButton++;
|
||||||
if (currentButton == numEntry) { // if current button is the last, than next button is the first
|
if (currentButton == numEntry) { // if current button is the last, than next button is the first
|
||||||
currentButton = 0;
|
currentButton = 0;
|
||||||
|
@ -464,6 +464,7 @@ int32 Menu::processMenu(int16 *menuSettings) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((uint8)_engine->_keyboard.key & 1)) { // on arrow key up
|
if (((uint8)_engine->_keyboard.key & 1)) { // on arrow key up
|
||||||
|
debug("pressed up");
|
||||||
currentButton--;
|
currentButton--;
|
||||||
if (currentButton < 0) { // if current button is the first, than previous button is the last
|
if (currentButton < 0) { // if current button is the first, than previous button is the last
|
||||||
currentButton = maxButton;
|
currentButton = maxButton;
|
||||||
|
@ -472,8 +473,9 @@ int32 Menu::processMenu(int16 *menuSettings) {
|
||||||
buttonReleased = false;
|
buttonReleased = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*(localData + 8) <= 5) { // if its a volume button
|
// if its a volume button
|
||||||
const int16 id = *(localData + currentButton * 2 + 4); // get button parameters from settings array
|
if ((menuSettings == OptionsMenuSettings || menuSettings == VolumeMenuSettings) && *(menuSettings + 8) <= 5) {
|
||||||
|
const int16 id = *(menuSettings + currentButton * 2 + MenuSettings_FirstButtonState); // get button parameters from settings array
|
||||||
|
|
||||||
Audio::Mixer *mixer = _engine->_system->getMixer();
|
Audio::Mixer *mixer = _engine->_system->getMixer();
|
||||||
switch (id) {
|
switch (id) {
|
||||||
|
@ -539,12 +541,12 @@ int32 Menu::processMenu(int16 *menuSettings) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buttonNeedRedraw) {
|
if (buttonNeedRedraw) {
|
||||||
*localData = currentButton;
|
menuSettings[MenuSettings_CurrentLoadedButton] = currentButton;
|
||||||
|
|
||||||
drawButton(localData, 0); // current button
|
drawButton(menuSettings, 0); // current button
|
||||||
do {
|
do {
|
||||||
_engine->readKeys();
|
_engine->readKeys();
|
||||||
drawButton(localData, 1);
|
drawButton(menuSettings, 1);
|
||||||
} while (_engine->_keyboard.pressedKey == 0 && _engine->_keyboard.skippedKey == 0 && _engine->_keyboard.internalKeyCode == 0);
|
} while (_engine->_keyboard.pressedKey == 0 && _engine->_keyboard.skippedKey == 0 && _engine->_keyboard.internalKeyCode == 0);
|
||||||
buttonNeedRedraw = false;
|
buttonNeedRedraw = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -552,14 +554,14 @@ int32 Menu::processMenu(int16 *menuSettings) {
|
||||||
// TODO: update volume settings
|
// TODO: update volume settings
|
||||||
}
|
}
|
||||||
|
|
||||||
drawButton(localData, 1);
|
drawButton(menuSettings, 1);
|
||||||
_engine->readKeys();
|
_engine->readKeys();
|
||||||
// WARNING: this is here to prevent a fade bug while quit the menu
|
// WARNING: this is here to prevent a fade bug while quit the menu
|
||||||
_engine->_screens->copyScreen(_engine->workVideoBuffer, _engine->frontVideoBuffer);
|
_engine->_screens->copyScreen(_engine->workVideoBuffer, _engine->frontVideoBuffer);
|
||||||
}
|
}
|
||||||
} while (!(_engine->_keyboard.skippedKey & 2) && !(_engine->_keyboard.skippedKey & 1));
|
} while (!(_engine->_keyboard.skippedKey & 2) && !(_engine->_keyboard.skippedKey & 1));
|
||||||
|
|
||||||
currentButton = *(localData + 5 + currentButton * 2); // get current browsed button
|
currentButton = *(menuSettings + MenuSettings_FirstButton + currentButton * 2); // get current browsed button
|
||||||
|
|
||||||
_engine->readKeys();
|
_engine->readKeys();
|
||||||
|
|
||||||
|
@ -679,17 +681,14 @@ int32 Menu::optionsMenu() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::mainMenu() {
|
bool Menu::init() {
|
||||||
_engine->_sound->stopSamples();
|
|
||||||
|
|
||||||
_engine->_screens->copyScreen(_engine->frontVideoBuffer, _engine->workVideoBuffer);
|
|
||||||
|
|
||||||
// load menu effect file only once
|
// load menu effect file only once
|
||||||
plasmaEffectPtr = (uint8 *)malloc(kPlasmaEffectFilesize);
|
plasmaEffectPtr = (uint8 *)malloc(kPlasmaEffectFilesize);
|
||||||
memset(plasmaEffectPtr, 0, kPlasmaEffectFilesize);
|
memset(plasmaEffectPtr, 0, kPlasmaEffectFilesize);
|
||||||
_engine->_hqrdepack->hqrGetEntry(plasmaEffectPtr, Resources::HQR_RESS_FILE, RESSHQR_PLASMAEFFECT);
|
return _engine->_hqrdepack->hqrGetEntry(plasmaEffectPtr, Resources::HQR_RESS_FILE, RESSHQR_PLASMAEFFECT) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
while (!_engine->shouldQuit()) {
|
void Menu::run() {
|
||||||
_engine->_text->initTextBank(0);
|
_engine->_text->initTextBank(0);
|
||||||
|
|
||||||
_engine->_music->playTrackMusic(9); // LBA's Theme
|
_engine->_music->playTrackMusic(9); // LBA's Theme
|
||||||
|
@ -722,7 +721,6 @@ void Menu::mainMenu() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_engine->_system->delayMillis(1000 / _engine->cfgfile.Fps);
|
_engine->_system->delayMillis(1000 / _engine->cfgfile.Fps);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 Menu::giveupMenu() {
|
int32 Menu::giveupMenu() {
|
||||||
|
|
|
@ -27,6 +27,17 @@
|
||||||
|
|
||||||
namespace TwinE {
|
namespace TwinE {
|
||||||
|
|
||||||
|
enum MenuSettingsType {
|
||||||
|
// button number
|
||||||
|
MenuSettings_CurrentLoadedButton = 0,
|
||||||
|
// is used to calc the height where the first button will appear
|
||||||
|
MenuSettings_NumberOfButtons = 1,
|
||||||
|
MenuSettings_ButtonsBoxHeight = 2,
|
||||||
|
MenuSettings_HeaderEnd = 3, // TODO: unknown
|
||||||
|
MenuSettings_FirstButtonState = 4,
|
||||||
|
MenuSettings_FirstButton = 5
|
||||||
|
};
|
||||||
|
|
||||||
class Menu {
|
class Menu {
|
||||||
private:
|
private:
|
||||||
TwinEEngine *_engine;
|
TwinEEngine *_engine;
|
||||||
|
@ -124,8 +135,10 @@ public:
|
||||||
*/
|
*/
|
||||||
int32 processMenu(int16 *menuSettings);
|
int32 processMenu(int16 *menuSettings);
|
||||||
|
|
||||||
|
bool init();
|
||||||
|
|
||||||
/** Used to run the main menu */
|
/** Used to run the main menu */
|
||||||
void mainMenu();
|
void run();
|
||||||
|
|
||||||
/** Used to run the in-game give-up menu */
|
/** Used to run the in-game give-up menu */
|
||||||
int32 giveupMenu();
|
int32 giveupMenu();
|
||||||
|
|
|
@ -257,10 +257,11 @@ void Text::drawText(int32 x, int32 y, const char *dialogue) { // Font
|
||||||
return;
|
return;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
uint8 currChar = (uint8) *(dialogue++); // read the next char from the string
|
const uint8 currChar = (uint8) *(dialogue++); // read the next char from the string
|
||||||
|
|
||||||
if (currChar == 0) // if the char is 0x0, -> end of string
|
if (currChar == '\0') {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (currChar == ' ') {
|
if (currChar == ' ') {
|
||||||
x += dialCharSpace;
|
x += dialCharSpace;
|
||||||
|
|
|
@ -142,6 +142,13 @@ Common::Error TwinEEngine::run() {
|
||||||
allocVideoMemory();
|
allocVideoMemory();
|
||||||
initAll();
|
initAll();
|
||||||
initEngine();
|
initEngine();
|
||||||
|
_sound->stopSamples();
|
||||||
|
_screens->copyScreen(frontVideoBuffer, workVideoBuffer);
|
||||||
|
|
||||||
|
_menu->init();
|
||||||
|
while (!shouldQuit()) {
|
||||||
|
_menu->run();
|
||||||
|
}
|
||||||
_music->stopTrackMusic();
|
_music->stopTrackMusic();
|
||||||
_music->stopMidiMusic();
|
_music->stopMidiMusic();
|
||||||
return Common::kNoError;
|
return Common::kNoError;
|
||||||
|
@ -258,8 +265,6 @@ void TwinEEngine::initEngine() {
|
||||||
_flaMovies->playFlaMovie(FLA_DRAGON3);
|
_flaMovies->playFlaMovie(FLA_DRAGON3);
|
||||||
|
|
||||||
_screens->loadMenuImage();
|
_screens->loadMenuImage();
|
||||||
|
|
||||||
_menu->mainMenu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwinEEngine::initMCGA() {
|
void TwinEEngine::initMCGA() {
|
||||||
|
@ -358,7 +363,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
|
||||||
if (loopCurrentKey == twineactions[TwinEActionType::OptionsMenu].localKey) {
|
if (loopCurrentKey == twineactions[TwinEActionType::OptionsMenu].localKey) {
|
||||||
freezeTime();
|
freezeTime();
|
||||||
_sound->pauseSamples();
|
_sound->pauseSamples();
|
||||||
_menu->OptionsMenuSettings[5] = 15;
|
_menu->OptionsMenuSettings[MenuSettings_FirstButton] = 15;
|
||||||
_text->initTextBank(0);
|
_text->initTextBank(0);
|
||||||
_menu->optionsMenu();
|
_menu->optionsMenu();
|
||||||
_text->initTextBank(_text->currentTextBank + 3);
|
_text->initTextBank(_text->currentTextBank + 3);
|
||||||
|
@ -478,7 +483,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
|
||||||
_redraw->redrawEngineActions(1);
|
_redraw->redrawEngineActions(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process behaviour menu - Press CTRL and F1..F4 Keys
|
// Process behaviour menu
|
||||||
if ((loopCurrentKey == twineactions[TwinEActionType::BehaviourMenu].localKey ||
|
if ((loopCurrentKey == twineactions[TwinEActionType::BehaviourMenu].localKey ||
|
||||||
loopCurrentKey == twineactions[TwinEActionType::QuickBehaviourNormal].localKey ||
|
loopCurrentKey == twineactions[TwinEActionType::QuickBehaviourNormal].localKey ||
|
||||||
loopCurrentKey == twineactions[TwinEActionType::QuickBehaviourAthletic].localKey ||
|
loopCurrentKey == twineactions[TwinEActionType::QuickBehaviourAthletic].localKey ||
|
||||||
|
@ -515,7 +520,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Press Enter to Recenter Screen
|
// Recenter Screen
|
||||||
if ((loopPressedKey & 2) && !disableScreenRecenter) {
|
if ((loopPressedKey & 2) && !disableScreenRecenter) {
|
||||||
_grid->newCameraX = _scene->sceneActors[_scene->currentlyFollowedActor].x >> 9;
|
_grid->newCameraX = _scene->sceneActors[_scene->currentlyFollowedActor].x >> 9;
|
||||||
_grid->newCameraY = _scene->sceneActors[_scene->currentlyFollowedActor].y >> 8;
|
_grid->newCameraY = _scene->sceneActors[_scene->currentlyFollowedActor].y >> 8;
|
||||||
|
@ -533,7 +538,7 @@ int32 TwinEEngine::runGameEngine() { // mainLoopInteration
|
||||||
_redraw->redrawEngineActions(1);
|
_redraw->redrawEngineActions(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process Pause - Press P
|
// Process Pause
|
||||||
if (loopCurrentKey == twineactions[TwinEActionType::Pause].localKey) {
|
if (loopCurrentKey == twineactions[TwinEActionType::Pause].localKey) {
|
||||||
freezeTime();
|
freezeTime();
|
||||||
_text->setFontColor(15);
|
_text->setFontColor(15);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue