Jump to content
  • entries
    658
  • comments
    2,707
  • views
    906,892

Uho - game's resetting


I was playing a round after splitting the menu into 2 ROM banks to make room for extra graphics and the game reset to the main menu with all the options initialized to the power-up values. It doesn't happen all the time. I just check the version from 10-14 and it did the same thing. Anybody notice this on a version prior to 10-14?

 

The IRQ vector points to the same place the RESET vector does, so I suspect a BRK is being hit. I haven't coded a BRK, so this would imply data is being treated like program code. I checked the compile results for a branch-out-of-range and there isn't one.

 

I've added a RTI and changed the IRQ vector to point to it and have told Stella to trap if it hits the RTI. Hasn't happened yet.

6 Comments


Recommended Comments

I figured out what's causing it, just need to figure out where.

 

Using Stella I trapped PC == InitSystem which is $f000. First thing InitSystem does is switch banks then call the init code. As I suspected, B is set so it is a BRK that is triggering the reset.

 

In examining the screen I see the trophy is still on-screen, but faded so it's from the prior frame. The DeadPlayers variable has already been reset, so for the current frame next-round has started and all players are now back in the game. The break happened on scan line 72, which is when the top-castle is being drawn; however, Stella is showing the overscan bank as the current bank. I noticed the shield for player 1 is onscreen, but with scrambled graphics. I then checked the graphic pointer and see it is set to $FFAD - it should only ever be between $ff40 and $ff80.

 

Based on that, a read of the graphics for shield one hit a bank-switch hot-spot and triggered a bank switch.

I tracked down the bug - it was related to the new AI speed adjustment routine and a shared RAM spot that holds $FE when the score is displayed and a FireBallCount at other times. In the very first frame of rounds 2+ the FireBallCount would hold $FE - causing a subtraction instead of addition when setting up the pointers to the MaxMove table. This resulted in the table pointing to commands instead of data.

 

Occasionally the value returned would cause the Y value to be adjusted to a value that would cause the bank switch hot-spot to be triggered. If the problem didn't occur on the first frame then it wouldn't occur for the current round as the FireBallCount is recalced at the end of Overscan.

 

The fix was to init FireBallCount to 0 when initializing a new round.

The following table controls how fast each AI player moves. P1 = top-left, P2 = bottom-right, P3 = top-right and P4 = bottom left.

 

;						  N T S C					  --------SPEED---------
;			 -------X-------  -------Y-------   X  Y	0   1   2   3   4   5
	.byte 2,1,1,1,2,1,1,1, 1,1,1,1,1,1,1,1; 10  8   P1
	.byte 2,1,1,2,1,1,2,1, 2,1,1,1,1,1,1,1; 11  9   P2  P1
	.byte 1,2,1,2,1,2,1,2, 2,1,1,1,2,1,1,1; 12 10   P3  P2  P1
	.byte 1,2,2,2,1,2,2,2, 2,1,2,1,2,1,2,1; 14 12   P4  P3  P2  P1
	.byte 3,2,2,2,2,2,2,2, 1,2,2,2,1,2,2,2; 17 14	   P4  P3  P2  P1
	.byte 3,2,2,3,2,2,3,2, 2,2,2,2,2,2,2,2; 19 16		   P4  P3  P2  P1
	.byte 2,3,3,3,2,3,3,3, 3,2,2,2,3,2,2,2; 22 18			   P4  P3  P2
	.byte 3,3,3,3,3,3,3,3, 3,2,3,2,3,2,3,2; 24 20				   P4  P3
	.byte 4,3,3,3,4,3,3,3, 2,3,3,3,2,3,3,3; 26 22					   P4

 

The speed is calculated as follows:

Speed = Game Speec(1-4) - 1 + FireballCount - 1 (Note: the second -1 only occurs if the fireball count <> 0).

 

The resulting value of speed sets which row(first row is row 0) of the table is used for P1, with the following 3 rows used for players 2 thru 4.

 

This makes playing top-left the hardest and bottom-left the easiest. I'm thinking about changing the order the table is read which would reverse this.

 

 

The bug was occuring because the FireballCount held $FE, which is equivalent to -2 when doing 8 bit math. I was playing a game at speed 3 so the resulting speed was -1 (3-1-2-1) which made P1's data point to the program code in front of the table. The problem would have been more pronounced if I'd been testing at speed 1 or 2 as

It sounds like the game is almost finished now - are you planning to add any more features (apart from the one we discussed), or is it essentially done now?

 

Chris

 

My current to-do list (in no order)

1) bug fix - if AI player catchs the lone fireball(ie: only 1 on screen) at the edge of the screen, they freeze in place instead of moving back and forth.

2) update AI move tables (make AI players slower for the kids level, reverse the speeds so P1 is fastest, not P4)

3) easter egg

4) 27 frame dragon animation(waiting on graphics from espire8)

5) update trophies (graphics and smoothly scroll on-off screen)

6) what we discussed.

 

If possible, I'd also like to add music to the menu and when the trophies for round and game are on screen. I haven't yet researched what to play or how to play it and will drop it if I run out of time.

Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...