If you appreciate the work done within the wiki, please consider supporting The Cutting Room Floor on Patreon. Thanks for all your support!

Dragon Quest (MSX)

From The Cutting Room Floor
Jump to navigation Jump to search

Title Screen

Dragon Quest

Developer: Enix
Publisher: Enix
Platform: MSX
Released in JP: November 1986


SourceIcon.png This game has uncompiled source code.


Dragon Quest makes its first appearance on computers that would keep going, even up to Dragon Quest XXI.

Uncompiled Source Code

Present from 0xC000-0x10000, complete with minor comments.

Translation:

Japanese English
MATITLE NO OWARI NI END MARK O End mark at the end of the matitle
MONSNO Monster Number
HANTEN FLAG Reverse Flag
(Translation: GlitterBerri)

JUSIN:	LD	HL,WNDFLG
	LD	DE,WNDFLG+1
	LD	BC,4
	LD	(HL),5FH	;SPACE CHARACTER CODE
	LDIR
	LD	A,0FAH		;END OF MINI SENTENCE CODE
	LD	(DE),A
	LD	IX,WNDFLG+4
JUSIN1:	LD	HL,10
	LD	(CALCU2),HL
	CALL	DIVIDE
	LD	A,(CALCU3)
	LD	(IX),A
	DEC	IX
	LD	HL,(CALCU1)
	LD	A,H
	OR	L
	JR	NZ,JUSIN1
	RET
;
CHRPT:	LD	A,(WINDX)
	LD	H,A
	LD	A,(WINDY)
	LD	L,A
	LD	A,(BGCHR)
CHRPUT:	EX	AF,AF
	LD	A,H
	ADD	A,A
	ADD	A,A
	ADD	A,A
	LD	H,A
	LD	A,L
	ADD	A,A
	ADD	A,A
	ADD	A,A
	LD	L,A
	EX	AF,AF'
	JP	CHROUT
;
;
;	WINDOW ROUTINE
;
; INPUT....CALCU1(1)=WINDOW NUMBER
;
WINDOZ:	EX	(SP),HL
	LD	A,(HL)
	INC	HL
	EX	(SP),HL
WINDOW:	LD	(CALCU1),A
	CP	3
	JR	Z,WIND31
	CP	4
	JR	NZ,WIND32
WIND31:	LD	A,85H
	JR	WIND33
WIND32:	CP	9
	JR	NZ,WIND34
	LD	A,86H
WIND33:;CALL	BEEP
	CALL	SOUND
WIND34:	LD	A,(CALCU1)
	CP	11
	JR	NC,WIND3X
	C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EH
	LD	(7800H),A	;BANK SELECT
	LD	IY,WINDDA
	ADD	IY,DE
	LD	A,(IY)
	LD	(BGAND),A	;KIND OF WINDOW
	LD	A,(IY+1)
	LD	(WINDDY),A
	LD	A,(IY+2)
	LD	(WINDDY+1),A	;WINDOW DATA ADDRESS
	LD	A,(IY+6)	;MATITLE NO OWARI NI END MARK O
	SRL	A
	LD	HL,MATITL
	ADD	A,L
	LD	L,A
	LD	(HL),0FFH
	LD	A,(IY+3)
	AND	1FH
	SLA	A
	LD	(WINDX),A	;WINDOW X POSITION
	LD	A,(MAINX)
	CP	0FFH
	JR	NZ,WIND21
	LD	A,(WINDX)
	INC	A
	LD	(MAINX),A
	LD	(MAINMX),A
WIND21:	LD	A,(IY+4)
	ADD	A,A
	LD	(WINDY),A	;WINDOW Y POSITION
	LD	A,(MAINY)
	CP	0FFH
	JR	NZ,WIND22
	LD	A,(WINDY)
	ADD	A,2
	CP	1EH
	JR	NZ,WIND23
	XOR	A
WIND23:	LD	(MAINY),A
WIND22:	LD	A,(IY+3)
	LD	(CALCU1),A
	LD	A,(IY+4)
	LD	(CALCU2),A
	CALL	CASCAD
	LD	HL,(BGADD)
	LD	(CALCU4),HL
	LD	(PALTAD),HL
	LD	A,(IY+5)
	LD	(WIMAXX),A	;WINDOW MAX X POSITION
	LD	HL,(WINDDY)
WIND13:	LD	A,(HL)
	INC	HL
	CP	0FFH		;END OF SENTENCE CODE
	JR	NZ,WIND13
	LD	(WINDDZ),HL
	LD	HL,(WINDDZ)
WIND14:	LD	A,(HL)
	INC	HL
	CP	0FFH
	JR	NZ,WIND14
	LD	(DATAAD),HL
	LD	(DATAA2),HL
	XOR	A
	LD	(WIMAXY),A
	LD	HL,MATITL
WIND18:	LD	A,(HL)
	CP	0FFH
	JR	Z,WIND17
	LD	A,(WIMAXY)
	INC	A
	INC	A
	LD	(WIMAXY),A
	INC	HL
	JR	WIND18

WIND17:	LD	A,(INPUTM)
	CP	0FEH
	JR	NZ,WIND16
	LD	A,(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CU1+1),A

PRMAIQ:	EX	(SP),HL
	LD	A,(HL)
	INC	HL
	EX	(SP),HL
	LD	(CALCU1),A	;CALCU1+1=0

PRMA11:	XOR	A
	LD	(MONSN2),A
	LD	A,0EH
	LD	(7800H),A
	LD	A,0FH
	LD	(7000H),A
	LD	HL,(CALCU1)
	ADD	HL,HL
	LD	(CALCU1),HL
	LD	DE,PTABLE
	ADD	HL,DE
	LD	A,(HL)
	INC	HL
	LD	H,(HL)
	LD	L,A
	LD	DE,8000H
	ADD	HL,DE
	LD	(TABADD),HL
	LD	(DATAAD),HL
;
PRMAI1:	LD	A,(MAINX)	;MAIN PANNEL'S CURSOR X POS.
	LD	(WINDX),A
	LD	A,(MAINY)	;MAIN PANNEL'S CURSOR Y POS.
	LD	(WINDY),A
	LD	A,(MAINMX)	;LEFT MARG X POS.
	LD	(WIMAXX),A
	LD	A,0FFH
	LD	(BGAND),A	;WRITE SCREEN WORK FLAG
	CALL	PRMA12
	CALL	PRMAIS
	CALL	PRMAI9
	LD	A,(WINDX)
	LD	(MAINX),A
	LD	A,(WINDY)
	LD	(MAINY),A
	LD	A,2
	LD	(7000H),A
	LD	A,0EH
	LD	(7800H),A
	RET
;
;	MAIN PANNEL PRINT SUB ROUTINE
;
PRMAIS:	CALL	WITNMI		;WAIT NMI
	LD	A,0FFH
	LD	(NMIFLG),A
PRMAI4:
PRMAI0:	CALL	WITNMI
	LD	A,(DEBUG)
	LD	B,A
	OR	A
	JR	Z,PRMA99
PRMA98:	CALL	WITNMI
	DJNZ	PRMA98
PRMA99:	LD	HL,(DATAAD)
	LD	A,(HL)
	CP	6DH
	JR	Z,PRMA80
	CP	6EH
	JR	NZ,PRMA81
PRMA80:	LD	A,0FFH
	LD	(MONSN2),A
PRMA81:	CALL	PRACHR
	LD	A,(MONSN2)
	OR	A
	JR	Z,PRMA82
	LD	HL,(DATAAD)
	LD	A,(HL)
	CP	4FH
	JR	C,PRMA83
	CP	63H
	JR	C,PRMA82
	CP	6CH
	JR	N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
	CALL	SOUND
;CALL	BEEP
	LD	A,(INPUTM)
	OR	A
	RET

INPUT1:	LD	A,(KEYDAT)
	AND	2		;B BUTTON
	JR	Z,INPUT3
	CALL	INPSU0
	LD	A,85H
	CALL	SOUND
;CALL	BEEP
	LD	A,0FFH
	LD	(INPUTM),A
	OR	A
	RET

INPUT3:	LD	A,(KEYDAT)
	AND	10H		;UP
	JR	Z,INPUT5
	LD	A,(INPUTX)
	CP	5
	JR	Z,INPU12
	LD	A,(INPUTY)
	OR	A
	JP	Z,INPUT0
INPU18:	LD	HL,INPUTY
	DEC	(HL)
	LD	A,(WINDY)
	DEC	A
	DEC	A
	LD	(WINDY),A
	CP	0FEH
	JP	NZ,INPU10
INPU19:	LD	A,1CH
	LD	(WINDY),A
	JP	INPU10
INPU12:	LD	A,(INPUTY)
	OR	A
	JP	Z,INPUT0
INPU20:	XOR	A
	LD	(INPUTY),A
	LD	A,(WIMAXX)
	LD	(WINDX),A
	LD	A,(WIMAXY)
	SUB	2
	CP	0FEH
	JR	NZ,INPU13
	LD	A,1CH
INPU13:	LD	(WINDY),A
	JP	INPU10

INPUT5:	LD	A,(KEYDAT)
	AND	20H		;DOWN
	JR	Z,INPUT6
	LD	A,(INPUTX)
	CP	5
	JR	Z,INPU14
	LD	A,(INPUTY)
	INC	A
	LD	(INPUTY),A
	LD	HL,INPUTM
	CP	(HL)
	JR	NZ,INPUT7
	DEC	A
	LD	(INPUTY),A
	JP	INPUT0
INPUT7:	LD	A,(WINDY)
	INC	A
	INC	A
	LD	(WINDY),A
	CP	1EH
	JP	NZ,INPU10
INPU21:	XOR	A
	LD	(WINDY),A
	JP	INPU10
INPU14:	LD	A,2
	LD	HL,INPUTY
	CP	(HL)
	JP	Z,INPUT0
INPU22:	LD	(INPUTY),A
	LD	A,(WIMAXX)
	LD	(WINDX),A
	LD	A,(WIMAXY)
	ADD	A,2
	CP	1EH
	JR	NZ,INPU15
	XOR	A
INPU15:	LD	(WINDY),A
	JP	INPU10

INPUT6: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	B
	JP	NZ,MONST2
	LD	A,(IX)
	OR	(IX+1)
	JR	Z,MONST9
	LD	L,(IX)
	LD	H,(IX+1)
	PUSH	HL
	POP	IX
MONST8:	LD	A,(IX)
	OR	(IX+1)
	JR	Z,MONST9
	PUSH	IX
	PUSH	DE
	LD	A,(IX)
	ADD	A,A
	ADD	A,A
	ADD	A,A
	ADD	A,E
	LD	L,A
	LD	A,(IX+1)
	ADD	A,A
	ADD	A,A
	ADD	A,A
	ADD	A,D
	LD	H,A
	LD	A,H
	LD	H,0
	REPT	5
	ADD	HL,HL
	ENDM
	ADD	A,L
	LD	L,A
	JR	NC,$+3
	INC	H
	EX	DE,HL
	INC	IX
	INC	IX
	PUSH	IX
	POP	HL
	CALL	ONEPUT
	POP	DE
	POP	IX
	LD	BC,8*2+2
	ADD	IX,BC
	JR	MONST8
MONST9:	LD	A,2
	LD	(7000H),A
	INC	A
	LD	(7800H),A
	RET
;
MONOFS: ;1   2    3     4     5    6      7     8     9     0
 DB 10,5, 10,5,  9,4, 10,4, 10,6,  9,4,	10,6, 11,4, 10,4, 10,3
 DB 10,4, 10,6, 10,6, 10,6, 10,6, 10,6,	10,5, 10,4, 10,6, 11,4
 DB 10,3,  9,6, 10,6, 10,6, 10,6, 10,6,	10,6,  9,6, 10,6, 10,6
 DB  9,6,  9,6, 10,6, 10,6,  9,6, 10,6,	10,6,  9,6, 10,6, 10,6
;
HANTEN:	PUSH	DE
	LD	HL,(CALCU1)
	LD	DE,0F2A0H
	LD	BC,32
	LDIR
	LD	HL,0F2A0H
	LD	DE,0F2A0H+16
	LD	B,16
HANTL0:	LD	A,(HL)
	REPT	8
	RLA
	RR	C
	ENDM
	LD	A,C
	EX	AF,AF'
	LD	A,(DE)
	REPT	8
	RLA
	RR	C
	ENDM
	LD	(HL),C
	EX	AF,AF'
	LD	(DE),A
	INC	HL
	INC	DE
	DJNZ	HANTL0
	LD	HL,0F2A0H
	POP	DE
	LD	BC,32
	CALL	005CH
	RET
;
;	PROGRAM START ROUTINE
;
START:	CALL	0138H
	RRCA
	RRCA
	AND	11B
	LD	C,A
	LD	B,0
	LD	HL,0FCC1H
	ADD	HL,BC
	LD	C,A
	LD	A,(HL)
	AND	80H
	OR	C
	LD	C,A
	INC	HL
	INC	HL
	INC	HL
	INC	HL
	LD	A,(HL)
	AND	1100B
	OR	C
	LD	H,80H
	CALL	0024H
	LD	A,0AH
	LD	(7000H),A
	LD	HL,8000H
	LD	DE,0D000H
	LD	BC,2000H
	LDIR
	XOR	A
	CALL	SOUND
;
	LD	A,2
	LD	(0FCAFH),A
	CALL	005FH
;
	LD	HL,1800H
	LD	B,3
PMTST1:	LD	C,0
PMTST0:	LD	A,C
	CALL	004DH
	INC	HL
	INC	C
	JR	NZ,PMTST0
	DJNZ	PMTST1
;
	LD	HL,2000H
	LD	BC,1800H
	LD	A,0F4H
	CALL	0056H
;
	DI
	LD	SP,0F380H
	LD	HL,NMI
	LD	A,0C3H
	LD	(0FDA0H),HL
	LD	(0FD9FH),A
	LD	A,(0F3E0H)
	OR	22H
	LD	(0F3E0H),A
	LD	B,A
	LD	C,1
	CALL	0047H
	EI
	XOR	A
	LD	(0F3DBH),A
	LD	A,1
	LD	(6800H),A
	LD	A,2
	LD	(7000H),A
	LD	A,15
	LD	(0F3E9H),A
	LD	(PLTCOL),A
	LD	A,1
	LD	(0F3EAH),A
	LD	(0F3EBH),A
	CALL	0062H
;
	LD	A,1
	LD	(6800H),A
	INC	A
	LD	(7000H),A
;
	LD	HL,0C000H
	LD	DE,0C000H+1
	LD	BC,0FFH
	LD	(HL),0
	LDIR			;FILL $00 TO $FF = $00
;
;CALL	CLSOBJ
;
	LD	A,0FFH
	LD	(HITPNT),A
	LD	A,8
	LD	(CHUNX),A
	LD	A,7
	LD	(CHUNY),A
;
			JR	MSKIP
	LD	A,1
	LD	(FIELD),A
MSLP0:	XOR	A
	LD	(MONSNO),A
MSLP:	CALL	PUTBAK
	CALL	CLSOBJ
	CALL	MONSTR
	CALL	PAUSE
	LD	A,(MONSNO)
	INC	A
	LD	(MONSNO),A
	CP	40
	JR	NZ,MSLP
	JR	MSLP0
;
MSKIP:
	LD	A,4
	LD	(7000H),A
	INC	A
	LD	(7800H),A
	CALL	8000H
	CALL	0069H
	LD	A,15
	LD	(0F3E9H),A
	LD	(PLTCOL),A
	LD	A,1
	LD	(0F3EAH),A
	LD	(0F3EBH),A
	CALL	0062H
	LD	A,2
	LD	(7000H),A

	LD	A,(NFLDY)
	CP	10H
	JP	NZ,STAR93
STAR94:	LD	A,0CH
	LD	(7000H),A
	CALL	8000H
	LD	A,2
	LD	(7000H),A
	JP	STAR92

STAR93:	LD	A,0CH
	LD	(7000H),A
	CALL	8003H
	LD	A,2
	LD	(7000H),A
STAR92:	LD	A,15
	LD	(PLTCOL),A
	LD	A,3
	LD	(7800H),A
	LD	HL,(0A004H)
	LD	DE,3800H
	LD	BC,800H
	CALL	005CH
	LD	A,0EH
	LD	(7800H),A
	LD	A,0FAH
	LD	(NAME+4),A
	XOR	A
	LD	(PUTFLG),A
	LD	HL,DOORFL
	LD	DE,DOORFL+1
	LD	BC,1FH
	LD	(HL),0
	LDIR
	CALL	STARSU
	LD	A,(HIMEFG)
	AND	8
	JR	Z,STAR97
	CALL	PRMAIO
	DB	17H
	LD	A,(LEVEL)
	CP	30
	JR	NZ,STAR90
	CALL	PRMAIZ
	DB	2
	JP	STAR95
STAR90:	CALL	NEXTEP
	CALL	PRMAIZ
	DB	0C1H
	CALL	PRMAIO
	DB	18H
STAR95:	CALL	PRMAIZ