Jump to content

Photo

TI-99 BASIC Color Code


28 replies to this topic

#1 ColecoFan1981 OFFLINE  

ColecoFan1981

    Moonsweeper

  • 353 posts
  • Location:Milwaukie (Oak Grove), OR

Posted Thu Mar 10, 2016 2:58 PM

I've taught myself to do pattern codes using TI Basic.

But, what I want to do is add color to this existing code:
5 INPUT "SHORTHAND?":A$
10 CALL CLEAR
20 CALL CHAR(33,A$)
30 FOR I=1 TO 4
40 CALL VCHAR(12,I+3,33,4)
50 NEXT I
60 GOTO 5 

The question is: how would I add such routines like COLOR CODE and SCREEN COLOR to the appropriate places in this existing code? Thank you!

 

~Ben



#2 sometimes99er OFFLINE  

sometimes99er

    River Patroller

  • 3,833 posts
  • Location:Denmark

Posted Thu Mar 10, 2016 3:06 PM

You could add these lines
 
2 CALL SCREEN(6)
3 CALL COLOR(1,16,1)


:)
 
colorcodes.png

Edited by sometimes99er, Thu Mar 10, 2016 3:11 PM.


#3 ColecoFan1981 OFFLINE  

ColecoFan1981

    Moonsweeper

  • Topic Starter
  • 353 posts
  • Location:Milwaukie (Oak Grove), OR

Posted Thu Mar 10, 2016 3:14 PM

You could add these lines
 

2 CALL SCREEN(6)
3 CALL COLOR(1,16,1)

:)
 
colorcodes.png

 

I'd also like to be able to select my own colors among these routines, without having to rewrite the whole CALL SCREEN and CALL COLOR routines. COLOR1 (foreground) and COLOR2 (background) would be of more usefulness. This would also mean altering certain line numbers to accept these codes.

 

I'd also like to be able fill the entire background (as the SCREEN COLOR represents) with this "shorthand" code.

 

~Ben


Edited by ColecoFan1981, Thu Mar 10, 2016 3:33 PM.


#4 arcadeshopper OFFLINE  

arcadeshopper

    River Patroller

  • 2,290 posts
  • Location:Portland, Oregon USA

Posted Thu Mar 10, 2016 3:30 PM

http://mainbyte.com/.../basic_ref.html

 

Great reference there for all the commands etc..  

 

call screen(color)  using the above chart works for the screen background

 

The COLOR subprogram allows you to specify either a foreground-color for #sprite-number or a foreground-color and background-color for characters in the character-set. In a given CALL COLOR, you may define sprite color(s) or character set colors, but not both. 

Each character has two colors. The color of the dots that make up the character itself is called the foreground-color. The color that occupies the rest of the character position on the screen is called the background-color. In sprites, the background-color is always code 1, transparent, which allows characters and the screen color to show through. To change the screen color, see the SCREEN subprogram. Foreground-color and background-color must have values from 1 through 16. The color codes are shown below: 


Color Code

Color

1

Transparent

2

Black

3

Medium Green

4

Light Green

5

Dark Blue

6

Light Blue

7

Dark Red

8

Cyan

9

Medium Red

10

Light Red

11

Dark Yellow

12

Light Yellow

13

Dark Green

14

Magenta

15

Gray

16

White



Until CALL COLOR is performed, the standard foreground-color is black (code 2) and the standard background-color is transparent (code 1) for all characters. Sprites have their color assigned when they are created. When a breakpoint occurs, all characters are reset to the standard colors. 

To use CALL COLOR you must also specify to which of the fifteen character sets the character belongs. (Note that TI BASIC has sixteen character sets while TI Extended BASIC has fifteen.) The list of ASCII character codes for the standard characters is given in Appendix C. The character-set numbers are given below: 

Set Number

Character Codes

0

30-31

1

32-39

2

40-47

3

48-55

4

56-63

5

64-71

6

