Author Topic: Routines  (Read 317669 times)

0 Members and 1 Guest are viewing this topic.

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Routines
« Reply #555 on: June 13, 2011, 04:35:48 pm »
It's not that much shorter if you add in an OS version check. I doubt the getHardwareVersion call exists on pre-1.13.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Routines
« Reply #556 on: June 13, 2011, 06:54:51 pm »
It's a B_CALL to the boot code, so it should exist on every OS with boot code. In other words, every OS. ;)
« Last Edit: June 13, 2011, 06:56:40 pm by Runer112 »

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Routines
« Reply #557 on: June 15, 2011, 09:54:02 am »
Request: OS version check (Would be cool for my very old fake RAM clear program xD)
EDIT: Was this program, sucks abit:
Also the text is indeed a bit off. O.o (
Quote from: DJ long time ago
Nice, although I think the text is a bit off, though, and there are two black squares at the end of the screenshot. It might be nice if it could be implemented as fake reset in a game :P
)
« Last Edit: June 15, 2011, 09:59:36 am by aeTIos »
I'm not a nerd but I pretend:

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Routines
« Reply #558 on: June 16, 2011, 03:44:40 am »
OS version check? Really? Molest me not with this pocket calculator---er . . . well anyway, EF6F4C6768 will return the major version number in the high byte and the minor version number in the low byte. So divide by 256 to get the high byte and do "and 255" to get the low byte. In theory, "or 0" should also work, assuming that doing an 8-bit logical operation implicitly strips the high octet.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Routines
« Reply #559 on: June 16, 2011, 03:50:17 am »
erm, cant you just do (ASM code)->A then do A->{L1}r ?
I'm not a nerd but I pretend:

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Routines
« Reply #560 on: June 16, 2011, 03:51:42 am »
Sure. You could then read the major version in {L1+1} and the minor version number in {L1}. In fact, Asm(EF6F4C6768)->{L1}r will work.
« Last Edit: June 16, 2011, 03:52:07 am by DrDnar »
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Routines
« Reply #561 on: June 16, 2011, 03:52:06 am »
Aha. Thats way easier xD
I'm not a nerd but I pretend:

Offline Fast Crash

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 192
  • Rating: +45/-7
  • Virus of tomorrow
    • View Profile
Re: Routines
« Reply #562 on: June 18, 2011, 07:38:50 am »
He is a routine that Mighty Moose and me made, it allows you to copy data from flash to ram (it uses flashtoram):

Code: [Select]
Getcalc(<your var in flash>,Yx)
{°Yx}r->H
{°Yx+2}->A
<Number of bytes to copy>->B
<Your pointer in RAM>->D
Asm(2AC489ED5BBC893AB689ED4BB889EF1750)

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Routines
« Reply #563 on: June 18, 2011, 07:44:18 am »
He is a routine that Mighty Moose and me made, it allows you to copy data from flash to ram (it uses flashtoram):

Code: [Select]
Getcalc(<your var in flash>,Yx)
{°Yx}r->H
{°Yx+2}->A
<Number of bytes to copy>->B
<Your pointer in RAM>->D
Asm(2AC489ED5BBC893AB689ED4BB889EF1750)

Nice, I don't really understand how it works, but nice :D

Ashbad

  • Guest
Re: Routines
« Reply #564 on: June 18, 2011, 07:51:58 am »
Well, iirc, you can just do this, since it is valid to use Page-pointer varsity in a Copy instruction:

Code: [Select]
Getcalc(YourVar,Yx)
Copy(Yx,RAMptr,amount)

I thnk I used that for TaNF, it's very useful if you want to keep tons of data in Archive but be able to access little parts quickly when needed.

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: Routines
« Reply #565 on: June 19, 2011, 12:39:15 pm »
Well, iirc, you can just do this, since it is valid to use Page-pointer varsity in a Copy instruction:

Code: [Select]
Getcalc(YourVar,Yx)
Copy(Yx,RAMptr,amount)

I thnk I used that for TaNF, it's very useful if you want to keep tons of data in Archive but be able to access little parts quickly when needed.

Does it work when there's a page break?




Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Routines
« Reply #566 on: June 19, 2011, 12:45:20 pm »
Well, iirc, you can just do this, since it is valid to use Page-pointer varsity in a Copy instruction:

Code: [Select]
Getcalc(YourVar,Yx)
Copy(Yx,RAMptr,amount)

I thnk I used that for TaNF, it's very useful if you want to keep tons of data in Archive but be able to access little parts quickly when needed.

Does it work when there's a page break?

I don't really understand this, but does Frash/Mighty's work when there's a page break? I really don't understand these routines :P

Offline Runer112

  • Project Author
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2289
  • Rating: +639/-31
    • View Profile
Re: Routines
« Reply #567 on: June 19, 2011, 01:52:20 pm »
For copying data from archive to RAM, you want to use Axe's built-in Copy() command. It's smaller, easier to use, and handles page boundaries better. They both handle boundary crossing during copying correctly, but only Axe's built-in command handles boundary crossing before copying correctly. Like:

Copy(Y₁+16384,L₁,256)
« Last Edit: June 19, 2011, 01:55:05 pm by Runer112 »

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Routines
« Reply #568 on: June 20, 2011, 09:48:03 pm »
Here's a routine I made to clear a 6*6 square on both buffers.  I believe it's fairly optimized and much more elegant than the equivalent Pt-On(r1,r2,[FCFCFCFCFCFC0000]) / Pt-Change(r1,r2,[FCFCFCFCFCFC0000]).  With slight modification this could even be used for other sprite sizes like 5*5 and 12*12.

Here it is:
Code: [Select]
:Lbl CLR
:.Clear a 6*6 spot on both buffers
:.r1 is the X coordinate and r2 is the Y coordinate
:r1^8
:Asm(450421FF07B7CB1CCB1D10FA)→r3
:...
:  ld b, l
:  ld hl, 0000011111111111b
:  or a
:loop:
:  rr h
:  rr l
:  djnz loop
:...
:r1/8+(r2*12)→r5
:For(r4,0,5)
:{r4*12+r5→r6+L6}rr∙r3→{r6+L6}rr
:{r6+L3}rr∙r3→{r6+L3}rr
:End
:Return

What not to do with my routine:
It doesn't clip, so don't pass it any arguments that will make it go off the bottom of the screen.  This includes even the very bottom corner, as it'll still overwrite one byte. :-\  However, it's quicker not to clip so that's why I wrote it this way.

Enjoy! ;D

P.S.  Thanks to Eeems and Runer for helping with small clarifications throughout my coding. :)
« Last Edit: June 20, 2011, 09:48:38 pm by ztrumpet »

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Routines
« Reply #569 on: June 20, 2011, 10:03:30 pm »
You can always use a single Pt-Mask() to write a white square to both buffers.  Not sure if yours is faster than that or not, but its possible due to the lack of clipping and argument checking.
___Axe_Parser___
Today the calculator, tomorrow the world!