├── LICENSE ├── makepico8 └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Astorek86 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /makepico8: -------------------------------------------------------------------------------- 1 | # If you haven't done before, you should replace the "init"-value in cmdline.txt with these: 2 | # init=/bin/bash -c "mount -t proc proc /proc; mount -t sysfs sys /sys; mount /boot; source /boot/makepico8" 3 | 4 | # Preconfiguring... 5 | mount -t tmpfs tmp /run 6 | mkdir -p /run/systemd 7 | mount / -o remount,rw 8 | 9 | # Remove init-Script and replace it with some options to prevent Console-Output 10 | sed -i 's| init=.*| loglevel=3 logo\.nologo fastboot|' /boot/cmdline.txt 11 | sed -i 's|console=tty1|console=tty3|' /boot/cmdline.txt 12 | 13 | # Create needed folders (if they don't exit already) 14 | mkdir -p /boot/pico-8/screenshots 15 | 16 | # Disable motd 17 | touch /boot/pico-8/.hushlogin 18 | 19 | # Create Group and User called "pico8" 20 | groupadd pico8 21 | useradd -d /boot/pico-8 -M -g pico8 -G video,audio,input -s /bin/bash pico8 22 | 23 | # Set the hostname to "pico8desktop" 24 | echo "pico8desktop" > /etc/hostname 25 | 26 | # Change /etc/fstab . Without root- or sudo-Permission, normal users aren't capable of writing vfat-Partition. 27 | # After these Changes, user "pico8" will be able to do so... 28 | picouid=$(id -u pico8) 29 | picogid=$(id -g pico8) 30 | sed -i "s/\(\/boot.*vfat.*\)defaults\(.*\)/\1rw,uid=$picouid,gid=$picogid\2/" /etc/fstab 31 | 32 | # Autologin the new User 33 | mkdir /etc/systemd/system/getty@tty1.service.d 34 | cat > /etc/systemd/system/getty@tty1.service.d/override.conf << EOF 35 | [Service] 36 | Type=simple 37 | ExecStart= 38 | ExecStart=-/sbin/agetty --skip-login --noclear --noissue --login-options "-f pico8" %I $TERM 39 | EOF 40 | 41 | # Start PICO8 after Login 42 | cat > /boot/pico-8/.profile << EOF 43 | PS1="" 44 | pgrep pico8 || (cd ~; amixer sset 'PCM' 80% > /dev/null 2>&1; ./pico8 > /dev/null 2>&1 -home /boot/pico-8 -desktop /boot/pico-8/screenshots -splore; sudo /sbin/shutdown -h now) 45 | EOF 46 | 47 | # Allow pico8 user to shutdown 48 | cat >> /etc/sudoers << EOF 49 | pico8 ALL=(ALL) NOPASSWD: /sbin/shutdown 50 | EOF 51 | 52 | #Postconfiguring... 53 | sync 54 | umount /boot 55 | mount / -o remount,ro 56 | sync 57 | sleep 5 58 | 59 | # Call Resize-Script 60 | /usr/lib/raspi-config/init_resize.sh 61 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pico-8: Desktop Console 2 | 3 | ![pico-8-paper-prototype](https://github.com/anthonycaccese/pico8-desktop-console/assets/1454947/4dd63356-214a-4558-97fe-020f0ad35769) 4 | 5 | The code in this repo heavily based on and inspired by the work of [Astorek86](https://github.com/Astorek86) who created a way to turn the GPi case + RaspberryPi Zero into a dedicated Pico-8 handheld. You can reference their original work here: https://github.com/Astorek86/Pico8-Script-for-GPi-Case. All credit to them for their original work and a huge thank you as well ❤️ 6 | 7 | In this repo are the changes I've made to that script while working on my own dedicated Pico-8 Console. My changes primarily remove all the aspects that were specific to the GPi case and adds elements that are specific to the version I am building (things like configuration for the square screen I will be using). 8 | 9 | ## Hardware 10 | 11 | Essentially I'll be building an all in one desktop console (screen and speakers included) similar in style/function to the classic Coleco tabletop arcade systems, Mac Classic or Vetrex. It will be dedicated to playing the awesome [Pico-8 fantasy console](https://www.lexaloffle.com/pico-8.php) and its amazing library of community developed games. Something you can turn on and start playing without any fuss. 12 | 13 | This is very much a work in progress 😊 so here is what I have so far... 14 | - `RaspberryPi Zero W:` you can use any RaspberryPi with this build. I just recommend that it has some way to access the internet as we'll be booting directly into Pico-8 Splore. 15 | - `Screen:` Goal is to use a 1:1 aspect ratio screen to match Pico-8's native square aspect ratio. I am using [this screen](https://a.aliexpress.com/_mtLhZdm) from AliExpress which is 4", 720x720 resolution and has a dedicated driver board with HDMI and power ports (making it super easy to set up) This screen does require custom settings in /config.txt which I'll outline in the software section below. 16 | - `Audio:` I am using this [amp](https://www.adafruit.com/product/3346) and these [speakers](https://www.adafruit.com/product/1669) its super easy to set up and fits well with the rest of the boards I am using. This does require you to have a raspberrypi with a header built in. I've added the configuration for these speakers into the steps below if you plan to use the same. 17 | 18 | I am working on the following... 19 | - `Case:` I created a quick "paper prototype" (cardboard really) to get a sense for the 3d model I'll create. I'll start working on that model over the next few weeks. When I have something I think will work i'll make sure to post the STLs as part of this repo. For now you can check out my initial prototype in this video: https://youtu.be/94ngQ8RXFYQ?feature=shared 20 | - `Controls:` The case will include at least 2 usb ports to be able to plug in controllers (up to 2 players) or mouse and keyboard. 21 | - `Power:` To keep things simple i'll just be focusing on creating a unit that can be plugged into the wall so... no battery (but I could explore that if the first version works out well) 22 | 23 | ## Software 24 | 25 | The primary aim for the software is to boot directly into Pico-8 Splore with as minimal a footprint as possible (while still enabling things like wifi). I also want to be able to shutdown the console directly from Pico-8 Splore and be able to control all aspects of the device with a usb controller. 26 | 27 | ### Steps 28 | 29 | 1. Download the lateset Raspbian Buster "Lite" from [RaspberryPi.org](https://downloads.raspberrypi.org/raspbian_lite_latest). We're using the lite version specifically because we'll be booting into Splore directly and won't need a desktop environment. 30 | 2. Unzip and write the Raspbian Buster "Lite" image to an SD card using your preferred image writing software (Win32DiskImager, Etcher, etc...) 31 | 4. After that's complete; plug the SD card back into your computer (you will need to make some changes on the `boot` partition before booting for the first time) 32 | 5. Download PICO-8 for RaspberryPi from https://www.lexaloffle.com/games.php?page=updates 33 | 6. Unzip the files from that archive to the `boot` partition of your SD card into a folder called `pico-8`. Your folder structure should look like this afterwards: 34 | ``` 35 | boot/ 36 | ├─ pico-8/ 37 | │ ├─ license.txt 38 | │ ├─ pico-8_manual.txt 39 | │ ├─ pico8 40 | │ ├─ pico8_64 41 | │ ├─ pico8_dyn 42 | │ ├─ pico8_gpio 43 | │ ├─ pico8.dat 44 | │ └─ readme_raspi.txt 45 | └─ (other files from the boot directory such as config.txt and cmdline.txt) 46 | ``` 47 | 6. *Optional but recommended*: Create a Folder named "carts" in the pico-8 directory you just made above and add some of your favourite cartridges in there. This will give you a direct list of games you can play in Splore when you don't have an internet connection. Your folder structure should look like this afterwards: 48 | ``` 49 | boot/ 50 | ├─ pico-8/ 51 | │ ├─ carts/ 52 | │ │ └─ (add your downloaded carts in .png or .p8 format here) 53 | │ ├─ license.txt 54 | │ ├─ pico-8_manual.txt 55 | │ ├─ pico8 56 | │ ├─ pico8_64 57 | │ ├─ pico8_dyn 58 | │ ├─ pico8_gpio 59 | │ ├─ pico8.dat 60 | │ └─ readme_raspi.txt 61 | └─ (other files from the boot directory such as config.txt and cmdline.txt) 62 | ``` 63 | 7. Edit `cmdline.txt` and replace this specific text `init=/usr/lib/raspi-config/init_resize.sh` with the following: 64 | ``` 65 | init=/bin/bash -c "mount -t proc proc /proc; mount -t sysfs sys /sys; mount /boot; source /boot/makepico8" 66 | ``` 67 | > This change sets up the first boot to call a script called makepico8 which will set up everything up. You'll add that script in the next step. 68 | 8. Download the `makepico8` script from this repo [here](https://raw.githubusercontent.com/anthonycaccese/pico8-desktop-console/main/makepico8) and copy it to your `boot` partition. Your folder structure should look like this afterwards: 69 | > Note: There is a section below that outlines what the makepico8 script does to help answer any questions. 70 | ``` 71 | boot/ 72 | ├─ pico-8/ 73 | │ ├─ carts/ 74 | │ │ └─ (add your downloaded carts in .png or .p8 format here) 75 | │ ├─ license.txt 76 | │ ├─ pico-8_manual.txt 77 | │ ├─ pico8 78 | │ ├─ pico8_64 79 | │ ├─ pico8_dyn 80 | │ ├─ pico8_gpio 81 | │ ├─ pico8.dat 82 | │ └─ readme_raspi.txt 83 | ├─ makepico8 84 | └─ (other files from the boot directory such as config.txt and cmdline.txt) 85 | ``` 86 | 9. Edit `config.txt` and replace its contents with the following. 87 | > [!IMPORTANT] 88 | > You should only do this step if you are using the same 720x720 screen that I listed in the hardware section. If you going to plug this into a regular monitor or tv you won't need to make this change to config.txt and you can skip this step. 89 | ``` 90 | [all] 91 | # 720x720 display config 92 | hdmi_force_hotplug=1 93 | config_hdmi_boost=10 94 | hdmi_group=2 95 | hdmi_mode=87 96 | hdmi_timings=720 0 100 20 100 720 0 20 8 20 0 0 0 60 0 48000000 6 97 | start_x=0 98 | ``` 99 | 10. *Optional but recommended*: If you want wifi to be set up out of the box; Create a file called `wpa_supplicant.conf` with the following content and replace all values between `< >` with your own. Add this file to the `boot` partition. 100 | ``` 101 | ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev 102 | update_config=1 103 | country= 104 | 105 | network={ 106 | ssid="" 107 | psk="" 108 | key_mgmt=WPA-PSK 109 | } 110 | ``` 111 | 11. *Optional but recommended*: If you want to be able to SSH into your device; create a filed called `ssh` (no extention) and add it to the `boot` partition. 112 | 113 | ### What does the `makepico8` script do? 114 | 115 | - It creates a new user called "pico8" and sets the home directory to `/boot/pico-8` 116 | - It changes the permission on the "boot" partition in /etc/fstab, because in Linux, only root is allowed to write on VFAT-Partitions. This script changes that and gives permission to the "pico8" user and the "pico8" group. 117 | - It modifies systemd-files to allow the "pico8" user to autologin (so a keyboard is not needed). 118 | - It modifies /etc/sudoers to enable to the "pico8" user to trigger a device shutdown (so you can shutdown the device directly from Splore). 119 | - It sets values to reduce/remove console output during boot. 120 | 121 | This script only runs on first boot to essentially "make" a dedicated Pico-8 device (hence its name 😀) and on subsequent boots its not called again. You can see that by checking how cmdline.txt is updated after your first boot. 122 | 123 | ### First Boot 124 | 125 | - After you have completed the above steps you should be able to plug your SD card into your RaspeberryPi and turn it on. 126 | - On first boot the makepico8 script will conduct all the setup described above and when finished your raspberrypi should reboot directly into Pico-8 Splore. 127 | - At this point, if everything worked correctly, you will be able to navigate splore, download carts from the BBS (if you set up networking) and see your manually added carts in the file menu. You should also be able to shutdown the device directly from splore. 128 | 129 | ### Audio 130 | > [!IMPORTANT] 131 | > You should only follow these steps if you are using the same amp that I listed in the hardware section above. These steps will only work with that specific amp. The source for the steps are located here https://learn.adafruit.com/adafruit-speaker-bonnet-for-raspberry-pi/raspberry-pi-usage 132 | 1. Add the following to config.txt 133 | ``` 134 | # adafruit speaker bonnet 135 | dtoverlay=hifiberry-dac 136 | dtoverlay=i2s-mmap 137 | ``` 138 | 2. add an `asound.conf` file to /etc with the followig contents 139 | ``` 140 | pcm.speakerbonnet { 141 | type hw card 0 142 | } 143 | pcm.!default { 144 | type plug 145 | slave.pcm "dmixer" 146 | } 147 | pcm.dmixer { 148 | type dmix 149 | ipc_key 1024 150 | ipc_perm 0666 151 | slave { 152 | pcm "speakerbonnet" 153 | period_time 0 154 | period_size 1024 155 | buffer_size 8192 156 | rate 44100 157 | channels 2 158 | } 159 | } 160 | ctl.dmixer { 161 | type hw card 0 162 | } 163 | ``` 164 | 165 | ## Additional Notes 166 | 167 | ### Videos (In Progress) 168 | - Screen & Software Test: https://youtu.be/JKJjj8BBlpU 169 | - Paper Prototype: https://youtu.be/94ngQ8RXFYQ 170 | 171 | ### Boot Time 172 | - First boot is the longest as it runs through the script to set things up. Subsequent boots take between 30 to 40 seconds from my testing so far. There may be ways to shorten this further but its not so long that I am going to focus on it just yet (there are lots of more fun things to do first). 173 | 174 | ### Getting rid of the password warning 175 | - Login over SSH with username `pi` / password `raspberry` 176 | - type `passwd` and follow the prompts 177 | 178 | ## Credits 179 | 180 | Thank you to [Astorek86](https://github.com/Astorek86) for their original work here: https://github.com/Astorek86/Pico8-Script-for-GPi-Case 181 | Thank you to [NerdyTeachers](https://nerdyteachers.com/PICO-8/) for their tips on how to reduce boot times. 182 | --------------------------------------------------------------------------------