;:poke56,112:clr
;:sys36864
	;.opt oo
	*= $8000
fo	=$e000 	; zeichensatz
rech	=$e9f0
fram	=$ea24
b	=$d1
f	=$f3
stack	=$7000
u	=$dc00
ab	jmp los
	ldy #0
	sty 4
	lda #224
	sta 5
	lda #1
	sta 2
	lda #1
	sta 3
	ldx #8
cp	lda (2),y
	sta (4),y
	iny
	bne cp
	inc 3
	inc 5
	dex
	bne cp
	beq ab
fah	brk 	; fahnenzaehler
anc	.byt 1 	; fahnen-animation
ane	.byt 1 	; wasser-animation
if	.byt 1 	; flag interrupt
cuz	brk 	; cursorblinkzaehler
anz	.byt 40 	; anz bomben
lang	.byt 26 	; feld-breite
hoch	.byt 12 	; feld-hoehe
temp	brk
tmp	=2
x0	brk 	; startpos spielfeld (x)
x9	brk 	; endpos spielfeld (x)
smnr	brk 	; smiley-nr
po	=181
cc	brk
cx	brk
cy	brk
joy	brk
ojoy	brk
rep	.byt 1 	; joystick-repeat
joyv	brk 	; joystick-speed
tas	brk
otas	brk
x	brk
y	brk
z	brk
game	brk 	; 1 = spiel laeuft
sp	=4 	; stackpointer
abo	brk 	; anz bomben noch im spiel
irq	brk
time	.word 0
ti	.word 0
	brk 	; rechenregister
to	.word 0
lang0	brk
hoch0	brk
maus	.byt 4,0,0,6,0,0,7,0,0,7,128,0,7,192,0,7,224
	.byt 0,7,240,0,7,192,0,6,224,0,4,224,0,0,112,0
	.byt 0,112,0,0,56,0,0,56
cucol	.byt 1,1,1,15,15,12,11,11,0,0,0
	.byt 11,11,12,15,15,-1
nucol	.byt 0,13,2,7,11,1,6,3
hide	sei
	lda anz
	sta temp
	lda #0
	tax
hi1	sta $c800,x
	sta $c900,x
	sta $ca00,x
	sta $cb00,x
	inx
	bne hi1
hi2	jsr rnd
	and #31
	cmp hoch
	bcs hi2
	tay
hi3	jsr rnd
	and #31
	cmp lang
	bcs hi3
	tax
	jsr adr
	lda (tmp),y
	bmi hi2
	lda #128
	sta (tmp),y
	dec temp
	bne hi2
	lda #40
	sec
	sbc lang
	lsr
	sta x0
	clc
	adc lang
	sta x9
	dec x0
	cli
	rts
frech	jsr rech
	jmp fram
rnd	lda 54299
	eor 53266
	eor 162
	rts
cadr	sei
	lda cx
	clc
	sbc x0
	tax
	lda cy
	sec
	sbc #7
	tay
adr	lda #0
	sta tmp+1
	tya
	asl
	asl
	asl
	asl
	rol tmp+1
	asl
	rol tmp+1
	sta tmp
	txa
	adc tmp
	sta tmp
	lda tmp+1
	adc #$c8
	sta tmp+1
	ldy #0
	rts
frame	dec x0
	ldx #3
	jsr frech
	ldy x0
	lda #116
	sta (b),y
fr1	lda #1
	sta (f),y
	iny
	lda #112
	sta (b),y
	cpy x9
	bcc fr1
	lda #1
	sta (f),y
	iny
	sta (f),y
	lda #117
	sta (b),y
	jsr zeir
	jsr zeir
	inx
	jsr frech
	ldy x0
	lda #118
	sta (b),y
fr2	lda #1
	sta (f),y
	iny
	lda #120
	sta (b),y
	cpy x9
	bcc fr2
	lda #1
	sta (f),y
	iny
	sta (f),y
	lda #119
	sta (b),y
	lda hoch
	sta temp
fr3	jsr zeir
	dec temp
	bpl fr3
	jsr zeir
	inx
	jsr frech
	ldy x0
	lda #115
	sta (b),y
fr4	lda #1
	sta (f),y
	iny
	lda #112
	sta (b),y
	cpy x9
	bcc fr4
	lda #1
	sta (f),y
	iny
	sta (f),y
	lda #114
	sta (b),y
	inc x0
	dex
	jsr frech
	dex
	stx temp
	ldy x0
	lda #82
	sta (b),y
fr5	lda #15
	sta (f),y
	iny
	lda #83
	sta (b),y
	cpy x9
	bcc fr5
	lda #84
	sta (b),y
	lda #15
	sta (f),y
	ldx #7
	jsr frech
	ldy x9
	lda #85
	sta (b),y
	lda #15
	sta (f),y
fr6	inx
	jsr frech
	ldy x9
	lda #86
	sta (b),y
	lda #15
	sta (f),y
	cpx temp
	bcc fr6
	lda #87
	sta (b),y
	rts
zeir	inx
	jsr frech
	ldy x0
	lda #113
	sta (b),y
	ldy x9
	iny
	sta (b),y
	lda #1
	sta (f),y
	ldy x0
	sta (f),y
	rts
feld	dec x9
	ldx #7
	lda hoch
	sta temp
fd1	jsr frech
	ldy x0
	lda #88
	sta (b),y
	lda #6
	sta (f),y
fd2	iny
	jsr rnd
	and #7
	clc
	adc #72
	sta (b),y
	lda #6
	sta (f),y
	cpy x9
	bcc fd2
	inx
	dec temp
	bne fd1
	jsr frech
	ldy x0
fd3	iny
	lda #6
	sta (f),y
	lda #89
	sta (b),y
	cpy x9
	bcc fd3
	inc x9
	rts
eck	sei
	lda y
	clc
	adc #7
	tax
	jsr rech
	lda x
	sec
	adc x0
	tay
	lda (b),y
	cmp #72
	bcc unart
	cmp #80
	bcc darf
unart	jmp raus
darf	ldx x
	ldy y
	jsr adr
	lda tmp
	sec
	sbc #33
	sta tmp
	lda tmp+1
	sbc #0
	sta tmp+1
	ldx #0
	ldy #0
	lda y
	beq e3
	lda x
	beq e1
	lda (tmp),y
	bpl e1
	inx
e1	iny
	lda (tmp),y
	bpl e2
	inx
e2	lda x
	cmp lang0
	bcs e3
	iny
	lda (tmp),y
	bpl e3
	inx
e3	lda x
	beq e4
	ldy #32
	lda (tmp),y
	bpl e4
	inx
e4	lda x
	cmp lang0
	bcs e5
	ldy #34
	lda (tmp),y
	bpl e5
	inx
e5	ldy #64
	lda y
	cmp hoch0
	bcs e8
	lda x
	beq e6
	lda (tmp),y
	bpl e6
	inx
e6	iny
	lda (tmp),y
	bpl e7
	inx
e7	lda x
	cmp lang0
	bcs e8
	iny
	lda (tmp),y
	bpl e8
	inx
e8	txa
	pha
	lda y
	clc
	adc #7
	tax
	jsr frech
	lda x
	sec
	adc x0
	tay
	pla
	beq null
	tax
	ora #48
	sta (b),y
	lda nucol-1,x
	sta (f),y
	jmp raus
null	lda #90
	sta (b),y
	lda #11
	sta (f),y
	lda y
	beq e13
	lda x
	beq e11
	jsr ph
	dec x
	dec y
	jsr rek
	jsr pl
e11	jsr ph
	dec y
	jsr rek
	jsr pl
	lda x
	cmp lang0
	bcs e13
	jsr ph
	dec y
	inc x
	jsr rek
	jsr pl
e13	lda x
	beq e14
	jsr ph
	dec x
	jsr rek
	jsr pl
e14	lda x
	cmp lang0
	bcs e15
	jsr ph
	inc x
	jsr rek
	jsr pl
e15	lda y
	cmp hoch0
	bcs raus
	lda x
	beq e16
	jsr ph
	inc y
	dec x
	jsr rek
	jsr pl
e16	jsr ph
	inc y
	jsr rek
	jsr pl
	lda x
	cmp lang0
	bcs raus
	jsr ph
	inc x
	inc y
	jsr rek
	jsr pl
raus	lda sp
	bne tour
	lda sp+1
	cmp #>stack
	bne tour
	jmp loop
ph	ldy #0
	lda x
	sta (sp),y
	lda y
	iny
	sta (sp),y
	inc sp
	inc sp
	bne ret
	inc sp+1
ret	rts
pl	lda sp
	bne run
	dec sp+1
run	dec sp
	dec sp
	ldy #0
	lda (sp),y
	sta x
	iny
	lda (sp),y
	sta y
	rts
rek	ldy #0
	pla
	sta (sp),y
	iny
	pla
	sta (sp),y
	inc sp
	inc sp
	bne ik
	inc sp+1
ik	jmp eck
tour	lda sp
	bne ru
	dec sp+1
ru	dec sp
	dec sp
	ldy #1
	lda (sp),y
	pha
	dey
	lda (sp),y
	pha
	rts
test	sei
	lda abo
	bne false
	lda hoch
	sta y
te1	dec y
	lda lang
	sta x
te2	dec x
	ldx x
	ldy y
	jsr adr
	lda y
	clc
	adc #7
	tax
	jsr frech
	lda x
	sec
	adc x0
	tay
	lda (b),y
	ldy #0
	cmp #121
	bcc noflag
	cmp #125
	bcs noflag
	lda (tmp),y
	bmi renn
false	clc
	rts
noflag	lda (tmp),y
	bmi false
renn	lda x
	bne te2
	lda y
	bne te1
	lda #3
	sta smnr
	jsr uda
	lda #0
	sta game
	lda #7
	ldy #2
	ldx x9
yel	sta 55454,x
	sta 55494,x
	inx
	dey
	bpl yel
	rts
plaus	clc
	ldy hoch
	lda #0
pl1	adc lang
	bcs pl2
	dey
	bne pl1
	cmp anz
	bcs pl2
	sta anz
pl2	rts
los	jsr 65409
	lda #11
	sta 53265
	lda #0
	sta game
	sta 53280
	sta 56576
	sta 646
	sta 53281
	lda #196
	sta 648
	lda #24
	sta 53272
	jsr $e544
	lda #<iq
	ldy #>iq
	sei
	sta 788
	sty 789
	lda #8
	sta $dc05
	ldx #63
	lda #0
	sta 51192
clrsp	sta 49152,x
	dex
	bpl clrsp
	ldx #40
sesp	lda maus,x
	sta 49152,x
	dex
	bpl sesp
	lda #1
	sta 53269
	lda #100
	sta 53248
	sta 53249
	lda #100
	sta 54287
	lda #129
	sta 54290
	ldx #208
	stx 50176
	inx
	stx 50177
	inx
	stx 50214
	inx
	stx 50215
	inx
	stx 51134
	inx
	stx 51135
	inx
	stx 51096
	inx
	stx 51097
	ldx #240
	stx 50216
	inx
	stx 50217
	inx
	stx 50254
	inx
	stx 50255
	inx
	stx 51174
	inx
	stx 51175
	inx
	stx 51136
	inx
	stx 51137
	ldx #21
tit1	txa
	clc
	adc #128
	sta 50219,x
	lda #181
	sta 50259,x
	dex
	bpl tit1
	ldx #7
	dec 50280
