Geekboy

Untitled

Oct 23rd, 2011
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Player bullet handlers
  2. ;
  3. ;PBT located at $8D00
  4. ;First 64 bytes is PBT's FBT, all are filled with values indicating player
  5. ;bullet's LSB base location (multiples of 3 starting at $8D40
  6. ;Last 64*3 bytes is PBT's actual bullet data entries, described below, but
  7. ;is up to called routine's interpretation.
  8. ;
  9. ;FBT's location is in (pbtfreebullet). If bit 6 is ever set, then the FBT
  10. ;is full.
  11. ;
  12. ;Important note: Character's X and Y positions are not stored as normal. There
  13. ;are two bits of accuracy at the start so you're going to have to right-shift
  14. ;twice to get the actual X,Y positions.
  15. ;
  16. ;Y = YYYY YYSS , where S is subpixel data
  17. ;X = XXXX XXSS , where S is subpixel data
  18. ;
  19.  
  20. ;Player bullet structure (3 bytes)
  21. ;+0 : YTTTTTTT, T=Timer 0-127, Y=1 if focused shot
  22. ;+1 : Y position if applicable
  23. ;+2 : X position if applicable
  24.  
  25. ;The routine that is being called must be able to distinguish between
  26. ;unfocused and focused modes, since there won't be seperation at
  27. ;this stage of the routine call.
  28. ;
  29. ;Several things to edit.
  30. ;(1) PBTPlayerRoutineTables : How bullets are created. Below it are links.
  31. ;(2) PBTPlayerTypeTables : Types of bullets and how they move
  32. ;
  33. ;You can make creative use of the game timers to tell bullets apart
  34. ;(gametimer1) by creating only certain ones on certain slices of masked time.
  35. ;A good mask might be like %00000111 so you get 8 different time slices on
  36. ;each processing. Also pay attention to firing delays or you might not ever
  37. ;get a single bullet out.
  38. ;
  39. ;Other than that, good luck. You're gonna need it.
  40.  
  41.  
  42. #DEFINE PBTSHOT(xofs,yofs,count) call PBTCreate \ .db xofs,yofs,count
  43.  
  44.  
  45.  
  46. PlayerShoot:
  47.  ld a,(characterID)
  48.  add a,a
  49.  ld e,a
  50.  ld d,0
  51.  ld hl,PBTPlayerRoutineTables
  52.  add hl,de
  53.  ld e,(hl)
  54.  inc hl
  55.  ld d,(hl)
  56.  ld hl,charweapon1
  57.  bit isfocused,(iy+danmakuflags)
  58.  jr z,_
  59.  inc hl
  60.  inc de
  61.  inc de  ;if focused, charweapon2, and inc pointer to a focused standpoint
  62. _:
  63.  ld a,(hl)
  64.  add a,a
  65.  add a,a  ;x4 for weapon power thing
  66.  ld L,a
  67.  ld h,0
  68.  add hl,de
  69.  ld a,(hl)
  70.  inc hl
  71.  ld h,(hl)
  72.  ld L,a
  73.  jp (hl)
  74.  
  75. PBTMainDraw:
  76.  xor a
  77.  call PBTFillBulletDetails
  78.  ld (itemp1),sp
  79.  ld sp,$8D40
  80.  ld a,64
  81. PBTMainDrawLoop:
  82.  ex af,af'
  83. dec sp
  84. pop af
  85. pop de
  86. cp $FF
  87. jp z,PBTMainDrawRet
  88. ld hl,(itemp2) ;unfocused
  89. bit 7,a
  90. jr z,_
  91. ld hl,(itemp3) ;focused
  92. _:
  93. jp (hl)        ;routine being jumped to MUST keep B intact
  94. PBTMainDrawRet:
  95. ex af,af'
  96.  dec a
  97.  jr nz,PBTMainDrawLoop
  98.  ld sp,(itemp1)
  99.  ret
  100.  
  101. PBTMainMove:
  102.  ld a,4
  103.  call PBTFillBulletDetails
  104.  ld (itemp1),sp
  105.  ld sp,$8D40
  106.  ld a,64
  107. PBTMainMoveLoop:
  108.  ex af,af'
  109. dec sp
  110. pop af   ;A=tCCCCCCC, where t=type, C=counter
  111. pop de   ;E=Ypos ; D=Xpos (no accuracy bits, negative values may be used)
  112. cp $FF
  113. jp z,PBTMainMoveRet
  114. ld hl,(itemp2) ;unfocused
  115. bit 7,a
  116. jr z,_
  117. ld hl,(itemp3) ;focused
  118. _:
  119. jp (hl)        ;routine being jumped to MUST keep B intact
  120. PBTMainMoveRet:
  121. ex af,af'
  122.  dec a
  123.  jr nz,PBTMainMoveLoop
  124.  ld sp,(itemp1)
  125.  ret
  126.  
  127. PBTCreate: ;in: macro'd. Xofs,Yofs,Count
  128.  ld hl,pbtfreebullet
  129.  bit 6,(hl)
  130.  ret nz     ;stop routine if over 64 bullets
  131.  ld a,(hl) ;1.read
  132.  inc (hl)  ;2.increment
  133.  ld L,a
  134.  ld h,$8D
  135.  ld L,(hl) ;got bullet position
  136.  push hl
  137.  pop ix
  138.  ld de,(chary)
  139.  srl e \ srl e ;y
  140.  srl d \ srl d ;x
  141.  pop hl
  142.  ld a,d
  143.  add a,(hl)
  144.  inc hl
  145.  ld (ix+2),a
  146.  ld a,e
  147.  add a,(hl)
  148.  inc hl
  149.  ld (ix+1),a
  150.  ld a,(mdanmaku)  ;isfocused == bit 1. Need to shift to bit 7.
  151.  rrca
  152.  rrca
  153.  and $80
  154.  or (hl) ;combining new counter with focused mask
  155.  inc hl
  156.  ld (ix+0),a
  157.  jp (hl)
  158.  
  159.  
  160. PBTDestroy: ;must be called in MOVE routine b4 SP is changed to save values
  161.  ld hl,-3
  162.  add hl,sp
  163.  ld (hl),$FF
  164.  ex de,hl
  165.  ld hl,pbtfreebullet
  166.  dec (hl)
  167.  ld L,(hl)
  168.  ld h,$8D
  169.  ld (hl),e
  170.  jp PBTMainMoveRet
  171.  
  172. PBTFillBulletDetails:
  173.  ld c,a
  174.  ld b,0   ;offset (0 if render cycle, 4 if move/collide cycle)
  175.  ld a,(characterID)
  176.  add a,a
  177.  ld hl,PBTPlayerTypeTables
  178.  add a,L
  179.  ld L,a
  180.  jr nc,$+3
  181.  inc h
  182.  ld e,(hl)
  183.  inc hl
  184.  ld d,(hl) ;got address to character's bullet table in DE
  185.  ld a,(charweapon1)  ;unfocused weapon type
  186.  add a,a  ;x2
  187.  add a,a  ;x4
  188.  add a,a  ;x8  ;weapon power type now available.
  189.  add a,e
  190.  ld L,a
  191.  ld h,d
  192.  jr nc,_
  193.  inc h
  194. _:
  195.  add hl,bc
  196.  ld a,(hl)
  197.  inc hl
  198.  ld h,(hl)
  199.  ld L,a
  200.  ld (itemp2),hl  ;unfocused weapon type in itemp2 variable
  201.  ld a,(charweapon2)  ;focused weapon type
  202.  add a,a  ;x2
  203.  add a,a  ;x4
  204.  add a,a  ;x8
  205.  add a,2  ;+more offset for focused type
  206.  add a,e
  207.  ld L,a
  208.  ld h,d
  209.  jr nc,_
  210.  inc h
  211. _:
  212.  add hl,bc
  213.  ld a,(hl)
  214.  inc hl
  215.  ld h,(hl)
  216.  ld L,a
  217.  ld (itemp3),hl  ;focused weapon type in itemp3 variable
  218.  ret
  219.  
  220. ;-----------------------------------------------------------------------------
  221. ;PLAYER BULLET CREATION TABLES
  222. ;
  223.  
  224.  
  225. PBTPlayerRoutineTables:
  226. .dw PBTPRT00  ;Devblock  (ChID0) DO NOT CHANGE THESE ENTRIES
  227. .dw PBTPRT01  ;Iambian   (ChID1)
  228. .dw PBTPRT02  ;Netham45  (ChID2)
  229. .dw PBTPRT03  ;???       (ChID3)
  230. .dw PBTPRT04  ;???       (ChID4)
  231. .dw PBTPRT05  ;???       (ChID5)
  232. .dw PBTPRT06  ;Netham45L (ChID6)
  233. .dw PBTPRT07  ;???       (ChID7)
  234.  
  235. PBTPRT00:  ;Devblock  (ChID0)
  236. .dw DevBlockUnfPwr1   ;direct links to the routines that is about to be used
  237. .dw DevBlockFocPwr1
  238. .dw DevBlockUnfPwr2   ;direct links to the routines that is about to be used
  239. .dw DevBlockFocPwr2
  240. PBTPRT01:  ;Iambian   (ChID1)
  241. .dw TestRoutineUnFocPwr1
  242. .dw TestRoutineFocusPwr1
  243. .dw TestRoutineUnFocPwr2
  244. .dw TestRoutineFocusPwr2
  245. PBTPRT02:  ;Netham45  (ChID2)
  246. .dw TestRoutineUnFocPwr1
  247. .dw TestRoutineFocusPwr1
  248. .dw TestRoutineUnFocPwr2
  249. .dw TestRoutineFocusPwr2
  250. PBTPRT03:  ;???       (ChID3)
  251. .dw TestRoutineUnFocPwr1
  252. .dw TestRoutineFocusPwr1
  253. .dw TestRoutineUnFocPwr2
  254. .dw TestRoutineFocusPwr2
  255. PBTPRT04:  ;???       (ChID4)
  256. .dw TestRoutineUnFocPwr1
  257. .dw TestRoutineFocusPwr1
  258. .dw TestRoutineUnFocPwr2
  259. .dw TestRoutineFocusPwr2
  260. PBTPRT05:  ;???       (ChID5)
  261. .dw TestRoutineUnFocPwr1
  262. .dw TestRoutineFocusPwr1
  263. .dw TestRoutineUnFocPwr2
  264. .dw TestRoutineFocusPwr2
  265. PBTPRT06:  ;Netham45L (ChID6)
  266. .dw TestRoutineUnFocPwr1
  267. .dw TestRoutineFocusPwr1
  268. .dw TestRoutineUnFocPwr2
  269. .dw TestRoutineFocusPwr2
  270. PBTPRT07:  ;???       (ChID7)
  271. .dw TestRoutineUnFocPwr1
  272. .dw TestRoutineFocusPwr1
  273. .dw TestRoutineUnFocPwr2
  274. .dw TestRoutineFocusPwr2
  275.  
  276.  
  277. ;-----------------------------------------------------------------------------
  278. ;PLAYER BULLET RENDER/MOVE/COLLISION TABLES
  279. ;
  280.  
  281. PBTPlayerTypeTables:
  282. .dw PBTPTT00  ;Devblock  (ChID0) DO NOT CHANGE THESE ENTRIES
  283. .dw PBTPTT01  ;Iambian   (ChID1)
  284. .dw PBTPTT02  ;Netham45  (ChID2)
  285. .dw PBTPTT03  ;???       (ChID3)
  286. .dw PBTPTT04  ;???       (ChID4)
  287. .dw PBTPTT05  ;???       (ChID5)
  288. .dw PBTPTT06  ;Netham45L (ChID6)
  289. .dw PBTPTT07  ;???       (ChID7)
  290.  
  291. ;SO FAR EVERY ENTRY IN THIS TABLE IS DUMMY ENTRIES. FILL IN WITH ACTUAL
  292. ;DATA CONNECTED TO ASSEMBLY ROUTINES WHENEVER YOU ARE READY TO CODE THIS
  293. ;HORRIBLE MESS.
  294. PBTPTT00:         ;Devblock  (ChID0)
  295. .dw PBTShot00Draw ;-Unfocused shot power 1 render
  296. .dw PBTShot00Draw ;-Focused   shot power 1 render
  297. .dw PBTShot00Move ;-Unfocused shot power 1 move/collide/remove
  298. .dw PBTShot00Move ;-Focused   shot power 1 move/collide/remove
  299. .dw PBTShot00Draw ;-Unfocused shot power 2 render
  300. .dw PBTShot00Draw ;-Focused   shot power 2 render
  301. .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
  302. .dw PBTShot00Move ;-Focused   shot power 2 move/collide/remove
  303. PBTPTT01:         ;Iambian   (ChID1)
  304. .dw PBTShot00Draw ;-Unfocused shot power 1 render
  305. .dw PBTShot00Draw ;-Focused   shot power 1 render
  306. .dw PBTShot00Move ;-Unfocused shot power 1 move/collide/remove
  307. .dw PBTShot00Move ;-Focused   shot power 1 move/collide/remove
  308. .dw PBTShot00Draw ;-Unfocused shot power 2 render
  309. .dw PBTShot00Draw ;-Focused   shot power 2 render
  310. .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
  311. .dw PBTShot00Move ;-Focused   shot power 2 move/collide/remove
  312. PBTPTT02:         ;Netham45  (ChID2)
  313. .dw PBTShot00Draw ;-Unfocused shot power 1 render
  314. .dw PBTShot00Draw ;-Focused   shot power 1 render
  315. .dw PBTShot00Move ;-Unfocused shot power 1 move/collide/remove
  316. .dw PBTShot00Move ;-Focused   shot power 1 move/collide/remove
  317. .dw PBTShot00Draw ;-Unfocused shot power 2 render
  318. .dw PBTShot00Draw ;-Focused   shot power 2 render
  319. .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
  320. .dw PBTShot00Move ;-Focused   shot power 2 move/collide/remove
  321. PBTPTT03:         ;???       (ChID3)
  322. .dw PBTShot00Draw ;-Unfocused shot power 1 render
  323. .dw PBTShot00Draw ;-Focused   shot power 1 render
  324. .dw PBTShot00Move ;-Unfocused shot power 1 move/collide/remove
  325. .dw PBTShot00Move ;-Focused   shot power 1 move/collide/remove
  326. .dw PBTShot00Draw ;-Unfocused shot power 2 render
  327. .dw PBTShot00Draw ;-Focused   shot power 2 render
  328. .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
  329. .dw PBTShot00Move ;-Focused   shot power 2 move/collide/remove
  330. PBTPTT04:         ;???       (ChID4)
  331. .dw PBTShot00Draw ;-Unfocused shot power 1 render
  332. .dw PBTShot00Draw ;-Focused   shot power 1 render
  333. .dw PBTShot00Move ;-Unfocused shot power 1 move/collide/remove
  334. .dw PBTShot00Move ;-Focused   shot power 1 move/collide/remove
  335. .dw PBTShot00Draw ;-Unfocused shot power 2 render
  336. .dw PBTShot00Draw ;-Focused   shot power 2 render
  337. .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
  338. .dw PBTShot00Move ;-Focused   shot power 2 move/collide/remove
  339. PBTPTT05:         ;???       (ChID5)PB00MoveCollide: ;dummy routine
  340. .dw PBTShot00Draw ;-Unfocused shot power 1 render
  341. .dw PBTShot00Draw ;-Focused   shot power 1 render
  342. .dw PBTShot00Move ;-Unfocused shot power 1 move/collide/remove
  343. .dw PBTShot00Move ;-Focused   shot power 1 move/collide/remove
  344. .dw PBTShot00Draw ;-Unfocused shot power 2 render
  345. .dw PBTShot00Draw ;-Focused   shot power 2 render
  346. .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
  347. .dw PBTShot00Move ;-Focused   shot power 2 move/collide/remove
  348. PBTPTT06:         ;Netham45L (ChID6)
  349. .dw PBTShot00Draw ;-Unfocused shot power 1 render
  350. .dw PBTShot00Draw ;-Focused   shot power 1 render
  351. .dw PBTShot00Move ;-Unfocused shot power 1 move/collide/remove
  352. .dw PBTShot00Move ;-Focused   shot power 1 move/collide/remove
  353. .dw PBTShot00Draw ;-Unfocused shot power 2 render
  354. .dw PBTShot00Draw ;-Focused   shot power 2 render
  355. .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
  356. .dw PBTShot00Move ;-Focused   shot power 2 move/collide/remove
  357. PBTPTT07:         ;???       (ChID7)PB00Draw         ;dummy routine
  358. .dw PBTShot00Draw ;-Unfocused shot power 1 render
  359. .dw PBTShot00Draw ;-Focused   shot power 1 render
  360. .dw PBTShot00Move ;-Unfocused shot power 1 move/collide/remove
  361. .dw PBTShot00Move ;-Focused   shot power 1 move/collide/remove
  362. .dw PBTShot00Draw ;-Unfocused shot power 2 render
  363. .dw PBTShot00Draw ;-Focused   shot power 2 render
  364. .dw PBTShot00Move ;-Unfocused shot power 2 move/collide/remove
  365. .dw PBTShot00Move ;-Focused   shot power 2 move/collide/remove
  366.  
  367. ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  368. ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  369. ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  370. ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  371.  
  372. ;=============================================================================
  373. ;CHARACTER FIRING CODE (what happens when you push the fire button)
  374. ;
  375.  
  376. DevBlockUnfPwr1:  ;These routines pretty much all do the same thing
  377. TestRoutineUnFocPwr1:
  378. TestRoutineUnFocPwr2:
  379. DevBlockUnfPwr2:
  380. ;This routine fires a single centered shot on even cycles and
  381. ;two side shots on odd cycles, every other game cycle
  382.  ld hl,firedelay
  383.  dec (hl)
  384.  ret nz
  385.  ld (hl),2  ;FIRE DELAY FOR STANDARD SHOT IS TWO
  386.  ld hl,charweapondat
  387.  inc (hl)
  388.  bit 0,(hl)  ;check to see if even or odd. Using it to alternate bullet sets
  389.  ld hl,(chary)
  390.  jp z,_      ;jump to two side bullets thing
  391.  PBTSHOT(3,-1,0) ;xofs,yofs,cnt. centered bullet
  392.  ret
  393. _:
  394.  PBTSHOT(0,-1,0) ;left side
  395.  PBTSHOT(6,-1,0) ;right side
  396.  ret
  397.  
  398. DevBlockFocPwr1:  ;Again, these routines all pretty much do the same thing
  399. DevBlockFocPwr2:
  400. TestRoutineFocusPwr1:
  401. TestRoutineFocusPwr2:
  402. ;This routine fires two centered shots every game cycle
  403. ;
  404.  ld hl,firedelay
  405.  dec (hl)
  406.  ret nz
  407.  ld (hl),1  ;ONE GAME CYCLE. THIS CYCLING PROBABLY ISN'T NEEDED THO.
  408.  PBTSHOT(2,-1,0) ;left center
  409.  PBTSHOT(4,-1,0) ;right center
  410.  ret
  411.  
  412. ;=============================================================================
  413. ;BULLET RENDERING CODE (cycle 2)
  414. ;
  415.  
  416. PBTShot00Draw:    ;standard 2x3 bullet
  417. ;E=Y D=X normalized (00yy yyyy,00xx xxxx)
  418.  ld c,d    ;keeping a backup of C for later screen merriment :)
  419.  ex de,hl  ;HL=00xxxxxx 00yyyyyy
  420.  sla h
  421.  sla h     ;HL=xxxxxx00 00yyyyyy
  422.  xor a
  423.  add hl,hl
  424.  rla
  425.  add hl,hl
  426.  rla
  427.  add hl,hl ;HL=xxx0000y yyyyy000 A=00000xxx (after next instruction)
  428.  rla
  429.  or L
  430.  ld L,a
  431.  ld a,h
  432.  and %00000001
  433.  or  %10000000
  434.  ld h,a         ;HL=address get. 99ccs. Not the best but filters out bad coord
  435.  ld a,c         ;saved X
  436.  ld b,7
  437.  and b
  438.  xor b          ;checking to see if xxx=7 (straddling bullet)
  439.  jr z,_  ;skip to special case bullets straddling the 8 bit boundary
  440.  xor b
  441.  add a,$20 ;bullet2x2 table, except we're drawing 2x3's
  442.  ld d,$40
  443.  ld e,a
  444.  ld a,(de)
  445.  ld c,a
  446.  ld de,8
  447.  ld a,(hl)
  448.  or c
  449.  ld (hl),a
  450.  add hl,de
  451.  ld a,(hl)
  452.  or c
  453.  ld (hl),a
  454.  add hl,de
  455.  ld a,(hl)
  456.  or c
  457.  ld (hl),a
  458.  jp PBTMainDrawRet     ;go back to main loop
  459. _:
  460.  ld de,7
  461.  set 0,(hl) \ inc hl \ set 7,(hl) \ add hl,de
  462.  set 0,(hl) \ inc hl \ set 7,(hl) \ add hl,de
  463.  set 0,(hl) \ inc hl \ set 7,(hl)
  464.  jp PBTMainDrawRet
  465.  
  466.  
  467. ;=============================================================================
  468. ;BULLET MOVEMENT/COLLISION CODE (cycle 5)
  469. ;
  470.  
  471. PBTShot00Move:    ;standard move by however manieth.
  472. ;E=Y D=X
  473. ;
  474. ;Routine to check for collisions with enemies should go here, but meh.
  475. ;Too lazy right now.
  476. ;
  477.  ld a,-3
  478.  add a,e
  479.  bit 7,a
  480.  jp nz,PBTDestroy
  481.  ld e,a
  482.  push de
  483.  pop de
  484.  jp PBTMainMoveRet
Advertisement
Add Comment
Please, Sign In to add comment