
HEAD4 = $60000	;$B40
FONT  = $60B40	;$1000
SIN   = $61B40	;$100
SPR   = $71B40+$100	;$AE0
Z_SCR = $71F90+$100	;$460
Z_SCR2= $72410+$100	;$460
B_SCR = $72880+$100	;$B80
B_SCR2= $73480+$100	;$B80


S:	JSR	S_MAKE
	MOVE.L	#$DFEFFF,A5
	JSR	S_INIT
	JSR	Z_INIT
	JSR	B_INIT
	JSR	S_RUT
	MOVE.L	#COP,$81(A5)
	CLR.W	$89(A5)
	MOVE.W	#$8020,$97(A5)

		JSR	IRQ_SET

	;JSR	TRACK
MAIN:	;MOVE.W	$DFF006,$DFF180
	BTST	#$6,$BFE001
	BNE	MAIN

		JSR	IRQ_CLR

	MOVE.L	#$22F8,$81(A5)
	MOVE.W	#$8020,$97(A5)
	MOVE.W	#$C000,$9B(A5)
	CLR.W	$89(A5)
	CLR.L	D0
RTS:	RTS

;팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎

OLDIRQ:	DC.L	$0
OLDENA:	DC.W	$0

IRQ_SET:MOVE.W	$DFF01C,D0
	OR.W	#$C000,D0
	MOVE.W	D0,OLDENA
	MOVE.W	#$7FFF,$DFF09A
	MOVE.W	#$040F,$DFF096
	MOVE.L	#$3E8,D0
	MOVE.B	#$00,$BFDE00
	MOVE.B	D0,$BFD400
	LSR.L	#$8,D0
	MOVE.B	D0,$BFD500
	MOVE.B	#$81,$BFDD00
	MOVE.B	#$11,$BFDE00
	MOVE.L	$78.W,OLDIRQ
	MOVE.L	#MYINT,$78.W
	MOVE.W	#$83C0,$DFF096
	MOVE.W	#$E000,$DFF09A
	RTS

IRQ_CLR:MOVE.W	#$7FFF,$DFF09A
	MOVE.L	OLDIRQ,$78.W
	MOVE.W	OLDENA,$DFF09A
	RTS

MYINT:	AND.W	#$20,$DFF01E
	BEQ.S	NOINT
	MOVEM.L	A0-A6/D0-D7,-(A7)

;MOVE.W	#$408,$DFF180
EVER:	CMP.B	#$1A,$DFF006
	BNE	EVER
	MOVE.W	#$0020,$DFF096
	BSR	LACE
	BSR	S_RUT
	MOVE.W	#$8020,$DFF096
	BSR	Z_RUT
	BSR	B_RUT
;MOVE.W	#$222,$DFF180

ENDINT:	MOVE.B	$BFDD00,D0
	MOVE.W	#$2020,$DFF09C
	MOVEM.L	(A7)+,A0-A6/D0-D7
	RTE

NOINT:	TST.B	$BFDD00
	MOVE.W	#$2000,$DFF09C
	RTE

;팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎

B_INIT:	MOVE.L	#B_SCR,A0
	MOVE.W	#[46*$40],D7
B_LOP:	CLR.B	(A0)+
	DBF	D7,B_LOP
	MOVE.L	#B_SCR2,A0
	MOVE.W	#[46*$40],D7
B_LOP2:	CLR.B	(A0)+
	DBF	D7,B_LOP2
	RTS

B_RUT:	BTST	#14,$DFF002
	BNE	B_RUT
	CLR.W	$DFF066
	MOVE.L	#$01000000,$DFF040
	MOVE.L	#B_SCR,$DFF054
	MOVE.W	#[$40*$40]+[46/2],$DFF058

B_WAIT:	BTST	#14,$DFF002
	BNE	B_WAIT
	MOVE.L	#B_SCR2,$DFF054
	MOVE.W	#[$40*$40]+[46/2],$DFF058

	MOVE.B	B_SID,D0
	AND.B	#$F,D0
	MOVE.B	D0,D1
	ASL.B	#$4,D1
	EOR.B	D1,D0
	MOVE.B	D0,B_SIDCOP+$3

ADD.B	#$FE,B_SINPOS
B_SINADD = $10

	MOVE.L	#B_BOBTEXT,A0
	MOVE.L	#SIN,A1
	MOVE.W	#22,D7
	MOVE.L	#B_SCR,D6
	CLR.L	D5
	MOVE.B	B_SINPOS,D5
	ADD.B	B_SID,D5
	AND.W	#$FF,D5

B_BLIT:	BTST	#14,$DFF002
	BNE	B_BLIT
	MOVE.L	#-1,$DFF044
	MOVE.W	#$20-2,$DFF064
	MOVE.W	#46-2,$DFF066
	MOVE.L	#$09F00000,$DFF040

B_BLOP:	BTST	#14,$DFF002
	BNE	B_BLOP
	MOVE.L	(A0)+,D2
	MOVE.L	D2,$DFF050	;BOBTEXT
	CLR.W	D0
	MOVE.B	(A1,D5.W),D0	;A1=SIN
	MULU	#46,D0
	ADD.L	D6,D0		;B_SCR
	MOVE.L	D0,$DFF054
	MOVE.W	#[$10*$40]+1,$DFF058

B_CLOP:	BTST	#14,$DFF002
	BNE	B_CLOP
	ADD.L	#$800,D2
	MOVE.L	D2,$DFF050
	ADD.L	#B_SCR2-B_SCR,D0
	MOVE.L	D0,$DFF054
	MOVE.W	#[$10*$40]+1,$DFF058

	ADD.B	#B_SINADD,D5	;SINPOS
	ADD.L	#$2,D6	;B_SCR
	DBF	D7,B_BLOP

	SUB.B	#$2,B_SID
	AND.B	#$F,B_SID
	CMP.B	#$E,B_SID
	BNE	RTS

	MOVE.L	#B_BOBTEXT,A0
	MOVE.W	#22,D7
B_LOP3:	MOVE.L	4(A0),(A0)+
	DBF	D7,B_LOP3

B_HEJ:	MOVE.L	B_POI,A0
	MOVE.B	(A0)+,D0
	CMP.B	#$FF,D0
	BNE	B_CON
MOVE.L	#B_TEXT,B_POI
BRA.S	B_HEJ

B_CON:	MOVE.L	A0,B_POI
	JSR	S_LOCATE
	MOVE.L	D0,B_BOBTEXT+[23*4]
	RTS

B_BOBTEXT:	BLK.L	24,FONT+$400
B_SID:		DC.B $02
B_SINPOS:	DC.B $00
B_POI:		DC.L B_TEXT

B_TEXT:	DC.B 'YIEEEAAAHO!       .... (EH?)      ... ANYWAY! '
DC.B '  WELCOME TO FUNNY, A DEMO MADE BY MAHONEY & KAKTUS IN SUMMER'
DC.B ' 1988.     THIS WAS SUPPOSED TO BE ON MEGADEMO III, BUT'
DC.B ' BECAUSE OF SOME STRANGE REASON, IT DIDN"T FIT ...    ('
DC.B 'MAYBE BECAUSE IT WASN"T CRUNCHED???)      //////   IS THERE'
DC.B ' ANYTHING MORE TO SAY?     YES, OFCOZ!     SCROLLS ARE MENT'
DC.B ' TO BE LONG ...        SORRY FOR NO MUSIC IN THIS INTRO, BUT'
DC.B ' WE"VE KEPT ALL OUR NEW TUNES TO OUR NEXT MUSIC-DISK:  '
DC.B ' >SOUNDS OF GNOMIC<       PROBABLY RELEASED BEFORE'
DC.B ' THIS MEGADEMO, I HOPE ...       @@@@@@@@@@@ '
DC.B '     WHAT MORE?     ANOTHER LOVE-STORY (HEJSAN KAKTUS!)'
DC.B '    HOW ABOUT 300 MIDI-INTERFACES IN THE FRIDGE??? '
DC.B '   OR MAYBE 45 EXTRA-DRIVES???      /////////////'
DC.B '       HERE IT COMES ...    THE HYPER-TURBO-GOLDEN-XL-'
DC.B 'ALPHABETIC-PERSONAL-SPLENDID-2000-NONSTOP-SPECIAL-'
DC.B 'GREETING-WORD:        HEJ!           # # # # # # # #'
DC.B '  LIFE IS HARD, I KNOW ...     TALKING ABOUT HI-TEC (HEJ'
DC.B ' FAIRLIGHT!)     THIS IS THE LOADING SCREEN TO THE MUSIC-'
DC.B 'DISK.    I KNOW THIS LOOKS SIMPLE (AND IT IS SIMPLE)'
DC.B ' BUT I DIDN"T WANT THE CRUNCHER TO WORK IN HALF AN HOUR'
DC.B ' WITH THE INSTRUMENTS ...    WITHOUT LOADING (AND CRUNCHING)'
DC.B ' I COULD HAVE ABOUT 5 MORE SCROLLS LIKE THIS ONE ...  '
DC.B '       OK?       "NUFF OF THAT!       INTERRUPT NO.6 IS NICE!'
DC.B '    OH! BUT LOOK AT YOUR MOUSE-POINTER ...   IS IT A DEVIL"S'
DC.B ' JOKE (#) ???        HAHAHA!    HARD WORK, I"VE HEARD THAT'
DC.B ' D.H. HAS BEEN TRYING TO CRACK IT FOR TWO WEEKS NOW ...  '
DC.B '   NOT ADVANCED, BUT ALIEN???     THE FUTURE IS SO BRIGHT,'
DC.B ' I JUST HAVE TO STAY INDOORS TO KEEP ME AWAY FROM BEING A'
DC.B ' "NEGER" ...    WHAT ABOUT SUN-GLASSES?    AND 168 KB'
DC.B ' SOUNDTRACKER-MUSIC?     OR MAYBE A GREEN DF1:     '
DC.B '  OPEN 5,8,15,"N0:HEJ,00"      REMEMBER:  WHAT DID YOU DO'
DC.B ' FOR GOD TODAY?     ++++++++++++       DO YOU SPEAK ENGLISH?'
DC.B '       N\\\, JA SPIKAR L[DOR ...     OH, YES!     N\\\,'
DC.B ' TILL H]NS ...      # # # # # DEN VAR D[LIG!!!!      '
DC.B '    NOP (NO OPERATION) HERE"S MAHONEY & KAKTUS FADING AWAY'
DC.B ' INTO THE DARK SPACE ...       BLEURGH!             '
	DC.B $FF
EVEN

;팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎

Z_INIT:	MOVE.L	#Z_SCR,A0
	MOVE.W	#46*16,D7
Z_LOP:	CLR.B	(A0)+
	DBF	D7,Z_LOP
	MOVE.L	#Z_SCR2,A0
	MOVE.W	#46*16,D7
Z_LOP2:	CLR.B	(A0)+
	DBF	D7,Z_LOP2
Z_RTS:	RTS

Z_LOC:	DC.B	$00,$00
Z_POI:	DC.L	Z_TEXT

Z_TEXT:	DC.B	'- ORTNIYNNUF - '
	DC.B	'SUTKAK & YENOHAM - RATSHTRON ',$FF
EVEN

Z_RUT:	ADD.B	#$1,Z_LOC
		MOVE.B	Z_LOC,D0
		ADD.B	#$1,D0
		AND.B	#$F,D0
		MOVE.B	D0,D1
		ASL.B	#$4,D1
		EOR.B	D1,D0
		MOVE.B	D0,Z_SIDCOP+$3
			MOVE.B	Z_LOC,D0
			AND.B	#$F,D0
			MOVE.B	D0,D1
			ASL.B	#$4,D1
			EOR.B	D1,D0
			MOVE.B	D0,Z_SIDCOP2+$3
	CMP.B	#$10,Z_LOC
	BNE.L	Z_RTS

	MOVE.B	#$0,Z_LOC
Z_BLTWAIT:
	BTST	#14,$DFF002
	BNE	Z_BLTWAIT

	MOVE.L	#-1,$DFF044
	MOVE.L	#Z_SCR,$DFF050
	MOVE.L	#Z_SCR+2,$DFF054
	CLR.L	$DFF064
	MOVE.L	#$09F00000,$DFF040
	MOVE.W	#[$10*$40]+[46/2],$DFF058

Z_BLT2:	BTST	#14,$DFF002
	BNE	Z_BLT2

	MOVE.L	#Z_SCR2,$DFF050
	MOVE.L	#Z_SCR2+2,$DFF054
	MOVE.W	#[$10*$40]+[46/2],$DFF058

Z_BLT3:	BTST	#14,$DFF002
	BNE	Z_BLT3

Z_HEJ:	MOVE.L	Z_POI,A0
	MOVE.B	(A0)+,D0
	CMP.B	#$FF,D0
	BNE	Z_CON
MOVE.L	#Z_TEXT,Z_POI
BRA.S	Z_HEJ

Z_CON:	MOVE.L	A0,Z_POI
	BSR	S_LOCATE
	MOVE.L	D0,A0
	MOVE.L	#Z_SCR,A1
	MOVE.W	#$F,D7

Z_LOP5:	MOVE.W	(A0),(A1)
	MOVE.W	$800(A0),$480(A1)	;Z_SCR2-Z_SCR
	ADD.L	#$20,A0
	ADD.L	#46,A1
	DBF	D7,Z_LOP5
	RTS

;팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎

S_CHAR:
DC.W	$000,$002,$004,$006,$008,$00A,$00C,$00E
DC.W	$010,$012,$014,$016,$018,$01A,$01C,$01E
DC.W	$200,$202,$204,$206,$208,$20A,$20C,$20E
DC.W	$210,$212,$214,$216,$218,$21A,$21C,$21E
DC.W	$400,$402,$404,$406,$408,$40A,$40C,$40E
DC.W	$410,$412,$414,$416,$418,$41A,$41C,$41E
DC.W	$600,$602,$604,$606,$608,$60A,$60C,$60E
DC.W	$610,$612,$614,$616,$618,$61A,$61C,$61E

S_LOCATE:
	AND.L	#$003F,D0
	ASL.W	#$1,D0
	AND.L	#$007E,D0
	MOVE.L	#S_CHAR,A0
	MOVE.W	(A0,D0.W),D0
	ADD.L	#FONT,D0
	RTS

SPRTEXT:DC.B	'MAHONEY & KAKTUS'

S_MAKE:	MOVE.W	#[$88*8]+3,D7
	MOVE.L	#SPR,A0
S_G:	CLR.B	(A0)+
	DBF	D7,S_G

	MOVE.L	#SPRTEXT,A1
	MOVE.L	#SPR+4,A2
	MOVE.W	#$7,D7

S_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R.L	D4
	MOVE.W	#$7,D7

S_LOP2:	MOVE.B	D5,(A0)
	MOVE.B	D5,D4
	ADD.B	#$11,D4
	MOVE.B	D4,2(A0)
	CLR.B	3(A0)

	MOVE.B	(A1,D0),D4
	ADD.B	D6,D4
	LSR.B	#$1,D4
	BCC	S_5
	MOVE.B	#$1,3(A0)
S_5:	ADD.B	#XSCR,D4
	MOVE.B	D4,1(A0)

	ADD.B	SINADD,D0	;SINADD
	AND.B	#$3F,D0
	ADD.B	#XADD,D6	;XPOSADD
	ADD.B	#YADD,D5	;YPOSADD
	ADD.L	#$88,A0
	DBF	D7,S_LOP2

	ADD.B	#$1,S_POI
	AND.B	#$3F,S_POI
	RTS

;팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎

THE_SIN:

DC.B 0,0,0,0,1,1,1,2,2,3,4,5,7,9,12,15
DC.B 18,21,23,25,27,28,29,30,30,31,31,31,32,32,32,32
DC.B 32,32,32,32,31,31,31,30,30,29,28,27,25,23,21,18
DC.B 15,12,9,7,5,4,3,2,2,1,1,1,0,0,0,0
DC.B $FF,$FF,$FF,$FF

;팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎

LACE:	BTST	#15,$DFF004
	BEQ.S	L_1

	MOVE.L	#HEAD4,D0
	BRA.S	L_C
L_1:	MOVE.L	#HEAD4+10,D0

L_C:	MOVE.W	D0,PL_1+6
	ADD.W	#720,D0
	MOVE.W	D0,PL_2+6
	ADD.W	#720,D0
	MOVE.W	D0,PL_3+6
	ADD.W	#720,D0
	MOVE.W	D0,PL_4+6
	ADD.W	#720,D0
	RTS

;팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎

COP:	DC.W	$0100,$2000,$0104,$003F
	DC.W	$0108,$0002,$010A,$0002
	DC.W	$008E,$3874,$0090,$B2C2,$0092,$0028,$0094,$00D0

DC.W	$0180,$0004,$0182,$03F,$0184,$02C,$0186,$018

DC.W	$00E0,Z_SCR/$10000,$00E2,Z_SCR+2
DC.W	$00E4,Z_SCR2/$10000,$00E6,Z_SCR2+2
Z_SIDCOP:	DC.W	$0102,$0000

DC.W 	$01A0,$000,$01A2,$4F7,$01A4,$3C5,$01A6,$263
DC.W 	$01A8,$000,$01AA,$4F7,$01AC,$3C5,$01AE,$263
DC.W 	$01B0,$000,$01B2,$4F7,$01B4,$3C5,$01B6,$263
DC.W 	$01B8,$000,$01BA,$4F7,$01BC,$3C5,$01BE,$263

SPR1:	DC.W	$0120,SPR/$10000,$0122,SPR
	DC.W	$0124,SPR/$10000,$0126,SPR+[$88*1]
	DC.W	$0128,SPR/$10000,$012A,SPR+[$88*2]
	DC.W	$012C,SPR/$10000,$012E,SPR+[$88*3]
	DC.W	$0130,SPR/$10000,$0132,SPR+[$88*4]
	DC.W	$0134,SPR/$10000,$0136,SPR+[$88*5]
	DC.W	$0138,SPR/$10000,$013A,SPR+[$88*6]
	DC.W	$013C,SPR/$10000,$013E,SPR+[$88*7]

DC.W	$4811,$FFFE,$0100,$0000

DC.W	$5011,$FFFE,$0100,$1000,$0092,$0038,$0094,$0040
DC.W	$0180,$008,$0182,$008
DC.W	$5111,$FFFE,$0180,$00C,$0182,$00C
DC.W	$5211,$FFFE,$0180,$008,$0182,$008
DC.W	$5311,$FFFE,$0180,$004,$0182,$004
DC.W	$5411,$FFFE,$0180,$000,$0182,$000

DC.W	$8E11,$FFFE

	DC.W	$0100,$0004,$0102,$0000
	DC.W	$0108,$FFFE+10,$010A,$FFFE+10
	DC.W	$008E,$9071,$0090,$B431,$0092,$0080,$0094,$0090

PL_1:	DC.W	$00E0,$0006,$00E2,$0000
PL_2:	DC.W	$00E4,$0006,$00E6,$0000+720
PL_3:	DC.W	$00E8,$0006,$00EA,$0000+720*2
PL_4:	DC.W	$00EC,$0006,$00EE,$0000+720*3

DC.W	$0182,$911,$0184,$FA9,$0186,$F98
DC.W 	$0188,$D76,$018A,$400,$018C,$E87,$018E,$300
DC.W 	$0190,$C65,$0192,$B54,$0194,$FBA,$0196,$A43
DC.W 	$0198,$610,$019A,$932,$019C,$721,$019E,$FCB

	DC.W	$9111,$FFFE,$0100,$C004

;********************* B_RUT
DC.W	$B611,$FFFE
	DC.W	$0100,$2004
	DC.W	$0108,$0002,$010A,$0002
	DC.W	$008E,$B774,$0090,$F7C2,$0092,$0028,$0094,$00D0
DC.W	$00E0,B_SCR/$10000,$00E2,B_SCR+2
DC.W	$00E4,B_SCR2/$10000,$00E6,B_SCR2+2
DC.W	$0182,$CCC,$0184,$999,$0186,$555
B_SIDCOP:	DC.W	$0102,$0000
;********************

DC.W	$F811,$FFFE,$0180,$004,$0182,$004
DC.W	$F911,$FFFE,$0180,$008,$0182,$008
DC.W	$FA11,$FFFE,$0180,$00C,$0182,$00C
DC.W	$FB11,$FFFE,$0180,$008,$0182,$008
DC.W	$FC11,$FFFE,$0180,$004,$0182,$004

DC.W	$008E,$FF74,$0090,$16C2,$0092,$0028,$0094,$00D0
DC.W	$0100,$0004,$0104,$003F,$0108,$0002,$010A,$0002
DC.W	$0180,$0004,$0182,$03F,$0184,$02C,$0186,$018

DC.W	$00E0,Z_SCR/$10000,$00E2,Z_SCR+2
DC.W	$00E4,Z_SCR2/$10000,$00E6,Z_SCR2+2
Z_SIDCOP2:	DC.W	$0102,$0000

DC.W	$FFE1,$FFFE,$0611,$FFFE,$0100,$2004

	DC.L	$FFFFFFFE



;팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎팎
