From f1a49afc60bcd61277ad581bc5358a52089a34fc Mon Sep 17 00:00:00 2001 From: meetpatty Date: Thu, 19 Oct 2017 22:00:59 +1300 Subject: [PATCH] Reinstate support for on the fly button mapping and mounting of floppies/cdroms. --- src/PSP2/README.txt | 245 +++++++++++++++++++++++++++++++++++++++++ src/PSP2/gui_psp.cpp | 3 +- src/PSP2/makefile | 71 ++++++++++++ src/PSP2/video_psp.cpp | 84 +++++++------- 4 files changed, 354 insertions(+), 49 deletions(-) create mode 100644 src/PSP2/README.txt create mode 100644 src/PSP2/makefile diff --git a/src/PSP2/README.txt b/src/PSP2/README.txt new file mode 100644 index 0000000..f7e55f8 --- /dev/null +++ b/src/PSP2/README.txt @@ -0,0 +1,245 @@ +Basilisk II for the Vita +======================== + +Basilisk II is a multi-platform Mac II emulator whose code is released under the terms of the +GPL v2. + +Features for the Vita version include: + +* Emulates a Mac II series machine running OS 7.0.1 through 8.1, depending on the ROM used. +* Uses UAE CPU emulation, with new SoftFloat FPU emulation for better compatibility. +* Supports on-the-fly change of colors and resolution (requires Display Manager). +* Has stereo, 16-bit, 44kHz audio (requires Sound Manager 3.0). +* Supports emulated floppy and CDROM with removable media (no CD audio yet). +* Supports up to four hardfiles for use as fixed drives. +* Emulates a Mac Extended ADB keyboard and mouse. Buttons can be remapped on-the-fly. + +The main Basilisk II website is located at http://basilisk.cebix.net/. This version of Basilisk II +is based on Chilly Willy's PSP port v1.1.1. + +Basilisk II comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to +redistribute it under the terms of the GNU General Public License. + +Installing Basilisk II for the Vita +=================================== + +Install the vpk in the usual way. Copy the Basilisk II folder in the archive to ux0:data. +If you look at the folder, you'll see the following: + +(directories) +cdroms +disks +files +hardfiles +imaps +roms + +(files) +BasiliskII_prefs +imaps/default +imaps/dpad_mouse + +The cdroms folder is where you copy the bin/cue dumps of Mac CDROMs you wish to use with the +emulation. These should be standard MODE1 ISO dumps, not raw dumps. The extension for CDROM +images are normally “.bin”, “.iso”, or “.img”. + +The disks folder is where you copy floppy images you wish to use with the emulation. These are +plain dumps of 1.44 MB high-density Mac or PC format microfloppy disks. PC format requires the +appropriate Mac extension to read, such as MacLink (part of OS 8). All files in this folder +should have an extension of “.dsk”. + +The files folder is mounted on the Mac desktop when enabled in the settings. Files in this folder +should be in AppleDouble, hqx, and binhex format. + +The hardfiles folder contains the files that are used as fixed hard disks in the emulation. They +can be virtually any size, but will generally be between 200 and 400 MB as a basic installation +of OS8 takes about 120 MB. You can have any number of files in this directory, but only a maximum +of four can be selected at one time. The extension of files in this folder should b “.hfv”, but may +also have no extension at all. + +The imaps folder holds the input maps for remapping the Vita buttons into Mac input events. This will +be explained later. + +The roms folder holds the Mac ROM images you might use with the emulation. You select one image in +the emulation setup. They can have any file name, but a typical extension is “.rom”. + +BasiliskII_prefs is a sample preferences file. + +Note: No Apple Macintosh ROMs or software of any sort is included with this program. You'll have to +find them yourself. This emulator is useless without a ROM and MacOS. + +Controls +======== +SELECT - Invoke the imap/floppy/cdrom menu + +While in the imap/floppy/cdrom menu, you press up/down to change between input maps, +floppies, and cdroms. Press left/right to browse the list of files in the imaps, disks, and +cdroms directories, respectively. Press CROSS to select an input map, or mount a CD-ROM or +floppy. Press SELECT again to exit the menu. Note that you can only have one cd-rom and +floppy mounted at a time. To mount another, you must first dismount the CD-ROM/floppy +which is already mounted. On the Mac, you dismount disks/cd-roms by throwing them in the +trash, or by selecting the disk and then selecting Eject from the Special menu (or pressing +the Command + E keys). + +Default Controls +================ +CROSS – mouse button +SQUARE – enter key +CIRCLE – command + w (Close Window) +TRIANGLE – command + q (Quit Application) +RTRIGGER – control key +LTRIGGER – option key +UP/DOWN/LEFT/RIGHT – corresponding cursor key +ANALOG STICK – mouse + +dpad_mouse Controls +=================== +CROSS – mouse button +SQUARE – enter key +CIRCLE – command + w (Close Window) +TRIANGLE – command + q (Quit Application) +RTRIGGER – control key +LTRIGGER – move mouse faster +UP/DOWN/LEFT/RIGHT – mouse +ANALOG STICK – mouse + +Imap file format +================ + +Each line has the following format: + + + +Lines starting with # are treated as comment lines and ignored, + +Valid vita key values are (OR keys to combine): + +0x0000 No key +0x0008 Start button. +0x0010 Up D-Pad button. +0x0020 Right D-Pad button. +0x0040 Down D-Pad button. +0x0080 Left D-Pad button. +0x0100 Left trigger. +0x0200 Right trigger. +0x1000 Triangle button. +0x2000 Circle button. +0x4000 Cross button. +0x8000 Square button. + +See below for Basilisk II key codes + +Example D-Pad Up = cursor up: + +0x0010 0x0000 62 255 255 255 + +Example Triangle = command + q: + +0x1000 0x0000 55 12 255 255 + +See imaps/default and imaps/dpad_mouse for further examples + +Basilisk II Key Codes +===================== + +0 A +1 S +2 D +3 F +4 H +5 G +6 Z +7 X +8 C +9 V +11 B +12 Q +13 W +14 E +15 R +16 Y +17 T +18 1 +19 2 +20 3 +21 4 +22 6 +23 5 +24 = +25 9 +26 7 +27 - +28 8 +29 0 +30 ] +31 O +32 U +33 [ +34 I +35 P +36 Return +37 L +38 J +39 ' +40 K +41 ; +42 \ +43 , +44 / +45 N +46 M +47 . +48 Tab +49 Space +50 ` +51 Backspace +53 Esc +54 Ctrl Left +55 Alt Left (-> Command) +56 Shift Left +57 Caps Lock +58 Logo Left (-> Option) +59 Cursor Left +60 Cursor Right +61 Cursor Down +62 Cursor Up +65 KP . +67 KP * +69 KP + +71 Num Lock +75 KP / +76 KP Enter +78 KP - +82 KP 0 +83 KP 1 +84 KP 2 +85 KP 3 +86 KP 4 +87 KP 5 +88 KP 6 +89 KP 7 +91 KP 8 +92 KP 9 +96 F5 +97 F6 +98 F7 +99 F3 +100 F8 +101 F9 +103 F11 +105 PrintScrn +107 Scroll Lock +109 F10 +111 F12 +113 Pause +114 Insert +115 Home +116 Page Up +117 Delete +118 F4 +119 End +120 F2 +121 Page Down +122 F1 +255 No key press +256 Mouse button 1 \ No newline at end of file diff --git a/src/PSP2/gui_psp.cpp b/src/PSP2/gui_psp.cpp index e902210..ceea70e 100644 --- a/src/PSP2/gui_psp.cpp +++ b/src/PSP2/gui_psp.cpp @@ -14,8 +14,7 @@ #include "sysdeps.h" #include "user_strings.h" #include "user_strings_psp.h" -#include "main.h" -#include "ime_dialog.h" +#include "main.h" #define Get_String(x) const_cast(GetString(x)) diff --git a/src/PSP2/makefile b/src/PSP2/makefile new file mode 100644 index 0000000..a492b3a --- /dev/null +++ b/src/PSP2/makefile @@ -0,0 +1,71 @@ +TARGET = BasiliskII +TITLE_ID = BASILISK0 + +CPUOBJS = ../uae_cpu/basilisk_glue.o ../uae_cpu/memory.o ../uae_cpu/newcpu.o \ + ../uae_cpu/readcpu.o cpustbl.o cpudefs.o \ + cpuemu1.o cpuemu2.o cpuemu3.o cpuemu4.o cpuemu5.o cpuemu6.o cpuemu7.o cpuemu8.o \ + ../uae_cpu/fpu/fpu_soft.o ../uae_cpu/fpu/softfloat/softfloat.o + +OBJS = ../main.o main_psp.o ../prefs.o ../prefs_items.o prefs_psp.o \ + prefs_editor_psp.o sys_psp.o ../rom_patches.o ../slot_rom.o \ + ../rsrc_patches.o ../emul_op.o ../macos_util.o ../xpram.o \ + xpram_psp.o ../timer.o timer_psp.o clip_psp.o ../adb.o \ + ../serial.o serial_psp.o ../ether.o ether_psp.o ../sony.o \ + ../disk.o ../cdrom.o ../scsi.o scsi_psp.o ../video.o \ + video_psp.o ../audio.o audio_psp.o ../extfs.o extfs_psp.o \ + ftruncate.o ../user_strings.o user_strings_psp.o \ + gui_psp.o reqfile.o debugScreen.o \ + $(CPUOBJS) + +INCLUDES = -I../include -I./include -I. -I../uae_cpu -I../uae_cpu/fpu/softfloat +LIBS = -lSceCtrl_stub -lSceTouch_stub -lSceLibKernel_stub -lSceAudio_stub -lSceNetCtl_stub \ + -lSceNet_stub -lvita2d -lSceDisplay_stub -lSceSysmodule_stub -lSceGxm_stub \ + -lScePgf_stub -lScePvf_stub -lSceHid_stub -lScePower_stub -lSceAppUtil_stub \ + -lSceCommonDialog_stub -lSceIme_stub -lfreetype -lpng -ljpeg -lz -lm -lc + +PREFIX = arm-vita-eabi +CC = $(PREFIX)-gcc +CXX := $(PREFIX)-g++ + +CFLAGS += -DFPU_SOFT -falign-functions=64 -O3 +CXXFLAGS = $(CFLAGS) -std=c++11 $(INCLUDES) -L$(VITASDK)\lib -Wno-narrowing -Wwrite-strings -fpermissive +ASFLAGS = $(CFLAGS) + +all: cpuemu1.o cpuemu2.o cpuemu3.o cpuemu4.o cpuemu5.o cpuemu6.o cpuemu7.o cpuemu8.o $(TARGET).vpk + +cpuemu1.o: cpuemu.cpp + $(CXX) -D_REENTRANT -DPART_1 $(CXXFLAGS) -c $< -o $@ +cpuemu2.o: cpuemu.cpp + $(CXX) -D_REENTRANT -DPART_2 $(CXXFLAGS) -c $< -o $@ +cpuemu3.o: cpuemu.cpp + $(CXX) -D_REENTRANT -DPART_3 $(CXXFLAGS) -c $< -o $@ +cpuemu4.o: cpuemu.cpp + $(CXX) -D_REENTRANT -DPART_4 $(CXXFLAGS) -c $< -o $@ +cpuemu5.o: cpuemu.cpp + $(CXX) -D_REENTRANT -DPART_5 $(CXXFLAGS) -c $< -o $@ +cpuemu6.o: cpuemu.cpp + $(CXX) -D_REENTRANT -DPART_6 $(CXXFLAGS) -c $< -o $@ +cpuemu7.o: cpuemu.cpp + $(CXX) -D_REENTRANT -DPART_7 $(CXXFLAGS) -c $< -o $@ +cpuemu8.o: cpuemu.cpp + $(CXX) -D_REENTRANT -DPART_8 $(CXXFLAGS) -c $< -o $@ + +%.vpk: eboot.bin + vita-mksfoex -s TITLE_ID=$(TITLE_ID) "$(TARGET)" param.sfo + vita-pack-vpk -s param.sfo -b eboot.bin \ + -a sce_sys/icon0.png=sce_sys/icon0.png \ + -a fonts/ChicagoFLF.ttf=fonts/ChicagoFLF.ttf \ + $@ + +eboot.bin: $(TARGET).velf + vita-make-fself -s $< $@ + +%.velf: %.elf + $(PREFIX)-strip -g $< + vita-elf-create $< $@ + +$(TARGET).elf: $(OBJS) + $(CXX) -Wl,-q -o $@ $^ $(LIBS) + +clean: + @rm -rf $(TARGET).velf $(TARGET).elf $(OBJS) diff --git a/src/PSP2/video_psp.cpp b/src/PSP2/video_psp.cpp index 2bceb92..2ea1ca8 100644 --- a/src/PSP2/video_psp.cpp +++ b/src/PSP2/video_psp.cpp @@ -94,7 +94,8 @@ double scale_x, scale_y; static int psp_lcd_aspect = 0; // 4:3 extern bool emerg_quit; // Flag: emergency quit requested - +extern int FONT_SIZE; +extern vita2d_font *font; extern char *psp_floppy_inserted; // String: filename of floppy inserted extern char *psp_cdrom_inserted; // String: filename of cdrom inserted @@ -634,8 +635,6 @@ static int numimaps = -1; static bool caps_lock = false; -extern char psp_home[]; - extern int parse_dir (char *path, struct fileentries *thefiles, int maxentries); #define NUM_MAPS 64 @@ -903,30 +902,31 @@ void handle_keyboard(void) } } -void handle_menu(SceCtrlData pad, char *message) +void handle_menu(SceCtrlData pad) { uint32 buttons; static uint32 oldButtons = 0; static uint32 sel = 0; static uint32 max = 0; static uint32 idx = 0; // 0 = input maps, 1 = floppies, 2 = cdroms - char temp[256]; + char temp[256]; + uint32 fc = 0xFF8888FF; if (numcdroms == -1) { - strcpy(temp, psp_home); + strcpy(temp, HOME_DIR); strcat(temp, "cdroms"); numcdroms = parse_dir(temp, cdroms, MAXCDROMS); } if (numfloppies == -1) { - strcpy(temp, psp_home); + strcpy(temp, HOME_DIR); strcat(temp, "disks"); numfloppies = parse_dir(temp, floppies, MAXFLOPPIES); } if (numimaps == -1) { - strcpy(temp, psp_home); + strcpy(temp, HOME_DIR); strcat(temp, "imaps"); numimaps = parse_dir(temp, imaps, MAXIMAPS); } @@ -947,8 +947,8 @@ void handle_menu(SceCtrlData pad, char *message) buttons = pad.buttons ^ oldButtons; // set if button changed oldButtons = pad.buttons; - if (buttons & (SCE_CTRL_LEFT | SCE_CTRL_RIGHT)) - if (pad.buttons & SCE_CTRL_LEFT) + if (buttons & (SCE_CTRL_UP | SCE_CTRL_DOWN)) + if (pad.buttons & SCE_CTRL_UP) { // dec index idx = idx>0 ? idx-1 : 2; @@ -962,7 +962,7 @@ void handle_menu(SceCtrlData pad, char *message) idx = idx>0 ? idx-1 : 2; } } - else if (pad.buttons & SCE_CTRL_RIGHT) + else if (pad.buttons & SCE_CTRL_DOWN) { // inc index idx = idx<2 ? idx+1 : 0; @@ -977,38 +977,38 @@ void handle_menu(SceCtrlData pad, char *message) } } - if (buttons & SCE_CTRL_UP) - if (pad.buttons & SCE_CTRL_UP) + if (buttons & SCE_CTRL_LEFT) + if (pad.buttons & SCE_CTRL_LEFT) sel = sel>0 ? sel-1 : max-1; - if (buttons & SCE_CTRL_DOWN) - if (pad.buttons & SCE_CTRL_DOWN) + if (buttons & SCE_CTRL_RIGHT) + if (pad.buttons & SCE_CTRL_RIGHT) sel = sel 0) + vita2d_font_draw_text(font, 14, FONT_SIZE*1.5, fc, FONT_SIZE, temp); if (buttons & SCE_CTRL_CROSS) if (pad.buttons & SCE_CTRL_CROSS) @@ -1097,10 +1097,6 @@ void handle_menu(SceCtrlData pad, char *message) } } -void show_msg(char *message, uint32 fc, uint32 bc) -{ -} - /* * Mac VBL interrupt */ @@ -1116,13 +1112,10 @@ void VideoInterrupt(void) uint32 buttons; static uint32 oldButtons = 0; static uint32 qualifiers = 0; - static bool input_mode = false; static bool show_menu = false; static bool show_on_right = true; static int frame_cnt = 0; - static char msgtxt[68] = { '\0' }; - uint32 fc = 0xFF000000; - uint32 bc = 0xFF8888FF; + uint32 fc = 0xFF8888FF; static int stick[16] = { -8, -8, -6, -4, -2, -1, -1, 0, 0, 0, 1, 1, 2, 4, 6, 8 }; sceCtrlReadBufferPositive(0, &pad, 1); @@ -1130,19 +1123,12 @@ void VideoInterrupt(void) buttons = pad.buttons ^ oldButtons; // set if button changed oldButtons = pad.buttons; - if (buttons & SCE_CTRL_START) - if (pad.buttons & SCE_CTRL_START) - input_mode = input_mode ? false : true; // toggle input mode - if (buttons & SCE_CTRL_SELECT) if (pad.buttons & SCE_CTRL_SELECT) show_menu = show_menu ? false : true; // toggle imap/floppy/cdrom menu - if (input_mode) - show_menu = false; // select used for qualifiers in OSK else { qualifiers = 0; // clear qualifiers when exit OSK - msgtxt[0] = 0; // clear onscreen message } // refresh video @@ -1152,6 +1138,7 @@ void VideoInterrupt(void) if (frame_cnt < 0) { vita2d_start_drawing(); + vita2d_clear_screen(); frame_cnt = frame_skip - 1; if (psp_screen_d == VDEPTH_4BIT) @@ -1163,12 +1150,15 @@ void VideoInterrupt(void) else if (psp_screen_d == VDEPTH_32BIT) refresh24(); + if (show_menu) + handle_menu(pad); + vita2d_end_drawing(); vita2d_swap_buffers(); } // process inputs - if (!input_mode && !show_menu) + if (!show_menu) { if (touch.reportNum <= 0 && mouseClickedTouch) { @@ -1252,13 +1242,13 @@ void VideoInterrupt(void) ADBMouseUp(1); } } + } + + if (keyboard_hid_handle) { + handle_keyboard(); } } - if (keyboard_hid_handle) { - handle_keyboard(); - } - // Emergency quit requested? Then quit if (emerg_quit) QuitEmulator();