
;Hello there!

;This is the source to recieve pictures from MIDI.
;I'm sorry that it's a bit spaghetti, but I couldn't improve it
;because I haven"t got the stuff at home to test my new version.
;This source works 100%, and I think that's the best way.

;Don"t worry if you can"t understand one word of this source, because
;it was made after 34 sleepless hours on a meeting.
;I'll try to explain as much as I can.

;Assemble it, and then jump to the label START.

STARTMEMPOS=$60000	;Where to lay the picture-data

ORG	$30000
LOAD	$30000

P_POI:	DC.L	STARTMEMPOS	;counter for the data

START:	LEA	SUPERVISORMODE,A1	;enter supervisormode
	MOVE.L	A1,$80
	TRAP	#0
	OR.W	#%0000011100000000,SR	;DISABLE INT
	MOVE.W	#$C800,$dff09a
	MOVE.W	#110,$dff032	;31250 BPS - the speed for MIDI
	MOVE.W	#$0800,$dff09c
	MOVE.W	#$0020,$DFF096	;Disable sprites
	MOVE.L	#COP,$DFF080	;Set copper

LO:	JSR	READMI	;read byte
	CMP.B	#$FF,D0	;controlbyte?
	BNE	LO	;no - go back

;************ move colours to copperlist
	MOVE.L	#COLOURS+$2,A5
	MOVE.W	#$F,D7

LOUP:	JSR	READMI
	ASL.B	#$1,D0
	MOVE.B	D0,(A5)
	JSR	READMI
	ASL.B	#$1,D0
	MOVE.B	D0,1(A5)
	ADD.L	#$4,A5
	DBF	D7,LOUP

;*********** Read bitplanedata

WAIT:	BTST	#14,$dff018	;wait until buffer full
	BEQ.S	WAIT
	MOVE.W	$dff018,D0	;read byte
	BSR	PRINT		;move data
	MOVE.W	#$0800,$dff09c
	BRA.S	WAIT		;loop forever

;*************** Read byte to reg D0

READMI:	BTST	#14,$dff018	;buffer full?
	BEQ.S	READMI		;no - go back
	MOVE.W	$dff018,D0	;read byte
	MOVE.W	#$0800,$dff09c
	RTS

;************* Move byte to bitplanes

PRINT:	MOVE.L	P_POI,A0	;pointer to A0
	MOVE.B	D0,(A0)+	;move byte
	MOVE.L	A0,P_POI	;A0 to pointer
	MOVE.B	D0,$DFF180	;flicker screen
	RTS

SUPERVISORMODE:
	ADDQ	#2,SP
	RTS

COP:	;set to normal Amiga-screen (almost!)
DC.W $0100,$4000,$0102,$0000,$0104,$0000
DC.W $0108,$0000,$010A,$0000
DC.W $008E,$3081,$0090,$F8C1,$0092,$0038,$0094,$00D0

COLOURS:
DC.W $0180,$000,$0182,$FFF,$0184,$EEE,$0186,$DDD
DC.W $0188,$CCC,$018A,$BBB,$018C,$AAA,$018E,$999
DC.W $0190,$888,$0192,$777,$0194,$666,$0196,$555
DC.W $0198,$444,$019A,$333,$019C,$222,$019E,$111

;Set all bitplanepointers
DC.W $00E0,STARTMEMPOS/$10000,$00E2,STARTMEMPOS
DC.W $00E4,STARTMEMPOS/$10000,$00E6,STARTMEMPOS+$1F40
DC.W $00E8,STARTMEMPOS/$10000,$00EA,STARTMEMPOS+[$1F40*2]
DC.W $00EC,STARTMEMPOS/$10000,$00EE,STARTMEMPOS+[$1F40*3]

DC.L $FFFFFFFE


;This is the end. The program won't return to Seka, so if you want
;to save the picture, do like this:
;1. reset the computer.
;2. enter seka again, with 0kb workspace.
;3. save the memory (WI) between STARTMEMPOS ($60000)
;			to STARTMEMPOS+32000 ($67d00)
;4. load the raw picture into a converter.

;If you have got a program to rip pictures (such as graphics-searcher)
;use that instead. It's much more comfortable.

;Signed >- MAHONEY & KAKTUS FOR NORTHSTAR -<

