Advertisement
Guest User

Untitled

a guest
Jun 7th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .StandardControls:
  2. .ReadUp_P1:
  3.   LDA buttons1          ;player 1 - Up
  4.   AND #%00001000
  5.   BEQ .ReadUp_P1Done
  6.    
  7.   LDA #$01                  ;1=up,2=down,3=left,4=right
  8.   STA CharacterDirection
  9.  
  10.   JSR MoveCartUp
  11.        
  12.   JSR CartToIsoConvert
  13.   RTS
  14.    
  15. .ReadUp_P1Done:
  16. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17. .ReadDown_P1:
  18.   LDA buttons1          ;Player 1 - Down
  19.   AND #%00000100
  20.   BEQ .ReadDown_P1Done
  21.  
  22.   LDA #$02                  ;1=up,2=down,3=left,4=right
  23.   STA CharacterDirection
  24.    
  25.   JSR MoveCartDown
  26.  
  27.   JSR CartToIsoConvert
  28.   RTS
  29.  
  30. .ReadDown_P1Done:
  31. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  32. .ReadLeft_P1:
  33.   LDA buttons1          ;Player 1 - Left
  34.   AND #%00000010
  35.   BEQ .ReadLeft_P1Done
  36.  
  37.   LDA #$03                  ;1=up,2=down,3=left,4=right
  38.   STA CharacterDirection
  39.    
  40.   JSR MoveCartLeft
  41.  
  42.   JSR CartToIsoConvert
  43.   RTS
  44.  
  45. .ReadLeft_P1Done:
  46. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  47. .ReadRight_P1:
  48.   LDA buttons1          ;Player 1 - Right
  49.   AND #%00000001
  50.   BEQ .ReadRight_P1Done
  51.  
  52.   LDA #$04                  ;1=up,2=down,3=left,4=right
  53.   STA CharacterDirection
  54.  
  55.   JSR MoveCartRight
  56.  
  57.   JSR CartToIsoConvert
  58.   RTS
  59.  
  60. .ReadRight_P1Done:
  61.  
  62. PlayingInputDone:
  63. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  64.   RTS
  65.  
  66. MoveCartUp:
  67.     LDA main_char_cart_y_lo         ;Subpixel Movement
  68.     SEC
  69.     SBC #movement_speed
  70.     STA main_char_cart_y_lo
  71.     BCS MoveCartUpDone          ;If the Carry Flag is set, don't move character
  72.    
  73.     LDA main_char_cart_y_hi
  74.     SBC #$01                    ;Subtract Carry and $01
  75.     STA main_char_cart_y_hi
  76. MoveCartUpDone:
  77.   RTS
  78.  
  79. MoveCartDown:
  80.     LDA main_char_cart_y_lo         ;Subpixel Movement
  81.     CLC
  82.     ADC #movement_speed
  83.     STA main_char_cart_y_lo
  84.     BCC MoveCartDownDone            ;If the Carry Flag is cleared, don't move character
  85.    
  86.     LDA main_char_cart_y_hi
  87.     ADC #$01                    ;Add Carry and $01
  88.     STA main_char_cart_y_hi
  89. MoveCartDownDone:
  90.   RTS
  91.  
  92. MoveCartLeft:
  93.     LDA main_char_cart_x_lo         ;Subpixel Movement
  94.     SEC
  95.     SBC #movement_speed
  96.     STA main_char_cart_x_lo
  97.     BCS MoveCartLeftDone            ;If the Carry Flag is set, don't move character
  98.    
  99.     LDA main_char_cart_x_hi
  100.     SBC #$01                    ;Subtract Carry and $01
  101.     STA main_char_cart_x_hi
  102. MoveCartLeftDone:
  103.   RTS
  104.  
  105. MoveCartRight:
  106.     LDA main_char_cart_x_lo         ;Subpixel Movement
  107.     CLC
  108.     ADC #movement_speed
  109.     STA main_char_cart_x_lo
  110.     BCC MoveCartRightDone           ;If the Carry Flag is cleard, don't move character
  111.    
  112.     LDA main_char_cart_x_hi
  113.     ADC #$01                    ;Add Carry and $01
  114.     STA main_char_cart_x_hi
  115. MoveCartRightDone:
  116.   RTS
  117.  
  118.  
  119. CartToIsoConvert:  ;Convert the Coords to show the sprites on the correct part of the screen
  120.   ;Convert Cartesian X Coord to Isometric X Coord
  121.     LDA main_char_cart_x_hi  ;isoX = cartX - cartY
  122.     SEC
  123.     SBC main_char_cart_y_hi
  124.     STA main_char_screen_x
  125.     CLC
  126.     ADC room_x_offset           ;Add the Offset to Iso X for the room type
  127.     STA main_char_screen_x
  128.  
  129.   ;Convert Cartesian Y Coord to Isometric Y Coord
  130.     LDA main_char_cart_x_hi   ;isoY = (cartX + cartY) / 2
  131.     CLC
  132.     ADC main_char_cart_y_hi
  133.     STA main_char_screen_y
  134.     LSR A                       ;Divide By 2
  135.     CLC
  136.     ADC room_y_offset           ;Add the Offset to Iso Y for the room type
  137.     STA main_char_screen_y  
  138.     ;ROR main_char_screen_y       ;Must use ROR because when going down, if (cartX + cartY) cause a carry over,
  139.  
  140.   RTS
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement