Jump to content
IGNORED

One single SCREEN for multiple DATA levels


Recommended Posts

Hi friends.


I would like to know if you can help me with this issue.

I have several levels in the game in a huge DATA sequence (about 700 lines):

 

GameScreens:
      DATE $AB6B,$AB6B,....
      DATE $AB6B,$AB6B,....

 

When the player advances to level 2, I use a variable to position the start of the data in the SCREEN command like this:

 

#ScreenAdjust=#ScreenAdjust+2223
SCREEN GameScreens, #ScreenAdjust, 0,14,BACKGROUND_ROWS,LastCol

 

Is there any way to break the DATA into multiple levels and still use only 1 SCREEN command (without IF)?

 

Something like this (it doesn't work):


Screens:
      DATA VARPTR Screen1(0)
      DATA VARPTR Screen2(0)
Screen1:
      DATE $AB6B,$AB6B,....
      DATE $AB6B,$AB6B,....
Screen2:
      DATE $BBBB,$BBBB,....
      DATE $BBBB,$BBBB,....

 

SCREEN Screens(0), 0, 0,14,BACKGROUND_ROWS,LastCol


Instead of this:

 

Screen1:
      DATE $AB6B,$AB6B,....
      DATE $AB6B,$AB6B,....
Screen2:
      DATE $BBBB,$BBBB,....
      DATE $BBBB,$BBBB,....

 

IF Level=1 THEN
    SCREEN Screen1, 0, 0,14,BACKGROUND_ROWS,LastCol
ELSEIF Level=2 THEN
    SCREEN Screen2, 0, 0,14,BACKGROUND_ROWS,LastCol
ELSEIF ....

 

Thanks!

 

Link to comment
Share on other sites

Not sure, but if you look at the generated assembly code, it might be possible to create a workaround by duplicating the code that is generated, but change one or two instructions to operate with VARPTR. I have made the same thing with the PLAY command, changes that haven't made their way into the language.

Link to comment
Share on other sites

@Intellivision Brasil

As expected, you can apply the very same principle to the SCREEN command as I did with the PLAY command. One drawback is that it gets more complicated if you want to change origin offset of your screen, but all the other parameters are the same.

 

I presume that BACKGROUND_ROWS is a constant, but LastCol is a variable? In that case, you need to look up how the compiler reads the value of a parameter and change the assembler code to the same syntax.

 

I don't know which additional features of IntyBASIC can utilize the VARPTR syntax, but here we have two examples: play different songs based on a variable, and display different screens based on a variable. Both solve the problem in just about the same way. Perhaps it can be generalized and something to add to the compiler for the future? @nanochess

many-screens.bas

Link to comment
Share on other sites

My suggestion would be to calculate yourself the offsets for the DATA table:

 

Something like this:

 

Screens:
      DATA 0
      DATA 240       ' Supposing the size of the previous screen

      DATA 480

      .... ' Etc etc
Screen1:
      DATE $AB6B,$AB6B,....
      DATE $AB6B,$AB6B,....
Screen2:
      DATE $BBBB,$BBBB,....
      DATE $BBBB,$BBBB,....

 

SCREEN Screen1, Screens(room), 0,14,BACKGROUND_ROWS,LastCol

 

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