1
0
mirror of https://github.com/KarolS/millfork.git synced 2024-09-27 12:57:41 +00:00

Add strzpaste and scrstrzpaste

This commit is contained in:
Karol Stasiak 2019-11-04 02:29:16 +01:00
parent 4abfab41df
commit 00841d685b
6 changed files with 76 additions and 1 deletions

View File

@ -20,7 +20,12 @@ If any of the strings is longer than 255 bytes, then the behaviour is undefined
#### `void strzcopy(pointer dest, pointer src)`
Copies the source null-terminated string into the destination buffer.
Copies the source null-terminated string into the destination buffer, including the string terminator.
If the source string is longer than 255 bytes, then the behaviour is undefined (might even crash).
#### `void strzpaste(pointer dest, pointer src)`
Copies the source null-terminated string into the destination buffer, excluding the string terminator.
If the source string is longer than 255 bytes, then the behaviour is undefined (might even crash).
#### `word strz2word(pointer str)`
@ -42,6 +47,7 @@ It contains functions for handling strings in the screen encoding with the same
#### `byte scrstrzlen(pointer str)`
#### `sbyte scrstrzcmp(pointer str1, pointer str2)`
#### `void scrstrzcopy(pointer dest, pointer src)`
#### `void scrstrzpaste(pointer dest, pointer src)`
#### `word scrstrz2word(pointer str)`
#### `void scrstrzappend(pointer buffer, pointer str)`
#### `void scrstrzappendchar(pointer buffer, byte char)`

View File

@ -4,6 +4,7 @@ import string
alias scrstrzlen = strzlen
alias scrstrzcmp = strzcmp
alias scrstrzcopy = strzcopy
alias scrstrzpaste = strzpaste
alias scrstrzappendchar = strzappendchar
alias scrstrz2word = strz2word
alias scrstrzappend = strzappend

View File

@ -39,3 +39,15 @@ void scrstrzcopy(pointer dest, pointer src) {
i += 1
} while c != nullchar_scr
}
void strzpaste(pointer dest, pointer src) {
byte i
byte c
i = 0
while true {
c = src[i]
if c == nullchar_scr { return }
dest[i] = c
i += 1
}
}

View File

@ -42,6 +42,18 @@ void scrstrzcopy(pointer dest, pointer src) {
? JP NZ, ___scrstrzcopy_loop
}
}
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
}
}
#else
void scrstrzcopy(pointer dest, pointer src) {
byte c
@ -52,4 +64,14 @@ void scrstrzcopy(pointer dest, pointer src) {
dest += 1
} while c != nullchar_scr
}
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
}
}
#endif

View File

@ -35,3 +35,15 @@ void strzcopy(pointer dest, pointer src) {
i += 1
} while c != nullchar
}
void strzpaste(pointer dest, pointer src) {
byte i
byte c
i = 0
while true {
c = src[i]
if c == nullchar { return }
dest[i] = c
i += 1
}
}

View File

@ -38,6 +38,18 @@ void strzcopy(pointer dest, pointer src) {
? JP NZ, ___strzcopy_loop
}
}
void strzpaste(pointer dest, pointer src) {
asm {
? LD HL,(src)
? LD DE,(dest)
___strzpaste_loop:
LD A,(HL)
? CP nullchar
? RET Z
LD (DE),A
? JP ___strzpaste_loop
}
}
#else
void strzcopy(pointer dest, pointer src) {
byte c
@ -48,4 +60,14 @@ void strzcopy(pointer dest, pointer src) {
dest += 1
} while c != nullchar
}
void strzpaste(pointer dest, pointer src) {
byte c
while true {
c = src[0]
if c == nullchar { return }
dest[0] = c
src += 1
dest += 1
}
}
#endif