It is currently Sat Dec 16, 2017 10:00 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: image as background
PostPosted: Wed Nov 09, 2005 9:33 am 
Offline

Joined: Thu Sep 15, 2005 2:53 pm
Posts: 12
put simply, all i am trying to do is take a full-color image and create an NES-rom with the image as the background (i understand i will not be able to use all colors). can you guys tell me what the best way to do this is?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 11:52 am 
Offline

Joined: Mon Apr 11, 2005 6:04 am
Posts: 20
Location: Kiev, Ukraine
The problem is that it there are only 256 unique tiles, which is like 1/4 of your background. You're gonna have to use a highly empty/repetetive image.

_________________
"Wearing of this garment does not enable you to fly."
-- On a child sized Superman costume.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 12:45 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19348
Location: NE Indiana, USA (NTSC)
Or divide the screen into a top half and a bottom half, use a redundant tile finder on each half, and use sprite 0-timed code to trigger a bankswitch between the two halves.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 12:49 pm 
Offline
User avatar

Joined: Wed Nov 10, 2004 6:47 pm
Posts: 1845
You can squeeze 512 tiles in (provided you don't use any sprites) by catching the screen mid-frame with sprite 0 hit or something and changing the page which the BG gets its tiles from (toggle $2000.4). You can do even more with CHR swapping if you're using a mapper and 16k or so CHR-ROM.

edit -- ah crap... tepples is too fast ;_;


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 12:59 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7317
Location: Chexbres, VD, Switzerland
I was wonderging the same thing, not how to be able to get enough tile, but how to convert from another format to NES format. Of couse, it's easy to convert into 4 colors grayscale or something, but it's not what I want. I want to know how to be able to convert a small 16 color or even 256 color image to the NES format, using both BG and sprites in a custom setup to allow as much acuratness in colors as possible. Any suggetions ?

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 1:14 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10166
Location: Rio de Janeiro - Brazil
I was going to say exactly what tepples just did. This way you could use up to 512 tiles. If you don't want to use a mapper, you can still do this. Only instead of actual bankswitching, you change bit 4 of $2000, so you use the other half of the pattern table. If you use all 512 tiles for the background you'll have none left for the sprites, though.

Also keep in mind the other limitations:
-4 palettes of 4 colors each (index 0 is the same color in all of them);
-palettes applied to blocks of 16x16 pixels;

I don't know what part of the process you're having trouble with, but I think this is a good way of preparing the pictures:
1. open your pic in photoshop os some similar tool;
2. resize it to the final size - this will be 256x240 if you want to use the whole screen, but remember you have limited tiles, so if it is a complex image, you might consider a smaller final size so you have enough tiles to represent the image;
3. place a new layer on top of your image, and draw a checkerboard-like pattern, made of 16x16 pixel squares;
4. apply a transparency to this new layer, so you can spot what areas of your image could share the same palette;
5. paint with the same color the squares that are over parts that could share the same palettes. you should have no more than 4 areas defined;
6. select each area, copy and paste to a new document and convert that image to indexed color (4 colors), forcing the colors you want your palettes to have. remember to repeat color 0 for all of the areas;
7. now you have all the areas, with their respective colors. take note on how your attribute table should be set (wich areas use wich palettes). put everything (all the areas) back together.

This was the image preparation process, now you have to convert it to the NES format, eliminate redundant tiles, and write the code to put the stuff on the screen. There are programs to help you in this part, it's up to you what to use.

I wrote the steps above because there is no software to do it automatically. I thought about writing one but never got the time to. I have a lot of ideas, though.

If this wasn't the part you needed help with at all, ignore this and we'll get to the part of convertion, arranging and displaying.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 1:28 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10166
Location: Rio de Janeiro - Brazil
Yeah, you guys are too fast when replying!

Hey Bregalad, the program I mentioned above is kinda like you described. The program would perform the steps I listed above automatically, based on some user input. It would let you chose the number of palettes to use, if you want to provide the palettes or let the program calculate them, how many tiles you want to use, etc.

If tiles weren't exactly equal, but close enough, the program would merge them into one (good for photos, suchs for drawings), if the result had more tiles than requested, of course. It's a sort of graphics compression scheme, in the end.

The hardest thing would be to set up the sprite layer, wich is very limited but could be used on extreme cases (few colors don't mach any avaliable color).

If people think such a software would be welcome, I may get back to it. What do you think? I decided to stop working on it when I realized that it was very rare for people to use large images on games... but if the program provides enough options it may be used for much more than just big images.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 1:55 pm 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7317
Location: Chexbres, VD, Switzerland
This can also apply to use small image, especially faces in a game.
I don't know if a full-feathured software would do the job fine... actually get the algoritm for a such thing would be pretty hard.
Here you are what I think :
- Put the image's satuaration to it's maximum, so all colors would be maxed out, scince the NES is unable to display mid-gray colors. Full gray color would stay gray, trough.
- Check for "sectors" where a color tone would be used. Those sectory would apply to the highest nybble of the NES palette color, so it would say if the image is gray, blue, pink, red, orange, yellow, green or cyan (with more or less precision). The user would be able to modify a bit the color intensity to fit his own palette
- Brithters colors should be tied to white, while darker colors should be tied to black (prepare for the luminosity calculation below)
- Check the most used color(s) and put it (them) as backgound color(s). The image will then be converted to use only 4 levels of luminosity, black and white inclued (or white may also be not include, but be used only in sprite if the picture is rather bright, but with few white on it)
- Check for all colors pixels that wasn't settup with the background color, and check how many different sprite palette it would fit (normally, using fade-pallettes only would be easier)
- Convert all pixels in 8x8 sprites blocks with each one it's own color, but keeping in mind that they can be aligned overmixed as you wish
- Make sure there is no too much sprites (not more than 8 per line)
- Test the final image

I think that this would be pretty hard to do. If anyone has a better algoritm, it would be welcome. However, it seems to not be that complicated to do it by hand, just a lot of thinking/optimizing is involved.

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 3:13 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10166
Location: Rio de Janeiro - Brazil
Hey Bregalad

I've been using the following approach:

First I shrink the image to 1/16th of it's size, so that each pixel is the average color of 16x16 pixel block from the original image. Then I quantize this image to 4 colors (or 3, or 2, depending on the number of palettes the user wants to use). The pixels with the same color represent blocks that will use the same palette.

Then we have to calculate color 0, wich should be be the most present color in the whole image. Then each group of blocks is quantized to 4 colors, one of wich is fixed, color 0.

About the sprite details, I haven't put much though on it yet. Maybe I could calculate the difference of the original image to the converted image, and assign sprites to represent the points where the difference was too large. The number of sprites to use would be supplied by the user, so, areas with larger differences would be favored in case there are not enough sprites.

I'm not sure if this is the best method. You presented some good ideas in your post too. I perform my tests using photoshop, çause I'm not in the mood to program a full algorithm and see that in the end the image sucks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 09, 2005 6:14 pm 
Offline

Joined: Thu Sep 15, 2005 2:53 pm
Posts: 12
haha...ok, i should have been more clear about this to begin with...im seriously inept at this stuff, i was hoping someone could give me some nbasic code that i could use, assuming i could get the .CHR myself.

something that basically specifies a starting address of the tiles, x and y position on the screen and a width of the thing to draw...does that make sense?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 8:08 am 
If you're talking about creating NES graphics, not convert to it, then use TileMolester or TileLayerPro, downloadable at http://www.zophar.net

Tokumaru : Splitting attribute into 16x16 aeas would be needed, but you should let the user change the fine scrolling to optimise it, or reduce the size to 8x8 so a MMC5's exgrafix image could also be encoded.
I ask myself how good would be to enter with a BMP file, and automatically convert it. I ask myself if a programm could do that job fine, instad of an actual person.


Top
  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 8:19 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10166
Location: Rio de Janeiro - Brazil
hum... I don't know anything about nbasic... I'm assuming it is a basic-type language for the NES?

But no matter what language you're using, you'll have to perform the following tasks:
1. turn off the PPU and wait for it to warm up (2 frames, I guess);
2. write the palettes your image uses to palette RAM;
3. write the tile arrangement data to the nametable;
4. write the attribute bytes to the attribute table;
5. set the PPU to display the nametable you wrote the stuff to;
6. turn the screen on (background rendering on);

I don't know if there is any ready-to-use code avaliable... a long long time ago I used the NES Screen Arranger software and I believe it had some code to display you picture included in the package. However it was a long time ago for me so I can't say how accurate the code is. I knew nothing about NES programming back then, but managed to get a few pics on the screen anyway. Maybe that's what you're looking for.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 8:54 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10166
Location: Rio de Janeiro - Brazil
Hey Bregalad

You're right, this kind of program should support palettes applied to 8x8 pixel areas.

The really hard part of doing it all automatically is to have pallets that will blend with each other, or the resulting image looks pretty blocky.

I'm basing my work on this on an old graphics compression technique called "block truncation coding". It divides the image in blocks and assigns a few colors to each block. When I saw this I thought it really resembled the way NES graphics work. However, it is intended to work with blocks smaller than 16x16, and the colors used in each block have no correlation to any other block, differently from the NES. And it also makes all of it's decisons based on luminance, wich won't look good for the NES.

Yesterday I did a test using photoshop, and realized a pretty ugly problem. When I converted each of the areas to their own 3 colors + color 0, the colors almost never blended with the other areas, resulting in a very blocky look sometimes. Sometimes the colors were close enough.

I can't think of a way to make the palletes blend smothly with each other... and even if there is a way, we would need to pick the correct colors to blend or it'd look ugly anyway.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 10:17 am 
Offline
User avatar

Joined: Fri Nov 12, 2004 2:49 pm
Posts: 7317
Location: Chexbres, VD, Switzerland
I always trough basing all stuff on luminance was good, while color would just enhance the picture.... See all NES games with detailed graphics, they pretty much all bases their graphics on luminance. However, Color effects could be provided by sprites where needed. But I'm rather interesting to small to medium pictures myself, for Character's faces or maybe cutscenes.

_________________
Life is complex: it has both real and imaginary components.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 11:44 am 
Offline

Joined: Thu Sep 15, 2005 2:53 pm
Posts: 12
tokumaru wrote:
a long long time ago I used the NES Screen Arranger software and I believe it had some code to display you picture included in the package. However it was a long time ago for me so I can't say how accurate the code is. I knew nothing about NES programming back then, but managed to get a few pics on the screen anyway. Maybe that's what you're looking for.


this app seems to be exactly what i need...but i cant seem to get it to work?? from the command prompt i move to the app directory and then type
NSA background.CHR

but i get an error:

16-bit MS-DOS Subsystem
Command Prompt - NSA background.CHR
X#=0D, CS=01B7 IP=000000245. The NTVDM CPU has encountered an unhandled exception. Choose 'Close' to terminate the application.

what gives????


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 20 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: lazygecko and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group