From 6ff5470cf1a3f896d2e3d2bd1d454aa5f5e8b133 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 9 Oct 2020 21:01:06 +0200 Subject: [PATCH] txtelite --- examples/test.p8 | 18 +++++---------- examples/textelite.p8 | 52 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 18 deletions(-) diff --git a/examples/test.p8 b/examples/test.p8 index 1f8cd60cf..883d70613 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -5,25 +5,17 @@ main { + str name + + struct Planet { ubyte x ubyte y - str name + str name = "????????" } + sub start() { - Planet p1 - - txt.print(planet_name) - txt.chrout('\n') - - planet_name = "saturn" - - txt.print(planet_name) - txt.chrout('\n') - txt.print_ub(len(planet_name)) - txt.chrout('\n') - txt.print_ub(strlen(planet_name)) txt.chrout('\n') } diff --git a/examples/textelite.p8 b/examples/textelite.p8 index 654c40d6a..f6e752b52 100644 --- a/examples/textelite.p8 +++ b/examples/textelite.p8 @@ -11,11 +11,7 @@ main { repeat 5 { planet.set_seed(rndw(), rndw()) planet.name = planet.random_name() - txt.print("System: ") - txt.print(planet.name) - txt.chrout('\n') - txt.print(planet.soup()) - txt.chrout('\n') + planet.display(false) txt.chrout('\n') } } @@ -40,6 +36,10 @@ _saveX .byte 0 planet { %option force_output + str[] govnames = ["Anarchy", "Feudal", "Multi-gov", "Dictatorship", "Communist", "Confederacy", "Democracy", "Corporate State"] + str[] econnames = ["Rich Industrial", "Average Industrial", "Poor Industrial", "Mainly Industrial", + "Mainly Agricultural", "Rich Agricultural", "Average Agricultural", "Poor Agricultural"] + str[] words81 = ["fabled", "notable", "well known", "famous", "noted"] str[] words82 = ["very", "mildly", "most", "reasonably", ""] str[] words83 = ["ancient", "\x95", "great", "vast", "pink"] @@ -89,6 +89,15 @@ planet { ubyte[4] goatsoup_seed = [0, 0, 0, 0] str name = " " ; 8 max + ubyte x + ubyte y + ubyte economy + ubyte govtype + ubyte techlevel + ubyte population + ubyte productivity + ubyte radius + ; todo: species sub set_seed(uword s1, uword s2) { goatsoup_seed[0] = lsb(s1) @@ -226,6 +235,39 @@ planet { } } + sub display(ubyte compressed) { + if compressed { + txt.print(name) + txt.print(" TL:") + txt.print_ub(techlevel+1) + txt.chrout(' ') + txt.print(econnames[economy]) + txt.chrout(' ') + txt.print(govnames[govtype]) + } else { + txt.print("\n\nSystem: ") + txt.print(name) + txt.print("\nPosition: ") + txt.print_ub(x) + txt.chrout(',') + txt.print_ub(y) + txt.print("\nEconomy: ") + txt.print(econnames[economy]) + txt.print("\nGovernment: ") + txt.print(govnames[govtype]) + txt.print("\nTech Level: ") + txt.print_ub(techlevel+1) + txt.print("\nTurnover: ") + txt.print_ub(productivity) + txt.print("\nRadius:") + txt.print_ub(radius) + txt.print("\nPopulation: ") + txt.print_ub(population >> 3) + txt.print(" Billion\n") + txt.print(soup()) + txt.chrout('\n') + } + } asmsub getword(ubyte list @A, ubyte wordidx @Y) -> uword @AY { %asm {{