;*******************************
;* STAGE4 MAP DATA
;* LCD LINE0 DATA
;* LCD LINE1 DATA
;* LCD LINE2 DATA
;* LCD LINE3 DATA
;* EVENT NO
;*  EVENT NO &HFF - BOSS STAGE
;*******************************

INIT_DATA_STAGE4:
; INITIAL DATA(18POINT)
DB 00,00,00,00,0
DB 15,00,00,00,0
DB 00,00,00,00,0
DB 00,15,00,00,0
DB 00,00,00,15,0
DB 00,00,00,00,0
DB 15,00,00,00,0
DB 00,00,00,00,0
DB 00,15,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,15,00,0
DB 00,00,00,15,0
DB 15,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,15,0
DB 00,00,00,00,0
DB 00,00,00,00,0;18

STAGE4_MAP:
DB 00,15,00,00,0;READY,ERASE
DB 00,00,00,00,0;START,ERASE
DB 00,00,00,00,0;READY START DISPLAY END
DB 00,00,15,00,0;GAME START
DB 00,00,00,00,0;DUMMY(1)

;******SPACE AREA**********
DB 00,00,00,00,0;DUMMY
DB 00,00,00,00,0;1
DB 00,00,00,00,0
DB 00,00,00,00,23
DB 15,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,15,00,23
DB 00,00,00,00,&HF0
DB 00,00,00,00,0
DB 00,15,00,00,0;10
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,24
DB 00,00,00,00,0
DB 00,00,00,15,0
DB 00,00,00,00,23
DB 00,00,00,00,&HF0
DB 15,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0;20
DB 00,15,00,00,24
DB 00,00,00,00,23
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,15,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,15,00,0
DB 00,00,00,00,0;30
DB 00,00,00,00,0;31

;******BASE AREA**********
;DB 0,00,00,0,0;DUMMY
DB 04,00,00,01,1;1
DB 04,00,00,01,9
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0;10
DB 04,00,00,01,10
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,22
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,9
DB 04,00,00,01,0
DB 04,00,00,01,0;20
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0;30
DB 04,00,00,01,13;31

;DB 00,00,00,0,0;DUMMY
DB 03,00,00,01,2;1
DB 03,00,00,01,11;MIS_BASE_UNDER(Y:24)
DB 03,03,00,01,3;3
DB 03,03,00,01,0
DB 03,00,00,01,0
DB 03,00,00,01,12;AIR BASE(Y:24)
DB 03,00,00,01,0
DB 03,00,00,01,0
DB 03,03,00,01,3
DB 03,03,00,01,0;10
DB 03,00,00,01,0
DB 03,00,00,01,0
DB 04,00,00,01,4
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,10;UNDER MIS BASE(Y:32)
DB 04,00,00,01,0
DB 04,00,00,01,0
DB 04,00,00,01,0;20
DB 04,00,00,01,0
DB 04,00,00,01,13;22

;DB 0,0,0,0,0;DUMMY
DB 04,00,00,03,5;1
DB 04,00,00,03,14
DB 04,00,03,03,6
DB 04,00,03,03,0
DB 04,00,03,03,0
DB 04,00,03,03,10;UNDER MIS BASE(Y:32)
DB 04,00,03,03,0
DB 04,00,03,03,0
DB 04,00,03,03,0
DB 04,00,00,0,15;10
DB 04,00,03,03,0
DB 04,00,03,03,0
DB 04,00,03,03,0
DB 04,00,03,03,0
DB 04,00,03,03,21;ABOVE MIS BASE(Y:24)
DB 04,00,00,00,15
DB 04,00,03,03,0
DB 04,00,03,03,10;UNDER MIS BASE(Y:32)
DB 04,00,00,0,15
DB 04,00,03,03,0;20
DB 04,00,03,03,21;ABOVE MIS BASE(Y:24)
DB 04,00,00,0,15
DB 04,00,03,03,0
DB 04,00,03,03,0;24

;DB 04,0,0,2,0;DUMMY
DB 04,00,00,02,04;1
DB 04,00,00,02,0
DB 04,00,00,02,0
DB 04,01,00,01,0
DB 04,03,04,01,8;5
DB 04,00,04,01,0
DB 04,00,04,01,0
DB 04,00,04,01,0
DB 04,00,04,01,17
DB 04,00,04,01,0;10
DB 04,00,04,01,0
DB 04,00,04,01,0
DB 04,00,04,01,18
DB 04,00,04,01,0
DB 04,00,04,01,0
DB 04,00,04,01,19
DB 04,00,04,01,0
DB 04,00,04,01,19
DB 04,00,04,01,0
DB 04,00,04,01,0;20
DB 04,00,04,01,0
DB 04,00,04,01,0;22

;------------BASE AREA END ----------------
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 15,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,15,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,15,00,00,0
;
DB 00,00,00,00,30
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,15,00,31
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,15,0
DB 00,00,00,00,30
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,15,00,00,0
DB 00,00,00,00,31
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 15,00,00,15,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,15,00,00,&HF2
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,15,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 15,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,00,0
DB 00,00,00,15,0
DB 00,00,00,00,&HFF ;BOSS

;******************************************************
;*              STAGE4 MAP CHARACTOR
;******************************************************
STAGE4_MAP_CHARA:
MAP4_CHR00:DB 0,0,0,0,0,0,0,0 ;無地背景
;MAP AREA BG

;********* CHARACTOR
;BASE
MAP4_CHR01:DB &HC0,&HC0,&HC0,&HC0,&HC0,&HC0,&HC0,&HC0;91
MAP4_CHR02:DB &HF0,&HF0,&HF0,&HF0,&HF0,&HF0,&HF0,&HF0;92
MAP4_CHR03:DB &HFF,&HFF,&HFF,&HFF,&HFF,&HFF,&HFF,&HFF;94 ;&HFF,&HC3,&HA5,&H99,&H99,&HA5,&HC3,&HFF;94
MAP4_CHR04:DB &H03,&H03,&H03,&H03,&H03,&H03,&H03,&H03;97
;

;上段
MAP4_CHR05:DB &H21,&H22,&H64,&HA5,&HA5,&HA4,&HA2,&HA1
MAP4_CHR06:DB &H90,&H8E,&HB2,&H42,&H8E,&H92,&H92,&H92
MAP4_CHR07:DB &H92,&H92,&H92,&H92,&H8E,&H42,&H32,&H0E
MAP4_CHR08:DB &H02,&H7E,&H86,&HA8,&H90,&H90,&H95,&H91
MAP4_CHR09:DB &H91,&H91,&H91,&H91,&H95,&H90,&HE0,&H20
;下段
MAP4_CHR10:DB &HE1,&H11,&HC9,&H29,&H29,&HC9,&H09,&HD2
MAP4_CHR11:DB &H52,&H52,&H52,&H52,&H52,&H52,&H22,&H02
MAP4_CHR12:DB &H02,&H22,&H52,&H52,&H72,&H52,&H72,&H52
MAP4_CHR13:DB &H52,&H22,&H02,&H02,&H3C,&HD4,&H54,&H74
MAP4_CHR14:DB &H04,&H04,&H74,&H54,&H54,&HFE,&H01,&H01
;星
MAP4_CHR15:;STAR
DB &H00,&H40,&H00,&H00,&H02,&H00,&H20,&H00

;******************************************************
;*              STAGE4 ENEMY CHARACTOR
;******************************************************

CHR_ST4_AIRBASE:
DB &H7F,&H80,&H98,&HD0,&H50,&H44,&H4C,&H48;88
DB &H48,&H4C,&H44,&H50,&HD0,&H98,&H80,&H7F

CHR_ST4_BASE_A1:DB &HFE,&H09,&H09,&H07,&H01,&H01,&H01,&HFE;89
CHR_ST4_BASE_A2:DB &HFE,&H01,&H07,&H09,&H09,&H07,&H01,&HFE;89
CHR_ST4_BASE_A3:DB &HFE,&H01,&H01,&H01,&H07,&H09,&H09,&HFE;89
CHR_ST4_BASE_A4:DB &HFE,&H25,&H25,&H19,&H01,&H01,&H01,&HFE;89
CHR_ST4_BASE_A6:DB &HFE,&H01,&H01,&H01,&H19,&H25,&H25,&HFE;89

CHR_ST4_BASE_U4:DB &H7F,&HA4,&HA4,&H98,&H80,&H80,&H80,&H7F;90
CHR_ST4_BASE_U6:DB &H7F,&H80,&H80,&H80,&H98,&HA4,&HA4,&H7F;90
CHR_ST4_BASE_U7:DB &H7F,&H90,&H90,&HE0,&H80,&H80,&H80,&H7F;90
CHR_ST4_BASE_U8:DB &H7F,&H80,&HE0,&H90,&H90,&HE0,&H80,&H7F;90
CHR_ST4_BASE_U9:DB &H7F,&H80,&H80,&H80,&HE0,&H90,&H90,&H7F;90

CHR_ST4_01:DB &H3C,&H5E,&H97,&HF3,&H73,&H37,&H67,&HFE;AIRBORN
CHR_ST4_02:DB &HFF,&HFF,&HFF,&H81,&HFF,&HE7,&H3C,&H3C;DEFENDER
CHR_ST4_03:DB &HE7,&HA5,&HE7,&HBD,&H99,&HC3,&H5A,&H66;ATTACKER1,2
CHR_ST4_04:DB &H66,&HC3,&HA5,&H18,&H18,&HA5,&HC3,&H66;CIRCULAR

;補給物品
CHR_ST4_SHUTTER:DB &HFF,&HD5,&HAB,&HD5,&HAB,&HD5,&HAB,&HFF
CHR_ST4_DOOR:DB &HFF,&H81,&HBD,&HA5,&HA5,&HBD,&H81,&HFF
CHR_ST4_CONT:DB &HFF,&H87,&HB7,&H97,&H97,&HB7,&H87,&HFF
CHR_ST4_CONT_BIG:;(16*16)
DB &H3F,&H20,&H28,&H2F,&H20,&H2F,&H28,&H20
DB &H20,&H28,&H2F,&H20,&H2F,&H28,&H20,&H3F
DB &HFF,&H07,&H17,&HF7,&H07,&HF7,&H17,&H07
DB &H07,&H17,&HF7,&H07,&HF7,&H17,&H07,&HFF
CHR_ST4_AIRPLANE:DB &H3B,&H6B,&HEF,&H9B,&H5B,&H5F,&H8B,&HFB

;******************************************************
;*              STAGE4 BOSS CHARACTOR
;******************************************************
CHR_BOSS4:;40*16

CHR_BOSS4_1_1:DB &H01,&H03,&H1F,&H3D,&H3A,&HF8,&HBC,&HFF
CHR_BOSS4_2_1:DB &HFF,&H3F,&H3F,&H1F,&H3F,&H7F,&HFF,&HFD
CHR_BOSS4_3_1:DB &HFD,&HFD,&HFC,&HFC,&HFC,&HFC,&HFC,&HFC
CHR_BOSS4_4_1:DB &HFC,&HBC,&H84,&HBC,&HFC,&HC6,&HAE,&HC7
CHR_BOSS4_5_1:DB &HFF,&H7F,&H20,&H1F,&H6A,&H8A,&H8F,&H70
CHR_BOSS4_1_2:DB &H80,&HFE,&H01,&H01,&H31,&H79,&H7F,&H7F
CHR_BOSS4_2_2:DB &HFF,&HFF,&HFF,&HFF,&HFF,&HFF,&HFF,&HFD
CHR_BOSS4_3_2:DB &HFD,&HFD,&HFD,&HFD,&HFD,&HFD,&H7D,&H7D
CHR_BOSS4_4_2:DB &H7D,&H7D,&H7D,&H7D,&H7D,&H7D,&H7D,&H7D
CHR_BOSS4_5_2:DB &H7F,&HFE,&H02,&HFC,&HAA,&HA9,&HF9,&H06

;CHR_BOSS4_1_1:DB &H01,&H03,&H1F,&H3D,&H3A,&HF8,&HBC,&HFF
;CHR_BOSS4_2_1:DB &HFF,&H3F,&H3F,&H1F,&H3F,&H7F,&HFF,&HFD
;CHR_BOSS4_3_1:DB &HFD,&HFD,&HFC,&HFC,&HFC,&HFC,&HFC,&HFC
;CHR_BOSS4_4_1:DB &HFC,&HFC,&HFC,&HFC,&HFC,&HFE,&HFE,&HFF
;CHR_BOSS4_5_1:DB &HFF,&H7F,&H20,&H1F,&H6A,&H8A,&H8F,&H70

;CHR_BOSS4_1_2:DB &HC0,&HC3,&H3F,&H03,&H31,&H79,&H7F,&H7F
;CHR_BOSS4_2_2:DB &HFF,&HFF,&HFF,&HFF,&HFF,&HFF,&HFB,&HF1
;CHR_BOSS4_3_2:DB &HF1,&HF1,&HF1,&HF1,&HF1,&HF1,&H71,&H71
;CHR_BOSS4_4_2:DB &H71,&H71,&H71,&H71,&H71,&H71,&H79,&H7D
;CHR_BOSS4_5_2:DB &H7F,&HFE,&H02,&HFC,&HAA,&HAB,&HF9,&H06

CHR_BOSS4_F_MIS:DB &H7E,&HDF,&HBF,&HFF,&HFF,&HFF,&HFF,&HFF
CHR_BOSS4_B_MIS:DB &HFF,&HFF,&HFF,&HFF,&HFF,&HBF,&HDF,&H7E
CHR_BOSS4_U_MIS:DB &H7D,&HFF,&HFF,&HFF,&HFF,&HBF,&HEF,&H7D
CHR_BOSS4_D_MIS:DB &HBE,&HFF,&HFF,&HFF,&HFF,&HFD,&HF7,&HBE
CHR_BOSS4_F_FGT:DB &H3C,&H42,&H99,&H81,&HE7,&H24,&H7E,&HE7



;******************************************************
;*              STAGE4 SENARIO INITIALIZE
;******************************************************
STAGE_4_INIT:
PRE IX,BASE_SENARIO_PTR
LDW $0,SCENARIO
STW $0,(IX+$31)

PRE IX,SCENARIO
LDW $0,ST4_SCENARIO_00 ;DUMMY
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_01
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_02
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_03
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_04
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_05
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_06
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_07
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_08
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_09
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_10
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_11
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_12
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_13
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_14
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_15
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_16
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_17
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_18
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_19
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_20
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_21
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_22
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_23
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_24
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_25
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_26
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_27
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_28
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_29
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_30
STIW $0,(IX+$31)
LDW $0,ST4_SCENARIO_31
STIW $0,(IX+$31)
;シナリオを追加する場合はここを修正(MAX64POINT)
RTN

;**********************************
;*    STAGE4 SCENARIO DATA
;*      (9BYTE:MAX64POINT)
;* 1:TIMING(出現タイミング+カウント(今回は1ドットスクロールなので0～7))
;* 2:ENEMY NO
;* 3:X
;* 4:Y
;* 5:LENGTH-X
;* 6:LENGTH-Y
;* 7:COUNTER1
;* 8:COUNTER2
;* 9:LIFE
;* 10:SCORE
;* 11:DAMAGE
;*
;*注意:必ず11BYTE定義すること
;*
;**********************************
ST4_SCENARIO_00: ;出現しない
DB &HFF ;END CODE

;------------ MAP ----------------------

ST4_SCENARIO_01:;MAP1
DB 0,91,136,08,&HF8,2,0,0,&HF8,0,10;最長248(&HF8)
DB 0,97,136,38,&HF8,2,0,0,&HF8,0,10;U2最長248(&HF8)
DB &HFF ;END CODE

ST4_SCENARIO_02:;MAP2
DB 0,91,136,08,&HB0,2,0,0,&HFF,0,10
DB 0,94,136,32,&H60,8,0,2,&HFF,2,10
DB &HFF ;END CODE

ST4_SCENARIO_03:;MAP3
DB 0,94,136,24,&H10,8,0,0,&HFF,2,10
DB &HFF ;END CODE

ST4_SCENARIO_04:;MAP4
DB 0,97,136,38,&H50,2,0,0,&HFF,0,10;U2
DB &HFF ;END CODE

ST4_SCENARIO_05:;MAP5
DB 0,94,136,08,&HC0,8,0,0,&HFF,0,10
DB 0,97,136,38,&HC0,2,0,0,&HFF,0,10;U2
DB &HFF ;END CODE

ST4_SCENARIO_06:;MAP6
DB 0,94,136,16,&HB0,8,0,0,&HFF,0,10
DB &HFF ;END CODE

ST4_SCENARIO_07:;MAP7
DB 0,92,136,08,&H20,4,0,0,&HFF,0,10
DB 0,97,136,38,&HB0,2,0,0,&HFF,0,10;U2
DB &HFF ;END CODE

ST4_SCENARIO_08:;MAP8
DB 0,91,136,08,&H90,2,0,0,&HFF,0,10
DB 0,97,136,22,&H90,2,0,0,&HFF,0,10
DB 0,94,136,24,&H08,8,0,0,&HFF,0,10
DB 0,16,136,32,&H08,8,0,0,&H03,1,1;隠し扉(Y:32)
DB &HFF ;END CODE
;------------ MAP END --------------

;------------ IN MAP ENEMY ----------

ST4_SCENARIO_09:
DB 0,90,136,32,08,8,0,0,&H00,1,1;UNDER MIS BASE(Y:32)
DB 0,89,136,08,08,8,0,0,&H00,1,1;ABOVE MIS BASE(Y:08)
DB &HFF ;END CODE

ST4_SCENARIO_10:
DB 0,90,136,32,08,8,0,0,&H00,1,1;UNDER MIS BASE(Y:32)
DB &HFF ;END CODE

ST4_SCENARIO_11:
DB 0,90,136,24,08,8,0,0,&H00,1,1;UNDER MIS BASE(Y:24)
DB &HFF ;END CODE

ST4_SCENARIO_12:
DB 0,88,136,24,16,8,0,0,&H00,3,1;AIR BASE(Y:24)
DB &HFF ;END CODE

ST4_SCENARIO_13:
DB 0,89,136,08,08,8,0,0,&H00,1,1;ABOVE MIS BASE(Y:08)
DB &HFF ;END CODE

ST4_SCENARIO_14:
DB 0,89,136,16,08,8,0,0,&H00,1,1;ABOVE MIS BASE(Y:16)
DB &HFF ;END CODE

ST4_SCENARIO_15:
DB 0,15,136,08,08,16,50,0,&H0A,0,1;シャッター(Y:8)
DB &HFF ;END CODE

ST4_SCENARIO_16:
DB 0,16,136,32,08,08,00,0,&H05,1,1;隠し扉(Y:32)
DB &HFF ;END CODE

ST4_SCENARIO_17:
DB 0,17,136,32,08,08,00,0,&H03,10,1;コンテナ(Y:32)
DB &HFF ;END CODE

ST4_SCENARIO_18:
DB 0,18,136,24,16,16,00,0,&H0A,100,1;大型コンテナ(Y:24)
DB &HFF ;END CODE

ST4_SCENARIO_19:
DB 0,19,136,32,08,08,00,0,&H00,10,1;飛行機(駐機)(Y:32)
DB &HFF ;END CODE

ST4_SCENARIO_20:
DB 0,90,136,24,08,8,0,0,&H00,1,1;UNDER MIS BASE(Y:24)
DB &HFF ;END CODE

ST4_SCENARIO_21:
DB 0,89,136,24,08,8,0,0,&H00,1,1;ABOVE MIS BASE(Y:24)
DB &HFF ;END CODE

ST4_SCENARIO_22:
DB 0,88,136,32,16,8,0,0,&H00,3,1;AIR BASE(Y:32)
DB &HFF ;END CODE

;--------------- STAGE4 START ----------------

ST4_SCENARIO_23:;飛行機
DB 0,20,144,08,08,08,00,0,&H00,1,1;飛行機
DB 0,20,136,20,08,08,00,0,&H00,1,1;飛行機
DB 0,20,144,32,08,08,00,0,&H00,1,1;飛行機
DB &HFF ;END CODE

ST4_SCENARIO_24:;CIRCULER
DB 0,21,136,08,08,08,40,0,&H00,1,1;CIRCULER1
DB 0,22,002,32,08,08,40,0,&H00,1,1;CIRCULER2
DB 2,21,136,08,08,08,40,0,&H00,1,1;CIRCULER1
DB 2,22,002,32,08,08,40,0,&H00,1,1;CIRCULER2
DB 4,21,136,08,08,08,40,0,&H00,1,1;CIRCULER1
DB 4,22,002,32,08,08,40,0,&H00,1,1;CIRCULER2
DB 6,21,136,08,08,08,40,0,&H00,1,1;CIRCULER1
DB 6,22,002,32,08,08,40,0,&H00,1,1;CIRCULER2
DB &HFF ;END CODE

ST4_SCENARIO_25:
DB &HFF ;END CODE

ST4_SCENARIO_26:
DB &HFF ;END CODE

ST4_SCENARIO_27:
DB &HFF ;END CODE

ST4_SCENARIO_28:
DB &HFF ;END CODE

ST4_SCENARIO_29:
DB &HFF ;END CODE

;-------------- AFTER MAP ---------------
ST4_SCENARIO_30:;DEFENDER+ATTACKER-1
DB 0,11,136,08,8,8,00,0,&HFF,0,1;DEFENDER
DB 0,11,136,24,8,8,00,0,&HFF,0,1;DEFENDER
DB 6,12,136,08,8,8,16,0,&H00,1,1
DB 6,12,136,24,8,8,16,0,&H00,1,1
DB &HFF ;END CODE

ST4_SCENARIO_31:;DEFENDER+ATTACKER-1
DB 0,11,136,16,8,8,00,0,&HFF,0,1;DEFENDER
DB 0,11,136,32,8,8,00,0,&HFF,0,1;DEFENDER
DB 6,13,136,16,8,8,16,0,&H00,1,1
DB 6,13,136,32,8,8,16,0,&H00,1,1
DB &HFF ;END CODE

;16以上追加する場合はSTAGE_2_INITを修正(MAX64POINT)

;*********************************
;*        ENEMY MOVE
;*
;* $9-$25   ENEMY DATA
;* $28      COUNTER
;*********************************
ST4_ENEMY_MOVE:

LD $28,$31

;**********************************************
;           　　STAGE4の特殊処理
;
;地上物については背景のスクロールと同期させるため2回に1回
;左に移動させる処理を行う。
;地上物(キャラNo70以降)及び背景と同期状態(垂直上昇中)の
;飛行物体の左移動($10)-1については、$30ではなく$29を使用すること。
;
;**********************************************
PRE IZ,GLOBAL_COUNTER
LD $29,(IZ+$31)
AN $29,$30 ;1
;
;特殊処理終了

ST4_ENEMYMOVE_LP:
PRE IX,ENEMY_DATA
;
PHUW $29
;
LDM $9,(IX+$28),8
SBC $9,$31
JR Z,NEXT_ST4_ENEMY_M
;-------- NO JUDGE(1-7) ------------
;---------- BULLET(8) --------------
SBC $9,8
JP Z,ST4_ENEMY08_MOVE;BULLET
;---------- BOSS CORE(9) -----------
;---------- NORM(10-255)------------
SBC $9,10
JP Z,ST4_ENEMY10_MOVE;AIRBORN
SBC $9,11
JP Z,ST4_ENEMY11_MOVE;DEFENDER
SBC $9,12
JP Z,ST4_ENEMY12_MOVE;ATTACKER1
SBC $9,13
JP Z,ST4_ENEMY13_MOVE;ATTACKER2
SBC $9,14
JP Z,ST4_ENEMY14_MOVE
SBC $9,15
JP Z,ST4_ENEMY15_MOVE;シャッター
SBC $9,16
JP Z,ST4_ENEMY16_MOVE;隠し扉
SBC $9,17
JP Z,ST4_ENEMY17_MOVE;コンテナ
SBC $9,18
JP Z,ST4_ENEMY18_MOVE;大型コンテナ
SBC $9,19
JP Z,ST4_ENEMY19_MOVE;飛行機(駐機)
SBC $9,20
JP Z,ST4_ENEMY20_MOVE;飛行機
SBC $9,21
JP Z,ST4_ENEMY21_MOVE;CIRCULER1
SBC $9,22
JP Z,ST4_ENEMY22_MOVE;CIRCULER2
SBC $9,88
JP Z,ST4_ENEMY88_MOVE;AIR_BASE
SBC $9,89
JP Z,ST4_ENEMY89_MOVE;MIS_BASE_ABOVE
SBC $9,90
JP Z,ST4_ENEMY90_MOVE;MIS_BASE_UNDER
SBC $9,95
JP C,ST4_GROUND_MOVE
SBC $9,95;U2
JP Z,ST4_ENEMY95_MOVE
SBC $9,96;U4
JP Z,ST4_ENEMY96_MOVE
SBC $9,97;U4
JP Z,ST4_ENEMY97_MOVE

NEXT_ST4_ENEMY_M:
;
PPUW $28
;
AD $28,ENEMY_STRUCT

JP NC,ST4_ENEMYMOVE_LP

RTN

ST4_ENEMY08_MOVE:;BULLET
CAL MOVE_BULLET
JP NEXT_ST4_ENEMY_M

ST4_ENEMY10_MOVE:
SBC $15,$30
JR Z,ST4_ENEMY10_SEC1
SB $10,$29;垂直上昇中で背景と同期
SB $11,$30
SBC $11,14
JP NZ,END_ST4ENEMYMOVE
LD $15,$30
JP END_ST4ENEMYMOVE
ST4_ENEMY10_SEC1:
SB $10,3
JP C,ST4_KILL_ENEMY
JP END_ST4ENEMYMOVE

ST4_ENEMY11_MOVE:;DEFENDER
SB $10,$30
JP C,ST4_KILL_ENEMY
JP END_ST4ENEMYMOVE

ST4_ENEMYCD_WAIT:EQU 16

ST4_ENEMY12_MOVE:;ATTACKER1
LD $0,$30
JP ST4_ENECD_COMMON

ST4_ENEMY13_MOVE:;ATTACKER2
LD $0,&HFF

;***********************************
;*       PARA
;* $0:MOVE1 Y ADD
;* ($0:1 OR &HFF)
;***********************************
ST4_ENECD_COMMON:
SB $10,$30
JP C,ST4_KILL_ENEMY

SB $14,$30

ST4_ENECD_SELECT:
SBC $15,$30;MOVE1
JR Z,ST4_ENEMYCD_SEC1
SBC $15,2;FIRE
JR Z,ST4_ENEMYCD_SEC2
SBC $15,3;MOVE2
JR Z,ST4_ENEMYCD_SEC3

;WAIT
SBC $14,$31
JP NZ,END_ST4ENEMYMOVE
LD $15,$30
LD $14,ST4_ENEMYCD_WAIT
JP END_ST4ENEMYMOVE

ST4_ENEMYCD_SEC1:;MOVE1
AD $11,$0
SBC $14,ST4_ENEMYCD_WAIT-8
JP NZ,END_ST4ENEMYMOVE
LD $15,2
LD $14,ST4_ENEMYCD_WAIT
JP END_ST4ENEMYMOVE

ST4_ENEMYCD_SEC2:;FIRE
PHUW $11
LD $5,4
AD $11,4
CAL INSERT_BULLET
PPUW $10
LD $15,3
LD $14,ST4_ENEMYCD_WAIT
JP END_ST4ENEMYMOVE

ST4_ENEMYCD_SEC3:;MOVE2
SB $11,$0
SBC $14,ST4_ENEMYCD_WAIT-8
JP NZ,END_ST4ENEMYMOVE
LD $15,$31
LD $14,ST4_ENEMYCD_WAIT
JP END_ST4ENEMYMOVE

ST4_ENEMY14_MOVE:
JP NZ,END_ST4ENEMYMOVE

ST4_ENEMY15_MOVE:;シャッター
SB $10,$29;背景と同期
JP C,ST4_KILL_ENEMY
SBC $15,$30
JR Z,ST4_ENEMY15_PH1
SBC $15,2;PHASE2は何もしない
JP Z,END_ST4ENEMYMOVE
SB $14,$30
JP NZ,END_ST4ENEMYMOVE
LD $14,16
LD $15,$30;PHASE1へ移行
JP END_ST4ENEMYMOVE
ST4_ENEMY15_PH1:
AD $11,$30
SB $14,$30
JP NZ,END_ST4ENEMYMOVE
LD $15,2;PHASE2へ移行
JP END_ST4ENEMYMOVE

ST4_ENEMY16_MOVE:;隠し扉
ST4_ENEMY17_MOVE:;コンテナ
ST4_ENEMY18_MOVE:;大型コンテナ
ST4_ENEMY19_MOVE:;飛行機(駐機)
SB $10,$29;背景と同期
JP C,ST4_KILL_ENEMY
JP END_ST4ENEMYMOVE

ST4_ENEMY20_MOVE:;飛行機
SB $10,3
JP C,ST4_KILL_ENEMY
JP END_ST4ENEMYMOVE

ST4_ENEMY21_MOVE:;CIRCLE1

ST4_E21_SELECT:
SBC $15,$30
JR Z,ST4_E21_SEC1
SBC $15,2
JR Z,ST4_E21_SEC2

ST4_E21_SEC0:
SB $10,3
SB $14,$30
JP NC,END_ST4ENEMYMOVE
LD $14,2
LD $15,$30
JP END_ST4ENEMYMOVE

ST4_E21_SEC1:
AD $11,2
SB $14,$30
JP NC,END_ST4ENEMYMOVE
LD $15,2
JP END_ST4ENEMYMOVE

ST4_E21_SEC2:
AD $10,3
SBC $10,130
JP NC,ST4_KILL_ENEMY;ENEMY21 KILL
JP END_ST4ENEMYMOVE

ST4_ENEMY22_MOVE:;CIRCULER2

ST4_E22_SELECT:
SBC $15,$30
JR Z,ST4_E22_SEC1
SBC $15,2
JR Z,ST4_E22_SEC2

ST4_E22_SEC0:
AD $10,3
SB $14,$30
JP NC,END_ST4ENEMYMOVE
LD $14,2
LD $15,$30
JP END_ST4ENEMYMOVE

ST4_E22_SEC1:
SB $11,2
SB $14,$30
JP NC,END_ST4ENEMYMOVE
LD $15,2
JP END_ST4ENEMYMOVE

ST4_E22_SEC2:
SB $10,3
JP C,ST4_KILL_ENEMY;ENEMY22 KILL
JP END_ST4ENEMYMOVE

ST4_AIRBORN_WAIT:EQU 16
ST4_ENEMY10_DATA:
DB 8,8,20,0,&H00,2,1;NO,X,Yは含まない

ST4_ENEMY88_MOVE:;AIR_BASE
SB $10,$29
JP C,ST4_KILL_ENEMY

;ENEMY_X-MY_X<80なら飛行機を飛ばす
PRE IZ,MY_X
LD $0,(IZ+$31)
LD $1,$10
SB $1,$0
SBC $1,80
JP NC,END_ST4ENEMYMOVE

SB $14,$30
JP NC,END_ST4ENEMYMOVE
LD $17,10
LD $18,$10
AD $18,4
LD $19,$11
SB $19,4
PRE IZ,ST4_ENEMY10_DATA
LDM $20,(IZ+$31),7
CAL INSERT_OBJECT
LD $14,ST4_AIRBORN_WAIT
JP END_ST4ENEMYMOVE

;*****************　地上物

ST4_MIS_WAIT:EQU 32

ST4_ENEMY89_MOVE:;MIS_BASE_ABOVE
SB $10,$29;背景と同期
JP C,ST4_KILL_ENEMY
LD $26,$10
AD $26,4
LD $27,$11
PRE IZ,MY_X
LDW $24,(IZ+$31)
CAL CALDIR
SBC $5,7
JP NC,ST4_ENE89_DSKIP
LD $15,$5
ST4_ENE89_DSKIP:
AD $14,$30
SBC $14,ST4_MIS_WAIT
JP C,END_ST4ENEMYMOVE
PHUW $11
AD $10,4
AD $11,6
CAL INSERT_BULLET
PPUW $10
LD $14,$31
JP END_ST4ENEMYMOVE

ST4_ENEMY90_MOVE:;MIS_BASE_UNDER
SB $10,$29;背景と同期
JP C,ST4_KILL_ENEMY
LD $26,$10
AD $26,4
LD $27,$11
PRE IZ,MY_X
LDW $24,(IZ+$31)
CAL CALDIR
SBC $5,4
JP C,ST4_ENE90_DSKIP
LD $15,$5
ST4_ENE90_DSKIP:
AD $14,$30
SBC $14,ST4_MIS_WAIT
JP C,END_ST4ENEMYMOVE
PHUW $11
AD $10,4
AD $11,2
CAL INSERT_BULLET
PPUW $10
LD $14,$31
JP END_ST4ENEMYMOVE

ST4_ENEMY95_MOVE:;GROUND
;AD $11,2
JR ST4_GROUND_MOVE

ST4_ENEMY96_MOVE:;GROUND
;AD $11,4
JR ST4_GROUND_MOVE

ST4_ENEMY97_MOVE:;GROUND
;AD $11,6

ST4_GROUND_MOVE:;GROUND
;地形のLIFEをMAX(&HFF)にする
LD $16,&HFF
;
SB $10,$29;背景と同期
JR NZ,END_ST4ENEMYMOVE
SB $12,8
JR Z,ST4_KILL_ENEMY
JR C,ST4_KILL_ENEMY
AD $10,8

END_ST4ENEMYMOVE:
;DATA SAVE & MAKE JUDGE DATA
PRE IX,ENEMY_DATA
STM $9,(IX+$28),8
JP NEXT_ST4_ENEMY_M

ST4_KILL_ENEMY:
CAL DELETE_OBJECT
JP NEXT_ST4_ENEMY_M

;*********************************
;*        STAGE4 ENEMY DISP
;*********************************
ST4_ENEMY_DISP:

LD $28,$31

ST4_ENEMYDISP_LP:
PRE IX,ENEMY_DATA

LDM $9,(IX+$28),8
SBC $9,$31
JP Z,NEXT_ST4_ENEMY_D
;
PHU $28
;
;GPRINTのRTN命令でRTN_ST4_EDISPに戻れるようにするため、RTN_ST4_EDISPのアドレスを
;SSPにPUSHしておく。
;なおGPRINTからの復帰はRTNでありSSPにスタックされたアドレス+1からプログラムを実行するため
;RTN_ST4_EDISPのアドレスから-1したものをSSPにPUSHする。
LDW $0,RTN_ST4_EDISP-1
PHSW $1

SBC $9,8
JP Z,ST4_ENEMY08_DISP;BULLET
SBC $9,10
JP Z,ST4_ENEMY10_DISP;AIRBORN
SBC $9,11
JP Z,ST4_ENEMY11_DISP;DEFENDER
SBC $9,12
JP Z,ST4_ENEMY12_DISP;ATTACKER1
SBC $9,13
JP Z,ST4_ENEMY13_DISP;ATTACKER2
SBC $9,14
JP Z,ST4_ENEMY14_DISP
SBC $9,15
JP Z,ST4_ENEMY15_DISP;シャッター
SBC $9,16
JP Z,ST4_ENEMY16_DISP;隠し扉
SBC $9,17
JP Z,ST4_ENEMY17_DISP;コンテナ
SBC $9,18
JP Z,ST4_ENEMY18_DISP;大型コンテナ
SBC $9,19
JP Z,ST4_ENEMY19_DISP;飛行機(駐機)
SBC $9,20
JP Z,ST4_ENEMY20_DISP;飛行機
SBC $9,21
JP Z,ST4_ENEMY21_DISP;CIRCULER1
SBC $9,22
JP Z,ST4_ENEMY22_DISP;CIRCULER2
SBC $9,88
JP Z,ST4_ENEMY88_DISP
SBC $9,89
JP Z,ST4_ENEMY89_DISP
SBC $9,90
JP Z,ST4_ENEMY90_DISP
SBC $9,91

;JUMPしなかった場合はSSPを戻す。
PPSW $0

RTN_ST4_EDISP:
;
PPU $28
;
NEXT_ST4_ENEMY_D:

AD $28,ENEMY_STRUCT

JP NC,ST4_ENEMYDISP_LP

RTN

ST4_ENEMY08_DISP:;BULLET
LDW $13,@CHR_BULLET
#if (USE_LIB=FAST_LIB)
JP SGPRINT_4
#else
LD $12,8
JP GPRINT
#endif

ST4_ENEMY10_DISP:;AIRBORN
LDW $13,SG_CHR_DATA03
#if (USE_LIB=NORMAL_G)
JP GPRINT
#endif
#if(USE_LIB=SUPER_GP)
JP SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
JP SGPRINT_FAST
#endif

ST4_ENEMY11_DISP:;DEFENDER
LDW $13,CHR_ST4_02
JP CPRINT_OR

ST4_ENEMY12_DISP:;ATTACKER1
ST4_ENEMY13_DISP:;ATTACKER2
LDW $13,SG_CHR_DATA04
#if (USE_LIB=NORMAL_G)
JP GPRINT
#endif
#if(USE_LIB=SUPER_GP)
JP SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
JP SGPRINT_FAST
#endif
RTN

ST4_ENEMY14_DISP:
RTN

ST4_ENEMY15_DISP:;シャッター(Y:8)
PHUW $11
LD $12,8
LDW $13,CHR_ST4_SHUTTER
CAL GPRINT
PPUW $10
LD $12,8
AD $11,8
LDW $13,CHR_ST4_SHUTTER
JP GPRINT

ST4_ENEMY16_DISP:;隠し扉
;LDW $13,CHR_ST4_SHUTTER
LDW $13,CHR_ST4_DOOR
JP CPRINT_OR

ST4_ENEMY17_DISP:;コンテナ
LDW $13,CHR_ST4_CONT
JP CPRINT_OR

ST4_ENEMY18_DISP:;コンテナ大
PHUW $11
LD $12,16
LDW $13,CHR_ST4_CONT_BIG
CAL CPRINT_OR
PPUW $10
LD $12,16
AD $11,8
LDW $13,CHR_ST4_CONT_BIG+16
JP CPRINT_OR

ST4_ENEMY19_DISP:;飛行機(駐機)
LDW $13,CHR_ST4_AIRPLANE
JP CPRINT_OR

ST4_ENEMY20_DISP:;飛行機
LDW $13,SG_CHR_DATA08;CHR_BOSS4_F_FIGHTER
#if (USE_LIB=NORMAL_G)
JP GPRINT
#endif
#if(USE_LIB=SUPER_GP)
JP SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
JP SGPRINT_FAST
#endif

ST4_ENEMY21_DISP:;CIRCULER1
ST4_ENEMY22_DISP:;CIRCULER2
LDW $13,SG_CHR_DATA05;CHR_ST4_04
#if (USE_LIB=NORMAL_G)
JP GPRINT
#endif
#if(USE_LIB=SUPER_GP)
JP SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
JP SGPRINT_FAST
#endif

ST4_ENEMY88_DISP:
LDW $13,CHR_ST4_AIRBASE
JP CPRINT_OR

ST4_ENEMY89_DISP:
SBC $15,6
JR Z,ST4_ENE89_DIR6
LD $1,$31
LD $0,$15
SB $0,1
BIU $0
BIU $0
BIU $0
LDW $13,CHR_ST4_BASE_A1
ADW $13,$0
JP CPRINT_OR
ST4_ENE89_DIR6:
LDW $13,CHR_ST4_BASE_A6
JP CPRINT_OR

ST4_ENEMY90_DISP:
SBC $15,4
JR Z,ST4_ENE90_DIR4
LD $1,$31
LD $0,$15
SB $0,6
BIU $0
BIU $0
BIU $0
LDW $13,CHR_ST4_BASE_U6
ADW $13,$0
JP CPRINT_OR
ST4_ENE90_DIR4:
LDW $13,CHR_ST4_BASE_U4
JP CPRINT_OR

LDW $13,CHR_ST4_AIRBASE
JP CPRINT_OR

;****** MAPはBG画面に描画するため不要


;*********************************
;*          BOSS4 INIT
;*  +0($9)  種類(0:未使用フラグ,&H01～&HFF)
;*  +1($10)  x(必須)
;*  +2($11)  y(必須)
;*  +3($12)  キャラのXサイズ
;*  +4($13)  キャラのYサイズ
;*  +5($14)  NONE
;*  +6($15)  NONE
;*  +7($16)  LIFE(Cフラグで破壊)(&HFF:破壊不能)
;**********************************
;NOTE
;
;BOSS4は3つのパーツで構成されている。
;PARTS Noは次のとおり
;
;          A9999 <- &H0A(10):CORE
;          B9999
;
;          &H0C(12):UP MISSILE
;          &H0D(13):DOWN MISSILE
;          &H0E(14):FRONT MISSILE
;          &H0F(15):BACK MISSILE
;          &H10(16):FREND FIGHTER
;
;動作の際は下記の各パーツのインデックスアドレスを
;直接指定してXを参照、変更している。
;
; 0:ENEMY_DATA_0 = &H09(09):BOSS4 CORE
; 1:ENEMY_DATA_1 = &H0A(10):BOSS4 HEAD UPPER
; 2:ENEMY_DATA_2 = &H0B(11):BOSS4 HEAD LOWER
;
;ENEMY_DATA
;+0 Active Flag/CHARACTOR No(0:NO 1-8:NO JUDGE 9-:NORM)
;+1 X
;+2 Y
;+3 CHARACTOR X SIZE(当たり判定で使用するので必須)
;+4 CHARACTOR Y SIZE(当たり判定で使用するので必須)
;+5 COUNTER1
;+6 COUNTER2
;+7 LIFE
;------------------------------------------
;+8 SCORE
;+9 DAMAGE
;+A～+F FREE

BOSS4_DATA_CORE:
DB 9,148,16,32,16,08,3,&H0A,10,10,0,0,0,0,0,0      ;CORE
BOSS4_DATA_HEUP:
DB 10,140,16,08,08,00,0,&HFF,0,10,0,0,0,0,0,0       ;HEAD UPPER
BOSS4_DATA_HELW:
DB 11,140,24,08,08,00,0,&HFF,0,10,0,0,0,0,0,0       ;HEAD LOWER
BOSS4_DATA_END:

BOSS4_DATA_NUM:EQU 3;BOSS4のパーツ数

BOSS4_INIT:

;RXCNT
;ENEMY_DATA初期化
LDW $0,ENEMY_DATA
LDW $2,&H0FF
LDW $28,CLEME
CAL IOCS_CAL

;BOSS COREの位置データ等を転送
PRE IX,BOSS4_DATA_CORE
LDIM $17,(IX+$31),8
LDM $25,(IZ+$31),2
CAL INSERT_OBJECT

PRE IX,BOSS4_DATA_HEUP
LDIM $17,(IX+$31),8
LDM $25,(IZ+$31),2
CAL INSERT_OBJECT

PRE IX,BOSS4_DATA_HELW
LDIM $17,(IX+$31),8
LDM $25,(IZ+$31),2
CAL INSERT_OBJECT

;転送したBOSSデータを実体化する
CAL INSERT_OBJECT_ON

;ボス戦闘中フラグをONにする。
PRE IX,NOW_BOSS_FIGHT
ST $30,(IX+$31)
;ボス破壊フラグをOFFにする。
PRE IX,BOSS_DESTROY
ST $31,(IX+$31)
;ボスのデータ数(BOSS4:2)を設定にする。
PRE IX,BOSS_DATA_NUM
LD $0,BOSS4_DATA_NUM
ST $0,(IX+$31)
RTN

;************************************
;*              BOSS4 PRE
;*  (BOSS4 MOVE STANBY POSITION)
;************************************
BOSS4_PRE:

PRE IX,ENEMY_DATA_01;HEAD UPPER
SB (IX+$30),$30
PRE IX,ENEMY_DATA_02;HEAD LOWER
SB (IX+$30),$30
PRE IX,ENEMY_DATA_00;CORE
LD $10,(IX+$30);BOSS4 CORE X
SB $10,$30
ST $10,(IX+$30)

;BOSS4のX座標が96になったらボス戦に突入
SBC $10,96
RTN NC
PRE IX,PHASE
LD $0,3
ST $0,(IX+$31) ;PHASE2->3
ST $31,(IX+$30) ;PHASE_COUNTER->0
RTN

;*********************************
;*          MOVE BOSS4
;*
;*USE:
;*      $0      WORK
;*      $2,$3   JUMP TABLE
;*      $9-$16  ENEMY DATA
;*      $28     COUNTER
;*      IX
;*      IZ
;*********************************
BOSS4_FIRE_MAX:EQU 3;正面、上下ミサイル発射最大数
BOSS4_ENEF_WAIT:EQU 16;正面ミサイル発射WAIT
BOSS4_UDMIS_WAIT:EQU 16;上下ミサイル発射WAIT

MOVE_BOSS4:

LD $28,$31

MOVE_BOSS4_LOOP:
PHU $28
PRE IX,ENEMY_DATA

LDM $9,(IX+$28),8

SBC $9,$31
JR Z,NEXT_MOVE_BOSS4
SBC $9,9
JP Z,BOSS4_P09_MOVE;BOSS4 CORE
SBC $9,10
JP Z,BOSS4_P10_MOVE;HEAD ABOVE
SBC $9,11
JP Z,BOSS4_P11_MOVE;HEAD UNDER
SBC $9,12
JP Z,BOSS4_P12_MOVE;BOSS4 UP MISSILE
SBC $9,13
JP Z,BOSS4_P13_MOVE;BOSS4 DOWN MISSILE
SBC $9,14
JP Z,BOSS4_P14_MOVE;BOSS4 FRONT MISSILE
SBC $9,15
JP Z,BOSS4_P15_MOVE;BOSS4 BACK MISSILE
SBC $9,16
JP Z,BOSS4_P16_MOVE;BOSS4 FREND FIGHTER

NEXT_MOVE_BOSS4:
PPU $28
AD $28,ENEMY_STRUCT
JR NC,MOVE_BOSS4_LOOP

RTN

BOSS4_P09_MOVE:

PRE IZ,SECTION
LD $0,(IZ+$31)

SBC $0,$31
JR Z,BOSS4_P09_SEC0;敵友軍機飛来
SBC $0,$30
JR Z,BOSS4_P09_SEC1;WAIT
SBC $0,2
JR Z,BOSS4_P09_SEC2;レーザー砲発射準備
SBC $0,3
JP Z,BOSS4_P09_SEC3;レーザー砲発射
SBC $0,4
JP Z,BOSS4_P09_SEC4;WAIT
SBC $0,5
JP Z,BOSS4_P09_SEC5;レーザー砲撤収
SBC $0,6
JP Z,BOSS4_P09_SEC6;上移動
SBC $0,7
JP Z,BOSS4_P09_SEC7;左移動
SBC $0,8
JP Z,BOSS4_P09_SEC8;下移動
SBC $0,9
JP Z,BOSS4_P09_SEC9;右移動
SBC $0,10
JP Z,BOSS4_P09_SEC10;初期位置まで戻る

BOSS4_P09_SEC0:;敵友軍機飛来
CAL BOSS4_FREND_INS
LDW $0,&H0001;SECTION=1,SECTION_COUNTER=0
PRE IZ,SECTION
STW $0,(IZ+$31)
LD $14,BOSS4_ENEF_WAIT
JP END_BOSS4_MOVE

BOSS4_P09_SEC1:;WAIT
SB $14,$30
JP NC,END_BOSS4_MOVE
END_BOSS4P1_SEC1:
LDW $0,&H0002;SECTION=2,SECTION_COUNTER=0
PRE IZ,SECTION
STW $0,(IZ+$31)
LD $14,4;WAIT COUNTER=8
LD $15,3;LIMIT COUNTER=3
JP END_BOSS4_MOVE

BOSS4_P09_SEC2:;正面ミサイル発射準備
SB $14,$30;WAIT COUNTER-=1
JP NC,END_BOSS4_MOVE
PRE IZ,ENEMY_DATA_01+2;HEAD UPPER Y
SB (IZ+$31),$30
PRE IZ,ENEMY_DATA_02+2;HEAD LOWER Y
AD (IZ+$31),$30
LD $14,8;WAIT COUNTER=8
SB $15,$30;LIMIT COUNTER
JP NC,END_BOSS4_MOVE
END_BOSS4P09SEC2:
LDW $0,&H0003;SECTION=3,SECTION_COUNTER=0
PRE IZ,SECTION
STW $0,(IZ+$31)
LD $14,BOSS4_ENEF_WAIT;FIRE WAIT COUNTER
LD $15,BOSS4_FIRE_MAX
JP END_BOSS4_MOVE

;正面ミサイルのデータ
BOSS4_P09SEC3_LA:
DB 14,0,0,8,8,0,0,&HFF,0,1

BOSS4_P09_SEC3:;正面ミサイル発射

SB $14,$30
JP NC,END_BOSS4_MOVE

PRE IZ,BOSS4_P09SEC3_LA
LDIM $17,(IZ+$31),8
LDM $25,(IZ+$31),2
LD $18,$10
LD $19,$11
AD $19,4
CAL INSERT_OBJECT
LD $14,BOSS4_ENEF_WAIT;FIRE WAIT COUNTER(RESET)
SB $15,$30
JP NC,END_BOSS4_MOVE

LDW $0,&H0004;SECTION=4,SECTION_COUNTER=0
PRE IZ,SECTION
STW $0,(IZ+$31)
LD $14,16;WAIT COUNTER=16
JP END_BOSS4_MOVE

BOSS4_P09_SEC4:;WAIT
SB $14,$30
JP NC,END_BOSS4_MOVE
LDW $0,&H0005;SECTION=5,SECTION_COUNTER=0
PRE IZ,SECTION
STW $0,(IZ+$31)
LD $14,4;WAIT COUNTER=4
LD $15,3;LIMIT COUNTER=3
JP END_BOSS4_MOVE

BOSS4_P09_SEC5:;レーザー砲撤収
SB $14,$30;WAIT COUNTER-=1
JP NC,END_BOSS4_MOVE
PRE IZ,ENEMY_DATA_01+2;HEAD ABOVE Y
AD (IZ+$31),$30
PRE IZ,ENEMY_DATA_02+2;HEAD UNDER Y
SB (IZ+$31),$30
LD $14,8;WAIT COUNTER=8
SB $15,$30;LIMIT COUNTER
JP NC,END_BOSS4_MOVE
LDW $0,&H0006;SECTION=6,SECTION_COUNTER=0
PRE IZ,SECTION
STW $0,(IZ+$31)
JP END_BOSS4_MOVE

BOSS4_P09_SEC6:;上移動
;HEAD MOVE
PRE IZ,ENEMY_DATA_01+2;HEAD ABOVE Y
SB (IZ+$31),$30
PRE IZ,ENEMY_DATA_02+2;HEAD UNDER Y
SB (IZ+$31),$30
;CORE MOVE
SB $11,$30
SBC $11,$31
JP NZ,END_BOSS4_MOVE

END_BOSS4P09SEC6:
CAL BOSS4_FREND_INS
LDW $0,&H0007;SECTION=7,SECTION_COUNTER=0
PRE IZ,SECTION
STW $0,(IZ+$31)
LD $14,BOSS4_UDMIS_WAIT
LD $15,$31
JP END_BOSS4_MOVE

;下向きミサイルのデータ(&H0E:14)
BOSS4_P09SEC3_DM:
DB 13,0,0,8,8,0,0,&HFF,0,1

BOSS4_P09_SEC7:;左移動
PRE IZ,ENEMY_DATA_01+1;HEAD ABOVE X
SB (IZ+$31),$30
PRE IZ,ENEMY_DATA_02+1;HEAD UNDER X
SB (IZ+$31),$30

;DOWN MISSILE FIRE
SB $14,$30
JR NC,BOSS4_DMIS_NF
;最大発射数以上は撃たない
SBC $15,BOSS4_FIRE_MAX
JR NC,BOSS4_DMIS_NF

PRE IZ,BOSS4_P09SEC3_DM
LDIM $17,(IZ+$31),8
LDM $25,(IZ+$31),2
LD $18,$10
AD $18,8
LD $19,$11
AD $19,8
CAL INSERT_OBJECT
LD $14,BOSS4_UDMIS_WAIT;COUNTER(RESET)
AD $15,$30;発射数+=1

BOSS4_DMIS_NF:
;CORE MOVE
SB $10,$30
SBC $10,4
JP NZ,END_BOSS4_MOVE

END_BOSS4P09SEC7:
CAL BOSS4_FREND_INS
LDW $0,&H0008;SECTION=8,SECTION_COUNTER=0
PRE IZ,SECTION
STW $0,(IZ+$31)
LDW $14,0;COUNTER1/2=0(RESET)
JP END_BOSS4_MOVE

;バック・ミサイルのデータ(&H10:16)
BOSS4_P09SEC3_BM:
DB 15,0,0,8,8,0,0,&HFF,0,1

BOSS4_P09_SEC8:;下移動
;HEAD MOVE
PRE IZ,ENEMY_DATA_01+2;HEAD ABOVE Y
AD (IZ+$31),$30
PRE IZ,ENEMY_DATA_02+2;HEAD UNDER Y
AD (IZ+$31),$30
;CORE MOVE
AD $11,$30

;Y座標が16になったらバックミサイルを発射
SBC $11,16
JR NZ,BOSS4_BM_NF
PRE IZ,BOSS4_P09SEC3_BM
LDIM $17,(IZ+$31),8
LDM $25,(IZ+$31),2
LD $18,$10
AD $18,24
LD $19,$11
AD $19,4
CAL INSERT_OBJECT

BOSS4_BM_NF:

SBC $11,32
JP NZ,END_BOSS4_MOVE

END_BOSS4P09SEC8:
CAL BOSS4_FREND_INS
LDW $0,&H0009;SECTION=9,SECTION_COUNTER=0
PRE IZ,SECTION
STW $0,(IZ+$31)
LD $14,BOSS4_UDMIS_WAIT
LD $15,$31
JP END_BOSS4_MOVE

;上向きミサイルのデータ(&H0D:13)
BOSS4_P09SEC3_UM:
DB 12,0,0,8,8,0,0,&HFF,0,1

BOSS4_P09_SEC9:;右移動
PRE IZ,ENEMY_DATA_01+1;HEAD ABOVE X
AD (IZ+$31),$30
PRE IZ,ENEMY_DATA_02+1;HEAD UNDER X
AD (IZ+$31),$30

;UP MISSILE FIRE
SB $14,$30
JR NC,BOSS4_UMIS_NF
;最大発射数以上は撃たない
SBC $15,BOSS4_FIRE_MAX
JR NC,BOSS4_UMIS_NF
PRE IZ,BOSS4_P09SEC3_UM
LDIM $17,(IZ+$31),8
LDM $25,(IZ+$31),2
LD $18,$10
AD $18,8
LD $19,$11
CAL INSERT_OBJECT
LD $14,BOSS4_UDMIS_WAIT;COUNTER(RESET)
AD $15,$30;発射数+=1

BOSS4_UMIS_NF:
;CORE MOVE
AD $10,$30
SBC $10,96
JP NZ,END_BOSS4_MOVE

END_BOSS4P09SEC9:
CAL BOSS4_FREND_INS
LDW $0,&H000A;SECTION=10,SECTION_COUNTER=0
PRE IZ,SECTION
STW $0,(IZ+$31)
JP END_BOSS4_MOVE

BOSS4_P09_SEC10:;初期位置まで戻る(上移動)
;HEAD MOVE
PRE IZ,ENEMY_DATA_01+2;HEAD ABOVE Y
SB (IZ+$31),$30
PRE IZ,ENEMY_DATA_02+2;HEAD UNDER Y
SB (IZ+$31),$30
;CORE MOVE
SB $11,$30
SBC $11,16
JP NZ,END_BOSS4_MOVE

LDW $0,&H0000;SECTION=0,SECTION_COUNTER=0
PRE IZ,SECTION
STW $0,(IZ+$31)
JP END_BOSS4_MOVE

BOSS4_P10_MOVE:
LD $16,&HFF;HEAD ABOVEのLIFEを回復させる
JP END_BOSS4_MOVE

BOSS4_P11_MOVE:
LD $16,&HFF;HEAD UNDERのLIFEを回復させる
JP END_BOSS4_MOVE

BOSS4_P12_MOVE:;BOSS4 UP MISSILE
SB $11,$30
SBC $11,4
JP NC,END_BOSS4_MOVE
JR ST4_KILL_BOSS

BOSS4_P13_MOVE:;BOSS4 DOWN MISSILE
AD $11,$30
SBC $11,44
JP C,END_BOSS4_MOVE
JR ST4_KILL_BOSS

BOSS4_P14_MOVE:;BOSS4 FRONT MISSILE
SB $10,3
JR NC,END_BOSS4_MOVE
JR ST4_KILL_BOSS

BOSS4_P15_MOVE:;BOSS4 BACK MISSILE
AD $10,3
SBC $10,144
JR C,END_BOSS4_MOVE
JR ST4_KILL_BOSS

BOSS4_P16_MOVE:;BOSS4 FREND FIGHTER
SB $10,4
JR NC,END_BOSS4_MOVE
JR ST4_KILL_BOSS

ST4_KILL_BOSS:
CAL DELETE_OBJECT
JP NEXT_MOVE_BOSS4

END_BOSS4_MOVE:
PRE IX,ENEMY_DATA
STM $9,(IX+$28),8
JP NEXT_MOVE_BOSS4

;BOSS4の友軍機のデータ(&H10:16)
BOSS4_FREND_DAT:
DB 16,0,0,8,8,0,0,&H00,2,1

BOSS4_FREND_INS:
;TOP
PRE IZ,BOSS4_FREND_DAT
LDIM $17,(IZ+$31),8
LDM $25,(IZ+$31),2
LD $18,154
LD $19,10
CAL INSERT_OBJECT

;BOTTOM
LD $19,30
CAL INSERT_OBJECT

;TOP
LD $0,8
LD $18,144
LD $19,20
JP INSERT_OBJECT

;*********************************
;*        DISP BOSS4
;*
;*USE:
;*      $0      WORK
;*      $2,$3   JUMP TABLE
;*      $9-$16  ENEMY DATA
;*      $28     COUNTER
;*      IX
;*      IZ
;*********************************
DISP_BOSS4:
LD $28,$31

DISP_BOSS4_LOOP:

PRE IX,ENEMY_DATA

LDM $9,(IX+$28),8
SBC $9,$31
JR Z,NEXT_DISP_BOSS4
;
PHU $28
;
;GPRINTのRTN命令でRTN_ST4_DBOSS4に戻れるようにするため、RTN_ST4_DBOSS4のアドレスを
;SSPにPUSHしておく。
;なおGPRINTからの復帰はRTNでありSSPにスタックされたアドレス+1からプログラムを実行するため
;RTN_ST4_DBOSS4のアドレスから-1したものをSSPにPUSHする。
LDW $0,RTN_ST4_DBOSS4-1
PHSW $1

SBC $9,09
JR Z,BOSS4_P09_DISP
SBC $9,10
JP Z,BOSS4_P10_DISP
SBC $9,11
JP Z,BOSS4_P11_DISP
SBC $9,12
JP Z,BOSS4_P12_DISP
SBC $9,13
JP Z,BOSS4_P13_DISP
SBC $9,14
JP Z,BOSS4_P14_DISP
SBC $9,15
JP Z,BOSS4_P15_DISP
SBC $9,16
JP Z,BOSS4_P16_DISP

;JUMPしなかった場合はSSPを戻す。
PPSW $0

RTN_ST4_DBOSS4:

;
PPU $28
;
NEXT_DISP_BOSS4:
AD $28,ENEMY_STRUCT
JR NC,DISP_BOSS4_LOOP
RTN

BOSS4_P09_DISP:;(BOSS4)
;
PHUW $11
;
LD $12,8
LDW $13,SG_CHR_DATA14;CHR_BOSS4_2_1
#if (USE_LIB=NORMAL_G)
CAL GPRINT
#endif
#if(USE_LIB=SUPER_GP)
CAL SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
CAL SGPRINT_FAST
#endif
;
PPUW $10
PHUW $11
;
LD $12,8
AD $10,8
LDW $13,SG_CHR_DATA15;CHR_BOSS4_3_1
#if (USE_LIB=NORMAL_G)
CAL GPRINT
#endif
#if(USE_LIB=SUPER_GP)
CAL SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
CAL SGPRINT_FAST
#endif
;
PPUW $10
PHUW $11
;
LD $12,8
AD $10,16
LDW $13,SG_CHR_DATA16;CHR_BOSS4_4_1
#if (USE_LIB=NORMAL_G)
CAL GPRINT
#endif
#if(USE_LIB=SUPER_GP)
CAL SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
CAL SGPRINT_FAST
#endif
;
PPUW $10
PHUW $11
;
LD $12,8
AD $10,24
LDW $13,SG_CHR_DATA17;CHR_BOSS4_5_1
#if (USE_LIB=NORMAL_G)
CAL GPRINT
#endif
#if(USE_LIB=SUPER_GP)
CAL SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
CAL SGPRINT_FAST
#endif
;
PPUW $10
AD $11,8
PHUW $11
;
LD $12,8
LDW $13,SG_CHR_DATA19;CHR_BOSS4_2_2
#if (USE_LIB=NORMAL_G)
CAL GPRINT
#endif
#if(USE_LIB=SUPER_GP)
CAL SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
CAL SGPRINT_FAST
#endif
;
PPUW $10
PHUW $11
;
LD $12,8
AD $10,8
LDW $13,SG_CHR_DATA20;CHR_BOSS4_3_2
#if (USE_LIB=NORMAL_G)
CAL GPRINT
#endif
#if(USE_LIB=SUPER_GP)
CAL SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
CAL SGPRINT_FAST
#endif
;
PPUW $10
PHUW $11
;
LD $12,8
AD $10,16
LDW $13,SG_CHR_DATA21;CHR_BOSS4_4_2
#if (USE_LIB=NORMAL_G)
CAL GPRINT
#endif
#if(USE_LIB=SUPER_GP)
CAL SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
CAL SGPRINT_FAST
#endif
;
PPUW $10
;
LD $12,8
AD $10,24
LDW $13,SG_CHR_DATA22;CHR_BOSS4_5_2
#if (USE_LIB=NORMAL_G)
JP GPRINT
#endif
#if(USE_LIB=SUPER_GP)
JP SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
JP SGPRINT_FAST
#endif
;
RTN

BOSS4_P10_DISP:
LD $12,8
LDW $13,SG_CHR_DATA13;CHR_BOSS4_1_1
#if (USE_LIB=NORMAL_G)
JP GPRINT
#endif
#if(USE_LIB=SUPER_GP)
JP SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
JP SGPRINT_FAST
#endif

BOSS4_P11_DISP:
LD $12,8
LDW $13,SG_CHR_DATA18;CHR_BOSS4_1_2
#if (USE_LIB=NORMAL_G)
JP GPRINT
#endif
#if(USE_LIB=SUPER_GP)
JP SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
JP SGPRINT_FAST
#endif

BOSS4_P12_DISP:
LD $12,8
LDW $13,SG_CHR_DATA11;CHR_BOSS4_U_MIS
#if (USE_LIB=NORMAL_G)
JP GPRINT
#endif
#if(USE_LIB=SUPER_GP)
JP SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
JP SGPRINT_FAST
#endif

BOSS4_P13_DISP:
LD $12,8
LDW $13,SG_CHR_DATA12;CHR_BOSS4_D_MISSILE
#if (USE_LIB=NORMAL_G)
JP GPRINT
#endif
#if(USE_LIB=SUPER_GP)
JP SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
JP SGPRINT_FAST
#endif

BOSS4_P14_DISP:
LDW $13,SG_CHR_DATA09;CHR_BOSS4_F_MISSILE
#if (USE_LIB=NORMAL_G)
JP GPRINT
#endif
#if(USE_LIB=SUPER_GP)
JP SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
JP SGPRINT_FAST
#endif

BOSS4_P15_DISP:
LD $12,8
LDW $13,SG_CHR_DATA10;CHR_BOSS4_B_MISSILE
#if (USE_LIB=NORMAL_G)
JP GPRINT
#endif
#if(USE_LIB=SUPER_GP)
JP SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
JP SGPRINT_FAST
#endif

BOSS4_P16_DISP:
LD $12,8
LDW $13,SG_CHR_DATA08;CHR_BOSS4_F_FIGHTER
#if (USE_LIB=NORMAL_G)
JP GPRINT
#endif
#if(USE_LIB=SUPER_GP)
JP SGPRINT
#endif
#if(USE_LIB=FAST_LIB)
JP SGPRINT_FAST
#endif

;**********************************
;*      BOSS4撃破時の処理
;**********************************
BOSS_DEF_ST4:

;RTN CODE 0:継続をセット
LD $5,$31

;下へ降下
LD $0,2
PRE IX,ENEMY_DATA_00;BOSS4 CORE
LD $11,(IX+$0)
AD $11,$30
ST $11,(IX+$0);BOSS4 CORE
AD $0,16
AD (IX+$0),$30;BOSS4 ABOVE HEAD
AD $0,16
AD (IX+$0),$30;BOSS4 UNDER HEAD

PRE IX,EXTRA_COUNTER
AD (IX+$31),$30
LD $0,40
SBC (IX+$31),$0
RTN NZ
;RTN CODE 1:次のフェーズに移行をセット
LD $5,$30
RTN

;**********************************
;*      ST4_INIT_GRAPHIC
;**********************************

ST4_INIT_GRAPHIC:
LDW $0,0;自機
LDW $2,CHR_FIGHTER
CAL SET_SGPRINT_DATA

LDW $0,1;MY BOMB L
LDW $2,CHR_BOMB_L
CAL SET_SGPRINT_DATA

LDW $0,2;MY_BOMB_R
LDW $2,CHR_BOMB_R
CAL SET_SGPRINT_DATA

;ENEMY

LDW $0,3
LDW $2,CHR_ST4_01
CAL SET_SGPRINT_DATA

LDW $0,4
LDW $2,CHR_ST4_03
CAL SET_SGPRINT_DATA

LDW $0,5
LDW $2,CHR_ST4_04;CIRCULAR
CAL SET_SGPRINT_DATA

;LDW $0,6
;LDW $2,CHR_ST4_04
;CAL SET_SGPRINT_DATA

LDW $0,7;BOSS
LDW $2,CHR_WHITE_BOX
CAL SET_SGPRINT_DATA

;BOSS
LDW $0,8;BOSS FREND FIGHTER
LDW $2,CHR_BOSS4_F_FGT
CAL SET_SGPRINT_DATA

LDW $0,9;BOSS FRONT MISSILE
LDW $2,CHR_BOSS4_F_MIS
CAL SET_SGPRINT_DATA

LDW $0,10;BOSS BACK MISSILE
LDW $2,CHR_BOSS4_B_MIS
CAL SET_SGPRINT_DATA

LDW $0,11;BOSS UP MISSILE
LDW $2,CHR_BOSS4_U_MIS
CAL SET_SGPRINT_DATA

LDW $0,12;BOSS4 DOWN MISSILE
LDW $2,CHR_BOSS4_D_MIS
CAL SET_SGPRINT_DATA

LDW $0,13;HEAD UPPER
LDW $2,CHR_BOSS4_1_1
CAL SET_SGPRINT_DATA

LDW $0,14;BOSS CORE
LDW $2,CHR_BOSS4_2_1
CAL SET_SGPRINT_DATA

LDW $0,15;BOSS
LDW $2,CHR_BOSS4_3_1
CAL SET_SGPRINT_DATA

LDW $0,16;BOSS
LDW $2,CHR_BOSS4_4_1
CAL SET_SGPRINT_DATA

LDW $0,17;BOSS
LDW $2,CHR_BOSS4_5_1
CAL SET_SGPRINT_DATA

LDW $0,18;HEAD LOWER
LDW $2,CHR_BOSS4_1_2
CAL SET_SGPRINT_DATA

LDW $0,19;BOSS
LDW $2,CHR_BOSS4_2_2
CAL SET_SGPRINT_DATA

LDW $0,20;BOSS
LDW $2,CHR_BOSS4_3_2
CAL SET_SGPRINT_DATA

LDW $0,21;BOSS
LDW $2,CHR_BOSS4_4_2
CAL SET_SGPRINT_DATA

LDW $0,22;BOSS
LDW $2,CHR_BOSS4_5_2
CAL SET_SGPRINT_DATA

RTN

