Omnimaga

Calculator Community => Major Community Projects => The Axe Parser Project => Topic started by: alberthrocks on April 04, 2011, 03:23:08 pm

Title: DCS Axiom development
Post by: alberthrocks on April 04, 2011, 03:23:08 pm
Sparking from this topic (http://ourl.ca/10077/193661;topicseen#new), I've decided to try and see if I can write a DCS axiom! :) However, my assembly is terrible, so I will need LOTS of help with it. From the messages in the thread, it seems that our assembly devs are puzzled at how to write an Axiom, but could easy make an ASM program. Hopefully, from this topic, a quick start/manual can be written on how to write Axioms. THEN our awesome assembly programmers' powers can be unleashed! ;)

OK, so let's get started! :D

First off, I'm basing my Axiom from the MemKit template. My assembler is SPASM (part of the WabbitStudio suite), OS Linux.
I also am using http://dcs.cemetech.net/index.php?title=GUI_API for reference on how to use the DCS' GUI libraries in assembly.
With that, I'm currently just trying to write example code for myself (and probably others).
I'm focusing on: http://dcs.cemetech.net/index.php?title=GUI_API#Adding_GUI_Elements

Here's a code snip from the API docs:
Code: [Select]
ld hl,SmWinData
ld de,SmWinDataEnd-SmWinData
ld a,GUIRSmallWin
call PushGUIStack
ld hl,winButtons
ld de,dat_end-winButtons
ld a,GUIRWinButtons
call pushGUIStack
ld hl,0
call GUIMouse
ret
SmWinData:
     .db 5,5     ;the x and y coordinates relative to the LCD of the top-left of the window
     .db $F8,$88,$88,$88,$F8   ;a square icon
     .db "My Window",0    ;the window title
SmWinDataEnd:
exitMyProg:
  call ResetAppPage
  ret
winButtons:
 .db 00100000b      ;only displaying a close button
 .dw 0              ;null pointer
 .dw 0              ;another null pointer
 .dw exitMyProg     ;we'll jump to exitMyProg when this button is clicked
dat_end:

Of course, we really don't want internal data, but the data for the arguments the user provides! :)

In the end, after a back and forth on IRC, I've gotten this code:
Code: [Select]
.nolist
#include "ti83plus.inc"
#include "Axe.inc"
#include "dcs7.inc"
.list

#define B_CALL(xxxx) rst 28h \ .dw xxxx

 .dw AXM_HEADER

 .dw Ax1_End
 .db AXM_ALL
 .dw tok_DrawL ;DlgBox()
 .db AXM_INLINE
 .db AXM_1ARG
 .org 0
 ; OLD CODE:
 ; call OpenGUIStack
 ; ld hl,SmWinData
 ; ld de,SmWinDataEnd-SmWinData
 ; ld a,GUIRSmallWin
 
 ; OK, so let's first get stuff ready! (Open the GUI stack!)
 call OpenGUIStack
 ; Text is stored in HL already, no need to move it around!
 ; Save hl!
 push hl
 ; Now find the length of the string arg!
 call sub_Length
 ; Copy it to the correct place...
 ex de,hl
 ; ...and bring back the string arg!
 pop hl
 ; Set window type!
 ld a,GUIRSmallWin
 
 ; Push the GUI!
 call PushGUIStack
 
 ; Now, add the close button to the window.
 ld hl,winButtons
 ld de,dat_end-winButtons
 ld a,GUIRWinButtons
 call pushGUIStack

 ; Now, render the GUI and give control (mouse) to DCS!
 ld hl,0
 call GUIMouse

 ret

exitMyProg:
  call ResetAppPage
  ret
winButtons:
 .db 00100000b      ;only displaying a close button
 .dw 0              ;null pointer
 .dw 0              ;another null pointer
 .dw exitMyProg     ;we'll jump to exitMyProg when this button is clicked
dat_end:
Ax1_End:

 .dw AXM_END

.end

Unfortunately, this crashes! :( Is there any errors that should be fixed?
Title: Re: DCS Axiom development
Post by: kindermoumoute on April 04, 2011, 03:50:46 pm
Thank to launch this project, I hope you will succeed !
Title: Re: DCS Axiom development
Post by: alberthrocks on April 04, 2011, 07:09:27 pm
Thank to launch this project, I hope you will succeed !
Thanks kindermoumoute! :) Don't expect it to be fast though - it's going to be a tough thing to make (at least for me).

So, does anyone has any ideas why this is failing?
Also, if you think you're faster at making this all work, the code is licensed under GPL v3, so feel free to take it and work on it! :)
Title: Re: DCS Axiom development
Post by: alberthrocks on April 08, 2011, 03:42:48 pm
Bumpity bumpity bump. Any fix for the crashing code above?

Also, this project is 100% open source (and free, obviously)! :) That means that this project is open for any collaboration, and I'd love to get some help for this Axiom. If you want to help out, hop right in! :D
Title: Re: DCS Axiom development
Post by: Munchor on April 08, 2011, 03:57:08 pm
Code: [Select]
call OpenGUIStack

 push hl

 call sub_Length

 ex de,hl

 pop hl

 ld a,GUIRSmallWin
 
 call PushGUIStack
 
 ld hl,winButtons
 ld de,dat_end-winButtons
 ld a,GUIRWinButtons
 call pushGUIStack

 ld hl,0
 call GUIMouse

 ret

