Jump to content

bogax

Members
  • Posts

    941
  • Joined

  • Last visited

1 Follower

Profile Information

  • Gender
    Male

Recent Profile Visitors

12,123 profile views

bogax's Achievements

Dragonstomper

Dragonstomper (6/9)

261

Reputation

  1. you didn't say what the problem is the code looks like it's for 8x8 sprites playfield pixels are 4x8 player pixels and the playfield coordinates don't jibe with player coordinates the player movement code does collision detection by converting player coordinates to playfield pixels and checking to see if there's a playfield pixel in the way it does the conversion by adding an offset to the player position and dividing by 4 (for x) or 8 (for y) you probably want to adjust the offsets to compensate for the difference in the sprite dimensions
  2. a couple of previous Multiple Sprite Shots with NUSIZ1 (Standard Kernel) Questions about NUSIZ1
  3. The short answer is yes, but a little ASM helps a lot Here are some previous comments
  4. I was thinking something like this ; d3 = 100's, d2 = 10's, d1 = 1's d3 = 0 : d2 = 0 : d1 = temp1 if d1 >= 100 then d3 = d3 + 1 : d1 = d1 - 100 if d1 >= 100 then d3 = d3 + 1 : d1 = d1 - 100 if d1 >= 50 then d2 = d2 + 5 : d1 = d1 - 50 if d1 >= 30 then d2 = d2 + 3 : d1 = d1 - 30 if d1 >= 20 then d2 = d2 + 2 : d1 = d1 - 20 if d1 >= 10 then d2 = d2 + 1 : d1 = d1 - 10
  5. What you want to do is subtract the 10's frome temp1 and add them to temp2 so you end up with the 10's in temp2 and the 1's in temp1 so the if statements would be like if temp1 > 99 then temp2 = temp2 + 10 : temp1 = temp1 - 100 ; temp2 gets the 10's ie 100 = 10 10's
  6. the fractional part is still just a byte it can reperesent 256 values, 0..255 inclusive as a .8 fraction (8 is the number of bits in a byte) a byte is the integer number of 256ths (1/256) 1 = 256 256ths .25 = 256 * .25 = 64 for 0.25 you have two bytes 0 and 64 ie the fractional byte will equal 64 this will be relatively neat in your case because youre looking for multiples of a power of two so eg .25 (a power of 2, 2^-2) is an integer number of 256ths if you want to test for 1.5 it will be 1 and .5 * 256 = 128 if a = 1 && b = 128 then [do something] for non powers of two it gets messier 0.33 is 84.48 256ths ie .33 * 256 = 84.48 and bB rounds it to 84 personally I'd dim it as b.a because the variables are in order in memory and the processor is little endian and expects a 16 bit quantity to be in order in memory with the least byte first but that has nothing to do with what you're doing
  7. some things need to be page aligned its possible that adding a few bytes or rearranging things could cause bB to add a bunch of padding
  8. you don't have to avoid gosubs but you do have to be mindfull of how deep you're going I have sometimes wondered if it would be worth doing a bit of indirection in the returns so eg you'ld define 16 return labels and implement a stack of nibbles for 4 bit return tokens with the stacking and returns done in software it would be messy and slow but you could turn 1 stack position into 4 (and would 16 possible returns be enough? could be a different 16 for each bank)
  9. 1 if you're only using horizontal and vertical you wouldn't need the timer which is only to make the second tap diagnol recognizeable as such 2 I think it would be trivial to either coerce a diagnol to horizontal or vertical or just ignore diagnols 3 its moot if you don't want to adapt it any way 😜 really I just meant to show the behavior without timing the double tap, the use of SWCHA and the use of tables (I just threw all those defs and macros and verbose names in there to keep RT happy )
  10. here I added a delay it uses another variable half for saving the state of SWCHA and half for a timer when it sees a change on SWCHA it starts the timer then processes the joystick when it times out a 4 frame delay seems a reasonable compromise between too long and not long enough (for me anyway) set optimization noinlinedata dim counter = c dim move_flags = m dim move_direction = temp1 dim j0_direction = temp2 def joy_was_0 = m{6} def frame_parity = m{5} def speed_x_2 = m{4} def true = 1 def false = 0 def set_move_flag = callmacro smd_mac def get_move_flag = callmacro gmd_mac const noscore = 1 const delay = 4 macro smd_mac {1} move_flags = (move_flags & %11110000) | {1} end macro gmd_mac {1} {1} = move_flags & %00001111 end gosub init loop COLUP0 = $38 COLUPF = $86 drawscreen get_move_flag move_direction if !collision(playfield, player0) then check_counter player0x = player0x - x_move_table[move_direction] player0y = player0y - y_move_table[move_direction] move_flags = 0 : move_direction = 0 goto skip_move check_counter if counter & $0F then count_down if (counter ^ SWCHA) & $F0 = 0 then check_parity counter = (counter & $F0) | delay goto check_parity count_down counter = counter - 1 if counter & $0F then check_parity check_joy0 j0_direction = (SWCHA ^ %11111111)/16 j0_direction = direction_table[j0_direction] if j0_direction = 0 then check_parity if j0_direction <> move_direction then move_direction = j0_direction : speed_x_2 = false : goto check_parity if joy_was_0 then speed_x_2 = true check_parity if speed_x_2 then do_move if frame_parity then skip_move do_move player0x = player0x + x_move_table[move_direction] player0y = player0y + y_move_table[move_direction] skip_move if SWCHA & $F0 = $F0 then joy_was_0 = false else joy_was_0 = true if frame_parity then frame_parity = false else frame_parity = true set_move_flag move_direction counter = counter & $0F : counter = (SWCHA & $F0) | counter goto loop init player0x = 40 player0y = 30 player0: %00011000 %00111100 %00111100 %00011000 end playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X..............XX..............X X..............XX..............X X..............XX..............X X..............XX..............X X..............XX..............X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end return data x_move_table 0, 0, 1, 1, 1, 0, -1, -1, -1 end data y_move_table 0, -1, -1, 0, 1, 1, 1, 0, -1 end ; 1 ; 8 2 ; 7 * 3 ; 6 4 ; 5 ; 0 1 2 3 4 5 6 7 8 9 10 SWCHA ; ---u --d- --du -l-- -l-u -ld- -ldu r--- r--u r-d- right left down up joy switches data direction_table 0, 1, 5, 0, 7, 8, 6, 0, 3, 2, 4 ; direction end double_tap_2.bas double_tap_2.bas.bin
  11. I can't get it to hold a diagonal so you may need a timer, but not for the double tap I'm using a keyboard but I'd guess it would also be a problem with a real joy stick
  12. I did one movement is controlled by two flags there's also a frame parity flag the current move direction is the lower four bits of the move_flags variable if joy0 is not active nothing changes if joy0 is active but the joy0 direction is different from the move direction the move direction is set to the joy0 direction and the speed_x_2 flag is set to false if the joy0 direction is the same as the move direction and joy direction was 0 on the previous frame the speed_x_2 flag is set to true (no timer) if the speed_x_2 flag is true the frame parity check is skipped and the player is moved each frame other wise the the player is moved every other frame a collision backs off the player and clears the move_flags variable set optimization noinlinedata dim move_flags = m dim move_direction = temp1 dim j0_direction = temp2 def joy_was_0 = m{6} def frame_parity = m{5} def speed_x_2 = m{4} def true = 1 def false = 0 def set_move_flag = callmacro smd_mac def get_move_flag = callmacro gmd_mac const noscore = 1 macro smd_mac {1} move_flags = (move_flags & %11110000) | {1} end macro gmd_mac {1} {1} = move_flags & %00001111 end gosub init loop COLUP0 = $38 COLUPF = $86 drawscreen get_move_flag move_direction if !collision(playfield, player0) then check_joy0 player0x = player0x - x_move_table[move_direction] player0y = player0y - y_move_table[move_direction] move_flags = 0 : move_direction = 0 goto skip_move check_joy0 j0_direction = (SWCHA ^ %11111111)/16 j0_direction = direction_table[j0_direction] if j0_direction = 0 then check_parity if j0_direction <> move_direction then move_direction = j0_direction : speed_x_2 = false : goto check_parity if joy_was_0 then speed_x_2 = true check_parity if speed_x_2 then do_move if frame_parity then skip_move do_move player0x = player0x + x_move_table[move_direction] player0y = player0y + y_move_table[move_direction] skip_move if j0_direction then joy_was_0 = false else joy_was_0 = true if frame_parity then frame_parity = false else frame_parity = true set_move_flag move_direction goto loop init player0x = 40 player0y = 30 player0: %00011000 %00111100 %00111100 %00011000 end playfield: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X..............................X X..............................X X..............XX..............X X..............XX..............X X..............XX..............X X..............XX..............X X..............XX..............X X..............................X X..............................X XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX end return data x_move_table 0, 0, 1, 1, 1, 0, -1, -1, -1 end data y_move_table 0, -1, -1, 0, 1, 1, 1, 0, -1 end ; 1 ; 8 2 ; 7 * 3 ; 6 4 ; 5 ; 0 1 2 3 4 5 6 7 8 9 10 SWCHA ; ---u --d- --du -l-- -l-u -ld- -ldu r--- r--u r-d- right left down up joy switches data direction_table 0, 1, 5, 0, 7, 8, 6, 0, 3, 2, 4 ; direction end double_tap.bas double_tap.bas.bin
  13. I think you are trying to convert you're direction to a number I find that a lot easier to deal with with this sort of stuff I'd suggest you go read about SWCHA and then do something like this direction = (SWCHA ^ %11111111)/16 direction = dirt[direction] ; 1 ; 8 2 ; 7 * 3 ; 6 4 ; 5 ; 0 1 2 3 4 5 6 7 8 9 10 SWCHA ; ---u --d- --du -l-- -l-u -ld- -ldu r--- r--u r-d- right left down up joy switches data dirt ; direction table 0 1, 5, 0, 7, 8, 6, 0 3, 2, 4 ; direction end do you really need to time it? could you just bump the speed up if you're already going in the same direction?
  14. you can reuse the variable. in this case variable e when you use the sdata statement bB makes the name you give it an alias for the variable lev1 becomes an alias for the variable e like you'd dimmed it dim lev1 = e bB also declares a lable derived from the sdata name by appending _begin so here the lable would be lev1_begin if you use the same sdata name twice bB will try to declare the same lable twice with different values so yes similar to two subroutines with the same lable
×
×
  • Create New...