[comp.sys.handhelds] HP48: new ML tetris in ASC format

nelson@skid.ps.uci.edu (Matt Nelson) (04/12/91)

for those who asked, here is the tetris library in ASC format. if you
missed it, the controls are as follows:

  left shift:	flip
           4:	flip
           5:	left
           6:   drop (hold down)
           *:	right

%%HP: T(3)A(R)F(.);
"04B20A151060455445259435604A64100000000D7000D3100E4A20E600000000
0000000000000001400000000000000000000000000000000000000000000000
0000000000041000503545142747000F0000E4A20E1000020006B000FD000431
003C90084A6000D9D20E163229E204A6300634E1DCC0247A20E4A20510000000
000000000000E4A20510000000000000000000B21300F2E129E204A6200CB2A1
29E204A64008DBF14B2A2F17A18DBF193632B2130D9D20E16323392030000000
000007108441293632B2130C2A2055000B001753110120001000003132333430
8500410004100033343536373839303132333435363738393E1B20F880004000
380000000000800000000000080000000000D700000000808FBFDFD348380000
0000001500000000800480024444480000000000170000000041048002444408
00000000001000040000220480024444080000000000D70004000014048702C3
4838000000000011000400080804800242404800000000009200040000140480
0242404800000000005400040000E3048002444448000000000010000A000014
048F1244483800000000001100040000E3000000000008000000000011000400
0022040F02403938000000000011000A00002204881240354800000000001000
0110001404001240350800000000001700842000140400124055080000000000
150040400014040C12C355080000000000D70021900014040012445508000000
00001000209008080400124495080000000000D70065C0080804881244954800
000000001000208008088F3FCFD3993800000000001000415004001000000000
0800000000001000404C0500500000000008000000000010000F121EFF300000
00000800000000001000802C020020000000000800000000001000CF7C020020
000000000800000000001000208C020020000000000800000000001000208C01
0044000000000800000000001000CF7298888400000000080000000000100040
432555540089DDC1080000000000100040C44222240044455008000000000010
00504882222400844DC1080000000000100050A013222A000545500800000000
001008201162222400C8D5D10800000000001004482285222400000000080000
0000001002882406222400EFFFFF380000000000100288481CFF3A0020000028
0000000000100288806400411020000028000000000010044011820080202000
00280000000000100830EFF1008020200000280000000000100440200FBBB020
200000280000000000100280EFF5444110200000280000000000100101200AAA
AE00200000280000000000100280100AAAAA00EFFFFF38000000000010044010
0CAAAA00000000080000000000100C78000CAAAA00449EC00800000000001004
48000CAAAA0044B2200800000000001004480004AAAA0044FE40080000000000
100444708BFFFA0044D2800800000000001004448F78008F30C59E6008000000
000010044C888800802000000008000000000010044C888C008020EFFFFF3800
00000000100444555D004040200000280000000000100444555D004040200000
280000000000100444555D002080200000280000000000100444555B00208020
0000280000000000100444265B001001200000280000000000100444222A0010
0120000028000000000010044C322F001001200000280000000000100444CFF8
001001EFFFFF380000000000100444000800100100000008000000000010044C
300F001001000000080000000000100444CFF800100100000008000000000010
0444000800100100000008000000000010044400080010010000000800000000
00100CCD2019A008FFBA818FB97608EE4408E9A808E188061308E47508E84608
F75D0034F00008E9A60808B135808A04D8E4C703462000C281AF0C8E6F1081A2
1B92E628E7C1034F0000DA8E0660808808EB6606B8F8E84308C8730D2D980824
0FF000EF6320209B293320119B633819F0D6F0CA34000008E7060C2D080820F0
E60C213401D2013200F81A20BD20115C016F16F161158016F16F161158016F16
F16115C001AE215E096AD03200F81A20B0181AF1CD581B580824F3800CAD9F6F
6F6CAC6C6C2135147D7315081A60AAEB808A3958EA0FFD08082038B66481A61B
808A1E08ED7FF8CF200808A07130F8082098E43FF8C31003008082008EF1FFAE
B808A251808B0B0A6D8C7000B65AEB808A1B1808B0E081839F8CA00081831F81
A61AA6EF796A008C74FF30181A60B8C40FFAE281A60B8C5FEF3220081A30B8C4
EEF8EADFF81AF1C0681832F81AF0C8EFCFF81A21B92A6334F0000DA8EF340808
908EA4400781AF0C8EE7FF8E1E408C4F50078EA6FF8CE9608ED6FF81B5808249
4700CA81AF1C06F6F6F6C6C2135D215F1F2F2F281A31C81AF0C66408E62FF81B
580824CC600CA81AF1C06F6F6F6C6C2135D215F1F2F2F281A31C81AF0C8E2FEF
81A21B92AC0070681AF0C078E7BEF0134F0000DA8EE430808918CD5308E4AEF8
1AF1C0681862081AF0C8C5AFF8E48EF81AF1C068186A081AF0C8C58FFD230480
18F06110DAD280196C7E018F735608080142164808C80808F2D760142164808C
8F2D76014313216914681AF08132174E78FB9760018D7BC8114713514334C2A2
08A66E17913381AF008F75D008EC70081AF103450000C2134D01401641408082
48200081AF18C213434E10001443456507134146808249E000E280824000008E
E020341000080824F00008CBF1034E100081AF10C21353483100134146808240
0C700EF61418082400C700EF281AF0901344100081AF10C2135AE215F096EE0B
6615D0AE201B6680821709E6B01590AE20115D031F0013483100134146808240
0E700EF281AF118A20081AF09D23048018F06110DAD28018086102343200081A
F10C21358EC7308CEC008086311724F96E60621D0180860117C2F96E606E7D01
8086211761F96E60688D018086511700F96E60698C01344100081AF10C2135AE
215D00134E100081AF10C213534831001341468082408F000EF21438A2001453
43200081AF10C2135147CE1458AE00348200081AF10C21341461458CB8BF81AF
20C281AF201351470181AF28CA81AF28131145018AA45D7C7C7F2819F2DAF2CA
34000008EFAFFCA340F000CA1313488000C213415F915C93422000EACF8AFBD3
4000008E07FF8082421100CA3440000D7130AF215C93422000CACF8AF8E01340
00008E23FF80824A0900CA3101AE7131147D51741470EF5FE8AA91A6F3488000
EA96F8D8C7A00D2AEB06CE8EC0FF07AE78E6010659F344010013414680824F00
000EF6D881B4347E100C2C9135D015B0F0F0F00181B580824DF100CAD230F0EF
7D5C6C6C9C21343150D514615D0F61CF1CF1C1A6D96DBE0134A000081AF10CA1
30146D734F78006120345000081AF10CA130146D734F560081AF10131143C206
315081A62A07135CE068EF4FFF781A62AA6E96EDD070181AF1034A0000C21341
4605E61440504D080820F0EF296E00348200081AF10C213414234600008B2008
18F8414001D581AF103450000C213414605E61440504017AAA84DDD86DDB8DAA
802BDD83AAD84DDA85CAA8ADD807AAC85CAC8ADA804DAD85ACA8DAC803EDD83E
DA84DDE83ADE810003040502070809060B0A0D0C0E0011121F0FECA6261EC2F1
26A10005020304090607080B0A0D0C0E021F0011125552722237174774747447
55747177571611247757577475781C93CFE"

