Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPad Version #233

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
60d961b
iPad Version
mattuna15 Jan 1, 2020
959572f
Update README.md
mattuna15 Jan 1, 2020
d747371
Update README.md
mattuna15 Jan 1, 2020
4121758
- Load/Save now writes to home/documents/myfile.txt - 1 file at the m…
mattuna15 Jan 2, 2020
a5096a9
Fix filename memory locations.
mattuna15 Jan 2, 2020
3849468
Add Function keys window on long press.
mattuna15 Jan 3, 2020
63652d9
Update README.md
mattuna15 Jan 3, 2020
7a3d955
Update README.md
mattuna15 Jan 3, 2020
ecc4f3e
Update README.md
mattuna15 Jan 3, 2020
9aeaca5
Add a gamepad controller view
mattuna15 Jan 3, 2020
1b15411
Merge branch 'master' into iPad -- R36
mattuna15 Jan 4, 2020
db61af8
Move SDL as submodule of the project.
mattuna15 Jan 4, 2020
0fc098f
Added Readme details
mattuna15 Jan 4, 2020
576bb6e
Switch to objc_msgsend to allow compatibility with new emulator relea…
mattuna15 Jan 4, 2020
041239f
file moves
mattuna15 Jan 4, 2020
ae4c52c
Add conditionals to SDL.h include
mattuna15 Jan 4, 2020
4b3f531
use conditionals for loading and saving
mattuna15 Jan 4, 2020
025238b
Add conditionals into main.c
mattuna15 Jan 4, 2020
f00391e
remove rom.sym
mattuna15 Jan 4, 2020
8fb50d3
Remove Whitespaces
mattuna15 Jan 5, 2020
6d8f9ca
Accept PRG and BIN files.
mattuna15 Jan 5, 2020
d4ee804
Few review tidy ups.
mattuna15 Jan 5, 2020
3b5322c
Update README.md
mattuna15 Jan 5, 2020
9a592d8
Update README.md
mattuna15 Jan 5, 2020
e017546
Remove submodule and add zip file
mattuna15 Jan 5, 2020
084588e
Update README.md
mattuna15 Jan 5, 2020
c87e7f1
Move receive file from App delegate to SDL_Events
mattuna15 Jan 5, 2020
ceb1bb8
Remove Loadfile from message observer
mattuna15 Jan 5, 2020
f9e4ec2
Switch to vanilla SDL code.
mattuna15 Jan 5, 2020
e593549
Update license
mattuna15 Jan 5, 2020
18c9bf1
Review tidy up
mattuna15 Jan 5, 2020
04fc141
Switch spaces to tabs for existing code.
mattuna15 Jan 6, 2020
815ff05
Use spaces indentation for .json
mattuna15 Jan 6, 2020
aab246a
More space/tab changes
mattuna15 Jan 6, 2020
b65c0dd
Add new line at eof .json files
mattuna15 Jan 6, 2020
6918058
Add new keyboard buttons.
mattuna15 Jan 7, 2020
e814d94
Editor style checks.
mattuna15 Jan 7, 2020
53bf65e
Review comments around filename handling.
mattuna15 Jan 7, 2020
9ba3b23
Whitespace character
mattuna15 Jan 7, 2020
7e7376a
Fix "SDL.h" build problem.
mattuna15 Jan 7, 2020
eed3b69
Add joystick controller.
mattuna15 Jan 9, 2020
6e29c55
Remove images
mattuna15 Jan 9, 2020
fa36e1e
editor config fixes
mattuna15 Jan 9, 2020
061f343
Add compiler options with an "optimised build"
mattuna15 Jan 9, 2020
54587ac
Scheme data
mattuna15 Jan 9, 2020
3f5a64e
Scheme editorconfig changes.
mattuna15 Jan 9, 2020
b828b1c
Fix slow joystick controls.
mattuna15 Jan 10, 2020
a1b8f68
Add support for d-pad controllers.
mattuna15 Jan 10, 2020
cd4cec2
Whitespace changes.
mattuna15 Jan 10, 2020
2c33f6a
Update README.md
mattuna15 Jan 11, 2020
d03b928
Update project xcode settings for sound.
mattuna15 Jan 12, 2020
3a3b73b
Update readme with iPad release details and add to project.
mattuna15 Jan 13, 2020
c02231d
Fix info.plist for .ipa validation
mattuna15 Jan 13, 2020
b38b33b
Add file sharing and files app direct access.
mattuna15 Jan 14, 2020
8d11a35
Version updates.
mattuna15 Jan 14, 2020
5e45a08
Add MAC OSX Target
mattuna15 Jan 15, 2020
fe1063f
Sort out includes.
mattuna15 Jan 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ indent_style = space
[*.md]
indent_style = space

[{*.css,*.html,*.js}]
[{*.css,*.html,*.js,*.json,*.xib,*.xcscheme}]
indent_style = space
59 changes: 59 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,62 @@ x16emu.js
x16emu.wasm
x16emu.worker.js

xcode/Frameworks/SDL/Xcode-iOS/Test/Info.plist
xcode/Frameworks/SDL/Xcode-iOS/Test/README
xcode/Frameworks/SDL/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj
xcode/Frameworks/SDL/Xcode/SDL/Info-Framework.plist
xcode/Frameworks/SDL/Xcode/SDL/pkg-support/SDL.info
xcode/Frameworks/SDL/Xcode/SDL/pkg-support/sdl_logo.pdf
xcode/Frameworks/SDL/Xcode/SDL/pkg-support/resources/License.txt
xcode/Frameworks/SDL/Xcode/SDL/pkg-support/resources/ReadMe.txt
xcode/Frameworks/SDL/Xcode/SDL/pkg-support/resources/SDL_DS_Store
xcode/Frameworks/SDL/Xcode/SDL/SDL.xcodeproj/project.pbxproj
xcode/Frameworks/SDL/Xcode/SDLTest/TestDropFile-Info.plist
xcode/Frameworks/SDL/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj
xcode/Frameworks/SDL/Xcode/XcodeDocSet/Doxyfile
xcode/X16/__MACOSX/JoyStickView/._JoyStickView.xcodeproj
xcode/X16/__MACOSX/JoyStickView/JoyStickViewTests/._JoyStickViewMonitorTests.swift
xcode/X16/__MACOSX/JoyStickView/JoyStickViewTests/._JoyStickViewTests.swift
xcode/X16/__MACOSX/JoyStickView/Resources/._Info.plist
xcode/X16/__MACOSX/JoyStickView/Src/._CoreGraphics+Additions.swift
xcode/X16/__MACOSX/JoyStickView/Src/._JoyStickView.h
xcode/X16/__MACOSX/JoyStickView/Src/._JoyStickView.swift
xcode/X16/__MACOSX/JoyStickView/Src/._JoyStickViewMonitor.swift
xcode/X16/__MACOSX/SDL/include/._SDL_config_iphoneos.h
xcode/X16/__MACOSX/SDL/include/._SDL_events.h
xcode/X16/__MACOSX/SDL/include/._SDL_gesture.h
xcode/X16/__MACOSX/SDL/include/._SDL_main.h
xcode/X16/__MACOSX/SDL/include/._SDL_platform.h
xcode/X16/__MACOSX/SDL/include/._SDL_scancode.h
xcode/X16/__MACOSX/SDL/include/._SDL_stdinc.h
xcode/X16/__MACOSX/SDL/include/._SDL_touch.h
xcode/X16/__MACOSX/SDL/src/._SDL.c
xcode/X16/__MACOSX/SDL/src/audio/._SDL_audio.c
xcode/X16/__MACOSX/SDL/src/audio/._SDL_audiocvt.c
xcode/X16/__MACOSX/SDL/src/events/._SDL_dropevents.c
xcode/X16/__MACOSX/SDL/src/events/._SDL_dropevents_c.h
xcode/X16/__MACOSX/SDL/src/events/._SDL_events_c.h
xcode/X16/__MACOSX/SDL/src/events/._SDL_gesture.c
xcode/X16/__MACOSX/SDL/src/events/._SDL_gesture_c.h
xcode/X16/__MACOSX/SDL/src/events/._SDL_keyboard.c
xcode/X16/__MACOSX/SDL/src/events/._SDL_keyboard_c.h
xcode/X16/__MACOSX/SDL/src/hidapi/testgui/._TestGUI.app.in
xcode/X16/__MACOSX/SDL/src/video/uikit/._SDL_uikitappdelegate.h
xcode/X16/__MACOSX/SDL/src/video/uikit/._SDL_uikitappdelegate.m
xcode/X16/__MACOSX/SDL/src/video/uikit/._SDL_uikitclipboard.h
xcode/X16/__MACOSX/SDL/src/video/uikit/._SDL_uikitevents.m
xcode/X16/__MACOSX/SDL/src/video/uikit/._SDL_uikitviewcontroller.h
xcode/X16/__MACOSX/SDL/src/video/uikit/._SDL_uikitviewcontroller.m
xcode/X16/__MACOSX/SDL/Xcode-iOS/Demos/._Demos.xcodeproj
xcode/X16/__MACOSX/SDL/Xcode-iOS/SDL/._SDL.xcodeproj
xcode/X16/__MACOSX/SDL/Xcode-iOS/SDLtest/._SDL2test.xcodeproj
xcode/X16/__MACOSX/SDL/Xcode-iOS/Template/SDL iOS Application/.____PROJECTNAME___.xcodeproj
xcode/X16/__MACOSX/SDL/Xcode-iOS/Test/._TestiPhoneOS.xcodeproj
xcode/X16/__MACOSX/SDL/Xcode/SDL/._SDL.xcodeproj
xcode/X16/__MACOSX/SDL/Xcode/SDLTest/._SDLTest.xcodeproj
xcode/Frameworks/SDL/test/.testmultiaudio.c.swp
xcode/Frameworks/SDL/test/testaudioinfo
xcode/Frameworks/SDL/test/testmultiaudio
xcode/Frameworks/SDL/Xcode-iOS/Demos/Demos.xcodeproj/project.xcworkspace/contents.xcworkspacedata
xcode/Frameworks/SDL/Xcode-iOS/Demos/Demos.xcodeproj/xcuserdata/mpe18.xcuserdatad/xcschemes/xcschememanagement.plist
xcode/Frameworks/SDL/Xcode/SDL/SDL.xcodeproj/xcuserdata/mpe18.xcuserdatad/xcschemes/xcschememanagement.plist
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ You can build a ROM image yourself using the [build instructions][x16rom-build]

Install SDL2 using `brew install sdl2`.

### iPad Build

Using Xcode open the project file in the emulator Xcode directory.
A copy of the framework source required is included as a zip file (Frameworks.zip).
Extract it in place before building.

Choose your device or simulator and press run.

### Linux Build

The SDL2 development package is available as a distribution package with most major versions of Linux:
Expand Down Expand Up @@ -162,7 +170,6 @@ The emulator will interpret filenames relative to the directory it was started i

To avoid incompatibility problems between the PETSCII and ASCII encodings, use lower case filenames on the host side, and unshifted filenames on the X16 side.


Dealing with BASIC Programs
---------------------------

Expand Down Expand Up @@ -211,6 +218,29 @@ When `-debug` is selected the No-Operation $FF will break into the debugger auto

Effectively keyboard routines only work when the debugger is running normally. Single stepping through keyboard code will not work at present.

iPad
----


### Release 0.1

* Files are saved in the $HOME/Documents folder
* On-screen joystick and external Gamecontrollers can be accessed by using a Long Press on the main window and pressing the appropriate button
* Function keys, a reset button and "ESC" button are available on the on-sceen keyboard
* To run PRG files:
1. Browse to the file in the "File App"
2. Select any BIN files you need and open them with the X16 app
3. Select the PRG file you wish to run.
4. The emulator will open and load the PRG
5. "RUN" will be displayed when it has loaded and is ready to go. Press ENTER at this point
* BASIC Code can be pasted by tapping the "Paste" Icon on the software keyboard
* Sound is now supported by default

TODO:
* BAS files are not yet able to be loaded from the Files app
* Mouse support
* Improve and optimise UI
* Implement command line parameters in UI such as uart and debugging tools

Wiki
----
Expand Down
2 changes: 2 additions & 0 deletions debugger.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
#include <stdio.h>
#include <inttypes.h>
#include <SDL.h>

#include "glue.h"
#include "disasm.h"
#include "memory.h"

#include "video.h"
#include "cpu/fake6502.h"
#include "debugger.h"
Expand Down
2 changes: 1 addition & 1 deletion disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <stdio.h>
#include <inttypes.h>
#include <string.h>
#include "glue.h"
#include "memory.h"

#include "cpu/mnemonics.h" // Automatically generated mnemonic table.

// *******************************************************************************************
Expand Down
4 changes: 4 additions & 0 deletions javascript_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#include <string.h>
#include "glue.h"

#ifdef WITH_YM2151
void init_audio(void);
#endif

char javascript_text_data[65536];

void
Expand Down
1 change: 1 addition & 0 deletions joystick.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <stdint.h>
#include <stdio.h>
#include <SDL.h>

#include "glue.h"
#include "via.h"

