LZ: Bitmaps
[Prev][Next][Index][Thread]
LZ: Bitmaps
-
Subject: LZ: Bitmaps
-
From: Edward Plese <eplese@lnd.com>
-
Date: Thu, 22 Aug 1996 13:30:17 -0500
-
In-Reply-To: <>
>I am starting a new game and I need to learn how to use bitmaps. For
>example, I want to place an 16x20 bitmap
>of a happy face anywhere on the screen. How would I do this? I already
>know that I really don't need nasr,
>since they won't actually be moving.
I would recommend that you make it so that the sprite will start exactly on
the MSB of one byte and end on the LSB of the following byte. This is so
that the sprite covers only two bytes on the screen as opposed to
coverering three of them and that's what NASR is for. A basic routine to
put a sprite on the screen would be:
ld hl,(PROGRAM_ADDR)
ld de,Sprite
add hl,de
ex de,hl ;de now points to Sprite
ld hl,$0000 ;offset in video memory. $0000 is upper left
Start:
;input: hl=offset in video memory
; de=pointer to sprite
ld bc,VIDEO_MEM
add hl,bc ;hl now holds address of spot in video mem
ld b,2 ;set to number of rows in sprite
Loop:
push bc
ld a,(de)
ld (hl),a
inc de
inc hl
ld a,(de)
ld (hl),a
inc de
ld bc,15
add hl,bc
pop bc
djnz Loop:
ret
Sprite:
.db %10101010,%10011001
.db %10101010,%10011001
This routine SHOULD work. I didn't bother to look through some of my
programs to see if it's right, but it should be. If it's not you should be
able to fix the problem. If not, then email me and I'll fix it for you.
Ed Plese, Jr.
(eplese@lnd.com)