Author Topic: Jade  (Read 20916 times)

0 Members and 2 Guests 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
Re: Jade
« Reply #45 on: March 17, 2013, 11:27:38 am »
I like option 2 the best, because that seems more automated and the user still gets to see that it is in fact asmdream doing the work.


Also, Update: I removed the keyMask port. Really, it isn't needed since it was actually faster to just scan all of the keys without checking if it needed to be read. In fact, I optimised the key scanning routine to be even faster and smaller than what I originally thought it could be:
Code: [Select]
     ld bc,0701h
     ld a,$FE      ;test the keys
     ld hl,saveSScreen+key0
KeyUpdateLoop:
     out (1),a
     rlca
     nop
     ini
     jr nz,KeyUpdateLoop
I replaced the byte with something else, explained later. For now, the next update is indirection:
I added in the ind1() and ind2() instructions. They have more complicate abilities, but the easiest way to use them is something like:
Code: [Select]
     ind2()
     lda(addr1,indirect)
ind2() says that the second argument passed to the processor will be read as indirection. How that may get complicated is with something like this:
Code: [Select]
     ind2()
     inc(addr1)
     inc(indirect)
The first increment works as normal, but the second one has indirection. Internally, ind() instructions rotate a bit into an indirection counter (up to 8 bits). I did this on purpose, instead of simply setting bit 0 or bit 1 accordingly. It is just as easy to rotate the bits in, so why give the extreme coder the ability to use all 8 bits? With this in mind, you can make both arguments in an instruction read as indirection:
Code: [Select]
     ind1()
     ind1()
     lda(indirect,indirect)
The way that works, is first a bit is rotated in, then another bit is rotated in, leaving the lower 2 bits of the indirection byte set, so the next two addresses will be computed as indirection. Even better is that the indirection byte is what has replaced keyMask, so you can control indirection a little more and save bytes in some cases.

The attached file has an updated Jade.inc with all of the supported instructions, as well as some documentation, a 'readme' an example, and the associated asmdream macros and equates that have been updated. No new screenies yet, sorry :/

Offline the_mad_joob

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 346
  • Rating: +47/-0
    • View Profile
Re: Jade
« Reply #46 on: March 17, 2013, 11:33:13 am »
Ok buddy, i'll check which data you need to pass and tell you that soon =]

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Jade
« Reply #47 on: March 18, 2013, 04:36:59 am »
What if you did ind2() \ ind1()? :P That's a cool idea, though, and definitely something that will make writing more complicated games easier :)

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: Jade
« Reply #48 on: March 18, 2013, 06:34:07 am »
Ok buddy, i'll check which data you need to pass and tell you that soon =]
Okay, thanks!

What if you did ind2() \ ind1()? :P That's a cool idea, though, and definitely something that will make writing more complicated games easier :)
Yes, that is valid, and it would cause the next argument to be indirection, then the one after that is normal, then the argument after that is indirection. The way this could be useful is when passing arguments to calls where you can force a call to use indirection. Though in that case, something like ind1() \ ind2() might be better.

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Jade
« Reply #49 on: March 18, 2013, 07:00:34 am »
Ah i misunderstood how it works, so the ind1/2 instructions don't update the indirection counter! That makes more sense. So ind1 is essentially:
ld hl,indCounter \ scf \ rr (hl)
...and ind2:
or a \ rr (hl) \ scf \ rr (hl)
...where you just rotate a byte in. You're not setting that specific bit but rather rotating it into that position.

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: Jade
« Reply #50 on: March 18, 2013, 07:05:04 am »
Yes, that is the trick :) Then, whenever an argument is read, it shifts the bits out to see if it should be read as indirection.

Offline the_mad_joob

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 346
  • Rating: +47/-0
    • View Profile
Re: Jade
« Reply #51 on: March 19, 2013, 09:35:25 am »
I'm preparing asmdream 1.00.
The 8xk will be ready in one or two days (other files later).
It'll include support for automatic assembling from external code (program or other app).
The hard part was to be able to actually tell asmdream that an automatic assembling was requested.
I finally found a way to pass that info using iy (the only register that is not overwritten by _executeapp bcall).
So it'll be quite easy for you xed =]

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: Jade
« Reply #52 on: March 19, 2013, 01:20:22 pm »
Thanks, that is awesome! Will it then check if IY is 89F0h and if it isn't, it sets it back to 89F0h and jumps to the automatic compiling routine?

Offline the_mad_joob

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 346
  • Rating: +47/-0
    • View Profile
