Author Topic: Renaming a command in TIOS  (Read 1569 times)

0 Members and 1 Guest are viewing this topic.

Offline Okimoka

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 8
  • Rating: +0/-0
    • View Profile
Renaming a command in TIOS
« on: March 11, 2017, 07:48:16 pm »
I have a disassembled 2.43 OS which I'd like to modify.
Specifically, I want to rename a Command (QuadReg). The modification should not be affected by a reset.
For that reason I cannot use token hooks or the like, so I figured I'd have to write into flash.
I was able to unlock the flash (copying code from ptterase.z80), but I couldn't get writing bytes into it to work
(talking about this function http://wikiti.brandonw.net/index.php?title=83Plus:OS:Raw_Flash_Commands#Writing).
The String "QuadReg" is at $7D49 (page 1A) and $4D85 (page 1)
I tried "set" to modify the bits and ld to zero the bytes, but it didn't work.

I'm wondering if this is even possible (as wikiti states, the command name has to be in a sector?)
Or would it be a better approach to modify the disassembly, then reassemble to .8xu?

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7917
  • Rating: +373/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Renaming a command in TIOS
« Reply #1 on: March 12, 2017, 07:46:34 am »
If I wanted to do that I'd probably make it a token hook and have zstart run my token hook on ram clear so that it is still persistant ;)

As for writing flash, have you been able to verify that you actually unlocked flash?

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline E37

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 251
  • Rating: +17/-0
  • Trial and error is the best teacher
    • View Profile
Re: Renaming a command in TIOS
« Reply #2 on: March 12, 2017, 09:35:41 am »
I'd agree with Sorunome, but you might have to chain hooks. I would use a hook since it is more flexible and you don't run the risk of screwing up the os.
Either way, once you are finished post your code!
I'm still around... kind of.

Offline Okimoka

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 8
  • Rating: +0/-0
    • View Profile
Re: Renaming a command in TIOS
« Reply #3 on: March 12, 2017, 10:22:48 am »
Thanks for the tip, zStart is really useful. Unfortunately it seems to get deleted when doing an "All Memory" reset, however when adding it again, the "run on RAM Clear" option is still installed.
I checked Bit 2 of port 02h to confirm the flash is unlocked (http://wikiti.brandonw.net/index.php?title=83Plus:Ports:02)
I don't think I can avoid messing with the OS tough

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7917
  • Rating: +373/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Renaming a command in TIOS
« Reply #4 on: March 12, 2017, 11:56:35 am »
Thanks for the tip, zStart is really useful. Unfortunately it seems to get deleted when doing an "All Memory" reset, however when adding it again, the "run on RAM Clear" option is still installed.
[...]
Oh, yeah, that still happens, zstart is still removed.
The reason for "run on RAM Clear" still being set is that zstart actually modifies the OS :P

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Okimoka

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 8
  • Rating: +0/-0
    • View Profile
Re: Renaming a command in TIOS
« Reply #5 on: March 13, 2017, 09:17:43 am »
From what I've gathered from this thread https://www.omnimaga.org/asm-language/(z80)-writing-to-flash/ it is possible to write into flash by finding a free sector to erase (I assume this is what zStart does, as there seem to be no side effects to the modification), then use WriteFlashUnsafe to write. When editing the original OS tough, don't I have to erase a sector that contains OS information?
I've tried reassembling the 2.43 Disassembly into an 8xu, but without success. I tried concatenating all pages, then compiling (SPASM tells me there are several redefinitions of labels and gives me a small file which, compiled with packxxu, gives me an unusuable 8xu). Compiling page for page of course resulted in reference errors.
(How) can one reasseble a 2.43 disassembly correctly?

Offline Eeems

  • Mr. Dictator
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6158
  • Rating: +318/-36
  • C'est la vie
    • View Profile
    • Eeems
Re: Renaming a command in TIOS
« Reply #6 on: March 13, 2017, 12:07:21 pm »
I would recommend against disassembling TI-OS to make modifications and then attempting to reassemble it. As others have mentioned I would recommend writing hooks and making sure they stay around through RAM clears.
If you really want to go the OS modification route so as to not lose it on a full memory reset. I would then instead of trying to build an 8xu from a modified version of the disassembly, write a patching program that patches the OS on device. I know a number of members have written OS modifications before for various reasons (fixing bugs etc).
/e

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7917
  • Rating: +373/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Renaming a command in TIOS
« Reply #7 on: March 13, 2017, 02:55:15 pm »
From what I've gathered from this thread https://www.omnimaga.org/asm-language/(z80)-writing-to-flash/ it is possible to write into flash by finding a free sector to erase (I assume this is what zStart does, as there seem to be no side effects to the modification), then use WriteFlashUnsafe to write. [...]
Oh, right, the flash command won't accept any write comments unless you cleared hte page first.
So here's how to go ahead:
1. copy the page to ram
2. modify the copy in ram
3. erase the flash page
4. write from ram to flash

Be sure to test this in an emulator, you might break your calc hard-time otherwise

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Okimoka

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 8
  • Rating: +0/-0
    • View Profile
Re: Renaming a command in TIOS
« Reply #8 on: March 24, 2017, 08:32:12 am »
Could these bcalls be of use for this?
FlashToRAM (http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:5017)
EraseFlashPage (http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:8084)
I managed to write a patch which writes zeros into flash and rename QuadReg to Q┬ĚdReg, so modifying it in RAM should be doable.
Writing back into flash after erasing the sector is probably also a matter of looping+stack?

However, I can't even get FlashToRAM to work. Since I want to copy page 1, I assume the source address is 0 and number of bytes is $8000. But I don't know where in RAM I should put the copy. Especially because RAM can only hold ~24000 bytes (sector size ~32000); I guess I'll have to use the archive?

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7917
  • Rating: +373/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Renaming a command in TIOS
« Reply #9 on: March 24, 2017, 08:51:24 am »
Writing back into flash after erasing the sector is probably also a matter of looping+stack?
Yeah, that should be the write routine you copypasted up there somewhere
Quote
However, I can't even get FlashToRAM to work. Since I want to copy page 1, I assume the source address is 0 and number of bytes is $8000. But I don't know where in RAM I should put the copy. Especially because RAM can only hold ~24000 bytes (sector size ~32000); I guess I'll have to use the archive?
If page 1 is currently in MemA (you can read up on memory mapping here) then it's a simple matter of
Code: [Select]
ld hl,$4000
ld de,someRamArea
ld bc,$4000
ldir

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!