; Disassembly of the machine code "STRANDED.DAT" from
; "stranded_on_rigel_5_(300-baud)_[sean_walsh].prg"
; in "Stranded%20On%20Rigel%205%20(Sean%20Walsh).zip" 
;
; CPU Type: Z80 for the Bally Professional Arcade
;
; Created by Richard C. Degler with dZ80 2.0
;    using script "BallyHVG.LUA" from scratch
;
; on Monday, 11 of October 2010 at 05:06 AM
;
; This code assembles with ZMac assembler
; command line: zmac -i -m STRANDED.ASM
;

; [modified BALLY Basic listing - will not txt2prg properly]
; [commented by Richard C. Degler using prototype prg2txt's]
;
; [Both versions are the same, except for the comments on one and different Direct Command loaders :]
;
; {13}
; {13}
; .STRANDED ON RIGEL 5{13}
; .BY SEAN WALSH{13}
; .ARCADIAN VOL.4 PG.72&73{13}
; {13}
; {13}
; [note: first line copies program and fontdata to TeXT area]
; for A=-24576to -22776;%(A)=KP;next A;%(20050)=-22886;:return ;run {13}
; [loads 1800 bytes, sets TXTUNF near bottom, turns off tape]
;
; [or as printed in the Arcadian ...]
;
; {13}
; A =  -24576;B=  -22784;for N=Ato B;%(N)=KP;next N;%(20050)=B-102;:return ;run {13}
; [Not sure why there are extra spaces in the second version, and {13}'s are c/r's]
;
; [line numbers in the following section were actually words]
; 6 W=20200;Y=W+13;R=W+3;F=-40;BC=0;FC=126;clear ;for A=-80to 80;line A,-40,0;F=F+rnd (3)-2;if F<-40F=-40
; [W is Alt STRing DISplay, Y is Character, R is X and Y loc]
; 7 line A,F,1;if A>50box rnd (160)-80,rnd (70)-40,1,1,1
; 10 next A;print "   STRANDED ON RIGEL 5";P=0;for A=17to 20;&(A)=7;next A;&(16)=92;&(22)=-1;if KPinput S
; [show Title with noise, enter S for Speed]
; 80 gosub 900;O=0;K=20;gosub 749+(P>0)
; [mute sounds, clear ??, and restore alt font to first shapes]
; 100 clear ;box -50,32,60,1,1;box -42,-5,1,74,1;P=0;box 0,0,3,87,1;box -5,0,10,2,1;%(Y)=128;%(R)=8774
; 105 CALLW;for A=0to 4
; [display a character $80 at X=70 and Y=34 ??]
; 110 @(A)=rnd (10)-1;for Q=0to A-1;if A=0next A
; [pick a random digit 0 to 9, bail if first one]
; 111 if @(A)=@(Q)goto 110
; [matched existing digit - try again]
; 120 next Q;next A;print "input CODE";print 
; [code number generated, ask for 5 digits]
; 124 for P=1to 8;for A=5to 9
; [P is Pass number, A is second group of array numbers]
; 125 @(A)=KP-48;if (@(A)<0)+(@(A)>9)goto 125
; [input a digit and validate]
; 126 TV=@(A)+48;next A;C=0;D=0;for A=0to 4;if @(A)=@(A+5)C=C+1
; [display digits, reset counters, increment C for each Correct]
; 140 for Q=5to 9;if @(A)=@(Q)D=D+1
; [compare against all 5 existing digits, increment D if found]
; 143 next Q;next A;CX=-36;print #0,D,"-",#0,C;if C=5goto 180
; [display results, to you won routine if all Correct]
; 161 for A=17to 20;&(A)=-1;next A;&(16)=33;&(22)=Pmul 31;next P
; [ramp sound effects on any wrong digit found]
; 170 %(Y)=129;%(R)=67;CALLW;N=9
; [display a character $81 at X=67 and Y=0 ??]
; 172 for A=32to Nstep -5;&(18)=-A;box -7,A,2,5,3;box -7,A,2,5,3;next A;box -7,N,7,2,2;N=N-2;if N>2goto 172
; [cycle sound effect, blow up screen ??]
; 175 gosub 700;goto 190
; [do ??, skip over you won to go again]
; 180 box 0,6,3,10,2;box 16,0,35,1,1;box 40,-30,50,5,1;box 40,-13,30,30,1;box 40,4,20,5,1;box 40,14,5,16,1;box 40,-30,5,5,2
; [you won phase one! here's your prize]
; 190 gosub 900;CX=12;CY=40;print "CODE WAS:";CX=21;for A=0to 4;print #0,@(A),;next A;if KPif P=9goto 100
; [either way, mute sound and go again on failure]
; 500 K=0;gosub 750
; [start of phase two, load font shapes two]
; 510 clear ;E=0;for A=1to 30;box rnd (160)-80,rnd (88)-44,1,1,1;next A;for T=1to 3;gosub 600;next T;V=80;H=V
; [??, fill screen with targets, and center ??]
; 520 for N=1to rnd (8-S)mul 14;H=H+JX(1)mul 4;%(R)=20480+H;CALLW;if TR(1)&(22)=-1;gosub 580
; [draw character 0 at ??, and check for shot]
; 530 CALLW;next N;for A=48-Tmul 10to 40step 10;for B=-74to 80step 16;if PX(B,A)gosub 600;T=T+1;goto 520
; [display a character 0, check for targets ??]
; 540 next B;T=T-1;next A;CALLW;goto 800
; [no targets left, if done display a character 0 and end]
; 580 for A=-32to 40step 10;box H-74,A,2,5,3;box H-74,A,2,5,3
; [shot ?? routine]
; 581 &(18)=A;if PX(H-74,A)box H-75,A+1,11,9,2;&(21)=-1;&(23)=9;gosub 900;return 
; [check for collision and ?? beep]
; 590 next A;E=E+1;return 
; [else missed, continue]
; 600 %(Y)=129;for A=0to 9;%(R)=2560mul T+Amul 16;CALLW;next A;%(Y)=128;if T#8return 
; [seed screen targets ?? routine - draw 10 character 1's, set character 0]
; 610 for A=1to 40;MU=3;next A;gosub 700;goto 510
; [rarely beep and flash screen]
; 700 for Z=1to 7;&(21)=-1;&(18)=99;&(19)=99;&(16)=1;&(23)=9;BC=7-Z;next Z;gosub 900;O=O+1;if O<5return 
; [noise and flash screen ?? routine, mute and decrement lives]
; 710 clear ;print "YOUR 5 LIVES ARE GONE";print "YOU HAVE FAILED!";if KPgoto 80
; [out of lives, wait for kp then restart]
; 749 for A=0to 10;C=W+Amul 2;%(C)=@(A);next A
; [copy 22 bytes of machine code routine on pass 1 only]
; 750 C=Y+7;for A=31-Kto 50-K;C=C+2;%(C)=@(A);next A;return 
; [copy 40 bytes of first or second font info into font]
; 800 for A=16to 19;&(A)=60;next A;&(21)=89;&(22)=-1;&(23)=61;for A=1to 15;print ;next A;gosub 900;print "GREAT!
; [successful end of game ?? routine - make cheer]
; 810 print "EFFICIENCY IS",100-Omul 9-P-E+Smul 3,"%";if KPgoto 80
; [show score, wait for kp then restart]
; 900 for Z=16to 23;&(Z)=0;next Z;return

; After Line 900 is the "end of program marker" and the "@(array)" which contains the "machine language" section as follows :

;         DW      $FF00           ; -256 [end of Basic program flag]

        ORG     $4EE8

; ****** Start from BALLY Basic with CALL20200 *** <-- Variable 'W' is pointed here
L4EE8:  PUSH    DE              ; store Basic Program pointer <-- copied starting from @(0)
        SYSSUK  STRDIS          ; UPI STRing DISplay
        DB      $4B             ; ... X = 75 <-- Variable 'R' is pointed here
        DB      $00             ; ... Y = 0
        DB      $28             ; ... Options = 40
        DW      L4EF2           ; ... String Address = 20210
        ;
        POP     DE              ; restore Basic Program pointer
        RET

; ****** Formatting Text string ***
L4EF2:  DB      $70,$F8,$4E     ; load IX with 20216 for Alternate Font Descriptor
        DB      $81,$00         ; ASCII $80 and/or $81 (Null Terminated) <-- Variable 'Y'

; L4EF7: 1 spare byte for ??
        DB      $30

; ****** Alternate Font Descriptor block *** (at 20216)
L4EF8:  DB      $80             ; FonT BASE character = 128 (normally 32)
        DB      $09             ; ... Frame X Size width = 9
        DB      $0F             ; ... Frame Y Size height = 15
        DB      $02             ; ... X size for char in BYTEs = 2
        DB      $09             ; ... Y SIZe height in rows = 9
        DW      $4EFF           ; ... Pattern Table address = 20223

; ****** Special Two-character 9 x 15 Font *** 20 words moved by Basic to 20222
L4EFF:
; *** Char $80 Human, First shape
        DB      $38,$00         ; . . X X X . . . . . . . . . . . <-- @(11 to 30)
        DB      $FE,$00         ; X X X X X X X . . . . . . . . .
        DB      $FE,$00         ; X X X X X X X . . . . . . . . .
        DB      $BA,$00         ; . . . X . . . . . . . . . . . .
        DB      $38,$00         ; . . X X X . . . . . . . . . . .
        DB      $7C,$00         ; . X X X X X . . . . . . . . . .
        DB      $6C,$00         ; . X X . X X . . . . . . . . . .
        DB      $C6,$00         ; X X . . . X X . . . . . . . . .
        DB      $00,$00         ; . . . . . . . . . . . . . . . .
; *** Char $81 Lander, First shape
        DB      $07,$00         ; . . . . . X X X . . . . . . . .
        DB      $3F,$E0         ; . . X X X X X X X X X . . . . .
        DB      $32,$60         ; . . X X . . X . . X X . . . . .
        DB      $3F,$E0         ; . . X X X X X X X X X . . . . .
        DB      $15,$40         ; . . . X . X . X . X . . . . . .
        DB      $17,$40         ; . . . X . X X X . X . . . . . .
        DB      $3A,$E0         ; . . X X . . . . X X X . . . . .
        DB      $02,$00         ; . . . . . . X . . . . . . . . .
        DB      $07,$00         ; . . . . . X X X . . . . . . . .
;  3 filler bytes (not used)
        DB      $00,$00         ; . . . . . . . . . . . . . . . . <-- 3 additional bytes
        DB      $00,$4E         ; . . . . . . . . . X . . X X X . <-- high byte of address
; *** Char $80 Human, Second shape
        DB      $04,$00         ; . . . . . X . . . . . . . . . . <-- @(31 to 50)
        DB      $04,$00         ; . . . . . X . . . . . . . . . .
        DB      $04,$00         ; . . . . . X . . . . . . . . . .
        DB      $0E,$00         ; . . . . X X X . . . . . . . . .
        DB      $1F,$00         ; . . . X X X X X . . . . . . . .
        DB      $1F,$00         ; . . . X X X X X . . . . . . . .
        DB      $1F,$00         ; . . . X X X X X . . . . . . . .
        DB      $3B,$80         ; . . X X . . . X X . . . . . . .
        DB      $7B,$C0         ; . X X X . . . X X X . . . . . .
; *** Char $81 Lander, Second shape
        DB      $1F,$00         ; . . . X X X X X . . . . . . . .
        DB      $7F,$C0         ; . X X X X X X X X X . . . . . .
        DB      $AA,$A0         ; X . X . X . X . X . X . . . . .
        DB      $7F,$C0         ; . X X X X X X X X X . . . . . .
        DB      $1F,$00         ; . . . X X X X X . . . . . . . .
        DB      $0E,$00         ; . . . . X X X . . . . . . . . .
        DB      $7F,$C0         ; . X X X X X X X X X . . . . . .
        DB      $64,$C0         ; . X X . . X . . X X . . . . . .
        DB      $F1,$E0         ; X X X X . . . X X X X . . . . .

; 14 filler bytes ??
        DB      $00,$00         ; . . . . . . . . . . . . . . . . <-- 3 additional bytes
        DB      $00,$00         ; . . . . . . . . . . . . . . . .
        DB      $00,$00         ; . . . . . . . . . . . . . . . .
        DB      $00,$00         ; . . . . . . . . . . . . . . . .
        DB      $00,$00         ; . . . . . . . . . . . . . . . .
        DB      $00,$00         ; . . . . . . . . . . . . . . . .
        DB      $00,$00         ; . . . . . . . . . . . . . . . .

; end of file

        END


As you can see, the machine code portion is moved by the Basic program before
being used, and either two-character font can also be copied into position.

Hope everyone has "Lucinda Terminal" font - the regular "Terminal" changed
&nbsp; to á in the preview.
Used <pre>code</pre> instead of <code>text</code> as one eats all blank lines.

If this listing is too fragged up, and for my comments on the Basic listing,
see :
http://tech.groups.yahoo.com/group/ballyalley/files/STRANDED.ASM 

Richard Degler


--- In ballyalley@yahoogroups.com, Adam Trionfo <ballyalley@...> wrote:
>
> 
> I added the "ML version" of "Stranded on Rigel 5" by Sean Walsh to 
> BallyAlley.com.  The "regular" version of this game was already on the
> website.  Now the archive contains both versions of this game.  Paul, can you
> tell me what is different about these two games.  From the Arcadian's
> description, it seems like the machine language MUST be included with the 
> game to work properly.  Is the non-ML version of the game incomplete?
>
> "Stranded on Rigel 5" is the May 1982 $100 prize winner in the Arcadian 
> newsletter.  This program is for use with Bally BASIC only; it is NOT 
> compatible with AstroBASIC.
> 
> This archive would make another great use of the digital-archiving procedure,
> as the non-digital archive is 8MB for both versions of the game.
> 
> The program can be downloaded here:
> 
> http://tinyurl.com/2c2p587
> 
> (or use the full URL:)
> 
> http://www.ballyalley.com/program_downloads/300_baud_programs/misc/misc.html
> 
> The game starts a little strangely (kind of like the game Mastermind).  I
> have gone ahead and typed-up the instructions out of the Arcadian.  They are
> included with the above archive, or you can view them here:
> 
> http://tinyurl.com/2c2cfj5
> 
> (or use the full URL:)
> 
> http://www.ballyalley.com/program_downloads/300_baud_programs/misc/Stranded%20On%20Rigel%205%20%28ML%20version%29%20%281982%29%28Sean%20Walsh%29%28300%20baud%29%28PD%29.txt
> 
> Have fun!
> 
> Adam
>