@@ -2362,6 +2362,9 @@ _: ld (DrawTile_SMC),hl \.r
23622362 or a , a
23632363 jr nz , _height_is_pow2
23642364 call __idvrmu
2365+ ex de , hl
2366+ push de
2367+ pop bc
23652368 jr _height_is_not_pow2
23662369_height_is_pow2: ; compute as power of 2 height using shifts
23672370 ld b , a
@@ -2373,15 +2376,18 @@ _: srl h
23732376 rr l
23742377 djnz - _
23752378_height_is_not_pow2:
2376- ld (ix +- 4 ) , l ; y = y_offset / tilemap->t_tile_height
2377- ld (ix + y_offset) , bc ; y_offset = y_offset % tilemap->t_tile_height ;
2379+ ld (ix +- 4 ) , l ; y = y_offset / tilemap->tile_height
2380+ ld (ix + y_offset) , bc ; y_offset = y_offset % tilemap->tile_height ;
23782381
23792382 ld c , (iy + t_tile_width)
23802383 ld hl , (ix + x_offset) ; x offset
23812384 ld a , (iy + t_type_width)
23822385 or a , a
23832386 jr nz , _width_is_pow2
23842387 call __idvrmu
2388+ ex de , hl
2389+ push de
2390+ pop bc
23852391 jr _width_is_not_pow2
23862392_width_is_pow2:
23872393 ld b , a
@@ -2398,7 +2404,7 @@ _width_is_not_pow2:
23982404 ld hl , (iy + t_x_loc)
23992405 or a , a
24002406 sbc hl , bc
2401- ld (x_offset_smc) , hl \.r ; x_offset_smc = tilemap->t_x_loc - x_offset;
2407+ ld (x_offset_smc) , hl \.r ; x_offset_smc = tilemap->x_loc - x_offset;
24022408
24032409 or a , a
24042410 sbc hl , hl
@@ -2422,6 +2428,7 @@ x_offset_smc =$+1
24222428 jr X_Loop
24232429
24242430_x_loop_inner:
2431+ or a , a
24252432 sbc hl , hl
24262433 ld l , (ix +- 1 )
24272434 ld bc , (iy + t_data) ; iy -> tilemap data
@@ -2490,7 +2497,7 @@ _TilePtr:
24902497; A pointer to an indexed tile in the tilemap (so it can be looked at or changed)
24912498; C Function:
24922499; uint8_t *gfx_TilePtr(gfx_tilemap_t *tilemap, unsigned x_offset, unsigned y_offset) {
2493- ; return &tilemap->map[(x_offset/tilemap->t_tile_width )+((y_offset/tilemap->t_tile_height )*tilemap->width)];
2500+ ; return &tilemap->map[(x_offset/tilemap->tile_width )+((y_offset/tilemap->tile_height )*tilemap->width)];
24942501; }
24952502 push ix
24962503 ld ix , 0
@@ -2499,10 +2506,11 @@ _TilePtr:
24992506 ld hl , (ix + x_offset)
25002507 ld a , (iy + t_type_width)
25012508 or a , a
2502- jr z ,+ _
2509+ jr nz ,+ _
25032510 ld bc , 0
25042511 ld c , (iy + t_tile_width)
25052512 call __idvrmu
2513+ ex de , hl
25062514 jr _width_no_pow2
25072515_: ld b , a
25082516_: srl h
@@ -2513,10 +2521,13 @@ _width_no_pow2:
25132521 ld hl , (ix + y_offset)
25142522 ld a , (iy + t_type_height)
25152523 or a , a
2516- jr z ,+ _
2524+ jr nz ,+ _
25172525 ld bc , 0
25182526 ld c , (iy + t_tile_height)
2527+ push de
25192528 call __idvrmu
2529+ ex de , hl
2530+ pop de
25202531 jr _height_no_pow2
25212532_: ld b , a
25222533_: srl h
0 commit comments