8x16 and whatever else unreg wants to know
Moderator: Moderators
In subtractions, the carry flag acts as a "borrow flag". Setting it before a subtraction is like putting a 1 in position to be borrowed, just in case. When the subtraction takes place, and the result is less than 0, the carry is borrowed and becomes 0. So you just have to peek at the carry afterward: if it's set, the result was equal to or greater than 0 (no need to borrow), if it's clear, the result was less than 0.
A CMP is exactly like a SBC, except that you don't have to set the carry before using it and it doesn't store the result, but all the other rules of subtraction apply to CMP.
A CMP is exactly like a SBC, except that you don't have to set the carry before using it and it doesn't store the result, but all the other rules of subtraction apply to CMP.
If you subtract NUM from A, a borrow will only happen if A < NUM.unregistered wrote:I want to branch if A is not < NUM.
Code: Select all
cmp #NUM
bcs Whatever
;A is less than NUM
jmp Skip
Whatever:
;A is equal to or larger than NUM
Skip:
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
Code: Select all
-- lda ($10),y
sta currenttile
; if ((currenttile >= 15) && (currenttile < 32)) ; is solid
; lda #01b
cmp #15 ;if (currenttile >= 15)
bcc +
cmp #32 ;if (currenttile < 32)
bcs +
lda #01b ;a is solid
jmp ++done
+
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
Getting a bit closer. I am at the point, now, where I'm susposed to write the code that creates the screenArray .dsb 240. I've thought about this and have tried to make firstRow .dsb 32 and secondRow .dsb 32 contain the contents of the first and second row of tiles. Then I get really lost... somehow I'm susposed to change firstRow and secondRow into the first row of screenArray... there is the two types of collision tiles... tokumaru typed "primary" and "secondary" to me in an earlier post.
I dont understand how these pieces of the puzzle fit together... it's really far far away from me now. If you could help with a helpful arrow that could guide me closer to this task ahread of me... that would be amazing! Going tosleep now, love yall. Maybe after sleep I'll be able to make more sense with ...these ideas... maybe reread this thread again... .
I dont understand how these pieces of the puzzle fit together... it's really far far away from me now. If you could help with a helpful arrow that could guide me closer to this task ahread of me... that would be amazing! Going tosleep now, love yall. Maybe after sleep I'll be able to make more sense with ...these ideas... maybe reread this thread again... .
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
When I'm trying to read this compressed data to create the level how can I tell if the 0s mean water? I drew this all on paper trying to figure it out.tokumaru wrote:Yup, I suggested something like that. I'm usually against hardcoding logic decisions to visuals, but if done carefully it isn't necessarily bad.unregistered wrote:Could the last row of each .chr file determine if the default collision would be water? (Moving all water tiles to row F) so if the tile is F3 then it's water? Could that work? (I don't know what "index of the metatile" means. That was my guess...)
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
If I ran into these eight tiles:
They would be translated like:
and then, tepples will leave me with 11000001 and 10100001.
And so after this point I should store each of those bytes in my screenArray.
When I've completed screenArray and add gravity I will check after each move if the girl has collided with something. If that something is a solid 0001 I will have to pull her out of the solid. If that something is water.... How do I know if the something IS water? How do I check the tile number?
Code: Select all
+---+---+
|S S|S W|
|A A|S W|
+---+---+
A = Air;
W = Water;
S = Solid; thanks tokumaru
Code: Select all
+---+---+
|1 1|1 0|
|0 0|1 0|
+---+---+
And so after this point I should store each of those bytes in my screenArray.
When I've completed screenArray and add gravity I will check after each move if the girl has collided with something. If that something is a solid 0001 I will have to pull her out of the solid. If that something is water.... How do I know if the something IS water? How do I check the tile number?
One of the ideas we had consisted in using 1 bit to select between water or air for the empty tiles, and 3 bits for the type of the solid tiles. In this case it would be easy to know if something is water, but since you decided to use the tile index...unregistered wrote:How do I know if the something IS water? How do I check the tile number?
Well, your screenArray only has the basic collision info, it doesn't say which tiles each block uses. The only way is to make screenArray hold the index of the metatiles instead of the collision info. That way, whenever you wanted to test for collisions, you'd have to get the metatile index at the position you want and use that to fetch the collision info from a table. With the same index you can easily access the tile indexes too. It's a bit more indirect, but that's not too bad.
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
sooooo, thank you for helpfull words ,tokumaru wrote:Well, your screenArray only has the basic collision info, it doesn't say which tiles each block uses. The only way is to make screenArray hold the index of the metatiles instead of the collision info. That way, whenever you wanted to test for collisions, you'd have to get the metatile index at the position you want and use that to fetch the collision info from a table. With the same index you can easily access the tile indexes too. It's a bit more indirect, but that's not too bad.
Code: Select all
+---+---+
|S S|S W|
|A A|S W|
+---+---+
Code: Select all
+---+---+
|? |?+1|
| | |
+---+---+
You are using metatiles to build your maps, right? Each metatile has some info attached to it: the index of the 4 tiles it uses, its collision information and the palette it uses. If you have that index, you can access any of that information.
So, by keeping an array of metatile indexes in RAM you can access their collision information as well as the tiles that make them up, in order to decide whether the empty tiles are air or water.
So, by keeping an array of metatile indexes in RAM you can access their collision information as well as the tiles that make them up, in order to decide whether the empty tiles are air or water.
-
- Posts: 1318
- Joined: Thu Apr 23, 2009 11:21 pm
- Location: cypress, texas
I don't know how to view the info attached to each metatile. But, after asking my sister (artist who does the graphics), I remember that each name table has a metatile map of 16 columns by 15 rows. So are the metatile indexes like $1A and $00 and $EF? If so, then should I create an array something like (00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 0A, 0B, 0C, 0D, 0E, 0F, 10, 11, 12... ...EC, ED, EE, EF)?
You could arrange the metatiles in ROM kinda like this:
Here I have 3 metatiles, each using 6 bytes. If I want to get the collision info for any given tile, I can just put its index in X or Y and read it from the MetatileCollision table.
So, if your screenArray is an array of 16x15 metatile indexes, you can do something like this to read the collision info of any metatile:
Just as easily you now can use lda MetatileTile0, x to read the index of its top left tile, and the other tables to find out anything you want about the metatile in that position.
Code: Select all
MetatileTile0:
.db $00, $04, $08
MetatileTile1:
.db $01, $05, $09
MetatileTile2:
.db $02, $06, $0a
MetatileTile3:
.db $03, $07, $0b
MetatileCollision:
.db %00001010, %01001100, $00011010
MetatilePalette:
.db %10101010, %00000000, %01010101
So, if your screenArray is an array of 16x15 metatile indexes, you can do something like this to read the collision info of any metatile:
Code: Select all
;use 2 4-bit coordinates to calculate
;how far in the array the metatile is
lda metatileY
asl
asl
asl
asl
ora metatileX
tax
;get the index of the metatile
lda screenArray, x
tax
;get its collision information
lda MetatileCollision, x