textelite

This commit is contained in:
Irmen de Jong 2020-10-09 22:47:42 +02:00
parent 8bb3b3be20
commit 94c30fc21e
2 changed files with 74 additions and 26 deletions

View File

@ -5,17 +5,32 @@
main { main {
str name
struct Planet {
ubyte x
ubyte y
str name = "????????"
}
sub start() { sub start() {
repeat 0 {
txt.print("repeat0\n")
}
repeat 2 {
txt.print("repeat2\n")
}
ubyte u=3
repeat u-1 {
txt.print("repeat u=2\n")
}
u=2
repeat u-1 {
txt.print("repeat u=1\n")
}
u=1
repeat u-1 {
txt.print("repeat u=0\n")
}
txt.chrout('\n') txt.chrout('\n')
} }

View File

@ -12,9 +12,8 @@ main {
txt.print("\nstart!!!!") txt.print("\nstart!!!!")
galaxy.debug_seed() galaxy.debug_seed()
;lgalaxy.generate_planet(galaxy.numforLave) galaxy.generate_planet(galaxy.numforLave)
galaxy.generate_planet(0) planet.display(false)
planet.display(true)
; repeat 5 { ; repeat 5 {
; planet.set_seed(rndw(), rndw()) ; planet.set_seed(rndw(), rndw())
@ -64,7 +63,7 @@ galaxy {
seed[1] = base1 seed[1] = base1
seed[2] = base2 seed[2] = base2
repeat galaxynum-1 { ; TODO fix repeat(0) repeat galaxynum-1 {
nextgalaxy() nextgalaxy()
} }
; planets are now created procedurally on the fly. ; planets are now created procedurally on the fly.
@ -130,17 +129,45 @@ galaxy {
txt.print_ub(pair4) txt.print_ub(pair4)
txt.chrout('\n') txt.chrout('\n')
ubyte longnameflag = lsb(seed[0]) & 64 ubyte ni = 0
; namechars = [self.pairs[pair1], if pairs[pair1] != '.' {
; self.pairs[pair1 + 1], planet.name[ni] = pairs[pair1]
; self.pairs[pair2], ni++
; self.pairs[pair2 + 1], }
; self.pairs[pair3], if pairs[pair1+1] != '.' {
; self.pairs[pair3 + 1]] planet.name[ni] = pairs[pair1+1]
; if longnameflag: # bit 6 of ORIGINAL w0 flags a four-pair name ni++
; namechars.append(self.pairs[pair4]) }
; namechars.append(self.pairs[pair4 + 1]) if pairs[pair2] != '.' {
; thissys.name = "".join(namechars).replace(".", "") planet.name[ni] = pairs[pair2]
ni++
}
if pairs[pair2+1] != '.' {
planet.name[ni] = pairs[pair2+1]
ni++
}
if pairs[pair3] != '.' {
planet.name[ni] = pairs[pair3]
ni++
}
if pairs[pair3+1] != '.' {
planet.name[ni] = pairs[pair1+3]
ni++
}
if lsb(seed[0]) & 64 {
; long name
if pairs[pair4] != '.' {
planet.name[ni] = pairs[pair4]
ni++
}
if pairs[pair4+1] != '.' {
planet.name[ni] = pairs[pair4+1]
ni++
}
}
planet.name[ni] = 0
} }
sub tweakseed() { sub tweakseed() {
@ -356,7 +383,7 @@ planet {
sub display(ubyte compressed) { sub display(ubyte compressed) {
if compressed { if compressed {
txt.print(name) print_name_uppercase()
txt.print(" TL:") txt.print(" TL:")
txt.print_ub(techlevel+1) txt.print_ub(techlevel+1)
txt.chrout(' ') txt.chrout(' ')
@ -365,7 +392,7 @@ planet {
txt.print(govnames[govtype]) txt.print(govnames[govtype])
} else { } else {
txt.print("\n\nSystem: ") txt.print("\n\nSystem: ")
txt.print(name) print_name_uppercase()
txt.print("\nPosition: ") txt.print("\nPosition: ")
txt.print_ub(x) txt.print_ub(x)
txt.chrout(',') txt.chrout(',')
@ -388,6 +415,12 @@ planet {
} }
} }
sub print_name_uppercase() {
ubyte c
for c in name
txt.chrout(c | 32)
}
asmsub getword(ubyte list @A, ubyte wordidx @Y) -> uword @AY { asmsub getword(ubyte list @A, ubyte wordidx @Y) -> uword @AY {
%asm {{ %asm {{
sty P8ZP_SCRATCH_REG sty P8ZP_SCRATCH_REG