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?
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
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
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) . .
12 or
7 + 4 = 11 .... 50% probability.
original
7 + 4 + 4
yes, it is way better, less readability but faster.
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.
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?
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.
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)
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.
