Sea War

Products: Sea War
Date: 19xx
Type: Cassette
Platform(s): TS 1000
Tags: Game

Sea War is a naval combat game in which one or two players maneuver ships and fire torpedoes across a scrolling ocean battlefield. The program makes extensive use of machine code, invoked via RAND USR at address 18810, which handles the core game engine — the BASIC loader at lines 0–3 is essentially a thin wrapper that saves the program and jumps into the machine code routine. The title screen is constructed from large block-graphic lettering built directly into a REM statement at line 0, including animated wave graphics and a detailed ship silhouette. Scoring data is embedded within the REM block as a lookup table with score thresholds and associated rank graphics encoded as sequences of block characters.


Program Analysis

Program Structure

The visible BASIC program is extremely compact, consisting of only four lines:

  1. Line 0: A massive REM statement containing the entire game engine as machine code bytes, plus decorative block-graphic title art, wave animations, ship graphics, scoring tables, and the actual game logic encoded as tokenized BASIC within the REM data block.
  2. Line 1: A REM statement with author/title metadata.
  3. Line 2: A SAVE "SEAWAR" statement.
  4. Line 3: RAND USR 18810 — the entry point that transfers control to the machine code stored in the REM block.

This is the classic ZX81/TS1000 pattern of hiding an entire program inside a REM statement and jumping to it with RAND USR. The BASIC interpreter never executes any of the content of line 0; it is purely a data carrier for the machine code routine.

Machine Code Entry Point

The instruction RAND USR 18810 on line 3 causes the CPU to call the address 18810 as a machine code subroutine. On a 16K ZX81/TS1000, address 18810 (decimal) falls within the RAM area that begins immediately after the system variables and display file. The REM statement at line 0 begins at a fixed offset from the start of the BASIC program area, and the machine code is positioned so that its entry point lands precisely at address 18810. This is a well-known technique for self-contained machine code games distributed as BASIC files.

Title Screen and Graphics

The REM block at line 0 contains a fully rendered title screen built from block graphic characters. The large “SEA WAR” and “WAR” lettering is constructed from block graphics pixels, accompanied by a wave pattern made of repeating ▞▖ and ▝▖ characters that simulate a rolling sea surface. A ship silhouette is rendered with block characters including ▐▙▞ forms suggesting a vessel with a mast and hull. Below the ship, a detailed wave band uses tilde and comma escape sequences (\~~, \,,) to produce a dense, animated-looking water texture.

Scoring and Rank Table

Embedded within the REM block is a scoring rank table. Score thresholds are listed with associated block-graphic rank insignia displayed beside them. The table spans from a score of 199 up to 999999, with increasing complexity of the rank graphic at each tier:

Score ThresholdRank Graphic (approximate)
199Single dots/spaces
399Scattered pixels
699Denser pixel pattern
999Solid pixel block
1999Extended block
4499–999999Increasingly complex insignia

Two-Player Support

The title screen text within the REM data explicitly offers “1 PLAYER – PRESS (1)” and “2 PLAYERS – PRESS (2)”, indicating the machine code engine handles both single-player (presumably against a computer opponent) and two-player (head-to-head) modes. The keypress detection and mode switching are handled entirely within the machine code.

Tokenized BASIC Within REM

A notable feature of the REM block content is that it contains what appears to be tokenized BASIC keyword sequences — fragments like GOSUB, RAND, FOR, LPRINT, FAST, SLOW, CLS, PLOT, UNPLOT, and many others are visible in the data. These are not interpreted as BASIC by the system; rather, they are the raw byte values of BASIC tokens (which overlap with Z80 opcode bytes) that form the actual machine code of the game. This is an artifact of disassembly/tokenization: Z80 opcodes whose byte values happen to correspond to ZX81 BASIC token codes are displayed as those keywords when the REM content is rendered as text.

Key BASIC Idioms

  • RAND USR 18810 — standard machine code launch idiom; RAND discards the return value of USR so the BASIC program does not error on return.
  • The entire game fits in four BASIC lines, with line 0’s REM acting as a binary data block.
  • SAVE "SEAWAR" at line 2 allows the file to be re-saved from the BASIC prompt, preserving the machine code payload intact within the REM statement.

