Jump to content
sometimes99er

19 Carrots of Gold

Recommended Posts

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
  • Like 1

Share this post


Link to post
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. ;-)

  • Like 1

Share this post


Link to post
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?

The short answer. Yes.

 

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

 

;)

Edited by sometimes99er
  • Like 2

Share this post


Link to post
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
  • Like 2

Share this post


Link to post
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.

 

;)

  • Like 2

Share this post


Link to post
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.

  • Like 2

Share this post


Link to post
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. :thumbsup:

 

7750a699cdf89dd6727e4bb3f586fbaf.jpg

Edited by sometimes99er
  • Like 3

Share this post


Link to post
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

  • Like 2

Share this post


Link to post
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!

  • Like 1

Share this post


Link to post
Share on other sites

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

 

7750a699cdf89dd6727e4bb3f586fbaf.jpg

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
  • Like 1

Share this post


Link to post
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.

  • Like 1

Share this post


Link to post
Share on other sites

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

 

 

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. :D

  • Like 1

Share this post


Link to post
Share on other sites

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

 

 

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. :D

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

  • Like 1

Share this post


Link to post
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.)

  • Like 1

Share this post


Link to post
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?

  • Like 1

Share this post


Link to post
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!

  • Like 2

Share this post


Link to post
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 this post


Link to post
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. :)

  • Like 2

Share this post


Link to post
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
  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

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

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...