@@ -71,7 +71,7 @@ include_library '../lcddrvce/lcddrvce.asm'
7171 export gfy_TransparentTilemap
7272 export gfy_TransparentTilemap_NoClip
7373 export gfy_TilePtr
74- export gfy_TilePtrMapped
74+ ; export gfy_TilePtrMapped
7575 export gfy_AllocSprite
7676 export gfy_Sprite
7777 export gfy_TransparentSprite
@@ -391,13 +391,13 @@ gfy_AllocSprite: ; COPIED_FROM_GRAPHX
391391 add hl , bc
392392 ld d , (hl) ; d = height
393393 add hl , bc
394- ld hl , (hl) ; hl = malloc
394+ ld iy , (hl) ; iy = malloc
395395 push de
396396 mlt de ; de = width * height
397397 inc de ; +2 to store width and height
398398 inc de ; de = width * height + 2
399399 push de
400- call _indcallHL ; hl = malloc(width * height + 2)
400+ call ti._indcall ; hl = malloc(width * height + 2)
401401 pop de
402402 pop de ; e = width, d = height, ude = unknown
403403 ; check if malloc failed (hl == 0)
@@ -637,6 +637,7 @@ FillScreen_FastCode_SrcSize := FillScreen_FastCode_DestSize-(FillScreen_PushesP
637637FillScreen_FastCode_SrcEnd := $
638638
639639;-------------------------------------------------------------------------------
640+ if 0
640641gfy_ZeroScreen: ; COPIED_FROM_GRAPHX
641642; Fills the screen with color index 0
642643; Arguments:
@@ -648,6 +649,7 @@ gfy_ZeroScreen: ; COPIED_FROM_GRAPHX
648649 call gfy_FillScreen
649650 pop hl
650651 ret
652+ end if
651653
652654;-------------------------------------------------------------------------------
653655gfy_SetPalette: ; COPIED_FROM_GRAPHX
@@ -3346,41 +3348,45 @@ gfy_TilePtr: ; COPIED_FROM_GRAPHX
33463348; uint8_t *gfy_TilePtr(gfy_tilemap_t *tilemap, unsigned x_offset, unsigned y_offset) {
33473349; return &tilemap->map[(x_offset/tilemap->tile_width)+((y_offset/tilemap->tile_height)*tilemap->width)];
33483350; }
3349- push ix
3350- ld ix , 0
3351- add ix , sp
3352- ld iy , (ix + 6 )
3353- ld hl , (ix + 9 )
3354- ld a , (iy + t_type_width)
3355- or a , a
3356- jr nz , .fastdiv0
3357- ld bc , 0
3351+ ld bc , 3
3352+ push bc
3353+ pop hl
3354+ add hl , sp
3355+ ld iy , (hl)
3356+ add hl , bc
3357+ ld hl , (hl)
3358+ ld b , (iy + t_type_width)
3359+ inc b
3360+ djnz .fastdiv0
3361+ ; UBC and B are zero
33583362 ld c , (iy + t_tile_width)
33593363 call ti._idvrmu
3360- ex de , hl
33613364 jr .widthnotpow2
3365+
33623366.fastdiv0:
3363- ld b , a
33643367.div0:
33653368 srl h
33663369 rr l
33673370 djnz .div0
3368- .widthnotpow2:
33693371 ex de , hl
3370- ld hl , (ix + 12 )
3371- ld a , (iy + t_type_height)
3372- or a , a
3373- jr nz , .fastdiv1
3374- ld bc , 0
3372+ .widthnotpow2:
3373+ ld hl , 9
3374+ add hl , sp
3375+ ld hl , (hl)
3376+ ld b , (iy + t_type_height)
3377+ inc b
3378+ djnz .fastdiv1
3379+ ; UBC and B are zero
33753380 ld c , (iy + t_tile_height)
33763381 push de
33773382 call ti._idvrmu
33783383 ex de , hl
33793384 pop de
33803385 jr .heightnotpow2
3386+
33813387.fastdiv1:
3382- ld b , a
3383- .div1: srl h
3388+ .div1:
3389+ srl h
33843390 rr l
33853391 djnz .div1
33863392.heightnotpow2:
@@ -3389,10 +3395,10 @@ gfy_TilePtr: ; COPIED_FROM_GRAPHX
33893395 add hl , de
33903396 ld de , (iy + t_data)
33913397 add hl , de
3392- pop ix
33933398 ret
33943399
33953400;-------------------------------------------------------------------------------
3401+ if 0
33963402gfy_TilePtrMapped: ; COPIED_FROM_GRAPHX
33973403; Returns a direct pointer to the input tile
33983404; Arguments:
@@ -3415,6 +3421,7 @@ gfy_TilePtrMapped: ; COPIED_FROM_GRAPHX
34153421 ld bc , (iy + 0 ) ; tilemap data
34163422 add hl , bc
34173423 ret
3424+ end if
34183425
34193426;-------------------------------------------------------------------------------
34203427gfy_GetTextX: ; COPIED_FROM_GRAPHX
@@ -3451,11 +3458,6 @@ gfy_SetTextXY: ; COPIED_FROM_GRAPHX
34513458 ld (_TextYPos) , hl
34523459 push hl ; xpos=don't care, sp=&xpos
34533460 ex de , hl ; hl=return address
3454- ;-------------------------------------------------------------------------------
3455- _indcallHL: ; COPIED_FROM_GRAPHX
3456- ; Calls HL
3457- ; Inputs:
3458- ; HL : Address to call
34593461 jp (hl)
34603462
34613463;-------------------------------------------------------------------------------
@@ -4082,13 +4084,17 @@ gfy_SetCharData: ; COPIED_FROM_GRAPHX
40824084; arg0 : Pointer to character data; if null returns current data
40834085; Returns:
40844086; Pointer to character data if null, otherwise pointer to next character
4085- ld iy , 0
4086- add iy , sp
4087+ ld hl , 6
4088+ add hl , sp
4089+ ld de , (hl) ; de -> custom_character_data
4090+ dec hl
4091+ dec hl
4092+ dec hl
4093+ ld a , (hl)
40874094 sbc hl , hl ; ld hl, 0
4088- ld de , (iy + 6 ) ; de -> custom_character_data
40894095 sbc hl , de ; sets z flag if NULL
40904096 add hl , de
4091- ld l , (iy + 3 ) ; hl = index
4097+ ld l , a ; hl = index
40924098 add hl , hl
40934099 add hl , hl
40944100 add hl , hl
@@ -6935,8 +6941,6 @@ __lshru := $0001EC
69356941; for debugging
69366942_boot_sprintf := $ 0000BC
69376943
6938- __indcallhl := _indcallHL
6939-
69406944;-------------------------------------------------------------------------------
69416945; inlined routines
69426946;-------------------------------------------------------------------------------
@@ -6955,6 +6959,9 @@ _memcpy:
69556959 ld hl , (iy + 4 ) ; Return the destination pointer
69566960 ret
69576961
6962+ __indcallhl:
6963+ jp (hl)
6964+
69586965__set_bc_and_mul_hl_by_240:
69596966 push hl
69606967 pop bc
0 commit comments