Author Topic: OFFSCRIPT  (Read 3366 times)

0 Members and 1 Guest are viewing this topic.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
OFFSCRIPT
« on: August 30, 2011, 05:48:25 pm »
What should the OFFSCRIPT variable look like (hex) if you want it to tell the calc to run a program named "OFFBY1" on startup? I have a reason for asking for the complete hex, a reason that is currently a surprise.

Will zStart interfere with this?

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: OFFSCRIPT
« Reply #1 on: August 30, 2011, 06:48:15 pm »
Well, OFFSCRPT is just assembly. So the assembly code would be:

Code: [Select]
.org $8001
bit 4, (iy + 8)
ret nz ;apd

ld hl, progName
rst 20h
bcall(_executePrgm)
ret
progName:
.db protProgObj, "OFFBY1", 0

And the hex would be:
Code: [Select]
FD CB 08 66 C0 21 0E 80 E7 EF 7C 4E C9 06 4F 46 46 42 59 31 00

zStart won't interfere unless you turn on the displaying of pictures or make a program so it runs on startups. DCS will interfere the very first time you run it regardless of settings though.


Edit:
    The normal rules of running TI-OS programs applies here. i.e. it can't be archived, and you can't be out of memory
« Last Edit: August 30, 2011, 06:49:14 pm by thepenguin77 »
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: OFFSCRIPT
« Reply #2 on: August 30, 2011, 07:12:45 pm »
Thanks thepenguin. Could I do a quick _ChkFindSym to see if it exists? And perhaps unarchive, then rearchive to solve the archive problem?

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: OFFSCRIPT
« Reply #3 on: August 30, 2011, 07:57:52 pm »
Go for it.

Another thing though, you need to be sure that OFFBY1 doesn't mess with $8000. If it does, it's going to overwrite your code and crash when it returns. This leaves you with a few options:
  • BJUMP to _ExecuteProgram, though you won't be able to rearchive it this way since it completely skips your code when it returns.
  • Copy a return code somewhere else, push its address, and BJUMP to _ExecuteProgram
  • Or just make sure it's not going to mess with $8000, (that's the easy way)

zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: OFFSCRIPT
« Reply #4 on: August 31, 2011, 03:48:02 pm »
Ok, so here's what I have:

Code: [Select]
.nolist
#include "ti83plus.inc"
#include "dcs7.inc"
.list
_ExecutePrgm .equ 4E7Ch
.org progstart
ld hl, AppVar
rst 20h
bcall(_ChkFindSym)
jr nc, notOK
ld hl, AppVar
rst 20h
ld hl,AppVar-AppVarCode
bcall(_CreateAppVar)
jr c, notOK
ld hl, AppVarCode
ld bc,AppVar-AppVarCode
ldir
set 1,(iy+33h)
ret
notOK:
ld hl, 0
ld (CurCol),hl
ld hl, TextError
bcall(_PutS)
ret

AppVarCode:
.relocate $8001
bit 4, (iy + 8)
ret nz ;apd

ld hl, progName
rst 20h
bcall(_ChkFindSym)
ld a,b
or a
call nz, UnArchive
bcall(_ExecutePrgm)
call UnArchive
ret
UnArchive:
ld hl, progName
rst 20h
bcall(_Arc_Unarc)
ld hl, progName
rst 20h
ret

progName:
.db protProgObj, "OFFBY1", 0
AppVar:
.db AppVarObj,"OFFSCRPT"
TextError:
.db "Error!",0

.end
END

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: OFFSCRIPT
« Reply #5 on: September 01, 2011, 03:07:52 pm »
I had to fix a few little things, but now it should work exactly like you want it to.

Code: [Select]
.nolist
#include "ti83plus.inc"
#include "dcs7.inc"
.list
_ExecutePrgm .equ 4E7Ch ;feel free to add this to ti83plus.inc
.org progstart ;  doing this everytime will eventually
ld hl, AppVar ;  be a pain when you have a lot
rst 20h
bcall(_ChkFindSym) ;this leaves OP1 intact
jr c, appvarDoesntExist
bcall(_delVarArc)

; jr nc, notOK ;see below VV

ld hl, AppVar
rst 20h
appVarDoesntExist:

ld hl,AppVar-AppVarCode
bcall(_CreateAppVar)
; jr c, notOK ;this throws Err:Memory, not C
inc de ;|
inc de ;|these two are because DE is originally
ld hl, AppVarCode ;  pointing to the size bytes
ld bc,AppVar-AppVarCode
ldir
set 1,(iy+33h)
ret
;notOK:
; ld hl, 0 ;          ^^
; ld (CurCol),hl ;this is a matter of style, but you probably
; ld hl, TextError ; just want to overwrite OFFSCRPT. the reason
; bcall(_PutS) ; for this is in case you run your program twice
; ret ; or there's an OFFSCRPT present you didn't make

AppVarCode:
.relocate $8001
bit 4, (iy + 8)
ret nz ;apd

ld hl, progName
rst 20h
bcall(_ChkFindSym)
ret c ;you probably just forgot this
ld a,b
or a
call nz, UnArchive
bcall(_ExecutePrgm)
call UnArchive
ret
UnArchive:
ld hl, progName
rst 20h
bcall(_Arc_Unarc)
ld hl, progName
rst 20h
ret

progName:
.db protProgObj, "OFFBY1", 0
AppVar:
.db AppVarObj,"OFFSCRPT"

;TextError:
;.db "Error!",0 ;not needed now

.end
END

Every change I made includes a comment.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: OFFSCRIPT
« Reply #6 on: September 01, 2011, 05:31:40 pm »
And make sure it's OFFSCRPT, not OFFSCRIPT (like in the topic title).
« Last Edit: September 01, 2011, 05:31:49 pm by Deep Thought »