TriforceOfKirbyPosted 9/5/2012 3:44:48 PM | First I would like to say thanks to everybody who helped me with my RPG, this is my first big project and I really appreciate the help, I will be posting any future questions here so I don't have to create a new topic, thanks to anyone willing to help me --- 3DS Friend Code: 1246-9643-6385 |
TriforceOfKirby (Topic Creator) Posted 9/6/2012 4:08:03 PM | My map code RESTORE @MAPDATA DIM MAP(32,24) FOR Y=0 TO 23 FOR X=0 TO 31 READ MAP X,Y NEXT NEXT FOR Y=0 TO 23 FOR X=0 TO 31 LOCATE X,Y IF MAP(X,Y)==0 THEN BGPUT 1,X,Y,36896 NEXT NEXT @MAPDATA --- 3DS Friend Code: 1246-9643-6385 |
SamKitsunePosted 9/7/2012 5:46:03 PM | It's not necessary to place the LOCATE command, because the BGPUT command does it for you. Actually, the LOCATE command is for characters, not backgrounds.
Umm . . . I have a question. What is the "36896" on the BGPUT? Are you trying the expert version of BGPUT? If so, you made a mistake. First, it's suppose to be 4-digits. Second, it's in a string. I wonder why you place that number. |
TriforceOfKirby (Topic Creator) Posted 9/7/2012 6:48:55 PM | yes I'm doing expert, and when I read the screen data for grass, it said that number, and it worked sooo yeah... --- 3DS Friend Code: 1246-9643-6385 |
TriforceOfKirby (Topic Creator) Posted 9/7/2012 6:50:47 PM | honestly I have no idea why it worked, I thought the same --- 3DS Friend Code: 1246-9643-6385 |
TriforceOfKirby (Topic Creator) Posted 9/7/2012 6:54:56 PM | and I don't know why I put LOCATE, it was in my code, I think I was going to get rid of it but I forgot, anyway it works --- 3DS Friend Code: 1246-9643-6385 |
TriforceOfKirby (Topic Creator) Posted 9/7/2012 7:09:48 PM | ok so I took out LOCATE, and also I tried reading screen data for grass again, I did this: BGPUT 0,0,0,32,9,0,0 BGREAD(0,0,0),SC PRINT SC and it gave me that same number so I did: ACLS:CLEAR BGPUT 0,0,0,'that# can't remember the exact# and it worked, could somebody explain that? --- 3DS Friend Code: 1246-9643-6385 |
ChangeVPosted 9/7/2012 8:07:04 PM | Range of BG tile/chracter number is 0~1023. Total 1024 tiles.
36896 divided by 1024 has 32 as a remainder.
PRINT 36896 % 1024
I believe, BGPUT command treats 36896 as 32. |
SamKitsunePosted 9/7/2012 8:42:55 PM | I was correct about the LOCATE. You don't need it.
As for the "36896" value, apparently, BGPUT accepts numeric values, because it will translates into a hexadecimal value. As it turns out, "36896" in hex is "9020", which is exactly the string used to make the grass tile. If you were to do it as a hex value, it would look like this.
BGPUT 1,X,Y,"9020"
I'll explain about the screen data. b00-09 is the character number, b10 is the horizontal flip, b11 is the vertical flip, and b12-15 is the palette number. To make the grass tile with no flips and a palette of 9, the character number is 32. If you understand bitwise, 32 is exactly b05. Since there are no flips, we ignore them. For the last four bits, b12-15, it's just like the character number, except easier. The palette is 9, therefore, it's a combination of 8 and 1. In this case, we use b12 and b15.
If we lined the bit values up, it would look like this, from right to left, of course.
1001 0000 0010 0000
Of course, we need to translate it into hex. Easy. Each of the four bits represents one hex value, from right to left. They are also in power of two. It would look like this.
8421
To make it easier to understand, look at what we do in order to translate it.
1001 0000 0010 0000 8001 0000 0020 0000 8+0+0+1 0+0+0+0 0+0+2+0 0+0+0+0 9020
As for how we get a numeric value out of the hex is a matter of math. Hex is a power of 16. The first digit is just the number value, the second digit is the value times 16, the third is the value times 256, and the fourth is the value times 4096. The fourth digit is 9, so 9*4096 is 36864. The second digit is 2, and so, 2*16 is 32. Combine them, and you will get the numeric value, 36896. Cool, right?
Of course, you don't have to do all of this. You can just use the string hex value to make it easy. |
TriforceOfKirby (Topic Creator) Posted 9/7/2012 9:19:57 PM | thanks, btw so should I use the hex string or the number? the number is 1 less character but will using the hex use less data? btw I know how to convert from decimal to binary to hexidecimal, but thanks anyways for the explanation --- 3DS Friend Code: 1246-9643-6385 |