From 94c30fc21ee95a6c98cb7ed42dd8629243a7291e Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 9 Oct 2020 22:47:42 +0200 Subject: [PATCH] textelite --- examples/test.p8 | 33 +++++++++++++++------ examples/textelite.p8 | 67 ++++++++++++++++++++++++++++++++----------- 2 files changed, 74 insertions(+), 26 deletions(-) diff --git a/examples/test.p8 b/examples/test.p8 index 883d70613..d64a92287 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -5,17 +5,32 @@ main { - str name - - - struct Planet { - ubyte x - ubyte y - str name = "????????" - } - 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') } diff --git a/examples/textelite.p8 b/examples/textelite.p8 index 3aaf4805f..5ca70b27f 100644 --- a/examples/textelite.p8 +++ b/examples/textelite.p8 @@ -12,9 +12,8 @@ main { txt.print("\nstart!!!!") galaxy.debug_seed() - ;lgalaxy.generate_planet(galaxy.numforLave) - galaxy.generate_planet(0) - planet.display(true) + galaxy.generate_planet(galaxy.numforLave) + planet.display(false) ; repeat 5 { ; planet.set_seed(rndw(), rndw()) @@ -64,7 +63,7 @@ galaxy { seed[1] = base1 seed[2] = base2 - repeat galaxynum-1 { ; TODO fix repeat(0) + repeat galaxynum-1 { nextgalaxy() } ; planets are now created procedurally on the fly. @@ -130,17 +129,45 @@ galaxy { txt.print_ub(pair4) txt.chrout('\n') - ubyte longnameflag = lsb(seed[0]) & 64 -; namechars = [self.pairs[pair1], -; self.pairs[pair1 + 1], -; self.pairs[pair2], -; self.pairs[pair2 + 1], -; self.pairs[pair3], -; self.pairs[pair3 + 1]] -; if longnameflag: # bit 6 of ORIGINAL w0 flags a four-pair name -; namechars.append(self.pairs[pair4]) -; namechars.append(self.pairs[pair4 + 1]) -; thissys.name = "".join(namechars).replace(".", "") + ubyte ni = 0 + if pairs[pair1] != '.' { + planet.name[ni] = pairs[pair1] + ni++ + } + if pairs[pair1+1] != '.' { + planet.name[ni] = pairs[pair1+1] + ni++ + } + if pairs[pair2] != '.' { + 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() { @@ -356,7 +383,7 @@ planet { sub display(ubyte compressed) { if compressed { - txt.print(name) + print_name_uppercase() txt.print(" TL:") txt.print_ub(techlevel+1) txt.chrout(' ') @@ -365,7 +392,7 @@ planet { txt.print(govnames[govtype]) } else { txt.print("\n\nSystem: ") - txt.print(name) + print_name_uppercase() txt.print("\nPosition: ") txt.print_ub(x) 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 { %asm {{ sty P8ZP_SCRATCH_REG