There's so many variations of each station (pods intact/destroyed, various state of center) that it's not practical to have each version in ROM. Instead, an intact image is in ROM for each orientation. Once per frame a RAM copy of the image would be made for each station, then it would be manipulated to remove destroyed pods and update the center. The RAM images are used for collision detection as well as display purposes.
While reviewing the code I realized that the open/close logic for the center only updated 1 station per frame. So only that station's RAM image would need to be updated, as well as any stations the player destroyed a pod on in the current frame. For all other stations, the RAM image was already correct.
So I added a render flag that gets set whenever a station's image needs to be updated. I figured it would save some time, but had no idea how much, so I started a round of Alpha Sector 3 on Kids level so that all 8 stations were always open (and thus nothing would need to be rendered). Using the original routine, time remaining in OverScan at the start of the game was $13 (19 decimal):
I then made the changes to implement the render flag and ran A-3 Kids again:
Time remaining in OverScan increased to $21 (33 decimal) (the Vertical Blank time changed from 16 to 15 due to having to draw an extra asteroid)
So not having to update any of the stations freed up (33-19)*64/76 = 11.8 scanlines worth of processing time, so on frames that a station changed we'd use 1.5 scanlines per station. Worse case scenerio would be somehow the player hit 4 pods on the exact same frame, highly unlikely, so I suspect that the typical max number of stations to update will be 2.
Besides that, the continue option now resets the various timers.
For Harmony or Stella (requires Stella 5.0.2 or newer)
- Carpenter likes this