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
- PBTCreate: ;in: macro'd. Xofs,Yofs,Count
- ld hl,pbtfreebullet
- bit 6,(hl)
- ret nz ;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)
- 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)
- ld L,(hl)
- 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 TestRoutineUnFocPwr1
- .dw TestRoutineFocusPwr1
- .dw TestRoutineUnFocPwr2
- .dw TestRoutineFocusPwr2
- 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: ;??? (ChID5)
- .dw TestRoutineUnFocPwr1
- .dw TestRoutineFocusPwr1
- .dw TestRoutineUnFocPwr2
- .dw TestRoutineFocusPwr2
- PBTPRT06: ;Netham45L (ChID6)
- .dw TestRoutineUnFocPwr1
- .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 ;??? (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 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
- 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: ;??? (ChID5)PB00MoveCollide: ;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
- 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,0) ;xofs,yofs,cnt. centered bullet
- ret
- _:
- PBTSHOT(0,-1,0) ;left side
- PBTSHOT(6,-1,0) ;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,0) ;left center
- PBTSHOT(4,-1,0) ;right center
- ret
- ;=============================================================================
- ;BULLET RENDERING CODE (cycle 2)
- ;
- 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
- ;=============================================================================
- ;BULLET MOVEMENT/COLLISION CODE (cycle 5)
- ;
- PBTShot00Move: ;standard move by however manieth.
- ;E=Y D=X
- ;
- ;Routine to check for collisions with enemies should go here, but meh.
- ;Too lazy right now.
- ;
- ld a,-3
- add a,e
- bit 7,a
- jp nz,PBTDestroy
- ld e,a
- push de
- pop de
- jp PBTMainMoveRet
Advertisement
Add Comment
Please, Sign In to add comment