Can I show an image with BIOS interrupts or assembly?

Programming, for all ages and all languages.
EbubekirK
Posts: 2
Joined: Fri Mar 29, 2013 7:46 am

Can I show an image with BIOS interrupts or assembly?

Post 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.
User avatar
brain
Member
Member
Posts: 234
Joined: Thu Nov 05, 2009 5:04 pm
Location: UK
Contact:

Re: Can I show an image with BIOS interrupts or assembly?

Post 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.
Mikemk
Member
Member
Posts: 409
Joined: Sat Oct 22, 2011 12:27 pm

Re: Can I show an image with BIOS interrupts or assembly?

Post by Mikemk »

or 640x480 16-color.
and it has to fit in memory
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
EbubekirK
Posts: 2
Joined: Fri Mar 29, 2013 7:46 am

Re: Can I show an image with BIOS interrupts or assembly?

Post by EbubekirK »

hm, can you show me example please ?
User avatar
brain
Member
Member
Posts: 234
Joined: Thu Nov 05, 2009 5:04 pm
Location: UK
Contact:

Re: Can I show an image with BIOS interrupts or assembly?

Post 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.
Mikemk
Member
Member
Posts: 409
Joined: Sat Oct 22, 2011 12:27 pm

Re: Can I show an image with BIOS interrupts or assembly?

Post 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!
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
User avatar
LieutenantHacker
Member
Member
Posts: 69
Joined: Sat May 04, 2013 2:24 pm
Location: Canada

Re: Can I show an image with BIOS interrupts or assembly?

Post 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
The desire to hack, with the ethics to code.
I'm gonna build an 8-bit computer soon, with this as reference: http://www.instructables.com/id/How-to- ... -Computer/
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Can I show an image with BIOS interrupts or assembly?

Post 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.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Mikemk
Member
Member
Posts: 409
Joined: Sat Oct 22, 2011 12:27 pm

Re: Can I show an image with BIOS interrupts or assembly?

Post by Mikemk »

I love dead threads.
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Can I show an image with BIOS interrupts or assembly?

Post by Love4Boobies »

How about zombie processes?
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Mikemk
Member
Member
Posts: 409
Joined: Sat Oct 22, 2011 12:27 pm

Re: Can I show an image with BIOS interrupts or assembly?

Post by Mikemk »

I don't know, that's on wikipedia
Programming is 80% Math, 20% Grammar, and 10% Creativity <--- Do not make fun of my joke!
If you're new, check this out.
AbstractYouShudNow
Member
Member
Posts: 92
Joined: Tue Aug 14, 2012 8:51 am

Re: Can I show an image with BIOS interrupts or assembly?

Post 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.
User avatar
Kazinsal
Member
Member
Posts: 559
Joined: Wed Jul 13, 2011 7:38 pm
Libera.chat IRC: Kazinsal
Location: Vancouver
Contact:

Re: Can I show an image with BIOS interrupts or assembly?

Post 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.
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Can I show an image with BIOS interrupts or assembly?

Post by Love4Boobies »

It's highly unlikely that the file's size is a concern.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
brain
Member
Member
Posts: 234
Joined: Thu Nov 05, 2009 5:04 pm
Location: UK
Contact:

Re: Can I show an image with BIOS interrupts or assembly?

Post 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...
Post Reply