Geekboy

Untitled

Apr 10th, 2013
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Bullet move/collide routines and all shared routines that associates with it
  2. ; nostack
  3. ; count = 1 for start everythign else is 0
  4. ; this is so we load the first set of values into the table
  5. ; ld hl,-X  ; where X is offset 4 = user 1 = Y
  6. ; add hl,sp
  7. ; to make hl = entry on bullet table
  8. InitLut:
  9. ;Moves a bullet based on a LUT
  10. ;Pre read decriment start by checking counter accomplished by checking state of what it was before hand
  11. ; Counter of 2 means next LUT entry
  12. ; Count of 1 means return to player via arctan
  13. ; 0 means first run
  14.  ld ix,(pTemp1)
  15.  ld hl,-3        
  16.  add hl,sp      ; load hl with flag
  17.   ld b,(hl)      ; load a with flags
  18.   ld a,b         ; save it in b for later.
  19.   and %11111100  ; check for a Count of 0
  20.   jr nz,NOTFRESH ; if not zero we are processing something move on
  21. ;B has flags hl points to flags
  22.   ld a,(ix)    ; load ix with count.
  23.   add a,a  
  24.   add a,a      ; chift to left
  25.   or b         ; merge with flags
  26.   ld (hl),a    ; save
  27.  dec hl        ; point hl to user
  28.  ld a,(ix)     ; load user into a
  29.  and %01111111      
  30.  ld (hl),a     ; not sure on value you here just plain overwrite
  31. NOTFRESH:
  32. LutHandlerStart:
  33. ; hl,-3
  34. ; %ccccccff c = Count F = flags
  35. ;The Flow
  36. ;first Decrement timer
  37. ;Check for z or c
  38. ;If Count = 2 move to next
  39. ;if Count = 1 move to follow player
  40. ;If count = HCF
  41. ;Else increment based on LUT parameters
  42. ;assume nothing is loaded as we may jump back here. later. can be removed if needed tho
  43.   ld hl,-3
  44.   add hl,sp
  45.   ld a,(hl)  ; ld a with flags
  46.   ld b,a     ; save in b
  47.   and %00000011 ; clear count for later
  48.   ld d,a        ; save for later
  49.   ld a,b        ; restore
  50.   and %11111100 ; clear for math
  51.   rrca \ rrca       ;div4  / move count to front of byte
  52.   ld e,a            ; save Count
  53.   dec a             ; shift dec
  54.   add a,a \ add a,a ; shift back
  55.   or d              ; merge back
  56.   ld (hl),a         ; save back into flagsk with new values
  57.   ld a,e            ; Restore count
  58.   cp 2              ; check values
  59.   jp c,FollowP      ; if 1 move to followP
  60.   jr z,IncLut       ; if 2 move to next position on lut
  61. MoveBulletBasedOnLutAngle:
  62.  ;Increase the bullet based on the lut angle.
  63.  ; pre increment/saving executes with old
  64.  ; First load angle
  65.  ; Check for inc val
  66.  ; if val get mult and mult
  67.  ; save back and execute
  68.   ld e,(hl)   ; flags in E
  69.  dec hl      ; point hl to user
  70.  ld c,(hl)   ; put angle into C
  71.  ld a,(ix)   ; ld a with incdec
  72.  and %11000000
  73.  jr z,++_       ; if 0 skip it
  74.  rlca \ rlca  ; save incdec in %00000011
  75.  add a,a        ; mult by 2
  76.  bit 0,E        ; if set to mult by 4 mult by 4
  77.  jr z,_         ; else skip it
  78.  add a,a
  79. _:
  80.  add a,c        ; if its zero just add it anyway
  81. _:
  82.  ld (hl),a      ; save back
  83.  jp moveang    ;inputs may vary juggle for that later. for now assuming c
  84.  
  85. IncLut:
  86.  ld a,(pTemp1)
  87.  inc a
  88.  inc a
  89.  ld (pTtemp1),a  ; inc to next slot
  90.  dec hl
  91.  ld (hl),0      ;zero so its a fresh init
  92.  jp lutinit
  93. FollowP:
  94. ; this is a stub have to get player xy and bullet xy and call r.arctan. followed by moveang
  95.  jp $
Advertisement
Add Comment
Please, Sign In to add comment