diff options
Diffstat (limited to 'mixlib')
-rw-r--r-- | mixlib/mix_device.c | 4 | ||||
-rw-r--r-- | mixlib/mix_device.h | 2 | ||||
-rw-r--r-- | mixlib/xmix_device.c | 15 | ||||
-rw-r--r-- | mixlib/xmix_device.h | 2 | ||||
-rw-r--r-- | mixlib/xmix_vm.c | 4 |
5 files changed, 18 insertions, 9 deletions
diff --git a/mixlib/mix_device.c b/mixlib/mix_device.c index 5d3927c..e63119b 100644 --- a/mixlib/mix_device.c +++ b/mixlib/mix_device.c @@ -148,11 +148,11 @@ mix_device_read (mix_device_t *dev, mix_word_t *block) } gboolean -mix_device_ioc (mix_device_t *dev, mix_short_t arg) +mix_device_ioc (mix_device_t *dev, mix_short_t arg, mix_word_t val) { g_return_val_if_fail (dev != NULL, FALSE); g_assert (dev->vtable != NULL); - return (dev->vtable->ioc) (dev, arg); + return (dev->vtable->ioc) (dev, arg, val); } gboolean diff --git a/mixlib/mix_device.h b/mixlib/mix_device.h index 1273f18..c0e03ab 100644 --- a/mixlib/mix_device.h +++ b/mixlib/mix_device.h @@ -148,7 +148,7 @@ mix_device_read (mix_device_t *dev, mix_word_t *block); >0 - skip forward the given number of blocks */ extern gboolean -mix_device_ioc (mix_device_t *dev, mix_short_t arg); +mix_device_ioc (mix_device_t *dev, mix_short_t arg, mix_word_t val); /* Check if a device is busy diff --git a/mixlib/xmix_device.c b/mixlib/xmix_device.c index 8d4084c..6fb085f 100644 --- a/mixlib/xmix_device.c +++ b/mixlib/xmix_device.c @@ -143,14 +143,20 @@ read_ (mix_device_t *dev, mix_word_t *block) } static gboolean -ioc_ (mix_device_t *dev, mix_short_t arg) +ioc_ (mix_device_t *dev, mix_short_t arg, mix_word_t val) { int m; FILE *file; + long diskblock; m = mix_short_magnitude(arg); if (mix_short_is_negative(arg)) m = -m; m *= sizeof (mix_word_t) * SIZES_[dev->type]; + + diskblock = mix_word_magnitude(val); + if (mix_word_is_negative(val)) diskblock = -diskblock; + diskblock *= sizeof (mix_word_t) * SIZES_[dev->type]; + file = mix_io_to_FILE (GET_CHANNEL_(dev)); if (dev->type >= mix_dev_TAPE_0 && dev->type <= mix_dev_TAPE_7) @@ -160,12 +166,13 @@ ioc_ (mix_device_t *dev, mix_short_t arg) } if (dev->type >= mix_dev_DISK_0 && dev->type <= mix_dev_DISK_7) { - if (m == 0) return FALSE; - // position disk + // move read/write head to block + if (m != 0 || diskblock < 0) return FALSE; + else fseek (file, diskblock, SEEK_SET); } if (dev->type == mix_dev_PAPER_TAPE) { - if (m == 0) return FALSE; + if (m != 0) return FALSE; rewind (file); } return TRUE; diff --git a/mixlib/xmix_device.h b/mixlib/xmix_device.h index 13950c9..4de321d 100644 --- a/mixlib/xmix_device.h +++ b/mixlib/xmix_device.h @@ -32,7 +32,7 @@ extern gchar *DEV_DIR_; /* table of overridable device operations */ typedef gboolean (*mix_dev_write_func_t) (mix_device_t *, const mix_word_t *); typedef gboolean (*mix_dev_read_func_t) (mix_device_t *, mix_word_t *); -typedef gboolean (*mix_dev_ioc_func_t) (mix_device_t *, mix_short_t); +typedef gboolean (*mix_dev_ioc_func_t) (mix_device_t *, mix_short_t, mix_word_t); typedef gboolean (*mix_dev_busy_func_t) (const mix_device_t *); typedef void (*mix_dev_destroy_t) (mix_device_t *); diff --git a/mixlib/xmix_vm.c b/mixlib/xmix_vm.c index 68a8106..1b8d80a 100644 --- a/mixlib/xmix_vm.c +++ b/mixlib/xmix_vm.c @@ -303,6 +303,7 @@ ioc_handler_ (mix_vm_t *vm, const mix_ins_t *ins) { mix_address_t addr; mix_device_t *dev; + mix_word_t val; g_assert (ins->opcode == mix_opIOC); @@ -312,7 +313,8 @@ ioc_handler_ (mix_vm_t *vm, const mix_ins_t *ins) dev = get_dev_ (vm, ins->fspec); fail_if_not_ (vm, dev != NULL, MIX_VM_ERROR_BAD_DEVICE_NO); - fail_if_not_ (vm, mix_device_ioc (dev, addr), MIX_VM_ERROR_DEV_CTL); + val = get_rX_ (vm); + fail_if_not_ (vm, mix_device_ioc (dev, addr, val), MIX_VM_ERROR_DEV_CTL); inc_loc_ (vm); return TRUE; |