Jump to content
IGNORED

DPC Sprite Demo


SpiceWare

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

  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 these three 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 
 

 

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

dpc.bin

DPC demo.zip

  • Like 4
Link to comment
Share on other sites

  • 9 months later...

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

Link to comment
Share on other sites

  • 2 weeks later...

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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