Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; the direction the frog is facing is strored in FDir
- ; 0123
- ; udlr
- CheckUP:
- ld a,(Fdir)
- cp 1 ; if we try to move backwards abort
- jp z,Main_Key_Check_Loop
- call GetLutPos ; returns the lut pos in hl
- ; to move up the screen we need to subtract 8 just the way the logic works
- ; But first we need to get out xpos in b
- ld a,(Xpos)
- ld b,a
- dec b ; for alignment with how djnz works
- jp c,Main_Key_Check_Loop ; if that carries we are on the edge why check ?
- ; then once we get there her we can do a djnz loop to look for a valid place to jump
- _:
- ld a,l ; put lut pos into a
- sub 8 ; move into position
- ld l,a ; save back for later
- ld a,(hl) ; load a with data in lut
- cp 255 ; check to see if its a lilypad
- jp Z,MoveUpPrep
- djnz -_
- jp Main_Key_Check_Loop
- CheckDown:
- ld a,(Fdir)
- or a ; if we try to move backwards abort
- jp z,Main_Key_Check_Loop
- call GetLutPos
- ; to move down the screen we need to add 8 just the way the logic works
- ; But first we need to get out xpos in b
- ld a,(Xpos)
- ld b,a
- ld a,8 ; then we need to get the distance from 8 because we are moving down
- sub a,b ; we do that here
- jp z,Main_Key_Loop_Check
- ld b,a ; put that back
- ; then once we get there her we can do a djnz loop to look for a valid place to jump
- _:
- ld a,l
- add 8
- ld l,a
- ld a,(hl)
- cp 255
- jp z,MoveDownPrep
- djnz -_
- jp Main_Key_Check_Loop
- CheckLeft:
- ld a,(Fdir)
- cp 3 ; if we try to move backwards abort
- jp z,Main_Key_Check_Loop
- Call GetLutPos
- ; to move down the screen we need to add 8 just the way the logic works
- ; But first we need to get out xpos in b
- ld a,(Xpos)
- ld b,a
- dec b
- jp c,Main_Key_Loop_Check
- ld b,a ; put that back
- ; then once we get there her we can do a djnz loop to look for a valid place to jump
- _:
- dec l
- ld a,(hl)
- cp 255
- jp z,MoveDownPrep
- djnz -_
- jp Main_Key_Check_Loop
- CheckRight:
- ld a,(Fdir)
- cp 2 ; if we try to move backwards abort
- jp z,Main_Key_Check_Loop
- Call GetLutPos
- ; to move down the screen we need to add 8 just the way the logic works
- ; But first we need to get out xpos in b
- ld a,(Xpos)
- ld b,a
- ld a,8
- sub a,b
- jp z,Main_Key_Check_Loop ; bound checking why we gonna move if we are on the edge
- ld b,a
- ; then once we get there her we can do a djnz loop to look for a valid place to jump
- _:
- inc l
- ld a,(hl)
- cp 255
- jp z,MoveRightPrep
- djnz -_
- jp Main_Key_Check_Loop
Advertisement
Add Comment
Please, Sign In to add comment