;MISh GUI ;By: Mikel Blanchrad ;http://TheLayer.home.ml.org/ ; ;Please do not put your name on this without telling me first :) ; ;Any optimization will be greatly appreciated! ;This program was modified by Richard Lewis to run under MISh v1.0 #include ti-85.h #include mish10.h PROG_HEADER =$FD #DEFINE UsgStart $8BF9 ; For Usgard, not needed. UsgLength = $8BF7 noStr = $80DF curVAT = $80E0 firstpg = $80E2 curStr = $80E3 VATName = TEXT_MEM2+158 ;9 bytes... proglist = $8100 .org 0 .db "MISh Standard GUI",0 Restart: ROM_CALL(CLEARLCD) ; DE gets cleared by CLEARLCD. inc e ; DE+1 ld ($8333),de ; CURSOR_X,CURSOR_Y = DE CALL_(BorderLines) ; Draw the nifty borders... ld hl,toptext ; Text in the top bar. ld de,(PROGRAM_ADDR) ; ZShell crap :Þ add hl,de ; You know I would prefer relocation. ROM_CALL(D_ZM_STR) ; Show the text. ld hl,$3901 ; (X,Y) For bottom text. ld ($8333),hl ld hl,BotInfo ; The text. ld de,(PROGRAM_ADDR) ; More of ZShell's crap :Þ add hl,de ROM_CALL(D_ZM_STR) ; Show it. ld hl,$FC00 ; HL= VIDEO_MEM CALL_(RepFill1) ; Invert that section of HL... ld hl,$FF90 ; HL= VIDEO_MEM+912 CALL_(RepFill1) ; Invert the bottom... RestartVAT: ld hl,VAT_START ; Skip the first entry, the Usgard string itself. ld (curVAT),hl ; Save where we are in the VAT. xor a ld (firstpg),a ; A= 0 ScanStrings: xor a ld (noStr),a ; noStr = 0 > No progs found...yet ld hl,$0802 ; (X/Y) for first prog. ld ($8333),hl ld hl,(curVAT) ; Get where we are. ld ix,proglist ; Where to put the prog list... Search: ld a,$0C ; $0C = 12 = String CALL_(fSEARCH_VAT) ; Search VAT @ Hl, for type A jr c,EndOfVAT ; If Carry set, then End of Vat Reached push hl ld a,(de) ; A= 1st byte of VAT "file" or a ; Invoke the Zerro Flag. jr nz,NoAsmProg ;If the first byte wasn't zero, then not a valid file inc de ; DE= 2nd byte of VAT "file" ld a,(de) ; A=(DE) cp PROG_HEADER ; Is the header correct? jr nz,NoAsmProg ;c ; Nope, so skip it. inc de ; Skip descritption... inc de ld hl,(PROGRAM_ADDR) ; HL=Program Address call CP_HL_DE ; Check if the program found is the shell jr z,NoAsmProg ; If Yes, then skip. push de ld hl,noStr ; HL= Number of files found. inc (hl) ; HL+1->HL ld hl,VATName ; HL=The name of the file. push hl push ix pop de ld bc,9 ldir ; Load the name...9 bytes... push de pop ix pop hl ROM_CALL(D_ZM_STR) ; Show the name! ld a,$29 ; Set (X/Y) for description. ld ($8333),a pop hl ROM_CALL(D_ZM_STR) ; Show it. ld hl,$8333 ; Get Current (X/Y). ld (hl),2 ; Put a two into the X. inc hl ; HL points to Y. ld a,(hl) ; A=Y add a,7 ; Y+7->A ld (hl),a ; Y=A NoAsmProg: pop hl ld a,(noStr) ; A= # of files found. cp 7 ; Is it 7? jr nz,Search ; No, so start again. EndOfVAT: ; End reached. ld (curVAT),hl ; Save where we are...for [MORE] key... ld hl,firstpg ld b,(hl) ; B=Place (for inverted cursor). inc (hl) ld a,(noStr) ; A= How many found. or a ; Invoke Zero Flag. jr nz,SelectProgram ; If #found > 0, then continue the program. or b JUMP_NZ(RestartVAT) ld hl,NoProgsTxt ; No Progs text. ld de,(PROGRAM_ADDR) ; ZShell crap. add hl,de ROM_CALL(D_ZM_STR) ; Show message. WAITENTER: ; Wait for enter. call GET_KEY cp K_ENTER ret z ; Leave. jr WAITENTER SelectProgram: xor a ; A=0 Update: ld (curStr),a ; curStr = 0...for [MORE] key action... Update2: CALL_(InvertCurrent) ; Invert the current selection... ld a,(noStr) ; A= noStr ld c,a ; C=A WaitKey: ; The main loop. APD_ON call GET_KEY ; Get Key into A or a ; or A < cp 0 jr z,WaitKey ; If A=0 check again. call APD_RESET ; Update APD! Woops! Not ZShell! APD_OFF cp K_ALPHA ; [ALPHA] Key? CALL_Z(ShutDown) ; Yup, Shutdown! cp K_MORE ; [MORE] Key? JUMP_Z(Beforerescan) ; Yup, so flip the page. cp K_EXIT ; [EXIT] key? ret z ; Leave if so. cp K_ENTER ; [ENTER]? jr z,ExecuteProgram ; Run it! ld hl,curStr ; HL= Cursor Place dec a ; A-1->A jr z,CursorDown ; Move cursor down. cp 3 ; Was it 3? jr nz,WaitKey ; No, so check keys again. CALL_(InvertCurrent) ; Invert it. ld a,(hl) ; A= Cursor Place dec (hl) ; HL-1->HL or a ; 0? jr nz,Update2 ; Nope, so Update. ld a,c dec a ; Move the inverted bar. jr Update ; Update CursorDown: CALL_(InvertCurrent) ; Invert it. ld a,(hl) ; HL= curStr = A inc a ; A+1->A cp c ; At the top? jr nz,Update ; Nope, So Update. jr SelectProgram ; Select it. ExecuteProgram: ; Run it. ld a,(curStr) ld h,9 ld l,a CALL_(MUL_HL) ; Get the actual spot. ld de,proglist ; DE=proglist add hl,de ; Get the prog... push HL ld BC,8 xor A ld (ZS_BITS),A ;make sure it is ZERO cpir dec HL ex DE,HL pop HL ex DE,HL sbc HL,DE ld A,L ld (OP1+1),A ex DE,HL ; ROM_CALL(VAR_EXEC) ; Run it! (HL= Var Name) ld DE,OP1+2 ld BC,8 ldir ;copy var name ld A,12 ld (OP1),A ;set type ld HL,(PROGRAM_ADDR) push HL call EXE pop HL ld (PROGRAM_ADDR),HL ld hl,ZS_BITS ; HL=ZSHELL_BITS bit 1,(hl) ret nz ; Leave Ok. call SET_DEF JUMP_(Restart) InvertCurrent: push hl ld a,(curStr) ld h,112 ld l,a CALL_(MUL_HL) ld de,$FC80 add hl,de ld b,112 Invert: ld a,(hl) cpl ld (hl),a inc hl djnz Invert pop hl ret ShutDown: CALL_(fSHUTDOWN) xor a ret CLEAR: ld (hl),0 fOTH_FILL: ld d,h ld e,l inc de ldir ret Beforerescan: ld hl,$FC80 ld bc,783 CALL_(CLEAR) CALL_(BorderLines) JUMP_(ScanStrings) BorderLines: ld ix,VIDEO_MEM+112 ; What we want to change! ld b,50 ; 62 times to loop...One screen lenght (width) ld de,16 ; make it vert! DrawBorder_LR: ; Draw Left, and both right walls! ld (ix),128 ; Draw Left Vert...128=One Startight Line ld (ix+4),1 ; (ix+4) equals 4th place...1=thickness ld (ix+15),1 ; (ix+15) equals far right edge...1=thickness add ix,de ; Fix the vert djnz DrawBorder_LR ; Check it b=0...if not go to DrawBorder_LR! ret RepFill1: ld b,112 RepFill: ld a,(hl) cpl ld (hl),a inc hl djnz RepFill ret NoProgsTxt: .db "No progs",0 toptext: .db 5,"MISh GUI v1.0 " .db "-- Mikel Blanchard",0 BotInfo: .db "[",6," ",7,"]"," move " .db "[ENTER] run " .db "[EXIT] quits",0 fSEARCH_VAT: ; *** SEARCH THE VAT ld de,(VAT_END) ; 4 inc de ; 1 call CP_HL_DE ; 3? ret c ; 1 cp (hl) ; 1 jr nz,SkipName ; 2 dec hl ; 1 ld c,(hl) ; 1 dec hl ; 1 ld b,(hl) ; 1 dec hl ; 1 ld de,VATName ; 3 push bc ; 1 ld b,(hl) ; 1 VAT_GetName: dec hl ; 1 ld a,(hl) ; 1 ld (de),a ; 1 inc de ; 1 djnz VAT_GetName ; 2 xor a ; 1 ld (de),a ; 1 pop de ; 1 dec hl ; 1 inc de ; 1 inc de ; 1 ;DE = pointer to data area ;VATName = name of VAT Entry ;HL updated or a ; 1 ret ; 1 SkipName: dec hl ; 1 dec hl ; 1 dec hl ; 1 ld e,(hl) ; 1 inc e ; 1 ld d,0 ; 2 or a ; 1 sbc hl,de ; 2 jr fSEARCH_VAT ; 2 = 48 MUL_HL: ld E, L ld D, 0 ld B, H ld HL, 0 Startmul: add HL, DE djnz Startmul ret fSHUTDOWN: DI ld a, 00000001b OUT ($03),A ;76543210 ld a, 00000000 ; |||| ; ||++---Low Resistance ; ++---- 10 Byte Buffer out (4),a EX AF,AF' ; 4B59 EXX ; 4B5A ;ld a, $40 ; Doesn't work correctly ;out (6),a EI HALT TurnOn: ;DI ld a, $16 ; Normal Buffer Mode out (4),a ld a, $41 out (6),a ld a, 00001011b ;LCD On out (3),a ;EI ret .end