bird@ihwpt.UUCP (09/03/87)
I need the outline of a routine that pokes characters into the keyboard buffer ($200-$2FF) and then transfers/calls a routine that will treat the line as having just been typed in. My main interest is the names and addresses of the routine(s) I call after the keyboard buffer is loaded. Joe Walters ihnp4!ihesa!bird
kamath@reed.UUCP (Sean Kamath) (09/09/87)
In article <1976@ihwpt.ATT.COM> bird@ihwpt.ATT.COM (J.L.Walters) writes: >I need the outline of a routine that pokes characters into >the keyboard buffer ($200-$2FF) and then transfers/calls >a routine that will treat the line as having just been typed >in. My main interest is the names and addresses of the routine(s) >I call after the keyboard buffer is loaded. > > Joe Walters > ihnp4!ihesa!bird Basically, it's call -141. In a less compact manner, here's S. H. Lam's technique in full: C$ contains a string, such as "300: A9 C1 4C ED FD". Then, gosub 1000 1000 C$ = C$ + " N D9C6G": REM SPACE NEEDED BEFORE AND AFTER 'N'!!! 1010 FOR I = 1 TO LEN (C$) 1020 POKE 511+I, ASC(MID$(C$,I,1)) + 128 1030 NEXT 1040 POKE 72,4: CALL -141: REM 72 CONTAINS THE STATUS BYTE. SEE BELOW! 1050 RETURN Now, about the poke 72,4. Well, it turns out that when you use G(o) in the monitor, whatever is in 72 goes into the P register when called. FOr years people said put a 0 there, but that was before interrupts were used much. Putting a 4 there turns off interrupts. You may not need to do that, so then put a 0 there! Now, the thing is, this is slow! So, a person called Clay Ruth developed a method of making it faster. It involved using the slow old way to create a machine language program to do it the fast way. Before I type that in, though, a man in Iowa!!!!! (Yeah, cheer cheer! (i'm from Iowa) ) did a much better job in a lot fewer bytes. Basically, the machine language program hooks into the ampersand routine, calls a lot of Applesoft stuff, and does the for_next loop without using the slow mid$ function. SO, in it's entirety: first, the machine code: ORG $300 0300: 20 7B DD JSR FRMEVL ; get a string in A. 0303: 20 00 E6 JSR FREFAC ; adr in INDEX 0306: AA TAX ; len to X 0307: A0 00 LDY #0 ; Y = 0 0309: B1 5E .1 LDA (INDEX),Y ; get a byte 030B: 09 80 ORA #$80 ; set high bit 030D: 99 00 02 STA $200,Y ; put in input buffer 0310: C8 INY ; next byte 0311: CA DEX ; any left? 0312: D0 F5 BNE .1 ; loop till done 0314: A2 04 LDX #$04 ; POKE 72,4 0316: 86 48 STX $48 0318: 4C 70 FF JMP $FF70 ; CALL -141 OK, now a little Applesoft to demonstrate: 10 REM LAM A'LA KASHMAREK 100 BELL$ = CHR$(7) 110 C$="0300: 20 7B DD 20 00 E6 AA A0 00 B1 5E 09 80 99 00 02 C8 CA D0 F5 A2 04 86 48 4C 70 FF N 3F6:00 03 N D9C6G" 200 PRINT BELL$: REM STANDERD LAM 210 FOR I = 1 TO LEN(C$); POKE 511+I,ASC(MID$(C$,I,1))+128:NEXT:POKE 72,4: CALL -141 220 PRINT BELL$ : REM LAM A'LA KASHMAREK 230 & C$ 240 PRINT BELL$ 250 END note: applesoft does a full expression evaluation, so you can just as well do: & c$+" N D96CG" as well as & "any normal monitor command" Hope this helps! Sean Kamath NOTE: All this comes out of Open-Apple (Releasing the Power to Everyone) which is a very worthwhile investement. I have no connection with them but as a subscriber. -- UUCP: {decvax allegra ucbcad ucbvax hplabs ihnp4}!tektronix!reed!kamath CSNET: reed!kamath@Tektronix.CSNET || BITNET: reed!kamath@Berkeley.BITNET ARPA: tektronix!reed!kamath@Berkeley <or> reed!kamath@hplabs US Snail: 3934 SE Boise, Portland, OR 97202 (I hate 4 line .sigs!)