;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 ;This is a stripped down version of MishStan.asm; I did it to make it small #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 toptext: .db "MISh Mini Menu v1.0",0 Restart: ROM_CALL(CLEARLCD) ; DE gets cleared by CLEARLCD. inc e ; DE+1 ld ($8333),de ; CURSOR_X,CURSOR_Y = DE ld hl,(PROGRAM_ADDR) ; Text in the top bar. ROM_CALL(D_ZM_STR) ; Show the text. 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 8;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) ret ; Leave. 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 ;APD stuff call APD_RESET WaitGetKey: call GET_KEY ; Get Key into A or a ; or A < cp 0 jr z,WaitGetKey ; If A=0 check again. APD_OFF 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 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 CLEAR: ld (hl),0 fOTH_FILL: ld d,h ld e,l inc de ldir ret Beforerescan: ld hl,$FC80 ld bc,895;783 CALL_(CLEAR) JUMP_(ScanStrings) 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 .end