Skip to content

Commit

Permalink
Patch version 0.2.1 (#8)
Browse files Browse the repository at this point in the history
* Improving exception handling

* Fixing CMakeList.txt

* Set filesize of flasher to 16k and launcher-os to 8k
  • Loading branch information
ifilot authored Oct 15, 2023
1 parent 78f4d90 commit 5a7a159
Show file tree
Hide file tree
Showing 14 changed files with 187 additions and 36 deletions.
39 changes: 22 additions & 17 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ env:
BUILD_TYPE: Release
PROGNAME: p2000t-fat-flasher
EXEC: p2000t-fat-flasher.exe
FIRMWAREFLASHER_BIN: FIRMWAREFLASHER.BIN
LAUNCHERFIRMWARE_BIN: LAUNCHERFIRMWARE.BIN
BASICROM_BIN: BASICROM.BIN

jobs:
# (optional) Create release
Expand Down Expand Up @@ -48,12 +51,13 @@ jobs:
cd launch-os
sed -i 's/node2000/node2000000/' Makefile
make
mv main.rom LAUNCHERFIRMWARE.BIN
mv main.rom ${{env.LAUNCHERFIRMWARE_BIN}}
truncate -s 8K ${{env.LAUNCHERFIRMWARE_BIN}}
- name: Upload launcher
uses: actions/upload-artifact@v3
with:
name: LAUNCHERFIRMWARE.BIN
path: launch-os/LAUNCHERFIRMWARE.BIN
name: ${{env.LAUNCHERFIRMWARE_BIN}}
path: launch-os/${{env.LAUNCHERFIRMWARE_BIN}}

deploy-launcher-firmware:
runs-on: ubuntu-latest
Expand All @@ -64,7 +68,7 @@ jobs:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: LAUNCHERFIRMWARE.BIN
name: ${{env.LAUNCHERFIRMWARE_BIN}}
path: ./
- name: Upload Release Asset
id: upload-release-asset
Expand All @@ -73,8 +77,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: LAUNCHERFIRMWARE.BIN
asset_name: LAUNCHERFIRMWARE.BIN
asset_path: ${{env.LAUNCHERFIRMWARE_BIN}}
asset_name: ${{env.LAUNCHERFIRMWARE_BIN}}
asset_content_type: application/octet-stream

################################################################################
Expand All @@ -92,12 +96,13 @@ jobs:
cd firmwareflasher
sed -i 's/node2000/node2000000/' Makefile
make
mv main.rom FIRMWAREFLASHER.BIN
mv main.rom ${{env.FIRMWAREFLASHER_BIN}}
truncate -s 16K ${{env.FIRMWAREFLASHER_BIN}}
- name: Upload launcher
uses: actions/upload-artifact@v3
with:
name: FIRMWAREFLASHER.BIN
path: firmwareflasher/FIRMWAREFLASHER.BIN
name: ${{env.FIRMWAREFLASHER_BIN}}
path: firmwareflasher/${{env.FIRMWAREFLASHER_BIN}}

deploy-firmware-flasher-rom:
runs-on: ubuntu-latest
Expand All @@ -108,7 +113,7 @@ jobs:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: FIRMWAREFLASHER.BIN
name: ${{env.FIRMWAREFLASHER_BIN}}
path: ./
- name: Upload Release Asset
id: upload-release-asset
Expand All @@ -117,8 +122,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: FIRMWAREFLASHER.BIN
asset_name: FIRMWAREFLASHER.BIN
asset_path: ${{env.FIRMWAREFLASHER_BIN}}
asset_name: ${{env.FIRMWAREFLASHER_BIN}}
asset_content_type: application/octet-stream

################################################################################
Expand All @@ -140,8 +145,8 @@ jobs:
- name: Upload
uses: actions/upload-artifact@v1
with:
name: BASICBOOTSTRAP.BIN
path: basicmod/BASICBOOTSTRAP.BIN
name: ${{env.BASICROM_BIN}}
path: basicmod/${{env.BASICROM_BIN}}

deploy-basic-cartridge:
runs-on: ubuntu-latest
Expand All @@ -152,7 +157,7 @@ jobs:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: BASICBOOTSTRAP.BIN
name: ${{env.BASICROM_BIN}}
path: ./
- name: Upload Release Asset
id: upload-release-asset
Expand All @@ -161,8 +166,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create-release.outputs.upload_url }}
asset_path: BASICBOOTSTRAP.BIN
asset_name: BASICBOOTSTRAP.BIN
asset_path: ${{env.BASICROM_BIN}}
asset_name: ${{env.BASICROM_BIN}}
asset_content_type: application/octet-stream

################################################################################
Expand Down
2 changes: 1 addition & 1 deletion firmwareflasher/config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef _CONFIG_H
#define _CONFIG_H

#define __VERSION__ "0.2.0"
#define __VERSION__ "0.2.1"

#endif
24 changes: 24 additions & 0 deletions firmwareflasher/copy.asm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,32 @@ ROMBANK EQU $63
ROMEXT EQU $65

PUBLIC _copybank0
PUBLIC _copyfirsttwosectors
PUBLIC _calculatecrc16

;-------------------------------------------------------------------------------
; Copy $0000 - $1FFF from external ROM
; to internal ROM
;-------------------------------------------------------------------------------
_copyfirsttwosectors:
ld bc,$2000
ld de,$0000
ld hl,$0000
di
copyfirsttwosectors_nextbyte:
push bc ; free up bc to be used in the routines below
call sst39sfrecv_external ; load value from external rom addr hl into a
call sst39sfwrbyte_internal ; send value to internal rom addr de from a
pop bc
inc de
inc hl
dec bc
ld a,b
or c
jp nz,copyfirsttwosectors_nextbyte
ei
ret

;-------------------------------------------------------------------------------
; Copy $0000 - $3FFF from external ROM
; to internal ROM
Expand Down
1 change: 1 addition & 0 deletions firmwareflasher/copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define _COPY_H

void copybank0(void);
void copyfirsttwosectors(void);
void calculatecrc16(void);

#endif // _COPY_H
12 changes: 7 additions & 5 deletions firmwareflasher/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,23 @@ int main(void) {
while(keymem[0x0C] == 0) {}

clearline(row);
const char copyfirmwarestr[] = "Copying firmware. Please wait.";
const char copyfirmwarestr[] = "Copying firmware (8kb). Please wait...";
memcpy(&vidmem[row * 0x50], copyfirmwarestr, strlen(copyfirmwarestr));

sst39sf_set_bank(0);
sst39sf_set_bank_romint(0);

for(uint16_t i=0; i<4; i++) { // loop over sectors
// only wipe the first two sectors as the launch-os is (by design) constrainted
// to 0x2000 bytes
for(uint16_t i=0; i<2; i++) { // loop over sectors
sst39sf_wipe_sector_romint(i * 0x1000);
}

// copy external bank0 to internal rom chip
copybank0();
copyfirsttwosectors();

clearline(row);
const char msgdone[] = "Completed data transfer: 16kb.";
const char msgdone[] = "Completed data transfer: 8kb.";
memcpy(&vidmem[row*0x50], msgdone, strlen(msgdone));

row += 2;
Expand All @@ -56,7 +58,7 @@ int main(void) {
const char crcstr[] = "CRC16 checksums:";
memcpy(&vidmem[0x50*row], crcstr, strlen(crcstr));
row++;
for(uint8_t i=0; i<4; i++) {
for(uint8_t i=0; i<2; i++) {
printhex(row*0x50+i*5, highmem9000[i*2]);
printhex(row*0x50+i*5+2, highmem9000[i*2+1]);
}
Expand Down
1 change: 1 addition & 0 deletions gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ find_package(Qt5 REQUIRED COMPONENTS Widgets SerialPort)
add_executable(p2000t-fat-flasher
src/blockmap.cpp
src/dialogslotselection.cpp
src/fatflashergui.cpp
src/fileallocationtable.cpp
src/flashthread.cpp
src/ioworker.cpp
Expand Down
2 changes: 2 additions & 0 deletions gui/p2000t-fat.pro
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ SOURCES += \
src/blockmap.cpp \
src/dialogslotselection.cpp \
src/fileallocationtable.cpp \
src/fatflashergui.cpp \
src/flashthread.cpp \
src/ioworker.cpp \
src/logwindow.cpp \
Expand All @@ -27,6 +28,7 @@ HEADERS += \
src/blockmap.h \
src/config.h \
src/dialogslotselection.h \
src/fatflashergui.h \
src/fileallocationtable.h \
src/flashthread.h \
src/ioworker.h \
Expand Down
3 changes: 2 additions & 1 deletion gui/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
#define _CONFIG_H

#define PROGRAM_NAME "P2000T FAT READER"
#define PROGRAM_VERSION "0.2.0"
#define PROGRAM_VERSION "0.2.1"
#define ICON_PATH ":/assets/icon/icon_128px.png"

#define UNUSED(x) (void)(x)

Expand Down
59 changes: 59 additions & 0 deletions gui/src/fatflashergui.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/****************************************************************************
* *
* P2000T-FAT-READER *
* Copyright (C) 2023 Ivo Filot <ivo@ivofilot.nl> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public license *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
****************************************************************************/

#include "fatflashergui.h"

/**
* @brief Default constructor
* @param argc number of command line argument
* @param argv command line arguments
*/
FATFlasherGUI::FATFlasherGUI(int& argc, char** argv) :
QApplication(argc, argv) {}

/**
* @brief notify
* @param receiver
* @param event
* @return
*/
bool FATFlasherGUI::notify(QObject* receiver, QEvent* event) {
bool done = true;
try {
done = QApplication::notify(receiver, event);
} catch (const std::exception& e) {
this->throw_message_window(tr("Uncaught exception was thrown."),
tr("An uncaught exception was thrown by the program. This is undiserable behavior and "
"the program will be terminated. Please carefully read the error message "
"and consult the manual or contact one of the developers.\n\nError:\n") + e.what());
throw(e);
}
return done;
}


void FATFlasherGUI::throw_message_window(const QString& title, const QString& message) {
QMessageBox message_box;
message_box.setText(message);
message_box.setIcon(QMessageBox::Critical);
message_box.setWindowTitle(title);
message_box.setWindowIcon(QIcon(ICON_PATH));
message_box.exec();
}
52 changes: 52 additions & 0 deletions gui/src/fatflashergui.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/****************************************************************************
* *
* P2000T-FAT-READER *
* Copyright (C) 2023 Ivo Filot <ivo@ivofilot.nl> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public license *
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
****************************************************************************/

#ifndef FATFLASHERGUI_H
#define FATFLASHERGUI_H

#include <QApplication>
#include <QMessageBox>
#include <QIcon>

#include "config.h"

class FATFlasherGUI : public QApplication
{
public:
/**
* @brief Default constructor
* @param argc number of command line argument
* @param argv command line arguments
*/
FATFlasherGUI(int& argc, char** argv);

/**
* @brief notify
* @param receiver
* @param event
* @return
*/
bool notify(QObject* receiver, QEvent* event);

private:
void throw_message_window(const QString& title, const QString& message);
};

#endif // FATFLASHERGUI_H
7 changes: 4 additions & 3 deletions gui/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* *
****************************************************************************/
#include "mainwindow.h"
#include "fatflashergui.h"

#include <QApplication>
#include <QStringList>
Expand Down Expand Up @@ -64,7 +65,7 @@ void message_output(QtMsgType type, const QMessageLogContext &context, const QSt

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
FATFlasherGUI app(argc, argv);
qRegisterMetaType<std::vector<uint8_t>>("stdvector_uint8_t");

std::unique_ptr<MainWindow> mainWindow;
Expand All @@ -74,7 +75,7 @@ int main(int argc, char *argv[])
// build main window
qInstallMessageHandler(message_output);
mainWindow = std::make_unique<MainWindow>(log_messages);
mainWindow->setWindowTitle(QString(PROGRAM_NAME) + " " + QString(PROGRAM_VERSION));
mainWindow->setWindowTitle(QString(PROGRAM_NAME));
} catch(const std::exception& e) {
std::cerr << "Error detected!" << std::endl;
std::cerr << e.what() << std::endl;
Expand All @@ -85,7 +86,7 @@ int main(int argc, char *argv[])

int res = -1;
try {
int res = app.exec();
res = app.exec();
} catch (const std::exception& e) {
std::cerr << "Error detected!" << std::endl;
std::cerr << e.what() << std::endl;
Expand Down
Loading

0 comments on commit 5a7a159

Please sign in to comment.