Jump to content
IGNORED

Banks are a bit confusing


Rabbit 2600

Recommended Posts

Experimenting with banks and I find them very confusing. I'm using the platformer (4k) as a base. (I'm sorry, I forgot who made it) In order to learn both platforming and banking coding.

 

I'm having a bit of an issue as to where I should put this line of code so that the player can proceed to the next level:

 if player0x = 140 then q = q + 1 : player0x = 25


q is a counter. It starts at 0, and thusly the first screen is shown. When player0 reaches 140 on the x axis he is then placed at position 25 on the x axis and q is increased by 1 and then screen number 2 should show. But nothing happens. Any ideas?

 

 

Source:

 def GRAVITY=0.05
 def JUMPVELOCITY=0.9

 set romsize 8kSC
 set smartbranching on
 rem set kernel_options pfcolors
 const pfres=22

 dim yvel=a.b
 dim ypos=c.d
 dim flags=e
 def REFLECT=flags{3}
 def JUMPING=flags{4}
 dim count=flags 
 rem count uses bits 5-7 of flags
 dim rjoy=flags
 rem rjoy uses bits 0-2 of flags

 rem if using superchip:
 rem variables f-z and var0-var47 are free
 rem superchip variables r000-r039 free


 player0x=20:player0y=20
 missile0x = 50
 missile0y = 70
 player1x = 125
 player1y = 31

 if q = 0 then playfield:
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 XX............................XX
 XX............................XX
 XX............................XX
 XX............................XX
 XX............................XX
 XX............................XX
 XX............................XX
 XXXX..XX..XXXXXXXXXXXXXXXXXXXXXX
 XX............................XX
 XX....XX......................XX
 XX..............................
 XX....XX........................
 XX..............................
 XX..XXXXXXXXXX..XX..XXXXXXXXXXXX
 XX............................XX
 XX..............XX............XX
 XX............................XX
 XX..............XX............XX
 XX............................XX
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end

 if q = 1 then playfield:
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 XX............................XX
 XX............................XX
 XX............................XX
 XX............................XX
 XX............................XX
 XX............................XX
 XX............................XX
 XX............................XX
 XX............................XX
 XX............................XX
 XX..............................
 XX..............................
 XX..............................
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 XX............................XX
 XX............................XX
 XX............................XX
 XX............................XX
 XX............................XX
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end


 c=20
 goto continue bank2

 bank 2

 rem this is located in bank 2 because pfread lives there

continue
 drawscreen

 if collision(player0,missile0) then missile0x = rand : missile0y = rand
 if collision(missile0,playfield) then missile0x = rand : missile0y = rand

 if player0x = 140 then q = q + 1 : player0x = 25

 if missile0x < 20 then missile0x = rand
 if missile0x > 135 then missile0x = rand
 if missile0y < 10 then missile0y = rand
 if missile0y > 80 then missile0y = rand

 count=count+32
 if JUMPING then werejumping
 if !joy0fire then nobutton
 yvel=JUMPVELOCITY
 JUMPING=1
nobutton
 if !JUMPING then nojump
werejumping
 yvel=yvel-GRAVITY
 ypos=ypos-yvel
nojump
 temp1=a|b:if temp1=0 then checkfall
 if !a{7} then skipadd
checkfall
 if player0x<10 || player0x>142 then keepfall

 rem height from XY
 rem 0=keep falling, 1=hit exactly, 2=hit too low, move up
 gosub heightread

 temp3=c+2
 temp3=temp3&3
 if temp2=0 then keepfall
 if temp3=1 then stopjump
 if temp3>1 then addandstop
keepfall
 JUMPING=1
 goto skipadd
addandstop
 c=c-1
stopjump
 JUMPING=0:d=255:a=0:b=0
skipadd
 if c>$64 then c=0
 player0y=c
 if count{5} then neg
 rjoy=(rjoy & %11111000) | (SWCHA/32)

 if rjoy{0} then noduck
 player0:
 %01100110
 %01111110
 %00011000
 %01111110
 %00011000
 %00111100
 %00111100
 %00011000
 0
 0
end


 goto neg
noduck
 if rjoy{1} then check7
 REFLECT=0
 temp1=blockread(player0x,c):if temp1=0 then player0x=player0x-1
 if player0x<7 then player0x=player0x+1
 rem goto donereadingjoy
check7
 if rjoy{2} then donereadingjoy
 REFLECT=1
 temp1=player0x+7
 temp1=blockread(temp1,c):if temp1=0 then player0x=player0x+1
 if player0x>$91 then player0x=player0x-1
donereadingjoy
 if !rjoy{2} || !rjoy{1} then running
 player0:
 %01100110
 %01100110
 %00111100
 %00011000
 %00011000
 %01111110
 %00011000
 %00111100
 %00111100
 %00011000
end
 goto neg
running
 if count{6} then frame24
 if count{7} then frame3
 player0:
 %01100011
 %01100110
 %00111100
 %00011000
 %01111000
 %01011011
 %00011110
 %00111000
 %00111000
 %00010000
end
 goto neg
frame3
 player0:
 %00011000
 %01111000
 %00111000
 %00011000
 %00111000
 %00111100
 %00011000
 %00111000
 %00111000
 %00010000
end
 goto neg
frame24
 if !count{7} then frame2
 player0:
 %11001100
 %01101100
 %00111000
 %00011000
 %01111000
 %00111110
 %00011100
 %00111000
 %00111000
 %00010000
end
 goto neg
frame2
 player0:
 %00110000
 %00111110
 %00011100
 %00011000
 %00011110
 %00111100
 %00011000
 %00111000
 %00111000
 %00010000
end
neg


  f=f+1

  if f = 10 then player1:
        %01101100
        %00100100
        %00000000
        %00111100
        %00000000
        %00111100
        %01010110
        %01010110
        %01111110
        %00111100
end

  if f = 20 then player1:
        %11000110
        %01000010
        %00000000
        %00111100
        %00000000
        %00111100
        %01010110
        %01010110
        %01111110
        %00111100
end

  if f=20 then f=0

 goto continue

 function pfget
 if pfread(temp1,temp2) then temp1=1 else temp1=0
 return thisbank

 function blockread
 temp1=temp1-17:temp1=temp1/4
 temp2=temp2/4
 rem pfpixel temp1 temp2 flip
 if temp1>31 then temp1=0:return thisbank
 temp1=pfget(temp1,temp2)
 return thisbank

heightread
 temp5=c+1
 temp5=temp5/4
 temp3=player0x-16
 temp4=temp3+1:temp4=temp4/4
 temp3=temp3/4:if temp3>$3d then temp6=0:temp4=0:goto skipfirst

 temp6=pfget(temp3,temp5)
 if temp4>temp3 then temp3=pfget(temp4,temp5):temp6=temp6|temp3
 temp4=temp4+1
skipfirst
 temp2=temp6
 rem pfpixel temp4 temp5 flip 
 if temp4<$20 then temp2=pfget(temp4,temp5):temp2=temp2|temp6
 return thisbank

 vblank
 scorecolor=15
 COLUPF=178
 COLUP0=$34
 COLUP1=$0E
 REFP0=flags
 return

Link to comment
Share on other sites

You have to go choose a new playfield when q changes.

 

 

def GRAVITY=0.05
def JUMPVELOCITY=0.9

set romsize 8kSC
set smartbranching on
rem set kernel_options pfcolors
const pfres=22

dim yvel=a.b
dim ypos=c.d
dim flags=e
def REFLECT=flags{3}
def JUMPING=flags{4}
dim count=flags
rem count uses bits 5-7 of flags
dim rjoy=flags
rem rjoy uses bits 0-2 of flags

rem if using superchip:
rem variables f-z and var0-var47 are free
rem superchip variables r000-r039 free


player0x=20:player0y=20
missile0x = 50
missile0y = 70
player1x = 125
player1y = 31

gosub choose_pf
c=20
goto continue bank2

choose_pf
if q = 0 then playfield:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX............................XX
XX............................XX
XX............................XX
XX............................XX
XX............................XX
XX............................XX
XX............................XX
XXXX..XX..XXXXXXXXXXXXXXXXXXXXXX
XX............................XX
XX....XX......................XX
XX..............................
XX....XX........................
XX..............................
XX..XXXXXXXXXX..XX..XXXXXXXXXXXX
XX............................XX
XX..............XX............XX
XX............................XX
XX..............XX............XX
XX............................XX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end

if q = 1 then playfield:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX............................XX
XX............................XX
XX............................XX
XX............................XX
XX............................XX
XX............................XX
XX............................XX
XX............................XX
XX............................XX
XX............................XX
XX..............................
XX..............................
XX..............................
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX............................XX
XX............................XX
XX............................XX
XX............................XX
XX............................XX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end
return

