Commit f05f81c7 authored by ROOL's avatar ROOL 🤖
Browse files

Fix RAM exhaustion with many fonts, and choices inversion

Detail:
  Line 1012 - Use the heap to claim/extend space for fonts. Fixes wimpslot problem with many installed fonts.
  Line 914-916 - Invert the choices file keywords to match the variables they set.
  Minor - Remove SWI constants, since the build system (Squish) gets these from swis.h. Don't listen for MESSAGE_HELPREPLY%. Change IconHandle to an integer. Use OS_ReadModeVariable to get eigenvalues since there's only 2 it's not worth constructing a list for OS_ReadVduVariables.
Admin:
  Submission from Chris Wraight, with minor edits.

Version 2.01. Tagged as 'Chars-2_01'
parent 3d0bd3a8
......@@ -11,13 +11,13 @@
GBLS Module_HelpVersion
GBLS Module_ComponentName
GBLS Module_ComponentPath
Module_MajorVersion SETS "2.00"
Module_Version SETA 200
Module_MajorVersion SETS "2.01"
Module_Version SETA 201
Module_MinorVersion SETS ""
Module_Date SETS "09 Jul 2016"
Module_ApplicationDate SETS "09-Jul-16"
Module_Date SETS "30 Jul 2016"
Module_ApplicationDate SETS "30-Jul-16"
Module_ComponentName SETS "Chars"
Module_ComponentPath SETS "castle/RiscOS/Sources/Apps/Chars"
Module_FullVersion SETS "2.00"
Module_HelpVersion SETS "2.00 (09 Jul 2016)"
Module_FullVersion SETS "2.01"
Module_HelpVersion SETS "2.01 (30 Jul 2016)"
END
/* (2.00)
/* (2.01)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 2.00
#define Module_MajorVersion_CMHG 2.01
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 09 Jul 2016
#define Module_Date_CMHG 30 Jul 2016
#define Module_MajorVersion "2.00"
#define Module_Version 200
#define Module_MajorVersion "2.01"
#define Module_Version 201
#define Module_MinorVersion ""
#define Module_Date "09 Jul 2016"
#define Module_Date "30 Jul 2016"
#define Module_ApplicationDate "09-Jul-16"
#define Module_ApplicationDate "30-Jul-16"
#define Module_ComponentName "Chars"
#define Module_ComponentPath "castle/RiscOS/Sources/Apps/Chars"
#define Module_FullVersion "2.00"
#define Module_HelpVersion "2.00 (09 Jul 2016)"
#define Module_LibraryVersionInfo "2:0"
#define Module_FullVersion "2.01"
#define Module_HelpVersion "2.01 (30 Jul 2016)"
#define Module_LibraryVersionInfo "2:1"
......@@ -69,8 +69,6 @@ WIN_TOOLBAR%=128 :REM Height of window toolbar
WIN_SMALL%=-360 :REM Height of smallest viewer pane
WIN_WIDTH%=926 :REM Width of viewer pane
WIN_MARGIN%=12 :REM Margin for window contents
XFONT_PAINT%=&60086 :REM SWI constants
XFONT_SCANSTR%=&600A1 :REM SWI constants
REM Buffers for SWIs
DIM Block% 255 :REM General purpose buffer
......@@ -94,10 +92,6 @@ REM GUI/window redrawing
FirstOpen%=TRUE :REM First-time open flag
WasDown%=0:IsDown%=0 :REM Flags to indicate Shift pressed
OldChar%=0: :REM Old selected character
DIM InputVars 3*4-1,OutputVars 2*4-1 :REM Screen Eigen factors
InputVars!0=4
InputVars!4=5
InputVars!8=-1
XEig%=0:YEig%=0 :REM Screen Eigen factors
REM Start-up options
......@@ -110,7 +104,6 @@ IF UCSManager% THEN
REM Global variables and storage
FONT_INVALID%=&FFFFFFFF :REM Invalid Unicode character
FONT_ENUMCHARS%=&400A9 :REM SWI constant
UCSNames%=FALSE :REM A UCS names file can be found
Lookup%=FALSE :REM Ptr to storage for Lookup table
MaxChars%=0 :REM Number of chars in display category
......@@ -604,7 +597,7 @@ FOR cat%=1 TO Category%(0,0)
code%=Category%(0,cat%)
tcode%=Category%(1,cat%)
REPEAT
SYS FONT_ENUMCHARS%,FontHandle%,code% TO ,next%,intcode%
SYS "Font_EnumerateCharacters",FontHandle%,code% TO ,next%,intcode%
IF intcode%>-1 THEN
chars%+=1
IF chars%*3 > total% THEN
......@@ -813,9 +806,9 @@ WHILE more%
ENDCASE
REM Centre the character and paint it
SYS XFONT_SCANSTR%,,CharDef%,ssflags%,1000000,1000000,,,4 TO e%,,,width%;flags%
SYS "XFont_ScanString",,CharDef%,ssflags%,1000000,1000000,,,4 TO e%,,,width%;flags%
IF flags% AND 1 THEN PROCchars_fonterror("FontErr5"):ENDPROC
SYS XFONT_PAINT%,,CharDef%,fpflags%,cx%-(width% DIV 800)+(CHAR_XBOX% DIV 2),cy% TO e%;flags%
SYS "XFont_Paint",,CharDef%,fpflags%,cx%-(width% DIV 800)+(CHAR_XBOX% DIV 2),cy% TO e%;flags%
IF flags% AND 1 THEN PROCchars_fonterror("FontErr6"):ENDPROC
cx%+=CHAR_XBOX%
IF cx%>xlimit% THEN cx%=xorigin%:cy%-=CHAR_YBOX%
......@@ -908,9 +901,9 @@ CASE icon% OF
BPUT#file%,"| Choices file for Chars"
BPUT#file%,""
IF Option_Open% THEN val$="Yes" ELSE val$="No"
BPUT#file%,"DesktopFont:"+val$
IF Option_DesktopFont% THEN val$="Yes" ELSE val$="No"
BPUT#file%,"Open:"+val$
IF Option_DesktopFont% THEN val$="Yes" ELSE val$="No"
BPUT#file%,"DesktopFont:"+val$
CLOSE#file%
IF button%=4 THEN Block%!0=ChoiceWin%:SYS "Wimp_CloseWindow",,Block%
ENDCASE
......@@ -961,9 +954,8 @@ MESSAGE_SAVEDESKTOP%=&A :REM Message constants
REM Initialise application
Block%!0=MESSAGE_SAVEDESKTOP%
Block%!4=MESSAGE_HELPREQUEST%
Block%!8=MESSAGE_HELPREPLY%
Block%!12=MESSAGE_MODECHANGE%
Block%!16=MESSAGE_QUIT%
Block%!8=MESSAGE_MODECHANGE%
Block%!12=MESSAGE_QUIT%
SYS "Wimp_Initialise",310,&4B534154,FNmsg_get("_TaskName"),Block% TO WimpVersion%,TaskHandle%
REM Wimp-based Error handling
......@@ -980,7 +972,7 @@ SYS "Wimp_CloseTemplate"
REM Create iconbar icon and update version in Info
Block%!0=-1:Block%!4=0:Block%!8=0:Block%!12=68:Block%!16=68
Block%!20=&3002:$(Block%+24)=FNmsg_get("ErrApp")
SYS "Wimp_CreateIcon",,Block% TO IconHandle
SYS "Wimp_CreateIcon",,Block% TO IconHandle%
PROCwimp_seticontext(InfoWin%,4,FNmsg_get("_Version"))
REM Create Iconbar menu
......@@ -1006,8 +998,10 @@ ENDIF
REM Create Font menu
SYS "Font_ListFonts",,0,7<<19,,0,,0 TO ,,,size%,,indsize%
DIM FontMenu% size%
DIM FontInd% indsize%
FontMenu%=FNheap_newblock(size%)
IF HeapError% THEN PROCwimp_error(FNmsg_get("Fatal2"))
FontInd%=FNheap_newblock(indsize%)
IF HeapError% THEN PROCwimp_error(FNmsg_get("Fatal2"))
FontBuffer%=size%
REM Create Encodings menu
......@@ -1322,8 +1316,8 @@ ENDPROC
DEF PROCwimp_getmodeinfo
REM Read current screen mode information
SYS "OS_ReadVduVariables",InputVars,OutputVars
XEig%=OutputVars!0:YEig%=OutputVars!4
SYS "OS_ReadModeVariable",-1,4 TO,,XEig%
SYS "OS_ReadModeVariable",-1,5 TO,,YEig%
ENDPROC
DEF PROCwimp_error (cause$)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment