View Single Post
Old 04-28-2017, 05:35 AM   #47
GeoffR
Wizard
GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.GeoffR ought to be getting tired of karma fortunes by now.
 
GeoffR's Avatar
 
Posts: 3,821
Karma: 19162882
Join Date: Nov 2012
Location: Te Riu-a-Māui
Device: Kobo Glo
My new laptop arrived and is all set up. I now have a dual-boot Debian 8 / Windows 7 setup, so I will be able to test things on an actual Windows system instead of just in Wine.

I've attached an updated patch_kobo_4039084.zip that includes the missing libnickel.so.1.0.0 patches from 4.3.8966, an updated `Force user line spacing in KePubs` patch that should work with more books, and an updated 4.3.9084.sh script which should give a more useful error message if the downloaded firmware is missing or corrupt.

Thank you Oren for doing the rest of the patches. I'll start a thread sometime soon and try to explain how I update those patches which make changes to function calls, such as `Freedom to advanced fonts control`.

Here are the missing/updated patches for those who want to update libnickel.so.1.0.0 via copy/paste instead of downloading the zip:

`My 24 line spacing values`
Spoiler:
Code:
<Patch>
patch_name = `My 24 line spacing values` 
patch_enable = `no`
# patch_group = `Line spacing values alternatives`
#
## This patch changes the values on the line spacing adjustment slider,
## increasing the number of spacing options from 15 to 24, and allowing
## much narrower spacing values to be set.
#
# save r5, initialise loop counter
replace_bytes = 611D98, 71 4B C7 E9 02 23, BD 60 00 25 ED 00
# loop to load 14 vals from new table 4e36bc
replace_bytes = 611D9E, D1 F6 28 ED 5B A3, 20 46 03 A1 29 44
replace_bytes = 611DA4, D3 E9 00 23, D1 F6 24 ED
replace_bytes = 611DA8, 07 F1 80 01 20 46, 08 35 70 2D F7 D1
# jump over new table
replace_bytes = 611DAE, 61 E9, 78 E0
# new table: 14 8-aligned doubles
base_address = 611DB0
replace_bytes = 0000, 1C 23 D1 F6 1E ED 58 A3, 00 00 00 00 00 00 F0 3F
replace_bytes = 0008, D3 E9 00 23 07 F1 80 01, 00 00 00 00 00 00 F0 3F
replace_bytes = 0010, 20 46 61 E9 1A 23 D1 F6, 00 00 00 00 00 00 F0 3F
replace_bytes = 0018, 14 ED 55 A3 D3 E9 00 23, 00 00 00 00 00 00 F0 3F
replace_bytes = 0020, 07 F1 80 01 20 46 61 E9, 00 00 00 00 00 00 F0 3F
replace_bytes = 0028, 18 23 D1 F6 0A ED 61 4B, 00 00 00 00 00 00 F0 3F
replace_bytes = 0030, 07 F1 80 01 4F F0 33 32, 00 00 00 00 00 00 F0 3F
replace_bytes = 0038, 20 46 61 E9 16 23 D1 F6, 00 00 00 00 00 00 F0 3F
replace_bytes = 0040, 00 ED 4D A3 D3 E9 00 23, 00 00 00 00 00 00 F0 3F
replace_bytes = 0048, 07 F1 80 01 20 46 61 E9, 00 00 00 00 00 00 F0 3F
replace_bytes = 0050, 14 23 D1 F6 F6 EC 58 4B, 00 00 00 00 00 00 F0 3F
replace_bytes = 0058, 07 F1 80 01 00 22 20 46, 00 00 00 00 00 00 F0 3F
replace_bytes = 0060, 61 E9 12 23 D1 F6 EC EC, 00 00 00 00 00 00 F0 3F
replace_bytes = 0068, 45 A3 D3 E9 00 23 07 F1, 00 00 00 00 00 00 F0 3F
base_address = 00000000
# initialise loop counter
replace_bytes = 611EA0, D1 F6 A6 EC, 00 BF 00 25
# loop to load 10 vals from old table
replace_bytes = 611EA4, 31 4B 07 F1 80 01, 20 46 1A A1 29 44
replace_bytes = 611EAA, 00 22 20 46, D1 F6 A2 EC
replace_bytes = 611EAE, 61 E9 02 23 D1 F6, 08 35 50 2D F7 D1
# restore r5
replace_bytes = 611EB4, 9E EC, BD 68
# continue at 611EB6
#
#
# Replacement value: the number of initial line spacing values to exclude from
# the line spacing slider; minimum 0, maximum 13. E.g. 9 will result in a
# slider with 15 positions, starting from the 10th replace_float value below.
replace_int = 611D9A, 0, 0
#
# 24 replacement line spacing values: change these replace_float values to suit
# your device and preferences:
#
base_address = 611DB0
replace_float = 0000, 1.0, 0.75
replace_float = 0008, 1.0, 0.78
replace_float = 0010, 1.0, 0.8
replace_float = 0018, 1.0, 0.82
replace_float = 0020, 1.0, 0.84
replace_float = 0028, 1.0, 0.86
replace_float = 0030, 1.0, 0.88
replace_float = 0038, 1.0, 0.9
replace_float = 0040, 1.0, 0.92
replace_float = 0048, 1.0, 0.94
replace_float = 0050, 1.0, 0.96
replace_float = 0058, 1.0, 0.98
replace_float = 0060, 1.0, 1.0
replace_float = 0068, 1.0, 1.02
base_address = 611F10
replace_float = 0000, 1.05, 1.05
replace_float = 0008, 1.07, 1.07
replace_float = 0010, 1.1, 1.1
replace_float = 0018, 1.35, 1.15
replace_float = 0020, 1.7, 1.2
replace_float = 0028, 1.8, 1.25
replace_float = 0030, 2.2, 1.3
replace_float = 0038, 2.4, 1.35
replace_float = 0040, 2.6, 1.4
replace_float = 0048, 2.8, 1.5
#
# The first 14 replacement values above should allow the line spacing to be
# adjusted in increments of one pixel when using a medium sized font on a high
# resolution device. If you use a smaller font size and/or a lower resolution
# device you might find that increasing the slider one step at a time doesn't
# always result in a line spacing increase at each step. In that case, you
# might want to use replacement values that are not quite so close together.
#
# For example: (I use these values on my 758x1024 Glo)
#
#  0.7 0.725 0.75 0.775 0.8 0.825 0.85 0.875 0.9 0.925 0.95 0.975 1.0 1.025 ...
#
# or: (these might better suit the 600x800 Touch)
#
#  0.6 0.633 0.667 0.7 0.733 0.767 0.8 0.833 0.867 9.0 9.33 9.67 1.0 1.025 ...
#
</patch>


`Freedom to advanced fonts control`
Spoiler:
Code:
<Patch>
patch_name = `Freedom to advanced fonts control`
patch_enable = `no`
#
## This patch allows the advanced font options (weight/sharpness adjustments)
## to work with sideloaded fonts too. (KEPUB: OTF and TTF. EPUB: TTF only.)
##
## WARNING: THIS PATCH MIGHT HAVE SOME SIDE-EFFECTS IF YOUR DEVICE IS SET TO
## A JAPANESE LOCALE OR JAPANESE LANGUAGE BOOKS ARE OPENED.
#
# VolumeManager.isJapanese(a) --> False
replace_bytes = 6102FE, C0 F6 0C EC, 00 20 00 20
# N3FontTypeUtil.setupMonotypeDropdown(b,c)
# --> N3FontTypeUtil.setupDropdown(UNDEFINED,b,c)
replace_bytes = 6DD39C, 50 46 31 46, 51 46 32 46
replace_bytes = 6DD3A0, E9 F5 82 EA, 06 F6 86 E9
# N3FontTypeController.setupAdvancedOption(...) --> NOP
replace_bytes = 78BB7E, 72 F5 BA EB, 00 46 00 46
replace_bytes = 78BD88, 72 F5 B4 EA, 00 46 00 46
</Patch>


`Allow download all in Browser`
Spoiler:
Code:
<Patch>
patch_name = `Allow download all in Browser`
patch_enable = `no`
#
## Allow the browser to download any file, not just the types it recognises.
#
replace_bytes = 7002DA, FB F5 08 E9, 01 20 01 20
</Patch>


`ePub fixed/adjustable top/bottom margins`
Spoiler:
Code:
<Patch>
patch_name = `ePub fixed/adjustable top/bottom margins`
patch_enable = `no`
# patch_group = `ePub padding-bottom alternatives`
#
## This patch sets the @page margin sizes in epubs, overriding any @page margin
## set in the book's CSS stylesheet (but not in the XPGT stylesheet, see below).
##
## By default the top and bottom margins are set to be adjustable, their size
## similar to the left/right margin size set by the adjustment slider. There
## are options to set the top and/or bottom margin to a fixed size instead.
##
## Note that @page margins are seperate from (and overlap) both the body margins
## set in the book and the left/right margins set from the adjustment slider,
## and are added to any page margins set in the Adobe XPGT stylesheet if the
## book has one (e.g. page-template.xpgt). For this reason you might want to
## consider using the Modify ePub Calibre plugin to remove any body margins and
## XPGT stylesheet margins before sideloading the book, or perhaps enabling the
## `Ignore ePub Adobe XPGT stylesheet (page-template.xpgt)` patch.
##
## Also note that a side-effect of this patch is that the body padding-bottom is
## removed from the built-in stylesheet, which means that there will no longer
## be a blank line added automatically at the end of chapters.
##
## See at the bottom of the patch for replacement values that can be used to
## tune the size of the margins to suit different devices and reading modes.
#
#
# Push an extra 8 bytes of scratch space onto the stack
replace_bytes = 534168, B7 B0, B9 B0
replace_bytes = 53416C, 02 AF, 04 AF
# Save this value for the third stack argument of the following function call
replace_bytes = 5343E8, AD F8 04 30, 02 93 01 93
# getReadingLineHeight(...) --> getReadingLeftMargin(...)
replace_bytes = 53441A, CD F7 96 EC, A7 F7 F0 ED
# (Setup call to QString.arg)
replace_bytes = 53441E, 4F F0 FF 33 07 F1, 00 23 01 22 0A 21
replace_bytes = 534424, 3C 0A 00 93, 00 93 01 91
replace_bytes = 534428, 20 23 AD F8 04 30, 42 43 92 08 01 3A
replace_bytes = 53442E, 50 46 21 46, B8 BF 00 22
replace_bytes = 534432, 00 22 67 23, 13 A8 21 46
# QString.arg(double, ...) --> QString.arg(int64, ...)
replace_bytes = 534436, B5 F7 1E ED, A7 F7 66 E8
#
# (There wasn't room to load sl above)
# mov r1,sl; --> adds r1,sp,#76
replace_bytes = 53443C, 51 46, 13 A9
# mov r0,sl; --> adds r0,sp,#76
replace_bytes = 534442, 50 46, 13 A8
# (Remember to pop scratch space if necessary)
#
#      padding-bottom: %1em !important;\n
# --> }@page{margin:%1px 00px %1px}body{
find_base_address = `\x20\0p\0a\0d\0d\0i\0n\0g\0-\0b\0o\0t\0t\0o\0m\0:\0 \0%\01\0e\0m\0 \0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0;\0\n\0`
replace_string = 0000, `\x20\0p\0a\0d\0d\0i\0n\0g\0-\0b\0o\0t\0t\0o\0m\0:\0 \0%\01\0e\0m\0 \0!\0i\0m\0p\0o\0r\0t\0a\0n\0t\0;\0\n\0`, `}\0@\0p\0a\0g\0e\0{\0m\0a\0r\0g\0i\0n\0:\0%\01\0p\0x\0 \00\00\0p\0x\0 \0%\01\0p\0x\0}\0b\0o\0d\0y\0{\0`
#
#
# *** Replacement values start here, don't change anything above ***
#
# Optional replacement value: Uncomment for a FIXED TOP MARGIN size in px,
# default 25px. Replacement value is margin size, two digits separated by \0
# (Leave commented out for an adjustable top margin.)
#replace_string = 001C, `%\01`, `2\05`
#
# Optional replacement value: Uncomment for a FIXED BOTTOM MARGIN size in px,
# default 00px. Replacement value is margin size, two digits separated by \0
# (Leave commented out for an adjustable bottom margin.)
#replace_string = 0030, `%\01`, `0\00`
#
# Optional replacement value: Uncomment to set the minimum LEFT/RIGHT MARGIN
# size in px, default 15px. (This margin will overlap the left/right margin
# set with the adjustment slider, not add to it.) Replacement value is margin
# size, two digits separated by \0
#replace_string = 0026, `0\00`, `1\05`
#
base_address = 000000
# Replacement value: Sets the step-size of the ADJUSTABLE top/bottom margin
# (if any) in quarter-pixels. These suggested values should be very close to
# the 1% step size of the left/right margins set by the slider. Larger values
# will make the top/bottom margins larger than the left/right margins.
# Suggested values:
#   24 (Touch/Mini), 30 (Glo/Aura/Aura2ed), 43 (AuraHD/H2O/GloHD), 56 (Aura One)
replace_int = 534420, 1, 30
#
# Replacement value: Set this to the size of the device's built-in top margin,
# in pixels. This value is subtracted from the adjustable top/bottom margin
# (if any) to compensate for any unremovable built-in top margin.
# Suggested values are:
#   0 For full-screen reading mode (fullScreenReading=true, all devices)
#  15 for normal reading mode (with custom or disabled footer, all devices)
replace_int = 53442C, 1, 0
</Patch>


