Skip to content

Commit fc43abb

Browse files
committed
Optimized _SetColor and _SetTransparentColor
1 parent 4b3f137 commit fc43abb

File tree

2 files changed

+21
-25
lines changed

2 files changed

+21
-25
lines changed
Binary file not shown.

CEdev/lib/src/graphics/graphx/graphics_lib.asm

+21-25
Original file line numberDiff line numberDiff line change
@@ -274,20 +274,20 @@ _SetColor:
274274
; arg0 : Global color index
275275
; Returns:
276276
; Previous global color index
277-
pop hl
278-
pop de
279-
push de ; e = new color value
280-
push hl
281-
ld hl,Color_SMC_1 \.r ; load the address of the current color
282-
ld d,(hl) ; d = old color
283-
ld a,e
284-
ld (hl),a
277+
pop de ;; de = return vetor
278+
ex (sp),hl ;; l = color
279+
ld a,l ;; a = color
280+
ld hl,Color_SMC_1 \.r
281+
ld c,(hl) ;; c = old color
282+
ld (hl),a ; store all the new color values
285283
ld (Color_SMC_2),a \.r
286284
ld (Color_SMC_3),a \.r
287-
ld (Color_SMC_4),a \.r ; store all the new color values
288-
ld (Color_SMC_5),a \.r ; store all the new color values
289-
ld a,d ; return previous color index
290-
ret
285+
ld (Color_SMC_4),a \.r
286+
ld (Color_SMC_5),a \.r
287+
_SetColor_Ret:
288+
ld a,c ; a = old color
289+
ex de,hl
290+
jp (hl)
291291

292292
;-------------------------------------------------------------------------------
293293
_SetTransparentColor:
@@ -296,19 +296,16 @@ _SetTransparentColor:
296296
; arg0 : Transparent color index
297297
; Returns:
298298
; Previous transparent color index
299-
pop hl
300-
pop de
301-
push de ; e = new transparent color value
302-
push hl
303-
ld hl,TColor_SMC_1 \.r ; load the address of the current transparent color
304-
ld d,(hl) ; d = old color
305-
ld a,e
306-
ld (hl),a
299+
pop de ;; de = return vetor
300+
ex (sp),hl ;; l = color
301+
ld a,l ;; a = color
302+
ld hl,TColor_SMC_1 \.r
303+
ld c,(hl) ;; c = old color
304+
ld (hl),a ; store all the new color values
307305
ld (TColor_SMC_2),a \.r
308-
ld (TColor_SMC_3),a \.r ; store all the new transparent colors
309-
ld (TColor_SMC_4),a \.r ; store all the new transparent colors
310-
ld a,d ; return previous transparent color index
311-
ret
306+
ld (TColor_SMC_3),a \.r
307+
ld (TColor_SMC_4),a \.r
308+
jr _SetColor_Ret
312309

313310
;-------------------------------------------------------------------------------
314311
_Begin:
@@ -4536,4 +4533,3 @@ tmpCharData:
45364533
.db 0,0,0,0,0,0,0,0
45374534
45384535
.endLibrary
4539-

0 commit comments

Comments
 (0)