Skip to content

Commit

Permalink
Fix Find panel in toolkit
Browse files Browse the repository at this point in the history
also some typos
commented out code to follow newton script calls
better help text
  • Loading branch information
MatthiasWM committed Jul 4, 2024
1 parent 74751be commit 42b3785
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 82 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Copyright 2003-2022 by Paul Guyot ([email protected]) and others.
# ==============================

cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)

project( "Einstein" VERSION "2024.4.22" )

Expand Down
4 changes: 2 additions & 2 deletions Emulator/JIT/Generic/TJITGenericROMPatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,10 @@ class TJITGenericPatchNativeCall : public TJITGenericPatchObject
\brief This Macro makes it easy to replace code anywhere in ROM.
The original ARM command at the given address is replaced with a call into
native code. The 'C' code can immediatly follow the Macro. The function must
native code. The 'C' code can immediately follow the Macro. The function must
end in `return ioUnit;` if the next instruction is to be executed, or in
`return 0L;` if the PC changed and execution shall continue elsewhere.
Two prameters are available to the function: 'JITUnit* ioUnit' and
Two parameters are available to the function: 'JITUnit* ioUnit' and
'TARMProcessor* ioCPU'.
The sample code replaces this sequence that returns
Expand Down
18 changes: 13 additions & 5 deletions Emulator/Screen/TScreenManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,29 @@
// ==============================

//
// The original Newton MP2x00 is an LCD screen with 480x320 resolution, 16
// shades of gray, and a backlight. The resistive touchscreen is glued to the
// front of the display. The viewing area of the display is 129mm x 87mm.
// The screen diagonal is about 6.1 inches.
// The original Newton MP2x00 is a black and white LCD screen with 480x320
// resolution and a removable backlight. Screen data is stored at 16 shades of
// gray in memory. The DMA hardware displays those shades of gray by turning
// pixels on and off at various pulse widths and pattern.
// The resistive touchscreen is glued to the front of the display. The viewing
// area of the display is 129mm x 87mm.
// The screen diagonal is 156mm or 6.15 inches.
//
// Markings on the display are 4C112522AH52, LCDFAT650MC, an M650-LOA, 93 11 18
// LM48019K STN480X C, 97H00928 a, 5.4"
//
// The display data is sent via a AWM 2896 80C VW 1 flatband cable (20pin).
// The display data is sent via a AWM 2896 80C VW 1 flat ribbon cable (20pin).
// Backlight and touchscreen use additional wires.
//
// ??? Sharp LM5H40TA LQ057V3DG02, similar (same?) pinout
// SHARP 5.5 inch display panel recommendation:
// LS055R1SX04 LS055R1SX03 LS055T1SX01 LS055R3SX01 LQ055K3SX02 LQ055T3SX02 LS055R1SC01 LQ055T3SX03 LQ055T3SX02Z LM32C041 LS055T3SX05 LS055D1SX02 LS055R3SX01 (G) LM6Q32 LS055R1SX08 LS055T1SX01A LS055D1SX05(G) LM6Q401 LM32C04P LM6Q40A LQ055W1GC01 LS055T1SX10 LQ055T3SX02Z(G) LS055D1SX04 LS055T3SX13 LS055T3SX09 LQ055T3SX05 LS055T1SX13 LQ055W1GC01Z LM5H40TA LM5H40TB LM6Q31 LM6Q33 LM6Q35 LM6Q40 LQ055T1SX05 LQ055T3SX02(G) LS055T3SX01(G) LS055T1SX09
//
// 6 inch e-ink: ED060SC7 EPD ($28, Kindle 3 D009001 spare part)
// 6 inch e-ink: GDE060BA-T, GDE060BAFL-T (front light, touch), 600x800, 4:3,
// parallel port with 20+ data pins (cut to 14?!)
// 122.4x90.6mm active, 138.4x101.8 outline
//

#include "TScreenManager.h"

Expand Down
10 changes: 5 additions & 5 deletions Toolkit/TFLTerminalPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ TFLTile::TFLTile(int x, int y, int w, int h, const char* label) :
void
TFLTile::resize(int x, int y, int w, int h)
{
Fl_Widget* monitor = child(2);
int mh = monitor->h();
// Fl_Widget* monitor = child(2);
// int mh = monitor->h();
Fl_Tile::resize(x, y, w, h);
child(1)->resize(x, y, w, h - mh);
child(2)->resize(x, y + h - mh, w, mh);
init_sizes();
// child(1)->resize(x, y, w, h - mh);
// child(2)->resize(x, y + h - mh, w, mh);
// init_sizes();
}

