Jump to content



0

How to display more sprites?


12 replies to this topic

#1 xian106 OFFLINE  

xian106

    Space Invader

  • 11 posts

Posted Mon Mar 28, 2005 11:45 PM

I want to display a big graphics,but the right side is not the same as the left side.So I think it must be done using sprites.
And I think it is:

screen
---------------------------------------------------
p0 p1 p0 p1 p0 p1
p0 p1 p0 p1 p0 p1
...............
--------------------------------------------------

But when I write the second "p0",it will cover with the first "p0"
How to do it?
May be I must use "resp0" again before write the second "p0",but I can not do it....

#2 DEBRO OFFLINE  

DEBRO

    Stargunner

  • 1,862 posts
  • Location:Atlanta, GA

Posted Tue Mar 29, 2005 12:06 AM

Read the The scores / 48-pixel highres routine explained! thread on [stella]. This may help you.

#3 xian106 OFFLINE  

xian106

    Space Invader

  • 11 posts

Posted Tue Mar 29, 2005 9:15 PM

Time is too hard to control....especially when the sprites moved.

#4 DEBRO OFFLINE  

DEBRO

    Stargunner

  • 1,862 posts
  • Location:Atlanta, GA

Posted Tue Mar 29, 2005 9:24 PM

xian106 said:

Time is too hard to control....especially when the sprites moved.
So what are trying to do? If it's a big moving sprite like in Dragster then read Eckhard's Movable 48 pixel sprite thread on [stella]. If you're looking for a formation like Space Invaders then read Paul Slocum's Atari 2600 Advanced Programming Guide. Read the section on the multi-sprite trick.

#5 vb_master OFFLINE  

vb_master

    Stargunner

  • 1,770 posts
  • Location:At my computer, where else?

Posted Tue Mar 29, 2005 11:02 PM

Flicker?

#6 xian106 OFFLINE  

xian106

    Space Invader

  • 11 posts

Posted Tue Mar 29, 2005 11:54 PM

OK,I get "bigmove.asm".I try to calculate its time,but have some trouble.
Could you have a look at:
[/code]

LDY TopDelay ;TopDelay =0 at the beginning
INY
;machine cycles
X1: STA Wsync ; 0,GO
DEY ; 2
BNE X1 ; 3--5
LDY #4 ; 2--7
X2: DEY ;
BPL X2 ; 5*4+5=25
; 25--32
LDA #9 ; 2 --34
STA LoopCount ; 3--37
JMP (DelayPTR) ;5--42 ;JMP TO $f241
JNDelay: byte $c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9
byte $c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9
byte $c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9
byte $c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9
byte $c9,$c5
; $f241 is here. C9=2 c5=3 5 --47
NOP ; 2 --49

X3: NOP ; 2 --51
NOP ; 2 --53
NOP ; 2 --55
LDY LoopCount ;3--58
LDA (s1),Y ; 5 --63
STA GRP0 ; 3 --66
LDA (s2),Y ; 5 --71
STA GRP1 ; 3 --74
LDA (s3),Y ; 5 --79(3)
STA GRP0 ; 3 --6
LDA (s6),Y ; 5 --11
STA Temp ; 3 --14
LDA (s5),Y ; 5 --19
TAX ; 2 --21
LDA (s4),Y ; 5 --26
LDY Temp ; 3 --29
STA GRP1 ; 3 --32
STX GRP0 ; 3 --35
STY GRP1 ; 3 --38
STA GRP0 ; 3 --41
DEC LoopCount ;5--46
BPL X3 ; 4 --50
; JMPX3 :NOP 2 --52


The problem is when p1 and p0 displayed?Could you label it behind the code?
In the X3 loop, there is 77 machine cycles?????

#7 xian106 OFFLINE  

xian106

    Space Invader

  • 11 posts

Posted Wed Mar 30, 2005 12:00 AM

I am sorry. I donn't know how to modify.....I forgot the "[/code]"




         LDY     TopDelay          ;TopDelay =0 at the beginning 

         INY     

                ;machine cycles

X1:      STA     Wsync; 0    	

         DEY	; 2    	

         BNE     X1; 3--5    	

         LDY     #4 ; 2--7  	