Notable Techniques

  • Using a REM statement as a machine code container is the dominant technique here, enabling a full game engine to coexist with a minimal BASIC wrapper.
  • Block graphics are used extensively for both the title screen art and the scoring rank display, achieving visually rich output without any custom character definition routines.
  • The wave animation texture in the title screen, constructed from alternating \~~ and \,, escape sequences across multiple rows, creates the illusion of a complex ocean surface using only the standard character set.
  • The scoring table is stored directly within the REM data, allowing the machine code to reference it by address without requiring separate data statements.

Content

Appears On

Related Products

Each player has three submarines. Higher scores result in more hostile features, including submarines, warships and helicopters. One or two...

Related Articles

Related Content

Image Gallery

Source Code

   0 REM -.    ████ ████  ██              █  █ █    █  █ -+-         █    █    █  █ ▐▙▞         ████ ███  ████                █ █    █  █   -+-       █  █ █    █  █   ▐▙▞       ████ ████ █  █                                                         ▐███▀▘                                     █   █  ██  ███             █   █ █  █ █  █            █   █ █  █ █  █   ▚[,,]\,,\,,     █   █ ████ ███             █   █ █  █ █  █            █ █ █ █  █ █  █             █ █  █  █ █  █                                                           1 PLAYER  - PRESS (1)                                 2 PLAYERS - PRESS (2)    ▖4                                  ▞▖   ▞▖   ▞▖   ▞▖   ▞▖   ▞▖    ▞ ▝▖ ▞ ▝▖ ▞ ▝▖ ▞ ▝▖ ▞ ▝▖ ▞ ▝▖ ▞▞   ▝▞   ▝▞   ▝▞   ▝▞   ▝▞   ▝▞  \~~\~~\,,\~~\,,\,, \~~ \,, \~~\~~\,,\,,\~~\,,  \~~\~~\,, \,,\,,\~~\~~\,,\~~ \,,\,, \~~ \,, \~~\~~\,,\,,\~~ \,,\~~\~~ \,, \~~\~~ \,,\~~\,,\~~\~~  \,,\,,  0                                #      ████ ████  ██             #      █  █ █    █  █ -+-        #      █    █    █  █ ▐▙▞        #      ████ ███  ████            #         █ █    █  █   -+-      #      █  █ █    █  █   ▐▙▞      #      ████ ████ █  █            #                                # \~~\~~\,,\~~\,,\,, \~~ \,, \~~\~~\,,\,,\~~\,,  \~~\~~\,, \,,\,,\~~\~~\,,\~~ \,,#                                #            █   █  ██  ███      #            █   █ █  █ █  █     #            █   █ █  █ █  █     #   ▚[,,]\,,\,,     █   █ ████ ███      #            █   █ █  █ █  █     #            █ █ █ █  █ █  █     #             █ █  █  █ █  █     #                                #                                #     1 PLAYER  - PRESS (1)      #                                #     2 PLAYERS - PRESS (2)      #   FASTSTR$ VAL Y 5[,]#▞*:4Q 7$[T]4 RAND Q#7▌[S]4 LIST AT SGN  LPRINT TAN 0 FASTSTR$ VAL U##M[/]#5##)##▘Z  GOSUB [K]5####5##▘4  GOSUB [K]AT SGN  LPRINT TAN 0[X]#▘▝ FASTSTR$ VAL ▘5  GOSUB # AND #5  Y [V]C▖\,,1/ RAND  GOSUB #**#\,,#- ;6**#AT SGN  LPRINT TAN   ▙RND▘▝CHR$ PI[<]#CHR$ PI[$]#LN >= FASTSTR$ VAL E▖##7#7 GOSUB #▞#ACS # C\,,0▌VAL ▞ \,,AT / PAUSE ACS # C▌=$7/ PLOT 6▒#5[,]#6**# GOSUB # AND #LN >=#E**#6\~~## RETURN C#ACS #4## RETURN*K#STR$ VAL E\~~#6:#E▒#6£## RETURN C7ACS #43# RETURN4K,E£##E:##E£#76£#E:#76:#=$/**AT SGN VAL ▞ E▖#7#E▒#\,,6▒#▘5 E\~~#\,,AT 6\~~#0▌/[0]AT SGN  LPRINT TAN 0000VAL STR$  FAST GOSUB #£RND56 ;##5[,]#▘ RUN ▝ GOSUB [K] LPRINT SGN AT TAN  FASTSTR$ VAL ▞.Y [S]C35NOT PI6▖#Y*[(]- # GOSUB #▞#LN >#LN [M]#LN [U]#   ▌/>=AT SGN  LPRINT TAN 000000000 FASTSTR$ VAL ▞3Y [S]C1   5▙RND6▖#2▘#= GOSUB #▞#LN >#LN [M]#LN [U]#▌/ THENAT SGN  LPRINT TAN 00# ▝[=]  REM 000000000000▖>     ▀▚▞▚          ▀▜-[,,][,,][,,][,,][,,][,,][,,]       ████[S][E][A][-][W][A][R]█████[>][>] █[~~][~~][~~][~~][~~][~~][~~][~~][~~][~~][~~][~~]██  ▘"[,,]████[,,]███[,,]███[~~]█████[~~]██████[~~]███00 FASTSTR$ VAL U[=]#M[L]#5[+]#)[=]#▘1  GOSUB [K]AT SGN  LPRINT TAN 00#  000000000000000▚[,,]\,,\,,=001910 ▌8# LIST # LIST #▝U DIM #█5 LIST #6 LOAD #6 LET #LN \,,#TAN #▞ :▞Y [T]C)5 SLOW#\,,# RETURNAS▌CHR$ \~~#FO$/ REM E£RNDUSQR # RETURN C▞▘. \,,/▖▘\,, \,,##▘▞ 5 FAST# GOSUB [K]AT SGN  LPRINT TAN  FASTSTR$ VAL USQR # RETURN 4+E£RND 7##5 STEP #▘▌  GOSUB [K]UABS #>/+E£RND▘< \,,##5 STEP #▘▌  GOSUB [K]UPEEK #>AT SGN  LPRINT TAN  FASTSTR$ VAL LN [<]#▘: 5SGN #)ABS # GOSUB [K]LN  SAVE #LN [V]▝Y PLOT [W]4\,,Y[X][X]4▖AT SGN  LPRINT TAN LN [M]#               Y LN ##   LN [U]#  Y RUN [X]4ACS Y CLEAR[W]4(E£RND7Q ##<▘3  GOSUB [K]/AY CLS[W]4[L]Y3MPEEK #Y▘MSQR #) FAST#5 AND #▘▞  GOSUB [K]5  6 FOR #LN ##LN PI#Y MSQR #Y3MABS #) FAST#5USR #▘▞  GOSUB [K]5  6 FOR #LN ##LN PI#UABS # RETURN04$UPEEK # RETURN04▞LN PEEK ##█#LN PEEK #LN 3#LN  UNPLOT #USQR # RETURN 445 FAST#)USR #▘▞  GOSUB [K]5ABS #PLN PI#UPEEK # RETURN0C#Y▘MSQR #/[W]5 FAST#) AND #▘▞  GOSUB [K]5PEEK #PLN PI#UABS # RETURN0C[C]Y MSQR #/[0]       00000000PLAYER 1PLAYER 2▘▖▚[,,]\,,\,,▘▖▄▄█▄▝▀-+-▚▟▌▝▌   ▖ ▄▄▟▙▄  REM 00000000LN [<]#LN [M]#LN [O]#5[>]#6▖#2\,,Y▀█# GOSUB #▞#LN >#5##6▖#2▌# GOSUB #▞#LN >#VAL ▘▒ )##USQR # RETURN 4▛5[>]# GOSUB [K]AT TAN 5[,]#/ RUN 0000000000000 FASTSTR$ VAL ▘> INPUT Y"M[<]#Y [T]C\~~LN ATN #LN [U]#▖$/ LET :\,,Y([T]C,LN ATN #5[6]#6▖## -▖ GOSUB #▞#LN >#LN [U]#£/ LPRINT Y5[S]C;LN ATN #5[6]#6▖##-▖ GOSUB #▞#LN >#LN [U]#▖/ LLIST AT SGN  LPRINT TAN     ▝W  REM -\~~.#-*C#-<8#-?4#>$[,]#:-3#////////////▛+R#▖▞VAL #////////$▒ LIST #////////////////<+##////////-£1#///////////#001999▝▘▘▘▘▘▘##00 FASTSTR$ VAL ▘5 # FAST5  2▒[J]ACS +ACS =ACS 6K▘\,,14 NEXT SGN ,ACS #C▖▘  TO \,,<,<STR$ - ACS #C▘+#; GOSUB #£RND\,,▘6 \,,SGN  FOR #7#AT SGN  LPRINT TAN \,, \~~\,, \,,  \~~ \~~  FASTLN ## LPRINT ▞▌: $4 CLEAR▌4 SAVE ▘## GOSUB #[*]#LN ##▘W# GOSUB #[*]#TAN             \,,\,,\~~ \,,\~~AT ▌4 DIM TAN  FASTSTR$ VAL  RETURN▞CQ#7#7#7# FAST RETURN▌4:# RETURN\~~C>▌$5 THEN COPY; FOR /= RETURN▖4:# RETURN-C INPUT ▖$54 ; FOR /▝$. LPRINT #F#F#F#U PAUSE ##7#FACS #42 RETURN▛S, FAST5[S]#Y/[Y]4\,, FOR  LPRINT ▘▖  GOSUB [K]/▒7777▌4 FOR  LPRINT AT SGN  LPRINT TAN ▞▝▌▘▀▌▖▝▞▘▌▀▞▖▘▝▀▘▞▌▝▖▌▞▀▝▘▖▀▖= FASTVAL 5▒#P4▝Q2#▞ 5 DIM #\,,#AT  LPRINT TAN  U LOAD ##▞▖5[/]#Y/[Y]4/ACS #4S[J][T]COLN \,,#▗LEN \,,#7Q3FLN  RAND #/87#F RETURN CLEAR4▖Q//;U▜# RETURN\~~4▖Y▌/" RETURN*4▖Y▖/▀LN \,,#LN █#7777$▌4[R]TAN  ▄▟▖5[/]#▞▖Y/[Y]CCVAL :▖7#7#7# FAST5##ACS #C▞7<$▖4 IF Y0[S]K▖▌$/ RAND ▞  GOSUB [K] LPRINT AT /▀7777▌4ATN TAN 5[S]#▞▌Y/[Y]C\~~77#7#Y<>/▀7777▌4 FOR TAN 5[S]#▞▌Y/[Y]C+7[J][Y]4▌FQ//"P7#7#.#F#/▝7777▌4 TO TAN E▚#Q▚7Q[,,]7Q\,,7Q\,,TAN LN ▘#[J][T]""LN [V]▝)▜#▞  FOR Y LOAD [V]4/ACS #4▘OACS #4▝P▖ACS #4\,,7# RETURN>C\~~O/▛7# RETURN▖C▘PF# RETURN\,,4▀O/▌ RETURN*4▘PLN  RAND #LN C#[J][T]""ACS #4▀LN ##ACS #""LN ##TAN U[=]# RETURN/"" FASTVAL  GOSUB #▜#▖$ GOSUB #[=]# GOSUB #▚#5 STEP  COPY\,,6[-]#AT  LPRINT TAN  FASTSTR$ VAL :▀5[▒]## RETURN/C"7777$4 POKE AT SGN  LPRINT TAN  GOSUB #▜#[J][S]C▘1#7====#FLN  RAND #/ NEWQ*FQ 7TAN  FASTSTR$ Q*)5 ;Q SGN  LPRINT TAN ▞▀)[▒]#, RETURN/4\,,<<<<▌4 POKE /R<, RETURN34:. FOR Q/77#7# FOR Q / NEW< FOR #7# FOR LN ##[J][T]4 OR 7 FOR #F#FO77 FOR LN ##[J][T]4COS LN [C]#/#, RETURN/COS  RETURN 4£ FOR Q/77#7# FOR Q TAN << FOR #7# FOR LN ##[J][T]""#▘ TO  COPY\,, FOR #F#FFP FOR <<<LN ##[J][T]""LN [J]#TAN [W]ABS ▘[;]LN LN LN 7777AT ▌4 DIM TAN             :▘SGN  LPRINT TAN [J]E▚##7#7#7#TAN : # RETURN COS  RETURN*COS  RETURN\,,COS  RETURN\~~COS STR$  FASTVAL ... RETURN<CE RETURN+C5 RETURN/C/, RETURN\~~K: RETURN▛K▌LN (#/*LN ##/>LN [W]#/$LN "#/▒LN *#/▀LN  COPY#AT  LPRINT Y/>SGN £TAN STR$ ▞▖6 PRINT #5[/]# FAST#77 RETURN/CE#7#E PRINT #[J] GOSUB #[W]42ACS #4,# RETURN▖K+ LPRINT    FASTLN ## LPRINT Q/5 ▝6 FOR #LN ##SGN TAN  LPRINT 7777▌4LEN SGN TAN E▚#Y▚[Y]4(7Y[,,][Y]4\~~7Y\,,[Y]4▖7[Y]C\,,5▜#LN ##:▘TAN LN ##: TAN [J]E▚#[Y]4 REM 7[Y]4 NEW7[Y]4 LLIST 7[Y]4 THENLN  NEXT #: TAN [A]#7#M[J]M""#LN [K]#LN ATN #Y<M""#LN [K]#TAN LN 5  6##6##LN ##LN 3#5 ▄6##5▟▖6##LN ##TAN ▘▖▀Y-[Y]4▘▌7# RETURN1S▖C▘$$7#7#5 TO  COPY;##5W#VAL  FASTSTR$ ▞  GOSUB [K]SGN 55 ;## LPRINT 7777AT ▌4 DIM TAN   ▗▌  ▄▄█▙▖ \~~[,,]\~~[,,]\~~\,,5[C]#Y/[Y]4*U LIST # RETURN COS LN \,,# RETURN▞""▘▛3 GOSUB #[C]#LN  RAND #TAN Y CLS7[Y]4▖FQ/TAN PE[E]#F6[E]#U[D]#ACS #4CU NEXT ## RETURN C45ATN #Y/[Y]C\,,7777▌4 PLOT /? FOR E[C]#GGG FOR #7#FLN  RAND #:▞ GOSUB #[E]#U[D]##5[L]#ACS #C▒7<$▖4 IF /\,,Y,[S]K▖▌$/ RAND ▞▀VAL  FASTSTR$ ▞  GOSUB [K] LPRINT ▘5 \,, FOR  LPRINT ▘▞ \,,AT ▌4 REM TAN \,,\~~ ▖▀ ▝▌▄ ▙▘ ▛\,,▀\~~▞ FASTSTR$ VAL 5##6I#5 ▌6 FOR #LN ##Y LN ##5##6I#LN 7#5[L]#6I#Y/M[C]#AT SGN  LPRINT TAN ▞▝▀▞▖▖000005ATN #▞▀Y/[Y]4▒7777▌COS / NEXT Y-[Y]C2O7[J][Y]C*P7VAL #7#[J]▝ FOR 54 \,, FOR #F#Y/>AT /**FQ/77#7#[J]>/LN -+-▚▟▌-+-▐▙▞ FAST:▀7#7#7#5 REM #ACS #C▞$<7▖4 IF VAL  FASTSTR$ ▞  GOSUB [K] LPRINT ▘5 \,, FOR  LPRINT 777AT ▞  GOSUB [K] LPRINT TAN U LET ##▞▀5##6 #5[G]#Y/[Y]C?VAL LN  PLOT #AT $▌C47777/ GOTO ACS #4 PAUSE [J][T]C INPUT LN \,,#XACS #4 CLS#7Q RETURNFLN  RAND #/>=▞▀5[G]#Y/[Y]4▒7777▌COS / NEXT VAL ##7#7#7#ACS #C=<#F#FOF) REM # GOSUB # #LN  PLOT #AT /NOT [D]ACS #CO$ FAST[J][T]4\,,.5 REM #6 #/#5 LIST #6 # LPRINT # RETURN C" RETURN▌C:LN \,,#ACS #C▛▖ FAST54 /U▌ FAST5 THEN COPY/N£ FASTY>[T]4\,,<5 LIST #6 #/95 REM #6 # LPRINT # RETURN C" RETURN▌C:LN \,,#ACS #C▛▖ FAST56 /▌▌ FAST5 STEP  COPY; FOR  LPRINT #F#F#F#LN [-]##[:]#STR$ ▞▀6 PRINT #5[G]#Y/[Y]4\,,7777▌4 POKE SGN TAN 77 FAST#7#E PRINT #[J] GOSUB #[W]4PACS #4L# RETURN▀S▒ RETURN5SC RETURN8K8 LPRINT FF)W# GOSUB # #LN  PLOT #)## GOSUB # #LN  PLOT #Q/5▘ 6 FOR #LN ##SGN TAN  LPRINT /[M] FASTSTR$ VAL U##M[/]#5##)##▘Z  GOSUB [K]E£RND)#▘; FOR 5##▘4  GOSUB [K]AT SGN  LPRINT TAN  FASTVAL U POKE # RETURN 4▀AT  LPRINT TAN #5**#Y/[Y]C\~~7777$4 PLOT AT  LPRINT TAN AT ▖▖£#7# FOR ▘# \,, FOR 7#7# LPRINT TAN ▞▖5**#Y/[Y]4▒7777▌COS / NEXT 77#7# FOR Q  FOR  FAST55 ; FOR  LPRINT #F#FFY-[Y]4▖Q// AND O FOR Q+ FOR /PEEK Y[S]MH#Y▌MF#/-YATN MH#Y▀MF#/\~~Y**MH#Y▖MF#6 PRINT #STR$ Q FQ ▞▀5ATN #Y/[Y]4\,,7777▌4 POKE SGN TAN 77#7# FASTE PRINT #[J] GOSUB #[W]4"[X]4▒ LPRINT FFFQ/SGN TAN  LPRINT /<> CLEAR FASTSTR$ VAL  GOSUB # FOR #E CONT #;6 CONT #5 DIM #▞▖# RETURNAS▛CHR$ \~~#FO/▘F▌4 LIST # RETURNAS:Q05 LIST #[J]M NEXT #▘$ /-5 CONT #) FAST#▞▌,[Y]CLSO[J]E GOSUB #▘$ \,,6 GOSUB #) CONT # GOSUB [K]5 INPUT #U NEXT #[Y]C.USQR # RETURN 4▌5ABS #/▀5PEEK #O5 NEXT #O/▌7<▌4LEN E£RNDUSQR # RETURN C▌▘. /▀▘\,, \,, FOR ▘▞ 5 FAST# GOSUB [K]LN PI#AT SGN  LPRINT TAN 0000# USQR # RETURN C▌E LET #/▀E LOAD #6 GOSUB #) CONT #▘$  GOSUB [K]U INPUT #M NEXT #5▜#Q(7Q▖FLN  RAND #5[▒]#Q/##<▘#  GOSUB [K]LN ATN #LN ##E GOSUB #USQR # RETURN C▖6 LET #TAN 6 LOAD #TAN 000VAL ▞▝▌4 CLEARX4 SAVE AT TAN   LN ##Y█LN ##LN [W]#Y█LN ##LN ▝#ACS INKEY$ ""Y█LN ##LN [W]#Y█LN ##LN ##Y█LN ##LN ▝#ACS INKEY$ ""Y█LN ##LN ##Y█LN ##LN [E]#Y█LN ##LN ##Y█LN ##LN ##Y█LN ##LN 8#Y█LN ##LN COS #Y█LN ###### ▘#  REM USQR # RETURN C▌5 AND #/▀5USR #▘▞ ) FAST# GOSUB [K]LN [<]#LN [M]#LN [U]#LN  NEXT #TAN 000199▘▝  ▘  000399▘▝▘ ▝▘ 000699▘▘ ▘▘ ▘000999▘▘▘▘▘▘▘001999▝▘▘▘▘▘▘002999▝  ▝  ▝003999▝  ▝  ▀004499▝▝ ▝▝ ▝004999▀▀▘ ▀▝ 007499▀▀▘ ▖▝ 009999▖ ▘▘ ▝▝014999▌▝▘▝▀▝▝029999▞▀▘▝▖▝▀049999▞▀ ▀▌ ▖069999▛▖▘▀▌▘▖079999▒▖▘▀▖▝▀089999\,,▖▘▀▌▝▖199999\,,▖▘▀▌▀▖999999\,,▖▘▀▌▀▖00000000000000000# ▖#  REM 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
   1 REM  ** PANDA SOFTWARE **            PROGRAM TITLE - SEAWAR          AUTHOR - S.C.WONG
   2 SAVE "SEAWA[R]"
   3 RAND USR 18810

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

People

No people associated with this content.

Scroll to Top