Jump to content

Photo

DPC Sprite Demo


6 replies to this topic

#1 SpiceWare OFFLINE  

SpiceWare

    Draconian

  • 11,674 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Sat Mar 13, 2010 9:24 PM

Decided to do a little experimenting with the Pitfall 2 DPC chip using my new Harmony cartridge. DPC uses a 10K ROM, which is comprised of two 4K banks plus an additional 2K that's used to store graphics data. Selection between the 4K banks is done via standard F8 bank switching, while the 2K is not directly accessible to the 6502.

There's a number of ways to update a sprite + color, DoDraw does it in 26
   lda #SPRITEHEIGHT
   dcp SpriteTemp
   bcs DoDraw
   lda #0
   .byte $2C
DoDraw
   lda (GfxPtr),Y
   sta GRP0  ;+18 cycles
   lda (ColorPtr),y
   sta COLUP0

For Stay Frosty I used a mask table (which wastes a bunch of ROM space with 0s) and was able to get that down to 21 cycles
   LDA (SpritePtr),y  ; 5
   AND (SpriteMask),y ; 5
   STA GRP0           ; 3
   LDA (ColorPtr),y   ; 5
   STA COLUP0         ; 3
DPC uses just 14 cycles
   LDA DF0DATAW ; 4
   STA GRP0     ; 3
   LDA DF1DATA  ; 4
   STA COLUP0   ; 3

At first glance using the DPC looked straightforward, it wasn't. I ended up downloading the source to Stella to see how DPC cartridge routines were implemented. The trick was instead of using GraphicDataPosition to prep the pointers, you need to use (2047 - GraphicDataPosition). There are 8 pointers that are set via DFxLOW and DFxHIGH (x = 0-7). Pointers 5, 6 and 7 appear to be used for music support, so if you've opted to have the DPC generate music this pointers might not be available for graphic data usage.
; 	set the DataStream Pointer 0 for the graphic data
	lda #<(2047 - GraphicDataPosition + HowFarDownScreen)
	sta DF0LOW
	lda #>(2047 - GraphicDataPosition + HowFarDownScreen)
	sta DF0HIGH
	
;	set the DataStream Pointer 1 for the color data
	lda #<(2047 - ColorDataPosition + HowFarDownScreen)
	sta DF1LOW
	lda #>(2047 - ColorDataPosition + HowFarDownScreen)
	sta DF1HIGH 

One the DataStream pointers are configured, just use LDA DFxDATA (x=0-7) to retrieve the data. Each access will automatically advance the data stream.

For sprite data you can set where in the data stream the sprite really exists, then use LDA DFxDATAW to read with the mask already applied.
;	set the MASK for DataStream 0
	lda #<(2047 - GraphicDataPosition)
	sta DF0TOP
	lda #<(2047 - GraphicDataPosition - ImageHeight)
	sta DF0BOT
In the demo move the joystick to position Frosty on the screen and hit Fire to switch between 6 images for Frosty. I forced 1 of the images to cross a page boundary and everything still works as expected.

Attached Files



#2 diogoandrei OFFLINE  

diogoandrei

    Chopper Commander

  • 211 posts
  • Location:Brazil

Posted Thu Jan 6, 2011 5:51 AM

Great work, congrats! May I ask you, how did you get the definitions (dpc.h)?

#3 cd-w OFFLINE  

cd-w

    Stargunner

  • 1,602 posts
  • Juno First!
  • Location:Glasgow, UK

Posted Thu Jan 6, 2011 5:55 AM

Great work, congrats! May I ask you, how did you get the definitions (dpc.h)?


The definitions came from the DPC chip patent.

Chris

#4 SpiceWare OFFLINE  

SpiceWare

    Draconian

  • Topic Starter
  • 11,674 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Thu Jan 6, 2011 9:35 AM

cd-w - Glad you answered as I didn't know where the definitions came from :)

diogoandrei - Don't know if you saw the other topics but we created DPC+, an expanded version of DPC, for use with the Harmony Cartridge. It provides for six 4K banks for code and a 4K bank for graphics data. There's also a special mode that decreases the time to update a sprite + color to just 10 cycle, as well as a way to call ARM functions. We've got a game in the pipeline that should be released next month that utilizes these and other new features of DPC+.

Harmony DPC+ programming
Harmony DPC+ ARM programming

#5 diogoandrei OFFLINE  

diogoandrei

    Chopper Commander

  • 211 posts
  • Location:Brazil

Posted Fri Jan 14, 2011 3:01 PM

Great work, congrats! May I ask you, how did you get the definitions (dpc.h)?


The definitions came from the DPC chip patent.

Chris


Thanks! =)

cd-w - Glad you answered as I didn't know where the definitions came from :)

diogoandrei - Don't know if you saw the other topics but we created DPC+, an expanded version of DPC, for use with the Harmony Cartridge. It provides for six 4K banks for code and a 4K bank for graphics data. There's also a special mode that decreases the time to update a sprite + color to just 10 cycle, as well as a way to call ARM functions. We've got a game in the pipeline that should be released next month that utilizes these and other new features of DPC+.

Harmony DPC+ programming
Harmony DPC+ ARM programming


Hey SpiceWare, I was not aware of that, thanks! I am really impressed with the results, contratulations! I will start reading on the DPC+ really soon. Let us know when the game is coming out!

#6 SpiceWare OFFLINE  

SpiceWare

    Draconian

  • Topic Starter
  • 11,674 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Thu Jan 20, 2011 4:03 PM

Let us know when the game is coming out!

Once nice thing about the game - we've now got Stella updated to run the ARM code! We're still working out a few kinks before it's released to the public, plus I'll have to update the DPC+ ARM demo to work with it. The ARM code isn't fully accurate though - it doesn't emulate the time it takes to run the ARM code. As such, you still need to test on a Harmony to make sure your code doesn't take to long to run (which will either crash the Atari or make the screen jitter).

I picked up a freelance project that's going to last 3 months for "phase 1". Atari 2600 games don't pay the bills, so sadly the game's been bumped to the back burner.

#7 chjmartin2 OFFLINE  

chjmartin2

    Moonsweeper

  • 321 posts
  • Location:Massachusetts

Posted Wed Feb 9, 2011 7:13 AM

Is there a DPC+ asm source code that displays a basic bitmap image lying around somewhere?




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users