RE: [stella] JoustPong: more exciting than ever!

Subject: RE: [stella] JoustPong: more exciting than ever!
From: Paul Slocum <paul-stella@xxxxxxxxxxxxxx>
Date: Tue, 24 Feb 2004 23:43:33 -0600

he's doing some stuff I don't understand with stack restoration
and what not

You probably don't need to save and restore it since I don't think you're actually using the stack anywhere. I copied an explanation of the PHP trick below. The trick requires you to change the stack pointer, so you have to save and restore it if you're using it elsewhere. (One of these days I need to finish that tips and tricks guide I was working on.)


 but I can't for the life of me figure out what's
moving the shared P0 graphic between the title kernal and
the game itself...

You're changing the NUSIZ0 register. It needs to be on 2 for the left player to appear in the correct place.


BTW: I think you need to set the carry flag before each skipDraw. I left that out just to save a few cycles and get the kernal running.


============================================================== SHOWING MISSILES USING PHP ==============================================================

This trick is originally from Combat and is probably the most efficient way to display the missiles and/or ball. This trick just requires that you don't use the stack during your kernal. Recall that:

  ENABL = $1F
  ENAM1 = $1E
  ENAM0 = $1D

In this example I'll show how to use the trick for both missiles. You can easily adapt it for the ball too. To set the trick up, before your kernal save the stack pointer and set the top of the stack to ENAM1+1.

  tsx                    ; Transfer stack pointer to X
  stx SavedStackPointer  ; Store it in RAM
  ldx #ENAM1+1
  txs                    ; Set the top of the stack to ENAM1+1

Now during the kernal you can compare your scanline counter to your missile position register and this will set the zero flag in the processor. Then to enable/disable the missile for that scanline, just push the processor flags onto the stack. The ENAxx registers use bit 1 to enable/disable which corresponds with the zero flag in the processor, so the enable/disable will be automatic. It takes few cycles and doesn't vary the number of cycles depending on the result like branching usually does.

  ; On each line of your the kernal...
  cpy MissilePos1        ; Assumes Y is your kernal line counter
  php
  cpy MissilePos0
  php

Then before you do it again, somewhere on each scanline you need to pull off the stack again using two PLA's or PLP's, or you can manually reset the stack pointer with ldx #ENAM1+1, txs.

After your kernal, restore the stack pointer:

  ldx SavedStackPointer
  txs


---------------------------------------------------------------------------------------------- Archives (includes files) at http://www.biglist.com/lists/stella/archives/ Unsub & more at http://www.biglist.com/lists/stella/


Current Thread