Search code examples
assemblygraphicsdosx86-16

x86- Best way to highlight specific area on a BMP pic?


I made a menu picture for a game. The next step I wanted to do on the menu is to highlight the option from the menu wich the cursor is floating on. And not by loading another bmp file, only with changing the specific area color, and return it normal after the action. So what is the best way to do it? If you can, add a code.

I'm working on DosBox(for windows), 8086 ASM. and im using graphic mide for the menu.

The menu:

My menu bmp file:


Solution

  • The most basic way would be calculating the start and the end address in the video memory and replacing all menu-point-background byte values in this block:

      mov si, start_address
      mov dx, end_address
    lbl_loop:
      lodsb
      cmp al, src_color_value
      jne @next
      mov byte ptr [si-1], dst_color_value
    next:
      cmp si, dx
      jl(e) lbl_loop       ; depends on if end_address is included or excluded
    

    DS has to be set to the video_segment. There surely are better ways to do this, but you get the idea.