Monday, June 26, 2017

Drawing the Cursor


Seems like our Chef Horst Hummel got impatient and sliced the hourglass cleanly in half..
The 16x16 cursor image is stored as a bitmap like the newspaper images I described in my previous post on graphics and animation in Supernova. The black outline and red filling are rendered seperately, both taking 32 bytes.
I skimmed through my code and could not find a shift that possibly corrupted the cursor data. But how to fix it? Well, it seems the image is split right at 8 pixels and since they are represented by one byte we could just do a wordRoll that swaps its bytes like swapped = (i >> 8) | (i << 8).
Wait a second....

The disassembly shows the critical part for drawing the black outline
next_line:
          lodsw
          mov cx,dx

next_pixel:
          shl ax,1
          jc skip1
          mov byte es:[di],0
skip1:
          inc di
          loop next_pixel

          add di,320
          sub di,dx
          dec bh
          jnz next_line
lodsw... The first endianess bug in this project that I got stuck on..
At least now it's working and I can keep going with more important stuff like actually making it playable and hopefully won't get distracted by those small things again...


 

No comments:

Post a Comment