I have a couple of asm related questions about Ti 83/84 plus calcs. First, what are and how to flash applications work? Are they just special asm programs? If so, how do you make one from an assembly program? (I'm actually coding assembly with mimas, so would that change the process?) Also, about hooks: Can you use/install hooks in a regular asm program, and does anyone know of a tutorial for using hooks, because I can't find anything about that on the internet.
Flash applications are mostly just assembly programs in a particular format that are run directly from Flash. However, they also need to be cryptographically signed and because they live in Flash you can't generally install them programattically on the calculator.
So it's not hard to build a Flash app, but you can't do so with Mimas.
Hooks, then: the OS has a few points where it supports them- when it executes some code that supports a hook, it checks whether one is installed and if one is then it calls the specified code with inputs and outputs that vary depending on which hook it is.
Hooks are installed by writing the address (and Flash page) of some code to a particular address in RAM, which the OS them reads and jumps to. As verification that a hook is actually installed, the first instruction in the hook's code must be ld a,e (the byte 0x83)- this isn't executed, it's just a marker that the given address is actually supposed to be a hook. There's documentation on each individual hook on WikiTI.
It is possible to include a hook in a RAM-based assembly program, but this is generally discouraged because it requires you to find a block of RAM in which to stash the hook's code (basically a form of TSR). If that gets overwritten by something you're likely to see unexpected behavior (crashes..).
There's general documentation on hooks that's somewhat more detailed than my comments here, also on WikiTI: http://wikiti.brandonw.net/index.php?title=83Plus:OS:Hooks
So it's not hard to build a Flash app, but you can't do so with Mimas.
Hooks, then: the OS has a few points where it supports them- when it executes some code that supports a hook, it checks whether one is installed and if one is then it calls the specified code with inputs and outputs that vary depending on which hook it is.
Hooks are installed by writing the address (and Flash page) of some code to a particular address in RAM, which the OS them reads and jumps to. As verification that a hook is actually installed, the first instruction in the hook's code must be ld a,e (the byte 0x83)- this isn't executed, it's just a marker that the given address is actually supposed to be a hook. There's documentation on each individual hook on WikiTI.
It is possible to include a hook in a RAM-based assembly program, but this is generally discouraged because it requires you to find a block of RAM in which to stash the hook's code (basically a form of TSR). If that gets overwritten by something you're likely to see unexpected behavior (crashes..).
There's general documentation on hooks that's somewhat more detailed than my comments here, also on WikiTI: http://wikiti.brandonw.net/index.php?title=83Plus:OS:Hooks
Okay, thanks for the help. I think I understand this for the most part, but I'm still a little unclear on how exactly I install the hook. Are there any tutorials that give a walkthrough on how to install them? (Preferably in a program, but I'm not sure how different it would be in an application) Also, if I do install them in ram, what would be a good place to do so?
*necropost* If you still have this topic watched, CamelCode, do you still have these questions? Were you able to build what you wanted?
- jef
- Newbie (Posts: 11)
- 20 Jul 2020 04:26:19 am
- Last edited by jef on 20 Jul 2020 06:51:21 am; edited 1 time in total
KermMartian wrote:
*necropost* If you still have this topic watched, CamelCode, do you still have these questions? Were you able to build what you wanted?
I'm not CamelCode, but I do have the same questions. I'm trying to build a flash app for the ti-84-plus (no CE!) but I can't find a template, and a toolchain to compile and sign the app. A small tutorial to build a flash-app should be fine.
Please note that I programmed in asm on the ti-85, ti-86 and HP48G, and I'm now converting to the ti-84-plus because the kids have these at high school and I'm teaching them asm. Building ordinary asm-programs on the ti-84-plus is no problem, but a flash-app is more difficult to find information about.
Thanks for your reply, KermMartian, and your code/work for the community is humbling to me. Congratulations...
An app is not very special, it just has an app header and gets built into an 8xk rather than 8xp. Spasm has built-in support for generating an 8xk and signing them, so it's pretty easy to do.
Here's a minimal app that does nothing (adapted slightly from WikiTI):
Code:
You can then build it trivially:
Code:
Here's a minimal app that does nothing (adapted slightly from WikiTI):
Code:
#include "ti83plus.inc"
; Master Field
.db 80h, 0Fh, 0, 0, 0, 0
; Name. While this is a variable-length field (0x40 | length for the second byte),
; spasm requires that names always be 8 characters. See
; https://github.com/alberthdev/spasm-ng/issues/53
.db 80h, 48h, "nop "
; Disable TI splash screen.
.db 80h, 90h
; Pages
.db 80h, 81h, 1
; Signing Key ID
.db 80h, 12h, 1, 4 ; or 15 for the TI-84+CSE
; Date stamp. Apparently, the calculator doesn't mind if you put
; nothing in this.
.db 03h, 22h, 09h, 00h
; Date stamp signature. Since nothing ever checks this, there's no
; reason ever to update it. Or even have data in it.
.db 02h, 00
; Final field
.db 80h, 70h
; No need for padding here. The OS will just start execution here.
bcall(_JForceCmdNoChar)
You can then build it trivially:
Code:
$ spasm app.asm app.8xk
I'm not a TI-Z80 developer, so I couldn't tell you where you might find the best FlashApp template, but I can at least try to point you towards good tools to build and sign a 83+/84+ FlashApp:
* spasm-ng, which also supports the eZ80, has good functionality, and it works on modern computers running multiple OS;
* RabbitSign is what I used to re-sign OS and FlashApps on the TI-68k series, it works just as well with TI-Z80 files if you feed it the right keys (04 for 83+ OS, 0104 for 83+ FlashApps).
* spasm-ng, which also supports the eZ80, has good functionality, and it works on modern computers running multiple OS;
* RabbitSign is what I used to re-sign OS and FlashApps on the TI-68k series, it works just as well with TI-Z80 files if you feed it the right keys (04 for 83+ OS, 0104 for 83+ FlashApps).
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TIEmu and TILP.
Co-admin of TI-Planet.
Co-maintainer of GCC4TI (GCC4TI online documentation), TIEmu and TILP.
Co-admin of TI-Planet.
Thanks for the template and the pointers to the necessary software!
Immediately trying this out... But I got stuck.
After building the 8xk with spasm-ng and sending it to the calculator with tilp2, I received the message:
Msg: FLASH application rejected (signature does not match).
So apparently I did something wrong
This is my configuration:
-linux ubuntu 18.04
-alberthdev/spasm-ng.git cloned and built
-tilp v1.17
-ti-84-plus 2.55MP
Any ideas what I'm doing wrong? Thanks in advance for you answers!
(I did change the bcall to b_call, because it won't compile otherwise.)
Immediately trying this out... But I got stuck.
After building the 8xk with spasm-ng and sending it to the calculator with tilp2, I received the message:
Msg: FLASH application rejected (signature does not match).
So apparently I did something wrong
This is my configuration:
-linux ubuntu 18.04
-alberthdev/spasm-ng.git cloned and built
-tilp v1.17
-ti-84-plus 2.55MP
Any ideas what I'm doing wrong? Thanks in advance for you answers!
(I did change the bcall to b_call, because it won't compile otherwise.)
You can try to re-sign the FlashApp using RabbitSign. That will give some information about what's going on: RabbitSign may complain or refuse to do it if it doesn't understand the format, it may or may not change the file's contents.
TILP II 1.17 is outdated, but that's almost certainly not your problem here
TILP II 1.17 is outdated, but that's almost certainly not your problem here
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TIEmu and TILP.
Co-admin of TI-Planet.
Co-maintainer of GCC4TI (GCC4TI online documentation), TIEmu and TILP.
Co-admin of TI-Planet.
Lionel Debroux wrote:
You can try to re-sign the FlashApp using RabbitSign. That will give some information about what's going on: RabbitSign may complain or refuse to do it if it doesn't understand the format, it may or may not change the file's contents.
Thanks for your patience. I was exactly trying that on the moment your message arrived.
-I took the code from above and compiled it to template.8xk with spasm-ng
-I installed rabbitsign 2.1 (comes with linux ubuntu bionic)
-I took the 0104.key file from brandonw
-I did rabbitsign -k 0104.key -g -r -t 8xk template.8xk
(-g to make a 8xk, -r to resign and -t to have an 8xk as input)
The result is template-signed.8xk which is refused by my calculator with the same error. Emulator tilem2 also refuses the result.
After inspection (cmp template8xk template-signed.8xk) rabbitsign actually changed something, and using the verbose option of rabbitsign I see everything looks fine to me:
0104.key: Loaded Rabin/RSA private key:
0104.key: n = ...
0104.key: p = ...
0104.key: q = ...
Signing TI-83/84 Plus application template.8xk...
template.8xk: hash = 7C666F6D2CAE8CEE7939FF5B1176F87B
template.8xk: sig = 793254F1136D35E37B5EE975FDE951F88FB6AC865F2AA2A401FE2EE6AE715CA3EF29F1BD246AAB668F57F9C2E4379DE21944DC84AFC6ECBE3ABC4D9F804D9C2D
template.8xk: f = 3
Still no solution, though...
On the TI-68k series, I'd clearly expect 80 7E 00 00 or 80 7F 00 00 00 00 fields instead of 80 70 at the end of the header... but maybe the TI-Z80 series is different, or spasm's FlashApp support fixes it
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TIEmu and TILP.
Co-admin of TI-Planet.
Co-maintainer of GCC4TI (GCC4TI online documentation), TIEmu and TILP.
Co-admin of TI-Planet.
In the mean time I tried still other things:
-looking at other flash games and trying to recompile / sign them
-looking at headers from other flash games or tutorials and building upon those
-looking at other posts about this, e.g. https://www.cemetech.net/forum/viewtopic.php?p=221502
-looking at other toolchains and trying them out
-...
Finally I found something that works, but it's definitely not the way to do things in the year 2020: I found Dwedit-Appdev-kit-v2.0 from 2004! With this + rabbitsign I managed to recompile and sign an example app that was included in the kit, and subsequently was able to run it on both tilem2 and my ti84plus-hardware. As said, I know this is probably not the best toolchain. So I'm still open for suggestions.
In particular I still have no flash-app template.asm that works with "spasm template.asm template.8xk".
-looking at other flash games and trying to recompile / sign them
-looking at headers from other flash games or tutorials and building upon those
-looking at other posts about this, e.g. https://www.cemetech.net/forum/viewtopic.php?p=221502
-looking at other toolchains and trying them out
-...
Finally I found something that works, but it's definitely not the way to do things in the year 2020: I found Dwedit-Appdev-kit-v2.0 from 2004! With this + rabbitsign I managed to recompile and sign an example app that was included in the kit, and subsequently was able to run it on both tilem2 and my ti84plus-hardware. As said, I know this is probably not the best toolchain. So I'm still open for suggestions.
In particular I still have no flash-app template.asm that works with "spasm template.asm template.8xk".
It's entirely possible that spasm doesn't correctly sign apps with "weird" headers like this one. As WikiTI notes, historically app headers were treated like fixed-size blocks but they're actually a series of variable-length fields and spasm may have some baked-in assumptions around that.
So you might try using the old header template you found and see if the output from spasm works.
So you might try using the old header template you found and see if the output from spasm works.
This is an old thread, but I too recently spent a long time searching the internet to figure out how to create flash apps, so I think I can provide some info that may help others in the future.
Spasm-ng is able to create and sign flash apps directly. The critical bit of information was located in "Appendix A: Creating Flash Applications with SPASM" in the book called "Hot Dog's TI-83 z80 ASM For The Absolute Beginner". (I can't seem to add hyperlinked text here, so you'll have to google for these.)
(The following was verified on Ubuntu 22.04 and the latest spasm-ng (v0.5-beta.3) at https://github.com/alberthdev/spasm-ng/).
The spasm-ng assembler provides an additional include file
Code:
and 2 macros, one going at near the beginning of the source code:
Code:
and one which goes at the very end of the source code:
Code:
Here is the complete hello.asm program:
Code:
Then type the spasm command to generate the hello.8xk file:
Code:
Spasm-ng is able to create and sign flash apps directly. The critical bit of information was located in "Appendix A: Creating Flash Applications with SPASM" in the book called "Hot Dog's TI-83 z80 ASM For The Absolute Beginner". (I can't seem to add hyperlinked text here, so you'll have to google for these.)
(The following was verified on Ubuntu 22.04 and the latest spasm-ng (v0.5-beta.3) at https://github.com/alberthdev/spasm-ng/).
The spasm-ng assembler provides an additional include file
Code:
#include "app.inc"
and 2 macros, one going at near the beginning of the source code:
Code:
defpage(0, "<name of app>")
and one which goes at the very end of the source code:
Code:
validate()
Here is the complete hello.asm program:
Code:
.nolist
#include "ti83plus.inc"
#include "app.inc"
.list
defpage(0, "hello")
main:
ld hl,0
ld (curRow),hl
ld hl,txtHello
call myPutS
bcall(_GetKey)
bjump(_JForceCmdNoChar)
myPutS:
ld a,(hl)
or a
ret z
bcall(_PutC)
inc hl
jr myPutS
txtHello:
.db "Hello world!",0
validate()
Then type the spasm command to generate the hello.8xk file:
Code:
$ spasm -I <inc-directory> hello.asm hello.8xk
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
» Go to Registration page
» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Advertisement