Post Reply 
Prime retro-gaming: trek!
08-27-2024, 12:16 AM
Post: #1
Prime retro-gaming: trek!
I converted the 1973 trek to python to put it on the Prime: :-D

https://udel.edu/~mm/hp/trek/

Not exactly what a calculator is intended for, I suppose, but fun. And a question, too, is there a way to use fixed width font on the Prime? The old game assumes it, and I had to hack at it a bit to somewhat line up things with variable width font. Printing a tab (\t) character results in a rectangle and not an actual tab, which would be an easy solution to lining up text.

Thanks,
Mike
Visit this user's website Find all posts by this user
Quote this message in a reply
08-28-2024, 07:57 PM (This post was last modified: 08-28-2024 07:57 PM by komame.)
Post: #2
RE: Prime retro-gaming: trek!
(08-27-2024 12:16 AM)ab3ap Wrote:  I converted the 1973 trek to python to put it on the Prime: :-D

https://udel.edu/~mm/hp/trek/
A very good port of the game! Big Grin

(08-27-2024 12:16 AM)ab3ap Wrote:  Not exactly what a calculator is intended for, I suppose, but fun.
Well, the HP Prime is a real computer, and computers can be used for many different things.

(08-27-2024 12:16 AM)ab3ap Wrote:  And a question, too, is there a way to use fixed width font on the Prime? The old game assumes it, and I had to hack at it a bit to somewhat line up things with variable width font. Printing a tab (\t) character results in a rectangle and not an actual tab, which would be an easy solution to lining up text.

There is no support for monospaced fonts (for now), but you can easily create such a terminal yourself, including support for \t and custom font types. To do this, you need to use graphic commands from the hpprime module.

By the way, it would be useful to have some advanced graphics library for Python that allows efficient access to the graphic frame buffer.

