From a3b2a38bcbbcfc12f9d7fee3ea8e35c8a1604d43 Mon Sep 17 00:00:00 2001 From: Zachary Wassall <runer112@gmail.com> Date: Thu, 2 Feb 2017 00:37:42 -0500 Subject: [PATCH 1/3] Optimized _AllocSprite --- .../lib/src/graphics/graphx/graphics_lib.asm | 49 +++++++++++-------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/CEdev/lib/src/graphics/graphx/graphics_lib.asm b/CEdev/lib/src/graphics/graphx/graphics_lib.asm index 9c70ab826..aaccd3ba1 100644 --- a/CEdev/lib/src/graphics/graphx/graphics_lib.asm +++ b/CEdev/lib/src/graphics/graphx/graphics_lib.asm @@ -121,27 +121,27 @@ _AllocSprite: ; arg2 : pointer to malloc routine ; Returns: ; Pointer to allocated sprite, first byte width, second height - ld iy,0 - add iy,sp - ld l,(iy+3) ; l = width of sprite - ld h,(iy+6) ; h = height of sprite - ld iy,(iy+9) ; iy = pointer to some malloc - push hl - mlt hl ; width * height - inc hl - inc hl ; allocate space for width and height bytes - push hl - call __indcall ; call the malloc routine - pop de - pop de - add hl,de - or a,a - sbc hl,de - ret z ; check to make sure malloc did not fail - ld (hl),e ; store width - inc hl - ld (hl),d ; store height - dec hl ; return sprite pointer + ld bc,3 + push bc + pop hl + add hl,sp + ld e,(hl) ;; e = width + add hl,bc + ld d,(hl) ;; d = height + add hl,bc + ld hl,(hl) ;; hl = malloc + push de + mlt de ;; de = width * height + inc de ; +2 to store width and height + inc de ;; de = width * height + 2 + push de + call _indcallHL_ASM ;; hl = malloc(width * height + 2) + pop de ;; de = width * height + 2 + add hl,de ; this should never carry + sbc hl,de ; check if malloc failed (hl == 0) + pop de ;; e = width, d = height + ret z ; abort if malloc failed + ld (hl),de ; store width and height ret ;------------------------------------------------------------------------------- @@ -4368,6 +4368,13 @@ _: rla xor a,1 ret +;------------------------------------------------------------------------------- +_indcallHL_ASM: +; Calls HL +; Inputs: +; HL : Address to call + jp (hl) + ;------------------------------------------------------------------------------- CharSpacing_ASM: .dl DefaultCharSpacing_ASM \.r From 61efd2d107a816853e4fdb510748e9b7b6da55d9 Mon Sep 17 00:00:00 2001 From: Zachary Wassall <runer112@gmail.com> Date: Thu, 2 Feb 2017 00:51:44 -0500 Subject: [PATCH 2/3] Utilized a preexisting jp (hl) for _indcallHL_ASM --- CEdev/lib/src/graphics/graphx/graphics_lib.asm | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/CEdev/lib/src/graphics/graphx/graphics_lib.asm b/CEdev/lib/src/graphics/graphx/graphics_lib.asm index aaccd3ba1..37968502e 100644 --- a/CEdev/lib/src/graphics/graphx/graphics_lib.asm +++ b/CEdev/lib/src/graphics/graphx/graphics_lib.asm @@ -2622,6 +2622,11 @@ _SetTextXY: ld (TextYPos_SMC),hl \.r push hl ; xpos=don't care, sp=&xpos ex de,hl ; hl=return address +;------------------------------------------------------------------------------- +_indcallHL_ASM: +; Calls HL +; Inputs: +; HL : Address to call jp (hl) ;------------------------------------------------------------------------------- @@ -4368,13 +4373,6 @@ _: rla xor a,1 ret -;------------------------------------------------------------------------------- -_indcallHL_ASM: -; Calls HL -; Inputs: -; HL : Address to call - jp (hl) - ;------------------------------------------------------------------------------- CharSpacing_ASM: .dl DefaultCharSpacing_ASM \.r From 9cee925fdb61d3f0297013ed2b738481f0eb6b02 Mon Sep 17 00:00:00 2001 From: Matt Waltz <matthewwaltzis@gmail.com> Date: Thu, 6 Apr 2017 11:00:53 -0700 Subject: [PATCH 3/3] Fix missing \.r --- src/graphx/graphx.asm | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/graphx/graphx.asm b/src/graphx/graphx.asm index e303f6d25..e7661e38e 100644 --- a/src/graphx/graphx.asm +++ b/src/graphx/graphx.asm @@ -137,23 +137,23 @@ _AllocSprite: push bc pop hl add hl,sp - ld e,(hl) ;; e = width + ld e,(hl) ; e = width add hl,bc - ld d,(hl) ;; d = height + ld d,(hl) ; d = height add hl,bc - ld hl,(hl) ;; hl = malloc + ld hl,(hl) ; hl = malloc push de - mlt de ;; de = width * height - inc de ; +2 to store width and height - inc de ;; de = width * height + 2 + mlt de ; de = width * height + inc de ; +2 to store width and height + inc de ; de = width * height + 2 push de - call _indcallHL_ASM ;; hl = malloc(width * height + 2) - pop de ;; de = width * height + 2 - add hl,de ; this should never carry - sbc hl,de ; check if malloc failed (hl == 0) - pop de ;; e = width, d = height - ret z ; abort if malloc failed - ld (hl),de ; store width and height + call _indcallHL_ASM \.r ; hl = malloc(width * height + 2) + pop de ; de = width * height + 2 + add hl,de ; this should never carry + sbc hl,de ; check if malloc failed (hl == 0) + pop de ; e = width, d = height + ret z ; abort if malloc failed + ld (hl),de ; store width and height ret ;-------------------------------------------------------------------------------