;*************************** AMUS Program Label ******************************
; Filename: ULTRIS.M68 Date: 01/08/92
; Category: UTIL Hash Code: 442-153-546-057 Version: 1.0(4)
; Initials: ULTR/US Name: DAVID PALLMANN
; Company: ULTRASOFT CORPORATION Telephone #: 5163484848
; Related Files:
; Min. Op. Sys.: AMOSL 1.3B/AMOS32 1.0 Expertise Level: BEG
; Special: Display is best suited to color terminals (AM72,AM75,PCs).
; Description: UltraSoft's Tetris-like game. Press E to get extended pieces
;*****************************************************************************
;****************************************************************************
;* *
;* ULTRIS *
;* UltraSoft's Tetris-like Game *
;* *
;****************************************************************************
;[104] 08 January 1992 13:39 Edited by David Pallmann
; Enhance for usability on non-Alpha Micro monochrome terminals.
;
;[103] 30 December 1991 13:40 Edited by David Pallmann
; Improve random number generator.
;
;[102] 24 December 1991 14:01 Edited by David Pallmann
; Adjusted scoring and speed-up logic for broader appeal.
;
;[101] 24 December 1991 10:04 Edited by David Pallmann
; Added B)ase vs. E)xtended piece set selection.
;
;[100] 19 December 1991 14:33 Edited by David Pallmann
; Created.
;version
VMAJOR =1
VMINOR =0
VSUB =0
VEDIT =104.
VWHO =0
;universals
SEARCH SYS
SEARCH SYSSYM
SEARCH TRM
;assembly parameters
HEIGHT =24. ; well height
WIDTH =14. ; well width
LFTOFF =<<80.-<WIDTH*2>>/2>
;colors
BLACK =0
WHITE =1
BLUE =2
MAGENTA =3
RED =4
YELLOW =5
GREEN =6
CYAN =7
;variables
.OFINI
.OFDEF RANIDX, 1 ; random number generator index
.OFDEF PROT, 1 ; piece rotation (0,1,2,3)
.OFDEF PROW, 1 ; moving piece row
.OFDEF PCOL, 1 ; moving piece column
.OFDEF PTYPE, 1 ; piece type code
.OFDEF DROP, 1 ; drop flag
.OFDEF PADR, 4 ; address of piece definition
.OFDEF COLOR, 1 ; color flag (0=monochrome)
.OFDEF XXXXXX, 1 ; unused (even up address)
.OFDEF SETFLG, 1 ; piece set flag (0=basic, 1=extended)
.OFDEF BLKFLG, 1 ; solid block flag (0=none, 1=supported)
.OFDEF ACCUM, 2 ; timer - count up register
.OFDEF MAXVAL, 2 ; timer - max value
.OFDEF BUFFER, 8. ; temporary work buffer
.OFDEF SCORE, 4 ; score
.OFDEF LEVSCR, 2 ; score for this piece
.OFDEF LEVELS, 2 ; levels removed
.OFDEF TRMFLG, TC.SIZ ; terminal characteristics
.OFDEF BOARD, HEIGHT*WIDTH ; the current display
.OFDEF PRVBRD, HEIGHT*WIDTH ; the prior display
.OFSIZ MEMSIZ
MOVE: TSTB PROW(A5) ; is there a piece to move?
JEQ CREATE ; no - go create one
TSTB DROP(A5) ; are we in Fast Drop mode?
BNE 10$ ; yes - go to it
;idler loop to pace drop rate with game duration
INCW ACCUM(A5) ; add one to accumulator
CMMW ACCUM(A5),MAXVAL(A5) ; time to move the piece?
BHIS 10$ ; yes - go do it
SLEEP #10. ; sleep 1/1000th second
JMP SCAN ; go check for keyboard input
;this is where the piece is actually moved
10$: CMPW LEVSCR(A5),#10. ;
BLOS 15$ ;
SUBW #5.,LEVSCR(A5) ;
15$: CLRW ACCUM(A5) ; clear out the accumulator
CALL DELETE ; delete piece from the board
INCB PROW(A5) ; add one to row
CALL CHECK ; will this be a collision?
BEQ 20$ ; yes
CALL ADD ; add piece back to the board
CALL UPDATE ; update the screen
JMP SCAN ; check input again
;we could not move the piece so it is at rock bottom
;cancel the current moving piece so that a new one will be created
20$: DECB PROW(A5) ;
CALL ADD ;
CLRB PROW(A5) ;
CLRB PCOL(A5) ;
CLRB PTYPE(A5) ;
CLR PADR(A5) ;
CLRB PROT(A5) ;
CLRB DROP(A5) ;
CMPW MAXVAL(A5),#5 ; are we as fast as can be?
JLO 10$ ; yes
SUBW #2,MAXVAL(A5) ; no - pick up the pace
30$: CALL REMOVE ; remove any levels that need it
JMP SCAN ; go check for keyboard input
;select Fast Drop mode in which our timing delay is temporarily inactivated
;for the current piece
;************
;* UPDATE *
;************
;Function: Update the display, by comparing BOARD(A5) to PRVBRD(A5)
;
; On mode color terminals we use glorious color
; On everything we use boring solid blocks
; On terminals that don't support solid blocks we use even
; more boring "[]"s.
UPDATE:
TSTB COLOR(A5) ; color terminal?
BNE 5$ ; yes
TSTB BLKFLG(A5) ; will we be using solid block? [104]
BEQ 5$ ; no [104]
CRT 23 ; no - select alternate char set
5$: LEA A0,BOARD+WIDTH(A5) ;
LEA A1,PRVBRD+WIDTH(A5) ;
MOV #2,D2 ;
MOV #HEIGHT-2,D4 ;
10$: MOV #1,D3 ;
MOV #WIDTH-2,D5 ;
INC A0 ;
INC A1 ;
20$: MOVB (A0)+,D0 ;
MOVB (A1)+,D1 ;
CMPB D0,D1 ;
BNE 30$ ;
25$: INCW D3 ;
SOB D5,20$ ;
INC A0 ;
INC A1 ;
INCW D2 ;
SOB D4,10$ ;
TSTB COLOR(A5) ; color terminal?
BNE 28$ ; yes
CRT 24 ; no - select standard char set
28$: RTN ;
30$: MOVW #-3_8.+1,D1 ;
MOVB D0,-1(A1) ;
BEQ 40$
TSTB COLOR(A5) ; color terminal?
BEQ 50$ ; no
MOVB D0,D1 ;
INCW D1 ;
AND #377,D1 ;
ADDW #-3_8.+0,D1 ;
40$: TCRT ;
MOV D3,D0 ;
MUL D0,#2 ;
ADD #LFTOFF,D0 ;
CURSOR D2,D0 ;
TYPE < > ;
BR 25$ ;
50$: MOVB D0,-1(A1) ;
MOV D3,D0 ;
MUL D0,#2 ;
ADD #LFTOFF,D0 ;
CURSOR D2,D0 ;
TSTB -1(A1) ;
BEQ 60$ ;
TSTB BLKFLG(A5) ; do we support solid block? [104]
BEQ 55$ ; no [104]
CRT 49 ;
CRT 49 ;
JMP 25$ ;
55$: TYPE [] ; best we can do on this term [104]
JMP 25$ ; [104]
60$: TYPE < > ;
JMP 25$ ;
;***********
;* CHECK *
;***********
;Function: See if piece's new location is a collision
;
;Inputs: PROW(A5), PCOL(A5) - piece location (of top left corner)
; PADR(A5) - index to piece definition
;
;Outputs: Z - set if there is a collision
30$: CURSOR D4,D3 ;
CRT 40 ;
MOV D5,D0 ;
SUB D3,D0 ;
DEC D0 ;
32$: CRT 46 ;
SOB D0,32$ ;
CRT 41 ;
CRT 24 ;
REST D0-D5 ;
BOXRTN: RTN ;
;************
;* RANDOM *
;************
;Function: Generate random number between 0 and 9
;
;Outputs: D7 - number
;
;Notes: Automatically seeds self the first time it is run and
; periodically.
IF NE,256.-<.-RANTBL>,ASMERP "?Random number table does not contain right number of entries"
BYTE -1,-1,-1,-1,-1,-1,-1,-1,-1,-1
RADIX 8
;*****************************
;* piece shape definitions *
;*****************************
;This is where pieces are defined
;Each piece is defined in four rotations (0, 90, 180, 270 degrees)