;VS8x - TI Presentation Link Adapter Driver ; (C) 2010 by Brandon Wilson. All rights reserved. ;Portions in util.asm, usb8x.inc, equates.inc (C) Dan Englender. include "settings.inc" ;Specific settings for this application NOLIST include "ti83plus.inc" LIST include "equates.inc" ;Equates and macros to be used include "header.asm" GLOBALS ON include "usb8x.inc" ;usb8x equates SEGMENT MAIN Var USBDriverCall,32 ; 32; RAM calls for U_CALL and callback routine Var USBDriverBuf,128 ;128; Static buffer for USB driver's usage EXTERN DispHexHL,DispHexA,IPutS,IPutC ;----------------------------------------------------------------------------- Init: ld hl,DummyCallback ld de,DummyCallbackLoc ld bc,DummyCallbackEnd-DummyCallback ldir U_CALL_INIT DummyCallbackLoc jr c,ExitApp B_CALL ClrLCDFull B_CALL HomeUp ld hl,USBDriverBuf U_CALL DriverInit jr c,ExitAppError call InitializePresentationLink jr c,ExitAppError call PresentationLinkClear ld hl,sEnterPicNumber call IPutS B_CALL ZeroOP1 B_CALL GetKey cp k0 jr c,DisplayCheckeredPattern cp k9+1 jr nc,DisplayCheckeredPattern ;Display picture's data, if it exists sub k0 jr z,$F add a,tPic1-1 jr storePicName $$: ld a,tPic0 storePicName: ld (OP1+2),a ld a,PictObj ld (OP1),a ld a,tVarPict ld (OP1+1),a rst rFINDSYM jr c,DisplayCheckeredPattern push de ld hl,plotSScreen ld bc,768 B_CALL MemClear pop hl ld c,(hl) inc hl ld b,(hl) inc hl ld de,plotSScreen push de ldir pop hl call PresentationLinkFastCopy jr pictureDisplayed DisplayCheckeredPattern: ;Display a checkered test pattern ld hl,plotSScreen ld de,plotSScreen+1 ld (hl),10101010b ld bc,767 push hl ldir pop hl call PresentationLinkFastCopy pictureDisplayed: B_CALL NewLine ld hl,sSuccess call IPutS B_CALL GetKey ExitApp: B_CALL ClrLCDFull B_CALL HomeUp B_CALL ClrTxtShd U_CALL HostKill U_CALL DriverKill B_JUMP JForceCmdNoChar ExitAppNoDrv: B_CALL ClrLCDFull B_CALL HomeUp B_CALL ClrTxtShd ExitAppError: B_CALL ClrLCDFull B_CALL HomeUp ld a,'E' B_CALL PutC U_CALL GetErrorCode ld h,b ld l,c call DispHexHL B_CALL GetKey B_CALL ClrLCDFull B_CALL HomeUp B_CALL ClrTxtShd U_CALL HostKill U_CALL DriverKill B_JUMP JForceCmdNoChar DummyCallback: ret DummyCallbackEnd: mainMenu: DB "VS8x v",VER_STRING,0 DB "1) Test",0 DW ExitApp DB "2) Quit",0 DW ExitApp sEnterPicNumber: DB "Enter Pic " DB "number ",LlBrack,"0-9]:",0 sSuccess: DB "Success! Press " DB "any key...",0 InitializePresentationLink: ;Initializes the USB Presentation Link adapter device and driver. ;Inputs: None ;Outputs: Returns carry flag set if problems ;Disable and kill the adapter if it's already connected and initialized res 3,(iy+41h) rst 28h DW 5311h xor a out (5Ah),a in a,(5Ah) ;Initialize the Presentation Link adapter U_CALL HostInit ret c ;Set the configuration ld b,1 U_CALL ConfigureDevice ret c ;Set up outgoing pipe ld bc,02h*256+pipeBulk ld de,2*256+0 U_CALL SetupOutPipe ;TODO: initialize the "LCD driver" ld a,40h call WriteInstruction ld a,05h call WriteInstruction ld a,01h call WriteInstruction ld a,03h call WriteInstruction ld a,16h call WriteInstruction ld a,08h call WriteInstruction ld a,0C0h call WriteInstruction ret PresentationLinkClear: ;Clears the Presentation Link adapter's display. ;Inputs: None ;Outputs: None ;Destroys plotSScreen. ;Returns carry flag set if problems ;Clear the display ld hl,plotSScreen ld de,plotSScreen+1 ld (hl),0 ld bc,767 push hl ldir pop hl ;NOTE: FALL THROUGH TO PresentationLinkFastCopy PresentationLinkFastCopy: ;Copies a 768-byte buffer to the Presentation Link adapter for displaying on a TV or projector. ;Inputs: HL => 768-byte buffer (such as plotSScreen) ;Outputs: Returns carry flag set if problems ld b,64 xor a call WriteInstruction ld a,40h call WriteInstruction ld a,05h call WriteInstruction ld a,01h call WriteInstruction ld a,07h call WriteInstruction ld a,80h-1 TIPFC_1: inc a push af push bc call WriteInstruction ld a,20h call WriteInstruction ld b,12 $$: ld a,(hl) call WriteData inc hl djnz $B pop bc pop af djnz TIPFC_1 ld a,05h ;NOTE: FALL THROUGH TO WriteInstruction WriteInstruction: ;Writes value to Presentation Link adapter's "LCD instruction" port. ;Inputs: A: value ;Outputs: Returns carry flag set if problems ;Preserves all registers (except A). push bc ld b,0 jr $F WriteData: ;Writes value to Presentation Link adapter's "LCD data" port. ;Inputs: A: value ;Outputs: Returns carry flag set if problems ;Preserves all registers (except A). push bc ld b,1 $$: call 000Bh push hl push de ld hl,appData ld (hl),a inc hl ld (hl),b dec hl ld b,2 ld c,02h U_CALL SendData pop de pop hl pop bc ret