Jump to content
InfernalKeith

XB command question

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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 by The Codex

Share this post


Link to post
Share on other sites

Um, might help if I actually populated the arrays in the example. :sad:

 

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

Share this post


Link to post
Share on other sites

Um, might help if I actually populated the arrays in the example. :sad:

 

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

Share this post


Link to post
Share on other sites

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 by sometimes99er

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 by The Codex

Share this post


Link to post
Share on other sites

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.

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