Geekboy

Untitled

Apr 4th, 2012
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. ; the direction the frog is facing is strored in FDir
  3. ;   0123
  4. ;   udlr
  5. CheckUP:
  6.  ld a,(Fdir)
  7.  cp 1                      ; if we try to move backwards abort
  8.  jp z,Main_Key_Check_Loop  
  9.  call GetLutPos            ; returns the lut pos in hl
  10.  
  11.  ; to move up the screen we need to subtract 8 just the way the logic works
  12.  ; But first we need to get out xpos in b
  13.  ld a,(Xpos)
  14.  ld b,a
  15.  dec b ; for alignment with how djnz works
  16.  jp c,Main_Key_Check_Loop   ; if that carries we are on the edge why check ?
  17.  
  18.  ; then once we get there her we can do a djnz loop to look for a valid place to jump
  19. _:
  20.  ld a,l  ; put lut pos into a
  21.  sub 8   ; move into position
  22.  ld l,a  ; save back for later
  23.  ld a,(hl)  ; load a with data in lut
  24.  cp 255     ; check to see if its a lilypad
  25.  jp Z,MoveUpPrep
  26.  djnz -_
  27.  jp Main_Key_Check_Loop
  28.  
  29.  
  30. CheckDown:
  31.  ld a,(Fdir)
  32.  or a                      ; if we try to move backwards abort
  33.  jp z,Main_Key_Check_Loop  
  34.  call GetLutPos
  35.   ; to move down the screen we need to add 8 just the way the logic works
  36.  ; But first we need to get out xpos in b
  37.  ld a,(Xpos)
  38.  ld b,a
  39.  ld a,8   ; then we need to get the distance from 8 because we are moving down
  40.  sub a,b  ; we do that here
  41.  jp z,Main_Key_Loop_Check
  42.  ld b,a   ; put that back
  43.   ; then once we get there her we can do a djnz loop to look for a valid place to jump
  44. _:
  45.  ld a,l
  46.  add 8
  47.  ld l,a
  48.  ld a,(hl)
  49.  cp 255
  50.  jp z,MoveDownPrep
  51.  djnz -_
  52.  jp Main_Key_Check_Loop
  53.  
  54.  
  55. CheckLeft:
  56.  ld a,(Fdir)
  57.  cp 3                      ; if we try to move backwards abort
  58.  jp z,Main_Key_Check_Loop  
  59.  Call GetLutPos
  60.   ; to move down the screen we need to add 8 just the way the logic works
  61.  ; But first we need to get out xpos in b
  62.  ld a,(Xpos)
  63.  ld b,a
  64.  dec b
  65.  jp c,Main_Key_Loop_Check
  66.  ld b,a   ; put that back
  67.   ; then once we get there her we can do a djnz loop to look for a valid place to jump
  68. _:
  69.  dec l
  70.  ld a,(hl)
  71.  cp 255
  72.  jp z,MoveDownPrep
  73.  djnz -_
  74.  jp Main_Key_Check_Loop
  75.  
  76. CheckRight:
  77.  ld a,(Fdir)
  78.  cp 2                      ; if we try to move backwards abort
  79.  jp z,Main_Key_Check_Loop  
  80.  Call GetLutPos
  81.  ; to move down the screen we need to add 8 just the way the logic works
  82.  ; But first we need to get out xpos in b
  83.  ld a,(Xpos)
  84.  ld b,a
  85.  ld a,8
  86.  sub a,b
  87.  jp z,Main_Key_Check_Loop      ; bound checking why we gonna move if we are on the edge
  88.  ld b,a
  89.  
  90.  ; then once we get there her we can do a djnz loop to look for a valid place to jump
  91. _:
  92.  inc l
  93.  ld a,(hl)
  94.  cp 255
  95.  jp z,MoveRightPrep
  96.  djnz -_
  97.  jp Main_Key_Check_Loop
Advertisement
Add Comment
Please, Sign In to add comment