From 248f59c6c3933498d97f9175c788a535d2940d29 Mon Sep 17 00:00:00 2001 From: sfja Date: Sun, 22 Nov 2026 01:36:51 +0100 Subject: [PATCH] builtin scroll --- common/arch.vc6asm | 7 +++++-- kernel/vcd_print.vc6asm | 6 ++---- readme.txt | 6 ++++++ src/emu.c | 32 ++++++++++++++++++++++---------- 4 files changed, 35 insertions(+), 16 deletions(-) diff --git a/common/arch.vc6asm b/common/arch.vc6asm index 72d351a..fd6f4d9 100644 --- a/common/arch.vc6asm +++ b/common/arch.vc6asm @@ -13,14 +13,17 @@ @const KBD_KEYDOWN_HANDLER 0xff12 @const KBD_KEYUP_HANDLER 0xff13 +@const VCD_CTL 0xff30 @const VCD_BEGIN 0xfb00 +@const VCD_CTL_SCROLL 1 << 1 + @const DISK_STATUS 0xff20 @const DISK_CTL 0xff21 @const DISK_BLOCK_ID 0xff22 @const DISK_ADDR 0xff23 -@const DISK_CTL_DIRECTION 1 << 0 -@const DISK_CTL_START 1 << 1 +@const DISK_CTL_DIRECTION 1 << 0 +@const DISK_CTL_START 1 << 1 @end diff --git a/kernel/vcd_print.vc6asm b/kernel/vcd_print.vc6asm index 4335507..fcfaf6f 100644 --- a/kernel/vcd_print.vc6asm +++ b/kernel/vcd_print.vc6asm @@ -36,10 +36,8 @@ putc: ret .scroll: - mov r1, VCD_BEGIN - mov r2, VCD_BEGIN + vcd_width - mov r3, vcd_width * (vcd_height - 1) - call memmove + mov r1, VCD_CTL_SCROLL + mov [VCD_CTL], r1 mov r1, VCD_BEGIN + vcd_width * (vcd_height - 1) mov r2, 0 diff --git a/readme.txt b/readme.txt index 837bf77..4c23d47 100644 --- a/readme.txt +++ b/readme.txt @@ -107,4 +107,10 @@ character buffer starts at fb00 character = fb00 + (y * 40 + x) +ff30 ctl + +## ctl + +0 reserved +1 scroll diff --git a/src/emu.c b/src/emu.c index 46fa01d..f9f8f1f 100644 --- a/src/emu.c +++ b/src/emu.c @@ -111,10 +111,10 @@ static uint16_t vm_arith(Opcode ty, uint16_t l, uint16_t r) } } -static void vm_disk_control(VM *vm, VMState *s, uint16_t control) +static void vm_disk_ctl(VM *vm, VMState *s, uint16_t ctl) { - bool is_write = control & 1; - bool start = control >> 1 & 1; + bool is_write = ctl & 1; + bool start = ctl >> 1 & 1; if (!start) return; @@ -130,6 +130,20 @@ static void vm_disk_control(VM *vm, VMState *s, uint16_t control) } } +static void vm_vcd_ctl(VM *vm, VMState *s, uint16_t ctl) +{ + (void)vm; + + bool scroll = ctl >> 1 & 1; + + if (scroll) { + memmove(&s->memory[0xfb00], + &s->memory[0xfb00 + 40 * 1], + sizeof(uint16_t) * 40 * 24); + vm->vcd_updated = true; + } +} + static void vm_run_op(VM *vm, VMState *s, const Op *op) { uint16_t *fl = &s->regs[Reg_Fl]; @@ -160,12 +174,11 @@ static void vm_run_op(VM *vm, VMState *s, const Op *op) case Op_Store: { uint16_t addr = op2_reg_or_imm(s, op); - if (addr == 0xff21) { - vm_disk_control(vm, s, s->regs[op->op1_reg]); - break; - } - - if (addr >= 0xfb00 && addr <= 0xfb00 + 40 * 25) + if (addr == 0xff21) + vm_disk_ctl(vm, s, s->regs[op->op1_reg]); + else if (addr == 0xff30) + vm_vcd_ctl(vm, s, s->regs[op->op1_reg]); + else if (addr >= 0xfb00 && addr <= 0xfb00 + 40 * 25) vm->vcd_updated = true; s->memory[addr] = s->regs[op->op1_reg]; @@ -295,7 +308,6 @@ void vm_run(VM *vm) vm->state = s; mtx_unlock(&vm->mtx); - thrd_sleep(&(struct timespec) { .tv_nsec = 100000 }, NULL); } }