Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- nanamiTest:
- ;1
- ; jp $
- ;Moves the bullet in the directoin given via an angle
- ; the angle is gotten from a lut and the lower bits of the counter are used for the lut table loc
- ; t = Ftttttt
- ; charweapondat holds the ttl for the angle
- ;E=Y D=X
- ;inc e \ inc d ;modify for collision routine
- ;ld ix,PBMoveANGcont ;return address for collision routine
- ;jp SmallBulletCollision ;IN: DE=XY,
- ;PBMoveANGcont:
- ; dec e \ dec d ;unmodify from collision routine
- ; jp $
- push de ;move the stack back because xy is poped into de before teh jump
- ld a,d
- and %11111100
- ld h,a
- ld a,e
- and %11111100
- ld l,a
- ld de,(chary) ; de = your pos
- ; srl e \ srl d
- ; srl e \ srl d ; pos is stored same as enimies no need to much with them
- ex de,hl
- ld b,0 ;initializing...
- ld a,e ;
- rrca \ rrca \ and %00111111
- sub L ;y1-y2
- jr nc,_ ;result is negative. Set B for flags (bit 0) and adjust Y for pos.
- set 0,b
- neg
- _:
- ld e,a ;D=Y for later
- rlca \ rlca ;shifting so that %00yyyynn is %yyyynn00 for later. n matters not
- ld L,a ;half-result in L now
- ld a,d
- rrca \ rrca \ and %00111111
- sub H ;x1-x2
- jr nc,_ ;result is negative. Set B for flags (bit 1) and adjust X for pos.
- set 1,b
- neg
- _:
- ld c,a ;C=X for results later
- rrca \ rrca ;shifting so that %00xxxxnn is %nn00xxxx. n still matters not.
- xor L ;combine with Y
- and $0F ;mask out to keep old X low bits
- xor L ;and we have %yyyyxxxx
- ld L,b ;saving flags into L for now.
- ld h,e ;restore H for... stuffs
- ld ix,ArcTanTable
- ld e,a
- ld d,0
- add ix,de ;We have our offset now.
- ;So at this point, C=X, H=Y, L=flags.
- ;Let's go ahead and do X-interpolation first.
- ld a,c
- and %00000011 ;value-ranking
- ld c,(ix+0) ;storing non-adjusted "output" value into C
- jr z,r.arctan.skipxx
- ld e,a ;Loop for second half of X interpolate
- cpl ;ranking first value on inverse of distance to next number
- add a,5 ;So 1=3,2=2,3=1
- ld b,a
- xor a
- _:
- add a,c
- djnz -_
- ld c,(ix+1)
- ld b,e
- _:
- add a,c
- djnz -_
- rra \ rra
- and %00111111
- ld c,a ;out by the time we're done with everything.
- r.arctan.skipxx:
- ld a,h
- ld H,c ;H=InterpolatedX
- and %00000011 ;value-ranking
- ld c,(ix+0) ;storing non-adjusted "output" value into C
- jr z,r.arctan.skipyy
- ld e,a ;Loop for second half of Y interpolate
- cpl ;ranking first value on inverse of distance to next number
- add a,5 ;So 1=3,2=2,3=1
- ld b,a
- xor a
- _:
- add a,c
- djnz -_
- ld c,(ix+16)
- ld b,e
- _:
- add a,c
- djnz -_
- rra \ rra ;Also trying to get any leftovers from too many values of 64
- cp 64
- jr z,_
- and %00111111
- _:
- ld c,a ;added. Since 64*4 is a 9 bit number, getting that back.
- r.arctan.skipyy:
- ld a,c
- add a,H
- rra
- cp 64
- jr z,_
- and %00111111 ;and NOW we have our final angle. (if it wasn't 64...)
- _:
- ld b,0 ;Set to 128 if X is negative. For additions later on.
- bit 1,L
- jr z,_
- ld b,128
- neg ;negate angle
- _:
- bit 0,L
- jr z,_
- neg ;negate angle again if (-,-) else first neg. Still correct :)
- _:
- add a,b ;completing the angle
- ld a,c ; put angle in a
- pop hl
- push hl ; restore xy
- jp moveang
- ;********************************
- ;If you needed to modify the counter, you will need the following code.
- ;AND DON'T FORGET TO PRESERVE BIT 7 OF L SINCE THAT IS THE FOCUSED FLAG.
- dec sp \ pop hl ;ENTER CODE
- ; Lut pos is in L
- ld a,(charweapondat) ; load DTTTTTTT into a
- and %01111111 ; clear d
- cp 1
- jp z,INCLUT ; if lut is 1 move to the next item on it
- jp c,_ ; if the counter is at 0 go back to the player
- ; dec angle timer
- push hl \ inc sp
- dec a
- ld (charweapondat),a
- ld a,l ; put offset into a
- and %01111111 ; clear focus bit
- ld hl,nanamiLUT45 ; load hl with LUTptr
- inc a ; do this so we are looking at the second item at the pointer
- add a,l ; add l to a to make
- ld l,a ; LUT+ofs
- ld a,(hl) ; store the angle we get into a
- and %01111111
- add a,a
- jp moveang
- _:
- Follow_player: ; gets a angle via the arctan function and sends the attack torwards the player
- push hl
- inc sp ; move the stack back to proper positions as we
- ld hl,0 ; are moving it into temp storage
- add hl,sp
- ld sp,(itemp1) ; old stack value was stored here
- push hl ; we have a stack now lets use it
- ex af,af' ; needed this last time dont ask me why
- push af ; save the shadow aff for some bloody reason
- ld a,d
- rlca \ rlca
- ld h,a
- ld a,e
- rlca \ rlca
- ld l,a
- ld de,(chary) ; de = your pos
- ; srl e \ srl d
- ; srl e \ srl d ; pos is stored same as enimies no need to much with them
- ; ex de,hl
- call r.arctan ; returns angle in c and a
- ; we leave it there so we can restore the stack
- pop af
- ex af,af'
- pop hl
- ld sp,hl
- ld a,c ; put angle in a
- pop hl
- push hl ; restore xy
- jp moveang
- ; we can do my own shit now stack is inited and old one is saved
- _:
- ;jp $
- ld a,(charweapondat) ; load dttttttt into a
- and %10000000 ; preserve d
- inc a ; make t = 1
- ld (charweapondat),a ; save
- ld a,l
- and %10000000
- ld l,a
- push hl \ inc sp ; quit
- pop de ; ^
- jp PBTDestroy ; ...
- INCLUT: ; must inc lut value by 2
- ;ld b,a ; save Dttttttt into b
- ;jp $
- ld a,l ; load a with FLLLLLLL
- inc a \ inc a ; inc a twice we do not monitor F we should never have 127 entries
- Xor l ;
- and %01111111
- xor l ; merge bit 7 of L with bits 0-6 of a
- ld l,A
- push hl \ inc sp ; EXIT CODE for modifying the timer
- ld hl,nanamiLUT45 ; load hl with pointer to the lut
- and %01111111 ; and out F ===! this is new forgot this !===
- add a,l ; merge with lut addy to make pointer
- ld l,a ; ^
- ld b,(hl) ; load b with the angle count off hte lut
- ld a,(charweapondat) ; load a with charweapondat
- and %10000000 ; clear T
- add a,b ; merge
- ld (charweapondat),a ; save back
- pop de ; important shit
- jp nanamitest ; start over so we actually do something
- moveang:
- ;jp $
- ; assumes x,y are in on teh table in the form of ss.^^^^^^ \ jp $
- pop hl ;then advance SP so the bullet table handler can continue
- ;doubling the spread
- ld c,a
- ld b,$82 ;and now complete the address thinger. in BC
- rlc L \ rlc L ;From %ss.yyyyyy to %yyyyyy.ss
- ld a,(bc) ;Get %AAAaaaaa. Let's use upper 3 bits
- rlca \ rlca \ rlca ;Got %aaaaaAAA
- and %00000111
- bit 7,c
- jp z,_
- neg ;We had a positive number but we need movement in negative
- _:
- add a,L
- ;jp nc,PBTDestroy ;Bullet went past top. Destroy it.
- ;cp 240
- ;jp nc,PBTDestroy ; special case handling for top of screen shooting people
- ld L,a
- ld a,c
- add a,64
- ld c,a
- ld a,(bc) ;Getting X angle.
- rlca \ rlca \ rlca ;like above
- and %00000111
- ld b,a
- ld a,c
- and %11000000
- ld a,b
- ; *phew*. Almost looks like I know what I'm doing :P
- jp po,_
- neg
- _:
- rlc h \ rlc h ;rotate x to xxxxxx.ss
- add a,h ;add our value to the X pos
- ld h,a ; save back
- and %11111100 ; and for collision
- ;jp z,PBTDestroy
- rrc h \ rrc h ; rever
- rrc L \ rrc L
- push hl
- pop hl
- jp PBTMainMoveRet ;stack unavailable
- ;2
Advertisement
Add Comment
Please, Sign In to add comment