Skip to content

Commit 8658801

Browse files
committed
Store iosys_mode for our own use to avoid a function call
1 parent 5c98a11 commit 8658801

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

glulxtoc/src/output/functions_common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl GlulxOutput {
8585
OP_GETSTRINGTBL => String::from("stream_get_table()"),
8686
OP_SETSTRINGTBL => runtime("stream_set_table", &args),
8787
// OP_GETIOSYS
88-
OP_SETIOSYS => runtime("stream_set_iosys", &args),
88+
OP_SETIOSYS => format!("iosys_mode = {}; stream_set_iosys(iosys_mode, {})", op_a, op_b),
8989
OP_GLK => format!("(temp0 = {}, temp1 = {}, perform_glk(temp0, temp1, pop_arguments(temp1, 0)))", op_a, op_b),
9090
OP_RANDOM => runtime("OP_RANDOM", &args),
9191
OP_SETRANDOM => runtime("glulx_setrandom", &args),

glulxtoc/src/output/templates/glulxtoc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ extern char _binary_image_data_start[];
3535
#define GLULX_IMAGE _binary_image_data_start
3636

3737
// runtime.c
38+
extern int iosys_mode;
3839
extern glui32 OP_DIV(glui32 arg1, glui32 arg2);
3940
extern glui32 OP_MOD(glui32 arg1, glui32 arg2);
4041
extern glui32 OP_SHIFTL(glui32 arg1, glui32 arg2);

glulxtoc/src/output/templates/runtime.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ MIT licenced
1515
#include "glulxtoc.h"
1616
#include <math.h>
1717

18+
int iosys_mode;
19+
1820
// From accel.c
1921
void init_accel(void) {}
2022
acceleration_func accel_find_func(glui32 index) { return NULL; }
@@ -254,8 +256,6 @@ void OP_STKROLL(glui32 arg0, glui32 arg1) {
254256

255257
void OP_STREAMX_SAFE(int mode, glui32 val) {
256258
// Shortcut for safe streaming
257-
glui32 iosys_mode, iosys_rock;
258-
stream_get_iosys(&iosys_mode, &iosys_rock);
259259
if (iosys_mode != 1 /* iosys_Filter */) {
260260
switch (mode) {
261261
case STREAM_CHAR: (*stream_char_handler)(val & 0xFF); return;

0 commit comments

Comments
 (0)