Jump to content
SpiceWare

DPC Sprite Demo

Recommended Posts

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
[code]
lda #SPRITEHEIGHT
dcp SpriteTemp
bcs DoDraw
lda #0
.byte $2C
DoDraw
lda (GfxPtr),Y
sta GRP0 ;+18 cycles
lda (ColorPtr),y
sta COLUP0
[/code]

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
[code]
LDA (SpritePtr),y ; 5
AND (SpriteMask),y ; 5
STA GRP0 ; 3
LDA (ColorPtr),y ; 5
STA COLUP0 ; 3
[/code]
DPC uses just 14 cycles
[code]
LDA DF0DATAW ; 4
STA GRP0 ; 3
LDA DF1DATA ; 4
STA COLUP0 ; 3
[/code]

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.
[code]
; 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
[/code]

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.
[code]
; set the MASK for DataStream 0
lda #<(2047 - GraphicDataPosition)
sta DF0TOP
lda #<(2047 - GraphicDataPosition - ImageHeight)
sta DF0BOT
[/code]
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.

Share this post


Link to post
Share on other sites
[quote name='diogoandrei' date='Thu Jan 6, 2011 11:51 AM' timestamp='1294314694' post='2176061']
Great work, congrats! May I ask you, how did you get the definitions (dpc.h)?
[/quote]

The definitions came from the [url="http://www.freepatentsonline.com/4644495.html"]DPC chip patent[/url].

Chris

Share this post


Link to post
Share on other sites
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+.

[url=http://www.atariage.com/forums/topic/163495-harmony-dpc-programming/]Harmony DPC+ programming[/url]
[url=http://www.atariage.com/forums/topic/163834-harmony-dpc-arm-programming/]Harmony DPC+ ARM programming[/url]

Share this post


Link to post
Share on other sites
[quote name='cd-w' date='Thu Jan 6, 2011 8:55 AM' timestamp='1294314948' post='2176063']
[quote name='diogoandrei' date='Thu Jan 6, 2011 11:51 AM' timestamp='1294314694' post='2176061']
Great work, congrats! May I ask you, how did you get the definitions (dpc.h)?
[/quote]

The definitions came from the [url="http://www.freepatentsonline.com/4644495.html"]DPC chip patent[/url].

Chris
[/quote]

Thanks! =)

[quote name='SpiceWare' date='Thu Jan 6, 2011 12:35 PM' timestamp='1294328105' post='2176180']
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+.

[url=http://www.atariage.com/forums/topic/163495-harmony-dpc-programming/]Harmony DPC+ programming[/url]
[url=http://www.atariage.com/forums/topic/163834-harmony-dpc-arm-programming/]Harmony DPC+ ARM programming[/url]
[/quote]

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!

Share this post


Link to post
Share on other sites
[quote]Let us know when the game is coming out![/quote]
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 [i]"phase 1"[/i]. Atari 2600 games don't pay the bills, so sadly the game's been bumped to the back burner.

Share this post


Link to post
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.

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