MxAshlynn

coder, producer, music fan, teagirl


my building-gamer blog
cohost.org/MxBuilder
my yurivania shrine
midnightpalace.gay/

posts from @MxAshlynn tagged #retro dev

also:

Here's my implementation of the Fisher-Yates/Knuth shuffling algorithm in GB Studio 4.x

Note that the deck consists of 20 cards, stored in the global variable heap from index 4 to 24.

I coded the swap in GBVM because the visual scripting does not yet have array operations. Here I use the RPN calculator to pop and push the values pointed to by i and j onto/off of the VM's stack.

This is the same algorithm in pseudo-C:

for (byte i = high_index; i > low_index; i--)
{
    j = random(from low_index to i);
    push(array[i]);
    push(array[j]);
    array[i] = pop();
    array[j] = pop();
}

I'm new to GBS 4, so any feedback is welcome!