Advertisement
Guest User

PIC-PONG.ASM V3.01

a guest
Dec 19th, 2012
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 58.14 KB | None | 0 0
  1. ;---------------------------------------------------;
  2. ;---------------------------------------------------;
  3. ; Name: PIC-PONG.ASM ;
  4. ; Use: DTI's version of the PONG game ;
  5. ;---------------------------------------------------;
  6. ; Copyright: (C)2012 DTI ;
  7. ; Dysfunctional Technologies, Inc. ;
  8. ; All Rights Reserved ;
  9. ;---------------------------------------------------;
  10. ; Author: Timothy S. Carlson ;
  11. ; Dysfunctional Technologies, Inc. ;
  12. ; Date: December 18, 2012 ;
  13. ; Version: V3.01 ;
  14. ;---------------------------------------------------;
  15. ; VERSION LOG: ;
  16. ; V3.00: Modified characters, character placement, ;
  17. ; and field to look more like the real PONG ;
  18. ; V3.01: Renamed to PIC-PONG ;
  19. ; Added 64x224 mode for copyright message ;
  20. ; Added piezo speaker for sounds ;
  21. ; Added ball 'slow-down' method ;
  22. ; Added special dot to field as court divider;
  23. ;---------------------------------------------------;
  24. ;---------------------------------------------------;
  25. #DEFINE _PONG.ASM_ ;
  26. #DEFINE _MAIN_MODULE_ ;
  27. ;---------------------------------------------------;
  28. #DEFINE _USE_THUMBSTICKS_ ;
  29. ;---------------------------------------------------;
  30.  
  31. ;---------------------------------------------------;
  32. ; Includes ;
  33. ;---------------------------------------------------;
  34. #INCLUDE Common.INC ;
  35. ;---------------------------------------------------;
  36.  
  37. ;---------------------------------------------------;
  38. ; Macros ;
  39. ;---------------------------------------------------;
  40. DELAY MACRO DTIME ;
  41. MOVLW DTIME ;
  42. MOVWF DTemp ;
  43. DECFSZ DTemp, F ;
  44. GOTO $-1 ;
  45. ENDM ;
  46. ;
  47. DO_BIT MACRO THISBIT, NOPS ;
  48. BTFSC INDF1, THISBIT ;
  49. BSF PORTA, VIDEO_0_BIT ;
  50. BTFSS INDF1, THISBIT ;
  51. BCF PORTA, VIDEO_0_BIT ;
  52. #IF NOPS > 0 ;
  53. NOP ;
  54. #ENDIF ;
  55. #IF NOPS > 1 ;
  56. NOP ;
  57. #ENDIF ;
  58. #IF NOPS > 2 ;
  59. NOP ;
  60. #ENDIF ;
  61. #IF NOPS > 3 ;
  62. NOP ;
  63. #ENDIF ;
  64. #IF NOPS > 4 ;
  65. NOP ;
  66. #ENDIF ;
  67. #IF NOPS > 5 ;
  68. NOP ;
  69. #ENDIF ;
  70. #IF NOPS > 6 ;
  71. NOP ;
  72. #ENDIF ;
  73. #IF NOPS > 7 ;
  74. NOP ;
  75. #ENDIF ;
  76. #IF NOPS > 8 ;
  77. NOP ;
  78. #ENDIF ;
  79. #IF NOPS > 9 ;
  80. NOP ;
  81. #ENDIF ;
  82. ENDM ;
  83. ;
  84. SET_SIGNAL MACRO COLOR ;
  85. MOVFW PORTA ;
  86. ANDLW VIDEO_MASK ;
  87. IORLW COLOR ;
  88. MOVWF PORTA ;
  89. ENDM ;
  90. ;
  91. NEG_SYNC_4US MACRO ;
  92. ;-----------------------------------------------;
  93. ; 4us Negative Sync Generation ;
  94. ;-----------------------------------------------;
  95. SET_SIGNAL COLOR_SYNC ;
  96. BTFSS System_Status, BUZZ_BIT ;
  97. GOTO $+16 ;
  98. DECFSZ Buzz_Count, F ;
  99. GOTO $+16 ;
  100. MOVFW Buzz_Reload ;
  101. MOVWF Buzz_Count ;
  102. BANKSEL TRISA ;
  103. BCF TRISA, RBUTT_BIT ; Set as OUTPUT
  104. BANKSEL MEMORY ;
  105. MOVLW RBUTT ;
  106. XORWF PORTA, F ;
  107. DECFSZ Buzz_Dur_LO, F ;
  108. GOTO $+16 ;
  109. DECFSZ Buzz_Dur_HI, F ;
  110. GOTO $+16 ;
  111. BCF System_Status, BUZZ_BIT ;
  112. GOTO $+15 ;
  113. NOP ;
  114. NOP ;
  115. NOP ;
  116. NOP ;
  117. NOP ;
  118. NOP ;
  119. NOP ;
  120. NOP ;
  121. NOP ;
  122. NOP ;
  123. NOP ;
  124. NOP ;
  125. NOP ;
  126. NOP ;
  127. MOVLW 3 ;
  128. MOVWF DTemp ;
  129. DECFSZ DTemp, F ;
  130. GOTO $-1 ;
  131. NOP ;
  132. ;-----------------------------------------------;
  133. ENDM ;
  134. ;
  135. NEG_SYNC_2US MACRO ;
  136. ;-----------------------------------------------;
  137. ; 2us Negative Sync Generation ;
  138. ;-----------------------------------------------;
  139. SET_SIGNAL COLOR_SYNC ;
  140. MOVLW 3 ;
  141. MOVWF DTemp ;
  142. DECFSZ DTemp, F ;
  143. GOTO $-1 ;
  144. NOP ;
  145. NOP ;
  146. ;-----------------------------------------------;
  147. ENDM ;
  148. ;
  149. POS_SYNC_2US MACRO ;
  150. ;-----------------------------------------------;
  151. ; 2us Positive Sync Generation ;
  152. ;-----------------------------------------------;
  153. SET_SIGNAL COLOR_BLACK ;
  154. MOVLW 3 ;
  155. MOVWF DTemp ;
  156. DECFSZ DTemp, F ;
  157. GOTO $-1 ;
  158. NOP ;
  159. NOP ;
  160. ;-----------------------------------------------;
  161. ENDM ;
  162. ;
  163. ;---------------------------------------------------;
  164.  
  165. ;---------------------------------------------------;
  166. ; Defines ;
  167. ;---------------------------------------------------;
  168. #IFDEF _USE_THUMBSTICKS_ ;
  169. #DEFINE RJOY H'01' ;
  170. #DEFINE RJOY_BIT 0 ; GPIO 0 - PIN 7
  171. #DEFINE RBUTT H'02' ;
  172. #DEFINE RBUTT_BIT 1 ; GPIO 1 - PIN 6
  173. #DEFINE LJOY H'04' ;
  174. #DEFINE LJOY_BIT 2 ; GPIO 2 - PIN 5
  175. #DEFINE LBUTT H'08' ;
  176. #DEFINE LBUTT_BIT 3 ; GPIO 3 - PIN 4
  177. #ELSE ;!_USE_THUMBSTICKS_ ;
  178. #DEFINE RBUTT_1 H'01' ;
  179. #DEFINE RBUTT_1_BIT 0 ; GPIO 0 - PIN 7
  180. #DEFINE RBUTT_2 H'02' ;
  181. #DEFINE RBUTT_2_BIT 1 ; GPIO 1 - PIN 6
  182. #DEFINE LBUTT_2 H'04' ;
  183. #DEFINE LBUTT_2_BIT 2 ; GPIO 2 - PIN 5
  184. #DEFINE LBUTT_1 H'08' ;
  185. #DEFINE LBUTT_1_BIT 3 ; GPIO 3 - PIN 4
  186. #ENDIF ;_USE_THUMBSTICKS_ ;
  187. ;
  188. #DEFINE VIDEO_1 H'10' ; 1K ohm
  189. #DEFINE VIDEO_1_BIT 4 ; GPIO 5 - PIN 2
  190. #DEFINE VIDEO_0 H'20' ; 470 ohm
  191. #DEFINE VIDEO_0_BIT 5 ; GPIO 4 - PIN 3
  192. ;
  193. #DEFINE VIDEO_MASK H'CF' ;
  194. #DEFINE COLOR_WHITE (VIDEO_0 + VIDEO_1) ;
  195. #DEFINE COLOR_BLACK VIDEO_1 ;
  196. #DEFINE COLOR_SYNC 0 ;
  197. #DEFINE MAX_LINES 56 ;
  198. #DEFINE DRAW_BALL_BIT 0 ;
  199. #DEFINE MAX_BALL_WAIT 3 ;
  200. #DEFINE VIDEO_BUFFER_START H'2010' ;
  201. #DEFINE LEFT_SCORE_START H'01' ;
  202. #DEFINE RIGHT_SCORE_START H'02' ;
  203. #DEFINE LEFT_PADDLE_START H'00' ;
  204. #DEFINE LEFT_PADDLE_BIT H'40' ;
  205. #DEFINE LEFT_PADDLE_MASK H'BF' ;
  206. #DEFINE RIGHT_PADDLE_START H'03' ;
  207. #DEFINE RIGHT_PADDLE_BIT H'02' ;
  208. #DEFINE RIGHT_PADDLE_MASK H'FD' ;
  209. #DEFINE PADDLE_SIZE 8 ;
  210. ;---------------------------------------------------;
  211.  
  212. ;---------------------------------------------------;
  213. USER_DATA_1 UDATA H'020' ;
  214. ;---------------------------------------------------;
  215. Ball_X res 1 ; 20
  216. Ball_Y res 1 ; 21
  217. Ball_Dir_X res 1 ; 22
  218. Ball_Dir_Y res 1 ; 23
  219. Paddle_1_Y res 1 ; 24
  220. Paddle_2_Y res 1 ; 25
  221. Score_1 res 1 ; 26
  222. Score_2 res 1 ; 27
  223. Ball_Wait res 1 ; 29
  224. #DEFINE BUZZ H'01' ;
  225. #DEFINE BUZZ_BIT 0 ;
  226. System_Status res 1 ; 28
  227. ;---------------------------------------------------;
  228. USER_DATA_2 UDATA_SHR H'070' ;
  229. ;---------------------------------------------------;
  230. Temp1 res 1 ; 70
  231. Temp2 res 1 ; 71
  232. DTemp res 1 ; 72
  233. DL_Count res 1 ; 73
  234. Line_Data res 4 ; 74-77
  235. Byte_Count res 1 ; 78
  236. Repeat_Count res 1 ; 79
  237. Buzz_Count res 1 ; 7A
  238. Buzz_Reload res 1 ; 7B
  239. Buzz_Dur_HI res 1 ; 7C
  240. Buzz_Dur_LO res 1 ; 7D
  241. ;---------------------------------------------------;
  242.  
  243. ;---------------------------------------------------;
  244. RESET_VECT CODE H'000' ;
  245. ;---------------------------------------------------;
  246. CALL _Initialize_System ;
  247. NOP ;
  248. NOP ;
  249. GOTO _MAIN ;
  250. ;---------------------------------------------------;
  251.  
  252. ;---------------------------------------------------;
  253. USER_CODE_1 CODE H'004' ;
  254. ;---------------------------------------------------;
  255. _MAIN: ;
  256. ;---------------------------------------------------;
  257. GOTO _Next_Frame ;
  258. ;---------------------------------------------------;
  259.  
  260. ;---------------------------------------------------;
  261. _Next_Frame: ;
  262. ;---------------------------------------------------;
  263. ;-----------------------------------------------;
  264. ; VERTICAL SYNC PULSE Time ;
  265. ; This consists of 5 blank half lines, ;
  266. ; 4 inverted half lines, and 5 more blank half ;
  267. ; lines. This totals 12 full lines of 64us each.;
  268. ; --------------------------------------------- ;
  269. ; NOTE: Timing is CRITICAL for a nice, clean ;
  270. ; display. If you notice the top part of the ;
  271. ; display is skewed or "tearing", your timings ;
  272. ; are wrong and need to be adjusted. Make sure ;
  273. ; you haven't inadvertently dropped a half frame;
  274. ;-----------------------------------------------;
  275. CALL _Blank_Half_Line ;
  276. CALL _Blank_Half_Line ;
  277. CALL _Blank_Half_Line ;
  278. CALL _Blank_Half_Line ;
  279. ;
  280. CALL _Transition_Half_Line ;
  281. ;
  282. CALL _Inverted_Half_Line ;
  283. CALL _Inverted_Half_Line ;
  284. CALL _Special_Half_Line ;
  285. ;
  286. CALL _Blank_Half_Line ;
  287. CALL _Blank_Half_Line ;
  288. CALL _Blank_Half_Line ;
  289. CALL _Blank_Half_Line ;
  290. CALL _Blank_Half_Line ;
  291. NOP ;
  292. ;-----------------------------------------------;
  293. ;
  294. ;-----------------------------------------------;
  295. ; Just a bunch of BLANK LINES, so that the video;
  296. ; data doesn't start in the non-display area. ;
  297. ; Add or remove lines to adjust the verticle ;
  298. ; position of your video. If you add or remove, ;
  299. ; make sure to adjust the number of BLANK LINES ;
  300. ; which follow the data lines, so that the video;
  301. ; stays at 60hz ;
  302. ;-----------------------------------------------;
  303. MOVLW 15 ;
  304. MOVWF Temp1 ;
  305. CALL _Blank_Line ;
  306. DECFSZ Temp1, F ;
  307. GOTO $-2 ;
  308. ;
  309. ;-----------------------------------------------;
  310. ; 224 Data lines ;
  311. ;-----------------------------------------------;
  312. CALL _Data_Lines ;
  313. ;
  314. ;-----------------------------------------------;
  315. ; Another 8 blank lines. So, to summarize: ;
  316. ; (note - I needed four full 60us frames for ;
  317. ; the game processing (paddles, ball, scores, ;
  318. ; etc.), so I moved four blank line there for ;
  319. ; use for those routines) ;
  320. ; ;
  321. ; - 12 VERTICAL SYNC lines ;
  322. ; - 21 BLANK LINES ;
  323. ; - 224 DATA LINES ;
  324. ; - 8 BLANK LINES ;
  325. ; ;
  326. ; For a total of 265 lines at 64us each, or ;
  327. ; 16.96ms, or approximately 60hz. 16.6666ms ;
  328. ; would be _perfect_. ;
  329. ;-----------------------------------------------;
  330. ; MOVLW 2 ;
  331. ; MOVWF Temp1 ;
  332. ; CALL _Blank_Line ;
  333. ; DECFSZ Temp1, F ;
  334. ; GOTO $-2 ;
  335. ;-----------------------------------------------;
  336. ;
  337. CALL _Copyright ; 8 blank FULL line (60us)
  338. NOP ;
  339. NOP ;
  340. ;-----------------------------------------------;
  341. ; All of the game processing is done here, the ;
  342. ; last 4 full 60us blank lines ;
  343. ;-----------------------------------------------;
  344. CALL _Update_Ball ; 1 blank FULL line (60us)
  345. CALL _Update_Scores ; 1 blank FULL line (60us)
  346. CALL _Update_Paddle_1 ; 1 blank FULL line (60us)
  347. CALL _Update_Paddle_2 ; 1 blank FULL line (60us)
  348. ;-----------------------------------------------;
  349. ;
  350. GOTO _Next_Frame ;
  351. ;---------------------------------------------------;
  352. ;
  353. ;---------------------------------------------------;
  354. _Data_Lines: ;
  355. ;---------------------------------------------------;
  356. ; NOP ;
  357. ;-----------------------------------------------;
  358. ; 4us Negative Sync Generation ;
  359. ;-----------------------------------------------;
  360. NEG_SYNC_4US ;
  361. ;-----------------------------------------------;
  362. SET_SIGNAL COLOR_BLACK ;
  363. ;
  364. MOVLW MAX_LINES ;
  365. MOVWF DL_Count ;
  366. ;
  367. MOVLW LOW VIDEO_BUFFER_START ;
  368. MOVWF FSR1L ;
  369. MOVLW HIGH VIDEO_BUFFER_START ;
  370. MOVWF FSR1H ;
  371. ;
  372. ;-----------------------------------------------;
  373. ; 60us Black Signal Generation ;
  374. ;-----------------------------------------------;
  375. DELAY 155 ;
  376. NOP ;
  377. NOP ;
  378. ;-----------------------------------------------;
  379. ;
  380. _DL_Next_Line: ;
  381. MOVLW 4 ;
  382. MOVWF Repeat_Count ;
  383. _DL_Repeat_Line: ;
  384. ;-----------------------------------------------;
  385. ; 4us Negative Sync Generation ;
  386. ;-----------------------------------------------;
  387. NEG_SYNC_4US ;
  388. ;-----------------------------------------------;
  389. ;
  390. ;-----------------------------------------------;
  391. ; Front porch - shifts the data to the right ;
  392. ; and hopefully centers it on the screen ;
  393. ; --------------------------------------------- ;
  394. ; NOTE: a DELAY 12 produces a nice 7.5us porch ;
  395. ;-----------------------------------------------;
  396. SET_SIGNAL COLOR_BLACK ;
  397. DELAY 15 ;
  398. ;-----------------------------------------------;
  399. ;
  400. MOVLW H'FC' ;
  401. ANDWF FSR1L, F ;
  402. MOVLW 4 ;
  403. MOVWF Byte_Count ;
  404. _DL_Next_Byte: ;
  405. ;-----------------------------------------------;
  406. ; This is where the 32 bits of data are actually;
  407. ; send out over the video signal ;
  408. ;-----------------------------------------------;
  409. DO_BIT 7, 8 ;
  410. DO_BIT 6, 8 ;
  411. DO_BIT 5, 8 ;
  412. DO_BIT 4, 8 ;
  413. DO_BIT 3, 8 ;
  414. DO_BIT 2, 8 ;
  415. DO_BIT 1, 8 ;
  416. DO_BIT 0, 1 ;
  417. ;
  418. ADDFSR FSR1, 1 ;
  419. ;
  420. _DL_Center_Line: ;
  421. MOVLW 3 ;
  422. XORWF Byte_Count, W ;
  423. BTFSS STATUS, Z ;
  424. GOTO _DL_Center_Line_Done ;
  425. NOP ;
  426. NOP ;
  427. NOP ;
  428. BCF PORTA, VIDEO_0_BIT ;
  429. NOP ;
  430. NOP ;
  431. NOP ;
  432. NOP ;
  433. BSF PORTA, VIDEO_0_BIT ;
  434. NOP ;
  435. BCF PORTA, VIDEO_0_BIT ;
  436. _DL_Center_Line_Done: ;
  437. ;
  438. DECFSZ Byte_Count, F ;
  439. GOTO _DL_Next_Byte ;
  440. DECF FSR1L, F ;
  441. ;-----------------------------------------------;
  442. ;
  443. ;-----------------------------------------------;
  444. ; Back porch - between this and the front porch,;
  445. ; this 'frames' the video on your TV (hopefully);
  446. ; --------------------------------------------- ;
  447. ; NOTE: a DELAY 8 (plus a NOP) produces a ;
  448. ; nice 4.5us back porch, which fleshes out the ;
  449. ; data line to 60us ;
  450. ;-----------------------------------------------;
  451. SET_SIGNAL COLOR_BLACK ;
  452. DELAY 2 ;
  453. NOP ;
  454. NOP ;
  455. ; NOP ;
  456. ; NOP ;
  457. ; NOP ;
  458. ; NOP ;
  459. ; NOP ;
  460. ;-----------------------------------------------;
  461. ;
  462. DECFSZ Repeat_Count, F ;
  463. GOTO $+2 ;
  464. GOTO _DL_Next_Data ;
  465. ; NOP ;
  466. ; NOP ;
  467. ; NOP ;
  468. NOP ;
  469. NOP ;
  470. NOP ;
  471. NOP ;
  472. NOP ;
  473. NOP ;
  474. GOTO _DL_Repeat_Line ;
  475. ;
  476. ;-----------------------------------------------;
  477. ; 224 lines of information to transmit ;
  478. ; so the screen size is 32x224. But we transmit ;
  479. ; each line 4 times, so it's actually 32x56 ;
  480. ;-----------------------------------------------;
  481. _DL_Next_Data: ;
  482. NOP ;
  483. ADDFSR FSR1, 1 ;
  484. DECFSZ DL_Count, F ;
  485. GOTO _DL_Next_Line ;
  486. ;
  487. NOP ;
  488. NOP ;
  489. NOP ;
  490. NOP ;
  491. ;-----------------------------------------------;
  492. ; 4us Negative Sync Generation ;
  493. ;-----------------------------------------------;
  494. NEG_SYNC_4US ;
  495. ;-----------------------------------------------;
  496. ;
  497. ;-----------------------------------------------;
  498. ; 60us Black Signal Generation ;
  499. ;-----------------------------------------------;
  500. SET_SIGNAL COLOR_BLACK ;
  501. DELAY 154 ;
  502. NOP ;
  503. ;
  504. ;-----------------------------------------------;
  505. ;
  506. RETURN ;
  507. ;---------------------------------------------------;
  508.  
  509. ;---------------------------------------------------;
  510. _Blank_Line: ;
  511. ;---------------------------------------------------;
  512. ;-----------------------------------------------;
  513. ; 4us Negative Sync Generation ;
  514. ;-----------------------------------------------;
  515. NEG_SYNC_4US ;
  516. ;-----------------------------------------------;
  517. ;
  518. ;-----------------------------------------------;
  519. ; 60us Black Signal Generation ;
  520. ;-----------------------------------------------;
  521. SET_SIGNAL COLOR_BLACK ;
  522. DELAY 156 ;
  523. ;-----------------------------------------------;
  524. ;
  525. RETURN ;
  526. ;---------------------------------------------------;
  527.  
  528. ;---------------------------------------------------;
  529. _Transition_Half_Line: ;
  530. ;---------------------------------------------------;
  531. NOP ;
  532. NOP ;
  533. NOP ;
  534. ;-----------------------------------------------;
  535. ; 2us Negative Sync Generation ;
  536. ;-----------------------------------------------;
  537. NEG_SYNC_2US ;
  538. ;-----------------------------------------------;
  539. ;
  540. ;-----------------------------------------------;
  541. ; 30us Blank Signal Generation ;
  542. ;-----------------------------------------------;
  543. SET_SIGNAL COLOR_BLACK ;
  544. DELAY 73 ;
  545. ;-----------------------------------------------;
  546. ;
  547. ;-----------------------------------------------;
  548. ; 2s Positive Sync Generation ;
  549. ;-----------------------------------------------;
  550. POS_SYNC_2US ;
  551. ;-----------------------------------------------;
  552. ;
  553. ;-----------------------------------------------;
  554. ; 30us Inverted Signal Generation ;
  555. ;-----------------------------------------------;
  556. SET_SIGNAL COLOR_SYNC ;
  557. DELAY 77 ;
  558. ;-----------------------------------------------;
  559. ;
  560. RETURN ;
  561. ;---------------------------------------------------;
  562.  
  563. ;---------------------------------------------------;
  564. _Inverted_Half_Line: ;
  565. ;---------------------------------------------------;
  566. ;-----------------------------------------------;
  567. ; 2s Positive Sync Generation ;
  568. ;-----------------------------------------------;
  569. POS_SYNC_2US ;
  570. ;-----------------------------------------------;
  571. ;
  572. ;-----------------------------------------------;
  573. ; 30us Inverted Signal Generation ;
  574. ;-----------------------------------------------;
  575. SET_SIGNAL COLOR_SYNC ;
  576. DELAY 77 ;
  577. ;-----------------------------------------------;
  578. ;
  579. RETURN ;
  580. ;---------------------------------------------------;
  581.  
  582. ;---------------------------------------------------;
  583. _Special_Half_Line: ;
  584. ;---------------------------------------------------;
  585. ;-----------------------------------------------;
  586. ; 2us Positive Sync Generation ;
  587. ;-----------------------------------------------;
  588. POS_SYNC_2US ;
  589. ;-----------------------------------------------;
  590. ;
  591. ;-----------------------------------------------;
  592. ; 30us Sync Signal Generation (SPECIAL) ;
  593. ;-----------------------------------------------;
  594. SET_SIGNAL COLOR_SYNC ;
  595. ;
  596. BANKSEL OPTION_REG ;
  597. BSF OPTION_REG, PSA ;
  598. BANKSEL TMR0 ;
  599. CLRF TMR0 ;
  600. ;
  601. BANKSEL TRISA ;
  602. BCF TRISA, 2 ;
  603. BANKSEL PORTA ;
  604. BCF PORTA, 2 ;
  605. NOP ;
  606. BSF PORTA, 2 ;
  607. BANKSEL TRISA ;
  608. BSF TRISA, 2 ;
  609. BANKSEL MEMORY ;
  610. ;
  611. DELAY 74 ;
  612. ;-----------------------------------------------;
  613. ;
  614. ;-----------------------------------------------;
  615. ; 2us Positive Sync Generation (SPECIAL) ;
  616. ;-----------------------------------------------;
  617. SET_SIGNAL COLOR_BLACK ;
  618. DELAY 2 ;
  619. NOP ;
  620. ;-----------------------------------------------;
  621. ;
  622. RETURN ;
  623. ;---------------------------------------------------;
  624.  
  625. ;---------------------------------------------------;
  626. _Blank_Half_Line: ;
  627. ;---------------------------------------------------;
  628. NOP ;
  629. NOP ;
  630. NOP ;
  631. ;-----------------------------------------------;
  632. ; 2us Negative Sync Generation ;
  633. ;-----------------------------------------------;
  634. NEG_SYNC_2US ;
  635. ;-----------------------------------------------;
  636. ;
  637. ;-----------------------------------------------;
  638. ; 30us Blank Signal Generation ;
  639. ;-----------------------------------------------;
  640. SET_SIGNAL COLOR_BLACK ;
  641. DELAY 76 ;
  642. ;-----------------------------------------------;
  643. ;
  644. RETURN ;
  645. ;---------------------------------------------------;
  646.  
  647. ;---------------------------------------------------;
  648. _Update_Scores: ;
  649. ;---------------------------------------------------;
  650. ; This will retrieve the character font information ;
  651. ; from program memory and display the two scores ;
  652. ; at the top left and top right of the screen. ;
  653. ; NOTE: This is a FULL BLANK LINE routine ;
  654. ; (around 19us to display each score). ;
  655. ;---------------------------------------------------;
  656. ;-----------------------------------------------;
  657. ; 4us Negative Sync Generation ;
  658. ;-----------------------------------------------;
  659. NEG_SYNC_4US ;
  660. ;-----------------------------------------------;
  661. ;
  662. ;-----------------------------------------------;
  663. ; 60us Blank Signal Generation ;
  664. ; But with lots of calculations going on ;
  665. ;-----------------------------------------------;
  666. SET_SIGNAL COLOR_BLACK ;
  667. ;
  668. BANKSEL OPTION_REG ;
  669. BCF OPTION_REG, PSA ;
  670. BANKSEL TMR0 ;
  671. CLRF TMR0 ;
  672. ;
  673. _US_Draw_Score1: ;
  674. MOVLW LOW VIDEO_BUFFER_START + LEFT_SCORE_START;
  675. MOVWF FSR1L ;
  676. MOVLW HIGH VIDEO_BUFFER_START ;
  677. MOVWF FSR1H ;
  678. ;
  679. CLRW ;
  680. MOVWI 0[INDF1] ;
  681. MOVWI 4[INDF1] ;
  682. MOVWI 8[INDF1] ;
  683. MOVWI 12[INDF1] ;
  684. MOVWI 16[INDF1] ;
  685. ;
  686. SWAPF Score_1, W ;
  687. ANDLW H'0F' ;
  688. MOVWF Temp1 ;
  689. ADDWF Temp1, F ;
  690. ADDWF Temp1, F ;
  691. ADDWF Temp1, F ;
  692. ADDWF Temp1, F ;
  693. ;
  694. MOVLW LOW VIDEO_BUFFER_START + LEFT_SCORE_START;
  695. MOVWF FSR1L ;
  696. MOVLW HIGH VIDEO_BUFFER_START ;
  697. MOVWF FSR1H ;
  698. ;
  699. MOVLW 5 ;
  700. MOVWF Temp2 ;
  701. _US1_Draw_Left_Char: ;
  702. MOVLP HIGH CHARACTER_TABLE ;
  703. MOVFW Temp1 ;
  704. ADDLW LOW CHARACTER_TABLE ;
  705. BTFSC STATUS, C ;
  706. INCF PCLATH, F ;
  707. CALLW ;
  708. MOVWF DTemp ;
  709. RRF DTemp, W ;
  710. ANDLW H'70' ;
  711. MOVWF INDF1 ;
  712. ADDFSR FSR1, 4 ;
  713. INCF Temp1, F ;
  714. DECFSZ Temp2, F ;
  715. GOTO _US1_Draw_Left_Char ;
  716. ;
  717. MOVFW Score_1 ;
  718. ANDLW H'0F' ;
  719. MOVWF Temp1 ;
  720. ADDWF Temp1, F ;
  721. ADDWF Temp1, F ;
  722. ADDWF Temp1, F ;
  723. ADDWF Temp1, F ;
  724. ;
  725. MOVLW LOW VIDEO_BUFFER_START + LEFT_SCORE_START;
  726. MOVWF FSR1L ;
  727. MOVLW HIGH VIDEO_BUFFER_START ;
  728. MOVWF FSR1H ;
  729. ;
  730. MOVLW 5 ;
  731. MOVWF Temp2 ;
  732. _US1_Draw_Right_Char: ;
  733. MOVLP HIGH CHARACTER_TABLE ;
  734. MOVFW Temp1 ;
  735. ADDLW LOW CHARACTER_TABLE ;
  736. BTFSC STATUS, C ;
  737. INCF PCLATH, F ;
  738. CALLW ;
  739. MOVWF DTemp ;
  740. RRF DTemp, W ;
  741. ANDLW H'07' ;
  742. MOVWF DTemp ;
  743. MOVFW INDF1 ;
  744. IORWF DTemp, W ;
  745. MOVWF INDF1 ;
  746. ADDFSR FSR1, 4 ;
  747. INCF Temp1, F ;
  748. DECFSZ Temp2, F ;
  749. GOTO _US1_Draw_Right_Char ;
  750. ;
  751. _US_Draw_Score2: ;
  752. MOVLW LOW VIDEO_BUFFER_START + RIGHT_SCORE_START;
  753. MOVWF FSR1L ;
  754. MOVLW HIGH VIDEO_BUFFER_START ;
  755. MOVWF FSR1H ;
  756. ;
  757. CLRW ;
  758. MOVWI 0[INDF1] ;
  759. MOVWI 4[INDF1] ;
  760. MOVWI 8[INDF1] ;
  761. MOVWI 12[INDF1] ;
  762. MOVWI 16[INDF1] ;
  763. ;
  764. SWAPF Score_2, W ;
  765. ANDLW H'0F' ;
  766. MOVWF Temp1 ;
  767. ADDWF Temp1, F ;
  768. ADDWF Temp1, F ;
  769. ADDWF Temp1, F ;
  770. ADDWF Temp1, F ;
  771. ;
  772. MOVLW LOW VIDEO_BUFFER_START + RIGHT_SCORE_START;
  773. MOVWF FSR1L ;
  774. MOVLW HIGH VIDEO_BUFFER_START ;
  775. MOVWF FSR1H ;
  776. ;
  777. MOVLW 5 ;
  778. MOVWF Temp2 ;
  779. _US2_Draw_Left_Char: ;
  780. MOVLP HIGH CHARACTER_TABLE ;
  781. MOVFW Temp1 ;
  782. ADDLW LOW CHARACTER_TABLE ;
  783. BTFSC STATUS, C ;
  784. INCF PCLATH, F ;
  785. CALLW ;
  786. ANDLW H'E0' ;
  787. MOVWF DTemp ;
  788. MOVWF INDF1 ;
  789. ADDFSR FSR1, 4 ;
  790. INCF Temp1, F ;
  791. DECFSZ Temp2, F ;
  792. GOTO _US2_Draw_Left_Char ;
  793. ;
  794. MOVFW Score_2 ;
  795. ANDLW H'0F' ;
  796. MOVWF Temp1 ;
  797. ADDWF Temp1, F ;
  798. ADDWF Temp1, F ;
  799. ADDWF Temp1, F ;
  800. ADDWF Temp1, F ;
  801. ;
  802. MOVLW LOW VIDEO_BUFFER_START + RIGHT_SCORE_START;
  803. MOVWF FSR1L ;
  804. MOVLW HIGH VIDEO_BUFFER_START ;
  805. MOVWF FSR1H ;
  806. ;
  807. MOVLW 5 ;
  808. MOVWF Temp2 ;
  809. _US2_Draw_Right_Char: ;
  810. MOVLP HIGH CHARACTER_TABLE ;
  811. MOVFW Temp1 ;
  812. ADDLW LOW CHARACTER_TABLE ;
  813. BTFSC STATUS, C ;
  814. INCF PCLATH, F ;
  815. CALLW ;
  816. ANDLW H'0E' ;
  817. MOVWF DTemp ;
  818. MOVFW INDF1 ;
  819. IORWF DTemp, W ;
  820. MOVWF INDF1 ;
  821. ADDFSR FSR1, 4 ;
  822. INCF Temp1, F ;
  823. DECFSZ Temp2, F ;
  824. GOTO _US2_Draw_Right_Char ;
  825. ;
  826. NOP ;
  827. MOVFW TMR0 ;
  828. SUBLW 227 ;
  829. BTFSC STATUS, C ;
  830. GOTO $-3 ;
  831. NOP ;
  832. NOP ;
  833. NOP ;
  834. NOP ;
  835. ;
  836. RETURN ;
  837. ;---------------------------------------------------;
  838.  
  839. ;---------------------------------------------------;
  840. _Update_Paddle_1: ;
  841. ;---------------------------------------------------;
  842. ; NOTE: This is a SINGLE FULL blank line routine - ;
  843. ; about 28us. It fits comfortably in a 60us window. ;
  844. ;---------------------------------------------------;
  845. NOP ;
  846. ;-----------------------------------------------;
  847. ; 4us Negative Sync Generation ;
  848. ;-----------------------------------------------;
  849. NEG_SYNC_4US ;
  850. ;-----------------------------------------------;
  851. ;
  852. ;-----------------------------------------------;
  853. ; 60us Blank Signal Generation ;
  854. ; But with lots of calculations going on ;
  855. ;-----------------------------------------------;
  856. SET_SIGNAL COLOR_BLACK ;
  857. ;
  858. BANKSEL OPTION_REG ;
  859. BCF OPTION_REG, PSA ;
  860. BANKSEL TMR0 ;
  861. CLRF TMR0 ;
  862. ;
  863. _UP1_Clear_Paddle: ;
  864. MOVFW Paddle_1_Y ;
  865. ADDWF Paddle_1_Y, W ;
  866. ADDWF Paddle_1_Y, W ;
  867. ADDWF Paddle_1_Y, W ;
  868. ADDLW LOW VIDEO_BUFFER_START + LEFT_PADDLE_START;
  869. MOVWF FSR1L ;
  870. MOVLW HIGH VIDEO_BUFFER_START ;
  871. MOVWF FSR1H ;
  872. MOVIW 0[INDF1] ;
  873. ANDLW LEFT_PADDLE_MASK ;
  874. MOVWI 0[INDF1] ;
  875. MOVIW 4[INDF1] ;
  876. ANDLW LEFT_PADDLE_MASK ;
  877. MOVWI 4[INDF1] ;
  878. MOVIW 8[INDF1] ;
  879. ANDLW LEFT_PADDLE_MASK ;
  880. MOVWI 8[INDF1] ;
  881. MOVIW 12[INDF1] ;
  882. ANDLW LEFT_PADDLE_MASK ;
  883. MOVWI 12[INDF1] ;
  884. MOVIW 16[INDF1] ;
  885. ANDLW LEFT_PADDLE_MASK ;
  886. MOVWI 16[INDF1] ;
  887. MOVIW 20[INDF1] ;
  888. ANDLW LEFT_PADDLE_MASK ;
  889. MOVWI 20[INDF1] ;
  890. MOVIW 24[INDF1] ;
  891. ANDLW LEFT_PADDLE_MASK ;
  892. MOVWI 24[INDF1] ;
  893. MOVIW 28[INDF1] ;
  894. ANDLW LEFT_PADDLE_MASK ;
  895. MOVWI 28[INDF1] ;
  896. ;
  897. #IFDEF _USE_THUMBSTICKS_ ;
  898. _UP1_Update: ;
  899. ;-----------------------------------------------;
  900. ; ADC Magic (Channel 0) ;
  901. ;-----------------------------------------------;
  902. BANKSEL ADCON1 ;
  903. MOVLW H'60' ; Left Justified
  904. MOVWF ADCON1 ; FOSC/64, VREF
  905. MOVLW B'00001011' ; AN2, ADC GO, ADC On
  906. MOVWF ADCON0 ;
  907. BTFSC ADCON0, GO ; Wait for conversion
  908. GOTO $-1 ;
  909. MOVFW ADRESH ; Get result
  910. BANKSEL MEMORY ;
  911. ;-----------------------------------------------;
  912. ;
  913. MOVWF Temp1 ;
  914. MOVLW H'60' ;
  915. SUBWF Temp1, W ;
  916. BTFSS STATUS, C ;
  917. DECF Paddle_1_Y, F ;
  918. MOVLW H'9F' ;
  919. SUBWF Temp1, W ;
  920. BTFSC STATUS, C ;
  921. INCF Paddle_1_Y, F ;
  922. BTFSC Paddle_1_Y, MSB ;
  923. CLRF Paddle_1_Y ;
  924. MOVLW 48 ;
  925. SUBWF Paddle_1_Y, W ;
  926. BTFSS STATUS, C ;
  927. GOTO _UP1_Update_Done ;
  928. MOVLW 48 ;
  929. MOVWF Paddle_1_Y ;
  930. _UP1_Update_Done: ;
  931. #ELSE ;!_USE_THUMBSTICKS_ ;
  932. _UP1_Check_Up: ;
  933. CLRW ;
  934. XORWF Paddle_1_Y, W ;
  935. BTFSC STATUS, Z ;
  936. GOTO _UP1_Check_Down ;
  937. BTFSS PORTA, LBUTT_1_BIT ;
  938. DECF Paddle_1_Y, F ;
  939. _UP1_Check_Down: ;
  940. MOVLW 48 ;
  941. XORWF Paddle_1_Y, W ;
  942. BTFSC STATUS, Z ;
  943. GOTO _UP1_Draw_Paddle ;
  944. BTFSS PORTA, LBUTT_2_BIT ;
  945. INCF Paddle_1_Y, F ;
  946. #ENDIF ;_USE_THUMBSTICKS_ ;
  947. ;
  948. _UP1_Draw_Paddle: ;
  949. MOVFW Paddle_1_Y ;
  950. ADDWF Paddle_1_Y, W ;
  951. ADDWF Paddle_1_Y, W ;
  952. ADDWF Paddle_1_Y, W ;
  953. ADDLW LOW VIDEO_BUFFER_START + LEFT_PADDLE_START;
  954. MOVWF FSR1L ;
  955. MOVLW HIGH VIDEO_BUFFER_START ;
  956. MOVWF FSR1H ;
  957. MOVIW 0[INDF1] ;
  958. IORLW LEFT_PADDLE_BIT ;
  959. MOVWI 0[INDF1] ;
  960. MOVIW 4[INDF1] ;
  961. IORLW LEFT_PADDLE_BIT ;
  962. MOVWI 4[INDF1] ;
  963. MOVIW 8[INDF1] ;
  964. IORLW LEFT_PADDLE_BIT ;
  965. MOVWI 8[INDF1] ;
  966. MOVIW 12[INDF1] ;
  967. IORLW LEFT_PADDLE_BIT ;
  968. MOVWI 12[INDF1] ;
  969. MOVIW 16[INDF1] ;
  970. IORLW LEFT_PADDLE_BIT ;
  971. MOVWI 16[INDF1] ;
  972. MOVIW 20[INDF1] ;
  973. IORLW LEFT_PADDLE_BIT ;
  974. MOVWI 20[INDF1] ;
  975. MOVIW 24[INDF1] ;
  976. IORLW LEFT_PADDLE_BIT ;
  977. MOVWI 24[INDF1] ;
  978. MOVIW 28[INDF1] ;
  979. IORLW LEFT_PADDLE_BIT ;
  980. MOVWI 28[INDF1] ;
  981. ;
  982. MOVFW TMR0 ;
  983. SUBLW 228 ;
  984. BTFSC STATUS, C ;
  985. GOTO $-3 ;
  986. NOP ;
  987. NOP ;
  988. NOP ;
  989. ;
  990. RETURN ;
  991. ;---------------------------------------------------;
  992.  
  993. ;---------------------------------------------------;
  994. _Update_Paddle_2: ;
  995. ;---------------------------------------------------;
  996. ; NOTE: This is a SINGLE FULL blank line routine - ;
  997. ; about 28us. It fits comfortably in a 60us window. ;
  998. ;---------------------------------------------------;
  999. ;-----------------------------------------------;
  1000. ; 4us Negative Sync Generation ;
  1001. ;-----------------------------------------------;
  1002. NEG_SYNC_4US ;
  1003. ;-----------------------------------------------;
  1004. ;
  1005. ;-----------------------------------------------;
  1006. ; 60us Blank Signal Generation ;
  1007. ; But with lots of calculations going on ;
  1008. ;-----------------------------------------------;
  1009. SET_SIGNAL COLOR_BLACK ;
  1010. ;
  1011. BANKSEL OPTION_REG ;
  1012. BCF OPTION_REG, PSA ;
  1013. BANKSEL TMR0 ;
  1014. CLRF TMR0 ;
  1015. ;
  1016. _UP2_Clear_Paddle: ;
  1017. MOVFW Paddle_2_Y ;
  1018. ADDWF Paddle_2_Y, W ;
  1019. ADDWF Paddle_2_Y, W ;
  1020. ADDWF Paddle_2_Y, W ;
  1021. ADDLW LOW VIDEO_BUFFER_START + RIGHT_PADDLE_START;
  1022. MOVWF FSR1L ;
  1023. MOVLW HIGH VIDEO_BUFFER_START ;
  1024. MOVWF FSR1H ;
  1025. MOVIW 0[INDF1] ;
  1026. ANDLW RIGHT_PADDLE_MASK ;
  1027. MOVWI 0[INDF1] ;
  1028. MOVIW 4[INDF1] ;
  1029. ANDLW RIGHT_PADDLE_MASK ;
  1030. MOVWI 4[INDF1] ;
  1031. MOVIW 8[INDF1] ;
  1032. ANDLW RIGHT_PADDLE_MASK ;
  1033. MOVWI 8[INDF1] ;
  1034. MOVIW 12[INDF1] ;
  1035. ANDLW RIGHT_PADDLE_MASK ;
  1036. MOVWI 12[INDF1] ;
  1037. MOVIW 16[INDF1] ;
  1038. ANDLW RIGHT_PADDLE_MASK ;
  1039. MOVWI 16[INDF1] ;
  1040. MOVIW 20[INDF1] ;
  1041. ANDLW RIGHT_PADDLE_MASK ;
  1042. MOVWI 20[INDF1] ;
  1043. MOVIW 24[INDF1] ;
  1044. ANDLW RIGHT_PADDLE_MASK ;
  1045. MOVWI 24[INDF1] ;
  1046. MOVIW 28[INDF1] ;
  1047. ANDLW RIGHT_PADDLE_MASK ;
  1048. MOVWI 28[INDF1] ;
  1049. ;
  1050. #IFDEF _USE_THUMBSTICKS_ ;
  1051. _UP2_Update: ;
  1052. ;-----------------------------------------------;
  1053. ; ADC Magic (Channel 0) ;
  1054. ;-----------------------------------------------;
  1055. BANKSEL ADCON1 ;
  1056. MOVLW H'60' ; Left Justified
  1057. MOVWF ADCON1 ; FOSC/64, VREF
  1058. MOVLW B'00000011' ; AN0, ADC GO, ADC On
  1059. MOVWF ADCON0 ;
  1060. BTFSC ADCON0, GO ; Wait for conversion
  1061. GOTO $-1 ;
  1062. MOVFW ADRESH ; Get result
  1063. BANKSEL MEMORY ;
  1064. ;-----------------------------------------------;
  1065. ;
  1066. MOVWF Temp1 ;
  1067. MOVLW H'60' ;
  1068. SUBWF Temp1, W ;
  1069. BTFSS STATUS, C ;
  1070. DECF Paddle_2_Y, F ;
  1071. MOVLW H'9F' ;
  1072. SUBWF Temp1, W ;
  1073. BTFSC STATUS, C ;
  1074. INCF Paddle_2_Y, F ;
  1075. BTFSC Paddle_2_Y, MSB ;
  1076. CLRF Paddle_2_Y ;
  1077. MOVLW 48 ;
  1078. SUBWF Paddle_2_Y, W ;
  1079. BTFSS STATUS, C ;
  1080. GOTO _UP2_Update_Done ;
  1081. MOVLW 48 ;
  1082. MOVWF Paddle_2_Y ;
  1083. _UP2_Update_Done: ;
  1084. #ELSE ;!_USE_THUMBSTICKS_ ;
  1085. _UP2_Check_Up: ;
  1086. CLRW ;
  1087. XORWF Paddle_2_Y, W ;
  1088. BTFSC STATUS, Z ;
  1089. GOTO _UP2_Check_Down ;
  1090. BTFSS PORTA, RBUTT_1_BIT ;
  1091. DECF Paddle_2_Y, F ;
  1092. _UP2_Check_Down: ;
  1093. MOVLW 40 ;
  1094. XORWF Paddle_2_Y, W ;
  1095. BTFSC STATUS, Z ;
  1096. GOTO _UP2_Draw_Paddle ;
  1097. BTFSS PORTA, RBUTT_2_BIT ;
  1098. INCF Paddle_2_Y, F ;
  1099. #ENDIF ;_USE_THUMBSTICKS_ ;
  1100. ;
  1101. _UP2_Draw_Paddle: ;
  1102. MOVFW Paddle_2_Y ;
  1103. ADDWF Paddle_2_Y, W ;
  1104. ADDWF Paddle_2_Y, W ;
  1105. ADDWF Paddle_2_Y, W ;
  1106. ADDLW LOW VIDEO_BUFFER_START + RIGHT_PADDLE_START;
  1107. MOVWF FSR1L ;
  1108. MOVLW HIGH VIDEO_BUFFER_START ;
  1109. MOVWF FSR1H ;
  1110. MOVIW 0[INDF1] ;
  1111. IORLW RIGHT_PADDLE_BIT ;
  1112. MOVWI 0[INDF1] ;
  1113. MOVIW 4[INDF1] ;
  1114. IORLW RIGHT_PADDLE_BIT ;
  1115. MOVWI 4[INDF1] ;
  1116. MOVIW 8[INDF1] ;
  1117. IORLW RIGHT_PADDLE_BIT ;
  1118. MOVWI 8[INDF1] ;
  1119. MOVIW 12[INDF1] ;
  1120. IORLW RIGHT_PADDLE_BIT ;
  1121. MOVWI 12[INDF1] ;
  1122. MOVIW 16[INDF1] ;
  1123. IORLW RIGHT_PADDLE_BIT ;
  1124. MOVWI 16[INDF1] ;
  1125. MOVIW 20[INDF1] ;
  1126. IORLW RIGHT_PADDLE_BIT ;
  1127. MOVWI 20[INDF1] ;
  1128. MOVIW 24[INDF1] ;
  1129. IORLW RIGHT_PADDLE_BIT ;
  1130. MOVWI 24[INDF1] ;
  1131. MOVIW 28[INDF1] ;
  1132. IORLW RIGHT_PADDLE_BIT ;
  1133. MOVWI 28[INDF1] ;
  1134. ;
  1135. NOP ;
  1136. MOVFW TMR0 ;
  1137. SUBLW 228 ;
  1138. BTFSC STATUS, C ;
  1139. GOTO $-3 ;
  1140. NOP ;
  1141. NOP ;
  1142. ;
  1143. RETURN ;
  1144. ;---------------------------------------------------;
  1145.  
  1146. ;---------------------------------------------------;
  1147. _Update_Ball: ;
  1148. ;---------------------------------------------------;
  1149. ; NOTE: This is a FULL blank line routine - ;
  1150. ; about 17-18us. It fits comfortably in a 60us ;
  1151. ; window. ;
  1152. ;---------------------------------------------------;
  1153. ;-----------------------------------------------;
  1154. ; 4us Negative Sync Generation ;
  1155. ;-----------------------------------------------;
  1156. NEG_SYNC_4US ;
  1157. ;
  1158. ;-----------------------------------------------;
  1159. ; 60us Blank Signal Generation ;
  1160. ; But with lots of calculations going on ;
  1161. ;-----------------------------------------------;
  1162. SET_SIGNAL COLOR_BLACK ;
  1163. ;
  1164. BANKSEL OPTION_REG ;
  1165. BCF OPTION_REG, PSA ;
  1166. BANKSEL TMR0 ;
  1167. CLRF TMR0 ;
  1168. ;
  1169. _UB_Check_Wait: ;
  1170. DECFSZ Ball_Wait, F ;
  1171. GOTO _UB_Exit ;
  1172. ;
  1173. MOVLW MAX_BALL_WAIT ;
  1174. MOVWF Ball_Wait ;
  1175. ;
  1176. CLRW ;
  1177. XORWF Ball_Dir_X, W ;
  1178. BTFSS STATUS, Z ;
  1179. GOTO _UB_Clear_Ball ;
  1180. CLRW ;
  1181. XORWF Ball_Dir_Y, W ;
  1182. BTFSS STATUS, Z ;
  1183. GOTO _UB_Clear_Ball ;
  1184. ;
  1185. _UB_Check_L_Serve: ;
  1186. BTFSC PORTA, LBUTT_BIT ;
  1187. GOTO _UB_Check_R_Serve ;
  1188. MOVLW 1 ;
  1189. MOVWF Ball_Dir_X ;
  1190. MOVLW 1 ;
  1191. MOVWF Ball_Dir_Y ;
  1192. MOVLW 16 ;
  1193. MOVWF Ball_X ;
  1194. MOVLW 27 ;
  1195. MOVWF Ball_Y ;
  1196. GOTO _UB_Service ;
  1197. _UB_Check_R_Serve: ;
  1198. BANKSEL TRISA ;
  1199. BSF TRISA, RBUTT_BIT ;
  1200. BANKSEL PORTA ;
  1201. BTFSC PORTA, RBUTT_BIT ;
  1202. GOTO _UB_Exit ;
  1203. BANKSEL TRISA ;
  1204. BCF TRISA, RBUTT_BIT ;
  1205. BANKSEL PORTA ;
  1206. MOVLW -1 ;
  1207. MOVWF Ball_Dir_X ;
  1208. MOVLW -1 ;
  1209. MOVWF Ball_Dir_Y ;
  1210. MOVLW 15 ;
  1211. MOVWF Ball_X ;
  1212. MOVLW 27 ;
  1213. MOVWF Ball_Y ;
  1214. _UB_Service: ;
  1215. CALL _Clear_Court ;
  1216. MOVLW H'11' ;
  1217. XORWF Score_1, W ;
  1218. BTFSC STATUS, Z ;
  1219. GOTO $+5 ;
  1220. MOVLW H'11' ;
  1221. XORWF Score_2, W ;
  1222. BTFSS STATUS, Z ;
  1223. GOTO _UB_Draw_Ball ;
  1224. CLRF Score_1 ;
  1225. CLRF Score_2 ;
  1226. GOTO _UB_Draw_Ball ;
  1227. ;
  1228. _UB_Clear_Ball: ;
  1229. MOVFW Ball_Y ;
  1230. ADDWF Ball_Y, W ;
  1231. ADDWF Ball_Y, W ;
  1232. ADDWF Ball_Y, W ;
  1233. ADDLW LOW VIDEO_BUFFER_START ;
  1234. MOVWF FSR1L ;
  1235. RRF Ball_X, W ;
  1236. MOVWF Temp1 ;
  1237. RRF Temp1, F ;
  1238. RRF Temp1, W ;
  1239. ANDLW H'1F' ;
  1240. ADDWF FSR1L, F ;
  1241. MOVLW HIGH VIDEO_BUFFER_START ;
  1242. MOVWF FSR1H ;
  1243. ;
  1244. MOVFW Ball_X ;
  1245. ANDLW H'07' ;
  1246. MOVWF Temp1 ;
  1247. MOVLW H'7F' ;
  1248. MOVWF DTemp ;
  1249. MOVLW 0 ; ;
  1250. XORWF Temp1, W ;
  1251. BTFSC STATUS, Z ;
  1252. GOTO $+5 ;
  1253. DECF Temp1, F ;
  1254. RRF DTemp, F ;
  1255. BSF DTemp, MSB ;
  1256. GOTO $-7 ;
  1257. ;
  1258. MOVFW DTemp ;
  1259. ANDWF INDF1, F ;
  1260. ;
  1261. MOVLW H'04' ;
  1262. ADDWF FSR1L, F ;
  1263. MOVFW DTemp ;
  1264. ANDWF INDF1, F ;
  1265. ;
  1266. _UB_Update_Ball_X: ;
  1267. MOVFW Ball_Dir_X ; Update Ball X Position
  1268. ADDWF Ball_X, F ;
  1269. ;
  1270. _UB_Update_Ball_X_Min: ;
  1271. MOVLW 0 ;
  1272. XORWF Ball_X, W ;
  1273. BTFSS STATUS, Z ;
  1274. GOTO _UB_Update_Ball_X_Max ;
  1275. MOVLW 1 ;
  1276. MOVWF Ball_Dir_X ;
  1277. ;
  1278. INCF Score_2, F ;
  1279. MOVLW 20 ;
  1280. MOVWF Buzz_Count ;
  1281. MOVWF Buzz_Reload ;
  1282. MOVLW H'7F' ;
  1283. MOVWF Buzz_Dur_LO ;
  1284. MOVLW H'01' ;
  1285. MOVWF Buzz_Dur_HI ;
  1286. BSF System_Status, BUZZ_BIT ;
  1287. MOVLW 0 ;
  1288. MOVWF Ball_Dir_X ;
  1289. MOVWF Ball_Dir_Y ;
  1290. MOVLW 15 ;
  1291. MOVWF Ball_X ;
  1292. MOVLW 27 ;
  1293. MOVWF Ball_Y ;
  1294. MOVFW Score_2 ;
  1295. ANDLW H'0F' ;
  1296. XORLW H'0A' ;
  1297. BTFSS STATUS, Z ;
  1298. GOTO _UB_BXMin_Exit ;
  1299. MOVFW Score_2 ;
  1300. ANDLW H'F0' ;
  1301. ADDLW H'10' ;
  1302. MOVWF Score_2 ;
  1303. MOVLW H'A0' ;
  1304. XORWF Score_2, W ;
  1305. BTFSC STATUS, Z ;
  1306. CLRF Score_2 ;
  1307. _UB_BXMin_Exit: ;
  1308. MOVLW H'11' ;
  1309. XORWF Score_2, W ;
  1310. BTFSS STATUS, Z ;
  1311. GOTO _UB_Exit ;
  1312. CALL _Clear_Court ;
  1313. CALL _Draw_Title ;
  1314. GOTO _UB_Exit ;
  1315. ;
  1316. _UB_Update_Ball_X_Max: ;
  1317. MOVLW 31 ;
  1318. XORWF Ball_X, W ;
  1319. BTFSS STATUS, Z ;
  1320. GOTO _UB_Update_Ball_Y ;
  1321. MOVLW -1 ;
  1322. MOVWF Ball_Dir_X ;
  1323. ;
  1324. INCF Score_1, F ;
  1325. MOVLW 20 ;
  1326. MOVWF Buzz_Count ;
  1327. MOVWF Buzz_Reload ;
  1328. MOVLW H'7F' ;
  1329. MOVWF Buzz_Dur_LO ;
  1330. MOVLW H'01' ;
  1331. MOVWF Buzz_Dur_HI ;
  1332. BSF System_Status, BUZZ_BIT ;
  1333. MOVLW 0 ;
  1334. MOVWF Ball_Dir_X ;
  1335. MOVWF Ball_Dir_Y ;
  1336. MOVLW 15 ;
  1337. MOVWF Ball_X ;
  1338. MOVLW 27 ;
  1339. MOVWF Ball_Y ;
  1340. MOVFW Score_1 ;
  1341. ANDLW H'0F' ;
  1342. XORLW H'0A' ;
  1343. BTFSS STATUS, Z ;
  1344. GOTO _UB_BXMax_Exit ;
  1345. MOVFW Score_1 ;
  1346. ANDLW H'F0' ;
  1347. ADDLW H'10' ;
  1348. MOVWF Score_1 ;
  1349. MOVLW H'A0' ;
  1350. XORWF Score_1, W ;
  1351. BTFSC STATUS, Z ;
  1352. CLRF Score_1 ;
  1353. _UB_BXMax_Exit: ;
  1354. MOVLW H'11' ;
  1355. XORWF Score_1, W ;
  1356. BTFSS STATUS, Z ;
  1357. GOTO _UB_Exit ;
  1358. CALL _Clear_Court ;
  1359. CALL _Draw_Title ;
  1360. GOTO _UB_Exit ;
  1361. ;
  1362. _UB_Update_Ball_Y: ;
  1363. MOVFW Ball_Dir_Y ; Update Ball Y Position
  1364. ADDWF Ball_Y, F ;
  1365. ;
  1366. _UB_Update_Ball_Y_Min: ;
  1367. MOVLW 0 ;
  1368. XORWF Ball_Y, W ;
  1369. BTFSS STATUS, Z ;
  1370. GOTO _UB_Update_Ball_Y_Max ;
  1371. MOVLW 1 ;
  1372. MOVWF Ball_Dir_Y ;
  1373. MOVLW 13 ;
  1374. MOVWF Buzz_Count ;
  1375. MOVWF Buzz_Reload ;
  1376. MOVLW H'3F' ;
  1377. MOVWF Buzz_Dur_LO ;
  1378. MOVLW H'01' ;
  1379. MOVWF Buzz_Dur_HI ;
  1380. BSF System_Status, BUZZ_BIT ;
  1381. GOTO _UB_Paddle_Detect ;
  1382. ;
  1383. _UB_Update_Ball_Y_Max: ;
  1384. MOVLW 55 ;
  1385. XORWF Ball_Y, W ;
  1386. BTFSS STATUS, Z ;
  1387. GOTO _UB_Paddle_Detect ;
  1388. MOVLW -1 ;
  1389. MOVWF Ball_Dir_Y ;
  1390. MOVLW 13 ;
  1391. MOVWF Buzz_Count ;
  1392. MOVWF Buzz_Reload ;
  1393. MOVLW H'3F' ;
  1394. MOVWF Buzz_Dur_LO ;
  1395. MOVLW H'01' ;
  1396. MOVWF Buzz_Dur_HI ;
  1397. BSF System_Status, BUZZ_BIT ;
  1398. ;
  1399. _UB_Paddle_Detect: ;
  1400. _UB_Paddle_Detect_Left: ;
  1401. MOVLW -1 ;
  1402. XORWF Ball_Dir_X, W ;
  1403. BTFSS STATUS, Z ;
  1404. GOTO _UB_Paddle_Detect_Right ;
  1405. ;
  1406. MOVLW 2 ;
  1407. XORWF Ball_X, W ;
  1408. BTFSS STATUS, Z ;
  1409. GOTO _UB_Draw_Ball ;
  1410. ;
  1411. MOVFW Paddle_1_Y ;
  1412. SUBWF Ball_Y, W ;
  1413. BTFSS STATUS, C ;
  1414. GOTO _UB_Draw_Ball ;
  1415. MOVFW Paddle_1_Y ;
  1416. ADDLW 8 ;
  1417. SUBWF Ball_Y, W ;
  1418. BTFSC STATUS, C ;
  1419. GOTO _UB_Draw_Ball ;
  1420. MOVLW 1 ;
  1421. MOVWF Ball_Dir_X ;
  1422. MOVLW 15 ;
  1423. MOVWF Buzz_Count ;
  1424. MOVWF Buzz_Reload ;
  1425. MOVLW H'3F' ;
  1426. MOVWF Buzz_Dur_LO ;
  1427. MOVLW H'01' ;
  1428. MOVWF Buzz_Dur_HI ;
  1429. BSF System_Status, BUZZ_BIT ;
  1430. GOTO _UB_Draw_Ball ;
  1431. ;
  1432. _UB_Paddle_Detect_Right: ;
  1433. MOVLW 1 ;
  1434. XORWF Ball_Dir_X, W ;
  1435. BTFSS STATUS, Z ;
  1436. GOTO _UB_Draw_Ball ;
  1437. ;
  1438. MOVLW 29 ;
  1439. XORWF Ball_X, W ;
  1440. BTFSS STATUS, Z ;
  1441. GOTO _UB_Draw_Ball ;
  1442. ;
  1443. MOVFW Paddle_2_Y ;
  1444. SUBWF Ball_Y, W ;
  1445. BTFSS STATUS, C ;
  1446. GOTO _UB_Draw_Ball ;
  1447. MOVFW Paddle_2_Y ;
  1448. ADDLW 8 ;
  1449. SUBWF Ball_Y, W ;
  1450. BTFSC STATUS, C ;
  1451. GOTO _UB_Draw_Ball ;
  1452. MOVLW -1 ;
  1453. MOVWF Ball_Dir_X ;
  1454. MOVLW 15 ;
  1455. MOVWF Buzz_Count ;
  1456. MOVWF Buzz_Reload ;
  1457. MOVLW H'3F' ;
  1458. MOVWF Buzz_Dur_LO ;
  1459. MOVLW H'01' ;
  1460. MOVWF Buzz_Dur_HI ;
  1461. BSF System_Status, BUZZ_BIT ;
  1462. ;
  1463. _UB_Draw_Ball: ;
  1464. MOVFW Ball_Y ;
  1465. ADDWF Ball_Y, W ;
  1466. ADDWF Ball_Y, W ;
  1467. ADDWF Ball_Y, W ;
  1468. ADDLW LOW VIDEO_BUFFER_START ;
  1469. MOVWF FSR1L ;
  1470. RRF Ball_X, W ;
  1471. MOVWF Temp1 ;
  1472. RRF Temp1, F ;
  1473. RRF Temp1, W ;
  1474. ANDLW H'1F' ;
  1475. ADDWF FSR1L, F ;
  1476. MOVLW HIGH VIDEO_BUFFER_START ;
  1477. MOVWF FSR1H ;
  1478. ;
  1479. MOVFW Ball_X ;
  1480. ANDLW H'07' ;
  1481. MOVWF Temp1 ;
  1482. MOVLW H'80' ;
  1483. MOVWF DTemp ;
  1484. MOVLW 0 ; ;
  1485. XORWF Temp1, W ;
  1486. BTFSC STATUS, Z ;
  1487. GOTO $+5 ;
  1488. DECF Temp1, F ;
  1489. RRF DTemp, F ;
  1490. BCF DTemp, MSB ;
  1491. GOTO $-7 ;
  1492. ;
  1493. MOVFW DTemp ;
  1494. IORWF INDF1, F ;
  1495. ;
  1496. MOVLW H'04' ;
  1497. ADDWF FSR1L, F ;
  1498. MOVFW DTemp ;
  1499. IORWF INDF1, F ;
  1500. ;
  1501. _UB_Exit: ;
  1502. BANKSEL TRISA ;
  1503. BSF TRISA, RBUTT_BIT ;
  1504. BANKSEL PORTA ;
  1505. ;
  1506. NOP ;
  1507. MOVFW TMR0 ;
  1508. SUBLW 227 ;
  1509. BTFSC STATUS, C ;
  1510. GOTO $-3 ;
  1511. NOP ;
  1512. ;
  1513. RETURN ;
  1514. ;---------------------------------------------------;
  1515.  
  1516. ;---------------------------------------------------;
  1517. _Initialize_System: ;
  1518. ;---;-----------------------------------------------;
  1519. ; Initialize Hardware ;
  1520. ;-----------------------------------------------;
  1521. BANKSEL OSCCON ;
  1522. MOVLW B'11110000' ; 32Mhz
  1523. MOVWF OSCCON ;
  1524. ;
  1525. BANKSEL OSCSTAT ; Wait for
  1526. IS1:MOVFW OSCSTAT ; high speed
  1527. ANDLW H'79' ; oscillator
  1528. XORLW H'59' ; to be
  1529. BTFSS STATUS, Z ; stable and
  1530. GOTO IS1 ; locked
  1531. ;
  1532. BANKSEL ANSELA ;
  1533. CLRF ANSELA ; ALL I/O as digital
  1534. #IFDEF _USE_THUMBSTICKS_ ;
  1535. BSF ANSELA, LJOY_BIT ;
  1536. BSF ANSELA, RJOY_BIT ;
  1537. #ENDIF ;_USE_THUMBSTICKS_ ;
  1538. ;
  1539. BANKSEL LATA ;
  1540. CLRF LATA ;
  1541. ;
  1542. BANKSEL TRISA ;
  1543. CLRF TRISA ;
  1544. BCF TRISA, VIDEO_0_BIT ; Set as OUTPUT
  1545. BCF TRISA, VIDEO_1_BIT ; Set As OUTPUT
  1546. #IFDEF _USE_THUMBSTICKS_ ;
  1547. BSF TRISA, LJOY_BIT ; Set as INPUT
  1548. BSF TRISA, LBUTT_BIT ; Set as INPUT
  1549. BSF TRISA, RJOY_BIT ; Set as INPUT
  1550. BCF TRISA, RBUTT_BIT ; Set as OUTPUT (PIEZO)
  1551. #ELSE ;!_USE_THUMBSTICKS_ ;
  1552. BSF TRISA, LBUTT_1_BIT ; Set as INPUT
  1553. BSF TRISA, LBUTT_2_BIT ; Set as INPUT
  1554. BSF TRISA, RBUTT_1_BIT ; Set as INPUT
  1555. BSF TRISA, RBUTT_2_BIT ; Set as INPUT
  1556. #ENDIF ;_USE_THUMBSTICKS_ ;
  1557. ;
  1558. BANKSEL PORTA ;
  1559. CLRF PORTA ;
  1560. BCF PORTA, VIDEO_0_BIT ; Set LOW
  1561. BCF PORTA, VIDEO_1_BIT ; Set LOW
  1562. #IFDEF _USE_THUMBSTICKS_ ;
  1563. BSF PORTA, LJOY_BIT ; Set HIGH
  1564. BSF PORTA, LBUTT_BIT ; Set HIGH
  1565. BSF PORTA, RJOY_BIT ; Set HIGH
  1566. BSF PORTA, RBUTT_BIT ; Set HIGH
  1567. #ELSE ;!_USE_THUMBSTICKS_ ;
  1568. BSF PORTA, LBUTT_1_BIT ; Set HIGH
  1569. BSF PORTA, LBUTT_2_BIT ; Set HIGH
  1570. BSF PORTA, RBUTT_1_BIT ; Set HIGH
  1571. BSF PORTA, RBUTT_2_BIT ; Set HIGH
  1572. #ENDIF ;_USE_THUMBSTICKS_ ;
  1573. ;
  1574. BANKSEL INTCON ;
  1575. CLRF INTCON ;
  1576. ;
  1577. BANKSEL OPTION_REG ;
  1578. CLRF OPTION_REG ;
  1579. ;
  1580. ;-----------------------------------------------;
  1581. ; Initialize Timer0 (for counting cycles) ;
  1582. ;-----------------------------------------------;
  1583. BANKSEL OPTION_REG ;
  1584. BCF OPTION_REG, NOT_WPUEN ;
  1585. BCF OPTION_REG, TMR0CS ;
  1586. BCF OPTION_REG, PSA ; prescaler to timer0
  1587. BCF OPTION_REG, PS2 ;
  1588. BCF OPTION_REG, PS1 ; 000 - 250ns
  1589. BCF OPTION_REG, PS0 ;
  1590. BANKSEL TMR0 ;
  1591. CLRF TMR0 ;
  1592. ;
  1593. ;-----------------------------------------------;
  1594. ; Initialize Video Buffer ;
  1595. ; Copy image from EEPROM into buffer memory ;
  1596. ;-----------------------------------------------;
  1597. BANKSEL MEMORY ;
  1598. ; PAGESEL _Clear_Court ;
  1599. CALL _Clear_Court ;
  1600. ; PAGESEL HIGH _Draw_Title ;
  1601. CALL _Draw_Title ;
  1602. ;
  1603. ;-----------------------------------------------;
  1604. ; Initialize Memory ;
  1605. ;-----------------------------------------------;
  1606. BANKSEL MEMORY ;
  1607. CLRF System_Status ;
  1608. ; BSF System_Status, BUZZ_BIT ;
  1609. MOVLW 1 ;
  1610. MOVWF Buzz_Count ;
  1611. MOVWF Buzz_Reload ;
  1612. MOVLW H'FF' ;
  1613. MOVWF Buzz_Dur_LO ;
  1614. MOVLW H'FF' ;
  1615. MOVWF Buzz_Dur_HI ;
  1616. MOVLW MAX_BALL_WAIT ;
  1617. MOVWF Ball_Wait ;
  1618. MOVLW 0 ;
  1619. MOVWF Score_1 ;
  1620. MOVLW 0 ;
  1621. MOVWF Score_2 ;
  1622. MOVLW 20 ;
  1623. MOVWF Paddle_1_Y ;
  1624. MOVLW 20 ;
  1625. MOVWF Paddle_2_Y ;
  1626. MOVLW 15 ;
  1627. MOVWF Ball_X ;
  1628. MOVLW 27 ;
  1629. MOVWF Ball_Y ;
  1630. MOVLW 0 ;
  1631. MOVWF Ball_Dir_X ;
  1632. MOVLW 0 ;
  1633. MOVWF Ball_Dir_Y ;
  1634. ;
  1635. ;-----------------------------------------------;
  1636. ; Initialize Other Subsystems ;
  1637. ;-----------------------------------------------;
  1638. ;
  1639. RETURN ;
  1640. ;---------------------------------------------------;
  1641.  
  1642. ;---------------------------------------------------;
  1643. _Copyright: ;
  1644. ;---------------------------------------------------;
  1645. ;-----------------------------------------------;
  1646. ; Setup ;
  1647. ;-----------------------------------------------;
  1648. MOVLW LOW COPYRIGHT_TABLE ;
  1649. MOVWF FSR1L ;
  1650. MOVLW HIGH COPYRIGHT_TABLE ;
  1651. MOVWF FSR1H ;
  1652. MOVLW 8 ;
  1653. MOVWF Temp1 ;
  1654. ;-----------------------------------------------;
  1655. ;
  1656. ;-----------------------------------------------;
  1657. ; 8 64us Data Line Generation ;
  1658. ;-----------------------------------------------;
  1659. _CR_Next_Line: ;
  1660. NOP ;
  1661. NOP ;
  1662. ;-----------------------------------------------;
  1663. ; 4us Negative Sync Generation ;
  1664. ;-----------------------------------------------;
  1665. NEG_SYNC_4US ;
  1666. ;-----------------------------------------------;
  1667. ;
  1668. ;-----------------------------------------------;
  1669. ; Xus Back Porch (Black Signal) Generation ;
  1670. ;-----------------------------------------------;
  1671. SET_SIGNAL COLOR_BLACK ;
  1672. DELAY 4 ;13 ;17 ;
  1673. NOP ;
  1674. NOP ;
  1675. NOP ;
  1676. ;-----------------------------------------------;
  1677. ;
  1678. ;-----------------------------------------------;
  1679. ; Data Generation ;
  1680. ;-----------------------------------------------;
  1681. DO_BIT 7, 1 ;
  1682. DO_BIT 6, 1 ;
  1683. DO_BIT 5, 1 ;
  1684. DO_BIT 4, 1 ;
  1685. DO_BIT 3, 1 ;
  1686. DO_BIT 2, 1 ;
  1687. DO_BIT 1, 1 ;
  1688. DO_BIT 0, 0 ;
  1689. ADDFSR FSR1, 1 ;
  1690. DO_BIT 7, 1 ;
  1691. DO_BIT 6, 1 ;
  1692. DO_BIT 5, 1 ;
  1693. DO_BIT 4, 1 ;
  1694. DO_BIT 3, 1 ;
  1695. DO_BIT 2, 1 ;
  1696. DO_BIT 1, 1 ;
  1697. DO_BIT 0, 0 ;
  1698. ADDFSR FSR1, 1 ;
  1699. DO_BIT 7, 1 ;
  1700. DO_BIT 6, 1 ;
  1701. DO_BIT 5, 1 ;
  1702. DO_BIT 4, 1 ;
  1703. DO_BIT 3, 1 ;
  1704. DO_BIT 2, 1 ;
  1705. DO_BIT 1, 1 ;
  1706. DO_BIT 0, 0 ;
  1707. ADDFSR FSR1, 1 ;
  1708. DO_BIT 7, 1 ;
  1709. DO_BIT 6, 1 ;
  1710. DO_BIT 5, 1 ;
  1711. DO_BIT 4, 1 ;
  1712. DO_BIT 3, 1 ;
  1713. DO_BIT 2, 1 ;
  1714. DO_BIT 1, 1 ;
  1715. DO_BIT 0, 0 ;
  1716. ADDFSR FSR1, 1 ;
  1717. DO_BIT 7, 1 ;
  1718. DO_BIT 6, 1 ;
  1719. DO_BIT 5, 1 ;
  1720. DO_BIT 4, 1 ;
  1721. DO_BIT 3, 1 ;
  1722. DO_BIT 2, 1 ;
  1723. DO_BIT 1, 1 ;
  1724. DO_BIT 0, 0 ;
  1725. ADDFSR FSR1, 1 ;
  1726. DO_BIT 7, 1 ;
  1727. DO_BIT 6, 1 ;
  1728. DO_BIT 5, 1 ;
  1729. DO_BIT 4, 1 ;
  1730. DO_BIT 3, 1 ;
  1731. DO_BIT 2, 1 ;
  1732. DO_BIT 1, 1 ;
  1733. DO_BIT 0, 0 ;
  1734. ADDFSR FSR1, 1 ;
  1735. DO_BIT 7, 1 ;
  1736. DO_BIT 6, 1 ;
  1737. DO_BIT 5, 1 ;
  1738. DO_BIT 4, 1 ;
  1739. DO_BIT 3, 1 ;
  1740. DO_BIT 2, 1 ;
  1741. DO_BIT 1, 1 ;
  1742. DO_BIT 0, 0 ;
  1743. ADDFSR FSR1, 1 ;
  1744. DO_BIT 7, 1 ;
  1745. DO_BIT 6, 1 ;
  1746. DO_BIT 5, 1 ;
  1747. DO_BIT 4, 1 ;
  1748. DO_BIT 3, 1 ;
  1749. DO_BIT 2, 1 ;
  1750. DO_BIT 1, 1 ;
  1751. DO_BIT 0, 0 ;
  1752. ADDFSR FSR1, 1 ;
  1753. ;-----------------------------------------------;
  1754. ;
  1755. ;-----------------------------------------------;
  1756. ; Xus Front Porch (Black Signal) Generation ;
  1757. ;-----------------------------------------------;
  1758. SET_SIGNAL COLOR_BLACK ;
  1759. ; DELAY 1 ;2 ;6 ;
  1760. ; NOP ;
  1761. ; NOP ;
  1762. ; NOP ;
  1763. ; NOP ;
  1764. ; NOP ;
  1765. ;-----------------------------------------------;
  1766. ;
  1767. DECFSZ Temp1, F ;
  1768. GOTO $+2 ;
  1769. RETURN ;
  1770. NOP ;
  1771. GOTO _CR_Next_Line ;
  1772. ;---------------------------------------------------;
  1773.  
  1774. ;---------------------------------------------------;
  1775. _Clear_Court: ;
  1776. ;---------------------------------------------------;
  1777. MOVLW LOW VIDEO_BUFFER_START ;
  1778. MOVWF FSR1L ;
  1779. MOVLW HIGH VIDEO_BUFFER_START ;
  1780. MOVWF FSR1H ;
  1781. MOVLW MAX_LINES * 4 ;
  1782. MOVWF Temp1 ; 224 bytes
  1783. _CC_IVB: ;
  1784. MOVLW H'00' ;
  1785. MOVWF INDF1 ;
  1786. INCF FSR1L, F ;
  1787. DECFSZ Temp1, F ;
  1788. GOTO _CC_IVB ;
  1789. RETURN ;
  1790. ;---------------------------------------------------;
  1791.  
  1792. ;---------------------------------------------------;
  1793. _Draw_Title: ;
  1794. ;---------------------------------------------------;
  1795. MOVLW LOW VIDEO_BUFFER_START + (15 * 4) ;
  1796. MOVWF FSR1L ;
  1797. MOVLW HIGH VIDEO_BUFFER_START ;
  1798. MOVWF FSR1H ;
  1799. MOVLW LOW PICPONG_TABLE ;
  1800. MOVWF FSR0L ;
  1801. MOVLW HIGH PICPONG_TABLE ;
  1802. MOVWF FSR0H ;
  1803. MOVLW PICPONG_TABLE_END - PICPONG_TABLE_START ;
  1804. MOVWF Temp1 ;
  1805. _DT_TITLE: ;
  1806. MOVFW INDF0 ;
  1807. MOVWF INDF1 ;
  1808. ADDFSR FSR1, 1 ;
  1809. ADDFSR FSR0, 1 ;
  1810. DECFSZ Temp1, F ;
  1811. GOTO _DT_TITLE ;
  1812. RETURN ;
  1813. ;---------------------------------------------------;
  1814.  
  1815. ;---------------------------------------------------;
  1816. ; COPYRIGHT Scan Line Data ;
  1817. ;---------------------------------------------------;
  1818. COPYRIGHT_TABLE: ;
  1819. ;---------------------------------------------------;
  1820. DT B'00000000', B'00000011', B'00111011', B'10001001', B'00100111', B'00100010', B'11100000', B'00000000'
  1821. DT B'00000000', B'00000011', B'10111011', B'10010011', B'10010111', B'01110110', B'11100000', B'00000000'
  1822. DT B'00000000', B'00000010', B'10010001', B'00010010', B'10010001', B'01010010', B'00100000', B'00000000'
  1823. DT B'10101010', B'10101010', B'10010001', B'00010010', B'00010111', B'01010010', B'11100101', B'01010101'
  1824. DT B'10101010', B'10101010', B'10010001', B'00010010', B'00010111', B'01010010', B'11100101', B'01010101'
  1825. DT B'00000000', B'00000010', B'10010001', B'00010010', B'10010100', B'01010010', B'10000000', B'00000000'
  1826. DT B'00000000', B'00000011', B'10010011', B'10010011', B'10010111', B'01110010', B'11100000', B'00000000'
  1827. DT B'00000000', B'00000011', B'00010011', B'10001001', B'00100111', B'00100010', B'11100000', B'00000000'
  1828. ;---------------------------------------------------;
  1829.  
  1830. ;---------------------------------------------------;
  1831. ;USER_CODE_2 CODE H'800' ;
  1832. ;---------------------------------------------------;
  1833. ; Numeric Characters (0-9) Scan Line Data ;
  1834. ;---------------------------------------------------;
  1835. CHARACTER_TABLE: ;
  1836. ;---------------------------------------------------;
  1837. DT B'11101110', B'10101010', B'10101010', B'10101010', B'11101110'
  1838. DT B'01000100', B'11001100', B'01000100', B'01000100', B'01000100'
  1839. DT B'11101110', B'00100010', B'11101110', B'10001000', B'11101110'
  1840. DT B'11101110', B'00100010', B'11101110', B'00100010', B'11101110'
  1841. DT B'10101010', B'10101010', B'11101110', B'00100010', B'00100010'
  1842. DT B'11101110', B'10001000', B'11101110', B'00100010', B'11101110'
  1843. DT B'11101110', B'10001000', B'11101110', B'10101010', B'11101110'
  1844. DT B'11101110', B'00100010', B'00100010', B'00100010', B'00100010'
  1845. DT B'11101110', B'10101010', B'11101110', B'10101010', B'11101110'
  1846. DT B'11101110', B'10101010', B'11101110', B'00100010', B'00100010'
  1847. ;---------------------------------------------------;
  1848.  
  1849. ;---------------------------------------------------;
  1850. ; PICPONG Title Scan Line Data ;
  1851. ;---------------------------------------------------;
  1852. PICPONG_TABLE: ;
  1853. ;---------------------------------------------------;
  1854. PICPONG_TABLE_START: ;
  1855. DT B'00000000', B'00000000', B'00000000', B'00000000'
  1856. DT B'00000000', B'00011001', B'01000000', B'00000000'
  1857. DT B'00000000', B'00011101', B'11100000', B'00000000'
  1858. DT B'00000000', B'00010100', B'10100000', B'00000000'
  1859. DT B'00000000', B'00010100', B'10100000', B'00000000'
  1860. DT B'00000000', B'00010101', B'10000000', B'00000000'
  1861. DT B'00000000', B'00010101', B'10001000', B'00000000'
  1862. DT B'00000000', B'00011101', B'10001000', B'00000000'
  1863. DT B'00000000', B'00011001', B'10000000', B'00000000'
  1864. DT B'00000000', B'00010001', B'10100000', B'00000000'
  1865. DT B'00000000', B'00010001', B'10100000', B'00000000'
  1866. DT B'00000000', B'00010001', B'11100000', B'00000000'
  1867. DT B'00000000', B'00010001', B'01000000', B'00000000'
  1868. DT B'00000000', B'00000000', B'00000000', B'00000000'
  1869. DT B'00000000', B'00000000', B'00000000', B'00000000'
  1870. DT B'00000000', B'01100010', B'01000100', B'00000000'
  1871. DT B'00000000', B'01110111', B'11101110', B'00000000'
  1872. DT B'00000000', B'01010101', B'10101010', B'00000000'
  1873. DT B'00000000', B'01010101', B'10101010', B'00000000'
  1874. DT B'00000000', B'01010101', B'10101010', B'00000000'
  1875. DT B'00000000', B'01010101', B'10101010', B'00000000'
  1876. DT B'00000000', B'01110101', B'10101110', B'00000000'
  1877. DT B'00000000', B'01100101', B'10100110', B'00000000'
  1878. DT B'00000000', B'01000101', B'10100010', B'00000000'
  1879. DT B'00000000', B'01000101', B'10101010', B'00000000'
  1880. DT B'00000000', B'01000111', B'10101110', B'00000000'
  1881. DT B'00000000', B'01000010', B'10100100', B'00000000'
  1882. DT B'00000000', B'00000000', B'00000000', B'00000000'
  1883. PICPONG_TABLE_END: ;
  1884. ;---------------------------------------------------;
  1885.  
  1886. ;---------------------------------------------------;
  1887. END ;
  1888. ;---------------------------------------------------;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement