The Lush Engine








Introduction
Background
Introduction
bgtiles.asm
bgtiled.asm
bgtilem.asm
putstile.asm
putdtile.asm
puthtile.asm
putvtile.asm
putmtile.asm
wallmeld.asm
Math
Objects
Palettes
Tiles
Utilities

Put Single Tile Routine

The following file is a routine to place a single tile on the background or window.

You can download the file as well if you don't want to cut and paste the text.

putstile.asm

To download the file using a PC, right-click the link and select the option "Save Target As" then save the file as you would any other file from windows.

This routine calls the 8 bit multiply routine, so if you haven't already got that, you can download it from here.

mult8.asm

Explanation

Source

;*****************************************************************
; Procedure Name  : put_single_tile
;
; Author          : Marc Gale (Xalthorn or Eldara)
;
; Description     : Places a single tile on the background or
;                   window (depending upon where you tell it the
;                   base address of the tile map is)
;
; On Entry        : A  = Tile bank for the tile
;                   B  = Y position (0-31)
;                   C  = Tile number
;                   D  = Palette number
;                   E  = X position (0-31)
;                   HL = Base address of tile map
;
; During          : All registers are used
;
; On Exit         : Nothing intentional
;*****************************************************************
put_single_tile:
 sla    a               ; move the ...
 sla    a               ; ... bank number to the ...
 sla    a               ; correct bit
 or     d               ; mix it with the palette number
 ld     d,a             ; store the result in d
 push   de              ; preserve d for later

 ld     a,0             ; select ...
 ldh    [$4F],a         ; ... data bank 0

 ld     d,0             ; set the high byte of DE to 0
 add    hl,de           ; increase the map pointer

 ld     a,b             ; grab the y position
 ld     b,32            ; put 32 (a row width) into b
 call   multiply_8      ; multiply a x b
 add    hl,de           ; add the result to the map pointer

 ld     a,c             ; get the tile number
 ld     [hl],a          ; place it on the map

 ld     a,1             ; switch to data ...
 ldh    [$4F],a         ; ... bank 1

 pop    de              ; restore bank 1 data
 ld     a,d             ; get the bank 1 data
 ld     [hl],a          ; place it on the map

 ret                    ; we're done

Buttons created using the interactive button maker at Coolarchive