Skip to content

Commit 367b618

Browse files
mateoconlechugaadriweb
authored andcommitted
fix gfx_TilePtr
1 parent 6183d05 commit 367b618

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/graphx/graphx.asm

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,7 +2873,7 @@ gfx_TilePtr:
28732873
ld ix,0
28742874
add ix,sp
28752875
ld iy,(ix+6)
2876-
ld hl,(ix+x_offset)
2876+
ld hl,(ix+9)
28772877
ld a,(iy+t_type_width)
28782878
or a,a
28792879
jr nz,.fastdiv0
@@ -2890,7 +2890,7 @@ gfx_TilePtr:
28902890
djnz .div0
28912891
.widthnotpow2:
28922892
ex de,hl
2893-
ld hl,(ix+y_offset)
2893+
ld hl,(ix+12)
28942894
ld a,(iy+t_type_height)
28952895
or a,a
28962896
jr nz,.fastdiv1
@@ -2927,17 +2927,18 @@ gfx_TilePtrMapped:
29272927
pop de ; return vector
29282928
pop iy ; tilemap struct
29292929
pop bc ; x offset
2930-
ex (sp),hl ; y offset
2931-
push bc
2930+
pop hl ; y offset
2931+
push hl
29322932
push bc
2933+
push iy
2934+
push de
29332935
ld h,(iy+13) ; tilemap width
29342936
mlt hl
29352937
ld b,0
29362938
add.s hl,bc
29372939
ld bc,(iy+0) ; tilemap data
29382940
add hl,bc
2939-
ex de,hl
2940-
jp (hl)
2941+
ret
29412942

29422943
;-------------------------------------------------------------------------------
29432944
gfx_GetTextX:

src/graphx/graphx.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,8 @@ void gfx_TransparentTilemap_NoClip(gfx_tilemap_t *tilemap,
416416

417417
/**
418418
* Gets a pointer to a particular tile given an initialized tilemap
419-
* structure and pixel offsets.
419+
* structure and pixel offsets. Measurement is done from the actual
420+
* tilemap, not the drawn offset location.
420421
*
421422
* @param tilemap Pointer to initialized tilemap structure.
422423
* @param x_offset Offset in pixels from the left of the tilemap.

0 commit comments

Comments
 (0)