.module Device .include "SonyIR.asm" ID.SIRCS = 0 Initialise push hl \ ld hl,InterfaceTable+ 0 \ jr InvokeInterfaceMethod ReadByte push hl \ ld hl,InterfaceTable+ 2 \ jr InvokeInterfaceMethod WriteByte push hl \ ld hl,InterfaceTable+ 4 \ jr InvokeInterfaceMethod GetSize push hl \ ld hl,InterfaceTable+ 6 \ jr InvokeInterfaceMethod SetSize push hl \ ld hl,InterfaceTable+ 8 \ jr InvokeInterfaceMethod GetPosition push hl \ ld hl,InterfaceTable+10 \ jr InvokeInterfaceMethod SetPosition push hl \ ld hl,InterfaceTable+12 \ jr InvokeInterfaceMethod IsEOF push hl \ ld hl,InterfaceTable+14 \ jr InvokeInterfaceMethod InvokeInterfaceMethod push af push de ld a,(ix+Info.Name+1) add a,a add a,a add a,a add a,a ld e,a ld d,0 add hl,de ld e,(hl) inc hl ld d,(hl) ex de,hl ld (OP1+0),hl pop de pop af pop hl ld (OP1+2),hl ld hl,ExitInterfaceMethod push hl ld hl,(OP1+0) push hl ld hl,(OP1+2) ret ExitInterfaceMethod ret SIRCS.Initialise ld (ix+Info.Position+0),1 \ ld (ix+Info.Position+1),0 ; TV ld (ix+Info.DataSize+0),12 \ ld (ix+Info.DataSize+1),0 ; 12-bit command word. or a ret SIRCS.ReadByte .fcall "Speed.SlowDown" - .fcall "SonyIR.Read" jr z,SIRCS.ReadByteSuccessful ei .fcall "Host.CanEscape" jr nz,- push af .fcall "Speed.SpeedUp" pop af scf ret SIRCS.ReadByteSuccessful ei ld (ix+Info.DataSize+0),a ld (ix+Info.Position+0),e ld (ix+Info.Position+1),d ld a,c or a push af .fcall "Speed.SpeedUp" pop af ret SIRCS.WriteByte push af .fcall "Speed.SlowDown" pop af ld c,a ld a,(ix+Info.DataSize+0) ld e,(ix+Info.Position+0) ld d,(ix+Info.Position+1) ld b,6 .fcall "SonyIR.WriteMultiple" ei .fcall "Speed.SpeedUp" or a ret SIRCS.GetSize ld l,(ix+Info.DataSize+0) ld h,(ix+Info.DataSize+1) or a ret SIRCS.SetSize ld a,h or a jr nz,SIRCS.BadWordSize ld a,l cp 12 jr z,SIRCS.GoodWordSize cp 15 jr z,SIRCS.GoodWordSize cp 20 jr nz,SIRCS.BadWordSize SIRCS.GoodWordSize ld (ix+Info.DataSize+0),a or a ret SIRCS.BadWordSize ld hl,Errors.BadWordSize scf ret SIRCS.GetPosition ld l,(ix+Info.Position+0) ld h,(ix+Info.Position+1) or a ret SIRCS.SetPosition ld (ix+Info.Position+0),l ld (ix+Info.Position+1),h or a ret Stub.Sorry ld hl,Errors.Sorry scf ret InterfaceTable .dw SIRCS.Initialise, SIRCS.ReadByte, SIRCS.WriteByte, SIRCS.GetSize, SIRCS.SetSize, SIRCS.GetPosition, SIRCS.SetPosition, Stub.Sorry .endmodule