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 ... 77 78 [79] 80 81 ... 317
1171
ASM / Re: ASM Optimized routines
« on: February 01, 2013, 01:39:49 pm »
Awesome, I definitely like rectangel codes! I am glad you preserve the coordinates, too. Here are a few optimisations that I see without examining the code too much.
Code: [Select]
  ld hl,or_xor
  ld (hl),a   ;use smc for xor/solid fill
To save a byte and a clock cycle, this can simply be:
Code: [Select]
  ld (or_xor),a
Code: [Select]
   rra    ;a = x coord / 8
   rra    ;
   rra    ;
   and %00011111 ;starting x/8 (starting byte in gbuf)
   ld e,a   ;
   add hl,de  ;add x
   ld de,gbuf  ;
   add hl,de  ;hl = offset in gbuf
To save 7 clock cycles and 0 bytes:
Code: [Select]
   rra    ;a = x coord / 8
   rra    ;
   rra    ;
   and %00011111 ;starting x/8 (starting byte in gbuf)
   or 40h   ;gbuf=9340h, 40h = %01000000, so this won't cause problems
   ld e,a   ;
   ld d,93h
   add hl,de  ;add x


Code: [Select]
  pop hl
  pop bc    ;restore b (# columns)
  pop af
  ld de,12
  add hl,de   ;move down to next row
Since B is already 0 at the start of this code, save a byte and 3 t-states:
Code: [Select]
  pop hl
  ld c,12
  add hl,bc
  pop bc    ;restore b (# columns)
  pop af
And now you can actually modify that whole routine to be a little faster:
Code: [Select]
  ld d,a
rectangle_loop_y:
  push bc
  push hl
rectangle_loop_x:
   ld e,a
or_xor = $
   or (hl)   ;smc will modify this to or/xor
   ld (hl),a
   ld a,e
   rrca
    jr nc,$+3
    inc hl
   djnz rectangle_loop_x
  pop hl
  ld c,12
  add hl,bc
  pop bc
  ld a,d
  dec c
   jr nz,rectangle_loop_y
You get rid of a push af / pop af in the loop which takes 21 t-states and replace it with a ld a,d which is 4 t-states.

This is definitely smaller than my routine. In mine, I make a 12-byte pattern to OR or XOR onto the screen o_o
One of the tricks I use is to find the first byte non-zero byte of the pattern:
Code: [Select]
;D is the x coordinate, here
;HL points to the pattern buffer (12 bytes)
     ld a,d
     and 7
     ld a,80h
     ld b,a
     jr z,$+5
       rrca
       djnz $-1
;A is the mask if it were for a pixel
;B is 0
     add a,a
     dec a
     ld (hl),a
So for example, if D and 7 = 3, you would get %00010000. 'add a,a' turns that to %00100000 and then dec a → %00011111.
And if you are worried about ' D and 7 ' = 0, you get %10000000→%00000000→%11111111 which is correct, or if 'D and 7' returns 7, %00000001→%00000010→%00000001.

1172
News / Re: TI-Concours 2013 !
« on: February 01, 2013, 07:58:27 am »
o_o I think I will participate, but if I make it to the finals, I won't be able to participate unless I get a Skype thing (I have no camera or mic).

Still, just in case I do get those in time, I should enter o.o

EDIT: I entered in TI-BASIC, z80 Assembly, and 68k BASIC. Also, because I plan to change my name in the future and I have started to use the name IRL, I am using that name instead of my legal name. This way if I do well I can put it on a CV ^-^

1173
Ash: Phoenix / Re: Optimization help [A:P]
« on: February 01, 2013, 07:00:52 am »
For the custom decimal drawing routine, this might work:
Code: [Select]
:E8458→A
:While Ans
:r3^10→{A--}
:r3/10→r3
:End
Now A points to the first byte of the decimal expansion. I am not sure if Axe has a better way. In assembly, division routines do double duty to return a remainder as well. I think Axe uses the bcall() for division by 10, so you can probably do:
Code: [Select]
:E8458→A
:While r3
:r3/10→r3
:Asm(26006F     ;a→hl
:→{A--}
:End
But then you will need a special case for r3=0. I am actually not sure if these methods are faster or smaller.

1174
TI Z80 / Re: On-Calc Tutorials
« on: February 01, 2013, 06:43:33 am »
Thanks! In code, I currently have this but I want to change it:
Code: [Select]
MainMenu:
     Menu("Command Index",cmdindex)
     Menu("Math Tutorials",mathtutorials)
     Menu("Programming Tutorials",programming)
     .db 0
programming:
     Item("Hello World",ex_helloworld,0)
cmdindex:
mathtutorials:
     .db 0
Anything labeled as a Menu() will open a new menu when it is selected and anything labeled as Item() well set it as the tutorial to use. I think I will make it a simple list that the user can scroll through and I think that I will change the format, too. This way the menu or item name is part of the data and there can be several organisation options. For example, a command that falls under several categories might be like this:
Code: [Select]
MainMenu:
     Menu(cmdindex)
     Menu(mathtutorials)
     Menu(probstattutorials)
     .db 0
cmdindex:
     .db "Command Index",0
     Item(cmd_nCr)
     .db 0

mathtutorials:
     .db "Math",0
     Item(cmd_nCr)
     .db 0

probstatstutorials:
     .db "Probability/Statistics",0
     Item(cmd_nCr)
     .db 0
cmd_nCr:
     .db "nCr",0
     .db tut_nCr
And now each menu is just an LUT of 3-byte elements. 1 byte is for the Menu/Item and 2 bytes for the pointer to the item data.

1175
TI Z80 / Re: Simulated Keypresses
« on: January 31, 2013, 10:00:20 pm »
Thanks! I finished up the main functions for the keyhook, now I need to add in a menu for the app to access the tutorials.
Code: (Current Supported Functions) [Select]
/=====================\
|    Key(val)         | 1 byte
\=====================/
  This is the main command. This tells the engine which key to
simulate. For example, to simulate [ENTER], use Key(skEnter).
/=====================\
|    Delay(val)       | 2 bytes
\=====================/
  This sets the delay between simulated key presses. I find 30
to work well.
/=====================\
|    Text(y,x,string) | 4 bytes + length of string
\=====================/
  This is how you communicate to the user. This is like the
BASIC command, except it draws over whatever is on the LCD, not
just the graph screen. For the worried, this does not affect the
contents of the graph screen. So for example:
     Text(56,0,"Hello World!")
/=====================\
|    WaitForKey(key)  | 2 bytes
\=====================/
  This waits for the user to press the appropriate key. When the
user presses the key, it will be registered. No other keys
respond while waiting.
/=====================\
|    Repeat(key,num)  | 3 bytes
\=====================/
  This will simulate a key press a number of times in a row.
This is useful for navigating menus to get to an item.
/=====================\
|    ExitTutor()      | 1 byte
\=====================/
  This ends the tutorial and normal OS stuff resumes.

  These commands should be enough for most tasks. However, if
there are more commands for the adventurous:
/=====================\
|    SetAns(num)      |
\=====================/
  This will set the "Ans" variable to the specified value. Note
that this whole program works with 1-byte values, 0 to 255.
/=====================\
|    TestAnsEqu(num)  |
\=====================/
  If 'Ans' is equal to 'num', then 'Ans' is set to 1, else it
is set to 0.
/=====================\
|    GetKey(num)      |
\=====================/
  Stores the user's keypress to Ans. This isn't as responsive
as it could be, yet, but it works.
/=============================\
|    JumpIfAnsEqu(num,label)  |  4 bytes
\=============================/
  This will jump to a label if Ans=num. Note that the label must
be on the same flash page.
/=====================\
|    PushAns()        |
\=====================/
  This pushes Ans onto a stack for later retrieval with
PopAns(). The stack is currently 240 bytes, but it may be
smaller in the future.
/=====================\
|    PopAns()         |
\=====================/
  This removes the last value on the stack and stores it to
'Ans'.
I think once I add in the menu the process will be much easier. I am glad I added in the ability to use Text() today because it makes it much more interactive :) The code that is used for the "tutorial" in the screenie is:
Code: [Select]
ex_helloworld:
     Key(skClear)
     Delay(30)
     Text(44,0,"First, we need to make")
     Text(50,0,"a new program. Press PRGM,")
     Text(56,0,"and the Tutor will do the rest.")
     WaitForKey(skPRGM)
     Key(skright)
     Key(skright)
     Key(skenter)
     Text(56,0,"Enter the program name")
     Key(skpower)      ;H
     Key(sksquared)     ;I
     Key(skminus)      ;W
     Key(sk7)          ;O
     Key(sktimes)      ;R
     Key(skrparen)     ;L
     Key(skinverse)    ;D
     Key(skEnter)
     Key(skClear)
     Key(skprgm)
     Key(skright)
     Repeat(skdown,7)
     Key(skEnter)
     Text(50,0,"Press ENTER to go to the")
     Text(56,0,"next line of code.")
     WaitForKey(skEnter)
     Key(skprgm)
     Key(skright)
     Repeat(skdown,2)
     Key(skEnter)
     Key(sk2nd)
     Key(skAlpha)
     Key(skplus)
     Key(skH-112)
     Key(skE-112)
     Key(skL-112)
     Key(skL-112)
     Key(skO-112)
     Key(skSpace-112)
     Key(skW-112)
     Key(skO-112)
     Key(skR-112)
     Key(skL-112)
     Key(skD-112)
     Key(skAlpha)
     Key(skMath)
     Repeat(skRight,3)
     Repeat(skDown,3)
     Key(skEnter)
     Key(sk2nd)
     Key(skMode)

     Key(skClear)
     Text(50,0,"Enter the program name,")
     Text(56,0,"then press ENTER to run it.")
     Key(skNULL)
     Key(skPrgmToken)
     Key(sk2nd)
     Key(skAlpha)
     Key(skpower)      ;H
     Key(sksquared)    ;I
     Key(skminus)      ;W
     Key(sk7)          ;O
     Key(sktimes)      ;R
     Key(skrparen)     ;L
     Key(skinverse)    ;D
     WaitForKey(skEnter)
     ExitTutor()

1176
Could someone check the list of bugs on the 1st post and post whatever is missing that was discovered in recent years? It would definitively be nice to complete that list, especially with the MP OSes. Please, only OS bugs, not bugs caused by ASM programs and stuff.
Okay, I updated it :)

Also who thinks that most OS 2.43 and 2.55 MP bugs will still be present in OS 4.0 for the Color 84+? <_<
The game.

1177
TI Z80 / Re: Simulated Keypresses
« on: January 30, 2013, 07:16:46 pm »
Hehe, I already started an idea on TI-Basic Developer about maybe creating an on-calc BASIC tutorial that steps users through the process of creating programs and how to use each command (like CtlgHelp, but much more involved). I have even started an idea for adding annotations so that you can inform the user what is happening at each step. I estimate that it would take one page to cover all of the commands and we could use a second page for the programming tutorials.

EDIT: I started making an app with some simple scripty commands so that non-assembly programmers can contribute code. I plan to add in menus, but for now it automatically installs the Hello World example walkthrough thingy. The code looks like:
Code: [Select]
ex_helloworld:
     Delay(30)
;     Text(56,0,"New Program")
     Key(skprgm)
     Key(skright)
     Key(skright)
     Key(skenter)
     Key(skpower)      ;H
     Key(sksquared)     ;I
     Key(skminus)      ;W
     Key(sk7)          ;O
     Key(sktimes)      ;R
     Key(skrparen)     ;L
     Key(skinverse)    ;D
     Key(skEnter)
     Key(skClear)
     Key(skprgm)
     Key(skright)
     Repeat(skdown,7)
     Key(skEnter)

     Key(skEnter)
     Key(skprgm)
     Key(skright)
     Repeat(skdown,2)
     Key(skEnter)
     Key(sk2nd)
     Key(skAlpha)
     Key(skplus)
     Key(skH-112)
     Key(skE-112)
     Key(skL-112)
     Key(skL-112)
     Key(skO-112)
     Key(skSpace-112)
     Key(skW-112)
     Key(skO-112)
     Key(skR-112)
     Key(skL-112)
     Key(skD-112)
     Key(skAlpha)
     Key(skMath)
     Repeat(skRight,3)
     Repeat(skDown,3)
     Key(skEnter)
     Key(sk2nd)
     Key(skMode)

     Key(skPrgmToken)
     Key(sk2nd)
     Key(skAlpha)
     Key(skpower)      ;H
     Key(sksquared)    ;I
     Key(skminus)      ;W
     Key(sk7)          ;O
     Key(sktimes)      ;R
     Key(skRParen)     ;L
     Key(skinverse)    ;D
     Key(skEnter)
     ExitTutor()
It is 65 bytes, by the way.

1178
Other / Re: How do you make 2.5 mm to 2.5 mm link cable?
« on: January 30, 2013, 05:37:30 pm »
You probably don't even need to file it down. I can use the 2.5mm headphones just fine to listen to music on the calc. I should look into a better method for making a cable, though. I have a 3.5mm to 3.5mm cable with two adapters for 2.5mm→3.5mm, but the connection gets kind of iffy and it needs to be just right for both lines to connect.

1179
TI Z80 / Re: Simulated Keypresses
« on: January 30, 2013, 01:55:36 pm »
Yay, I finished something on my lunch break! Now you can do *[num] to execute a key press [num] times in a row. As well, I fixed the issue with modifiying the string while the edit buffer was open, so you can now use this program to create programs and modify them!

EDIT: I have attached an updated version. The new version allows you to set a delay for reading each key press. Now you can actually see what is going on making this program possibly an excellent tool for on-calc tutorials.

1180
TI Z80 / Re: Simulated Keypresses
« on: January 30, 2013, 06:43:56 am »
I need to adjust the program a bit because I realised that I made a silly mistake. (Warning: This is complicated ASMy stuff): Since the keyhook automatically deletes the first element from the string once it is read, I ran into a problem when I made a key sequence to create and edit a program or equation. I realised this last night which is why I tested it and it is because the edit buffer is still open. I think that what I will do is if the edit buffer is open, I will just fill the bytes with 00 and treat those as null bytes, then when the edit buffer is closed, I will delete all the appropriate stuff.

Now, stuff I have been thinking of adding:
  • *<<number>> to execute a key press a number of times. This shouldn't be difficult to add.
  • For(number)<<key sequence>>End to execute a keysequence a number of times. This might be difficult to do since I will need to somehow keep track of which key to execute next.
EDIT: To give an idea of the syntax for *, I am thinking something like 3*7 will simulate pressing right 7 times. I already have the code planned for this, so if I have time today, I will try to have it implemented :)

1181
TI Z80 / Re: Simulated Keypresses
« on: January 29, 2013, 06:18:17 pm »
Thanks, and yes, there is no delay between keypresses. It can even press non-repeating keys multiple times in a row :)

1182
TI Z80 / Tutor App
« on: January 29, 2013, 06:00:57 pm »
EDIT:22 April 2013
This topic is now renamed Tutor App as the project has evolved. An updated version can be found at this post later in the topic.


(original post)

On TI-BD, there was an idea for simulating keypresses, so I offered my assembly program to simulate a keypress. But then they wanted to simulate a list of keypresses, so I finally started working on that. Currently, whenever the OS looks for keypresses (not while programs are executing), the hook looks for the hacked string 17 (AA11h) and if it contains data, it will read the numbers one at a time, executing the keypresses.

The keypresses are not getKey values. If you have used assembly keycodes (where Enter=9, for example), that is the set you will want to use. To simulate pressing [2nd]+[nobbc], add 56, to simulate [ALPHA]+[nobbc], add 112. So for example, [Graph]=49, [PRGM]=31, [MATH]=47. To open the graph screen, then press [2nd][prgm] and then select 1:ClrDraw, use:
Code: [Select]
"49,87,9
To do that, then select the A:Pen from the draw menu, add an additional 87,159 (159=112+47). Finally, the arrows are 1=down,2=left,3=right,4=up. Combining all this:
Code: [Select]
"49,87,9,87,159,9,2,2,2,2,1,1,1,1,3,3,3,3,4,4,4,4
That will select ClrDraw, then Pen, then it will draw you a box :)
Spoiler For List of Key Codes:
01      Down
02      Left
03      Right
04      Up

