(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-18-24 03:45 AM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - VB6 Overflowing NES rendering... New poll | |
Pages: 1 2 3Add to favorites | Next newer thread | Next older thread
User Post
Disch

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6578 days
Last view: 6578 days
Posted on 05-01-06 11:20 AM Link | Quote
Well what are you trying? I'm under the impression that you don't understand my example at all, and are just trying to copy/paste/VB-ify it rather than actually transpose it... which means you're more or less guessing (which of course will lead to "it's not working what do I do now" 99% of the time)

Let's try this the other way -- how are you outputting pixels? I take it it has something to do with that "Buffer.Line" function. But I can't make heads or tails of anything after that. What is this "Step" thing? What is that "BF" for? Nothing even remotely resembling that was in my example.

If you can show me the following:

1) how to make a 4-entry array of colors
2) how to output a single red pixel at given x,y coords

Then I can make a more detailed example for you.


(edited by Disch on 05-01-06 10:22 AM)
Arthus

140


 





Since: 11-17-05
From: Australia

Last post: 6510 days
Last view: 6510 days
Posted on 05-01-06 12:03 PM Link | Quote
Here is an 4-entry array of colors, I assumed an array that has 4 values which are colors. And how to draw a pixel to a box.

' Dims name for array
Dim Pallette2BPP(0 To 3) As Long
' Puts value in array
Pallatte2BPP = Array(RGB(255, 255, 255), RGB(255, 0, 0), RGB(0, 255, 0), RGB(0, 0, 255))
' Makes actual pixel
pic_tiles(0).Line (1, 1)-Step(1, 1), Pallette2BPP(0)


The "BF" means "box", and "filled". Which allows you to make a fully colored box using the color you specify. Here is a more detailed look at the use of the ".Line" statement.
Disch

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6578 days
Last view: 6578 days
Posted on 05-01-06 12:17 PM Link | Quote
Good God... you mean you're actually drawing whole LINES for each pixel? What ever happened to good old-fashioned pixel plotting . Ah well I guess that's VB for ya.

Anyway.. .for a more clear example:




Dim Palette2BPP(0 To 3) As Long

Palette2BPP = Array( ... ' Left this part out -- put in your colors here

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

For y = 0 To 7

a = romdata(offset + y)
b = romdata(offset + y + 8)

Buffer.Line (0,y)-Step(0,y), Palette2BPP( ((a / 128) And 1) + ((b / 64) And 2) )
Buffer.Line (1,y)-Step(1,y), Palette2BPP( ((a / 64) And 1) + ((b / 32) And 2) )
Buffer.Line (2,y)-Step(2,y), Palette2BPP( ((a / 32) And 1) + ((b / 16) And 2) )
Buffer.Line (3,y)-Step(3,y), Palette2BPP( ((a / 16) And 1) + ((b / 8) And 2) )
Buffer.Line (4,y)-Step(4,y), Palette2BPP( ((a / 8) And 1) + ((b / 4) And 2) )
Buffer.Line (5,y)-Step(5,y), Palette2BPP( ((a / 4) And 1) + ((b / 2) And 2) )
Buffer.Line (6,y)-Step(6,y), Palette2BPP( ((a / 2) And 1) + (b And 2) )
Buffer.Line (7,y)-Step(7,y), Palette2BPP( (a And 1) + ((b * 2) And 2) )

Next




Note: I made some assumptions here.

1) I assumed the coords you give to line are inclusive. IE... specifying it to draw a line from 0,0 to 0,0 would draw a single pixel at 0,0 and no other pixels.

2) I assumed the keyword for a bitwise And operation is "And" and not the & symbol. I seem to remember it being something like that, but I can't be sure. You may want to check.

3) I avoided bitwise ORs altogether and just used addition instead.

4) I left out the BF at the end, since I'm not drawing a box, just single pixels. This means your image should be 1x the size and won't be "zoomed in" at all.

5) I assumed the For loop is inclusive as well (I assumed "0 To 7" will run 8 times, not 7)


(edited by Disch on 05-01-06 11:18 AM)
Arthus

140


 





Since: 11-17-05
From: Australia

Last post: 6510 days
Last view: 6510 days
Posted on 05-01-06 12:31 PM Link | Quote
OK, tried that, gives out something rather interesting... see attachment below.

