Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized _SetTextXY #47

Merged
merged 2 commits into from
Feb 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 8 additions & 35 deletions CEdev/lib/src/graphics/graphx/graphics_lib.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2615,36 +2615,14 @@ _SetTextXY:
; arg1 : Text Y Pos
; Returns:
; None
jp _SetTextXY_ASM \.r
SetTextXY_SMC =$-3
_SetTextXY_ASM:
ld hl,3
add hl,sp ; hl -> arg0
ld de,TextXPos_SMC \.r
ldi
ldi ; copy in new x pos
inc hl
ld a,(hl)
ld (TextYPos_SMC),a \.r ; set new y pos
ret

;-------------------------------------------------------------------------------
_SetTextXY_Clip_ASM:
; Sets the text X and Y positions
; Arguments:
; arg0 : Text X Pos
; arg1 : Text Y Pos
; Returns:
; None
ld hl,3
add hl,sp ; hl -> arg0
ld de,TextXPos_SMC \.r
ldi
ldi
ldi ; copy in new x pos
ld hl,(hl)
ld (TextYPos_SMC),hl \.r ; set new y pos
ret
pop de ; de=return address, sp=&xpos
pop hl ; hl=xpos, sp=&ypos
ld (TextXPos_SMC),hl \.r
ex (sp),hl ; hl=ypos, ypos=don't care
ld (TextYPos_SMC),hl \.r
push hl ; xpos=don't care, sp=&xpos
ex de,hl ; hl=return address
jp (hl)

;-------------------------------------------------------------------------------
_PrintStringXY_Clip_ASM:
Expand Down Expand Up @@ -2780,12 +2758,10 @@ _SetTextConfig:
ret nz
ld de,_PrintChar_ASM \.r
ld bc,_PrintStringXY_ASM \.r
ld iy,_SetTextXY_ASM \.r
jr SetCharSMC ; set unclipped character routine
SetClipText:
ld de,_PrintChar_Clip_ASM \.r
ld bc,_PrintStringXY_Clip_ASM \.r
ld iy,_SetTextXY_Clip_ASM \.r
SetCharSMC:
ld hl,PrintChar_SMC_0 \.r
ld (hl),de ; holy crap what a hack
Expand All @@ -2798,9 +2774,6 @@ SetCharSMC:
push bc
pop hl
ld (PrintStringXY_SMC),hl \.r ; change which text routines we want to use
push iy
pop hl
ld (SetTextXY_SMC),hl \.r
or a,a
sbc hl,hl
ld (TextYPos_SMC),hl \.r
Expand Down