Register | Login | |||||
Main
| Memberlist
| Active users
| ACS
| Commons
| Calendar
| Online users Ranks | FAQ | Color Chart | Photo album | IRC Chat |
| |
1 user currently in Rom Hacking: |
Acmlm's Board - I2 Archive - Rom Hacking - Editor programming - Graphics? | | | |
Pages: 1 2 | Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
User | Post | ||
Exim Micro-Goomba Level: 6 Posts: 3/10 EXP: 549 For next: 358 Since: 01-04-05 Since last post: 102 days Last activity: 22 min. |
| ||
Finally I've found the damn pointer-table in the game I've been working on. (it was split up in lower and upper part and located at two different positions) actually I would have gathered enough Information about the map-datastructure to write a map-editor. A text-based editor would suck, so I'd like to create a graphical one. My question is: do other editors use copied graphics from the game or do they read the graphics directly from the rom with the corespondig palette? |
|||
dan Snap Dragon Level: 43 Posts: 410/782 EXP: 534516 For next: 30530 Since: 03-15-04 Since last post: 20 hours Last activity: 14 hours |
| ||
It's preferable to read the graphics from the ROM. For editors for NES games, it's pretty much expected, SNES less so. However, it's not unacceptable to load them from external files. |
|||
Exim Micro-Goomba Level: 6 Posts: 4/10 EXP: 549 For next: 358 Since: 01-04-05 Since last post: 102 days Last activity: 22 min. |
| ||
is there some source-code out there to read and display graphics from a rom file? I don't really feel like reading through hardware and emulation docs. | |||
dan Snap Dragon Level: 43 Posts: 411/782 EXP: 534516 For next: 30530 Since: 03-15-04 Since last post: 20 hours Last activity: 14 hours |
| ||
What programming language are you using? | |||
Exim Micro-Goomba Level: 6 Posts: 5/10 EXP: 549 For next: 358 Since: 01-04-05 Since last post: 102 days Last activity: 22 min. |
| ||
I prefer C++, but I'm able to read/write VB, C-derivates, Delphi and Eiffel. | |||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 3177/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
You need to know how to use GDI functions such as BitBlt and SetPixel. What you generally want to do is read the palettes and graphic data, and draw each pixel on a buffer based on the palette data. (Convert the palettes to BGR (RGB backward) and stick them in an array, and use the individual pixel data as the index.) Then you just copy 8x8 squares from the tile buffer onto one main buffer, stretching if necessary (use StretchBlt) and copy that onto the window's DC. (You could copy directly to the DC from the tile buffer, but you'll get flicker.) For sprites or BG layers with transparent colours, set the transparent colour's palette entry to something that won't be used in the game's palette data, and use TransparentBlt specifying that colour as the transparent colour. (TransparentBlt can also stretch the image. Tip: Since most systems use 15-bit colour or an index to a palette hard-coded into the system, the number of possible RGB colours is quite limited. For example, 15-bit colour will always translate to multiples of 8 for the red, green and blue values, so use something that isn't a multiple of 8 as your transparent colour and it's guaranteed not to conflict with the palettes. ) | |||
Parasyte Bullet Bill Level: 35 Posts: 286/514 EXP: 267348 For next: 12588 Since: 05-25-04 Since last post: 104 days Last activity: 32 days |
| ||
Stay away from SetPixel. If you're going to draw many pixels at a time, it's better to use CreateDIBSection, which will create a bitmap that returns a pointer to the bitmap data in memory. Using that pointer, you can read and write the bitmap data directly. It gets rid of so much overhead that you would have to deal with when using SetPixel. (IE hundreds of times faster than SetPixel.) | |||
Dish Spiny Level: 38 Posts: 276/596 EXP: 355646 For next: 14801 Since: 03-15-04 From: Disch Since last post: 18 days Last activity: 18 days |
| ||
I second that. CreateDIBSection all the way. If for some reason you can't use it.... SetDIBits is the next best thing. SetPixel is so far beyond slow it's practically useless. |
|||
Exim Micro-Goomba Level: 6 Posts: 6/10 EXP: 549 For next: 358 Since: 01-04-05 Since last post: 102 days Last activity: 22 min. |
| ||
what's about GetPixelAddress (availible in CImage) ? Or do I have to care about the pitch? CreateDIBSection returns a bitmaphandle (HBITMAP) ...?? or does this handle act like a pointer? |
|||
Dish Spiny Level: 38 Posts: 277/596 EXP: 355646 For next: 14801 Since: 03-15-04 From: Disch Since last post: 18 days Last activity: 18 days |
| ||
I'm not really familiar with CImage (are you using MFC?) Anyway... the HBITMAP handle is just that: a handle to the bitmap. It's the non-MFC equivilent of a CBitmap. You get the pointer to the bitmap data through one of the parameters you pass to the function. Here's some sample code to help explain.
This example makes a bitmap 256x240 pixels and puts it in an offscreen DC. You can write directly to the pixels as though it were a big array through the "pixels" pointer in this example. One funky side effect to take note of is that Windows bitmaps are stored upside-down... so 'pixels' actually points to the last row in the bitmap followed by the second last, etc... not the first followed by the second like you'd might expect. Once you change your pixels and stuff you can do ordinary BitBlt()s with mDC as your source to blit the image to another surface (or to the display) Once you're done with everything, you need to do cleanup:
|
|||
FuSoYa Defender of Relm Level: 26 Posts: 147/255 EXP: 99529 For next: 2746 Since: 03-15-04 From: Moon Since last post: 7 days Last activity: 7 hours |
| ||
Originally posted by Disch Or you can just make the height value negative if you don't like working with upside-down images. |
|||
Dish Spiny Level: 38 Posts: 278/596 EXP: 355646 For next: 14801 Since: 03-15-04 From: Disch Since last post: 18 days Last activity: 18 days |
| ||
That works? Haw |
|||
Exim Micro-Goomba Level: 6 Posts: 7/10 EXP: 549 For next: 358 Since: 01-04-05 Since last post: 102 days Last activity: 22 min. |
| ||
Thanks a lot. Hopefully I'll be able to get the job done with this. yes, I'm using MFC. Creating all the windows, buttons, textfields, input, messagehandling my own would drive me crazy I think... never got far beyond creating a window and draw stuff in it with the mouse. I bet when I'd like to add buttons I'd use mfc-objects. |
|||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 3209/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
Ugh. I tried to use DIB sections once, damn near drove me nuts. WTF is this scanline crap anyway? | |||
Dish Spiny Level: 38 Posts: 279/596 EXP: 355646 For next: 14801 Since: 03-15-04 From: Disch Since last post: 18 days Last activity: 18 days |
| ||
Originally posted by Exim It's not as hard as you'd think. Dialogs and stuff are pretty much automated by the API. There's only like 4 things you have to do differently when making dialogs straight in the WinAPI than you'd do when working in MFC. But I'm just talking. If you're more comfortable with MFC, it's alright to stick with it... just try to break from it eventually. Originally posted by HyperHacker *shrug* The code I gave in that other post pretty much takes care of all of it. All you have to do from there is treat "pixels" as a big array of pixels =P. Writes to it will change the image directly. Don't see what's so complicated about that. |
|||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 3234/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
So when you modify the array, you're actually modifying the image? That's probably the problem. I did it in VB, so without pointers I had to copy the image to an array and back which was very confusing. | |||
Parasyte Bullet Bill Level: 35 Posts: 292/514 EXP: 267348 For next: 12588 Since: 05-25-04 Since last post: 104 days Last activity: 32 days |
| ||
Yes. The pointer points directly to the actual bitmap data. | |||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 3256/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
Oooooooooh... Do I have to do something special when creating the bitmap though, or can I just use CreateCompatibleBitmap() and CreateDC() like I usually do? | |||
Parasyte Bullet Bill Level: 35 Posts: 297/514 EXP: 267348 For next: 12588 Since: 05-25-04 Since last post: 104 days Last activity: 32 days |
| ||
Use CreateCompatibleDC(), CreateDIBSection(), and SelectObject(), as in Disch's example. | |||
HyperLamer <||bass> and this was the soloution i thought of that was guarinteed to piss off the greatest amount of people Sesshomaru Tamaranian Level: 118 Posts: 3274/8210 EXP: 18171887 For next: 211027 Since: 03-15-04 From: Canada, w00t! LOL FAD Since last post: 2 hours Last activity: 2 hours |
| ||
Awesome... Though I notice he saves the value from SelectObject and does stuff with it at the end. Is that necessary? My programs seem to have been working fine without it, but that might just be XP cleaning it up for me. |
Pages: 1 2 | Add to favorites | "RSS" Feed | Next newer thread | Next older thread |
Acmlm's Board - I2 Archive - Rom Hacking - Editor programming - Graphics? | | | |