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 Double Tile Routine

The following file is a routine to place a single 2x2 tile on the background or window. Bear in mind that the routine does not check for valid x and y positions.

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

putdtile.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_double_tile
;
; Author          : Marc Gale (Xalthorn or Eldara)
;
; Description     : Places a single 2x2 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  = Base 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_double_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

 push   hl              ; preserve the map pointer
 ld     a,c             ; get the first tile number
 ld     [hli],a         ; place it on the map and increase HL
 inc    a               ; next tile number
 ld     [hl],a          ; place it on the map
 inc    a               ; next tile number
 ld     d,0             ; set up DE ...
 ld     e,31            ; ... to hold 31
 add    hl,de           ; add 31 to map pointer (one row down,
                        ; one tile back)
 ld     [hli],a         ; place the tile on the map
 inc    a               ; next tile
 ld     [hl],a          ; place it on the map

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

 pop    hl              ; restore map pointer
 pop    de              ; restore bank 1 data
 ld     a,d             ; get the bank 1 data
 ld     [hli],a         ; place it on the map, increase HL
 ld     [hl],a          ; place it on the map
 ld     d,0             ; set up DE ...
 ld     e,31            ; ... to hold 31
 add    hl,de           ; add 31 to map pointer (one row down,
                        ; one tile back)
 ld     [hli],a         ; place the data on the map
 ld     [hl],a          ; last one

 ret                    ; we're done

Buttons created using the interactive button maker at Coolarchive