72-79

7

80-87

8

88-95

9

96-103

10

104-111

11

112-119

12

120-127

13

128-135

14

136-143

Options:
 
Examples:
CALL COLOR(3,5,8) sets the foreground-color of characters 48 through 55 to 5 (dark blue) and the background-color to 8 (cyan). 

>100 CALL COLOR(3,5,8) 

CALL COLOR(#5,16) sets sprite number 5 to have a foreground-color of 16 (white). The background-color is always 1 (transparent). 

>100 CALL COLOR(#5,16) 

CALL COLOR(#7 ,INT(RND* 16 + 1)) sets sprite number 7 to have a foreground-color chosen randomly from the 16 colors available. The background-color is 1 (transparent). 

>100 CALL COLOR(#7,INT(RND*16 +1))

  • RXB likes this

#5 sometimes99er OFFLINE  

sometimes99er

    River Patroller

  • 3,833 posts
  • Location:Denmark

Posted Thu Mar 10, 2016 10:51 PM

I'd also like to be able to select my own colors among these routines, without having to rewrite the whole CALL SCREEN and CALL COLOR routines. COLOR1 (foreground) and COLOR2 (background) would be of more usefulness. This would also mean altering certain line numbers to accept these codes.
 
I'd also like to be able fill the entire background (as the SCREEN COLOR represents) with this "shorthand" code.
 
~Ben


10 INPUT "BACKGROUND COLOR?":B
20 INPUT "FOREGROUND COLOR?":F
30 CALL SCREEN(B)
40 FOR I=1 TO 8
50 CALL COLOR(I,F,1)
60 NEXT I
105 INPUT "SHORTHAND?":A$
110 CALL CLEAR
120 CALL CHAR(33,A$)
130 FOR I=1 TO 4
140 CALL VCHAR(12,I+3,33,4)
150 NEXT I
160 GOTO 105
 

Unfortunately one can't change the color of the cursor in TI Basic. One can with TI Extended Basic. You would then change line 40 to start from 0 instead of 1.

:)

#6 ColecoFan1981 OFFLINE  

ColecoFan1981

    Moonsweeper

  • Topic Starter
  • 353 posts
  • Location:Milwaukie (Oak Grove), OR

Posted Fri Mar 11, 2016 2:13 AM

10 INPUT "BACKGROUND COLOR?":B
20 INPUT "FOREGROUND COLOR?":F
30 CALL SCREEN(B)
40 FOR I=1 TO 8
50 CALL COLOR(I,F,1)
60 NEXT I
105 INPUT "SHORTHAND?":A$
110 CALL CLEAR
120 CALL CHAR(33,A$)
130 FOR I=1 TO 4
140 CALL VCHAR(12,I+3,33,4)
150 NEXT I
160 GOTO 105
 
Unfortunately one can't change the color of the cursor in TI Basic. One can with TI Extended Basic. You would then change line 40 to start from 0 instead of 1.

:)

 

Thank you, that is a better representation!

 

~Ben


  • RXB likes this

#7 ColecoFan1981 OFFLINE  

ColecoFan1981

    Moonsweeper

  • Topic Starter
  • 353 posts
  • Location:Milwaukie (Oak Grove), OR

Posted Thu Mar 17, 2016 9:52 PM

BUMP

 

I wonder what code I should type into Extended Basic to fill an entire background with an 8x8 sprite and requested colors?

 

Thank you,

 

 

 

Ben



#8 sometimes99er OFFLINE  

sometimes99er

    River Patroller

  • 3,833 posts
  • Location:Denmark

Posted Fri Mar 18, 2016 12:10 AM

I wonder what code I should type into Extended Basic to fill an entire background with an 8x8 sprite and requested colors?

 
Sprites
 
You can't fill the entire background (screen) with sprites.

There's a hardware limit of 32 sprites. Extended Basic can use up to 28 of these.

Also hardware limits the number of sprites visible horizontally to only 4. Using 16x16 magnified sprites would help further in trying to fill the screen.

The screen is 256x192. 16x16 magnified sprites arranged with 4 across and 7 down (4x7=28) fills 4x16x2=128 pixels across and 7x16x2=224 pixels down (the screen is only 192). 128/256=0.5
 
- It would fill half the background.
 
10 INPUT "BACKGROUND COLOR?":B
20 INPUT "FOREGROUND COLOR?":F
30 CALL SCREEN(B)
40 CALL CLEAR
50 CALL CHAR(36,RPT$("FF",32))
60 CALL MAGNIFY(4)
70 FOR X=0 TO 3
80 FOR Y=0 TO 6
90 CALL SPRITE(#1+X+Y*4,36,F,1+Y*32,1+X*32)
100 NEXT Y
110 NEXT X
120 GOTO 10
 
  

Characters
 
You can fill the background with an 8x8 character with requested colors. CALL CLEAR fills the screen with the space character. We cheat and redefine exactly the space character, code 32.
 
10 INPUT "BACKGROUND COLOR?":B
20 INPUT "FOREGROUND COLOR?":F
30 INPUT "SHORTHAND?":A$
40 CALL SCREEN(B)
50 CALL CLEAR
60 CALL CHAR(32,A$)
70 CALL COLOR(1,F,B)
80 GOTO 10
 
 
:)

Edited by sometimes99er, Fri Mar 18, 2016 12:34 AM.


#9 ColecoFan1981 OFFLINE  

ColecoFan1981

    Moonsweeper

  • Topic Starter
  • 353 posts
  • Location:Milwaukie (Oak Grove), OR

Posted Fri Mar 18, 2016 12:29 PM

 
Sprites
 
You can't fill the entire background (screen) with sprites.

There's a hardware limit of 32 sprites. Extended Basic can use up to 28 of these.

Also hardware limits the number of sprites visible horizontally to only 4. Using 16x16 magnified sprites would help further in trying to fill the screen.

The screen is 256x192. 16x16 magnified sprites arranged with 4 across and 7 down (4x7=28) fills 4x16x2=128 pixels across and 7x16x2=224 pixels down (the screen is only 192). 128/256=0.5
 
- It would fill half the background.
 

10 INPUT "BACKGROUND COLOR?":B
20 INPUT "FOREGROUND COLOR?":F
30 CALL SCREEN(B)
40 CALL CLEAR
50 CALL CHAR(36,RPT$("FF",32))
60 CALL MAGNIFY(4)
70 FOR X=0 TO 3
80 FOR Y=0 TO 6
90 CALL SPRITE(#1+X+Y*4,36,F,1+Y*32,1+X*32)
100 NEXT Y
110 NEXT X
120 GOTO 10
 
  

Characters
 
You can fill the background with an 8x8 character with requested colors. CALL CLEAR fills the screen with the space character. We cheat and redefine exactly the space character, code 32.
 
10 INPUT "BACKGROUND COLOR?":B
20 INPUT "FOREGROUND COLOR?":F
30 INPUT "SHORTHAND?":A$
40 CALL SCREEN(B)
50 CALL CLEAR
60 CALL CHAR(32,A$)
70 CALL COLOR(1,F,B)
80 GOTO 10
 
 
:)

 

Thank you, that last one worked for sure!

 

~Ben


  • RXB likes this

#10 ColecoFan1981 OFFLINE  

ColecoFan1981

    Moonsweeper

  • Topic Starter
  • 353 posts
  • Location:Milwaukie (Oak Grove), OR

Posted Wed Feb 15, 2017 4:33 PM

I wonder how I would do shorthand code on TI Extended Basic to create and fill a background with a 16x16 sprite?

 

Would it be simple as changing line 60 to CALL CHAR (64,A$) or something like that?

 

~Ben


Edited by ColecoFan1981, Wed Feb 15, 2017 4:42 PM.


#11 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • 3,197 posts
  • Location:Silver Run, Maryland

Posted Wed Feb 15, 2017 4:59 PM

I wonder how I would do shorthand code on TI Extended Basic to create and fill a background with a 16x16 sprite?

 

Would it be simple as changing line 60 to CALL CHAR (64,A$) or something like that?

 

~Ben

 

It is not as simple and it also depends on what magnification you want.  Magnification=2 is the easiest.  It requires 4 contiguous characters (chr0 – chr3).  Your background would require alternating chr0, chr2 on every other line, starting with the first and chr1, chr3 on every other line, starting with the second line.  If chr0 is to remain 32 (space), then chr1='!', chr2='"', chr3='#'.

 

Other magnifications would require more bit twiddling because the pixels are doubled in both the X and Y directions—doable, but not simple.

 

...lee



#12 Opry99er OFFLINE  

Opry99er

    Quadrunner

  • 8,221 posts
  • Location:Cookeville, TN

Posted Wed Feb 15, 2017 6:01 PM

Do you need sprites, or just the SPRITE patterns duplicated throughout the entire screen?

If the latter, it is a simple sequence of DISPLAY ATs inside an embedded loop using STEP.

And, of course, the definition of the characters you want to display. I would post example code, but I am at work.

Edited by Opry99er, Wed Feb 15, 2017 6:03 PM.


#13 ColecoFan1981 OFFLINE  

ColecoFan1981

    Moonsweeper

  • Topic Starter
  • 353 posts
  • Location:Milwaukie (Oak Grove), OR

Posted Thu Feb 16, 2017 5:07 PM

Do you need sprites, or just the SPRITE patterns duplicated throughout the entire screen?

If the latter, it is a simple sequence of DISPLAY ATs inside an embedded loop using STEP.

And, of course, the definition of the characters you want to display. I would post example code, but I am at work.

Opry99er,

 

It's trying to re-create these vertical chevron backgrounds in the ColecoVision port of Mr. Do! that's been hard at me right now within an 8x8 framework and why they would look better in 16x16. I am giving you the applicable screenshots for your convenience.

 

~Ben

Attached Files


Edited by ColecoFan1981, Thu Feb 16, 2017 5:11 PM.


#14 Opry99er OFFLINE  

Opry99er

    Quadrunner

  • 8,221 posts
  • Location:Cookeville, TN

Posted Thu Feb 16, 2017 5:30 PM

You don't need SPRITEs, just some clever programming. :)

DL the XB manual, then look up DISPLAY AT and FOR loops with STEP. A little tinkering and you'll have it. It will be the 8x8 framework still, but you will display each tile you need in the pattern varying your rows and columns in the loop.

You can do it. :) Or, if I get off eaely enough tonight, I'll make you a framework sample code block you can adjust to meet your needs.

#15 ColecoFan1981 OFFLINE  

ColecoFan1981

    Moonsweeper

  • Topic Starter
  • 353 posts
  • Location:Milwaukie (Oak Grove), OR

Posted Thu Feb 16, 2017 6:16 PM

You don't need SPRITEs, just some clever programming. :)

DL the XB manual, then look up DISPLAY AT and FOR loops with STEP. A little tinkering and you'll have it. It will be the 8x8 framework still, but you will display each tile you need in the pattern varying your rows and columns in the loop.

You can do it. :) Or, if I get off eaely enough tonight, I'll make you a framework sample code block you can adjust to meet your needs.

I am hoping you'll send me the correct code whenever you can make it.

 

~Ben



#16 Opry99er OFFLINE  

Opry99er

    Quadrunner

  • 8,221 posts
  • Location:Cookeville, TN

Posted Thu Feb 16, 2017 6:50 PM

What I send you will be example code in tutorial format, commented so that you can see what's going on.

You can plug in hex values for your characters and plug in whatever values you need for your loop to make the background you want.

I will try to do it tonight, unless someone else beats me to it.

#17 ColecoFan1981 OFFLINE  

ColecoFan1981

    Moonsweeper

  • Topic Starter
  • 353 posts
  • Location:Milwaukie (Oak Grove), OR

Posted Thu Feb 16, 2017 8:12 PM

In the meantime, the shorthand I used is:

113366CC88CC6633

 

~Ben


Edited by ColecoFan1981, Thu Feb 16, 2017 8:19 PM.


#18 sometimes99er OFFLINE  

sometimes99er

    River Patroller

  • 3,833 posts
  • Location:Denmark

Posted Fri Feb 17, 2017 4:16 AM

Changed the shorthand a bit. ;)
   

100 call clear
110 call screen(2)
120 call char(40,"3366CC88CC663311")
140 call hchar(4,1,40,21*32)
150 call color(2,11,6)
160 goto 160
  
100 call clear
110 call screen(2)
120 call char(32,"3366CC88CC663311")
140 call hchar(1,1,40,3*32)
150 call color(1,11,6)
160 goto 160
  

Edited by sometimes99er, Fri Feb 17, 2017 4:21 AM.


#19 sometimes99er OFFLINE  

sometimes99er

    River Patroller

  • 3,833 posts
  • Location:Denmark

Posted Sat Feb 18, 2017 2:37 AM

A few cherries. :)
  

! clear screen
100 call clear::call screen(2)
! chevron pattern, 8 by 8 pixel character
110 call char(40,"3366CC88CC663311")
! display chevron character
120 call hchar(4,1,40,21*32)
! colors for chevron and cherry characters
130 call color(2,11,6,5,2,6,6,7,6)
! cherry patterns, 8x8 pixel characters
140 call char(65,"00000000000001020000003048880808",72,"040E1B1D1F0E000010386C747C38")
! display cherry characters
150 display at(8,5):"ABABABAB";
160 display at(9,5):"HIHIHIHI";
! wait forever
170 goto 170
 


#20 ColecoFan1981 OFFLINE  

ColecoFan1981

    Moonsweeper

  • Topic Starter
  • 353 posts
  • Location:Milwaukie (Oak Grove), OR

Posted Sat Feb 18, 2017 12:54 PM

 

