From e28d3263dc39f54d2bbadc026f4bf7989b7a3701 Mon Sep 17 00:00:00 2001 From: uruk Date: Fri, 28 Jun 2013 18:41:04 +0200 Subject: [PATCH] AVALANCHE: Sequence: replace namespace with class. --- engines/avalanche/avalanche.cpp | 1 + engines/avalanche/avalanche.h | 2 + engines/avalanche/sequence2.cpp | 120 ++++++++++++++++---------------- engines/avalanche/sequence2.h | 30 ++++---- 4 files changed, 82 insertions(+), 71 deletions(-) diff --git a/engines/avalanche/avalanche.cpp b/engines/avalanche/avalanche.cpp index c6821711df9..7465ac6b754 100644 --- a/engines/avalanche/avalanche.cpp +++ b/engines/avalanche/avalanche.cpp @@ -55,6 +55,7 @@ namespace Avalanche { _visa.setParent(this); _lucerna.setParent(this); _enid.setParent(this); + _celer.setParent(this); } AvalancheEngine::~AvalancheEngine() { diff --git a/engines/avalanche/avalanche.h b/engines/avalanche/avalanche.h index 643b97c7f06..6a3187c0721 100644 --- a/engines/avalanche/avalanche.h +++ b/engines/avalanche/avalanche.h @@ -37,6 +37,7 @@ #include "avalanche/visa2.h" #include "avalanche/lucerna2.h" #include "avalanche/enid2.h" +#include "avalanche/celer2.h" #include "engines/engine.h" #include "engines/advancedDetector.h" @@ -61,6 +62,7 @@ public: Visa _visa; Lucerna _lucerna; Enid _enid; + Celer _celer; AvalancheEngine(OSystem *syst, const AvalancheGameDescription *gd); diff --git a/engines/avalanche/sequence2.cpp b/engines/avalanche/sequence2.cpp index 851dcb139a4..79c3e04b2e3 100644 --- a/engines/avalanche/sequence2.cpp +++ b/engines/avalanche/sequence2.cpp @@ -27,6 +27,8 @@ /* SEQUENCE The sequencer. */ +#include "avalanche/avalanche.h" + #include "avalanche/sequence2.h" #include "common/scummsys.h" #include "avalanche/gyro2.h" @@ -36,74 +38,74 @@ namespace Avalanche { - namespace Sequence { +void Sequence::setParent(AvalancheEngine *vm) { + _vm = vm; +} - void then_show(byte what) { - byte fv; - for (fv = 1; fv <= seq_length; fv ++) - if (seq[fv] == 0) { - seq[fv] = what; - return; - } - } +void Sequence::first_show(byte what) { + /* First, we need to blank out the entire array. */ + for (int i = 0; i < sizeof(seq); i++) + seq[i] = 0; - void first_show(byte what) { - /* First, we need to blank out the entire array. */ - for (int i = 0; i < sizeof(seq); i++) - seq[i] = 0; + /* Then it's just the same as then_show. */ + then_show(what); - /* Then it's just the same as then_show. */ - then_show(what); +} - } - - void then_flip(byte where, byte ped) { - then_show(now_flip); - - Gyro::dna.flip_to_where = where; - Gyro::dna.flip_to_ped = ped; - } - - void start_to_close() { - Timeout::lose_timer(Timeout::reason_sequencer); - Timeout::set_up_timer(7, Timeout::PROCsequence, Timeout::reason_sequencer); - } - - void start_to_open() { - Gyro::dna.user_moves_avvy = false; /* They can't move. */ - Trip::stopwalking(); /* And they're not moving now. */ - start_to_close(); /* Apart from that, it's the same thing. */ - } - - void call_sequencer(); - - /* This PROC is called by Timeout when it's time to do another frame. */ - static void shove_left() { - memcpy(seq, seq+1, seq_length - 1); /* Shift everything to the left. */ - } - - void call_sequencer() { - switch (seq[0]) { - case 0: +void Sequence::then_show(byte what) { + byte fv; + for (fv = 1; fv <= seq_length; fv ++) + if (seq[fv] == 0) { + seq[fv] = what; return; - break; /* No more routines. */ - case 177: { - Gyro::dna.user_moves_avvy = true; - Trip::fliproom(Gyro::dna.flip_to_where, Gyro::dna.flip_to_ped); /* 177 = Flip room. */ - if (seq[0] == 177) shove_left(); - } - break; } +} - if ((seq[0] >= 1) && (seq[0] <= 176)) { - /* Show a frame. */ - Celer::show_one(seq[1]); - shove_left(); +void Sequence::then_flip(byte where, byte ped) { + then_show(now_flip); + + _vm->_gyro.dna.flip_to_where = where; + _vm->_gyro.dna.flip_to_ped = ped; +} + +void Sequence::start_to_close() { + Timeout::lose_timer(Timeout::reason_sequencer); + Timeout::set_up_timer(7, Timeout::procsequence, Timeout::reason_sequencer); +} + +void Sequence::start_to_open() { + _vm->_gyro.dna.user_moves_avvy = false; /* They can't move. */ + Trip::stopwalking(); /* And they're not moving now. */ + start_to_close(); /* Apart from that, it's the same thing. */ +} + + + +/* This PROC is called by Timeout when it's time to do another frame. */ +void Sequence::shove_left() { + memcpy(seq, seq+1, seq_length - 1); /* Shift everything to the left. */ +} + +void Sequence::call_sequencer() { + switch (seq[0]) { + case 0: + return; + break; /* No more routines. */ + case 177: { + _vm->_gyro.dna.user_moves_avvy = true; + Trip::fliproom(_vm->_gyro.dna.flip_to_where, _vm->_gyro.dna.flip_to_ped); /* 177 = Flip room. */ + if (seq[0] == 177) shove_left(); } - - start_to_close(); /* Make sure this PROC gets called again. */ + break; } - } // End of namespace Sequence . + if ((seq[0] >= 1) && (seq[0] <= 176)) { + /* Show a frame. */ + _vm->_celer.show_one(seq[1]); + shove_left(); + } + + start_to_close(); /* Make sure this PROC gets called again. */ +} } // End of namespace Avalanche. diff --git a/engines/avalanche/sequence2.h b/engines/avalanche/sequence2.h index 0e53ccf2a1c..7bd79bc61bf 100644 --- a/engines/avalanche/sequence2.h +++ b/engines/avalanche/sequence2.h @@ -33,32 +33,38 @@ #include "common/scummsys.h" namespace Avalanche { +class AvalancheEngine; - namespace Sequence { +class Sequence { +public: + static const int16 now_flip = 177; - const int16 now_flip = 177; - - const int16 seq_length = 10; + static const int16 seq_length = 10; - byte seq[seq_length]; + byte seq[seq_length]; + void setParent(AvalancheEngine *vm); - void first_show(byte what); + void first_show(byte what); - void then_show(byte what); + void then_show(byte what); - void then_flip(byte where, byte ped); + void then_flip(byte where, byte ped); - void start_to_close(); + void start_to_close(); - void start_to_open(); + void start_to_open(); - void call_sequencer(); + void call_sequencer(); - } // End of namespace Sequence . +private: + AvalancheEngine *_vm; + + void shove_left(); +}; } // End of namespace Avalanche.