[A83] Tilemap problems


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

[A83] Tilemap problems



Could someone please help me with this problem that I am having with my
program. I am trying to make a tilemap reader that will display 6 x 6
sprites on the screen. I seem to be having two problems though. The first is
whenever it displays the image that it has made it looks garbled. The second
is that the 'ret' command to return to the part from which it was called won
t work it just takes me out of the program. I have a comment next to were it
won't work (it is right before the tilemap itself.) If anyone could help it
would be greatly appreciated. The code is below, and once again thank you to
anyone who will help.
Start:
bcall(_runindicoff)
ld a,0
ld (X),a
call TilemapDraw
bcall(_grbufcpy)
bcall(_getkey)
ret
TilemapDraw:
bcall(_grbufclr)
ld hl,Tilemap
ld de,(X)
ld d,0
add hl,de
ld de,0000h     ;So we start out at 0,0
ld b,10             ;The height of my columns
RowLoop:
push bc
ld b,13            ;The width of my rows
ColumnLoop:
ld a,(hl)
inc hl
push hl
ld l,a
ld h,0
add hl,hl
add hl,hl
push de
ld de,sprites
add hl,de
pop de
push bc
ld b,6                 ;The width of our sprite
ld l,d                  ;Our postion on the screen
ld a,e
push de
call ionputsprite
pop de
ld a,6
add a,e
ld e,a
pop bc             ;Gets the bc that we used to store the rows
pop hl
djnz ColumnLoop
ld e,00h
ld a,6
add a,d
ld d,a
pop bc            ;Gets the bc that we used to store the columns
djnz RowLoop
ret                     ;THIS IS THE RET COMMAND THAT WONT WORK
Tilemap:
.db 0,0,0,0,0,0,0,0,0,0,0,0,0
.db 1,2,1,1,1,2,1,1,1,1,1,1,2
.db 0,2,0,0,0,2,0,0,0,0,0,0,2
.db 1,1,1,2,1,1,1,1,1,1,2,1,1
.db 0,0,0,2,0,0,0,0,0,0,2,0,0
.db 1,2,1,1,1,2,1,1,1,1,1,1,1
.db 0,2,0,0,0,2,0,0,0,0,0,0,0
.db 1,1,1,2,1,1,1,1,1,1,2,1,1
.db 0,0,0,2,0,0,0,0,0,0,2,0,0
.db 1,1,1,1,1,1,1,1,1,1,1,1,1
sprites:
blankspace: ;0
.db %000000
.db %000000
.db %000000
.db %000000
.db %000000
.db %000000
floor: ;1
.db %110110
.db %110110
.db %000000
.db %101101
.db %101101
.db %111111
ladder: ;2
.db %111100
.db %001100
.db %001100
.db %001111
.db %001100
.db %001100