Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!think.com!linus!snorkelwacker.mit.edu!ai-lab!rice-chex!bson From: bson@rice-chex.ai.mit.edu (Jan Brittenson) Newsgroups: comp.sys.handhelds Subject: Re: HP48: new ML tetris in ASC format Message-ID: <14972@life.ai.mit.edu> Date: 17 Apr 91 04:37:34 GMT References: <1991Apr15.061548.12826@colorado.edu> <280a9907:2787.1comp.sys.hand <280b63a2:2787.2comp.sys.handhelds;1@hpcvbbs.UUCP> Sender: news@ai.mit.edu Organization: nil Lines: 196 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