view dod.s @ 8:7599c6d44eb5

Identified several more SWI routines and commented them. Identified serveral SWI routines and identified them: 1 and 11h through 15h Also added some useful names on several veriables.
author William Astle <lost@l-w.ca>
date Sun, 26 May 2013 12:43:36 -0600
parents c7e6b6318fea
children b0415d785676
line wrap: on
line source
; Dungeons of Daggorath
;
; Original game copyright © 1982 by Dyna Micro
;
; The code contained in this file is not the original source code to Dungeons of Daggorath. It was
; constructed by William Astle in 2013 by disassembling the Dungeons of Daggorath ROM.
;
; According to a web page retrieved from http://frodpod.tripod.com/lisence.html on May 24, 2013,
; this endeavour is permitted. In case the web page becomes unavailable, and because it contains what
; I believe to be important credit information, I have reproduced the text of it below:
;
;***********************************************************************************************************
;* Grant of license to reproduce Dungeons of Daggorath
;*
;* My name is Douglas J. Morgan.  I was the president of DynaMicro, Inc. (since dissolved), the company
;* which conceived, created and wrote Dungeons of Daggorath, a best selling Radio Shack Color Computer
;* adventure game. 
;*
;* I have examined the contract I signed with Radio Shack for their license of the game.  The contract
;* provides that Radio Shack shall have an exclusive license to manufacture and produce the game, but
;* that said exclusive license shall revert to a non-exclusive license should Radio Shack cease to
;* produce and sell the game.  To the best of my knowledge, they have not produced the game for many
;* years.  Thus, it is my belief that the right to grant a license for the game has reverted to me. 
;*
;* I hereby grant a non-exclusive permanent world-wide license to any and all Color Computer site
;* administrators, emulator developers, programmers or any other person or persons who wish to develop,
;* produce, duplicate, emulate, or distribute the game on the sole condition that they exercise every
;* effort to preserve the game insofar as possible in its original and unaltered form. 
;*
;* The game was a labor of love.  Additional credits to Phillip C. Landmeier - who was my partner and
;* who originally conceived the vision of the game and was responsible for the (then) state of the art
;* sounds and realism, to April Landmeier, his wife - the artist who drew all the creatures as well as
;* all the artwork for the manual and game cover, and to Keith Kiyohara - a gifted programmer who helped
;* write the original game and then contributed greatly to compressing a 16K game into 8K so that it
;* could be carried and produced by Radio Shack.
;*
;* The game did very well for us.  I give it to the world with thanks to all who bought it, played it
;* or enjoyed it. 
;*
;* There is one existing copy of the original source code.  Anyone willing to pay for the copying of
;* the listing (at Kinko's) and shipment to them, who intends to use it to enhance or improve the emulator
;* versions of the game is welcome to it. 
;*
;* Verification of this license grant or requests for the listing can be made by contacting Louis Jordan,
;* Thank you.
;***********************************************************************************************************
;
; Louis Jordan's email address is given as louisgjordan@yahoo.com in a hyperlink in the above statement.
;
; It is my belief that this endeavor to disassemble Dungeons of Daggorath is in compliance with the above
; license grant. I have done so for my own amusement and for the challenge. I have also done so because
; I failed to elicit a response from Louis Jordan as described in the license grant. I am not surprised
; that I received no reply given that the page above was put online during or prior to 2006.

; some utility macros
dod		macro noexpand
		swi
		fcb \1
		ifeq \1-$1B
		fcb \2
		endc
		endm

skip2		macro noexpand
		fcb $8c
		endm


; macros for color basic ROM calls
romcall		macro noexpand
		swi2
		fcb \1
		endm

; draw a graphic with graphic data at (X)
drawgraphic	macro noexpand
		dod S01
		endm
; render a packed string (immediate data)
renderstrimmp	macro noexpand
		dod S02
		endm
; render a packed string from (X)
renderstr	macro noexpand
		dod S03
		endm
; render character in A
renderchar	macro noexpand
		dod S04
		endm
; decode a 5 bit packed string from (X) to V335
decodestrsb	macro noexpand
		dod S05
		endm
; decode a 5 bit packed string from (X) to (U)
decodestr	macro noexpand
		dod S06
		endm

; clear graphics screen one; return parameter pointer in U
cleargfx1	macro noexpand
		dod S08
		endm
; clear graphics screen two; return parameter pointer in U
cleargfx2	macro noexpand
		dod S09
		endm
; clear the status line
clearstatus	macro noexpand
		dod S0A
		endm
; clear the command entry area
clearcommand	macro noexpand
		dod S0B
		endm

; do a newline, show prompt, and cursor
showprompt	macro noexpand
		dod S0F
		endm

; do a delay for about 1.33 seconds
delay		macro noexpand
		dod S10
		endm

; set a block of memory (from X to U-1) to $00
clearblock	macro noexpand
		dod S11
		endm
; set a block of memory (from X to U-1) to $ff
setblock	macro noexpand
		dod S12
		endm
; fade in the image at (X) with sound effects at scale 1.0, clear status and command area
fadeinclrst	macro noexpand
		dod S13
		endm
; fade in the image at (X) with sound effects at scale 1.0, clear command area
fadein		macro noexpand
		dod S14
		endm
; fade out image at (X) with sound effects, clear command area
fadeout		macro noexpand
		dod S15
		endm

; play a sound number from immediate data at full volume
playsoundimm	macro noexpand
		dod S1B,\1
		endm
; play sound specified in A, volume in B
playsound	macro noexpand
		dod S1C
		endm

; ROM call numbers
POLCAT		equ 0
CSRDON		equ 4
BLKIN		equ 6
BLKOUT		equ 8
WRTLDR		equ 12

ROMTAB		equ $A000

BLKTYP		equ $7c
BLKLEN		equ $7d
CBUFAD		equ $7e

RESVEC		equ $A027

; SWI routines
S00		equ 0
S01		equ 1
S02		equ 2
S03		equ 3
S04		equ 4
S05		equ 5
S06		equ 6
S07		equ 7
S08		equ 8
S09		equ 9
S0A		equ $0A
S0B		equ $0B
S0C		equ $0C
S0D		equ $0D
S0E		equ $0E
S0F		equ $0F
S10		equ $10
S11		equ $11
S12		equ $12
S13		equ $13
S14		equ $14
S15		equ $15
S16		equ $16
S17		equ $17
S18		equ $18
S19		equ $19
S1A		equ $1A
S1B		equ $1B
S1C		equ $1C

PIA0		equ $ff00
PIA1		equ $ff20
SAMREG		equ $ffc0
TOPRAM		equ $4000
STACK		equ $1000

; the direct page
		org $200
V1F4		equ $1f4
V200		rmb 2				initialized to $0000
V202		rmb 1
V203		rmb 2				initialized to $ffff
V205		rmb 1
V206		rmb 1
V207		rmb 1
V208		rmb 1
V209		rmb 2				pointer to primary screen parameter block
V20B		rmb 2				pointer to secondary screen parameter block
V20D		rmb 2				pointer to demo game command sequence
V20F		rmb 2
V211		rmb 2
V213		rmb 1
V214		rmb 1
V215		rmb 2
V217		rmb 2
V219		rmb 1
V21A		rmb 1
V21B		rmb 1
V21C		rmb 1
V21D		rmb 2
V21F		rmb 2
V221		rmb 2
V223		rmb 1
V224		rmb 2
V226		rmb 2
V228		rmb 1
V229		rmb 2
V22B		rmb 1
V22C		rmb 1				the current level background colour mask
V22D		rmb 1				the current light level, $ff means dark
lightcount	rmb 1				counter between pixels when drawing lines
ybeg		rmb 2				start Y coord for line drawing
xbeg		rmb 2				start X coord for line drawing
yend		rmb 2				end Y coord for line drawing
xend		rmb 2				end X coord for line drawing
xcur		rmb 3				current X coordinate when drawing line
ycur		rmb 3				current Y coordinate when drawing line
xpstep		rmb 3				difference in X coordinate between pixels when drawing line
ypstep		rmb 3				difference in Y coordinate between pixels when drawing line
pixelcount	rmb 2				number of pixels to draw in a line
xbstep		rmb 1				the offset to add to pointer when moving to new byte (line drawing)
xystep		rmb 1				the offset to add to pointer when moving to new row (line drawing)
drawstart	rmb 2				start address of drawing area (line drawing)
drawend		rmb 2				end address of drawing area (line drawing)
V24B		rmb 4
V24F		rmb 1
V250		rmb 1
V251		rmb 1
V252		rmb 2
V254		rmb 2
V256		rmb 3
V259		rmb 2
V25B		rmb 2
V25D		rmb 2
V25F		rmb 2
V261		rmb 1
V262		rmb 1
V263		rmb 2
V265		rmb 6
V26B		rmb 1
V26C		rmb 1
V26D		rmb 1
V26E		rmb 1
V26F		rmb 1
V270		rmb 3
V273		rmb 1
V274		rmb 1
V275		rmb 2
V277		rmb 1
V278		rmb 1
V279		rmb 2
V27B		rmb 1
V27C		rmb 1
V27D		rmb 1
V27E		rmb 3
V281		rmb 1
V282		rmb 4
V286		rmb 2
V288		rmb 2
V28A		rmb 1
V28B		rmb 1
V28C		rmb 1
V28D		rmb 1
V28E		rmb 1
V28F		rmb 1
V290		rmb 1
V291		rmb 1
V292		rmb 2
V294		rmb 1
V295		rmb 2
V297		rmb 3
V29A		rmb 1
V29B		rmb 1
V29C		rmb 1
V29D		rmb 1
V29E		rmb 1
V29F		rmb 2
V2A1		rmb 10
V2AB		rmb 2
V2AD		rmb 1
V2AE		rmb 1
V2AF		rmb 1
V2B0		rmb 1
V2B1		rmb 1
V2B2		rmb 2
V2B4		rmb 1
V2B5		rmb 1
V2B6		rmb 1
V2B7		rmb 1				nonzero means nonstandard text location
V2B8		rmb 1
V2B9		rmb 2
V2BB		rmb 1
keybufread	rmb 1				keyboard buffer read offset
keybufwrite	rmb 1				keyboard buffer write offset
		rmb 3
V2C1		rmb 1				temporary variable used during line drawing and division
V2C2		rmb 1				temporary variable used during division
V2C3		rmb 1				temporary variable used during division
V2C4		rmb 1
V2C5		rmb 1
V2C6		rmb 1
V2C7		rmb 10
keybuf		rmb 32				keyboard ring buffer
V2F1		rmb 32
V311		rmb 2
V313		rmb 32
V333		rmb 2
V335		rmb 34				temporary buffer used for decoding immediate packed strings
V357		rmb 10				temporary buffer used for decoding font data
V361		rmb 31
V380		rmb 2				screen start address of info text area
V382		rmb 2				number of character cells in info text area
V384		rmb 2				current cursor position in info text area
V386		rmb 1				background colour mask for info text area
V387		rmb 1				nonzero if info text area should not be rendered on secondary screen
V388		rmb 2				screen start address of status line area
V38A		rmb 2				number of character cells in status line area
V38C		rmb 2				cursor position in status line area
V38E		rmb 1				background colour mask for status line area
V38F		rmb 1				nonzero if status line text should not be rendered on secondary screen
V390		rmb 2				start offset of the command entry area
V392		rmb 2				numer of character cells in command entry area
V394		rmb 2				current cursor position in entry area
V396		rmb 1				background colour mask of background area
V397		rmb 1				nonzero if main text should not be rendered on secondary screen
V398		rmb 43
V3C3		rmb 17
V3D4		rmb 20
V3E8		rmb $20c
V5F4		rmb $400
V9F4		rmb 9
V9FD		rmb $10a
VB07		rmb 10
VB11		rmb 4
VB15		rmb $3f0
VF05		equ *


		org $c000
START		ldu #LC0D1			point to the demo setup routine
		bra LC008			go handle the game
LC005		ldu #LC124			point to the real game setup routine
LC008		lds #STACK			put the stack somewhere safe
		ldx #PIA0			point at PIA0
		ldd #$34fa			initializers for the PIA
		sta 3,x				set data mode, interrupts disabled (side B)
		sta 1,x				set data mode, interrupts disabled (side A)
		ldx #PIA1			point at PIA1
		sta 1,x				set data mode, interrupts disabled (side A)
		clr 3,x				set direction mode for side B
		stb 2,x				set VDG and single bit sound to output
		lda #$3c			flags for data mode, no interrupts, sound enabled
		sta 3,x				set side B for data mode
		ldd #$2046			SAM value for "pmode 4" graphics, screen at $1000
		jsr LC266			go set the SAM register
		lda #$f8			value for "pmode 4", color set 1
		sta 2,x				set VDG mode
		ldx #V200			point to start of variables
LC030		clr ,x+				clear a byte
		cmpx #TOPRAM			are we at the top of memory?
		blo LC030			brif not
		stu ,--s			set return address to the game initialization routine
		lda #V200/256			point to MSB of direct page
		tfr a,dp			set DP appropriately
		setdp V200/256			tell the assembler about DP
		ldy #LD7E8			point to variable initialization table
LC041		lda ,y+				fetch number of bytes in this initializer
		beq LC086			brif zero - we're done
		ldx ,y++			get address to copy bytes to
		bsr LC04B			go copy bytes
		bra LC041			go handle another initializer
LC04B		ldb ,y+				fetch source byte
		stb ,x+				stow at destination
		deca				are we done yet?
		bne LC04B			brif not
		rts				return to caller
LC053		pshs cc,a,b,x,y,u		save registers and interrupt status
		orcc #$10			disable IRQ
		ldx #V29F
LC05A		clr ,x+
		cmpx #V2AD
		blo LC05A
		ldx #V9FD
		stx V2B9
LC066		clr ,x+
		cmpx #VB07
		blo LC066
		ldy #LD7DC
		dec V2BB
		ldd #12
LC076		ldx ,y++
		beq LC084
		jsr LC25C
		stx 3,u
		jsr LC21D
		bra LC076
LC084		puls cc,a,b,x,y,u,pc
LC086		bsr LC053
		ldu #LDA91
		clra
LC08C		ldb ,u
		andb #$0f
		stb V28C
		ldb ,u+
		lsrb
		lsrb
		lsrb
		lsrb
		stb V28D
LC09A		dod S17
		dec 5,x
		incb
		cmpb #5
		ble LC0A5
		ldb V28D
LC0A5		dec V28C
		bne LC09A
		inca
		cmpu #LDAA3
		blo LC08C
		ldu #V388				point to text parameters for status area
		dec V2B7				indicate nonstandard text area
		clearstatus				blank status line (where we'll put the copyright notice)
		renderstrimmp				display copyright message
		fcb $f8,$df,$0c,$c9			packed string "COPYRIGHT  DYNA MICRO  MCMLXXXII"
		fcb $27,$45,$00,$02
		fcb $65,$c1,$03,$52
		fcb $39,$3c,$00,$68
		fcb $da,$cc,$63,$09
		fcb $48
		clr <V2B7				reset text rendering to standard mode
		rts					
LC0D1		dec V277
		bsr LC114
		ldx #LDF10
		dec V29E
		fadein
		renderstrimmp				display <CR>"I DARE YE ENTER..."<CR>
		fcb $9f,$d2,$02,$06
		fcb $45,$06,$4a,$02
		fcb $ba,$85,$97,$bd
		fcb $ef,$80
		renderstrimmp				display "...THE DUNGEONS OF DAGGORATH!!!"
		fcb $f7,$bd,$ea,$20
		fcb $a0,$25,$5c,$72
		fcb $bd,$d3,$03,$cc
		fcb $02,$04,$e7,$7c
		fcb $83,$44,$6f,$7b
		delay					; wait for about 2.6 seconds
		delay					;
		fadeout
		cleargfx2				clear second graphics screen
		dec V2B4
		sync
		lda #2
		ldu #LD7D5
		bra LC131
LC114		ldd #$343c				set up initializers for PIAs
		sta PIA1+1				set data mode, no interrupts, cassette off
		stb PIA1+3				set data mode, no interrupts, sound on
		inca					adjust to enable interrupt
		sta PIA0+3				set data mode, enable VSYNC, clear MSB of analog MUX
		cwai #$ef				enable IRQ and wait for one
		rts					return to caller
LC124		bsr LC114
		ldd #$100b
		std V213
		clr V217
		clra
		ldu #LD7D9
LC131		dod S16
		dod S1A
		ldy #V229
LC139		lda ,u+
		bmi LC14F
		dod S17
		inc 5,x
		exg x,u
		dod S18
		exg x,u
		clr 11,x
		stx ,y
		tfr x,y
		bra LC139
LC14F		tst V277
		beq LC166
		dec V29B
		ldx #LCDB2
		stx V2B2
		dec V294
		dod S0E
		delay
		delay
		clr V29B
		sync
		sync
LC166		dod S19
		showprompt
		jmp LC1F5
LC16D		stx CBUFAD
		romcall BLKIN
		tsta
		lbne RESVEC
		ldb BLKTYP
		rts
LC17C		ldu #PIA0
		ldd #$343c
		sta 3,u
		sta PIA1+3
		stb PIA1+1
		rts
LC18B		ldx V200
LC18D		leax -1,x
		bne LC18D
		rts
LC192		bsr LC17C
		bsr LC18B
		bsr LC18B
		romcall WRTLDR
		romcall BLKOUT
		bsr LC18B
		romcall WRTLDR
		ldx #V200
LC1A6		ldd #$0180
		std BLKTYP
		stx CBUFAD
		romcall BLKOUT
		cmpx #VF05
		blo LC1A6
		stu BLKTYP
		romcall BLKOUT
		bsr LC18B
		bra LC1EC
LC1C1		bsr LC17C
		romcall CSRDON
LC1C6		ldu V20B
		ldx ,u
		bsr LC16D
		bne LC1C6
		ldx ,u
		ldu #V313
		ldb #8
LC1D5		lda ,x+
		cmpa ,u+
		bne LC1C1
		decb
		bne LC1D5
		romcall CSRDON
		ldx #V200
LC1E4		bsr LC16D
		bpl LC1E4
		lds #STACK
LC1EC		jsr LC114
		clr V2B8
		dod S19
		showprompt
LC1F5		ldu #V2AB
		clr V2BB
LC1FA		tfr u,y
LC1FC		tst V2B8
		bgt LC192
		bmi LC1C1
		ldu ,u
		beq LC1F5
		pshs y,u
		jsr [3,u]
		puls y,u
		tst V2BB
		bne LC1F5
		cmpb #12
		beq LC1FA
		bsr LC238
		bsr LC21D
		tfr y,u
		bra LC1FC
LC21D		pshs cc,a,b,x
		orcc #$10
		sta 2,u
		ldx #V29F
		abx
		clra
		clrb
		std ,u
LC22B		cmpd ,x
		beq LC234
		ldx ,x
		bra LC22B
LC234		stu ,x
		puls cc,a,b,x,pc
LC238		pshs cc,x
		orcc #$10
		ldx ,u
		stx ,y
		puls cc,x,pc
LC242		pshs b,x,y,u
		tst V29B
		bne LC25A
LC248		tfr u,y
		ldu ,u
		beq LC25A
		dec 2,u
		bne LC248
		bsr LC238
		ldb #12
		bsr LC21D
		bra LC248
LC25A		puls b,x,y,u,pc
LC25C		pshs x
		ldu V2B9
		leax 7,u
		stx V2B9
		puls x,pc
LC266		pshs x,b,a			save registers
		ldx #SAMREG			point to SAM register
LC26B		lsra				; shift the bit value to set to carry
		rorb				;
		bcs LC272			brif bit set
		sta ,x				clear the bit
		skip2				skip next instruction
LC272		sta 1,x				set the bit
		leax 2,x			move to next SAM register bit
		cmpx #SAMREG+$14		are we at the end of the register?
		blo LC26B			brif not
		puls a,b,x,pc			restore registers and return
; IRQ service routine
LC27D		ldx #PIA1
		lda -29,x
		lbpl LC320
		lda #2
		tfr a,dp
		tst V2B4
		beq LC29D
		ldd V209
		ldu V20B
		std V20B
		stu V209
		ldd 4,u
		bsr LC266
		clr V2B4
LC29D		tst V29C
		beq LC2A9
		com V29D
		lda V29D
		lsla
		lsla
		sta ,x
LC2A9		tst V2B1
		beq LC2DC
		dec V2AE
		bne LC2DC
		lda V2AF
		sta V2AE
		ldb 2,x
		eorb #2
		stb 2,x
		tst V2AD
		beq LC2DC
		ldu #V388
		ldx 4,u
		ldd #15
		std 4,u
		lda #$20
		com V2B0
		beq LC2D1
		lda #$22
LC2D1		jsr LCA17
		inc 5,u
		inca
		jsr LCA17
		stx 4,u
LC2DC		ldu #V2A1
		jsr LC242
		ldx #V295
		ldy #LC324
LC2E9		inc ,x
		cmpx #V29A
		beq LC2FF
		lda ,x
		cmpa ,y+
		blt LC2FF
		clr ,x+
		leau 2,u
		jsr LC242
		bra LC2E9
LC2FF		tst V228
		bne LC320
		tst V277
		beq LC318
		clr PIA0+2			strobe all keyboard columns
		lda PIA0			fetch row data
		anda #$7f			mask off comparator input
		cmpa #$7f			did we have any keys down?
		beq LC320			brif not
		ldx #LC005			; stop any demo game active; start a game
		stx 10,s			;
LC318		romcall POLCAT			poll the keyboard
		tsta				was a key down?
		beq LC320			brif not
		bsr LC340			go process keyboard input
LC320		lda PIA0+2			clear interrupt status
		rti
LC324		fcb $06,$0a,$3c,$3c,$18
LC329		pshs cc,b,x			save registers and interrupt status
		orcc #$10			disable IRQ
		clra				flag no key pressed
		ldx #keybuf			point to keyboard ring buffer
		ldb keybufread			get buffer read offset
		cmpb keybufwrite		same as buffer write offset?
		beq LC33E			brif so - no key available
		lda b,x				fetch key from buffer
		incb				bump buffer pointer
		andb #$1f			wrap around if needed
		stb keybufread			save new buffer read offset
LC33E		puls cc,b,x,pc			restore registers and interrupts
LC340		pshs cc,b,x			save registers and interrupt status
		orcc #$10			disable IRQ
		ldx #keybuf			point to keyboard ring buffer
		ldb keybufwrite			get buffer write offset
		sta b,x				stash new key
		incb				bump buffer pointer
		andb #$1f			wrap around if needed
		stb keybufwrite			save new buffer write offset
		puls cc,b,x,pc			restore registers and interrupts
; SWI handler
LC352		andcc #$ef			re-enable IRQ - SWI disables it
		ldx 10,s			get return address
		lda ,x+				get operation code
		stx 10,s			save new return address
		ldx #LC384			point to first SWI routine
		ldu #LC995			point to routine offset table
LC360		ldb ,u+				get length of previous routine
		abx				add to routine pointer
		deca				are we at the right routine?
		bpl LC360			brif not
		stx ,--s			save routine address
		ldd 3,s				restore D register
		ldx 6,s				restore X register
		ldu 10,s			restore U register
		jsr [,s++]			call the routine
		rti				return to caller
; SWI2 handler
LC371		clrb				; restore direct page for ROM call
		tfr b,dp			;
		ldu 10,s			get return address
		ldb ,u+				get ROM routine offset
		stu 10,s			save new return address
		ldu #ROMTAB			point to ROM vector table
		jsr [b,u]			call the ROM routine
		sta 1,s				; save return values
		stx 4,s				;
		rti				return to caller
; SWI 0 routine
LC384		lda V26E
		tst V275
		beq LC38E
		lda V26F
		clr V275
LC38E		clrb
		suba #7
		suba V28B
		bge LC39F
		decb
		cmpa #$f9
		ble LC39F
		ldx #LCB96
		ldb a,x
LC39F		stb V22D
		rts
; SWI 1 routine
;***********************************************************************************************************
; This routine renders a line graphic from the specification stored at (X).
;
; The data at (X) is a series of operations as follows:
;
; if (X) is < $FA, then the two bytes at (X) are an absolute Y and X coordinate. If V251 is clear, this is
; the first vertex in a polygon and the coordinates are simply recorded. Otherwise, a line is drawn from
; the previous coordinates to the new coordinates. These coordinates have the Y coordinate first.
;
; If (X) is >= $FA, it is a special operation defined as follows:
;
; FA: return from a "subroutine" to the previous flow
; FB: call a subroutine at the memory address in the next two bytes
; FC: draw a series of points using relative motion. The following byte is split into nibbles with the
;	upper nibble being the Y displacement and the lower nibble being the X displacement. These values
;	are signed and will be doubled when applied to the drawing. This gives a range of -32 to +30 in
;	steps of 2 for each direction. If both displacements are zero (a zero byte), this is the end of
;	the relative sequence. The end of one of these sequences is the end of a polygon.
; FD: like FB but doesn't record the previous location
; FE: flags the end of the input and causes a return to the caller. Do not use this in a subroutine as
;	the stack will have been used to record the return data location.
; FF: mark the next coordinates as the start of a new polygon.
;
; In all cases, the X and Y coordinates actually used have a scale factor applied to them based on the
; distance from the defined centre of the graphics area which is stored in (V205,V207). The horizontal
; scale factor is at V24F and the vertical scaling factor is at V250. A factor of 128 serves as a scale
; factor of 1. 192 would be 1.5 and 64 would be 0.5.
;
; Variables used:
;
; V205		the horizontal centre point for rendering graphics and scaling
; V207		the vertical centre point for rendering graphics and scaling
; V22D		the light level with respect to rendering the graphic
; V24F		the horizontal scaling factor (binary point to the right of bit 7)
; V250		the vertical scaling factor (binary point to the right of bit 7)
; V251		nonzero if this is not the first coordinate in a polygon
; V252		the most recent absolute unscaled X coordinate
; V254		the most recent absolute unscaled Y coordinate
LC3A2		clr V251			mark input as start of polygon
		lda V22D			fetch dungeon light level
		inca				is it $ff (dark)?
		beq LC3F6			brif so - skip rendering
LC3A9		ldb ,x				fetch input data
		subb #$fa			adjust for operation codes
		blo LC3CF			brif not operation code
		leax 1,x			move on to next image data byte
		ldy #LC3B9			point to jump table for operation codes
		ldb b,y				get offset to operation routine
		jmp b,y				execute operation routine
LC3B9		fcb LC3C9-LC3B9			(FA) return from a "subroutine"
		fcb LC3BF-LC3B9			(FB) call a "subroutine"
		fcb LC417-LC3B9			(FC) polygon
		fcb LC3C6-LC3B9			(FD) jump to a new "routine"
		fcb LC3F6-LC3B9			(FE) end of input - return to caller
		fcb LC3CB-LC3B9			(FF) next coordinates are start of new polygon
LC3BF		ldd ,x++			get address of "subroutine" to call
		stx ,--s			save return address
		tfr d,x				set new "execution" address
		skip2				skip next instruction
LC3C6		ldx ,x				get address of "routine" to jump to
		skip2				skip next instruction
LC3C9		ldx ,s++			get back saved input location
LC3CB		clr V251			reset polygon start flag to start
		bra LC3A9			go process more input
LC3CF		tst V251			is this the first coordinate in a polygon?
		bne LC3D9			brif not
		bsr LC3E2			fetch input coordinates and save them
		dec V251			flag as not first coordinate
		bra LC3A9			go process more input
LC3D9		bsr LC3E0			set up coordinates to draw a line
		jsr drawline			draw the line
		bra LC3A9			go process more input
LC3E0		bsr LC3F7			move last end coordinates to line start
LC3E2		ldb ,x+				get the next Y coordinate and move pointer forward
		stb V254			save unscaled Y coordinate
		bsr LC400			scale the Y coordinate
		addd V207			add in base Y coordinate
		std yend			save scaled end coordinate for line
		ldb ,x+				get the next X coordinate and move pointer forward
		stb V252			save unscaled X coordinate
		bsr LC406			scale the X coordinate
		addd V205			add in base X coordinate
		std xend			save scaled X coordinate for line
LC3F6		rts				return to caller
LC3F7		ldd yend			fetch last Y coordinate
		std ybeg			save as begining of new line segment
		ldd xend			fetch last X coordinate
		std xbeg			save as beginning of new line segment
		rts				return to caller
LC400		lda V250			get desired vertical scaling factor
		subb V208			find difference from Y base coordinate
		bra LC40A			go finish calculating scale
LC406		lda V24F			get desired horizontal scale factor
		subb V206			find difference from X base coordinate
LC40A		bcs LC40F			brif negative difference
		mul				apply the scaling factor
		bra LC414			normalize to an integer in D and return
LC40F		negb				make coordinate difference positive
		mul				apply the scaling factor
		jsr LCA99			negate coordinate value
LC414		jmp LD377			normalize to an integer in D and return
LC417		lda ,x+				get next byte in input
		beq LC3CB			brif NUL - end of values
		bsr LC3F7			move last end coordinate to start coordinate for line
		ldb -1,x			get the relative movement specifications
		asrb				; fetch high nibble signed extended into B
		asrb				;
		asrb				;
		asrb				;
		lslb				and multiply by two
		addb V254			add in previous Y coordinate
		stb V254			save new Y coordinate
		bsr LC400			go scale the Y coordinate
		addd V207			add in the Y base coordinate
		std yend			save new ending Y coordinate
		ldb -1,x			get back the input byte again
		andb #$0f			mask off the upper bits
		bitb #8				is bit 3 set?
		beq LC438			brif not
		orb #$f0			sign extend to 8 bits
LC438		lslb				multiply by two
		addb V252			add in saved X coordinate
		stb V252			save new X coordinate
		bsr LC406			go scale the X coordinate
		addd V205			add in base X coordinate
		std xend			save new ending X coordinate
		jsr drawline			go draw a line
		bra LC417			look for another line segment
; swi 2 routine
; fetch a packed string immediately following the call and display it
LC448		ldx 12,s			fetch return address - string address
		decodestrsb			go decode string
		stx 12,s			save new return address - after string
		ldx #V335			point to decoded string
		skip2				skip the next instruction - nothing to display yet
LC452		renderchar			display character in A
; swi 3 routine
; display an unpacked string pointed to by X
LC454		lda ,x+				fetch byte from string
		bpl LC452			brif not end of string - display it
		rts				return to caller
; swi 4 routine
; display character in A
LC459		tst V2B7			are we looking for standard text mode?
		bne LC460			brif not
		ldu #V390			point to display state information
LC460		ldx 4,u				fetch current screen location
		jsr LC9B2			actually display the appropriate character
		cmpx 2,u			are we at the end of text area?
		blo LC46C			brif not
		jsr LC9D4			go scroll the text area
LC46C		stx 4,u				save new screen location
		rts				return to caller
; swi 5 routine - decode packed string at X to V335
LC46F		ldu #V335			point to output buffer
; swi 6 routine - decode a packed string at X to U
; the first value is the length of the string less one
LC472		leay -1,u			point to working data before buffer
		clr ,y				initialize value counter
		bsr LC48C			fetch a value
		tfr b,a				save length
LC47A		bsr LC48C			fetch a value
		stb ,u+				save in output
		deca				done yet?
		bpl LC47A			brif not
		sta ,u				flag end of string with $ff
		tst ,y				did we consume an even number of bytes?
		beq LC489			brif so
		leax 1,x			move pointer forward
LC489		stx 6,s				save pointer past end of input
		rts				return to caller
LC48C		pshs a,u			save registers
		lda ,y				get value counter
		ldu #LC4A2			point to value handlers
		lda a,u				get offset to handler for this value
		jsr a,u				call the handler for this value
		lda ,y				get value counter
		inca				bump it
		anda #7				wrap it around - the pattern repeats every 8 values
		sta ,y				save new value counter
		andb #$1f			values are only 5 bits - clear out extra bits
		puls a,u,pc			restore registers and return
LC4A2		fcb LC4AA-LC4A2			value 0 handler
		fcb LC4B0-LC4A2			value 1 handler
		fcb LC4B5-LC4A2			value 2 handler
		fcb LC4B9-LC4A2			value 3 handler
		fcb LC4BE-LC4A2			value 4 handler
		fcb LC4C3-LC4A2			value 5 handler
		fcb LC4C7-LC4A2			value 6 handler
		fcb LC4CC-LC4A2			value 7 handler
; value 0: upper 5 bits of current input byte
LC4AA		ldb ,x				fetch input byte
		lsrb				; align in low bits of B
LC4AD		lsrb				;
LC4AE		lsrb				;
		rts				return to caller
; value 1: lower 3 bits of current input byte and upper 2 bits of next one
; consumes a byte
LC4B0		ldd ,x+				fetch input data and consume a byte
		jmp LD379			; align in low bits of B
; value 2: bits 5...1 of current input byte
LC4B5		ldb ,x				fetch input byte
		bra LC4AE			align in low bits of B
; value 3: bits 0 of current byte and upper 4 bits of next one
; consumes a byte
LC4B9		ldd ,x+				fetch input data and consume a byte
		jmp LD37D			align in low bits of B
; value 4: low 4 bits of input byte and high bit of next one
; consumes a byte
LC4BE		ldd ,x+				fetch input data and consume a byte
		jmp LD377			align in low bits of B
; value 5: bits 6...2 of current input byte
LC4C3		ldb ,x				fetch input data
		bra LC4AD			align in low bits of B
; value 6: low two bits of current input byte and high 3 bits of next one
; consums a byte
LC4C7		ldd ,x+				fetch input data and consume a byte
		jmp LD37B			align in low bits of B
; value 7: low 5 bits of current input byte
; consumes a byte
LC4CC		ldb ,x+				fetch input data - already aligned
		rts				return to caller
; swi 7 routine
LC4CF		ldx #8
LC4D2		clrb
		ldy #8
		lda V26D
		anda #$e1
LC4DB		lsla
		bcc LC4DF
		incb
LC4DF		leay -1,y
		bne LC4DB
		lsrb
		rol V26B
		rol V26C
		rol V26D
		leax -1,x
		bne LC4D2
		lda V26B
		sta 3,s
		rts
; swi 8 routine - clear first graphics screen
LC4F3		ldu V209			point to first screen parameter block
		skip2				skip next instruction
; swi 9 routine - clear second graphics screen
LC4F6		ldu V20B			point to second screen parameter block
		ldb V22C			get current level background colour
		bsr LC517			go clear the graphics area of the screen
		stu 10,s			save pointer to parameter block for the caller
		rts				return to caller
; swi 10 routine - clear the status line
LC4FF		ldx #V388			point to text area parameters for the status line
		ldu #LD87C			point to screen address table for the status line
		bra LC50D			go clear the status line
; swi 11 routine - clear the command entry area
LC507		ldx #V390			point to text area parameters for the command area
		ldu #LD888			point to screen address table for the command area
LC50D		clr 4,x				; set current cursor to start of text area
		clr 5,x				;
		ldb 6,x				get background colour of text area
		bsr LC517			go clear text area
		leau 6,u			and repeat the process for the other graphics screen
LC517		pshs a,b,x,y,u			save regsiters
		sex				get background colour to A
		tfr d,y				move it into Y too (4 bytes of background colour)
		leax ,u				point to start of parameter area
		ldu 2,u				get address of end of text area (+1)
LC520		pshu a,b,y			blast 4 background bytes to area
		cmpu ,x				are we at the start of the area?
		bne LC520			brif not
		puls a,b,x,y,u,pc		restore registers and return
; swi 12 routine
LC529		clr V2C1
		ldd V217
		std V2C2
		lda #6
LC531		lsl V2C3
		rol V2C2
		rol V2C1
		deca
		bne LC531
		clr V2C4
		ldd V221
		std V2C5
		lsl V2C6
		rol V2C5
		rol V2C4
		ldd V217
		addd V2C5
		std V2C5
		ldb V2C4
		adcb #0
		stb V2C4
		clr V2C7
LC554		ldd V2C2
		subd V2C5
		std V2C2
		lda V2C1
		sbca V2C4
		sta V2C1
		inc V2C7
		bcc LC554
		lda V2C7
		suba #19
		sta V2AF
		tst V228
		bne LC595
		cmpa #3
		bgt LC5AE
		clearcommand
		lda V26E
		sta V270
LC578		dec V26F
		jsr [V2B2]
		dec V2B4
		sync
		dec V26E
		lda V26E
		cmpa #$f8
		bgt LC578
		cleargfx2
		dec V2B4
		dec V228
		clr keybufread			; reset keyboard buffer
		clr keybufwrite			;
		bra LC5AE
LC595		cmpa #4
		ble LC5AE
LC599		jsr [V2B2]
		dec V2B4
		sync
		inc V26F
		inc V26E
		lda V26E
		cmpa V270
		ble LC599
		clr V228
		showprompt
LC5AE		ldx V217
		cmpx V221
		blo LC5B5
		rts
; This routine handles player death
LC5B5		ldx #LDF10			
		dec V29E
		fadeinclrst
		renderstrimmp
		fcb $ff,$c1,$92,$d0		"YET ANOTHER DOES NOT RETURN..."
		fcb $01,$73,$e8,$82
		fcb $c8,$04,$79,$66
		fcb $07,$3e,$80,$91
		fcb $69,$59,$3b,$de
		fcb $f0
		clr V228
		dec V277
LC5D7		bra LC5D7			wait forever (or until the IRQ does something)
; swi 13 routine
LC5D9		ldu #V388
		dec V2B7
		lda V22C
		coma
		sta 6,u
		clra
		clrb
		bsr LC609
		std 4,u
		ldx V21D
		bsr LC617
		renderstr
		ldd #17
		bsr LC609
		ldx V21F
		bsr LC617
		tfr x,y
		ldd #$21
LC5FD		decb
		tst ,y+
		bpl LC5FD
		std 4,u
		renderstr
		clr V2B7
		rts
LC609		pshs a,b
		std 4,u
		ldd #15
LC610		renderchar
		decb
		bne LC610
		puls a,b,pc
LC617		pshs a,b,y,u
		leay ,x
		bne LC622
		ldx #LC650
		bra LC63C
LC622		ldu #V313
		tst 11,y
		bne LC632
		lda 9,y
		ldx #LD8F4
		bsr LC63E
		clr -1,u
LC632		lda 10,y
		ldx #LD96B
		bsr LC63E
		ldx #V313
LC63C		puls a,b,y,u,pc
LC63E		pshs a,x
LC640		decodestrsb
		deca
		bpl LC640
		ldx #V335+1
LC648		lda ,x+
		sta ,u+
		bpl LC648
		puls a,x,pc
LC650		fcb $05,$0d,$10,$14		unpacked string "EMPTY"
		fcb $19,$ff
; swi 14 routine
LC656		tst V228
		bne LC65F
		bsr LC660
		dec V2B4
		sync
LC65F		rts
LC660		pshs a,b,x,y,u
		ldd V226
		ldu V224
		beq LC66C
		adda 7,u
		addb 8,u
LC66C		std V26E
		jsr [V2B2]
		puls a,b,x,y,u,pc
; swi 15 routine
LC674		ldx #LC67A
		renderstr
		rts
LC67A		fcb $1f,$1e			unpacked string CR PERIOD UNDERSCORE BS (including following)
LC67C		fcb $1c,$24,$ff			unpacked string UNDERSCORE BS

; swi 16 routine
; delay for 81 ticks (1.3 seconds)
LC67F		ldb #$51			fetch delay tick count
LC681		sync				wait for a tick
		decb				are we done yet?
		bne LC681			brif not
		rts
; these two routine clear an area to 0 (black) or $ff (white) starting at X and
; ending at U
; swi 17 routine
LC686		clra				set area to $00 (clear to black)
		skip2				skip next byte
; swi 18 routine
LC688		lda #$ff			set area to $FF (clear to white)
LC68A		sta ,x+				clear a byte
		cmpx 10,s			are we done yet?
		bne LC68A			brif not
		rts				return to caller
; This looks like a leftover from earlier development which had the
; rom calls as a SWI call instead of using SWI2. This routine cannot
; be reached through the SWI mechanism and it cannot be called directly
LC691		clrb				; reset direct page for ROM call
		tfr b,dp			;
		ldu 12,s			fetch return address
		ldb ,u+				fetch rom call wanted
		stu 12,s			save new return address
		ldu #ROMTAB			point to ROM vector table
		jsr [b,u]			call the routine
		sta 3,s				; save return values
		stx 6,s				;
		rts
; swi 19 routine
; fade in the image specified by (X) with sound effects, clear status line and command area
LC6A4		clr V2B1
		clearstatus			clear the status area
; swi 20 routine
; fade in the image specified by (X) with sound effects, clear command area
LC6A8		clearcommand			clear the command area
		ldd #$8080			; set X and Y scale values to 1.0
		std V24F			;
		ldb V29E
		beq LC6B7
		ldb #$20			set apparent lighting to 32 (less apparent)
		dec V29C
LC6B7		bsr LC6D7			go draw the image
		decb				; reduce lighting count - make more apparent
		decb				;
		bpl LC6B7			brif not done 16 steps
		clr V29C
		clr V29E
LC6C1		playsoundimm $16
		rts				return to caller
; swi 21 routine
; fade out the image specified by (X) with sound effects, clear command area
LC6C5		clearcommand			clear the command entry area
		bsr LC6C1
		clrb				set apparent illumination to fully lit			
		dec V29C
LC6CC		bsr LC6D7			go draw the image
		incb				; bump lighting count (make less apparent)
		incb				;
		cmpb #$20			have we done 16 steps?
		bne LC6CC			brif not
		clr V29C
		rts				return to caller
LC6D7		pshs x,u			save registers
		stb V22D			set illumination value for graphic rendering
		stb V29D
		cleargfx2			clear second graphics screen
		drawgraphic			go draw graphic
		dec V2B4
		sync				wait for an interrupt
		puls x,u,pc			restore registers and return
; swi 22 routine
LC6E6		jsr LD489
		ldd #$12c
		std 4,u
		renderstrimmp
		fcb $3c,$24,$58,$06		packed string "PREPARE!"
		fcb $45,$d8
		clr V2B7
		dec V2B4
		rts
; swi 23 routine
LC6FB		ldu V20F
		stu 6,s
		leax 14,u
		stx V20F
		sta 9,u
		stb 4,u
		dod S18
		ldb 10,u
		ldx #LC719
		lda b,x
		bmi LC718
		ldb 11,u
		dod S18
		stb 11,u
LC718		rts
LC719		fcb $ff,$ff,$ff,$10
		fcb $11,$0f
; swi 24 routine
LC71F		lsla
		lsla
		ldx #LDA00
		leay a,x
		leax 10,u
		lda #4
		jsr LC04B
		ldx #LDA60
LC730		leax 4,x
		lda ,x
		bmi LC742
		cmpa 3,s
		bne LC730
		ldd 1,x
		std 6,u
		lda 3,x
		sta 8,u
LC742		rts
; swi 25 routine
LC743		clearstatus
		clearcommand
		dod S0C
		inc V2AE
		dec V2AD
		dec V2B1
		dod S0D
LC751		ldx #LCE66
		stx V2B2
		dod S0E
		rts
; swi 26 routine
LC759		sta V281
		ldb #12
		mul
		addd #V398
		std V282
		ldb V281
		ldx #LCFFD
LC768		stx V286
LC76A		lda ,x+
		bpl LC76A
		decb
		bpl LC768
		ldx #V3D4			get start address to clear
		ldu #V5F4			get end address to clear
		clearblock			go clear area to zeros
		jsr LC053
		jsr LCC9C
		ldu V282
		lda #11
LC783		ldb a,u
		beq LC78D
LC787		jsr LCFA5
		decb
		bne LC787
LC78D		deca
		bpl LC783
		ldu #V3C3
		clr V291
LC795		jsr LCF63
		beq LC7B6
		tst 5,x
		bpl LC795
LC79E		leau 17,u
		cmpu #V5F4
		blo LC7AA
		ldu #V3D4
LC7AA		tst 12,u
		beq LC79E
		ldd 8,u
		stx 8,u
		std ,x
		bra LC795
LC7B6		lda V281
		anda #1
		nega
		sta V22C
		sta V396
		sta V386
		coma
		sta V38E
		rts
; swi 27 routine
; play a sound specified by the immediate identifier
LC7C8		ldx 12,s			fetch return address
		lda ,x+				fetch immediate data
		stx 12,s			update return address
		ldb #$ff
; swi 28 routine
; play a sound specified by the value in A
LC7D0		stb V261
		ldx #LC7DC			point to sound routine jump table
		lsla				two bytes per jump table entry
		jsr [a,x]			call the sound generator routine
		clr PIA1			turn off sound output
		rts				return to caller
; the jump table for sound routines
LC7DC		fdb LC82B			sound 0
		fdb LC850			sound 1
		fdb LC951			sound 2
		fdb LC83C			sound 3
		fdb LC8E2			sound 4
		fdb LC955			sound 5
		fdb LC84A			sound 6
		fdb LC8DE			sound 7
		fdb LC84D			sound 8
		fdb LC959			sound 9
		fdb LC877			sound 10
		fdb LC877			sound 11
		fdb LC80A			sound 12
		fdb LC811			sound 13
		fdb LC827			sound 14
		fdb LC8DA			sound 15
		fdb LC8A6			sound 16
		fdb LC8B2			sound 17
		fdb LC93F			sound 18
		fdb LC8E6			sound 19
		fdb LC872			sound 20
		fdb LC86D			sound 21
		fdb LC88A			sound 22
; sound 12
LC80A		ldu #LC823
		lda #4
		bra LC816
; sound 13
LC811		ldu #LC81F
		lda #10
LC816		sta V25F
LC818		jsr ,u
		dec V25F
		bne LC818
		rts
LC81F		ldx #$40
		fcb $10
LC823		ldx #$80
		fcb $10
; sound 14
LC827		ldx #$100
		fcb $10
; sound 0
LC82B		ldx #$20
LC82E		bsr LC835
		leax -1,x
		bne LC82E
		rts
LC835		lda #$ff
		bsr LC869
		clra
		bra LC869
; sound 3
LC83C		ldx #$500
LC83F		bsr LC835
		leax $30,x
		cmpx #$800
		blo LC83F
		rts
; sound 6
LC84A		lda #2
		skip2
; sound 8
LC84D		lda #1
		skip2
; sound 1
LC850		lda #10
		sta V262
LC854		ldy #$c0
LC858		bsr LC8CE
		bsr LC8C5
		leay -1,y
		bne LC858
		bsr LC8BA
		dec V262
		bne LC854
		rts
LC867		bsr LC8CE
LC869		bsr LC8C5
		bra LC8BD
; sound 21
LC86D		ldu #LDBDA
		bra LC893
; sound 20
LC872		ldu #LDBD2
		bra LC893
; sound 10, sound 11
LC877		lda #8
		sta V25F
LC87B		bsr LC8CE
		clra
		lsrb
		bne LC882
		incb
LC882		tfr d,x
		bsr LC82E
		dec V25F
		bne LC87B
; sound 22
LC88A		ldu #LDBD2
		bsr LC893
		bsr LC8BA
		leau 4,u
LC893		ldx ,u
LC895		ldy 2,u
LC898		bsr LC867
		leay -1,y
		bne LC898
		leax 2,x
		cmpx #$150
		bne LC895
		rts
; sound 16
LC8A6		jsr LC931
		fcb $80
LC8AA		bsr LC922
		bcs LC8B2
		bsr LC8C5
		bra LC8AA
; sound 17
LC8B2		jsr LC92E
		fcb $a0
LC8B6		bsr LC926
		bra LC8B6
LC8BA		ldx #$1000
LC8BD		pshs x
LC8BF		leax -1,x
		bne LC8BF
LC8C3		puls x,pc
LC8C5		ldb V261
		mul
		anda #$fc
		sta PIA1
		rts
LC8CE		ldd V256
		lslb
		rola
		lslb
		rola
		addd V256
		incb
		std V256
		rts
; sound 15
LC8DA		bsr LC915
		fdb $6424
; sound 7
LC8DE		bsr LC915
		fdb $3212
; sound 4
LC8E2		bsr LC915
		fdb $AF36
; sound 19
LC8E6		bsr LC915
		fdb $1909
LC8EA		bsr LC92E
		fcb $60
LC8ED		ldx V263
		ldy V265
		clra
LC8F3		leax -1,x
		bne LC8FD
		ldx V263
		eora #$7f
		bsr LC90A
LC8FD		leay -1,y
		bne LC8F3
		ldy V265
		eora #$80
		bsr LC90A
		bra LC8F3
LC90A		sta V259
		bsr LC97E
		bls LC8C3			skip the caller to this routine and return to its caller
		bsr LC8C5
		lda V259
		rts
; this routine doesn't return to the caller but to the caller's caller
LC915		ldx ,s++
		ldb ,x+
		clra
		std V263
		ldb ,x+
		std V265
		bra LC8EA
LC922		bsr LC8CE
		bra LC98D
LC926		bsr LC8CE
LC928		bsr LC97E
		bls LC8C3			skip the caller to this routine and return to its caller
		bra LC8C5
LC92E		ldx V203
		fcb $10
LC931		ldx V200
LC933		stx V25B
		ldx ,s
		ldb ,x+
		clra
		std V25D
		stx ,s
		rts
; sound 18
LC93F		bsr LC92E
		fcb $60
LC942		jsr LC8CE
		lsra
		bsr LC928
		jsr LC8CE
		ora #$80
		bsr LC928
		bra LC942
; sound 2
LC951		ldx #$300
		fcb $10
; sound 5
LC955		ldx #$200
		fcb $10
; sound 9
LC959		ldx #$100
		stx V25D
		clra
		clrb
		std V25B
LC962		bsr LC922
		bcs LC971
		jsr LC8C5
		ldx #$f0
		jsr LC8BD
		bra LC962
LC971		bsr LC92E
		fcb $40
LC974		bsr LC926
		ldx #$60
		jsr LC8BD
		bra LC974
LC97E		pshs a
		ldd V25B
		subd V25D
LC984		pshs cc
		std V25B
		ldb 1,s
		mul
		puls cc,b,pc
LC98D		pshs a
		ldd V25B
		addd V25D
		bra LC984
; this is the swi routine offset table - each byte is the difference between the entry point
; of the previous routine and itself
LC995		fcb 0				first routine has nothing before it
		fcb LC3A2-LC384
		fcb LC448-LC3A2
		fcb LC454-LC448
		fcb LC459-LC454
		fcb LC46F-LC459
		fcb LC472-LC46F
		fcb LC4CF-LC472
		fcb LC4F3-LC4CF
		fcb LC4F6-LC4F3
		fcb LC4FF-LC4F6
		fcb LC507-LC4FF
		fcb LC529-LC507
		fcb LC5D9-LC529
		fcb LC656-LC5D9
		fcb LC674-LC656
		fcb LC67F-LC674
		fcb LC686-LC67F
		fcb LC688-LC686
		fcb LC6A4-LC688
		fcb LC6A8-LC6A4
		fcb LC6C5-LC6A8
		fcb LC6E6-LC6C5
		fcb LC6FB-LC6E6
		fcb LC71F-LC6FB
		fcb LC743-LC71F
		fcb LC759-LC743
		fcb LC7C8-LC759
		fcb LC7D0-LC7C8
;***********************************************************************************************************
; The following code handles displaying text on the screen. It works as follows.
;
; The graphics screen is divided into a grid of character cells 32 columns wide by 24 rows high. Each cell
; is 8 pixels wide by 8 pixels high. Text can be rendered anywhere on the screen as long as it fits within
; a character cell. The cells line up on even bytes which makes actually rendering the characters fast.
;
; Characters are encoded in 5 bits as follows: A through Z are given codes 1 through 26. 0 is a space. 27
; is the exclamation point, 28 is the underscore, 29 is the question mark, and 30 is the period. Code 31
; is used as a carriage return. Codes 32 and 33 are the left and right parts of the contracted heart symbol
; while 34 and 35 are the left and right parts of the expanded heart symbol. 36 is backspace.
;
; Glyphs for codes 0 through 30 are encoded using the packed five bit encoding and are located at LDB1B. They
; are encoded in a 5 by 7 bitmap which is shifted to be offset one pixel from the left of the character cell
; upon decoding.
;
; The glyphs for the heart codes are in unpacked encoding and are located at LDBB6 and occupy the entire
; 8 bit width of the character cell.
;
; These routines expect a pointer to the text configuration parameters in U. At offset 0 is the start address
; of the scrollable area of the screen (memory address). At offset 2 is the ending character cell address of
; the scrollable area of the screen. At offset 4 is the current printing position. At offset 6 is a mask with
; all pixels set to the background colour. At offset 7 a flag which when nonzero inhibits rendering text to
; the secondary graphics screen area. For the ordinary command entry area at the bottom of the screen, this
; will point to V390.
LC9B2		cmpa #$24			is it backspace?	
		beq LC9BF			brif so
		cmpa #$1f			vertical spacer?
		beq LC9CA			brif so
		bsr LCA17			go handle a glyph
		leax 1,x			move to next character position
		rts				return to caller
LC9BF		leax -1,x			move display pointer back one
		cmpx V203			did we wrap around negative?			
		bne LC9C9			brif not
		ldx 2,u				get end of text area
		leax -1,x			move back one position to be in the text area
LC9C9		rts				return to caller
LC9CA		leax $20,x			move pointer forward one character row
		exg d,x				move pointer so we can do math
		andb #$e0			force pointer to the start of the line
		exg d,x				put pointer back where it belongs
		rts				return to caller
LC9D4		pshs a,b,x,y			save registers
		ldx ,u				get start of screen address
		ldd 2,u				get end of text area
		subd #$20			knock one character row off it
		std 2,s				save new display location
		bsr LCA10			multiply by 8 - 8 pixel rows per cell
		tfr d,y				save counter
LC9E3		ldd $100,x			get bytes 8 pixel rows ahead
		tst 7,u				do we need to skip the second screen?
		bne LC9EF			brif so
		std $1800,x			save scroll data on second screen
LC9EF		std ,x++			save scroll data and move pointer ahead
		leay -2,y			are we done yet?
		bne LC9E3			brif not
		ldb 6,u				fetch current background colour
		sex				and make A match
		ldy #$100			number of bytes to blank bottom row
LC9FC		tst 7,u				are we doing second screen too?
		bne LCA04			brif not
		std $1800,x			blank pixels in second screen
LCA04		std ,x++			blank pixels and move pointer forward
		leay -2,y			are we done yet?
		bne LC9FC			brif not
		puls a,b,x,y,pc			restore registers and return
LCA0C		lslb				; enter here to shift D left 5 bits
		rola				;
		lslb				;
		rola				;
LCA10		lslb				; enter here to shift D left 3 bits
		rola				;
LCA12		lslb				; enter here to shift D left 2 bits
		rola				;
		lslb				;
		rola				;
		rts
LCA17		pshs a,b,x,y,u			save registers
		cmpa #$20			is it a printing character?
		blo LCA29			brif so
		suba #$20			mask off printing characters
		ldb #7				7 bytes per font table entry
		mul				get offset in table
		addd #LDBB6			add in base address of table
		tfr d,x				put font pointer somewhere useful
		bra LCA44			go draw glyph
LCA29		ldb #5				5 bytes per font table entry
		mul				get offset in table
		addd #LDB1B			add in base address of table
		tfr d,x				put pointer somewhere useful
		ldu #V357			point to buffer to decode glyph data
		decodestr			go decode a packed string
		ldx #V357+7			point one past end of buffer
LCA39		lsl ,-x				; centre glyph data in byte
		lsl ,x				;
		cmpx #V357			at start of buffer?
		bhi LCA39			brif not - keep centring
		ldu 6,s				get back U value
LCA44		ldd 4,u				get display address location
		bsr LCA10			multiply by 8 - gets start of row in 11..8
		lsrb				; and divide lsb by 8 again to get offset within
		lsrb				; the row to bits 4..0
		lsrb				; and force to top of character cell
		addd ,u				add in start of text area
		tfr d,y				put pointer somewhere useful
		ldb #7				seven bytes to copy
LCA51		lda ,x+				get byte from font data
		eora 6,u			merge with background colour
		sta ,y				save it on the screen
		tst 7,u				do we need to update second screen?
		bne LCA5F			brif not
		sta $1800,y			save pixels on second screen
LCA5F		leay $20,y			move display pointer down one pixel row
		decb				are we done yet?
		bne LCA51			brif not - do another
		puls a,b,x,y,u,pc		restore registers and return
; This routine divides a 16 bit unsigned value in D by a 16 bit unsigned value in X. The result
; will be in D with the binary point to the right of A.
LCA67		pshs a,b,x			make hole for result and save divisor
		clr ,s				; initialize quotient
		clr 1,s				;
		clr V2C1			use V2C1 for extra precision on dividend
		std V2C2			save dividend
		beq LCA97			brif dividend is zero - nothing to do
		cmpd 2,s			is dividend equal to divisor?
		bne LCA7C			brif not
		inc ,s				set quotient to 1.0
		bra LCA97			go return
LCA7C		ldx #16				we need to do 16 iterations
LCA7F		lsl V2C3			; shift dividend
		rol V2C2			;
		rol V2C1			;
		lsl 1,s				= shift quotient
		rol ,s				=
		ldd V2C1			get dividend high word
		subd 2,s			subtract out divisor
		bcs LCA93			brif it doesn't go
		std V2C1			save new dividend residue
		inc 1,s				record the fact that it went
LCA93		leax -1,x			have we done all 16 bits?
		bne LCA7F			brif not
LCA97		puls a,b,x,pc			fetch result, restore registers, and return
LCA99		coma				; do a one's complement of D
		comb				;
		addd #1				adding 1 turns it into negation
		rts				return to caller
LCA9F		pshs a,b,x			save registers
		ldx pixelcount			get number of pixels to draw
		ldd ,s				get the difference
		bpl LCAAE			brif positive
		bsr LCA99			negate difference
		bsr LCA67			divide by number of pixels
		bsr LCA99			negate the result
		skip2				skip next instruction
LCAAE		bsr LCA67			divide by number of pixels
		std ,s				save step value
		puls a,b,x,pc			restore registers and return
LCAB4		jmp LCB8A			go return from the line drawing routine
; Draw a line from (xbeg,ybeg) to (xend,yend) respecting the light level in the dungeon (V22D)
; which is used as a step count between when to actually draw pixels.
;
; Variables used:
; V22D		the current light level in the dungeon
; lightcount	how many pixels left before we actually draw another
; ybeg		input start Y
; xbeg		input start X
; yend		input end Y
; xend		input end X
; xcur		X coordinate of pixel to be drawn (24 bits with 8 bits after binary point)
; ycur		U cpprdomate of pixel to be drawn (24 bits with 8 bits after binary point)
; xpstep	24 bit X coordinate difference (per pixel)
; ypstep	24 bit Y coordinate difference (per pixel)
; pixelcount	number of pixels to draw in the line
; xbstep	the offset for when X coordinate goes to a new byte
; xystep	the offset for when Y coordinate goes to a new line
; drawstart	the start address of the graphics screen area the line is within
; drawend	the end address of the graphics screen area the line is within
; V2C1		a temporary scratch variable
;
; Note: ypstep+1 and xpstep+1 are also used as temporary holding values for the
; integer difference in the Y and X coordinates respectively.
drawline	pshs a,b,x,y,u			save registers
		inc V22D			are we completely dark?
		beq LCAB4			brif so - we can short circuit drawing entirely
		lda V22D			get light level in dungeon
		sta lightcount			save in working count (skip count for pixel drawing)
		ldd xend			get end X coordinate
		subd xbeg			subtract start X coordinate
		std xpstep+1			save coordinate difference
		bpl LCACB			brif positive difference
		bsr LCA99			negate the difference
LCACB		std pixelcount			save absolute value of X difference as pixel count
		ldd yend			get end Y coordinate
		subd ybeg			subtract start Y coordinate
		std ypstep+1			save coordinate difference
		bpl LCAD7			brif positive difference
		bsr LCA99			negate the difference
LCAD7		cmpd pixelcount			is the Y difference bigger than X?
		blt LCAE0			brif not
		std pixelcount			save Y difference as pixel count
		beq LCAB4			brif no pixels to draw - short circuit
LCAE0		ldd xpstep+1			get X difference
		bsr LCA9F			calculate X stepping value
		std xpstep+1			save X stepping value
		tfr a,b				save msb of difference
		sex				sign extend it
		ldb #1				X stepping value - 1 for ascending
		sta xpstep			sign extend stepping difference to 24 bits
		bpl LCAF0			brif positive
		negb				set stepping value to -1
LCAF0		stb xbstep			save X byte stepping value
		ldd ypstep+1			get Y difference
		bsr LCA9F			calculate Y step value
		std ypstep+1			save result
		tfr a,b				save msb of difference
		sex				sign extend it
		ldb #$20			Y byte stepping value - 32 bytes per line, ascending
		sta ypstep			sign extend the difference to 24 bits
		bpl LCB02			brif positive
		negb				negate the difference - -32 bytes per line, descending
LCB02		stb xystep			save Y byte stepping value
		ldd xbeg			get start X coordinate
		std xcur			save in X coordinate counter
		ldd ybeg			get start Y coordinate
		std ycur			save in Y coordinate counter
		lda #$80			value for low 8 bits to make the values ".5"
		sta xcur+2			set X coordinate to ".5"
		sta ycur+2			set Y coordinate to ".5"
		ldx 2,u				get end of graphics area address
		stx drawend			save it for later
		ldx ,u				get start of graphics area address
		stx drawstart			save it for later
		ldd ycur			get Y coordinate for pixel
		jsr LCA0C			shift left 5 bits - 32 bytes per row
		leax d,x			add to screen start address
		ldd xcur			get X coordinate for pixel
		jsr LD37F			shift right 3 bits - 8 pixels per byte
		leax d,x			add to row start address
		ldu #LCB8E			point to table of pixel masks
		ldy pixelcount			get number of pixels to draw
LCB2E		dec lightcount			are we ready to draw another pixel (due to light level)?
		bne LCB54			brif not
		lda V22D			get light level
		sta lightcount			reset current "pixel delay"
		tst xcur			is X coordinate off the right of the screen?
		bne LCB54			brif so
		cmpx drawstart			is the pixel address before the start of the graphics area?
		blo LCB54			brif so
		cmpx drawend			is the pixel address after the end of the graphics area?
		bhs LCB54			brif so
		ldb xcur+1			get X coordinate lsb
		andb #7				mask off low 3 bits for offset in byte
		lda b,u				get pixel mask to use
		tst V22C			currently using black background?
		beq LCB50			brif so
		coma				invert mask for white background
		anda ,x				merge in existing graphics data
		skip2				skip next instruction
LCB50		ora ,x				merge in existing graphics data (black background)
		sta ,x				save new graphics data on the screen
LCB54		lda xcur+1			get X coordinate lsb
		anda #$f8			mask off the pixel offset in the byte
		sta V2C1			save it for later
		ldd xcur+1			get X coordinate low bits
		addd xpstep+1			add in X difference
		std xcur+1			save new low bits for X coordinate
		ldb xcur			get X coordinate high bits
		adcb xpstep			add in difference high bits
		stb xcur			save new X coordinate high bits
		anda #$f8			mask off pixel offset in data byte
		cmpa V2C1			are we in the same byte?
		beq LCB70			brif so
		ldb xbstep			get byte X step value 
		leax b,x			move pointer appropriately
LCB70		ldd ycur+1			get Y coord low bits
		sta V2C1			save screen Y coordinate
		addd ypstep+1			add in Y step value low bits
		std ycur+1			save new low bits
		ldb ycur			get Y coord high bits
		adcb ypstep			add in Y step value high bits
		stb ycur			save new Y coord high bits
		cmpa V2C1			are we on the same scren row?
		beq LCB86			brif so
		ldb xystep			get Y byte step value
		leax b,x			move pointer appropriately
LCB86		leay -1,y			have we drawn all the pixels?
		bne LCB2E			brif not - draw another
LCB8A		dec V22D			compensate for "inc" above
		puls a,b,x,y,u,pc		restore registers and return
LCB8E		fcb $80,$40,$20,$10		pixels 0, 1, 2, 3 (left to right) in byte
		fcb $08,$04,$02,$01		pixels 4, 5, 6, 7 (left to right) in byte
LCB96		pshs a,x,u
		ldx V211
		ldu #V313
LCB9D		lda ,x+
		beq LCB9D
		bra LCBA5
LCBA3		lda ,x+
LCBA5		ble LCBAF
		sta ,u+
		cmpu #V333
		blo LCBA3
LCBAF		lda #$ff
		sta ,u+
		stx V211
		tst V313
		puls a,x,u,pc
LCBBA		clr V290
		ldx #LD96A
		bsr LCBEC
		bmi LCBC8
		beq LCBDF
		std V28E
		rts
LCBC8		dec V290
		ldx #LD8F3
		bsr LCBE7
		ble LCBDF
		std V28E
		ldx #LD96A
		bsr LCBEC
		ble LCBDF
		cmpb V28F
		bne LCBDF
		rts
LCBDF		leas 2,s
LCBE1		renderstrimmp
		fcb $17,$7b,$d0			packed "???" string
		rts
LCBE7		pshs a,b,x,y,u
		clra
		bra LCBF4
LCBEC		pshs a,b,x,y,u
		clra
		clrb
		bsr LCB96
		bmi LCC2D
LCBF4		clr V278
		clr V27B
		ldb ,x+
		stb V279
LCBFC		ldu #V313
		decodestrsb
		ldy #V335+1
LCC05		ldb ,u+
		bmi LCC17
		cmpb ,y+
		bne LCC22
		tst ,y
		bpl LCC05
		tst ,u
		bpl LCC22
LCC15		dec V27B
LCC17		tst V278
		bne LCC2B
		inc V278
		ldb V335
		std ,s
LCC22		inca
		dec V279
		bne LCBFC
		tst V278
		bne LCC2F
LCC2B		ldd V203
LCC2D		std ,s
LCC2F		puls a,b,x,y,u,pc
LCC31		ldx #LD8D9
		bsr LCBEC
		ble LCBDF
		ldu #V21F
		cmpa #1
		beq LCC46
		ldu #V21D
		cmpa #0
		bne LCBDF
LCC46		ldx ,u
		rts
LCC49		pshs a,b,x,u
		deca
		bsr LCC56
		inca
		bsr LCC56
		inca
		bsr LCC56
		puls a,b,x,u,pc
LCC56		pshs a,b
		decb
		bsr LCC60
		incb
		bsr LCC60
		incb
		skip2
LCC60		pshs a,b
		bsr LCC8E
		bne LCC6B
		bsr LCC7B
		lda ,x
		skip2
LCC6B		lda #$ff
		sta ,u+
		puls a,b,pc
LCC71		dod S07
		anda #$1f
		tfr a,b
		dod S07
		anda #$1f
LCC7B		pshs a,b
		anda #$1f
		andb #$1f
		tfr d,x
		ldb #$20
		mul
		addd #V5F4
		exg d,x
		abx
		puls a,b,pc
LCC8E		pshs a,b
		anda #$1f
		cmpa ,s
		bne LCC9A
		andb #$1f
		cmpb 1,s
LCC9A		puls a,b,pc
LCC9C		ldx #V5F4			get start address to set to $ff
		ldu #V9F4			get end address
		setblock			go set block to $ff
		ldx #LCD9F
		ldb V281
		abx
		ldd ,x++
		std V26B
		lda ,x
		sta V26D
		ldy #V1F4
		jsr LCC71
		std V27C
LCCBB		dod S07
		anda #3
		sta V28A
		dod S07
		anda #7
		inca
		sta V27E
		bra LCCD2
LCCCA		ldd V288
		std V27C
		dec V27E
		beq LCCBB
LCCD2		ldd V27C
		jsr LD11B
		bsr LCC8E
		bne LCCBB
		std V288
		tst ,x
		beq LCCCA
		ldu #V9F4
		jsr LCC49
		lda 3,u
		adda ,u
		adda 1,u
		beq LCCBB
		lda 1,u
		adda 2,u
		adda 5,u
		beq LCCBB
		lda 5,u
		adda 8,u
		adda 7,u
		beq LCCBB
		lda 7,u
		adda 6,u
		adda 3,u
		beq LCCBB
		clr ,x
		leay -1,y
		bne LCCCA
		clr V27C
		clr V27D
LCD11		ldd V27C
		jsr LCC7B
		lda ,x
		inca
		beq LCD41
		ldd V27C
		ldu #V9F4
		jsr LCC49
		lda ,x
		ldb #$ff
		cmpb 1,u
		bne LCD2D
		ora #3
LCD2D		cmpb 3,u
		bne LCD33
		ora #$c0
LCD33		cmpb 5,u
		bne LCD39
		ora #$0c
LCD39		cmpb 7,u
		bne LCD3F
		ora #$30
LCD3F		sta ,x
LCD41		ldb #$20
		inc V27D
		cmpb V27D
		bne LCD11
		clr V27D
		inc V27C
		cmpb V27C
		bne LCD11
		ldb #$46
		ldu #LCDAA
LC056		bsr LCD6D
		decb
		bne LC056
		ldb #$2d
		ldu #LCDAE
LCD60		bsr LCD6D
		decb
		bne LCD60
		ldb V297
LCD67		dod S07
		decb
		bne LCD67
		rts
LCD6D		pshs a,b,x,y,u
		ldy #LCDA6
LCD73		jsr LCC71
		std V288
		ldb ,x
		cmpb #$ff
		beq LCD73
		dod S07
		anda #3
		sta V28A
		bitb a,y
		bne LCD73
		orb a,u
		stb ,x
		ldd V288
		jsr LD11B
		ldb V28A
		addb #2
		andb #3
		lda ,x
		ora b,u
		sta ,x
		puls a,b,x,y,u,pc
LCD9F		fcb $73,$c7,$5d,$97
		fcb $f3,$13,$87
LCDA6		fcb $03,$0c,$30,$c0
LCDAA		fcb $01,$04,$10,$40
LCDAE		fcb $02,$08,$20,$80
LCDB2		ldu V20B
		ldd #$1f1f
		std V27C
LCDB9		ldd V27C
		bsr LCE11
		jsr LCC7B
		clrb
		lda ,x
		inca
		bne LCDC7
		decb
LCDC7		lda #6
LCDC9		stb ,y
		leay $20,y
		deca
		bne LCDC9
		dec V27D
		bpl LCDB9
		lda #$1f
		sta V27D
		dec V27C
		bpl LCDB9
		tst V294
		beq LCE2B
		clr V291
LCDE3		jsr LCF63
		beq LCDF7
		tst 5,x
		bne LCDE3
		ldd 2,x
		bsr LCE11
		ldd #8
		bsr LCE1D
		bra LCDE3
LCDF7		ldx #V3C3
LCDFA		leax $11,x
		cmpx #V5F4
		beq LCE2B
		tst 12,x
		beq LCDFA
		ldd 15,x
		bsr LCE11
		ldd #$1054
		bsr LCE1D
		bra LCDFA
LCE11		tfr d,y
		ldb #$c0
		mul
		addd ,u
		exg d,y
		leay b,y
		rts
LCE1D		sta $20,y
		stb $40,y
		stb $60,y
		sta $80,y
LCE2A		rts
LCE2B		ldd V213
		bsr LCE11
		ldd #$2418
		bsr LCE1D
		ldx V286
		bsr LCE38
LCE38		lda ,x+
		bmi LCE2A
		ldd ,x++
		bsr LCE11
		ldd #$3c24
		bsr LCE1D
		bra LCE38
LCE47		pshs a,x
		ldx #LCF48
		tst V273
		bne LCE5C
		leax >1,x
		tst V274
LCE56		bne LCE5C
		leax $fff5,x
LCE5C		lda V28B
		lda a,x
		sta V24F
		sta V250
		puls a,x,pc
LCE66		cleargfx2
		clr V28B
		ldd V213
		std V27C
LCE6E		bsr LCE47
		ldd V27C
		jsr LCC7B
		lda ,x
		ldu #V9F4
		ldx #4
LCE7D		tfr a,b
		andb #3
		stb 4,u
		stb ,u+
		lsra
		lsra
		leax -1,x
		bne LCE7D
		ldb V223
		ldu #V9F4
		leau b,u
		ldy #LDBDE
LCE96		lda ,y+
		bmi LCED8
		ldb a,u
		lslb
		cmpb #4
		bne LCEA9
		ldx b,y
		dec V275
		bsr LCECE
		ldb #6
LCEA9		ldx b,y
		bsr LCECE
		leay 8,y
		bra LCE96
LCEB1		rts
LCEB2		tfr x,y
		tst b,u
		bne LCEB1
		addb V223
		stb V28A
		ldd V27C
		jsr LD11B
		jsr LCF82
		beq LCEB1
		exg x,y
LCEC8		tst 2,y
		beq LCECE
		dec V275
LCECE		pshs u
		dod S00
		ldu V20B
		drawgraphic
		puls u,pc
LCED8		ldd V27C
		jsr LCF82
		beq LCEEB
		tfr x,y
		ldb 13,y
		lslb
		ldx #LDAA3
		ldx b,x
		bsr LCEC8
LCEEB		ldb #3
		ldx #LDCB0
		bsr LCEB2
		ldb #1
		ldx #LDCB9
		bsr LCEB2
		ldx #LDD3C
		ldd V27C
		jsr LCFE1
		bmi LCF09
		ldx #LDCC2
		lsla
		ldx a,x
LCF09		bsr LCECE
		clr V291
LCF0D		ldd V27C
		jsr LCF53
		beq LCF24
		lda 10,x
		lsla
		ldx #LD9EE
		ldx a,x
		dec V275
		bsr LCECE
		bsr LCECE
		bra LCF0D
LCF24		tst ,u
		bne LCF3D
		lda V223
		sta V28A
		ldd V27C
		jsr LD11B
		std V27C
		inc V28B
		lda V28B
		cmpa #9
		lble LCE6E
LCF3D		rts
LCF3E		fcb $c8,$80,$50,$32
		fcb $1f,$14
LCF44		fcb $0c,$08,$04,$02
LCF48		fcb $ff,$9c,$64,$41
		fcb $28,$1a,$10,$0a
LCF50		fcb $06,$03,$01
LCF53		bsr LCF63
		beq LCF62
		cmpd 2,x
		bne LCF53
		tst 5,x
		bne LCF53
		andcc #$fb
LCF62		rts
LCF63		pshs a
		lda V281
		ldx V292
		tst V291
		bne LCF72
		ldx #VB07
		dec V291
LCF72		leax 14,x
		stx V292
		cmpx V20F
		beq LCF80
		cmpa 4,x
		bne LCF72
		andcc #$fb
LCF80		puls a,pc
LCF82		ldx #V3C3
LCF85		leax $11,x
		cmpx #V5F4
		beq LCF96
		cmpd 15,x
		bne LCF85
		tst 12,x
		beq LCF85
LCF96		rts
LCF97		pshs a,b,x
LCF99		jsr LCC71
		std ,s
		lda ,x
		inca
		beq LCF99
		puls a,b,x,pc
LCFA5		pshs a,b,x,y,u
LCFA7		ldu #V3C3
LCFAA		leau $11,u
		tst 12,u
		bne LCFAA
		dec 12,u
		sta 13,u
		ldb #8
		mul
		addd #LDABB
		tfr d,y
		tfr u,x
		lda #8
		jsr LC04B
LCFC4		bsr LCF97
		bsr LCF82
		bne LCFC4
		std 15,u
		tfr u,x
		jsr LC25C
		stx 5,u
		ldd #LD041
		std 3,u
		lda 6,x
		ldb #4
		jsr LC21D
		puls a,b,x,y,u,pc
LCFE1		pshs a,b,x,u
		ldu V286
		bsr LCFF2
		tsta
		bpl LCFEE
		bsr LCFF2
		adda #2
LCFEE		sta ,s
		puls a,b,x,u,pc
LCFF2		lda ,u+
		bmi LCFFC
		ldx ,u++
		cmpx 2,s
		bne LCFF2
LCFFC		rts
LCFFD		fcb $80,$01,$00,$17
LD001		fcb $00,$0f,$04,$00
LD005		fcb $14,$11,$01,$1c
LD009		fcb $1e,$80,$01,$02
LD00D		fcb $03,$00,$03,$1f
LD011		fcb $00,$13,$14,$00
LD015		fcb $1f,$00,$80,$80
LD019		fcb $00,$00,$1f,$00
LD01D		fcb $05,$00,$00,$16
LD021		fcb $1c,$00,$1f,$10
LD025		fcb $80,$80
LD027		ldx V282
		ldb #11
		clra
LD02C		adda b,x
		decb
		bpl LD02C
		cmpa #$20
		bhs LD03D
		dod S07
		anda #7
		adda #2
		inc a,x
LD03D		ldd #$0508
		rts
LD041		ldy 5,u
		tst V22B
		bne LD06A
		ldb 12,y
		bne LD04D
		rts
LD04D		lda 13,y
		cmpa #6
		beq LD06D
		cmpa #10
		bge LD06D
		ldd 15,y
		clr V291
		jsr LCF53
		beq LD06D
		ldd 8,y
		stx 8,y
		std ,x
		dec 5,x
		dod S0E
LD06A		jmp LD103
LD06D		ldd 15,y
		cmpd V213
		bne LD0B2
		lda 13,y
		ldb #$ff
		playsound
		ldd #$8080
		ldx V21D
		bsr LD09E
		ldx V21F
		bsr LD09E
		sta V21A
		stb V21C
		tfr y,x
		ldu #V217
		jsr LD3D7
		bmi LD099
		playsoundimm $13
		jsr LD40C
LD099		dod S0C
		jmp LD10F
LD09E		pshs a,b,x
		beq LD0B0
		lda 10,x
		cmpa #3
		bne LD0B0
		ldx 6,x
		cmpx ,s
		bhs LD0B0
		stx ,s
LD0B0		puls a,b,x,pc
LD0B2		cmpa V213
		bne LD0C3
		lda 16,y
		ldb #1
		suba V214
		bmi LD0D0
		ldb #3
		bra LD0D0
LD0C3		ldd 15,y
		cmpb V214
		bne LD0E4
		ldb #2
		suba V213
		bmi LD0D0
		clrb
LD0D0		stb V28A
		ldd 15,y
LD0D4		bsr LD136
		bne LD0E4
		cmpd V213
		bne LD0D4
		ldb V28A
		stb 14,y
		clrb
		bra LD101
LD0E4		ldx #LD114
		dod S07
		tsta
		bmi LD0EE
		leax 3,x
LD0EE		anda #3
		bne LD0F4
		leax 1,x
LD0F4		lda #3
LD0F6		ldb ,x+
		bsr LD14F
		beq LD103
		deca
		bne LD0F6
		ldb #2
LD101		bsr LD14F
LD103		lda 6,y
		ldx 15,y
		cmpx V213
		bne LD111
		dod S0E
		clr V2B5
LD10F		lda 7,y
LD111		ldb #4
		rts
LD114		fcb $00,$03,$01,$00
		fcb $01,$03,$00		
LD11B		pshs a,b
		ldb V28A
		andb #3
		lslb
		ldx #LD12E
		ldd b,x
		adda ,s+
		addb ,s+
		jmp LCC7B
LD12E		fdb $ff00
		fdb 1
		fdb $100
		fdb $ff
LD136		pshs a,b,x,y,u
		bsr LD11B
		jsr LCC8E
		bne LD14D
		tfr d,u
		lda ,x
		inca
		beq LD14C
		stu ,s
		stx 2,s
		lda #1
LD14C		deca
LD14D		puls a,b,x,y,u,pc
LD14F		pshs a,b,x
		addb 14,y
		andb #3
		stb V28A
		ldd 15,y
		bsr LD136
		bne LD199
		jsr LCF82
		bne LD199
		std 15,y
		ldb V28A
		stb 14,y
		ldd 15,y
		suba V213
		bpl LD16F
		nega
LD16F		subb V214
		bpl LD174
		negb
LD174		stb V2C1
		cmpa V2C1
		bge LD17C
		exg a,b
LD17C		sta V2C1
		cmpa #8
		bgt LD198
		cmpb #2
		bgt LD198
		dod S07
		bita #1
		beq LD196
		lda V2C1
		ldb #$1f
		mul
		comb
		lda 13,y
		playsound
LD196		dec V2B5
LD198		clra
LD199		puls a,b,x,pc
LD19B		ldu V224
		beq LD1BC
		lda 6,u
		beq LD1BC
		deca
		sta 6,u
		cmpa #5
		bgt LD1B0
		ldb #$18
		stb 9,u
		clr 11,u
LD1B0		cmpa 7,u
		bge LD1B6
		sta 7,u
LD1B6		cmpa 8,u
		bge LD1BC
		sta 8,u
LD1BC		dec V2B5
		ldd #$0108
		rts
LD1C2		tst V2B5
		bne LD1CD
		ldx #LCDB2
		cmpx V2B2
		bne LD1D1
LD1CD		clr V2B5
		dod S0E
LD1D1		ldd #$0304
		rts
LD1D5		clra
		clrb
		subd V221
		jsr LD379
		addd V221
		bgt LD1E2
		clra
		clrb
LD1E2		std V221
		dod S0C
		lda V2AF
		ldb #2
		rts
LD1EB		tst V277
		bne LD21B
LD1EF		jsr LC329
		tsta
		beq LD248
		tst V228
		bne LD1EF
		cmpa #$20
		beq LD215
		ldb #$1f
		cmpa #$0d
		beq LD212
		ldb #$24
		cmpa #8
		beq LD212
		clrb
		cmpa #$41
		blo LD212
		cmpa #$5a
		bls LD215
LD212		tfr b,a
		skip2
LD215		anda #$1f
		bsr LD24C
		bra LD1EF
LD21B		ldy V20D			fetch pointer to command sequence
		ldb ,y+				do we have a command to do?
		bpl LD229			brif so
		delay				wait for a bit
		delay				wait for a bit more
		jmp START			go start over again with the splash and demo
LD229		ldx ,y++			get pointer to the word
		ldu #V361			point to command decode buffer
		decodestr			decode the keyword
		leau 1,u			move past the "object type" flag
		delay				wait a bit
		skip2				skip next instruction
LD235		bsr LD24C
		lda ,u+				fetch a character from the decoded string
		bpl LD235			brif not end of string
		clra				code for a space
		bsr LD24C			
		decb				have we consumed all the words in this command?
		bne LD229			brif not - get another
		lda #$1f			code for carriage return
		bsr LD24C
		sty V20D			save new command stream pointer
LD248		ldd #$0102
		rts
LD24C		pshs a,b,x,y,u
		tst V2AD
		bne LD256
		dod S19
		showprompt
LD256		ldu V211
		cmpa #$1f
		beq LD26F
		cmpa #$24
		beq LD27D
		renderchar
		sta ,u+
		ldx #LC67C
		renderstr
		cmpu #V311
		bne LD2B4
LD26F		clra
		renderchar
		ldd V203
		std ,u++
		ldu #V2F1
		stu V211
		bra LD292
LD27D		cmpu #V2F1
		beq LD2B4
		leau -1,u
		ldx #LD28C
		renderstr
		bra LD2B4
LD28C		fcb $00,$24,$24,$1c
		fcb $24,$ff
LD292		ldx #LD894
		jsr LCBEC
		beq LD2A7
		bpl LD2A1
		jsr LCBE1
		bra LD2A7
LD2A1		lsla
		ldx #LD9D0
		jsr [a,x]
LD2A7		ldu #V2F1
		tst V2AD
		beq LD2B4
		tst V228
		bne LD2B4
		showprompt
LD2B4		stu V211
		puls a,b,x,y,u,pc
LD2B8		jsr LCC31
		ldu ,u
		bne LD2C2
		ldu #VB07
LD2C2		tfr u,y
		lda 12,u
		sta V219
		lda 13,u
		sta V21B
		adda V219
		rora
		lsra
		lsra
		ldx V217
		jsr LD436
		addd V221
		std V221
		lda 10,u
		adda #12
		ldb #$ff
		playsound
		lda 9,u
		cmpa #$13
		blt LD2F7
		cmpa #$15
		bgt LD2F7
		dec 6,u
		bne LD2F7
		lda #$16
		sta 9,u
		jsr LD638
LD2F7		ldd V213
		jsr LCF82
		beq LD375
		ldu #V217
		exg x,u
		lda 10,y
		cmpa #1
		beq LD31F
		jsr LD3D7
		bmi LD375
		ldy V224
		beq LD319
		lda 9,y
		cmpa #$18
		bne LD31F
LD319		dod S07
		anda #3
		bne LD375
LD31F		playsoundimm $12
		renderstrimmp
		fcb $16,$f7,$b0			packed "!!!" string
		jsr LD40C
		bhi LD375
		leax 8,u
LD32E		ldx ,x
		beq LD33A
		clr 5,x
		ldd 15,u
		std 2,x
		bra LD32E
LD33A		ldx V282
		ldb 13,u
		dec b,x
		clr 12,u
		dod S0E
		playsoundimm $15
		ldd ,u
		bsr LD37F
		addd V217
		bpl LD351
		lda #$7f
LD351		std V217
		lda 13,u
		cmpa #10
		beq LD386
		cmpa #11
		bne LD375
		dec V22B
		ldd #$713
		std V226
		ldx #$b23
		stx V20F
		ldd V200
		std V229
		std V224
		std V21F
		std V21D
		dod S19
LD375		dod S0C
LD377		asra
		rorb
LD379		asra
		rorb
LD37B		asra
		rorb
LD37D		asra
		rorb
LD37F		asra
		rorb
LD381		asra
		rorb
LD383		asra
		rorb
		rts
LD386		ldx #LDF10
		fadeinclrst
		renderstrimmp
		fcb $ff,$c0,$57,$3e		packed string "ENOUGH! I TIRE OF THIS PLAY..."
		fcb $a7,$46,$c0,$90
		fcb $51,$32,$28,$1e
		fcb $60,$51,$09,$98
		fcb $20,$c0,$e7,$de
		fcb $f0
		renderstrimmp
		fcb $e8,$00,$08,$48		packed string "PREPARE TO MEET THY DOOM!!!"
		fcb $b0,$0c,$8a,$0a
		fcb $3c,$0d,$29,$68
		fcb $0a,$23,$20,$23
		fcb $de,$dd,$ef,$60
		delay
		ldu V224
		stu V229
		beq LD3C4
		clra
		clrb
		std ,u
LD3C4		ldd #200
		std V215
		lda #3
		dod S1A
		jsr LCF97
		std V213
		fadeout
		dod S19
		rts
LD3D7		pshs a,b,x,u
		lda #15
		sta V2C1
		ldd ,u
		subd 10,u
		jsr LCA12
LD3E4		subd ,x
		bcs LD3EC
		dec V2C1
		bne LD3E4
LD3EC		ldb V2C1
		subb #3
		bpl LD3FB
		negb
		lda #$19
		mul
		jsr LCA99
		bra LD3FE
LD3FB		lda #10
		mul
LD3FE		std ,--s
		dod S07
		tfr a,b
		clra
		addd ,s++
		subd #$7f
		puls a,b,x,u,pc
LD40C		pshs a,b,x,y,u
		tfr x,y
		ldx ,y
		lda 2,y
		bsr LD436
		tfr d,x
		lda 3,u
		bsr LD436
		addd 10,u
		std 10,u
		ldx ,y
		lda 4,y
		bsr LD436
		tfr d,x
		lda 5,u
		bsr LD436
		addd 10,u
		std 10,u
		ldx ,u
		cmpx 10,u
		puls a,b,x,y,u,pc
LD436		pshs a,b,x
		clr V2C1
		ldb 3,s
		mul
		std V2C2
		lda ,s
		ldb 2,s
		mul
		addd V2C1
		lsl V2C3
		rolb
		rola
		std ,s
		puls a,b,x,pc
LD44E		ldd V213
		jsr LCFE1
		bmi LD46F
		sta V2C1
		ldx #LD8D9
		jsr LCBEC
		ble LD46F
		ldb V2C1
		cmpa #4
		beq LD472
		cmpa #5
		bne LD46F
		lda #1
		bitb #2
		bne LD478
LD46F		jmp LCBE1
LD472		lda #$ff
		cmpb #1
		bne LD46F
LD478		dod S16
		adda V281
		dod S1A
		dod S19
		rts
LD481		ldx #LD495
		stx V2B2
		dod S0E
		rts
LD489		cleargfx2
		ldx ,u
		ldu #V380
		stx ,u
		dec V2B7
		rts
LD495		bsr LD489
		clr V2B6
		ldd #10
		std 4,u
		renderstrimmp
		fcb $62,$5c,$0a,$21		packed string "IN THIS ROOM"
		fcb $33,$04,$9e,$f6
		fcb $fc
		ldd V213
		jsr LCF82
		beq LD4C0
		ldx 4,u
		leax 11,x
		stx 4,u
		renderstrimmp
		fcb $56,$c7,$22,$86		packed string "!CREATURE!"
		fcb $95,$91,$77,$f0
LD4C0		clr V291
LD4C2		ldd V213
		jsr LCF53
		beq LD4CD
		bsr LD505
		bra LD4C2
LD4CD		tst V2B6
		beq LD4D3
		bsr LD4FE
LD4D3		ldd #$1b20
LD4D6		renderchar
		decb
		bne LD4D6
		ldx 4,u
		leax 12,x
		stx 4,u
		renderstrimmp
		fcb $40,$82,$35,$c0		packed string "BACKPACK"
		fcb $23,$5f,$c0
		ldx #V229
LD4ED		ldx ,x
		beq LD4FB
		cmpx V224
		bne LD4F7
		com 6,u
LD4F7		bsr LD505
		bra LD4ED
LD4FB		clr V2B7
		rts
LD4FE		lda #$1f
		renderchar
		clr V2B6
		rts
LD505		pshs a,b,x
		jsr LC617
		renderstr
		lda V22C
		sta 6,u
		com V2B6
		beq LD51E
		ldd 4,u
		addd #$10
		andb #$f0
		std 4,u
		skip2
LD51E		bsr LD4FE
		puls a,b,x,pc
LD522		bsr LD576
		bne LD573
		jsr LCBBA
		clr V291
LD52B		ldd V213
		jsr LCF53
		beq LD573
		tst V290
		bne LD53C
		lda 10,x
		cmpa V28F
		bra LD540
LD53C		lda 9,x
		cmpa V28E
LD540		bne LD52B
		stx ,u
		inc 5,x
		ldb 10,x
		ldx #LD9FA
		ldb b,x
		clra
		bra LD56B
LD550		bsr LD576
		beq LD573
		clra
		clrb
		std ,u
		clr 5,x
		ldd V213
		std 2,x
		lda V281
		sta 4,x
		ldb 10,x
		ldx #LD9FA
		ldb b,x
		negb
		sex
LD56B		addd V215
		std V215
		dod S0C
		bra LD5B7
LD573		jmp LCBE1
LD576		jmp LCC31
LD579		bsr LD576
		beq LD573
LD57D		ldd V229
		std ,x
		stx V229
		clra
		clrb
		std ,u
		bra LD5B7
LD589		bsr LD576
		bne LD573
		jsr LCBBA
		ldx #V229
LD593		tfr x,y
		ldx ,x
		beq LD573
		tst V290
		bne LD5A3
		lda 10,x
		cmpa V28F
		bra LD5A7
LD5A3		lda 9,x
		cmpa V28E
LD5A7		bne LD593
		ldd ,x
		std ,y
		stx ,u
LD5AF		clra
		clrb
		cmpx V224
		bne LD5B7
		std V224
LD5B7		dod S0D
		dod S0E
		rts
LD5BC		ldx #LD8F3
		jsr LCBEC
		ble LD5EF
		tst V27B
		beq LD5EF
		std V28E
		ldu V21D
		bsr LD5D0
		ldu V21F
LD5D0		beq LD5EF
		lda 10,u
		cmpa #1
		bne LD5EF
		lda 7,u
		beq LD5EF
		cmpa V28E
		bne LD5EF
		sta 9,u
		dod S18
		playsoundimm $0D
		dod S0D
		clr 7,u
		cmpa #$12
		beq LD5F0
LD5EF		rts
LD5F0		ldx #LDF39
		dec V29E
		fadeinclrst
		renderstrimmp
		fcb $ff,$c4,$54,$3d		packed string victory message line 1
		fcb $84,$d8,$08,$59
		fcb $D1,$2e,$c8,$03
		fcb $70,$a6,$93,$05
		fcb $10,$50,$20,$2e
		fcb $20
		renderstrimmp
		fcb $c8,$00,$00,$00		packed string victory message line 2
		fcb $00,$03,$cc,$00
		fcb $81,$c5,$b8,$2e
		fcb $9d,$06,$44,$f7
		fcb $bc
LD621		bra LD621
LD623		jsr LCC31
		ldu ,u
		beq LD63E
		lda 11,u
		beq LD63E
		ldb #$19
		mul
		cmpd V217
		bgt LD63E
		lda 9,u
LD638		dod S18
		clr 11,u
		dod S0D
LD63E		rts
LD63F		ldx #LD8D9
		jsr LCBEC
		ble LD693
		ldb V223
		cmpa #0
		bne LD654
		decb
		bsr LD66D
		bsr LD674
		bra LD669
LD654		cmpa #1
		bne LD65D
		incb
		bsr LD66D
		bra LD667
LD65D		cmpa #3
		bne LD693
		addb #2
		bsr LD66D
		bsr LD684
LD667		bsr LD684
LD669		dec V2B4
		sync
		rts
LD66D		andb #3
		stb V223
		jmp LC660
LD674		bsr LD696
		bne LD683
		ldd #8
LD67B		bsr LD6BA
		addd #$20
		tsta
		beq LD67B
LD683		rts
LD684		bsr LD696
		bne LD692
		ldd #$f8
LD68B		bsr LD6BA
		subd #$20
		bpl LD68B
LD692		rts
LD693		jmp LCBE1
LD696		ldu V2B2
		cmpu #LCE66
		bne LD6B9
		ldx #$8080
		stx V24F
		clr V28B
		dod S00
		cleargfx1
		ldx #LD6C6
		drawgraphic
		ldx #$11
		stx ybeg
		ldx #$87
		stx yend
		clra
LD6B9		rts
LD6BA		std xbeg
		std xend
		bsr LD6C0
LD6C0		jsr drawline
		com V22C
		rts
LD6C6		fcb $10,$00,$10,$ff
		fcb $ff,$88,$00,$88
		fcb $ff,$fe
LD6D0		ldx #LD8D9
		jsr LCBEC
		blt LD693
		bgt LD6E3
		dec V273
		dod S0E
		clrb
		clr V273
		bra LD6EF
LD6E3		cmpa #2
		bne LD6F3
		dec V274
		dod S0E
		ldb #2
		clr V274
LD6EF		bsr LD720
		bra LD70E
LD6F3		cmpa #1
		bne LD701
		ldb #1
		bsr LD720
		bne LD70E
		bsr LD684
		bra LD70E
LD701		cmpa #0
		bne LD693
		ldb #3
		bsr LD720
		bne LD70E
		jsr LD674
LD70E		ldd V215
		jsr LD37F
		addd #3
		addd V221
		std V221
		dod S0C
		dec V2B4
		sync
		rts
LD720		pshs a,b
		clr ,-s
		addb V223
		andb #3
		stb V28A
		ldd V213
		jsr LD136
		beq LD738
		playsoundimm $14
		dec ,s
		ldd V213
LD738		std V213
		jsr LC660
		tst ,s+
		puls a,b,pc
LD741		jsr LCC31
		beq LD767
		ldd 9,x
		cmpb #5
		bne LD757
		stx V224
		jsr LD57D
		playsoundimm $11
		dod S0E
		rts
LD757		tfr x,u
		ldx #LD76B
LD75C		cmpa ,x
		beq LD768
		leax 3,x
		cmpx #LD77A
		blo LD75C
LD767		rts
LD768		jmp [1,x]
LD76B		fcb $05
		fdb LD77A
		fcb $09
		fdb LD783
		fcb $08
		fdb LD787
		fcb $04
		fdb LD7A2
		fcb $07
		fdb LD7A0
LD77A		ldd #V3E8
		addd V217
		std V217
		bra LD792
LD783		clra
		clrb
		bra LD790
LD787		ldx V217
		lda #$66
		jsr LD436
		addd V221
LD790		std V221
LD792		ldb #$17
		stb 9,u
		clr 11,u
		playsoundimm $0c
		dod S0D
		dod S0C
		rts
LD7A0		clra
		skip2
LD7A2		lda #$ff
		sta V294
		tst 11,u
		bne LD7B6
		playsoundimm $0e
		clr V2AD
		ldx #LCDB2
		stx V2B2
		dod S0E
LD7B6		rts
LD7B7		bsr LD7BC
		dec V2B8
		rts
LD7BC		ldx #V313			get start address to set to $ff
		leau $20,x			set $20 bytes
		setblock			go clear block to $ff
		jmp LCB96
LD7C7		bsr LD7BC
		stx CBUFAD
		ldd #$0f
		std BLKTYP
		inc V2B8
		rts
LD7D5		fcb $0d,$0f,$10,$ff
LD7D9		fcb $11,$0f
		fcb $ff
LD7DC		fdb LD1EB
		fdb LD1C2
		fdb LD1D5
		fdb LD19B
		fdb LD027
		fdb 0
; cold start variable initializers
LD7E8		fcb 12
		fdb $103
		jmp LC371
		jmp LC352
		jmp LC27D
		jmp LC27D
		fcb $17
		fdb V202
		fcb $01				V202
		fdb $ffff			V203 - 16 bit all ones value, or -1
		fcb $00				V205
		fcb $80				V206
		fcb 0				V207
		fcb $4c				V208
		fdb LD870			V209 - pointer to primary display screen info
		fdb LD876			V20B - pointer to secondary display screen info
		fdb LD988			V20D - pointer to demo game command sequence
		fdb VB15			V20F
		fdb V2F1			V211
		fcb $0c				V213
		fcb $16				V214
		fdb $23				V215
		fdb $17a0			V217
		fcb $54	
		fdb V380
		fdb $1000			V380 - text area starts at top of screen
		fdb $0260			V382 - text area ends after 19 lines
		fdb 0				V384 - text cursor position at top of screen
		fcb 0				V386 - black background
		fcb $ff				V387 - do not render on secondary screen
		fdb $2300			V388 - text area starts at row 19 on screen
		fdb $40				V38A - text area goes for two lines
		fdb 0				V38C - text cursor is at top of area
		fcb $ff				V38E - background is white
		fcb 0				V38F - do render on secondary screen
		fdb $2400			V390 - text area starts at row 20 on screen
		fdb $80				V392 - text area goes for four lines
		fdb 0				V394 - text cursor is at top of area
		fcb 0				V396 - background is black
		fcb 0				V397 - do render on secondary screen
		fcb $09,$09,$04,$02
		fcb $00,$00,$00,$00
		fcb $00,$00,$00,$00
		fcb $02,$04,$00,$06
		fcb $06,$06,$00,$00
		fcb $00,$00,$00,$00
		fcb $00,$00,$00,$04
		fcb $00,$06,$08,$04
		fcb $00,$00,$01,$00
		fcb $00,$00,$00,$00
		fcb $00,$00,$08,$06
		fcb $06,$04,$00,$00
		fcb $02,$02,$02,$02
		fcb $02,$02,$02,$04
		fcb $04,$08,$00,$01
		fcb 4
		fdb VB11
		fcb $04,$00,$00,$05
		fcb 0

; these tables are used for clearing and otherwise setting up the graphics screens
LD870		fdb $1000			primary screen start address
		fdb $2300			primary screen gfx area end address
		fdb $2046			primary screen SAM register value
LD876		fdb $2800			secondary screen start address
		fdb $3b00			secondary screen gfx area end address
		fdb $20a6			secondary screen SAM register value
LD87C		fdb $2300			start address of status line on first screen
		fdb $2400			end address of status line on first screen
		fdb 0				dummy (SAM regster setting)
		fdb $3b00			start address of status line on second screen
		fdb $3c00			end address of status line on second screen
		fdb 0				dummy (SAM register setting)
LD888		fdb $2400			start address of command area on first screen
		fdb $2800			end address of command area on first screen
		fdb 0				dummy (SAM register setting)
		fdb $3c00			start address of command area on second screen
		fdb $4000			end address of command area on second screen
		fdb 0				dummy (SAM register setting)

; This is the keyword table used for command parsing. Each keyword is stored in packed format.
; Each keyword is preceded by a value which indicates the object type. Where the object type is
; not relevant, that value will be zero. The value is shown in parentheses below.
LD894		fcb 15				15 keywords in the command list
LD895		fcb $30,$03,$4a,$04,$6b		"ATTACK" keyword
		fcb $28,$06,$c4,$b4,$40		"CLIMB" keyword
		fcb $20,$09,$27,$c0		"DROP" keyword
LD8A3		fcb $38,$0b,$80,$b5,$2e,$28	"EXAMINE" keyword
		fcb $18,$0e,$5a,$00		"GET" keyword
		fcb $30,$12,$e1,$85,$d4		"INCANT" keyword
LD8B2		fcb $20,$18,$f7,$ac		"LOOK" keyword
LD8B6		fcb $20,$1A,$fb,$14		"MOVE" keyword
LD8BA		fcb $20,$21,$56,$30		"PULL" keyword
		fcb $30,$24,$5b,$14,$2c		"REVEAL" keyword
		fcb $20,$27,$47,$dc		"STOW" keyword
LD8C7		fcb $20,$29,$59,$38		"TURN" keyword
LD8CB		fcb $18,$2b,$32,$80		"USE" keyword
		fcb $28,$34,$c7,$84,$80		"ZLOAD" keyword
		fcb $28,$35,$30,$d8,$a0		"ZSAVE" keyword
LD8D9		fcb 6				6 keywords in direction list
LD8DA		fcb $20,$18,$53,$50		"LEFT" keyword
LD8DE		fcb $28,$24,$93,$a2,$80		"RIGHT" keyword
		fcb $20,$04,$11,$ac		"BACK" keyword
		fcb $30,$03,$27,$d5,$c4		"AROUND" keyword		
		fcb $10,$2b,$00			"UP" keyword
		fcb $20,$08,$fb,$b8		"DOWN" keyword
LD8F3		fcb 25				25 keywords in the misc keywords list
LD8F4		fcb $38,$67,$58,$48,$ad,$28	"SUPREME" keyword (1)
		fcb $28,$54,$fa,$b0,$a0		"JOULE" keyword (1)
		fcb $31,$0a,$cb,$26,$68		"ELVISH" keyword (4)
		fcb $38,$da,$9a,$22,$49,$60	"MITHRIL" keyword (3)
		fcb $20,$a6,$52,$c8		"SEER" keyword (2)
		fcb $28,$28,$82,$de,$60		"THEWS" keyword (0)
		fcb $20,$64,$96,$94		"RIME" keyword (1)
		fcb $30,$ac,$99,$a5,$ee		"VISION" keyword (2)
		fcb $20,$02,$2c,$94		"ABYE" keyword (0)
		fcb $20,$10,$16,$14		"HALE" keyword (0)
		fcb $29,$66,$f6,$06,$40		"SOLAR" keyword (5)
		fcb $30,$c5,$27,$bb,$45		"BRONZE" keyword (3)
		fcb $30,$6d,$56,$0c,$2e		"VULCAN" keyword (1)
		fcb $21,$13,$27,$b8		"IRON" keyword (4)
		fcb $29,$59,$57,$06,$40		"LUNAR" keyword (5)
		fcb $21,$60,$97,$14		"PINE" keyword (5)
		fcb $38,$d8,$50,$d1,$05,$90	"LEATHER" keyword (3)
		fcb $31,$2e,$f7,$90,$ae		"WOODEN" keyword (4)
		fcb $28,$4c,$97,$05,$80		"FINAL" keyword (1)
		fcb $30,$4a,$e2,$c8,$f9		"ENERGY" keyword (1)
		fcb $18,$52,$32,$80		"ICE" keyword (1)
		fcb $20,$4c,$99,$14		"FIRE" keyword (1)
		fcb $20,$4e,$f6,$10		"GOLD" keyword (1)
		fcb $28,$0a,$d8,$53,$20		"EMPTY" keyword (0)
		fcb $21,$48,$50,$90		"DEAD" keyword (5)
LD96A		fcb 6				6 object types in the following list
LD96B		fcb $28,$0c,$c0,$cd,$60		"FLASK" keyword (0)
		fcb $20,$64,$97,$1c		"RING" keyword (1)
		fcb $30,$a6,$39,$3d,$8c		"SCROLL" keyword (2)
LD979		fcb $30,$e6,$84,$95,$84		"SHIELD" keyword (3)
LD97E		fcb $29,$27,$77,$c8,$80		"SWORD" keyword (4)
LD983		fcb $29,$68,$f9,$0d,$00		"TORCH" keyword (5)
; The following is the sequence of commands used in the demo game
LD988		fcb 1				EXAMINE
		fdb LD8A3
		fcb 3				PULL RIGHT TORCH
		fdb LD8BA
		fdb LD8DE
		fdb LD983
		fcb 2				USE RIGHT
		fdb LD8CB
		fdb LD8DE
		fcb 1				LOOK
		fdb LD8B2
		fcb 1				MOVE
		fdb LD8B6
		fcb 3				PULL LEFT SHIELD
		fdb LD8BA
		fdb LD8DA
		fdb LD979
		fcb 3				PULL RIGHT SWORD
		fdb LD8BA
		fdb LD8DE
		fdb LD97E
		fcb 1				MOVE
		fdb LD8B6
		fcb 1				MOVE
		fdb LD8B6
		fcb 2				ATTACK RIGHT
		fdb LD895
		fdb LD8DE
		fcb 2				TURN RIGHT
		fdb LD8C7
		fdb LD8DE
		fcb 1				MOVE
		fdb LD8B6
		fcb 1				MOVE
		fdb LD8B6
		fcb 1				MOVE
		fdb LD8B6
		fcb 2				TURN RIGHT
		fdb LD8C7
		fdb LD8DE
		fcb 1				MOVE
		fdb LD8B6
		fcb 1				MOVE
		fdb LD8B6
		fcb $ff
; jump table for commands
LD9D0		fdb LD2B8			ATTACK
		fdb LD44E			CLIMB
		fdb LD550			DROP
		fdb LD481			EXAMINE
		fdb LD522			GET
		fdb LD5BC			INCANT
		fdb LC751			LOOK
		fdb LD6D0			MOVE
		fdb LD589			PULL
		fdb LD623			REVEAL
		fdb LD579			STOW
		fdb LD63F			TURN
		fdb LD741			USE
		fdb LD7B7			ZLOAD
		fdb LD7C7			ZSAVE

LD9EE		fdb LDC19
		fdb LDC21
		fdb LDC2A
		fdb LDBFA
		fdb LDC0F
		fdb LDC07

LD9FA		fcb $05,$01

LD9FC		fcb $0A,$19,$19,$0A
LDA00		fcb $01,$FF,$00,$05
LDA04		fcb $01,$AA,$00,$05
LDA08		fcb $04,$96,$40,$40
LDA0C		fcb $03,$8C,$0D,$1A
LDA10		fcb $02,$82,$00,$05
LDA14		fcb $00,$46,$00,$05
LDA18		fcb $01,$34,$00,$05
LDA1C		fcb $02,$32,$00,$05
LDA20		fcb $00,$30,$00,$05
LDA24		fcb $00,$28,$00,$05
LDA28		fcb $05,$46,$00,$05
LDA2C		fcb $03,$19,$00,$1A
LDA30		fcb $01,$0D,$00,$05
LDA34		fcb $04,$0D,$00,$28
LDA38		fcb $05,$19,$00,$05
LDA3C		fcb $05,$05,$00,$05
LDA40		fcb $03,$05,$00,$0A
LDA44		fcb $04,$05,$00,$10
LDA48		fcb $01,$00,$00,$00
LDA4C		fcb $01,$00,$FF,$FF
LDA50		fcb $01,$00,$FF,$FF
LDA54		fcb $01,$00,$FF,$FF
LDA58		fcb $01,$00,$00,$05
LDA5C		fcb $00,$00,$00,$05
LDA60		fcb $05,$05,$00,$05
LDA64		fcb $00,$03,$12,$00
LDA68		fcb $01,$03,$13,$00
LDA6C		fcb $03,$40,$40,$00
LDA70		fcb $06,$03,$14,$00
LDA74		fcb $0A,$3C,$0D,$0B
LDA78		fcb $0B,$60,$80,$00
LDA7C		fcb $0C,$03,$15,$00
LDA80		fcb $0E,$1E,$0A,$04
LDA84		fcb $0F,$0F,$07,$00
LDA88		fcb $10,$6C,$80,$00
LDA8C		fcb $18,$00,$00,$00
LDA90		fcb $FF

LDA91		fcb $41,$31,$31

LDA94		fcb $32,$23,$23,$11
LDA98		fcb $13,$16,$14,$14
LDA9C		fcb $16,$01,$04,$08
LDAA0		fcb $08,$03,$04

LDAA3		fcb $DE

LDAA4		fcb $26,$DF,$CA,$DD
LDAA8		fcb $41,$DE,$59,$DE
LDAAC		fcb $82,$DD,$51,$DE
LDAB0		fcb $3F,$DE,$9D,$DE
LDAB4		fcb $07,$DD,$A3,$DF
LDAB8		fcb $65,$DF,$10

LDABB		fcb $00

LDABC		fcb $20,$00,$FF,$80
LDAC0		fcb $FF,$17,$0B,$00
LDAC4		fcb $38,$00,$FF,$50
LDAC8		fcb $80,$0F,$07,$00
LDACC		fcb $C8,$00,$FF,$34
LDAD0		fcb $C0,$1D,$17,$01
LDAD4		fcb $30,$00,$FF,$60
LDAD8		fcb $A7,$1F,$1F,$01
LDADC		fcb $F8,$00,$80,$60
LDAE0		fcb $3C,$0D,$07,$02
LDAE4		fcb $C0,$00,$80,$80
LDAE8		fcb $30,$11,$0D,$01
LDAEC		fcb $90,$FF,$80,$FF
LDAF0		fcb $80,$05,$04,$03
LDAF4		fcb $20,$00,$40,$FF
LDAF8		fcb $08,$0D,$07,$03
LDAFC		fcb $20,$C0,$10,$C0
LDB00		fcb $08,$03,$03,$03
LDB04		fcb $E8,$FF,$05,$FF
LDB08		fcb $03,$04,$03,$03
LDB0C		fcb $E8,$FF,$06,$FF
LDB10		fcb $00,$0D,$07,$1F
LDB14		fcb $40,$FF,$06,$FF
LDB18		fcb $00,$0D,$07

; This is the text font - these values are in packed format
LDB1B		fcb $30,$00,$00,$00,$00		char code 0 - space
		fcb $31,$15,$18,$fe,$31		char code 1 - A
		fcb $37,$a3,$1f,$46,$3e		char code 2 - B
		fcb $33,$a3,$08,$42,$2e		char code 3 - C
		fcb $37,$a3,$18,$c6,$3e		char code 4 - D	
		fcb $37,$e1,$0f,$42,$1f		char code 5 - E
		fcb $37,$e1,$0f,$42,$10		char code 6 - F
		fcb $33,$e3,$08,$4e,$2f		char code 7 - G
		fcb $34,$63,$1f,$c6,$31		char code 8 - H
		fcb $33,$88,$42,$10,$8e		char code 9 - I
		fcb $30,$42,$10,$86,$2e		char code 10 - J
		fcb $34,$65,$4c,$52,$51		char code 11 - K
		fcb $34,$21,$08,$42,$1f		char code 12 - L
		fcb $34,$77,$5a,$d6,$31		char code 13 - M
		fcb $34,$63,$9a,$ce,$31		char code 14 - N
		fcb $33,$a3,$18,$c6,$2e		char code 15 - O
		fcb $37,$a3,$1f,$42,$10		char code 16 - P
		fcb $33,$a3,$18,$d6,$4d		char code 17 - Q
		fcb $37,$a3,$1f,$52,$51		char code 18 - R
		fcb $33,$a3,$07,$06,$2e		char code 19 - S
		fcb $37,$ea,$42,$10,$84		char code 20 - T
		fcb $34,$63,$18,$c6,$2e		char code 21 - U
		fcb $34,$63,$15,$28,$84		char code 22 - V
		fcb $34,$63,$1a,$d7,$71		char code 23 - W
		fcb $34,$62,$a2,$2a,$31		char code 24 - X
		fcb $34,$62,$a2,$10,$84		char code 25 - Y
		fcb $37,$c2,$22,$22,$1f		char code 26 - Z
		fcb $31,$08,$42,$10,$04		char code 27 - !
		fcb $30,$00,$00,$00,$1f		char code 28 - underscore
		fcb $33,$a2,$13,$10,$04		char code 29 - ?
		fcb $30,$00,$00,$00,$04		char code 30 - .
; some special glyphs
LDBB6		fcb $00,$00,$01,$01,$00,$00,$00	char code 32 - left part of contracted heart
		fcb $00,$a0,$f0,$f0,$e0,$40,$00	char code 33 - right part of contracted heart
		fcb $00,$01,$03,$03,$01,$00,$00	char code 34 - left half of expanded heart
		fcb $00,$b0,$f8,$f8,$f0,$e0,$40	char code 35 - right part of expanded heart

LDBD2		fcb $00,$80

LDBD4		fcb $00,$01,$00,$50
LDBD8		fcb $00,$04

LDBDA		fcb $00,$50

LDBDC		fcb $00,$05

LDBDE		fcb $03,$DC

LDBE0		fcb $4F,$DC,$6B,$DC
LDBE4		fcb $9B,$DC,$33,$00
LDBE8		fcb $DC,$6A,$DC,$8B
LDBEC		fcb $DC,$A9,$DC,$45
LDBF0		fcb $01,$DC,$5D,$DC
LDBF4		fcb $7B,$DC,$A2,$DC
LDBF8		fcb $3C,$FF

LDBFA		fcb $86,$AC

LDBFC		fcb $80,$C0,$7A,$BA
LDC00		fcb $80,$A8,$FC,$3E
LDC04		fcb $04,$00,$FE

LDC07		fcb $76

LDC08		fcb $3C,$FC,$F7,$FF
LDC0C		fcb $2A,$00,$FE

LDC0F		fcb $72

LDC10		fcb $50,$7C,$64,$FF
LDC14		fcb $76,$52,$72,$56
LDC18		fcb $FE

LDC19		fcb $6E,$A2,$FC

LDC1C		fcb $51,$0E,$B1,$00
LDC20		fcb $FE

LDC21		fcb $7A,$3C,$FC

LDC24		fcb $11,$1F,$FF,$F1
LDC28		fcb $00,$FE

LDC2A		fcb $76,$C2

LDC2C		fcb $FC,$1F,$34,$F1
LDC30		fcb $DC,$00,$FE,$10
LDC34		fcb $1B,$26,$40,$72
LDC38		fcb $40,$88,$1B,$FE
LDC3C		fcb $10,$E5,$26,$C0
LDC40		fcb $72,$C0,$88,$E5
LDC44		fcb $FE,$26,$40,$26
LDC48		fcb $C0,$FF,$72,$40
LDC4C		fcb $72,$C0,$FE,$26
LDC50		fcb $1D,$26,$40,$72
LDC54		fcb $40,$72,$1B,$FF
LDC58		fcb $10,$1B,$26,$40
LDC5C		fcb $FE,$26,$E5,$26
LDC60		fcb $C0,$72,$C0,$72
LDC64		fcb $E5,$FF,$10,$E5
LDC68		fcb $26,$C0,$FE,$80
LDC6C		fcb $28,$41,$28,$44
LDC70		fcb $38,$77,$38,$FF
LDC74		fcb $5C,$30,$5D,$34
LDC78		fcb $FD,$DC,$33,$80
LDC7C		fcb $D8,$41,$D8,$44
LDC80		fcb $C8,$77,$C8,$FF
LDC84		fcb $5C,$D0,$5D,$CC
LDC88		fcb $FD,$DC,$3C,$72
LDC8C		fcb $6C,$43,$6C,$43
LDC90		fcb $94,$72,$94,$FF
LDC94		fcb $5E,$7E,$5E,$82
LDC98		fcb $FD,$DC,$45,$80
LDC9C		fcb $28,$42,$32,$75
LDCA0		fcb $3A,$FE,$80,$D8
LDCA4		fcb $42,$CE,$75,$C6
LDCA8		fcb $FE,$71,$6C,$43
LDCAC		fcb $80,$72,$94,$FE
LDCB0		fcb $64,$1C,$FC,$44
LDCB4		fcb $2E,$42,$4C,$00
LDCB8		fcb $FE

LDCB9		fcb $64,$E4,$FC

LDCBC		fcb $4C,$22,$4E,$44
LDCC0		fcb $00,$FE

LDCC2		fcb $DD,$0E

LDCC4		fcb $DC,$CA,$DD,$2A
LDCC8		fcb $DC,$D0,$FB,$DC
LDCCC		fcb $D6,$FD,$DD,$0E
LDCD0		fcb $FB,$DC,$D6,$FD
LDCD4		fcb $DD,$2A,$18,$74
LDCD8		fcb $80,$74,$FF,$18
LDCDC		fcb $8C,$80,$8C,$FF
LDCE0		fcb $1C,$74,$1C,$8C
LDCE4		fcb $FF,$28,$74,$28
LDCE8		fcb $8C,$FF,$34,$74
LDCEC		fcb $34,$8C,$FF,$40
LDCF0		fcb $74,$40,$8C,$FF
LDCF4		fcb $4C,$74,$4C,$8C
LDCF8		fcb $FF,$58,$74,$58
LDCFC		fcb $8C,$FF,$64,$74
LDD00		fcb $64,$8C,$FF,$70
LDD04		fcb $74,$70,$8C,$FF
LDD08		fcb $7B,$74,$7B,$8C
LDD0C		fcb $FF,$FA,$22,$64
LDD10		fcb $18,$5C,$18,$A4
LDD14		fcb $22,$9C,$22,$64
LDD18		fcb $18,$64,$FF,$22
LDD1C		fcb $9C,$18,$9C,$FF
LDD20		fcb $1C,$2F,$1C,$60
LDD24		fcb $FF,$1C,$A1,$1C
LDD28		fcb $D2,$FE,$76,$64
LDD2C		fcb $80,$5C,$80,$A4
LDD30		fcb $76,$9C,$76,$64
LDD34		fcb $80,$64,$FF,$76
LDD38		fcb $9C,$80,$9C,$FF
LDD3C		fcb $1C,$2F,$1C,$D2
LDD40		fcb $FE,$68,$62,$FC
LDD44		fcb $D7,$D4,$14,$12
LDD48		fcb $30,$1D,$0D,$FD
LDD4C		fcb $29,$00,$FD,$DD
LDD50		fcb $62,$68,$62,$5E
LDD54		fcb $7C,$60,$7E,$6A
LDD58		fcb $64,$FF,$66,$84
LDD5C		fcb $5C,$72,$66,$76
LDD60		fcb $6E,$72,$66,$84
LDD64		fcb $FC,$02,$56,$56
LDD68		fcb $17,$EE,$02,$EA
LDD6C		fcb $BB,$BB,$EA,$EA
LDD70		fcb $00,$4E,$5C,$FC
LDD74		fcb $C2,$51,$3E,$CF
LDD78		fcb $FC,$42,$13,$00
LDD7C		fcb $6A,$5A,$FC,$1E
LDD80		fcb $11,$F3,$62,$39
LDD84		fcb $E2,$0C,$E4,$8A
LDD88		fcb $E2,$00,$56,$54
LDD8C		fcb $FC,$54,$65,$2E
LDD90		fcb $CA,$BA,$A1,$D4
LDD94		fcb $EE,$12,$D2,$13
LDD98		fcb $E1,$20,$F6,$24
LDD9C		fcb $72,$58,$EE,$C5
LDDA0		fcb $BE,$00,$FE,$50
LDDA4		fcb $7C,$5E,$72,$6E
LDDA8		fcb $78,$84,$70,$68
LDDAC		fcb $4E,$84,$30,$44
LDDB0		fcb $48,$54,$20,$16
LDDB4		fcb $58,$34,$72,$5C
LDDB8		fcb $80,$34,$8E,$16
LDDBC		fcb $A8,$58,$E0,$44
LDDC0		fcb $B8,$84,$D0,$70
LDDC4		fcb $B2,$84,$90,$6E
LDDC8		fcb $88,$5E,$8E,$50
LDDCC		fcb $84,$FF,$84,$70
LDDD0		fcb $FC,$C5,$92,$BE
LDDD4		fcb $C3,$43,$5E,$72
LDDD8		fcb $45,$00,$52,$7A
LDDDC		fcb $FC,$78,$E9,$8D
LDDE0		fcb $EC,$33,$0C,$24
LDDE4		fcb $72,$47,$E7,$00
LDDE8		fcb $16,$A8,$FC,$2D
LDDEC		fcb $C2,$3D,$30,$4B
LDDF0		fcb $4B,$ED,$B2,$9D
LDDF4		fcb $71,$3D,$DD,$91
LDDF8		fcb $7D,$52,$63,$A3
LDDFC		fcb $2D,$ED,$2D,$CB
LDE00		fcb $CB,$D0,$DD,$42
LDE04		fcb $ED,$00,$FE,$3E
LDE08		fcb $44,$44,$58,$38
LDE0C		fcb $64,$FF,$4A,$5A
LDE10		fcb $46,$4A,$FC,$33
LDE14		fcb $F5,$F5,$C1,$5A
LDE18		fcb $62,$0E,$00,$64
LDE1C		fcb $50,$FC,$B3,$17
LDE20		fcb $34,$EB,$0A,$3D
LDE24		fcb $00,$FE,$7C,$A0
LDE28		fcb $FC,$C2,$22,$E4
LDE2C		fcb $24,$2C,$EC,$04
LDE30		fcb $04,$E2,$42,$00
LDE34		fcb $7C,$A8,$FC,$C1
LDE38		fcb $21,$12,$F2,$E1
LDE3C		fcb $41,$00,$FE,$70
LDE40		fcb $4A,$FC,$E0,$EE
LDE44		fcb $2C,$42,$14,$14
LDE48		fcb $20,$0C,$CC,$22
LDE4C		fcb $0C,$22,$00,$7C
LDE50		fcb $5A,$FC,$E0,$0C
LDE54		fcb $2C,$20,$04,$00
LDE58		fcb $FE,$52,$82,$FC
LDE5C		fcb $28,$7D,$5F,$50
LDE60		fcb $5B,$F5,$2F,$D5
LDE64		fcb $17,$17,$F3,$22
LDE68		fcb $E1,$14,$DD,$8F
LDE6C		fcb $8D,$DB,$EC,$00
LDE70		fcb $56,$82,$FC,$33
LDE74		fcb $31,$1B,$91,$3B
LDE78		fcb $5F,$F5,$00,$6C
LDE7C		fcb $74,$72,$76,$78
LDE80		fcb $90,$FE,$22,$7C
LDE84		fcb $FC,$04,$1F,$0E
LDE88		fcb $FF,$00,$50,$8E
LDE8C		fcb $40,$88,$2E,$92
LDE90		fcb $40,$9C,$52,$8C
LDE94		fcb $4C,$88,$40,$92
LDE98		fcb $3A,$8C,$FD,$DE
LDE9C		fcb $B3,$1E,$7E,$FC
LDEA0		fcb $50,$0F,$E0,$00
LDEA4		fcb $2C,$96,$34,$A6
LDEA8		fcb $4C,$A4,$5C,$96
LDEAC		fcb $4C,$88,$34,$86
LDEB0		fcb $2C,$96,$FF,$50
LDEB4		fcb $8C,$80,$98,$84
LDEB8		fcb $A0,$84,$90,$7E
LDEBC		fcb $90,$54,$82,$FF
LDEC0		fcb $54,$7E,$7E,$6E
LDEC4		fcb $84,$6E,$84,$5C
LDEC8		fcb $80,$66,$50,$74
LDECC		fcb $FF,$50,$8C,$FC
LDED0		fcb $3A,$D9,$83,$DE
LDED4		fcb $AD,$E6,$A1,$E2
LDED8		fcb $22,$61,$26,$EA
LDEDC		fcb $20,$3D,$DD,$E0
LDEE0		fcb $00,$34,$80,$14
LDEE4		fcb $80,$FC,$0E,$21
LDEE8		fcb $02,$E1,$0E,$00
LDEEC		fcb $4A,$66,$FC,$E0
LDEF0		fcb $02,$D0,$08,$30
LDEF4		fcb $02,$20,$01,$30
LDEF8		fcb $02,$D0,$01,$87
LDEFC		fcb $00,$2E,$6E,$40
LDF00		fcb $66,$40,$64,$1E
LDF04		fcb $66,$14,$62,$1E
LDF08		fcb $5E,$40,$60,$40
LDF0C		fcb $62,$14,$62,$FE
LDF10		fcb $2E,$62,$FC,$21
LDF14		fcb $2F,$2D,$FD,$CE
LDF18		fcb $C2,$F2,$12,$0F
LDF1C		fcb $1E,$3F,$21,$12
LDF20		fcb $E3,$E0,$00,$68
LDF24		fcb $9A,$FC,$21,$2F
LDF28		fcb $2D,$FD,$CE,$C2
LDF2C		fcb $F2,$12,$0F,$1E
LDF30		fcb $3F,$22,$12,$E2
LDF34		fcb $E0,$00,$FD,$DF
LDF38		fcb $65

LDF39		fcb $28,$56,$40

LDF3C		fcb $5C,$2A,$64,$36
LDF40		fcb $52,$38,$68,$28
LDF44		fcb $56,$FF,$42,$8C
LDF48		fcb $FC,$70,$AD,$35
LDF4C		fcb $1B,$B3,$00,$60
LDF50		fcb $92,$78,$94,$64
LDF54		fcb $88,$6A,$9A,$74
LDF58		fcb $8A,$60,$92,$FF
LDF5C		fcb $50,$74,$FC,$53
LDF60		fcb $EC,$E4,$4D,$B0
LDF64		fcb $00,$40,$7C,$FC
LDF68		fcb $4E,$C0,$7B,$9C
LDF6C		fcb $D4,$E4,$E1,$E1
LDF70		fcb $DD,$1C,$96,$03
LDF74		fcb $00,$1C,$82,$FC
LDF78		fcb $03,$45,$71,$DA
LDF7C		fcb $1E,$11,$E1,$00
LDF80		fcb $30,$86,$36,$8E
LDF84		fcb $74,$A4,$84,$84
LDF88		fcb $82,$76,$78,$5E
LDF8C		fcb $5A,$6E,$84,$84
LDF90		fcb $48,$6A,$FF,$40
LDF94		fcb $66,$FC,$1F,$BD
LDF98		fcb $F1,$53,$00,$42
LDF9C		fcb $66,$FC,$1E,$32
LDFA0		fcb $11,$73,$00,$58
LDFA4		fcb $70,$48,$78,$FF
LDFA8		fcb $3E,$84,$14,$80
LDFAC		fcb $34,$7A,$40,$7A
LDFB0		fcb $3C,$7C,$72,$80
LDFB4		fcb $50,$82,$44,$82
LDFB8		fcb $3E,$84,$FF,$28
LDFBC		fcb $82,$FC,$FF,$1E
LDFC0		fcb $11,$F2,$3F,$20
LDFC4		fcb $0F,$C0,$FF,$31
LDFC8		fcb $00,$FE,$84,$82
LDFCC		fcb $70,$7A,$5C,$7C
LDFD0		fcb $5E,$7E,$5E,$82
LDFD4		fcb $5C,$84,$70,$82
LDFD8		fcb $80,$8C,$84,$88
LDFDC		fcb $84,$72,$78,$6C
LDFE0		fcb $6A,$76,$78,$70
LDFE4		fcb $7C,$74,$7C,$7E
LDFE8		fcb $FF,$64,$78,$FC
LDFEC		fcb $E0,$E2,$EE,$E0
LDFF0		fcb $F1,$22,$EE,$06
LDFF4		fcb $2E,$E2,$11,$20
LDFF8		fcb $2E,$22,$20,$00
LDFFC		fcb $FE,$4B,$53,$4B