akcs.gandalf@hpcvbbs.UUCP (Rakkiat Trimahaloek) (04/16/91)

For the new ML tetris the keys is just the same with PC version
I have. I loved it.

For all guys complaining about rotate key. It has two rotate keys.
The one which you complained is '6' key. The other one I use is 
'left shift' key( the orange one) which rotate in the same manner
as PC tetris.

If you still don't like it, let's hack it now.
For me! I'll do it in this summer this time is for exam...

akcs.falco@hpcvbbs.UUCP (Andrey Dolgachev) (04/17/91)

Well, I thought about taking the ML Tetris apart to see what made it tick
(and take a look at the routines).  So, I started by making the library
into a directory.  What I found was a USERLANG program, a configuration
program (17000 ATTACH), a string, a GROB, and a machine code routine. 
Now, maybe some of you have cautght on to the imortatnt part?  Well, I'll
giv you another hint, remember how the ON key does not function wile
playing Tetris?  Not yet, wel, if you look at the Start program, the
USERLANG program that is, you find that it recalls the string to the
stack, and then executes the machine code routine.  And, finally, if you
haven't caught on yet, the string can't be visited or edited because you
"can't edit null character".  Unfortuantely, I have the old version of
CHIP48, not 2.25, so I wasn't able to make sure if ML Tetris reallly is a
CHIP program or not, but it sure does seem like it, don't it?    I would
appreciate it if somebody takes a llok and sees if the string can be run
with their CHIP or if one of ttheir chip games can be run with the code
segment in ML Tetirs.  The library can be recalled as a directory by
using the RCLLIB program in HACKIT, posted by a kind soul a few days ago.
  Also, it looks like I'm going to have to delve into machine code to
speed up my Tetris.  BTW, it looks like the main speed increase is not
the speed of the actual routines, like the rotating or moving routines ,
but the speedup comes about from the way that key-presses arehandled. 
THe partial ML Tetris uses KEY, which doesn't care if you you hold down
the the ke.  Becuase of this,  there's a noticeable lag and you have to
repeatedly press the keys.  Anyways, I tried making the rotate function
do contnuous and it was very fast (you could barely see the piece when it
rotated) so it look slike I'm going to have to modify my key-handling
routine with ML.  Unless a kind soul has info on pokeing the key buffer
and directly polling the status of keys from ML or RPL, it looks like I'm
going to be spending some time manuallly dissambling the KEY routine. 
However, it's good that there is a faster Tetirs out (which means better)
, after all, competition always improves the product.
        ---Falco

stevev@greylady.uoregon.edu (Steve VanDevender) (04/17/91)

The new ML Tetris is not a CHIP48 program.  For one thing, CHIP48
is limited to 32x64 resolution, while the ML Tetris clearly
operates in full 64x131.  I don't know what the string does, but
it doesn't appear to be a valid CHIP48 program and the code
object is not just a copy of CHIP48.
--
Steve VanDevender 	stevev@greylady.uoregon.edu
"Bipedalism--an unrecognized disease affecting over 99% of the population.
Symptoms include lack of traffic sense, slow rate of travel, and the
classic, easily recognized behavior known as walking."

bson@rice-chex.ai.mit.edu (Jan Brittenson) (04/17/91)

In a posting of [16 Apr 91 21:40:06 GMT]
   akcs.falco@hpcvbbs.UUCP (Andrey Dolgachev) writes:

 > if you look at the Start program, the USERLANG program that is, you
 > find that it recalls the string to the stack, and then executes the
 > machine code routine.

   The string is probably just some configuration data, or used for
data storage in the ML program.

 > The partial ML Tetris uses KEY, which doesn't care if you you hold down
 > the the ke.  Becuase of this,  there's a noticeable lag and you have to
 > repeatedly press the keys.

   The lag is probably from the time it takes for the RPL program to
dispatch the proper code. I don't know how you do it, but GET, POS,
and similar commands are slow (say, 1/4 s) when the argument is a
list. You would do better to rewrite the code so that the functions
that are called when keys are pressed are called:

	KEY1F		For the 7 key
	KEY22		For the / key
	KEYFF		For no key

   Then have a string "KEYxx", and pass it to an ML routine that picks
the next key in the keyboard buffer and overwrites the last two digits
of the string with its scan code, in hex. Let the ML program end by
jumping to the SYSEVAL address plus suitable offset, to convert it to
a name. Then in your main RPL program, when the ML keyboard routine
returns, simply do an EVAL. Also let the ML program ignore undefined
keys. So, your RPL program would look like:

	<< ... "KEYFF" MLGETKEY EVAL ... >>

 > However, it's good that there is a faster Tetirs out (which means
 > better), after all, competition always improves the product.

   Personally, I prefer cooperation to competition. Your mileage may
vary.

   Included below is some basic info on the HP-48 keyboard, stuff that
I have accumulated for a future posting on the matter. So don't be
surprised if this reappears one day, in some mutated shape & form.

Good luck!
						-- Jan Brittenson
						   bson@ai.mit.edu


;;+
;;
;; Keyboard Interface.
;;
;; Keyboard scan codes are numbered 1 for [A], 2 for [B], 3 [C]...
;; #19h [ENTER]... #1Fh [7]... #31h [+]. [alpha] is #80h, [yellow] is
;; #40h, and [blue] is #C0h. ON has no scan code.
;; 
;; This program reads the keyboard buffer. If a key is present, it
;; returns it in A.A. If no key is present, it enters light sleep and
;; waits for one.
;;
;; kb_poll polls the keyboard buffer, carry set if non-empty, key in A.A.
;; kb_get does the same, but waits until a key is pressed.
;;
;; Jan Brittenson, April 1991
;; This program is in the Public Domain
;;
;;-

	radix	^d16

event_mask = 10e

;; Poll keyboard buffer

kb_poll:
	move.5	keybuf+1, d0	; KB Put ptr
	move.s	@d0, a		; A.S = put ctr
	dec	d0
	move.s	@d0, c		; C.S = get ctr
	breq.s	c, a, $100	; Ctrs are equal - buffer empty

	move	c.15, p		; P = get ctr
	inc.s	c		; Remove key
	move.s	c, @d0

	swap	c, d0
	add	p+1, c
	add	p+1, c		; C += get ctr, in bytes
	clr	p
	move	c, d0		; D0 = &next key
	clr.a	a
	move.b	@d0, a		; A.A = key
	retsetc
