0 Members and 2 Guests are viewing this topic.

p_MulFullSigned: .db __MulFullSignedEnd-1-$ push hl call $3F00+sub_MulFull pop bc xor a bit 7,b jr z,$+4 sbc hl,de or d ret p sbc hl,bc ret__MulFullSignedEnd:

ld hl, 5push hlcall $9D9D

call $0005

p_NthStr: .db __NthStrEnd-$+1 pop bc pop de push bc ex de,hl__NthStrLoop: ld a,d or e ret z xor a ld b,h cpir dec de jr __NthStrLoop__NthStrEnd:

p_NthStr: .db __NthStrEnd-$+1 pop bc pop de push bc ex de,hl__NthStrLoop: ld a,d or e ret z xor a cpir dec de jr __NthStrLoop__NthStrEnd:

I am not sure if I had an outdated source (1.1.2) but I saw this code and a one -byte optimisation

I'm not so sure that would work, because there's a possible case where you could be running code from an app and finding the Nth string in a large appvar in RAM, for example (which could be more than 16KB in size).

You do have an outdated version of Axe, I already added that optimizaion in 1.2.0.

p_SDiv: .db __SDivEnd-1-$ ld a,h xor d push af xor d jp p,__SDivSkip1-p_SDiv-1 xor a sub l ld l,a sbc a,a sub h ld h,a__SDivSkip1: bit 7,d jr z,__SDivSkip2 xor a sub e ld e,a sbc a,a sub d ld d,a__SDivSkip2: call $3F00+sub_Divx_SDivEntry: pop af ret p xor a sub l ld l,a sbc a,a sub h ld h,a ret__SDivEnd:

p_SDiv: .db __SDivEnd-1-$ ld a,h xor d push af xor d jp p,__SDivSkip1-p_SDiv-1 xor a sub l ld l,a sbc a,a sub h ld h,a__SDivSkip1: xor d jp p,__SDivSkip2-p_SDiv-1 xor a sub e ld e,a sbc a,a sub d ld d,a__SDivSkip2: call $3F00+sub_Divx_SDivEntry: pop af ret p xor a sub l ld l,a sbc a,a sub h ld h,a ret__SDivEnd:

; Fill(ptr, amount, byte (not word)); hl = ptr, de = byte, bc = amount ld (hl),e dec bc ld a,c or b ret z ; or whatever to quit ld e,l ld d,h inc de ldir ret ; ↑

p_GetByte: .db __GetByteEnd-$-1 di ld bc,$0803 ;Bit counter in b, bit mask in c ld hl,-1 xor a out (0),a ;Make sure we are reset in a,(0) and c ;Check to see if sender is ready dec a ret nz ;If not, then go back inc a out (0),a ;Relay a confirmation ex (sp),hl ;Wait at until confirmation is read (59 T-states minimum) ex (sp),hl ld a,(de) ;Bit counter in b and bitmask in c xor a ;Store received byte in l ld hl,$AA out (0),a ;Reset the ports to receive data__GetByteLoop: in a,(0) xor l rra jr c,__GetByteLoop in a,(0) rra rra ;bits cycled in are masked with 0x55. Need to invert anyways, so mask at the end with 0xAA rr l djnz __GetByteLoop ret

p_SendByte: .db __SendByteEnd-$-1 di ld bc,$5503 ;Bit counter in b, bit mask in c ld a,%00000010 out (0),a ;Indicate we are ready to send__SendByteTimeout: dec hl ld a,h or l jr z,__SendByteDone in a,(0) ;Loop is 59 T-states maximum and c jr nz,__SendByteTimeout ;Keep looping till we get it out (0),a__SendLoop: rrc e ccf rla sla b ccf rla out (0),a ex (sp),hl ex (sp),hl nop jr nz,__SendLoop;need 37cc xor a ex (sp),hl ex (sp),hl__SendByteDone out (0),a ret__SendByteEnd:

p_LineShr: .db __LineShrEnd-$-1;; l=y2, ix=buff, (sp)=ret, (sp+2)=ret_2, (sp+4)=x2, (sp+6)=y1, (sp+8)=x1 ld a,l pop bc pop hl pop de ex (sp),hl ld d,l pop hl ex (sp),hl push bc;; a=y2, d=y1, e=x2, l=x1, (sp)=ret, (sp+2)=ret_2 cp 64 ret nc ld h,a ld a,d cp 64 ret nc ld a,l cp 96 ret nc ld a,e cp 96 ret nc sub l jr nc,__LineShrSkipRev ex de,hl neg;; a=dx, d=y1, e=x2, h=y2, l=x1__LineShrSkipRev: push af ; Saving DX (it will be popped into HL below) ld a,l ; IX+=L/8+D*12 (actually D*4+D*4+D*4) rra rra rra and %00011111 ld c,a ld b,0 add ix,bc ld a,d add a,a add a,a ld c,a add ix,bc add ix,bc add ix,bc ld a,l ; Calculating the starting pixel mask and %00000111 inc a ld b,a ld a,%00000001__LineShrMaskLoop: rrca djnz __LineShrMaskLoop ld c,a ld a,h ; Calculating delta Y and negating the Y increment if necessary sub d ; This is the last instruction for which we need the original data ld de,12 jr nc,__LineShrSkipNeg ld de,-12 neg__LineShrSkipNeg: pop hl ; Recalling DX ld l,a ; H=DX, L=DY cp h jr nc,__LineVert ; Line is rather vertical than horizontal ld a,h__LineVert: ld b,a ; Pixel counter inc b cp l scf ; Setting up gradient counter ccf rra scf ret ; c=1, z=vertical major__LineShrEnd:

p_LineShr: .db __LineShrEnd-$-1;; l=y2, ix=buff, (sp)=ret, (sp+2)=ret_2, (sp+4)=x2, (sp+6)=y1, (sp+8)=x1 ld a,l pop bc pop hl pop de ex (sp),hl ld d,l pop hl ex (sp),hl push bc;; a=y2, d=y1, e=x2, l=x1, (sp)=ret, (sp+2)=ret_2 ld h,a ld a,63 cp h ret c cp d ret c ld a,95 cp l ret c cp e ret c ld a,e sub l jr nc,__LineShrSkipRev ex de,hl neg;; a=dx, d=y1, e=x2, h=y2, l=x1__LineShrSkipRev: push af ; Saving DX (it will be popped into HL below) ld a,d add a,a add a,a ld c,a ld b,0 add ix,bc add ix,bc add ix,bc ld a,l and 7 ld e,a xor l rra rra rra ld c,a add ix,bc ld b,a inc b ld a,%00000001__LineShrMaskLoop: rrca djnz __LineShrMaskLoop ld c,a ld a,h ; Calculating delta Y and negating the Y increment if necessary sub d ; This is the last instruction for which we need the original data ld de,12 jr nc,__LineShrSkipNeg ld de,-12 neg__LineShrSkipNeg: pop hl ; Recalling DX ld l,a ; H=DX, L=DY cp h jr nc,__LineVert ; Line is rather vertical than horizontal ld a,h__LineVert: ld b,a ; Pixel counter inc b cp l res 0,a ; Setting up gradient counter rrca ret ; c=0, z=vertical major__LineShrEnd:

p_LineShr: .db __LineShrEnd-$-1;; l=y2, ix=buff, (sp)=ret, (sp+2)=ret_2, (sp+4)=x2, (sp+6)=y1, (sp+8)=x1 ld a,l pop bc pop hl pop de ex (sp),hl ld d,l pop hl ex (sp),hl push bc;; a=y2, d=y1, e=x2, l=x1, (sp)=ret, (sp+2)=ret_2 ld h,a ld a,63 cp h ret c cp d ret c ld a,95 cp l ret c cp e ret c ld a,e sub l jr nc,__LineShrSkipRev ex de,hl neg;; a=dx, d=y1, e=x2, h=y2, l=x1__LineShrSkipRev: ld e,a ; Saving DX ld a,l ; IX+=L/8+D*12 (actually D*4+D*4+D*4) rra rra rra and %00011111 ld c,a ld b,0 add ix,bc ld a,d add a,a add a,a ld c,a add ix,bc add ix,bc add ix,bc ld a,l ; Calculating the starting pixel mask and %00000111 inc a ld b,a ld a,%00000001__LineShrMaskLoop: rrca djnz __LineShrMaskLoop ld c,a ld a,h ; Calculating delta Y and negating the Y increment if necessary sub d ; This is the last instruction for which we need the original data ld h,e ; DX ld l,a ; DY ld de,12 jr nc,__LineShrSkipNeg ld de,-12 neg__LineShrSkipNeg: cp h jr nc,__LineVert ; Line is rather vertical than horizontal ld a,h__LineVert: ld b,a ; Pixel counter inc b cp l res 0,a ; Setting up gradient counter rrca ret ; c=0, z=vertical major__LineShrEnd:

;7 bytes, 36cc ld a,l or h add a,255 sbc hl,hl inc hl

;7 bytes, 28cc xor a cp h ld h,a sbc a,l sbc a,a ld l,a inc l