亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? receiver.asm

?? WII游戲機(jī)無(wú)線手柄SNES通訊模塊
?? ASM
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
; ================================================================================================
; PROJECT:		SnesHack - A wireless/Wii-enabled SNES and NES controller hack.
; FILENAME:		Receiver.asm
; DESCRIPTION:	Code for the 16F84A receiver firmware.
; COPYRIGHT:	Copyright (c) 2007 Mark Feldman. All Rights Reserved.
; ================================================================================================

	list	p=16F84A
	radix	hex

	#include "C:\Program Files\Microchip\MPASM Suite\p16f84a.inc"

	__config	_HS_OSC & _PWRTE_OFF & _WDT_OFF & _CP_OFF

; ================================================================================================
; constants
; ================================================================================================

FALSE					equ	0
TRUE					equ	(!FALSE)

; used when we've lost the wireless signal. this is the number of good packets in a row we need
; to receive before assuming that we're picking up a good signal again.
VALID_SIGNAL_COUNT		equ 3

; REC_PORT/REC_BIT reads data from the console, it needs to be a pin that can trigger an interrupt.
; SEND_PORT/SEND_BIT sends data to the console on the same line, it needs to be open collector.
; these pins are both connected directly to the console's data line; if this program is ported
; to another type of PIC then there is no reason why they can't be implemented with a single pin,
; provided that pin supports interrupt-on-falling-edge and is open collector output.
REC_PORT				equ	PORTB
REC_BIT					equ 0
SEND_PORT				equ PORTA
SEND_BIT				equ 4

; this pin reads incoming data packets from the wireless receiver module.
WIRELESS_PORT			equ PORTB
WIRELESS_BIT			equ 1

; these pins are used to control the bidirectional red/green LED used to indicate whether or
; not we are receiving a valid wireless signal. they have no other function and can be safely
; removed if needed.
RED_LED_PORT			equ PORTB
RED_LED_BIT				equ 2
GREEN_LED_PORT			equ PORTB
GREEN_LED_BIT			equ 3

; this pin is used to generate a test signal that is held high while a wireless packet is being read.
; it has no other function, and can be safely removed if needed.
TEST_PORT				equ PORTB
TEST_BIT				equ 4

; ================================================================================================
; variables
; ================================================================================================

; variables used by the interrupt handler when receiving console packets
W_TEMP					equ 0Ch				; saves W
STATUS_TEMP				equ 0Dh				; saves STATUS
RECEIVED_PACKET			equ 0Eh				; lets main loop know that a packet was just received
BITS_READ				equ 0Fh				; total number of bits read so far
BITS_TO_SEND			equ	10h				; total number of bits to send to the console
BIT_NUM					equ	11h				; total number of bits in the current byte read/sent
CURRENT_BYTE			equ	12h				; curent byte being sent (so we don't trash the value in INDF)

; scratch variables used by the wireless timing routines
TIMER1					equ	14h
TIMER2					equ	15h

; used when we've lost the wireless signal, counts the number of good packets
; in a row that we've received
PACKET_COUNTER			equ	16h

; counts the number of interrupts we've had since the last valid wireless packet was received.
; when this number exceeds some critical value (hard-coded to 10) then the receiver assumes
; we've lost the wireless signal.
TIMEOUT_COUNTER			equ	17h

; temporary 2-byte buffer used to store button data read in from the wireless packets.
; the data is then copied into the WIRELESS_BUTTONS packet for sending to the console.
WIRELESS_BUTTONS		equ 18h

; an 11-byte packet sent to the console containing the button press states. the first
; two bytes of this structure are filled with the data from WIRELESS_BUTTONS after a
; complete, uncorrupted packet has been received from the wireless module. this
; double-buffering helps avoid random button messages being sent to the controller
; when the wireless signal is disconnected mid-packet.
CONSOLE_BUTTONS			equ 20h

; a general buffer area used to store packet data sent to and received from the console
PACKET_BUFFER			equ 30h

; ================================================================================================
; macros
; ================================================================================================

; sets the open collector output data line low
SEND_0					MACRO
						bcf		SEND_PORT, SEND_BIT
            			ENDM

; sets the open collector output data line high
SEND_1					MACRO
						bsf		SEND_PORT, SEND_BIT
            			ENDM

; initializes FSR to point to a buffer that will be used to store a packet destined for the console
START_PACKET			MACRO	BUFFER_ADDR
						movlw	BUFFER_ADDR
						movwf	FSR
						ENDM

; packs a constant value into the buffer pointed to by FSR and increments the buffer pointer
PACK_CONST				MACRO	CONST
						movlw	CONST
						movwf	INDF
						incf	FSR,F
						ENDM

; finishes off a packet by adding a 1 bit to the end of it and gets the buffer ready to
; send by pointing FSR to the start of it
END_PACKET				MACRO	BUFFER_ADDR, NUM_BYTES
						PACK_CONST 08h
						movlw	BUFFER_ADDR
						movwf	FSR
						movlw	NUM_BYTES*8+1
						ENDM

; reads a button state from an incoming wireless packet, sets the appropriate bit in the
; buffer, waits for the next bit to arrive and then checks to make sure that an interrupt
; hasn't occurred (interrupts throw off the timing, so the rest of the wireless packet has
; to be ignored; skipping a packet doesn't matter though, as we receive at least two wireless 
; packets for every console packet).
READ_WIRELESS_BUTTON	MACRO	ADDR, BIT, REVERSE_POLARITY
						bcf		ADDR, BIT							; clear the buffer bit
#if REVERSE_POLARITY
						btfss	WIRELESS_PORT, WIRELESS_BIT			; read the wireless port, is it 1?
#else
						btfsc	WIRELESS_PORT, WIRELESS_BIT			; read the wireless port, is it 0?
#endif
						bsf		ADDR, BIT							; yes, so set the buffer bit
						call	wireless_pulse_delay				; wait for the next pulse
						ENDM

; turns the LED off
LED_OFF					MACRO
						bcf		RED_LED_PORT, RED_LED_BIT
						bcf		GREEN_LED_PORT, GREEN_LED_BIT
						ENDM

; sets the LED to red to indicate we have power but not a valid wireless signal
LED_RED					MACRO
						bcf		GREEN_LED_PORT, GREEN_LED_BIT
						bsf		RED_LED_PORT, RED_LED_BIT
						ENDM

; sets the LED to green to indicate we have power and a valid wireless signal
LED_GREEN				MACRO
						bcf		RED_LED_PORT, RED_LED_BIT
						bsf		GREEN_LED_PORT, GREEN_LED_BIT
						ENDM

; these macros are used to generate a test signal that goes high when we're reading
; a packet from the wireless port. used solely for testing on an oscilloscope.

TEST_SIGNAL_ON			MACRO
						bsf		TEST_PORT, TEST_BIT
						ENDM

TEST_SIGNAL_OFF			MACRO
						bcf		TEST_PORT, TEST_BIT
						ENDM

; ================================================================================================
; entry point -	jumps to the initialization and main loop
; ================================================================================================
	org	0000h
		goto	initialization

