Subject: Re: [TI994A] Ultima IV (WAAYYY off topic)

From: Owen Brand <[email-masked]>
Date: Wed, 3 Mar 2010 20:56:15 -0500

Yea--- that would be perfectly logical if all my keys were  
sequential... But I think I've narrowed the necessary usage down to 6  
keys accessible during "world-navigation"--- I should be able to  
handle these with minimal memory usage.

E-enter
I-inventory
M-map
T-talk
S-save gamestate
X-exit

I had thought about using just "M" for menu--- then having all this  
stuff outside the main gameloop--- but it would still eat up memory--  
it would still be there... Anyway, it'll be fun implementing this  
stuff.  :). I'll keep you appraised.

Owen Brand
Opry99er.com

On Mar 3, 2010, at 8:00 PM, Keith Bergman <[email-masked]> wrote:

> Owen, have you considered ON K-48 GOSUB 2000,3000,4000, 5000...  
> etc?  One line.
>
>
>
>
>
>
>
> On Wed, Mar 3, 2010 at 7:35 PM, Owen Brand <[email-masked]>  
> wrote:
>
> Really, I'm trying to do 2 things---
>
> 1) Keep my memory usage to a minimum... I will be requiring as much  
> memory as I can in this project so im trying to avoid a big string  
> of "IF K=56 THEN GOSUB 1000 :: IF K=57 THEN GOSUB 2000 :: IF......."  
> in my main gameloop.
>
> 2) I am looking for an assembly challenge to get me a bit further  
> into  the language, and this is an appropriate use of my time, as  
> this game is occupying 100% of my free time.
>
> I'm trying to use XB as a vehicle but drive it with assembly  
> support.... I know I should just go pure assembly, but to do that,  
> it would require me to start from scratch.  I know it doesn't make  
> sense to many experienced AL programmers, but I "GET" XB---it is  
> human-readable.  Maybe I SHOULD just do it all in assembly... But if  
> I can learn little things along the way, perhaps the learning curve  
> won't be as painful and won't halt my project until I can fathom the  
> AL language.  Lottrup's book has taught me alot--- but I haven't the  
> slightest clue as to how to even START an entire game in the  
> assembly language of our computer.
>
> Owen Brand
> Opry99er.com
>
> On Mar 3, 2010, at 7:14 PM, tursi <[email-masked]> wrote:
>
>>
>> > Is it possible to set up a keyboard interface in TMS9900 and have  
>> it
>> > function in XB?  For instance, if I wanted 10 keys to do specific
>> > things, but didn't want to use a ton of XB lines to do it, could  
>> I slap
>> > a CALL LINK into my game loop for keyboard check?  Of course this  
>> would
>> > require passing the info back into XB---might not be worth the  
>> effort.
>> >  Just curious....
>>
>> The answer is probably "of course", but the question is a little  
>> vague.
>> It's usually much easier to do the code in XB than ASM, but it  
>> depends
>> what you're actually looking for.
>>
>
>
>

---

From: tursi <[email-masked]>
Date: Wed, 3 Mar 2010 19:37:19 -0800 (PST)

> Yea--- that would be perfectly logical if all my keys were sequential... But I think I've narrowed the necessary usage
> down to 6 keys accessible during "world-navigation"--- I should be able to handle these with minimal memory usage.  
> E-enter
> I-inventory
> M-map
> T-talk
> S-save gamestate
> X-exit

