Page 1 of 2
Can I show an image with BIOS interrupts or assembly?
Posted: Fri Mar 29, 2013 7:48 am
by EbubekirK
I am trying write a simple bootloader, and I want to show an image when my bootloader starts. How can I do this?
I am using assembly with nasm assembler.
Re: Can I show an image with BIOS interrupts or assembly?
Posted: Fri Mar 29, 2013 8:58 am
by brain
Learn the format of the image you are using, and write an image parser in assembly to display it. I recommend gif of no larger than 320x200 because you can render that perfectly on mode 13h.
Re: Can I show an image with BIOS interrupts or assembly?
Posted: Fri Mar 29, 2013 5:16 pm
by Mikemk
or 640x480 16-color.
and it has to fit in memory
Re: Can I show an image with BIOS interrupts or assembly?
Posted: Fri Mar 29, 2013 11:51 pm
by EbubekirK
hm, can you show me example please ?
Re: Can I show an image with BIOS interrupts or assembly?
Posted: Sat Mar 30, 2013 2:17 am
by brain
Not really, its far too in depth to simply copy and paste a few lines. It's going to take a few hundred lines of code to display a gif, and you'll have to understand the pallette registers, the format of mode 13h, and the gif format including LZ compression used to make the file smaller. You will also know enough BIOS interrupts to read the file from the filesystem, and you will actually need a filesystem (failing that you could embed the image in your bootloader, making it much larger). I suggest you read up on the GIF format, and go from there.
I did this many years ago, and also the ancient PCX format which can be a little easier. It's worth it but not trivial.
For a real world of hurt, try implementing jpeg without libjpeg or such. That is naaaasty.
Re: Can I show an image with BIOS interrupts or assembly?
Posted: Mon Apr 01, 2013 7:05 am
by Mikemk
If the image is about 256 pixels or less (16x16), you can embed the raw data in your bootloader, and switch to mode 13 through bios, and simply copy the lines to correct offsets - don't forget to skip over pixels!
Re: Can I show an image with BIOS interrupts or assembly?
Posted: Wed May 08, 2013 4:04 pm
by LieutenantHacker
As mentioned, you need to parse the format of an image and render it.
That's not easy at all from a general view point, but perfectly possible.
Try starting off with this:
http://en.wikipedia.org/wiki/Graphics_I ... ile_format
And assuming you know Assembly you need to program using it. Hopefully you're at least somewhat good at it, otherwise you'll need to go through more trouble optimizing a high-level-language.
You'll also likely have to store the file somewhere (a filesystem), which will also not be easy.
You should both work on the previous mentioned subjects, and try and get a better understanding of what's necessary and effective to get this done right.
You could also just write directly to video memory without an image file being loaded from a storage drive and write pixel-by-pixel in graphics mode (like 13h mentioned before), but that can be even more tedious depending on the purpose.
EXTRA:
The answers to this question, and the links given might also help you out with your problem:
http://stackoverflow.com/questions/1420 ... es#tab-top
Re: Can I show an image with BIOS interrupts or assembly?
Posted: Wed May 08, 2013 5:10 pm
by Love4Boobies
If you think GIF is too much of a hassle for something as small as a splash screen, you might want to look into PCX, which has a simple format and uses LRE compression. You can be done with it in a matter of minutes.
Re: Can I show an image with BIOS interrupts or assembly?
Posted: Thu May 09, 2013 7:13 am
by Mikemk
I love dead threads.
Re: Can I show an image with BIOS interrupts or assembly?
Posted: Thu May 09, 2013 6:12 pm
by Love4Boobies
Re: Can I show an image with BIOS interrupts or assembly?
Posted: Fri May 10, 2013 2:17 pm
by Mikemk
I don't know, that's on wikipedia
Re: Can I show an image with BIOS interrupts or assembly?
Posted: Fri May 31, 2013 12:41 pm
by AbstractYouShudNow
Why GIF ? Just use raw data or something close to it, like bitmaps. BIOS interrupts are not that hard once you got Ralf Brown's interrupt list, or their corresponding articles on the wiki. Your bootloader doesn't need to be in assembly, I tell it by experience, and as a proof, GRUB is mostly written in C.
Re: Can I show an image with BIOS interrupts or assembly?
Posted: Fri May 31, 2013 2:00 pm
by Kazinsal
AbstractYouShudNow wrote:Why GIF ? Just use raw data or something close to it, like bitmaps.
Raw bitmap at 320x200x8 is almost 64 KB. 320x200x8 GIF is much smaller. PNG will get even smaller, but the process of decoding a PNG is a bit more involved than a GIF or even just a bitmap that's been tossed through RLE.
EDIT: Quick test, using
this image: Raw bitmap, 64000 bytes. GIF, 32988 bytes. Unoptimized PNG, 20658 bytes. Optimized (optipng -o7) PNG, 11398 bytes. If you're willing to write/port a small deflate and PNG library, PNG is great. If you're not, GIF or PCX (didn't have GIMP on hand to test with -- probably similar size results to GIF) is your best bet.
Disclaimer: My numbers for PNG are higher than they should be -- that's 32-bit RGBA PNG and not PNG-8.
Re: Can I show an image with BIOS interrupts or assembly?
Posted: Fri May 31, 2013 9:03 pm
by Love4Boobies
It's highly unlikely that the file's size is a concern.
Re: Can I show an image with BIOS interrupts or assembly?
Posted: Sat Jun 01, 2013 4:05 am
by brain
For one image it might not be worth using gif or png. Lets say your image is 32k as png but the image decompressor is 32k you wouldn't save anything if the image decompressed is 64k. In fact at runtime you're taking up even more ram, 96k, with 64k decompressed image plus 32k decompressor...