Jump to content
  • entries
    657
  • comments
    2,692
  • views
    897,849

3 fireballs


SpiceWare

2,206 views

I now have the 3 fireballs bouncing around most of the playfield. I haven't rewritten the lower castle routines so the fireballs disappear while they traverse the lower 1/4th of the screen.

 

blog-3056-1142917210_thumb.png

 

I also made the left castles have a checkerboard pattern to make sure my updates to PF0 and PF1 are happening when they should. As you can tell by the purple castle, the original code wasn't quite up to spec :lolblue:

 

There's also a few things odd with the fireballs

  • X position 0 thru 4* are showing on the right side of the screen
    I can use X values 5-164* to compensate, so it's not a major problem
  • There's a weird "hiccup" as the fireballs cross over pixel 8* from the left edge of the screen
    I'm using the positioning routine that Robert Mundschau posted to the Stella List a couple years back. I'll have to try another routine and compare the results. Another routine might fix X range as well.
  • The fireballs are smaller than the one in Warlords
    I'm using a 2LK along with the PHP trick as mentioned here at the MiniDig, so the ball/missiles span 2 scan lines. In Warlords the ball moves in 2 scan line increments, but is displayed over 4 scan lines. I doubt there's time to change it for all 3 fireballs so they'll be staying at 2 scan lines.

* may not be exact pixels

 

Anyhow it's time for bed. Here's the source and BIN if you care to take a look Medieval_Mayhem_2006_03_20.zip

11 Comments


Recommended Comments

To make the ball span four scan lines, you can use a 4LK (unroll the 2LK an one iteration) and use two Y values for each projectle (one Y value will control the appearance on even-numbered line-pairs and the other will control it on odd-numbered line-pairs).

Link to comment

Use this positioning routine:

   sec
  sta WSYNC
DivideLoop
  sbc #15
  bcs DivideLoop ;+4	4

  eor #7
  asl
  asl
  asl
  asl			;+10  14

  sta.wx HMP0,X  ;+5   19
  sta RESP0,X	;+4   23

  sta WSYNC
  sta HMOVE

With X indexing into which sprite to position and A holding the position (0-159 for players, adjust slightly for ball and missiles).

 

Advantages of this:

1. It always takes the exact same amount of time. For all horizontal positions < 165 it will take exactly 1 scanline plus 3 cycles (for the HMOVE).

2. It positions correctly for positions 0-164 (with 160-164 equivalent to 0-4). I.e., no hiccups.

 

This can also be modified to use a table instead of the eor/asl stuff, like this:

   sta WSYNC
  nop
  sec
DivideLoop
  sbc #15
  bcs DivideLoop ;+4	8

  tay			;+2   10
  lda HMOVETable,Y;+5   15

  sta HMP0,X	 ;+4   19
  sta RESP0,X	;+4   23

  sta WSYNC
  sta HMOVE

 

Just went back to [stella] and read the post you linked to - the real key here is that the RESxx write must end at cycle 23 for this to work smoothly, not at cycle 21.

Link to comment

The kernel change is not a problem. If I understand the even-odd setup, I'd do the following after calculating the ball's current X-Y values:

	lda BallYhigh
sta BallYeven
sta BallYodd
and #1; test even-odd
beq .decOdd; even so dec the odd row
dec BallYeven
.byte $2c; BIT command to skip over dec BallYeven
.decOdd
dec BallYodd

 

Slick, even at the price of 6 bytes of RAM.

Link to comment

I dropped in the new positioning routine and it works great, thanx! :thumbsup:

 

I took the HMOVE out as I was set up to position all the objects and then do a single HMOVE. Before I removed the HMOVE the fireballs where jumping around like crazy 8)

 

For the ball & missiles I just add 1 before calling the subroutine and they line up perfectly. I'm leaving the fireball's X values as 0-158 (not 159 as it's double wide) as it needs to start with 0 for the collision calculation to figure out which brick to remove when a castle is hit.

 

Now to try supercat's even-odd row suggestion for the fireballs.

Link to comment
even-odd fireball routines are slick!

 

Works nicely, doesn't it? Unrolling the kernel to four lines will also help with reading the paddles since you only have to do a "hard" paddle read once every four lines and can do "easy" reads on the rest.

Link to comment

What do you mean by Hard vs Easy paddle reads? I don't think I've heard those terms used before.

 

I wrote a blog entry about reading all four paddles at once. The basic trick is to combine all four paddle inputs into a byte; if Y contains something between 64 and 127, this may be accomplished via:

 cpy inpt0
 ror
 cpy inpt1
 ror
 cpy inpt2
 ror
 cpy inpt3
 ror
 eor paddlebits*
 sta paddlebits*

 

On half the scan lines, you EOR this value with a variable paddlebits0. On half of the remaining scan lines, you EOR with paddlebits1. On half the remaining scan lines, you can use paddlebits2, etc. or, if you like, you can use the 'conventional' read method to get higher-order bits. I'll assume you use my method for the two LSB's and a normal approach for the other five bits (putting the results in paddle0-paddle3).

 

Once the frame is over, you need to munge the paddle and paddlebits values a little. Something like:

 lsr paddle0
 ror
 lsr paddle1
 ror
 lsr paddle2
 ror
 lsr paddle3
 ror
 sta paddlebits2
 eor paddlebits1
; May need EOR #$F0
 sta paddlebits1
 eor paddlebits0
; May need EOR #$F0
 sta paddlebits0
 lda paddlebits2
 asl
 rol paddle3
 asl
 rol paddle2
 asl
 rol paddle1
 asl
 rol paddle0
 lda paddlebits1
 asl
 rol paddle3
 asl
 rol paddle2
 asl
 rol paddle1
 asl
 rol paddle0
 lda paddlebits0
 asl
 rol paddle3
 asl
 rol paddle2
 asl
 rol paddle1
 asl
 rol paddle0

The 'optional' EOR #$F0 instructions may or may not be needed, depending upon how many loop iterations you run.

 

Using the conventional paddle reading method:

 lda inpt0
 bmi yep
 byte $2C
yep:
 sty paddle0

Will take nine cycles per paddle, or 36 cycles to read all four. The "easy scan lines" approach takes five cycles per paddle, plus six, so 26 cycles to read all four. A savings of ten cycles on three scan lines out of every four.

Link to comment

I had read your blog entry on reading 4 paddles at once and plan to try it out once I update the lower 1/4th of the screen.

Link to comment
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...