Skip to content

Commit 86fb11a

Browse files
Gérald DeGR00TEruner112
authored andcommitted
_PixelPtr no more sub-routined (#123)
* _PixelPtr no more sub-routined As subroutine _PixelPtr & included _PixelPtrNoChecks were actually called only once, I suggest no more call for each. * Update graphx.asm * Optimize non-critical code for size
1 parent 7886247 commit 86fb11a

File tree

1 file changed

+14
-27
lines changed

1 file changed

+14
-27
lines changed

src/graphx/graphx.asm

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ gfx_GetPixel:
528528
inc hl
529529
inc hl ; hl = &y
530530
ld e,(hl) ; e = y
531+
_GetPixel:
531532
ld d,LcdWidth/2
532533
mlt de ; de = y * (lcdWidth / 2)
533534
ld hl,(CurrentBuffer) ; hl = buffer
@@ -560,8 +561,18 @@ gfx_SetPixel:
560561
add hl,de ; move to next argument
561562
ld e,(hl) ; e = y coordinate
562563
_SetPixel:
563-
call _PixelPtr
564-
ret c ; return if out of bounds
564+
ld hl,-LcdWidth
565+
add hl,bc
566+
ret c ; return if out of bounds
567+
ld hl,-LcdHeight
568+
add hl,de
569+
ret c ; return if out of bounds
570+
ld hl,(CurrentBuffer)
571+
add hl,bc
572+
ld d,LcdWidth/2
573+
mlt de
574+
add hl,de
575+
add hl,de
565576
ld (hl),0 ; get the actual pixel
566577
Color_1 = $-1
567578
ret
@@ -4796,8 +4807,7 @@ gfx_FloodFill:
47964807

47974808
ld e,(ix+9)
47984809
ld bc,(ix+6)
4799-
call _PixelPtrNoChecks ; ov = p(x, y);
4800-
ld a,(hl)
4810+
call _GetPixel ; ov = p(x, y);
48014811

48024812
ld (.oldcolor0),a
48034813
ld (.oldcolor1),a
@@ -5689,29 +5699,6 @@ _LZ_ReadVarSize:
56895699
pop ix
56905700
ret
56915701

5692-
;-------------------------------------------------------------------------------
5693-
_PixelPtr:
5694-
; Gets the address of a pixel
5695-
; Inputs:
5696-
; BC=X
5697-
; E=Y
5698-
; Outputs:
5699-
; HL->address of pixel
5700-
ld hl,-LcdWidth
5701-
add hl,bc
5702-
ret c
5703-
ld hl,-LcdHeight
5704-
add hl,de
5705-
ret c
5706-
_PixelPtrNoChecks:
5707-
ld hl,(CurrentBuffer)
5708-
add hl,bc
5709-
ld d,LcdWidth/2
5710-
mlt de
5711-
add hl,de
5712-
add hl,de
5713-
ret
5714-
57155702
;-------------------------------------------------------------------------------
57165703
_Maximum:
57175704
; Calculate the resut of a signed comparison

0 commit comments

Comments
 (0)