 .OPT NO LIST›; SAVE #D1:PHENTRY.M65›;›;›; LOAD #D1:SCREEN1.M65›;› .PAGE "Peripheral Handler Entry"›;›;› *= $E486›PENTV› JMP PHE     Peripheral entry›;›  LIST › .LOCAL›; Peripheral handler entry:›;  install device in hatabs if›; not already there and if room›; Entry: ascii name in x›;  table addr in y,a (lsb,msb)›; Returns:›;  already installed: a=a y=y›;   x points name+1 in Hatabs›;   c=1 s=0›;›;  newly installed:  a=a›;   x points name y=ascii name›;   c=0 s=?›;›;  no room: a=a y=$ff x=34›;   c=1 s=1›;›;›; *= $EEBC 07 Oct 94›PHE› PHA         Pointed to by Pentv› TYA         Table address› PHA         to stack› TXA         Device name to a› LDX #0›?FINDDEV› CMP HATABS,X› BEQ ?FOUND› INX› INX› INX› CPX #34› BMI ?FINDDEV› LDX #0      Not found,› TAY         save device and› LDA #0      find empty slot›;›?FINDMT› CMP HATABS,X› BEQ ?INSTALL Got one› INX› INX› INX› CPX #34› BMI ?FINDMT› PLA         Clear stack› PLA› LDY #255    Flag no free› SEC         return -ve and c=1› RTS›;›?FOUND› PLA         Restore address› TAY         to y,a› PLA› INX         x points address› SEC         return +ve and c=1› RTS›;›?INSTALL› TYA› STA HATABS,X Device name› PLA› STA HATABS+1,X Addr lsb› PLA› STA HATABS+2,X Addr msb› CLC         return +/- and c=0› RTS›; -------------------------------›; This routine is called only once.›; (from the CIO Open routine)›;›PDOPENPOLL› LDY #0› LDA (ICBALZ),Y Get device name› LDY ICDNOZ     and device number› JSR POLL.PD    Poll it› BPL ?POLLEDOK  Go if good› LDY #130       Else, no device› RTS›;›; .BYTE $4F   ddevic›; .BYTE 1     dunit›; .BYTE $40   dcomnd›; .BYTE $40   dstats›; .WORD DVSTAT dbuflo/hi›; .WORD 30    dtimlo/hi›; .WORD 4     dbytlo/hi›;›; Mapping The Atari p.209›;  Type 3 Poll ("Are you there?")›;›; Dvstat bytes:›;  .Word Handler size (even number)›;  .Byte SIO address for loading›;  .Byte Peripheral rev. number›;›;  Cdevic = $4F›;  Ccomnd = $40›;  Caux1  = $4F›;  Caux2  = $4F›;›;  Type 4 Poll ("Null")›;  Cdevic = $4F›;  Ccomnd = $40›;  Caux1  = $4E›;  Caux2  = $4E›;›?POLLEDOK› LDA #$7F› STA ICHIDZ› LDA # <?PUT-1 Put byte› STA ICPTLZ  address-1› LDA # >?PUT-1› STA ICPTHZ› LDA DVSTAT+2 Device Sio addr›  ALDX  ICAX5Z Recover channel› STA ICAX4,X› LDY #0› LDA (ICBALZ),Y› STA ICAX3,X› LDY #1› RTS›; ------------------------›;›;›;›?PUT› PHA         Put byte routine› TXA         for provisionally› PHA         open iocb.› AND #$0F    Verify iocb#› BNE ?BADCH› CPX #$80› BPL ?BADCH› LDA HNDLOD  Was handler loaded?› BNE ?HNDLOD Yes› LDY #130    Else, no device›;›?EREXIT› PLA› PLA› CPY #0› RTS›;›?BADCH› LDY #134    invalid iocb#› BMI ?EREXIT Always›;›?HNDLOD› ASTX  ICAX5Z› LDY #0›;›?COPY› LDA ICHID,X Copy iocb› STA ICHIDZ,Y to ziocb› INX› INY› CPY #12› BMI ?COPY› JSR INITPD  Initialize device› BMI ?EREXIT› PLA         recover x› TAX› PLA         recover a› TAY         save a› LDA ICPTHZ  Do indirect jsr› PHA         to put byte› LDA ICPTLZ› PHA› TYA         recover byte› LDY #146    invalid xio code› RTS› .BYTE 0,0,0,0 Unused› .BYTE 0,0› JMP MOTORON Not referenced›