Skip to content

Commit c73b02d

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 3cf1e26 + c4332d6 commit c73b02d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3790
-816
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ jobs:
2424
submodules: true
2525
- name: make
2626
run: LDFLAGS=-Wl,--no-undefined make -j$(getconf _NPROCESSORS_ONLN) -f Makefile.libretro
27+
- name: artifacts
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: Libretro-linux
31+
path: picodrive_libretro.so
2732

2833
build-win32:
2934
runs-on: ubuntu-latest

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ else
183183
LDFLAGS += -lEGL -lGLESv2 # on raspi GLESv1_CM is included in GLESv2
184184
endif
185185
OBJS += platform/linux/emu.o platform/linux/blit.o # FIXME
186-
OBJS += platform/common/plat_sdl.o platform/common/input_sdlkbd.o
186+
OBJS += platform/common/plat_sdl.o platform/common/inputmap_kbd.o
187187
OBJS += platform/libpicofe/plat_sdl.o platform/libpicofe/in_sdl.o
188188
OBJS += platform/libpicofe/linux/plat.o
189189
USE_FRONTEND = 1
@@ -298,7 +298,7 @@ ifeq "$(USE_FRONTEND)" "1"
298298

299299
# common
300300
OBJS += platform/common/main.o platform/common/emu.o platform/common/upscale.o \
301-
platform/common/menu_pico.o platform/common/config_file.o
301+
platform/common/menu_pico.o platform/common/keyboard.o platform/common/config_file.o
302302

303303
# libpicofe
304304
OBJS += platform/libpicofe/input.o platform/libpicofe/readpng.o \

Makefile.libretro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ SHARED ?= -shared
661661
LDFLAGS += $(SHARED) $(fpic)
662662

663663
ifeq ($(ARCH),)
664-
ARCH = $(shell $(CC) -dumpmachine | awk -F '-' '{print $$1}')
664+
ARCH = $(shell $(CC) $(CFLAGS) -dumpmachine | awk -F '-' '{print $$1}')
665665
endif
666666
PLATFORM = libretro
667667
NO_CONFIG_MAK = yes

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,40 @@ Further instructions can be found in `platform/base_readme.txt`.
2929
PicoDrive can use Storyware pages and pad overlays in png format in the same
3030
directory as the cartridge image. The selected page is displayed automatically
3131
if the pen is used on the storyware or pad. Details about how to correctly name
32-
the pages can be found in the *How to run Sega Pico games* section in
33-
`platform/base_readme.txt`.
32+
the pages can be found in `platform/base_readme.txt`.
33+
34+
### Sega Pico Pen and Sega Mouse
35+
36+
On all platforms with physical mouse support, PicoDrive can use real mouse
37+
input to emulate a Sega Mouse or the Pico Pen. A physical mouse can be operated
38+
in either a captured or uncaptured state, selectable via the `Capture mouse` hotkey.
39+
Mouse mode can be activated by setting `mouse` as the input device for one
40+
of the pads. It depends on the game as to which pad should be used for mouse
41+
input. More information is located in `platform/base_readme.txt`.
42+
43+
### Sega Pico and SC-3000 Keyboards
44+
45+
PicoDrive provides support for the Pico and SC-3000 keyboards. This can be
46+
enabled in the `Controls` configuration menu. Once enabled, keyboard input may
47+
be activated via the `Keyboard` emulator hotkey.
48+
49+
Both physical keyboard support and a virtual keyboard overlay are available.
50+
Physical keyboards are assigned a default key mapping corresponding to an
51+
American PC layout, but the mapping can be redefined in the `Controls`
52+
configuration menu. Note that only 'unmodified' physical key presses (e.g.
53+
`a`, `1` etc) can be mapped to emulated keyboard input; special characters
54+
entered via modifier/meta keys (e.g. `Ctrl`, `Shift` etc) will not work.
55+
Additional information may be found in `platform/base_readme.txt`.
56+
57+
### Sega SC-3000 Cassette Drive
58+
59+
In addition to keyboard support, PicoDrive emulates the SC-3000 cassette tape
60+
drive which may be used in conjunction with BASIC cartridges. Tape emulation
61+
includes an automatic start/stop feature, where the tape is only advanced when
62+
it is accessed by the SC-3000; manual pausing of the tape is unnecessary for
63+
multi-part loading or saving.
64+
65+
PicoDrive supports tape files in `WAV` and `bitstream` format.
3466

3567
### Gallery
3668

cpu/sh2/compiler.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5678,7 +5678,7 @@ static void sh2_smc_rm_blocks(u32 a, int len, int tcache_id, int free)
56785678

56795679
if (!removed) {
56805680
if (len <= 4)
5681-
dbg(2, "rm_blocks called @%08x, no work?", _a);
5681+
dbg(2, "rm_blocks called @%08x, no work?", a);
56825682
return;
56835683
}
56845684

@@ -5902,6 +5902,9 @@ static void bcache_stats(void)
59025902

59035903
void sh2_drc_flush_all(void)
59045904
{
5905+
if (block_tables[0] == NULL)
5906+
return;
5907+
59055908
backtrace();
59065909
state_dump();
59075910
block_stats();

pico/32x/32x.c

Lines changed: 60 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,16 @@ void Pico32xStartup(void)
120120
sh2_init(&ssh2, 1, &msh2);
121121
ssh2.irq_callback = sh2_irq_cb;
122122
}
123+
123124
PicoMemSetup32x();
124125
p32x_pwm_ctl_changed();
125126
p32x_timers_recalc();
126127

128+
Pico32x.regs[0] |= P32XS_ADEN;
129+
127130
Pico32x.sh2_regs[0] = P32XS2_ADEN;
128131
if (Pico.m.ncart_in)
129-
Pico32x.sh2_regs[0] |= P32XS_nCART;
132+
Pico32x.sh2_regs[0] |= P32XS2_nCART;
130133

