;
; File generated by cc65 v 2.13.3
;
	.fopt		compiler,"cc65 v 2.13.3"
	.setcpu		"6502"
	.smart		on
	.autoimport	on
	.case		on
	.debuginfo	off
	.importzp	sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
	.macpack	longbranch
	.forceimport	__STARTUP__
	.import		_getchar
	.import		_printf
	.import		_strcpy
	.import		_strlen
	.import		_memcpy
	.import		_isalpha
	.import		_toupper
	.export		_out
	.export		_rotor
	.export		_ref
	.export		_notch
	.export		_scramble
	.export		_enigma
	.export		_cypher
	.export		_rotate
	.export		_test
	.export		_permute
	.export		_permuteAll
	.export		_readCh
	.export		_initParams
	.export		_main

.segment	"DATA"

_rotor:
	.byte	$45,$4B,$4D,$46,$4C,$47,$44,$51,$56,$5A,$4E,$54,$4F,$57,$59,$48
	.byte	$58,$55,$53,$50,$41,$49,$42,$52,$43,$4A
	.byte	$41,$4A,$44,$4B,$53,$49,$52,$55,$58,$42,$4C,$48,$57,$54,$4D,$43
	.byte	$51,$47,$5A,$4E,$50,$59,$46,$56,$4F,$45
	.byte	$42,$44,$46,$48,$4A,$4C,$43,$50,$52,$54,$58,$56,$5A,$4E,$59,$45
	.byte	$49,$57,$47,$41,$4B,$4D,$55,$53,$51,$4F
	.byte	$45,$53,$4F,$56,$50,$5A,$4A,$41,$59,$51,$55,$49,$52,$48,$58,$4C
	.byte	$4E,$46,$54,$47,$4B,$44,$43,$4D,$57,$42
	.byte	$56,$5A,$42,$52,$47,$49,$54,$59,$55,$50,$53,$44,$4E,$48,$4C,$58
	.byte	$41,$57,$4D,$4A,$51,$4F,$46,$45,$43,$4B
_ref:
	.byte	$59,$52,$55,$48,$51,$53,$4C,$44,$50,$58,$4E,$47,$4F,$4B,$4D,$49
	.byte	$45,$42,$46,$5A,$43,$57,$56,$4A,$41,$54
_notch:
	.byte	$51,$45,$56,$4A,$5A

.segment	"RODATA"

L0001:
	.byte	$0A,$25,$73,$0A,$25,$73,$0A,$00,$57,$68,$65,$65,$6C,$73,$20,$25
	.byte	$64,$20,$25,$64,$20,$25,$64,$20,$53,$74,$61,$72,$74,$20,$25,$63
	.byte	$20,$25,$63,$20,$25,$63,$20,$52,$69,$6E,$67,$73,$20,$25,$63,$20
	.byte	$25,$63,$20,$25,$63,$20,$0A,$53,$74,$65,$63,$6B,$65,$72,$20,$22
	.byte	$25,$73,$22,$0A,$00,$25,$73,$20,$64,$65,$63,$6F,$64,$65,$64,$20
	.byte	$2D,$3E,$20,$25,$73,$0A,$0A,$00,$00,$43,$68,$65,$63,$6B,$69,$6E
	.byte	$67,$20,$77,$68,$65,$65,$6C,$73,$20,$25,$64,$20,$25,$64,$20,$25
	.byte	$64,$20,$0A,$00,$62,$72,$75,$74,$69,$6E,$67,$20,$25,$73,$20,$66
	.byte	$6F,$72,$20,$25,$73,$20,$0A,$00,$0A,$46,$6F,$75,$6E,$64,$20,$25
	.byte	$64,$20,$73,$6F,$6C,$75,$74,$69,$6F,$6E,$73,$2E,$0A,$00,$0A,$00
	.byte	$64,$29,$65,$66,$61,$75,$6C,$74,$20,$6F,$72,$20,$75,$29,$73,$65
	.byte	$72,$20,$0A,$00,$62,$29,$72,$75,$74,$65,$66,$6F,$72,$63,$65,$0A
	.byte	$00,$45,$6E,$63,$72,$79,$70,$74,$65,$64,$20,$73,$74,$72,$69,$6E
	.byte	$67,$3A,$20,$0A,$00,$52,$65,$66,$65,$72,$65,$6E,$63,$65,$20,$73
	.byte	$74,$72,$69,$6E,$67,$3A,$20,$0A,$00,$00,$57,$68,$65,$65,$6C,$20
	.byte	$25,$64,$3A,$20,$00,$53,$74,$61,$72,$74,$20,$25,$64,$3A,$20,$00
	.byte	$53,$74,$65,$63,$6B,$65,$72,$3A,$20,$00,$57,$68,$65,$65,$6C,$73
	.byte	$20,$25,$64,$20,$25,$64,$20,$25,$64,$20,$53,$74,$61,$72,$74,$20
	.byte	$25,$63,$20,$25,$63,$20,$25,$63,$20,$52,$69,$6E,$67,$73,$20,$25
	.byte	$63,$20,$25,$63,$20,$25,$63,$20,$53,$74,$65,$63,$6B,$65,$72,$20
	.byte	$22,$25,$73,$22,$0A,$00

.segment	"BSS"

_out:
	.res	80,$00

; ---------------------------------------------------------------
; unsigned char __near__ scramble (unsigned char, __near__ struct P*)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_scramble: near

.segment	"CODE"

	jsr     decsp4
	ldx     #$00
	lda     #$00
	jsr     pushax
	ldy     #$08
	ldx     #$00
	lda     (sp),y
	ldx     #$00
	jsr     _toupper
	ldy     #$08
	sta     (sp),y
	ldy     #$08
	ldx     #$00
	lda     (sp),y
	ldx     #$00
	jsr     _isalpha
	jsr     bnegax
	jeq     L0011
	ldx     #$00
	lda     #$FF
	jmp     L000C
L0011:	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$06
	jsr     ldauidx
	pha
	clc
	adc     #$01
	ldy     #$06
	jsr     staspidx
	pla
	ldy     #$07
	jsr     ldaxysp
	ldy     #$06
	jsr     ldauidx
	cmp     #$5B
	lda     #$00
	ldx     #$00
	rol     a
	jeq     L0017
	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$06
	jsr     ldauidx
	sec
	sbc     #$1A
	ldy     #$06
	jsr     staspidx
L0017:	ldy     #$01
	lda     (sp),y
	dey
	ora     (sp),y
	jeq     L001D
	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$07
	jsr     ldauidx
	pha
	clc
	adc     #$01
	ldy     #$07
	jsr     staspidx
	pla
	ldy     #$07
	jsr     ldaxysp
	ldy     #$07
	jsr     ldauidx
	cmp     #$5B
	lda     #$00
	ldx     #$00
	rol     a
	jeq     L0021
	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$07
	jsr     ldauidx
	sec
	sbc     #$1A
	ldy     #$07
	jsr     staspidx
L0021:	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$08
	jsr     ldauidx
	pha
	clc
	adc     #$01
	ldy     #$08
	jsr     staspidx
	pla
	ldy     #$07
	jsr     ldaxysp
	ldy     #$08
	jsr     ldauidx
	cmp     #$5B
	lda     #$00
	ldx     #$00
	rol     a
	jeq     L0029
	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$08
	jsr     ldauidx
	sec
	sbc     #$1A
	ldy     #$08
	jsr     staspidx
L0029:	ldx     #$00
	lda     #$00
	ldy     #$00
	jsr     staxysp
L001D:	ldy     #$07
	jsr     ldaxysp
	ldy     #$06
	jsr     ldauidx
	jsr     pushax
	ldy     #$09
	jsr     ldaxysp
	ldy     #$00
	jsr     ldauidx
	jsr     decax1
	clc
	adc     #<(_notch)
	tay
	txa
	adc     #>(_notch)
	tax
	tya
	ldy     #$00
	jsr     ldauidx
	jsr     toseqax
	jeq     L003E
	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$07
	jsr     ldauidx
	pha
	clc
	adc     #$01
	ldy     #$07
	jsr     staspidx
	pla
	ldy     #$07
	jsr     ldaxysp
	ldy     #$07
	jsr     ldauidx
	cmp     #$5B
	lda     #$00
	ldx     #$00
	rol     a
	jeq     L0038
	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$07
	jsr     ldauidx
	sec
	sbc     #$1A
	ldy     #$07
	jsr     staspidx
L0038:	ldy     #$07
	jsr     ldaxysp
	ldy     #$07
	jsr     ldauidx
	jsr     pushax
	ldy     #$09
	jsr     ldaxysp
	ldy     #$01
	jsr     ldauidx
	jsr     decax1
	clc
	adc     #<(_notch)
	tay
	txa
	adc     #>(_notch)
	tax
	tya
	ldy     #$00
	jsr     ldauidx
	jsr     toseqax
	jeq     L003E
	ldx     #$00
	lda     #$01
	ldy     #$00
	jsr     staxysp
L003E:	ldx     #$00
	lda     #$00
	ldy     #$04
	jsr     staxysp
L0045:	ldy     #$07
	jsr     ldaxysp
	ldy     #$09
	jsr     incaxy
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	jne     L0048
	jmp     L0046
L0048:	ldy     #$08
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$09
	jsr     ldaxysp
	ldy     #$09
	jsr     incaxy
	jsr     pushax
	ldy     #$09
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	jsr     toseqax
	jeq     L004F
	ldy     #$07
	jsr     ldaxysp
	ldy     #$09
	jsr     incaxy
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     incax1
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	ldy     #$08
	sta     (sp),y
	jmp     L0047
L004F:	ldy     #$08
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$09
	jsr     ldaxysp
	ldy     #$09
	jsr     incaxy
	jsr     pushax
	ldy     #$09
	jsr     ldaxysp
	jsr     incax1
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	jsr     toseqax
	jeq     L0047
	ldy     #$07
	jsr     ldaxysp
	ldy     #$09
	jsr     incaxy
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	ldy     #$08
	sta     (sp),y
L0047:	ldy     #$04
	ldx     #$00
	lda     #$02
	jsr     addeqysp
	jmp     L0045
L0046:	ldx     #$00
	lda     #$00
	ldy     #$04
	jsr     staxysp
L005C:	ldy     #$05
	jsr     ldaxysp
	cmp     #$03
	txa
	sbc     #$00
	bvc     L0063
	eor     #$80
L0063:	asl     a
	lda     #$00
	ldx     #$00
	rol     a
	jne     L005F
	jmp     L005D
L005F:	ldy     #$07
	jsr     ldaxysp
	jsr     incax6
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	ldy     #$41
	jsr     decaxy
	ldy     #$08
	ldx     #$00
	clc
	adc     (sp),y
	sta     (sp),y
	ldy     #$08
	ldx     #$00
	lda     (sp),y
	cmp     #$5B
	lda     #$00
	ldx     #$00
	rol     a
	jeq     L0068
	ldy     #$08
	ldx     #$00
	lda     (sp),y
	sec
	sbc     #$1A
	sta     (sp),y
L0068:	ldy     #$07
	jsr     ldaxysp
	jsr     incax3
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	ldy     #$41
	jsr     decaxy
	ldy     #$08
	ldx     #$00
	eor     #$FF
	sec
	adc     (sp),y
	sta     (sp),y
	ldy     #$08
	ldx     #$00
	lda     (sp),y
	cmp     #$41
	jsr     boolult
	jeq     L006F
	ldy     #$08
	ldx     #$00
	clc
	lda     #$1A
	adc     (sp),y
	sta     (sp),y
L006F:	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	jsr     decax1
	jsr     pushax
	ldx     #$00
	lda     #$1A
	jsr     tosmulax
	clc
	adc     #<(_rotor)
	tay
	txa
	adc     #>(_rotor)
	tax
	tya
	jsr     pushax
	ldy     #$0A
	ldx     #$00
	lda     (sp),y
	ldy     #$41
	jsr     decaxy
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	ldy     #$08
	sta     (sp),y
	ldy     #$07
	jsr     ldaxysp
	jsr     incax3
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	ldy     #$41
	jsr     decaxy
	ldy     #$08
	ldx     #$00
	clc
	adc     (sp),y
	sta     (sp),y
	ldy     #$08
	ldx     #$00
	lda     (sp),y
	cmp     #$5B
	lda     #$00
	ldx     #$00
	rol     a
	jeq     L007B
	ldy     #$08
	ldx     #$00
	lda     (sp),y
	sec
	sbc     #$1A
	sta     (sp),y
L007B:	ldy     #$07
	jsr     ldaxysp
	jsr     incax6
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	ldy     #$41
	jsr     decaxy
	ldy     #$08
	ldx     #$00
	eor     #$FF
	sec
	adc     (sp),y
	sta     (sp),y
	ldy     #$08
	ldx     #$00
	lda     (sp),y
	cmp     #$41
	jsr     boolult
	jeq     L005E
	ldy     #$08
	ldx     #$00
	clc
	lda     #$1A
	adc     (sp),y
	sta     (sp),y
L005E:	ldy     #$05
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$04
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	jmp     L005C
L005D:	ldy     #$08
	ldx     #$00
	lda     (sp),y
	ldy     #$41
	jsr     decaxy
	clc
	adc     #<(_ref)
	tay
	txa
	adc     #>(_ref)
	tax
	tya
	ldy     #$00
	jsr     ldauidx
	ldy     #$08
	sta     (sp),y
	ldx     #$00
	lda     #$03
	ldy     #$04
	jsr     staxysp
L0089:	ldy     #$05
	lda     (sp),y
	dey
	ora     (sp),y
	jne     L008C
	jmp     L008A
L008C:	ldy     #$07
	jsr     ldaxysp
	jsr     incax6
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     decax1
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	ldy     #$41
	jsr     decaxy
	ldy     #$08
	ldx     #$00
	clc
	adc     (sp),y
	sta     (sp),y
	ldy     #$08
	ldx     #$00
	lda     (sp),y
	cmp     #$5B
	lda     #$00
	ldx     #$00
	rol     a
	jeq     L0094
	ldy     #$08
	ldx     #$00
	lda     (sp),y
	sec
	sbc     #$1A
	sta     (sp),y
L0094:	ldy     #$07
	jsr     ldaxysp
	jsr     incax3
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     decax1
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	ldy     #$41
	jsr     decaxy
	ldy     #$08
	ldx     #$00
	eor     #$FF
	sec
	adc     (sp),y
	sta     (sp),y
	ldy     #$08
	ldx     #$00
	lda     (sp),y
	cmp     #$41
	jsr     boolult
	jeq     L009B
	ldy     #$08
	ldx     #$00
	clc
	lda     #$1A
	adc     (sp),y
	sta     (sp),y
L009B:	ldx     #$00
	lda     #$00
	ldy     #$02
	jsr     staxysp
L009F:	ldy     #$03
	jsr     ldaxysp
	cmp     #$1A
	txa
	sbc     #$00
	bvc     L00A6
	eor     #$80
L00A6:	asl     a
	lda     #$00
	ldx     #$00
	rol     a
	jne     L00A2
	jmp     L00A0
L00A2:	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     decax1
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	jsr     decax1
	jsr     pushax
	ldx     #$00
	lda     #$1A
	jsr     tosmulax
	clc
	adc     #<(_rotor)
	tay
	txa
	adc     #>(_rotor)
	tax
	tya
	jsr     pushax
	ldy     #$05
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	jsr     pushax
	ldy     #$0A
	ldx     #$00
	lda     (sp),y
	jsr     toseqax
	jeq     L00A1
	jmp     L00A0
L00A1:	ldy     #$03
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$02
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	jmp     L009F
L00A0:	ldy     #$03
	jsr     ldaxysp
	ldy     #$41
	jsr     incaxy
	ldy     #$08
	sta     (sp),y
	ldy     #$07
	jsr     ldaxysp
	jsr     incax3
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     decax1
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	ldy     #$41
	jsr     decaxy
	ldy     #$08
	ldx     #$00
	clc
	adc     (sp),y
	sta     (sp),y
	ldy     #$08
	ldx     #$00
	lda     (sp),y
	cmp     #$5B
	lda     #$00
	ldx     #$00
	rol     a
	jeq     L00B2
	ldy     #$08
	ldx     #$00
	lda     (sp),y
	sec
	sbc     #$1A
	sta     (sp),y
L00B2:	ldy     #$07
	jsr     ldaxysp
	jsr     incax6
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     decax1
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	ldy     #$41
	jsr     decaxy
	ldy     #$08
	ldx     #$00
	eor     #$FF
	sec
	adc     (sp),y
	sta     (sp),y
	ldy     #$08
	ldx     #$00
	lda     (sp),y
	cmp     #$41
	jsr     boolult
	jeq     L008B
	ldy     #$08
	ldx     #$00
	clc
	lda     #$1A
	adc     (sp),y
	sta     (sp),y
L008B:	ldy     #$05
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     decax1
	ldy     #$04
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	jmp     L0089
L008A:	ldx     #$00
	lda     #$00
	ldy     #$04
	jsr     staxysp
L00BD:	ldy     #$07
	jsr     ldaxysp
	ldy     #$09
	jsr     incaxy
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	jne     L00C0
	jmp     L00BE
L00C0:	ldy     #$08
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$09
	jsr     ldaxysp
	ldy     #$09
	jsr     incaxy
	jsr     pushax
	ldy     #$09
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	jsr     toseqax
	jeq     L00C7
	ldy     #$07
	jsr     ldaxysp
	ldy     #$09
	jsr     incaxy
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     incax1
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	ldy     #$08
	sta     (sp),y
	jmp     L00BF
L00C7:	ldy     #$08
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$09
	jsr     ldaxysp
	ldy     #$09
	jsr     incaxy
	jsr     pushax
	ldy     #$09
	jsr     ldaxysp
	jsr     incax1
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	jsr     toseqax
	jeq     L00BF
	ldy     #$07
	jsr     ldaxysp
	ldy     #$09
	jsr     incaxy
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	ldy     #$08
	sta     (sp),y
L00BF:	ldy     #$04
	ldx     #$00
	lda     #$02
	jsr     addeqysp
	jmp     L00BD
L00BE:	ldy     #$08
	ldx     #$00
	lda     (sp),y
	jmp     L000C
L000C:	ldy     #$09
	jsr     addysp
	rts

.endproc

; ---------------------------------------------------------------
; __near__ unsigned char* __near__ enigma (__near__ unsigned char*, __near__ struct P*)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_enigma: near

.segment	"CODE"

	jsr     decsp2
	ldx     #$00
	lda     #$00
	ldy     #$00
	jsr     staxysp
L00D6:	ldy     #$01
	jsr     ldaxysp
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     _strlen
	jsr     tosultax
	jne     L00D9
	jmp     L00D7
L00D9:	lda     #<(_out)
	ldx     #>(_out)
	ldy     #$00
	clc
	adc     (sp),y
	pha
	txa
	iny
	adc     (sp),y
	tax
	pla
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$05
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	jsr     pusha
	ldy     #$06
	jsr     ldaxysp
	jsr     pushax
	jsr     _scramble
	ldy     #$00
	jsr     staspidx
	ldy     #$01
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$00
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	jmp     L00D6
L00D7:	lda     #<(_out)
	ldx     #>(_out)
	ldy     #$00
	clc
	adc     (sp),y
	pha
	txa
	iny
	adc     (sp),y
	tax
	pla
	jsr     pushax
	ldx     #$00
	lda     #$00
	ldy     #$00
	jsr     staspidx
	lda     #<(_out)
	ldx     #>(_out)
	jmp     L00D5
L00D5:	jsr     incsp6
	rts

.endproc

; ---------------------------------------------------------------
; void __near__ cypher (__near__ struct P*)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_cypher: near

.segment	"CODE"

	ldy     #$A2
	jsr     subysp
	ldx     #$00
	lda     #$00
	jsr     pushax
L00ED:	jsr     _getchar
	ldy     #$02
	jsr     staxysp
	cpx     #$00
	bne     L00F2
	cmp     #$0A
L00F2:	jsr     boolne
	jeq     L00EE
	lda     #$54
	jsr     leaa0sp
	ldy     #$00
	clc
	adc     (sp),y
	pha
	txa
	iny
	adc     (sp),y
	tax
	pla
	jsr     pushax
	ldy     #$05
	jsr     ldaxysp
	jsr     _toupper
	ldy     #$00
	jsr     staspidx
	ldy     #$01
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$00
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	jmp     L00ED
L00EE:	lda     #$54
	jsr     leaa0sp
	ldy     #$00
	clc
	adc     (sp),y
	pha
	txa
	iny
	adc     (sp),y
	tax
	pla
	jsr     pushax
	ldx     #$00
	lda     #$00
	ldy     #$00
	jsr     staspidx
	lda     #$04
	jsr     leaa0sp
	jsr     pushax
	lda     #$56
	jsr     leaa0sp
	jsr     pushax
	ldy     #$A9
	jsr     ldaxysp
	jsr     pushax
	jsr     _enigma
	jsr     _strcpy
	lda     #<(L0001)
	ldx     #>(L0001)
	jsr     pushax
	lda     #$06
	jsr     leaa0sp
	jsr     pushax
	lda     #$58
	jsr     leaa0sp
	jsr     pushax
	ldy     #$06
	jsr     _printf
	ldy     #$A6
	jsr     addysp
	rts

.endproc

; ---------------------------------------------------------------
; void __near__ rotate (int, int, int, __near__ unsigned char*, __near__ unsigned char*, __near__ unsigned char*, __near__ int*)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_rotate: near

.segment	"CODE"

	ldy     #$28
	jsr     subysp
	ldy     #$34
	ldx     #$00
	lda     (sp),y
	ldy     #$13
	sta     (sp),y
	ldy     #$32
	ldx     #$00
	lda     (sp),y
	ldy     #$14
	sta     (sp),y
	ldy     #$30
	ldx     #$00
	lda     (sp),y
	ldy     #$15
	sta     (sp),y
	ldx     #$00
	lda     #$41
	ldy     #$16
	sta     (sp),y
	ldx     #$00
	lda     #$41
	ldy     #$17
	sta     (sp),y
	ldx     #$00
	lda     #$41
	ldy     #$18
	sta     (sp),y
	lda     #$1C
	jsr     leaa0sp
	jsr     pushax
	ldy     #$2D
	jsr     ldaxysp
	jsr     _strcpy
	ldx     #$00
	lda     #$41
	ldy     #$19
	sta     (sp),y
L011A:	ldy     #$19
	ldx     #$00
	lda     (sp),y
	cmp     #$5B
	jsr     boolult
	jne     L011D
	jmp     L011B
L011D:	ldx     #$00
	lda     #$41
	ldy     #$1A
	sta     (sp),y
L0125:	ldy     #$1A
	ldx     #$00
	lda     (sp),y
	cmp     #$5B
	jsr     boolult
	jne     L0128
	jmp     L011C
L0128:	ldx     #$00
	lda     #$41
	ldy     #$1B
	sta     (sp),y
L0130:	ldy     #$1B
	ldx     #$00
	lda     (sp),y
	cmp     #$5B
	jsr     boolult
	jne     L0133
	jmp     L0127
L0133:	lda     sp
	ldx     sp+1
	jsr     pushax
	lda     #$15
	jsr     leaa0sp
	jsr     pushax
	ldx     #$00
	lda     #$13
	jsr     _memcpy
	ldx     #$00
	lda     #$00
	ldy     #$26
	jsr     staxysp
L0142:	ldy     #$2D
	jsr     ldaxysp
	jsr     _strlen
	jsr     pushax
	ldy     #$29
	jsr     ldaxysp
	jsr     tosugtax
	jeq     L0143
	ldy     #$2F
	jsr     ldaxysp
	jsr     pushax
	ldy     #$29
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	jsr     pushax
	ldy     #$2F
	jsr     ldaxysp
	jsr     pushax
	ldy     #$2B
	jsr     ldaxysp
	jsr     tosaddax
	ldy     #$00
	jsr     ldauidx
	jsr     pusha
	lda     #$03
	jsr     leaa0sp
	jsr     pushax
	jsr     _scramble
	jsr     tosneax
	jeq     L0146
	jmp     L0143
	jmp     L014C
L0146:	ldy     #$27
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$26
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
L014C:	jmp     L0142
L0143:	ldy     #$2D
	jsr     ldaxysp
	jsr     _strlen
	jsr     pushax
	ldy     #$29
	jsr     ldaxysp
	jsr     toseqax
	jeq     L0132
	ldy     #$50
	jsr     subysp
	ldy     #$79
	jsr     ldaxysp
	jsr     pushax
	ldy     #$01
	jsr     ldaxidx
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$00
	jsr     staxspidx
	lda     regsave
	ldx     regsave+1
	lda     #<(L0001+8)
	ldx     #>(L0001+8)
	jsr     pushax
	ldy     #$65
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$68
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$6B
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$71
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$74
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$77
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$74
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$77
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$7A
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	lda     #$80
	jsr     leaa0sp
	jsr     pushax
	ldy     #$16
	jsr     _printf
	lda     #$50
	jsr     leaa0sp
	jsr     pushax
	lda     #$65
	jsr     leaa0sp
	jsr     pushax
	ldx     #$00
	lda     #$13
	jsr     _memcpy
	lda     sp
	ldx     sp+1
	jsr     pushax
	ldy     #$81
	jsr     ldaxysp
	jsr     pushax
	lda     #$54
	jsr     leaa0sp
	jsr     pushax
	jsr     _enigma
	jsr     _strcpy
	lda     #<(L0001+69)
	ldx     #>(L0001+69)
	jsr     pushax
	ldy     #$81
	jsr     ldaxysp
	jsr     pushax
	lda     #$04
	jsr     leaa0sp
	jsr     pushax
	ldy     #$06
	jsr     _printf
	ldy     #$50
	jsr     addysp
L0132:	ldy     #$1B
	ldx     #$00
	lda     (sp),y
	pha
	clc
	adc     #$01
	ldy     #$1B
	sta     (sp),y
	pla
	jmp     L0130
L0127:	ldy     #$1A
	ldx     #$00
	lda     (sp),y
	pha
	clc
	adc     #$01
	ldy     #$1A
	sta     (sp),y
	pla
	jmp     L0125
L011C:	ldy     #$19
	ldx     #$00
	lda     (sp),y
	pha
	clc
	adc     #$01
	ldy     #$19
	sta     (sp),y
	pla
	jmp     L011A
L011B:	ldy     #$36
	jsr     addysp
	rts

.endproc

; ---------------------------------------------------------------
; void __near__ test (int, int, int, __near__ unsigned char*, __near__ unsigned char*, __near__ int*)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_test: near

.segment	"CODE"

	jsr     decsp4
	ldx     #$00
	lda     #$00
	jsr     pushax
	ldx     #$00
	lda     #$00
	jsr     pushax
	jsr     decsp5
	ldy     #$FF
L017B:	iny
	lda     L0001+88,y
	sta     (sp),y
	bne     L017B
	lda     #<(L0001+89)
	ldx     #>(L0001+89)
	jsr     pushax
	ldy     #$1A
	jsr     ldaxysp
	jsr     pushax
	ldy     #$1A
	jsr     ldaxysp
	jsr     pushax
	ldy     #$1A
	jsr     ldaxysp
	jsr     pushax
	ldy     #$08
	jsr     _printf
	ldx     #$00
	lda     #$00
	ldy     #$05
	jsr     staxysp
L0181:	ldy     #$06
	jsr     ldaxysp
	cmp     #$03
	txa
	sbc     #$00
	bvc     L0188
	eor     #$80
L0188:	asl     a
	lda     #$00
	ldx     #$00
	rol     a
	jne     L0184
	jmp     L0182
L0184:	ldy     #$06
	jsr     ldaxysp
	cmp     #$01
	txa
	sbc     #$00
	bvs     L018C
	eor     #$80
L018C:	asl     a
	lda     #$00
	ldx     #$00
	rol     a
	jeq     L018A
	ldx     #$00
	lda     #$41
	ldy     #$0C
	sta     (sp),y
L018D:	ldy     #$0C
	ldx     #$00
	lda     (sp),y
	cmp     #$42
	jsr     boolult
	jne     L0190
	jmp     L018E
L0190:	ldy     #$0C
	ldx     #$00
	lda     (sp),y
	jsr     incax1
	ldy     #$0B
	sta     (sp),y
L0195:	ldy     #$0B
	ldx     #$00
	lda     (sp),y
	cmp     #$42
	jsr     boolult
	jne     L0198
	jmp     L018F
L0198:	ldy     #$0C
	ldx     #$00
	lda     (sp),y
	ldy     #$00
	sta     (sp),y
	ldy     #$0B
	ldx     #$00
	lda     (sp),y
	ldy     #$01
	sta     (sp),y
	ldx     #$00
	lda     #$00
	ldy     #$02
	sta     (sp),y
	ldy     #$06
	jsr     ldaxysp
	cmp     #$02
	txa
	sbc     #$00
	bvs     L01A8
	eor     #$80
L01A8:	asl     a
	lda     #$00
	ldx     #$00
	rol     a
	jeq     L01A6
	ldy     #$0C
	ldx     #$00
	lda     (sp),y
	jsr     incax1
	ldy     #$0A
	sta     (sp),y
L01A9:	ldy     #$0A
	ldx     #$00
	lda     (sp),y
	cmp     #$42
	jsr     boolult
	jne     L01AC
	jmp     L01AA
L01AC:	ldy     #$0A
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$0D
	ldx     #$00
	lda     (sp),y
	jsr     toseqax
	jeq     L01B1
	jmp     L01AB
L01B1:	ldy     #$0A
	ldx     #$00
	lda     (sp),y
	jsr     incax1
	ldy     #$09
	sta     (sp),y
L01B3:	ldy     #$09
	ldx     #$00
	lda     (sp),y
	cmp     #$42
	jsr     boolult
	jne     L01B6
	jmp     L01AB
L01B6:	ldy     #$09
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$0E
	ldx     #$00
	lda     (sp),y
	jsr     toseqax
	jne     L01BC
	ldy     #$09
	ldx     #$00
	lda     (sp),y
	jsr     pushax
	ldy     #$0D
	ldx     #$00
	lda     (sp),y
	jsr     toseqax
	jne     L01BC
	ldx     #$00
	lda     #$00
	jeq     L01BD
L01BC:	ldx     #$00
	lda     #$01
L01BD:	jeq     L01BB
	jmp     L01B5
L01BB:	ldy     #$08
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$07
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	ldy     #$0A
	ldx     #$00
	lda     (sp),y
	ldy     #$02
	sta     (sp),y
	ldy     #$09
	ldx     #$00
	lda     (sp),y
	ldy     #$03
	sta     (sp),y
	ldx     #$00
	lda     #$00
	ldy     #$04
	sta     (sp),y
	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	lda     #$0A
	jsr     leaa0sp
	jsr     pushax
	ldy     #$1A
	jsr     ldaxysp
	jsr     pushax
	jsr     _rotate
L01B5:	ldy     #$09
	ldx     #$00
	lda     (sp),y
	pha
	clc
	adc     #$01
	ldy     #$09
	sta     (sp),y
	pla
	jmp     L01B3
L01AB:	ldy     #$0A
	ldx     #$00
	lda     (sp),y
	pha
	clc
	adc     #$01
	ldy     #$0A
	sta     (sp),y
	pla
	jmp     L01A9
L01AA:	jmp     L0197
L01A6:	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	lda     #$0A
	jsr     leaa0sp
	jsr     pushax
	ldy     #$1A
	jsr     ldaxysp
	jsr     pushax
	jsr     _rotate
L0197:	ldy     #$0B
	ldx     #$00
	lda     (sp),y
	pha
	clc
	adc     #$01
	ldy     #$0B
	sta     (sp),y
	pla
	jmp     L0195
L018F:	ldy     #$0C
	ldx     #$00
	lda     (sp),y
	pha
	clc
	adc     #$01
	ldy     #$0C
	sta     (sp),y
	pla
	jmp     L018D
L018E:	jmp     L0183
L018A:	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	ldy     #$18
	jsr     ldaxysp
	jsr     pushax
	lda     #$0A
	jsr     leaa0sp
	jsr     pushax
	ldy     #$1A
	jsr     ldaxysp
	jsr     pushax
	jsr     _rotate
L0183:	ldy     #$06
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$05
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	jmp     L0181
L0182:	ldy     #$19
	jsr     addysp
	rts

.endproc

; ---------------------------------------------------------------
; void __near__ permute (int, int, int, __near__ unsigned char*, __near__ unsigned char*, __near__ int*)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_permute: near

.segment	"CODE"

	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	jsr     _test
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$09
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0D
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	jsr     _test
	ldy     #$09
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0D
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	jsr     _test
	ldy     #$09
	jsr     ldaxysp
	jsr     pushax
	ldy     #$09
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0F
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	jsr     _test
	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0D
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0D
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	jsr     _test
	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0F
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	jsr     _test
	ldy     #$0C
	jsr     addysp
	rts

.endproc

; ---------------------------------------------------------------
; void __near__ permuteAll (__near__ unsigned char*, __near__ unsigned char*)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_permuteAll: near

.segment	"CODE"

	ldx     #$00
	lda     #$00
	jsr     pushax
	lda     #<(L0001+116)
	ldx     #>(L0001+116)
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$07
	jsr     ldaxysp
	jsr     pushax
	ldy     #$06
	jsr     _printf
	ldx     #$00
	lda     #$01
	jsr     pushax
	ldx     #$00
	lda     #$02
	jsr     pushax
	ldx     #$00
	lda     #$03
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	lda     #$0A
	jsr     leaa0sp
	jsr     pushax
	jsr     _permute
	ldx     #$00
	lda     #$01
	jsr     pushax
	ldx     #$00
	lda     #$02
	jsr     pushax
	ldx     #$00
	lda     #$04
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	lda     #$0A
	jsr     leaa0sp
	jsr     pushax
	jsr     _permute
	ldx     #$00
	lda     #$01
	jsr     pushax
	ldx     #$00
	lda     #$02
	jsr     pushax
	ldx     #$00
	lda     #$05
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	lda     #$0A
	jsr     leaa0sp
	jsr     pushax
	jsr     _permute
	ldx     #$00
	lda     #$01
	jsr     pushax
	ldx     #$00
	lda     #$03
	jsr     pushax
	ldx     #$00
	lda     #$04
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	lda     #$0A
	jsr     leaa0sp
	jsr     pushax
	jsr     _permute
	ldx     #$00
	lda     #$01
	jsr     pushax
	ldx     #$00
	lda     #$03
	jsr     pushax
	ldx     #$00
	lda     #$05
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	lda     #$0A
	jsr     leaa0sp
	jsr     pushax
	jsr     _permute
	ldx     #$00
	lda     #$01
	jsr     pushax
	ldx     #$00
	lda     #$04
	jsr     pushax
	ldx     #$00
	lda     #$05
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	lda     #$0A
	jsr     leaa0sp
	jsr     pushax
	jsr     _permute
	ldx     #$00
	lda     #$02
	jsr     pushax
	ldx     #$00
	lda     #$03
	jsr     pushax
	ldx     #$00
	lda     #$04
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	lda     #$0A
	jsr     leaa0sp
	jsr     pushax
	jsr     _permute
	ldx     #$00
	lda     #$02
	jsr     pushax
	ldx     #$00
	lda     #$03
	jsr     pushax
	ldx     #$00
	lda     #$05
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	lda     #$0A
	jsr     leaa0sp
	jsr     pushax
	jsr     _permute
	ldx     #$00
	lda     #$02
	jsr     pushax
	ldx     #$00
	lda     #$04
	jsr     pushax
	ldx     #$00
	lda     #$05
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	lda     #$0A
	jsr     leaa0sp
	jsr     pushax
	jsr     _permute
	ldx     #$00
	lda     #$03
	jsr     pushax
	ldx     #$00
	lda     #$04
	jsr     pushax
	ldx     #$00
	lda     #$05
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	ldy     #$0B
	jsr     ldaxysp
	jsr     pushax
	lda     #$0A
	jsr     leaa0sp
	jsr     pushax
	jsr     _permute
	lda     #<(L0001+136)
	ldx     #>(L0001+136)
	jsr     pushax
	ldy     #$03
	jsr     ldaxysp
	jsr     pushax
	ldy     #$04
	jsr     _printf
	jsr     incsp6
	rts

