Previous Next Contents Index
The Hook and Command code routine & 
   The Command code table 

This routine is entered with the A register holding an 'IF1 hook code', a '+D command
code' or an invalid error code. The routine calls a set of subroutines in the +D system,
and is intended to help machine-code access to the drives. There are two tables
containing addresses of the routines, the first is located in ROM (at #0DD7) and consists
of the addresses of the routines for the IF1 hookcodes. The second table is located at
address #22DE and consists of the addresses of the +D command code routines.

228E HOOK_CODE  LD   (#3AC5),DE
2292            CP   24
2294            JR   NC,#22BC,COMM_CODE  Jump if code isn't a hook code.
2296            LD   DE,#0DD7,IF1_HOOK   Address of hook (IF1) code table.
2299 CODE_CONT  LD   (IY+0),#FF          Clear error.
229D            SET  2,(IY+1)            What's the purpose of this?
22A1            INC  HL                  Advance return address past the code.
22A2            PUSH HL
22A3            ADD  A,A                 Table is made of two byte addresses, so
22A4            LD   L,A                 double code.
22A5            LD   H,0
22A7            ADD  HL,DE               Point codes entry in table.
22A8            LD   E,(HL)              Fetch the address of the routine.
22A9            INC  HL
22AA            LD   D,(HL)
22AB            LD   HL,#22C8,HOOK_RET   Return address after completion of
22AE            PUSH HL                  code.
22AF            LD   (#2066),SP          Set D_ERR_SP.
22B3            EX   DE,HL
22B4            LD   DE,(#3AC5)          Restore DE and A.
22B8            LD   A,( #3E4F)
22BB            JP   (HL)                Jump to the routine.

22BC COMM_CODE  SUB  24                  Adjust range for command codes (0..20).
22BE            CP   21
22C0            JP   NC,#1666,REP_17     Give error if not a command code.
22C3            LD   DE,#22DE,MGT_HOOK   Address of command code table.
22C6            JR   #2299,CODE_CONT     Continue with command codes.

THE 'HOOK_RET' ROUTINE
This routine is entered whenever a hook or command code is finished.

22C8 HOOK_RET   PUSH HL
22C9            LD   HL,#0000
22CC            LD   (#2066),HL          Clear D_ERR_SP.
22CF            POP  HL
22D0            CALL #168E,BORD_REST     Return to the calling routine with the
22D3            JP   #0050,UNPAGE_1      'main' ROM paged in.

THE 'PAGE-IN +D' SUBROUTINE
This is called by using 'command code' 71. On return the +D is paged-in and the HL
register contains 0, to indicate that this is a +D (with a DISCiPLE HL holds 1).

22D6 PATCH      POP  HL                  Drop 'HOOK_RET' return address.
22D7            LD   HL,#0000            Clear 'D_ERR_SP'.
22DA            LD   (#2066),HL
22DD            RET                      HL=0, meaning 'this is a +D'.

THE 'COMMAND CODE ADRESSES' TABLE
This jump table consists of the 21 addresses of the routines called by using the various
'command codes'.
 
22DE MGT_HOOK   DEFW #2F8B,HXFER         Command code #33, 51.
22E0            DEFW #2F9E,OFSM          Command code #34, 52.
22E2            DEFW #2FA4,HOFLE         Command code #35, 53.
22E4            DEFW #0761,SBYT          Command code #36, 54.
22E6            DEFW #2FAB,HSVBK         Command code #37, 55.
22E8            DEFW #0B89,CFSM          Command code #38, 56.
22EA            DEFW #15C9,PNTP          Command code #39, 57.
22EC            DEFW #12D2,COPS          Command code #3A, 58.
22EE            DEFW #2FB1,HGFLE         Command code #3B, 59.
22F0            DEFW #077F,LBYT          Command code #3C, 60.
22F2            DEFW #2FB7,HLDBK         Command code #3D, 61.
22F4            DEFW #3016,JWSAD         Command code #3E, 62.
22F6            DEFW #300F,JRSAD         Command code #3F, 63.
22F8            DEFW #06B6,REST          Command code #40, 64.
22FA            DEFW #2FBD,HERAZ         Command code #41, 65.
22FC            DEFW #133E,COPS2         Command code #42, 66.
22FE            DEFW #3154,PCAT          Command code #43, 67.
2300            DEFW #2FD4,HRSAD         Command code #44, 68.
2302            DEFW #2FF2,HWSAD         Command code #45, 69.
2304            DEFW #3110,OTFOC         Command code #46, 70.
2305            DEFW #22D6,PATCH         Command code #47, 71.

Previous Next Contents Index