From 330b3fc10da27fd56e479d535840dd21bf921a0b Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Thu, 1 Jul 2021 17:53:30 +0200 Subject: [PATCH] :art: use next_bbq_pos --- include/vm.h | 5 +++++ plug | 2 +- src/vm/driver.c | 2 +- src/vm/vm.c | 11 +++++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/include/vm.h b/include/vm.h index 9922c002..471f4822 100644 --- a/include/vm.h +++ b/include/vm.h @@ -136,4 +136,9 @@ ANN m_str code_name(const m_str, const bool); ANN uint32_t gw_rand(uint32_t s[2]); ANN void gw_seed(uint32_t s[2], const uint64_t); ANN void handle(VM_Shred shred, const m_str effect); + + +#define BBQ_POS_MAX 16777216 + +void next_bbq_pos(const VM *vm); #endif diff --git a/plug b/plug index a982b436..54905315 160000 --- a/plug +++ b/plug @@ -1 +1 @@ -Subproject commit a982b4368dc4a90c46c7e20aecbf6a2c69cd7839 +Subproject commit 549053153c3de75b8e1c0bc46842abc149891575 diff --git a/src/vm/driver.c b/src/vm/driver.c index d6f289f5..d229dd5b 100644 --- a/src/vm/driver.c +++ b/src/vm/driver.c @@ -31,7 +31,7 @@ ANN void driver_alloc(Driver *d) { static DRVRUN(dummy_run) { while (di->is_running) { di->run(vm); - ++di->pos; + next_bbq_pos(vm); } } diff --git a/src/vm/vm.c b/src/vm/vm.c index 040f7062..7ec9cbac 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -1202,6 +1202,17 @@ vm_run(const VM *vm) { // lgtm [cpp/use-of-goto] } } +static inline next_bbq_pos(const VM *vm) { + Driver *const di = vm->bbq; + if(++di->pos == 16777216-1) { + for(m_uint i = 0; i < vector_size(&vm->shreduler->shreds); i++) { + const VM_Shred shred = (VM_Shred)vector_at(&vm->shreduler->shreds, i); + shred->tick->wake_time -= 16777216.0; + } + di->pos = 0; + } +} + static void vm_run_audio(const VM *vm) { vm_run(vm); vm_ugen_init(vm); -- 2.43.0