Geekboy

Untitled

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