90

AFAIK, the AMS 1.00-3.10 HLock doesn't trash (sp).w, and HLock is not the only AMS routine abused that way by various programs - but you're right smile
avatarMembre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
Co-admin de TI-Planet.

91

Folco (./89) :
Potential bug in sld.asm, ExtractFileFromPack : unexpected behavior if HLock destroys (sp).w
move.w (sp),-(sp) // ROM_THROW HLock // addq.l #2,sp would solve that

Under PedroM, I control how HLock is written and which registers are destroyed tongue

92

Of course, but I have reported that because it's part of sld.asm, which is shared with PreOS. ^^
avatar<<< Kernel Extremist©®™ >>>
Feel the power of (int16) !

93

Folco (./92) :
Of course, but I have reported that because it's part of sld.asm, which is shared with PreOS. ^^

TI would never release a newer AMS tongue

94

FolcOS will destroy (sp) ! #evil#
avatar<<< Kernel Extremist©®™ >>>
Feel the power of (int16) !

95

# devil # not #evil# !

96

RC7 is available with the latest bugs about the link (maybe) fixed, the RAM_THROW extension by Martial, and other fixed bugs (bsearch) and a faster qsort.
PpHd (./64) :
Bug found: performing twice 'echo Hello > toto | ls' produce a 'Protected Memory' error.

Not fixed yet. To do in RC8.

97

Nice ! I test now the link ! \o/
avatar<<< Kernel Extremist©®™ >>>
Feel the power of (int16) !

98

OS tranfert successful, but using FreeFlash. Did you fix the problem with the 'install tib' command ?

I reboot and begin testing with TI-Connect.




TI Device Explorer :
- The calc is seen as a TI89 !
- Nevertheless, I get a 'command' error when detecting the device
- I can browse folders, but I don't see vars.

Ti Device Info :
- Always nothing displayed, I get first one 'format' error, then Ti-Connect throws its error, then I get a 'reset' error. I will retry using link debug info.

RAM_THROW seems to work fine (tested some functions and data in user mode). happy
avatar<<< Kernel Extremist©®™ >>>
Feel the power of (int16) !

99

Folco (./98) :
Did you fix the problem with the 'install tib' command ?

I don't know what is the problem.
Folco (./98) :
- Nevertheless, I get a 'command' error when detecting the device

sad
Folco (./98) :
- I can browse folders, but I don't see vars.

sad
Folco (./98) :
- Always nothing displayed, I get first one 'format' error, then Ti-Connect throws its error, then I get a 'reset' error. I will retry using link debug info.

Thanks.

Could you try if there is no regression with Tilp?

100

Of course, but now I'll do that on Sunday.

When using 'install tib', must I use a fsigned ROM and fflash ? I think no ? The provided TIB should be right to be transfered ?
avatar<<< Kernel Extremist©®™ >>>
Feel the power of (int16) !

101

Folco (./100) :
When using 'install tib', must I use a fsigned ROM and fflash ? I think no ? The provided TIB should be right to be transfered ?

no / yes

102

I've just noticed that ExtGraph's demo33, which tests DrawClipLine and the equivalent ExtGraph routine, when run under PedroM, corrupts the screen and the heap (and everything in-between), before crashing, which triggers a full reset (<= corrupted heap).
The lines in the top-left quarter of the screen are fine, the crashes happens when drawing the vertical line (or perhaps, the first line of the top-right quarter of the screen).
avatarMembre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
Co-admin de TI-Planet.

103

Lionel Debroux (./102) :
I've just noticed that ExtGraph's demo33, which tests DrawClipLine and the equivalent ExtGraph routine, when run under PedroM, corrupts the screen and the heap (and everything in-between), before crashing, which triggers a full reset (<= corrupted heap).
The lines in the top-left quarter of the screen are fine, the crashes happens when drawing the vertical line (or perhaps, the first line of the top-right quarter of the screen).

A bug in PedroM or in extgraph ? cheeky

104

Oh shit, I messed up the edit when I reformulated my message couic
The first version contained the piece of information that it runs properly under AMS, so it would be a bug in PedroM.
In PedroM, the crash happens during the first loop of GrayDrawClipLine, which is a thin wrapper over DrawClipLine.

#define NO_EXIT_SUPPORT
#define OPTIMIZE_ROM_CALLS

#define NO_CALC_DETECT
#define NO_AMS_CHECK
#define MIN_AMS 100

#include <tigcclib.h>
#include "../../lib/extgraph.h"  // NOTE: this path is just for this demo !!
                                 //       if the extgraph library is correctly
                                 //       installed you should use:
                                 //
                                 //       #include <extgraph.h>

#define INITIAL_TIMER_VALUE (100000*20UL)

/*===========================================================================*/
/* main routine: where all the fun starts ...                                */
/*===========================================================================*/
void _main(void) {
    short         i,j;
    unsigned long measure_val;
    char          tmpstr[50] = "Measuring, please wait ...";
    static const short modes[4] = {COLOR_LIGHTGRAY,COLOR_DARKGRAY,COLOR_BLACK,COLOR_WHITE};
    unsigned short clippedcoord[4];
    LCD_BUFFER    screen;

    LCD_save(screen);

    OSFreeTimer(USER_TIMER);
    OSRegisterTimer(USER_TIMER,INITIAL_TIMER_VALUE);

    if (!GrayOn()) goto end;

    //---------------------------------------------------------------------
    // built-in OS line drawing routine ...
    //---------------------------------------------------------------------
    GrayClearScreen_R();
    OSTimerRestart(USER_TIMER);
    for (j=0;j<4;j++) {
        short used_color = modes[j];
        for (i=-40;  i<280;i++) GrayDrawClipLine(120,64,i,-40,used_color); // Crashes here.
        for (i=-40;  i<168;i++) GrayDrawClipLine(120,64,280,i,used_color);
        for (i=280;i>=-40; i--) GrayDrawClipLine(120,64,i,168,used_color);
        for (i=168;i>=-40; i--) GrayDrawClipLine(120,64,-40,i,used_color);
    }
    measure_val = OSTimerCurVal(USER_TIMER);
    sprintf(tmpstr,"OS routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val);
    GrayDrawRect(0,0,239,7,COLOR_WHITE,RECT_FILLED);
    GrayDrawStrExt(0,0,tmpstr,A_NORMAL | A_CENTERED | A_SHADOWED,F_4x6);

    if (ngetchx() == KEY_ESC) goto end;

    
    //---------------------------------------------------------------------
    // new line drawing routine ...
    //---------------------------------------------------------------------
    GrayClearScreen_R();
    OSTimerRestart(USER_TIMER);
    for (j=0;j<4;j++) {
        short used_color = modes[j];
        for (i=-40;  i<280;i++) GrayClipDrawLine_R(120,64,i,-40,clippedcoord,used_color,GrayGetPlane(LIGHT_PLANE),GrayGetPlane(DARK_PLANE),GrayFastDrawLine2B_R);
        for (i=-40;  i<280;i++) GrayClipDrawLine_R(120,64,280,i,clippedcoord,used_color,GrayGetPlane(LIGHT_PLANE),GrayGetPlane(DARK_PLANE),GrayFastDrawLine2B_R);
        for (i=280;i>=-40; i--) GrayClipDrawLine_R(120,64,i,168,clippedcoord,used_color,GrayGetPlane(LIGHT_PLANE),GrayGetPlane(DARK_PLANE),GrayFastDrawLine2B_R);
        for (i=168;i>=-40; i--) GrayClipDrawLine_R(120,64,-40,i,clippedcoord,used_color,GrayGetPlane(LIGHT_PLANE),GrayGetPlane(DARK_PLANE),GrayFastDrawLine2B_R);
    }
    measure_val = OSTimerCurVal(USER_TIMER);
    sprintf(tmpstr,"Own routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val);
    GrayDrawRect(0,0,239,7,COLOR_WHITE,RECT_FILLED);
    GrayDrawStrExt(0,0,tmpstr,A_NORMAL | A_CENTERED | A_SHADOWED,F_4x6);

    if (ngetchx() == KEY_ESC) goto end;


    GrayOff();
    ClrScr();
    //---------------------------------------------------------------------
    // built-in OS line drawing routine ...
    //---------------------------------------------------------------------
    OSTimerRestart(USER_TIMER);
    for (j=0;j<4;j++) {
        WIN_RECT rect = {120, 64, 0, -40};
        for (i=-40;  i<280;i++) {rect.x1 = i; DrawClipLine(&rect,&(SCR_RECT){{0, 0, 239, 127}},A_XOR); }
        for (i=-40;  i<168;i++) {rect.y1 = i; DrawClipLine(&rect,&(SCR_RECT){{0, 0, 239, 127}},A_XOR); }
        for (i=280;i>=-40; i--) {rect.x1 = i; DrawClipLine(&rect,&(SCR_RECT){{0, 0, 239, 127}},A_XOR); }
        for (i=168;i>=-40; i--) {rect.y1 = i; DrawClipLine(&rect,&(SCR_RECT){{0, 0, 239, 127}},A_XOR); }
    }
    measure_val = OSTimerCurVal(USER_TIMER);
    sprintf(tmpstr,"OS routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val);
    GrayDrawRect2B(0,0,239,7,COLOR_WHITE,RECT_FILLED,LCD_MEM,LCD_MEM);
    GrayDrawStrExt2B(0,0,tmpstr,A_NORMAL | A_CENTERED,F_4x6,LCD_MEM,LCD_MEM);

    if (ngetchx() == KEY_ESC) goto end;

    //---------------------------------------------------------------------
    // new line drawing routine ...
    //---------------------------------------------------------------------
    ClrScr();
    OSTimerRestart(USER_TIMER);
    for (j=0;j<4;j++) {
        for (i=-40;  i<280;i++) ClipDrawLine_R(120,64,i,-40,clippedcoord,A_XOR,LCD_MEM,FastDrawLine_R);
        for (i=-40;  i<280;i++) ClipDrawLine_R(120,64,280,i,clippedcoord,A_XOR,LCD_MEM,FastDrawLine_R);
        for (i=280;i>=-40; i--) ClipDrawLine_R(120,64,i,168,clippedcoord,A_XOR,LCD_MEM,FastDrawLine_R);
        for (i=168;i>=-40; i--) ClipDrawLine_R(120,64,-40,i,clippedcoord,A_XOR,LCD_MEM,FastDrawLine_R);
    }
    measure_val = OSTimerCurVal(USER_TIMER);
    sprintf(tmpstr,"Own routine took %lu ticks",INITIAL_TIMER_VALUE-measure_val);
    GrayDrawRect2B(0,0,239,7,COLOR_WHITE,RECT_FILLED,LCD_MEM,LCD_MEM);
    GrayDrawStrExt2B(0,0,tmpstr,A_NORMAL | A_CENTERED,F_4x6,LCD_MEM,LCD_MEM);

    ngetchx();

    end:
    OSFreeTimer(USER_TIMER);
    GrayOff();
    LCD_restore(screen);
    GKeyFlush();
    ST_helpMsg(EXTGRAPH_VERSION_PWDSTR);
}


I'm going to investigate further.
avatarMembre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
Co-admin de TI-Planet.

105

        for (i=-40;  i<280;i++) GrayDrawClipLine(120,64,i,-40,used_color);
        for (i=-40;  i<168;i++) {if (i >= 13) GrayDrawClipLine(120,64,280,i,used_color);}
        for (i=280;i>=-40; i--) GrayDrawClipLine(120,64,i,168,used_color);
        for (i=168;i>=-40; i--) GrayDrawClipLine(120,64,-40,i,used_color);

and
        for (i=-40;  i<280;i++) {rect.x1 = i; DrawClipLine(&rect,&(SCR_RECT){{0, 0, 239, 127}},A_XOR); }
        for (i=-40;  i<168;i++) if (i >= 13) {rect.y1 = i; DrawClipLine(&rect,&(SCR_RECT){{0, 0, 239, 127}},A_XOR); }
        for (i=280;i>=-40; i--) {rect.x1 = i; DrawClipLine(&rect,&(SCR_RECT){{0, 0, 239, 127}},A_XOR); }
        for (i=168;i>=-40; i--) {rect.y1 = i; DrawClipLine(&rect,&(SCR_RECT){{0, 0, 239, 127}},A_XOR); }


fix the crashes, but some lines from the top-right and bottom-left corners (drawn by the first and third lines) are missing, and a bit of garbage is drawn at the top-left border of the screen. That shouldn't happen smile
avatarMembre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
Co-admin de TI-Planet.

106

Patch:
--- a/src/c/clipline.c
+++ b/src/c/clipline.c
@@ -55,7 +55,7 @@ typedef union {
         swap(y1,y2);                                                    \
         dx = -dx;                                                       \
       }                                                                 \
-    if ((x1 > Clip.Right) || (x2 < Clip.Left) || (y1 > Clip.Down) || (y2 < Clip.Up)) \
+    if ((x1 > Clip.Right) || (x2 < Clip.Left) || (y1 > Clip.Down && y2 > Clip.Down ) || (y2 < Clip.Up && y1 < Clip.Up)) \
       return;                                                           \
     dy = y2 - y1;                                                       \
     if (dx == 0)                                                        \
@@ -111,42 +111,41 @@ typedef union {
           }                                                             \
       }                                                                 \
     else       {                                                       \
-      dy = - dy;                                                        \
       if (x1 < Clip.Left)                                               \
         {                                                               \
-          if ((y1 > Clip.Down) && ((t = x1 + dx *(y1-Clip.Down)/dy) >= Clip.Left)) \
+          if ((y1 > Clip.Down) && ((t = x1 + dx *(Clip.Down-y1)/dy) >= Clip.Left)) \
             {                                                           \
               x1 = t;                                                   \
               y1 = Clip.Down;                                           \
               if (x1 > Clip.Right) return;                              \
             }                                                           \
           else {                                                       \
-            y1 += dy * (Clip.Left-x1) / dx;                             \
+            y1 = y1 + dy * (Clip.Left-x1) / dx;                         \
             x1 = Clip.Left;                                             \
             if (y1 < Clip.Up) return;                                   \
           }                                                             \
         }                                                               \
       else if (y1 > Clip.Down)                                          \
         {                                                               \
-          x1 += dx * (y1-Clip.Down) / dy;                               \
+          x1 = x1 + dx * (Clip.Down-y1) / dy;                           \
           y1 = Clip.Down;                                               \
           if (x1 > Clip.Right) return;                                  \
         }                                                               \
       if (x2 > Clip.Right)                                              \
         {                                                               \
-          if ((y2 < Clip.Up) && ((t = x2 - dx*(Clip.Up-y2)/dy) <= Clip.Right)) \
+          if ((y2 < Clip.Up) && ((t = x2 + dx*(Clip.Up-y2)/dy) <= Clip.Right)) \
             {                                                           \
               x2 = t;                                                   \
               y2 = Clip.Up;                                             \
             }                                                           \
           else {                                                       \
-            y2 -= dy * (x2-Clip.Right) / dx;                            \
+            y2 = y2 + dy * (Clip.Right-x2) / dx;                        \
             x2 = Clip.Right;                                            \
           }                                                             \
         }                                                               \
       else if (y2 < Clip.Up)                                            \
         {                                                               \
-          x2 -= dx * (Clip.Up-y2) / dy;                                 \
+          x2 = x2 + dx * (Clip.Up-y2) / dy;                             \
           y2 = Clip.Up;                                                 \
         }                                                               \
     }                                                                   \
@@ -165,5 +164,7 @@ void DrawClipLine (const WIN_RECT *Line, const SCR_RECT *clip, short Attr)
   Clip.Right = clip->xy.x1;
   Clip.Down = clip->xy.y1;
   ClipLine(x1, y1, x2, y2);
+  //if (x1 < 0 || x2 >239 || y1 < 0 || y1 > 127 || y2 < 0 || y2 > 127)
+  //  asm ("toto: bra toto\n");
   DrawLine(x1,y1,x2,y2,Attr);
 }

107

I've rebuilt PedroM and I can confirm that your fix is OK smile
While ExtGraph's GrayClipDrawLine_R is faster than calling PedroM's DrawClipLine twice, PedroM's DrawClipLine is faster than ExtGraph's ClipDrawLine_R...

NOTE: you could make the ClipLine macro of src/c/clipline.c several bytes smaller (and several clocks faster), by using inline assembly for the "swap" macro:
#define ASM_EXCHANGE(val1,val2) asm volatile ("exg %0,%1" : "=da" (val1),"=da" (val2) : "0" (val1),"1" (val2) : "cc")


In the src folder, `make CAS=1` works, but `make` doesn't, due to an undefined reference on the following line:
xdef Zs_function_call
Moving this line down by one line, under the
ifd USE_MAIN_PROGRAM
conditional section, should fix the problem.
avatarMembre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
Co-admin de TI-Planet.

108

Lionel Debroux (./107) :
NOTE: you could make the ClipLine macro of src/c/clipline.c several bytes smaller (and several clocks faster), by using inline assembly for the "swap" macro: #define ASM_EXCHANGE(val1,val2) asm volatile ("exg %0,%1" : "=da" (val1),"=da" (val2) : "0" (val1),"1" (val2) : "cc")

I dont like mixing specific asm code with C (moreover, the clipline macro is quite generic) but thanks for the advice.
(Moreover what really costs is the multiplication and the division).
Lionel Debroux (./107) :
In the src folder, `make CAS=1` works, but `make` doesn't, due to an undefined reference on the following line:
xdef Zs_function_call
Moving this line down by one line, under the
ifd USE_MAIN_PROGRAM conditional section, should fix the problem.

Already fixed in RC8, but thanks!

109

I dont like mixing specific asm code with C (moreover, the clipline macro is quite generic) but thanks for the advice.

I reported this because you had to perform some size optimization before being able to release RC7, and this one was a low-hanging fruit smile
Two other low-hanging fruits are replacing bsearch() and qsort() by ASM versions.
(Moreover what really costs is the multiplication and the division).

Indeed.
avatarMembre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
Co-admin de TI-Planet.

110

It's not a low-hanging fruit, it's very advanced optimization to use inline assembly in C code, and it significantly decreases readability. It could also actually make the code worse in future versions of GCC. I recommend sticking with plain C in most cases.
avatarMes news pour calculatrices TI: Ti-Gen
Mes projets PC pour calculatrices TI: TIGCC, CalcForge (CalcForgeLP, Emu-TIGCC)
Mes chans IRC: #tigcc et #inspired sur irc.freequest.net (UTF-8)

Liberté, Égalité, Fraternité

111

RC8 Released with the following fixes:
PpHd (./64) :
Bug found: performing twice 'echo Hello > toto | ls' produce a 'Protected Memory' error.
Fixed

Bug ./104 : Fixed

Add new system variable: linklog
Execute: "logfile"->system\linklog
to log in 'logfile' all the communications.

Folco: Could you use this feature to tell me what happens with TI software?

112

Ok ! I try now
avatar<<< Kernel Extremist©®™ >>>
Feel the power of (int16) !

113

PpHd (./99) :
Folco (./98) :
Did you fix the problem with the 'install tib' command ?

I don't know what is the problem.

When I use this command, I get a "?". Ok, I send the tib with TiLP, then the "?" is replaced by a bold "o" and a death's head. confus [ON] reset the calc.
avatar<<< Kernel Extremist©®™ >>>
Feel the power of (int16) !

114

Folco (./113) :

When I use this command, I get a "?". Ok, I send the tib with TiLP, then the "?" is replaced by a bold "o" and a death's head. confus.gif [ON] reset the calc.


It doesn't explain the problem smile

115

Ah ?!? grin I though that sending a TIB after having typed the command would upgrade the calc. But using that, TiLP doesn't start to send. Could someone test, or explain me what I don't know how to use this command ?

BTW -> RC8 transfert successful, using freeflash ^^
avatar<<< Kernel Extremist©®™ >>>
Feel the power of (int16) !

116

Folco (./115) :

Ah ?!? biggrin.gif I though that sending a TIB after having typed the command would upgrade the calc. But using that, TiLP doesn't start to send. Could someone test, or explain me what I don't know how to use this command ?


It is the right way. But I don't where is the error in the protocol. I haven't changed it from the previous releases (0.80 & 0.81).

117

I'm still getting troubles with TiLP when sending a file to the PC (timeout). It could depend on file size, I will try to do a test case.

In the shell, the cursor seems to be always 5 pixels above the top of the line, so it's in the middle of the line with system\font set at "1" or "2"
avatar<<< Kernel Extremist©®™ >>>
Feel the power of (int16) !

118

Folco (./117) :
I'm still getting troubles with TiLP when sending a file to the PC (timeout). It could depend on file size, I will try to do a test case.


Thanks.
Folco (./117) :
In the shell, the cursor seems to be always 5 pixels above the top of the line, so it's in the middle of the line with system\font set at "1" or "2"

Yes, the cursor remains the same regardless of the font grin

119

The problem could be with TiLP itself : topics/123598-tilp2-crash-dans-la-reception-des-fichiers#0
The problem is that my linklog is 8kB large, it would be boring to type it by hand sorry
avatar<<< Kernel Extremist©®™ >>>
Feel the power of (int16) !

120

Yeah, it would indeed be extremely boring, not to mention error-prone grin
avatarMembre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
Co-admin de TI-Planet.