Advertisement
Guest User

PONG.ASM V4.01

a guest
Dec 27th, 2012
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 95.57 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 28, 2012 ;
  13. ; Version: V4.01 ;
  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. ; V3.03: Updated version number display to V3.03 ;
  54. ; - Adding more comments ;
  55. ; - Changed references to 'Half_Line' and ;
  56. ; 'Full_Line' in some proc titles to ;
  57. ; '30us_Line' and '60us_Line' respectively. ;
  58. ; (_Blank_Half_Line => _Blank_30us_Line) ;
  59. ; - Moved some line generation procs to high ;
  60. ; page, added PAGESELs, adjusted timings. ;
  61. ; - _Blank_60us_Line ;
  62. ; - _Blank_30us_Line ;
  63. ; - _Special_30us_Line ;
  64. ; - _Inverted_30us_Line ;
  65. ; - Everything possible has been moved to the ;
  66. ; high page of memory, with the exceptions: ;
  67. ; - _Update_Paddle_1 ;
  68. ; - _Update_Paddle_2 ;
  69. ; - _Update_Ball ;
  70. ; I am only using 655 words in the low page ;
  71. ; of program memory now (H'000'-H'28E') out ;
  72. ; of 4096 bytes (2048 words). The high page ;
  73. ; is packed - H'800'-H'D92'. I left the ;
  74. ; above procs in the low page as I will be ;
  75. ; making modifications / enhancements to ;
  76. ; these routines in the near future. ;
  77. ; - NOTE: If you see what appears to be stray ;
  78. ; NOPs strewn about in the code - DON'T ;
  79. ; REMOVE THEM. They are there for video ;
  80. ; timings purposes. Remove them and DOOM! ;
  81. ; V3.04: Updated version number display to V3.04 ;
  82. ; - Changed the use of Timer0 (8bit) from ;
  83. ; loading zero and waiting for count to ;
  84. ; loading (inverse) count and waiting for ;
  85. ; overflow flag (TMR0IF) in INTCON. ;
  86. ; - Created _Clear_Items and _Draw_Items. ;
  87. ; _Clear_Items clears ball, paddles, scores ;
  88. ; _Draw_Items draws ball, paddles, scores ;
  89. ; - Removed _Update_Scores, since one half ;
  90. ; went into _Clear_Items and the other half ;
  91. ; went into _Draw_Items. There was nothing ;
  92. ; left, except for 60us line generation, ;
  93. ; after that. ;
  94. ; V3.05: Updated verion number display to V3.05 ;
  95. ; - Changed field size from 32x56 to 32x48 ;
  96. ; - Changed VIDEO_BUFFER start from H'2010' to;
  97. ; H'2020' to recover 16 bytes of data memory;
  98. ; that are now available due to small field ;
  99. ; - Added dynamic creation of blank lines ;
  100. ; depending on screen size. This will keep ;
  101. ; the screen centered (vertically) in the ;
  102. ; viewable area of the video frame and keep ;
  103. ; the video frame at 60hz ;
  104. ; - Added court sidelines so that the limits ;
  105. ; of the court can be easily determined no ;
  106. ; matter the size of the field. ;
  107. ; - Added 'SERVICE' markers (arrows next to ;
  108. ; the scores) to easily determine who's turn;
  109. ; it is to serve. Last one scored serves. ;
  110. ; - Reduced size of title screen and changed ;
  111. ; title back to just 'PONG'. Title screen ;
  112. ; was too large and the time to draw (or ;
  113. ; clear) was blowing WAY past the 60us limit;
  114. ; - Changed wall collision detection so that ;
  115. ; Ball_Dir_Y can be something other that 1 ;
  116. ; or -1. This opens the door to implementing;
  117. ; 'english' on the ball ;
  118. ; - Service is now done from the paddle, not ;
  119. ; center court. And the beginning Ball_Y ;
  120. ; position is centered with the paddle ;
  121. ; - Ball angle on service (Ball_Dir_Y at 1 or ;
  122. ; for the left paddle, -1 or -2 for the ;
  123. ; right paddle) depends on paddle position ;
  124. ; - The starting position of the scores has ;
  125. ; been dropped one line to keep the score ;
  126. ; display from bumping against the court ;
  127. ; side line. ;
  128. ; - With a field of 32x48, PONG has been ;
  129. ; testing on a Sony PS1 LCD monitor, a small;
  130. ; PHILIPS LCD TV, and a regular CRT TV which;
  131. ; all work well. However, a 32" Chinese made;
  132. ; LCD TV does not work - maybe because it ;
  133. ; wants 50hz? Any feedback on various TVs ;
  134. ; used with PONG would be appreciated. ;
  135. ; - Added a check to see if the left or right ;
  136. ; button is being held - this keeps from ;
  137. ; holding the button down and continuously ;
  138. ; serving the ball. ;
  139. ; - Even MORE comments added. I sure hope I ;
  140. ; remove all of the old (irrelevent) ones. ;
  141. ; - Back to the large graphics to the title. ;
  142. ; I split it into two 60us lines. Also did ;
  143. ; a lot of tricks to reduce the instruction ;
  144. ; count. _Clear_Screen replaces _Clear_Items;
  145. ; and will clear the screen OR display the ;
  146. ; title at the appropriate time. ;
  147. ; - EVERYTHING uses TIMER0 now, except for ;
  148. ; generating a positive 2us sync pulse. Not ;
  149. ; enough cycles to incorporate the timer. ;
  150. ; - All loose code and commented out lines ;
  151. ; removed. All timings at spec. RELEASE! ;
  152. ; V3.06: Updated verion number display to V3.06 ;
  153. ; - Corrected a few bugs in ball/paddle ;
  154. ; collision detection. ;
  155. ; - Corrected a bug in _Clear_Screen ;
  156. ; - Moved all 30us stuff to a procedure called;
  157. ; _Vertical_Sync. ;
  158. ; - Split the code as evenly as I could ;
  159. ; between the low page and high page of ;
  160. ; program memory. Lots of room for editing ;
  161. ; now without worrying about bumping the ;
  162. ; ceilings. There's around 900 program words;
  163. ; free in each page. ;
  164. ; - I don't think there are any major bugs - ;
  165. ; just enhancements waiting in the wings. ;
  166. ; Time to final release and move on! ;
  167. ; V3.07: Updated version number display to V3.07 ;
  168. ; - Added a blank line and then two white ;
  169. ; lines just after the copyright lines. Just;
  170. ; because I like it better. ;
  171. ; - Fixed the 'shoot off in a horitontal angle;
  172. ; when hitting the upper sideline wall' bug.;
  173. ; If you saw the V3.06 demo video, it was ;
  174. ; occurring frequently and the OCD in me ;
  175. ; said "You gotta fix that". ;
  176. ; That's it for this version - RELEASE! ;
  177. ; V4.00: Updated version number display to V4.00 ;
  178. ; - Converting timings of video signal to ;
  179. ; TIMER0 Interrupt Service Routine. ;
  180. ; - Added a 'shake loose' of the PICKIT if ;
  181. ; attached. Without the 'shake loose', the ;
  182. ; PICKIT hold GPIO1 low, which is the RBUTT.;
  183. ; V4.01: Updated version number display to V4.01 ;
  184. ; - Added COMPUTER mode for player 2. Hold ;
  185. ; down the LEFT button when powering up. A ;
  186. ; large 'C' should display in the upper ;
  187. ; right corner. PLAYER 2 is now controlled ;
  188. ; by the computer. ;
  189. ;---------------------------------------------------;
  190. ;---------------------------------------------------;
  191.  
  192. ;---------------------------------------------------;
  193. ; Project Defines ;
  194. ;---------------------------------------------------;
  195. #DEFINE _PONG.ASM_ ;
  196. #DEFINE _MAIN_MODULE_ ;
  197. ;---------------------------------------------------;
  198. #DEFINE _DEBUG_ TRUE ;
  199. #DEFINE _USE_THUMBSTICKS_ TRUE ;
  200. ;---------------------------------------------------;
  201.  
  202. ;---------------------------------------------------;
  203. ; Includes ;
  204. ;---------------------------------------------------;
  205. ; This file has some common defines (TRUE, FALSE, ;
  206. ; etc.) used throughout the program. It also has the;
  207. ; CONFIGURATION_BITS settings for the PIC, which are;
  208. ; only processed in the module that has the define ;
  209. ; _MAIN_MODULE_. ;
  210. ;---------------------------------------------------;
  211. #INCLUDE Common.INC ;
  212. ;---------------------------------------------------;
  213.  
  214. ;---------------------------------------------------;
  215. ; Macros ;
  216. ;---------------------------------------------------;
  217. DELAY MACRO DTIME ;
  218. ;-----------------------------------------------;
  219. ; The time munger used EVERYWHERE ;
  220. ;-----------------------------------------------;
  221. MOVLW DTIME ;
  222. MOVWF DTemp ;
  223. DECFSZ DTemp, F ;
  224. GOTO $-1 ;
  225. ;-----------------------------------------------;
  226. ENDM ;
  227. ;
  228. DO_BIT MACRO THISBIT, NOPS ;
  229. ;-----------------------------------------------;
  230. ; Sets the DAC either WHITE or BLACK ;
  231. ; Does a specified delay in NOPs ;
  232. ;-----------------------------------------------;
  233. ; NOTE: This is used in the higher resolution ;
  234. ; COPYRIGHT lines and when generating the ;
  235. ; gameplay data lines. ;
  236. ;-----------------------------------------------;
  237. ; Note that a WHITE bit check is done first and ;
  238. ; then a BLACK bit check. If you reverse the ;
  239. ; order, things look a bit differently on the ;
  240. ; screen. That is because there is a two ;
  241. ; instruction delay between writing the bit in ;
  242. ; one state or in the other state. Reversing the;
  243. ; order (BLACK first, then WHITE) causes black ;
  244. ; 'gaps'. This order is most visually appealing,;
  245. ; at least to me. ;
  246. ;-----------------------------------------------;
  247. BTFSC INDF1, THISBIT ;
  248. BSF PORTA, VIDEO_0_BIT ;
  249. BTFSS INDF1, THISBIT ;
  250. BCF PORTA, VIDEO_0_BIT ;
  251. #IF NOPS > 0 ;
  252. NOP ;
  253. #ENDIF ;
  254. #IF NOPS > 1 ;
  255. NOP ;
  256. #ENDIF ;
  257. #IF NOPS > 2 ;
  258. NOP ;
  259. #ENDIF ;
  260. #IF NOPS > 3 ;
  261. NOP ;
  262. #ENDIF ;
  263. #IF NOPS > 4 ;
  264. NOP ;
  265. #ENDIF ;
  266. #IF NOPS > 5 ;
  267. NOP ;
  268. #ENDIF ;
  269. #IF NOPS > 6 ;
  270. NOP ;
  271. #ENDIF ;
  272. #IF NOPS > 7 ;
  273. NOP ;
  274. #ENDIF ;
  275. #IF NOPS > 8 ;
  276. NOP ;
  277. #ENDIF ;
  278. #IF NOPS > 9 ;
  279. NOP ;
  280. #ENDIF ;
  281. ;-----------------------------------------------;
  282. ENDM ;
  283. ;
  284. SET_DAC2BIT MACRO COLOR ;
  285. ;-----------------------------------------------;
  286. ; Sets the 2bit DAC to the desired color ;
  287. ; Both bits are done at once, or else some weird;
  288. ; transitions on the DAC can be seen. Okay if ;
  289. ; just colors (WHITE, GRAY, BLACK), but if a ;
  290. ; sync pulse shows up out context, it can really;
  291. ; mess up the video timings ;
  292. ;-----------------------------------------------;
  293. MOVFW PORTA ;
  294. ANDLW ~(VIDEO_0 | VIDEO_1) ;
  295. IORLW COLOR ;
  296. MOVWF PORTA ;
  297. ;-----------------------------------------------;
  298. ENDM ;
  299. ;
  300. AUDIO_PROC MACRO ;
  301. ;-----------------------------------------------;
  302. ; This handles the sound generation during the ;
  303. ; game. Sounds are produced by toggling GPIO1 ;
  304. ; at the end of each 60us line - if it is ;
  305. ; toggled during ALL 60us lines, you get a high ;
  306. ; frequency (around 7800hz). If every other 60us;
  307. ; line, the frequency is around lower. This ;
  308. ; procedure is NOT run during VERTICAL SYNC time;
  309. ; to keep AUDIO from altering the timings of the;
  310. ; video, causing distortions of the image on the;
  311. ; screen. ;
  312. ;-----------------------------------------------;
  313. BTFSC System_Status, VERTICAL_SYNC_BIT ;
  314. GOTO $+15 ;
  315. BTFSS System_Status, BUZZ_BIT ;
  316. GOTO $+13 ;
  317. DECFSZ Buzz_Count, F ;
  318. GOTO $+11 ;
  319. MOVFW Buzz_Reload ;
  320. MOVWF Buzz_Count ;
  321. MOVLW AUDIO ;
  322. XORWF PORTA, F ;
  323. DECFSZ Buzz_Dur_LO, F ;
  324. GOTO $+5 ;
  325. DECFSZ Buzz_Dur_HI, F ;
  326. GOTO $+3 ;
  327. BCF System_Status, BUZZ_BIT ;
  328. BSF PORTA, AUDIO_BIT ;
  329. ;-----------------------------------------------;
  330. ENDM ;
  331. ;
  332. #DEFINE SIG_2US 2 ;
  333. #DEFINE SIG_4US 4 ;
  334. #DEFINE SIG_30US 30 ;
  335. #DEFINE SIG_60US 60 ;
  336. ;
  337. START_TIMING MACRO SIG_1_LEN, SIG_2_LEN ;
  338. AUDIO_PROC ;
  339. ;
  340. BTFSC PORTA, VIDEO_1_BIT ;
  341. GOTO $-1 ;
  342. ;
  343. #IF (SIG_1_LEN == 2) ;
  344. MOVLW ~((SIG_1_LEN*2)-0) ;
  345. #ENDIF ;
  346. #IF (SIG_1_LEN == 4) ;
  347. MOVLW ~((SIG_1_LEN*3)-1) ;
  348. #ENDIF ;
  349. #IF (SIG_1_LEN == 30) ;
  350. MOVLW ~((SIG_1_LEN*4)-5) ;
  351. #ENDIF ;
  352. #IF (SIG_1_LEN == 60) ;
  353. MOVLW ~((SIG_1_LEN*4)-5) ;
  354. #ENDIF ;
  355. ;
  356. MOVWF Next_Vid_Timing ;
  357. ;
  358. BTFSS PORTA, VIDEO_1_BIT ;
  359. GOTO $-1 ;
  360. ;
  361. #IF (SIG_2_LEN == 2) ;
  362. MOVLW ~((SIG_2_LEN*2)-0) ;
  363. #ENDIF ;
  364. #IF (SIG_2_LEN == 4) ;
  365. MOVLW ~((SIG_2_LEN*3)-1) ;
  366. #ENDIF ;
  367. #IF (SIG_2_LEN == 30) ;
  368. MOVLW ~((SIG_2_LEN*4)-5) ;
  369. #ENDIF ;
  370. #IF (SIG_2_LEN == 60) ;
  371. MOVLW ~((SIG_2_LEN*4)-5) ;
  372. #ENDIF ;
  373. ;
  374. MOVWF Next_Vid_Timing ;
  375. ;-----------------------------------------------;
  376. ENDM ;
  377. ;
  378. PLAY_SOUND MACRO FREQUENCY, DURATION ;
  379. ;-----------------------------------------------;
  380. ; This will play a sound of a specified ;
  381. ; frequency for a specified duration ;
  382. ; The lower the frequency number, the higher ;
  383. ; the frequency. Duration is also a function ;
  384. ; of the frequency number, so if frequency goes ;
  385. ; up, adjust the duration down. ;
  386. ;-----------------------------------------------;
  387. ; Sound is played during 4us HORIZONTAL SYNC ;
  388. ; times of the video signal. There is a short ;
  389. ; period during VERTICAL SYNC where nothing is ;
  390. ; done with sound because there ARE no 4us ;
  391. ; HSYNCs. There are 2us HSYNCs during VSYNC, but;
  392. ; there isn't enough time to process the sound ;
  393. ; code without stretching out the 2us HSYNCs ;
  394. ; beyond 2us, and that will mess up the video ;
  395. ; timings. The total time between the last 4us ;
  396. ; HSYNC before VSYNC and the first 4us HSYNC ;
  397. ; after VSYNC is only ~512us, so it's barely ;
  398. ; noticable. After all, it's only a game... ;
  399. ;-----------------------------------------------;
  400. ; NOTE that a FREQUENCY of 0 is treated as a ;
  401. ; frequency of 256. 0<=Freq<=255. The count is ;
  402. ; decremented BEFORE it is checked to be 0, so ;
  403. ; starting with 0 will dec, see 255, continue ;
  404. ; loop. Just so you are warned. ;
  405. ;-----------------------------------------------;
  406. MOVLW FREQUENCY ;
  407. MOVWF Buzz_Count ;
  408. MOVWF Buzz_Reload ;
  409. MOVLW LOW DURATION ;
  410. MOVWF Buzz_Dur_LO ;
  411. MOVLW HIGH DURATION ;
  412. MOVWF Buzz_Dur_HI ;
  413. BSF System_Status, BUZZ_BIT ;
  414. ;-----------------------------------------------;
  415. ENDM ;
  416. ;---------------------------------------------------;
  417.  
  418. ;---------------------------------------------------;
  419. ; Defines ;
  420. ;---------------------------------------------------;
  421. ; You have to chose between using all buttons, ;
  422. ; or using a thumbstick with a button. I might ;
  423. ; be able to figure out a way to automatically ;
  424. ; determine which is connected, but for now you ;
  425. ; will just have to decide which you want, set ;
  426. ; _USE_THUMBSTICKS_ to either TRUE or FALSE, and;
  427. ; re-compile the project. ;
  428. ;-----------------------------------------------;
  429. #IF _USE_THUMBSTICKS_ ;
  430. #DEFINE RJOY H'01' ; Right THUMBSTICK
  431. #DEFINE RJOY_BIT 0 ; GPIO 0 - PIN 7
  432. #DEFINE AUDIO H'02' ; Audio Output when set to OUTPUT
  433. #DEFINE AUDIO_BIT 1 ; GPIO 1 - PIN 6
  434. #DEFINE RBUTT H'02' ; Right BUTTON when set to INPUT
  435. #DEFINE RBUTT_BIT 1 ; GPIO 1 - PIN 6
  436. #DEFINE LJOY H'04' ; Left THUMBSTICK
  437. #DEFINE LJOY_BIT 2 ; GPIO 2 - PIN 5
  438. #DEFINE LBUTT H'08' ; Left BUTTON
  439. #DEFINE LBUTT_BIT 3 ; GPIO 3 - PIN 4
  440. #ELSE ;!_USE_THUMBSTICKS_ ;
  441. #DEFINE RBUTT_1 H'01' ; Right BUTTON 1
  442. #DEFINE RBUTT_1_BIT 0 ; GPIO 0 - PIN 7
  443. #DEFINE RBUTT_2 H'02' ; Right BUTTON 2
  444. #DEFINE RBUTT_2_BIT 1 ; GPIO 1 - PIN 6
  445. #DEFINE LBUTT_2 H'04' ; Left BUTTON 2
  446. #DEFINE LBUTT_2_BIT 2 ; GPIO 2 - PIN 5
  447. #DEFINE LBUTT_1 H'08' ; Left BUTTON 1
  448. #DEFINE LBUTT_1_BIT 3 ; GPIO 3 - PIN 4
  449. #ENDIF ;_USE_THUMBSTICKS_ ;
  450. ;-----------------------------------------------;
  451. ;
  452. ;-----------------------------------------------;
  453. ; 2bit DAC definitions. The 2bit DAC is just a ;
  454. ; pair of resistors on two GPIOs, which feeds ;
  455. ; the VIDEO out. ;
  456. ;-----------------------------------------------;
  457. #DEFINE VIDEO_1 H'10' ; 1K ohm
  458. #DEFINE VIDEO_1_BIT 4 ; GPIO 5 - PIN 2
  459. #DEFINE VIDEO_0 H'20' ; 470 ohm
  460. #DEFINE VIDEO_0_BIT 5 ; GPIO 4 - PIN 3
  461. ;
  462. #DEFINE COLOR_WHITE (VIDEO_0 + VIDEO_1) ;
  463. #DEFINE COLOR_BLACK VIDEO_1 ;
  464. #DEFINE COLOR_GRAY VIDEO_0 ;
  465. #DEFINE COLOR_SYNC 0 ;
  466. ;-----------------------------------------------;
  467. ;
  468. ;-----------------------------------------------;
  469. ; There are 224 lines created during _Data_Lines;
  470. ; However, because of memory limitations, I ;
  471. ; cannot allocate enough memory for the video ;
  472. ; buffer. So - I do have enough memory for 56 ;
  473. ; lines - 1/4 of 224 - so we display each line ;
  474. ; of data 4 times. ;
  475. ;-----------------------------------------------;
  476. #DEFINE MAX_LINES 56 ; DON'T EXCEED 56
  477. ;-----------------------------------------------;
  478. ; Make certain NUM_LINES is an even number so ;
  479. ; all of the math works out properly. Make sure ;
  480. ; NOT to exceed the MAX_LINES value. And don't ;
  481. ; change NUM_LINES for less than 9 - that's the ;
  482. ; paddle height, so that will probably break it.;
  483. ; But then - the paddle height is adjustable ;
  484. ; with just changing a define (below), so - who ;
  485. ; knows! ;
  486. ;-----------------------------------------------;
  487. #DEFINE NUM_LINES 48 ; DON'T EXCEED 48
  488. ;-----------------------------------------------;
  489. ;
  490. ;-----------------------------------------------;
  491. ; This is my method of making the game easier or;
  492. ; harder - either I update and draw the ball ;
  493. ; every frame (fast ball), or every other frame ;
  494. ; (not as fast), or every 3rd frame (normal ;
  495. ; ball) or higher for slower. Set MAX_BALL_WAIT ;
  496. ; to the desired speed (1=fast, 2=not as fast, ;
  497. ; 3=normal, 4=slower, etc.). This is hardcoded ;
  498. ; right now, a change requires a recompile. I ;
  499. ; have plans to allocate another precious byte ;
  500. ; of data memory so that the ball speed can be ;
  501. ; changed by a menu item. ;
  502. ;-----------------------------------------------;
  503. #DEFINE DRAW_BALL_BIT 0 ;
  504. #DEFINE MAX_BALL_WAIT 3 ;
  505. ;
  506. ;-----------------------------------------------;
  507. ; Just a bunch of hardcoded starting points, ;
  508. ; sizes, and bit-munching stuff for the various ;
  509. ; graphics. ;
  510. ;-----------------------------------------------;
  511. ; I use the PIC's LINEAR MEMORY scheme to create;
  512. ; a contiguous video buffer. Grab the MicroChip ;
  513. ; documentation and read up. Then go search on ;
  514. ; the web for some docs that will really explain;
  515. ; it for you. ;
  516. ;-----------------------------------------------;
  517. #DEFINE VIDEO_BUFFER_START H'2030' ;
  518. #DEFINE FIELD_HEIGHT NUM_LINES ;
  519. #DEFINE FIELD_WIDTH 32 ;
  520. #DEFINE LEFT_SCORE_START H'01' ;
  521. #DEFINE RIGHT_SCORE_START H'02' ;
  522. #DEFINE LEFT_PADDLE_START H'00' ;
  523. #DEFINE LEFT_PADDLE_BIT H'40' ;
  524. #DEFINE LEFT_PADDLE_MASK H'BF' ;
  525. #DEFINE RIGHT_PADDLE_START H'03' ;
  526. #DEFINE RIGHT_PADDLE_BIT H'02' ;
  527. #DEFINE RIGHT_PADDLE_MASK H'FD' ;
  528. #DEFINE PADDLE_HEIGHT 9 ;
  529. #DEFINE BALL_HEIGHT 3 ;
  530. #DEFINE SERVICE_1_START H'00' ;
  531. #DEFINE SERVICE_2_START H'03' ;
  532. #DEFINE COMPUTER_2_START H'07' ;
  533. ;---------------------------------------------------;
  534.  
  535. ;---------------------------------------------------;
  536. ;---------------------------------------------------;
  537. USER_DATA_1 UDATA H'020' ;
  538. ;---------------------------------------------------;
  539. Ball_X res 1 ; 20
  540. Ball_Y res 1 ; 21
  541. Ball_Dir_X res 1 ; 22
  542. Ball_Dir_Y res 1 ; 23
  543. Paddle_1_Y res 1 ; 24
  544. Paddle_2_Y res 1 ; 25
  545. Score_1 res 1 ; 26
  546. Score_2 res 1 ; 27
  547. Ball_Wait res 1 ; 28
  548. ;---------------------------------------------------;
  549. ; Bit definitions for System_Status ;
  550. ;---------------------------------------------------;
  551. #DEFINE BUZZ H'01' ;
  552. #DEFINE BUZZ_BIT 0 ;
  553. #DEFINE P1_SERVICE H'02' ;
  554. #DEFINE P1_SERVICE_BIT 1 ;
  555. #DEFINE P2_SERVICE H'04' ;
  556. #DEFINE P2_SERVICE_BIT 2 ;
  557. #DEFINE P1_PRESSED H'08' ;
  558. #DEFINE P1_PRESSED_BIT 3 ;
  559. #DEFINE P2_PRESSED H'10' ;
  560. #DEFINE P2_PRESSED_BIT 4 ;
  561. #DEFINE VERTICAL_SYNC H'20' ;
  562. #DEFINE VERTICAL_SYNC_BIT 5 ;
  563. #DEFINE WHICH_CR H'40' ;
  564. #DEFINE WHICH_CR_BIT 6 ;
  565. #DEFINE P2_COMPUTER H'80' ;
  566. #DEFINE P2_COMPUTER_BIT 7 ;
  567. ;---------------------------------------------------;
  568. System_Status res 1 ; 29
  569. Buzz_Count res 1 ; 2A
  570. Buzz_Reload res 1 ; 2B
  571. Buzz_Dur_HI res 1 ; 2C
  572. Buzz_Dur_LO res 1 ; 2D
  573. ;---------------------------------------------------;
  574. ; Consume Left_Overs / Smaller_Screen for your data ;
  575. ; variables as need. LO/SS is just here to pad to ;
  576. ; push Video_Buffer1 to the proper spot. ;
  577. Left_Overs res 2 ; 2E-2F
  578. ;---------------------------------------------------;
  579. ; Only 6 bytes left - 2A-2F ;
  580. ;---------------------------------------------------;
  581. Smaller_Screen res 32 ; 30-4F
  582. ;---------------------------------------------------;
  583. ; I've pushed the VIDEO_BUFFER to H'2020', since the;
  584. ; field has become smaller (32x48 vs 32x56). The ;
  585. ; required size of the VIDEO_BUFFER is also less, so;
  586. ; this will give up 24 more bytes of data memory for;
  587. ; use in game programming. ;
  588. ;---------------------------------------------------;
  589. ; 16 additional bytes left (smaller screen) - 30-3F ;
  590. ;---------------------------------------------------;
  591. ; We don't access the Video_BufferX arrays directly,;
  592. ; we use LINEAR PAGE memory through the FSR register;
  593. ; LINEAR PAGE memory groups the data memory at 0x20,;
  594. ; 0xA0, and Ox120 into a contiguous linear page. ;
  595. ; Note that the shared memory (at the top 16 bytes ;
  596. ; of each page) is NOT included in the LINEAR PAGE ;
  597. ; memory mapping. ;
  598. ;---------------------------------------------------;
  599. ; MEMORY MAP - LINEAR PAGE MEMORY - 240 bytes total ;
  600. ; 0x2000-0x204F - 0x020-0x06F 80 bytes ;
  601. ; 0x2050-0x20BF - 0x0A0-0x0EF 80 bytes ;
  602. ; 0x20A0-0x20EF - 0x120-0x16F 80 bytes ;
  603. ;---------------------------------------------------;
  604. ; Since out max lines (now) is 48, we need 48x8 ;
  605. ; (192) bytes of memory for the screen buffer. This ;
  606. ; leaves us with 48 bytes of data memory for program;
  607. ; variables, plus the 16 in shared memory for 64! ;
  608. ;---------------------------------------------------;
  609. Video_Buffer1 res 32 ; 50-6F
  610. ;---------------------------------------------------;
  611. ;---------------------------------------------------;
  612.  
  613. ;---------------------------------------------------;
  614. ;---------------------------------------------------;
  615. USER_DATA_2 UDATA H'0A0' ;
  616. ;---------------------------------------------------;
  617. Video_Buffer2 res 80 ; A0-EF
  618. ;---------------------------------------------------;
  619. ;---------------------------------------------------;
  620.  
  621. ;---------------------------------------------------;
  622. ;---------------------------------------------------;
  623. USER_DATA_3 UDATA H'120' ;
  624. ;---------------------------------------------------;
  625. Video_Buffer3 res 80 ; 120-6F
  626. ;---------------------------------------------------;
  627. ;---------------------------------------------------;
  628.  
  629. ;---------------------------------------------------;
  630. ;---------------------------------------------------;
  631. USER_DATA_S UDATA_SHR H'070' ;
  632. ;---------------------------------------------------;
  633. Temp1 res 1 ; 70
  634. Temp2 res 1 ; 71
  635. DTemp res 1 ; 72
  636. DL_Count res 1 ; 73
  637. Line_Data res 4 ; 74-77
  638. Line_Count res 1 ; 78
  639. Repeat_Count res 1 ; 79
  640. Vid_Timing res 1 ; 7A
  641. Next_Vid_Timing res 1 ; 7B
  642. VSync_Count res 1 ; 7C
  643. ;---------------------------------------------------;
  644. ; Only 3 bytes left! - 7D-7F ;
  645. ;---------------------------------------------------;
  646. ;---------------------------------------------------;
  647.  
  648. ;---------------------------------------------------;
  649. ;---------------------------------------------------;
  650. ; Reset Vector Code - Entry point from reset ;
  651. ;---------------------------------------------------;
  652. RESET_VECT CODE H'000' ;
  653. ;---------------------------------------------------;
  654. ; Initialize the hardware and memory elements. ;
  655. ; This is a FAR CALL to a proc in the high ;
  656. ; page of Program Memory, so it needs the ;
  657. ; PAGESEL before and after the CALL to properly ;
  658. ; set the upper 2 bits in the program counter. ;
  659. ; I am slowly converting ALL CALLs (and some ;
  660. ; GOTOs) to having PAGESEL before and after, but;
  661. ; the added instruction cycles mess up the video;
  662. ; timings in some spots. To be done slowly and ;
  663. ; surely. ;
  664. ;-----------------------------------------------;
  665. PAGESEL _Initialize_System ;
  666. GOTO _Initialize_System ;
  667. NOP ;
  668. NOP ;
  669. ;---------------------------------------------------;
  670. ;---------------------------------------------------;
  671.  
  672. ;---------------------------------------------------;
  673. ;---------------------------------------------------;
  674. ; Interrupt Vector Code ;
  675. ;---------------------------------------------------;
  676. INT_VECT CODE H'004' ;
  677. ;---------------------------------------------------;
  678. _IV_Entry: ;
  679. ;-----------------------------------------------;
  680. ; Toggle the BLACK/SYNC bit ;
  681. ;-----------------------------------------------;
  682. MOVLW VIDEO_1 ;
  683. XORWF PORTA, F ;
  684. ;-----------------------------------------------;
  685. ;
  686. ;-----------------------------------------------;
  687. ; Load current timing into TMR0, load next ;
  688. ; timing into current timing. ;
  689. ;-----------------------------------------------;
  690. MOVFW Vid_Timing ;
  691. MOVWF TMR0 ;
  692. MOVFW Next_Vid_Timing ;
  693. MOVWF Vid_Timing ;
  694. ;-----------------------------------------------;
  695. _IV_Exit: ;
  696. BCF INTCON, TMR0IF ;
  697. RETFIE ;
  698. ;---------------------------------------------------;
  699. ;---------------------------------------------------;
  700.  
  701. ;---------------------------------------------------;
  702. ;---------------------------------------------------;
  703. ; User Code in the low page of Program Memory ;
  704. ; More user code (USER_CODE_2) can be found in the ;
  705. ; high page of Program Memory, starting at H'800' ;
  706. ;---------------------------------------------------;
  707. USER_CODE_1 CODE H'00C' ;
  708. ;---------------------------------------------------;
  709.  
  710. ;---------------------------------------------------;
  711. _Update_Paddles: ;
  712. ;---------------------------------------------------;
  713. ; 60us BLACK line ;
  714. ;-----------------------------------------------;
  715. PAGESEL _Black_Line_60us ;
  716. CALL _Black_Line_60us ;
  717. PAGESEL $ ;
  718. ;-----------------------------------------------;
  719. ;
  720. #IF _USE_THUMBSTICKS_ ;
  721. _UP1_Update: ;
  722. ;-----------------------------------------------;
  723. ; ADC Magic (Channel 0) ;
  724. ;-----------------------------------------------;
  725. BANKSEL ADCON1 ;
  726. MOVLW H'60' ; Left Justified
  727. MOVWF ADCON1 ; FOSC/64, VREF
  728. MOVLW B'00001011' ; AN2, ADC GO, ADC On
  729. MOVWF ADCON0 ;
  730. BTFSC ADCON0, GO ; Wait for conversion
  731. GOTO $-1 ;
  732. MOVFW ADRESH ; Get result
  733. BANKSEL MEMORY ;
  734. ;-----------------------------------------------;
  735. ;
  736. ;-----------------------------------------------;
  737. ; The following code uses the joystick in a ;
  738. ; normal fashion - paddle position follows the ;
  739. ; joystick position. ;
  740. ;-----------------------------------------------;
  741. MOVWF Paddle_1_Y ;
  742. RRF Paddle_1_Y, F ;
  743. RRF Paddle_1_Y, F ;
  744. MOVLW H'3F' ;
  745. ANDWF Paddle_1_Y, F ;
  746. MOVLW 23 ;
  747. SUBWF Paddle_1_Y, F ;
  748. ;-----------------------------------------------;
  749. ;
  750. ;-----------------------------------------------;
  751. ; The following code uses the joystick in a ;
  752. ; button fashion - once the joystick crosses a ;
  753. ; certain threshold (position), the joystick ;
  754. ; reading is treating as an UP or DOWN button ;
  755. ; press and either increments or decrements the ;
  756. ; paddle position. ;
  757. ;-----------------------------------------------;
  758. ; MOVWF Temp1 ;
  759. ; MOVLW H'90' ;
  760. ; SUBWF Temp1, W ;
  761. ; BTFSS STATUS, C ;
  762. ; DECF Paddle_1_Y, F ;
  763. ; MOVLW H'98' ;
  764. ; SUBWF Temp1, W ;
  765. ; BTFSC STATUS, C ;
  766. ; INCF Paddle_1_Y, F ;
  767. ;-----------------------------------------------;
  768. ;
  769. ;-----------------------------------------------;
  770. ; Make sure the paddle position stays within the;
  771. ; range of the field. ;
  772. ;-----------------------------------------------;
  773. _UP1_Limit_Paddle_Position: ;
  774. ;-----------------------------------------------;
  775. ; Lower Limit ;
  776. ;-----------------------------------------------;
  777. BTFSC Paddle_1_Y, MSB ;
  778. CLRF Paddle_1_Y ;
  779. ;-----------------------------------------------;
  780. ; Upper Limit ;
  781. ;-----------------------------------------------;
  782. MOVLW NUM_LINES - PADDLE_HEIGHT ;
  783. SUBWF Paddle_1_Y, W ;
  784. BTFSS STATUS, C ;
  785. GOTO _UP1_Update_Done ;
  786. MOVLW NUM_LINES - PADDLE_HEIGHT ;
  787. MOVWF Paddle_1_Y ;
  788. ;-----------------------------------------------;
  789. ;
  790. _UP1_Update_Done: ;
  791. #ELSE ;!_USE_THUMBSTICKS_ ;
  792. _UP1_Check_Up: ;
  793. CLRW ;
  794. XORWF Paddle_1_Y, W ;
  795. BTFSC STATUS, Z ;
  796. GOTO _UP1_Check_Down ;
  797. BTFSS PORTA, LBUTT_1_BIT ;
  798. DECF Paddle_1_Y, F ;
  799. _UP1_Check_Down: ;
  800. MOVLW NUM_LINES - PADDLE_HEIGHT ;
  801. XORWF Paddle_1_Y, W ;
  802. BTFSC STATUS, Z ;
  803. GOTO _UP1_Draw_Paddle ;
  804. BTFSS PORTA, LBUTT_2_BIT ;
  805. INCF Paddle_1_Y, F ;
  806. #ENDIF ;_USE_THUMBSTICKS_ ;
  807. ;
  808. #IF _USE_THUMBSTICKS_ ;
  809. _UP2_Update: ;
  810. BTFSC System_Status, P2_COMPUTER_BIT ;
  811. GOTO _UP2_Computer ;
  812. ;
  813. ;-----------------------------------------------;
  814. ;-----------------------------------------------;
  815. _UP2_Human: ;
  816. ;-----------------------------------------------;
  817. ; ADC Magic (Channel 0) ;
  818. ;-----------------------------------------------;
  819. BANKSEL ADCON1 ;
  820. MOVLW H'60' ; Left Justified
  821. MOVWF ADCON1 ; FOSC/64, VREF
  822. MOVLW B'00000011' ; AN0, ADC GO, ADC On
  823. MOVWF ADCON0 ;
  824. BTFSC ADCON0, GO ; Wait for conversion
  825. GOTO $-1 ;
  826. MOVFW ADRESH ; Get result
  827. BANKSEL MEMORY ;
  828. ;-----------------------------------------------;
  829. ;
  830. MOVWF Temp1 ;
  831. MOVLW H'60' ;
  832. SUBWF Temp1, W ;
  833. BTFSS STATUS, C ;
  834. INCF Paddle_2_Y, F ;
  835. MOVLW H'9F' ;
  836. SUBWF Temp1, W ;
  837. BTFSC STATUS, C ;
  838. DECF Paddle_2_Y, F ;
  839. BTFSC Paddle_2_Y, MSB ;
  840. CLRF Paddle_2_Y ;
  841. MOVLW NUM_LINES - PADDLE_HEIGHT ;
  842. SUBWF Paddle_2_Y, W ;
  843. BTFSS STATUS, C ;
  844. GOTO _UP2_Human_Done ;
  845. MOVLW NUM_LINES - PADDLE_HEIGHT ;
  846. MOVWF Paddle_2_Y ;
  847. _UP2_Human_Done: ;
  848. GOTO _UP_Exit ;
  849. ;-----------------------------------------------;
  850. ;
  851. ;-----------------------------------------------;
  852. ;-----------------------------------------------;
  853. _UP2_Computer: ;
  854. ;-----------------------------------------------;
  855. MOVLW (FIELD_WIDTH * 7) / 9 ;
  856. SUBWF Ball_X, W ;
  857. BTFSS STATUS, C ;
  858. GOTO _UP2_Computer_Done ;
  859. ;-----------------------------------------------;
  860. MOVFW Paddle_2_Y ;
  861. ADDLW PADDLE_HEIGHT / 2 ;
  862. SUBWF Ball_Y, W ;
  863. BTFSS STATUS, C ;
  864. DECF Paddle_2_Y, F ;
  865. ;-----------------------------------------------;
  866. MOVFW Paddle_2_Y ;
  867. ADDLW PADDLE_HEIGHT / 2 ;
  868. SUBWF Ball_Y, W ;
  869. BTFSC STATUS, C ;
  870. INCF Paddle_2_Y, F ;
  871. ;-----------------------------------------------;
  872. BTFSC Paddle_2_Y, MSB ;
  873. CLRF Paddle_2_Y ;
  874. MOVLW NUM_LINES - PADDLE_HEIGHT ;
  875. SUBWF Paddle_2_Y, W ;
  876. BTFSS STATUS, C ;
  877. GOTO _UP2_Computer_Done ;
  878. MOVLW NUM_LINES - PADDLE_HEIGHT ;
  879. MOVWF Paddle_2_Y ;
  880. ;-----------------------------------------------;
  881. _UP2_Computer_Done: ;
  882. GOTO _UP_Exit ;
  883. ;
  884. #ELSE ;!_USE_THUMBSTICKS_ ;
  885. _UP2_Check_Up: ;
  886. CLRW ;
  887. XORWF Paddle_2_Y, W ;
  888. BTFSC STATUS, Z ;
  889. GOTO _UP2_Check_Down ;
  890. BTFSS PORTA, RBUTT_1_BIT ;
  891. DECF Paddle_2_Y, F ;
  892. _UP2_Check_Down: ;
  893. MOVLW NUM_LINES - PADDLE_HEIGHT ;
  894. XORWF Paddle_2_Y, W ;
  895. BTFSC STATUS, Z ;
  896. GOTO _UP2_Draw_Paddle ;
  897. BTFSS PORTA, RBUTT_2_BIT ;
  898. INCF Paddle_2_Y, F ;
  899. #ENDIF ;_USE_THUMBSTICKS_ ;
  900. ;
  901. _UP_Exit: ;
  902. RETURN ;
  903. ;---------------------------------------------------;
  904.  
  905. ;---------------------------------------------------;
  906. _Update_Ball: ;
  907. ;---------------------------------------------------;
  908. ; 60us BLACK line ;
  909. ;-----------------------------------------------;
  910. PAGESEL _Black_Line_60us ;
  911. CALL _Black_Line_60us ;
  912. PAGESEL $ ;
  913. ;
  914. _UB_Check_Wait: ;
  915. ;-----------------------------------------------;
  916. ; This is the delay so the ball isn't so fast ;
  917. ;-----------------------------------------------;
  918. DECFSZ Ball_Wait, F ;
  919. GOTO _UB_Exit ;
  920. ;
  921. MOVLW MAX_BALL_WAIT ;
  922. MOVWF Ball_Wait ;
  923. ;-----------------------------------------------;
  924. ;
  925. ;-----------------------------------------------;
  926. ; Is the ball moving? (Ball_Dir_X or Ball_Dir_Y ;
  927. ; not equal to zero?) If so, update the ball ;
  928. ; position. Otherwise, check for serve. ;
  929. ;-----------------------------------------------;
  930. CLRW ;
  931. XORWF Ball_Dir_X, W ;
  932. BTFSS STATUS, Z ;
  933. GOTO _UB_Update_Ball_X ;
  934. CLRW ;
  935. XORWF Ball_Dir_Y, W ;
  936. BTFSS STATUS, Z ;
  937. GOTO _UB_Update_Ball_X ;
  938. ;-----------------------------------------------;
  939. ;
  940. ;-----------------------------------------------;
  941. ; Check if left player pushed button to serve ;
  942. ;-----------------------------------------------;
  943. _UB_Check_L_Serve: ;
  944. BTFSS System_Status, P1_SERVICE_BIT ;
  945. GOTO _UB_Check_R_Serve ;
  946. BTFSC PORTA, LBUTT_BIT ;
  947. GOTO _UB_Check_L_Unpressed ;
  948. BTFSC System_Status, P1_PRESSED_BIT ;
  949. GOTO _UB_Check_R_Serve ;
  950. BSF System_Status, P1_PRESSED_BIT ;
  951. BCF System_Status, P1_SERVICE_BIT ;
  952. BCF System_Status, P2_SERVICE_BIT ;
  953. MOVLW 1 ;
  954. MOVWF Ball_Dir_X ;
  955. MOVFW Paddle_1_Y ;
  956. ADDLW PADDLE_HEIGHT / 2 ;
  957. SUBLW NUM_LINES / 2 ;
  958. MOVLW -2 ;
  959. BTFSC STATUS, C ;
  960. MOVLW 1 ;
  961. MOVWF Ball_Dir_Y ;
  962. MOVLW 2 ;
  963. MOVWF Ball_X ;
  964. MOVFW Paddle_1_Y ;
  965. ADDLW PADDLE_HEIGHT / 2 ;
  966. MOVWF Ball_Y ;
  967. GOTO _UB_Service ;
  968. _UB_Check_L_Unpressed: ;
  969. BCF System_Status, P1_PRESSED_BIT ;
  970. ;-----------------------------------------------;
  971. ;
  972. ;-----------------------------------------------;
  973. ; Check if right player pushed button to serve ;
  974. ;-----------------------------------------------;
  975. _UB_Check_R_Serve: ;
  976. BTFSC System_Status, P2_COMPUTER_BIT ;
  977. GOTO _UB_CRS_Computer ;
  978. ;-----------------------------------------------;
  979. _UB_CRS_Human: ;
  980. BTFSS System_Status, P2_SERVICE_BIT ;
  981. GOTO _UB_Exit ;
  982. BTFSC System_Status, BUZZ_BIT ;
  983. GOTO _UB_Exit ;
  984. BANKSEL TRISA ;
  985. BSF TRISA, RBUTT_BIT ; Set as input (for BUTTON)
  986. BANKSEL PORTA ;
  987. BTFSC PORTA, RBUTT_BIT ;
  988. GOTO _UB_CRS_Unpressed ;
  989. BANKSEL TRISA ;
  990. BCF TRISA, RBUTT_BIT ; Set as output (for AUDIO)
  991. BANKSEL MEMORY ;
  992. BTFSC System_Status, P2_PRESSED_BIT ;
  993. GOTO _UB_Exit ;
  994. BANKSEL TRISA ;
  995. BCF TRISA, RBUTT_BIT ; Set as output (for AUDIO)
  996. BANKSEL MEMORY ;
  997. GOTO _UB_CRS_Init ;
  998. ;-----------------------------------------------;
  999. ;
  1000. ;-----------------------------------------------;
  1001. _UB_CRS_Computer: ;
  1002. BTFSS System_Status, P1_SERVICE_BIT ;
  1003. BTFSS System_Status, P2_SERVICE_BIT ;
  1004. GOTO _UB_CRS_Unpressed ;
  1005. BTFSC System_Status, P2_PRESSED_BIT ;
  1006. ;-----------------------------------------------;
  1007. ;
  1008. ;-----------------------------------------------;
  1009. _UB_CRS_Init: ;
  1010. BSF System_Status, P2_PRESSED_BIT ;
  1011. BCF System_Status, P1_SERVICE_BIT ;
  1012. BCF System_Status, P2_SERVICE_BIT ;
  1013. MOVLW -1 ;
  1014. MOVWF Ball_Dir_X ;
  1015. MOVFW Paddle_2_Y ;
  1016. ADDLW PADDLE_HEIGHT / 2 ;
  1017. SUBLW NUM_LINES / 2 ;
  1018. MOVLW -1 ;
  1019. BTFSC STATUS, C ;
  1020. MOVLW 2 ;
  1021. MOVWF Ball_Dir_Y ;
  1022. MOVLW 29 ;
  1023. MOVWF Ball_X ;
  1024. MOVFW Paddle_2_Y ;
  1025. ADDLW PADDLE_HEIGHT / 2 ;
  1026. MOVWF Ball_Y ;
  1027. GOTO _UB_Service ;
  1028. ;-----------------------------------------------;
  1029. ;
  1030. ;-----------------------------------------------;
  1031. _UB_CRS_Unpressed: ;
  1032. BCF System_Status, P2_PRESSED_BIT ;
  1033. GOTO _UB_Exit ;
  1034. ;-----------------------------------------------;
  1035. ;
  1036. ;-----------------------------------------------;
  1037. _UB_Service: ;
  1038. MOVLW H'11' ;
  1039. XORWF Score_1, W ;
  1040. BTFSC STATUS, Z ;
  1041. GOTO $+5 ;
  1042. MOVLW H'11' ;
  1043. XORWF Score_2, W ;
  1044. BTFSS STATUS, Z ;
  1045. GOTO _UB_Exit ;
  1046. CLRF Score_1 ;
  1047. CLRF Score_2 ;
  1048. GOTO _UB_Exit ;
  1049. ;-----------------------------------------------;
  1050. ;
  1051. ;-----------------------------------------------;
  1052. _UB_Update_Ball_X: ;
  1053. MOVFW Ball_Dir_X ; Update Ball X Position
  1054. ADDWF Ball_X, F ;
  1055. ;-----------------------------------------------;
  1056. ;
  1057. ;-----------------------------------------------;
  1058. _UB_Update_Ball_X_Min: ;
  1059. MOVLW 0 ;
  1060. XORWF Ball_X, W ;
  1061. BTFSS STATUS, Z ;
  1062. GOTO _UB_Update_Ball_X_Max ;
  1063. MOVLW 1 ;
  1064. MOVWF Ball_Dir_X ;
  1065. ;
  1066. INCF Score_2, F ;
  1067. PLAY_SOUND 24, H'017F' ; Frequency, Duration
  1068. BCF System_Status, P1_SERVICE_BIT ;
  1069. BSF System_Status, P2_SERVICE_BIT ;
  1070. MOVLW 0 ;
  1071. MOVWF Ball_Dir_X ;
  1072. MOVWF Ball_Dir_Y ;
  1073. MOVLW 15 ;
  1074. MOVWF Ball_X ;
  1075. MOVLW 27 ;
  1076. MOVWF Ball_Y ;
  1077. MOVFW Score_2 ;
  1078. ANDLW H'0F' ;
  1079. XORLW H'0A' ;
  1080. BTFSS STATUS, Z ;
  1081. GOTO _UB_BXMin_Exit ;
  1082. MOVFW Score_2 ;
  1083. ANDLW H'F0' ;
  1084. ADDLW H'10' ;
  1085. MOVWF Score_2 ;
  1086. MOVLW H'A0' ;
  1087. XORWF Score_2, W ;
  1088. BTFSC STATUS, Z ;
  1089. CLRF Score_2 ;
  1090. _UB_BXMin_Exit: ;
  1091. MOVLW H'11' ;
  1092. XORWF Score_2, W ;
  1093. BTFSS STATUS, Z ;
  1094. GOTO _UB_Exit ;
  1095. BSF System_Status, P1_SERVICE_BIT ;
  1096. BSF System_Status, P2_SERVICE_BIT ;
  1097. GOTO _UB_Exit ;
  1098. ;-----------------------------------------------;
  1099. ;
  1100. ;-----------------------------------------------;
  1101. _UB_Update_Ball_X_Max: ;
  1102. MOVLW 31 ;
  1103. XORWF Ball_X, W ;
  1104. BTFSS STATUS, Z ;
  1105. GOTO _UB_Update_Ball_Y ;
  1106. MOVLW -1 ;
  1107. MOVWF Ball_Dir_X ;
  1108. ;
  1109. INCF Score_1, F ;
  1110. PLAY_SOUND 24, H'017F' ; Frequency, Duration
  1111. BSF System_Status, P1_SERVICE_BIT ;
  1112. BCF System_Status, P2_SERVICE_BIT ;
  1113. MOVLW 0 ;
  1114. MOVWF Ball_Dir_X ;
  1115. MOVWF Ball_Dir_Y ;
  1116. MOVLW 15 ;
  1117. MOVWF Ball_X ;
  1118. MOVLW 27 ;
  1119. MOVWF Ball_Y ;
  1120. MOVFW Score_1 ;
  1121. ANDLW H'0F' ;
  1122. XORLW H'0A' ;
  1123. BTFSS STATUS, Z ;
  1124. GOTO _UB_BXMax_Exit ;
  1125. MOVFW Score_1 ;
  1126. ANDLW H'F0' ;
  1127. ADDLW H'10' ;
  1128. MOVWF Score_1 ;
  1129. MOVLW H'A0' ;
  1130. XORWF Score_1, W ;
  1131. BTFSC STATUS, Z ;
  1132. CLRF Score_1 ;
  1133. _UB_BXMax_Exit: ;
  1134. MOVLW H'11' ;
  1135. XORWF Score_1, W ;
  1136. BTFSS STATUS, Z ;
  1137. GOTO _UB_Exit ;
  1138. BSF System_Status, P1_SERVICE_BIT ;
  1139. BSF System_Status, P2_SERVICE_BIT ;
  1140. GOTO _UB_Exit ;
  1141. ;-----------------------------------------------;
  1142. ;
  1143. ;-----------------------------------------------;
  1144. ; Update Ball_Y position ;
  1145. ;-----------------------------------------------;
  1146. _UB_Update_Ball_Y: ;
  1147. MOVFW Ball_Dir_Y ;
  1148. ADDWF Ball_Y, F ;
  1149. ;-----------------------------------------------;
  1150. ;
  1151. ;-----------------------------------------------;
  1152. ; Check for collision with upper sideline ;
  1153. ;-----------------------------------------------;
  1154. _UB_Update_Ball_Y_Min: ;
  1155. BTFSS Ball_Y, MSB ;
  1156. GOTO _UB_Update_Ball_Y_Max ;
  1157. COMF Ball_Y, F ;
  1158. COMF Ball_Dir_Y, F ;
  1159. INCF Ball_Dir_Y, F ;
  1160. ;-----------------------------------------------;
  1161. ; Play the 'Ball Hit Sideline' sound ;
  1162. ;-----------------------------------------------;
  1163. PLAY_SOUND 6, H'017F' ; Frequency, Duration
  1164. GOTO _UB_Paddle_Detect_Left ;
  1165. ;-----------------------------------------------;
  1166. ;
  1167. ;-----------------------------------------------;
  1168. ; Check for collision with lower sideline ;
  1169. ;-----------------------------------------------;
  1170. _UB_Update_Ball_Y_Max: ;
  1171. MOVLW NUM_LINES - 2 ;
  1172. SUBWF Ball_Y, W ;
  1173. BTFSS STATUS, C ;
  1174. GOTO _UB_Paddle_Detect_Left ;
  1175. MOVLW NUM_LINES - 2 ;
  1176. MOVWF Ball_Y ;
  1177. COMF Ball_Dir_Y, F ;
  1178. INCF Ball_Dir_Y, F ;
  1179. ;-----------------------------------------------;
  1180. ; Play the 'Ball Hit Wall' sound ;
  1181. ;-----------------------------------------------;
  1182. PLAY_SOUND 6, H'017F' ; Frequency, Duration
  1183. ;-----------------------------------------------;
  1184. ;
  1185. ;-----------------------------------------------;
  1186. ; Check for collision with left paddle ;
  1187. ;-----------------------------------------------;
  1188. _UB_Paddle_Detect_Left: ;
  1189. ;-----------------------------------------------;
  1190. ; On the same vertical line as the left paddle? ;
  1191. ;-----------------------------------------------;
  1192. MOVLW 1 ;
  1193. XORWF Ball_X, W ;
  1194. BTFSS STATUS, Z ;
  1195. GOTO _UB_Paddle_Detect_Right ;
  1196. ;
  1197. MOVFW Paddle_1_Y ;
  1198. MOVWF Temp1 ;
  1199. GOTO _UB_PD_Check_Hit ;
  1200. ;
  1201. ;-----------------------------------------------;
  1202. ; Check for collision with right paddle ;
  1203. ;-----------------------------------------------;
  1204. _UB_Paddle_Detect_Right: ;
  1205. ;-----------------------------------------------;
  1206. ; On the same vertical line as the right paddle?;
  1207. ;-----------------------------------------------;
  1208. MOVLW 30 ;
  1209. XORWF Ball_X, W ;
  1210. BTFSS STATUS, Z ;
  1211. GOTO _UB_Exit ;
  1212. MOVFW Paddle_2_Y ;
  1213. MOVWF Temp1 ;
  1214. ;-----------------------------------------------;
  1215. ;
  1216. _UB_PD_Check_Hit: ;
  1217. ;-----------------------------------------------;
  1218. ; Are we on the save horizontal plane as the ;
  1219. ; paddle? ;
  1220. ;-----------------------------------------------;
  1221. MOVFW Ball_Y ;
  1222. ADDLW BALL_HEIGHT ;
  1223. SUBWF Temp1, W ;
  1224. BTFSC STATUS, C ;
  1225. GOTO _UB_Exit ;
  1226. ;
  1227. MOVFW Temp1 ;
  1228. ADDLW PADDLE_HEIGHT - 1 ;
  1229. MOVWF Temp2 ;
  1230. MOVFW Ball_Y ;
  1231. SUBWF Temp2, W ;
  1232. BTFSS STATUS, C ;
  1233. GOTO _UB_Exit ;
  1234. ;
  1235. _UB_PD_Its_A_Hit: ;
  1236. ;-----------------------------------------------;
  1237. ; Reverse the ball 'X' direction ;
  1238. ;-----------------------------------------------;
  1239. COMF Ball_Dir_X, F ;
  1240. INCF Ball_Dir_X, F ;
  1241. ;-----------------------------------------------;
  1242. ; Adjust the ball 'X' position ;
  1243. ;-----------------------------------------------;
  1244. MOVFW Ball_Dir_X ;
  1245. ADDWF Ball_X, F ;
  1246. ;-----------------------------------------------;
  1247. ; Play the 'Ball Hit Paddle' sound ;
  1248. ;-----------------------------------------------;
  1249. PLAY_SOUND 8, H'014F' ; Frequency, Duration
  1250. ;-----------------------------------------------;
  1251. ;
  1252. ;-----------------------------------------------;
  1253. ; Ball update done. Restore RBUTT as an output ;
  1254. ; for sound and wait for 60us to pass. ;
  1255. ;-----------------------------------------------;
  1256. _UB_Exit: ;
  1257. BANKSEL TRISA ;
  1258. BCF TRISA, RBUTT_BIT ; Set as OUTPUT (for AUDIO)
  1259. BANKSEL MEMORY ;
  1260. ;
  1261. RETURN ;
  1262. ;---------------------------------------------------;
  1263.  
  1264. ;---------------------------------------------------;
  1265. _Draw_Items: ;
  1266. ;---------------------------------------------------;
  1267. ;-----------------------------------------------;
  1268. ; 60us BLACK Line ;
  1269. ;-----------------------------------------------;
  1270. START_TIMING SIG_4US, SIG_60US ;
  1271. ;-----------------------------------------------;
  1272. ;
  1273. _DI_Draw_Service_Player_1: ;
  1274. MOVLW LOW VIDEO_BUFFER_START + SERVICE_1_START;
  1275. MOVWF FSR1L ;
  1276. MOVLW HIGH VIDEO_BUFFER_START ;
  1277. MOVWF FSR1H ;
  1278. MOVLW LOW SERVICE_TABLE ;
  1279. MOVWF FSR0L ;
  1280. MOVLW HIGH SERVICE_TABLE ;
  1281. MOVWF FSR0H ;
  1282. MOVLW (SERVICE_TABLE_END - SERVICE_TABLE_START) / 2
  1283. MOVWF Temp1 ;
  1284. _DI_DSP1_Next_Byte: ;
  1285. MOVFW INDF0 ;
  1286. BTFSS System_Status, P1_SERVICE_BIT ;
  1287. CLRW ;
  1288. BTFSC System_Status, P2_SERVICE_BIT ;
  1289. CLRW ;
  1290. MOVWF INDF1 ;
  1291. ADDFSR FSR0, 1 ;
  1292. ADDFSR FSR1, 4 ;
  1293. DECFSZ Temp1, F ;
  1294. GOTO _DI_DSP1_Next_Byte ;
  1295. ;
  1296. _DI_Draw_Service_Player_2: ;
  1297. MOVLW LOW VIDEO_BUFFER_START + SERVICE_2_START;
  1298. MOVWF FSR1L ;
  1299. MOVLW HIGH VIDEO_BUFFER_START ;
  1300. MOVWF FSR1H ;
  1301. MOVLW LOW SERVICE_TABLE ;
  1302. MOVWF FSR0L ;
  1303. MOVLW HIGH SERVICE_TABLE ;
  1304. MOVWF FSR0H ;
  1305. MOVLW (SERVICE_TABLE_END - SERVICE_TABLE_START) / 2
  1306. MOVWF Temp1 ;
  1307. ADDWF FSR0L, F ;
  1308. _DI_DSP2_Next_Byte: ;
  1309. MOVFW INDF0 ;
  1310. BTFSS System_Status, P2_SERVICE_BIT ;
  1311. CLRW ;
  1312. BTFSC System_Status, P1_SERVICE_BIT ;
  1313. CLRW ;
  1314. MOVWF INDF1 ;
  1315. ADDFSR FSR0, 1 ;
  1316. ADDFSR FSR1, 4 ;
  1317. DECFSZ Temp1, F ;
  1318. GOTO _DI_DSP2_Next_Byte ;
  1319. ;
  1320. _DI_Draw_Score1: ;
  1321. _DI_DS1_Draw_Left_Char: ;
  1322. SWAPF Score_1, W ;
  1323. ANDLW H'0F' ;
  1324. MOVWF Temp1 ;
  1325. ;
  1326. MOVLW LOW VIDEO_BUFFER_START + LEFT_SCORE_START
  1327. MOVWF FSR1L ;
  1328. MOVLW HIGH VIDEO_BUFFER_START ;
  1329. MOVWF FSR1H ;
  1330. ;
  1331. MOVLW HIGH CHARACTER_TABLE ;
  1332. MOVWF FSR0H ;
  1333. MOVLW LOW CHARACTER_TABLE ;
  1334. ADDWF Temp1, W ;
  1335. BTFSC STATUS, C ;
  1336. INCF FSR0H, F ;
  1337. MOVWF FSR0L ;
  1338. ;
  1339. MOVLW 5 ;
  1340. MOVWF Temp1 ;
  1341. _DI_DS1_DLC_Next_Line: ;
  1342. MOVFW INDF0 ;
  1343. MOVWF DTemp ;
  1344. RRF DTemp, W ;
  1345. ANDLW H'70' ;
  1346. MOVWF INDF1 ;
  1347. ADDFSR FSR0, 10 ;
  1348. ADDFSR FSR1, 4 ;
  1349. DECFSZ Temp1, F ;
  1350. GOTO _DI_DS1_DLC_Next_Line ;
  1351. ;
  1352. _DI_DS1_Draw_Right_Char: ;
  1353. MOVFW Score_1 ;
  1354. ANDLW H'0F' ;
  1355. MOVWF Temp1 ;
  1356. ;
  1357. MOVLW LOW VIDEO_BUFFER_START + LEFT_SCORE_START
  1358. MOVWF FSR1L ;
  1359. MOVLW HIGH VIDEO_BUFFER_START ;
  1360. MOVWF FSR1H ;
  1361. ;
  1362. MOVLW HIGH CHARACTER_TABLE ;
  1363. MOVWF FSR0H ;
  1364. MOVLW LOW CHARACTER_TABLE ;
  1365. ADDWF Temp1, W ;
  1366. BTFSC STATUS, C ;
  1367. INCF FSR0H, F ;
  1368. MOVWF FSR0L ;
  1369. ;
  1370. MOVLW 5 ;
  1371. MOVWF Temp1 ;
  1372. _DI_DS1_DRC_Next_Line: ;
  1373. MOVFW INDF0 ;
  1374. MOVWF DTemp ;
  1375. RRF DTemp, W ;
  1376. ANDLW H'07' ;
  1377. MOVWF DTemp ;
  1378. MOVFW INDF1 ;
  1379. IORWF DTemp, W ;
  1380. MOVWF INDF1 ;
  1381. ADDFSR FSR0, 10 ;
  1382. ADDFSR FSR1, 4 ;
  1383. DECFSZ Temp1, F ;
  1384. GOTO _DI_DS1_DRC_Next_Line ;
  1385. ;
  1386. _DI_Draw_Score2: ;
  1387. _DI_DS2_Draw_Left_Char: ;
  1388. SWAPF Score_2, W ;
  1389. ANDLW H'0F' ;
  1390. MOVWF Temp1 ;
  1391. ;
  1392. MOVLW LOW VIDEO_BUFFER_START + RIGHT_SCORE_START
  1393. MOVWF FSR1L ;
  1394. MOVLW HIGH VIDEO_BUFFER_START ;
  1395. MOVWF FSR1H ;
  1396. ;
  1397. MOVLW HIGH CHARACTER_TABLE ;
  1398. MOVWF FSR0H ;
  1399. MOVLW LOW CHARACTER_TABLE ;
  1400. ADDWF Temp1, W ;
  1401. BTFSC STATUS, C ;
  1402. INCF FSR0H, F ;
  1403. MOVWF FSR0L ;
  1404. ;
  1405. MOVLW 5 ;
  1406. MOVWF Temp1 ;
  1407. _DI_DS2_DLC_Next_Line: ;
  1408. MOVFW INDF0 ;
  1409. ANDLW H'E0' ;
  1410. MOVWF INDF1 ;
  1411. ADDFSR FSR0, 10 ;
  1412. ADDFSR FSR1, 4 ;
  1413. DECFSZ Temp1, F ;
  1414. GOTO _DI_DS2_DLC_Next_Line ;
  1415. ;
  1416. _DI_DS2_Draw_Right_Char: ;
  1417. MOVFW Score_2 ;
  1418. ANDLW H'0F' ;
  1419. MOVWF Temp1 ;
  1420. ;
  1421. MOVLW LOW VIDEO_BUFFER_START + RIGHT_SCORE_START
  1422. MOVWF FSR1L ;
  1423. MOVLW HIGH VIDEO_BUFFER_START ;
  1424. MOVWF FSR1H ;
  1425. ;
  1426. MOVLW HIGH CHARACTER_TABLE ;
  1427. MOVWF FSR0H ;
  1428. MOVLW LOW CHARACTER_TABLE ;
  1429. ADDWF Temp1, W ;
  1430. BTFSC STATUS, C ;
  1431. INCF FSR0H, F ;
  1432. MOVWF FSR0L ;
  1433. MOVLW 5 ;
  1434. MOVWF Temp1 ;
  1435. _DI_DS2_DRC_Next_Line: ;
  1436. MOVFW INDF0 ;
  1437. ANDLW H'0E' ;
  1438. MOVWF DTemp ;
  1439. MOVFW INDF1 ;
  1440. IORWF DTemp, W ;
  1441. MOVWF INDF1 ;
  1442. ADDFSR FSR0, 10 ;
  1443. ADDFSR FSR1, 4 ;
  1444. DECFSZ Temp1, F ;
  1445. GOTO _DI_DS2_DRC_Next_Line ;
  1446. ;
  1447. ;-----------------------------------------------;
  1448. ; 60us BLACK Line ;
  1449. ;-----------------------------------------------;
  1450. START_TIMING SIG_4US, SIG_60US ;
  1451. ;-----------------------------------------------;
  1452. ;
  1453. _DI_Draw_Computer_Player_2: ;
  1454. BTFSS System_Status, P2_COMPUTER_BIT ;
  1455. GOTO _DI_DCP2_Done ;
  1456. MOVLW LOW VIDEO_BUFFER_START + COMPUTER_2_START
  1457. MOVWF FSR1L ;
  1458. MOVLW HIGH VIDEO_BUFFER_START ;
  1459. MOVWF FSR1H ;
  1460. MOVLW LOW COMPUTER_2_TABLE ;
  1461. MOVWF FSR0L ;
  1462. MOVLW HIGH COMPUTER_2_TABLE ;
  1463. MOVWF FSR0H ;
  1464. MOVLW COMPUTER_2_TABLE_END - COMPUTER_2_TABLE_START
  1465. MOVWF Temp1 ;
  1466. _DI_DCP2_Next_Byte: ;
  1467. MOVFW INDF0 ;
  1468. IORWF INDF1 ;
  1469. ADDFSR FSR0, 1 ;
  1470. ADDFSR FSR1, 4 ;
  1471. DECFSZ Temp1, F ;
  1472. GOTO _DI_DCP2_Next_Byte ;
  1473. _DI_DCP2_Done: ;
  1474. ;
  1475. _DI_Draw_Paddle_1: ;
  1476. MOVFW Paddle_1_Y ;
  1477. ADDWF Paddle_1_Y, W ;
  1478. ADDWF Paddle_1_Y, W ;
  1479. ADDWF Paddle_1_Y, W ;
  1480. ADDLW LOW VIDEO_BUFFER_START + LEFT_PADDLE_START
  1481. MOVWF FSR1L ;
  1482. MOVLW HIGH VIDEO_BUFFER_START ;
  1483. MOVLW PADDLE_HEIGHT ;
  1484. MOVWF Temp1 ;
  1485. _DI_DP1_Next_Bit: ;
  1486. MOVFW INDF1 ;
  1487. IORLW LEFT_PADDLE_BIT ;
  1488. MOVWF INDF1 ;
  1489. ADDFSR FSR1, 4 ;
  1490. DECFSZ Temp1, F ;
  1491. GOTO _DI_DP1_Next_Bit ;
  1492. ;
  1493. _DI_Draw_Paddle_2: ;
  1494. MOVFW Paddle_2_Y ;
  1495. ADDWF Paddle_2_Y, W ;
  1496. ADDWF Paddle_2_Y, W ;
  1497. ADDWF Paddle_2_Y, W ;
  1498. ADDLW LOW VIDEO_BUFFER_START + RIGHT_PADDLE_START;
  1499. MOVWF FSR1L ;
  1500. MOVLW HIGH VIDEO_BUFFER_START ;
  1501. MOVWF FSR1H ;
  1502. MOVLW PADDLE_HEIGHT ;
  1503. MOVWF Temp1 ;
  1504. _DI_DP2_Next_Bit: ;
  1505. MOVFW INDF1 ;
  1506. IORLW RIGHT_PADDLE_BIT ;
  1507. MOVWF INDF1 ;
  1508. ADDFSR FSR1, 4 ;
  1509. DECFSZ Temp1, F ;
  1510. GOTO _DI_DP2_Next_Bit ;
  1511. ;
  1512. _DI_Draw_Ball: ;
  1513. ;-----------------------------------------------;
  1514. ; Check to see if the ball has any movement. If ;
  1515. ; not, we are either at the end of a game or ;
  1516. ; waiting for service. In that case, don't draw ;
  1517. ; the ball. ;
  1518. ;-----------------------------------------------;
  1519. CLRW ;
  1520. XORWF Ball_Dir_X, W ;
  1521. BTFSS STATUS, Z ;
  1522. GOTO _DI_DB_Draw ;
  1523. CLRW ;
  1524. XORWF Ball_Dir_Y, W ;
  1525. BTFSC STATUS, Z ;
  1526. GOTO _DI_Exit ;
  1527. MOVLW 1 ;
  1528. XORWF Ball_Wait, W ;
  1529. BTFSS STATUS, Z ;
  1530. GOTO _DI_Exit ;
  1531. ;
  1532. _DI_DB_Draw: ;
  1533. ;-----------------------------------------------;
  1534. ; This is where we actually 'draw' the ball. ;
  1535. ;-----------------------------------------------;
  1536. MOVFW Ball_Y ;
  1537. ADDWF Ball_Y, W ;
  1538. ADDWF Ball_Y, W ;
  1539. ADDWF Ball_Y, W ;
  1540. ADDLW LOW VIDEO_BUFFER_START ;
  1541. MOVWF FSR1L ;
  1542. RRF Ball_X, W ;
  1543. MOVWF Temp1 ;
  1544. RRF Temp1, F ;
  1545. RRF Temp1, W ;
  1546. ANDLW H'1F' ;
  1547. ADDWF FSR1L, F ;
  1548. MOVLW HIGH VIDEO_BUFFER_START ;
  1549. MOVWF FSR1H ;
  1550. ;
  1551. MOVFW Ball_X ;
  1552. ANDLW H'07' ;
  1553. MOVWF Temp1 ;
  1554. MOVLW H'80' ;
  1555. MOVWF DTemp ;
  1556. MOVLW 0 ; ;
  1557. XORWF Temp1, W ;
  1558. BTFSC STATUS, Z ;
  1559. GOTO $+5 ;
  1560. DECF Temp1, F ;
  1561. RRF DTemp, F ;
  1562. BCF DTemp, MSB ;
  1563. GOTO $-7 ;
  1564. ;
  1565. MOVLW BALL_HEIGHT ;
  1566. MOVWF Temp1 ;
  1567. MOVFW DTemp ;
  1568. _DI_DB_D_Next_Pixel: ;
  1569. XORWF INDF1, F ;
  1570. ADDFSR FSR1, 4 ;
  1571. DECFSZ Temp1, F ;
  1572. GOTO _DI_DB_D_Next_Pixel ;
  1573. ;
  1574. _DI_Exit: ;
  1575. RETURN ;
  1576. ;---------------------------------------------------;
  1577.  
  1578. ;---------------------------------------------------;
  1579. USER_CODE_2 CODE H'800' ;
  1580. ;---------------------------------------------------;
  1581. ;---------------------------------------------------;
  1582. _Initialize_System: ;
  1583. ;---;-----------------------------------------------;
  1584. ; Initialize Hardware ;
  1585. ;-----------------------------------------------;
  1586. ; - Oscillator ;
  1587. ;-----------------------------------------------;
  1588. _IS_Init_Oscillator: ;
  1589. BANKSEL OSCCON ;
  1590. MOVLW B'11110000' ; 32Mhz
  1591. MOVWF OSCCON ;
  1592. ;
  1593. BANKSEL OSCSTAT ; Wait for
  1594. _IS_IO_Wait: ;
  1595. MOVFW OSCSTAT ; high speed
  1596. ANDLW H'79' ; oscillator
  1597. XORLW H'59' ; to be
  1598. BTFSS STATUS, Z ; stable and
  1599. GOTO _IS_IO_Wait ; locked
  1600. ;-----------------------------------------------;
  1601. ;
  1602. ;-----------------------------------------------;
  1603. ; - GPIOs ;
  1604. ;-----------------------------------------------;
  1605. _IS_Init_GPIOs: ;
  1606. BANKSEL ANSELA ;
  1607. CLRF ANSELA ; ALL I/O as digital
  1608. #IF _USE_THUMBSTICKS_ ;
  1609. BSF ANSELA, LJOY_BIT ;
  1610. BSF ANSELA, RJOY_BIT ;
  1611. #ENDIF ;_USE_THUMBSTICKS_ ;
  1612. ;
  1613. BANKSEL LATA ;
  1614. CLRF LATA ;
  1615. ;
  1616. BANKSEL TRISA ;
  1617. CLRF TRISA ;
  1618. BCF TRISA, VIDEO_0_BIT ; Set as OUTPUT
  1619. BCF TRISA, VIDEO_1_BIT ; Set as OUTPUT
  1620. BCF TRISA, AUDIO_BIT ; Set as OUTPUT
  1621. #IF _USE_THUMBSTICKS_ ;
  1622. BSF TRISA, LJOY_BIT ; Set as INPUT
  1623. BSF TRISA, LBUTT_BIT ; Set as INPUT
  1624. BSF TRISA, RJOY_BIT ; Set as INPUT
  1625. BCF TRISA, RBUTT_BIT ; Set as OUTPUT (AUDIO)
  1626. #ELSE ;!_USE_THUMBSTICKS_ ;
  1627. BSF TRISA, LBUTT_1_BIT ; Set as INPUT
  1628. BSF TRISA, LBUTT_2_BIT ; Set as INPUT
  1629. BSF TRISA, RBUTT_1_BIT ; Set as INPUT
  1630. BSF TRISA, RBUTT_2_BIT ; Set as INPUT
  1631. #ENDIF ;_USE_THUMBSTICKS_ ;
  1632. ;
  1633. BANKSEL PORTA ;
  1634. CLRF PORTA ;
  1635. BCF PORTA, VIDEO_0_BIT ; Set LOW
  1636. BCF PORTA, VIDEO_1_BIT ; Set LOW
  1637. BSF PORTA, AUDIO_BIT ; Set HIGH
  1638. #IF _USE_THUMBSTICKS_ ;
  1639. BSF PORTA, LJOY_BIT ; Set HIGH
  1640. BSF PORTA, LBUTT_BIT ; Set HIGH
  1641. BSF PORTA, RJOY_BIT ; Set HIGH
  1642. BSF PORTA, RBUTT_BIT ; Set HIGH
  1643. #ELSE ;!_USE_THUMBSTICKS_ ;
  1644. BSF PORTA, LBUTT_1_BIT ; Set HIGH
  1645. BSF PORTA, LBUTT_2_BIT ; Set HIGH
  1646. BSF PORTA, RBUTT_1_BIT ; Set HIGH
  1647. BSF PORTA, RBUTT_2_BIT ; Set HIGH
  1648. #ENDIF ;_USE_THUMBSTICKS_ ;
  1649. ;-----------------------------------------------;
  1650. ;
  1651. ;-----------------------------------------------;
  1652. ; - Miscellaneous ;
  1653. ;-----------------------------------------------;
  1654. _IS_Init_Misc: ;
  1655. BANKSEL INTCON ;
  1656. CLRF INTCON ;
  1657. ;
  1658. BANKSEL OPTION_REG ;
  1659. CLRF OPTION_REG ;
  1660. ;-----------------------------------------------;
  1661. ;
  1662. ;-----------------------------------------------;
  1663. ; - Timer0 ;
  1664. ;-----------------------------------------------;
  1665. _IS_Init_Timer0: ;
  1666. BANKSEL OPTION_REG ;
  1667. BCF OPTION_REG, NOT_WPUEN ;
  1668. BCF OPTION_REG, TMR0CS ;
  1669. BCF OPTION_REG, PSA ; prescaler to timer0
  1670. BCF OPTION_REG, PS2 ;
  1671. BCF OPTION_REG, PS1 ; 000 - 250ns
  1672. BCF OPTION_REG, PS0 ;
  1673. ;
  1674. BANKSEL TMR0 ;
  1675. MOVLW H'15' ;
  1676. MOVWF TMR0 ;
  1677. MOVWF Vid_Timing ;
  1678. MOVWF Next_Vid_Timing ;
  1679. ;
  1680. BANKSEL INTCON ;
  1681. BCF INTCON, TMR0IF ;
  1682. BSF INTCON, TMR0IE ;
  1683. BSF INTCON, GIE ;
  1684. ;-----------------------------------------------;
  1685. ;
  1686. ;-----------------------------------------------;
  1687. ; - Memory ;
  1688. ;-----------------------------------------------;
  1689. _IS_Init_Memory: ;
  1690. BANKSEL MEMORY ;
  1691. CLRF System_Status ;
  1692. BSF System_Status, P1_SERVICE_BIT ;
  1693. BSF System_Status, P2_SERVICE_BIT ;
  1694. BSF System_Status, VERTICAL_SYNC_BIT ;
  1695. BCF System_Status, BUZZ_BIT ;
  1696. MOVLW 0 ;
  1697. MOVWF Buzz_Count ;
  1698. MOVWF Buzz_Reload ;
  1699. MOVLW H'FF' ;
  1700. MOVWF Buzz_Dur_LO ;
  1701. MOVLW H'FF' ;
  1702. MOVWF Buzz_Dur_HI ;
  1703. MOVLW MAX_BALL_WAIT ;
  1704. MOVWF Ball_Wait ;
  1705. MOVLW 0 ;
  1706. MOVWF Score_1 ;
  1707. MOVLW 0 ;
  1708. MOVWF Score_2 ;
  1709. MOVLW 20 ;
  1710. MOVWF Paddle_1_Y ;
  1711. MOVLW 20 ;
  1712. MOVWF Paddle_2_Y ;
  1713. MOVLW 15 ;
  1714. MOVWF Ball_X ;
  1715. MOVLW 27 ;
  1716. MOVWF Ball_Y ;
  1717. MOVLW 0 ;
  1718. MOVWF Ball_Dir_X ;
  1719. MOVLW 0 ;
  1720. MOVWF Ball_Dir_Y ;
  1721. ;-----------------------------------------------;
  1722. ;
  1723. ;-----------------------------------------------;
  1724. ; - Video Buffer ;
  1725. ;-----------------------------------------------;
  1726. _IS_Clear_Video: ;
  1727. PAGESEL _Clear_Screen ;
  1728. CALL _Clear_Screen ;
  1729. PAGESEL $ ;
  1730. ;-----------------------------------------------;
  1731. ;
  1732. ;-----------------------------------------------;
  1733. ; - Other Subsystems ;
  1734. ;-----------------------------------------------;
  1735. ;-----------------------------------------------;
  1736. ;
  1737. ;-----------------------------------------------;
  1738. ; This will shake loose the PICKIT, if attached ;
  1739. ;-----------------------------------------------;
  1740. _IS_Shake_Loose_PICKIT: ;
  1741. BANKSEL TRISA ;
  1742. BCF TRISA, RBUTT_BIT ;
  1743. BANKSEL PORTA ;
  1744. BSF PORTA, RBUTT_BIT ;
  1745. _IS_SLP_Wait_For_Button: ;
  1746. DELAY 255 ;
  1747. DELAY 255 ;
  1748. DELAY 255 ;
  1749. DELAY 255 ;
  1750. DELAY 255 ;
  1751. DELAY 255 ;
  1752. DELAY 255 ;
  1753. DELAY 255 ;
  1754. BANKSEL TRISA ;
  1755. BSF TRISA, RBUTT_BIT ;
  1756. BANKSEL PORTA ;
  1757. BTFSS PORTA, RBUTT_BIT ;
  1758. GOTO _IS_SLP_Wait_For_Button ;
  1759. BANKSEL TRISA ;
  1760. BCF TRISA, RBUTT_BIT ;
  1761. BANKSEL PORTA ;
  1762. BSF PORTA, RBUTT_BIT ;
  1763. ;-----------------------------------------------;
  1764. ;
  1765. ;-----------------------------------------------;
  1766. ; This will see if BUTTON 1 (left player) is ;
  1767. ; being pressed at power up. If so, PLAYER 2 ;
  1768. ; will be flagged as a COMPUTER PLAYER. ;
  1769. ;-----------------------------------------------;
  1770. _IS_Check_For_Computer_Option: ;
  1771. BTFSC PORTA, LBUTT_BIT ;
  1772. GOTO _IS_Exit ;
  1773. BSF System_Status, P2_COMPUTER_BIT ;
  1774. BSF System_Status, P1_PRESSED_BIT ;
  1775. ; BTFSS PORTA, LBUTT_BIT ;
  1776. ; GOTO $-1 ;
  1777. ;-----------------------------------------------;
  1778. ;
  1779. _IS_Exit: ;
  1780. ; PAGESEL _Next_Frame ;
  1781. ; GOTO _Next_Frame ;
  1782. ;---------------------------------------------------;
  1783.  
  1784. ;---------------------------------------------------;
  1785. _Next_Frame: ;
  1786. ;---------------------------------------------------;
  1787. ; VERTICAL SYNC PULSE Time ;
  1788. ; This consists of 5 blank half lines, ;
  1789. ; 4 inverted half lines, and 5 more blank half ;
  1790. ; lines. This totals 7 full lines of 64us each. ;
  1791. ; --------------------------------------------- ;
  1792. ; NOTE: Timing is CRITICAL for a nice, clean ;
  1793. ; display. If you notice the top part of the ;
  1794. ; display is skewed or "tearing", your timings ;
  1795. ; are wrong and need to be adjusted. Make sure ;
  1796. ; you haven't inadvertently dropped a half frame;
  1797. ;-----------------------------------------------;
  1798. ; First, a special blank 30us line. If _DEBUG_ ;
  1799. ; is enabled, it will produce a pulse on the ;
  1800. ; GPIO2 pin for debugging purposes (checking the;
  1801. ; time elapsed for a single video frame). ;
  1802. ;-----------------------------------------------;
  1803. PAGESEL _Vertical_Sync ;
  1804. CALL _Vertical_Sync ;
  1805. PAGESEL $ ;
  1806. ;-----------------------------------------------;
  1807. ; Just a bunch of BLANK LINES, so that the video;
  1808. ; data doesn't start in the non-display area. ;
  1809. ; Add or remove lines to adjust the vertical ;
  1810. ; position of your video. If you add or remove, ;
  1811. ; make sure to adjust the number of BLANK LINES ;
  1812. ; which follow the data lines, so that the video;
  1813. ; stays at 60hz ;
  1814. ;-----------------------------------------------;
  1815. MOVLW 13 + ((MAX_LINES - NUM_LINES) * 2) ;
  1816. MOVWF Line_Count ;
  1817. _NF_Next_Black_60us_Line1: ;
  1818. PAGESEL _Black_Line_60us ;
  1819. CALL _Black_Line_60us ;
  1820. PAGESEL $ ;
  1821. DECFSZ Line_Count, F ;
  1822. GOTO _NF_Next_Black_60us_Line1 ;
  1823. ;-----------------------------------------------;
  1824. ;
  1825. ;-----------------------------------------------;
  1826. ; 2 WHITE lines (for court sideline) + 1 BLACK ;
  1827. ; line (with court centerline) + 192 DATA lines ;
  1828. ; (assuming NUM_LINES = 48) + 1 BLACK line (with;
  1829. ; court centerline) + 2 WHITE lines (for court ;
  1830. ; sideline). ;
  1831. ;-----------------------------------------------;
  1832. PAGESEL _Data_Lines ;
  1833. CALL _Data_Lines ;
  1834. PAGESEL $ ;
  1835. ;-----------------------------------------------;
  1836. ;
  1837. ;-----------------------------------------------;
  1838. ; Display copyright and software version number.;
  1839. ; 1 BLACK line + 8 DATA lines + 1 BLACK line + ;
  1840. ; 2 WHITE lines - 12 60us lines total ;
  1841. ;-----------------------------------------------;
  1842. PAGESEL _Copyright ;
  1843. CALL _Copyright ;
  1844. PAGESEL $ ;
  1845. ;-----------------------------------------------;
  1846. ;
  1847. ;-----------------------------------------------;
  1848. ; More BLACK Lines: ;
  1849. ;-----------------------------------------------;
  1850. #IF ((MAX_LINES - NUM_LINES) * 2) > 8 ;
  1851. MOVLW ((MAX_LINES - NUM_LINES) * 2) - 8 ;
  1852. MOVWF Line_Count ;
  1853. _NF_Next_Black_60us_Line2: ;
  1854. PAGESEL _Black_Line_60us ;
  1855. CALL _Black_Line_60us ;
  1856. PAGESEL $ ;
  1857. DECFSZ Line_Count, F ;
  1858. GOTO _NF_Next_Black_60us_Line2 ;
  1859. #ENDIF ;
  1860. ;-----------------------------------------------;
  1861.  
  1862. ;-----------------------------------------------;
  1863. ; Clear the scores, paddles and ball from the ;
  1864. ; display - and draw the Title if necessary. ;
  1865. ; 2 60us lines ;
  1866. ;-----------------------------------------------;
  1867. PAGESEL _Clear_Screen ;
  1868. CALL _Clear_Screen ; 2 BLACK 60us lines
  1869. PAGESEL $ ; Screen Clear / Title Draw
  1870. ;-----------------------------------------------;
  1871. ;
  1872. ;-----------------------------------------------;
  1873. ; All of the game processing is done here, the ;
  1874. ; last 4 full 60us BLACK lines ;
  1875. ;-----------------------------------------------;
  1876. PAGESEL _Update_Paddles ;
  1877. CALL _Update_Paddles ; 1 BLACK 60us line
  1878. PAGESEL $ ; Paddles Computations
  1879. PAGESEL _Update_Ball ;
  1880. CALL _Update_Ball ; 1 BLACK 60us line
  1881. PAGESEL $ ; Ball Computations
  1882. PAGESEL _Draw_Items ;
  1883. CALL _Draw_Items ; 2 BLACK 60us lines
  1884. PAGESEL $ ; Scores/Paddles/Ball Display
  1885. ;-----------------------------------------------;
  1886. ;
  1887. ;-----------------------------------------------;
  1888. ; So, to summarize (with NUM_LINES = 48): ;
  1889. ; - 7 VERTICAL SYNC lines (14 30us lines) ;
  1890. ; - 30 BLANK LINES for screen centering ;
  1891. ; - 2 WHITE lines for COURT SIDELINE ;
  1892. ; - 192 DATA lines for GAME FIELD ;
  1893. ; - 2 WHITE lines for COURT SIDELINE ;
  1894. ; - 1 BLANK line between SIDELINE & COPYRIGHT ;
  1895. ; - 8 DATA lines for COPYRIGHT ;
  1896. ; - 12 BLANK lines for screen centering ;
  1897. ; - 2 BLANK lines for screen clear / title ;
  1898. ; - 4 BLANK lines for game processing ;
  1899. ; ;
  1900. ; For a total of 260 lines at 64us each, or ;
  1901. ; 16.637ms, or approximately 60hz. 16.666ms ;
  1902. ; would be _perfect_. ;
  1903. ;-----------------------------------------------;
  1904. ;
  1905. GOTO _Next_Frame ;
  1906. ;---------------------------------------------------;
  1907.  
  1908. ;---------------------------------------------------;
  1909. _Vertical_Sync: ;
  1910. ;---------------------------------------------------;
  1911. ; Set the VERTICAL_SYNC flag, to keep audio from;
  1912. ; audio from playing during this time and ;
  1913. ; possibly disrupting the video timing ;
  1914. ;-----------------------------------------------;
  1915. BSF System_Status, VERTICAL_SYNC_BIT ;
  1916. ;-----------------------------------------------;
  1917. ; The _Special_30us_Line will produce a pulse on;
  1918. ; GPIO2 if the _DEBUG_ flag is set to TRUE. This;
  1919. ; is for checking the timing of the entire video;
  1920. ; frame (~60hz, ~16.66ms). ;
  1921. ;-----------------------------------------------;
  1922. START_TIMING SIG_2US, SIG_30US ;
  1923. START_TIMING SIG_2US, SIG_30US ;
  1924. START_TIMING SIG_2US, SIG_30US ;
  1925. START_TIMING SIG_2US, SIG_30US ;
  1926. START_TIMING SIG_2US, SIG_30US ;
  1927. ;-----------------------------------------------;
  1928. ; If _DEBUG_ is enabled, it will produce a pulse;
  1929. ; on the GPIO2 pin for debugging purposes. This ;
  1930. ; pulse is mainly to measure the time (in ms) ;
  1931. ; and frequency of a single video frame. ;
  1932. ;-----------------------------------------------;
  1933. #IF _DEBUG_ ;
  1934. BANKSEL TRISA ;
  1935. BCF TRISA, 2 ;
  1936. BANKSEL PORTA ;
  1937. BCF PORTA, 2 ;
  1938. NOP ;
  1939. BSF PORTA, 2 ;
  1940. BANKSEL TRISA ;
  1941. BSF TRISA, 2 ;
  1942. BANKSEL MEMORY ;
  1943. #ENDIF ; _DEBUG_ ;
  1944. ;-----------------------------------------------;
  1945. ; 4 inverted 30us lines ;
  1946. ;-----------------------------------------------;
  1947. START_TIMING SIG_30US, SIG_2US ;
  1948. START_TIMING SIG_30US, SIG_2US ;
  1949. START_TIMING SIG_30US, SIG_2US ;
  1950. START_TIMING SIG_30US, SIG_2US ;
  1951. ;-----------------------------------------------;
  1952. ; 5 more blank 30us lines ;
  1953. ;-----------------------------------------------;
  1954. START_TIMING SIG_2US, SIG_30US ;
  1955. START_TIMING SIG_2US, SIG_30US ;
  1956. START_TIMING SIG_2US, SIG_30US ;
  1957. START_TIMING SIG_2US, SIG_30US ;
  1958. START_TIMING SIG_2US, SIG_30US ;
  1959. ;-----------------------------------------------;
  1960. ; Clear the VERTICAL_SYNC flag, so that audio ;
  1961. ; can continue playing ;
  1962. ;-----------------------------------------------;
  1963. BCF System_Status, VERTICAL_SYNC_BIT ;
  1964. ;-----------------------------------------------;
  1965. ; Increment the vertical sync count ;
  1966. ;-----------------------------------------------;
  1967. INCF VSync_Count, F ;
  1968. ;-----------------------------------------------;
  1969. RETURN ;
  1970. ;---------------------------------------------------;
  1971.  
  1972. ;---------------------------------------------------;
  1973. _Data_Lines: ;
  1974. ;---------------------------------------------------;
  1975. ; Note: This will generate 1 60us blank line, then ;
  1976. ; 224 60us data lines, and finally a 60us blank line;
  1977. ;---------------------------------------------------;
  1978. ;-----------------------------------------------;
  1979. ; Two WHITE lines (for upper court sideline) and;
  1980. ; one BLACK line (with the court centerline) ;
  1981. ;-----------------------------------------------;
  1982. PAGESEL _White_Line_60us ;
  1983. CALL _White_Line_60us ;
  1984. CALL _White_Line_60us ;
  1985. PAGESEL $ ;
  1986. ;-----------------------------------------------;
  1987. PAGESEL _Black_Line_60us ;
  1988. CALL _Black_Line_60us ;
  1989. PAGESEL $ ;
  1990. DELAY 77 ;
  1991. NOP ;
  1992. BCF PORTA, VIDEO_0_BIT ;
  1993. BCF PORTA, VIDEO_0_BIT ;
  1994. BSF PORTA, VIDEO_0_BIT ;
  1995. BSF PORTA, VIDEO_0_BIT ;
  1996. BCF PORTA, VIDEO_0_BIT ;
  1997. ;-----------------------------------------------;
  1998. ;
  1999. ;-----------------------------------------------;
  2000. ; Set up of video buffer pointer and line count ;
  2001. ;-----------------------------------------------;
  2002. MOVLW LOW VIDEO_BUFFER_START ;
  2003. MOVWF FSR1L ;
  2004. MOVLW HIGH VIDEO_BUFFER_START ;
  2005. MOVWF FSR1H ;
  2006. ;
  2007. MOVLW NUM_LINES ;
  2008. MOVWF DL_Count ;
  2009. ;-----------------------------------------------;
  2010. ;
  2011. ;-----------------------------------------------;
  2012. ; We repeat each line 4 times, since we don't ;
  2013. ; have a big enough video buffer for 192 lines ;
  2014. ;-----------------------------------------------;
  2015. _DL_Next_Line: ;
  2016. MOVLW 4 ;
  2017. MOVWF Repeat_Count ;
  2018. _DL_Repeat_Line: ;
  2019. MOVLW H'FC' ;
  2020. ANDWF FSR1L, F ;
  2021. ;-----------------------------------------------;
  2022. ;
  2023. ;-----------------------------------------------;
  2024. ; 60us Line Generation ;
  2025. ;-----------------------------------------------;
  2026. PAGESEL _Black_Line_60us ;
  2027. CALL _Black_Line_60us ;
  2028. PAGESEL $ ;
  2029. ;-----------------------------------------------;
  2030. ;
  2031. ;-----------------------------------------------;
  2032. ; Front porch - shifts the data to the right ;
  2033. ; and hopefully centers it on the screen ;
  2034. ;-----------------------------------------------;
  2035. DELAY 13 ;
  2036. NOP ;
  2037. ;-----------------------------------------------;
  2038. ;
  2039. ;-----------------------------------------------;
  2040. ; This is where the 32 bits of data are actually;
  2041. ; send out over the video signal ;
  2042. ;-----------------------------------------------;
  2043. DO_BIT 7, 8 ;
  2044. DO_BIT 6, 8 ;
  2045. DO_BIT 5, 8 ;
  2046. DO_BIT 4, 8 ;
  2047. DO_BIT 3, 8 ;
  2048. DO_BIT 2, 8 ;
  2049. DO_BIT 1, 8 ;
  2050. DO_BIT 0, 7 ;
  2051. ;
  2052. ADDFSR FSR1, 1 ;
  2053. ;
  2054. DO_BIT 7, 8 ;
  2055. DO_BIT 6, 8 ;
  2056. DO_BIT 5, 8 ;
  2057. DO_BIT 4, 8 ;
  2058. DO_BIT 3, 8 ;
  2059. DO_BIT 2, 8 ;
  2060. DO_BIT 1, 8 ;
  2061. DO_BIT 0, 7 ;
  2062. ;
  2063. ADDFSR FSR1, 1 ;
  2064. ;
  2065. _DL_Center_Line: ;
  2066. BCF PORTA, VIDEO_0_BIT ;
  2067. BCF PORTA, VIDEO_0_BIT ;
  2068. BSF PORTA, VIDEO_0_BIT ;
  2069. BSF PORTA, VIDEO_0_BIT ;
  2070. BCF PORTA, VIDEO_0_BIT ;
  2071. _DL_Center_Line_Done: ;
  2072. ;
  2073. DO_BIT 7, 8 ;
  2074. DO_BIT 6, 8 ;
  2075. DO_BIT 5, 8 ;
  2076. DO_BIT 4, 8 ;
  2077. DO_BIT 3, 8 ;
  2078. DO_BIT 2, 8 ;
  2079. DO_BIT 1, 8 ;
  2080. DO_BIT 0, 7 ;
  2081. ;
  2082. ADDFSR FSR1, 1 ;
  2083. ;
  2084. DO_BIT 7, 8 ;
  2085. DO_BIT 6, 8 ;
  2086. DO_BIT 5, 8 ;
  2087. DO_BIT 4, 8 ;
  2088. DO_BIT 3, 8 ;
  2089. DO_BIT 2, 8 ;
  2090. DO_BIT 1, 8 ;
  2091. DO_BIT 0, 7 ;
  2092. ;
  2093. ADDFSR FSR1, 1 ;
  2094. ;
  2095. DECF FSR1L, F ;
  2096. ;-----------------------------------------------;
  2097. ;
  2098. ;-----------------------------------------------;
  2099. ; Back porch - between this and the front porch,;
  2100. ; this 'frames' the video on your TV (hopefully);
  2101. ; --------------------------------------------- ;
  2102. ; NOTE: this DELAY and NOPs fleshes out the data;
  2103. ; line to 60us ;
  2104. ;-----------------------------------------------;
  2105. SET_DAC2BIT COLOR_BLACK ;
  2106. ;-----------------------------------------------;
  2107. ;
  2108. DECFSZ Repeat_Count, F ;
  2109. GOTO _DL_Repeat_Line ;
  2110. GOTO _DL_Next_Data ;
  2111. ;
  2112. ;-----------------------------------------------;
  2113. ; 224 lines of information to transmit ;
  2114. ; so the screen size is 32x224. But we transmit ;
  2115. ; each line 4 times, so it's actually 32x56 ;
  2116. ;-----------------------------------------------;
  2117. _DL_Next_Data: ;
  2118. ;-----------------------------------------------;
  2119. ADDFSR FSR1, 1 ;
  2120. DECFSZ DL_Count, F ;
  2121. GOTO _DL_Next_Line ;
  2122. ;
  2123. ;-----------------------------------------------;
  2124. ; One BLACK line (with court centerline) and two;
  2125. ; WHITE lines (for lower court sideline) ;
  2126. ;-----------------------------------------------;
  2127. PAGESEL _Black_Line_60us ;
  2128. CALL _Black_Line_60us ;
  2129. PAGESEL $ ;
  2130. DELAY 77 ;
  2131. NOP ;
  2132. BCF PORTA, VIDEO_0_BIT ;
  2133. BCF PORTA, VIDEO_0_BIT ;
  2134. BSF PORTA, VIDEO_0_BIT ;
  2135. BSF PORTA, VIDEO_0_BIT ;
  2136. BCF PORTA, VIDEO_0_BIT ;
  2137. ;-----------------------------------------------;
  2138. PAGESEL _White_Line_60us ;
  2139. CALL _White_Line_60us ;
  2140. CALL _White_Line_60us ;
  2141. PAGESEL $ ;
  2142. ;-----------------------------------------------;
  2143. ;
  2144. RETURN ;
  2145. ;---------------------------------------------------;
  2146.  
  2147. ;---------------------------------------------------;
  2148. _Copyright: ;
  2149. ;---------------------------------------------------;
  2150. ; Note: This is a 60us line routine. It will ;
  2151. ; generate 8 60us data lines. ;
  2152. ;---------------------------------------------------;
  2153. ;-----------------------------------------------;
  2154. ; One BLACK line ;
  2155. ;-----------------------------------------------;
  2156. PAGESEL _Black_Line_60us ;
  2157. CALL _Black_Line_60us ;
  2158. PAGESEL $ ;
  2159. ;-----------------------------------------------;
  2160. ;
  2161. ;-----------------------------------------------;
  2162. ; Setup ;
  2163. ;-----------------------------------------------;
  2164. _CR_Check_If_Time_To_Switch: ;
  2165. MOVLW 255 ; / 60 frames = secs
  2166. XORWF VSync_Count, W ;
  2167. BTFSS STATUS, Z ;
  2168. GOTO _CR_Determine_Copyright_To_Display ;
  2169. ;
  2170. _CR_Switch_Copyright: ;
  2171. CLRF VSync_Count ;
  2172. MOVLW WHICH_CR ;
  2173. XORWF System_Status, F ;
  2174. ;
  2175. _CR_Determine_Copyright_To_Display: ;
  2176. BTFSC System_Status, WHICH_CR_BIT ;
  2177. GOTO _CR_Copyright_2 ;
  2178. ;
  2179. _CR_Copyright_1: ;
  2180. MOVLW LOW COPYRIGHT_TABLE1_START ;
  2181. MOVWF FSR1L ;
  2182. MOVLW HIGH COPYRIGHT_TABLE1_START ;
  2183. MOVWF FSR1H ;
  2184. MOVLW (COPYRIGHT_TABLE1_END - COPYRIGHT_TABLE1_START) / 8
  2185. MOVWF Temp1 ;
  2186. GOTO _CR_Next_Line ;
  2187. ;
  2188. _CR_Copyright_2: ;
  2189. MOVLW LOW COPYRIGHT_TABLE2_START ;
  2190. MOVWF FSR1L ;
  2191. MOVLW HIGH COPYRIGHT_TABLE2_START ;
  2192. MOVWF FSR1H ;
  2193. MOVLW (COPYRIGHT_TABLE2_END - COPYRIGHT_TABLE2_START) / 8
  2194. MOVWF Temp1 ;
  2195. ;-----------------------------------------------;
  2196. ;
  2197. ;-----------------------------------------------;
  2198. ; 8 60us Data Lines Generation ;
  2199. ;-----------------------------------------------;
  2200. _CR_Next_Line: ;
  2201. ;-----------------------------------------------;
  2202. ; 60us BLACK Line ;
  2203. ;-----------------------------------------------;
  2204. START_TIMING SIG_4US, SIG_60US ;
  2205. ;-----------------------------------------------;
  2206. ;
  2207. ;-----------------------------------------------;
  2208. ; Xus Back Porch (Black Signal) Generation ;
  2209. ;-----------------------------------------------;
  2210. DELAY 13 ;
  2211. NOP ;
  2212. ;-----------------------------------------------;
  2213. ;
  2214. ;-----------------------------------------------;
  2215. ; Data Generation ;
  2216. ;-----------------------------------------------;
  2217. DO_BIT 7, 0 ;
  2218. DO_BIT 6, 0 ;
  2219. DO_BIT 5, 0 ;
  2220. DO_BIT 4, 0 ;
  2221. DO_BIT 3, 0 ;
  2222. DO_BIT 2, 0 ;
  2223. DO_BIT 1, 0 ;
  2224. DO_BIT 0, 0 ;
  2225. ADDFSR FSR1, 1 ;
  2226. DO_BIT 7, 0 ;
  2227. DO_BIT 6, 0 ;
  2228. DO_BIT 5, 0 ;
  2229. DO_BIT 4, 0 ;
  2230. DO_BIT 3, 0 ;
  2231. DO_BIT 2, 0 ;
  2232. DO_BIT 1, 0 ;
  2233. DO_BIT 0, 0 ;
  2234. ADDFSR FSR1, 1 ;
  2235. DO_BIT 7, 0 ;
  2236. DO_BIT 6, 0 ;
  2237. DO_BIT 5, 0 ;
  2238. DO_BIT 4, 0 ;
  2239. DO_BIT 3, 0 ;
  2240. DO_BIT 2, 0 ;
  2241. DO_BIT 1, 0 ;
  2242. DO_BIT 0, 0 ;
  2243. ADDFSR FSR1, 1 ;
  2244. DO_BIT 7, 0 ;
  2245. DO_BIT 6, 0 ;
  2246. DO_BIT 5, 0 ;
  2247. DO_BIT 4, 0 ;
  2248. DO_BIT 3, 0 ;
  2249. DO_BIT 2, 0 ;
  2250. DO_BIT 1, 0 ;
  2251. DO_BIT 0, 0 ;
  2252. ADDFSR FSR1, 1 ;
  2253. DO_BIT 7, 0 ;
  2254. DO_BIT 6, 0 ;
  2255. DO_BIT 5, 0 ;
  2256. DO_BIT 4, 0 ;
  2257. DO_BIT 3, 0 ;
  2258. DO_BIT 2, 0 ;
  2259. DO_BIT 1, 0 ;
  2260. DO_BIT 0, 0 ;
  2261. ADDFSR FSR1, 1 ;
  2262. DO_BIT 7, 0 ;
  2263. DO_BIT 6, 0 ;
  2264. DO_BIT 5, 0 ;
  2265. DO_BIT 4, 0 ;
  2266. DO_BIT 3, 0 ;
  2267. DO_BIT 2, 0 ;
  2268. DO_BIT 1, 0 ;
  2269. DO_BIT 0, 0 ;
  2270. ADDFSR FSR1, 1 ;
  2271. DO_BIT 7, 0 ;
  2272. DO_BIT 6, 0 ;
  2273. DO_BIT 5, 0 ;
  2274. DO_BIT 4, 0 ;
  2275. DO_BIT 3, 0 ;
  2276. DO_BIT 2, 0 ;
  2277. DO_BIT 1, 0 ;
  2278. DO_BIT 0, 0 ;
  2279. ADDFSR FSR1, 1 ;
  2280. DO_BIT 7, 0 ;
  2281. DO_BIT 6, 0 ;
  2282. DO_BIT 5, 0 ;
  2283. DO_BIT 4, 0 ;
  2284. DO_BIT 3, 0 ;
  2285. DO_BIT 2, 0 ;
  2286. DO_BIT 1, 0 ;
  2287. DO_BIT 0, 0 ;
  2288. ADDFSR FSR1, 1 ;
  2289. ;-----------------------------------------------;
  2290. ;
  2291. ;-----------------------------------------------;
  2292. ; Xus Front Porch (Black Signal) Generation ;
  2293. ;-----------------------------------------------;
  2294. NOP ;
  2295. SET_DAC2BIT COLOR_BLACK ;
  2296. ;-----------------------------------------------;
  2297. ;
  2298. ;-----------------------------------------------;
  2299. ; All of this nonsense is just to get the timing;
  2300. ; right between doing the next copyright line or;
  2301. ; starting the series of blank lines. ;
  2302. ;-----------------------------------------------;
  2303. DECFSZ Temp1, F ;
  2304. GOTO _CR_Next_Line ;
  2305. ;-----------------------------------------------;
  2306. ;
  2307. ;-----------------------------------------------;
  2308. ; One BLACK line and two WHITE lines: ;
  2309. ;-----------------------------------------------;
  2310. PAGESEL _Black_Line_60us ;
  2311. CALL _Black_Line_60us ;
  2312. PAGESEL _White_Line_60us ;
  2313. CALL _White_Line_60us ;
  2314. CALL _White_Line_60us ;
  2315. PAGESEL $ ;
  2316. ;-----------------------------------------------;
  2317. ;
  2318. RETURN ;
  2319. ;---------------------------------------------------;
  2320.  
  2321. ;---------------------------------------------------;
  2322. _Black_Line_30us: ;
  2323. ;---------------------------------------------------;
  2324. START_TIMING SIG_2US, SIG_30US ;
  2325. RETURN ;
  2326. ;---------------------------------------------------;
  2327.  
  2328. ;---------------------------------------------------;
  2329. _Black_Line_60us: ;
  2330. ;---------------------------------------------------;
  2331. START_TIMING SIG_4US, SIG_60US ;
  2332. RETURN ;
  2333. ;---------------------------------------------------;
  2334.  
  2335. ;---------------------------------------------------;
  2336. _White_Line_60us: ;
  2337. ;---------------------------------------------------;
  2338. PAGESEL _Black_Line_60us ;
  2339. CALL _Black_Line_60us ;
  2340. PAGESEL $ ;
  2341. BSF PORTA, VIDEO_0_BIT ;
  2342. DELAY 149 ;
  2343. BCF PORTA, VIDEO_0_BIT ;
  2344. RETURN ;
  2345. ;---------------------------------------------------;
  2346.  
  2347. ;---------------------------------------------------;
  2348. _Clear_Screen: ;
  2349. ;---------------------------------------------------;
  2350. ; This is a 2 60us BLACK lines routine ;
  2351. ;---------------------------------------------------;
  2352. ;-----------------------------------------------;
  2353. ; 60us BLACK Line ;
  2354. ;-----------------------------------------------;
  2355. START_TIMING SIG_4US, SIG_60US ;
  2356. ;-----------------------------------------------;
  2357. ;
  2358. _CS_Top: ;
  2359. ;-----------------------------------------------;
  2360. ; Set up the pointer to the video buffer ;
  2361. ;-----------------------------------------------;
  2362. MOVLW HIGH VIDEO_BUFFER_START ;
  2363. MOVWF FSR1H ;
  2364. MOVLW LOW VIDEO_BUFFER_START ;
  2365. MOVWF FSR1L ;
  2366. ;-----------------------------------------------;
  2367. ;
  2368. ;-----------------------------------------------;
  2369. ; Set up the pointer to the title table ;
  2370. ;-----------------------------------------------;
  2371. MOVLW HIGH TITLE_TABLE ;
  2372. MOVWF FSR0H ;
  2373. MOVLW LOW TITLE_TABLE ;
  2374. MOVWF FSR0L ;
  2375. ;-----------------------------------------------;
  2376. ;
  2377. ;-----------------------------------------------;
  2378. ; Set up the number of bytes to transfer ;
  2379. ;-----------------------------------------------;
  2380. MOVLW ((NUM_LINES * 4) /2) / 8 ;
  2381. MOVWF Temp1 ;
  2382. ;-----------------------------------------------;
  2383. ;
  2384. ;-----------------------------------------------;
  2385. ; Transfer the data from the title table to the ;
  2386. ; video buffer, 8 bytes at a time. Doing it in ;
  2387. ; groups of 8 in a loop, instead of 1 byte at a ;
  2388. ; time in a loop, speeds up the transfer as it ;
  2389. ; cuts out a lot of the instruction cycles for ;
  2390. ; the looping mechanism. ;
  2391. ;-----------------------------------------------;
  2392. _CS_T_Next_8_Bytes: ;
  2393. MOVIW 0[INDF0] ;
  2394. MOVWI 0[INDF1] ;
  2395. MOVIW 1[INDF0] ;
  2396. MOVWI 1[INDF1] ;
  2397. MOVIW 2[INDF0] ;
  2398. MOVWI 2[INDF1] ;
  2399. MOVIW 3[INDF0] ;
  2400. MOVWI 3[INDF1] ;
  2401. MOVIW 4[INDF0] ;
  2402. MOVWI 4[INDF1] ;
  2403. MOVIW 5[INDF0] ;
  2404. MOVWI 5[INDF1] ;
  2405. MOVIW 6[INDF0] ;
  2406. MOVWI 6[INDF1] ;
  2407. MOVIW 7[INDF0] ;
  2408. MOVWI 7[INDF1] ;
  2409. _CS_T_Check_For_Title: ;
  2410. BTFSC System_Status, P1_SERVICE_BIT ; If SERVICE is clear for both
  2411. BTFSS System_Status, P2_SERVICE_BIT ; players, then it's the start
  2412. GOTO $+2 ; of a game. Draw the title.
  2413. ADDFSR FSR0, 8 ;
  2414. ADDFSR FSR1, 8 ;
  2415. DECFSZ Temp1, F ;
  2416. GOTO _CS_T_Next_8_Bytes ;
  2417. ;-----------------------------------------------;
  2418. ;
  2419. ;-----------------------------------------------;
  2420. ; 60us BLACK Line ;
  2421. ;-----------------------------------------------;
  2422. START_TIMING SIG_4US, SIG_60US ;
  2423. ;-----------------------------------------------;
  2424. ;
  2425. _CS_Bottom: ;
  2426. ;-----------------------------------------------;
  2427. ; Set up the pointer to the video buffer ;
  2428. ;-----------------------------------------------;
  2429. MOVLW HIGH VIDEO_BUFFER_START ;
  2430. MOVWF FSR1H ;
  2431. MOVLW LOW VIDEO_BUFFER_START ;
  2432. ADDLW (NUM_LINES * 4) / 2 ;
  2433. MOVWF FSR1L ;
  2434. BTFSC STATUS, C ;
  2435. INCF FSR1H, F ;
  2436. ;-----------------------------------------------;
  2437. ;
  2438. ;-----------------------------------------------;
  2439. ; Set up the pointer to the title table ;
  2440. ;-----------------------------------------------;
  2441. MOVLW HIGH TITLE_TABLE ;
  2442. MOVWF FSR0H ;
  2443. MOVLW LOW TITLE_TABLE ;
  2444. _CS_B_Check_For_Title1: ;
  2445. BTFSC System_Status, P1_SERVICE_BIT ; If SERVICE is clear for both
  2446. BTFSS System_Status, P2_SERVICE_BIT ; players, then it's the start
  2447. GOTO $+2 ; of a game. Draw the title.
  2448. ADDLW (NUM_LINES * 4) / 2 ;
  2449. MOVWF FSR0L ;
  2450. BTFSC STATUS, C ;
  2451. INCF FSR0H, F ;
  2452. ;-----------------------------------------------;
  2453. ;
  2454. ;-----------------------------------------------;
  2455. ; Set up the number of bytes to transfer ;
  2456. ;-----------------------------------------------;
  2457. MOVLW ((NUM_LINES * 4) /2) / 8 ;
  2458. MOVWF Temp1 ;
  2459. ;-----------------------------------------------;
  2460. ;
  2461. ;-----------------------------------------------;
  2462. ; Transfer the data from the title table to the ;
  2463. ; video buffer, 8 bytes at a time. Doing it in ;
  2464. ; groups of 8 in a loop, instead of 1 byte at a ;
  2465. ; time in a loop, speeds up the transfer as it ;
  2466. ; cuts out a lot of the instruction cycles for ;
  2467. ; the looping mechanism. ;
  2468. ;-----------------------------------------------;
  2469. _CS_B_Next_8_Bytes: ;
  2470. MOVIW 0[INDF0] ;
  2471. MOVWI 0[INDF1] ;
  2472. MOVIW 1[INDF0] ;
  2473. MOVWI 1[INDF1] ;
  2474. MOVIW 2[INDF0] ;
  2475. MOVWI 2[INDF1] ;
  2476. MOVIW 3[INDF0] ;
  2477. MOVWI 3[INDF1] ;
  2478. MOVIW 4[INDF0] ;
  2479. MOVWI 4[INDF1] ;
  2480. MOVIW 5[INDF0] ;
  2481. MOVWI 5[INDF1] ;
  2482. MOVIW 6[INDF0] ;
  2483. MOVWI 6[INDF1] ;
  2484. MOVIW 7[INDF0] ;
  2485. MOVWI 7[INDF1] ;
  2486. _CS_B_Check_For_Title2: ;
  2487. BTFSC System_Status, P1_SERVICE_BIT ; If SERVICE is clear for both
  2488. BTFSS System_Status, P2_SERVICE_BIT ; players, then it's the start
  2489. GOTO $+2 ; of a game. Draw the title.
  2490. ADDFSR FSR0, 8 ;
  2491. ADDFSR FSR1, 8 ;
  2492. DECFSZ Temp1, F ;
  2493. GOTO _CS_B_Next_8_Bytes ;
  2494. ;-----------------------------------------------;
  2495. ;
  2496. RETURN ;
  2497. ;---------------------------------------------------;
  2498.  
  2499. ;---------------------------------------------------;
  2500. ; Numeric Characters (0-9) Scan Line Data ;
  2501. ;---------------------------------------------------;
  2502. CHARACTER_TABLE: ;
  2503. ;---------------------------------------------------;
  2504. ; These are the bitmaps for the score characters;
  2505. ; 0-9, 4x5 pixels ;
  2506. ;-----------------------------------------------;
  2507. DT B'11101110', B'01000100', B'11101110', B'11101110', B'10101010', B'11101110', B'11101110', B'11101110', B'11101110', B'11101110'
  2508. DT B'10101010', B'11001100', B'00100010', B'00100010', B'10101010', B'10001000', B'10001000', B'00100010', B'10101010', B'10101010'
  2509. DT B'10101010', B'01000100', B'11101110', B'11101110', B'11101110', B'11101110', B'11101110', B'00100010', B'11101110', B'11101110'
  2510. DT B'10101010', B'01000100', B'10001000', B'00100010', B'00100010', B'00100010', B'10101010', B'00100010', B'10101010', B'00100010'
  2511. DT B'11101110', B'01000100', B'11101110', B'11101110', B'00100010', B'11101110', B'11101110', B'00100010', B'11101110', B'00100010'
  2512. ;---------------------------------------------------;
  2513.  
  2514. ;---------------------------------------------------;
  2515. SERVICE_TABLE: ;
  2516. ;---------------------------------------------------;
  2517. ; These are the bitmaps for the 'SERVICE' arrow ;
  2518. ; that shows up next to a score. ;
  2519. ;-----------------------------------------------;
  2520. SERVICE_TABLE_START: ;
  2521. DT B'00000100' ;
  2522. DT B'00000010' ;
  2523. DT B'00000001' ;
  2524. DT B'00000010' ;
  2525. DT B'00000100' ;
  2526. DT B'00100000' ;
  2527. DT B'01000000' ;
  2528. DT B'10000000' ;
  2529. DT B'01000000' ;
  2530. DT B'00100000' ;
  2531. SERVICE_TABLE_END: ;
  2532. ;---------------------------------------------------;
  2533.  
  2534. ;---------------------------------------------------;
  2535. COMPUTER_2_TABLE: ;
  2536. ;---------------------------------------------------;
  2537. ; These are the bitmaps for the 'SERVICE' arrow ;
  2538. ; that shows up next to a score. ;
  2539. ;-----------------------------------------------;
  2540. COMPUTER_2_TABLE_START: ;
  2541. DT B'00000010' ;
  2542. DT B'00000111' ;
  2543. DT B'00000101' ;
  2544. DT B'00000100' ;
  2545. DT B'00000101' ;
  2546. DT B'00000111' ;
  2547. DT B'00000010' ;
  2548. COMPUTER_2_TABLE_END: ;
  2549. ;---------------------------------------------------;
  2550.  
  2551. ;---------------------------------------------------;
  2552. ; Title Title Scan Line Data ;
  2553. ;---------------------------------------------------;
  2554. TITLE_TABLE: ;
  2555. ;---------------------------------------------------;
  2556. TITLE_TABLE_START: ;
  2557. ;-----------------------------------------------;
  2558. ; The first 6x4 lines should be 0 so that the ;
  2559. ; title graphic does not merge with the scores, ;
  2560. ; and for the screen to clear the title properly;
  2561. ;-----------------------------------------------;
  2562. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2563. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2564. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2565. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2566. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2567. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2568. ;-----------------------------------------------;
  2569. ; The next 42x4 lines contain the title graphic ;
  2570. ;-----------------------------------------------;
  2571. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2572. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2573. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2574. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2575. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2576. DT B'00000111', B'10000000', B'01110000', B'00000000'
  2577. DT B'00000111', B'11000000', B'11111000', B'00000000'
  2578. DT B'00000111', B'11000000', B'11111000', B'00000000'
  2579. DT B'00000100', B'01000000', B'10001000', B'00000000'
  2580. DT B'00000100', B'01000000', B'10001000', B'00000000'
  2581. DT B'00000100', B'01001110', B'10001001', B'11000000'
  2582. DT B'00000111', B'11011111', B'10001011', B'11100000'
  2583. DT B'00000111', B'11011111', B'10001011', B'11100000'
  2584. DT B'00000111', B'10010001', B'10001010', B'00100000'
  2585. DT B'00000100', B'00010001', B'10001010', B'00000000'
  2586. DT B'00000100', B'00010001', B'10001010', B'00000000'
  2587. DT B'00000100', B'00010001', B'10001010', B'01100000'
  2588. DT B'00000100', B'00010001', B'10001010', B'01100000'
  2589. DT B'00000100', B'00010001', B'10001010', B'01100000'
  2590. DT B'00000100', B'00010001', B'10001010', B'00100000'
  2591. DT B'00000000', B'00010001', B'00000010', B'00100000'
  2592. DT B'00000000', B'00010001', B'00000010', B'00100000'
  2593. DT B'00000000', B'00011111', B'00000011', B'11100000'
  2594. DT B'00000000', B'00011111', B'00000011', B'11100000'
  2595. DT B'00000000', B'00001110', B'00000001', B'11000000'
  2596. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2597. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2598. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2599. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2600. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2601. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2602. DT B'00001110', B'11101110', B'01110101', B'01110000'
  2603. DT B'00001000', B'10101010', B'00100101', B'01000000'
  2604. DT B'00001100', B'10101100', B'00100111', B'01100000'
  2605. DT B'00001000', B'10101010', B'00100101', B'01000000'
  2606. DT B'00001000', B'11101010', B'00100101', B'01110000'
  2607. DT B'00000000', B'00000000', B'00000000', B'00000000'
  2608. DT B'00000101', B'11011101', B'11101010', B'11100000'
  2609. DT B'00000100', B'01010001', B'10101010', B'10100000'
  2610. DT B'00000101', B'11011001', B'11101110', B'10100000'
  2611. DT B'00000101', B'00010001', B'10100010', B'10100000'
  2612. DT B'00000101', B'11010001', B'11100010', B'11100000'
  2613. TITLE_TABLE_END: ;
  2614. ;---------------------------------------------------;
  2615.  
  2616. ;---------------------------------------------------;
  2617. ; COPYRIGHT Scan Line Data ;
  2618. ;---------------------------------------------------;
  2619. COPYRIGHT_TABLE1_START: ;
  2620. ;---------------------------------------------------;
  2621. ; this is the bitmap for the COPYRIGHT line ;
  2622. ; 64x8 pixels ;
  2623. ;-----------------------------------------------;
  2624. DT B'00110011', B'10111000', B'10010010', B'00111001', B'00010111', B'00000101', B'01010000', B'10001000'
  2625. DT B'00111011', B'10111001', B'00111001', B'00111011', B'10110111', B'00000101', B'01010001', B'11011000'
  2626. DT B'10101001', B'00010001', B'00101001', B'00001010', B'10010001', B'01010101', B'01010001', B'01001001'
  2627. DT B'10101001', B'00010001', B'00100001', B'00111010', B'10010111', B'01010101', B'01110001', B'01001001'
  2628. DT B'10101001', B'00010001', B'00100001', B'00111010', B'10010111', B'01010101', B'01110001', B'01001001'
  2629. DT B'10101001', B'00010001', B'00101001', B'00100010', B'10010100', B'01010101', B'00010001', B'01001001'
  2630. DT B'00111001', B'00111001', B'00111001', B'00111011', B'10010111', B'00000101', B'00010101', B'11001000'
  2631. DT B'00110001', B'00111000', B'10010010', B'00111001', B'00010111', B'00000010', B'00010100', B'10001000'
  2632. ;---------------------------------------------------;
  2633. COPYRIGHT_TABLE1_END: ;
  2634. ;---------------------------------------------------;
  2635. COPYRIGHT_TABLE2_START: ;
  2636. ;---------------------------------------------------;
  2637. ; this is the bitmap for the COPYRIGHT line ;
  2638. ; 64x8 pixels ;
  2639. ;-----------------------------------------------;
  2640. DT B'01110101', B'10100010', B'01110101', B'01010011', B'10000010', B'00100110', B'01001110', B'01000100'
  2641. DT B'01110101', B'11110111', B'01110101', B'01010011', B'10000111', B'01110111', B'01001110', B'11101110'
  2642. DT B'00100101', B'01010101', B'00100101', B'01010010', B'00000101', B'01010101', B'01001000', B'10101010'
  2643. DT B'00100101', B'01010101', B'00100111', B'01110011', B'10000100', B'01110110', B'01001110', B'10101010'
  2644. DT B'00100101', B'01010101', B'00100111', B'00100011', B'10000100', B'01110111', B'01001110', B'10101010'
  2645. DT B'00100101', B'01010101', B'00100101', B'00100000', B'10000101', B'01010101', B'01000010', B'10101010'
  2646. DT B'00100101', B'01010111', B'00100101', B'00100011', B'10100111', B'01010101', B'01101110', B'11101010'
  2647. DT B'00100101', B'01010010', B'00100101', B'00100011', B'10100010', B'01010101', B'01101110', B'01001010'
  2648. ;---------------------------------------------------;
  2649. COPYRIGHT_TABLE2_END: ;
  2650. ;---------------------------------------------------;
  2651.  
  2652. ;---------------------------------------------------;
  2653. ;---------------------------------------------------;
  2654. END ;
  2655. ;---------------------------------------------------;
  2656. ;---------------------------------------------------;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement