InfernalKeith Posted April 15, 2010 Share Posted April 15, 2010 Is there an XB command that will tell you the color of a character set? Like, say a player moves to a square with a "*" on it, and the color of the asterisk determines what happens next (and has been changing periodically throughout play). Is there an equivalent to CALL CHARPAT that reports back the number of a charset's color? Quote Link to comment Share on other sites More sharing options...
The Codex Posted April 15, 2010 Share Posted April 15, 2010 (edited) If there isn't, you could use a code workaround that would do the same thing, assuming your color sets are stored in an array: REM SET UP THE COLOR ARRAYS 100 OPTION BASE 0 110 DIM CLRFORE(14), CLRBACK(14) 120 FOR I=0 TO 14::READ CLRFORE(I), CLRBACK(I)::CALL COLOR(I,CLRFORE(I),CLRBACK(I))::NEXT I REM GET A CHARACTER AT SCREEN POSITION X,Y 500 CALL GCHAR(Y, X, C) REM GET THE COLOR SET NUMBER OF THAT CHARACTER REM NOTE - THIS PROBABLY NEEDS TO BE TWEAKED SO THAT THE DIVISION ALWAYS ROUNDS DOWN 510 CSET = (C / - 3 REM NOW GET YOUR COLORS FROM THE ARRAYS 520 MYFORE = CLRFORE(CSET) 530 MYBACK = CLRBACK(CSET) REM DATA PAIRS FOR COLOR ARRAYS 900 DATA 1,0,2,1,3,2,4,3,5,4,6,8,1,4,10,7,3,14,10,8,2,5,9,7,13,11,14,0 EDIT - Fixed the ding-dang example code Edited April 15, 2010 by The Codex Quote Link to comment Share on other sites More sharing options...
unhuman Posted April 15, 2010 Share Posted April 15, 2010 Or you could find the right place to call peek.... I'm sure that's just dreamin tho. Quote Link to comment Share on other sites More sharing options...
The Codex Posted April 15, 2010 Share Posted April 15, 2010 Um, might help if I actually populated the arrays in the example. 110 DIM CLRFORE(14), CLRBACK(14) 120 FOR I=0 TO 14::READ CLRFORE(I), CLRBACK(I)::CALL COLOR(I,CLRFORE(I),CLRBACK(I))::NEXT I That's what I get for coding without the emulator up. Quote Link to comment Share on other sites More sharing options...
InfernalKeith Posted April 15, 2010 Author Share Posted April 15, 2010 Um, might help if I actually populated the arrays in the example. 110 DIM CLRFORE(14), CLRBACK(14) 120 FOR I=0 TO 14::READ CLRFORE(I), CLRBACK(I)::CALL COLOR(I,CLRFORE(I),CLRBACK(I))::NEXT I My hope was to be able to let the colors get randomly redefined, then do something like a CALL GCHAR to see which color the player was standing on. Not having to take time or use variables to keep track of the colors. I never recalled running into a command like that, but I don't recall ever needing it until today. I may have to do it your way, though, which should work. Probably not in 30 lines, unfortunately. That's what I get for coding without the emulator up. Quote Link to comment Share on other sites More sharing options...
sometimes99er Posted April 15, 2010 Share Posted April 15, 2010 (edited) Or you could find the right place to call peek.... I'm sure that's just dreamin tho. Yep, XB hasnt got CALL PEEKV like Mini Mem has. CALL PEEK targets CPU whereas CALL PEEKV targets VDP (that's where the colors are). Edited April 15, 2010 by sometimes99er Quote Link to comment Share on other sites More sharing options...
Opry99er Posted April 15, 2010 Share Posted April 15, 2010 You could roll your own sub... Set up the re-color routine with variables for the color codes SUB GETCOLOR just find the character on the screen (GCHAR) then determine the set it is in by doing some dividing, then have it reference the pre-set variables you set up for the sets. I don't have access to a computer to work this up, but this is how I would do it. or something of the like Quote Link to comment Share on other sites More sharing options...
Opry99er Posted April 15, 2010 Share Posted April 15, 2010 Looks like you all beat me to the punch. . Yep, that's how--Codex has some good thoughts there. Quote Link to comment Share on other sites More sharing options...
InfernalKeith Posted April 15, 2010 Author Share Posted April 15, 2010 Looks like you all beat me to the punch. . Yep, that's how--Codex has some good thoughts there. But I WAAAANT a built-in command to do it!!! (stomps and pouts) Ah well. It's not like I have time to work on it today anyway. Gonna do some Classic99 work this weekend at the in-laws', so hopefully I'll have something to show for it next week. Quote Link to comment Share on other sites More sharing options...
Opry99er Posted April 15, 2010 Share Posted April 15, 2010 Forth is expandable--- any command you need becomes as simple as typing it in. And once you make your sub, it's as simple as typing in CALL BADASSFUNK. Quote Link to comment Share on other sites More sharing options...
The Codex Posted April 15, 2010 Share Posted April 15, 2010 But I WAAAANT a built-in command to do it!!! (stomps and pouts) Hey, if Tursi can emulate the who dang computer, certainly he can modify Extended BASIC without breaking a sweat. Ask him to put this command in there. Quote Link to comment Share on other sites More sharing options...
Opry99er Posted April 15, 2010 Share Posted April 15, 2010 But then the game would not run on a real TI... And our Infernal Keith is a "code-on-hardware" kind of fella. A true massochist... <jk> if I could code in hardware 100% of the time, I would.. Just not set up for it. Quote Link to comment Share on other sites More sharing options...
The Codex Posted April 15, 2010 Share Posted April 15, 2010 (edited) Oh, alright then. If you want something that runs in unmodified XB and doesn't take up too much space, here is an example of two versions of the code. The version that sets the foreground colors takes 3 lines (need one for the DATA statement), the random foreground routine only needs two. REM we assume here that you only care about the foreground color and will preset the background to transparent REM if not the case, this code can be modified to handle the background instead, or even both colors REM the compressed setup - data reading version 100 OPTION BASE 0::DIM CF(14)::FOR I=0 TO 14::READ CF(I)::CALL COLOR(I,CF(I),0)::NEXT I 110 DATA 1,2,3,4,5,6,1,10,3,11,2,9,13,14 REM the compressed setup - random colors version 100 OPTION BASE 0::DIM CF(14)::FOR I=0 TO 14::CF(I)=INT(RND*16+1)::CALL COLOR(I,CF(I),0)::NEXT I 110 REM NO DATA NEEDED REM game code blah blah blah, assume vars for the position-of-interest (PX, PY) and colorset foreground value (CS) REM this is whatever you want in your game, it just demos fetching the colorset foreground 500 PX=12::PY=8::GOSUB 10000::DISPLAY AT(1,1):CS 600 CALL KEY(0,K,S)::IF S=0 THEN 600 700 END REM the compressed colorset foreground fetch 10000 CALL GCHAR(PY,PX,CV)::CN=INT(CV/8)-3::CS=CF(CN)::RETURN Lines 100, 10000, and optionally 110, are the only lines which are the actual colorset routines. Everything else is your game code. It expects at least three global variables (as stated in the REM comments), one each for row position, column position, and colorset number storage, so be sure you define those as well. Edited April 15, 2010 by The Codex Quote Link to comment Share on other sites More sharing options...
InfernalKeith Posted April 15, 2010 Author Share Posted April 15, 2010 Oh, alright then. If you want something that runs in unmodified XB and doesn't take up too much space, here is an example of two versions of the code. The version that sets the foreground colors takes 3 lines (need one for the DATA statement), the random foreground routine only needs two. REM we assume here that you only care about the foreground color and will preset the background to transparent REM if not the case, this code can be modified to handle the background instead, or even both colors REM the compressed setup - data reading version 100 OPTION BASE 0::DIM CF(14)::FOR I=0 TO 14::READ CF(I)::CALL COLOR(I,CF(I),0)::NEXT I 110 DATA 1,2,3,4,5,6,1,10,3,11,2,9,13,14 REM the compressed setup - random colors version 100 OPTION BASE 0::DIM CF(14)::FOR I=0 TO 14::CF(I)=INT(RND*16+1)::CALL COLOR(I,CF(I),0)::NEXT I 110 REM NO DATA NEEDED REM game code blah blah blah, assume vars for the position-of-interest (PX, PY) and colorset foreground value (CS) REM this is whatever you want in your game, it just demos fetching the colorset foreground 500 PX=12::PY=8::GOSUB 10000::DISPLAY AT(1,1):CS 600 CALL KEY(0,K,S)::IF S=0 THEN 600 700 END REM the compressed colorset foreground fetch 10000 CALL GCHAR(PY,PX,CV)::CN=INT(CV/8)-3::CS=CF(CN)::RETURN Lines 100, 10000, and optionally 110, are the only lines which are the actual colorset routines. Everything else is your game code. It expects at least three global variables (as stated in the REM comments), one each for row position, column position, and colorset number storage, so be sure you define those as well. Thanks man! I didn't mean for you to have to write me any code, but I'll definitely use this with gratitude. The basic premise of the game is that you're picking up diamonds of varying colors - some colors give you points, others take points away, kill you, or do other stuff. Each time you pick one up, all the other diamonds' colors change, leaving you stuck choosing the 'least worst' option sometimes. I figured being able to identify the color quickly, and then change the entire charset's color at once, would make the game fast. The only disadvantage, of course, is that you then end up using up quite a bit of your character sets to have one diamond character of each of the colors you use. More later, hopefully. Quote Link to comment Share on other sites More sharing options...
The Codex Posted April 15, 2010 Share Posted April 15, 2010 You are a cruel, cruel man with the puzzle games. Quote Link to comment Share on other sites More sharing options...
InfernalKeith Posted April 15, 2010 Author Share Posted April 15, 2010 You are a cruel, cruel man with the puzzle games. Well, when you suck at sprites, your options are limited. 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.