Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;Player bullet handlers
- ;
- ;PBT located at $8D00
- ;First 64 bytes is PBT's FBT, all are filled with values indicating player
- ;bullet's LSB base location (multiples of 3 starting at $8D40
- ;Last 64*3 bytes is PBT's actual bullet data entries, described below, but
- ;is up to called routine's interpretation.
- ;
- ;FBT's location is in (pbtfreebullet). If bit 6 is ever set, then the FBT
- ;is full.
- ;
- ;Important note: Character's X and Y positions are not stored as normal. There
- ;are two bits of accuracy at the start so you're going to have to right-shift
- ;twice to get the actual X,Y positions.
- ;
- ;Y = YYYY YYSS , where S is subpixel data
- ;X = XXXX XXSS , where S is subpixel data
- ;
- ;Player bullet structure (3 bytes)
- ;+0 : YTTTTTTT, T=Timer 0-127, Y=1 if focused shot
- ;+1 : Y position if applicable
- ;+2 : X position if applicable
- ;The routine that is being called must be able to distinguish between
- ;unfocused and focused modes, since there won't be seperation at
- ;this stage of the routine call.
- ;
- ;Several things to edit.
- ;(1) PBTPlayerRoutineTables : How bullets are created. Below it are links.
- ;(2) PBTPlayerTypeTables : Types of bullets and how they move
- ;
- ;You can make creative use of the game timers to tell bullets apart
- ;(gametimer1) by creating only certain ones on certain slices of masked time.
- ;A good mask might be like %00000111 so you get 8 different time slices on
- ;each processing. Also pay attention to firing delays or you might not ever
- ;get a single bullet out.
- ;
- ;Other than that, good luck. You're gonna need it.
- #DEFINE PBTSHOT(xofs,yofs,count) call PBTCreate \ .db xofs,yofs,count
- PlayerShoot:
- ld a,(characterID)
- add a,a
- ld e,a
- ld d,0
- ld hl,PBTPlayerRoutineTables
- add hl,de
- ld e,(hl)
- inc hl
- ld d,(hl)
- ld hl,charweapon1
- bit isfocused,(iy+danmakuflags)
- jr z,_
- inc hl
- inc de
- inc de ;if focused, charweapon2, and inc pointer to a focused standpoint
- _:
- ld a,(hl)
- add a,a
- add a,a ;x4 for weapon power thing
- ld L,a
- ld h,0
- add hl,de
- ld a,(hl)
- inc hl
- ld h,(hl)
- ld L,a
- jp (hl)
- PBTMainDraw:
- xor a
- call PBTFillBulletDetails
- ld (itemp1),sp
- ld sp,$8D40
- ld a,64
- PBTMainDrawLoop:
- ex af,af'
- dec sp
- pop af
- pop de
- cp $FF
- jp z,PBTMainDrawRet
- ld hl,(itemp2) ;unfocused
- bit 7,a
- jr z,_
- ld hl,(itemp3) ;focused
- _:
- jp (hl) ;routine being jumped to MUST keep B intact
- PBTMainDrawRet:
- ex af,af'
- dec a
- jr nz,PBTMainDrawLoop
- ld sp,(itemp1)
- ret
- PBTMainMove:
- ld a,4
- call PBTFillBulletDetails
- ld (itemp1),sp
- ld sp,$8D40
- ld a,64
- PBTMainMoveLoop:
- ex af,af'
- dec sp
- pop af ;A=tCCCCCCC, where t=type, C=counter
- pop de ;E=Ypos ; D=Xpos (no accuracy bits, negative values may be used)
- cp $FF
- jp z,PBTMainMoveRet
- ld hl,(itemp2) ;unfocused
- bit 7,a
- jr z,_
- ld hl,(itemp3) ;focused
- _:
- jp (hl) ;routine being jumped to MUST keep B intact
- PBTMainMoveRet:
- ex af,af'
- dec a
- jr nz,PBTMainMoveLoop
- ld sp,(itemp1)
- ret
- PBTNoCreate:
- pop hl
- inc hl
- inc hl
- inc hl
- jp (hl)
- PBTCreate: ;in: macro'd. Xofs,Yofs,Count
- ld hl,pbtfreebullet
- bit 6,(hl)
- jp nz,PBTNoCreate ;stop routine if over 64 bullets
- ld a,(hl) ;1.read
- inc (hl) ;2.increment
- ld L,a
- ld h,$8D
- ld L,(hl) ;got bullet position
- push hl
- pop ix
- ld de,(chary)
- srl e \ srl e ;y
- srl d \ srl d ;x
- pop hl
- ld a,d
- add a,(hl)
- inc hl
- ld (ix+2),a
- ld a,e
- add a,(hl)
- inc hl
- ld (ix+1),a
- ld a,(mdanmaku) ;isfocused == bit 1. Need to shift to bit 7.
- rrca
- rrca
- and $80
- or (hl) ;combining new counter with focused mask
- inc hl
- ld (ix+0),a
- jp (hl)
- PBTCreate2: ;D=Xofs,E=Yofs,A=Count
- push af
- ld hl,pbtfreebullet
- bit 6,(hl)
- jr z,_ ;stop routine if over 64 bullets. Jump past if no stop.
- pop af
- ret
- _:
- ld a,(hl) ;1.read
- inc (hl) ;2.increment
- ld L,a
- ld h,$8D
- ld L,(hl) ;got bullet position
- push hl
- pop ix
- ld a,(charx)
- srl a \ srl a
- add a,d
- ld (ix+2),a
- ld a,(chary)
- srl a \ srl a
- add a,e
- ld (ix+1),a
- ld a,(mdanmaku)
- rrca
- rrca
- and $80
- pop bc
- or b ;combining masks for b7=focused, b0-b6=counter
- ld (ix+0),a
- ret
- PBTDestroy: ;must be called in MOVE routine b4 SP is changed to save values
- ld hl,-3
- add hl,sp
- ld (hl),$FF
- ex de,hl
- ld hl,pbtfreebullet
- dec (hl) ;1.decrement
- ld L,(hl) ;2.write
- ld h,$8D
- ld (hl),e
- jp PBTMainMoveRet
- PBTFillBulletDetails:
- ld c,a
- ld b,0 ;offset (0 if render cycle, 4 if move/collide cycle)
- ld a,(characterID)
- add a,a
- ld hl,PBTPlayerTypeTables
- add a,L
- ld L,a
- jr nc,$+3
- inc h
- ld e,(hl)
- inc hl
- ld d,(hl) ;got address to character's bullet table in DE
- ld a,(charweapon1) ;unfocused weapon type
- add a,a ;x2
- add a,a ;x4
- add a,a ;x8 ;weapon power type now available.
- add a,e
- ld L,a
- ld h,d
- jr nc,_
- inc h
- _:
- add hl,bc
- ld a,(hl)
- inc hl
- ld h,(hl)
- ld L,a
- ld (itemp2),hl ;unfocused weapon type in itemp2 variable
- ld a,(charweapon2) ;focused weapon type
- add a,a ;x2
- add a,a ;x4
- add a,a ;x8
- add a,2 ;+more offset for focused type
- add a,e
- ld L,a
- ld h,d
- jr nc,_
- inc h
- _:
- add hl,bc
- ld a,(hl)
- inc hl
- ld h,(hl)
- ld L,a
- ld (itemp3),hl ;focused weapon type in itemp3 variable
- ret
- ;-----------------------------------------------------------------------------
- ;PLAYER BULLET CREATION TABLES
- ;
- PBTPlayerRoutineTables:
- .dw PBTPRT00 ;Devblock (ChID0) DO NOT CHANGE THESE ENTRIES
- .dw PBTPRT01 ;Iambian (ChID1)
- .dw PBTPRT02 ;Netham45 (ChID2)
- .dw PBTPRT03 ;??? (ChID3)
- .dw PBTPRT04 ;??? (ChID4)
- .dw PBTPRT05 ;??? (ChID5)
- .dw PBTPRT06 ;Netham45L (ChID6)
- .dw PBTPRT07 ;??? (ChID7)
- PBTPRT00: ;Devblock (ChID0)
- .dw DevBlockUnfPwr1 ;direct links to the routines that is about to be used
- .dw DevBlockFocPwr1
- .dw DevBlockUnfPwr2 ;direct links to the routines that is about to be used
- .dw DevBlockFocPwr2
- PBTPRT01: ;Iambian (ChID1)
- .dw IambianClaw ; Unfocused attack pwr1
- .dw IambianFire ; Focused attack pwr1
- .dw IambianClaw ; pwr2
- .dw IambianFire ; pwr2
- PBTPRT02: ;Netham45 (ChID2)
- .dw TestRoutineUnFocPwr1
- .dw TestRoutineFocusPwr1
- .dw TestRoutineUnFocPwr2
- .dw TestRoutineFocusPwr2
- PBTPRT03: ;??? (ChID3)
- .dw TestRoutineUnFocPwr1
- .dw TestRoutineFocusPwr1
- .dw TestRoutineUnFocPwr2
- .dw TestRoutineFocusPwr2
- PBTPRT04: ;??? (ChID4)
- .dw TestRoutineUnFocPwr1
- .dw TestRoutineFocusPwr1
- .dw TestRoutineUnFocPwr2
- .dw TestRoutineFocusPwr2
- PBTPRT05: ;Nanami (ChID5)
- .dw NanamiP1U
- .dw NanamiP1F
- .dw NanamiP2U
- .dw NanamiP2F
- PBTPRT06: ;Netham45L (ChID6)
- .dw ShotHyperdrive
- .dw TestRoutineFocusPwr1
- .dw TestRoutineUnFocPwr2
- .dw TestRoutineFocusPwr2
- PBTPRT07: ;??? (ChID7)
- .dw TestRoutineUnFocPwr1
- .dw TestRoutineFocusPwr1
- .dw TestRoutineUnFocPwr2
- .dw TestRoutineFocusPwr2
- ;-----------------------------------------------------------------------------
- ;PLAYER BULLET RENDER/MOVE/COLLISION TABLES
- ;
- PBTPlayerTypeTables:
- .dw PBTPTT00 ;Devblock (ChID0) DO NOT CHANGE THESE ENTRIES
- .dw PBTPTT01 ;Iambian (ChID1)
- .dw PBTPTT02 ;Netham45 (ChID2)
- .dw PBTPTT03 ;??? (ChID3)
- .dw PBTPTT04 ;??? (ChID4)
- .dw PBTPTT05 ;Nanami (ChID5)
- .dw PBTPTT06 ;Netham45L (ChID6)
- .dw PBTPTT07 ;??? (ChID7)
- ;SO FAR EVERY ENTRY IN THIS TABLE IS DUMMY ENTRIES. FILL IN WITH ACTUAL
- ;DATA CONNECTED TO ASSEMBLY ROUTINES WHENEVER YOU ARE READY TO CODE THIS
- ;HORRIBLE MESS.
- PBTPTT00: ;Devblock (ChID0)
- .dw PBTShot00Draw ;-Unfocused shot power 1 render
- .dw PBTShot00Draw ;-Focused shot power 1 render
- .dw PBTShot00Move ;-Unfocused shot power 1 move/collide/remove
- .dw PBTShot00Move ;-Focused shot power 1 move/collide/remove
- .dw PBTShot00Draw ;-Unfocused shot power 2 render
- .dw PBTShot00Draw ;-Focused shot power 2 render
- .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
- .dw PBTShot00Move ;-Focused shot power 2 move/collide/remove
- PBTPTT01: ;Iambian (ChID1)
- .dw PBTShot01DrawIam ;-Unfocused shot power 1 render
- .dw PBTShot00DrawIam ;-Focused shot power 1 render
- .dw PBTCLAWMove ;-Unfocused shot power 1 move/collide/remove
- .dw PBMoveANG ;-Focused shot power 1 move/collide/remove
- .dw PBTShot01DrawIam ;-Unfocused shot power 2 render
- .dw PBTShot00DrawIam ;-Focused shot power 2 render
- .dw PBTCLAWMove ;-Unfocused shot power 2 move/collide/remove
- .dw PBMoveANG;-Focused shot power 2 move/collide/remove
- PBTPTT02: ;Netham45 (ChID2)
- .dw PBTShot00Draw ;-Unfocused shot power 1 render
- .dw PBTShot00Draw ;-Focused shot power 1 render
- .dw PBTShot00Move ;-Unfocused shot power 1 move/collide/remove
- .dw PBTShot00Move ;-Focused shot power 1 move/collide/remove
- .dw PBTShot00Draw ;-Unfocused shot power 2 render
- .dw PBTShot00Draw ;-Focused shot power 2 render
- .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
- .dw PBTShot00Move ;-Focused shot power 2 move/collide/remove
- PBTPTT03: ;??? (ChID3)
- .dw PBTShot00Draw ;-Unfocused shot power 1 render
- .dw PBTShot00Draw ;-Focused shot power 1 render
- .dw PBTShot00Move ;-Unfocused shot power 1 move/collide/remove
- .dw PBTShot00Move ;-Focused shot power 1 move/collide/remove
- .dw PBTShot00Draw ;-Unfocused shot power 2 render
- .dw PBTShot00Draw ;-Focused shot power 2 render
- .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
- .dw PBTShot00Move ;-Focused shot power 2 move/collide/remove
- PBTPTT04: ;??? (ChID4)
- .dw PBTShot00Draw ;-Unfocused shot power 1 render
- .dw PBTShot00Draw ;-Focused shot power 1 render
- .dw PBTShot00Move ;-Unfocused shot power 1 move/collide/remove
- .dw PBTShot00Move ;-Focused shot power 1 move/collide/remove
- .dw PBTShot00Draw ;-Unfocused shot power 2 render
- .dw PBTShot00Draw ;-Focused shot power 2 render
- .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
- .dw PBTShot00Move ;-Focused shot power 2 move/collide/remove
- PBTPTT05: ;Nanami (ChID5)PB00MoveCollide: ;dummy routine
- .dw PBTShot00Drawiam ;-Unfocused shot power 1 render
- .dw PBTShot00Drawiam ;-Focused shot power 1 render
- .dw nanamiTest ;-Unfocused shot power 1 move/collide/remove
- .dw nanamitest ;-Focused shot power 1 move/collide/remove
- .dw PBTShot00Drawiam ;-Unfocused shot power 2 render
- .dw PBTShot00Drawiam ;-Focused shot power 2 render
- .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
- .dw PBTShot00Move ;-Focused shot power 2 move/collide/remove
- PBTPTT06: ;Netham45L (ChID6)
- .dw PBTShot00Draw ;-Unfocused shot power 1 render
- .dw PBTShot00Draw ;-Focused shot power 1 render
- .dw PBTShot00Move ;-Unfocused shot power 1 move/collide/remove
- .dw PBTShot00Move ;-Focused shot power 1 move/collide/remove
- .dw PBTShot00Draw ;-Unfocused shot power 2 render
- .dw PBTShot00Draw ;-Focused shot power 2 render
- .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
- .dw PBTShot00Move ;-Focused shot power 2 move/collide/remove
- PBTPTT07: ;??? (ChID7)PB00Draw ;dummy routine
- .dw PBTShot00Draw ;-Unfocused shot power 1 render
- .dw PBTShot00Draw ;-Focused shot power 1 render
- .dw PBTShot00Move ;-Unfocused shot power 1 move/collide/remove
- .dw PBTShot00Move ;-Focused shot power 1 move/collide/remove
- .dw PBTShot00Draw ;-Unfocused shot power 2 render
- .dw PBTShot00Draw ;-Focused shot power 2 render
- .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
- .dw PBTShot00Move ;-Focused shot power 2 move/collide/remove
- ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
- ;=============================================================================
- ;CHARACTER FIRING CODE (what happens when you push the fire button)
- ;
- DevBlockUnfPwr1: ;These routines pretty much all do the same thing
- TestRoutineUnFocPwr1:
- TestRoutineUnFocPwr2:
- DevBlockUnfPwr2:
- ;This routine fires a single centered shot on even cycles and
- ;two side shots on odd cycles, every other game cycle
- ld hl,firedelay
- dec (hl)
- ret nz
- ld (hl),2 ;FIRE DELAY FOR STANDARD SHOT IS TWO
- ld hl,charweapondat
- inc (hl)
- bit 0,(hl) ;check to see if even or odd. Using it to alternate bullet sets
- ld hl,(chary)
- jp z,_ ;jump to two side bullets thing
- PBTSHOT(3,-1,126) ;xofs,yofs,cnt. centered bullet
- ret
- _:
- PBTSHOT(0,-1,126) ;left side
- PBTSHOT(6,-1,126) ;right side
- ret
- DevBlockFocPwr1: ;Again, these routines all pretty much do the same thing
- DevBlockFocPwr2:
- TestRoutineFocusPwr1:
- TestRoutineFocusPwr2:
- ;This routine fires two centered shots every game cycle
- ;
- ld hl,firedelay
- dec (hl)
- ret nz
- ld (hl),1 ;ONE GAME CYCLE. THIS CYCLING PROBABLY ISN'T NEEDED THO.
- PBTSHOT(2,-1,126) ;left center
- PBTSHOT(4,-1,126) ;right center
- ret
- ShotHyperdrive:
- PBTSHOT(3,-1,126)
- PBTSHOT(3,-1,126)
- PBTSHOT(3,-1,126)
- PBTSHOT(3,-1,126)
- PBTSHOT(3,-1,126)
- PBTSHOT(3,-1,126)
- PBTSHOT(3,-1,126)
- PBTSHOT(3,-1,126)
- ret
- ;==========================================================
- ;============Dragons attacks===============================
- IambianClaw:
- ;Fires a 2 waves straight forward
- ;Pwr 2 attack fires 6 waves spaced out in a 15degree arc
- ld a,(firedelay) ;load a with fire delay
- ; 1 Good we can fire again
- ; 0 nope already shot a bullet wait till next keypress
- or a ;if z quit because we have already shot a bullet and not let go of the key
- ret z ; ^
- xor a ; zero a
- ld (firedelay),a ; and load it back into fire delay so that we do not shoot again
- ld a,(pbtfreebullet) ; load a with amount of bullets on the PBT
- cp 3 ; if greater than 3 QUIT
- ret nc ; ^
- ;PBTSHOT(xofs,yofs,count)
- ;PBTSHOT(1,1,126)
- ld a,120 ;load up teh cannon sire
- LD d,1 ; Account for wind
- ld e,1 ; AIM
- call pbtcreate2 ; FIRE!!!!! BLAM BANG BANG BOOM
- ret ; Till the next fight good sir *tips hat*
- IambianFire:
- ld hl,firedelay
- dec (hl)
- ret nz
- ld (hl),1 ;FIRE DELAY FOR STANDARD SHOT IS TWO
- call FormatDragonFire
- and %01111110
- CALL PBTCREATE2
- call FormatDragonFire
- and %01101111
- CALL PBTCREATE2
- call FormatDragonFire
- and %01011111
- CALL PBTCREATE2
- call FormatDragonFire
- and %01101111
- CALL PBTCREATE2
- ret
- FormatDragonFire:
- LD D,3
- LD E,-1
- ld hl,lfsrseed1
- ld a,(hl)
- rrca
- ld (hl),a
- jp nc,+_
- xor %00111000
- ld (hl),a
- _:
- set 6,a
- ret
- ;=======================end dragons attacks===================================
- ;=============================================================================
- ;=============================================================================
- ;==========================Nanami's Attacks===================================
- NanamiP1U:
- ; This attack sends a single shot out in a arch with the shape of
- ; _----_
- ; | |
- ; \ /
- ; \ /
- ; \/
- ; X
- ; where X is nanami
- ; it follows this path unless 2nd is released in which it takes the most linear path back to nanmi from its current
- ; position
- ;
- ; This attack also starts the arc in a different direction based on which direction you were traveling last
- ;
- ; This has a look up table at Nanami45LUT that is aligned on the LUT page
- ; This LUT contains the offsets from the firing position of nanami that makes it have this proper arc
- ; by doing it this way its much faster and causes less of a headache.
- ; When second is released we will be having the bullet come back to nanami this will be done with a arctan look up.
- ; going to see if i cant get away with reusing some of iambians enimy routines here have to lookinto the track function
- ; - 5 minutes later -
- ; we can use the call r.arctan to get the angle and return it in C
- ;
- ; TTl of bullet.
- ; i have no clue how to do this other than doing blatant collision detection with your self ask iambian
- ; LUT is organized as such
- ; 2 bytes per pair
- ; a pair consists of a counbt and a angle/2
- ; so
- ; .db 20,45
- ; would move the bullet at a 90D angle for 20 game cycles
- ; angle/2 is because we can not fit more than 127 different angles in the counter var i am using
- ; char weapon dat serve a few purposes.
- ; bit 7 is our left/right indicator
- ; and the lower 7 bits are angle ttl
- ; it set move left if reset move right
- ; [22:50:17] <+Iambian> If we really want this thing to be like fukken amazing, I suggest a particle trail :)
- ; [22:50:32] <+Iambian> A particle trail made of bullets
- ; [22:50:32] <@geekbozu> or a rotating thing
- ; [;22:50:35] <@geekbozu> and done
- ; [22:50:36] <@geekbozu> totally done
- ; [22:50:49] <@geekbozu> have to think of how to do that tho...
- ; [22:50:52] <@geekbozu> eh not to hard
- ; [22:50:54] <+Iambian> Bullets that can so totally damage the enemy
- ; [22:51:25] <@geekbozu> uhm consequences of calling the pbtbullet create routien while in bullet movement code?
- ; [22:51:47] <+Iambian> Without preserving SP? Epic fail.
- ; [22:51:59] <@geekbozu> well yeah presering sp obviously
- ; [22:52:12] <@geekbozu> (same trick as used to call the sprite routien)
- ; [22:52:25] <+Iambian> Yeah, well that should work.
- ; [22:52:37] <+Iambian> For creating the trail...
- ; [22:52:43] * @geekbozu adds some comments to his noteblock
- ; [22:53:22] <@geekbozu> also i intend to just create bullets at semi random intervals with semi random velocities that are slower than the orb
- ; [22:53:26] <@geekbozu> and it should make a nice effect
- ; [22:53:37] <+Iambian> I suggest getting the current angle that the thing is heading in, negating that so it goes in the opposite direction, then adding an angle that is plus or minus some amount. Probably similar to how the dragonfire is done, except the revised full-range code should be used
- ; [22:53:55] <@geekbozu> yeah more or less what i am thinking
- ; [22:54:07] <@geekbozu> but thats at a later date
- ;; [22:54:13] * @geekbozu copies irc logs into npp
- ld hl,charweapondat
- ld a,(keyread) ; preset charweapondat with keydata
- bit 1,a ; this is now how i want this to work but for testing it will work
- jp z,_
- set 7,(hl)
- jp ++_
- _:
- res 7,(hl)
- _:
- ld a,(firedelay) ; load with keycheck
- or a
- ret z ; if still held quit
- ld a,(pbtfreebullet) ; load a temp variable for incase we have been mashing second
- cp 1
- ret z ; if your just being a button masher quit
- set 0,(hl) ; make sure charweapon dat is at least 1
- ld a,0 ; load up teh cannon sire
- LD d,1 ; Account for wind
- ld e,1 ; AIM
- call pbtcreate2 ; FIRE!!!!! BLAM BANG BANG BOOM
- NanamiP1F:
- NanamiP2U:
- ; This attack sends 2 orbs shot out in a arch with the shape of roughly
- ; ____
- ; _-- --_
- ; | _----_ |
- ; \ | | /
- ; \ \ / /
- ; - \ / -
- ; \ \/ /
- ; X
- ; where X is nanami
- ; they travel at 40 and 50D respectively
- ; it follows this path unless 2nd is released in which it takes the most linear path back to nanmi from its current
- ; position
- ;
- ; This attack also starts the arc in a different direction based on which direction you were traveling last
- ;
- ; This has a look up table at Nanami40LUT and Nanami50LUT that is aligned on the LUT page
- ; This LUT contains the offsets from the firing position of nanami that makes it have this proper arc
- ; by doing it this way its much faster and causes less of a headache.
- ; When second is released we will be having the bullet come back to nanami this will be done with a arctan look up.
- ; going to see if i cant get away with reusing some of iambians enimy routines here have to lookinto the track function
- ; - 5 minutes later -
- ; we can use the call r.arctan to get the angle and return it in C
- ;
- ; TTl of bullet.
- ; i have no clue how to do this other than doing blatant collision detection with your self ask iambian
- NanamiP2F:
- ;jp $
- ;ld hl,charweapondat ; load hl with direction pointer and angle counter
- ; ld a,(keyread) ; preset charweapondat with keydata
- ;bit 1,a ; this is not how i want this to work but for testing it will work
- ;jp z,_ ; if z set that way
- ;set 7,(hl) ; else this way
- ;jp Checkb
- ;_:
- ; res 7,(hl)
- ;Checkb:
- ld a,(firedelay) ; load with keycheck
- or a
- ret z ; if still held quit
- ld a,(pbtfreebullet) ; load a temp variable for incase we have been mashing second
- cp 1
- ret z ; if your just being a button masher quit
- ld a,0 ; load up teh cannon sire
- LD d,5 ; Account for wind
- ld e,1 ; AIM
- call pbtcreate2 ; FIRE!!!!! BLAM BANG BANG BOOM
- ;=============================================================================
- ;==========================End Nanami's Attacks===============================
- ;=============================================================================
- ;=============================================================================
- ;BULLET RENDERING CODE (cycle 2)
- ;1
- PBTShot00Draw: ;standard 2x3 bullet
- ;E=Y D=X normalized (00yy yyyy,00xx xxxx)
- ld c,d ;keeping a backup of C for later screen merriment :)
- ex de,hl ;HL=00xxxxxx 00yyyyyy
- sla h
- sla h ;HL=xxxxxx00 00yyyyyy
- xor a
- add hl,hl
- rla
- add hl,hl
- rla
- add hl,hl ;HL=xxx0000y yyyyy000 A=00000xxx (after next instruction)
- rla
- or L
- ld L,a
- ld a,h
- and %00000001
- or %10000000
- ld h,a ;HL=address get. 99ccs. Not the best but filters out bad coord
- ld a,c ;saved X
- ld b,7
- and b
- xor b ;checking to see if xxx=7 (straddling bullet)
- jr z,_ ;skip to special case bullets straddling the 8 bit boundary
- xor b
- add a,$20 ;bullet2x2 table, except we're drawing 2x3's
- ld d,$40
- ld e,a
- ld a,(de)
- ld c,a
- ld de,8
- ld a,(hl)
- or c
- ld (hl),a
- add hl,de
- ld a,(hl)
- or c
- ld (hl),a
- add hl,de
- ld a,(hl)
- or c
- ld (hl),a
- jp PBTMainDrawRet ;go back to main loop
- _:
- ld de,7
- set 0,(hl) \ inc hl \ set 7,(hl) \ add hl,de
- set 0,(hl) \ inc hl \ set 7,(hl) \ add hl,de
- set 0,(hl) \ inc hl \ set 7,(hl)
- jp PBTMainDrawRet
- PBTShot00DrawIam: ;standard 2x3 bullet
- ;E=Y D=X normalized (00yy yyyy,00xx xxxx)
- ld c,d ;keeping a backup of C for later screen merriment :)
- ex de,hl ;HL=00xxxxxx 00yyyyyy
- ld a,h
- and %00111111
- ld h,a
- ld a,l
- and %00111111
- ld l,a
- cp 63
- jp z,PBTMainDrawRet
- sla h
- sla h ;HL=xxxxxx00 00yyyyyy
- xor a
- add hl,hl
- rla
- add hl,hl
- rla
- add hl,hl ;HL=xxx0000y yyyyy000 A=00000xxx (after next instruction)
- rla
- or L
- ld L,a
- ld a,h
- and %00000001
- or %10000000
- ld h,a ;HL=address get. 99ccs. Not the best but filters out bad coord
- ld a,c ;saved X
- ld b,7
- and b
- xor b ;checking to see if xxx=7 (straddling bullet)
- jr z,_ ;skip to special case bullets straddling the 8 bit boundary
- xor b
- add a,$20 ;bullet2x2 table, except we're drawing 2x3's
- ld d,$40
- ld e,a
- ld a,(de)
- ld c,a
- ld de,8
- ld a,(hl)
- or c
- ld (hl),a
- add hl,de
- ld a,(hl)
- or c
- ld (hl),a
- add hl,de
- ld a,(hl)
- or c
- ld (hl),a
- jp PBTMainDrawRet ;go back to main loop
- _:
- ld a,c
- cp 63
- jp nc,PBTMainDrawREt
- ld de,7
- set 0,(hl) \ inc hl \ set 7,(hl) \ add hl,de
- set 0,(hl) \ inc hl \ set 7,(hl) \ add hl,de
- set 0,(hl) \ inc hl \ set 7,(hl)
- jp PBTMainDrawRet
- PBTShot01DrawIam:
- ;Draws a 8x16 arc
- ;fires on of 3 sprites based off of the angle in the counter
- ;E=Y D=X normalized (00yy yyyy,00xx xxxx)
- ;IX=spritelocation
- ; Is this a piercing attack? i dont think it is. ask teh dragon later
- ld hl,0
- add hl,sp ; save the current stack pointer into hl
- ld sp,(itemp1) ; restores the stack so we can use it
- push hl ; push it onto the stack for safe keeping
- ex af,af' ; exchange and save flags
- push af ; why i have no bloody clue
- ;ex af,af'
- ld a,d ; ld a with X
- add a,6 ; Increase a with 6 ; we do this so that the 8x16 sprite is over the center of
- ld d,a ; load it back into D ; the dragon not the far left
- push de ; save to stack
- sub 8 ; move it over so that the main point is at the top of the arc but we draw it from the side like
- ; the sprite is oriented
- ld d,a ; load the modified x back into a
- ld ix,WaveGfxDat ; load ix with sprite pointer...
- call DrawClippedSpriteGeneral ;do shit that is in teh lable
- pop de ; restore x and y (even though y is unmodified)
- ld ix,wavegfxdat+8 ; load ix with second half of wave sprite
- call drawclippedspritegeneral ;.. do i really need to spell this out for you
- ;ex af,af'
- pop af ;restore af
- ex af,af' ; ^
- pop hl
- ld sp,hl ; restore previous stack
- jp PBTMainDrawRet
- ;2
- ;=============================================================================
- ;BULLET MOVEMENT/COLLISION CODE (cycle 5)
- ;1
- PBTShot00Move: ;standard move by however manieth.
- ;E=Y D=X
- inc e \ inc d ;modify for collision routine
- ld ix,PBTShot00MoveCont ;return address for collision routine
- jp SmallBulletCollision ;IN: DE=XY,
- PBTShot00MoveCont:
- dec e \ dec d ;unmodify from collision routine
- ld a,-3 ;Move the Y direction up by 3 pixels
- add a,e ;
- bit 7,a ;
- jp nz,PBTDestroy ;But if it went above the top (carry), then kill the bullet
- ld e,a ;Else store the result back to E and wait for the push
- push de ;save result of movement
- ;********************************
- ;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
- DEC L
- ;cp 10
- jr nz,_
- push hl \ inc sp ;EXIT CODE
- pop de ;back to the way it was...
- jp PBTDestroy ;and get rid of the bullet.
- _:
- push hl \ inc sp ;EXIT CODE
- ;********************************
- pop de ;then advance SP so the bullet table handler can continue
- jp PBTMainMoveRet ;stack unavailable
- PBTCLAWMove: ;standard move by however manieth.
- ;E=Y D=X
- inc e \ inc d ;modify for collision routine
- ld ix,PBTShot00MoveCont2 ;return address for collision routine
- jp SmallBulletCollision ;IN: DE=XY,
- PBTShot00MoveCont2:
- dec e \ dec d ;unmodify from collision routine
- ld a,-3 ;Move the Y direction up by 3 pixels
- add a,e ;
- bit 7,a ;
- jp nz,PBTDestroy ;But if it went above the top (carry), then kill the bullet
- ld e,a ;Else store the result back to E and wait for the push
- push de ;save result of movement
- pop de
- jp pbtmainmoveret
- ;********************************
- ;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
- ;DEC L
- ;;cp 10
- ;jr nz,_
- ;push hl \ inc sp ;EXIT CODE
- ;pop de ;back to the way it was...
- ;jp PBTDestroy ;and get rid of the bullet.
- ;_:
- ; push hl \ inc sp ;EXIT CODE
- ;********************************
- ; pop de ;then advance SP so the bullet table handler can continue
- ; jp PBTMainMoveRet ;stack unavailable
- SmallBulletCollision: ;E=Y D=X (bullet)
- ld hl,$8E01 ;starting off with byte needed to see if anything is there
- ld bc,$0A08 ;ten enemies, using C as a constant for adjustments
- SmallBulletCollisionLoop:
- xor a
- cp (hl)
- jr z,SmallBulletCollisionSkip
- inc L
- inc L
- inc L ;position Y
- ld a,(hl)
- sub e ;bY-eY. 10-12. Carry means no collide
- jr nc,SmallBulletCollisionSkipY
- add a,c
- jr nc,SmallBulletCollisionSkipY
- inc L
- ld a,(hl) ;position X
- sub d ;same deal as above. Skipping comments.
- jr nc,SmallBulletCollisionSkipX
- add a,c ;
- jr nc,SmallBulletCollisionSkipX
- ;Collision happened. We may trash this bullet entry now via calling.
- ld c,1 ;BASE WEAPON POWER
- call DamageEnemy
- jp PBTDestroy
- SmallBulletCollisionSkip:
- ld a,20
- jp _
- SmallBulletCollisionSkipY:
- ld a,17
- jp _
- SmallBulletCollisionSkipX:
- ld a,16
- _:
- add a,L
- ld L,a
- djnz SmallBulletCollisionLoop
- SmallBulletCollisionBossCheck:
- xor a
- cp (hl)
- jp z,SmallBulletCollideReturn
- inc L
- inc L
- inc L ;position Y
- ld a,(hl)
- sub e ;bY-eY. 10-12. Carry means no collide
- jp nc,SmallBulletCollideReturn
- add a,c ;(bY-eY)-8. (22-20)-8. Carry means CAN collide, else no collide
- jp nc,SmallBulletCollideReturn
- inc L
- ld a,(hl) ;position X
- sub d ;same deal as above. Skipping comments.
- jp nc,SmallBulletCollideReturn
- add a,c ;
- jp nc,SmallBulletCollideReturn
- ld c,1 ;BASE POWER
- call DamageBoss
- jp PBTDestroy
- SmallBulletCollideReturn;
- jp (ix)
- ;2
- PBMoveANG:
- ;1
- ;Moves the bullet in the directoin given via an angle
- ;Stored in the LSB of the counter
- ;Doing: F.ttt.aaaa, where F=focused(donotmod),t=time,a=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
- push de ;move the stack back for something...
- ;********************************
- ;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
- ld a,(gametimer1)
- and 1 ;ticking the timer every other game cycle
- ld a,L
- jr z,_
- and %01110000
- sub %00010000
- jr nz,_
- push hl \ inc sp ;EXIT CODE
- pop de ;back to the way it was...
- jp PBTDestroy ;and get rid of the bullet.
- _:
- xor L
- and %01110000
- xor L
- ld L,a
- push hl \ inc sp ;EXIT CODE
- ld a,L
- pop hl ;then advance SP so the bullet table handler can continue
- and %00001111
- add a,a ;doubling the spread
- add a,192-16 ;get true angle 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
- 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
- bit 7,c ;zero-crossing?
- jr z,_ ;jump if not negative.
- neg
- _:
- rlc h \ rlc h
- add a,h
- ld h,a
- and %11111100
- jp z,PBTDestroy
- rrc h \ rrc h
- rrc L \ rrc L
- push hl
- pop hl
- jp PBTMainMoveRet ;stack unavailable
- ;2
- 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 for something...
- ;********************************
- ;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
- and %00111111
- ld h,a
- ld a,e
- and %00111111
- ld l,a
- ld de,(chary) ; de = your pos
- ;ex de,hl
- call r.arctan ; returns angle in c and a
- ld (curscore+1),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
- ;add a,128
- pop de
- push de ; 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:
- 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 pe,_
- neg
- _:
- rlc h \ rlc h
- add a,h
- ld h,a
- and %11111100
- ;jp z,PBTDestroy
- rrc h \ rrc h
- rrc L \ rrc L
- push hl
- pop hl
- jp PBTMainMoveRet ;stack unavailable
- ;2
- Add100ToScore:
- ld a,8
- ld (scoretime),a ;resetting score timer
- ld de,100
- ld hl,(tempscore)
- add hl,de
- ld (tempscore),hl
- ld e,0
- ld hl,(tempscore+2)
- adc hl,de
- ld (tempscore+2),hl
- ret
- DamageBoss:
- ld a,(charpower)
- add a,c ;base power
- ld hl,bossArmor
- sub (hl)
- jr nc,_
- xor a ;cannot pierce that armor.
- _:
- ld c,a
- ld b,0
- ld hl,(bossHP)
- sbc hl,bc
- jr nc,_
- ld hl,0 ;boss HP never go below 0. Check when script system is invoked
- _:
- ld (bossHP),hl
- jp Add100ToScore
- DamageEnemy:
- inc L
- ld a,(hl) ;enemyHP
- or a
- jp z,Add100ToScore ;skip trying to kill enemy. Enemy is invincible.
- ld a,(charpower)
- add a,c
- ld c,a
- ld a,(hl) ;curhp-dmg
- sub c
- ld (hl),a
- jr z,$+4
- jp nc,Add100ToScore ;enemy still alive. Don't destruct
- ld a,-5
- add a,L
- ld L,a
- xor a
- ld (hl),a ;remove enemy. Might want to make a fancy explosion. Not now.
- dec hl
- dec a
- ld (hl),a ;set primary counter to 0 (up to 8) for explosiony stuffs
- jp Add100ToScore
- WaveGfxDat:
- .option bm_min_w = 8
- #include "GfxDat\Attacks\Wave.bmp"
- NanamiLUT45: ;$4030
- .db 1,0 ; dummy entry to get the variables initialized
- .db 20,32 ;4
- .db 20,64 ;6
- .db 20,98 ;8
- .db 20,127
- .db 00,00 ;12
Advertisement
Add Comment
Please, Sign In to add comment