Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit 10d6f25

Browse files
authored
Merge branch 'master' into mar753/render-to-texture-with-options
2 parents 2aadb3c + 3c57177 commit 10d6f25

File tree

10 files changed

+111
-18
lines changed

10 files changed

+111
-18
lines changed

core/deps/chdpsr/cdipsr.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,27 @@ void CDI_get_tracks (FILE *fsource, image_s *image)
113113
fread(&image->tracks, 2, 1, fsource);
114114
}
115115

116-
void CDI_init (FILE *fsource, image_s *image, char *fsourcename)
116+
bool CDI_init (FILE *fsource, image_s *image, const char *fsourcename)
117117
{
118118
image->length = core_fsize(fsource);
119119

120-
if (image->length < 8) printf( "Image file is too short");
121-
122-
fseek(fsource, image->length-8, SEEK_SET);
123-
fread(&image->version, 4, 1, fsource);
124-
fread(&image->header_offset, 4, 1, fsource);
125-
126-
// if (errno != 0) printf( fsourcename);
127-
if (image->header_offset == 0) printf( "Bad image format");
120+
if (image->length < 8)
121+
{
122+
printf("%s: Image file is too short\n", fsourcename);
123+
return false;
124+
}
125+
126+
fseek(fsource, image->length-8, SEEK_SET);
127+
fread(&image->version, 4, 1, fsource);
128+
fread(&image->header_offset, 4, 1, fsource);
129+
130+
if ((image->version != CDI_V2 && image->version != CDI_V3 && image->version != CDI_V35)
131+
|| image->header_offset == 0)
132+
{
133+
printf("%s: Bad image format\n", fsourcename);
134+
return false;
135+
}
136+
return true;
128137
}
129138

130139
void CDI_get_sessions (FILE *fsource, image_s *image)

core/deps/chdpsr/cdipsr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef struct track_s
3939
#define CDI_V35 0x80000006
4040

4141
unsigned long ask_type(core_file *fsource, long header_position);
42-
void CDI_init(core_file *fsource, image_s *image, char *fsourcename);
42+
bool CDI_init(core_file *fsource, image_s *image, const char *fsourcename);
4343
void CDI_get_sessions(core_file *fsource, image_s *image);
4444
void CDI_get_tracks(core_file *fsource, image_s *image);
4545
void CDI_read_track(core_file *fsource, image_s *image, track_s *track);

core/imgread/cdi.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,18 @@ Disc* cdi_parse(const wchar* file)
1313
if (!fsource)
1414
return 0;
1515

16-
Disc* rv= new Disc();
17-
1816
image_s image = { 0 };
1917
track_s track = { 0 };
20-
CDI_init(fsource,&image,0);
18+
if (!CDI_init(fsource, &image, file))
19+
{
20+
core_fclose(fsource);
21+
return NULL;
22+
}
2123

2224
CDI_get_sessions(fsource,&image);
2325

26+
Disc* rv= new Disc();
27+
2428
image.remaining_sessions = image.sessions;
2529

2630
/////////////////////////////////////////////////////////////// Loop sessions
@@ -36,7 +40,7 @@ Disc* cdi_parse(const wchar* file)
3640

3741
image.header_position = core_ftell(fsource);
3842

39-
printf("\nSession %d has %d track(s)\n",image.global_current_session,image.tracks);
43+
//printf("\nSession %d has %d track(s)\n",image.global_current_session,image.tracks);
4044

4145
if (image.tracks == 0)
4246
printf("Open session\n");
@@ -57,7 +61,7 @@ Disc* cdi_parse(const wchar* file)
5761
image.header_position = core_ftell(fsource);
5862

5963
// Show info
60-
64+
#if 0
6165
printf("Saving ");
6266
printf("Track: %2d ",track.global_current_track);
6367
printf("Type: ");
@@ -73,7 +77,7 @@ Disc* cdi_parse(const wchar* file)
7377
printf("Pregap: %-3ld ",track.pregap_length);
7478
printf("Size: %-6ld ",track.length);
7579
printf("LBA: %-6ld ",track.start_lba);
76-
80+
#endif
7781
if (ft)
7882
{
7983
ft=false;
@@ -102,7 +106,7 @@ Disc* cdi_parse(const wchar* file)
102106

103107
rv->tracks.push_back(t);
104108

105-
printf("\n");
109+
//printf("\n");
106110

107111
// if (track.pregap_length != 150) printf("Warning! This track seems to have a non-standard pregap...\n");
108112

@@ -122,7 +126,7 @@ Disc* cdi_parse(const wchar* file)
122126
else
123127
{
124128

125-
printf("Track position: %lu\n",track.position + track.pregap_length * track.sector_size);
129+
//printf("Track position: %lu\n",track.position + track.pregap_length * track.sector_size);
126130
core_fseek(fsource, track.position, SEEK_SET);
127131
// fseek(fsource, track->pregap_length * track->sector_size, SEEK_CUR);
128132
// fseek(fsource, track->length * track->sector_size, SEEK_CUR);
@@ -155,6 +159,7 @@ Disc* cdi_parse(const wchar* file)
155159

156160
image.remaining_sessions--;
157161
}
162+
core_fclose(fsource);
158163

159164
rv->type=GuessDiscType(CD_M1,CD_M2,CD_DA);
160165

shell/android-studio/reicast/src/main/java/com/reicast/emulator/Emulator.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class Emulator extends Application {
2222
public static final String pref_mipmaps = "use_mipmaps";
2323
public static final String pref_resolution = "resolution";
2424
public static final String pref_frameskip = "frame_skip";
25+
public static final String pref_clipping = "clipping";
2526
public static final String pref_pvrrender = "pvr_render";
2627
public static final String pref_syncedrender = "synced_render";
2728
public static final String pref_modvols = "modifier_volumes";
@@ -44,6 +45,7 @@ public class Emulator extends Application {
4445
public static boolean crtview = false;
4546
public static boolean subdivide = false;
4647
public static int frameskip = 0;
48+
public static boolean clipping = false;
4749
public static boolean pvrrender = false;
4850
public static boolean syncedrender = false;
4951
public static boolean modvols = true;
@@ -67,6 +69,7 @@ public void getConfigurationPrefs(SharedPreferences mPrefs) {
6769
Emulator.widescreen = mPrefs.getInt(pref_resolution, 0) == 2;
6870
Emulator.crtview = mPrefs.getInt(pref_resolution, 0) == 1;
6971
Emulator.frameskip = mPrefs.getInt(pref_frameskip, frameskip);
72+
Emulator.clipping = mPrefs.getBoolean(pref_clipping, clipping);
7073
Emulator.pvrrender = mPrefs.getBoolean(pref_pvrrender, pvrrender);
7174
Emulator.syncedrender = mPrefs.getBoolean(pref_syncedrender, syncedrender);
7275
Emulator.bootdisk = mPrefs.getString(pref_bootdisk, bootdisk);
@@ -93,6 +96,7 @@ public void loadConfigurationPrefs() {
9396
JNIdc.widescreen(Emulator.widescreen ? 1 : 0);
9497
JNIdc.subdivide(Emulator.subdivide ? 1 : 0);
9598
JNIdc.frameskip(Emulator.frameskip);
99+
JNIdc.clipping(Emulator.clipping ? 1 : 0);
96100
JNIdc.pvrrender(Emulator.pvrrender ? 1 : 0);
97101
JNIdc.syncedrender(Emulator.syncedrender ? 1 : 0);
98102
JNIdc.modvols(Emulator.modvols ? 1 : 0);

shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/OptionsFragment.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,16 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
375375
limit_fps.setChecked(mPrefs.getBoolean(Emulator.pref_limitfps, Emulator.limitfps));
376376
limit_fps.setOnCheckedChangeListener(limitfps_option);
377377

378+
OnCheckedChangeListener clipping_option = new OnCheckedChangeListener() {
379+
380+
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
381+
mPrefs.edit().putBoolean(Emulator.pref_clipping, isChecked).apply();
382+
}
383+
};
384+
CompoundButton clipping_fps = (CompoundButton) getView().findViewById(R.id.clipping_option);
385+
clipping_fps.setChecked(mPrefs.getBoolean(Emulator.pref_clipping, Emulator.clipping));
386+
clipping_fps.setOnCheckedChangeListener(clipping_option);
387+
378388
OnCheckedChangeListener mipmaps_option = new OnCheckedChangeListener() {
379389

380390
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@@ -711,6 +721,7 @@ private void resetEmuSettings() {
711721
mPrefs.edit().remove(Emulator.pref_mipmaps).apply();
712722
mPrefs.edit().remove(Emulator.pref_resolution).apply();
713723
mPrefs.edit().remove(Emulator.pref_frameskip).apply();
724+
mPrefs.edit().remove(Emulator.pref_clipping).apply();
714725
mPrefs.edit().remove(Emulator.pref_pvrrender).apply();
715726
mPrefs.edit().remove(Emulator.pref_syncedrender).apply();
716727
mPrefs.edit().remove(Emulator.pref_bootdisk).apply();

shell/android-studio/reicast/src/main/java/com/reicast/emulator/emu/JNIdc.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public final class JNIdc
4444
public static native void widescreen(int stretch);
4545
public static native void subdivide(int subdivide);
4646
public static native void frameskip(int frames);
47+
public static native void clipping(int clipping);
4748
public static native void pvrrender(int render);
4849
public static native void syncedrender(int sync);
4950
public static native void modvols(int volumes);

shell/android-studio/reicast/src/main/jni/src/Android.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_cable(JNIEnv *env,job
5353
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_region(JNIEnv *env,jobject obj, jint region) __attribute__((visibility("default")));
5454
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_broadcast(JNIEnv *env,jobject obj, jint broadcast) __attribute__((visibility("default")));
5555
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_rtt(JNIEnv *env,jobject obj, jint rtt) __attribute__((visibility("default")));
56+
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_clipping(JNIEnv *env,jobject obj, jint clipping) __attribute__((visibility("default")));
5657
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_limitfps(JNIEnv *env,jobject obj, jint limiter) __attribute__((visibility("default")));
5758
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_nobatch(JNIEnv *env,jobject obj, jint nobatch) __attribute__((visibility("default")));
5859
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_nosound(JNIEnv *env,jobject obj, jint noaudio) __attribute__((visibility("default")));
@@ -128,6 +129,11 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_mipmaps(JNIEnv *env,j
128129
settings.rend.UseMipmaps = mipmaps;
129130
}
130131

132+
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_clipping(JNIEnv *env,jobject obj, jint clipping)
133+
{
134+
settings.rend.Clipping = clipping;
135+
}
136+
131137
JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_widescreen(JNIEnv *env,jobject obj, jint stretch)
132138
{
133139
settings.rend.WideScreen = stretch;

shell/android-studio/reicast/src/main/res/layout-v14/configure_fragment.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,34 @@
694694
</LinearLayout>
695695
</TableRow>
696696

697+
<TableRow
698+
android:layout_marginTop="10dp"
699+
android:gravity="center_vertical" >
700+
701+
<TextView
702+
android:id="@+id/clipping_text"
703+
android:layout_width="wrap_content"
704+
android:layout_height="wrap_content"
705+
android:layout_weight="0.5"
706+
android:ems="10"
707+
android:gravity="center_vertical|left"
708+
android:text="@string/clipping" />
709+
710+
<LinearLayout
711+
android:layout_width="wrap_content"
712+
android:layout_height="wrap_content"
713+
android:layout_weight="1"
714+
android:gravity="right"
715+
android:orientation="vertical" >
716+
717+
<Switch
718+
android:id="@+id/clipping_option"
719+
android:layout_width="wrap_content"
720+
android:layout_height="wrap_content"
721+
android:focusable="true" />
722+
</LinearLayout>
723+
</TableRow>
724+
697725
<TableRow
698726
android:layout_marginTop="10dp"
699727
android:gravity="center_vertical" >

shell/android-studio/reicast/src/main/res/layout/configure_fragment.xml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,34 @@
694694
</LinearLayout>
695695
</TableRow>
696696

697+
<TableRow
698+
android:layout_marginTop="10dp"
699+
android:gravity="center_vertical" >
700+
701+
<TextView
702+
android:id="@+id/clipping_text"
703+
android:layout_width="wrap_content"
704+
android:layout_height="wrap_content"
705+
android:layout_weight="0.5"
706+
android:ems="10"
707+
android:gravity="center_vertical|left"
708+
android:text="@string/clipping" />
709+
710+
<LinearLayout
711+
android:layout_width="wrap_content"
712+
android:layout_height="wrap_content"
713+
android:layout_weight="1"
714+
android:gravity="right"
715+
android:orientation="vertical" >
716+
717+
<Checkbox
718+
android:id="@+id/clipping_option"
719+
android:layout_width="wrap_content"
720+
android:layout_height="wrap_content"
721+
android:focusable="true" />
722+
</LinearLayout>
723+
</TableRow>
724+
697725
<TableRow
698726
android:layout_marginTop="10dp"
699727
android:gravity="center_vertical" >

shell/android-studio/reicast/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<string name="select_sound">Disable Emulator Sound</string>
5757
<string name="select_depth">View Rendering Depth</string>
5858
<string name="boot_disk">Boot Disk (ie. Gameshark, Utopia)</string>
59+
<string name="clipping">Clipping</string>
5960

6061
<string name="reset_emu">Reset Emu</string>
6162
<string name="reset_emu_title">Reset Emulator Settings</string>

0 commit comments

Comments
 (0)