Jump to content
IGNORED

IntyBASIC Change Foreground Color of SCREEN Area?


First Spear

Recommended Posts

Hey all.

 

My code has some graphic card data that looks like this:

       super_cards:
       DATA $0000,$0000,$0000,$0000,$02FF,$0687,$0000,$0000

There is a lot of data that looks like that, $02FF (solid white block) and $0687 (block 4px high and 8px wide). The image data gets rendered with the SCREEN statement.

 

What I want to do is change the foreground color so it shows in a random value between $02F9 and $02FF for the solid block. This has to happen on the following BACKTAB locations

80-87

100-107

120-127

140-147

160-167

180-187

200-207

220-227

 

What is a good way to do that?

 

Thanks.

 

Link to comment
Share on other sites

The former. Just a new color instead of white for the whole region before the user sees it. I understand that the card data is in ROM and can't be changed, so I am hoping there is a way with SCREEN or some other color change can be made so the image does not flicker with the original white before the destination color changes.

 

Thanks!

 

 

Do you want to paint this character once in a random colour at the given locations, or do you want a solution where you can paint each location and afterwards somehow change the colour/palette for a certain location, like colour cycling?

Link to comment
Share on other sites

I'm not sure if I have understood you correctly, but this is the best I can do:

 

  MODE 1:DEFINE 0,1,gfx:WAIT

loop:
  SCREEN screen_cards,0,0,20,12
 
  FOR i=80 TO 220 STEP 20
    #j=$3e00 + RANDOM(
    FOR k=i TO i+7
      #BACKTAB(k)=(#BACKTAB(k) AND $07f8) + #j
    NEXT
  NEXT
 
  WHILE CONT.BUTTON = 0:WEND
  WHILE CONT.BUTTON:WEND
 
  GOTO loop
 
screen_cards:
 DATA $0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802
 DATA $0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801
 DATA $0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807
 DATA $0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806
 DATA $0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805
 DATA $0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804
 DATA $0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803
 DATA $0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802
 DATA $0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801
 DATA $0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807
 DATA $0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806
 DATA $0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805

gfx:   DATA $7e3c,$ffff,$7eff,$003c
Indeed it will flicker very briefly between the SCREEN command, which I'm using here to restore the entire screen, and painting the coloured bars.

 

I tried a solution using multiple SCREEN commands too, but it wasn't any faster and besides in case your graphics can be any symbols, it wouldn't work. I also tried using SCREEN with array variables but didn't get it to work as expected, plus that it didn't seem to go any faster.

 

I suppose if you're using a memory expansion, you could dynamically prepare a backtab with the exact desired content and restore that with the variable syntax. You would need 240 of those 16-bit variables though.

Edited by carlsson
  • Like 1
Link to comment
Share on other sites

If your game anyway will use e.g. JLP memory, you can waste a good 240 words as a double buffer:

 

  REM Needs to be compiled with JLP support!

  MODE 1:DEFINE 0,1,gfx:WAIT

  DIM #buffer(240)

  m=0
 
loop:
  FOR i=0 TO 239
    #buffer(i)=screen_cards(i)
  NEXT

  FOR i=80 TO 220 STEP 20
    j=RANDOM(
    FOR k=i TO i+7
	  #buffer(k+m) = $3e00 + (#buffer(k+m) AND $07f8) + j
    NEXT
  NEXT

  SCREEN #buffer,0,0,20,12

  WHILE CONT.BUTTON = 0:WEND
  WHILE CONT.BUTTON:WEND

  m=m+1:IF m>12 THEN m=0
  GOTO loop

screen_cards:
 DATA $0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802
 DATA $0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801
 DATA $0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807
 DATA $0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806
 DATA $0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805
 DATA $0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804
 DATA $0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803
 DATA $0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802
 DATA $0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801
 DATA $0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807
 DATA $0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806
 DATA $0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805,$0804,$0803,$0802,$0801,$0807,$0806,$0805

gfx:
  DATA $7e3c,$ffff,$7eff,$003c
Note that this won't compile or work on a stock Intellivision, though it is definitely flicker free.
  • Like 1
Link to comment
Share on other sites

I had asked a similar question a few weeks back, just with background colors instead of foreground. Maybe this could be a new feature of the SCREEN command where the foreground/background color could be modified before being placed on screen?

 

Look at the code nanochess provided in post #2. Hopefully this helps. http://atariage.com/forums/topic/284499-how-to-change-background-colors-quickly-with-intybasic/

Link to comment
Share on other sites

I might be barking up the wrong tree here, but if the issue is that changes on the screen might be visible too soon, is it possible to tamper with the Display Enable register at STIC $20? I read that the interrupt routine toggles it on every frame in order for the display to not go blank, but on the other hand, is it feasible to not hit the register until you are certain you want the display enabled? It would require a rewrite of the IntyBASIC epilogue, but is even a solution worth looking into? Obviously it would cause the screen to flicker if you don't enable it for every frame, but I don't know what it will look like.

  • Like 1
Link to comment
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.
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...