[vcf-midatlantic] 2:00am BASIC epiphany
Henry S. Courbis
info at reactivemicro.com
Fri Aug 31 05:30:50 EDT 2018
>just another English major
You're a Major in the English Army? Didn't strike me as the sort of chap.
Henry S. Courbis
Office Toll Free: (800) REACTIVE (732-2848)
Office/Mobile Direct: (856) 779-1900
www.ReActiveMicro.com <http://www.ReactiveMicro.com> - Sales, Support, and
News, Our Headquarters on the Internet
ReActiveMicro.com/wiki - Support, Software, Manuals, and History. Create
your own page today!
Facebook.com/reactivemicrousa - Our Social Media Outlet and Support
On Thu, Aug 30, 2018 at 11:30 PM, Evan Koblentz via vcf-midatlantic <
vcf-midatlantic at lists.vcfed.org> wrote:
> I had a spontaneous idea tonight for removing two lines of my Lego robot
> As usual, this epiphany on my part is probably TOTALLY FRIGGIN' OBVIOUS to
> most of you, but I'm proud that I figured it out on my own. :)
> Before, on the forklift robot, this was my code for checking the
> upper/lower touch sensors (limit switches) and moving the forklift motor
> appropriately. I had it at 9 lines (not counting REMarks) which was greatly
> reduced from Dan R.'s original 16 lines.
> 3010 IF PEEK (49249) > 127 AND PEEK(L) = 64 THEN RETURN
> 3020 IF PEEK (49249) > 127 THEN POKE L,16
> 3030 IF PEEK(L) = 80 THEN RETURN
> 3040 IF PEEK(49249) > 127 THEN GOTO 3020
> 3050 IF PEEK(49250) > 127 AND PEEK(L) = 128 THEN RETURN
> 3060 IF PEEK(49250) > 127 THEN POKE L,32
> 3070 IF PEEK(L) = 160 THEN RETURN
> 3080 IF PEEK(49250) > 127 THEN GOTO 3060
> 3090 RETURN
> Background: In that code, PEEK(49249) in Applesoft checks joystick button
> 0 and PEEK(49250) checks button 1. If their value is greater than 127 then
> you know they're currently being pressed. PEEK(L) checks the value at the
> address of the interface card. 64/128 are the sensors attached to ports
> (bits) 6 and 7, respectively. POKE L,16/32 turns on the motor (in opposite
> directions) that's attached via a connector spanned to ports 4/5. Lines
> 3030 and 3070 stop the motors if the sensors become active ** while ** the
> motor is moving, because then the total value being read from the interface
> box is sensor + the motor.
> The idea that popped into my head tonight: you can combine lines 3010/3020
> into one, and also lines 3050/3060 into one, thereby reducing the routine
> by two lines and having the same effect.
> 3010 IF PEEK (49249) > 127 AND PEEK(L) <> 64 THEN POKE L,16
> 3020 IF PEEK(L) = 80 THEN RETURN
> 3030 IF PEEK(49249) > 127 THEN GOTO 3010
> 3040 IF PEEK(49250) > 127 AND PEEK(L) <> 128 POKE L,32
> 3050 IF PEEK(L) = 160 THEN RETURN
> 3060 IF PEEK(49250) > 127 THEN GOTO 3040
> 3070 RETURN
> So instead of saying, "Exit the routine if the lower/upper touch sensors
> are active, which we know is true if the value at address L is 64 or 128,"
> instead I'm saying, "Turn on the motor ** ONLY IF ** the lower/upper touch
> sensors aren't active."
> I can't test it until this weekend at the soonest, but I am ** pretty sure
> ** it'll work -- or at least I don't see any obvious reason why it would **
> not ** work. After all, the forklift motor can't turn on when either sensor
> is active, because I'm not programmatically allowing it -- right?
> If it works, then I'll convert it to IBM BASIC too. The button PEEKs
> become STRIG (stick trigger) values, and the POKEs become OUT.
> Saving two lines of interpreted / non-compiled BASIC isn't going to have
> any significant impact on program execution speed or disk space, but it
> makes the code that much easier for non-programmers to understand, and it
> gives me that much more confidence of about being than just another English
> major. :)
More information about the vcf-midatlantic