Author Topic: Font Hook Hacking  (Read 7913 times)

0 Members and 1 Guest are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Font Hook Hacking
« on: April 06, 2012, 05:21:49 pm »
When using the Font Hook, you cannot do special things on your own. For example, you cannot use your own drawing routines to speed things up. About a year and a half ago, I introduced an 8x8 font hook in BatLib and this is something I had never seen elsewhere. I had to do some semi-hacky things to display fonts in a custom way as opposed to just changing the data displayed and I figured this might be useful for others to use. Pretty much, if you want to use your own routine to display the font when the OS wants to draw a char, try adding this to the end of your hook:
Code: [Select]
   ld hl,18
    add hl,sp
    ld sp,hl
    pop hl
    ld a,l
    out (6),a
    pop hl
    pop ix
    pop hl
    pop de
    pop bc
    pop af
    ret
I am not sure if that works across all OSes, but I don't have access to them all :/ The main scary part that could cause a crash is the fact that this readjusts the stack. If other OSes makes other calls or pushes/pops, this will likely cause a crash.

I used that to let me draw the fonts directly to the LCD and make sure the OS didn't try to mess that up. Plus, it skips over tons of OS code XD You will need to handle inverted text on your own, though, too. I just check the flag and use CPL on the data if it is supposed to be inverted.
Screenie:

As you can see, my actual hook needs help, too, because menus don't work, but the main part is that 8x8 fonts can work XD
EDIT: I have tested some OSes:
1.03 fail
1.10 fail
1.12 fail
1.13 good
1.14 good
1.15 good
1.17 good
1.18 good
1.19 good
2.30 good
2.40 good
2.41 good
2.43 good
2.53 works except in MathPrint, but doesn't crash
2.55 works except in MathPrint, but doesn't crash

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Font Hook Hacking
« Reply #1 on: April 06, 2012, 06:56:20 pm »
That's pretty cool, nice handwriting font, but the problem is that you can't see the last 4 columns. You can't wrap around?

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Font Hook Hacking
« Reply #2 on: April 06, 2012, 07:06:59 pm »
I played with it for a bit before releasing that version, and one version did wrap text. The issue was that certain menus got really buggy.

Offline AzNg0d1030

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 522
  • Rating: +45/-4
  • Hardcore anime watcher.
    • View Profile
Re: Font Hook Hacking
« Reply #3 on: April 06, 2012, 07:35:03 pm »
Do you need to go through the process of selecting the font every time you turn off and turn on the calc?  Or does the calc remember it?
You just lost the game.



Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Font Hook Hacking
« Reply #4 on: April 06, 2012, 08:13:21 pm »
When you set a font hook, it remains until you run a program that replaces it, disables it, or your RAM gets cleared :)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Font Hook Hacking
« Reply #5 on: April 06, 2012, 08:49:28 pm »
Nice stuff. I wonder if this works with archived fonts?

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Font Hook Hacking
« Reply #6 on: April 06, 2012, 08:50:40 pm »
Well, if your font hook does, then yes (the example does use an archived font). The code is just a way to bypass a bunch of the OS stuff when it is returning from the hook :)

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Font Hook Hacking
« Reply #7 on: April 06, 2012, 08:52:56 pm »
You say that it may crash in other Oses, so my question is which OS is it tested to work properly in? I remember seeing this when you added it into batlib. I thought it was cool then, and I still think it's really cool now. =)

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Font Hook Hacking
« Reply #8 on: April 06, 2012, 09:05:57 pm »
Well, I got an early birthday present from thepenguin77 so I have just now managed to confirm that it wil crash on OS1.03 and I still have to test others. It does work on 2.43 for sure since that is what i tested on before. I am right now working on a good fix, but to be universal will add a bunch of code XD

EDIT:(though that could be related to Bcalls)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Font Hook Hacking
« Reply #9 on: April 06, 2012, 09:07:03 pm »
Well, if your font hook does, then yes (the example does use an archived font). The code is just a way to bypass a bunch of the OS stuff when it is returning from the hook :)
Oh I thought the code itself wasa font hook ???. I'm confused now lol. I guess it doesn't help that I know nothing about ASM...

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Font Hook Hacking
« Reply #10 on: April 06, 2012, 09:14:58 pm »
Os 1.03? Do you mean bootcode 1.03? Someone should also test on the MP OSes, and whatever the current OS for the old TI-83+s is. (1.16?)

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Font Hook Hacking
« Reply #11 on: April 06, 2012, 09:15:35 pm »
I am going to test those once I fix my broken Wabbit XD

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Font Hook Hacking
« Reply #12 on: April 06, 2012, 09:20:00 pm »
I don't think OS 1.03 matters much, considering it cannot run apps, apparently, or can barely run any. As long as it works on OS 1.19, 2.43, 2.53 and 2.55MP I guess it's fine.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Font Hook Hacking
« Reply #13 on: April 06, 2012, 09:22:02 pm »
Yea if you actually meant OS 1.03 that would be like... super old. O_o

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Font Hook Hacking
« Reply #14 on: April 06, 2012, 09:23:09 pm »
I think it only came on very few calcs too. Most calcs in the early 83+ days had OS 1.12 I think.