Jump to content

Mord's Blog

  • entries
    170
  • comments
    93
  • views
    100,661

Collision Detection Rewrite


Mord

287 views

For budding 6502 programmers.

 

 

	ldx #7							; We load the Collision Pointer.
lda (SpriteP1_SpriteDataPtrLow),x ;
sta Collision_PtrLow		;
ldx #9							;
lda (SpriteP1_SpriteDataPtrLow),x ;
sta Collision_PtrHigh			 ;

jmp (Collision_PtrLow)

 

This code compiles with dasm just fine.

 

But it is INCORRECT. To get the proper addressing mode, you must use the Y instead of the X. Something I keep forgetting to double check since dasm won't break down on me when it compiles. I just spent an hour looking at the code and the associated code around it going "There's an error here. HERE. It is obvious. It has to be or I'd have found it by now... *stares at loading of pointer* I bet it's staring me right... in... the.... eye...."

 

:ponder:

 

Anyway the basis for the real Collision Handler is now functioning for Player-to-object collisions. I can see some uses for object-object collision checks as well. That'll be easy enough to add in later. Next part to generalize is the object itself. Both it's AI routine, and it's collision routine. This step will be to rewrite the hardwired heart object so that's aware of where it is in the item list and act on the appropriate item slot. Right now it functions while hardwired to the Region 1 object slot.

 

*edit*

 

And I've just rewrote the collision function associated with the heart so that it can correctly update it's associated item slot.

 

This caused a minor glitch in the graphics from timing issues - apparently the display code is so tight that it can't handle an item's graphics crossing a page boundary. I left a note in the source code close to where the objects would begin to keep an eye on that sort of stuff. (And to remind me it's an issue!) Regardless, cleared that up in short order.

 

So only two parts remaining.

 

1. Impliment the Object AI routines. (This would control monsters moving about, timers on temporary objects, etc.) This promises to be easy enough. It'll be harder to try to make it run faster later on, or split it's AI running across multiple frames, etc. But for now it'll just check all 8 object slots to see if it holds an item to update, and run the associated functions if so.

 

 

2. Rewrite the Heart Placer routine to populate all item slots whenever it finds an empty slot. This is just a temp function so I can see how things are working.

 

I will probably add a few extra types of objects as well. ;)

 

But for now. sleep.

0 Comments


Recommended Comments

There are no comments to display.

Guest
Add a comment...

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