Friday, May 22, 2015

Studying Thayer's Quest's LDP routines

It turns out that Thayer's Quest's LDP routines are very similar to Dragon's Lair's.  I would bet money that the assembly language code was lifted straight from Dragon's Lair F2 and modified for Thayer's Quest.

Here is Thayer's Quest's PR-7820 routine:

ROM_U33:1ED8 SendToPR7820:                           ; CODE XREF: SendToLdp+7 j
ROM_U33:1ED8                 push    hl
ROM_U33:1ED9                 ld      hl, A783PortF5Cache ; bit 5: 1 = output mode to LDP, 0 = input mode
ROM_U33:1ED9                                         ; bit 6: pin 11 (pr-7820 enter')
ROM_U33:1ED9                                         ; bit 7: pin 17 (pr-7820 int/ext', ld-v1000 enter')
ROM_U33:1EDC                 res     7, (hl)         ; lower int/ext' (ie go external)
ROM_U33:1EDE                 ld      a, (hl)
ROM_U33:1EDF                 out     (0F5h), a       ; apply changes to hardware
ROM_U33:1EE1                 ld      a, (A784CmdToSendToLdp)
ROM_U33:1EE4                 out     (0F4h), a       ; put command byte on pr-7820 data bus
ROM_U33:1EE6                 ld      hl, A783PortF5Cache ; bit 5: 1 = output mode to LDP, 0 = input mode
ROM_U33:1EE6                                         ; bit 6: pin 11 (pr-7820 enter')
ROM_U33:1EE6                                         ; bit 7: pin 17 (pr-7820 int/ext', ld-v1000 enter')
ROM_U33:1EE9                 set     5, (hl)         ; enable output mode to LDP data lines
ROM_U33:1EEB                 ld      a, (hl)
ROM_U33:1EEC                 out     (0F5h), a       ; apply changes to hardware
ROM_U33:1EEE                 res     6, (hl)         ; enable ENTER' line for pr-7820
ROM_U33:1EF0                 ld      a, (hl)
ROM_U33:1EF1                 out     (0F5h), a       ; apply changes to hardware
ROM_U33:1EF3                 call    Delay20ms       ; stalls for 20ms (confirmed on real hardware)
ROM_U33:1EF6                 ld      hl, A783PortF5Cache ; bit 5: 1 = output mode to LDP, 0 = input mode
ROM_U33:1EF6                                         ; bit 6: pin 11 (pr-7820 enter')
ROM_U33:1EF6                                         ; bit 7: pin 17 (pr-7820 int/ext', ld-v1000 enter')
ROM_U33:1EF9                 set     6, (hl)         ; disable ENTER' line
ROM_U33:1EFB                 ld      a, (hl)
ROM_U33:1EFC                 out     (0F5h), a
ROM_U33:1EFE                 call    Delay20ms       ; stalls for 20ms (confirmed on real hardware)
ROM_U33:1F01                 ld      hl, A783PortF5Cache ; bit 5: 1 = output mode to LDP, 0 = input mode
ROM_U33:1F01                                         ; bit 6: pin 11 (pr-7820 enter')
ROM_U33:1F01                                         ; bit 7: pin 17 (pr-7820 int/ext', ld-v1000 enter')
ROM_U33:1F04                 res     5, (hl)         ; go into input mode
ROM_U33:1F06                 ld      a, (hl)
ROM_U33:1F07                 out     (0F5h), a
ROM_U33:1F09                 pop     hl
ROM_U33:1F0A                 ret
ROM_U33:1F0A ; END OF FUNCTION CHUNK FOR SendToLdp


<end>

So, I've been having some problems with getting PR-7820 mode on Dexter working with Thayer's Quest.  I noticed that Thayer's Quest is sending a 'pause' command after a search finishes and this is exposing a defect in Dexter that I am working on fixing.

ROM_U33:1C57 sub_1C57:                               ; CODE XREF: ROM_U33:1BB0 p
ROM_U33:1C57                                         ; ROM_U33:1BC1 p ...
ROM_U33:1C57                 ld      (unk_A794), de
ROM_U33:1C5B                 ld      hl, unk_A791
ROM_U33:1C5E                 res     0, (hl)
ROM_U33:1C60                 call    SearchToFrame   ; convert number to BCD
ROM_U33:1C63                 call    SendPauseToLdp  ; 'FB'
ROM_U33:1C66                 ret
ROM_U33:1C66 ; End of function sub_1C57

<end>


No comments:

Post a Comment