Jump to content
IGNORED

Re-visiting Defender...


PacManPlus

Recommended Posts

17 minutes ago, PacManPlus said:

Is there a faster routine to clear memory?

I'm no assembly expert, but I think you can spend 2 cycles to save 160 by counting down instead of up and dropping the comparison.

 

;	CLEAR_SCANNER - BLANK OUT ENTIRE SCANNER
CLEAR_SCANNER
	LDX #SCANBUFLINESIZE * 4
	LDA #$00
CLR_SCANNER_LOOP
	STA SCN_ZONE1_LINE1+$00-1,X
	STA SCN_ZONE1_LINE2+$00-1,X
	STA SCN_ZONE1_LINE3+$00-1,X
	STA SCN_ZONE1_LINE4+$00-1,X
	STA SCN_ZONE1_LINE5+$00-1,X
	STA SCN_ZONE1_LINE6+$00-1,X
	STA SCN_ZONE1_LINE7+$00-1,X
	STA SCN_ZONE1_LINE8+$00-1,X
	DEX 
	BNE CLR_SCANNER_LOOP
	RTS

 

(@Eagle, snap)

  • Like 2
Link to comment
Share on other sites

Yeah, don't think you'll do better than Eagle's and SmittyB's countdown suggestion, without unrolling. (which would be ridiculous)

 

If you're not already, you can run the radar clear+build during the visible screen, after the radar itself is displayed. You could also get away with splitting the radar clear+update into strips, and update each strip on different frames. At the coarse resolution of the radar, even 1 zone per frame would likely work.

  • Like 2
Link to comment
Share on other sites

Hey Guys

 

Thanks for the ideas (again) ;)  So, I'd put this one at the most difficult port than any game I've done so far, except for Baby Pac-Man:

2 hours ago, RevEng said:

Yeah, don't think you'll do better than Eagle's and SmittyB's countdown suggestion, without unrolling. (which would be ridiculous)

 

If you're not already, you can run the radar clear+build during the visible screen, after the radar itself is displayed. You could also get away with splitting the radar clear+update into strips, and update each strip on different frames. At the coarse resolution of the radar, even 1 zone per frame would likely work.

I like the idea of clearing it during the visible screen, as I have a DLI right after it (to change resolutions).  Thank you for that!

 

I'm also planning on doing the count down...  Now I know why GCC used that so much. 

I always like counting upward...  my OCD insists on it :P But this is more important.

 

2 hours ago, Eagle said:

Try using Eor and after Eor again to clear. Maybe will be faster than clear all memory.

I actually tried than when I did my first attempt at Defender.  I ended up undoing it, although I forget why...  Something about I didn't like the way it worked.  Thank you though!

 

2 hours ago, Eagle said:

Also make sure that BMI is not crossing page boundary.  
In Mads assembly i use .Align 256

Yep that one's good, thank you :)

  • Like 4
Link to comment
Share on other sites

8 hours ago, RevEng said:

without unrolling. (which would be ridiculous)

 

 

Actually is not bad idea

 

ldx #$0f         ;SCANBUFLINESIZE-1

lda #$00

loop

sta $1800,x

sta $1810,x

sta $1820,x

sta $1830,x

sta $1900,x

sta $1910,x

.....

.....

dex

bpl loop

 

This will save 240 cycles :) and cost only 72 bytes 

 

 

 

  • Like 5
Link to comment
Share on other sites

33 minutes ago, Cafeman said:

I really enjoy reading these posts which share methods to save cycles.  One question though, what is meant by the term unrolling?

Since loops take cycles themselves to execute, sometimes instead of looping for X number of iterations, you code that block of code X number of times in a row, removing the loop, or "unrolling" it. Obviously this takes up more space, depending on the number of instructions in the loop and the number of iterations, and is often not practical as an optimization solution ... but when you need it, you need it.

  • Like 5
Link to comment
Share on other sites

Well, I've used the unrolling technique then, and I understand exactly why you'd use the method. I remember  being instructed about the decrementing loop too for optimization reasons, else I'd have likely started off incrementing with an extra compare. I've always admired the elegant design of 6502 ASM, how you can utilize commands that will set a flag and save you an instruction, for example. 

  • Like 3
Link to comment
Share on other sites

  • 2 weeks later...

Hmm...  I have an idea.  Once I get back home From Chipley (FL) I'll be back into this.

 

There's at most 42 objects in the list that needs to go through per frame.  There should be enough CPU time to do this.  I'll have a look through the 'hot spot' utility again to see where I'm using all of my cycles.

 

Also, I was looking at some frame-by-frame movements of the enemies, and they all seem to move every frame (so no splitting duties between frames) :(

The only other thing possible is maybe the routine that *alters* movement is done on certain frames (i.e. they currently move left every frame but every 4th frame they decide if that direction should be altered).

 

I did find the source code on line, but nothing is commented. :(

I wish I could talk to Eugene Jarvis, like I did with some of the other games I've done.  Just to get a general idea of how things were done on the Arcade hardware.

 

  • Like 11
Link to comment
Share on other sites

2 hours ago, PacManPlus said:

Also, I was looking at some frame-by-frame movements of the enemies, and they all seem to move every frame (so no splitting duties between frames) :(

Maybe it would be possible to have them do double the movement on alternate frames instead? The difference might not be noticeable at all.

  • Like 3
Link to comment
Share on other sites

30 minutes ago, Karl G said:

Maybe it would be possible to have them do double the movement on alternate frames instead? The difference might not be noticeable at all.

For sure, or perhaps off-screen enemies can have less-frequent more-coarse updates.

 

But I think here we're seeing PMP just striving to make it arcade accurate, rather than hitting an actual implementation issue. :)

  • Like 5
Link to comment
Share on other sites

16 hours ago, PacManPlus said:

 

I did find the source code on line, but nothing is commented. :(

I wish I could talk to Eugene Jarvis, like I did with some of the other games I've done.  Just to get a general idea of how things were done on the Arcade hardware.

 

Let me see if I can drum up his contact info.  I used to have it.

  • Like 1
Link to comment
Share on other sites

On 12/31/2021 at 7:48 AM, PacManPlus said:

I did find the source code on line, but nothing is commented. :(

Ahem...

https://github.com/mwenge/defender/tree/master/src

 

So are you planning on replicating the original's monophonic sound? Going monophonic might allow richer sound effects by using both TIA channels to construct each sound.

  • Like 1
Link to comment
Share on other sites

7 minutes ago, RevEng said:

Speaking of Defender sound, I'll just leave this here...

 

http://www.dl.unospace.net/defender_sound/

Holy crap. I was wearing headphones when I listened to those - instant nostalgia! Right back to 1980-something and playing a real Defender cab as a teenager. ?

  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   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...