I am creating a small pong game using x86-16 assembly in a boot sector to run in QEMU on Ubuntu 20.04.2.
I want to make a console beep when the ball hits a paddle. What would be a space efficient way to create a beep sound of any kind in x86-16?
I'm using FASM.
You can use the BIOS.Teletype function 0Eh for this.
It's a function that writes the character from
ALto the display page fromBHusing the color fromBL. The function also interprets some control codes: 13 for carriage return, 10 for linefeed, 8 for backspace, and 7 for bell. The function returns nothing.Because sounding the beeper is an audible operation, you can shave off a few bytes and not mention anything for the displaypage or the color.
In the limited space of your bootsector, next is all it takes to beep: