The game is Nazo no Murasamejou (Mysterious Murasame Castle) for the Disk System. A pretty hard game, but a good one.
http://en.wikipedia.org/wiki/Nazo_no_Murasame_J%C5%8D