09    Enter
10    +
11    -
12    *
13    /
14    ^
15    Clear

17    (-)
18    3
19    6
20    9
21    )
22    tan(
23    vars

25    .
26    2
27    5
28    8
29    (
30    cos(
31    prgm
32    Stat
33    0
34    1
35    4
36    7
37    ,
38    sin(
39    APPS
40    XTON

42    sto>
43    ln(
44    log(
45    X^2
46    X^-1
47    Math
48    Alpha
49    graph
50    trace
51    zoom
52    window
53    Y=
54    2nd
55    mode
56      delete

255    [2nd][On]
254    [prgm][enter] displays prgmA (Even if it doesn't exist)
253    [2nd][Stat]
252    Displays LA (list A)
251    Disp If
250    [Graph]
249    Catalog
248    nothing
247    Same as FE
246    RAM Clear
Spoiler For How To Make Hacked Strings:
There are several "easy" ways, but they involve getting the hacked string name in a string, then use Rcl Ans in a program to paste the name their. They typically have funky names, so don't be alarmed if your string is named something like GDB1-- it is because the OS doesn't have real names for them, so it uses what it has. Anyways:
  • Xtravar Beta provides an easy way to select hacked variables. In this case, find the Strings, and search for String 17 (11h) it will have a name 'sigma'x.
  • You can use Celtic 3 to do det(17,"AA11
  • You can use BatLib to do dim(5,"AA11
  • Xtra will take a list input to create a hacked var token. This has an included opcode.

1183
Grammer / Re: Grammer 2-The APP
« on: January 29, 2013, 06:42:07 am »
 °Z is meant to work with RunPart :) Actually, AddPart does not require a buffer. If you want, you can use AddPart() with one buffer, then switch the buffer for RunPart and the particles would still be in the correct location on the new buffer.

Also, I think there were 18 bytes when I updated it, but I found extra code to delete XD

1184
Grammer / Re: Grammer 2-The APP
« on: January 27, 2013, 07:35:24 am »
I worked on Grammer a little bit yesterday and at some points I  had precisely 0 bytes of coding space. However, I removed two undocumented experimental routines for sending/receiving bytes over the I/O port and now there are 69 bytes of coding space available!

As to the updates, I may have broken some things because I made a few more complicated modifications. I am pretty sure that I checked everything that could be affected, but I may have missed something.
  • Else is finally added as a command. In a very basic way, Else works like you would expect:
    Code: [Select]
    If A=B
    Then
    <<do stuff>>
    Else
    <<do stuff>>
    End
  • Else has some complicated things that it can do. The way I implemented Else, it can stand alone as its own command. If you do this, it will seek an appropriate End token. For example:
    Code: [Select]
    While A>3
    A-1→A
    If A=5
    Else        ;This will skip over everything until it finds the correct End
    If A=4
    Then
    <<do stuff>>
    End         ;not the correct End!
    End         ;The correct End!
    If you don't uderstand that, don't worry. As well, you can do something like this:
    Code: [Select]
    While A
    A-1→A
    Text(0,A,"O
    Else
    DispGraph
    End
    That is actually a neat trick to help you understand how Else works, but it isn't optimised :P That basically does this:
    Code: [Select]
    While A
    A-1→A
    Text(0,A,"O
    End
    DispGraph
    Personally, I would just stick with the first use. The other methods will just complicate your code and probably cause confusion when parts of code don't work.
  • Typewriter Text has been fixed! Now you don't need a DispGraph after using /Text( to see the last character.
  • The degree token now acts as a command on its own, too. This can be used to temporarily change the draw buffer for the Text( command. Any command that has an optional buffer argument will revert the draw buffer back to normal. So for example, if Z points to the back buffer:
Code: [Select]
oZ           ;o is supposed to be the degree token
Text(0,0,"HI!
Text(6,0,"This is on another buffer.
Pxl-On(3,3
Text(0,0,"HI!     ;This is now drawn on the main buffer since the Pxl-On( command resets the temporary draw buffer
It also happens that this works for the particle commands as well, so now you can draw particles on back buffers without using complicated techniques.

1185
Grammer / Re: [Grammer] Displaying "!" with /Text(
« on: January 26, 2013, 10:06:41 am »
Oh, I had completely forgotten about that issue D: Yes, /Text( doesn't seem to update the LCD with the last character, sorry :/

Pages: 1 ... 77 78 [79] 80 81 ... 317