tit3	txa
	clc
	adc #150
	sta 50244,x
	dex
	bpl tit3
	ldx #5
tit4	txa
	clc
	adc #182
	sta 50284,x
	dex
	bpl tit4
	ldx #248
	stx 50292
	inx
	stx 50293
	inx
	stx 50282
	inx
	stx 50283
	ldx #216
	stx 50252
	inx
	stx 50253
	inx
	stx 50242
	inx
	stx 50243
	ldx #35
	lda #15
fa1	sta 55338,x
	sta 55378,x
	dex
	bpl fa1
	cli
	lda #12
	sta 53281
	lda #27
	sta 53265
spiel	lda #0
	sta game
	jsr plaus
	lda anz
	sta abo
	jsr hide
	ldx #3
erb	jsr frech
	ldy #2
er1	lda #32
	sta (b),y
	iny
	cpy #38
	bcc er1
	inx
	cpx #25
	bcc erb
	jsr frame
	jsr feld
	lda #0
	sta smnr
	lda #1
	sta game
	lda u+14
	ora #128
	sta u+14
	lda u+15
	and #127
	sta u+15
	lda #0
	sta time+1
	sta u+11
	sta u+10
	sta u+9
	sta u+8
loop	jsr test
lz	cli
	lda joy
	and #16
	beq feuer
	lda joy
	cmp #31
	bne lz
	lda tas
	beq lz
	jmp marker
feuer	lda cc
	cmp #82
	beq q82
	cmp #84
	beq q84
	cmp #85
	beq q85
	cmp #87
	beq q87
	cmp #72
	bcc nowa
	cmp #80
	bcs nowa
	jmp water
nowa	ldx cx
	ldy cy
	beq loop
	cpy #4
	bcc no4
	cpy #6
	bcs no4
	cpx #19
	bcc no4
	cpx #21
	bcs no4
	jmp spiel
no4	cpy #3
	bcs loop
	txa
	lsr
	cmp #13
	beq bomi
	cmp #18
	bne loop
	lda anz
	cmp #99
	bcc kann
endb	jmp spiel
bomi	dec anz
	bne endb
kann	inc anz
	bne endb
q82	lda lang
	cmp #7
	bcc qloop
	dec lang
	bne qspiel
q84	lda lang
	cmp #32
	bcs qloop
	inc lang
	bne qspiel
q85	lda hoch
	cmp #3
	bcc qloop
	dec hoch
	bne qspiel
q87	lda hoch
	cmp #15
	bcs qloop
	inc hoch
qspiel	jmp spiel
qloop	jmp loop
water	lda game
	beq qloop
	jsr cadr
	lda (tmp),y
	bpl nbomb
	lda #0
	sta game
	lda #2
	sta smnr
	lda hoch
	sta y
bo1	dec y
	lda lang
	sta x
bo2	dec x
	ldx x
	ldy y
	jsr adr
	lda y
	clc
	adc #7
	tax
	jsr frech
	lda x
	sec
	adc x0
	tay
	sty z
	lda (b),y
	ldy #0
	cmp #72
	bcc noh2o
	cmp #80
	bcc h2o
noh2o	cmp #121
	bcc lauf
	cmp #125
	bcs lauf
	lda (tmp),y
	bmi lauf
	ldy z
	lda #81
	sta (b),y
	bne lauf
h2o	lda (tmp),y
	bpl lauf
	ldy z
	lda #80
	sta (b),y
	lda b+1
	and #3
	ora #$d8
	sta b+1
	lda #9
	sta (b),y
lauf	lda x
	bne bo2
	lda y
	bne bo1
dloop	jmp loop
nbomb	lda cx
	clc
	sbc x0
	sta x
	lda cy
	sec
	sbc #7
	sta y
	ldx lang
	dex
	stx lang0
	ldx hoch
	dex
	stx hoch0
	lda #0
	sta sp
	lda #>stack
	sta sp+1
	jmp eck
marker	jsr uda
	sei
	lda game
	beq dloop
	jsr cadr
	lda cc
	cmp #72
	bcc dloop
	cmp #80
	bcc mamark
	cmp #121
	bcc dloop
	cmp #125
	bcs dloop
	inc abo
	jsr rnd
	ldy #0
	and #7
	clc
	adc #72
	sta (po),y
	lda #6
	bne color
mamark	lda abo
	cmp #-99
	beq dloop
	dec abo
	jsr rnd
	ldy #0
	and #3
	clc
	adc #121
	sta (po),y
	lda #1
color	pha
	lda po+1
	and #3
	ora #216
	sta po+1
	pla
	sta (po),y
	jmp loop
iq	inc irq
	jsr stick
	jsr mouse
	jsr smile
	jsr segment
	jsr boanz
	dec if
	bne noiq
	lda #8
	sta if
	lda 1
	pha
	lda #53
	sta 1
	jsr anim
	pla
	sta 1
	jmp $ea31
noiq	jmp $ea7e
uda	cli
	lda irq
ud	cmp irq
	beq ud
	rts
anim	dec anc
	bne ani
	jsr rnd
	and #7
	clc
	adc #2
	sta anc
	inc fah
	lda #0
	sta c+2
	lda fah
	and #7
	clc
	adc #104
	ldy #200
	jsr co
	lda #0
	sta c+2
	lda fah
	clc
	adc #2
	and #7
	clc
	adc #104
	ldy #208
	jsr co
	lda #0
	sta c+2
	lda fah
	clc
	adc #4
	and #7
	clc
	adc #104
	ldy #216
	jsr co
	lda #0
	sta c+2
	lda fah
	clc
	adc #6
	and #7
	clc
	adc #104
	ldy #224
	jsr co
ani	dec ane
	bne an0
	lda #8
	sta ane
	ldx #7
	ldy #0
	lda #1
fi	sta fo+579,y
	iny
	iny
	iny
	iny
	iny
	iny
	iny
	iny
	dex
	bpl fi
	jsr rnd
	and #%111000
	clc
	adc #3
	tax
	lda #17
	sta fo+576,x
an0	rts
co	asl
	rol c+2
	asl
	rol c+2
	asl
	rol c+2
	sta c+1
	lda c+2
	ora #>fo
	sta c+2
	sty d+1
	ldx #7
c	lda fo,x
d	sta fo+968,x
	dex
	bpl c
	rts
mouse	lda joy
	and #1
	bne notup
	lda 53249
	cmp #51
	bcc notup
	dec 53249
notup	lda joy
	and #2
	bne notdn
	lda 53249
	cmp #249
	bcs notdn
	inc 53249
notdn	lda joy
	and #4
	bne notle
	lda 53264
	bne le
	lda 53248
	cmp #21
	bcc notle
le	lda 53248
	bne le1
	lda #0
	sta 53264
le1	dec 53248
notle	lda joy
	and #8
	bne notri
	lda 53264
	beq ri
	lda 53248
	cmp #82
	bcs notri
ri	inc 53248
	bne notri
	inc 53264
notri	inc cuz
	lda cuz
	lsr
	lsr
	lsr
	lsr
	tax
	lda cucol,x
	bpl setcc
	sta cuz
	bne notri
setcc	sta 53248+39
	lda #0
	sta po+1
	lda 53249
	sec
	sbc #50
	lsr
	lsr
	lsr
	sta cy
	asl
	asl
	sta po
	asl
	asl
	rol po+1
	adc po
	sta po
	bcc iz
	inc po+1
iz	asl po
	rol po+1
	lda po+1
	adc #196
	sta po+1
	lda 53264
	bne iz5
	lda 53248
	sbc #19
	lsr
	lsr
	lsr
	bpl iz4
iz5	lda 53248
	clc
	adc #237
	php
	lsr
	lsr
	lsr
	plp
	bcc iz4
	adc #31
iz4	sta cx
	clc
	adc po
	sta po
	bcc iz2
	inc po+1
iz2	ldy #0
	lda (po),y
	sta cc
	rts
smile	lda smnr
	asl
	ora #64
	tax
	stx 50355
	inx
	stx 50356
	and #7
	ora #96
	tax
	stx 50395
	inx
	stx 50396
	lda #7
	sta 55475
	sta 55476
	sta 55515
	sta 55516
	lda ojoy
	and #16
	beq fireb
	lda smnr
	cmp #1
	bne nosmi
	dec smnr
nosmi	rts
fireb	cmp smnr
	bne nosmi
	inc smnr
	rts
stick	lda #31
	sta joy
	lda 56320
	and #31
	cmp #31
	beq new
	cmp ojoy
	bne new
	dec rep
	bne keyre
	ldy joyv
	sty rep
	cpy #2
	bcc set
	dec joyv
	bne set
new	ldx #12
	stx joyv
set	sta joy
	sta ojoy
keyre	lda 203
	and #63
	ora 653
	cmp otas
	sta otas
	bne newk
	lda #0
newk	sta tas
keins	rts
segment	lda game
	beq keins
	lda #32
	tay
	ldx abo
	bpl encore
	lda #202
	ldy #234
encore	ldx x0
	sta 50336,x
	tya
	sta 50376,x
	ldy #192
	lda abo
	bpl plubs
	eor #-1
	clc
	adc #1
plubs	cmp #10
	bcc kl10
	sbc #10
	iny
	bne plubs
kl10	adc #192
	pha
	tya
	sta 50337,x
	clc
	adc #32
	sta 50377,x
	pla
	sta 50338,x
	clc
	adc #32
	sta 50378,x
	lda #2
	tax
	ldy x0
ppa	sta 55456,y
	sta 55496,y
	iny
	dex
	bpl ppa
	lda #0
	sta ti+1
	lda time+1
	cmp #>999
	bne valid
	lda time
	cmp #<999
	beq keins
valid	lda u+11
	lda #0
	sta time
	sta time+1
	lda u+10
	pha
	and #240
	cmp #16
	bne h0
	lda #>600
	sta time+1
	lda #<600
	sta time
h0	pla
	and #15
	sta ti
	asl
	pha
	adc ti
	sta ti
	pla
	asl
	pha
	adc ti
	sta ti
	pla
	asl
	adc ti
	asl
	rol ti+1
	asl
	rol ti+1
	adc time
	sta time
	lda time+1
	adc ti+1
	sta time+1
	lda u+9
	pha
	and #15
	clc
	adc time
	sta time
	bcc h1
	inc time+1
h1	pla
	and #240
	lsr
	lsr
	lsr
	lsr
	sta ti
	asl
	asl
	adc ti
	asl
	adc time
	sta time
	bcc h2
	inc time+1
h2	lda u+8
	lda #0
	sta ti
	sta ti+1
	lda time
	sta to
	lda time+1
	sta to+1
h3	lda to+1
	bne h4
	lda to
	cmp #100
	bcc h5
h4	lda to
	sec
	sbc #100
	sta to
	lda to+1
	sbc #0
	sta to+1
	inc ti
	bne h3
h5	lda to
	cmp #10
	bcc h6
	sbc #10
	sta to
	inc ti+1
	bne h5
h6	sta ti+2
	ldy #0
	ldx x9
h7	lda ti,y
	ora #192
	sta 50334,x
	and #15
	ora #224
	sta 50374,x
	lda #2
	sta 55454,x
	sta 55494,x
	inx
	iny
	cpy #3
	bcc h7
	rts
boanz	lda anz
	ldx #160
ba1	cmp #10
	bcc ba2
	sbc #10
	inx
	bne ba1
ba2	stx 50290
	ora #160
	sta 50291
	rts