.endproc

; ---------------------------------------------------------------
; unsigned char __near__ readCh (void)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_readCh: near

.segment	"CODE"

	jsr     decsp2
L025D:	jsr     _getchar
	ldy     #$01
	sta     (sp),y
	cmp     #$0A
	jsr     boolne
	jeq     L025E
	ldy     #$01
	ldx     #$00
	lda     (sp),y
	ldy     #$00
	sta     (sp),y
	jmp     L025D
L025E:	ldy     #$00
	ldx     #$00
	lda     (sp),y
	jmp     L025C
L025C:	jsr     incsp2
	rts

.endproc

; ---------------------------------------------------------------
; void __near__ initParams (__near__ struct P*)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_initParams: near

.segment	"RODATA"

L0267:
	.byte	$00
	.res	63,$00
L026A:
	.byte	$00
	.res	63,$00

.segment	"CODE"

	ldy     #$43
	jsr     subysp
	ldy     #$3F
L0268:	lda     L0267,y
	sta     (sp),y
	dey
	bpl     L0268
	ldy     #$40
	jsr     subysp
	ldy     #$3F
L026B:	lda     L026A,y
	sta     (sp),y
	dey
	bpl     L026B
	lda     #<(L0001+158)
	ldx     #>(L0001+158)
	jsr     pushax
	ldy     #$02
	jsr     _printf
	lda     #<(L0001+160)
	ldx     #>(L0001+160)
	jsr     pushax
	ldy     #$02
	jsr     _printf
	lda     #<(L0001+180)
	ldx     #>(L0001+180)
	jsr     pushax
	ldy     #$02
	jsr     _printf
	jsr     _readCh
	ldy     #$80
	sta     (sp),y
	ldy     #$80
	ldx     #$00
	lda     (sp),y
	cmp     #$42
	jsr     booleq
	jeq     L0274
	lda     #<(L0001+193)
	ldx     #>(L0001+193)
	jsr     pushax
	ldy     #$02
	jsr     _printf
	ldx     #$00
	lda     #$00
	ldy     #$81
	jsr     staxysp
L027A:	jsr     _getchar
	ldy     #$80
	sta     (sp),y
	cmp     #$0A
	jsr     boolne
	jeq     L027B
	lda     #$40
	jsr     leaa0sp
	ldy     #$81
	clc
	adc     (sp),y
	pha
	txa
	iny
	adc     (sp),y
	tax
	pla
	jsr     pushax
	ldy     #$82
	ldx     #$00
	lda     (sp),y
	ldy     #$00
	jsr     staspidx
	ldy     #$82
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$81
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	jmp     L027A
L027B:	lda     #<(L0001+213)
	ldx     #>(L0001+213)
	jsr     pushax
	ldy     #$02
	jsr     _printf
	ldx     #$00
	lda     #$00
	ldy     #$81
	jsr     staxysp
L0287:	jsr     _getchar
	ldy     #$80
	sta     (sp),y
	cmp     #$0A
	jsr     boolne
	jeq     L0288
	lda     sp
	ldx     sp+1
	ldy     #$81
	clc
	adc     (sp),y
	pha
	txa
	iny
	adc     (sp),y
	tax
	pla
	jsr     pushax
	ldy     #$82
	ldx     #$00
	lda     (sp),y
	ldy     #$00
	jsr     staspidx
	ldy     #$82
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$81
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	jmp     L0287
L0288:	lda     #$40
	jsr     leaa0sp
	jsr     pushax
	lda     #$02
	jsr     leaa0sp
	jsr     pushax
	jsr     _permuteAll
	jmp     L0265
L0274:	ldy     #$80
	ldx     #$00
	lda     (sp),y
	cmp     #$55
	jsr     boolne
	jeq     L0293
	ldx     #$00
	lda     #$00
	ldy     #$81
	jsr     staxysp
L0295:	ldy     #$82
	jsr     ldaxysp
	cmp     #$03
	txa
	sbc     #$00
	bvc     L029C
	eor     #$80
L029C:	asl     a
	lda     #$00
	ldx     #$00
	rol     a
	jne     L0298
	jmp     L0296
L0298:	ldy     #$84
	jsr     ldaxysp
	jsr     pushax
	ldy     #$84
	jsr     ldaxysp
	jsr     tosaddax
	jsr     pushax
	ldy     #$84
	jsr     ldaxysp
	jsr     incax1
	ldy     #$00
	jsr     staspidx
	ldy     #$84
	jsr     ldaxysp
	jsr     incax3
	jsr     pushax
	ldy     #$84
	jsr     ldaxysp
	jsr     tosaddax
	jsr     pushax
	ldx     #$00
	lda     #$41
	ldy     #$00
	jsr     staspidx
	ldy     #$84
	jsr     ldaxysp
	jsr     incax6
	jsr     pushax
	ldy     #$84
	jsr     ldaxysp
	jsr     tosaddax
	jsr     pushax
	ldx     #$00
	lda     #$41
	ldy     #$00
	jsr     staspidx
	ldy     #$82
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$81
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	jmp     L0295
L0296:	ldy     #$84
	jsr     ldaxysp
	ldy     #$09
	jsr     incaxy
	jsr     pushax
	lda     #<(L0001+233)
	ldx     #>(L0001+233)
	jsr     _strcpy
	jmp     L02AA
