8x16 and whatever else unreg wants to know

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

3gengames wrote:In games that use 16x16 pixel blocks, or 2x2 tiles, you can put ANY block there. But if you do a 1 tile per byte way, you won't be able to put pretty much any type of tile except one of the same colors, making it difficult to have an advantage at all of not using 2x2 tiles.
Still dont understand... :? But it's ok. The advantage of not using 2x2 tiles is that the level creater can make thinner walls! :D

tokumaru wrote:
unregistered wrote:
3gengames wrote:Well, 16x16 is used because 1 tile is SMALL. And, then, most tiles you won't be able to put because of color differences,
What? :?
He said that because the NES uses the same palette for all tiles in a 16x16-pixel area. If you try to put tiles that use different palettes in the same 16x16-pixel area you'll have problems.
Oh ok, yes that makes sense. :) Thank you. :)

tokumaru wrote:
ok I've beeen thinking. Maybe I could use 2x2tiles for collision and break each byte up into 4 parts..... 1 part for each tile. That may work... 4 different collision blocks.
That would give you 4 different collision attributes... In my opinion that's too little, but could work in a simple game. Two types are mandatory: "empty" and "solid", and you have 2 left to choose from "water", "lava" (or anything that hurts), "platform" (only solid at the top), "conveyor belt", and so on. If your game can get away with only 4 -types, that's OK, but many games need more.
Um, I think our game could use just 4... maybe. Thanks for this great explanation tokumaru! It helps me understand better about what to do. :)
tokumaru wrote:
There are rocks that need to be destroyed... Could those be sprites instead of counting as one of the collision blocks?
If you don't need many of them aligned horizontally, then yes, using sprites would be more convenient. If there are too many destructible blocks though, the sprite limitations will get in the way.
YEAY!!! Thank you God's son! And thank you tokumaru! :D
tokumaru wrote:
ha! I'm not even sure what the attribute bytes do... :?
Attribute bytes select which palettes are used for the background tiles. Each byte defines the 4 palettes used in a 32x32-pixel area, one palette for each 16x16-pixel area. The good thing about using 32x32-pixel blocks is that you don't have to do any sort of attribute byte manipulation, you can just copy attribute bytes straight to the attribute tables (as long as you don't scroll vertically).
Will tell my sister; thanks tokumaru! :) This is interesting.
Last edited by unregistered on Fri Sep 16, 2011 2:00 pm, edited 4 times in total.
3gengames
Formerly 65024U
Posts: 2284
Joined: Sat Mar 27, 2010 12:57 pm

Post by 3gengames »

2x2 tiles can go in any order, if you use 1 tile, then you can't put any of a different tile inside an attribute, aka you can't give each one a color, you'll still have to use ones colored for that one.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

Code: Select all

    screenArray .dsb 240
    firstRow .dsb 32

    ldy #$00
    ldx #$04
   
;-   sta screenArray,x  this line is pointless right now
    lda #<bg
    sta $10
    lda #>bg
    sta $11
-   lda ($10),y
    ;if a is "solid" then we mark the first tile '01'
    ;else if a is "empty" then we mark the first tile '00'  
    ;else if a is "water" then we mark the first tile '11'
    ;else a is "_4" so mark the first tile '10'
	
    sta firstRow,x
	
      txa ;<-- transfer (x)firstRow into a
      pha ;<-- push a on stack
	
	
    iny
    bne -
    inc $11
       ;we need x to keep track of the pointer used with firstRow	
    dex
	  ;we also need that dex counter x value to end this loop
    bne -
Ok, I need help with this... :?
...so I wanted to then pla (pull the counter x from the stack) and then tax (transfer a to x) and I can't because I just pushed the other x value on the stack. My stack skills are very poor... they can only improve... what is the correct way to handle this? :) Pleaes explain. Goodnight.
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Post by thefox »

