Re: A86: Graphics


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

Re: A86: Graphics



Ricci Adams wrote:

>   Can somebody please explain how to do graphics in assembly?  I have
> look
> at alot of sources but I still can't figure it out.  Thanks in
> advanced.
>
>
>                     -Ricci Adams

heres a quick way to put images on the screen (it will put 8x8 sprites
on a screen of 16*8 "boxes") :
to get you're sprite ANYWHERE you must use the findpixel routine and
modify this code (alot)
   .
   :
   ld hl,PIC       ; point to where your picture is
   call DrawPic ; call the routine
   ret

DrawPic:        ; will draw picture at (0,0)
    ex de, hl      ; DE now points to picture
    ld hl,$FC00 ; HL points to first byte in the video memory
; here you must increment HL by the numberof bytes you want, to get your
pic somewhere else then (0,0)  you might
; want to you use (b,c) as your cord then multiply B * 16 add that to HL
then add C, or how ever you want to do it
    ld b,8           ; we want 8 lines, of course you could change it to
except a register for the number of lines, or to read it
                        ; from memory, whatever, I just hardcoded this
in for the ex.
DrawPicLoop:
    push bc             ;save the counter of lines
    ld a,(de)            ;get one byte from PIC
    ld (hl),a             ;put in vidmem
    inc de                ;point to next byte

    ld b,0              ;
    ld c,16            ;
    add hl,bc         ; here we add hl by 16 because we want our next
line DIRECTLY under the one before it
    pop bc            ;get the counter back
    djnz DrawPicLoop          ;and keep going until all 8 lines done




PIC:                            ; this is your picture represented by 8
bytes
   .db %11111111       ; this just happens to be a box with a line
through it :)
   .db %11000001
   .db %10100001
   .db %10010001
   .db %10001001
   .db %10000101
   .db %10000011
   .db %11111111


   That should get you started.  Of course I've only be doing this for
about a week so I know there is a better way.  But that should help
some.




References: