: un début de désarchivage des programmes (mais je suis à peu près sûr que ça ne marche pas encore
zshell.z80
.nolist
;#include "ti84pcse.inc"
#include "ti83p.inc" ; only for debug
#define program_length_count saferam1
.list
.org $4000
.db $80,$0f,$00,$00,$00,$00 ; program length = 0
.db $80,$12,$01,$04 ; program type = shareware for TI 83+
.db $80,$21,$01 ; app id = 1
.db $80,$31,$01 ; app build # = 1
.db $80,$48, "zSHELL " ; app name (must be 8 bytes long)
.db $80,$81,$01 ; app page = 1
.db $80,$90 ; no default splash screen
.db $03,$26,$09,$04,$04,$06f,$1b,$80 ; date stamp = 5/12/1999
.db $02,$0d,$40 ; encrypted TI date stamp signature
.db $a1,$6b,$99,$f6,$59,$bc,$67
.db $f5,$85,$9c,$09,$6c,$0f,$b4,$03,$9b,$c9
.db $03,$32,$2c,$e0,$03,$20,$e3,$2c,$f4,$2d
.db $73,$b4,$27,$c4,$a0,$72,$54,$b9,$ea,$7c
.db $3b,$aa,$16,$f6,$77,$83,$7a,$ee,$1a,$d4
.db $42,$4c,$6b,$8b,$13,$1f,$bb,$93,$8b,$fc
.db $19,$1c,$3c,$ec,$4d,$e5,$75
.db $80,$7f,$00,$00,$00,$00 ; program image length = 0
.dw $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000 ; padding (header length must be 128 bytes long)
start:
di ; disable interrupts (todo : check which bcall may resume them)
bcall(_clrlcdfull) ; clear screen
bcall(_indicatoroff) ; disable run indicator
bcall(_cleargbuf) ; clear graph buffer
res texterasebelow,(iy+textflags) ; reset some textflags
res textinverse,(iy+textflags) ; reset some textflags
ld hl,$0501
ld (currow),hl
ld hl,zshell_string
call iputs
bit parserhookactive,(iy+hookflags4)
jr z,install_zshell ; no current hook
;in a,(pmpagea)
;ld hl,parserhookptr+2
;cp (hl)
;jr nz,quit ; zshell hook already exists
uninstall_zshell:
; todo : ask to destroy/chain current hooks or uninstall zshell hook
bcall(_disableparserhook)
ld hl,$0003
ld (currow),hl
ld hl,uninstalling_string
call iputs
bcall(_getkey)
bcall(_jforcecmdnochar)
install_zshell:
ld hl,zshell_hook ; put hook adress into hl
in a,(pmpagea) ; put page # into a
bcall(_setparserhook) ; install hook
ld hl,$0003
ld (currow),hl
ld hl,installing_string
call iputs
bcall(_getkey)
quit:
; todo : ask for destroying or chaining it
bcall(_jforcecmdnochar) ; quit the app
iputs:
ld a,(hl)
or a
ret z
bcall(_putc)
inc hl
jr iputs
get_byte:
push de ; de = vat pointer
push hl ; hl = data to read
ld a,b ; b = flash page #, or 0 if in ram
or a
call nz,get_byte_paged
push hl
ld hl,(program_length_count)
dec (hl) ; just to make sure we're not reading out of the program (todo : check if prgm length are +1)
ld a,(hl)
or a
pop hl
ld a,(hl)
pop hl
pop de
inc hl
ret nz
scf ; c is set if we're out of the program
ret
get_byte_paged:
push bc
ld a,b
bcall(_getbytepaged)
ld (hl),b
pop bc
ret
#include "hook.inc"
zshell_string:
.db "zSHELL",0
installing_string:
.db "zSHELL has been installed",0
uninstalling_string:
.db "zSHELL has been uninstalled",0
.end
hook.inc
zshell_hook:
.db $83 ; used by os for hook safety check (add a,e can be used too)
or a
jr z,zshell_hook_start ; we just want to handle prgm, not TI-Basic functions
zshell_hook_return_z:
xor a
ret
zshell_hook_start:
ld hl,(basic_start) ; what's on homescreen
ld a,(hl)
cp tprog
jr nz,zshell_hook_return_z
zshell_hook_continue:
rst rmov9toop1
ld hl,op1
ld (hl),progobj
bcall(_chkfindsym)
ex de,hl ; cause of _getbytepaged parameters
ld a,e_undefined
bjumpc(_jerror)
call get_byte
ld e,a
call get_byte
ret c ; the program is empty
ld d,a ; de now contains the length of the program
ld (program_length_count),de
call get_byte ; skip t2bytetok/texttok
call get_byte
cp tasmprgm
ld hl,asm_unsquished_txt
jr z,zshell_hook_execute_prgm
;cp tzshellprgm
;ld hl,zshell_txt
;jr z,zshell_hook_execute_prgm
jr zshell_hook_return_z ; TI-Basic program
zshell_hook_execute_prgm:
; todo : skip zshell things
ld a,b
or a
call nz,zshell_hook_unarchive
; todo : relocate non archived prgm before launch
jp progstart
zshell_hook_unarchive:
push hl
ld hl,(program_length_count)
push bc
bcall(_enoughmem)
pop bc
pop hl
ld a,e_memory
bjumpc(_jerror)
ld a,b
ld de,progstart
ld bc,(program_length_count)
bcall(_flashtoram)
ret
zshell_hook_return_nz:
or $80 ; reset zero flag, the parser can't continue to parse the variable
ret
asm_unsquished_txt:
.db "ASM unsquished",0
zshell_txt:
.db "zSHELL",0
basic_txt:
.db "TI-Basic (?)",0