Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Xeda112358

Pages: 1 ... 114 115 [116] 117 118 ... 317
1726
Grammer / Re: Grammer 2-The APP
« on: April 30, 2012, 11:54:58 am »
hehe, thanks :)

@Sorunome: If I were to include all that, I would just have one giant app like DoorsCS7 :P

1727
Grammer / Re: Find the error in a beginner's program
« on: April 30, 2012, 11:46:34 am »
Okay, I believe the problem is just that you have :expr(Input →AC' Input will not normally handle numbers >65535 x.x. I also changed a few things:
Code: [Select]
:.0:             ;This line gets ignored because it starts with "."
:Return→B
:ClrDraw
:Line(1,5,9,95,6
:Line(0,6,9,95,6
:Text(8,5,"Base Converter
:/Text(18,0,"Base ?
:DispGraph
:expr(Input →G
:/Text(18,0,"Valeur Décimale ?
:DispGraph
:expr(Input →A  ;
:/Text(30,0,"= "
:Text('°A,G
:DispGraph
:Repeat         ;Added a space here. Just a single space means it uses the last value
:getkey         ;"Repeat getKey" does not change ans
:End
:If =15
:Goto B
:ClrDraw:DispGraph
:Stop

By the way, it looks nice o.o

1728
Grammer / Re: Grammer 2-The APP
« on: April 30, 2012, 11:33:16 am »
Quote
I'm just curious, but is it possible to run apps from grammer program? (or just any kind of program)

I'm not sure, but If you can find a pointer to the App, you may execute the code like an assembly program.

(I don't know how to run assembly programs in a Grammer code...If a Grammer code runs with expr( , maybe an assembly prog needs Asm(expr( ? )


PS: Quite good readme, now :)  There is much more info.
If you know the assembly code to run an app, then yes, you can actually run an app from Grammer. I never even thought about that because it is complicated to do in Assembly.

To run assembly programs, use Asm( and to run hex codes, use AsmPrgm. To execute an App, you want to use AsmPrgm. Be warned that this will exit the program and not return:
Code: [Select]
.0:
Get("EAppName    ;Yes, actually use E. I'm hacking Grammer >.>
AsmPrgm2178843614EF4E4CD8D306C38040
solve(4,2,"App Not Found
Stop
This will leave garbage on the screen in some cases, just as a warning. Also, if the App name does not work, try adding spaces until their are 8 chars. For example, Axe is really named
"Axe     "

1729
Wow, that stuff is neat D:

1730
Grammer / Re: Latest Grammer Updates
« on: April 29, 2012, 11:04:11 pm »
Version 2.29.04.12
I have rewritten the readme, added in support for the menu options, and modified some commands. I tried fixing bugs like the fact that length( wasn't returning what it was supposed to. I also made more arguments optional for certain functions like the sprite and circle commands. Any comments or suggestions can go in the appropriate topic :)

1731
ASM / Re: Bit Math
« on: April 29, 2012, 01:36:44 pm »
Yes, Z80 Bits does indeed have some useful routines in there to look at :)

Oh, and so to do 2-byte multiplication, you can simply change the counter to 16, and then the input registers to 16-bit ones?

and yeah, the division routine would be great.
Yep :) Just remember, though, that 16-bit arithmetic sometimes takes a bit more work. For example, shifting HL left is as simple as add hl,hl, but shifting DE left, there is no add de,de instruction. So you have to do something like sla e \ rl d which is 3 bytes larger.

As for division, here is a routine:
Code: [Select]
HL_Div_C:
;Inputs:
;     HL is the numerator
;     C is the denominator
;Outputs:
;     A is the remainder
;     B is 0
;     C is not changed
;     DE is not changed
;     HL is the quotient
;
       ld b,16
       xor a
Loop:
         add hl,hl
         rla
         cp c
         jr c,$+4
           inc l
           sub c
         djnz Loop
       ret
Luckily, division is pretty simple compared to multiplication. DEHL/C is much easier than DEHL*C. XD

1732
ASM / Re: Bit Math
« on: April 29, 2012, 12:35:12 pm »
Hmm, it doesn't look quite right if you are trying to multiply registers. I don't know if this will help you?
Code: [Select]

D_Times_E:
;Inputs:
;     D and E are factors
;Outputs:
;     A is the product (lower 8 bits)
;     B is 0
;     C,DE, HL are not changed
;Size:  12 bytes
;Speed: 304+b cycles where b is the number of set bits in E
     xor a         ;This is an optimised way to set A to zero. 4 cycles, 1 byte.
     ld b,8        ;Number of bits in E, so number of times we will cycle through
Loop:
     add a,a       ;We double A, so we shift it left.
     rlc e         ;We want the next bit in E, so it is shifted into the c flag
     jr nc,$+3     ;If it is 0, we don't need to add anything to A
       add a,d     ;Since it was 1, we do A+1*D
     djnz Loop     ;Decrements B, if it isn't zero yet, jump back to Loop:
     ret
Basically, this works like regular multiplication that you would do by hand. Since the above code is using 8-bit registers, there are 8 digits per number. Since bits are only 1 or 0, we only have to multiply by one or zero. Then we just add the result to the accumulator. When we get ready to add the next multiplication, we need to shift the accumulator left. In Decimal, we do this by multiplying by ten (tacking on a zero at the end). In binary, we multiply by 2. I hope this helps?

As for division, the algorithm is actually very similar and uses long division like you learned in grade school, except with binary. Say you have 37/5. In binary, you are doing:

00100101/101.

so you shift the 00100101 and move the overflow into another register. Pretend I have done this 5 times already:
0000010010100000
Now you see, the overflow is not greater than 5, so shift once more:
0000100101000000
Now it is, so we get tricky. First, subtract five from the overflow and increment the other number by 1:
0000010001000001
Now shift again:
0000100010000010
Now it is greater than 5 again, so:
0000001110000011
Shift again:
00000011100000110
And do the proper adjustment:
00000001000000111

Now look at that o_O You have the remainder as 2 and the division is 7. Note that in all, there were 8 shifts. I hope this helps! If you want a division code, feel free to ask :)

1733
Grammer / Re: Grammer 2-The APP
« on: April 29, 2012, 12:07:20 pm »
If I can do it, I plan to let Grammer do some hook chaining to allow it to be a little more compatible with the others :)

1734
Grammer / Re: Grammer 2-The APP
« on: April 29, 2012, 12:01:52 pm »
I am currently working on it :)

1735
Grammer / Re: Grammer 2-The APP
« on: April 29, 2012, 11:47:04 am »
Okay, I have been working on this for the past two hours and I now have the main menu working better :) You can now use all of the options:
Gram-When this is highlighted, it only displays programs with a Grammer header
AppV-When this is highlighted, it shows appvars instead of programs
Asm-When this is highlighted, it shows assembly programs. There is a Grammer header for assembly programs, too, just like there are MirageOS programs and ION programs.
Exit-Exits the app
Hook-Currently, this toggles the token hook on and off

Caution: Any program run from this menu is run as a Grammer program or Asm program.

So, again, to summarize:
-You can now run Grammer Asm programs and regular ASM programs from Grammer (The screenshot shows a program I made with Axe)
-You can run a program as a Grammer program, even if it doesn't have the header
-You can toggle the Token hook on or off
-You can look at the program list or appvar list in case you converted your programs to appvars

Also, there are now 655 bytes left, but there is code that I still need to remove.

EDIT: Also, I have been working at cleaning up the readme+tutorial and I am trying to document all of the calls in the jump table so that Assembly programmers can start making Grammer Asm programs.

1736
ASM / Re: The User Program Variable
« on: April 28, 2012, 10:40:48 pm »
If you want to edit the first byte, you can try this:
Code: [Select]
     ld hl,NAME
     rst rMOV9TOOP1
     bcall(_ChkFindSym)
     ret c                ;The program doesn't exist, so exit
     ex de,hl
;Just checking to make sure the size isn't zero, otherwise it will edit unknown data
     ld a,(hl)
     inc hl
     or (hl)
     ret z
     inc hl
     ld (hl),30h     ;or whatever byte you want
     ret
NAME:
     .db 5,"HELLO",0 ;5 means program, 0 terminates
If you want to see more complicated code that edits the first byte of the second line:
Code: [Select]
     ld hl,NAME
     rst rMOV9TOOP1
     bcall(_ChkFindSym)
     ret c
     ex de,hl
;Just checking to make sure the size isn't zero, otherwise it will edit unknown data
     ld c,(hl)
     ld a,c
     inc hl
     or (hl)
     ret z
     ld b,(hl)
     inc hl
;BC is now the size of the program
;HL points to the data
     ld a,3Fh        ;3Fh is the newline token
     cpir            ;Search a max of BC bytes at HL for the first instance of A
     ret po          ;No bytes left in the program
;HL now points to the byte after the start of the second line
;Make sure it isn't another newline. (means Line 2 was empty)
     cp (hl)
     ret z
     ld (hl),30h     ;or whatever byte you want
     ret
NAME:
     .db 5,"HELLO",0

1737
Grammer / Re: Grammer 3-Concepts, ideas, requests
« on: April 28, 2012, 01:51:06 pm »
Oh, you are right, it is only one page o_O

1738
Grammer / Re: Grammer 2-The APP
« on: April 28, 2012, 10:42:13 am »
Ah, okay :) I'll go ahead and answer it in the other topic then :) I was thinking about adding it directly to Grammer as well, since it is very small. If I do have enough space after fixing everything up, I probably will add it to Grammer 2. I am currently working on rewriting the code for the main menu to be smaller and then add the code to handle all the options.

1739
Grammer / Re: Grammer 3-Concepts, ideas, requests
« on: April 28, 2012, 10:31:13 am »
Yes, for Grammer 3, I will make sure to have a good readme :) (That is a good idea)

EDIT: Yeong asked about adding a menu hook in Grammer 3 and that reminded me about some of the other menu features that I think would be awesome.
Since Grammer 3 won't be using the OS menu system, I will definitely be adding a way to make a customisable MenuKey that works like my MenuKeyHook. I will also make it easy for the user to add in extra, customisable menus, too.

Also, since I plan to have custom command sets, I will probably leave the F1 to F4 keys as changing menus depending on what command sets you have loaded. F5 will probably be the custom menu.

1740
Grammer / Re: Grammer 2-The APP
« on: April 28, 2012, 12:25:32 am »
I am still confused D:
I've no clue what is going on !_!


EDIT: Do you mean like a Menu( command?
EDIT2: Or do you mean that MenuKeyHook? o.o That I could do, but I have 878 bytes of space left.

Pages: 1 ... 114 115 [116] 117 118 ... 317