As for the monospaced font terminal, I'll try to write it, and it shouldn't be too difficult (read: I'll share it soon).

All the best!

Piotr Kowalewski
Find all posts by this user
Quote this message in a reply
08-29-2024, 03:11 PM
Post: #3
RE: Prime retro-gaming: trek!
In addition to Piotr's comment, I'd like to add this teaser. Simply copy the code to the Python app. It doesn't do fancy things, but shows how things could be displayed --- the Prime is a graphing calculator after all.

Code:
import hpprime as hp
from graphic import *
bg = 0xf8f8f8 #background color 

hp.eval('print') 
hp.fillrect(0,0,0,320,240,bg,cyan)
Width = 20 
hMargin = 5; vMargin = 15
def string(arg):
    return '"' + str(arg) +'"'
    
def RGB(r,g,b):
    return (r*256+g)*256+b
    
def strip(arg): 
    return str(arg)[1:-1]

def TxtOut(t,x,y,f,c,*args):
    if len(args)>2:
       raise(SyntaxError("too many arguments"))
    if True in [isinstance(i,list) for i in t]:
       raise(TypeError("can't convert 'list' object to str implicitly")) 
    parms=(int(x),int(y),int(f),int(c))
    if len(args)>0:parms+=(int(args[0]),)
    if len(args)>1:parms+=(int(args[1]),)
    return hp.eval('TEXTOUT_P('+string(t)+','+strip(parms)+')')       

def TxtRight(t,x,y,f,c,*args):
   x -= hp.eval('TEXTSIZE('+string(t)+','+str(f)+')')[0]
   TxtOut(t,x,y,f,c,*args)

def TxtCenter(t,x,y,f,c,*args):
   x  -=  (hp.eval('TEXTSIZE('+string(t)+','+str(f)+')')[0])/2
   TxtOut(t,x,y,f,c,*args)
 
def PutSymb(Symb,x,y):
    x = hMargin+(x-1)*Width+Width/2
    y = vMargin+(y-1)*Width+Width/2
    hp.circle(0,x,y,1,bg)
    hp.pixon(0,x,y,bg)
    TxtOut(Symb,x-Width/4,y-Width/4,2,0)
     
def DrawGrid():
    hp.fillrect(0,hMargin-1,vMargin-1,Width*8+2,Width*8+2,0,bg)
    xy0=[(hMargin+x*Width+Width/2,vMargin+y*Width+Width/2) 
          for x in range(8) for y in range(8)]
    for xy in xy0:
        x,y = xy
        hp.circle(0,x,y,1,0)
        hp.pixon(0,x,y,0)
    TxtOut("Sector 8-8 in Qadrant 5-2",hMargin,0,2,0)
    
DrawGrid()

hp.eval('DRAWMENU("Course","Phaser","Torpedo","SR Scan","LR Scan","Report")')

PutSymb("E",8,8)
PutSymb("✵",5,5)
PutSymb("B",4,4)
PutSymb("K",2,6)
PutSymb("✵",1,1)
PutSymb("K",4,3)
TxtOut("Condition Yellow",200,10,3,0,200,yellow)
TxtOut("Energie: 290",200,30,3,0,200,red)


hp.eval("wait")

Hope you're addicted.

Günter
Find all posts by this user
Quote this message in a reply
08-29-2024, 04:53 PM
Post: #4
RE: Prime retro-gaming: trek!
(08-28-2024 07:57 PM)komame Wrote:  
(08-27-2024 12:16 AM)ab3ap Wrote:  I converted the 1973 trek to python to put it on the Prime: :-D
https://udel.edu/~mm/hp/trek/
A very good port of the game! Big Grin
Thank you, Piotr! My goal was to minimize change in look or game play. I had to move text next to short range scan to make it fit, and some other little things. Otherwise, it looks very much as it originally did. Smile

(08-28-2024 07:57 PM)komame Wrote:  As for the monospaced font terminal, I'll try to write it, and it shouldn't be too difficult (read: I'll share it soon).
I look forward to it, thanks!
Mike Markowski
Visit this user's website Find all posts by this user
Quote this message in a reply
08-29-2024, 04:59 PM
Post: #5
RE: Prime retro-gaming: trek!
(08-29-2024 03:11 PM)Guenter Schink Wrote:  In addition to Piotr's comment, I'd like to add this teaser.
...
Hope you're addicted.

Thanks for that, Günter, you have me thinking now... My goal originally was the 1970s look and feel for nostalgia. But it has simple internals and might be fun to put a new "face" on the game and capitalize on what the Prime can do! Smile

Mike Markowski
Visit this user's website Find all posts by this user
Quote this message in a reply
08-30-2024, 12:58 AM (This post was last modified: 08-30-2024 12:59 AM by jte.)
Post: #6
RE: Prime retro-gaming: trek!
Seeing this certainly brightened my day. Big Grin After seeing it, I had to show my daughter some other ports of trek. (I have definite memories of playing a C64 port of the game; I don't immediately remember playing it on my ZX81.)

In the past, for this sort of thing, and for other games from the 8-bit era of home computers / early consoles, I was thinking what could be nice would be to add a PPL graphics command to get a convenient / quick analog to "character graphics" of the 70s / 80s: the PPL command would take a two-dimensional array (matrix?) of character indices, a grob (of character graphics / a font / a "sprite sheet") + stride information, and a destination graphical anchor point. Running the command would blit a rectangle of the grob onto the destination for each entry in the array (the rectangle taken being determined by the character from the array and the stride information). (Of course, if the sprite sheet were a more typical font — "A" for 65 etc., a regularly spaced terminal could be drawn with one PPL command as well.)

Another possibility would be to have a grob being used for the "character framebuffer". (So a single pixel in that grob would determine the rectangle taken, rather than an integer.) A string is another possibility. (Each has advantages; perhaps they should all be allowed. A string as source would involve a slightly different rendering approach on the back end.)
Find all posts by this user
Quote this message in a reply
08-30-2024, 01:08 AM
Post: #7
RE: Prime retro-gaming: trek!
(08-29-2024 04:53 PM)ab3ap Wrote:  
(08-28-2024 07:57 PM)komame Wrote:  A very good port of the game! Big Grin
Thank you, Piotr! My goal was to minimize change in look or game play. I had to move text next to short range scan to make it fit, and some other little things. Otherwise, it looks very much as it originally did. Smile

(08-28-2024 07:57 PM)komame Wrote:  As for the monospaced font terminal, I'll try to write it, and it shouldn't be too difficult (read: I'll share it soon).
I look forward to it, thanks!
Mike Markowski

I'll second that. Me too! Big Grin

Hmmm... now I'm wanting to play trek. Thanks again, Mike, for porting & posting.
Find all posts by this user
Quote this message in a reply
08-30-2024, 08:37 AM
Post: #8
RE: Prime retro-gaming: trek!
That looks great, thanks for helping keep the Prime alive :-).
Find all posts by this user
Quote this message in a reply
08-30-2024, 08:49 PM
Post: #9
RE: Prime retro-gaming: trek!
(08-30-2024 12:58 AM)jte Wrote:  ...the PPL command would take a two-dimensional array (matrix?) of character indices, a grob (of character graphics / a font / a "sprite sheet") + stride information, and a destination graphical anchor point...
What a cool idea and probably more time consuming (to create char graphics) than difficult. How ironic, the modern lengths we'll go to to recreate that retro feel! Big Grin

Mike
Visit this user's website Find all posts by this user
Quote this message in a reply
08-30-2024, 08:59 PM
Post: #10
RE: Prime retro-gaming: trek!
(08-30-2024 08:37 AM)matalog Wrote:  That looks great, thanks for helping keep the Prime alive :-).
You're welcome, matalog, it was a fun diversion.

I also added an unadvertised 'm' (for map) command. It's updated every time you do a short or long range scan. To play on the calculator, I feel that self-contained record keeping is helpful to better enjoy the game. Or, ignore its presence for 70s experience! -Mike Markowski
Visit this user's website Find all posts by this user
Quote this message in a reply
08-30-2024, 10:34 PM (This post was last modified: 08-30-2024 10:58 PM by komame.)
Post: #11
RE: Prime retro-gaming: trek!
The beta version of the terminal is ready.

   

Most features are operational, including:

- text display with screen scrolling support (surprisingly, it works remarkably fast!)
- tab (\t) support (configurable size upon terminal creation)
- setting the cursor at any position on the screen (x,y)
- light and dark mode
- clearing the terminal
- input mode

Regarding the input mode, it currently works at a basic level, meaning it displays a prompt and allows entering text or numbers. It supports Backspace and Clear for erasing entered text. Currently, toggling the Alpha and Shift modifiers works in a somewhat limited manner, as the first press activates the modifier and the second deactivates it. There is no support yet for single-use. Of course, I intend to refine this.

While playing Trek, I realized that it would be useful to have a feature in 'input' that initially sets the Alpha and Shift modifiers according to the type of data being entered. For example, when a command is issued, the Alpha modifier should be active immediately, and when a numerical value is being entered, no modifiers should be active. This terminal has such a capability (as an optional parameter to the 'input' function).

I also plan to add support for diacritical characters and buffering so that the content of any part of the terminal can be read. I have other ideas, but more on that later...

I will prepare a short documentation and share the source code tomorrow.

(08-30-2024 12:58 AM)jte Wrote:  I have definite memories of playing a C64 port of the game [...]
In the past, for this sort of thing, and for other games from the 8-bit era of home computers / early consoles, I was thinking what could be nice would be to add a PPL graphics command to get a convenient / quick analog to "character graphics" of the 70s / 80s: the PPL command would take a two-dimensional array (matrix?) of character indices, a grob (of character graphics / a font / a "sprite sheet") + stride information, and a destination graphical anchor point. Running the command would blit a rectangle of the grob onto the destination for each entry in the array (the rectangle taken being determined by the character from the array and the stride information). (Of course, if the sprite sheet were a more typical font — "A" for 65 etc., a regularly spaced terminal could be drawn with one PPL command as well.)

I had exactly the same idea when I promised to write this terminal. I created a bitmap with a graphic presentation of each character in sequence (all in one line next to each other) and I copy rectangles depending on the given character (after converting it to its numerical value, which are then treated as indices for rightward shifting to select the correct rectangle). The font I used comes from an 8-bit Atari. That was my first computer back in the 80s...

Piotr Kowalewski
Find all posts by this user
Quote this message in a reply
08-31-2024, 08:59 PM (This post was last modified: 08-31-2024 09:38 PM by komame.)
Post: #12
RE: Prime retro-gaming: trek!
Hi, Mike!

I've adjusted your (port of) game to use my terminal (tml module).

.zip  Trek_tml.hpappdir.zip (Size: 12.02 KB / Downloads: 11)

With the current font, tml can display 30 lines of 40 characters each on the screen. However, I see that this game requires a screen with more characters per line. For now, I've added extra newline characters '\n' in some texts to make long texts look sensible. Tomorrow, I will try to apply a different font that can display 64 characters per line.

Terminal initialization looks like this:
Code:
tr = tml(dark_mode = False, tab_size = 8)
Setting dark_mode to True allows for displaying white letters on a black background.
An optional tab_size parameter defines the size of the tabulator. If not specified, the default size is set to 4. See how much this has simplified the damageRpt() function.

When issuing commands, do not press Alpha; instead, directly press the key with the appropriate letter (the Alpha modifier is automatically activated for commands). Currently, there is no display of the active modifiers' status, so it is unknown which ones are active at any given time (I plan to address this in the coming days). However, for the purposes of this game, that is entirely sufficient, as there is no need to use them since they activate automatically.

I was initially going to prepare the documentation first, but I decided that adjusting the game would be more interesting, so I tackled that first. I will share the documentation tomorrow as soon as I finish it.

The 'tml' project is still in the beta phase.

Piotr Kowalewski
Find all posts by this user
Quote this message in a reply
09-01-2024, 01:55 AM
Post: #13
RE: Prime retro-gaming: trek!
It seems that there is a bug in your port in the warp() function.
When you try to cross the edge of the galaxy, it starts displaying negative sector coordinates.
   

Piotr Kowalewski
Find all posts by this user
Quote this message in a reply
09-01-2024, 08:54 PM
Post: #14
RE: Prime retro-gaming: trek!
(08-31-2024 08:59 PM)komame Wrote:  Hi, Mike!

I've adjusted your (port of) game to use my terminal (tml module).
[...]

Thank you, Piotr, this is exciting to see! I'm unable to look at it till tomorrow, but can't wait. I also converted STTR1 - the original trek - which is a little better and has a couple more functions. However, it's short range scan is harder to read. It will also greatly benefit from your terminal and then I'll share that, too.

Thanks!
Mike
Visit this user's website Find all posts by this user
Quote this message in a reply
09-02-2024, 04:43 PM (This post was last modified: 09-02-2024 04:48 PM by komame.)
Post: #15
RE: Prime retro-gaming: trek!
This is what it looks like when using the 8x8 font (8-bit Atari style) - 40 characters in a row:
   
And this is what it looks like in dark mode when using the 5x10 font (my design), which allows for 64 characters in a row:
   


I was thinking that such a terminal offers tremendous possibilities. For instance, one could create a windowing system, something like Turbo Vision (a library from the 90s that worked with Turbo Pascal, displaying windows in text mode with the ability to scale, move, etc.). You could also make your own text editor (including a Python script editor) with options to choose the type of font, etc.

@Mike, let me know your first impression Smile
If you're using an emulator on a PC, remember not to use a physical keyboard. On the emulator, only the on-screen keyboard will work (at least for letters, as numbers should function).
It's best to use this on a physical HP Prime.

Piotr Kowalewski
Find all posts by this user
Quote this message in a reply
09-02-2024, 08:17 PM
Post: #16
RE: Prime retro-gaming: trek!
(09-02-2024 04:43 PM)komame Wrote:  This is what it looks like when using the 8x8 font (8-bit Atari style) - 40 characters in a row:

And this is what it looks like in dark mode when using the 5x10 font (my design), which allows for 64 characters in a row:

I was thinking that such a terminal offers tremendous possibilities. [...]

It's fantastic, Piotr, thanks for sharing your hard work! It really does offer many possibilities. Prime programming is not so different from 1980s programming in some ways.

Is your 5x10 font also available? It looks very nice and STTR1 is wider than trek. Hopefully, the smaller font will shrink things down enough. If not, I'll modify output to fit. I'll copy your tml changes into my debugged Trek app and share it soon. Thanks again, really nice work! Smile -Mike
Visit this user's website Find all posts by this user
Quote this message in a reply
09-02-2024, 10:36 PM (This post was last modified: 09-02-2024 10:36 PM by komame.)
Post: #17
RE: Prime retro-gaming: trek!
(09-02-2024 08:17 PM)ab3ap Wrote:  It's fantastic, Piotr, thanks for sharing your hard work!

Thanks!

When I saw the final result, it immediately reminded me of the good old days when I was programming my first games in BASIC on Atari. When I was in high school, I wrote an economic game (in C++) that took place several centuries ago. As the ruler of villages, you had to care for your subjects, farmlands, mills, defend against invaders, and at the same time multiply your wealth (without going bankrupt), despite many obstacles that fate threw your way. It was possible to play with several people (I think up to 4), including attacking each other for robbery Big Grin
This game spread throughout the whole school in the blink of an eye. Later, I graduated from that school and returned for a visit after about 3 years. I was incredibly happy when, upon entering the computer room, I saw my game on several screens! It was still there, they were still playing it. A wonderful feeling... Everything was in text mode. Unfortunately, I don't have the source code. It got lost over all these years.

(09-02-2024 08:17 PM)ab3ap Wrote:  It really does offer many possibilities. Prime programming is not so different from 1980s programming in some ways.

That's right! With the option to set the cursor anywhere on the screen using the set_cursor(x,y) method, you can even create animated games in text mode, like 'PONG' or even more complex ones like 'Breakout' or 'Labyrinth'. I've noticed that just filling the screen with text content is incredibly fast, so if you prevent the screen from scrolling, you can really get a lot out of it. Besides, scrolling the screen is also very fast, definitely faster than in the factory terminal of HP Prime, and I think it would be even faster if I used a larger font (for now I am playing with very small ones). It seems that the 'tml' module is the foundation for giving old text games and programs new life on the HP Prime Wink

(09-02-2024 08:17 PM)ab3ap Wrote:  Is your 5x10 font also available? It looks very nice and STTR1 is wider than trek. [...]

Of course, it is available, and another one is on the way, this time a bit larger. Attached you will find Trek with a slightly newer version of 'tml' (still in beta) featuring the 5x10 font.

(09-02-2024 08:17 PM)ab3ap Wrote:  Thanks again, really nice work! Smile

And thank you for the kind comments and appreciation of my work. I really am eager to develop this solution further, and I have many ideas for its development.

All the best!


Attached File(s)
.zip  Trek_tml_5x10.hpappdir.zip (Size: 12.13 KB / Downloads: 12)

Piotr Kowalewski
Find all posts by this user
Quote this message in a reply
09-03-2024, 01:08 PM
Post: #18
RE: Prime retro-gaming: trek!
(09-02-2024 10:36 PM)komame Wrote:  I was incredibly happy when, upon entering the computer room, I saw my game on several screens! It was still there, they were still playing it. A wonderful feeling... Everything was in text mode. Unfortunately, I don't have the source code. It got lost over all these years.
That's too bad, that would be great to revisit your early effort.

(09-02-2024 10:36 PM)komame Wrote:  It seems that the 'tml' module is the foundation for giving old text games and programs new life on the HP Prime Wink
It is a more generally useful piece of software than porting trek. Big Grin

(09-02-2024 08:17 PM)ab3ap Wrote:  Is your 5x10 font also available? It looks very nice and STTR1 is wider than trek. [...]
(09-02-2024 10:36 PM)komame Wrote:  Of course, it is available, and another one is on the way, this time a bit larger. Attached you will find Trek with a slightly newer version of 'tml' (still in beta) featuring the 5x10 font.
Thanks! I used tml with STTR1 (1972 Star Trek) and the smaller font allows sttr1 output to fit on the Prime screen without modifying output formatting. Smile It can be downloaded from my Star Trek page, and I will update the page after work to describe the sttr1/tml combination.

Mike Markowski
Visit this user's website Find all posts by this user
Quote this message in a reply
09-06-2024, 01:10 AM (This post was last modified: 09-06-2024 06:13 PM by ab3ap.)
Post: #19
RE: Prime retro-gaming: trek!
(09-01-2024 01:55 AM)komame Wrote:  It seems that there is a bug in your port in the warp() function.
When you try to cross the edge of the galaxy, it starts displaying negative sector coordinates.

Thank you, Piotr. I fixed the bug last night (I think!) and then uploaded a wrong and broken version. Apologies to anyone who might have downloaded that. I've played a few games and tried some crazy warping and all seems well now. But please let me know if other strange behavior appears. The correct versions have been uploaded today. Smile

Thanks,
Mike
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)