Since there can be more than one bullet at a time, we need to store it in an array. Arrays are basically lists of elements with a similar structure; see our guide to arrays for more information.
But before we make the subroutines, we need to decide what the array's going to look like. An array is just a list of elements, so we need to figure out the most efficient format we can use to store a bullet. What information do we need about a bullet?
So that's it. Four bytes per element. We can store the bullets in L4
, which gives us 256 bytes of memory (64 elements of our array) to work with. Like with all arrays, we need to first set a variable up to store the number of elements. It should be initialized in the init code:
Now you can add the bullet-adding subroutine to prgmASHMUPR
:
Again, see http://clrhome.org/tutorials/arrays/02/ for a full-length explanation on how this works.