L0293:	ldx     #$00
	lda     #$00
	ldy     #$81
	jsr     staxysp
L02AB:	ldy     #$82
	jsr     ldaxysp
	cmp     #$03
	txa
	sbc     #$00
	bvc     L02B2
	eor     #$80
L02B2:	asl     a
	lda     #$00
	ldx     #$00
	rol     a
	jne     L02AE
	jmp     L02AC
L02AE:	lda     #<(L0001+234)
	ldx     #>(L0001+234)
	jsr     pushax
	ldy     #$84
	jsr     ldaxysp
	jsr     incax1
	jsr     pushax
	ldy     #$04
	jsr     _printf
	ldy     #$84
	jsr     ldaxysp
	jsr     pushax
	ldy     #$84
	jsr     ldaxysp
	jsr     tosaddax
	jsr     pushax
	jsr     _readCh
	ldy     #$30
	jsr     decaxy
	ldy     #$00
	jsr     staspidx
	ldy     #$82
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$81
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	jmp     L02AB
L02AC:	ldx     #$00
	lda     #$00
	ldy     #$81
	jsr     staxysp
L02BA:	ldy     #$82
	jsr     ldaxysp
	cmp     #$03
	txa
	sbc     #$00
	bvc     L02C1
	eor     #$80
L02C1:	asl     a
	lda     #$00
	ldx     #$00
	rol     a
	jne     L02BD
	jmp     L02BB
L02BD:	ldy     #$84
	jsr     ldaxysp
	jsr     incax3
	jsr     pushax
	ldy     #$84
	jsr     ldaxysp
	jsr     tosaddax
	jsr     pushax
	ldx     #$00
	lda     #$41
	ldy     #$00
	jsr     staspidx
	ldy     #$82
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$81
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	jmp     L02BA
L02BB:	ldx     #$00
	lda     #$00
	ldy     #$81
	jsr     staxysp
L02C6:	ldy     #$82
	jsr     ldaxysp
	cmp     #$03
	txa
	sbc     #$00
	bvc     L02CD
	eor     #$80
L02CD:	asl     a
	lda     #$00
	ldx     #$00
	rol     a
	jne     L02C9
	jmp     L02C7
L02C9:	lda     #<(L0001+245)
	ldx     #>(L0001+245)
	jsr     pushax
	ldy     #$84
	jsr     ldaxysp
	jsr     incax1
	jsr     pushax
	ldy     #$04
	jsr     _printf
	ldy     #$84
	jsr     ldaxysp
	jsr     incax6
	jsr     pushax
	ldy     #$84
	jsr     ldaxysp
	jsr     tosaddax
	jsr     pushax
	jsr     _readCh
	ldy     #$00
	jsr     staspidx
	ldy     #$82
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$81
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	jmp     L02C6
L02C7:	lda     #<(L0001+256)
	ldx     #>(L0001+256)
	jsr     pushax
	ldy     #$02
	jsr     _printf
	ldx     #$00
	lda     #$00
	ldy     #$81
	jsr     staxysp
L02D9:	jsr     _getchar
	ldy     #$80
	sta     (sp),y
	cmp     #$0A
	jsr     boolne
	jeq     L02DA
	ldy     #$84
	jsr     ldaxysp
	ldy     #$09
	jsr     incaxy
	jsr     pushax
	ldy     #$84
	jsr     ldaxysp
	jsr     tosaddax
	jsr     pushax
	ldy     #$82
	ldx     #$00
	lda     (sp),y
	ldy     #$00
	jsr     staspidx
	ldy     #$82
	jsr     ldaxysp
	sta     regsave
	stx     regsave+1
	jsr     incax1
	ldy     #$81
	jsr     staxysp
	lda     regsave
	ldx     regsave+1
	jmp     L02D9
L02DA:	ldy     #$84
	jsr     ldaxysp
	ldy     #$09
	jsr     incaxy
	jsr     pushax
	ldy     #$84
	jsr     ldaxysp
	jsr     tosaddax
	jsr     pushax
	ldx     #$00
	lda     #$00
	ldy     #$00
	jsr     staspidx
L02AA:	lda     #<(L0001+266)
	ldx     #>(L0001+266)
	jsr     pushax
	ldy     #$86
	jsr     ldaxysp
	ldy     #$00
	jsr     ldauidx
	jsr     pushax
	ldy     #$88
	jsr     ldaxysp
	ldy     #$01
	jsr     ldauidx
	jsr     pushax
	ldy     #$8A
	jsr     ldaxysp
	ldy     #$02
	jsr     ldauidx
	jsr     pushax
	ldy     #$8C
	jsr     ldaxysp
	ldy     #$06
	jsr     ldauidx
	jsr     pushax
	ldy     #$8E
	jsr     ldaxysp
	ldy     #$07
	jsr     ldauidx
	jsr     pushax
	ldy     #$90
	jsr     ldaxysp
	ldy     #$08
	jsr     ldauidx
	jsr     pushax
	ldy     #$92
	jsr     ldaxysp
	ldy     #$03
	jsr     ldauidx
	jsr     pushax
	ldy     #$94
	jsr     ldaxysp
	ldy     #$04
	jsr     ldauidx
	jsr     pushax
	ldy     #$96
	jsr     ldaxysp
	ldy     #$05
	jsr     ldauidx
	jsr     pushax
	ldy     #$98
	jsr     ldaxysp
	ldy     #$09
	jsr     incaxy
	jsr     pushax
	ldy     #$16
	jsr     _printf
L0265:	ldy     #$85
	jsr     addysp
	rts

.endproc

; ---------------------------------------------------------------
; void __near__ main (void)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_main: near

.segment	"CODE"

	ldy     #$13
	jsr     subysp
	lda     sp
	ldx     sp+1
	jsr     pushax
	jsr     _initParams
	lda     sp
	ldx     sp+1
	jsr     pushax
	jsr     _cypher
	ldy     #$13
	jsr     addysp
	rts

.endproc

