diff options
| -rw-r--r-- | engines/gargoyle/frotz/processor.cpp | 4 | ||||
| -rw-r--r-- | engines/gargoyle/frotz/processor.h | 36 | ||||
| -rw-r--r-- | engines/gargoyle/frotz/processor_input.cpp | 30 | ||||
| -rw-r--r-- | engines/gargoyle/frotz/processor_streams.cpp | 8 | ||||
| -rw-r--r-- | engines/gargoyle/frotz/processor_table.cpp | 5 | ||||
| -rw-r--r-- | engines/gargoyle/frotz/processor_text.cpp | 5 | 
6 files changed, 74 insertions, 14 deletions
| diff --git a/engines/gargoyle/frotz/processor.cpp b/engines/gargoyle/frotz/processor.cpp index 85a539b48f..934101332d 100644 --- a/engines/gargoyle/frotz/processor.cpp +++ b/engines/gargoyle/frotz/processor.cpp @@ -135,8 +135,8 @@ Processor::Processor(OSystem *syst, const GargoyleGameDescription *gameDesc) :  		GlkInterface(syst, gameDesc), Errors(),  		_finished(0), _sp(nullptr), _fp(nullptr), _frameCount(0),  		zargc(0), _decoded(nullptr), _encoded(nullptr), _resolution(0), -		_randomInterval(0), _randomCtr(0), first_restart(true), _bufPos(0), -		_locked(false), _prevC('\0') { +		_randomInterval(0), _randomCtr(0), first_restart(true), script_valid(false), +		_bufPos(0), _locked(false), _prevC('\0') {  	static const Opcode OP0_OPCODES[16] = {  		&Processor::z_rtrue,  		&Processor::z_rfalse, diff --git a/engines/gargoyle/frotz/processor.h b/engines/gargoyle/frotz/processor.h index d754b1f1ee..1554265092 100644 --- a/engines/gargoyle/frotz/processor.h +++ b/engines/gargoyle/frotz/processor.h @@ -56,6 +56,7 @@ private:  	uint _randomInterval;  	uint _randomCtr;  	bool first_restart; +	bool script_valid;  	// Stack data  	zword _stack[STACK_SIZE]; @@ -202,6 +203,21 @@ private:  	/**@}*/  	/** +	 * \defgroup Memory support methods +	 * @{ +	 */ + +	/** +	 * Write a byte value to the dynamic Z-machine memory. +	 */ +	void storeb(zword addr, zbyte value); + +	/** +	 * Write a word value to the dynamic Z-machine memory. +	 */ +	void storew(zword addr, zword value); + +	/**  	 * \defgroup Object support methods  	 * @{  	 */ @@ -308,6 +324,26 @@ private:  	zchar stream_read_input(int max, zchar *buf, zword timeout, zword routine,  		bool hot_keys, bool no_scripting); +	/* +	 * script_open +	 * +	 * Open the transscript file. 'AMFV' makes this more complicated as it +	 * turns transscription on/off several times to exclude some text from +	 * the transscription file. This wasn't a problem for the original V4 +	 * interpreters which always sent transscription to the printer, but it +	 * means a problem to modern interpreters that offer to open a new file +	 * every time transscription is turned on. Our solution is to append to +	 * the old transscription file in V1 to V4, and to ask for a new file +	 * name in V5+. +	 * +	 */ +	void script_open(); + +	/* +	 * Stop transscription. +	 */ +	void script_close(); +  	 /**@}*/  	/** diff --git a/engines/gargoyle/frotz/processor_input.cpp b/engines/gargoyle/frotz/processor_input.cpp index 86a8abc13a..43f0aaf455 100644 --- a/engines/gargoyle/frotz/processor_input.cpp +++ b/engines/gargoyle/frotz/processor_input.cpp @@ -26,8 +26,6 @@ namespace Gargoyle {  namespace Frotz {  // TODO: Implement method stubs -static void storeb(zword, zchar) {} -static void storew(zword, zword) {}  static void save_undo() {}  static zword os_read_mouse() { return 0; } @@ -80,7 +78,35 @@ int Processor::read_number() {  	    value = 10 * value + buffer[i] - '0';      return value; +} + +void Processor::storeb(zword addr, zbyte value) { +	if (addr >= h_dynamic_size) +		runtimeError(ERR_STORE_RANGE); + +	if (addr == H_FLAGS + 1) {	/* flags register is modified */ + +		h_flags &= ~(SCRIPTING_FLAG | FIXED_FONT_FLAG); +		h_flags |= value & (SCRIPTING_FLAG | FIXED_FONT_FLAG); + +		if (value & SCRIPTING_FLAG) { +			if (!ostream_script) +				script_open(); +		} else { +			if (ostream_script) +				script_close(); +		} + +		// TOR - glkified / refresh_text_style (); +	} + +	SET_BYTE(addr, value); + +} +void Processor::storew(zword addr, zword value) { +	storeb((zword)(addr + 0), hi(value)); +	storeb((zword)(addr + 1), lo(value));  }  void Processor::z_read() { diff --git a/engines/gargoyle/frotz/processor_streams.cpp b/engines/gargoyle/frotz/processor_streams.cpp index ae4dbaada1..a5360959f2 100644 --- a/engines/gargoyle/frotz/processor_streams.cpp +++ b/engines/gargoyle/frotz/processor_streams.cpp @@ -222,6 +222,14 @@ continue_input:      return key;  } +void Processor::script_open() { +	// TODO +} + +void Processor::script_close() { +	// TODO +} +  void Processor::z_input_stream() {  	flush_buffer(); diff --git a/engines/gargoyle/frotz/processor_table.cpp b/engines/gargoyle/frotz/processor_table.cpp index 4e660ca693..d4490628e3 100644 --- a/engines/gargoyle/frotz/processor_table.cpp +++ b/engines/gargoyle/frotz/processor_table.cpp @@ -25,11 +25,6 @@  namespace Gargoyle {  namespace Frotz { -// TODO: Method stubs to implement -static void storeb(zword, zbyte) {} -static void storew(zword, zword) {} - -  void Processor::z_copy_table() {      zword addr;      zword size = zargs[2]; diff --git a/engines/gargoyle/frotz/processor_text.cpp b/engines/gargoyle/frotz/processor_text.cpp index f6a82fb56e..630bd50dbe 100644 --- a/engines/gargoyle/frotz/processor_text.cpp +++ b/engines/gargoyle/frotz/processor_text.cpp @@ -25,11 +25,6 @@  namespace Gargoyle {  namespace Frotz { -// TODO: Replace method stubs -static void storeb(zword, zchar) {} -static void storew(zword, zword) {} - -  zchar Processor::ZSCII_TO_LATIN1[] = {      0x0e4, 0x0f6, 0x0fc, 0x0c4, 0x0d6, 0x0dc, 0x0df, 0x0bb,      0x0ab, 0x0eb, 0x0ef, 0x0ff, 0x0cb, 0x0cf, 0x0e1, 0x0e9, | 
