Jump to content

rje

Members
  • Posts

    1079
  • Joined

  • Last visited

  • Days Won

    34

Everything posted by rje

  1. I suffer from premature optimization. I'm continually delayed when thinking about data storage for my Traveller-Trader game. I've done and re-done the same structure many, many, many times, compressing some data while leaving other data alone, thinking about what's easy to use versus what representation reduces wasted memory. First, I'll show you the uncompressed, raw data. Then I'll show you where I've been taking it. The unit of data is the Universal World Profile, which actually includes some star system information, as well. It is data sufficient to run the game, and to add a bit of useful in-game descriptive color. It looks more or less like this: [Regina, A,788899,12, N,S, Ag Ri Cp Sa, G, 138, D, Im, G0 V, M0 D] Now here's one form of the record I devise for these. The map is typically a 50% utilized 8x10 sparse matrix; I like to store the "empty" locations, because just because there's no star doesn't mean nothing's there. In other words, I can hide objects there. $00-0F "Regina" is the name. $10 "A" is the starport code from [A,B,C,D,E,X]. $11-$13 788899 are nybbles representing world characteristics. $14 "12" is the tech level [0-34]. "N,S" are up to two bases from [N,S,D,W, and a few others]. I typically combine them with the starport into a one-byte index. $15-$16 "Ag Ri Cp Sa" are trade comments. I pack these into bitfields across two bytes. "G" is the trade safety rating of [Green, Amber, Red]. I usually pack it with the trade comments. $17 "13" are digit codes for - number of planetoid belts (1), - number of gas giants (3), - and number of other worlds (8) in the system. $18 "D" is the highest ranking noble present. $19 "Im" is a code for the empire this world belongs to. $1A-$1F "G0 V" and "M0 D" are the two stars in the system. These fit nicely into six bytes to store up to three stars. A 32 byte record is very tidy. With a 256 byte header the subsector map fits in 2816 bytes. When I need to read in four of these, I'm only reading 11K. On the other hand, it's a tight space. I was also thinking about a 48 byte record size, which would make the subsector map exactly 4K in size. Reading four of those in would take 16K... not much more than 11K. X16 Considerations Either way, if I read in four subsector maps, I'd be using two RAM banks. Therefore it seems better to go for the larger record size and have a little extra wasted space. Anyone have suggestions? Even if it's "STOP WORRYING ABOUT IT".
  2. I suffer from premature optimization. I'm continually delayed when thinking about data storage for my Traveller-Trader game. I've done and re-done the same structure many, many, many times, compressing some data while leaving other data alone, thinking about what's easy to use versus what representation reduces wasted memory. First, I'll show you the uncompressed, raw data. Then I'll show you where I've been taking it. The unit of data is the Universal World Profile, which actually includes some star system information, as well. It is data sufficient to run the game, and to add a bit of useful in-game descriptive color. It looks more or less like this: [03,10, Regina, A,788899,12, N,S, Ag Ri Cp Sa, G, 138, D, Im, G0 V, M0 D] Now here's one form of the record I devise for these. The map is typically a 50% utilized 8x10 sparse matrix; I like to store the "empty" locations, because just because there's no star doesn't mean nothing's there. In other words, I can hide objects there. $00-0F "Regina" is the name, and I allow 16 bytes for the name. $10 "A" is the starport code, with a range of [A,B,C,D,E,X]. $11-$13 788899 are 4-bit values representing world characteristics. I store them in 3 bytes. $14 "12" is the tech level, with a range from 0 to 34. "N,S" are bases. System may have up to 2 of these from a restricted set of codes. I typically combine them with the starport into a one-byte index. $15-$16 "Ag Ri Cp Sa" are trade comments. I pack these into bitfields across two bytes. "G" is the trade safety rating, from the range [Green, Amber, Red]. I usually pack it with the trade comments. $17 "13" are digit codes for number of planetoid belts (1), number of gas giants (3), and number of other worlds (8) in the system. I typically reduce these into one byte. $18 "D" is the highest ranking nobility present, and store it in one byte. $19 "Im" is a code for the empire this world belongs to ("Imperium" in this case). I store the two characters as is. $1A-$1F "G0 V" and "M0 D" are the two stars in the system. These fit nicely into six bytes to store up to three stars. A 32 byte record is very tidy. With a 256 byte header the subsector map fits in 2816 bytes. When I need to read in four of these, I'm only reading 11K. On the other hand, it's a tight space. I was also thinking about a 48 byte record size, which would make the subsector map exactly 4K in size. Reading four of those in would take 16K... not much more than 11K. X16 Considerations Either way, if I read in four subsector maps, I'd be using two RAM banks. Therefore it seems better to go for the larger record size and have a little extra wasted space. Anyone have suggestions? Even if it's "STOP WORRYING ABOUT IT".
  3. Once you get the feel of it, and get a cheat-sheet, you'll find the PETSCII graphics could be useful for defining the screen panels. More pretty than rows of ========== and ************.
  4. rje

    WASD Keyboard

    An update on the WASD keyboard: I love it, and I didn't expect to. For 17 years I've loved my Topre-switched "Happy Hacker II" keyboard... and I still love its layout. But then I bought the WASD this year, and used it as my primary keyboard, WFH and home use. The Happy Hacker II is my backup, plugged into the same computer, under the auxiliary monitor. It took maybe a month to get used to the feel, and now I prefer it. Now, the Topre keys feel mushy, whereas before I didn't notice. I increasingly prefer the crisp precision of the mechanical switches now. I am officially spoiled. I think that's a good thing -- Kickstarter is okay, but if you don't need it, then don't use it.
  5. Welcome, fellow Texan! I've also been enjoying anew the frustration of BASIC! You'll find this forum a great place for your questions.
  6. I'm on cc65, and VS Code is what I use at work -- I should use it @ home as well, instead of vi.
  7. Back to RETROTrek. These retro space games need a purpose. As I recall, the Trek games I played way back when involved hunting down and (ahem) neutralizing enemy ships -- cleaning out a region of space. Starbases would be available for repairs, reloading, perhaps for refitting, or whatnot. Is that RETROTrek's mission?
  8. Because it's easy, I implemented long variables in my pre-processor. So I pre-declare with longvar /my_long_var_name$ ml$ And the pre-processor keeps two maps (in both directions) and complains if something gets stomped on. Of course, if I don't pre-declare a short variable, I can still stomp on it all day long.
  9. So when I type :DOTS (N-) 0 ?DO [CHAR] . EMIT LOOP; It responds with :DOTS(N-) ? :DOTS. ? I think it doesn't understand me. Do I need spaces in different places? AH I SEE. Yes, I needed a space between LOOP and ; .. everywhere really. This worked: : DOTS ( N - ) 0 ?DO [CHAR] . EMIT LOOP ; 25 DOTS
  10. So maybe I should ask... is FORTH good for writing things like BASIC interpreters?
  11. Thinking a little about it, it seems that WHILE can be modeled after BASIC 2.0's FOR statement, right? Because the FOR has an embedded test for stopping the loop. So it's kind of like a WHILE. Or, put another way, the two share some common logic patterns, if not actual code.
  12. Just out of curiosity, what sort of pain would be involved in adding a major syntactic feature like WHILE? I understand that a WHILE is little more than W_LABEL: IF expr GOTO W_CONTINUE GOTO W_DONE W_CONTINUE: ...do stuff.. GOTO W_LABEL W_DONE: ...but that's not trivial, injecting a new thing into BASIC 2.0. I also understand that C's FOR construct is just an initial condition and a WHILE with a "last" statement in the loop. F_BEGIN: <initialization step> F_WHILE: IF <test step> GOTO F_CONTINUE GOTO F_DONE F_CONTINUE: ...do stuff.. <last step> GOTO F_WHILE F_DONE
  13. No kidding. They guy's breadboards are immaculate and ordered. Amazing.
  14. It's committed to Commodore BASIC, forked and modified from version 2.0. It can have many improvements, such as better garbage collection (stolen from BASIC 4.0). Michael's already added drawing commands, a feature-rich set of "DOS" commands, and prefixes for hexadecimal($dc) and binary numbers(%11011100). It can have a MOD infix (needed!). It could conceivably have improvements from Simon's BASIC, or from Compute! magazine's SuperBASIC, or any number of alterations of Commodore BASIC. Heck, maybe it could even have native integer operations. But unless someone is going to dive into the interpreter and modify it for long variables, I doubt it's going to have that. Same goes for some modern control flow syntax. A tool could potentially help here too. I've thought about this one: my raw listing could have long variable names mapped to valid, short ones. The easiest way to do that would to have actual data dictionary entries that looked like this in the raw source: var mylongvarname$ ml$ Every time the translator would find one of these, it would check its hashtable to make sure the long variable and short variable aren't already declared -- and would die if they were. Otherwise, it would create new entries, and replace the long variable name with the short one in the transpiled BASIC. This would force me, ahead of time, to declare the variable mapping, and force me to change the mapping when there's a collision. Hmmm. The more I think about it, the more I like it.
  15. rje

    WASD Keyboard

    Oh I had serious, painful sticker shock, and I don't think about it. I funneled profits from my Kickstarter project to buy it.
  16. And the two-letter variable limitation really causes a problem for long BASIC programs, when I start to lose track of my variables, because I don't have a separate document with a dictionary of variables I'm using and where they're used, etc.
  17. I got a C in 8086 assembly (it was a four credit course! ouch!), a million years ago, but that doesn't stop me from writing assembly when I think I can get away with it. 6502 is easier anyway. For me though it's a matter of necessity: I won't write it unless I have significant runtime delays I need to seriously reduce. Or if I can do something useful in 256 bytes or less. And I do work high level in my real job. As in, React, and Java. And I write Perl for fun. Actually, I wrote Perl utilities to get around the limitations of BASIC 2.0... including a filter that lets me code with labels, no line numbers, and combines multiple source files (all of which is EXTREMELY helpful), and even a thing that simulates simple data structures (I don't use the latter -- it's really hacky).
  18. That's it!! Thank you. I'm going to write that down... Hey where is that documented?
  19. RND() is something I learned only in the last several years. And... it's well documented in the C64 wiki you quoted (yeah, I think that's a good reference!). A negative number seeds the PRNG. A positive number returns the next random number. And a zero... just doesn't work well. So you want to seed it with TI, the system timestamp. So, negative TI. But, you want a human element to effectively randomize WHEN that seeding happens... hence "press any key to continue". I note that this also works really well: ... INPUT "YOUR NAME"; NA$ R=RND(-TI) ... ...that way, you've also gathered info by which to record his score for the leaderboard...
  20. With my lovely WASD X16 keyboard and the lovely r38 emulator, how do I insert spaces into a line (e.g. of BASIC)? I read how to do it just a couple weeks ago, and now I've forgotten.
  21. rje

    WASD Keyboard

    When I bought my X16 keyboard, I wanted it *now*. Though I wanted MX Brown or MX Red, I got an MX Clear. And I love it. But I'm sure I'd love the other ones too.
  22. And in case you don't know about the Commodore's random number generator, the time to seed it is after that key has been pressed. And you'll want to do it like this: R = RND(-TI) :REM SEED PRNG I'm one of the guys doing a space retro clone game thingy. My target is Traveller, rather than Trek, and I've got a couple of early programs in the repo, but with r38 I can start on the Magnum Opus.
  23. I just realized that this is more powerful and useful than I thought: THE FUZZY PROBLEM One of the games I'm writing uses data ... this data is already established, so its nature and content are understood. All I have to do is get it on the SD card in a way that the X16 likes. I expect to have around 125 subdirectories, each with 16 files give or take. Each file is smaller than 8K in size. THE IMMEDIATE MODE SOLUTION "Immediate" mode can be used to create one subdirectory and its 16 files in one shot. Or maybe more... since this is immediate mode, I can make it a "stream" of small programs, each of which creates a file. Or, even better, one program that creates a file, and immediate data that loads in the data to write AND run that program, then load in another set of data, run the program, and repeat 2000 times.
  24. On the C64, VIC-20, and PET -- and probably on the other machines as well -- you could POKE straight to screen memory. Which I never did, because I didn't like it, but it was available. I guess we can VPOKE to VERA. There is SPC(X), which might be similar to HTAB. You might also not know about the Commodore cursor character codes. It ain't pretty, but sometimes they're useful. That would be one way of simulating a VTAB... poorly. Tom shared one of those hacks recently: VV$="{down}{down}{down}{down}... (about 25 times)" ({down} is the printable representation of cursor-down... ...which isn't printable on ASCII) Then: ? "{home}" LEFT$(VV$,Y) Gets you to the Y-th row. Hmm, we could probably do a DEF FN that simulates a VTAB. Now if you don't want to trigger BASIC 2.0's Maladjusted Garbage Collector, you'll need to be more creative. Okay, FINE, I'll put a feature request in github for something like BASIC 4.0 string handling. But it doesn't sound easy. ...and I see that Michael has already put this on the request list. Back in July: https://github.com/commanderx16/x16-rom/issues/155
×
×
  • Create New...

Important Information

Please review our Terms of Use