A83: hiding progs


[Prev][Next][Index][Thread]

A83: hiding progs




i just finished this. i haven't uploaded it yet (not that it would show
up for a few days anyway), but i thought i would post it. just remember,
i wrote this and i am going to upload it to ticalc. in other words don't
take credit for this and if you do use it give me credit.

btw, the prog has to be named ZNOPROGS and it has to be squished.


;--------------------------------------------------------
; Name:         No Progs 83
; Author:       Ian Graf (ian_graf@geocities.com)
; Version:      1.0
; Platform:     TI-OS
; Language:     TI-83 Assembly
; Memory:       375 bytes (not including ZASMLOAD)
; Date:         20/8/98
;--------------------------------------------------------


.NOLIST
#define equ .equ
#define EQU .equ
#define end .end
#include "ti83asm.inc"
#include "tokens.inc"
.LIST

#define char_table_end $8401

.org $9327

     im 1                       ; make sure it isn't running in im 2

     ld hl,noprogs              ; display "No Progs 83"
     call _puts                 ;
     call _newline              ;

     ld hl,by                   ; display "By Ian Graf"
     call _puts                 ;
     call _newline              ;

     ld a,(state)               ; check if it is running
     or a                       ;
     jr nz,disable_interrupt    ;

enable_interrupt:

     ld hl,enabled              ; dipslay "Enabled"
     call _puts                 ;
     call _newline              ;

     ld a,1                     ; set state to enabled
     call store_state           ;

     ld hl,$8300                ; set up interrupt vector
     ld de,$8301                ;
     ld (hl),$84                ;
     ld bc,$0100                ;
     ldir                       ;

     ld hl,interrupt_start      ; copy interrupt
     ld de,$8484                ;
     ld bc,interrupt_end-interrupt_start+1  ;
     ldir                       ;

     ld de,$8403                ; set end of char table to 3rd byte of
     ld (char_table_end),de     ; free mem in the apd buff

     ld a,$83                   ; point i to interrupt vector
     ld i,a                     ;
     im 2                       ;
     ret                        ;

disable_interrupt:

     ld hl,disabled             ; display "Disabled"
     call _puts                 ;
     call _newline              ;

     xor a                      ; set state to disabled
     ld (state),a               ;

store_state:

     push af                    ; write back state
     call _zerooop1             ;
     ld de,op1                  ;
     ld hl,progname             ;
     ld bc,9                    ;
     ldir                       ;
     call _chkfindsym           ;
     inc de                     ;
     inc de                     ;
     ld hl,state-$9327          ;
     add hl,de                  ;
     pop af                     ;
     ld (hl),a                  ;
     ret                        ;


;-------------------------------
; interrupt program

interrupt_start:

     di                         ;
     ex af,af'                  ;
     exx                        ;

     ld a,($800A)               ; apd counter
     cp $11                     ;
     jr c,interrupt_off         ;

     ld a,$11011111             ;
     out (1),a                  ;
     in a,(1)                   ;
     bit 2,a                    ; right arrow
     jr nz,exit_interrupt       ;

     bit indicrun,(iy+indicflags)  ; run indicator on
     jr nz,exit_interrupt       ;

     bit plotdisp,(iy+plotflags)  ; in graph screen
     jr nz,exit_interrupt       ;

     bit curlock,(iy+curflags)  ; cursor off
     jr nz,exit_interrupt       ;

     ld de,(char_table_end)     ; get pointer to end of char table
     ld hl,(progptr)            ; reset pointer to current program

next_prog:

     call detect-interrupt_start+$8484  ; find next program
     jr z,change_name           ; change the name
     ld (char_table_end),de     ; store pointer to end of table

exit_interrupt:

     exx                        ;
     ex af,af'                  ;
     jp $0038                   ; normal interrupt handler

interrupt_off:

     ld a,$74                   ; reset apd counter
     ld ($800A),a               ;

     ld a,$08                   ; turn off lcd
     out (3),a                  ;
     ld a,$01                   ; mask on key interrupts
     out (3),a                  ;
     pop hl                     ; return to when the int occured
     exx                        ;
     ex af,af'                  ;
     ei                         ; enable interrupts
     halt                       ; wait for an interrupt
     jp $0038                   ;

change_name:

     dec hl                     ; skip type
     dec hl                     ; skip size
     dec hl                     ; skip size
     ld b,(hl)                  ; get name length
     push bc                    ;
     dec hl                     ; first char
     ld a,(hl)                  ; get char
     cp '!'                     ; check if it is system prog
     jr z,name                  ; "!" or "#"
     cp '#'                     ;
     jr z,name                  ;
     cp '('                     ; hidden?
     jr nz,hide                 ; hide it

show:

     ld a,($8403)               ; get char
     ld (hl),a                  ; store to name
     push hl                    ; store pointer
     push de                    ;
     ld hl,$8404                ; shrink char table by 1 byte
     ld de,$8403                ;
     ld bc,128                  ;
     ldir                       ;
     pop de                     ;
     pop hl                     ; restore pointer
     dec de                     ;
     jr name                    ; skip past rest of name

hide:

     ld a,(hl)                  ; get char
     ld (de),a                  ; add char to end of table
     inc de                     ; move past char
     ld a,'('                   ; change prog name
     ld (hl),a                  ;

name:

     pop bc                     ; restore length of name

namel:

     dec hl                     ; next char 
     djnz namel                 ;
     jr next_prog               ; next program

detect:

     ld a,(hl)                  ; vat location
     and %00011111              ; mask system bits
     dec a                      ; cp $01
     jr z,list                  ;
     cp 12                      ; cp $0D
     jr z,list                  ;
     sub 4                      ; cp $05
     ret z                      ;
     dec a                      ; cp $06
     ret                        ;

list:

     dec hl                     ; skip pointer
     dec hl                     ; skip size
     dec hl                     ; skip size
     ld b,(hl)                  ; name length

listl:

     dec hl                     ; skip char
     djnz listl                 ;
     dec hl                     ; next pointer
     jr detect                  ; look for program

interrupt_end:


;-------------------------------
; dialog

noprogs:

     .db "No Progs 83",0

by:

     .db "By Ian Graf",0

enabled:

     .db "Enabled",0

disabled:

     .db "Disabled",0

progname:

     .db 5,"ZNOPROGS"

state:

     .db 0

.end
END