Jump to content
IGNORED

batari Superchip weird playfield collision


Recommended Posts

I have two sample codes that show a simple sprite moving on a playfield with 4 openings (top, down, left, right), which are to simulate doors (like on Beserk)

 

By using "set romsize 8k", not using Superchip, the sprite is able to move past the top and down doors as expected.

 

By using "set romsize 8kSC", using Superchip, the sprite collides with "something" on the top, and some random crap playfield lines on the bottom (the crap lines change on each reset).

 

Removing "set kernel_options no_blank_lines" does make the random playfield lines on the last row to disappear, but the sprite still collides with something and refuses to move past the bottom and top doors.

 

Do you know what could be going on? Thanks !

 ; Remove the comment below to not use Superchip, and everything works as expected
 ; set romsize 8k

 ; When using Superchip, there are some random crap on the last row and the sprite collides with something on the top and bottom doors
 set romsize 8kSC
 
 ; Removing this line hides the crap playfield lines on the bottom, but the sprite still collides with "something"
 set kernel_options no_blank_lines
 
 player0x = 50 : player0y = 50

 player0:
 %11111111
 %10000001
 %10000001
 %10000001
 %10000001
 %10000001
 %10000001
 %11111111
end

 COLUBK = $00 : COLUPF = $46

 playfield:
 XXXXXXXXXXXXX.....XXXXXXXXXXXXXX
 XX............................XX
 X..............................X
 XX............................XX
 ................................
 ................................
 ................................
 XX............................XX
 X..............................X
 XX............................XX
 XXXXXXXXXXXXX.....XXXXXXXXXXXXXX
end
 
 ; Go to main loop on bank 2
 goto __main bank2

 bank 2
 ;--------------------------------------------------
 ; Main loop
 ;--------------------------------------------------
__main
 COLUP0 = $0E
 
 gosub __move_player 
 
 drawscreen
 
 goto __main

 ;--------------------------------------------------
 ; Moves and check playfield collisions for player0
 ;--------------------------------------------------
__move_player
 if !joy0up then goto __skip_up
 
 temp6 = (player0x-10)/4
 temp5 = (player0y-9)/8
 if temp6 < 34 then if pfread(temp6,temp5) then goto __skip_up
 temp4 = (player0x-17)/4
 if temp4 < 34 then if pfread(temp4,temp5) then goto __skip_up
 temp3 = temp6 - 1
 if temp3 < 34 then if pfread(temp3,temp5) then goto __skip_up
 
 player0y = player0y - 1
 
__skip_up
 if !joy0down then goto __skip_down

 temp6 = (player0x-10)/4
 temp5 = (player0y)/8
 if temp6 < 34 then if pfread(temp6,temp5) then goto __skip_down
 temp4 = (player0x-17)/4
 if temp4 < 34 then if pfread(temp4,temp5) then goto __skip_down
 temp3 = temp6 - 1
 if temp3 < 34 then if pfread(temp3,temp5) then goto __skip_down

 player0y = player0y + 1

__skip_down
 if !joy0left then goto __skip_left

 temp6 = (player0x-18)/4
 temp5 = (player0y-1)/8
 if temp6 < 34 then if pfread(temp6,temp5) then goto __skip_left
 temp4 = (player0y-8)/8
 if temp6 < 34 then if pfread(temp6,temp4) then goto __skip_left
 
 player0x = player0x - 1

__skip_left
 if !joy0right then goto __skip_right
 
 temp6 = (player0x-9)/4
 temp5 = (player0y-1)/8
 if temp6 < 34 then if pfread(temp6,temp5) then goto __skip_right
 temp4 = (player0y-8)/8
 if temp6 < 34 then if pfread(temp6,temp4) then goto __skip_right
 
 player0x = player0x + 1
 
__skip_right
 return thisbank

 

2 hours ago, KevKelley said:

With SuperChip, don't you have to define the playfield resolution? Or is that just optional should you choose to go with something other than the standard kernel?

The documentation seems to say that if using the standard 12 rows height, pfres is optional.

Either way, I tested with "const pfres=12" added to the example above, and the same behavior is still happening.

Edited by rfunes
Typo

Just to give a feedback, I was able to "fix" the two issues.

 

For the random lines, I only fixed the symptoms, but was not able to find the cause. When using Superchip with no_blank_lines enabled, these random lines will appear below the last row.

 

The way to remove the random lines that appear below the 11th row of the playfield is to define the 12th row of the playfield, as empty ("................................").

 

I still do not understand why these random lines appear only when using the Superchip with no_blank_lines enabled, and why this does not happen when not using Superchip.

playfield:
 XXXXXXXXXXXXX.....XXXXXXXXXXXXXX
 XX............................XX
 X..............................X
 XX............................XX
 ................................
 ................................
 ................................
 XX............................XX
 X..............................X
 XX............................XX
 XXXXXXXXXXXXX.....XXXXXXXXXXXXXX
 ................................
end

 

The fix for the movement was to add an exception to the up and down movement code, to bypass the playfield vs player collision check using pfread.

 

I checked the values of the temp5 variable for the up and down movement code, and noticed that when it goes below 0, it wraps around to 31, and when over the last row, it goes over 11. So I added code to check for when temp5 is greater than 10, and when so to bypass the playfield collision checking.

 

I think this issue happened because pfread was being fed Y coordinates over 11.

__move_player
 if !joy0up then goto __skip_up
 
 temp6 = (player0x-10)/4
 temp5 = (player0y-9)/8

 if temp5 > 10 then goto __move_up ; THIS FIXED THE ISSUE

 if temp6 < 34 then if pfread(temp6,temp5) then goto __skip_up
 temp4 = (player0x-17)/4
 if temp4 < 34 then if pfread(temp4,temp5) then goto __skip_up
 temp3 = temp6 - 1
 if temp3 < 34 then if pfread(temp3,temp5) then goto __skip_up

__move_up
 player0y = player0y - 1
 
__skip_up
 if !joy0down then goto __skip_down

 temp6 = (player0x-10)/4
 temp5 = (player0y)/8

 if temp5 > 10 then goto __move_down ; THIS FIXED THE ISSUE

 if temp6 < 34 then if pfread(temp6,temp5) then goto __skip_down
 temp4 = (player0x-17)/4
 if temp4 < 34 then if pfread(temp4,temp5) then goto __skip_down
 temp3 = temp6 - 1
 if temp3 < 34 then if pfread(temp3,temp5) then goto __skip_down

__move_down
 player0y = player0y + 1

__skip_down
 if !joy0left then goto __skip_left

 temp6 = (player0x-18)/4
 temp5 = (player0y-1)/8
 if temp6 < 34 then if pfread(temp6,temp5) then goto __skip_left
 temp4 = (player0y-8)/8
 if temp6 < 34 then if pfread(temp6,temp4) then goto __skip_left
 
 player0x = player0x - 1

__skip_left
 if !joy0right then goto __skip_right
 
 temp6 = (player0x-9)/4
 temp5 = (player0y-1)/8
 if temp6 < 34 then if pfread(temp6,temp5) then goto __skip_right
 temp4 = (player0y-8)/8
 if temp6 < 34 then if pfread(temp6,temp4) then goto __skip_right
 
 player0x = player0x + 1
 
__skip_right
 return thisbank

 

Edited by rfunes
  • Like 1

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