Jump to content



0

How to do coloured Sprites?


9 replies to this topic

#1 Steril707 OFFLINE  

Steril707

    Chopper Commander

  • 170 posts
  • Location:München

Posted Tue Sep 4, 2007 5:38 AM

I am using Skipdraw for my sprites, and everything seems to work fine, and i guess i understood now how skipdraw works in terms of the pointer subtraction it does inside a page.

Now i want one of my sprites to have a new color each line...

I tried to do the same thing that Skipdraw does with a colortable + appropriate pointer, and wanted to use a simple
lda (colortable), y
sta COLUP0
inside my kernal,
, but didnt get far with this.

So, can somebody tell me something about this, or point me to some threads with info about how to get coloured sprites working? I havent found anything here using the Atariage-search yet...

thanks a lot,
Michael

#2 SeaGtGruff OFFLINE  

SeaGtGruff

    River Patroller

  • 4,543 posts
  • Location:Georgia, USA

Posted Tue Sep 4, 2007 12:21 PM

View PostSteril707, on Tue Sep 4, 2007 7:38 AM, said:

I am using Skipdraw for my sprites, and everything seems to work fine, and i guess i understood now how skipdraw works in terms of the pointer subtraction it does inside a page.

Now i want one of my sprites to have a new color each line...

I tried to do the same thing that Skipdraw does with a colortable + appropriate pointer, and wanted to use a simple
lda (colortable), y
sta COLUP0
inside my kernal,
, but didnt get far with this.

So, can somebody tell me something about this, or point me to some threads with info about how to get coloured sprites working? I havent found anything here using the Atariage-search yet...

thanks a lot,
Michael
These may be dumb questions, but did you define the lo-byte/hi-byte pointers for colortable, did you set them to the correct lo-byte/hi-byte values, and did you create a table of color values at the address pointed to by those pointers?

Michael

#3 Steril707 OFFLINE  

Steril707

    Chopper Commander

  • 170 posts
  • Location:München

Posted Tue Sep 4, 2007 2:23 PM

Hey Michael,
i am currently in the weird situation that i cannot post any code, for the pc where i code at is not connected to the internet. This will change over the next days though...

I think i did all the things you mentioned, but i am not completely sure if i did everything the right way... Hmm, i guess i have to wait until i can post some code, once more ;)

anyway, thanks... :)

Michael

#4 LS_Dracon OFFLINE  

LS_Dracon

    Moonsweeper

  • 410 posts

Posted Wed Sep 5, 2007 9:31 PM

Don't need pointer or var.
Just :
...
   tay
   lda colortable,y
   sta COLUP0
   lda (spritepointer),y
...
After tay.

#5 DEBRO OFFLINE  

DEBRO

    Stargunner

  • 1,862 posts
  • Location:Atlanta, GA

Posted Thu Sep 6, 2007 5:54 AM

Hi there,

View PostSteril707, on Tue Sep 4, 2007 4:23 PM, said:

I think i did all the things you mentioned, but i am not completely sure if i did everything the right way... Hmm, i guess i have to wait until i can post some code, once more ;)
Have a look my Climber 5 source. Unfortunately I can't find it right now. You should be able to find it if you do a search in the forums or [stella]. I did the same thing you're trying to do with the climber.

Make sure you set up your indirect pointer for your colors the same way you set up your indirect pointer to the graphics data.

This is how I set mine up...
   sec
   lda #KERNEL_HEIGHT
   tay							 ; used for the kernel
   sbc verPosP1					; subtract the climber vertical position
   adc #CLIMBER_HEIGHT-1		   ; add back in the climber height to get the
								   ; offset
   sta climberOffset			   ; this is decremented in the kernel to
								   ; determine when the y-register is in range
								   ; to draw the climber
   clc
   adc playerGraphicLSB			; add the value to the graphic pointer LSB
   sta playerPointer			   ; so the indirect read doesn't cross a page
								   ; boundary
   lda climberOffset
   clc
   adc playerColorsLSB			 ; now calculate the color pointer LSB the
   sta playerColorPointer		  ; same way

Then in the kernel I would do the typical...
   lda #CLIMBER_HEIGHT-1		   ; 2
   dcp climberOffset			   ; 5
   bcs .colorClimber			   ; 2
   SLEEP_9						 ; 9
   lda #0						  ; 2
   beq .drawClimber				; -10
   
.colorClimber
   lda (playerColorPointer),y	  ; 5
   sta COLUP1					  ; 3
   lda (playerPointer),y		   ; 5
.drawClimber
   sta GRP1						; 3

Also, your colors would have the same page restrictions as your graphic data.

I hope this helps.

#6 Steril707 OFFLINE  

Steril707

    Chopper Commander

  • 170 posts
  • Location:München

Posted Sun Sep 9, 2007 12:12 PM

Hello Dennis,
thanks for your advice and code samples...

Just one question: Can't i just change the Player color all the time...I guess it doesnt make any difference, if i do a playercolor-write and the player isnt being drawn this scanline anyway, isnt it?

greets,
Mike

#7 SeaGtGruff OFFLINE  

SeaGtGruff

    River Patroller

  • 4,543 posts
  • Location:Georgia, USA

Posted Sun Sep 9, 2007 4:19 PM

View PostSteril707, on Sun Sep 9, 2007 2:12 PM, said:

Can't i just change the Player color all the time...I guess it doesnt make any difference, if i do a playercolor-write and the player isnt being drawn this scanline anyway, isnt it?
If by "change the Player color all the time" you mean on each scan line-- or pair of scan lines, if you're using a 2-line kernel-- then I don't think that would work unless you're also drawing the player on each line (i.e., a 192-line or 96-line tall player). Otherwise, the index to the playercolor table won't match up with the index to the playershape table, see? Also, it would take up more ROM.

On the other hand, if ROM isn't an issue, but cycles *are* an issue, then playershape and playercolor tables that span the height of the screen might be useful, since you could just load and store the playershape and playercolor data on each line, without having to spend cycles on testing any variables and then taking the appropriate branches. But since your player will presumably need to move in the vertical direction, you'll need to pad the beginning and end of the tables with enough "blank" lines to let you move the player vertically by changing the point at which you start reading from the tables.

Michael

#8 DEBRO OFFLINE  

DEBRO

    Stargunner

  • 1,862 posts
  • Location:Atlanta, GA

Posted Mon Sep 10, 2007 2:40 AM

Hi there,

View PostSteril707, on Sun Sep 9, 2007 2:12 PM, said:

Just one question: Can't i just change the Player color all the time...I guess it doesnt make any difference, if i do a playercolor-write and the player isnt being drawn this scanline anyway, isnt it?
You could but if you're using skipDraw and indirect indexing for the colors then your cycle counts wouldn't be constant it you did a read outside the table.

#9 Steril707 OFFLINE  

Steril707

    Chopper Commander

  • 170 posts
  • Location:München

Posted Tue Sep 11, 2007 4:16 AM

@ Dennis: Hmm, somehow i don't get this whole thing together..I concentrated on other things though on my game.
I still hope i can tackle this subject not too far in the future..

@Michael: I am using a 2lk, but i still have y being in the "true" scanline count, not the halfed one. just doing dey after every STA WSYNC. Else i couldn't update the background and foreground colors each row on Bombjack.

#10 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Tue Sep 11, 2007 5:10 AM

If there's not enough leftover cycles in either portion of your 2lk, you could try unrolling the loop where the player character is drawn.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users