From c7c752cd7339785f155175e041b62ca6a8e0db4a Mon Sep 17 00:00:00 2001 From: Veikko Sariola Date: Mon, 2 Nov 2020 22:52:48 +0200 Subject: [PATCH] Change the stack rewind in the end of render to be slightly less fragile, anticipating putting more stuff in the stack. Specifically, we will soon put the su_sample_offsets and su_delay_times table addresses to stack in the render_samples, to avoid hard coding them in the api call. --- include/sointu/footer.inc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/sointu/footer.inc b/include/sointu/footer.inc index 8593720..c2f9561 100644 --- a/include/sointu/footer.inc +++ b/include/sointu/footer.inc @@ -379,11 +379,13 @@ su_render_sampleloop: ; loop through every sample in the row inc eax cmp eax, TOTAL_ROWS jl su_render_rowloop -%ifdef INCLUDE_MULTIVOICE_TRACKS + ; rewind the stack. Use add when there's a lot to clean, repeated pops if only a little +%if su_stack.render_epilogue - su_stack.tick > 3*PTRSIZE add _SP, su_stack.render_epilogue - su_stack.tick ; rewind the remaining tack %else - pop _AX - pop _AX + %rep (su_stack.render_epilogue - su_stack.tick)/PTRSIZE + pop _AX ; the entropy of 3 x pop _AX is probably lower than 3 byte add + %endrep ; but this needs to be confirmed %endif render_epilogue