NESDev and Strangulation Records messageboards
Forum Index | FAQ | New User | Login | Search

Previous ThreadView All ThreadsNext Thread*Show in Threaded Mode


SubjectCan someone explain collision detection in english? new  
Posted byFistOfFury
Posted on10/30/02 08:50 AM
From IP65.56.17.215  



The basic idea and method of how it works? I want learn how to do it in snes code, I can't find any snes code examples for collision detection, if someone would explain it to me the basics of how it's done, I can then figure out what I need to do to make it work with the snes. Thanks.




SubjectRe: Can someone explain collision detection in english? new  
Posted byMemblers
Posted on10/30/02 09:25 AM
From IP68.58.96.167  



The easiest way to do it seems to be using square or rectangular boxes, and checking when they overlap. I'm sure there's other ways to do it, probably better ones to, but here's how I'm doing it in a game. This is only covers sprite-to-sprite collisions.

Say a sprites Y coord is $60. You'd load that into A, then compare it to the Y coord of something it could potentially hit. This will set the carry flag to use in a greater-than/less-than check.

LDA player_y
CMP enemy_y
BCS player_is_above_object
CLC ; not really neccessary because we know the carry is clear =)
ADC #8 ; make the 'box' 8 pixels high
CMP enemy_y
BCS player_hit

Now, I might've screwed that example up (the code in my game is maybe too complicated to make a good example), but hopefully this explains the basics.




SubjectRe: Can someone explain collision detection in english? new  
Posted bykoitsu
Posted on10/30/02 09:39 AM
From IP12.234.118.8  



A common method we used to use on the IIGS was using sprite masks. I really have no desire on documenting this though, since it'd be overkill on the NES or SNES due to the excessive processing overhead (at least we have hardware sprites on the NES/SNES ;-) ).

-- jdc


SubjectRe: Can someone explain collision detection in english? new  
Posted byFistOfFury
Posted on10/30/02 10:30 AM
From IP65.56.64.172  



Yeah, sprite collision detection, that's what I meant. Only thing I didn't understand is the BCS instruction in your code. BCS = branch on??? bleh I can't remember right now.




SubjectRe: Can someone explain collision detection in english? new  
Posted byMemblers
Posted on10/30/02 10:38 AM
From IP68.58.96.167  



BCS = branch on carry set
BCC = branch on carry clear




SubjectRe: Can someone explain collision detection in english? new  
Posted byMemblers
Posted on10/30/02 10:42 AM
From IP68.58.96.167  



I should probably explain a bit more.

CMP works like the SBC instruction (but without using the carry, I believe), the difference is that it doesn't modify any registers/memory, only the status flag.




SubjectRe: Can someone explain collision detection in english? new  
Posted byFistOfFury
Posted on10/30/02 10:43 AM
From IP65.56.64.172  



Those are nes only intructions? I don't see those two in my snes intruction set file. Bleh maybe my file is missing stuff.




SubjectRe: Can someone explain collision detection in english? new  
Posted byFistOfFury
Posted on10/30/02 10:45 AM
From IP65.56.64.172  



that was supposed to read "instruction" lol im half asleep




SubjectRe: Can someone explain collision detection in english? new  
Posted byMemblers
Posted on10/30/02 10:46 AM
From IP68.58.96.167  



Those are 6502, and the 65816 has every 6502 instruction supported.

Perhaps you have a file that only lists the new instructions that were added to the 65816. The best doc I've found about that CPU had the filename 65816info.txt




SubjectRe: Can someone explain collision detection in english? new  
Posted byFistOfFury
Posted on10/30/02 10:54 AM
From IP65.56.64.172  



;Those are 6502, and the 65816 has every 6502 instruction supported.

Can you use a 6502 instruction in 65816 native mode? Or it doesn't matter, they are all the same and no different instructions?

"Perhaps you have a file that only lists the new instructions that were added to the 65816. The best doc I've found about that CPU had the filename 65816info.txt"

That's the file I have, and a couple others. It's in there, I'm just half asleep and missed it. hehe








SubjectRe: Can someone explain collision detection in english?  
Posted byMemblers
Posted on10/30/02 11:03 AM
From IP68.58.96.167  



The 6502 emulation mode will set it up like a normal 6502 (zero-page being at $0000, stack at $0100, 8-bit index and memory), but you can still use the new 65816 instructions even in that mode. The opcodes are still the same.




SubjectRe: Can someone explain collision detection in english? new  
Posted bykoitsu
Posted on10/30/02 11:26 AM
From IP12.234.118.8  



I HIGHLY recommend you wait until you receive either your Eyes/Lichty book, or purchase the reference guide from WDC.

Literally __ALL__ CPU issues and instruction set questions you have will be answered, believe me. And yes, I do mean *ALL*.

BTW -- It's not recommended you run the SNES in emulation mode for long periods of time. Hence why you see the CLC/XCE right off the bat at the beginning of SNES titles. The 65816 starts in emulation mode, hence why this is necessary.

Bottom line: if you're fucking with the SNES, you should be using native mode, otherwise go with an older system (NES) for 6502. There's very little (not "none," just very little) reason to switch into emulation mode. There's nothing wrong with 16-bit registers or a nice fat 64K addressable direct page.

-- jdc


SubjectRe: Can someone explain collision detection in english? new  
Posted byFistOfFury
Posted on10/30/02 11:34 AM
From IP65.56.64.172  



Yeah, I kinda figured it would be better in native mode, but I wasn't clear if there would be 6502 instructions are can only be used in emulation mode, that's what I mean to ask in my above post.

"Hence why you see the CLC/XCE right off the bat at the beginning of SNES titles. The 65816 starts in emulation mode, hence why this is necessary."

Yes, I've seen that before in all the titles I've disasembled, the CLC/XCE is like the very first 2 lines or very near to that in all of the roms I've looked at.




Previous ThreadView All ThreadsNext Thread*Show in Threaded Mode
Jump to

Memblers' homepage             Contact Me

Forums powered by WWWThreads Demo