Jump to content
IGNORED

GROM table usage


Mik's Arcade

Recommended Posts

Hi -

 

I found a few topics discussing the GROM table but none seemed to address the problem I am having.

 

I've got a status bar on my screen working.  What I have it doing is that on certain events, I want to print ONE character at a time on the bottom row of the screen. It is basically a timer.

The first character prints at card 220, then 221, then 222.....239

 

This hardcoded logic works...

 

          IF bcard = 220 then PRINT AT bcard COLOR 6, "\0"
          IF bcard = 221 then PRINT AT bcard COLOR 6, "\45"
          IF bcard = 222 then PRINT AT bcard COLOR 6, "\33"
          IF bcard = 223 then PRINT AT bcard COLOR 6, "\39"
          IF bcard = 224 then PRINT AT bcard COLOR 6, "\41"
          IF bcard = 225 then PRINT AT bcard COLOR 6, "\35"

          .

          ..

          ...

          IF bcard = 239 then PRINT AT bcard COLOR 6, "\0"

 

Obviously, I want to replace this all with 2 lines of code:

 

          PRINT AT bcard COLOR 6, bonus_bar(bval)
          bcard = bcard + 1 : bval = bval + 1     

 

bonus_bar is a series of DATA strings to hold the values.   bcard is initially set to 220 and bval is set to 0.

 

bonus_bar:

DATA "\0","\45","\33","\39","\41"
DATA "\35","\0","\34","\47","\46"
DATA "\53","\51","\0","\0","\0"
DATA "\0","\0","\0","\0","\0"

 

 

It compiles, but when it runs it prints out junk for the letters, the blanks print fine, but that could be a happy accident.

 

Also, does the GROM table work with #BACKTAB  ?

 

I tried          

#backtab(bcard) = bonus_bar(bval)

 

And got same results....

 

thanks in advance

 

 

 

Edited by Mik's Arcade
added more info
Link to comment
Share on other sites

For the second approach, I would use numerical values in the DATA statement, then multiply bonus_bar(bval) by 8 and add the constants for background and foreground colour to the value that you put into #BACKTAB. Or if you have a fixed colour (like you seem to have $0006 = yellow on black), bake it into the data with the multiplication.

  • Like 1
Link to comment
Share on other sites

6 hours ago, carlsson said:

For the second approach, I would use numerical values in the DATA statement, then multiply bonus_bar(bval) by 8 and add the constants for background and foreground colour to the value that you put into #BACKTAB. Or if you have a fixed colour (like you seem to have $0006 = yellow on black), bake it into the data with the multiplication.

Man, you are such a genius!

 

 

I used the numerical values in the data statement and then these 2 line of code worked:

 

bonus_bar:                 
DATA 0,45,33,39,41
DATA 35,0,34,47,46
DATA 53,51,0,0
DATA 0,0,0,0,0
 

  #backtab(bcard) = bonus_bar(bval) * 8 + 6

   bcard = bcard + 1 : bval = bval + 1 

 

I actually tried this yesterday with PRINT, but not with BACKTAB and I doubt I would have known to do the * 8 + 6 part anyways.

 

A have a Ninja Commander moving from the left of the screen to the right, and when it hits the right boundary it triggers this code and starts moving left

Then, when it hits the left boundary it triggers again and starts moving right.

This repeats and if you can't kill him before BVAL = 20, you LOSE!!!!  LOL.  But fear not, this is the easiest boss....it's like your practice run for the harder ones.  They will have their own triggers for this logic.

 

Now that it works I will space the letters out so it is not all those blanks at the end.

 

as always, many thanks!!

Edited by Mik's Arcade
  • Like 2
Link to comment
Share on other sites

I'm not sure that I'm a genius, but I've "been around" before if you know what I mean.

 

This example works:

 

  MODE 1

  FOR i=0 TO 19
    PRINT AT 40+i,text(i)*8+6
  NEXT

loop:  GOTO loop

REM text:
REM  DATA " ","M","A","G","I","C"
REM  DATA " ","B","O","N","U","S"
REM  DATA " "," "," "," "," "," "," "," "

text:
  DATA "\0","\45","\33","\39","\41"
  DATA "\35","\0","\34","\47","\46"
  DATA "\53","\51","\0","\0","\0"
  DATA "\0","\0","\0","\0","\0"
Edited by carlsson
Link to comment
Share on other sites

I always feel like there is new stuff to learn.

 

Unfortunately, this works, but now that I am testing movement of both the player and the Commander I have a new problem.

 

Once I start moving the player, it advances the bar all the way.  I don't know how this could happen because the only time this code is executed is when the X axis of the commander hits a threshold.  The player variables are all unique and part of a different subroutine all together.  I'm sure this has everything to do with FRAME and screen refresh.0...lol. I hope I can figure this out as it is quite a wrench. 

Edited by Mik's Arcade
Link to comment
Share on other sites

wow.....this is very odd.

 

It seems when I move the player, it is also causing the Commander to move as well. I have no idea how this can happen as they are using separate variables and GOSUB calls to control their individual states

 

I'm using the same logic as I used on the main loop when he battles the ninjas and don't have any issues. 

 

What a show stopper.....I'll figure it out eventually....

Link to comment
Share on other sites

14 hours ago, cmadruga said:

One idea is to check for typos... maybe the Commander's sprite coordinates are using the player ones due to a copy & paste 'malfunction', etc.

 

Yeah, I just went over the code and was hoping for something that easy.  So, far, that is not the case. it is very bizzare....I'll get it eventually.

 

EDIT:  The more I test the more I can see what's going on, but not quite sure how to fix yet.

 

It seems when I move the player (either left or right), it is somehow causing the Commander to move to right on top of the code that moves the commander depending what state he is in. So it sort of fast forwards the commander to the right. (This was also fast forwarding the status bar that was my original l issue.)

 

It's odd, because I use the same code for controlling and moving the player in the main loop and this does not happen to the regular enemy states, and there are six moving at a time!  Go figure I would have a problem with just managing one enemy....lol.   The code is a bit different in this loop so I just need to figure out how to keep the player state code from messing with the enemy state code. 

 

Edited by Mik's Arcade
Link to comment
Share on other sites

I fixed it!   But, I will need help from the braniacs to explain why this matters.

 

So, for the boss fights I am just using the same array variables I use for the regular ninja in order to save variables and be lazy so I can cut and paste.

 

So, for example I used nx(c) and ny(c) to reference the X and Y coordinate for the 6 enemy ninjas on screen. I'd use a FOR C = 0 to 5 LOOP to handle all the work

 

Since I only have ONE boss, I just referenced these values as nx(0) and ny(0) as I don't need a loop.

 

Everything magically fixed itself when I did this instead

 

c = 0

nx(c)

ny(c)

 

What is the term for this? Direct versus indirect referencing?  Why would this even matter?

 

Either way, we are all good now!   Everything works.  The player and commander boss all do their own things while the bonus timer ticks away down to zero.  This also taught me how to build out the mile tracker I was looking for in my Marathon Quest game.

 

Oh my goodness I am so close to completing this game! I just need to add enemy weapons to the mix and the win/lose states, then the bonus battle code is done and then I just need to set up the other bosses.

 

Edited by Mik's Arcade
Link to comment
Share on other sites

On 11/16/2021 at 1:52 PM, Mik's Arcade said:

Everything magically fixed itself when I did this instead

 

c = 0

nx(c)

ny(c)

 

What is the term for this? Direct versus indirect referencing?  Why would this even matter?

Interesting, without seeing the code I can't think of a reason why this would make a difference.

 

On 11/16/2021 at 1:52 PM, Mik's Arcade said:

Oh my goodness I am so close to completing this game! I just need to add enemy weapons to the mix and the win/lose states, then the bonus battle code is done and then I just need to set up the other bosses.

Keep going! You are on the home stretch!

 

(Being able to call a game "complete" is a challenge in itself for me. But I'm getting better.)

 

Link to comment
Share on other sites

2 hours ago, cmadruga said:

Interesting, without seeing the code I can't think of a reason why this would make a difference.

 

Keep going! You are on the home stretch!

 

(Being able to call a game "complete" is a challenge in itself for me. But I'm getting better.)

 

 

It is still a head scratcher to me why setting C =0 and using nx(c) instead of just nx(0) made a difference, but oh well. Everything is working fine now. All I have left to do now is program for allowing the boss to fire weapons and I am done with the major coding from end to end. Then I just need to set up the other bosses and their behavior in the framework. I was hoping for a contest because I want the judges to do a code peer review and grade it. I might ask Oscar or someone to do it if they have the time once I am 100% done with it, or wait for the next contest in 2022.  Maybe I can have 2 games done for it.

 

After that, it's the fun stuff. I need to go back, polish it up, add the sound effects, and add quality of life changes. But this is the much easier stuff. Icing on the cake. With what I learned since starting, I can clean up some of the code and get rid of redundancies. I am also going to improve the graphics since I "get" how to layer sprites now.  :) 

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