Jump to content
IGNORED

Pretty pattern


Vorticon

Recommended Posts

Screwing around with RXB 2023 I made this:

100 CALL CLEAR
110 CALL SCREEN(12)
120 CALL COLOR(9,4,13)
130 CALL CHAR(96,"FFFEFCF8F0E0C080")
140 CALL CHAR(97,"0103070F1F3F7FFF")
160 CALL CHAR(98,"80C0E0F0F8FCFEFF")
165 CALL CHAR(99,"FF7F3F1F0F070301")
170 FOR C=1 TO 24 :: RV=INT(RND*4) :: S$=S$&CHR$(RV+96) :: NEXT C
180 PRINT CHR$(96+RV);
180 CALL SCROLLRIGHT(1,S$)
190 S$="" :: GOTO 170

Why can I not edit out the duplicate line 180?

Link to comment
Share on other sites

1 hour ago, senior_falcon said:

Yes, and if you made it 28 and added the one extra B=(B=0) it would probably work.

Not gonna argue against that, as it is correct.  If not being redundant is not the goal, then definitely.

1 hour ago, Asmusr said:

Is B=B=0 more efficient than B=NOT B ?

That would work, since that would also alternate between 0 and -1.  B=NOT B executes 10,000 iterations in 71 seconds, while B=B=0 executes 10,000 iterations in 83 seconds.  Bit-wise operator FTW!

Link to comment
Share on other sites

2 hours ago, Asmusr said:

Is B=B=0 more efficient than B=NOT B ?

I ran a test loop on Classic99 to test this:

100 CALL CLEAR
110 OPEN #1:"CLOCK"
120 INPUT #1:A$,B$,C$
130 FOR C=1 TO 10000
140 B=B=0 or 140 B=NOT B
150 NEXT C
160 INPUT #1:D$,E$,F$
170 PRINT A$,D$:B$,E$,C$,F$
180 END

Times are:

B=B=0 is 1 minute 35 seconds

B=NOT B is 1 minute 23 seconds so this one is faster.

 

I can tell you the reason why is each = sign has to evaluate the previous one's value, so the NOT only requires one evaluation not two.

It does not slow down assembly in ROM that much but over a loop of 10,000 it does show up.

 

Link to comment
Share on other sites

59 minutes ago, jrhodes said:

The B=B=0 confused me too, to be honest.

Makes sense now.

 

I think most of us are used to initializing multiple variables in most high-level programming languages using a construct like

A=B=C=0     ; <---initialize A,B,C to 0

where the relational operator is entirely different (often ‘==’), but TI chose to do that in XB as

A,B,C=0           ! <----initialize A,B,C to 0 in TI XB

to insure it was different from using a second ‘=’ as a relational operator, which is, of course, the same symbol(!?).

 

...lee

  • Like 5
Link to comment
Share on other sites

2 hours ago, Lee Stewart said:

 

I think most of us are used to initializing multiple variables in most high-level programming languages using a construct like

A=B=C=0     ; <---initialize A,B,C to 0

where the relational operator is entirely different (often ‘==’), but TI chose to do that in XB as

A,B,C=0           ! <----initialize A,B,C to 0 in TI XB

to insure it was different from using a second ‘=’ as a relational operator, which is, of course, the same symbol(!?).

 

...lee

I don't think I ever knew BASIC could do that. 

Thanks Lee.

  • Like 2
Link to comment
Share on other sites

It is just as fast to use HCHAR as using PRINT and you can get all 32 columns. Unfortunately you have to start at row 23 because PRINT blanks the last line


10 CALL CLEAR :: RANDOMIZE :: CALL SCREEN(10):: CALL COLOR(1,7,10,2,9,10)
20 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF",40,"FFFEFCF8F0E0C0800103070F1F3F7FFF")
30 FOR I=1 TO 32 :: B=(B=0):: CALL HCHAR(23,I,34+INT(RND*2)*7+B):: NEXT I :: B=B=0 :: PRINT :: GOTO 30

 

The above can be compiled, but the scrolling seems too fast to me. This looks much better compiled:

 

10 CALL CLEAR :: RANDOMIZE :: CALL SCREEN(10):: CALL COLOR(1,7,10,2,9,10)
20 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF",40,"FFFEFCF8F0E0C0800103070F1F3F7FFF")
30 FOR R=1 TO 24 :: FOR I=1 TO 32 :: B=(B=0):: CALL HCHAR(R,I,34+INT(RND*2)*7+B):: NEXT I :: B=B=0 :: NEXT R :: GOTO 30

PATTERN.GIF.50c5193333b5915f5c6a7c2d79c3c957.GIF


 

 

Edited by senior_falcon
  • Like 8
Link to comment
Share on other sites

14 hours ago, RXB said:

Screwing around with RXB 2023 I made this:

100 CALL CLEAR
110 CALL SCREEN(12)
120 CALL COLOR(9,4,13)
130 CALL CHAR(96,"FFFEFCF8F0E0C080")
140 CALL CHAR(97,"0103070F1F3F7FFF")
160 CALL CHAR(98,"80C0E0F0F8FCFEFF")
165 CALL CHAR(99,"FF7F3F1F0F070301")
170 FOR C=1 TO 24 :: RV=INT(RND*4) :: S$=S$&CHR$(RV+96) :: NEXT C
180 PRINT CHR$(96+RV);
180 CALL SCROLLRIGHT(1,S$)
190 S$="" :: GOTO 170

Why can I not edit out the duplicate line 180?

Very cool doing it sideways! The pattern however doesn't look quite right and I suspect that's because you're not using 2 shades of green for the characters. Unless of course you're not going for the original pattern.

Link to comment
Share on other sites

9 hours ago, senior_falcon said:

10 CALL CLEAR :: RANDOMIZE :: CALL SCREEN(10):: CALL COLOR(1,7,10,2,9,10)
20 CALL CHAR(33,"FF7F3F1F0F07030180C0E0F0F8FCFEFF",40,"FFFEFCF8F0E0C0800103070F1F3F7FFF")
30 FOR R=1 TO 24 :: FOR I=1 TO 32 :: B=(B=0):: CALL HCHAR(R,I,34+INT(RND*2)*7+B):: NEXT I :: B=B=0 :: NEXT R :: GOTO 30

I did not think HCHAR would be as fast as print... I have to say though that while compilation is impressively fast, there is definitely a certain charm to seeing the pattern slowly building on the screen. It's probably just me 😁 Why are you using the parentheses with the first B=B=0? 

  • Like 1
Link to comment
Share on other sites

1 hour ago, Vorticon said:

Why are you using the parentheses with the first B=B=0? 

Three reasons:

1 - I used to think it was necessary. I used that a lot in TI BASIC for lines like this: 10 IF (X=7)*(Y=3) THEN 200.  Here the parentheses are necessary, and I thought they always were.

2 - I'm a little hard of thinking, and this keeps me from getting confused. When I see B=(B=0) I understand what is happening.

3 - I thought the compiler needed it. Evidently not, because I forgot to put them in the second B=B=0 and that still works properly.

(If I intended to compile the code, I would still use the parentheses just to be sure)

  • Like 2
Link to comment
Share on other sites

Just looking at Classic99 Debugger memory for these I get:

B=NOT B

>00 0A FF 00 0A FF E3 05 42 BE BD     42 00

                                        B  =  NOT   B

                                                Token

 

B=B=0

>00 0A FF E0 08 42 BE 42 BE C8          01        30 00

                         B   =  B   =   Numeric  Length  0

                                             Token

 

The B=B=0 has more tokens to be processed by the XB interpreter but does not slow down processing much.

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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