[A83] Re: Scroll/TileMap
[Prev][Next][Index][Thread]
[A83] Re: Scroll/TileMap
> From: "Nicholas Palladino" <nickps1@hotmail.com>
>
> How could I make a Tile map or backround, and make it scroll
> form right to left across the sceen? An example is how could I
> make a mario level that scrolls and haveand has placed 8*8
> sprites like the boxes in mario. If anyone knows how to do
> this without using any shells just in plain asm please tell me.
>
> -Thanks
>
With 8*8 tiles a normal tilemap on a 96*64 screen is 12*8. So, to be able to
scroll the screen left and right, make the tilemap bigger, e.g. 16*8. You're
tilemap routine should then, after drawing a row off 12 tiles, skip 4 bytes
to draw the next the row on the screen. Now to scroll the screen, just
inc/dec some coordinate, which tells where to start drawing the tilemap.
Next piece of code shows the basics...
moveRight:
ld a,(position)
inc a
jr update
moveLeft:
ld a,(position)
dec a
update:
ld (position),a
ld d,0
ld e,a
ld hl,tilemap
add hl,de ; now HL is tilemap+(position)
drawTileMap:
; draw the tilemap with HL pointing to the start
; remember after drawing a row (screen is 12 tiles wide)
; to skip 4 bytes (because the tilemap is 16 tiles wide)
...
position:
.db 0
tilemap:
.db 0,0,...16x...,0,0
...8x....
.db 0,0,...16x...,0,0
tiledata:
...
Tijl Coosemans
Follow-Ups:
References: