mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 11:51:52 +00:00
PRINCE: script added
This commit is contained in:
parent
dce5c876c5
commit
71f8ce0894
@ -1,6 +1,7 @@
|
||||
MODULE := engines/prince
|
||||
|
||||
MODULE_OBJS = \
|
||||
script.o \
|
||||
graphics.o \
|
||||
mhwanh.o \
|
||||
detection.o \
|
||||
|
58
engines/prince/script.cpp
Normal file
58
engines/prince/script.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
#include "prince/script.h"
|
||||
|
||||
#include "common/debug-channels.h"
|
||||
#include "common/stream.h"
|
||||
|
||||
namespace Prince {
|
||||
|
||||
Script::Script(PrinceEngine *vm) :
|
||||
_code(NULL), _stacktop(0), _vm(vm), _random("GroovieScripts") {
|
||||
}
|
||||
|
||||
Script::~Script() {
|
||||
}
|
||||
|
||||
bool Script::loadFromStream(Common::SeekableReadStream &stream) {
|
||||
_codeSize = stream.size();
|
||||
_code = new byte[_codeSize];
|
||||
|
||||
if (!_code)
|
||||
return false;
|
||||
|
||||
stream.read(_code, _codeSize);
|
||||
// Initialize the script
|
||||
_currentInstruction = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Script::step() {
|
||||
}
|
||||
|
||||
uint8 Script::getCodeByte(uint16 address) {
|
||||
if (address >= _codeSize)
|
||||
error("Trying to read a script byte at address 0x%04X, while the "
|
||||
"script is just 0x%04X bytes long", address, _codeSize);
|
||||
return _code[address];
|
||||
}
|
||||
|
||||
uint8 Script::readScript8bits() {
|
||||
uint8 data = getCodeByte(_currentInstruction);
|
||||
_currentInstruction++;
|
||||
return data;
|
||||
}
|
||||
|
||||
uint16 Script::readScript16bits() {
|
||||
uint8 lower = readScript8bits();
|
||||
uint8 upper = readScript8bits();
|
||||
return lower | (upper << 8);
|
||||
}
|
||||
|
||||
uint32 Script::readScript32bits() {
|
||||
uint16 lower = readScript16bits();
|
||||
uint16 upper = readScript16bits();
|
||||
return lower | (upper << 16);
|
||||
}
|
||||
|
||||
}
|
||||
|
73
engines/prince/script.h
Normal file
73
engines/prince/script.h
Normal file
@ -0,0 +1,73 @@
|
||||
/* 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 PRINCE_SCRIPT_H
|
||||
#define PRINCE_SCRIPT_H
|
||||
|
||||
#include "common/random.h"
|
||||
|
||||
namespace Common {
|
||||
class SeekableReadStream;
|
||||
}
|
||||
|
||||
namespace Prince {
|
||||
|
||||
class PrinceEngine;
|
||||
|
||||
class Script
|
||||
{
|
||||
public:
|
||||
Script(PrinceEngine *vm);
|
||||
virtual ~Script();
|
||||
|
||||
bool loadFromStream(Common::SeekableReadStream &stream);
|
||||
|
||||
void step();
|
||||
|
||||
private:
|
||||
PrinceEngine *_vm;
|
||||
|
||||
Common::RandomSource _random;
|
||||
|
||||
byte *_code;
|
||||
uint16 _codeSize;
|
||||
uint16 _currentInstruction;
|
||||
|
||||
// Stack
|
||||
uint16 _stack[0x20];
|
||||
uint8 _stacktop;
|
||||
uint8 _savedStacktop;
|
||||
|
||||
// Helper functions
|
||||
uint8 getCodeByte(uint16 address);
|
||||
uint8 readScript8bits();
|
||||
uint16 readScript16bits();
|
||||
uint32 readScript32bits();
|
||||
uint16 readScript8or16bits();
|
||||
|
||||
typedef void (Script::*OpcodeFunc)();
|
||||
static OpcodeFunc _opcodes[];
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user