There are two easy options. In one, you apply some fancy math and reduce 
those numbers down to an index (for instance, the first three, E,I,M, are 
all four characters apart. (chr-69)/4 would give 1,2,3 for them.

The other, simpler to solve and easier to extend, is to list all 
possibilities from A-Z. This is only 26 entries and would fit on a line. 
For the ones you don't want to do anything, they just branch to a function 
that does nothing (or maybe says 'invalid key'). I'll paste a listing 
below (it'll hopefully work). Note the ON..GOSUB for all 26 entries, 
assuming subroutines in the single-digit thousands, is still too long to 
enter naturally (25 entries works). So you need to do the trick of filling 
it to the end (use '1' for the last line number), then edit it. Of course, 
you could restrict the range more and use only valid values. The concept 
of this trick is just to do nothing with the invalid entries - they are 
only there as filler between the valid ones.

10 PRINT :"E - ENTER":"I - INVENTORY":"M - MAP":"T - TALK":"S - SAVE":"X - 
EXIT"

15 CALL KEY(0,K,S)
20 IF K<65 OR K>90 THEN 15

25 K=K-64 :: REM 'A' IS 65
26 PRINT

30 ON K GOSUB 1000,1000,1000,1000,2000,1000,1000,
1000,3000,1000,1000,1000,4000,1000,1000,1000,
1000,1000,6000,5000,1000,1000,1000,7000,1000,1000

40 GOTO 10

1000 REM - INVALID KEY, IGNORE, OR PRINT WARNING
1010 PRINT "-- INCORRECT KEY"
1020 RETURN

2000 REM ENTER
2010 PRINT "YOU ENTER THE PALACE!"
2020 RETURN

3000 REM INVENTORY
3010 PRINT "YOU ARE CARRYING:"
3020 PRINT " NO TEA"
3030 PRINT " CROSSBOW"
3040 PRINT " AN OVERDUE VHS TAPE"
3050 RETURN

4000 REM MAP
4010 PRINT "XXXXXX"
4020 PRINT "X X XX"
4030 PRINT "XX X X"
4040 PRINT "X XX X"
4050 PRINT "X   *X"
4060 PRINT "XXXXXX"
4070 PRINT :"* - YOU ARE HERE"
4080 RETURN

5000 PRINT "YOU ASK THE INTERESTING"
5010 PRINT "GENTLEMENT IF HE HAS SEEN"
5020 PRINT "ANY WALLBIES LATELY. HE"
5030 PRINT "SAYS YOU SHOULD BUY HIM"
5040 PRINT "A BEER."
5050 RETURN

6000 REM SAVE GAME
6010 PRINT "* SAVING GAME...."
6020 FOR A=1 TO 300 :: NEXT A
6030 PRINT "* NO, NOT REALLY."
6040 RETURN

7000 REM EXIT
7010 PRINT "DO YOU REALLY WANT TO EXIT?"
7020 PRINT "WELL, OKAY."
7030 END

---

From: Owen Brand <[email-masked]>
Date: Wed, 3 Mar 2010 22:56:39 -0500

Hahahah!!!!  You're hilarious!!! :). I love it... It makes perfect  
sense---and how did you know my game was based on Wallbies?!?  :)  No,  
but in all seriousness, using all the Keys in the range is a perfect  
idea... I will more than likely just have it make a funky sound and  
return back to the CALL KEY.... Since I plan to put a joystick  
function in there, there really won't be any need to use ESDX--- it  
might be a bit cumbersome for the user who plays this on the real TI,  
but it'll be much easier in emulation to use the arrow keys.  :).  
Thanks again--- I wouldn't have thought to use all the keys in a  
range-- my natural inclination would be to define as few keys as  
possible to minimize the number of calls--- but this is a perfect  
example of stepping back to go forward.  I think I just got my  
navigation interface, thanks man.  :)

Owen Brand
Opry99er.com

On Mar 3, 2010, at 10:37 PM, tursi <[email-masked]> wrote:

> sequential... But I think I've narrowed the necessary usage
> > down to 6 keys accessible during "world-navigation"--- I should be  
> able to handle these with minimal memory usage.
> > E-enter
> > I-inventory
> > M-map
> > T-talk
> > S-save gamestate
> > X-exit
>

---

From: tursi <[email-masked]>
Date: Wed, 3 Mar 2010 20:17:49 -0800 (PST)

> Hahahah!!!!  You're hilarious!!! :). I love it... It makes perfect sense---and how did you know my game was based on
> Wallbies?!?  :)  No, but in all seriousness, using all the Keys in the range is a perfect idea... I will more than

hehe.. I like wallbies. ;)

Glad it was useful! It was fun to do.

---

From: ti99_forever <[email-masked]>
Date: Wed, 3 Mar 2010 22:28:47 -0800 (PST)

I prefer:
ON POS("EIMTSX",A$,1)+1 GOSUB... for this example.
the +1 takes care of A$ NOT being in the list of possibilities, A$ of course being the command that was entered.

--- On Wed, 3/3/10, tursi <[email-masked]> wrote:

> From: tursi <[email-masked]>
> Subject: Re: [TI994A] Ultima IV (WAAYYY off topic)
> To: "[email-masked]" <[email-masked]>
> Date: Wednesday, March 3, 2010, 10:37 PM
> > Yea--- that would be perfectly
> logical if all my keys were sequential... But I think I've
> narrowed the necessary usage
> > down to 6 keys accessible during "world-navigation"---
> I should be able to handle these with minimal memory usage.
>  
> > E-enter
> > I-inventory
> > M-map
> > T-talk
> > S-save gamestate
> > X-exit
> 
> ------------------------------------
> 
> Yahoo! Groups Links
> 
> 
>     [email-masked]
> 
> 
>

---

From: "Tursi" <[email-masked]>
Date: Thu, 4 Mar 2010 02:47:42 -0800

> the +1 takes care of A$ NOT being in the list of possibilities, A$ of 
> course being the command that was entered.

Ahhh.. there you go.. that's much cleaner. :) I was coming at it backwards, 
from a jump table perspective. :)

---

From: Keith Bergman <[email-masked]>
Date: Thu, 4 Mar 2010 07:37:20 -0500

THAT is slick.  Thank you, sir, I can see that being in my toolbox forever
now.

---

From: Owen Brand <[email-masked]>
Date: Thu, 4 Mar 2010 08:49:15 -0500

Ahhh yea...  :) see?  There IS an XB guru here.  :)

Owen Brand
Opry99er.com

On Mar 4, 2010, at 1:28 AM, ti99_forever <[email-masked]> wrote:

> the +1 takes care of A$ NOT being in the list of possibilities, A$  
> of course being the command that was entered.
>