131134
if (!Pico.m.pal)
132135
Pico32x.vdp_regs[0] |= P32XV_nPAL;
@@ -141,7 +144,9 @@ void Pico32xStartup(void)
141144

142145
void Pico32xShutdown(void)
143146
{
147+
elprintf(EL_STATUS|EL_32X, "32X shutdown");
144148
Pico32x.sh2_regs[0] &= ~P32XS2_ADEN;
149+
Pico32x.regs[0] &= ~P32XS_ADEN;
145150

146151
rendstatus_old = -1;
147152

@@ -243,34 +248,71 @@ void PicoReset32x(void)
243248
}
244249
}
245250

246-
static void p32x_render_frame(void)
251+
static void Pico32xRenderSync(int lines)
247252
{
248253
if (Pico32xDrawMode != PDM32X_OFF && !PicoIn.skipFrame) {
249-
int offs, lines;
254+
int offs;
250255

251256
pprof_start(draw);
252257

253-
offs = 8; lines = 224;
254-
if (Pico.video.reg[1] & 8) {
258+
offs = 8;
259+
if (Pico.video.reg[1] & 8)
255260
offs = 0;
256-
lines = 240;
257-
}
258261

259262
if ((Pico32x.vdp_regs[0] & P32XV_Mx) != 0 && // 32x not blanking
260263
(!(Pico.video.debug_p & PVD_KILL_32X)))
261264
{
262265
int md_bg = Pico.video.reg[7] & 0x3f;
263266

264-
// we draw full layer (not line-by-line)
265-
PicoDraw32xLayer(offs, lines, md_bg);
267+
// we draw lines up to the sync point (not line-by-line)
268+
PicoDraw32xLayer(offs, lines-Pico32x.sync_line, md_bg);
266269
}
267270
else if (Pico32xDrawMode == PDM32X_BOTH)
268-
PicoDraw32xLayerMdOnly(offs, lines);
271+
PicoDraw32xLayerMdOnly(offs, lines-Pico32x.sync_line);
269272

270273
pprof_end(draw);
271274
}
272275
}
273276

277+
void Pico32xDrawSync(SH2 *sh2)
278+
{
279+
// the fast renderer isn't operating on a line-by-line base
280+
if (sh2 && !(PicoIn.opt & POPT_ALT_RENDERER)) {
281+
unsigned int cycle = (sh2 ? sh2_cycles_done_m68k(sh2) : SekCyclesDone());
282+
int line = ((cycle - Pico.t.m68c_frame_start) * (long long)((1LL<<32)/488.5)) >> 32;
283+
284+
if (Pico32x.sync_line < line && line < (Pico.video.reg[1] & 8 ? 240 : 224)) {
285+
// make sure the MD image is also sync'ed to this line for merging
286+
PicoDrawSync(line, 0, 0);
287+
288+
// pfff... need to save and restore some persistent data for MD renderer
289+
void *dest = Pico.est.DrawLineDest;
290+
int incr = Pico.est.DrawLineDestIncr;
291+
Pico32xRenderSync(line);
292+
Pico.est.DrawLineDest = dest;
293+
Pico.est.DrawLineDestIncr = incr;
294+
}
295+
296+
// remember line we sync'ed to
297+
Pico32x.sync_line = line;
298+
}
299+
}
300+
301+
static void p32x_render_frame(void)
302+
{
303+
if (Pico32xDrawMode != PDM32X_OFF && !PicoIn.skipFrame) {
304+
int lines;
305+
306+
pprof_start(draw);
307+
308+
lines = 224;
309+
if (Pico.video.reg[1] & 8)
310+
lines = 240;
311+
312+
Pico32xRenderSync(lines);
313+
}
314+
}
315+
274316
static void p32x_start_blank(void)
275317
{
276318
// enter vblank
@@ -616,6 +658,7 @@ void PicoFrame32x(void)
616658
pcd_prepare_frame();
617659

618660
PicoFrameStart();
661+
Pico32x.sync_line = 0;
619662
if (Pico32xDrawMode != PDM32X_BOTH)
620663
Pico.est.rendstatus |= PDRAW_SYNC_NEEDED;
621664
PicoFrameHints();
@@ -654,14 +697,20 @@ void Pico32xStateLoaded(int is_early)
654697
p32x_timers_recalc();
655698
p32x_pwm_state_loaded();
656699
p32x_run_events(SekCyclesDone());
700+
701+
// TODO wakeup CPUs for now. poll detection stuff must go to the save state!
702+
p32x_m68k_poll_event(0, -1);
703+
p32x_sh2_poll_event(msh2.poll_addr, &msh2, SH2_IDLE_STATES, msh2.m68krcycles_done);
704+
p32x_sh2_poll_event(ssh2.poll_addr, &ssh2, SH2_IDLE_STATES, ssh2.m68krcycles_done);
657705
}
658706

659707
void Pico32xPrepare(void)
660708
{
709+
// fallback in case it was missing in saved config
661710
if (msh2.mult_m68k_to_sh2 == 0 || msh2.mult_sh2_to_m68k == 0)
662711
Pico32xSetClocks(PICO_MSH2_HZ, 0);
663712
if (ssh2.mult_m68k_to_sh2 == 0 || ssh2.mult_sh2_to_m68k == 0)
664-
Pico32xSetClocks(0, PICO_MSH2_HZ);
713+
Pico32xSetClocks(0, PICO_SSH2_HZ);
665714

666715
sh2_execute_prepare(&msh2, PicoIn.opt & POPT_EN_DRC);
667716
sh2_execute_prepare(&ssh2, PicoIn.opt & POPT_EN_DRC);

0 commit comments

Comments
 (0)