(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
05-14-24 09:23 PM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - Visual BASIC 6 Help New poll | |
Add to favorites | Next newer thread | Next older thread
User Post
interdpth

Mole
MZM rapist


 





Since: 11-18-05

Last post: 6295 days
Last view: 6294 days
Posted on 01-30-06 09:26 PM Link | Quote
Ok well i'm working on a map editor and I got the data and everything but I can't seem to make a decent drawing loop to save my life. This works and displays the tiles but it doesn't display the tile correctly instead of blitting them right to left then down it blits the tiles Diagonally. So here's my code if anyone minds helping
Samp(0 to 1023)' There's data in here already
Get #12, TSA - &H8000000 + 1,Samp()
Counter = 0
DestX = DestY = 0
For i = 0 To 128
For x = destX To destX + 1
For y = destY To destY + 1
''''''''''''''''''''''''''''''''''
tile1 = Samp(Counter) And Not &HFF00

'''''''''''''''''
tile2 = Samp(Counter + 1) And Not &HFF00

'''''''''''''''''
tile3 = Samp(Counter + 2) And Not &HFF00

'''''''''''''''''
tile4 = Samp(Counter + 3) And Not &HFF00

'''''''''''''''''
'Tile1 for the block
BitBlt picMap.hdc, x * 8, y * 8, 8, 8, picTileSet.hdc, tile1 \ 8, tile1 Mod 8, vbSrcAnd
'tile2
BitBlt picMap.hdc, (x * 8) + 1, y * 8, 8, 8, picTileSet.hdc, tile2 \ 8, tile2 Mod 8, vbSrcAnd
'tile3
BitBlt picMap.hdc, (x * 8), (y * 8) + 1, 8, 8, picTileSet.hdc, tile3 \ 8, tile3 Mod 8, vbSrcAnd
'tile4
BitBlt picMap.hdc, (x * 8) + 1, (y * 8) + 1, 8, 8, picTileSet.hdc, tile4 \ 8, tile4 Mod 8, vbSrcAnd
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

''''''''''''''''''''''''''''''''''

Next y
Next x
picMap.Refresh
Counter = i + 3
destX = destX + 1
destY = destY + 1
Next i
Guy Perfect









Since: 11-18-05

Last post: 6297 days
Last view: 6295 days
Posted on 01-30-06 11:11 PM Link | Quote
Compound assignments are not allowed in VB. What you have going is this:

DestX = DestY = 0

The first = is understood to be an assignment, but the second = is understood to be equality. The equivalent of what you're saying, in C, is "DestX = DestY == 0;", which isn't what you want.

All you end up doing is setting DestX to True, not 0. Numerically, this would mean that DestX = -1. So when you say "For x = destX To destX + 1", you're actually saying "For x = -1 To 0"

To correct this problem, seperate the two statements like this:

DestX = 0: DestY = 0



All VB data types (except for Byte) are signed, so &HFF00 is actually -256 since 16 bits fits in an Integer variable and gets converted to signed thusly. Use the typecasting character & after the hex number to force the compiler to interperate the literal as a Long and not an Integer. Doing so will yeild the value 65280, which is what you will need for your bitwise calculations. Use it in this form:

&FF00&

Additionally, the way you're using it is "And Not &HFF00"... This may be done to combat the negation, but if not, you could use "And &HFF" to get the same result.



The math you're using for the destination X and Y of BitBlt is a bit incorrect. What you have is this:

(x * 8) + 1, (y * 8) + 1

Where what you want is this:

(x + 1) * 8, (y + 1) * 8

This will ensure that tiles are blitted on an 8-pixel boundary. What you had was only moving the destination by 1 pixel in each direction.



If I understand correctly what you're trying to do, you want to read the tile at the (X, Y)th index in the source DC. The code for that you have is as such:

Tile1 \ 8, Tile1 Mod 8

I don't know if this is correct or not, but instinct tells me you're probably gonna need something else. I suggest this:

(Tile1 \ 8) * 8, (Tile1 Mod 8) * 8

I also feel that use of the Integer Division operator is somewhat extraneous, so I recommend using Int(Tile1 / 8) * 8, but that's your call.



For blitting, use SRCCOPY instead of SRCAND, since a straight blit with SRCAND will only look correct on a white background.



You're calling the locations of the coordinates from a file buffer and incrementing the accumulator by 3 plus the current pass number, as such:

Counter = I + 3

What you probably want to do is have it read data sequentially from start to finish. And since you're reading 4 tiles, you'll need to compensate for 4 bytes. Thus, you should increment the counter by 4 each pass:

Counter = Counter + 4



The reason your tiles are blitting diagonally is because you're incrementing DestX and DestY at the same time:

DestX = DestX + 1
DestY = DestY + 1


In order to go from left to right, top to bottom for 1024 bytes (assuming a square map), you would have to have 32 passes for Y, and within there, 32 passes for X. Like this example:
For Y = 0 To 31
For X = 0 To 31
'Do stuff
Next
Next
It appears as though your tiles are being copied in 2x2 squares to the destination, so your loops would have to compensate for that with a little extra math:
For Y = 0 To 30 Step 2
For X = 0 To 30 Step 2
'Do stuff
Next
Next


To sum it all up, I've prepared a tentative drawing routine for you. I do not know if this will work properly, as I cannot test it. But even if it doesn't, you have something a little more tidy to work off of:

Samp(0 To 1023) ' There's data in here already
Get #12, TSA - &H8000000 + 1, Samp()
Counter = 0

For Y = 0 To 30 Step 2
For X = 0 To 30 Step 2
'Get source tile coordinates (I assume)
Tile1 = Samp(Counter) And &HFF
Tile2 = Samp(Counter + 1) And &HFF
Tile3 = Samp(Counter + 2) And &HFF
Tile4 = Samp(Counter + 3) And &HFF

'Blit tiles
BitBlt picMap.hDC, X * 8, Y * 8, 8, 8, picTileSet.hDC, _
(Tile1 \ 8) * 8, (Tile1 Mod 8) * 8, vbSrcCopy
BitBlt picMap.hDC, (X + 1) * 8, Y * 8, 8, 8, picTileSet.hDC, _
(Tile2 \ 8) * 8, (Tile2 Mod 8) * 8, vbSrcCopy
BitBlt picMap.hDC, X * 8, (Y + 1) * 8, 8, 8, picTileSet.hDC, _
(Tile3 \ 8) * 8, (Tile3 Mod 8) * 8, vbSrcCopy
BitBlt picMap.hDC, (X + 1) * 8, (Y + 1) * 8, 8, 8, picTileSet.hDC, _
(Tile4 \ 8) * 8, (Tile4 Mod 8) * 8, vbSrcCopy

Counter = Counter + 4
Next
Next



(edited by BGNG on 01-30-06 10:19 PM)
interdpth

Mole
MZM rapist


 





Since: 11-18-05

Last post: 6295 days
Last view: 6294 days
Posted on 01-30-06 11:41 PM Link | Quote
BGNG i must say thank you so much. It's almost done but there's 1 problem. It's drawing the tiles only in the corners so how would I make it so the tiles go else where that's what the main Diagonal problem was.
Guy Perfect









Since: 11-18-05

Last post: 6297 days
Last view: 6295 days
Posted on 01-30-06 11:47 PM Link | Quote
Could you post a screenshot showing the problem?
interdpth

Mole
MZM rapist


 





Since: 11-18-05

Last post: 6295 days
Last view: 6294 days
Posted on 01-31-06 01:08 AM Link | Quote
Ok well here's what the code you gave me does

The code works fine for 1 block other then the fact I need to add tile filpping but anyhow

I need it so it blits more then 1 block to the picture box there should 128 blocks total. So that what I need to know.
Guy Perfect









Since: 11-18-05

Last post: 6297 days
Last view: 6295 days
Posted on 01-31-06 01:56 AM Link | Quote
Looking at the code again, there should be a full 256×256 image blitted to the destination DC. Looking at the picture, that's not how it is.

An easy way to verify if things are working correcly is to add the following line:

Tile1 = 0: Tile2 = 0: Tile3 = 0: Tile4 = 0

Before the line:

'Blit tiles

...That should cause the same tile to be drawn over and over again. Try that, and tell me if it works or not.
interdpth

Mole
MZM rapist


 





Since: 11-18-05

Last post: 6295 days
Last view: 6294 days
Posted on 01-31-06 02:02 AM Link | Quote
Yeah it's doing that fine but what i meant is this is for the TSA portion of the map data so I need more blocks then just the one. by block 4 2x2 tiles make up a block so yeah, thanks a bunch
Guy Perfect









Since: 11-18-05

Last post: 6297 days
Last view: 6295 days
Posted on 01-31-06 02:37 AM Link | Quote
If it did draw the same tile over and over with that suggestion, then the image blitter is working properly and there's a problem with your TSA data or perhaps how you're loading it into the source picture box. (Perhaps the \ 8 and Mod 8 should be 16's instead of 8's?)
interdpth

Mole
MZM rapist


 





Since: 11-18-05

Last post: 6295 days
Last view: 6294 days
Posted on 01-31-06 09:53 PM Link | Quote
Ok, what I meant was that it draws all the tiles in the same part of the dest DC I need it to blit to different X and Y's instead of (0,0) (0,8) (8,0) and (8,8) all the tiles are getting blitted correctly but they all get blitted to the same coords on the destination
Guy Perfect









Since: 11-18-05

Last post: 6297 days
Last view: 6295 days
Posted on 01-31-06 11:32 PM Link | Quote
Oh, I see what you mean. That's an easy fix. Come to think of it, that's probably what DestX and DestY were for.

Yeah, just define some arbitrary values for X and Y translation and add them to the destination X's and Y's when you blit. That will enable you to put the data anywhere you please. "X * 8" will become "X * 8 + DestX" and so-forth.



Here's Tentative Drawing Routine Take 2. Just change the values of DestX and DestY to move the final blitting coordinates:

Samp(0 To 1023) ' There's data in here already
Get #12, TSA - &H8000000 + 1, Samp()
Counter = 0

DestX = 0
DestY = 0

For Y = 0 To 30 Step 2
For X = 0 To 30 Step 2
'Get source tile coordinates (I assume)
Tile1 = Samp(Counter) And &HFF
Tile2 = Samp(Counter + 1) And &HFF
Tile3 = Samp(Counter + 2) And &HFF
Tile4 = Samp(Counter + 3) And &HFF

'Blit tiles
BitBlt picMap.hDC, X * 8 + DestX, Y * 8 + DestY, 8, 8, picTileSet.hDC, _
(Tile1 \ 8) * 8, (Tile1 Mod 8) * 8, vbSrcCopy
BitBlt picMap.hDC, (X + 1) * 8 + DestX, Y * 8 + DestY, 8, 8, picTileSet.hDC, _
(Tile2 \ 8) * 8, (Tile2 Mod 8) * 8, vbSrcCopy
BitBlt picMap.hDC, X * 8 + DestX, (Y + 1) * 8 + DestY, 8, 8, picTileSet.hDC, _
(Tile3 \ 8) * 8, (Tile3 Mod 8) * 8, vbSrcCopy
BitBlt picMap.hDC, (X + 1) * 8 + DestX, (Y + 1) * 8 + DestY, 8, 8, picTileSet.hDC, _
(Tile4 \ 8) * 8, (Tile4 Mod 8) * 8, vbSrcCopy

Counter = Counter + 4
Next
Next



(edited by BGNG on 02-04-06 10:21 AM)
interdpth

Mole
MZM rapist


 





Since: 11-18-05

Last post: 6295 days
Last view: 6294 days
Posted on 01-31-06 11:57 PM Link | Quote
Thanks, man thanks a whole lot! You will definently be credited, and if you want you can even beta my metroid zero mission editor next month.
Guy Perfect









Since: 11-18-05

Last post: 6297 days
Last view: 6295 days
Posted on 02-01-06 12:27 AM Link | Quote
All in a day's work. And I'll pass on the beta-ing. I've got enough going on here on my end that more probably wouldn't work out too well.


(edited by BGNG on 05-01-06 04:35 PM)
(edited by BGNG on 05-01-06 04:35 PM)
(edited by BGNG on 05-01-06 04:37 PM)
Add to favorites | Next newer thread | Next older thread
Acmlm's Board - I3 Archive - Programming - Visual BASIC 6 Help |


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.037 seconds; used 413.59 kB (max 513.62 kB)