AVALANCHE: Scrolls: replace namespace with class.

This commit is contained in:
uruk 2013-06-28 17:41:02 +02:00
parent b7ef84983e
commit e4c8d82f9d
2 changed files with 222 additions and 195 deletions

View File

@ -25,6 +25,8 @@
* Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
*/
#include "avalanche/avalanche.h"
#include "avalanche/scrolls2.h"
#include "avalanche/gyro2.h"
#include "avalanche/logger2.h"
@ -41,31 +43,25 @@
namespace Avalanche {
namespace Scrolls {
const int16 Scrolls::roman = 0;
const int16 Scrolls::italic = 1;
const int16 roman = 0;
const int16 italic = 1;
const int16 halficonwidth = 19; /* Half the width of an icon. */
int16 dix, diy;
Gyro::raw ch[2];
byte cfont; /* Current font */
int16 dodgex, dodgey;
byte param; /* For using arguments code */
byte use_icon;
const int16 Scrolls::halficonwidth = 19; /* Half the width of an icon. */
void initialize_scrolls() {
warning("STUB: Scrolls::initialize_scrolls()");
}
void state(byte x) { /* Sets "Ready" light to whatever */
Scrolls::Scrolls() : aboutscroll(false) {
}
void Scrolls::setParent(AvalancheEngine *vm) {
_vm = vm;
}
void Scrolls::state(byte x) { /* Sets "Ready" light to whatever */
byte page_;
if (Gyro::ledstatus == x) return; /* Already like that! */
if (_vm->_gyro.ledstatus == x) return; /* Already like that! */
warning("STUB: Scrolls::state(). Calls of Pascal units need to be removed.");
//switch (x) {
@ -83,18 +79,18 @@ namespace Avalanche {
// break; /* Hit a key */
//}
Gyro::super_off();
_vm->_gyro.super_off();
/* for (page_ = 0; page_ <= 1; page_ ++) {
setactivepage(page_);
bar(419, 195, 438, 197);
}*/
Gyro::super_on();
Gyro::ledstatus = x;
}
_vm->_gyro.super_on();
_vm->_gyro.ledstatus = x;
}
void easteregg() {
void Scrolls::easteregg() {
uint16 fv, ff;
warning("STUB: Scrolls::easteregg(). Calls of Pascal units need to be removed.");
@ -113,10 +109,10 @@ namespace Avalanche {
settextstyle(0, 0, 1);
settextjustify(0, 2);*/
Gyro::background(0);
}
_vm->_gyro.background(0);
}
void say(int16 x, int16 y, Common::String z) { /* Fancy FAST screenwriting */
void Scrolls::say(int16 x, int16 y, Common::String z) { /* Fancy FAST screenwriting */
const int16 locol = 2;
byte xx, yy, ox, bit, lz, t;
int16 yp;
@ -127,24 +123,24 @@ namespace Avalanche {
x = x / 8;
lz = z.size();
ox = 0;
Logger::log_scrollline();
_vm->_logger.log_scrollline();
for (xx = 1; xx <= lz; xx ++) {
switch (z[xx]) {
case '\22': {
cfont = roman;
Logger::log_roman();
_vm->_logger.log_roman();
}
break;
case '\6': {
cfont = italic;
Logger::log_italic();
_vm->_logger.log_italic();
}
break;
default: {
ox += 1;
for (yy = 1; yy <= 12; yy ++) itw[yy][ox] = ~ ch[cfont][z[xx]][yy + 1];
Logger::log_scrollchar(Common::String(z[xx]));
_vm->_logger.log_scrollchar(Common::String(z[xx]));
}
}
}
@ -163,7 +159,7 @@ namespace Avalanche {
}
}
}
yp = x + y * 80 + (1 - Gyro::cp) * Gyro::pagetop;
yp = x + y * 80 + (1 - _vm->_gyro.cp) * _vm->_gyro.pagetop;
for (yy = 1; yy <= 12; yy ++) {
yp += 80;
for (bit = 0; bit <= locol; bit ++) {
@ -179,29 +175,29 @@ namespace Avalanche {
}
}
}
}
/* Here are the procedures that Scroll calls */ /* So they must be... */ /*$F+*/
/* Here are the procedures that Scroll calls */ /* So they must be... */ /*$F+*/
void normscroll() {
void Scrolls::normscroll() {
warning("STUB: Scrolls::normscroll()");
}
}
void dialogue() {
void Scrolls::dialogue() {
warning("STUB: Scrolls::dialogue()");
}
void music_scroll();
}
static void store_(byte what, Gyro::tunetype &played) {
void Scrolls::store_(byte what, tunetype &played) {
memcpy(played, played+1, sizeof(played) - 1);
played[30] = what;
}
}
static bool they_match(Gyro::tunetype &played) {
bool Scrolls::they_match(tunetype &played) {
byte fv, mistakes;
bool they_match_result;
@ -214,21 +210,21 @@ namespace Avalanche {
they_match_result = mistakes < 5;
return they_match_result;
}
}
void music_scroll() {
void Scrolls::music_scroll() {
char r;
byte value;
byte last_one, this_one;
Gyro::tunetype played;
tunetype played;
state(3);
Gyro::seescroll = true;
Gyro::on();
Gyro::newpointer(4);
_vm->_gyro.seescroll = true;
_vm->_gyro.on();
_vm->_gyro.newpointer(4);
//do {
//do {
// Gyro::check(); /* was "checkclick;" */
@ -243,7 +239,7 @@ namespace Avalanche {
//}
//}
}
}
@ -255,8 +251,4 @@ namespace Avalanche {
} // End of namespace Scrolls
} // End of namespace Avalanche

View File

@ -34,20 +34,23 @@
// #include "avalanche/joystick2.h" - Will be implemented later, if it will be implemented at all...
namespace Avalanche {
class AvalancheEngine;
namespace Scrolls {
class Scrolls {
public:
bool aboutscroll; /* Is this the about box? */
// Call it where Scrolls are first used.
// Procuded to replace the initizalization part of the original Pascal unit.
void initialize_scrolls();
const bool aboutscroll = false; /* Is this the about box? */
Scrolls();
void setParent(AvalancheEngine *vm);
void state(byte x); /* Sets "Ready" light to whatever */
void drawscroll(Gyro::proc gotoit); /* This is one of the oldest procs in the game. */
void drawscroll(proc gotoit); /* This is one of the oldest procs in the game. */
void bubble(Gyro::proc gotoit);
void bubble(proc gotoit);
void resetscroll();
@ -65,7 +68,39 @@ namespace Avalanche {
void musical_scroll();
} // End of namespace Scrolls
private:
AvalancheEngine *_vm;
static const int16 roman;
static const int16 italic;
static const int16 halficonwidth; /* Half the width of an icon. */
int16 dix, diy;
raw ch[2];
byte cfont; /* Current font */
int16 dodgex, dodgey;
byte param; /* For using arguments code */
byte use_icon;
void easteregg();
void say(int16 x, int16 y, Common::String z);
void normscroll();
void dialogue();
void store_(byte what, tunetype &played);
bool they_match(tunetype &played);
void music_scroll();
};
} // End of namespace Avalanche