builtin scroll
This commit is contained in:
parent
b5d8ad7559
commit
248f59c6c3
@ -13,14 +13,17 @@
|
|||||||
@const KBD_KEYDOWN_HANDLER 0xff12
|
@const KBD_KEYDOWN_HANDLER 0xff12
|
||||||
@const KBD_KEYUP_HANDLER 0xff13
|
@const KBD_KEYUP_HANDLER 0xff13
|
||||||
|
|
||||||
|
@const VCD_CTL 0xff30
|
||||||
@const VCD_BEGIN 0xfb00
|
@const VCD_BEGIN 0xfb00
|
||||||
|
|
||||||
|
@const VCD_CTL_SCROLL 1 << 1
|
||||||
|
|
||||||
@const DISK_STATUS 0xff20
|
@const DISK_STATUS 0xff20
|
||||||
@const DISK_CTL 0xff21
|
@const DISK_CTL 0xff21
|
||||||
@const DISK_BLOCK_ID 0xff22
|
@const DISK_BLOCK_ID 0xff22
|
||||||
@const DISK_ADDR 0xff23
|
@const DISK_ADDR 0xff23
|
||||||
|
|
||||||
@const DISK_CTL_DIRECTION 1 << 0
|
@const DISK_CTL_DIRECTION 1 << 0
|
||||||
@const DISK_CTL_START 1 << 1
|
@const DISK_CTL_START 1 << 1
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@ -36,10 +36,8 @@ putc:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.scroll:
|
.scroll:
|
||||||
mov r1, VCD_BEGIN
|
mov r1, VCD_CTL_SCROLL
|
||||||
mov r2, VCD_BEGIN + vcd_width
|
mov [VCD_CTL], r1
|
||||||
mov r3, vcd_width * (vcd_height - 1)
|
|
||||||
call memmove
|
|
||||||
|
|
||||||
mov r1, VCD_BEGIN + vcd_width * (vcd_height - 1)
|
mov r1, VCD_BEGIN + vcd_width * (vcd_height - 1)
|
||||||
mov r2, 0
|
mov r2, 0
|
||||||
|
|||||||
@ -107,4 +107,10 @@ character buffer starts at fb00
|
|||||||
|
|
||||||
character = fb00 + (y * 40 + x)
|
character = fb00 + (y * 40 + x)
|
||||||
|
|
||||||
|
ff30 ctl
|
||||||
|
|
||||||
|
## ctl
|
||||||
|
|
||||||
|
0 reserved
|
||||||
|
1 scroll
|
||||||
|
|
||||||
|
|||||||
32
src/emu.c
32
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 is_write = ctl & 1;
|
||||||
bool start = control >> 1 & 1;
|
bool start = ctl >> 1 & 1;
|
||||||
|
|
||||||
if (!start)
|
if (!start)
|
||||||
return;
|
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)
|
static void vm_run_op(VM *vm, VMState *s, const Op *op)
|
||||||
{
|
{
|
||||||
uint16_t *fl = &s->regs[Reg_Fl];
|
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: {
|
case Op_Store: {
|
||||||
uint16_t addr = op2_reg_or_imm(s, op);
|
uint16_t addr = op2_reg_or_imm(s, op);
|
||||||
|
|
||||||
if (addr == 0xff21) {
|
if (addr == 0xff21)
|
||||||
vm_disk_control(vm, s, s->regs[op->op1_reg]);
|
vm_disk_ctl(vm, s, s->regs[op->op1_reg]);
|
||||||
break;
|
else if (addr == 0xff30)
|
||||||
}
|
vm_vcd_ctl(vm, s, s->regs[op->op1_reg]);
|
||||||
|
else if (addr >= 0xfb00 && addr <= 0xfb00 + 40 * 25)
|
||||||
if (addr >= 0xfb00 && addr <= 0xfb00 + 40 * 25)
|
|
||||||
vm->vcd_updated = true;
|
vm->vcd_updated = true;
|
||||||
|
|
||||||
s->memory[addr] = s->regs[op->op1_reg];
|
s->memory[addr] = s->regs[op->op1_reg];
|
||||||
@ -295,7 +308,6 @@ void vm_run(VM *vm)
|
|||||||
|
|
||||||
vm->state = s;
|
vm->state = s;
|
||||||
mtx_unlock(&vm->mtx);
|
mtx_unlock(&vm->mtx);
|
||||||
thrd_sleep(&(struct timespec) { .tv_nsec = 100000 }, NULL);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user