This seems like fully working to me. So, I have no idea of what the problem might me. Maybe ask for help at Cemetech too, they have some Assembly experts over there :D
Title: Re: DCS Axiom development
Post by: Munchor on April 12, 2011, 11:28:02 am
I may have an idea (Kerm Martian's actually).

Code: [Select]
; OK, so let's first get stuff ready! (Open the GUI stack!)
 call OpenGUIStack
 ; Text is stored in HL already, no need to move it around!
 ; Save hl!
 push hl
 ; Now find the length of the string arg!
 call sub_Length
 ; Copy it to the correct place...
 ex de,hl
 ; ...and bring back the string arg!
 pop hl
 ; Set window type!
 ld a,GUIRSmallWin
 
 ; Push the GUI!

When you call OpenGUIStack, it probably deletes what's in hl, so then you can't really push it.
Title: Re: DCS Axiom development
Post by: alberthrocks on April 13, 2011, 08:57:19 pm
OK, I've (hopefully) fixed it! :) Unfortunately, I'm *really* busy atm, so I didn't have time to test.
From what you've said above, I've followed this logic:
Code: [Select]
; Save hl!
 push hl
 ; Now find the length of the string arg!
 call sub_Length
The argument is saved, and we call sub_Length to figure out the length of that string argument.
It gets pushed back to HL, so I pushed HL to a stack to save the argument.
Code: [Select]
; Copy it to the correct place...
 ex de,hl
I exchanged the new HL with DE, where it's supposed to go. Now the length is saved!

Code: [Select]
call OpenGUIStackSince we don't need HL anymore, we're can call it and let it destroy things!

Code: [Select]
; ...and bring back the string arg!
 pop hl
And of course, HL is save and sound.... right?

Hopefully that logic will work! :)
I've attached the compiled 8Xp - simply add #Axiom(DCSAXIOM) to your code, and then
use DrawL("hello world!") to test! :)

Beware that this may crash your calc, so please, please, PLEASE back up your stuff before proceeding.
Thanks to KermMartian for the tip! :)

EDIT: Silly me, forgot to actually attach something! :P
Also, you can view the entire code here:
http://code.google.com/p/axe-gui-libraries/source/browse/src/dcs7axiom/DCSAxiom.z80

EDIT 2: Apparently DE is also destroyed too (according to http://dcs.cemetech.net/index.php?title=OpenGUIStack), so I've added a push/pop de into the code and recompiled - hopefully this is the panacea to the crash? (Reattached program with changes)
Title: Re: DCS Axiom development
Post by: Munchor on April 14, 2011, 06:10:22 am
Very nice alberthrocks! I gotta check that and try and add CloseGUIStack.
Title: Re: DCS Axiom development
Post by: kindermoumoute on May 16, 2011, 12:54:15 pm
Up ?
Title: Re: DCS Axiom development
Post by: DJ Omnimaga on May 16, 2011, 05:33:01 pm
IN summary, this is an Axiom to use Doors CS GUI libraries and such things, right?
Title: Re: DCS Axiom development
Post by: alberthrocks on May 16, 2011, 07:25:34 pm
Yup! :)
It's still a heavy WIP, but it will be ready soon! :D
Thank you guys for reminding me! It'll be a while before this takes off due to much projects and HW from school, and tests next week. I'm literally swamped to death... X_X
Title: Re: DCS Axiom development
Post by: DJ Omnimaga on May 16, 2011, 08:47:35 pm
When do you finish school?