Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ; Name: PONG.ASM ;
- ; Use: DTI's version of the PONG game ;
- ;---------------------------------------------------;
- ; Copyright: (C)2012 DTI ;
- ; Dysfunctional Technologies, Inc. ;
- ; All Rights Reserved ;
- ;---------------------------------------------------;
- ; Author: Timothy S. Carlson ;
- ; Dysfunctional Technologies, Inc. ;
- ; Date: December 21, 2012 ;
- ; Version: V3.03 ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ; WEBSITE: www.dysfunctionaltechnologies.com ;
- ; EMAIL: tscarlson@gmail.com ;
- ; ;
- ; You are welcome to use this code as you see fit, ;
- ; however - not to be used in for-profit products ;
- ; unless we have come to a monetary agreement. ;
- ; ;
- ; If this code is used, credit given is appreciated ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ; VERSION LOG: ;
- ; V3.00: Modified characters, character placement, ;
- ; and field to look more like the real PONG ;
- ; V3.01: Renamed to PIC-PONG ;
- ; - Added 64x224 mode for copyright message ;
- ; - Added piezo speaker for sounds ;
- ; - Added ball 'slow-down' method ;
- ; - Added special dot as court divider ;
- ; V3.02: Fixed my program memory page issues. ;
- ; - Revamped _Draw_Scores. Cleaner, faster. ;
- ; - Redid title - "PONG FOR THE 12F1840" ;
- ; - Added _DEBUG_ turns on/off GP2 VSYNC Pulse;
- ; - Moved some procs to high page: ;
- ; - _Draw_Title ;
- ; - _Clear_Court ;
- ; - _Copyright ;
- ; - _Initialize_System ;
- ; - More comments ;
- ; - Modified comments discussing the number of;
- ; lines, what they do, and how long (in ms) ;
- ; for a complete video frame. ;
- ; 260 lines * 64us each = 16.64ms per frame ;
- ; The current timing is ~16.645ms per frame ;
- ; - General Cleanup ;
- ; - Added the software version number at the ;
- ; bottom right of the screen, in the copy- ;
- ; right strip. ;
- ; V3.03: Updated version number display to V3.03 ;
- ; - Adding more comments ;
- ; - Changed references to 'Half_Line' and ;
- ; 'Full_Line' in some proc titles to ;
- ; '30us_Line' and '60us_Line' respectively. ;
- ; (_Blank_Half_Line => _Blank_30us_Line) ;
- ; - Moved some line generation procs to high ;
- ; page, added PAGESELs, adjusted timings. ;
- ; - _Blank_60us_Line ;
- ; - _Blank_30us_Line ;
- ; - _Special_30us_Line ;
- ; - _Inverted_30us_Line ;
- ; - Everything possible has been moved to the ;
- ; high page of memory, with the exceptions: ;
- ; - _Update_Paddle_1 ;
- ; - _Update_Paddle_2 ;
- ; - _Update_Ball ;
- ; I am only using 655 words in the low page ;
- ; of program memory now (H'000'-H'28E') out ;
- ; of 4096 bytes (2048 words). The high page ;
- ; is packed - H'800'-H'D92'. I left the ;
- ; above procs in the low page as I will be ;
- ; making modifications / enhancements to ;
- ; these routines in the near future. ;
- ; - NOTE: If you see what appears to be stray ;
- ; NOPs strewn about in the code - DON'T ;
- ; REMOVE THEM. They are there for video ;
- ; timings purposes. Remove them and DOOM! ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ; Project Defines ;
- ;---------------------------------------------------;
- #DEFINE _PONG.ASM_ ;
- #DEFINE _MAIN_MODULE_ ;
- ;---------------------------------------------------;
- #DEFINE _DEBUG_ FALSE ;
- #DEFINE _USE_THUMBSTICKS_ TRUE ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ; Includes ;
- ;---------------------------------------------------;
- #INCLUDE Common.INC ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ; Macros ;
- ;---------------------------------------------------;
- DELAY MACRO DTIME ;
- ;-----------------------------------------------;
- ; The time munger used EVERYWHERE ;
- ;-----------------------------------------------;
- MOVLW DTIME ;
- MOVWF DTemp ;
- DECFSZ DTemp, F ;
- GOTO $-1 ;
- ;-----------------------------------------------;
- ENDM ;
- ;
- DO_BIT MACRO THISBIT, NOPS ;
- ;-----------------------------------------------;
- ; Sets the DAC either WHITE or BLACK ;
- ; Does a specified delay in NOPs ;
- ;-----------------------------------------------;
- ; Note that a WHITE bit check is done first and ;
- ; then a BLACK bit check. If you reverse the ;
- ; order, things look a bit differently on the ;
- ; screen. That is because there is a two ;
- ; instruction delay and reversing the order ;
- ; causes black 'gaps'. This order is most ;
- ; visually appealing, at least to me. ;
- ;-----------------------------------------------;
- BTFSC INDF1, THISBIT ;
- BSF PORTA, VIDEO_0_BIT ;
- BTFSS INDF1, THISBIT ;
- BCF PORTA, VIDEO_0_BIT ;
- #IF NOPS > 0 ;
- NOP ;
- #ENDIF ;
- #IF NOPS > 1 ;
- NOP ;
- #ENDIF ;
- #IF NOPS > 2 ;
- NOP ;
- #ENDIF ;
- #IF NOPS > 3 ;
- NOP ;
- #ENDIF ;
- #IF NOPS > 4 ;
- NOP ;
- #ENDIF ;
- #IF NOPS > 5 ;
- NOP ;
- #ENDIF ;
- #IF NOPS > 6 ;
- NOP ;
- #ENDIF ;
- #IF NOPS > 7 ;
- NOP ;
- #ENDIF ;
- #IF NOPS > 8 ;
- NOP ;
- #ENDIF ;
- #IF NOPS > 9 ;
- NOP ;
- #ENDIF ;
- ;-----------------------------------------------;
- ENDM ;
- ;
- SET_SIGNAL MACRO COLOR ;
- ;-----------------------------------------------;
- ; Sets the 2bit DAC to the desired color ;
- ; Both bits are done at once, or else some weird;
- ; transitions on the DAC can be seen. Okay if ;
- ; just colors (WHITE, GRAY, BLACK), but if a ;
- ; sync pulse shows up out context, it can really;
- ; mess up the video timings ;
- ;-----------------------------------------------;
- MOVFW PORTA ;
- ANDLW ~(VIDEO_0 | VIDEO_1) ;
- IORLW COLOR ;
- MOVWF PORTA ;
- ;-----------------------------------------------;
- ENDM ;
- ;
- NEG_SYNC_4US MACRO ;
- ;-----------------------------------------------;
- ; 4us Negative Sync Generation ;
- ;-----------------------------------------------;
- ; Not only does this do a 4us negative sync, it ;
- ; also handles the sound generation during the ;
- ; game. Sounds are produced by toggling GPIO1 ;
- ; during HSYNCs - if it is toggled during ALL ;
- ; HSYNCs, you get a high freq (around 7800hz). ;
- ; If every other HSYNC, the freq is around lower;
- ;-----------------------------------------------;
- ; Don't touch this unless you really understand ;
- ; it. I am trying to keep the number of cycles ;
- ; equal even when playing sounds. If this is ;
- ; changed, it could cause 'tearing' of the ;
- ; video when a sound is playing. ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_SYNC ;
- BTFSS System_Status, BUZZ_BIT ;
- GOTO $+16 ;
- DECFSZ Buzz_Count, F ;
- GOTO $+16 ;
- MOVFW Buzz_Reload ;
- MOVWF Buzz_Count ;
- BANKSEL TRISA ;
- BCF TRISA, RBUTT_BIT ; Set as OUTPUT
- BANKSEL MEMORY ;
- MOVLW RBUTT ;
- XORWF PORTA, F ;
- DECFSZ Buzz_Dur_LO, F ;
- GOTO $+16 ;
- DECFSZ Buzz_Dur_HI, F ;
- GOTO $+16 ;
- BCF System_Status, BUZZ_BIT ;
- GOTO $+15 ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- MOVLW 3 ;
- MOVWF DTemp ;
- DECFSZ DTemp, F ;
- GOTO $-1 ;
- NOP ;
- ;-----------------------------------------------;
- ENDM ;
- ;
- NEG_SYNC_2US MACRO ;
- ;-----------------------------------------------;
- ; 2us Negative Sync Generation ;
- ;-----------------------------------------------;
- ; Used during VSYNC only. ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_SYNC ;
- MOVLW 3 ;
- MOVWF DTemp ;
- DECFSZ DTemp, F ;
- GOTO $-1 ;
- NOP ;
- NOP ;
- ;-----------------------------------------------;
- ENDM ;
- ;
- POS_SYNC_2US MACRO ;
- ;-----------------------------------------------;
- ; 2us Positive Sync Generation ;
- ;-----------------------------------------------;
- ; Using during VSYNC only. ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- MOVLW 3 ;
- MOVWF DTemp ;
- DECFSZ DTemp, F ;
- GOTO $-1 ;
- NOP ;
- NOP ;
- ;-----------------------------------------------;
- ENDM ;
- ;
- PLAY_SOUND MACRO FREQUENCY, DURATION ;
- ;-----------------------------------------------;
- ; This will play a sound of a specified ;
- ; frequency for a specified duration ;
- ; The lower the frequency number, the higher ;
- ; the frequency. Duration is also a function ;
- ; of the frequency number, so if frequency goes ;
- ; up, adjust the duration down. ;
- ;-----------------------------------------------;
- ; Sound is played during 4us HORIZONTAL SYNC ;
- ; times of the video signal. There is a short ;
- ; period during VERTICAL SYNC where nothing is ;
- ; done with sound because there ARE no 4us ;
- ; HSYNCs. There are 2us HSYNCs during VSYNC, but;
- ; there isn't enough time to process the sound ;
- ; code without stretching out the 2us HSYNCs ;
- ; beyond 2us, and that will mess up the video ;
- ; timings. The total time between the last 4us ;
- ; HSYNC before VSYNC and the first 4us HSYNC ;
- ; after VSYNC is only ~512us, so it's barely ;
- ; noticable. After all, it's only a game... ;
- ;-----------------------------------------------;
- ; NOTE that a FREQUENCY of 0 is treated as a ;
- ; frequency of 256. 0<=Freq<=255. The count is ;
- ; decremented BEFORE it is checked to be 0, so ;
- ; starting with 0 will dec, see 255, continue ;
- ; loop. Just so you are warned. ;
- ;-----------------------------------------------;
- MOVLW FREQUENCY ;
- MOVWF Buzz_Count ;
- MOVWF Buzz_Reload ;
- MOVLW LOW DURATION ;
- MOVWF Buzz_Dur_LO ;
- MOVLW HIGH DURATION ;
- MOVWF Buzz_Dur_HI ;
- BSF System_Status, BUZZ_BIT ;
- ;-----------------------------------------------;
- ENDM ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ; Defines ;
- ;---------------------------------------------------;
- ; You have to chose between using all buttons, ;
- ; or using a thumbstick with a button. I might ;
- ; be able to figure out a way to automatically ;
- ; determine which is connected, but for now you ;
- ; will just have to decide which you want, set ;
- ; _USE_THUMBSTICKS_ to either TRUE or FALSE, and;
- ; re-compile the project. ;
- ;-----------------------------------------------;
- #IF _USE_THUMBSTICKS_ ;
- #DEFINE RJOY H'01' ; Right THUMBSTICK
- #DEFINE RJOY_BIT 0 ; GPIO 0 - PIN 7
- #DEFINE RBUTT H'02' ; Right BUTTON
- #DEFINE RBUTT_BIT 1 ; GPIO 1 - PIN 6
- #DEFINE LJOY H'04' ; Left THUMBSTICK
- #DEFINE LJOY_BIT 2 ; GPIO 2 - PIN 5
- #DEFINE LBUTT H'08' ; Left BUTTON
- #DEFINE LBUTT_BIT 3 ; GPIO 3 - PIN 4
- #ELSE ;!_USE_THUMBSTICKS_ ;
- #DEFINE RBUTT_1 H'01' ; Right BUTTON 1
- #DEFINE RBUTT_1_BIT 0 ; GPIO 0 - PIN 7
- #DEFINE RBUTT_2 H'02' ; Right BUTTON 2
- #DEFINE RBUTT_2_BIT 1 ; GPIO 1 - PIN 6
- #DEFINE LBUTT_2 H'04' ; Left BUTTON 2
- #DEFINE LBUTT_2_BIT 2 ; GPIO 2 - PIN 5
- #DEFINE LBUTT_1 H'08' ; Left BUTTON 1
- #DEFINE LBUTT_1_BIT 3 ; GPIO 3 - PIN 4
- #ENDIF ;_USE_THUMBSTICKS_ ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 2bit DAC definitions. The 2bit DAC is just a ;
- ; pair of resistors on two GPIOs, which feeds ;
- ; the VIDEO out. ;
- ;-----------------------------------------------;
- #DEFINE VIDEO_1 H'10' ; 1K ohm
- #DEFINE VIDEO_1_BIT 4 ; GPIO 5 - PIN 2
- #DEFINE VIDEO_0 H'20' ; 470 ohm
- #DEFINE VIDEO_0_BIT 5 ; GPIO 4 - PIN 3
- ;
- #DEFINE COLOR_WHITE (VIDEO_0 + VIDEO_1) ;
- #DEFINE COLOR_BLACK VIDEO_1 ;
- #DEFINE COLOR_SYNC 0 ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; There are 224 lines created during _Data_Lines;
- ; However, because of memory limitations, I ;
- ; cannot allocate enough memory for the video ;
- ; buffer. So - I do have enough memory for 56 ;
- ; lines - 1/4 of 224 - so we display each line ;
- ; of data 4 times. ;
- ;-----------------------------------------------;
- #DEFINE MAX_LINES 56 ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; This is my method of making the game easier or;
- ; harder - either I update and draw the ball ;
- ; every frame (fast ball), or every other frame ;
- ; (not as fast), or every 3rd frame (normal ;
- ; ball) or higher for slower. Set MAX_BALL_WAIT ;
- ; to the desired speed (1=fast, 2=not as fast, ;
- ; 3=normal, 4=slower, etc.). This is hardcoded ;
- ; right now, a change requires a recompile. I ;
- ; have plans to allocate another precious byte ;
- ; of data memory so that the ball speed can be ;
- ; changed by a menu item. ;
- ;-----------------------------------------------;
- #DEFINE DRAW_BALL_BIT 0 ;
- #DEFINE MAX_BALL_WAIT 3 ;
- ;
- ;-----------------------------------------------;
- ; Just a bunch of hardcoded starting points, ;
- ; sizes, and bit-munching stuff for the various ;
- ; graphics. ;
- ;-----------------------------------------------;
- ; I use the PIC's LINEAR MEMORY scheme to create;
- ; a contiguous video buffer. Grab the MicroChip ;
- ; documentation and read up. Then go search on ;
- ; the web for some docs that will really explain;
- ; it for you. ;
- ;-----------------------------------------------;
- #DEFINE VIDEO_BUFFER_START H'2010' ;
- #DEFINE LEFT_SCORE_START H'01' ;
- #DEFINE RIGHT_SCORE_START H'02' ;
- #DEFINE LEFT_PADDLE_START H'00' ;
- #DEFINE LEFT_PADDLE_BIT H'40' ;
- #DEFINE LEFT_PADDLE_MASK H'BF' ;
- #DEFINE RIGHT_PADDLE_START H'03' ;
- #DEFINE RIGHT_PADDLE_BIT H'02' ;
- #DEFINE RIGHT_PADDLE_MASK H'FD' ;
- #DEFINE PADDLE_SIZE 8 ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- USER_DATA_1 UDATA H'020' ;
- ;---------------------------------------------------;
- Ball_X res 1 ; 20
- Ball_Y res 1 ; 21
- Ball_Dir_X res 1 ; 22
- Ball_Dir_Y res 1 ; 23
- Paddle_1_Y res 1 ; 24
- Paddle_2_Y res 1 ; 25
- Score_1 res 1 ; 26
- Score_2 res 1 ; 27
- Ball_Wait res 1 ; 28
- ;---------------------------------------------------;
- ; Bit definitions for System_Status ;
- ;---------------------------------------------------;
- #DEFINE BUZZ H'01' ;
- #DEFINE BUZZ_BIT 0 ;
- ;---------------------------------------------------;
- System_Status res 1 ; 29
- ;---------------------------------------------------;
- ; Only 6 bytes left - 2A-2F ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- USER_DATA_2 UDATA_SHR H'070' ;
- ;---------------------------------------------------;
- Temp1 res 1 ; 70
- Temp2 res 1 ; 71
- DTemp res 1 ; 72
- DL_Count res 1 ; 73
- Line_Data res 4 ; 74-77
- Byte_Count res 1 ; 78
- Line_Count res 1 ; 79
- Repeat_Count res 1 ; 7A
- Buzz_Count res 1 ; 7B
- Buzz_Reload res 1 ; 7C
- Buzz_Dur_HI res 1 ; 7D
- Buzz_Dur_LO res 1 ; 7E
- ;---------------------------------------------------;
- ; Only 1 bytes left! - 7F ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ; Reset Vector Code - Entry point from reset ;
- ;---------------------------------------------------;
- RESET_VECT CODE H'000' ;
- ;---------------------------------------------------;
- ; Initialize the hardware and memory elements. ;
- ; This is a FAR CALL to a proc in the high ;
- ; page of Program Memory, so it needs the ;
- ; PAGESEL before and after the CALL to properly ;
- ; set the upper 2 bits in the program counter. ;
- ; I am slowly converting ALL CALLs (and some ;
- ; GOTOs) to having PAGESEL before and after, but;
- ; the added instruction cycles mess up the video;
- ; timings in some spots. To be done slowly and ;
- ; surely. ;
- ;-----------------------------------------------;
- PAGESEL _Initialize_System ;
- CALL _Initialize_System ;
- PAGESEL $ ;
- ;-----------------------------------------------;
- ; _Next_Frame is in the high page of Program ;
- ; Memory. This is the only GOTO that is in the ;
- ; code that requires PAGESEL. ;
- ;-----------------------------------------------;
- PAGESEL _Next_Frame ;
- GOTO _Next_Frame ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ; Interrupt Vector Code ;
- ; Since we are not using or desire to use interrupts;
- ; this is not needed. ;
- ;---------------------------------------------------;
- ; INT_VECT CODE H'004' ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ; User Code in the low page of Program Memory ;
- ; More user code (USER_CODE_2) can be found in the ;
- ; high page of Program Memory, starting at H'800' ;
- ;---------------------------------------------------;
- USER_CODE_1 CODE ;
- ;---------------------------------------------------;
- _Update_Paddle_1: ;
- ;---------------------------------------------------;
- ; Note: This is a 60us line routine. ;
- ;---------------------------------------------------;
- NOP ;
- ;-----------------------------------------------;
- ; 4us Negative Sync Generation ;
- ;-----------------------------------------------;
- NEG_SYNC_4US ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 60us Blank Signal Generation ;
- ; But with lots of calculations going on ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- ;
- BANKSEL OPTION_REG ;
- BCF OPTION_REG, PSA ;
- BANKSEL TMR0 ;
- CLRF TMR0 ;
- ;
- _UP1_Clear_Paddle: ;
- MOVFW Paddle_1_Y ;
- ADDWF Paddle_1_Y, W ;
- ADDWF Paddle_1_Y, W ;
- ADDWF Paddle_1_Y, W ;
- ADDLW LOW VIDEO_BUFFER_START + LEFT_PADDLE_START;
- MOVWF FSR1L ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- MOVIW 0[INDF1] ;
- ANDLW LEFT_PADDLE_MASK ;
- MOVWI 0[INDF1] ;
- MOVIW 4[INDF1] ;
- ANDLW LEFT_PADDLE_MASK ;
- MOVWI 4[INDF1] ;
- MOVIW 8[INDF1] ;
- ANDLW LEFT_PADDLE_MASK ;
- MOVWI 8[INDF1] ;
- MOVIW 12[INDF1] ;
- ANDLW LEFT_PADDLE_MASK ;
- MOVWI 12[INDF1] ;
- MOVIW 16[INDF1] ;
- ANDLW LEFT_PADDLE_MASK ;
- MOVWI 16[INDF1] ;
- MOVIW 20[INDF1] ;
- ANDLW LEFT_PADDLE_MASK ;
- MOVWI 20[INDF1] ;
- MOVIW 24[INDF1] ;
- ANDLW LEFT_PADDLE_MASK ;
- MOVWI 24[INDF1] ;
- MOVIW 28[INDF1] ;
- ANDLW LEFT_PADDLE_MASK ;
- MOVWI 28[INDF1] ;
- ;
- #IF _USE_THUMBSTICKS_ ;
- _UP1_Update: ;
- ;-----------------------------------------------;
- ; ADC Magic (Channel 0) ;
- ;-----------------------------------------------;
- BANKSEL ADCON1 ;
- MOVLW H'60' ; Left Justified
- MOVWF ADCON1 ; FOSC/64, VREF
- MOVLW B'00001011' ; AN2, ADC GO, ADC On
- MOVWF ADCON0 ;
- BTFSC ADCON0, GO ; Wait for conversion
- GOTO $-1 ;
- MOVFW ADRESH ; Get result
- BANKSEL MEMORY ;
- ;-----------------------------------------------;
- ;
- MOVWF Temp1 ;
- MOVLW H'60' ;
- SUBWF Temp1, W ;
- BTFSS STATUS, C ;
- DECF Paddle_1_Y, F ;
- MOVLW H'9F' ;
- SUBWF Temp1, W ;
- BTFSC STATUS, C ;
- INCF Paddle_1_Y, F ;
- BTFSC Paddle_1_Y, MSB ;
- CLRF Paddle_1_Y ;
- MOVLW 48 ;
- SUBWF Paddle_1_Y, W ;
- BTFSS STATUS, C ;
- GOTO _UP1_Update_Done ;
- MOVLW 48 ;
- MOVWF Paddle_1_Y ;
- _UP1_Update_Done: ;
- #ELSE ;!_USE_THUMBSTICKS_ ;
- _UP1_Check_Up: ;
- CLRW ;
- XORWF Paddle_1_Y, W ;
- BTFSC STATUS, Z ;
- GOTO _UP1_Check_Down ;
- BTFSS PORTA, LBUTT_1_BIT ;
- DECF Paddle_1_Y, F ;
- _UP1_Check_Down: ;
- MOVLW 48 ;
- XORWF Paddle_1_Y, W ;
- BTFSC STATUS, Z ;
- GOTO _UP1_Draw_Paddle ;
- BTFSS PORTA, LBUTT_2_BIT ;
- INCF Paddle_1_Y, F ;
- #ENDIF ;_USE_THUMBSTICKS_ ;
- ;
- _UP1_Draw_Paddle: ;
- MOVFW Paddle_1_Y ;
- ADDWF Paddle_1_Y, W ;
- ADDWF Paddle_1_Y, W ;
- ADDWF Paddle_1_Y, W ;
- ADDLW LOW VIDEO_BUFFER_START + LEFT_PADDLE_START;
- MOVWF FSR1L ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- MOVIW 0[INDF1] ;
- IORLW LEFT_PADDLE_BIT ;
- MOVWI 0[INDF1] ;
- MOVIW 4[INDF1] ;
- IORLW LEFT_PADDLE_BIT ;
- MOVWI 4[INDF1] ;
- MOVIW 8[INDF1] ;
- IORLW LEFT_PADDLE_BIT ;
- MOVWI 8[INDF1] ;
- MOVIW 12[INDF1] ;
- IORLW LEFT_PADDLE_BIT ;
- MOVWI 12[INDF1] ;
- MOVIW 16[INDF1] ;
- IORLW LEFT_PADDLE_BIT ;
- MOVWI 16[INDF1] ;
- MOVIW 20[INDF1] ;
- IORLW LEFT_PADDLE_BIT ;
- MOVWI 20[INDF1] ;
- MOVIW 24[INDF1] ;
- IORLW LEFT_PADDLE_BIT ;
- MOVWI 24[INDF1] ;
- MOVIW 28[INDF1] ;
- IORLW LEFT_PADDLE_BIT ;
- MOVWI 28[INDF1] ;
- ;
- MOVFW TMR0 ;
- SUBLW 228 ;
- BTFSC STATUS, C ;
- GOTO $-3 ;
- NOP ;
- NOP ;
- NOP ;
- ;
- RETURN ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- _Update_Paddle_2: ;
- ;---------------------------------------------------;
- ; Note: This is a 60us line routine. ;
- ;---------------------------------------------------;
- ;-----------------------------------------------;
- ; 4us Negative Sync Generation ;
- ;-----------------------------------------------;
- NEG_SYNC_4US ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 60us Blank Signal Generation ;
- ; But with lots of calculations going on ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- ;
- BANKSEL OPTION_REG ;
- BCF OPTION_REG, PSA ;
- BANKSEL TMR0 ;
- CLRF TMR0 ;
- ;
- _UP2_Clear_Paddle: ;
- MOVFW Paddle_2_Y ;
- ADDWF Paddle_2_Y, W ;
- ADDWF Paddle_2_Y, W ;
- ADDWF Paddle_2_Y, W ;
- ADDLW LOW VIDEO_BUFFER_START + RIGHT_PADDLE_START;
- MOVWF FSR1L ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- MOVIW 0[INDF1] ;
- ANDLW RIGHT_PADDLE_MASK ;
- MOVWI 0[INDF1] ;
- MOVIW 4[INDF1] ;
- ANDLW RIGHT_PADDLE_MASK ;
- MOVWI 4[INDF1] ;
- MOVIW 8[INDF1] ;
- ANDLW RIGHT_PADDLE_MASK ;
- MOVWI 8[INDF1] ;
- MOVIW 12[INDF1] ;
- ANDLW RIGHT_PADDLE_MASK ;
- MOVWI 12[INDF1] ;
- MOVIW 16[INDF1] ;
- ANDLW RIGHT_PADDLE_MASK ;
- MOVWI 16[INDF1] ;
- MOVIW 20[INDF1] ;
- ANDLW RIGHT_PADDLE_MASK ;
- MOVWI 20[INDF1] ;
- MOVIW 24[INDF1] ;
- ANDLW RIGHT_PADDLE_MASK ;
- MOVWI 24[INDF1] ;
- MOVIW 28[INDF1] ;
- ANDLW RIGHT_PADDLE_MASK ;
- MOVWI 28[INDF1] ;
- ;
- #IF _USE_THUMBSTICKS_ ;
- _UP2_Update: ;
- ;-----------------------------------------------;
- ; ADC Magic (Channel 0) ;
- ;-----------------------------------------------;
- BANKSEL ADCON1 ;
- MOVLW H'60' ; Left Justified
- MOVWF ADCON1 ; FOSC/64, VREF
- MOVLW B'00000011' ; AN0, ADC GO, ADC On
- MOVWF ADCON0 ;
- BTFSC ADCON0, GO ; Wait for conversion
- GOTO $-1 ;
- MOVFW ADRESH ; Get result
- BANKSEL MEMORY ;
- ;-----------------------------------------------;
- ;
- MOVWF Temp1 ;
- MOVLW H'60' ;
- SUBWF Temp1, W ;
- BTFSS STATUS, C ;
- DECF Paddle_2_Y, F ;
- MOVLW H'9F' ;
- SUBWF Temp1, W ;
- BTFSC STATUS, C ;
- INCF Paddle_2_Y, F ;
- BTFSC Paddle_2_Y, MSB ;
- CLRF Paddle_2_Y ;
- MOVLW 48 ;
- SUBWF Paddle_2_Y, W ;
- BTFSS STATUS, C ;
- GOTO _UP2_Update_Done ;
- MOVLW 48 ;
- MOVWF Paddle_2_Y ;
- _UP2_Update_Done: ;
- #ELSE ;!_USE_THUMBSTICKS_ ;
- _UP2_Check_Up: ;
- CLRW ;
- XORWF Paddle_2_Y, W ;
- BTFSC STATUS, Z ;
- GOTO _UP2_Check_Down ;
- BTFSS PORTA, RBUTT_1_BIT ;
- DECF Paddle_2_Y, F ;
- _UP2_Check_Down: ;
- MOVLW 40 ;
- XORWF Paddle_2_Y, W ;
- BTFSC STATUS, Z ;
- GOTO _UP2_Draw_Paddle ;
- BTFSS PORTA, RBUTT_2_BIT ;
- INCF Paddle_2_Y, F ;
- #ENDIF ;_USE_THUMBSTICKS_ ;
- ;
- _UP2_Draw_Paddle: ;
- MOVFW Paddle_2_Y ;
- ADDWF Paddle_2_Y, W ;
- ADDWF Paddle_2_Y, W ;
- ADDWF Paddle_2_Y, W ;
- ADDLW LOW VIDEO_BUFFER_START + RIGHT_PADDLE_START;
- MOVWF FSR1L ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- MOVIW 0[INDF1] ;
- IORLW RIGHT_PADDLE_BIT ;
- MOVWI 0[INDF1] ;
- MOVIW 4[INDF1] ;
- IORLW RIGHT_PADDLE_BIT ;
- MOVWI 4[INDF1] ;
- MOVIW 8[INDF1] ;
- IORLW RIGHT_PADDLE_BIT ;
- MOVWI 8[INDF1] ;
- MOVIW 12[INDF1] ;
- IORLW RIGHT_PADDLE_BIT ;
- MOVWI 12[INDF1] ;
- MOVIW 16[INDF1] ;
- IORLW RIGHT_PADDLE_BIT ;
- MOVWI 16[INDF1] ;
- MOVIW 20[INDF1] ;
- IORLW RIGHT_PADDLE_BIT ;
- MOVWI 20[INDF1] ;
- MOVIW 24[INDF1] ;
- IORLW RIGHT_PADDLE_BIT ;
- MOVWI 24[INDF1] ;
- MOVIW 28[INDF1] ;
- IORLW RIGHT_PADDLE_BIT ;
- MOVWI 28[INDF1] ;
- ;
- NOP ;
- MOVFW TMR0 ;
- SUBLW 226 ;
- BTFSC STATUS, C ;
- GOTO $-3 ;
- NOP ;
- NOP ;
- ;
- RETURN ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- _Update_Ball: ;
- ;---------------------------------------------------;
- ; Note: This is a 60us line routine. ;
- ;---------------------------------------------------;
- ;-----------------------------------------------;
- ; 4us Negative Sync Generation ;
- ;-----------------------------------------------;
- NEG_SYNC_4US ;
- ;
- ;-----------------------------------------------;
- ; 60us Blank Signal Generation ;
- ; But with lots of calculations going on ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- ;
- BANKSEL OPTION_REG ;
- BCF OPTION_REG, PSA ;
- BANKSEL TMR0 ;
- CLRF TMR0 ;
- ;
- _UB_Check_Wait: ;
- DECFSZ Ball_Wait, F ;
- GOTO _UB_Exit ;
- ;
- MOVLW MAX_BALL_WAIT ;
- MOVWF Ball_Wait ;
- ;
- CLRW ;
- XORWF Ball_Dir_X, W ;
- BTFSS STATUS, Z ;
- GOTO _UB_Clear_Ball ;
- CLRW ;
- XORWF Ball_Dir_Y, W ;
- BTFSS STATUS, Z ;
- GOTO _UB_Clear_Ball ;
- ;
- _UB_Check_L_Serve: ;
- BTFSC PORTA, LBUTT_BIT ;
- GOTO _UB_Check_R_Serve ;
- MOVLW 1 ;
- MOVWF Ball_Dir_X ;
- MOVLW 1 ;
- MOVWF Ball_Dir_Y ;
- MOVLW 16 ;
- MOVWF Ball_X ;
- MOVLW 27 ;
- MOVWF Ball_Y ;
- GOTO _UB_Service ;
- _UB_Check_R_Serve: ;
- BTFSC System_Status, BUZZ_BIT ;
- GOTO _UB_Exit ;
- BANKSEL TRISA ;
- BSF TRISA, RBUTT_BIT ;
- BANKSEL PORTA ;
- BTFSC PORTA, RBUTT_BIT ;
- GOTO _UB_Exit ;
- BANKSEL TRISA ;
- BCF TRISA, RBUTT_BIT ;
- BANKSEL PORTA ;
- MOVLW -1 ;
- MOVWF Ball_Dir_X ;
- MOVLW -1 ;
- MOVWF Ball_Dir_Y ;
- MOVLW 15 ;
- MOVWF Ball_X ;
- MOVLW 27 ;
- MOVWF Ball_Y ;
- _UB_Service: ;
- PAGESEL _Clear_Court ;
- CALL _Clear_Court ;
- PAGESEL $ ;
- MOVLW H'11' ;
- XORWF Score_1, W ;
- BTFSC STATUS, Z ;
- GOTO $+5 ;
- MOVLW H'11' ;
- XORWF Score_2, W ;
- BTFSS STATUS, Z ;
- GOTO _UB_Draw_Ball ;
- CLRF Score_1 ;
- CLRF Score_2 ;
- GOTO _UB_Draw_Ball ;
- ;
- _UB_Clear_Ball: ;
- MOVFW Ball_Y ;
- ADDWF Ball_Y, W ;
- ADDWF Ball_Y, W ;
- ADDWF Ball_Y, W ;
- ADDLW LOW VIDEO_BUFFER_START ;
- MOVWF FSR1L ;
- RRF Ball_X, W ;
- MOVWF Temp1 ;
- RRF Temp1, F ;
- RRF Temp1, W ;
- ANDLW H'1F' ;
- ADDWF FSR1L, F ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- ;
- MOVFW Ball_X ;
- ANDLW H'07' ;
- MOVWF Temp1 ;
- MOVLW H'7F' ;
- MOVWF DTemp ;
- MOVLW 0 ; ;
- XORWF Temp1, W ;
- BTFSC STATUS, Z ;
- GOTO $+5 ;
- DECF Temp1, F ;
- RRF DTemp, F ;
- BSF DTemp, MSB ;
- GOTO $-7 ;
- ;
- MOVFW DTemp ;
- ANDWF INDF1, F ;
- ;
- MOVLW H'04' ;
- ADDWF FSR1L, F ;
- MOVFW DTemp ;
- ANDWF INDF1, F ;
- ;
- _UB_Update_Ball_X: ;
- MOVFW Ball_Dir_X ; Update Ball X Position
- ADDWF Ball_X, F ;
- ;
- _UB_Update_Ball_X_Min: ;
- MOVLW 0 ;
- XORWF Ball_X, W ;
- BTFSS STATUS, Z ;
- GOTO _UB_Update_Ball_X_Max ;
- MOVLW 1 ;
- MOVWF Ball_Dir_X ;
- ;
- INCF Score_2, F ;
- PLAY_SOUND 20, H'017F' ; Frequency, Duration
- MOVLW 0 ;
- MOVWF Ball_Dir_X ;
- MOVWF Ball_Dir_Y ;
- MOVLW 15 ;
- MOVWF Ball_X ;
- MOVLW 27 ;
- MOVWF Ball_Y ;
- MOVFW Score_2 ;
- ANDLW H'0F' ;
- XORLW H'0A' ;
- BTFSS STATUS, Z ;
- GOTO _UB_BXMin_Exit ;
- MOVFW Score_2 ;
- ANDLW H'F0' ;
- ADDLW H'10' ;
- MOVWF Score_2 ;
- MOVLW H'A0' ;
- XORWF Score_2, W ;
- BTFSC STATUS, Z ;
- CLRF Score_2 ;
- _UB_BXMin_Exit: ;
- MOVLW H'11' ;
- XORWF Score_2, W ;
- BTFSS STATUS, Z ;
- GOTO _UB_Exit ;
- PAGESEL _Clear_Court ;
- CALL _Clear_Court ;
- PAGESEL _Draw_Title ;
- CALL _Draw_Title ;
- PAGESEL $ ;
- GOTO _UB_Exit ;
- ;
- _UB_Update_Ball_X_Max: ;
- MOVLW 31 ;
- XORWF Ball_X, W ;
- BTFSS STATUS, Z ;
- GOTO _UB_Update_Ball_Y ;
- MOVLW -1 ;
- MOVWF Ball_Dir_X ;
- ;
- INCF Score_1, F ;
- PLAY_SOUND 20, H'017F' ; Frequency, Duration
- MOVLW 0 ;
- MOVWF Ball_Dir_X ;
- MOVWF Ball_Dir_Y ;
- MOVLW 15 ;
- MOVWF Ball_X ;
- MOVLW 27 ;
- MOVWF Ball_Y ;
- MOVFW Score_1 ;
- ANDLW H'0F' ;
- XORLW H'0A' ;
- BTFSS STATUS, Z ;
- GOTO _UB_BXMax_Exit ;
- MOVFW Score_1 ;
- ANDLW H'F0' ;
- ADDLW H'10' ;
- MOVWF Score_1 ;
- MOVLW H'A0' ;
- XORWF Score_1, W ;
- BTFSC STATUS, Z ;
- CLRF Score_1 ;
- _UB_BXMax_Exit: ;
- MOVLW H'11' ;
- XORWF Score_1, W ;
- BTFSS STATUS, Z ;
- GOTO _UB_Exit ;
- PAGESEL _Clear_Court ;
- CALL _Clear_Court ;
- PAGESEL _Draw_Title ;
- CALL _Draw_Title ;
- PAGESEL $ ;
- GOTO _UB_Exit ;
- ;
- _UB_Update_Ball_Y: ;
- MOVFW Ball_Dir_Y ; Update Ball Y Position
- ADDWF Ball_Y, F ;
- ;
- _UB_Update_Ball_Y_Min: ;
- MOVLW 0 ;
- XORWF Ball_Y, W ;
- BTFSS STATUS, Z ;
- GOTO _UB_Update_Ball_Y_Max ;
- MOVLW 1 ;
- MOVWF Ball_Dir_Y ;
- PLAY_SOUND 13, H'013F' ; Frequency, Duration
- GOTO _UB_Paddle_Detect ;
- ;
- _UB_Update_Ball_Y_Max: ;
- MOVLW 55 ;
- XORWF Ball_Y, W ;
- BTFSS STATUS, Z ;
- GOTO _UB_Paddle_Detect ;
- MOVLW -1 ;
- MOVWF Ball_Dir_Y ;
- PLAY_SOUND 13, H'013F' ; Frequency, Duration
- ;
- _UB_Paddle_Detect: ;
- _UB_Paddle_Detect_Left: ;
- MOVLW -1 ;
- XORWF Ball_Dir_X, W ;
- BTFSS STATUS, Z ;
- GOTO _UB_Paddle_Detect_Right ;
- ;
- MOVLW 2 ;
- XORWF Ball_X, W ;
- BTFSS STATUS, Z ;
- GOTO _UB_Draw_Ball ;
- ;
- MOVFW Paddle_1_Y ;
- SUBWF Ball_Y, W ;
- BTFSS STATUS, C ;
- GOTO _UB_Draw_Ball ;
- MOVFW Paddle_1_Y ;
- ADDLW 8 ;
- SUBWF Ball_Y, W ;
- BTFSC STATUS, C ;
- GOTO _UB_Draw_Ball ;
- MOVLW 1 ;
- MOVWF Ball_Dir_X ;
- PLAY_SOUND 15, H'013F' ; Frequency, Duration
- GOTO _UB_Draw_Ball ;
- ;
- _UB_Paddle_Detect_Right: ;
- MOVLW 1 ;
- XORWF Ball_Dir_X, W ;
- BTFSS STATUS, Z ;
- GOTO _UB_Draw_Ball ;
- ;
- MOVLW 29 ;
- XORWF Ball_X, W ;
- BTFSS STATUS, Z ;
- GOTO _UB_Draw_Ball ;
- ;
- MOVFW Paddle_2_Y ;
- SUBWF Ball_Y, W ;
- BTFSS STATUS, C ;
- GOTO _UB_Draw_Ball ;
- MOVFW Paddle_2_Y ;
- ADDLW 8 ;
- SUBWF Ball_Y, W ;
- BTFSC STATUS, C ;
- GOTO _UB_Draw_Ball ;
- MOVLW -1 ;
- MOVWF Ball_Dir_X ;
- PLAY_SOUND 15, H'013F' ; Frequency, Duration
- ;
- _UB_Draw_Ball: ;
- MOVFW Ball_Y ;
- ADDWF Ball_Y, W ;
- ADDWF Ball_Y, W ;
- ADDWF Ball_Y, W ;
- ADDLW LOW VIDEO_BUFFER_START ;
- MOVWF FSR1L ;
- RRF Ball_X, W ;
- MOVWF Temp1 ;
- RRF Temp1, F ;
- RRF Temp1, W ;
- ANDLW H'1F' ;
- ADDWF FSR1L, F ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- ;
- MOVFW Ball_X ;
- ANDLW H'07' ;
- MOVWF Temp1 ;
- MOVLW H'80' ;
- MOVWF DTemp ;
- MOVLW 0 ; ;
- XORWF Temp1, W ;
- BTFSC STATUS, Z ;
- GOTO $+5 ;
- DECF Temp1, F ;
- RRF DTemp, F ;
- BCF DTemp, MSB ;
- GOTO $-7 ;
- ;
- MOVFW DTemp ;
- IORWF INDF1, F ;
- ;
- MOVLW H'04' ;
- ADDWF FSR1L, F ;
- MOVFW DTemp ;
- IORWF INDF1, F ;
- ;
- _UB_Exit: ;
- BANKSEL TRISA ;
- BSF TRISA, RBUTT_BIT ;
- BANKSEL PORTA ;
- ;
- NOP ;
- MOVFW TMR0 ;
- SUBLW 227 ;
- BTFSC STATUS, C ;
- GOTO $-3 ;
- NOP ;
- ;
- RETURN ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- USER_CODE_2 CODE H'800' ;
- ;---------------------------------------------------;
- _Next_Frame: ;
- ;---------------------------------------------------;
- ;-----------------------------------------------;
- ; VERTICAL SYNC PULSE Time ;
- ; This consists of 5 blank half lines, ;
- ; 4 inverted half lines, and 5 more blank half ;
- ; lines. This totals 7 full lines of 64us each. ;
- ; --------------------------------------------- ;
- ; NOTE: Timing is CRITICAL for a nice, clean ;
- ; display. If you notice the top part of the ;
- ; display is skewed or "tearing", your timings ;
- ; are wrong and need to be adjusted. Make sure ;
- ; you haven't inadvertently dropped a half frame;
- ;-----------------------------------------------;
- ; First, a special blank 30us line. If _DEBUG_ ;
- ; is enabled, it will produce a pulse on the ;
- ; GPIO2 pin for debugging purposes (checking the;
- ; time elapsed for a single video frame). ;
- ;-----------------------------------------------;
- PAGESEL _Special_30us_Line ;
- CALL _Special_30us_Line ;
- PAGESEL $ ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 4 blank 30us lines ;
- ;-----------------------------------------------;
- MOVLW 4 ;
- MOVWF Line_Count ;
- _NF_Next_Blank_30us_Line1: ;
- PAGESEL _Blank_30us_Line ;
- CALL _Blank_30us_Line ;
- PAGESEL $ ;
- DECFSZ Line_Count, F ;
- GOTO _NF_Next_Blank_30us_Line1 ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; Timing fix for transition from 30us lines to ;
- ; inverted 30us lines. ;
- ;-----------------------------------------------;
- NOP ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 4 inverted 30us lines ;
- ;-----------------------------------------------;
- MOVLW 4 ;
- MOVWF Line_Count ;
- _NF_Next_Inverted_30us_Line: ;
- PAGESEL _Inverted_30us_Line ;
- CALL _Inverted_30us_Line ;
- PAGESEL $ ;
- DECFSZ Line_Count, F ;
- GOTO _NF_Next_Inverted_30us_Line ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 5 blank 30us lines ;
- ;-----------------------------------------------;
- MOVLW 5 ;
- MOVWF Line_Count ;
- _NF_Next_Blank_30us_Line2: ;
- PAGESEL _Blank_30us_Line ;
- CALL _Blank_30us_Line ;
- PAGESEL $ ;
- DECFSZ Line_Count, F ;
- GOTO _NF_Next_Blank_30us_Line2 ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; Just a bunch of BLANK LINES, so that the video;
- ; data doesn't start in the non-display area. ;
- ; Add or remove lines to adjust the vertical ;
- ; position of your video. If you add or remove, ;
- ; make sure to adjust the number of BLANK LINES ;
- ; which follow the data lines, so that the video;
- ; stays at 60hz ;
- ;-----------------------------------------------;
- MOVLW 15 ;
- MOVWF Line_Count ;
- _NF_Next_Blank_60us_Line: ;
- PAGESEL _Blank_60us_Line ;
- CALL _Blank_60us_Line ;
- PAGESEL $ ;
- DECFSZ Line_Count, F ;
- GOTO _NF_Next_Blank_60us_Line ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 224 Data lines + 2 Blank Lines (1 before and ;
- ; one after) for timing fixes ;
- ;-----------------------------------------------;
- PAGESEL _Data_Lines ;
- CALL _Data_Lines ;
- PAGESEL $ ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 8 lines for the copyright. So, to summarize: ;
- ; (note - I needed four full 60us frames for ;
- ; the game processing (paddles, ball, scores, ;
- ; etc.), so I moved four blank line there for ;
- ; use for those routines) ;
- ; ;
- ; - 7 VERTICAL SYNC lines ;
- ; - 15 BLANK LINES ;
- ; - 1 BLANK LINE (for timing fixes) ;
- ; - 224 DATA LINES ;
- ; - 1 BLANK LINE (for timing fixes) ;
- ; - 8 LINES FOR COPYRIGHT ;
- ; - 4 BLANK LINES (game processing) ;
- ; ;
- ; For a total of 260 lines at 64us each, or ;
- ; 16.664ms, or approximately 60hz. 16.666ms ;
- ; would be _perfect_. ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; Display copyright and software version number ;
- ;-----------------------------------------------;
- PAGESEL _Copyright ;
- CALL _Copyright ; 8 blank FULL line (60us)
- PAGESEL $ ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; All of the game processing is done here, the ;
- ; last 4 full 60us blank lines ;
- ;-----------------------------------------------;
- PAGESEL _Update_Ball ;
- CALL _Update_Ball ; 1 blank FULL line (60us)
- PAGESEL $ ; (ball computations)
- PAGESEL _Update_Scores ;
- CALL _Update_Scores ; 1 blank FULL line (60us)
- PAGESEL $ ; (score display)
- PAGESEL _Update_Paddle_1 ;
- CALL _Update_Paddle_1 ; 1 blank FULL line (60us)
- PAGESEL $ ; (paddle 1 computations)
- PAGESEL _Update_Paddle_2 ;
- CALL _Update_Paddle_2 ; 1 blank FULL line (60us)
- PAGESEL $ ; (paddle 2 computations)
- ;-----------------------------------------------;
- ;
- GOTO _Next_Frame ;
- ;---------------------------------------------------;
- ;
- ;---------------------------------------------------;
- _Blank_30us_Line: ;
- ;---------------------------------------------------;
- ; Used only during VERTICAL SYNC ;
- ; NOTE: This is a 30us line routine ;
- ;---------------------------------------------------;
- ;-----------------------------------------------;
- ; 2us Negative Sync Generation ;
- ;-----------------------------------------------;
- NEG_SYNC_2US ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 30us Blank Signal Generation ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- ;
- BANKSEL OPTION_REG ;
- BCF OPTION_REG, PSA ;
- BANKSEL TMR0 ;
- CLRF TMR0 ;
- ;
- NOP ;
- MOVFW TMR0 ;
- SUBLW 106 ;
- BTFSC STATUS, C ;
- GOTO $-3 ;
- NOP ;
- NOP ;
- NOP ;
- ;-----------------------------------------------;
- ;
- RETURN ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- _Special_30us_Line: ;
- ;---------------------------------------------------;
- ; Note: This is a 30us line routine. ;
- ;---------------------------------------------------;
- ;-----------------------------------------------;
- ; 2us Negative Sync Generation ;
- ;-----------------------------------------------;
- NEG_SYNC_2US ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 30us Blank Signal Generation (SPECIAL) ;
- ;-----------------------------------------------;
- ; If _DEBUG_ is TRUE, this will generate a ;
- ; pulse on GPIO2 for debug purposes - used to ;
- ; check the timing of a complete video frame. ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- ;
- BANKSEL OPTION_REG ;
- BCF OPTION_REG, PSA ;
- BANKSEL TMR0 ;
- CLRF TMR0 ;
- ;
- #IF _DEBUG_ ;
- BANKSEL TRISA ;
- BCF TRISA, 2 ;
- BANKSEL PORTA ;
- BCF PORTA, 2 ;
- NOP ;
- BSF PORTA, 2 ;
- BANKSEL TRISA ;
- BSF TRISA, 2 ;
- BANKSEL MEMORY ;
- #ENDIF ; _DEBUG_ ;
- ;
- NOP ;
- MOVFW TMR0 ;
- SUBLW 106 ;
- BTFSC STATUS, C ;
- GOTO $-3 ;
- ;
- ;-----------------------------------------------;
- ; This is what irks me about using the Timers ;
- ; for timing the video signals. You would think ;
- ; that since the timing comes AFTER the debug ;
- ; code that is there - or not there - the ;
- ; use of the timer should give you a stable ;
- ; timing. But no - each case requires hand ;
- ; tweaks in order to get the timings right. This;
- ; has been driving me a bit crazy for the entire;
- ; project. Thank God for my USBee ZX analyzer. ;
- ;-----------------------------------------------;
- #IF !_DEBUG_ ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- #ENDIF ; !_DEBUG_ ;
- ;
- ;-----------------------------------------------;
- ;
- RETURN ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- _Inverted_30us_Line: ;
- ;---------------------------------------------------;
- ; Used only during VERTICAL SYNC ;
- ; Note: This is a 30us line routine. ;
- ;---------------------------------------------------;
- ;-----------------------------------------------;
- ; 30us Inverted Signal Generation ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_SYNC ;
- DELAY 77 ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 2s Positive Sync Generation ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- ; DELAY 1 ;
- NOP ;
- NOP ;
- NOP ;
- ; POS_SYNC_2US ;
- ;-----------------------------------------------;
- ;
- RETURN ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- _Blank_60us_Line: ;
- ;---------------------------------------------------;
- ; Note: This is a 60us line routine. ;
- ;---------------------------------------------------;
- ;-----------------------------------------------;
- ; 4us Negative Sync Generation ;
- ;-----------------------------------------------;
- NEG_SYNC_4US ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 60us Black Signal Generation ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- DELAY 155 ;
- NOP ;
- ;-----------------------------------------------;
- ;
- RETURN ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- _Data_Lines: ;
- ;---------------------------------------------------;
- ; Note: This will generate 1 60us blank line, then ;
- ; 224 60us data lines, and finally a 60us blank line;
- ;---------------------------------------------------;
- ;-----------------------------------------------;
- ; 4us Negative Sync Generation ;
- ;-----------------------------------------------;
- NEG_SYNC_4US ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- ;
- MOVLW MAX_LINES ;
- MOVWF DL_Count ;
- ;
- MOVLW LOW VIDEO_BUFFER_START ;
- MOVWF FSR1L ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- ;
- ;-----------------------------------------------;
- ; 60us Black Signal Generation ;
- ;-----------------------------------------------;
- DELAY 155 ;
- NOP ;
- NOP ;
- ;-----------------------------------------------;
- ;
- _DL_Next_Line: ;
- MOVLW 4 ;
- MOVWF Repeat_Count ;
- _DL_Repeat_Line: ;
- ;-----------------------------------------------;
- ; 4us Negative Sync Generation ;
- ;-----------------------------------------------;
- NEG_SYNC_4US ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; Front porch - shifts the data to the right ;
- ; and hopefully centers it on the screen ;
- ; --------------------------------------------- ;
- ; NOTE: a DELAY 12 produces a nice 7.5us porch ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- DELAY 15 ;
- ;-----------------------------------------------;
- ;
- MOVLW H'FC' ;
- ANDWF FSR1L, F ;
- MOVLW 4 ;
- MOVWF Byte_Count ;
- _DL_Next_Byte: ;
- ;-----------------------------------------------;
- ; This is where the 32 bits of data are actually;
- ; send out over the video signal ;
- ;-----------------------------------------------;
- DO_BIT 7, 8 ;
- DO_BIT 6, 8 ;
- DO_BIT 5, 8 ;
- DO_BIT 4, 8 ;
- DO_BIT 3, 8 ;
- DO_BIT 2, 8 ;
- DO_BIT 1, 8 ;
- DO_BIT 0, 1 ;
- ;
- ADDFSR FSR1, 1 ;
- ;
- _DL_Center_Line: ;
- MOVLW 3 ;
- XORWF Byte_Count, W ;
- BTFSS STATUS, Z ;
- GOTO _DL_Center_Line_Done ;
- NOP ;
- NOP ;
- NOP ;
- BCF PORTA, VIDEO_0_BIT ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- BSF PORTA, VIDEO_0_BIT ;
- NOP ;
- BCF PORTA, VIDEO_0_BIT ;
- _DL_Center_Line_Done: ;
- ;
- DECFSZ Byte_Count, F ;
- GOTO _DL_Next_Byte ;
- DECF FSR1L, F ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; Back porch - between this and the front porch,;
- ; this 'frames' the video on your TV (hopefully);
- ; --------------------------------------------- ;
- ; NOTE: a DELAY 8 (plus a NOP) produces a ;
- ; nice 4.5us back porch, which fleshes out the ;
- ; data line to 60us ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- DELAY 2 ;
- NOP ;
- NOP ;
- ;-----------------------------------------------;
- ;
- DECFSZ Repeat_Count, F ;
- GOTO $+2 ;
- GOTO _DL_Next_Data ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- GOTO _DL_Repeat_Line ;
- ;
- ;-----------------------------------------------;
- ; 224 lines of information to transmit ;
- ; so the screen size is 32x224. But we transmit ;
- ; each line 4 times, so it's actually 32x56 ;
- ;-----------------------------------------------;
- _DL_Next_Data: ;
- NOP ;
- ADDFSR FSR1, 1 ;
- DECFSZ DL_Count, F ;
- GOTO _DL_Next_Line ;
- ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- ;-----------------------------------------------;
- ; 4us Negative Sync Generation ;
- ;-----------------------------------------------;
- NEG_SYNC_4US ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 60us Black Signal Generation ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- DELAY 154 ;
- NOP ;
- ;
- ;-----------------------------------------------;
- ;
- RETURN ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- _Clear_Court: ;
- ;---------------------------------------------------;
- MOVLW LOW VIDEO_BUFFER_START ;
- MOVWF FSR1L ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- MOVLW MAX_LINES * 4 ;
- MOVWF Temp1 ; 224 bytes
- _CC_Next_Byte: ;
- MOVLW H'00' ;
- MOVWF INDF1 ;
- INCF FSR1L, F ;
- DECFSZ Temp1, F ;
- GOTO _CC_Next_Byte ;
- RETURN ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- _Update_Scores: ;
- ;---------------------------------------------------;
- ; Note: This is a 60us line routine. ;
- ;---------------------------------------------------;
- ; This will retrieve the character font information ;
- ; from high program memory and display the two ;
- ; scores at the top middle of the screen. It takes ;
- ; around 40.5us to display both scores. ;
- ;---------------------------------------------------;
- ;-----------------------------------------------;
- ; 4us Negative Sync Generation ;
- ;-----------------------------------------------;
- NEG_SYNC_4US ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 60us Blank Signal Generation ;
- ; But with lots of calculations going on ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- ;
- BANKSEL OPTION_REG ;
- BCF OPTION_REG, PSA ;
- BANKSEL TMR0 ;
- CLRF TMR0 ;
- ;
- _US_Draw_Score1: ;
- _US1_Clear_Score: ;
- MOVLW LOW VIDEO_BUFFER_START + LEFT_SCORE_START;
- MOVWF FSR1L ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- ;
- CLRW ;
- MOVWI 0[INDF1] ;
- MOVWI 4[INDF1] ;
- MOVWI 8[INDF1] ;
- MOVWI 12[INDF1] ;
- MOVWI 16[INDF1] ;
- ;
- _US1_Draw_Left_Char: ;
- SWAPF Score_1, W ;
- ANDLW H'0F' ;
- MOVWF Temp1 ;
- ;
- MOVLW LOW VIDEO_BUFFER_START + LEFT_SCORE_START;
- MOVWF FSR1L ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- ;
- MOVLW HIGH CHARACTER_TABLE ;
- MOVWF FSR0H ;
- MOVLW LOW CHARACTER_TABLE ;
- ADDWF Temp1, W ;
- BTFSC STATUS, C ;
- INCF FSR0H, F ;
- MOVWF FSR0L ;
- ;
- MOVLW 5 ;
- MOVWF Temp1 ;
- _US1_DLC_Next_Line: ;
- MOVFW INDF0 ;
- MOVWF DTemp ;
- RRF DTemp, W ;
- ANDLW H'70' ;
- MOVWF INDF1 ;
- ADDFSR FSR0, 10 ;
- ADDFSR FSR1, 4 ;
- DECFSZ Temp1, F ;
- GOTO _US1_DLC_Next_Line ;
- ;
- _US1_Draw_Right_Char: ;
- MOVFW Score_1 ;
- ANDLW H'0F' ;
- MOVWF Temp1 ;
- ;
- MOVLW LOW VIDEO_BUFFER_START + LEFT_SCORE_START;
- MOVWF FSR1L ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- ;
- MOVLW HIGH CHARACTER_TABLE ;
- MOVWF FSR0H ;
- MOVLW LOW CHARACTER_TABLE ;
- ADDWF Temp1, W ;
- BTFSC STATUS, C ;
- INCF FSR0H, F ;
- MOVWF FSR0L ;
- ;
- MOVLW 5 ;
- MOVWF Temp1 ;
- _US1_DRC_Next_Line ;
- MOVFW INDF0 ;
- MOVWF DTemp ;
- RRF DTemp, W ;
- ANDLW H'07' ;
- MOVWF DTemp ;
- MOVFW INDF1 ;
- IORWF DTemp, W ;
- MOVWF INDF1 ;
- ADDFSR FSR0, 10 ;
- ADDFSR FSR1, 4 ;
- DECFSZ Temp1, F ;
- GOTO _US1_DRC_Next_Line ;
- ;
- _US_Draw_Score2: ;
- _US2_Clear_Score: ;
- MOVLW LOW VIDEO_BUFFER_START + RIGHT_SCORE_START;
- MOVWF FSR1L ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- ;
- CLRW ;
- MOVWI 0[INDF1] ;
- MOVWI 4[INDF1] ;
- MOVWI 8[INDF1] ;
- MOVWI 12[INDF1] ;
- MOVWI 16[INDF1] ;
- ;
- _US2_Draw_Left_Char: ;
- SWAPF Score_2, W ;
- ANDLW H'0F' ;
- MOVWF Temp1 ;
- ;
- MOVLW LOW VIDEO_BUFFER_START + RIGHT_SCORE_START;
- MOVWF FSR1L ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- ;
- MOVLW HIGH CHARACTER_TABLE ;
- MOVWF FSR0H ;
- MOVLW LOW CHARACTER_TABLE ;
- ADDWF Temp1, W ;
- BTFSC STATUS, C ;
- INCF FSR0H, F ;
- MOVWF FSR0L ;
- ;
- MOVLW 5 ;
- MOVWF Temp1 ;
- _US2_DLC_Next_Line: ;
- MOVFW INDF0 ;
- ANDLW H'E0' ;
- MOVWF INDF1 ;
- ADDFSR FSR0, 10 ;
- ADDFSR FSR1, 4 ;
- DECFSZ Temp1, F ;
- GOTO _US2_DLC_Next_Line ;
- ;
- _US2_Draw_Right_Char: ;
- MOVFW Score_2 ;
- ANDLW H'0F' ;
- MOVWF Temp1 ;
- ;
- MOVLW LOW VIDEO_BUFFER_START + RIGHT_SCORE_START;
- MOVWF FSR1L ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- ;
- MOVLW HIGH CHARACTER_TABLE ;
- MOVWF FSR0H ;
- MOVLW LOW CHARACTER_TABLE ;
- ADDWF Temp1, W ;
- BTFSC STATUS, C ;
- INCF FSR0H, F ;
- MOVWF FSR0L ;
- MOVLW 5 ;
- MOVWF Temp1 ;
- _US2_DRC_Next_Line: ;
- MOVFW INDF0 ;
- ANDLW H'0E' ;
- MOVWF DTemp ;
- MOVFW INDF1 ;
- IORWF DTemp, W ;
- MOVWF INDF1 ;
- ADDFSR FSR0, 10 ;
- ADDFSR FSR1, 4 ;
- DECFSZ Temp1, F ;
- GOTO _US2_DRC_Next_Line ;
- ;
- NOP ;
- MOVFW TMR0 ;
- SUBLW 227 ;
- BTFSC STATUS, C ;
- GOTO $-3 ;
- NOP ;
- NOP ;
- NOP ;
- NOP ;
- ;
- RETURN ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- _Initialize_System: ;
- ;---;-----------------------------------------------;
- ; Initialize Hardware ;
- ;-----------------------------------------------;
- BANKSEL OSCCON ;
- MOVLW B'11110000' ; 32Mhz
- MOVWF OSCCON ;
- ;
- BANKSEL OSCSTAT ; Wait for
- IS1:MOVFW OSCSTAT ; high speed
- ANDLW H'79' ; oscillator
- XORLW H'59' ; to be
- BTFSS STATUS, Z ; stable and
- GOTO IS1 ; locked
- ;
- BANKSEL ANSELA ;
- CLRF ANSELA ; ALL I/O as digital
- #IF _USE_THUMBSTICKS_ ;
- BSF ANSELA, LJOY_BIT ;
- BSF ANSELA, RJOY_BIT ;
- #ENDIF ;_USE_THUMBSTICKS_ ;
- ;
- BANKSEL LATA ;
- CLRF LATA ;
- ;
- BANKSEL TRISA ;
- CLRF TRISA ;
- BCF TRISA, VIDEO_0_BIT ; Set as OUTPUT
- BCF TRISA, VIDEO_1_BIT ; Set As OUTPUT
- #IF _USE_THUMBSTICKS_ ;
- BSF TRISA, LJOY_BIT ; Set as INPUT
- BSF TRISA, LBUTT_BIT ; Set as INPUT
- BSF TRISA, RJOY_BIT ; Set as INPUT
- BCF TRISA, RBUTT_BIT ; Set as OUTPUT (PIEZO)
- #ELSE ;!_USE_THUMBSTICKS_ ;
- BSF TRISA, LBUTT_1_BIT ; Set as INPUT
- BSF TRISA, LBUTT_2_BIT ; Set as INPUT
- BSF TRISA, RBUTT_1_BIT ; Set as INPUT
- BSF TRISA, RBUTT_2_BIT ; Set as INPUT
- #ENDIF ;_USE_THUMBSTICKS_ ;
- ;
- BANKSEL PORTA ;
- CLRF PORTA ;
- BCF PORTA, VIDEO_0_BIT ; Set LOW
- BCF PORTA, VIDEO_1_BIT ; Set LOW
- #IF _USE_THUMBSTICKS_ ;
- BSF PORTA, LJOY_BIT ; Set HIGH
- BSF PORTA, LBUTT_BIT ; Set HIGH
- BSF PORTA, RJOY_BIT ; Set HIGH
- BSF PORTA, RBUTT_BIT ; Set HIGH
- #ELSE ;!_USE_THUMBSTICKS_ ;
- BSF PORTA, LBUTT_1_BIT ; Set HIGH
- BSF PORTA, LBUTT_2_BIT ; Set HIGH
- BSF PORTA, RBUTT_1_BIT ; Set HIGH
- BSF PORTA, RBUTT_2_BIT ; Set HIGH
- #ENDIF ;_USE_THUMBSTICKS_ ;
- ;
- BANKSEL INTCON ;
- CLRF INTCON ;
- ;
- BANKSEL OPTION_REG ;
- CLRF OPTION_REG ;
- ;
- ;-----------------------------------------------;
- ; Initialize Timer0 (for counting cycles) ;
- ;-----------------------------------------------;
- BANKSEL OPTION_REG ;
- BCF OPTION_REG, NOT_WPUEN ;
- BCF OPTION_REG, TMR0CS ;
- BCF OPTION_REG, PSA ; prescaler to timer0
- BCF OPTION_REG, PS2 ;
- BCF OPTION_REG, PS1 ; 000 - 250ns
- BCF OPTION_REG, PS0 ;
- BANKSEL TMR0 ;
- CLRF TMR0 ;
- ;
- ;-----------------------------------------------;
- ; Initialize Video Buffer ;
- ; Copy image from EEPROM into buffer memory ;
- ;-----------------------------------------------;
- BANKSEL MEMORY ;
- PAGESEL _Clear_Court ;
- CALL _Clear_Court ;
- PAGESEL _Draw_Title ;
- CALL _Draw_Title ;
- PAGESEL $ ;
- ;
- ;-----------------------------------------------;
- ; Initialize Memory ;
- ;-----------------------------------------------;
- BANKSEL MEMORY ;
- CLRF System_Status ;
- MOVLW 0 ;
- MOVWF Buzz_Count ;
- MOVWF Buzz_Reload ;
- MOVLW H'FF' ;
- MOVWF Buzz_Dur_LO ;
- MOVLW H'FF' ;
- MOVWF Buzz_Dur_HI ;
- MOVLW MAX_BALL_WAIT ;
- MOVWF Ball_Wait ;
- MOVLW 0 ;
- MOVWF Score_1 ;
- MOVLW 0 ;
- MOVWF Score_2 ;
- MOVLW 20 ;
- MOVWF Paddle_1_Y ;
- MOVLW 20 ;
- MOVWF Paddle_2_Y ;
- MOVLW 15 ;
- MOVWF Ball_X ;
- MOVLW 27 ;
- MOVWF Ball_Y ;
- MOVLW 0 ;
- MOVWF Ball_Dir_X ;
- MOVLW 0 ;
- MOVWF Ball_Dir_Y ;
- ;
- ;-----------------------------------------------;
- ; Initialize Other Subsystems ;
- ;-----------------------------------------------;
- ;
- RETURN ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ; Numeric Characters (0-9) Scan Line Data ;
- ;---------------------------------------------------;
- CHARACTER_TABLE: ;
- ;---------------------------------------------------;
- DT B'11101110', B'01000100', B'11101110', B'11101110', B'10101010', B'11101110', B'11101110', B'11101110', B'11101110', B'11101110'
- DT B'10101010', B'11001100', B'00100010', B'00100010', B'10101010', B'10001000', B'10001000', B'00100010', B'10101010', B'10101010'
- DT B'10101010', B'01000100', B'11101110', B'11101110', B'11101110', B'11101110', B'11101110', B'00100010', B'11101110', B'11101110'
- DT B'10101010', B'01000100', B'10001000', B'00100010', B'00100010', B'00100010', B'10101010', B'00100010', B'10101010', B'00100010'
- DT B'11101110', B'01000100', B'11101110', B'11101110', B'00100010', B'11101110', B'11101110', B'00100010', B'11101110', B'00100010'
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- _Draw_Title: ;
- ;---------------------------------------------------;
- MOVLW LOW VIDEO_BUFFER_START + (11 * 4) ;
- MOVWF FSR1L ;
- MOVLW HIGH VIDEO_BUFFER_START ;
- MOVWF FSR1H ;
- MOVLW LOW TITLE_TABLE ;
- MOVWF FSR0L ;
- MOVLW HIGH TITLE_TABLE ;
- MOVWF FSR0H ;
- MOVLW TITLE_TABLE_END - TITLE_TABLE_START ;
- MOVWF Temp1 ;
- _DT_Next_Byte: ;
- MOVFW INDF0 ;
- MOVWF INDF1 ;
- ADDFSR FSR1, 1 ;
- ADDFSR FSR0, 1 ;
- DECFSZ Temp1, F ;
- GOTO _DT_Next_Byte ;
- RETURN ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ; Title Title Scan Line Data ;
- ;---------------------------------------------------;
- TITLE_TABLE: ;
- ;---------------------------------------------------;
- TITLE_TABLE_START: ;
- DT B'00000000', B'00000000', B'00000000', B'00000000'
- DT B'00000000', B'01100010', B'01000100', B'00000000'
- DT B'00000000', B'01110111', B'11101110', B'00000000'
- DT B'00000000', B'01010101', B'10101010', B'00000000'
- DT B'00000000', B'01010101', B'10101010', B'00000000'
- DT B'00000000', B'01010101', B'10101010', B'00000000'
- DT B'00000000', B'01010101', B'10101010', B'00000000'
- DT B'00000000', B'01110101', B'10101110', B'00000000'
- DT B'00000000', B'01100101', B'10100110', B'00000000'
- DT B'00000000', B'01000101', B'10100010', B'00000000'
- DT B'00000000', B'01000101', B'10101010', B'00000000'
- DT B'00000000', B'01000111', B'10101110', B'00000000'
- DT B'00000000', B'01000010', B'10100100', B'00000000'
- DT B'00000000', B'00000000', B'00000000', B'00000000'
- DT B'00001110', B'01001100', B'01110101', B'01110000'
- DT B'00001110', B'11101110', B'01110101', B'01110000'
- DT B'00001000', B'10101010', B'00100101', B'01000000'
- DT B'00001000', B'10101010', B'00100101', B'01000000'
- DT B'00001000', B'10101010', B'00100101', B'01000000'
- DT B'00001100', B'10101110', B'00100111', B'01100000'
- DT B'00001100', B'10101100', B'00100111', B'01100000'
- DT B'00001000', B'10101010', B'00100101', B'01000000'
- DT B'00001000', B'10101010', B'00100101', B'01000000'
- DT B'00001000', B'10101010', B'00100101', B'01000000'
- DT B'00001000', B'11101010', B'00100101', B'01110000'
- DT B'00001000', B'01001010', B'00100101', B'01110000'
- DT B'00000000', B'00000000', B'00000000', B'00000000'
- DT B'00000101', B'10011101', B'01001010', B'01000000'
- DT B'00000101', B'11011101', B'11101010', B'11100000'
- DT B'00000100', B'01010001', B'10101010', B'10100000'
- DT B'00000100', B'01010001', B'10101010', B'10100000'
- DT B'00000100', B'11010001', B'11101010', B'10100000'
- DT B'00000101', B'11011001', B'01001110', B'10100000'
- DT B'00000101', B'00011001', B'11101110', B'10100000'
- DT B'00000101', B'00010001', B'10100010', B'10100000'
- DT B'00000101', B'00010001', B'10100010', B'10100000'
- DT B'00000101', B'00010001', B'10100010', B'10100000'
- DT B'00000101', B'11010001', B'11100010', B'11100000'
- DT B'00000101', B'11010001', B'01000010', B'01000000'
- DT B'00000000', B'00000000', B'00000000', B'00000000'
- TITLE_TABLE_END: ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- _Copyright: ;
- ;---------------------------------------------------;
- ; Note: This is a 60us line routine. It will ;
- ; generate 8 60us data lines. ;
- ;---------------------------------------------------;
- ;-----------------------------------------------;
- ; Setup ;
- ;-----------------------------------------------;
- MOVLW LOW COPYRIGHT_TABLE ;
- MOVWF FSR1L ;
- MOVLW HIGH COPYRIGHT_TABLE ;
- MOVWF FSR1H ;
- MOVLW 8 ;
- MOVWF Temp1 ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; 8 64us Data Line Generation ;
- ;-----------------------------------------------;
- _CR_Next_Line: ;
- NOP ;
- ;-----------------------------------------------;
- ; 4us Negative Sync Generation ;
- ;-----------------------------------------------;
- NEG_SYNC_4US ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; Xus Back Porch (Black Signal) Generation ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- DELAY 4 ;
- NOP ;
- NOP ;
- NOP ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; Data Generation ;
- ;-----------------------------------------------;
- DO_BIT 7, 1 ;
- DO_BIT 6, 1 ;
- DO_BIT 5, 1 ;
- DO_BIT 4, 1 ;
- DO_BIT 3, 1 ;
- DO_BIT 2, 1 ;
- DO_BIT 1, 1 ;
- DO_BIT 0, 0 ;
- ADDFSR FSR1, 1 ;
- DO_BIT 7, 1 ;
- DO_BIT 6, 1 ;
- DO_BIT 5, 1 ;
- DO_BIT 4, 1 ;
- DO_BIT 3, 1 ;
- DO_BIT 2, 1 ;
- DO_BIT 1, 1 ;
- DO_BIT 0, 0 ;
- ADDFSR FSR1, 1 ;
- DO_BIT 7, 1 ;
- DO_BIT 6, 1 ;
- DO_BIT 5, 1 ;
- DO_BIT 4, 1 ;
- DO_BIT 3, 1 ;
- DO_BIT 2, 1 ;
- DO_BIT 1, 1 ;
- DO_BIT 0, 0 ;
- ADDFSR FSR1, 1 ;
- DO_BIT 7, 1 ;
- DO_BIT 6, 1 ;
- DO_BIT 5, 1 ;
- DO_BIT 4, 1 ;
- DO_BIT 3, 1 ;
- DO_BIT 2, 1 ;
- DO_BIT 1, 1 ;
- DO_BIT 0, 0 ;
- ADDFSR FSR1, 1 ;
- DO_BIT 7, 1 ;
- DO_BIT 6, 1 ;
- DO_BIT 5, 1 ;
- DO_BIT 4, 1 ;
- DO_BIT 3, 1 ;
- DO_BIT 2, 1 ;
- DO_BIT 1, 1 ;
- DO_BIT 0, 0 ;
- ADDFSR FSR1, 1 ;
- DO_BIT 7, 1 ;
- DO_BIT 6, 1 ;
- DO_BIT 5, 1 ;
- DO_BIT 4, 1 ;
- DO_BIT 3, 1 ;
- DO_BIT 2, 1 ;
- DO_BIT 1, 1 ;
- DO_BIT 0, 0 ;
- ADDFSR FSR1, 1 ;
- DO_BIT 7, 1 ;
- DO_BIT 6, 1 ;
- DO_BIT 5, 1 ;
- DO_BIT 4, 1 ;
- DO_BIT 3, 1 ;
- DO_BIT 2, 1 ;
- DO_BIT 1, 1 ;
- DO_BIT 0, 0 ;
- ADDFSR FSR1, 1 ;
- DO_BIT 7, 1 ;
- DO_BIT 6, 1 ;
- DO_BIT 5, 1 ;
- DO_BIT 4, 1 ;
- DO_BIT 3, 1 ;
- DO_BIT 2, 1 ;
- DO_BIT 1, 1 ;
- DO_BIT 0, 0 ;
- ADDFSR FSR1, 1 ;
- ;-----------------------------------------------;
- ;
- ;-----------------------------------------------;
- ; Xus Front Porch (Black Signal) Generation ;
- ;-----------------------------------------------;
- SET_SIGNAL COLOR_BLACK ;
- ;-----------------------------------------------;
- ;
- DECFSZ Temp1, F ;
- GOTO $+3 ;
- NOP ;
- RETURN ;
- NOP ;
- NOP ;
- GOTO _CR_Next_Line ;
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- ; COPYRIGHT Scan Line Data ;
- ;---------------------------------------------------;
- COPYRIGHT_TABLE: ;
- ;---------------------------------------------------;
- DT B'00000110', B'01110111', B'00010010', B'01001110', B'01000101', B'11000101', B'01110000', B'10011100'
- DT B'00000111', B'01110111', B'00100111', B'00101110', B'11101101', B'11000101', B'01110001', B'11011100'
- DT B'00000101', B'00100010', B'00100101', B'00100010', B'10100100', B'01000101', B'00010001', B'01000100'
- DT B'01010101', B'00100010', B'00100100', B'00101110', B'10100101', B'11010101', B'00110001', B'01001100'
- DT B'01010101', B'00100010', B'00100100', B'00101110', B'10100101', B'11010101', B'00110001', B'01001100'
- DT B'00000101', B'00100010', B'00100101', B'00101000', B'10100101', B'00000101', B'00010001', B'01000100'
- DT B'00000111', B'00100111', B'00100111', B'00101110', B'11100101', B'11000101', B'01110101', B'11011100'
- DT B'00000110', B'00100111', B'00010010', B'01001110', B'01000101', B'11000010', B'01110100', B'10011100'
- ;---------------------------------------------------;
- ;---------------------------------------------------;
- END ;
- ;---------------------------------------------------;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement