Initial commit
This commit is contained in:
1 parent
18876c5b45
commit
4e8a063f86
47 files changed
+4209
-1
No files matched your search
@@ -0,0 +1,754 @@
|
||||
#include <p12f629.inc>
|
||||
processor p12f629
|
||||
|
||||
; ---------------------------------------------------------------------
|
||||
; feature enhanced SNES CIC clone for PIC Microcontroller (key mode only)
|
||||
;
|
||||
; Copyright (C) 2010 by Maximilian Rehkopf (ikari_01) <otakon@gmx.net>
|
||||
; This software is part of the sd2snes project.
|
||||
;
|
||||
; Last Modified: Oct. 2015 by Peter Bartmann <borti4938@gmx.de>
|
||||
;
|
||||
; Based on reverse engineering work and disassembly by segher,
|
||||
; http://hackmii.com/2010/01/the-weird-and-wonderful-cic/
|
||||
;
|
||||
; This program is free software; you can redistribute it and/or modify
|
||||
; it under the terms of the GNU General Public License as published by
|
||||
; the Free Software Foundation; version 2 of the License only.
|
||||
;
|
||||
; This program is distributed in the hope that it will be useful,
|
||||
; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
; GNU General Public License for more details.
|
||||
;
|
||||
; You should have received a copy of the GNU General Public License
|
||||
; along with this program; if not, write to the Free Software
|
||||
; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
;
|
||||
; ---------------------------------------------------------------------
|
||||
;
|
||||
; pin configuration: (cartridge pin) [key CIC pin]
|
||||
;
|
||||
; ,---_---.
|
||||
; +5V (27,58) [16] |1 8| GND (5,36) [8]
|
||||
; CIC clk (56) [6] |2 7| CIC data i/o 0 (55) [2]
|
||||
; status out |3 6| CIC data i/o 1 (24) [1]
|
||||
; /PAIR |4 5| CIC slave reset (25) [7]
|
||||
; `-------'
|
||||
;
|
||||
;
|
||||
; Status out can be connected to a LED. It indicates:
|
||||
;
|
||||
; state | output
|
||||
; -------------------------+----------------------------
|
||||
; OK or no lock CIC | high
|
||||
; error | low
|
||||
; SuperCIC pair mode | 148.75kHz / 50% duty cycle
|
||||
; SuperCIC host detected | scarce spikes (3.3us)
|
||||
; but pair mode disabled |
|
||||
;
|
||||
; In case lockout fails, the region is switched automatically and
|
||||
; will be used after the next reset.
|
||||
;
|
||||
; The /PAIR pin can be used to enable or disable SuperCIC pair mode.
|
||||
; It can be tied low or high to statically enable or disable pair mode
|
||||
; detection, or connected to a switch or MCU to dynamically enable pair
|
||||
; mode detection (it should then be connected to a pull-up resistor to
|
||||
; Vcc). Pair mode detection can be enabled during operation,
|
||||
; but pair mode cannot be left until the next power cycle.
|
||||
; See SuperCIC lock documentation for a more detailed description of
|
||||
; pair mode.
|
||||
;
|
||||
; memory usage:
|
||||
;
|
||||
; 0x20 buffer for seed calc and transfer
|
||||
; 0x21 - 0x2f seed area (lock seed)
|
||||
; 0x30 buffer for seed calc
|
||||
; 0x31 - 0x3f seed area (key seed; 0x31 filled in by lock)
|
||||
; 0x40 - 0x41 buffer for seed calc
|
||||
; 0x4d buffer for eeprom access
|
||||
; 0x4e loop variable for longwait
|
||||
; 0x4f loop variable for wait
|
||||
; 0x5c GPIO buffer variable for pair mode allow
|
||||
; 0x5d 0: SuperCIC pair mode available flag
|
||||
; 0x5e SuperCIC pair mode detect (phase 1)
|
||||
; 0x5f SuperCIC pair mode detect (phase 2)
|
||||
; ---------------------------------------------------------------------
|
||||
|
||||
|
||||
; -----------------------------------------------------------------------
|
||||
__CONFIG _EC_OSC & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _CPD_OFF
|
||||
|
||||
; -----------------------------------------------------------------------
|
||||
; code memory
|
||||
org 0x0000
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
goto init
|
||||
isr
|
||||
org 0x0004
|
||||
bcf INTCON, 1 ; clear interrupt cause
|
||||
bcf GPIO, 0
|
||||
bcf GPIO, 1
|
||||
bsf GPIO, 4 ; LED on
|
||||
clrf 0x5e ; clear pair mode detect
|
||||
clrf 0x5f ; clear pair mode detect
|
||||
bsf 0x5f, 1 ;
|
||||
clrf 0x5d ; clear pair mode available
|
||||
clrf 0x5c ; clear pair mode allow buffer
|
||||
bsf 0x5c, 3 ; assume disallow
|
||||
bsf INTCON, 7 ; re-enable interrupts (ISR will continue as main)
|
||||
goto main
|
||||
init
|
||||
org 0x0010
|
||||
bcf STATUS, RP0
|
||||
clrf GPIO
|
||||
movlw 0x07 ; GPIO2..0 are digital I/O (not connected to comparator)
|
||||
movwf CMCON
|
||||
movlw 0x90 ; global enable interrupts + enable external interrupt
|
||||
movwf INTCON
|
||||
bsf STATUS, RP0
|
||||
movlw 0x2d ; in out in in out in
|
||||
movwf TRISIO
|
||||
movlw 0x24 ; pullups for reset+clk to avoid errors when no CIC in host
|
||||
movwf WPU
|
||||
movlw 0x00 ; 0x80 for global pullup disable
|
||||
movwf OPTION_REG
|
||||
|
||||
bcf STATUS, RP0
|
||||
bsf GPIO, 4 ; LED on
|
||||
idle
|
||||
goto idle ; wait for interrupt from lock
|
||||
|
||||
main
|
||||
bsf STATUS, RP0
|
||||
bsf TRISIO, 0
|
||||
bcf TRISIO, 1
|
||||
bcf STATUS, RP0
|
||||
; --------INIT LOCK SEED (what the lock sends)--------
|
||||
movlw 0xb
|
||||
movwf 0x21
|
||||
movlw 0x1
|
||||
movwf 0x22
|
||||
movlw 0x4
|
||||
movwf 0x23
|
||||
movlw 0xf
|
||||
movwf 0x24
|
||||
movlw 0x4
|
||||
movwf 0x25
|
||||
movlw 0xb
|
||||
movwf 0x26
|
||||
movlw 0x5
|
||||
movwf 0x27
|
||||
movlw 0x7
|
||||
movwf 0x28
|
||||
movlw 0xf
|
||||
movwf 0x29
|
||||
movlw 0xd
|
||||
movwf 0x2a
|
||||
movlw 0x6
|
||||
movwf 0x2b
|
||||
movlw 0x1
|
||||
movwf 0x2c
|
||||
movlw 0xe
|
||||
movwf 0x2d
|
||||
movlw 0x9
|
||||
movwf 0x2e
|
||||
movlw 0x8
|
||||
movwf 0x2f
|
||||
|
||||
; --------INIT KEY SEED (what we must send)--------
|
||||
bsf STATUS, RP0 ; D/F411 and D/F413
|
||||
clrf EEADR ; differ in 2nd seed nibble
|
||||
bsf EECON1, RD ; of key stream,
|
||||
movf EEDAT, w ; restore saved nibble from EEPROM
|
||||
bcf STATUS, RP0
|
||||
movwf 0x32
|
||||
movlw 0xa
|
||||
movwf 0x33
|
||||
movlw 0x1
|
||||
movwf 0x34
|
||||
movlw 0x8
|
||||
movwf 0x35
|
||||
movlw 0x5
|
||||
movwf 0x36
|
||||
movlw 0xf
|
||||
movwf 0x37
|
||||
movlw 0x1
|
||||
movwf 0x38
|
||||
movwf 0x39
|
||||
movlw 0xe
|
||||
movwf 0x3a
|
||||
movlw 0x1
|
||||
movwf 0x3b
|
||||
movlw 0x0
|
||||
movwf 0x3c
|
||||
movlw 0xd
|
||||
movwf 0x3d
|
||||
movlw 0xe
|
||||
movwf 0x3e
|
||||
movlw 0xc
|
||||
movwf 0x3f
|
||||
|
||||
; --------wait for stream ID--------
|
||||
movlw 0xb5
|
||||
call wait
|
||||
clrf 0x31 ; clear lock stream ID
|
||||
|
||||
; --------lock sends stream ID. 15 cycles per bit--------
|
||||
; bsf GPIO, 0 ; (debug marker)
|
||||
; bcf GPIO, 0 ;
|
||||
btfsc GPIO, 0 ; check stream ID bit
|
||||
bsf 0x31, 3 ; copy to lock seed
|
||||
movlw 0x2 ; wait=3*W+5
|
||||
call wait ; burn 11 cycles
|
||||
nop
|
||||
nop
|
||||
|
||||
; bsf GPIO, 0
|
||||
; bcf GPIO, 0
|
||||
btfsc GPIO, 0 ; check stream ID bit
|
||||
bsf 0x31, 0 ; copy to lock seed
|
||||
movlw 0x2 ;
|
||||
call wait ; burn 11 cycles
|
||||
nop
|
||||
nop
|
||||
|
||||
; bsf GPIO, 0
|
||||
; bcf GPIO, 0
|
||||
btfsc GPIO, 0 ; check stream ID bit
|
||||
bsf 0x31, 1 ; copy to lock seed
|
||||
movlw 0x2 ;
|
||||
call wait ; burn 11 cycles
|
||||
nop
|
||||
nop
|
||||
|
||||
; bsf GPIO, 0
|
||||
; bcf GPIO, 0
|
||||
btfsc GPIO, 0 ; check stream ID bit
|
||||
bsf 0x31, 2 ; copy to lock seed
|
||||
bsf STATUS, RP0
|
||||
bcf TRISIO, 0
|
||||
bsf TRISIO, 1
|
||||
bcf STATUS, RP0
|
||||
movlw 0x27 ; "wait" 1
|
||||
call wait ; wait 121
|
||||
nop
|
||||
; --------main loop--------
|
||||
loop
|
||||
movlw 0x1
|
||||
loop0
|
||||
addlw 0x30 ; key stream
|
||||
movwf FSR ; store in index reg
|
||||
loop1
|
||||
nop
|
||||
movf INDF, w ; load seed value
|
||||
movwf 0x20
|
||||
bcf 0x20, 1 ; clear bit 1
|
||||
btfsc 0x20, 0 ; copy from bit 0
|
||||
bsf 0x20, 1 ; (if set)
|
||||
bsf 0x20, 4 ; LED on
|
||||
movf 0x20, w
|
||||
movwf GPIO
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
movlw 0x10
|
||||
movwf GPIO ; reset GPIO
|
||||
movlw 0x13
|
||||
call wait
|
||||
nop
|
||||
btfsc 0x5d, 0 ; pair mode available signal
|
||||
bcf GPIO, 4 ;
|
||||
nop
|
||||
nop
|
||||
bsf GPIO, 4 ;
|
||||
btfsc GPIO, 0 ; both pins must be low...
|
||||
goto die
|
||||
btfsc GPIO, 1 ; ...when no bit transfer takes place
|
||||
goto die ; if not -> lock cic error state -> die
|
||||
incf FSR, f ; next one
|
||||
movlw 0xf
|
||||
andwf FSR, w
|
||||
btfss STATUS, Z
|
||||
goto loop1
|
||||
call mangle
|
||||
call mangle
|
||||
call mangle
|
||||
movlw 0x2 ; wait 10
|
||||
call wait ;
|
||||
nop
|
||||
nop
|
||||
btfsc 0x37, 0
|
||||
goto swap
|
||||
bsf STATUS, RP0
|
||||
bcf TRISIO, 0
|
||||
bsf TRISIO, 1
|
||||
goto swapskip
|
||||
swap
|
||||
bsf STATUS, RP0
|
||||
bsf TRISIO, 0
|
||||
bcf TRISIO, 1
|
||||
nop
|
||||
swapskip
|
||||
bcf STATUS, RP0
|
||||
movf 0x37, w
|
||||
andlw 0xf
|
||||
btfss STATUS, Z
|
||||
goto loop0
|
||||
goto loop
|
||||
|
||||
; --------calculate new seeds--------
|
||||
; had to be unrolled because PIC has an inefficient way of handling
|
||||
; indirect access, no post increment, etc.
|
||||
mangle
|
||||
call mangle_lock
|
||||
movf GPIO, w ; buffer GPIO state
|
||||
movwf 0x5c ; for pair mode "transaction"
|
||||
mangle_key
|
||||
movf 0x2f, w
|
||||
movwf 0x20
|
||||
mangle_key_loop
|
||||
addlw 0x1
|
||||
addwf 0x21, f
|
||||
movf 0x22, w
|
||||
movwf 0x40
|
||||
movf 0x21, w
|
||||
addwf 0x22, f
|
||||
incf 0x22, f
|
||||
comf 0x22, f
|
||||
movf 0x23, w
|
||||
movwf 0x41 ; store 23 to 41
|
||||
movlw 0xf
|
||||
andwf 0x23, f
|
||||
movf 0x40, w ; add 40(22 old)+23+#1 and skip if carry
|
||||
andlw 0xf
|
||||
addwf 0x23, f
|
||||
incf 0x23, f
|
||||
btfsc 0x23, 4
|
||||
goto mangle_key_withskip
|
||||
mangle_key_withoutskip
|
||||
movf 0x41, w ; restore 23
|
||||
addwf 0x24, f ; add to 24
|
||||
movf 0x25, w
|
||||
movwf 0x40 ; save 25 to 40
|
||||
movf 0x24, w
|
||||
addwf 0x25, f
|
||||
movf 0x26, w
|
||||
movwf 0x41 ; save 26 to 41
|
||||
movf 0x40, w ; restore 25
|
||||
andlw 0xf ; mask nibble
|
||||
addlw 0x8 ; add #8 to HIGH nibble
|
||||
movwf 0x40
|
||||
btfss 0x40, 4 ; skip if carry to 5th bit
|
||||
addwf 0x26, w
|
||||
movwf 0x26
|
||||
|
||||
movf 0x41, w ; restore 26
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x27, f ; add to 27
|
||||
|
||||
movf 0x27, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x28, f ; add to 28
|
||||
|
||||
movf 0x28, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x29, f ; add to 29
|
||||
|
||||
movf 0x29, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x2a, f ; add to 2a
|
||||
|
||||
movf 0x2a, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x2b, f ; add to 2b
|
||||
|
||||
movf 0x2b, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x2c, f ; add to 2c
|
||||
|
||||
movf 0x2c, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x2d, f ; add to 2d
|
||||
|
||||
movf 0x2d, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x2e, f ; add to 2e
|
||||
|
||||
movf 0x2e, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x2f, f ; add to 2f
|
||||
|
||||
movf 0x20, w ; restore original 0xf
|
||||
andlw 0xf
|
||||
addlw 0xf
|
||||
movwf 0x20
|
||||
|
||||
btfsc 0x5d, 0 ; pair mode available signal
|
||||
bcf GPIO, 4
|
||||
nop
|
||||
nop
|
||||
bsf GPIO, 4
|
||||
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
btfss 0x20, 4 ; skip if half-byte carry
|
||||
goto mangle_return ; +2 cycles in return
|
||||
nop
|
||||
goto mangle_key_loop
|
||||
; 69 when goto, 69 when return
|
||||
; CIC has 78 -> 9 nops
|
||||
|
||||
mangle_key_withskip
|
||||
movf 0x41, w ; restore 23
|
||||
addwf 0x23, f ; add to 23
|
||||
movf 0x24, w
|
||||
movwf 0x40 ; save 24 to 40
|
||||
movf 0x23, w
|
||||
addwf 0x24, f
|
||||
movf 0x25, w
|
||||
movwf 0x41 ; save 25 to 41
|
||||
movf 0x40, w ; restore 24
|
||||
andlw 0xf ; mask nibble
|
||||
addlw 0x8 ; add #8 to HIGH nibble
|
||||
movwf 0x40
|
||||
btfss 0x40, 4 ; skip if carry to 5th bit
|
||||
addwf 0x25, w
|
||||
movwf 0x25
|
||||
|
||||
movf 0x41, w ; restore 25
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x26, f ; add to 26
|
||||
|
||||
movf 0x26, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x27, f ; add to 27
|
||||
|
||||
movf 0x27, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x28, f ; add to 28
|
||||
|
||||
movf 0x28, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x29, f ; add to 29
|
||||
|
||||
movf 0x29, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x2a, f ; add to 2a
|
||||
|
||||
movf 0x2a, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x2b, f ; add to 2b
|
||||
|
||||
movf 0x2b, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x2c, f ; add to 2c
|
||||
|
||||
movf 0x2c, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x2d, f ; add to 2d
|
||||
|
||||
movf 0x2d, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x2e, f ; add to 2e
|
||||
|
||||
movf 0x2e, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x2f, f ; add to 2f
|
||||
|
||||
movf 0x20, w ; restore original 0xf
|
||||
andlw 0xf
|
||||
addlw 0xf
|
||||
movwf 0x20
|
||||
;-------pair mode code-------
|
||||
bcf GPIO, 0
|
||||
movf GPIO, w
|
||||
btfss 0x5c, 3
|
||||
bsf GPIO, 0
|
||||
movwf 0x5e
|
||||
movf GPIO, w
|
||||
movwf 0x5f
|
||||
bcf GPIO, 0
|
||||
|
||||
btfsc 0x5d, 0 ; pair mode available signal
|
||||
bcf GPIO, 4
|
||||
bsf GPIO, 4
|
||||
;-------end of pair mode code-------
|
||||
btfss 0x20, 4 ; skip if half-byte carry
|
||||
goto mangle_return ; +2 cycles in return
|
||||
movf 0x20, w ; restore w (previously destroyed)
|
||||
goto mangle_key_loop
|
||||
mangle_return
|
||||
return
|
||||
; 73 when goto, 73 when return
|
||||
; CIC has 84 -> 11 nops
|
||||
|
||||
mangle_lock
|
||||
movf 0x3f, w
|
||||
movwf 0x30
|
||||
mangle_lock_loop
|
||||
addlw 0x1
|
||||
addwf 0x31, f
|
||||
movf 0x32, w
|
||||
movwf 0x40
|
||||
movf 0x31, w
|
||||
addwf 0x32, f
|
||||
incf 0x32, f
|
||||
comf 0x32, f
|
||||
movf 0x33, w
|
||||
movwf 0x41 ; store 33 to 41
|
||||
movlw 0xf
|
||||
andwf 0x33, f
|
||||
movf 0x40, w ; add 40(32 old)+33+#1 and skip if carry
|
||||
andlw 0xf
|
||||
addwf 0x33, f
|
||||
incf 0x33, f
|
||||
btfsc 0x33, 4
|
||||
goto mangle_lock_withskip
|
||||
mangle_lock_withoutskip
|
||||
movf 0x41, w ; restore 33
|
||||
addwf 0x34, f ; add to 34
|
||||
movf 0x35, w
|
||||
movwf 0x40 ; save 35 to 40
|
||||
movf 0x34, w
|
||||
addwf 0x35, f
|
||||
movf 0x36, w
|
||||
movwf 0x41 ; save 36 to 41
|
||||
movf 0x40, w ; restore 35
|
||||
andlw 0xf ; mask nibble
|
||||
addlw 0x8 ; add #8 to HIGH nibble
|
||||
movwf 0x40
|
||||
btfss 0x40, 4 ; skip if carry to 5th bit
|
||||
addwf 0x36, w
|
||||
movwf 0x36
|
||||
|
||||
movf 0x41, w ; restore 36
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x37, f ; add to 37
|
||||
|
||||
movf 0x37, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x38, f ; add to 38
|
||||
|
||||
movf 0x38, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x39, f ; add to 39
|
||||
|
||||
movf 0x39, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x3a, f ; add to 3a
|
||||
|
||||
movf 0x3a, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x3b, f ; add to 3b
|
||||
|
||||
movf 0x3b, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x3c, f ; add to 3c
|
||||
|
||||
movf 0x3c, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x3d, f ; add to 3d
|
||||
|
||||
movf 0x3d, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x3e, f ; add to 3e
|
||||
|
||||
movf 0x3e, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x3f, f ; add to 3f
|
||||
|
||||
movf 0x30, w ; restore original 0xf
|
||||
andlw 0xf
|
||||
addlw 0xf
|
||||
movwf 0x30
|
||||
|
||||
btfsc 0x5d, 0 ; pair mode available signal
|
||||
bcf GPIO, 4
|
||||
nop
|
||||
nop
|
||||
bsf GPIO, 4
|
||||
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
btfss 0x30, 4 ; skip if half-byte carry
|
||||
goto mangle_return
|
||||
nop
|
||||
goto mangle_lock_loop
|
||||
; 69 when goto, 69 when return
|
||||
; CIC has 78 -> 9 nops
|
||||
|
||||
mangle_lock_withskip
|
||||
movf 0x41, w ; restore 33
|
||||
addwf 0x33, f ; add to 33
|
||||
movf 0x34, w
|
||||
movwf 0x40 ; save 34 to 40
|
||||
movf 0x33, w
|
||||
addwf 0x34, f
|
||||
movf 0x35, w
|
||||
movwf 0x41 ; save 35 to 41
|
||||
movf 0x40, w ; restore 34
|
||||
andlw 0xf ; mask nibble
|
||||
addlw 0x8 ; add #8 to HIGH nibble
|
||||
movwf 0x40
|
||||
btfss 0x40, 4 ; skip if carry to 5th bit
|
||||
addwf 0x35, w
|
||||
movwf 0x35
|
||||
|
||||
movf 0x41, w ; restore 35
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x36, f ; add to 36
|
||||
|
||||
movf 0x36, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x37, f ; add to 37
|
||||
|
||||
movf 0x37, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x38, f ; add to 38
|
||||
|
||||
movf 0x38, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x39, f ; add to 39
|
||||
|
||||
movf 0x39, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x3a, f ; add to 3a
|
||||
|
||||
movf 0x3a, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x3b, f ; add to 3b
|
||||
|
||||
movf 0x3b, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x3c, f ; add to 3c
|
||||
|
||||
movf 0x3c, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x3d, f ; add to 3d
|
||||
|
||||
movf 0x3d, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x3e, f ; add to 3e
|
||||
|
||||
movf 0x3e, w ;
|
||||
addlw 0x1 ; inc
|
||||
addwf 0x3f, f ; add to 3f
|
||||
|
||||
movf 0x30, w ; restore original 0xf
|
||||
andlw 0xf
|
||||
addlw 0xf
|
||||
movwf 0x30
|
||||
;-------pair mode code-------
|
||||
btfss 0x5e, 1
|
||||
goto scic_pair_skip1
|
||||
btfsc 0x5f, 1
|
||||
goto scic_pair_skip2
|
||||
btfsc 0x5c, 3
|
||||
goto scic_pair_skip3
|
||||
goto supercic_pairmode
|
||||
scic_pair_skip1
|
||||
nop
|
||||
nop
|
||||
scic_pair_skip2
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
goto scic_pair_skip4
|
||||
scic_pair_skip3
|
||||
bcf GPIO, 4
|
||||
bsf 0x5d, 0 ; set pair mode available
|
||||
nop
|
||||
bsf GPIO, 4
|
||||
|
||||
scic_pair_skip4
|
||||
;-------end of pair mode code-------
|
||||
btfss 0x30, 4 ; skip if half-byte carry
|
||||
goto mangle_return
|
||||
nop
|
||||
goto mangle_lock_loop
|
||||
; 73 when goto, 73 when return
|
||||
; CIC has 84 -> 11 nops
|
||||
|
||||
; --------wait: 3*(W-1)+7 cycles (including call+return). W=0 -> 256!--------
|
||||
wait
|
||||
movwf 0x4f
|
||||
wait0 decfsz 0x4f, f
|
||||
goto wait0
|
||||
return
|
||||
|
||||
; --------wait long: 8+(3*(w-1))+(772*w). W=0 -> 256!--------
|
||||
longwait
|
||||
movwf 0x4e
|
||||
clrw
|
||||
longwait0
|
||||
call wait
|
||||
decfsz 0x4e, f
|
||||
goto longwait0
|
||||
return
|
||||
|
||||
; --------change region in eeprom and die--------
|
||||
die
|
||||
movlw 0x3a ;wait 50ms before writing
|
||||
call longwait ;("error" might be due to power loss)
|
||||
bsf STATUS, RP0
|
||||
clrw
|
||||
movwf EEADR
|
||||
bsf EECON1, RD
|
||||
movf EEDAT, w
|
||||
bcf STATUS, RP0
|
||||
movwf 0x4d
|
||||
btfsc 0x4d, 0
|
||||
goto die_reg_6
|
||||
die_reg_9
|
||||
movlw 0x9 ; died with PAL, fall back to NTSC
|
||||
goto die_reg_cont
|
||||
die_reg_6
|
||||
movlw 0x6 ; died with NTSC, fall back to PAL
|
||||
die_reg_cont
|
||||
bsf STATUS, RP0
|
||||
movwf EEDAT
|
||||
bsf EECON1, WREN
|
||||
|
||||
die_intloop
|
||||
bcf INTCON, GIE
|
||||
btfsc INTCON, GIE
|
||||
goto die_intloop
|
||||
|
||||
movlw 0x55
|
||||
movwf EECON2
|
||||
movlw 0xaa
|
||||
movwf EECON2
|
||||
bsf EECON1, WR
|
||||
bsf INTCON, GIE
|
||||
|
||||
bcf STATUS, RP0
|
||||
bcf GPIO, 4
|
||||
; --------get caught up--------
|
||||
die_trap
|
||||
goto die_trap
|
||||
; -----------------------------------------------------------------------
|
||||
supercic_pairmode
|
||||
bsf STATUS, RP0
|
||||
bsf TRISIO, 0
|
||||
bsf TRISIO, 1
|
||||
bcf STATUS, RP0
|
||||
supercic_pairmode_loop
|
||||
bsf GPIO, 4
|
||||
nop
|
||||
nop
|
||||
bcf GPIO, 4
|
||||
goto supercic_pairmode_loop
|
||||
|
||||
; eeprom memory
|
||||
org __EEPROM_START
|
||||
de 0x09 ; D411 (NTSC)
|
||||
end
|
||||
@@ -0,0 +1,71 @@
|
||||
:020000040000FA
|
||||
:1000000000000000000010288B1005108510051658
|
||||
:10001000DE01DF01DF14DD01DC01DC158B17202898
|
||||
:10002000831285010730990090308B0083162D30A4
|
||||
:1000300085002430950000308100831205161F28AA
|
||||
:1000400083160514851083120B30A1000130A20025
|
||||
:100050000430A3000F30A4000430A5000B30A6002C
|
||||
:100060000530A7000730A8000F30A9000D30AA0006
|
||||
:100070000630AB000130AC000E30AD000930AE00F0
|
||||
:100080000830AF0083169B011C141A088312B200BB
|
||||
:100090000A30B3000130B4000830B5000530B600B6
|
||||
:1000A0000F30B7000130B800B9000E30BA0001308F
|
||||
:1000B000BB000030BC000D30BD000E30BE000C3067
|
||||
:1000C000BF00B530E221B1010518B1150230E221BF
|
||||
:1000D00000000000051831140230E2210000000089
|
||||
:1000E0000518B1140230E221000000000518311596
|
||||
:1000F00083160510851483122730E2210000013099
|
||||
:10010000303E840000000008A000A0102018A014B9
|
||||
:1001100020162008850000000000000000001030BC
|
||||
:1001200085001330E22100005D1805120000000078
|
||||
:1001300005160518EC298518EC29840A0F300405EA
|
||||
:10014000031D8228B920B920B9200230E221000025
|
||||
:1001500000003718AF28831605108514B3288316BE
|
||||
:10016000051485100000831237080F39031D8028FD
|
||||
:100170007F284C210508DC002F08A000013EA107C4
|
||||
:100180002208C0002108A207A20AA2092308C10070
|
||||
:100190000F30A30540080F39A307A30A231A0B2920
|
||||
:1001A0004108A4072508C0002408A5072608C100A7
|
||||
:1001B00040080F39083EC000401E2607A60041082F
|
||||
:1001C000013EA7072708013EA8072808013EA90706
|
||||
:1001D0002908013EAA072A08013EAB072B08013E69
|
||||
:1001E000AC072C08013EAD072D08013EAE072E08D6
|
||||
:1001F000013EAF0720080F390F3EA0005D18051221
|
||||
:100200000000000005160000000000000000201E95
|
||||
:100210004B290000BE284108A3072408C00023087A
|
||||
:10022000A4072508C10040080F39083EC000401E41
|
||||
:100230002507A5004108013EA6072608013EA7079D
|
||||
:100240002708013EA8072808013EA9072908013E02
|
||||
:10025000AA072A08013EAB072B08013EAC072C0871
|
||||
:10026000013EAD072D08013EAE072E08013EAF0747
|
||||
:1002700020080F390F3EA00005100508DC1D0514ED
|
||||
:10028000DE000508DF0005105D1805120516201EAA
|
||||
:100290004B292008BE2808003F08B000013EB107E6
|
||||
:1002A0003208C0003108B207B20AB2093308C100EF
|
||||
:1002B0000F30B30540080F39B307B30A331A9B292F
|
||||
:1002C0004108B4073508C0003408B5073608C10036
|
||||
:1002D00040080F39083EC000401E3607B6004108EE
|
||||
:1002E000013EB7073708013EB8073808013EB90795
|
||||
:1002F0003908013EBA073A08013EBB073B08013EF8
|
||||
:10030000BC073C08013EBD073D08013EBE073E0854
|
||||
:10031000013EBF0730080F390F3EB0005D180512CF
|
||||
:100320000000000005160000000000000000301E64
|
||||
:100330004B2900004E294108B3073408C000330898
|
||||
:10034000B4073508C10040080F39083EC000401E00
|
||||
:100350003507B5004108013EB6073608013EB7072C
|
||||
:100360003708013EB8073808013EB9073908013E91
|
||||
:10037000BA073A08013EBB073B08013EBC073C08F0
|
||||
:10038000013EBD073D08013EBE073E08013EBF07D6
|
||||
:1003900030080F390F3EB000DE1CD329DF18D529F5
|
||||
:1003A000DC19DA29092A0000000000000000000022
|
||||
:1003B0000000DE2905125D1400000516301E4B29D1
|
||||
:1003C00000004E29CF00CF0BE3290800CE00030127
|
||||
:1003D000E221CE0BE82908003A30E621831603011A
|
||||
:1003E0009B001C141A088312CD004D18F9290930FE
|
||||
:1003F000FA29063083169A001C158B138B1BFD29D6
|
||||
:1004000055309D00AA309D009C148B178312051255
|
||||
:10041000082A8316051485148312051600000000AF
|
||||
:0404200005120D2A8A
|
||||
:02400E00D33F9E
|
||||
:024200000900B3
|
||||
:00000001FF
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,101 @@
|
||||
:020000040000FA
|
||||
:100000000000000000003128033087060428071094
|
||||
:10001000871007110511303090008C0105180E284B
|
||||
:10002000C401D101D201D301D401D701D901DE012C
|
||||
:10003000DF01831600009B011C141A0883120000C4
|
||||
:10004000D500D600D80003398719033AD000D00E66
|
||||
:10005000851D53160230D8058C018E018F011014B6
|
||||
:1000600046288312000085010730990000308B007C
|
||||
:100070008316000029308500093087000030950084
|
||||
:1000800080308100831200000511072840303322A0
|
||||
:10009000000007150000000007118316000007107C
|
||||
:1000A0008714831200000B30A1000130A20004303D
|
||||
:1000B000A3000F30A4000430A5000B30A6000530CB
|
||||
:1000C000A7000730A8000F30A9000D30AA000630A5
|
||||
:1000D000AB000130AC000E30AD000930AE0008308E
|
||||
:1000E000AF000F30B1000030B2000A30B300013071
|
||||
:1000F000B4000830B5000530B6000F30B70001304D
|
||||
:10010000B800B9000E30BA000130BB000030BC00AE
|
||||
:100110000D30BD000E30BE000C30BF00BA302F22B3
|
||||
:10012000B119071400000000071001302F22000051
|
||||
:1001300000003118071400000000071001302F22C2
|
||||
:1001400000000000B1180714000000000710013083
|
||||
:100150002F220000000031190714000000000710D2
|
||||
:1001600001302F228316000007148710831200002D
|
||||
:1001700022302F22000000000130C3000130203E59
|
||||
:100180008400000000080139A0002018A0145008C5
|
||||
:10019000A00420088700000000000708C2005008E3
|
||||
:1001A00087003C224418C20C04160008C206041240
|
||||
:1001B0004218C314C31C0829D7105316D901D418E8
|
||||
:1001C00059165D22840A0F300405031DC1280B2136
|
||||
:1001D0000B210B213708C4000000000000000000C4
|
||||
:1001E0003718F7288316000007148710FC28831699
|
||||
:1001F00000000710871400008312000054155408F3
|
||||
:1002000059048500431037080F39031DBF28BE2845
|
||||
:1002100000000000E1289E21000000002F08A0003F
|
||||
:10022000013EA1072208C0002108A207A20AA209D4
|
||||
:100230002308C1000F30A30540080F39A307A30A04
|
||||
:10024000231A5D294108A4072508C0002408A50732
|
||||
:100250002608C10040080F39083EC000401E26078E
|
||||
:10026000A6004108013EA7072708013EA807280865
|
||||
:10027000013EA9072908013EAA072A08013EAB074B
|
||||
:100280002B08013EAC072C08013EAD072D08013EAE
|
||||
:10029000AE072E08013EAF0720080F390F3EA00021
|
||||
:1002A000000000000000000000000000000000004E
|
||||
:1002B0000000201E9D29000010294108A3072408E2
|
||||
:1002C000C0002308A4072508C10040080F39083ED4
|
||||
:1002D000C000401E2507A5004108013EA6072608CC
|
||||
:1002E000013EA7072708013EA8072808013EA907E5
|
||||
:1002F0002908013EAA072A08013EAB072B08013E48
|
||||
:10030000AC072C08013EAD072D08013EAE072E08B4
|
||||
:10031000013EAF0720080F390F3EA00087140708E1
|
||||
:10032000DE000000871000000708DF00000000006A
|
||||
:100330000000201E9D292008102908003F08B00059
|
||||
:10034000013EB1073208C0003108B207B20AB20953
|
||||
:100350003308C1000F30B30540080F39B307B30AA3
|
||||
:10036000331AED294108B4073508C0003408B50731
|
||||
:100370003608C10040080F39083EC000401E36074D
|
||||
:10038000B6004108013EB7073708013EB8073808F4
|
||||
:10039000013EB9073908013EBA073A08013EBB07DA
|
||||
:1003A0003B08013EBC073C08013EBD073D08013E3D
|
||||
:1003B000BE073E08013EBF0730080F390F3EB000B0
|
||||
:1003C000000000000000000000000000000000002D
|
||||
:1003D0000000301E9D290000A0294108B307340801
|
||||
:1003E000C0003308B4073508C10040080F39083E83
|
||||
:1003F000C000401E3507B5004108013EB60736086B
|
||||
:10040000013EB7073708013EB8073808013EB90773
|
||||
:100410003908013EBA073A08013EBB073B08013ED6
|
||||
:10042000BC073C08013EBD073D08013EBE073E0833
|
||||
:10043000013EBF0730080F390F3EB0005E18232A77
|
||||
:100440005F1C252ACC2A00000000000000000000EC
|
||||
:10045000000000000000301E9D290000A029CF00F0
|
||||
:10046000CF0B302A0800CE0003012F22CE0B352AF5
|
||||
:10047000080005180728392A431C4F2A2230040691
|
||||
:10048000031D532A421C4A2A0000D7105912D410C7
|
||||
:1004900009305B2AD7145916D41406305B2A0000A1
|
||||
:1004A000000000000000000000000000000000004C
|
||||
:1004B000000000005C2AB20008000508511C952AC3
|
||||
:1004C0000000D10051187E2A0000521CE82AD201F7
|
||||
:1004D0005608D500D800831600009A001C15553028
|
||||
:1004E0009D00AA309D009C14831200000230D805A4
|
||||
:1004F00010108C018E018F01101408000000000004
|
||||
:10050000000000000C1CB82A10108C018E018F0115
|
||||
:100510001014D60A05305619D6065608033987191D
|
||||
:10052000033AD000D00E5214B62AD1005118B12A85
|
||||
:100530000000000000000000000000000000531A4E
|
||||
:10054000C82A0C1CBC2A8C01D30A531EC02A0330B3
|
||||
:100550005506031DAD2A5708AF2A58080000D400DD
|
||||
:10056000B62A8E018F018C011014B72A08000000F2
|
||||
:10057000000000000000000000000000000000007B
|
||||
:100580000000000000000000000000000000B62A8B
|
||||
:10059000000000000000A72A83160000071487143B
|
||||
:1005A00083120000DD015D150718DD1487185D1644
|
||||
:1005B00005185D115D088500071CE32A20308719A6
|
||||
:1005C000303A8700D22A10308719303A8700D22A71
|
||||
:1005D000051110108E018F018C011014D101051826
|
||||
:1005E00051140C1CEF2A511C0728D30110108E0146
|
||||
:1005F0008F018C0110140C1CFB2A8C01D30A0A30C9
|
||||
:080600005306031DFB2A072825
|
||||
:02400E00D33F9E
|
||||
:024200000100BB
|
||||
:00000001FF
|
||||
Reference in new issue
Block a user