;******************* Final.asm *************************
			extend
;-----------------------------------------------------
			include		../join/rp5c77
			include		../join/buffer.def
			include		../join/rp5a22
			include     ../join/work.def
			include		../join/label.def
			include		../join/object.def
;-----------------------------------------------------
			ext		Set_DMA,PPU_INT_SET,Rotate_mode7
			ext		KEY_CHECK,Trigger_sound_1,BGM_fade_out
			ext		Back_up_set,Set_4bit_mode1
;
			glb		Final_init,Final_main,Final_nmi
			glb		OBJ_ERASE,X_inx,Y_iny,Rank_Check_sum
			glb		Rank_Check,Color_Set_sub,Upper_body_set
			glb		Upper_body_set2,Banzai_Set_everyone
;-----------------------------------------------------
addr			equ		60h			;3byte
Pose_counter	equ		63h
Pose_timer		equ		65h
Pose_flag		equ		67h
button_TG       equ     6ah  		;4byte
Fight_counter	equ		6eh
;
Set_address		equ		70h
Scroll_X		equ		72h			;3byte
Center_X		equ		75h
Move_flag		equ		77h
Patern_counter	equ		79h
Cmp_check		equ		7bh
Angle_set		equ		7dh
Zoom_set		equ		7fh
;
Center_Y		equ		81h			;3byte
Scroll_Y		equ		84h
revolve_flag	equ		86h
Scroll_speed	equ		88h
MAKU_counter	equ		8ah
maku_flag		equ		8ch
Champgne_timer	equ		8eh
;
Maku_position	equ		92h
OBJ_check_flag	equ		96h
MAKU_move_flag	equ		98h
MAKU_speed_cmp	equ		9ah
Pukupuku_flag	equ		9ch
pukupuku_speed	equ		9eh
;
X_cmp			equ		198h
Rom_offset		equ		19ah
Zannen_counter	equ		19ch
Zannen_timer	equ		19eh
;
Fight_timer		equ		1a0h
Explosion_count	equ		1a2h
Explosion_timer	equ		1a4h
Cork_place		equ		1a6h
Award_counter	equ		1a8h
Fall_cup		equ		1aah
Shock_flag		equ		1ach
kumo_flag		equ		1aeh
;
Message_counter	equ		1b0h
Message_timer	equ		1b2h
Message_position equ	1b4h
yossy_flag		equ		1b6h
Color_timer		equ		1b8h
Fit_cmp			equ		1bah
Start_position	equ		1bch
Zannen_V_ram	equ		1beh
;
Set_color		equ		1f0h
Turu_counter	equ		1f2h
pukupuku_hanten	equ		1f4h		
pukupuku_count	equ		1f6h
Explosion_head	equ		1f8h
kage_flag		equ		1fah
;
Fall_bin		equ		1e0h
Width_throw		equ		1e2h
Width_timer		equ		1e4h
Catch_timer		equ		1e6h
Flying_sound_count	equ		1e8h
jmp_H_timer		equ		1ech
Rom_address		equ		1eeh
;
Maku_zoom_set	equ		1900h
Change_flag		equ		1902h
paper_counetr	equ		1904h
paper_timer		equ		1906h
Fall_acceleration	equ		1908h
fall_paper			equ		1938h
Width_fall			equ		1968h
Width_add			equ		1998h
oam_paper_address	equ		19c8h
paper_fall_data		equ		19cah
H_dma_flag			equ		19cch
Hanten_cmp			equ		19ceh
Hanten_cmp1			equ		19d0h
;-----------------------------------------------------
Hdma_data		equ		180h
oamdat			equ		200h
msbdat			equ		400h
Color_buffer	equ		1c0h
;
rotate_A		equ		190h
rotate_B        equ     192h
rotate_C        equ     194h
rotate_D        equ     196h
;
Kage_window_init	equ		1800h
Kage_window_set		equ		1840h
Kage_cmp_dataset	equ		1860h
Banzai_counter		equ		18f0h
;
Special_Cup     equ     3067f5h
;-----------------------------------------------------
bank85      		sect    rel         ;(PBR=85)
;===================================================================
;*******************************************************************
;					INITIAL ROUTINE
;*******************************************************************
;===================================================================
Final_init		equ		$
				phb
				phk
				plb
;
				stz		<trans_counter

				lda		#016CH
				sta		!player_r0+30h
				sta		!player_r1+30h
				sta		!player_r2+30h
				sta		!player_r3+30h
				sta		!player_r4+30h
				sta		!player_r5+30h
				sta		!player_r6+30h
				sta		!player_r7+30h
;
				mem8
				idx8
				sep		#00110000b
;
				JSL     >PPU_INT_SET         ;ppu&oam initial
				JSL		>Final_PPU
				JSR		Final_tensou
;
				mem16
				idx16
				rep		#00110000b
;
				JSL		>Back_up_set
;
				plb
				RTL
;
;=================================================================
;*****************************************************************
;					MAINE ROUNTINE
;*****************************************************************
;=================================================================
Final_main		equ		$
				phb
				phk
				plb
;<<<<<<<<<<<<<<<<< タイマーセット >>>>>>>>>>>>>>>
				inc		<Champgne_timer						;１位の人用タイマー
				lda		<Champgne_timer
				cmp		#0700h
				bne		Set_MAINE
				lda		#0600h
				sta		<Champgne_timer
;<<<<<<<<<<<<<<<< ボタンチェック >>>>>>>>>>>>>>>>>
Set_MAINE		JSR     KEY_CHECK
;<<<<<<<<<<<<<<<< 表彰セット >>>>>>>>>>>>>>>>>>>>>
				JSR		AWARD_SET
;<<<<<<<<<<<<<<<< ４位以上チェック >>>>>>>>>>>>>>
				JSR		Rank_Check
				cpx		#0006h
				bcc		AWARD_routine
;<<<<<<<<<<<<<<<<< 残念セット >>>>>>>>>>>>>>>>>>>>
				JSR		Message_set
				JSR		Zannen_pose
				jmp		owari_main
;<<<<<<<<<<<< 幕だしタイマーチェック >>>>>>>>>>>>>
AWARD_routine	lda		<Champgne_timer
				cmp		#0350h
				bcc		Check_rank_set		
				JSR		MAKU_zoom
				jmp		owari_main
;<<<<<<<<<<<<<< ランクチェック >>>>>>>>>>>>>>>>>>>
Check_rank_set	JSR		Rank_Check				
				jmp		(!Select_rank,x)				;ランクインデックスジャンプ
;<<<<<<<<<<<<<<< ランク１ >>>>>>>>>>>>>>>>>>>>>>>>
Rank_1			JSR     Pukupuku_1
				JSL		>KAGE_move
				JMP		owari_main
;<<<<<<<<<<<<<<< ランク2 >>>>>>>>>>>>>>>>>>>>>>>>>
Rank_2			equ		$
				JSR		Pukupuku_2
				JSL     >Set_kage
				JMP     owari_main
;<<<<<<<<<<<<<<< ランク3 >>>>>>>>>>>>>>>>>>>>>>>>>
Rank_3			equ		$
				JSR		Pukupuku_3
				JSL     >Set_kage
;<<<<<<<<<<<<<<< 雲スクロールセット >>>>>>>>>>>>>>
owari_main		JSR		KUMO_move
				JSR		Paper_fall_set
				JSR		Final_end_set
				plb
				RTL
;================================================================
;***************************************************************
;					NMI wari komi.			  
;***************************************************************
;================================================================
Final_nmi			equ		$
				phb
				phk
				plb
;
				mem8
				sep		#00100000b
;
			 	lda		#00000000b			
				sta		Color_address
;
				ldx		#4800h
				ldy		#0
loop_color_1	JSR		Color_Set_sub			
			 	cpy		#0040h
			 	bne		loop_color_1
;
				mem8
				idx8
				sep		#00110000b
;<<<<<<<<<<<<<< スクロールセット >>>>>>>>>>>>>>>>>>
				lda		<Scroll_X+1
				sta     Scroll_0H
				lda		<Scroll_X+2
				sta     Scroll_0H
;
				lda     <Scroll_Y
				sta     Scroll_0V
				lda     <Scroll_Y+1
				sta     Scroll_0V
;<<<<<<<<<<<<<<< 拡大縮小、回転セット >>>>>>>>>>>>>>
				lda		rotate_A
				sta		Rotation_A
				lda		rotate_A+1
				sta		Rotation_A
;
				lda		rotate_B
				sta		Rotation_B
				lda		rotate_B+1
				sta		Rotation_B
;
				lda		rotate_C
				sta		Rotation_C
				lda		rotate_C+1
				sta		Rotation_C
;
				lda		rotate_D
				sta		Rotation_D
				lda		rotate_D+1
				sta		Rotation_D
;<<<<<<<<<<<<<<<< センターセット >>>>>>>>>>>>>>>>>>>>
				lda		<Center_X
				sta		Rotation_X
				lda		<Center_X+1
				sta     Rotation_X
;
				lda		<Center_Y
				sta     Rotation_Y
				lda     <Center_Y+1
				sta		Rotation_Y
;<<<<<<<<<<<<<<<<< Ｈ−ＤＭＡセット >>>>>>>>>>>>>>>>>
				lda		H_dma_flag
				sta     DMA_synchronic
;<<<<<<<<<<<<<<<< ４位以上チェック >>>>>>>>>>>>>>
				mem16
				idx16
				JSR		Rank_Check
				cpx		#0006
				bcs		owari_nmi_set
				mem8
				idx8
				sep		#00110000b
;<<<<<<<<<<<<<<<< カラー書き換えセット >>>>>>>>>>>>>>
				lda		#28h
				sta		Color_address
;
				ldx		#10h
color_change	lda		Color_buffer,x
				sta     Color_write
				inx
				lda		Color_buffer,x
				sta     Color_write
				inx
				cpx		#20h
				bne		color_change		
;<<<<<<<<<<<<< 幕出し、タイマーチェック >>>>>>>>>>>>>
				mem16
				idx16
				rep		#00110000b
				lda		<Champgne_timer
				cmp		#0350h
				bcs		maku_nmi
;<<<<<<<<<<<<<<<< 書き換え用 >>>>>>>>>>>>>>>>>>>>>>>>
Pukupuku_nmi	JSR		Pukupuku_tensou		;１,2,3位
				jmp		owari_nmi_set
;
maku_nmi		JSR		MAKU_tensou			
owari_nmi_set	plb
				rtl
;<<<<<<<<<< ランクチェックサブルーチン >>>>>>>>>>>>>>
Rank_Check		equ		$
				mem16
				idx16
				rep		#00110000b
				ldx		#0
				lda		game_mode			;プレイヤーチェック
				beq		Check_rank2p
				cmp		#0004
				beq		Check_rank_2con
;
Check_rank		lda		point_rank,x		;一人用ランクセット
				cmp		#1000h				;１コントローラー
				beq		owari_rank_chk
				inx
				inx
				jmp		Check_rank
;
Check_rank_2con	lda		point_rank,x		;一人用ランクセット
				cmp		#1100h				;2コントローラー
				beq		owari_rank_chk
				inx
				inx
				jmp		Check_rank_2con

Check_rank2p	lda		point_rank,x		;二人用ランクセット
				cmp		#1000h
				beq		owari_rank_chk
				cmp		#1100h
				beq		owari_rank_chk
				inx
				inx
				jmp		Check_rank2p
owari_rank_chk	rts
;
Rank_Check_sum	phb
				phk
				plb
				JSR		Rank_Check
				plb
				rtl
;===================================================================
;******************************************************************
;						INITIAL SET ROUTINE
;******************************************************************
;==================================================================
;**********************************************************
;					TENSOU SET
;**********************************************************
Final_tensou	equ		$
				mem8
				idx8
;<<<<<<<<<<<<<<<<<<<<< OBJ >>>>>>>>>>>>>>>>>>>>>>>>>>
				ldx		#1ch
				jsr     Set_DMA
;<<<<<<<<<<<<<<<<<<<< 文字ＣＧＸ >>>>>>>>>>>>>>>>>>>>
 				ldx		#22h
				jsr		Set_DMA
;<<<<<<<<<<<<<<<<<<<<<< SC_2.CGX >>>>>>>>>>>>>>>>>>>>
				ldx		#1eh
				jsr     Set_DMA
;<<<<<<<<<<<<<<<<<<<<<< SC_2 >>>>>>>>>>>>>>>>>>>>>>>>
				ldx		#20h
				jsr		Set_DMA
;<<<<<<<<<< 上半身ＯＢＪキャラクターセット >>>>>>>>>>
				idx16
				mem16
				rep		#00110000b
				JSR		Upper_body_set
				jmp		CG_set
;
Upper_body_set
				lda		#5400h					;マリオセット
				ldx		#0
				ldy		#0
				JSR		Kart_set
;
				lda		#5600h					;ルイージセット
				ldx		#0003h
				ldy     #0004h
				JSR		Kart_set
;
				lda		#5440h					;クッパセット
				ldx		#0006h
				ldy     #0
				JSR     Kart_set
;
				lda		#5480h					;ピーチセット
				ldx		#0009h
				ldy     #0
				JSR		Kart_set
;
				lda		#54c0h					;コングセット
				ldx		#000ch
				ldy     #0
				JSR		Kart_set
;
				lda		#5640h					;ノコノコセット
				ldx		#000fh
				ldy     #0
				JSR		Kart_set
;
				lda		#5680h					;キノピヨセット
				ldx		#0012h
				ldy     #0
				JSR		Kart_set
;
				lda		#56c0h					;ヨッシー
				ldx		#0015h
				ldy     #0
  				JSR		Kart_set
				rts
;												A=V-RAM アドレス		
;												X=ROM先頭アドレス
;												Y=OFF_set ROMアドレス
;<<<<<<<<< 上半身キャラクターセットサブルーチン >>>>>>
Kart_set		equ		$
				pha
				sta		Screen_address
;
				JSR		Rom_Set
;
				sty		Rom_address
				mem16			
				rep		#00100000b
				lda		Rom_select_0,y			;ノーマルポーズ上側
				JSR		Kart_V_set
;
				ldy		Rom_address
				lda		Rom_select_0+2,y		;Ｖポーズ上側
				JSR		Kart_V_set
;
				pla								;ＶＲＡＭアドレスセッ
				clc
				adc		#100h
				sta		Screen_address
;
				ldy     Rom_address
				lda		Rom_select_1,y
				JSR		Kart_V_set
;
				ldy     Rom_address
				lda		Rom_select_1+2,y		;Ｖポーズ下側
				JSR		Kart_V_set
				rts
;	
Set_Vram		equ		$						;ＶＲＡＭセット
				mem16
				idx16
loop_kao		lda		[<addr],y
				sta		Screen_write
				iny
				iny
				rts
;
Rom_Set			mem16
				idx16
				lda		OBJ_kart,x				;ＲＯＭアドレスセット
				sta		<addr
				mem8
				sep		#00100000b
				inx
				inx
				lda		OBJ_kart,x
				sta		<addr+2
				rts
;
Kart_V_set		equ		$
				tay
				ldx		#0
loop_kart		JSR		Set_Vram
				inx
				inx
				cpx		#0040h
				bne		loop_kart
				rts
;
Rom_select_0	DW		0040h,5900h,0040h,2100h
Rom_select_1    DW      0240h,5b00h,0240h,2300h
;<<<<<<<<<<<<<< カラー転送 >>>>>>>>>>>>>>>>>>>>>>>>
CG_set			mem8
				sep		#00100000b
			 	lda		#00000000b			
				sta		Color_address
;
				ldx		#4800h
				ldy		#0
loop_color		JSR		Color_Set_sub			
			 	cpy		#200h
			 	bne		loop_color
;<<<<<<<<<<<<<<<<< 順位チェック >>>>>>>>>>>>>>>>>>>
				JSR		Rank_Check
				cpx		#0006
				bcs		Set_mode7
;<<<<<<<<<<<<<<<< 幕用カラー書き換えセット >>>>>>>>>>>>
Set_maku_color	phx
				mem8
				sep		#00100000b
				lda		#20h
				sta		Color_address
;
				mem16
				rep		#00100000b
				ldy		#0000
				lda		CG_Address,x
				tax
				mem8
				sep		#00100000b
loop_change		lda		>7f0000h,x
				sta     Color_write
				sta		Color_buffer,y
				inx
				iny
				lda		>7f0000h,x
				sta     Color_write
				sta		Color_buffer,y
				inx
				iny
				cpy		#0020h
				bne		loop_change		
				plx
;<<<<<<<<<<<<<< カップ用カラー書き換えセット >>>>>>>>>>>>
				lda		#0f4h
				sta		Color_address
;
				mem16
				rep		#00100000b
				ldy		#0
				lda		Cup_color_address,x
				tax
loop_change_1	JSR		Color_Set_sub				
				cpy		#0006h
				bne		loop_change_1
;
;<<<<<<<<<<<<< モード７キャラクター転送 >>>>>>>>>>>
Set_mode7		mem8
				sep		#00100000b
				stz     Screen_address
				stz     Screen_address+1
;
				ldx		#0
loop_chra		lda		>7fc000h,x
				sta     Screen_write+1
				inx
				cpx		#4000h
				bne		loop_chra
;<<<<<<<<<<<<<< ＢＧ１ぬきセット >>>>>>>>>>>>>>>>>
				stz     Screen_address
				stz     Screen_address+1
;
				lda     #00000000b
				sta     Screen_step
;
				ldx		#0
				lda		#06fh
loop_nuki		sta		Screen_write
				inx
				cpx		#4000h
				bne		loop_nuki
;;<<<<<<<<<<<<<<<< ＯＡＭセット >>>>>>>>>>>>>>>>>>>
				idx16
				mem16
				rep		#00110000b
;--------(ビン セット)------------
				lda		#0ae6eh
				sta		oamdat+168h
				lda		#3ce4h
				sta		oamdat+16ah
;----------(表彰用)------------
				JSR     Banzai_award		
;----------(雲セット)-----------
				ldy		#0
				ldx		#0							
Set_obj_2		lda		KUMO_data,y
				sta		oamdat+1e8h,x
				iny
				iny
				JSR		X_inx
				cpx		#0018h
				bne		Set_obj_2
;
				ldy		#0
				lda		world_number
				cmp		#0003
				beq		Special_kumo
				asl		a
				tax
				lda		Select_kumo,x
loop_kumo_set	sta		oamdat+1eah,y
				JSR		Y_iny
				cpy		#0018h
				bne		loop_kumo_set	
				jmp		SET_MSB
;
Special_kumo	ldx		#0
loop_kumo_set1	lda		Select_kumo,x
				sta		oamdat+1eah,y
				JSR		Y_iny
				inx
				inx
				cpx		#0006
				bne		Check_Ycounter
				ldx		#0
Check_Ycounter	cpy		#0018h
				bne		loop_kumo_set1	
;<<<<<<<<<<<<<<< ＭＳＢセット >>>>>>>>>>>>>>>>>>>>>
SET_MSB			ldx		#0
loop_msb1		stz		msbdat,x
				inx
				inx
				cpx		#0014h
				bne		loop_msb1
;
loop_msb		lda		#0aaaah
				sta		msbdat,x
				inx
				inx
				cpx		#0020h
				bne		loop_msb
;
				lda		#00aah
				sta     msbdat+14h
				lda		#0a0a0h
				sta     msbdat+16h
;<<<<<<<<<<<<<<<<< 順位チェック >>>>>>>>>>>>>>>>>>>
				JSR		Rank_Check
				cpx		#0006
				bcs		Zannen_kart
				phx
				JSR		Pukupuku_screen
				plx
				cpx		#0
				bne		Set_Hdma_jump
				JSR		Kage_Hdma_set
Set_Hdma_jump	jmp		Set_Hdma
;<<<<<<<<<< 残念用キャラＶ＿ＲＡＭセット >>>>>>>>>>>>
Zannen_kart		mem16
				rep		#00100000b
				lda		point_rank,x
				tax
				lda		<driver_number,x
				pha
				tax
				lda		Zannen_color,x
				sta		Set_color
				pla		
				lsr		a
				mem8
				sep		#00100000b
				sta		Multiplicand
				lda		#0003
				sta		Multiplier
				nop
				nop
				nop
				nop
				mem16
				rep		#00100000b
;--------(ルイジチェック)----------
				lda		Product
				cmp		#0003
				bne		Luigi_Mario_set
				lda		#0
Luigi_Mario_set	tax
				phx
;---------(Ｖ＿ＲＡＭセット)----------
				lda		#4ae0h
				sta		Screen_address
				sta		Zannen_V_ram		
				lda		#0020h
				sta		X_cmp
				ldy		#0
				sty		Rom_offset
				JSR		Zannen_tensou
;
				plx
				lda		#4a00h
				sta		Screen_address
				sta		Zannen_V_ram		
				lda		#00c0h
				sta		X_cmp
				ldy		#5800h
				sty		Rom_offset
				JSR		Zannen_tensou
;--------(ルイジチェック)----------
				lda     Product
				cmp		#0003
				bne     Zannen_OAM_set
				JSR		LUIGI_V_set
;----------(ＯＡＭセット)--------------
Zannen_OAM_set	ldx		#0
				ldy		#0
loop_zannen_set	lda		Zannen_position,x
				sta		oamdat+140h,y
				inx
				inx
				JSR		Y_iny
				cpx		#0008
				bne		loop_zannen_set
;
				ldy		#0
				lda		Zannen_counter
				JSR		Zannen_oam_set
				jmp		Set_Hdma
;
LUIGI_V_set
				ldx		#0003
				JSR		Rom_Set
				mem16
				rep		#00100000b
;
				ldx		#0
				JSR		Vram_set_Sub
				ldx		#0002
				JSR		Vram_set_Sub
				ldx		#0004
				JSR		Vram_set_Sub
				ldx		#0006
				JSR		Vram_set_Sub
				ldx		#0008
				JSR		Vram_set_Sub
				ldx		#000ah
				JSR		Vram_set_Sub
				rts
;
Vram_set_Sub	lda		V_ram_select,x
				sta     Screen_address
				pha
				lda		Rom_select_2,x
				sta		Rom_address
				JSR		Kart_V_set
				pla
				clc
				adc		#0100h
				sta		Screen_address
				lda		Rom_address
				clc
				adc		#0200h
				JSR     Kart_V_set
				rts
Rom_select_2	DW		0000h,2140h,2400h,2440h,2080h,20c0h
;
V_ram_select	DW		4ae0h,4aa0h,4c00h,4c20h,4c40h,4c60h
;---------(残念転送サブルーチン)---------
Zannen_tensou	equ		$
				stz		Zannen_counter
;
				JSR		Rom_Set
;
				mem8
				lda     #80h
				sta     Screen_step
;
				mem16			
				rep		#00100000b
loop_zannen		ldx		#0
loop_zannen_1	JSR		Set_Vram
				inx
				cpx		X_cmp
				bne		loop_zannen_1
;
				lda		Zannen_V_ram
				clc
				adc		#0100h
				sta		Zannen_V_ram
				sta		Screen_address
;
				lda		Rom_offset
				clc
				adc		#0200h
				sta		Rom_offset
				tay
				inc		Zannen_counter
				lda		Zannen_counter
				cmp		#0004
				bne		loop_zannen
				stz		Zannen_counter
				rts
;
Zannen_oam_set	asl		a
				tax
				lda		Zannen_pose_data,x
				tax	
loop_pose_set	lda		!0,x
				ora		Set_color
				sta		oamdat+142h,y
				JSR		Y_iny
				inx
				inx
				cpy		#0010h
				bne		loop_pose_set
				rts		
;<<<<<<<<<<<<<<<< Ｈ−ＤＭＡセット >>>>>>>>>>>>>>>>>>>
Set_Hdma		mem8
				sep		#00100000b
				ldx		#0
loop_hdma		lda		TENSOU_DATA,x
				sta		Hdma_data,x
				inx
				cpx		#0eh
				bne		loop_hdma
;----(H_DMA SET)--------
				lda		#0							;1address set.
				sta		DMA_1
;
				lda		#00000101b					;to 2105h
				sta		DMA_1+1
;
				lda		#10000000b					;from 180h
				sta		DMA_1+2
;
				lda		#00000001b
				sta		DMA_1+3
;
				lda		#0
				sta		DMA_1+4
;
				lda		#0
				sta		DMA_1+5
				sta		DMA_1+6
				lda		#85h
				sta		DMA_1+7
;;- - - - - - - - - - - - - - - - - - - - - - - -
				lda		#0						;1address set.
				sta		DMA_2
;
				lda		#00101100b				;to 212ch
				sta		DMA_2+1
;
				lda		#10000111b				;from 187h
				sta		DMA_2+2
;
				lda		#00000001b
				sta		DMA_2+3
;
				lda		#0
				sta		DMA_2+4
;
				lda		#0
				sta		DMA_2+5
				sta		DMA_2+6
				lda		#85h
				sta		DMA_2+7
				rts
;<<<<<<<<<<<<<<<<<	メッセージセット サブルーチン >>>>>>>>>>>
Message_data_set
				mem16
				idx16
loop_moji		lda		!0,x
				cmp		#0ffffh
				beq		message_owari
				sta		oamdat+02h,y
				JSR		Y_iny
				inx
				inx
				jmp		loop_moji
message_owari	rts
;<<<<<<<<<<<< プクプク用スクリーンセット >>>>>>>>>>
Pukupuku_screen	mem16
				idx16
				lda		Select_zoom,x						;プクプク用
				sta		<Zoom_set
				clc
				adc		#0002h
				sta		Hanten_cmp
				sec
				sbc		#0012h
				sta		Hanten_cmp1
;-------------(トロフィーポジション)-----------
				lda     Select_position,x
				sta     oamdat+140h
				lda		#0104h
				sta		oamdat+142h
				lda     #0fa00h
				sta     Fall_cup
;----------(紙吹雪イニシャル)-----------
				JSL		>Paper_init_set
;--------(横方向セット)------------------
				lda		#0080h
				sta		Width_fall
				sta     Width_fall+12h
				sta     Width_fall+10h
				sta     Width_fall+24h
				lda		#0040h
				sta		Width_fall+20h
				sta     Width_fall+0ch
				sta     Width_fall+16h
				sta     Width_fall+26h
				lda		#0060h
				sta     Width_fall+18h
				sta     Width_fall+1ah
				sta     Width_fall+0ah
				sta     Width_fall+8h
				lda		#0ff60h
				sta		Width_fall+4
				sta     Width_fall+2ah
				sta     Width_fall+0eh
				sta     Width_fall+1ch
				lda		#0ffc0h
				sta     Width_fall+14h
				sta     Width_fall+6
				sta     Width_fall+28h
				sta     Width_fall+2ch
				lda		#0ff40h
				sta     Width_fall+1eh
				sta     Width_fall+2h
				sta     Width_fall+22h
				sta     Width_fall+2eh

;--------------------------------------
				lda		#12abh
				sta		<Set_address
;
				lda		#000ch						;書き換え回数セット
				sta		<Cmp_check
				ldx		#0004						;パターンセット
				lda		PATERN_DATA,x
;
				mem8
				sep		#00100000b
;
				JSR		KAKIKAE_set					;書き換えセット
;
				mem16
				rep		#00100000b
				lda		#14b3h						;アドレス再セット
				sta		<Set_address
;
				JSR		Pukupuku_tensou
				rts
;<<<<<<<<<<<<< 影用Ｈ−ＤＭＡセット >>>>>>>>>>>>>>
Kage_Hdma_set	equ		$
				mem16
				rep		#00100000b
				lda		#000eh
				sta		H_dma_flag
;
				mem8
				sep		#00100000b
;
				lda		#00100000b
				sta		Window_control+2
				lda		#00010000b
				sta		Color_control
				lda		#10100111b
				sta		Color_brend
				lda		#11100111b
				sta		Color_bias
;
				ldx		#0
loop_kage_data	lda		Kage_window_data,x
				sta		Kage_window_init,x
				inx
				cpx		#000dh
				bne		loop_kage_data
;
				ldx		#0
				ldy		#0
loop_kage_size	lda		Kage_window,x
				sta		Kage_window_set,y
				inx
				iny
				iny
				cpx		#000fh
				bne		loop_kage_size
;
				ldx		#0
				lda		#0ffh
loop_set_end	sta     Kage_window_set+1,x
				inx
				inx
				cpx		#001eh
				bne		loop_set_end			
;	
				ldx		#0
loop_set_cmp	lda		Kage_cmp_data,x
				sta     Kage_cmp_dataset,x
				inx
				cpx		#000fh
				bne		loop_set_cmp			

				lda		#01000001b					;1address set.
				sta		DMA_3
;
				lda		#00100110b				;to 2126h
				sta		DMA_3+1
;
				lda		#0						;from 1800h
				sta		DMA_3+2
;
				lda		#00011000b
				sta		DMA_3+3
;
				lda		#0
				sta		DMA_3+4
;
				lda		#0
				sta		DMA_3+5
				sta		DMA_3+6
				lda		#85h
				sta		DMA_3+7
owari_tensou	rts
Kage_window_data
				DB		70h
				DW		NO_window
				DB		40h
				DW      NO_window
				DB		8eh   
				DW		Kage_window_set
				DB		40h
				DW      NO_window
				DB		0
;
NO_window		DB		02h,01h
;
Kage_window		DB		0f9h
				DB		0eeh
				DB		0e7h
;
				DB		0dfh
				DB		0dbh
				DB		0d7h
				DB		0d6h
;
				DB		0d6h
				DB		0d7h
				DB		0dbh
				DB		0dfh
;
				DB		0e6h				
				DB		0edh
				DB		0f2h
				DB		0fah
;
Kage_cmp_data	DB		14h,2bh,38h,46h,50h
				DB		58h,5ah,5ah,58h,50h
				DB		46h,38h,2ah,1ah	14h

;<<<<<<<<<<<<<<<<<< カラーセットサブルチン >>>>>>>>>>>
Color_Set_sub	equ		$
				mem8
				sep		#00100000b
				lda		>7f0000h,x
				sta     Color_write
				inx
				iny
				lda		>7f0000h,x
				sta     Color_write
				inx
				iny
				mem16
				rep		#00100000b
				rts
;===================================================================
;*******************************************************************
;						データー
;*******************************************************************
;===================================================================
;
;<<<<<<<<<<<<< メインルーチンセレクトデーター >>>>>>>>>>>>>
Select_rank		DW		Rank_1,Rank_2,Rank_3
;<<<<<<<<<<<<<<<<< ＨＤＭＡ用データー >>>>>>>>>>>>>>>>>>>>>
TENSOU_DATA		DB		80h,07h,08h,07h,60h,01h,00h
				DB		80h,11h,07h,11h,50h,12h,00h
;<<<<<<<<<<<<<<<<< 上半身用ＲＯＭデーター >>>>>>>>>>>>>>>>>
OBJ_kart		DL		0c02000h,84a000h,0c12000h,0c22000h
				DL		0c32000h,0c52000h,0c62000h,0c42000h
;<<<<<<<<<<<<<<<< 幕用カラー書き換えアドレス >>>>>>>>>>>>>>>
CG_Address		DW		4840h,4860h,4880h
;<<<<<<<<<<<<<<<<カップ用カラー書き換えアドレス >>>>>>>>>>>
Cup_color_address
				DW		49e8h,49f8h,49f0h
;<<<<<<<<<<<<<<<< プクプク用サイズデーター >>>>>>>>>>>>>>>>
Select_zoom		DW		0100h,0180h,0200h
;********************************************************
;					BG	データー
;********************************************************
PATERN_DATA		DW		PUKUPUKU_DATA1,PUKUPUKU_DATA2,PUKUPUKU_DATA
;
;<<<<<<<<<<<<<<<<<<< プクプク用データー .>>>>>>>>>>>>>>>>>>>
PUKUPUKU_DATA	DB		88h,88h,00h,01h,02h,03h,04h,05h,06h,07h,0ffh
				DB		88h,88h,10h,11h,12h,13h,14h,15h,16h,17h,0ffh
				DB		08h,09h,0ah,0bh,0ch,0dh,0eh,0fh,20h,21h,0ffh
				DB		18h,19h,1ah,1bh,1ch,1dh,1eh,1fh,30h,31h,0ffh
				DB		22h,23h,24h,25h,26h,27h,28h,29h,0ffh
				DB		32h,33h,34h,35h,36h,37h,38h,39h,0ffh
				DB		2eh,2fh,40h,41h,42h,43h,44h,45h,0ffh
				DB		3eh,3fh,50h,51h,52h,53h,54h,55h,0ffh
				DB		4ah,4bh,4ch,4dh,4eh,4fh,60h,61h,0ffh
				DB		5ah,5bh,5ch,5dh,5eh,5fh,70h,71h,0ffh
				DB		88h,66h,67h,68h,69h,6ah,6bh,6ch,6dh,88h,0ffh
				DB		88h,76h,77h,78h,79h,7ah,7bh,7ch,7dh,88h,0ffh
;
PUKUPUKU_DATA1	DB		2ah,2bh,2ch,2dh,0ffh
				DB		3ah,3bh,3ch,3dh,0ffh
				DB		46h,47h,48h,49h,0ffh
				DB		56h,57h,58h,59h,0ffh
				DB		62h,63h,64h,65h,0ffh
				DB		72h,73h,74h,75h,0ffh
;
PUKUPUKU_DATA2	DB		2ah,2bh,6eh,6fh,0ffh
				DB		3ah,3bh,7eh,7fh,0ffh
				DB		80h,81h,82h,83h,0ffh
				DB		90h,91h,92h,93h,0ffh
				DB		84h,85h,86h,87h,0ffh
				DB		94h,95h,96h,97h,0ffh
;<<<<<<<<<<<<<<<<<<<<< 幕用データー >>>>>>>>>>>>>>>>>>>>>>>>>>>>
MAKU_Set		DW		MAKU_data,MAKU_data1,MAKU_data2,MAKU_data3
;
MAKU_data		DB		06fh,0a6h,0a7h,0a0h,0a1h,0a8h,0a9h,0ffh
				DB		0ceh,0b6h,0b7h,0b0h,0b1h,0b8h,0b9h,0cfh,0ffh
;
MAKU_data1		DB		06fh,0a6h,0a7h,0a2h,0a3h,0a8h,0a9h,0ffh
				DB		0ceh,0b6h,0b7h,0b2h,0b3h,0b8h,0b9h,0cfh,0ffh
;
MAKU_data2		DB		06fh,0a6h,0a7h,0a4h,0a5h,0a8h,0a9h,0ffh
				DB		0ceh,0b6h,0b7h,0b4h,0b5h,0b8h,0b9h,0cfh,0ffh
;
MAKU_data3		DB		0aah,0abh,0ach,0adh,0c0h,0c1h,0c2h,0c3h
				DB		0c4h,0c5h,0c6h,0c7h,0c8h,0c9h,0cah,0cbh
				DB		0cch,0cdh,0ffh
				DB		0bah,0bbh,0bch,0bdh,0d0h,0d1h,0d2h,0d3h
				DB		0d4h,0d5h,0d6h,0d7h,0d8h,0d9h,0dah,0dbh
				DB		0dch,0ddh,0ffh
;***********************************************************
;					OBJ	データー
;***********************************************************
;<<<<<<<<<<<<<<<<<<<<<<< 雲データー >>>>>>>>>>>>>>>>>>>>>>>>>>>>
KUMO_data		DW		7070h,5800h,60b0h,20f0h
				DW		1888h,4040h
;
Select_kumo		DW		082ah,082eh,08cch
;
;<<<<<<<<<<<<<<<<<<<<<<<< 爆発データー >>>>>>>>>>>>>>>>>>>>>>>>>>
Explosion_set	DW		Explosion_data,Explosion_data1,Explosion_data2
;
Explosion_data	DW		6034h,38aah,6044h,38ach
				DW		7034h,0f8ach,7044h,0f8aah
;
Explosion_data1	DW		6034h,78ach,6044h,78aah
				DW      7034h,0b8aah,7044h,0b8ach
;
Explosion_data2	DW		0f0e0h,78ach,0f0e0h,78aah
				DW      0f0e0h,0b8aah,0f0e0h,0b8ach
;<<<<<<<<<<<<<<<<<<< 残念ポーズデーター >>>>>>>>>>>>>>>>>>>>>>>>>>
Zannen_position	DW		0b0b8h,0b0c8h
				DW		0c0b8h,0c0c8h
;
Zannen_pose_data	DW	Zannen_0,Zannen_1,Zannen_2,Zannen_3
;
Zannen_0		DW		30aeh,70aeh
				DW		30ceh,70ceh
;
Zannen_1		DW		70c2h,70c0h
				DW		30ceh,70ceh
;
Zannen_2		DW		70c6h,70c4h
				DW		30ceh,70ceh
;
Zannen_3		DW		30aah,70aah
				DW		30cah,70cah
;
Zannen_color	DW		0200h,0400h,0000h,0600h
				DW		0600h,0400h,0200h,0000h
;<<<<<<<<<<<<<<<<<<<<<<< 文字データー >>>>>>>>>>>>>>>>>>>>>>>>>>>
;----------(文字ポジション用)---------
Position_select	DW		5028h,5030h,5038h,502ch
;----------(クラス用)-------------
Class_Select	DW		Class_50,Class_100,Class_150
;
Class_50		DW		0f85h,0f80h,0faah,0fafh,0fafh,0ffffh
Class_100		DW		0f81h,0f80h,0f80h,0faah,0fafh,0ffffh
Class_150		DW      0f81h,0f85h,0f80h,0faah,0fafh,0ffffh
;------------(ワールド用)-----------
World_select	DW		World_0,World_1,World_2,World_3,World_cup
;
World_0			DW		0f96h,0f9eh,0f9ch,0f91h,0f9bh
				DW		0f98h,0f98h,0f96h,0ffffh
World_1			DW      0f8fh,0f95h,0f98h,0fa0h,0f8eh,0f9bh,0ffffh
World_2			DW      0f9ch,0f9dh,0f8ah,0f9bh,0ffffh
World_3			DW		0f9ch,0f99h,0f8eh,0f8ch,0f92h,0f8ah,0f95h,0ffffh
World_cup		DW		0fafh,0f8ch,0f9eh,0f99h,0fafh,0f9bh,0f8ah,0f8ch
				DW		0f8eh,0fadh,0ffffh
;------------(名前用)------------
NAME_select		DW		MARIO_name,LUIZI_name,KUPPA_name,PEACH_name
				DW		KONG_name,NOKO_name,KINOP_name,YOSSY_name
				DW		Name_massage,Name_massage_1
;
MARIO_name		DW		0f96h,0f8ah,0f9bh,0f92h,0f98h,0ffffh
LUIZI_name		DW      0f95h,0f9eh,0f92h,0f90h,0f92h,0ffffh
KUPPA_name		DW      0f8bh,0f98h,0fa0h,0f9ch,0f8eh,0f9bh,0ffffh
PEACH_name		DW      0f9dh,0f91h,0f8eh,0fafh,0f99h,0f9bh
				DW		0f92h,0f97h,0f8ch,0f8eh,0f9ch,0f9ch,0ffffh
KONG_name		DW      0f8dh,0f94h,0fafh,0f93h,0f9bh,0fa5h,0ffffh
NOKO_name		DW      0f94h,0f98h,0f98h,0f99h,0f8ah,0ffffh
KINOP_name		DW      0f9dh,0f98h,0f8ah,0f8dh,0ffffh
YOSSY_name		DW      0fa2h,0f98h,0f9ch,0f91h,0f92h,0ffffh
;
Name_massage	DW		0fafh,0fa0h,0f92h,0f97h,0f9ch,0fafh
				DW		0f9dh,0f91h,0f8eh,0fafh,0ffffh
;
Name_massage_1	DW      0fafh,0f8ch,0f8ah,0f96h,0f8eh,0fafh,0f92h
				DW		0f97h,0fafh,0ffffh
;------------(トロフィー用,通常メッセージ)------------
Cup_select		DW		Gold_cup,Silver_cup,Copper_cup,Cup_set
;
Gold_cup		DW		0f90h,0f98h,0f95h,0f8dh,0fa5h,0fadh,0ffffh
Silver_cup		DW		0f9ch,0f92h,0f95h,0f9fh,0f8eh,0f9bh
				DW		0fa5h,0fadh,0ffffh
Copper_cup		DW		0f8bh,0f9bh,0f98h,0f97h,0fa3h
				DW		0f8eh,0fa5h,0fadh,0ffffh
;
Cup_set			DW		0f90h,0f9bh,0f8eh,0f8ah
				DW		0f9dh,0fafh,0f9bh,0f8ah,0f8ch,0f8eh
				DW		0fa7h,0000h,0ffffh
;------------(順位用、残念メッセージ)-------------------
Rank_select		DW		Rank_4,Rank_5,Rank_6,Rank_7,Rank_8,Rank_message
;
Rank_4			DW		0f84h,0f9dh,0f91h,0fafh,0ffffh
Rank_5			DW      0f85h,0f9dh,0f91h,0fafh,0ffffh
Rank_6          DW      0f86h,0f9dh,0f91h,0fafh,0ffffh
Rank_7          DW      0f87h,0f9dh,0f91h,0fafh,0ffffh
Rank_8          DW      0f88h,0f9dh,0f91h,0fafh,0ffffh
Rank_message	DW		0f99h,0f95h,0f8ah,0f8ch,0f8eh,0fa5h
				DW		0fadh,0f9dh,0f9bh,0fa2h,0fafh,0f8ah,0f90h,0f8ah
				DW		0f92h,0f97h,0fa5h,0000h,0ffffh
;-------------(スペシャルメッセージ)-------------------	
Special_data	DW		0f8eh,0fa1h,0f8ch,0f8eh,0f95h,0f95h,0f8eh,0f97h
				DW		0f9dh,0fafh,0f8dh,0f9bh,0f92h,0f9fh,0f92h,0f97h
				DW		0f90h,0fa7h,0fadh,0fa2h,0f98h,0f9eh,0fafh,0f8ah
				DW		0f9bh,0f8eh,0fafh,0f97h,0f98h,0fa0h,0fafh,0f8ah
				DW		0fafh,0f9ch,0f9eh,0f99h,0f8eh,0f9bh,0fadh,0f96h
				DW		0f8ah,0f9bh,0f92h,0f98h,0fafh,0f94h,0f8ah
				DW		0f9bh,0f9dh,0fafh,0f8eh,0fa1h,0f99h,0f8eh
				DW		0f9bh,0f9dh,0fa5h,0000h,0ffffh
;<<<<<<<<<<<<<<<<<<<<< 降下キャラクターデーター >>>>>>>>>>>>>>>>>
Select_position	DW		2878h,3a5ah,4c97h
;
Fall_cup_select	DW		0ea2h,0ea0h,0ee0h
;
;<<<<<<<<<<<<<<<<<<<<< マリオポーズ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
MARIO_POSE		DW		Mario_1,Mario_2
;
Mario_1			DW		09d70h,3340h,09d80h,7340h
				DW		0ad70h,3200h,0ad80h,7200h
				DW		0f0e0h,32c4h,0ffffh
;
Mario_2			DW      09970h,3342h,09980h,7342h
				DW		0a970h,3202h,0a980h,7202h
				DW		0ad78h,32c2h,0ffffh
;
MARIO_Champgne	DW      Champgne_mario2,Champgne_mario3,Champgne_mario1
Champgne_mario1	DW      0ac75h,03ce2h,0ffffh
;
Champgne_mario2	DW		0a773h,03ce4h,0ffffh
Champgne_mario3 DW      09c6dh,03ce6h,0ffffh
;
MARIO_Shawer	DW		Shawer_mario1,Shawer_mario2,Shawer_mario3
				DW		Shawer_mario4,Shawer_mario5,Shawer_mario6
				DW		Shawer_mario7
Shawer_mario1	DW		0966dh,038aeh,0ffffh
Shawer_mario2	DW		0886dh,078aeh
				DW		0976dh,038eeh,0ffffh
Shawer_mario3	DW		08f6dh,038eah
				DW		09871h,038ebh
				DW		09f71h,0f8ebh,0ffffh
Shawer_mario4   DW		08f6dh,0b8fah,08f75h,0f8fah
				DW		0976eh,0b8fbh,09776h,0f8fbh
				DW		09f6eh,0f8fah,09f73h,0b8fah,0ffffh
Shawer_mario5   DW		0916dh,0b8fah,09175h,0f8fah
				DW		0976eh,0b8fbh,09776h,0f8fbh
				DW		0a06eh,0f8fah,0a073h,0b8fah,0ffffh
Shawer_mario6   DW		0916bh,0b8fbh,09176h,0f8fbh
				DW		0996ch,0b8fbh,09973h,0f8fbh
				DW		0a06dh,0f8fbh,0a073h,0b8fbh,0ffffh
Shawer_mario7   DW		09b6ch,078fbh,09b73h,038fbh
				DW		0a16dh,0f8fbh,0a173h,078fbh,0ffffh
;<<<<<<<<<<<<<<<<<<<<<< クッパポーズ >>>>>>>>>>>>>>>>>>>>>>>>>>>
KUPPA_POSE		DW		KUPPA_1,KUPPA_2
KUPPA_POSE1		DW		KUPPA_2,KUPPA_3
;	
KUPPA_1			DW		09970h,3144h,09980h,7144h
				DW		0a970h,300ch,0a980h,700ch
				DW		0b970h,302ch,0b980h,702ch,0ffffh
;
KUPPA_2			DW		09970h,3146h,09980h,7146h
				DW      0a970h,300eh,0a980h,700eh
				DW		0b970h,302ch,0b980h,702ch,0ffffh
;
KUPPA_3			DW		09a70h,3146h,09a80h,7146h
				DW      0aa70h,300eh,0aa80h,700eh
				DW		0b970h,302ch,0b980h,702ch,0ffffh
;
KUPPA_Champgne  DW      Champgne_kuppa1,Champgne_kuppa2,Champgne_kuppa3
KUPPA_Champgne1 DW      Champgne_kuppa3,Champgne_kuppa1
Champgne_kuppa1	DW		09684h,03ce2h,0ffffh
Champgne_kuppa2	DW		09784h,03ce2h,0ffffh
Champgne_kuppa3	DW		0a178h,3ce2h,0ffffh
;<<<<<<<<<<<<<<<<<<<<<<<< ピーチポーズ >>>>>>>>>>>>>>>>>>>>>>>>>
PEACH_POSE		DW		PEACH_1,PEACH_2
PEACH_1			DW		09970h,3748h,09980h,7748h
				DW      0a970h,3608h,0a980h,7608h
				DW		0b970h,3628h,0b980h,7628h,0ffffh
;
PEACH_2			DW		09970h,374ah,09980h,774ah
				DW      0a970h,360ah,0a980h,760ah
				DW      0b970h,3628h,0b980h,7628h,0ffffh
;
;<<<<<<<<<<<<<<<<<<<<<<<< コングポーズ >>>>>>>>>>>>>>>>>>>>>>>>>
KONG_POSE		DW		KONG_1,KONG_2,KONG_3,KONG_4
				DW		KONG_5,KONG_6
;
KONG_1			DW		09d70h,374eh,09d80h,774eh
				DW      0ad70h,3640h,0ad80h,7640h,0ffffh
;
KONG_2			DW		09d70h,374ch,09d80h,774ch
				DW      0ad70h,3642h,0ad80h,7642h,0ffffh
;
KONG_3			DW      09e70h,374ch,09d80h,774eh
				DW      0ad70h,3642h,0ad80h,7640h,0ffffh
;
KONG_4          DW      09d70h,374eh,09e80h,774ch
				DW      0ad70h,3640h,0ad80h,7642h,0ffffh
;
KONG_5			DW		0a67ch,36dfh,0ffffh
;
KONG_6			DW      0a67ch,36cfh,0ffffh
;
KONG_Champgne 	DW      Champgne_kong1,Champgne_kong2
				DW		Champgne_kong3,Champgne_kong4
				DW      Champgne_kong5,Champgne_kong6
Champgne_kong1	DW		0a975h,03ce2h,0ffffh
;
Champgne_kong2	DW		09670h,0bce2h,0ffffh
;
Champgne_kong3  DW      09678h,0fce4h
				DW		09670h,0bce2h,0ffffh
;
Champgne_kong4  DW      09680h,0fce2h
				DW		09674h,0bce2h,0ffffh
;
Champgne_kong5 	DW      09670h,0bce2h
				DW		09e80h,0bce4h,0ffffh
;
Champgne_kong6 	DW      09e70h,0bce4h
				DW		09680h,0fce2h,0ffffh
;<<<<<<<<<<<<<<<<<<<<< ルイジポーズ >>>>>>>>>>>>>>>>>>>>>>>>>>>
LUIZI_POSE		DW		LUIZI_1,LUIZI_2
;
LUIZI_1			DW		09d70h,3560h,09d80h,7560h
				DW		0ad70h,3420h,0ad80h,7420h
				DW		0f0e0h,32c4h,0ffffh
;
LUIZI_2			DW      09970h,3562h,09980h,7562h
				DW		0a970h,3422h,0a980h,7422h
				DW		0ad78h,32c2h,0ffffh
;
LUIZI_Champgne  DW      Champgne_luizi1,Champgne_luizi2
				DW		Champgne_luizi3,Champgne_luizi4
				DW		Champgne_luizi5,Champgne_luizi6
				DW		Champgne_luizi7
Champgne_luizi1	DW      0a975h,03ce2h,0ffffh
;
Champgne_luizi2	DW      0a870h,03ce4h
				DW      0a880h,03ce4h,0ffffh
Champgne_luizi3 DW      0a870h,03ce2h
				DW      0a880h,07ce2h,0ffffh
Champgne_luizi4	DW      0a970h,0bce2h
				DW      0a980h,0fce2h,0ffffh
Champgne_luizi5	DW      0a870h,0bce4h
				DW      0a880h,0bce4h,0ffffh
Champgne_luizi6 DW      0a870h,0fce2h
				DW      0a880h,0bce2h,0ffffh
Champgne_luizi7 DW      0a970h,07ce2h
				DW      0a980h,03ce2h,0ffffh
;
LUIZI_shower	DW		Shower_luizi_1
				DW		Shower_luizi_2,Shower_luizi_3
				DW		Shower_luizi_4,Shower_luizi_5
;
Shower_luizi_1	DW		09970h,38aeh
				DW		09980h,38aeh,0ffffh
;
Shower_luizi_2	DW		0a068h,38eah
				DW		0a088h,78eah,0ffffh
;
Shower_luizi_3	DW		0a268h,38ebh,0a26eh,38fah,0a968h,38fbh
				DW		0a290h,78ebh,0a28ah,78fah,0a992h,78fbh
				DW		0ffffh
;
Shower_luizi_4	DW		0f0e0h,38ebh,0a268h,38fah,0a26eh,38fbh
				DW		0f0e0h,78ebh,0a290h,78fah,0a28ah,78fbh
				DW		0ffffh
;
Shower_luizi_5	DW		0f0e0h,38ebh,0f0e0h,38fah,0a668h,38fbh
				DW		0f0e0h,78ebh,0f0e0h,78fah,0a68eh,78fbh
				DW		0ffffh
;<<<<<<<<<<<<<<<<<<<<<<< ノコノコポーズ >>>>>>>>>>>>>>>>>>>>>>>>
NOKO_POSE		DW		NOKONOKO_1,NOKONOKO_2,NOKONOKO_3,NOKONOKO_4
;
NOKONOKO_1		DW		09e70h,3564h,09e80h,7564h
				DW		0ae70h,3424h,0ae80h,7424h
				DW		0f0e0h,32c4h,0ffffh
;
NOKONOKO_2		DW      09a70h,3566h,09a80h,7566h
				DW		0aa70h,3426h,0aa80h,7426h
				DW		0ad78h,32c2h,0ffffh
;
NOKONOKO_3		DW		09e6fh,3564h,09e7fh,7564h
				DW		0ae70h,3424h,0ae80h,7424h
				DW		0f0e0h,32c4h,0ffffh
;
NOKONOKO_4		DW		09e71h,3564h,09e81h,7564h
				DW		0ae70h,3424h,0ae80h,7424h
				DW		0f0e0h,32c4h,0ffffh
;
NOKO_Champgne	DW      Champgne_noko1,Champgne_noko2
				DW		Champgne_noko3,Champgne_noko4
				DW		Champgne_noko5,Champgne_noko6
				DW		Champgne_noko7,Champgne_noko8
				DW		Champgne_noko9,Champgne_noko10
				DW		Champgne_noko11,Champgne_noko12
Champgne_noko1	DW      0a975h,03ce2h,0ffffh
;
Champgne_noko2	DW		0b276h,03ce2h,0ffffh
Champgne_noko3  DW      0b276h,03ce2h
				DW      0b283h,03ce2h,0ffffh
Champgne_noko4  DW      0b275h,03ce4h
				DW      0b285h,03ce2h,0ffffh
Champgne_noko5  DW      0b276h,03ce4h
				DW      0b283h,03ce2h,0ffffh
Champgne_noko6  DW      0b272h,03ce4h
				DW      0b27fh,03ce4h,0ffffh
Champgne_noko7  DW      0b278h,07ce2h
				DW      0b272h,03ce4h,0ffffh
Champgne_noko8  DW      0b26eh,07ce2h
				DW      0b27fh,03ce4h,0ffffh
Champgne_noko9  DW      0b26ch,07ce2h
				DW      0b27dh,03ce4h,0ffffh
Champgne_noko10 DW      0b278h,03ce2h
				DW      0b27dh,03ce4h,0ffffh
;
Champgne_noko11	DW      0ba76h,038fch,0ffffh
Champgne_noko12 DW      0ba81h,038fch,0ffffh
;<<<<<<<<<<<<<<<<<<<<< キノピヨポーズ >>>>>>>>>>>>>>>>>>>>>>
KINOP_POSE		DW		KINOPYO_1,KINOPYO_2
;
KINOPYO_1		DW		09f70h,3368h,09f80h,7368h
				DW		0af70h,3204h,0af80h,7204h
				DW		0f0e0h,32c4h,0ffffh
;
KINOPYO_2		DW      09b70h,336ah,09b80h,736ah
				DW		0ab70h,3206h,0ab80h,7206h
				DW		0ad78h,32c2h,0ffffh
;
KINOP_Champgne	DW		Champgne_kinop1,Champgne_kinop2

Champgne_kinop1	DW		0a975h,3ce2h,0ffffh
Champgne_kinop2	DW		0a972h,3ce4h,0ffffh
;
;<<<<<<<<<<<<<<<<<<<<<<<< ヨッシーポーズ >>>>>>>>>>>>>>>>>>>>>>
YOSSY_POSE			DW		YOSSY_1,YOSSY_2
;
YOSSY_1				DW		09d70h,316ch,09d80h,716ch
					DW		0ad70h,3044h,0ad80h,7044h,0ffffh
;
YOSSY_2				DW      09d70h,316eh,09d80h,716eh
					DW		0ad70h,3046h,0ad80h,7046h,0ffffh
;
;=========================================================================
;***********************************************************************
;						MAIN ROUTINE
;***********************************************************************
;========================================================================
;------------(１位用メインルーチン)-----------
;**************************************************************
;				プクプクスクロール,拡大縮小,回転セット
;**************************************************************
Pukupuku_1		equ		$
				mem16
				idx16
;<<<<<<<<<<<<<<<<<<<< 爆発チェック >>>>>>>>>>>>>>>>>>>>>>>>>
Set_pukupuku	lda     <Champgne_timer
				cmp		#0260h;017ch
				beq		Reset_move
				cmp		#0260h;017ch
				bcs		Set_burst
				jmp		Set_flying
Reset_move		stz		<MAKU_move_flag
				lda		#0029h					;プクプク割れる音
				JSL		>Trigger_sound_1
				stz		Pukupuku_flag
;
Burst_Set		JSR		Set_burst
				rts
;<<<<<<<<<<<<<<<<<<<< プクプク移動セット >>>>>>>>>>>>>>>>>>
Set_flying		lda     <Champgne_timer
				cmp		#00eeh
				beq		pukupuku_move			;ブレーキング
				cmp		#0113h
				beq		pukupuku_move			;カップセット
				cmp		#0114h
				beq		pukupuku_move			;ストップセット
				cmp		#01d0h;18ch
				beq     pukupuku_move			;スタート
				jmp		Set_speed
pukupuku_move	inc		Pukupuku_flag
;
Set_speed		JSR		Flying_sound
				lda     Pukupuku_flag
				asl		a
				tax
				jmp		(!Select_speed,x)
;
down_pukupuku	JSR		Speed_down_set
				jmp		Move_pukupuku
;
Cup_fall		JSR     Fall_character_set
;
				lda		#0cb8bh
				sta		Fit_cmp
				jmp     Move_pukupuku
;
Stop_pukupuku	JSR		Stop_fly_set
				jmp     Move_pukupuku
;
Refly_pukupuku	JSR		Set_refly
				jmp     Move_pukupuku
;
Move_pukupuku	lda     <pukupuku_speed
				sta		<Scroll_speed
				JSR		Scroll_routine
				jmp		Set_angle
;<<<<<<<<<<<<<<< プクプクが割れたときの処理 >>>>>>>>>>>>>>>>
Set_burst		JSR		Set_explosion
;
				lda		Pukupuku_flag
				asl		a
				tax
				jmp		(!select_pkupku,x)
;
Flying_0		inc     <Scroll_Y
				lda		<Scroll_X+1
				cmp		#00e0h
				bcc     Stop_set
				sec
				sbc		#0004			
				sta		<Scroll_X+1
				lda		#180h
				sta		<Center_X				;Ｘセンターセット
				lda		#0170h						;Ｙセンターセット
				sta		<Center_Y			
				jmp		Set_angle_1
;
Flying_1		dec		<Center_Y
				dec     <Center_Y
				lda     <Scroll_X+1
				cmp		#147h
				bcs		Stop_set
				clc
				adc		#0003
				sta     <Scroll_X+1
				jmp     Set_angle_1
;
Flying_2;		inc		<Center_Y
				dec     <Scroll_Y
				lda		<Scroll_Y
				cmp		#110h
				bcc		Stop_set
				jmp     Set_angle_1
;
Flying_3		lda		<Scroll_X+1
				cmp		#00a0h
				bcc		Stop_set
				sec
				sbc		#0003
				sta     <Scroll_X+1
				dec		<Scroll_Y
				jmp     Set_angle_1
;
Flying_4		inc		<Scroll_Y
				lda		<Scroll_Y
				cmp		#108h
				bcs		Stop_set
				jmp     Set_angle_1
;
Flying_5		dec		<Scroll_Y
				dec		<Scroll_Y
				jmp		World_swing_set
Set_angle_1		lda     <Angle_set				;右回転セット
				clc
				adc		#-0900h
				sta		<Angle_set
;
				lda		<Zoom_set				;ズームセット
				clc
				adc		#0010h
				cmp		#0800h
				beq		World_swing_set
				sta		<Zoom_set
;
World_swing_set	
;- - - - - - - - - - - -- - - - - - - - - - -
Set_angle		JSR		Revolve_routine			;回転,縮小拡大セット
owari_pukupuku	rts
;- - - - - - - - - - - - - - - - - - - - - - -
Stop_set		inc		Pukupuku_flag
				jmp		Set_angle_1
;
select_pkupku	DW		Flying_0,Flying_1,Flying_2,Flying_3
				DW		Flying_4,Flying_5
;
Select_speed	DW		Move_pukupuku,down_pukupuku,Cup_fall
				DW		Stop_pukupuku,Refly_pukupuku

;<<<<<<<<<<<<<<< 爆発用サブルーチン >>>>>>>>>>>>>>>>>>>
Set_explosion	equ		$
				inc		Explosion_timer
				lda		Explosion_timer
				cmp		#0002h
				bne		owari_explosion
				stz		Explosion_timer
;
				ldy		#0
				ldx		Explosion_count
				lda		Explosion_set,x
				tax
loop_explosion	lda		!0,x
				sta		oamdat+1c0h,y
				iny
				iny
				inx
				inx
				cpy		#0010h
				bne		loop_explosion
;
explosion_Count	lda		Explosion_count
				cmp		#0004
				beq		owari_explosion
				inc		Explosion_count
				inc		Explosion_count
owari_explosion	rts
;
;***********************************************************
;					２位プクプク
;***********************************************************
;
Pukupuku_2		equ		$
;<<<<<<<<<<<<<<<<<<<< プクプク移動セット >>>>>>>>>>>>>>>>>>
				lda     <Champgne_timer
				cmp		#013ah
				beq		pukupuku_move_1			;ブレーキング
				cmp		#0160h
				beq		pukupuku_move_1			;カップセット
				cmp		#0161h
				beq		pukupuku_move_1			;ストップセット
				cmp		#020ch;1d5h
				beq     pukupuku_move_1			;スタート
				jmp		Set_speed_1
pukupuku_move_1	inc		Pukupuku_flag
;-------(インデックスジャンプ)-------
Set_speed_1		JSR		Flying_sound			;飛行音
				lda     Pukupuku_flag
				asl		a		
				tax
				jmp		(!Select_speed_1,x)
;-----------(スピードダウン)---------
down_pukupuku_1	JSR		Speed_down_set
				jmp		Move_pukupuku_1
;-----------(カップセット)-----------
Cup_fall_1		JSR     Fall_character_set
;
				lda		#0b898h
				sta		Fit_cmp
				jmp     Move_pukupuku_1
;-----------(ストップセット)-----------
Stop_pukupuku_1	JSR		Stop_fly_set
				jmp     Move_pukupuku_1
;---------(再スタートセット)-----------
Refly_pukupuku_1
				JSR		Set_refly
				jmp     Move_pukupuku_1
;----------(スクロールセット)----------
Move_pukupuku_1	lda     <pukupuku_speed
				sta		<Scroll_speed
				JSR		Scroll_routine
				JSR     Revolve_routine
				rts
;
Select_speed_1	DW		Move_pukupuku_1,down_pukupuku_1,Cup_fall_1
				DW		Stop_pukupuku_1
				DW		Refly_pukupuku_1,Move_pukupuku_1
;***********************************************************
;					3位プクプク
;***********************************************************
;
Pukupuku_3		equ		$
;<<<<<<<<<<<<<<<<<<<< プクプク移動セット >>>>>>>>>>>>>>>>>>
				lda     <Champgne_timer
				cmp		#009fh
				beq		pukupuku_move_2			;ブレーキング
				cmp		#00c1h
				beq		pukupuku_move_2			;カップセット
				cmp		#00c2h
				beq		pukupuku_move_2			;ストップセット
				cmp		#016dh;136h
				beq     pukupuku_move_2			;スタート
				jmp		Set_speed_2
pukupuku_move_2	inc		Pukupuku_flag
;-------(インデックスジャンプ)-------
Set_speed_2		JSR		Flying_sound			;飛行音
				lda     Pukupuku_flag
				asl		a
				tax
				jmp		(!Select_speed_2,x)
;-----------(スピードダウン)---------
down_pukupuku_2	JSR		Speed_down_set
				jmp		Move_pukupuku_2
;-----------(カップセット)-----------
Cup_fall_2		JSR		Fall_character_set
;
				lda		#0c09ch					;カップ着地ポイントセット
				sta		Fit_cmp
				jmp     Move_pukupuku_2
;-----------(ストップセット)-----------
Stop_pukupuku_2	JSR		Stop_fly_set
				jmp     Move_pukupuku_2
;---------(再スタートセット)-----------
Refly_pukupuku_2
				JSR		Set_refly
				jmp     Move_pukupuku_2
;----------(スクロールセット)----------
Move_pukupuku_2	lda     <pukupuku_speed
				sta		<Scroll_speed
				JSR		Scroll_routine
				JSR     Revolve_routine
				rts
;
Select_speed_2	DW		Move_pukupuku_2,down_pukupuku_2,Cup_fall_2
				DW		Stop_pukupuku_2
				DW		Refly_pukupuku_2,Move_pukupuku_2

;*********************************************************
;				プクプクサブルーチン集
;*********************************************************
Flying_sound	equ		$
				inc		Flying_sound_count
				lda		Flying_sound_count
				cmp		#0016h
				bne		owari_sound_set
				stz		Flying_sound_count
				lda		#0064h
				JSR		>Trigger_sound_1
owari_sound_set	rts
;<<<<<<<<<<<<<<< スピード降下セット >>>>>>>>>>>>>>
Speed_down_set	equ		$
				lda		<pukupuku_speed
				cmp		#0010h
				bcc		owari_down
				sec
				sbc		#0004
				sta		<pukupuku_speed
owari_down		rts
;<<<<<<<<<<<<<<< ストップ、カップ降下セット >>>>>>>>>>>>
Stop_fly_set	equ		$
;--------(しっぽストップ)--------
				stz		Flying_sound_count
				stz     <Move_flag
				stz		<pukupuku_speed
;--------(カップ降下)------------
				lda     pukupuku_count
				cmp		#000bh
				bne		pukupuku_count_set
				JSR		Fall_cup_set
				jmp		owari_Stop_fly
;--------(プヨプヨセット)---------
pukupuku_count_set
Set_puyopuyo	lda     <Zoom_set
				clc
				adc		pukupuku_hanten
				sta		<Zoom_set
				cmp		Hanten_cmp
				beq		Hanten_set
				cmp		Hanten_cmp1
				beq     Hanten_set
owari_Stop_fly	rts
;------------(反転セット)----------
Hanten_set		lda		pukupuku_hanten
				eor		#0ffffh
				inc		a
				sta		pukupuku_hanten
				inc		pukupuku_count
				lda		pukupuku_count
				cmp		#000bh
				beq		Cup_fall_sound
				lda		#0023h
				JSR		>Trigger_sound_1
				jmp		Set_puyopuyo
Cup_fall_sound	lda		#004ah
				JSR		>Trigger_sound_1
				jmp     Set_puyopuyo
;<<<<<<<<<<<<<<<< リスタートセット >>>>>>>>>>>>>>>>>
Set_refly		equ		$
				JSR		Fall_cup_set
				lda		<pukupuku_speed
				clc
				adc		#0004h
				cmp		#0084h
				bcs		owari_refly
				sta		<pukupuku_speed
owari_refly		rts		
;<<<<<<<<<<<<<<<<< カップ降下ルーチン >>>>>>>>>>>>>>>
Fall_cup_set	equ		$
;-------(加速度セット)-------
				lda		Fall_cup
				beq		Cup_pri_1
				cmp		#0800h
				beq		max_speed
Set_kasoku		clc
				adc		#0080h
				sta		Fall_cup
;-----(ポジションセット)-------
max_speed		mem8
				sep		#00100000b
				lda		Fit_cmp+1				;爆発セット
				cmp		Fit_cmp
				bne		Set_V_fall
				JSR		Hit_explosion
;
Set_V_fall		lda		oamdat+141h
				clc
				adc		Fall_cup+1
				cmp		Fit_cmp
				beq		kkk
				cmp		Fit_cmp
				bcs		kkk
				sta		oamdat+141h
				mem16
				rep		#00100000b		
				rts
;--------(反転セット)-------
kkk				mem8
				lda		Fall_cup+1
				lsr		a
				cmp		#0002
				bcc		No_fall
				eor		#0ffh
				inc		a
				sta		Fall_cup+1
				lda		Fit_cmp+1				;ヒットポイントセット
				sta		Fit_cmp
;
				mem16
				rep		#00100000b
				lda		oamdat+140h					;爆発位置セット
				clc
				adc		#1000h
				sta		oamdat+148h
;
				lda		#0037h					;ｓｅセット
				JSR		>Trigger_sound_1
				jmp		max_speed
No_fall			mem16
				rep		#00100000b
				stz		Fall_cup
				rts
;
Cup_pri_1		lda		oamdat+142h
				ora		#3000h
				sta     oamdat+142h
				lda     Fall_cup
				jmp		Set_kasoku
;<<<<<<<<<<<< 降下キャラクターセット >>>>>>>>>>>>>
Fall_character_set	
;----------(クラス別トロフィーセット)------
				lda		game_level
				tax
				lda		Fall_cup_select,x
				sta		oamdat+142h				;カップセット
				rts
;<<<<<<<<<<<<<<<<< 紙吹雪セット >>>>>>>>>>>>>>>>>>
Paper_fall_set	equ		$
;-------(紙吹雪スタートセット)--------------
				lda		pukupuku_count
				cmp		#000bh
				beq		Set_paper_fall
				rts
;-------(紙吹雪パターンチェンジタイマー)----
Set_paper_fall	inc		paper_timer
				lda		paper_timer
				cmp		#0006
				bne		Fall_paper
				stz		paper_timer
;-------(紙吹雪パターンチェンジセット)--------
				ldx		oam_paper_address
reset_paper_counetr
				ldy		paper_counetr
loop_paper_chracter
				lda		Select_paper,y
				beq		reset_paper_counetr
				sta		oamdat+2,x
				JSR		Y_iny
				JSR		X_inx
				iny		
				iny		
				cpx		#0140h
				bne		loop_paper_chracter
;
				inc		paper_counetr
				inc		paper_counetr
				lda		paper_counetr
				cmp		#0006
				bne		Fall_paper
				stz		paper_counetr
;---------(落下スピードセット)-----------------
Fall_paper		mem8
				sep		#00100000b
				ldx     oam_paper_address
				ldy		paper_fall_data
loop_fall_paper	lda		fall_paper,y
				clc
				adc		Fall_acceleration,y
				sta		fall_paper,y
				lda		Fall_acceleration+1,y
				adc		#0
				sta		fall_paper+1,y
;----------(横方向移動量セット)------------------
				lda		Width_add,y
				clc
				adc		Width_fall,y
				sta		Width_add,y
				lda		Width_fall+1,y
				adc		#0
				sta		Width_add+1,y
;------------------(横方向セット)----------------
				lda		Width_add+1,y
				bmi		Set_erase_left		
;
				stz		<OBJ_check_flag			;右に消える
				lda		oamdat,x
				clc
				adc		Width_add+1,y
				sta		oamdat,x
				bcc		fall_length
				phy
				JSR		OBJ_ERASE
				ply
				jmp		fall_length
;
Set_erase_left	lda		#02
				sta		<OBJ_check_flag			;左に消える
				lda		oamdat,x
				clc
				adc		Width_add+1,y
				sta		oamdat,x
				bcs		fall_length
				phy
				JSR		OBJ_ERASE
				ply
;-----------------(縦方向セット)----------------
fall_length		lda		oamdat+1,x
				clc
				adc		fall_paper+1,y
				sta		oamdat+1,x
				cmp		#0f8h
				bcc		No_up_reset
				lda		#0ffh
				sta		oamdat+1,x
;
No_up_reset		iny
				iny
				JSR		X_inx
				cpy		#0030h
				bne		loop_fall_paper
;
owari_paper_fall
				mem16
				rep		#00100000b
				rts
;
Select_paper	DW		3aa4h,3aa5h,7aa4h
				DW		3ab6h,3ab7h,7ab6h
				DW		3aa8h,3aa9h,7aa9h
				DW		3ab8h,3ab9h,7ab8h
				DW		3aa6h,3aa7h,7aa6h
				DW		3ab4h,3ab5h,7ab4h
				DW		0000h,0000h,0000h
;<<<<< カップが頭に当たった時の爆発ルーチン >>>>>>
Hit_explosion	equ		$
				mem16
				rep		#00100000b
				lda		Explosion_head
				cmp		#0006h
				beq		owari_bakuhatu
				ldx		Explosion_head
				lda		Atari_set,x
				sta		oamdat+14ah
				inc		Explosion_head
				inc		Explosion_head
owari_bakuhatu	mem8
				sep		#00100000b
				rts
;
Atari_set       DW      386eh,786eh,38c4h
;********************************************************
;					雲、動かしセット
;********************************************************
KUMO_move		equ		$
				mem16
				idx16
				inc		kumo_flag					;フラグセット
				lda		kumo_flag
				cmp		#0005
				bne		owari_kumo
;
				stz		<OBJ_check_flag				;イレースフラグセット
				stz		kumo_flag					;フラグセットリセット
				mem8
				sep		#00100000b
				ldx		#01e8h
loop_kumo		inc		oamdat,x					;Ｈポジションセット
				lda		oamdat,x
				beq		Set_MSB
				jmp		Set_inx
;
Set_MSB			JSR		OBJ_ERASE
;	
Set_inx			JSR		X_inx						;データーインク
				cpx		#0200h
				bne		loop_kumo
owari_kumo		mem16
				rep		#00100000b
				rts
;
;
;*******************************************************
;					幕、ズームセット
;*******************************************************
MAKU_zoom		equ		$
;<<<<<<<<<<<<<<< カラー書き換えセット >>>>>>>>>>>
				inc		Color_timer
				lda		Color_timer
				cmp		#0002
				bne		Center_set
				stz		Color_timer
;
				ldx		#0010h
				lda		Color_buffer,x
				pha
;
loop_color_set	inx
				inx
   				lda		Color_buffer,x
				dex
				dex
				sta		Color_buffer,x
				inx
				inx
				cpx		#001eh
				bne		loop_color_set
;
				pla
				sta		Color_buffer,x
;<<<<<<<<<<<<<<< ＳＥセット　>>>>>>>>>>>>>>>>>>>
				lda		<Champgne_timer
				cmp		#0359h
				bne		Center_set
;
				lda		#004bh
				JSL		>Trigger_sound_1
;<<<<<<<<<<<<<<< センターセット >>>>>>>>>>>>>>>>>
Center_set		lda		#0080h					
				sta		<Center_X
				lda		#0080h
				sta		<Center_Y
;<<<<<<<<<<<<<<< スクロールセット >>>>>>>>>>>>>>>
				stz		<Scroll_X+1				
				lda		#0038h
				sta		<Scroll_Y
;<<<<<<<<<<<<<<< アングルセット >>>>>>>>>>>>>>>>>
				stz		<Angle_set
;<<<<<<<<<<<<<<< ズームセット >>>>>>>>>>>>>>>>>>>
				
				lda		<MAKU_counter
				cmp		#00a8h
				beq		Maku_hanten
				cmp		#00a8h
				bcc		Maku_hanten
;
Maku_Set		sec
				sbc		Maku_zoom_set
				sta		<MAKU_counter
				sta		<Zoom_set
;
				lda		Maku_zoom_set
				cmp		#001ch
				beq		Maku_kaiten_set
				clc
				adc		#0001h
				sta		Maku_zoom_set
;
Maku_kaiten_set	JSR     Revolve_routine         
				rts
owari_maku		JSR		Message_set
				rts
;
Maku_hanten		lda		Maku_zoom_set
				cmp		#0001
				beq		owari_maku
				lsr		a
				lsr		a
				lsr		a
				mem8
				sep		#00100000b
				sta		Multiplicand
				lda		#0005
				sta		Multiplier
				nop
				nop
				nop
				nop
				mem16
				rep		#00100000b
				lda		Product
				eor		#0ffffh
				inc		a
				sta		Maku_zoom_set
				lda		<MAKU_counter
				jmp		Maku_Set
;******************************************************
;					メッセージ セット
;******************************************************
Message_set		equ		$
				lda		Message_timer
				and		#8000h
				bne		Set_position
;<<<<<<<<<<<<<<<<< ＭＳＢ　セット >>>>>>>>>>>>>>>>
				stz		msbdat+0eh
				stz		msbdat+0fh
				stz		msbdat+12h
;<<<<<<<<<<< ＯＡＭブッファークリアー >>>>>>>>>>>>
				stz		Change_flag
				lda		#0110h
				sta		oam_paper_address
				lda		#0018h
				sta		paper_fall_data
;
				ldx		#0
				lda		#0f0f8h
loop_clare		sta		oamdat,x
				inx
				inx
				cpx		#0110h
				bne		loop_clare
;
				lda		#8000h
				sta		Message_timer
;
				JSR		MOJI_set
;<<<<<<<<<<<<<<<< タイマーセット >>>>>>>>>>>>>>>>
Set_position	inc		Message_timer
				lda		Message_timer
				and		#00ffh
				cmp		#0001h
				bne		owari_message
				lda		#8000h
				sta		Message_timer
;<<<<<<<<<<<<<<<< ポジションセット >>>>>>>>>>>>>
				ldx		Message_counter
				lda		oamdat+02h,x
				beq		owari_message
				cmp		#0fadh
				beq		Set_V_pos
;
Set_Paragraph	lda		Message_position
				sta		oamdat,x
;
Space_set		lda     Message_position
				clc		
				adc		#0008h
				sta		Message_position
;
Set_oam			JSR		X_inx
				stx		Message_counter
owari_message	rts	
;<<<<<<<<<<<<<<<<< 改行セット >>>>>>>>>>>>>>>>>>
Set_V_pos		lda		Message_position
				and		#0ff00h
				clc
				adc		#1000h
				clc
				adc		Start_position
				sta		Message_position		
				jmp		Set_oam
;<<<<<<<<<<<<<< 文字セット サブ >>>>>>>>>>>>>>>
MOJI_set		ldy		#0
;-----------(順位チェック)------------
				JSR     Rank_Check
				cpx		#0006
				bcs		Set_zannen_1
;---------(スペシャルチェック)--------
				lda		world_number
				cmp		#0003
				bne		Set_usual
				cpx		#0000
				beq		Special_set
;---------(通常メッセージ)------------
Set_usual		phx
				JSR		Class_set
				JSR		World_set			;ワールドセレクト
				plx
				phx
				JSR		NAME_set			;名前セレクト
;
				ldx		#0010h
				lda     NAME_select,x
				tax
				JSR     Message_data_set
;
				lda		Change_flag
				cmp		#0001
				bne		Set_cup
				lda		#0fadh
				sta		oamdat+02h,y
				JSR		Y_iny
;
Set_cup			plx
				lda		Cup_select,x		;カップセレクト
				tax
				JSR     Message_data_set
;
				lda		Change_flag
				cmp		#0001
				bne		End_message
				dey
				dey
				dey
				dey
				lda		#0fafh
				sta     oamdat+02h,y
				JSR     Y_iny
;
End_message		ldx		#0006
				lda		Cup_select,x
				tax
				JSR     Message_data_set
;
				lda		world_number		;文字ポジション
				asl		a
				tax
				lda		Position_select,x	
				sta		Message_position
				and		#00ffh
				sta		Start_position
				jmp		owari_moji_set
Set_zannen_1	jmp		Set_zannen		
;---------(スペシャルメッセージ)-------
Special_set		lda		#503ch				;文字ポジション
				sta		Message_position
				and		#00ffh
				sta		Start_position
;
				ldx		#0					;メッセージセット
loop_special	lda		Special_data,x
				cmp		#0ffffh
				beq		owari_special
				sta		oamdat+02h,y
				JSR		Y_iny
				inx
				inx
				jmp		loop_special
owari_special	rts
;--------(残念メッセージ)-------
Set_zannen		phx
				JSR     Class_set
				JSR		World_set			;ワールドセレクト
				plx
				phx
				JSR		NAME_set			;名前セレクト
				ldx		#0012h
				lda     NAME_select,x
				tax
				JSR     Message_data_set
;
				lda		Change_flag
				cmp		#0001
				bne		Set_rank
				lda		#0fadh
				sta		oamdat+02h,y
				JSR		Y_iny
;
Set_rank		plx							;順位セット
				txa
				sec
				sbc		#0006
				tax
				lda     Rank_select,x
				tax		
				JSR     Message_data_set
;
				lda		Change_flag
				cmp		#0002
				bne		after_message
				lda		#0fadh
				sta		oamdat+02h,y
				JSR     Y_iny
;
after_message	ldx		#000ah
				lda     Rank_select,x
				tax		
				JSR     Message_data_set
;
erase_change	lda		Change_flag
				beq		End_position
				tya
				sec
				sbc		#0030h
				tay
				lda		#0fafh
				sta		oamdat+02h,y
;
End_position	lda		world_number		;文字ポジション
				asl		a
				tax
				lda		Position_select,x	
				sec
				sbc		#1400h
				sta		Message_position
				and		#00ffh
				sta		Start_position
owari_moji_set	rts
;<<<<<<<<<<<< 名前セットサブルーチン >>>>>>>>>>
NAME_set		lda		point_rank,x
				tax
				lda		<driver_number,x
				pha
				cmp		#0006
				beq		Set_change_1
Set_name		pla
				tax
				lda		NAME_select,x
				tax
				JSR		Message_data_set
				rts
;
Set_change_1	lda		#0001
				sta		Change_flag
				jmp		Set_name
;<<<<<<<<<< ワールドセット サブルーチン >>>>>>>>>
World_set		equ		$
				lda		world_number
				pha
				cmp		#0001
				beq     Set_change_2
				cmp		#0002
				beq		Set_change_2
Set_world		pla
				asl		a
				tax
				lda		World_select,x
				tax
				JSR     Message_data_set
;
				ldx		#0008
				lda		World_select,x
				tax
				JSR     Message_data_set
				rts
;
Set_change_2	lda		#0002
				sta     Change_flag
				jmp		Set_world
;<<<<<<<<<<<< クラス　セットサブルーチン >>>>>>>>>>
Class_set		equ		$
				lda		game_level
				tax
				lda		Class_Select,x
				tax
				JSR     Message_data_set
				rts
;
;***********************************************************
;						残念セット
;***********************************************************
Zannen_pose		equ		$
				mem16
				idx16
;<<<<<<<<<<<<<<< タイマーチェック >>>>>>>>>>>>>>>>>
				inc		Zannen_timer
				lda		Zannen_timer
				cmp		#000bh
				beq		Zannen_coun_set
;
				lda		Zannen_counter
				jmp		SET_Zannen
;<<<<<<<<<<<<<<< インデックスジャンプ >>>>>>>>>>>>>>
Zannen_coun_set	stz		Zannen_timer
				lda		Zannen_counter
				cmp		#0010h
				beq		reset_counter
				inc		a
				sta		Zannen_counter
SET_Zannen		asl		a
				tax		
				jmp		(!Zannen_select,x)
reset_counter	stz		Zannen_counter
				jmp		SET_Zannen
;<<<<<<<<<<<<<<<< フラグセット >>>>>>>>>>>>>>>>>>>>>
Zannen_set_0	lda		#0
				jmp		Zannen_OAM
;
Zannen_set_1	lda		#0001
				jmp		Zannen_OAM
;
Zannen_set_2	lda		#0002
				jmp		Zannen_OAM
;
Zannen_set_3	lda		#0003
				jmp		Zannen_OAM
;
Zannen_OAM		ldy		#0
				JSR     Zannen_oam_set
				rts
;
Zannen_select	DW		Zannen_set_0,Zannen_set_1,Zannen_set_2
				DW		Zannen_set_2,Zannen_set_2,Zannen_set_1
				DW		Zannen_set_0,Zannen_set_1,Zannen_set_2
				DW		Zannen_set_2,Zannen_set_2,Zannen_set_1,Zannen_set_0
				DW		Zannen_set_3,Zannen_set_3,Zannen_set_3,Zannen_set_3
;---------------------(表彰セットメインルーチン)-------------
;
;************************************************************
;					表彰セット
;************************************************************
AWARD_SET		equ		$
				mem16
				idx16
;<<<<<<<<<< バンザイ開始チェックタイマー >>>>>>>>>>>>>
				lda		pukupuku_count
				cmp		#0007h
				bcc		owari_award				
;<<<<<<<<<<<<<<< バンザイタイマー >>>>>>>>>>>>>>>>>>>>>
Pose_timer_set	inc		<Pose_timer						
				lda		<Pose_timer
				cmp		#0010h
				bne		owari_award
				stz		<Pose_timer
;<<<<<<<<<<<<<<<< バンザイセット >>>>>>>>>>>>>>>>>>>>>>
				JSR		Banzai_award
				jmp		Set_pose
;
;
Banzai_award	equ		$
				ldy		#0178h								;ＯＡＭアドレスセット
Set_Award		ldx		Award_counter						;順位カウンター
				cpx		#0006
				beq		Banzai_owari
				lda		point_rank,x
				tax
				lda		<driver_number,x
				tax
				JSR		(!select_award,x)
				inc		Award_counter
				inc		Award_counter
				jmp		Set_Award
;
Award_mario		JSR		Set_MARIO
				rts
;
Award_luizi		JSR		Set_LUIZI
				rts
;
Award_kuppa		JSR		Set_KUPPA
				rts
;
Award_peach		JSR		Set_PEACH
				rts
;
Award_kong		JSR		Set_KONG
				rts
;
Award_noko		JSR		Set_NOKONOKO
				rts
;
Award_kinop		JSR		Set_KINOPIYO
				rts
;
Award_yossy		JSR		Set_YOSSY
				rts
;
Banzai_owari	stz		Award_counter
				rts
;<<<<<<<<<<<<<<<< ポーズセットカウント >>>>>>>>>>>>>>>>>>
Set_pose		stz		Award_counter
				inc		<Pose_counter
				inc		<Pose_counter
				lda		<Pose_counter						;ポーズチェンジカウンター
				cmp		#0004
				beq		Reset_pose
;<<<<<<<<<<<<<<<<< シャンパンファイト >>>>>>>>>>>>>>>>>>>
owari_award		JSR		Rank_Check
				cpx		#0000h
				beq		Set_Fight
				rts
;
Set_Fight		ldy		#0178h
				ldx		#0
				lda		point_rank,x
				tax
				lda		<driver_number,x
				tax
				JMP		(!Select_NO.1,x)
;
NO.1_mario		JSR		MARIO_Champgne_set
				rts
;
NO.1_luizi		JSR		LUIZI_Champgne_set
				rts
;
NO.1_kuppa		JSR		KUPPA_Champgne_set
				rts
;
NO.1_peach		JSR		PEACH_Champgne_set
				rts
;
NO.1_kong		JSR		KONG_Champgne_set
				rts
;
NO.1_noko		JSR		NOKONOKO_Champgne_set
				rts
;
NO.1_kinop		JSR		KINOPIYO_Champgne_set
				rts
;
NO.1_yossy		JSR		YOSSY_Champgne_set
				rts
;<<<<<<<<<<<<<<<<< ポーズカウンターリセット >>>>>>>>>>>>>
Reset_pose		stz		<Pose_counter
				jmp		owari_award	
;
select_award	DW		Award_mario,Award_luizi,Award_kuppa
				DW		Award_peach,Award_kong,Award_noko
				DW		Award_kinop,Award_yossy
;
Select_NO.1		DW		NO.1_mario,NO.1_luizi,NO.1_kuppa
				DW		NO.1_peach,NO.1_kong,NO.1_noko
				DW		NO.1_kinop,NO.1_yossy
;**********************************************************
;					マリオポーズセット
;**********************************************************
Set_MARIO		equ		$
;<<<<<<<<<<<<<<< バンザイ処理 >>>>>>>>>>>>>>>>>>>>>>>>>>
				phy
				ldx		<Pose_counter
				lda		MARIO_POSE,x
				tax
				phx
				JSR		AWARD_OAM_SET			
;<<<<<<<<<<<<<<<<< 表彰位置セット >>>>>>>>>>>>>>>>>>>>>>
				ldx		Award_counter
				lda		MARIO_offset,x
				sta		<addr
;
				plx
				ply
				JSR     Order_position
				rts
;
MARIO_offset	DW		0000h,0f81dh,0f0e1h,0fd0eh
;***********************************************************
;					マリオ シャンペンセット
;***********************************************************
MARIO_Champgne_set	equ		$
;<<<<<<<<<<<<<<<<< タイマーチェック >>>>>>>>>>>>>>>>>>>
				lda		<Champgne_timer
				cmp		#01b0h;0140h
				beq		Champne_mario
				cmp		#0240h;015ch
				beq		Champne_mario
				cmp		#0260h;0178h
				beq		Champne_mario
;
				lda		<Pose_flag
				jmp		SET_mario
;<<<<<<<<<<<<<<<< インデックスジャンプ >>>>>>>>>>>>>>>>
Champne_mario	lda		<Pose_flag
				inc		a
				sta		<Pose_flag
SET_mario		asl		a
				tax		
				jmp		(!Select_mario,x)
;<<<<<<<<<<<<<<<<< ポーズセット >>>>>>>>>>>>>>>>>>>>>>>
MARIO_1			ldx		#0
				JSR		Banz_stop_mario
				ldx		#0004
				JSR     Set_up_mario
				JMP		owari_mario
;			
MARIO_2			lda		#0a873h
				sta		oamdat+150h
				ldx		#0
				JSR		Banz_stop_mario
				JSR		Cork_set
				JMP		owari_mario
;<<<<<<<<<<<<< シャンペンポーズセット >>>>>>>>>>>>>>>>>
MARIO_count		JSR     Set_ERASE
;----------(タイマーセット)-----------
				inc		Fight_timer
				lda		Fight_timer
				cmp		#0003h
				beq		MARIO_fight_set
				lda		<Fight_counter
				asl		a
				tax
				jmp		Set_fight
;
MARIO_fight_set	stz		Fight_timer
;-------(インデックスジャンプ)----------
MARIO_reset		lda		<Fight_counter
				cmp		#000dh
				beq		reset_kin_fight
				asl		a
				tax
				inc		<Fight_counter
Set_fight		jmp		(!MARIO_fight,x)
;
reset_kin_fight	stz		<Fight_counter
				jmp		MARIO_reset
;----------(パターンセット)--------------
MARIO_3			ldx		#0
				JSR		Banz_stop_mario
				ldx		#0
				JSR		Set_up_mario
				JMP     owari_mario
;
MARIO_4 		ldy		#0148h						;ＯＡＭアドレス
				ldx		#0
				JMP     Jump_set
;
MARIO_5			ldy		#0148h						;ＯＡＭアドレス
				ldx		#0002h
				JMP     Jump_set
;
MARIO_6			ldy		#014ch						;ＯＡＭアドレス
				ldx		#0004
				JMP     Jump_set
;
MARIO_7			ldy		#0150h						;ＯＡＭアドレス
				ldx		#0006
				JMP     Jump_set
;
MARIO_8			ldy		#0150h						;ＯＡＭアドレス
				ldx		#0008
				JMP     Jump_set
;
MARIO_9			ldy		#0150h						;ＯＡＭアドレス
				ldx		#000ah
				JMP     Jump_set
;
MARIO_10		ldy		#0150h						;ＯＡＭアドレス
				ldx		#000ch
				JMP     Jump_set
;
Jump_set		JSR     Set_MARIO_Shaw
;
				ldx		#0002
				JSR		Banz_stop_mario
				ldx		#0002
				JSR		Set_up_mario
owari_mario		rts
;<<<<<<<<<<<<<< インデックスデーター >>>>>>>>>>>>>>>>>>
Select_mario	DW		owari_mario,MARIO_1,MARIO_2
				DW		MARIO_count
MARIO_fight		DW		MARIO_3,MARIO_4,MARIO_5
				DW		MARIO_6,MARIO_7,MARIO_8
				DW		MARIO_9,MARIO_10,MARIO_3
				DW		MARIO_3,MARIO_3,MARIO_3
				DW		MARIO_3,MARIO_3
;<<<<<<<<<<<<<<< バンザイストップ >>>>>>>>>>>>>>>>>>>>>
Banz_stop_mario	ldy		#0178h						;ＯＡＭアドレス
				JSR     Set_MARIO_POSE
				rts
;<<<<<<<<<<<<<<< シャンペン傾けセット >>>>>>>>>>>>>>>>>
Set_up_mario	ldy		#0168h						;ＯＡＭアドレス
				JSR     Set_MARIO_Cham
				rts
;<<<<<<<<<<<<<<<<<< サブルーチン >>>>>>>>>>>>>>>>>>>>>>
Set_MARIO_Cham	equ		$
				lda		MARIO_Champgne,x
				tax
				JSR		AWARD_OAM_SET
				rts
;
Set_MARIO_POSE	equ		$
				lda		MARIO_POSE,x
				tax
				JSR		AWARD_OAM_SET
				rts
;
Set_MARIO_Shaw	equ		$
				lda		MARIO_Shawer,x
				tax
				JSR		AWARD_OAM_SET
				rts
;***********************************************************
;						クッパ
;***********************************************************
Set_KUPPA		equ		$		
				phy
				ldx		<Pose_counter
				lda		KUPPA_POSE,x
				tax
				phx
				JSR		AWARD_OAM_SET
;
				ldx		Award_counter
				lda		KUPPA_offset,x
				sta		<addr
;
				plx
				ply
				JSR     Order_position
				rts
;
KUPPA_offset	DW		0000h,0f81eh,0f0e0h,0fd62h
;*********************************************************
;				クッパ シャンペンセット
;*********************************************************
KUPPA_Champgne_set	equ		$
;<<<<<<<<<<<<<<< タイマーチェック >>>>>>>>>>>>>>>>>
				lda		<Champgne_timer
				cmp		#01b0h;0140h
				beq		Champne_kuppa
				cmp		#0244h;0160h
				beq		Champne_kuppa
				cmp		#025ah;0178h
				beq		Champne_kuppa
;
				lda		<Pose_flag
				jmp		SET_kuppa
;<<<<<<<<<<<<<<< インデックスジャンプ >>>>>>>>>>>>>>
Champne_kuppa	lda		<Pose_flag
				inc		a
				sta		<Pose_flag
SET_kuppa		asl		a
				tax		
				jmp		(!Select_kuppa,x)
;<<<<<<<<<<<<<<<< ポーズグセット >>>>>>>>>>>>>>>>>>>
Chap_kuppa_1	ldy		#0168h						;ＯＡＭアドレス
				ldx		#0004
				JSR		Set_KUPPA_Cham
				jmp		Stop_kuppa
;
Chap_kuppa_2	lda		<Champgne_timer
				cmp		#0244h
				bne		no_se_cork
;
				lda		#0049h
				JSL		>Trigger_sound_1
no_se_cork		lda		#09e74h
				sta		oamdat+150h
				JSR		Cork_set
				jmp     Stop_kuppa
;
Chap_kuppa_3	JSR		Set_ERASE
				JSR		Set_drink_kuppa
				jmp		owari_kuppa
Stop_kuppa		JSR     Banz_stop_kuppa
owari_kuppa		rts
;
Select_kuppa	DW		owari_kuppa,Chap_kuppa_1
				DW		Chap_kuppa_2,Chap_kuppa_3
;<<<<<<<<<<<<<<<<< バンザイストップ >>>>>>>>>>>>>>>>
Banz_stop_kuppa	ldy		#0178h
				ldx		#0
				lda		KUPPA_POSE,x
				tax
				JSR		AWARD_OAM_SET			
				rts
;<<<<<<<<<<<<<<<< 屈伸アクションサブ >>>>>>>>>>>>>>>
Set_drink_kuppa	equ		$
				inc		Fight_timer
				lda		Fight_timer
				cmp		#0071h
				bcc		banzai_kuppa
				cmp		#0110h
				bne		Gattu_kuppa
				stz		Fight_timer
;--------(シャンペンセット)-------
Gattu_kuppa		ldx		<Pose_counter
				ldy		#0168h						;ＯＡＭアドレス
				JSR     Set_KUPPA_Cham
;-------(屈伸セット)--------------
				ldy		#0178h						;ＯＡＭアドレス
				ldx		<Pose_counter
				lda		KUPPA_POSE1,x
				tax
				JSR		AWARD_OAM_SET			
				rts
;--------(シャンペンセット)-------
banzai_kuppa	ldy		#0168h						;ＯＡＭアドレス
				ldx		<Pose_counter
				lda		KUPPA_Champgne1,x
				tax
				JSR		AWARD_OAM_SET
;
				ldy		#0178h
				ldx		<Pose_counter
				lda		KUPPA_POSE,x
				tax
				JSR		AWARD_OAM_SET			
				rts
;<<<<<<<<<<<<<<<<< サブルーチン >>>>>>>>>>>>>>>>>>>>
Set_KUPPA_Cham	equ		$
				lda		KUPPA_Champgne,x
				tax
				JSR		AWARD_OAM_SET
				rts			
;*************************************************************
;						ピーチ
;*************************************************************
Set_PEACH		equ		$		
				phy
				ldx		<Pose_counter
				lda		PEACH_POSE,x
				tax
				phx
				JSR		AWARD_OAM_SET
;
				ldx		Award_counter
				lda		PEACH_offset,x
				sta		<addr
;
				plx
				ply
				JSR     Order_position
				rts
;
PEACH_offset	DW		0000h,0f81dh,0f0e1h,0fd44h
;************************************************************
;					ピーチ シャンペンセット
;************************************************************
PEACH_Champgne_set	equ		$
;<<<<<<<<<<<<<<<< タイマーチェック >>>>>>>>>>>>>>>>>>>
				lda		<Champgne_timer
				cmp		#01b0h;0140h
				beq		Champne_peach
				cmp		#0244h;0160h
				beq		Champne_peach
				cmp		#0260h;0178h
				beq		Champne_peach
				cmp		#0261h;0179h
				beq     Champne_peach
;	
				lda		<Pose_flag
				jmp		SET_peach
;<<<<<<<<<<<<<<<< インデックスジャンプ >>>>>>>>>>>>>>>>
Champne_peach	lda		<Pose_flag
				inc		a
				sta		<Pose_flag
SET_peach		asl		a
				tax		
				jmp		(!Select_peach,x)
;<<<<<<<<<<<<<<<<<<< 瓶持ちセット >>>>>>>>>>>>>>>>>>>>>
Chap_peach_1	lda		#0a677h
				sta		oamdat+168h
				lda		#03ce2h
				sta		oamdat+16ah
				jmp		Stop_peach
;<<<<<<<<<<<<<<<<<<< コルク発射セット >>>>>>>>>>>>>>>>>>
Chap_peach_2	lda     <Champgne_timer
				cmp		#0244h
				bne		NO_se_cork
				lda		#0049h
				JSL		>Trigger_sound_1
NO_se_cork		lda		#09e74h
				sta		oamdat+150h
				JSR		Cork_set
				jmp     Stop_peach
;<<<<<<<<<<<<<<<<<<< 瓶投げセット >>>>>>>>>>>>>>>>>>>>>
Chap_peach_3	JSR		Set_ERASE
				lda		#0500h
				sta		Fall_bin
				lda		#0a878h
				sta		oamdat+168h
				lda		#03ce4h
				sta		oamdat+16ah
				lda		#0
				sta		Width_throw
				stz		Width_timer
Stop_peach		ldx     #0
				JSR     Banz_stop_peach
owari_peach		rts
;<<<<<<<<<<<<<<<<<<< 瓶投げセット >>>>>>>>>>>>>>>>>>>>>
Chap_peach_4
				inc		Catch_timer
				lda		Catch_timer
				cmp		#0009
				bcs		Throw_set_1		
				ldx		#0
				JSR     Banz_stop_peach
				rts
;
Throw_set_1		JSR		Check_speed_upset
;
				mem16
				rep		#00100000b
				ldx		#0
				lda		Catch_timer
				beq		Set_POSE_1
				cmp		#0168h
				bcs		Set_POSE_1
				ldx		#0002
Set_POSE_1		JSR     Banz_stop_peach
				rts

;;
Select_peach	DW		owari_peach,Chap_peach_1
				DW		Chap_peach_2,Chap_peach_3
				DW		Chap_peach_4

;<<<<<<<<<<<<<<<<<< バンザイストップ >>>>>>>>>>>>>>>>>>
Banz_stop_peach	ldy		#0178h						;ＯＡＭアドレス
				lda		PEACH_POSE,x
				tax
				JSR		AWARD_OAM_SET			
				rts
;
Chap_select		DW		03ce4h,03ce6h,03ce8h,0bce6h,0bce4h,0bce6h
			 	DW      03ce8h,03ce6h
;*********************************************************
;					コング
;*********************************************************
Set_KONG		equ		$	
				mem16
				idx16	
				phy
				ldx		<Pose_counter
				lda		KONG_POSE,x
				tax
				phx
				JSR		AWARD_OAM_SET
;
				ldx		Award_counter
				lda		KONG_offset,x
				sta		<addr
;
				plx
				ply
				JSR     Order_position
				rts
;
KONG_offset		DW		0000h,0f81eh,0f0e1h,0fd9ch
;********************************************************
;					コング シャンペンセット
;********************************************************
KONG_Champgne_set	equ		$
;<<<<<<<<<<<<<<<<< タイマーチェック >>>>>>>>>>>>>>>>>
				lda		<Champgne_timer
				cmp		#01b0h;0140h
				beq		Champne_kong
				cmp		#0240h;015ch
				beq		Champne_kong
				cmp		#0260h;0178h
				beq     Champne_kong
;
				lda		<Pose_flag
				jmp		SET_kong
;<<<<<<<<<<<<<<<<<< インデックスジャンプ >>>>>>>>>>>>>
Champne_kong	lda		<Pose_flag
				inc		a
				sta		<Pose_flag
SET_kong		asl		a
				tax		
				jmp		(!Select_kong,x)
;<<<<<<<<<<<<<<<<<<< ポーズセット >>>>>>>>>>>>>>>>>>>>
Chap_kong_1		ldy		#0168h						;ＯＡＭアドレス
				ldx		#0000
				JSR     Set_KONG_Cham
				jmp		Kong_pose_set	
;
Chap_kong_2		lda		#0a873h
				sta		oamdat+150h
				JSR		Cork_set
;
Kong_pose_set	ldx		#0						
				ldy		#0178h						;ＯＡＭアドレス
				JSR     Set_KONG_POSE
				jmp		owari_kong
;<<<<<<<<<<<< シャンペンポーズセット >>>>>>>>>>>>>>>>
KONG_count		JSR     Set_ERASE
;--------(タイマーセット)---------
				inc		Fight_timer
				lda		Fight_timer
				cmp		#000bh
				beq		KONG_fight_set
;-------(インデックスジャンプ)-----
KONG_fight_set1	lda     <Fight_counter
				cmp		#0005h
				beq		reset_kon_fight
				asl		a
				tax
				jmp     (!KONG_fight,x)
;
KONG_fight_set	stz		Fight_timer
;
				lda		<Fight_counter
				asl		a
				tax
				inc		<Fight_counter
				jmp		(!KONG_fight,x)
;
reset_kon_fight	lda		#0003
				sta		<Fight_counter
				jmp		KONG_fight_set1
;---------(ポ-ズセット)------------
Chap_kong_3		ldy     #0168h						;ＯＡＭアドレス
				ldx		#0002
				jmp     Kong_banzai
;
Chap_kong_4		ldy     #0168h						;ＯＡＭアドレス
				ldx		#0004
				jmp     Kong_banzai
;
Chap_kong_5		ldy     #0168h						;ＯＡＭアドレス
				ldx		#0006
Kong_banzai		JSR		Set_KONG_Cham
				ldy		#0178h
				ldx		#0002
				JSR     Set_KONG_POSE
				jmp     owari_kong
;
Chap_kong_6		
;----ダンスポーズ
				ldy		#0178h						;ＯＡＭアドレス
				ldx		#0004
				JSR		Set_KONG_POSE
;----口セット
				ldy		#0150h						;ＯＡＭアドレス
				ldx		#0008
				JSR		Set_KONG_POSE
;
				ldy     #0168h						;ＯＡＭアドレス
				ldx		#0008
				jmp     Set_KONG_cham
;
Chap_kong_7		
;----ダンスポーズ
				ldy     #0178h						;ＯＡＭアドレス
				ldx		#0006
				JSR		Set_KONG_POSE
;----口セット
				ldy     #0150h						;ＯＡＭアドレス
				ldx		#000ah
				JSR		Set_KONG_POSE
;
				ldy     #0168h						;ＯＡＭアドレス
				ldx		#000ah
Set_KONG_cham	JSR		Set_KONG_Cham
owari_kong		rts	
;- - - - - - - - - -- - - - - - - - - - - - - - - - - - - -
Select_kong		DW		owari_kong, Chap_kong_1,Chap_kong_2
				DW		KONG_count
;
KONG_fight		DW		Chap_kong_3,Chap_kong_4,Chap_kong_5
				DW		Chap_kong_6,Chap_kong_7
;<<<<<<<<<<<<<<<<< サブルーチン >>>>>>>>>>>>>>>>
Set_KONG_Cham	equ		$
				lda		KONG_Champgne,x
				tax
				JSR		AWARD_OAM_SET			
				rts
;
Set_KONG_POSE	equ		$
				lda		KONG_POSE,x
				tax
				JSR		AWARD_OAM_SET
				rts
;********************************************************
;						ルイジ
;********************************************************
Set_LUIZI		equ		$		
				phy
				ldx		<Pose_counter
				lda		LUIZI_POSE,x
				tax
				phx
				JSR		AWARD_OAM_SET
;
				ldx		Award_counter
				lda		LUIZI_offset,x
				sta		<addr

				plx
				ply
				JSR     Order_position
				rts
;
LUIZI_offset	 DW      0000h,0f81dh,0f0e1h,0fdf2h
;********************************************************
;					ルイジ シャンペンセット
;********************************************************
LUIZI_Champgne_set	equ		$
;<<<<<<<<<<<<<<<<< タイマーチェック >>>>>>>>>>>>>>>
				lda		<Champgne_timer
				cmp		#01b0h;0140h
				beq		Champne_luizi
				cmp		#0240h;015ch
				beq		Champne_luizi
				cmp		#0260h;0178h
				beq     Champne_luizi
				cmp		#0270h;0188h
				beq		Champne_luizi
				cmp		#0280h;0198h
;
				lda		<Pose_flag
				jmp		SET_luizi
;<<<<<<<<<<<<<<<<< インデックスジャンプ >>>>>>>>>>>
Champne_luizi	lda		<Pose_flag
				inc		a
				sta		<Pose_flag
SET_luizi		asl		a
				tax		
				jmp		(!Select_luizi,x)
;<<<<<<<<<<<<<<<<< アクションセット >>>>>>>>>>>>>>>
Chap_luizi_1	ldy		#0168h						;ＯＡＭアドレス
				ldx		#0000
				jmp		Luizi_cham_set
;	
Chap_luizi_2	lda		#0a873h
				sta		oamdat+150h
				JSR		Cork_set
				jmp     Luizi_cham_set
;
Chap_luizi_3	JSR		Set_ERASE
				ldy		#0168h						;ＯＡＭアドレス
				ldx		#0002
				jmp     Luizi_cham_set
;<<<<<<<<<<<< シャンペンアクションセット >>>>>>>>>>>
Luizi_count		
;---------(タイマセット)----------
				inc		Fight_timer					
				lda		Fight_timer
				cmp		#0006h
				beq		Luizi_fight_set
				lda		<Fight_counter
				asl		a
				tax
				jmp		Luizi_jump
;
Luizi_fight_set	stz		Fight_timer
				JSR     Set_ERASE
;-----(インデックスジャンプ)------
				lda		<Fight_counter
				cmp		#0005
				beq		Loop_luizi
				asl		a
				tax
				inc		<Fight_counter
Luizi_jump		jmp		(!LUIZI_fight,x)
;
Loop_luizi		stz		<Fight_counter
				rts
;------(パターンセット)----------
Chap_luizi_4	ldy		#0148h						;ＯＡＭアドレス
				ldx		#0002
				JSR     Set_LUIZI_shaw
;
				ldy		#0168h						;ＯＡＭアドレス
				ldx		#0004
				jmp		Luizi_cham_set
;
Chap_luizi_5	JSR		Set_ERASE					;ＯＡＭリセット
				ldy		#0150h						;ＯＡＭアドレス
				ldx		#0004
				JSR     Set_LUIZI_shaw
;
				ldy		#0168h						;ＯＡＭアドレス
				ldx		#0006h
				jmp     Luizi_cham_set
;
Chap_luizi_6	ldy		#0150h						;ＯＡＭアドレス
				ldx		#0006
				JSR     Set_LUIZI_shaw
;
				ldy		#0168h						;ＯＡＭアドレス
				ldx		#0008h
				jmp     Luizi_cham_set
;
Chap_luizi_7	ldy		#0150h						;ＯＡＭアドレス
				ldx		#0008h
				JSR     Set_LUIZI_shaw
;
				ldy		#0168h						;ＯＡＭアドレス
				ldx		#000ah
				jmp     Luizi_cham_set
;
Chap_luizi_8	JSR		Set_ERASE					;ＯＡＭリセット
				ldy		#0168h						;ＯＡＭアドレス
				ldx		#000ch
				jmp     Luizi_cham_set
;
Chap_luizi_9	ldy		#0168h						;ＯＡＭアドレス
				ldx		#0000
				JSR		Set_LUIZI_shaw		
;
				ldy		#0168h						;ＯＡＭアドレス
				ldx		#0002h
Luizi_cham_set	JSR     Set_LUIZI_Cham
;
Stop_luizi		ldx		#0						
				ldy		#0178h						;ＯＡＭアドレス
				JSR     Set_LUIZI_POSE
owari_luizi		rts
;--------------------------------------------------------------
Select_luizi	DW		owari_luizi,Chap_luizi_1,Chap_luizi_2
				DW		Chap_luizi_3,Luizi_count
LUIZI_fight		DW		Chap_luizi_4,Chap_luizi_5,Chap_luizi_6
				DW		Chap_luizi_7,Chap_luizi_8,Chap_luizi_9
;<<<<<<<<<<<<<<<< ポーズサブルーチン >>>>>>>>>>>>>>>>
Set_LUIZI_POSE	equ		$
				lda		LUIZI_POSE,x
				tax
				JSR		AWARD_OAM_SET
				rts
;<<<<<<<<<<<<<<<< シャンペンサブルーチン >>>>>>>>>>>>>
Set_LUIZI_Cham	equ		$
				lda		LUIZI_Champgne,x
				tax
				JSR		AWARD_OAM_SET
				rts
;<<<<<<<<<<< シャンペンシャワーサブルーチン >>>>>>>>>
Set_LUIZI_shaw	equ		$
				lda		LUIZI_shower,x
				tax
				JSR		AWARD_OAM_SET
				rts
;<<<<<<<<<<<< ＯＡＭリセットサブルーチン >>>>>>>>>>>>
Set_ERASE		equ		$
				ldx		#0
				lda		#0f0f8h
loop_erase		sta		oamdat+144h,x
				inx
				inx
				cpx		#0034h
				bne		loop_erase
				rts
;********************************************************
;			  		ノコノコ
;********************************************************
Set_NOKONOKO	equ		$		
				phy
				ldx		<Pose_counter
				lda		NOKO_POSE,x
				tax
				phx
				JSR		AWARD_OAM_SET
;
				ldx		Award_counter
				lda		NOKONOKO_offset,x
				sta		<addr
;
				plx
				ply
				JSR     Order_position
				rts
;
NOKONOKO_offset	DW      0000h,0f81eh,0f0e1h,0fd2ah
;**********************************************************
;					ノコノコ シャンペンセット
;***********************************************************
NOKONOKO_Champgne_set	equ		$
;<<<<<<<<<<<<<<<< タイマーチェック >>>>>>>>>>>>>>>>>>>>>
				lda		<Champgne_timer
				cmp		#01b0h;0140h
				beq		Champne_noko
				cmp		#0240h;015ch
				beq		Champne_noko
				cmp		#0260h;0178h
				beq     Champne_noko
				jmp		SET_noko
;<<<<<<<<<<<<<<<< インデックスジャンプ >>>>>>>>>>>>>>>
Champne_noko	lda		<Pose_flag
				inc		a
				sta		<Pose_flag
SET_noko		lda     <Pose_flag
				asl		a
				tax		
				jmp		(!Select_noko,x)
;<<<<<<<<<<<<<<<<< ポーズセット >>>>>>>>>>>>>>>>>>>>>
NOKO_1			ldy		#0168h						;ＯＡＭアドレス
				ldx		#0000
				JMP		NOKO_cham_set
;
NOKO_2			lda		#0a873h
				sta		oamdat+150h
				JSR		Cork_set
				JMP		NOKO_12
;<<<<<<<<<<<<<<<< シャンペンポーズセット >>>>>>>>>>>>>
NOKO_count		JSR     Set_ERASE
;-------(タイマーセット)-------
				inc		Fight_timer
				lda		Fight_timer
				cmp		#0007h
				beq		NOKO_fight_set
;--------(インデックスジャンプ)---
NOKO_fight_set1	
				lda     <Fight_counter
				cmp		#000dh
				beq		reset_nok_fight
				asl		a
				tax
				jmp     (!NOKO_fight,x)
;
NOKO_fight_set	stz		Fight_timer
;
				lda		<Fight_counter
				asl		a
				tax
				inc		<Fight_counter
				jmp		(!NOKO_fight,x)
;
reset_nok_fight	lda		#0001
				sta		<Fight_counter
				jmp		NOKO_fight_set1
;--------(パターンセット)---------
NOKO_3			ldy		#0168h						;ＯＡＭアドレス
				ldx		#0002
				jmp		NOKO_cham_set
;
NOKO_4			ldy		#0168h						;ＯＡＭアドレス
				ldx		#0004
				jmp     NOKO_cham_set
;
NOKO_5			ldy		#0168h						;ＯＡＭアドレス
				ldx		#0006
				JSR     Set_NOKO_Cham
;
				ldx		#0004						
				ldy		#0178h						;ＯＡＭアドレス
				JSR     Set_NOKO_POSE
				jmp		owari_noko
;
NOKO_6			ldy		#0168h						;ＯＡＭアドレス
				ldx		#0008
				jmp     NOKO_cham_set
;
NOKO_7			ldy		#0168h						;ＯＡＭアドレス
				ldx		#000ah
				jmp     NOKO_cham_set
;
NOKO_8			ldy		#0168h						;ＯＡＭアドレス
				ldx		#000ch
				JSR     Set_NOKO_Cham
;
				ldy		#0150h						;ＯＡＭアドレス
				ldx		#0014h
				jmp     NOKO_cham_set
;
NOKO_9			JSR		Set_ERASE					;ＯＡＭリセット
				ldy		#0168h						;ＯＡＭアドレス
				ldx		#000eh
				jmp     NOKO_cham_set
;
NOKO_10			ldy		#0168h					;ＯＡＭアドレス
				ldx		#0010h
				JSR     Set_NOKO_Cham
;
				ldx		#0006						
				ldy		#0178h					;ＯＡＭアドレス
				JSR     Set_NOKO_POSE
				jmp		owari_noko
;
NOKO_11			ldy		#0168h					;ＯＡＭアドレス
				ldx		#0012h
				JSR     Set_NOKO_Cham
;
				ldy		#0150h					;ＯＡＭアドレス
				ldx		#0016h
NOKO_cham_set	JSR     Set_NOKO_Cham
;
NOKO_12			ldx		#0						
				ldy		#0178h						;ＯＡＭアドレス
				JSR     Set_NOKO_POSE
owari_noko		rts
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select_noko		DW		owari_noko,NOKO_1,NOKO_2,NOKO_count
;
NOKO_fight		DW		NOKO_3,NOKO_4,NOKO_5,NOKO_5,NOKO_5,NOKO_6,NOKO_7
				DW		NOKO_8,NOKO_9,NOKO_10,NOKO_10,NOKO_10,NOKO_11
;<<<<<<<<<<<<<<<<< サブルーチン >>>>>>>>>>>>>>>>>>
Set_NOKO_Cham	equ		$
				lda		NOKO_Champgne,x
				tax
				JSR		AWARD_OAM_SET
				rts
;
Set_NOKO_POSE	equ		$
				lda		NOKO_POSE,x
				tax
				JSR		AWARD_OAM_SET
				rts
;***********************************************************
;						キノピヨ
;***********************************************************
Set_KINOPIYO	equ		$		
				phy
				ldx		<Pose_counter
				lda		KINOP_POSE,x
				tax
				phx
				JSR		AWARD_OAM_SET
;
				ldx		Award_counter
				lda		KINOPIYO_offset,x
				sta		<addr
;
				plx
				ply
				JSR     Order_position
				rts
;
KINOPIYO_offset DW      0000h,0f81eh,0f0e1h,0fdd6h				
;***********************************************************
;					キノピヨ シャンペンセット
;***********************************************************
KINOPIYO_Champgne_set	equ		$
;<<<<<<<<<<<<<<<<< タイマーチェック >>>>>>>>>>>>>>>>>>>> 
				lda		<Champgne_timer
				cmp		#01b0h;0140h
				beq		Champne_kinop
				cmp		#0240h;015ch
				beq		Champne_kinop
				cmp		#0260h;0178h
				beq		Champne_kinop
				cmp		#0268h;0180h
				beq     Champne_kinop
;
				lda		<Pose_flag
				jmp		SET_kinop
;<<<<<<<<<<<<<<<<<< インデックスジャンプ >>>>>>>>>>>>>>>
Champne_kinop	lda		<Pose_flag
				inc		a
				sta		<Pose_flag
SET_kinop		asl		a
				tax		
				jmp		(!Select_kinop,x)
;<<<<<<<<<<<<<<<<<<<< ポーズセット >>>>>>>>>>>>>>>>>>>>>
Chap_kinop_1	JSR		Set_lean_kinop
				jmp		banzai_stop
;
Chap_kinop_2	lda		#0a873h
				sta		oamdat+150h
				JSR     Cork_set
				jmp		banzai_stop

Chap_kinop_3	JSR		Set_turu_0
				JSR     Set_up_kinop
				jmp     banzai_stop
;
Chap_kinop_4	JSR     Set_turu_1
;
banzai_stop		JSR		Banz_stop_kinop
owari_kinop     rts
;<<<<<<<<<<<<<<<<<<<< セレクトデーター >>>>>>>>>>>>>>>>>>
Select_kinop	DW		owari_kinop,Chap_kinop_1,Chap_kinop_2
				DW		Chap_kinop_3,Chap_kinop_4
;<<<<<<<<<<<<<<<<<<<< バンザイストップ >>>>>>>>>>>>>>>>>>
Banz_stop_kinop	ldy		#0178h
				ldx		#0
				lda		KINOP_POSE,x
				tax
				JSR		AWARD_OAM_SET			
				rts
;<<<<<<<<<<<<<<<<<<< シャンペン傾けセット >>>>>>>>>>>>>>>>
Set_lean_kinop	ldy		#0168h							;ＯＡＭアドレス
				ldx		#0
				JSR		Set_KINOP_Cham
				rts
;<<<<<<<<<<<<<<<<<< シャンペン直立セット >>>>>>>>>>>>>>>>>
Set_up_kinop	ldy		#0168h							;ＯＡＭアドレス
				ldx		#0002					
				JSR		Set_KINOP_Cham
				rts
;<<<<<<<<<<<<<<<<<< つるセット >>>>>>>>>>>>>>>>>>>>>>>>
Set_turu_0		JSR		Set_ERASE
;-------(つる　の先セット)--------
				lda		#09a72h
				sta     oamdat+1d0h
				sta		oamdat+144h
				lda		#3100h
				sta		oamdat+1d2h
;-------(つるの葉セット)----------
				ldx		#0
				lda		#3102h
loop_turu		sta		oamdat+1d6h,x
				JSR		X_inx
				cpx		#0010h
				bne		loop_turu
;
				sta		oamdat+146h
				stz		Turu_counter
				lda		#0001
				sta		<Fight_counter
				rts
;<<<<<<<<<<<<<<<<<< つるセット_1 >>>>>>>>>>>>>>>>>>>>>>>>
Set_turu_1		equ		$
;-------(つるの先カウンター)-----------
Set_counter		lda		<Fight_counter
				cmp		#0010h
				beq		Set_tutr
Set_count_inc	inc		<Fight_counter
;--------(つるの先、延ばしセット)------
				lda		oamdat+1d0h
				sec
				sbc		#0100h
				sta		oamdat+1d0h
;---------(反転セット)-----------------
owari_turu		inc		Fight_timer
				lda		Fight_timer
				cmp		#0009h
				bne		owari_hanten
				stz		Fight_timer
;		
				ldx		#0
loop_hanten		lda		oamdat+1d2h,x
				eor		#4000h
				sta		oamdat+1d2h,x
				JSR		X_inx
				cpx		#0014h
				bne		loop_hanten
				sta		oamdat+146h
owari_hanten	rts
;--------(つるの葉セット)--------------
Set_tutr		ldx		Turu_counter
				cpx		#0010h
				beq		owari_turu
				lda		oamdat+1d0h
				and		#0ff00h
				clc
				adc		#0072h
				sta		oamdat+1d4h,x
				JSR		X_inx
				stx		Turu_counter
				stz		<Fight_counter
				jmp		Set_count_inc
;<<<<<<<<<<<<<<<< シャンペン用サブルーチン >>>>>>>>>>>>>>>>
Set_KINOP_Cham	equ		$
				lda		KINOP_Champgne,x
				tax
				JSR		AWARD_OAM_SET			
				rts
;<<<<<<<<<<<<<<<<< コルク用サブルーチン >>>>>>>>>>>>>>>>>>>
Cork_set		equ		$
				lda		<Champgne_timer
				cmp		#0240h
				bne		Cork_attack
;
				lda		#0049h
				JSL		>Trigger_sound_1
Cork_attack		lda		Cork_place						;コルク軌道セット
				clc
				adc		#0202h
				sta		Cork_place
				lda		oamdat+150h
				sec
				sbc		Cork_place
				sta		oamdat+150h
;
				lda		#38deh							;コルクのキャラクターセット
				sta		oamdat+152h
;- - - - - - - - - - - - - - - - - - - - - -
				lda		Shock_flag
				cmp		#000ah
				beq		owari_cork
;
				ldx		Shock_flag
				lda		Cork_data,x						;フラシュコルクセット
				sta		oamdat+152h
;
				lda		Shock_flag						;最初のコルク発射チェック
				bne		cork_jump
;
				lda		oamdat+168h						;瓶ショックセット
				clc
				adc		#0202h
				sta		oamdat+168h
cork_jump		inc		Shock_flag
				inc		Shock_flag
owari_cork		rts
;
Cork_data		DW		38ech,38edh,38eah,38ebh,38fah,38fbh
;**********************************************************
;						ヨッシー
;**********************************************************
Set_YOSSY		equ		$		
				phy
				ldx		<Pose_counter
				lda		YOSSY_POSE,x
				tax
				phx
				JSR		AWARD_OAM_SET
;
				ldx		Award_counter
				lda		YOSSY_offset,x
				sta		<addr

				plx
				ply
				JSR		Order_position
				rts
;
YOSSY_offset	 DW     0000h,0f81eh,0f0e1h,0fdbch
;************************************************************
;					ヨッシー シャンペンセット
;************************************************************
YOSSY_Champgne_set	equ		$
;<<<<<<<<<<<<<<<<< タイマーチェック >>>>>>>>>>>>>>>>>
				lda		<Champgne_timer
				cmp		#01b0h;0140h
				beq		Champne_yossy
				cmp		#0240h;015ch
				beq		Champne_yossy
				cmp		#025fh;0177h
				beq		Champne_yossy		
				cmp		#0260h;0178h
				beq		Champne_yossy		
;
				lda		<Pose_flag
				jmp		SET_yossy
;<<<<<<<<<<<<<< インデックスジャンプ >>>>>>>>>>>>>>>>
Champne_yossy	lda		<Pose_flag
				inc		a
				sta		<Pose_flag
SET_yossy		asl		a
				tax		
				jmp		(!Select_yossy,x)
;<<<<<<<<<<<<<<<<<< ポーズセット >>>>>>>>>>>>>>>>>>>>>
YOSSY_set1		JSR		Banz_stop_yossy
				lda		#0a776h
				sta		oamdat+168h
				lda		#03ce2h
				sta		oamdat+16ah
				JMP		owari_yossy
;			
YOSSY_set2		lda		#0a873h
				sta		oamdat+150h
				JSR		Banz_stop_yossy
				JSR     Cork_set
				JMP		owari_yossy
;
YOSSY_set3		JSR		Set_fit_yossy
				JMP     owari_yossy
;
YOSSY_set4		JSR     Set_fit_yossy1
owari_yossy		rts
;<<<<<<<<<<<<<<<<<< インデックスデーター >>>>>>>>>>>>>>>
Select_yossy	DW		owari_yossy,YOSSY_set1,YOSSY_set2
				DW		YOSSY_set3,YOSSY_set4
;<<<<<<<<<<<<<<<<<< バンザイストップ >>>>>>>>>>>>>>>>>>>
Banz_stop_yossy	ldx		#0						
				JSR     Set_YOSSY_POSE
				rts
;<<<<<<<<<<<<<<<<<<< 瓶投げセット >>>>>>>>>>>>>>>>>>>>>
Set_fit_yossy   equ     $
				JSR		Set_ERASE
				lda		#0500h
				sta		Fall_bin
				lda		#0a872h
				sta		oamdat+168h
				lda		#03ce4h
				sta		oamdat+16ah
				lda		#00ffh
				sta		Width_throw
				stz		Width_timer
				ldx     #0
				JSR     Set_YOSSY_POSE
				rts
;<<<<<<<<<<<<<<<<<<< 瓶投げセット >>>>>>>>>>>>>>>>>>>>>
Set_fit_yossy1	equ		$
				inc		Catch_timer
				lda		Catch_timer
				cmp		#0009h
				bcs		Throw_set		
				ldx		#0
				JSR     Set_YOSSY_POSE
				rts
;
Throw_set		JSR		Check_speed_upset
;
				mem16
				rep		#00100000b
				ldx		#0
				lda		Catch_timer
				beq		Set_POSE
				cmp		#0028h
				bcs		Set_POSE
				ldx		#0002
Set_POSE		JSR     Set_YOSSY_POSE
				rts
;-------(加速度セット)-------
Check_speed_upset
				lda		Fall_bin
				cmp		#0500h
				beq		Set_bin_1
				clc
				adc		#0040h
				sta		Fall_bin
;-----(ポジションセット)-------
Set_bin_1		mem8
				sep		#00100000b
				lda		oamdat+169h
				clc
				adc		Fall_bin+1
				cmp		#0a8h
				beq		Spped_up_bin_1
				cmp		#0a8h
				bcs		Spped_up_bin_1	
				sta		oamdat+169h
;
				inc		Width_timer
				lda		Width_timer
				cmp		#03h
				bne		BIN_pose_set
				stz		Width_timer
				lda		oamdat+168h
				clc
				adc		Width_throw
				sta		oamdat+168h
;---------(ビン書き換え)----------
BIN_pose_set	mem16
				rep		#00100000b
				inc		Fight_timer
				lda		Fight_timer
				cmp		#0003h
				bne		NO_set_bin_1
				stz		Fight_timer
;
				lda		Fight_counter
				tax		
				lda		Chap_select,x
				sta		oamdat+16ah
				lda		Fight_counter
				clc
				adc		#0002
				cmp		#0010h
				beq		reset_bin_1
				sta		Fight_counter
				rts
reset_bin_1		stz		Fight_counter
NO_set_bin_1	rts
;--------(反転セット)-------
Spped_up_bin_1	mem8
				lda		Fall_bin+1
				eor		#0ffh
				inc		a
				sta		Fall_bin+1
				lda		Width_throw
				eor		#0ffh
				inc		a
				sta		Width_throw
				stz		Catch_timer
				stz		Catch_timer+1
				mem16
				rep		#00100000b
				lda		#03ce4h
				sta		oamdat+16ah
				rts
;<<<<<<<<<<<<<<<<<<<<< サブルーチン >>>>>>>>>>>>>>>>>>>>>>>>>>
Set_YOSSY_POSE	equ		$
				ldy		#0178h
				lda		YOSSY_POSE,x
				tax
				JSR		AWARD_OAM_SET
				rts
;***********************************************************
;					最終チェック
;***********************************************************
Final_end_set	equ		$
				lda		<Champgne_timer					;タイマーチェック
				cmp		#04b0h
				bcc		owari_final
;
				lda		<button_TG						;ボタンチェック
				ora     <button_TG+2
				and     #9000h
				beq		owari_final
;
Set_reset
				lda		#8f00h							;フェードインセット
				sta		<fade_control
;
				lda		#0040h							;フェードスピードセット
				sta		fade_speed
;
				JSL		>BGM_fade_out					;音楽フェードアウト
;
				lda		world_number
				cmp		#03
				bne		Set_normal_end
;
				JSR		Rank_Check
				cpx		#0
				bne		Set_normal_end
;
				lda		#0ch							;エンディングセット
				jmp		Set_selecta
;
Set_normal_end	lda		#04h							;タイトルセット
Set_selecta		sta		<game_selecta
owari_final		rts		
;************************************************************
;					メイン用 サブルーチン集
;************************************************************
;<<<<<<<<<<<<<<<<<<<< スクロール >>>>>>>>>>>>>>>>
Scroll_routine	equ		$
				mem16
				idx16
				lda		<Scroll_X
				clc
				adc		<Scroll_speed
				sta		<Scroll_X
 				mem8
				sep		#00100000b
				lda		<Scroll_X+2
				adc		#0
				sta		<Scroll_X+2
				mem16
				rep		#00100000b
				rts
;<<<<<<<<<<<<<<<<<< 回転、拡大縮小 >>>>>>>>>>>>>>>>
Revolve_routine	equ		$
				mem16
				idx16
				lda		<Zoom_set
				ldy		<Angle_set
				ldx		#rotate_A
				JSL		>Rotate_mode7
				rts
;<<<<<<<<<<<<<<<<<<< ｘセット >>>>>>>>>>>>>>>>>>>>>
X_inx			equ		$
				inx
				inx
				inx
				inx
				rts							
;<<<<<<<<<<<<<<<<<<< Yセット >>>>>>>>>>>>>>>>>>>>>>
Y_iny			equ		$
				iny
				iny
				iny
				iny
				rts
;<<<<<<<<<<<<< オブジェMSB用サブルーチン >>>>>>>>>>>
OBJ_ERASE		equ		$
				mem16
				idx16
				rep		#00100000b
				phx
				txa
				and		#000ch					;何個目のオブジェチェック
				lsr		a
				lsr		a
				tay
;
				txa								;何個目のMSBチェック
				lsr		a
				lsr     a
				lsr     a
				lsr     a
				tax
;
				mem8
				sep		#00100000b
				lda		msbdat,x				;MSBセットチェック
				and		MSB_data,y
				bne		Set_MSB1
;
				lda     msbdat,x				;MSB裏画面セット
				ora		MSB_data,y
				sta		msbdat,x
				plx
;
				lda		<OBJ_check_flag			;出現パターンチェック
				beq		right_erase
				cmp		#0002
				beq		paper_left_erase
;													
				lda		#0ffh					;左に消す時（旗用）
				sta		oamdat,x
				jmp		owari_erase
;
paper_left_erase
				lda		#08h					;左に消す時（紙吹雪用）
				sta		oamdat,x
				jmp		owari_erase
;
right_erase		lda		#0f0h					;左から出る時（雲用）
				sta		oamdat,x
owari_erase		rts
;
Set_MSB1		idx16							;ＭＳＢおもて画面の時
				mem8
				lda     msbdat,x
				and		MSB_data1,y
				sta		msbdat,x
				plx
				jmp		owari_erase
;<<<<<<<<<<<<< 表彰ＯＢＪ，ＯＡＭセット >>>>>>>>>>>>>>>>>>>>
AWARD_OAM_SET	equ		$
				mem16
				idx16
loop_OAM_set	lda		!0,x
				cmp		#0ffffh
				beq		owari_Set
				sta		oamdat,y
				inx
				inx
				iny
				iny
				jmp		loop_OAM_set
owari_Set		rts
;<<<<<<<<<<<<<<<<< 表彰ポジションセット >>>>>>>>>>>>>>>>>
Order_position	equ		$
				phy
				phx
				mem8
				sep		#00100000b
				JSR		SET_Hposition
;
				plx
				ply
				JSR		SET_Vposition
				mem16
				rep		#00100000b
				rts
;<<<<<<<<<<<<<<<<< 表彰Ｈポジションセット >>>>>>>>>>>>>>>>>>
SET_Hposition	equ		$
				mem8
loop_Hpos		lda		!0,x
				cmp		#0ffh
				beq		owari_Hpos
				sec
				sbc		<addr
				sta		oamdat,y
				JSR		X_inx
				JSR		Y_iny
				jmp		loop_Hpos
owari_Hpos		rts
;<<<<<<<<<<<<<<<<<< 表彰Vポジションセット >>>>>>>>>>>>>>>>>>>
SET_Vposition   equ     $
loop_Vpos		lda		!1,x
				cmp		#0ffh
				beq		owari_Vpos
				sec
				sbc		<addr+1
				sta		oamdat+1,y
				JSR		X_inx
				JSR		Y_iny
				jmp		loop_Vpos
owari_Vpos		rts

MSB_data		DB		01h,04h,10h,40h
MSB_data1		DB		0feh,0fbh,0efh,0bfh
;=====================================================================
;********************************************************************
;					NMI ROUTINE
;********************************************************************
;=====================================================================
;**********************************************************
;					プクプクムーブ書き換えセット
;**********************************************************
Pukupuku_tensou	equ		$
				mem16
				idx16
				inc		<Move_flag				
				lda		<Move_flag
				cmp     #0007h
				bne		owari_move
				stz		<Move_flag
;
				lda		#0006h						;書き換え回数セット
				sta		<Cmp_check
				ldx		<Patern_counter				;パターンセット
				lda		PATERN_DATA,x
;
				mem8
				sep		#00100000b
;
				JSR		KAKIKAE_set					;書き換えセット
;
				mem16
				rep		#00100000b
				lda		#14b3h						;アドレス再セット
				sta		<Set_address
;
				JSR		Counter_set					;パターンカウンターセット
owari_move		rts
;		
;**********************************************************
;					幕、転送セット
;**********************************************************
MAKU_tensou		equ		$
;<<<<<<<<<<<<<<<<<<<<<< ぬきセット >>>>>>>>>>>>>>>>>>
				mem16
				rep		#00100000b
				lda		#12abh						;アドレスセット
				sta		<Set_address
				mem8
				sep		#00100000b
;
				ldy		#0
Loop_NUKI_set	ldx		#0
				lda		<Set_address				;アドレスセット
				sta     Screen_address
				lda		<Set_address+1
				sta		Screen_address+1
;
				stz     Screen_step
;	
Loop_NUKI		lda		#6fh						;データーセット
				sta		Screen_write
				inx		
				cpx		#000ch
				beq		Reset_address
				jmp		Loop_NUKI
;
Reset_address	mem16
				rep		#00100000b
				lda		<Set_address				;アドレス繰り上げセット
				clc
				adc		#80h
				sta		<Set_address
				mem8
				sep		#00100000b
				iny
				cpy		#000ch						;読み取り回数チェック
				bne		Loop_NUKI_set
				mem16
				rep		#00100000b
;<<<<<<<<<<<<<<<<<< 幕、セット >>>>>>>>>>>>>>>>>>>>>>>>>>>>
				lda		#0002						;書き換え回数セット
				sta		<Cmp_check
				lda		#060ch						;アドレスセット
				sta		<Set_address
;
				JSR		Rank_Check					;ランクセット
;
				lda		MAKU_Set,x					;書き換えセット
				mem8
				sep		#00100000b
				JSR		KAKIKAE_set
				mem16
				rep		#00100000b
;
				lda		#0002						;書き換え回数セット
				sta		<Cmp_check
				lda		#0707h						;アドレスセット
				sta		<Set_address
;
				lda		MAKU_Set+6
				mem8
				sep		#00100000b
				JSR		KAKIKAE_set
				mem16
				rep		#00100000b
				rts
				rts
;************************************************************
;					書き換え用サブルーチン
;************************************************************
;
;<<<<<<<<<<<<<< パターンカウンターセット >>>>>>>>>>>>>>>
Counter_set		equ		$			
				ldx     <Patern_counter			
				inx
				inx
				stx		<Patern_counter
				cpx		#0004
				beq		reset_count
owari_count		rts
;
reset_count		stz		<Patern_counter
				jmp		owari_count
;<<<<<<<<<<<<<<<<<<< 転送用サブルーチン >>>>>>>>>>>>>>>>>
KAKIKAE_set		mem8
				idx16
				tax
;
				ldy		#0
loop_character	lda		<Set_address				;アドレスセット
				sta     Screen_address
				lda		<Set_address+1
				sta     Screen_address+1
;
				lda     #00000000b
				sta     Screen_step
;	
loop_puku		lda		!0,x						;データーセット
				cmp		#0ffh
				beq		owari_set
				sta		Screen_write
				inx		
				jmp		loop_puku
;
owari_set		mem16
Flying			rep		#00100000b
				lda		Set_address					;アドレス繰り上げセット
				clc
				adc		#80h
				sta		Set_address
				mem8
				sep		#00100000b
				inx		
				iny
				cpy		<Cmp_check					;読み取り回数チェック
				bne		loop_character
				rts
;**********************************************************
;				エンディング用サブ
;**********************************************************
Upper_body_set2	equ		$
				phb
				phk
				plb
				JSR     Upper_body_set
				plb
				rtl

;
Banzai_Set_everyone
				phb
				phk
				plb

				mem16
				idx16
				ldy		#0
				ldx		#0006
				stx		Award_counter		
;
				lda		Banzai_counter+00h
				sta		Pose_counter
				JSR		Set_KUPPA
;
				lda		Banzai_counter+02h
				sta		Pose_counter
				JSR     Set_PEACH
;
				lda		Banzai_counter+04h
				sta		Pose_counter
				JSR     Set_NOKONOKO
;
				lda		Banzai_counter+06h
				sta		Pose_counter
				JSR		Set_MARIO
;
				lda		Banzai_counter+08h
				sta		Pose_counter
				JSR		Set_LUIZI
;
				lda		Banzai_counter+0ah
				sta		Pose_counter
				JSR     Set_KINOPIYO
;
				lda		Banzai_counter+0ch
				sta		Pose_counter
				JSR     Set_YOSSY
;
				lda		Banzai_counter+0eh
				sta		Pose_counter
				JSR     Set_KONG
;
Banzai_kage_erase
				lda		#0f0f8h
				sta		oamdat+40h
				sta		oamdat+54h
				sta		oamdat+68h
				sta		oamdat+7ch
				plb
				rtl

;==============================================================
bank84			sect		rel
;==============================================================
;*******************************************************
;					影、動かしセット
;*******************************************************
KAGE_move		equ		$
				mem16
				idx16
				phb
				phk
				plb
				ldx		#0
				lda     <Champgne_timer
				cmp		#0260h
				bcs		Erase_kage	
				JSR		Set_kage_1
				plb
				rtl
;
Erase_kage		mem8
				sep		#00100000b
				ldx		#0
				lda		#0
loop_erase_kage	sta		Kage_window_set+1,x
				inx
				inx
				cpx		#001eh
				bne		loop_erase_kage
				mem16
				rep		#00100000b
				plb
				rtl
;<<<<<<<<<<<<<<< 影　移動セット >>>>>>>>>>>>>>>>>>>> 
Set_kage		phb
				phk
				plb
				JSR		Set_kage_1
				plb
				rtl
;
Set_kage_1		mem8
				sep		#00100000b
				lda		<pukupuku_speed
				clc	
				adc		kage_flag
				sta		kage_flag
				lda		kage_flag+1
				adc		#0
				sta		kage_flag+2
;
				ldx		#0
				ldy		#0
loop_kage		lda		Kage_window_set,x
				sec
				sbc		kage_flag+2
				cmp		#0001
				bcc		length_cut
				sta		Kage_window_set,x
				jmp		Set_teal
;
				
length_cut		lda     Kage_cmp_dataset,y
				sec		
				sbc     kage_flag+2
				bcc		NO_kage
				sta		Kage_cmp_dataset,y
				jmp		Kaga_erase
;
Set_teal		lda		Kage_cmp_dataset,y
				beq		next_kage_set
Kaga_erase		clc
				adc		Kage_window_set,x
				bcs		next_kage_set
				sta		Kage_window_set+1,x
next_kage_set 	inx
				inx
				iny
				cpy		#000fh
				bne		loop_kage
owari_kage		mem16
				rep		#00100000b
				rts
;
NO_kage			stz		Kage_window_set+1,x
				jmp		next_kage_set

;
;******************************************************
;					PPU&WORK INITIAL SET
;******************************************************
Final_PPU		equ		$
				phb
				phk
				plb
				mem16
				idx16
				rep		#00110000b
;
				lda		#0a3eh
				sta		MAKU_counter
				lda		#0001h
				sta		Explosion_timer
				lda		#0001
				sta		yossy_flag
				lda		#6040h
				sta		Message_position
				lda		#0080h
				sta		<pukupuku_speed
				lda		#0002h
				sta		pukupuku_hanten
				lda		#0005
				sta		paper_timer
;
				lda		#0180h
				sta		<Center_X
				lda		#0160h
				sta		<Center_Y
;
				lda		#0080h
				sta		<Scroll_X+1
				lda		#0104h
				sta		<Scroll_Y
;
				sta		rotate_A
				sta     rotate_D
;
				lda		#0018h
				sta		Maku_zoom_set
;
				lda		#00e0h
				sta		oam_paper_address
;
				lda		#0006
				sta     H_dma_flag
;
				mem8
				idx8
				sep		#00110000b
;<<<<<<<<<<<<<<<<< PPU SET >>>>>>>>>>>>>>>>>>>>>>>>>>
Set_PPU			lda		#0
				sta		Screen_bank
;
				lda		#01100100b
				sta		Screen_bank+1
				lda		#01101100b
				sta     Screen_bank+2
;
				lda		#01100000b
				sta		Screen_segment
				lda		#01110111b
				sta     Screen_segment+1
;
				lda     #10000000b
				sta     Screen_step
;
				lda		#00000010b
				sta		Sprite_size
;
				lda		#80h
				sta		Screen_flip
;  
				stz		Rotation_A
				stz     Rotation_B
				stz     Rotation_C
				stz		Rotation_D
				lda		#01
				sta		Rotation_A
				sta		Rotation_D
				stz     Rotation_B
				stz     Rotation_C
;
				lda		#80h
				sta		Rotation_X
				lda		#01
				sta     Rotation_X
				sta		Rotation_Y
				lda		#60h
				sta     Rotation_Y
;
				plb
				rtl
;**********************************************************
;				紙吹雪イニシャル
;**********************************************************
Paper_init_set	equ		$
				mem16
				idx16
;---------(紙吹雪ポジションセット)--------------
				ldx		#0
				lda		#0f010h
loop_paper_position
				sta		oamdat+0e0h,x
				clc
				adc		#000ah
				inx
				inx
				inx
				inx
				cpx		#0060h
				bne		loop_paper_position
;---------(落下スピードセット)-----------------
				ldx		#0
				lda		#0080h
loop_acceleration
				sta		Fall_acceleration,x
				clc
				adc		#0010h
				inx
				inx
				cpx		#0018h
				bne     loop_acceleration
loop_acceleration1
				sta		Fall_acceleration,x
				sec	
				sbc		#0008
				inx
				inx
				cpx		#0030h
				bne		loop_acceleration1
				rtl

				END


