Re: A86: How to use Video Mem?


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

Re: A86: How to use Video Mem?



In a message dated 97-10-01 00:43:54 EDT, you write:

> 
>  I wrote earlier:
>  > How do I display a picture on the screen that is written in binary 
>  > like
>  > %11111111
>  > %10000001
>  > %11111111
>  > 
>  > Please help me.
>   
>  Now for more information.  I have the source code for nibbles and was 
>  wondering how they made the levels apper the have code like this:
>  
>  level_data:
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>           .db      %00000000,%00000000,%00000000,%00000000
>  
>  How do I make the levels appear if they are written like that?
>  
>  Thanks,
>  
>  Dann  
>  

To start simple, if you want to put

%11111111
%10000001
%11111111

on the screen, it would definitely be easiest if you're intending on making
the top-left corner be at the left side of one of the 8x8 squares (i.e. x is
a multiple of 8).  In this case, you could use a findpixel routine to point
hl to the location you want it.  Otherwise, it is immensely more complicated
and I'm still working on a routine that'll do it right.  Anyway, if you have
hl pointing to that location in video mem ($FC00+16y+x/8) then you could
point de to the location in your program where the pic is.  Then it would
probably be good if they were switched (ex de,hl) because ldi is pretty much
just ld (de),(hl)\inc hl\inc de.  So, once hl and de are set up, you'd want
to ldi and then increment de by 15 more (to get to the next line), so I would

 push hl
 ld hl,15
 add hl,de
 ex de,hl
 pop hl
so that hl is the same as it was, and de is 15 more.

then just ldi and increment de again and again until you finish the sprite.
 If you're going to do this more than 2 or 3 times, it would be a good idea
to make a loop (but you might want to push/pop bc if you're using a djnz
because I think ldi might dec bc as well)

About the nibbles levels, it appears that each bit represents a 4x4 box.  If
you wanted to display it, then it would be somewhat tricky, and I can't think
of a good algorithm off the top of my head...

~Steve