 ; strlen() implementation that only looks at the first 256
 ; byte of the string. returns 255 if the length is >=255.
 ; saves a measly 4 bytes over the cc65 strlen().

 ; extern unsigned char strlen8(const char *str);

 .importzp ptr1
 .export _strlen8

_strlen8:
 sta ptr1
 stx ptr1+1
 ldy #0
@loop:
 lda (ptr1),y
 beq @done
 iny
 bne @loop
 dey ; return(255) if Y rolls over
@done:
 tya
 ldx #0 ; sadly necessary even though we return a char...
 rts

