# 19 Carrots of Gold

## Recommended Posts

Exsqueeze me. Bugs Bunny fan art parody. Ha ha ha ...

Edited  by sometimes99er

##### Share on other sites

That's pretty cool, for a noob, can you explain it line by line?

I get most of it.

Why 9^9?

Sub and subend?

Why call char, display at and sprite? Is that the only way to do 3 colors?

Edited by Sinphaltimus

##### Share on other sites

Exsqueeze me

```! 19 Carrots of Gold, 2016.09.01 sometimes99er
100 call screen(11)::call clear::call magnify(3)::call color(9,10,1,10,3,1)
110 call char(97,"000000000000000E0F1F1B3D367860800080808",104,"000000507870F8C")
120 call char(100,"0000000007080810122124434CB0C00038544246829C60202020C")
130 for i=1 to 19::call carrot(i,int(rnd*22),int(rnd*27))::next i::for i=0 to 9^9::next i
140 sub carrot(i,y,x)::display at(y+1,x+1):"ah"; ::display at(y+2,x+1):"bc"; ::call sprite(#i,100,2,y*8+3,x*8+16)::subend
run

```

Cute, I copied and pasted it into JS99er and let it run.

##### Share on other sites

That's pretty cool, for a noob, can you explain it line by line?

Thanks, and no, it's really basic.

I get most of it.

Phew.

Why 9^9?

Instead of going to a new line with a GOTO looping forever. Squeezing the number of lines. 9^9 is just a really big number.

Sub and subend?

You have to look in the manual. Could have used GOSUB, or embedded the code, but SUB is so nice.

Why call char, display at and sprite? Is that the only way to do 3 colors?

You can toggle patterns 60 times a second to get 3 colors (flickers but some combinations are better than others).

Edited by sometimes99er

##### Share on other sites

Cute, I copied and pasted it into JS99er and let it run.

Thanks. Didn't know you could paste in js99er. Cool.

##### Share on other sites

Neat, not bad for such tight code. Could you add a bunny?

##### Share on other sites

Thanks. Didn't know you could paste in js99er. Cool.

Yep, just highlight the text here and copy, either from the menu, or ctrl C and then go into Exbasic in JS99er.net and cntrl V and wha-La.

a bastardized english version of the French word "voila" meaning "there it is"

Often used by morons (me) in an attempt to sound more intelligent than they actually are.

Incidentally, voila sounds phonetically like whala hence the improper spelling.

Edited by RickyDean

##### Share on other sites

Neat, not bad for such tight code. Could you add a bunny?

Thanks. And yes, I could add a bunny, but it would double the size of the program. And next thing would be to animate the bunny and make it a game. Let's just say it's on my list.

##### Share on other sites

Thanks. And yes, I could add a bunny, but it would double the size of the program. And next thing would be to animate the bunny and make it a game. Let's just say it's on my list.

Yeeeah, I just want to animate a little 8x8 character running across the screen...... lol.

##### Share on other sites

Yeeeah, I just want to animate a little 8x8 character running across the screen...... lol.

Which you've done so nicely. And it motivated me to look more into platformers.

Edited by sometimes99er

##### Share on other sites

Which you've done so nicely. And it motivated me to look more into platformers.

I remember boots like those!

Theme song....

##### Share on other sites

Regarding SUB and SUBEND...

Subprograms are a unique feature of TI Extended BASIC. Basically, you can write your own subprograms just like CALL HCHAR, CLEAR, SCREEN are. You can pass values into the subprogram, both to use and to pass back values.

My favorite use of subprograms, which I do in almost every program:

1000 SUB WAIT(W):: FOR I=1 TO W :: NEXT I :: SUBEND

A delay subprogram, cuts down on the amount of code space wasted on FOR/NEXT loops

1000 SUB SND(S):: ON S GOTO 1010,1020,...

1010 CALL SOUND(100,110,2):: GOTO 1999

...

1999 SUBEND

A sound subprogram, all the game's sounds are contained in a single large block and can be called by using an ID number

##### Share on other sites

Regarding SUB and SUBEND...

Subprograms are a unique feature of TI Extended BASIC. Basically, you can write your own subprograms just like CALL HCHAR, CLEAR, SCREEN are. You can pass values into the subprogram, both to use and to pass back values.

My favorite use of subprograms, which I do in almost every program:

1000 SUB WAIT(W):: FOR I=1 TO W :: NEXT I :: SUBEND

A delay subprogram, cuts down on the amount of code space wasted on FOR/NEXT loops

1000 SUB SND(S):: ON S GOTO 1010,1020,...

1010 CALL SOUND(100,110,2):: GOTO 1999

...

1999 SUBEND

A sound subprogram, all the game's sounds are contained in a single large block and can be called by using an ID number

Whoa. I only ever used gosub and return in ti xb.

So sub and subend is like a script you can pass arguments to but it's self contained with in the program? (I know it doesn't have to be, they can be called from a file on disk)

Ok, this is something new I need to learn.

Awesome stuff. Thanks!

##### Share on other sites

Which you've done so nicely. And it motivated me to look more into platformers.

Wow, thanks man. That means a lot coming from you. As for me, I can make them, but I can't wear them. 6' 300 lbs is not graceful enough for wearing them I think. Edited by Sinphaltimus

##### Share on other sites

Whoa. I only ever used gosub and return in ti xb.

So sub and subend is like a script you can pass arguments to but it's self contained with in the program? (I know it doesn't have to be, they can be called from a file on disk)

Ok, this is something new I need to learn.

Awesome stuff. Thanks!

Yeah, subprograms are contained in the program. They have to be at the end of the program listing as well, but they can also be outside the pre-scan.

Oh, what's pre-scan? Pre-scan is detailed in the little addendum XB manual. Basically, you can cut down on the time for the program to start running by reducing the amount of your program scanned ahead of time for memory allocation.

The pattern you typically see of programs using it is the first block of statements are all variable/array declarations and all sub programs (built-in ones) used. That lets the pre-scan know everything it has to allocate memory for. Then it is turned off for the bulk of the program until the end, where any DATA and IMAGE statements are, as well as custom subprograms.

##### Share on other sites

Really cool, sometimes99er!!! Hoping for a new Rabbit Trail... One that has a bit of replay value.

A challenge for you, Sinphaltimus... Write your own CALL CLEAR subprogram, and replace it in the following code chunk:

100 CALL CLEAR

110 PRINT "I CAN WRITE A NEW SUBPROGRAM!!"

120 END

Replace CALL CLEAR with a SUB of your own design and call it CLR.

##### Share on other sites

Really cool, sometimes99er!!! Hoping for a new Rabbit Trail... One that has a bit of replay value.

A challenge for you, Sinphaltimus... Write your own CALL CLEAR subprogram, and replace it in the following code chunk:

100 CALL CLEAR

110 PRINT "I CAN WRITE A NEW SUBPROGRAM!!"

120 END

Replace CALL CLEAR with a SUB of your own design and call it CLR.

I accept. I will complete when I get home from work tonight. Thanks. I would have put it off otherwise.

##### Share on other sites

Hmmm ... I tried to paste the BASIC code into my TIImageTool, but since you used lowercase letters, it got all subprogram names wrong ("CALL screen" - "SUBPROGRAM NOT FOUND IN 100"). The command words are uppercased, since they are reserved words, but the names could - in principle - be case-sensitive.

However, when I enter text in Extended Basic directly, those strings are always changed to uppercase, also the variable names. Is it correct to assume that all non-quoted strings are changed to uppercase?

(Also, I'll have to add some special handling for these interleaved "!" comments because until now I assumed that every line can be parsed as a program line.)

##### Share on other sites

About that pre-scan that was mentioned. BITD I had a program, I cannot remember it's name or if it was XB or E/A5, but it would take any XB program, and crunch it down in size, remove all REM statements, change long variable names and add that pre-scan command then spit out some real compact code.

Does anyone remember it's name or have a link to the program and documentation in PDF format?

##### Share on other sites

Really cool, sometimes99er!!! Hoping for a new Rabbit Trail... One that has a bit of replay value.

Thanks. Putting on my ...

##### Share on other sites

About that pre-scan that was mentioned. BITD I had a program, I cannot remember it's name or if it was XB or E/A5, but it would take any XB program, and crunch it down in size, remove all REM statements, change long variable names and add that pre-scan command then spit out some real compact code.

Does anyone remember it's name or have a link to the program and documentation in PDF format?

PrescanIt!

##### Share on other sites

Hmmm ... I tried to paste the BASIC code into my TIImageTool, but since you used lowercase letters, it got all subprogram names wrong ("CALL screen" - "SUBPROGRAM NOT FOUND IN 100"). The command words are uppercased, since they are reserved words, but the names could - in principle - be case-sensitive.

However, when I enter text in Extended Basic directly, those strings are always changed to uppercase, also the variable names. Is it correct to assume that all non-quoted strings are changed to uppercase?

Excellent. Good question, sounds plausible, that's all I can say.

##### Share on other sites

Sometimes, if you have not yet read it, I HIGHLY suggest you read "Watership Down" for some inspiration. One of my all time favorite books.

##### Share on other sites

OK, TIMT can now filter out the additional comments; it will only allow a BASIC line without line number when it starts with a ! or REM token and then discard it, hence it will be possible to paste listings with additional non-line comments. For the automatic uppercase translation I'd have to think a bit longer (or you simply stay with uppercase ).

Edited by mizapf

##### Share on other sites

Sometimes, if you have not yet read it, I HIGHLY suggest you read "Watership Down" for some inspiration. One of my all time favorite books.

Actually I will.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.