Writing code for the bootsector introduces a unique problem, being limited to 512 bytes for data and code. That's right, data AND code.
Want small code? x86 assembly or C, that's fine there.
Want images? Good luck.
A 20 by 20 pixel image, with 8 bits (1 byte) per pixel, is 400 bytes. With code being about 200, that is way over the limit. There is one tradeoff we can use to save a huge amount of space, and is what makes this project possible.
Instead of having a byte for a single pixel, 256 colours, each byte now contains 8 pixels. Each single bit inside the BIOS video memory represents a black and white (on and off) state for that pixel.
The same 20 by 20 pixel image will now be 50 bytes instead of the 400 bytes it was before. The DVD logo is a single solid colour anyway, just use it's alpha/transparency to generate a black and white image.
Rendering the DVD logo image goes like this
- Generate a bitmapped (1 bit per pixel) raw representation of the image with a python script.
- Use the
incbin
NASM directive to insert the raw file straight into the final binary, keep a label/pointer to the data. - In the rendering loop, keep a representation of a rectangle. It's position, size, velocity, stuff like that.
- When drawing, copy each byte mapped from the rectangles texture coordinates straight to the VRAM.
This is what you will need.
- nasm (netwide assembler)
- objcopy and ld (binutils)
- qemu (qemu-system-i386)
- gdb (for make-debug)
What does each rule in the makefile do?
make
- create boot.bin to execute and boot.elf for debug symbolsmake run
- use boot.bin and qemu to execute in a VMmake run-debug
- use gdb to connect to qemu's remote debugger
Some kind of POSIX enviroment is recommended. Use WSL on Windows.
Not like you remembered but close enough.