Skip to content

Commit fa7d322

Browse files
committed
Optimize gfx_PrintStringXY and gfx_SetTextConfig
1 parent 0247884 commit fa7d322

File tree

1 file changed

+16
-62
lines changed

1 file changed

+16
-62
lines changed

src/graphx/graphx.asm

Lines changed: 16 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,26 +2950,6 @@ gfx_SetFontHeight:
29502950
; Previous font height
29512951
setSmcBytes _TextHeight
29522952

2953-
;-------------------------------------------------------------------------------
2954-
_PrintStringXY_Clip:
2955-
; Places a string at the given coordinates
2956-
; Arguments:
2957-
; arg0 : Pointer to string
2958-
; arg1 : Text X Pos
2959-
; arg2 : Text Y Pos
2960-
; Returns:
2961-
; None
2962-
ld iy,3
2963-
lea bc,iy
2964-
add iy,sp
2965-
lea hl,iy+3
2966-
ld de,_TextXPos
2967-
ldir ; copy in the y location
2968-
ld hl,(hl)
2969-
ld (_TextYPos),hl ; set new y pos
2970-
ld hl,(iy)
2971-
jr _DrawCharacters ; jump to the main string handler
2972-
29732953
;-------------------------------------------------------------------------------
29742954
gfx_PrintStringXY:
29752955
; Places a string at the given coordinates
@@ -2979,21 +2959,12 @@ gfx_PrintStringXY:
29792959
; arg2 : Text Y Pos
29802960
; Returns:
29812961
; None
2982-
jp _PrintStringXY
2983-
__PrintStringXY = $-3
2984-
_PrintStringXY:
2985-
ld hl,9
2986-
add hl,sp
2987-
ld a,(hl)
2988-
ld (_TextYPos),a
2989-
dec hl
2990-
dec hl
2991-
ld de,_TextXPos + 1
2992-
ldd
2993-
ldd
2994-
dec hl
2995-
dec hl
2996-
ld hl,(hl)
2962+
pop iy ; iy = return vector
2963+
pop bc ; bc = str
2964+
call gfx_SetTextXY
2965+
push bc
2966+
ex (sp),hl ; hl = str
2967+
push iy
29972968
; jr _DrawCharacters ; emulated by dummifying next instructions:
29982969
db $01 ; pop de \ ex (sp),hl \ push de -> ld bc,*
29992970

@@ -3064,35 +3035,18 @@ gfx_SetTextConfig:
30643035
; arg0 : Configuration numbers
30653036
; Returns:
30663037
; None
3067-
pop hl
30683038
pop de
3039+
ex (sp),hl ; hl = config
30693040
push de
3070-
push hl
3071-
ld a,e ; a = argument
3072-
dec a ; 1 = TEXT_CLIP
3073-
jr z,.setcliptext
3074-
dec a ; 2 = TEXT_NOCLIP
3075-
ret nz
3076-
ld de,_PrintChar
3077-
ld bc,_PrintStringXY
3078-
jr .setunclippedtext ; set unclipped character routine
3079-
.setcliptext:
3080-
ld de,_PrintChar_Clip
3081-
ld bc,_PrintStringXY_Clip
3082-
.setunclippedtext:
3083-
ld hl,PrintChar_0
3084-
ld (hl),de ; holy crap what a hack
3085-
ld hl,PrintChar_1
3086-
ld (hl),de
3087-
ld hl,PrintChar_2
3088-
ld (hl),de ; modify all the interal routines to use the clipped text routine
3089-
push bc
3090-
pop hl
3091-
ld (__PrintStringXY),hl ; change which text routines we want to use
3092-
xor a,a
3093-
sbc hl,hl
3094-
ld (_TextYPos),hl
3095-
ld (_TextXPos),hl ; reset the current posistions
3041+
dec l ; l = config - 1
3042+
ld hl,_PrintChar_Clip
3043+
jr z,.writesmc ; z ==> config == gfx_text_clip
3044+
; config == gfx_text_noclip
3045+
ld hl,_PrintChar
3046+
.writesmc: ; hl = PrintChar routine
3047+
ld (PrintChar_0),hl
3048+
ld (PrintChar_1),hl
3049+
ld (PrintChar_2),hl
30963050
ret
30973051

30983052
;-------------------------------------------------------------------------------

0 commit comments

Comments
 (0)