|
|
Put Vertical Tile RoutineThe following file is a routine to place a vertical 1x2 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. 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. Explanation
Source
;*****************************************************************
; Procedure Name : put_vertical_tile
;
; Author : Marc Gale (Xalthorn or Eldara)
;
; Description : Places a single 1x2 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_vertical_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 [hl],a ; place it on the map
inc a ; next tile number
ld d,0 ; set up DE ...
ld e,32 ; ... to hold 32
add hl,de ; add 32 to map pointer (one row down,
; one tile back)
ld [hl],a ; place the tile 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 [hl],a ; place it on the map
ld d,0 ; set up DE ...
ld e,32 ; ... to hold 32
add hl,de ; add 32 to map pointer (one row down,
; one tile back)
ld [hl],a ; place the data on the map
ret ; we're done
|