bank 2

rem this is located in bank 2 because pfread lives there

continue
drawscreen

if collision(player0,missile0) then missile0x = rand : missile0y = rand
if collision(missile0,playfield) then missile0x = rand : missile0y = rand

if player0x = 140 then q = q + 1 : gosub choose_pf bank1 : player0x = 25

if missile0x < 20 then missile0x = rand
if missile0x > 135 then missile0x = rand
if missile0y < 10 then missile0y = rand
if missile0y > 80 then missile0y = rand

count=count+32
if JUMPING then werejumping
if !joy0fire then nobutton
yvel=JUMPVELOCITY
JUMPING=1
nobutton
if !JUMPING then nojump
werejumping
yvel=yvel-GRAVITY
ypos=ypos-yvel
nojump
temp1=a|b:if temp1=0 then checkfall
if !a{7} then skipadd
checkfall
if player0x<10 || player0x>142 then keepfall

rem height from XY
rem 0=keep falling, 1=hit exactly, 2=hit too low, move up
gosub heightread

temp3=c+2
temp3=temp3&3
if temp2=0 then keepfall
if temp3=1 then stopjump
if temp3>1 then addandstop
keepfall
JUMPING=1
goto skipadd
addandstop
c=c-1
stopjump
JUMPING=0:d=255:a=0:b=0
skipadd
if c>$64 then c=0
player0y=c
if count{5} then neg
rjoy=(rjoy & %11111000) | (SWCHA/32)

if rjoy{0} then noduck
player0:
%01100110
%01111110
%00011000
%01111110
%00011000
%00111100
%00111100
%00011000
0
0
end


goto neg
noduck
if rjoy{1} then check7
REFLECT=0
temp1=blockread(player0x,c):if temp1=0 then player0x=player0x-1
if player0x<7 then player0x=player0x+1
rem goto donereadingjoy
check7
if rjoy{2} then donereadingjoy
REFLECT=1
temp1=player0x+7
temp1=blockread(temp1,c):if temp1=0 then player0x=player0x+1
if player0x>$91 then player0x=player0x-1
donereadingjoy
if !rjoy{2} || !rjoy{1} then running
player0:
%01100110
%01100110
%00111100
%00011000
%00011000
%01111110
%00011000
%00111100
%00111100
%00011000
end
goto neg
running
if count{6} then frame24
if count{7} then frame3
player0:
%01100011
%01100110
%00111100
%00011000
%01111000
%01011011
%00011110
%00111000
%00111000
%00010000
end
goto neg
frame3
player0:
%00011000
%01111000
%00111000
%00011000
%00111000
%00111100
%00011000
%00111000
%00111000
%00010000
end
goto neg
frame24
if !count{7} then frame2
player0:
%11001100
%01101100
%00111000
%00011000
%01111000
%00111110
%00011100
%00111000
%00111000
%00010000
end
goto neg
frame2
player0:
%00110000
%00111110
%00011100
%00011000
%00011110
%00111100
%00011000
%00111000
%00111000
%00010000
end
neg


f=f+1

if f = 10 then player1:
%01101100
%00100100
%00000000
%00111100
%00000000
%00111100
%01010110
%01010110
%01111110
%00111100
end

if f = 20 then player1:
%11000110
%01000010
%00000000
%00111100
%00000000
%00111100
%01010110
%01010110
%01111110
%00111100
end

if f=20 then f=0

goto continue

function pfget
if pfread(temp1,temp2) then temp1=1 else temp1=0
return thisbank

function blockread
temp1=temp1-17:temp1=temp1/4
temp2=temp2/4
rem pfpixel temp1 temp2 flip
if temp1>31 then temp1=0:return thisbank
temp1=pfget(temp1,temp2)
return thisbank

heightread
temp5=c+1
temp5=temp5/4
temp3=player0x-16
temp4=temp3+1:temp4=temp4/4
temp3=temp3/4:if temp3>$3d then temp6=0:temp4=0:goto skipfirst

temp6=pfget(temp3,temp5)
if temp4>temp3 then temp3=pfget(temp4,temp5):temp6=temp6|temp3
temp4=temp4+1
skipfirst
temp2=temp6
rem pfpixel temp4 temp5 flip
if temp4<$20 then temp2=pfget(temp4,temp5):temp2=temp2|temp6
return thisbank

vblank
scorecolor=15
COLUPF=178
COLUP0=$34
COLUP1=$0E
REFP0=flags
return
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...