Geekboy

Untitled

Feb 4th, 2012
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. nanamiTest:
  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.  
  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.  jp moveang
  39. _:
  40. Follow_player:     ; gets a angle via the arctan function and sends the attack torwards the player
  41.  push hl \ inc sp ; move the stack back to proper positions as we
  42.  ld hl,0          ; are moving it into temp storage
  43.  add hl,sp
  44.  ld sp,(itemp1)   ; old stack value was stored here
  45.  push hl          ; we have a stack now lets use it
  46.   ex af,af'       ; needed this last time dont as me why
  47.  push af         ; save the shadow aff for some bloody reason
  48.  
  49.  
  50.   ld hl,(chary)   ; de = your pos
  51.   ex de,hl
  52.   call r.arctan   ; returns angle in c
  53.                  ; we leave it there so we can restore the stack
  54.  pop af
  55.  ex af,af'
  56.  pop hl
  57.  ld sp,hl
  58.  
  59.  ld a,c    ; put angle in a
  60.  srl a     ; div by 2 because we need to for the angle routine
  61.  jp moveang
  62.   ; we can do my own shit now stack is inited and old one is saved
  63.  
  64. _:
  65.  jp $
  66.  ld a,(charweapondat)  ;  load dttttttt into a
  67.  and %10000000         ;  preserve d
  68.  inc a                 ; make t = 1
  69.  ld (charweapondat),a  ; save
  70.  ld a,l
  71.  and %10000000
  72.  ld l,a
  73.  push hl \ inc sp      ; quit
  74.  pop de                ; ^
  75.  jp PBTDestroy         ; ...
  76. INCLUT:            ; must inc lut value by 2
  77.  ;ld b,a            ; save Dttttttt into b
  78.  ld a,l            ; load a with FLLLLLLL
  79.  inc a \ inc a     ; inc a twice we do not monitor F here because the bullet will leave the screen before 127 cycles go by
  80.  Xor l             ;
  81.  and %01111111    
  82.  xor l             ; merge bit 7 of L with bits 0-6 of a
  83.  ld l,A        
  84.  push hl \ inc sp  ; EXIT CODE for modifying the timer
  85.  ld hl,nanamiLUT45 ; load hl with pointer to the lut
  86.  and %01111111     ; and out F ===! this is new forgot this !===
  87.  add a,l           ; merge with lut addy to make pointer
  88.  ld l,a            ; ^
  89.  ld b,(hl)         ; load b with the angle count off hte lut
  90.  ld a,(charweapondat) ; load a with charweapondat
  91.  and %10000000        ; clear T
  92.  add a,b               ; merge
  93.  ld (charweapondat),a  ; save back
  94.  pop de                ; important shit
  95.  jp nanamitest         ; start over so we actually do something
  96. moveang:
  97.  pop hl             ;then advance SP so the bullet table handler can continue
  98.  and %01111111
  99.  add a,a            ;doubling the spread
  100. ; add a,192-16        ;get true angle spread
  101.  ld c,a
  102.  ld b,$82           ;and now complete the address thinger. in BC
  103.  rlc L \ rlc L      ;From %ss.yyyyyy to %yyyyyy.ss
  104.  ld a,(bc)          ;Get %AAAaaaaa. Let's use upper 3 bits
  105.  rlca \ rlca \ rlca ;Got %aaaaaAAA
  106.  and %00000111
  107.  bit 7,c
  108.  jp z,_
  109.  neg    ;We had a positive number but we need movement in negative
  110. _:
  111.  add a,L
  112.  ;jp nc,PBTDestroy   ;Bullet went past top. Destroy it.
  113.  ;cp 240
  114.  ;jp nc,PBTDestroy    ; special case handling for top of screen shooting people
  115.  ld L,a
  116.  ld a,c
  117.  add a,64
  118.  ld c,a
  119.  ld a,(bc)          ;Getting X angle.
  120.  rlca \ rlca \ rlca ;like above
  121.  and %00000111
  122.  ld b,a
  123.  ld a,c
  124.  and %11000000
  125.  ld a,b    
  126.  ; *phew*. Almost looks like I know what I'm doing :P  
  127.  jp pe,_        
  128.  neg
  129. _:
  130.  rlc h \ rlc h
  131.  add a,h
  132.  ld h,a
  133.  and %11111100
  134.  ;jp z,PBTDestroy
  135.  
  136.  rrc h \ rrc h
  137.  rrc L \ rrc L
  138.  push hl
  139.  pop hl
  140.  jp PBTMainMoveRet ;stack unavailable
Advertisement
Add Comment
Please, Sign In to add comment