Developing my new game for the scene!

Página 28/75
21 | 22 | 23 | 24 | 25 | 26 | 27 | | 29 | 30 | 31 | 32 | 33

Por flyguille

Prophet (3031)

imagem de flyguille

18-03-2016, 00:06

MOA wrote:

Was looking at your assembly code, and have some minor (potential) peephole optimizations:

ld h, a					; +24 pixels.
bit 7, h
jr nz, .Escape				; Escape with ZF = 0 if map overflow.
; af discarded (not sure if ZF=0 is used by callee)

--> slightly faster (and 1 byte shorter) version
ld h, a
rla
jr c, .Escape

and:

ld a, c
add a, $80
ld c, a
ld a, b
adc a, 0
ld b, a
; hl not used

--> faster to do this?
ld hl,$80
add hl,bc
ld b,h
ld c,l

if I used 8bits op for 16bits number, I am sure HL is used (check in the next higher layer).

Can you repost the original context of those improvements? with your insertions as comments, to understand that improve?

Por kanima

Master (194)

imagem de kanima

18-03-2016, 00:02

MOA wrote:

Was looking at your assembly code, and have some minor (potential) peephole optimizations:

ld a, c
add a, $80
ld c, a
ld a, b
adc a, 0
ld b, a
; hl not used

--> faster to do this?
ld hl,$80
add hl,bc
ld b,h
ld c,l

I think the following is probably even faster?

ld a,c
add a,$80
ld c,a
jr nc, .done
inc b
.done

Por MOA

Champion (293)

imagem de MOA

18-03-2016, 00:07

flyguille wrote:

8bits op for 16bits number, I am sure HL is used (check in the next higher layer).

Ok, wasn't clear to me HL was used in higher layer (only BC is mentioned as return value)

			ld a, c
			add a, $80
			ld c, a
			ld a, b
			adc a, 0
			ld b, a

; HL not used, as far as I can see...

.CanFall:		xor a
			ret

Por MOA

Champion (293)

imagem de MOA

18-03-2016, 00:15

flyguille wrote:
MOA wrote:

Was looking at your assembly code, and have some minor (potential) peephole optimizations:

ld h, a					; +24 pixels.
bit 7, h
jr nz, .Escape				; Escape with ZF = 0 if map overflow.
; af discarded (not sure if ZF=0 is used by callee)

--> slightly faster (and 1 byte shorter) version
ld h, a
rla
jr c, .Escape

Can you repost the original context of those improvements? with your insertions as comments, to understand that improve?

Original context:

			ld h, a					; +24 pixels.
			bit 7, h ; --> use RLA?
			jr nz, .Escape				; Escape with ZF = 0 if map overflow.

			call .HorizontalCheck
			pop bc
			jr nz, .CanFall				; Even if here is floor, as before was tested some space for fall, it jumps with a "Can Fall".

			ld a, c
			add a, $80
			ld c, a
			ld a, b
			adc a, 0
			ld b, a

.CanFall:		xor a
			ret

.Escape:		pop bc
			ret

.
.
.HorizontalCheck:	ld a, (ix + Sprite.MapOx)
.
.

Por flyguille

Prophet (3031)

imagem de flyguille

18-03-2016, 00:18

12 or
7 + 4 = 11 .... 50% probability.

original
7 + 4 + 4

yes, it is way better, less readability but faster.

Por flyguille

Prophet (3031)

imagem de flyguille

18-03-2016, 00:16

MOA wrote:
flyguille wrote:
MOA wrote:

Was looking at your assembly code, and have some minor (potential) peephole optimizations:

ld h, a					; +24 pixels.
bit 7, h ; --> change to RLA
jr nz, .Escape				; Escape with ZF = 0 if map overflow.
; af discarded (not sure if ZF=0 is used by callee)

--> slightly faster (and 1 byte shorter) version
ld h, a
rla
jr c, .Escape

Can you repost the original context of those improvements? with your insertions as comments, to understand that improve?

Original context:

			ld h, a					; +24 pixels.
			bit 7, h
			jr nz, .Escape				; Escape with ZF = 0 if map overflow.

			call .HorizontalCheck
			pop bc
			jr nz, .CanFall				; Even if here is floor, as before was tested some space for fall, it jumps with a "Can Fall".

			ld a, c
			add a, $80
			ld c, a
			ld a, b
			adc a, 0
			ld b, a

.CanFall:		xor a
			ret

.Escape:		pop bc
			ret

.
.
.HorizontalCheck:	ld a, (ix + Sprite.MapOx)
.
.

the problem with that improve, is that the routine outputs a meaningfull Z or NZ , if I use the CF, is not guarantee it escapes with NZ.

Por MOA

Champion (293)

imagem de MOA

18-03-2016, 00:19

flyguille wrote:
MOA wrote:
flyguille wrote:
MOA wrote:

Was looking at your assembly code, and have some minor (potential) peephole optimizations:

ld h, a					; +24 pixels.
bit 7, h ; --> change to RLA
jr nz, .Escape				; Escape with ZF = 0 if map overflow.
; af discarded (not sure if ZF=0 is used by callee)

--> slightly faster (and 1 byte shorter) version
ld h, a
rla
jr c, .Escape

Can you repost the original context of those improvements? with your insertions as comments, to understand that improve?

Original context:

			ld h, a					; +24 pixels.
			bit 7, h
			jr nz, .Escape				; Escape with ZF = 0 if map overflow.

			call .HorizontalCheck
			pop bc
			jr nz, .CanFall				; Even if here is floor, as before was tested some space for fall, it jumps with a "Can Fall".

			ld a, c
			add a, $80
			ld c, a
			ld a, b
			adc a, 0
			ld b, a

.CanFall:		xor a
			ret

.Escape:		pop bc
			ret

.
.
.HorizontalCheck:	ld a, (ix + Sprite.MapOx)
.
.

the problem with that improve, is that the routine outputs a meaningfull Z or NZ , if I use the CF, is not guarantee it escapes with NZ.

Yeah, wasn't sure the ZF was part of the return value... maybe you can refactor to use the CF instead?

Por flyguille

Prophet (3031)

imagem de flyguille

18-03-2016, 03:20

MOA wrote:
flyguille wrote:
MOA wrote:
flyguille wrote:
MOA wrote:

Was looking at your assembly code, and have some minor (potential) peephole optimizations:

ld h, a					; +24 pixels.
bit 7, h ; --> change to RLA
jr nz, .Escape				; Escape with ZF = 0 if map overflow.
; af discarded (not sure if ZF=0 is used by callee)

--> slightly faster (and 1 byte shorter) version
ld h, a
rla
jr c, .Escape

Can you repost the original context of those improvements? with your insertions as comments, to understand that improve?

Original context:

			ld h, a					; +24 pixels.
			bit 7, h
			jr nz, .Escape				; Escape with ZF = 0 if map overflow.

			call .HorizontalCheck
			pop bc
			jr nz, .CanFall				; Even if here is floor, as before was tested some space for fall, it jumps with a "Can Fall".

			ld a, c
			add a, $80
			ld c, a
			ld a, b
			adc a, 0
			ld b, a

.CanFall:		xor a
			ret

.Escape:		pop bc
			ret

.
.
.HorizontalCheck:	ld a, (ix + Sprite.MapOx)
.
.

the problem with that improve, is that the routine outputs a meaningfull Z or NZ , if I use the CF, is not guarantee it escapes with NZ.

Yeah, wasn't sure the ZF was part of the return value... maybe you can refactor to use the CF instead?

Nah, don't worth the job.

Well, the idea of jr c, + inc r.... did 33 micro-improvements (scanned all the code) noticeable, nah..., but that worth the job.

I did others improvements sorting better the class code table. But, too, micro improvement, just saving 2 instruction here and there, nothing more.

So, it do as fast as z80 can do the pile of features that it has. Don't worth to remove any of the features.

Tomorrow or a bit later, I will release a little demo (as it is), to gather some feedback, and see if it is dificult for players or it feels well. And if gamers finds the path to the exit of the map portion done. Wink

Por Grauw

Ascended (10699)

imagem de Grauw

18-03-2016, 09:29

flyguille wrote:

12 or
7 + 4 = 11 .... 50% probability.
original
7 + 4 + 4

You should include the M1 cycle in your counts; 13 or 8 + 5 vs. 8 + 5 + 5. See Z80 / R800 instruction set on the MAP for an easy reference (Timing Z80+M1 column)

Por flyguille

Prophet (3031)

imagem de flyguille

18-03-2016, 15:51

one thing more that I want to fix...., and come a test release, and see who is the first that comment in the forum the hidden message.

Página 28/75
21 | 22 | 23 | 24 | 25 | 26 | 27 | | 29 | 30 | 31 | 32 | 33