Dragon's Lair (NES)

The NES Dragon's Lair is a rather underwhelming platformer based on Don Bluth's famous Laserdisc game.

Source Code
While the US version uses a 128KB ROM, the Japanese and European ones use 256KB ROMs. As a result, the latter two have a lot of unused space filled with garbage, leftovers from MS-DOS executables, and other crap.

Still, there's a lot of source code within said garbage.

Combined Source
The Japanese and European versions contain different parts of the source code, oddly, but they can be compiled in one huge assembler file, covering almost all of program banks 30-39. Regardless, there are some differences between the two versions, and it appears the Japanese one was done earlier; see the "diff" file in the next section.

B3B_END IF	B3B_END>$BFFF PRINTF "**** BANK $3B too long !! ****" ENDIF


 * End of bank $3A/$3B




 * Start of bank $39

ORG	$139,$A000


 * Sprite attribute tables
 * Sprite attribute tables

SPR3_ATAB_L DL	A_B0 DL	A_B1 DL	A_B2 DL	A_B3 DL	A_B4 DL	A_B5 DL	A_B6 DL	A_B7 DL	A_B8 DL	A_B9 DL	A_B10 DL	A_B11 DL	A_B12 DL	A_B13 DL	A_B14 DL	A_B15 DL	A_B16 DL	A_B17 DL	A_B18 DL	A_B19 DL	A_B20 DL	A_B21 DL	A_B22 DL	A_B23 DL	A_B24 DL	A_B25 DL	A_B26 DL	A_B27 DL	A_B28 DL	A_B29 DL	A_B30 DL	A_B31 DL	A_B32 DL	A_B33

SPR3_ATAB_H DH	A_B0 DH	A_B1 DH	A_B2 DH	A_B3 DH	A_B4 DH	A_B5 DH	A_B6 DH	A_B7 DH	A_B8 DH	A_B9 DH	A_B10 DH	A_B11 DH	A_B12 DH	A_B13 DH	A_B14 DH	A_B15 DH	A_B16 DH	A_B17 DH	A_B18 DH	A_B19 DH	A_B20 DH	A_B21 DH	A_B22 DH	A_B23 DH	A_B24 DH	A_B25 DH	A_B26 DH	A_B27 DH	A_B28 DH	A_B29 DH	A_B30 DH	A_B31 DH	A_B32 DH	A_B33

A_B0	DS	34,2 DS	22,1 DS	8,0 A_B1	DS	31,2 DS	24,1 DS	9,0 A_B2	DS	34,2 DS	25,1 DS	5,0 A_B3	DS	21,2 DS	16,1 DS	7,2 DS	8,1 DS	12,0 A_B4	DS	9,2 DS	12,1 DS	1,0 DS	18,2 DS	24,1 A_B5	DS	28,2 DS	31,1 DS	5,0 A_B6	DS	31,2 DS	21,1 DS	12,0 A_B7	DS	28,2 DS	23,1 DS	13,0 A_B8	DS	9,2 DS	15,1 DS	1,0 DS	24,2 DS	15,1 A_B9	DS	37,2 DS	20,1 DS	7,0 A_B10	DS	14,2 DS	10,1 DS	40,0 A_B11	DS	25,0 DS	11,2 DS	25,1 DS	3,0 A_B12	DS	15,2 DS	36,1 DS	13,0 A_B13	DS	9,2 DS	17,1 DS	1,0 DS	16,2 DS	21,1 A_B14	DS	31,2 DS	31,1 DS	2,0 A_B15	DS	9,2 DS	13,1 DS	1,0 DS	18,2 DS	23,1 A_B16	DS	29,2 DS	32,1 DS	3,0 A_B17	DS	12,2 DS	17,1 DS	1,0 DS	8,2 DS	22,1 DS	4,0 A_B18	DS	13,0 DS	6,1 DS	45,0 A_B19	DS	18,0 DS	2,1 DS	34,3 DS	10,1 A_B20	DS	52,3 DS	12,1 A_B21	DS	64,0 A_B22	DS	46,1 DS	18,0 A_B23	DS	11,0 DS	20,1 DS	10,2 DS	23,3 A_B24	DS	25,0 DS	23,3 DS	16,0 A_B26	DS	58,0 DS	6,1 A_B33 A_B27       	DS	64,1 A_B28	DS	15,3 DS	17,0 DS	32,1 A_B29	DS	11,0 DS	20,2 DS	33,3 A_B30	DS	18,3 DS	46,0 A_B31 A_B25	DS	64,3 A_B32        	DS	32,2 DS	23,1 DS	9,0




 * Gold bonus screen


 * IN
 * A = 0-No bonus, 1-Normal bonus , 2-Big bonus
 * A = 0-No bonus, 1-Normal bonus , 2-Big bonus

G_BONUS1 TAX BNE	!1	;No bonus RTS !1	LDA	#3	;Preload with start adding to DEX		;10's digit. BEQ	!2 LDA	#2	;Change to adding to 100's !2			;digit. STA	ZPAGE_BYTE9	;Store which digit to start ;adding to.

LDA	PL_GOLD ORA	PL_GOLD+1	;Don't do gold bonus if no ORA	PL_GOLD+2	;gold. CMP	#246 BNE	!3 RTS !3

LDA	#0 STA	N_COLAP_CHR STA	N_BONUS_FLAG

JSR	SET_S0

LDA	#128	;Stop music JSR	START_TUNE

JSR	DISABLE_NC

LDA	#GR_1ST+24     	;Background bank for chrs STA	N_BG_BANK1 LDA	#GR_1ST+24+2 STA	N_BG_BANK2

LDA	#PAL_1 JSR	CLS

LDA	#21	;'GOLD BONUS' JSR	DRAW_SCR39

JSR	D_GB	;Draw gold bars

JSR	ENABLE_CN

LDA	#$FF STA	CDF_A1+1

JSR	SPR_CLEAR   	;All sprite off screen LDA	#39                  	;Put on split CHR STA	$200	;Y LDA	#64 STA	$201	;Character LDA	#BIT5 STA	$202	;Ctr LDA	#16 STA	$203	;X LDA	#1 STA	N_DMA_FLAG WAIT_FRAME

JSR	ENABLE_SPR

LDX	#0 JSR	FADE_IN

LDX	#20	;Wait before starting JSR	M_WAIT_FRAME

LDY	#>SCR_START+(32*16)+10-2 LDX	#SCR_START+(32*20)+10-2 LDX	#SCR_START+(32*24)+10-2 LDX	#SCR_START+(32*16)+10 LDX	#SCR_START+(32*20)+10 LDX	#SCR_START+(32*24)+10 LDX	#<SCR_START+(32*24)+10 LDA	PL_GOLD	;100's of gold JSR	GB_D

RTS




 * Draw a highlighted bar


 * IN
 * X - LSB Screen address of bar left
 * Y - MSB Screen address of bar left
 * A = Number in bar
 * A = Number in bar

GB_D PHA LDA	#0 STA	ZPAGE_BYTE11 PLA

SEC SBC	#246 STA	ZPAGE_BYTE10   	;Number highlighted BEQ	!1

LDA	#PAL_1 STA	PR_ATTR


 * Draw highlighted ones

!2	JSR	D_G2X2 INC	ZPAGE_BYTE11	;Number drawn DEC	ZPAGE_BYTE10 BNE	!2


 * Draw unhighlighted ones

!1	LDA	#PAL_3 STA	PR_ATTR

!4	LDA	ZPAGE_BYTE11 CMP	#10 BNE	!3 RTS !3	JSR	D_G2X2 INC	ZPAGE_BYTE11 JMP	!4


 * Draw a gold 2x2

D_G2X2 STX	ZPAGE_WORD1 STY	ZPAGE_WORD1+1

LDA	PR_ATTR JSR	SET_SCR_ATTR	;Set attribute for quad
 * Set attribute

LDX	ZPAGE_WORD1 LDY	ZPAGE_WORD1+1 STY	VDP_VRAM_PTR STX	VDP_VRAM_PTR
 * Draw top line

LDA	#$69 STA	VDP_VRAM_DATA LDA	#$6A STA	VDP_VRAM_DATA

TXA CLC ADC	#32 TAX BCC	!1 INY !1	STY	VDP_VRAM_PTR STX	VDP_VRAM_PTR
 * Downline and draw second line

LDA	#$6B STA	VDP_VRAM_DATA LDA	#$6C STA	VDP_VRAM_DATA

LDX	ZPAGE_WORD1 LDY	ZPAGE_WORD1+1 INX INX RTS


 * Clear a bar
 * Clear a bar


 * IN
 * X - LSB Screen address of bar left
 * Y - MSB Screen address of bar left
 * A - Number in bar to start with
 * A - Number in bar to start with

GB_R

SEC SBC	#246 STA	ZPAGE_BYTE10 STY	ZPAGE_WORD11+1 STX	ZPAGE_WORD11

!3	LDA	ZPAGE_BYTE10 BEQ	!5 ASL	A	;Icons 2 chrs wide !1	LDY	ZPAGE_WORD11+1	;Add offset to screen address ADC	ZPAGE_WORD11 TAX

JSR	CON_SCR_ATTR	;Calc attribute address STX	N_BONUS_AADR	;Set up NMI to draw attribute STY	N_BONUS_AADR+1

STA	N_BONUS_ATTR	;PAL_3 in rlevant bits EOR	#$FF STA	N_BONUS_AMASK	;Hole for attribute LDA	#1 STA	N_BONUS_FLAG STA	N_BG_FLAG

LDA	#24 STA	ZPAGE_BYTE11

LDA	#1	;Add to score LDY	ZPAGE_BYTE9 JSR	SC_ADD

LDY	#18       	;Make sound FX	JSR	FX_TRIGGER

!4	JSR	PANEL_SCAN LDA	#1 STA	N_BG_FLAG WAIT_FRAME DEC	ZPAGE_BYTE11 BNE	!4

DEC	ZPAGE_BYTE10 BNE	!3

!5	DEC	ZPAGE_BYTE9

RTS


 * Setup NMI vars to change score digits
 * Setup NMI vars to change score digits


 * Scan the scores,lives and gold and if any need changing then
 * setup one digit to be changed.

PANEL_SCAN LDA	N_P_FLAG BEQ	!1	;Still waiting for update RTS !1


 * Scan current player score,gold or lives

LDX	#PL_VARS_LEN-1 PS_LP	LDA	PL_SC,X CMP	PL_DATA_SO,X	;Search for any differences BNE	PS_FND DEX BPL	PS_LP


 * Scan dormat players score

LDX	#5-1	;Just do score PS_LP2	LDA	PL_SC+P_VARS_LEN,X CMP	PL2_DATA_SO,X	;Search for any differences BNE	PS_FND1 DEX BPL	PS_LP2

RTS

PS_FND1	STA	PL2_DATA_SO,X	;Set onscreen for pl 2 score SEC SBC	#246-$0A STA	N_P_CHR	;Set character to draw

LDA	PL_NUM BNE	PS_SNMI	;This is player 1's score(Lft) JMP	PS_RGT	;This is player 2's score(Rgt)

PS_FND STA	PL_DATA_SO,X	;Set onscreen var SEC SBC	#246-$0A STA	N_P_CHR	;Set character to draw

LDA	PL_NUM BEQ	PS_SNMI	;This is player 1's score(Lft) ;This is player 2's score(Rgt) PS_RGT	TXA CMP	#5	;If Gold or lives alternate BCS	!1	;with whoose go it is	CLC ADC	#PL_VARS_LEN	;If score swap their sides TAX !1


 * Setup vars to get NMI to draw a score digit.

PS_SNMI LDA	P_ATAB,X STA	N_P_SADR LDA	#>SCR_START STA	N_P_SADR+1

LDA	#1 STA	N_P_FLAG

RTS


 * Screen address offset table

P_ATAB	DB	96+96+9	;Player 1 score DB	96+96+10 DB	96+96+11 DB	96+96+12 DB	96+96+13 DB	96+64+24	;        Gold DB	96+64+25 DB	96+64+26 DB	96+64+5	;        Lives DB	96+64+6 DB	96+96+18	;Player 2 score DB	96+96+19 DB	96+96+20 DB	96+96+21 DB	96+96+22


 * Throw a dagger control routines
 * Throw a dagger control routines


 * Initialization, this routine starts a dagger if there is one free


 * This routine was modifyed to cope with axes and fireballs


 * IN
 * A=Direction (BIT6=0 - Facing right 1 - Facing left)
 * A=Direction (BIT6=0 - Facing right 1 - Facing left)

D_INIT STA	ZPAGE_BYTE2

LDX	WEAPON_TYPE BEQ	DI_3ON	;3 daggers allowed DEX BEQ	DI_2ON	;2 axes JMP	DI_1ON	;1 fireball

DI_3ON	LDX	#2*D_VAR_LEN LDA	D_VARS+D_X_OFF+(2*D_VAR_LEN) BEQ	DI_FREE DI_2ON	LDX	#1*D_VAR_LEN LDA	D_VARS+D_X_OFF+(1*D_VAR_LEN) BEQ	DI_FREE DI_1ON	LDX	#0*D_VAR_LEN LDA	D_VARS+D_X_OFF+(0*D_VAR_LEN) BEQ	DI_FREE

RTS


 * X holds offset of block to init.

DI_FREE LDA	WEAPON_TYPE STA	D_VARS+D_TYP_OFF,X ;Store type in vars

LDA	#0 STA	D_VARS+D_ANI_OFF,X ;Start at first anim


 * Setup Y velocity

LDA	#<(-800) STA	D_VARS+D_YSP_OFF,X LDA	#>(-800) STA	D_VARS+D_YSP_OFF+1,X


 * Setup X velocitys and X,Y's

LDA	ZPAGE_BYTE2 AND	#SDC_LEFT BEQ	DI_GOING_RGT


 * Going left


 * Set velocity going left

LDA	#<0+(0-D_XSPEED) STA	D_VARS+D_XSP_OFF,X LDA	#>0+(0-D_XSPEED) STA	D_VARS+D_XSP_OFF+1,X

LDA	ZPAGE_BYTE2 AND	#SDC_DOWN BNE	DI_CRAWLING_L


 * Throw while standing up facing left

LDA	DIRK_X_ONSCR STA	D_VARS+D_X_OFF,X LDA	DIRK_Y SEC SBC	#52 STA	D_VARS+D_Y_OFF,X JMP	DI_XVXY_END


 * Throw while crawling left

DI_CRAWLING_L

LDA	DIRK_X_ONSCR SEC SBC	#18 BCS	!1 RTS		; Error, Off edge !1	STA	D_VARS+D_X_OFF,X LDA	DIRK_Y SEC SBC	#31 STA	D_VARS+D_Y_OFF,X JMP	DI_XVXY_END


 * Going right

DI_GOING_RGT


 * Setup X velocity for going right

LDA	#D_XSPEED STA	D_VARS+D_XSP_OFF+1,X

LDA	ZPAGE_BYTE2 AND	#SDC_DOWN BNE	DI_CRAWLING_R


 * Throw while standing up facing right

LDA	DIRK_X_ONSCR CLC		;Setup dagger starting X	ADC	#24 BCS	!1 CMP	#230 BCC	!2 !1	RTS		; Error, Off edge !2	STA	D_VARS+D_X_OFF,X LDA	DIRK_Y SEC SBC	#52 STA	D_VARS+D_Y_OFF,X JMP	DI_XVXY_END


 * Throw while crawling right

DI_CRAWLING_R LDA	DIRK_X_ONSCR CLC ADC	#38 BCC	!1 RTS		; Error, Off edge !1	STA	D_VARS+D_X_OFF,X LDA	DIRK_Y SEC SBC	#31 STA	D_VARS+D_Y_OFF,X

DI_XVXY_END LDA	D_E_FRAC	;Subtract energy from Dirk CLC		;for each weapon thrown ADC	#16 STA	D_E_FRAC BCC	!1 LDA	#-1 JSR	DIRK_NRG_ADD !1

LDY	#1	;Preload with normal dagger FX	LDX	WEAPON_TYPE DEX BNE	!2 LDY	#15	;Axe throw FX !2	JMP	FX_TRIGGER	;and 'RTS'


 * Process all currently running daggers
 * Process all currently running daggers

D_PROCESS LDX	#2*D_VAR_LEN	;Offset to current dagger vars DP_LOOP LDA	D_VARS+D_X_OFF,X BEQ16	DP_END	;This dagger isn't on

LDA	#D_GRAVITY CLC ADC	D_VARS+D_YSP_OFF,X STA	D_VARS+D_YSP_OFF,X	;Add gravity to	BCC	!1 	;speed INC	D_VARS+D_YSP_OFF+1,X !1

CLC ADC	D_VARS+D_YF_OFF,X STA	D_VARS+D_YF_OFF,X	;Add Y speed to Yf	LDA	D_VARS+D_YSP_OFF+1,X	;and Y	ADC	D_VARS+D_Y_OFF,X STA	D_VARS+D_Y_OFF,X

LDA	D_VARS+D_YSP_OFF+1,X BMI	BP_STILL_GOING CMP	#7 BCC	BP_STILL_GOING


 * Stop this dagger

BP_STOP LDA	#0 	;the end STA	D_VARS+D_X_OFF,X	;If so,stop dagger JMP	DP_END BP_STILL_GOING

LDA	D_VARS+D_XSP_OFF,X CLC	  	;Add X speed to	ADC	D_VARS+D_XF_OFF,X	;dagger X	STA	D_VARS+D_XF_OFF,X LDA	D_VARS+D_XSP_OFF+1,X ADC	D_VARS+D_X_OFF,X CMP	#255-(D_XSPEED/256) BCS	BP_STOP  	;Gone off edge of	STA	D_VARS+D_X_OFF,X	;screen

LDA	D_VARS+D_TYP_OFF,X BEQ16	DP_DAG_SP


 * Draw an axe and fireball

DP_AF_SP LDA	D_VARS+D_X_OFF,X STA	ZPAGE_WORD5 LDA	D_VARS+D_Y_OFF,X STA	ZPAGE_WORD6	;Setup X and Y's	LDA	#0 STA	ZPAGE_WORD5+1 STA	ZPAGE_WORD6+1

LDA	D_VARS+D_TYP_OFF,X CMP	#1 BEQ	DP_AXE_SP    	;Axe specific draw


 * Specific draw for fireball

LDA	D_VARS+D_ANI_OFF,X CMP	#3 BCC	DP_FB_AOK LDA	#0 DP_FB_AOK	TAY	             	;Animate the fireball CLC ADC	#1 STA	D_VARS+D_ANI_OFF,X

LDA	D_VARS+D_XSP_OFF+1,X BMI	DP_FB_LEFT SET16	ZPAGE_WORD2,DP_FB_LDEF LDA	#BIT6 JMP	DP_FB_DEF_END DP_FB_LEFT SET16	ZPAGE_WORD2,DP_FB_RDEF LDA	#0 DP_FB_DEF_END STX	ZPAGE_BYTE10	;Preserve X	TAX		;Setup X for SPR_DRAW

TYA ASL	A STA	ZPAGE_BYTE1 ASL	A CLC		;6 bytes per animation ADC	ZPAGE_BYTE1	;entry. ADD16_A	ZPAGE_WORD2

LDA	#128+1       	;Window number

JSR	SPR3_DRAW_39	;Draw sprite

LDX	ZPAGE_BYTE10	;Restore X

JMP	DP_END


 * Specific draw for axe

DP_AXE_SP LDA	D_VARS+D_ANI_OFF,X CMP	#4 BCC	DP_AXE_AOK LDA	#0 DP_AXE_AOK	TAY		;Animate the dagger CLC ADC	#1 STA	D_VARS+D_ANI_OFF,X

LDA	D_VARS+D_XSP_OFF+1,X BMI	DP_AXE_LEFT SET16	ZPAGE_WORD2,DP_AXE_LDEF LDA	#0 JMP	DP_AXE_DEF_END DP_AXE_LEFT SET16	ZPAGE_WORD2,DP_AXE_RDEF LDA	#BIT6 DP_AXE_DEF_END STX	ZPAGE_BYTE10	;Preserve X	TAX		;Setup X for SPR_DRAW

TYA ASL	A STA	ZPAGE_BYTE1 ASL	A CLC		;6 bytes per animation ADC	ZPAGE_BYTE1	;entry. ADD16_A	ZPAGE_WORD2

LDA	#128+1	;Window number

JSR	SPR3_DRAW_39	;Draw sprite

LDX	ZPAGE_BYTE10	;Restore X

JMP	DP_END


 * Draw a dagger

DP_DAG_SP LDY	#0 LDA	D_VARS+D_Y_OFF,X STA	(SD_PAGE_PTR),Y	;Setup Y of dagger sprites LDY	#4 STA	(SD_PAGE_PTR),Y

LDA	D_VARS+D_X_OFF,X DEY		; Y=3 STA	(SD_PAGE_PTR),Y	;Setup X of dagger sprites CLC ADC	#8 LDY	#7 STA	(SD_PAGE_PTR),Y

LDA	D_VARS+D_XSP_OFF+1,X BMI	DP_CHR_LEFT


 * Setup dagger characters for going right

LDA	#$14+64 LDY	#1 STA	(SD_PAGE_PTR),Y	;Characters LDA	#$13+64 LDY	#5 STA	(SD_PAGE_PTR),Y LDA	#0+SPR_CTR_X_FLIP JMP	DP_CHR_SEND


 * Setup dagger characters for going left

DP_CHR_LEFT LDA	#$13+64 LDY	#1 STA	(SD_PAGE_PTR),Y	;Characters LDA	#$14+64 LDY	#5 STA	(SD_PAGE_PTR),Y LDA	#0 DP_CHR_SEND

LDY	#2 STA	(SD_PAGE_PTR),Y	;Attribute LDY	#6 STA	(SD_PAGE_PTR),Y

LDA	SD_PAGE_PTR	;Move over 2 sprites CLC ADC	#8 BNE	!1 LDA	#4 !1	STA	SD_PAGE_PTR

DP_END TXA SEC		;Move to next daggers vars SBC	#D_VAR_LEN TAX BCS16	DP_LOOP

JMP	SET_NORM_BANK    	;and 'RTS'


 * Cameo screens
 * Cameo screens

CAMEO LDA	#128	;Stop tune playing JSR	START_TUNE

LDX	SCR_NUM       	;Setup BG bank LDA	CAM_B_TAB,X BEQ	!1 STA	N_BG_BANK1 CLC ADC	#2 STA	N_BG_BANK2

WAIT_FRAME LDA	VDP_CTR_VAR0	;Force screen 1 AND	#NOT-HORI_SWAP	;to get rid of the STA	VDP_CTR_VAR0	;dash. STA	VDP_CTR_REG0

LDA	#-1 LDX	SCR_NUM DEX BEQ	!2       	;Don't scroll entrance cameo LDA	#-6 !2	STA	N_SC_X JSR	DISABLE_NC       	;Turn off NMI and CHR's

LDA	#PAL_1 JSR	CLS     	;Clear screen

LDX	SCR_NUM 	;Draw screen LDA	CAM_S_TAB,X JSR	S7_DS

LDX	SCR_NUM          	;Draw attributes LDA	CAM_A_TABL,X STA	ZPAGE_WORD1 LDA	CAM_A_TABH,X STA	ZPAGE_WORD1+1 SET_VRAM_PTR 27C8 LDX	#56 JSR	SI_SET_ATTR2

LDA	#0       	;Leave dash on other screen STA	N_SPLIT

JSR	ENABLE_CN

LDX	SCR_NUM LDA	CAM_F_TAB,X PHA TAX JSR	FADE_IN

LDX	#100	;Wait for 100 frames JSR	M_WAIT_FRAME

PLA TAX JSR	FADE_OUT

!1 	RTS

CAM_B_TAB	DB	0	; 0 - Drawbridge DB	GR_1ST+38	; 1 - Entrance hall DB	GR_1ST+42             	; 2 - Mines DB	GR_1ST+46             	; 3 - Reaper DB	0            	; 4 - DB	GR_1ST+50             	; 5 - Singe DB	0               	; 6 - Elevator DB	0                    	; 7 - Treasury DB	0                    	; 8 - Dungeon

CAM_S_TAB	DB	0	; 0 - Drawbridge DB	31	; 1 - Entrance hall DB	32                    	; 2 - Mines DB	33                   	; 3 - Reaper DB	0	; 4 - DB	35             	; 5 - Singe DB	0               	; 6 - Elevator DB	0                    	; 7 - Treasury DB	0                    	; 8 - Dungeon

CAM_F_TAB	DB	0	; 0 - Drawbridge DB	75	; 1 - Entrance hall DB	80                    	; 2 - Mines DB	85                   	; 3 - Reaper DB	0	; 4 - DB	90             	; 5 - Singe DB	0               	; 6 - Elevator DB	0                    	; 7 - Treasury DB	0                    	; 8 - Dungeon

CAM_A_TABH	DH	0	; 0 - Drawbridge DH	AM_C102_0	; 1 - Entrance hall DH	AM_C106_0	; 2 - Mines DH	AM_C110_0	; 3 - Reaper DH	0	; 4 - DH	AM_C114_0   	; 5 - Singe DH	0   	; 6 - Elevator DH	0   	; 7 - Treasury DH	0                    	; 8 - Dungeon

CAM_A_TABL	DL	0	; 0 - Drawbridge DL	AM_C102_0	; 1 - Entrance hall DL	AM_C106_0	; 2 - Mines DL	AM_C110_0	; 3 - Reaper DL	0	; 4 - DL	AM_C114_0   	; 5 - Singe DL	0   	; 6 - Elevator DL	0   	; 7 - Treasury DL	0                    	; 8 - Dungeon


 * C102_0 ATTRIBUTE MAP ( 8 X 6 )

AM_C102_0

DB	$65,$95,$65,$15,$45,$95,$65,$95 DB	$EE,$BB,$EE,$33,$CC,$BB,$EE,$BB DB	$AA,$22,$00,$00,$00,$00,$88,$AA DB	$AA,$22,$00,$00,$00,$00,$88,$AA DB	$AA,$22,$00,$00,$00,$00,$88,$AA DB	$AA,$AA,$00,$00,$00,$00,$88,$AA DB	$AA,$AA,$00,$00,$00,$00,$88,$AA


 * C106_0 ATTRIBUTE MAP ( 8 X 6 )

AM_C106_0

DB	$55,$B5,$A5,$A5,$A5,$A5,$F5,$11 DB	$9D,$AA,$AA,$AA,$AA,$AA,$AE,$11 DB	$99,$AA,$55,$55,$55,$99,$AA,$11 DB	$99,$AA,$55,$95,$55,$99,$AA,$11 DB	$99,$AA,$05,$09,$05,$89,$AA,$11 DB	$99,$AA,$00,$00,$00,$88,$AA,$11 DB	$99,$AA,$00,$00,$00,$88,$AA,$11


 * C110_0 ATTRIBUTE MAP ( 8 X 6 )

AM_C110_0

DB	$55,$55,$55,$55,$55,$55,$55,$11 DB	$55,$55,$05,$05,$05,$05,$45,$01 DB	$15,$00,$00,$00,$00,$00,$44,$00 DB	$00,$00,$C0,$FF,$33,$00,$44,$00 DB	$00,$00,$FC,$FF,$FF,$00,$44,$20 DB	$00,$C0,$FF,$00,$CC,$30,$A6,$22 DB	$0F,$0F,$0F,$00,$0C,$0F,$0A,$02


 * C114_0 ATTRIBUTE MAP ( 8 X 6 )

AM_C114_0

DB	$AA,$EF,$77,$55,$FF,$FF,$FF,$33 DB	$BA,$EE,$77,$55,$FF,$FF,$FF,$33 DB	$FF,$FA,$86,$55,$FF,$FF,$FF,$33 DB	$FF,$BF,$AA,$65,$5F,$5F,$5F,$13 DB	$FF,$FF,$FF,$76,$55,$55,$55,$11 DB	$FF,$FF,$FF,$FF,$FF,$FF,$FF,$33 DB	$FF,$FF,$FF,$FF,$FF,$FF,$FF,$33


 * Lizard king
 * Lizard king

LIZ_ON_TIME	EQU	100

LIZARD_PROCESS

LDA	LIZARD_FLAG BEQ16	LP_NOT_ON	;Wait before bringing DEC	LIZARD_FLAG	;another on. BNE	LP_NOT_END

LDA	FADE_PALETTE CLC ADC	#4 LDX	#4 LDY	#4 JSR	CHANGE_PAL	;Set sprite palette
 * Lizard has ended

LDA	SPR3_WIN2_R	;Reset back to normal STA	SPR3_WIN2             	;sprite bank

LDY	#FLAG_OFF+1 LDA	(LIZ_FCD_VARS),Y ORA	#(FCD_SP1_BIT/256)	;Set death bit STA	(LIZ_FCD_VARS),Y

RTS

LP_NOT_END LDA	LIZARD_FLAG CMP	#LIZ_ON_TIME-20 BEQ	LP_EXPLODE	;Start lizard on explosions RTS


 * Start lizard appear explosions

LP_EXPLODE LDA	#18 LDX	#7 LDY	#1 JSR	CHANGE_PAL


 * Start lizard king.

SET16	ZPAGE_WORD2,FCD_LZ LDA	#8 STA	ZPAGE_BYTE1	;Hit count LDA	#ST_LZ STA	ZPAGE_BYTE2	;Sprite type JSR	SI_39	;Try to start FCD sprite. BNE	LP_CANT_START LDA	ZPAGE_WORD1 STA	LIZ_FCD_VARS	;Store address of FCD vars LDA	ZPAGE_WORD1+1 STA	LIZ_FCD_VARS+1 LDA	DIRK_Y SEC SBC	#22 JSR	SR_39	;Start Lizard after waiting

JSR	LP_ST_SMOKE BNE	LP_CANT_START	;Can't start smoke LDA	DIRK_Y	;Start bottom smoke SEC SBC	#44 JSR	SR_39

JSR	LP_ST_SMOKE BNE	LP_CANT_START	;Can't start smoke LDA	DIRK_Y	;Start top smoke SEC SBC	#72 JSR	SR_39

LP_CANT_START

LDA	#23 STA	SPR3_WIN2
 * Change to correct sprite bank in window 2


 * Start lizard king fanfare

LDY	#31 JSR	FX_TRIGGER LDY	#32 JSR	FX_TRIGGER LDY	#33 JMP	FX_TRIGGER 	;and 'RTS'


 * Lizard king is not on so check if he can be brought on

LP_NOT_ON

LDA	PL_GOLD ORA	PL_GOLD+1	;Don't do gold bonus if no ORA	PL_GOLD+2	;gold. CMP	#246 BNE	!1 RTS !1
 * Don't bring on if no gold

LDX	SCR_NUM LDA	LIZ_SCR_TABL,X STA	ZPAGE_WORD1	;Setup WORD1 as pointer to LDA	LIZ_SCR_TABH,X	;ON/OFF data. STA	ZPAGE_WORD1+1
 * Check if allowed on at the current scroll position

LP_FLOOP LDY	#0 LDA	(ZPAGE_WORD1),Y STA	ZPAGE_WORD2 INY		;WORD2 is ON x	LDA	(ZPAGE_WORD1),Y STA	ZPAGE_WORD2+1 ORA	ZPAGE_WORD2 CMP	#$FF BNE	LP_!END RTS

LP_!END CMP16	ZPAGE_WORD2,SCROLL_XOFFSET BCS16	LP_FLOOP_NEXT

LDY	#2 LDA	(ZPAGE_WORD1),Y STA	ZPAGE_WORD2 INY		;WORD2 is OFF x	LDA	(ZPAGE_WORD1),Y STA	ZPAGE_WORD2+1

CMP16	ZPAGE_WORD2,SCROLL_XOFFSET BCC	LP_FLOOP_NEXT


 * In range so bring lizard king on.

JSR	RND_A1 CMP	#251 BCS	LP_BO_S1 RTS LP_BO_S1	JSR	RND_A1 CMP 	#18 BCC	LP_BO_S2 RTS LP_BO_S2

LDA	#LIZ_ON_TIME STA	LIZARD_FLAG
 * Bring lizard king on.


 * Kill all other sprites

LDX	#MAX_FCD_UNITS SET16	ZPAGE_WORD1,SPR0 LDY	#FLAG_OFF+1 LP_LP	LDA	(ZPAGE_WORD1),Y ORA	#FCD_DEATH_BIT/256 STA	(ZPAGE_WORD1),Y ADD16_8	ZPAGE_WORD1,FCD_VARS_LEN DEX BNE	LP_LP

RTS

LP_FLOOP_NEXT ADD16_8 ZPAGE_WORD1,4	;Move to next JMP	LP_FLOOP

LP_ST_SMOKE SET16	ZPAGE_WORD2,FCD_SMOKE LDA	#200 STA	ZPAGE_BYTE1	;Hit count LDA	#ST_NULL STA	ZPAGE_BYTE2	;Sprite type JMP	SI_39	;Start lizard appear smoke ;and 'RTS'

LIZ_SCR_TABL	DL	LIZ_DUMMY DL	LIZ_SCR1 DL	LIZ_SCR2 DL	LIZ_DUMMY DL	LIZ_DUMMY DL	LIZ_SCR5 DL	LIZ_DUMMY DL	LIZ_DUMMY DL	LIZ_DUMMY

LIZ_SCR_TABH	DH	LIZ_DUMMY DH	LIZ_SCR1 DH	LIZ_SCR2 DH	LIZ_DUMMY DH	LIZ_DUMMY DH	LIZ_SCR5 DH	LIZ_DUMMY DH	LIZ_DUMMY DH	LIZ_DUMMY

LIZ_SCR5 LIZ_SCR1	DW	0,980 DW	$FFFF
 * Entrance hall
 * Singe

LIZ_SCR2	DW	0,500 DW	1400,1500 DW	$FFFF
 * Mines

LIZ_DUMMY	DW	$FFFF

B39_END IF	B39_END>$BFFF PRINTF "**** BANK $39 too long !! ****" ENDIF


 * End of bank $39
 * Start of bank $38
 * Start of bank $38
 * Start of bank $38

ORG	$138,$8000


 * Include all the BG animation data.
 * Include all the BG animation data.

INCLUDE "BG_ANIM.SRC"	;ACB's and DCB's	INCLUDE "BG_MAP1.SRC"	;Bg anims map data


 * Table of pointers to palettes.
 * Table of pointers to palettes.

SPAL_PTR_TAB DW	PAL_BLACK	;0 - Mines (Bright) DW	MI_P1	;1 DW	MI_P2	;2 DW	MI_P3	;3 DW	S_PAL_S2	;4 DW	PAL_BLACK	;5 - Mines (Dark) DW	MI_P1	;6 DW	MI_P2	;7 DW	MI_P4	;8 DW	S_PAL_S2	;9 DW	DIRK_FLASH_PAL	;10 DW	PAL_BLACK	;11 - Elevator DW	ELEV_PAL0	;12 DW	ELEV_PAL1	;13 DW	ELEV_PAL2	;14 DW	S_PAL_S6 	;15 DW	MI_P5	;16 - 2 entry candle lit mines DW	MI_P6	;17 - 2 entry bright mines DW	S_PAL_S2A	;18 - 1 entry for lizard king DW	S_PAL_S2B	;19 - 1 entry for normal DW	PAL_BLACK	;20 - Grim reaper DW	R00_PAL	;21 DW	R01_PAL	;22 DW	R02_PAL	;23 DW	S_PAL_S2	;24 DW	FLASH_PAL	;25 - 4 ent Lighting flash DW	PAL_BLACK	;26 - Drawbridge DW	DB_PAL1	;27 DW	DB_PAL2	;28 DW	DB_PAL3	;29 DW	S_PAL_S0	;30 DW	PAL_BLACK	;31 - Name entry, DW	AT_PAL1	;32 - high score table DW	AT_PAL2	;33 - and title screen DW	AT_PAL3	;34 DW	AT_SPR_PAL	;35 DW	G1_PAL0	;36 - 'Start' glow DW	G1_PAL1	;37 DW	G1_PAL2	;38 DW	G1_PAL3	;39 DW	G1_PAL4	;40 DW	PAL_BLACK	;41 DW	SG_PAL1	;42 - Singe's Lair DW	SG_PAL2	;43 DW	SG_PAL3	;44 DW	S_PAL_S0	;45 DW	SG_PAL4	;46 - Dragon on	DW	PAL_BLACK	;47 - Entrance Hall DW	PAL_BLACK	;48 DW	EH2_PAL	;49 DW	EH2_PAL	;50 DW	S_PAL_S2	;51 DW	PAL_BLACK	;52 - Treasury DW	T_PAL0	;53 DW	T_PAL1	;54 DW	T_PAL2	;55 DW	S_PAL_S7	;56 DW	SG_PAL	;57 - Singe bits palette DW	PAL_BLACK	;58 - No fade set of palettes DW	PAL_BLACK	;59  for use with mines drak DW	PAL_BLACK	;60  section and grim reaper DW	PAL_BLACK	;61  end. DW	S_PAL_S2	;62 DW	SG_PAL5	;63 - Singe 1 ent green DW	SG_FLASH	;64 - Flash Reaper/Singe white DW	R03_PAL	;65 - Reaper 1 ent blue DW	PAL_BLACK	;66 - End screen palettes DW	ES_PAL1	;67 DW	ES_PAL2	;68 DW	ES_PAL3	;69 DW	S_PAL_S0	;70 DW	S0_SNK	;71 - Green for snake s0           	DW	EH3_PAL	;72 - End screen (Entrance hall) DW	EH3_F	;73 - Flash snake DW	EH3_R	;74 - Restore snake DW	PAL_BLACK	;75 - Entrance hall cameo DW	PAL_BLACK 	;76 DW	CAM_PAL3 	;77 DW	CAM_PAL3 	;78 DW	S_PAL_S0	;79 DW	PAL_BLACK	;80 - Mines cameo DW	PAL_BLACK 	;81 DW	MIN_PAL3 	;82 DW	MIN_PAL3 	;83 DW	S_PAL_S0	;84 DW	PAL_BLACK	;85 DW	PAL_BLACK 	;86 DW	REAP_PAL3 	;87 DW	REAP_PAL3 	;88 DW	S_PAL_S0	;89 DW	PAL_BLACK	;90 DW	PAL_BLACK	;91 DW	SING_PAL3	;92 DW	SING_PAL3	;93 DW	S_PAL_S0	;94 DW	PAL_BLACK	;95 DW	EH3_R	;96 - Restore snake DW	EH3_R	;97 DW	EH3_R	;98 DW	S_PAL_S0	;99 DW	PAL_BLACK	;100 - Credit screens DW	R00_PAL	;101 DW	R01_PAL	;102 DW	CS_PAL	;103 DW	S_PAL_S2	;104


 * BG palettes

FLASH_PAL	DB	WHITE3,WHITE2,WHITE1,WHITE0 DB	WHITE3,WHITE2,WHITE1,WHITE0 DB	WHITE3,WHITE2,WHITE1,WHITE0 DB	WHITE3,WHITE2,WHITE1,WHITE0

PAL_BLACK	DB	BLACK,BLACK,BLACK,BLACK DB	BLACK,BLACK,BLACK,BLACK DB	BLACK,BLACK,BLACK,BLACK DB	BLACK,BLACK,BLACK,BLACK


 * Sprite palettes


 * Screen 0 - Drawbridge

S_PAL_S0	DB	BLACK,WHITE2,WHITE1,WHITE0 DB	BLACK,ORANGE2,ORANGE3,YELLOW1 DB	BLACK,WHITE2,YELLOW2,WHITE0 S0_SNK	DB	BLACK,GREEN3,GREEN2,MID_GREEN1

S_PAL_S2	DB	BLACK,WHITE2,WHITE1,WHITE0 DB	BLACK,ORANGE2,ORANGE3,YELLOW1 DB	BLACK,WHITE2,YELLOW2,WHITE0 S_PAL_S2B	DB	BLACK,ORANGE3,ORANGE2,ORANGE1


 * Screen 6 - Elevator

S_PAL_S6	DB	BLACK,WHITE2,WHITE1,WHITE0 DB	BLACK,ORANGE2,ORANGE3,YELLOW1 DB	BLACK,WHITE2,YELLOW2,WHITE0 DB	BLACK,ORANGE3,ORANGE2,ORANGE1

S_PAL_S7	DB	BLACK,WHITE2,WHITE1,WHITE0 DB	BLACK,ORANGE2,ORANGE3,YELLOW1 DB	BLACK,WHITE2,YELLOW2,WHITE0 S_PAL_S2A	DB	BLACK,WHITE2,LT_GREEN1,LT_GREEN2 ;Lizard king palette

DIRK_FLASH_PAL	DB	BLACK,WHITE2,WHITE1,WHITE0 DB	BLACK,WHITE2,WHITE2,WHITE2 DB	BLACK,WHITE2,WHITE2,WHITE2
 * DB	BLACK,WHITE1,MID_GREEN1,MID_GREEN0

SG_FLASH	DB	BLACK,WHITE3,WHITE3,WHITE3


 * Attract mode sprite palette

AT_SPR_PAL	DB	BLACK,BLUE2,BLUE2,BLUE1 DB	BLACK,ORANGE2,ORANGE1,ORANGE0 DB	BLACK,GREEN3,GREEN2,GREEN1 DB	BLACK,ORANGE3,ORANGE2,ORANGE1


 * Sprite palette for Singe's bits

SG_PAL	DB	BLACK,WHITE3,PURPLE2,PURPLE1

MI_F	DB	BLACK



B38_END IF	B38_END>$9FFF PRINTF "**** BANK $38 too long !! ****" ENDIF


 * End of bank $38
 * Start of bank $37
 * Start of bank $37
 * Start of bank $37

ORG	$137,$A000


 * Include screen maps

INCLUDE "GR_SMAP2.SRC"

B37_END IF	B37_END>$BFFF PRINTF "**** BANK $37 too long !! ****" ENDIF


 * End of bank $37
 * Start of bank $36
 * Start of bank $36
 * Start of bank $36

ORG	$136,$8000


 * Include the ZZ_ and BM_ data for SPR_DRAW

INCLUDE "GR_MAP.SRC" INCLUDE "GR_MAP2.SRC" INCLUDE "GR_MAP3.SRC"


 * ZZ_ and BM_ maps for test sprite

BM_TEST	DB	%11000000 DB	%11000000

ZZ_TEST	DB	30,30,30,30

B36_END IF	B36_END>$9FFF PRINTF "**** BANK $36 too long !! ****" ENDIF


 * End of bank $36


 * Start of bank $34+35
 * Start of bank $34+35

ORG	$134,$8000

INCBIN	"SCRBLK.INC"

B35_END IF	B35_END>$BFFF PRINTF "**** BANK $34+$35 too long !! ****" ENDIF


 * End of bank $34+$35
 * Start of bank $32
 * Start of bank $32
 * Start of bank $32

ORG	$132,$8000



INCBIN "ATTR.INC"


 * Collapsing floor collision tables.(X,Screen address)
 * Collapsing floor collision tables.(X,Screen address)


 * Screen 0 - Drawbridge

SCR0_COLAP_TAB DW	104,9024+13 DW	112,9024+14 DW	120,9024+15

DW	$FFFF


 * Screen 3 - Grim reaper

SCR3_COLAP_TAB DW	88,9024+11 DW	96,9024+12 DW	104,9024+13 DW	136,9024+17 DW	144,9024+18 DW	152,9024+19 DW	184,9024+23 DW	192,9024+24 DW	200,9024+25 DW	232,9024+29 DW	240,9024+30 DW	248,9024+31
 * Gr #1

DW	512+152,8896+19 DW	512+160,8896+20 DW	512+168,8896+21
 * Gr #3

DW	1280+208,9984+26 DW	1280+216,9984+27 DW	1280+224,9984+28 DW	1280+232,9984+29
 * Gr #6

DW	1536+8,8960+1 DW	1536+16,8960+2 DW	1536+24,8960+3 DW	1536+32,8960+4 DW	1536+40,8960+5 DW	1536+72,8960+9 DW	1536+80,8960+10 DW	1536+88,8960+11 DW	1536+120,9024+15 DW	1536+128,9024+16
 * Gr #7

DW	1792+120,10048+15 DW	1792+128,10048+16 DW	1792+136,10048+17 DW	1792+168,10112+21 DW	1792+176,10112+22 DW	1792+184,10112+23 DW	1792+192,10112+24 DW	1792+200,10112+25 DW	1792+232,10112+29 DW	1792+240,10112+30
 * Gr #8

DW	2048+16,9088+2 DW	2048+24,9088+3 DW	2048+32,9088+4 DW	2048+40,9088+5 DW	2048+192,9024+24 DW	2048+200,9024+25 DW	2048+208,9024+26 DW	2048+216,9024+27 DW	2048+248,9024+31
 * Gr #9

DW	2304+0,10048+0 DW	2304+8,10048+1 DW	2304+16,10048+2 DW	2304+48,10048+6 DW	2304+56,10048+7 DW	2304+64,10048+8 DW	2304+72,10048+9 DW	2304+104,10048+13 DW	2304+112,10048+14
 * Gr #10

DW	2560+32,9024+4 DW	2560+40,9024+5 DW	2560+48,9024+6 DW	2560+80,9024+10 DW	2560+88,9024+11 DW	2560+200,9024+25 DW	2560+232,9024+29 DW	2560+240,9024+30
 * Gr #11


 * Gr

DW	$FFFF



B32_END IF	B32_END>$BFFF PRINTF "**** BANK $32 too long !! ****" ENDIF


 * End of bank $32
 * Start of bank $30/31
 * Start of bank $30/31
 * Start of bank $30/31

ORG	$130,$8000

MUSIC_BASE	INCBIN	"MUSIC.INC"

FX_INIT	EQU	MUSIC_BASE+0 FX_TRIGGER1	EQU	MUSIC_BASE+3 FX_PROCESS	EQU	MUSIC_BASE+6 MUSIC_TRIGGER	EQU	MUSIC_BASE+9 MUSIC_PROCESS	EQU	MUSIC_BASE+12

B30_END IF	B30_END>$BFFF PRINTF "**** BANK $30 too long !! ****" ENDIF

IF	EPROM=99 SEND COMPUTER1 ENDIF IF	EPROM=98 SEND MSDOS,"C:\PDSMAST\DLAIRFCS\EPROM\DL.PDS" ENDIF
 * End of bank $30/$31


 * Print memory usage messages
 * Print memory usage messages

PRINTF "Bank $3F has %d bytes free",$FFFF-B3F_END PRINTF "Bank $3C/D has %d bytes free",$C000-B3D_END PRINTF "Bank $3A/B has %d bytes free",$C000-B3B_END PRINTF "Bank $39 has %d bytes free",$C000-B39_END PRINTF "Bank $38 has %d bytes free",$A000-B38_END PRINTF "Bank $37 has %d bytes free",$C000-B37_END PRINTF "Bank $36 has %d bytes free",$A000-B36_END PRINTF "Bank $34 has %d bytes free",$C000-B35_END PRINTF "Bank $32/3 has %d bytes free",$C000-B32_END PRINTF "Bank $30/1 has %d bytes free",$C000-B30_END

END


 * End of file: DLAIR.ASM

�ize LDA	#2 STA	ZPAGE_BYTE2		;Ysize JSR	DRAW_CHR_BLOCK	;Draw disc

SET16	ZPAGE_WORD1,ATTRWALL0 JSR	SI_SET_ATTR	;Set screen attributes JSR	SET_PA	;Reset panel attributes

JSR	SET_S0	;Set to screen 0

LDA	#104 STA	DIRK_X LDA	#167 STA	DIRK_Y

LDX	#0 STX	ELEV_CNT	;Brick scroll position

LDY	#1 JMP	INIT_SCR_END


 * 1a) Normal screen

INIT_STATIC INY LDA	(ZPAGE_WORD10),Y	;Screen number JSR	DRAW_SCREEN	;Draw normal screen

LDY	#2 LDA	(ZPAGE_WORD10),Y STA	ZPAGE_WORD1	;Setup WORD1 as pointer INY		;to attribute map LDA	(ZPAGE_WORD10),Y STA	ZPAGE_WORD1+1 JSR	SI_SET_ATTR	;Draw screen attributes

JSR	SET_S0	;Set to screen 0

LDY	#4 LDA	(ZPAGE_WORD10),Y STA	DIRK_Y

LDA	#12 STA	DIRK_X

LDY	#5 JMP	INIT_SCR_END


 * 1b) Draw scrolling screen

INIT_SCROLLING


 * Setup screen height and Y offset to top of strip

LDX	SCR_NUM LDA	IS_SCR_YS,X STA	SCROLL_YS LDA	IS_SCR_YOFF,X STA	SCROLL_YOFF

INY LDA	(ZPAGE_WORD10),Y STA	ZPAGE_WORD1 INY		;Setup WORD1 pointing LDA	(ZPAGE_WORD10),Y	;at reset point STA	ZPAGE_WORD1+1	;table
 * Find correct reset point and setup parms for Dirk start pos and screen
 * draw.

LDY	#0 SI_FPOS_LOOP LDA	(ZPAGE_WORD1),Y STA	ZPAGE_WORD2 INY		;WORD2 is reset X	LDA	(ZPAGE_WORD1),Y STA	ZPAGE_WORD2+1 CMP16	DIRK_X_DIE,ZPAGE_WORD2	;Compare against how far Dirk ;got last go. BCC	SI_POS_FOUND	;Exit if reset X is greater TYA CLC ADC	#9-1	;Move to next entry TAY JMP	SI_FPOS_LOOP SI_POS_FOUND TYA SEC SBC	#9+1	;Move back to last entry TAY LDA	(ZPAGE_WORD1),Y STA	SCROLL_XOFFSET INY		;Setup Dirk's X position LDA	(ZPAGE_WORD1),Y STA	SCROLL_XOFFSET+1 utine comprises of three separate tables:-


 * Table 0 contains pointers to the top left hand corner screen address.

SCR_DRAW_TAB0	DW	DL_SCR_TLFT	;0 - Panel DW	DL_SCR_TLFT+(5*32)	;1 - Draw Bridge DW	SCR1_START+(26*32)	;2 - Reaper floor DW	DL_SCR_TLFT+(5*32)	;3 - Treasury DW	SCR1_START+(15*32)+22	;4 - Reaper

IF	FCS=1 DW	SCR_START+(9*32)+10	;5 - SBIM logo DW	SCR_START+(13*32)+13	;6 - Presents DW	SCR_START+(12*32)+24	;7 - TM	DW	SCR_START+(19*32)+11	;8 - Released by	DW	SCR_START+(21*32)+4	;9 - EPIC logo DW	SCR_START+(24*32)+5	;10- Licensed by Nintendo DW	SCR_START+(7*32)+7	;11- EPIC release DW	SCR_START+(12*32)+10	;12- Developed by	DW	SCR_START+(14*32)+12	;13- MotiveTime logo DW	SCR_START+(18*32)+1	;14- Copyright message DW	SCR_START+(15*32)+10	;15- Dragons Lair logo s1	ENDIF

IF	GBR=1 DW	SCR_START+(5*32)+9	;5 - SBIM logo DW	SCR_START+(9*32)+11	;6 - Presents DW	SCR_START+(3*32)+9	;7 - Don Bluth cs2 DW	SCR_START+(14*32)+10	;8 - Released by	DW	SCR_START+(16*32)+6	;9 - Elite logo DW	SCR_START+(24*32)+5	;10- Licensed by Nintendo DW	SCR_START+(7*32)+5	;11- Elite release DW	SCR_START+(12*32)+10	;12- Developed by	DW	SCR_START+(14*32)+11	;13- MotiveTime logo DW	SCR_START+(18*32)+1	;14- Copyright message DW	SCR_START+(11*32)+8	;15- Dragons Lair logo s1	ENDIF

DW	SCR_START+(3*32)+9	;16- Dragons Lair logo s2	DW	SCR_START+(4*32)+23	;17- TM credits screen 2 DW	SCR_START+(32*8)+7	;18- SCORES DW	SCR_START+(32*10)+8	;19- PLAYERS DW	SCR_START+(32*13)+8	;20- MUSIC DW	SCR_START+(32*10)+7	;21- GOLD DW	SCR_START+(32*23)+13	;22- Mtime logo option screens DW	SCR1_START+(32*8)+10	;23- DL	0 ENDIF

DL	0	;4-

IF	SINGE DL	S5_TP_TAB	;5 - Singe ELSE DL	0 ENDIF

DL	S6_TP_TAB	;6 - Elevator DL	S7_TP_TAB	;7 - Treasury DL	S8_TP_TAB	;8 - Dungeon

SCR_TPTR_TABH	DH	S0_TP_TAB	;0 - Drawbridge

IF	HALL DH	S1_TP_TAB	;1 - Entrance hall ELSE DH	0 ENDIF

IF	MINES DH	S2_TP_TAB	;2 - Mines ELSE DH	0 ENDIF

IF	REAPER DH	S3_TP_TAB	;3 - Grim reaper ELSE DH	0 ENDIF

DH	0	;4-

IF	SINGE DH	S5_TP_TAB	;5 - Singe ELSE DH	0 ENDIF

DH	S6_TP_TAB	;6 - Elevator DH	S7_TP_TAB	;7 - Treasury DH	S8_TP_TAB	;8 - Dungeon


 * Include graphics source files
 * Include graphics source files

INCLUDE "GR_SMAP1.SRC"


 * Sprite Collision boxes
 * Sprite Collision boxes


 * Table of pointers to collision boxes

SDC_COL_PTRS_L	DL	SCOL_0 DL	SCOL_1 DL	SCOL_2 DL	SCOL_3 DL	SCOL_4 DL	SCOL_5 DL	SCOL_6 DL	SCOL_7 DL	SCOL_8 DL	SCOL_9 DL	SCOL_10 DL	SCOL_11 DL	SCOL_12 DL	SCOL_13 DL	SCOL_14 DL	SCOL_15 DL	SCOL_16 DL	SCOL_17 DL	SCOL_18 DL	SCOL_19 DL	SCOL_20 DL	SCOL_21 DL	SCOL_22 DL	SCOL_23 DL	SCOL_24 DL	SCOL_25 DL	SCOL_26 DL	SCOL_27 DL	SCOL_25 ;28 DL	SCOL_26 ;29 DL	SCOL_27 ;30 DL	SCOL_31 DL	SCOL_32 DL	SCOL_33 DL	SCOL_34 DL	SCOL_35 DL	SCOL_36 DL	SCOL_37 DL	SCOL_38 DL	SCOL_39 DL	SCOL_40 DL	SCOL_41 DL	SCOL_42 DL	SCOL_43 DL	SCOL_44 DL	SCOL_45 DL	SCOL_46 DL	SCOL_47

SDC_COL_PTRS_H	DH	SCOL_0 DH	SCOL_1 DH	SCOL_2 DH	SCOL_3 DH	SCOL_4 DH	SCOL_5 DH	SCOL_6 DH	SCOL_7 DH	SCOL_8 DH	SCOL_9 DH	SCOL_10 DH	SCOL_11 DH	SCOL_12 DH	SCOL_13 DH	SCOL_14 DH	SCOL_15 DH	SCOL_16 DH	SCOL_17 DH	SCOL_18 DH	SCOL_19 DH	SCOL_20 DH	SCOL_21 DH	SCOL_22 DH	SCOL_23 DH	SCOL_24 DH	SCOL_25 DH	SCOL_26 SCR_NUM CMP	#6 BNE	SF_NOT_6


 * Screen 6 (Elevator)

LDA	DIRK_FLAG AND	#FCD_SEC_BIT	;Only check for exit if on	BEQ	SF_NOT_6	;platform, else do normal bump ;into sides.

LDA	DIRK_X	;Test if walked off left CMP	#L_EDGE	;or right edge of elevator BCC	SF_OFF_ELEV CMP	#R_EDGE BCS	SF_OFF_ELEV

RTS


 * Walked off edge

SF_OFF_ELEV LDX	SCR_NUM_OLD	;Start correct screen LDA	SF_ETABL,X STA	ZPAGE_WORD1 LDA	SF_ETABH,X	;Setup W1 as pointer to	STA	ZPAGE_WORD1+1	;exit list

LDY	ELEV_ENUM	;Number of exit from elevator LDA	(ZPAGE_WORD1),Y	;Screen to go to	CMP	#7	;If new screen is treasury BEQ	!1	;don't update SCR_NUM_OLD so	CMP	#8 BEQ	!1 STA	SCR_NUM_OLD	;It's the same elev next time !1	STA	SCR_NUM JMP	SCR_E_END

SF_ETABL	DL	SF_EL0 DL	SF_EL1 DL	SF_EL2 DL	SF_EL3 DL	SF_EL4 DL	SF_EL5 DL	SF_EL6 DL	SF_EL7

SF_ETABH	DH	SF_EL0 DH	SF_EL1 DH	SF_EL2 DH	SF_EL3 DH	SF_EL4 DH	SF_EL5 DH	SF_EL6 DH	SF_EL7

SF_EL0			;Drawbridge

SF_EL1	DB	1,2,8,7	;Entrance hall SF_EL2	DB	8,2,3,7	;Mines

SF_EL3	DB	5,8,3,7	;Grim reaper

SF_EL4			;Not implemented

SF_EL5			;Singe

SF_EL6			;Elevator

SF_EL7			;Treasury

SF_NOT_6


 * Stop exit off left of screen

LDA	DIRK_X_ONSCR CMP	#L_EDGE BCS	SF_LOK

LDA	SCR_NUM	;Dirk exits on the left CMP	#7	;in the treasury BNE	!1 LDA	END_LEVEL_FLAG	;Exit from treasury BNE	SF_LEVEL_END !1	LDA	#L_EDGE+4	;Put Dirk at left JSR	SF_CEP

SF_LOK

SF_SCROLL LDA	SCROLL_FLAG 	;Is it a scrolling section BEQ	SF_NOT_SCROLL

LDA	SCROLL_XOFFSET+1	;Test if finished scrolling CMP	SCROLL_LENGTH+1	;(16 bit compare) BCC	SF_END BNE	!1 LDA	SCROLL_XOFFSET CMP	SCROLL_LENGTH BCC	SF_END


 * Scroll has finished so allow Dirk freedom to walk right.

!1	LDA	#0 STA	SCROLL_FLAG	;Clear scroll flag

SF_NOT_SCROLL LDA	DIRK_X_ON OL_S1	;Scr 1 - Entrance Hall DH	BG_COL_S2	;Scr 2 - Mines DH	BG_COL_S3	;Scr 3 - Grim reaper DH	0	;Scr 4 - DH	BG_COL_S5	;Scr 5 - Singe DH	BG_COL_S6	;Scr 6 - Elevator DH	BG_COL_S7	;Scr 7 - Treasury DH	BG_COL_S8	;Scr 8 - Dungeon


 * Bonus collision data

BONUS_TABL	DL	BTAB_S0 DL	BTAB_S1 DL	BTAB_S2 DL	BTAB_S3 DL	0 DL	BTAB_S5 DL	BTAB_S6 DL	BTAB_S7 DL	BTAB_S8

BONUS_TABH	DH	BTAB_S0 DH	BTAB_S1 DH	BTAB_S2 DH	BTAB_S3 DH	0 DH	BTAB_S5 DH	BTAB_S6 DH	BTAB_S7 DH	BTAB_S8

INCLUDE "BG_COL.SRC"	;Background

Source Differences
The Japanese and European source codes have some differences:
 * The Japanese code has the "cameo" screens disabled by inserting the RET opcode at the start of the display routine. The same difference is present in the final binary code. There are no splash screens between levels, but they can be enabled by using Game Genie code.
 * The Japanese version lacks the "Dungeon" level data tables.

--- EU.asm +++ JP.asm @@ -956,6 +956,8 @@ 	LDA	#128	;Stop tune playing JSR	START_TUNE +	RTS + 	LDX	SCR_NUM       	;Setup BG bank LDA	CAM_B_TAB,X BEQ	!1 @@ -1953,7 +1955,6 @@ 	DL	S6_TP_TAB	;6 - Elevator DL	S7_TP_TAB	;7 - Treasury -	DL	S8_TP_TAB	;8 - Dungeon SCR_TPTR_TABH	DH	S0_TP_TAB	;0 - Drawbridge @@ -1985,7 +1986,6 @@ 	DH	S6_TP_TAB	;6 - Elevator DH	S7_TP_TAB	;7 - Treasury -	DH	S8_TP_TAB	;8 - Dungeon ;-- @@ -2140,11 +2140,11 @@ SF_EL0			;Drawbridge -SF_EL1	DB	1,2,8,7	;Entrance hall +SF_EL1	DB	1,2,0,7	;Entrance hall -SF_EL2	DB	8,2,3,7	;Mines +SF_EL2	DB	1,2,3,7	;Mines -SF_EL3	DB	5,8,3,7	;Grim reaper +SF_EL3	DB	5,2,3,7	;Grim reaper SF_EL4			;Not implemented