A86: Re: Re: ASM Clear-Up


[Prev][Next][Index][Thread]

A86: Re: Re: ASM Clear-Up




Thanks for the help and again, I'm sorry about the HTML messages. Why not?

When you use this routine you can change the value that is loaded into the
bc register right? But if you do it will screw up the clipping and masking
though. Thanks for the help again. I'm starting to understand a whole lot
more things tonight.

David Phillips said,

>A routine called a "Find Pixel" routine is used to calculate the correct
>offset and mask for a pixel (remember that video memory is formatted 8
>pixels per byte).  A few hours ago I posted Dux's totally amazing 105
>t-state _Fastest_ FindPixel routine.  It works like this:
>
>   ld bc,$3020    ; find pixel at coords (48, 32)
>   call FindPixel ; calc offset and mask
>                  ; hl now points to the address of the pixel
>                  ; a is now the "mask for the pixel, meaning
>                  ; the bit for the pixel is set, all other
>                  ; bits are clear
>
>Now, to set a pixel (all examples follow the above code):
>
>  or (hl)         ; set the bit by ORing the mask and the video byte
>  ld (hl),a       ; write the byte back to video memory
>
>Or to clear the pixel:
>  cpl             ; invert the mask, so the pixel's bit is clear
>                  ; and all other bits are set
>  and (hl)        ; clear by ANDing the pixel's bit with a clear bit
>                  ; which will clear it, since both won't be set
>                  ; all other bits are set in the inverted mask, so
>                  ; if the other bits in video memory are set, they
>                  ; will stay set, and if they are clear, they will
>                  ; stay clear, since that's what AND does ;-)
>  ld (hl),a       ; z80 only does stuff with the accumulator...dumb z80
>
>To invert the pixel:
>  xor (hl)        ; flip the bit by XORing (eXclusive ORing) it
>  ld (hl),a       ; again, if this was x86, hehe
>
>Be sure to check both of the Sprite sections at 86 Central, along with the
>Display section.
>
>I hope this helps, I don't have time tonight to further explain.  For more
>information, check out 86 Central and read ALL of the tutorials on asm
>(http://ti86.acz.org/).  Later!
>
>--
>David Phillips <david@acz.org>
>http://www.acz.org/
>
>