A few cherries. :)
  

! clear screen
100 call clear::call screen(2)
! chevron pattern, 8 by 8 pixel character
110 call char(40,"3366CC88CC663311")
! display chevron character
120 call hchar(4,1,40,21*32)
! colors for chevron and cherry characters
130 call color(2,11,6,5,2,6,6,7,6)
! cherry patterns, 8x8 pixel characters
140 call char(65,"00000000000001020000003048880808",72,"040E1B1D1F0E000010386C747C38")
! display cherry characters
150 display at(8,5):"ABABABAB";
160 display at(9,5):"HIHIHIHI";
! wait forever
170 goto 170
 

Thank you for that! Now to try that on some Tomy Tutor/MSX-style Mr. Do! background patterns!

I made a repeat of lines 150 and 160 at 170 and 180, but what do I do to remove the black border to the right of the second row of cherries I created?

 

~Ben


Edited by ColecoFan1981, Sat Feb 18, 2017 12:57 PM.


#21 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • 3,197 posts
  • Location:Silver Run, Maryland

Posted Sat Feb 18, 2017 5:42 PM

Thank you for that! Now to try that on some Tomy Tutor/MSX-style Mr. Do! background patterns!

I made a repeat of lines 150 and 160 at 170 and 180, but what do I do to remove the black border to the right of the second row of cherries I created?

 

~Ben

 

Description of code does not really help.  You need to post your actual code.

 

My guess is that you have introduced a space at the end of your DISPLAY AT statement(s).  The character set in which <space> resides has a black background, which is the likely reason for the unwanted black blocks.

 

...lee



#22 ColecoFan1981 OFFLINE  

