Geekboy

Untitled

Mar 13th, 2012
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. nanamiTest:
  2.  
  3. ;1
  4. ; jp $
  5. ;Moves the bullet in the directoin given via an angle
  6. ; the angle is gotten from a lut and the lower bits of the counter are used for the lut table loc
  7. ; t = Ftttttt
  8. ; charweapondat holds the ttl for the angle
  9. ;E=Y D=X
  10.  ;inc e \ inc d           ;modify for collision routine
  11.  ;ld ix,PBMoveANGcont     ;return address for collision routine
  12.  ;jp SmallBulletCollision ;IN: DE=XY,
  13. ;PBMoveANGcont:
  14. ; dec e \ dec d     ;unmodify from collision routine
  15.  
  16. ; jp $
  17.  push de           ;move the stack back for something...
  18.  ld a,d
  19.  
  20.  
  21.  
  22.  
  23. ;********************************
  24. ;If you needed to modify the counter, you will need the following code.
  25. ;AND DON'T FORGET TO PRESERVE BIT 7 OF L SINCE THAT IS THE FOCUSED FLAG.
  26.  dec sp \ pop hl   ;ENTER CODE
  27.  ; Lut pos is in L
  28.  ld a,(charweapondat)  ; load DTTTTTTT into a
  29.  and %01111111         ; clear d
  30.  cp 1              
  31.  jp z,INCLUT       ; if lut is 1 move to the next item on it
  32.  jp c,_           ; if the counter is at 0 go back to the player
  33.              ; dec angle timer
  34.  push hl \ inc sp
  35.  dec a
  36.  ld (charweapondat),a
  37.  ld a,l            ; put offset into a
  38.  and %01111111     ; clear focus bit
  39.  ld hl,nanamiLUT45 ; load hl with LUTptr
  40.  inc a             ; do this so we are looking at the second item at the pointer
  41.  add a,l           ; add l to a to make
  42.  ld l,a            ; LUT+ofs
  43.  ld a,(hl)         ; store the angle we get into a
  44.  and %01111111
  45.  add a,a  
  46.  jp moveang
  47. _:
  48. Follow_player:     ; gets a angle via the arctan function and sends the attack torwards the player
  49.  push hl \ inc sp ; move the stack back to proper positions as we
  50.  ld hl,0          ; are moving it into temp storage
  51.  add hl,sp
  52.  ld sp,(itemp1)   ; old stack value was stored here
  53.  push hl          ; we have a stack now lets use it
  54.   ex af,af'       ; needed this last time dont ask me why
  55.  push af         ; save the shadow aff for some bloody reason
  56.  
  57.  
  58.   ld a,d
  59.   and %00111111
  60.   ld h,a
  61.   ld a,e
  62.   and %00111111
  63.   ld l,a
  64.      
  65.  
  66.   ld de,(chary)   ; de = your pos
  67.   srl e \ srl d
  68.   srl e \ srl d
  69.  ; ex de,hl
  70.   call r.arctan   ; returns angle in c and a
  71.                ; we leave it there so we can restore the stack
  72.  
  73.  
  74.  pop af
  75.  ex af,af'
  76.  pop hl
  77.  ld sp,hl
  78.  
  79.  ld a,c    ; put angle in a
  80.  
  81.  pop de
  82.  push de ; restore xy
  83.  jp moveang
  84.   ; we can do my own shit now stack is inited and old one is saved
  85.  
  86. _:
  87.  ;jp $
  88.  ld a,(charweapondat)  ;  load dttttttt into a
  89.  and %10000000         ;  preserve d
  90.  inc a                 ; make t = 1
  91.  ld (charweapondat),a  ; save
  92.  ld a,l
  93.  and %10000000
  94.  ld l,a
  95.  push hl \ inc sp      ; quit
  96.  pop de                ; ^
  97.  jp PBTDestroy         ; ...
  98. INCLUT:            ; must inc lut value by 2
  99.  ;ld b,a            ; save Dttttttt into b
  100.  ;jp $
  101.  ld a,l            ; load a with FLLLLLLL
  102.  inc a \ inc a     ; inc a twice we do not monitor F we should never have 127 entries
  103.  Xor l             ;
  104.  and %01111111    
  105.  xor l             ; merge bit 7 of L with bits 0-6 of a
  106.  ld l,A        
  107.  push hl \ inc sp  ; EXIT CODE for modifying the timer
  108.  ld hl,nanamiLUT45 ; load hl with pointer to the lut
  109.  and %01111111     ; and out F ===! this is new forgot this !===
  110.  add a,l           ; merge with lut addy to make pointer
  111.  ld l,a            ; ^
  112.  ld b,(hl)         ; load b with the angle count off hte lut
  113.  ld a,(charweapondat) ; load a with charweapondat
  114.  and %10000000       ; clear T
  115.  add a,b               ; merge
  116.  ld (charweapondat),a  ; save back
  117.  pop de                ; important shit
  118.  jp nanamitest         ; start over so we actually do something
  119. moveang:
  120.  ;jp $
  121.  
  122.  ; assumes x,y are in on teh table in the form of ss.^^^^^^
  123.  inc sp
  124.  pop hl             ;then advance SP so the bullet table handler can continue
  125.            ;doubling the spread
  126.  
  127.  ld c,a
  128.  ld b,$82           ;and now complete the address thinger. in BC
  129.  rlc L \ rlc L      ;From %ss.yyyyyy to %yyyyyy.ss
  130.  ld a,(bc)          ;Get %AAAaaaaa. Let's use upper 3 bits
  131.  rlca \ rlca \ rlca ;Got %aaaaaAAA
  132.  and %00000111
  133.  bit 7,c
  134.  jp z,_
  135.  neg    ;We had a positive number but we need movement in negative
  136. _:
  137.  add a,L
  138.  ;jp nc,PBTDestroy   ;Bullet went past top. Destroy it.
  139.  ;cp 240
  140.  ;jp nc,PBTDestroy    ; special case handling for top of screen shooting people
  141.  ld L,a
  142.  ld a,c
  143.  add a,64
  144.  ld c,a
  145.  ld a,(bc)          ;Getting X angle.
  146.  rlca \ rlca \ rlca ;like above
  147.  and %00000111
  148.  ld b,a
  149.  ld a,c
  150.  and %11000000
  151.  ld a,b    
  152.  ; *phew*. Almost looks like I know what I'm doing :P  
  153.  jp po,_        
  154.  neg
  155. _:
  156.  rlc h \ rlc h  ;rotate x to xxxxxx.ss
  157.  add a,h        ;add our value to the X pos
  158.  ld h,a         ; save back
  159.  and %11111100  ; and for collision
  160.  ;jp z,PBTDestroy
  161.  
  162.  rrc h \ rrc h  ; rever
  163.  rrc L \ rrc L
  164.  push hl
  165.  pop hl
  166.  jp PBTMainMoveRet ;stack unavailable
  167.  
  168. ;2
Advertisement
Add Comment
Please, Sign In to add comment