3D Stars Trainer Menu


My first attempt at 3D projection... 3D balls coming towards you.

This is really nasty coding, no signed values were used so I did

each quadrant separately. This meant no rotation could be done

but this also allowed smoother movement. The effect really works

well, I think. So far this menu had been used only once. That was 

3 months ago, I doubt I'll use it again soon.





	heap	O=512k			;max 128k object buffer                
	size	8			;4 32kblocks                          
                                                                                  
	SMC+				;yes, we want a smc header            
	lrom				;yes, please split in 32k hunks 
      
starmap         equ     $1400
planeflip	equ	$10
joydata		equ	planeflip+2
storage1	equ	joydata+2
storage2	equ	storage1+2
storage3	equ	storage2+2
starcount	equ	storage3+2
menuscroll	equ	starcount+2
menutimer	equ	menuscroll+2
menumotion	equ	menutimer+2
menudirection	equ	menumotion+2
menuoffset	equ	menudirection+2
currentline	equ	menuoffset+2
numconv		equ	currentline+2
low2		equ	numconv+2
low1		equ	low2+2
low0		equ	low1+2
high6		equ	low0+2
high5		equ	high6+2
high4		equ	high5+2
hundreds	equ	high4+2
ones		equ	hundreds+2
tens		equ	ones+2
numbertimer	equ	tens+2
bottomtimer	equ	numbertimer+2
bottomfadeon	equ	bottomtimer+2
bottomoffset	equ	bottomfadeon+2
csh0		equ	bottomoffset+2
ssh4		equ	csh0+2
cst2		equ	ssh4+2
sst6		equ	cst2+2
sms8		equ	sst6+2
ssa		equ	sms8+2
scs		equ	ssa+2
lineval1	equ	scs+2
lineval2	equ	lineval1+2
lineval3	equ	lineval2+2
lineval4	equ	lineval3+2
scrollval	equ	lineval4+2
scrolltext	equ	scrollval+2
scrollcount	equ	scrolltext+2
scrollcol	equ	scrollcount+2
sineoffsetx	equ	scrollcol+2
sineoffsety	equ	sineoffsetx+2
sinetimer	equ	sineoffsety+2
storage4	equ	sinetimer+2
textoff		equ	storage4+2
flipflop	equ	textoff+2
texttimer	equ	flipflop+2
textoffset	equ	texttimer+2
toggle		equ	textoffset+2



UnpackBuffr     EQU     $7f0000
Buff2	EQU	$000200	; 24-bit address of $1A0 byte buffer
in	EQU	$65
out	EQU	$68
wrkbuf	EQU	$6a
counts	EQU	$6d
blocks	EQU	$4f
bitbufl	EQU	$51
bitbufh	EQU	$43
bufbits	EQU	$55
bitlen	EQU	$57
hufcde	EQU	$59
hufbse	EQU	$5b
temp1	EQU	$5d
temp2	EQU	$5f
temp3	EQU	$61
temp4	EQU	$63
tmptab	EQU	0	; indexed from Buff2
rawtab	EQU	$20	; indexed from Buff2
postab	EQU	$a0	; indexed from Buff2
slntab	EQU	$120	; indexed from Buff2


;==========================================================================
;      Code (c) 1995 -Pan-/ANTHROX   All code can be used at will!
;==========================================================================                     

	;jmp	Slow
	;jmp	Cheat
	jmp	IRQ  
	;jmp	LEVEL

Start:
	

	phk			; Put current bank on stack
	plb			; make it current programming bank
				; if this program were used as an intro
				; and it was located at bank $20 then an
				; LDA $8000 would actually read from
				; $008000 if it were not changed!
				; JSRs and JMPs work fine, but LDAs do not! 
	clc			; Clear Carry flag
	xce			; Native 16 bit mode  (no 6502 Emulation!) 
;==========================================================================
	
	sep	#$30
	stz	$212c
	lda	#$0f
	sta	$2100




	rep	#$10
	sep	#$20
	ldx	#music		; CRUNCHED FILE
	stx	$65
	phk
	pla
	;lda	#^Picture1		; CRUNCHED FILE BANK
	sta	$67
	ldx	#UnpackBuffr		; LOW WORD UNPACK BUFFER
	stx	$68
	lda	#^UnpackBuffr		; UNPACK BUFFER BANK
	pha
	plb
	jsr	UNPACK				;Requires A[8] XY[16]

	phk
	plb

	jsr	musique
	

	rep	#$10
	sep	#$20
	ldx	#packedgfx		; CRUNCHED FILE
	stx	$65
	phk
	pla
	;lda	#^Picture1		; CRUNCHED FILE BANK
	sta	$67
	ldx	#UnpackBuffr		; LOW WORD UNPACK BUFFER
	stx	$68
	lda	#^UnpackBuffr		; UNPACK BUFFER BANK
	pha
	plb
	jsr	UNPACK				;Requires A[8] XY[16]

	phk
	plb



	jsr	Snes_Init


	rep	#$30
	sep	#$20
	jsr	Copy_Gfx
	jsr	Make_tiles
	jsr	Copy_colors
	jsr	Sprite_setup
	jsr	Setup_Starmap
	jsr	Option_Setup
	jsr	HDMA


	lda	#$01
	sta	$2105
	
	lda	#$17
	sta	$212c

	lda	#$78
	sta	$2107
	
	lda	#$71
	sta	$2108

	lda	#$58
	sta	$2109

	lda	#$10
	sta	$210b

	lda	#$05
	sta	$210c

	lda	#$01
	sta	$4200


	ldx	#$001e
	stx	starcount

	ldx	#$0000
	stx	menuscroll
	stx	menutimer
	stx	menumotion   
	stx	menudirection
	stx	menuoffset

	ldx	#$0001		; menu's starting currentline
	stx	currentline

	ldx	#$0000
	stx	numbertimer

	ldx	#$0000
	stx	bottomtimer
	stx	bottomfadeon
	stx	bottomoffset
	ldx	#$0001
	stx	csh0
	dex
	stx	ssh4
	stx	cst2
	stx	sst6
	stx	sms8
	stx	ssa 
	stx	scs
	ldx	#$0000
	stx	lineval1
	inx
	inx
	inx
	inx
	stx	lineval2
	inx
	inx
	inx
	inx
	stx	lineval3
	inx
	inx
	inx
	inx
	stx	lineval4

	ldx	#$0180
	stx	scrollval
	lda	#$0010
	stx	scrollcount
 
	ldx	#$0000
	stx	scrolltext

	ldx	#$000f
	stx	scrollcol

	ldx	#$0050
	stx	sineoffsetx
	ldx	#$0000
	stx	sineoffsety
	stx	sinetimer

	ldx	#$003f
	stx	textoff
	ldx	#$0000
	stx	flipflop
	stx	texttimer

	ldx	#$0000
	stx	textoffset
	stx	toggle



	lda	#$0f
	sta	$2100

	jsr	tune

Waitloop:
	jsr	WaitVb
	jsr	joypad

	jsr 	StarDMA
	jsr	buttselect
	jsr	scroll
	jsr	textsquish
	jsr	movemenu

	;lda	#$80
	;sta	$2100

	rep	#$30

	lda	scrollval
	and	#$01ff
	sta	$1f24
	jsr	HDMAwave

	jsr	Movestar



	rep	#$30
	lda	menuscroll
	clc
	adc	#$0086
	sta	$1e28
	sep	#$20
	jsr	atxsine

	;lda	#$0f
	;sta	$2100

	lda	joydata+1
	cmp	#$10
	beq	endintro
	bra	Waitloop


endintro:
	sep	#$20
	jsr	WaitVb
	jsr	Snes_Init
	jsr	tuneoff
	jmp	gameover


;=========================================================================
;                      Squish/Un-Squish 2 lines of text
;=========================================================================
textsquish:


	rep	#$30
	lda	textoffset
	asl a
	asl a
	asl a
	asl a
	asl a
	asl a
	asl a
	clc
	adc	#bottext
	tax

	sep	#$20
	lda	#$01
	sta	$4370
	lda	#$18
	sta	$4371
	stx	$4372	
	phk
	pla
	sta	$4374

	lda	#$0080
	sta	$4375

	ldx	#$5ac0
	stx	$2116

	lda	#$80
	sta	$420b






textcontinue:
	lda	texttimer
	beq	textnostop
	dec	texttimer
	rts


textnostop:

	lda	flipflop
	and	#$01
	bne	textsquishgoing

textsquishcoming:


	lda	textoff		; increase sine offset ($00 - $ff)
	dec a
	and	#$3f
	sta	textoff
	cmp	#$00
	bne	notsstop1
	lda	#$01
	sta	flipflop

	lda	#$ff
	sta	texttimer




notsstop1:



	rep	#$30
	ldx	textoff		; get sine offset
	lda	textsine,x
	and	#$00ff

	sta	storage1		; bottom h pos offset
	stz	storage2		; clear xstorage2 (becomes remainder)
	bra	tscont



textsquishgoing:

	sep	#$20

	lda	textoff		; increase sine offset ($00 - $ff)
	inc a
	and	#$3f
	sta	textoff
	cmp	#$3f
	bne	notsstop2
	stz	flipflop
	
	lda	textoffset
	inc a
	and	#$07
	sta	textoffset
	
	

	
notsstop2:
	

	rep	#$30
	ldx	textoff		; get sine offset
	lda	textsine,x
	and	#$00ff

	sta	storage1		; bottom h pos offset
	stz	storage2		; clear xstorage2 (becomes remainder)

					; top line's position is always $0	
					; bottom line's position goes
					; in accordance with sine data


					; to calculate the slope for the
					; other lines we divide the
					; bottom's h position by
					; the bottom line v position
					; (which line it's located)
					; the bottom line v pos is 128
					; so this is the calculaton we need:
					; bottomHpos/bottomVpos = slope value

					; what's important to know is that
					; we need the remainder to create
					; a smooth slope

tscont:

	lda	storage1		; get the bottom line's H pos



	lsr a				; divide by 128 and get remainder
	ror	storage2		; 
	lsr a				; quotient
	ror	storage2		; remainder
	lsr a				; 
	ror	storage2		;
	;lsr a				; we shift the accumulator right
	;ror	storage2		; and send the carried bit to the

	;lsr a				; remainder through ROR
	;ror	storage2		; quotient remainder
	;lsr a				; 01010101 01000000
	;ror	storage2		;  after division by 2 (shift to right)
	;lsr a				; 00101010 10100000
	;ror	storage2		;


					; after getting to many strange
					; effects while using the SNES'
					; built in division I resorted to
					; using a fool proof method:
					; my own code!


	sta	storage1		; store the quotient

	stz	storage3		; counter
	
	stz	storage4		; decimal counter


	ldx	#$0000
	ldy	#$0010			; # of lines = 16
hposdrawloop2:

	inx			; skip first byte of HDMA list

	lda	storage3	; store counter (H pos offset) in HDMA list
	inc a
	inc a
	sta	$1f46,x
	
	inx			; jump over the 2 bytes of HDMA list to get
	inx			; to the next line of the list

	lda	storage4	; get decimal counter
	clc
	adc	storage2	; add the remainder of the division
	sta	storage4	; store it back into the decimal counter
	bcc	nohposadd2	; if the carry bit is set (the addition value
	inc	storage3	; becomes more than $ffff) then increase
				; Whole number counter by one

nohposadd2:

	lda	storage3	; get whole number counter 
	clc
	adc	storage1	; add qoutient
	sta	storage3	; store it into the whole number counter again

	dey			; decrease # of lines left to draw
	bne	hposdrawloop2	; if it's not 0, then do the whole thing again!
	sep	#$20
	rts



textsine:




 dc.b  0,1,1,1,2,2,2
 dc.b  3,3,4,4,5,5,6,7,8,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
 dc.b  23,25,26,27,28,30,31,32,34,35,37,38,40,41,42,44,45,47,48,50
 dc.b  52,53,55,56,58,59,61,62,62,62,62,62,62,62,62





;==========================================================================
;                           Anthrox Sprite Sine Waver
;==========================================================================

atxsine:
	rep	#$30
	sep	#$20

	ldx	sineoffsetx
	lda	sine,x
	sec
	sbc	#$88
	sta	$0500

	ldx	sineoffsety
	lda	sine,x
	sec
	sbc	#$90
	sta	$0501

	lda	#$0e
	sta	$0502
	lda	#$00
	sta	$0503

	rep	#$30
	lda	sineoffsetx
	clc
	adc	#$08
	and	#$00ff
	tax
	sep	#$20
	lda	sine,x
	sec
	sbc	#$88
	sta	$0504

	rep	#$30
	lda	sineoffsety
	clc
	adc	#$08
	and	#$00ff
	tax
	sep	#$20
	lda	sine,x
	sec
	sbc	#$90
	sta	$0505
	
	lda	#$0c
	sta	$0506
	stz	$0507




	rep	#$30
	lda	sineoffsetx
	clc
	adc	#$10
	and	#$00ff
	tax
	sep	#$20
	lda	sine,x
	sec
	sbc	#$88
	sta	$0508

	rep	#$30
	lda	sineoffsety
	clc
	adc	#$10
	and	#$00ff
	tax
	sep	#$20
	lda	sine,x
	sec
	sbc	#$90
	sta	$0509
	
	lda	#$0a
	sta	$050a
	stz	$050b



	rep	#$30
	lda	sineoffsetx
	clc
	adc	#$18
	and	#$00ff
	tax
	sep	#$20
	lda	sine,x
	sec
	sbc	#$88
	sta	$050c

	rep	#$30
	lda	sineoffsety
	clc
	adc	#$18
	and	#$00ff
	tax
	sep	#$20
	lda	sine,x
	sec
	sbc	#$90
	sta	$050d
	
	lda	#$08
	sta	$050e
	stz	$050f



	rep	#$30
	lda	sineoffsetx
	clc
	adc	#$20
	and	#$00ff
	tax
	sep	#$20
	lda	sine,x
	sec
	sbc	#$88
	sta	$0510

	rep	#$30
	lda	sineoffsety
	clc
	adc	#$20
	and	#$00ff
	tax
	sep	#$20
	lda	sine,x
	sec
	sbc	#$90
	sta	$0511
	
	lda	#$06
	sta	$0512
	stz	$0513



	rep	#$30
	lda	sineoffsetx
	clc
	adc	#$28
	and	#$00ff
	tax
	sep	#$20
	lda	sine,x
	sec
	sbc	#$88
	sta	$0514

	rep	#$30
	lda	sineoffsety
	clc
	adc	#$28
	and	#$00ff
	tax
	sep	#$20
	lda	sine,x
	sec
	sbc	#$90
	sta	$0515
	
	lda	#$04
	sta	$0516
	stz	$0517



	rep	#$30
	lda	sineoffsetx
	clc
	adc	#$30
	and	#$00ff
	tax
	sep	#$20
	lda	sine,x
	sec
	sbc	#$88
	sta	$0518

	rep	#$30
	lda	sineoffsety
	clc
	adc	#$30
	and	#$00ff
	tax
	sep	#$20
	lda	sine,x
	sec
	sbc	#$90
	sta	$0519
	
	lda	#$02
	sta	$051a
	stz	$051b



	inc	sineoffsetx

	inc	sineoffsety

	lda	sinetimer
	inc a
	and	#$3f
	sta	sinetimer
	beq	incsinex


	rts

incsinex:
	inc	sineoffsetx
	rts


;==========================================================================
;                              Scroll Routine
;==========================================================================

scroll:
	rep	#$30
	sep	#$20

	ldx	scrollval
	inx
	inx
	stx	scrollval

	dec	scrollcount
	dec	scrollcount
	lda	scrollcount
	beq	scrollok
	rts

scrollok:

	lda	#$10
	sta	scrollcount

	lda	scrollcol
	inc a			; increase scroll column
	and	#$1f
	sta	scrollcol


	rep	#$30
	lda	scrollcol
	and	#$000f
	asl a
	clc
	adc	#$6300
	sta	storage1

	lda	scrollcol
	and	#$0010
	bne	eq400

	lda	storage1	
	sta	storage2		; the address
	bra	not400

eq400:
	lda	storage1
	clc
	adc	#$0400
	sta	storage2

not400:
	ldx	scrolltext
	lda	scrtxt,x
	and	#$00ff
	bne	noresetscroll
	ldx	#$0000
	stx	scrolltext
	bra	not400


noresetscroll:

	cmp	#$005f
	bcc	allcapital
	sec
	sbc	#$0020


allcapital:

	sec
	sbc	#$0020
	asl a
	ora	#$1c00
	ldx	storage2
	stx	$2116
	sta	$2118
	inc a
	sta	$2118
	dec a
	pha
	lda	storage2
	clc
	adc	#$0020
	sta	storage2
	pla
	ldx	storage2
	stx	$2116
	clc
	adc	#$0080
	sta	$2118
	inc a
	sta	$2118
	
	sep	#$20
	ldx	scrolltext
	inx
	stx	scrolltext
	rts


	

;==========================================================================
;         Move Star By Multiplying (X and Y) by 32 and Dividing them by Z
;==========================================================================
Movestar:
	rep	#$30

	ldy	#$0000; sprite data offset
	sty	storage1 ; map offset
	ldy	#$0020
	sty	storage2
	lda	starcount
	sta	storage3

Movethestar:
	rep	#$30
	sep	#$20

	ldx	storage1
	ldy	storage2

	rep	#$30
	lda	$1400,x		; calculate (X*32)/Z
	and	#$00ff
	xba
	sta	$4204
	sep	#$20
	lda	$1500,x
	sta	$4206
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	rep	#$30
	lda	$4214
	cmp	#$0080
	bcc	skip1
	jmp	nostar
skip1
	;and	#$00ff
	ora	#$0080	


	sep	#$20

	sta	$0500,y

	rep	#$30



	lda	$1480,x		; calculate (Y*32)/z
	and	#$00ff
	xba

	sta	$4204
	sep	#$20
	lda	$1500,x
	sta	$4206
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	rep	#$30
	lda	$4214
	cmp	#$0080
	bcc	skip2
	jmp	nostar
skip2:

	;and	#$00ff
	ora	#$0080
	cmp	#$00f0
	bcc	skip3
	jmp	nostar
skip3:
	sep	#$20
	
	sta	$0501,y

	rep	#$30

movezstar:		
	lda	$1500,x
	and	#$007f
	lsr a
	lsr a
	;lsr a
	phx
	tax
	sep	#$20
	lda	starsize,x
	sta	$0502,y


	plx

	lda	$1580,x
	and	#$03
	asl a
	sta	$0503,y


movezstar2:
	;rep	#$30

	ldx	storage1

	sep	#$20
	lda	$1500,x
	dec a
	dec a
	and	#$7f
	sta	$1500,x

	;sep	#$20



	ldy	storage2
	iny
	iny
	iny
	iny
	sty	storage2

	inc	storage1
	dec	storage3
	;lda	storage3
	beq	endstar
	jmp	Movethestar

endstar:
	sep	#$20
	lda	starcount
	sta	storage3
	jmp	Movethestar2
	
	
nostar:
	;rep	#$30
	sep	#$20

	lda	#$00
	sta	$0500,y
	lda	#$f0
	sta	$0501,y
	lda	#$00
	sta	$0502,y
	sta	$0503,y
	ldx	storage1

	lda	#$00
	sta	$1500,x

	lda	$1400,x
	clc
	adc	#$03
	sta	$1400,x
	lda	$1480,x
	clc
	adc	#$63
	sta	$1480,x

	inc	$1580,x

	rep	#$30
	bra	movezstar2




Movethestar2:
	;rep	#$30
	;sep	#$20

	ldx	storage1
	ldy	storage2

	rep	#$30
	lda	$1400,x		; calculate (X*32)/Z
	and	#$00ff

	xba


	sta	$4204
	sep	#$20
	lda	$1500,x
	sta	$4206
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	rep	#$30
	lda	$4214
	cmp	#$0080
	bcc	skip12
	jmp	nostar2
skip12:
	;and	#$00ff
	ora	#$0080	


	sep	#$20
	sta	$0500,y

	rep	#$30



	lda	$1480,x		; calculate (Y*32)/z
	and	#$00ff
	xba

	sta	$4204
	sep	#$20
	lda	$1500,x
	sta	$4206
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	rep	#$30
	lda	$4214
	cmp	#$0080
	bcc	skip22
	jmp	nostar2
skip22:

	;and	#$00ff
	ora	#$0080
	cmp	#$00ff
	bcc	skip32
	jmp	nostar2
skip32:
	sep	#$20
	eor	#$ff
	sta	$0501,y

	rep	#$30

movezstar21:		
	lda	$1500,x
	and	#$007f
	lsr a
	lsr a
	;lsr a
	phx
	tax
	sep	#$20
	lda	starsize,x
	and	#$00ff
	sta	$0502,y

	;rep	#$30
	;sep	#$20
	plx

	lda	$1580,x
	and	#$03
	asl a
	sta	$0503,y


movezstar22:
	;rep	#$30

	ldx	storage1

	sep	#$20
	lda	$1500,x
	dec a
	dec a
	and	#$7f
	sta	$1500,x

	;sep	#$20



	ldy	storage2
	iny
	iny
	iny
	iny
	sty	storage2

	inc	storage1
	dec	storage3
	;lda	storage3
	beq	endstar2
	jmp	Movethestar2

endstar2:
	sep	#$20
	lda	starcount
	sta	storage3
	jmp	Movethestar3
	
	
nostar2:
	;rep	#$30
	sep	#$20

	lda	#$00
	sta	$0500,y
	lda	#$f0
	sta	$0501,y
	lda	#$00
	sta	$0502,y
	sta	$0503,y
	ldx	storage1

	lda	#$00
	sta	$1500,x

	lda	$1400,x
	clc
	adc	#$03
	sta	$1400,x
	lda	$1480,x
	clc
	adc	#$57
	sta	$1480,x

	inc	$1580,x

	rep	#$30
	bra	movezstar22



	sep	#20



Movethestar3:
	;rep	#$30
	;sep	#$20

	ldx	storage1
	ldy	storage2

	rep	#$30
	lda	$1400,x		; calculate (X*32)/Z
	and	#$00ff
	xba
	sta	$4204
	sep	#$20
	lda	$1500,x
	sta	$4206
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	rep	#$30
	lda	$4214
	cmp	#$0080
	bcc	skip13
	jmp	nostar3
skip13
	;and	#$00ff
	ora	#$0080	


	sep	#$20
	eor	#$ff
	sta	$0500,y

	rep	#$30



	lda	$1480,x		; calculate (Y*32)/z
	and	#$00ff
	xba

	sta	$4204
	sep	#$20
	lda	$1500,x
	sta	$4206
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	rep	#$30
	lda	$4214
	cmp	#$0080
	bcc	skip23
	jmp	nostar3
skip23:

	;and	#$00ff
	ora	#$0080
	cmp	#$00f0
	bcc	skip33
	jmp	nostar3
skip33:
	sep	#$20
	
	sta	$0501,y

	rep	#$30

movezstar3:		
	lda	$1500,x
	and	#$007f
	lsr a
	lsr a
	;lsr a
	phx
	tax
	sep	#$20
	lda	starsize,x
	and	#$00ff
	sta	$0502,y

	;rep	#$30
	;sep	#$20
	plx

	lda	$1580,x
	and	#$03
	asl a
	sta	$0503,y


movezstar23:
	;rep	#$30

	ldx	storage1

	sep	#$20
	lda	$1500,x
	dec a
	dec a
	and	#$7f
	sta	$1500,x

	sep	#$20



	ldy	storage2
	iny
	iny
	iny
	iny
	sty	storage2

	inc	storage1
	dec	storage3
	;lda	storage3
	beq	endstar3
	jmp	Movethestar3

endstar3:
	sep	#$20
	lda	starcount
	sta	storage3
	jmp	Movethestar4
	
	
nostar3:
	;rep	#$30
	sep	#$20

	lda	#$00
	sta	$0500,y
	lda	#$f0
	sta	$0501,y
	lda	#$00
	sta	$0502,y
	sta	$0503,y
	ldx	storage1

	lda	#$00
	sta	$1500,x
	
	lda	$1400,x
	clc
	adc	#$71
	sta	$1400,x
	lda	$1480,x
	clc
	adc	#$03
	sta	$1480,x

	inc	$1580,x

	rep	#$30
	bra	movezstar23




Movethestar4:
	;rep	#$30
	;sep	#$20

	ldx	storage1
	ldy	storage2

	rep	#$30
	lda	$1400,x		; calculate (X*32)/Z
	and	#$00ff
	xba

	sta	$4204
	sep	#$20
	lda	$1500,x
	sta	$4206
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	rep	#$30
	lda	$4214
	cmp	#$0080
	bcc	skip14
	jmp	nostar4
skip14
	;and	#$00ff
	ora	#$0080	


	sep	#$20
	eor	#$ff
	sta	$0500,y

	rep	#$30



	lda	$1480,x		; calculate (Y*32)/z
	and	#$00ff
	xba
	sta	$4204
	sep	#$20
	lda	$1500,x
	sta	$4206
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	nop
	rep	#$30
	lda	$4214
	cmp	#$0080
	bcc	skip24
	jmp	nostar4
skip24:

	;and	#$00ff
	ora	#$0080
	cmp	#$00ff
	bcc	skip34
	jmp	nostar4
skip34:
	sep	#$20
	eor	#$ff
	sta	$0501,y

	rep	#$30

movezstar4:		
	lda	$1500,x
	and	#$007f
	lsr a
	lsr a
	;lsr a
	phx
	tax
	sep	#$20
	lda	starsize,x
	and	#$00ff
	sta	$0502,y

	;rep	#$30
	;sep	#$20
	plx

	lda	$1580,x
	and	#$03
	asl a
	sta	$0503,y




movezstar24:
	rep	#$30

	ldx	storage1

	sep	#$20
	lda	$1500,x
	dec a
	dec a
	and	#$7f
	sta	$1500,x
	sep	#$20



	ldy	storage2
	iny
	iny
	iny
	iny
	sty	storage2

	inc	storage1
	dec	storage3
	;lda	storage3
	beq	endstar4
	jmp	Movethestar4

endstar4:
	sep	#$20
	rts
	
	
nostar4:
	;rep	#$30
	sep	#$20

	lda	#$00
	sta	$0500,y
	lda	#$f0
	sta	$0501,y
	lda	#$00
	sta	$0502,y
	sta	$0503,y
	ldx	storage1

	lda	#$00
	sta	$1500,x
	lda	$1400,x
	clc
	adc	#$03
	sta	$1400,x
	lda	$1480,x
	clc
	adc	#$af
	sta	$1480,x

	inc	$1580,x
	

	rep	#$30
	bra	movezstar24




starsize:


	dc.b	$4e,$4e,$4e,$4e,$4e
	dc.b	$4c,$4c,$4a,$4a,$48,$48,$46,$46
	dc.b	$44,$44,$42,$42,$40,$40,$2e,$2e
	dc.b	$2c,$2c,$2a,$2a,$26,$26,$24,$24
	dc.b	$22,$22,$20


;=========================================================================
;                          HDMA Current Line Waver
;=========================================================================
HDMAwave:
	rep	#$30
	sep	#$20

	ldx	#$0000
	txy
clearDMAcolor:
	stz	$1e90,x
	stz	$1e91,x
	inx
	inx
	inx
	iny
	cpy	#13
	bne	clearDMAcolor

	ldx	lineval1
	ldy	#$1084
	jsr	drawline

	ldx	lineval2
	ldy	#$2108
	jsr	drawline

	ldx	lineval3
	ldy	#$318c
	jsr	drawline

	ldx	lineval4
	ldy	#$39ce
	jsr	drawline


	lda	lineval1
	inc a
	and	#$3f
	sta	lineval1



	lda	lineval2
	inc a
	and	#$3f
	sta	lineval2



	lda	lineval3
	inc a
	and	#$3f
	sta	lineval3



	lda	lineval4
	inc a
	and	#$3f
	sta	lineval4

	rts


	
drawline:
	rep	#$30
	lda	hdmasine,x
	and	#$00ff
	sta	storage1
	asl a
	clc
	adc	storage1
	tax
	tya
	sta	$1e90,x
	sep	#$20
	rts


hdmasine:

 dc.b  6,7,7,8,8,9,9,10,10,11,11,11,12,12,12,12,12,12,12,12,12,11
 dc.b  11,11,10,10,9,9,8,8,7,7,6,5,5,4,4,3,3,2,2,1,1,1,0,0,0,0,0,0
 dc.b  0,0,0,1,1,1,2,2,3,3,4,4,5,5,6


;==========================================================================
;                   Change Trainer Value And Print Yes/No/#
;==========================================================================

buttselect:
	sep	#$20
	lda	joydata+1
	bit	#$80
	bne	OptB
	bit	#$02
	bne	OptB
	bit	#$01
	bne	OptA
	lda	joydata
	bit	#$80
	bne	OptA
	stz	numbertimer
	rts

OptA:
	jmp	Incopt
OptB:
	jmp	Decopt

Incopt:
	ldx	currentline		; get current option line
	dex
	lda	Type,x
	beq	Textopt
	jmp	Numberopt
Textopt:
	lda	#$01
	sta	$1c00,x
	jmp	displayyn	

Numberopt:
	lda	numbertimer
	inc a
	and	#$03
	sta	numbertimer
	beq	Numberoptinc
	rts
Numberoptinc:
	lda	$1c00,x
	cmp	Max,x
	bne	Incnumber
	rts
Incnumber:
	inc	$1c00,x
	lda	$1c00,x
PrintDec:
	sta	numconv
	jsr	Hex2Dec

	rep	#$30
	lda	currentline
	dec a
	asl a
	asl a
	asl a
	asl a
	asl a
	asl a
	clc
	adc	#$7019
	sta	$2116
	sep	#$20

	lda	hundreds
	clc
	adc	#$10
	sta	$2118
	lda	#$10
	sta	$2119
	lda	tens
	clc
	adc	#$10
	sta	$2118
	lda	#$10
	sta	$2119
	lda	ones
	clc
	adc	#$10
	sta	$2118
	lda	#$10
	sta	$2119


	rep	#$30
	lda	currentline
	dec a
	asl a
	asl a
	asl a
	asl a
	asl a
	asl a
	clc
	adc	#$7039
	sta	$2116
	sep	#$20
	lda	hundreds
	clc
	adc	#$70
	sta	$2118
	lda	#$10
	sta	$2119
	lda	tens
	clc
	adc	#$70
	sta	$2118
	lda	#$10
	sta	$2119
	lda	ones
	clc
	adc	#$70
	sta	$2118
	lda	#$10
	sta	$2119



	rts




Decopt:
	ldx	currentline		; get current option line
	dex
	lda	Type,x
	beq	Textopt1
	jmp	Numberopt1
Textopt1:
	lda	#$00
	sta	$1c00,x
	jmp	displayyn	

Numberopt1:
	lda	numbertimer
	inc a
	and	#$03
	sta	numbertimer
	beq	Numberoptdec
	rts

Numberoptdec:
	lda	$1c00,x
	cmp	Min,x
	bne	Decnumber
	rts
Decnumber:
	dec	$1c00,x
	lda	$1c00,x
	sta	numconv
	jsr	Hex2Dec

	rep	#$30
	lda	currentline
	dec a
	asl a
	asl a
	asl a
	asl a
	asl a
	asl a
	clc
	adc	#$7019
	sta	$2116
	sep	#$20
	lda	hundreds
	clc
	adc	#$10
	sta	$2118
	lda	#$10
	sta	$2119
	lda	tens
	clc
	adc	#$10
	sta	$2118
	lda	#$10
	sta	$2119
	lda	ones
	clc
	adc	#$10
	sta	$2118
	lda	#$10
	sta	$2119

	rep	#$30
	lda	currentline
	dec a
	asl a
	asl a
	asl a
	asl a
	asl a
	asl a
	clc
	adc	#$7039
	sta	$2116
	sep	#$20
	lda	hundreds
	clc
	adc	#$70
	sta	$2118
	lda	#$10
	sta	$2119
	lda	tens
	clc
	adc	#$70
	sta	$2118
	lda	#$10
	sta	$2119
	lda	ones
	clc
	adc	#$70
	sta	$2118
	lda	#$10
	sta	$2119



	rts




displayyn:
	rep	#$30
	lda	currentline
	dec a
	asl a
	asl a
	asl a
	asl a
	asl a
	asl a
	clc
	adc	#$7019
	sta	$2116
	sep	#$20
	lda	$1c00,x
	beq	TxtNo
	ldx	#$0000
copyyes:
	lda	YES,x
	sec
	sbc	#$20
	sta	$2118
	lda	#$14
	sta	$2119
	inx
	cpx	#$03
	bne	copyyes

	rep	#$30
	lda	currentline
	dec a
	asl a
	asl a
	asl a
	asl a
	asl a
	asl a
	clc
	adc	#$7039
	sta	$2116
	
	ldx	#$0000
	sep	#$20
copyyes2:
	lda	YES,x
	sec
	sbc	#$20
	clc
	adc	#$60
	sta	$2118
	lda	#$14
	sta	$2119
	inx
	cpx	#$03
	bne	copyyes2

	rts
TxtNo:
	ldx	#$0000
copyno:
	lda	NO,x
	sec
	sbc	#$20
	sta	$2118
	lda	#$18
	sta	$2119
	inx
	cpx	#$03
	bne	copyno

	
	rep	#$30
	lda	currentline
	dec a
	asl a
	asl a
	asl a
	asl a
	asl a
	asl a
	clc
	adc	#$7039
	sta	$2116
	
	ldx	#$0000
	sep	#$20
copyno2:
	lda	NO,x
	sec
	sbc	#$20
	clc
	adc	#$60
	sta	$2118
	lda	#$18
	sta	$2119
	inx
	cpx	#$03
	bne	copyno2


	rts


	

;==========================================================================
;                          Move Menu Up/Down
;==========================================================================

movemenu:
	sep	#$20
	lda	menumotion
	beq	menucheckpad
	lda	menudirection
	beq	md3
	bne	mu3

menucheckpad:
	lda	joydata+1
	;and	#$0c
	bit	#$08
	bne	movedown
	bit	#$04
	bne	moveup
	rts

movedown:
	jmp	movedown2
moveup:
	jmp	moveup2

movedown2:
	lda	currentline
	cmp	#$01
	beq	md4
	dec	currentline
	lda	#$01
	sta	menumotion	; turn on menu motor!

	stz	menudirection	; 0 = moving down
	stz	menuoffset	; set to 0
	;rts
md3:
	dec	menuscroll
	lda	menuoffset
	inc a
	sta	menuoffset
	cmp	#$10
	beq	md4
	rts
md4:
	stz	menumotion
	rts


moveup2:
	lda	currentline
	cmp	options
	beq	mu4
	inc	currentline
	lda	#$01
	sta	menumotion
	lda	#$01
	sta	menudirection
	stz	menuoffset
	;rts

mu3:
	inc	menuscroll
	lda	menuoffset
	inc a
	sta	menuoffset
	cmp	#$10
	beq	mu4
	rts
mu4:
	stz	menumotion
	rts




;=========================================================================
;                         Hex to Decimal Conversion
;=========================================================================

Hex2Dec:

	;lda	#$8f
	;sta	$1f28		; number to be converted

	rep	#$30
	lda	numconv
	and	#$000f
	asl a
	asl a
	tax
	sep	#$20
	inx
	inx
	inx
	lda	LOW,x
	sta	low2
	dex
	lda	LOW,x
	sta	low1
	dex
	lda	LOW,x
	sta	low0

	rep	#$30
	lda	numconv
	and	#$00f0
	lsr a
	lsr a
	lsr a
	lsr a
	asl a
	asl a
	tax
	sep	#$20
	inx
	inx
	inx
	lda	HIGH,x
	sta	high6
	dex	
	lda	HIGH,x
	sta	high5
	dex
	lda	HIGH,x
	sta	high4

oneadd:
	lda	high6
	clc
	adc	low2
	cmp	#$0a
	bcs	onehigh
	stz	hundreds
	sta	ones
	bra	tenadd
onehigh:
	sec
	sbc	#$0a
	sta	ones
	lda	#$01
	sta	hundreds

tenadd:
	lda	high5
	clc
	adc	low1
	clc
	adc	hundreds

	cmp	#$0a
	bcs	tenhigh
	stz	hundreds
	sta	tens
	bra	hundadd
tenhigh:
	sec	
	sbc	#$0a
	sta	tens
	lda	#$01
	sta	hundreds
	
hundadd:
	lda	high4
	clc
	adc	low0
	clc
	adc	hundreds
	sta	hundreds
	rts


;==========================================================================
;                            Option Setup Routine
;==========================================================================

Option_Setup:

	
	ldx	#$0000
clearopts:
	stz	$1c00,x
	inx
	cpx	#$0100
	bne	clearopts

	ldx	#$0000
SetOptRam:
	lda	Type,x
	bne	Numberthing
SetRamOpt:
	inx
	cpx	options
	bne	SetOptRam
	jmp	thisthat

Numberthing:
	lda	Begin,x
	sta	$1c00,x
	bra	SetRamOpt


thisthat:

	
	ldx	#$0001
	stx	currentline
	
printopt:
	ldx	currentline
	dex
	lda	Type,x
	bne	numbtype
	jsr	displayyn
contOptram:
	ldx	currentline
	inx
	stx	currentline
	ldx	currentline
	dex 
	cpx	options
	bne	printopt
	rts
numbtype:
	
	ldx	currentline
	dex
	lda	$1c00,x
	jsr	PrintDec
	bra	contOptram



;==========================================================================
;                         Wait For Vertical Blank
;==========================================================================
WaitVb:
	lda	$4210
	bpl	WaitVb
WaitVb2:
	lda	$4210
	bmi	WaitVb2
	rts




;==========================================================================
;                      Sprite Scroll Routine
;==========================================================================

StarDMA:
	rep	#$10	; x,y = 16 bit
	sep	#$20	; a = 8 bit
			; start of General DMA graphics copy routine!
	lda	#$00
	sta	$4370		; 0= 1 byte per register (not a word!)
	lda	#$04
	sta	$4371		; 21xx   this is 2104 (VRAM)
	lda	#$00
	sta	$4372
	lda	#$05		; address = $7e0500
	sta	$4373
	lda	#$7e
	sta	$4374		; bank address of data in ram
	ldx	#$0200
	stx	$4375		; # of bytes to be transferred

	ldx	#$0000
	stx	$2102

	lda	#$80
	sta	$420b

	rts


;==========================================================================
;                          Joypad Routine
;==========================================================================

joypad:
	lda	$4212
	and	#$01
	beq	joypad
joypad2:
	lda	$4212
	and	#$01
	bne	joypad2

	ldx	$4218
	stx	joydata
	rts

;==========================================================================
;                           Setup Star Map
;==========================================================================
Setup_Starmap:
	rep	#$30
	ldx	#$0000
fixstarxypos:
	lda	randomnumbers,x
	lsr a
	xba
	lsr a
	xba
	
	and	#$7f7f
	sta	$1400,x
	inx
	inx
	cpx	#$0100
	bne	fixstarxypos
	sep	#$20
	ldx	#$0000
fixstarzpos
	lda	randomnumbers,x
	lsr a
	lsr a
	lsr a
	lsr a
	sta	$1500,x
	
	lda	randomnumbers,x
	and	#$03			; make the color array!
	sta	$1580,x

	inx
	cpx	#$0080
	bne	fixstarzpos


	rts




;==========================================================================
;       	     SETUP ROUTINES FOR PROGRAM
;==========================================================================



;==========================================================================
;                         Copy graf-x data
;==========================================================================

Copy_Gfx:
	ldx	#$0000		; Vram address $0000 
	stx	$2116		; 
	ldx	#$0000
Clearvr:
	stz	$2118		; clear entire Vram
	stz	$2119
	inx
	bne	Clearvr

	rep	#$30


	ldx	#$4000
	stx	$2116


	ldx	#$0000
	
copystaticgfx:
	;lda	stargfx,x
	lda	>$7f0000+1536,x
	sta	$2118
	inx
	inx
	cpx	#$0c00
	bne	copystaticgfx
	
	ldx	#$0000
	stx	$2116


	ldx	#$0000
copyatxlogo:
	;lda	atxlogo,x
	lda	>$7f0000+4608,x
	sta	$2118
	inx
	inx
	cpx	#$1100
	bne	copyatxlogo
	
	ldx	#$1000
	stx	$2116

	ldx	#$0000
copyfont:
	;lda	font,x
	lda	>$7f0000+8960,x
	sta	$2118
	inx
	inx
	cpx	#$1800
	bne	copyfont

	ldx	#$2000
	stx	$2116

	ldx	#$0000
copyscrollfont:
	;lda	scrollfont,x
	lda	>$7f0000+15104,x
	sta	$2118
	inx
	inx
	cpx	#$2000
	bne	copyscrollfont

	ldx	#$5000
	stx	$2116
	
	ldx	#$0000
copytextfont:
	;lda	textfont,x
	lda	>$7f0000,x
	sta	$2118
	inx
	inx
	cpx	#$0600
	bne	copytextfont

	sep	#$20

	rts

;==========================================================================
;                      Copy Colors
;==========================================================================
Copy_colors:
	stz	$2121		; Select Color Register 1
	ldx	#$0000
CopCol:	
	lda	Colors,X
	sta	$2122
	inx
	cpx	#$0200 		; copy 32 colors ($20*2)
	bne	CopCol
	rts
;==========================================================================
;                      Make Tiles
;==========================================================================

Make_tiles:

	rep	#$30


	ldx	#$7800
	stx	$2116
	
	ldx	#$0000
copyatxchar:
	lda	atxchar,x
	clc
	adc	#$0400
	sta	$2118
	inx
	inx
	cpx	#$0400
	bne	copyatxchar

	rep	#$30

	ldx	#$7000
	stx	$2116

	ldx	#$0000
	stx	storage1
	stx	storage2
	
	ldx	#$0000
copydoublemenu:
	stz	storage1
	txy
copymenutxt:
	lda	menutxt,x
	and	#$00ff
	sec
	sbc	#$20
	ora	#$0c00
	sta	$2118
	inx
	lda	storage1
	inc a
	sta	storage1
	cmp	#$0020
	bne	copymenutxt

	tyx
	stz	storage1
	
copymenutxt2:
	lda	menutxt,x
	and	#$00ff
	sec
	sbc	#$0020
	clc
	adc	#$0060
	ora	#$0c00
	sta	$2118
	inx
	lda	storage1
	inc a
	sta	storage1
	cmp	#$0020
	bne	copymenutxt2

	lda	storage2
	inc a
	sta	storage2
	cmp	#$0010
	bne	copydoublemenu

	ldx	#$5ac0
	stx	$2116

	ldx	#$0000
printtest:
	lda	testxt,x
	and	#$00ff
	sec
	sbc	#$20
	sta	$2118
	inx	
	cpx	#$0040
	bne	printtest

	sep	#$20
	rts


testxt:
	dc.b	'this is a test to see what happe'
	dc.b	'to this Line when i try to squis'



;==========================================================================
;                        Start of HDMA routine
;==========================================================================

HDMA:
	rep	#$10
	sep	#$20


	ldx	#$0000
copy210flist:
	lda	list210f,x
	sta	$1e20,x
	inx
	cpx	#$0020
	bne	copy210flist

	ldx	#$0000
copy2121list:
	lda	list2121,x
	sta	$1e40,x
	inx
	cpx	#$0040
	bne	copy2121list

	ldx	#$0000
copy2122list:
	lda	list2122,x
	sta	$1e80,x
	inx
	cpx	#$0060
	bne	copy2122list

	ldx	#$0000
copy2107list:
	lda	list2107,x
	sta	$1ee0,x
	inx
	cpx	#$0020
	bne	copy2107list

	ldx	#$0000
copy210blist:
	lda	list210b,x
	sta	$1f00,x
	inx
	cpx	#$0020
	bne	copy210blist

	ldx	#$0000
copy210dlist:
	lda	list210d,x
	sta	$1f20,x
	inx
	cpx	#$0020
	bne	copy210dlist

	ldx	#$000
copy2112list:
	lda	list2112,x
	sta	$1f40,x
	inx
	cpx	#$0040
	bne	copy2112list



	lda     #$03        
	sta     $4300         
	lda     #$0f       
	sta     $4301         
	ldx     #$1e20  
	stx     $4302         
	lda	#$7e          
	sta     $4304

	lda	#$00
	sta	$4310
	lda	#$21
	sta	$4311
	ldx	#$1e40
	stx	$4312
	lda	#$7e
	sta	$4314

	lda	#$02
	sta	$4320
	lda	#$22
	sta	$4321
	ldx	#$1e80
	stx	$4322
	lda	#$7e
	sta	$4324

	lda	#$00
	sta	$4330
	lda	#$07
	sta	$4331
	ldx	#$1ee0
	stx	$4332
	lda	#$7e
	sta	$4334

	lda	#$00
	sta	$4340
	lda	#$0b
	sta	$4341
	ldx	#$1f00
	stx	$4342
	lda	#$7e
	sta	$4344
	
	lda	#$02
	sta	$4350
	lda	#$0d
	sta	$4351
	ldx	#$1f20
	stx	$4352
	lda	#$7e
	sta	$4354

	lda	#$02
	sta	$4360
	lda	#$12
	sta	$4361
	ldx	#$1f40
	stx	$4362
	lda	#$7e
	sta	$4364

	



	jsr	WaitVb
	lda	#%01111111
	sta	$420c
	rts


list210f:
	dc.b	$57,$00,$01,$00,$01
	dc.b	$50,$00,$00,$86,$00	; yay
	dc.b	$8,$00,$01,$00,$01
	dc.b	$10,$00,$01,$d8,0		:<-bot text
	dc.b	$01,$00,$01,$00,$01,0,0,0,0

list2121:
	dc.b	$54,$00
	dc.b	1,0,1,0,1,0
	dc.b	$22,0
	dc.b	1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0
	dc.b	1,0,1,0,1,0,1,0,1,0,1,0,1,0,$1f,0
	dc.b	1,0,1,0,1,0
	dc.b	1,0
	dc.b	0,0

list2122:
	dc.b	$54,$00,00
	dc.b	1,$88,0
	dc.b	1,$9c,1
	dc.b	1,$88,0
	dc.b	$22,0,0
	dc.b	1,$ff,$ff,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0,0
	dc.b	1,$00,$00,1,0,0,1,0,0,1,0,0,1,$ff,$ff,1,0,0,1,0,0,$1f,0,0
	dc.b	1,$88,0
	dc.b	1,$9c,1
	dc.b	1,$88,0	
	dc.b	1,0,0
	dc.b	0,0,0

list2107:
	dc.b	$7f,$78
	dc.b	$7f,$61
	dc.b	0,0

list210b:
	dc.b	$7f,$10
	dc.b	$7f,$12
	dc.b	0,0

list210d:
	dc.b	$7f,$00,$00
	dc.b	$7f,$00,$00
	dc.b	0,0,0

list2112:
	dc.b	$7f,$00,$00
	dc.b	$2e,$02,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$01,$80,$00
	dc.b	$7f,$80,$00

	dc.b	0,0,0


;==========================================================================
;                           Sprite Setup routine
;==========================================================================

Sprite_setup:
	lda	#$62
	sta	$2101
	stz	$2102
	stz	$2103
	ldx	#$0000
sprtclear:
	stz	$2104		; Horizontal position
	lda	#$f0
	sta	$2104		; Vertical position
	stz	$2104		; sprite object = 0
	lda	#%00110000
	sta	$2104		; pallete = 0, priority = 0, h;v flip = 0
	inx
	cpx	#$0080		; (128 sprites)
	bne	sprtclear
	ldx	#$0000
sprtdataclear:
	stz	$2104		; clear H-position MSB
	stz	$2104		; and make size small
	inx
	cpx	#$0020		; 32 extra bytes for sprite data
				; info
	bne	sprtdataclear

	ldx	#$0000
clearspritememory:
	lda	#$f0
	sta	$0500,x
	inx
	cpx	#$0200
	bne	clearspritememory

clearspritememory2:
	lda	#$00
	sta	$0500,x

	inx
	cpx	#$0220
	bne	clearspritememory2

	rts


;==========================================================================
;                   SNES Register Initialization routine
;==========================================================================
Snes_Init:
	sep 	#$30    ; X,Y,A are 8 bit numbers
	lda 	#$8F    ; screen off, full brightness
	sta 	$2100   ; brightness + screen enable register 
	stz 	$2101   ; Sprite register (size + address in VRAM)
	stz 	$2102   ; Sprite registers (address of sprite memory [OAM])
	stz 	$2103   ;    ""                       ""
	stz 	$2105   ; Mode 0, = Graphic mode register
	stz 	$2106   ; noplanes, no mosaic, = Mosaic register
	stz 	$2107   ; Plane 0 map VRAM location
	stz 	$2108   ; Plane 1 map VRAM location
	stz 	$2109   ; Plane 2 map VRAM location
	stz 	$210A   ; Plane 3 map VRAM location
	stz 	$210B   ; Plane 0+1 Tile data location
	stz 	$210C   ; Plane 2+3 Tile data location
	stz 	$210D   ; Plane 0 scroll x (first 8 bits)
	stz 	$210D   ; Plane 0 scroll x (last 3 bits) #$0 - #$07ff
	stz 	$210E   ; Plane 0 scroll y (first 8 bits)
	stz 	$210E   ; Plane 0 scroll y (last 3 bits) #$0 - #$07ff
	stz 	$210F   ; Plane 1 scroll x (first 8 bits)
	stz 	$210F   ; Plane 1 scroll x (last 3 bits) #$0 - #$07ff
	stz 	$2110   ; Plane 1 scroll y (first 8 bits)
	stz 	$2110   ; Plane 1 scroll y (last 3 bits) #$0 - #$07ff
	stz 	$2111   ; Plane 2 scroll x (first 8 bits)
	stz 	$2111   ; Plane 2 scroll x (last 3 bits) #$0 - #$07ff
	stz 	$2112   ; Plane 2 scroll y (first 8 bits)
	stz 	$2112   ; Plane 2 scroll y (last 3 bits) #$0 - #$07ff
	stz 	$2113   ; Plane 3 scroll x (first 8 bits)
	stz 	$2113   ; Plane 3 scroll x (last 3 bits) #$0 - #$07ff
	stz 	$2114   ; Plane 3 scroll y (first 8 bits)
	stz 	$2114   ; Plane 3 scroll y (last 3 bits) #$0 - #$07ff
	lda 	#$80    ; increase VRAM address after writing to $2119
	sta 	$2115   ; VRAM address increment register
	stz 	$2116   ; VRAM address low
	stz 	$2117   ; VRAM address high
	stz 	$211A   ; Initial Mode 7 setting register
	stz 	$211B   ; Mode 7 matrix parameter A register (low)
	lda 	#$01
	sta 	$211B   ; Mode 7 matrix parameter A register (high)
	stz 	$211C   ; Mode 7 matrix parameter B register (low)
	stz 	$211C   ; Mode 7 matrix parameter B register (high)
	stz 	$211D   ; Mode 7 matrix parameter C register (low)
	stz 	$211D   ; Mode 7 matrix parameter C register (high)
	stz 	$211E   ; Mode 7 matrix parameter D register (low)
	sta 	$211E   ; Mode 7 matrix parameter D register (high)
	stz 	$211F   ; Mode 7 center position X register (low)
	stz 	$211F   ; Mode 7 center position X register (high)
	stz 	$2120   ; Mode 7 center position Y register (low)
	stz 	$2120   ; Mode 7 center position Y register (high)
	stz 	$2121   ; Color number register ($0-ff)
	stz 	$2123   ; BG1 & BG2 Window mask setting register
	stz 	$2124   ; BG3 & BG4 Window mask setting register
	stz 	$2125   ; OBJ & Color Window mask setting register
	stz 	$2126   ; Window 1 left position register
	stz 	$2127   ; Window 2 left position register
	stz 	$2128   ; Window 3 left position register
	stz 	$2129   ; Window 4 left position register
	stz 	$212A   ; BG1, BG2, BG3, BG4 Window Logic register
	stz 	$212B   ; OBJ, Color Window Logic Register (or,and,xor,xnor)
	sta 	$212C   ; Main Screen designation (planes, sprites enable)
	stz 	$212D   ; Sub Screen designation
	stz 	$212E   ; Window mask for Main Screen
	stz 	$212F   ; Window mask for Sub Screen
	lda 	#$30
	sta 	$2130   ; Color addition & screen addition init setting
	stz 	$2131   ; Add/Sub sub designation for screen, sprite, color
	lda 	#$E0
	sta 	$2132   ; color data for addition/subtraction
	stz 	$2133   ; Screen setting (interlace x,y/enable SFXdata)
	stz 	$4200   ; Enable V-blank, interrupt, Joypad register
	lda 	#$FF
	sta 	$4201   ; Programmable I/O port
	stz 	$4202   ; Multiplicand A
	stz 	$4203   ; Multiplier B
	stz 	$4204   ; Multiplier C
	stz 	$4205   ; Multiplicand C
	stz 	$4206   ; Divisor B
	stz 	$4207   ; Horizontal Count Timer
	stz 	$4208   ; Horizontal Count Timer MSB (most significant bit)
	stz 	$4209   ; Vertical Count Timer
	stz 	$420A   ; Vertical Count Timer MSB
	stz 	$420B   ; General DMA enable (bits 0-7)
	stz 	$420C   ; Horizontal DMA (HDMA) enable (bits 0-7)
	stz 	$420D	; Access cycle designation (slow/fast rom)
	rts




;===========================================================================
;                         Start Of Unpack Routine
;===========================================================================

;---------------------------------------------------------
; PRO-PACK Unpack Source Code - Super NES, Method 1
;
; Copyright (c) 1992 Rob Northen Computing
;
; File: RNC_1.S
;
; Date: 9.03.92
;---------------------------------------------------------
;---------------------------------------------------------
; Unpack Routine - Super NES, Method 1
;
; To unpack a packed file (in any data bank) to an output
; buffer (in any data bank) Note: the packed and unpacked
; files are limited to 65536 bytes in length.
;
; To call (assumes 16-bit accumulator)
;
;
; On exit,
;
; A, X, Y undefined, M=0, X=0
;---------------------------------------------------------
;---------------------------------------------------------
; Equates
;---------------------------------------------------------


;---------------------------------------------------------
UNPACK	rep	#$39	; 16-bit AXY, clear D and C
	lda	#Buff2
	sta	wrkbuf
	lda	#^Buff2
	sta	wrkbuf+2
	lda	#17
	adc	in
	sta	in
	lda	[in]
	and	#$00ff
	sta	blocks
	inc	in
	lda	[in]
	sta	bitbufl
	stz	bufbits
	lda	#2
	jsr	gtbits
unpack2	ldy	#rawtab
	jsr	makehuff
	ldy	#postab
	jsr	makehuff
	ldy	#slntab
	jsr	makehuff
	lda	#16
	jsr	gtbits
	sta	counts
	jmp	unpack8
unpack3	ldy	#postab
	jsr	gtval
	sta	temp2
	lda	out
	clc
	sbc	temp2
	sta	temp3
	ldy	#slntab
	jsr	gtval
	inc	a
	inc	a
	lsr	a
	tax
	ldy	#0

	lda	temp2
	bne	unpack5
	sep	#$20	; 8-bit accumulator
	lda	(temp3),y


	xba
	lda	(temp3),y
	rep	#$20	; 16-bit accumulator
unpack4

	
	sta	(out),y
	iny
	iny
	dex
	bne	unpack4
	bra	unpack6
unpack5	lda	(temp3),y
	sta	(out),y
	iny
	iny
	dex
	bne	unpack5
unpack6	bcc	unpack7
	sep	#$20	; 8-bit accumulator
	lda	(temp3),y
	sta	(out),y
	

	iny
	rep	#$21	; 16-bit accumulator, clear carry
unpack7	tya
	adc	out
	sta	out
unpack8	ldy	#rawtab
	jsr	gtval
	tax
	beq	unpack14
	ldy	#0
	lsr	a
	beq	unpack10
	tax
unpack9	lda	[in],y
	sta	(out),y
	iny
	iny
	dex
	bne	unpack9
unpack10	bcc	unpack11
	sep	#$20	; 8-bit accumulator
	lda	[in],y


	sta	(out),y


	rep	#$21	; 16-bit accumulator, clear carry
	iny
unpack11	tya
	adc	in
	sta	in
	tya
	adc	out
	sta	out
	stz	bitbufh
	lda	bufbits
	tay
	asl	a
	tax
	lda	[in]
	cpy	#0
	beq	unpack13
unpack12	asl	a
	rol	bitbufh
	dey
	bne	unpack12
unpack13	sta	temp1
	phb
	phk
	plb
	lda	msktab,x		;>
	plb
	and	bitbufl
	ora	temp1



	sta	bitbufl
unpack14	dec	counts
	beq	.Mark1
	jmp	unpack3
.Mark1	dec	blocks
	beq	.Mark2
	jmp	unpack2
.Mark2	rts
;-----------------------------------------------------------
gtval	ldx	bitbufl
	bra	gtval3
gtval2	iny
	iny
gtval3	txa
	and	[wrkbuf],y
	iny
	iny
	cmp	[wrkbuf],y
	bne	gtval2
	tya
	adc	#(15*4+1)
	tay
	lda	[wrkbuf],y
	pha
	xba
	and	#$ff
	jsr	gtbits
	pla
	and	#$ff
	cmp	#2
	bcc	gtval4
	dec	a
	asl	a
	pha
	lsr	a


	jsr	gtbits
	plx
	phb
	phk
	plb
	ora	bittab,x		;>
	plb
gtval4	rts
bittab	dcr.w	1
	dcr.w	2
	dcr.w	4
	dcr.w	8
	dcr.w	$10
	dcr.w	$20
	dcr.w	$40
	dcr.w	$80
	dcr.w	$100
	dcr.w	$200
	dcr.w	$400
	dcr.w	$800
	dcr.w	$1000
	dcr.w	$2000
	dcr.w	$4000
	dcr.w	$8000
;-----------------------------------------------------------
gtbits	tay
	asl	a
	tax
	phb
	phk
	plb
	lda	msktab,x		;>
	plb
	and	bitbufl
	pha
	lda	bitbufh
	ldx	bufbits
	beq	gtbits3
gtbits2	lsr	a
	ror	bitbufl
	dey
	beq	gtbits4
	dex
	beq	gtbits3
	lsr	a
	ror	bitbufl



	dey
	beq	gtbits4
	dex
	bne	gtbits2
gtbits3	inc	in
	inc	in
	lda	[in]
	ldx	#16
	bra	gtbits2
gtbits4	dex
	stx	bufbits
	sta	bitbufh
	pla
gtbits5	rts
msktab	dcr.w	0
	dcr.w	1
	dcr.w	3
	dcr.w	7
	dcr.w	$f
	dcr.w	$1f
	dcr.w	$3f
	dcr.w	$7f
	dcr.w	$ff
	dcr.w	$1ff
	dcr.w	$3ff
	dcr.w	$7ff
	dcr.w	$fff
	dcr.w	$1fff
	dcr.w	$3fff
	dcr.w	$7fff
	dcr.w	$ffff
;-----------------------------------------------------------
makehuff	sty	temp4
	lda	#5
	jsr	gtbits
	beq	gtbits5
	sta	temp1


	sta	temp2
	ldy	#0
makehuff2	phy
	lda	#4
	jsr	gtbits
	ply
	sta	[wrkbuf],y
	iny
	iny
	dec	temp2
	bne	makehuff2
	stz	hufcde
	lda	#$8000
	sta	hufbse
	lda	#1
	sta	bitlen
makehuff3	lda	bitlen
	ldx	temp1
	ldy	#0
makehuff4	cmp	[wrkbuf],y
	bne	makehuff8
	phx
	sty	temp3
	asl	a
	tax
	phb
	phk
	plb
	lda	msktab,x		;>
	plb
	ldy	temp4
	sta	[wrkbuf],y
	iny
	iny
	lda	#16
	sec
	sbc	bitlen


	pha
	lda	hufcde
	sta	temp2
	ldx	bitlen
makehuff5	asl	temp2
	ror	a


	dex
	bne	makehuff5
	plx
	beq	makehuff7
makehuff6	lsr	a
	dex
	bne	makehuff6
makehuff7	sta	[wrkbuf],y
	iny
	iny
	sty	temp4
	tya
	clc
	adc	#(15*4)


	tay
	lda	bitlen
	xba
	sep	#$20	; 8-bit accumulator
	lda	temp3
	lsr	a
	rep	#$21	; 16-bit accumulator, clear carry
	sta	[wrkbuf],y
	lda	hufbse
	adc	hufcde


	sta	>$002100

	sta	hufcde
	lda	bitlen
	ldy	temp3
	plx
makehuff8	iny
	iny
	dex
	bne	makehuff4
	lsr	hufbse
	inc	bitlen
	cmp	#16
	bne	makehuff3
	rts




Colors:

	; 4 color plane colors

	; cyan
	dc.w	$0000,$E87F,$C45A,$8039 

	;grey
	dc.w	$0200,$FF7F,$D65A,$8C31 
 

	; orange

	dc.w	$0200,$FF03,$D602,$CE01 
 

	; purple

	dc.w	$0200,$1F59,$9A48,$1638 
 

	; atx colors (sky blue)

	dc.w	$0000,$1C53,$5A7F,$8030,$C230,$0439,$4641,$8849
	dc.w	$CA51,$0C5A,$105A,$5262,$946A,$D672,$187F,$5A7F 
 
	; atx colors (lake grey)

	dc.w	$0000,$1C53,$5A7F,$4218,$8420,$C628,$0831,$4A39
	dc.w	$8C41,$CE49,$1052,$525A,$9462,$D66A,$1873,$5A7F 
 


	; font colors 
	;                   Gold

	dc.w	$0000,$FF7F,$FF1B,$DA12,$D409,$1009,$8C00,$4800 
	dc.w	$0000,$FF7F,$FF1B,$DA12,$D409,$1009,$8C00,$4800
 


	;                   blue
	dc.w	$0000,$E47F,$447F,$8272,$C059,$0049,$8030,$0020 
 	dc.w	$0000,$E47F,$447F,$8272,$C059,$0049,$8030,$0020

	;                   green

	dc.w	$0000,$E003,$E003,$4003,$C002,$0002,$4001,$8000 
	dc.w	$0000,$E003,$E003,$4003,$C002,$0002,$4001,$8000


	;		    red

	dc.w	$0000,$1F28,$1C20,$1818,$1410,$1008,$0E00,$0A00 
 	dc.w	$0000,$1F28,$1C20,$1818,$1410,$1008,$0E00,$0A00


	;		    silver

	dc.w	$0000,$FF7F,$9A7F,$5873,$166B,$D462,$925A,$5052
	dc.w	$0E4A,$CC41,$8A39,$4831,$0629,$C420,$8218,$4010 

	;			; green


	;		sprite colors
	;                   red
	dc.w	$0000,$DC5A,$9C52,$1A42,$9A39,$5A31,$1829,$D820
	dc.w	$9818,$5810,$1608,$1400,$1200,$0E00,$0A00,$0600 
	;		 blue
	dc.w	$0000,$DC5A,$9A5A,$165A,$D259,$9059,$4C59,$C858
	dc.w	$8658,$4258,$0058,$0050,$0040,$0038,$0028,$0018 
	;                gold
	dc.w	$0000,$FF03,$FF03,$FA03,$F803,$1603,$9202,$D001
	dc.w	$4E01,$8C00,$8A00,$4800,$4800,$0600,$0400,$0400 
 	;                 green
	dc.w	$0000,$DC5A,$9A52,$964A,$923A,$5032,$4C2A,$081A
	dc.w	$0612,$C209,$C001,$8001,$8001,$4001,$0001,$C000 
	;		grey

	dc.w	$0000,$DC5A,$9A5A,$5852,$564A,$1442,$D039,$8E31
	dc.w	$4C29,$4A29,$0821,$C618,$C618,$8410,$4208,$4208 

	;		purblue

	dcr.w	$0000,$5F7F,$DF72,$5F72,$DF69,$5C61,$D660,$9258
	dcr.w	$0E58,$0850,$0450,$0240,$0038,$0030,$0028,$0020 
 
	;		purple

	dc.w	$0000,$DC5A,$9A5A,$1852,$D649,$9441,$5039,$CE30
	dc.w	$8C28,$4A28,$4820,$0818,$0618,$0610,$0410,$0408 
 	;                yellow

	dc.w	$0000,$DC5A,$9A52,$9A4A,$983A,$5632,$542A,$121A
	dc.w	$1212,$D009,$CE01,$8C01,$8C01,$4A01,$0801,$C600 



randomnumbers:
	dc.w	$3AA7,$3ECB,$3A50,$9684,$6807,$6DBA,$0FA0
	dc.w	$C455,$722F,$3280,$630A,$A402,$244E,$3FF7,$FBB5
	dc.w	$83F4,$7210,$2165,$6688,$1248,$516B,$43BB,$E409
	dc.w	$656A,$7144,$7525,$C2AE,$E455,$B7A9,$9087,$5E33
	dc.w	$8C23,$072A,$33B1,$A61E,$1989,$E1AA,$FC54,$8A0B
	dc.w	$1722,$1FEE,$9226,$079B,$68D5,$1090,$FEC8,$3B4C
	dc.w	$10DA,$EF06,$A471,$46B7,$4D47,$1984,$3F3F,$FC58
	dc.w	$D0E2,$B601,$ECF3,$5647,$4113,$738B,$305F,$914A
	dc.w	$8665,$420B,$D45B,$8825,$F3B6,$F2C1,$ABEF,$96CA
	dc.w	$4BD7,$A1D4,$8D0C,$A6B1,$EF4C,$033E,$8FAF,$CE49
	dc.w	$4975,$72FD,$9552,$1366,$3FBE,$67F9,$61BF,$307C
	dc.w	$2B57,$0FBF,$05C1,$FAA3,$0E8E,$DA0D,$6BDA,$E101
	dc.w	$DF3D,$CBF2,$8C3A,$0D97,$BED5,$FAD5,$30D9,$361D
	dc.w	$9C81,$3C27,$5BBD,$45EE,$2C62,$8B21,$5424,$1976
	dc.w	$3D5B,$3778,$7599,$3EB8,$6A92,$3C30,$BF88,$2F27
	dc.w	$ABE4,$C50F,$256F,$15AF,$FB7C,$BF5C,$3407,$DCCE
	dc.w	$361A
 


sine:



	dc.w	$0004,$0A0E,$1318,$1D21,$2529,$2D31,$3538,$3C3E
	dc.w	$4143,$4648,$494A,$4B4C,$4C4C,$4C4C,$4B4B,$4948
	dc.w	$4744,$4341,$3E3C,$3936,$3330,$2D2A,$2724,$211E
	dc.w	$1B18,$1513,$100D,$0B09,$0705,$0403,$0101,$0000
	dc.w	$0000,$0001,$0203,$0406,$0709,$0B0E,$1012,$1518
	dc.w	$1B1E,$2124,$272A,$2D30,$3336,$393B,$3E40,$4345
	dc.w	$4648,$4A4B,$4C4C,$4D4D,$4D4C,$4C4B,$4A48,$4644
	dc.w	$423F,$3C39,$3632,$2E2A,$2622,$1D19,$140F,$0B05
	dc.w	$01FC,$F7F3,$EEE9,$E4E0,$DBD7,$D4CF,$CCC9,$C5C2
	dc.w	$C0BD,$BBB9,$B8B6,$B5B4,$B4B3,$B3B4,$B4B5,$B7B8
	dc.w	$BABB,$BEC0,$C2C4,$C7CA,$CCD0,$D3D6,$D9DC,$DFE2
	dc.w	$E5E8,$EAED,$F0F2,$F4F7,$F8FA,$FCFD,$FEFF,$0000
	dc.w	$0000,$00FF,$FEFE,$FCFB,$F9F7,$F5F3,$F1EE,$EBE8
	dc.w	$E6E3,$E0DD,$D9D6,$D3D0,$CDCA,$C8C5,$C2C0,$BEBC
	dc.w	$B9B8,$B7B5,$B4B3,$B3B3,$B3B3,$B4B5,$B6B8,$BABC
	dc.w	$BEC0,$C3C6,$CACD,$D1D5,$D9DD,$E2E6,$EBF0,$F5FA 
 

 


YES:	dc.b	"YES"

NO:
	dc.b	"NO "

LOW:
	dc.b	0,0,0,0
	dc.b	0,0,0,1
	dc.b	0,0,0,2
	dc.b	0,0,0,3
	dc.b	0,0,0,4
	dc.b	0,0,0,5
	dc.b	0,0,0,6
	dc.b	0,0,0,7
	dc.b	0,0,0,8
	dc.b	0,0,0,9
	dc.b	0,0,1,0
	dc.b	0,0,1,1
	dc.b	0,0,1,2
	dc.b	0,0,1,3
	dc.b	0,0,1,4
	dc.b	0,0,1,5
	
HIGH:
	dc.b	0,0,0,0
	dc.b	0,0,1,6
	dc.b	0,0,3,2
	dc.b	0,0,4,8
	dc.b	0,0,6,4
	dc.b	0,0,8,0
	dc.b	0,0,9,6
	dc.b	0,1,1,2
	dc.b	0,1,2,8
	dc.b	0,1,4,4
	dc.b	0,1,6,0
	dc.b	0,1,7,6
	dc.b	0,1,9,2
	dc.b	0,2,0,8
	dc.b	0,2,2,4
	dc.b	0,2,4,0

stargfx:
	;.bin	star.dat

atxlogo:
	;.bin	atxlogo.dat
atxchar:
	.bin	atxlogo.char
font:
	;.bin	font.dat
scrollfont:
	;.bin	scrollfont.dat
textfont:
	;.bin	4color.dat


packedgfx:
	.bin	gfx.rnc





MOFF	equ	$0200	;stop music 
MBONUS	equ	$0201	;timer bonus countdown
MCHEAT	equ	$0202	;cheat mode enabled
MCLICK	equ	$0203	;button click
MOVER	equ	$0204	;game over/time up
MTRING	equ	$0205	;tring for startup of the wildcard
MSOLVED	equ	$0206	;puzzle solved tune
MTUNE	equ	$0207	;New tune....
MWINDOW	equ	$0208	;Open selection window
MSELECT	equ	$0209	;Move cursor up and down
MRESET	equ	$0400	; reset the music controller

tune	rep #$30
	;lda #MTUNE
	lda	#MBONUS
	jsr NewSound_l
	sep #$20
 	rts

tuneoff:
	rep	#$30
	lda	#MRESET
	jsr	NewSound_l
	sep	#$20
	rts


	rep 	#$30
NewSound_l 	
	ora	toggle 
	sta	>$002140 
	lda	toggle 
	eor	#$0100 
	sta	toggle 
	rts


musique:
	
	rep	#$30
	stz	toggle

 	sep	#$20
	lda	#$7f
	sta $a5 
	lda #00 
	sta $a4 
	sta $a3 
 

	php       
	rep     #$30  
	ldy     #$0000  
	lda     #$bbaa  
L00f7b6 cmp     >$002140 
	bne     L00f7b6  
	sep     #$20  
	lda     #$cc  
	bra     L00f7f5 
L00f7c1 lda     [$a3],y  
	iny       
	bpl     L00f7cb		; check for bank overflow 
	ldy     #$0000 		; if so, zero y 
	inc     $a5		; and inc work reg bank 
L00f7cb xba       
	lda     #$00  
	bra     L00f7e2 
L00f7d0 xba       
	lda     [$a3],y  
	iny       
	bpl     L00f7db    	; check for bank overflow 
	ldy     #$0000		; if so, zero y 
	inc     $a5 		; and inc work reg bank 
L00f7db xba       
L00f7dc cmp     >$002140 
	bne     L00f7dc  
	inc     a  
L00f7e2 rep     #$20  
	sta     >$002140 
	sep     #$20  
	dex       
	bne     L00f7d0  
L00f7ec cmp     >$002140 
	bne     L00f7ec  
L00f7f1 adc     #$03  
	beq     L00f7f1  
L00f7f5 pha       
	rep     #$20  
	lda     [$a3],y  
	iny       
	iny       
	tax       
	lda     [$a3],y  
	iny       
	iny       
	sta     >$002142 
	sep     #$20  
	cpx     #$0001  
	lda     #$00  
	rol     a  
	sta     >$002141 
	adc     #$7f  
	pla       
	sta     >$002140 
L00f815 cmp     >$002140 
	bne     L00f815  
	bvs     L00f7c1  
	plp       
	sep     #$30  
	rts     




music:
	.bin	atxchip2.rnc




bottext:

		;********************************
	text	$00,"     Intro Coded By: -Pan-      "
	text	$00," Music Composed By: The Doctor  "

	text	$04,"       U.S.S. Enterprise        "
	text	$04,"  412-233-2611  Sysop: Picard   "

	text	$08,"     Intro Coded By: -Pan-      "
	text	$08," Music Composed By: The Doctor  "

	text	$0c,"           Trade Line           "
	text	$0c," 514-838-9651 Sysop: Wild Fire  "

	text	$00,"     Small Vegetable Patch      "
	text	$00," +44-1619452712 Sys: Mad Turnip "

	text	$04,"            Dial Hard           "
	text	$04,"  +41-7350-0155   Sysop: Fury   "

	text	$08,"            Vengence            "
	text	$08," +61-Pri-vate Sysop: The Cause  "

	text	$0c,"             Synergy            "
	text	$0c," +49-PRIVATE Sysop: Sigma Seven "


gameover:
	rep	#$30
	sep	#$20
	ldx	#$0000
copycheatdata:
	lda	$1c00,x
	sta	>$700000,x
	inx
	cpx	#$0020
	bne	copycheatdata

	sep	#$30
	lda	#$00
	phk
	plb
	dc.b	$5c,$54,$80,$00		: <- jump to game!!


menutxt:
	
	dc.b	"   Unlimited Lives:      Yes    "
	dc.b	"   Unlimited Health:     Yes    "
	dc.b	"   Unlimited Shout:      Yes    "
	dc.b	"   Invincibilty:         Yes    "
	dc.b	"   999 Bones:            Yes    "
	dc.b	"   Unlimited Credits:    Yes    "
	dc.b	"   In-Game Weapon Sel:   Yes    "
	dc.b	"     Press Select In Game       "
	dc.b	"       To change weapons        "
	dc.b	"                                "
	dc.b	"                                "
	dc.b	"                                "
	dc.b	"                                "
	dc.b	"                                "
	dc.b	"    trained by -pan- and twk    "
	dc.b	"                                "





scrtxt:
	dc.b	"knock knock!! -Pan-'s here and busting loose with another "
	dc.b	"head crunching trainer... this time it's p-man plus 7! "
	dc.b	" trained on September 18 - 1995     the first -pan- trainer "
	dc.b	"in the anthrox-swat co-op and only 5 days after my 23rd birthday!  "
	dc.b	"greetings to everyone, sorry.. no time to make a list right now but i'll "
	dc.b	"get yas in the next one - i promise!!          cya!       "	
	dc.b	"        ",0



options:
	dc.b	7		;<- # of options
Type:                              
        dc.b    0,0,0,0,0,0,0,0,0,0,0,0,1  
                                   
Min:                               
        dc.b    1,1,1,0,0,1,1,1,3,0,0,0,1
                                   
Max:                               
        dc.b    9,9,5,$ff,5,6,1,1,1,1,1,1,12 
                                   
Begin:                             
        dc.b    2,2,4,0,0,1,1,1,3,0,0,0,1  



Slow:
	php
	sep	#$30
	dc.b	$af,$00,$00,$70
	and	#$01
	eor	#$01
	sta	$420d
	plp
	rtl



Cheat:
	dc.b	$ad,$18,$42
	dc.b	$85,$7a
	pha
	php
	sep	#$30
	dc.b	$af,$01,$80,$70
	beq	Livesoff
	lda	#$09
	sta	$1da1
	sta	$1da3
Livesoff:
	dc.b	$af,$02,$80,$70
	beq	Damage
	lda	#$0a
	sta	$1d09
	sta	$1d0b

Damage:
	;dc.b	$af,$03,$80,$70
	;beq	noammo
	;lda	#$99
	;sta	$1096
noammo:
	dc.b	$af,$03,$80,$70
	beq	nohyper
	lda	#$01
	sta	$1db1
	sta	$1db3

nohyper:
	dc.b	$af,$04,$80,$70
	beq	nothingy
	lda	#$01
	dc.b	$8f,$e0,$65,$7e
nothingy:
	;dc.b	$af,$05,$80,$70
	;beq	nojumpy
	;rep	#$30
	;dc.b	$a5,$7a
	;cmp	#$2020
	;bne	nojumpy
	;stz	$7a
	;sep	#$20
	;stz	$1e05

nojumpy:
	sep	#$20
	
	plp
	pla
	rtl
Time1:

	php
	sep	#$20
	dc.b	$af,$03,$80,$70
	beq	timeoff
	plp
	dc.b	$5c,$ab,$89,$01
	rtl
timeoff:
	plp
	dc.b	$a9,$e5,$04
	dc.b	$85,$e9
	dc.b	$5c,$9f,$89,$01
	;rtl
LEVEL:

	lda	$1a03
	bne	levelhere2
	bra	levelhere
levelthing:
	dc.b	$5c,$7d,$9e,$1d


levelhere:
	php
	rep	#$30
	dc.b	$af,$0c,$00,$70
	and	#$00ff
	dec a
	asl a
	asl a
	asl a
	sta	>$7e1a03
	plp
	lda	>$7e1a03
	beq	levelthing
	dc.b	$5c,$95,$9e,$1d

levelhere2:
	lda	$7e1a03
	dc.b	$5c,$95,$9e,$1d
	rtl

leveljunk:
	dcr.w	$8,$b,$14,$1d,$29,$33

IRQ:
	;dc.b	$ee,$c6,$ec
	;dc.b	$af,$10,$42,$00
	pha
	php
	sep	#$20
	dc.b	$af,$00,$00,$70
	beq	IRQnrg
	lda	#$03
	sta	>$7e0556
IRQnrg:
	dc.b	$af,$01,$00,$70
	beq	IRQtime

	lda	#$03
	sta	>$7e0558
	sta	>$7e0572
IRQtime:
	dc.b	$af,$02,$00,$70
	beq	IRQinvul
	lda	#$0a
	sta	>$7e056c
	sta	>$7e056e
IRQinvul:
	dc.b	$af,$03,$00,$70
	beq	irqbones
	lda	#$77
	sta	>$7e00b6
irqbones:
	dc.b	$af,$04,$00,$70
	beq	irqcred
	lda	#$99
	sta	>$7e0560
	lda	#$09
	sta	>$7e0561
irqcred:
	dc.b	$af,$05,$00,$70	
	beq	irqweap
	lda	#$10
	sta	>$7e008c

irqweap:
	dc.b	$af,$06,$00,$70
	beq	IRQend

	dc.b	$af,$ff,$00,$70
	inc a
	and	#$03
	dc.b	$8f,$ff,$00,$70
	bne	IRQend

	lda	$1f97
	cmp	#$20
	bne	IRQend

	dc.b	$af,$fe,$00,$70
	inc a
	and	#$03
	dc.b	$8f,$fe,$00,$70
	asl a
	sta	>$7e07ba
	lda	#$00
	sta	>$7e07bb
	
	


IRQend:
	plp
	pla



	dc.b	$5c,$9d,$94,$82


	rtl


	lda	>$7e1776
	ora	>$7e1778
	cmp	#$20
	beq	selectison
	plp
	pla
	rtl
selectison:

	lda	>$7e1775
	ora	>$7e1777
	and	#$20
	cmp	#$20
	bne	nolevelskippy
	sep	#$30
	;lda	>$7e0039
	lda	>$7e003a
	cmp	#$ff
	bne	nolevelskippy

	phx
	ldx	#$fe
levelloop:
	inx
	inx
	cpx	#$4c
	beq	forgetitall
	lda	>$0084f2,x
	cmp	>$7e003b
	bne	levelloop
	inx
	inx
	lda	>$0084f2,x
	sta	>$7e0039
	lda	#$00
	sta	>$7e003a
	plx	
	plp
	pla
	rtl

forgetitall:
	ldx	#$4e
	lda	>$0084f2,x
	sta	>$7e0039
	lda	#$00
	sta	>$7e003a
	plx
	plp
	pla
	rtl

nolevelskippy:
	lda	>$7e1775
	ora	>$7e1777
	and	#$10		; 10
	cmp	#$10
	bne	nodooropen
	lda	#$00
	sta	>$7e0024
	plp
	pla
	rtl

nodooropen:
	lda	>$7e1775	; 6
	and	#$80		; 80
	cmp	#$80
	bne	noitemsel1
	
	lda	>$70000f
	inc a
	and	#$07
	sta	>$70000f
	bne	noitemsel1


	lda	>$7e006d
	inc a
	inc a
	cmp	#$0c
	bcs	item1over
	sta	>$7e006d
	plp
	pla
	rtl

item1over:
	lda	#$00
	sta	>$7e006d
	plp
	pla
	rtl

noitemsel1:

	lda	>$7e1777
	and	#$80
	cmp	#$80
	bne	noitemsel2

	lda     >$70000f  
	inc a             
	and     #$07      
	sta     >$70000f  
	bne     noitemsel2


	lda	>$7e006f
	inc a
	inc a
	cmp	#$0c
	bcs	item2over
	sta	>$7e006f
	plp
	pla
	rtl

item2over:
	lda	#$00
	sta	>$7e006f
noitemsel2:
	plp
	pla
	rtl





	org	$fffc	;reset vector in 6502 mode
	dcr.w	Start
	.pad

