SOURCE CODE

This is the entire game of Adventure disassembled by Simon Cornwell. Simon was cool enough to document the code with an extraordinary amount of comments. Thanks, Simon!


;Adventure Dissassembly
;ROM Start
F000	4C,EF,F2		JMP &F2EF			;Goto start of game.




;Alternative Start
F003	78		SEI			
F004	D8		CLD			;Initialise 6507.
F005	4C,06,F3		JMP &F306			;Start game with no variable initialisation.




;Print Display
F008	85,2B		STA &2B			;Clear horizontal motion.
F00A	A5,86		LDA &86			;Position player00 sprite to
F00C	A2,00		LDX #&00			;the X coordinate of Object1.
F00E	20,D2,F0		JSR &F0D2

F011	A5,88		LDA &88			;Position player01 sprite to
F013	A2,01		LDX #&01			;the X coordinate of Object2.
F015	20,D2,F0		JSR &F0D2

F018	A5,8B		LDA &8B			;Position ball sprite to
F01A	A2,04		LDX #&04			;the X coordinate of the Man.
F01C	20,D2,F0		JSR &F0D2

F01F	85,02		STA &02			;Wait for horizontal blank.
F021	85,2A		STA &2A			;Apply horizontal motion.
F023	85,2C		STA &2C			;Clear collision latches.

F025	A5,8C		LDA &8C			;Get the Y coordinate of the Man.
F027	38		SEC	
F028	E9,04		SBC #&04			;And adjust it (by four scan lines)
F02A	85,8D		STA &8D			;for printing (so Y coordinate specifies middle)

F02C	AD,84,02		LDA &284			;Wait for end of the
F02F	D0,FB		BNE &F02C			;current frame.

F031	A9,00		LDA #&00
F033	85,90		STA &90			;Set Player00 definition index.
F035	85,81		STA &91			;Set Player01 definition index.
F037	85,8F		STA &8F			;Set room definition index.
F039	85,1C		STA &1C			;Clear any graphics for Player01.
F03B	A9,01		LDA #&01
F03D	85,26		STA &26			;Vertically delay Player01.
F03F	A9,68		LDA #&68
F041	85,8E		STA &8E			;Set scan line count.

;Print top line of room.
F043	A4,8F		LDY &8F			;Get room definition index.
F045	B1,80		LDA (&80),Y		;Get first room definition byte.
F047	85,0D		STA &0D			;And display.
F049	C8		INY
F04A	B1,80		LDA (&80),Y		;Get next room definition byte.
F04C	85,0E		STA &0E			;And display.
F04E	C8		INY
F04F	B1,80		LDA (&80),Y		;Get last room definition byte.
F051	85,0F		STA &0F			;And display.
F053	C8		INY
F054	84,8F		STY &8F			;Save for next time

F056	85,02		STA &02			;Wait for horizontal blank.
F058	A9,00		LDA #00
F05A	85,01		STA &01			;Clear any vertical blank.
F05C	4C,72,F0		JMP &F072

;Print Player01 (Object 02)
F05F	A5,8E		LDA &8E			;Get current scan line.
F061	38		SEC			;Have we reached Object2's
F062	E5,89		SBC &89			;Y coordinate?
F064	85,02		STA &02			;Wait for horizontal blank.
F066	10,0A		BPL &F072			;If not, branch.

F068	A4,91		LDY &91			;Get the Player01 definition index.
F06A	B1,84		LDA (&84),Y		;Get the next Player01 definition byte.
F06C	85,1C		STA &1C			;And display.
F06E	F0,02		BEQ &F076			;If zero then defintion finished.

F070	E6,91		INC &91			;Goto next Player01 definition byte.

;Print Player00 (Object 01), Ball (Man) and Room.
F072	A2,00		LDX #&00		
F074	A5,8E		LDA &8E			;Get current scan line.
F076	38		SEC			;Have we reached Object1's
F077	E5,87		SBC &87			;Y coordinate?
F079	10,09		BPL &F088			;If not then branch.

F07B	A4,90		LDY &90			;Get Player00 definition index.
F07D	B1,82		LDA (&82),Y		;Get the next Player00 definition byte.
F07F	AA		TAX
F080	F0,02		BEQ &F088			;If zero then defintion finished.

F082	E6,90		INC &90			;Goto next Player00 definition byte.

F084	A0,00		LDY #&00			;Disable Ball graphic.
F086	A5,8E		LDA &8E			;Get scan line count.
F088	38		SEC			;Have we reached the Man's
F089	E5,8D		SBC &8D			;Y coordinate.
F08B	29,FC		AND #&FC			;Mask value to four eitherside (getting depth of 8)
F08D	D0,02		BNE &02			;If not, branch.

F08F	A0,02		LDY #&02			;Enable Ball graphic.

F091	A5,8E		LDA &8E			;Get scan line count.
F093	29,0F		AND #&0F			;Have we reached a sixteenth scan line?
F095	D0,26		BNE &F0BD			;If not, branch.

F097	85,02		STA &02			;Wait for horizontal blank.
F099	84,1F		STY &1F			;Enable Ball (if wanted)
F09B	86,1B		STX &1B			;Display player 00 definition byte (if wanted)

F09D	A4,8F		LDY &8F			;Get room definition index.
F09F	B1,80		LDA (&80),Y		;Get first room definition byte.
F0A1	85,0D		STA &0D			;And display.
F0A3	C8		INY
F0A4	B1,80		LDA (&80),Y		;Get next room definition byte.
F0A6	85,0E		STA &0E			;And display
F0A8	C8		INY
F0A9	B1,80		LDA (&80),Y		;Get next room definition byte.
F0AB	85,0F		STA &0F			;And display.
F0AD	C8		INY
F0AE	84,8F		STY &8F			;Save for next time.

F0B0	C6,8E		DEC &8E			;Goto next scan line.
F0B2	A5,8E		LDA &8E			;Get the scan line.
F0B4	C9,08		CMP #&08			;Have we reached to within 8 scan lines of the bottom.
F0B6	10,A7		BPL &F05F			;If not, branch.

F0B8	85,01		STA &01			;Turn on VBLANK
F0BA	4C,C6,F0		JMP &F0C6		

;Print Player00 (Object 01) and Ball (Man)
F0BD	85,02		STA &02			;Wait for horizontal blank.
F0BF	84,1F		STY &1F			;Enable Ball (if wanted).
F0C1	86,1B		STX &1B			;Display Player00 definition byte (if wanted).
F0C3	4C,0B,F0		JMP &F0B0

;Tidy Up
F0C6	A9,00		LDA #&00
F0C8	85,1C		STA &1C			;Clear any graphics for Player01
F0CA	85,1B		STA &1B			;Clear any graphics for Player00
F0CC	A9,3B		LDA #&3B
F0CE	8D,96,02		STA &296			;Start timing this frame using
F0D1	60		RTS			;the 64 bit counter.




;Position Sprite X horizontally
F0D2	A0,02		LDY #&02			;Start with 10 clock cycles (to avoid HBlank)
F0D4	38		SEC			;Divide the coordinate
F0D5	C8		INY			;wanted by fifteen i.e.
F0D6	E9,0F		SBC #&0F			;get course horizontal
F0D8	B0,FB		BCS &F0D5			;value (in multiples of 5 clock cycles).
						;(therefore giving 15 colour cycles)
F0DA	49,FF		EOR #&FF			;Flip remainder to positive value (inverted).
F0DC	E9,06		SBC #&06			;Convert to left or right of current position.
F0DE	0A		ASL A
F0DF	0A		ASL A			;Move to high nybble for TIA
F0E0	0A		ASL A			;(horizontal motion)
F0E1	0A		ASL A
F0E2	84,02		STY &02			;Wait for horizontal blank.

F0E4	88		DEY			;Count down the colour
F0E5	10,FD		BPL &F0E4			;cycles (these are 5 machine/15 colour cycles).

F0E7	95,10		STA &10,X			;Reset the sprite thus positioning it coursely.
F0E9	95,20		STA &20,X			;Set horizontal (fine) motion of sprite.
F0EB	60		RTS




;Perform VSYNC
F0EC	AD,84,02	LDA &284				;Get timer output
F0EF	D0,FB		BNE F0EF			;and wait for time-out

F0F1	A9,02		LDA #&02
F0F3	85,02		STA &02			;Wait for horizontal blank.
F0F5	85,01		STA &01			;Start vertical blanking.

F0F7	85,02		STA &02			;Wait for horizontal blank.
F0F9	85,02		STA &02			;Wait for horizontal blank.
F0FB	85,02		STA &02			;Wait for horizontal blank.

F0FD	85,00		STA &00			;Start vertical sync.
F0FF	85,02		STA &02			;Wait for horizontal blank.
F101	85,02		STA &02			;Wait for horizontal blank.

F103	A9,00		LDA #&00
F105	85,02		STA &02			;Wait for horizontal blank.
F107	85,00		STA &00			;End vertical sync.

F109	A9,48		LDA #&48			;Set 64 clock interval to
F10B	8D,96,02		STA &0296			;countdown next frame.
F10E	60		RTS




;Set up room for print.
F10F	A5,8A		LDA &8A			;Get current room number.
F111	20,71,F2		JSR &F271			;Convert it to an address.
F114	A0,00		LDY #&00
F116	B1,93		LDA (&93),Y		;Get low pointer to room
F118	85,80		STA &80			;graphics.
F11A	A0,01		LDY #&01
F11C	B1,93		LDA (&93),Y		;Get high pointer to room
F11E	85,81		STA &81			;graphics.

;Check B&W for room graphics.
F120	AD,82,02		LDA &0282			;Get console switches
F123	29,08		AND #&08			;Check black and white switch.
F125	F0,0C		BEQ &F133			;Branch if B&W.

;Use colour
F127	A0,02		LDY #&02
F129	B1,93		LDA (&93),Y		;Get room colour.
F12B	20,D3,F2		JSR &F2D3			;Change if necessary
F12E	85,08		STA &08			;And put in playfield colour register.
F130	4C,3C,F1	JMP &F13C

;Use B&W
F133	A0,03		LDY #&03
F135	B1,93		LDA (&93),Y		;Get B&W colour.
F137	20,D3,F2		JSR &F2D3			;Change if necessary.
F13A	85,08		STA &08			;And put in the playfield colour register.
				
;Colour background.
F13C	A9,08		LDA #&08			;Get light grey background.
F13E	20,D3,F2		JSR &F2D3			;Change if necessary.
F141	85,09		STA &09			;And put in the background colour register.

;Playfield control
F143	A0,04		LDY #&04
F145	B1,93		LDY (&93),Y		;Get playfield control value.
F147	85,0A		STA &0A			;And put in the playfield control register.
F149	29,C0		AND #&C0		;Get the 'thin wall' flags.
F14B	4A		LSR A
F14C	4A		LSR A
F14D	4A		LSR A			;Get the first bit into position.
F14E	4A		LSR A
F14F	4A		LSR A
F150	85,1E		STA &1E			;Enable right hand thin wall (if wanted - missile01)
F152	4A		LSR A
F153	85,1D		STA &1D			;Enable left hand thin wall (if wanted - missle00)

;Get objects to display.
F155	20,35,F2	JSR &F235		;Get next two objects to display.

;Sort out their order.
F158	A5,95		LDA &95			;If the object1 is the
F15A	C9,00		CMP #&00		;invisible surround
F15C	F0,0A		BEQ &F168		;then branch to swap (we want it as player01)

F15E	C9,5A		CMP #&5A		;If the first object is the bridge then
F160	D0,12		BNE &F174		;swap the objects (we want it as player01)

F162	A5,96		LDA &96			;If the object2 is the
F164	C9,00		CMP #&00		;invisble surround then branch to leave
F166	F0,0C		BEQ &F174		;it (we want it as player01)

F168	A5,95		LDA &95
F16A	85,D8		STA &D8
F16C	A5,96		LDA &96
F16E	85,95		STA &95			;Swap the objects to print.
F170	A5,D8		LDA &D8
F172	85,96		STA &96

;Set up object1 to print.
F174	A6,95		LDX &95			;Get object1.
F176	BD,44,FF	LDA &FF44,X		;Get low pointer to it's dynamic information.
F179	85,93		STA &93	
F17B	BD,45,FF	LDA &FF45,X		;Get high pointer to it's dynamic information.
F17E	85,94		STA &94

F180	A0,01		LDY #&01
F182	B1,93		LDA (&93),Y		;Get object1's X coordinate.
F184	85,86		STA &86			;And store for print.
F186	A0,02		LDY #&02
F188	B1,93		LDA (&93),Y		;Get object1's Y coordinate.
F18A	85,87		STA &87			;And store for print.

F18C	BD,46,FF	LDA &FF46,X		;Get low pointer to state value.
F18F	85,93		STA &93
F191	BD,47,FF	LDA &FF47,X		;Get high pointer to state value.
F194	85,94		STA &94
F196	A0,00		LDY #&00
F198	B1,93		LDA (&93),Y		;Retrieve object1's current state.
F19A	85,DC		STA &DC

F19C	BD,48,FF	LDA &FF48,X		;Get low pointer to state information.
F19F	85,93		STA &93
F1A1	BD,49,FF	LDA &FF49,X		;Get high pointer to state information.
F1A4	85,94		STA &94
F1A6	20,A1,F2	JSR &F2A1		;Find current state in the state information.

F1A9	C8		INY			;Index to the state's corresponding graphic pointer.
F1AA	B1,93		LDA (&93),Y		;Get object1's low graphic address.
F1AC	85,82		STA &82			;And store for print.
F1AE	C8 		INY
F1AF	B1,93		LDA (&93),Y		;Get object1's high graphic address.
F1B1	85,83		STA &83			;And store for print.

;Check B&W for object01
F1B3	AD,02,82	LDA &0282		;Get console switches
F1B6	29,08		AND #&08		;Check black and white switches.
F1B8	F0,0B		BEQ &F1C5		;Branch if B&W.

;Colour
F1BA	BD,4A,FF	LDA &FF4A,X		;Get object1's colour.
F1BD	20,D3,F2	JSR &F2D3		;Change if necessary.
F1C0	85,06		STA &06			;And set colour luminance00.
F1C2	4C,CD,F1	JMP &F1CD

;B&W
F1C5	BD,4B,FF	LDA &FF4B,X		;Get object1's B&W colour.
F1C8	20,D3,F2	JSR &F2D3		;Change if necessary.
F1CB	85,06		STA &06			;And set colour luminance00.

;Object1 Size
F1CD	BD,4C,FF	LDA &FF4C,X		;Get object1's size.
F1D0	09,10		ORA #&10		;And set to larger size if necessary.
F1D2	85,04		STA &04			;(Used by bridge and invisible surround).

;Set up Object2 to print.
F1D4	A6,96		LDX &96			;Get object2.
F1D6	BD,44,FF	LDA &FF44,X
F1D9	85,93		STA &93			;Get low pointer to it's dynamic information.
F1DB	BD,45,FF	LDA &FF45,X
F1DE	85,94		STA &94			;Get high pointer to it's dynamic information.
F1E0	A0,01		LDY #&01
F1E2	B1,93		LDA (&93),Y		;Get object2's X coordinate.
F1E4	85,88		STA &88			;And store for print.
F1E6	A0,02		LDY #&02	
F1E8	B1,93		LDA (&93),Y		;Get object2's Y coordinate.
F1EA	85,89		STA &89			;And store for print.
F1EC	BD,46,FF	LDA &FF46,X		;Get low pointer to state value.
F1EF	85,93		STA &93
F1F1	BD,47,FF	LDA &FF47,X		;Get high pointer to state value.
F1F4	85,94		STA &94

F1F6	A0,00		LDY #&00
F1F8	B1,93		LDA (&93),Y		;Retrieve object2's current state.
F1FA	85,DC		STA &DC
F1FC	BD,48,FF	LDA &FF48,X		;Get low pointer to state information.
F1FF	85,93		STA &93
F201	BD,49,FF	LDA &FF49,X		;Get high pointer to state information.
F204	85,94		STA &94
F206	20,A1,F2	JSR &F2A1		;Find the current state in the state information.

F209	C8		INY			;Index to the state's corresponding graphic pointer.
F20A	B1,93		LDA (&93),Y
F20C	85,84		STA &84			;Get object2's low graphic address.
F20E	C8		INY
F20F	B1,93		LDA (&93),Y		;Get object2's high graphic address.
F211	85,85		STA &85

;Check B&W for Object2
F213	AD,82,02	LDA &0282		;Get console switches
F216	29,08		AND #&08		;Check black and white switch.
F218	F0,0B		BEQ &F225		;If B&W then branch.

;Colour
F21A	BD,4A,FF	LDA &FF4A,X		;Get object2's colour
F21D	20,D3,F2	JSR &F2D3		;Change if necessary.
F220	85,07		STA &07			;And set colour luminance01.
F222	4C,2D,F2	JMP &F22D

;B&W
F225	BD,4B,FF	LDA &FF4B,X		;Get object2's B&W colour.
F228	20,D3,F2	JSR &F2D3		;Change if necessary.
F22B	85,07		STA &07			;And set colour luminance01.

;Object2 Size.
F22D	BD,4C,FF	LDA &FF4C,X		;Get object2's size.
F230	09,10		ORA #&10		;And set to larger size if necessary.
F232	85,05		STA &05			;(Used by bridge and invisible surround)
F234	60		RTS




;Fill cache with two object's in this room.
F235	A4,9C		LDY &9C			;Get last object.
F237	A9,A2		LDA #&A2		;Set cache to
F239	85,95		STA &95			;no-objects.
F23B	85,96		STA &96
F23D	98		TYA
F23E	18		CLC			;Goto the next object to
F23F	69,09		ADC #&09		;check (add nine).
F241	C9,A2		CMP #&A2		;Check if over maximum.
F243	90,02		BCC &F247

F245	A9,00		LDA #&00		;If so, wrap to zero.

F247	A8		TAY
F248	B9,44,FF	LDA &FF44,Y		;Get low byte of object info.
F24B	85,93		STA &93
F24D	B9,45,FF	LDA &FF45,Y		;Get high byte of object info.
F250	85,94		STA &94

F252	A2,00		LDX #&00
F254	A1,93		LDA (&93,X)		;Get objects current room.
F256	C5,8A		CMP &8A			;Is it in this room?
F258	D0,10		BNE &F26A		;If not, try next object (branch).

F25A	A5,95		LDA &95			;Check first slot.
F25C	C9,A2		CMP #&A2		;If not default (no-object)
F25E	D0,05		BNE &FF65		;then branch.

F260	84,95		STY &95			;Store this object's number to print
F262	4C,6A,F2	JMP &F26A		;and try for more.

F265	84,96		STY &96			;Store this object's number to print
F267	4C,6E,F2	JMP &F26E		;and then give up - no slots free.

F26A	C4,9C		CPY &9C			;Have we done all the objects.
F26C	D0,CF		BNE &F2EF		;If not, continue.

F26E	84,9C		STY &9C			;If so, store current count
F270	60		RTS			;for next time.




;Covert room number to address.
F271	85,D8		STA &D8			;Store room number wanted.
F273	85,93		STA &93
F275	A9,00		LDA #&00		;Zero the high byte of the
F277	85,94		STA &94			;offset.
F279	18		CLC
F27A	26,93		ROL &93	
F27C	26,94		ROL &94			;Multiply room number by eight.
F27E	26,93		ROL &93
F280	26,94		ROL &94
F282	26,93		ROL &93
F284	29,94		ROL &94

F286	A5,D8		LDA &D8			;Get the original room number.
F288	18		CLC
F289	65,93		ADC &93
F28B	85,93		STA &93			;And add it to the offset.
F28D	A9,00		LDA #&00
F28F	65,94		ADC &94			;In effect the room number is
F291	85,94		STA &94			;multiplied by nine.

F293	A9,1B		LDA #&1B
F295	18		CLC
F296	65,93		ADC &93			;Add the room data base address
F298	85,93		STA &93			;to the offset therefore getting
F29A	A9,FE		LDA #&FE		;the final room data address.
F29C	65,94		ADC &94
F29E	85,94		STA &94
F2A0	60		RTS





;Get pointer to current state.
F2A1	A0,00		LDY #&00
F2A3	A5,DC		LDA &DC			;Get the current object state.
F2A5	D1,93		CMP (&93),Y		;Have we found it in the list of states.
F2A7	90,08		BCC &F2B1		;If nearing it then found it and return.
F2A9	F0,06		BEQ &F2B1		;If found it then return.

F2AB	C8		INY			
F2AC	C8		INY			;Goto next state in list of states.
F2AD	C8		INY
F2AE	4C,A5,F2	JMP &F2A5

F2B1	60		RTS




;Check for input.
F2B2	E6,E5		INC &E5			;Increment low count.
F2B4	D0,08		BNE &F2BE

F2B6	E6,E6		INC &E6			;Increment the high count if
F2B8	D0,04		BNE &F2BE		;needed.

F2BA	A9,80		LDA #&80		;Wrap the high count (indicating
F2BC	85,E6		STA &E6			;timeout) if needed.

F2BE	AD,80,02	LDA &0280		;Get joystick values.
F2C1	C9,FF		CMP #&FF		;If any movement then branch.
F2C3	D0,09		BNE &F2CE

F2C5	AD,82,02	LDA &0282		;Get the console switches
F2C8	29,03		AND #&03		;Mask for the reset/select switches.
F2CA	C9,03		CMP #&03		;Have either of them been used.
F2CC	F0,04		BEQ &F2D2		;If not branch

F2CE	A9,00		LDA #&00		;Zero the high count if the
F2D0	85,E6		STA &E6			;switches or joystick have been used.

F2D2	60		RTS




;Change colour if necessary.
F2D3	4A		LSR A			;If bit 0 of the colour is set
F2D4	90,04		BCC &F2DA		;then the room is to flash.

F2D6	A8		TAY			;Use colour as an index (usually E5 - the low counter).
F2D7	B9,80,00	LDA &0080,Y		;Get flash colour (usually the low counter)

F2DA	A4,E6		LDY &E6			;Get the input counter.
F2DC	10,04		BPL &F2E2		;If console/joystick moved recently then branch.

F2DE	45,E6		EOR &E6			;Merge the high counter with the colour wanted.
F2E0	29,FB		AND #&FB		;Keep this colour but merge down the luminance.

F2E2	0A		ASL A			;And restore original colour if necessary.
F2E3	60		RTS




;Get the address of the dynamic information for an object.
F2E4	BD,44,FF	LDA &FF44,X
F2E7	85,93		STA &93			;Get and store the low address.
F2E9	BD,45,FF	LDA &FF45,X
F2EC	85,94		STA &94			;Get and store the high address.
F2EE	60		RTS




;Game Start
F2EF	78		SEI			;Interupts off.
F2F0	D8		CLD
F2F1	A2,28		LDX #&28		;Clear TIA registers
F2F3	A9,00		LDA #&00		;&04-&2C i.e. blank
F2F5	95,04		STA &04,X		;everything and turn
F2F7	CA		DEX			;everything off.
F2F8	10,FB		BPL &F2F5

F2FA	9A		TXS			;Reset stack.
F2FB	95,00		STA &00,X		;Clear &FF-&80 which
F2FD	CA		DEX			;are the user variables.
F2FE	30,FB		BMI &F2FB

F300	20,71,F3	JSR &F371		;Position the thin walls (missiles)
F303	20,D3,F3	JSR &F3D3		;Set up objects rooms and positions.


F306	20,84,F3	JSR &F384		;Check to see if game wants to start.
F309	20,23,FA	JSR &FA23		;Make noise if necessary.
F30C	20,B2,F2	JSR &F2B2		;Check for any input.

F30F	A5,DE		LDA &DE			;Is the game currently active.
F311	D0,52		BNE &F365		;If not branch

F313	A5,B9		LDA &B9			;Get the room the chalise is in.
F315	C9,12		CMP #&12		;Is it in the yellow castle?
F317	D0,0A		BNE &F323		;If not, branch.

F319	A9,FF		LDA #&FF
F31B	85,DF		STA &DF			;Set the note count to maximum.
F31D	85,DE		STA &DE			;Set the game to inactive.
F31F	A9,00		LDA #&00		;Set the noise type to end-noise.
F321	85,E0		STA &E0

F323	A0,00		LDY #&00		;Allow joystick read - all movement.
F325	20,C2,F4	JSR &F4C2		;Check ball collisions and move ball.
F328	20,D4,F5	JSR &F5D4		;Move the carried object.
F32B	20,EC,F0	JSR &F0EC		;Wait for VSYNC
F32E	20,0F,F1	JSR &F10F		;Set up the room and objects for display.
F331	20,08,F0	JSR &F008		;Display the room and objects.
F334	20,56,F5	JSR &F556		;Deal with object pickup and putdown.
F337	A0,01		LDY #&01		;Disallow joystick read - move vertically only.
F339	20,C2,F4	JSR &F4C2		;Check ball collisions and move ball.
F33C	20,E7,F9	JSR &F9E7		;Deal with invisible surround moving.
F33F	20,EC,F0	JSR &F0EC		;Wait for VSYNC
F342	20,A5,F8	JSR &F8A5		;Move and deal with bat.
F345	20,3C,F9	JSR &F93C		;Move and deal with portcullises.
F348	20,08,F0	JSR &F008		;Display the room and objects.
F34B	20,CB,F7	JSR &F7CB		;Move and deal with green dragon.
F34E	20,B0,F7	JSR &F7B0		;Move and deal with yellow dragon.
F351	20,EC,F0	JSR &F0EC		;Wait for VSYNC
F354	A0,02		LDY #&02		;Disallow joystick read/bridge check - move horizontally only.
F356	20,C2,F4	JSR &F4C2		;Check ball collisions and move ball.
F359	20,95,F7	JSR &F795		;Move and deal with the red dragon.
F35C	20,B3,F9	JSR &F9B3		;Deal with the magnet
F35F	20,08,F0	JSR &F008		;Display the room and objects.
F362	4C,06,F3	JMP &F306	



;Non-Active Game Loop
F365	20,EC,F0	JSR &F0EC		;Wait for VSYNC
F368	20,08,F0	JSR &F008		;Display the room and objects.
F36B	20,0F,F1	JSR &F10F		;Set up room and objects for display.
F36E	4C,06,F3	JMP &F306



;Position missles to "thin wall" areas
F371	A9,0D		LDA #&0D		;Position missle00 to
F373	A2,02		LDX #&02		;(0D,00) - left thin wall
F375	20,D2,F0	JSR &F0D2
F378	A9,96		LDA #&96		;Position missle01 to
F37A	A2,03		LDX #&03		;(96,00) - right thin wall
F37C	20,D2,F0	JSR &F0D2
F37F	85,02		STA &02			;Wait for horizontal blank
F381	85,2A		STA &2A			;Apply the horizontal move
F383	60		RTS



;Reset/Select A Game
F384	AD,82,02	LDA &0282		;Get the console switches
F387	49,FF		EOR #&FF		;Flip (as reset active low).
F389	25,92		AND &92			;Compare with what was before.
F38B	29,01		AND #01			;And check only the reset switch.
F38D	F0,26		BEQ &F3B5		;If no reset then branch.

F38F	A5,DE		LDA &DE			;Has the game started.
F391	C9,FF		CMP #&FF		;If not then branch.
F393	F0,3E		BEQ &F3D3

F395	A9,11		LDA #&11		;Get the yellow castle room.
F397	85,8A		STA &8A			;Make it the current room.
F399	85,E2		STA &E2			;Make it the previous room.
F39B	A9,50		LDA #&50		;Get the X coordinate.
F39D	85,8B		STA &8B			;Make it the current ball X coordinate.
F39F	85,E3		STA &E3			;Make it the previous ball X coordinate.
F3A1	A9,20		LDA #&20		;Get the Y coordinate.
F3A3	85,8C		STA &8C			;Make it the current ball Y coordinate.
F3A5	85,E4		STA &E4			;Make it the previous ball Y coordinate.
F3A7	A9,00		LDA #&00
F3A9	85,A8		STA &A8			;Set the red dragon's state to OK.
F3AB	85,AD		STA &AD			;Set the yellow dragon's state to OK.
F3AD	85,B2		STA &B2			;Set the green dragon's state to OK.
F3AF	85,DF		STA &DF			;Set the note count to zero (ops!)
F3B1	A9,A2		LDA #&A2
F3B3	85,9D		STA &9D			;Set no object being carried.

;Check for select.
F3B5	AD,82,02	LDA &0282		;Get the console switches
F3B8	49,FF		EOR #&FF		;Flip (as select active low)
F3BA	25,92		AND &92			;Compare with what was before.
F3BC	29,02		AND #&02		;And check only the select switch.
F3BE	F0,4C		BEQ &F40C		;Branch if select not being used.

F3C0	A5,8A		LDA &8A			;Get the current room.
F3C2	C9,00		CMP #&00		;Is it the 'number' room.
F3C4	D0,0D		BNE &F3D3		;Branch if not.

F3C6	A5,DD		LDA &DD			;Increment the level
F3C8	18		CLC			;number (by two).
F3C9	69,02		ADC #&02
F3CB	C9,06		CMP #&06		;Has it reached the maximum?
F3CD	90,02		BCC &F3D1

F3CF	A9,00		LDA #&00		;If so, reset it back to 00.

F3D1	85,DD		STA &DD			;And store the new level number.

;Set up the object locations.
F3D3	A9,00		LDA #&00		;Set the current room to the
F3D5	85,8A		STA &8A			;'number' room.
F3D7	85,E2		STA &E2			;And the previous room.
F3D9	A9,00		LDA #&00		;Set the ball's Y coordinate to zero.
F3DB	85,8C		STA &8C			;And the previous Y coordinate
F3DD	85,E4		STA &E4			;(So can't be seen)

F3DF	A4,DD		LDY &DD			;Get the level number.
F3E1	B9,5A,F4	LDA &F45A,Y		;Get the low pointer to object locations.
F3E4	85,93		STA &93
F3E6	B9,5B,F4	LDA &F45B,Y		;Get the high pointer to object locations.
F3E9	85,94		STA &94

F3EB	A0,30		LDY #&30		;Copy all the objects dynamamic information
F3ED	B1,93		LDA (&93),Y		;(the rooms and positions) into
F3EF	99,A1,00	STA &00A1,Y		;the working area.
F3F2	88		DEY
F3F3	10,F8		BNE &F3ED

F3F5	A5,DD		LDA &DD			;Get the level number.
F3F7	C9,04		CMP #&04		;Branch if levels one
F3F9	90,09		BCC &F404		;or two (i.e. all objects in definite rooms).

F3FB	20,12,F4	JSR &F412		;Put some objects in random rooms.
F3FE	20,EC,F0	JSR &F0EC		;Wait for VSYNC
F401	20,08,F0	JSR &F008		;Display room and objects.

F404	A9,00		LDA #&00		;Signal that the game has started.
F406	85,DE		STA &DE
F408	A9,A2		LDA #&A2		;Set no object being carried.
F40A	85,9D		STA &9D

F40C	AD,82,02	LDA &0282		;Store the current console switches
F40F	85,92		STA &92
F411	60		RTS



;Put objects in random rooms (for level 3)
F412	A0,1E		LDY #&1E		;For each of the eleven objects...

F414	A5,E5		LDA &E5			;Get the low input counter as seed.
F416	4A		LSR A
F417	4A		LSR A
F418	4A		LSR A			;Generate a pseudo-random
F419	4A		LSR A			;room number.
F41A	4A		LSR A
F41B	38		SEC
F41C	65,E5		ADC &E5			;Store as the new low input counter.
F41E	85,E5		STA &E5
F420	29,1F		AND #&1F		;Trim so represents a room value.
F422	D9,3A,F4	CMP &F43A,Y		;If it is less than the
F425	90,ED		BCC &F414		;lower bound for object then get another.

F427	D9,3B,F4	CMP &F43B,Y		;If it equals or is
F42A	F0,02		BEQ &F42E		;less than the higher bound for object
F42C	B0,E6		BCS &F414		;then continue (branch if higher)

F42E	BE,39,F4	LDX &F439,Y		;Get the dynamic data index for this object.
F431	95,00		STA &00,X		;Store the new room value.
F433	88		DEY
F434	88		DEY			;Goto next object.
F435	88		DEY
F436	10,DC		BPL &F414		;Until all done.

F438	60		RTS



;Room bounds data.
;i.e. the chalise at location &B9 can only exist in rooms 13-1A for 
;     level 3.

	Offset	Lower Bound	Higher bound
F439	B9	13		1A		;Chalise
F43C	A4	01		1D		;Red dragon.
F43F	A9	01		1D		;Yellow dragon.
F442	AE	01		1D		;Green Dragon.
F445	B6	01		1D		;Sword
F448	BC	01		1D		;Bridge
F44B	BF	01		1D		;Yellow Key
F44E	C2	01		16		;White Key
F451	C5	01		12		;Black Key
F454	CB	01		1D		;Bat
F457	B3	01		1D		;Magnet

F45A	60,F4					;Pointer to object locations for game 01.
F45C	91,F4					:Pointer to object locations for game 02.
F45E	91,F4					;Pointer to object locations for game 03.

;Object locations (room and coordinate) for game 01.
F460	15,51,12				;Black dot (Room,X,Y)
F463	0E,50,20,00,00				;Red Dragon (Room,X,Y,Movement,State)
F468	01,51,20,00,00				;Yellow Dragon (Room,X,Y,Movement,State)
F46D	1D,50,20,00,00				;Green Dragon (Room,X,Y,Movement,State)
F472	1B,80,20				;Magnet (Room,X,Y)
F475	12,20,20				;Sword (Room,X,Y)
F478	1C,30,20				;Chalise (Room,X,Y)
F47B	04,29,37				;Bridge (Room,X,Y)
F47E	11,20,40				;Yellow Key (Room,X,Y)
F481	0E,20,40				;White Key (Room,X,Y)
F484	1D,20,40				;Black Key (Room,X,Y)
F487	1C					;Portcullis State
F488	1C					;Portcullis State
F489	1C					;Portcullis State
F48A	1A,20,20,00,00				;Bat (Room,X,Y,Movement,State)
F48F	78,00					;Bat (Carrying,Fed-Up)

;Object locations (room and coordinate) for games 02 and 03.
F491	15,51,12				;Black Dot (Room,X,Y)
F494	14,50,20,A0,00				;Red Dragon (Room,X,Y,Movement,State)
F499	19,50,20,A0,00				;Yellow Dragon (Room,X,Y,Movement,State)
F49E	04,50,20,A0,00				;Green Dragon (Room,X,Y,Movement,State)
F4A3	E0,80,20				;Magnet (Room,X,Y)
FAA6	11,20,20				;Sword (Room,X,Y)
F4A9	14,03,20				;Chalise (Room,X,Y)
F4AC	0B,40,40				;Bridge (Room,X,Y)
F4AF	09,20,40				;Yellow Key (Room,X,Y)
F4B2	06,20,40				;White Key (Room,X,Y)
F4B5	19,20,40				;Black Key (Room,X,Y)
F4B8	1C					;Portcullis State
F4B9	1C					;Portcullis State
F4BA	1C					;Portcullis State
F4BB	02,20,20,90,00				;Bat (Room,X,Y,Movement,State)
F4C0	78,00					;Bat (Carrying,Fed-Up)



;Check ball collisions and move ball.
F4C2	A5,36		LDA &36
F4C4	29,80		AND #&80		;Get ball-playfield collision 
F4C6	D0,2D		BNE &F4F5		;Branch if collision (Player-Wall)

F4C8	A5,34		LDA &34
F4CA	29,40		AND #&40		;Get ball-missile00 collision.
F4CC	D0,27		BNE &F4F5		;Branch if collision. (Player-Left Thin)

F4CE	A5,35		LDA &35
F4D0	29,40		AND #&40		;Get ball-missile01 collision.
F4D2	F0,06		BEQ &F4DA		;Branch if no collision.

F4D4	A5,96		LDA &96			;If object2 (to print) is
F4D6	C9,87		CMP #&87		;not the black dot then collide.
F4D8	D0,1B		BNE &F4F5

F4DA	A5,32		LDA &32
F4DC	29,40		CMP #&40		;Get ball-player00 collision.
F4DE	F0,06		BEQ &F4E6		;If no collision then branch.

F4E0	A5,95		LDA &95			;If object1 (to print) is
F4E2	C9,00		CMP #&00		;not the invisible surround then
F4E4	D0,0F		BNE &F4F5		;branch (collision)

F4E6	A5,33		LDA &33
F4E8	29,40		AND #&40		;Get ball-player01 collision.
F4EA	F0,33		BEQ &F51F		;If no collision then branch.

F4EC	A5,96		LDA &96			;If player01 to print is
F4EE	C9,00		CMP #&00		;not the invisible surround then
F4F0	D0,03		BNE &F4F5		;branch (collision)

F4F2	4C,1F,F5	JMP &F51F		;No collision - branch.

;Player collided (with something)
F4F5	C0,02		CPY #&02		;Are we checking for the bridge?
F4F7	D0,36		BNE &F52F		;If not, branch.

F4F9	A5,9D		LDA &9D			;Get the object being carried.
F4FB	C9,5A		CMP #&5A		;Branch if it is the bridge.
F4FD	F0,33		BEQ &F532

F4FF	A5,8A		LDA &8A			;Get the current room.
F501	C5,BC		CMP &BC			;Is the bridge in this room.
F503	D0,2A		BNE &F52F		;If not, branch.

;Check going through bridge
F505	A5,8B		LDA &8B			;Get the ball's X coordinate.
F507	38		SEC
F508	E5,BD		SBC &BD			;Subtract the bridge's X coordinate.
F50A	C9,0A		CMP #&0A		;If less than &0A then forget it.
F50C	90,21		BCC &F52F

F50E	C9,17		CMP #&17		;If more than &17 then forget it.
F510	B0,1D		BCS &F52F

F512	A5,BE		LDA &BE			;Get the bridge's Y coordinate.
F514	38		SEC
F515	E5,8C		SBC &8C			;Subtract the ball's Y coordinate.
F517	C9,FC		CMP #&FC
F519	B0,04		BCS &F51F		;If more than &FC then going through bridge.

F51B	C9,19		CMP #&19		;If more than &19 then forget it.
F51D	B0,10		BCS &F52F

;No collision (and going through bridge)
F51F	A9,FF		LDA #&FF		;Reset the joystick input.
F521	85,99		STA &99
F523	A5,8A		LDA &8A			;Get the current room.
F525	85,E2		STA &E2			;And store temporarily.
F527	A5,8B		LDA &8B			;Get the ball's X coordinate.
F529	85,E3		STA &E3			;And store temporarily.
F52B	A5,8C		LDA &8C			;Get the ball's Y coordinate.
F52D	85,E4		STA &E4			;And store temporarily.

;C
F52F	C0,00		CPY #&00		;???Is game in first phase.
F531	D0,05		BNE &F538		;If not, don't bother with joystick read.

F533	AD,80,02	LDA &0280		;Read joysticks
F536	85,99		STA &99			;And store value.

F538	A5,E2		LDA &E2			;Get temporary room
F53A	85,8A		STA &8A			;And make it the current room.
F53C	A5,E3		LDA &E3			;Get temporary X coordinate.
F53E	85,8B		STA &8B			;And make it the man's X coordinate.
F540	A5,E4		LDA &E4			;Get temporary Y coordinate.
F542	85,8C		STA &8C			;And make it the man's Y coordinate.

F544	A5,99		LDA &99			;Get the joystick position.
F546	19,53,F5	ORA &F553,Y		;Merge out movement not allowed in this phase.
F549	85,9B		STA &9B			;And store cooked movement.

F54B	A0,04		LDY #&04		;Set the delta for the ball.
F54D	A2,8A		LDX #&8A		;Point to ball's coordinates.
F54F	20,FF,F5	JSR &F5FF		;Move the ball.
F552	60		RTS



;Joystick Merge Values
F553	00,C0,30				;No change,No horizontal,No vertical



;Deal with object pickup and putdown.
F556	26,3C		ROL &3C			;Get joystick trigger.
F558	66,D7		ROR &D7			;Merge into joystick record.
F55A	A5,D7		LDA &D7			;Get joystick record.
F55C	29,C0		AND #&C0		;Merge out previous presses.
F55E	C9,40		CMP #&40		;Was it previously pressed.
F560	D0,10		BNE &F572		;If not branch.

F562	A9,A2		LDA #&A2
F564	C5,9D		CMP &9D			;If nothing is being carried
F566	F0,0A		BEQ &F572		;then branch.

;Drop object
F568	85,9D		STA &9D			;Drop object.
F56A	A9,04		LDA #&04		;Set noise type to four.
F56C	85,E0		STA &E0
F56E	A9,04		LDA #&04		;Set noise count to four.
F570	85,DF		STA &DF

F572	A9,FF		LDA #&FF		;????
F574	85,98		STA &98

;Check for collision.
F576	A5,32		LDA &32
F578	29,40		AND #&40		;Get Ball-Player00 collision.
F57A	F0,07		BEQ &F583		;If nothing occured branch.

;With Player00
F57C	A5,95		LDA &95			;Get type of Player00. 
F57E	85,97		STA &97			;And store.
F580	4C,93,F5	JMP &F593		;Deal with collision.

;With Player01
F583	A5,33		LDA &33
F585	29,40		AND #&40		;Get Ball-Player01 collision.
F587	F0,07		BEQ &F590		;If nothing has happened, branch.

F589	A5,96		LDA &96			;Get type of Player01
F58B	85,97		STA &97			;And store.
F58D	4C,93,F5	JMP &F593		;Deal with collision.

F590	4C,D3,F5	JMP &F5D3		;Deal with no collision (return).

;Collision occured.
F593	A6,97		LDX &97			;Get the object collided with.
F595	20,E4,F2	JSR &F2E4		;Get it's dynamic information.
F598	A5,97		LDA &97			;Get the object collided with.
F59A	C9,51		CMP #&51		;Is it carriable?
F59C	90,35		BCC &F5D3		;If not, branch.

F59E	A0,00		LDY #&00
F5A0	B1,93		LDA (&93),Y		;Get the object's room.
F5A2	C5,8A		CMP &85			;Is it in the current room.
F5A4	D0,4D		BNE &F5F3		;If not, branch (huh?)

F5A6	A5,97		LDA &97			;Get the object collided with.
F5A8	C5,9D		CMP &9D			;Is it the object being carried.
F5AA	F0,08		BEQ &F5B4		;If so, branch (and actually pick it up).

F5AC	A9,05		LDA #&05		;Set noise type to five.
F5AE	85,E0		STA &E0
F5B0	A9,04		LDA #&04		;Set noise count to four.
F5B2	85,DF		STA &DF

F5B4	A5,97		LDA &97			;Set object as being
F5B6	85,9D		STA &9D			;carried.

F5B8	A6,93		LDX &93			;Get dynamic address low byte.
F5BA	A0,06		LDY #&06
F5BC	A5,99		LDA &99			;????
F5BE	20,AC,F6	JSR &F6AC		;????

F5C1	A0,01		LDY #01
F5C3	B1,93		LDA (&93),Y		;Get the object's X coordinate.
F5C5	38		SEC
F5C6	E5,8B		SBC &8B			;Subtract the ball's X coordinate.
F5C8	85,9E		STA &9E			;And store the difference.
F5CA	A0,02		LDY #&02
F5CC	B1,93		LDA (&93),Y		;Get the object's Y coordinate.
F5CE	38		SEC
F5CF	E5,8C		SBC &8C			;Subtract the ball's Y coordinate.
F5D1	85,9F		STA &9F			;And store the difference.

;No collision
F5D3	60		RTS



;Move the carried object
F5D4	A6,9D		LDX &9D			;Get the object being carried.
F5D6	E0,A2		CPX #&A2		;If nothing then branch (return)
F5D8	F0,24		BEQ &F5FE

F5DA	20,E4,F2	JSR &F2E4		;Get it's dynamic information.
F5DD	A0,00		LDY #&00
F5DF	A5,8A		LDA &8A			;Get the current room.
F5E1	91,93		STA (&93),Y		;And store as the object's current room.
F5E3	A0,01		LDY #&01
F5E5	A5,8B		LDA &8B			;Get the ball's X coordinate.
F5E7	18		CLC
F5E8	65,9E		ADC &9E			;Add the X difference.
F5EA	91,93		STA (&93),Y		;And store as the object's X coordinate.
F5EC	A0,02		LDY &02
F5EE	A5,8C		LDA &8C			;Get the ball's Y coordinate.
F5F0	18		CLC
F5F1	65,9F		ADC &9F			;Add the Y difference.
F5F3	91,93		STA (&93),Y		;And store as the object's Y coordinate.

F5F5	A0,00		LDY #&00		;Set no delta.
F5F7	A9,FF		LDA #&FF		;Set no movement.
F5F9	A6,93		LDX &93			;Get the objects dynamic address.
F5FB	20,FF,F5	JSR &F5FF		;Move the object.
F5FE	90		RTS



;Move object in a direction by a delta .
F5FF	20,AC,F6	JSR &F6AC		;Move object by delta.
F602	A0,02		LDY #&02		;Set to do the three
F604	84,9A		STY &9A			;portcullises.
F606	B9,C8,00	LDA &00C8,Y		;Get port's state.
F609	C9,1C		CMP #&1C		;Is it in a closed state?
F60B	F0,22		BEQ &F62F		;If not, next port.

;Deal with object moving out of a castle.
F60D	A4,9A		LDY &9A			;Get port number.
F60F	B5,00		LDA &00,X		;Get object's room number.
F611	D9,AD,F9	CMP &F9AD,Y		;Is it in a castle entry room
F614	D0,19		BNE &F62F		;If not, next port.

F616	B5,02		LDA &02,X		;Get object's Y coordinate
F618	C9,0D		CMP #&0D		;Is it above &0D i.e. at the bottom.
F61A	10,13		BPL &F62F		;If so then branch.

F61C	B9,B0,F9	LDA &F9B0,X		;Get the castle room.
F61F	95,00		STA &00,X		;And put the object in the castle room.
F621	A9,50		LDA #&50
F623	95,01		STA &01,X		;Set the object's new X coordinate.
F625	A9,2C		LDA #&2C
F627	95,02		STA &02,X		;Set the new object's Y coordinate.
F629	A9,01		LDA #&01
F62B	99,C8,00	STA &00C8,Y		;Set portcullis state to 01.
F62E	60		RTS

F62F	A4,9A		LDY &9A			;Get portcullis number.
F631	88		DEY			;Goto next.	
F632	10,D0		BPL &F604		;And continue.

;Check and Deal With Up.
F634	B5,02		LDA &02,X		;Get object's Y coordinate.
F636	C9,6A		CMP #&6A		;Has it reached above the top.
F638	30,09		BMI &F643		;If not, branch.

F63A	A9,D0		LDA #&D0		;Set new Y coordinate to bottom.
F63C	95,02		STA &02,X
F63E	A0,05		LDY #&05		;Get the direction wanted.
F640	4C,9F,F6	JMP &F69F		;Go and get new room.

;Check and Deal With Left
F643	B5,01		LDA &01,X		;Get objects's X coordinate.
F645	C9,03		CMP #&03		;Is it three or less?
F647	90,07		BCC &F650		;If so, branch. (off to left)

F649	C9,F0		CMP #&F0		;Is it &F0 or more.
F64B	B0,03		BCS &F650		;If so, branch. (off to right)

F64D	4C,62,F6	JMP &F662

F650	E0,8A		CPX #&8A		;Are we dealing with the ball.
F652	F0,05		BEQ &F659		:If so, branch.

F654	A9,9A		LDA #&9A		;Set new X coordinate for other objects.
F656	4C,5B,F6	JMP &F65B

F659	A9,9E		LDA #&9E		;Set new X coordinate for the ball.

F65B	95,01		STA &01,X		;Store the new X coordinate.
F65D	A0,08		LDY #&08		;And get direction wanted.
F65F	4C,9F,F6	JMP &F69F		;Go and get new room.

;Check amnd Deal With Down.
F662	B5,02		LDA &02,X		;Get the object's Y coordinate.
F664	C9,0D		CMP #&0D		;If it's greater than &0D then
F666	B0,09		BCS &F671		;branch.

F668	A9,69		LDA #&69		;Set new Y coordinate.
F66A	95,02		STA &02,X
F66C	A0,07		LDY #&07		;Get the direction wanted.
F66E	4C,9F,F6	JMP &F69F		;Go and get new room.

;Check and Deal with Right.
F671	B5,01		LDA &01,X		;Get object's X coordinate.
F673	E0,8A		CPX #&8A		;Are we dealing with the ball.
F675	D0,1B		BNE &F692		;Branch if not.

F677	C9,9F		CMP #&9F		;Has the object reached the right.
F679	90,30		BCC &F6AB		;Branch if not.

F67B	B5,00		LDA &00,X		;Get the ball's room.
F67D	C9,03		CMP #&03		;Is it room #3 (Right to secret room)
F67F	D0,15		BNE &F696		;Branch if not.

F681	A5,A1		LDA &A1			;Check the room of the black dot.
F683	C9,15		CMP #&15		;Is it in the hidden room area.
F685	F0,0F		BEQ &F696		;Is so, branch.

;Manually change to secret room.
F687	A9,1E		LDA #&1E		;Set room to secret room.
F689	95,00		STA &00,X		;And make it current.
F68B	A9,03		LDA #&03		;Set the X coordinate.
F68D	95,01		STA &01,X
F68F	4C,AB,F6	JMP &F6AB		;And exit.

F692	C9,9B		CMP #&9B		;Has the object reached the right of screen.
F694	90,15		BCC &F6AB		;Branch if not (No room change)

F696	A9,03		LDA #&03		;Set the new X coordinate.
F698	95,01		STA &01,X
F69A	A0,06		LDY #&06		;And get the direction wanted.
F69C	4C,9F,F6	JMP &F69F		;Get the new room.

;Get new room.
F69F	B5,00		LDA &00,X		;Get the object's room.
F6A1	20,71,F2	JSR &F271		;Convert it to an address.
F6A4	B1,93		LDA (&93),Y		;Get the next adjacent room.
F6A6	20,D5,F6	JSR &F6D5		;Deal with level differences.
F6A9	95,00		STA &00,X		;And store as new object's room.

F6AB	60		RTS



;Move object in direction by delta.
F6AC	85,9B		STA &9B			;Store direction wanted.
F6AE	88		DEY			;Count down the delta.
F6AF	30,23		BMI &F6D4

F6B1	A5,9B		LDA &9B			;Get direction wanted.
F6B3	29,80		AND #&80		;Check for right move.
F6B5	D0,02		BNE &F6B9		;If no move right then branch.

F6B7	F6,01		INC &01,X		;Increment the X coordinate.

F6B9	A5,9B		LDA &9B			;Get direction wanted.
F6BB	29,40		AND #&40		;Check for left move.
F6BD	D0,02		BNE &F6C1		;If no move left then branch.

F6BF	D6,01		DEC &01,X		;Decrement the X coordinate.

F6C1	A5,9B		LDA &9B			;Get direction wanted.
F6C3	29,10		AND #&10		;Check for move up.
F6C5	D0,02		BNE &F6C9		;If no move up then branch.

F6C7	F6,02		INC &02,X		;Increment the Y coordinate.

F6C9	A5,9B		LDA &9B			;Get direction wanted.
F6CB	29,20		AND #&20		;Check for move down.
F6CD	D0,02		BNE &F6D1		;If no move down then branch.

F6CF	D6,02		DEC &02,Y		;Decrement the Y coordinate.

F6D1	4C,AE,F6	JMP &F6AE		;Keep going until delta finished.
F6D4	60		RTS



;Adjust next room for different levels.
F6D5	C9,80		CMP #&80		;Is the room number	
F6D7	90,0F		BCC &F6E8		;above &80?

F6D9	38		SEC
F6DA	E9,80		SBC #&80		;Remove the &80 flag and
F6DC	85,D8		STA &D8			;store the room number.
F6DE	A5,DD		LDA &DD			;Get the level number.
F6E0	4A		LSR A			;Divide it by two.
F6E1	18		CLC
F6E2	65,D8		ADC &D8			;Add to the original room.
F6E4	A8		TAY
F6E5	B9,32,FF	LDA &FF32,Y		;Use as an offset and get
						;the next room.
F6E8	60		RTS



;Get player-ball collision.
F6E9	C5,95		CMP &95			;Is it the first object?
F6EB	F0,07		BEQ &F6F4		;Yes - then branch.
	
F6ED	C5,96		CMP &96			;Is it the second object?
F6EF	F0,08		BEQ &F6F9		;Yes - then branch.

F6F1	A9,00		LDA #&00		;Otherwise nothing.
F6F3	60		RTS

F6F4	A5,32		LDA &32			;Get player00-ball collision.
F6F6	29,40		AND #&40
F6F8	60		RTS

F6F9	A5,33		LDA &33			;Get player01-ball collision.
F6FB	29,40		AND #&40
F6FD	60		RTS



;Find which object has hit object wanted.
F6FE	A5,37		LDA &37			;Get Player00-Player01
F700	29,80		AND #&80		;collision.
F702	F0,08		BEQ &F70C		;If nothing, branch.

F704	E4,95		CPX &95			;Is object 1 the one being hit.
F706	F0,07		BEQ &F70F		;If so, branch.

F708	E4,96		CPX &96			;Is object 2 the one being hit.
F70A	F0,06		BEQ &F712		;If so, branch.

F70C	A9,A2		LDA #&A2		;Set nothing and exit.
F70E	60		RTS

F70F	A5,96		LDA &96			;Therefore select the other.
F711	60		RTS

F712	A5,95		LDA &95			;Therefore select the other.
F714	60		RTS



;Move object.
F715	20,28,F7	JSR &F728		;Get liked object and movement.
F718	A6,D5		LDX &D5			;Get dynamic data address.
F71A	A5,9B		LDA &9B			;Get movement.
F71C	D0,02		BNE &F720		;If movement then branch.

F71E	B5,03		LDA &03,X		;Use old movement.

F720	95,03		STA &03,X		;Store the new movement.			
F722	A4,D4		LDY &D4			;Get object's delta.
F724	20,FF,F5	JSR &F5FF		;Move the object.
F727	60		RTS




;Find liked object and get movement.
F728	A9,00		LDA #&00		;Set index to zero.
F72A	85,E1		STA &E1

F72C	A4,E1		LDY &E1			;Get index.
F72E	B1,D2		LDA (&D2),Y		;Get first object.
F730	AA		TAX
F731	C8		INY
F732	B1,D2		LDA (&D2),Y		;Get second object.
F734	A8		TAY
F735	B5,00		LDA &00,X		;Get object1's room.		
F737	D9,00,00	CMP &0000,Y		;Compare with object2's room.
F73A	D0,0C		BNE &F748		;If not the same room then branch.

F73C	C4,D6		CPY &D6			;Have we matched the second object
F73E	F0,08		BEQ &F748		;for difficulty (if so, carry on).

F740	E4,D6		CPX &D6			;Have we matched the first object
F742	F0,04		BEQ &F748		;for difficulty (if so, carry on).

F744	20,57,F7	JSR &F757		;Get object's movement.
F747	60		RTS

F748	E6,E1		INC &E1			;Increment the index.
F74A	E6,E1		INC &E1
F74C	A4,E1		LDY &E1			;Get the index number.
F74E	B1,D2		LDA (&D2),Y		;Check for end of sequence.
F750	D0,DA		BNE &F72C		;If not branch.

F752	A9,00		LDA #&00		;Set no move if no
F754	85,9B		STA &9B			;liked object found.
F756	60		RTS



;Work out object's movement.
F757	A9,FF		LDA #&FF		;Set object movement to none.
F759	85,9B		STA &9B

F75B	B9,00,00	LDA &0000,Y		;Get object2's room.
F75E	D5,00		CMP &00,X		;Compare it with object's room.
F760	D0,30		BNE &F792		;If not the same, forget it.

F762	B9,01,00	LDA &0001,Y		;Get object2's X coordinate.
F765	D5,01		CMP &01,X		;Get object1's X coordinate.
F767	90,0B		BCC &F774		;If object2 to left of object1 then branch.
F769	F0,0F		BEQ &F77A		;If object2 on object1 then branch.

F76B	A5,9B		LDA &9B			;Get object movement.
F76D	29,7F		AND #&7F		;Signal a move right.
F76F	85,9B		STA &9B
F771	4C,7A,F7	JMP &F77A		;Now try vertical.

F774	A5,9B		LDA &9B			;Get object movement.
F776	29,BF		AND #&BF		;Signal a move left.
F778	85,9B		STA &9B


F77A	B9,02,00	LDA &0002,Y		;Get object2's Y coordinate.
F77D	D5,02		CMP &02,X		;Get object1's X coordinate.
F77F	90,0B		BCC &F78C		;If object2 below object 1 then branch.
F781	F0,0F		BEQ &F792		;If object2 on object 1 then branch.

F783	A5,9B		LDA &9B			;Get object movement.
F785	29,EF		AND #&EF		;Signal a move up.
F787	85,9B		STA &9B
F789	4C,92,F7	JMP &F792		;Jump to finish.

F78C	A5,9B		LDA &9B			;Get object movement.
F78E	29,DF		AND #&DF		;Signal a move down.
F790	85,9B		STA &9B

F792	A5,9B		LDA &9B			;Get the move.
F794	60		RTS



;Move the Red Dragon
F795	A9,A7		LDA #&A7
F797	85,D2		STA &D2			;Set low address of object store.
F799	A9,F7		LDA #&F7
F79B	85,D3		STA &D3			;Set high address of object store.
F79D	A9,04		LDA #&04		
F79F	85,D4		STA &D4			;Set red dragon's delta.
F7A1	A2,36		LDX #&36		;Select dragon #1 : Red
F7A3	20,EA,F7	JSR &F7EA
F7A6	60		RTS



;Red Dragon Object Matrix
F7A7	B6,A4					;Sword,Red Dragon
F7A9	A4,8A					;Red Dragon,Ball
F7AB	A4,B9					;Red Dragon,Chalise
F7AD	A4,C2					;Red Dragon,White Key
F7AF	00



;Move the yellow dragon.
F7B0	A9,C2		LDA #&C2
F7B2	85,D2		STA &D2			;Set low address of object store.
F7B4	A9,F7		LDA #&F7
F7B6	85,D3		STA &D3			;Set high address of object store.
F7B8	A9,03		LDA #&03
F7BA	85,D4		STA &D4			;Set yellow dragon's delta.
F7BC	A2,3F		LDX #&3F
F7BE	20,EA,F7	JSR &F7EA		;Select dragon #2 : Yellow
F7C1	60		RTS



;Yellow Dragon Object Matrix
F7C2	B6,A9					;Sword,Yellow Dragon
F7C4	BF,A9					;Yellow Key,Yellow Dragon
F7C6	A9,8A					;Yellow Dragon,Ball
F7C8	A9,B9					;Yellow Dragon,Chalise
F7CA	00



;Move the green dragon.
F7CB	A9,DD		LDA #&DD
F7CD	85,D2		STA &D2			;Set low address of object store.
F7CF	A9,F7		LDA #&F7
F7D1	85,D3		STA &D3			;Set high address of object store.
F7D3	A9,03		LDA #&03
F7D5	85,D4		STA &D4			;Set green dragon's delta.
F7D7	A2,48		LDX #&48		;Select dragon #3 : Green
F7D9	20,EA,F7	JSR &F7EA
F7DC	60		RTS



;Green dragon object matrix.
F7DD	B6,AE					;Sword,Green Dragon
F7DF	AE,8A					;Green Dragon,Ball
F7E1	AE,B9					;Green Dragon,Chalise
F7E3	AE,BC					;Green Dragon,Bridge
F7E5	AE,B3					;Green Dragon,Magnet
F7E7	AE,C5					;Green Dragon,Black Key
F7E9	00


;Move Object
F7EA	86,A0		STX &A0			;Save object dealing with.
F7EC	BD,44,FF	LDA &FF44,X		;Get the object's dynamic data.
F7EF	AA		TAX
F7F0	B5,04		LDA &04,X		;Get object's state.
F7F2	C9,00		CMP #&00		;Is it in state 00 (normal #1)
F7F4	D0,58		BNE &F84E		;Branch if not.

;Dragon Normal (State 1)
F7F6	AD,82,02	LDA &0282		;Read console switches.
F7F9	29,80		AND #&80		;Check for P1 difficulty.
F7FB	F0,05		BEQ &F802		;If Amateur branch.

F7FD	A9,00		LDA #&00		;Set hard - ignore nothing.
F7FF	4C,04,F8	JMP &F804

F802	A9,B6		LDA #&B6		;Set easy - ignore sword.

F804	85,D6		STA &D6			;Store difficulty.
F806	86,D5		STX &D5			;Store dynamic data address.
F808	20,15,F7	JSR &F715

F80B	A5,A0		LDA &A0			;Get object.
F80D	20,E9,F6	JSR &F6E9		;And get the player-ball collision.
F810	F0,20		BEQ &F832		;If none then branch.

F812	AD,82,02	LDA &0282		;Get console switches
F815	2A		ROL A			;Move P0 difficulty to
F816	2A		ROL A			;bit 01 position.
F817	2A		ROL A
F818	29,01		AND #&01		;Mask it out.
F81A	05,DD		ORA &DD			;Merge in the level number.
F81C	A8		TAY			;Create lookup.
F81D	B9,9F,F8	LDA &F89F,Y		;Get new state.
F820	95,04		STA &04,X		;Store as dragon's state (open mouthed).
F822	A5,E3		LDA &E3
F824	95,01		STA &01,X		;Get temp ball X coord and store as dragon's.
F826	A5,E4		LDA &E4
F828	95,02		STA &02,X		;Get temp ball Y coord and store as dragon's.
F82A	A9,01		LDA #&01
F82C	85,E0		STA &E0			;Set noise type 01.
F82E	A9,10		LDA #&10
F830	85,DF		STA &DF			;Set noise count to 10 i.e. make roar noise.

F832	86,9A		STX &9A			;Store the object dynamic data address.
F834	A6,A0		LDX &A0			;Get the object number.
F836	20,FE,F6	JSR &F6FE		;See if another object has hit the dragon.
F839	A6,9A		LDX &9A			;Get the object address.
F83B	C9,51		CMP #&51		;Has the sword hit the dragon.
F83D	D0,0C		BNE &F84B		;If not, branch.

F83F	A9,01		LDA #&01		;Set the state to 01 (Dead)
F841	95,04		STA &04,X
F843	A9,03		LDA #&03		;Set sound three.
F845	85,E0		STA &E0
F847	A9,10		LDA #&10		;Set a noise count of &10.
F849	85,DF		STA &DF

F84B	4C,9E,F8	JMP &F89E		;Jump to finish.

F84E	C9,01		CMP #&01		;Is it in State 01 (Dead)
F850	F0,4C		BEQ &F89E		;Branch if so (Return)

F852	C9,02		CMP #&02		;Is it in State 02 (Normal #2)
F854	D0,1B		BNE &F871		;Branch if not.

;Normal Dragon State 2 (Eaten Ball)
F856	B5,00		LDA &00,X		;Get the dragon's current room.
F858	85,8A		STA &8A			;Store as the ball's current room.
F85A	85,E2		STA &E2			;And previous room.
F85C	B5,01		LDA &01,X		;Get dragon's X coordinate.
F85E	18		CLC
F85F	69,03		ADC #&03		;Adjust.
F861	85,8B		STA &8B			;And store as the ball's X coordinate.
F863	85,E3		STA &E3			;And previous X coordinate.
F865	B5,02		LDA &02,X		;Get the dragon's Y coordinate.
F867	38		SEC
F868	E9,0A		SBC #&0A		;Adjust.
F86A	85,8C		STA &8C			;And store the ball's Y coordinate.
F86C	85,E4		STA &E4			;And the previous Y coordinate.
F86E	4C,9E,F8	JMP &F89E


;Dragon Roaring.
F871	F6,04		INC &04,X		;Increment the dragon's state.
F873	B5,04		LDA &04,X		;Get it's state.
F875	C9,FC		CMP #&FC		;Is it near the end.
F877	90,25		BCC &F89E		;If not, branch.

F879	A5,A0		LDA &A0			;Get the dragon's number.
F87B	20,E9,F6	JSR &F6E9		;Check if the ball is colliding.
F87E	F0,1E		BEQ &F89E		;If not, branch.

F880	A9,02		LDA #&02		;Set state to state 02 : Eaten.
F882	96,04		STA &04,X
F884	A9,02		LDA #&02		;Set noise two.
F886	85,E0		STA &E0
F888	A9,10		LDA #&10		;Set count of noise to &10.
F88A	85,DF		STA &DF
F88C	A9,9B		LDA #&9B		;Get the maximum X coordinate.
F88E	D5,01		CMP #&01,X		;Compare with dragon's X coordinate.
F890	F0,04		BEQ &F896
F892	B0,02		BCS &F896

F894	95,01		STA &01,X		;If too large then use it.

F896	A9,17		LDA #&17		;Set minimum Y coordinate.
F898	D5,02		CMP #&02,X		;Compare with the dragon's Y coordinate.
F89A	90,02		BCC &F89E

F89C	95,02		STA &02,X		;If too small, set as dragon's Y coordinate.

F89E	60		RTS



;Dragon Difficulty.
F89F	D7,EB					;Level 1 : Am,Pro
F8A1	F2,F7					;Level 2 : Am,Pro
F8A3	F2,F7					:Level 3 : Am,Pro



;Move Bat
F8A5	E6,CF		INC &CF			;Put bat in next state.
F8A7	A5,CF		LDA &CF			;Get the bat state.
F8A9	C9,08		CMP #&08		;Has it reached maximum.
F8AB	D0,04		BNE &F8B1

F8AD	A9,00		LDA #&00		;If so, reset the bat state.
F8AF	85,CF		STA &CF

F8B1	A5,D1		LDA &D1			;Get the Bat fed-up value.
F8B3	F0,0E		BEQ &F8C3		;If Bat fed-up then branch.

F8B5	E6,D1		INC &D1			;Increment its value for next time.
F8B7	A5,CE		LDA &CE			;Get the Bat's movement.
F8B9	A2,CB		LDX #&CB		;Position to Bat.
F8BB	A0,04		LDY #&04		;Get the Bat's deltas.
F8BD	20,FF,F5	JSR &F5FF		;Move the Bat.
F8C0	4C,08,F9	JMP &F908		;Update the Bat's object.

;Bat Fed-Up
F8C3	A9,CB		LDA #&CB		;Store bat's dynamic data address.
F8C5	85,D5		STA &D5
F8C7	A9,03		LDA #&03		;Set the bat's delta.
F8C9	85,D4		STA &D4
F8CB	A9,27		LDA #&27		;Set low address of object store.
F8CD	85,D2		STA &D2
F8CF	A9,F9		LDA #&F9		;Set high address of object store.
F8D1	85,D3		STA &D3
F8D3	A5,D0		LDA &D0			;Get object being bat carried.
F8D5	85,D6		STA &D6			;And copy.
F8D7	20,15,F7	JSR &F715		;Move the bat.

F8DA	A4,E1		LDY &E1			;Get object liked index.
F8DC	B1,D2		LDA (&D2),Y		;Look up the object found in the table.
F8DE	F0,28		BEQ &F908		;If nothing found, forget it.

F8E0	C8		INY
F8E1	B1,D2		LDA (&D2),Y		;Get the object wanted.
F8E3	AA		TAX
F8E4	B5,00		LDA &00,X		;Get the object's room.
F8E6	C5,CB		CMP &CB			;Is it the same as the Bats?
F8E8	D0,1E		BNE &F908		;If not, forget it.

;See if Bat can pick up object.
F8EA	B5,01		LDA &01,X		;Get the object's X coordinate.
F8EC	38		SEC
F8ED	E5,CC		SBC &CC			;Find the difference with the bat's
F8EF	18		CLC			;X coordinate.
F8F0	69,04		ADC #&04		;Adjust so Bat in middle of object.
F8F2	29,F8		AND #&F8		;Is Bat within seven pixels?
F8F4	D0,12		BNE &F908		;If not, no pickup possible.

F8F6	B5,02		LDA &02,X		;Get the object's Y coordinate.
F8F8	38		SEC
F8F9	E5,CD		SBC &CD			;Find the difference with the bat's
F8FB	18		CLC			;Y coordinate.
F8FC	69,04		ADC #&04		;Adjust.
F8FE	29,F8		AND #&F8		;Is Bat within seven pixels?
F900	D0,06		BNE &F908		;If not, no pickup possible.

;Got Object
F902	86,D0		STX &D0			;Store object as being carried.
F904	A9,10		LDA #&10		;Reset the bat fed up time.
F906	85,D1		STA &D1

;Move object being bat carried.
F908	A6,D0		LDX &D0			;Get object being bat carried.
F90A	A5,CB		LDA &CB			;Get the Bat's room.
F90C	95,00		STA &00,X		;Store this as the object's room.
F90E	A5,CC		LDA &CC			;Get the Bat's X coordinate.
F910	18		CLC
F911	69,08		ADC #&08		;Adjust to the right.
F913	95,01		STA &01,X		;Make it the object's X coordinate.
F915	A5,CD		LDA &CD			;Get the Bat's Y coordinate.
F917	95,02		STA &02,X		;Store as the object's Y coordinate.
F919	A5,D0		LDA &D0			;Get object being Bat carried.
F91B	A4,9D		LDY &9D			;Get the object being Ball carried.
F91D	D9,44,FF	CMP &FF44,Y		;Are they the same?
F920	D0,04		BNE &F926		;If not, branch.

F922	A9,A2		LDA #&A2		;Set nothing being
F924	85,9D		STA &9D			;carried.

F926	60		RTS



;Bat Object Matrix
F927	CB,B9					;Bat,Chalise
F929	CB,B6					;Bat,Sword
F92B	CB,BC					;Bat,Bridge
F92D	CB,BF					;Bat,Yellow Key
F92F	CB,C2					;Bat,White Key
F931	CB,C5					;Bat,Black Key
F933	CB,A4					;Bat,Red Dragon
F935	CB,A9					;Bat,Yellow Dragon
F937	CB,AE					;Bat,Green Dragon
F939	CB,B3					;Bat,Magnet
F93B	00



;Deal with portcullis and collisions.
F93C	A0,02		LDY #&02		;For each portcullis.
F93E	BE,A7,F9	LDX &F9A7,Y		;Get the portcullises offset number.
F941	20,FE,F6	JSR &F6FE		;See if an object's collided with it.
F944	85,97		STA &97			;Store that object.
F946	D9,AA,F9	CMP &F9AA,Y		;Is it the associated key?
F949	D0,04		BNE &F94F		;If not then branch.

F94B	98		TYA			;Get the portcullis number.
F94C	AA		TAX
F94D	F6,C8		INC &C8,X		;Change it's state to open it.

F94F	98		TYA			;Get the portcullis number.
F950	AA		TAX
F951	B5,C8		LDA &C8,X		;Get it's state.
F953	C9,1C		CMP #&1C		;Is it closed?
F955	F0,31		BEQ &F988		;Yes - then branch.

F957	B9,A7,F9	LDA &F9A7,Y		;Get portcullis number.
F95A	20,E9,F6	JSR &F6E9		;Get the player-ball collision.
F95D	F0,09		BEQ &F968		;If none, then branch.

F95F	A9,01		LDA #&01		;Set the portcullis to closed.
F961	95,C8		STA &C8,X
F963	A2,8A		LDX #&8A		;Set to the castle.
F965	4C,7F,F9	JMP &F97F		;Put ball in castle.

F968	A5,97		LDA &97			;Get the object that's hit the portcullis.
F96A	C9,A2		CMP #&A2		;Is it nothing.
F96C	F0,0E		BEQ &F97C		;If so, branch.

F96E	A6,97		LDX &97			;Get object.
F970	84,9A		STY &9A			;Save Y
F972	20,E4,F2	JSR &F2E4		;And find it's dynamic address.
F975	A4,9A		LDY &9A			;Retrieve Y
F977	A6,93		LDX &93			;Get objects address.
F979	4C,7F,F9	JMP &F97F		;Put object in castle.

F97C	4C,88,F9	JMP &F988

F97F	B9,AD,F9	LDA &F9AD,Y		;Look up castle entry room for this port.
F982	95,00		STA &00,X		;Make it the object's room.
F984	A9,10		LDA #&10		;Give the object a new Y coordinate.
F986	95,02		STA &02,X

F988	98		TYA			;Get portcullis number.
F989	AA		TAX
F98A	B5,C8		LDA &C8,X		;Get it's state.
F98C	C9,01		CMP #&01		;Is it open.
F98E	F0,10		BEQ &F9A0		;Yes - then branch.

F990	C9,1C		CMP #&1C		;Is it closed.
F992	F0,0C		BEQ &F9A0		;Yes - then branch.

F994	F6,C8		INC &C8,X		;Increment it's state.
F996	B5,C8		LDA &C8,X		;Get the state.
F998	C9,38		CMP #&38		;Has it reached maximum state.
F99A	D0,04		BNE &F9A0		;If not, branch.

F99C	A9,01		LDA #&01		;Set to ???closed
F99E	95,C8		STA &C8,X		;state.

F9A0	88		DEY			;Goto the next portcullis.
F9A1	30,03		BMI &F9A6		;Branch if finished.
F9A3	4C,3E,F9	JMP &F93E		;Do next portcullis.
F9A6	60		RTS



;Portcullis #1,#2,#3
F9A7	09,12,1B



;Keys #1 #2 #3 (Yellow,White,Black)
F9AA	63,6C,75		



;Castle Entry Rooms (Yellow,White,Black)
F9AD	12,1A,1B



;Castle Rooms (Yellow,White,Black)
F9B0	11,0F,10



;Deal with Magnet
F9B3	A5,B5		LDA &B5			;Get Magnet's Y coordinate.
F9B5	38		SEC
F9B6	E9,08		SBC #&08		;Adjust to it's 'poles'.
F9B8	85,B5		STA &B5		
F9BA	A9,00		LDA #&00		;Con difficulty!
F9BC	85,D6		STA &D6
F9BE	A9,DA		LDA #&DA		;Set low address of object store.
F9C0	85,D2		STA &D2
F9C2	A9,F9		LDA #&F9		;Set high address of object store.
F9C4	85,D3		STA &D3
F9C6	20,28,F7	JSR &F728		;Get liked object and set movement.
F9C9	A5,9B		LDA &9B			;Get movement.
F9CB	F0,05		BEQ &F9D2		;If none, then forget it.

F9CD	A0,01		LDY #&01		;Set delta to one.
F9CF	20,FF,F5	JSR &F5FF		;Move object.

F9D2	A5,B5		LDA &B5			;Reset the magnet's
F9D4	18		CLC			;Y coordinate.
F9D5	69,08		ADC #&08
F9D7	85,B5		STA &B5
F9D9	60		RTS



;Magnet Object Matrix
F9DA	BF,B3					;Yellow Key,Magnet
F9DC	C2,B3					;White Key,Magnet
F9DE	C5,B3					;Black Key,Magnet
F9E0	B6,B3					;Sword,Magnet
F9E2	BC,B3					;Bridge,Magnet
F9E4	B9,B3					;Chalise,Magnet
F9E6	00



;Deal with invisble surround moving.
F9E7	A5,8A		LDA &8A			;Get the current room.
F9E9	20,71,F2	JSR &F271		;Convert it to an address.
F9EC	A0,02		LDY #&02
F9EE	B1,93		LDA (&93),Y		;Get the room's colour.
F9F0	C9,08		CMP #&08		;Is it invisible.
F9F2	F0,07		BEQ &F9FB		;If so branch.

F9F4	A9,00		LDA #&00		;If not, signal that
F9F6	85,DB		STA &DB			;invisible surround not 
F9F8	4C,22,FA	JMP &FA22		;wanted.

F9FB	A5,8A		LDA &8A			;Get the current room.
F9FD	85,D9		STA &D9			;And store as the invisible surrounds.
F9FF	A5,8B		LDA &8B			;Get the ball's X coordinate.
FA01	38		SEC
FA02	E9,0E		SBC #&0E		;Adjust for surround.
FA04	85,DA		STA &DA			;And store as surround's X coordinate.
FA06	A5,8C		LDA &8C			;Get the ball's Y coordinate.
FA08	18		CLC
FA09	69,0E		ADC #&0E		;Adjust for surround.
FA0B	85,DB		STA &DB			;And store as surround's Y coordinate.
FA0D	A5,DA		LDA &DA			;Get the surround's X coordinate.
FA0F	C9,F0		CMP #&F0		;Is it close to the right edge?
FA11	90,07		BCC &FA1A		;Branch if not.

FA13	A9,01		LDA #&01		;Flick surround to the
FA15	85,DA		STA &DA			;otherside of the screen.
FA17	4C,22,FA	JMP &FA22

FA1A	C9,82		CMP #&82		;???
FA1C	90,04		BCC &FA22		;???

FA1E	A9,81		LDA #&81		;???
FA20	85,DA		STA &DA			;???

FA22	60		RTS



;Make a noise.
FA23	A5,DF		LDA &DF			;Check note count.
FA25	D0,05		BNE &FA2C		;Branch if noise to be made.

FA27	85,19		STA &19			;Turn off the volume.
FA29	85,1A		STA &1A
FA2B	60		RTS

FA2C	C6,DF		DEC &DF			;Goto the next note.
FA2E	A5,E0		LDA &E0			;Get the noise type.
FA30	F0,15		BEQ &FA47		;Game Over

FA32	C9,01		CMP #&01		;Roar
FA34	F0,1F		BEQ &FA55

FA36	C9,02		CMP #&02		;Man eaten.
FA38	F0,32		BEQ &FA6C

FA3A	C9,03		CMP #&03		;Dying dragon.
FA3C	F0,41		BEQ &FA7F

FA3E	C9,04		CMP #&04		;Dropping object.
FA40	F0,4A		BEQ &FA8C	

FA42	C9,05		CMP #&05		;Picking up object.
FA44	F0,55		BEQ &FA9B

FA46	60		RTS



;Noise 0 : Game Over
FA47	A5,DF		LDA &DF
FA49	85,08		STA &08			;Colour-Luminance Playfield
FA4B	85,15		STA &15			;Audio-Control 00
FA4D	4A		LSR A
FA4E	85,19		STA &19			;Audio-Volume 00
FA50	4A		LSR A
FA51	4A		LSR A
FA52	85,17		STA &17			;Audio-Frequency 00
FA54	60		RTS


;Noise 1 : Roar
FA55	A5,DF		LDA &DF			;Get noise count.
FA57	4A		LSR A
FA58	A9,03		LDA #&03		;If it was even then
FA5A	B0,02		BCS &FA5E		;branch.

FA5C	A9,08		LDA #&08		;Set a different audio control value.

FA5E	85,15		STA &15			;Set audio-control 00.
FA60	A5,DF		LDA &DF			;Set the volume to the noise count.
FA62	85,19		STA &19
FA64	4A		LSR A			;Divide by four.
FA65	4A		LSR A
FA66	18		CLC
FA67	69,1C		ADC #&1C		;Set the frequency.
FA69	85,17		STA &17
FA6B	60		RTS


;Noise 2 : Man Eaten
FA6C	A9,06		LDA #&06
FA6E	85,15		STA &15			;Audio-Control 00
FA70	A5,DF		LDA &DF
FA72	49,0F		EOR #&0F
FA74	85,17		STA &17			;Audio-Frequency 00
FA76	A5,DF		LDA &DF
FA78	4A		LSR A
FA79	18		CLC
FA7A	69,08		ADC #&08
FA7C	85,19		STA &19			;Audio-Volume 00
FA7E	60		RTS




;Noise 3 : Dying Dragon
FA7F	A9,04		LDA #&04		;Set the Audio-Control
FA81	85,15		STA &15	
FA83	A5,DF		LDA &DF			;Put the note count in
FA85	85,19		STA &19			;the volume.
FA87	49,1F		EOR #&1F
FA89	85,17		STA &17			;Flip the count and store
FA8B	60		RTS			;as the frequency.




;Noise 4 : Dropping object.
FA8C	A5,DF		LDA &DF			;Get note count.
FA8E	49,03		EOR #&03		;Reverse it as noise does up.
FA90	85,17		STA &17			;Store in frequency for channel 00.
FA92	A9,05		LDA #&05
FA94	85,19		STA &19			;Set volume on channel 00.
FA96	A9,06		LDA #&06
FA98	85,15		STA &15			;Set a noise on channel 00.
FA9A	60		RTS



;Noise 5 : Pickup up an object.
FA9B	A5,DF		LDA &DF			;Get note count.
FA9D	4C,90,FA	JMP &FA90		;And make same noise as drop.



;Left Of Name Room
FAA0	F0,FF,FF	XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRRRRRR
FAA3	00,00,00
FAA6	00,00,00
FAA9	00,00,00
FAAC	00,00,00
FAAF	00,00,00
FAB2*	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRRRRRR



;Below Yellow Castle
FAB2*	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRRRRRR
FAB5	00,00,00
FAB8	00,00,00
FABB	00,00,00
FABE	00,00,00
FAC1	00,00,00
FAC4	F0,FF,FF	XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRRRRRR



;Side corridore
FAC7	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR
FACA	00,00,00
FACD	00,00,00
FAD0	00,00,00
FAD3	00,00,00
FAD6	00,00,00
FAD9	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR



;Number Room Defn
FADC	F0,FF,FF        XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR		
FADF	30,00,00        XX                                    RR
FAE2	30,00,00        XX                                    RR
FAE5	30,00,00        XX                                    RR
FAE8	30,00,00        XX                                    RR
FAEB	30,00,00        XX                                    RR
FAEE	F0,FF,0F        XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR



;Object #1 States (Porcullis)
FAF1	04,24,FB		;State 04 at FB24	;Open
FAF4	08,22,FB		;State 08 at FB22
FAF7	0C,20,FB		;State 0C at FB20
FAFA	10,1E,FB		;State 10 at FB1E
FAFD	14,1C,FB		;State 14 at FB1C
FB00	18,1A,FB		;State 18 at FB1A
FB03	1C,18,FB		;State 1C at FB18	;Closed
FB06	20,1A,FB		;State 20 at FB1A
FB09	24,1C,FB		;State 24 at FB1C
FB0C	28,1E,FB		;State 28 at FB1E
FB0F	2C,20,FB		;State 2C at FB20
FB12	30,22,FB		;State 30 at FB22
FB15	FF,24,FB		;State FF at FB24	;Open



;Object #1 States 04-FF (Graphic)
FB18	FE		XXXXXXX 
FB19	AA		X X X X
FB1A	FE		XXXXXXX
FB1B	AA		X X X X
FB1C	FE		XXXXXXX
FB1D	AA		X X X X
FB1E	FE		XXXXXXX
FB1F	AA		X X X X
FB20	FE		XXXXXXX
FB21	AA		X X X X
FB22	FE		XXXXXXX
FB23	AA		X X X X
FB24	FE		XXXXXXX
FB25	AA		X X X X
FB26	FE		XXXXXXX
FB27	AA		X X X X
FB28	00



;Two Exit Room
FB29	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR
	30,00,00	XX                                    RR
	30,00,00	XX                                    RR
	30,00,00	XX                                    RR
	30,00,00	XX                                    RR
	30,00,00	XX                                    RR
	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR



;Top of Blue Maze
FB3E	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR
FB41	00,0C,0C                XX    XX        RR    RR 
FB44	F0,0C,3C	XXXX    XX    XXXX    RRRR    RR    RRRR
FB47	F0,0C,00	XXXX    XX                    RR    RRRR
FB4A	F0,FF,3F	XXXXXXXXXXXXXXXXXX    RRRRRRRRRRRRRRRRRR
FB4D	00,30,30              XX        XX    RR        RR
FB50	F0,33,3F	XXXX  XX  XXXXXXXX    RRRRRRRR  RR  RRRR



;Blue Maze #1
FB53	F0,FF,FF	XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR
FB56	00,00,00
FB59	F0,FC,FF	XXXXXXXXXX  XXXXXXXXRRRRRRRR  RRRRRRRRRR
FB5C	F0,00,C0	XXXX              XXRR              RRRR
FB5F	F0,3F,CF	XXXX  XXXXXXXXXX  XXRR  RRRRRRRRRR  RRRR
FB62	00,30,CC              XX      XX  XXRR  RR      RR 
FB65	F0,F3,CC	XXXXXXXX  XX  XX  XXRR  RR  RR  RRRRRRRR



;Bottom Of Blue Maze
FB68	F0,F3,0C	XXXXXXXX  XX  XX        RR  RR  RRRRRRRR
FB6B	00,30,0C              XX      XX        RR      RR
FB6E	F0,3F,0F	XXXX  XXXXXXXXXX        RRRRRRRRRR  RRRR
FB71	F0,00,00	XXXX                                RRRR
FB74	F0,F0,00	XXXXXXXX                        RRRRRRRR
FB77	00,30,00              XX                        RR
FB7A	F0,FF,FF	XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR



;Centre of Blue Maze
FB7D	F0,33,3F	XXXX  XX  XXXXXXXX    RRRRRRRR  RR  RRRR
FB80	00,30,3C              XX      XXXX    RRRR      RR
FB83	F0,FF,3C	XXXXXXXXXXXX  XXXX    RRRR  RRRRRRRRRRRR
FB86	00,03,3C                  XX  XXXX    RRRR  RR
FB89	F0,33,3C	XXXX  XX  XX  XXXX    RRRR  RR  RR  RRRR
FB8C	00,33,0C              XX  XX  XX        RR  RR  RR
FB8F	F0,F3,0C	XXXXXXXX  XX  XX        RR  RR  RRRRRRRR



;Blue Maze Entry
FB92	F0,F3,CC	XXXXXXXX  XX  XX  XXRR  RR  RR  RRRRRRRR
FB95	00,33,0C              XX  XX  XX        RR  RR  RR
FB98	F0,33,FC	XXXX  XX  XX  XXXXXXRRRRRR  RR  RR  RRRR
FB9B	00,33,00              XX  XX                RR  RR
FB9E	F0,F3,FF	XXXXXXXX  XXXXXXXXXXRRRRRRRRRR  RRRRRRRR
FBA1	00,00,00
FBA4	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR



;Maze Middle
FBA7	F0,FF,CC	XXXXXXXXXXXX  XX  XXRR  RR  RRRRRRRRRRRR
FBAA	00,00,CC                      XX  XXRR  RR
FBAD	F0,03,CF	XXXX      XXXXXX  XXRR  RRRRRR      RRRR
FBB0	00,03,00                  XX                RR
FBB3	F0,F3,FC	XXXXXXXX  XX  XXXXXXRRRRRR  RR  RRRRRRRR		; edited by MP
FBB6	00,33,0C              XX  XX  XX        RR  RR  RR
FBB9*	F0,33,CC	XXXX  XX  XX  XX  XXRR  RR  RR  RR  RRRR



;Maze Side
FBB9*	F0,33,CC	XXXX  XX  XX  XX  XXRR  RR  RR  RR  RRRR
FBBC	00,30,CC	      XX      XX  XXRR  RR      RR
FBBF	00,3F,CC              XXXXXX  XX  XXRR  RR  RRRRRR
FBC2	00,00,C0			  XXRR
FBC5	00,3F,C3	      XXXXXXXX    XXRR    RRRRRRRR
FBC8	00,30,C0	      XX          XXRR          RR
FBCB	F0,FF,FF	XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR



;Maze Entry
FBCE	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR
FBD1	00,30,00	      XX                        RR
FBD4	F0,30,FF	XXXX  XX    XXXXXXXXRRRRRRRRR   RR  RRRR
FBD7	00,30,C0              XX          XXRR          RR
FBDA	F0,F3,C0	XXXXXXXX  XX      XXRR      RR  RRRRRRRR
FBDD	00,03,C0                  XX      XXRR      RR         
FBE0	F0,FF,CC	XXXXXXXXXXXX  XX  XXRR  RR  RRRRRRRRRRRR



;Caste Definition
FBE3	F0,FE,15	XXXXXXXXXXX X X X      R R R RRRRRRRRRRR
FBE6	30,03,1F	XX        XXXXXXX      RRRRRRR        RR
FBE9	30,03,FF	XX        XXXXXXXXXXRRRRRRRRRR        RR
FBEC	30,00,FF	XX          XXXXXXXXRRRRRRRR          RR
FBEF	30,00,3F	XX          XXXXXX    RRRRRR          RR
FBF2	30,00,00	XX                                    RR
FBF5	F0,FF,0F	XXXXXXXXXXXXXXXX            RRRRRRRRRRRR



;Object Data
;Offset 0 : Room number of object.
;Offset 1 : X coordinate of object.
;Offset 2 : Y coordinate of object.



;Object #1 : Portcullis
FBF8	11,4D,31		;Room 11,(4D,31)



;Object #2 : Portcullis
FBFB	0F,4D,31		;Room 0F,(4D,31)



;Object #3 : Portcullis
FBFE	10,4D,31		;Room 10,(4D,31)



;Object #0 : State
FC01	00



;Object #1 : State List
FC02	FF,05,FC		;State FF at FC05



;Object #1 : Graphic
FC05	FF		XXXXXXXX
FC06	FF		XXXXXXXX
FC07	FF		XXXXXXXX
FC08	FF		XXXXXXXX
FC09	FF		XXXXXXXX
FC0A	FF		XXXXXXXX
FC0B	FF		XXXXXXXX
FC0C	FF		XXXXXXXX
FC0D	FF		XXXXXXXX
FC0E	FF		XXXXXXXX
FC0F	FF		XXXXXXXX
FC10	FF		XXXXXXXX
FC11	FF		XXXXXXXX
FC12	FF		XXXXXXXX
FC13	FF		XXXXXXXX
FC14	FF		XXXXXXXX
FC15	FF		XXXXXXXX
FC16	FF		XXXXXXXX
FC17	FF		XXXXXXXX
FC18	FF		XXXXXXXX
FC19	FF		XXXXXXXX
FC1A	FF		XXXXXXXX
FC1B	FF		XXXXXXXX
FC1C	FF		XXXXXXXX
FC1D	FF		XXXXXXXX
FC1E	FF		XXXXXXXX
FC1F	FF		XXXXXXXX
FC20	FF		XXXXXXXX
FC21	FF		XXXXXXXX
FC22	FF		XXXXXXXX
FC23	FF		XXXXXXXX
FC24	FF		XXXXXXXX
FC25	00



;Red Maze #1
FC26	F0,FF,FF	XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR
FC29	00,00,00
FC2C	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR
FC2F	00,00,0C                      XX        RR
FC32	F0,FF,0C	XXXXXXXXXXXX  XX        RR  RRRRRRRRRRRR
FC35	F0,03,CC	XXXX      XX  XX  XXRR  RR  RR      RRRR
FC38*	F0,33,CF	XXXX  XX  XXXXXX  XXRR  RRRRRR  RR  RRRR



;Bottom Of Red Maze
FC38	F0,33,CF	XXXX  XX  XXXXXX  XXRR  RRRRRR  RR  RRRR
FC3B	F0,30,00	XXXX  XX                        RR  RRRR
FC3E	F0,33,FF	XXXX  XX  XXXXXXXXXXRRRRRRRRRR  RR  RRRR
FC41	00,33,00	      XX  XX                RR  RR  RRRR
FC44	F0,FF,00	XXXXXXXXXXXX                RRRRRRRRRRRR
FC47	00,00,00
FC4A	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR



;Top Of Red Maze
FC4D	F0,FF,FF	XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR
FC50	00,00,C0                          XXRR
FC53	F0,FF,CF	XXXXXXXXXXXXXXXX  XXRR  RRRRRRRRRRRRRRRR
FC56	00,00,CC                      XX  XXRR  RR
FC59	F0,33,FF	XXXX  XX  XXXXXXXXXXRRRRRRRRRR  RR  RRRR
FC5C	F0,33,00	XXXX  XX  XX                RR  RR  RRRR
FC5F*	F0,3F,0C	XXXX  XXXXXX  XX        RR  RRRRRR  RRRR



;White castle entry
FC5F*	F0,3F,0C	XXXX  XXXXXX  XX        RR  RRRRRR  RRRR
FC62	F0,00,0C	XXXX          XX        RR          RRRR
FC65	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR
FC68	00,30,00              XX                        RR
FC6B	F0,30,00	XXXX  XX                        RR  RRRR
FC6E	00,30,00              XX                        RR
FC71	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR



;Top Entry Room
FC74	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR
FC77	30,00,00	XX                                    RR
FC7A	30,00,00	XX                                    RR
FC7D	30,00,00	XX                                    RR
FC80	30,00,00	XX                                    RR
FC83	30,00,00	XX                                    RR
FC86	F0,FF,FF	XXXXXXXXXXXXXXXXXXXXRRRRRRRRRRRRRRRRRRRR



;Black Maze #1
FC89	F0,F0,FF	XXXXXXXX    XXXXXXXXRRRRRRRR    RRRRRRRR
FC8C	00,00,03	            XX            RR
FC8F	F0,FF,03	XXXXXXXXXXXXXX            RRRRRRRRRRRRRR
FC92	00,00,00
FC95	30,3F,FF	XX    XXXXXXXXXXXXXXRRRRRRRRRRRRRR    RR
FC98	00,30,00              XX                        RR
FC9B*	F0,F0,FF	XXXXXXXX    XXXXXXXXRRRRRRRR    RRRRRRRR



;Black Maze #3
FC9B*	F0,F0,FF	XXXXXXXX    XXXXXXXXMMMMMMMM    MMMMMMMM
FC9E	30,00,00	XX                  MM
FCA1	30,3F,FF	XX    XXXXXXXXXXXXXXMM    MMMMMMMMMMMMMM
FCA4	00,30,00	      XX                  MM
FCA7	F0,F0,FF	XXXXXXXX    XXXXXXXXMMMMMMMM    MMMMMMMM
FCAA	30,00,03	XX          XX      MM          MM
FCAD	F0,F0,FF	XXXXXXXX    XXXXXXXXMMMMMMMM    MMMMMMMM



;Black Maze #2
FCB0	F0,FF,FF	XXXXXXXXXXXXXXXXXXXXMMMMMMMMMMMMMMMMMMMM
FCB3	00,00,C0                          XX                  MM
FCB6	F0,FF,CF	XXXXXXXXXXXXXXXX  XXMMMMMMMMMMMMMMMM  MM
FCB9	00,00,0C                      XX                  MM
FCBC	F0,0F,FF	XXXX    XXXXXXXXXXXXMMMM    MMMMMMMMMMMM
FCBF	00,0F,C0	        XXXX      XX        MMMM      MM
FCC2*	30,CF,CC	XX  XX  XXXX  XX  XXMM  MM  MMMM  MM  MM



;Black Maze Entry
FCC2*	30,CF,CC	XX  XX  XXXX  XX  XXRR  RR  RRRR  RR  RR
FCC5	00,C0,CC            XX        XX  XXRR  RR        RR
FCC8	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR
FCCB	00,00,00
FCCE	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR
FCD1	00,00,00
FCD4	F0,FF,0F	XXXXXXXXXXXXXXXX        RRRRRRRRRRRRRRRR



;Object #0A : State
FCD7	00



;Object #0A : List of States
FCD8	FF,DB,FC			;State FF at &FCDB



;Object #0A: State FF : Graphic
FCDB	C3		XX    XX
FCDC	C3		XX    XX
FCDD	C3		XX    XX
FCDE	C3		XX    XX
FCDF	42		 X    X
FCE0	42		 X    X
FCE1	42		 X    X
FCE2	42		 X    X
FCE3	42		 X    X
FCE4	42		 X    X
FCE5	42		 X    X
FCE6	42		 X    X
FCE7	42		 X    X
FCE8	42		 X    X
FCE9	42		 X    X
FCEA	42		 X    X
FCEB	42		 X    X
FCEC	42		 X    X
FCED	42		 X    X
FCEE	42		 X    X
FCEF	C3		XX    XX
FCF0	C3		XX    XX
FCF1	C3		XX    XX
FCF2	C3		XX    XX
FCF3	00



;Object #5 State #1 Graphic :'1'
FCF4	04	  	     X
FCF5	0C		    XX
FCF6	04		     X
FCF7	04		     X
FCF8	04		     X
FCF9	04		     X
FCFA	0E		    XXX
FCFB	00



;Object #0B : State
FCFC	00



;Object #0B : List Of States
FCFD	FF,00,FD			;State FF at FD00



;Object #0B : State FF : Graphic
FD00 	07		     XXX
FD01	FD		XXXXXX X
FD02	A7		X X  XXX
FD03	00



;Object #5 State #2 Graphic :'2'
FD04	0E		    XXX
FD05	11		   X   X			  
FD06	01		       X
FD07	02		      X
FD08	04		     X
FD09	08		    X
FD0A	1F		   XXXXX
FD0B	00



;Object #5 State #3 Graphic :'3'
FD0C	0E		    XXX
FD0D	11		   X   X
FD0E	01		       X
FD0F	06		     XX
FD10	01		       X
FD11	11		   X   X
FD12	0E		    XXX
FD13	00



;Object #0E : List Of States
FD14	03,1A,FD		;State 03 at &FD1A
FD17	FF,22,FD		;State FF at &FD22



;Object #0E : State 03 : Graphic
FD1A	81		X      X
FD1B	81		X      X
FD1C	C3		XX    XX
FD1D	C3		XX    XX
FD1E	FF		XXXXXXXX
FD1F	5A		 X XX X
FD20	66		 XX  XX
FD21	00



;Object #0E : State FF : Graphic
FD22	01		       X
FD23	80		X
FD24	01		       X
FD25	80		X
FD26	3C		  XXXX
FD27	5A		 X XX X
FD28	66		 XX  XX
FD29	C3		XX    XX
FD2A	81		X      X
FD2B	81		X      X
FD2C	81		X      X
FD2D	00



;Object #6 : States
FD2E	00,3A,FD		;State 00 at &FD3A
FD31	01,66,FD		;State 01 at &FD66
FD34	02,3A,FD		;State 02 at &FD3A
FD37	FF,4F,FD		;State FF at &FD4F



;Object #6 : State #00 : Graphic
FD3A	06		     XX
FD3B	0F		    XXXX
FD3C	F3		XXXX  XX
FD3D	FE		XXXXXXX
FD3E	0E		    XXX
FD3F	04		     X
FD40	04		     X
FD41	1E		   XXXX
FD42	3F		  XXXXXX
FD43	7F		 XXXXXXX
FD44	E3		XXX   XX
FD45	C3		XX    XX
FD46	C3		XX    XX
FD47	C7		XX   XXX
FD48	FF		XXXXXXXX
FD49	3C		  XXXX
FD4A	08		    X
FD4B	8F		X   XXXX
FD4C	E1		XXX    X
FD4D	3F		  XXXXXX
FD4E	00



;Object 6 : State FF : Graphic
FD4F	80		X
FD50	40		 X
FD51	26		  X  XX
FD52	1F		   XXXXX
FD53	0B		    X XX
FD54	0E		    XXX
FD55	1E		   XXXX
FD56	24		  X  X
FD57	44		 X   X
FD58	8E		X   XXX
FD59	1E		   XXXX
FD5A	3F		  XXXXXX
FD5B	7F		 XXXXXXX
FD5C	7F		 XXXXXXX
FD5D	7F		 XXXXXXX
FD5E	7F		 XXXXXXX
FD5F	3E		  XXXXX
FD60	1C		   XXX
FD61	08		    X
FD62	F8		XXXXX
FD63	80		X
FD64	E0		XXX
FD65	00	



;Object 6 : State 02 : Graphic
FD66	0C		    XX
FD67	0C		    XX
FD68	0C		    XX
FD69	0E		    XXX
FD6A	1B		   XX X
FD6B	7F		 XXXXXXX
FD6C	CE		XX  XXX
FD6D	80		X
FD6E	FC		XXXXXX
FD6F	FE		XXXXXXX
FD70	FE		XXXXXXX
FD71	7E		 XXXXXX
FD72	78		 XXXX
FD73	20		  X
FD74	6E		 XX XXX
FD75	42		 X    X
FD76	7E		 XXXXXX
FD77	00



;Object #9 : State
FD78	00



;Object #9 : List of States
FD79	FF,7C,FD			;State FF at &FD7C



;Object #9 : State FF : Graphic
FD7C	20	 	  X
FD7D	40		 X
FD7E	FF		XXXXXXXX
FD7F	40		 X
FD80	20		  X
FD81	00



;Object #0F : State
FD82	00



;Object #0F : List Of States
FD83	FF,86,FD			;State FF at FD86



;Object #0F : State FF : Graphic
FD86	80		X
	00



;Object #4 : State FF : Graphic
FD88	F0		XXXX
FD89	80		X
FD8A	80		X
FD8B	80		X
FD8C	F4		XXXX X
FD8D	04		     X
FD8E	87		X    XXX
FD8F	E5		XXX  X X
FD90	87		X    XXX
FD91	80		X
FD92	05		     X X
FD93	E5		XXX  X X
FD94	A7		X X  XXX
FD95	E1		XXX    X
FD96	87		X    XXX
FD97	E0		XXX
FD98	01		       X
FD99	E0		XXX
FD9A	A0		X X
FD9B	F0		XXXX
FD9C	01		       X
FD9D	40		 X
FD9E	E0		XXX
FD9F	40		 X
FDA0	40		 X
FDA1	40		 X
FDA2	01		       X
FDA3	E0		XXX
FDA4	A0		X X
FDA5	E0		XXX
FDA6	80		X
FDA7	E0		XXX
FDA8	01		       X
FDA9	20		  X
FDAA	20		  X
FDAB	E0		XXX
FDAC	A0		X X
FDAD	E0		XXX
FDAE	01		       X
FDAF	01		       X
FDB0	01		       X
FDB1	11		   X   X
FDB2	A8		X X X
FDB3	A8		X X X
FDB4	A8		X X X
FDB5	F8		XXXXX
FDB6	01		       X
FDB7	E0		XXX
FDB8	A0		X X
FDB9	F0		XXXX
FDBA	01		       X
FDBB	80		X
FDBC	E0		XXX
FDBD	8F		X   XXXX
FDBE	89		X   X  X
FDBF	0F		    XXXX
FDC0	8A		X   X X
FDC1	E9		XXX X  X
FDC2	80		X
FDC3	8E		X   XXX
FDC4	0A		    X X
FDC5	EE		XXX XXX
FDC6	A0		X X
FDC7	E8		XXX X
FDC8	88		X   X
FDC9	EE		XXX XXX
FDCA	0A		    X X
FDCB	8E		X   XXX
FDCC	E0		XXX
FDCD	A4		X X  X
FDCE	A4		X X  X
FDCF	04		     X
FDD0	80		X
FDD1	08		    X
FDD2	0E		    XXX
FDD3	0A		    X X
FDD4	0A		    X X
FDD5	80		X
FDD6	0E		    XXX
FDD7	0A		    X X
FDD8	0E		    XXX
FDD9	08		    X
FDDA	0E		    XXX
FDDB	80		X
FDDC	04		     X
FDDD	0E		    XXX
FDDE	04		     X
FDDF	04		     X
FDE0	04		     X
FDE1	80        	X
FDE2	04		     X
FDE3	0E		    XXX
FDE4	04		     X
FDE5	04		     X
FDE6	04		     X
FDE7	00



;Object #4 : Author's name
FDE8	1E,50,69		;Room 1E,(50,69)



;Object #4 : Current State
FDEB	00



;Object #4 : States
FDEC	FF,88,FD		;State FF at FD88



;Object #10 : State	
FDEF	00



;Object #10 : List Of States
FDF0	FF,F3,FD			;State FF at &FDF3



;Object #10 : State FF : Graphic
FDF3	81		X      X
FDF4	81		X      X
FDF5	C3		XX    XX
FDF6	7E		 XXXXXX
FDF7	7E		 XXXXXX
FDF8	3C		  XXXX
FDF9	18		   XX
FDFA	18		   XX
FDFB	7E		 XXXXXX
FDFC	00



;Object #12 : State
FDFD	00



;Object #12 : List of States
FDFE	FF,01,FE



;Object #12 : State FF : Graphic
FE01	00



;Object #5 Number.
FE02	00,50,40			;#5 Number: Room 00,(50,40)



;Object #5 States.
FE05	01,F4,FC			;State 1 at FCF4
FE08	03,04,FD			;State 3 at FD04
FE0B	FF,0C,FD			;State FF at FD0C



;Object #11 : State
FE0E	00



;Object #11 : List Of States
FE0F	FF,12,FE			;State FF at FE12



;Object #11 : State FF : Graphic
FE12	3C		  XXXX
FE13	7E		 XXXXXX
FE14	E7		XXX  XXX
FE15	C3		XX    XX
FE16	C3		XX    XX
FE17	C3		XX    XX
FE18	C3		XX    XX
FE19	C3		XX    XX
FE1A	00



;Room Data
;Offset 0 : Low byte room graphics data
;Offset 1 : High byte room graphics data
;Offset 2 : Colour
;Offset 3 : B&W colour
;Offset 4 : Bits 5-0 : Playfield control
	    Bit 6    : True if right thin wall wanted
	    Bit 7    : True if left thin wall wanted
;Offset 5 : Room Above
;Offset 6 : Room Left
;Offset 7 : Room Down
;Offset 8 : Room Right

FE1B	DC,FA,86,0A,21,00,00,00,00	;00; 'Number' room.	Purple		Reflected/8 Clock Ball
FE24	B2,FA,38,0A,A1,08,02,80,03	;01; (Top Access)			Reflected/8 Clock Ball
FE2D	B2,FA,58,0A,21,11,03,83,01	;02; (Top Access)	Green
FE36	A0,FA,C8,0A,61,06,01,86,02	;03; Left of Name
FE3F	3E,FB,D6,0A,21,10,05,07,06	;04; Top of Blue Maze	Blue
FE48	53,FB,D6,0A,21,1D,06,08,04	;05; Blue Maze #1	Blue
FE51	68,FB,D6,0A,21,07,04,03,05	;06; Bottom of Blue MazeBlue
FE5A	7D,FB,D6,0A,21,04,08,06,08	;07; Centre of Blue MazeBlue
FE63	92,FB,D6,0A,21,05,07,01,07	;08; Blue Maze Entry	Blue
FE6C	A7,FB,08,08,25,0A,0A,0B,0A	;09; Maze Middle	Invisible	Reflected/Playfield Priority
FE75	CE,FB,08,08,25,03,09,09,09	;0A; Maze Entry		Invisible	Reflected/Playfield Priority
FE7E	B9,FB,08,08,25,09,0C,1C,0D	;0B; Maze Side		Invisible	Reflected/Playfield Priority
FE87	C7,FA,B8,0A,61,1C,0D,1D,0B	;0C; (Side corridore)
FE90	C7,FA,78,0A,A1,0F,0B,0E,0C	;0D; (Side corridore)
FE99	74,FC,98,0A,21,0D,10,0F,10	;0E; (Top Entry Room)
FEA2	E3,FB,0C,0C,21,0E,0F,0D,0F	;0F White Castle	White
FEAB	E3,FB,00,02,21,01,1C,04,1C	;10 Black Castle	Black	
FEB4	E3,FB,2A,0A,21,06,03,02,01	;11 Yellow Castle	Yellow
FEBD	DC,FA,2A,0A,21,12,12,12,12	;12 Yellow Castle Entry	Yellow
FEC6	89,FC,08,08,25,15,14,15,16	;13 Black Maze #1	Invisible	Reflected/Playfield Priority
FECF	B0,FC,08,08,24,16,15,16,13	;14 Black Maze #2	Invisible	Duplicate/Playfield Priority
FED8	9B,FC,08,08,24,13,16,13,14	;15 Black Maze #3	Invisible	Duplicate/Playfield Priority
FEE1	C2,FC,08,08,25,14,13,1B,15	;16 Black Maze Entry	Invisible	Reflected/Playfield Priority
FEEA	26,FC,66,0A,21,19,18,19,18	;17 (Red Maze #1)	Red
FEF3	4D,FC,66,0A,21,1A,17,1A,17	;18 Top Of Red Maze	Red
FEFC	38,FC,66,0A,21,17,1A,17,1A	;19 Bottom Of Red Maze	Red
FF05	5F,FC,66,0A,21,18,19,18,19	;1A; White Castle Entry	Red
FF0E	29,FB,66,0A,21,89,89,89,89	;1B; Black Castle Entry	Red
FF17	DC,FA,86,0A,21,1D,07,8C,08	;1C; Other purple room	Purple
FF20	74,FC,66,0A,21,8F,01,10,03	;1D; (Top Entry Room)	Red
FF29	B2,FA,86,0A,21,06,01,06,03	;1E; Name Room		Purple



;Room differences for different levels (level 1, 2, 3)
FF32	10,0F,0F		;Down from Room 01
FF35	05,11,11		;Down from Room 02
FF38	1D,0A,0A		;Down from Room 03
FF3B	1C,16,16		;U/L/R/D from Room 1B (Black castle room)
FF3E	1B,0C,0C                ;Down from Room 1C
FF41	03,0C,0C		;Up from Room 1D  (top entry room)



;Objects
;Offset 0 : Low byte object information (moveable stuff)
;Offset 1 : High byte object information (moveable stuff)
;Offset 2 : Low byte to object's current state
;Offset 3 : High byte to object's current state
;Offset 4 : Low byte list of states
;Offset 5 : High byte list of states
;Offset 6 : Colour
;Offset 7 : Colour in B&W.
;Offset 8 : Size of object

FF44	D9,00,01,FC,02,FC,28,0C,07	00	;#0  Invisible surround
FF4D	F8,FB,C8,00,F1,FA,00,00,00	09	;#1  Portcullis #1	Black
FF56	FB,FB,C9,00,F1,FA,00,00,00	12	;#2  Portcullis #2	Black
FF5F	FE,FB,CA,00,F1,FA,00,00,00	1B	;#3  Portcullis #3	Black
FF68	E8,FD,EB,FD,EC,FD,CB,00,00	24	;#4  Name		Flash
FF71	02,FE,DD,00,05,FE,C8,00,00	2D	;#5  Number		Green
FF7A	A4,00,A8,00,2E,FD,36,0E,00	36	;#6  Dragon #1		Red
FF83	A9,00,AD,00,2E,FD,1A,06,00	3F	;#7  Dragon #2		Yellow
FF8C	AE,00,B2,00,2E,FD,C8,00,00	48	;#8  Dragon #3		Green
FF95	B6,00,78,FD,79,FD,1A,06,00	51	;#9  Sword		Yellow
FF9E	BC,00,D7,FC,D8,FC,66,02,07	5A	;#0A Bridge		Purple
FFA7	BF,00,FC,FC,FD,FC,1A,06,00	63	;#0B Key #01		Yellow
FFB0	C2,00,FC,FC,FD,FC,0E,0E,00	6C	;#0C Key #02		White
FFB9	C5,00,FC,FC,FD,FC,00,00,00	75	;#0D Key #03		Black
FFC2	CB,00,CF,00,14,FD,00,00,00	7E	;#0E Bat		Black
FFCB	A1,00,82,FD,83,FD,08,08,00	87	;#0F Black Dot		Light gray
FFD4	B9,00,EF,FD,F0,FD,CB,06,00	90	;#10 Chalise		Flash
FFDD	B3,00,0E,FE,0F,FE,00,06,00	99	;#11 Magnet		Black
FFE6	BC,00,FD,FD,FE,FD,00,00,00	A2	;#12 Null		Black



;Not Used
FFEF	00,00,00,00,00,00,00,00,00,00



;6502 Vectors (Not Used?)
FFFA	00,F0					;NMI
FFFC	00,F0					;Reset
FFFE	00,F0					;IRQ





 


Home