Jump to content

ZackAttack

Members
  • Content Count

    785
  • Joined

  • Last visited

Posts posted by ZackAttack


  1.  

    I knew you could put actual code between asm and end, but I didn't know/remember that you could put a file between asm and end.

    I think you're overlooking the fact that dasm recognizes include so the following is actually a line of asm technically.

    include "HelloWorld/test.asm"

    I assume dasm is what is actually performing the step of loading that file and inserting it's contents inline.


  2. That's not going to work because the asm file is defining the physical(ROM) location of the code which is not compatible with the asm the basic source is being transformed into.

     

    You could try trimming the test.asm file so it doesn't have any seg or org statements, but even then I think you're going to run into problems with what you're trying to do. In order to get this working you would probably need a very good understanding of assembly programming.

     

    There is also a good chance that the generated test.asm is going to corrupt the state of the bB code. So even if you get it to compile it will likely crash.


  3. I'd start with a basic finite state machine (FSM) that has 2 states, traveling and navigate. In the traveling state the AI agent would continue to move in the same direction until it aligns with the PF, at which time it would transition to the navigate state. In the navigate state I would map the A.I. agent's location to the PF pixel/block that it is currently aligned with and then look at the surrounding pixels (top, bottom, left, right) to determine which directions it can go without colliding with a wall. Once a new course is chosen it would transition back into the traveling state and start the process all over again.

     

    The selection of available directions could be made at random or use an algorithm to chase/flee the player.


  4. Nice job. I played through a couple times and didn't see any bugs. I wish my game was progressing this quickly.

     

    Have you considered making the boss behave less random? Maybe he could move in a preset path and then randomly choose between a few different attack types. Like moving left to right at the top of the screen and then swooping down at you. Maybe he'd only take damage when he's in certain states. It could make it feel more boss like. Assuming you haven't already run out of resources or moved on to the next project.


  5. Btw, the falling off in PF0 region bug still exists, it just has 3 monsters going crazy when it happens now. You are able to reproduce this bug right?

     

    I suppose the biggest challenge with the coordinates is that you can't compare them directly because the widths of both objects are greater than one. So you need to create a hitbox for each and then test if the hitboxes intersect.

     

    Personally I would probably just mask off the lower bits of each coordinate and compare them like that. Chances are that would produce correct results most of the time. It would look something like this:

     ;**PSEUDO CODE**
     if (monster0.x & $e0)=(missile0.x & $0e) AND (monster0.y & $e0)=(missile0.y & $e0) then gosub HideMonster0
    

    Of course you could always just go back to no monsters 25% of the time. Though getting ambushed does look cooler.


  6. Ok, now I get what you're doing. m is multiplexed to hold if the current state is moving right and the sequence count. n is multiplexed to hold if the current state is moving left and the sequence count.

     

    Since the sequence count never exceeds 16 it only requires 5 bits and each state indicator only requires a bit each. You could multiplex all 3 into just a single variable. I don't think it would really make the code much more difficult to read and you free up a variable each place you are doing this. So it could be worth checking out. I can throw together some example code if you're not sure what I'm suggesting.

     

    Here's a few comments about your example that may be helpful.

     

    Aliases can be used to give variables more meaningful names.

     

     

    bB does support if else constructs.

     if joy0right then m=m+1 else m=0
    
    ;is equivalent to
    
     if joy0right then m=m+1
     if !joy0right then m=0
    
    

    When a variable needs to be limited to a range of 0 <= var < 2^n it can be bitwise ANDed with (2^n)-1 to save a few cycles and make the cycle count constant.

     m = m & $0F
    
    ;is equivalent to
    
     if m>15 then m=0
    

    This also makes it easier to multiplex the direction indicators into the same variable.

     ;Roll sequence count back to 0 without clearing direction flags (bits 7 and 6)
     m = m & $EF
    

  7. Have you heard about learnfun & playfun? It's something similar for the NES, but the source code was released and I bet it wouldn't be terribly difficult to adapt it to the VCS.

     

    Another thought is that it might be possible to just brute force all the possible input combinations for a given game on the VCS since the system is so small compared to a modern PC.


  8.  

    In my game you will notice that the two special attack animations (down+action) loop one way, mirror, and then loop the other way (while activating a collision, timed at the blade),and then stop and reset to the primary frame. This is very easy to do with two controlled variables. I use several instances in the game where two variables are used in tandem to control various aspects of animation.

    I assume one of those variables is to count through the sequence of frames. How is the second variable used?


  9. It would be nice to have more cycle count subsections on the bB page.

     

    It would also be nice to have a new section or subsection that lists the cycle count and ROM space saved (or wasted) for various programming techniques.

    I wouldn't mind contributing to this. Should I start a new topic or just send you updates via PM?


  10. I use certain animation that loops back and forth and must have multiple variables. I was quoting 'the book' for the the programmer. I'm also pretty sure that answering in assembly isn't going to help this beginner with ease of use, or help to explain how to stop the sprite! Ease of use does calculate into efficiency, in my opinion.

    I'm not exactly sure what you mean by loops back and forth. Could you provide an example? I do agree with you on keeping the code simple when possible. Also, I'm not trying to say that the method you suggested is wrong or worse. I just thought it would be interesting to analyze them more in depth and figured why not share my findings.

     

     

     

    but of course you should gosub to the on goto and then return

    (if you just have to use on goto) instead of that jump there then

    jump back nonsense, and that will cost something ;)

     

     

    re a blog, a tabulation and comparison of different techniques would

    be usefull but it could get complicated

    (eg if it were me I'd probably put the sprites in a data statement)

    I was thinking it would be more focused on the "how it works" rather than "which is better".


  11. For fun, let's look at the disassembly of both methods and compare them. I'm sure Papa already knows all this, but for the rest of us it should be educational.

     

    Method #1 (Chained IF statements)

      if a=0 then l1
      if a=1 then l2
      if a=2 then l3
      if a=3 then l4
    
    produces
    
    LDA $D6
    CMP #$00
    BEQ l1
    LDA $D6
    CMP #$01
    BEQ l2
    LDA $D6
    CMP #$02
    BEQ l3
    LDA $D6
    CMP #$03
    BEQ l4
    

    If the last branch is taken the total cycles consumed will be 4 LDA ZP (3), 4 CMP (2), 3 BEQ-not taken (2), 1 BEQ-taken (3) for a grand total of 29 cycles. This could have been reduced to 20 if the compiler was a little smarter about omitting the redundant loads. Another observation is that this code runs in O(n) time. In other words, the more if statements you chain the more valuable CPU cycles you consume. The other problem is the loss of ROM space. It takes 6 bytes to add the LDA/CMP/BEQ instructions for each if statement.

     

    Method #2 (on ... goto)

    on a goto l1 l2 l3 l4
    
    Produces:
    
    LDX $D6
    LDA MSB_Lookup,X
    PHA
    LDA LSB_Lookup,X
    PHA
    RTS
    
    *MSB_Lookup and LSB_Lookup each contain a byte per label in on ... goto construct
    
    
    

    In all cases the total cycles consumed will be 1 LDX ZP (3), 2 LDA Absolute,X (4), 2 PHA (3), 1 RTS 6 for a grand total of 23. What is even more interesting is that the code runs in O(1) time. In other words, it's going to take 23 cycles regardless of how many labels you have. An added bonus is that each new label will only use 2 bytes of ROM to expand each lookup table by a byte.

     

    So in conclusion, using the on...goto method is the better solution when efficient use of CPU is important. I'd also like to point out that both methods only dealt with a single variable. So I don't understand the claim that it will use less RAM. None of this should come as any surprise since RT generally provides sound advice based on many years of experience with bB.

     

    If any bB programmers found this interesting or usefull let me know. I may consider creating a blog where I analyze different commands periodically.

    • Like 4

  12. I like the game concept, it's very entertaining. You may want to swap the left and right controls to make it feel more like you're in a t-rex simulator. Right now it feels like you're controlling the fleeing student instead of the dinosaur.


  13. I'd like to make a couple bees flying in a overlapped figure-eight pattern as one of the enemies in this game. Does this sprite look ok? Any suggestions on how to improve it? I'm aiming for something similar to this. It needs to be a normal width sprite, but it is full resolution and can be as tall as you want.

     

    post-40226-0-17867500-1425053208.png

     

    • Like 2
×
×
  • Create New...