X2:      DEY	;   

         BPL     X2; 5*4+5=25  	

          ; 25--32	

         LDA     #9; 2 --34	

         STA     LoopCount; 3--37  	

         JMP     (DelayPTR);5--42	;JMP TO $f241

JNDelay: byte    $c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9

         byte    $c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9

         byte    $c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9

         byte    $c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9,$c9

         byte  $c9,$c5; $f241 is here. C9=2 c5=3  5 --47	

         NOP  ; 2 --49	

X3:      NOP  ; 2 --51	

         NOP  ; 2 --53

         NOP  ; 2 --55

         LDY     LoopCount;3--58

         LDA     (s1),Y	; 5 --63

         STA     GRP0	; 3 --66

         LDA     (s2),Y	; 5 --71

         STA     GRP1	; 3 --74

         LDA     (s3),Y ; 5 --79(3)

         STA     GRP0	; 3 --6

         LDA     (s6),Y	; 5 --11;;;;;;;;;;;;;;;;;;;;;;;;

         STA     Temp	; 3 --14

         LDA     (s5),Y	; 5 --19

         TAX  ; 2 --21

         LDA     (s4),Y ; 5 --26

         LDY     Temp	; 3 --29

         STA     GRP1	; 3 --32

         STX     GRP0	; 3 --35

         STY     GRP1	; 3 --38

         STA     GRP0	; 3 --41

         DEC     LoopCount;5--46

         BPL     X3	; 4 --50

                	; JMPX3  :NOP  2 --52



                  

                  

        ;The problem is when p1 and p0 displayed?Could you label it behind the code?   

        ; In the X3 loop, there is 77 machine cycles?????	

[/code]

#8 Thomas Jentzsch OFFLINE  

Thomas Jentzsch

    Thrust, Jammed, SWOOPS!

  • 16,745 posts
  • Always left from right here!
  • Location:Düsseldorf, Germany

Posted Wed Mar 30, 2005 7:19 AM

You should follow the 1st link.

#9 xian106 OFFLINE  

xian106

    Space Invader

  • 11 posts

Posted Thu Mar 31, 2005 10:08 AM

I had understood this problem.That's real hard.Time is important.
But there is a problem that I don not understand.It's about the pattern B position (RESP0) in the following program.I just use this program,but donn't undertand.

LDX	#$00;x =0,1,2,3,4 pattern =b c d,e f

	LDA	#30

	JSR	SetPatPos

----------------------------------------------------------------	

SetPatPos

	SEC

	STA	wsync	

.1	SBC	#$0F;2

	BCS	.1;3

	EOR	#$07;2

	ASL	;2

	ASL	;2

	ASL	;2

	ASL	;2        14+(a/$0f+1)*5 machine cycles

	STA	hmp0,X;4	B  C  D  E or F fine position

	STA	resp0,X;	pattern B,C,D,E,F position

	RTS


I had read this problem for a whole day~~
I donn't know why the value A-3 will be the actual position. Like:
A=#30 In this program,between the "STA WSYCN" and "STA RESP0,W" will take 14+(#30/$0f+1)*5=29 machine cycles, and HMP0=60(Shift left 6 pixels),So the B's position is 29*3-6=81 and 81-68=13 pixels (On TV).But I try it in games, the B's position will be 27 pixels(on TV) which is equal to A-3

A=#50,102-1=101 101-68=33 But it's 47 actually
A=#51,102-0=102 102-68=34 But it's 48 actually
A=#30, 87-6= 81 81-68=13 But it's 27 actually
A=#3 57-3= 54 54-68=-14 But it's 0 actually
Why it is?
I tried my best to understand it,but lost. I'm in China,and no friends could tell me.Writing games by oneself is not popular in China,and just programmer does it.I don't realize them.:) And no Atari program network for chinese on the Internet. So I ask help in USA,I think you could help me.
Thanks.
Don't laugh at me asking so fatuous problem :) I just study it by muself on the internet,and I like it very much.


The attachment is my try using this program.
I want to display "progra" at the middle of screen.But it has something wrong.I calculated its time carefully.I don't know why it is.Is it following season 1 or 2?
1 The reason is that I got a wrong position using above program. Maybe the position is not A-3....What number is it?.......
2 The reason is that time is wrong in my "display" loop.Please help me to check it.
Thank you.

Attached Files



#10 Thomas Jentzsch OFFLINE  

Thomas Jentzsch

    Thrust, Jammed, SWOOPS!

  • 16,745 posts
  • Always left from right here!
  • Location:Düsseldorf, Germany

Posted Thu Mar 31, 2005 12:57 PM

Welcome to Atari 2600 programming Xian!

Ok, here is the code again, now using my usual labeling and with corrected cycle counting:
SetPatPos

  sec

  sta	WSYNC	

.1

  sbc   #$0F   ;2

  bcs   .1     ;2/3

  eor   #$07   ;2

  asl          ;2

  asl          ;2

  asl          ;2

  asl          ;2

  sta	HMP0,x ;4	

  sta	RESP0,x;4 = 18+n*5-1

  rts
So with a value of 30, hitting RESP0 happens at 18+3*5-1 = 32 (not 29).

The code above still has some minor offset (e.g. using 0, will not result in a displayinmg it at pixel 0), because with n=0, RESP0 happens at 22, which is IIRC, one cycle to early. But, unless the branch crosses a 256 byte boundary it should position the sprites pretty reliable.

#11 DEBRO OFFLINE  

DEBRO

    Stargunner

  • 1,862 posts
  • Location:Atlanta, GA

Posted Thu Mar 31, 2005 1:11 PM

xian106 said:

The attachment is my try using this program.
I want to display "progra" at the middle of screen.But it has something wrong.I calculated its time carefully.I don't know why it is.Is it following season  1 or 2?
Have you subscribed to [stella]? There are a lot of people there that can help with 2600 programming. It's a small community of VCS developers.

The reason why you're not seeing the word "progra" is because your routine has a bug. In your code you have...

    lda pdata_g,x    ;4--25

    tax        ;2--27

    ldy pdata_r,x    ;4--31
So you're overwriting your index with the sprite data.

#12 xian106 OFFLINE  

xian106

    Space Invader

  • 11 posts

Posted Thu Mar 31, 2005 10:06 PM

DEBRO, Thank you for your help.I will have a try to modify my program.
And I have subscribed to stella just now.I think people in the Stella are proficient at 2600 program,it seems to be not wright that I ask them so simply question...

Thomas Jentzsch,Thank you.
"18+n*5-1" I think you mean I must add the 4 cycles with "sta RESP0,x",but why is a "-1" needed? Is it because the "bcs .1" ? When the C flag is set," bcs .1" just be 2 cycles?
OK,if it is "18+n*5-1",When A=3 , (18+1*5-1)*3-3-68= -5,but I had a try in games,when A=3, sprite will be displayed on the left side of screen,it means that the the position must be zero,and our result is -5.Why?

#13 Thomas Jentzsch OFFLINE  

Thomas Jentzsch

    Thrust, Jammed, SWOOPS!

  • 16,745 posts
  • Always left from right here!
  • Location:Düsseldorf, Germany

Posted Fri Apr 1, 2005 4:49 AM

xian106 said:

"18+n*5-1" I think you mean I must add the 4 cycles with "sta RESP0,x"
Yup, the reset gets triggered at the very last cycle of that instruction.

Quote

...,but why is a "-1"  needed? Is it because the "bcs .1" ? When the C flag is set," bcs .1" just be 2 cycles?
The other way arround: When C is clear (= branch not taken), the instruction requires only 2 cycles. So, when exiting the loop, we save one cylce (the "-1").

Quote

OK,if it is "18+n*5-1",When A=3 , (18+1*5-1)*3-3-68= -5,but I had a try in games,when A=3, sprite will be displayed on the left side of screen,it means that the the position must be zero,and our result is -5.Why?
I am not sure, if I understand you correctly here. I suppose ther eare two problems overlapping, making it hard to fix them.

1. problem:
A write to RESPx before cycle 23 works like a write at cycle 23. This is happening in your example above. Replace the last instruction with sta.w RESP0,x (= 5 cycles instead of 4).

2. problem:
The code above may not be 100% perfect. The might be a small offset (less than 3 pixel). Just add that offset at the start of the code and everything should be fine.
Note: missiles and IIRC the ball, have a slightly different offset than the sprites.

BTW: Don't be afraid to ask at [stella]. Just make sure that you check the archives before asking. If anything is still unclear (and this code is quite tricky), just ask, please.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users