Expand Down
64 changes: 34 additions & 30 deletions keyboard.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <SDL.h>
#include <stdio.h>
#include <stdbool.h>
#include "glue.h"
Expand Down Expand Up @@ -225,41 +224,46 @@ void
handle_keyboard(bool down, SDL_Keycode sym, SDL_Scancode scancode)
{
if (down) {
if (log_keyboard) {
printf("DOWN 0x%02X\n", scancode);
fflush(stdout);
#if __APPLE__ && (TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE)
// iOS device
if (scancode == SDL_SCANCODE_MENU) {
sendNotification("ShowKeyboard");
}
#endif

if (log_keyboard) {
printf("DOWN 0x%02X\n", scancode);
fflush(stdout);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indenting is incorrect.


int ps2_scancode = ps2_scancode_from_SDL_Scancode(scancode);
if (ps2_scancode == 0xff) {
// "Pause/Break" sequence
ps2_buffer_add(0, 0xe1);
ps2_buffer_add(0, 0x14);
ps2_buffer_add(0, 0x77);
ps2_buffer_add(0, 0xe1);
ps2_buffer_add(0, 0xf0);
ps2_buffer_add(0, 0x14);
ps2_buffer_add(0, 0xf0);
ps2_buffer_add(0, 0x77);
int ps2_scancode = ps2_scancode_from_SDL_Scancode(scancode);
if (ps2_scancode == 0xff) {
// "Pause/Break" sequence
ps2_buffer_add(0, 0xe1);
ps2_buffer_add(0, 0x14);
ps2_buffer_add(0, 0x77);
ps2_buffer_add(0, 0xe1);
ps2_buffer_add(0, 0xf0);
ps2_buffer_add(0, 0x14);
ps2_buffer_add(0, 0xf0);
ps2_buffer_add(0, 0x77);
} else {
if (ps2_scancode & EXTENDED_FLAG) {
ps2_buffer_add(0, 0xe0);
}
ps2_buffer_add(0, ps2_scancode & 0xff);
}
} else {
if (log_keyboard) {
printf("UP 0x%02X\n", scancode);
fflush(stdout);
}

int ps2_scancode = ps2_scancode_from_SDL_Scancode(scancode);
if (ps2_scancode & EXTENDED_FLAG) {
ps2_buffer_add(0, 0xe0);
}
ps2_buffer_add(0, 0xf0); // BREAK
ps2_buffer_add(0, ps2_scancode & 0xff);
}
} else {
if (log_keyboard) {
printf("UP 0x%02X\n", scancode);
fflush(stdout);
}

int ps2_scancode = ps2_scancode_from_SDL_Scancode(scancode);
if (ps2_scancode & EXTENDED_FLAG) {
ps2_buffer_add(0, 0xe0);
}
ps2_buffer_add(0, 0xf0); // BREAK
ps2_buffer_add(0, ps2_scancode & 0xff);
}
}


9 changes: 9 additions & 0 deletions keyboard.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
#if __APPLE__
#include <TargetConditionals.h>
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
#include "ios_functions.h"
#endif
#endif

#include <SDL.h>

void handle_keyboard(bool down, SDL_Keycode sym, SDL_Scancode scancode);

46 changes: 43 additions & 3 deletions loadsave.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@
#include <dirent.h>
#include <unistd.h>
#include "glue.h"

#include "memory.h"

#include "video.h"
#include "rom_symbols.h"

#if __APPLE__
#include <TargetConditionals.h>
#endif

#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

Expand Down Expand Up @@ -51,7 +57,17 @@ create_directory_listing(uint8_t *data)
*data++ = 'C';
*data++ = 0;

if (!(dirp = opendir("."))) {
#if __APPLE__ && (TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do this concatening a few times in this file.
Maybe extract it to some static helper function?
You can move the ifdef to it too.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks I'll take a look.

char filename[255];
//use correct file location for ios
strcpy(filename,getenv("HOME"));
//concatenating the path string returned from HOME
strcat(filename,"/Documents/.");
#else
const char *filename = ".";
#endif

if (!(dirp = opendir(filename))) {
return 0;
}
while ((dp = readdir(dirp))) {
Expand Down Expand Up @@ -132,7 +148,19 @@ LOAD()
RAM[STATUS] = 0;
a = 0;
} else {
FILE *f = fopen(filename, "rb");
#if __APPLE__ && (TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE)
//use correct file location for ios
char full_filename[255];
//concatenating the path string returned from HOME
strcpy(full_filename, getenv("HOME"));
strcat(full_filename, "/Documents/");
strcat(full_filename, filename);
#else
char *full_filename = filename;
#endif

FILE *f = fopen(full_filename, "rb");

if (!f) {
a = 4; // FNF
RAM[STATUS] = a;
Expand Down Expand Up @@ -209,8 +237,20 @@ SAVE()
a = 0;
return;
}
//use correct file location for ios
#if __APPLE__ && (TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE)
//use correct file location for ios
char full_filename[255];
//concatenating the path string returned from HOME
strcpy(full_filename, getenv("HOME"));
strcat(full_filename, "/Documents/");
strcat(full_filename, filename);
#else
char *full_filename = filename;
#endif

FILE *f = fopen(full_filename, "wb");

FILE *f = fopen(filename, "wb");
if (!f) {
a = 4; // FNF
RAM[STATUS] = a;
Expand Down
Loading