		Section	Hamster_Bit_of_Code,code

ScreenWidth	EQU	640
ScreenBytes	EQU	ScreenWidth/8
ScreenLines	EQU	256
Forbid		EQU	-$84
Permit		EQU	-$8A


****************************************************************************
*                                                                          *
****************************************************************************

Start		movem.l d0-a6,-(a7)
		movea.l $4,a6
		jsr     Forbid(a6)
		lea     $dff000,a0
		move.w  $dff002,System_DMA		;DMACon_Read
		bset    #$f,System_DMA
		move.l  #copper,$dff080			;CopperList
		move.l	#Sound,$dff0A0 ; AUD0LCH
		move.w	#SoundLen,$dff0A4 ; aud0len
		move.w	#$109,$dff0A6 ; aud0period
		move.w	#$63,$dff0A8 ; audvol!
		move.l	#Sound2,$dff0B0
		move.w	#Sound2len,$dff0b4
		move.w	#$379,$dff0b6
		move.w	#$20,$dff0b8
		
			; FEDCBA9876543210
		move.w  #%1000000110100011,$dff096	;DMACon
		clr.w   $dff088				;CopperList 1 Strobe
		         ;FEDCBA9876543210
		move.w  #%0000000000100000,$dff104
		bsr.w   bitplanecode			;My Hamster :)
		move.l	#$0101FFFE,d1

****************************************/
***************************************/
**************************************/
*************************************|     Main Program Follows
**************************************\
***************************************\
****************************************\


Starter		move.l  #50,Delay
;		bsr.b	Pause
;		bsr.w	VBG
;		bsr.w	ScrollUp
;		bsr.b	pause
;		bsr.w   ScrollDown_Back
;		bsr.b	pause
		;move.l	#1000,d6 ; LAME TIMED LOOP! ;-(
		
Looping_For_Luck
		bsr.w	VBG
;		bsr.b	Ripper
		dbra	d6,Looping_For_Luck
		
		bsr	VBG
	;	bsr	VBG
	;	bsr     Blue_Blast
	;	bsr	VBG
	;	bsr	VBG
	;	
EndLoop		bsr.w	VBG
		bsr.w	ColRipper
		add.w	#1,Counter2
		cmp	#127,Counter2
		beq	Set_Tog
		
Here
		btst	#6,$bfe001
		beq.w	ShutDown
		bra.b	EndLoop

Set_Tog	
	move.l	#0,Counter2
	move.l	#100,delay
	move.l	#$FFF,$Dff180
	bsr	pause
	bra     Here


***********************************************************************
*                   Mouse Check For User Input                        *
***********************************************************************

MouseCheck	btst	#6,$bfe001      ;)   
		beq.w	ShutDown        ;)     Mouse Check Loop!
		rts


**************************************************************************
*		Pause Routine For All Sorts Of Pauses                    *
**************************************************************************

Pause:
        	move.l	Delay,d0
Vblank_Loop	bsr.w	VBG
		dbra	d0,Vblank_Loop
		rts

****************************************************************************
*              Main Rippler Routine.. Needs Some Work!                     *
****************************************************************************

Ripper  	lea	Space,a0 
		lea	Sine,a1
		move.w	#256,D0		 ;counter
		add.l   #$01000000,d1
Add_Wait	move.l	d1,(a0)+	 ;move Wait into copper
		move.w  #$102,(a0)+
		move.b	#$00,(a0)+
		move.b	(a1)+,(a0)+
		add.l   #$01000000,d1
		add.b	#1,d2
		dbra	d0,Add_Wait
		rts

ColRipper	lea	Space,a0
		lea	Sine,a1
		move.w	#256,d0
		add.l	#$01000000,d1
Add_Waiting	move.l	d1,(a0)+
		move.w	#$102,(a0)+
		move.b	#$00,(a0)+
		move.b  (a1)+,(a0)+
		move.w  #$192,(a0)+
		move.w  (a1),(a0)+
		add.l   #$01000000,d1
		add.b   #1,d2
		dbra    d0,Add_Waiting
		rts
		

***************************************************************************
*                    Exit Code To Get The Hell Outa here!		  *
***************************************************************************

ShutDown	;bsr.w   ScrollUp_Back
		;bsr.b     Pause
		;bsr.w   ScrollDown
		;bsr.w     Pause
		lea	$dff000,a0
		move.l	$4,a6
		
		movea.l	$9c(a6),a1	;]    
		move.w	#$7fff,$dff096	;]       Get Back The OLD
		move.l	$26(a1),$dff080	;]      System Copper List
		clr.w	$dff088		;]		
		move.w	System_DMA,$dff096
		jsr	Permit(a6)
		movem.l	(a7)+,d0-a6
		moveq.l	#$00,d0
		RTS			; End of Logical Program

****************************************************************************
*                   Anyone Seen A VBLANK Around Here?                      *
****************************************************************************

VBG             and.w   #$20,$dff01e
                beq.b     VBG
                rts
                
****************************************************************************
*                     Bit Plane Set-up Hamster                             *
****************************************************************************

BitPlaneCode	move.l	#BitPlanes,a0
		move.l	#Screen1,d0
		move.l	#Screen2,d5
		move.l	#7,d1                    ;SET THIS RIGHT!!
PlaneLoop	move.w	d0,6(a0)                 ; IMPORTANT!!!
		swap	d0
		move.w	d0,2(a0)
		addq	#8,a0
		move.w	d5,6(a0)
		swap	d5
		move.w	d5,2(a0)
		addq	#8,a0
		swap	d5
		swap	d0
		add.l  	#20480,d0 
		add.l	#20480,d5
		dbra	d1,PlaneLoop
		rts


****************************************************************************
*                        Scroll Screen Effect                              *
****************************************************************************

Blue_Blast
		move.l	#01,delay
		lea	Colours,a0
		bsr	VBG
		move.w	#$001,6(a0)
		bsr	pause
		move.w  #$004,6(a0)
		bsr	pause
		move.w  #$008,6(a0)
		bsr	pause
		move.w  #$00A,6(a0)
		bsr	pause
		move.w  #$00F,6(a0)
		bsr	pause
		move.w	#$FFF,6(a0)
		bsr	pause
		move.w	#$888,6(a0)
		move.l	#01,delay
		bsr	pause
		move.w	#$000,6(a0)
		move.l	#50,delay
		rts

ScrollUP	move.w	#255,d0
lp		move.l	#BitPlanes,a0	
		bsr.w   VBG
		add.w	#80,6(a0)
		dbra	d0,lp
		rts

ScrollDown      move.w  #255,d0
lp2             move.l  #BitPlanes,a0
                bsr.w   VBG
                sub.w   #80,6(a0)
                dbra    d0,lp2
                rts

ScrollUP_Back   move.w  #255,d0
lp3             move.l  #BitPlanes,a0
		addq	#8,a0
                bsr.w   VBG
                add.w   #80,6(a0)
                dbra    d0,lp3
                rts

ScrollDown_Back move.w  #255,d0
lp4             move.l  #BitPlanes,a0
		addq	#8,a0
                bsr.w   VBG
                sub.w   #80,6(a0)
                dbra    d0,lp4
                rts



;FadeColour	move.l	#Colours,a0
;		move.w	#16,d0
;lp3		add.w	#$111,6(a0)
;		dbra	d0,lp3
;		rts
		
****************************************************************************
*                    Everythings DATA From Now On.			   *
****************************************************************************

		Section Buffers,Data
		
System_DMA	dc.w	0
Delay		dc.l	0
Counter		dc.w	0
Counter2	dc.w	0
Toggle		dc.b	0
		dc.b	0
Siner		include sources:sine.asm ; My Sine Table
		
		Section	Copper_List,Data_C
		
Copper	        dc.l	$01200000,$01220000
		dc.l    $01240000,$01260000,$01280000,$012a0000
 		dc.l    $012c0000,$012e0000,$01300000,$01320000
 		dc.l	$01340000,$01360000,$013c0000,$013e0000
 		dc.l    $01400000,$01420000,$01440000,$01460000
 		dc.l    $01480000,$014a0000,$014c0000,$014e0000
 		dc.l    $01500000,$01520000,$01540000,$01560000
 		dc.l    $01580000,$015a0000,$015c0000,$015e0000
 		dc.l    $01600000,$01620000,$01640000,$01660000
 		dc.l    $01680000,$016a0000,$016c0000,$016e0000
  		dc.l	$01700000,$01720000,$01740000,$01760000
  		dc.l	$01780000,$017A0000,$017c0000,$017e0000
; 
	

			      ;FEDCBA9876543210
		dc.w	$0100,%1010010000000000 ;bplcon1
		dc.w	$0102,$0000		;bplcon2
		dc.w	$0104,$0024		;bplcon3
		dc.w    $008e,$2c41		;Diwstrt
		dc.w    $0090,$2cc1		;Diwstop
		dc.w    $0092,$0038		;Ddfstrt
		dc.w    $0094,$00d0		;Ddfstop
		              ;FEDCBA09876543210
		dc.w    $0104,%00000000000000000
		
		dc.w	$01fc,%00000000000000101  ;Fmode


		dc.w	$0108,0		;Odd Mod.
		dc.w	$010a,0		;Even Mod.
		
Colours         dc.l    $01800000,$01820FFF
		dc.l    $01840222,$01860333
		dc.l    $01880333,$018A0444
		dc.l    $018C0444,$018E0555
		
		dc.l    $01a00555,$01a20666
		dc.l    $01a40777,$01a60777
		dc.l    $01a80888,$01aA0888
		dc.l    $01aC0000,$01aE0999
		
		dc.l    $01900000,$01920FFF
		dc.l    $01940222,$01960333
		dc.l    $01980333,$019A0444
		dc.l    $019C0444,$019E0555

		dc.l    $01b00555,$01b20666
		dc.l    $01b40777,$01b60777
		dc.l    $01b80888,$01bA0888
		dc.l    $01bC0000,$01bE0999
		
;01800999 01820000 01840888 01860888
;01880777 018A0777 018C0666 018E0555
;01900555 01920444 01940444 01960333
;01980333 019A0222 019C0222 019E0111

		;01800111 01820111 01840111 01860222
		;01880222 018A0333 018C0333 018E0444
		;01900555 01920555 01940666 01960777
		;01980777 019A0888 019C0888 019E0999
			

BitPlanes	dc.l    $00e00000,$00e20000  ;Plane 1
		dc.l    $00e40000,$00e60000  ;Plane 2
		dc.l    $00e80000,$00ea0000  ;Plane 3
		dc.l    $00ec0000,$00ee0000  ;Plane 4
		dc.l    $00f00000,$00f20000  ;Plane 5
		dc.l	$00F40000,$00F60000  ;Plane 6
		dc.l	$00f80000,$00fa0000  ;Plane 7
		dc.l	$00fc0000,$00fe0000  ;Plane 8
		
;		DC.W    $F0E1,$FFFE  ;
;		dc.w	$108,-320    ;  Quick And Dirty Reflection
;		dc.w	$10a,-320    ;
Space           ds.l    60240 ; 340K.... BLOODY HELL!!!

		dc.w	$FFFF,$FFFE



****************************************************************************
*               Screens And Sprites, And Bits and Bytes                    *
****************************************************************************


		Section Screens,Data_C
		
		;cnop	0,8 ;Lets Align The BitMap Correctly!

Screen0		ds.b	80*256
Screen1		incbin	raws:front.Raw
Screen2		incbin	raws:back.raw
Screen3		ds.b	80*256
		
Sound		incbin	raws:grid
SoundLen        equ     (*-Sound)>>1

Sound2		incbin	ram:wave
sound2len	equ	(*-Sound2)>>1