Re: Jade
« Reply #53 on: March 19, 2013, 02:08:19 pm »
Yes, but iy must then point to a safe ram location because that routine actually writes there.
Asmdream will then restore iy to $89F0 and then alter the same flags the routine normally do.
The thing is, i don't know yet if _executeapp "reads" the flags but i'm pretty sure it doesn't.
Anyway, i think that's a nice trick to pass parameters to an app.
I also found a way for an app to know if it was executed from external code just by checking if sp is different than $FFE3.
« Last Edit: March 19, 2013, 02:13:54 pm by the_mad_joob »

Offline the_mad_joob

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 346
  • Rating: +47/-0
    • View Profile
Re: Jade
« Reply #54 on: March 21, 2013, 03:38:05 pm »
Re xed...

As far as what i've tested, running from external code works fine from a prgm (nostub only, don't try from shell prgms) or an application.
The important thing to mention is that it DOES NOT RETURN.

RULES

($8000>$BFFF) = ram page 1 (if not already the case)
($C000>$FFFF) = ram page 0 (if not already the case)
(progtoedit) = "asmdream"
($9AEF) = auto mode only : source prgm name , zero-terminated < bad stuff will probably happen if : 1) leading char is not ltheta 2) name exceeds 8 chars 3) you forget the terminating zero
iy = run mode = flags (standard) | appbackupscreen (auto)

Then you just have to bcall _executeapp, as simple as that.

Hope it will be useful to you dude =]
« Last Edit: March 23, 2013, 01:06:00 pm by the_mad_joob »

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: Jade
« Reply #55 on: March 21, 2013, 04:21:40 pm »
Thanks, I will see what I can do! I will also try to see if there is a way to make it return to an app, too. If it doesn't return because of bcall(_JForceCmdNoChar), then that would be an issue for programs because it would eat a little RAM. For an app, I can just temporarily create a GetKey hook to automatically re-enter the app.

EDIT: One solution might be to make it so that your app starts with:
Code: [Select]
     jp Start     ;go to the normal start of the app
     jp Compile    ;jump to the compiling code
If your compiling code is a subroutine that ends with an RET, then people can simply use 'call 4083h' to compile a program.

Offline the_mad_joob

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 346
  • Rating: +47/-0
    • View Profile
Re: Jade
« Reply #56 on: March 21, 2013, 05:10:57 pm »
Well, there is probably a way to return, in the case the user doesn't use the goto feature, which automatically gives control back to the os (That's the drawback.).
Instead of a getkey hook, maybe there's a key corresponding to app execution that can be passed to _jforcecmd.
About your solution, that was the first method i tested.
It works, but i gave up that idea when i saw that off-page calls randomly fail (probably because the app was not initialized as it should have been).
The other main issue when returning is the potential data conflicts in safe ram locations between asmdream and the prgm/app that calls it.
Anyway, i'll have to take a closer look at that because the shell i want to make is supposed to be able to run anything, and return.
« Last Edit: March 21, 2013, 05:32:19 pm by the_mad_joob »

Offline the_mad_joob

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 346
  • Rating: +47/-0
    • View Profile
Re: Jade
« Reply #57 on: March 23, 2013, 01:09:50 pm »
Found a bug where a few stack entries were wasted when the goto feature is selected.
I totally recoded that feature (now using a temp hook).
There you go...

EDIT :
A few precisions if you intend to use some temp hooks for returning :
When asmdream exits normally (no goto), it is done with the regular _jforcecmdnochar.
When asmdream exits with goto, it is also done with _jforcecmdnochar, but before that, hook $9B88 is installed (which automatically opens up the prgm editor at the homescreen).
Note that the previous hook is automatically restored (if any).
That means you will probably need 1 hook for each case.
For the goto case, i thought maybe of a hook that checks for [2nd]+[quit], but there is still a very slim chance the user exits the prgm editor with [2nd]+[off]...
« Last Edit: March 26, 2013, 03:49:27 pm by the_mad_joob »

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: Jade
« Reply #58 on: March 23, 2013, 02:03:38 pm »
Hmm, thanks for the update. I am starting to get swamped with projects, homework and studying, so I don't know how soon it will be before I get something working with this.

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: Jade
« Reply #59 on: July 29, 2013, 11:08:21 am »
I haven't added in any of the shell parts that I wanted to add in, yet, but I did rewrite parts of the graphics code. I am emulating the screen with a different approach and that allowed me to make a slightly faster LCD update routine and a much faster clipped sprite routine. The end product is about a 23% speed boost in my pong example :)

Also, going through the code, I think I can try to give it much better organisation and possibly reduce the size and increase the speed. It is quite a mess at the moment.