Author Topic: Routines  (Read 313184 times)

0 Members and 1 Guest are viewing this topic.

SirCmpwn

  • Guest
Re: Routines
« Reply #105 on: March 19, 2010, 02:15:27 pm »
Sure!  Here you go:
L1: Asm(21788411E389010900EDB0) \ Asm(21E389E7EFF1421A4F131A4713131321959D0B0BEDB0)
L2: Asm(21788411448D010900EDB0) \ Asm(21448DE7EFF1421A4F131A4713131321959D0B0BEDB0)
L3: Asm(21788411699B010900EDB0) \ Asm(21699BE7EFF1421A4F131A4713131321959D0B0BEDB0)
L5: Asm(217884117F85010900EDB0) \ Asm(217F85E7EFF1421A4F131A4713131321959D0B0BEDB0)
L6: Asm(217884113796010900EDB0) \ Asm(213796E7EFF1421A4F131A4713131321959D0B0BEDB0)
This is untested, I just changed some hex values.  It should work, though.

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: Routines
« Reply #106 on: March 19, 2010, 02:33:57 pm »
aaah ok, thanks. Personally I would rather use L1 and L2 if possible, for more safety reasons ^^

SirCmpwn

  • Guest
Re: Routines
« Reply #107 on: March 19, 2010, 03:12:08 pm »
Fair enough, but I'm using L1 and L2 for Half-Life and wanted an alternative.

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: Routines
« Reply #108 on: March 19, 2010, 03:17:41 pm »
Aaah ok ^^

But seriously, thanks a lot for posting that stuff. Just making it clear, though, if for example you got your ASM code followed with [00->GDB1, when you run your program, [00->GDB1 becomes the equivalent of [01->GDB1, [02, [03 and so on, right? Just making sure so I won't start using writeback for the wrong stuff x.x Also could you show an example where you modify multiple lists elements at once? I would really like to know how it is done and what are the results depending of what the rest of your code does
« Last Edit: March 19, 2010, 03:19:11 pm by DJ Omnimaga »

SirCmpwn

  • Guest
Re: Routines
« Reply #109 on: March 19, 2010, 04:14:49 pm »
This is how it works.  The first routine copies the name of the currently running program to the end of tempSwapArea (unless you specify somewhere else).  Thats all it does.
The second routine is where the magic happens.  It copies the name from tempSwapArea into OP1 and looks it up using ChkFindSym.  Then, it copies the length of the program into bc.  Then, it puts 9D95 (the location of the currently executing program) into hl.  Then, it places the location of the data according to the VAT into de.  Then, it ldirs everything from 9D95 into the saved program.
What this means is that because Axe copies everything from [] tags to the end of the program, if you modify it while running at 9D95, the last routine applies the changes to the saved program.
This works because TIOS doesn't run compiled Axe programs from their real location in memory.  It copies them to 9D95 first.  So to use these routines, here is an example:
Code: [Select]
Asm(...) (First routine)
[00->GDB1
{GDB1}+1->{GDB1}
Asm(...) (Second routine)
So the output from Axe looks like this, more or less:

1) First routine
2) {GDB1}+1->{GDB1
3) Second routine
4) ret      ;Leave the program
5) 00      ;GDB1 Points here

When you run the program, this is copied to 9D95 and executed.  When it hits line 2, the code at 9D95 changes to this:

1) First routine
2) {GDB1}+1->{GDB1
3) Second routine
4) ret      ;Leave the program
5) 01      ;GDB1 Points here

When it his line 3, the second routine copies lines 1 to 5 into the original location.  The saved program becomes:

1) First routine
2) {GDB1}+1->{GDB1
3) Second routine
4) ret      ;Leave the program
5) 01      ;GDB1 Points here

Without the second routine, line 5 would remain at 00.

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: Routines
« Reply #110 on: March 19, 2010, 04:33:51 pm »
aaaah ok. This is some confusing stuff to understand, but I think I get what it does now. So now could I do
Code: [Select]
Asm(...) (First routine)
[0001050309050807->GDB1
{GDB1}+1->{GDB1}
{GDB1+1}+1->{GDB1+1}
{GDB1+2}+1->{GDB1+2}
{GDB1+3}+1->{GDB1+3}
{GDB1+4}+1->{GDB1+4}
{GDB1+5}+1->{GDB1+5}
{GDB1+6}+1->{GDB1+6}
{GDB1+7}+1->{GDB1+7}
Asm(...) (Second routine)

Then the code would change from like

1) First routine
2) {GDB1}+1->{GDB1
3) Second routine
4) ret      ;Leave the program
5) 0001050309050807     ;GDB1 Points here

to

1) First routine
2) {GDB1}+1->{GDB1
3) Second routine
4) ret      ;Leave the program
5) 010206040A060908     ;GDB1 Points here

?

Or would I need to do some modifications?

SirCmpwn

  • Guest
Re: Routines
« Reply #111 on: March 19, 2010, 04:35:25 pm »
At first glance, that looks correct.  Program write-back and SMC is kind of hard to explain to a non-assembly programmer, you are getting along with that description quite well! ;D

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: Routines
« Reply #112 on: March 19, 2010, 04:51:48 pm »
yeah, I had an hard time understanding some Axe stuff due to that (like pointers). However, one awesome thing with axe is that it seems to act as some sort of bridge to learn some low level programming concepts easier, with a more familiar language.

SirCmpwn

  • Guest
Re: Routines
« Reply #113 on: March 19, 2010, 04:58:02 pm »
Yep!  And here is another routine for use in Axe that works quite well, and will work even better once getkey support for ON is added.
Toggle Screen On/Off
(Adapted from the WikiTI version)
Code: [Select]
Lbl TS
Asm(DB10CB6F20053E03D310B93E02D310)
Return
Note: This routine must be called as a subroutine, do not try to run it in-line if you don't want to exit your program prematruely and leave your user with a turned-off screen and no way to turn it on.
« Last Edit: March 19, 2010, 04:58:26 pm by SirCmpwn »

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: Routines
« Reply #114 on: March 19, 2010, 05:01:59 pm »
Does it acts like Auto Power Down?

SirCmpwn

  • Guest
Re: Routines
« Reply #115 on: March 19, 2010, 05:09:19 pm »
No, you call it, and if the screen is on, it turns it off.  If the screen is off, it turns it on.

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: Routines
« Reply #116 on: March 19, 2010, 05:10:45 pm »
aaah ok, I see.

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Routines
« Reply #117 on: March 19, 2010, 06:58:32 pm »
Yay writeback!  Now i can add highscores to anything i want! ^^

So corect me if I'm wrong but running the asm code makes *all* data writeback?

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: Routines
« Reply #118 on: March 19, 2010, 07:44:07 pm »
mhmm I hope not x.x, cuz what if I have like 200 sprites in my data?

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Routines
« Reply #119 on: March 19, 2010, 07:47:00 pm »
Yeah, but from what it looks like there is no point where the data to be kept in the program is specified, so it seems to keep *all* the data D:

Then again, if you have 200 sprites in your program to begin with, enabling writeback won't mess with them unless you mess with them yourself, and it won't add to the size since they are already in the program normally.