If you're geeking out to the question, then you're in the right place.
Because I write code for fun, and because I do Traveller for fun, and because I think 8-bit computers are fun, I find myself writing Traveller code for a new-retro 8 bit platform. The hardware isn't important in this case.
Here is what's important:
(1) Data is loaded from an SD card. This means that there's actually plenty of room for Charted Space.
(2) The SD's file system is, I believe, FAT 32, so there is an upper limit on number of files per directory, and it's less than 2,000. It's safest to assume that the solution should only have a couple hundred files -- for example, 1 file per sector, 125 sectors.
(3) Assume we can't SEEK into a file. It might be doable, but I haven't been able to do it yet.
(4) Data is loaded into banked RAM. There is 512K available.
(5) Assume we can calculate trade codes on the fly.
(6) Assume we can z-encode the world name, if we really had to save a couple bytes per system.
***
Anyway back to the thing. I'm using Charted Space to run a Trader sim. Right now, that means the Marches plus Deneb, and that's it.
The current version is here: https://www.commanderx16.com/forum/index.php?/files/file/102-traveller-trader-wip/
But I think I can do better. I think I can access all of Charted Space in an elegant way. I think extraneous stuff can be eliminated, because the game itself won't be able to leverage all of that data.
The storage will be binary. The way we do this is to define the structure -- or structures -- that holds all relevant data. Then we fit it into files of an appropriate size -- whatever that is -- so that it's "easy" to find the data you want.
At a bare minimum, I think I'd need (most of) the world name, its UWP, its bases, un-calculatable trade codes, and Belt and GG presence.
Because I write code for fun, and because I do Traveller for fun, and because I think 8-bit computers are fun, I find myself writing Traveller code for a new-retro 8 bit platform. The hardware isn't important in this case.
Here is what's important:
(1) Data is loaded from an SD card. This means that there's actually plenty of room for Charted Space.
(2) The SD's file system is, I believe, FAT 32, so there is an upper limit on number of files per directory, and it's less than 2,000. It's safest to assume that the solution should only have a couple hundred files -- for example, 1 file per sector, 125 sectors.
(3) Assume we can't SEEK into a file. It might be doable, but I haven't been able to do it yet.
(4) Data is loaded into banked RAM. There is 512K available.
(5) Assume we can calculate trade codes on the fly.
(6) Assume we can z-encode the world name, if we really had to save a couple bytes per system.
***
Anyway back to the thing. I'm using Charted Space to run a Trader sim. Right now, that means the Marches plus Deneb, and that's it.
The current version is here: https://www.commanderx16.com/forum/index.php?/files/file/102-traveller-trader-wip/
But I think I can do better. I think I can access all of Charted Space in an elegant way. I think extraneous stuff can be eliminated, because the game itself won't be able to leverage all of that data.
The storage will be binary. The way we do this is to define the structure -- or structures -- that holds all relevant data. Then we fit it into files of an appropriate size -- whatever that is -- so that it's "easy" to find the data you want.
At a bare minimum, I think I'd need (most of) the world name, its UWP, its bases, un-calculatable trade codes, and Belt and GG presence.
Code:
typedef struct {
char abbreviation[5]; // four chars + null
unsigned char allegiance[8];
unsigned int x;
unsigned int y;
unsigned char moreStuff[3];
UWPline *restOfBank; // 430 of these in the rest of the bank
// Then, 430 each in the next 2 banks. Max = 1280 UWPs
} SectorHeader;
typedef struct {
unsigned int zname[6]; // z-text can store ~15 chars
int belt : 1; // belts present?
int gg : 1; // ggs present?
int starport_and_bases_and_zone : 6; // multiplexed list
int siz: 4; // 0-15
int atm: 4; // 0-15
int hyd: 4; // 0-15
int pop: 4; // 0-15
int gov: 4; // 0-15
int law: 4; // 0-15
int tl: 5; // 0-31
int allegiance_index : 3; // 8 allegiances listed in sector header
int primary : 4; // multiplexed
int companion : 4; // also multiplexed
int companion_location : 2; // 0=binary, 1=near, 2=far
int an : 1; // ancients
int cp : 1; // capital
int mr : 1; // military
int re : 1; // reserve
int rs : 1; // research
int sa : 1; // satellite
} UWPline; // 19 bytes
Last edited: