GLK: FROTZ: Add GlkInterface initialize method

This commit is contained in:
Paul Gilbert 2018-11-11 21:33:20 -08:00 committed by Paul Gilbert
parent a083eb3d5c
commit 9fadd84b37
7 changed files with 146 additions and 12 deletions

View File

@ -234,13 +234,14 @@ struct UserOptions {
bool _save_quetzal;
int _err_report_mode;
bool _sound;
bool _user_tandy_bit;
UserOptions() : _attribute_assignment(0), _attribute_testing(0),
_context_lines(0), _object_locating(0), _object_movement(0),
_left_margin(0), _right_margin(0), _ignore_errors(false), _piracy(false),
_undo_slots(MAX_UNDO_SLOTS), _expand_abbreviations(0), _script_cols(80),
_save_quetzal(true),
_err_report_mode(ERR_DEFAULT_REPORT_MODE), _sound(true) {
_save_quetzal(true), _err_report_mode(ERR_DEFAULT_REPORT_MODE), _sound(true),
_user_tandy_bit(false) {
}
};

View File

@ -26,7 +26,7 @@ namespace Gargoyle {
namespace Frotz {
GlkInterface::GlkInterface(OSystem *syst, const GargoyleGameDescription *gameDesc) :
Glk(syst, gameDesc),
Glk(syst, gameDesc), UserOptions(),
oldstyle(0), curstyle(0), cury(1), curx(1), fixforced(0),
curr_fg(-2), curr_bg(-2), curr_font(1), prev_font(1), temp_font(0),
curr_status_ht(0), mach_status_ht(0), gos_status(nullptr), gos_upper(nullptr),
@ -40,6 +40,135 @@ GlkInterface::GlkInterface(OSystem *syst, const GargoyleGameDescription *gameDes
Common::fill(&statusline[0], &statusline[256], '\0');
}
void GlkInterface::initialize() {
uint width, height;
/*
* Init glk stuff
*/
// monor
glk_stylehint_set(wintype_AllTypes, style_Preformatted, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_Preformatted, stylehint_Weight, 0);
glk_stylehint_set(wintype_AllTypes, style_Preformatted, stylehint_Oblique, 0);
// monob
glk_stylehint_set(wintype_AllTypes, style_Subheader, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_Subheader, stylehint_Weight, 1);
glk_stylehint_set(wintype_AllTypes, style_Subheader, stylehint_Oblique, 0);
// monoi
glk_stylehint_set(wintype_AllTypes, style_Alert, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_Alert, stylehint_Weight, 0);
glk_stylehint_set(wintype_AllTypes, style_Alert, stylehint_Oblique, 1);
// monoz
glk_stylehint_set(wintype_AllTypes, style_BlockQuote, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_BlockQuote, stylehint_Weight, 1);
glk_stylehint_set(wintype_AllTypes, style_BlockQuote, stylehint_Oblique, 1);
// propr
glk_stylehint_set(wintype_TextBuffer, style_Normal, stylehint_Proportional, 1);
glk_stylehint_set(wintype_TextGrid, style_Normal, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_Weight, 0);
glk_stylehint_set(wintype_AllTypes, style_Normal, stylehint_Oblique, 0);
// propb
glk_stylehint_set(wintype_TextBuffer, style_Header, stylehint_Proportional, 1);
glk_stylehint_set(wintype_TextGrid, style_Header, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_Header, stylehint_Weight, 1);
glk_stylehint_set(wintype_AllTypes, style_Header, stylehint_Oblique, 0);
// propi
glk_stylehint_set(wintype_TextBuffer, style_Emphasized, stylehint_Proportional, 1);
glk_stylehint_set(wintype_TextGrid, style_Emphasized, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_Emphasized, stylehint_Weight, 0);
glk_stylehint_set(wintype_AllTypes, style_Emphasized, stylehint_Oblique, 1);
// propi
glk_stylehint_set(wintype_TextBuffer, style_Note, stylehint_Proportional, 1);
glk_stylehint_set(wintype_TextGrid, style_Note, stylehint_Proportional, 0);
glk_stylehint_set(wintype_AllTypes, style_Note, stylehint_Weight, 1);
glk_stylehint_set(wintype_AllTypes, style_Note, stylehint_Oblique, 1);
gos_lower = glk_window_open(0, 0, 0, wintype_TextGrid, 0);
if (!gos_lower)
gos_lower = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
glk_window_get_size(gos_lower, &width, &height);
glk_window_close(gos_lower, NULL);
gos_lower = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);
gos_upper = glk_window_open(gos_lower,
winmethod_Above | winmethod_Fixed,
0,
wintype_TextGrid, 0);
gos_channel = NULL;
glk_set_window(gos_lower);
gos_curwin = gos_lower;
/*
* Icky magic bit setting
*/
if (h_version == V3 && _user_tandy_bit)
h_config |= CONFIG_TANDY;
if (h_version == V3 && gos_upper)
h_config |= CONFIG_SPLITSCREEN;
if (h_version == V3 && !gos_upper)
h_config |= CONFIG_NOSTATUSLINE;
if (h_version >= V4)
h_config |= CONFIG_BOLDFACE | CONFIG_EMPHASIS |
CONFIG_FIXED | CONFIG_TIMEDINPUT | CONFIG_COLOUR;
if (h_version >= V5)
h_flags &= ~(GRAPHICS_FLAG | MOUSE_FLAG | MENU_FLAG);
if ((h_version >= 5) && (h_flags & SOUND_FLAG))
h_flags |= SOUND_FLAG;
if ((h_version == 3) && (h_flags & OLD_SOUND_FLAG))
h_flags |= OLD_SOUND_FLAG;
if ((h_version == 6) && (_sound != 0))
h_config |= CONFIG_SOUND;
if (h_version >= V5 && (h_flags & UNDO_FLAG))
if (_undo_slots == 0)
h_flags &= ~UNDO_FLAG;
h_screen_cols = width;
h_screen_rows = height;
h_screen_height = h_screen_rows;
h_screen_width = h_screen_cols;
h_font_width = 1;
h_font_height = 1;
/* Must be after screen dimensions are computed. */
if (h_version == V6) {
h_flags &= ~GRAPHICS_FLAG;
}
// Use the ms-dos interpreter number for v6, because that's the
// kind of graphics files we understand. Otherwise, use DEC.
h_interpreter_number = h_version == 6 ? INTERP_MSDOS : INTERP_DEC_20;
h_interpreter_version = 'F';
{
// Set these per spec 8.3.2.
h_default_foreground = WHITE_COLOUR;
h_default_background = BLACK_COLOUR;
if (h_flags & COLOUR_FLAG)
h_flags &= ~COLOUR_FLAG;
}
}
int GlkInterface::os_char_width(zchar z) {
return 1;
}
@ -118,7 +247,7 @@ void GlkInterface::gos_update_width() {
glk_window_get_size(gos_upper, &width, nullptr);
h_screen_cols = width;
SET_BYTE(H_SCREEN_COLS, width);
if (curx > width) {
if ((uint)curx > width) {
glk_window_move_cursor(gos_upper, 0, cury - 1);
curx = 1;
}
@ -140,7 +269,7 @@ void GlkInterface::reset_status_ht() {
glui32 height;
if (gos_upper) {
glk_window_get_size(gos_upper, nullptr, &height);
if (mach_status_ht != height) {
if ((uint)mach_status_ht != height) {
glk_window_set_arrangement(
glk_window_get_parent(gos_upper),
winmethod_Above | winmethod_Fixed,

View File

@ -40,7 +40,7 @@ enum SoundEffect {
* Implements an intermediate interface on top of the GLK layer, providing screen
* and sound effect handling
*/
class GlkInterface : public Glk, public virtual Mem {
class GlkInterface : public Glk, public UserOptions, public virtual Mem {
public:
zchar statusline[256];
int oldstyle;
@ -139,6 +139,11 @@ public:
* Constructor
*/
GlkInterface(OSystem *syst, const GargoyleGameDescription *gameDesc);
/**
* Initialization
*/
void initialize();
};
} // End of namespace Frotz

View File

@ -186,7 +186,7 @@ public:
/**
* Initialize
*/
virtual void initialize();
void initialize();
/**
* Read a word

View File

@ -132,7 +132,7 @@ Opcode Processor::ext_opcodes[64] = {
};
Processor::Processor(OSystem *syst, const GargoyleGameDescription *gameDesc) :
GlkInterface(syst, gameDesc), Mem(), Errors(), UserOptions(),
GlkInterface(syst, gameDesc), Mem(), Errors(),
_finished(0), _sp(nullptr), _fp(nullptr), _frameCount(0),
zargc(0), _decoded(nullptr), _encoded(nullptr), _resolution(0),
_randomInterval(0), _randomCtr(0), first_restart(true) {
@ -181,6 +181,7 @@ Processor::Processor(OSystem *syst, const GargoyleGameDescription *gameDesc) :
void Processor::initialize() {
Mem::initialize();
GlkInterface::initialize();
if (h_version <= V4) {
op0_opcodes[9] = &Processor::z_pop;

View File

@ -48,7 +48,7 @@ typedef void (Processor::*Opcode)();
/**
* Zcode processor
*/
class Processor : public virtual Mem, public Errors, public GlkInterface, public UserOptions {
class Processor : public virtual Mem, public Errors, public GlkInterface {
private:
Opcode op0_opcodes[16];
Opcode op1_opcodes[16];
@ -1308,7 +1308,7 @@ public:
/**
* Initialization
*/
virtual void initialize() override;
void initialize();
/**
* Z-code interpreter main loop

View File

@ -26,8 +26,6 @@ namespace Gargoyle {
namespace Frotz {
// TODO: Implement method stubs
static zchar stream_read_key(zword, zword, bool) { return 0; }
static zchar stream_read_input(int, zchar *, zword, zword, bool, bool) { return 0;}
static void storeb(zword, zchar) {}
static void storew(zword, zword) {}
static void save_undo() {}