Also I shall to the best of my knowledge correct the assumptions:
1) I think if you make the start and end co-ords 0,0. The pixel isn't going anywhere. So I think 0,0 to 1,1 would draw a pixel.

2) Yes, you are correct.

3) OK...

4) OK...

5) Yes, you are correct.

EDIT: I forgot to put in the attachment...


(edited by Arthus on 05-01-06 11:35 AM)
Disch

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6578 days
Last view: 6578 days
Posted on 05-01-06 12:38 PM Link | Quote
yeah an attachment might help figure out the problem. (Of course I'll also need to see what the image is supposed to look like)

If #1 was a problem, you could change the coords so that the X coord is 1 higher in the second part. Erm... I worded that bad.. .but like:



Buffer.Line (0,y)-Step(1,y) Palette2BPP( 'blah
Buffer.Line (1,y)-Step(2,y) Palette2BPP( 'blah
Buffer.Line (2,y)-Step(3,y) Palette2BPP( 'blah
'etc




I was worried that might draw 2 pixels.
Arthus

140


 





Since: 11-17-05
From: Australia

Last post: 6510 days
Last view: 6510 days
Posted on 05-01-06 12:55 PM Link | Quote
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.

Attachments

Disch

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6578 days
Last view: 6578 days
Posted on 05-01-06 01:19 PM Link | Quote
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

140


 





Since: 11-17-05
From: Australia

Last post: 6510 days
Last view: 6510 days
Posted on 05-01-06 01:29 PM Link | Quote
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

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6578 days
Last view: 6578 days
Posted on 05-01-06 01:55 PM Link | Quote
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

140


 





Since: 11-17-05
From: Australia

Last post: 6510 days
Last view: 6510 days
Posted on 05-01-06 02:02 PM Link | Quote
But shouldn't they be outputting 0-3 instead of 65280-1677215?
Disch

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6578 days
Last view: 6578 days
Posted on 05-01-06 02:15 PM Link | Quote
((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)


(edited by Disch on 05-01-06 01:17 PM)
(edited by Disch on 05-01-06 01:18 PM)
(edited by Disch on 05-01-06 01:21 PM)
Guy Perfect









Since: 11-18-05

Last post: 6300 days
Last view: 6298 days
Posted on 05-01-06 05:00 PM Link | Quote
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.
Dan

Purple Leever


 





Since: 11-18-05

Last post: 6307 days
Last view: 6298 days
Posted on 05-01-06 06:33 PM Link | Quote
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.
Disch

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6578 days
Last view: 6578 days
Posted on 05-01-06 06:53 PM Link | Quote

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
HyperHacker

Star Mario
Finally being paid to code in VB! If only I still enjoyed that. <_<
Wii #7182 6487 4198 1828


 





Since: 11-18-05
From: Canada, w00t!
My computer's specs, if anyone gives a damn.
STOP TRUNCATING THIS >8^(

Last post: 6298 days
Last view: 6298 days
Posted on 05-02-06 04:18 AM Link | Quote
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

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6578 days
Last view: 6578 days
Posted on 05-02-06 03:02 PM Link | Quote
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

Star Mario
Finally being paid to code in VB! If only I still enjoyed that. <_<
Wii #7182 6487 4198 1828


 





Since: 11-18-05
From: Canada, w00t!
My computer's specs, if anyone gives a damn.
STOP TRUNCATING THIS >8^(

Last post: 6298 days
Last view: 6298 days
Posted on 05-03-06 12:29 AM Link | Quote
Hm, that does sound better. I'll have to try that next time I do something GDI-related.
Arthus

140


 





Since: 11-17-05
From: Australia

Last post: 6510 days
Last view: 6510 days
Posted on 05-03-06 10:35 AM Link | Quote
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
Disch

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6578 days
Last view: 6578 days
Posted on 05-03-06 03:38 PM Link | Quote
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....


(edited by Disch on 05-03-06 02:45 PM)
HyperHacker

Star Mario
Finally being paid to code in VB! If only I still enjoyed that. <_<
Wii #7182 6487 4198 1828


 





Since: 11-18-05
From: Canada, w00t!
My computer's specs, if anyone gives a damn.
STOP TRUNCATING THIS >8^(

Last post: 6298 days
Last view: 6298 days
Posted on 05-03-06 10:21 PM Link | Quote
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.
Pages: 1 2 3Add to favorites | Next newer thread | Next older thread
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.014 seconds; used 455.65 kB (max 591.02 kB)