(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
06-16-24 01:19 PM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - VB6 Overflowing NES rendering...
  
User name:
Password:
Reply:
 
Options: - -
Quik-Attach:
Preview for more options

Max size 1.00 MB, types: png, gif, jpg, txt, zip, rar, tar, gz, 7z, ace, mp3, ogg, mid, ips, bz2, lzh, psd

UserPost
Guy Perfect
Posts: 278/451
Yeah, there's also a lot of places that think "Dim X, Y, Z As Integer" will create three Integer variables when it will actually create one Integer and two Variants. Another thing to watch out for.
Dan
Posts: 141/219
I stand corrected. Although there are a lot of websites out there that believe that arrays are defaulted to one-based.
wboy
Posts: 12/15
Originally posted by BGNG
Default is 0. If you say something like "Dim Array(5) As Integer" then the indexes will be 0 through 4.


Yes the default base is 0, although the declaration in your example will actually have the indexes 0 thru 5. Lbound to UBound confirms this.

If you declare "Option Base 1", then the indexes will be 1 thru 5, so the only way (I know of) in VB6 to declare a variable to have 0 thru 4 indexes is "Dim Array(0 to 4) As Integer" which would also effectively ignore the set Option Base even if it was set to 1.
Guy Perfect
Posts: 277/451
Default is 0. If you say something like "Dim Array(5) As Integer" then the indexes will be 0 through 4.
Dan
Posts: 140/219
I believe the default is one-based. Whoever thought that one (or the whole feature of being able to set a start index for an array) up needs shot.
HyperHacker
Posts: 1876/5072
You can choose in VB whether you want zero- or one-based, but I'm not sure what the default is. Also, check the Scale property of your PictureBox; it needs to be set to Pixels. I dunno WTF Twips are, but they're not very useful.
Disch
Posts: 177/202
From what I found on MSDN it looks like PSet is supposed to have a "flags" parameter before you give it the X,Y coords. Although that page doesn't seem to give you valid values for the flag... it just says it's a "keyword", whatever the hell that means.

Or maybe it's something else silly, like VB using "twips" or whatever instead of actual pixels? Who freaking knows.

You're on your own from here... I can't help anymore since the rest is VB-specific crap. But those calculations you're using to decode NES 2bpp are correct. I'm certain of that.

EDIT -- unless VB doesn't zero-base array indecies? I'm under the assuption it would, but you never know.

Palette2BPP( 0 ) <-- should be the first element in the array
Palette2BPP( 1 ) <-- should be the second -- not the first (dunno if VB treats this as the first or not?)

If I'm wrong on that assumption, you'll have to add an additional 1 to all those. IE:

((a / 128) And 1) + ((b / 64) And 2) + 1

I find that unlikely though -- but with VB you never know....
Arthus
Posts: 97/142
OK, I'm using the PSet method, and i'm still getting the same result:

Public Sub PaintTile(Buffer As PictureBox)

Palette2BPP = Array(RGB(255, 255, 255), RGB(255, 0, 0), RGB(0, 255, 0), RGB(0, 0, 255))

Dim a As Byte
Dim b As Byte
Dim y As Integer

For y = 0 To 7
offset = 201744

a = romdata(offset + y)
b = romdata(offset + y + 8)
Buffer.PSet (0, y), Palette2BPP(((a / 128) And 1) + ((b / 64) And 2))
Buffer.PSet (1, y), Palette2BPP(((a / 64) And 1) + ((b / 32) And 2))
Buffer.PSet (2, y), Palette2BPP(((a / 32) And 1) + ((b / 16) And 2))
Buffer.PSet (3, y), Palette2BPP(((a / 16) And 1) + ((b / 8) And 2))
Buffer.PSet (4, y), Palette2BPP(((a / 8) And 1) + ((b / 4) And 2))
Buffer.PSet (5, y), Palette2BPP(((a / 4) And 1) + ((b / 2) And 2))
Buffer.PSet (6, y), Palette2BPP(((a / 2) And 1) + (b And 2))
Buffer.PSet (7, y), Palette2BPP((a And 1) + ((b * 2) And 2))

Next

End Sub
HyperHacker
Posts: 1869/5072
Hm, that does sound better. I'll have to try that next time I do something GDI-related.
Disch
Posts: 172/202
Originally posted by HyperMackerel
Ideally you'd use CreateCompatibleBitmap, CreateDC, BitBlt and SetPixel to draw tiles. A bit more complex, but hundreds of times faster than anything built into VB.


CreateDIBSection + CreateCompatibleDC + BitBlt = win

CreateDIBSection is super mega-awesome.
HyperHacker
Posts: 1866/5072
Ideally you'd use CreateCompatibleBitmap, CreateDC, BitBlt and SetPixel to draw tiles. A bit more complex, but hundreds of times faster than anything built into VB.
Disch
Posts: 170/202

VB is only as stupid as the one who insults it.


The sentence you are reading right now is a lie.

And 1000 other paradoxes.



Word @ Dan

On the major note: thanks for pointing out PSet, BGNG -- I knew there had to be some way to set a pixel -- that Line method was super insane mega-crazy
Dan
Posts: 138/219
Originally posted by BGNG
Disch:
VB is only as stupid as the one who insults it.

I guess that makes me stupid then, because VB sucks complete and utter balls. Having used it for a good few years, and having used other alternatives for another few years I definitely feel qualified to say that. Quite why people still use it, when there are far better (free) things out there to use, I don't know.
Guy Perfect
Posts: 272/451
Arthus:
Use the PSet method to draw individual pixels as opposed to the Line method.

Disch:
VB is only as stupid as the one who insults it.
Disch
Posts: 169/202
((a / 128) And 1) + ((b / 64) And 2) <--- this will equate to 0-3

Palette2BPP( ((a / 128) And 1) + ((b / 64) And 2) ) <--- this will use that 0-3 to index an array, which will give you a color value (those large numbers you're getting).

If you wanted to break this into several steps you could say:




tmp = ((a / 128) And 1) + ((b / 64) And 2) ' tmp = 0-3
color = Palette2BPP( tmp )                 ' color is now our desired RGB color value
Buffer.Line (0, y)-Step(1, 1), color       ' output that color




That's exactly the same, just broken into smaller steps.

(sorry about all the edits -- so many minor corrections and spacing issues)
Arthus
Posts: 94/142
But shouldn't they be outputting 0-3 instead of 65280-1677215?
Disch
Posts: 168/202
Originally posted by Arthus
Which means, It should output something similar to that, but before I change the colors to match it the same as the desired pixel.


Ah. Okay, whoops


And the functions I was refering to were these:
Palette2BPP( ((a / 128) And 1) + ((b / 64) And 2) )


Yeah that isn't a function. 'Palette2BPP' should be an array, and unless I'm mistaken, VB uses parenthesis to surround the index to the array.

All that "a/128 And ..." crap is just a bunch of math that will boil down to a single number (0-3) which indexes the Palette2BPP array. It shouldn't be calling any function.


And they are now not returning 0. They are returning numbers like 1677215 and 65280...


Okay -- that sounds about right. Those big numbers should be your colors (65280 is &HFF00 -- your green)
Arthus
Posts: 93/142
You misread my wording:
"I get the attached with what it should be (once I change the colors)"

Which means, It should output something similar to that, but before I change the colors to match it the same as the desired pixel.

And the functions I was refering to were these:
Palette2BPP( ((a / 128) And 1) + ((b / 64) And 2) )

And they are now not returning 0. They are returning numbers like 1677215 and 65280...

Also, i'll look into a put pixel or somthing...
Disch
Posts: 167/202
Well that is some pretty strange output....

Originally posted by Arthus
OK, with some modifications, it seems with teh 1,2,3 it keept on adding on. So just ading 1 was just fine like so:

Buffer.Line (0, y)-Step(1, 1), Palette2BPP( etc...
Buffer.Line (1, y)-Step(1, 1), Palette2BPP( etc...



Okay -- that seems to make more sense after re-reading that page you linked about Line

I swear though... isn't there a PutPixel() function or SetPixel or something? This line drawing is complete insanity.


With that, I get the attached with what it should be (once I change the colors)


Well... wait... the colors should be in your Palette2BPP array. That's why it's there.


I also might add that all those Pallette2BPP functions return a 0.


functions? I thought that was how you made an array.

Palette2BPP( 0 ) should be giving you your first color, Palette2BPP( 1 ) should be giving you your second, etc. The whole math with 'a' and 'b' and all that dividing and bitwork just produces a number from 0-3 which represents the pixel to output. From there, I just used that to index the palette array to output the desired color for that pixel. Or at least, that's what I was trying to do.

Also note that this will only create an 8x8 pixel image (1 tile, no stretching) -- the "desired" image you attached was actually 32x32 pixels (4 tiles, 2x stretching)
Arthus
Posts: 92/142
OK, with some modifications, it seems with teh 1,2,3 it keept on adding on. So just ading 1 was just fine like so:

Buffer.Line (0, y)-Step(1, 1), Palette2BPP( etc...
Buffer.Line (1, y)-Step(1, 1), Palette2BPP( etc...

With that, I get the attached with what it should be (once I change the colors)

I also might add that all those Pallette2BPP functions return a 0.
This is a long thread. Click here to view it.
Acmlm's Board - I3 Archive - Programming - VB6 Overflowing NES rendering...


ABII

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

Page rendered in 0.011 seconds; used 368.62 kB (max 432.28 kB)