// ============================================================================ //
Expand Down
33 changes: 17 additions & 16 deletions Toolkit/TFLToolkitUI.fl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ if (mi)
Function {CreateToolkitWindow(int x, int y)} {open
} {
Fl_Window wToolkitWindow {open
xywh {282 267 720 600} type Double resizable
xywh {408 471 720 600} type Double resizable
code0 {wToolkitWindow->position(x, y);} visible
} {
Fl_Menu_Bar wToolkitMenubar {open
Expand Down Expand Up @@ -174,7 +174,7 @@ Function {CreateToolkitWindow(int x, int y)} {open
}
MenuItem {} {
label {ROM Patcher}
callback {gToolkit->LoadSampleCode(4);} selected
callback {gToolkit->LoadSampleCode(4);}
xywh {40 40 100 20}
}
}
Expand Down Expand Up @@ -262,17 +262,16 @@ Function {CreateToolkitWindow(int x, int y)} {open
}
MenuItem {} {
label {Open Project...}
xywh {0 0 100 20} deactivate
}
MenuItem {} {
label {Decompile Package...}
callback {gToolkit->UserActionDecompilePkg();}
xywh {0 0 100 20}
xywh {0 0 100 20} deactivate divider
}
MenuItem {} {
label {Add File...}
xywh {0 0 100 20} deactivate
}
MenuItem {} {
label {Remove File}
xywh {0 0 100 20} deactivate divider
}
MenuItem {} {
label Build
callback {gToolkit->UserActionBuild();}
Expand All @@ -296,14 +295,14 @@ Function {CreateToolkitWindow(int x, int y)} {open
MenuItem {} {
label {Process Earlier}
callback {gToolkit->AppInstall();}
xywh {16 16 100 20} shortcut 0x400032 deactivate
xywh {16 16 100 20} shortcut 0xffbf deactivate
}
MenuItem {} {
label {Process Later}
callback {gToolkit->AppBuild();
gToolkit->AppInstall();
gToolkit->AppRun();}
xywh {16 16 100 20} shortcut 0x400072 deactivate divider
xywh {16 16 100 20} shortcut 0xffc0 deactivate divider
}
MenuItem {} {
label {Project Settings...}
Expand Down Expand Up @@ -624,6 +623,11 @@ gToolkit->AppRun();}
tkHelpDialog->show();}
xywh {12 12 100 20}
}
MenuItem {} {
label {Decompile Package...}
callback {gToolkit->UserActionDecompilePkg();}
xywh {0 0 100 20}
}
MenuItem {} {
label {About Toolkit...}
xywh {0 0 100 20} deactivate
Expand Down Expand Up @@ -711,7 +715,7 @@ tkHelpDialog->show();}
Fl_Button wToolkitFindHide {
label X
callback {gToolkit->UserActionFindHide();}
xywh {701 58 18 18} box FLAT_BOX down_box DOWN_BOX color 51 labelsize 11 hide
xywh {701 58 18 18} box FLAT_BOX down_box DOWN_BOX color 51 labelsize 11
}
Fl_Button wToolkitReplaceNext {
label Replace
Expand All @@ -728,11 +732,8 @@ tkHelpDialog->show();}
xywh {0 114 720 486} resizable
class TFLTile
} {
Fl_Box wTileResizable {
xywh {20 150 380 414} hide resizable
}
Fl_Group wScriptPanel {
xywh {0 114 720 386}
Fl_Group wScriptPanel {selected
xywh {0 114 720 386} resizable
class TFLScriptPanel
} {}
Fl_Text_Display wToolkitTerminal {
Expand Down
111 changes: 85 additions & 26 deletions Toolkit/TTkHelpText.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,112 @@ <h1>NewtonScript Extensions</h1>

<h2>Globals</h2>

<b>MakeBinaryFromString(str, sym)</b>: Generate a binary object from an ASCII string.
<br>
<b>MakeBinaryFromARM(ARM_Instructions)</b>: Generate a binary function from ARM assembler text.
Lines should be separated with \n characters.
<br>
<b>MakeBinaryFromARMFile(ARM_Assembler_Filename)</b>:
<br>
<b>PatchFileFromARM(ARM_Instructions, filename)</b>:
<br>
<b>AddStepForm(mainView, scrollClipper)</b>:
<br>
StepDeclare(mainView, scrollClipper, 'scrollClipper)</b>:
<br>
<b>MakeBinaryFromString(str, sym)</b>: Generate a binary object with the given
symbol from an Unicode text. The input format is UTF-8. The format of the binary
object is UTF-8 for newt/64, but it is converted to UTF-16 when written into
a 32 bit package or streaming package, and the symbol is <tt>'string</tt>.

<p>
<b>PatchFileFromARM(ARM_Instructions, filename)</b>: This global function
is a little helper for a very specific job. The first argument is a string
with ARM assembler instructions, usually starting with <tt>org address</tt> to
define the position in the binary. The second argument is the the file path and
name of an ARM binary, usually the NewtonOS ROM file. Calling
<tt>PatchFileFromARM</tt> will assemble and link the ARM code into ARM commends
and then overwrite the code in the ROM file with the new ARM code at the
given addresses.

<p>
<b>MakeBinaryFromARM(ARM_Instructions)</b>: Create the binary part of
a <tt>BinCFunction</tt> from ARM assembly code. Here, <tt>nativeMath</tt> and
<tt>newtonScriptMath</tt> are both functions that can be called from anywhere
in a script:
<p>
<pre>
nativeMath: {
class : 'BinCFunction,
numArgs: 2,
offset: 0,
code: MakeBinaryFromARM("
ldr r1, [r1] @ Unref the first argument
ldr r1, [r1] @ Get the integer object
mov r1, r1, lsr #2 @ convert it into an integer
ldr r2, [r2]
ldr r2, [r2] @ do the same with the second arg
mov r2, r2, lsr #2
add r0, r1, r2 @ add both integers
mov r0, r0, lsl #2 @ convert the result into an integer object
mov pc, lr @ return to the interpreter
")
}
// The same in Newton Script
newtonScriptMath: func(a, b) begin
return a+b;
end
</pre>

<p>
<b>MakeBinaryFromARMFile(ARM_Assembler_Filename)</b>: Same as above, but
instead of as string with ARM instructions, this call takes a file path and
name of an ARM assembler code file.

<p>
<b>AddStepForm(theParentView, myView)</b>: This is an original NTK function.
It ensures that the parent view has a frame named "StepChildren", and then
adds <tt>myView</tt> to that frame. This is needed to ensure that a new view
will appear as a child of the parent view when an app is opened.

<p>
<b>StepDeclare(theParentView, myView, 'myView)</b>: This is an original NTK
function. It ensures that the parent view has an array named
"StepAllocateContext", and the appends <tt>myView</tt> and the symbol
<tt>'myView</tt> to the array.

<p>
<b>_STDERR_</b>:
<br>

<p>
<b>_STDOUT_</b>:

<h2>FLTK extensions</h2>

<b>fltk:message(message)</b>: Open a message dialog box.
<br>

<p>
<b>fltk:choice(message, cancel_button, ok_button, opt_button)</b>:
Open a user choice dialog box and return the selected button id.
<br>

<p>
<b>fltk:filechooser(message, pattern, filename, relative)</b>:
Open a file chooser dialog. Returns filename or NIL.
<br>

<h2>Host File Access extensions</h2>

<b>file:new()</b>: Create a frame to access files on the host machine.
<br>

<p>
<b>file:open(filename, mode)</b>: Open a file, mode is 'read|'write|'readwrite|'append.
<br>

<p>
<b>file:isOpen()</b>: Returns nil or true.
<br>

<p>
<b>file:size()</b>: Returns file size in bytes.
<br>

<p>
<b>file:read(size)</b>: Read up to size bytes and return a binary object with the data.
<br>

<p>
<b>file:write(binaryObject)</b>: Write the content of a binary object to a file.
<br>

<p>
<b>file:seek(pos, mode)</b>: Set read position, mode is 'set|'cur|'end.
<br>

<p>
<b>file:tell()</b>: Return the current read position in the file.
<br>

<p>
<b>file:close()</b>: Closes a file, returns exception or true.
<br>

</body>
</html>
Loading

0 comments on commit 42b3785

Please sign in to comment.