Advertisement
Guest User

PONG.ASM V3.02

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