Brian's Man Cave Posted April 18 Share Posted April 18 If I define all my bitmaps. Then during the game I define again a bunch of bitmaps for animation purposes, is there a limit to how many can be redefined? Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted April 18 Share Posted April 18 Just now, Brian's Man Cave said: If I define all my bitmaps. Then during the game I define again a bunch of bitmaps for animation purposes, is there a limit to how many can be redefined? What do you mean? Could you be a bit more precise in what you are asking? Here are a few limitations: You can use at most two DEFINE statements per frame (DEFINE and DEFINE ALTERNATE). You can load up to about 16 cards per frame. You could attempt to load more, but the ones that didn't make it will not load. You can load as many different cards as you want using DEFINE throughout your game. That is, you can load a different set of cards on each frame using DEFINE if you like. dZ. Quote Link to comment Share on other sites More sharing options...
Brian's Man Cave Posted April 18 Author Share Posted April 18 1 hour ago, DZ-Jay said: What do you mean? Could you be a bit more precise in what you are asking? Here are a few limitations: You can use at most two DEFINE statements per frame (DEFINE and DEFINE ALTERNATE). You can load up to about 16 cards per frame. You could attempt to load more, but the ones that didn't make it will not load. You can load as many different cards as you want using DEFINE throughout your game. That is, you can load a different set of cards on each frame using DEFINE if you like. dZ. So I have my game loop with 2 characters on the screen. For each of their movements I redefine the bitmaps. Perhaps I am trying to load more than 16 per frame as you stated above. I am still trying to figure out frame timing. If my code has the label game_loop then ends with goto game_loop… is that one frame? Quote Link to comment Share on other sites More sharing options...
+cmadruga Posted April 18 Share Posted April 18 You can define: - 18 cards per frame with no music. - 16 with music. - 13 with ECS music. I don't know if those 2 characters you mention are in the same card set. If yes, you can use a single DEFINE instruction for both. If not, you can use DEFINE ALTERNATE for one of them. Make sure you have a WAIT instruction on your game loop, that drives the change in frames and ensures the DEFINEs will 'stick'. Hope this helps. 1 Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted April 18 Share Posted April 18 7 hours ago, Brian's Man Cave said: So I have my game loop with 2 characters on the screen. For each of their movements I redefine the bitmaps. Perhaps I am trying to load more than 16 per frame as you stated above. I am still trying to figure out frame timing. If my code has the label game_loop then ends with goto game_loop… is that one frame? A frame is marked when the video chip (STIC) interrupts the CPU to draw the video frame for the TV. It is a hardware event, driven by the TV signal. It occurs regularly at 60Hz (60 times a second) on NTSC, 50Hz on PAL/SECAM. The typical game loop, prepares all the sprites and graphics, and updates the game state, and then calls WAIT to wait for the next frame. Something like this: MainLoop: ' Update game state, graphics, and stuff ... ' Game logic here ... WAIT Goto MainLoop That represents one game cycle or iteration. You could call it a "frame" but it may or may not be the same as a video frame (i.e., the video hardware interrupt). The frame interrupt will arrive at its precise interval, whether you WAIT for it or not. That is, if your code takes too long to process in one loop iteration, a video hardware interrupt may occur in the middle of it, even before the WAIT statement. When the video frame interrupt arrives, it will apply the changes prepared by the DEFINE statement (among others). The DEFINE only prepares to copy the bitmaps, it's when the interrupt arrives that they get loaded. Now, I keep saying "interrupt" while others talk about "WAIT," and this is on purpose. The WAIT statement does no magic -- it merely pauses your game loop and waits idly for an interrupt to arrive. If your game logic runs neatly within the time it takes between interrupts, then your game cycle matches the frame rate, and a "frame" is the same as a "game loop iteration." However like I said above, if your code takes too long to process, the interrupt may arrive anyway. In that case, the DEFINE will be applied when the interrupt happens, even if it is in the middle of your game loop, and a WAIT later on will just cause it to wait to the next one. What is actually the problem you are experiencing? Is it that your graphics do not appear on the screen even after using DEFINE? Perhaps if you shared some code we may be able to help. dZ. Quote Link to comment Share on other sites More sharing options...
Brian's Man Cave Posted April 18 Author Share Posted April 18 @cmadruga @DZ-Jay Thanks for the explanation and assistance. I just tried using DEFINE ALTERNATE and that seemed to do the trick. I will have to check how many cards are being updated at once to make sure I am not going over the limit! Its two different card sets that are being updated. Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted April 18 Share Posted April 18 2 hours ago, Brian's Man Cave said: @cmadruga @DZ-Jay Thanks for the explanation and assistance. I just tried using DEFINE ALTERNATE and that seemed to do the trick. Then the problem is not the number of cards. The difference between DEFINE and DEFINE ALTERNATE is that each one can load a different set. Using both allows you to load from two separate sets in one go. However, you still can only load up to 18 (or less, as @cmadruga mentioned) in one frame between them. 2 hours ago, Brian's Man Cave said: I still do not understand the problem. If you were using a single DEFINE before, then you couldn’t have been loading multiple sets of cards, since you can only include one on each DEFINE statement. If you were using multiple DEFINE statements one after the other without a WAIT in between — then that is your problem. Only one DEFINE is applied per frame. If you include more than one, only the last one would take effect. That’s what DEFINE ALTERNATE gives you: it allows you to use two DEFINES at once (the second one is the ALTERNATE one). dZ. Quote Link to comment Share on other sites More sharing options...
Brian's Man Cave Posted April 18 Author Share Posted April 18 48 minutes ago, DZ-Jay said: Then the problem is not the number of cards. The difference between DEFINE and DEFINE ALTERNATE is that each one can load a different set. Using both allows you to load from two separate sets in one go. However, you still can only load up to 18 (or less, as @cmadruga mentioned) in one frame between them. I still do not understand the problem. If you were using a single DEFINE before, then you couldn’t have been loading multiple sets of cards, since you can only include one on each DEFINE statement. If you were using multiple DEFINE statements one after the other without a WAIT in between — then that is your problem. Only one DEFINE is applied per frame. If you include more than one, only the last one would take effect. That’s what DEFINE ALTERNATE gives you: it allows you to use two DEFINES at once (the second one is the ALTERNATE one). dZ. The 2 characters I have on the screen each use their own set of bitmaps. The player character animates by changing bitmaps (moves his legs), the other character moves when it gets shot/hit by a sprite. So I assume my issue was that I was Defining both at the same time without using that Alternate. Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted April 18 Share Posted April 18 56 minutes ago, Brian's Man Cave said: The 2 characters I have on the screen each use their own set of bitmaps. The player character animates by changing bitmaps (moves his legs), the other character moves when it gets shot/hit by a sprite. So I assume my issue was that I was Defining both at the same time without using that Alternate. That makes sense, and it is also what I was thinking. I’m glad you were able to solve it. Out of curiosity, I do have some questions on what you are actually doing. When you say that the “player character animates by changing bitmaps,” do you mean you change the bitmaps using DEFINE on every frame, or by changing the card used by the SPRITE command? In other words, are you using DEFINE to load the new bitmap, or are you using it to load all the bitmaps for a character, and then use the SPRITE statement to point to each bitmap in GRAM when animating? I guess it really does not matter since you solved your problem, and the DEFINE ALTERNATE worked for you; but I wanted to better understand what you were trying to do. dZ. Quote Link to comment Share on other sites More sharing options...
Brian's Man Cave Posted April 18 Author Share Posted April 18 1 hour ago, DZ-Jay said: That makes sense, and it is also what I was thinking. I’m glad you were able to solve it. Out of curiosity, I do have some questions on what you are actually doing. When you say that the “player character animates by changing bitmaps,” do you mean you change the bitmaps using DEFINE on every frame, or by changing the card used by the SPRITE command? In other words, are you using DEFINE to load the new bitmap, or are you using it to load all the bitmaps for a character, and then use the SPRITE statement to point to each bitmap in GRAM when animating? I guess it really does not matter since you solved your problem, and the DEFINE ALTERNATE worked for you; but I wanted to better understand what you were trying to do. dZ. I am making a port of Donkey Kong 3, so the game background I made uses quite a bit of bitmaps. In previous games I made, all the character animations were in the same set of bitmaps, so I figured I would try it this way. The character Stanley uses this code: #animate_stan = #animate_stan + 1 if #animate_stan <= 5 then DEFINE ALTERNATE 60,4,screen_bitmaps_stan_1 else DEFINE ALTERNATE 60,4,screen_bitmaps_stan_2 end if if #animate_stan > 10 then #animate_stan = 0 so when he is moving, I swap the bitmaps to show animation in his legs. Donkey Kong is the same... I have created a variable called state to show where he is on the ropes. When DK moves up or down the ropes (State 1, State 2 etc.) I load in the set of bitmaps to show his movement and update the #Backtabs. Not sure if this is the best method to do this, but its all I could think of Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted April 18 Share Posted April 18 15 minutes ago, Brian's Man Cave said: I am making a port of Donkey Kong 3, so the game background I made uses quite a bit of bitmaps. In previous games I made, all the character animations were in the same set of bitmaps, so I figured I would try it this way. The character Stanley uses this code: #animate_stan = #animate_stan + 1 if #animate_stan <= 5 then DEFINE ALTERNATE 60,4,screen_bitmaps_stan_1 else DEFINE ALTERNATE 60,4,screen_bitmaps_stan_2 end if if #animate_stan > 10 then #animate_stan = 0 I suppose that "#animate_stan" is a counter that signals when to switch the bitmaps, and that "screen_bitmaps_stan_1" and "_2" are the walking legs pictures, is this correct? If so, why does the DEFINE ALTERNATE says to load 4 cards? Perhaps it is a set instead ...? If so, why do you need 2 sets of walking spanimation sequences? I am not questioning your methods, I am just trying to understand your code. 15 minutes ago, Brian's Man Cave said: Not sure if this is the best method to do this, but its all I could think of That's cool. I just do not follow your explanation completely, so I am not in a position to suggest whether there is a better method or not. dZ. Quote Link to comment Share on other sites More sharing options...
Brian's Man Cave Posted April 18 Author Share Posted April 18 Just now, DZ-Jay said: I suppose that "#animate_stan" is a counter that signals when to switch the bitmaps, and that "screen_bitmaps_stan_1" and "_2" are the walking legs pictures, is this correct? If so, why does the DEFINE ALTERNATE says to load 4 cards? Perhaps it is a set instead ...? If so, why do you need 2 sets of walking spanimation sequences? I am not questioning your methods, I am just trying to understand your code. That's cool. I just do not follow your explanation completely, so I am not in a position to suggest whether there is a better method or not. dZ. Stan is using 2 sprites (doubly) to make him, one sprite for his red outfit/legs and one for his tan face and arms: screen_bitmaps_stan_1: 'looking up BITMAP "......#." 'body red BITMAP "......#." BITMAP "......##" BITMAP "......##" BITMAP ".....###" BITMAP "......##" BITMAP ".....##." BITMAP "........" BITMAP ".....#.." BITMAP "...####." BITMAP "...##.#." BITMAP "...##.#." BITMAP ".###.#.." BITMAP ".#...#.." BITMAP "##....#." BITMAP ".....#.." BITMAP "..##...." 'face Tan BITMAP "..####.." BITMAP ".###.#.." BITMAP "...###.." BITMAP "...###.." BITMAP ".#####.." BITMAP "..####.." BITMAP "...##..." BITMAP "...##..." BITMAP ".....#.." BITMAP ".....##." BITMAP ".....##." BITMAP "....##.." BITMAP "........" BITMAP "........" BITMAP "........" Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted April 18 Share Posted April 18 7 minutes ago, Brian's Man Cave said: Stan is using 2 sprites (doubly) to make him, one sprite for his red outfit/legs and one for his tan face and arms: screen_bitmaps_stan_1: 'looking up BITMAP "......#." 'body red BITMAP "......#." BITMAP "......##" BITMAP "......##" BITMAP ".....###" BITMAP "......##" BITMAP ".....##." BITMAP "........" BITMAP ".....#.." BITMAP "...####." BITMAP "...##.#." BITMAP "...##.#." BITMAP ".###.#.." BITMAP ".#...#.." BITMAP "##....#." BITMAP ".....#.." BITMAP "..##...." 'face Tan BITMAP "..####.." BITMAP ".###.#.." BITMAP "...###.." BITMAP "...###.." BITMAP ".#####.." BITMAP "..####.." BITMAP "...##..." BITMAP "...##..." BITMAP ".....#.." BITMAP ".....##." BITMAP ".....##." BITMAP "....##.." BITMAP "........" BITMAP "........" BITMAP "........" Gotcha! Makes sense. Thanks for the explanation. dZ. 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.