gdxapp4d/gdxapp4d-lib-unicodezd/src/main/java/love/distributedrebirth/unicode4d/CodePointᶻᴰ.java
2022-11-28 01:12:22 +01:00

140 lines
6.7 KiB
Java

/*
* Copyright ©Δ∞ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.unicode4d;
import java.util.List;
import ᒢᐩᐩ.ᒡᒢᑊᒻᒻᓫᔿ.ᣳᣝᐤᣜᣳ.ᐪᓫᣗᔿᑊᣕᣔᐪᐤᣗ.T002ᖟ;
import ᒢᐩᐩ.ᒡᒢᑊᒻᒻᓫᔿ.ᣳᣝᐤᣜᣳ.ᒢᓫᑊᐣᑊ.ᔿᓫᒻᓫᓫ.V036Teger;
import ᒢᐩᐩ.ᒡᒢᑊᒻᒻᓫᔿ.ᣳᣝᐤᣜᣳ.ᒢᓫᑊᐣᑊ.ᔿᓫᒻᓫᓫ.V072Tong;
import ᒢᐩᐩ.ᔆʸᔆᐪᓫᔿ.ᒃᣔᒃᓫᒻ.ᑊᐣᓑᖮᐪᔆ.DuytsDocAuthor注;
@DuytsDocAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
public enum CodePointᶻᴰ {
INSTANCE;
private static final int MASK_CMD = 0b111000000000000000;
private static final int MASK_SIGN = 0b000100000000000000;
private static final int MASK_ARGU = 0b000011111111111111;
public static final int MODIFIER_STRIKE_HIGH = 0b000000000000000001;
public static final int MODIFIER_STRIKE_MID = 0b000000000000000010;
public static final int MODIFIER_STRIKE_LOW = 0b000000000000000100;
public static final int MODIFIER_STRIKE_UNDER = 0b000000000000001000;
public static final int MODIFIER_ITALIC_LR = 0b000000000000010000;
public static final int MODIFIER_ITALIC_RL = 0b000000000000100000;
public static final int MODIFIER_SCRIPT_TOP = 0b000000000001000000;
public static final int MODIFIER_SCRIPT_SUB = 0b000000000010000000;
public static final int MODIFIER_ENVELOP = 0b000000000100000000;
public int getArgument(V036Teger teger, T002ᖟ part) {
int value = teger.partᗅᗷᗷᗅ(part).getNativeValue();
int result = value & MASK_ARGU;
if ((value & MASK_SIGN) != 0) {
result |= 0xFFFFC000;
}
return result;
}
public void setArgument(V036Teger teger, T002ᖟ part, int number) {
int value = teger.partᗅᗷᗷᗅ(part).getNativeValue();
int result = (value & MASK_CMD) + ((number >> 17) & MASK_SIGN) + (number & MASK_ARGU);
teger.partᗅᗷᗷᗅ(part).setNativeValue(result);
}
public int getArgumentUnicode(V036Teger teger) {
int unicode = 0;
unicode += teger.partᗅᗷᗷᗅ(T002ᖟ.PART_1).getNativeValue() & MASK_ARGU+MASK_SIGN;
unicode += (teger.partᗅᗷᗷᗅ(T002ᖟ.PART_2).getNativeValue() & MASK_ARGU+MASK_SIGN) << 15;
return unicode;
}
public void setArgumentUnicode(V036Teger teger, int unicode) {
int value1 = teger.partᗅᗷᗷᗅ(T002ᖟ.PART_1).getNativeValue();
int value2 = teger.partᗅᗷᗷᗅ(T002ᖟ.PART_2).getNativeValue();
value1 = (value1 & MASK_CMD) + (unicode & MASK_ARGU+MASK_SIGN);
value2 = (value2 & MASK_CMD) + ((unicode >> 15) & MASK_ARGU+MASK_SIGN);
teger.partᗅᗷᗷᗅ(T002ᖟ.PART_1).setNativeValue(value1);
teger.partᗅᗷᗷᗅ(T002ᖟ.PART_2).setNativeValue(value2);
}
public CodePointCommandᶻᴰ getCommand(V036Teger teger) {
int mode = 0;
mode += (teger.partᗅᗷᗷᗅ(T002ᖟ.PART_1).getNativeValue() >> 15) << 0;
mode += (teger.partᗅᗷᗷᗅ(T002ᖟ.PART_2).getNativeValue() >> 15) << 3;
return CodePointCommandᶻᴰ.values()[mode];
}
public void setCommand(V036Teger teger, CodePointCommandᶻᴰ command) {
int mode = command.ordinal();
int value1 = teger.partᗅᗷᗷᗅ(T002ᖟ.PART_1).getNativeValue();
int value2 = teger.partᗅᗷᗷᗅ(T002ᖟ.PART_2).getNativeValue();
teger.partᗅᗷᗷᗅ(T002ᖟ.PART_1).setNativeValue(value1 | (((mode >> 0) << 15)) & MASK_CMD);
teger.partᗅᗷᗷᗅ(T002ᖟ.PART_2).setNativeValue(value2 | (((mode >> 3) << 15)) & MASK_CMD);
}
/**
* Provides legacy access to the unicode number definition.
*/
public int searchUnicode(List<V072Tong> tongs) {
for (V072Tong tong:tongs) {
if (CodePointCommandᶻᴰ.UNICODE.equals(CodePointᶻᴰ.INSTANCE.getCommand(tong.partᗅᗷᗷᗅ(T002ᖟ.PART_1)))) {
return CodePointᶻᴰ.INSTANCE.getArgumentUnicode(tong.partᗅᗷᗷᗅ(T002ᖟ.PART_1));
}
if (CodePointCommandᶻᴰ.UNICODE.equals(CodePointᶻᴰ.INSTANCE.getCommand(tong.partᗅᗷᗷᗅ(T002ᖟ.PART_2)))) {
return CodePointᶻᴰ.INSTANCE.getArgumentUnicode(tong.partᗅᗷᗷᗅ(T002ᖟ.PART_2));
}
}
return -1;
}
/**
* Provides number access so that 0123456789 is equal in all languages/fonts.
* TODO: Add support for the other number ranges to like: base10,base16,base27,etc.
*/
public int searchNumber(List<V072Tong> tongs) {
for (V072Tong tong:tongs) {
if (CodePointCommandᶻᴰ.NUMBER.equals(CodePointᶻᴰ.INSTANCE.getCommand(tong.partᗅᗷᗷᗅ(T002ᖟ.PART_1)))) {
return CodePointᶻᴰ.INSTANCE.getArgumentUnicode(tong.partᗅᗷᗷᗅ(T002ᖟ.PART_1));
}
if (CodePointCommandᶻᴰ.NUMBER.equals(CodePointᶻᴰ.INSTANCE.getCommand(tong.partᗅᗷᗷᗅ(T002ᖟ.PART_2)))) {
return CodePointᶻᴰ.INSTANCE.getArgumentUnicode(tong.partᗅᗷᗷᗅ(T002ᖟ.PART_2));
}
}
return -1;
}
/**
* Provides access to vocal tone expression, so "A" and "a" and many other "a"'s have an equal tone expression.
* TODO: And add support for invisible voice glue letters/commands so text-to-speech is correct.
*/
public int searchVocalTone(List<V072Tong> tongs) {
return -1;
}
}