mirror of
https://github.com/irmen/prog8.git
synced 2025-05-12 19:47:48 +00:00
renamed 'string' module to 'strings' for consistency
This commit is contained in:
parent
42e2c5f605
commit
906b137a7c
@ -252,7 +252,7 @@ class ConstExprEvaluator {
|
|||||||
return when(call.target.nameInSource[0]) {
|
return when(call.target.nameInSource[0]) {
|
||||||
"math" -> evalMath(call, constArgs)
|
"math" -> evalMath(call, constArgs)
|
||||||
"floats" -> evalFloats(call, constArgs)
|
"floats" -> evalFloats(call, constArgs)
|
||||||
"string" -> evalString(call, constArgs)
|
"strings" -> evalString(call, constArgs)
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -546,7 +546,7 @@ class ExpressionSimplifier(private val program: Program, private val errors: IEr
|
|||||||
return listOf(IAstModification.ReplaceNode(functionCallExpr, cast, parent))
|
return listOf(IAstModification.ReplaceNode(functionCallExpr, cast, parent))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(functionCallExpr.target.nameInSource == listOf("string", "contains")) {
|
else if(functionCallExpr.target.nameInSource == listOf("strings", "contains")) {
|
||||||
val target = (functionCallExpr.args[0] as? IdentifierReference)?.targetVarDecl(program)
|
val target = (functionCallExpr.args[0] as? IdentifierReference)?.targetVarDecl(program)
|
||||||
if(target?.value is StringLiteral) {
|
if(target?.value is StringLiteral) {
|
||||||
errors.info("for actual strings, use a regular containment check instead: 'char in string'", functionCallExpr.position)
|
errors.info("for actual strings, use a regular containment check instead: 'char in string'", functionCallExpr.position)
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
%import textio
|
%import textio
|
||||||
%import conv
|
%import conv
|
||||||
%import string
|
%import strings
|
||||||
%import syslib
|
%import syslib
|
||||||
|
|
||||||
diskio {
|
diskio {
|
||||||
@ -163,7 +163,7 @@ io_error:
|
|||||||
if lf_start_list(pattern_ptr) {
|
if lf_start_list(pattern_ptr) {
|
||||||
while lf_next_entry() {
|
while lf_next_entry() {
|
||||||
if list_filetype!="dir" {
|
if list_filetype!="dir" {
|
||||||
filenames_buffer += string.copy(list_filename, filenames_buffer) + 1
|
filenames_buffer += strings.copy(list_filename, filenames_buffer) + 1
|
||||||
files_found++
|
files_found++
|
||||||
if filenames_buffer - buffer_start > filenames_buf_size-20 {
|
if filenames_buffer - buffer_start > filenames_buf_size-20 {
|
||||||
@(filenames_buffer)=0
|
@(filenames_buffer)=0
|
||||||
@ -265,7 +265,7 @@ io_error:
|
|||||||
if not list_skip_disk_name {
|
if not list_skip_disk_name {
|
||||||
if list_pattern==0
|
if list_pattern==0
|
||||||
return true
|
return true
|
||||||
if string.pattern_match(list_filename, list_pattern)
|
if strings.pattern_match(list_filename, list_pattern)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
list_skip_disk_name = false
|
list_skip_disk_name = false
|
||||||
@ -297,7 +297,7 @@ close_end:
|
|||||||
; if you're going to read from it yourself instead of using f_read()!
|
; if you're going to read from it yourself instead of using f_read()!
|
||||||
f_close()
|
f_close()
|
||||||
|
|
||||||
cbm.SETNAM(string.length(filenameptr), filenameptr)
|
cbm.SETNAM(strings.length(filenameptr), filenameptr)
|
||||||
cbm.SETLFS(READ_IO_CHANNEL, drivenumber, READ_IO_CHANNEL) ; note: has to be Channel,x,Channel because otherwise f_seek doesn't work
|
cbm.SETLFS(READ_IO_CHANNEL, drivenumber, READ_IO_CHANNEL) ; note: has to be Channel,x,Channel because otherwise f_seek doesn't work
|
||||||
void cbm.OPEN() ; open 12,8,12,"filename"
|
void cbm.OPEN() ; open 12,8,12,"filename"
|
||||||
if_cc {
|
if_cc {
|
||||||
@ -457,7 +457,7 @@ _end jsr cbm.READST
|
|||||||
modifier[3] = 'w'
|
modifier[3] = 'w'
|
||||||
if open_for_seeks
|
if open_for_seeks
|
||||||
modifier[3] = 'm'
|
modifier[3] = 'm'
|
||||||
cx16.r0L = string.append(list_filename, modifier) ; secondary 13 requires a mode suffix to signal we're writing/modifying
|
cx16.r0L = strings.append(list_filename, modifier) ; secondary 13 requires a mode suffix to signal we're writing/modifying
|
||||||
cbm.SETNAM(cx16.r0L, list_filename)
|
cbm.SETNAM(cx16.r0L, list_filename)
|
||||||
cbm.SETLFS(WRITE_IO_CHANNEL, drivenumber, WRITE_IO_CHANNEL)
|
cbm.SETLFS(WRITE_IO_CHANNEL, drivenumber, WRITE_IO_CHANNEL)
|
||||||
void cbm.OPEN() ; open 13,8,13,"filename"
|
void cbm.OPEN() ; open 13,8,13,"filename"
|
||||||
@ -519,7 +519,7 @@ no_mciout:
|
|||||||
str device_not_present_error = "device not present #xx"
|
str device_not_present_error = "device not present #xx"
|
||||||
if cbm.READST()==128 {
|
if cbm.READST()==128 {
|
||||||
device_not_present_error[len(device_not_present_error)-2] = 0
|
device_not_present_error[len(device_not_present_error)-2] = 0
|
||||||
void string.copy(conv.str_ub(drivenumber), &device_not_present_error+len(device_not_present_error)-2)
|
void strings.copy(conv.str_ub(drivenumber), &device_not_present_error+len(device_not_present_error)-2)
|
||||||
return device_not_present_error
|
return device_not_present_error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,7 +596,7 @@ io_error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub internal_save_routine(uword filenameptr, uword startaddress, uword savesize, bool headerless) -> bool {
|
sub internal_save_routine(uword filenameptr, uword startaddress, uword savesize, bool headerless) -> bool {
|
||||||
cbm.SETNAM(string.length(filenameptr), filenameptr)
|
cbm.SETNAM(strings.length(filenameptr), filenameptr)
|
||||||
cbm.SETLFS(1, drivenumber, 0)
|
cbm.SETLFS(1, drivenumber, 0)
|
||||||
uword @shared end_address = startaddress + savesize
|
uword @shared end_address = startaddress + savesize
|
||||||
cx16.r0L = 0
|
cx16.r0L = 0
|
||||||
@ -651,7 +651,7 @@ io_error:
|
|||||||
|
|
||||||
|
|
||||||
sub internal_load_routine(uword filenameptr, uword address_override, bool headerless) -> uword {
|
sub internal_load_routine(uword filenameptr, uword address_override, bool headerless) -> uword {
|
||||||
cbm.SETNAM(string.length(filenameptr), filenameptr)
|
cbm.SETNAM(strings.length(filenameptr), filenameptr)
|
||||||
ubyte secondary = 1
|
ubyte secondary = 1
|
||||||
cx16.r1 = 0
|
cx16.r1 = 0
|
||||||
if address_override!=0
|
if address_override!=0
|
||||||
@ -677,7 +677,7 @@ io_error:
|
|||||||
; -- delete a file on the drive
|
; -- delete a file on the drive
|
||||||
list_filename[0] = 's'
|
list_filename[0] = 's'
|
||||||
list_filename[1] = ':'
|
list_filename[1] = ':'
|
||||||
ubyte flen = string.copy(filenameptr, &list_filename+2)
|
ubyte flen = strings.copy(filenameptr, &list_filename+2)
|
||||||
cbm.SETNAM(flen+2, list_filename)
|
cbm.SETNAM(flen+2, list_filename)
|
||||||
cbm.SETLFS(1, drivenumber, 15)
|
cbm.SETLFS(1, drivenumber, 15)
|
||||||
void cbm.OPEN()
|
void cbm.OPEN()
|
||||||
@ -689,9 +689,9 @@ io_error:
|
|||||||
; -- rename a file on the drive
|
; -- rename a file on the drive
|
||||||
list_filename[0] = 'r'
|
list_filename[0] = 'r'
|
||||||
list_filename[1] = ':'
|
list_filename[1] = ':'
|
||||||
ubyte flen_new = string.copy(newfileptr, &list_filename+2)
|
ubyte flen_new = strings.copy(newfileptr, &list_filename+2)
|
||||||
list_filename[flen_new+2] = '='
|
list_filename[flen_new+2] = '='
|
||||||
ubyte flen_old = string.copy(oldfileptr, &list_filename+3+flen_new)
|
ubyte flen_old = strings.copy(oldfileptr, &list_filename+3+flen_new)
|
||||||
cbm.SETNAM(3+flen_new+flen_old, list_filename)
|
cbm.SETNAM(3+flen_new+flen_old, list_filename)
|
||||||
cbm.SETLFS(1, drivenumber, 15)
|
cbm.SETLFS(1, drivenumber, 15)
|
||||||
void cbm.OPEN()
|
void cbm.OPEN()
|
||||||
@ -701,7 +701,7 @@ io_error:
|
|||||||
|
|
||||||
sub send_command(uword commandptr) {
|
sub send_command(uword commandptr) {
|
||||||
; -- send a dos command to the drive (don't read any response)
|
; -- send a dos command to the drive (don't read any response)
|
||||||
cbm.SETNAM(string.length(commandptr), commandptr)
|
cbm.SETNAM(strings.length(commandptr), commandptr)
|
||||||
cbm.SETLFS(15, drivenumber, 15)
|
cbm.SETLFS(15, drivenumber, 15)
|
||||||
void cbm.OPEN()
|
void cbm.OPEN()
|
||||||
cbm.CLRCHN()
|
cbm.CLRCHN()
|
||||||
@ -776,7 +776,7 @@ internal_vload:
|
|||||||
list_filename[0] = 'c'
|
list_filename[0] = 'c'
|
||||||
list_filename[1] = 'd'
|
list_filename[1] = 'd'
|
||||||
list_filename[2] = ':'
|
list_filename[2] = ':'
|
||||||
void string.copy(path, &list_filename+3)
|
void strings.copy(path, &list_filename+3)
|
||||||
send_command(list_filename)
|
send_command(list_filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -785,19 +785,19 @@ internal_vload:
|
|||||||
list_filename[0] = 'm'
|
list_filename[0] = 'm'
|
||||||
list_filename[1] = 'd'
|
list_filename[1] = 'd'
|
||||||
list_filename[2] = ':'
|
list_filename[2] = ':'
|
||||||
void string.copy(name, &list_filename+3)
|
void strings.copy(name, &list_filename+3)
|
||||||
send_command(list_filename)
|
send_command(list_filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
sub rmdir(str name) {
|
sub rmdir(str name) {
|
||||||
; -- remove a subdirectory.
|
; -- remove a subdirectory.
|
||||||
void string.find(name, '*')
|
void strings.find(name, '*')
|
||||||
if_cs
|
if_cs
|
||||||
return ; refuse to act on a wildcard *
|
return ; refuse to act on a wildcard *
|
||||||
list_filename[0] = 'r'
|
list_filename[0] = 'r'
|
||||||
list_filename[1] = 'd'
|
list_filename[1] = 'd'
|
||||||
list_filename[2] = ':'
|
list_filename[2] = ':'
|
||||||
void string.copy(name, &list_filename+3)
|
void strings.copy(name, &list_filename+3)
|
||||||
send_command(list_filename)
|
send_command(list_filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -860,7 +860,7 @@ io_error:
|
|||||||
sub prepend(str dir) {
|
sub prepend(str dir) {
|
||||||
if dir[0]=='/' and dir[1]==0
|
if dir[0]=='/' and dir[1]==0
|
||||||
return
|
return
|
||||||
cx16.r9L = string.length(dir)
|
cx16.r9L = strings.length(dir)
|
||||||
cx16.r12 -= cx16.r9L
|
cx16.r12 -= cx16.r9L
|
||||||
sys.memcopy(dir, cx16.r12, cx16.r9L)
|
sys.memcopy(dir, cx16.r12, cx16.r9L)
|
||||||
cx16.r12--
|
cx16.r12--
|
||||||
@ -874,7 +874,7 @@ io_error:
|
|||||||
list_filename[1] = '-'
|
list_filename[1] = '-'
|
||||||
list_filename[2] = 'h'
|
list_filename[2] = 'h'
|
||||||
list_filename[3] = ':'
|
list_filename[3] = ':'
|
||||||
void string.copy(name, &list_filename+4)
|
void strings.copy(name, &list_filename+4)
|
||||||
send_command(list_filename)
|
send_command(list_filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
%import textio
|
%import textio
|
||||||
%import conv
|
%import conv
|
||||||
%import string
|
%import strings
|
||||||
%import syslib
|
%import syslib
|
||||||
|
|
||||||
diskio {
|
diskio {
|
||||||
@ -141,7 +141,7 @@ io_error:
|
|||||||
if lf_start_list(pattern_ptr) {
|
if lf_start_list(pattern_ptr) {
|
||||||
while lf_next_entry() {
|
while lf_next_entry() {
|
||||||
if list_filetype!="dir" {
|
if list_filetype!="dir" {
|
||||||
filenames_buffer += string.copy(list_filename, filenames_buffer) + 1
|
filenames_buffer += strings.copy(list_filename, filenames_buffer) + 1
|
||||||
files_found++
|
files_found++
|
||||||
if filenames_buffer - buffer_start > filenames_buf_size-20 {
|
if filenames_buffer - buffer_start > filenames_buf_size-20 {
|
||||||
@(filenames_buffer)=0
|
@(filenames_buffer)=0
|
||||||
@ -243,7 +243,7 @@ io_error:
|
|||||||
if not list_skip_disk_name {
|
if not list_skip_disk_name {
|
||||||
if list_pattern==0
|
if list_pattern==0
|
||||||
return true
|
return true
|
||||||
if string.pattern_match(list_filename, list_pattern)
|
if strings.pattern_match(list_filename, list_pattern)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
list_skip_disk_name = false
|
list_skip_disk_name = false
|
||||||
@ -275,7 +275,7 @@ close_end:
|
|||||||
; if you're going to read from it yourself instead of using f_read()!
|
; if you're going to read from it yourself instead of using f_read()!
|
||||||
f_close()
|
f_close()
|
||||||
|
|
||||||
cbm.SETNAM(string.length(filenameptr), filenameptr)
|
cbm.SETNAM(strings.length(filenameptr), filenameptr)
|
||||||
cbm.SETLFS(READ_IO_CHANNEL, drivenumber, READ_IO_CHANNEL) ; note: has to be Channel,x,Channel because otherwise f_seek doesn't work
|
cbm.SETLFS(READ_IO_CHANNEL, drivenumber, READ_IO_CHANNEL) ; note: has to be Channel,x,Channel because otherwise f_seek doesn't work
|
||||||
void cbm.OPEN() ; open 12,8,12,"filename"
|
void cbm.OPEN() ; open 12,8,12,"filename"
|
||||||
if_cc {
|
if_cc {
|
||||||
@ -398,7 +398,7 @@ _end jsr cbm.READST
|
|||||||
; and check the drive's status message!
|
; and check the drive's status message!
|
||||||
f_close_w()
|
f_close_w()
|
||||||
|
|
||||||
cbm.SETNAM(string.length(filenameptr), filenameptr)
|
cbm.SETNAM(strings.length(filenameptr), filenameptr)
|
||||||
cbm.SETLFS(WRITE_IO_CHANNEL, drivenumber, 1)
|
cbm.SETLFS(WRITE_IO_CHANNEL, drivenumber, 1)
|
||||||
void cbm.OPEN() ; open 13,8,1,"filename"
|
void cbm.OPEN() ; open 13,8,1,"filename"
|
||||||
if_cc {
|
if_cc {
|
||||||
@ -444,7 +444,7 @@ _end jsr cbm.READST
|
|||||||
str device_not_present_error = "device not present #xx"
|
str device_not_present_error = "device not present #xx"
|
||||||
if cbm.READST()==128 {
|
if cbm.READST()==128 {
|
||||||
device_not_present_error[len(device_not_present_error)-2] = 0
|
device_not_present_error[len(device_not_present_error)-2] = 0
|
||||||
void string.copy(conv.str_ub(drivenumber), &device_not_present_error+len(device_not_present_error)-2)
|
void strings.copy(conv.str_ub(drivenumber), &device_not_present_error+len(device_not_present_error)-2)
|
||||||
return device_not_present_error
|
return device_not_present_error
|
||||||
}
|
}
|
||||||
uword messageptr = &list_filename
|
uword messageptr = &list_filename
|
||||||
@ -508,7 +508,7 @@ io_error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub save(uword filenameptr, uword start_address, uword savesize) -> bool {
|
sub save(uword filenameptr, uword start_address, uword savesize) -> bool {
|
||||||
cbm.SETNAM(string.length(filenameptr), filenameptr)
|
cbm.SETNAM(strings.length(filenameptr), filenameptr)
|
||||||
cbm.SETLFS(1, drivenumber, 0)
|
cbm.SETLFS(1, drivenumber, 0)
|
||||||
uword @shared end_address = start_address + savesize
|
uword @shared end_address = start_address + savesize
|
||||||
cx16.r0L = 0
|
cx16.r0L = 0
|
||||||
@ -539,7 +539,7 @@ io_error:
|
|||||||
; and the rest is loaded at the given location in memory.
|
; and the rest is loaded at the given location in memory.
|
||||||
; Returns the end load address+1 if successful or 0 if a load error occurred.
|
; Returns the end load address+1 if successful or 0 if a load error occurred.
|
||||||
sub load(uword filenameptr, uword address_override) -> uword {
|
sub load(uword filenameptr, uword address_override) -> uword {
|
||||||
cbm.SETNAM(string.length(filenameptr), filenameptr)
|
cbm.SETNAM(strings.length(filenameptr), filenameptr)
|
||||||
ubyte secondary = 1
|
ubyte secondary = 1
|
||||||
cx16.r1 = 0
|
cx16.r1 = 0
|
||||||
if address_override!=0
|
if address_override!=0
|
||||||
@ -578,7 +578,7 @@ io_error:
|
|||||||
; -- delete a file on the drive
|
; -- delete a file on the drive
|
||||||
list_filename[0] = 's'
|
list_filename[0] = 's'
|
||||||
list_filename[1] = ':'
|
list_filename[1] = ':'
|
||||||
ubyte flen = string.copy(filenameptr, &list_filename+2)
|
ubyte flen = strings.copy(filenameptr, &list_filename+2)
|
||||||
cbm.SETNAM(flen+2, list_filename)
|
cbm.SETNAM(flen+2, list_filename)
|
||||||
cbm.SETLFS(1, drivenumber, 15)
|
cbm.SETLFS(1, drivenumber, 15)
|
||||||
void cbm.OPEN()
|
void cbm.OPEN()
|
||||||
@ -590,9 +590,9 @@ io_error:
|
|||||||
; -- rename a file on the drive
|
; -- rename a file on the drive
|
||||||
list_filename[0] = 'r'
|
list_filename[0] = 'r'
|
||||||
list_filename[1] = ':'
|
list_filename[1] = ':'
|
||||||
ubyte flen_new = string.copy(newfileptr, &list_filename+2)
|
ubyte flen_new = strings.copy(newfileptr, &list_filename+2)
|
||||||
list_filename[flen_new+2] = '='
|
list_filename[flen_new+2] = '='
|
||||||
ubyte flen_old = string.copy(oldfileptr, &list_filename+3+flen_new)
|
ubyte flen_old = strings.copy(oldfileptr, &list_filename+3+flen_new)
|
||||||
cbm.SETNAM(3+flen_new+flen_old, list_filename)
|
cbm.SETNAM(3+flen_new+flen_old, list_filename)
|
||||||
cbm.SETLFS(1, drivenumber, 15)
|
cbm.SETLFS(1, drivenumber, 15)
|
||||||
void cbm.OPEN()
|
void cbm.OPEN()
|
||||||
@ -611,7 +611,7 @@ io_error:
|
|||||||
|
|
||||||
sub send_command(uword commandptr) {
|
sub send_command(uword commandptr) {
|
||||||
; -- send a dos command to the drive
|
; -- send a dos command to the drive
|
||||||
cbm.SETNAM(string.length(commandptr), commandptr)
|
cbm.SETNAM(strings.length(commandptr), commandptr)
|
||||||
cbm.SETLFS(15, drivenumber, 15)
|
cbm.SETLFS(15, drivenumber, 15)
|
||||||
void cbm.OPEN()
|
void cbm.OPEN()
|
||||||
cbm.CLRCHN()
|
cbm.CLRCHN()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
string {
|
strings {
|
||||||
; the string functions shared across compiler targets
|
; the string functions shared across compiler targets
|
||||||
%option merge, no_symbol_prefixing, ignore_unused
|
%option merge, no_symbol_prefixing, ignore_unused
|
||||||
|
|
||||||
@ -12,11 +12,11 @@ string {
|
|||||||
; -- gets rid of whitespace and other non-visible characters at the end of the string
|
; -- gets rid of whitespace and other non-visible characters at the end of the string
|
||||||
if s[0]==0
|
if s[0]==0
|
||||||
return
|
return
|
||||||
cx16.r0L = string.length(s)
|
cx16.r0L = length(s)
|
||||||
do {
|
do {
|
||||||
cx16.r0L--
|
cx16.r0L--
|
||||||
cx16.r1L = s[cx16.r0L]
|
cx16.r1L = s[cx16.r0L]
|
||||||
} until cx16.r0L==0 or string.isprint(cx16.r1L) and not string.isspace(cx16.r1L)
|
} until cx16.r0L==0 or isprint(cx16.r1L) and not isspace(cx16.r1L)
|
||||||
s[cx16.r0L+1] = 0
|
s[cx16.r0L+1] = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ string {
|
|||||||
; -- gets rid of whitespace and other non-visible characters at the start of the string (destructive)
|
; -- gets rid of whitespace and other non-visible characters at the start of the string (destructive)
|
||||||
cx16.r0 = lstripped(s)
|
cx16.r0 = lstripped(s)
|
||||||
if cx16.r0 != s
|
if cx16.r0 != s
|
||||||
void string.copy(cx16.r0, s)
|
void copy(cx16.r0, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
sub lstripped(str s) -> str {
|
sub lstripped(str s) -> str {
|
||||||
@ -35,7 +35,7 @@ string {
|
|||||||
do {
|
do {
|
||||||
cx16.r0L++
|
cx16.r0L++
|
||||||
cx16.r1L = s[cx16.r0L]
|
cx16.r1L = s[cx16.r0L]
|
||||||
} until cx16.r1L==0 or string.isprint(cx16.r1L) and not string.isspace(cx16.r1L)
|
} until cx16.r1L==0 or isprint(cx16.r1L) and not isspace(cx16.r1L)
|
||||||
return s+cx16.r0L
|
return s+cx16.r0L
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,11 +49,11 @@ string {
|
|||||||
; -- gets rid of whitespace characters at the end of the string
|
; -- gets rid of whitespace characters at the end of the string
|
||||||
if s[0]==0
|
if s[0]==0
|
||||||
return
|
return
|
||||||
cx16.r0L = string.length(s)
|
cx16.r0L = length(s)
|
||||||
do {
|
do {
|
||||||
cx16.r0L--
|
cx16.r0L--
|
||||||
cx16.r1L = s[cx16.r0L]
|
cx16.r1L = s[cx16.r0L]
|
||||||
} until cx16.r0L==0 or not string.isspace(cx16.r1L)
|
} until cx16.r0L==0 or not isspace(cx16.r1L)
|
||||||
s[cx16.r0L+1] = 0
|
s[cx16.r0L+1] = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ string {
|
|||||||
; -- gets rid of whitespace characters at the start of the string (destructive)
|
; -- gets rid of whitespace characters at the start of the string (destructive)
|
||||||
cx16.r0 = ltrimmed(s)
|
cx16.r0 = ltrimmed(s)
|
||||||
if cx16.r0 != s
|
if cx16.r0 != s
|
||||||
void string.copy(cx16.r0, s)
|
void copy(cx16.r0, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
sub ltrimmed(str s) -> str {
|
sub ltrimmed(str s) -> str {
|
||||||
@ -72,41 +72,41 @@ string {
|
|||||||
do {
|
do {
|
||||||
cx16.r0L++
|
cx16.r0L++
|
||||||
cx16.r1L = s[cx16.r0L]
|
cx16.r1L = s[cx16.r0L]
|
||||||
} until not string.isspace(cx16.r1L)
|
} until not isspace(cx16.r1L)
|
||||||
return s+cx16.r0L
|
return s+cx16.r0L
|
||||||
}
|
}
|
||||||
|
|
||||||
sub startswith(str st, str prefix) -> bool {
|
sub startswith(str st, str prefix) -> bool {
|
||||||
ubyte prefix_len = string.length(prefix)
|
ubyte prefix_len = length(prefix)
|
||||||
ubyte str_len = string.length(st)
|
ubyte str_len = length(st)
|
||||||
if prefix_len > str_len
|
if prefix_len > str_len
|
||||||
return false
|
return false
|
||||||
cx16.r9L = st[prefix_len]
|
cx16.r9L = st[prefix_len]
|
||||||
st[prefix_len] = 0
|
st[prefix_len] = 0
|
||||||
cx16.r9H = string.compare(st, prefix) as ubyte
|
cx16.r9H = compare(st, prefix) as ubyte
|
||||||
st[prefix_len] = cx16.r9L
|
st[prefix_len] = cx16.r9L
|
||||||
return cx16.r9H==0
|
return cx16.r9H==0
|
||||||
}
|
}
|
||||||
|
|
||||||
sub endswith(str st, str suffix) -> bool {
|
sub endswith(str st, str suffix) -> bool {
|
||||||
ubyte suffix_len = string.length(suffix)
|
ubyte suffix_len = length(suffix)
|
||||||
ubyte str_len = string.length(st)
|
ubyte str_len = length(st)
|
||||||
if suffix_len > str_len
|
if suffix_len > str_len
|
||||||
return false
|
return false
|
||||||
return string.compare(st + str_len - suffix_len, suffix) == 0
|
return compare(st + str_len - suffix_len, suffix) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
sub findstr(str haystack, str needle) -> ubyte {
|
sub findstr(str haystack, str needle) -> ubyte {
|
||||||
; searches for needle in haystack.
|
; searches for needle in haystack.
|
||||||
; returns index in haystack where it first occurs, and Carry set,
|
; returns index in haystack where it first occurs, and Carry set,
|
||||||
; or if needle doesn't occur in haystack it returns Carry clear and 255 (an invalid index.)
|
; or if needle doesn't occur in haystack it returns Carry clear and 255 (an invalid index.)
|
||||||
cx16.r2L = string.length(haystack)
|
cx16.r2L = length(haystack)
|
||||||
cx16.r3L = string.length(needle)
|
cx16.r3L = length(needle)
|
||||||
if cx16.r3L <= cx16.r2L {
|
if cx16.r3L <= cx16.r2L {
|
||||||
cx16.r2L = cx16.r2L-cx16.r3L+1
|
cx16.r2L = cx16.r2L-cx16.r3L+1
|
||||||
cx16.r3 = haystack
|
cx16.r3 = haystack
|
||||||
repeat cx16.r2L {
|
repeat cx16.r2L {
|
||||||
if string.startswith(cx16.r3, needle) {
|
if startswith(cx16.r3, needle) {
|
||||||
sys.set_carry()
|
sys.set_carry()
|
||||||
return cx16.r3-haystack as ubyte
|
return cx16.r3-haystack as ubyte
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
%import shared_string_functions
|
%import shared_string_functions
|
||||||
|
|
||||||
string {
|
strings {
|
||||||
%option no_symbol_prefixing, ignore_unused
|
%option no_symbol_prefixing, ignore_unused
|
||||||
|
|
||||||
asmsub length(uword string @AY) clobbers(A) -> ubyte @Y {
|
asmsub length(uword string @AY) clobbers(A) -> ubyte @Y {
|
||||||
@ -60,7 +60,7 @@ _loop dey
|
|||||||
stx P8ZP_SCRATCH_B1
|
stx P8ZP_SCRATCH_B1
|
||||||
sta cx16.r0
|
sta cx16.r0
|
||||||
sty cx16.r0+1
|
sty cx16.r0+1
|
||||||
jsr string.length
|
jsr length
|
||||||
tya
|
tya
|
||||||
sec
|
sec
|
||||||
sbc P8ZP_SCRATCH_B1
|
sbc P8ZP_SCRATCH_B1
|
||||||
@ -158,7 +158,7 @@ _found tya
|
|||||||
stx P8ZP_SCRATCH_B1
|
stx P8ZP_SCRATCH_B1
|
||||||
sta _str
|
sta _str
|
||||||
sty _str+1
|
sty _str+1
|
||||||
jsr string.length
|
jsr length
|
||||||
dey
|
dey
|
||||||
lda _str
|
lda _str
|
||||||
sta P8ZP_SCRATCH_W1
|
sta P8ZP_SCRATCH_W1
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
%import shared_string_functions
|
%import shared_string_functions
|
||||||
|
|
||||||
string {
|
strings {
|
||||||
%option ignore_unused
|
%option ignore_unused
|
||||||
|
|
||||||
sub length(str st) -> ubyte {
|
sub length(str st) -> ubyte {
|
||||||
@ -73,7 +73,7 @@ string {
|
|||||||
; returns Carry set if found + index in A, or Carry clear if not found (and A will be 255, an invalid index).
|
; returns Carry set if found + index in A, or Carry clear if not found (and A will be 255, an invalid index).
|
||||||
; NOTE: because this isn't an asmsub, there's only a SINGLE return value here. On the c64/cx16 targets etc there are 2 return values.
|
; NOTE: because this isn't an asmsub, there's only a SINGLE return value here. On the c64/cx16 targets etc there are 2 return values.
|
||||||
ubyte ix
|
ubyte ix
|
||||||
for ix in string.length(stringptr)-1 downto 0 {
|
for ix in length(stringptr)-1 downto 0 {
|
||||||
if stringptr[ix]==character {
|
if stringptr[ix]==character {
|
||||||
sys.set_carry()
|
sys.set_carry()
|
||||||
return ix
|
return ix
|
||||||
@ -96,8 +96,8 @@ string {
|
|||||||
; Often you don’t have to call this explicitly and can just write string1 = string2
|
; Often you don’t have to call this explicitly and can just write string1 = string2
|
||||||
; but this function is useful if you’re dealing with addresses for instance.
|
; but this function is useful if you’re dealing with addresses for instance.
|
||||||
%ir {{
|
%ir {{
|
||||||
loadm.w r65534,string.copy.source
|
loadm.w r65534,strings.copy.source
|
||||||
loadm.w r65535,string.copy.target
|
loadm.w r65535,strings.copy.target
|
||||||
syscall 39 (r65534.w, r65535.w): r0.b
|
syscall 39 (r65534.w, r65535.w): r0.b
|
||||||
returnr.b r0
|
returnr.b r0
|
||||||
}}
|
}}
|
||||||
@ -116,8 +116,8 @@ string {
|
|||||||
; Note that you can also directly compare strings and string values with eachother using
|
; Note that you can also directly compare strings and string values with eachother using
|
||||||
; comparison operators ==, < etcetera (this will use strcmp automatically).
|
; comparison operators ==, < etcetera (this will use strcmp automatically).
|
||||||
%ir {{
|
%ir {{
|
||||||
loadm.w r65534,string.compare.st1
|
loadm.w r65534,strings.compare.st1
|
||||||
loadm.w r65535,string.compare.st2
|
loadm.w r65535,strings.compare.st2
|
||||||
syscall 16 (r65534.w, r65535.w) : r0.b
|
syscall 16 (r65534.w, r65535.w) : r0.b
|
||||||
returnr.b r0
|
returnr.b r0
|
||||||
}}
|
}}
|
@ -109,7 +109,7 @@ private fun builtinSizeof(args: List<Expression>, position: Position, program: P
|
|||||||
val elementDt = ArrayToElementTypes.getValue(dt.getOr(DataType.UNDEFINED))
|
val elementDt = ArrayToElementTypes.getValue(dt.getOr(DataType.UNDEFINED))
|
||||||
NumericLiteral.optimalInteger(program.memsizer.memorySize(elementDt) * length, position)
|
NumericLiteral.optimalInteger(program.memsizer.memorySize(elementDt) * length, position)
|
||||||
}
|
}
|
||||||
dt istype DataType.STR -> throw SyntaxError("sizeof(str) is undefined, did you mean len, or perhaps string.length?", position)
|
dt istype DataType.STR -> throw SyntaxError("sizeof(str) is undefined, did you mean len, or perhaps strings.length?", position)
|
||||||
else -> NumericLiteral(DataType.UBYTE, program.memsizer.memorySize(dt.getOr(DataType.UNDEFINED)).toDouble(), position)
|
else -> NumericLiteral(DataType.UBYTE, program.memsizer.memorySize(dt.getOr(DataType.UNDEFINED)).toDouble(), position)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -97,7 +97,10 @@ class ModuleImporter(private val program: Program,
|
|||||||
importModule(it)
|
importModule(it)
|
||||||
},
|
},
|
||||||
failure = {
|
failure = {
|
||||||
errors.err("no module found with name $moduleName. Searched in: $sourcePaths (and internal libraries)", import.position)
|
if(moduleName=="string")
|
||||||
|
errors.err("the 'string' module is now named 'strings'", import.position)
|
||||||
|
else
|
||||||
|
errors.err("no module found with name $moduleName. Searched in: $sourcePaths (and internal libraries)", import.position)
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -1989,7 +1989,7 @@ internal class AstChecker(private val program: Program,
|
|||||||
}
|
}
|
||||||
else if(targetDatatype==DataType.STR) {
|
else if(targetDatatype==DataType.STR) {
|
||||||
if(sourceDatatype==DataType.UWORD)
|
if(sourceDatatype==DataType.UWORD)
|
||||||
errors.err("can't assign UWORD to STR. If the source is a string and you actually want to overwrite the target string, use an explicit string.copy(src,tgt) instead.", position)
|
errors.err("can't assign UWORD to STR. If the source is a string and you actually want to overwrite the target string, use an explicit strings.copy(src,tgt) instead.", position)
|
||||||
else
|
else
|
||||||
errors.err("type of value $sourceDatatype doesn't match target $targetDatatype", position)
|
errors.err("type of value $sourceDatatype doesn't match target $targetDatatype", position)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
%import floats
|
%import floats
|
||||||
%import textio
|
%import textio
|
||||||
%import string
|
%import strings
|
||||||
%import anyall
|
%import anyall
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
@ -24,10 +24,10 @@ main {
|
|||||||
if length!=5 txt.print("error len1\n")
|
if length!=5 txt.print("error len1\n")
|
||||||
length = len(uwarr)
|
length = len(uwarr)
|
||||||
if length!=5 txt.print("error len2\n")
|
if length!=5 txt.print("error len2\n")
|
||||||
length=string.length(name)
|
length=strings.length(name)
|
||||||
if length!=5 txt.print("error strlen1\n")
|
if length!=5 txt.print("error strlen1\n")
|
||||||
name[3] = 0
|
name[3] = 0
|
||||||
length=string.length(name)
|
length=strings.length(name)
|
||||||
if length!=3 txt.print("error strlen2\n")
|
if length!=3 txt.print("error strlen2\n")
|
||||||
|
|
||||||
; ANY
|
; ANY
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import floats
|
%import floats
|
||||||
%import string
|
%import strings
|
||||||
%import syslib
|
%import syslib
|
||||||
%import math
|
%import math
|
||||||
%import anyall
|
%import anyall
|
||||||
|
@ -238,13 +238,13 @@ main {
|
|||||||
val src="""
|
val src="""
|
||||||
%import floats
|
%import floats
|
||||||
%import math
|
%import math
|
||||||
%import string
|
%import strings
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
float fl = 1.2 ; no other assignments
|
float fl = 1.2 ; no other assignments
|
||||||
bool @shared result1 = string.isdigit(math.diff(119, floats.floor(floats.deg(fl)) as ubyte))
|
bool @shared result1 = strings.isdigit(math.diff(119, floats.floor(floats.deg(fl)) as ubyte))
|
||||||
bool @shared result2 = string.isletter(math.diff(119, floats.floor(floats.deg(1.2)) as ubyte))
|
bool @shared result2 = strings.isletter(math.diff(119, floats.floor(floats.deg(1.2)) as ubyte))
|
||||||
}
|
}
|
||||||
}"""
|
}"""
|
||||||
val result = compileText(Cx16Target(), true, src, writeAssembly = false)!!
|
val result = compileText(Cx16Target(), true, src, writeAssembly = false)!!
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
%import textio
|
%import textio
|
||||||
%import floats
|
%import floats
|
||||||
%import string
|
%import strings
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
@ -15,10 +15,10 @@ main {
|
|||||||
sub test_string() {
|
sub test_string() {
|
||||||
str name="john"
|
str name="john"
|
||||||
|
|
||||||
if (string.compare(name, "aaa")==0) or (string.compare(name, "john")==0) or (string.compare(name, "bbb")==0) {
|
if (strings.compare(name, "aaa")==0) or (strings.compare(name, "john")==0) or (strings.compare(name, "bbb")==0) {
|
||||||
txt.print("name1 ok\n")
|
txt.print("name1 ok\n")
|
||||||
}
|
}
|
||||||
if (string.compare(name, "aaa")==0) or (string.compare(name, "zzz")==0) or (string.compare(name, "bbb")==0) {
|
if (strings.compare(name, "aaa")==0) or (strings.compare(name, "zzz")==0) or (strings.compare(name, "bbb")==0) {
|
||||||
txt.print("name2 fail!\n")
|
txt.print("name2 fail!\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
%import cx16logo
|
%import cx16logo
|
||||||
%import math
|
%import math
|
||||||
%import prog8_lib
|
%import prog8_lib
|
||||||
%import string
|
%import strings
|
||||||
%import syslib
|
%import syslib
|
||||||
%import test_stack
|
%import test_stack
|
||||||
%import textio
|
%import textio
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
;;%import floats
|
;;%import floats
|
||||||
%import math
|
%import math
|
||||||
%import prog8_lib
|
%import prog8_lib
|
||||||
%import string
|
%import strings
|
||||||
%import syslib
|
%import syslib
|
||||||
%import test_stack
|
%import test_stack
|
||||||
%import textio
|
%import textio
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
%import graphics
|
%import graphics
|
||||||
%import math
|
%import math
|
||||||
%import prog8_lib
|
%import prog8_lib
|
||||||
%import string
|
%import strings
|
||||||
%import syslib
|
%import syslib
|
||||||
%import test_stack
|
%import test_stack
|
||||||
%import textio
|
%import textio
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
%import prog8_lib
|
%import prog8_lib
|
||||||
%import psg
|
%import psg
|
||||||
%import sprites
|
%import sprites
|
||||||
%import string
|
%import strings
|
||||||
%import syslib
|
%import syslib
|
||||||
%import test_stack
|
%import test_stack
|
||||||
%import textio
|
%import textio
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
%import conv
|
%import conv
|
||||||
%import math
|
%import math
|
||||||
%import prog8_lib
|
%import prog8_lib
|
||||||
%import string
|
%import strings
|
||||||
%import syslib
|
%import syslib
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
%import cx16logo
|
%import cx16logo
|
||||||
%import math
|
%import math
|
||||||
%import prog8_lib
|
%import prog8_lib
|
||||||
%import string
|
%import strings
|
||||||
%import syslib
|
%import syslib
|
||||||
%import test_stack
|
%import test_stack
|
||||||
%import textio
|
%import textio
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
%import math
|
%import math
|
||||||
%import monogfx
|
%import monogfx
|
||||||
%import prog8_lib
|
%import prog8_lib
|
||||||
%import string
|
%import strings
|
||||||
%import syslib
|
%import syslib
|
||||||
%import test_stack
|
%import test_stack
|
||||||
%import textio
|
%import textio
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
Prog8 compiler v10.5.1 by Irmen de Jong (irmen@razorvine.net)
|
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
|
||||||
|
Prerelease version from git commit 7a647300 in branch nextversion
|
||||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||||
|
|
||||||
Compiling program import-all-atari.p8
|
Compiling program import-all-atari.p8
|
||||||
@ -137,10 +138,10 @@ math {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LIBRARY MODULE NAME: string
|
LIBRARY MODULE NAME: strings
|
||||||
---------------------------
|
----------------------------
|
||||||
|
|
||||||
string {
|
strings {
|
||||||
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
||||||
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
||||||
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
||||||
@ -192,12 +193,20 @@ atari {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sys {
|
sys {
|
||||||
const ubyte sizeof_bool
|
const byte MAX_BYTE
|
||||||
const ubyte sizeof_byte
|
const ubyte MAX_UBYTE
|
||||||
const ubyte sizeof_float
|
const uword MAX_UWORD
|
||||||
const ubyte sizeof_ubyte
|
const word MAX_WORD
|
||||||
const ubyte sizeof_uword
|
const byte MIN_BYTE
|
||||||
const ubyte sizeof_word
|
const ubyte MIN_UBYTE
|
||||||
|
const uword MIN_UWORD
|
||||||
|
const word MIN_WORD
|
||||||
|
const ubyte SIZEOF_BOOL
|
||||||
|
const ubyte SIZEOF_BYTE
|
||||||
|
const ubyte SIZEOF_FLOAT
|
||||||
|
const ubyte SIZEOF_UBYTE
|
||||||
|
const ubyte SIZEOF_UWORD
|
||||||
|
const ubyte SIZEOF_WORD
|
||||||
const ubyte target
|
const ubyte target
|
||||||
clear_carry ()
|
clear_carry ()
|
||||||
clear_irqd ()
|
clear_irqd ()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
Prog8 compiler v10.5.1 by Irmen de Jong (irmen@razorvine.net)
|
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
|
||||||
|
Prerelease version from git commit 7a647300 in branch nextversion
|
||||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||||
|
|
||||||
Compiling program import-all-c128.p8
|
Compiling program import-all-c128.p8
|
||||||
@ -179,10 +180,10 @@ diskio {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LIBRARY MODULE NAME: string
|
LIBRARY MODULE NAME: strings
|
||||||
---------------------------
|
----------------------------
|
||||||
|
|
||||||
string {
|
strings {
|
||||||
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
||||||
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
||||||
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
||||||
@ -453,12 +454,20 @@ c128 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sys {
|
sys {
|
||||||
const ubyte sizeof_bool
|
const byte MAX_BYTE
|
||||||
const ubyte sizeof_byte
|
const ubyte MAX_UBYTE
|
||||||
const ubyte sizeof_float
|
const uword MAX_UWORD
|
||||||
const ubyte sizeof_ubyte
|
const word MAX_WORD
|
||||||
const ubyte sizeof_uword
|
const byte MIN_BYTE
|
||||||
const ubyte sizeof_word
|
const ubyte MIN_UBYTE
|
||||||
|
const uword MIN_UWORD
|
||||||
|
const word MIN_WORD
|
||||||
|
const ubyte SIZEOF_BOOL
|
||||||
|
const ubyte SIZEOF_BYTE
|
||||||
|
const ubyte SIZEOF_FLOAT
|
||||||
|
const ubyte SIZEOF_UBYTE
|
||||||
|
const ubyte SIZEOF_UWORD
|
||||||
|
const ubyte SIZEOF_WORD
|
||||||
const ubyte target
|
const ubyte target
|
||||||
clear_carry ()
|
clear_carry ()
|
||||||
clear_irqd ()
|
clear_irqd ()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
Prog8 compiler v10.5.1 by Irmen de Jong (irmen@razorvine.net)
|
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
|
||||||
|
Prerelease version from git commit 7a647300 in branch nextversion
|
||||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||||
|
|
||||||
Compiling program import-all-c64.p8
|
Compiling program import-all-c64.p8
|
||||||
@ -102,6 +103,8 @@ LIBRARY MODULE NAME: floats
|
|||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
floats {
|
floats {
|
||||||
|
const float E
|
||||||
|
const float EPSILON
|
||||||
const float PI
|
const float PI
|
||||||
const float TWOPI
|
const float TWOPI
|
||||||
const float π
|
const float π
|
||||||
@ -300,10 +303,10 @@ diskio {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LIBRARY MODULE NAME: string
|
LIBRARY MODULE NAME: strings
|
||||||
---------------------------
|
----------------------------
|
||||||
|
|
||||||
string {
|
strings {
|
||||||
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
||||||
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
||||||
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
||||||
@ -575,12 +578,22 @@ c64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sys {
|
sys {
|
||||||
const ubyte sizeof_bool
|
const byte MAX_BYTE
|
||||||
const ubyte sizeof_byte
|
const float MAX_FLOAT
|
||||||
const ubyte sizeof_float
|
const ubyte MAX_UBYTE
|
||||||
const ubyte sizeof_ubyte
|
const uword MAX_UWORD
|
||||||
const ubyte sizeof_uword
|
const word MAX_WORD
|
||||||
const ubyte sizeof_word
|
const byte MIN_BYTE
|
||||||
|
const float MIN_FLOAT
|
||||||
|
const ubyte MIN_UBYTE
|
||||||
|
const uword MIN_UWORD
|
||||||
|
const word MIN_WORD
|
||||||
|
const ubyte SIZEOF_BOOL
|
||||||
|
const ubyte SIZEOF_BYTE
|
||||||
|
const ubyte SIZEOF_FLOAT
|
||||||
|
const ubyte SIZEOF_UBYTE
|
||||||
|
const ubyte SIZEOF_UWORD
|
||||||
|
const ubyte SIZEOF_WORD
|
||||||
const ubyte target
|
const ubyte target
|
||||||
clear_carry ()
|
clear_carry ()
|
||||||
clear_irqd ()
|
clear_irqd ()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
Prog8 compiler v10.5.1 by Irmen de Jong (irmen@razorvine.net)
|
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
|
||||||
|
Prerelease version from git commit 7a647300 in branch nextversion
|
||||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||||
|
|
||||||
Compiling program import-all-cx16.p8
|
Compiling program import-all-cx16.p8
|
||||||
@ -236,6 +237,8 @@ LIBRARY MODULE NAME: floats
|
|||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
floats {
|
floats {
|
||||||
|
const float E
|
||||||
|
const float EPSILON
|
||||||
const float PI
|
const float PI
|
||||||
const float TWOPI
|
const float TWOPI
|
||||||
const float π
|
const float π
|
||||||
@ -600,10 +603,10 @@ sprites {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LIBRARY MODULE NAME: string
|
LIBRARY MODULE NAME: strings
|
||||||
---------------------------
|
----------------------------
|
||||||
|
|
||||||
string {
|
strings {
|
||||||
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
||||||
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
||||||
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
||||||
@ -1129,12 +1132,22 @@ cx16 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sys {
|
sys {
|
||||||
const ubyte sizeof_bool
|
const byte MAX_BYTE
|
||||||
const ubyte sizeof_byte
|
const float MAX_FLOAT
|
||||||
const ubyte sizeof_float
|
const ubyte MAX_UBYTE
|
||||||
const ubyte sizeof_ubyte
|
const uword MAX_UWORD
|
||||||
const ubyte sizeof_uword
|
const word MAX_WORD
|
||||||
const ubyte sizeof_word
|
const byte MIN_BYTE
|
||||||
|
const float MIN_FLOAT
|
||||||
|
const ubyte MIN_UBYTE
|
||||||
|
const uword MIN_UWORD
|
||||||
|
const word MIN_WORD
|
||||||
|
const ubyte SIZEOF_BOOL
|
||||||
|
const ubyte SIZEOF_BYTE
|
||||||
|
const ubyte SIZEOF_FLOAT
|
||||||
|
const ubyte SIZEOF_UBYTE
|
||||||
|
const ubyte SIZEOF_UWORD
|
||||||
|
const ubyte SIZEOF_WORD
|
||||||
const ubyte target
|
const ubyte target
|
||||||
clear_carry ()
|
clear_carry ()
|
||||||
clear_irqd ()
|
clear_irqd ()
|
||||||
@ -1192,8 +1205,7 @@ LIBRARY MODULE NAME: textio
|
|||||||
txt {
|
txt {
|
||||||
const ubyte DEFAULT_HEIGHT
|
const ubyte DEFAULT_HEIGHT
|
||||||
const ubyte DEFAULT_WIDTH
|
const ubyte DEFAULT_WIDTH
|
||||||
const uword VERA_TEXTMATRIX_ADDR
|
const long VERA_TEXTMATRIX
|
||||||
const ubyte VERA_TEXTMATRIX_BANK
|
|
||||||
ubyte[] color_to_charcode
|
ubyte[] color_to_charcode
|
||||||
bell ()
|
bell ()
|
||||||
chrout (ubyte character @A) = $ffd2
|
chrout (ubyte character @A) = $ffd2
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
Prog8 compiler v10.5.1 by Irmen de Jong (irmen@razorvine.net)
|
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
|
||||||
|
Prerelease version from git commit 7a647300 in branch nextversion
|
||||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||||
|
|
||||||
Compiling program import-all-neo.p8
|
Compiling program import-all-neo.p8
|
||||||
@ -127,10 +128,10 @@ math {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LIBRARY MODULE NAME: string
|
LIBRARY MODULE NAME: strings
|
||||||
---------------------------
|
----------------------------
|
||||||
|
|
||||||
string {
|
strings {
|
||||||
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
||||||
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
||||||
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
||||||
@ -177,12 +178,20 @@ neo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sys {
|
sys {
|
||||||
const ubyte sizeof_bool
|
const byte MAX_BYTE
|
||||||
const ubyte sizeof_byte
|
const ubyte MAX_UBYTE
|
||||||
const ubyte sizeof_float
|
const uword MAX_UWORD
|
||||||
const ubyte sizeof_ubyte
|
const word MAX_WORD
|
||||||
const ubyte sizeof_uword
|
const byte MIN_BYTE
|
||||||
const ubyte sizeof_word
|
const ubyte MIN_UBYTE
|
||||||
|
const uword MIN_UWORD
|
||||||
|
const word MIN_WORD
|
||||||
|
const ubyte SIZEOF_BOOL
|
||||||
|
const ubyte SIZEOF_BYTE
|
||||||
|
const ubyte SIZEOF_FLOAT
|
||||||
|
const ubyte SIZEOF_UBYTE
|
||||||
|
const ubyte SIZEOF_UWORD
|
||||||
|
const ubyte SIZEOF_WORD
|
||||||
const ubyte target
|
const ubyte target
|
||||||
clear_carry ()
|
clear_carry ()
|
||||||
clear_irqd ()
|
clear_irqd ()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
Prog8 compiler v10.5.1 by Irmen de Jong (irmen@razorvine.net)
|
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
|
||||||
|
Prerelease version from git commit 7a647300 in branch nextversion
|
||||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||||
|
|
||||||
Compiling program import-all-pet32.p8
|
Compiling program import-all-pet32.p8
|
||||||
@ -137,10 +138,10 @@ math {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LIBRARY MODULE NAME: string
|
LIBRARY MODULE NAME: strings
|
||||||
---------------------------
|
----------------------------
|
||||||
|
|
||||||
string {
|
strings {
|
||||||
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
append (uword target @R0, uword suffix @R1) -> clobbers (Y) -> ubyte @A
|
||||||
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
compare (uword string1 @R0, uword string2 @AY) -> clobbers (Y) -> byte @A
|
||||||
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
contains (uword string @AY, ubyte character @X) -> bool @Pc
|
||||||
@ -210,12 +211,20 @@ cbm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sys {
|
sys {
|
||||||
const ubyte sizeof_bool
|
const byte MAX_BYTE
|
||||||
const ubyte sizeof_byte
|
const ubyte MAX_UBYTE
|
||||||
const ubyte sizeof_float
|
const uword MAX_UWORD
|
||||||
const ubyte sizeof_ubyte
|
const word MAX_WORD
|
||||||
const ubyte sizeof_uword
|
const byte MIN_BYTE
|
||||||
const ubyte sizeof_word
|
const ubyte MIN_UBYTE
|
||||||
|
const uword MIN_UWORD
|
||||||
|
const word MIN_WORD
|
||||||
|
const ubyte SIZEOF_BOOL
|
||||||
|
const ubyte SIZEOF_BYTE
|
||||||
|
const ubyte SIZEOF_FLOAT
|
||||||
|
const ubyte SIZEOF_UBYTE
|
||||||
|
const ubyte SIZEOF_UWORD
|
||||||
|
const ubyte SIZEOF_WORD
|
||||||
const ubyte target
|
const ubyte target
|
||||||
clear_carry ()
|
clear_carry ()
|
||||||
clear_irqd ()
|
clear_irqd ()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
Prog8 compiler v10.5.1 by Irmen de Jong (irmen@razorvine.net)
|
Prog8 compiler v10.6-SNAPSHOT by Irmen de Jong (irmen@razorvine.net)
|
||||||
|
Prerelease version from git commit 7a647300 in branch nextversion
|
||||||
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
This software is licensed under the GNU GPL 3.0, see https://www.gnu.org/licenses/gpl.html
|
||||||
|
|
||||||
Compiling program import-all-virtual.p8
|
Compiling program import-all-virtual.p8
|
||||||
@ -143,6 +144,8 @@ LIBRARY MODULE NAME: floats
|
|||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
floats {
|
floats {
|
||||||
|
const float E
|
||||||
|
const float EPSILON
|
||||||
const float PI
|
const float PI
|
||||||
const float TWOPI
|
const float TWOPI
|
||||||
const float π
|
const float π
|
||||||
@ -251,10 +254,10 @@ monogfx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LIBRARY MODULE NAME: string
|
LIBRARY MODULE NAME: strings
|
||||||
---------------------------
|
----------------------------
|
||||||
|
|
||||||
string {
|
strings {
|
||||||
append (str target, str suffix) -> ubyte
|
append (str target, str suffix) -> ubyte
|
||||||
compare (str st1, str st2) -> byte
|
compare (str st1, str st2) -> byte
|
||||||
contains (str st, ubyte character) -> bool
|
contains (str st, ubyte character) -> bool
|
||||||
@ -294,12 +297,22 @@ LIBRARY MODULE NAME: syslib
|
|||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
sys {
|
sys {
|
||||||
const ubyte sizeof_bool
|
const byte MAX_BYTE
|
||||||
const ubyte sizeof_byte
|
const float MAX_FLOAT
|
||||||
const ubyte sizeof_float
|
const ubyte MAX_UBYTE
|
||||||
const ubyte sizeof_ubyte
|
const uword MAX_UWORD
|
||||||
const ubyte sizeof_uword
|
const word MAX_WORD
|
||||||
const ubyte sizeof_word
|
const byte MIN_BYTE
|
||||||
|
const float MIN_FLOAT
|
||||||
|
const ubyte MIN_UBYTE
|
||||||
|
const uword MIN_UWORD
|
||||||
|
const word MIN_WORD
|
||||||
|
const ubyte SIZEOF_BOOL
|
||||||
|
const ubyte SIZEOF_BYTE
|
||||||
|
const ubyte SIZEOF_FLOAT
|
||||||
|
const ubyte SIZEOF_UBYTE
|
||||||
|
const ubyte SIZEOF_UWORD
|
||||||
|
const ubyte SIZEOF_WORD
|
||||||
const ubyte target
|
const ubyte target
|
||||||
clear_carry ()
|
clear_carry ()
|
||||||
clear_irqd ()
|
clear_irqd ()
|
||||||
|
@ -78,7 +78,7 @@ len (x)
|
|||||||
Note: this can be different from the number of *bytes* in memory if the datatype isn't a byte. See sizeof().
|
Note: this can be different from the number of *bytes* in memory if the datatype isn't a byte. See sizeof().
|
||||||
Note: lengths of strings and arrays are determined at compile-time! If your program modifies the actual
|
Note: lengths of strings and arrays are determined at compile-time! If your program modifies the actual
|
||||||
length of the string during execution, the value of len(s) may no longer be correct!
|
length of the string during execution, the value of len(s) may no longer be correct!
|
||||||
(use the ``string.length`` routine if you want to dynamically determine the length by counting to the
|
(use the ``strings.length`` routine if you want to dynamically determine the length by counting to the
|
||||||
first 0-byte)
|
first 0-byte)
|
||||||
|
|
||||||
|
|
||||||
@ -482,8 +482,8 @@ to see what's in there. (Note: slight variations for different compiler targets)
|
|||||||
descriptions for the various methods in this library for details and tips.
|
descriptions for the various methods in this library for details and tips.
|
||||||
|
|
||||||
|
|
||||||
string
|
strings
|
||||||
------
|
-------
|
||||||
Provides string manipulation routines.
|
Provides string manipulation routines.
|
||||||
|
|
||||||
``length (str) -> ubyte length``
|
``length (str) -> ubyte length``
|
||||||
@ -527,7 +527,7 @@ Provides string manipulation routines.
|
|||||||
``compare (string1, string2) -> ubyte result``
|
``compare (string1, string2) -> ubyte result``
|
||||||
Returns -1, 0 or 1 depending on whether string1 sorts before, equal or after string2.
|
Returns -1, 0 or 1 depending on whether string1 sorts before, equal or after string2.
|
||||||
Note that you can also directly compare strings and string values with each other
|
Note that you can also directly compare strings and string values with each other
|
||||||
using ``==``, ``<`` etcetera (it will use string.compare for you under water automatically).
|
using ``==``, ``<`` etcetera (it will use strings.compare for you under water automatically).
|
||||||
This even works when dealing with uword (pointer) variables when comparing them to a string type.
|
This even works when dealing with uword (pointer) variables when comparing them to a string type.
|
||||||
|
|
||||||
``copy (from, to) -> ubyte length``
|
``copy (from, to) -> ubyte length``
|
||||||
|
@ -432,13 +432,13 @@ read the syntax reference on strings.
|
|||||||
|
|
||||||
Using the ``in`` operator you can easily check if a character is present in a string,
|
Using the ``in`` operator you can easily check if a character is present in a string,
|
||||||
example: ``if '@' in email_address {....}`` (however this gives no clue about the location
|
example: ``if '@' in email_address {....}`` (however this gives no clue about the location
|
||||||
in the string where the character is present, if you need that, use the ``string.find()``
|
in the string where the character is present, if you need that, use the ``strings.find()``
|
||||||
library function instead)
|
library function instead)
|
||||||
**Caution:**
|
**Caution:**
|
||||||
This checks *all* elements in the string with the length as it was initially declared.
|
This checks *all* elements in the string with the length as it was initially declared.
|
||||||
Even when a string was changed and is terminated early with a 0-byte early,
|
Even when a string was changed and is terminated early with a 0-byte early,
|
||||||
the containment check with ``in`` will still look at all character positions in the initial string.
|
the containment check with ``in`` will still look at all character positions in the initial string.
|
||||||
Consider using ``string.find`` followed by ``if_cs`` (for instance) to do a "safer" search
|
Consider using ``strings.find`` followed by ``if_cs`` (for instance) to do a "safer" search
|
||||||
for a character in such strings (one that stops at the first 0 byte)
|
for a character in such strings (one that stops at the first 0 byte)
|
||||||
|
|
||||||
|
|
||||||
@ -482,7 +482,7 @@ by the compiler everywhere you refer to the constant (and no memory is allocated
|
|||||||
for the constant itself). Onlythe simple numeric types (byte, word, float) can be defined as a constant.
|
for the constant itself). Onlythe simple numeric types (byte, word, float) can be defined as a constant.
|
||||||
If something is defined as a constant, very efficient code can usually be generated from it.
|
If something is defined as a constant, very efficient code can usually be generated from it.
|
||||||
Variables on the other hand can't be optimized as much, need memory, and more code to manipulate them.
|
Variables on the other hand can't be optimized as much, need memory, and more code to manipulate them.
|
||||||
Note that a subset of the library routines in the ``math``, ``string`` and ``floats`` modules are recognised in
|
Note that a subset of the library routines in the ``math``, ``strings`` and ``floats`` modules are recognised in
|
||||||
compile time expressions. For example, the compiler knows what ``math.sin8u(12)`` is and replaces it with the computed result.
|
compile time expressions. For example, the compiler knows what ``math.sin8u(12)`` is and replaces it with the computed result.
|
||||||
|
|
||||||
When using ``&`` (the address-of operator but now applied to a datatype), the variable will point to specific location in memory,
|
When using ``&`` (the address-of operator but now applied to a datatype), the variable will point to specific location in memory,
|
||||||
|
@ -8,7 +8,6 @@ Future Things and Ideas
|
|||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
- something to reduce the need to use fully qualified names all the time. 'with' ? Or 'using <prefix>'?
|
- something to reduce the need to use fully qualified names all the time. 'with' ? Or 'using <prefix>'?
|
||||||
- rename 'string' module to 'strings' to be consistent with 'floats'?
|
|
||||||
- on the C64: make the floating point routines @banked so that basic can be permanently banked out even if you use floats? But this will crash when the call is done from program code at $a000+
|
- on the C64: make the floating point routines @banked so that basic can be permanently banked out even if you use floats? But this will crash when the call is done from program code at $a000+
|
||||||
- Libraries: improve ability to create library files in prog8; for instance there's still stuff injected into the start of the start() routine AND there is separate setup logic going on before calling it.
|
- Libraries: improve ability to create library files in prog8; for instance there's still stuff injected into the start of the start() routine AND there is separate setup logic going on before calling it.
|
||||||
Make up our mind! Maybe all setup does need to be put into start() ? because the program cannot function correctly when the variables aren't initialized properly bss is not cleared etc. etc.
|
Make up our mind! Maybe all setup does need to be put into start() ? because the program cannot function correctly when the variables aren't initialized properly bss is not cleared etc. etc.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import string
|
%import strings
|
||||||
|
|
||||||
; Animal guessing game where the computer gets smarter every time.
|
; Animal guessing game where the computer gets smarter every time.
|
||||||
; Note: this program can be compiled for multiple target systems.
|
; Note: this program can be compiled for multiple target systems.
|
||||||
@ -114,8 +114,8 @@ main {
|
|||||||
|
|
||||||
animals[new_animal_number] = animal_names_ptr
|
animals[new_animal_number] = animal_names_ptr
|
||||||
questions[new_question_number] = questions_ptr
|
questions[new_question_number] = questions_ptr
|
||||||
animal_names_ptr += string.copy(name, animal_names_ptr)+1 ; store animal name in buffer
|
animal_names_ptr += strings.copy(name, animal_names_ptr)+1 ; store animal name in buffer
|
||||||
questions_ptr += string.copy(userinput, questions_ptr)+1 ; store question in buffer
|
questions_ptr += strings.copy(userinput, questions_ptr)+1 ; store question in buffer
|
||||||
|
|
||||||
answers_questions[new_question_number] = mkword(0, 0)
|
answers_questions[new_question_number] = mkword(0, 0)
|
||||||
if answer[0]=='y'
|
if answer[0]=='y'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
%import string
|
%import strings
|
||||||
%import textio
|
%import textio
|
||||||
%option no_sysinit
|
%option no_sysinit
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
@ -9,7 +9,7 @@ main {
|
|||||||
sub start() {
|
sub start() {
|
||||||
; copy basic rom to ram and replace ready prompt
|
; copy basic rom to ram and replace ready prompt
|
||||||
sys.memcopy($a000, $a000, $2000)
|
sys.memcopy($a000, $a000, $2000)
|
||||||
void string.copy(iso:"HELLO!\r", $a378)
|
void strings.copy(iso:"HELLO!\r", $a378)
|
||||||
|
|
||||||
txt.print("8 bytes at $f000 (kernal rom):\n")
|
txt.print("8 bytes at $f000 (kernal rom):\n")
|
||||||
for cx16.r0 in $f000 to $f007 {
|
for cx16.r0 in $f000 to $f007 {
|
||||||
@ -21,7 +21,7 @@ main {
|
|||||||
; store some other data in the RAM below those kernal ROM locations
|
; store some other data in the RAM below those kernal ROM locations
|
||||||
; switch off kernal rom to see those bytes
|
; switch off kernal rom to see those bytes
|
||||||
; we cannot print during this time and the IRQ has to be disabled temporarily as well.
|
; we cannot print during this time and the IRQ has to be disabled temporarily as well.
|
||||||
void string.copy("hello !?", $f000)
|
void strings.copy("hello !?", $f000)
|
||||||
sys.set_irqd()
|
sys.set_irqd()
|
||||||
c64.banks(%101) ; switch off roms
|
c64.banks(%101) ; switch off roms
|
||||||
ubyte[8] buffer
|
ubyte[8] buffer
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import palette
|
%import palette
|
||||||
%import string
|
%import strings
|
||||||
%import gfx_hires
|
%import gfx_hires
|
||||||
|
|
||||||
; Mockup of a classic Amiga Workbench screen.
|
; Mockup of a classic Amiga Workbench screen.
|
||||||
@ -164,7 +164,7 @@ widget {
|
|||||||
const ubyte height = 28
|
const ubyte height = 28
|
||||||
highlightedrect(x, y, width, height, false, false)
|
highlightedrect(x, y, width, height, false, false)
|
||||||
uword middlex = x+width/2+1
|
uword middlex = x+width/2+1
|
||||||
ubyte halfstring = string.length(caption) * 4
|
ubyte halfstring = strings.length(caption) * 4
|
||||||
gfx_hires.text(middlex-halfstring,y+height+1,1,caption)
|
gfx_hires.text(middlex-halfstring,y+height+1,1,caption)
|
||||||
gfx_hires.disc(x+width/4+4, y+height/2, height/2-3, 1)
|
gfx_hires.disc(x+width/4+4, y+height/2, height/2-3, 1)
|
||||||
gfx_hires.fillrect(x+20,y+12,width/2,height/2-4,3)
|
gfx_hires.fillrect(x+20,y+12,width/2,height/2-4,3)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
%import syslib
|
%import syslib
|
||||||
%import string
|
%import strings
|
||||||
|
|
||||||
; Streaming routine for MCF files (multipurpose chunk format):
|
; Streaming routine for MCF files (multipurpose chunk format):
|
||||||
; 1. call open()
|
; 1. call open()
|
||||||
@ -18,7 +18,7 @@ mcf {
|
|||||||
|
|
||||||
sub open(str filename, ubyte drive, ubyte channel) -> bool {
|
sub open(str filename, ubyte drive, ubyte channel) -> bool {
|
||||||
file_channel = channel
|
file_channel = channel
|
||||||
cbm.SETNAM(string.length(filename), filename)
|
cbm.SETNAM(strings.length(filename), filename)
|
||||||
cbm.SETLFS(channel, drive, 2)
|
cbm.SETLFS(channel, drive, 2)
|
||||||
void cbm.OPEN()
|
void cbm.OPEN()
|
||||||
if_cc {
|
if_cc {
|
||||||
|
@ -16,8 +16,8 @@ main {
|
|||||||
if diskio.f_open_w("@:seektestfile.bin") {
|
if diskio.f_open_w("@:seektestfile.bin") {
|
||||||
repeat 100 {
|
repeat 100 {
|
||||||
str text = "hello world.*"
|
str text = "hello world.*"
|
||||||
void diskio.f_write(text, string.length(text))
|
void diskio.f_write(text, strings.length(text))
|
||||||
total += string.length(text)
|
total += strings.length(text)
|
||||||
}
|
}
|
||||||
diskio.f_close_w()
|
diskio.f_close_w()
|
||||||
txt.print("written size=")
|
txt.print("written size=")
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
%import floats
|
%import floats
|
||||||
%import textio
|
%import textio
|
||||||
%import string
|
%import strings
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
main {
|
main {
|
||||||
@ -75,7 +75,7 @@ main {
|
|||||||
'-' -> negative=true
|
'-' -> negative=true
|
||||||
'+', ' ' -> { /* skip */ }
|
'+', ' ' -> { /* skip */ }
|
||||||
else -> {
|
else -> {
|
||||||
if string.isdigit(cx16.r0L) {
|
if strings.isdigit(cx16.r0L) {
|
||||||
result *= 10
|
result *= 10
|
||||||
result += cx16.r0L - '0'
|
result += cx16.r0L - '0'
|
||||||
} else
|
} else
|
||||||
@ -92,7 +92,7 @@ main {
|
|||||||
cx16.r0L = @(stringptr)
|
cx16.r0L = @(stringptr)
|
||||||
if cx16.r0L==' '
|
if cx16.r0L==' '
|
||||||
continue
|
continue
|
||||||
else if string.isdigit(cx16.r0L) {
|
else if strings.isdigit(cx16.r0L) {
|
||||||
exponent--
|
exponent--
|
||||||
result *= 10
|
result *= 10
|
||||||
result += cx16.r0L - '0'
|
result += cx16.r0L - '0'
|
||||||
@ -113,7 +113,7 @@ main {
|
|||||||
'+', ' ' -> { /* skip */ }
|
'+', ' ' -> { /* skip */ }
|
||||||
'-' -> neg_exponent=true
|
'-' -> neg_exponent=true
|
||||||
else -> {
|
else -> {
|
||||||
if string.isdigit(cx16.r0L) {
|
if strings.isdigit(cx16.r0L) {
|
||||||
exp_value *= 10
|
exp_value *= 10
|
||||||
exp_value += cx16.r0L - '0'
|
exp_value += cx16.r0L - '0'
|
||||||
} else
|
} else
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
%import floats
|
%import floats
|
||||||
|
|
||||||
|
%import strings
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
%import textio
|
%import textio
|
||||||
%import conv
|
%import conv
|
||||||
%import diskio
|
%import diskio
|
||||||
%import string
|
%import strings
|
||||||
%zeropage basicsafe
|
%zeropage basicsafe
|
||||||
|
|
||||||
; Prog8 adaptation of the Text-Elite galaxy system trading simulation engine.
|
; Prog8 adaptation of the Text-Elite galaxy system trading simulation engine.
|
||||||
@ -517,7 +517,7 @@ galaxy {
|
|||||||
ubyte distance = planet.distance(px, py)
|
ubyte distance = planet.distance(px, py)
|
||||||
if distance <= max_distance {
|
if distance <= max_distance {
|
||||||
planet.name = make_current_planet_name()
|
planet.name = make_current_planet_name()
|
||||||
planet.name[0] = string.upperchar(planet.name[0])
|
planet.name[0] = strings.upperchar(planet.name[0])
|
||||||
uword tx = planet.x
|
uword tx = planet.x
|
||||||
uword ty = planet.y
|
uword ty = planet.y
|
||||||
if local {
|
if local {
|
||||||
@ -803,7 +803,7 @@ planet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
randname[nx] = 0
|
randname[nx] = 0
|
||||||
randname[0] = string.upperchar(randname[0])
|
randname[0] = strings.upperchar(randname[0])
|
||||||
return randname
|
return randname
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -875,12 +875,12 @@ planet {
|
|||||||
source_ptr = source_stack[stack_ptr]
|
source_ptr = source_stack[stack_ptr]
|
||||||
} else {
|
} else {
|
||||||
if c == $b0 {
|
if c == $b0 {
|
||||||
@(result_ptr) = string.upperchar(name[0])
|
@(result_ptr) = strings.upperchar(name[0])
|
||||||
result_ptr++
|
result_ptr++
|
||||||
concat_string(&name + 1)
|
concat_string(&name + 1)
|
||||||
}
|
}
|
||||||
else if c == $b1 {
|
else if c == $b1 {
|
||||||
@(result_ptr) = string.upperchar(name[0])
|
@(result_ptr) = strings.upperchar(name[0])
|
||||||
result_ptr++
|
result_ptr++
|
||||||
ubyte ni
|
ubyte ni
|
||||||
for ni in 1 to len(name) {
|
for ni in 1 to len(name) {
|
||||||
@ -995,7 +995,7 @@ planet {
|
|||||||
|
|
||||||
sub print_name_uppercase() {
|
sub print_name_uppercase() {
|
||||||
for cx16.r0L in name
|
for cx16.r0L in name
|
||||||
txt.chrout(string.upperchar(cx16.r0L))
|
txt.chrout(strings.upperchar(cx16.r0L))
|
||||||
}
|
}
|
||||||
|
|
||||||
sub getword(ubyte listnum, ubyte wordidx) -> uword {
|
sub getword(ubyte listnum, ubyte wordidx) -> uword {
|
||||||
@ -1012,7 +1012,7 @@ util {
|
|||||||
if pc == 0
|
if pc == 0
|
||||||
return true
|
return true
|
||||||
; to lowercase for case insensitive compare:
|
; to lowercase for case insensitive compare:
|
||||||
if string.lowerchar(pc)!=string.lowerchar(sc)
|
if strings.lowerchar(pc)!=strings.lowerchar(sc)
|
||||||
return false
|
return false
|
||||||
prefixptr++
|
prefixptr++
|
||||||
stringptr++
|
stringptr++
|
||||||
@ -1020,7 +1020,7 @@ util {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sub print_right(ubyte width, uword s) {
|
sub print_right(ubyte width, uword s) {
|
||||||
repeat width - string.length(s) {
|
repeat width - strings.length(s) {
|
||||||
txt.spc()
|
txt.spc()
|
||||||
}
|
}
|
||||||
txt.print(s)
|
txt.print(s)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user