Skip to content

Commit

Permalink
SuperCIC: fix previous fix, increase tolerance, make lock work with e…
Browse files Browse the repository at this point in the history
…very key
  • Loading branch information
mrehkopf committed Mar 29, 2019
1 parent d80e61f commit c74abd4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions cic/supercic/supercic-key.asm
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,14 @@ main
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
nop
nop
movf INDF, w ; load seed value
movwf 0x20
Expand All @@ -254,6 +253,8 @@ loop1
movwf GPIO
nop
nop
nop
nop
movlw 0x10
movwf GPIO ; reset GPIO
movlw 0x13
Expand Down
17 changes: 9 additions & 8 deletions cic/supercic/supercic-lock.asm
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,10 @@ main
bcf TRISC, 1
bcf STATUS, RP0
nop
movlw 0x23 ;
call wait ; wait 109
movlw 0x22 ;
call wait ; wait 106
nop
nop
movlw 0x1 ; 'first time' bit
movwf 0x43 ; for key detection
; --------main loop--------
Expand All @@ -409,6 +411,7 @@ loop1
movf 0x20, w
movwf PORTC
nop
nop
movf PORTC, w ; read input
movwf 0x42 ; store input
movf 0x50, w ; get LED state
Expand All @@ -432,7 +435,6 @@ loop1
clrf 0x59 ; clear D4 output
btfsc 0x54, 1 ; use effective region for D4 output
bsf 0x59, 4
nop

main_skipinval2
call checkrst
Expand Down Expand Up @@ -480,7 +482,6 @@ swapskip


main_skipinval1
nop
nop
nop
goto main_skipinval2
Expand Down Expand Up @@ -654,12 +655,12 @@ mangle_key_withskip
movwf 0x5e
nop
bcf PORTC, 1
nop ; add nop here, 2010 SCIC key is a bit late.
movf PORTC, w
movwf 0x5f
nop
nop
nop
nop
btfss 0x20, 4 ; skip if half-byte carry
goto mangle_return ; +2 cycles in return
movf 0x20, w ; restore w (previously destroyed)
Expand Down Expand Up @@ -763,7 +764,7 @@ mangle_lock_withoutskip
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
Expand Down Expand Up @@ -1127,7 +1128,7 @@ rst2_loop2
goto rst ; finally reset
; -----------------------------------------------------------------------
; eeprom data
DEEPROM CODE
org __EEPROM_START
de 0x01 ;current mode (default: 60Hz)
end
end
; ------------------------------------------------------------------------

0 comments on commit c74abd4

Please sign in to comment.