fetch apple roms and disks; read from resources (in some places)

This commit is contained in:
Christopher A. Mosher 2022-12-06 18:00:53 -05:00
parent b8b83e6752
commit 2093696a5e
16 changed files with 115 additions and 205 deletions

View File

@ -36,7 +36,29 @@ jobs:
"fetch-apple":
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- name: "Fetch"
run: |
set -x
cd share/Resources/apple
./fetch.sh
- uses: "actions/upload-artifact@v3"
with:
name: "apple2-artifacts"
path: "share/Resources/apple/stage/*"
"build":
needs:
- "build-roms"
- "fetch-apple"
strategy:
matrix:
include:
@ -76,6 +98,11 @@ jobs:
name: "epple2-roms"
path: "share/Resources/rom"
- uses: "actions/download-artifact@v3"
with:
name: "apple2-artifacts"
path: "share/Resources/apple/stage"
- name: "Build"
run: "./bin/build.sh"
@ -91,175 +118,3 @@ jobs:
tmp/cpack/*.deb
tmp/cpack/*.dmg
tmp/cpack/*.exe
# "build-epple2-ubuntu":
# needs: "build-roms"
# runs-on: "ubuntu-latest"
# steps:
# - name: "Prepare runner"
# run: |
# set -x
# sudo apt-get update -qqqq
# sudo apt-get install -qqqq libsdl2-dev tree
#
# - uses: "actions/checkout@v3"
#
# - name: "Build"
# run: |
# set -x
# mkdir build
# cd build
# cmake ..
# cmake --build .
#
# - uses: "actions/download-artifact@v3"
# with:
# name: "epple2-roms"
# path: "build/epple2-roms"
#
# - name: "Stage"
# run: |
# set -x
# pwd
# cd build
# mkdir -p stage/usr/local/bin
# mkdir -p stage/usr/local/etc/epple2
# mkdir -p stage/usr/local/lib/epple2/system
# mkdir -p stage/usr/local/lib/epple2/cards
# cp src/epple2 stage/usr/local/bin/
# cp conf/*.conf stage/usr/local/etc/epple2/
# cp epple2-roms/epple2sys.a65 stage/usr/local/lib/epple2/system/
# cp epple2-roms/stdout.a65 stage/usr/local/lib/epple2/cards/
# cp epple2-roms/stdin.a65 stage/usr/local/lib/epple2/cards/
# cp epple2-roms/clock.a65 stage/usr/local/lib/epple2/cards/
# tree stage
#
# - name: "Package"
# uses: "jiro4989/build-deb-action@v2"
# with:
# package: "${{ env.name }}"
# desc: "${{ env.desc }}"
# maintainer: "${{ github.repository_owner }}"
# version: "${{ github.ref }}"
# arch: "amd64"
# package_root: "build/stage"
# depends: "${{ env.deb_depends }}"
#
# - uses: "softprops/action-gh-release@v1"
# with:
# files: |
# *.deb
#
#
#
# "build-epple2-macos":
# needs: "build-roms"
# runs-on: "macos-latest"
# steps:
# - name: "Prepare runner"
# run: |
# set -x
# HOMEBREW_NO_AUTO_UPDATE=1 brew install sdl2 tree
#
# - uses: "actions/checkout@v3"
#
# - name: "Build"
# run: |
# set -x
# mkdir build
# cd build
# cmake ..
# cmake --build .
#
# - uses: "actions/download-artifact@v3"
# with:
# name: "epple2-roms"
# path: "build/epple2-roms"
#
# - name: "Stage"
# run: |
# set -x
# pwd
# cd build
# mkdir -p stage/local/bin
# mkdir -p stage/local/etc/epple2
# mkdir -p stage/local/lib/epple2/system
# mkdir -p stage/local/lib/epple2/cards
# cp src/epple2 stage/local/bin/
# cp conf/*.conf stage/local/etc/epple2/
# cp epple2-roms/epple2sys.a65 stage/local/lib/epple2/system/
# cp epple2-roms/stdout.a65 stage/local/lib/epple2/cards/
# cp epple2-roms/stdin.a65 stage/local/lib/epple2/cards/
# cp epple2-roms/clock.a65 stage/local/lib/epple2/cards/
# cp /usr/local/lib/libSDL2.dylib stage/local/bin/
# tree stage
#
# - name: "Package"
# run: |
# set -x
# pkgbuild --identifier nu.mine.mosher.$name --root build/stage --install-location /usr $name.pkg
#
# - uses: "softprops/action-gh-release@v1"
# with:
# files: |
# *.pkg
#
#
#
# "build-epple2-windows":
# needs: "build-roms"
# runs-on: "windows-latest"
# steps:
# - name: "Prepare runner"
# run: |
# Invoke-WebRequest -Uri "https://github.com/libsdl-org/SDL/releases/download/release-2.24.2/SDL2-devel-2.24.2-VC.zip" -OutFile "C:/Program Files/SDL2-devel-VC.zip"
# Expand-Archive -LiteralPath "C:/Program Files/SDL2-devel-VC.zip" -DestinationPath "C:/Program Files/"
#
# - uses: "actions/checkout@v3"
#
# - name: "Build"
# shell: "bash"
# run: |
# set -x
# mkdir build
# cd build
# cmake ..
# cmake --build .
#
# - uses: "actions/download-artifact@v3"
# with:
# name: "epple2-roms"
# path: "build/epple2-roms"
#
# - name: "Stage"
# shell: "bash"
# run: |
# set -x
# pwd
# cd build
# mkdir -p stage/epple2/etc/epple2
# mkdir -p stage/epple2/lib/epple2/system
# mkdir -p stage/epple2/lib/epple2/cards
# cp src/Debug/epple2.exe stage/epple2/
# cp conf/*.conf stage/epple2/etc/epple2/
# cp epple2-roms/epple2sys.a65 stage/epple2/lib/epple2/system/
# cp epple2-roms/stdout.a65 stage/epple2/lib/epple2/cards/
# cp epple2-roms/stdin.a65 stage/epple2/lib/epple2/cards/
# cp epple2-roms/clock.a65 stage/epple2/lib/epple2/cards/
# cp "C:/Program Files/SDL2-2.24.2/lib/x64/SDL2.dll" stage/epple2/
#
# - name: "Package"
# uses: "thedoctor0/zip-release@main"
# with:
# directory: "build/stage"
# path: "${{ env.name }}"
# filename: "${{ env.name }}-windows.zip"
#
# - uses: "softprops/action-gh-release@v1"
# with:
# files: |
# build/stage/*.zip

View File

@ -139,10 +139,26 @@ conf/epple2.a2pbare.conf
conf/epple2.a2pdos33.conf
conf/epple2.a2ploaded.conf
conf/epple2.visual6502.conf
cpu/transistors
rom/epple2sys.a65
rom/stdout.a65
rom/clock.a65
rom/stdin.a65
apple/stage/13-disk2.a65
apple/stage/16-disk2.a65
apple/stage/a2-monitor.a65
apple/stage/a2-intbasic.a65
apple/stage/a2-other.a65
apple/stage/a2p-monitor.a65
apple/stage/a2p-applesoft.a65
apple/stage/original31sysmas.d13.woz
apple/stage/original32sysmasstd.d13.woz
apple/stage/original32sysmaspls.d13.woz
apple/stage/original321sysmasstd.d13.woz
apple/stage/original321sysmaspls.d13.woz
apple/stage/original330sysmas.do.woz
apple/stage/original331sysmas.do.woz
apple/stage/original332sysmas.do.woz
)
list(TRANSFORM resources PREPEND "share/Resources/")

3
share/Resources/apple/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/*.zip
/apple2/
/stage/

25
share/Resources/apple/fetch.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/sh
curl -LO https://github.com/cmosher01/Apple-II-System-Masters/releases/download/v1.1.0/apple2sysmas.zip
unzip apple2sysmas.zip
curl -LO https://github.com/cmosher01/Apple-II-Source/releases/download/v1.1.2/apple2sys.zip
unzip apple2sys.zip
mkdir stage
cp ./apple2/dos/controller/13sector/disk2.a65 ./stage/13-disk2.a65
cp ./apple2/dos/controller/16sector/disk2.a65 ./stage/16-disk2.a65
cp ./apple2/system/monitor/apple2/monitor.a65 ./stage/a2-monitor.a65
cp ./apple2/system/intbasic/intbasic.a65 ./stage/a2-intbasic.a65
cp ./apple2/system/other/other.a65 ./stage/a2-other.a65
cp ./apple2/system/monitor/apple2plus/monitor.a65 ./stage/a2p-monitor.a65
cp ./apple2/system/applesoft/applesoft.a65 ./stage/a2p-applesoft.a65
cp ./apple2/dos/system/dos310/original31sysmas.d13.woz ./stage/original31sysmas.d13.woz
cp ./apple2/dos/system/dos320/original32sysmaspls.d13.woz ./stage/original32sysmaspls.d13.woz
cp ./apple2/dos/system/dos320/original32sysmasstd.d13.woz ./stage/original32sysmasstd.d13.woz
cp ./apple2/dos/system/dos321/original321sysmaspls.d13.woz ./stage/original321sysmaspls.d13.woz
cp ./apple2/dos/system/dos321/original321sysmasstd.d13.woz ./stage/original321sysmasstd.d13.woz
cp ./apple2/dos/system/dos330/original330sysmas.do.woz ./stage/original330sysmas.do.woz
cp ./apple2/dos/system/dos331/original331sysmas.do.woz ./stage/original331sysmas.do.woz
cp ./apple2/dos/system/dos332/original332sysmas.do.woz ./stage/original332sysmas.do.woz

View File

@ -31,4 +31,4 @@ slot 6 disk13
import slot 6 rom 0 13-disk2.a65
# Insert DOS 3.1 System Master disk into drive 1
#load slot 6 drive 1 clean31sysmas_stock_rawdos.dsk.woz
load slot 6 drive 1 original31sysmas.d13.woz

View File

@ -37,4 +37,4 @@ slot 6 disk
import slot 6 rom 0 16-disk2.a65
# Insert DOS 3.3 System Master disk (original version) in drive 1
#load slot 6 drive 1 clean330sysmas.dsk.woz
load slot 6 drive 1 original330sysmas.do.woz

View File

@ -58,7 +58,7 @@ import slot 4 rom 0 clock.a65
slot 5 disk13
import slot 5 rom 0 13-disk2.a65
# Insert the DOS 3.1 System Master disk into drive 1 of slot 5
#load slot 5 drive 1 clean31sysmas_stock_rawdos.dsk.woz
load slot 5 drive 1 original31sysmas.d13.woz
@ -67,7 +67,7 @@ import slot 5 rom 0 13-disk2.a65
slot 6 disk
import slot 6 rom 0 16-disk2.a65
# Insert the DOS 3.3 System Master disk (original version) into slot 6
#load slot 6 drive 1 clean330sysmas.dsk.woz
load slot 6 drive 1 original330sysmas.do.woz

View File

@ -35,4 +35,4 @@ slot 6 disk
import slot 6 rom 0 16-disk2.a65
# Insert DOS 3.3 System Master disk (original version) in drive 1
#load slot 6 drive 1 clean330sysmas.dsk.woz
load slot 6 drive 1 original330sysmas.do.woz

View File

@ -57,7 +57,7 @@ import slot 4 rom 0 clock.a65
slot 5 disk13
import slot 5 rom 0 13-disk2.a65
# Insert the DOS 3.1 System Master disk into drive 1 of slot 5
#load slot 5 drive 1 clean31sysmas_stock_rawdos.dsk.woz
load slot 5 drive 1 original31sysmas.d13.woz
@ -66,7 +66,7 @@ import slot 5 rom 0 13-disk2.a65
slot 6 disk
import slot 6 rom 0 16-disk2.a65
# Insert the DOS 3.3 System Master disk (original version) into slot 6
#load slot 6 drive 1 clean330sysmas.dsk.woz
load slot 6 drive 1 original330sysmas.do.woz

View File

@ -50,11 +50,11 @@ import slot 4 rom 0 clock.a65
#slot 5 disk13
#import slot 5 rom 0 13-disk2.a65
#load slot 5 drive 1 clean31sysmas_stock_rawdos.dsk.woz
#load slot 5 drive 1 original31sysmas.d13.woz
#slot 6 disk
#import slot 6 rom 0 16-disk2.a65
#load slot 6 drive 1 clean330sysmas.dsk.woz
#load slot 6 drive 1 original330sysmas.do.woz
#slot 7 firmware
#import slot 7 rombank 1000 a2-intbasic.a65

View File

@ -48,15 +48,13 @@ Apple2::Apple2(KeypressQueue& keypresses, PaddleButtonStates& paddleButtonStates
addressBus(gui,revision,ram,rom,kbd,videoMode,paddles,paddleButtonStates,speaker,cassetteIn,cassetteOut,slts),
picgen(tv,videoMode,revision),
video(videoMode,addressBus,picgen,textRows),
transistors("transistors"),
transistors("transistors"), // TODO load file from resources
cpu(NULL),
powerUpReset(*this),
revision(1)
{
revision(1) {
}
Apple2::~Apple2()
{
Apple2::~Apple2() {
}
void Apple2::useEpple2Cpu() {

View File

@ -22,7 +22,6 @@
#include <cstring>
#include <SDL_audio.h>
#include <SDL_log.h>
#include "tinyfiledialogs.h"
#include "cassettein.h"
#include "e2const.h"
#include <vector>
@ -216,8 +215,8 @@ bool CassetteIn::load(const std::string& filePath) {
SDL_AudioSpec wav_spec;
std::uint8_t *wav_buffer;
std::uint32_t wav_length;
if (SDL_LoadWAV(filePath.c_str(), &wav_spec, &wav_buffer, &wav_length) == nullptr) {
// TODO try to load from resources
SDL_Log("Error: %s ; file: %s\n", SDL_GetError(), filePath.c_str());
return false;
}

View File

@ -21,7 +21,6 @@
#include <cstdlib>
#include <SDL_audio.h>
#include <SDL_log.h>
#include "tinyfiledialogs.h"
#include "cassetteout.h"
#include "e2const.h"
#include <vector>

View File

@ -40,6 +40,7 @@
#include <istream>
#include <fstream>
#include <sstream>
#include <filesystem>
#include <string>
#include <stdexcept>
#include <cctype>

View File

@ -18,10 +18,12 @@
*/
#include "wozfile.h"
#include "E2wxApp.h"
#include <istream>
#include <ostream>
#include <fstream>
#include <filesystem>
#include <cmath>
#include <cstring>
@ -112,54 +114,64 @@ void WozFile::dumpTracks() {
bool WozFile::load(const std::string& filePath) {
printf("Reading WOZ 2.0 file: %s\n", filePath.c_str());
std::ifstream in(filePath.c_str(), std::ios::binary|std::ios::in);
if (!in.is_open()) {
printf("Error opening file: %d\n", errno);
return false;
std::ifstream *in = new std::ifstream(filePath.c_str(), std::ios::binary|std::ios::in);
if (!in->is_open()) {
std::filesystem::path f = wxGetApp().GetResDir();
f /= filePath.c_str();
in = new std::ifstream(f.c_str(), std::ios::binary|std::ios::in);
if (!in->is_open()) {
printf("Error opening file: %d\n", errno);
delete in;
return false;
}
}
if (isLoaded()) {
unload();
}
std::uint32_t woz2;
in.read((char*)&woz2, sizeof(woz2));
in->read((char*)&woz2, sizeof(woz2));
if (woz2 != 0x325A4F57u) {
printf("WOZ2 magic bytes missing.");
printf("WOZ2 magic bytes missing. Found: %8x", woz2);
delete in;
return false;
}
printf("WOZ2 magic bytes present\n");
std::uint32_t sanity;
in.read((char*)&sanity, sizeof(sanity));
in->read((char*)&sanity, sizeof(sanity));
if (sanity != 0x0A0D0AFFu) {
printf("FF 0A 0D 0A bytes corrupt.\n");
delete in;
return false;
}
std::uint32_t crc_given;
in.read((char*)&crc_given, sizeof(crc_given));
in->read((char*)&crc_given, sizeof(crc_given));
printf("Read given CRC: %08x\n", crc_given);
// TODO verify CRC
std::uint32_t chunk_id;
std::uint32_t chunk_size;
bool five_25(false);
while (in.read((char*)&chunk_id, sizeof(chunk_id))) {
in.read((char*)&chunk_size, sizeof(chunk_size));
while (in->read((char*)&chunk_id, sizeof(chunk_id))) {
in->read((char*)&chunk_size, sizeof(chunk_size));
printf("Chunk %.4s of size 0x%08x\n", (char*)&chunk_id, chunk_size);
switch (chunk_id) {
case 0x4F464E49: { // INFO
std::uint8_t* buf = new std::uint8_t[chunk_size];
in.read((char*)buf, chunk_size);
in->read((char*)buf, chunk_size);
printf("INFO version %d\n", *buf);
if (*buf != 2) {
printf("File is not WOZ2 version.\n");
delete in;
return false;
}
five_25 = (buf[1]==1);
printf("Disk type: %s\n", five_25 ? "5.25" : buf[1]==2 ? "3.5" : "?");
if (!five_25) {
printf("Only 5 1/4\" disk images are supported.\n");
delete in;
return false;
}
this->writable = !(buf[2]==1);
@ -193,7 +205,7 @@ bool WozFile::load(const std::string& filePath) {
break;
case 0x50414D54: { // TMAP
this->tmap = new std::uint8_t[chunk_size];
in.read((char*)this->tmap, chunk_size);
in->read((char*)this->tmap, chunk_size);
this->initialQtrack = 0;
while (this->initialQtrack < chunk_size && this->tmap[this->initialQtrack] == 0xFFu) {
@ -218,10 +230,11 @@ bool WozFile::load(const std::string& filePath) {
case 0x534B5254: { // TRKS
if (chunk_size < C_QTRACK*8) {
printf("ERROR: TRKS chunk doesn't have 160 track entries.\n");
delete in;
return false;
}
std::uint8_t* buf = new std::uint8_t[chunk_size];
in.read((char*)buf, chunk_size);
in->read((char*)buf, chunk_size);
std::uint8_t* te = buf;
for (std::uint8_t qt(0); qt < C_QTRACK; ++qt) {
struct trk_t ts;
@ -262,7 +275,7 @@ bool WozFile::load(const std::string& filePath) {
break;
case 0x4154454D: { // META
std::uint8_t* buf = new std::uint8_t[chunk_size];
in.read(reinterpret_cast<char*>(buf), chunk_size);
in->read(reinterpret_cast<char*>(buf), chunk_size);
std::uint32_t i(0);
char* pc(reinterpret_cast<char*>(buf));
while (i++ < chunk_size) {
@ -278,7 +291,7 @@ bool WozFile::load(const std::string& filePath) {
break;
default: { // unknown type of chunk; safely skip past it and ignore it
// TODO save all unknown chunks and write out during save (at end of file)
in.seekg(chunk_size, in.cur);
in->seekg(chunk_size, in->cur);
}
break;
}
@ -288,7 +301,8 @@ bool WozFile::load(const std::string& filePath) {
in.close();
in->close();
delete in;
this->filePath = filePath;