; ================================================================================================
; interrupt handler -	there's only one type of interrupt used in this program; it gets
;						triggered when the console sends a command. this function reads the
;						command, parses it, dispatches control to the appropriate handler,
;						and re-enables interrupts before returning. timing is critical in this
;						function...we don't have time to jump to a handler, so the handler code
;						has to appear here.
; ================================================================================================
	org	0004h
		
		; get the next packet from the console	  (cycle #)
		movwf	W_TEMP							; ( 2/3) save W register
		swapf	STATUS, W						; ( 3/4) save STATUS register
		movwf	STATUS_TEMP						; ( 4/5)
		movlw	PACKET_BUFFER					; ( 5/6) FSR <- buffer address
		movwf	FSR								; ( 6/7)
		clrf	BIT_NUM							; ( 7/8)
read_bit
		incf	BITS_READ, F					; (8) increment bits read
		bcf		STATUS, C						; (9)		clear carry flag
		btfsc	REC_PORT, REC_BIT				; (10)		is this bit a 1?
		bsf		STATUS, C						; (11)		if yes then set carry bit
		rlf		INDF, F							; (12)		rotate carry bit into the current 

byte
		incf	BIT_NUM, F						; (13) increment current bit number
		btfsc	BIT_NUM, 3						; (14) have we set 8 bits yet?
		incf	FSR, F							; (15) if yes then advance the buffer ptr
		btfsc	BIT_NUM, 3						; (16) have we set 8 bits yet?
		clrf	BIT_NUM							; (17) if yes then reset the current bit number to 0
		nop										; (18)
		nop										; (19)
		btfss	REC_PORT, REC_BIT				; (20) has the data line returned to 0?
		goto	start_bit						; (21) if yes then go read another bit
		btfss	REC_PORT, REC_BIT				; (22) that check is too early, this one is more likely...
		goto	start_bit						; (23) 
		btfss	REC_PORT, REC_BIT				; (22) and sometimes it can appear here...
		goto	start_bit						; (23) 
		btfss	REC_PORT, REC_BIT				; (24) last chance...
		goto	start_bit						; (25) 
		decf	BITS_READ, F					; (34) ok, we've timed out. knock off the last bit
		goto	finished_packet					; (35) (which should be a 1) and we're done.
start_bit
		movfw	BITS_READ						; (3) safety check
		addlw	-22h							; (4)	have we read 34 bits?
		btfss	STATUS, Z						; (5)	if yes then don't read any more
		goto	read_bit						; (6) go read in the next bit

finished_packet
		call	check_4003XXh					; request button states?
		iorlw	0
		btfss	STATUS, Z
		goto	end_interrupt

		call	check_00h						; request id/status?
		iorlw	0
		btfss	STATUS, Z
		goto	end_interrupt

		call	check_41h						; request origins?
		iorlw	0
		btfss	STATUS, Z
		goto	end_interrupt
		
end_interrupt
		bsf		RECEIVED_PACKET, 0				; signal that we've just received a console packet
		clrf	BITS_READ						; we dont' have time to do this in the interrupt initialization
		swapf	STATUS_TEMP, W					; restore STATUS
		movwf	STATUS
		swapf	W_TEMP, F						; restore W
		swapf	W_TEMP, W
		bcf		INTCON, INTF					; clear the pin interrupt flag
		retfie									; return from interrupt

; ================================================================================================
; check_4003XXh -	checks to see if we've received a "request button states" command,
;					if we have then the button buffer is sent to the console.
; ================================================================================================

check_4003XXh
		movfw	BITS_READ						; must be a 24-bit packet
		sublw	18h
		btfss	STATUS, Z
		retlw	0
		movfw	PACKET_BUFFER
		sublw	40h
		btfss	STATUS, Z
		retlw	0
		movfw	PACKET_BUFFER+1					; second byte must be 03h
		sublw	03h
		btfss	STATUS, Z
		retlw	0

		movlw	CONSOLE_BUTTONS					; send the button data packet to the console
		movwf	FSR
		movlw	41h								; = 65 bits
		call	send_packet
		incf	TIMEOUT_COUNTER					; increment the time-out counter
		retlw	1

; ================================================================================================
; check_00h -	checks to see if we've received a "request id/status" command,
;				if we have then send the standard controller id word and status byte are sent
;				to the console
; ================================================================================================

check_00h
		movfw	BITS_READ						; must be an 8-bit packet
		sublw	8h
		btfss	STATUS, Z
		retlw	0
		movfw	PACKET_BUFFER					; first byte must be 00h
		sublw	00h
		btfss	STATUS, Z

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线精品一区二区 | 亚洲成人午夜电影| 日韩欧美亚洲一区二区| 成人免费高清在线| 日本欧美在线看| 中文字幕一区二区三区不卡在线| 欧美一级日韩免费不卡| 99国产精品久| 国产一区福利在线| 日韩精品亚洲专区| 综合电影一区二区三区 | 国产日韩欧美高清| 日韩一区二区免费在线电影 | 欧美mv和日韩mv的网站| 色www精品视频在线观看| 国产制服丝袜一区| 青青草精品视频| 亚洲综合精品久久| 国产精品国产a级| 久久麻豆一区二区| 欧美高清视频www夜色资源网| 99久久精品免费看国产免费软件| 国内精品伊人久久久久av影院| 午夜精品久久久久久久久久久 | 国精产品一区一区三区mba视频| 亚洲高清一区二区三区| 亚洲免费观看在线视频| 国产精品麻豆网站| 国产免费观看久久| 亚洲成人免费观看| 亚洲一区二区三区美女| 亚洲视频狠狠干| 国产日韩精品一区二区浪潮av| 日韩精品中午字幕| 日韩欧美国产综合在线一区二区三区| 欧美综合亚洲图片综合区| 91视频观看视频| 99久久精品情趣| 97se狠狠狠综合亚洲狠狠| 岛国一区二区在线观看| 国产激情视频一区二区在线观看| 国产麻豆成人传媒免费观看| 激情成人综合网| 国内精品免费**视频| 久久精品国产澳门| 国产一区二区三区在线观看免费| 精品中文av资源站在线观看| 精品在线你懂的| 国产精品一线二线三线| 国产成人免费高清| www.亚洲色图| 一本一道久久a久久精品综合蜜臀| 成人激情黄色小说| 色综合久久综合中文综合网| 色噜噜狠狠成人中文综合 | 91精品国产综合久久久久久久| 欧美老人xxxx18| 欧美成人艳星乳罩| 久久精品免视看| 中文一区在线播放| 亚洲精品国产一区二区三区四区在线 | 国产日本亚洲高清| 中文av一区二区| 亚洲欧美另类在线| 亚洲aⅴ怡春院| 久久精品国产在热久久| 东方aⅴ免费观看久久av| 久久品道一品道久久精品| 欧美激情一区不卡| 亚洲综合色婷婷| 久久精品国产77777蜜臀| 国产精品乡下勾搭老头1| 99视频一区二区| 欧美久久久久久久久久| 久久久精品国产免大香伊| 国产精品国产a级| 首页欧美精品中文字幕| 精品一区免费av| 色婷婷av一区| 日韩欧美一区在线| 国产精品丝袜久久久久久app| 亚洲精品欧美专区| 久久国产精品一区二区| av亚洲精华国产精华精华| 精品视频色一区| 337p粉嫩大胆色噜噜噜噜亚洲| 亚洲欧洲精品天堂一级| 日韩一区精品视频| a4yy欧美一区二区三区| 欧美一区二区三区日韩视频| 中文乱码免费一区二区| 日本系列欧美系列| 成人免费视频app| 欧美精选午夜久久久乱码6080| 中文字幕精品综合| 日本不卡一区二区三区 | 欧美亚洲自拍偷拍| 久久夜色精品国产噜噜av| 一区二区在线免费| 国产91精品久久久久久久网曝门 | 日韩一区二区免费在线电影| 亚洲视频一二区| 国产一区二区视频在线播放| 欧美性欧美巨大黑白大战| 久久久久久久综合日本| 蜜臀久久99精品久久久久宅男| proumb性欧美在线观看| 久久天天做天天爱综合色| 性做久久久久久免费观看欧美| 成人免费的视频| 精品国产凹凸成av人网站| 午夜成人在线视频| 一本色道久久综合亚洲91| 中文字幕免费不卡| 国产一区二区三区精品欧美日韩一区二区三区| 在线观看一区二区视频| 中文字幕日韩欧美一区二区三区| 国产一区二区成人久久免费影院 | 日韩激情一区二区| 91蜜桃免费观看视频| 国产精品网站在线| 国产美女主播视频一区| 欧美成人性福生活免费看| 日韩成人av影视| 欧美日韩精品一区二区| 亚洲精品国产a久久久久久| 不卡的电视剧免费网站有什么| 久久精品一区蜜桃臀影院| 久久国产综合精品| 日韩欧美一二三四区| 日韩激情一区二区| 3751色影院一区二区三区| 亚洲国产日韩a在线播放| 99久久婷婷国产精品综合| 国产欧美日韩视频在线观看| 国产不卡免费视频| 中文字幕不卡在线观看| 99综合电影在线视频| 国产欧美日韩另类视频免费观看| 国产传媒久久文化传媒| 久久久国际精品| 国产很黄免费观看久久| 久久精品一区八戒影视| 国产 欧美在线| 亚洲国产成人私人影院tom| 国产老肥熟一区二区三区| 国产情人综合久久777777| 成人不卡免费av| 国产精品卡一卡二| 99riav一区二区三区| 一区二区三区四区精品在线视频| 欧美日韩一区二区三区高清| 日日夜夜精品视频免费| 日韩欧美一级在线播放| 国产精品一区二区x88av| 欧美国产日韩一二三区| 91麻豆自制传媒国产之光| 亚洲国产成人porn| 日韩欧美国产精品一区| 国产伦精品一区二区三区免费| 日本一区二区三区在线观看| 99re这里只有精品6| 亚洲一区二区三区四区五区黄| 欧美一级在线观看| 国产福利视频一区二区三区| 国产精品天干天干在线综合| 色婷婷av一区| 久久精品国产亚洲a| 国产三级一区二区| 欧美在线视频你懂得| 欧美a级理论片| 中文天堂在线一区| 欧美日韩日日摸| 国产精品一区二区x88av| 亚洲精品国产第一综合99久久| 日韩视频一区二区在线观看| 国产成人无遮挡在线视频| 亚洲综合男人的天堂| 久久综合九色综合欧美就去吻| 91在线看国产| 九九视频精品免费| 一区二区三区 在线观看视频| 日韩欧美电影在线| 色综合天天综合网天天狠天天| 日韩电影在线观看一区| 中文字幕国产一区二区| 69堂精品视频| av一区二区不卡| 久热成人在线视频| 一区二区三区毛片| 久久亚洲春色中文字幕久久久| 日本精品视频一区二区| 韩国成人福利片在线播放| 亚洲午夜羞羞片| 国产精品私房写真福利视频| 欧美一二三区在线| 一本色道**综合亚洲精品蜜桃冫| 精品一区二区三区在线观看| 亚洲成人免费看| 成人免费一区二区三区在线观看|