Skip to content

Commit

Permalink
Revert Zebra improvements from panstromek and ndk 23
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Murawski committed Dec 2, 2023
1 parent 13e3984 commit fc03884
Show file tree
Hide file tree
Showing 26 changed files with 183 additions and 597 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: ndk
uses: nttld/[email protected]
with:
ndk-version: r23
ndk-version: r21e
- name: set up JDK 17
uses: actions/setup-java@v3
with:
Expand Down Expand Up @@ -68,6 +68,6 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
ndk: 23.1.7779620
ndk: 21.4.7075529
script: ./gradlew connectedCheck

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: ndk
uses: nttld/[email protected]
with:
ndk-version: r23
ndk-version: r21e
- name: set up JDK 17
uses: actions/setup-java@v3
with:
Expand Down
3 changes: 1 addition & 2 deletions project/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ android {
resources {
excludes += ['META-INF/DEPENDENCIES', 'META-INF/LICENSE', 'META-INF/LICENSE.txt', 'META-INF/license.txt', 'META-INF/NOTICE', 'META-INF/NOTICE.txt', 'META-INF/notice.txt', 'META-INF/ASL2.0', 'README.txt']
}
jniLibs.useLegacyPackaging = false
}

ndkVersion "23.1.7779620"
ndkVersion "21.4.7075529"

externalNativeBuild {
ndkBuild {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,6 @@ public void testCrash3() throws InterruptedException {

}

@Test
public void testCrash4() throws InterruptedException {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_TEXT, "D3C3C4C5B4E3E2D2C6B3B5C2E1C1A3A6A5A4A7B2F4F5D6F3F2E6G4G5G3H4F6G6H3H2H7G1F1D1H5H6H1B6C7F7F8D7");

zebra.runOnUiThread(() -> zebra.onNewIntent(intent));

Thread.sleep(2000);
zebra.runOnUiThread(() -> zebra.undoAll());
Thread.sleep(10000);

}


}
339 changes: 0 additions & 339 deletions project/src/main/jni/zebra/LICENSE

This file was deleted.

19 changes: 10 additions & 9 deletions project/src/main/jni/zebra/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ SRCS = \
thordb.c \
timer.c \
unflip.c
# bitbvald.c

HEADERS = \
autoplay.h \
Expand Down Expand Up @@ -84,6 +85,7 @@ HEADERS = \
thordb.h \
timer.h \
unflip.h
# bitbvald.h


BOOKTOOL_SRCS = $(SRCS) booktool.c
Expand All @@ -103,7 +105,6 @@ PRACTICE_EXE = practice
ENDDEV_EXE = enddev
ZEBRA_EXE = zebra
SCRZEBRA_EXE = scrzebra
TUNE8DBS_EXE = tune8dbs



Expand All @@ -122,11 +123,14 @@ CXX = g++

# --- Flags ---

DEFS = -DINCLUDE_BOOKTOOL -DTEXT_BASED -DZLIB_STATIC
DEFS = -DINCLUDE_BOOKTOOL -DTEXT_BASED -DUSE_PENTIUM_ASM -DZLIB_STATIC
#DEFS = -DUSE_PENTIUM_ASM -DZLIB_STATIC

WARNINGS = -Wall -Wcast-align -Wwrite-strings -Wstrict-prototypes -Winline
OPTS = -O4 -s -fomit-frame-pointer -falign-functions=32
#OPTS = -O4 -s -fomit-frame-pointer -mtune=core2 -falign-functions=32
#OPTS = -O2 -s -fomit-frame-pointer -march=pentium -malign-functions=6 -fschedule-insns2
OPTS = -O4 -s -fomit-frame-pointer -mtune=pentium2 -falign-functions=32
#OPTS = -O4 -pg -mtune=pentium2 -falign-functions=32
#OPTS = -O4 -g -mtune=pentium2

CFLAGS = $(OPTS) $(WARNINGS) $(DEFS)
CXXFLAGS = $(CFLAGS)
Expand All @@ -150,10 +154,7 @@ libzebra.a: $(OBJS)
clean :
$(RM) $(OBJS) booktool.o zebra.o scrzebra.o $(ZEBRA_EXE) a.out core \
*.stackdump gmon.out $(PRACTICE_OBJS) $(PRACTICE_EXE) \
libzebra.a *.da autop.o \
$(BOOKTOOL_OBJS) $(ENDDEV_OBJS) \
$(AUTOPLAY_EXE) $(BOOKTOOL_EXE) $(ENDDEV_EXE) $(SCRZEBRA_EXE) $(TUNE8DBS_EXE) \

libzebra.a *.da

booktool : $(OBJS) $(BOOKTOOL_OBJS) autop.o
$(CC) -o $(BOOKTOOL_EXE) $(CFLAGS) $(BOOKTOOL_OBJS) autop.o $(LDFLAGS)
Expand All @@ -173,7 +174,7 @@ bookinst:
$(CC) -o bookinst $(CFLAGS) bookinst.c myrandom.o

tune8dbs:
$(CC) -o $(TUNE8DBS_EXE) $(CFLAGS) tune8dbs.c $(LDFLAGS)
$(CC) -o tune8dbs $(CFLAGS) tune8dbs.c $(LDFLAGS)

genbb: genbb.o
$(CC) -o genbb genbb.o
Expand Down
35 changes: 0 additions & 35 deletions project/src/main/jni/zebra/README.md

This file was deleted.

52 changes: 26 additions & 26 deletions project/src/main/jni/zebra/bitbtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,15 @@ static const unsigned int high_flip[56] = {
#define bbFlips_Right_low(pos, mask) \
contig = right_contiguous[(opp_bits_low >> (pos + 1)) & mask]; \
fl = right_flip[contig] << (pos + 1); \
t = ((int)(-(unsigned int)(my_bits_low & fl))) >> 31u; \
t = -(int)(my_bits_low & fl) >> 31; \
my_bits_low |= fl & t; \
flipped = contig & t
#endif

#define bbFlips_Right_high(pos, mask) \
contig = right_contiguous[(opp_bits_high >> (pos + 1u)) & mask]; \
fl = right_flip[contig] << (pos + 1u); \
t = ((int)(-(unsigned int)(my_bits_high & fl))) >> 31u; \
contig = right_contiguous[(opp_bits_high >> (pos + 1)) & mask]; \
fl = right_flip[contig] << (pos + 1); \
t = -(int)(my_bits_high & fl) >> 31; \
my_bits_high |= fl & t; \
flipped = contig & t

Expand Down Expand Up @@ -544,22 +544,22 @@ static const unsigned int high_flip[56] = {


#define bbFlips_Down_2_3(pos, vec, maskh) \
if (opp_bits_low & (1u << (pos + vec))) { \
if (opp_bits_low & (1u << (pos + vec * 2u))) { \
t = (opp_bits_high >> (pos + vec * 3u - 32u)) & 1u; \
contig = 2u + t; \
t &= (opp_bits_high >> (pos + vec * 4u - 32u)); \
if (opp_bits_low & (1 << (pos + vec))) { \
if (opp_bits_low & (1 << (pos + vec * 2))) { \
t = (opp_bits_high >> (pos + vec * 3 - 32)) & 1; \
contig = 2 + t; \
t &= (opp_bits_high >> (pos + vec * 4 - 32)); \
contig += t; \
t &= (opp_bits_high >> (pos + vec * 5u - 32u)); \
t &= (opp_bits_high >> (pos + vec * 5 - 32)); \
contig += t; \
t = lsb_mask[contig - 2] & maskh; \
if (my_bits_high & t) { \
my_bits_high |= t; \
my_bits_low |= (1u << (pos + vec)) | (1u << (pos + vec * 2u)); \
my_bits_low |= (1 << (pos + vec)) | (1 << (pos + vec * 2)); \
flipped += contig; \
} \
} else { \
t = (my_bits_low >> (pos + vec * 2u)) & 1u; \
t = (my_bits_low >> (pos + vec * 2)) & 1; \
my_bits_low |= t << (pos + vec); \
flipped += t; \
} \
Expand Down Expand Up @@ -679,17 +679,17 @@ static const unsigned int high_flip[56] = {


#define bbFlips_Down_1_3(pos, vec, maskh) \
if (opp_bits_low & (1u << (pos + vec))) { \
t = (opp_bits_high >> (pos + vec * 2u - 32u)) & 1u; \
if (opp_bits_low & (1 << (pos + vec))) { \
t = (opp_bits_high >> (pos + vec * 2 - 32)) & 1; \
contig = 1 + t; \
t &= (opp_bits_high >> (pos + vec * 3u - 32u)); \
t &= (opp_bits_high >> (pos + vec * 3 - 32)); \
contig += t; \
t &= (opp_bits_high >> (pos + vec * 4u - 32u)); \
t &= (opp_bits_high >> (pos + vec * 4 - 32)); \
contig += t; \
t = lsb_mask[contig - 1u] & maskh; \
t = lsb_mask[contig - 1] & maskh; \
if (my_bits_high & t) { \
my_bits_high |= t; \
my_bits_low |= 1u << (pos + vec); \
my_bits_low |= 1 << (pos + vec); \
flipped += contig; \
} \
}
Expand Down Expand Up @@ -775,7 +775,7 @@ static const unsigned int high_flip[56] = {
t &= (opp_bits_high >> (pos + vec * 3 - 32)); \
contig += t; \
fl = lsb_mask[contig] & mask; \
t = ((int)(-(unsigned int)(my_bits_high & fl))) >> 31u; \
t = -(int)(my_bits_high & fl) >> 31; \
my_bits_high |= fl & t; \
flipped += contig & t; \
}
Expand All @@ -795,10 +795,10 @@ static const unsigned int high_flip[56] = {
#endif

#define bbFlips_Up_0_3(pos, vec, mask) \
if (opp_bits_low & (1u << (pos + 32u - vec))) { \
t = (opp_bits_low >> (pos + 32u - vec * 2u)) & 1u; \
if (opp_bits_low & (1 << (pos + 32 - vec))) { \
t = (opp_bits_low >> (pos + 32 - vec * 2)) & 1; \
contig = 1 + t; \
t &= (opp_bits_low >> (pos + 32u - vec * 3u)); \
t &= (opp_bits_low >> (pos + 32 - vec * 3)); \
contig += t; \
fl = msb_mask[contig] & mask; \
t = -(int)(my_bits_low & fl) >> 31; \
Expand Down Expand Up @@ -1021,7 +1021,7 @@ TestFlips_bitboard_a8( unsigned int my_bits_high, unsigned int my_bits_low, unsi
unsigned int t, fl;

/* Right */
bbFlips_Right_high(24u, 0x3Fu);
bbFlips_Right_high(24, 0x3F);
/* Up right */
bbFlips_Up_3_3(24, 7, 0x00020408u, 0x10204080u);
/* Up */
Expand Down Expand Up @@ -1115,7 +1115,7 @@ TestFlips_bitboard_h2( unsigned int my_bits_high, unsigned int my_bits_low, unsi
/* Down left */
bbFlips_Down_2_3(15, 7, 0x02040810u);
/* Down */
bbFlips_Down_2_3(15u, 8u, 0x80808080u);
bbFlips_Down_2_3(15, 8, 0x80808080u);

my_bits_low |= 0x00008000u;
bb_flips.high = my_bits_high;
Expand Down Expand Up @@ -1339,7 +1339,7 @@ TestFlips_bitboard_h3( unsigned int my_bits_high, unsigned int my_bits_low, unsi
/* Down left */
bbFlips_Down_1_3(23, 7, 0x04081020u);
/* Down */
bbFlips_Down_1_3(23u, 8u, 0x80808080u);
bbFlips_Down_1_3(23, 8, 0x80808080u);
/* Up */
bbFlips_Up_1_low(23, 8);
/* Up left */
Expand Down Expand Up @@ -1553,7 +1553,7 @@ TestFlips_bitboard_h5( unsigned int my_bits_high, unsigned int my_bits_low, unsi
/* Down */
bbFlips_Down_2_high(7, 8, 0x00808000u);
/* Up */
bbFlips_Up_0_3(7u, 8u, 0x80808080u);
bbFlips_Up_0_3(7, 8, 0x80808080u);
/* Up left */
bbFlips_Up_0_3(7, 9, 0x40201008u);

Expand Down
2 changes: 1 addition & 1 deletion project/src/main/jni/zebra/end.c
Original file line number Diff line number Diff line change
Expand Up @@ -2409,7 +2409,7 @@ setup_end( void ) {
if ( dir_mask[pos] & (1 << k) ) {
unsigned int neighbor = shift + dir_shift[k];
if ( neighbor < 32 )
neighborhood_mask[pos].low |= ((unsigned int)1 << ((unsigned int)neighbor));
neighborhood_mask[pos].low |= (1 << neighbor);
else
neighborhood_mask[pos].high |= (1 << (neighbor - 32));
}
Expand Down
Loading

0 comments on commit fc03884

Please sign in to comment.