ColecoFan1981 Posted March 10, 2016 Share Posted March 10, 2016 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 1 Quote Link to comment Share on other sites More sharing options...
sometimes99er Posted March 10, 2016 Share Posted March 10, 2016 (edited) You could add these lines 2 CALL SCREEN(6) 3 CALL COLOR(1,16,1) Edited March 10, 2016 by sometimes99er Quote Link to comment Share on other sites More sharing options...
ColecoFan1981 Posted March 10, 2016 Author Share Posted March 10, 2016 (edited) You could add these lines 2 CALL SCREEN(6) 3 CALL COLOR(1,16,1) 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 March 10, 2016 by ColecoFan1981 Quote Link to comment Share on other sites More sharing options...
+arcadeshopper Posted March 10, 2016 Share Posted March 10, 2016 http://mainbyte.com/ti99/basic/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, 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, 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)) 1 Quote Link to comment Share on other sites More sharing options...
sometimes99er Posted March 11, 2016 Share Posted March 11, 2016 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. Quote Link to comment Share on other sites More sharing options...
ColecoFan1981 Posted March 11, 2016 Author Share Posted March 11, 2016 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 1 Quote Link to comment Share on other sites More sharing options...
ColecoFan1981 Posted March 18, 2016 Author Share Posted March 18, 2016 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 Quote Link to comment Share on other sites More sharing options...
sometimes99er Posted March 18, 2016 Share Posted March 18, 2016 (edited) 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 March 18, 2016 by sometimes99er 3 Quote Link to comment Share on other sites More sharing options...
ColecoFan1981 Posted March 18, 2016 Author Share Posted March 18, 2016 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 1 Quote Link to comment Share on other sites More sharing options...
ColecoFan1981 Posted February 15, 2017 Author Share Posted February 15, 2017 (edited) 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 February 15, 2017 by ColecoFan1981 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted February 15, 2017 Share Posted February 15, 2017 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 Quote Link to comment Share on other sites More sharing options...
Opry99er Posted February 16, 2017 Share Posted February 16, 2017 (edited) 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 February 16, 2017 by Opry99er Quote Link to comment Share on other sites More sharing options...
ColecoFan1981 Posted February 16, 2017 Author Share Posted February 16, 2017 (edited) 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 Edited February 16, 2017 by ColecoFan1981 1 Quote Link to comment Share on other sites More sharing options...
Opry99er Posted February 16, 2017 Share Posted February 16, 2017 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. Quote Link to comment Share on other sites More sharing options...
ColecoFan1981 Posted February 17, 2017 Author Share Posted February 17, 2017 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 Quote Link to comment Share on other sites More sharing options...
Opry99er Posted February 17, 2017 Share Posted February 17, 2017 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. Quote Link to comment Share on other sites More sharing options...
ColecoFan1981 Posted February 17, 2017 Author Share Posted February 17, 2017 (edited) In the meantime, the shorthand I used is: 113366CC88CC6633 ~Ben Edited February 17, 2017 by ColecoFan1981 Quote Link to comment Share on other sites More sharing options...
sometimes99er Posted February 17, 2017 Share Posted February 17, 2017 (edited) 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 February 17, 2017 by sometimes99er Quote Link to comment Share on other sites More sharing options...
sometimes99er Posted February 18, 2017 Share Posted February 18, 2017 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 Quote Link to comment Share on other sites More sharing options...
ColecoFan1981 Posted February 18, 2017 Author Share Posted February 18, 2017 (edited) 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 February 18, 2017 by ColecoFan1981 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted February 18, 2017 Share Posted February 18, 2017 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 Quote Link to comment Share on other sites More sharing options...
ColecoFan1981 Posted February 19, 2017 Author Share Posted February 19, 2017 (edited) 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 February 19, 2017 by ColecoFan1981 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted February 19, 2017 Share Posted February 19, 2017 Ben... Here is what I get with that code on Classic99: Is this your experience? Is the black border you do not want the one surrounding the multi-colored rectangle in this graphic? ...lee cherries2.bmp Quote Link to comment Share on other sites More sharing options...
ColecoFan1981 Posted February 19, 2017 Author Share Posted February 19, 2017 (edited) Ben... Here is what I get with that code on Classic99: cherries2.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 February 19, 2017 by ColecoFan1981 Quote Link to comment Share on other sites More sharing options...
sometimes99er Posted February 19, 2017 Share Posted February 19, 2017 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.