added textio.spc(). assem tweaks.

This commit is contained in:
Irmen de Jong 2021-01-14 22:51:09 +01:00
parent 04e75455c4
commit 7277c08fa6
17 changed files with 193 additions and 134 deletions

View File

@ -19,14 +19,19 @@ sub clear_screen() {
txt.chrout(147) txt.chrout(147)
} }
sub home() {
txt.chrout(19)
}
sub nl() { sub nl() {
txt.chrout('\n') txt.chrout('\n')
} }
sub home() { sub spc() {
txt.chrout(19) txt.chrout(' ')
} }
asmsub fill_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) { asmsub fill_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) {
; ---- fill the character screen with the given fill character and character color. ; ---- fill the character screen with the given fill character and character color.
; (assumes screen and color matrix are at their default addresses) ; (assumes screen and color matrix are at their default addresses)

View File

@ -19,14 +19,19 @@ sub clear_screen() {
txt.chrout(147) txt.chrout(147)
} }
sub home() {
txt.chrout(19)
}
sub nl() { sub nl() {
txt.chrout('\n') txt.chrout('\n')
} }
sub home() { sub spc() {
txt.chrout(19) txt.chrout(' ')
} }
asmsub fill_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) { asmsub fill_screen (ubyte char @ A, ubyte color @ Y) clobbers(A) {
; ---- fill the character screen with the given fill character and character color. ; ---- fill the character screen with the given fill character and character color.
%asm {{ %asm {{

View File

@ -30,7 +30,7 @@ diskio {
ubyte low = c64.CHRIN() ubyte low = c64.CHRIN()
ubyte high = c64.CHRIN() ubyte high = c64.CHRIN()
txt.print_uw(mkword(high, low)) txt.print_uw(mkword(high, low))
txt.chrout(' ') txt.spc()
ubyte @zp char ubyte @zp char
repeat { repeat {
char = c64.CHRIN() char = c64.CHRIN()
@ -295,7 +295,8 @@ _in_buffer sta $ffff
; Routine to read text lines from a text file. Lines must be less than 255 characters. ; Routine to read text lines from a text file. Lines must be less than 255 characters.
; Reads characters from the input file UNTIL a newline or return character (or EOF). ; Reads characters from the input file UNTIL a newline or return character (or EOF).
; The line read will be 0-terminated in the buffer (and not contain the end of line character). ; The line read will be 0-terminated in the buffer (and not contain the end of line character).
; The length of the line is returned in Y. ; The length of the line is returned in Y. Note that an empty line is okay and is length 0!
; I/O error status should be checked by the caller itself via READST() routine.
%asm {{ %asm {{
sta P8ZP_SCRATCH_W1 sta P8ZP_SCRATCH_W1
sty P8ZP_SCRATCH_W1+1 sty P8ZP_SCRATCH_W1+1

View File

@ -482,7 +482,7 @@ galaxy {
txt.chrout('*') txt.chrout('*')
else else
txt.chrout('-') txt.chrout('-')
txt.chrout(' ') txt.spc()
planet.name = make_current_planet_name() planet.name = make_current_planet_name()
planet.display(true) planet.display(true)
txt.print(" (") txt.print(" (")
@ -853,9 +853,9 @@ planet {
print_name_uppercase() print_name_uppercase()
txt.print(" TL:") txt.print(" TL:")
txt.print_ub(techlevel+1) txt.print_ub(techlevel+1)
txt.chrout(' ') txt.spc()
txt.print(econnames[economy]) txt.print(econnames[economy])
txt.chrout(' ') txt.spc()
txt.print(govnames[govtype]) txt.print(govnames[govtype])
} else { } else {
txt.print("\n\nSystem: ") txt.print("\n\nSystem: ")
@ -864,7 +864,7 @@ planet {
txt.print_ub(x) txt.print_ub(x)
txt.chrout('\'') txt.chrout('\'')
txt.print_ub(y) txt.print_ub(y)
txt.chrout(' ') txt.spc()
txt.chrout('#') txt.chrout('#')
txt.print_ub(number) txt.print_ub(number)
txt.print("\nEconomy: ") txt.print("\nEconomy: ")
@ -883,15 +883,15 @@ planet {
if species_is_alien { if species_is_alien {
if species_size < len(species_sizes) { if species_size < len(species_sizes) {
txt.print(species_sizes[species_size]) txt.print(species_sizes[species_size])
txt.chrout(' ') txt.spc()
} }
if species_color < len(species_colors) { if species_color < len(species_colors) {
txt.print(species_colors[species_color]) txt.print(species_colors[species_color])
txt.chrout(' ') txt.spc()
} }
if species_look < len(species_looks) { if species_look < len(species_looks) {
txt.print(species_looks[species_look]) txt.print(species_looks[species_look])
txt.chrout(' ') txt.spc()
} }
if species_kind < len(species_kinds) { if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind]) txt.print(species_kinds[species_kind])
@ -956,7 +956,7 @@ util {
sub print_right(ubyte width, uword st) { sub print_right(ubyte width, uword st) {
repeat width - string.length(st) { repeat width - string.length(st) {
txt.chrout(' ') txt.spc()
} }
txt.print(st) txt.print(st)
} }

View File

@ -472,7 +472,7 @@ galaxy10 {
txt.chrout('*') txt.chrout('*')
else else
txt.chrout('-') txt.chrout('-')
txt.chrout(' ') txt.spc()
planet10.name = make_current_planet10_name() planet10.name = make_current_planet10_name()
planet10.display(true) planet10.display(true)
txt.print(" (") txt.print(" (")
@ -843,9 +843,9 @@ planet10 {
print_name_uppercase() print_name_uppercase()
txt.print(" TL:") txt.print(" TL:")
txt.print_ub(techlevel+1) txt.print_ub(techlevel+1)
txt.chrout(' ') txt.spc()
txt.print(econnames[economy]) txt.print(econnames[economy])
txt.chrout(' ') txt.spc()
txt.print(govnames[govtype]) txt.print(govnames[govtype])
} else { } else {
txt.print("\n\nSystem: ") txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet10 {
txt.print_ub(x) txt.print_ub(x)
txt.chrout('\'') txt.chrout('\'')
txt.print_ub(y) txt.print_ub(y)
txt.chrout(' ') txt.spc()
txt.chrout('#') txt.chrout('#')
txt.print_ub(number) txt.print_ub(number)
txt.print("\nEconomy: ") txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet10 {
if species_is_alien { if species_is_alien {
if species_size < len(species_sizes) { if species_size < len(species_sizes) {
txt.print(species_sizes[species_size]) txt.print(species_sizes[species_size])
txt.chrout(' ') txt.spc()
} }
if species_color < len(species_colors) { if species_color < len(species_colors) {
txt.print(species_colors[species_color]) txt.print(species_colors[species_color])
txt.chrout(' ') txt.spc()
} }
if species_look < len(species_looks) { if species_look < len(species_looks) {
txt.print(species_looks[species_look]) txt.print(species_looks[species_look])
txt.chrout(' ') txt.spc()
} }
if species_kind < len(species_kinds) { if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind]) txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util10 {
sub print_right(ubyte width, uword st) { sub print_right(ubyte width, uword st) {
repeat width - string.length(st) { repeat width - string.length(st) {
txt.chrout(' ') txt.spc()
} }
txt.print(st) txt.print(st)
} }

View File

@ -472,7 +472,7 @@ galaxy2 {
txt.chrout('*') txt.chrout('*')
else else
txt.chrout('-') txt.chrout('-')
txt.chrout(' ') txt.spc()
planet2.name = make_current_planet2_name() planet2.name = make_current_planet2_name()
planet2.display(true) planet2.display(true)
txt.print(" (") txt.print(" (")
@ -843,9 +843,9 @@ planet2 {
print_name_uppercase() print_name_uppercase()
txt.print(" TL:") txt.print(" TL:")
txt.print_ub(techlevel+1) txt.print_ub(techlevel+1)
txt.chrout(' ') txt.spc()
txt.print(econnames[economy]) txt.print(econnames[economy])
txt.chrout(' ') txt.spc()
txt.print(govnames[govtype]) txt.print(govnames[govtype])
} else { } else {
txt.print("\n\nSystem: ") txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet2 {
txt.print_ub(x) txt.print_ub(x)
txt.chrout('\'') txt.chrout('\'')
txt.print_ub(y) txt.print_ub(y)
txt.chrout(' ') txt.spc()
txt.chrout('#') txt.chrout('#')
txt.print_ub(number) txt.print_ub(number)
txt.print("\nEconomy: ") txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet2 {
if species_is_alien { if species_is_alien {
if species_size < len(species_sizes) { if species_size < len(species_sizes) {
txt.print(species_sizes[species_size]) txt.print(species_sizes[species_size])
txt.chrout(' ') txt.spc()
} }
if species_color < len(species_colors) { if species_color < len(species_colors) {
txt.print(species_colors[species_color]) txt.print(species_colors[species_color])
txt.chrout(' ') txt.spc()
} }
if species_look < len(species_looks) { if species_look < len(species_looks) {
txt.print(species_looks[species_look]) txt.print(species_looks[species_look])
txt.chrout(' ') txt.spc()
} }
if species_kind < len(species_kinds) { if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind]) txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util2 {
sub print_right(ubyte width, uword st) { sub print_right(ubyte width, uword st) {
repeat width - string.length(st) { repeat width - string.length(st) {
txt.chrout(' ') txt.spc()
} }
txt.print(st) txt.print(st)
} }

View File

@ -472,7 +472,7 @@ galaxy3 {
txt.chrout('*') txt.chrout('*')
else else
txt.chrout('-') txt.chrout('-')
txt.chrout(' ') txt.spc()
planet3.name = make_current_planet3_name() planet3.name = make_current_planet3_name()
planet3.display(true) planet3.display(true)
txt.print(" (") txt.print(" (")
@ -843,9 +843,9 @@ planet3 {
print_name_uppercase() print_name_uppercase()
txt.print(" TL:") txt.print(" TL:")
txt.print_ub(techlevel+1) txt.print_ub(techlevel+1)
txt.chrout(' ') txt.spc()
txt.print(econnames[economy]) txt.print(econnames[economy])
txt.chrout(' ') txt.spc()
txt.print(govnames[govtype]) txt.print(govnames[govtype])
} else { } else {
txt.print("\n\nSystem: ") txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet3 {
txt.print_ub(x) txt.print_ub(x)
txt.chrout('\'') txt.chrout('\'')
txt.print_ub(y) txt.print_ub(y)
txt.chrout(' ') txt.spc()
txt.chrout('#') txt.chrout('#')
txt.print_ub(number) txt.print_ub(number)
txt.print("\nEconomy: ") txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet3 {
if species_is_alien { if species_is_alien {
if species_size < len(species_sizes) { if species_size < len(species_sizes) {
txt.print(species_sizes[species_size]) txt.print(species_sizes[species_size])
txt.chrout(' ') txt.spc()
} }
if species_color < len(species_colors) { if species_color < len(species_colors) {
txt.print(species_colors[species_color]) txt.print(species_colors[species_color])
txt.chrout(' ') txt.spc()
} }
if species_look < len(species_looks) { if species_look < len(species_looks) {
txt.print(species_looks[species_look]) txt.print(species_looks[species_look])
txt.chrout(' ') txt.spc()
} }
if species_kind < len(species_kinds) { if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind]) txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util3 {
sub print_right(ubyte width, uword st) { sub print_right(ubyte width, uword st) {
repeat width - string.length(st) { repeat width - string.length(st) {
txt.chrout(' ') txt.spc()
} }
txt.print(st) txt.print(st)
} }

View File

@ -472,7 +472,7 @@ galaxy4 {
txt.chrout('*') txt.chrout('*')
else else
txt.chrout('-') txt.chrout('-')
txt.chrout(' ') txt.spc()
planet4.name = make_current_planet4_name() planet4.name = make_current_planet4_name()
planet4.display(true) planet4.display(true)
txt.print(" (") txt.print(" (")
@ -843,9 +843,9 @@ planet4 {
print_name_uppercase() print_name_uppercase()
txt.print(" TL:") txt.print(" TL:")
txt.print_ub(techlevel+1) txt.print_ub(techlevel+1)
txt.chrout(' ') txt.spc()
txt.print(econnames[economy]) txt.print(econnames[economy])
txt.chrout(' ') txt.spc()
txt.print(govnames[govtype]) txt.print(govnames[govtype])
} else { } else {
txt.print("\n\nSystem: ") txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet4 {
txt.print_ub(x) txt.print_ub(x)
txt.chrout('\'') txt.chrout('\'')
txt.print_ub(y) txt.print_ub(y)
txt.chrout(' ') txt.spc()
txt.chrout('#') txt.chrout('#')
txt.print_ub(number) txt.print_ub(number)
txt.print("\nEconomy: ") txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet4 {
if species_is_alien { if species_is_alien {
if species_size < len(species_sizes) { if species_size < len(species_sizes) {
txt.print(species_sizes[species_size]) txt.print(species_sizes[species_size])
txt.chrout(' ') txt.spc()
} }
if species_color < len(species_colors) { if species_color < len(species_colors) {
txt.print(species_colors[species_color]) txt.print(species_colors[species_color])
txt.chrout(' ') txt.spc()
} }
if species_look < len(species_looks) { if species_look < len(species_looks) {
txt.print(species_looks[species_look]) txt.print(species_looks[species_look])
txt.chrout(' ') txt.spc()
} }
if species_kind < len(species_kinds) { if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind]) txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util4 {
sub print_right(ubyte width, uword st) { sub print_right(ubyte width, uword st) {
repeat width - string.length(st) { repeat width - string.length(st) {
txt.chrout(' ') txt.spc()
} }
txt.print(st) txt.print(st)
} }

View File

@ -472,7 +472,7 @@ galaxy5 {
txt.chrout('*') txt.chrout('*')
else else
txt.chrout('-') txt.chrout('-')
txt.chrout(' ') txt.spc()
planet5.name = make_current_planet5_name() planet5.name = make_current_planet5_name()
planet5.display(true) planet5.display(true)
txt.print(" (") txt.print(" (")
@ -843,9 +843,9 @@ planet5 {
print_name_uppercase() print_name_uppercase()
txt.print(" TL:") txt.print(" TL:")
txt.print_ub(techlevel+1) txt.print_ub(techlevel+1)
txt.chrout(' ') txt.spc()
txt.print(econnames[economy]) txt.print(econnames[economy])
txt.chrout(' ') txt.spc()
txt.print(govnames[govtype]) txt.print(govnames[govtype])
} else { } else {
txt.print("\n\nSystem: ") txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet5 {
txt.print_ub(x) txt.print_ub(x)
txt.chrout('\'') txt.chrout('\'')
txt.print_ub(y) txt.print_ub(y)
txt.chrout(' ') txt.spc()
txt.chrout('#') txt.chrout('#')
txt.print_ub(number) txt.print_ub(number)
txt.print("\nEconomy: ") txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet5 {
if species_is_alien { if species_is_alien {
if species_size < len(species_sizes) { if species_size < len(species_sizes) {
txt.print(species_sizes[species_size]) txt.print(species_sizes[species_size])
txt.chrout(' ') txt.spc()
} }
if species_color < len(species_colors) { if species_color < len(species_colors) {
txt.print(species_colors[species_color]) txt.print(species_colors[species_color])
txt.chrout(' ') txt.spc()
} }
if species_look < len(species_looks) { if species_look < len(species_looks) {
txt.print(species_looks[species_look]) txt.print(species_looks[species_look])
txt.chrout(' ') txt.spc()
} }
if species_kind < len(species_kinds) { if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind]) txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util5 {
sub print_right(ubyte width, uword st) { sub print_right(ubyte width, uword st) {
repeat width - string.length(st) { repeat width - string.length(st) {
txt.chrout(' ') txt.spc()
} }
txt.print(st) txt.print(st)
} }

View File

@ -472,7 +472,7 @@ galaxy6 {
txt.chrout('*') txt.chrout('*')
else else
txt.chrout('-') txt.chrout('-')
txt.chrout(' ') txt.spc()
planet6.name = make_current_planet6_name() planet6.name = make_current_planet6_name()
planet6.display(true) planet6.display(true)
txt.print(" (") txt.print(" (")
@ -843,9 +843,9 @@ planet6 {
print_name_uppercase() print_name_uppercase()
txt.print(" TL:") txt.print(" TL:")
txt.print_ub(techlevel+1) txt.print_ub(techlevel+1)
txt.chrout(' ') txt.spc()
txt.print(econnames[economy]) txt.print(econnames[economy])
txt.chrout(' ') txt.spc()
txt.print(govnames[govtype]) txt.print(govnames[govtype])
} else { } else {
txt.print("\n\nSystem: ") txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet6 {
txt.print_ub(x) txt.print_ub(x)
txt.chrout('\'') txt.chrout('\'')
txt.print_ub(y) txt.print_ub(y)
txt.chrout(' ') txt.spc()
txt.chrout('#') txt.chrout('#')
txt.print_ub(number) txt.print_ub(number)
txt.print("\nEconomy: ") txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet6 {
if species_is_alien { if species_is_alien {
if species_size < len(species_sizes) { if species_size < len(species_sizes) {
txt.print(species_sizes[species_size]) txt.print(species_sizes[species_size])
txt.chrout(' ') txt.spc()
} }
if species_color < len(species_colors) { if species_color < len(species_colors) {
txt.print(species_colors[species_color]) txt.print(species_colors[species_color])
txt.chrout(' ') txt.spc()
} }
if species_look < len(species_looks) { if species_look < len(species_looks) {
txt.print(species_looks[species_look]) txt.print(species_looks[species_look])
txt.chrout(' ') txt.spc()
} }
if species_kind < len(species_kinds) { if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind]) txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util6 {
sub print_right(ubyte width, uword st) { sub print_right(ubyte width, uword st) {
repeat width - string.length(st) { repeat width - string.length(st) {
txt.chrout(' ') txt.spc()
} }
txt.print(st) txt.print(st)
} }

View File

@ -472,7 +472,7 @@ galaxy7 {
txt.chrout('*') txt.chrout('*')
else else
txt.chrout('-') txt.chrout('-')
txt.chrout(' ') txt.spc()
planet7.name = make_current_planet7_name() planet7.name = make_current_planet7_name()
planet7.display(true) planet7.display(true)
txt.print(" (") txt.print(" (")
@ -843,9 +843,9 @@ planet7 {
print_name_uppercase() print_name_uppercase()
txt.print(" TL:") txt.print(" TL:")
txt.print_ub(techlevel+1) txt.print_ub(techlevel+1)
txt.chrout(' ') txt.spc()
txt.print(econnames[economy]) txt.print(econnames[economy])
txt.chrout(' ') txt.spc()
txt.print(govnames[govtype]) txt.print(govnames[govtype])
} else { } else {
txt.print("\n\nSystem: ") txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet7 {
txt.print_ub(x) txt.print_ub(x)
txt.chrout('\'') txt.chrout('\'')
txt.print_ub(y) txt.print_ub(y)
txt.chrout(' ') txt.spc()
txt.chrout('#') txt.chrout('#')
txt.print_ub(number) txt.print_ub(number)
txt.print("\nEconomy: ") txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet7 {
if species_is_alien { if species_is_alien {
if species_size < len(species_sizes) { if species_size < len(species_sizes) {
txt.print(species_sizes[species_size]) txt.print(species_sizes[species_size])
txt.chrout(' ') txt.spc()
} }
if species_color < len(species_colors) { if species_color < len(species_colors) {
txt.print(species_colors[species_color]) txt.print(species_colors[species_color])
txt.chrout(' ') txt.spc()
} }
if species_look < len(species_looks) { if species_look < len(species_looks) {
txt.print(species_looks[species_look]) txt.print(species_looks[species_look])
txt.chrout(' ') txt.spc()
} }
if species_kind < len(species_kinds) { if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind]) txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util7 {
sub print_right(ubyte width, uword st) { sub print_right(ubyte width, uword st) {
repeat width - string.length(st) { repeat width - string.length(st) {
txt.chrout(' ') txt.spc()
} }
txt.print(st) txt.print(st)
} }

View File

@ -472,7 +472,7 @@ galaxy8 {
txt.chrout('*') txt.chrout('*')
else else
txt.chrout('-') txt.chrout('-')
txt.chrout(' ') txt.spc()
planet8.name = make_current_planet8_name() planet8.name = make_current_planet8_name()
planet8.display(true) planet8.display(true)
txt.print(" (") txt.print(" (")
@ -843,9 +843,9 @@ planet8 {
print_name_uppercase() print_name_uppercase()
txt.print(" TL:") txt.print(" TL:")
txt.print_ub(techlevel+1) txt.print_ub(techlevel+1)
txt.chrout(' ') txt.spc()
txt.print(econnames[economy]) txt.print(econnames[economy])
txt.chrout(' ') txt.spc()
txt.print(govnames[govtype]) txt.print(govnames[govtype])
} else { } else {
txt.print("\n\nSystem: ") txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet8 {
txt.print_ub(x) txt.print_ub(x)
txt.chrout('\'') txt.chrout('\'')
txt.print_ub(y) txt.print_ub(y)
txt.chrout(' ') txt.spc()
txt.chrout('#') txt.chrout('#')
txt.print_ub(number) txt.print_ub(number)
txt.print("\nEconomy: ") txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet8 {
if species_is_alien { if species_is_alien {
if species_size < len(species_sizes) { if species_size < len(species_sizes) {
txt.print(species_sizes[species_size]) txt.print(species_sizes[species_size])
txt.chrout(' ') txt.spc()
} }
if species_color < len(species_colors) { if species_color < len(species_colors) {
txt.print(species_colors[species_color]) txt.print(species_colors[species_color])
txt.chrout(' ') txt.spc()
} }
if species_look < len(species_looks) { if species_look < len(species_looks) {
txt.print(species_looks[species_look]) txt.print(species_looks[species_look])
txt.chrout(' ') txt.spc()
} }
if species_kind < len(species_kinds) { if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind]) txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util8 {
sub print_right(ubyte width, uword st) { sub print_right(ubyte width, uword st) {
repeat width - string.length(st) { repeat width - string.length(st) {
txt.chrout(' ') txt.spc()
} }
txt.print(st) txt.print(st)
} }

View File

@ -472,7 +472,7 @@ galaxy9 {
txt.chrout('*') txt.chrout('*')
else else
txt.chrout('-') txt.chrout('-')
txt.chrout(' ') txt.spc()
planet9.name = make_current_planet9_name() planet9.name = make_current_planet9_name()
planet9.display(true) planet9.display(true)
txt.print(" (") txt.print(" (")
@ -843,9 +843,9 @@ planet9 {
print_name_uppercase() print_name_uppercase()
txt.print(" TL:") txt.print(" TL:")
txt.print_ub(techlevel+1) txt.print_ub(techlevel+1)
txt.chrout(' ') txt.spc()
txt.print(econnames[economy]) txt.print(econnames[economy])
txt.chrout(' ') txt.spc()
txt.print(govnames[govtype]) txt.print(govnames[govtype])
} else { } else {
txt.print("\n\nSystem: ") txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet9 {
txt.print_ub(x) txt.print_ub(x)
txt.chrout('\'') txt.chrout('\'')
txt.print_ub(y) txt.print_ub(y)
txt.chrout(' ') txt.spc()
txt.chrout('#') txt.chrout('#')
txt.print_ub(number) txt.print_ub(number)
txt.print("\nEconomy: ") txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet9 {
if species_is_alien { if species_is_alien {
if species_size < len(species_sizes) { if species_size < len(species_sizes) {
txt.print(species_sizes[species_size]) txt.print(species_sizes[species_size])
txt.chrout(' ') txt.spc()
} }
if species_color < len(species_colors) { if species_color < len(species_colors) {
txt.print(species_colors[species_color]) txt.print(species_colors[species_color])
txt.chrout(' ') txt.spc()
} }
if species_look < len(species_looks) { if species_look < len(species_looks) {
txt.print(species_looks[species_look]) txt.print(species_looks[species_look])
txt.chrout(' ') txt.spc()
} }
if species_kind < len(species_kinds) { if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind]) txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util9 {
sub print_right(ubyte width, uword st) { sub print_right(ubyte width, uword st) {
repeat width - string.length(st) { repeat width - string.length(st) {
txt.chrout(' ') txt.spc()
} }
txt.print(st) txt.print(st)
} }

View File

@ -12,18 +12,22 @@
main { main {
sub start() { sub start() {
txt.print("\n65c02 file based assembler.\n") txt.print("\n65c02 file based assembler.\n\nfilename or enter for interactive: ")
; user_input() str filename = "?" * 20
file_input() if txt.input_chars(filename)
file_input(filename)
else
user_input()
; test_stack.test() test_stack.test()
} }
sub user_input() { sub user_input() {
txt.lowercase() txt.lowercase()
parser.print_emit_bytes = true parser.print_emit_bytes = true
txt.print("Empty line to stop.\n") parser.program_counter = $4000
txt.print("\nEmpty line to stop.\n")
repeat { repeat {
ubyte input_length = 0 ubyte input_length = 0
txt.chrout('A') txt.chrout('A')
@ -42,55 +46,67 @@ main {
if not parser.process_line() if not parser.process_line()
break break
} }
parser.done()
} }
sub file_input() { sub file_input(uword filename) {
parser.print_emit_bytes = false parser.print_emit_bytes = false
str filename = "romdis.asm" ubyte success = false
txt.print("\nread file: ") txt.print("\nreading ")
txt.print(filename) txt.print(filename)
txt.nl() txt.spc()
if diskio.f_open(8, filename) { if diskio.f_open(8, filename) {
c64.SETTIM(0,0,0) c64.SETTIM(0,0,0)
uword line=0 uword line=0
repeat { repeat {
if diskio.f_readline(parser.input_line) { void diskio.f_readline(parser.input_line)
line++ line++
if not lsb(line)
txt.chrout('.')
if not parser.process_line() { if not lsb(line)
txt.print("\nerror. last line was ") txt.chrout('.')
txt.print_uw(line)
txt.chrout(':') if not parser.process_line() {
txt.print(parser.word_addrs[0]) txt.print("\nerror. last line was ")
txt.chrout(' ') txt.print_uw(line)
txt.print(": ")
txt.print(parser.word_addrs[0])
if parser.word_addrs[1] {
txt.spc()
txt.print(parser.word_addrs[1]) txt.print(parser.word_addrs[1])
txt.chrout(' ') }
if parser.word_addrs[2] {
txt.spc()
txt.print(parser.word_addrs[2]) txt.print(parser.word_addrs[2])
txt.nl()
break
} }
if c64.READST() txt.nl()
break
if c64.STOP2() {
txt.print("?break\n")
break
}
} else
break break
}
if c64.READST() {
success = c64.READST()&64==64 ; end of file?
break
}
if c64.STOP2() {
txt.print("?break\n")
break
}
} }
diskio.f_close() diskio.f_close()
parser.done()
print_summary(line) if success
print_summary(line, parser.pc_min, parser.pc_max)
} else {
txt.print(diskio.status(8))
} }
} }
sub print_summary(uword lines) { sub print_summary(uword lines, uword start_address, uword end_address) {
txt.print("\n\nfinal address: ") txt.print("\n\nstart address: ")
txt.print_uwhex(parser.program_counter, 1) txt.print_uwhex(start_address, 1)
txt.print("\n end address: ")
txt.print_uwhex(end_address, 1)
txt.print("\n lines: ") txt.print("\n lines: ")
txt.print_uw(lines) txt.print_uw(lines)
@ -115,8 +131,10 @@ parser {
str input_line = "?" * 160 str input_line = "?" * 160
uword[3] word_addrs uword[3] word_addrs
uword program_counter = $4000 uword program_counter = $ffff
ubyte print_emit_bytes = true ubyte print_emit_bytes
uword pc_min = $ffff
uword pc_max = $0000
sub process_line() -> ubyte { sub process_line() -> ubyte {
string.lower(input_line) string.lower(input_line)
@ -131,6 +149,11 @@ parser {
return false return false
} }
sub done() {
if program_counter>pc_max
pc_max = program_counter
}
sub do_assign() -> ubyte { sub do_assign() -> ubyte {
; target is in word_addrs[0], value is in word_addrs[2] ('=' is in word_addrs[1]) ; target is in word_addrs[0], value is in word_addrs[2] ('=' is in word_addrs[1])
if not word_addrs[2] { if not word_addrs[2] {
@ -152,6 +175,10 @@ parser {
txt.print("\n* = ") txt.print("\n* = ")
txt.print_uwhex(program_counter, true) txt.print_uwhex(program_counter, true)
txt.nl() txt.nl()
if program_counter<pc_min
pc_min = program_counter
if program_counter>pc_max
pc_max = program_counter
} else { } else {
symbols.setvalue(word_addrs[0], cx16.r15) symbols.setvalue(word_addrs[0], cx16.r15)
} }
@ -275,7 +302,7 @@ parser {
ubyte num_operand_bytes = operand_size[addr_mode] ubyte num_operand_bytes = operand_size[addr_mode]
if print_emit_bytes { if print_emit_bytes {
txt.chrout(' ') txt.spc()
txt.print_uwhex(program_counter, 1) txt.print_uwhex(program_counter, 1)
txt.print(" ") txt.print(" ")
} }
@ -406,7 +433,7 @@ parser {
return false return false
} }
if print_emit_bytes { if print_emit_bytes {
txt.chrout(' ') txt.spc()
txt.print_uwhex(program_counter, 1) txt.print_uwhex(program_counter, 1)
txt.print(" ") txt.print(" ")
} }
@ -489,7 +516,7 @@ _is_2_entry
if print_emit_bytes { if print_emit_bytes {
txt.print_ubhex(value, 0) txt.print_ubhex(value, 0)
txt.chrout(' ') txt.spc()
} }
} }

View File

@ -34,7 +34,7 @@ main {
iter++ iter++
} }
txt.color2(1, max_iter-iter) txt.color2(1, max_iter-iter)
txt.chrout(' ') txt.spc()
} }
txt.nl() txt.nl()
} }

View File

@ -7,7 +7,28 @@ main {
sub start() { sub start() {
txt.print("hello\n") str filename="?"*40
txt.print("> ")
ubyte il = txt.input_chars(filename)
txt.print_ub(il)
txt.nl()
txt.print_ubhex(filename[0],1)
txt.print_ubhex(filename[1],1)
txt.print_ubhex(filename[2],1)
txt.nl()
txt.print(filename)
txt.nl()
txt.print("> ")
il = txt.input_chars(filename)
txt.print_ub(il)
txt.nl()
txt.print_ubhex(filename[0],1)
txt.print_ubhex(filename[1],1)
txt.print_ubhex(filename[2],1)
txt.nl()
txt.print(filename)
txt.nl()
} }
} }

View File

@ -472,7 +472,7 @@ galaxy {
txt.chrout('*') txt.chrout('*')
else else
txt.chrout('-') txt.chrout('-')
txt.chrout(' ') txt.spc()
planet.name = make_current_planet_name() planet.name = make_current_planet_name()
planet.display(true) planet.display(true)
txt.print(" (") txt.print(" (")
@ -843,9 +843,9 @@ planet {
print_name_uppercase() print_name_uppercase()
txt.print(" TL:") txt.print(" TL:")
txt.print_ub(techlevel+1) txt.print_ub(techlevel+1)
txt.chrout(' ') txt.spc()
txt.print(econnames[economy]) txt.print(econnames[economy])
txt.chrout(' ') txt.spc()
txt.print(govnames[govtype]) txt.print(govnames[govtype])
} else { } else {
txt.print("\n\nSystem: ") txt.print("\n\nSystem: ")
@ -854,7 +854,7 @@ planet {
txt.print_ub(x) txt.print_ub(x)
txt.chrout('\'') txt.chrout('\'')
txt.print_ub(y) txt.print_ub(y)
txt.chrout(' ') txt.spc()
txt.chrout('#') txt.chrout('#')
txt.print_ub(number) txt.print_ub(number)
txt.print("\nEconomy: ") txt.print("\nEconomy: ")
@ -873,15 +873,15 @@ planet {
if species_is_alien { if species_is_alien {
if species_size < len(species_sizes) { if species_size < len(species_sizes) {
txt.print(species_sizes[species_size]) txt.print(species_sizes[species_size])
txt.chrout(' ') txt.spc()
} }
if species_color < len(species_colors) { if species_color < len(species_colors) {
txt.print(species_colors[species_color]) txt.print(species_colors[species_color])
txt.chrout(' ') txt.spc()
} }
if species_look < len(species_looks) { if species_look < len(species_looks) {
txt.print(species_looks[species_look]) txt.print(species_looks[species_look])
txt.chrout(' ') txt.spc()
} }
if species_kind < len(species_kinds) { if species_kind < len(species_kinds) {
txt.print(species_kinds[species_kind]) txt.print(species_kinds[species_kind])
@ -946,7 +946,7 @@ util {
sub print_right(ubyte width, uword s) { sub print_right(ubyte width, uword s) {
repeat width - string.length(s) { repeat width - string.length(s) {
txt.chrout(' ') txt.spc()
} }
txt.print(s) txt.print(s)
} }