2019-10-31 16:29:05 +00:00
|
|
|
#if NULLCHAR_SAME
|
|
|
|
#error The module scrstring_fastpointers should not be included directly
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#pragma zilog_syntax
|
|
|
|
|
|
|
|
byte scrstrzlen(pointer str) {
|
|
|
|
pointer end
|
|
|
|
end = str
|
|
|
|
while end[0] != nullchar_scr {
|
|
|
|
end += 1
|
|
|
|
}
|
|
|
|
return lo(end - str)
|
|
|
|
}
|
|
|
|
|
|
|
|
sbyte scrstrzcmp(pointer str1, pointer str2) {
|
|
|
|
while true {
|
|
|
|
if str1[0] == nullchar_scr {
|
|
|
|
if str2[0] == nullchar_scr {
|
|
|
|
return 0
|
|
|
|
} else {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
} else if str1[0] != str2[0] {
|
|
|
|
if str1[0] < str2[0] { return -1 }
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
str1 += 1
|
|
|
|
str2 += 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if CPUFEATURE_Z80 || CPUFEATURE_8080
|
|
|
|
void scrstrzcopy(pointer dest, pointer src) {
|
|
|
|
asm {
|
|
|
|
? LD HL,(src)
|
|
|
|
? LD DE,(dest)
|
|
|
|
___scrstrzcopy_loop:
|
|
|
|
LD A,(HL)
|
|
|
|
LD (DE),A
|
|
|
|
? CP nullchar_scr
|
|
|
|
? JP NZ, ___scrstrzcopy_loop
|
|
|
|
}
|
|
|
|
}
|
2019-11-04 01:29:16 +00:00
|
|
|
void scrstrzpaste(pointer dest, pointer src) {
|
|
|
|
asm {
|
|
|
|
? LD HL,(src)
|
|
|
|
? LD DE,(dest)
|
|
|
|
___scrstrzpaste_loop:
|
|
|
|
LD A,(HL)
|
|
|
|
? CP nullchar_scr
|
|
|
|
? RET Z
|
|
|
|
LD (DE),A
|
|
|
|
? JP ___scrstrzpaste_loop
|
|
|
|
}
|
|
|
|
}
|
2019-10-31 16:29:05 +00:00
|
|
|
#else
|
|
|
|
void scrstrzcopy(pointer dest, pointer src) {
|
|
|
|
byte c
|
|
|
|
do {
|
|
|
|
c = src[0]
|
|
|
|
dest[0] = c
|
|
|
|
src += 1
|
|
|
|
dest += 1
|
|
|
|
} while c != nullchar_scr
|
|
|
|
}
|
2019-11-04 01:29:16 +00:00
|
|
|
void scrstrzpaste(pointer dest, pointer src) {
|
|
|
|
byte c
|
|
|
|
while true {
|
|
|
|
c = src[0]
|
|
|
|
if c == nullchar_scr { return }
|
|
|
|
dest[0] = c
|
|
|
|
src += 1
|
|
|
|
dest += 1
|
|
|
|
}
|
|
|
|
}
|
2019-10-31 16:29:05 +00:00
|
|
|
#endif
|