Re: A86: Need Help! Level Maps!


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

Re: A86: Need Help! Level Maps!




I've decided to post the routine we are using in an upcoming game, along
with reposting Dan Eble's(?) aligned sprite routine.  I was reluctant to do
so earlier because I didn't ask my partner yet--but I don't Matt Johnson
will mind.  I don't claim that these to be the fastest way to do this, btw.

Enjoy!  ;-)

;==========================================================================
; DrawMap:
;  Draws 16 tiles across and 8 tiles down from a 128 byte map stored at Map
;  Every byte in Map is a number which represents a tile.
;  Tile data starts at MapSprites, and the sprite is retrieved with the
equation:
;   Sprite = MapSprites + (8 * MAP NUMBER), because there are 8 bytes per
sprite
;===========================================================================
DrawMap:
 ld de, $0700		; X Counter = 7, Y Counter = 0
 ld hl, Map		; HL --> (16 x 8) Map
 ld b, 14		; Map 14 bytes wide on display

LoopY:
 push bc		; Save Counter
 ld b, 8		; Map 8 bytes wide (high when drawn)

LoopX:
 push hl 		; Save MAP pointer
 push de		; HL -> Bitmap Tile by equ: 8 * MAP NUMBER

  ld l, (hl)		; Load Tile # into L
  ld h, 0
  add hl, hl		; Multiply by 8
  add hl, hl
  add hl, hl
  ex de, hl		; DE = Address Offset
  ld hl, MapSprites 	; HL -> Start Bitmapped Tile Data
  add hl, de		; HL -> Correct Bitmapped Tile for that MAP NUMBER

 pop de

  push de
  push bc 		; Save X counter
  push ix
   call GridPutSprite; PutSprite HL at (E, D) to virtual screen
  pop ix
  pop bc		; Recover Counter
  pop de

ExitLoopX:

 pop hl		; Recover Map Pointer
 inc hl		; Next Map Tile in Map Pointer
 dec d			; One tile closer to top of screen

 djnz LoopX	

 ld d, 7		; reset D counter
 inc e			; One tile closer to right of screen
 pop bc		; Recover Counter
 djnz LoopY

 ret


;============================================================================
; GridPutSprite:  (Dan Eble?)
;  Puts an aligned sprite at (E, D), where HL -> Sprite
;===========================================================================
; IN : D  = y (0-7 inclusive)
;      E  = x (0-15 inclusive)
;      HL-> sprite
;
; OUT: AF, BC, DE, HL, IX modified
; Current total : 28b/567t (not counting ret)
;===========================================================================
GridPutSprite:
 push hl
 pop ix          ; ix-> sprite

 srl d           ; de = 128y+x (16 bytes/row, 8 rows)
 rra
 and $80
 or e            ; add x offset (remember x <= 15)
 ld e,a

 ld hl,$fc00   ; hl-> video mem
 add hl,de     ; hl-> video mem + offset


 ld b,8          ; initialize loop counter
 ld de,$10 	   ; initialize line increment

GPS_Loop
 ld a,(ix+0)     ; get byte from sprite
 ld (hl),a       ; put byte on screen
 inc ix          ; move to next byte in sprite
 add hl,de       ; move to next line on screen

 djnz GPS_Loop
 ret


At 07:36 PM 8/5/98 PDT, you wrote:
>
>Anyone help me. I need a Map reader to read a 8x16 Level Map. Depending 
>on if each bit of the map is on or off I need it to display either a 
>grass sprite or a Block sprite. These are 8x8 sprites. BIOSERRORS helped 
>me but he didn't give me an example of how to use the map reader to 
>display sprites. Anyone who helps me will get MAJOR credit for the game. 
>Your Name WILL be on the Title Screen. Please help! All I need is the 
>level reader that puts sprites to the screen. I have one by BIOSERRORS 
>that I can use to see If a block's in front of you. PLEASE HELP!
>
>InFuZeD at Zone TI - "Making Basic Programming Worth While"
>
>
>______________________________________________________
>Get Your Private, Free Email at http://www.hotmail.com
>

--
David Phillips
mailto:electrum@tfs.net
ICQ: 13811951
AOL/AIM: electrum32


References: