You need to write / use an image downloader or use your own image file format. BMP may look simple, but too much in it, like pixel compression formats, etc., but you can still focus on a specific type of BMP and ignore everyone else ...
In the days of MS-DOS, I used 256 color PCX images with a palette because I used 256 color video modes. Here's an example of a NASM LINEZ game:
- Colored lines - a simple game in C ++ / verification algorithm
see pcx: routine pcx: It decodes the downloaded PCX file from ds:0 into the original VGA image in es:di . Be wary that it only supports 64 KByte size 64 KByte !!! Now, to render the image, you would need to copy the contents of es:di to VideoRAM (suppose A000:0000 ), for example, using rep movsd or you can set es:di for it (first of all) which may flicker).
This PCX loader, however, does not use the palette from the image, so you need to encode it ... (routines for changing the VGA palette are included in the source, which you just need to extract the RGB values ββfrom PCX I think it was at the end of the file). Look at here:
- my C ++ PCX loader with palette
if converts PCX to 32-bit source image.
For more information on MS-DOS software, see PCGPE 1.0
Here is another example game ( TASM ) that uses its own image file format:
- What is the best way to move an object on the screen?
It has text menus, access to binary files, 320x200 sprite graphics, 3 people.
[Edit1] New code
I deleted the old code sample, and instead I created a compiled and working 8-bit PCX with a color palette viewer in TASM . It uses VESA mode 800x600x256 colors ( 103h ).
The image should fit on the screen, and its file size should be less than 64 KB.
I did not add any error messages or error messages ... It just uploads the image.pcx file and displays it on VESA , and then waits for the output with the final hit. Here is the source of TASM :
PCX.ASM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .386 IDEAL MODEL TINY ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATASEG file: db 'image.pcx',0 ;filename to load buff: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; CODESEG STARTUPCODE scrxs equ 800 scrys equ 600 mov ax,103h ; VESA 800x600x256 call vesamod mov al,0 call vesapag ; scrxs equ 320 ; scrys equ 200 ; mov ax,19 ; VGA 320x200x256 ; int 10h lea dx,[file] ; load PCX into DS:buff, CX bytes call fopen lea dx,[buff] mov cx,64000 ; some max value to fit into DS segment call fread ; CX is PCX real size call fclose lea si,[buff] ; decode directly to VRAM mov ax,0A000h mov es,ax mov di,0 call pcx mainl0: mov ax,256 ; test keyboard int 16h jz mainl0 sub ax,ax ; clear key buffer int 16h mov ax,3 ;|VGA 80x25 text int 16 ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; vesamod:pusha ;set VESA videomode ax mov bx,ax mov ax,4f02h int 16 popa ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; vesapag:pusha ;al=page switch vesa video page window A mov [cs:scrpag],al mov dl,al sub dh,dh sub bx,bx mov ax,4f05h ; window A int 16 popa ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .386P scrpag db 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; .386P hand dw 0 ;
So, make any image up to 800x600 convert it to 256 color PCX with a palette and rename it to image.pcx . Then put it in the *.com file and run it. I compiled it with the Commander Volcov script vc.ext as follows:
asm:@c:\language\compil\tasm\tasm !.! /ic:\language\source\tasm\inc @c:\language\compil\tasm\tlink !.obj /t /x @del !.obj
so every time I press enter in any asm file, it compiles. Just change the paths, and if you do not target *.com files, change the /t switch accordingly. Here's a preview from my DOSBox :