$100:
	clr.a	a
	retclrc

;; Wait for a key to become pressed, then return scan code in
;; A.B. Uses C.A and B.B.

kb_get:
	call	kb_poll		; Get key, if any
	retcs			; Return if there was a key in the buffer

; No keys are down - enter light sleep

	move.5	event_mask, d0
	move.p1	8, c
	move.1	c, @d0
	rsi
	shutdn			; Go asleep
	move.p1	0xc, c		; Restore event mask
	move.1	c, @d0
	jump	kb_get		; Check buffer again


 O  /
  \/
  /\  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 O  \


	     (IN) #20 #10 #08 #04 #02 #01


	(OUT)	   6   5   4   3   2   1

	#100	9      B   C   D   E   F

	#080	8     PRG CST VAR  up NXT

	#040	7     STO EVL <<< dwn >>>

	#020	6     COS TAN sqt pwr inv

	#010	5 ON* ENT +/- EEX DEL <==

	#008	4 alp SIN  7   8   9   /

	#004	3 yel MTH  4   5   6   x

	#002	2 blu  A   1   2   3   -

	#001	1      '   0   .  SPC  +


   (*) The ON key is actually in a column of its own.
   #xxx refers to the keyboard scan bits. The column
   scan bit for the ON key is #8000.



   The keyboard bit pattern at #704DD is updated whenever a key is
pressed. There are 13 nybbles, 4 bits each, making 52 bits. There are
49 keys, so three bits are unused. The first bit isn't used, the next
corresponds to the bottom rightmost key [+], the one following
corresponds to SPC, then comes period [.], [0], ['], after which
immediately follows the next row - [-], [3], and so forth, up to the
upper leftmost key, which is [B]. (See figure above for the physical
layout of the keyboard). Below is a table of all key bit codes. More
than one bit is set if more than one key is being held down
simultaneously.



  Key    704E7 704E2 704DD 	      Key    704E7 704E2 704DD 

   B    |  1  |     |     |           <==   |     |   1 |     |
   C    |   8 |     |     |	      alp   |     |    8|     |
   D    |   4 |     |     |	      SIN   |     |    4|     |
   E    |   2 |     |     |	       7    |     |    2|     |
   F    |   1 |     |     |            8    |     |    1|     |
  PRG   |    8|     |     |            9    |     |     |8    |
  CST   |    4|     |     |            /    |     |     |4    |
  VAR   |    2|     |     |           yel   |     |     |2    |
   up   |    1|     |     |           MTH   |     |     |1    |
  NXT   |     |8    |     |            4    |     |     | 8   |
  STO   |     |4    |     |            5    |     |     | 4   |
  EVL   |     |2    |     |            6    |     |     | 2   |
  <<<   |     |1    |     |            x    |     |     | 1   |
  dwn   |     | 8   |     |           blu   |     |     |  8  |
  >>>   |     | 4   |     |            A    |     |     |  4  |
  COS   |     | 2   |     |            1    |     |     |  2  |
  TAN   |     | 1   |     |            2    |     |     |  1  |
  sqt   |     |  8  |     |            3    |     |     |   8 |
  pwr   |     |  4  |     |            -    |     |     |   4 |
  inv   |     |  2  |     |            '    |     |     |   2 |
  ENT   |     |  1  |     |            0    |     |     |   1 |
  +/-   |     |   8 |     |            .    |     |     |    8|
  EEX   |     |   4 |     |           SPC   |     |     |    4|
  DEL   |     |   2 |     |            +    |     |     |    2|


						-- Jan Brittenson
						   bson@ai.mit.edu

pashdown@javelin.sim.es.com (Pete Ashdown) (04/17/91)

akcs.falco@hpcvbbs.UUCP (Andrey Dolgachev) writes:

>CHIP48, not 2.25, so I wasn't able to make sure if ML Tetris reallly is a
>CHIP program or not, but it sure does seem like it, don't it?

No, it doesn't.  Reason #1: Screen resolution.
-- 
      /       "Uhh" - Jon Bon Jovi         \       THISSPACEHASBEENRENTEDTHISS
\\  /  AMGIA!!  The computer for the mind. \X v//  PAC  SMiles! from Ilana EHA
 |XV       [FREE CD'S! SEND ME MONEY!]       X\/   SBEENRENTEDTHISPACEHASBEENR
Pete Ashdown  pashdown@javelin.sim.es.com ...uunet!javelin.sim.es.com!pashdown

d90perko@odalix.ida.liu.se (Per Konradsson) (04/18/91)

The only thing that the string on the stack does is to allocate memmory
to the ML program.

/Per Konradsson Author of ML-Tetris.

.