Advertisement
Min_65816

zero2

Jun 20th, 2021
46
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. hirom ; (should be s-dd1)
  2.  
  3. !transfer_buff = $f4
  4.  
  5. org $c02874
  6. l_c02874:
  7. phb
  8. pei ($16)
  9. sep #$20
  10. rep #$10
  11. lda $16
  12. pha : plb
  13. sta $01 : sta $1e
  14. lda #$54 : sta $00
  15. lda $12 : sta $02
  16. lda #$6b : sta $03
  17. lda #$ff : sta $1d
  18.  
  19. ldy $10
  20. rep #$21
  21. stz $10
  22. lda [$10],y : iny : iny
  23. adc $14
  24. tyx
  25. ldy $14
  26. sta $14
  27. lda #$00ff
  28. jsl $800000
  29. sep #$20
  30. stz $01 : lda $16 : inc : sta $03
  31. phx
  32. tyx
  33. ply
  34. sep #$21
  35.  
  36. .flag
  37. lda [$10],y : iny
  38. rol
  39. sta $02
  40. bcs .lz
  41.  
  42. .uncomp
  43. lda [$10],y : iny
  44. sta $0000,x : inx
  45.  
  46. .next
  47. cpx $14
  48. bcs .end
  49.  
  50. - asl $02
  51. bcc .uncomp
  52. beq .flag
  53.  
  54. .lz
  55. lda [$10],y : iny : sta $1c
  56. lda [$10],y : iny : dec : sta $00
  57. sty $16
  58. txy
  59. rep #$21
  60. txa
  61. adc $1c
  62. tax
  63. lda $00
  64. sep #$20
  65. bit $03
  66. bmi +
  67. mvn $7e7e
  68. tyx
  69. ldy $16
  70. cpx $14
  71. bcc -
  72. bra .end
  73.  
  74. + mvn $7f7f
  75. tyx
  76. ldy $16
  77. cpx $14
  78. bcc -
  79.  
  80. .end
  81. plx : stx $16
  82. plb
  83. tdc
  84. sep #$30
  85. rtl
  86.  
  87. ; (other codes)
  88.  
  89. l_c0b60b_clear_center:
  90. lda #$0080
  91. ldx #$7e
  92. - sta $c440,x
  93. dex #2
  94. bpl -
  95. rts
  96.  
  97. l_c0b60b_update:
  98. clc : lda $10 : adc #$8c10 : sta $10
  99. tdc : adc $12 : sta $12 : tay
  100. lda $14 : adc #$02eb : sta $14
  101. bcc +
  102. inc $16
  103. + asl #6
  104. clc
  105. adc $10
  106. sta $18
  107. rts
  108.  
  109. l_c0b60b_post:
  110. ldx #$7e : phx : plb
  111. rep #$31
  112. ldx #$c4c0
  113. ldy #$c3c0
  114. -- txa
  115. adc #$0010
  116. sta $18
  117. - lda $0000,x : eor #$00ff : sta $0000,y
  118. lda $0010,x : eor #$00ff : sta $0010,y
  119. lda $0020,x : eor #$00ff : sta $0020,y
  120. lda $0030,x : eor #$00ff : sta $0030,y
  121. lda $0040,x : eor #$00ff : sta $0040,y
  122. lda $0050,x : eor #$00ff : sta $0050,y
  123. lda $0060,x : eor #$00ff : sta $0060,y
  124. lda $0070,x : eor #$00ff : sta $0070,y
  125. inx #2 : iny #2
  126. cpx $18
  127. bcc -
  128. tya : sbc #$0090 : tay
  129. txa : adc #$006f : tax
  130. cpx #$f4c0
  131. bcc --
  132. rts
  133. warnpc $c02a0c
  134. padbyte $00 : pad $c02a0c
  135.  
  136. org $c0b60b
  137. l_c0b60b:
  138. php
  139. phb
  140. phd
  141. sep #$10
  142. rep #$20
  143. pea $807e
  144. plb
  145. jsr l_c0b60b_clear_center
  146. plb
  147. stz $10 : sta $12
  148. stz $14 : stz $16
  149. lda #$c4c0 : sta $2181
  150. ldx #$00 : stx $2183
  151. ldx #$60
  152.  
  153. .loop
  154. phx
  155. jsr l_c0b60b_update
  156. lda $10
  157. ldx #$00
  158. cpx $16
  159. bne .one
  160. bra +
  161.  
  162. - iny
  163. cmp $18
  164. beq .next
  165.  
  166. +
  167. -- sty $2180 : stx $2180
  168. clc
  169. adc $14
  170. bcs -
  171. cmp $18
  172. bne --
  173. bra .next
  174.  
  175. - iny
  176. cmp $18
  177. beq .next
  178.  
  179. .one
  180. -- sty $2180 : stx $2180
  181. iny
  182. clc
  183. adc $14
  184. bcs -
  185. cmp $18
  186. bne --
  187.  
  188. .next
  189. plx
  190. dex
  191. bne .loop
  192.  
  193. .end
  194. jsr l_c0b60b_post
  195. pld
  196. plb
  197. plp
  198. rtl
  199. warnpc $c0b674
  200. padbyte $00 : pad $c0b674
  201.  
  202. ; ------------------------
  203.  
  204. org $c70000
  205. l_c70000:
  206. jmp l_c70006
  207.  
  208. l_c70003:
  209. jmp l_c7005b
  210.  
  211. l_c70006:
  212. php
  213. rep #$30
  214. phx
  215. phy
  216. phb
  217. pea $8787 : plb : plb
  218. phd
  219. lda #$0000 : tcd : tay
  220. sep #$20
  221. jsr l_c701a5
  222.  
  223. ldy #$204a
  224. lda #$c7
  225. jsr l_c701f9
  226. jsr l_c701dd ; set jump
  227.  
  228. jsr .sub
  229. jsr .sub
  230. jsr .sub
  231.  
  232. stz $80
  233. stz $81
  234. stz $82
  235.  
  236. pld
  237. plb
  238. ply
  239. plx
  240. plp
  241. rtl
  242.  
  243. .sub
  244. lda $2143
  245. - cmp $2143
  246. beq -
  247. rts
  248.  
  249. l_c701a5:
  250. php
  251. phx
  252. sep #$20
  253. lda #$ff : sta $2140
  254. ldx #$bbaa
  255. - cpx $2140
  256. bne -
  257. lda #$cc : sta $8c
  258. plx
  259. plp
  260. rts
  261.  
  262. l_c701c1:
  263. phx
  264. sep #$20
  265. lda #$fc : sta $2140
  266. ldx #$bbaa
  267. - cpx $2140
  268. bne -
  269. plx
  270. rts
  271.  
  272. l_c701dd:
  273. phx
  274. ldx #$0400 : stx $2142
  275. stz $2141
  276. lda $8c : sta $2140
  277. plx
  278. rts
  279.  
  280. l_c701f9:
  281. php
  282. phb
  283. phx
  284. pha
  285. plb
  286. lda $8c
  287. phd
  288. pea $2100
  289. pld
  290.  
  291. .begin
  292. ldx $0000,y
  293. beq .end
  294. jsr transfer_ipl
  295. bra .begin
  296.  
  297. .end
  298. pld
  299. sta $8c
  300. plx
  301. plb
  302. plp
  303. rts
  304.  
  305. transfer_ipl:
  306. xba
  307. lda $0002,y : sta $42
  308. lda $0003,y : sta $43
  309. iny #4
  310. xba
  311.  
  312. .begin
  313. sta $41
  314. sta $40
  315. - cmp $40
  316. bne -
  317.  
  318. tdc : xba
  319. lda $0000,y : iny
  320. xba
  321. bra .loop
  322.  
  323. - xba
  324. lda $0000,y : iny
  325. xba
  326. -- cmp $40
  327. bne --
  328. inc
  329.  
  330. .loop
  331. rep #$20
  332. sta $40
  333. sep #$20
  334. dex
  335. bne -
  336.  
  337. - cmp $40
  338. bne -
  339.  
  340. inc : inc
  341. bne +
  342. inc
  343. + rts
  344.  
  345. l_c7005b:
  346. php
  347. rep #$30
  348. phx
  349. phy
  350. tsx
  351. txy
  352. ldx #$1f9f ; (avoid stack overflow)
  353. txs
  354. phy
  355. phb
  356. pea $8787 : plb : plb
  357. phd
  358. pea $0000 : pld
  359. pei (!transfer_buff)
  360. pei (!transfer_buff+2)
  361. pei (!transfer_buff+4)
  362. pei (!transfer_buff+6)
  363. pei (!transfer_buff+8)
  364. pei (!transfer_buff+10)
  365. pha
  366. tdc : tay
  367. lda #$1500 : sta $8a
  368. stz $8e
  369. pla
  370. and #$00ff
  371. beq ++
  372.  
  373. asl
  374. tax
  375. lda $c71000,x
  376. tax
  377. jsr .sync
  378. jsr transfer_1_begin
  379. jsr transfer_2_begin
  380. rep #$20 : lda $8a : sta $7e2000
  381. sep #$20 : lda $8e : sta $7e2002
  382. bra +
  383.  
  384. ++ jsr l_c701c1
  385. rep #$20 : lda $7e2000 : sta $8a
  386. sep #$20 : lda $7e2002 : sta $8e
  387.  
  388. + stz $8f
  389. - tdc
  390. lda $8f
  391. cmp #$03
  392. beq .end
  393.  
  394. rep #$20
  395. tax
  396. sep #$20
  397. lda $80,x
  398. beq .end
  399.  
  400. rep #$20
  401. asl
  402. tax
  403. lda $c71078,x
  404. tax
  405.  
  406. jsr transfer_3_begin
  407. tdc : lda $8f
  408. tay
  409. clc
  410. lda $c70000,x : inx
  411. phx
  412. tyx
  413. adc $c704dd,x
  414. plx
  415. sta $8d
  416.  
  417. jsr transfer_2_begin
  418. inc $8f
  419. bra -
  420.  
  421. .end
  422. jsr .finalize
  423. plx : stx.b !transfer_buff+10
  424. plx : stx.b !transfer_buff+8
  425. plx : stx.b !transfer_buff+6
  426. plx : stx.b !transfer_buff+4
  427. plx : stx.b !transfer_buff+2
  428. plx : stx.b !transfer_buff+0
  429. pld
  430. plb
  431. plx
  432. txs
  433. ply
  434. plx
  435. plp
  436. rtl
  437.  
  438. .finalize
  439. stz $2141 : lda #$ff : sta $2140
  440. - lda $2140
  441. bne -
  442. stz $2140
  443. rts
  444.  
  445. .sync
  446. php
  447. phx
  448. sep #$20
  449. lda #$ff : sta $2140
  450. ldx #$bbaa
  451. - cpx $2140
  452. bne -
  453. plx
  454. plp
  455. rts
  456.  
  457. transfer_1:
  458. - inx
  459. jsr transfer_1_1
  460.  
  461. .begin
  462. rep #$20
  463. lda $c70000,x : inx : inx
  464. tay
  465. sep #$20
  466. lda $c70000,x
  467. bne -
  468.  
  469. inx
  470. lda $c70000,x : inx
  471. sta $8d
  472. rts
  473.  
  474. transfer_1_1:
  475. php
  476. phb
  477. pha : plb
  478. phx
  479. sta.b !transfer_buff+2
  480.  
  481. .begin
  482. ldx $0000,y
  483. beq .end
  484. phx
  485. rep #$21
  486. tya
  487. adc #$0004 : sta.b !transfer_buff
  488. adc $01,s
  489. tax
  490. lda $0002,y
  491. tay
  492. txa
  493. plx
  494. pha
  495. sep #$20
  496. jsr fast_transfer
  497. ply
  498. bra .begin
  499.  
  500. .end
  501. plx
  502. plb
  503. plp
  504. rts
  505.  
  506. transfer_3:
  507. - inx
  508. jsr transfer_3_1
  509.  
  510. .begin
  511. rep #$20
  512. lda $c70000,x : inx : inx
  513. tay
  514. sep #$20
  515. lda $c70000,x
  516. bne -
  517.  
  518. inx
  519. rts
  520.  
  521. transfer_3_1:
  522. phb
  523. phx
  524. pha : plb : sta.b !transfer_buff+2
  525.  
  526. tdc
  527. lda $8f
  528. rep #$20
  529. asl
  530. tax
  531. lda $c704cd,x
  532. tax
  533.  
  534. .begin
  535. rep #$21
  536. lda $0000,y
  537. beq .end
  538. iny #4 : sty.b !transfer_buff
  539. txy
  540. tax
  541. adc.b !transfer_buff
  542. pha
  543. sep #$20
  544. jsr fast_transfer
  545. ply
  546. bra .begin
  547.  
  548. .end
  549. sep #$20
  550. plx
  551. plb
  552. rts
  553.  
  554. transfer_2:
  555. - sta $86
  556. asl
  557. adc $86
  558. phx
  559. tax
  560. lda $c71c75,x
  561. tay
  562. sep #$20
  563. lda $c71c77,x
  564. phb
  565. pha : plb
  566. jsr .sub1
  567. jsr .sub2
  568. jsr .sub3
  569. inc $8d
  570. inc $8e
  571. plb
  572. plx
  573. inx #2
  574.  
  575. .begin
  576. rep #$20
  577. lda $c70000,x
  578. bne -
  579. sep #$20
  580. rts
  581.  
  582. .sub1
  583. pei ($88)
  584. tdc : lda $8d
  585. rep #$20
  586. sta $86
  587. asl
  588. adc $86
  589. asl
  590. adc #$1208
  591. tax
  592. lda $0000,y : sta $84
  593. lda $0002,y : sta $86
  594. lda $0004,y : sta $88
  595. tya
  596. adc #$0006
  597. pha
  598. sep #$20
  599. lda $8e : sta $84
  600.  
  601. ldy #$0084 : sty.b !transfer_buff
  602. lda #$87 : sta.b !transfer_buff+2
  603. txy
  604. ldx #$0006
  605. jsr fast_transfer
  606.  
  607. ply
  608. plx : stx $88
  609. rts
  610.  
  611. .sub2
  612. rep #$30
  613. sec : lda $0002,y : sbc $0000,y
  614. clc : adc $8a
  615. sta $86
  616. lda $8a : sta $84
  617. iny #4
  618. phy
  619.  
  620. lda $8e
  621. and #$00ff
  622. asl #2
  623. adc #$1400
  624. tay
  625.  
  626. sep #$20
  627. ldx #$0084 : stx.b !transfer_buff
  628. lda #$87 : sta.b !transfer_buff+2
  629. ldx #$0004
  630. jsr fast_transfer
  631.  
  632. ply
  633. rts
  634.  
  635. .sub3
  636. rep #$31
  637. lda $0000,y : iny #4 : sty.b !transfer_buff
  638. sta $86 : pha
  639. adc $8a
  640. ldy $8a
  641. sta $8a
  642. sep #$20
  643. phb : pla : sta.b !transfer_buff+2
  644. plx
  645. jsr fast_transfer
  646. rts
  647.  
  648. fast_transfer:
  649. php
  650. phb
  651. sep #$20
  652. lda #$87 : pha : plb
  653. jsr send_size_and_dest
  654. sep #$10
  655. stz.b !transfer_buff+11
  656. ldy.b !transfer_buff+10
  657. bra +
  658.  
  659. .begin
  660. jsr confirm
  661. + jsr read_bytes
  662. bra ++
  663.  
  664. .loop
  665. jsr read_bytes
  666. dey #2
  667. - cpy $2140
  668. bne -
  669. ++ stx $2141 : sta $2142 : xba : sta $2143
  670.  
  671. + ldy.b !transfer_buff+10 : sty $2140
  672. bne .loop
  673.  
  674. rep #$20
  675. inc.b !transfer_buff+1 : inc.b !transfer_buff+4 : inc.b !transfer_buff+7
  676. sep #$20
  677. dec.b !transfer_buff+9
  678. bne .begin
  679.  
  680. jsr confirm
  681. plb
  682. plp
  683. rts
  684.  
  685. send_size_and_dest:
  686. stx $4204
  687. lda #$03 : sta $4206
  688. xba : xba : nop : nop
  689. rep #$20
  690. lda $4216
  691. lsr
  692. adc $4214
  693. tax
  694. sep #$20
  695. sta $2142 : eor #$ff : inc : sta.b !transfer_buff+10
  696. xba
  697. sta $2143 : sta.b !transfer_buff+9
  698. lda #$ff : sta $2141
  699. dec : sta $2140
  700. inc
  701. - cmp $2141
  702. bne -
  703.  
  704. rep #$20
  705. txa
  706. dec
  707. ora #$ff00
  708. pha
  709. tya
  710. adc $01,s
  711. sep #$20
  712. sta $2142 : xba : sta $2143
  713. lda.b !transfer_buff+10 : sta $2140
  714. stz $2141
  715. - lda $2141
  716. bne -
  717.  
  718. txa
  719. beq +
  720. inc.b !transfer_buff+9
  721. + rep #$20
  722. ldy.b !transfer_buff+2
  723. lda.b !transfer_buff
  724. sec
  725. adc $01,s
  726. sta.b !transfer_buff
  727. bcs +
  728. dey
  729. + sep #$20
  730. tya
  731. sta.b !transfer_buff+2
  732. rep #$21
  733. pla
  734. txa : adc.b !transfer_buff : sta.b !transfer_buff+3
  735. sep #$20
  736. tdc : adc.b !transfer_buff+2 : sta.b !transfer_buff+5
  737.  
  738. rep #$21
  739. txa : adc.b !transfer_buff+3 : sta.b !transfer_buff+6
  740. sep #$20
  741. tdc : adc.b !transfer_buff+5 : sta.b !transfer_buff+8
  742.  
  743. rts
  744.  
  745. confirm:
  746. inc.b !transfer_buff+11
  747. lda.b !transfer_buff+11
  748. - cmp $2141
  749. bne -
  750. rts
  751.  
  752. read_bytes:
  753. lda [!transfer_buff+0],y : tax
  754. lda [!transfer_buff+6],y : xba
  755. lda [!transfer_buff+3],y
  756. iny : sty.b !transfer_buff+10
  757. rts
  758. warnpc $c704cd
  759. padbyte $00 : pad $c704cd
  760.  
  761. org $c72afb
  762. arch spc700
  763. base $0ea5
  764. mov y, #$bb
  765. mov a, #$aa
  766. movw $f4, ya
  767. mov a, #$fe
  768. - cmp a, $f4
  769. bne -
  770.  
  771. .begin
  772. movw ya, $f6
  773. mov $f5, #$ff
  774. movw $14, ya ; size
  775. eor a, #$ff : inc a : inc a
  776. mov x, a
  777. - mov a, $f5
  778. bne -
  779.  
  780. movw ya, $f6
  781. mov $f4, x
  782. mov $f5, #$00
  783. mov .st1+1, a
  784. mov .st1+2, y
  785. addw ya, $14
  786. mov .st2+1, a
  787. mov .st2+2, y
  788. addw ya, $14
  789. mov .st3+1, a
  790. mov .st3+2, y
  791. mov y, #$00
  792. - cmp x, $f4
  793. bne -
  794. dec x
  795.  
  796. -- mov a, $f5 ; 3 bytes / 40 cycles
  797.  
  798. .st1
  799. mov $0000+X, a
  800. mov a, $f6
  801.  
  802. .st2
  803. mov $0000+X, a
  804. mov a, $f7
  805. mov $f4, x
  806.  
  807. .st3
  808. mov $0000+X, a
  809. inc x
  810. - cmp x, $f4
  811. bne --
  812.  
  813. cmp x, #$00
  814. bne -
  815.  
  816. inc y : mov $f5, y
  817. inc .st1+2
  818. inc .st2+2
  819. inc .st3+2
  820. mov a, $f4
  821.  
  822. - dec a
  823. beq --
  824. + mov a, $f4
  825. bpl -
  826.  
  827. + inc a
  828. bne .begin
  829.  
  830. mov $f4, #$00
  831. - mov a, $f4
  832. bmi -
  833. mov $f1, #$31
  834. ret
  835. warnpc $c72b84
  836. padbyte $00 : pad $c72b84
Advertisement
RAW Paste Data Copied
Advertisement