ColecoFan1981

    Moonsweeper

  • Topic Starter
  • 353 posts
  • Location:Milwaukie (Oak Grove), OR

Posted Sat Feb 18, 2017 7:42 PM

 

A few cherries. :)
  

! clear screen
100 call clear::call screen(2)
! chevron pattern, 8 by 8 pixel character
110 call char(40,"3366CC88CC663311")
! display chevron character
120 call hchar(4,1,40,21*32)
! colors for chevron and cherry characters
130 call color(2,11,6,5,2,6,6,7,6)
! cherry patterns, 8x8 pixel characters
140 call char(65,"00000000000001020000003048880808",72,"040E1B1D1F0E000010386C747C38")
! display cherry characters
150 display at(8,5):"ABABABAB";
160 display at(9,5):"HIHIHIHI";
170 display at(10,5):"ABABABAB";
180 display at(11,5):"HIHIHIHI";
! wait forever
190 goto 190
 

Lee,

 

Here's the code in question originally submitted to me by sometimes99er, but which I modified (lines 170 and 180 are modified, and I moved the end to 190) to include an extra horizontal row of cherries.

 

~Ben


Edited by ColecoFan1981, Sat Feb 18, 2017 7:42 PM.


#23 Lee Stewart ONLINE  

Lee Stewart

    River Patroller

  • 3,197 posts
  • Location:Silver Run, Maryland

Posted Sat Feb 18, 2017 8:27 PM

Ben...

 

Here is what I get with that code on Classic99:

 

Attached File  cherries2.png   1.04KB   2 downloads

 

Is this your experience?  Is the black border you do not want the one surrounding the multi-colored rectangle in this graphic?

 

...lee

Attached Files



#24 ColecoFan1981 OFFLINE  

ColecoFan1981

    Moonsweeper

  • Topic Starter
  • 353 posts
  • Location:Milwaukie (Oak Grove), OR

Posted Sat Feb 18, 2017 8:53 PM

Ben...

 

Here is what I get with that code on Classic99:

 

attachicon.gifcherries2.png

 

Is this your experience?  Is the black border you do not want the one surrounding the multi-colored rectangle in this graphic?

 

...lee

Lee,

 

Thank you... it worked perfectly for me this time! I must've done something wrong the first time I tried that...

 

~Ben


Edited by ColecoFan1981, Sat Feb 18, 2017 8:54 PM.


#25 sometimes99er OFFLINE  

sometimes99er

    River Patroller

  • 3,833 posts
  • Location:Denmark

Posted Sun Feb 19, 2017 1:22 AM

More cherries ... ;)
  
There are several ways to do all the cherries, and things might have gotten way too heavy too soon with loops and data statements. It's important that you take your own steps, experiment and understand the inner workings.
  
Sooner or later you'll realize that TI Extended Basic runs slow (or too slow) in the attempt at making a game like Mr. Do. :|
 
! clear screen
100 call clear::call screen(2)
! chevron pattern, 8 by 8 pixel character
110 call char(40,"3366CC88CC663311")
! display chevron character
120 call hchar(4,1,40,20*32)
! colors for chevron and cherry characters
130 call color(2,11,6,5,2,6,6,7,6)
! cherry patterns, 8x8 pixel characters
200 call char(65,"00000000000001020000003048880808",72,"040E1B1D1F0E000010386C747C38")
! display cherry characters
! data format: row, column, direction (-1 = end of data)
210 data 8,5,right,8,19,right,14,3,down,16,11,right,14,21,down,-1
220 read row::if row=-1 then 999 else read col,direct$
230 if direct$="right" then rowEnd=row+2::colEnd=col+6 else rowEnd=row+6::colEnd=col+2
240 for x=col to colEnd step 2::for y=row to rowEnd step 2
250 display at(y,x):"AB";::display at(y+1,x):"HI";
260 next y::next x
270 goto 220
! wait forever
999 goto 999
 





0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users