68k Idioms
Some things you’ll frequently find in 68k code in Gauntlet:
link a6, #NN
This sets up a new stack frame, with any appropriate local variables. If NN=0, there are no local variables, otherwise the NN specifies how many bytes to allocate on the stack for the desired local variables.
movem.l d2-d6/a2-a3, -(sp)
[…]
movem.l NN(a6), d2-d6/a2-a3
Save the listed registers onto the stack. In standard 68k calling conventions, a subroutine can use d0-d1 and a0-a1 for its own needs, and must save/restore any other registers. NN is the offset into the stack to use for restoring variables at the end of the subroutine.
add d0,d0
Most frequently used to convert from an array index to the memory offset used by that index, for word-sized array elements. e.g.:
movea.l #v_arrMobPosH, a0
add d0,d0
move.w (a0, d0.w), a1
Takes a mob id (in d0), turns it into an offset, and retrieves the horizontal position of that mobid from video RAM
move.b someVariable+1, d0
Copies into d0 the low byte of the word-sized variable at someVariable