---

From: mark wills <[email-masked]>
Date: Thu, 4 Mar 2010 09:54:51 -0800 (PST)

Damn, you beat me ;-)

----- Original Message ----
> From: ti99_forever <[email-masked]>
> To: [email-masked]
> Sent: Thu, 4 March, 2010 6:28:47
> --- On Wed, 3/3/10, tursi wrote:
> 
> > From: tursi 
> > To: "[email-masked]"

---

From: mark wills <[email-masked]>
Date: Thu, 4 Mar 2010 09:54:05 -0800 (PST)

Put your keypresses in a string and use POS with ON...

KEY$="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
CALL KEY(0,K,S)
IF S<>0 THEN K=POS(KEY$,K,1) ELSE K=0
IF K>0 THEN ON K GOSUB XXX,XXX,XXX,XXX,XXX,XXX,XXX,XXX

Now you can use ANY key you like, and YOU determine it's value, from it's position in KEY$

Do you see how that works?

I also re-used the variable K ;-)

HTH

----- Original Message ----
> Sent: Thu, 4 March, 2010 4:17:49

---

From: Insane Multitasker <[email-masked]>
Date: Thu, 4 Mar 2010 23:50:31 -0600

Execution speed may dictate use of one over the other. 

You can also handle lower case characters using Ben's example with a twist:

ON INT(POS("EeIiMmTtSsXx",A$,1)/2+.5)+1 GOSUB...

IIRC .5 will be needed to round up the INT value.

Tim

> From: [email-masked]
> Date: Thu, 4 Mar 2010 02:47:42 -0800
 		 	   		  
_________________________________________________________________
Hotmail: Free, trusted and rich email service.
http://clk.atdmt.com/GBL/go/201469228/direct/01/

---

From: "Jacques Groslouis" <[email-masked]>
Date: Fri, 5 Mar 2010 06:55:23 -0400

Tim,

There is another way of accepting either upper or lower case keys by 
including CALL KEY(3,K,S) in your program. By setting the key unit to 3 all 
key presses are accepted as upper case.

Regards,

Jacques

Nominate someone to your TI99HOF
Check out www.ti99hof.org

----- Original Message ----- 
From: "Insane Multitasker" <[email-masked]>
To: <[email-masked]>
Sent: Friday, March 05, 2010 1:50 AM
Subject: RE: [TI994A] Ultima IV (WAAYYY off topic)

Tim

---

From: Insane Multitasker <[email-masked]>
Date: Sun, 7 Mar 2010 16:25:35 -0600

Thank you, Jacques, I had forgotten about the key modes.

I substituted mode 3 in the program I'm writing and was
able to simplify my scan loop a bit.  Now the largest line
in my program is only 8 lines of code.  <grin>

Tim

> From: [email-masked]
> Date: Fri, 5 Mar 2010 06:55:23 -0400

---

From: Insane Multitasker <[email-masked]>
Date: Sun, 7 Mar 2010 17:44:35 -0600

I did find some interesting results along the way.  My keyscan
loop was using POS to branch to a routine like this:

"3020 CALL KEY(3,K,S)::IF S<1 THEN 3020 ELSE Q=POS("XSDEQ ",CHR$(K),1)+1 :: ON Q GOTO 3020,3030,3030,3030,3030,1000,2100"

From a computational perspective, 1000 iterations of the Q=POS...
statement requires approximately 33 seconds to process.  Because
my routine is timing-sensitive I decided to pre-process the keypress
positions:

"50 DIM R(100)"
"60 A$="XSDEQ "::FOR I=1 TO LEN(A$)::R(ASC(SEG$(A$,I,1)))=I::NEXT I"
...
"3020 CALL KEY(3,K,S)::IF S<1 THEN 3020 ELSE Q=R(K)::ON Q+1 GOTO 3020,3030,3030,3030,3030,1000,2100"

The array assignment requires approximately 6 (six) seconds to 
process 1000 iterations.  Nearly a six-fold improvement.  Because
unassigned values are ==0, there is no need to process all keys

I'm sure there are even more ways to "skin the cat" the fun is locating them :)

Tim

To: [email-masked]
From: [email-masked]
Date: Sun, 7 Mar 2010 16:25:35 -0600
Subject: [TI994A] CALL KEY and POS

Tim

> > from a jump table perspective. :)
 		 	   		  
Hotmail: Free, trusted and rich email service. Get it now.

 		 	   		  
_________________________________________________________________
Hotmail: Trusted email with powerful SPAM protection.
http://clk.atdmt.com/GBL/go/201469227/direct/01/

---

From: "Jacques Groslouis" <[email-masked]>
Date: Sun, 7 Mar 2010 20:03:58 -0400

Tim,

(28 * 5) + 23 = 163

Others will think that we are learning to talk in a numeric language.<bigger 
grin>

Jacques

----- Original Message ----- 
From: "Insane Multitasker" <[email-masked]>
To: <[email-masked]>
Sent: Sunday, March 07, 2010 6:25 PM
Subject: [TI994A] CALL KEY and POS

Tim