; This is an example of a plug-in/startup/shutdown file all rolled into one. ; Upon running this program, it saves the contrast level of the TI Homescreen ; and restores the contrast of SuperNova. If this is the first time you ; have run this program, by default, the contrast level of SuperNova will ; be the contrast level of the TI Homescreen. Inside SuperNova or SuperNova ; programs, pressing [+] and [-] will change the contrast level. Upon ; exiting SuperNova, the contrast level of SuperNova will be saved and the ; contrast level of the TI Homescreen will be saved. ; Compile with TASM and use "MAKESN.EXE CONTRAST START END" #include "TI-85.H" .org 0 .db 0 ; Z-Terminated title of our program ; I didn't add a title to conserve space. ; A Plug-In file has took hook on to SuperNova so that it will be called ; during GET_KEY calls. To do this a Plug-In uses the startup and shutdown ; string characteristics to hook and unhook itself from SuperNova. ld hl,SN_BITS ; Load SN_BITS RE_CALC ; Oops! bit 6,(hl) ; Test Bit 6 for shutdown bit jr nz,Shutdown ; If Bit is set, run the shutdown routine ; otherwise proceed with startup routine Startup: ld hl,(PROGRAM_ADDR) ld de,Data add hl,de ; hl = Save area for the TI Homescreen ; contrast level ld a,(CONTRAST) ld (hl),a ; Save contrast data for the TI Homescreen inc hl ; hl = Save area for the SN contrast level ld a,(hl) cp $FF ; Check SN byte to see if this is the first ; time CONTRAST is being run. jr nz,NoNewUser ; Proceed to next stage if not. NewUser: ld a,(CONTRAST) ld (hl),a ; Otherwise by default, the contrast level ; will be the contrast level of the TI. NoNewUser: ld a,(hl) ld (CONTRAST),a ; Restore SuperNova contrast level LD_PLUGIN(oldhandler,customroutine) ; Load Plug-In system out (2),a ; Output Contrast ret ; Return to normal operation ; This is the plug-in routine for CONTRAST ; This routine will be called everytime GET_KEY is called. customroutine: push hl ; Make sure to save all registers! push bc push de push af start: ; Contrast Changer Routine cp $0A ; [+] = Contrast Up jr z,contrast_up cp $0B ; [-] = Contrast Down jr z,contrast_down return: pop af ; Restore all registers! pop de pop bc pop hl oldhandler: CALL ERROR_CALL ; This is needed so that other plugins ; will be called after this one is done. ; YOU MUST put this here, otherwise other previously loaded Plug-Ins ; WILL NOT BE CALLED by SuperNova. ret ; Jump back to SN ; Contrast Up Routine contrast_up: ld a,(CONTRAST) cp 31 jr z,return inc a ld (CONTRAST),a out (2),a jr return ; Contrast Down Routine contrast_down: ld a,(CONTRAST) cp 0 jr z,return dec a ld (CONTRAST),a out (2),a jr return ; This is run when SuperNova shuts down Shutdown: ld de,(PROGRAM_ADDR) ld hl,Data2 add hl,de ld a,(CONTRAST) ld (hl),a ; Save SuperNova contrast level dec hl ld a,(hl) ld (CONTRAST),a ; Restore TI Homescreen contrast level out (2),a ; Output Contrast Level ret ; Exit Data: .db $FF ; TI Homescreen Contrast Level Data Data2: .db $FF ; SuperNova Contrast Level Data .end