`Set KePub hyphenation`
Spoiler:
Code:
<Patch>
patch_name = `Set KePub hyphenation`
patch_enable = `no`
#
## The built-in KePub stylesheet has a line "* { -webkit-hyphens: auto; }"
## to turn on hyphenation, but it is only used if the device's justification
## button is set to full justification. With this patch enabled hyphenation
## will always be turned on, regardless of justification button setting.
##
## (The publisher can still turn hyphenation off/on in the book's stylesheet.)
#
# Alternative 1: Always turn KePub hyphenation on
replace_bytes = 7C43AA, 29 F5 42 EE, 01 20 01 20
#
# Alternative 2: Never turn KePub hyphenation on
#replace_bytes = 7C43AA, 29 F5 42 EE, 00 20 00 20
</Patch>


`Always display chapter name on navigation menu`
Spoiler:
Code:
<Patch>
patch_name = `Always display chapter name on navigation menu`
patch_enable = `no`
#
## Normally the <-> navigation menu only displays the current chapter name if
## [Reading settings > Display progress for:] is set to 'Current Chapter'.
## This patch causes the current chapter name to be displayed if 'Entire book'
## progress is selected as well. Works for both ePub and KePub books.
#
# in ReadingMenuScrubberController::setChapterAndProgressText(...)
#  progressTypeIsBookBased(...) --> False
replace_bytes = 795EE4, 50 F5 28 E9, 00 20 00 20
</Patch>


`Force user line spacing in KePubs` (updated to more forceful version)
Spoiler:
Code:
<Patch>
patch_name = `Force user line spacing in KePubs`
patch_enable = `no`
#
## This patch will allow the line spacing set by the slider to take effect
## in some problem KePub books with fixed linespacing (including ones where the
## publisher has used <div> instead of <p> for paragraphs, or wrapped each
## paragraph in a <span> and set the line-height on the span.) However it might
## also override some line spacing that would better be left fixed, e.g. it can
## cause problems with the spacing of paragraphs that begin with a raise-cap.
#
# body, p { line-height: %1 ... }  -->  body *  { line-height: %1 ... }
#
#strings -tx -el libnickel.so.1.0.0 | grep "body, p { line-height: %1"
base_address = 99FFA0
#base_address = 9A6220
replace_string = 0000, `b\0o\0d\0y\0,\0 \0p\0 \0{\0`, `b\0o\0d\0y\0 \0*\0 \0 \0{\0`
#
# Option: Comment out the replace_string line above and uncomment the one below
# for a less forceful version of this patch.
#
# body, p { line-height: %1 ... }  -->  body,div,p{line-height:%1 ... }
#
#replace_string = 0000, `b\0o\0d\0y\0,\0 \0p\0 \0{\0 \0l\0i\0n\0e\0-\0h\0e\0i\0g\0h\0t\0:\0 \0%`, `b\0o\0d\0y\0,\0d\0i\0v\0,\0p\0{\0l\0i\0n\0e\0-\0h\0e\0i\0g\0h\0t\0:\0%`
</Patch>
Attached Files
File Type: zip patch_kobo_4039084.zip (501.6 KB, 367 views)
GeoffR is offline   Reply With Quote