unregistered wrote:
3gengames wrote:In games that use 16x16 pixel blocks, or 2x2 tiles, you can put ANY block there. But if you do a 1 tile per byte way, you won't be able to put pretty much any type of tile except one of the same colors, making it difficult to have an advantage at all of not using 2x2 tiles.
Still dont understand... :? But it's ok. The advantage of not using 2x2 tiles is that the level creater can make thinner walls! :D
Not exactly true, no matter what size of metatiles you use, you can always have walls that are 8 pixels wide (or even thinner). It all depends on how you're handling collisions, not the actual graphical contents of the metatile/tiles. In this sense it's best to think of metatiles simply as a method of compression.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

thefox wrote:
unregistered wrote:
3gengames wrote:In games that use 16x16 pixel blocks, or 2x2 tiles, you can put ANY block there. But if you do a 1 tile per byte way, you won't be able to put pretty much any type of tile except one of the same colors, making it difficult to have an advantage at all of not using 2x2 tiles.
Still dont understand... :? But it's ok. The advantage of not using 2x2 tiles is that the level creater can make thinner walls! :D
Not exactly true, no matter what size of metatiles you use, you can always have walls that are 8 pixels wide (or even thinner). It all depends on how you're handling collisions, not the actual graphical contents of the metatile/tiles. In this sense it's best to think of metatiles simply as a method of compression.
Ok, wow... thank you thefox! :D
edit: So does that mean it is possible to use 2x2 compression with more than 2 bits for the collision blocks and still have 8 pixel (or thinner) wide walls? How could I do that? I am betting I need more experience in order to understand that... ok. :)
Last edited by unregistered on Sat Sep 17, 2011 4:07 pm, edited 1 time in total.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

Since you plan to have collision information for each of the 4 tiles in a 16x16-pixel block, you can very well make the left half "solid" and the right half "empty", which will result in a wall that's 8 pixels wide.

I can't really comment on the code you posted, because I don't know what you are trying to achieve with it.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

tokumaru wrote:Since you plan to have collision information for each of the 4 tiles in a 16x16-pixel block, you can very well make the left half "solid" and the right half "empty", which will result in a wall that's 8 pixels wide.
!!! Brilliant! :D But I would still be limited by only having 4 collision block types. Which is perfectly good... thats what God says. :) And I totally agree. :)
tokumaru wrote:I can't really comment on the code you posted, because I don't know what you are trying to achieve with it.
I'm not trying to achieve much... it is a bit like working out the logic... I need another index register, i think, so I can keep track of three variables. But there isn't another index register... so I thought mabye it would be time to use the stack to switch between the 2 index-x-values. : )
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

unregistered wrote:But I would still be limited by only having 4 collision block types. Which is perfectly good... thats what God says. :) And I totally agree. :)
I have noticed you like to mention God a lot, but now you're kinda pushing it, aren't you? Somehow I doubt God has ever said that 4 collision types are enough in a NES game. I'm not a religious person at all, but doesn't that classify as "using the Lord's name in vain"?
tokumaru wrote:I need another index register, i think, so I can keep track of three variables. But there isn't another index register... so I thought mabye it would be time to use the stack to switch between the 2 index-x-values. : )
I the stack is giving you trouble, just use temporary RAM locations for the registers you need to swap.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

tokumaru wrote:
unregistered wrote:But I would still be limited by only having 4 collision block types. Which is perfectly good... thats what God says. :) And I totally agree. :)
I have noticed you like to mention God a lot, but now you're kinda pushing it, aren't you? Somehow I doubt God has ever said that 4 collision types are enough in a NES game. I'm not a religious person at all, but doesn't that classify as "using the Lord's name in vain"?
No, it's by God's grace that he allows me to have a relationship with him. He loves each of us much... so much! :D He's my best friend and he waits to help you and me... each of us! :D So, now that you know about him loving us, as I was thinking what to say he inserted the thought "perfectly good" in my head and I typed it out. And I thought about how he helped me with the using 4 objects idea and of how this game doesn't require more than 4 of them. And so I kept it there and returned later to add "And I totally agree." because after going through all of that I wanted to. :)

I'm sorry it came across as confusing. :(
tokumaru wrote:
tokumaru wrote:I need another index register, i think, so I can keep track of three variables. But there isn't another index register... so I thought mabye it would be time to use the stack to switch between the 2 index-x-values. : )
I the stack is giving you trouble, just use temporary RAM locations for the registers you need to swap.
Yes! tokumaru, thank you, this thought ran through my head earlier and I cast it aside, for bringing it back to me. :) : )
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

It's still possible to get a resolution of 8x8 pixels for collision, have one byte per unique metatile, and have more than three different collision responses.

Code: Select all

76543210
||||||||
||||++++- Collision response class for 8x8 spaces that are full
||||      (e.g. solid, platform, water, hurt floor, conveyor, pieces of slope)
|||+----- 0: Top left is empty; 1: full
||+------ 0: Top right is empty; 1: full
|+------- 0: Bottom left is empty; 1: full
+-------- 0: Bottom right is empty; 1: full
Or did you plan on having multiple collision responses (other than air+something else) in one metatile?
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

That's an interesting idea, tepples. 16 types of responses should be enough for everything, and you can still make any of the 4 tiles empty. Pretty clever.

Slopes might need more information though, which could come from the tile's index. I would probably put all the slopes at the beginning of the tileset, and whenever a slope is found the index of the tile would be used as an index into the table of height maps.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

Wow, tepples yes interesting and extra brilliant!! Thank you so much! :D
Tomorrow is going to be so much fun! No, I dont remember having multiple collision tiles under 1 metatile. Will tell my sister.

tokumaru, great to read about your words about slopes... I don't know if slopes are going to be a part of our game... maybe they'll make it into the last 3 incomplete levels! :D Hope they do so we can try your suggestion. Thanks! :) I'm so tired... mustsleep. good night.

edited
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

tepples, im still awake. : ) Um, well, your suggestion is extra brilliant! :) But, I dont think it will work for us :( because there are many places with water and wall under the same metatile... like you said, parts other than solid or air. I'm still happy, thank you it is really a wonderful idea. :) Ok to sleep. good night.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Post by tokumaru »

unregistered wrote:tepples, im still awake. : ) Um, well, your suggestion is extra brilliant! :) But, I dont think it will work for us :( because there are many places with water and wall under the same metatile... like you said, parts other than solid or air.
Can't you just arrange the metatiles some other way? For example, instead of doing this (which you can't, because Water and Solid can't be in the same metatile):

Code: Select all

+---+
|A A|
|A A|
+---+
|W W|
|S S|
+---+

A = Air;
W = Water;
S = Solid;
You can do this (which has the exact same effect, it's just aligned differently):

Code: Select all

+---+
|A A|
|W W|
+---+
|S S|
|S S|
+---+
I really can't think of many cases where you'd absolutely need 2 different kinds of collisions in the same metatile. I'm pretty sure that in 99% of the cases the level design can be slightly altered to match the limitations.
unregistered
Posts: 1318
Joined: Thu Apr 23, 2009 11:21 pm
Location: cypress, texas

Post by unregistered »

tokumaru wrote:
unregistered wrote:tepples, im still awake. : ) Um, well, your suggestion is extra brilliant! :) But, I dont think it will work for us :( because there are many places with water and wall under the same metatile... like you said, parts other than solid or air.
Can't you just arrange the metatiles some other way? For example, instead of doing this (which you can't, because Water and Solid can't be in the same metatile):

Code: Select all

+---+
|A A|
|A A|
+---+
|W W|
|S S|
+---+

A = Air;
W = Water;
S = Solid;
You can do this (which has the exact same effect, it's just aligned differently):

Code: Select all

+---+
|A A|
|W W|
+---+
|S S|
|S S|
+---+
I really can't think of many cases where you'd absolutely need 2 different kinds of collisions in the same metatile. I'm pretty sure that in 99% of the cases the level design can be slightly altered to match the limitations.

This must be part of the 1%. :(

Code: Select all

+---+
|W W|
|W W|
+---+
|S S|
|W W|
+---+
|W W|
|W W|
+---+
Thank you though. :D I'll tell my sister what you've said... when she wakes up.
Post Reply