It is currently Sat Oct 19, 2019 3:58 pm

 All times are UTC - 7 hours

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Scroll window and ObjectsPosted: Thu Oct 18, 2018 10:33 am

Joined: Tue Jul 01, 2014 4:02 pm
Posts: 333
Hey all. So, I've got a completely unruly routine gauging objects' placement. It has been the most maddening thing, and the wonkiness and complexity of it is still yielding edge cases I can't account for. So I'm trying to dramatically simplify so at the very least, anomalies will be easier to find.

Essentially, right now I have a 32 column area. I have a 16 bit camera position, which I can compare to an object's 16 bit position to know whether or not to give the object a draw status. This generally works, but I get the occasional edge case where the draw state flips on when the object should be firmly in the opposite nametable (one less in the high byte tan the camera position).

I also attempted to trying things with turning an object's position into a value out of 32, for a direct comparison with the camera's column. After a lot of edge case scenarios, this gave me similar unexpected false writes.

What methods do you guys use for things like this? How would you keep objects within a camera view? The 16bit idea above would be the most logical, wouldn't it?

Top

 Post subject: Re: Scroll window and ObjectsPosted: Thu Oct 18, 2018 3:14 pm

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 1037
Location: cypress, texas
Hi, our game uses 16bit square metatiles and is set up with enough RAM set aside to store 32 columns. Also, our camera, like yours, is 16bit. The crucial explanation to my question about how to keep track of metatiles exists, from tepples, at the bottom of page 69 of this thread.

It was hard for me to understand , but I spent much time rereading tepples' post over and over and then experimenting with my code trying to grasp his valid_left and visible_left. There was an end to my struggles, thankfully, after being blessed with fully grasping and implementing everything he talked about. Hope his post can help you too; tepples is so wise.

edit: Sorry, you are talking about objects... um I still haven't solved the only edge case reading problem that I still have... but, so far, the simplest way of checking an object's collision, that I've found, is to do something like this (labels beginning with + work in asm6... +skip can be changed to whatever type of label you want ):
Code:
;if you are comparing two 16 bit values:
lda column+0
eor objectX+0
bne +skip
lda column+1
eor objectX+1
bne +skip
;code to run if the two 16bit values are equal
+skip
eor works because that instruction never returns 0 unless all bits of both values are the same.
i.e.
0 xor 0 = 0
0 xor 1 = 1
1 xor 0 = 1
1 xor 1 = 0

Notice that the only results of 0 are when both bits are the same.

edit2: Sorry. Fixed misspellings from "lable" to "label". Also noticed that my code example didn't make any sense... why would we ever check object's location with camera's position... so those variable names have been updated so that it becomes helpful, I hope.

final edit: It doesn't make sense, to me, that the column should be 16bit... so I created two other variables columnLo and columnHi... and there are two translate functions that run depending on if the player is pressing left or right... each translate the column # to be drawn to columnLo and columnHi. They aren't posted here because they are very specific to our game.

Last edited by unregistered on Fri Oct 19, 2018 10:39 am, edited 2 times in total.

Top

 Post subject: Re: Scroll window and ObjectsPosted: Fri Oct 19, 2018 12:20 am

Joined: Tue Feb 07, 2017 2:03 am
Posts: 764
You must get the two values into the same space, then its trivial, just beware the tri-state of < >= you might need to handle =. You need to be very diligent and 100% check to make sure that your start values and end values are either inclusive or exclusive and never mix it up.

There is no standard, there is no "this is the way it is done", there is no I'm doing this what am I doing wrong. It is 100% abstract and is what ever rules and maths you have come up with, we can't help you with anything specific unless we see ALL of your code, and I mean all of it. Typically when I stuff something like this up, I stuff up the easy part I assume is right and get all the hard maths correct. Due to spaces being collinear with each other, you can get the case where it is actually 100% wrong, but just so happens to look right 95% of the time.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 3 posts ]

 All times are UTC - 7 hours

#### Who is online

Users browsing this forum: Google Adsense [Bot] and 7 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ NES / Famicom    NESdev    NESemdev    NES Graphics    NES Music    Homebrew Projects       2019 NESdev Competition       2018 NESdev Competition       2017 NESdev Competition       2016 NESdev Competition       2014 NESdev Competition       2011 NESdev Competition    Newbie Help Center    NES Hardware and Flash Equipment       Reproduction    NESdev International       FCdev       NESdev China       NESdev Middle East Other    General Stuff    Membler Industries    Other Retro Dev       SNESdev       GBDev    Test Forum Site Issues    phpBB Issues    Web Issues    nesdevWiki