Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to VT100/ANSI escape codes #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# Trek52
# Fullscreen TREK for RSTS/E

Trek52 is a re-creation of the classic text-based Star Trek game that uses VT52 escape codes to make the game more graphical on that terminal.
fstrek is a re-creation of the classic text-based Star Trek game that
supports full-screen gameplay for VT52 and VT100 (ANSI compatible)
terminals.

It is written in Digital Equipment Corporation's BASIC Plus.
It is written in Digital Equipment Corporation's BASIC Plus for the
RSTS/E operating system.

You can see a video demo at [Star Trek, and the evolution of a BASIC programmer - YouTube](https://youtu.be/ksL232PHivI)
This program was originally written by Bob Flanders and released on
June 3, 2022.

Bob Flanders June 3, 2022
You can see a video demo at
[Star Trek, and the evolution of a BASIC programmer - YouTube](https://youtu.be/ksL232PHivI)

The trek52cr.bas.zip contains a the .bas program that has carriage returns only and is more suitable for loading into RSTS/E Basic-Plus. (Line feeds mess up the load.)

https://groups.google.com/g/pidp-11/c/K-DzzAX4x70 and the entry on 6/3/2022 at midnight has directions how to use it.
47 changes: 40 additions & 7 deletions trek52.bas → fstrek.bas
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

! TREK52 - A version of Star Trek for the VT52 terminal
! TREK - A version of Star Trek for RSTS/E
! Written by Bob Alexander - [email protected]
! Implemented in DEC BASIC-PLUS.
! Inspired by the original Star Trek game written by
! Mike Mayfield.
! Written in 2022. Released to the public domain. No rights reserved.
! Adapted from TREK52 to also support VT100 sequences by Hans Huebner.

! Set up the environment
110 extend
Expand Down Expand Up @@ -32,7 +33,11 @@
! damage report
185 commandX% = 25% : commandY% = 14% : damageX% = 0% : damageY% = 14%

! Initialize the VT52 escape codes
! Determine terminal type
186 terminalType% = fnGetTerminalType%()
187 if terminalType% = 0 then print "Unknown terminal, can't continue" : stop

! Initialize the terminal escape codes
190 q = fnInitializeEscapeCodes

! Use RSTS' input trick for getting a single character from the
Expand Down Expand Up @@ -224,8 +229,30 @@
! Modulo function
2210 def fnmod%(n%, d%) = n% - n% / d% * d%

! Terminal handling
2220 def fnGetTerminalType%()
2225 dim returned%(30)
2230 change sys(chr$(6%)+chr$(16%)+chr$(0%)+chr$(255%)+chr$(0%)) to returned%
2235 if returned%(11%) = 128% then goto 2255 ! Hardcopy
2240 change sys(chr$(6%)+chr$(16%)+chr$(1%)+chr$(255%)+chr$(0%)) to returned%
2245 if returned%(5) = 3% then fnGetTerminalType% = 1 : goto 2260 ! VT52
2250 if returned%(25) and 1% then fnGetTerminalType% = 2 : goto 2260 ! ANSI
2255 fnTerminalType% = 0
2260 fnend

2300 def fnBareNum$(n%)
2301 rn$ = num$(n%)
2302 l% = len(rn$)
2303 fnBareNum$ = mid(rn$, 2, l% - 2)
2304 fnend

! Return a string that will position cursor at x, y
2310 def fnCursor$(x%, y%) = esc$ + "Y" + chr$(y% + 32%) + chr$(x% + 32%)
2310 def fnCursor$(x%, y%)
2320 if terminalType% = 1 then &
fnCursor$ = esc$ + "Y" + chr$(y% + 32%) + chr$(x% + 32%)
2330 if terminalType% = 2 then &
fnCursor$ = esc$ + "[" + fnBareNum$(y%+1) + ";" + fnBareNum$(x%+1) + "H"
2340 fnend

! Return a right justified NUM$
2410 def fnRNum$(n%, width%)
Expand Down Expand Up @@ -935,7 +962,7 @@
! Welcome the user and print instructions
32010 def fnWelcome
32015 print clearScreen$;
32020 print " * * * VT52 STAR TREK * * *" : print
32020 print " * * * RSTS/E STAR TREK * * *" : print
32030 print "Do you want instructions (Y, [N])? ";
32035 a$ = fnGetChar$() : a$ = cvt$$(left(a$, 1), 32%) : print clearScreen$;
32040 for dummy% = 1% while a$ <> "N"
Expand Down Expand Up @@ -964,12 +991,18 @@
32255 q$ = sys(chr$(2%)) ! Re-enable echoing
32260 fnend

! Initialize VT52 escape codes
! Initialize terminal escape codes
32410 def fnInitializeEscapeCodes
32420 esc$ = chr$(27% + 128%)
32430 startOfLine$ = chr$(13%)
32440 clearLine$ = esc$ + "K"
32450 clearScreen$ = esc$ + "H" + esc$ + "J"
! VT52
32440 if terminalType% = 1% then &
clearLine$ = esc$ + "K" : &
clearScreen$ = esc$ + "H" + esc$ + "J"
! VT100
32450 if terminalType% = 2% then &
clearLine$ = esc$ + "[K" : &
clearScreen$ = esc$ + "[H" + esc$ + "[2J"
32490 fnend

32500 data " Instructions", &
Expand Down
Binary file removed trek52cr.bas.zip
Binary file not shown.