;print8x - USB Printer Driver and Interface ; (C) 2006 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 EXTERN IPutS,IGetKey,DispHexA,DispHexHL,PrinterInit,GetPrinterCapabilities,GetPrinterStatus,USBErrorNoDrv,USBError EXTERN vputstring,StartPrintJob,SendPrintData,StopPrintJob,IPutS11,IsLanguageSupported,SoftKey,SendSoftReset,LDL_sendReset EXTERN LDL_startPrintJob,LDL_stopPrintJob,LDL_ejectPage,PrintData Var USBDriverCall,32 ; 32; RAM calls for U_CALL and callback routine Var USBDriverBuf,128 ;128; Static buffer for USB driver's usage ;----------------------------------------------------------------------------- Init: U_CALL_INIT DummyRet jr c,USBErrorNoDrv ld hl,USBDriverBuf U_CALL DriverInit jr c,USBError U_CALL HostInit jr c,USBError ld a,5 B_CALL PutC ld b,1 U_CALL ConfigureDevice ld a,5 B_CALL PutC ld hl,appData ld (hl),0 inc hl ld (hl),0 inc hl ld (hl),0 inc hl ld (hl),4 inc hl ld (hl),1 ld b,5 ld c,2 ld hl,appData U_CALL SendData jr c,USBError ld a,5 B_CALL PutC B_CALL GetKey jr AppExit call PrinterInit jr c,USBError refreshData: B_CALL ClrLCDFull B_CALL GrBufClr ld hl,0 ld de,6*256+95 B_CALL FillRect ld hl,3 ld (penCol),hl ld hl,appBackUpScreen ld de,appBackUpScreen+64 call GetPrinterCapabilities jr c,USBError ld hl,appBackUpScreen+64 set textInverse,(iy+textFlags) call vputstring res textInverse,(iy+textFlags) call GetPrinterStatus jr c,USBError ld de,7*256+5 ld (penCol),de ld hl,sLanguagesSupported call vputstring ld hl,appBackUpScreen ld de,14*256+10 ld (penCol),de ld b,-5 langDispLoop: push bc call IsLanguageSupported push af call vputstring pop af push hl ld hl,sNotSupported jr nc,langIsSupported jr $F langIsSupported: ld hl,sSupported $$: call vputstring pop hl ld a,(penRow) add a,7 ld (penRow),a ld a,10 ld (penCol),a pop bc inc b jr z,$F ld a,(hl) or a jr nz,langDispLoop $$: call GetPrinterStatus jr c,USBError push af ld hl,48*256+5 ld (penCol),hl ld hl,sStatus call vputstring pop af push af and 00000001b set textInverse,(iy+textFlags) jr z,$F res textInverse,(iy+textFlags) $$: ld hl,sErrorStatus call vputstring pop af push af and 00000010b res textInverse,(iy+textFlags) jr z,$F set textInverse,(iy+textFlags) $$: ld hl,sSelected call vputstring pop af and 00000100b set textInverse,(iy+textFlags) jr z,$F res textInverse,(iy+textFlags) $$: ld hl,sPaper call vputstring res textInverse,(iy+textFlags) ld hl,sMenuTable call SoftKey mainKeyLoop: call IGetKey cp kMode jr z,AppExit cp kClear jr z,AppExit cp kQuit jr z,AppExit cp kZoom jr z,sendTestData cp kTrace jr z,printTestPage cp kGraph jr z,AppExit cp kYequ jr z,refreshData cp kWindow jr nz,mainKeyLoop call SendSoftReset jr refreshData sendTestData: call StartPrintJob ld hl,sTestPageData ;sLanguagesSupported ld bc,sTestPageDataEnd-sTestPageData ;sNotSupported-sLanguagesSupported-2 call PrintData call StopPrintJob jr mainKeyLoop printTestPage: call StartPrintJob ld hl,TIdata ld bc,TIdataEnd-TIdata call PrintData call StopPrintJob jr mainKeyLoop AppExit: B_CALL ClrLCDFull B_CALL HomeUp U_CALL HostKill U_CALL DriverKill B_JUMP JForceCmdNoChar DummyRet: ret sLanguagesSupported: DB "Languages supported: ",0 sNotSupported: DB " - UNSUPPORTED",0 sSupported: DB "- Supported",0 sMenuTable: DB "Updt",0 DB "Rset",0 DB "Prnt",0 DB "Test",0 DB "Quit",0 sStatus: DB "Status: ",0 sErrorStatus: DB 6,"ERR",6,0 sSelected: DB 6,"SEL",6,0 sPaper: DB 6,"PAPER",6,0 sTestPageData: DB "This is a printer test page.";,0Dh,0Dh DB "If you can read this text, then the driver is functioning correctly.";,0Dh,0Dh DB "This will be an extremely long sentence to see if text wrapping from one line" DB " to the next is functioning correctly. If not, please send me an e-mail to" DB " let me know what you did to reproduce the problem." DB "I may be able to figure out what the problem is and correct it so that text" DB "will wrap properly and everyone will be happy, especially you, since you can" DB "wrap text, and especially me, because I will have fixed it." sTestPageDataEnd: TIdata: DB 1Bh,26h,6Ch,31h,54h DB 1Bh,45h,1Bh,25h,2Dh,31h,32h DB 33h,34h,35h,58h,0Ch,"Steve & Hank - USB Printer",0Dh,0Ah,0Dh,0Ah DB "GO MAVERICKS!!!!!!",1Bh,45h,1Bh,25h,2Dh,31h,32h,33h,34h,35h,58h DB 58h,40h,50h,4Ah,4Ch,20h,4Ah,4Fh,42h,20h,4Eh,41h,4Dh,45h,3Dh,22h,5Ah,22h,0Dh,0Ah,40h,50h,4Ah,4Ch,20h,45h,4Eh,54h,45h,52h,20h,4Ch DB 41h,4Eh,47h,55h,41h,47h,45h,20h,3Dh,20h,50h,43h,4Ch,0Ah,1Bh,45h,41h,4Ch,56h,1Bh,25h,2Dh,31h,32h,33h,34h,35h,58h,40h,50h,4Ah,4Ch DB 20h,45h,4Fh,4Ah,20h,4Eh,41h,4Dh,45h,3Dh,22h,5Ah,22h,0Dh,0Ah,1Bh,25h,2Dh,31h,32h,33h,34h,35h,58h,1Bh,25h,2Dh,31h,32h,33h,34h,35h DB 58h,40h,50h,4Ah,4Ch,20h,53h,45h,54h,20h,52h,45h,53h,4Fh,4Ch,55h,54h,49h,4Fh,4Eh,20h,3Dh,20h,36h,30h,30h,0Dh,0Ah,40h,50h,4Ah,4Ch DB 20h,45h,4Eh,54h,45h,52h,20h,4Ch,41h,4Eh,47h,55h,41h,47h,45h,20h,3Dh,20h,50h,43h,4Ch,0Ah,1Bh,45h,1Bh,2Ah,70h,36h,30h,30h,59h,1Bh DB 2Ah,70h,32h,30h,30h,58h,1Bh,2Ah,74h,37h,35h,52h,1Bh,2Ah,72h,30h,46h,1Bh,2Ah,72h,31h,41h,1Bh,2Ah,62h,31h,32h,57h,7Fh,0FFh,0EFh,0FFh DB 0FDh,0FFh,0FFh,0BFh,0FFh,0F7h,0FFh,0FEh,1Bh,2Ah,62h,31h,32h,57h,80h,00h,30h,00h,06h,00h,00h,0C0h,00h,18h,00h,02h,1Bh,2Ah,62h,31h,32h,57h DB 0BBh,0A3h,0B7h,67h,76h,0ACh,4Ch,0D5h,0D1h,9Bh,0B3h,0BAh,1Bh,2Ah,62h,31h,32h,57h,0A1h,22h,34h,52h,26h,0AAh,0AAh,0D5h,11h,59h,2Ah,2Ah,1Bh,2Ah DB 62h,31h,32h,57h,0B1h,23h,36h,52h,26h,0ACh,0ECh,0DDh,91h,99h,2Bh,2Ah,1Bh,2Ah,62h,31h,32h,57h,0A1h,22h,34h,52h,26h,0EAh,0A8h,0D5h,11h,19h DB 2Ah,2Ah,1Bh,2Ah,62h,31h,32h,57h,0A3h,0BBh,0B7h,67h,26h,0AAh,0A8h,0D5h,0DDh,1Bh,0AAh,3Ah,1Bh,2Ah,62h,31h,32h,57h,80h,00h,30h,00h,06h,00h DB 00h,0C0h,00h,18h,00h,02h,1Bh,2Ah,72h,43h,1Bh,45h,1Bh,25h,2Dh,31h,32h,33h,34h,35h,58h,53h,74h,65h,76h,65h,20h,46h,61h,6Ch,61h,73h DB 74h,65h,72h,1Bh,25h,2Dh,31h,32h,33h,34h,35h,58h,40h,50h,4Ah,4Ch,20h,53h,45h,54h,20h,52h,45h,53h,4Fh,4Ch,55h,54h,49h,4Fh,4Eh,20h DB 3Dh,20h,36h,30h,30h,0Dh,0Ah,40h,50h,4Ah,4Ch,20h,45h,4Eh,54h,45h,52h,20h,4Ch,41h,4Eh,47h,55h,41h,47h,45h,20h,3Dh,20h,50h,43h,4Ch DB 0Ah,1Bh,45h,1Bh,2Ah,70h,36h,30h,30h,59h,1Bh,2Ah,70h,32h,30h,30h,58h,1Bh,2Ah,74h,37h,35h,52h,1Bh,2Ah,72h,30h,46h,1Bh,2Ah,72h,31h DB 41h,1Bh,2Ah,62h,31h,32h,57h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,1Bh,2Ah,62h,31h,32h,57h,80h,00h,08h,00h,00h,04h,00h DB 00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,93h,18h,08h,00h,40h,04h,00h,0C0h,02h,00h,60h,01h,1Bh,2Ah,62h,31h,32h,57h,0AAh,0A0h,08h DB 00h,0A0h,04h,00h,0A0h,02h,00h,80h,01h,1Bh,2Ah,62h,31h,32h,57h,0BBh,20h,08h,00h,0E0h,04h,00h,0C0h,02h,00h,80h,01h,1Bh,2Ah,62h,31h,32h DB 57h,0AAh,0A0h,08h,00h,0A0h,04h,00h,0A0h,02h,00h,80h,01h,1Bh,2Ah,62h,31h,32h,57h,0ABh,18h,08h,00h,0A0h,04h,00h,0C0h,02h,00h,60h,01h,1Bh DB 2Ah,62h,31h,32h,57h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,1Bh,2Ah,62h,31h,32h,57h,80h,00h,0Fh,0FFh,0FFh,0FCh,00h,00h,02h DB 00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,10h,0Fh,0FFh,0FFh,0FCh,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,30h,0Fh,0FFh,0FFh DB 0FCh,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,10h,0Fh,0FFh,0FFh,0FCh,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h DB 10h,0Fh,0FFh,0FFh,0FCh,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,38h,0Fh,0FFh,0FFh,0FCh,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h DB 31h,32h,57h,80h,00h,0Fh,0FFh,0FFh,0FCh,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh DB 0FFh,1Bh,2Ah,62h,31h,32h,57h,80h,00h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,30h,08h,00h,00h,04h,00h DB 00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,08h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,10h,08h DB 00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,20h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h DB 57h,80h,38h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,00h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh DB 2Ah,62h,31h,32h,57h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,1Bh,2Ah,62h,31h,32h,57h,80h,00h,08h,00h,00h,04h,00h,00h,02h DB 00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,30h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,08h,08h,00h,00h DB 04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,10h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h DB 08h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,30h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h DB 31h,32h,57h,80h,00h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh DB 0FFh,1Bh,2Ah,62h,31h,32h,57h,80h,00h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,20h,08h,00h,00h,04h,00h DB 00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,28h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,38h,08h DB 00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,08h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h DB 57h,80h,08h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,00h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh DB 2Ah,62h,31h,32h,57h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,1Bh,2Ah,62h,31h,32h,57h,80h,00h,08h,00h,00h,04h,00h,00h,02h DB 00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,38h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,20h,08h,00h,00h DB 04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,30h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h DB 08h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,30h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h DB 31h,32h,57h,80h,00h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh DB 0FFh,1Bh,2Ah,62h,31h,32h,57h,80h,00h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,18h,08h,00h,00h,04h,00h DB 00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,20h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,38h,08h DB 00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,28h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h DB 57h,80h,38h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh,2Ah,62h,31h,32h,57h,80h,00h,08h,00h,00h,04h,00h,00h,02h,00h,00h,01h,1Bh DB 2Ah,62h,31h,32h,57h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,1Bh,2Ah,62h,31h,32h,57h,80h,00h,00h,00h,00h,00h,00h,00h,00h DB 3Fh,0FFh,0F9h,1Bh,2Ah,62h,31h,32h,57h,91h,00h,00h,00h,00h,00h,00h,00h,00h,4Ah,00h,05h,1Bh,2Ah,62h,31h,32h,57h,0ABh,20h,00h,00h,00h DB 00h,00h,00h,00h,4Eh,4Ch,0A5h,1Bh,2Ah,62h,31h,32h,57h,0B9h,00h,00h,00h,00h,00h,00h,00h,00h,4Eh,0AAh,0A5h,1Bh,2Ah,62h,31h,32h,57h,0A9h DB 20h,00h,00h,00h,00h,00h,00h,00h,4Ah,0CAh,0A5h,1Bh,2Ah,62h,31h,32h,57h,0ABh,80h,00h,00h,00h,00h,00h,00h,00h,4Ah,6Ah,0E5h,1Bh,2Ah,62h DB 31h,32h,57h,80h,00h,00h,00h,00h,00h,00h,00h,00h,40h,00h,05h,1Bh,2Ah,62h,31h,32h,57h,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh DB 0FFh,1Bh,2Ah,72h,43h,1Bh,45h,1Bh,25h,53h,74h,65h,76h,65h,20h,46h,61h,6Ch,61h,73h,74h,65h,72h TIdataEnd: