Jump to content







Photo

Revisiting Juno First

Posted by Nathan Strum, 05 October 2007 · 195 views

Game Sprites
So, I was looking through my folder full of WIP homebrews, and came upon Juno First. When last seen, Chris had put together a nice looking title screen:
Posted Image

But as was mentioned in the comments, it would have been nice to make the scores a single color, instead of multicolored:
Posted Image

So I was wondering if this would work... (I think this is what Bob mentioned in the comments, but I'm not sure):

First, you have the title and some of the text, made up of sprites, as before:
Posted Image

But then, the scores and aliens are actually created by making a large bitmap out of the sprites, that's a negative image, in black:
Posted Image

Below that, is the tricky part that I'm not sure about. It would involve changing the playfield color on a line by line basis, to put color behind where the alien ships go. Then, putting something solid behind where the score goes. What I'm not sure of, is if you can change the playfield color to do that, or if you can somehow make a large, single-color missile or ball for that (seems to me you can't, since their colors are defined by the player sprites and playfield, if memory serves).
Posted Image

Below that, of course, would be a black background:
Posted Image

I'm also wondering if there would be a way to do this using flicker... since the entire logo is going to be flickering anyway (as are pretty-much all the sprites in the game). Maybe display the multicolored playfield one frame, then the solid one the next.

Anyway... just wondering. :) Still hoping to see Chris be able to finish this someday.




Using the playfield colors for the score works. Actually I did that in Jammed.

You use inverted sprites for that so that the playfield colors definies becomes visible. It saves on write (3 cycles) to a TIA register.

But here the situation is different. We would have to change the color twice, once midscreen. So we need an additional load and store for switching to white. That's 5 extra cylces. I am not sure if it is possible to gain that many cylces in the already pretty tight 48 pixel routine.

Though, the two dots might help here. Only one load instead of two, saving 5 cylces. I'll have a look at it tonight.

BTW: There are only four color registers:
- background
- PF and ball
- P0 and M0
- P1 and M1
  • Report
I am still lurking around these parts and I definitely haven't given up on Juno First. It has been a very busy year for me - I moved house twice, changed jobs, and I'm getting married next month! I plan to get back to Juno First again sometime in the new year. It might be possible to use the playfield to change the score colour, but it is going to be difficult as there aren't any spare cycles in the current code (see below). Perhaps someone can spot an optimisation in this code to free up some space?

Cheers,
Chris

	  ; Store Height
		ldy #7	
		sty LINE 
	   ; Load First Char & Colour
		lda (PTR0),Y
		sta GRP0
		lda (CPTR),Y
		sta COLUP0
		sta COLUP1
		sta WSYNC			  ; [0]
		SLEEP 5				; [0] + 5
		jmp StartSpriteLoop	; [5] + 3
SpriteLoop
	   ; Fetch Current Line
		ldy LINE			   ; [62] + 3
		lda (CPTR),Y		   ; [65] + 5
		sta COLUP0			 ; [70] + 3
		sta COLUP1			 ; [73] + 3	  
	   ; Display First 3 Chars
		lda (PTR0),Y		   ; [0] + 5
		sta GRP0			   ; [5] + 3	   > 54
StartSpriteLoop
		lda Dot,Y			  ; [8] + 4
		sta GRP1			   ; [12] + 3	  < 42
		sta.w GRP0			 ; [15] + 4	  < 44	
	   ; Prefetch Remaining 3 Chars
		lax (PTR1),Y		   ; [19] + 5
		lda (PTR2),Y		   ; [24] + 5
		sta TEMP			   ; [29] + 3
		lda (PTR3),Y		   ; [32] + 5
		tay					; [37] + 2
		lda TEMP			   ; [39] + 3
	   ; Display Remaining 3 Chars
		stx GRP1			   ; [42] + 3	  > 44 < 47
		sta GRP0			   ; [45] + 3	  > 46 < 50
		sty GRP1			   ; [48] + 3	  > 49 < 52
		sta GRP0			   ; [51] + 3	  > 52 < 55
	   ; Update Counter
		dec LINE			   ; [54] + 5
		bpl SpriteLoop		 ; [59] + 2/3
  • Report
Well, you've got one free cycle...And, as mentioned above, if you use inverted sprites overlaying the playfield, you can leave the sprite color unchanged and just change the playfield color, which would cut one of your color changes. So there, I've freed 4 cycles for you already. :)

And, as I mentioned previously, every score has a zero in the ones column, so you could hardcode that just like you hardcoded the dots. Which would save you another cycle. So now we've got 5 free cycles, just enough for a lda #WHITE sta COLUPF !

I'll leave the rest (the easy part :lol:) to you!

EDIT: The last line, of course, doesn't have a final zero, but just code that line separately as a special case (and there you'll have even more free cycles since the final 3 characters are all the same). :)
  • Report
I have experimented with something like this. The basic idea is to preserve Y by using the stack pointer as the third register. I got the idea from looking at code in Thrust. The timing is probably wrong, and IIRC, when trying it in bB, it is was really difficult to get it right. But if you can get it to work, you should gain 10 cycles by my count (which may also be wrong.)
SpriteLoop
	  ; Fetch Current Line

; Y is preloaded before entering routine
		lda (CPTR),Y
		sta COLUP0
		sta COLUP1
	  ; Display First 3 Chars
		lda (PTR0),Y
		sta GRP0
StartSpriteLoop
		lda Dot,Y
		sta GRP1
		sta.w GRP0
	  ; Prefetch Remaining 3 Chars
		lax (PTR3),Y
		txs
		lax (PTR1),Y
		lda (PTR2),Y
  sleep 4
 ;old values (1,3,2) in x,a,y
 ;new values (1,3,2) in x, s, and a, preserving y
	 ; Display Remaining 3 Chars
		stx GRP1
		tsx
		stx GRP0
		sta GRP1
		stx GRP0
	  ; Update Counter

		dey
  sleep 6
		bpl SpriteLoop
  • Report
After some experimenting I found out, that cycles are not the problem (by far). I have 10 cycles left now.

But changing the color while the 48 pixels are displayed is not easy.
  • Report

Thomas Jentzsch, on Fri Oct 5, 2007 8:00 AM, said:

Though, the two dots might help here. Only one load instead of two, saving 5 cylces. I'll have a look at it tonight

How about setting one sprite to 'two copies close' and one to 'two copies far'. Use the missiles for the periods (you'll get a second "copy" of each, but they'll be covered up by score digits). Since you'll only have four sprite shapes to worry about you should have no trouble hitting COLUPx.
  • Report

cd-w, on Fri Oct 5, 2007 2:10 PM, said:

It has been a very busy year for me - I moved house twice, changed jobs, and I'm getting married next month!
Congratulations! Does she like Atari? :lol:

cd-w, on Fri Oct 5, 2007 2:10 PM, said:

I plan to get back to Juno First again sometime in the new year.
Cool. :)

(Now if we can just get Manuel to start back up on Colony 7. :) )
  • Report
Found a solution. :lol:

Here is the kernel code:
.digitLoop:					;	   @66
	dey						; 2
	sty	 .counter		   ; 3
	SLEEP   3				  ; 3
	lda	 ColorTbl,y		 ; 4
	sta	 COLUPF			 ; 3	ball defines alien color 
	lda	 AlienGfxTbl,y	  ; 4
	sta	 GRP0			   ; 3
	lda	 DotGfxTbl,y		; 4
	sta	 GRP1			   ; 3
	sta	 GRP0			   ; 3
	lax	 ThirdGfxTbl,y	  ; 4
	txs						; 2
	lax	 FirstGfxTbl,y	  ; 4
	lda	 SecondGfxTbl,y	 ; 4
	ldy	 #$0e			   ; 2
	sty	 COLUBK			 ; 3
	stx	 GRP1			   ; 3
	sta	 GRP0			   ; 3
	tsx						; 2
	stx	 GRP1			   ; 3
	sty	 GRP0			   ; 3
	lda	 #0				 ; 2
	sta	 COLUBK			 ; 3
	ldy	 .counter
	bne	 .digitLoop		 ; 2³
Positions:
P0: 56
P1: 64
M0: 104
M1: 16
BL: 56
  • Report

supercat, on Sat Oct 6, 2007 12:23 AM, said:

...but they'll be covered up by score digits).
Thought about that one two. Unfortunately the dots are one row above the score bottom line and the copies therefore would show.
  • Report

Thomas Jentzsch, on Sat Oct 6, 2007 8:46 AM, said:

supercat, on Sat Oct 6, 2007 12:23 AM, said:

...but they'll be covered up by score digits).
Thought about that one two. Unfortunately the dots are one row above the score bottom line and the copies therefore would show.

So move them down a row. Or else set the playfield black and priority, and arrange things so the extra missile copies are off to the left.
  • Report

supercat, on Sat Oct 6, 2007 6:18 PM, said:

Or else set the playfield black and priority, and arrange things so the extra missile copies are off to the left.
Yes, that works too. And is much more elegant than my solution. :lol:
  • Report

Thomas Jentzsch, on Sat Oct 6, 2007 2:44 PM, said:

Found a solution. :lol:

Many thanks - I will include this in the next release (sometime in the new year I hope).

Chris
  • Report

cd-w, on Mon Oct 8, 2007 2:26 PM, said:

Many thanks - I will include this in the next release (sometime in the new year I hope).
I have done some more elegant solution, based on supercat's suggestion. Contact me, when you need it.
  • Report