From a30eaec4c099988eede3a1f4121af3165b2f021d Mon Sep 17 00:00:00 2001 From: Mark Long Date: Fri, 22 Jan 2021 15:45:10 -0600 Subject: [PATCH] New IntBasic file viewer, various code clean up and bug fixes. --- AppleSAWS.pro | 292 +- LICENSE | 44 +- README.md | 84 +- src/applesoftfile/ApplesoftRetokenizer.cpp | 1086 +- src/applesoftfile/ApplesoftRetokenizer.h | 104 +- src/applesoftfile/applesoftfile.cxx | 156 +- src/applesoftfile/applesoftfile.h | 86 +- src/applesoftfile/applesoftformatter.cxx | 348 +- src/applesoftfile/applesoftformatter.h | 106 +- src/applesoftfile/applesoftline.h | 32 +- src/applesoftfile/applesofttoken.cxx | 720 +- src/applesoftfile/applesofttoken.h | 428 +- src/binaryfile/AssemblerSymbolModel.cpp | 272 +- src/binaryfile/AssemblerSymbolModel.h | 120 +- src/binaryfile/AssemblerSymbols.cpp | 284 +- src/binaryfile/AssemblerSymbols.h | 120 +- src/binaryfile/EntryPointModel.cpp | 268 +- src/binaryfile/EntryPointModel.h | 120 +- src/binaryfile/EntryPoints.cpp | 272 +- src/binaryfile/EntryPoints.h | 104 +- src/binaryfile/MemoryUsageMap.h | 216 +- src/binaryfile/binaryfile.cxx | 62 +- src/binaryfile/binaryfile.h | 38 +- src/binaryfile/binaryfilemetadata.cpp | 136 +- src/binaryfile/binaryfilemetadata.h | 94 +- src/binaryfile/disassembler.cxx | 1962 ++-- src/binaryfile/disassembler.h | 430 +- src/diskfiles/dos33/catalogsector.cxx | 109 +- src/diskfiles/dos33/catalogsector.h | 90 +- src/diskfiles/dos33/diskfile.cxx | 367 +- src/diskfiles/dos33/diskfile.h | 118 +- src/diskfiles/dos33/filedescriptiveentry.cxx | 4 +- src/diskfiles/dos33/filedescriptiveentry.h | 110 +- src/diskfiles/dos33/genericfile.cxx | 34 +- src/diskfiles/dos33/genericfile.h | 81 +- src/diskfiles/dos33/sector.cxx | 94 +- src/diskfiles/dos33/sector.h | 114 +- src/diskfiles/dos33/tracksectorlist.cxx | 48 +- src/diskfiles/dos33/tracksectorlist.h | 54 +- src/diskfiles/dos33/vtoc.cxx | 199 +- src/diskfiles/dos33/vtoc.h | 66 +- src/intbasic/IntBasicFile.cxx | 4 + src/internals/JumpLineManager.cpp | 346 +- src/internals/JumpLineManager.h | 204 +- src/internals/memory.cxx | 42 +- src/internals/memory.h | 42 +- src/main.cpp | 60 +- src/relocatablefile/relocatablefile.cxx | 200 +- src/relocatablefile/relocatablefile.h | 218 +- src/textfile/textfile.cxx | 36 +- src/textfile/textfile.h | 34 +- src/ui/catalogwidget.cxx | 337 +- src/ui/catalogwidget.h | 92 +- src/ui/catalogwidget.ui | 218 +- src/ui/diskexplorer/DiskExplorer.cpp | 532 +- src/ui/diskexplorer/DiskExplorer.h | 164 +- src/ui/diskexplorer/DiskExplorerMapWidget.cpp | 746 +- src/ui/diskexplorer/DiskExplorerMapWidget.h | 342 +- src/ui/viewers/applesoftfiledetailviewer.cpp | 396 +- src/ui/viewers/applesoftfiledetailviewer.h | 82 +- src/ui/viewers/applesoftfiledetailviewer.ui | 132 +- src/ui/viewers/applesoftfileviewer.cxx | 865 +- src/ui/viewers/applesoftfileviewer.h | 169 +- src/ui/viewers/applesoftfileviewer.ui | 151 +- src/ui/viewers/charsetviewer.cpp | 326 +- src/ui/viewers/charsetviewer.h | 102 +- src/ui/viewers/disassemblerviewer.cpp | 3279 +++--- src/ui/viewers/disassemblerviewer.h | 141 +- src/ui/viewers/disassemblerviewer.ui | 88 +- src/ui/viewers/fileviewerinterface.h | 82 +- src/ui/viewers/hexdumpviewer.cpp | 450 +- src/ui/viewers/hexdumpviewer.h | 106 +- src/ui/viewers/hexdumpviewer.ui | 89 +- src/ui/viewers/hiresviewwidget.cxx | 244 +- src/ui/viewers/hiresviewwidget.h | 94 +- src/ui/viewers/mazeviewer.cpp | 870 +- src/ui/viewers/mazeviewer.h | 110 +- src/ui/viewers/texthexdumpviewer.cpp | 359 +- src/ui/viewers/texthexdumpviewer.h | 102 +- src/ui/viewers/texthexdumpviewer.ui | 71 +- src/ui/viewers/viewerbase.cpp | 397 +- src/ui/viewers/viewerbase.h | 96 +- src/ui/viewers/viewerbase.ui | 124 +- src/ui/widgets/CharacterSetExplorer.cpp | 166 +- src/ui/widgets/CharacterSetExplorer.h | 68 +- src/ui/widgets/CharacterSetExplorer.ui | 150 +- src/ui/widgets/DisassemblerMetadataDialog.cpp | 286 +- src/ui/widgets/DisassemblerMetadataDialog.h | 112 +- src/ui/widgets/DisassemblerMetadataDialog.ui | 390 +- src/ui/widgets/FlowLineTextBrowser.cpp | 627 +- src/ui/widgets/FlowLineTextBrowser.h | 154 +- src/ui/widgets/HiresScreenWidget.cpp | 1216 +- src/ui/widgets/HiresScreenWidget.h | 292 +- src/ui/widgets/LocationInfoDialog.cpp | 82 +- src/ui/widgets/LocationInfoDialog.h | 64 +- src/ui/widgets/LocationInfoDialog.ui | 238 +- src/ui/widgets/asciiinfodialog.h | 123 +- src/ui/widgets/asciiinfodialog.ui | 9874 ++++++++--------- src/ui/widgets/characterwidget.cpp | 286 +- src/ui/widgets/characterwidget.h | 96 +- src/ui/widgets/hexconverter.cpp | 201 +- src/ui/widgets/hexconverter.h | 60 +- src/ui/widgets/hexconverter.ui | 158 +- src/ui/widgets/hrcgcontrolsinfo.h | 66 +- src/ui/widgets/hrcgcontrolsinfo.ui | 1894 ++-- src/util/AppleColors.h | 46 +- src/util/applestring.cxx | 175 +- src/util/applestring.h | 73 +- src/util/charset.cpp | 109 +- src/util/charset.h | 84 +- src/util/util.h | 174 +- 111 files changed, 19732 insertions(+), 19546 deletions(-) diff --git a/AppleSAWS.pro b/AppleSAWS.pro index 827d607..07afc5b 100644 --- a/AppleSAWS.pro +++ b/AppleSAWS.pro @@ -1,143 +1,149 @@ - -QT += core gui printsupport -CONFIG += c++11 - -MOC_DIR = ./.build -UI_DIR = ./.build -OBJECTS_DIR = ./.build - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = AppleSAWS -TEMPLATE = app - -INCLUDEPATH += src/ -INCLUDEPATH += src/relocatablefile -INCLUDEPATH += src/diskfiles -INCLUDEPATH += src/diskfiles/dos33 -INCLUDEPATH += src/util -INCLUDEPATH += src/applesoftfile -INCLUDEPATH += src/binaryfile -INCLUDEPATH += src/textfile -INCLUDEPATH += src/ui/viewers -INCLUDEPATH += src/imported -INCLUDEPATH += src/internals -INCLUDEPATH += src/ui/diskexplorer/ -INCLUDEPATH += src/ui/widgets/ -INCLUDEPATH += src/ui - -DEFINES += WS_VIDEO - -SOURCES += \ - src/main.cpp \ - src/diskfiles/dos33/diskfile.cxx \ - src/diskfiles/dos33/sector.cxx \ - src/diskfiles/dos33/vtoc.cxx \ - src/diskfiles/dos33/catalogsector.cxx \ - src/diskfiles/dos33/tracksectorlist.cxx \ - src/diskfiles/dos33/filedescriptiveentry.cxx \ - src/diskfiles/dos33/genericfile.cxx \ - src/util/applestring.cxx \ - src/applesoftfile/applesoftfile.cxx \ - src/applesoftfile/applesofttoken.cxx \ - src/applesoftfile/applesoftformatter.cxx \ - src/binaryfile/disassembler.cxx \ - src/binaryfile/binaryfile.cxx \ - src/textfile/textfile.cxx \ - src/ui/catalogwidget.cxx \ - src/ui/viewers/hiresviewwidget.cxx \ - src/ui/viewers/applesoftfileviewer.cxx \ - src/ui/viewers/disassemblerviewer.cpp \ - src/ui/viewers/hexdumpviewer.cpp \ - src/ui/viewers/texthexdumpviewer.cpp \ - src/ui/viewers/mazeviewer.cpp \ - src/ui/viewers/charsetviewer.cpp \ - src/internals/memory.cxx \ - src/relocatablefile/relocatablefile.cxx \ - src/binaryfile/binaryfilemetadata.cpp \ - src/util/charset.cpp \ - src/ui/widgets/characterwidget.cpp \ - src/ui/viewers/applesoftfiledetailviewer.cpp \ - src/ui/widgets/hexconverter.cpp \ - src/ui/viewers/viewerbase.cpp \ - src/ui/widgets/CharacterSetExplorer.cpp \ - src/ui/widgets/HiresScreenWidget.cpp \ - src/ui/widgets/DisassemblerMetadataDialog.cpp \ - src/binaryfile/EntryPointModel.cpp \ - src/ui/widgets/LocationInfoDialog.cpp \ - src/binaryfile/EntryPoints.cpp \ - src/binaryfile/AssemblerSymbols.cpp \ - src/binaryfile/AssemblerSymbolModel.cpp \ - src/ui/diskexplorer/DiskExplorer.cpp \ - src/ui/diskexplorer/DiskExplorerMapWidget.cpp \ - src/applesoftfile/ApplesoftRetokenizer.cpp \ - src/internals/JumpLineManager.cpp \ - src/ui/widgets/FlowLineTextBrowser.cpp - - -HEADERS += \ - src/diskfiles/dos33/diskfile.h \ - src/diskfiles/dos33/sector.h \ - src/diskfiles/dos33/vtoc.h \ - src/diskfiles/dos33/catalogsector.h \ - src/diskfiles/dos33/tracksectorlist.h \ - src/diskfiles/dos33/filedescriptiveentry.h \ - src/diskfiles/dos33/genericfile.h \ - src/util/util.h \ - src/util/applestring.h \ - src/applesoftfile/applesoftfile.h \ - src/applesoftfile/applesofttoken.h \ - src/binaryfile/disassembler.h \ - src/binaryfile/binaryfile.h \ - src/textfile/textfile.h \ - src/ui/catalogwidget.h \ - src/ui/viewers/hiresviewwidget.h \ - src/ui/viewers/applesoftfileviewer.h \ - src/applesoftfile/applesoftformatter.h \ - src/applesoftfile/applesoftline.h \ - src/internals/memory.h \ - src/ui/viewers/disassemblerviewer.h \ - src/ui/viewers/hexdumpviewer.h \ - src/ui/viewers/texthexdumpviewer.h \ - src/relocatablefile/relocatablefile.h \ - src/ui/viewers/mazeviewer.h \ - src/binaryfile/binaryfilemetadata.h \ - src/ui/widgets/characterwidget.h \ - src/util/charset.h \ - src/ui/viewers/charsetviewer.h \ - src/ui/viewers/applesoftfiledetailviewer.h \ - src/ui/widgets/hexconverter.h \ - src/ui/widgets/hrcgcontrolsinfo.h \ - src/ui/viewers/viewerbase.h \ - src/ui/viewers/fileviewerinterface.h \ - src/ui/widgets/CharacterSetExplorer.h \ - src/ui/widgets/HiresScreenWidget.h \ - src/ui/widgets/DisassemblerMetadataDialog.h \ - src/binaryfile/EntryPointModel.h \ - src/ui/widgets/LocationInfoDialog.h \ - src/binaryfile/EntryPoints.h \ - src/binaryfile/AssemblerSymbols.h \ - src/binaryfile/AssemblerSymbolModel.h \ - src/binaryfile/MemoryUsageMap.h \ - src/ui/diskexplorer/DiskExplorer.h \ - src/ui/diskexplorer/DiskExplorerMapWidget.h \ - src/applesoftfile/ApplesoftRetokenizer.h \ - src/util/AppleColors.h \ - src/internals/JumpLineManager.h \ - src/ui/widgets/FlowLineTextBrowser.h \ - src/ui/widgets/asciiinfodialog.h - -FORMS += \ - src/ui/catalogwidget.ui \ - src/ui/viewers/applesoftfileviewer.ui \ - src/ui/viewers/disassemblerviewer.ui \ - src/ui/viewers/hexdumpviewer.ui \ - src/ui/viewers/texthexdumpviewer.ui \ - src/ui/viewers/applesoftfiledetailviewer.ui \ - src/ui/widgets/hexconverter.ui \ - src/ui/widgets/hrcgcontrolsinfo.ui \ - src/ui/viewers/viewerbase.ui \ - src/ui/widgets/CharacterSetExplorer.ui \ - src/ui/widgets/DisassemblerMetadataDialog.ui \ - src/ui/widgets/LocationInfoDialog.ui \ - src/ui/widgets/asciiinfodialog.ui + +QT += core gui printsupport +CONFIG += c++11 + +MOC_DIR = ./.build +UI_DIR = ./.build +OBJECTS_DIR = ./.build + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = AppleSAWS +TEMPLATE = app + +INCLUDEPATH += src/ +INCLUDEPATH += src/relocatablefile +INCLUDEPATH += src/diskfiles +INCLUDEPATH += src/diskfiles/dos33 +INCLUDEPATH += src/util +INCLUDEPATH += src/applesoftfile +INCLUDEPATH += src/intbasic +INCLUDEPATH += src/binaryfile +INCLUDEPATH += src/textfile +INCLUDEPATH += src/ui/viewers +INCLUDEPATH += src/imported +INCLUDEPATH += src/internals +INCLUDEPATH += src/ui/diskexplorer/ +INCLUDEPATH += src/ui/widgets/ +INCLUDEPATH += src/ui + +DEFINES += WS_VIDEO + +SOURCES += \ + src/intbasic/IntBasicFile.cxx \ + src/main.cpp \ + src/diskfiles/dos33/diskfile.cxx \ + src/diskfiles/dos33/sector.cxx \ + src/diskfiles/dos33/vtoc.cxx \ + src/diskfiles/dos33/catalogsector.cxx \ + src/diskfiles/dos33/tracksectorlist.cxx \ + src/diskfiles/dos33/filedescriptiveentry.cxx \ + src/diskfiles/dos33/genericfile.cxx \ + src/ui/viewers/intbasicfileviewer.cxx \ + src/util/applestring.cxx \ + src/applesoftfile/applesoftfile.cxx \ + src/applesoftfile/applesofttoken.cxx \ + src/applesoftfile/applesoftformatter.cxx \ + src/binaryfile/disassembler.cxx \ + src/binaryfile/binaryfile.cxx \ + src/textfile/textfile.cxx \ + src/ui/catalogwidget.cxx \ + src/ui/viewers/hiresviewwidget.cxx \ + src/ui/viewers/applesoftfileviewer.cxx \ + src/ui/viewers/disassemblerviewer.cpp \ + src/ui/viewers/hexdumpviewer.cpp \ + src/ui/viewers/texthexdumpviewer.cpp \ + src/ui/viewers/mazeviewer.cpp \ + src/ui/viewers/charsetviewer.cpp \ + src/internals/memory.cxx \ + src/relocatablefile/relocatablefile.cxx \ + src/binaryfile/binaryfilemetadata.cpp \ + src/util/charset.cpp \ + src/ui/widgets/characterwidget.cpp \ + src/ui/viewers/applesoftfiledetailviewer.cpp \ + src/ui/widgets/hexconverter.cpp \ + src/ui/viewers/viewerbase.cpp \ + src/ui/widgets/CharacterSetExplorer.cpp \ + src/ui/widgets/HiresScreenWidget.cpp \ + src/ui/widgets/DisassemblerMetadataDialog.cpp \ + src/binaryfile/EntryPointModel.cpp \ + src/ui/widgets/LocationInfoDialog.cpp \ + src/binaryfile/EntryPoints.cpp \ + src/binaryfile/AssemblerSymbols.cpp \ + src/binaryfile/AssemblerSymbolModel.cpp \ + src/ui/diskexplorer/DiskExplorer.cpp \ + src/ui/diskexplorer/DiskExplorerMapWidget.cpp \ + src/applesoftfile/ApplesoftRetokenizer.cpp \ + src/internals/JumpLineManager.cpp \ + src/ui/widgets/FlowLineTextBrowser.cpp + + +HEADERS += \ + src/diskfiles/dos33/diskfile.h \ + src/diskfiles/dos33/sector.h \ + src/diskfiles/dos33/vtoc.h \ + src/diskfiles/dos33/catalogsector.h \ + src/diskfiles/dos33/tracksectorlist.h \ + src/diskfiles/dos33/filedescriptiveentry.h \ + src/diskfiles/dos33/genericfile.h \ + src/intbasic/IntBasicFile.h \ + src/ui/viewers/intbasicfileviewer.h \ + src/util/util.h \ + src/util/applestring.h \ + src/applesoftfile/applesoftfile.h \ + src/applesoftfile/applesofttoken.h \ + src/binaryfile/disassembler.h \ + src/binaryfile/binaryfile.h \ + src/textfile/textfile.h \ + src/ui/catalogwidget.h \ + src/ui/viewers/hiresviewwidget.h \ + src/ui/viewers/applesoftfileviewer.h \ + src/applesoftfile/applesoftformatter.h \ + src/applesoftfile/applesoftline.h \ + src/internals/memory.h \ + src/ui/viewers/disassemblerviewer.h \ + src/ui/viewers/hexdumpviewer.h \ + src/ui/viewers/texthexdumpviewer.h \ + src/relocatablefile/relocatablefile.h \ + src/ui/viewers/mazeviewer.h \ + src/binaryfile/binaryfilemetadata.h \ + src/ui/widgets/characterwidget.h \ + src/util/charset.h \ + src/ui/viewers/charsetviewer.h \ + src/ui/viewers/applesoftfiledetailviewer.h \ + src/ui/widgets/hexconverter.h \ + src/ui/widgets/hrcgcontrolsinfo.h \ + src/ui/viewers/viewerbase.h \ + src/ui/viewers/fileviewerinterface.h \ + src/ui/widgets/CharacterSetExplorer.h \ + src/ui/widgets/HiresScreenWidget.h \ + src/ui/widgets/DisassemblerMetadataDialog.h \ + src/binaryfile/EntryPointModel.h \ + src/ui/widgets/LocationInfoDialog.h \ + src/binaryfile/EntryPoints.h \ + src/binaryfile/AssemblerSymbols.h \ + src/binaryfile/AssemblerSymbolModel.h \ + src/binaryfile/MemoryUsageMap.h \ + src/ui/diskexplorer/DiskExplorer.h \ + src/ui/diskexplorer/DiskExplorerMapWidget.h \ + src/applesoftfile/ApplesoftRetokenizer.h \ + src/util/AppleColors.h \ + src/internals/JumpLineManager.h \ + src/ui/widgets/FlowLineTextBrowser.h \ + src/ui/widgets/asciiinfodialog.h + +FORMS += \ + src/ui/catalogwidget.ui \ + src/ui/viewers/applesoftfileviewer.ui \ + src/ui/viewers/disassemblerviewer.ui \ + src/ui/viewers/hexdumpviewer.ui \ + src/ui/viewers/intbasicfileviewer.ui \ + src/ui/viewers/texthexdumpviewer.ui \ + src/ui/viewers/applesoftfiledetailviewer.ui \ + src/ui/widgets/hexconverter.ui \ + src/ui/widgets/hrcgcontrolsinfo.ui \ + src/ui/viewers/viewerbase.ui \ + src/ui/widgets/CharacterSetExplorer.ui \ + src/ui/widgets/DisassemblerMetadataDialog.ui \ + src/ui/widgets/LocationInfoDialog.ui \ + src/ui/widgets/asciiinfodialog.ui diff --git a/LICENSE b/LICENSE index 1eac358..f846f93 100644 --- a/LICENSE +++ b/LICENSE @@ -1,22 +1,22 @@ -The MIT License (MIT) - -Copyright (c) 2015 Mark D. Long - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - +The MIT License (MIT) + +Copyright (c) 2015 Mark D. Long + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/README.md b/README.md index 6e273af..bf87d70 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,42 @@ -# AppleSAWS -##Apple Software Analysis WorkShop - -This is a toolkit for exploring DOS 3.3 disk contents. I started this because I had become interested in a game that I used to play a long time ago and I wanted to dig deeper into the internals of how it worked. Since it was a nice combination of a series of Applesoft and Binary files, I decided that a tool to help explore those types of things would be handy. Of course, I've ended up spending far more time writing the tool than I have actually exploring the game, but nonetheless, it's been a fun ongoing project. - -This code is being developed using Qt5, with development work being done on Linux, but it should compile and run without problems on Windows and Mac. - -Among other things, the app includes: -* Code that reads and parses DOS-format disk images at the disk-structure level. (It's just read-only for now, and ProDOS is on the horizon) -* An Applesoft parser/retokenizer/reformatter which can show code in its normal form or reindented on multiple lines with syntax highlighting, and can optionally show integers as hex values inline. The retokenizer creates new tokens for strings, variable names, numeric values, DATA payloads, REM remarks, and other things that are nice to have -- and sets the stage to create an analyzer for deeper processing of the code later on. -* A binary file processor with a flow-tracing disassembler, which can show hex dumps and disassembly of code and data blocks (it also temporarily has some common labels for well-known addresses hard-coded into the display, though dynamic labeling of symbols is in the works.) It can also display the relocation table for type-R relocatable files. It also displays a linear graph of jumps, subroutines, and branches! -* A Text file viewer. -* A graphics viewer which can show hires screen dumps as monochrome, with NTSC artifacts, or a hybrid mode where each pixel's natural color is shown in-place (with no white color blending.) -* An HRCG character set viewer and explorer -* Exporting files and graphics to the local filesystem (as either .txt or .png files, as appropriate) -* A disk explorer which allows viewing the disk at the sector level, exploring directory and VTOC structure, and more! -* (Though not useful to most) A maze viewer for the game which I was originally exploring (Datamost's *The Missing Ring*, by Terry Romine, 1982) -* Probably some other stuff I can't think of at the moment. - -There is also a Hex/Decimal converter utility and some in-app documentation for HRCG control character codes. Mainly stuff that I found useful at the time I was writing it. - -In the pipeline are some more useful features (as I get a chance): -* Syntax Highlighting **(Currently in progress!)** -* More low-level disk exploration tools (sector-level stuff, comparing DOS versions between disks, etc.) -* More analysis of Applesoft programs (Tracing flow control; determining unaccessable lines of code; finding addresses of PEEKS, POKES, CALLS, USRs, and &'s; determining "hidden" areas of memory stuffed between lines or after the end of the program itself) -* Processing and analysis of Integer Basic files -* Much more robust disassembly tools: - * Handling differences between 6502/65C02/65816 ops, as well as "undocumented" ops on the original 6502 - * Automated detection of Code Segments vs Data Segments **(Currently in progress!)** - * Allowing user-defined labels for addresses **(Currently in progress!)** -* Shape table processing and viewing -* ProDOS support -* Modification/Writing disk images -* Lots of optimization and refactoring -- **(Ongoing)** -* Tools for processing DHGR graphics -* Introduction of project management, allowing annotation and documention of interconnectivity between files and disk image contents, as well as preferences of groups of default viewers to open for a given image or set of images **(In progress!)** -* Plenty of other stuff! - -Anyway, if you take a look at it and think it's interesting, I'd love to hear some feedback. - -![Screenshot](/image/AppleSAWS_screenshot.png) - +# AppleSAWS +##Apple Software Analysis WorkShop + +This is a toolkit for exploring DOS 3.3 disk contents. I started this because I had become interested in a game that I used to play a long time ago and I wanted to dig deeper into the internals of how it worked. Since it was a nice combination of a series of Applesoft and Binary files, I decided that a tool to help explore those types of things would be handy. Of course, I've ended up spending far more time writing the tool than I have actually exploring the game, but nonetheless, it's been a fun ongoing project. + +This code is being developed using Qt5, with development work being done on Linux, but it should compile and run without problems on Windows and Mac. + +Among other things, the app includes: +* Code that reads and parses DOS-format disk images at the disk-structure level. (It's just read-only for now, and ProDOS is on the horizon) +* An Applesoft parser/retokenizer/reformatter which can show code in its normal form or reindented on multiple lines with syntax highlighting, and can optionally show integers as hex values inline. The retokenizer creates new tokens for strings, variable names, numeric values, DATA payloads, REM remarks, and other things that are nice to have -- and sets the stage to create an analyzer for deeper processing of the code later on. +* A binary file processor with a flow-tracing disassembler, which can show hex dumps and disassembly of code and data blocks (it also temporarily has some common labels for well-known addresses hard-coded into the display, though dynamic labeling of symbols is in the works.) It can also display the relocation table for type-R relocatable files. It also displays a linear graph of jumps, subroutines, and branches! +* A Text file viewer. +* A graphics viewer which can show hires screen dumps as monochrome, with NTSC artifacts, or a hybrid mode where each pixel's natural color is shown in-place (with no white color blending.) +* An HRCG character set viewer and explorer +* Exporting files and graphics to the local filesystem (as either .txt or .png files, as appropriate) +* A disk explorer which allows viewing the disk at the sector level, exploring directory and VTOC structure, and more! +* (Though not useful to most) A maze viewer for the game which I was originally exploring (Datamost's *The Missing Ring*, by Terry Romine, 1982) +* Probably some other stuff I can't think of at the moment. + +There is also a Hex/Decimal converter utility and some in-app documentation for HRCG control character codes. Mainly stuff that I found useful at the time I was writing it. + +In the pipeline are some more useful features (as I get a chance): +* Syntax Highlighting **(Currently in progress!)** +* More low-level disk exploration tools (sector-level stuff, comparing DOS versions between disks, etc.) +* More analysis of Applesoft programs (Tracing flow control; determining unaccessable lines of code; finding addresses of PEEKS, POKES, CALLS, USRs, and &'s; determining "hidden" areas of memory stuffed between lines or after the end of the program itself) +* Processing and analysis of Integer Basic files +* Much more robust disassembly tools: + * Handling differences between 6502/65C02/65816 ops, as well as "undocumented" ops on the original 6502 + * Automated detection of Code Segments vs Data Segments **(Currently in progress!)** + * Allowing user-defined labels for addresses **(Currently in progress!)** +* Shape table processing and viewing +* ProDOS support +* Modification/Writing disk images +* Lots of optimization and refactoring -- **(Ongoing)** +* Tools for processing DHGR graphics +* Introduction of project management, allowing annotation and documention of interconnectivity between files and disk image contents, as well as preferences of groups of default viewers to open for a given image or set of images **(In progress!)** +* Plenty of other stuff! + +Anyway, if you take a look at it and think it's interesting, I'd love to hear some feedback. + +![Screenshot](/image/AppleSAWS_screenshot.png) + diff --git a/src/applesoftfile/ApplesoftRetokenizer.cpp b/src/applesoftfile/ApplesoftRetokenizer.cpp index 7f1817e..ddd35eb 100644 --- a/src/applesoftfile/ApplesoftRetokenizer.cpp +++ b/src/applesoftfile/ApplesoftRetokenizer.cpp @@ -1,543 +1,543 @@ -#include "ApplesoftRetokenizer.h" -#include "applesofttoken.h" -#include "util.h" - -#include -#include - -ApplesoftRetokenizer::ApplesoftRetokenizer() -{ - m_isParsed = false; -} - -void ApplesoftRetokenizer::setData(QByteArray data) -{ - m_data = data; - m_data_end = data.length(); - m_isParsed = false; -} - -void ApplesoftRetokenizer::parse(quint16 start_address) -{ - if (m_isParsed) - { - qWarning("File is already parsed. Not reparsing."); - return; - } - - //TODO: This could be changed to search for hidden space between applesoft lines - int idx = 0; - quint8 val = 0; - m_retokenized_lines.clear(); - - quint16 current_address = start_address; - while (idx < m_data.length()) { - ApplesoftLine line; - line.address = current_address; - - line.next_address = makeWord(m_data[idx],m_data[idx+1]); - idx++; idx++; - - line.linenum = makeWord(m_data[idx],m_data[idx+1]); - idx++; idx++; - - if (line.next_address == 0x00) { break; } - do { - val = m_data[idx++]; - ApplesoftToken token(val); - line.tokens.append(token); - } while (val != 0x00); - - - retokenizeLine(line); - - current_address = line.next_address; - - m_retokenized_lines.append(line); - } - - m_data_end = idx; - - if (idx < m_data.length()) { - qDebug() << QString("%1 byte(s) unaccounted for.").arg(m_data.length() - idx); - } - - retokenizeLinesForFormatting(); - - m_isParsed = true; -} - -void ApplesoftRetokenizer::retokenizeLinesForFormatting() -{ - QVector retLines; - - foreach(ApplesoftLine line, m_retokenized_lines) - { - int indentlevel = 1; - // quint16 linenum = line.linenum; - - bool firstToken = true; - ApplesoftToken previousToken; - QMutableVectorIterator tokenIt(line.tokens); - while (tokenIt.hasNext()) - { - ApplesoftToken token = tokenIt.next(); - bool isFlowTarget = false; - - QString tokenstr = token.getRawPrintableString(); - if (firstToken) - { - if (!tokenstr.startsWith(" ")) - { - ApplesoftToken tmptoken(ApplesoftToken::OptFmtLeadingSpaceTokenValue); - tokenIt.remove(); - tokenIt.insert(tmptoken); - tokenIt.insert(token); - } - firstToken = false; - } - - quint16 preTokenId = previousToken.getTokenId(); - if (preTokenId == ApplesoftToken::ASGoto || - preTokenId == ApplesoftToken::ASGosub || - preTokenId == ApplesoftToken::ASThen) - { - isFlowTarget = false; - if (preTokenId == ApplesoftToken::ASGoto || preTokenId == ApplesoftToken::ASGosub) - { - isFlowTarget = true; - } - else if (preTokenId == ApplesoftToken::ASThen - && token.getTokenId() == ApplesoftToken::IntegerTokenVal) - { - isFlowTarget = true; - } - if (isFlowTarget) - { - QPair pair; - pair.first = line.linenum; - pair.second = token.getWordValue(); - m_flowTargets.append(pair); - - ApplesoftToken tmptoken(ApplesoftToken::OptFmtFlagFlowTargetNextTokenValue); - tokenIt.remove(); - tokenIt.insert(tmptoken); - tokenIt.insert(token); - } - } - - if (token.getTokenId() == ApplesoftToken::ASReturn) - { - ApplesoftToken tmptoken(ApplesoftToken::OptFmtReturnLineBreakTokenValue); - tokenIt.insert(tmptoken); - } - - if (token.getTokenId() == ':') - { - ApplesoftToken tmptoken(ApplesoftToken::OptFmtIndentLineBreakTokenValue); - tokenIt.insert(tmptoken); - for (int ind = 0; ind < indentlevel; ind++) - { - ApplesoftToken tmptoken(ApplesoftToken::OptFmtIndentTabTokenValue); - tokenIt.insert(tmptoken); - } - if (!tokenIt.peekNext().getRawPrintableString().startsWith(" ")) - { - ApplesoftToken tmptoken(ApplesoftToken::OptFmtIndentSpaceTokenValue); - tokenIt.insert(tmptoken); - } - } - if (token.getTokenId() == ApplesoftToken::ASThen) - { - indentlevel++; - if (tokenIt.peekNext().getTokenId() != ApplesoftToken::IntegerTokenVal) - { - ApplesoftToken tmptoken(ApplesoftToken::OptFmtIndentLineBreakTokenValue); - tokenIt.insert(tmptoken); - for (int ind = 0; ind < indentlevel; ind++) - { - ApplesoftToken tmptoken(ApplesoftToken::OptFmtIndentTabTokenValue); - tokenIt.insert(tmptoken); - } - if (!tokenIt.peekNext().getRawPrintableString().startsWith(" ")) - { - ApplesoftToken tmptoken(ApplesoftToken::OptFmtIndentSpaceTokenValue); - tokenIt.insert(tmptoken); - } - } - } - - previousToken = token; - } - retLines.append(line); - } - - m_retokenized_lines = retLines; -} - -void ApplesoftRetokenizer::retokenizeLine(ApplesoftLine &line) -{ - QList tmptokens = QList::fromVector(line.tokens); - tmptokens = retokenizeRems(tmptokens); - tmptokens = retokenizeStrings(tmptokens); - tmptokens = retokenizeDataStatements(tmptokens); - tmptokens = retokenizeVariables(tmptokens); - tmptokens = retokenizeNumbers(tmptokens); - tmptokens = retokenizeNegativeNumbers(tmptokens); - line.tokens = tmptokens.toVector(); -} - -QList ApplesoftRetokenizer::retokenizeRems(QList&tmptokens) -{ - // Handle REMs - ApplesoftToken token; - QList replacements; - - QByteArray buffer; - - bool inRem = false; - - while (!tmptokens.isEmpty()) - { - token = tmptokens.takeFirst(); - - if (!inRem) { - replacements.append(token); - if (token.getByteValue() == ApplesoftToken::ASRem) - { - inRem = true; - } - } - else - { - buffer.append(token.getByteValue()); - } - } - if (inRem) { - ApplesoftToken remstrtoken(ApplesoftToken::RemStringTokenVal, buffer); - replacements.append(remstrtoken); - buffer.clear(); - inRem = false; - } - - return replacements; -} - -QList ApplesoftRetokenizer::retokenizeStrings(QList&tmptokens) -{ - // Handle Strings - QList replacements; - - QString buffer; - ApplesoftToken token; - - bool inString = false; - - while (!tmptokens.isEmpty()) - { - token = tmptokens.takeFirst(); - if (token.getTokenId() >= 0x80) - { - replacements.append(token); - // continue; - } else - - if (token.getWordValue() == '"') - { - if (!inString) - { - inString = true; - buffer.append(token.getWordValue()); - // continue; - } - else - { - buffer.append(token.getWordValue()); - ApplesoftToken strtoken(ApplesoftToken::StringTokenVal, buffer); - replacements.append(strtoken); - buffer.clear(); - inString = false; - // continue; - } - } else - - if (inString) - { - buffer.append(token.getWordValue()); - // continue; - } else - - replacements.append(token); - } - - return replacements; -} - -QList ApplesoftRetokenizer::retokenizeDataStatements(QList&tmptokens) -{ - // Handle DATAs - - QList replacements; - ApplesoftToken token; - - QList datatokenbuffer; - bool inData = false; - while (!tmptokens.isEmpty()) - { - token = tmptokens.takeFirst(); - - if (!inData) { - replacements.append(token); - if (token.getTokenId() == ApplesoftToken::ASData) - { - inData = true; - } - } - else - { - datatokenbuffer.append(token); - } - } - if (inData) { - QList dataTokens; - dataTokens = retokenizeDataPayload(datatokenbuffer); - replacements.append(dataTokens); - datatokenbuffer.clear(); - inData = false; - } - return replacements; -} - - -QList ApplesoftRetokenizer::retokenizeDataPayload(QList& tmptokens) -{ - QList retval; - - ApplesoftToken token; - - QString stringbuffer; - - while (!tmptokens.isEmpty()) - { - token = tmptokens.takeFirst(); - if (token.getTokenId() == ApplesoftToken::StringTokenVal) - { - ApplesoftToken newToken(ApplesoftToken::DataStringTokenVal, token.getStringValue()); - retval.append(newToken); - continue; - } - if (token.getWordValue() == ',') - { - if (!stringbuffer.isEmpty()) - { - ApplesoftToken datastrtoken(ApplesoftToken::DataStringTokenVal, stringbuffer); - retval.append(datastrtoken); - stringbuffer.clear(); - } - retval.append(token); - continue; - - } - stringbuffer.append(token.getWordValue()); - } - if (!stringbuffer.isEmpty()) - { - ApplesoftToken datastrtoken(ApplesoftToken::DataStringTokenVal, stringbuffer); - retval.append(datastrtoken); - stringbuffer.clear(); - } - return retval; -} -QList ApplesoftRetokenizer::retokenizeVariables(QList&tmptokens) -{ - // Handle variable names - ApplesoftToken token; - - QRegularExpression varregexp("[A-Za-z][A-Za-z0-9]*[$%]?\\(?"); - - QString parsestring; - // Parse the tokens to find assist - for (int idx = 0; idx < tmptokens.count();idx++) - { - token = tmptokens.at(idx); - - if (token.getTokenId() < 0x0080 && token.getTokenId() > 0x0000) - { - parsestring.append(QChar(token.getWordValue())); - } - else - { - parsestring.append("_"); - } - } - QList matchstack; - QRegularExpressionMatchIterator matches = varregexp.globalMatch(parsestring); - // qDebug() << parsestring; - while (matches.hasNext()) { - QRegularExpressionMatch rematch = matches.next(); - matchstack.push_front(rematch); - - // qDebug() << "Capture " << " = " << rematch.capturedTexts() << "From: " << rematch.capturedStart() - // << "To: " << rematch.capturedEnd()-1 << "("< ApplesoftRetokenizer::retokenizeNumbers(QList&tmptokens) -{ - // Handle numbers - ApplesoftToken token; - - QRegularExpression varregexp("[0-9]+(\\.[0-9]*)?"); - - QString parsestring; - // Parse the tokens to find assist - for (int idx = 0; idx < tmptokens.count();idx++) - { - token = tmptokens.at(idx); - - if (token.getTokenId() < 0x0080 && token.getTokenId() > 0x0000) - { - parsestring.append(QChar(token.getWordValue())); - } - else - { - parsestring.append("_"); - } - } - QList matchstack; - QRegularExpressionMatchIterator matches = varregexp.globalMatch(parsestring); - // qDebug() << parsestring; - while (matches.hasNext()) { - QRegularExpressionMatch rematch = matches.next(); - matchstack.push_front(rematch); - - // qDebug() << "Capture " << " = " << rematch.capturedTexts() << "From: " << rematch.capturedStart() - // << "To: " << rematch.capturedEnd()-1 << "("< ApplesoftRetokenizer::retokenizeNegativeNumbers(QList&tmptokens) -{ - //TODO: Code to make determination of negative numbers vs. unary minus/math formulas. - // Prefixed '-' tokens for negative numbers should get merged with the integer value token. - // So, need to determine when we're in an expression vs when we're starting a number. - // - // A = -1 should retokenize. - // A = - 4 - 1 should retokenize -4 - // A = - 4 - - 1 should retokenize -4 and -1 - // A = 3 - 1 shoud not retokenize - // A = A - 1 should not - // A = PEEK(123) - 5 should not - // A = 4 * - 1 should - // A = (1 + 2) - 4 should not - // A = (1 + 2) + - 4 should - // A = (1 + 2) - - 4 should - // POKE - 4, 1 should - // PRINT + - 4 should - // PRINT - 4 should - // PRINT + + + - - - 4 should retokenize the last -4. - // A = 1 - - 4 should - // A = 1 - - - 4 should, probably, but it's errorprone to say the least, - // as are any multiple arbitrary +/-'s. Have to hope for the best here. - // Best bet would be to look at how Applesoft handles these values. - // A = - 0 is the same as 0 - - ApplesoftToken token; - - QMutableListIteratorit(tmptokens); - - bool lastWasInt = false; - - while (it.hasNext()) - { - token = it.next(); - if (token.getTokenId() == ApplesoftToken::IntegerTokenVal) lastWasInt = true; - else if (token.getTokenId() == ApplesoftToken::FloatTokenVal) lastWasInt = true; - else if (token.getTokenId() == ApplesoftToken::IntVarTokenVal) lastWasInt = true; - else if (token.getTokenId() == ApplesoftToken::FloatVarTokenVal) lastWasInt = true; - else if (token.getTokenId() == ')') lastWasInt = true; - else - if (token.getTokenId() == ApplesoftToken::ASMINUS) - { - if (!lastWasInt && it.hasNext() && it.peekNext().getTokenId() == ApplesoftToken::IntegerTokenVal) - { - it.remove(); - token = it.next(); - it.remove(); - int val = token.getUnsignedIntegerValue() * -1; - token.setValue(val); - it.insert(token); - lastWasInt = true; - } - else - { - lastWasInt = false; - } - } - else - { - lastWasInt = false; - } - } - - return tmptokens; -} - +#include "ApplesoftRetokenizer.h" +#include "applesofttoken.h" +#include "util.h" + +#include +#include + +ApplesoftRetokenizer::ApplesoftRetokenizer() +{ + m_isParsed = false; +} + +void ApplesoftRetokenizer::setData(QByteArray data) +{ + m_data = data; + m_data_end = data.length(); + m_isParsed = false; +} + +void ApplesoftRetokenizer::parse(quint16 start_address) +{ + if (m_isParsed) + { + qWarning("File is already parsed. Not reparsing."); + return; + } + + //TODO: This could be changed to search for hidden space between applesoft lines + int idx = 0; + quint8 val = 0; + m_retokenized_lines.clear(); + + quint16 current_address = start_address; + while (idx < m_data.length()) { + ApplesoftLine line; + line.address = current_address; + + line.next_address = makeWord(m_data[idx],m_data[idx+1]); + idx++; idx++; + + line.linenum = makeWord(m_data[idx],m_data[idx+1]); + idx++; idx++; + + if (line.next_address == 0x00) { break; } + do { + val = m_data[idx++]; + ApplesoftToken token(val); + line.tokens.append(token); + } while (val != 0x00); + + + retokenizeLine(line); + + current_address = line.next_address; + + m_retokenized_lines.append(line); + } + + m_data_end = idx; + + if (idx < m_data.length()) { + qDebug() << QString("%1 byte(s) unaccounted for.").arg(m_data.length() - idx); + } + + retokenizeLinesForFormatting(); + + m_isParsed = true; +} + +void ApplesoftRetokenizer::retokenizeLinesForFormatting() +{ + QVector retLines; + + foreach(ApplesoftLine line, m_retokenized_lines) + { + int indentlevel = 1; + // quint16 linenum = line.linenum; + + bool firstToken = true; + ApplesoftToken previousToken; + QMutableVectorIterator tokenIt(line.tokens); + while (tokenIt.hasNext()) + { + ApplesoftToken token = tokenIt.next(); + bool isFlowTarget = false; + + QString tokenstr = token.getRawPrintableString(); + if (firstToken) + { + if (!tokenstr.startsWith(" ")) + { + ApplesoftToken tmptoken(ApplesoftToken::OptFmtLeadingSpaceTokenValue); + tokenIt.remove(); + tokenIt.insert(tmptoken); + tokenIt.insert(token); + } + firstToken = false; + } + + quint16 preTokenId = previousToken.getTokenId(); + if (preTokenId == ApplesoftToken::ASGoto || + preTokenId == ApplesoftToken::ASGosub || + preTokenId == ApplesoftToken::ASThen) + { + isFlowTarget = false; + if (preTokenId == ApplesoftToken::ASGoto || preTokenId == ApplesoftToken::ASGosub) + { + isFlowTarget = true; + } + else if (preTokenId == ApplesoftToken::ASThen + && token.getTokenId() == ApplesoftToken::IntegerTokenVal) + { + isFlowTarget = true; + } + if (isFlowTarget) + { + QPair pair; + pair.first = line.linenum; + pair.second = token.getWordValue(); + m_flowTargets.append(pair); + + ApplesoftToken tmptoken(ApplesoftToken::OptFmtFlagFlowTargetNextTokenValue); + tokenIt.remove(); + tokenIt.insert(tmptoken); + tokenIt.insert(token); + } + } + + if (token.getTokenId() == ApplesoftToken::ASReturn) + { + ApplesoftToken tmptoken(ApplesoftToken::OptFmtReturnLineBreakTokenValue); + tokenIt.insert(tmptoken); + } + + if (token.getTokenId() == ':') + { + ApplesoftToken tmptoken(ApplesoftToken::OptFmtIndentLineBreakTokenValue); + tokenIt.insert(tmptoken); + for (int ind = 0; ind < indentlevel; ind++) + { + ApplesoftToken tmptoken(ApplesoftToken::OptFmtIndentTabTokenValue); + tokenIt.insert(tmptoken); + } + if (!tokenIt.peekNext().getRawPrintableString().startsWith(" ")) + { + ApplesoftToken tmptoken(ApplesoftToken::OptFmtIndentSpaceTokenValue); + tokenIt.insert(tmptoken); + } + } + if (token.getTokenId() == ApplesoftToken::ASThen) + { + indentlevel++; + if (tokenIt.peekNext().getTokenId() != ApplesoftToken::IntegerTokenVal) + { + ApplesoftToken tmptoken(ApplesoftToken::OptFmtIndentLineBreakTokenValue); + tokenIt.insert(tmptoken); + for (int ind = 0; ind < indentlevel; ind++) + { + ApplesoftToken tmptoken(ApplesoftToken::OptFmtIndentTabTokenValue); + tokenIt.insert(tmptoken); + } + if (!tokenIt.peekNext().getRawPrintableString().startsWith(" ")) + { + ApplesoftToken tmptoken(ApplesoftToken::OptFmtIndentSpaceTokenValue); + tokenIt.insert(tmptoken); + } + } + } + + previousToken = token; + } + retLines.append(line); + } + + m_retokenized_lines = retLines; +} + +void ApplesoftRetokenizer::retokenizeLine(ApplesoftLine &line) +{ + QList tmptokens = QList::fromVector(line.tokens); + tmptokens = retokenizeRems(tmptokens); + tmptokens = retokenizeStrings(tmptokens); + tmptokens = retokenizeDataStatements(tmptokens); + tmptokens = retokenizeVariables(tmptokens); + tmptokens = retokenizeNumbers(tmptokens); + tmptokens = retokenizeNegativeNumbers(tmptokens); + line.tokens = tmptokens.toVector(); +} + +QList ApplesoftRetokenizer::retokenizeRems(QList&tmptokens) +{ + // Handle REMs + ApplesoftToken token; + QList replacements; + + QByteArray buffer; + + bool inRem = false; + + while (!tmptokens.isEmpty()) + { + token = tmptokens.takeFirst(); + + if (!inRem) { + replacements.append(token); + if (token.getByteValue() == ApplesoftToken::ASRem) + { + inRem = true; + } + } + else + { + buffer.append(token.getByteValue()); + } + } + if (inRem) { + ApplesoftToken remstrtoken(ApplesoftToken::RemStringTokenVal, buffer); + replacements.append(remstrtoken); + buffer.clear(); + inRem = false; + } + + return replacements; +} + +QList ApplesoftRetokenizer::retokenizeStrings(QList&tmptokens) +{ + // Handle Strings + QList replacements; + + QString buffer; + ApplesoftToken token; + + bool inString = false; + + while (!tmptokens.isEmpty()) + { + token = tmptokens.takeFirst(); + if (token.getTokenId() >= 0x80) + { + replacements.append(token); + // continue; + } else + + if (token.getWordValue() == '"') + { + if (!inString) + { + inString = true; + buffer.append(token.getWordValue()); + // continue; + } + else + { + buffer.append(token.getWordValue()); + ApplesoftToken strtoken(ApplesoftToken::StringTokenVal, buffer); + replacements.append(strtoken); + buffer.clear(); + inString = false; + // continue; + } + } else + + if (inString) + { + buffer.append(token.getWordValue()); + // continue; + } else + + replacements.append(token); + } + + return replacements; +} + +QList ApplesoftRetokenizer::retokenizeDataStatements(QList&tmptokens) +{ + // Handle DATAs + + QList replacements; + ApplesoftToken token; + + QList datatokenbuffer; + bool inData = false; + while (!tmptokens.isEmpty()) + { + token = tmptokens.takeFirst(); + + if (!inData) { + replacements.append(token); + if (token.getTokenId() == ApplesoftToken::ASData) + { + inData = true; + } + } + else + { + datatokenbuffer.append(token); + } + } + if (inData) { + QList dataTokens; + dataTokens = retokenizeDataPayload(datatokenbuffer); + replacements.append(dataTokens); + datatokenbuffer.clear(); + inData = false; + } + return replacements; +} + + +QList ApplesoftRetokenizer::retokenizeDataPayload(QList& tmptokens) +{ + QList retval; + + ApplesoftToken token; + + QString stringbuffer; + + while (!tmptokens.isEmpty()) + { + token = tmptokens.takeFirst(); + if (token.getTokenId() == ApplesoftToken::StringTokenVal) + { + ApplesoftToken newToken(ApplesoftToken::DataStringTokenVal, token.getStringValue()); + retval.append(newToken); + continue; + } + if (token.getWordValue() == ',') + { + if (!stringbuffer.isEmpty()) + { + ApplesoftToken datastrtoken(ApplesoftToken::DataStringTokenVal, stringbuffer); + retval.append(datastrtoken); + stringbuffer.clear(); + } + retval.append(token); + continue; + + } + stringbuffer.append(token.getWordValue()); + } + if (!stringbuffer.isEmpty()) + { + ApplesoftToken datastrtoken(ApplesoftToken::DataStringTokenVal, stringbuffer); + retval.append(datastrtoken); + stringbuffer.clear(); + } + return retval; +} +QList ApplesoftRetokenizer::retokenizeVariables(QList&tmptokens) +{ + // Handle variable names + ApplesoftToken token; + + QRegularExpression varregexp("[A-Za-z][A-Za-z0-9]*[$%]?\\(?"); + + QString parsestring; + // Parse the tokens to find assist + for (int idx = 0; idx < tmptokens.count();idx++) + { + token = tmptokens.at(idx); + + if (token.getTokenId() < 0x0080 && token.getTokenId() > 0x0000) + { + parsestring.append(QChar(token.getWordValue())); + } + else + { + parsestring.append("_"); + } + } + QList matchstack; + QRegularExpressionMatchIterator matches = varregexp.globalMatch(parsestring); + // qDebug() << parsestring; + while (matches.hasNext()) { + QRegularExpressionMatch rematch = matches.next(); + matchstack.push_front(rematch); + + // qDebug() << "Capture " << " = " << rematch.capturedTexts() << "From: " << rematch.capturedStart() + // << "To: " << rematch.capturedEnd()-1 << "("< ApplesoftRetokenizer::retokenizeNumbers(QList&tmptokens) +{ + // Handle numbers + ApplesoftToken token; + + QRegularExpression varregexp("[0-9]+(\\.[0-9]*)?"); + + QString parsestring; + // Parse the tokens to find assist + for (int idx = 0; idx < tmptokens.count();idx++) + { + token = tmptokens.at(idx); + + if (token.getTokenId() < 0x0080 && token.getTokenId() > 0x0000) + { + parsestring.append(QChar(token.getWordValue())); + } + else + { + parsestring.append("_"); + } + } + QList matchstack; + QRegularExpressionMatchIterator matches = varregexp.globalMatch(parsestring); + // qDebug() << parsestring; + while (matches.hasNext()) { + QRegularExpressionMatch rematch = matches.next(); + matchstack.push_front(rematch); + + // qDebug() << "Capture " << " = " << rematch.capturedTexts() << "From: " << rematch.capturedStart() + // << "To: " << rematch.capturedEnd()-1 << "("< ApplesoftRetokenizer::retokenizeNegativeNumbers(QList&tmptokens) +{ + //TODO: Code to make determination of negative numbers vs. unary minus/math formulas. + // Prefixed '-' tokens for negative numbers should get merged with the integer value token. + // So, need to determine when we're in an expression vs when we're starting a number. + // + // A = -1 should retokenize. + // A = - 4 - 1 should retokenize -4 + // A = - 4 - - 1 should retokenize -4 and -1 + // A = 3 - 1 shoud not retokenize + // A = A - 1 should not + // A = PEEK(123) - 5 should not + // A = 4 * - 1 should + // A = (1 + 2) - 4 should not + // A = (1 + 2) + - 4 should + // A = (1 + 2) - - 4 should + // POKE - 4, 1 should + // PRINT + - 4 should + // PRINT - 4 should + // PRINT + + + - - - 4 should retokenize the last -4. + // A = 1 - - 4 should + // A = 1 - - - 4 should, probably, but it's errorprone to say the least, + // as are any multiple arbitrary +/-'s. Have to hope for the best here. + // Best bet would be to look at how Applesoft handles these values. + // A = - 0 is the same as 0 + + ApplesoftToken token; + + QMutableListIteratorit(tmptokens); + + bool lastWasInt = false; + + while (it.hasNext()) + { + token = it.next(); + if (token.getTokenId() == ApplesoftToken::IntegerTokenVal) lastWasInt = true; + else if (token.getTokenId() == ApplesoftToken::FloatTokenVal) lastWasInt = true; + else if (token.getTokenId() == ApplesoftToken::IntVarTokenVal) lastWasInt = true; + else if (token.getTokenId() == ApplesoftToken::FloatVarTokenVal) lastWasInt = true; + else if (token.getTokenId() == ')') lastWasInt = true; + else + if (token.getTokenId() == ApplesoftToken::ASMINUS) + { + if (!lastWasInt && it.hasNext() && it.peekNext().getTokenId() == ApplesoftToken::IntegerTokenVal) + { + it.remove(); + token = it.next(); + it.remove(); + int val = token.getUnsignedIntegerValue() * -1; + token.setValue(val); + it.insert(token); + lastWasInt = true; + } + else + { + lastWasInt = false; + } + } + else + { + lastWasInt = false; + } + } + + return tmptokens; +} + diff --git a/src/applesoftfile/ApplesoftRetokenizer.h b/src/applesoftfile/ApplesoftRetokenizer.h index 229b2ba..6cc80fb 100644 --- a/src/applesoftfile/ApplesoftRetokenizer.h +++ b/src/applesoftfile/ApplesoftRetokenizer.h @@ -1,52 +1,52 @@ -#ifndef APPLESOFTRETOKENIZER_H -#define APPLESOFTRETOKENIZER_H - -#include "applesoftline.h" - -#include -#include -#include -#include - -class ApplesoftRetokenizer -{ -public: - ApplesoftRetokenizer(); - - void setData(QByteArray data); - void parse(quint16 start_address = 0x0801); - - quint16 getEndOfDataOffset() const { return m_data_end; } - - QVector getRetokenizedLines() { return m_retokenized_lines; } - - QList > getFlowTargets() const { return m_flowTargets; } - -private: - void retokenizeLinesForFormatting(); - - - void retokenizeLine(ApplesoftLine &line); - QList retokenizeRems(QList &datatokens); - QList retokenizeStrings(QList &datatokens); - QList retokenizeDataStatements(QList &datatokens); - QList retokenizeDataPayload(QList &datatokens); - QList retokenizeVariables(QList &datatokens); - QList retokenizeNumbers(QList &datatokens); - QList retokenizeNegativeNumbers(QList &datatokens); - - - QVector m_retokenized_lines; - QByteArray m_data; - - quint16 m_data_end; - - bool m_isParsed; - - QList > m_flowTargets; - -}; - - -#endif // APPLESOFTRETOKENIZER_H - +#ifndef APPLESOFTRETOKENIZER_H +#define APPLESOFTRETOKENIZER_H + +#include "applesoftline.h" + +#include +#include +#include +#include + +class ApplesoftRetokenizer +{ +public: + ApplesoftRetokenizer(); + + void setData(QByteArray data); + void parse(quint16 start_address = 0x0801); + + quint16 getEndOfDataOffset() const { return m_data_end; } + + QVector getRetokenizedLines() { return m_retokenized_lines; } + + QList > getFlowTargets() const { return m_flowTargets; } + +private: + void retokenizeLinesForFormatting(); + + + void retokenizeLine(ApplesoftLine &line); + QList retokenizeRems(QList &datatokens); + QList retokenizeStrings(QList &datatokens); + QList retokenizeDataStatements(QList &datatokens); + QList retokenizeDataPayload(QList &datatokens); + QList retokenizeVariables(QList &datatokens); + QList retokenizeNumbers(QList &datatokens); + QList retokenizeNegativeNumbers(QList &datatokens); + + + QVector m_retokenized_lines; + QByteArray m_data; + + quint16 m_data_end; + + bool m_isParsed; + + QList > m_flowTargets; + +}; + + +#endif // APPLESOFTRETOKENIZER_H + diff --git a/src/applesoftfile/applesoftfile.cxx b/src/applesoftfile/applesoftfile.cxx index b994cb2..112f173 100644 --- a/src/applesoftfile/applesoftfile.cxx +++ b/src/applesoftfile/applesoftfile.cxx @@ -1,78 +1,78 @@ -#include "applesoftfile.h" -#include "util.h" -#include -#include -#include -#include -#include - -ApplesoftFile::ApplesoftFile(QByteArray data) : GenericFile(data) -{ - m_retokenizer = Q_NULLPTR; - m_data_end = data.length(); - - if (!data.isEmpty()) - { - setData(data); - } - setAddress(0x801); -} - -void ApplesoftFile::setData(QByteArray data) -{ - if (!m_retokenizer) - { - m_retokenizer = new ApplesoftRetokenizer(); - } - - GenericFile::setData(data); - - quint8 addlo = m_data.at(0); - quint8 addhi = m_data.at(1); - m_length = makeWord(addlo,addhi); - m_data.remove(0,2); - - m_retokenizer->setData(m_data); - m_retokenizer->parse(); - m_data_end = m_retokenizer->getEndOfDataOffset(); - m_lines = m_retokenizer->getRetokenizedLines(); - - m_flowTargets = m_retokenizer->getFlowTargets(); -} - -QByteArray ApplesoftFile::rawData() { - QByteArray retval; - retval.append(m_length % 255); - retval.append(m_length / 255); - retval.append(m_data); - return retval; -} - -QStringList ApplesoftFile::extraDataHexValues() { - QStringList retval; - - QString debugline = ""; - int count = 0; - foreach (quint8 val, extraData()) { - debugline.append(QString("%1").arg(val,2,16,QChar('0')).toUpper()); - count++; - if (count == 16) { - retval.append(debugline); - debugline = ""; - count = 0; - } else { - debugline.append(" "); - } - } - if (!debugline.simplified().isEmpty()) { - retval.append(debugline); - } - return retval; -} - -QByteArray ApplesoftFile::extraData() -{ - return m_data.mid(m_data_end); -} - - +#include "applesoftfile.h" +#include "util.h" +#include +#include +#include +#include +#include + +ApplesoftFile::ApplesoftFile(QByteArray data) : GenericFile(data) +{ + m_retokenizer = Q_NULLPTR; + m_data_end = data.length(); + + if (!data.isEmpty()) + { + setData(data); + } + setAddress(0x801); +} + +void ApplesoftFile::setData(QByteArray data) +{ + if (!m_retokenizer) + { + m_retokenizer = new ApplesoftRetokenizer(); + } + + GenericFile::setData(data); + + quint8 addlo = m_data.at(0); + quint8 addhi = m_data.at(1); + m_length = makeWord(addlo,addhi); + m_data.remove(0,2); + + m_retokenizer->setData(m_data); + m_retokenizer->parse(); + m_data_end = m_retokenizer->getEndOfDataOffset(); + m_lines = m_retokenizer->getRetokenizedLines(); + + m_flowTargets = m_retokenizer->getFlowTargets(); +} + +QByteArray ApplesoftFile::rawData() { + QByteArray retval; + retval.append(m_length % 255); + retval.append(m_length / 255); + retval.append(m_data); + return retval; +} + +QStringList ApplesoftFile::extraDataHexValues() { + QStringList retval; + + QString debugline = ""; + int count = 0; + foreach (quint8 val, extraData()) { + debugline.append(QString("%1").arg(val,2,16,QChar('0')).toUpper()); + count++; + if (count == 16) { + retval.append(debugline); + debugline = ""; + count = 0; + } else { + debugline.append(" "); + } + } + if (!debugline.simplified().isEmpty()) { + retval.append(debugline); + } + return retval; +} + +QByteArray ApplesoftFile::extraData() +{ + return m_data.mid(m_data_end); +} + + diff --git a/src/applesoftfile/applesoftfile.h b/src/applesoftfile/applesoftfile.h index d08fba3..b0b1225 100644 --- a/src/applesoftfile/applesoftfile.h +++ b/src/applesoftfile/applesoftfile.h @@ -1,43 +1,43 @@ -#ifndef APPLESOFTFILE_H -#define APPLESOFTFILE_H - -#include -#include -#include -#include - -#include "applesoftline.h" -#include "genericfile.h" -#include "applesofttoken.h" -#include "ApplesoftRetokenizer.h" - - -class ApplesoftFile : public GenericFile -{ -public: - ApplesoftFile(QByteArray data = QByteArray()); - void setData(QByteArray data); - QByteArray extraData(); - QStringList extraDataHexValues(); - - QVector getLines() const { return m_lines; } - - quint16 length() const { return m_length; } - - QByteArray rawData(); - -private: - - QVector m_lines; - int m_data_end; - quint16 m_length; - - ApplesoftRetokenizer *m_retokenizer; - - QList > m_flowTargets; - -}; - - - -#endif // APPLESOFTFILE_H +#ifndef APPLESOFTFILE_H +#define APPLESOFTFILE_H + +#include +#include +#include +#include + +#include "applesoftline.h" +#include "genericfile.h" +#include "applesofttoken.h" +#include "ApplesoftRetokenizer.h" + + +class ApplesoftFile : public GenericFile +{ +public: + ApplesoftFile(QByteArray data = QByteArray()); + void setData(QByteArray data); + QByteArray extraData(); + QStringList extraDataHexValues(); + + QVector getLines() const { return m_lines; } + + quint16 length() const { return m_length; } + + QByteArray rawData(); + +private: + + QVector m_lines; + int m_data_end; + quint16 m_length; + + ApplesoftRetokenizer *m_retokenizer; + + QList > m_flowTargets; + +}; + + + +#endif // APPLESOFTFILE_H diff --git a/src/applesoftfile/applesoftformatter.cxx b/src/applesoftfile/applesoftformatter.cxx index 94b787c..b091077 100644 --- a/src/applesoftfile/applesoftformatter.cxx +++ b/src/applesoftfile/applesoftformatter.cxx @@ -1,174 +1,174 @@ -#include "applesoftformatter.h" -#include "util.h" -#include -#include -#include - -#define HEXPREFIX "0x" - -ApplesoftFormatter::ApplesoftFormatter(QObject *parent) : - QObject(parent) -{ - m_file = Q_NULLPTR; -} - -void ApplesoftFormatter::setFile(ApplesoftFile *file) -{ - m_file = file; - emit newFile(file); -} - -void ApplesoftFormatter::formatDocument(QTextDocument *doc) -{ - if (!doc) return; - - doc->clear(); - QTextCursor cursor(doc); - cursor.beginEditBlock(); - - bool synhl = (m_format_options.testFlag(SyntaxHighlighting)); - - foreach (ApplesoftLine line, m_file->getLines()) - { - QString linestring = QString("%1 ").arg(line.linenum,5,10,QChar(' ')); - - if (synhl) - { - cursor.insertText(linestring, - ApplesoftToken::textFormat(ApplesoftToken::LineNumberTokenVal)); - } - else - { - cursor.insertText(linestring,ApplesoftToken::defaultTextFormat()); - } - - QVectorIteratortokenIt(line.tokens); - bool isBranchTarget = false; - while (tokenIt.hasNext()) - { - ApplesoftToken token = tokenIt.next(); - if (token.isOptFmtToken()) - { - switch (token.getTokenId()) - { - - case ApplesoftToken::OptFmtFlagFlowTargetNextTokenValue: - { - if (m_format_options.testFlag(ShowIntsAsHex)) - isBranchTarget = true; - break; - } - - case ApplesoftToken::OptFmtIndentLineBreakTokenValue: - { - if (m_format_options.testFlag(ReindentCode)) - cursor.insertBlock(); - break; - } - case ApplesoftToken::OptFmtIndentSpaceTokenValue: - { - if (m_format_options.testFlag(ReindentCode)) - cursor.insertText(" ",ApplesoftToken::defaultTextFormat()); - break; - } - case ApplesoftToken::OptFmtIndentTabTokenValue: - { - if (m_format_options.testFlag(ReindentCode)) - cursor.insertText(" ",ApplesoftToken::defaultTextFormat()); - break; - } - case ApplesoftToken::OptFmtLeadingSpaceTokenValue: - { - cursor.insertText(" ",ApplesoftToken::defaultTextFormat()); - break; - } - case ApplesoftToken::OptFmtReturnLineBreakTokenValue: - { - if (m_format_options.testFlag(BreakAfterReturn)) - cursor.insertBlock(); - break; - } - default: - { - break; - } - } - } // isOptFmt - else - { - QString tokenstr = token.getRawPrintableString(); - - - QTextCharFormat fmt = ApplesoftToken::defaultTextFormat(); - if (synhl) fmt = token.textFormat(); - - - if (token.getTokenId() == ApplesoftToken::IntegerTokenVal) - { - if (m_format_options.testFlag(ShowIntsAsHex) && !isBranchTarget) - { - quint32 ui32val = token.getUnsignedIntegerValue(); - qint32 i32val = token.getIntegerValue(); - if ((i32val < 128 && i32val >= -128) || ui32val < 256) - { - quint8 ui8 = ui32val; - tokenstr = HEXPREFIX+uint8ToHex(ui8); - } - else if ((i32val < 32768 && i32val >= -32768) || ui32val < 65536) - { - quint16 ui16 = ui32val; - tokenstr = HEXPREFIX+uint16ToHex(ui16); - } - else - { - tokenstr = HEXPREFIX+uint32ToHex(ui32val); - } - } // isShowIntsAsHex - isBranchTarget = false; - } - - // if (m_format_options.testFlag(ShowCtrlChars)) - // { - // tokenstr.replace(QChar(0x7f),QChar(0x2401)); - - // for (int idx = 1; idx <= 0x1f; idx++) { - // if (idx == '\n') continue; - // tokenstr.replace(QChar(idx),QChar(idx+0x2400)); - // } - // } // if ShowCtrlChars - - - - QTextCharFormat invFormat = ApplesoftToken::defaultInverseTextFormat(); - if (m_format_options.testFlag(SyntaxHighlighting)) - invFormat = ApplesoftToken::textFormat( - ApplesoftToken::ControlCharTokenVal); - - - foreach (QChar ch, tokenstr) - { - if (ch == QChar(0x7f)) - { - cursor.insertText(QChar(0x00d7),invFormat); - } - else if (ch < QChar(' ')) - { - if (m_format_options.testFlag(ShowCtrlChars)) - { - QChar newch = ch.unicode()+0x40; - cursor.insertText(newch,invFormat); - } - } - else cursor.insertText(ch,fmt); - } - - } - - } // while tokenIt.hasNext() - - //formattedText.append("\n"); - cursor.insertBlock(); - - } // foreach line - cursor.endEditBlock(); -} +#include "applesoftformatter.h" +#include "util.h" +#include +#include +#include + +#define HEXPREFIX "0x" + +ApplesoftFormatter::ApplesoftFormatter(QObject *parent) : + QObject(parent) +{ + m_file = Q_NULLPTR; +} + +void ApplesoftFormatter::setFile(ApplesoftFile *file) +{ + m_file = file; + emit newFile(file); +} + +void ApplesoftFormatter::formatDocument(QTextDocument *doc) +{ + if (!doc) return; + + doc->clear(); + QTextCursor cursor(doc); + cursor.beginEditBlock(); + + bool synhl = (m_format_options.testFlag(SyntaxHighlighting)); + + foreach (ApplesoftLine line, m_file->getLines()) + { + QString linestring = QString("%1 ").arg(line.linenum,5,10,QChar(' ')); + + if (synhl) + { + cursor.insertText(linestring, + ApplesoftToken::textFormat(ApplesoftToken::LineNumberTokenVal)); + } + else + { + cursor.insertText(linestring,ApplesoftToken::defaultTextFormat()); + } + + QVectorIteratortokenIt(line.tokens); + bool isBranchTarget = false; + while (tokenIt.hasNext()) + { + ApplesoftToken token = tokenIt.next(); + if (token.isOptFmtToken()) + { + switch (token.getTokenId()) + { + + case ApplesoftToken::OptFmtFlagFlowTargetNextTokenValue: + { + if (m_format_options.testFlag(ShowIntsAsHex)) + isBranchTarget = true; + break; + } + + case ApplesoftToken::OptFmtIndentLineBreakTokenValue: + { + if (m_format_options.testFlag(ReindentCode)) + cursor.insertBlock(); + break; + } + case ApplesoftToken::OptFmtIndentSpaceTokenValue: + { + if (m_format_options.testFlag(ReindentCode)) + cursor.insertText(" ",ApplesoftToken::defaultTextFormat()); + break; + } + case ApplesoftToken::OptFmtIndentTabTokenValue: + { + if (m_format_options.testFlag(ReindentCode)) + cursor.insertText(" ",ApplesoftToken::defaultTextFormat()); + break; + } + case ApplesoftToken::OptFmtLeadingSpaceTokenValue: + { + cursor.insertText(" ",ApplesoftToken::defaultTextFormat()); + break; + } + case ApplesoftToken::OptFmtReturnLineBreakTokenValue: + { + if (m_format_options.testFlag(BreakAfterReturn)) + cursor.insertBlock(); + break; + } + default: + { + break; + } + } + } // isOptFmt + else + { + QString tokenstr = token.getRawPrintableString(); + + + QTextCharFormat fmt = ApplesoftToken::defaultTextFormat(); + if (synhl) fmt = token.textFormat(); + + + if (token.getTokenId() == ApplesoftToken::IntegerTokenVal) + { + if (m_format_options.testFlag(ShowIntsAsHex) && !isBranchTarget) + { + quint32 ui32val = token.getUnsignedIntegerValue(); + qint32 i32val = token.getIntegerValue(); + if ((i32val < 128 && i32val >= -128) || ui32val < 256) + { + quint8 ui8 = ui32val; + tokenstr = HEXPREFIX+uint8ToHex(ui8); + } + else if ((i32val < 32768 && i32val >= -32768) || ui32val < 65536) + { + quint16 ui16 = ui32val; + tokenstr = HEXPREFIX+uint16ToHex(ui16); + } + else + { + tokenstr = HEXPREFIX+uint32ToHex(ui32val); + } + } // isShowIntsAsHex + isBranchTarget = false; + } + + // if (m_format_options.testFlag(ShowCtrlChars)) + // { + // tokenstr.replace(QChar(0x7f),QChar(0x2401)); + + // for (int idx = 1; idx <= 0x1f; idx++) { + // if (idx == '\n') continue; + // tokenstr.replace(QChar(idx),QChar(idx+0x2400)); + // } + // } // if ShowCtrlChars + + + + QTextCharFormat invFormat = ApplesoftToken::defaultInverseTextFormat(); + if (m_format_options.testFlag(SyntaxHighlighting)) + invFormat = ApplesoftToken::textFormat( + ApplesoftToken::ControlCharTokenVal); + + + foreach (QChar ch, tokenstr) + { + if (ch == QChar(0x7f)) + { + cursor.insertText(QChar(0x00d7),invFormat); + } + else if (ch < QChar(' ')) + { + if (m_format_options.testFlag(ShowCtrlChars)) + { + QChar newch = ch.unicode()+0x40; + cursor.insertText(newch,invFormat); + } + } + else cursor.insertText(ch,fmt); + } + + } + + } // while tokenIt.hasNext() + + //formattedText.append("\n"); + cursor.insertBlock(); + + } // foreach line + cursor.endEditBlock(); +} diff --git a/src/applesoftfile/applesoftformatter.h b/src/applesoftfile/applesoftformatter.h index e6b1f2a..80fdeb5 100644 --- a/src/applesoftfile/applesoftformatter.h +++ b/src/applesoftfile/applesoftformatter.h @@ -1,53 +1,53 @@ -#ifndef APPLESOFTFORMATTER_H -#define APPLESOFTFORMATTER_H - -#include -#include -#include -#include - -#include "applesoftfile.h" - -class ApplesoftFormatter : public QObject -{ - Q_OBJECT - -public: - enum FormatOption { - NoOptions = 0x00, - - SyntaxHighlighting = 0x01, - ShowCtrlChars = 0x02, - BreakAfterReturn = 0x04, - ReindentCode = 0x08, - ShowIntsAsHex = 0x10, - - AllFlags = 0xffffffff - }; - Q_DECLARE_FLAGS(FormatOptions, FormatOption) - -public: - explicit ApplesoftFormatter(QObject *parent = 0); - void setFlags(FormatOptions options) { m_format_options = options; } - void setFile(ApplesoftFile *file); - - FormatOptions flags() { return m_format_options; } - - void formatDocument(QTextDocument *doc); - -signals: - void newFile(ApplesoftFile *file); - -public slots: - -private: - FormatOptions m_format_options; - - ApplesoftFile *m_file; - - -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(ApplesoftFormatter::FormatOptions) - -#endif // APPLESOFTFORMATTER_H +#ifndef APPLESOFTFORMATTER_H +#define APPLESOFTFORMATTER_H + +#include +#include +#include +#include + +#include "applesoftfile.h" + +class ApplesoftFormatter : public QObject +{ + Q_OBJECT + +public: + enum FormatOption { + NoOptions = 0x00, + + SyntaxHighlighting = 0x01, + ShowCtrlChars = 0x02, + BreakAfterReturn = 0x04, + ReindentCode = 0x08, + ShowIntsAsHex = 0x10, + + AllFlags = 0xffffffff + }; + Q_DECLARE_FLAGS(FormatOptions, FormatOption) + +public: + explicit ApplesoftFormatter(QObject *parent = 0); + void setFlags(FormatOptions options) { m_format_options = options; } + void setFile(ApplesoftFile *file); + + FormatOptions flags() { return m_format_options; } + + void formatDocument(QTextDocument *doc); + +signals: + void newFile(ApplesoftFile *file); + +public slots: + +private: + FormatOptions m_format_options; + + ApplesoftFile *m_file; + + +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(ApplesoftFormatter::FormatOptions) + +#endif // APPLESOFTFORMATTER_H diff --git a/src/applesoftfile/applesoftline.h b/src/applesoftfile/applesoftline.h index 053f4d0..6eb79fe 100644 --- a/src/applesoftfile/applesoftline.h +++ b/src/applesoftfile/applesoftline.h @@ -1,16 +1,16 @@ -#ifndef APPLESOFTLINE_H -#define APPLESOFTLINE_H -#include -#include - -class ApplesoftToken; - -struct ApplesoftLine { - qint16 address; - quint16 next_address; - quint16 linenum; - QVector tokens; -}; - - -#endif // APPLESOFTLINE_H +#ifndef APPLESOFTLINE_H +#define APPLESOFTLINE_H +#include +#include + +class ApplesoftToken; + +struct ApplesoftLine { + qint16 address; + quint16 next_address; + quint16 linenum; + QVector tokens; +}; + + +#endif // APPLESOFTLINE_H diff --git a/src/applesoftfile/applesofttoken.cxx b/src/applesoftfile/applesofttoken.cxx index 85cf257..81fc525 100644 --- a/src/applesoftfile/applesofttoken.cxx +++ b/src/applesoftfile/applesofttoken.cxx @@ -1,360 +1,360 @@ -#include "applesofttoken.h" - -QMap ApplesoftToken::m_tokens = QMap(); - -ApplesoftToken::ApplesoftToken() -{ - if (m_tokens.size() == 0) { initializeTokenTable(); } - setTokenId(DefaultTokenVal); -} - -ApplesoftToken::ApplesoftToken(quint16 id) -{ - if (m_tokens.size() == 0) { initializeTokenTable(); } - setTokenId(id); -} - -ApplesoftToken::ApplesoftToken(quint16 id, QVariant payload) -{ - if (m_tokens.size() == 0) { initializeTokenTable(); } - setTokenId(id); - setValue(payload); -} - -void ApplesoftToken::setTokenId(quint16 id) -{ - m_token_id = id; - m_token_type = UNKNOWN_TOKEN; - m_command_type = NONE; - - if (id <= 0x7f) { - setValue(id); - m_token_type = ASCIICHAR_TOKEN; - m_command_type = NONE; - } else if (id <= 0xC7) { - setValue(id); - m_token_type = APPLESOFT_TOKEN; - m_command_type = COMMAND; - } else if (id <= 0xD1) { - setValue(id); - m_token_type = APPLESOFT_TOKEN; - m_command_type = OPERATOR; - } else if (id <= 0xEA) { - setValue(id); - m_token_type = APPLESOFT_TOKEN; - m_command_type = FUNCTION; - } else if (id <= 0xFF) { - setValue(id); - m_token_type = UNDEFINED_APPLESOFT_TOKEN; - m_command_type = NONE; - } else if (id == StringTokenVal) { - m_token_type = STRING_TOKEN; - m_command_type = NONE; - } else if (id == RemStringTokenVal) { - m_token_type = REM_TOKEN; - m_command_type = NONE; - } else if (id == DataStringTokenVal) { - m_token_type = DATASTRING_TOKEN; - m_command_type = NONE; - } else if (id == IntegerTokenVal) { - m_token_type = INTEGER_TOKEN; - m_command_type = NONE; - } else if (id == FloatTokenVal) { - m_token_type = FLOAT_TOKEN; - m_command_type = NONE; - } else if (id == IntVarTokenVal) { - m_token_type = INT_VARIABLE_TOKEN; - m_command_type = NONE; - } else if (id == IntAryVarTokenVal) { - m_token_type = INT_ARY_VARIABLE_TOKEN; - m_command_type = NONE; - } else if (id == FloatVarTokenVal) { - m_token_type = FLOAT_VARIABLE_TOKEN; - m_command_type = NONE; - } else if (id == FloatAryVarTokenVal) { - m_token_type = FLOAT_ARY_VARIABLE_TOKEN; - m_command_type = NONE; - } else if (id == StringVarTokenVal) { - m_token_type = STRING_VARIABLE_TOKEN; - m_command_type = NONE; - } else if (id == StringAryVarTokenVal) { - m_token_type = STRING_ARY_VARIABLE_TOKEN; - m_command_type = NONE; - } else if (id >= 0xe000 && id < 0xf000) { - m_token_type = OPTIONAL_FORMAT_TOKEN; - m_command_type = OPTIONAL_FORMAT; - } -} - -void ApplesoftToken::setValue(QVariant value) -{ - m_payload = value; -} - - - -QString ApplesoftToken::getRawPrintableString() const -{ - if (m_token_id == DefaultTokenVal) { - return ""; - } else if (m_token_id == 0x00) { - return ""; - } else if (m_token_id <= 0x7f) { - return QString((m_token_id)); - } else if (m_token_id <= 0xff) { - return m_tokens[m_token_id]; - } else if (m_token_id == StringTokenVal) { - return getStringValue(); - } else if (m_token_id == RemStringTokenVal) { - return getStringValue(); - } else if (m_token_id == DataStringTokenVal) { - return getStringValue(); - } else if (m_token_id == IntegerTokenVal) { - return getStringValue(); - } else if (m_token_id == FloatTokenVal) { - return getStringValue(); - } else if (m_token_id == IntVarTokenVal) { - return getStringValue(); - } else if (m_token_id == IntAryVarTokenVal) { - return getStringValue(); - } else if (m_token_id == FloatVarTokenVal) { - return getStringValue(); - } else if (m_token_id == FloatAryVarTokenVal) { - return getStringValue(); - } else if (m_token_id == StringVarTokenVal) { - return getStringValue(); - } else if (m_token_id == StringAryVarTokenVal) { - return getStringValue(); - } else if (m_token_id >= 0xe000 && m_token_id < 0xf000) { - return ""; - } else { - return "[temp undefined]"; - } -} - -QTextCharFormat ApplesoftToken::defaultTextFormat() -{ - QTextCharFormat tf; // Default - tf.setForeground(Qt::black); - return tf; -} - -QTextCharFormat ApplesoftToken::defaultInverseTextFormat() -{ - QTextCharFormat tf; - tf.setForeground(Qt::white); - tf.setBackground(Qt::black); - return tf; -} - -QTextCharFormat ApplesoftToken::textFormat(quint16 tokenType) -{ - QTextCharFormat tf = defaultTextFormat(); - - if (tokenType < 0x80) // Ascii - { - tf.setForeground(Qt::black); - } - else if (tokenType < 0x100) // Applesoft Tokens - { - tf.setForeground(Qt::black); - } - else if (tokenType == StringTokenVal) - { - tf.setForeground(Qt::blue); - tf.setFontWeight(QFont::Bold); - } - else if (tokenType == IntegerTokenVal || tokenType == FloatTokenVal) - { - tf.setForeground(Qt::darkGreen); - tf.setFontWeight(QFont::Bold); - } - else if (tokenType == StringVarTokenVal || - tokenType == StringAryVarTokenVal || - tokenType == IntVarTokenVal || - tokenType == IntAryVarTokenVal || - tokenType == FloatVarTokenVal || - tokenType == FloatAryVarTokenVal) - { - tf.setFontWeight(QFont::Bold); - tf.setForeground(Qt::darkMagenta); - } - else if (tokenType == RemStringTokenVal) - { - tf.setForeground(Qt::darkGray); - tf.setFontUnderline(true); - } - else if (tokenType == DataStringTokenVal) - { - tf.setForeground(Qt::darkRed); - } - else if (tokenType == ControlCharTokenVal) - { - // Inverse of StringTokenVal - tf.setForeground(Qt::white); - tf.setBackground(Qt::blue); - } - - return tf; -} - - - -void ApplesoftToken::makeTextCharFormats() -{ -// TCFDefault, -// TCFCtrlChar, -// TCFAscii, -// TCFFunction, -// TCFOperator, -// TCFUnusedToken, -// TCFNumber, -// TCFString, -// TCFVariable, -// TCFDataString, -// TCFRemString, -// TCFUnknown - - -} - -void ApplesoftToken::initializeTokenTable() -{ - m_tokens[ASEnd] = " END "; m_tokens[ASFor] = " FOR "; - m_tokens[ASNext] = " NEXT "; m_tokens[ASData] = " DATA "; - m_tokens[ASInput] = " INPUT "; m_tokens[ASDel] = " DEL "; - m_tokens[ASDim] = " DIM "; m_tokens[ASRead] = " READ "; - m_tokens[ASGr] = " GR "; m_tokens[ASText] = " TEXT "; - m_tokens[ASPr] = " PR# "; m_tokens[ASIn] = " IN# "; - m_tokens[ASCall] = " CALL "; m_tokens[ASPlot] = " PLOT "; - m_tokens[ASHlin] = " HLIN "; m_tokens[ASVlin] = " VLIN "; - m_tokens[ASHgr2] = " HGR2 "; m_tokens[ASHgr] = " HGR "; - m_tokens[ASHcolor] = " HCOLOR= "; m_tokens[ASHplot] = " HPLOT "; - m_tokens[ASDraw] = " DRAW "; m_tokens[ASXdraw] = " XDRAW "; - m_tokens[ASHtab] = " HTAB "; m_tokens[ASHome] = " HOME "; - m_tokens[ASRot] = " ROT= "; m_tokens[ASScale] = " SCALE= "; - m_tokens[ASShload] = " SHLOAD "; m_tokens[ASTrace] = " TRACE "; - m_tokens[ASNotrace] = " NOTRACE "; m_tokens[ASNormal] = " NORMAL "; - m_tokens[ASInverse] = " INVERSE "; m_tokens[ASFlash] = " FLASH "; - m_tokens[ASColor] = " COLOR= "; m_tokens[ASPop] = " POP "; - m_tokens[ASVtab] = " VTAB "; m_tokens[ASHimem] = " HIMEM: "; - m_tokens[ASLomem] = " LOMEM: "; m_tokens[ASOnerr] = " ONERR "; - m_tokens[ASResume] = " RESUME "; m_tokens[ASRecall] = " RECALL "; - m_tokens[ASStore] = " STORE "; m_tokens[ASSpeed] = " SPEED= "; - m_tokens[ASLet] = " LET "; m_tokens[ASGoto] = " GOTO "; - m_tokens[ASRun] = " RUN "; m_tokens[ASIf] = " IF "; - m_tokens[ASRestore] = " RESTORE "; m_tokens[ASAMP] = " & "; - m_tokens[ASGosub] = " GOSUB "; m_tokens[ASReturn] = " RETURN "; - m_tokens[ASRem] = " REM "; m_tokens[ASStop] = " STOP "; - m_tokens[ASOn] = " ON "; m_tokens[ASWait] = " WAIT "; - m_tokens[ASLoad] = " LOAD "; m_tokens[ASSave] = " SAVE "; - m_tokens[ASDef] = " DEF "; m_tokens[ASPoke] = " POKE "; - m_tokens[ASPrint] = " PRINT "; m_tokens[ASCont] = " CONT "; - m_tokens[ASList] = " LIST "; m_tokens[ASClear] = " CLEAR "; - m_tokens[ASGet] = " GET "; m_tokens[ASNew] = " NEW "; - m_tokens[ASTab] = " TAB("; m_tokens[ASTo] = " TO "; - m_tokens[ASFn] = " FN "; m_tokens[ASSpc] = " SPC( "; - m_tokens[ASThen] = " THEN "; m_tokens[ASAt] = " AT "; - m_tokens[ASNot] = " NOT "; m_tokens[ASStep] = " STEP "; - m_tokens[ASPLUS] = " + "; m_tokens[ASMINUS] = " - "; - m_tokens[ASASTERISK] = " * "; m_tokens[ASSLASH] = " / "; - m_tokens[ASCARET] = " ^ "; m_tokens[ASAnd] = " AND "; - m_tokens[ASOr] = " OR "; m_tokens[ASGREATER] = " > "; - m_tokens[ASEQUAL] = " = "; m_tokens[ASLESS] = " < "; - m_tokens[ASSgn] = " SGN"; m_tokens[ASInt] = " INT"; - m_tokens[ASAbs] = " ABS"; m_tokens[ASUsr] = " USR"; - m_tokens[ASFre] = " FRE"; m_tokens[ASScrn] = " SCRN( "; - m_tokens[ASPdl] = " PDL"; m_tokens[ASPos] = " POS"; - m_tokens[ASSqr] = " SQR"; m_tokens[ASRnd] = " RND"; - m_tokens[ASLog] = " LOG"; m_tokens[ASExp] = " EXP"; - m_tokens[ASCos] = " COS"; m_tokens[ASSin] = " SIN"; - m_tokens[ASTan] = " TAN"; m_tokens[ASAtn] = " ATN"; - m_tokens[ASPeek] = " PEEK"; m_tokens[ASLen] = " LEN"; - m_tokens[ASStr] = " STR$"; m_tokens[ASVal] = " VAL"; - m_tokens[ASAsc] = " ASC"; m_tokens[ASChr] = " CHR$"; - m_tokens[ASLeft] = " LEFT$ "; m_tokens[ASRight] = " RIGHT$ "; - m_tokens[ASMid] = " MID$ "; - m_tokens[AS_EB] = "{Token 0xEB} "; m_tokens[AS_EC] = "{Token 0xEC} "; - m_tokens[AS_ED] = "{Token 0xED} "; m_tokens[AS_EE] = "{Token 0xEE} "; - m_tokens[AS_EF] = "{Token 0xEF} "; m_tokens[AS_F0] = "{Token 0xF0} "; - m_tokens[AS_F1] = "{Token 0xF1} "; m_tokens[AS_F2] = "{Token 0xF2} "; - m_tokens[AS_F3] = "{Token 0xF3} "; m_tokens[AS_F4] = "{Token 0xF4} "; - m_tokens[AS_F5] = "{Token 0xF5} "; m_tokens[AS_F6] = "{Token 0xF6} "; - m_tokens[AS_F7] = "{Token 0xF7} "; m_tokens[AS_F8] = "{Token 0xF8} "; - m_tokens[AS_F9] = "{Token 0xF9} "; m_tokens[AS_FA] = "{Token 0xFA} "; - m_tokens[AS_FB] = "{Token 0xFB} "; m_tokens[AS_FC] = "{Token 0xFC} "; - m_tokens[AS_FD] = "{Token 0xFD} "; m_tokens[AS_FE] = "{Token 0xFE} "; - m_tokens[AS_FF] = "{Token 0xFF} "; -} - -const quint16 ApplesoftToken::ASEnd = 0x80; const quint16 ApplesoftToken::ASFor = 0x81; -const quint16 ApplesoftToken::ASNext = 0x82; const quint16 ApplesoftToken::ASData = 0x83; -const quint16 ApplesoftToken::ASInput = 0x84; const quint16 ApplesoftToken::ASDel = 0x85; -const quint16 ApplesoftToken::ASDim = 0x86; const quint16 ApplesoftToken::ASRead = 0x87; -const quint16 ApplesoftToken::ASGr = 0x88; const quint16 ApplesoftToken::ASText = 0x89; -const quint16 ApplesoftToken::ASPr = 0x8A; const quint16 ApplesoftToken::ASIn = 0x8B; -const quint16 ApplesoftToken::ASCall = 0x8C; const quint16 ApplesoftToken::ASPlot = 0x8D; -const quint16 ApplesoftToken::ASHlin = 0x8E; const quint16 ApplesoftToken::ASVlin = 0x8F; - -const quint16 ApplesoftToken::ASHgr2 = 0x90; const quint16 ApplesoftToken::ASHgr = 0x91; -const quint16 ApplesoftToken::ASHcolor = 0x92; const quint16 ApplesoftToken::ASHplot = 0x93; -const quint16 ApplesoftToken::ASDraw = 0x94; const quint16 ApplesoftToken::ASXdraw = 0x95; -const quint16 ApplesoftToken::ASHtab = 0x96; const quint16 ApplesoftToken::ASHome = 0x97; -const quint16 ApplesoftToken::ASRot = 0x98; const quint16 ApplesoftToken::ASScale = 0x99; -const quint16 ApplesoftToken::ASShload = 0x9A; const quint16 ApplesoftToken::ASTrace = 0x9B; -const quint16 ApplesoftToken::ASNotrace = 0x9C; const quint16 ApplesoftToken::ASNormal = 0x9D; -const quint16 ApplesoftToken::ASInverse = 0x9E; const quint16 ApplesoftToken::ASFlash = 0x9F; - -const quint16 ApplesoftToken::ASColor = 0xA0; const quint16 ApplesoftToken::ASPop = 0xA1; -const quint16 ApplesoftToken::ASVtab = 0xA2; const quint16 ApplesoftToken::ASHimem = 0xA3; -const quint16 ApplesoftToken::ASLomem = 0xA4; const quint16 ApplesoftToken::ASOnerr = 0xA5; -const quint16 ApplesoftToken::ASResume = 0xA6; const quint16 ApplesoftToken::ASRecall = 0xA7; -const quint16 ApplesoftToken::ASStore = 0xA8; const quint16 ApplesoftToken::ASSpeed = 0xA9; -const quint16 ApplesoftToken::ASLet = 0xAA; const quint16 ApplesoftToken::ASGoto = 0xAB; -const quint16 ApplesoftToken::ASRun = 0xAC; const quint16 ApplesoftToken::ASIf = 0xAD; -const quint16 ApplesoftToken::ASRestore = 0xAE; const quint16 ApplesoftToken::ASAMP = 0xAF; - -const quint16 ApplesoftToken::ASGosub = 0xB0; const quint16 ApplesoftToken::ASReturn = 0xB1; -const quint16 ApplesoftToken::ASRem = 0xB2; const quint16 ApplesoftToken::ASStop = 0xB3; -const quint16 ApplesoftToken::ASOn = 0xB4; const quint16 ApplesoftToken::ASWait = 0xB5; -const quint16 ApplesoftToken::ASLoad = 0xB6; const quint16 ApplesoftToken::ASSave = 0xB7; -const quint16 ApplesoftToken::ASDef = 0xB8; const quint16 ApplesoftToken::ASPoke = 0xB9; -const quint16 ApplesoftToken::ASPrint = 0xBA; const quint16 ApplesoftToken::ASCont = 0xBB; -const quint16 ApplesoftToken::ASList = 0xBC; const quint16 ApplesoftToken::ASClear = 0xBD; -const quint16 ApplesoftToken::ASGet = 0xBE; const quint16 ApplesoftToken::ASNew = 0xBF; - -const quint16 ApplesoftToken::ASTab = 0xC0; const quint16 ApplesoftToken::ASTo = 0xC1; -const quint16 ApplesoftToken::ASFn = 0xC2; const quint16 ApplesoftToken::ASSpc = 0xC3; -const quint16 ApplesoftToken::ASThen = 0xC4; const quint16 ApplesoftToken::ASAt = 0xC5; -const quint16 ApplesoftToken::ASNot = 0xC6; const quint16 ApplesoftToken::ASStep = 0xC7; -const quint16 ApplesoftToken::ASPLUS = 0xC8; const quint16 ApplesoftToken::ASMINUS = 0xC9; -const quint16 ApplesoftToken::ASASTERISK = 0xCA; const quint16 ApplesoftToken::ASSLASH = 0xCB; -const quint16 ApplesoftToken::ASCARET = 0xCC; const quint16 ApplesoftToken::ASAnd = 0xCD; -const quint16 ApplesoftToken::ASOr = 0xCE; const quint16 ApplesoftToken::ASGREATER = 0xCF; - -const quint16 ApplesoftToken::ASEQUAL = 0xD0; const quint16 ApplesoftToken::ASLESS = 0xD1; -const quint16 ApplesoftToken::ASSgn = 0xD2; const quint16 ApplesoftToken::ASInt = 0xD3; -const quint16 ApplesoftToken::ASAbs = 0xD4; const quint16 ApplesoftToken::ASUsr = 0xD5; -const quint16 ApplesoftToken::ASFre = 0xD6; const quint16 ApplesoftToken::ASScrn = 0xD7; -const quint16 ApplesoftToken::ASPdl = 0xD8; const quint16 ApplesoftToken::ASPos = 0xD9; -const quint16 ApplesoftToken::ASSqr = 0xDA; const quint16 ApplesoftToken::ASRnd = 0xDB; -const quint16 ApplesoftToken::ASLog = 0xDC; const quint16 ApplesoftToken::ASExp = 0xDD; -const quint16 ApplesoftToken::ASCos = 0xDE; const quint16 ApplesoftToken::ASSin = 0xDF; - -const quint16 ApplesoftToken::ASTan = 0xE0; const quint16 ApplesoftToken::ASAtn = 0xE1; -const quint16 ApplesoftToken::ASPeek = 0xE2; const quint16 ApplesoftToken::ASLen = 0xE3; -const quint16 ApplesoftToken::ASStr = 0xE4; const quint16 ApplesoftToken::ASVal = 0xE5; -const quint16 ApplesoftToken::ASAsc = 0xE6; const quint16 ApplesoftToken::ASChr = 0xE7; -const quint16 ApplesoftToken::ASLeft = 0xE8; const quint16 ApplesoftToken::ASRight = 0xE9; -const quint16 ApplesoftToken::ASMid = 0xEA; const quint16 ApplesoftToken::AS_EB = 0xEB; -const quint16 ApplesoftToken::AS_EC = 0xEC; const quint16 ApplesoftToken::AS_ED = 0xED; -const quint16 ApplesoftToken::AS_EE = 0xEE; const quint16 ApplesoftToken::AS_EF = 0xEF; - -const quint16 ApplesoftToken::AS_F0 = 0xF0; const quint16 ApplesoftToken::AS_F1 = 0xF1; -const quint16 ApplesoftToken::AS_F2 = 0xF2; const quint16 ApplesoftToken::AS_F3 = 0xF3; -const quint16 ApplesoftToken::AS_F4 = 0xF4; const quint16 ApplesoftToken::AS_F5 = 0xF5; -const quint16 ApplesoftToken::AS_F6 = 0xF6; const quint16 ApplesoftToken::AS_F7 = 0xF7; -const quint16 ApplesoftToken::AS_F8 = 0xF8; const quint16 ApplesoftToken::AS_F9 = 0xF9; -const quint16 ApplesoftToken::AS_FA = 0xFA; const quint16 ApplesoftToken::AS_FB = 0xFB; -const quint16 ApplesoftToken::AS_FC = 0xFC; const quint16 ApplesoftToken::AS_FD = 0xFD; -const quint16 ApplesoftToken::AS_FE = 0xFE; const quint16 ApplesoftToken::AS_FF = 0xFF; +#include "applesofttoken.h" + +QMap ApplesoftToken::m_tokens = QMap(); + +ApplesoftToken::ApplesoftToken() +{ + if (m_tokens.size() == 0) { initializeTokenTable(); } + setTokenId(DefaultTokenVal); +} + +ApplesoftToken::ApplesoftToken(quint16 id) +{ + if (m_tokens.size() == 0) { initializeTokenTable(); } + setTokenId(id); +} + +ApplesoftToken::ApplesoftToken(quint16 id, QVariant payload) +{ + if (m_tokens.size() == 0) { initializeTokenTable(); } + setTokenId(id); + setValue(payload); +} + +void ApplesoftToken::setTokenId(quint16 id) +{ + m_token_id = id; + m_token_type = UNKNOWN_TOKEN; + m_command_type = NONE; + + if (id <= 0x7f) { + setValue(id); + m_token_type = ASCIICHAR_TOKEN; + m_command_type = NONE; + } else if (id <= 0xC7) { + setValue(id); + m_token_type = APPLESOFT_TOKEN; + m_command_type = COMMAND; + } else if (id <= 0xD1) { + setValue(id); + m_token_type = APPLESOFT_TOKEN; + m_command_type = OPERATOR; + } else if (id <= 0xEA) { + setValue(id); + m_token_type = APPLESOFT_TOKEN; + m_command_type = FUNCTION; + } else if (id <= 0xFF) { + setValue(id); + m_token_type = UNDEFINED_APPLESOFT_TOKEN; + m_command_type = NONE; + } else if (id == StringTokenVal) { + m_token_type = STRING_TOKEN; + m_command_type = NONE; + } else if (id == RemStringTokenVal) { + m_token_type = REM_TOKEN; + m_command_type = NONE; + } else if (id == DataStringTokenVal) { + m_token_type = DATASTRING_TOKEN; + m_command_type = NONE; + } else if (id == IntegerTokenVal) { + m_token_type = INTEGER_TOKEN; + m_command_type = NONE; + } else if (id == FloatTokenVal) { + m_token_type = FLOAT_TOKEN; + m_command_type = NONE; + } else if (id == IntVarTokenVal) { + m_token_type = INT_VARIABLE_TOKEN; + m_command_type = NONE; + } else if (id == IntAryVarTokenVal) { + m_token_type = INT_ARY_VARIABLE_TOKEN; + m_command_type = NONE; + } else if (id == FloatVarTokenVal) { + m_token_type = FLOAT_VARIABLE_TOKEN; + m_command_type = NONE; + } else if (id == FloatAryVarTokenVal) { + m_token_type = FLOAT_ARY_VARIABLE_TOKEN; + m_command_type = NONE; + } else if (id == StringVarTokenVal) { + m_token_type = STRING_VARIABLE_TOKEN; + m_command_type = NONE; + } else if (id == StringAryVarTokenVal) { + m_token_type = STRING_ARY_VARIABLE_TOKEN; + m_command_type = NONE; + } else if (id >= 0xe000 && id < 0xf000) { + m_token_type = OPTIONAL_FORMAT_TOKEN; + m_command_type = OPTIONAL_FORMAT; + } +} + +void ApplesoftToken::setValue(QVariant value) +{ + m_payload = value; +} + + + +QString ApplesoftToken::getRawPrintableString() const +{ + if (m_token_id == DefaultTokenVal) { + return ""; + } else if (m_token_id == 0x00) { + return ""; + } else if (m_token_id <= 0x7f) { + return QString((m_token_id)); + } else if (m_token_id <= 0xff) { + return m_tokens[m_token_id]; + } else if (m_token_id == StringTokenVal) { + return getStringValue(); + } else if (m_token_id == RemStringTokenVal) { + return getStringValue(); + } else if (m_token_id == DataStringTokenVal) { + return getStringValue(); + } else if (m_token_id == IntegerTokenVal) { + return getStringValue(); + } else if (m_token_id == FloatTokenVal) { + return getStringValue(); + } else if (m_token_id == IntVarTokenVal) { + return getStringValue(); + } else if (m_token_id == IntAryVarTokenVal) { + return getStringValue(); + } else if (m_token_id == FloatVarTokenVal) { + return getStringValue(); + } else if (m_token_id == FloatAryVarTokenVal) { + return getStringValue(); + } else if (m_token_id == StringVarTokenVal) { + return getStringValue(); + } else if (m_token_id == StringAryVarTokenVal) { + return getStringValue(); + } else if (m_token_id >= 0xe000 && m_token_id < 0xf000) { + return ""; + } else { + return "[temp undefined]"; + } +} + +QTextCharFormat ApplesoftToken::defaultTextFormat() +{ + QTextCharFormat tf; // Default + tf.setForeground(Qt::black); + return tf; +} + +QTextCharFormat ApplesoftToken::defaultInverseTextFormat() +{ + QTextCharFormat tf; + tf.setForeground(Qt::white); + tf.setBackground(Qt::black); + return tf; +} + +QTextCharFormat ApplesoftToken::textFormat(quint16 tokenType) +{ + QTextCharFormat tf = defaultTextFormat(); + + if (tokenType < 0x80) // Ascii + { + tf.setForeground(Qt::black); + } + else if (tokenType < 0x100) // Applesoft Tokens + { + tf.setForeground(Qt::black); + } + else if (tokenType == StringTokenVal) + { + tf.setForeground(Qt::blue); + tf.setFontWeight(QFont::Bold); + } + else if (tokenType == IntegerTokenVal || tokenType == FloatTokenVal) + { + tf.setForeground(Qt::darkGreen); + tf.setFontWeight(QFont::Bold); + } + else if (tokenType == StringVarTokenVal || + tokenType == StringAryVarTokenVal || + tokenType == IntVarTokenVal || + tokenType == IntAryVarTokenVal || + tokenType == FloatVarTokenVal || + tokenType == FloatAryVarTokenVal) + { + tf.setFontWeight(QFont::Bold); + tf.setForeground(Qt::darkMagenta); + } + else if (tokenType == RemStringTokenVal) + { + tf.setForeground(Qt::darkGray); + tf.setFontUnderline(true); + } + else if (tokenType == DataStringTokenVal) + { + tf.setForeground(Qt::darkRed); + } + else if (tokenType == ControlCharTokenVal) + { + // Inverse of StringTokenVal + tf.setForeground(Qt::white); + tf.setBackground(Qt::blue); + } + + return tf; +} + + + +void ApplesoftToken::makeTextCharFormats() +{ +// TCFDefault, +// TCFCtrlChar, +// TCFAscii, +// TCFFunction, +// TCFOperator, +// TCFUnusedToken, +// TCFNumber, +// TCFString, +// TCFVariable, +// TCFDataString, +// TCFRemString, +// TCFUnknown + + +} + +void ApplesoftToken::initializeTokenTable() +{ + m_tokens[ASEnd] = " END "; m_tokens[ASFor] = " FOR "; + m_tokens[ASNext] = " NEXT "; m_tokens[ASData] = " DATA "; + m_tokens[ASInput] = " INPUT "; m_tokens[ASDel] = " DEL "; + m_tokens[ASDim] = " DIM "; m_tokens[ASRead] = " READ "; + m_tokens[ASGr] = " GR "; m_tokens[ASText] = " TEXT "; + m_tokens[ASPr] = " PR# "; m_tokens[ASIn] = " IN# "; + m_tokens[ASCall] = " CALL "; m_tokens[ASPlot] = " PLOT "; + m_tokens[ASHlin] = " HLIN "; m_tokens[ASVlin] = " VLIN "; + m_tokens[ASHgr2] = " HGR2 "; m_tokens[ASHgr] = " HGR "; + m_tokens[ASHcolor] = " HCOLOR= "; m_tokens[ASHplot] = " HPLOT "; + m_tokens[ASDraw] = " DRAW "; m_tokens[ASXdraw] = " XDRAW "; + m_tokens[ASHtab] = " HTAB "; m_tokens[ASHome] = " HOME "; + m_tokens[ASRot] = " ROT= "; m_tokens[ASScale] = " SCALE= "; + m_tokens[ASShload] = " SHLOAD "; m_tokens[ASTrace] = " TRACE "; + m_tokens[ASNotrace] = " NOTRACE "; m_tokens[ASNormal] = " NORMAL "; + m_tokens[ASInverse] = " INVERSE "; m_tokens[ASFlash] = " FLASH "; + m_tokens[ASColor] = " COLOR= "; m_tokens[ASPop] = " POP "; + m_tokens[ASVtab] = " VTAB "; m_tokens[ASHimem] = " HIMEM: "; + m_tokens[ASLomem] = " LOMEM: "; m_tokens[ASOnerr] = " ONERR "; + m_tokens[ASResume] = " RESUME "; m_tokens[ASRecall] = " RECALL "; + m_tokens[ASStore] = " STORE "; m_tokens[ASSpeed] = " SPEED= "; + m_tokens[ASLet] = " LET "; m_tokens[ASGoto] = " GOTO "; + m_tokens[ASRun] = " RUN "; m_tokens[ASIf] = " IF "; + m_tokens[ASRestore] = " RESTORE "; m_tokens[ASAMP] = " & "; + m_tokens[ASGosub] = " GOSUB "; m_tokens[ASReturn] = " RETURN "; + m_tokens[ASRem] = " REM "; m_tokens[ASStop] = " STOP "; + m_tokens[ASOn] = " ON "; m_tokens[ASWait] = " WAIT "; + m_tokens[ASLoad] = " LOAD "; m_tokens[ASSave] = " SAVE "; + m_tokens[ASDef] = " DEF "; m_tokens[ASPoke] = " POKE "; + m_tokens[ASPrint] = " PRINT "; m_tokens[ASCont] = " CONT "; + m_tokens[ASList] = " LIST "; m_tokens[ASClear] = " CLEAR "; + m_tokens[ASGet] = " GET "; m_tokens[ASNew] = " NEW "; + m_tokens[ASTab] = " TAB("; m_tokens[ASTo] = " TO "; + m_tokens[ASFn] = " FN "; m_tokens[ASSpc] = " SPC( "; + m_tokens[ASThen] = " THEN "; m_tokens[ASAt] = " AT "; + m_tokens[ASNot] = " NOT "; m_tokens[ASStep] = " STEP "; + m_tokens[ASPLUS] = " + "; m_tokens[ASMINUS] = " - "; + m_tokens[ASASTERISK] = " * "; m_tokens[ASSLASH] = " / "; + m_tokens[ASCARET] = " ^ "; m_tokens[ASAnd] = " AND "; + m_tokens[ASOr] = " OR "; m_tokens[ASGREATER] = " > "; + m_tokens[ASEQUAL] = " = "; m_tokens[ASLESS] = " < "; + m_tokens[ASSgn] = " SGN"; m_tokens[ASInt] = " INT"; + m_tokens[ASAbs] = " ABS"; m_tokens[ASUsr] = " USR"; + m_tokens[ASFre] = " FRE"; m_tokens[ASScrn] = " SCRN( "; + m_tokens[ASPdl] = " PDL"; m_tokens[ASPos] = " POS"; + m_tokens[ASSqr] = " SQR"; m_tokens[ASRnd] = " RND"; + m_tokens[ASLog] = " LOG"; m_tokens[ASExp] = " EXP"; + m_tokens[ASCos] = " COS"; m_tokens[ASSin] = " SIN"; + m_tokens[ASTan] = " TAN"; m_tokens[ASAtn] = " ATN"; + m_tokens[ASPeek] = " PEEK"; m_tokens[ASLen] = " LEN"; + m_tokens[ASStr] = " STR$"; m_tokens[ASVal] = " VAL"; + m_tokens[ASAsc] = " ASC"; m_tokens[ASChr] = " CHR$"; + m_tokens[ASLeft] = " LEFT$ "; m_tokens[ASRight] = " RIGHT$ "; + m_tokens[ASMid] = " MID$ "; + m_tokens[AS_EB] = "{Token 0xEB} "; m_tokens[AS_EC] = "{Token 0xEC} "; + m_tokens[AS_ED] = "{Token 0xED} "; m_tokens[AS_EE] = "{Token 0xEE} "; + m_tokens[AS_EF] = "{Token 0xEF} "; m_tokens[AS_F0] = "{Token 0xF0} "; + m_tokens[AS_F1] = "{Token 0xF1} "; m_tokens[AS_F2] = "{Token 0xF2} "; + m_tokens[AS_F3] = "{Token 0xF3} "; m_tokens[AS_F4] = "{Token 0xF4} "; + m_tokens[AS_F5] = "{Token 0xF5} "; m_tokens[AS_F6] = "{Token 0xF6} "; + m_tokens[AS_F7] = "{Token 0xF7} "; m_tokens[AS_F8] = "{Token 0xF8} "; + m_tokens[AS_F9] = "{Token 0xF9} "; m_tokens[AS_FA] = "{Token 0xFA} "; + m_tokens[AS_FB] = "{Token 0xFB} "; m_tokens[AS_FC] = "{Token 0xFC} "; + m_tokens[AS_FD] = "{Token 0xFD} "; m_tokens[AS_FE] = "{Token 0xFE} "; + m_tokens[AS_FF] = "{Token 0xFF} "; +} + +const quint16 ApplesoftToken::ASEnd = 0x80; const quint16 ApplesoftToken::ASFor = 0x81; +const quint16 ApplesoftToken::ASNext = 0x82; const quint16 ApplesoftToken::ASData = 0x83; +const quint16 ApplesoftToken::ASInput = 0x84; const quint16 ApplesoftToken::ASDel = 0x85; +const quint16 ApplesoftToken::ASDim = 0x86; const quint16 ApplesoftToken::ASRead = 0x87; +const quint16 ApplesoftToken::ASGr = 0x88; const quint16 ApplesoftToken::ASText = 0x89; +const quint16 ApplesoftToken::ASPr = 0x8A; const quint16 ApplesoftToken::ASIn = 0x8B; +const quint16 ApplesoftToken::ASCall = 0x8C; const quint16 ApplesoftToken::ASPlot = 0x8D; +const quint16 ApplesoftToken::ASHlin = 0x8E; const quint16 ApplesoftToken::ASVlin = 0x8F; + +const quint16 ApplesoftToken::ASHgr2 = 0x90; const quint16 ApplesoftToken::ASHgr = 0x91; +const quint16 ApplesoftToken::ASHcolor = 0x92; const quint16 ApplesoftToken::ASHplot = 0x93; +const quint16 ApplesoftToken::ASDraw = 0x94; const quint16 ApplesoftToken::ASXdraw = 0x95; +const quint16 ApplesoftToken::ASHtab = 0x96; const quint16 ApplesoftToken::ASHome = 0x97; +const quint16 ApplesoftToken::ASRot = 0x98; const quint16 ApplesoftToken::ASScale = 0x99; +const quint16 ApplesoftToken::ASShload = 0x9A; const quint16 ApplesoftToken::ASTrace = 0x9B; +const quint16 ApplesoftToken::ASNotrace = 0x9C; const quint16 ApplesoftToken::ASNormal = 0x9D; +const quint16 ApplesoftToken::ASInverse = 0x9E; const quint16 ApplesoftToken::ASFlash = 0x9F; + +const quint16 ApplesoftToken::ASColor = 0xA0; const quint16 ApplesoftToken::ASPop = 0xA1; +const quint16 ApplesoftToken::ASVtab = 0xA2; const quint16 ApplesoftToken::ASHimem = 0xA3; +const quint16 ApplesoftToken::ASLomem = 0xA4; const quint16 ApplesoftToken::ASOnerr = 0xA5; +const quint16 ApplesoftToken::ASResume = 0xA6; const quint16 ApplesoftToken::ASRecall = 0xA7; +const quint16 ApplesoftToken::ASStore = 0xA8; const quint16 ApplesoftToken::ASSpeed = 0xA9; +const quint16 ApplesoftToken::ASLet = 0xAA; const quint16 ApplesoftToken::ASGoto = 0xAB; +const quint16 ApplesoftToken::ASRun = 0xAC; const quint16 ApplesoftToken::ASIf = 0xAD; +const quint16 ApplesoftToken::ASRestore = 0xAE; const quint16 ApplesoftToken::ASAMP = 0xAF; + +const quint16 ApplesoftToken::ASGosub = 0xB0; const quint16 ApplesoftToken::ASReturn = 0xB1; +const quint16 ApplesoftToken::ASRem = 0xB2; const quint16 ApplesoftToken::ASStop = 0xB3; +const quint16 ApplesoftToken::ASOn = 0xB4; const quint16 ApplesoftToken::ASWait = 0xB5; +const quint16 ApplesoftToken::ASLoad = 0xB6; const quint16 ApplesoftToken::ASSave = 0xB7; +const quint16 ApplesoftToken::ASDef = 0xB8; const quint16 ApplesoftToken::ASPoke = 0xB9; +const quint16 ApplesoftToken::ASPrint = 0xBA; const quint16 ApplesoftToken::ASCont = 0xBB; +const quint16 ApplesoftToken::ASList = 0xBC; const quint16 ApplesoftToken::ASClear = 0xBD; +const quint16 ApplesoftToken::ASGet = 0xBE; const quint16 ApplesoftToken::ASNew = 0xBF; + +const quint16 ApplesoftToken::ASTab = 0xC0; const quint16 ApplesoftToken::ASTo = 0xC1; +const quint16 ApplesoftToken::ASFn = 0xC2; const quint16 ApplesoftToken::ASSpc = 0xC3; +const quint16 ApplesoftToken::ASThen = 0xC4; const quint16 ApplesoftToken::ASAt = 0xC5; +const quint16 ApplesoftToken::ASNot = 0xC6; const quint16 ApplesoftToken::ASStep = 0xC7; +const quint16 ApplesoftToken::ASPLUS = 0xC8; const quint16 ApplesoftToken::ASMINUS = 0xC9; +const quint16 ApplesoftToken::ASASTERISK = 0xCA; const quint16 ApplesoftToken::ASSLASH = 0xCB; +const quint16 ApplesoftToken::ASCARET = 0xCC; const quint16 ApplesoftToken::ASAnd = 0xCD; +const quint16 ApplesoftToken::ASOr = 0xCE; const quint16 ApplesoftToken::ASGREATER = 0xCF; + +const quint16 ApplesoftToken::ASEQUAL = 0xD0; const quint16 ApplesoftToken::ASLESS = 0xD1; +const quint16 ApplesoftToken::ASSgn = 0xD2; const quint16 ApplesoftToken::ASInt = 0xD3; +const quint16 ApplesoftToken::ASAbs = 0xD4; const quint16 ApplesoftToken::ASUsr = 0xD5; +const quint16 ApplesoftToken::ASFre = 0xD6; const quint16 ApplesoftToken::ASScrn = 0xD7; +const quint16 ApplesoftToken::ASPdl = 0xD8; const quint16 ApplesoftToken::ASPos = 0xD9; +const quint16 ApplesoftToken::ASSqr = 0xDA; const quint16 ApplesoftToken::ASRnd = 0xDB; +const quint16 ApplesoftToken::ASLog = 0xDC; const quint16 ApplesoftToken::ASExp = 0xDD; +const quint16 ApplesoftToken::ASCos = 0xDE; const quint16 ApplesoftToken::ASSin = 0xDF; + +const quint16 ApplesoftToken::ASTan = 0xE0; const quint16 ApplesoftToken::ASAtn = 0xE1; +const quint16 ApplesoftToken::ASPeek = 0xE2; const quint16 ApplesoftToken::ASLen = 0xE3; +const quint16 ApplesoftToken::ASStr = 0xE4; const quint16 ApplesoftToken::ASVal = 0xE5; +const quint16 ApplesoftToken::ASAsc = 0xE6; const quint16 ApplesoftToken::ASChr = 0xE7; +const quint16 ApplesoftToken::ASLeft = 0xE8; const quint16 ApplesoftToken::ASRight = 0xE9; +const quint16 ApplesoftToken::ASMid = 0xEA; const quint16 ApplesoftToken::AS_EB = 0xEB; +const quint16 ApplesoftToken::AS_EC = 0xEC; const quint16 ApplesoftToken::AS_ED = 0xED; +const quint16 ApplesoftToken::AS_EE = 0xEE; const quint16 ApplesoftToken::AS_EF = 0xEF; + +const quint16 ApplesoftToken::AS_F0 = 0xF0; const quint16 ApplesoftToken::AS_F1 = 0xF1; +const quint16 ApplesoftToken::AS_F2 = 0xF2; const quint16 ApplesoftToken::AS_F3 = 0xF3; +const quint16 ApplesoftToken::AS_F4 = 0xF4; const quint16 ApplesoftToken::AS_F5 = 0xF5; +const quint16 ApplesoftToken::AS_F6 = 0xF6; const quint16 ApplesoftToken::AS_F7 = 0xF7; +const quint16 ApplesoftToken::AS_F8 = 0xF8; const quint16 ApplesoftToken::AS_F9 = 0xF9; +const quint16 ApplesoftToken::AS_FA = 0xFA; const quint16 ApplesoftToken::AS_FB = 0xFB; +const quint16 ApplesoftToken::AS_FC = 0xFC; const quint16 ApplesoftToken::AS_FD = 0xFD; +const quint16 ApplesoftToken::AS_FE = 0xFE; const quint16 ApplesoftToken::AS_FF = 0xFF; diff --git a/src/applesoftfile/applesofttoken.h b/src/applesoftfile/applesofttoken.h index 92a463e..4a9c730 100644 --- a/src/applesoftfile/applesofttoken.h +++ b/src/applesoftfile/applesofttoken.h @@ -1,214 +1,214 @@ -#ifndef APPLESOFTTOKEN_H -#define APPLESOFTTOKEN_H - -#include -#include -#include -#include - -enum TextCharFormatType { - TCFDefault, - TCFCtrlChar, - TCFAscii, - TCFFunction, - TCFOperator, - TCFUnusedToken, - TCFNumber, - TCFString, - TCFVariable, - TCFDataString, - TCFRemString, - TCFUnknown -}; - - -class ApplesoftToken -{ -public: - - static const quint16 StringTokenVal = 0x100; - static const quint16 RemStringTokenVal = 0x101; - static const quint16 DataStringTokenVal = 0x102; - - static const quint16 IntegerTokenVal = 0x103; - static const quint16 FloatTokenVal = 0x104; - - static const quint16 IntVarTokenVal = 0x105; - static const quint16 IntAryVarTokenVal = 0x106; - - static const quint16 FloatVarTokenVal = 0x107; - static const quint16 FloatAryVarTokenVal = 0x108; - - static const quint16 StringVarTokenVal = 0x109; - static const quint16 StringAryVarTokenVal = 0x10A; - - static const quint16 OptFmtLeadingSpaceTokenValue = 0xe000; - static const quint16 OptFmtIndentLineBreakTokenValue = 0xe001; - static const quint16 OptFmtIndentTabTokenValue = 0xe002; - static const quint16 OptFmtIndentSpaceTokenValue = 0xe003; - static const quint16 OptFmtFlagFlowTargetNextTokenValue = 0xe004; - static const quint16 OptFmtReturnLineBreakTokenValue = 0xe005; - - static const quint16 ControlCharTokenVal = 0xfffd; - static const quint16 LineNumberTokenVal = 0xfffe; - static const quint16 DefaultTokenVal = 0xffff; - - - - static const quint16 ASEnd; static const quint16 ASFor; - static const quint16 ASNext; static const quint16 ASData; - static const quint16 ASInput; static const quint16 ASDel; - static const quint16 ASDim; static const quint16 ASRead; - static const quint16 ASGr; static const quint16 ASText; - static const quint16 ASPr; static const quint16 ASIn; - static const quint16 ASCall; static const quint16 ASPlot; - static const quint16 ASHlin; static const quint16 ASVlin; - - static const quint16 ASHgr2; static const quint16 ASHgr; - static const quint16 ASHcolor; static const quint16 ASHplot; - static const quint16 ASDraw; static const quint16 ASXdraw; - static const quint16 ASHtab; static const quint16 ASHome; - static const quint16 ASRot; static const quint16 ASScale; - static const quint16 ASShload; static const quint16 ASTrace; - static const quint16 ASNotrace; static const quint16 ASNormal; - static const quint16 ASInverse; static const quint16 ASFlash; - - static const quint16 ASColor; static const quint16 ASPop; - static const quint16 ASVtab; static const quint16 ASHimem; - static const quint16 ASLomem; static const quint16 ASOnerr; - static const quint16 ASResume; static const quint16 ASRecall; - static const quint16 ASStore; static const quint16 ASSpeed; - static const quint16 ASLet; static const quint16 ASGoto; - static const quint16 ASRun; static const quint16 ASIf; - static const quint16 ASRestore; static const quint16 ASAMP; - - static const quint16 ASGosub; static const quint16 ASReturn; - static const quint16 ASRem; static const quint16 ASStop; - static const quint16 ASOn; static const quint16 ASWait; - static const quint16 ASLoad; static const quint16 ASSave; - static const quint16 ASDef; static const quint16 ASPoke; - static const quint16 ASPrint; static const quint16 ASCont; - static const quint16 ASList; static const quint16 ASClear; - static const quint16 ASGet; static const quint16 ASNew; - - static const quint16 ASTab; static const quint16 ASTo; - static const quint16 ASFn; static const quint16 ASSpc; - static const quint16 ASThen; static const quint16 ASAt; - static const quint16 ASNot; static const quint16 ASStep; - static const quint16 ASPLUS; static const quint16 ASMINUS; - static const quint16 ASASTERISK; static const quint16 ASSLASH; - static const quint16 ASCARET; static const quint16 ASAnd; - static const quint16 ASOr; static const quint16 ASGREATER; - - static const quint16 ASEQUAL; static const quint16 ASLESS; - static const quint16 ASSgn; static const quint16 ASInt; - static const quint16 ASAbs; static const quint16 ASUsr; - static const quint16 ASFre; static const quint16 ASScrn; - static const quint16 ASPdl; static const quint16 ASPos; - static const quint16 ASSqr; static const quint16 ASRnd; - static const quint16 ASLog; static const quint16 ASExp; - static const quint16 ASCos; static const quint16 ASSin; - - static const quint16 ASTan; static const quint16 ASAtn; - static const quint16 ASPeek; static const quint16 ASLen; - static const quint16 ASStr; static const quint16 ASVal; - static const quint16 ASAsc; static const quint16 ASChr; - static const quint16 ASLeft; static const quint16 ASRight; - static const quint16 ASMid; static const quint16 AS_EB; - static const quint16 AS_EC; static const quint16 AS_ED; - static const quint16 AS_EE; static const quint16 AS_EF; - - static const quint16 AS_F0; static const quint16 AS_F1; - static const quint16 AS_F2; static const quint16 AS_F3; - static const quint16 AS_F4; static const quint16 AS_F5; - static const quint16 AS_F6; static const quint16 AS_F7; - static const quint16 AS_F8; static const quint16 AS_F9; - static const quint16 AS_FA; static const quint16 AS_FB; - static const quint16 AS_FC; static const quint16 AS_FD; - static const quint16 AS_FE; static const quint16 AS_FF; - - typedef enum { - UNKNOWN_TOKEN = 0x0, - ASCIICHAR_TOKEN = 0x1, - APPLESOFT_TOKEN = 0x2, - UNDEFINED_APPLESOFT_TOKEN = 0x3, - STRING_TOKEN = 0x4, - INTEGER_TOKEN = 0x5, - FLOAT_TOKEN = 0x6, - DATASTRING_TOKEN = 0x7, - REM_TOKEN = 0x8, - INT_VARIABLE_TOKEN = 0x9, - INT_ARY_VARIABLE_TOKEN = 0xA, - FLOAT_VARIABLE_TOKEN = 0xB, - FLOAT_ARY_VARIABLE_TOKEN = 0xC, - STRING_VARIABLE_TOKEN = 0xD, - STRING_ARY_VARIABLE_TOKEN = 0xE, - OPTIONAL_FORMAT_TOKEN = 0xF - } TokenType; - - typedef enum { - NONE, - COMMAND, - OPERATOR, - FUNCTION, - UNDEFINED_COMMAND, - OPTIONAL_FORMAT - } CommandType; - - ApplesoftToken(); - ApplesoftToken(quint16 id); - ApplesoftToken(quint16 id, QVariant payload); - - void setTokenId(quint16 id); - quint16 getTokenId() const { return m_token_id; } - - void setValue(QVariant value); - QVariant getValue() const { return m_payload; } - - QByteArray getByteStringValue() const { return m_payload.toByteArray(); } - QString getStringValue() const { return m_payload.toString(); } - quint32 getUnsignedIntegerValue() const { return (quint32) (m_payload.toUInt() & 0xFFFFFFFF); } - qint32 getIntegerValue() const { return (qint32) (m_payload.toInt() & 0xFFFFFFFF); } - - quint16 getWordValue() const { return (quint16) (m_payload.toUInt() & 0xFFFF); } - quint8 getByteValue() const { return (quint8) (m_payload.toUInt() & 0xFF); } - - TokenType getTokenType() const { return m_token_type; } - CommandType getCommandType() const { return m_command_type; } - - QString getRawPrintableString() const; - - QTextCharFormat textFormat() - { - return textFormat(m_token_id); - } - - static QTextCharFormat defaultTextFormat(); - static QTextCharFormat defaultInverseTextFormat(); - static QTextCharFormat textFormat(quint16 tokentype) ; - - QString getStringForToken(quint8 token) { - if (m_tokens.size() == 0) { initializeTokenTable(); } - return m_tokens[token]; - } - - - bool isOptFmtToken() const { return (m_token_id >= 0xe000 && m_token_id < 0xf000); } - -private: - void makeTextCharFormats(); - - - static QMap m_tokens; - - quint16 m_token_id; - QString m_tokenname; - QVariant m_payload; - TokenType m_token_type; - CommandType m_command_type; - - static void initializeTokenTable(); -}; - - -#endif // APPLESOFTTOKEN_H +#ifndef APPLESOFTTOKEN_H +#define APPLESOFTTOKEN_H + +#include +#include +#include +#include + +enum TextCharFormatType { + TCFDefault, + TCFCtrlChar, + TCFAscii, + TCFFunction, + TCFOperator, + TCFUnusedToken, + TCFNumber, + TCFString, + TCFVariable, + TCFDataString, + TCFRemString, + TCFUnknown +}; + + +class ApplesoftToken +{ +public: + + static const quint16 StringTokenVal = 0x100; + static const quint16 RemStringTokenVal = 0x101; + static const quint16 DataStringTokenVal = 0x102; + + static const quint16 IntegerTokenVal = 0x103; + static const quint16 FloatTokenVal = 0x104; + + static const quint16 IntVarTokenVal = 0x105; + static const quint16 IntAryVarTokenVal = 0x106; + + static const quint16 FloatVarTokenVal = 0x107; + static const quint16 FloatAryVarTokenVal = 0x108; + + static const quint16 StringVarTokenVal = 0x109; + static const quint16 StringAryVarTokenVal = 0x10A; + + static const quint16 OptFmtLeadingSpaceTokenValue = 0xe000; + static const quint16 OptFmtIndentLineBreakTokenValue = 0xe001; + static const quint16 OptFmtIndentTabTokenValue = 0xe002; + static const quint16 OptFmtIndentSpaceTokenValue = 0xe003; + static const quint16 OptFmtFlagFlowTargetNextTokenValue = 0xe004; + static const quint16 OptFmtReturnLineBreakTokenValue = 0xe005; + + static const quint16 ControlCharTokenVal = 0xfffd; + static const quint16 LineNumberTokenVal = 0xfffe; + static const quint16 DefaultTokenVal = 0xffff; + + + + static const quint16 ASEnd; static const quint16 ASFor; + static const quint16 ASNext; static const quint16 ASData; + static const quint16 ASInput; static const quint16 ASDel; + static const quint16 ASDim; static const quint16 ASRead; + static const quint16 ASGr; static const quint16 ASText; + static const quint16 ASPr; static const quint16 ASIn; + static const quint16 ASCall; static const quint16 ASPlot; + static const quint16 ASHlin; static const quint16 ASVlin; + + static const quint16 ASHgr2; static const quint16 ASHgr; + static const quint16 ASHcolor; static const quint16 ASHplot; + static const quint16 ASDraw; static const quint16 ASXdraw; + static const quint16 ASHtab; static const quint16 ASHome; + static const quint16 ASRot; static const quint16 ASScale; + static const quint16 ASShload; static const quint16 ASTrace; + static const quint16 ASNotrace; static const quint16 ASNormal; + static const quint16 ASInverse; static const quint16 ASFlash; + + static const quint16 ASColor; static const quint16 ASPop; + static const quint16 ASVtab; static const quint16 ASHimem; + static const quint16 ASLomem; static const quint16 ASOnerr; + static const quint16 ASResume; static const quint16 ASRecall; + static const quint16 ASStore; static const quint16 ASSpeed; + static const quint16 ASLet; static const quint16 ASGoto; + static const quint16 ASRun; static const quint16 ASIf; + static const quint16 ASRestore; static const quint16 ASAMP; + + static const quint16 ASGosub; static const quint16 ASReturn; + static const quint16 ASRem; static const quint16 ASStop; + static const quint16 ASOn; static const quint16 ASWait; + static const quint16 ASLoad; static const quint16 ASSave; + static const quint16 ASDef; static const quint16 ASPoke; + static const quint16 ASPrint; static const quint16 ASCont; + static const quint16 ASList; static const quint16 ASClear; + static const quint16 ASGet; static const quint16 ASNew; + + static const quint16 ASTab; static const quint16 ASTo; + static const quint16 ASFn; static const quint16 ASSpc; + static const quint16 ASThen; static const quint16 ASAt; + static const quint16 ASNot; static const quint16 ASStep; + static const quint16 ASPLUS; static const quint16 ASMINUS; + static const quint16 ASASTERISK; static const quint16 ASSLASH; + static const quint16 ASCARET; static const quint16 ASAnd; + static const quint16 ASOr; static const quint16 ASGREATER; + + static const quint16 ASEQUAL; static const quint16 ASLESS; + static const quint16 ASSgn; static const quint16 ASInt; + static const quint16 ASAbs; static const quint16 ASUsr; + static const quint16 ASFre; static const quint16 ASScrn; + static const quint16 ASPdl; static const quint16 ASPos; + static const quint16 ASSqr; static const quint16 ASRnd; + static const quint16 ASLog; static const quint16 ASExp; + static const quint16 ASCos; static const quint16 ASSin; + + static const quint16 ASTan; static const quint16 ASAtn; + static const quint16 ASPeek; static const quint16 ASLen; + static const quint16 ASStr; static const quint16 ASVal; + static const quint16 ASAsc; static const quint16 ASChr; + static const quint16 ASLeft; static const quint16 ASRight; + static const quint16 ASMid; static const quint16 AS_EB; + static const quint16 AS_EC; static const quint16 AS_ED; + static const quint16 AS_EE; static const quint16 AS_EF; + + static const quint16 AS_F0; static const quint16 AS_F1; + static const quint16 AS_F2; static const quint16 AS_F3; + static const quint16 AS_F4; static const quint16 AS_F5; + static const quint16 AS_F6; static const quint16 AS_F7; + static const quint16 AS_F8; static const quint16 AS_F9; + static const quint16 AS_FA; static const quint16 AS_FB; + static const quint16 AS_FC; static const quint16 AS_FD; + static const quint16 AS_FE; static const quint16 AS_FF; + + typedef enum { + UNKNOWN_TOKEN = 0x0, + ASCIICHAR_TOKEN = 0x1, + APPLESOFT_TOKEN = 0x2, + UNDEFINED_APPLESOFT_TOKEN = 0x3, + STRING_TOKEN = 0x4, + INTEGER_TOKEN = 0x5, + FLOAT_TOKEN = 0x6, + DATASTRING_TOKEN = 0x7, + REM_TOKEN = 0x8, + INT_VARIABLE_TOKEN = 0x9, + INT_ARY_VARIABLE_TOKEN = 0xA, + FLOAT_VARIABLE_TOKEN = 0xB, + FLOAT_ARY_VARIABLE_TOKEN = 0xC, + STRING_VARIABLE_TOKEN = 0xD, + STRING_ARY_VARIABLE_TOKEN = 0xE, + OPTIONAL_FORMAT_TOKEN = 0xF + } TokenType; + + typedef enum { + NONE, + COMMAND, + OPERATOR, + FUNCTION, + UNDEFINED_COMMAND, + OPTIONAL_FORMAT + } CommandType; + + ApplesoftToken(); + ApplesoftToken(quint16 id); + ApplesoftToken(quint16 id, QVariant payload); + + void setTokenId(quint16 id); + quint16 getTokenId() const { return m_token_id; } + + void setValue(QVariant value); + QVariant getValue() const { return m_payload; } + + QByteArray getByteStringValue() const { return m_payload.toByteArray(); } + QString getStringValue() const { return m_payload.toString(); } + quint32 getUnsignedIntegerValue() const { return (quint32) (m_payload.toUInt() & 0xFFFFFFFF); } + qint32 getIntegerValue() const { return (qint32) (m_payload.toInt() & 0xFFFFFFFF); } + + quint16 getWordValue() const { return (quint16) (m_payload.toUInt() & 0xFFFF); } + quint8 getByteValue() const { return (quint8) (m_payload.toUInt() & 0xFF); } + + TokenType getTokenType() const { return m_token_type; } + CommandType getCommandType() const { return m_command_type; } + + QString getRawPrintableString() const; + + QTextCharFormat textFormat() + { + return textFormat(m_token_id); + } + + static QTextCharFormat defaultTextFormat(); + static QTextCharFormat defaultInverseTextFormat(); + static QTextCharFormat textFormat(quint16 tokentype) ; + + QString getStringForToken(quint8 token) { + if (m_tokens.size() == 0) { initializeTokenTable(); } + return m_tokens[token]; + } + + + bool isOptFmtToken() const { return (m_token_id >= 0xe000 && m_token_id < 0xf000); } + +private: + void makeTextCharFormats(); + + + static QMap m_tokens; + + quint16 m_token_id; + QString m_tokenname; + QVariant m_payload; + TokenType m_token_type; + CommandType m_command_type; + + static void initializeTokenTable(); +}; + + +#endif // APPLESOFTTOKEN_H diff --git a/src/binaryfile/AssemblerSymbolModel.cpp b/src/binaryfile/AssemblerSymbolModel.cpp index 95e1a30..8f9ddae 100644 --- a/src/binaryfile/AssemblerSymbolModel.cpp +++ b/src/binaryfile/AssemblerSymbolModel.cpp @@ -1,136 +1,136 @@ -#include "AssemblerSymbolModel.h" -#include "util.h" - -#include - -AssemblerSymbolModel::AssemblerSymbolModel(QObject *parent, AssemblerSymbols *symbols) - :QAbstractTableModel(parent) -{ - setAssemblerSymbolsData(symbols); -} - -void AssemblerSymbolModel::setAssemblerSymbolsData(AssemblerSymbols *symbols) -{ - assemblerSymbols = symbols; - - if (assemblerSymbols) - { - connect(assemblerSymbols, &AssemblerSymbols::symbolAddedAt, this, &AssemblerSymbolModel::handleSymbolAddition); - connect(assemblerSymbols, &AssemblerSymbols::symbolChangedAt, this, &AssemblerSymbolModel::handleSymbolChange); - connect(assemblerSymbols, &AssemblerSymbols::symbolRemovedAt, this, &AssemblerSymbolModel::handleSymbolRemoval); - } - -} - -QVariant AssemblerSymbolModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (!assemblerSymbols) return QVariant(); - - if (orientation == Qt::Horizontal) - { - if (role == Qt::DisplayRole) - { - if (section == 0) - return ""; - - } - } - else // Orientation == Qt::Vertical - { - if (role == Qt::DisplayRole) - { - return "0x"+uint16ToHex(assemblerSymbols->at(section).address); - } - } - return QVariant(); -} - - -int AssemblerSymbolModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - if (!assemblerSymbols) return 0; - - return assemblerSymbols->numAssemblerSymbols(); -} - -int AssemblerSymbolModel::columnCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return 2; -} - -QVariant AssemblerSymbolModel::data(const QModelIndex &index, int role) const -{ - if (!assemblerSymbols) return QVariant(); - - if (role == Qt::DisplayRole) - { - if (index.column() == 0) - { - QString val; - if (assemblerSymbols->at(index.row()).symbolsize == SizeWord) - { - val = "WORD"; - } - else if (assemblerSymbols->at(index.row()).symbolsize == SizeByte) - { - val = "BYTE"; - } - return val; - } - else if (index.column() == 1) - { - return assemblerSymbols->at(index.row()).name; - } - } - return QVariant(); -} - -bool AssemblerSymbolModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if (!assemblerSymbols) return false; - - if (data(index, role) != value) { - if (index.column() == 1) - { - assemblerSymbols->symbolRefAt(index.row()).name = value.toString(); - } - emit dataChanged(index, index, QVector() << role); - return true; - } - return false; -} - -Qt::ItemFlags AssemblerSymbolModel::flags(const QModelIndex &index) const -{ - Q_UNUSED(index); - if (index.column() == 1) - return Qt::ItemIsEditable | QAbstractTableModel::flags(index); - else - return QAbstractTableModel::flags(index); -} - -bool AssemblerSymbolModel::insertRows(int row, int count, const QModelIndex &parent) -{ - beginInsertRows(parent, row, row + count - 1); - endInsertRows(); - return false; -} - -bool AssemblerSymbolModel::removeRows(int row, int count, const QModelIndex &parent) -{ - if (!assemblerSymbols) return false; - bool success = false; - - beginRemoveRows(parent, row, row + count - 1); - for (int idx = 0; idx < count; idx++) - { - assemblerSymbols->removeSymbolAt(row); - success = true; - } - endRemoveRows(); - return success; -} - - +#include "AssemblerSymbolModel.h" +#include "util.h" + +#include + +AssemblerSymbolModel::AssemblerSymbolModel(QObject *parent, AssemblerSymbols *symbols) + :QAbstractTableModel(parent) +{ + setAssemblerSymbolsData(symbols); +} + +void AssemblerSymbolModel::setAssemblerSymbolsData(AssemblerSymbols *symbols) +{ + assemblerSymbols = symbols; + + if (assemblerSymbols) + { + connect(assemblerSymbols, &AssemblerSymbols::symbolAddedAt, this, &AssemblerSymbolModel::handleSymbolAddition); + connect(assemblerSymbols, &AssemblerSymbols::symbolChangedAt, this, &AssemblerSymbolModel::handleSymbolChange); + connect(assemblerSymbols, &AssemblerSymbols::symbolRemovedAt, this, &AssemblerSymbolModel::handleSymbolRemoval); + } + +} + +QVariant AssemblerSymbolModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (!assemblerSymbols) return QVariant(); + + if (orientation == Qt::Horizontal) + { + if (role == Qt::DisplayRole) + { + if (section == 0) + return ""; + + } + } + else // Orientation == Qt::Vertical + { + if (role == Qt::DisplayRole) + { + return "0x"+uint16ToHex(assemblerSymbols->at(section).address); + } + } + return QVariant(); +} + + +int AssemblerSymbolModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + if (!assemblerSymbols) return 0; + + return assemblerSymbols->numAssemblerSymbols(); +} + +int AssemblerSymbolModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return 2; +} + +QVariant AssemblerSymbolModel::data(const QModelIndex &index, int role) const +{ + if (!assemblerSymbols) return QVariant(); + + if (role == Qt::DisplayRole) + { + if (index.column() == 0) + { + QString val; + if (assemblerSymbols->at(index.row()).symbolsize == SizeWord) + { + val = "WORD"; + } + else if (assemblerSymbols->at(index.row()).symbolsize == SizeByte) + { + val = "BYTE"; + } + return val; + } + else if (index.column() == 1) + { + return assemblerSymbols->at(index.row()).name; + } + } + return QVariant(); +} + +bool AssemblerSymbolModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (!assemblerSymbols) return false; + + if (data(index, role) != value) { + if (index.column() == 1) + { + assemblerSymbols->symbolRefAt(index.row()).name = value.toString(); + } + emit dataChanged(index, index, QVector() << role); + return true; + } + return false; +} + +Qt::ItemFlags AssemblerSymbolModel::flags(const QModelIndex &index) const +{ + Q_UNUSED(index); + if (index.column() == 1) + return Qt::ItemIsEditable | QAbstractTableModel::flags(index); + else + return QAbstractTableModel::flags(index); +} + +bool AssemblerSymbolModel::insertRows(int row, int count, const QModelIndex &parent) +{ + beginInsertRows(parent, row, row + count - 1); + endInsertRows(); + return false; +} + +bool AssemblerSymbolModel::removeRows(int row, int count, const QModelIndex &parent) +{ + if (!assemblerSymbols) return false; + bool success = false; + + beginRemoveRows(parent, row, row + count - 1); + for (int idx = 0; idx < count; idx++) + { + assemblerSymbols->removeSymbolAt(row); + success = true; + } + endRemoveRows(); + return success; +} + + diff --git a/src/binaryfile/AssemblerSymbolModel.h b/src/binaryfile/AssemblerSymbolModel.h index 3cb1876..e14443e 100644 --- a/src/binaryfile/AssemblerSymbolModel.h +++ b/src/binaryfile/AssemblerSymbolModel.h @@ -1,60 +1,60 @@ -#ifndef ASSEMBLERSYMBOLMODEL_H -#define ASSEMBLERSYMBOLMODEL_H - - -#include "AssemblerSymbols.h" - -#include -#include - - - - -class AssemblerSymbolModel : public QAbstractTableModel -{ - Q_OBJECT - -public: - explicit AssemblerSymbolModel(QObject *parent = 0, AssemblerSymbols *symbols = Q_NULLPTR); - void setAssemblerSymbolsData(AssemblerSymbols *symbols); - - // Header: - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;//DONE - - // Basic functionality: - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent = QModelIndex()) const override; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - - // Editable: - bool setData(const QModelIndex &index, const QVariant &value, - int role = Qt::EditRole) override; - - Qt::ItemFlags flags(const QModelIndex& index) const override; - - // Add data: - bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; - - // Remove data: - bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; - - void doTestData(); - - -protected slots: - void handleSymbolAddition(int location) { insertRows(location,1); } - void handleSymbolRemoval(int location) { removeRows(location, 1); } - void handleSymbolChange(int location) - { - QModelIndex ind = createIndex(location,0); - emit dataChanged(ind,ind,QVector() << Qt::DisplayRole); - } - - -private: - AssemblerSymbols *assemblerSymbols; -}; - - -#endif // ASSEMBLERSYMBOLMODEL_H +#ifndef ASSEMBLERSYMBOLMODEL_H +#define ASSEMBLERSYMBOLMODEL_H + + +#include "AssemblerSymbols.h" + +#include +#include + + + + +class AssemblerSymbolModel : public QAbstractTableModel +{ + Q_OBJECT + +public: + explicit AssemblerSymbolModel(QObject *parent = 0, AssemblerSymbols *symbols = Q_NULLPTR); + void setAssemblerSymbolsData(AssemblerSymbols *symbols); + + // Header: + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;//DONE + + // Basic functionality: + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + + // Editable: + bool setData(const QModelIndex &index, const QVariant &value, + int role = Qt::EditRole) override; + + Qt::ItemFlags flags(const QModelIndex& index) const override; + + // Add data: + bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; + + // Remove data: + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; + + void doTestData(); + + +protected slots: + void handleSymbolAddition(int location) { insertRows(location,1); } + void handleSymbolRemoval(int location) { removeRows(location, 1); } + void handleSymbolChange(int location) + { + QModelIndex ind = createIndex(location,0); + emit dataChanged(ind,ind,QVector() << Qt::DisplayRole); + } + + +private: + AssemblerSymbols *assemblerSymbols; +}; + + +#endif // ASSEMBLERSYMBOLMODEL_H diff --git a/src/binaryfile/AssemblerSymbols.cpp b/src/binaryfile/AssemblerSymbols.cpp index f4f591d..a901e8a 100644 --- a/src/binaryfile/AssemblerSymbols.cpp +++ b/src/binaryfile/AssemblerSymbols.cpp @@ -1,142 +1,142 @@ -#include "AssemblerSymbols.h" - - -AssemblerSymbols::AssemblerSymbols(QObject *parent) : QObject(parent) -{ - -} - -int AssemblerSymbols::locationOfSymbolAtAddress(quint16 address) -{ - // Assume list m_assemblerSymbols is sorted by address (it should be) - QListIterator it(m_assemblerSymbols); - int idx = 0; - while (it.hasNext()) - { - AssemblerSymbol ep = it.next(); - if (ep.address == address) return idx; - if (ep.address > address) return -1; - idx++; - } - return -1; -} - -bool AssemblerSymbols::hasAssemSymbolAtAddress(quint16 address) -{ - // Assume list m_assemblerSymbols is sorted by address (it should be) - QListIterator it(m_assemblerSymbols); - while (it.hasNext()) - { - AssemblerSymbol ep = it.next(); - if (ep.address == address) return true; - if (ep.address > address) return false; - } - return false; -} - -void AssemblerSymbols::editSymbol(int location, AssemblerSymbol newSymbol) -{ - - if (m_assemblerSymbols.at(location).address == newSymbol.address) - { - m_assemblerSymbols[location].name = newSymbol.name; - emit symbolChangedAt(location); - } - else - { - removeSymbolAt(location); - addSymbol(newSymbol); - } -} - -void AssemblerSymbols::addSymbol(AssemblerSymbol ep) -{ - if (hasAssemSymbolAtAddress(ep.address)) return; - - int idx = 0; - for (; idx < m_assemblerSymbols.count(); idx++) - { - if (ep.address < m_assemblerSymbols[idx].address) - break; - } - m_assemblerSymbols.insert(idx,ep); - emit symbolAddedAt(idx); - emit symbolAdded(ep,idx); -} - -void AssemblerSymbols::removeSymbolAt(int location) -{ - m_assemblerSymbols.removeAt(location); -} - -//--------------------------------------------------------------------------- -// STREAMING OPERATORS - -QDataStream &AssemblerSymbols::read(QDataStream &dataStream) -{ - quint8 version; - dataStream >> version; - if (version == 0) - { - dataStream >> m_assemblerSymbols; - } - else qWarning("Unhandled version of AssemSymbolModel (%d) found in QDataStream",version); - - return dataStream; -} - -QDataStream &AssemblerSymbols::write(QDataStream &dataStream) const -{ - quint8 version = 0; // Increment this and update read() if new items are added - dataStream << version; - dataStream << m_assemblerSymbols; - return dataStream; -} - -QDataStream &operator<<(QDataStream &out, const AssemblerSymbols &model) -{ - return model.write(out); -} - -QDataStream &operator>>(QDataStream &in, AssemblerSymbols&model) -{ - return model.read(in); -} - -QDataStream &operator<<(QDataStream &out, const AssemblerSymbol &model) -{ - out << model.address; - out << model.name; - out << (qint32) model.symbolsize; - return out; -} - -QDataStream &operator>>(QDataStream &in, AssemblerSymbol &model) -{ - in >> model.address; - in >> model.name; - qint32 size; - in >> size; - model.symbolsize = (SymbolSize) size; - return in; -} - -//--------------------------------------------------------------------------- -// TESTING - -void AssemblerSymbols::doTestData() -{ - AssemblerSymbol ep; - ep.address = 0x0100; - ep.name = "Test Symbol 1"; - addSymbol(ep); - ep.address = 0x0200; - ep.name = "Test Symbol 2"; - addSymbol(ep); - ep.address = 0x0300; - ep.name = "Test Symbol 3"; - addSymbol(ep); - -} - - +#include "AssemblerSymbols.h" + + +AssemblerSymbols::AssemblerSymbols(QObject *parent) : QObject(parent) +{ + +} + +int AssemblerSymbols::locationOfSymbolAtAddress(quint16 address) +{ + // Assume list m_assemblerSymbols is sorted by address (it should be) + QListIterator it(m_assemblerSymbols); + int idx = 0; + while (it.hasNext()) + { + AssemblerSymbol ep = it.next(); + if (ep.address == address) return idx; + if (ep.address > address) return -1; + idx++; + } + return -1; +} + +bool AssemblerSymbols::hasAssemSymbolAtAddress(quint16 address) +{ + // Assume list m_assemblerSymbols is sorted by address (it should be) + QListIterator it(m_assemblerSymbols); + while (it.hasNext()) + { + AssemblerSymbol ep = it.next(); + if (ep.address == address) return true; + if (ep.address > address) return false; + } + return false; +} + +void AssemblerSymbols::editSymbol(int location, AssemblerSymbol newSymbol) +{ + + if (m_assemblerSymbols.at(location).address == newSymbol.address) + { + m_assemblerSymbols[location].name = newSymbol.name; + emit symbolChangedAt(location); + } + else + { + removeSymbolAt(location); + addSymbol(newSymbol); + } +} + +void AssemblerSymbols::addSymbol(AssemblerSymbol ep) +{ + if (hasAssemSymbolAtAddress(ep.address)) return; + + int idx = 0; + for (; idx < m_assemblerSymbols.count(); idx++) + { + if (ep.address < m_assemblerSymbols[idx].address) + break; + } + m_assemblerSymbols.insert(idx,ep); + emit symbolAddedAt(idx); + emit symbolAdded(ep,idx); +} + +void AssemblerSymbols::removeSymbolAt(int location) +{ + m_assemblerSymbols.removeAt(location); +} + +//--------------------------------------------------------------------------- +// STREAMING OPERATORS + +QDataStream &AssemblerSymbols::read(QDataStream &dataStream) +{ + quint8 version; + dataStream >> version; + if (version == 0) + { + dataStream >> m_assemblerSymbols; + } + else qWarning("Unhandled version of AssemSymbolModel (%d) found in QDataStream",version); + + return dataStream; +} + +QDataStream &AssemblerSymbols::write(QDataStream &dataStream) const +{ + quint8 version = 0; // Increment this and update read() if new items are added + dataStream << version; + dataStream << m_assemblerSymbols; + return dataStream; +} + +QDataStream &operator<<(QDataStream &out, const AssemblerSymbols &model) +{ + return model.write(out); +} + +QDataStream &operator>>(QDataStream &in, AssemblerSymbols&model) +{ + return model.read(in); +} + +QDataStream &operator<<(QDataStream &out, const AssemblerSymbol &model) +{ + out << model.address; + out << model.name; + out << (qint32) model.symbolsize; + return out; +} + +QDataStream &operator>>(QDataStream &in, AssemblerSymbol &model) +{ + in >> model.address; + in >> model.name; + qint32 size; + in >> size; + model.symbolsize = (SymbolSize) size; + return in; +} + +//--------------------------------------------------------------------------- +// TESTING + +void AssemblerSymbols::doTestData() +{ + AssemblerSymbol ep; + ep.address = 0x0100; + ep.name = "Test Symbol 1"; + addSymbol(ep); + ep.address = 0x0200; + ep.name = "Test Symbol 2"; + addSymbol(ep); + ep.address = 0x0300; + ep.name = "Test Symbol 3"; + addSymbol(ep); + +} + + diff --git a/src/binaryfile/AssemblerSymbols.h b/src/binaryfile/AssemblerSymbols.h index 482ebeb..75db468 100644 --- a/src/binaryfile/AssemblerSymbols.h +++ b/src/binaryfile/AssemblerSymbols.h @@ -1,60 +1,60 @@ -#ifndef ASSEMBLERSYMBOLS_H -#define ASSEMBLERSYMBOLS_H - -#include -#include - -typedef enum { - SizeUnknown = 0, - SizeByte = 1, - SizeWord = 2 -} SymbolSize; - -struct AssemblerSymbol { - quint16 address; - QString name; - SymbolSize symbolsize; -}; - - -class AssemblerSymbols : public QObject -{ - Q_OBJECT -public: - explicit AssemblerSymbols(QObject *parent = 0); - - bool hasAssemSymbolAtAddress(quint16 address); - - const AssemblerSymbol &at(int location) const { return m_assemblerSymbols.at(location); } - AssemblerSymbol &symbolRefAt(int location) { return m_assemblerSymbols[location]; } - AssemblerSymbol &operator[](int location) { return m_assemblerSymbols[location]; } - - void editSymbol(int at, AssemblerSymbol newSymbol); - - QDataStream &read(QDataStream &dataStream); - QDataStream &write(QDataStream &dataStream) const; - - int numAssemblerSymbols() const { return m_assemblerSymbols.count(); } - - void doTestData(); - - int locationOfSymbolAtAddress(quint16 address); -signals: - void symbolAdded(AssemblerSymbol &AssemblerSymbol, int location); - void symbolAddedAt(int location); - void symbolRemovedAt(int location); - void symbolChangedAt(int location); - -public slots: - void addSymbol(AssemblerSymbol ep); - void removeSymbolAt(int location); - -protected: - QList m_assemblerSymbols; -}; - -QDataStream &operator<<(QDataStream &out, const AssemblerSymbols &model); -QDataStream &operator>>(QDataStream &in, AssemblerSymbols &model); - - -#endif // ASSEMBLERSYMBOLS_H +#ifndef ASSEMBLERSYMBOLS_H +#define ASSEMBLERSYMBOLS_H + +#include +#include + +typedef enum { + SizeUnknown = 0, + SizeByte = 1, + SizeWord = 2 +} SymbolSize; + +struct AssemblerSymbol { + quint16 address; + QString name; + SymbolSize symbolsize; +}; + + +class AssemblerSymbols : public QObject +{ + Q_OBJECT +public: + explicit AssemblerSymbols(QObject *parent = 0); + + bool hasAssemSymbolAtAddress(quint16 address); + + const AssemblerSymbol &at(int location) const { return m_assemblerSymbols.at(location); } + AssemblerSymbol &symbolRefAt(int location) { return m_assemblerSymbols[location]; } + AssemblerSymbol &operator[](int location) { return m_assemblerSymbols[location]; } + + void editSymbol(int at, AssemblerSymbol newSymbol); + + QDataStream &read(QDataStream &dataStream); + QDataStream &write(QDataStream &dataStream) const; + + int numAssemblerSymbols() const { return m_assemblerSymbols.count(); } + + void doTestData(); + + int locationOfSymbolAtAddress(quint16 address); +signals: + void symbolAdded(AssemblerSymbol &AssemblerSymbol, int location); + void symbolAddedAt(int location); + void symbolRemovedAt(int location); + void symbolChangedAt(int location); + +public slots: + void addSymbol(AssemblerSymbol ep); + void removeSymbolAt(int location); + +protected: + QList m_assemblerSymbols; +}; + +QDataStream &operator<<(QDataStream &out, const AssemblerSymbols &model); +QDataStream &operator>>(QDataStream &in, AssemblerSymbols &model); + + +#endif // ASSEMBLERSYMBOLS_H diff --git a/src/binaryfile/EntryPointModel.cpp b/src/binaryfile/EntryPointModel.cpp index 8f102fb..b4e1e5e 100644 --- a/src/binaryfile/EntryPointModel.cpp +++ b/src/binaryfile/EntryPointModel.cpp @@ -1,134 +1,134 @@ -#include "EntryPointModel.h" -#include "util.h" - -#include - - - -EntryPointModel::EntryPointModel(QObject *parent, EntryPoints *points) - : QAbstractTableModel(parent) -{ - setEntryPointsData(points); -} - -void EntryPointModel::setEntryPointsData(EntryPoints *points) -{ - entryPoints = points; - - if (entryPoints) - { - connect(entryPoints, &EntryPoints::pointAddedAt, this, &EntryPointModel::handlePointAddition); - connect(entryPoints, &EntryPoints::pointChangedAt, this, &EntryPointModel::handlePointChange); - - } - -} - -QVariant EntryPointModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (!entryPoints) return QVariant(); - - if (orientation == Qt::Horizontal) - { - if (role == Qt::DisplayRole) - { - if (section == 0) - return ""; - - } - } - else // Orientation == Qt::Vertical - { - if (role == Qt::DisplayRole) - { - return "0x"+uint16ToHex(entryPoints->at(section).address); - } - } - return QVariant(); -} - - -int EntryPointModel::rowCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - if (!entryPoints) return 0; - - return entryPoints->numEntryPoints(); -} - -int EntryPointModel::columnCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent); - return 1; -} - -QVariant EntryPointModel::data(const QModelIndex &index, int role) const -{ - if (!entryPoints) return QVariant(); - - if (role == Qt::DisplayRole) - { - if (index.column() == 0) - { - return entryPoints->at(index.row()).note; - } - } - return QVariant(); -} - -bool EntryPointModel::setData(const QModelIndex &index, const QVariant &value, int role) -{ - if (!entryPoints) return false; - - if (data(index, role) != value) { - if (index.column() == 0) - { - entryPoints->pointRefAt(index.row()).note = value.toString(); - } - emit dataChanged(index, index, QVector() << role); - return true; - } - return false; -} - -Qt::ItemFlags EntryPointModel::flags(const QModelIndex &index) const -{ - Q_UNUSED(index); - if (index.column() == 0) - return Qt::ItemIsEditable | QAbstractTableModel::flags(index); - else - return QAbstractTableModel::flags(index); -} - -bool EntryPointModel::insertRows(int row, int count, const QModelIndex &parent) -{ - beginInsertRows(parent, row, row + count - 1); - endInsertRows(); - return false; -} - -bool EntryPointModel::removeRows(int row, int count, const QModelIndex &parent) -{ - qDebug() << __FILE__ << __LINE__; - - if (!entryPoints) return false; - qDebug() << __FILE__ << __LINE__; - bool success = false; - qDebug() << __FILE__ << __LINE__; - - beginRemoveRows(parent, row, row + count - 1); - qDebug() << __FILE__ << __LINE__; - for (int idx = 0; idx < count; idx++) - { - qDebug() << __FILE__ << __LINE__; - entryPoints->removePointAt(row); - qDebug() << __FILE__ << __LINE__; - success = true; - } - qDebug() << __FILE__ << __LINE__; - endRemoveRows(); - qDebug() << __FILE__ << __LINE__; - return success; -} - - +#include "EntryPointModel.h" +#include "util.h" + +#include + + + +EntryPointModel::EntryPointModel(QObject *parent, EntryPoints *points) + : QAbstractTableModel(parent) +{ + setEntryPointsData(points); +} + +void EntryPointModel::setEntryPointsData(EntryPoints *points) +{ + entryPoints = points; + + if (entryPoints) + { + connect(entryPoints, &EntryPoints::pointAddedAt, this, &EntryPointModel::handlePointAddition); + connect(entryPoints, &EntryPoints::pointChangedAt, this, &EntryPointModel::handlePointChange); + + } + +} + +QVariant EntryPointModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (!entryPoints) return QVariant(); + + if (orientation == Qt::Horizontal) + { + if (role == Qt::DisplayRole) + { + if (section == 0) + return ""; + + } + } + else // Orientation == Qt::Vertical + { + if (role == Qt::DisplayRole) + { + return "0x"+uint16ToHex(entryPoints->at(section).address); + } + } + return QVariant(); +} + + +int EntryPointModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + if (!entryPoints) return 0; + + return entryPoints->numEntryPoints(); +} + +int EntryPointModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return 1; +} + +QVariant EntryPointModel::data(const QModelIndex &index, int role) const +{ + if (!entryPoints) return QVariant(); + + if (role == Qt::DisplayRole) + { + if (index.column() == 0) + { + return entryPoints->at(index.row()).note; + } + } + return QVariant(); +} + +bool EntryPointModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (!entryPoints) return false; + + if (data(index, role) != value) { + if (index.column() == 0) + { + entryPoints->pointRefAt(index.row()).note = value.toString(); + } + emit dataChanged(index, index, QVector() << role); + return true; + } + return false; +} + +Qt::ItemFlags EntryPointModel::flags(const QModelIndex &index) const +{ + Q_UNUSED(index); + if (index.column() == 0) + return Qt::ItemIsEditable | QAbstractTableModel::flags(index); + else + return QAbstractTableModel::flags(index); +} + +bool EntryPointModel::insertRows(int row, int count, const QModelIndex &parent) +{ + beginInsertRows(parent, row, row + count - 1); + endInsertRows(); + return false; +} + +bool EntryPointModel::removeRows(int row, int count, const QModelIndex &parent) +{ + qDebug() << __FILE__ << __LINE__; + + if (!entryPoints) return false; + qDebug() << __FILE__ << __LINE__; + bool success = false; + qDebug() << __FILE__ << __LINE__; + + beginRemoveRows(parent, row, row + count - 1); + qDebug() << __FILE__ << __LINE__; + for (int idx = 0; idx < count; idx++) + { + qDebug() << __FILE__ << __LINE__; + entryPoints->removePointAt(row); + qDebug() << __FILE__ << __LINE__; + success = true; + } + qDebug() << __FILE__ << __LINE__; + endRemoveRows(); + qDebug() << __FILE__ << __LINE__; + return success; +} + + diff --git a/src/binaryfile/EntryPointModel.h b/src/binaryfile/EntryPointModel.h index 118a4f6..935ae64 100644 --- a/src/binaryfile/EntryPointModel.h +++ b/src/binaryfile/EntryPointModel.h @@ -1,60 +1,60 @@ -#ifndef ENTRYPOINTMODEL_H -#define ENTRYPOINTMODEL_H - -#include "EntryPoints.h" - -#include -#include - - - - -class EntryPointModel : public QAbstractTableModel -{ - Q_OBJECT - -public: - explicit EntryPointModel(QObject *parent = 0, EntryPoints *points = Q_NULLPTR); - void setEntryPointsData(EntryPoints *points); - - // Header: - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; - // Basic functionality: - int rowCount(const QModelIndex &parent = QModelIndex()) const override; - int columnCount(const QModelIndex &parent = QModelIndex()) const override; - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; - - // Editable: - bool setData(const QModelIndex &index, const QVariant &value, - int role = Qt::EditRole) override; - - Qt::ItemFlags flags(const QModelIndex& index) const override; - - // Add data: - bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; - - // Remove data: - bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; - - void doTestData(); - - -protected slots: - void handlePointAddition(int location) { insertRows(location,1); } -// void handlePointRemoval(int location) { removeRows(location, 1); } - void handlePointChange(int location) - { - QModelIndex ind = createIndex(location,0); - emit dataChanged(ind,ind,QVector() << Qt::DisplayRole); - } - - -private: - EntryPoints *entryPoints; -}; - - - - -#endif // ENTRYPOINTMODEL_H +#ifndef ENTRYPOINTMODEL_H +#define ENTRYPOINTMODEL_H + +#include "EntryPoints.h" + +#include +#include + + + + +class EntryPointModel : public QAbstractTableModel +{ + Q_OBJECT + +public: + explicit EntryPointModel(QObject *parent = 0, EntryPoints *points = Q_NULLPTR); + void setEntryPointsData(EntryPoints *points); + + // Header: + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; + // Basic functionality: + int rowCount(const QModelIndex &parent = QModelIndex()) const override; + int columnCount(const QModelIndex &parent = QModelIndex()) const override; + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; + + // Editable: + bool setData(const QModelIndex &index, const QVariant &value, + int role = Qt::EditRole) override; + + Qt::ItemFlags flags(const QModelIndex& index) const override; + + // Add data: + bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; + + // Remove data: + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; + + void doTestData(); + + +protected slots: + void handlePointAddition(int location) { insertRows(location,1); } +// void handlePointRemoval(int location) { removeRows(location, 1); } + void handlePointChange(int location) + { + QModelIndex ind = createIndex(location,0); + emit dataChanged(ind,ind,QVector() << Qt::DisplayRole); + } + + +private: + EntryPoints *entryPoints; +}; + + + + +#endif // ENTRYPOINTMODEL_H diff --git a/src/binaryfile/EntryPoints.cpp b/src/binaryfile/EntryPoints.cpp index 38df74f..916fcbd 100644 --- a/src/binaryfile/EntryPoints.cpp +++ b/src/binaryfile/EntryPoints.cpp @@ -1,136 +1,136 @@ -#include "EntryPoints.h" -#include - -EntryPoints::EntryPoints(QObject *parent) : QObject(parent) -{ - -} - -bool EntryPoints::hasEntryPointAtAddress(quint16 address) -{ - // Assume list m_entryPoints is sorted by address (it should be) - QListIterator it(m_entryPoints); - while (it.hasNext()) - { - EntryPoint ep = it.next(); - if (ep.address == address) return true; - if (ep.address > address) return false; - } - return false; -} - -void EntryPoints::editPoint(int location, EntryPoint newPoint) -{ - - if (m_entryPoints.at(location).address == newPoint.address) - { - m_entryPoints[location].note = newPoint.note; - emit pointChangedAt(location); - } - else - { - removePointAt(location); - addPoint(newPoint); - } -} - -void EntryPoints::addPoint(EntryPoint ep) -{ - if (hasEntryPointAtAddress(ep.address)) return; - - int idx = 0; - for (; idx < m_entryPoints.count(); idx++) - { - if (ep.address < m_entryPoints[idx].address) - break; - } - m_entryPoints.insert(idx,ep); - emit pointAddedAt(idx); - emit pointAdded(ep,idx); -} - -void EntryPoints::removePointAt(int location) -{ - m_entryPoints.removeAt(location); -} - -//--------------------------------------------------------------------------- -// STREAMING OPERATORS - -QDataStream &EntryPoints::read(QDataStream &dataStream) -{ - quint8 version; - dataStream >> version; - if (version == 0) - { - dataStream >> m_entryPoints; - } - else qWarning("Unhandled version of EntryPointModel (%d) found in QDataStream",version); - - return dataStream; -} - -QDataStream &EntryPoints::write(QDataStream &dataStream) const -{ - quint8 version = 0; // Increment this and update read() if new items are added - dataStream << version; - dataStream << m_entryPoints; - return dataStream; -} - -QList EntryPoints::getEntryPointAddresses() const -{ - QList retval; - - QListIterator it(m_entryPoints); - while (it.hasNext()) - { - retval.append(it.next().address); - } - return retval; -} - -QDataStream &operator<<(QDataStream &out, const EntryPoints &model) -{ - return model.write(out); -} - -QDataStream &operator>>(QDataStream &in, EntryPoints&model) -{ - return model.read(in); -} - -QDataStream &operator<<(QDataStream &out, const EntryPoint &model) -{ - out << model.address; - out << model.note; - return out; -} - -QDataStream &operator>>(QDataStream &in, EntryPoint &model) -{ - in >> model.address; - in >> model.note; - - return in; -} - -//--------------------------------------------------------------------------- -// TESTING - -void EntryPoints::doTestData() -{ - EntryPoint ep; - ep.address = 0x0010; - ep.note = "Test Entry Point 1"; - addPoint(ep); - ep.address = 0x0020; - ep.note = "Test Entry Point 2"; - addPoint(ep); - ep.address = 0x0030; - ep.note = "Test Entry Point 3"; - addPoint(ep); - -} - - +#include "EntryPoints.h" +#include + +EntryPoints::EntryPoints(QObject *parent) : QObject(parent) +{ + +} + +bool EntryPoints::hasEntryPointAtAddress(quint16 address) +{ + // Assume list m_entryPoints is sorted by address (it should be) + QListIterator it(m_entryPoints); + while (it.hasNext()) + { + EntryPoint ep = it.next(); + if (ep.address == address) return true; + if (ep.address > address) return false; + } + return false; +} + +void EntryPoints::editPoint(int location, EntryPoint newPoint) +{ + + if (m_entryPoints.at(location).address == newPoint.address) + { + m_entryPoints[location].note = newPoint.note; + emit pointChangedAt(location); + } + else + { + removePointAt(location); + addPoint(newPoint); + } +} + +void EntryPoints::addPoint(EntryPoint ep) +{ + if (hasEntryPointAtAddress(ep.address)) return; + + int idx = 0; + for (; idx < m_entryPoints.count(); idx++) + { + if (ep.address < m_entryPoints[idx].address) + break; + } + m_entryPoints.insert(idx,ep); + emit pointAddedAt(idx); + emit pointAdded(ep,idx); +} + +void EntryPoints::removePointAt(int location) +{ + m_entryPoints.removeAt(location); +} + +//--------------------------------------------------------------------------- +// STREAMING OPERATORS + +QDataStream &EntryPoints::read(QDataStream &dataStream) +{ + quint8 version; + dataStream >> version; + if (version == 0) + { + dataStream >> m_entryPoints; + } + else qWarning("Unhandled version of EntryPointModel (%d) found in QDataStream",version); + + return dataStream; +} + +QDataStream &EntryPoints::write(QDataStream &dataStream) const +{ + quint8 version = 0; // Increment this and update read() if new items are added + dataStream << version; + dataStream << m_entryPoints; + return dataStream; +} + +QList EntryPoints::getEntryPointAddresses() const +{ + QList retval; + + QListIterator it(m_entryPoints); + while (it.hasNext()) + { + retval.append(it.next().address); + } + return retval; +} + +QDataStream &operator<<(QDataStream &out, const EntryPoints &model) +{ + return model.write(out); +} + +QDataStream &operator>>(QDataStream &in, EntryPoints&model) +{ + return model.read(in); +} + +QDataStream &operator<<(QDataStream &out, const EntryPoint &model) +{ + out << model.address; + out << model.note; + return out; +} + +QDataStream &operator>>(QDataStream &in, EntryPoint &model) +{ + in >> model.address; + in >> model.note; + + return in; +} + +//--------------------------------------------------------------------------- +// TESTING + +void EntryPoints::doTestData() +{ + EntryPoint ep; + ep.address = 0x0010; + ep.note = "Test Entry Point 1"; + addPoint(ep); + ep.address = 0x0020; + ep.note = "Test Entry Point 2"; + addPoint(ep); + ep.address = 0x0030; + ep.note = "Test Entry Point 3"; + addPoint(ep); + +} + + diff --git a/src/binaryfile/EntryPoints.h b/src/binaryfile/EntryPoints.h index cb5e63c..1b501d9 100644 --- a/src/binaryfile/EntryPoints.h +++ b/src/binaryfile/EntryPoints.h @@ -1,52 +1,52 @@ -#ifndef ENTRYPOINTS_H -#define ENTRYPOINTS_H - -#include -#include - -struct EntryPoint { - quint16 address; - QString note; -}; - -class EntryPoints : public QObject -{ - Q_OBJECT -public: - explicit EntryPoints(QObject *parent = 0); - - bool hasEntryPointAtAddress(quint16 address); - - const EntryPoint &at(int location) const { return m_entryPoints.at(location); } - EntryPoint &pointRefAt(int location) { return m_entryPoints[location]; } - EntryPoint &operator[](int location) { return m_entryPoints[location]; } - - void editPoint(int at, EntryPoint newPoint); - - QDataStream &read(QDataStream &dataStream); - QDataStream &write(QDataStream &dataStream) const; - - int numEntryPoints() const { return m_entryPoints.count(); } - - QList getEntryPointAddresses() const; - - void doTestData(); - -signals: - void pointAdded(EntryPoint &entryPoint, int location); - void pointAddedAt(int location); - void pointRemovedAt(int location); - void pointChangedAt(int location); - -public slots: - void addPoint(EntryPoint ep); - void removePointAt(int location); - -protected: - QList m_entryPoints; -}; - -QDataStream &operator<<(QDataStream &out, const EntryPoints &model); -QDataStream &operator>>(QDataStream &in, EntryPoints &model); - -#endif // ENTRYPOINTS_H +#ifndef ENTRYPOINTS_H +#define ENTRYPOINTS_H + +#include +#include + +struct EntryPoint { + quint16 address; + QString note; +}; + +class EntryPoints : public QObject +{ + Q_OBJECT +public: + explicit EntryPoints(QObject *parent = 0); + + bool hasEntryPointAtAddress(quint16 address); + + const EntryPoint &at(int location) const { return m_entryPoints.at(location); } + EntryPoint &pointRefAt(int location) { return m_entryPoints[location]; } + EntryPoint &operator[](int location) { return m_entryPoints[location]; } + + void editPoint(int at, EntryPoint newPoint); + + QDataStream &read(QDataStream &dataStream); + QDataStream &write(QDataStream &dataStream) const; + + int numEntryPoints() const { return m_entryPoints.count(); } + + QList getEntryPointAddresses() const; + + void doTestData(); + +signals: + void pointAdded(EntryPoint &entryPoint, int location); + void pointAddedAt(int location); + void pointRemovedAt(int location); + void pointChangedAt(int location); + +public slots: + void addPoint(EntryPoint ep); + void removePointAt(int location); + +protected: + QList m_entryPoints; +}; + +QDataStream &operator<<(QDataStream &out, const EntryPoints &model); +QDataStream &operator>>(QDataStream &in, EntryPoints &model); + +#endif // ENTRYPOINTS_H diff --git a/src/binaryfile/MemoryUsageMap.h b/src/binaryfile/MemoryUsageMap.h index 27c49b1..a5fd129 100644 --- a/src/binaryfile/MemoryUsageMap.h +++ b/src/binaryfile/MemoryUsageMap.h @@ -1,107 +1,109 @@ -#ifndef MEMORYUSAGEMAP_H -#define MEMORYUSAGEMAP_H - -#include -#include -#include - -enum MemoryUsage { - Unknown = 0x00000000, - Data = 0x00000001, - Operation = 0x00000002, - // OperationArgHi = 0x00000004, - // OperationArgLo = 0x00000008, - OperationArg = 0x00000010, - - RefAddressHi = 0x00000100, - RefAddressLo = 0x00000200, - RefAddress = RefAddressLo | RefAddressHi, - ZeroPageRefAddress = 0x00000400, - - InvalidOperation = 0x00001000, - Break = 0x00002000, - UndeterminedJump = 0x00004000, - StopsExecution = InvalidOperation | Break | UndeterminedJump, - - EntryPointAddr = 0x00010000, - BranchOffsetAddr = 0x00020000, - Jump = 0x00040000, - Return = 0x00080000, -}; -Q_DECLARE_FLAGS(MemoryUsages,MemoryUsage) - - -class MemoryUsageMap : public QVector -{ - -public: - MemoryUsageMap() - { - fill(MemoryUsage::Unknown,65536); - } - - void clearData() - { - for (int idx = 0; idx < size(); idx++) - { - (*this)[idx] = MemoryUsage::Unknown; - } - } - - void merge(const MemoryUsageMap &other) - { - if (other.size() != size()) - { - qWarning("Mismatched size of MemoryMaps!"); - return; - } - for (int idx = 0; idx < size(); idx++) - { - (*this)[idx] |= other[idx]; - } - } - - QList addressesWhichContain(MemoryUsage usage) - { - QList retval; - for (int idx = 0; idx < size(); idx++) - { - if (value(idx).testFlag(usage)) - { - retval.append((quint16) idx); - } - } - return retval; - } - -private: - void clear(); - void append(const MemoryUsages &); - void append(MemoryUsages &&); - void append(const QVector); - void insert(int,const MemoryUsages &); - void insert(int,int,const MemoryUsages &); - void move(int,int); - void prepend(const MemoryUsages&); - void push_back(const MemoryUsages&); - void push_back(MemoryUsages&&); - void push_front(const MemoryUsages&); - void remove(int); - void remove(int,int); - void removeAll(const MemoryUsages&); - void removeAt(int); - void removeFirst(); - void removeLast(); - bool removeOne(const MemoryUsages&); - void reserve(int); - void resize(int); - void swap(QVector&); - MemoryUsages &takeAt(int); - MemoryUsages &takeFirst(); - MemoryUsages &takeLast(); - -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(MemoryUsages) - -#endif // MEMORYUSAGEMAP_H +#ifndef MEMORYUSAGEMAP_H +#define MEMORYUSAGEMAP_H + +#include +#include +#include +#include + + +enum MemoryUsage { + Unknown = 0x00000000, + Data = 0x00000001, + Operation = 0x00000002, + // OperationArgHi = 0x00000004, + // OperationArgLo = 0x00000008, + OperationArg = 0x00000010, + + RefAddressHi = 0x00000100, + RefAddressLo = 0x00000200, + RefAddress = RefAddressLo | RefAddressHi, + ZeroPageRefAddress = 0x00000400, + + InvalidOperation = 0x00001000, + Break = 0x00002000, + UndeterminedJump = 0x00004000, + StopsExecution = InvalidOperation | Break | UndeterminedJump, + + EntryPointAddr = 0x00010000, + BranchOffsetAddr = 0x00020000, + Jump = 0x00040000, + Return = 0x00080000, +}; +Q_DECLARE_FLAGS(MemoryUsages,MemoryUsage) + + +class MemoryUsageMap : public QVector +{ + +public: + MemoryUsageMap() + { + fill(MemoryUsage::Unknown,65536); + } + + void clearData() + { + for (int idx = 0; idx < size(); idx++) + { + (*this)[idx] = MemoryUsage::Unknown; + } + } + + void merge(const MemoryUsageMap &other) + { + if (other.size() != size()) + { + qWarning("Mismatched size of MemoryMaps!"); + return; + } + for (int idx = 0; idx < size(); idx++) + { + (*this)[idx] |= other[idx]; + } + } + + QList addressesWhichContain(MemoryUsage usage) + { + QList retval; + for (int idx = 0; idx < size(); idx++) + { + if (value(idx).testFlag(usage)) + { + retval.append((quint16) idx); + } + } + return retval; + } + +private: + void clear(); + void append(const MemoryUsages &); + void append(MemoryUsages &&); + void append(const QVector); + void insert(int,const MemoryUsages &); + void insert(int,int,const MemoryUsages &); + void move(int,int); + void prepend(const MemoryUsages&); + void push_back(const MemoryUsages&); + void push_back(MemoryUsages&&); + void push_front(const MemoryUsages&); + void remove(int); + void remove(int,int); + void removeAll(const MemoryUsages&); + void removeAt(int); + void removeFirst(); + void removeLast(); + bool removeOne(const MemoryUsages&); + void reserve(int); + void resize(int); + void swap(QVector&); + MemoryUsages &takeAt(int); + MemoryUsages &takeFirst(); + MemoryUsages &takeLast(); + +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(MemoryUsages) + +#endif // MEMORYUSAGEMAP_H diff --git a/src/binaryfile/binaryfile.cxx b/src/binaryfile/binaryfile.cxx index a9fb6ba..247e98a 100644 --- a/src/binaryfile/binaryfile.cxx +++ b/src/binaryfile/binaryfile.cxx @@ -1,31 +1,31 @@ -#include -#include "binaryfile.h" -#include "util.h" - -BinaryFile::BinaryFile(QByteArray data) : GenericFile(data) -{ - m_length = 0; - - if (!data.isEmpty()) { - setData(data); - } -} - -void BinaryFile::setData(QByteArray data) -{ - if (data.length() >= 4) { - QByteArray metadata = data.left(4); - m_data = data.mid(4); - setAddress(makeWord(metadata[0],metadata[1])); - m_length = makeWord(metadata[2],metadata[3]); - } -} - -void BinaryFile::dump() -{ - qDebug() << QString("Address: %1 Length: %2") - .arg((quint16) address(),4,16,QChar('0')) - .arg(m_length,4,16,QChar('0')).toUpper(); - qDebug() << QString("Data Length Recorded: %1") - .arg(m_data.length(),4,16,QChar('0')).toUpper(); -} +#include +#include "binaryfile.h" +#include "util.h" + +BinaryFile::BinaryFile(QByteArray data) : GenericFile(data) +{ + m_length = 0; + + if (!data.isEmpty()) { + setData(data); + } +} + +void BinaryFile::setData(QByteArray data) +{ + if (data.length() >= 4) { + QByteArray metadata = data.left(4); + m_data = data.mid(4); + setAddress(makeWord(metadata[0],metadata[1])); + m_length = makeWord(metadata[2],metadata[3]); + } +} + +void BinaryFile::dump() +{ + qDebug() << QString("Address: %1 Length: %2") + .arg((quint16) address(),4,16,QChar('0')) + .arg(m_length,4,16,QChar('0')).toUpper(); + qDebug() << QString("Data Length Recorded: %1") + .arg(m_data.length(),4,16,QChar('0')).toUpper(); +} diff --git a/src/binaryfile/binaryfile.h b/src/binaryfile/binaryfile.h index 17c8d7a..f03bc4d 100644 --- a/src/binaryfile/binaryfile.h +++ b/src/binaryfile/binaryfile.h @@ -1,19 +1,19 @@ -#ifndef BINARYFILE_H -#define BINARYFILE_H - -#include "genericfile.h" - -class BinaryFile : public GenericFile -{ -public: - BinaryFile(QByteArray data = QByteArray()); - void setData(QByteArray data); - - virtual quint16 length() { return m_length; } - - void dump(); - -protected: -}; - -#endif // BINARYFILE_H +#ifndef BINARYFILE_H +#define BINARYFILE_H + +#include "genericfile.h" + +class BinaryFile : public GenericFile +{ +public: + BinaryFile(QByteArray data = QByteArray()); + void setData(QByteArray data); + + virtual quint16 length() { return m_length; } + + void dump(); + +protected: +}; + +#endif // BINARYFILE_H diff --git a/src/binaryfile/binaryfilemetadata.cpp b/src/binaryfile/binaryfilemetadata.cpp index 42d029e..9df1022 100644 --- a/src/binaryfile/binaryfilemetadata.cpp +++ b/src/binaryfile/binaryfilemetadata.cpp @@ -1,68 +1,68 @@ -#include "binaryfilemetadata.h" -#include "genericfile.h" -#include -#include -#include -BinaryFileMetadata::BinaryFileMetadata(GenericFile *file, quint16 defaultAddress, QObject *parent) - : QObject(parent) -{ - m_file = file; - m_defaultAddress = defaultAddress; - - m_eps = new EntryPoints(this); - m_as = new AssemblerSymbols(this); - - load(); -} - -void BinaryFileMetadata::load() -{ - QFile infile(QString("%1%2%3") - .arg(m_file->diskFile()->getMetaDataPath()) - .arg(m_file->filename()) - .arg(".bfm")); - if (infile.open(QIODevice::ReadOnly)) - { - qDebug() << "Loading binary file metadata from" << QString("%1%2%3") - .arg(m_file->diskFile()->getMetaDataPath()) - .arg(m_file->filename()) - .arg(".bfm"); - QDataStream ds(&infile); - ds >> *m_eps; - ds >> *m_as; - infile.close(); - } - else qDebug() << "Cannot open " << QString("%1%2%3") - .arg(m_file->diskFile()->getMetaDataPath()) - .arg(m_file->filename()) - .arg(".bfm") << "for reading"; - -} - -void BinaryFileMetadata::save() -{ - QFile outfile(QString("%1%2%3") - .arg(m_file->diskFile()->getMetaDataPath()) - .arg(m_file->filename()) - .arg(".bfm")); - if (outfile.open(QIODevice::WriteOnly)) - { - qDebug() << "Saving binary file metadata to" << QString("%1%2%3") - .arg(m_file->diskFile()->getMetaDataPath()) - .arg(m_file->filename()) - .arg(".bfm"); - QDataStream ds(&outfile); - ds << *m_eps; - ds << *m_as; - outfile.close(); - } - else qDebug() << "Cannot open " << QString("%1%2%3") - .arg(m_file->diskFile()->getMetaDataPath()) - .arg(m_file->filename()) - .arg(".bfm") << "for writing"; - -} - - - - +#include "binaryfilemetadata.h" +#include "genericfile.h" +#include +#include +#include +BinaryFileMetadata::BinaryFileMetadata(GenericFile *file, quint16 defaultAddress, QObject *parent) + : QObject(parent) +{ + m_file = file; + m_defaultAddress = defaultAddress; + + m_eps = new EntryPoints(this); + m_as = new AssemblerSymbols(this); + + load(); +} + +void BinaryFileMetadata::load() +{ + QFile infile(QString("%1%2%3") + .arg(m_file->diskFile()->getMetaDataPath()) + .arg(m_file->filename()) + .arg(".bfm")); + if (infile.open(QIODevice::ReadOnly)) + { + qDebug() << "Loading binary file metadata from" << QString("%1%2%3") + .arg(m_file->diskFile()->getMetaDataPath()) + .arg(m_file->filename()) + .arg(".bfm"); + QDataStream ds(&infile); + ds >> *m_eps; + ds >> *m_as; + infile.close(); + } + else qDebug() << "Cannot open " << QString("%1%2%3") + .arg(m_file->diskFile()->getMetaDataPath()) + .arg(m_file->filename()) + .arg(".bfm") << "for reading"; + +} + +void BinaryFileMetadata::save() +{ + QFile outfile(QString("%1%2%3") + .arg(m_file->diskFile()->getMetaDataPath()) + .arg(m_file->filename()) + .arg(".bfm")); + if (outfile.open(QIODevice::WriteOnly)) + { + qDebug() << "Saving binary file metadata to" << QString("%1%2%3") + .arg(m_file->diskFile()->getMetaDataPath()) + .arg(m_file->filename()) + .arg(".bfm"); + QDataStream ds(&outfile); + ds << *m_eps; + ds << *m_as; + outfile.close(); + } + else qDebug() << "Cannot open " << QString("%1%2%3") + .arg(m_file->diskFile()->getMetaDataPath()) + .arg(m_file->filename()) + .arg(".bfm") << "for writing"; + +} + + + + diff --git a/src/binaryfile/binaryfilemetadata.h b/src/binaryfile/binaryfilemetadata.h index f12af84..b383978 100644 --- a/src/binaryfile/binaryfilemetadata.h +++ b/src/binaryfile/binaryfilemetadata.h @@ -1,47 +1,47 @@ -#ifndef BINARYFILEMETADATA_H -#define BINARYFILEMETADATA_H - -#include "EntryPoints.h" -#include "AssemblerSymbols.h" -#include "genericfile.h" -#include "binaryfile.h" - -#include -#include -#include -#include - - - - -class BinaryFileMetadata : public QObject -{ - Q_OBJECT -public: - BinaryFileMetadata(GenericFile *file, quint16 defaultAddress, QObject *parent = 0); - - QString filename() const { return m_file->filename(); } - - EntryPoints *entryPoints() { return m_eps; } - AssemblerSymbols *assemblerSymbols() { return m_as; } - -signals: - void doDisassemble(QList); - -public slots: - void load(); - void save(); - - void requestDisassembly() { emit doDisassemble(m_eps->getEntryPointAddresses()); } - -private: - - EntryPoints *m_eps; - AssemblerSymbols *m_as; - - GenericFile *m_file; - - quint16 m_defaultAddress; -}; - -#endif // BINARYFILEMETADATA_H +#ifndef BINARYFILEMETADATA_H +#define BINARYFILEMETADATA_H + +#include "EntryPoints.h" +#include "AssemblerSymbols.h" +#include "genericfile.h" +#include "binaryfile.h" + +#include +#include +#include +#include + + + + +class BinaryFileMetadata : public QObject +{ + Q_OBJECT +public: + BinaryFileMetadata(GenericFile *file, quint16 defaultAddress, QObject *parent = 0); + + QString filename() const { return m_file->filename(); } + + EntryPoints *entryPoints() { return m_eps; } + AssemblerSymbols *assemblerSymbols() { return m_as; } + +signals: + void doDisassemble(QList); + +public slots: + void load(); + void save(); + + void requestDisassembly() { emit doDisassemble(m_eps->getEntryPointAddresses()); } + +private: + + EntryPoints *m_eps; + AssemblerSymbols *m_as; + + GenericFile *m_file; + + quint16 m_defaultAddress; +}; + +#endif // BINARYFILEMETADATA_H diff --git a/src/binaryfile/disassembler.cxx b/src/binaryfile/disassembler.cxx index 9b9664a..aa09e5b 100644 --- a/src/binaryfile/disassembler.cxx +++ b/src/binaryfile/disassembler.cxx @@ -1,981 +1,981 @@ -#include "disassembler.h" -#include -#include -#include - - -Disassembler::Disassembler(QByteArray memimage) -{ - m_memimage = memimage, makeOpcodeTable(); - m_memusagemap.clearData(); - -} - - -QList Disassembler::disassemble(quint16 from, quint16 to, - QList entryPoints, - bool processRecursively) { - m_from = from; - m_to = to; - QList retval; - qDebug() << "\n\n*****************\n\nDisassemble: From"< 0xffff || (idx < from)) { - qDebug() << "Breaking."; - break; - } - } -#else - MemoryUsageMap memuse; - - bool stopping = false; - quint16 next = from; - while (entryPoints.count()) - { - next = entryPoints.takeFirst(); - //m_jumps.append(entryPoints); - m_stack.push(next); - } - - while (!stopping) - { - // quint8 opcode = m_memimage[next]; - // qDebug() << "Opcode: " << uint8ToHex(opcode); - DisassembledItem item; - bool ok = false; - - if (next >= from && next <= to) //TODO: Remove this to not limit disassembly to program range - ok = disassembleOp(next,item,&memuse); - - if (ok) - { - retval.append(item); - - quint16 flow = item.nextFlowAddress(); - qDebug() << uint16ToHex(next) << uint16ToHex(flow); - if (item.isBranch()) - { - qDebug() << "Is Branch"; - m_stack.push(item.targetAddress()); - // if (!m_jumps.contains(item.targetAddress())) - // { - // m_jumps.append(item.targetAddress()); - // qDebug() << "Appending branch" << uint16ToHex(item.targetAddress()) << "to jump table"; - - // } - } - - if (item.isJsr() && !item.canNotFollow()) - { - if (item.targetAddress() <= to) //TODO: Remove this to not limit disassembly to program range - { - if (m_stack.push(item.targetAddress())) - //if (!m_jumps.contains(item.targetAddress())) - { - qDebug() << "Appending" << uint16ToHex(item.targetAddress()) << "to jump table"; - - //m_jumps.append(item.targetAddress()); - } - else - { - qDebug() << "Not adding" << uint16ToHex(item.targetAddress()) << "to jump table"; - } - } - } - - if (next <= to) //TODO: Remove this to not limit disassembly to program range - { - next = flow; - stopping = item.stopsProcessing(); - } - else stopping = true; - } - else - { - stopping = true; // already processed this address - } - - // if (found.contains(next)) stopping = true; - if (next >= to) stopping = true; - // if (stopping) { - // qDebug() << "Stopping. Stops processing: " - // << item.stopsProcessing() - // << ", next>=to: " << (next >= to) - // << ", alreadyFound: " << ((!ok)?"true":"false"); - // } - } - - m_memusagemap.merge(memuse); - - if (processRecursively) - //while (m_jumps.size()) - while (!m_stack.isEmpty()) - { - // quint16 num = m_jumps.takeFirst(); - quint16 num = m_stack.pop(); - if (!m_memusagemap[num].testFlag(Operation)) - { - if (num >= from && num <= to) // TODO: remove this to not limit disassembly to program range - { - qDebug() << "Calling recursively to"<() << num,false)); - qDebug() << "Return from recursive call."; - } - } - } - -#endif - qSort(retval); - - // QStringList hexdump; - // foreach (quint16 adr,m_memusagemap.addressesWhichContain(Operation)) - // { - // hexdump.append(uint16ToHex(adr)); - // } - // qDebug() << "Operations:" << hexdump; - - // hexdump.clear(); - // foreach (quint16 adr,m_memusagemap.addressesWhichContain(OperationArg)) - // { - // hexdump.append(uint16ToHex(adr)); - // } - // qDebug() << "Operations Args:" << hexdump; - - if (processRecursively) - { - // m_jlm.dumpJumps(); - m_jumplines = m_jlm.buildJumpLines(); - qDebug() << "Num Channels: " << m_jlm.getNumJumpLineChannels(); - } - - return retval; -} - -bool Disassembler::disassembleOp(quint16 address, DisassembledItem &retval, MemoryUsageMap *memuse) -{ - - if (memuse) - { - if ((*memuse)[address].testFlag(Operation)) return false; - } - - quint8 opcode = m_memimage[address]; - AssyInstruction op = m_opcodeinfo[opcode]; - retval.setInstruction(op); - - if (opcode == 0x6C || opcode == 0x7c) // Indirect jumps - { - m_jlm.addJump(address,address,IsUnknownJump,m_from,m_to); - retval.setCanNotFollow(true); - } - - QString disassemblyLine; - QString hexValueString; - QByteArray hexValues; - hexValues.append(opcode); - - // Prepare Op Code arguments - - for (int idx = 1; idx < op.numArgs()+1; idx++) { - quint8 val = m_memimage[address+idx]; - hexValues.append(val); - } - if (memuse) - { - (*memuse)[address].setFlag(Operation); - for (int idx = 1; idx < op.numArgs()+1; idx++) - { - (*memuse)[address+idx].setFlag(OperationArg); - } - } - - quint16 argval = 0; - if (op.numArgs() == 1) - argval = (quint8) hexValues[1]; - else if (op.numArgs() == 2) - { - argval = makeWord(hexValues[1],hexValues[2]); - } - - - - for (int idx = 0; idx < hexValues.length(); idx++) { - hexValueString.append(QString("%1 ").arg((quint8) hexValues[idx],2,16,QChar('0'))); - } - - retval.setNextContiguousAddress(address+1+op.numArgs()); - retval.setNextFlowAddress(address+1+op.numArgs()); - - // Disassemble instruction - switch (op.addressMode()) { - case AM_InvalidOp: { - disassemblyLine = op.mnemonic(); - retval.setIsInvalidOp(true); - break; - } - case AM_Absolute:{ - disassemblyLine = QString("%1 _ARG16_").arg(op.mnemonic()); - retval.setRawArgument(argval); - break; - } - case AM_AbsoluteIndexedIndirect:{ - disassemblyLine = QString("%1 (_ARG16_,x)").arg(op.mnemonic()); - retval.setRawArgument(argval); - break; - } - case AM_AbsoluteIndexedWithX:{ - disassemblyLine = QString("%1 _ARG16_,x").arg(op.mnemonic()); - retval.setRawArgument(argval); - break; - } - case AM_AbsoluteIndexedWithY:{ - disassemblyLine = QString("%1 _ARG16_,y").arg(op.mnemonic()); - retval.setRawArgument(argval); - break; - } - case AM_AbsoluteIndirect:{ - disassemblyLine = QString("%1 (_ARG16_)").arg(op.mnemonic()); - retval.setRawArgument(argval); - break; - } - case AM_Immediate:{ - disassemblyLine = QString("%1 #%2").arg(op.mnemonic()).arg((quint8) hexValues[1],2,16,QChar('0')).toUpper(); - retval.setRawArgument(argval); - break; - } - case AM_Implied:{ - disassemblyLine = op.mnemonic(); - break; - } - case AM_Accumulator:{ - disassemblyLine = op.mnemonic(); - break; - } - case AM_ProgramCounterRelative:{ - qint8 offset = (qint8) hexValues[1]; - quint16 offsetAddress = address+2+offset; - - retval.setTargetAddress(offsetAddress); - if (opcode == 0x80) // BRA - m_jlm.addJump(address,offsetAddress,IsBRA,m_from,m_to); - else - m_jlm.addJump(address,offsetAddress,IsBranch,m_from,m_to); - - disassemblyLine = QString("%1 _ARG16_ {%2%3}").arg(op.mnemonic()) - .arg((offset<0)?"-":"+") - .arg(abs(offset)); - retval.setRawArgument(offsetAddress); - break; - } - case AM_ZeroPage:{ - disassemblyLine = QString("%1 _ARG8_").arg(op.mnemonic()); - retval.setRawArgument(argval); - break; - } - case AM_ZeroPageIndirectIndexedWithY:{ - disassemblyLine = QString("%1 (_ARG8_),Y").arg(op.mnemonic()); - retval.setRawArgument(argval); - break; - } - case AM_ZeroPageIndexedIndirect:{ - disassemblyLine = QString("%1 (_ARG8_,x)").arg(op.mnemonic()); - retval.setRawArgument(argval); - break; - } - case AM_ZeroPageIndexedWithX:{ - disassemblyLine = QString("%1 _ARG8_,x").arg(op.mnemonic()); - retval.setRawArgument(argval); - break; - } - case AM_ZeroPageIndexedWithY:{ - disassemblyLine = QString("%1 _ARG8_,y").arg(op.mnemonic()); - retval.setRawArgument(argval); - break; - } - case AM_ZeroPageIndirect:{ - disassemblyLine = QString("%1 (_ARG8_)").arg(op.mnemonic()); - retval.setRawArgument(argval); - break; - } - default:{ - disassemblyLine = op.mnemonic(); - retval.setIsInvalidOp(true); - qDebug() << "Unhandled Address Mode: " << op.addressMode(); - break; - } - } - - if (opcode == 0x20 || opcode == 0x4c) { - retval.setTargetAddress(makeWord(hexValues[1],hexValues[2])); - - if (opcode == 0x4c) // JMP - { - qDebug() << "JMP: Adding flow address " - << uint16ToHex(makeWord(hexValues[1],hexValues[2])) << "to jump table"; - m_jlm.addJump(address,argval,IsJMP,m_from,m_to); - m_stack.push(argval); - retval.setCanNotFollow(true); - } - else // JSR - { - m_jlm.addJump(address,argval,IsJSR,m_from,m_to); - } - } - - retval.setAddress(address); - retval.setDisassembledString(disassemblyLine.toUpper()); - retval.setHexString(hexValueString.trimmed().toUpper().leftJustified(12,' ')); - retval.setHexValues(hexValues); - - return true; -} - -void Disassembler::makeOpcodeTable() -{ - m_opcodeinfo[0x00] = AssyInstruction(0x00, "BRK", AM_Implied); - m_opcodeinfo[0x10] = AssyInstruction(0x10, "BPL", AM_ProgramCounterRelative); - m_opcodeinfo[0x20] = AssyInstruction(0x20, "JSR", AM_Absolute); - m_opcodeinfo[0x30] = AssyInstruction(0x30, "BMI", AM_ProgramCounterRelative); - m_opcodeinfo[0x40] = AssyInstruction(0x40, "RTI", AM_Implied); - m_opcodeinfo[0x50] = AssyInstruction(0x50, "BVC", AM_ProgramCounterRelative); - m_opcodeinfo[0x60] = AssyInstruction(0x60, "RTS", AM_Implied); - m_opcodeinfo[0x70] = AssyInstruction(0x70, "BVS", AM_ProgramCounterRelative); - m_opcodeinfo[0x80] = AssyInstruction(0x80, "BRA", AM_ProgramCounterRelative); //65C02 - m_opcodeinfo[0x90] = AssyInstruction(0x90, "BCC", AM_ProgramCounterRelative); - m_opcodeinfo[0xa0] = AssyInstruction(0xa0, "LDY", AM_Immediate); - m_opcodeinfo[0xb0] = AssyInstruction(0xb0, "BCS", AM_ProgramCounterRelative); - m_opcodeinfo[0xc0] = AssyInstruction(0xc0, "CPY", AM_Immediate); - m_opcodeinfo[0xd0] = AssyInstruction(0xd0, "BNE", AM_ProgramCounterRelative); - m_opcodeinfo[0xe0] = AssyInstruction(0xe0, "CPX", AM_Immediate); - m_opcodeinfo[0xf0] = AssyInstruction(0xf0, "BEQ", AM_ProgramCounterRelative); - - m_opcodeinfo[0x01] = AssyInstruction(0x01, "ORA", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0x11] = AssyInstruction(0x11, "ORA", AM_ZeroPageIndirectIndexedWithY); - m_opcodeinfo[0x21] = AssyInstruction(0x21, "AND", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0x31] = AssyInstruction(0x31, "AND", AM_ZeroPageIndirectIndexedWithY); - m_opcodeinfo[0x41] = AssyInstruction(0x41, "EOR", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0x51] = AssyInstruction(0x51, "EOR", AM_ZeroPageIndirectIndexedWithY); - m_opcodeinfo[0x61] = AssyInstruction(0x61, "ADC", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0x71] = AssyInstruction(0x71, "ADC", AM_ZeroPageIndirectIndexedWithY); - m_opcodeinfo[0x81] = AssyInstruction(0x81, "STA", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0x91] = AssyInstruction(0x91, "STA", AM_ZeroPageIndirectIndexedWithY); - m_opcodeinfo[0xa1] = AssyInstruction(0xa1, "LDA", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0xb1] = AssyInstruction(0xb1, "LDA", AM_ZeroPageIndirectIndexedWithY); - m_opcodeinfo[0xc1] = AssyInstruction(0xc1, "CMP", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0xd1] = AssyInstruction(0xd1, "CMP", AM_ZeroPageIndirectIndexedWithY); - m_opcodeinfo[0xe1] = AssyInstruction(0xe1, "SBC", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0xf1] = AssyInstruction(0xff, "SBC", AM_ZeroPageIndirectIndexedWithY); - - m_opcodeinfo[0x02] = AssyInstruction(0x02, "???", AM_InvalidOp); - m_opcodeinfo[0x12] = AssyInstruction(0x12, "ORA", AM_ZeroPageIndirect); - m_opcodeinfo[0x22] = AssyInstruction(0x22, "???", AM_InvalidOp); - m_opcodeinfo[0x32] = AssyInstruction(0x32, "AND", AM_ZeroPageIndirect); - m_opcodeinfo[0x42] = AssyInstruction(0x42, "???", AM_InvalidOp); - m_opcodeinfo[0x52] = AssyInstruction(0x52, "EOR", AM_ZeroPageIndirect); - m_opcodeinfo[0x62] = AssyInstruction(0x62, "???", AM_InvalidOp); - m_opcodeinfo[0x72] = AssyInstruction(0x72, "ADC", AM_ZeroPageIndirect); - m_opcodeinfo[0x82] = AssyInstruction(0x82, "???", AM_InvalidOp); - m_opcodeinfo[0x92] = AssyInstruction(0x92, "STA", AM_ZeroPageIndirect); //65C02 - m_opcodeinfo[0xa2] = AssyInstruction(0xa2, "LDX", AM_Immediate); - m_opcodeinfo[0xb2] = AssyInstruction(0xb2, "LDA", AM_ZeroPageIndirect); //65C02 - m_opcodeinfo[0xc2] = AssyInstruction(0xc2, "???", AM_InvalidOp); - m_opcodeinfo[0xd2] = AssyInstruction(0xd2, "CMP", AM_ZeroPageIndirect); - m_opcodeinfo[0xe2] = AssyInstruction(0xe2, "???", AM_InvalidOp); - m_opcodeinfo[0xf2] = AssyInstruction(0xf2, "SBC", AM_ZeroPageIndirect); - - m_opcodeinfo[0x03] = AssyInstruction(0x03, "???", AM_InvalidOp); - m_opcodeinfo[0x13] = AssyInstruction(0x13, "???", AM_InvalidOp); - m_opcodeinfo[0x23] = AssyInstruction(0x23, "???", AM_InvalidOp); - m_opcodeinfo[0x33] = AssyInstruction(0x33, "???", AM_InvalidOp); - m_opcodeinfo[0x43] = AssyInstruction(0x43, "???", AM_InvalidOp); - m_opcodeinfo[0x53] = AssyInstruction(0x53, "???", AM_InvalidOp); - m_opcodeinfo[0x63] = AssyInstruction(0x63, "???", AM_InvalidOp); - m_opcodeinfo[0x73] = AssyInstruction(0x73, "???", AM_InvalidOp); - m_opcodeinfo[0x83] = AssyInstruction(0x83, "???", AM_InvalidOp); - m_opcodeinfo[0x93] = AssyInstruction(0x93, "???", AM_InvalidOp); - m_opcodeinfo[0xa3] = AssyInstruction(0xa3, "???", AM_InvalidOp); - m_opcodeinfo[0xb3] = AssyInstruction(0xb3, "???", AM_InvalidOp); - m_opcodeinfo[0xc3] = AssyInstruction(0xc3, "???", AM_InvalidOp); - m_opcodeinfo[0xd3] = AssyInstruction(0xd3, "???", AM_InvalidOp); - m_opcodeinfo[0xe3] = AssyInstruction(0xe3, "???", AM_InvalidOp); - m_opcodeinfo[0xf3] = AssyInstruction(0xf3, "???", AM_InvalidOp); - - m_opcodeinfo[0x04] = AssyInstruction(0x04, "TSB", AM_ZeroPage); //65C02 - m_opcodeinfo[0x14] = AssyInstruction(0x14, "TRB", AM_ZeroPage); //65C02 - m_opcodeinfo[0x24] = AssyInstruction(0x24, "BIT", AM_ZeroPage); - m_opcodeinfo[0x34] = AssyInstruction(0x34, "BIT", AM_ZeroPageIndexedWithX); //65C02 - m_opcodeinfo[0x44] = AssyInstruction(0x44, "???", AM_InvalidOp); - m_opcodeinfo[0x54] = AssyInstruction(0x54, "???", AM_InvalidOp); - m_opcodeinfo[0x64] = AssyInstruction(0x64, "STZ", AM_ZeroPage); //65C02 - m_opcodeinfo[0x74] = AssyInstruction(0x74, "STZ", AM_ZeroPageIndexedWithX); //65C02 - m_opcodeinfo[0x84] = AssyInstruction(0x84, "STY", AM_ZeroPage); - m_opcodeinfo[0x94] = AssyInstruction(0x94, "STY", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0xa4] = AssyInstruction(0xa4, "LDY", AM_ZeroPage); - m_opcodeinfo[0xb4] = AssyInstruction(0xb4, "LDY", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0xc4] = AssyInstruction(0xc4, "CPY", AM_ZeroPage); - m_opcodeinfo[0xd4] = AssyInstruction(0xd4, "???", AM_InvalidOp); - m_opcodeinfo[0xe4] = AssyInstruction(0xe4, "CPX", AM_ZeroPage); - m_opcodeinfo[0xf4] = AssyInstruction(0xf4, "???", AM_InvalidOp); - - m_opcodeinfo[0x05] = AssyInstruction(0x05, "ORA", AM_ZeroPage); - m_opcodeinfo[0x15] = AssyInstruction(0x15, "ORA", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x25] = AssyInstruction(0x25, "AND", AM_ZeroPage); - m_opcodeinfo[0x35] = AssyInstruction(0x35, "AND", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x45] = AssyInstruction(0x45, "EOR", AM_ZeroPage); - m_opcodeinfo[0x55] = AssyInstruction(0x55, "EOR", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x65] = AssyInstruction(0x65, "ADC", AM_ZeroPage); - m_opcodeinfo[0x75] = AssyInstruction(0x75, "ADC", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x85] = AssyInstruction(0x85, "STA", AM_ZeroPage); - m_opcodeinfo[0x95] = AssyInstruction(0x95, "STA", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0xa5] = AssyInstruction(0xa5, "LDA", AM_ZeroPage); - m_opcodeinfo[0xb5] = AssyInstruction(0xb5, "LDA", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0xc5] = AssyInstruction(0xc5, "CMP", AM_ZeroPage); - m_opcodeinfo[0xd5] = AssyInstruction(0xd5, "CMP", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0xe5] = AssyInstruction(0xe5, "SEC", AM_ZeroPage); - m_opcodeinfo[0xf5] = AssyInstruction(0xf5, "SEC", AM_ZeroPageIndexedWithX); - - m_opcodeinfo[0x06] = AssyInstruction(0x06, "ASL", AM_ZeroPage); - m_opcodeinfo[0x16] = AssyInstruction(0x16, "ASL", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x26] = AssyInstruction(0x26, "ROL", AM_ZeroPage); - m_opcodeinfo[0x36] = AssyInstruction(0x36, "ROL", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x46] = AssyInstruction(0x46, "LSR", AM_ZeroPage); - m_opcodeinfo[0x56] = AssyInstruction(0x56, "LSR", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x66] = AssyInstruction(0x66, "ROR", AM_ZeroPage); - m_opcodeinfo[0x76] = AssyInstruction(0x76, "ROR", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x86] = AssyInstruction(0x86, "STX", AM_ZeroPage); - m_opcodeinfo[0x96] = AssyInstruction(0x96, "STX", AM_ZeroPageIndexedWithY); - m_opcodeinfo[0xa6] = AssyInstruction(0xa6, "LDX", AM_ZeroPage); - m_opcodeinfo[0xb6] = AssyInstruction(0xb6, "LDX", AM_ZeroPageIndexedWithY); - m_opcodeinfo[0xc6] = AssyInstruction(0xc6, "DEC", AM_ZeroPage); - m_opcodeinfo[0xd6] = AssyInstruction(0xd6, "DEC", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0xe6] = AssyInstruction(0xe6, "INC", AM_ZeroPage); - m_opcodeinfo[0xf6] = AssyInstruction(0xf6, "INC", AM_ZeroPageIndexedWithX); - - m_opcodeinfo[0x07] = AssyInstruction(0x07, "???", AM_InvalidOp); - m_opcodeinfo[0x17] = AssyInstruction(0x17, "???", AM_InvalidOp); - m_opcodeinfo[0x27] = AssyInstruction(0x27, "???", AM_InvalidOp); - m_opcodeinfo[0x37] = AssyInstruction(0x37, "???", AM_InvalidOp); - m_opcodeinfo[0x47] = AssyInstruction(0x47, "???", AM_InvalidOp); - m_opcodeinfo[0x57] = AssyInstruction(0x57, "???", AM_InvalidOp); - m_opcodeinfo[0x67] = AssyInstruction(0x67, "???", AM_InvalidOp); - m_opcodeinfo[0x77] = AssyInstruction(0x77, "???", AM_InvalidOp); - m_opcodeinfo[0x87] = AssyInstruction(0x87, "???", AM_InvalidOp); - m_opcodeinfo[0x97] = AssyInstruction(0x97, "???", AM_InvalidOp); - m_opcodeinfo[0xa7] = AssyInstruction(0xa7, "???", AM_InvalidOp); - m_opcodeinfo[0xb7] = AssyInstruction(0xb7, "???", AM_InvalidOp); - m_opcodeinfo[0xc7] = AssyInstruction(0xc7, "???", AM_InvalidOp); - m_opcodeinfo[0xd7] = AssyInstruction(0xd7, "???", AM_InvalidOp); - m_opcodeinfo[0xe7] = AssyInstruction(0xe7, "???", AM_InvalidOp); - m_opcodeinfo[0xf7] = AssyInstruction(0xf7, "???", AM_InvalidOp); - - m_opcodeinfo[0x08] = AssyInstruction(0x08, "PHP", AM_Implied); - m_opcodeinfo[0x18] = AssyInstruction(0x18, "CLC", AM_Implied); - m_opcodeinfo[0x28] = AssyInstruction(0x28, "PLP", AM_Implied); - m_opcodeinfo[0x38] = AssyInstruction(0x38, "SEC", AM_Implied); - m_opcodeinfo[0x48] = AssyInstruction(0x48, "PHA", AM_Implied); - m_opcodeinfo[0x58] = AssyInstruction(0x58, "CLI", AM_Implied); - m_opcodeinfo[0x68] = AssyInstruction(0x68, "PLA", AM_Implied); - m_opcodeinfo[0x78] = AssyInstruction(0x78, "SEI", AM_Implied); - m_opcodeinfo[0x88] = AssyInstruction(0x88, "DEY", AM_Implied); - m_opcodeinfo[0x98] = AssyInstruction(0x98, "TYA", AM_Implied); - m_opcodeinfo[0xa8] = AssyInstruction(0xa8, "TAY", AM_Implied); - m_opcodeinfo[0xb8] = AssyInstruction(0xb8, "CLV", AM_Implied); - m_opcodeinfo[0xc8] = AssyInstruction(0xc8, "INY", AM_Implied); - m_opcodeinfo[0xd8] = AssyInstruction(0xd8, "CLD", AM_Implied); - m_opcodeinfo[0xe8] = AssyInstruction(0xe8, "INX", AM_Implied); - m_opcodeinfo[0xf8] = AssyInstruction(0xf8, "SED", AM_Implied); - - m_opcodeinfo[0x09] = AssyInstruction(0x09, "ORA", AM_Immediate); - m_opcodeinfo[0x19] = AssyInstruction(0x19, "ORA", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x29] = AssyInstruction(0x29, "AND", AM_Immediate); - m_opcodeinfo[0x39] = AssyInstruction(0x39, "AND", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x49] = AssyInstruction(0x49, "EOR", AM_Immediate); - m_opcodeinfo[0x59] = AssyInstruction(0x59, "EOR", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x69] = AssyInstruction(0x69, "ADC", AM_Immediate); - m_opcodeinfo[0x79] = AssyInstruction(0x79, "ADC", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x89] = AssyInstruction(0x89, "BIT", AM_Immediate); //65C02 - m_opcodeinfo[0x99] = AssyInstruction(0x99, "STA", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xa9] = AssyInstruction(0xa9, "LDA", AM_Immediate); - m_opcodeinfo[0xb9] = AssyInstruction(0xb9, "LDA", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xc9] = AssyInstruction(0xc9, "CMP", AM_Immediate); - m_opcodeinfo[0xd9] = AssyInstruction(0xd9, "CMP", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xe9] = AssyInstruction(0xe9, "SBC", AM_Immediate); - m_opcodeinfo[0xf9] = AssyInstruction(0xf9, "SBC", AM_AbsoluteIndexedWithY); - - m_opcodeinfo[0x0a] = AssyInstruction(0x0a, "ASL", AM_Accumulator); - m_opcodeinfo[0x1a] = AssyInstruction(0x1a, "INA", AM_Accumulator); //65C02 - m_opcodeinfo[0x2a] = AssyInstruction(0x2a, "ROL", AM_Accumulator); - m_opcodeinfo[0x3a] = AssyInstruction(0x3a, "DEC", AM_Accumulator); //65C02 - m_opcodeinfo[0x4a] = AssyInstruction(0x4a, "LSR", AM_Accumulator); - m_opcodeinfo[0x5a] = AssyInstruction(0x5a, "PHY", AM_Implied);//65C02 - m_opcodeinfo[0x6a] = AssyInstruction(0x6a, "ROR", AM_Accumulator); - m_opcodeinfo[0x7a] = AssyInstruction(0x7a, "PLY", AM_Implied);//65C02 - m_opcodeinfo[0x8a] = AssyInstruction(0x8a, "TXA", AM_Implied); - m_opcodeinfo[0x9a] = AssyInstruction(0x9a, "TXS", AM_Implied); - m_opcodeinfo[0xaa] = AssyInstruction(0xaa, "TAX", AM_Implied); - m_opcodeinfo[0xba] = AssyInstruction(0xba, "TSX", AM_Implied); - m_opcodeinfo[0xca] = AssyInstruction(0xca, "DEX", AM_Implied); - m_opcodeinfo[0xda] = AssyInstruction(0xda, "PHX", AM_Implied);//65C02 - m_opcodeinfo[0xea] = AssyInstruction(0xea, "NOP", AM_Implied); - m_opcodeinfo[0xfa] = AssyInstruction(0xfa, "PLX", AM_Implied);//65C02 - - m_opcodeinfo[0x0b] = AssyInstruction(0x0b, "???", AM_InvalidOp); - m_opcodeinfo[0x1b] = AssyInstruction(0x1b, "???", AM_InvalidOp); - m_opcodeinfo[0x2b] = AssyInstruction(0x2b, "???", AM_InvalidOp); - m_opcodeinfo[0x3b] = AssyInstruction(0x3b, "???", AM_InvalidOp); - m_opcodeinfo[0x4b] = AssyInstruction(0x4b, "???", AM_InvalidOp); - m_opcodeinfo[0x5b] = AssyInstruction(0x5b, "???", AM_InvalidOp); - m_opcodeinfo[0x6b] = AssyInstruction(0x6b, "???", AM_InvalidOp); - m_opcodeinfo[0x7b] = AssyInstruction(0x7b, "???", AM_InvalidOp); - m_opcodeinfo[0x8b] = AssyInstruction(0x8b, "???", AM_InvalidOp); - m_opcodeinfo[0x9b] = AssyInstruction(0x9b, "???", AM_InvalidOp); - m_opcodeinfo[0xab] = AssyInstruction(0xab, "???", AM_InvalidOp); - m_opcodeinfo[0xbb] = AssyInstruction(0xbb, "???", AM_InvalidOp); - m_opcodeinfo[0xcb] = AssyInstruction(0xcb, "???", AM_InvalidOp); - m_opcodeinfo[0xdb] = AssyInstruction(0xdb, "???", AM_InvalidOp); - m_opcodeinfo[0xeb] = AssyInstruction(0xeb, "???", AM_InvalidOp); - m_opcodeinfo[0xfb] = AssyInstruction(0xfb, "???", AM_InvalidOp); - - m_opcodeinfo[0x0c] = AssyInstruction(0x0c, "TSB", AM_Absolute); //65C02 - m_opcodeinfo[0x1c] = AssyInstruction(0x1c, "TRB", AM_Absolute); //65C02 - m_opcodeinfo[0x2c] = AssyInstruction(0x2c, "BIT", AM_Absolute); - m_opcodeinfo[0x3c] = AssyInstruction(0x3c, "BIT", AM_AbsoluteIndexedWithX); //65C02 - m_opcodeinfo[0x4c] = AssyInstruction(0x4c, "JMP", AM_Absolute); - m_opcodeinfo[0x5c] = AssyInstruction(0x5c, "???", AM_InvalidOp); - m_opcodeinfo[0x6c] = AssyInstruction(0x6c, "JMP", AM_AbsoluteIndirect); - m_opcodeinfo[0x7c] = AssyInstruction(0x7c, "JMP", AM_AbsoluteIndexedIndirect); //65C02 - m_opcodeinfo[0x8c] = AssyInstruction(0x8c, "STY", AM_Absolute); - m_opcodeinfo[0x9c] = AssyInstruction(0x9c, "STZ", AM_Absolute); - m_opcodeinfo[0xac] = AssyInstruction(0xac, "LDY", AM_Absolute); - m_opcodeinfo[0xbc] = AssyInstruction(0xbc, "LDY", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xcc] = AssyInstruction(0xcc, "CPY", AM_Absolute); - m_opcodeinfo[0xdc] = AssyInstruction(0xdc, "???", AM_InvalidOp); - m_opcodeinfo[0xec] = AssyInstruction(0xec, "CPX", AM_Absolute); - m_opcodeinfo[0xfc] = AssyInstruction(0xfc, "???", AM_InvalidOp); - - m_opcodeinfo[0x0d] = AssyInstruction(0x0d, "ORA", AM_Absolute); - m_opcodeinfo[0x1d] = AssyInstruction(0x1d, "ORA", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x2d] = AssyInstruction(0x2d, "AND", AM_Absolute); - m_opcodeinfo[0x3d] = AssyInstruction(0x3d, "AND", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x4d] = AssyInstruction(0x4d, "EOR", AM_Absolute); - m_opcodeinfo[0x5d] = AssyInstruction(0x5d, "EOR", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x6d] = AssyInstruction(0x6d, "ADC", AM_Absolute); - m_opcodeinfo[0x7d] = AssyInstruction(0x7d, "ADC", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x8d] = AssyInstruction(0x8d, "STA", AM_Absolute); - m_opcodeinfo[0x9d] = AssyInstruction(0x9d, "STA", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xad] = AssyInstruction(0xad, "LDA", AM_Absolute); - m_opcodeinfo[0xbd] = AssyInstruction(0xbd, "LDA", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xcd] = AssyInstruction(0xcd, "CMP", AM_Absolute); - m_opcodeinfo[0xdd] = AssyInstruction(0xdd, "CMP", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xed] = AssyInstruction(0xed, "SBC", AM_Absolute); - m_opcodeinfo[0xfd] = AssyInstruction(0xfd, "SBC", AM_AbsoluteIndexedWithX); - - m_opcodeinfo[0x0e] = AssyInstruction(0x0e, "ASL", AM_Absolute); - m_opcodeinfo[0x1e] = AssyInstruction(0x1e, "ASL", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x2e] = AssyInstruction(0x2e, "ROL", AM_Absolute); - m_opcodeinfo[0x3e] = AssyInstruction(0x3e, "ROL", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x4e] = AssyInstruction(0x4e, "LSR", AM_Absolute); - m_opcodeinfo[0x5e] = AssyInstruction(0x5e, "LSR", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x6e] = AssyInstruction(0x6e, "ROR", AM_Absolute); - m_opcodeinfo[0x7e] = AssyInstruction(0x7e, "ROR", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x8e] = AssyInstruction(0x8e, "STX", AM_Absolute); - m_opcodeinfo[0x9e] = AssyInstruction(0x9e, "STZ", AM_AbsoluteIndexedWithX); //65C02 - m_opcodeinfo[0xae] = AssyInstruction(0xae, "LDX", AM_Absolute); - m_opcodeinfo[0xbe] = AssyInstruction(0xbe, "LDX", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xce] = AssyInstruction(0xce, "DEC", AM_Absolute); - m_opcodeinfo[0xde] = AssyInstruction(0xde, "DEC", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xee] = AssyInstruction(0xee, "INC", AM_Absolute); - m_opcodeinfo[0xfe] = AssyInstruction(0xfe, "INC", AM_AbsoluteIndexedWithX); - - m_opcodeinfo[0x0f] = AssyInstruction(0x0f, "???", AM_InvalidOp); - m_opcodeinfo[0x1f] = AssyInstruction(0x1f, "???", AM_InvalidOp); - m_opcodeinfo[0x2f] = AssyInstruction(0x2f, "???", AM_InvalidOp); - m_opcodeinfo[0x3f] = AssyInstruction(0x3f, "???", AM_InvalidOp); - m_opcodeinfo[0x4f] = AssyInstruction(0x4f, "???", AM_InvalidOp); - m_opcodeinfo[0x5f] = AssyInstruction(0x5f, "???", AM_InvalidOp); - m_opcodeinfo[0x6f] = AssyInstruction(0x6f, "???", AM_InvalidOp); - m_opcodeinfo[0x7f] = AssyInstruction(0x7f, "???", AM_InvalidOp); - m_opcodeinfo[0x8f] = AssyInstruction(0x8f, "???", AM_InvalidOp); - m_opcodeinfo[0x9f] = AssyInstruction(0x9f, "???", AM_InvalidOp); - m_opcodeinfo[0xaf] = AssyInstruction(0xaf, "???", AM_InvalidOp); - m_opcodeinfo[0xbf] = AssyInstruction(0xbf, "???", AM_InvalidOp); - m_opcodeinfo[0xcf] = AssyInstruction(0xcf, "???", AM_InvalidOp); - m_opcodeinfo[0xdf] = AssyInstruction(0xdf, "???", AM_InvalidOp); - m_opcodeinfo[0xef] = AssyInstruction(0xef, "???", AM_InvalidOp); - m_opcodeinfo[0xff] = AssyInstruction(0xff, "???", AM_InvalidOp); - -#ifdef UNUSED_OPCODES - m_opcodeinfo[0x00] = AssyInstruction(0x00, "BRK", AM_Implied); - m_opcodeinfo[0x10] = AssyInstruction(0x10, "BPL", AM_ProgramCounterRelative); - m_opcodeinfo[0x20] = AssyInstruction(0x20, "JSR", AM_Absolute); - m_opcodeinfo[0x30] = AssyInstruction(0x30, "BMI", AM_ProgramCounterRelative); - m_opcodeinfo[0x40] = AssyInstruction(0x40, "RTI", AM_Implied); - m_opcodeinfo[0x50] = AssyInstruction(0x50, "BVC", AM_ProgramCounterRelative); - m_opcodeinfo[0x60] = AssyInstruction(0x60, "RTS", AM_Implied); - m_opcodeinfo[0x70] = AssyInstruction(0x70, "BVS", AM_ProgramCounterRelative); - m_opcodeinfo[0x80] = AssyInstruction(0x80, "nop", AM_ZeroPage); - m_opcodeinfo[0x90] = AssyInstruction(0x90, "BCC", AM_ProgramCounterRelative); - m_opcodeinfo[0xa0] = AssyInstruction(0xa0, "LDY", AM_Immediate); - m_opcodeinfo[0xb0] = AssyInstruction(0xb0, "BCC", AM_ProgramCounterRelative); - m_opcodeinfo[0xc0] = AssyInstruction(0xc0, "LDY", AM_Immediate); - m_opcodeinfo[0xd0] = AssyInstruction(0xd0, "BCS", AM_ProgramCounterRelative); - m_opcodeinfo[0xe0] = AssyInstruction(0xe0, "CPX", AM_Immediate); - m_opcodeinfo[0xf0] = AssyInstruction(0xf0, "BEQ", AM_ProgramCounterRelative); - - m_opcodeinfo[0x01] = AssyInstruction(0x01, "ORA", AM_AbsoluteIndexedIndirect); - m_opcodeinfo[0x11] = AssyInstruction(0x11, "ORA", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x21] = AssyInstruction(0x21, "AND", AM_AbsoluteIndexedIndirect); - m_opcodeinfo[0x31] = AssyInstruction(0x31, "AND", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x41] = AssyInstruction(0x41, "EOR", AM_AbsoluteIndexedIndirect); - m_opcodeinfo[0x51] = AssyInstruction(0x51, "EOR", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x61] = AssyInstruction(0x61, "ADC", AM_AbsoluteIndexedIndirect); - m_opcodeinfo[0x71] = AssyInstruction(0x71, "ADC", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x81] = AssyInstruction(0x81, "STA", AM_AbsoluteIndexedIndirect); - m_opcodeinfo[0x91] = AssyInstruction(0x91, "STA", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xa1] = AssyInstruction(0xa1, "LDA", AM_AbsoluteIndexedIndirect); - m_opcodeinfo[0xb1] = AssyInstruction(0xb1, "LDA", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xc1] = AssyInstruction(0xc1, "CMP", AM_AbsoluteIndexedIndirect); - m_opcodeinfo[0xd1] = AssyInstruction(0xd1, "CMP", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xe1] = AssyInstruction(0xe1, "SBC", AM_AbsoluteIndexedIndirect); - m_opcodeinfo[0xf1] = AssyInstruction(0xff, "SBC", AM_AbsoluteIndexedWithY); - - m_opcodeinfo[0x02] = AssyInstruction(0x02, "halt", AM_Immediate); - m_opcodeinfo[0x12] = AssyInstruction(0x12, "asl-ora", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0x22] = AssyInstruction(0x22, "and", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x32] = AssyInstruction(0x32, "halt", AM_Immediate); - m_opcodeinfo[0x42] = AssyInstruction(0x42, "halt", AM_Immediate); - m_opcodeinfo[0x52] = AssyInstruction(0x52, "halt", AM_Immediate); - m_opcodeinfo[0x62] = AssyInstruction(0x62, "halt", AM_Immediate); - m_opcodeinfo[0x72] = AssyInstruction(0x72, "halt", AM_Immediate); - m_opcodeinfo[0x82] = AssyInstruction(0x82, "halt", AM_Immediate); - m_opcodeinfo[0x92] = AssyInstruction(0x92, "halt", AM_Immediate); - m_opcodeinfo[0xa2] = AssyInstruction(0xa2, "LDX", AM_Immediate); - m_opcodeinfo[0xb2] = AssyInstruction(0xb2, "halt", AM_Immediate); - m_opcodeinfo[0xc2] = AssyInstruction(0xc2, "halt", AM_Immediate); - m_opcodeinfo[0xd2] = AssyInstruction(0xd2, "halt", AM_Immediate); - m_opcodeinfo[0xe2] = AssyInstruction(0xe2, "halt", AM_Immediate); - m_opcodeinfo[0xf2] = AssyInstruction(0xf2, "halt", AM_Immediate); - - m_opcodeinfo[0x03] = AssyInstruction(0x03, "asl/ora", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0x13] = AssyInstruction(0x13, "asl/ora", AM_ZeroPageIndirect); - m_opcodeinfo[0x23] = AssyInstruction(0x23, "rol/and", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0x33] = AssyInstruction(0x33, "rol/and", AM_ZeroPageIndexedWithY); - m_opcodeinfo[0x43] = AssyInstruction(0x43, "lsr/eor", AM_ZeroPage); - m_opcodeinfo[0x53] = AssyInstruction(0x53, "lsr/eor", AM_ZeroPageIndirectIndexedWithY); - m_opcodeinfo[0x63] = AssyInstruction(0x63, "ror/adc", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0x73] = AssyInstruction(0x73, "ror/adc", AM_ZeroPageIndirectIndexedWithY); - m_opcodeinfo[0x83] = AssyInstruction(0x83, "sta/stx", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0x93] = AssyInstruction(0x93, "sta/stx", AM_ZeroPageIndirectIndexedWithY); - m_opcodeinfo[0xa3] = AssyInstruction(0xa3, "lda/ldx", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0xb3] = AssyInstruction(0xb3, "lda/ldx", AM_ZeroPageIndirectIndexedWithY); - m_opcodeinfo[0xc3] = AssyInstruction(0xc3, "dec/cmp", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0xd3] = AssyInstruction(0xd3, "dec/cmp", AM_ZeroPageIndirectIndexedWithY); - m_opcodeinfo[0xe3] = AssyInstruction(0xe3, "inc/sbc", AM_ZeroPageIndexedIndirect); - m_opcodeinfo[0xf3] = AssyInstruction(0xf3, "inc/sbc", AM_ZeroPageIndirectIndexedWithY); - - m_opcodeinfo[0x04] = AssyInstruction(0x04, "nop", AM_ZeroPage); - m_opcodeinfo[0x14] = AssyInstruction(0x14, "nop", AM_ZeroPage); - m_opcodeinfo[0x24] = AssyInstruction(0x24, "BIT", AM_ZeroPage); - m_opcodeinfo[0x34] = AssyInstruction(0x34, "nop", AM_ZeroPage); - m_opcodeinfo[0x44] = AssyInstruction(0x44, "nop", AM_ZeroPage); - m_opcodeinfo[0x54] = AssyInstruction(0x54, "nop", AM_ZeroPage); - m_opcodeinfo[0x64] = AssyInstruction(0x64, "nop", AM_ZeroPage); - m_opcodeinfo[0x74] = AssyInstruction(0x74, "nop", AM_ZeroPage); - m_opcodeinfo[0x84] = AssyInstruction(0x84, "STY", AM_ZeroPage); - m_opcodeinfo[0x94] = AssyInstruction(0x94, "STY", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0xa4] = AssyInstruction(0xa4, "nop", AM_ZeroPage); - m_opcodeinfo[0xb4] = AssyInstruction(0xb4, "LDY", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0xc4] = AssyInstruction(0xc4, "CPY", AM_ZeroPage); - m_opcodeinfo[0xd4] = AssyInstruction(0xd4, "nop", AM_ZeroPage); - m_opcodeinfo[0xe4] = AssyInstruction(0xe4, "CPX", AM_ZeroPage); - m_opcodeinfo[0xf4] = AssyInstruction(0xf4, "nop", AM_ZeroPage); - - m_opcodeinfo[0x05] = AssyInstruction(0x05, "ORA", AM_ZeroPage); - m_opcodeinfo[0x15] = AssyInstruction(0x15, "ORA", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x25] = AssyInstruction(0x25, "AND", AM_ZeroPage); - m_opcodeinfo[0x35] = AssyInstruction(0x35, "AND", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x45] = AssyInstruction(0x45, "EOR", AM_ZeroPage); - m_opcodeinfo[0x55] = AssyInstruction(0x55, "EOR", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x65] = AssyInstruction(0x65, "ADC", AM_ZeroPage); - m_opcodeinfo[0x75] = AssyInstruction(0x75, "ADC", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x85] = AssyInstruction(0x85, "STA", AM_ZeroPage); - m_opcodeinfo[0x95] = AssyInstruction(0x95, "STA", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0xa5] = AssyInstruction(0xa5, "LDA", AM_ZeroPage); - m_opcodeinfo[0xb5] = AssyInstruction(0xb5, "LDA", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0xc5] = AssyInstruction(0xc5, "CMP", AM_ZeroPage); - m_opcodeinfo[0xd5] = AssyInstruction(0xd5, "CMP", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0xe5] = AssyInstruction(0xe5, "SEC", AM_ZeroPage); - m_opcodeinfo[0xf5] = AssyInstruction(0xf5, "SEC", AM_ZeroPageIndexedWithX); - - m_opcodeinfo[0x06] = AssyInstruction(0x06, "ASL", AM_ZeroPage); - m_opcodeinfo[0x16] = AssyInstruction(0x16, "ASL", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x26] = AssyInstruction(0x26, "ROL", AM_ZeroPage); - m_opcodeinfo[0x36] = AssyInstruction(0x36, "ROL", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x46] = AssyInstruction(0x46, "LSR", AM_ZeroPage); - m_opcodeinfo[0x56] = AssyInstruction(0x56, "LSR", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x66] = AssyInstruction(0x66, "ROR", AM_ZeroPage); - m_opcodeinfo[0x76] = AssyInstruction(0x76, "ROR", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x86] = AssyInstruction(0x86, "STX", AM_ZeroPage); - m_opcodeinfo[0x96] = AssyInstruction(0x96, "STX", AM_ZeroPageIndexedWithY); - m_opcodeinfo[0xa6] = AssyInstruction(0xa6, "LDX", AM_ZeroPage); - m_opcodeinfo[0xb6] = AssyInstruction(0xb6, "LDX", AM_ZeroPageIndexedWithY); - m_opcodeinfo[0xc6] = AssyInstruction(0xc6, "DEC", AM_ZeroPage); - m_opcodeinfo[0xd6] = AssyInstruction(0xd6, "DEC", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0xe6] = AssyInstruction(0xe6, "INC", AM_ZeroPage); - m_opcodeinfo[0xf6] = AssyInstruction(0xf6, "INC", AM_ZeroPageIndexedWithX); - - m_opcodeinfo[0x07] = AssyInstruction(0x07, "asl/ora", AM_ZeroPage); - m_opcodeinfo[0x17] = AssyInstruction(0x17, "asl/ora", AM_ZeroPageIndirectIndexedWithY); - m_opcodeinfo[0x27] = AssyInstruction(0x27, "rol/and", AM_ZeroPage); - m_opcodeinfo[0x37] = AssyInstruction(0x37, "rol/and", AM_ZeroPageIndexedWithX); - m_opcodeinfo[0x47] = AssyInstruction(0x47, "lsr/eor", AM_ZeroPage); - m_opcodeinfo[0x57] = AssyInstruction(0x57, "lsr/eor", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x67] = AssyInstruction(0x67, "ror/adc", AM_ZeroPage); - m_opcodeinfo[0x77] = AssyInstruction(0x77, "ror/adc", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x87] = AssyInstruction(0x87, "sta/stx", AM_ZeroPage); - m_opcodeinfo[0x97] = AssyInstruction(0x97, "sta/stx", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xa7] = AssyInstruction(0xa7, "lda/ldx", AM_ZeroPage); - m_opcodeinfo[0xb7] = AssyInstruction(0xb7, "ldx/ldx", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xc7] = AssyInstruction(0xc7, "dec/cmp", AM_ZeroPage); - m_opcodeinfo[0xd7] = AssyInstruction(0xd7, "dec/cmp", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xe7] = AssyInstruction(0xe7, "inc/sbc", AM_ZeroPage); - m_opcodeinfo[0xf7] = AssyInstruction(0xf7, "inc/sbc", AM_AbsoluteIndexedWithX); - - m_opcodeinfo[0x08] = AssyInstruction(0x08, "PHP", AM_Implied); - m_opcodeinfo[0x18] = AssyInstruction(0x18, "CLC", AM_Implied); - m_opcodeinfo[0x28] = AssyInstruction(0x28, "PLP", AM_Implied); - m_opcodeinfo[0x38] = AssyInstruction(0x38, "SEC", AM_Implied); - m_opcodeinfo[0x48] = AssyInstruction(0x48, "PHA", AM_Implied); - m_opcodeinfo[0x58] = AssyInstruction(0x58, "CLI", AM_Implied); - m_opcodeinfo[0x68] = AssyInstruction(0x68, "PLA", AM_Implied); - m_opcodeinfo[0x78] = AssyInstruction(0x78, "SEI", AM_Implied); - m_opcodeinfo[0x88] = AssyInstruction(0x88, "DEY", AM_Implied); - m_opcodeinfo[0x98] = AssyInstruction(0x98, "TYA", AM_Implied); - m_opcodeinfo[0xa8] = AssyInstruction(0xa8, "TAY", AM_Implied); - m_opcodeinfo[0xb8] = AssyInstruction(0xb8, "CLV", AM_Implied); - m_opcodeinfo[0xc8] = AssyInstruction(0xc8, "INY", AM_Implied); - m_opcodeinfo[0xd8] = AssyInstruction(0xd8, "CLD", AM_Implied); - m_opcodeinfo[0xe8] = AssyInstruction(0xe8, "INX", AM_Implied); - m_opcodeinfo[0xf8] = AssyInstruction(0xf8, "SED", AM_Implied); - - m_opcodeinfo[0x09] = AssyInstruction(0x09, "ORA", AM_Immediate); - m_opcodeinfo[0x19] = AssyInstruction(0x19, "ORA", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x29] = AssyInstruction(0x29, "AND", AM_Immediate); - m_opcodeinfo[0x39] = AssyInstruction(0x39, "AND", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x49] = AssyInstruction(0x49, "EOR", AM_Immediate); - m_opcodeinfo[0x59] = AssyInstruction(0x59, "EOR", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x69] = AssyInstruction(0x69, "ADC", AM_Immediate); - m_opcodeinfo[0x79] = AssyInstruction(0x79, "ADC", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x89] = AssyInstruction(0x89, "nop", AM_ZeroPage); - m_opcodeinfo[0x99] = AssyInstruction(0x99, "STA", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xa9] = AssyInstruction(0xa9, "LDA", AM_Immediate); - m_opcodeinfo[0xb9] = AssyInstruction(0xb9, "LDA", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xc9] = AssyInstruction(0xc9, "CMP", AM_Immediate); - m_opcodeinfo[0xd9] = AssyInstruction(0xd9, "CMP", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xe9] = AssyInstruction(0xe9, "SBC", AM_Immediate); - m_opcodeinfo[0xf9] = AssyInstruction(0xf9, "SBC", AM_AbsoluteIndexedWithY); - - m_opcodeinfo[0x0a] = AssyInstruction(0x0a, "ASL", AM_Accumulator); - m_opcodeinfo[0x1a] = AssyInstruction(0x1a, "nop", AM_Implied); - m_opcodeinfo[0x2a] = AssyInstruction(0x2a, "ROL", AM_Accumulator); - m_opcodeinfo[0x3a] = AssyInstruction(0x3a, "nop", AM_Implied); - m_opcodeinfo[0x4a] = AssyInstruction(0x4a, "LSR", AM_Accumulator); - m_opcodeinfo[0x5a] = AssyInstruction(0x5a, "nop", AM_Implied); - m_opcodeinfo[0x6a] = AssyInstruction(0x6a, "ROR", AM_Accumulator); - m_opcodeinfo[0x7a] = AssyInstruction(0x7a, "nop", AM_Implied); - m_opcodeinfo[0x8a] = AssyInstruction(0x8a, "TXA", AM_Implied); - m_opcodeinfo[0x9a] = AssyInstruction(0x9a, "TXS", AM_Implied); - m_opcodeinfo[0xaa] = AssyInstruction(0xaa, "TAX", AM_Implied); - m_opcodeinfo[0xba] = AssyInstruction(0xba, "TSX", AM_Implied); - m_opcodeinfo[0xca] = AssyInstruction(0xca, "DEX", AM_Implied); - m_opcodeinfo[0xda] = AssyInstruction(0xda, "nop", AM_Implied); - m_opcodeinfo[0xea] = AssyInstruction(0xea, "NOP", AM_Implied); - m_opcodeinfo[0xfa] = AssyInstruction(0xfa, "nop", AM_Implied); - - m_opcodeinfo[0x0b] = AssyInstruction(0x0b, "and/mov bit7->Cy", AM_Immediate); - m_opcodeinfo[0x1b] = AssyInstruction(0x1b, "asl/ora", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x2b] = AssyInstruction(0x2b, "and/mov bit7->Cy", AM_Immediate); - m_opcodeinfo[0x3b] = AssyInstruction(0x3b, "asl/ora", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x4b] = AssyInstruction(0x4b, "and/lsr A", AM_Immediate); - m_opcodeinfo[0x5b] = AssyInstruction(0x5b, "lsr/eor", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x6b] = AssyInstruction(0x6b, "and/ror A", AM_Immediate); - m_opcodeinfo[0x7b] = AssyInstruction(0x7b, "ror/adc", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0x8b] = AssyInstruction(0x8b, "txa/and", AM_Immediate); - m_opcodeinfo[0x9b] = AssyInstruction(0x9b, "sta/stx", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xab] = AssyInstruction(0xab, "lda/ldx", AM_Implied); - m_opcodeinfo[0xbb] = AssyInstruction(0xbb, "lda/ldx", AM_Implied); - m_opcodeinfo[0xcb] = AssyInstruction(0xcb, "sbx", AM_Immediate); - m_opcodeinfo[0xdb] = AssyInstruction(0xdb, "dec/cmp", AM_Absolute); - m_opcodeinfo[0xeb] = AssyInstruction(0xeb, "sbc", AM_Immediate); - m_opcodeinfo[0xfb] = AssyInstruction(0xfb, "inc/sbc", AM_Absolute); - - m_opcodeinfo[0x0c] = AssyInstruction(0x0c, "nop", AM_Absolute); - m_opcodeinfo[0x1c] = AssyInstruction(0x1c, "nop", AM_Absolute); - m_opcodeinfo[0x2c] = AssyInstruction(0x2c, "BIT", AM_Absolute); - m_opcodeinfo[0x3c] = AssyInstruction(0x3c, "nop", AM_Absolute); - m_opcodeinfo[0x4c] = AssyInstruction(0x4c, "JMP", AM_Absolute); - m_opcodeinfo[0x5c] = AssyInstruction(0x5c, "nop", AM_Absolute); - m_opcodeinfo[0x6c] = AssyInstruction(0x6c, "JMP", AM_AbsoluteIndirect); - m_opcodeinfo[0x7c] = AssyInstruction(0x7c, "nop", AM_Absolute); - m_opcodeinfo[0x8c] = AssyInstruction(0x8c, "STY", AM_Absolute); - m_opcodeinfo[0x9c] = AssyInstruction(0x9c, "sta/stx", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xac] = AssyInstruction(0xac, "LDY", AM_Absolute); - m_opcodeinfo[0xbc] = AssyInstruction(0xbc, "LDY", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xcc] = AssyInstruction(0xcc, "CPY", AM_Absolute); - m_opcodeinfo[0xdc] = AssyInstruction(0xdc, "???", AM_InvalidOp); - m_opcodeinfo[0xec] = AssyInstruction(0xec, "CPX", AM_Absolute); - m_opcodeinfo[0xfc] = AssyInstruction(0xfc, "???", AM_InvalidOp); - - m_opcodeinfo[0x0d] = AssyInstruction(0x0d, "ORA", AM_Absolute); - m_opcodeinfo[0x1d] = AssyInstruction(0x1d, "ORA", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x2d] = AssyInstruction(0x2d, "AND", AM_Absolute); - m_opcodeinfo[0x3d] = AssyInstruction(0x3d, "AND", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x4d] = AssyInstruction(0x4d, "EOR", AM_Absolute); - m_opcodeinfo[0x5d] = AssyInstruction(0x5d, "EOR", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x6d] = AssyInstruction(0x6d, "ADC", AM_Absolute); - m_opcodeinfo[0x7d] = AssyInstruction(0x7d, "ADC", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x8d] = AssyInstruction(0x8d, "STA", AM_Absolute); - m_opcodeinfo[0x9d] = AssyInstruction(0x9d, "STA", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xad] = AssyInstruction(0xad, "LDA", AM_Absolute); - m_opcodeinfo[0xbd] = AssyInstruction(0xbd, "LDA", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xcd] = AssyInstruction(0xcd, "CMP", AM_Absolute); - m_opcodeinfo[0xdd] = AssyInstruction(0xdd, "CMP", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xed] = AssyInstruction(0xed, "SBC", AM_Absolute); - m_opcodeinfo[0xfd] = AssyInstruction(0xfd, "SBC", AM_AbsoluteIndexedWithX); - - m_opcodeinfo[0x0e] = AssyInstruction(0x0e, "ASL", AM_Absolute); - m_opcodeinfo[0x1e] = AssyInstruction(0x1e, "ASL", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x2e] = AssyInstruction(0x2e, "ROL", AM_Absolute); - m_opcodeinfo[0x3e] = AssyInstruction(0x3e, "ROL", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x4e] = AssyInstruction(0x4e, "LSR", AM_Absolute); - m_opcodeinfo[0x5e] = AssyInstruction(0x5e, "LSR", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x6e] = AssyInstruction(0x6e, "ROR", AM_Absolute); - m_opcodeinfo[0x7e] = AssyInstruction(0x7e, "ROR", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x8e] = AssyInstruction(0x8e, "STX", AM_Absolute); - m_opcodeinfo[0x9e] = AssyInstruction(0x9e, "sta/stx", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xae] = AssyInstruction(0xae, "LDX", AM_Absolute); - m_opcodeinfo[0xbe] = AssyInstruction(0xbe, "LDX", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xce] = AssyInstruction(0xce, "DEC", AM_Absolute); - m_opcodeinfo[0xde] = AssyInstruction(0xde, "DEC", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xee] = AssyInstruction(0xee, "INC", AM_Absolute); - m_opcodeinfo[0xfe] = AssyInstruction(0xfe, "INC", AM_AbsoluteIndexedWithX); - - m_opcodeinfo[0x0f] = AssyInstruction(0x0f, "asl/ora", AM_Absolute); - m_opcodeinfo[0x1f] = AssyInstruction(0x1f, "asl/ora", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x2f] = AssyInstruction(0x2f, "rol/and", AM_Absolute); - m_opcodeinfo[0x3f] = AssyInstruction(0x3f, "rol/and", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x4f] = AssyInstruction(0x4f, "lsr/eor", AM_Absolute); - m_opcodeinfo[0x5f] = AssyInstruction(0x5f, "lsr/eor", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x6f] = AssyInstruction(0x6f, "ror/adc", AM_Absolute); - m_opcodeinfo[0x7f] = AssyInstruction(0x7f, "ror/adc", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0x8f] = AssyInstruction(0x8f, "sta/stx", AM_Absolute); - m_opcodeinfo[0x9f] = AssyInstruction(0x9f, "sta/stx", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xaf] = AssyInstruction(0xaf, "lda/ldx", AM_Absolute); - m_opcodeinfo[0xbf] = AssyInstruction(0xbf, "ldx/ldx", AM_AbsoluteIndexedWithY); - m_opcodeinfo[0xcf] = AssyInstruction(0xcf, "dec/cmp", AM_Absolute); - m_opcodeinfo[0xdf] = AssyInstruction(0xdf, "dec/cmp", AM_AbsoluteIndexedWithX); - m_opcodeinfo[0xef] = AssyInstruction(0xef, "inc/sbc", AM_Absolute); - m_opcodeinfo[0xff] = AssyInstruction(0xff, "inc/sbc", AM_AbsoluteIndexedWithX); -#endif - -} - -void Disassembler::setUnknownToData(quint16 from, quint16 to) -{ - for (int idx = from; idx <= to; idx++) - { - if (m_memusagemap[idx].testFlag(Unknown)) - { - m_memusagemap[idx].setFlag(Data); - } - } -} - -AssyInstruction::AssyInstruction(quint8 opcode, QString mnemonic, AddressMode am) { - m_opcode = opcode; - m_mnemonic = mnemonic; - m_addressMode = am; -} - -quint8 AssyInstruction::numArgs() { - switch (m_addressMode) { - case AM_Absolute: - case AM_AbsoluteIndexedIndirect: - case AM_AbsoluteIndexedWithX: - case AM_AbsoluteIndexedWithY: - case AM_AbsoluteIndirect: - return 2; - case AM_ProgramCounterRelative: - case AM_ZeroPage: - case AM_ZeroPageIndirectIndexedWithY: - case AM_ZeroPageIndexedIndirect: - case AM_ZeroPageIndexedWithX: - case AM_ZeroPageIndexedWithY: - case AM_ZeroPageIndirect: - case AM_Immediate: - return 1; - case AM_InvalidOp: - case AM_Implied: - case AM_Accumulator: - default: - return 0; - } -} - -DisassembledItem::DisassembledItem(AssyInstruction instr) { - m_canNotFollow = false; - setInstruction(instr); -} - -void DisassembledItem::setInstruction(AssyInstruction instr) { - m_instruction = instr; - // qDebug() << "Set instruction: " << uint8ToHex(instr.opcode()); - // qDebug() << " Copied instr:" << m_instruction.debugStr(); - if (instr.opcode() == 0x20) { m_is_jsr = true; } - if (instr.opcode() == 0x10) { m_is_branch = true; } // BPL - if (instr.opcode() == 0x30) { m_is_branch = true; } // BMI - if (instr.opcode() == 0x50) { m_is_branch = true; } // BVC - if (instr.opcode() == 0x70) { m_is_branch = true; } // BVS - if (instr.opcode() == 0x90) { m_is_branch = true; } // BCC - if (instr.opcode() == 0xB0) { m_is_branch = true; } // BCS - if (instr.opcode() == 0xD0) { m_is_branch = true; } // BNE - if (instr.opcode() == 0xF0) { m_is_branch = true; } // BEQ - if (instr.opcode() == 0x80) { m_is_jump = true; } // BRA - if (instr.opcode() == 0x4C) { m_is_jump = true; } // JMP a - if (instr.opcode() == 0x6C) { m_is_jump = true; } // JMP (a) - if (instr.opcode() == 0x7C) { m_is_jump = true; } // JMP (a,x) -} - -QString DisassembledItem::disassembledString() { - QString retval = rawDisassembledString(); - if (hasArg()) { - if (retval.contains("_ARG16_")) { - retval.replace("_ARG16_","$"+arg16Str()); - } else if (retval.contains("_ARG8_")) { - retval.replace("_ARG8_","$"+arg8Str()); - } - } - return retval; -} - -void DisassembledItem::init() { - m_address = m_target_address = 0; - m_nextContiguousAddress = 0; - m_nextFlowAddress = 0; - m_is_jump = m_is_branch = m_is_jsr = false; - m_unknown_ta = true; - m_raw_arg = 0; - m_has_arg = false; - m_canNotFollow = false; - m_isInvalidOp = false; - -} +#include "disassembler.h" +#include +#include +#include + + +Disassembler::Disassembler(QByteArray memimage) +{ + m_memimage = memimage, makeOpcodeTable(); + m_memusagemap.clearData(); + +} + + +QList Disassembler::disassemble(quint16 from, quint16 to, + QList entryPoints, + bool processRecursively) { + m_from = from; + m_to = to; + QList retval; + qDebug() << "\n\n*****************\n\nDisassemble: From"< 0xffff || (idx < from)) { + qDebug() << "Breaking."; + break; + } + } +#else + MemoryUsageMap memuse; + + bool stopping = false; + quint16 next = from; + while (entryPoints.count()) + { + next = entryPoints.takeFirst(); + //m_jumps.append(entryPoints); + m_stack.push(next); + } + + while (!stopping) + { + // quint8 opcode = m_memimage[next]; + // qDebug() << "Opcode: " << uint8ToHex(opcode); + DisassembledItem item; + bool ok = false; + + if (next >= from && next <= to) //TODO: Remove this to not limit disassembly to program range + ok = disassembleOp(next,item,&memuse); + + if (ok) + { + retval.append(item); + + quint16 flow = item.nextFlowAddress(); + qDebug() << uint16ToHex(next) << uint16ToHex(flow); + if (item.isBranch()) + { + qDebug() << "Is Branch"; + m_stack.push(item.targetAddress()); + // if (!m_jumps.contains(item.targetAddress())) + // { + // m_jumps.append(item.targetAddress()); + // qDebug() << "Appending branch" << uint16ToHex(item.targetAddress()) << "to jump table"; + + // } + } + + if (item.isJsr() && !item.canNotFollow()) + { + if (item.targetAddress() <= to) //TODO: Remove this to not limit disassembly to program range + { + if (m_stack.push(item.targetAddress())) + //if (!m_jumps.contains(item.targetAddress())) + { + qDebug() << "Appending" << uint16ToHex(item.targetAddress()) << "to jump table"; + + //m_jumps.append(item.targetAddress()); + } + else + { + qDebug() << "Not adding" << uint16ToHex(item.targetAddress()) << "to jump table"; + } + } + } + + if (next <= to) //TODO: Remove this to not limit disassembly to program range + { + next = flow; + stopping = item.stopsProcessing(); + } + else stopping = true; + } + else + { + stopping = true; // already processed this address + } + + // if (found.contains(next)) stopping = true; + if (next >= to) stopping = true; + // if (stopping) { + // qDebug() << "Stopping. Stops processing: " + // << item.stopsProcessing() + // << ", next>=to: " << (next >= to) + // << ", alreadyFound: " << ((!ok)?"true":"false"); + // } + } + + m_memusagemap.merge(memuse); + + if (processRecursively) + //while (m_jumps.size()) + while (!m_stack.isEmpty()) + { + // quint16 num = m_jumps.takeFirst(); + quint16 num = m_stack.pop(); + if (!m_memusagemap[num].testFlag(Operation)) + { + if (num >= from && num <= to) // TODO: remove this to not limit disassembly to program range + { + qDebug() << "Calling recursively to"<() << num,false)); + qDebug() << "Return from recursive call."; + } + } + } + +#endif + qSort(retval); + + // QStringList hexdump; + // foreach (quint16 adr,m_memusagemap.addressesWhichContain(Operation)) + // { + // hexdump.append(uint16ToHex(adr)); + // } + // qDebug() << "Operations:" << hexdump; + + // hexdump.clear(); + // foreach (quint16 adr,m_memusagemap.addressesWhichContain(OperationArg)) + // { + // hexdump.append(uint16ToHex(adr)); + // } + // qDebug() << "Operations Args:" << hexdump; + + if (processRecursively) + { + // m_jlm.dumpJumps(); + m_jumplines = m_jlm.buildJumpLines(); + qDebug() << "Num Channels: " << m_jlm.getNumJumpLineChannels(); + } + + return retval; +} + +bool Disassembler::disassembleOp(quint16 address, DisassembledItem &retval, MemoryUsageMap *memuse) +{ + + if (memuse) + { + if ((*memuse)[address].testFlag(Operation)) return false; + } + + quint8 opcode = m_memimage[address]; + AssyInstruction op = m_opcodeinfo[opcode]; + retval.setInstruction(op); + + if (opcode == 0x6C || opcode == 0x7c) // Indirect jumps + { + m_jlm.addJump(address,address,IsUnknownJump,m_from,m_to); + retval.setCanNotFollow(true); + } + + QString disassemblyLine; + QString hexValueString; + QByteArray hexValues; + hexValues.append(opcode); + + // Prepare Op Code arguments + + for (int idx = 1; idx < op.numArgs()+1; idx++) { + quint8 val = m_memimage[address+idx]; + hexValues.append(val); + } + if (memuse) + { + (*memuse)[address].setFlag(Operation); + for (int idx = 1; idx < op.numArgs()+1; idx++) + { + (*memuse)[address+idx].setFlag(OperationArg); + } + } + + quint16 argval = 0; + if (op.numArgs() == 1) + argval = (quint8) hexValues[1]; + else if (op.numArgs() == 2) + { + argval = makeWord(hexValues[1],hexValues[2]); + } + + + + for (int idx = 0; idx < hexValues.length(); idx++) { + hexValueString.append(QString("%1 ").arg((quint8) hexValues[idx],2,16,QChar('0'))); + } + + retval.setNextContiguousAddress(address+1+op.numArgs()); + retval.setNextFlowAddress(address+1+op.numArgs()); + + // Disassemble instruction + switch (op.addressMode()) { + case AM_InvalidOp: { + disassemblyLine = op.mnemonic(); + retval.setIsInvalidOp(true); + break; + } + case AM_Absolute:{ + disassemblyLine = QString("%1 _ARG16_").arg(op.mnemonic()); + retval.setRawArgument(argval); + break; + } + case AM_AbsoluteIndexedIndirect:{ + disassemblyLine = QString("%1 (_ARG16_,x)").arg(op.mnemonic()); + retval.setRawArgument(argval); + break; + } + case AM_AbsoluteIndexedWithX:{ + disassemblyLine = QString("%1 _ARG16_,x").arg(op.mnemonic()); + retval.setRawArgument(argval); + break; + } + case AM_AbsoluteIndexedWithY:{ + disassemblyLine = QString("%1 _ARG16_,y").arg(op.mnemonic()); + retval.setRawArgument(argval); + break; + } + case AM_AbsoluteIndirect:{ + disassemblyLine = QString("%1 (_ARG16_)").arg(op.mnemonic()); + retval.setRawArgument(argval); + break; + } + case AM_Immediate:{ + disassemblyLine = QString("%1 #%2").arg(op.mnemonic()).arg((quint8) hexValues[1],2,16,QChar('0')).toUpper(); + retval.setRawArgument(argval); + break; + } + case AM_Implied:{ + disassemblyLine = op.mnemonic(); + break; + } + case AM_Accumulator:{ + disassemblyLine = op.mnemonic(); + break; + } + case AM_ProgramCounterRelative:{ + qint8 offset = (qint8) hexValues[1]; + quint16 offsetAddress = address+2+offset; + + retval.setTargetAddress(offsetAddress); + if (opcode == 0x80) // BRA + m_jlm.addJump(address,offsetAddress,IsBRA,m_from,m_to); + else + m_jlm.addJump(address,offsetAddress,IsBranch,m_from,m_to); + + disassemblyLine = QString("%1 _ARG16_ {%2%3}").arg(op.mnemonic()) + .arg((offset<0)?"-":"+") + .arg(abs(offset)); + retval.setRawArgument(offsetAddress); + break; + } + case AM_ZeroPage:{ + disassemblyLine = QString("%1 _ARG8_").arg(op.mnemonic()); + retval.setRawArgument(argval); + break; + } + case AM_ZeroPageIndirectIndexedWithY:{ + disassemblyLine = QString("%1 (_ARG8_),Y").arg(op.mnemonic()); + retval.setRawArgument(argval); + break; + } + case AM_ZeroPageIndexedIndirect:{ + disassemblyLine = QString("%1 (_ARG8_,x)").arg(op.mnemonic()); + retval.setRawArgument(argval); + break; + } + case AM_ZeroPageIndexedWithX:{ + disassemblyLine = QString("%1 _ARG8_,x").arg(op.mnemonic()); + retval.setRawArgument(argval); + break; + } + case AM_ZeroPageIndexedWithY:{ + disassemblyLine = QString("%1 _ARG8_,y").arg(op.mnemonic()); + retval.setRawArgument(argval); + break; + } + case AM_ZeroPageIndirect:{ + disassemblyLine = QString("%1 (_ARG8_)").arg(op.mnemonic()); + retval.setRawArgument(argval); + break; + } + default:{ + disassemblyLine = op.mnemonic(); + retval.setIsInvalidOp(true); + qDebug() << "Unhandled Address Mode: " << op.addressMode(); + break; + } + } + + if (opcode == 0x20 || opcode == 0x4c) { + retval.setTargetAddress(makeWord(hexValues[1],hexValues[2])); + + if (opcode == 0x4c) // JMP + { + qDebug() << "JMP: Adding flow address " + << uint16ToHex(makeWord(hexValues[1],hexValues[2])) << "to jump table"; + m_jlm.addJump(address,argval,IsJMP,m_from,m_to); + m_stack.push(argval); + retval.setCanNotFollow(true); + } + else // JSR + { + m_jlm.addJump(address,argval,IsJSR,m_from,m_to); + } + } + + retval.setAddress(address); + retval.setDisassembledString(disassemblyLine.toUpper()); + retval.setHexString(hexValueString.trimmed().toUpper().leftJustified(12,' ')); + retval.setHexValues(hexValues); + + return true; +} + +void Disassembler::makeOpcodeTable() +{ + m_opcodeinfo[0x00] = AssyInstruction(0x00, "BRK", AM_Implied); + m_opcodeinfo[0x10] = AssyInstruction(0x10, "BPL", AM_ProgramCounterRelative); + m_opcodeinfo[0x20] = AssyInstruction(0x20, "JSR", AM_Absolute); + m_opcodeinfo[0x30] = AssyInstruction(0x30, "BMI", AM_ProgramCounterRelative); + m_opcodeinfo[0x40] = AssyInstruction(0x40, "RTI", AM_Implied); + m_opcodeinfo[0x50] = AssyInstruction(0x50, "BVC", AM_ProgramCounterRelative); + m_opcodeinfo[0x60] = AssyInstruction(0x60, "RTS", AM_Implied); + m_opcodeinfo[0x70] = AssyInstruction(0x70, "BVS", AM_ProgramCounterRelative); + m_opcodeinfo[0x80] = AssyInstruction(0x80, "BRA", AM_ProgramCounterRelative); //65C02 + m_opcodeinfo[0x90] = AssyInstruction(0x90, "BCC", AM_ProgramCounterRelative); + m_opcodeinfo[0xa0] = AssyInstruction(0xa0, "LDY", AM_Immediate); + m_opcodeinfo[0xb0] = AssyInstruction(0xb0, "BCS", AM_ProgramCounterRelative); + m_opcodeinfo[0xc0] = AssyInstruction(0xc0, "CPY", AM_Immediate); + m_opcodeinfo[0xd0] = AssyInstruction(0xd0, "BNE", AM_ProgramCounterRelative); + m_opcodeinfo[0xe0] = AssyInstruction(0xe0, "CPX", AM_Immediate); + m_opcodeinfo[0xf0] = AssyInstruction(0xf0, "BEQ", AM_ProgramCounterRelative); + + m_opcodeinfo[0x01] = AssyInstruction(0x01, "ORA", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0x11] = AssyInstruction(0x11, "ORA", AM_ZeroPageIndirectIndexedWithY); + m_opcodeinfo[0x21] = AssyInstruction(0x21, "AND", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0x31] = AssyInstruction(0x31, "AND", AM_ZeroPageIndirectIndexedWithY); + m_opcodeinfo[0x41] = AssyInstruction(0x41, "EOR", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0x51] = AssyInstruction(0x51, "EOR", AM_ZeroPageIndirectIndexedWithY); + m_opcodeinfo[0x61] = AssyInstruction(0x61, "ADC", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0x71] = AssyInstruction(0x71, "ADC", AM_ZeroPageIndirectIndexedWithY); + m_opcodeinfo[0x81] = AssyInstruction(0x81, "STA", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0x91] = AssyInstruction(0x91, "STA", AM_ZeroPageIndirectIndexedWithY); + m_opcodeinfo[0xa1] = AssyInstruction(0xa1, "LDA", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0xb1] = AssyInstruction(0xb1, "LDA", AM_ZeroPageIndirectIndexedWithY); + m_opcodeinfo[0xc1] = AssyInstruction(0xc1, "CMP", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0xd1] = AssyInstruction(0xd1, "CMP", AM_ZeroPageIndirectIndexedWithY); + m_opcodeinfo[0xe1] = AssyInstruction(0xe1, "SBC", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0xf1] = AssyInstruction(0xff, "SBC", AM_ZeroPageIndirectIndexedWithY); + + m_opcodeinfo[0x02] = AssyInstruction(0x02, "???", AM_InvalidOp); + m_opcodeinfo[0x12] = AssyInstruction(0x12, "ORA", AM_ZeroPageIndirect); + m_opcodeinfo[0x22] = AssyInstruction(0x22, "???", AM_InvalidOp); + m_opcodeinfo[0x32] = AssyInstruction(0x32, "AND", AM_ZeroPageIndirect); + m_opcodeinfo[0x42] = AssyInstruction(0x42, "???", AM_InvalidOp); + m_opcodeinfo[0x52] = AssyInstruction(0x52, "EOR", AM_ZeroPageIndirect); + m_opcodeinfo[0x62] = AssyInstruction(0x62, "???", AM_InvalidOp); + m_opcodeinfo[0x72] = AssyInstruction(0x72, "ADC", AM_ZeroPageIndirect); + m_opcodeinfo[0x82] = AssyInstruction(0x82, "???", AM_InvalidOp); + m_opcodeinfo[0x92] = AssyInstruction(0x92, "STA", AM_ZeroPageIndirect); //65C02 + m_opcodeinfo[0xa2] = AssyInstruction(0xa2, "LDX", AM_Immediate); + m_opcodeinfo[0xb2] = AssyInstruction(0xb2, "LDA", AM_ZeroPageIndirect); //65C02 + m_opcodeinfo[0xc2] = AssyInstruction(0xc2, "???", AM_InvalidOp); + m_opcodeinfo[0xd2] = AssyInstruction(0xd2, "CMP", AM_ZeroPageIndirect); + m_opcodeinfo[0xe2] = AssyInstruction(0xe2, "???", AM_InvalidOp); + m_opcodeinfo[0xf2] = AssyInstruction(0xf2, "SBC", AM_ZeroPageIndirect); + + m_opcodeinfo[0x03] = AssyInstruction(0x03, "???", AM_InvalidOp); + m_opcodeinfo[0x13] = AssyInstruction(0x13, "???", AM_InvalidOp); + m_opcodeinfo[0x23] = AssyInstruction(0x23, "???", AM_InvalidOp); + m_opcodeinfo[0x33] = AssyInstruction(0x33, "???", AM_InvalidOp); + m_opcodeinfo[0x43] = AssyInstruction(0x43, "???", AM_InvalidOp); + m_opcodeinfo[0x53] = AssyInstruction(0x53, "???", AM_InvalidOp); + m_opcodeinfo[0x63] = AssyInstruction(0x63, "???", AM_InvalidOp); + m_opcodeinfo[0x73] = AssyInstruction(0x73, "???", AM_InvalidOp); + m_opcodeinfo[0x83] = AssyInstruction(0x83, "???", AM_InvalidOp); + m_opcodeinfo[0x93] = AssyInstruction(0x93, "???", AM_InvalidOp); + m_opcodeinfo[0xa3] = AssyInstruction(0xa3, "???", AM_InvalidOp); + m_opcodeinfo[0xb3] = AssyInstruction(0xb3, "???", AM_InvalidOp); + m_opcodeinfo[0xc3] = AssyInstruction(0xc3, "???", AM_InvalidOp); + m_opcodeinfo[0xd3] = AssyInstruction(0xd3, "???", AM_InvalidOp); + m_opcodeinfo[0xe3] = AssyInstruction(0xe3, "???", AM_InvalidOp); + m_opcodeinfo[0xf3] = AssyInstruction(0xf3, "???", AM_InvalidOp); + + m_opcodeinfo[0x04] = AssyInstruction(0x04, "TSB", AM_ZeroPage); //65C02 + m_opcodeinfo[0x14] = AssyInstruction(0x14, "TRB", AM_ZeroPage); //65C02 + m_opcodeinfo[0x24] = AssyInstruction(0x24, "BIT", AM_ZeroPage); + m_opcodeinfo[0x34] = AssyInstruction(0x34, "BIT", AM_ZeroPageIndexedWithX); //65C02 + m_opcodeinfo[0x44] = AssyInstruction(0x44, "???", AM_InvalidOp); + m_opcodeinfo[0x54] = AssyInstruction(0x54, "???", AM_InvalidOp); + m_opcodeinfo[0x64] = AssyInstruction(0x64, "STZ", AM_ZeroPage); //65C02 + m_opcodeinfo[0x74] = AssyInstruction(0x74, "STZ", AM_ZeroPageIndexedWithX); //65C02 + m_opcodeinfo[0x84] = AssyInstruction(0x84, "STY", AM_ZeroPage); + m_opcodeinfo[0x94] = AssyInstruction(0x94, "STY", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0xa4] = AssyInstruction(0xa4, "LDY", AM_ZeroPage); + m_opcodeinfo[0xb4] = AssyInstruction(0xb4, "LDY", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0xc4] = AssyInstruction(0xc4, "CPY", AM_ZeroPage); + m_opcodeinfo[0xd4] = AssyInstruction(0xd4, "???", AM_InvalidOp); + m_opcodeinfo[0xe4] = AssyInstruction(0xe4, "CPX", AM_ZeroPage); + m_opcodeinfo[0xf4] = AssyInstruction(0xf4, "???", AM_InvalidOp); + + m_opcodeinfo[0x05] = AssyInstruction(0x05, "ORA", AM_ZeroPage); + m_opcodeinfo[0x15] = AssyInstruction(0x15, "ORA", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x25] = AssyInstruction(0x25, "AND", AM_ZeroPage); + m_opcodeinfo[0x35] = AssyInstruction(0x35, "AND", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x45] = AssyInstruction(0x45, "EOR", AM_ZeroPage); + m_opcodeinfo[0x55] = AssyInstruction(0x55, "EOR", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x65] = AssyInstruction(0x65, "ADC", AM_ZeroPage); + m_opcodeinfo[0x75] = AssyInstruction(0x75, "ADC", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x85] = AssyInstruction(0x85, "STA", AM_ZeroPage); + m_opcodeinfo[0x95] = AssyInstruction(0x95, "STA", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0xa5] = AssyInstruction(0xa5, "LDA", AM_ZeroPage); + m_opcodeinfo[0xb5] = AssyInstruction(0xb5, "LDA", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0xc5] = AssyInstruction(0xc5, "CMP", AM_ZeroPage); + m_opcodeinfo[0xd5] = AssyInstruction(0xd5, "CMP", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0xe5] = AssyInstruction(0xe5, "SEC", AM_ZeroPage); + m_opcodeinfo[0xf5] = AssyInstruction(0xf5, "SEC", AM_ZeroPageIndexedWithX); + + m_opcodeinfo[0x06] = AssyInstruction(0x06, "ASL", AM_ZeroPage); + m_opcodeinfo[0x16] = AssyInstruction(0x16, "ASL", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x26] = AssyInstruction(0x26, "ROL", AM_ZeroPage); + m_opcodeinfo[0x36] = AssyInstruction(0x36, "ROL", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x46] = AssyInstruction(0x46, "LSR", AM_ZeroPage); + m_opcodeinfo[0x56] = AssyInstruction(0x56, "LSR", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x66] = AssyInstruction(0x66, "ROR", AM_ZeroPage); + m_opcodeinfo[0x76] = AssyInstruction(0x76, "ROR", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x86] = AssyInstruction(0x86, "STX", AM_ZeroPage); + m_opcodeinfo[0x96] = AssyInstruction(0x96, "STX", AM_ZeroPageIndexedWithY); + m_opcodeinfo[0xa6] = AssyInstruction(0xa6, "LDX", AM_ZeroPage); + m_opcodeinfo[0xb6] = AssyInstruction(0xb6, "LDX", AM_ZeroPageIndexedWithY); + m_opcodeinfo[0xc6] = AssyInstruction(0xc6, "DEC", AM_ZeroPage); + m_opcodeinfo[0xd6] = AssyInstruction(0xd6, "DEC", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0xe6] = AssyInstruction(0xe6, "INC", AM_ZeroPage); + m_opcodeinfo[0xf6] = AssyInstruction(0xf6, "INC", AM_ZeroPageIndexedWithX); + + m_opcodeinfo[0x07] = AssyInstruction(0x07, "???", AM_InvalidOp); + m_opcodeinfo[0x17] = AssyInstruction(0x17, "???", AM_InvalidOp); + m_opcodeinfo[0x27] = AssyInstruction(0x27, "???", AM_InvalidOp); + m_opcodeinfo[0x37] = AssyInstruction(0x37, "???", AM_InvalidOp); + m_opcodeinfo[0x47] = AssyInstruction(0x47, "???", AM_InvalidOp); + m_opcodeinfo[0x57] = AssyInstruction(0x57, "???", AM_InvalidOp); + m_opcodeinfo[0x67] = AssyInstruction(0x67, "???", AM_InvalidOp); + m_opcodeinfo[0x77] = AssyInstruction(0x77, "???", AM_InvalidOp); + m_opcodeinfo[0x87] = AssyInstruction(0x87, "???", AM_InvalidOp); + m_opcodeinfo[0x97] = AssyInstruction(0x97, "???", AM_InvalidOp); + m_opcodeinfo[0xa7] = AssyInstruction(0xa7, "???", AM_InvalidOp); + m_opcodeinfo[0xb7] = AssyInstruction(0xb7, "???", AM_InvalidOp); + m_opcodeinfo[0xc7] = AssyInstruction(0xc7, "???", AM_InvalidOp); + m_opcodeinfo[0xd7] = AssyInstruction(0xd7, "???", AM_InvalidOp); + m_opcodeinfo[0xe7] = AssyInstruction(0xe7, "???", AM_InvalidOp); + m_opcodeinfo[0xf7] = AssyInstruction(0xf7, "???", AM_InvalidOp); + + m_opcodeinfo[0x08] = AssyInstruction(0x08, "PHP", AM_Implied); + m_opcodeinfo[0x18] = AssyInstruction(0x18, "CLC", AM_Implied); + m_opcodeinfo[0x28] = AssyInstruction(0x28, "PLP", AM_Implied); + m_opcodeinfo[0x38] = AssyInstruction(0x38, "SEC", AM_Implied); + m_opcodeinfo[0x48] = AssyInstruction(0x48, "PHA", AM_Implied); + m_opcodeinfo[0x58] = AssyInstruction(0x58, "CLI", AM_Implied); + m_opcodeinfo[0x68] = AssyInstruction(0x68, "PLA", AM_Implied); + m_opcodeinfo[0x78] = AssyInstruction(0x78, "SEI", AM_Implied); + m_opcodeinfo[0x88] = AssyInstruction(0x88, "DEY", AM_Implied); + m_opcodeinfo[0x98] = AssyInstruction(0x98, "TYA", AM_Implied); + m_opcodeinfo[0xa8] = AssyInstruction(0xa8, "TAY", AM_Implied); + m_opcodeinfo[0xb8] = AssyInstruction(0xb8, "CLV", AM_Implied); + m_opcodeinfo[0xc8] = AssyInstruction(0xc8, "INY", AM_Implied); + m_opcodeinfo[0xd8] = AssyInstruction(0xd8, "CLD", AM_Implied); + m_opcodeinfo[0xe8] = AssyInstruction(0xe8, "INX", AM_Implied); + m_opcodeinfo[0xf8] = AssyInstruction(0xf8, "SED", AM_Implied); + + m_opcodeinfo[0x09] = AssyInstruction(0x09, "ORA", AM_Immediate); + m_opcodeinfo[0x19] = AssyInstruction(0x19, "ORA", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x29] = AssyInstruction(0x29, "AND", AM_Immediate); + m_opcodeinfo[0x39] = AssyInstruction(0x39, "AND", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x49] = AssyInstruction(0x49, "EOR", AM_Immediate); + m_opcodeinfo[0x59] = AssyInstruction(0x59, "EOR", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x69] = AssyInstruction(0x69, "ADC", AM_Immediate); + m_opcodeinfo[0x79] = AssyInstruction(0x79, "ADC", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x89] = AssyInstruction(0x89, "BIT", AM_Immediate); //65C02 + m_opcodeinfo[0x99] = AssyInstruction(0x99, "STA", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xa9] = AssyInstruction(0xa9, "LDA", AM_Immediate); + m_opcodeinfo[0xb9] = AssyInstruction(0xb9, "LDA", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xc9] = AssyInstruction(0xc9, "CMP", AM_Immediate); + m_opcodeinfo[0xd9] = AssyInstruction(0xd9, "CMP", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xe9] = AssyInstruction(0xe9, "SBC", AM_Immediate); + m_opcodeinfo[0xf9] = AssyInstruction(0xf9, "SBC", AM_AbsoluteIndexedWithY); + + m_opcodeinfo[0x0a] = AssyInstruction(0x0a, "ASL", AM_Accumulator); + m_opcodeinfo[0x1a] = AssyInstruction(0x1a, "INA", AM_Accumulator); //65C02 + m_opcodeinfo[0x2a] = AssyInstruction(0x2a, "ROL", AM_Accumulator); + m_opcodeinfo[0x3a] = AssyInstruction(0x3a, "DEC", AM_Accumulator); //65C02 + m_opcodeinfo[0x4a] = AssyInstruction(0x4a, "LSR", AM_Accumulator); + m_opcodeinfo[0x5a] = AssyInstruction(0x5a, "PHY", AM_Implied);//65C02 + m_opcodeinfo[0x6a] = AssyInstruction(0x6a, "ROR", AM_Accumulator); + m_opcodeinfo[0x7a] = AssyInstruction(0x7a, "PLY", AM_Implied);//65C02 + m_opcodeinfo[0x8a] = AssyInstruction(0x8a, "TXA", AM_Implied); + m_opcodeinfo[0x9a] = AssyInstruction(0x9a, "TXS", AM_Implied); + m_opcodeinfo[0xaa] = AssyInstruction(0xaa, "TAX", AM_Implied); + m_opcodeinfo[0xba] = AssyInstruction(0xba, "TSX", AM_Implied); + m_opcodeinfo[0xca] = AssyInstruction(0xca, "DEX", AM_Implied); + m_opcodeinfo[0xda] = AssyInstruction(0xda, "PHX", AM_Implied);//65C02 + m_opcodeinfo[0xea] = AssyInstruction(0xea, "NOP", AM_Implied); + m_opcodeinfo[0xfa] = AssyInstruction(0xfa, "PLX", AM_Implied);//65C02 + + m_opcodeinfo[0x0b] = AssyInstruction(0x0b, "???", AM_InvalidOp); + m_opcodeinfo[0x1b] = AssyInstruction(0x1b, "???", AM_InvalidOp); + m_opcodeinfo[0x2b] = AssyInstruction(0x2b, "???", AM_InvalidOp); + m_opcodeinfo[0x3b] = AssyInstruction(0x3b, "???", AM_InvalidOp); + m_opcodeinfo[0x4b] = AssyInstruction(0x4b, "???", AM_InvalidOp); + m_opcodeinfo[0x5b] = AssyInstruction(0x5b, "???", AM_InvalidOp); + m_opcodeinfo[0x6b] = AssyInstruction(0x6b, "???", AM_InvalidOp); + m_opcodeinfo[0x7b] = AssyInstruction(0x7b, "???", AM_InvalidOp); + m_opcodeinfo[0x8b] = AssyInstruction(0x8b, "???", AM_InvalidOp); + m_opcodeinfo[0x9b] = AssyInstruction(0x9b, "???", AM_InvalidOp); + m_opcodeinfo[0xab] = AssyInstruction(0xab, "???", AM_InvalidOp); + m_opcodeinfo[0xbb] = AssyInstruction(0xbb, "???", AM_InvalidOp); + m_opcodeinfo[0xcb] = AssyInstruction(0xcb, "???", AM_InvalidOp); + m_opcodeinfo[0xdb] = AssyInstruction(0xdb, "???", AM_InvalidOp); + m_opcodeinfo[0xeb] = AssyInstruction(0xeb, "???", AM_InvalidOp); + m_opcodeinfo[0xfb] = AssyInstruction(0xfb, "???", AM_InvalidOp); + + m_opcodeinfo[0x0c] = AssyInstruction(0x0c, "TSB", AM_Absolute); //65C02 + m_opcodeinfo[0x1c] = AssyInstruction(0x1c, "TRB", AM_Absolute); //65C02 + m_opcodeinfo[0x2c] = AssyInstruction(0x2c, "BIT", AM_Absolute); + m_opcodeinfo[0x3c] = AssyInstruction(0x3c, "BIT", AM_AbsoluteIndexedWithX); //65C02 + m_opcodeinfo[0x4c] = AssyInstruction(0x4c, "JMP", AM_Absolute); + m_opcodeinfo[0x5c] = AssyInstruction(0x5c, "???", AM_InvalidOp); + m_opcodeinfo[0x6c] = AssyInstruction(0x6c, "JMP", AM_AbsoluteIndirect); + m_opcodeinfo[0x7c] = AssyInstruction(0x7c, "JMP", AM_AbsoluteIndexedIndirect); //65C02 + m_opcodeinfo[0x8c] = AssyInstruction(0x8c, "STY", AM_Absolute); + m_opcodeinfo[0x9c] = AssyInstruction(0x9c, "STZ", AM_Absolute); + m_opcodeinfo[0xac] = AssyInstruction(0xac, "LDY", AM_Absolute); + m_opcodeinfo[0xbc] = AssyInstruction(0xbc, "LDY", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xcc] = AssyInstruction(0xcc, "CPY", AM_Absolute); + m_opcodeinfo[0xdc] = AssyInstruction(0xdc, "???", AM_InvalidOp); + m_opcodeinfo[0xec] = AssyInstruction(0xec, "CPX", AM_Absolute); + m_opcodeinfo[0xfc] = AssyInstruction(0xfc, "???", AM_InvalidOp); + + m_opcodeinfo[0x0d] = AssyInstruction(0x0d, "ORA", AM_Absolute); + m_opcodeinfo[0x1d] = AssyInstruction(0x1d, "ORA", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x2d] = AssyInstruction(0x2d, "AND", AM_Absolute); + m_opcodeinfo[0x3d] = AssyInstruction(0x3d, "AND", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x4d] = AssyInstruction(0x4d, "EOR", AM_Absolute); + m_opcodeinfo[0x5d] = AssyInstruction(0x5d, "EOR", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x6d] = AssyInstruction(0x6d, "ADC", AM_Absolute); + m_opcodeinfo[0x7d] = AssyInstruction(0x7d, "ADC", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x8d] = AssyInstruction(0x8d, "STA", AM_Absolute); + m_opcodeinfo[0x9d] = AssyInstruction(0x9d, "STA", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xad] = AssyInstruction(0xad, "LDA", AM_Absolute); + m_opcodeinfo[0xbd] = AssyInstruction(0xbd, "LDA", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xcd] = AssyInstruction(0xcd, "CMP", AM_Absolute); + m_opcodeinfo[0xdd] = AssyInstruction(0xdd, "CMP", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xed] = AssyInstruction(0xed, "SBC", AM_Absolute); + m_opcodeinfo[0xfd] = AssyInstruction(0xfd, "SBC", AM_AbsoluteIndexedWithX); + + m_opcodeinfo[0x0e] = AssyInstruction(0x0e, "ASL", AM_Absolute); + m_opcodeinfo[0x1e] = AssyInstruction(0x1e, "ASL", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x2e] = AssyInstruction(0x2e, "ROL", AM_Absolute); + m_opcodeinfo[0x3e] = AssyInstruction(0x3e, "ROL", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x4e] = AssyInstruction(0x4e, "LSR", AM_Absolute); + m_opcodeinfo[0x5e] = AssyInstruction(0x5e, "LSR", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x6e] = AssyInstruction(0x6e, "ROR", AM_Absolute); + m_opcodeinfo[0x7e] = AssyInstruction(0x7e, "ROR", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x8e] = AssyInstruction(0x8e, "STX", AM_Absolute); + m_opcodeinfo[0x9e] = AssyInstruction(0x9e, "STZ", AM_AbsoluteIndexedWithX); //65C02 + m_opcodeinfo[0xae] = AssyInstruction(0xae, "LDX", AM_Absolute); + m_opcodeinfo[0xbe] = AssyInstruction(0xbe, "LDX", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xce] = AssyInstruction(0xce, "DEC", AM_Absolute); + m_opcodeinfo[0xde] = AssyInstruction(0xde, "DEC", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xee] = AssyInstruction(0xee, "INC", AM_Absolute); + m_opcodeinfo[0xfe] = AssyInstruction(0xfe, "INC", AM_AbsoluteIndexedWithX); + + m_opcodeinfo[0x0f] = AssyInstruction(0x0f, "???", AM_InvalidOp); + m_opcodeinfo[0x1f] = AssyInstruction(0x1f, "???", AM_InvalidOp); + m_opcodeinfo[0x2f] = AssyInstruction(0x2f, "???", AM_InvalidOp); + m_opcodeinfo[0x3f] = AssyInstruction(0x3f, "???", AM_InvalidOp); + m_opcodeinfo[0x4f] = AssyInstruction(0x4f, "???", AM_InvalidOp); + m_opcodeinfo[0x5f] = AssyInstruction(0x5f, "???", AM_InvalidOp); + m_opcodeinfo[0x6f] = AssyInstruction(0x6f, "???", AM_InvalidOp); + m_opcodeinfo[0x7f] = AssyInstruction(0x7f, "???", AM_InvalidOp); + m_opcodeinfo[0x8f] = AssyInstruction(0x8f, "???", AM_InvalidOp); + m_opcodeinfo[0x9f] = AssyInstruction(0x9f, "???", AM_InvalidOp); + m_opcodeinfo[0xaf] = AssyInstruction(0xaf, "???", AM_InvalidOp); + m_opcodeinfo[0xbf] = AssyInstruction(0xbf, "???", AM_InvalidOp); + m_opcodeinfo[0xcf] = AssyInstruction(0xcf, "???", AM_InvalidOp); + m_opcodeinfo[0xdf] = AssyInstruction(0xdf, "???", AM_InvalidOp); + m_opcodeinfo[0xef] = AssyInstruction(0xef, "???", AM_InvalidOp); + m_opcodeinfo[0xff] = AssyInstruction(0xff, "???", AM_InvalidOp); + +#ifdef UNUSED_OPCODES + m_opcodeinfo[0x00] = AssyInstruction(0x00, "BRK", AM_Implied); + m_opcodeinfo[0x10] = AssyInstruction(0x10, "BPL", AM_ProgramCounterRelative); + m_opcodeinfo[0x20] = AssyInstruction(0x20, "JSR", AM_Absolute); + m_opcodeinfo[0x30] = AssyInstruction(0x30, "BMI", AM_ProgramCounterRelative); + m_opcodeinfo[0x40] = AssyInstruction(0x40, "RTI", AM_Implied); + m_opcodeinfo[0x50] = AssyInstruction(0x50, "BVC", AM_ProgramCounterRelative); + m_opcodeinfo[0x60] = AssyInstruction(0x60, "RTS", AM_Implied); + m_opcodeinfo[0x70] = AssyInstruction(0x70, "BVS", AM_ProgramCounterRelative); + m_opcodeinfo[0x80] = AssyInstruction(0x80, "nop", AM_ZeroPage); + m_opcodeinfo[0x90] = AssyInstruction(0x90, "BCC", AM_ProgramCounterRelative); + m_opcodeinfo[0xa0] = AssyInstruction(0xa0, "LDY", AM_Immediate); + m_opcodeinfo[0xb0] = AssyInstruction(0xb0, "BCC", AM_ProgramCounterRelative); + m_opcodeinfo[0xc0] = AssyInstruction(0xc0, "LDY", AM_Immediate); + m_opcodeinfo[0xd0] = AssyInstruction(0xd0, "BCS", AM_ProgramCounterRelative); + m_opcodeinfo[0xe0] = AssyInstruction(0xe0, "CPX", AM_Immediate); + m_opcodeinfo[0xf0] = AssyInstruction(0xf0, "BEQ", AM_ProgramCounterRelative); + + m_opcodeinfo[0x01] = AssyInstruction(0x01, "ORA", AM_AbsoluteIndexedIndirect); + m_opcodeinfo[0x11] = AssyInstruction(0x11, "ORA", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x21] = AssyInstruction(0x21, "AND", AM_AbsoluteIndexedIndirect); + m_opcodeinfo[0x31] = AssyInstruction(0x31, "AND", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x41] = AssyInstruction(0x41, "EOR", AM_AbsoluteIndexedIndirect); + m_opcodeinfo[0x51] = AssyInstruction(0x51, "EOR", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x61] = AssyInstruction(0x61, "ADC", AM_AbsoluteIndexedIndirect); + m_opcodeinfo[0x71] = AssyInstruction(0x71, "ADC", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x81] = AssyInstruction(0x81, "STA", AM_AbsoluteIndexedIndirect); + m_opcodeinfo[0x91] = AssyInstruction(0x91, "STA", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xa1] = AssyInstruction(0xa1, "LDA", AM_AbsoluteIndexedIndirect); + m_opcodeinfo[0xb1] = AssyInstruction(0xb1, "LDA", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xc1] = AssyInstruction(0xc1, "CMP", AM_AbsoluteIndexedIndirect); + m_opcodeinfo[0xd1] = AssyInstruction(0xd1, "CMP", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xe1] = AssyInstruction(0xe1, "SBC", AM_AbsoluteIndexedIndirect); + m_opcodeinfo[0xf1] = AssyInstruction(0xff, "SBC", AM_AbsoluteIndexedWithY); + + m_opcodeinfo[0x02] = AssyInstruction(0x02, "halt", AM_Immediate); + m_opcodeinfo[0x12] = AssyInstruction(0x12, "asl-ora", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0x22] = AssyInstruction(0x22, "and", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x32] = AssyInstruction(0x32, "halt", AM_Immediate); + m_opcodeinfo[0x42] = AssyInstruction(0x42, "halt", AM_Immediate); + m_opcodeinfo[0x52] = AssyInstruction(0x52, "halt", AM_Immediate); + m_opcodeinfo[0x62] = AssyInstruction(0x62, "halt", AM_Immediate); + m_opcodeinfo[0x72] = AssyInstruction(0x72, "halt", AM_Immediate); + m_opcodeinfo[0x82] = AssyInstruction(0x82, "halt", AM_Immediate); + m_opcodeinfo[0x92] = AssyInstruction(0x92, "halt", AM_Immediate); + m_opcodeinfo[0xa2] = AssyInstruction(0xa2, "LDX", AM_Immediate); + m_opcodeinfo[0xb2] = AssyInstruction(0xb2, "halt", AM_Immediate); + m_opcodeinfo[0xc2] = AssyInstruction(0xc2, "halt", AM_Immediate); + m_opcodeinfo[0xd2] = AssyInstruction(0xd2, "halt", AM_Immediate); + m_opcodeinfo[0xe2] = AssyInstruction(0xe2, "halt", AM_Immediate); + m_opcodeinfo[0xf2] = AssyInstruction(0xf2, "halt", AM_Immediate); + + m_opcodeinfo[0x03] = AssyInstruction(0x03, "asl/ora", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0x13] = AssyInstruction(0x13, "asl/ora", AM_ZeroPageIndirect); + m_opcodeinfo[0x23] = AssyInstruction(0x23, "rol/and", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0x33] = AssyInstruction(0x33, "rol/and", AM_ZeroPageIndexedWithY); + m_opcodeinfo[0x43] = AssyInstruction(0x43, "lsr/eor", AM_ZeroPage); + m_opcodeinfo[0x53] = AssyInstruction(0x53, "lsr/eor", AM_ZeroPageIndirectIndexedWithY); + m_opcodeinfo[0x63] = AssyInstruction(0x63, "ror/adc", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0x73] = AssyInstruction(0x73, "ror/adc", AM_ZeroPageIndirectIndexedWithY); + m_opcodeinfo[0x83] = AssyInstruction(0x83, "sta/stx", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0x93] = AssyInstruction(0x93, "sta/stx", AM_ZeroPageIndirectIndexedWithY); + m_opcodeinfo[0xa3] = AssyInstruction(0xa3, "lda/ldx", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0xb3] = AssyInstruction(0xb3, "lda/ldx", AM_ZeroPageIndirectIndexedWithY); + m_opcodeinfo[0xc3] = AssyInstruction(0xc3, "dec/cmp", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0xd3] = AssyInstruction(0xd3, "dec/cmp", AM_ZeroPageIndirectIndexedWithY); + m_opcodeinfo[0xe3] = AssyInstruction(0xe3, "inc/sbc", AM_ZeroPageIndexedIndirect); + m_opcodeinfo[0xf3] = AssyInstruction(0xf3, "inc/sbc", AM_ZeroPageIndirectIndexedWithY); + + m_opcodeinfo[0x04] = AssyInstruction(0x04, "nop", AM_ZeroPage); + m_opcodeinfo[0x14] = AssyInstruction(0x14, "nop", AM_ZeroPage); + m_opcodeinfo[0x24] = AssyInstruction(0x24, "BIT", AM_ZeroPage); + m_opcodeinfo[0x34] = AssyInstruction(0x34, "nop", AM_ZeroPage); + m_opcodeinfo[0x44] = AssyInstruction(0x44, "nop", AM_ZeroPage); + m_opcodeinfo[0x54] = AssyInstruction(0x54, "nop", AM_ZeroPage); + m_opcodeinfo[0x64] = AssyInstruction(0x64, "nop", AM_ZeroPage); + m_opcodeinfo[0x74] = AssyInstruction(0x74, "nop", AM_ZeroPage); + m_opcodeinfo[0x84] = AssyInstruction(0x84, "STY", AM_ZeroPage); + m_opcodeinfo[0x94] = AssyInstruction(0x94, "STY", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0xa4] = AssyInstruction(0xa4, "nop", AM_ZeroPage); + m_opcodeinfo[0xb4] = AssyInstruction(0xb4, "LDY", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0xc4] = AssyInstruction(0xc4, "CPY", AM_ZeroPage); + m_opcodeinfo[0xd4] = AssyInstruction(0xd4, "nop", AM_ZeroPage); + m_opcodeinfo[0xe4] = AssyInstruction(0xe4, "CPX", AM_ZeroPage); + m_opcodeinfo[0xf4] = AssyInstruction(0xf4, "nop", AM_ZeroPage); + + m_opcodeinfo[0x05] = AssyInstruction(0x05, "ORA", AM_ZeroPage); + m_opcodeinfo[0x15] = AssyInstruction(0x15, "ORA", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x25] = AssyInstruction(0x25, "AND", AM_ZeroPage); + m_opcodeinfo[0x35] = AssyInstruction(0x35, "AND", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x45] = AssyInstruction(0x45, "EOR", AM_ZeroPage); + m_opcodeinfo[0x55] = AssyInstruction(0x55, "EOR", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x65] = AssyInstruction(0x65, "ADC", AM_ZeroPage); + m_opcodeinfo[0x75] = AssyInstruction(0x75, "ADC", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x85] = AssyInstruction(0x85, "STA", AM_ZeroPage); + m_opcodeinfo[0x95] = AssyInstruction(0x95, "STA", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0xa5] = AssyInstruction(0xa5, "LDA", AM_ZeroPage); + m_opcodeinfo[0xb5] = AssyInstruction(0xb5, "LDA", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0xc5] = AssyInstruction(0xc5, "CMP", AM_ZeroPage); + m_opcodeinfo[0xd5] = AssyInstruction(0xd5, "CMP", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0xe5] = AssyInstruction(0xe5, "SEC", AM_ZeroPage); + m_opcodeinfo[0xf5] = AssyInstruction(0xf5, "SEC", AM_ZeroPageIndexedWithX); + + m_opcodeinfo[0x06] = AssyInstruction(0x06, "ASL", AM_ZeroPage); + m_opcodeinfo[0x16] = AssyInstruction(0x16, "ASL", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x26] = AssyInstruction(0x26, "ROL", AM_ZeroPage); + m_opcodeinfo[0x36] = AssyInstruction(0x36, "ROL", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x46] = AssyInstruction(0x46, "LSR", AM_ZeroPage); + m_opcodeinfo[0x56] = AssyInstruction(0x56, "LSR", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x66] = AssyInstruction(0x66, "ROR", AM_ZeroPage); + m_opcodeinfo[0x76] = AssyInstruction(0x76, "ROR", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x86] = AssyInstruction(0x86, "STX", AM_ZeroPage); + m_opcodeinfo[0x96] = AssyInstruction(0x96, "STX", AM_ZeroPageIndexedWithY); + m_opcodeinfo[0xa6] = AssyInstruction(0xa6, "LDX", AM_ZeroPage); + m_opcodeinfo[0xb6] = AssyInstruction(0xb6, "LDX", AM_ZeroPageIndexedWithY); + m_opcodeinfo[0xc6] = AssyInstruction(0xc6, "DEC", AM_ZeroPage); + m_opcodeinfo[0xd6] = AssyInstruction(0xd6, "DEC", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0xe6] = AssyInstruction(0xe6, "INC", AM_ZeroPage); + m_opcodeinfo[0xf6] = AssyInstruction(0xf6, "INC", AM_ZeroPageIndexedWithX); + + m_opcodeinfo[0x07] = AssyInstruction(0x07, "asl/ora", AM_ZeroPage); + m_opcodeinfo[0x17] = AssyInstruction(0x17, "asl/ora", AM_ZeroPageIndirectIndexedWithY); + m_opcodeinfo[0x27] = AssyInstruction(0x27, "rol/and", AM_ZeroPage); + m_opcodeinfo[0x37] = AssyInstruction(0x37, "rol/and", AM_ZeroPageIndexedWithX); + m_opcodeinfo[0x47] = AssyInstruction(0x47, "lsr/eor", AM_ZeroPage); + m_opcodeinfo[0x57] = AssyInstruction(0x57, "lsr/eor", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x67] = AssyInstruction(0x67, "ror/adc", AM_ZeroPage); + m_opcodeinfo[0x77] = AssyInstruction(0x77, "ror/adc", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x87] = AssyInstruction(0x87, "sta/stx", AM_ZeroPage); + m_opcodeinfo[0x97] = AssyInstruction(0x97, "sta/stx", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xa7] = AssyInstruction(0xa7, "lda/ldx", AM_ZeroPage); + m_opcodeinfo[0xb7] = AssyInstruction(0xb7, "ldx/ldx", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xc7] = AssyInstruction(0xc7, "dec/cmp", AM_ZeroPage); + m_opcodeinfo[0xd7] = AssyInstruction(0xd7, "dec/cmp", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xe7] = AssyInstruction(0xe7, "inc/sbc", AM_ZeroPage); + m_opcodeinfo[0xf7] = AssyInstruction(0xf7, "inc/sbc", AM_AbsoluteIndexedWithX); + + m_opcodeinfo[0x08] = AssyInstruction(0x08, "PHP", AM_Implied); + m_opcodeinfo[0x18] = AssyInstruction(0x18, "CLC", AM_Implied); + m_opcodeinfo[0x28] = AssyInstruction(0x28, "PLP", AM_Implied); + m_opcodeinfo[0x38] = AssyInstruction(0x38, "SEC", AM_Implied); + m_opcodeinfo[0x48] = AssyInstruction(0x48, "PHA", AM_Implied); + m_opcodeinfo[0x58] = AssyInstruction(0x58, "CLI", AM_Implied); + m_opcodeinfo[0x68] = AssyInstruction(0x68, "PLA", AM_Implied); + m_opcodeinfo[0x78] = AssyInstruction(0x78, "SEI", AM_Implied); + m_opcodeinfo[0x88] = AssyInstruction(0x88, "DEY", AM_Implied); + m_opcodeinfo[0x98] = AssyInstruction(0x98, "TYA", AM_Implied); + m_opcodeinfo[0xa8] = AssyInstruction(0xa8, "TAY", AM_Implied); + m_opcodeinfo[0xb8] = AssyInstruction(0xb8, "CLV", AM_Implied); + m_opcodeinfo[0xc8] = AssyInstruction(0xc8, "INY", AM_Implied); + m_opcodeinfo[0xd8] = AssyInstruction(0xd8, "CLD", AM_Implied); + m_opcodeinfo[0xe8] = AssyInstruction(0xe8, "INX", AM_Implied); + m_opcodeinfo[0xf8] = AssyInstruction(0xf8, "SED", AM_Implied); + + m_opcodeinfo[0x09] = AssyInstruction(0x09, "ORA", AM_Immediate); + m_opcodeinfo[0x19] = AssyInstruction(0x19, "ORA", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x29] = AssyInstruction(0x29, "AND", AM_Immediate); + m_opcodeinfo[0x39] = AssyInstruction(0x39, "AND", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x49] = AssyInstruction(0x49, "EOR", AM_Immediate); + m_opcodeinfo[0x59] = AssyInstruction(0x59, "EOR", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x69] = AssyInstruction(0x69, "ADC", AM_Immediate); + m_opcodeinfo[0x79] = AssyInstruction(0x79, "ADC", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x89] = AssyInstruction(0x89, "nop", AM_ZeroPage); + m_opcodeinfo[0x99] = AssyInstruction(0x99, "STA", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xa9] = AssyInstruction(0xa9, "LDA", AM_Immediate); + m_opcodeinfo[0xb9] = AssyInstruction(0xb9, "LDA", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xc9] = AssyInstruction(0xc9, "CMP", AM_Immediate); + m_opcodeinfo[0xd9] = AssyInstruction(0xd9, "CMP", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xe9] = AssyInstruction(0xe9, "SBC", AM_Immediate); + m_opcodeinfo[0xf9] = AssyInstruction(0xf9, "SBC", AM_AbsoluteIndexedWithY); + + m_opcodeinfo[0x0a] = AssyInstruction(0x0a, "ASL", AM_Accumulator); + m_opcodeinfo[0x1a] = AssyInstruction(0x1a, "nop", AM_Implied); + m_opcodeinfo[0x2a] = AssyInstruction(0x2a, "ROL", AM_Accumulator); + m_opcodeinfo[0x3a] = AssyInstruction(0x3a, "nop", AM_Implied); + m_opcodeinfo[0x4a] = AssyInstruction(0x4a, "LSR", AM_Accumulator); + m_opcodeinfo[0x5a] = AssyInstruction(0x5a, "nop", AM_Implied); + m_opcodeinfo[0x6a] = AssyInstruction(0x6a, "ROR", AM_Accumulator); + m_opcodeinfo[0x7a] = AssyInstruction(0x7a, "nop", AM_Implied); + m_opcodeinfo[0x8a] = AssyInstruction(0x8a, "TXA", AM_Implied); + m_opcodeinfo[0x9a] = AssyInstruction(0x9a, "TXS", AM_Implied); + m_opcodeinfo[0xaa] = AssyInstruction(0xaa, "TAX", AM_Implied); + m_opcodeinfo[0xba] = AssyInstruction(0xba, "TSX", AM_Implied); + m_opcodeinfo[0xca] = AssyInstruction(0xca, "DEX", AM_Implied); + m_opcodeinfo[0xda] = AssyInstruction(0xda, "nop", AM_Implied); + m_opcodeinfo[0xea] = AssyInstruction(0xea, "NOP", AM_Implied); + m_opcodeinfo[0xfa] = AssyInstruction(0xfa, "nop", AM_Implied); + + m_opcodeinfo[0x0b] = AssyInstruction(0x0b, "and/mov bit7->Cy", AM_Immediate); + m_opcodeinfo[0x1b] = AssyInstruction(0x1b, "asl/ora", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x2b] = AssyInstruction(0x2b, "and/mov bit7->Cy", AM_Immediate); + m_opcodeinfo[0x3b] = AssyInstruction(0x3b, "asl/ora", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x4b] = AssyInstruction(0x4b, "and/lsr A", AM_Immediate); + m_opcodeinfo[0x5b] = AssyInstruction(0x5b, "lsr/eor", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x6b] = AssyInstruction(0x6b, "and/ror A", AM_Immediate); + m_opcodeinfo[0x7b] = AssyInstruction(0x7b, "ror/adc", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0x8b] = AssyInstruction(0x8b, "txa/and", AM_Immediate); + m_opcodeinfo[0x9b] = AssyInstruction(0x9b, "sta/stx", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xab] = AssyInstruction(0xab, "lda/ldx", AM_Implied); + m_opcodeinfo[0xbb] = AssyInstruction(0xbb, "lda/ldx", AM_Implied); + m_opcodeinfo[0xcb] = AssyInstruction(0xcb, "sbx", AM_Immediate); + m_opcodeinfo[0xdb] = AssyInstruction(0xdb, "dec/cmp", AM_Absolute); + m_opcodeinfo[0xeb] = AssyInstruction(0xeb, "sbc", AM_Immediate); + m_opcodeinfo[0xfb] = AssyInstruction(0xfb, "inc/sbc", AM_Absolute); + + m_opcodeinfo[0x0c] = AssyInstruction(0x0c, "nop", AM_Absolute); + m_opcodeinfo[0x1c] = AssyInstruction(0x1c, "nop", AM_Absolute); + m_opcodeinfo[0x2c] = AssyInstruction(0x2c, "BIT", AM_Absolute); + m_opcodeinfo[0x3c] = AssyInstruction(0x3c, "nop", AM_Absolute); + m_opcodeinfo[0x4c] = AssyInstruction(0x4c, "JMP", AM_Absolute); + m_opcodeinfo[0x5c] = AssyInstruction(0x5c, "nop", AM_Absolute); + m_opcodeinfo[0x6c] = AssyInstruction(0x6c, "JMP", AM_AbsoluteIndirect); + m_opcodeinfo[0x7c] = AssyInstruction(0x7c, "nop", AM_Absolute); + m_opcodeinfo[0x8c] = AssyInstruction(0x8c, "STY", AM_Absolute); + m_opcodeinfo[0x9c] = AssyInstruction(0x9c, "sta/stx", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xac] = AssyInstruction(0xac, "LDY", AM_Absolute); + m_opcodeinfo[0xbc] = AssyInstruction(0xbc, "LDY", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xcc] = AssyInstruction(0xcc, "CPY", AM_Absolute); + m_opcodeinfo[0xdc] = AssyInstruction(0xdc, "???", AM_InvalidOp); + m_opcodeinfo[0xec] = AssyInstruction(0xec, "CPX", AM_Absolute); + m_opcodeinfo[0xfc] = AssyInstruction(0xfc, "???", AM_InvalidOp); + + m_opcodeinfo[0x0d] = AssyInstruction(0x0d, "ORA", AM_Absolute); + m_opcodeinfo[0x1d] = AssyInstruction(0x1d, "ORA", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x2d] = AssyInstruction(0x2d, "AND", AM_Absolute); + m_opcodeinfo[0x3d] = AssyInstruction(0x3d, "AND", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x4d] = AssyInstruction(0x4d, "EOR", AM_Absolute); + m_opcodeinfo[0x5d] = AssyInstruction(0x5d, "EOR", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x6d] = AssyInstruction(0x6d, "ADC", AM_Absolute); + m_opcodeinfo[0x7d] = AssyInstruction(0x7d, "ADC", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x8d] = AssyInstruction(0x8d, "STA", AM_Absolute); + m_opcodeinfo[0x9d] = AssyInstruction(0x9d, "STA", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xad] = AssyInstruction(0xad, "LDA", AM_Absolute); + m_opcodeinfo[0xbd] = AssyInstruction(0xbd, "LDA", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xcd] = AssyInstruction(0xcd, "CMP", AM_Absolute); + m_opcodeinfo[0xdd] = AssyInstruction(0xdd, "CMP", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xed] = AssyInstruction(0xed, "SBC", AM_Absolute); + m_opcodeinfo[0xfd] = AssyInstruction(0xfd, "SBC", AM_AbsoluteIndexedWithX); + + m_opcodeinfo[0x0e] = AssyInstruction(0x0e, "ASL", AM_Absolute); + m_opcodeinfo[0x1e] = AssyInstruction(0x1e, "ASL", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x2e] = AssyInstruction(0x2e, "ROL", AM_Absolute); + m_opcodeinfo[0x3e] = AssyInstruction(0x3e, "ROL", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x4e] = AssyInstruction(0x4e, "LSR", AM_Absolute); + m_opcodeinfo[0x5e] = AssyInstruction(0x5e, "LSR", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x6e] = AssyInstruction(0x6e, "ROR", AM_Absolute); + m_opcodeinfo[0x7e] = AssyInstruction(0x7e, "ROR", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x8e] = AssyInstruction(0x8e, "STX", AM_Absolute); + m_opcodeinfo[0x9e] = AssyInstruction(0x9e, "sta/stx", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xae] = AssyInstruction(0xae, "LDX", AM_Absolute); + m_opcodeinfo[0xbe] = AssyInstruction(0xbe, "LDX", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xce] = AssyInstruction(0xce, "DEC", AM_Absolute); + m_opcodeinfo[0xde] = AssyInstruction(0xde, "DEC", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xee] = AssyInstruction(0xee, "INC", AM_Absolute); + m_opcodeinfo[0xfe] = AssyInstruction(0xfe, "INC", AM_AbsoluteIndexedWithX); + + m_opcodeinfo[0x0f] = AssyInstruction(0x0f, "asl/ora", AM_Absolute); + m_opcodeinfo[0x1f] = AssyInstruction(0x1f, "asl/ora", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x2f] = AssyInstruction(0x2f, "rol/and", AM_Absolute); + m_opcodeinfo[0x3f] = AssyInstruction(0x3f, "rol/and", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x4f] = AssyInstruction(0x4f, "lsr/eor", AM_Absolute); + m_opcodeinfo[0x5f] = AssyInstruction(0x5f, "lsr/eor", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x6f] = AssyInstruction(0x6f, "ror/adc", AM_Absolute); + m_opcodeinfo[0x7f] = AssyInstruction(0x7f, "ror/adc", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0x8f] = AssyInstruction(0x8f, "sta/stx", AM_Absolute); + m_opcodeinfo[0x9f] = AssyInstruction(0x9f, "sta/stx", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xaf] = AssyInstruction(0xaf, "lda/ldx", AM_Absolute); + m_opcodeinfo[0xbf] = AssyInstruction(0xbf, "ldx/ldx", AM_AbsoluteIndexedWithY); + m_opcodeinfo[0xcf] = AssyInstruction(0xcf, "dec/cmp", AM_Absolute); + m_opcodeinfo[0xdf] = AssyInstruction(0xdf, "dec/cmp", AM_AbsoluteIndexedWithX); + m_opcodeinfo[0xef] = AssyInstruction(0xef, "inc/sbc", AM_Absolute); + m_opcodeinfo[0xff] = AssyInstruction(0xff, "inc/sbc", AM_AbsoluteIndexedWithX); +#endif + +} + +void Disassembler::setUnknownToData(quint16 from, quint16 to) +{ + for (int idx = from; idx <= to; idx++) + { + if (m_memusagemap[idx].testFlag(Unknown)) + { + m_memusagemap[idx].setFlag(Data); + } + } +} + +AssyInstruction::AssyInstruction(quint8 opcode, QString mnemonic, AddressMode am) { + m_opcode = opcode; + m_mnemonic = mnemonic; + m_addressMode = am; +} + +quint8 AssyInstruction::numArgs() { + switch (m_addressMode) { + case AM_Absolute: + case AM_AbsoluteIndexedIndirect: + case AM_AbsoluteIndexedWithX: + case AM_AbsoluteIndexedWithY: + case AM_AbsoluteIndirect: + return 2; + case AM_ProgramCounterRelative: + case AM_ZeroPage: + case AM_ZeroPageIndirectIndexedWithY: + case AM_ZeroPageIndexedIndirect: + case AM_ZeroPageIndexedWithX: + case AM_ZeroPageIndexedWithY: + case AM_ZeroPageIndirect: + case AM_Immediate: + return 1; + case AM_InvalidOp: + case AM_Implied: + case AM_Accumulator: + default: + return 0; + } +} + +DisassembledItem::DisassembledItem(AssyInstruction instr) { + m_canNotFollow = false; + setInstruction(instr); +} + +void DisassembledItem::setInstruction(AssyInstruction instr) { + m_instruction = instr; + // qDebug() << "Set instruction: " << uint8ToHex(instr.opcode()); + // qDebug() << " Copied instr:" << m_instruction.debugStr(); + if (instr.opcode() == 0x20) { m_is_jsr = true; } + if (instr.opcode() == 0x10) { m_is_branch = true; } // BPL + if (instr.opcode() == 0x30) { m_is_branch = true; } // BMI + if (instr.opcode() == 0x50) { m_is_branch = true; } // BVC + if (instr.opcode() == 0x70) { m_is_branch = true; } // BVS + if (instr.opcode() == 0x90) { m_is_branch = true; } // BCC + if (instr.opcode() == 0xB0) { m_is_branch = true; } // BCS + if (instr.opcode() == 0xD0) { m_is_branch = true; } // BNE + if (instr.opcode() == 0xF0) { m_is_branch = true; } // BEQ + if (instr.opcode() == 0x80) { m_is_jump = true; } // BRA + if (instr.opcode() == 0x4C) { m_is_jump = true; } // JMP a + if (instr.opcode() == 0x6C) { m_is_jump = true; } // JMP (a) + if (instr.opcode() == 0x7C) { m_is_jump = true; } // JMP (a,x) +} + +QString DisassembledItem::disassembledString() { + QString retval = rawDisassembledString(); + if (hasArg()) { + if (retval.contains("_ARG16_")) { + retval.replace("_ARG16_","$"+arg16Str()); + } else if (retval.contains("_ARG8_")) { + retval.replace("_ARG8_","$"+arg8Str()); + } + } + return retval; +} + +void DisassembledItem::init() { + m_address = m_target_address = 0; + m_nextContiguousAddress = 0; + m_nextFlowAddress = 0; + m_is_jump = m_is_branch = m_is_jsr = false; + m_unknown_ta = true; + m_raw_arg = 0; + m_has_arg = false; + m_canNotFollow = false; + m_isInvalidOp = false; + +} diff --git a/src/binaryfile/disassembler.h b/src/binaryfile/disassembler.h index b634238..2f5e1b9 100644 --- a/src/binaryfile/disassembler.h +++ b/src/binaryfile/disassembler.h @@ -1,215 +1,215 @@ -#ifndef DISASSEMBLER_H -#define DISASSEMBLER_H - -#include "MemoryUsageMap.h" -#include "util.h" -#include "JumpLineManager.h" - -#include -#include -#include -#include -#include - - -enum AddressMode { - AM_InvalidOp, - AM_Absolute, // a - AM_AbsoluteIndexedIndirect, // (a,x) - AM_AbsoluteIndexedWithX, // a,x - AM_AbsoluteIndexedWithY, // a,y - AM_AbsoluteIndirect, // (a) - AM_Immediate, // # - AM_Implied, // i - AM_Accumulator, // A - AM_ProgramCounterRelative, // r - AM_ZeroPage, // zp - AM_ZeroPageIndexedIndirect, // (zp,x) - AM_ZeroPageIndexedWithX, // zp,x - AM_ZeroPageIndexedWithY, // zp,y - AM_ZeroPageIndirect, // (zp) - AM_ZeroPageIndirectIndexedWithY // (zp),y -}; -////////////////////////////////////////////////////////////////////////////// - -class AddressStack -{ - public: - AddressStack() { } - - bool push(quint16 address, bool force = false) { - if (force || (!m_stack.contains(address))) - { - qDebug() << " PUSH: " << uint16ToHex(address); - m_stack.push(address); - return true; - } - return false; - } - - bool isEmpty() { return m_stack.isEmpty(); } - quint16 pop() { return m_stack.pop(); } - - private: - QStack m_stack; -}; - -////////////////////////////////////////////////////////////////////////////// - -struct AssyInstruction { - -public: - - AssyInstruction(quint8 opcode = 0x00, QString mnemonic = "???", AddressMode am = AM_InvalidOp); - - AddressMode addressMode() { return m_addressMode; } - - QString mnemonic() { return m_mnemonic; } - - quint8 opcode() { return m_opcode; } - - quint8 numArgs(); - - QString debugStr() { return QString("%1 %2 %3").arg(uint8ToHex(m_opcode)).arg(m_mnemonic).arg(m_addressMode); } - -private: - QString m_mnemonic; - quint8 m_opcode; - AddressMode m_addressMode; -}; -////////////////////////////////////////////////////////////////////////////// - -class DisassembledItem { -public: - DisassembledItem() { init(); } - - DisassembledItem(AssyInstruction instr); - - bool operator<(const DisassembledItem &other) const { return (address() < other.address()); } - - void setInstruction(AssyInstruction instr); - - void setAddress(quint16 add) { m_address = add; } - void setDisassembledString(QString ds) { m_disassembly_text = ds; } - void setHexValues(QByteArray hv) { m_hexvalues = hv; } - void setHexString(QString hs) { m_hexstring = hs; } - void setBranch(bool branch) { m_is_branch = branch; } - void setJump(bool jump) { m_is_jump = jump; } - void setJsr(bool jsr) { m_is_jsr = jsr; } - void setTargetAddress(quint16 ta) { m_unknown_ta = false; m_target_address = ta; } - void setRawArgument(quint16 arg) { m_has_arg = true; m_raw_arg = arg; } - void setCanNotFollow(bool canNotFollow) { m_canNotFollow = canNotFollow; } - void setIsInvalidOp(bool isInvalid) { m_isInvalidOp = isInvalid; } - - AssyInstruction assyInstruction() const { return m_instruction; } - QString rawDisassembledString() const { return m_disassembly_text; } - QString disassembledString(); - quint16 address() const { return m_address; } - QString hexAddress() const { return QString("%1").arg(m_address,4,16,QChar('0')).toUpper(); } - QByteArray hexValues() const { return m_hexvalues; } - QString hexString() const { return m_hexstring; } - bool isBranch() const { return m_is_branch; } - bool isJump() const { return m_is_jump; } - bool isJsr() const { return m_is_jsr; } - bool isReturn() { return (m_instruction.opcode() == 0x60) || m_instruction.opcode() == 0x40; } - bool isBreak() { return (m_instruction.opcode() == 0x00); } - bool isInvalidOp() { return m_isInvalidOp; } - - bool canNotFollow() { return m_canNotFollow; } - - bool stopsProcessing() { - if (isReturn()) qDebug() << "Is Return"; - if (isInvalidOp()) qDebug() << "Is Invalid Op" << uint8ToHex(m_instruction.opcode()); - if (canNotFollow()) qDebug() << "Not following jump"; - if (isBreak()) qDebug() << "Is Break"; - return isBreak() || isInvalidOp() || isReturn() || canNotFollow(); } - - quint16 nextContiguousAddress() { return m_nextContiguousAddress; } - quint16 nextFlowAddress() { return m_nextFlowAddress; } - - void setNextContiguousAddress(quint16 addr) { m_nextContiguousAddress = addr; } - void setNextFlowAddress(quint16 addr) { m_nextFlowAddress = addr; } - - quint16 targetAddress() const { return m_target_address; } - bool hasArg() const { return m_has_arg; } - quint16 arg16() { return m_raw_arg; } - quint8 arg8() { return m_raw_arg % 256; } - QString arg16Str() { return QString("%1").arg(arg16(),4,16,QChar('0')).toUpper(); } - QString arg8Str() { return QString("%1").arg(arg8(),2,16,QChar('0')).toUpper(); } - -private: - void init(); - - quint16 m_address; - quint16 m_nextContiguousAddress; - quint16 m_nextFlowAddress; - quint16 m_target_address; - - QByteArray m_hexvalues; - QString m_disassembly_text; - QString m_hexstring; - bool m_is_branch; - bool m_is_jump; - bool m_is_jsr; - AssyInstruction m_instruction; - bool m_unknown_ta; - quint16 m_raw_arg; - bool m_has_arg; - bool m_isInvalidOp; - bool m_canNotFollow; -}; - - -////////////////////////////////////////////////////////////////////////////// - -class Disassembler -{ -public: - - - - Disassembler(QByteArray memimage); - - enum ProcessorType { - P6502, - P65C02 - }; - - QList disassemble(quint16 from, - quint16 to, - QList entryPoints, - bool processRecursively = true); - - MemoryUsageMap *memoryUsageMap() { return &m_memusagemap; } - - void setUnknownToData(quint16 from, quint16 to); - - QString getMnemonicForOp(quint8 opcode) - { - return m_opcodeinfo[opcode].mnemonic(); - } - - JumpLines getJumpLines() const { return m_jumplines; } - -private: - bool disassembleOp(quint16 address, DisassembledItem &retval, MemoryUsageMap *memuse = Q_NULLPTR); - void makeOpcodeTable(); - - - quint16 m_from; - quint16 m_to; - - QHash m_opcodeinfo; - QByteArray m_memimage; - - AddressStack m_stack; - - MemoryUsageMap m_memusagemap; - - JumpLineManager m_jlm; - - JumpLines m_jumplines; - -}; - -#endif // DISASSEMBLER_H +#ifndef DISASSEMBLER_H +#define DISASSEMBLER_H + +#include "MemoryUsageMap.h" +#include "util.h" +#include "JumpLineManager.h" + +#include +#include +#include +#include +#include + + +enum AddressMode { + AM_InvalidOp, + AM_Absolute, // a + AM_AbsoluteIndexedIndirect, // (a,x) + AM_AbsoluteIndexedWithX, // a,x + AM_AbsoluteIndexedWithY, // a,y + AM_AbsoluteIndirect, // (a) + AM_Immediate, // # + AM_Implied, // i + AM_Accumulator, // A + AM_ProgramCounterRelative, // r + AM_ZeroPage, // zp + AM_ZeroPageIndexedIndirect, // (zp,x) + AM_ZeroPageIndexedWithX, // zp,x + AM_ZeroPageIndexedWithY, // zp,y + AM_ZeroPageIndirect, // (zp) + AM_ZeroPageIndirectIndexedWithY // (zp),y +}; +////////////////////////////////////////////////////////////////////////////// + +class AddressStack +{ + public: + AddressStack() { } + + bool push(quint16 address, bool force = false) { + if (force || (!m_stack.contains(address))) + { + qDebug() << " PUSH: " << uint16ToHex(address); + m_stack.push(address); + return true; + } + return false; + } + + bool isEmpty() { return m_stack.isEmpty(); } + quint16 pop() { return m_stack.pop(); } + + private: + QStack m_stack; +}; + +////////////////////////////////////////////////////////////////////////////// + +struct AssyInstruction { + +public: + + AssyInstruction(quint8 opcode = 0x00, QString mnemonic = "???", AddressMode am = AM_InvalidOp); + + AddressMode addressMode() { return m_addressMode; } + + QString mnemonic() { return m_mnemonic; } + + quint8 opcode() { return m_opcode; } + + quint8 numArgs(); + + QString debugStr() { return QString("%1 %2 %3").arg(uint8ToHex(m_opcode)).arg(m_mnemonic).arg(m_addressMode); } + +private: + QString m_mnemonic; + quint8 m_opcode; + AddressMode m_addressMode; +}; +////////////////////////////////////////////////////////////////////////////// + +class DisassembledItem { +public: + DisassembledItem() { init(); } + + DisassembledItem(AssyInstruction instr); + + bool operator<(const DisassembledItem &other) const { return (address() < other.address()); } + + void setInstruction(AssyInstruction instr); + + void setAddress(quint16 add) { m_address = add; } + void setDisassembledString(QString ds) { m_disassembly_text = ds; } + void setHexValues(QByteArray hv) { m_hexvalues = hv; } + void setHexString(QString hs) { m_hexstring = hs; } + void setBranch(bool branch) { m_is_branch = branch; } + void setJump(bool jump) { m_is_jump = jump; } + void setJsr(bool jsr) { m_is_jsr = jsr; } + void setTargetAddress(quint16 ta) { m_unknown_ta = false; m_target_address = ta; } + void setRawArgument(quint16 arg) { m_has_arg = true; m_raw_arg = arg; } + void setCanNotFollow(bool canNotFollow) { m_canNotFollow = canNotFollow; } + void setIsInvalidOp(bool isInvalid) { m_isInvalidOp = isInvalid; } + + AssyInstruction assyInstruction() const { return m_instruction; } + QString rawDisassembledString() const { return m_disassembly_text; } + QString disassembledString(); + quint16 address() const { return m_address; } + QString hexAddress() const { return QString("%1").arg(m_address,4,16,QChar('0')).toUpper(); } + QByteArray hexValues() const { return m_hexvalues; } + QString hexString() const { return m_hexstring; } + bool isBranch() const { return m_is_branch; } + bool isJump() const { return m_is_jump; } + bool isJsr() const { return m_is_jsr; } + bool isReturn() { return (m_instruction.opcode() == 0x60) || m_instruction.opcode() == 0x40; } + bool isBreak() { return (m_instruction.opcode() == 0x00); } + bool isInvalidOp() { return m_isInvalidOp; } + + bool canNotFollow() { return m_canNotFollow; } + + bool stopsProcessing() { + if (isReturn()) qDebug() << "Is Return"; + if (isInvalidOp()) qDebug() << "Is Invalid Op" << uint8ToHex(m_instruction.opcode()); + if (canNotFollow()) qDebug() << "Not following jump"; + if (isBreak()) qDebug() << "Is Break"; + return isBreak() || isInvalidOp() || isReturn() || canNotFollow(); } + + quint16 nextContiguousAddress() { return m_nextContiguousAddress; } + quint16 nextFlowAddress() { return m_nextFlowAddress; } + + void setNextContiguousAddress(quint16 addr) { m_nextContiguousAddress = addr; } + void setNextFlowAddress(quint16 addr) { m_nextFlowAddress = addr; } + + quint16 targetAddress() const { return m_target_address; } + bool hasArg() const { return m_has_arg; } + quint16 arg16() { return m_raw_arg; } + quint8 arg8() { return m_raw_arg % 256; } + QString arg16Str() { return QString("%1").arg(arg16(),4,16,QChar('0')).toUpper(); } + QString arg8Str() { return QString("%1").arg(arg8(),2,16,QChar('0')).toUpper(); } + +private: + void init(); + + quint16 m_address; + quint16 m_nextContiguousAddress; + quint16 m_nextFlowAddress; + quint16 m_target_address; + + QByteArray m_hexvalues; + QString m_disassembly_text; + QString m_hexstring; + bool m_is_branch; + bool m_is_jump; + bool m_is_jsr; + AssyInstruction m_instruction; + bool m_unknown_ta; + quint16 m_raw_arg; + bool m_has_arg; + bool m_isInvalidOp; + bool m_canNotFollow; +}; + + +////////////////////////////////////////////////////////////////////////////// + +class Disassembler +{ +public: + + + + Disassembler(QByteArray memimage); + + enum ProcessorType { + P6502, + P65C02 + }; + + QList disassemble(quint16 from, + quint16 to, + QList entryPoints, + bool processRecursively = true); + + MemoryUsageMap *memoryUsageMap() { return &m_memusagemap; } + + void setUnknownToData(quint16 from, quint16 to); + + QString getMnemonicForOp(quint8 opcode) + { + return m_opcodeinfo[opcode].mnemonic(); + } + + JumpLines getJumpLines() const { return m_jumplines; } + +private: + bool disassembleOp(quint16 address, DisassembledItem &retval, MemoryUsageMap *memuse = Q_NULLPTR); + void makeOpcodeTable(); + + + quint16 m_from; + quint16 m_to; + + QHash m_opcodeinfo; + QByteArray m_memimage; + + AddressStack m_stack; + + MemoryUsageMap m_memusagemap; + + JumpLineManager m_jlm; + + JumpLines m_jumplines; + +}; + +#endif // DISASSEMBLER_H diff --git a/src/diskfiles/dos33/catalogsector.cxx b/src/diskfiles/dos33/catalogsector.cxx index 372571a..d82a8b3 100644 --- a/src/diskfiles/dos33/catalogsector.cxx +++ b/src/diskfiles/dos33/catalogsector.cxx @@ -1,53 +1,56 @@ -#include "catalogsector.h" -#include "sector.h" - -CatalogSector::CatalogSector(Sector *data) -{ - m_data = data; - - m_next.track = m_data->rawData()[0x01]; - m_next.sector = m_data->rawData()[0x02]; - - for (int idx = 0; idx<7; idx++) - { - FileDescriptiveEntry fde = makeFDE(idx*0x23+0x0B); - if (fde.firstTSListSector != TSPair(0,0)) { - m_fdes.append(fde); - } - } -} - -void CatalogSector::dumpFDEs() { - for (int idx = 0; idx<7; idx++) - { - FileDescriptiveEntry fde = m_fdes[idx]; - if (fde.firstTSListSector != TSPair(0,0)) { - qDebug() << "FDE #"<rawData()[offset + 0x00]; - fde.firstTSListSector.sector = m_data->rawData()[offset + 0x01]; - fde.fileTypeAndFlags = m_data->rawData()[offset + 0x02]; - fde.lengthInSectors = makeWord( m_data->rawData()[offset + 0x21], m_data->rawData()[offset + 0x22]); - for (int idx = 0x03; idx <= 0x20; idx++) { - fde.filename.append(m_data->rawData()[idx+offset]); - } - if (fde.firstTSListSector.track == 0xFF) - { - //TODO: Double check this stuff. applevision.dsk is a good example. - qDebug() << "File" << fde.filename.printable() << "is deleted"; - fde.deleted = true; - qDebug() << fde.filename; - fde.firstTSListSector.track = m_data->rawData()[offset + 0x20]; - qDebug() << " New track: " << (quint8) fde.firstTSListSector.track; - qDebug() << " Sector: " << fde.firstTSListSector.sector; - - } - return fde; -} +#include "catalogsector.h" +#include "sector.h" + +CatalogSector::CatalogSector(Sector *data) +{ + m_data = data; + + m_next.track = m_data->rawData()[0x01]; + m_next.sector = m_data->rawData()[0x02]; + + for (int idx = 0; idx<7; idx++) + { + FileDescriptiveEntry fde = makeFDE(idx*0x23+0x0B); + if (fde.firstTSListSector != TSPair(0,0)) { + m_fdes.append(fde); + } + } +} + +void CatalogSector::dumpFDEs() { + for (int idx = 0; idx<7; idx++) + { + FileDescriptiveEntry fde = m_fdes[idx]; + if (fde.firstTSListSector != TSPair(0,0)) { + qDebug() << "FDE #"<rawData()[offset + 0x00]; + fde.firstTSListSector.sector = m_data->rawData()[offset + 0x01]; + fde.fileTypeAndFlags = m_data->rawData()[offset + 0x02]; + fde.lengthInSectors = makeWord( m_data->rawData()[offset + 0x21], + m_data->rawData()[offset + 0x22]); + + for (int idx = 0x03; idx <= 0x20; idx++) { + fde.filename.append(m_data->rawData()[idx+offset]); + } + + if (fde.firstTSListSector.track == 0xFF) + { + //TODO: Double check this stuff. applevision.dsk is a good example. + qDebug() << "File" << fde.filename.printable() << "is deleted"; + fde.deleted = true; + qDebug() << fde.filename; + fde.firstTSListSector.track = m_data->rawData()[offset + 0x20]; + qDebug() << " New track: " << (quint8) fde.firstTSListSector.track; + qDebug() << " Sector: " << fde.firstTSListSector.sector; + } + + return fde; +} diff --git a/src/diskfiles/dos33/catalogsector.h b/src/diskfiles/dos33/catalogsector.h index b6a8b45..f845e5c 100644 --- a/src/diskfiles/dos33/catalogsector.h +++ b/src/diskfiles/dos33/catalogsector.h @@ -1,45 +1,45 @@ -#ifndef CATALOGSECTOR_H -#define CATALOGSECTOR_H - -#include -#include -#include - -#include "util.h" -#include "applestring.h" -#include "filedescriptiveentry.h" - -class Sector; - - - -class CatalogSector -{ -public: - CatalogSector(Sector *sector); - - FileDescriptiveEntry &getFDE(quint8 number) { - if (number >= m_fdes.length()) { - number = m_fdes.length() - 1; - } - return m_fdes[number]; - } - - QList getFDEs() { return m_fdes; } - - TSPair nextCatalogSector() { return m_next; } - - void dumpFDEs(); - - Sector *getSector() const { return m_data; } - -private: - FileDescriptiveEntry makeFDE(int offset); - -private: - Sector *m_data; - QList m_fdes; - TSPair m_next; -}; - -#endif // CATALOGSECTOR_H +#ifndef CATALOGSECTOR_H +#define CATALOGSECTOR_H + +#include +#include +#include + +#include "util.h" +#include "applestring.h" +#include "filedescriptiveentry.h" + +class Sector; + + + +class CatalogSector +{ +public: + CatalogSector(Sector *sector); + + FileDescriptiveEntry &getFDE(quint8 number) { + if (number >= m_fdes.length()) { + number = m_fdes.length() - 1; + } + return m_fdes[number]; + } + + QList getFDEs() { return m_fdes; } + + TSPair nextCatalogSector() { return m_next; } + + void dumpFDEs(); + + Sector *getSector() const { return m_data; } + +private: + FileDescriptiveEntry makeFDE(int offset); + +private: + Sector *m_data; + QList m_fdes; + TSPair m_next; +}; + +#endif // CATALOGSECTOR_H diff --git a/src/diskfiles/dos33/diskfile.cxx b/src/diskfiles/dos33/diskfile.cxx index 2ffd7e5..ca39687 100644 --- a/src/diskfiles/dos33/diskfile.cxx +++ b/src/diskfiles/dos33/diskfile.cxx @@ -1,181 +1,186 @@ -#include "diskfile.h" - -#include -#include -#include -#include -#include - -#include "tracksectorlist.h" -#include "applesoftfile.h" -#include "binaryfile.h" -#include "relocatablefile.h" -#include "textfile.h" - -DiskFile::DiskFile(QString filename) -{ - if (!filename.isEmpty()) - { - read(filename); - } -} - -DiskFile::~DiskFile() -{ - foreach (GenericFile *file, m_files) - { - delete file; - } -} - -bool DiskFile::read(QString filename) -{ - m_fullImageName = filename; - m_imageName = QFileInfo(filename).fileName(); - if (m_imageName.toUpper().contains(".D13")) - { - m_sectors_per_track = 13; - } - else - { - m_sectors_per_track = 16; - } - - QFile infile(filename); - QCryptographicHash hash(QCryptographicHash::Md5); - - if (infile.open(QIODevice::ReadOnly)) - { - QByteArray contents = infile.readAll(); - QDataStream qds(contents); - for (int track = 0; track < 35; track++) - { - for (int sector = 0; sector < m_sectors_per_track; sector++) - { - char buffer[256]; - if (qds.readRawData(buffer,256) == 256) - { - Sector sec; - sec.setTrackSector(track,sector); - sec.setData(QByteArray(buffer,256)); - m_contents[track][sector] = sec; - } - else - { - qDebug() << "Invalid sector read!"; - return false; - } - } - } - hash.addData(contents); - - m_hash = hash.result(); - qDebug() << "Hash: " << m_hash; - - return true; - } - else - qDebug() << "Could not open file " << filename; - return false; -} - -VTOC DiskFile::getVTOC() -{ - return getSector(17,0).promoteToVTOC(); -} - -QList DiskFile::getCatalogSectors() -{ - QList retval; - VTOC vtoc = getVTOC(); - TSPair ts = vtoc.firstCatalogSector(); - - CatalogSector cs = getSector(ts).promoteToCatalogSector(); - retval.append(cs); - while (cs.nextCatalogSector() != TSPair(0,0)) { - ts = cs.nextCatalogSector(); - cs = getSector(ts).promoteToCatalogSector(); - retval.append(cs); - } - return retval; -} - -GenericFile *DiskFile::getFile(FileDescriptiveEntry fde) -{ - GenericFile *retval = 0; - if (m_files.contains(fde)) - { - retval = m_files[fde]; - } - else - { - TrackSectorList tsl = getSector(fde.firstTSListSector).promoteToTrackSectorList(); - QByteArray data = getDataFromTrackSectorList(tsl); - - if (fde.fileType() == "A") - { - retval = new ApplesoftFile(data); - } - else if (fde.fileType() == "B") - { - retval = new BinaryFile(data); - } - else if (fde.fileType() == "R") - { - retval = new RelocatableFile(data); - } - else if ((fde.fileType() == "T")) - { - retval = new TextFile(data); - } - else - { - retval = new GenericFile(data); - } - m_files[fde] = retval; - } - if (retval) { retval->setDiskFile(this); } - return retval; -} - - -QByteArray DiskFile::getDataFromTrackSectorList(TrackSectorList tsl) -{ - QByteArray retval; - - foreach(TSPair pair, tsl.getDataTSPairs()) - { - Sector sec = getSector(pair); - retval.append(sec.rawData()); - } - - if (tsl.getNextTSList() != TSPair(0,0)) { - TrackSectorList nextTsl = getSector(tsl.getNextTSList()).promoteToTrackSectorList(); - retval.append(getDataFromTrackSectorList(nextTsl)); - } - - return retval; -} - -QList DiskFile::getAllFDEs() { - QList retval; - - QList sectors = getCatalogSectors(); - - foreach (CatalogSector cs, sectors) - { - QList fdes = cs.getFDEs(); - retval.append(fdes); - } - return retval; -} - -QString DiskFile::getMetaDataPath() const { - QString path = QString("%1.metadata/").arg(getFullDiskImageName()); - - QDir dir(path); - dir.mkpath("."); - - return path; -} - +#include "diskfile.h" + +#include +#include +#include +#include +#include + +#include "tracksectorlist.h" +#include "applesoftfile.h" +#include "binaryfile.h" +#include "IntBasicFile.h" +#include "relocatablefile.h" +#include "textfile.h" + +DiskFile::DiskFile(QString filename) +{ + if (!filename.isEmpty()) + { + read(filename); + } +} + +DiskFile::~DiskFile() +{ + foreach (GenericFile *file, m_files) + { + delete file; + } +} + +bool DiskFile::read(QString filename) +{ + m_fullImageName = filename; + m_imageName = QFileInfo(filename).fileName(); + if (m_imageName.toUpper().contains(".D13")) + { + m_sectors_per_track = 13; + } + else + { + m_sectors_per_track = 16; + } + + QFile infile(filename); + QCryptographicHash hash(QCryptographicHash::Md5); + + if (infile.open(QIODevice::ReadOnly)) + { + QByteArray contents = infile.readAll(); + QDataStream qds(contents); + for (int track = 0; track < 35; track++) + { + for (int sector = 0; sector < m_sectors_per_track; sector++) + { + char buffer[256]; + if (qds.readRawData(buffer,256) == 256) + { + Sector sec; + sec.setTrackSector(track,sector); + sec.setData(QByteArray(buffer,256)); + m_contents[track][sector] = sec; + } + else + { + qDebug() << "Invalid sector read!"; + return false; + } + } + } + hash.addData(contents); + + m_hash = hash.result(); + qDebug() << "Hash: " << m_hash; + + return true; + } + else + qDebug() << "Could not open file " << filename; + return false; +} + +VTOC DiskFile::getVTOC() +{ + return getSector(17,0).promoteToVTOC(); +} + +QList DiskFile::getCatalogSectors() +{ + QList retval; + VTOC vtoc = getVTOC(); + TSPair ts = vtoc.firstCatalogSector(); + + CatalogSector cs = getSector(ts).promoteToCatalogSector(); + retval.append(cs); + while (cs.nextCatalogSector() != TSPair(0,0)) { + ts = cs.nextCatalogSector(); + cs = getSector(ts).promoteToCatalogSector(); + retval.append(cs); + } + return retval; +} + +GenericFile *DiskFile::getFile(FileDescriptiveEntry fde) +{ + GenericFile *retval = 0; + if (m_files.contains(fde)) + { + retval = m_files[fde]; + } + else + { + TrackSectorList tsl = getSector(fde.firstTSListSector).promoteToTrackSectorList(); + QByteArray data = getDataFromTrackSectorList(tsl); + + if (fde.fileType() == "A") + { + retval = new ApplesoftFile(data); + } + else if (fde.fileType() == "B") + { + retval = new BinaryFile(data); + } + else if (fde.fileType() == "R") + { + retval = new RelocatableFile(data); + } + else if ((fde.fileType() == "T")) + { + retval = new TextFile(data); + } + else if ((fde.fileType() == "I")) + { + retval = new IntBasicFile(data); + } + else + { + retval = new GenericFile(data); + } + m_files[fde] = retval; + } + if (retval) { retval->setDiskFile(this); } + return retval; +} + + +QByteArray DiskFile::getDataFromTrackSectorList(TrackSectorList tsl) +{ + QByteArray retval; + + foreach(TSPair pair, tsl.getDataTSPairs()) + { + Sector sec = getSector(pair); + retval.append(sec.rawData()); + } + + if (tsl.getNextTSList() != TSPair(0,0)) { + TrackSectorList nextTsl = getSector(tsl.getNextTSList()).promoteToTrackSectorList(); + retval.append(getDataFromTrackSectorList(nextTsl)); + } + + return retval; +} + +QList DiskFile::getAllFDEs() { + QList retval; + + QList sectors = getCatalogSectors(); + + foreach (CatalogSector cs, sectors) + { + QList fdes = cs.getFDEs(); + retval.append(fdes); + } + return retval; +} + +QString DiskFile::getMetaDataPath() const { + QString path = QString("%1.metadata/").arg(getFullDiskImageName()); + + QDir dir(path); + dir.mkpath("."); + + return path; +} + diff --git a/src/diskfiles/dos33/diskfile.h b/src/diskfiles/dos33/diskfile.h index 69a10c3..e737b7d 100644 --- a/src/diskfiles/dos33/diskfile.h +++ b/src/diskfiles/dos33/diskfile.h @@ -1,59 +1,59 @@ -#ifndef DISKFILE_H -#define DISKFILE_H - -#include -#include -#include -#include -#include - -#include "util.h" -#include "sector.h" -#include "vtoc.h" - -class GenericFile; - -class DiskFile -{ -public: - DiskFile(QString filename = ""); - ~DiskFile(); - - bool read(QString filename); - - Sector &getSector(TSPair ts) { return getSector(ts.track, ts.sector); } - - Sector &getSector(int track, int sector) { - return m_contents[track][sector]; - } - - VTOC getVTOC(); - - QList getCatalogSectors(); - - GenericFile *getFile(FileDescriptiveEntry fde); - - QByteArray getDataFromTrackSectorList(TrackSectorList tsl); - - QList getAllFDEs(); - - QByteArray fileHash() const { return m_hash; } - - QString getDiskImageName() const { return m_imageName; } - QString getFullDiskImageName() const { return m_fullImageName; } - QString getMetaDataPath() const; - -private: - - QMap< int, QMap< int, Sector> > m_contents; - QMap m_files; - QByteArray m_hash; - - QString m_imageName; - QString m_fullImageName; - - quint8 m_sectors_per_track; - -}; - -#endif // DISKFILE_H +#ifndef DISKFILE_H +#define DISKFILE_H + +#include +#include +#include +#include +#include + +#include "util.h" +#include "sector.h" +#include "vtoc.h" + +class GenericFile; + +class DiskFile +{ +public: + DiskFile(QString filename = ""); + ~DiskFile(); + + bool read(QString filename); + + Sector &getSector(TSPair ts) { return getSector(ts.track, ts.sector); } + + Sector &getSector(int track, int sector) { + return m_contents[track][sector]; + } + + VTOC getVTOC(); + + QList getCatalogSectors(); + + GenericFile *getFile(FileDescriptiveEntry fde); + + QByteArray getDataFromTrackSectorList(TrackSectorList tsl); + + QList getAllFDEs(); + + QByteArray fileHash() const { return m_hash; } + + QString getDiskImageName() const { return m_imageName; } + QString getFullDiskImageName() const { return m_fullImageName; } + QString getMetaDataPath() const; + +private: + + QMap< int, QMap< int, Sector> > m_contents; + QMap m_files; + QByteArray m_hash; + + QString m_imageName; + QString m_fullImageName; + + quint8 m_sectors_per_track; + +}; + +#endif // DISKFILE_H diff --git a/src/diskfiles/dos33/filedescriptiveentry.cxx b/src/diskfiles/dos33/filedescriptiveentry.cxx index 8d3836e..6e6ee6d 100644 --- a/src/diskfiles/dos33/filedescriptiveentry.cxx +++ b/src/diskfiles/dos33/filedescriptiveentry.cxx @@ -1,2 +1,2 @@ -#include "filedescriptiveentry.h" - +#include "filedescriptiveentry.h" + diff --git a/src/diskfiles/dos33/filedescriptiveentry.h b/src/diskfiles/dos33/filedescriptiveentry.h index c3269b5..bc6bba7 100644 --- a/src/diskfiles/dos33/filedescriptiveentry.h +++ b/src/diskfiles/dos33/filedescriptiveentry.h @@ -1,55 +1,55 @@ -#ifndef FILEDESCRIPTIVEENTRY_H -#define FILEDESCRIPTIVEENTRY_H - -#include "util.h" -#include -#include "applestring.h" - -struct FileDescriptiveEntry { - TSPair firstTSListSector; - int fileTypeAndFlags; - AppleString filename; - quint16 lengthInSectors; - bool deleted; - - FileDescriptiveEntry() { - fileTypeAndFlags = 0; - lengthInSectors = 0; - deleted = false; - } - - bool operator<(const FileDescriptiveEntry& f1) const { - return f1.filename < filename; - } - - QString fileType() { - if (fileTypeAndFlags & DOSIntegerBasicFile) { return "I"; } - if (fileTypeAndFlags & DOSApplesoftBasicFile) { return "A"; } - if (fileTypeAndFlags & DOSRelocatableFile) { return "R"; } - if (fileTypeAndFlags & DOSRawBinaryFile) { return "B"; } - if (fileTypeAndFlags & DOSTypeSFile) { return "S"; } - if (fileTypeAndFlags & DOSTypeAFile) { return "a"; } - if (fileTypeAndFlags & DOSTypeBFile) { return "b"; } - return "T"; - } - - bool isLocked() { return (fileTypeAndFlags & DOSIsLocked); } - - void dump() { - qDebug() << "First TS List Sector: Track: " << QString("%1").arg(firstTSListSector.track,2,16,QChar('0')).toUpper() - << " Sector: " << QString("%1").arg(firstTSListSector.sector,2,16,QChar('0')).toUpper(); - qDebug() << "File Type and Flags: " << QString::number((quint8)fileTypeAndFlags) << "(" << fileType() << "," << (isLocked()?"Locked":"Unlocked") << ")"; - qDebug() << "Filename: " << filename.printable(); - qDebug() << "Length in Sectors: " << lengthInSectors; - } - - void catalog() { - QString output = QString("%1 %2 %3 %4").arg(QString(isLocked()?"*":" ")) - .arg(lengthInSectors,3,10,QChar('0')) - .arg(fileType()) - .arg(filename.printable().trimmed()); - qDebug() << output; - } -}; - -#endif // FILEDESCRIPTIVEENTRY_H +#ifndef FILEDESCRIPTIVEENTRY_H +#define FILEDESCRIPTIVEENTRY_H + +#include "util.h" +#include +#include "applestring.h" + +struct FileDescriptiveEntry { + TSPair firstTSListSector; + int fileTypeAndFlags; + AppleString filename; + quint16 lengthInSectors; + bool deleted; + + FileDescriptiveEntry() { + fileTypeAndFlags = 0; + lengthInSectors = 0; + deleted = false; + } + + bool operator<(const FileDescriptiveEntry& f1) const { + return f1.filename < filename; + } + + QString fileType() { + if (fileTypeAndFlags & DOSIntegerBasicFile) { return "I"; } + if (fileTypeAndFlags & DOSApplesoftBasicFile) { return "A"; } + if (fileTypeAndFlags & DOSRelocatableFile) { return "R"; } + if (fileTypeAndFlags & DOSRawBinaryFile) { return "B"; } + if (fileTypeAndFlags & DOSTypeSFile) { return "S"; } + if (fileTypeAndFlags & DOSTypeAFile) { return "a"; } + if (fileTypeAndFlags & DOSTypeBFile) { return "b"; } + return "T"; + } + + bool isLocked() { return (fileTypeAndFlags & DOSIsLocked); } + + void dump() { + qDebug() << "First TS List Sector: Track: " << QString("%1").arg(firstTSListSector.track,2,16,QChar('0')).toUpper() + << " Sector: " << QString("%1").arg(firstTSListSector.sector,2,16,QChar('0')).toUpper(); + qDebug() << "File Type and Flags: " << QString::number((quint8)fileTypeAndFlags) << "(" << fileType() << "," << (isLocked()?"Locked":"Unlocked") << ")"; + qDebug() << "Filename: " << filename.printable(); + qDebug() << "Length in Sectors: " << lengthInSectors; + } + + void catalog() { + QString output = QString("%1 %2 %3 %4").arg(QString(isLocked()?"*":" ")) + .arg(lengthInSectors,3,10,QChar('0')) + .arg(fileType()) + .arg(filename.printable().trimmed()); + qDebug() << output; + } +}; + +#endif // FILEDESCRIPTIVEENTRY_H diff --git a/src/diskfiles/dos33/genericfile.cxx b/src/diskfiles/dos33/genericfile.cxx index 017bc10..d4630fe 100644 --- a/src/diskfiles/dos33/genericfile.cxx +++ b/src/diskfiles/dos33/genericfile.cxx @@ -1,17 +1,17 @@ -#include "genericfile.h" - -GenericFile::GenericFile(QByteArray data) -{ - m_diskfile = 0; - if (!data.isEmpty()) { - setData(data); - } - m_address = 0x00; - m_length = 0x00; -} - -void GenericFile::setData(QByteArray data) -{ - m_data = data; - m_length = data.size(); -} +#include "genericfile.h" + +GenericFile::GenericFile(QByteArray data) +{ + m_diskfile = 0; + if (!data.isEmpty()) { + setData(data); + } + m_address = 0x00; + m_length = 0x00; +} + +void GenericFile::setData(QByteArray data) +{ + m_data = data; + m_length = data.size(); +} diff --git a/src/diskfiles/dos33/genericfile.h b/src/diskfiles/dos33/genericfile.h index c4eda1a..38da6d4 100644 --- a/src/diskfiles/dos33/genericfile.h +++ b/src/diskfiles/dos33/genericfile.h @@ -1,39 +1,42 @@ -#ifndef GENERICFILE_H -#define GENERICFILE_H - -#include "diskfile.h" - -#include -#include - - -class GenericFile -{ -public: - GenericFile(QByteArray data = QByteArray()); - virtual ~GenericFile() { } - virtual void setData(QByteArray data); - - virtual QByteArray data() { return m_data; } - void setFilename(QString filename) { m_filename = filename; } - QString filename() const { return m_filename; } - virtual void setAddress(quint16 location) { m_address = location; } - virtual quint16 address() { return m_address; } - virtual QByteArray rawData() { return m_data; } - - virtual void setLength(quint16 length) { m_length = length; } - virtual quint16 length() { return m_length; } - - DiskFile *diskFile() const { return m_diskfile; } - void setDiskFile(DiskFile *diskfile) { m_diskfile = diskfile; } - -protected: - QByteArray m_data; - QString m_filename; - quint16 m_address; - qint16 m_length; - DiskFile * m_diskfile; - -}; - -#endif // GENERICFILE_H +#ifndef GENERICFILE_H +#define GENERICFILE_H + +#include "diskfile.h" + +#include +#include + + +class GenericFile +{ +public: + GenericFile(QByteArray data = QByteArray()); + virtual ~GenericFile() { } + + virtual void setData(QByteArray data); + virtual QByteArray data() { return m_data; } + + void setFilename(QString filename) { m_filename = filename; } + QString filename() const { return m_filename; } + + virtual void setAddress(quint16 location) { m_address = location; } + virtual quint16 address() { return m_address; } + + virtual QByteArray rawData() { return m_data; } + + virtual void setLength(quint16 length) { m_length = length; } + virtual quint16 length() const { return m_length; } + + DiskFile *diskFile() const { return m_diskfile; } + void setDiskFile(DiskFile *diskfile) { m_diskfile = diskfile; } + +protected: + QByteArray m_data; + QString m_filename; + quint16 m_address; + qint16 m_length; + DiskFile * m_diskfile; + +}; + +#endif // GENERICFILE_H diff --git a/src/diskfiles/dos33/sector.cxx b/src/diskfiles/dos33/sector.cxx index 000c7ac..bfa0d13 100644 --- a/src/diskfiles/dos33/sector.cxx +++ b/src/diskfiles/dos33/sector.cxx @@ -1,47 +1,47 @@ -#include "sector.h" - -#include -#include - -QByteRef Sector::operator[](uint offset) { - if (offset > 255) { - offset = 255; - } - return m_data[offset]; -} - -bool Sector::setData(QByteArray data) { - if (data.length() != 256) return false; - - m_data = data; - return true; -} - -void Sector::dump() { - qDebug() << "Dumping Track " << track() << "Sector " << sector() << " ..."; - for (int jdx = 0; jdx < 16; jdx++) - { - QString line; - line += QString("%1 (%2): ").arg(jdx*16,2,16,QChar('0')).arg(jdx*16,3,10,QChar(' ')); - for (int idx = 0; idx < 16; idx++) - { - int offset = (jdx*16) + idx; - quint8 val = m_data[offset]; - line += QString("%1 ").arg(val,2,16,QChar('0')); - if (idx == 7) line += " "; - } - line = line.toUpper(); - line += " "; - for (int idx = 0; idx < 16; idx++) - { - int offset = (jdx*16) + idx; - quint8 val = m_data[offset]; - if (val > 127) { val -= 128; } - QChar ch(val); - line += QString("%1").arg(ch.isPrint()?ch:'.'); - } - - qDebug() << line; - } -} - +#include "sector.h" + +#include +#include + +QByteRef Sector::operator[](uint offset) { + if (offset > 255) { + offset = 255; + } + return m_data[offset]; +} + +bool Sector::setData(QByteArray data) { + if (data.length() != 256) return false; + + m_data = data; + return true; +} + +void Sector::dump() { + qDebug() << "Dumping Track " << track() << "Sector " << sector() << " ..."; + for (int jdx = 0; jdx < 16; jdx++) + { + QString line; + line += QString("%1 (%2): ").arg(jdx*16,2,16,QChar('0')).arg(jdx*16,3,10,QChar(' ')); + for (int idx = 0; idx < 16; idx++) + { + int offset = (jdx*16) + idx; + quint8 val = m_data[offset]; + line += QString("%1 ").arg(val,2,16,QChar('0')); + if (idx == 7) line += " "; + } + line = line.toUpper(); + line += " "; + for (int idx = 0; idx < 16; idx++) + { + int offset = (jdx*16) + idx; + quint8 val = m_data[offset]; + if (val > 127) { val -= 128; } + QChar ch(val); + line += QString("%1").arg(ch.isPrint()?ch:'.'); + } + + qDebug() << line; + } +} + diff --git a/src/diskfiles/dos33/sector.h b/src/diskfiles/dos33/sector.h index c1bdda9..02e1b66 100644 --- a/src/diskfiles/dos33/sector.h +++ b/src/diskfiles/dos33/sector.h @@ -1,57 +1,57 @@ -#ifndef SECTOR_H -#define SECTOR_H - -#include - -#include "vtoc.h" -#include "catalogsector.h" -#include "tracksectorlist.h" - -class Sector -{ -public: - - Sector() { - m_data.resize(256); - m_track = 255; - m_sector = 255; - } - - VTOC promoteToVTOC() { - return VTOC(this); - } - - CatalogSector promoteToCatalogSector() { - return CatalogSector(this); - } - - TrackSectorList promoteToTrackSectorList() { - return TrackSectorList(this); - } - - int sector() { return m_sector; } - int track() { return m_track; } - - void setTrackSector(int track, int sector) { - setTrack(track); - setSector(sector); - } - - void setTrack(int track) { m_track = track; } - void setSector(int sector) { m_sector = sector; } - - QByteRef operator[](uint offset); - - bool setData(QByteArray data); - - void dump(); - - QByteArray rawData() { return m_data; } - -private: - QByteArray m_data; - int m_track; - int m_sector; -}; - -#endif // SECTOR_H +#ifndef SECTOR_H +#define SECTOR_H + +#include + +#include "vtoc.h" +#include "catalogsector.h" +#include "tracksectorlist.h" + +class Sector +{ +public: + + Sector() { + m_data.resize(256); + m_track = 255; + m_sector = 255; + } + + VTOC promoteToVTOC() { + return VTOC(this); + } + + CatalogSector promoteToCatalogSector() { + return CatalogSector(this); + } + + TrackSectorList promoteToTrackSectorList() { + return TrackSectorList(this); + } + + int sector() { return m_sector; } + int track() { return m_track; } + + void setTrackSector(int track, int sector) { + setTrack(track); + setSector(sector); + } + + void setTrack(int track) { m_track = track; } + void setSector(int sector) { m_sector = sector; } + + QByteRef operator[](uint offset); + + bool setData(QByteArray data); + + void dump(); + + QByteArray rawData() { return m_data; } + +private: + QByteArray m_data; + int m_track; + int m_sector; +}; + +#endif // SECTOR_H diff --git a/src/diskfiles/dos33/tracksectorlist.cxx b/src/diskfiles/dos33/tracksectorlist.cxx index caa395c..2df19c8 100644 --- a/src/diskfiles/dos33/tracksectorlist.cxx +++ b/src/diskfiles/dos33/tracksectorlist.cxx @@ -1,24 +1,24 @@ -#include "tracksectorlist.h" - -#include "sector.h" - -TrackSectorList::TrackSectorList(Sector *data) -{ - m_data = data; - - m_next_tslist.track = m_data->rawData()[0x01]; - m_next_tslist.sector = m_data->rawData()[0x02]; - - m_sector_offset.track = m_data->rawData()[0x05]; - m_sector_offset.sector = m_data->rawData()[0x06]; - - for (int idx = 0x0C; idx < 0xff; idx+=2) - { - TSPair ts(m_data->rawData()[idx],m_data->rawData()[idx+1]); - if (ts == TSPair(0,0)) { - break; - } else { - m_ts_pairs_for_data.append(ts); - } - } -} +#include "tracksectorlist.h" + +#include "sector.h" + +TrackSectorList::TrackSectorList(Sector *data) +{ + m_data = data; + + m_next_tslist.track = m_data->rawData()[0x01]; + m_next_tslist.sector = m_data->rawData()[0x02]; + + m_sector_offset.track = m_data->rawData()[0x05]; + m_sector_offset.sector = m_data->rawData()[0x06]; + + for (int idx = 0x0C; idx < 0xff; idx+=2) + { + TSPair ts(m_data->rawData()[idx],m_data->rawData()[idx+1]); + if (ts == TSPair(0,0)) { + break; + } else { + m_ts_pairs_for_data.append(ts); + } + } +} diff --git a/src/diskfiles/dos33/tracksectorlist.h b/src/diskfiles/dos33/tracksectorlist.h index 4a24d7d..6c040d4 100644 --- a/src/diskfiles/dos33/tracksectorlist.h +++ b/src/diskfiles/dos33/tracksectorlist.h @@ -1,27 +1,27 @@ -#ifndef TRACKSECTORLIST_H -#define TRACKSECTORLIST_H - -#include "util.h" - -class Sector; - -class TrackSectorList -{ -public: - TrackSectorList(Sector *data); - - TSPair getNextTSList() const { return m_next_tslist; } - TSPair getSectorOffset() const { return m_sector_offset; } - - QList getDataTSPairs() { return m_ts_pairs_for_data; } - -private: - - TSPair m_next_tslist; - TSPair m_sector_offset; - QList m_ts_pairs_for_data; - - Sector *m_data; -}; - -#endif // TRACKSECTORLIST_H +#ifndef TRACKSECTORLIST_H +#define TRACKSECTORLIST_H + +#include "util.h" + +class Sector; + +class TrackSectorList +{ +public: + TrackSectorList(Sector *data); + + TSPair getNextTSList() const { return m_next_tslist; } + TSPair getSectorOffset() const { return m_sector_offset; } + + QList getDataTSPairs() { return m_ts_pairs_for_data; } + +private: + + TSPair m_next_tslist; + TSPair m_sector_offset; + QList m_ts_pairs_for_data; + + Sector *m_data; +}; + +#endif // TRACKSECTORLIST_H diff --git a/src/diskfiles/dos33/vtoc.cxx b/src/diskfiles/dos33/vtoc.cxx index 67dd610..0fe5d8f 100644 --- a/src/diskfiles/dos33/vtoc.cxx +++ b/src/diskfiles/dos33/vtoc.cxx @@ -1,99 +1,100 @@ -#include "vtoc.h" - -#include -#include - -#include "sector.h" -#include "util.h" - -VTOC::VTOC(Sector *data) -{ - m_data = data; -} - -TSPair VTOC::firstCatalogSector() { - return TSPair(m_data->rawData()[0x01], m_data->rawData()[0x02]); -} - -quint8 VTOC::dosVersion() { - return m_data->rawData()[0x03]; -} - -quint8 VTOC::volumeNumber() { - return m_data->rawData()[0x06]; -} - -quint8 VTOC::maxTSPairs() { - return m_data->rawData()[0x27]; -} - -quint8 VTOC::lastTrackAllocated() { - return m_data->rawData()[0x30]; -} - -qint8 VTOC::directionOfAllocation() { - return m_data->rawData()[0x31]; -} - -quint8 VTOC::tracksPerDisk() { - return m_data->rawData()[0x34]; -} - -quint8 VTOC::sectorsPerDisk() { - return m_data->rawData()[0x35]; -} - -qint16 VTOC::bytesPerSector() { - return makeWord(m_data->rawData()[0x36], - m_data->rawData()[0x37]); -} - -bool VTOC::isSectorInUse(TSPair ts) { - quint8 track = ts.track; - quint8 sec = ts.sector; - quint8 baseaddr = (track * 4) + 0x38; - - //quint16 word = (((quint16) m_data->rawData()[baseaddr]) *256) + (quint8) m_data->rawData()[baseaddr+1]; - quint16 word = makeWord(m_data->rawData()[baseaddr+1],m_data->rawData()[baseaddr]); - quint16 bitpos = (quint16) 0x01 << (quint16) sec; - - return !(word & bitpos); -} - -void VTOC::dump() -{ - /* - for (qint8 idx = 0x0f; idx >= 0; idx--) { - quint8 shift; - if (idx < 0x08) { shift = idx; } else { shift = idx-0x08; } - qDebug() << "Idx: " << idx << "Shift: " << (quint8) shift << "Bitpos: " << (quint8) (0x01 << shift); - } -*/ - qDebug() << "Dumping VTOC Track " << m_data->track() << "Sector " << m_data->sector() << " ..."; - qDebug() << " Track number of first catalog sector: " << QString::number(firstCatalogSector().track); - qDebug() << " Sector number of first catalog sector: " << QString::number(firstCatalogSector().sector); - qDebug() << " Release number of DOS used to INIT disk: " << QString::number(dosVersion()); - qDebug() << " Disk Volume Number: " << QString::number(volumeNumber()); - qDebug() << " Max track/sector pairs that fit in t/s list sector (122=256): " << QString::number(maxTSPairs()); - qDebug() << " Last track where sectors were allocated: " << QString::number(lastTrackAllocated()); - qDebug() << " Direction of track allocations (+/- 1): " << QString::number(directionOfAllocation()); - qDebug() << " Number tracks per disk: " << QString::number(tracksPerDisk()); - qDebug() << " Number sectors per disk: " << QString::number(sectorsPerDisk()); - qDebug() << " Number bytes/sector: " << QString::number(bytesPerSector()); - qDebug() << " Track Usage (.=free, 0-F=used):"; - for (quint8 track = 0; track < m_data->rawData()[0x34];track++) - { - qDebug() << " " << QString("Track %1:").arg((int) track,2,10,QChar('0')) << buildUseString(track); - } - } - -QString VTOC::buildUseString(quint8 track) { - QString usestr; - for (qint8 sec = 0x0f; sec >= 0; sec--) - { - usestr.append(isSectorInUse(TSPair(track,sec))?QString::number(sec,16).toUpper():"-"); - } - return usestr; -} - - +#include "vtoc.h" + +#include +#include + +#include "sector.h" +#include "util.h" + +VTOC::VTOC(Sector *data) +{ + m_data = data; +} + +TSPair VTOC::firstCatalogSector() { + return TSPair(m_data->rawData()[0x01], m_data->rawData()[0x02]); +} + +quint8 VTOC::dosVersion() { + return m_data->rawData()[0x03]; +} + +quint8 VTOC::volumeNumber() { + return m_data->rawData()[0x06]; +} + +quint8 VTOC::maxTSPairs() { + return m_data->rawData()[0x27]; +} + +quint8 VTOC::lastTrackAllocated() { + return m_data->rawData()[0x30]; +} + +qint8 VTOC::directionOfAllocation() { + return m_data->rawData()[0x31]; +} + +quint8 VTOC::tracksPerDisk() { + return m_data->rawData()[0x34]; +} + +quint8 VTOC::sectorsPerDisk() { + return m_data->rawData()[0x35]; +} + +qint16 VTOC::bytesPerSector() { + return makeWord(m_data->rawData()[0x36], + m_data->rawData()[0x37]); +} + +bool VTOC::isSectorInUse(TSPair ts) { + quint8 track = ts.track; + quint8 sec = ts.sector; + quint8 baseaddr = (track * 4) + 0x38; + + //quint16 word = (((quint16) m_data->rawData()[baseaddr]) *256) + (quint8) m_data->rawData()[baseaddr+1]; + quint16 word = makeWord(m_data->rawData()[baseaddr+1], + m_data->rawData()[baseaddr]); + quint16 bitpos = (quint16) 0x01 << (quint16) sec; + + return !(word & bitpos); +} + +void VTOC::dump() +{ + /* + for (qint8 idx = 0x0f; idx >= 0; idx--) { + quint8 shift; + if (idx < 0x08) { shift = idx; } else { shift = idx-0x08; } + qDebug() << "Idx: " << idx << "Shift: " << (quint8) shift << "Bitpos: " << (quint8) (0x01 << shift); + } +*/ + qDebug() << "Dumping VTOC Track " << m_data->track() << "Sector " << m_data->sector() << " ..."; + qDebug() << " Track number of first catalog sector: " << QString::number(firstCatalogSector().track); + qDebug() << " Sector number of first catalog sector: " << QString::number(firstCatalogSector().sector); + qDebug() << " Release number of DOS used to INIT disk: " << QString::number(dosVersion()); + qDebug() << " Disk Volume Number: " << QString::number(volumeNumber()); + qDebug() << " Max track/sector pairs that fit in t/s list sector (122=256): " << QString::number(maxTSPairs()); + qDebug() << " Last track where sectors were allocated: " << QString::number(lastTrackAllocated()); + qDebug() << " Direction of track allocations (+/- 1): " << QString::number(directionOfAllocation()); + qDebug() << " Number tracks per disk: " << QString::number(tracksPerDisk()); + qDebug() << " Number sectors per disk: " << QString::number(sectorsPerDisk()); + qDebug() << " Number bytes/sector: " << QString::number(bytesPerSector()); + qDebug() << " Track Usage (.=free, 0-F=used):"; + for (quint8 track = 0; track < m_data->rawData()[0x34];track++) + { + qDebug() << " " << QString("Track %1:").arg((int) track,2,10,QChar('0')) << buildUseString(track); + } + } + +QString VTOC::buildUseString(quint8 track) { + QString usestr; + for (qint8 sec = 0x0f; sec >= 0; sec--) + { + usestr.append(isSectorInUse(TSPair(track,sec))?QString::number(sec,16).toUpper():"-"); + } + return usestr; +} + + diff --git a/src/diskfiles/dos33/vtoc.h b/src/diskfiles/dos33/vtoc.h index f829aa8..9a882d0 100644 --- a/src/diskfiles/dos33/vtoc.h +++ b/src/diskfiles/dos33/vtoc.h @@ -1,33 +1,33 @@ -#ifndef VTOC_H -#define VTOC_H - -#include -#include "util.h" -class Sector; -class QString; - - -class VTOC -{ -public: - VTOC(Sector *data); - - void dump(); - TSPair firstCatalogSector(); - quint8 dosVersion(); - quint8 volumeNumber(); - quint8 maxTSPairs(); - quint8 lastTrackAllocated(); - qint8 directionOfAllocation(); - quint8 tracksPerDisk(); - quint8 sectorsPerDisk(); - qint16 bytesPerSector(); - bool isSectorInUse(TSPair ts); - -private: - QString buildUseString(quint8 track); - - Sector *m_data; -}; - -#endif // VTOC_H +#ifndef VTOC_H +#define VTOC_H + +#include +#include "util.h" +class Sector; +class QString; + + +class VTOC +{ +public: + VTOC(Sector *data); + + void dump(); + TSPair firstCatalogSector(); + quint8 dosVersion(); + quint8 volumeNumber(); + quint8 maxTSPairs(); + quint8 lastTrackAllocated(); + qint8 directionOfAllocation(); + quint8 tracksPerDisk(); + quint8 sectorsPerDisk(); + qint16 bytesPerSector(); + bool isSectorInUse(TSPair ts); + +private: + QString buildUseString(quint8 track); + + Sector *m_data; +}; + +#endif // VTOC_H diff --git a/src/intbasic/IntBasicFile.cxx b/src/intbasic/IntBasicFile.cxx index 0a1fe8c..252606b 100644 --- a/src/intbasic/IntBasicFile.cxx +++ b/src/intbasic/IntBasicFile.cxx @@ -26,6 +26,10 @@ quint16 IntBasicFile::get16(quint8 v1, quint8 v2) QByteArray IntBasicFile::dumpBufferAsIntBasicFile(QByteArray origdata) /* + * THIS CODE IS MODIFIED FROM PAUL SCHYLTER'S SAMPLE CODE AVAILABLE AT: + * https://macgui.com/usenet/?group=1&start=14720&id=184603 + * + * * Integer Basic file format: * * (16-bit little endian) diff --git a/src/internals/JumpLineManager.cpp b/src/internals/JumpLineManager.cpp index 7257e6d..69553a6 100644 --- a/src/internals/JumpLineManager.cpp +++ b/src/internals/JumpLineManager.cpp @@ -1,173 +1,173 @@ -#include "JumpLineManager.h" - -JumpLineManager::JumpLineManager(quint16 from, quint16 to) - : m_start(from), - m_end(to) -{ - //qDebug() << "JumpLineManager(from:"<= from && src <= to && dest >= from && dest <= to) - { - if (!m_jumpmap.contains(jump)) - { - // qDebug() << "JumpLineManager::addJump: Added Jump from" << uint16ToHex(src) << "to" << uint16ToHex(dest) << ", Type:" << type; - m_jumpmap.insert(jump,type); - } - else - { - //qDebug() << "JumpLineManager::addJump: Not adding duplicate jump:" << uint16ToHex(src) << "," << uint16ToHex(dest); - } - } - else - { - // qDebug() << "JumpLineManager::addJump: Address range is out of bounds"; - - } -} - -void JumpLineManager::dumpJumps() const { - dumpJumps(m_jumpmap); -} - -void JumpLineManager::dumpJumps(JumpMap map) const -{ - //qDebug() << "JumpLineManager::dumpJumps()\n JumpTable:"; - QMapIterator it(map); - while (it.hasNext()) - { - it.next(); - QString jumptypelabel; - if (it.value() == IsUnknownJump) { jumptypelabel = "Unknown Jump"; } - if (it.value() == IsJMP) { jumptypelabel = "JMP"; } - if (it.value() == IsBranch) { jumptypelabel = "Branch"; } - if (it.value() == IsJSR) { jumptypelabel = "JSR"; } - if (it.value() == IsBRA) { jumptypelabel = "BRA"; } - //qDebug() << " Jump from" << uint16ToHex(it.key().first) << "to" - // << uint16ToHex(it.key().second) << jumptypelabel; - } -} - -JumpLines JumpLineManager::buildJumpLines() -{ -//qDebug() << "A"; - - m_channelsAtAddress.clear(); - m_jumplines.m_maxChannel = 0; - QMapIterator it(m_jumpmap); - while (it.hasNext()) - { - it.next(); - TJump range = it.key(); - - JumpLine jl; - jl.type = it.value(); - jl.from = range.first; - jl.to = range.second; - int channel = findBestChannel(jl); - setChannelForJumpLine(channel,jl); - - m_jumplines.jumpLines.append(jl); - m_jumplines.m_maxChannel = qMax(m_jumplines.m_maxChannel, channel); - } - //qDebug() << "A"; - - - return m_jumplines; - -} - - - -int JumpLineManager::findBestChannel(JumpLine &jl) -{ - //qDebug() << "findBestChannel()"; - if (m_jumplines.jumpLines.count() == 0) - { - return 0; - } - - int potentialChannel = 0; - bool foundChannel = false; - while (!foundChannel) - { - //qDebug() << "Tryning potential channel" << potentialChannel; - bool matched = false; - for (quint16 addr = jl.min(); addr <= jl.max(); addr++) - { - // If any of these addresses contain the potential channel, move on - if (m_channelsAtAddress[addr].contains(potentialChannel)) - { - matched = true; - } - } - if (matched) - { - potentialChannel++; - matched = false; - } - else - { - foundChannel = true; - } - } - return potentialChannel; -} - -void JumpLineManager::setChannelForJumpLine(int channel, JumpLine &jl) -{ - jl.channel = channel; - for (quint16 addr = jl.min(); addr <= jl.max(); addr++) - { - m_channelsAtAddress[addr].append(channel); - } -} - -void JumpLineManager::dumpJumpLines() const -{ - //foreach (JumpLine jl, m_jumplines.jumpLines) - // { - //qDebug() << " JumpLine from:" << uint16ToHex(jl.from) - // << " to:" << uint16ToHex(jl.to) - // << "channel: " << jl.channel << " type:" << jl.type; - // } -} - -bool JumpLineManager::doJumpsIntersect(TJump &A, TJump &B) const -{ - - if (A == B) return false; - if (isLineWithinRange(A.first,B) || isLineWithinRange(A.second,B)) - return true; - - if (isLineWithinRange(B.first,A) || isLineWithinRange(B.second,A)) - return true; - - return false; - -} - -bool JumpLineManager::isLineWithinRange(quint16 line, TJump &jm) const -{ - quint16 min = qMin(jm.first,jm.second); - quint16 max = qMax(jm.first,jm.second); - - return (line > min && line < max); -} - -QList JumpLines::jumpLinesAtAddress(quint16 addrs) -{ - QList list; - foreach (JumpLine jl, jumpLines) - { - if (addrs >= jl.min() && addrs <= jl.max()) - { - list.append(jl); - } - } - return list; -} +#include "JumpLineManager.h" + +JumpLineManager::JumpLineManager(quint16 from, quint16 to) + : m_start(from), + m_end(to) +{ + //qDebug() << "JumpLineManager(from:"<= from && src <= to && dest >= from && dest <= to) + { + if (!m_jumpmap.contains(jump)) + { + // qDebug() << "JumpLineManager::addJump: Added Jump from" << uint16ToHex(src) << "to" << uint16ToHex(dest) << ", Type:" << type; + m_jumpmap.insert(jump,type); + } + else + { + //qDebug() << "JumpLineManager::addJump: Not adding duplicate jump:" << uint16ToHex(src) << "," << uint16ToHex(dest); + } + } + else + { + // qDebug() << "JumpLineManager::addJump: Address range is out of bounds"; + + } +} + +void JumpLineManager::dumpJumps() const { + dumpJumps(m_jumpmap); +} + +void JumpLineManager::dumpJumps(JumpMap map) const +{ + //qDebug() << "JumpLineManager::dumpJumps()\n JumpTable:"; + QMapIterator it(map); + while (it.hasNext()) + { + it.next(); + QString jumptypelabel; + if (it.value() == IsUnknownJump) { jumptypelabel = "Unknown Jump"; } + if (it.value() == IsJMP) { jumptypelabel = "JMP"; } + if (it.value() == IsBranch) { jumptypelabel = "Branch"; } + if (it.value() == IsJSR) { jumptypelabel = "JSR"; } + if (it.value() == IsBRA) { jumptypelabel = "BRA"; } + //qDebug() << " Jump from" << uint16ToHex(it.key().first) << "to" + // << uint16ToHex(it.key().second) << jumptypelabel; + } +} + +JumpLines JumpLineManager::buildJumpLines() +{ +//qDebug() << "A"; + + m_channelsAtAddress.clear(); + m_jumplines.m_maxChannel = 0; + QMapIterator it(m_jumpmap); + while (it.hasNext()) + { + it.next(); + TJump range = it.key(); + + JumpLine jl; + jl.type = it.value(); + jl.from = range.first; + jl.to = range.second; + int channel = findBestChannel(jl); + setChannelForJumpLine(channel,jl); + + m_jumplines.jumpLines.append(jl); + m_jumplines.m_maxChannel = qMax(m_jumplines.m_maxChannel, channel); + } + //qDebug() << "A"; + + + return m_jumplines; + +} + + + +int JumpLineManager::findBestChannel(JumpLine &jl) +{ + //qDebug() << "findBestChannel()"; + if (m_jumplines.jumpLines.count() == 0) + { + return 0; + } + + int potentialChannel = 0; + bool foundChannel = false; + while (!foundChannel) + { + //qDebug() << "Tryning potential channel" << potentialChannel; + bool matched = false; + for (quint16 addr = jl.min(); addr <= jl.max(); addr++) + { + // If any of these addresses contain the potential channel, move on + if (m_channelsAtAddress[addr].contains(potentialChannel)) + { + matched = true; + } + } + if (matched) + { + potentialChannel++; + matched = false; + } + else + { + foundChannel = true; + } + } + return potentialChannel; +} + +void JumpLineManager::setChannelForJumpLine(int channel, JumpLine &jl) +{ + jl.channel = channel; + for (quint16 addr = jl.min(); addr <= jl.max(); addr++) + { + m_channelsAtAddress[addr].append(channel); + } +} + +void JumpLineManager::dumpJumpLines() const +{ + //foreach (JumpLine jl, m_jumplines.jumpLines) + // { + //qDebug() << " JumpLine from:" << uint16ToHex(jl.from) + // << " to:" << uint16ToHex(jl.to) + // << "channel: " << jl.channel << " type:" << jl.type; + // } +} + +bool JumpLineManager::doJumpsIntersect(TJump &A, TJump &B) const +{ + + if (A == B) return false; + if (isLineWithinRange(A.first,B) || isLineWithinRange(A.second,B)) + return true; + + if (isLineWithinRange(B.first,A) || isLineWithinRange(B.second,A)) + return true; + + return false; + +} + +bool JumpLineManager::isLineWithinRange(quint16 line, TJump &jm) const +{ + quint16 min = qMin(jm.first,jm.second); + quint16 max = qMax(jm.first,jm.second); + + return (line > min && line < max); +} + +QList JumpLines::jumpLinesAtAddress(quint16 addrs) +{ + QList list; + foreach (JumpLine jl, jumpLines) + { + if (addrs >= jl.min() && addrs <= jl.max()) + { + list.append(jl); + } + } + return list; +} diff --git a/src/internals/JumpLineManager.h b/src/internals/JumpLineManager.h index 6e14605..79a8263 100644 --- a/src/internals/JumpLineManager.h +++ b/src/internals/JumpLineManager.h @@ -1,102 +1,102 @@ -#ifndef JUMPLINEMANAGER_H -#define JUMPLINEMANAGER_H - -#include -#include -#include -#include - -#include "util.h" - -typedef QPair TJump; -typedef enum { - IsUnknownJump, - IsJMP, - IsBranch, - IsJSR, - IsBRA -} JumpType; -typedef QMap JumpMap; - -class JumpLine { -public: - JumpLine() : from(0), to(0), channel(-1), type(IsUnknownJump) { } - quint16 from; - quint16 to; - int channel; - JumpType type; - - inline quint16 min() const { return qMin(from,to); } - inline quint16 max() const { return qMax(from,to); } - inline bool isUp() const { return (from > to); } - inline bool isDown() const { return !isUp(); } -}; - -////////////////// - -class JumpLines -{ -public: - JumpLines() : m_maxChannel(0) - { - - } - - QList channelsAtAddress(quint16 address) - { - return m_channelsAtAddress[address]; - } - - QList jumpLinesAtAddress(quint16 addrs); - - QList jumpLines; - - int m_maxChannel; - - QMap > m_channelsAtAddress; -}; - -////////////////// - -class JumpLineManager -{ -public: - JumpLineManager(quint16 from = 0x0000, quint16 to = 0xffff); - - void addJump(quint16 src, quint16 dest, JumpType type,quint16 from = 0, quint16 to = 0xffff); - void dumpJumps() const; - - JumpLines buildJumpLines(); - JumpLines getJumpLines() const { return m_jumplines; } - - - - void clear() { m_jumpmap.clear(); } - void dumpJumpLines() const; - - int getNumJumpLineChannels() const { return m_jumplines.m_maxChannel; } - -protected: - int findBestChannel(JumpLine &jl); - - void setChannelForJumpLine(int channel, JumpLine &jl); - -private: - quint16 m_start; - quint16 m_end; - - JumpMap m_jumpmap; - - JumpLines m_jumplines; - - QMap> m_channelsAtAddress; - - - bool doJumpsIntersect(TJump &A, TJump &B) const; - bool isLineWithinRange(quint16 line, TJump &jm) const; - - void dumpJumps(JumpMap map) const; - -}; - -#endif // JUMPLINEMANAGER_H +#ifndef JUMPLINEMANAGER_H +#define JUMPLINEMANAGER_H + +#include +#include +#include +#include + +#include "util.h" + +typedef QPair TJump; +typedef enum { + IsUnknownJump, + IsJMP, + IsBranch, + IsJSR, + IsBRA +} JumpType; +typedef QMap JumpMap; + +class JumpLine { +public: + JumpLine() : from(0), to(0), channel(-1), type(IsUnknownJump) { } + quint16 from; + quint16 to; + int channel; + JumpType type; + + inline quint16 min() const { return qMin(from,to); } + inline quint16 max() const { return qMax(from,to); } + inline bool isUp() const { return (from > to); } + inline bool isDown() const { return !isUp(); } +}; + +////////////////// + +class JumpLines +{ +public: + JumpLines() : m_maxChannel(0) + { + + } + + QList channelsAtAddress(quint16 address) + { + return m_channelsAtAddress[address]; + } + + QList jumpLinesAtAddress(quint16 addrs); + + QList jumpLines; + + int m_maxChannel; + + QMap > m_channelsAtAddress; +}; + +////////////////// + +class JumpLineManager +{ +public: + JumpLineManager(quint16 from = 0x0000, quint16 to = 0xffff); + + void addJump(quint16 src, quint16 dest, JumpType type,quint16 from = 0, quint16 to = 0xffff); + void dumpJumps() const; + + JumpLines buildJumpLines(); + JumpLines getJumpLines() const { return m_jumplines; } + + + + void clear() { m_jumpmap.clear(); } + void dumpJumpLines() const; + + int getNumJumpLineChannels() const { return m_jumplines.m_maxChannel; } + +protected: + int findBestChannel(JumpLine &jl); + + void setChannelForJumpLine(int channel, JumpLine &jl); + +private: + quint16 m_start; + quint16 m_end; + + JumpMap m_jumpmap; + + JumpLines m_jumplines; + + QMap> m_channelsAtAddress; + + + bool doJumpsIntersect(TJump &A, TJump &B) const; + bool isLineWithinRange(quint16 line, TJump &jm) const; + + void dumpJumps(JumpMap map) const; + +}; + +#endif // JUMPLINEMANAGER_H diff --git a/src/internals/memory.cxx b/src/internals/memory.cxx index a2ce767..836f079 100644 --- a/src/internals/memory.cxx +++ b/src/internals/memory.cxx @@ -1,21 +1,21 @@ -#include "memory.h" -#include - -Memory::Memory() -{ - quint8 zero = 0; - for (int idx = 0; idx < 65536; idx++) { - m_memory.append(zero); - } -} - -bool Memory::addFile(QByteArray data, quint16 start) -{ - if (start+data.length() > 65536) { - qDebug() << "Memory overflow adding data."; return false; - } - - m_memory.replace(start,data.length(),data); - - return true; -} +#include "memory.h" +#include + +Memory::Memory() +{ + quint8 zero = 0; + for (int idx = 0; idx < 65536; idx++) { + m_memory.append(zero); + } +} + +bool Memory::addFile(QByteArray data, quint16 start) +{ + if (start+data.length() > 65536) { + qDebug() << "Memory overflow adding data."; return false; + } + + m_memory.replace(start,data.length(),data); + + return true; +} diff --git a/src/internals/memory.h b/src/internals/memory.h index cd1fa4c..77a00c1 100644 --- a/src/internals/memory.h +++ b/src/internals/memory.h @@ -1,21 +1,21 @@ -#ifndef MEMORY_H -#define MEMORY_H - -#include - -class Memory { -public: - Memory(); - - bool addFile(QByteArray data, quint16 start); - - QByteArray &values() { return m_memory; } - - quint8 at(quint16 addr) { return m_memory.at(addr); } - -private: - QByteArray m_memory; -}; - - -#endif +#ifndef MEMORY_H +#define MEMORY_H + +#include + +class Memory { +public: + Memory(); + + bool addFile(QByteArray data, quint16 start); + + QByteArray &values() { return m_memory; } + + quint8 at(quint16 addr) { return m_memory.at(addr); } + +private: + QByteArray m_memory; +}; + + +#endif diff --git a/src/main.cpp b/src/main.cpp index 20e7dd0..ac9acba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,30 +1,30 @@ -#include -#include -#include - -#include "binaryfile.h" -#include "genericfile.h" -#include "diskfile.h" -#include "catalogsector.h" -#include "applesoftfile.h" -#include "DiskExplorer.h" - -int main(int argc, char** argv) -{ - QApplication a(argc, argv); - QCoreApplication::setOrganizationName("AppleSAWS"); - QCoreApplication::setOrganizationDomain("ml.com"); - QCoreApplication::setApplicationName("AppleSAWS"); - DiskExplorer w; - QSettings settings; - QString lastOpened = settings.value("lastOpened").toString(); - if (!lastOpened.isEmpty()) - { - w.loadDiskFile(lastOpened); - } - w.show(); - - return a.exec(); - -} - +#include +#include +#include + +#include "binaryfile.h" +#include "genericfile.h" +#include "diskfile.h" +#include "catalogsector.h" +#include "applesoftfile.h" +#include "DiskExplorer.h" + +int main(int argc, char** argv) +{ + QApplication a(argc, argv); + QCoreApplication::setOrganizationName("LydianScaleSoftware"); + QCoreApplication::setOrganizationDomain("lydianscale.com"); + QCoreApplication::setApplicationName("AppleSAWS"); + DiskExplorer w; + QSettings settings; + QString lastOpened = settings.value("lastOpened").toString(); + if (!lastOpened.isEmpty()) + { + w.loadDiskFile(lastOpened); + } + w.show(); + + return a.exec(); + +} + diff --git a/src/relocatablefile/relocatablefile.cxx b/src/relocatablefile/relocatablefile.cxx index 6a2b97e..cff6587 100644 --- a/src/relocatablefile/relocatablefile.cxx +++ b/src/relocatablefile/relocatablefile.cxx @@ -1,100 +1,100 @@ -#include -#include "relocatablefile.h" -#include "util.h" - -RelocatableFile::RelocatableFile(QByteArray data) : GenericFile(data) -{ - // qDebug() << "Relocatable file ctor"; - if (!data.isEmpty()) { - setData(data); - } -} - -void RelocatableFile::setData(QByteArray data) -{ - // qDebug() << "setData()"; - if (data.length() >= 6) { - m_starting_ram_address = makeWord(m_data[0],m_data[1]); - m_ram_image_length = makeWord(m_data[2],m_data[3]); - m_code_image_length = makeWord(m_data[4],m_data[5]); - - int offset = 0; - - for (int idx = 6; idx < m_code_image_length+6; idx++) { - quint8 val = m_data[idx]; - m_binary_code_image.append(val); - } - - for (int N = 0; N < (m_code_image_length/4); N++) { - offset = m_code_image_length+ 6 +(N*4); - -// qDebug() << "N: " << N << uint8ToHex(m_data[offset]) -// << uint8ToHex(m_data[offset+1]) -// << uint8ToHex(m_data[offset+2]) -// << uint8ToHex(m_data[offset+3]); - - RelocatableDictItem rdi = RelocatableDictItem(m_data[offset],m_data[offset+1], - m_data[offset+2],m_data[offset+3]); - m_relocatable_dict.append(rdi); - if (rdi.isEndOfRLD()) { break; } - } - - - - } -} - -void RelocatableFile::dump() -{ - qDebug() << "\nTotalLength: " << length(); - qDebug() << "Starting Ram Address: " << (quint16) m_starting_ram_address << uint16ToHex(m_starting_ram_address); - qDebug() << "Length of Ram Image: " << (quint16) m_ram_image_length << uint16ToHex(m_ram_image_length); - qDebug() << "Length of Code Image: " << (quint16) m_code_image_length << uint16ToHex(m_code_image_length); - - int itemIdx = 0; - foreach (RelocatableDictItem item, m_relocatable_dict) { - Byte4ReturnType b4rt = item.getByte4(); - QString typestr; - if (b4rt.first == ESDSymbol) { typestr = "ESDSymbol"; } - else if (b4rt.first == ByteHi) { typestr = "Hi Byte"; } - else { typestr = "Lo Byte"; } - quint16 fo = item.getFieldOffset(); - qDebug() << " Item #" << itemIdx++ - << "Field Offset: " << uint16ToHex(fo) - << "FieldSize: " << ((item.getFieldSize()==RFS2Byte)?"2-Byte":"1-Byte") - << typestr << uint8ToHex(b4rt.second) - << ((item.isNotEndOfRLD())?"NotEndOfRLD":"EndOfRLD") - << " " << ((item.isExtern())?"Extern":"Not Extern"); - } - - -} - -QStringList RelocatableFile::decodeRelocatableDict() -{ - QStringList retval; - int idx = 0; - foreach (RelocatableDictItem item, m_relocatable_dict) { - Byte4ReturnType b4rt = item.getByte4(); - QString typestr; - if (b4rt.first == ESDSymbol) { typestr = "ESDSymbol"; } - else if (b4rt.first == ByteHi) { typestr = "Hi Byte"; } - else { typestr = "Lo Byte"; } - quint16 fo = item.getFieldOffset(); -// qDebug() << " Item #" << idx -// << "Field Offset: " << uint16ToHex(fo) -// << "FieldSize: " << ((item.getFieldSize()==RFS2Byte)?"2-Byte":"1-Byte") -// << typestr << uint8ToHex(b4rt.second) -// << ((item.isNotEndOfRLD())?"NotEndOfRLD":"EndOfRLD") -// << " " << ((item.isExtern())?"Extern":"Not Extern"); - - retval.append(QString("Item %1, Offset %2, @ %3, %4 Field, %5") - .arg(idx++) - .arg(uint16ToHex(fo)) - .arg(uint16ToHex(fo+address()+6)) - .arg((item.getFieldSize()==RFS2Byte)?"2-Byte":"1-Byte") - .arg((item.isExtern())?"Extern":"Not Extern")); - } - - return retval; -} +#include +#include "relocatablefile.h" +#include "util.h" + +RelocatableFile::RelocatableFile(QByteArray data) : GenericFile(data) +{ + // qDebug() << "Relocatable file ctor"; + if (!data.isEmpty()) { + setData(data); + } +} + +void RelocatableFile::setData(QByteArray data) +{ + // qDebug() << "setData()"; + if (data.length() >= 6) { + m_starting_ram_address = makeWord(m_data[0],m_data[1]); + m_ram_image_length = makeWord(m_data[2],m_data[3]); + m_code_image_length = makeWord(m_data[4],m_data[5]); + + int offset = 0; + + for (int idx = 6; idx < m_code_image_length+6; idx++) { + quint8 val = m_data[idx]; + m_binary_code_image.append(val); + } + + for (int N = 0; N < (m_code_image_length/4); N++) { + offset = m_code_image_length+ 6 +(N*4); + +// qDebug() << "N: " << N << uint8ToHex(m_data[offset]) +// << uint8ToHex(m_data[offset+1]) +// << uint8ToHex(m_data[offset+2]) +// << uint8ToHex(m_data[offset+3]); + + RelocatableDictItem rdi = RelocatableDictItem(m_data[offset],m_data[offset+1], + m_data[offset+2],m_data[offset+3]); + m_relocatable_dict.append(rdi); + if (rdi.isEndOfRLD()) { break; } + } + + + + } +} + +void RelocatableFile::dump() +{ + qDebug() << "\nTotalLength: " << length(); + qDebug() << "Starting Ram Address: " << (quint16) m_starting_ram_address << uint16ToHex(m_starting_ram_address); + qDebug() << "Length of Ram Image: " << (quint16) m_ram_image_length << uint16ToHex(m_ram_image_length); + qDebug() << "Length of Code Image: " << (quint16) m_code_image_length << uint16ToHex(m_code_image_length); + + int itemIdx = 0; + foreach (RelocatableDictItem item, m_relocatable_dict) { + Byte4ReturnType b4rt = item.getByte4(); + QString typestr; + if (b4rt.first == ESDSymbol) { typestr = "ESDSymbol"; } + else if (b4rt.first == ByteHi) { typestr = "Hi Byte"; } + else { typestr = "Lo Byte"; } + quint16 fo = item.getFieldOffset(); + qDebug() << " Item #" << itemIdx++ + << "Field Offset: " << uint16ToHex(fo) + << "FieldSize: " << ((item.getFieldSize()==RFS2Byte)?"2-Byte":"1-Byte") + << typestr << uint8ToHex(b4rt.second) + << ((item.isNotEndOfRLD())?"NotEndOfRLD":"EndOfRLD") + << " " << ((item.isExtern())?"Extern":"Not Extern"); + } + + +} + +QStringList RelocatableFile::decodeRelocatableDict() +{ + QStringList retval; + int idx = 0; + foreach (RelocatableDictItem item, m_relocatable_dict) { + Byte4ReturnType b4rt = item.getByte4(); + QString typestr; + if (b4rt.first == ESDSymbol) { typestr = "ESDSymbol"; } + else if (b4rt.first == ByteHi) { typestr = "Hi Byte"; } + else { typestr = "Lo Byte"; } + quint16 fo = item.getFieldOffset(); +// qDebug() << " Item #" << idx +// << "Field Offset: " << uint16ToHex(fo) +// << "FieldSize: " << ((item.getFieldSize()==RFS2Byte)?"2-Byte":"1-Byte") +// << typestr << uint8ToHex(b4rt.second) +// << ((item.isNotEndOfRLD())?"NotEndOfRLD":"EndOfRLD") +// << " " << ((item.isExtern())?"Extern":"Not Extern"); + + retval.append(QString("Item %1, Offset %2, @ %3, %4 Field, %5") + .arg(idx++) + .arg(uint16ToHex(fo)) + .arg(uint16ToHex(fo+address()+6)) + .arg((item.getFieldSize()==RFS2Byte)?"2-Byte":"1-Byte") + .arg((item.isExtern())?"Extern":"Not Extern")); + } + + return retval; +} diff --git a/src/relocatablefile/relocatablefile.h b/src/relocatablefile/relocatablefile.h index d364e0d..9a31762 100644 --- a/src/relocatablefile/relocatablefile.h +++ b/src/relocatablefile/relocatablefile.h @@ -1,109 +1,109 @@ -#ifndef RELOCATABLEFILE_H -#define RELOCATABLEFILE_H - -#include -#include - -#include "genericfile.h" -#include "util.h" - - -typedef enum { RFS1Byte, RFS2Byte } FieldSize; -typedef enum { ULIsHighByte, ULIsLowByte } WordUpperLower; -typedef enum { LowHi, HiLow } Endianness; -typedef enum { ByteLo, ByteHi, ESDSymbol } Byte4Type; - -typedef QPair Byte4ReturnType; - -class RelocatableDictItem { -public: - RelocatableDictItem() {init(0,0,0,0); } - RelocatableDictItem(quint8 rld, quint8 fo_low, quint8 fo_hi, quint8 lbsym) { - init(rld,fo_low, fo_hi,lbsym); - } - RelocatableDictItem(quint8 rld, quint16 fo, quint8 lbsym) { - init(rld,fo,lbsym); - } - - void init(quint8 rld, quint8 fo_low, quint8 fo_hi, quint8 lbsym) { - m_rld_flag = rld; - m_halfword_or_sym_num = lbsym; - m_field_offset = makeWord(fo_low,fo_hi); - } - - void init(quint8 rld, quint16 fo, quint8 lbsym) { - m_rld_flag = rld; - m_halfword_or_sym_num = lbsym; - m_field_offset = fo; - } - - FieldSize getFieldSize() { return (m_rld_flag & 0x80)?RFS2Byte:RFS1Byte; } - WordUpperLower getWordBytePos() { return (m_rld_flag & 0x40)?ULIsHighByte:ULIsLowByte; } - Endianness getEndianness() { return (m_rld_flag & 0x20)?HiLow:LowHi; } - bool isExtern() { return (m_rld_flag & 0x10); } - bool isNotEndOfRLD() { return (m_rld_flag & 0x01); } - bool isEndOfRLD() { return !(m_rld_flag & 0x01); } - - Byte4ReturnType getByte4() { - Byte4ReturnType retval; - - if (isExtern()) { - retval.first = ESDSymbol; - } else if (getWordBytePos() == ULIsHighByte) { - retval.first = ByteHi; - } else { - retval.first = ByteLo; - } - - retval.second = m_halfword_or_sym_num; - - return retval; - } - - quint16 getFieldOffset() { return m_field_offset; } - - quint8 getRLDFlag() { return m_rld_flag; } - quint8 getRawHalfWordOrSymNum() { return m_halfword_or_sym_num; } - -private: - - quint8 m_rld_flag; - quint16 m_field_offset; - quint8 m_halfword_or_sym_num; - -}; - - - -class RelocatableFile : public GenericFile -{ -public: - - RelocatableFile(QByteArray data = QByteArray()); - void setData(QByteArray data); - - virtual quint16 length() { return m_data.length(); } - - void dump(); - - QByteArray getBinaryCodeImage() { return m_binary_code_image; } - QList getRelocatableDict() { return m_relocatable_dict; } - - quint16 address() { return m_starting_ram_address; } - quint16 codeImageLength() { return m_code_image_length; } - - QStringList decodeRelocatableDict(); - -protected: - quint16 m_starting_ram_address; - quint16 m_ram_image_length; - quint16 m_code_image_length; - - QByteArray m_binary_code_image; - - QList m_relocatable_dict; - - -}; - -#endif +#ifndef RELOCATABLEFILE_H +#define RELOCATABLEFILE_H + +#include +#include + +#include "genericfile.h" +#include "util.h" + + +typedef enum { RFS1Byte, RFS2Byte } FieldSize; +typedef enum { ULIsHighByte, ULIsLowByte } WordUpperLower; +typedef enum { LowHi, HiLow } Endianness; +typedef enum { ByteLo, ByteHi, ESDSymbol } Byte4Type; + +typedef QPair Byte4ReturnType; + +class RelocatableDictItem { +public: + RelocatableDictItem() {init(0,0,0,0); } + RelocatableDictItem(quint8 rld, quint8 fo_low, quint8 fo_hi, quint8 lbsym) { + init(rld,fo_low, fo_hi,lbsym); + } + RelocatableDictItem(quint8 rld, quint16 fo, quint8 lbsym) { + init(rld,fo,lbsym); + } + + void init(quint8 rld, quint8 fo_low, quint8 fo_hi, quint8 lbsym) { + m_rld_flag = rld; + m_halfword_or_sym_num = lbsym; + m_field_offset = makeWord(fo_low,fo_hi); + } + + void init(quint8 rld, quint16 fo, quint8 lbsym) { + m_rld_flag = rld; + m_halfword_or_sym_num = lbsym; + m_field_offset = fo; + } + + FieldSize getFieldSize() { return (m_rld_flag & 0x80)?RFS2Byte:RFS1Byte; } + WordUpperLower getWordBytePos() { return (m_rld_flag & 0x40)?ULIsHighByte:ULIsLowByte; } + Endianness getEndianness() { return (m_rld_flag & 0x20)?HiLow:LowHi; } + bool isExtern() { return (m_rld_flag & 0x10); } + bool isNotEndOfRLD() { return (m_rld_flag & 0x01); } + bool isEndOfRLD() { return !(m_rld_flag & 0x01); } + + Byte4ReturnType getByte4() { + Byte4ReturnType retval; + + if (isExtern()) { + retval.first = ESDSymbol; + } else if (getWordBytePos() == ULIsHighByte) { + retval.first = ByteHi; + } else { + retval.first = ByteLo; + } + + retval.second = m_halfword_or_sym_num; + + return retval; + } + + quint16 getFieldOffset() { return m_field_offset; } + + quint8 getRLDFlag() { return m_rld_flag; } + quint8 getRawHalfWordOrSymNum() { return m_halfword_or_sym_num; } + +private: + + quint8 m_rld_flag; + quint16 m_field_offset; + quint8 m_halfword_or_sym_num; + +}; + + + +class RelocatableFile : public GenericFile +{ +public: + + RelocatableFile(QByteArray data = QByteArray()); + void setData(QByteArray data); + + virtual quint16 length() { return m_data.length(); } + + void dump(); + + QByteArray getBinaryCodeImage() { return m_binary_code_image; } + QList getRelocatableDict() { return m_relocatable_dict; } + + quint16 address() { return m_starting_ram_address; } + quint16 codeImageLength() { return m_code_image_length; } + + QStringList decodeRelocatableDict(); + +protected: + quint16 m_starting_ram_address; + quint16 m_ram_image_length; + quint16 m_code_image_length; + + QByteArray m_binary_code_image; + + QList m_relocatable_dict; + + +}; + +#endif diff --git a/src/textfile/textfile.cxx b/src/textfile/textfile.cxx index 7aaa458..7fb65ff 100644 --- a/src/textfile/textfile.cxx +++ b/src/textfile/textfile.cxx @@ -1,18 +1,18 @@ -#include -#include "textfile.h" - -TextFile::TextFile(QByteArray data) : GenericFile(data) -{ - if (!data.isEmpty()) { - setData(data); - } -} - -void TextFile::setData(QByteArray data) -{ - m_data = data; -} - -void TextFile::dump() -{ -} +#include +#include "textfile.h" + +TextFile::TextFile(QByteArray data) : GenericFile(data) +{ + if (!data.isEmpty()) { + setData(data); + } +} + +void TextFile::setData(QByteArray data) +{ + m_data = data; +} + +void TextFile::dump() +{ +} diff --git a/src/textfile/textfile.h b/src/textfile/textfile.h index 35f24fc..5de2518 100644 --- a/src/textfile/textfile.h +++ b/src/textfile/textfile.h @@ -1,17 +1,17 @@ -#ifndef TEXTFILE_H -#define TEXTFILE_H - -#include "genericfile.h" - -class TextFile : public GenericFile -{ -public: - TextFile(QByteArray data = QByteArray()); - void setData(QByteArray data); - - void dump(); - -protected: -}; - -#endif // TEXTFILE_H +#ifndef TEXTFILE_H +#define TEXTFILE_H + +#include "genericfile.h" + +class TextFile : public GenericFile +{ +public: + TextFile(QByteArray data = QByteArray()); + void setData(QByteArray data); + + void dump(); + +protected: +}; + +#endif // TEXTFILE_H diff --git a/src/ui/catalogwidget.cxx b/src/ui/catalogwidget.cxx index ae84ab7..3b22b02 100644 --- a/src/ui/catalogwidget.cxx +++ b/src/ui/catalogwidget.cxx @@ -1,167 +1,170 @@ -#include "catalogwidget.h" -#include "ui_catalogwidget.h" -#include "filedescriptiveentry.h" -#include "binaryfile.h" -#include "applesoftfile.h" -#include "genericfile.h" -#include -#include -#include -#include -#include - -CatalogWidget::CatalogWidget(QWidget *parent) : - QWidget(parent), - ui(new Ui::CatalogWidget) -{ - ui->setupUi(this); - ui->catalog_list->setFont(QFont("monospace")); - ui->noteButton->setText(QChar(0x270d)); - ui->noteButton->setFont(QFont("sans",16,QFont::Bold)); - - connect(ui->catalog_list, &QListWidget::itemDoubleClicked, - this, &CatalogWidget::itemDoubleClicked); -} - -CatalogWidget::~CatalogWidget() -{ - delete ui; -} - -void CatalogWidget::prepForNewDisk(QString filename, DiskFile *disk) -{ - m_disk = disk; - m_diskname = filename; -} - -QString CatalogWidget::createToolTip(FileDescriptiveEntry &fde) { - QString retval; - retval += AppleString(fde.filename).printable().trimmed() + "\n"; - retval += QString("Type: %1\n").arg(fde.fileType()); - retval += QString("Sectors: %1 (%2 bytes)\n") - .arg(fde.lengthInSectors) - .arg(fde.lengthInSectors*256); - retval += QString("%1\n").arg(fde.isLocked()?"Locked":"Unlocked"); - - GenericFile *file = m_disk->getFile(fde); - quint16 address = file->address(); - retval += QString("Address: $%1 (%2)\n").arg((quint16) (address),4,16,QChar('0')) - .arg(address); - - if (dynamic_cast(file)) { - BinaryFile *binfile = dynamic_cast(file); - quint16 length = binfile->length(); - - retval += QString("Length: $%1 (%2)\n").arg((quint16) (length),4,16,QChar('0')) - .arg(length); - } else if (dynamic_cast(file)) { - ApplesoftFile *asfile = dynamic_cast(file); - quint16 length = asfile->length(); - retval += QString("Length: $%1 (%2)\n").arg((quint16) (length),4,16,QChar('0')) - .arg(length); - quint16 uabytes = asfile->extraData().length(); - if (uabytes) { - retval += QString("Unaccounted Bytes: $%1 (%2)\n").arg((quint16) (uabytes),4,16,QChar('0')) - .arg(uabytes); - } - } else { - retval += QString("Data Length: $%1 (%2)\n").arg((quint16) (file->data().length()),4,16,QChar('0')) - .arg(file->data().length()); - } - - return retval; -} - -void CatalogWidget::processNewlyLoadedDisk(QString diskfilename, DiskFile *disk) -{ - if (m_disk == disk) { - QUrl url = QUrl::fromLocalFile(diskfilename); - QString shortfilename = url.fileName(); - QFontMetrics fm(ui->catalog_list->font()); - QRect maxrect; - ui->volume_label->setText(shortfilename); - int idx = 0; - foreach(FileDescriptiveEntry fde, m_disk->getAllFDEs()) { - QString filetype = fde.fileType(); - QString filename = AppleString(fde.filename).printable().trimmed(); - quint16 size = fde.lengthInSectors; - bool locked = fde.isLocked(); - QString sizeStr = QString("%1").arg(size,5,10,QChar(' ')).toUpper(); - QString text = QString("%1 %2 %3 %4").arg(locked?"*":" ").arg(sizeStr).arg(filetype).arg(filename); - QListWidgetItem *item = new QListWidgetItem(text); - - if (filetype == "A") { item->setForeground(Qt::blue); } - else if (filetype == "I") { item->setForeground(Qt::darkYellow); } - else if (filetype == "B") { item->setForeground(Qt::darkGreen); } - else if (filetype == "T") { item->setForeground(Qt::red); } - else if (filetype == "R") { item->setForeground(Qt::darkRed); } - else if (filetype == "S") { item->setForeground(Qt::magenta); } - else if (filetype == "a") { item->setForeground(Qt::darkBlue); } - else if (filetype == "b") { item->setForeground(Qt::darkMagenta); } - else { item->setForeground(Qt::black); } - - item->setToolTip(createToolTip(fde)); - item->setData(0x0100,idx); - ui->catalog_list->addItem(item); - QRect rect = fm.boundingRect(text); - if (rect.width() > maxrect.width()) { - maxrect = rect; - } - idx++; - } -// QFont italfont = ui->catalog_list->font(); -// italfont.setItalic(true); -// QListWidgetItem *item = new QListWidgetItem("Boot Sector"); -// item->setForeground(Qt::black); -// item->setFont(italfont); -// item->setData(0x0100,-1); -// ui->catalog_list->addItem(item); - -// item = new QListWidgetItem("DOS Image"); -// item->setForeground(Qt::black); -// item->setFont(italfont); -// item->setData(0x0100,-2); -// ui->catalog_list->addItem(item); - - ui->catalog_list->resize(maxrect.width(),ui->catalog_list->size().height()); - } -} - -void CatalogWidget::unloadDisk(DiskFile *disk) -{ - if (m_disk == disk) { - m_disk = 0; - } - ui->catalog_list->clear(); - ui->volume_label->clear(); -} - -void CatalogWidget::itemDoubleClicked(QListWidgetItem *item) -{ - int idx = item->data(0x0100).toInt(); - if (idx >= 0) - { - FileDescriptiveEntry fde = m_disk->getAllFDEs()[idx]; - // qDebug() << "Default File " << AppleString(fde.filename).printable().trimmed(); - emit openWithDefaultViewer(m_disk,fde); - } - else - { - if (idx == -1) // Boot Sector - { - - } - else if (idx == -2) // DOS Image - { - - } - } -} - -void CatalogWidget::itemClicked(QListWidgetItem *item) -{ - int idx = item->data(0x0100).toInt(); - FileDescriptiveEntry fde = m_disk->getAllFDEs()[idx]; - // qDebug() << "Default File " << AppleString(fde.filename).printable().trimmed(); - emit newFileSelected(m_disk,fde); -} +#include "catalogwidget.h" +#include "ui_catalogwidget.h" +#include "filedescriptiveentry.h" +#include "binaryfile.h" +#include "applesoftfile.h" +#include "genericfile.h" +#include "IntBasicFile.h" +#include +#include +#include +#include +#include + +CatalogWidget::CatalogWidget(QWidget *parent) : + QWidget(parent), + ui(new Ui::CatalogWidget) +{ + ui->setupUi(this); + QFont catalogFont; + catalogFont.setStyleHint(QFont::Monospace); + ui->catalog_list->setFont(catalogFont); + ui->noteButton->setText(QChar(0x270d)); + ui->noteButton->setFont(QFont("sans",16,QFont::Bold)); + + connect(ui->catalog_list, &QListWidget::itemDoubleClicked, + this, &CatalogWidget::itemDoubleClicked); +} + +CatalogWidget::~CatalogWidget() +{ + delete ui; +} + +void CatalogWidget::prepForNewDisk(QString filename, DiskFile *disk) +{ + m_disk = disk; + m_diskname = filename; +} + +QString CatalogWidget::createToolTip(FileDescriptiveEntry &fde) { + QString retval; + retval += AppleString(fde.filename).printable().trimmed() + "\n"; + retval += QString("Type: %1\n").arg(fde.fileType()); + retval += QString("Sectors: %1 (%2 bytes)\n") + .arg(fde.lengthInSectors) + .arg(fde.lengthInSectors*256); + retval += QString("%1\n").arg(fde.isLocked()?"Locked":"Unlocked"); + + GenericFile *file = m_disk->getFile(fde); + quint16 address = file->address(); + retval += QString("Address: $%1 (%2)\n").arg((quint16) (address),4,16,QChar('0')) + .arg(address); + + if (dynamic_cast(file)) { + BinaryFile *binfile = dynamic_cast(file); + quint16 length = binfile->length(); + + retval += QString("Length: $%1 (%2)\n").arg((quint16) (length),4,16,QChar('0')) + .arg(length); + } else if (dynamic_cast(file)) { + ApplesoftFile *asfile = dynamic_cast(file); + quint16 length = asfile->length(); + retval += QString("Length: $%1 (%2)\n").arg((quint16) (length),4,16,QChar('0')) + .arg(length); + quint16 uabytes = asfile->extraData().length(); + if (uabytes) { + retval += QString("Unaccounted Bytes: $%1 (%2)\n").arg((quint16) (uabytes),4,16,QChar('0')) + .arg(uabytes); + } + } else { + retval += QString("Data Length: $%1 (%2)\n").arg((quint16) (file->data().length()),4,16,QChar('0')) + .arg(file->data().length()); + } + + return retval; +} + +void CatalogWidget::processNewlyLoadedDisk(QString diskfilename, DiskFile *disk) +{ + if (m_disk == disk) { + QUrl url = QUrl::fromLocalFile(diskfilename); + QString shortfilename = url.fileName(); + QFontMetrics fm(ui->catalog_list->font()); + QRect maxrect; + ui->volume_label->setText(shortfilename); + int idx = 0; + foreach(FileDescriptiveEntry fde, m_disk->getAllFDEs()) { + QString filetype = fde.fileType(); + QString filename = AppleString(fde.filename).printable().trimmed(); + quint16 size = fde.lengthInSectors; + bool locked = fde.isLocked(); + QString sizeStr = QString("%1").arg(size,5,10,QChar(' ')).toUpper(); + QString text = QString("%1 %2 %3 %4").arg(locked?"*":" ").arg(sizeStr).arg(filetype).arg(filename); + QListWidgetItem *item = new QListWidgetItem(text); + + if (filetype == "A") { item->setForeground(Qt::blue); } + else if (filetype == "I") { item->setForeground(Qt::darkYellow); } + else if (filetype == "B") { item->setForeground(Qt::darkGreen); } + else if (filetype == "T") { item->setForeground(Qt::red); } + else if (filetype == "R") { item->setForeground(Qt::darkRed); } + else if (filetype == "S") { item->setForeground(Qt::magenta); } + else if (filetype == "a") { item->setForeground(Qt::darkBlue); } + else if (filetype == "b") { item->setForeground(Qt::darkMagenta); } + else { item->setForeground(Qt::black); } + + item->setToolTip(createToolTip(fde)); + item->setData(0x0100,idx); + ui->catalog_list->addItem(item); + QRect rect = fm.boundingRect(text); + if (rect.width() > maxrect.width()) { + maxrect = rect; + } + idx++; + } +// QFont italfont = ui->catalog_list->font(); +// italfont.setItalic(true); +// QListWidgetItem *item = new QListWidgetItem("Boot Sector"); +// item->setForeground(Qt::black); +// item->setFont(italfont); +// item->setData(0x0100,-1); +// ui->catalog_list->addItem(item); + +// item = new QListWidgetItem("DOS Image"); +// item->setForeground(Qt::black); +// item->setFont(italfont); +// item->setData(0x0100,-2); +// ui->catalog_list->addItem(item); + + ui->catalog_list->resize(maxrect.width(),ui->catalog_list->size().height()); + } +} + +void CatalogWidget::unloadDisk(DiskFile *disk) +{ + if (m_disk == disk) { + m_disk = 0; + } + ui->catalog_list->clear(); + ui->volume_label->clear(); +} + +void CatalogWidget::itemDoubleClicked(QListWidgetItem *item) +{ + int idx = item->data(0x0100).toInt(); + if (idx >= 0) + { + FileDescriptiveEntry fde = m_disk->getAllFDEs()[idx]; + // qDebug() << "Default File " << AppleString(fde.filename).printable().trimmed(); + emit openWithDefaultViewer(m_disk,fde); + } + else + { + if (idx == -1) // Boot Sector + { + + } + else if (idx == -2) // DOS Image + { + + } + } +} + +void CatalogWidget::itemClicked(QListWidgetItem *item) +{ + int idx = item->data(0x0100).toInt(); + FileDescriptiveEntry fde = m_disk->getAllFDEs()[idx]; + // qDebug() << "Default File " << AppleString(fde.filename).printable().trimmed(); + emit newFileSelected(m_disk,fde); +} diff --git a/src/ui/catalogwidget.h b/src/ui/catalogwidget.h index dd5a7a2..ec003ad 100644 --- a/src/ui/catalogwidget.h +++ b/src/ui/catalogwidget.h @@ -1,46 +1,46 @@ -#ifndef CATALOGWIDGET_H -#define CATALOGWIDGET_H - -#include -#include - -#include "diskfile.h" - -namespace Ui { -class CatalogWidget; -} - -class CatalogWidget : public QWidget -{ - Q_OBJECT - - -public: - explicit CatalogWidget(QWidget *parent = 0); - ~CatalogWidget(); - -public slots: - void prepForNewDisk(QString filename, DiskFile *disk); - void processNewlyLoadedDisk(QString filename, DiskFile *disk); - void unloadDisk(DiskFile *disk); - -signals: - void newFileSelected(DiskFile *disk, FileDescriptiveEntry entry); - void openWithDefaultViewer(DiskFile *disk, FileDescriptiveEntry fde); - -protected: - QString createToolTip(FileDescriptiveEntry &fde); - -private slots: - void itemClicked(QListWidgetItem *item); - void itemDoubleClicked(QListWidgetItem *item); - -private: - - Ui::CatalogWidget *ui; - - DiskFile *m_disk; - QString m_diskname; -}; - -#endif // CATALOGWIDGET_H +#ifndef CATALOGWIDGET_H +#define CATALOGWIDGET_H + +#include +#include + +#include "diskfile.h" + +namespace Ui { +class CatalogWidget; +} + +class CatalogWidget : public QWidget +{ + Q_OBJECT + + +public: + explicit CatalogWidget(QWidget *parent = 0); + ~CatalogWidget(); + +public slots: + void prepForNewDisk(QString filename, DiskFile *disk); + void processNewlyLoadedDisk(QString filename, DiskFile *disk); + void unloadDisk(DiskFile *disk); + +signals: + void newFileSelected(DiskFile *disk, FileDescriptiveEntry entry); + void openWithDefaultViewer(DiskFile *disk, FileDescriptiveEntry fde); + +protected: + QString createToolTip(FileDescriptiveEntry &fde); + +private slots: + void itemClicked(QListWidgetItem *item); + void itemDoubleClicked(QListWidgetItem *item); + +private: + + Ui::CatalogWidget *ui; + + DiskFile *m_disk; + QString m_diskname; +}; + +#endif // CATALOGWIDGET_H diff --git a/src/ui/catalogwidget.ui b/src/ui/catalogwidget.ui index c9ea5a9..707963e 100644 --- a/src/ui/catalogwidget.ui +++ b/src/ui/catalogwidget.ui @@ -1,109 +1,109 @@ - - - CatalogWidget - - - - 0 - 0 - 328 - 560 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - Courier 10 Pitch - 10 - - - - Form - - - - 2 - - - 2 - - - 2 - - - 2 - - - 2 - - - - - 2 - - - - - 4 - - - - - - Sans Serif - 12 - - - - TextLabel - - - - - - - - Sans Serif - - - - Notes for image. - - - - - - - - - - - - false - - - true - - - false - - - - - - - - - - + + + CatalogWidget + + + + 0 + 0 + 328 + 560 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + Courier 10 Pitch + 10 + + + + Form + + + + 2 + + + 2 + + + 2 + + + 2 + + + 2 + + + + + 2 + + + + + 4 + + + + + + Sans Serif + 12 + + + + TextLabel + + + + + + + + Sans Serif + + + + Notes for image. + + + + + + + + + + + + false + + + true + + + false + + + + + + + + + + diff --git a/src/ui/diskexplorer/DiskExplorer.cpp b/src/ui/diskexplorer/DiskExplorer.cpp index 0bbb643..177803d 100644 --- a/src/ui/diskexplorer/DiskExplorer.cpp +++ b/src/ui/diskexplorer/DiskExplorer.cpp @@ -1,266 +1,266 @@ -#include "DiskExplorer.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "genericfile.h" -#include "viewerbase.h" - -DiskExplorer::DiskExplorer(QWidget *parent) : QMainWindow(parent) -{ - m_action_Unload_Disk_Image = 0; - m_disk = 0; - m_horizSizePref = -1; - m_toolsHidden = true; - - resize(300,800); - initUi(); -} - -DiskExplorer::~DiskExplorer() -{ -} - -void DiskExplorer::initUi() -{ - QMenuBar *menuBar = new QMenuBar(this); - setMenuBar(menuBar); - QMenu *menu = new QMenu(tr("&File"),this); - menuBar->addMenu(menu); - - QAction *action_Load_Disk_Image = new QAction(tr("&Load Disk Image..."),this); - menu->addAction(action_Load_Disk_Image); - - connect(action_Load_Disk_Image, &QAction::triggered, - this, &DiskExplorer::showLoadDialog); - - m_action_Unload_Disk_Image = new QAction(tr("&Unload Disk Image"),this); - m_action_Unload_Disk_Image->setEnabled(false); - menu->addAction(m_action_Unload_Disk_Image); - - connect(m_action_Unload_Disk_Image, &QAction::triggered, - this, &DiskExplorer::unloadDiskFile); - - menu->addSeparator(); - - QAction *action_Quit = new QAction(tr("&Quit"),this); - menu->addAction(action_Quit); - - connect(action_Quit, &QAction::triggered, qApp, &QApplication::quit); - - menu = new QMenu(tr("&Util"),this); - menuBar->addMenu(menu); - - QAction *action_Hex_Converter = new QAction(tr("&Hex Converter..."),this); - menu->addAction(action_Hex_Converter); - - menu->addSeparator(); - - m_setDiskToolsVisibleAction = new QAction(tr("Show &Disk tools"),this); - m_setDiskToolsVisibleAction->setCheckable(true); - m_setDiskToolsVisibleAction->setChecked(false); - - connect(m_setDiskToolsVisibleAction, &QAction::triggered, this, &DiskExplorer::setDiskToolsVisible); - - menu->addAction(m_setDiskToolsVisibleAction); - - - menu = new QMenu(tr("&Misc"),this); - menuBar->addMenu(menu); - - QAction *action_HRCG_Commands = new QAction(tr("&HRCG Commands..."),this); - menu->addAction(action_HRCG_Commands); - m_hrcgDialog = new HRCGControlsInfo(this); - connect(action_HRCG_Commands, &QAction::triggered, m_hrcgDialog, &HRCGControlsInfo::show); - - m_hexConverter = new HexConverter(this); - connect(action_Hex_Converter, &QAction::triggered, m_hexConverter, &HexConverter::show); - - QAction *action_Ascii_Info = new QAction(tr("&ASCII Table..."),this); - menu->addAction(action_Ascii_Info); - m_AsciiInfoDialog = new AsciiInfoDialog(this); - connect(action_Ascii_Info, &QAction::triggered, m_AsciiInfoDialog, &AsciiInfoDialog::show); - - - QWidget *widget = new QWidget(0); - m_gridLayout = new QGridLayout(); - m_gridLayout->setVerticalSpacing(4); - m_gridLayout->setHorizontalSpacing(4); - widget->setLayout(m_gridLayout); - m_cw = new CatalogWidget(widget); - m_demw = new DiskExplorerMapWidget(35,16,widget); - m_frame = new QFrame(widget); - m_frame->setFrameStyle(QFrame::Raised); - m_frame->setMinimumSize(200,200); - QGridLayout *frameLayout = new QGridLayout(0); - m_frame->setLayout(frameLayout); - m_hdv = new HexDumpViewer(this); - frameLayout->addWidget(m_hdv); - - m_gridLayout->setColumnStretch(0,4); - m_gridLayout->setColumnStretch(1,1); - m_gridLayout->setColumnStretch(2,4); - - m_gridLayout->addWidget(m_cw,0,0,2,1); - m_gridLayout->addWidget(m_demw,0,1,1,2); - m_key = m_demw->makeKeyWidget(); - m_gridLayout->addWidget(m_key,1,1); - m_gridLayout->addWidget(m_frame,1,2); - this->setCentralWidget(widget); - - connect(m_cw, &CatalogWidget::openWithDefaultViewer, - this, &DiskExplorer::handleDiskItemSelectedDefaultOpen); - connect(m_demw, &DiskExplorerMapWidget::showSectorData, - this, &DiskExplorer::handleShowSectorData); - - QStatusBar *statusBar = new QStatusBar(this); - setStatusBar(statusBar); - - m_demwStatusWidget = m_demw->getStatusWidget(); - statusBar->addPermanentWidget(m_demwStatusWidget); - - setDiskToolsVisible(false); -} - - -void DiskExplorer::unloadDiskFile() -{ - if (m_disk) - { - m_cw->unloadDisk(m_disk); - m_demw->unloadDisk(); - m_hdv->setRawData(QByteArray(),0); - } -} - -void DiskExplorer::loadDiskFile(QString filename) -{ - if (m_disk) { - unloadDiskFile(); - } - - m_disk = new DiskFile(); - m_cw->prepForNewDisk(filename,m_disk); - if (m_disk->read(filename)) { - m_action_Unload_Disk_Image->setEnabled(true); - QSettings settings; - settings.setValue("lastOpened",filename); - m_cw->processNewlyLoadedDisk(filename,m_disk); - m_demw->setDisk(m_disk); - } else { - emit diskFileLoadFailed(filename,m_disk); - delete m_disk; - m_disk = 0; - } -} - -void DiskExplorer::handleShowSectorData(QByteArray data, int track, int sector, QVariant metadata) -{ - Q_UNUSED(track) - Q_UNUSED(sector) - Q_UNUSED(metadata) - m_hdv->setRawData(data,0); -} - -void DiskExplorer::showLoadDialog() -{ - QSettings settings; - QString last = settings.value("lastOpened",".").toString(); - QString filename = QFileDialog::getOpenFileName(this, - tr("Open Disk Image"), - last, - "Disk Images (*.do *.dsk)"); - if (!filename.isEmpty()) { - loadDiskFile(filename); - } -} - -void DiskExplorer::handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescriptiveEntry fde) -{ - GenericFile *file = disk->getFile(fde); - file->setFilename(AppleString(fde.filename).printable().trimmed()); - - ViewerBase *vb = new ViewerBase(); - qDebug() << "Adding viewer" << vb; - m_viewerList.append(vb); - - connect(vb,&ViewerBase::viewerClosing, - this, &DiskExplorer::handleViewerClosing); - vb->setFile(file); - vb->show(); -} - -void DiskExplorer::setDiskToolsVisible(bool visible) -{ - m_toolsHidden = !visible; - if (visible) - { - m_gridLayout->setColumnStretch(0,4); - m_gridLayout->setColumnStretch(1,1); - m_gridLayout->setColumnStretch(2,4); - } - else - { - m_gridLayout->setColumnStretch(0,0); - m_gridLayout->setColumnStretch(1,0); - m_gridLayout->setColumnStretch(2,0); - } - - if (m_demwStatusWidget) { m_demwStatusWidget->setVisible(visible); } - - m_demw->setVisible(visible); - m_frame->setVisible(visible); - m_hdv->setVisible(visible); - m_key->setVisible(visible); - - if (!visible) - { - QTimer::singleShot(100, this, SLOT(doResize())); - } -} - -void DiskExplorer::handleViewerClosing(ViewerBase *viewer) -{ - qDebug() << "Removing viewer " << viewer; - m_viewerList.removeAll(viewer); -} - -void DiskExplorer::doResize() -{ - resize(m_horizSizePref, this->height()); -} - -void DiskExplorer::showEvent(QShowEvent *event) -{ - Q_UNUSED(event); - if (m_horizSizePref == -1) - { - m_horizSizePref = this->width(); - } -} - -void DiskExplorer::closeEvent(QCloseEvent *) -{ - foreach (ViewerBase *viewer, m_viewerList) - { - if (viewer) - { - viewer->deleteLater(); - } - } -} - -void DiskExplorer::resizeEvent(QResizeEvent *) -{ - if (m_toolsHidden) - { - m_horizSizePref = this->width(); - } -} - +#include "DiskExplorer.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "genericfile.h" +#include "viewerbase.h" + +DiskExplorer::DiskExplorer(QWidget *parent) : QMainWindow(parent) +{ + m_action_Unload_Disk_Image = 0; + m_disk = 0; + m_horizSizePref = -1; + m_toolsHidden = true; + + resize(300,800); + initUi(); +} + +DiskExplorer::~DiskExplorer() +{ +} + +void DiskExplorer::initUi() +{ + QMenuBar *menuBar = new QMenuBar(this); + setMenuBar(menuBar); + QMenu *menu = new QMenu(tr("&File"),this); + menuBar->addMenu(menu); + + QAction *action_Load_Disk_Image = new QAction(tr("&Load Disk Image..."),this); + menu->addAction(action_Load_Disk_Image); + + connect(action_Load_Disk_Image, &QAction::triggered, + this, &DiskExplorer::showLoadDialog); + + m_action_Unload_Disk_Image = new QAction(tr("&Unload Disk Image"),this); + m_action_Unload_Disk_Image->setEnabled(false); + menu->addAction(m_action_Unload_Disk_Image); + + connect(m_action_Unload_Disk_Image, &QAction::triggered, + this, &DiskExplorer::unloadDiskFile); + + menu->addSeparator(); + + QAction *action_Quit = new QAction(tr("&Quit"),this); + menu->addAction(action_Quit); + + connect(action_Quit, &QAction::triggered, qApp, &QApplication::quit); + + menu = new QMenu(tr("&Util"),this); + menuBar->addMenu(menu); + + QAction *action_Hex_Converter = new QAction(tr("&Hex Converter..."),this); + menu->addAction(action_Hex_Converter); + + menu->addSeparator(); + + m_setDiskToolsVisibleAction = new QAction(tr("Show &Disk tools"),this); + m_setDiskToolsVisibleAction->setCheckable(true); + m_setDiskToolsVisibleAction->setChecked(false); + + connect(m_setDiskToolsVisibleAction, &QAction::triggered, this, &DiskExplorer::setDiskToolsVisible); + + menu->addAction(m_setDiskToolsVisibleAction); + + + menu = new QMenu(tr("&Misc"),this); + menuBar->addMenu(menu); + + QAction *action_HRCG_Commands = new QAction(tr("&HRCG Commands..."),this); + menu->addAction(action_HRCG_Commands); + m_hrcgDialog = new HRCGControlsInfo(this); + connect(action_HRCG_Commands, &QAction::triggered, m_hrcgDialog, &HRCGControlsInfo::show); + + m_hexConverter = new HexConverter(this); + connect(action_Hex_Converter, &QAction::triggered, m_hexConverter, &HexConverter::show); + + QAction *action_Ascii_Info = new QAction(tr("&ASCII Table..."),this); + menu->addAction(action_Ascii_Info); + m_AsciiInfoDialog = new AsciiInfoDialog(this); + connect(action_Ascii_Info, &QAction::triggered, m_AsciiInfoDialog, &AsciiInfoDialog::show); + + + QWidget *widget = new QWidget(0); + m_gridLayout = new QGridLayout(); + m_gridLayout->setVerticalSpacing(4); + m_gridLayout->setHorizontalSpacing(4); + widget->setLayout(m_gridLayout); + m_cw = new CatalogWidget(widget); + m_demw = new DiskExplorerMapWidget(35,16,widget); + m_frame = new QFrame(widget); + m_frame->setFrameStyle(QFrame::Raised); + m_frame->setMinimumSize(200,200); + QGridLayout *frameLayout = new QGridLayout(0); + m_frame->setLayout(frameLayout); + m_hdv = new HexDumpViewer(this); + frameLayout->addWidget(m_hdv); + + m_gridLayout->setColumnStretch(0,4); + m_gridLayout->setColumnStretch(1,1); + m_gridLayout->setColumnStretch(2,4); + + m_gridLayout->addWidget(m_cw,0,0,2,1); + m_gridLayout->addWidget(m_demw,0,1,1,2); + m_key = m_demw->makeKeyWidget(); + m_gridLayout->addWidget(m_key,1,1); + m_gridLayout->addWidget(m_frame,1,2); + this->setCentralWidget(widget); + + connect(m_cw, &CatalogWidget::openWithDefaultViewer, + this, &DiskExplorer::handleDiskItemSelectedDefaultOpen); + connect(m_demw, &DiskExplorerMapWidget::showSectorData, + this, &DiskExplorer::handleShowSectorData); + + QStatusBar *statusBar = new QStatusBar(this); + setStatusBar(statusBar); + + m_demwStatusWidget = m_demw->getStatusWidget(); + statusBar->addPermanentWidget(m_demwStatusWidget); + + setDiskToolsVisible(false); +} + + +void DiskExplorer::unloadDiskFile() +{ + if (m_disk) + { + m_cw->unloadDisk(m_disk); + m_demw->unloadDisk(); + m_hdv->setRawData(QByteArray(),0); + } +} + +void DiskExplorer::loadDiskFile(QString filename) +{ + if (m_disk) { + unloadDiskFile(); + } + + m_disk = new DiskFile(); + m_cw->prepForNewDisk(filename,m_disk); + if (m_disk->read(filename)) { + m_action_Unload_Disk_Image->setEnabled(true); + QSettings settings; + settings.setValue("lastOpened",filename); + m_cw->processNewlyLoadedDisk(filename,m_disk); + m_demw->setDisk(m_disk); + } else { + emit diskFileLoadFailed(filename,m_disk); + delete m_disk; + m_disk = 0; + } +} + +void DiskExplorer::handleShowSectorData(QByteArray data, int track, int sector, QVariant metadata) +{ + Q_UNUSED(track) + Q_UNUSED(sector) + Q_UNUSED(metadata) + m_hdv->setRawData(data,0); +} + +void DiskExplorer::showLoadDialog() +{ + QSettings settings; + QString last = settings.value("lastOpened",".").toString(); + QString filename = QFileDialog::getOpenFileName(this, + tr("Open Disk Image"), + last, + "Disk Images (*.do *.dsk)"); + if (!filename.isEmpty()) { + loadDiskFile(filename); + } +} + +void DiskExplorer::handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescriptiveEntry fde) +{ + GenericFile *file = disk->getFile(fde); + file->setFilename(AppleString(fde.filename).printable().trimmed()); + + ViewerBase *vb = new ViewerBase(); + qDebug() << "Adding viewer" << vb; + m_viewerList.append(vb); + + connect(vb,&ViewerBase::viewerClosing, + this, &DiskExplorer::handleViewerClosing); + vb->setFile(file); + vb->show(); +} + +void DiskExplorer::setDiskToolsVisible(bool visible) +{ + m_toolsHidden = !visible; + if (visible) + { + m_gridLayout->setColumnStretch(0,4); + m_gridLayout->setColumnStretch(1,1); + m_gridLayout->setColumnStretch(2,4); + } + else + { + m_gridLayout->setColumnStretch(0,0); + m_gridLayout->setColumnStretch(1,0); + m_gridLayout->setColumnStretch(2,0); + } + + if (m_demwStatusWidget) { m_demwStatusWidget->setVisible(visible); } + + m_demw->setVisible(visible); + m_frame->setVisible(visible); + m_hdv->setVisible(visible); + m_key->setVisible(visible); + + if (!visible) + { + QTimer::singleShot(100, this, SLOT(doResize())); + } +} + +void DiskExplorer::handleViewerClosing(ViewerBase *viewer) +{ + qDebug() << "Removing viewer " << viewer; + m_viewerList.removeAll(viewer); +} + +void DiskExplorer::doResize() +{ + resize(m_horizSizePref, this->height()); +} + +void DiskExplorer::showEvent(QShowEvent *event) +{ + Q_UNUSED(event); + if (m_horizSizePref == -1) + { + m_horizSizePref = this->width(); + } +} + +void DiskExplorer::closeEvent(QCloseEvent *) +{ + foreach (ViewerBase *viewer, m_viewerList) + { + if (viewer) + { + viewer->deleteLater(); + } + } +} + +void DiskExplorer::resizeEvent(QResizeEvent *) +{ + if (m_toolsHidden) + { + m_horizSizePref = this->width(); + } +} + diff --git a/src/ui/diskexplorer/DiskExplorer.h b/src/ui/diskexplorer/DiskExplorer.h index 8a12a76..1f51cb7 100644 --- a/src/ui/diskexplorer/DiskExplorer.h +++ b/src/ui/diskexplorer/DiskExplorer.h @@ -1,82 +1,82 @@ -#ifndef DISKEXPLORER_H -#define DISKEXPLORER_H - -#include - -#include "catalogwidget.h" -#include "DiskExplorerMapWidget.h" -#include "diskfile.h" -#include "hrcgcontrolsinfo.h" -#include "hexconverter.h" -#include "hexdumpviewer.h" -#include "viewerbase.h" -#include "asciiinfodialog.h" - -#include -#include - - -class DiskExplorer : public QMainWindow -{ - Q_OBJECT -public: - explicit DiskExplorer(QWidget *parent = 0); - virtual ~DiskExplorer(); - -signals: - void diskFileLoading(QString filename, DiskFile *file); - void diskFileLoaded(QString filename, DiskFile *file); - void diskFileLoadFailed(QString filename, DiskFile *file); - void diskFileUnloading(DiskFile *file); - void diskFileUnloaded(); - -public slots: - void unloadDiskFile(); - void loadDiskFile(QString filename); - void showLoadDialog(); - -private slots: - void handleShowSectorData(QByteArray data, int track, int sector, QVariant metadata); - void handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescriptiveEntry fde); - - void setDiskToolsVisible(bool visible); - - void handleViewerClosing(ViewerBase *viewer); -protected: - void initUi(); - - void showEvent(QShowEvent *event); - void closeEvent(QCloseEvent *); - void resizeEvent(QResizeEvent *); - -protected slots: - void doResize(); -private: - QAction *m_setDiskToolsVisibleAction; - - CatalogWidget *m_cw; - DiskExplorerMapWidget *m_demw; - QFrame *m_frame; - HexDumpViewer *m_hdv; - QWidget *m_key; - QGridLayout *m_gridLayout; - - QWidget *m_demwStatusWidget; - - DiskFile *m_disk; - - HRCGControlsInfo *m_hrcgDialog; - HexConverter *m_hexConverter; - AsciiInfoDialog *m_AsciiInfoDialog; - - - QAction *m_action_Unload_Disk_Image; - - int m_horizSizePref; - - QList m_viewerList; - - bool m_toolsHidden; -}; - -#endif // DISKEXPLORER_H +#ifndef DISKEXPLORER_H +#define DISKEXPLORER_H + +#include + +#include "catalogwidget.h" +#include "DiskExplorerMapWidget.h" +#include "diskfile.h" +#include "hrcgcontrolsinfo.h" +#include "hexconverter.h" +#include "hexdumpviewer.h" +#include "viewerbase.h" +#include "asciiinfodialog.h" + +#include +#include + + +class DiskExplorer : public QMainWindow +{ + Q_OBJECT +public: + explicit DiskExplorer(QWidget *parent = 0); + virtual ~DiskExplorer(); + +signals: + void diskFileLoading(QString filename, DiskFile *file); + void diskFileLoaded(QString filename, DiskFile *file); + void diskFileLoadFailed(QString filename, DiskFile *file); + void diskFileUnloading(DiskFile *file); + void diskFileUnloaded(); + +public slots: + void unloadDiskFile(); + void loadDiskFile(QString filename); + void showLoadDialog(); + +private slots: + void handleShowSectorData(QByteArray data, int track, int sector, QVariant metadata); + void handleDiskItemSelectedDefaultOpen(DiskFile *disk, FileDescriptiveEntry fde); + + void setDiskToolsVisible(bool visible); + + void handleViewerClosing(ViewerBase *viewer); +protected: + void initUi(); + + void showEvent(QShowEvent *event); + void closeEvent(QCloseEvent *); + void resizeEvent(QResizeEvent *); + +protected slots: + void doResize(); +private: + QAction *m_setDiskToolsVisibleAction; + + CatalogWidget *m_cw; + DiskExplorerMapWidget *m_demw; + QFrame *m_frame; + HexDumpViewer *m_hdv; + QWidget *m_key; + QGridLayout *m_gridLayout; + + QWidget *m_demwStatusWidget; + + DiskFile *m_disk; + + HRCGControlsInfo *m_hrcgDialog; + HexConverter *m_hexConverter; + AsciiInfoDialog *m_AsciiInfoDialog; + + + QAction *m_action_Unload_Disk_Image; + + int m_horizSizePref; + + QList m_viewerList; + + bool m_toolsHidden; +}; + +#endif // DISKEXPLORER_H diff --git a/src/ui/diskexplorer/DiskExplorerMapWidget.cpp b/src/ui/diskexplorer/DiskExplorerMapWidget.cpp index 1400ee1..6ca28b1 100644 --- a/src/ui/diskexplorer/DiskExplorerMapWidget.cpp +++ b/src/ui/diskexplorer/DiskExplorerMapWidget.cpp @@ -1,373 +1,373 @@ -#include "DiskExplorerMapWidget.h" - -//#include "vtoc.h" -//#include "catalogsector.h" -#include "util.h" - -#include -#include -#include -#include -#include - -DiskExplorerMapWidget::DiskExplorerMapWidget(int numtracks, int numsectors, QWidget *parent) : QWidget(parent) -{ - m_numtracks = numtracks; - m_numsectors = numsectors; - m_diskLabel = Q_NULLPTR; - m_statusWidget = Q_NULLPTR; - - m_deferredSetup = false; - - setWindowTitle("Disk Explorer"); - - m_currentChecked = Q_NULLPTR; - - initColors(); - - QGridLayout *layout = new QGridLayout(); - layout->setSizeConstraint(QLayout::SetFixedSize); - layout->setHorizontalSpacing(2); - layout->setVerticalSpacing(1); - - m_bgroup = new QButtonGroup(this); - - setLayout(layout); - QLabel *tracklabel = new QLabel("Track",this); - layout->addWidget(tracklabel,0,0,1,m_numtracks+1,Qt::AlignHCenter); - for (int track= 0; track < numtracks; track++) - { - QLabel *label = new QLabel(QString("%1").arg(track)); - label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); - layout->addWidget(label,1,track+1); - } - for (int sec = 0; sec < numsectors; sec++) - { - QLabel *label = new QLabel(QString("Sec %1").arg(sec)); - label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); - layout->addWidget(label,sec+2,0); - } - for (int track = 0; track < 35; track++) - { - for (int sec = 0; sec < 16; sec++) - { - DEButton *tb = new DEButton(this,track,sec); - tb->setObjectName(QString("BtnT%1S%2").arg(track).arg(sec)); - tb->setBgColor(m_defaultColor); - tb->setCheckable(true); - m_bgroup->addButton(tb,(track * numsectors) + sec); - connect(tb, &DEButton::checked, this, &DiskExplorerMapWidget::handleButtonCheck); - m_buttons[track][sec] = tb; - - tb->setAutoFillBackground(true); - - layout->addWidget(tb,sec+2,track+1); - } - } - - makeStatusWidget(); -} - -void DiskExplorerMapWidget::makeStatusWidget() -{ - QWidget *statusWidget = new QWidget(this); - QHBoxLayout *hbl = new QHBoxLayout(this); - statusWidget->setLayout(hbl); - - m_trackSectorLabel = new QLabel(this); - m_trackSectorLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); - m_trackSectorLabel->setText("No Track/Sector selected"); - hbl->insertWidget(0,m_trackSectorLabel,0,Qt::AlignLeft | Qt::AlignVCenter); - - m_diskLabel = new QLabel(this); - m_diskLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); - m_diskLabel->setText("[No Disk]"); - hbl->insertWidget(1,m_diskLabel,0,Qt::AlignLeft | Qt::AlignVCenter); - - m_statusWidget = statusWidget; -} - -QString DiskExplorerMapWidget::getSectorDescription(int track, int sector) -{ - if (track == 0) { - return "Boot Sector"; - } - else if (track <= 2) - { - return "DOS Image"; - } - else if (track == 17 && sector == 0) - { - return "VTOC"; - } - else - { - QString desc = "xxx"; - if (m_sectorDescriptions.contains(DETSPair(track,sector))) - { - desc = m_sectorDescriptions[DETSPair(track,sector)]; - } - return desc.simplified(); - } - -} - -void DiskExplorerMapWidget::handleButtonCheck(int track, int sector, bool checked) -{ - DEButton *currbutton = buttonAt(track,sector); - - if (m_currentChecked) - { - // Do anything needed to clean up after previous button click - // m_currentClicked->setHighlighted(false); - } - - if (checked) - { - Sector sec = m_disk->getSector(track,sector); - QByteArray data = sec.rawData(); - emit showSectorData(data,track,sector,QVariant()); - m_trackSectorLabel->setText( - QString("Track: %1 Sector: %2 (%3)") - .arg(track) - .arg(sector) - .arg(getSectorDescription(track,sector))); - } - else{ - emit showSectorData(QByteArray(),-1,-1,QVariant()); - m_trackSectorLabel->setText("No Track/Sector selected"); - } - - m_currentChecked = currbutton; -} - -void DiskExplorerMapWidget::setButtonBgColor(int track, int sector, QColor color) -{ - buttonAt(track,sector)->setBgColor(color); -} - -void DiskExplorerMapWidget::setDisk(DiskFile *disk) -{ - if (disk) - { - m_sectorDescriptions.clear(); - - m_disk = disk; - setWindowTitle(QString("Disk Explorer - %1").arg(m_disk->getDiskImageName())); - m_diskLabel->setText(disk->getDiskImageName()); - - if (!isHidden()) - { - if (m_disk) - { - mapDiskToButtons(); - } - } - else - { - m_deferredSetup = true; - } - } -} - -void DiskExplorerMapWidget::unloadDisk() -{ - if (m_disk) - { - m_sectorDescriptions.clear(); - m_bgroup->setExclusive(false); - for (int track = 0; track < m_numtracks; track++) - { - for (int sec = 0; sec < m_numsectors; sec++) - { - DEButton *button = buttonAt(track,sec); - button->setText(""); - button->setBgColor(m_defaultColor); - button->setChecked(false); - } - } - setAllButtonsEnabled(false); - } -} - -void DiskExplorerMapWidget::setAllButtonsEnabled(bool enabled) -{ - for (int track = 0; track < m_numtracks; track++) - { - for (int sec = 0; sec < m_numsectors; sec++) - { - DEButton *button = buttonAt(track,sec); - button->setEnabled(enabled); - } - } -} - -QLabel *DiskExplorerMapWidget::makeKeyLabel(QWidget *parent, QString name, QColor color) -{ - QLabel *label = new QLabel(name,parent); - label->setStyleSheet(QString("background-color:%1; color: %2") - .arg(color.name()) - .arg(determineFgColor(color).name())); - label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); - return label; -} - -QGroupBox *DiskExplorerMapWidget::makeKeyWidget() -{ - int idx = 0; - QGroupBox *groupbox= new QGroupBox(this); - groupbox->setTitle("Key"); - QGridLayout *layout = new QGridLayout(); - layout->setVerticalSpacing(0); - layout->setHorizontalSpacing(0); - groupbox->setLayout(layout); - - layout->addWidget(makeKeyLabel(groupbox,"Unused Sector",m_defaultColor),idx++,0); - layout->addWidget(makeKeyLabel(groupbox,"Boot Sector",m_bootSectorColor),idx++,0); - layout->addWidget(makeKeyLabel(groupbox,"DOS Image",m_dosImageColor),idx++,0); - layout->addWidget(makeKeyLabel(groupbox,"VTOC",m_vtocColor),idx++,0); - layout->addWidget(makeKeyLabel(groupbox,"Dir Entry",m_dirEntryColor),idx++,0); - layout->addWidget(makeKeyLabel(groupbox,"T/S List",m_tsListColor),idx++,0); - layout->addWidget(makeKeyLabel(groupbox,"Applesoft File",m_applesoftFileColor),idx++,0); - layout->addWidget(makeKeyLabel(groupbox,"Int. Basic File",m_intBasicFileColor),idx++,0); - layout->addWidget(makeKeyLabel(groupbox,"Binary File",m_binaryFileColor),idx++,0); - layout->addWidget(makeKeyLabel(groupbox,"Text File",m_textFileColor),idx++,0); - layout->addWidget(makeKeyLabel(groupbox,"Relocatable File",m_reloFileColor),idx++,0); - layout->addWidget(makeKeyLabel(groupbox,"Type-A File",m_typeAFileColor),idx++,0); - layout->addWidget(makeKeyLabel(groupbox,"Type-B File",m_typeBFileColor),idx++,0); - layout->addWidget(makeKeyLabel(groupbox,"Type-S File",m_typeSFileColor),idx++,0); - - return groupbox; -} - -DEButton *DiskExplorerMapWidget::buttonAt(int track, int sector) -{ - if (track >= m_numtracks || sector >= m_numsectors) - { - if (track >= m_numtracks) { track = 0; } - if (sector >= m_numsectors) { sector = 0; } - qWarning() << "Invalid track/sector for button (" << track << "," << sector << ")"; - } - return m_buttons[track][sector]; -} - -void DiskExplorerMapWidget::initColors() -{ - m_defaultColor = QColor(Qt::lightGray); - m_bootSectorColor = QColor("#20b060"); - m_dosImageColor = QColor("#30d000"); - m_vtocColor = QColor("#efc010"); - m_tsListColor = QColor("#ff8000"); - m_dirEntryColor = QColor("#dfdf00"); - m_applesoftFileColor = QColor("#3030e0"); - m_intBasicFileColor = QColor("#00d0d0"); - m_binaryFileColor = QColor("#d060d0"); - m_textFileColor = QColor("#F05060"); - m_reloFileColor = QColor("#d00000"); - m_typeAFileColor = QColor("#c040a0"); - m_typeBFileColor = QColor("#c03030"); - m_typeSFileColor = QColor("#20a0a0"); -} - -void DiskExplorerMapWidget::mapDiskToButtons() -{ - setAllButtonsEnabled(true); - m_bgroup->setExclusive(false); - - int idx = 0; - for (int track = 0; track < 3; track++) - { - for (int sec = 0; sec < m_numsectors; sec++) - { - if (track == 0) - buttonAt(track,sec)->setBgColor(m_bootSectorColor); - else - buttonAt(track,sec)->setBgColor(m_dosImageColor); - buttonAt(track,sec)->setText(QString("%1").arg(idx++)); - } - } - - buttonAt(17,0)->setBgColor(m_vtocColor); - buttonAt(17,0)->setText(QString("%1").arg(idx++)); - - int catseccount = 0; - foreach (CatalogSector cs, m_disk->getCatalogSectors()) - { - Sector *sec = cs.getSector(); - - QString desc = QString("Catalog Sector #%1").arg(++catseccount); - m_sectorDescriptions.insert(DETSPair(sec->track(),sec->sector()),desc); - - buttonAt(sec->track(),sec->sector())->setBgColor(m_dirEntryColor); - buttonAt(sec->track(),sec->sector())->setText(QString("%1").arg(idx++)); - - foreach(FileDescriptiveEntry fde, cs.getFDEs()) - { - Sector *s = &(m_disk->getSector(fde.firstTSListSector)); - TrackSectorList tsl(s); - - int tsltr = fde.firstTSListSector.track; - int tslse = fde.firstTSListSector.sector; - - int tslcount = 0; - while (tsltr != 0) - { - tslcount++; - buttonAt(tsltr,tslse)->setBgColor(m_tsListColor); - buttonAt(tsltr,tslse)->setText(QString("%1").arg(idx)); - //qDebug() << "Button" << idx << "=" << tsltr << "," << tslse << " " << fde.filename.printable() << "TSL"; - - QString description = QString("T/S List #%1 for %2").arg(tslcount).arg(fde.filename.printable()); - m_sectorDescriptions.insert(DETSPair(tsltr,tslse),description); - - idx++; - - int sectorcount = 0; - foreach(TSPair tsp, tsl.getDataTSPairs()) - { - int se = tsp.sector; - int tr = tsp.track; - - QString description = QString("Sector #%1.%2 of %3") - .arg(tslcount) - .arg(++sectorcount) - .arg(fde.filename.printable()); - m_sectorDescriptions.insert(DETSPair(tr,se),description); - - QColor color; - if (fde.fileType() == "I") color = m_intBasicFileColor; - else if (fde.fileType() == "A") color = m_applesoftFileColor; - else if (fde.fileType() == "R") color = m_reloFileColor; - else if (fde.fileType() == "B") color = m_binaryFileColor; - else if (fde.fileType() == "S") color = m_typeSFileColor; - else if (fde.fileType() == "T") color = m_textFileColor; - else if (fde.fileType() == "a") color = m_typeAFileColor; - else if (fde.fileType() == "b") color = m_typeBFileColor; - else qDebug() << "Unknown file type: " << fde.fileType(); - buttonAt(tr,se)->setBgColor(color); - setButtonText(tr,se,QString("%1").arg(idx)); - //qDebug() << "Button" << idx << "=" << tr << "," << se << " " << fde.filename.printable(); - // fde.dump(); - idx++; - } - tsltr = tsl.getNextTSList().track; - tslse = tsl.getNextTSList().sector; - tsl = m_disk->getSector(tsl.getNextTSList()).promoteToTrackSectorList(); - } - } - } - m_bgroup->setExclusive(true); - -} - -void DiskExplorerMapWidget::showEvent(QShowEvent *) -{ - if (m_deferredSetup) - { - if (m_disk) - { - mapDiskToButtons(); - } - m_deferredSetup = false; - } -} +#include "DiskExplorerMapWidget.h" + +//#include "vtoc.h" +//#include "catalogsector.h" +#include "util.h" + +#include +#include +#include +#include +#include + +DiskExplorerMapWidget::DiskExplorerMapWidget(int numtracks, int numsectors, QWidget *parent) : QWidget(parent) +{ + m_numtracks = numtracks; + m_numsectors = numsectors; + m_diskLabel = Q_NULLPTR; + m_statusWidget = Q_NULLPTR; + + m_deferredSetup = false; + + setWindowTitle("Disk Explorer"); + + m_currentChecked = Q_NULLPTR; + + initColors(); + + QGridLayout *layout = new QGridLayout(); + layout->setSizeConstraint(QLayout::SetFixedSize); + layout->setHorizontalSpacing(2); + layout->setVerticalSpacing(1); + + m_bgroup = new QButtonGroup(this); + + setLayout(layout); + QLabel *tracklabel = new QLabel("Track",this); + layout->addWidget(tracklabel,0,0,1,m_numtracks+1,Qt::AlignHCenter); + for (int track= 0; track < numtracks; track++) + { + QLabel *label = new QLabel(QString("%1").arg(track)); + label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + layout->addWidget(label,1,track+1); + } + for (int sec = 0; sec < numsectors; sec++) + { + QLabel *label = new QLabel(QString("Sec %1").arg(sec)); + label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + layout->addWidget(label,sec+2,0); + } + for (int track = 0; track < 35; track++) + { + for (int sec = 0; sec < 16; sec++) + { + DEButton *tb = new DEButton(this,track,sec); + tb->setObjectName(QString("BtnT%1S%2").arg(track).arg(sec)); + tb->setBgColor(m_defaultColor); + tb->setCheckable(true); + m_bgroup->addButton(tb,(track * numsectors) + sec); + connect(tb, &DEButton::checked, this, &DiskExplorerMapWidget::handleButtonCheck); + m_buttons[track][sec] = tb; + + tb->setAutoFillBackground(true); + + layout->addWidget(tb,sec+2,track+1); + } + } + + makeStatusWidget(); +} + +void DiskExplorerMapWidget::makeStatusWidget() +{ + QWidget *statusWidget = new QWidget(this); + QHBoxLayout *hbl = new QHBoxLayout(this); + statusWidget->setLayout(hbl); + + m_trackSectorLabel = new QLabel(this); + m_trackSectorLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); + m_trackSectorLabel->setText("No Track/Sector selected"); + hbl->insertWidget(0,m_trackSectorLabel,0,Qt::AlignLeft | Qt::AlignVCenter); + + m_diskLabel = new QLabel(this); + m_diskLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken); + m_diskLabel->setText("[No Disk]"); + hbl->insertWidget(1,m_diskLabel,0,Qt::AlignLeft | Qt::AlignVCenter); + + m_statusWidget = statusWidget; +} + +QString DiskExplorerMapWidget::getSectorDescription(int track, int sector) +{ + if (track == 0) { + return "Boot Sector"; + } + else if (track <= 2) + { + return "DOS Image"; + } + else if (track == 17 && sector == 0) + { + return "VTOC"; + } + else + { + QString desc = "xxx"; + if (m_sectorDescriptions.contains(DETSPair(track,sector))) + { + desc = m_sectorDescriptions[DETSPair(track,sector)]; + } + return desc.simplified(); + } + +} + +void DiskExplorerMapWidget::handleButtonCheck(int track, int sector, bool checked) +{ + DEButton *currbutton = buttonAt(track,sector); + + if (m_currentChecked) + { + // Do anything needed to clean up after previous button click + // m_currentClicked->setHighlighted(false); + } + + if (checked) + { + Sector sec = m_disk->getSector(track,sector); + QByteArray data = sec.rawData(); + emit showSectorData(data,track,sector,QVariant()); + m_trackSectorLabel->setText( + QString("Track: %1 Sector: %2 (%3)") + .arg(track) + .arg(sector) + .arg(getSectorDescription(track,sector))); + } + else{ + emit showSectorData(QByteArray(),-1,-1,QVariant()); + m_trackSectorLabel->setText("No Track/Sector selected"); + } + + m_currentChecked = currbutton; +} + +void DiskExplorerMapWidget::setButtonBgColor(int track, int sector, QColor color) +{ + buttonAt(track,sector)->setBgColor(color); +} + +void DiskExplorerMapWidget::setDisk(DiskFile *disk) +{ + if (disk) + { + m_sectorDescriptions.clear(); + + m_disk = disk; + setWindowTitle(QString("Disk Explorer - %1").arg(m_disk->getDiskImageName())); + m_diskLabel->setText(disk->getDiskImageName()); + + if (!isHidden()) + { + if (m_disk) + { + mapDiskToButtons(); + } + } + else + { + m_deferredSetup = true; + } + } +} + +void DiskExplorerMapWidget::unloadDisk() +{ + if (m_disk) + { + m_sectorDescriptions.clear(); + m_bgroup->setExclusive(false); + for (int track = 0; track < m_numtracks; track++) + { + for (int sec = 0; sec < m_numsectors; sec++) + { + DEButton *button = buttonAt(track,sec); + button->setText(""); + button->setBgColor(m_defaultColor); + button->setChecked(false); + } + } + setAllButtonsEnabled(false); + } +} + +void DiskExplorerMapWidget::setAllButtonsEnabled(bool enabled) +{ + for (int track = 0; track < m_numtracks; track++) + { + for (int sec = 0; sec < m_numsectors; sec++) + { + DEButton *button = buttonAt(track,sec); + button->setEnabled(enabled); + } + } +} + +QLabel *DiskExplorerMapWidget::makeKeyLabel(QWidget *parent, QString name, QColor color) +{ + QLabel *label = new QLabel(name,parent); + label->setStyleSheet(QString("background-color:%1; color: %2") + .arg(color.name()) + .arg(determineFgColor(color).name())); + label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + return label; +} + +QGroupBox *DiskExplorerMapWidget::makeKeyWidget() +{ + int idx = 0; + QGroupBox *groupbox= new QGroupBox(this); + groupbox->setTitle("Key"); + QGridLayout *layout = new QGridLayout(); + layout->setVerticalSpacing(0); + layout->setHorizontalSpacing(0); + groupbox->setLayout(layout); + + layout->addWidget(makeKeyLabel(groupbox,"Unused Sector",m_defaultColor),idx++,0); + layout->addWidget(makeKeyLabel(groupbox,"Boot Sector",m_bootSectorColor),idx++,0); + layout->addWidget(makeKeyLabel(groupbox,"DOS Image",m_dosImageColor),idx++,0); + layout->addWidget(makeKeyLabel(groupbox,"VTOC",m_vtocColor),idx++,0); + layout->addWidget(makeKeyLabel(groupbox,"Dir Entry",m_dirEntryColor),idx++,0); + layout->addWidget(makeKeyLabel(groupbox,"T/S List",m_tsListColor),idx++,0); + layout->addWidget(makeKeyLabel(groupbox,"Applesoft File",m_applesoftFileColor),idx++,0); + layout->addWidget(makeKeyLabel(groupbox,"Int. Basic File",m_intBasicFileColor),idx++,0); + layout->addWidget(makeKeyLabel(groupbox,"Binary File",m_binaryFileColor),idx++,0); + layout->addWidget(makeKeyLabel(groupbox,"Text File",m_textFileColor),idx++,0); + layout->addWidget(makeKeyLabel(groupbox,"Relocatable File",m_reloFileColor),idx++,0); + layout->addWidget(makeKeyLabel(groupbox,"Type-A File",m_typeAFileColor),idx++,0); + layout->addWidget(makeKeyLabel(groupbox,"Type-B File",m_typeBFileColor),idx++,0); + layout->addWidget(makeKeyLabel(groupbox,"Type-S File",m_typeSFileColor),idx++,0); + + return groupbox; +} + +DEButton *DiskExplorerMapWidget::buttonAt(int track, int sector) +{ + if (track >= m_numtracks || sector >= m_numsectors) + { + if (track >= m_numtracks) { track = 0; } + if (sector >= m_numsectors) { sector = 0; } + qWarning() << "Invalid track/sector for button (" << track << "," << sector << ")"; + } + return m_buttons[track][sector]; +} + +void DiskExplorerMapWidget::initColors() +{ + m_defaultColor = QColor(Qt::lightGray); + m_bootSectorColor = QColor("#20b060"); + m_dosImageColor = QColor("#30d000"); + m_vtocColor = QColor("#efc010"); + m_tsListColor = QColor("#ff8000"); + m_dirEntryColor = QColor("#dfdf00"); + m_applesoftFileColor = QColor("#3030e0"); + m_intBasicFileColor = QColor("#00d0d0"); + m_binaryFileColor = QColor("#d060d0"); + m_textFileColor = QColor("#F05060"); + m_reloFileColor = QColor("#d00000"); + m_typeAFileColor = QColor("#c040a0"); + m_typeBFileColor = QColor("#c03030"); + m_typeSFileColor = QColor("#20a0a0"); +} + +void DiskExplorerMapWidget::mapDiskToButtons() +{ + setAllButtonsEnabled(true); + m_bgroup->setExclusive(false); + + int idx = 0; + for (int track = 0; track < 3; track++) + { + for (int sec = 0; sec < m_numsectors; sec++) + { + if (track == 0) + buttonAt(track,sec)->setBgColor(m_bootSectorColor); + else + buttonAt(track,sec)->setBgColor(m_dosImageColor); + buttonAt(track,sec)->setText(QString("%1").arg(idx++)); + } + } + + buttonAt(17,0)->setBgColor(m_vtocColor); + buttonAt(17,0)->setText(QString("%1").arg(idx++)); + + int catseccount = 0; + foreach (CatalogSector cs, m_disk->getCatalogSectors()) + { + Sector *sec = cs.getSector(); + + QString desc = QString("Catalog Sector #%1").arg(++catseccount); + m_sectorDescriptions.insert(DETSPair(sec->track(),sec->sector()),desc); + + buttonAt(sec->track(),sec->sector())->setBgColor(m_dirEntryColor); + buttonAt(sec->track(),sec->sector())->setText(QString("%1").arg(idx++)); + + foreach(FileDescriptiveEntry fde, cs.getFDEs()) + { + Sector *s = &(m_disk->getSector(fde.firstTSListSector)); + TrackSectorList tsl(s); + + int tsltr = fde.firstTSListSector.track; + int tslse = fde.firstTSListSector.sector; + + int tslcount = 0; + while (tsltr != 0) + { + tslcount++; + buttonAt(tsltr,tslse)->setBgColor(m_tsListColor); + buttonAt(tsltr,tslse)->setText(QString("%1").arg(idx)); + //qDebug() << "Button" << idx << "=" << tsltr << "," << tslse << " " << fde.filename.printable() << "TSL"; + + QString description = QString("T/S List #%1 for %2").arg(tslcount).arg(fde.filename.printable()); + m_sectorDescriptions.insert(DETSPair(tsltr,tslse),description); + + idx++; + + int sectorcount = 0; + foreach(TSPair tsp, tsl.getDataTSPairs()) + { + int se = tsp.sector; + int tr = tsp.track; + + QString description = QString("Sector #%1.%2 of %3") + .arg(tslcount) + .arg(++sectorcount) + .arg(fde.filename.printable()); + m_sectorDescriptions.insert(DETSPair(tr,se),description); + + QColor color; + if (fde.fileType() == "I") color = m_intBasicFileColor; + else if (fde.fileType() == "A") color = m_applesoftFileColor; + else if (fde.fileType() == "R") color = m_reloFileColor; + else if (fde.fileType() == "B") color = m_binaryFileColor; + else if (fde.fileType() == "S") color = m_typeSFileColor; + else if (fde.fileType() == "T") color = m_textFileColor; + else if (fde.fileType() == "a") color = m_typeAFileColor; + else if (fde.fileType() == "b") color = m_typeBFileColor; + else qDebug() << "Unknown file type: " << fde.fileType(); + buttonAt(tr,se)->setBgColor(color); + setButtonText(tr,se,QString("%1").arg(idx)); + //qDebug() << "Button" << idx << "=" << tr << "," << se << " " << fde.filename.printable(); + // fde.dump(); + idx++; + } + tsltr = tsl.getNextTSList().track; + tslse = tsl.getNextTSList().sector; + tsl = m_disk->getSector(tsl.getNextTSList()).promoteToTrackSectorList(); + } + } + } + m_bgroup->setExclusive(true); + +} + +void DiskExplorerMapWidget::showEvent(QShowEvent *) +{ + if (m_deferredSetup) + { + if (m_disk) + { + mapDiskToButtons(); + } + m_deferredSetup = false; + } +} diff --git a/src/ui/diskexplorer/DiskExplorerMapWidget.h b/src/ui/diskexplorer/DiskExplorerMapWidget.h index d395885..feb0e5b 100644 --- a/src/ui/diskexplorer/DiskExplorerMapWidget.h +++ b/src/ui/diskexplorer/DiskExplorerMapWidget.h @@ -1,171 +1,171 @@ -#ifndef DISKEXPLORERMAPWIDGET_H -#define DISKEXPLORERMAPWIDGET_H - -#include -#include -#include -#include -#include -#include -#include - - -#include "diskfile.h" - - -class DEButton : public QPushButton -{ - Q_OBJECT -public: - DEButton(QWidget *parent,int track = -1, int sec = -1) : QPushButton(parent) - { - setTrack(track); - setSector(sec); - connect(this, &DEButton::clicked, this, &DEButton::handleClick); - m_isHighlighted = false; - } - void setTrack(int track) { m_track = track; } - void setSector(int sector) { m_sector = sector; } - - int track() const { return m_track; } - int sector() const { return m_sector; } - - void clearBgColor() { m_backgroundColor = ""; setText(""); setStyleSheet(makeStyleSheet());} - - void setBgColor(QColor color) { - m_fgColor = determineFgColor(color).name(); - m_backgroundColor = color.name(); - m_hlColor = color.lighter(155).name(); - setStyleSheet(makeStyleSheet()); - } - - bool highlighted() const { return m_isHighlighted; } - void setHighlighted(bool highlighted) { m_isHighlighted = highlighted;setStyleSheet(makeStyleSheet()); } - - void reset() { setHighlighted(false); setChecked(false); makeStyleSheet(); qDebug() << "Reset";} - - void resetToDefault() { clearBgColor(); reset(); } - - QColor determineFgColor(QColor bgColor) - { - if (qGray(bgColor.rgb()) > 128) - { - return QColor(Qt::black); - } - return Qt::white; - } - -signals: - void checked(int track, int sec,bool ); - -private slots: - void handleClick(bool isChecked) { emit checked(m_track,m_sector,isChecked); } - - QSize minimumSizeHint() const Q_DECL_OVERRIDE { return QSize(24,24); } - QSize sizeHint() const Q_DECL_OVERRIDE { return QSize(24,24); } - bool hasHeightForWidth() const Q_DECL_OVERRIDE { return true; } - int heightForWidth(int width) const Q_DECL_OVERRIDE { return width; } - -private: - QString makeStyleSheet() const { - return QString(" QPushButton { font: 10px; border-width: 1px; color: %1; background-color: %2} " - " QPushButton:checked { font: bold italic 11px; } " - ) .arg(m_fgColor) - .arg(m_backgroundColor); - } - - int m_track; - int m_sector; - bool m_isHighlighted; - - QString m_fgColor; - QString m_backgroundColor; - QString m_hlColor; -}; - - - -typedef QPair DETSPair; - -class DiskExplorerMapWidget : public QWidget -{ - Q_OBJECT - -public: - explicit DiskExplorerMapWidget(int numtracks, int numsectors, QWidget *parent = 0); - - void setButtonBgColor(int track, int sector, QColor color); - void setButtonText(int track, int sector, QString text) { - buttonAt(track,sector)->setText(text); - } - - void setDisk(DiskFile *disk); - void unloadDisk(); - - void setAllButtonsEnabled(bool enabled); - - QGroupBox *makeKeyWidget(); - QWidget *getStatusWidget() const { return m_statusWidget; } - -signals: - void showSectorData(QByteArray data, int track, int sector, QVariant metadata); - -public slots: - void handleButtonCheck(int track, int sector, bool checked); - -protected: - void mapDiskToButtons(); - DEButton *buttonAt(int track, int sector); - - void initColors(); - - QColor determineFgColor(QColor bgColor) - { - if (qGray(bgColor.rgb()) > 128) - { - return QColor(Qt::black); - } - return Qt::white; - } - - QLabel *makeKeyLabel(QWidget *parent, QString name, QColor color); - void showEvent(QShowEvent *); - void makeStatusWidget(); - QString getSectorDescription(int track, int sector); - -private: - - QMap > m_buttons; - DEButton *m_currentChecked; - - int m_numtracks; - int m_numsectors; - - QColor m_defaultColor; - QColor m_bootSectorColor; - QColor m_dosImageColor; - QColor m_vtocColor; - QColor m_dirEntryColor; - QColor m_tsListColor; - QColor m_applesoftFileColor; - QColor m_intBasicFileColor; - QColor m_binaryFileColor; - QColor m_textFileColor; - QColor m_reloFileColor; - QColor m_typeAFileColor; - QColor m_typeBFileColor; - QColor m_typeSFileColor; - - QButtonGroup *m_bgroup; - DiskFile *m_disk; - - bool m_deferredSetup; - - QLabel *m_diskLabel; - QLabel *m_trackSectorLabel; - QWidget *m_statusWidget; - - QMap< DETSPair, QString> m_sectorDescriptions; -}; - -#endif // DISKEXPLORERMAPWIDGET_H +#ifndef DISKEXPLORERMAPWIDGET_H +#define DISKEXPLORERMAPWIDGET_H + +#include +#include +#include +#include +#include +#include +#include + + +#include "diskfile.h" + + +class DEButton : public QPushButton +{ + Q_OBJECT +public: + DEButton(QWidget *parent,int track = -1, int sec = -1) : QPushButton(parent) + { + setTrack(track); + setSector(sec); + connect(this, &DEButton::clicked, this, &DEButton::handleClick); + m_isHighlighted = false; + } + void setTrack(int track) { m_track = track; } + void setSector(int sector) { m_sector = sector; } + + int track() const { return m_track; } + int sector() const { return m_sector; } + + void clearBgColor() { m_backgroundColor = ""; setText(""); setStyleSheet(makeStyleSheet());} + + void setBgColor(QColor color) { + m_fgColor = determineFgColor(color).name(); + m_backgroundColor = color.name(); + m_hlColor = color.lighter(155).name(); + setStyleSheet(makeStyleSheet()); + } + + bool highlighted() const { return m_isHighlighted; } + void setHighlighted(bool highlighted) { m_isHighlighted = highlighted;setStyleSheet(makeStyleSheet()); } + + void reset() { setHighlighted(false); setChecked(false); makeStyleSheet(); qDebug() << "Reset";} + + void resetToDefault() { clearBgColor(); reset(); } + + QColor determineFgColor(QColor bgColor) + { + if (qGray(bgColor.rgb()) > 128) + { + return QColor(Qt::black); + } + return Qt::white; + } + +signals: + void checked(int track, int sec,bool ); + +private slots: + void handleClick(bool isChecked) { emit checked(m_track,m_sector,isChecked); } + + QSize minimumSizeHint() const Q_DECL_OVERRIDE { return QSize(24,24); } + QSize sizeHint() const Q_DECL_OVERRIDE { return QSize(24,24); } + bool hasHeightForWidth() const Q_DECL_OVERRIDE { return true; } + int heightForWidth(int width) const Q_DECL_OVERRIDE { return width; } + +private: + QString makeStyleSheet() const { + return QString(" QPushButton { font: 10px; border-width: 1px; color: %1; background-color: %2} " + " QPushButton:checked { font: bold italic 11px; } " + ) .arg(m_fgColor) + .arg(m_backgroundColor); + } + + int m_track; + int m_sector; + bool m_isHighlighted; + + QString m_fgColor; + QString m_backgroundColor; + QString m_hlColor; +}; + + + +typedef QPair DETSPair; + +class DiskExplorerMapWidget : public QWidget +{ + Q_OBJECT + +public: + explicit DiskExplorerMapWidget(int numtracks, int numsectors, QWidget *parent = 0); + + void setButtonBgColor(int track, int sector, QColor color); + void setButtonText(int track, int sector, QString text) { + buttonAt(track,sector)->setText(text); + } + + void setDisk(DiskFile *disk); + void unloadDisk(); + + void setAllButtonsEnabled(bool enabled); + + QGroupBox *makeKeyWidget(); + QWidget *getStatusWidget() const { return m_statusWidget; } + +signals: + void showSectorData(QByteArray data, int track, int sector, QVariant metadata); + +public slots: + void handleButtonCheck(int track, int sector, bool checked); + +protected: + void mapDiskToButtons(); + DEButton *buttonAt(int track, int sector); + + void initColors(); + + QColor determineFgColor(QColor bgColor) + { + if (qGray(bgColor.rgb()) > 128) + { + return QColor(Qt::black); + } + return Qt::white; + } + + QLabel *makeKeyLabel(QWidget *parent, QString name, QColor color); + void showEvent(QShowEvent *); + void makeStatusWidget(); + QString getSectorDescription(int track, int sector); + +private: + + QMap > m_buttons; + DEButton *m_currentChecked; + + int m_numtracks; + int m_numsectors; + + QColor m_defaultColor; + QColor m_bootSectorColor; + QColor m_dosImageColor; + QColor m_vtocColor; + QColor m_dirEntryColor; + QColor m_tsListColor; + QColor m_applesoftFileColor; + QColor m_intBasicFileColor; + QColor m_binaryFileColor; + QColor m_textFileColor; + QColor m_reloFileColor; + QColor m_typeAFileColor; + QColor m_typeBFileColor; + QColor m_typeSFileColor; + + QButtonGroup *m_bgroup; + DiskFile *m_disk; + + bool m_deferredSetup; + + QLabel *m_diskLabel; + QLabel *m_trackSectorLabel; + QWidget *m_statusWidget; + + QMap< DETSPair, QString> m_sectorDescriptions; +}; + +#endif // DISKEXPLORERMAPWIDGET_H diff --git a/src/ui/viewers/applesoftfiledetailviewer.cpp b/src/ui/viewers/applesoftfiledetailviewer.cpp index 00f5ff4..9b412d5 100644 --- a/src/ui/viewers/applesoftfiledetailviewer.cpp +++ b/src/ui/viewers/applesoftfiledetailviewer.cpp @@ -1,196 +1,200 @@ -#include "applesoftfiledetailviewer.h" -#include "ui_applesoftfiledetailviewer.h" - -#include -#include -#include -#include - - -ApplesoftFileDetailViewer::ApplesoftFileDetailViewer(ApplesoftFile *file, QWidget *parent) : - QWidget(parent), - ui(new Ui::ApplesoftFileDetailViewer) -{ - ui->setupUi(this); - ui->m_varView->setSortingEnabled(true); - m_file = file; - load(); - setLineData(m_file->getLines()); -} - -ApplesoftFileDetailViewer::~ApplesoftFileDetailViewer() -{ - save(); - delete ui; -} - -void ApplesoftFileDetailViewer::setLineData(QVector lineData) -{ - m_lines = lineData; - process(); -} - -bool ApplesoftFileDetailViewer::save() -{ - - if (ui->gridLayout->rowCount() == 0) { return false; } - - QMap map; - for (int idx = 0; idx < ui->m_varView->rowCount(); idx++) - { - QString var = ui->m_varView->item(idx,1)->text(); - if (var.contains(",")) - { - var.truncate(var.indexOf(",")); - } - var = var.trimmed(); - QString note = ui->m_varView->item(idx,2)->text().trimmed(); - if (note.length()) - { - map.insert(var,note); - } - } - - QFile outfile(QString("%1%2%3") - .arg(m_file->diskFile()->getMetaDataPath()) - .arg(m_file->filename()) - .arg(".asvar")); - if (outfile.open(QIODevice::WriteOnly)) - { - QDataStream ds(&outfile); - ds << map; - outfile.close(); - return true; - } - return false; -} - -bool ApplesoftFileDetailViewer::load() -{ - QFile infile(QString("%1%2%3") - .arg(m_file->diskFile()->getMetaDataPath()) - .arg(m_file->filename()) - .arg(".asvar")); - if (infile.open(QIODevice::ReadOnly)) - { - QDataStream ds(&infile); - ds >> m_notes; - infile.close(); - return true; - } - return false; -} - - -void ApplesoftFileDetailViewer::process() -{ - QMap vardata; - QMap vartypes; - QMap varalias; - - - foreach (ApplesoftLine line, m_lines) - { - quint16 linenum = line.linenum; - foreach(ApplesoftToken token, line.tokens) - { - quint16 tid = token.getTokenId(); - if (tid == ApplesoftToken::IntVarTokenVal || - tid == ApplesoftToken::IntAryVarTokenVal || - tid == ApplesoftToken::FloatVarTokenVal || - tid == ApplesoftToken::FloatAryVarTokenVal || - tid == ApplesoftToken::StringVarTokenVal || - tid == ApplesoftToken::StringAryVarTokenVal) - { - QString varname = token.getStringValue(); - QString fullname = varname; - varname = shortenName(varname); - if (varname.contains("(")) { varname.append(")"); } - if (fullname.contains("(")) { fullname.append(")"); } - vardata[varname].append(QString("%1").arg(linenum)); - vartypes[varname] = tid; - if (fullname != varname) - { - varalias[varname].append(fullname); - } - } - } - } - - QMap typemap; - - QStringList keys = vardata.keys(); - ui->m_varView->setRowCount(keys.count()); - qSort(keys); - int idx = 0; - foreach (QString key, keys) - { - vardata[key].removeDuplicates(); - QString linenums = vardata[key].join(","); - quint16 vtype = vartypes[key]; - QString vtname; - switch (vtype) { - case ApplesoftToken::IntVarTokenVal: vtname = "Int"; break; - case ApplesoftToken::FloatVarTokenVal: vtname = "Float"; break; - case ApplesoftToken::StringVarTokenVal: vtname = "String"; break; - case ApplesoftToken::IntAryVarTokenVal: vtname = "Int Array"; break; - case ApplesoftToken::FloatAryVarTokenVal: vtname = "Float Array"; break; - case ApplesoftToken::StringAryVarTokenVal: vtname = "String Array"; break; - default: vtname = "Unknown"; - } - - QTableWidgetItem *twi = new QTableWidgetItem(vtname); - twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - ui->m_varView->setItem(idx,0,twi); - - QString keywithalias = key; - if (varalias.contains(key)) - { - varalias[key].removeDuplicates(); - QString aliases = varalias[key].join(", "); - keywithalias.append(", "); - keywithalias.append(aliases); - } - twi = new QTableWidgetItem(keywithalias); - twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - ui->m_varView->setItem(idx,1,twi); - - twi = new QTableWidgetItem(" "); - if (m_notes.contains(key)) - { - twi->setText(m_notes[key]); - } - twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); - ui->m_varView->setItem(idx,2,twi); - - - twi = new QTableWidgetItem(linenums); - twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - ui->m_varView->setItem(idx,3,twi); - idx++; - } - - ui->m_varView->resizeColumnToContents(0); - ui->m_varView->resizeColumnToContents(1); - ui->m_varView->resizeColumnToContents(2); - -} - -QString ApplesoftFileDetailViewer::shortenName(QString name) -{ - bool hasParen = name.contains('('); - if (hasParen) { name.remove(name.indexOf('('),1); } - - bool hasDollar = name.contains('$'); - if (hasDollar) { name.remove(name.indexOf('$'),1); } - - bool hasPercent = name.contains('%'); - if (hasPercent) { name.remove(name.indexOf('%'),1); } - - name = name.left(2); - if (hasDollar) { name.append("$"); } - if (hasPercent) { name.append("%"); } - if (hasParen) { name.append("("); } - - return name; - } +#include "applesoftfiledetailviewer.h" +#include "ui_applesoftfiledetailviewer.h" + +#include +#include +#include +#include +#include + + +ApplesoftFileDetailViewer::ApplesoftFileDetailViewer(ApplesoftFile *file, QWidget *parent) : + QWidget(parent), + ui(new Ui::ApplesoftFileDetailViewer) +{ + + ui->setupUi(this); + + ui->m_varView->setSortingEnabled(true); + m_file = file; + load(); + setLineData(m_file->getLines()); +} + +ApplesoftFileDetailViewer::~ApplesoftFileDetailViewer() +{ + save(); + delete ui; +} + +void ApplesoftFileDetailViewer::setLineData(QVector lineData) +{ + m_lines = lineData; + process(); +} + +bool ApplesoftFileDetailViewer::save() +{ + + if (ui->gridLayout->rowCount() == 0) { return false; } + + QMap map; + for (int idx = 0; idx < ui->m_varView->rowCount(); idx++) + { + QString var = ui->m_varView->item(idx,1)->text(); + if (var.contains(",")) + { + var.truncate(var.indexOf(",")); + } + var = var.trimmed(); + QString note = ui->m_varView->item(idx,2)->text().trimmed(); + if (note.length()) + { + map.insert(var,note); + } + } + + QFile outfile(QString("%1%2%3") + .arg(m_file->diskFile()->getMetaDataPath()) + .arg(m_file->filename()) + .arg(".asvar")); + if (outfile.open(QIODevice::WriteOnly)) + { + QDataStream ds(&outfile); + ds << map; + outfile.close(); + return true; + } + return false; +} + +bool ApplesoftFileDetailViewer::load() +{ + QFile infile(QString("%1%2%3") + .arg(m_file->diskFile()->getMetaDataPath()) + .arg(m_file->filename()) + .arg(".asvar")); + if (infile.open(QIODevice::ReadOnly)) + { + QDataStream ds(&infile); + ds >> m_notes; + infile.close(); + return true; + } + return false; +} + + +void ApplesoftFileDetailViewer::process() +{ + QMap vardata; + QMap vartypes; + QMap varalias; + + + foreach (ApplesoftLine line, m_lines) + { + quint16 linenum = line.linenum; + foreach(ApplesoftToken token, line.tokens) + { + quint16 tid = token.getTokenId(); + if (tid == ApplesoftToken::IntVarTokenVal || + tid == ApplesoftToken::IntAryVarTokenVal || + tid == ApplesoftToken::FloatVarTokenVal || + tid == ApplesoftToken::FloatAryVarTokenVal || + tid == ApplesoftToken::StringVarTokenVal || + tid == ApplesoftToken::StringAryVarTokenVal) + { + QString varname = token.getStringValue(); + QString fullname = varname; + varname = shortenName(varname); + if (varname.contains("(")) { varname.append(")"); } + if (fullname.contains("(")) { fullname.append(")"); } + vardata[varname].append(QString("%1").arg(linenum)); + vartypes[varname] = tid; + if (fullname != varname) + { + varalias[varname].append(fullname); + } + } + } + } + + QMap typemap; + + QStringList keys = vardata.keys(); + ui->m_varView->setRowCount(keys.count()); + keys.sort(); + + int idx = 0; + foreach (QString key, keys) + { + vardata[key].removeDuplicates(); + QString linenums = vardata[key].join(","); + quint16 vtype = vartypes[key]; + QString vtname; + switch (vtype) { + case ApplesoftToken::IntVarTokenVal: vtname = "Int"; break; + case ApplesoftToken::FloatVarTokenVal: vtname = "Float"; break; + case ApplesoftToken::StringVarTokenVal: vtname = "String"; break; + case ApplesoftToken::IntAryVarTokenVal: vtname = "Int Array"; break; + case ApplesoftToken::FloatAryVarTokenVal: vtname = "Float Array"; break; + case ApplesoftToken::StringAryVarTokenVal: vtname = "String Array"; break; + default: vtname = "Unknown"; + } + + QTableWidgetItem *twi = new QTableWidgetItem(vtname); + twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + ui->m_varView->setItem(idx,0,twi); + + QString keywithalias = key; + if (varalias.contains(key)) + { + varalias[key].removeDuplicates(); + QString aliases = varalias[key].join(", "); + keywithalias.append(", "); + keywithalias.append(aliases); + } + twi = new QTableWidgetItem(keywithalias); + twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + ui->m_varView->setItem(idx,1,twi); + + twi = new QTableWidgetItem(" "); + if (m_notes.contains(key)) + { + twi->setText(m_notes[key]); + } + twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable); + ui->m_varView->setItem(idx,2,twi); + + + twi = new QTableWidgetItem(linenums); + twi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); + ui->m_varView->setItem(idx,3,twi); + idx++; + } + + ui->m_varView->resizeColumnToContents(0); + ui->m_varView->resizeColumnToContents(1); + ui->m_varView->resizeColumnToContents(2); + +} + +QString ApplesoftFileDetailViewer::shortenName(QString name) +{ + bool hasParen = name.contains('('); + if (hasParen) { name.remove(name.indexOf('('),1); } + + bool hasDollar = name.contains('$'); + if (hasDollar) { name.remove(name.indexOf('$'),1); } + + bool hasPercent = name.contains('%'); + if (hasPercent) { name.remove(name.indexOf('%'),1); } + + name = name.left(2); + if (hasDollar) { name.append("$"); } + if (hasPercent) { name.append("%"); } + if (hasParen) { name.append("("); } + + return name; + } diff --git a/src/ui/viewers/applesoftfiledetailviewer.h b/src/ui/viewers/applesoftfiledetailviewer.h index 16069fe..7088b51 100644 --- a/src/ui/viewers/applesoftfiledetailviewer.h +++ b/src/ui/viewers/applesoftfiledetailviewer.h @@ -1,41 +1,41 @@ -#ifndef APPLESOFTFILEDETAILVIEWER_H -#define APPLESOFTFILEDETAILVIEWER_H - -#include -#include "applesoftline.h" -#include "applesofttoken.h" -#include "applesoftfile.h" -#include - -namespace Ui { -class ApplesoftFileDetailViewer; -} - -class ApplesoftFileDetailViewer : public QWidget -{ - Q_OBJECT - -public: - explicit ApplesoftFileDetailViewer(ApplesoftFile *file, QWidget *parent = 0); - ~ApplesoftFileDetailViewer(); - - void setLineData(QVector lineData); - void foo() { qDebug() << "AFDV::foo!"; } - - bool save(); - bool load(); - -protected: - QString shortenName(QString name); -private: - void process(); - - Ui::ApplesoftFileDetailViewer *ui; - QVector m_lines; - - QMap m_notes; - - ApplesoftFile *m_file; -}; - -#endif // APPLESOFTFILEDETAILVIEWER_H +#ifndef APPLESOFTFILEDETAILVIEWER_H +#define APPLESOFTFILEDETAILVIEWER_H + +#include +#include "applesoftline.h" +#include "applesofttoken.h" +#include "applesoftfile.h" +#include + +namespace Ui { +class ApplesoftFileDetailViewer; +} + +class ApplesoftFileDetailViewer : public QWidget +{ + Q_OBJECT + +public: + explicit ApplesoftFileDetailViewer(ApplesoftFile *file, QWidget *parent = 0); + ~ApplesoftFileDetailViewer(); + + void setLineData(QVector lineData); + void foo() { qDebug() << "AFDV::foo!"; } + + bool save(); + bool load(); + +protected: + QString shortenName(QString name); +private: + void process(); + + Ui::ApplesoftFileDetailViewer *ui; + QVector m_lines; + + QMap m_notes; + + ApplesoftFile *m_file; +}; + +#endif // APPLESOFTFILEDETAILVIEWER_H diff --git a/src/ui/viewers/applesoftfiledetailviewer.ui b/src/ui/viewers/applesoftfiledetailviewer.ui index 1160faa..39f5dc4 100644 --- a/src/ui/viewers/applesoftfiledetailviewer.ui +++ b/src/ui/viewers/applesoftfiledetailviewer.ui @@ -1,66 +1,66 @@ - - - ApplesoftFileDetailViewer - - - - 0 - 0 - 766 - 515 - - - - Variables - - - - - - true - - - Qt::ElideNone - - - false - - - true - - - true - - - true - - - false - - - - Variable - - - - - Type - - - - - Notes - - - - - Lines - - - - - - - - - + + + ApplesoftFileDetailViewer + + + + 0 + 0 + 766 + 515 + + + + Variables + + + + + + true + + + Qt::ElideNone + + + false + + + true + + + true + + + true + + + false + + + + Type + + + + + Variable + + + + + Notes + + + + + Lines + + + + + + + + + diff --git a/src/ui/viewers/applesoftfileviewer.cxx b/src/ui/viewers/applesoftfileviewer.cxx index 58c1a36..840c71b 100644 --- a/src/ui/viewers/applesoftfileviewer.cxx +++ b/src/ui/viewers/applesoftfileviewer.cxx @@ -1,412 +1,453 @@ -#include "applesoftfileviewer.h" -#include "ui_applesoftfileviewer.h" -#include "applesoftformatter.h" -#include -#include -#include -#include -#include - - -ApplesoftFileViewer::ApplesoftFileViewer(QWidget *parent) : - FileViewerInterface(parent), - ui(new Ui::ApplesoftFileViewer) -{ - ui->setupUi(this); - m_afdv = Q_NULLPTR; - - QSettings settings; - QString title = QString("Applesoft Viewer"); - m_title = title; - setWindowTitle(title); - - m_formatter = new ApplesoftFormatter(this); - m_formatter->setFlags(ApplesoftFormatter::ShowCtrlChars); - connect(ui->findButton, &QToolButton::clicked, this, &ApplesoftFileViewer::findText); - m_isFirstFind = true; - ui->textArea->setUndoRedoEnabled(false); - ui->textArea->setUndoRedoEnabled(true); - - m_showIntsAction = Q_NULLPTR; - m_reindentCodeAction = Q_NULLPTR; - m_blankAfterReturnsAction = Q_NULLPTR; - m_syntaxHighlightingAction = Q_NULLPTR; - m_showVarExplorerAction = Q_NULLPTR; - m_wordWrapAction = Q_NULLPTR; - m_showCtrlCharsAction = Q_NULLPTR; - - toggleWordWrap(settings.value("ASViewer.WordWrap",true).toBool()); - - setIndentCode(settings.value("ASViewer.indentCode",false).toBool(), NoReformat); - setIntsAsHex(settings.value("ASViewer.intsAsHex",false).toBool(), NoReformat); - setBreakAfterReturn(settings.value("ASViewer.breakAfterReturn",false).toBool(), NoReformat); - setSyntaxHighlighting(settings.value("ASViewer.syntaxHighlighting",true).toBool(), NoReformat); - setShowCtrlChars(settings.value("ASViewer.showCtrlChars",true).toBool(), NoReformat); -} - -ApplesoftFileViewer::~ApplesoftFileViewer() -{ - if (m_afdv) - { - m_afdv->deleteLater(); - } - delete ui; -} - -bool ApplesoftFileViewer::makeMenuOptions(QMenu *menu) -{ - QSettings settings; - - if (!m_showIntsAction) - { - m_showIntsAction = new QAction("Show Ints as &Hex",this); - m_showIntsAction->setCheckable(true); - m_showIntsAction->setChecked(settings.value("ASViewer.intsAsHex",false).toBool()); - setIntsAsHex(settings.value("ASViewer.intsAsHex",false).toBool(),NoReformat); - - connect(m_showIntsAction, &QAction::toggled, ui->findText, &QLineEdit::clear); - connect(m_showIntsAction, &QAction::toggled, - this, static_cast< void (ApplesoftFileViewer::*)(bool)>(&ApplesoftFileViewer::setIntsAsHex)); - - } - menu->addAction(m_showIntsAction); - - if (!m_reindentCodeAction) - { - m_reindentCodeAction = new QAction("&Indent code",this); - m_reindentCodeAction->setCheckable(true); - m_reindentCodeAction->setChecked(settings.value("ASViewer.indentCode",false).toBool()); - setIndentCode(settings.value("ASViewer.indentCode",false).toBool(),NoReformat); - - connect(m_reindentCodeAction, &QAction::toggled, ui->findText, &QLineEdit::clear); - connect(m_reindentCodeAction, &QAction::toggled, - this, static_cast< void (ApplesoftFileViewer::*)(bool)>(&ApplesoftFileViewer::setIndentCode)); - - } - menu->addAction(m_reindentCodeAction); - - if (!m_blankAfterReturnsAction) - { - m_blankAfterReturnsAction = new QAction("Blank &Line after RETURNs",this); - m_blankAfterReturnsAction->setCheckable(true); - m_blankAfterReturnsAction->setChecked(settings.value("ASViewer.breakAfterReturn",false).toBool()); - setIndentCode(settings.value("ASViewer.breakAfterReturn",false).toBool(),NoReformat); - - connect(m_blankAfterReturnsAction, &QAction::toggled, ui->findText, &QLineEdit::clear); - connect(m_blankAfterReturnsAction, &QAction::toggled, - this, static_cast< void (ApplesoftFileViewer::*)(bool)>(&ApplesoftFileViewer::setBreakAfterReturn)); - } - menu->addAction(m_blankAfterReturnsAction); - - if (!m_showCtrlCharsAction) - { - m_showCtrlCharsAction = new QAction("Show &Control Characters",this); - m_showCtrlCharsAction->setCheckable(true); - m_showCtrlCharsAction->setChecked(settings.value("ASViewer.showCtrlChars",false).toBool()); - setIndentCode(settings.value("ASViewer.showCtrlChars",false).toBool(),NoReformat); - - connect(m_showCtrlCharsAction, &QAction::toggled, ui->findText, &QLineEdit::clear); - connect(m_showCtrlCharsAction, &QAction::toggled, - this, static_cast(&ApplesoftFileViewer::setShowCtrlChars)); - } - menu->addAction(m_showCtrlCharsAction); - - - menu->addSeparator(); - - if (!m_wordWrapAction) - { - m_wordWrapAction = new QAction("&Word Wrap",this); - m_wordWrapAction->setCheckable(true); - m_wordWrapAction->setChecked(settings.value("ASViewer.WordWrap",true).toBool()); - toggleWordWrap(settings.value("ASViewer.WordWrap",true).toBool()); - connect(m_wordWrapAction, &QAction::triggered, this, &ApplesoftFileViewer::toggleWordWrap); - } - menu->addAction(m_wordWrapAction); - - if (!m_syntaxHighlightingAction) - { - m_syntaxHighlightingAction = new QAction("&Syntax Highlighting",this); - m_syntaxHighlightingAction->setCheckable(true); - m_syntaxHighlightingAction->setChecked(settings.value("ASViewer.syntaxHighlighting",false).toBool()); - setIndentCode(settings.value("ASViewer.syntaxHighlighting",false).toBool(),NoReformat); - - connect(m_syntaxHighlightingAction, &QAction::toggled, ui->findText, &QLineEdit::clear); - connect(m_syntaxHighlightingAction, &QAction::toggled, - this, static_cast(&ApplesoftFileViewer::setSyntaxHighlighting)); - } - menu->addAction(m_syntaxHighlightingAction); - - - - menu->addSeparator(); - - if (!m_showVarExplorerAction) - { - m_showVarExplorerAction = new QAction("Show &Variable Explorer...",this); - m_showVarExplorerAction->setCheckable(false); - connect(m_showVarExplorerAction, &QAction::triggered, this, &ApplesoftFileViewer::launchVarBrowser); - } - menu->addAction(m_showVarExplorerAction); - - return true; -} - -bool ApplesoftFileViewer::optionsMenuItems(QMenu *menu) -{ - return makeMenuOptions(menu); -} - - -void ApplesoftFileViewer::toggleWordWrap(bool enabled) -{ - if (enabled) - { - ui->textArea->setWordWrapMode(QTextOption::WordWrap); - } - else - { - ui->textArea->setWordWrapMode(QTextOption::NoWrap); - } - QSettings settings; - settings.setValue("ASViewer.WordWrap",enabled); -} - -void ApplesoftFileViewer::setIndentCode(bool enabled, ReformatRule reformat) -{ - if (enabled) - { - m_formatter->setFlags(m_formatter->flags() | ApplesoftFormatter::ReindentCode); - } - else - { - m_formatter->setFlags(m_formatter->flags() & ~ApplesoftFormatter::ReindentCode); - } - QSettings settings; - settings.setValue("ASViewer.indentCode",enabled); - if (reformat == ForceReformat) - reformatText(); -} - -void ApplesoftFileViewer::setBreakAfterReturn(bool enabled, ReformatRule reformat) -{ - if (enabled) - { - m_formatter->setFlags(m_formatter->flags() | ApplesoftFormatter::BreakAfterReturn); - } - else - { - m_formatter->setFlags(m_formatter->flags() & ~ApplesoftFormatter::BreakAfterReturn); - } - QSettings settings; - settings.setValue("ASViewer.breakAfterReturn",enabled); - if (reformat == ForceReformat) - reformatText(); -} - -void ApplesoftFileViewer::setShowCtrlChars(bool enabled, ReformatRule reformat) -{ - if (enabled) - { - m_formatter->setFlags(m_formatter->flags() | ApplesoftFormatter::ShowCtrlChars); - } - else - { - m_formatter->setFlags(m_formatter->flags() & ~ApplesoftFormatter::ShowCtrlChars); - } - QSettings settings; - settings.setValue("ASViewer.showCtrlChars",enabled); - if (reformat == ForceReformat) - reformatText(); -} - -void ApplesoftFileViewer::setSyntaxHighlighting(bool enabled) -{ - setSyntaxHighlighting(enabled, ForceReformat); -} - -void ApplesoftFileViewer::setSyntaxHighlighting(bool enabled, ReformatRule reformat) -{ - if (enabled) - { - m_formatter->setFlags(m_formatter->flags() | ApplesoftFormatter::SyntaxHighlighting); - } - else - { - m_formatter->setFlags(m_formatter->flags() & ~ApplesoftFormatter::SyntaxHighlighting); - } - QSettings settings; - settings.setValue("ASViewer.syntaxHighlighting",enabled); - if (reformat == ForceReformat) - reformatText(); -} - -void ApplesoftFileViewer::setIntsAsHex(bool enabled, ReformatRule reformat) -{ - if (enabled) - { - m_formatter->setFlags(m_formatter->flags() | ApplesoftFormatter::ShowIntsAsHex); - } - else - { - m_formatter->setFlags(m_formatter->flags() & ~ApplesoftFormatter::ShowIntsAsHex); - } - QSettings settings; - settings.setValue("ASViewer.intsAsHex",enabled); - if (reformat == ForceReformat) - reformatText(); -} - -void ApplesoftFileViewer::reformatText() -{ - QTextDocument *doc = ui->textArea->document(); - - doc->clear(); - m_formatter->formatDocument(doc); - - QTextCursor cursor = ui->textArea->textCursor(); - cursor.movePosition(QTextCursor::Start,QTextCursor::MoveAnchor); - ui->textArea->setTextCursor(cursor); - - //qDebug() << m_formatter->flowTargets(); -} - -void ApplesoftFileViewer::setFile(GenericFile *file) { - ApplesoftFile *af = dynamic_cast(file); - if (af) - { - setFile(af); - } -} - -void ApplesoftFileViewer::setFile(ApplesoftFile *file) { - m_file = file; - m_formatter->setFile(file); - - QString title = QString("Applesoft Viewer: %1").arg(m_file->filename()); - m_title = title; - setWindowTitle(title); - QTextDocument *doc = ui->textArea->document(); - m_formatter->formatDocument(doc); - QTextCursor cursor = ui->textArea->textCursor(); - cursor.movePosition(QTextCursor::Start,QTextCursor::MoveAnchor); - ui->textArea->setTextCursor(cursor); -} - -void ApplesoftFileViewer::setData(QByteArray data) -{ - ui->textArea->setText(data); -} - -void ApplesoftFileViewer::setText(QString text) -{ - ui->textArea->setHtml(text); -} - -void ApplesoftFileViewer::launchVarBrowser() -{ - if (!m_afdv) - { - m_afdv = new ApplesoftFileDetailViewer(m_file); - qDebug() << "m_afdv = " << m_afdv; - m_afdv->setWindowTitle(QString("Variables - %1").arg(m_file->filename())); - } - m_afdv->show(); -} - -void ApplesoftFileViewer::findText() -{ - //TODO: Make this much more robust - - QString searchString = ui->findText->text(); - QTextDocument *document = ui->textArea->document(); - - if (m_isFirstFind == false) - { - document->undo(); - } - - if (searchString.isEmpty()) { - ui->findResults->setText(""); - return; - } - - QTextCursor highlightCursor(document); - QTextCursor cursor(document); - - cursor.beginEditBlock(); - - QTextCharFormat plainFormat(highlightCursor.charFormat()); - QTextCharFormat colorFormat = plainFormat; - colorFormat.setBackground(Qt::yellow); - int count = 0; - while(!highlightCursor.isNull() && !highlightCursor.atEnd()) { - highlightCursor = document->find(searchString, highlightCursor); - - if (!highlightCursor.isNull()) { - count++; - int position = highlightCursor.position(); - highlightCursor.setPosition(position,QTextCursor::KeepAnchor); - highlightCursor.mergeCharFormat(colorFormat); - } - } - QString results = QString("%1 match%2").arg(count).arg(count != 1?"es":""); - ui->findResults->setText(results); - cursor.endEditBlock(); - ui->textArea->ensureCursorVisible(); - - m_isFirstFind = false; -} - -bool ApplesoftFileViewer::canPrint() const { return true; } - -void ApplesoftFileViewer::doPrint() -{ - QPrinter printer; - - QPrintDialog dialog(&printer, this); - dialog.setWindowTitle(tr("Print Applesoft File")); - if (ui->textArea->textCursor().hasSelection()) - dialog.addEnabledOption(QAbstractPrintDialog::PrintSelection); - if (dialog.exec() != QDialog::Accepted) { - return; - } - - QTextDocument printDoc; - QFont printFont("Courier",10); - printDoc.setDefaultFont(printFont); - QTextOption printOptions; - printOptions.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); - printDoc.setDefaultTextOption(printOptions); - m_formatter->formatDocument(&printDoc); - printDoc.print(&printer); - - //ui->textArea->document()->print(&printer); -} - -bool ApplesoftFileViewer::canExport() const { return true; } - -void ApplesoftFileViewer::doExport() -{ - QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); - QDir savename = QDir(defaultPath).filePath(m_file->filename()+".txt"); - - QString saveName = QFileDialog::getSaveFileName(this, - tr("Export Applesoft"), savename.path(), tr("Text Files (*.txt)")); - - if (saveName == "") return; // User cancelled - - qDebug() << "Set filename: " << saveName; - - QFile saveFile(saveName); - if (!saveFile.open(QIODevice::WriteOnly | QIODevice::Text)) - { - QMessageBox::warning(this,"Save Error","Could not save "+saveName); - return; - } - - QTextStream out(&saveFile); - out << ui->textArea->document()->toPlainText(); - saveFile.close(); -} - +#include "applesoftfileviewer.h" +#include "ui_applesoftfileviewer.h" +#include "applesoftformatter.h" +#include "util.h" +#include +#include +#include +#include +#include +#include + + +ApplesoftFileViewer::ApplesoftFileViewer(QWidget *parent) : + FileViewerInterface(parent), + ui(new Ui::ApplesoftFileViewer) +{ + ui->setupUi(this); + m_afdv = Q_NULLPTR; + + + QFont textAreaFont; + textAreaFont.setStyleHint(QFont::Monospace); + textAreaFont.setPointSize(12); + + QSettings settings; + QString title = QString("Applesoft Viewer"); + m_title = title; + setWindowTitle(title); + + m_formatter = new ApplesoftFormatter(this); + m_formatter->setFlags(ApplesoftFormatter::ShowCtrlChars); + connect(ui->findButton, &QToolButton::clicked, this, &ApplesoftFileViewer::findText); + m_isFirstFind = true; + ui->textArea->setUndoRedoEnabled(false); + ui->textArea->setUndoRedoEnabled(true); + + m_showIntsAction = Q_NULLPTR; + m_reindentCodeAction = Q_NULLPTR; + m_blankAfterReturnsAction = Q_NULLPTR; + m_syntaxHighlightingAction = Q_NULLPTR; + m_showVarExplorerAction = Q_NULLPTR; + m_wordWrapAction = Q_NULLPTR; + m_showCtrlCharsAction = Q_NULLPTR; + m_setFontAction = Q_NULLPTR; + + toggleWordWrap(settings.value("ASViewer.WordWrap",true).toBool()); + + setIndentCode(settings.value("ASViewer.indentCode",false).toBool(), NoReformat); + setIntsAsHex(settings.value("ASViewer.intsAsHex",false).toBool(), NoReformat); + setBreakAfterReturn(settings.value("ASViewer.breakAfterReturn",false).toBool(), NoReformat); + setSyntaxHighlighting(settings.value("ASViewer.syntaxHighlighting",true).toBool(), NoReformat); + setShowCtrlChars(settings.value("ASViewer.showCtrlChars",true).toBool(), NoReformat); + + setTextFont(fontFromSettings("ASViewer.textFont", textAreaFont), NoReformat); +} + +ApplesoftFileViewer::~ApplesoftFileViewer() +{ + if (m_afdv) + { + m_afdv->deleteLater(); + } + delete ui; +} + +bool ApplesoftFileViewer::makeMenuOptions(QMenu *menu) +{ + QSettings settings; + + if (!m_showIntsAction) + { + m_showIntsAction = new QAction("Show Ints as &Hex",this); + m_showIntsAction->setCheckable(true); + m_showIntsAction->setChecked(settings.value("ASViewer.intsAsHex",false).toBool()); + setIntsAsHex(settings.value("ASViewer.intsAsHex",false).toBool(),NoReformat); + + connect(m_showIntsAction, &QAction::toggled, ui->findText, &QLineEdit::clear); + connect(m_showIntsAction, &QAction::toggled, + this, static_cast< void (ApplesoftFileViewer::*)(bool)>(&ApplesoftFileViewer::setIntsAsHex)); + + } + menu->addAction(m_showIntsAction); + + if (!m_reindentCodeAction) + { + m_reindentCodeAction = new QAction("&Indent code",this); + m_reindentCodeAction->setCheckable(true); + m_reindentCodeAction->setChecked(settings.value("ASViewer.indentCode",false).toBool()); + setIndentCode(settings.value("ASViewer.indentCode",false).toBool(),NoReformat); + + connect(m_reindentCodeAction, &QAction::toggled, ui->findText, &QLineEdit::clear); + connect(m_reindentCodeAction, &QAction::toggled, + this, static_cast< void (ApplesoftFileViewer::*)(bool)>(&ApplesoftFileViewer::setIndentCode)); + + } + menu->addAction(m_reindentCodeAction); + + if (!m_blankAfterReturnsAction) + { + m_blankAfterReturnsAction = new QAction("Blank &Line after RETURNs",this); + m_blankAfterReturnsAction->setCheckable(true); + m_blankAfterReturnsAction->setChecked(settings.value("ASViewer.breakAfterReturn",false).toBool()); + setIndentCode(settings.value("ASViewer.breakAfterReturn",false).toBool(),NoReformat); + + connect(m_blankAfterReturnsAction, &QAction::toggled, ui->findText, &QLineEdit::clear); + connect(m_blankAfterReturnsAction, &QAction::toggled, + this, static_cast< void (ApplesoftFileViewer::*)(bool)>(&ApplesoftFileViewer::setBreakAfterReturn)); + } + menu->addAction(m_blankAfterReturnsAction); + + if (!m_showCtrlCharsAction) + { + m_showCtrlCharsAction = new QAction("Show &Control Characters",this); + m_showCtrlCharsAction->setCheckable(true); + m_showCtrlCharsAction->setChecked(settings.value("ASViewer.showCtrlChars",false).toBool()); + setIndentCode(settings.value("ASViewer.showCtrlChars",false).toBool(),NoReformat); + + connect(m_showCtrlCharsAction, &QAction::toggled, ui->findText, &QLineEdit::clear); + connect(m_showCtrlCharsAction, &QAction::toggled, + this, static_cast(&ApplesoftFileViewer::setShowCtrlChars)); + } + menu->addAction(m_showCtrlCharsAction); + + + menu->addSeparator(); + + if (!m_wordWrapAction) + { + m_wordWrapAction = new QAction("&Word Wrap",this); + m_wordWrapAction->setCheckable(true); + m_wordWrapAction->setChecked(settings.value("ASViewer.WordWrap",true).toBool()); + toggleWordWrap(settings.value("ASViewer.WordWrap",true).toBool()); + connect(m_wordWrapAction, &QAction::triggered, this, &ApplesoftFileViewer::toggleWordWrap); + } + menu->addAction(m_wordWrapAction); + + if (!m_syntaxHighlightingAction) + { + m_syntaxHighlightingAction = new QAction("&Syntax Highlighting",this); + m_syntaxHighlightingAction->setCheckable(true); + m_syntaxHighlightingAction->setChecked(settings.value("ASViewer.syntaxHighlighting",false).toBool()); + setIndentCode(settings.value("ASViewer.syntaxHighlighting",false).toBool(),NoReformat); + + connect(m_syntaxHighlightingAction, &QAction::toggled, ui->findText, &QLineEdit::clear); + connect(m_syntaxHighlightingAction, &QAction::toggled, + this, static_cast(&ApplesoftFileViewer::setSyntaxHighlighting)); + } + menu->addAction(m_syntaxHighlightingAction); + + + + menu->addSeparator(); + + if (!m_showVarExplorerAction) + { + m_showVarExplorerAction = new QAction("Show &Variable Explorer...",this); + m_showVarExplorerAction->setCheckable(false); + connect(m_showVarExplorerAction, &QAction::triggered, this, &ApplesoftFileViewer::launchVarBrowser); + } + menu->addAction(m_showVarExplorerAction); + + menu->addSeparator(); + + if (!m_setFontAction) + { + m_setFontAction = new QAction("Set &Font...",this); + connect(m_setFontAction, &QAction::triggered, this, [this] { + bool ok; + QFont font = QFontDialog::getFont(&ok, + ui->textArea->font(), + this, "Set Font", + QFontDialog::MonospacedFonts); + if (ok) { + setTextFont(font,ForceReformat); + fontToSettings("ASViewer.textFont",font); + } + + }); + } + menu->addAction(m_setFontAction); + + return true; +} + +bool ApplesoftFileViewer::optionsMenuItems(QMenu *menu) +{ + return makeMenuOptions(menu); +} + + +void ApplesoftFileViewer::toggleWordWrap(bool enabled) +{ + if (enabled) + { + ui->textArea->setWordWrapMode(QTextOption::WordWrap); + } + else + { + ui->textArea->setWordWrapMode(QTextOption::NoWrap); + } + QSettings settings; + settings.setValue("ASViewer.WordWrap",enabled); +} + +void ApplesoftFileViewer::setIndentCode(bool enabled, ReformatRule reformat) +{ + if (enabled) + { + m_formatter->setFlags(m_formatter->flags() | ApplesoftFormatter::ReindentCode); + } + else + { + m_formatter->setFlags(m_formatter->flags() & ~ApplesoftFormatter::ReindentCode); + } + QSettings settings; + settings.setValue("ASViewer.indentCode",enabled); + if (reformat == ForceReformat) + reformatText(); +} + +void ApplesoftFileViewer::setBreakAfterReturn(bool enabled, ReformatRule reformat) +{ + if (enabled) + { + m_formatter->setFlags(m_formatter->flags() | ApplesoftFormatter::BreakAfterReturn); + } + else + { + m_formatter->setFlags(m_formatter->flags() & ~ApplesoftFormatter::BreakAfterReturn); + } + QSettings settings; + settings.setValue("ASViewer.breakAfterReturn",enabled); + if (reformat == ForceReformat) + reformatText(); +} + +void ApplesoftFileViewer::setShowCtrlChars(bool enabled, ReformatRule reformat) +{ + if (enabled) + { + m_formatter->setFlags(m_formatter->flags() | ApplesoftFormatter::ShowCtrlChars); + } + else + { + m_formatter->setFlags(m_formatter->flags() & ~ApplesoftFormatter::ShowCtrlChars); + } + QSettings settings; + settings.setValue("ASViewer.showCtrlChars",enabled); + if (reformat == ForceReformat) + reformatText(); +} + +void ApplesoftFileViewer::setSyntaxHighlighting(bool enabled) +{ + setSyntaxHighlighting(enabled, ForceReformat); +} + +void ApplesoftFileViewer::setSyntaxHighlighting(bool enabled, ReformatRule reformat) +{ + if (enabled) + { + m_formatter->setFlags(m_formatter->flags() | ApplesoftFormatter::SyntaxHighlighting); + } + else + { + m_formatter->setFlags(m_formatter->flags() & ~ApplesoftFormatter::SyntaxHighlighting); + } + QSettings settings; + settings.setValue("ASViewer.syntaxHighlighting",enabled); + if (reformat == ForceReformat) + reformatText(); +} + +void ApplesoftFileViewer::setIntsAsHex(bool enabled, ReformatRule reformat) +{ + if (enabled) + { + m_formatter->setFlags(m_formatter->flags() | ApplesoftFormatter::ShowIntsAsHex); + } + else + { + m_formatter->setFlags(m_formatter->flags() & ~ApplesoftFormatter::ShowIntsAsHex); + } + QSettings settings; + settings.setValue("ASViewer.intsAsHex",enabled); + if (reformat == ForceReformat) + reformatText(); +} + +void ApplesoftFileViewer::setTextFont(const QFont &font, ReformatRule reformat) +{ + ui->textArea->setFont(font); + if (reformat == ForceReformat) + { + reformatText(); + } +} + +void ApplesoftFileViewer::reformatText() +{ + QTextDocument *doc = ui->textArea->document(); + + doc->clear(); + m_formatter->formatDocument(doc); + + QTextCursor cursor = ui->textArea->textCursor(); + cursor.movePosition(QTextCursor::Start,QTextCursor::MoveAnchor); + ui->textArea->setTextCursor(cursor); + + //qDebug() << m_formatter->flowTargets(); +} + +void ApplesoftFileViewer::setFile(GenericFile *file) { + ApplesoftFile *af = dynamic_cast(file); + if (af) + { + setFile(af); + } +} + +void ApplesoftFileViewer::setFile(ApplesoftFile *file) { + m_file = file; + m_formatter->setFile(file); + + QString title = QString("Applesoft Viewer: %1").arg(m_file->filename()); + m_title = title; + setWindowTitle(title); + QTextDocument *doc = ui->textArea->document(); + m_formatter->formatDocument(doc); + QTextCursor cursor = ui->textArea->textCursor(); + cursor.movePosition(QTextCursor::Start,QTextCursor::MoveAnchor); + ui->textArea->setTextCursor(cursor); +} + +void ApplesoftFileViewer::setData(QByteArray data) +{ + ui->textArea->setText(data); +} + +void ApplesoftFileViewer::setText(QString text) +{ + ui->textArea->setHtml(text); +} + +void ApplesoftFileViewer::launchVarBrowser() +{ + if (!m_afdv) + { + m_afdv = new ApplesoftFileDetailViewer(m_file); + qDebug() << "m_afdv = " << m_afdv; + m_afdv->setWindowTitle(QString("Variables - %1").arg(m_file->filename())); + } + m_afdv->show(); +} + +void ApplesoftFileViewer::findText() +{ + //TODO: Make this much more robust + + QString searchString = ui->findText->text(); + QTextDocument *document = ui->textArea->document(); + + if (m_isFirstFind == false) + { + document->undo(); + } + + if (searchString.isEmpty()) { + ui->findResults->setText(""); + return; + } + + QTextCursor highlightCursor(document); + QTextCursor cursor(document); + + cursor.beginEditBlock(); + + QTextCharFormat plainFormat(highlightCursor.charFormat()); + QTextCharFormat colorFormat = plainFormat; + colorFormat.setBackground(Qt::yellow); + int count = 0; + while(!highlightCursor.isNull() && !highlightCursor.atEnd()) { + highlightCursor = document->find(searchString, highlightCursor); + + if (!highlightCursor.isNull()) { + count++; + int position = highlightCursor.position(); + highlightCursor.setPosition(position,QTextCursor::KeepAnchor); + highlightCursor.mergeCharFormat(colorFormat); + } + } + QString results = QString("%1 match%2").arg(count).arg(count != 1?"es":""); + ui->findResults->setText(results); + cursor.endEditBlock(); + ui->textArea->ensureCursorVisible(); + + m_isFirstFind = false; +} + +bool ApplesoftFileViewer::canPrint() const { return true; } + +void ApplesoftFileViewer::doPrint() +{ + QPrinter printer; + + QPrintDialog dialog(&printer, this); + dialog.setWindowTitle(tr("Print Applesoft File")); + if (ui->textArea->textCursor().hasSelection()) + dialog.addEnabledOption(QAbstractPrintDialog::PrintSelection); + if (dialog.exec() != QDialog::Accepted) { + return; + } + + QTextDocument printDoc; + QFont printFont; + printFont.setStyleHint(QFont::Monospace); + printFont.setPointSize(10); + printDoc.setDefaultFont(printFont); + QTextOption printOptions; + printOptions.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere); + printDoc.setDefaultTextOption(printOptions); + m_formatter->formatDocument(&printDoc); + printDoc.print(&printer); + + //ui->textArea->document()->print(&printer); +} + +bool ApplesoftFileViewer::canExport() const { return true; } + +void ApplesoftFileViewer::doExport() +{ + QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); + QDir savename = QDir(defaultPath).filePath(m_file->filename()+".txt"); + + QString saveName = QFileDialog::getSaveFileName(this, + tr("Export Applesoft"), savename.path(), tr("Text Files (*.txt)")); + + if (saveName == "") return; // User cancelled + + qDebug() << "Set filename: " << saveName; + + QFile saveFile(saveName); + if (!saveFile.open(QIODevice::WriteOnly | QIODevice::Text)) + { + QMessageBox::warning(this,"Save Error","Could not save "+saveName); + return; + } + + QTextStream out(&saveFile); + out << ui->textArea->document()->toPlainText(); + saveFile.close(); +} + diff --git a/src/ui/viewers/applesoftfileviewer.h b/src/ui/viewers/applesoftfileviewer.h index 5e1705a..cbff63c 100644 --- a/src/ui/viewers/applesoftfileviewer.h +++ b/src/ui/viewers/applesoftfileviewer.h @@ -1,83 +1,86 @@ -#ifndef APPLESOFTFILEVIEWER_H -#define APPLESOFTFILEVIEWER_H - -#include -#include -#include - -#include "applesoftfile.h" -#include "applesoftformatter.h" -#include "viewerbase.h" -#include "applesoftfiledetailviewer.h" - - -namespace Ui { -class ApplesoftFileViewer; -} - -class ApplesoftFileViewer : public FileViewerInterface -{ - Q_OBJECT - -public: - - typedef enum { - ForceReformat, - NoReformat - } ReformatRule; - - ApplesoftFileViewer(QWidget *parent = 0); - ~ApplesoftFileViewer(); - - virtual bool optionsMenuItems(QMenu *menu); - - virtual bool canPrint() const; - - bool canExport() const; - -public slots: - void setFile(GenericFile *file); - void setFile(ApplesoftFile *m_file); - void setData(QByteArray data); - void setText(QString text); - void findText(); - void doPrint(); - void doExport(); - -protected slots: - void toggleWordWrap(bool enabled); - void setSyntaxHighlighting(bool enabled); - void setSyntaxHighlighting(bool enabled, ReformatRule reformat); - - void setIndentCode(bool enabled) { setIndentCode(enabled, ForceReformat); } - void setIndentCode(bool enabled, ReformatRule reformat); - - void setIntsAsHex(bool enabled) { setIntsAsHex(enabled, ForceReformat); } - void setIntsAsHex(bool enabled, ReformatRule reformat); - - void setBreakAfterReturn(bool enabled) { setBreakAfterReturn(enabled,ForceReformat); } - void setBreakAfterReturn(bool enabled, ReformatRule reformat); - - void setShowCtrlChars(bool enabled) { setShowCtrlChars(enabled,ForceReformat); } - void setShowCtrlChars(bool enabled, ReformatRule reformat); - void launchVarBrowser(); - void reformatText(); - -private: - bool makeMenuOptions(QMenu *menu); - - ApplesoftFile *m_file; - ApplesoftFormatter *m_formatter; - bool m_isFirstFind; - Ui::ApplesoftFileViewer *ui; - ApplesoftFileDetailViewer *m_afdv; - QAction *m_showIntsAction; - QAction *m_reindentCodeAction; - QAction *m_blankAfterReturnsAction; - QAction *m_syntaxHighlightingAction; - QAction *m_showVarExplorerAction; - QAction *m_wordWrapAction; - QAction *m_showCtrlCharsAction; -}; - -#endif // APPLESOFTFILEVIEWER_H +#ifndef APPLESOFTFILEVIEWER_H +#define APPLESOFTFILEVIEWER_H + +#include +#include +#include + +#include "applesoftfile.h" +#include "applesoftformatter.h" +#include "viewerbase.h" +#include "applesoftfiledetailviewer.h" + + +namespace Ui { +class ApplesoftFileViewer; +} + +class ApplesoftFileViewer : public FileViewerInterface +{ + Q_OBJECT + +public: + + typedef enum { + ForceReformat, + NoReformat + } ReformatRule; + + ApplesoftFileViewer(QWidget *parent = 0); + ~ApplesoftFileViewer(); + + virtual bool optionsMenuItems(QMenu *menu); + + virtual bool canPrint() const; + + bool canExport() const; + +public slots: + void setFile(GenericFile *file); + void setFile(ApplesoftFile *m_file); + void setData(QByteArray data); + void setText(QString text); + void findText(); + void doPrint(); + void doExport(); + +protected slots: + void toggleWordWrap(bool enabled); + void setSyntaxHighlighting(bool enabled); + void setSyntaxHighlighting(bool enabled, ReformatRule reformat); + + void setIndentCode(bool enabled) { setIndentCode(enabled, ForceReformat); } + void setIndentCode(bool enabled, ReformatRule reformat); + + void setIntsAsHex(bool enabled) { setIntsAsHex(enabled, ForceReformat); } + void setIntsAsHex(bool enabled, ReformatRule reformat); + + void setBreakAfterReturn(bool enabled) { setBreakAfterReturn(enabled,ForceReformat); } + void setBreakAfterReturn(bool enabled, ReformatRule reformat); + + void setShowCtrlChars(bool enabled) { setShowCtrlChars(enabled,ForceReformat); } + void setShowCtrlChars(bool enabled, ReformatRule reformat); + + void setTextFont(const QFont &font, ReformatRule reformat); + void launchVarBrowser(); + void reformatText(); + +private: + bool makeMenuOptions(QMenu *menu); + + ApplesoftFile *m_file; + ApplesoftFormatter *m_formatter; + bool m_isFirstFind; + Ui::ApplesoftFileViewer *ui; + ApplesoftFileDetailViewer *m_afdv; + QAction *m_showIntsAction; + QAction *m_reindentCodeAction; + QAction *m_blankAfterReturnsAction; + QAction *m_syntaxHighlightingAction; + QAction *m_showVarExplorerAction; + QAction *m_wordWrapAction; + QAction *m_showCtrlCharsAction; + QAction *m_setFontAction; +}; + +#endif // APPLESOFTFILEVIEWER_H diff --git a/src/ui/viewers/applesoftfileviewer.ui b/src/ui/viewers/applesoftfileviewer.ui index d1c6a52..abeab7b 100644 --- a/src/ui/viewers/applesoftfileviewer.ui +++ b/src/ui/viewers/applesoftfileviewer.ui @@ -1,80 +1,71 @@ - - - ApplesoftFileViewer - - - - 0 - 0 - 294 - 270 - - - - - Courier 10 Pitch - 10 - - - - Form - - - - - - - - - - false - - - - - - - Find - - - - - - - - - - - - - - - - - - - Misc Fixed - 14 - 50 - false - PreferAntialias - - - - false - - - - - - - - FileViewerInterface - QWidget -
viewerbase.h
- 1 -
-
- - -
+ + + ApplesoftFileViewer + + + + 0 + 0 + 294 + 270 + + + + + Courier 10 Pitch + 10 + + + + Form + + + + + + + + + + false + + + + + + + Find + + + + + + + + + + + + + + + + + + false + + + + + + + + FileViewerInterface + QWidget +
viewerbase.h
+ 1 +
+
+ + +
diff --git a/src/ui/viewers/charsetviewer.cpp b/src/ui/viewers/charsetviewer.cpp index a043384..04153ba 100644 --- a/src/ui/viewers/charsetviewer.cpp +++ b/src/ui/viewers/charsetviewer.cpp @@ -1,163 +1,163 @@ -#include "charsetviewer.h" -#include -#include -#include -#include - -CharSetViewer::CharSetViewer(QWidget *parent) : FileViewerInterface(parent) -{ - m_file = Q_NULLPTR; - m_cse = Q_NULLPTR; - - QGridLayout *qgl = new QGridLayout(this); - setLayout(qgl); - QString title = QString("Character Set Viewer"); - setWindowTitle(title); -} - -CharSetViewer::~CharSetViewer() -{ -} - -void CharSetViewer::setFile(GenericFile *file) -{ - if (dynamic_cast(file)) - { - BinaryFile *bf = dynamic_cast(file); - setFile(bf); - } -} - -void CharSetViewer::setFile(BinaryFile *file) -{ - m_file = file; - QString title = QString("Character Set Viewer: %1").arg(file->filename()); - setWindowTitle(title); - m_data = file->data(); - m_data.resize(file->length()); - m_charset.buildSetFromSetBlob(m_data); - - int xpos = 0; - int ypos = 0; - foreach (CharSetCharacter csc, m_charset.allCharacters()) - { - CharacterWidget *cw = new CharacterWidget(this,csc); - cw->showGrid(true); - cw->enableBitShift(true); - cw->setBgColor(Qt::white); - cw->setFgColor(Qt::black); - - QGridLayout *qgl = qobject_cast(this->layout()); - qgl->addWidget(cw,ypos,xpos); - //cw->move(xpos,ypos); - cw->show(); - - xpos+= cw->width(); - if (xpos/cw->width() > 11) { - xpos = 0; - ypos += cw->height(); - } - } -} - -bool CharSetViewer::optionsMenuItems(QMenu *menu) -{ - QSettings settings; - - QAction *action = new QAction("Show &Grid",menu); - action->setCheckable(true); - action->setChecked(settings.value("CharSetViewer.ShowGrid",true).toBool()); - showGrid(settings.value("CharSetViewer.ShowGrid",true).toBool()); - connect(action, &QAction::toggled, this, &CharSetViewer::showGrid); - menu->addAction(action); - - action = new QAction("&Enable Bit Shift",menu); - action->setCheckable(true); - action->setChecked(settings.value("CharSetViewer.EnableBitShift",true).toBool()); - enableBitShift(settings.value("CharSetViewer.EnableBitShift",true).toBool()); - connect(action, &QAction::toggled, this, &CharSetViewer::enableBitShift); - menu->addAction(action); - - menu->addSeparator(); - - action = new QAction("&Character Set Explorer..."); - connect(action, &QAction::triggered, this, &CharSetViewer::showExplorer); - menu->addAction(action); - - return true; -} - -void CharSetViewer::showExplorer() -{ - if (!m_cse) { - m_cse = new CharacterSetExplorer(this); - connect(m_cse, &CharacterSetExplorer::destroyed, this, &CharSetViewer::cleanupExplorer); - m_cse->setCharSet(m_charset); - } - m_cse->show(); - m_cse->raise(); -} - -void CharSetViewer::cleanupExplorer() -{ - m_cse = Q_NULLPTR; -} - -QList CharSetViewer::getChildren() -{ - QList retval; - foreach (QObject *child, children()) - { - if (dynamic_cast(child)) - { - retval.append(dynamic_cast(child)); - } - } - return retval; -} - -void CharSetViewer::setFgColor(QColor color) -{ - foreach (auto child, getChildren()) - { - child->setFgColor(color); - } -} - -void CharSetViewer::setBgColor(QColor color) -{ - foreach (auto child, getChildren()) - { - child->setBgColor(color); - } -} - -void CharSetViewer::setGridColor(QColor color) -{ - foreach (auto child, getChildren()) - { - child->setGridColor(color); - } -} - -void CharSetViewer::showGrid(bool show) -{ - QSettings settings; - settings.setValue("CharSetViewer.ShowGrid",show); - - foreach (auto child, getChildren()) - { - child->showGrid(show); - } -} - -void CharSetViewer::enableBitShift(bool enable) -{ - QSettings settings; - settings.setValue("CharSetViewer.EnableBitShift",enable); - - foreach (auto child, getChildren()) - { - child->enableBitShift(enable); - } -} +#include "charsetviewer.h" +#include +#include +#include +#include + +CharSetViewer::CharSetViewer(QWidget *parent) : FileViewerInterface(parent) +{ + m_file = Q_NULLPTR; + m_cse = Q_NULLPTR; + + QGridLayout *qgl = new QGridLayout(this); + setLayout(qgl); + QString title = QString("Character Set Viewer"); + setWindowTitle(title); +} + +CharSetViewer::~CharSetViewer() +{ +} + +void CharSetViewer::setFile(GenericFile *file) +{ + if (dynamic_cast(file)) + { + BinaryFile *bf = dynamic_cast(file); + setFile(bf); + } +} + +void CharSetViewer::setFile(BinaryFile *file) +{ + m_file = file; + QString title = QString("Character Set Viewer: %1").arg(file->filename()); + setWindowTitle(title); + m_data = file->data(); + m_data.resize(file->length()); + m_charset.buildSetFromSetBlob(m_data); + + int xpos = 0; + int ypos = 0; + foreach (CharSetCharacter csc, m_charset.allCharacters()) + { + CharacterWidget *cw = new CharacterWidget(this,csc); + cw->showGrid(true); + cw->enableBitShift(true); + cw->setBgColor(Qt::white); + cw->setFgColor(Qt::black); + + QGridLayout *qgl = qobject_cast(this->layout()); + qgl->addWidget(cw,ypos,xpos); + //cw->move(xpos,ypos); + cw->show(); + + xpos+= cw->width(); + if (xpos/cw->width() > 11) { + xpos = 0; + ypos += cw->height(); + } + } +} + +bool CharSetViewer::optionsMenuItems(QMenu *menu) +{ + QSettings settings; + + QAction *action = new QAction("Show &Grid",menu); + action->setCheckable(true); + action->setChecked(settings.value("CharSetViewer.ShowGrid",true).toBool()); + showGrid(settings.value("CharSetViewer.ShowGrid",true).toBool()); + connect(action, &QAction::toggled, this, &CharSetViewer::showGrid); + menu->addAction(action); + + action = new QAction("&Enable Bit Shift",menu); + action->setCheckable(true); + action->setChecked(settings.value("CharSetViewer.EnableBitShift",true).toBool()); + enableBitShift(settings.value("CharSetViewer.EnableBitShift",true).toBool()); + connect(action, &QAction::toggled, this, &CharSetViewer::enableBitShift); + menu->addAction(action); + + menu->addSeparator(); + + action = new QAction("&Character Set Explorer..."); + connect(action, &QAction::triggered, this, &CharSetViewer::showExplorer); + menu->addAction(action); + + return true; +} + +void CharSetViewer::showExplorer() +{ + if (!m_cse) { + m_cse = new CharacterSetExplorer(this); + connect(m_cse, &CharacterSetExplorer::destroyed, this, &CharSetViewer::cleanupExplorer); + m_cse->setCharSet(m_charset); + } + m_cse->show(); + m_cse->raise(); +} + +void CharSetViewer::cleanupExplorer() +{ + m_cse = Q_NULLPTR; +} + +QList CharSetViewer::getChildren() +{ + QList retval; + foreach (QObject *child, children()) + { + if (dynamic_cast(child)) + { + retval.append(dynamic_cast(child)); + } + } + return retval; +} + +void CharSetViewer::setFgColor(QColor color) +{ + foreach (auto child, getChildren()) + { + child->setFgColor(color); + } +} + +void CharSetViewer::setBgColor(QColor color) +{ + foreach (auto child, getChildren()) + { + child->setBgColor(color); + } +} + +void CharSetViewer::setGridColor(QColor color) +{ + foreach (auto child, getChildren()) + { + child->setGridColor(color); + } +} + +void CharSetViewer::showGrid(bool show) +{ + QSettings settings; + settings.setValue("CharSetViewer.ShowGrid",show); + + foreach (auto child, getChildren()) + { + child->showGrid(show); + } +} + +void CharSetViewer::enableBitShift(bool enable) +{ + QSettings settings; + settings.setValue("CharSetViewer.EnableBitShift",enable); + + foreach (auto child, getChildren()) + { + child->enableBitShift(enable); + } +} diff --git a/src/ui/viewers/charsetviewer.h b/src/ui/viewers/charsetviewer.h index 7b65411..4a4bd30 100644 --- a/src/ui/viewers/charsetviewer.h +++ b/src/ui/viewers/charsetviewer.h @@ -1,51 +1,51 @@ -#ifndef CHARSETVIEWER_H -#define CHARSETVIEWER_H - -#include "binaryfile.h" -#include "characterwidget.h" -#include "fileviewerinterface.h" -#include "CharacterSetExplorer.h" - -#include - -class CharSetViewer : public FileViewerInterface -{ - Q_OBJECT -public: - explicit CharSetViewer(QWidget *parent = 0); - virtual ~CharSetViewer(); - - void setFile(GenericFile *file); - void setFile(BinaryFile *file); - - virtual bool optionsMenuItems(QMenu *menu); - -public slots: - void setFgColor(QColor color); - void setBgColor(QColor color); - void setGridColor(QColor color); - - void showGrid(bool show); - void enableBitShift(bool enable); - - void showExplorer(); - -signals: - -protected: - QList getChildren(); - -protected slots: - void cleanupExplorer(); - -private: - BinaryFile *m_file; - - QByteArray m_data; - - CharacterSet m_charset; - - CharacterSetExplorer *m_cse; -}; - -#endif // CHARSETVIEWER_H +#ifndef CHARSETVIEWER_H +#define CHARSETVIEWER_H + +#include "binaryfile.h" +#include "characterwidget.h" +#include "fileviewerinterface.h" +#include "CharacterSetExplorer.h" + +#include + +class CharSetViewer : public FileViewerInterface +{ + Q_OBJECT +public: + explicit CharSetViewer(QWidget *parent = 0); + virtual ~CharSetViewer(); + + void setFile(GenericFile *file); + void setFile(BinaryFile *file); + + virtual bool optionsMenuItems(QMenu *menu); + +public slots: + void setFgColor(QColor color); + void setBgColor(QColor color); + void setGridColor(QColor color); + + void showGrid(bool show); + void enableBitShift(bool enable); + + void showExplorer(); + +signals: + +protected: + QList getChildren(); + +protected slots: + void cleanupExplorer(); + +private: + BinaryFile *m_file; + + QByteArray m_data; + + CharacterSet m_charset; + + CharacterSetExplorer *m_cse; +}; + +#endif // CHARSETVIEWER_H diff --git a/src/ui/viewers/disassemblerviewer.cpp b/src/ui/viewers/disassemblerviewer.cpp index da4edc6..cdea699 100644 --- a/src/ui/viewers/disassemblerviewer.cpp +++ b/src/ui/viewers/disassemblerviewer.cpp @@ -1,1621 +1,1658 @@ -#include "disassemblerviewer.h" -#include "ui_disassemblerviewer.h" -#include "disassembler.h" -#include "memory.h" -#include "util.h" -#include "relocatablefile.h" - -#include -#include -#include -#include - - -DisassemblerViewer::DisassemblerViewer(QWidget *parent) : - FileViewerInterface(parent), - ui(new Ui::DisassemblerViewer) -{ - ui->setupUi(this); - m_isRelo = false; - m_dmd = Q_NULLPTR; - m_wordWrapAction = Q_NULLPTR; - m_showMetadataAction = Q_NULLPTR; - - QString title = QString("Disassembly Viewer"); - setWindowTitle(title); - - QSettings settings; - toggleWordWrap(settings.value("DisassemblerViewer.WordWrap",true).toBool()); -} - -DisassemblerViewer::~DisassemblerViewer() -{ - delete ui; -} - -void DisassemblerViewer::setFile(GenericFile *file) -{ - - if (dynamic_cast(file)) - { - setFile(dynamic_cast(file)); - } - if (dynamic_cast(file)) - { - setFile(dynamic_cast(file)); - } -} - -void DisassemblerViewer::toggleWordWrap(bool enabled) -{ - if (enabled) - { - ui->textArea->setWordWrapMode(QTextOption::WordWrap); - } - else - { - ui->textArea->setWordWrapMode(QTextOption::NoWrap); - } - QSettings settings; - settings.setValue("DisassemblerViewer.WordWrap",enabled); -} - -void DisassemblerViewer::setFile(BinaryFile *file) { - m_file = file; - m_isRelo = false; - - m_bfm = new BinaryFileMetadata(m_file, file->address(), this); - - connect(m_bfm, &BinaryFileMetadata::doDisassemble, - this, &DisassemblerViewer::handleDisassembleRequest); - - QString title = QString("Disassembler Viewer: %1").arg(m_file->filename()); - setWindowTitle(title); - - quint16 address = file->address(); - - m_mem.addFile(m_file->data(), address); - - QList addresses = m_bfm->entryPoints()->getEntryPointAddresses(); - if (!addresses.count()) { addresses.append(address); } - handleDisassembleRequest(addresses); -} - -void DisassemblerViewer::setFile(RelocatableFile *file) { - m_file = file; - m_isRelo = true; - - m_bfm = new BinaryFileMetadata(m_file, file->address() + 6, this); - - connect(m_bfm, &BinaryFileMetadata::doDisassemble, - this, &DisassemblerViewer::handleDisassembleRequest); - - QString title = QString("Disassembler Viewer: %1 (Relocatable)").arg(m_file->filename()); - setWindowTitle(title); - - quint16 address = file->address() + 6 ; // Handle offset for relocatable metadata - - m_mem.addFile(m_file->data(), address); - - QList addresses = m_bfm->entryPoints()->getEntryPointAddresses(); - if (!addresses.count()) { addresses.append(address); } - handleDisassembleRequest(addresses); -} - -void DisassemblerViewer::handleDisassembleRequest(QList addresses) -{ - QStringList strings; - - disassemble(addresses); - strings += getDisassemblyStrings(); - qSort(strings); - strings.removeDuplicates(); - - if (m_isRelo) - { - QByteArray joinedlines = qPrintable(strings.join("\n")); - QStringList rd = (dynamic_cast(m_file))->decodeRelocatableDict(); - QByteArray rdlines = qPrintable(rd.join("\n")); - ui->textArea->clear(); - setData(joinedlines + "\n\n== Relocation Dictionary ==\n\n" + rdlines); - } - else - { - QByteArray joinedlines = qPrintable(strings.join("\n")); - ui->textArea->clear(); - setData(joinedlines); - } -} - - -QStringList DisassemblerViewer::getDisassemblyStrings() { - return m_disassemblyStrings; -} - -void DisassemblerViewer::disassemble(QList entryPoints) { - - Disassembler dis(m_mem.values()); - - int length = m_file->length(); - - QList lines = dis.disassemble(m_file->address(), - m_file->address()+length, - entryPoints); - dis.setUnknownToData(m_file->address(),m_file->address()+length); - m_jumpLines = dis.getJumpLines(); - - QStringList formattedLines; - - foreach (DisassembledItem di, lines) { - QString ds = di.rawDisassembledString(); - if (di.hasArg()) { - QString potentialLabel = getPotentialLabel(di.arg16()); - if (!potentialLabel.isEmpty()) { - if (ds.contains("_ARG16_")) { ds.replace("_ARG16_",potentialLabel); } - else if (ds.contains("_ARG8_")) { ds.replace("_ARG8_",potentialLabel); } - } else { - ds = di.disassembledString(); - } - } - QString raw = di.rawDisassembledString(); - if (raw.contains("RTS")) { ds += "\n"; } //TODO: Temp for spacing - if (raw.contains("JMP")) { ds += "\n"; } //TODO: Temp for spacing - if (raw.contains("???")) { ds += "\n"; } //TODO: Temp for spacing - if (raw.contains("BRA")) { ds += "\n"; } //TODO: Temp for spacing - if (raw.contains("BRK")) { ds += "\n"; } //TODO: Temp for spacing - - - - QString newline = QString("%1: %2 %3").arg(di.hexAddress()).arg(di.hexString()).arg(ds); - formattedLines.append(newline); - } - - for (int idx = m_file->address(); idx < m_file->address()+length; idx++) - { - if (dis.memoryUsageMap()->at(idx).testFlag(Data) || - dis.memoryUsageMap()->at(idx).testFlag(Unknown)) - { - QString newline; - bool usedefault = false; - - if (m_bfm->assemblerSymbols()->hasAssemSymbolAtAddress(idx)) - { - int loc = m_bfm->assemblerSymbols()->locationOfSymbolAtAddress(idx); - if (m_bfm->assemblerSymbols()->at(loc).symbolsize == SizeByte) - { - newline = QString("%1: .Byte $%2 ; %3").arg(uint16ToHex(idx)) - .arg(uint8ToHex(m_mem.at(idx))) - .arg(m_bfm->assemblerSymbols()->at(loc).name);; - } - else if (m_bfm->assemblerSymbols()->at(loc).symbolsize == SizeWord) - { - newline = QString("%1: .Word $%2 ; %3").arg(uint16ToHex(idx)) - .arg(uint16ToHex(m_mem.at(idx) + (m_mem.at(idx+1)*256))) - .arg(m_bfm->assemblerSymbols()->at(loc).name); - idx++; - } - else - { - usedefault = true; - } - } - else - { - usedefault = true; - } - - if (usedefault) - { - newline = QString("%1: %2 %3 (%4)").arg(uint16ToHex(idx)) - .arg(uint8ToHex(m_mem.at(idx))) - .arg(makeDescriptorStringForVal(m_mem.at(idx))) - .arg(dis.getMnemonicForOp(m_mem.at(idx))); - } - formattedLines.append(newline); - } - } - qSort(formattedLines); - - m_disassemblyStrings = formattedLines; -} - - - -QString DisassemblerViewer::getPotentialLabel(quint16 address) { - QString retval = QString(); - - if (address == 0x24) { retval = "MON.CURSORHORIZ"; } - else if (address == 0x28) { retval = "MON.BASL"; } - else if (address == 0x29) { retval = "MON.BASH"; } - else if (address == 0x33) { retval = "MON.PROMPTCHAR"; } - else if (address == 0x36) { retval = "DOS.CSWL"; } - else if (address == 0x37) { retval = "DOS.CSWH"; } - else if (address == 0x38) { retval = "DOS.KSWL"; } - else if (address == 0x39) { retval = "DOS.KSWH"; } - else if (address == 0x40) { retval = "DOS.FILE_BUFFER_L"; } - else if (address == 0x41) { retval = "DOS.FILE_BUFFER_H"; } - else if (address == 0x42) { retval = "DOS.BUFFER_ADDR_L"; } - else if (address == 0x43) { retval = "DOS.BUFFER_ADDR_H"; } - else if (address == 0x44) { retval = "DOS.NUMERIC_OPERAND_L"; } - else if (address == 0x45) { retval = "DOS.NUMERIC_OPERAND_H"; } - - else if (address == 0x67) { retval = "AS.PROG_STARTL"; } - else if (address == 0x68) { retval = "AS.PROG_STARTH"; } - - else if (address == 0x69) { retval = "AS.VAR_STARTL"; } - else if (address == 0x6A) { retval = "AS.VAR_STARTH"; } - - else if (address == 0x6B) { retval = "AS.ARRAY_STARTL"; } - else if (address == 0x6C) { retval = "AS.ARRAY_STARTH"; } - - else if (address == 0x6D) { retval = "AS.NUMSTORE_ENDL"; } - else if (address == 0x6E) { retval = "AS.NUMSTORE_ENDH"; } - - else if (address == 0x6F) { retval = "AS.STRING_STARTL"; } - else if (address == 0x70) { retval = "AS.STRING_STARTH"; } - - else if (address == 0x71) { retval = "AS.PTR_9L"; } - else if (address == 0x72) { retval = "AS.PTR_9H"; } - - else if (address == 0x73) { retval = "AS.HIMEM_L"; } - else if (address == 0x74) { retval = "AS.HIMEM_H"; } - - else if (address == 0x75) { retval = "AS.CURR_LINENUM_L"; } - else if (address == 0x76) { retval = "AS.CURR_LINENUM_H"; } - - else if (address == 0x77) { retval = "AS.INTR_LINENUM_L"; } - else if (address == 0x78) { retval = "AS.INTR_LINENUM_H"; } - - else if (address == 0x79) { retval = "AS.NEXT_STATEMENT_L"; } - else if (address == 0x7A) { retval = "AS.NEXT_STATEMENT_H"; } - - else if (address == 0x7B) { retval = "AS.DATA_LINENUM_L"; } - else if (address == 0x7C) { retval = "AS.DATA_LINENUM_H"; } - - else if (address == 0x7D) { retval = "AS.DATA_ADDR_L"; } - else if (address == 0x7E) { retval = "AS.DATA_ADDR_H"; } - - else if (address == 0x7F) { retval = "AS.INPUT_SRC_L"; } - else if (address == 0x80) { retval = "AS.INPUT_SRC_H"; } - - else if (address == 0x81) { retval = "AS.LAST_VARNAME_L"; } - else if (address == 0x82) { retval = "AS.LAST_VARNAME_H"; } - - else if (address == 0x83) { retval = "AS.LAST_VARVAL_L"; } - else if (address == 0x84) { retval = "AS.LAST_VARVAL_H"; } - - else if (address == 0xAF) { retval = "AS.PROGEND_L"; } - else if (address == 0xB0) { retval = "AS.PROGEND_H"; } - - else if (address == 0xD6) { retval = "DOS.AS.LOCK"; } - - else if (address == 0xE0) { retval = "AS.HGR_X_L"; } - else if (address == 0xE1) { retval = "AS.HGR_X_H"; } - else if (address == 0xE2) { retval = "AS.HGR_Y"; } - - else if (address == 0xE4) { retval = "AS.HGR_COLOR"; } - - else if (address == 0xE8) { retval = "AS.SHAPETBL_L"; } - else if (address == 0xE9) { retval = "AS.SHAPETBL_H"; } - - else if (address == 0xEA) { retval = "AS.HGR_COLLISION_CTR"; } - - else if (address == 0x03d0) { retval = "DOS.WARMSTART"; } - else if (address == 0x03d3) { retval = "DOS.COLDSTART"; } - else if (address == 0x03d6) { retval = "DOS.FILE_MANAGER"; } - else if (address == 0x03d9) { retval = "DOS.RWTS"; } - else if (address == 0x03dc) { retval = "DOS.FM_PARAM_LIST_LOCATE"; } - else if (address == 0x03e3) { retval = "DOS.RWTS_PARAM_LIST_LOCATE"; } - else if (address == 0x03ea) { retval = "DOS.REPLACE_DOS_INTERCEPTS"; } - else if (address == 0x03ef) { retval = "DOS.AUTOSTART_BRK_HANDLER"; } - else if (address == 0x03f2) { retval = "DOS.AUTOSTART_RESET_HANDLER"; } - else if (address == 0x03f4) { retval = "DOS.POWERUP_BYTE"; } - else if (address == 0x03f5) { retval = "AMPR_VEC"; } - else if (address == 0x03f8) { retval = "MON.CTRL_Y_VEC"; } - else if (address == 0x03fb) { retval = "DOS.NMI_HANDLER"; } - else if (address == 0x03fe) { retval = "DOS.IRQ_HANDLER"; } - - else if (address == 0x0400) { retval = "MON.LINE1"; } - - else if (address == 0x07f8) { retval = "MON.MSLOT"; } - else if (address == 0xc000) { retval = "KEYBOARD"; } - - else if (address == 0xc001) { retval = "M80_SET80COL"; } - else if (address == 0xc002) { retval = "M80_RDMAINRAM"; } - else if (address == 0xc003) { retval = "M80_RDCARDRAM"; } - else if (address == 0xc004) { retval = "M80_WRMAINRAM"; } - else if (address == 0xc005) { retval = "M80_WRCARDRAM"; } - - else if (address == 0xc006) { retval = "MON.SETSLOTCXROM"; } - else if (address == 0xc007) { retval = "MON.SETINTCXROM"; } - - else if (address == 0xc008) { retval = "M80_SETSTDSZ"; } - else if (address == 0xc009) { retval = "M80_SETALTZP"; } - else if (address == 0xc00A) { retval = "M80_SETINTC3ROM"; } - else if (address == 0xc00B) { retval = "M80_SETSLOTC3ROM"; } - else if (address == 0xc00C) { retval = "M80_CLR80VID"; } - else if (address == 0xc00D) { retval = "M80_SET80VID"; } - else if (address == 0xc00E) { retval = "M80_CLRALTCHAR"; } - else if (address == 0xc00F) { retval = "M80_SETALTCHAR"; } - - else if (address == 0xc010) { retval = "MON.KBDSTRB"; } - - else if (address == 0xc011) { retval = "M80_RDLCBNK2"; } - else if (address == 0xc012) { retval = "M80_RDLCRAM"; } - else if (address == 0xc013) { retval = "M80_RDRAMRD"; } - else if (address == 0xc014) { retval = "M80_RDRAMWRT"; } - - else if (address == 0xc015) { retval = "RDCXROM"; } - else if (address == 0xc016) { retval = "RDALTZP"; } - else if (address == 0xc017) { retval = "RDC3ROM"; } - - else if (address == 0xc018) { retval = "MON.RD80STORE"; } - - else if (address == 0xc019) { retval = "RDVBLBAR"; } - else if (address == 0xc01A) { retval = "RDTEXT"; } - else if (address == 0xc01B) { retval = "RDMIXED"; } - - else if (address == 0xc01c) { retval = "RDPAGE2"; } - else if (address == 0xc01D) { retval = "RDHIRES"; } - else if (address == 0xc01E) { retval = "RDALTCHAR"; } - - else if (address == 0xc01f) { retval = "RD80VID"; } - - else if (address == 0xc020) { retval = "TAPEOUT"; } - - else if (address == 0xc030) { retval = "SPKR"; } - - else if (address == 0xc040) { retval = "STROBE"; } - - else if (address == 0xc050) { retval = "SW.TXTCLR"; } - else if (address == 0xc051) { retval = "SW.TXTSET"; } - else if (address == 0xc052) { retval = "SW.MIXCLR"; } - else if (address == 0xc053) { retval = "SW.MIXSET"; } - else if (address == 0xc054) { retval = "SW.LOWSCR"; } - else if (address == 0xc055) { retval = "SW.HISCR"; } - else if (address == 0xc056) { retval = "SW.LORES"; } - else if (address == 0xc057) { retval = "SW.HIRES"; } - else if (address == 0xc058) { retval = "SW.SETAN0"; } - else if (address == 0xc059) { retval = "SW.CLRAN0"; } - else if (address == 0xc05a) { retval = "SW.SETAN1"; } - else if (address == 0xc05b) { retval = "SW.CLRAN1"; } - else if (address == 0xc05c) { retval = "SW.SETAN2"; } - else if (address == 0xc05d) { retval = "SW.CLRAN2"; } - else if (address == 0xc05e) { retval = "SW.SETAN3"; } - else if (address == 0xc05f) { retval = "SW.CLRAN3"; } - else if (address == 0xc060) { retval = "MON.TAPEIN"; } - else if (address == 0xc064) { retval = "MON.PADDL0"; } - else if (address == 0xc070) { retval = "MON.PTRIG"; } - - else if (address == 0xc080) { retval = "RDRAMBANK2_NOWRITE"; } - else if (address == 0xc081) { retval = "RDROM_WRBANK2"; } - else if (address == 0xc082) { retval = "RDROM_NOWRITE"; } - else if (address == 0xc083) { retval = "RDWRBANK2"; } - else if (address == 0xc084) { retval = "RDRAM_NOWRITE"; } - else if (address == 0xc085) { retval = "READROM_WRBANK2"; } - else if (address == 0xc086) { retval = "RDROM_NOWRITE"; } - else if (address == 0xc087) { retval = "RDWRBANK2"; } - else if (address == 0xc088) { retval = "RDBANK1_NOWRITE"; } - else if (address == 0xc089) { retval = "RDROM_WRBANK1"; } - else if (address == 0xc08A) { retval = "RDROM_NOWRITE"; } - else if (address == 0xc08B) { retval = "RDWRBANK1"; } - else if (address == 0xc08C) { retval = "RDBANK1_NOWRITE"; } - else if (address == 0xc08D) { retval = "RDROM_WRBANK1"; } - else if (address == 0xc08E) { retval = "RDROM_NOWRITE"; } - else if (address == 0xc08F) { retval = "RDWR_BANK1"; } - - else if (address == 0xc090) { retval = "SLOT1_ROM0"; } - else if (address == 0xc091) { retval = "SLOT1_ROM1"; } - else if (address == 0xc092) { retval = "SLOT1_ROM2"; } - else if (address == 0xc093) { retval = "SLOT1_ROM3"; } - else if (address == 0xc094) { retval = "SLOT1_ROM4"; } - else if (address == 0xc095) { retval = "SLOT1_ROM5"; } - else if (address == 0xc096) { retval = "SLOT1_ROM6"; } - else if (address == 0xc097) { retval = "SLOT1_ROM7"; } - else if (address == 0xc098) { retval = "SLOT1_ROM8"; } - else if (address == 0xc099) { retval = "SLOT1_ROM9"; } - else if (address == 0xc09A) { retval = "SLOT1_ROMA"; } - else if (address == 0xc09B) { retval = "SLOT1_ROMB"; } - else if (address == 0xc09C) { retval = "SLOT1_ROMC"; } - else if (address == 0xc09D) { retval = "SLOT1_ROMD"; } - else if (address == 0xc09E) { retval = "SLOT1_ROME"; } - else if (address == 0xc09F) { retval = "SLOT1_ROMF"; } - - else if (address == 0xc0A0) { retval = "SLOT2_ROM0"; } - else if (address == 0xc0A1) { retval = "SLOT2_ROM1"; } - else if (address == 0xc0A2) { retval = "SLOT2_ROM2"; } - else if (address == 0xc0A3) { retval = "SLOT2_ROM3"; } - else if (address == 0xc0A4) { retval = "SLOT2_ROM4"; } - else if (address == 0xc0A5) { retval = "SLOT2_ROM5"; } - else if (address == 0xc0A6) { retval = "SLOT2_ROM6"; } - else if (address == 0xc0A7) { retval = "SLOT2_ROM7"; } - else if (address == 0xc0A8) { retval = "SLOT2_ROM8"; } - else if (address == 0xc0A9) { retval = "SLOT2_ROM9"; } - else if (address == 0xc0AA) { retval = "SLOT2_ROMA"; } - else if (address == 0xc0AB) { retval = "SLOT2_ROMB"; } - else if (address == 0xc0AC) { retval = "SLOT2_ROMC"; } - else if (address == 0xc0AD) { retval = "SLOT2_ROMD"; } - else if (address == 0xc0AE) { retval = "SLOT2_ROME"; } - else if (address == 0xc0AF) { retval = "SLOT2_ROMF"; } - - else if (address == 0xc0B0) { retval = "SLOT3_ROM0"; } - else if (address == 0xc0B1) { retval = "SLOT3_ROM1"; } - else if (address == 0xc0B2) { retval = "SLOT3_ROM2"; } - else if (address == 0xc0B3) { retval = "SLOT3_ROM3"; } - else if (address == 0xc0B4) { retval = "SLOT3_ROM4"; } - else if (address == 0xc0B5) { retval = "SLOT3_ROM5"; } - else if (address == 0xc0B6) { retval = "SLOT3_ROM6"; } - else if (address == 0xc0B7) { retval = "SLOT3_ROM7"; } - else if (address == 0xc0B8) { retval = "SLOT3_ROM8"; } - else if (address == 0xc0B9) { retval = "SLOT3_ROM9"; } - else if (address == 0xc0BA) { retval = "SLOT3_ROMA"; } - else if (address == 0xc0BB) { retval = "SLOT3_ROMB"; } - else if (address == 0xc0BC) { retval = "SLOT3_ROMC"; } - else if (address == 0xc0BD) { retval = "SLOT3_ROMD"; } - else if (address == 0xc0BE) { retval = "SLOT3_ROME"; } - else if (address == 0xc0BF) { retval = "SLOT3_ROMF"; } - - else if (address == 0xc0C0) { retval = "SLOT4_ROM0"; } - else if (address == 0xc0C1) { retval = "SLOT4_ROM1"; } - else if (address == 0xc0C2) { retval = "SLOT4_ROM2"; } - else if (address == 0xc0C3) { retval = "SLOT4_ROM3"; } - else if (address == 0xc0C4) { retval = "SLOT4_ROM4"; } - else if (address == 0xc0C5) { retval = "SLOT4_ROM5"; } - else if (address == 0xc0C6) { retval = "SLOT4_ROM6"; } - else if (address == 0xc0C7) { retval = "SLOT4_ROM7"; } - else if (address == 0xc0C8) { retval = "SLOT4_ROM8"; } - else if (address == 0xc0C9) { retval = "SLOT4_ROM9"; } - else if (address == 0xc0CA) { retval = "SLOT4_ROMA"; } - else if (address == 0xc0CB) { retval = "SLOT4_ROMB"; } - else if (address == 0xc0CC) { retval = "SLOT4_ROMC"; } - else if (address == 0xc0CD) { retval = "SLOT4_ROMD"; } - else if (address == 0xc0CE) { retval = "SLOT4_ROME"; } - else if (address == 0xc0CF) { retval = "SLOT4_ROMF"; } - - else if (address == 0xc0D0) { retval = "SLOT5_ROM0"; } - else if (address == 0xc0D1) { retval = "SLOT5_ROM1"; } - else if (address == 0xc0D2) { retval = "SLOT5_ROM2"; } - else if (address == 0xc0D3) { retval = "SLOT5_ROM3"; } - else if (address == 0xc0D4) { retval = "SLOT5_ROM4"; } - else if (address == 0xc0D5) { retval = "SLOT5_ROM5"; } - else if (address == 0xc0D6) { retval = "SLOT5_ROM6"; } - else if (address == 0xc0D7) { retval = "SLOT5_ROM7"; } - else if (address == 0xc0D8) { retval = "SLOT5_ROM8"; } - else if (address == 0xc0D9) { retval = "SLOT5_ROM9"; } - else if (address == 0xc0DA) { retval = "SLOT5_ROMA"; } - else if (address == 0xc0DB) { retval = "SLOT5_ROMB"; } - else if (address == 0xc0DC) { retval = "SLOT5_ROMC"; } - else if (address == 0xc0DD) { retval = "SLOT5_ROMD"; } - else if (address == 0xc0DE) { retval = "SLOT5_ROME"; } - else if (address == 0xc0DF) { retval = "SLOT5_ROMF"; } - - else if (address == 0xc0E0) { retval = "SLOT6_ROM0"; } - else if (address == 0xc0E1) { retval = "SLOT6_ROM1"; } - else if (address == 0xc0E2) { retval = "SLOT6_ROM2"; } - else if (address == 0xc0E3) { retval = "SLOT6_ROM3"; } - else if (address == 0xc0E4) { retval = "SLOT6_ROM4"; } - else if (address == 0xc0E5) { retval = "SLOT6_ROM5"; } - else if (address == 0xc0E6) { retval = "SLOT6_ROM6"; } - else if (address == 0xc0E7) { retval = "SLOT6_ROM7"; } - else if (address == 0xc0E8) { retval = "SLOT6_ROM8"; } - else if (address == 0xc0E9) { retval = "SLOT6_ROM9"; } - else if (address == 0xc0EA) { retval = "SLOT6_ROMA"; } - else if (address == 0xc0EB) { retval = "SLOT6_ROMB"; } - else if (address == 0xc0EC) { retval = "SLOT6_ROMC"; } - else if (address == 0xc0ED) { retval = "SLOT6_ROMD"; } - else if (address == 0xc0EE) { retval = "SLOT6_ROME"; } - else if (address == 0xc0EF) { retval = "SLOT6_ROMF"; } - - else if (address == 0xc0F0) { retval = "SLOT7_ROM0"; } - else if (address == 0xc0F1) { retval = "SLOT7_ROM1"; } - else if (address == 0xc0F2) { retval = "SLOT7_ROM2"; } - else if (address == 0xc0F3) { retval = "SLOT7_ROM3"; } - else if (address == 0xc0F4) { retval = "SLOT7_ROM4"; } - else if (address == 0xc0F5) { retval = "SLOT7_ROM5"; } - else if (address == 0xc0F6) { retval = "SLOT7_ROM6"; } - else if (address == 0xc0F7) { retval = "SLOT7_ROM7"; } - else if (address == 0xc0F8) { retval = "SLOT7_ROM8"; } - else if (address == 0xc0F9) { retval = "SLOT7_ROM9"; } - else if (address == 0xc0FA) { retval = "SLOT7_ROMA"; } - else if (address == 0xc0FB) { retval = "SLOT7_ROMB"; } - else if (address == 0xc0FC) { retval = "SLOT7_ROMC"; } - else if (address == 0xc0FD) { retval = "SLOT7_ROMD"; } - else if (address == 0xc0FE) { retval = "SLOT7_ROME"; } - else if (address == 0xc0FF) { retval = "SLOT7_ROMF"; } - - else if (address == 0xc100) { retval = "M80_BFUNCPG"; } - else if (address == 0xc107) { retval = "M80_B.FUNCK"; } - else if (address == 0xc10E) { retval = "M80_B.FUNCNE"; } - else if (address == 0xc11f) { retval = "M80_B.OLDFUNC"; } - else if (address == 0xc129) { retval = "M80_F.CLREOP"; } - else if (address == 0xc12d) { retval = "M80_CLEOP1"; } - else if (address == 0xc143) { retval = "M80_F.HOME"; } - else if (address == 0xc14d) { retval = "M80_F.SCROLL"; } - else if (address == 0xc153) { retval = "M80_SCRL1"; } - else if (address == 0xc169) { retval = "M80_SCRL2"; } - else if (address == 0xc172) { retval = "M80_SCRL3"; } - else if (address == 0xc17d) { retval = "M80_F.CLREOL"; } - else if (address == 0xc181) { retval = "M80_CLEOL2"; } - else if (address == 0xc18a) { retval = "M80_F.SETWND"; } - else if (address == 0xc19c) { retval = "M80_F.CLEOLZ"; } - else if (address == 0xc1a1) { retval = "M80_F.GORET"; } - else if (address == 0xc1a4) { retval = "M80_B.FUNCO"; } - else if (address == 0xc1c5) { retval = "M80_NOI"; } - else if (address == 0xc1cd) { retval = "M80_B.SCROLL"; } - else if (address == 0xc1d3) { retval = "M80_B.CLREOL"; } - else if (address == 0xc1d9) { retval = "M80_B.CLEOLZ"; } - else if (address == 0xc1e1) { retval = "M80_B.CLREOP"; } - else if (address == 0xc1e7) { retval = "M80_B.SETWND"; } - else if (address == 0xc1ea) { retval = "M80_B.RESET"; } - else if (address == 0xc1ed) { retval = "M80_B.HOME"; } - else if (address == 0xc1ff) { retval = "M80_B.VECTOR"; } - else if (address == 0xc20e) { retval = "M80_B.GETCH"; } - else if (address == 0xc211) { retval = "M80_B.FUNC1"; } - else if (address == 0xc219) { retval = "M80_B.SETWNDX"; } - else if (address == 0xc221) { retval = "M80_B.SETWND2"; } - else if (address == 0xc22e) { retval = "M80_GOBACK"; } - else if (address == 0xc234) { retval = "M80_B.RESETX"; } - else if (address == 0xc252) { retval = "M80_BLAST"; } - else if (address == 0xc261) { retval = "M80_DIAGS"; } - else if (address == 0xc264) { retval = "M80_RESETRET"; } - else if (address == 0xc26e) { retval = "M80_B.ESCFIX"; } - else if (address == 0xc272) { retval = "M80_B.ESCFIX2"; } - else if (address == 0xc27a) { retval = "M80_B.ESCFIX3"; } - else if (address == 0xc27d) { retval = "M80_GORETN"; } - else if (address == 0xc280) { retval = "M80_ESCIN"; } - else if (address == 0xc284) { retval = "M80_ESCOUT"; } - else if (address == 0xc288) { retval = "M80_B.KEYIN"; } - else if (address == 0xc29c) { retval = "M80_B.KEYIN2"; } - else if (address == 0xc2b5) { retval = "M80_GOTKEY"; } - else if (address == 0xc2c6) { retval = "M80_KEYDLY"; } - else if (address == 0xc2cc) { retval = "M80_IK1"; } - else if (address == 0xc2ce) { retval = "M80_IK2"; } - else if (address == 0xc2d5) { retval = "M80_IK2A"; } - else if (address == 0xc2db) { retval = "M80_IK3"; } - else if (address == 0xc2e6) { retval = "M80_KDRETN"; } - else if (address == 0xc2e9) { retval = "M80_KDRETY"; } - else if (address == 0xc2ea) { retval = "M80_KDRET"; } - else if (address == 0xc2eb) { retval = "M80_F.RETURN"; } - else if (address == 0xc2f1) { retval = "M80_F.RET1"; } - else if (address == 0xc2f4) { retval = "M80_X.CLEOLZ"; } - else if (address == 0xc2f6) { retval = "M80_X.CLEOL2"; } - else if (address == 0xc300) { retval = "M80_CN00/M80_BASICINT"; } - else if (address == 0xc305) { retval = "M80_BASICIN"; } - else if (address == 0xc307) { retval = "M80_BASICOUT"; } - else if (address == 0xc317) { retval = "M80_BASICENT"; } - else if (address == 0xc336) { retval = "M80_BASICENT2"; } - else if (address == 0xc348) { retval = "M80_JBASINIT"; } - else if (address == 0xc34b) { retval = "M80_JPINIT"; } - else if (address == 0xc351) { retval = "M80_JPREAD"; } - else if (address == 0xc357) { retval = "M80_JPWRITE"; } - else if (address == 0xc35d) { retval = "M80_JPSTAT"; } - else if (address == 0xc363) { retval = "M80_MOVE"; } - else if (address == 0xc378) { retval = "M80_MOVEC2M"; } - else if (address == 0xc37b) { retval = "M80_MOVESTRT"; } - else if (address == 0xc380) { retval = "M80_MOVELOOP"; } - else if (address == 0xc38a) { retval = "M80_NXTA1"; } - else if (address == 0xc398) { retval = "M80_C01"; } - else if (address == 0xc3a3) { retval = "M80_C03"; } - else if (address == 0xc3ac) { retval = "M80_MOVERET"; } - else if (address == 0xc3b0) { retval = "M80_XFER"; } - else if (address == 0xc3c5) { retval = "M80_XFERC2M"; } - else if (address == 0xc3cd) { retval = "M80_XFERAZP"; } - else if (address == 0xc3dc) { retval = "M80_XFERSZP"; } - else if (address == 0xc3eb) { retval = "M80_SETCB"; } - else if (address == 0xc803) { retval = "M80_BASICINIT"; } - else if (address == 0xc813) { retval = "M80_HANG"; } - else if (address == 0xc816) { retval = "M80_BINIT1"; } - else if (address == 0xc831) { retval = "M80_BINIT1A"; } - else if (address == 0xc850) { retval = "M80_BINIT2"; } - else if (address == 0xc85d) { retval = "M80_CLEARIT"; } - else if (address == 0xc866) { retval = "M80_C8BASIC"; } - else if (address == 0xc874) { retval = "M80_C8B2"; } - else if (address == 0xc87e) { retval = "M80_C8B3"; } - else if (address == 0xc890) { retval = "M80_C8B4"; } - else if (address == 0xc896) { retval = "M80_BOUT"; } - else if (address == 0xc8a1) { retval = "M80_BPRINT"; } - else if (address == 0xc8b4) { retval = "M80_KBDWAIT"; } - else if (address == 0xc8c0) { retval = "M80_NOWAIT"; } - else if (address == 0xc8cc) { retval = "M80_BPNCTL"; } - else if (address == 0xc8e2) { retval = "M80_BIORET"; } - else if (address == 0xc8f6) { retval = "M80_BINPUT"; } - else if (address == 0xc905) { retval = "M80_B.INPUT"; } - else if (address == 0xc918) { retval = "M80_ESCAPING"; } - else if (address == 0xc929) { retval = "M80_ESC1"; } - else if (address == 0xc92b) { retval = "M80_ESC2"; } - else if (address == 0xc935) { retval = "M80_ESC3"; } - else if (address == 0xc945) { retval = "M80_ESCSPEC"; } - else if (address == 0xc954) { retval = "M80_ESCSPEC2"; } - else if (address == 0xc960) { retval = "M80_ESCNONE"; } - else if (address == 0xc963) { retval = "M80_ESCSPEC3"; } - else if (address == 0xc972) { retval = "M80_ESCTAB"; } - else if (address == 0xc983) { retval = "M80_ESCCHAR"; } - else if (address == 0xc994) { retval = "M80_PSTATUS"; } - else if (address == 0xc99e) { retval = "M80_PSTATUS2"; } - else if (address == 0xc9b0) { retval = "M80_PSTATUS3"; } - else if (address == 0xc9b4) { retval = "M80_PSTATUS4"; } - else if (address == 0xc9b7) { retval = "M80_NOESC"; } - else if (address == 0xc9c6) { retval = "M80_B.NOPICK"; } - else if (address == 0xc9df) { retval = "M80_B.CHKCAN"; } - else if (address == 0xc9f7) { retval = "M80_B.FLIP"; } - else if (address == 0xca02) { retval = "M80_B.CANLIT"; } - else if (address == 0xca0a) { retval = "M80_B.FIXCHR"; } - else if (address == 0xca24) { retval = "M80_B.INRET"; } - else if (address == 0xca27) { retval = "M80_GETPRIOR"; } - else if (address == 0xca49) { retval = "M80_GPX"; } - else if (address == 0xca4a) { retval = "M80_PREAD"; } - else if (address == 0xca4f) { retval = "M80_PREADRET2"; } - else if (address == 0xca51) { retval = "M80_PWRITE"; } - else if (address == 0xca62) { retval = "M80_PIGOOD"; } - else if (address == 0xca74) { retval = "M80_PREAD"; } - else if (address == 0xca8a) { retval = "M80_PREADRET2"; } - else if (address == 0xca8e) { retval = "M80_PWRITE"; } - else if (address == 0xca9e) { retval = "M80_PWRITE2"; } - else if (address == 0xcaaf) { retval = "M80_GETY"; } - else if (address == 0xcacb) { retval = "M80_PWRITE3"; } - else if (address == 0xcadc) { retval = "M80_STARTXY"; } - else if (address == 0xcaeb) { retval = "M80_PWRITE4"; } - else if (address == 0xcb09) { retval = "M80_PWWRAP"; } - else if (address == 0xcb0f) { retval = "M80_PWRITERET"; } - else if (address == 0xcb15) { retval = "M80_GETKEY"; } - else if (address == 0xcb1b) { retval = "M80_GETK2"; } - else if (address == 0xcb24) { retval = "M80_TESTCARD"; } - else if (address == 0xcb48) { retval = "M80_STAY2"; } - else if (address == 0xcb4d) { retval = "M80_STAY80"; } - else if (address == 0xcb4e) { retval = "M80_TESTFAIL"; } - else if (address == 0xcb51) { retval = "M80_BASCALC"; } - else if (address == 0xcb54) { retval = "M80_BASCALCZ"; } - else if (address == 0xcb55) { retval = "M80_BSCLC1"; } - else if (address == 0xcb5b) { retval = "M80_BSCLC1A"; } - else if (address == 0xcb6d) { retval = "M80_BSCLC2"; } - else if (address == 0xcb7e) { retval = "M80_BASCLC3"; } - else if (address == 0xcb97) { retval = "M80_BASCLCX"; } - else if (address == 0xcb99) { retval = "M80_CTLCHAR"; } - else if (address == 0xcbab) { retval = "M80_CTLCHARX"; } - else if (address == 0xcbae) { retval = "M80_CTLGO"; } - else if (address == 0xcbb2) { retval = "M80_CTLRET"; } - else if (address == 0xcbb6) { retval = "M80_CTLXFER"; } - else if (address == 0xcbbc) { retval = "M80_X.BELL"; } - else if (address == 0xcbce) { retval = "M80_BELL2"; } - else if (address == 0xcbcf) { retval = "M80_WAIT"; } - else if (address == 0xcbd0) { retval = "M80_WAIT2"; } - else if (address == 0xcbd1) { retval = "M80_WAIT3"; } - else if (address == 0xcbdb) { retval = "M80_X.BS"; } - else if (address == 0xcbe2) { retval = "M80_BS40"; } - else if (address == 0xcbeb) { retval = "M80_BSDONE"; } - else if (address == 0xcbec) { retval = "M80_X.CR"; } - else if (address == 0xcbfd) { retval = "M80_X.CRPAS"; } - else if (address == 0xcc0c) { retval = "M80_X.CRRET"; } - else if (address == 0xcc0d) { retval = "M80_X.EM"; } - else if (address == 0xcc1a) { retval = "M80_X.SUB"; } - else if (address == 0xcc1d) { retval = "M80_X.SUB80"; } - else if (address == 0xcc1f) { retval = "M80_X.SUBLP"; } - else if (address == 0xcc26) { retval = "M80_X.FS"; } - else if (address == 0xcc33) { retval = "M80_X.FSRET"; } - else if (address == 0xcc34) { retval = "M80_X.US"; } - else if (address == 0xcc40) { retval = "M80_X.US1"; } - else if (address == 0xcc45) { retval = "M80_X.US2"; } - else if (address == 0xcc48) { retval = "M80_X.USRET"; } - else if (address == 0xcc49) { retval = "M80_X.SO"; } - else if (address == 0xcc52) { retval = "M80_X.SI"; } - else if (address == 0xcc59) { retval = "M80_STUFFINV"; } - else if (address == 0xcc5f) { retval = "M80_CTLADL"; } - else if (address == 0xcc78) { retval = "M80_CTLADH"; } - else if (address == 0xcc91) { retval = "M80_X.LF"; } - else if (address == 0xcc9e) { retval = "M80_X.LF2"; } - else if (address == 0xcca4) { retval = "M80_SCROLLUP"; } - else if (address == 0xccaa) { retval = "M80_SCROLLDN"; } - else if (address == 0xccae) { retval = "M80_SCROLL1"; } - else if (address == 0xccb8) { retval = "M80_SCROLL2"; } - else if (address == 0xccd1) { retval = "M80_SCRLSUB"; } - else if (address == 0xccdd) { retval = "M80_MSCROL0"; } - else if (address == 0xcce1) { retval = "M80_MSCROL1"; } - else if (address == 0xccf9) { retval = "M80_MSCRL2"; } - else if (address == 0xcd02) { retval = "M80_MSCRLRET"; } - else if (address == 0xcd09) { retval = "M80_ONEMORE"; } - else if (address == 0xcd10) { retval = "M80_MSCRLRTS"; } - else if (address == 0xcd11) { retval = "M80_X.SCRLRET"; } - else if (address == 0xcd17) { retval = "M80_X.SCRLRET2"; } - else if (address == 0xcd20) { retval = "M80_X.LFRET"; } - else if (address == 0xcd23) { retval = "M80_X.VT"; } - else if (address == 0xcd2c) { retval = "M80_X.VTLOOP"; } - else if (address == 0xcd32) { retval = "M80_X.VTNEXT"; } - else if (address == 0xcd42) { retval = "M80_X.FF"; } - else if (address == 0xcd48) { retval = "M80_X.GS"; } - else if (address == 0xcd4e) { retval = "M80_X.GSEOLZ"; } - else if (address == 0xcd54) { retval = "M80_X.GS2"; } - else if (address == 0xcd59) { retval = "M80_X.DC1"; } - else if (address == 0xcd64) { retval = "M80_X.DC1B"; } - else if (address == 0xcd76) { retval = "M80_X.DC1RTS"; } - else if (address == 0xcd77) { retval = "M80_X.DC2"; } - else if (address == 0xcd88) { retval = "M80_X.DC2B"; } - else if (address == 0xcd90) { retval = "M80_X.NAK"; } - else if (address == 0xcd9a) { retval = "M80_X.NAKRET/M80_DC2RET"; } - else if (address == 0xcd9b) { retval = "M80_FULL80"; } - else if (address == 0xcdaa) { retval = "M80_QUIT"; } - else if (address == 0xcdc0) { retval = "M80_QUIT2"; } - else if (address == 0xcddb) { retval = "M80_SCRN84"; } - else if (address == 0xcdea) { retval = "M80_SCR40"; } - else if (address == 0xce01) { retval = "M80_SCR40RET"; } - else if (address == 0xce0a) { retval = "M80_ATEFOR"; } - else if (address == 0xce13) { retval = "M80_ATEFOR1"; } - else if (address == 0xce22) { retval = "M80_GET84"; } - else if (address == 0xce32) { retval = "M80_SCRN48"; } - else if (address == 0xce3e) { retval = "M80_SCR80"; } - else if (address == 0xce55) { retval = "M80_SCR80RET"; } - else if (address == 0xce58) { retval = "M80_SCRNRET"; } - else if (address == 0xce63) { retval = "M80_FORATE"; } - else if (address == 0xce6f) { retval = "M80_FORATE1"; } - else if (address == 0xce91) { retval = "M80_CLRHALF"; } - else if (address == 0xce9b) { retval = "M80_CLRHALF2"; } - else if (address == 0xcea3) { retval = "M80_DO48"; } - else if (address == 0xceaf) { retval = "M80_SETCH"; } - else if (address == 0xced9) { retval = "M80_SETCHRTS"; } - else if (address == 0xcedd) { retval = "M80_INVERT"; } - else if (address == 0xcef2) { retval = "M80_STORCHAR"; } - else if (address == 0xcef9) { retval = "M80_STOR2"; } - else if (address == 0xcf00) { retval = "M80_SEV"; } - else if (address == 0xcf01) { retval = "M80_PICK"; } - else if (address == 0xcf06) { retval = "M80_SCREENIT"; } - else if (address == 0xcf1e) { retval = "M80_SCRN2"; } - else if (address == 0xcf2a) { retval = "M80_STOR80"; } - else if (address == 0xcf37) { retval = "M80_SCRN3"; } - else if (address == 0xcf40) { retval = "M80_SCRN40"; } - else if (address == 0xcf4a) { retval = "M80_STOR40"; } - else if (address == 0xcf4e) { retval = "M80_STPKEXIT"; } - else if (address == 0xcf52) { retval = "M80_ESCON"; } - else if (address == 0xcf65) { retval = "M80_ESCOFF"; } - else if (address == 0xcf6e) { retval = "M80_ESCRET"; } - else if (address == 0xcf78) { retval = "M80_COPYROM"; } - else if (address == 0xcf95) { retval = "M80_COPYROM2"; } - else if (address == 0xcfb3) { retval = "M80_LCB2ROM"; } - else if (address == 0xcfb9) { retval = "M80_LCB1"; } - else if (address == 0xcfc2) { retval = "M80_LCB1ROM"; } - else if (address == 0xcfc5) { retval = "M80_COPYRET"; } - else if (address == 0xcfc8) { retval = "M80_PSETUP"; } - else if (address == 0xcfd2) { retval = "M80_PSETUP2"; } - else if (address == 0xcfdf) { retval = "M80_PSETUPRET"; } - else if (address == 0xcfea) { retval = "M80_F.TABLE"; } - else if (address == 0xcff0) { retval = "M80_PLUSMINUS1"; } - else if (address == 0xcff3) { retval = "M80_B.TABLE"; } - else if (address == 0xcff9) { retval = "M80_WNDTAB"; } - else if (address == 0xcffd) { retval = "M80_ZZEND"; } - - - else if (address == 0xcfff) { retval = "MON.CLRROM"; } - else if (address == 0xe000) { retval = "MON.BASIC"; } - else if (address == 0xe003) { retval = "MON.BASIC2"; } - - else if (address == 0xd365) { retval = "AS.GTFORPNT"; } - else if (address == 0xd39e) { retval = "AS.BLTU"; } - else if (address == 0xd39a) { retval = "AS.BLTU2"; } - else if (address == 0xd3d6) { retval = "AS.CHKMEM"; } - else if (address == 0xd3e3) { retval = "AS.REASON"; } - else if (address == 0xd410) { retval = "AS.MEMERR"; } - else if (address == 0xd412) { retval = "AS.ERROR"; } - else if (address == 0xd431) { retval = "AS.PRINT_ERROR_LINNUM"; } - else if (address == 0xd43c) { retval = "AS.RESTART"; } - else if (address == 0xd45c) { retval = "AS.NUMBERED_LINE"; } - else if (address == 0xd4b5) { retval = "AS.PUT_NEW_LINE"; } - else if (address == 0xd4f2) { retval = "AS.FIX_LINKS"; } - else if (address == 0xd52c) { retval = "AS.INLIN"; } - else if (address == 0xd52e) { retval = "AS.INLIN2"; } - else if (address == 0xd553) { retval = "AS.INCHR"; } - else if (address == 0xd559) { retval = "AS.PARSE_INPUT_LINE"; } - else if (address == 0xd56c) { retval = "AS.PARSE"; } - else if (address == 0xd61a) { retval = "AS.FNDLIN"; } - else if (address == 0xd61e) { retval = "AS.FL1"; } - else if (address == 0xd648) { retval = "AS.RTS1"; } - else if (address == 0xd649) { retval = "AS.NEW"; } - else if (address == 0xd64b) { retval = "AS.SCRTCH"; } - else if (address == 0xd665) { retval = "AS.SETPTRS"; } - else if (address == 0xd66a) { retval = "AS.CLEAR"; } - else if (address == 0xd66c) { retval = "AS.CLEARC"; } - else if (address == 0xd683) { retval = "AS.STKINI"; } - else if (address == 0xd696) { retval = "AS.RTS2"; } - else if (address == 0xd697) { retval = "AS.STXTPT"; } - else if (address == 0xd6a5) { retval = "AS.LIST"; } - else if (address == 0xd6da) { retval = "AS.LIST0"; } - else if (address == 0xd6fe) { retval = "AS.LIST1"; } - else if (address == 0xd702) { retval = "AS.LIST2"; } - else if (address == 0xd724) { retval = "AS.LIST3"; } - else if (address == 0xd72c) { retval = "AS.GETCHR"; } - else if (address == 0xd734) { retval = "AS.LIST4"; } - else if (address == 0xd766) { retval = "AS.FOR"; } - else if (address == 0xd7af) { retval = "AS.STEP"; } - else if (address == 0xd7d2) { retval = "AS.NEWSTT"; } - else if (address == 0xd805) { retval = "AS.TRACE_"; } - else if (address == 0xd826) { retval = "AS.GOEND"; } - else if (address == 0xd828) { retval = "AS.EXECUTE_STATEMENT"; } - else if (address == 0xd82a) { retval = "AS.EXECUTE_STATEMENT1"; } - else if (address == 0xd842) { retval = "AS.COLON_"; } - else if (address == 0xd846) { retval = "AS.SYNERR1"; } - else if (address == 0xd849) { retval = "AS.RESTORE"; } - else if (address == 0xd853) { retval = "AS.SETDA"; } - else if (address == 0xd857) { retval = "AS.RTS3"; } - else if (address == 0xd858) { retval = "AS.ISCNTC"; } - else if (address == 0xd863) { retval = "AS.CONTROL_C_TYPED"; } - else if (address == 0xd86e) { retval = "AS.STOP"; } - else if (address == 0xd870) { retval = "AS.END"; } - else if (address == 0xd871) { retval = "AS.END2"; } - else if (address == 0xd88a) { retval = "AS.END4"; } - else if (address == 0xd896) { retval = "AS.CONT"; } - else if (address == 0xd8af) { retval = "AS.RTS4"; } - else if (address == 0xd8b0) { retval = "AS.SAVE"; } - else if (address == 0xd8c9) { retval = "AS.LOAD"; } - else if (address == 0xd8F0) { retval = "AS.VARTIO"; } - else if (address == 0xd901) { retval = "AS.PROGIO"; } - else if (address == 0xd912) { retval = "AS.RUN"; } - else if (address == 0xd921) { retval = "AS.GOSUB"; } - else if (address == 0xd935) { retval = "AS.GO_TO_LINE"; } - else if (address == 0xd93e) { retval = "AS.GOTO"; } - else if (address == 0xd96a) { retval = "AS.RTS5"; } - else if (address == 0xd96b) { retval = "AS.POP"; } - else if (address == 0xd97c) { retval = "AS.UNDERR"; } - else if (address == 0xd981) { retval = "AS.SYNERR2"; } - else if (address == 0xd984) { retval = "AS.RETURN"; } - else if (address == 0xd995) { retval = "AS.DATA"; } - else if (address == 0xd998) { retval = "AS.ADDON"; } - else if (address == 0xd9a2) { retval = "AS.RTS6"; } - else if (address == 0xd9a3) { retval = "AS.DATAN"; } - else if (address == 0xd9a6) { retval = "AS.REMN"; } - else if (address == 0xd9c5) { retval = "AS.PULL3"; } - else if (address == 0xd9c9) { retval = "AS.IF"; } - else if (address == 0xd9dc) { retval = "AS.REM"; } - else if (address == 0xd9e1) { retval = "AS.IFTRUE"; } - else if (address == 0xd9ec) { retval = "AS.ONGOTO"; } - else if (address == 0xd9f4) { retval = "AS.ON1"; } - else if (address == 0xd9f8) { retval = "AS.ON2"; } - else if (address == 0xda0b) { retval = "AS.RTS7"; } - else if (address == 0xda0c) { retval = "AS.LINGET"; } - else if (address == 0xda46) { retval = "AS.LET"; } - else if (address == 0xda63) { retval = "AS.LET2"; } - else if (address == 0xda7a) { retval = "AS.LET_STRING"; } - else if (address == 0xda7b) { retval = "AS.PUTSTR"; } - else if (address == 0xdacf) { retval = "AS.PR_SPRING"; } - else if (address == 0xdad5) { retval = "AS.PRINT"; } - else if (address == 0xdad7) { retval = "AS.PRINT2"; } - else if (address == 0xdafb) { retval = "AS.CRDO"; } - else if (address == 0xdb00) { retval = "AS.NEGATE"; } - else if (address == 0xdb02) { retval = "AS.PR_RTS8"; } - else if (address == 0xdb03) { retval = "AS.PR_COMMA"; } - else if (address == 0xdb16) { retval = "AS.PR_TAB_OR_SPC"; } - else if (address == 0xdb2c) { retval = "AS.NXSPC"; } - else if (address == 0xdb2f) { retval = "AS.PR_NEXT_CHAR"; } - else if (address == 0xdb35) { retval = "AS.DOSPC"; } - else if (address == 0xdb3a) { retval = "AS.STROUT"; } - else if (address == 0xdb3d) { retval = "AS.STRPRT"; } - else if (address == 0xdb57) { retval = "AS.OUTSP"; } - else if (address == 0xdb5a) { retval = "AS.OUTQUES"; } - else if (address == 0xdb5c) { retval = "AS.OUTDO"; } - else if (address == 0xdb71) { retval = "AS.INPUTERR"; } - else if (address == 0xdb7b) { retval = "AS.READERR"; } - else if (address == 0xdb7f) { retval = "AS.ERLIN"; } - else if (address == 0xdb86) { retval = "AS.INPERR"; } - else if (address == 0xdb87) { retval = "AS.RESPERR"; } - else if (address == 0xdba0) { retval = "AS.GET"; } - else if (address == 0xdbb2) { retval = "AS.INPUT"; } - else if (address == 0xdbdc) { retval = "AS.NXIN"; } - else if (address == 0xdbe2) { retval = "AS.READ"; } - else if (address == 0xdbe9) { retval = "AS.INPUT_FLAG_ZERO"; } - else if (address == 0xdbeb) { retval = "AS.PROCESS_INPUT_LIST"; } - else if (address == 0xdbf1) { retval = "AS.PROCESS_INPUT_ITEM"; } - else if (address == 0xdC2b) { retval = "AS.INSTART"; } - else if (address == 0xdC69) { retval = "AS.INPUT_DATA"; } - else if (address == 0xdC72) { retval = "AS.INPUT_MORE"; } - else if (address == 0xdC99) { retval = "AS.INPFIN"; } - else if (address == 0xdCa0) { retval = "AS.FINDATA"; } - else if (address == 0xdCC6) { retval = "AS.INPDONE"; } - else if (address == 0xdcdf) { retval = "AS.ERR_EXTRA"; } - else if (address == 0xdcef) { retval = "AS.ERR_REENTRY"; } - else if (address == 0xdcf9) { retval = "AS.NEXT"; } - else if (address == 0xdcff) { retval = "AS.NEXT1"; } - else if (address == 0xdd02) { retval = "AS.NEXT2"; } - else if (address == 0xdd0d) { retval = "AS.GERR"; } - else if (address == 0xdd0f) { retval = "AS.NEXT3"; } - else if (address == 0xdd67) { retval = "AS.FRMNUM"; } - else if (address == 0xdd6a) { retval = "AS.CHKNUM"; } - else if (address == 0xdd6c) { retval = "AS.CHKSTR"; } - else if (address == 0xdd6d) { retval = "AS.CHKVAL"; } - else if (address == 0xdd78) { retval = "AS.JERROR"; } - else if (address == 0xdd7b) { retval = "AS.FRMEVL"; } - else if (address == 0xdd86) { retval = "AS.FRMEVL1"; } - else if (address == 0xdd95) { retval = "AS.FRMEVL2"; } - else if (address == 0xddcd) { retval = "AS.FRM_PRECEDENCE_TEST"; } - else if (address == 0xddd6) { retval = "AS.NXOP"; } - else if (address == 0xddd7) { retval = "AS.SAVOP"; } - else if (address == 0xdde4) { retval = "AS.FRM_RELATIONAL"; } - else if (address == 0xddf6) { retval = "AS.FRM_PREFNC"; } - else if (address == 0xddfd) { retval = "AS.FRM_RECURSE"; } - else if (address == 0xde0d) { retval = "AS.SNTXERR"; } - else if (address == 0xde10) { retval = "AS.FRM_STACK1"; } - else if (address == 0xde15) { retval = "AS.FRM_STACK2"; } - else if (address == 0xde20) { retval = "AS.FRM_STACK3"; } - else if (address == 0xde35) { retval = "AS.NOTMATH"; } - else if (address == 0xde38) { retval = "AS.GOEX"; } - else if (address == 0xde3a) { retval = "AS.FRM_PERFORM1"; } - else if (address == 0xde43) { retval = "AS.FRM_PERFORM2"; } - else if (address == 0xde5d) { retval = "AS.EXIT"; } - else if (address == 0xde60) { retval = "AS.FRM_ELEMENT"; } - else if (address == 0xde81) { retval = "AS.STRTXT"; } - else if (address == 0xde90) { retval = "AS.NOT_"; } - else if (address == 0xde98) { retval = "AS.EQUOP"; } - else if (address == 0xdea4) { retval = "AS.FN_"; } - else if (address == 0xdeab) { retval = "AS.SGN_"; } - else if (address == 0xdeb2) { retval = "AS.PARCHK"; } - else if (address == 0xdeb8) { retval = "AS.CHKCLS"; } - else if (address == 0xdebb) { retval = "AS.CHKOPN"; } - else if (address == 0xdebe) { retval = "AS.CHKCOM"; } - else if (address == 0xdec0) { retval = "AS.SYNCHR"; } - else if (address == 0xdec9) { retval = "AS.SYNERR"; } - else if (address == 0xdece) { retval = "AS.MIN"; } - else if (address == 0xded0) { retval = "AS.EQUL"; } - else if (address == 0xded5) { retval = "AS.FRM_VARIABLE"; } - else if (address == 0xded7) { retval = "AS.FRM_VARIABLE_CALL"; } - else if (address == 0xdef9) { retval = "AS.SCREEN"; } - else if (address == 0xdf0c) { retval = "AS.UNARY"; } - else if (address == 0xdf4f) { retval = "AS.OR"; } - else if (address == 0xdf55) { retval = "AS.AND"; } - else if (address == 0xdf5d) { retval = "AS.FALSE"; } - else if (address == 0xdf60) { retval = "AS.TRUE"; } - else if (address == 0xdf65) { retval = "AS.RELOPS"; } - else if (address == 0xdf7d) { retval = "AS.STRCMP"; } - else if (address == 0xdfaa) { retval = "AS.STRCMP1"; } - else if (address == 0xdfb0) { retval = "AS.NUMCMP"; } - else if (address == 0xdfb5) { retval = "AS.STRCMP2"; } - else if (address == 0xdfc1) { retval = "AS.CMPDONE"; } - else if (address == 0xdfcd) { retval = "AS.PDL"; } - else if (address == 0xdfd6) { retval = "AS.NXDIM"; } - else if (address == 0xdfd9) { retval = "AS.DIM"; } - else if (address == 0xdfe3) { retval = "AS.PTRGET"; } - else if (address == 0xdfe8) { retval = "AS.PTRGET2"; } - else if (address == 0xdfea) { retval = "AS.PTRGET3"; } - else if (address == 0xdff4) { retval = "AS.BADNAM"; } - else if (address == 0xdff7) { retval = "AS.NAMOK"; } - else if (address == 0xe007) { retval = "AS.PTRGET4"; } - else if (address == 0xe07d) { retval = "AS.ISLETC"; } - else if (address == 0xe087) { retval = "AS.NAME_NOT_FOUND"; } - else if (address == 0xe09c) { retval = "AS.MAKE_NEW_VARIABLE"; } - else if (address == 0xe0de) { retval = "AS.SET_VARPNT_AND_YA"; } - else if (address == 0xe0ed) { retval = "AS.GETARY"; } - else if (address == 0xe0ef) { retval = "AS.GETARY2"; } - else if (address == 0xe102) { retval = "AS.MAKINT"; } - else if (address == 0xe108) { retval = "AS.MKINT"; } - else if (address == 0xe10c) { retval = "AS.AYINT"; } - else if (address == 0xe119) { retval = "AS.MI1"; } - else if (address == 0xe11b) { retval = "AS.MI2"; } - else if (address == 0xe11e) { retval = "AS.ARRAY"; } - else if (address == 0xe196) { retval = "AS.SUBERR"; } - else if (address == 0xe199) { retval = "AS.IQERR"; } - else if (address == 0xe19b) { retval = "AS.JER"; } - else if (address == 0xe19e) { retval = "AS.USE_OLD_ARRAY"; } - else if (address == 0xe1b8) { retval = "AS.MAKE_NEW_ARRAY"; } - else if (address == 0xe24b) { retval = "AS.FIND_ARRAY_ELEMENT"; } - else if (address == 0xe253) { retval = "AS.FAE1"; } - else if (address == 0xe269) { retval = "AS.GSE"; } - else if (address == 0xe26c) { retval = "AS.GME"; } - else if (address == 0xe26f) { retval = "AS.FAE2"; } - else if (address == 0xe270) { retval = "AS.FAE3"; } - else if (address == 0xe2ac) { retval = "AS.RTS9"; } - else if (address == 0xe2ad) { retval = "AS.MULTIPLY_SUBSCRIPT"; } - else if (address == 0xe2b6) { retval = "AS.MULTIPLY_SUBS1"; } - else if (address == 0xe2de) { retval = "AS.FRE"; } - else if (address == 0xe2f2) { retval = "AS.GIVAYF"; } - else if (address == 0xe2ff) { retval = "AS.POS"; } - else if (address == 0xe301) { retval = "AS.SNGFLT"; } - else if (address == 0xe306) { retval = "AS.ERRDIR"; } - else if (address == 0xe30e) { retval = "AS.UNDFNC"; } - else if (address == 0xe313) { retval = "AS.DEF"; } - else if (address == 0xe341) { retval = "AS.FNC_"; } - else if (address == 0xe354) { retval = "AS.FUNCT"; } - else if (address == 0xe3af) { retval = "AS.FNCDATA"; } - else if (address == 0xe3c5) { retval = "AS.STR"; } - else if (address == 0xe3d5) { retval = "AS.STRINI"; } - else if (address == 0xe3dd) { retval = "AS.STRSPA"; } - else if (address == 0xe3e7) { retval = "AS.STRLIT"; } - else if (address == 0xe3ed) { retval = "AS.STRLT2"; } - else if (address == 0xe42a) { retval = "AS.PUTNEW"; } - else if (address == 0xe432) { retval = "AS.JERR"; } - else if (address == 0xe435) { retval = "AS.PUTEMP"; } - else if (address == 0xe452) { retval = "AS.GETSPA"; } - else if (address == 0xe484) { retval = "AS.GARBAG"; } - else if (address == 0xe488) { retval = "AS.FIND_HIGHEST_STRING"; } - else if (address == 0xe519) { retval = "AS.CHECK_SIMPLE_VARIABLE"; } - else if (address == 0xe523) { retval = "AS.CHECK_VARIABLE"; } - else if (address == 0xe552) { retval = "AS.CHECK_BUMP"; } - else if (address == 0xe55d) { retval = "AS.CHECK_EXIT"; } - else if (address == 0xe562) { retval = "AS.MOVE_HIGHEST_STRING_TO_TOP"; } - else if (address == 0xe597) { retval = "AS.CAT"; } - else if (address == 0xe5d4) { retval = "AS.MOVINS"; } - else if (address == 0xe5e2) { retval = "AS.MOVSTR"; } - else if (address == 0xe5e6) { retval = "AS.MOVSTR1"; } - else if (address == 0xe5fd) { retval = "AS.FRESTR"; } - else if (address == 0xe600) { retval = "AS.FREFAC"; } - else if (address == 0xe604) { retval = "AS.FRETMP"; } - else if (address == 0xe635) { retval = "AS.FRETMS"; } - else if (address == 0xe646) { retval = "AS.CHRSTR"; } - else if (address == 0xe65a) { retval = "AS.LEFTSTR"; } - else if (address == 0xe660) { retval = "AS.SUBSTRING1"; } - else if (address == 0xe667) { retval = "AS.SUBSTRING2"; } - else if (address == 0xe668) { retval = "AS.SUBSTRING3"; } - else if (address == 0xe686) { retval = "AS.RIGHTSTR"; } - else if (address == 0xe691) { retval = "AS.MIDSTR"; } - else if (address == 0xe6b9) { retval = "AS.SUBSTRING_SETUP"; } - else if (address == 0xe6d6) { retval = "AS.LEN"; } - else if (address == 0xe6dc) { retval = "AS.GETSTR"; } - else if (address == 0xe6e5) { retval = "AS.ASC"; } - else if (address == 0xe6f2) { retval = "AS.GOIQ"; } - else if (address == 0xe6f5) { retval = "AS.GTBYTC"; } - else if (address == 0xe6f8) { retval = "AS.GETBYT"; } - else if (address == 0xe6fb) { retval = "AS.CONINT"; } - else if (address == 0xe707) { retval = "AS.VAL"; } - else if (address == 0xe73d) { retval = "AS.POINT"; } - else if (address == 0xe746) { retval = "AS.GTNUM"; } - else if (address == 0xe74c) { retval = "AS.COMBYTE"; } - else if (address == 0xe752) { retval = "AS.GETADR"; } - else if (address == 0xe764) { retval = "AS.PEEK"; } - else if (address == 0xe77b) { retval = "AS.POKE"; } - else if (address == 0xe784) { retval = "AS.WAIT"; } - else if (address == 0xe79f) { retval = "AS.RTS10"; } - else if (address == 0xe7a0) { retval = "AS.FADDH"; } - else if (address == 0xe7a7) { retval = "AS.FSUB"; } - else if (address == 0xe7aa) { retval = "AS.FSUBT"; } - else if (address == 0xe7b9) { retval = "AS.FADD1"; } - else if (address == 0xe7be) { retval = "AS.FADD"; } - else if (address == 0xe7c1) { retval = "AS.FADDT"; } - else if (address == 0xe7ce) { retval = "AS.FADD2"; } - else if (address == 0xe7fa) { retval = "AS.FADD3"; } - else if (address == 0xe829) { retval = "AS.NORMALIZE_FAC1"; } - else if (address == 0xe82e) { retval = "AS.NORMALIZE_FAC2"; } - else if (address == 0xe84e) { retval = "AS.ZERO_FAC"; } - else if (address == 0xe850) { retval = "AS.STA_IN_FAC_SIGN_AND_EXP"; } - else if (address == 0xe852) { retval = "AS.STA_IN_FAC_SIGN"; } - else if (address == 0xe855) { retval = "AS.FADD4"; } - else if (address == 0xe874) { retval = "AS.NORMALIZE_FAC3"; } - else if (address == 0xe880) { retval = "AS.NORMALIZE_FAC4"; } - else if (address == 0xe88d) { retval = "AS.NORMALIZE_FAC5"; } - else if (address == 0xe88f) { retval = "AS.NORMALIZE_FAC6"; } - else if (address == 0xe89d) { retval = "AS.RTS11"; } - else if (address == 0xe89e) { retval = "AS.COMPLEMENT_FAC"; } - else if (address == 0xe8a4) { retval = "AS.COMPLEMENT_FAC_MANTISSA"; } - else if (address == 0xe8c6) { retval = "AS.INCREMENT_FAC_MANTISSA"; } - else if (address == 0xe8d4) { retval = "AS.RTS12"; } - else if (address == 0xe8d5) { retval = "AS.OVERFLOW"; } - else if (address == 0xe8da) { retval = "AS.SHIFT_RIGHT1"; } - else if (address == 0xe8dc) { retval = "AS.SHIFT_RIGHT2"; } - else if (address == 0xe8f0) { retval = "AS.SHIFT_RIGHT"; } - else if (address == 0xe8fd) { retval = "AS.SHIFT_RIGHT3"; } - else if (address == 0xe907) { retval = "AS.SHIFT_RIGHT4"; } - else if (address == 0xe911) { retval = "AS.SHIFT_RIGHT5"; } - else if (address == 0xe941) { retval = "AS.LOG"; } - else if (address == 0xe948) { retval = "AS.GIQ"; } - else if (address == 0xe94b) { retval = "AS.LOG2"; } - else if (address == 0xe97f) { retval = "AS.FMULT"; } - else if (address == 0xe982) { retval = "AS.FMULTT"; } - else if (address == 0xe9b0) { retval = "AS.MULTIPLY1"; } - else if (address == 0xe9b5) { retval = "AS.MULTIPLY2"; } - else if (address == 0xe9e2) { retval = "AS.RTS13"; } - else if (address == 0xe9e3) { retval = "AS.LOAD_ARG_FROM_YA"; } - else if (address == 0xea0e) { retval = "AS.ADD_EXPONENTS"; } - else if (address == 0xea10) { retval = "AS.ADD_EXPONENTS1"; } - else if (address == 0xea2b) { retval = "AS.OUTOFRNG"; } - else if (address == 0xea31) { retval = "AS.ZERO"; } - else if (address == 0xea36) { retval = "AS.JOV"; } - else if (address == 0xeae9) { retval = "AS.MUL10"; } - else if (address == 0xea55) { retval = "AS.DIV10"; } - else if (address == 0xea5e) { retval = "AS.DIV"; } - else if (address == 0xea66) { retval = "AS.FDIV"; } - else if (address == 0xeae6) { retval = "AS.COPY_RESULT_INTO_FAC"; } - else if (address == 0xeaf9) { retval = "AS.LOAD_FAC_FROM_YA"; } - else if (address == 0xeb1e) { retval = "AS.STORE_FAC_IN_TEMP2_ROUNDED"; } - else if (address == 0xeb21) { retval = "AS.STORE_FAC_IN_TEMP1_ROUNDED"; } - else if (address == 0xeb27) { retval = "AS.SETFOR"; } - else if (address == 0xeb2b) { retval = "AS.STORE_FAC_AT_YX_ROUNDED"; } - else if (address == 0xeb53) { retval = "AS.COPY_FAC_TO_ARG"; } - else if (address == 0xeb63) { retval = "AS.COPY_FAC_TO_ARG_ROUNDED"; } - else if (address == 0xeb71) { retval = "AS.RTS14"; } - else if (address == 0xeb72) { retval = "AS.ROUND_FAC"; } - else if (address == 0xeb7a) { retval = "AS.INCREMENT_MANTISSA"; } - else if (address == 0xeb82) { retval = "AS.SIGN"; } - else if (address == 0xeb86) { retval = "AS.SIGN1"; } - else if (address == 0xeb88) { retval = "AS.SIGN2"; } - else if (address == 0xeb8f) { retval = "AS.RTS15"; } - else if (address == 0xeb90) { retval = "AS.SGN"; } - else if (address == 0xeb9e) { retval = "AS.FLOAT"; } - else if (address == 0xeb9b) { retval = "AS.FLOAT1"; } - else if (address == 0xeba0) { retval = "AS.FLOAT2"; } - else if (address == 0xebaf) { retval = "AS.ABS"; } - else if (address == 0xebb2) { retval = "AS.FCOMP"; } - else if (address == 0xebb4) { retval = "AS.FCOMP2"; } - else if (address == 0xebf2) { retval = "AS.QINT"; } - else if (address == 0xec11) { retval = "AS.RTS16"; } - else if (address == 0xec12) { retval = "AS.QINT2"; } - else if (address == 0xec23) { retval = "AS.INT"; } - else if (address == 0xec40) { retval = "AS.QINT3"; } - else if (address == 0xec49) { retval = "AS.RTS17"; } - else if (address == 0xec4a) { retval = "AS.FIN"; } - else if (address == 0xec61) { retval = "AS.FIN1"; } - else if (address == 0xec64) { retval = "AS.FIN2"; } - else if (address == 0xec66) { retval = "AS.FIN3"; } - else if (address == 0xec87) { retval = "AS.FIN4"; } - else if (address == 0xec8a) { retval = "AS.FIN5"; } - else if (address == 0xec8c) { retval = "AS.FIN6"; } - else if (address == 0xec98) { retval = "AS.FIN10"; } - else if (address == 0xec9e) { retval = "AS.FIN7"; } - else if (address == 0xeca0) { retval = "AS.FIN8"; } - else if (address == 0xecc1) { retval = "AS.FIN9"; } - else if (address == 0xecd5) { retval = "AS.ADDACC"; } - else if (address == 0xece8) { retval = "AS.GETEXP"; } - else if (address == 0xed19) { retval = "AS.INPRT"; } - else if (address == 0xed24) { retval = "AS.LINPRT"; } - else if (address == 0xed2e) { retval = "AS.PRINT_FAC"; } - else if (address == 0xed31) { retval = "AS.GO_STROUT"; } - else if (address == 0xed34) { retval = "AS.FOUT"; } - else if (address == 0xed36) { retval = "AS.FOUT1"; } - else if (address == 0xed8c) { retval = "AS.FOUT2"; } - else if (address == 0xee17) { retval = "AS.FOUT3"; } - else if (address == 0xee57) { retval = "AS.FOUT4"; } - else if (address == 0xee5a) { retval = "AS.FOUT5"; } - else if (address == 0xee5f) { retval = "AS.FOUT6"; } - else if (address == 0xee8d) { retval = "AS.SQR"; } - else if (address == 0xee97) { retval = "AS.FPWRT"; } - else if (address == 0xeed0) { retval = "AS.NEGOP"; } - else if (address == 0xeeda) { retval = "AS.RTS18"; } - else if (address == 0xef09) { retval = "AS.EXP"; } - else if (address == 0xef5c) { retval = "AS.POLYNOMIAL_ODD"; } - else if (address == 0xef72) { retval = "AS.POLYNOMIAL"; } - else if (address == 0xef76) { retval = "AS.SERMAIN"; } - else if (address == 0xefa5) { retval = "AS.RTS19"; } - else if (address == 0xefae) { retval = "AS.RND"; } - else if (address == 0xefe7) { retval = "AS.GO_MOVMF"; } - else if (address == 0xefea) { retval = "AS.COS"; } - else if (address == 0xeff1) { retval = "AS.SIN"; } - else if (address == 0xf023) { retval = "AS.SIN1"; } - else if (address == 0xf026) { retval = "AS.SIN2"; } - else if (address == 0xf03a) { retval = "AS.TAN"; } - else if (address == 0xf062) { retval = "AS.TAN1"; } - else if (address == 0xf094) { retval = "AS.MS_EASTER_EGG_DATA"; } - else if (address == 0xf09e) { retval = "AS.ATN"; } - else if (address == 0xf0cd) { retval = "AS.RTS20"; } - else if (address == 0xf10b) { retval = "AS.GENERIC_CHRGET"; } - else if (address == 0xf128) { retval = "AS.COLD_START"; } - else if (address == 0xf1d5) { retval = "AS.CALL"; } - else if (address == 0xf1de) { retval = "AS.IN_NUMBER"; } - else if (address == 0xf1e5) { retval = "AS.PR_NUMBER"; } - else if (address == 0xf1ec) { retval = "AS.PLOTFNS"; } - else if (address == 0xf206) { retval = "AS.GOERR"; } - else if (address == 0xf209) { retval = "AS.LINCOOR"; } - else if (address == 0xf225) { retval = "AS.PLOT"; } - else if (address == 0xf232) { retval = "AS.HLIN"; } - else if (address == 0xf241) { retval = "AS.VLIN"; } - else if (address == 0xf24f) { retval = "AS.COLOR"; } - else if (address == 0xf256) { retval = "AS.VTAB"; } - else if (address == 0xf262) { retval = "AS.SPEED"; } - else if (address == 0xf26d) { retval = "AS.TRACE"; } - else if (address == 0xf26f) { retval = "AS.NOTRACE"; } - else if (address == 0xf273) { retval = "AS.NORMAL"; } - else if (address == 0xf277) { retval = "AS.INVERSE"; } - else if (address == 0xf280) { retval = "AS.FLASH"; } - else if (address == 0xf286) { retval = "AS.HIMEM"; } - else if (address == 0xf296) { retval = "AS.JMM"; } - else if (address == 0xf299) { retval = "AS.SETHI"; } - else if (address == 0xf2a6) { retval = "AS.LOMEM"; } - else if (address == 0xf2cb) { retval = "AS.ONERR"; } - else if (address == 0xf2e9) { retval = "AS.HANDLERR"; } - else if (address == 0xf318) { retval = "AS.RESUME"; } - else if (address == 0xf32e) { retval = "AS.JSYN"; } - else if (address == 0xf331) { retval = "AS.DEL"; } - else if (address == 0xf390) { retval = "AS.GR"; } - else if (address == 0xf399) { retval = "AS.TEXT"; } - else if (address == 0xf39f) { retval = "AS.STORE"; } - else if (address == 0xf3bc) { retval = "AS.RECALL"; } - else if (address == 0xf3d8) { retval = "AS.HGR2"; } - else if (address == 0xf3e2) { retval = "AS.HGR"; } - else if (address == 0xf3ea) { retval = "AS.SETHPG"; } - else if (address == 0xf3f2) { retval = "AS.HCLR"; } - else if (address == 0xf3f6) { retval = "AS.BKGND"; } - else if (address == 0xf411) { retval = "AS.HPOSN"; } - else if (address == 0xf457) { retval = "AS.HPLOT0"; } - else if (address == 0xf465) { retval = "AS.MOVE_LEFT_OR_RIGHT"; } - else if (address == 0xf47e) { retval = "AS.COLOR_SHIFT"; } - else if (address == 0xf48a) { retval = "AS.MOVE_RIGHT"; } - else if (address == 0xf49c) { retval = "AS.LRUDX1"; } - else if (address == 0xf49d) { retval = "AS.LRUDX2"; } - else if (address == 0xf4b3) { retval = "AS.LRUD1"; } - else if (address == 0xf4b4) { retval = "AS.LRUD2"; } - else if (address == 0xf4c4) { retval = "AS.LRUD3"; } - else if (address == 0xf4c8) { retval = "AS.LRUD4"; } - else if (address == 0xf4d3) { retval = "AS.MOVE_UP_OR_DOWN"; } - else if (address == 0xf505) { retval = "AS.MOVE_DOWN"; } - else if (address == 0xf530) { retval = "AS.HLINRL"; } - else if (address == 0xf53a) { retval = "AS.HGLN"; } - else if (address == 0xf57c) { retval = "AS.MOVEX"; } - else if (address == 0xf581) { retval = "AS.MOVEX2"; } - else if (address == 0xf5cb) { retval = "AS.HFIND"; } - else if (address == 0xf600) { retval = "AS.RTS22"; } - else if (address == 0xf601) { retval = "AS.DRAW0"; } - else if (address == 0xf605) { retval = "AS.DRAW1"; } - else if (address == 0xf65d) { retval = "AS.XDRAW0"; } - else if (address == 0xf661) { retval = "AS.XDRAW1"; } - else if (address == 0xf6b9) { retval = "AS.HFNS"; } - else if (address == 0xf6e6) { retval = "AS.GGERR"; } - else if (address == 0xf6e9) { retval = "AS.HCOLOR"; } - else if (address == 0xf6f5) { retval = "AS.RTS23"; } - else if (address == 0xf6fc) { retval = "AS.COLORTBL"; } - else if (address == 0xf6fe) { retval = "AS.HPLOT"; } - else if (address == 0xf721) { retval = "AS.ROT"; } - else if (address == 0xf727) { retval = "AS.SCALE"; } - else if (address == 0xf72d) { retval = "AS.DRAWPNT"; } - else if (address == 0xf769) { retval = "AS.DRAW"; } - else if (address == 0xf76f) { retval = "AS.XDRAW"; } - else if (address == 0xf775) { retval = "AS.SHLOAD"; } - else if (address == 0xf7bc) { retval = "AS.TAPEPNT"; } - else if (address == 0xf7d9) { retval = "AS.GETARYPT"; } - else if (address == 0xf7e7) { retval = "AS.HTAB"; } - - else if (address == 0xf800) { retval = "MON.PLOT"; } - else if (address == 0xf80c) { retval = "MON.RTMASK"; } - else if (address == 0xf80e) { retval = "MON.PLOT1"; } - else if (address == 0xf819) { retval = "MON.HLINE"; } - else if (address == 0xf828) { retval = "MON.VLINE"; } - else if (address == 0xf831) { retval = "MON.RTS1"; } - else if (address == 0xf832) { retval = "MON.CLRSCR"; } - else if (address == 0xf836) { retval = "MON.CLRTOP"; } - else if (address == 0xf838) { retval = "MON.CLRSC2"; } - else if (address == 0xf83c) { retval = "MON.CLRSC3"; } - else if (address == 0xf847) { retval = "MON.GBASCALC"; } - else if (address == 0xf856) { retval = "MON.GBCALC"; } - else if (address == 0xf85f) { retval = "MON.NXTCOL"; } - else if (address == 0xf864) { retval = "MON.SETCOL"; } - else if (address == 0xf871) { retval = "MON.SCRN"; } - else if (address == 0xf879) { retval = "MON.SCRN2"; } - else if (address == 0xf87f) { retval = "MON.RTMSKZ"; } - else if (address == 0xf882) { retval = "MON.INDS1"; } - else if (address == 0xf88c) { retval = "MON.INDS2"; } - else if (address == 0xf89b) { retval = "MON.IEVEN"; } - else if (address == 0xf8a5) { retval = "MON.ERR"; } - else if (address == 0xf8a9) { retval = "MON.GETFMT"; } - else if (address == 0xf8be) { retval = "MON.MNNDX1"; } - else if (address == 0xf8c2) { retval = "MON.MNNDX2"; } - else if (address == 0xf8c9) { retval = "MON.NBBDX3"; } - else if (address == 0xf8d0) { retval = "MON.UBSDSP"; } - else if (address == 0xf8d4) { retval = "MON.PRINTOP"; } - else if (address == 0xf8db) { retval = "MON.PRNTBL"; } - else if (address == 0xf8f5) { retval = "MON.PRMN1"; } - else if (address == 0xf8f9) { retval = "MON.PRMN2"; } - else if (address == 0xf910) { retval = "MON.PRADR1"; } - else if (address == 0xf914) { retval = "MON.PRADR2"; } - else if (address == 0xf926) { retval = "MON.PRADR3"; } - else if (address == 0xf92a) { retval = "MON.PRADR4"; } - else if (address == 0xf930) { retval = "MON.PRADR5"; } - else if (address == 0xf938) { retval = "MON.RELADR"; } - else if (address == 0xf940) { retval = "MON.PRNTYX"; } - else if (address == 0xf941) { retval = "MON.PRNTAX"; } - else if (address == 0xf944) { retval = "MON.PRNTX"; } - else if (address == 0xf948) { retval = "MON.PRBLNK"; } - else if (address == 0xf94a) { retval = "MON.PRBL2"; } - else if (address == 0xf94c) { retval = "MON.PRBL3"; } - else if (address == 0xf953) { retval = "MON.PCADJ"; } - else if (address == 0xf954) { retval = "MON.PCADJ2"; } - else if (address == 0xf956) { retval = "MON.PCADJ3"; } - else if (address == 0xf95c) { retval = "MON.PCADJ4"; } - else if (address == 0xf961) { retval = "MON.RTS2"; } - else if (address == 0xf962) { retval = "MON.FMT1"; } - else if (address == 0xf9a6) { retval = "MON.FMT2"; } - else if (address == 0xf9b4) { retval = "MON.CHAR1"; } - else if (address == 0xf9ba) { retval = "MON.CHAR2"; } - else if (address == 0xf9c0) { retval = "MON.MNEML"; } - else if (address == 0xfa00) { retval = "MON.MNEMR"; } - else if (address == 0xfa40) { retval = "MON.IRQ"; } - else if (address == 0xfa4c) { retval = "MON.BREAK"; } - else if (address == 0xfa59) { retval = "MON.OLDBRK"; } - else if (address == 0xfa62) { retval = "MON.RESET"; } - else if (address == 0xfa6f) { retval = "MON.INITAN"; } - else if (address == 0xfa81) { retval = "MON.NEWMON"; } - else if (address == 0xfa9b) { retval = "MON.FIXSEV"; } - else if (address == 0xfaa3) { retval = "MON.NOFIX"; } - else if (address == 0xfaa6) { retval = "MON.PWRUP"; } - else if (address == 0xfaa9) { retval = "MON.SETPG3"; } - else if (address == 0xfaab) { retval = "MON.SETPLP"; } - else if (address == 0xfaba) { retval = "MON.SLOOP"; } - else if (address == 0xfac7) { retval = "MON.NXTBYT"; } - else if (address == 0xfad7) { retval = "MON.REGDSP"; } - else if (address == 0xfada) { retval = "MON.RGDPS1"; } - else if (address == 0xfae4) { retval = "MON.RDSP1"; } - else if (address == 0xfafd) { retval = "MON.PWRCON"; } - else if (address == 0xfb02) { retval = "MON.DISKID"; } - else if (address == 0xfb09) { retval = "MON.TITLE"; } - else if (address == 0xfb11) { retval = "MON.XLTBL"; } - else if (address == 0xfb19) { retval = "MON.RTBL"; } - else if (address == 0xfb1e) { retval = "MON.PREAD"; } - else if (address == 0xfb25) { retval = "MON.PREAD2"; } - else if (address == 0xfb2e) { retval = "MON.RTS2D"; } - else if (address == 0xfb2f) { retval = "MON.INIT"; } - else if (address == 0xfb39) { retval = "MON.SETTXT"; } - else if (address == 0xfb40) { retval = "MON.SETGR"; } - else if (address == 0xfb4b) { retval = "MON.SETWND"; } - else if (address == 0xfb5b) { retval = "MON.TABV"; } - else if (address == 0xfb60) { retval = "MON.APPLEII"; } - else if (address == 0xfb65) { retval = "MON.STITLE"; } - else if (address == 0xfb6A) { retval = "MON.GETLN"; } - else if (address == 0xfb6f) { retval = "MON.SETPWRC"; } - else if (address == 0xfb78) { retval = "MON.VIDWAIT"; } - else if (address == 0xfb88) { retval = "MON.KBDWAIT"; } - - else if (address == 0xfbb3) { retval = "M80_F8VERSION"; } - - else if (address == 0xfb94) { retval = "MON.NOWAIT"; } - else if (address == 0xfb97) { retval = "MON.ESCOLD"; } - else if (address == 0xfb9b) { retval = "MON.ESCNOW"; } - else if (address == 0xfba5) { retval = "MON.ESCNEW"; } - else if (address == 0xfbb3) { retval = "MON.VERSION"; } - else if (address == 0xfbb4) { retval = "MON.GOTOCX"; } - else if (address == 0xfbc1) { retval = "MON.BASCALC"; } - - else if (address == 0xfbd0) { retval = "MON.BASCLC2"; } - else if (address == 0xfbd9) { retval = "MON.BELL1"; } - else if (address == 0xfbe4) { retval = "MON.BELL2"; } - else if (address == 0xfbef) { retval = "MON.RTS2B"; } - else if (address == 0xfbf0) { retval = "MON.STORADV"; } - else if (address == 0xfbf4) { retval = "MON.ADVANCE"; } - else if (address == 0xfbfc) { retval = "MON.RTS3"; } - else if (address == 0xfbfd) { retval = "MON.VIDOUT"; } - else if (address == 0xfc10) { retval = "MON.BS"; } - else if (address == 0xfc1a) { retval = "MON.UP"; } - else if (address == 0xfc22) { retval = "MON.VTAB"; } - else if (address == 0xfc24) { retval = "MON.VTABZ"; } - else if (address == 0xfc2b) { retval = "MON.RTS4"; } - else if (address == 0xfc2c) { retval = "MON.ESC1"; } - else if (address == 0xfc42) { retval = "MON.CLREOP"; } - else if (address == 0xfc58) { retval = "MON.HOME"; } - else if (address == 0xfc62) { retval = "MON.CR"; } - else if (address == 0xfc66) { retval = "MON.LF"; } - else if (address == 0xfc70) { retval = "MON.SCROLL"; } - else if (address == 0xfc72) { retval = "MON.XGOTOCX"; } - - else if (address == 0xfc75) { retval = "M80_SNIFFIRQ"; } - - else if (address == 0xfc84) { retval = "MON.RDCX"; } - else if (address == 0xfc91) { retval = "MON.ISSLOTS"; } - else if (address == 0xfc99) { retval = "MON.ISPAGE1"; } - else if (address == 0xfc9c) { retval = "MON.CLREOL"; } - else if (address == 0xfc9e) { retval = "MON.CLREOLZ"; } - else if (address == 0xfca8) { retval = "MON.WAIT"; } - else if (address == 0xfca9) { retval = "MON.WAIT2"; } - else if (address == 0xfcaa) { retval = "MON.WAIT3"; } - else if (address == 0xfcb4) { retval = "MON.NXTA4"; } - else if (address == 0xfcba) { retval = "MON.NXTA1"; } - else if (address == 0xfcc8) { retval = "MON.RTS4B"; } - else if (address == 0xfcc9) { retval = "MON.HEADR"; } - else if (address == 0xfcd6) { retval = "MON.WRBIT"; } - else if (address == 0xfcdb) { retval = "MON.ZERDLY"; } - else if (address == 0xfce2) { retval = "MON.ONEDLY"; } - else if (address == 0xfce5) { retval = "MON.WRTAPE"; } - else if (address == 0xfcec) { retval = "MON.RDBYTE"; } - else if (address == 0xfcee) { retval = "MON.RDBYT2"; } - else if (address == 0xfcfa) { retval = "MON.READ2BIT"; } - else if (address == 0xfcfd) { retval = "MON.RDBIT"; } - else if (address == 0xfd0c) { retval = "MON.RDKEY"; } - - else if (address == 0xfd18) { retval = "MON.KEYIN"; } - else if (address == 0xfd21) { retval = "MON.RDESC"; } - - else if (address == 0xfd29) { retval = "M80_FUNCEXIT"; } - - else if (address == 0xfd2f) { retval = "MON.ESC"; } - else if (address == 0xfd35) { retval = "MON.RDCHAR"; } - else if (address == 0xfd3d) { retval = "MON.NOTCR"; } - else if (address == 0xfd5f) { retval = "MON.NOTCR1"; } - else if (address == 0xfd62) { retval = "MON.CANCEL"; } - else if (address == 0xfd67) { retval = "MON.GETLNZ"; } - else if (address == 0xfd6a) { retval = "MON.GETLN"; } - else if (address == 0xfd71) { retval = "MON.BCKSPC"; } - else if (address == 0xfd75) { retval = "MON.NXTCHAR"; } - else if (address == 0xfd7e) { retval = "MON.CAPTST"; } - else if (address == 0xfd84) { retval = "MON.ADDINP"; } - else if (address == 0xfd8e) { retval = "MON.CROUT"; } - else if (address == 0xfd92) { retval = "MON.PRA1"; } - else if (address == 0xfd96) { retval = "MON.PRYX2"; } - else if (address == 0xfda3) { retval = "MON.XAMB"; } - else if (address == 0xfdad) { retval = "MON.MOD8CHK"; } - else if (address == 0xfdb3) { retval = "MON.XAM"; } - else if (address == 0xfdb6) { retval = "MON.DATAOUT"; } - else if (address == 0xfdc5) { retval = "MON.RTS4C"; } - else if (address == 0xfdc6) { retval = "MON.XAMPM"; } - else if (address == 0xfdd1) { retval = "MON.ADD"; } - else if (address == 0xfdda) { retval = "MON.PRBYTE"; } - else if (address == 0xfde3) { retval = "MON.PRHEX"; } - else if (address == 0xfde5) { retval = "MON.PRHEXZ"; } - else if (address == 0xfded) { retval = "MON.COUT"; } - else if (address == 0xfdf0) { retval = "MON.COUT1"; } - else if (address == 0xfdf6) { retval = "MON.COUTZ"; } - else if (address == 0xfe00) { retval = "MON.BLI"; } - else if (address == 0xfe04) { retval = "MON.BLANK"; } - else if (address == 0xfe0b) { retval = "MON.STOR"; } - else if (address == 0xfe17) { retval = "MON.RTS5"; } - else if (address == 0xfe18) { retval = "MON.SETMODE"; } - else if (address == 0xfe1d) { retval = "MON.SETMDZ"; } - else if (address == 0xfe20) { retval = "MON.LT"; } - else if (address == 0xfe22) { retval = "MON.LT2"; } - else if (address == 0xfe2c) { retval = "MON.MOVE"; } - else if (address == 0xfe36) { retval = "MON.VFY"; } - else if (address == 0xfe58) { retval = "MON.VFYOK"; } - else if (address == 0xfe5e) { retval = "MON.LIST"; } - else if (address == 0xfe63) { retval = "MON.LIST2"; } - else if (address == 0xfe75) { retval = "MON.A1PC"; } - else if (address == 0xfe78) { retval = "MON.A1PCLP"; } - else if (address == 0xfe7f) { retval = "MON.A1PCRTS"; } - else if (address == 0xfe80) { retval = "MON.SETINV"; } - else if (address == 0xfe84) { retval = "MON.SETNORM"; } - else if (address == 0xfe86) { retval = "MON.SETIFLG"; } - else if (address == 0xfe89) { retval = "MON.SETKBD"; } - else if (address == 0xfe8b) { retval = "MON.INPORT"; } - else if (address == 0xfe8d) { retval = "MON.INPRT"; } - else if (address == 0xfe93) { retval = "MON.SETVID"; } - else if (address == 0xfe95) { retval = "MON.OUTPORT"; } - else if (address == 0xfe97) { retval = "MON.OUTPRT"; } - else if (address == 0xfe9b) { retval = "MON.IOPRT"; } - else if (address == 0xfea7) { retval = "MON.IOPRT1"; } - else if (address == 0xfea9) { retval = "MON.IOPRT2"; } - else if (address == 0xfeaf) { retval = "MON.CKSUMFIX"; } - else if (address == 0xfeb0) { retval = "MON.XBASIC"; } - else if (address == 0xfeb3) { retval = "MON.BASCONT"; } - else if (address == 0xfeb6) { retval = "MON.GO"; } - else if (address == 0xfebf) { retval = "MON.REGZ"; } - else if (address == 0xfec2) { retval = "MON.TRACE"; } - else if (address == 0xfec4) { retval = "MON.STEPZ"; } - else if (address == 0xfeca) { retval = "MON.USR"; } - else if (address == 0xfecd) { retval = "MON.WRITE"; } - else if (address == 0xfed4) { retval = "MON.WR1"; } - else if (address == 0xfeed) { retval = "MON.WRBYTE"; } - else if (address == 0xfeef) { retval = "MON.WRBYT2"; } - else if (address == 0xfef6) { retval = "MON.CRMON"; } - else if (address == 0xfefd) { retval = "MON.READ"; } - else if (address == 0xff02) { retval = "MON.READ2"; } - else if (address == 0xff0a) { retval = "MON.RD2"; } - else if (address == 0xff16) { retval = "MON.RD3"; } - else if (address == 0xff2d) { retval = "MON.PRERR"; } - else if (address == 0xff3a) { retval = "MON.BELL"; } - else if (address == 0xff3f) { retval = "MON.RESTORE"; } - else if (address == 0xff44) { retval = "MON.RESTR1"; } - else if (address == 0xff4a) { retval = "MON.SAVE"; } - else if (address == 0xff4c) { retval = "MON.SAV1"; } - - else if (address == 0xff58) { retval = "M80_IORTS"; } - - else if (address == 0xff59) { retval = "MON.OLDRST"; } - else if (address == 0xff65) { retval = "MON.MON"; } - else if (address == 0xff69) { retval = "MON.MONZ"; } - else if (address == 0xff73) { retval = "MON.NXTITM"; } - else if (address == 0xff7a) { retval = "MON.CRSRCH"; } - else if (address == 0xff8a) { retval = "MON.DIG"; } - else if (address == 0xff90) { retval = "MON.NXTBIT"; } - else if (address == 0xff98) { retval = "MON.NXTBAS"; } - else if (address == 0xffa2) { retval = "MON.NXTBS2"; } - else if (address == 0xffa7) { retval = "MON.GETNUM"; } - else if (address == 0xffad) { retval = "MON.NXTCHR"; } - else if (address == 0xffbe) { retval = "MON.TOSUB"; } - else if (address == 0xffc7) { retval = "MON.ZMODE"; } - else if (address == 0xffcc) { retval = "MON.CHRTBL"; } - else if (address == 0xffe3) { retval = "MON.SUBTBL"; } - - return retval; -} - -bool DisassemblerViewer::optionsMenuItems(QMenu *menu) -{ - QSettings settings; - - if (!m_wordWrapAction) { - m_wordWrapAction = new QAction("&Word Wrap"); - m_wordWrapAction->setCheckable(true); - m_wordWrapAction->setChecked(settings.value("DisassemblerViewer.WordWrap",true).toBool()); - connect(m_wordWrapAction, &QAction::toggled, - this, &DisassemblerViewer::toggleWordWrap); - } - menu->addAction(m_wordWrapAction); - - menu->addSeparator(); - - if (!m_showMetadataAction) { - m_showMetadataAction = new QAction("&Dissassembler Metadata"); - connect(m_showMetadataAction, &QAction::triggered, - this, &DisassemblerViewer::showMetadataDialog); - } - menu->addAction(m_showMetadataAction); - - return true; -} - -void DisassemblerViewer::showMetadataDialog() -{ - if (!m_dmd) { - m_dmd = new DisassemblerMetadataDialog(m_bfm, this); - } - m_dmd->show(); - m_dmd->raise(); -} - -void DisassemblerViewer::setData(QByteArray data) -{ - ui->textArea->setText(data); - ui->textArea->setJumpLines(&m_jumpLines); -} - - -bool DisassemblerViewer::canPrint() const { return true; } - -void DisassemblerViewer::doPrint() -{ - QPrinter printer; - - QPrintDialog dialog(&printer, this); - dialog.setWindowTitle(tr("Print Dissassembly")); - if (ui->textArea->textCursor().hasSelection()) - dialog.addEnabledOption(QAbstractPrintDialog::PrintSelection); - if (dialog.exec() != QDialog::Accepted) { - // qDebug() << "Cancelled"; - - return; - } - - ui->textArea->print(&printer); -} - -bool DisassemblerViewer::canExport() const { return true; } - -void DisassemblerViewer::doExport() -{ - QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); - QDir savename = QDir(defaultPath).filePath(m_file->filename()+".txt"); - - QString saveName = QFileDialog::getSaveFileName(this, - tr("Export Disassembly"), savename.path(), tr("Text Files (*.txt)")); - - if (saveName == "") return; // User cancelled - - // qDebug() << "Set filename: " << saveName; - - QFile saveFile(saveName); - if (!saveFile.open(QIODevice::WriteOnly | QIODevice::Text)) - { - QMessageBox::warning(this,"Save Error","Could not save "+saveName); - return; - } - - QTextStream out(&saveFile); - out << ui->textArea->document()->toPlainText(); - saveFile.close(); -} - -QString DisassemblerViewer::makeDescriptorStringForVal(quint8 val) -{ - QString retval; - - // QString zone; - // if (val <= 0x3f) zone = "Inverse"; - // else if (val <= 0x7f) zone = "Flash"; - // else if (val <= 0x9f) zone = "(Alt) Normal"; - // else zone = "Normal"; - - // quint8 baseascii = val; - // if (val <= 0x1f) baseascii += 0x40; - // else if (val <= 0x5f) baseascii += 0; - // else if (val <= 0xbf) baseascii -= 0x40; - // else baseascii -= 80; - - // QString ch = QChar(baseascii); - // if (val == 0xff) ch = "[DEL]"; - - // QString appleAscii = QString("%1 %2").arg(ch).arg(zone); - - // if (val < 0x20) - // { - // QString ctrl = QString(" / (^%1)").arg(QChar(val+0x40)); - // appleAscii.append(ctrl); - // } - - // retval = QString("; %1 / %2").arg(val).arg(appleAscii); - retval = QString("; %1").arg(val); - return retval; -} +#include "disassemblerviewer.h" +#include "ui_disassemblerviewer.h" +#include "disassembler.h" +#include "memory.h" +#include "util.h" +#include "relocatablefile.h" + +#include +#include +#include +#include +#include + + +DisassemblerViewer::DisassemblerViewer(QWidget *parent) : + FileViewerInterface(parent), + ui(new Ui::DisassemblerViewer) +{ + ui->setupUi(this); + QFont textAreaFont; + textAreaFont.setStyleHint(QFont::Monospace); + + + m_isRelo = false; + m_dmd = Q_NULLPTR; + m_wordWrapAction = Q_NULLPTR; + m_showMetadataAction = Q_NULLPTR; + m_setFontAction = Q_NULLPTR; + + + QString title = QString("Disassembly Viewer"); + setWindowTitle(title); + + QSettings settings; + toggleWordWrap(settings.value("DisassemblerViewer.WordWrap",true).toBool()); + + setTextFont(fontFromSettings("DisassemblerViewer.textFont", textAreaFont)); +} + +DisassemblerViewer::~DisassemblerViewer() +{ + delete ui; +} + +void DisassemblerViewer::setTextFont(const QFont &font) +{ + ui->textArea->setFont(font); +} +void DisassemblerViewer::setFile(GenericFile *file) +{ + + if (dynamic_cast(file)) + { + setFile(dynamic_cast(file)); + } + if (dynamic_cast(file)) + { + setFile(dynamic_cast(file)); + } +} + +void DisassemblerViewer::toggleWordWrap(bool enabled) +{ + if (enabled) + { + ui->textArea->setWordWrapMode(QTextOption::WordWrap); + } + else + { + ui->textArea->setWordWrapMode(QTextOption::NoWrap); + } + QSettings settings; + settings.setValue("DisassemblerViewer.WordWrap",enabled); +} + +void DisassemblerViewer::setFile(BinaryFile *file) { + m_file = file; + m_isRelo = false; + + m_bfm = new BinaryFileMetadata(m_file, file->address(), this); + + connect(m_bfm, &BinaryFileMetadata::doDisassemble, + this, &DisassemblerViewer::handleDisassembleRequest); + + QString title = QString("Disassembler Viewer: %1").arg(m_file->filename()); + setWindowTitle(title); + + quint16 address = file->address(); + + m_mem.addFile(m_file->data(), address); + + QList addresses = m_bfm->entryPoints()->getEntryPointAddresses(); + if (!addresses.count()) { addresses.append(address); } + handleDisassembleRequest(addresses); +} + +void DisassemblerViewer::setFile(RelocatableFile *file) { + m_file = file; + m_isRelo = true; + + m_bfm = new BinaryFileMetadata(m_file, file->address() + 6, this); + + connect(m_bfm, &BinaryFileMetadata::doDisassemble, + this, &DisassemblerViewer::handleDisassembleRequest); + + QString title = QString("Disassembler Viewer: %1 (Relocatable)").arg(m_file->filename()); + setWindowTitle(title); + + quint16 address = file->address() + 6 ; // Handle offset for relocatable metadata + + m_mem.addFile(m_file->data(), address); + + QList addresses = m_bfm->entryPoints()->getEntryPointAddresses(); + if (!addresses.count()) { addresses.append(address); } + handleDisassembleRequest(addresses); +} + +void DisassemblerViewer::handleDisassembleRequest(QList addresses) +{ + QStringList strings; + + disassemble(addresses); + strings += getDisassemblyStrings(); + // qSort(strings); + strings.sort(); + strings.removeDuplicates(); + + if (m_isRelo) + { + QByteArray joinedlines = qPrintable(strings.join("\n")); + QStringList rd = (dynamic_cast(m_file))->decodeRelocatableDict(); + QByteArray rdlines = qPrintable(rd.join("\n")); + ui->textArea->clear(); + setData(joinedlines + "\n\n== Relocation Dictionary ==\n\n" + rdlines); + } + else + { + QByteArray joinedlines = qPrintable(strings.join("\n")); + ui->textArea->clear(); + setData(joinedlines); + } +} + + +QStringList DisassemblerViewer::getDisassemblyStrings() { + return m_disassemblyStrings; +} + +void DisassemblerViewer::disassemble(QList entryPoints) { + + Disassembler dis(m_mem.values()); + + int length = m_file->length(); + int end = m_file->address()+length; + if (end > 0xffff) { end = 0xffff; } + + QList lines = dis.disassemble(m_file->address(), + end, + entryPoints); + dis.setUnknownToData(m_file->address(),m_file->address()+length); + m_jumpLines = dis.getJumpLines(); + + QStringList formattedLines; + + foreach (DisassembledItem di, lines) { + QString ds = di.rawDisassembledString(); + if (di.hasArg()) { + QString potentialLabel = getPotentialLabel(di.arg16()); + if (!potentialLabel.isEmpty()) { + if (ds.contains("_ARG16_")) { ds.replace("_ARG16_",potentialLabel); } + if (ds.contains("_ARG8_")) { ds.replace("_ARG8_",potentialLabel); } + } else { + ds = di.disassembledString(); + } + } + QString raw = di.rawDisassembledString(); + if (raw.contains("RTS")) { ds += "\n"; } //TODO: Temp for spacing + if (raw.contains("JMP")) { ds += "\n"; } //TODO: Temp for spacing + if (raw.contains("???")) { ds += "\n"; } //TODO: Temp for spacing + if (raw.contains("BRA")) { ds += "\n"; } //TODO: Temp for spacing + if (raw.contains("BRK")) { ds += "\n"; } //TODO: Temp for spacing + + + + QString newline = QString("%1: %2 %3").arg(di.hexAddress()).arg(di.hexString()).arg(ds); + formattedLines.append(newline); + } + + for (int idx = m_file->address(); idx < m_file->address()+length; idx++) + { + if (dis.memoryUsageMap()->at(idx).testFlag(Data) || + dis.memoryUsageMap()->at(idx).testFlag(Unknown)) + { + QString newline; + bool usedefault = false; + + if (m_bfm->assemblerSymbols()->hasAssemSymbolAtAddress(idx)) + { + int loc = m_bfm->assemblerSymbols()->locationOfSymbolAtAddress(idx); + if (m_bfm->assemblerSymbols()->at(loc).symbolsize == SizeByte) + { + newline = QString("%1: .Byte $%2 ; %3").arg(uint16ToHex(idx)) + .arg(uint8ToHex(m_mem.at(idx))) + .arg(m_bfm->assemblerSymbols()->at(loc).name);; + } + if (m_bfm->assemblerSymbols()->at(loc).symbolsize == SizeWord) + { + newline = QString("%1: .Word $%2 ; %3").arg(uint16ToHex(idx)) + .arg(uint16ToHex(m_mem.at(idx) + (m_mem.at(idx+1)*256))) + .arg(m_bfm->assemblerSymbols()->at(loc).name); + idx++; + } + else + { + usedefault = true; + } + } + else + { + usedefault = true; + } + + if (usedefault) + { + newline = QString("%1: %2 %3\t(%4)\t'%5'").arg(uint16ToHex(idx)) + .arg(uint8ToHex(m_mem.at(idx))) + .arg(makeDescriptorStringForVal(m_mem.at(idx))) + .arg(dis.getMnemonicForOp(m_mem.at(idx))) + .arg(AppleChar::printable(m_mem.at(idx))); + } + formattedLines.append(newline); + } + } + qSort(formattedLines); + + m_disassemblyStrings = formattedLines; +} + + + +QString DisassemblerViewer::getPotentialLabel(quint16 address) +{ + if (address == 0x24) { return "MON.CURSORHORIZ"; } + if (address == 0x28) { return "MON.BASL"; } + if (address == 0x29) { return "MON.BASH"; } + if (address == 0x33) { return "MON.PROMPTCHAR"; } + if (address == 0x36) { return "DOS.CSWL"; } + if (address == 0x37) { return "DOS.CSWH"; } + if (address == 0x38) { return "DOS.KSWL"; } + if (address == 0x39) { return "DOS.KSWH"; } + if (address == 0x40) { return "DOS.FILE_BUFFER_L"; } + if (address == 0x41) { return "DOS.FILE_BUFFER_H"; } + if (address == 0x42) { return "DOS.BUFFER_ADDR_L"; } + if (address == 0x43) { return "DOS.BUFFER_ADDR_H"; } + if (address == 0x44) { return "DOS.NUMERIC_OPERAND_L"; } + if (address == 0x45) { return "DOS.NUMERIC_OPERAND_H"; } + + if (address == 0x67) { return "AS.PROG_STARTL"; } + if (address == 0x68) { return "AS.PROG_STARTH"; } + + if (address == 0x69) { return "AS.VAR_STARTL"; } + if (address == 0x6A) { return "AS.VAR_STARTH"; } + + if (address == 0x6B) { return "AS.ARRAY_STARTL"; } + if (address == 0x6C) { return "AS.ARRAY_STARTH"; } + + if (address == 0x6D) { return "AS.NUMSTORE_ENDL"; } + if (address == 0x6E) { return "AS.NUMSTORE_ENDH"; } + + if (address == 0x6F) { return "AS.STRING_STARTL"; } + if (address == 0x70) { return "AS.STRING_STARTH"; } + + if (address == 0x71) { return "AS.PTR_9L"; } + if (address == 0x72) { return "AS.PTR_9H"; } + + if (address == 0x73) { return "AS.HIMEM_L"; } + if (address == 0x74) { return "AS.HIMEM_H"; } + + if (address == 0x75) { return "AS.CURR_LINENUM_L"; } + if (address == 0x76) { return "AS.CURR_LINENUM_H"; } + + if (address == 0x77) { return "AS.INTR_LINENUM_L"; } + if (address == 0x78) { return "AS.INTR_LINENUM_H"; } + + if (address == 0x79) { return "AS.NEXT_STATEMENT_L"; } + if (address == 0x7A) { return "AS.NEXT_STATEMENT_H"; } + + if (address == 0x7B) { return "AS.DATA_LINENUM_L"; } + if (address == 0x7C) { return "AS.DATA_LINENUM_H"; } + + if (address == 0x7D) { return "AS.DATA_ADDR_L"; } + if (address == 0x7E) { return "AS.DATA_ADDR_H"; } + + if (address == 0x7F) { return "AS.INPUT_SRC_L"; } + if (address == 0x80) { return "AS.INPUT_SRC_H"; } + + if (address == 0x81) { return "AS.LAST_VARNAME_L"; } + if (address == 0x82) { return "AS.LAST_VARNAME_H"; } + + if (address == 0x83) { return "AS.LAST_VARVAL_L"; } + if (address == 0x84) { return "AS.LAST_VARVAL_H"; } + + if (address == 0xAF) { return "AS.PROGEND_L"; } + if (address == 0xB0) { return "AS.PROGEND_H"; } + + if (address == 0xD6) { return "DOS.AS.LOCK"; } + + if (address == 0xE0) { return "AS.HGR_X_L"; } + if (address == 0xE1) { return "AS.HGR_X_H"; } + if (address == 0xE2) { return "AS.HGR_Y"; } + + if (address == 0xE4) { return "AS.HGR_COLOR"; } + + if (address == 0xE8) { return "AS.SHAPETBL_L"; } + if (address == 0xE9) { return "AS.SHAPETBL_H"; } + + if (address == 0xEA) { return "AS.HGR_COLLISION_CTR"; } + + if (address == 0x03d0) { return "DOS.WARMSTART"; } + if (address == 0x03d3) { return "DOS.COLDSTART"; } + if (address == 0x03d6) { return "DOS.FILE_MANAGER"; } + if (address == 0x03d9) { return "DOS.RWTS"; } + if (address == 0x03dc) { return "DOS.FM_PARAM_LIST_LOCATE"; } + if (address == 0x03e3) { return "DOS.RWTS_PARAM_LIST_LOCATE"; } + if (address == 0x03ea) { return "DOS.REPLACE_DOS_INTERCEPTS"; } + if (address == 0x03ef) { return "DOS.AUTOSTART_BRK_HANDLER"; } + if (address == 0x03f2) { return "DOS.AUTOSTART_RESET_HANDLER"; } + if (address == 0x03f4) { return "DOS.POWERUP_BYTE"; } + if (address == 0x03f5) { return "AMPR_VEC"; } + if (address == 0x03f8) { return "MON.CTRL_Y_VEC"; } + if (address == 0x03fb) { return "DOS.NMI_HANDLER"; } + if (address == 0x03fe) { return "DOS.IRQ_HANDLER"; } + + if (address == 0x0400) { return "MON.LINE1"; } + + if (address == 0x07f8) { return "MON.MSLOT"; } + if (address == 0xc000) { return "KEYBOARD"; } + + if (address == 0xc001) { return "M80_SET80COL"; } + if (address == 0xc002) { return "M80_RDMAINRAM"; } + if (address == 0xc003) { return "M80_RDCARDRAM"; } + if (address == 0xc004) { return "M80_WRMAINRAM"; } + if (address == 0xc005) { return "M80_WRCARDRAM"; } + + if (address == 0xc006) { return "MON.SETSLOTCXROM"; } + if (address == 0xc007) { return "MON.SETINTCXROM"; } + + if (address == 0xc008) { return "M80_SETSTDSZ"; } + if (address == 0xc009) { return "M80_SETALTZP"; } + if (address == 0xc00A) { return "M80_SETINTC3ROM"; } + if (address == 0xc00B) { return "M80_SETSLOTC3ROM"; } + if (address == 0xc00C) { return "M80_CLR80VID"; } + if (address == 0xc00D) { return "M80_SET80VID"; } + if (address == 0xc00E) { return "M80_CLRALTCHAR"; } + if (address == 0xc00F) { return "M80_SETALTCHAR"; } + + if (address == 0xc010) { return "MON.KBDSTRB"; } + + if (address == 0xc011) { return "M80_RDLCBNK2"; } + if (address == 0xc012) { return "M80_RDLCRAM"; } + if (address == 0xc013) { return "M80_RDRAMRD"; } + if (address == 0xc014) { return "M80_RDRAMWRT"; } + + if (address == 0xc015) { return "RDCXROM"; } + if (address == 0xc016) { return "RDALTZP"; } + if (address == 0xc017) { return "RDC3ROM"; } + + if (address == 0xc018) { return "MON.RD80STORE"; } + + if (address == 0xc019) { return "RDVBLBAR"; } + if (address == 0xc01A) { return "RDTEXT"; } + if (address == 0xc01B) { return "RDMIXED"; } + + if (address == 0xc01c) { return "RDPAGE2"; } + if (address == 0xc01D) { return "RDHIRES"; } + if (address == 0xc01E) { return "RDALTCHAR"; } + + if (address == 0xc01f) { return "RD80VID"; } + + if (address == 0xc020) { return "TAPEOUT"; } + + if (address == 0xc030) { return "SPKR"; } + + if (address == 0xc040) { return "STROBE"; } + + if (address == 0xc050) { return "SW.TXTCLR"; } + if (address == 0xc051) { return "SW.TXTSET"; } + if (address == 0xc052) { return "SW.MIXCLR"; } + if (address == 0xc053) { return "SW.MIXSET"; } + if (address == 0xc054) { return "SW.LOWSCR"; } + if (address == 0xc055) { return "SW.HISCR"; } + if (address == 0xc056) { return "SW.LORES"; } + if (address == 0xc057) { return "SW.HIRES"; } + if (address == 0xc058) { return "SW.SETAN0"; } + if (address == 0xc059) { return "SW.CLRAN0"; } + if (address == 0xc05a) { return "SW.SETAN1"; } + if (address == 0xc05b) { return "SW.CLRAN1"; } + if (address == 0xc05c) { return "SW.SETAN2"; } + if (address == 0xc05d) { return "SW.CLRAN2"; } + if (address == 0xc05e) { return "SW.SETAN3"; } + if (address == 0xc05f) { return "SW.CLRAN3"; } + if (address == 0xc060) { return "MON.TAPEIN"; } + if (address == 0xc064) { return "MON.PADDL0"; } + if (address == 0xc070) { return "MON.PTRIG"; } + + if (address == 0xc080) { return "RDRAMBANK2_NOWRITE"; } + if (address == 0xc081) { return "RDROM_WRBANK2"; } + if (address == 0xc082) { return "RDROM_NOWRITE"; } + if (address == 0xc083) { return "RDWRBANK2"; } + if (address == 0xc084) { return "RDRAM_NOWRITE"; } + if (address == 0xc085) { return "READROM_WRBANK2"; } + if (address == 0xc086) { return "RDROM_NOWRITE"; } + if (address == 0xc087) { return "RDWRBANK2"; } + if (address == 0xc088) { return "RDBANK1_NOWRITE"; } + if (address == 0xc089) { return "RDROM_WRBANK1"; } + if (address == 0xc08A) { return "RDROM_NOWRITE"; } + if (address == 0xc08B) { return "RDWRBANK1"; } + if (address == 0xc08C) { return "RDBANK1_NOWRITE"; } + if (address == 0xc08D) { return "RDROM_WRBANK1"; } + if (address == 0xc08E) { return "RDROM_NOWRITE"; } + if (address == 0xc08F) { return "RDWR_BANK1"; } + + if (address == 0xc090) { return "SLOT1_ROM0"; } + if (address == 0xc091) { return "SLOT1_ROM1"; } + if (address == 0xc092) { return "SLOT1_ROM2"; } + if (address == 0xc093) { return "SLOT1_ROM3"; } + if (address == 0xc094) { return "SLOT1_ROM4"; } + if (address == 0xc095) { return "SLOT1_ROM5"; } + if (address == 0xc096) { return "SLOT1_ROM6"; } + if (address == 0xc097) { return "SLOT1_ROM7"; } + if (address == 0xc098) { return "SLOT1_ROM8"; } + if (address == 0xc099) { return "SLOT1_ROM9"; } + if (address == 0xc09A) { return "SLOT1_ROMA"; } + if (address == 0xc09B) { return "SLOT1_ROMB"; } + if (address == 0xc09C) { return "SLOT1_ROMC"; } + if (address == 0xc09D) { return "SLOT1_ROMD"; } + if (address == 0xc09E) { return "SLOT1_ROME"; } + if (address == 0xc09F) { return "SLOT1_ROMF"; } + + if (address == 0xc0A0) { return "SLOT2_ROM0"; } + if (address == 0xc0A1) { return "SLOT2_ROM1"; } + if (address == 0xc0A2) { return "SLOT2_ROM2"; } + if (address == 0xc0A3) { return "SLOT2_ROM3"; } + if (address == 0xc0A4) { return "SLOT2_ROM4"; } + if (address == 0xc0A5) { return "SLOT2_ROM5"; } + if (address == 0xc0A6) { return "SLOT2_ROM6"; } + if (address == 0xc0A7) { return "SLOT2_ROM7"; } + if (address == 0xc0A8) { return "SLOT2_ROM8"; } + if (address == 0xc0A9) { return "SLOT2_ROM9"; } + if (address == 0xc0AA) { return "SLOT2_ROMA"; } + if (address == 0xc0AB) { return "SLOT2_ROMB"; } + if (address == 0xc0AC) { return "SLOT2_ROMC"; } + if (address == 0xc0AD) { return "SLOT2_ROMD"; } + if (address == 0xc0AE) { return "SLOT2_ROME"; } + if (address == 0xc0AF) { return "SLOT2_ROMF"; } + + if (address == 0xc0B0) { return "SLOT3_ROM0"; } + if (address == 0xc0B1) { return "SLOT3_ROM1"; } + if (address == 0xc0B2) { return "SLOT3_ROM2"; } + if (address == 0xc0B3) { return "SLOT3_ROM3"; } + if (address == 0xc0B4) { return "SLOT3_ROM4"; } + if (address == 0xc0B5) { return "SLOT3_ROM5"; } + if (address == 0xc0B6) { return "SLOT3_ROM6"; } + if (address == 0xc0B7) { return "SLOT3_ROM7"; } + if (address == 0xc0B8) { return "SLOT3_ROM8"; } + if (address == 0xc0B9) { return "SLOT3_ROM9"; } + if (address == 0xc0BA) { return "SLOT3_ROMA"; } + if (address == 0xc0BB) { return "SLOT3_ROMB"; } + if (address == 0xc0BC) { return "SLOT3_ROMC"; } + if (address == 0xc0BD) { return "SLOT3_ROMD"; } + if (address == 0xc0BE) { return "SLOT3_ROME"; } + if (address == 0xc0BF) { return "SLOT3_ROMF"; } + + if (address == 0xc0C0) { return "SLOT4_ROM0"; } + if (address == 0xc0C1) { return "SLOT4_ROM1"; } + if (address == 0xc0C2) { return "SLOT4_ROM2"; } + if (address == 0xc0C3) { return "SLOT4_ROM3"; } + if (address == 0xc0C4) { return "SLOT4_ROM4"; } + if (address == 0xc0C5) { return "SLOT4_ROM5"; } + if (address == 0xc0C6) { return "SLOT4_ROM6"; } + if (address == 0xc0C7) { return "SLOT4_ROM7"; } + if (address == 0xc0C8) { return "SLOT4_ROM8"; } + if (address == 0xc0C9) { return "SLOT4_ROM9"; } + if (address == 0xc0CA) { return "SLOT4_ROMA"; } + if (address == 0xc0CB) { return "SLOT4_ROMB"; } + if (address == 0xc0CC) { return "SLOT4_ROMC"; } + if (address == 0xc0CD) { return "SLOT4_ROMD"; } + if (address == 0xc0CE) { return "SLOT4_ROME"; } + if (address == 0xc0CF) { return "SLOT4_ROMF"; } + + if (address == 0xc0D0) { return "SLOT5_ROM0"; } + if (address == 0xc0D1) { return "SLOT5_ROM1"; } + if (address == 0xc0D2) { return "SLOT5_ROM2"; } + if (address == 0xc0D3) { return "SLOT5_ROM3"; } + if (address == 0xc0D4) { return "SLOT5_ROM4"; } + if (address == 0xc0D5) { return "SLOT5_ROM5"; } + if (address == 0xc0D6) { return "SLOT5_ROM6"; } + if (address == 0xc0D7) { return "SLOT5_ROM7"; } + if (address == 0xc0D8) { return "SLOT5_ROM8"; } + if (address == 0xc0D9) { return "SLOT5_ROM9"; } + if (address == 0xc0DA) { return "SLOT5_ROMA"; } + if (address == 0xc0DB) { return "SLOT5_ROMB"; } + if (address == 0xc0DC) { return "SLOT5_ROMC"; } + if (address == 0xc0DD) { return "SLOT5_ROMD"; } + if (address == 0xc0DE) { return "SLOT5_ROME"; } + if (address == 0xc0DF) { return "SLOT5_ROMF"; } + + if (address == 0xc0E0) { return "SLOT6_ROM0"; } + if (address == 0xc0E1) { return "SLOT6_ROM1"; } + if (address == 0xc0E2) { return "SLOT6_ROM2"; } + if (address == 0xc0E3) { return "SLOT6_ROM3"; } + if (address == 0xc0E4) { return "SLOT6_ROM4"; } + if (address == 0xc0E5) { return "SLOT6_ROM5"; } + if (address == 0xc0E6) { return "SLOT6_ROM6"; } + if (address == 0xc0E7) { return "SLOT6_ROM7"; } + if (address == 0xc0E8) { return "SLOT6_ROM8"; } + if (address == 0xc0E9) { return "SLOT6_ROM9"; } + if (address == 0xc0EA) { return "SLOT6_ROMA"; } + if (address == 0xc0EB) { return "SLOT6_ROMB"; } + if (address == 0xc0EC) { return "SLOT6_ROMC"; } + if (address == 0xc0ED) { return "SLOT6_ROMD"; } + if (address == 0xc0EE) { return "SLOT6_ROME"; } + if (address == 0xc0EF) { return "SLOT6_ROMF"; } + + if (address == 0xc0F0) { return "SLOT7_ROM0"; } + if (address == 0xc0F1) { return "SLOT7_ROM1"; } + if (address == 0xc0F2) { return "SLOT7_ROM2"; } + if (address == 0xc0F3) { return "SLOT7_ROM3"; } + if (address == 0xc0F4) { return "SLOT7_ROM4"; } + if (address == 0xc0F5) { return "SLOT7_ROM5"; } + if (address == 0xc0F6) { return "SLOT7_ROM6"; } + if (address == 0xc0F7) { return "SLOT7_ROM7"; } + if (address == 0xc0F8) { return "SLOT7_ROM8"; } + if (address == 0xc0F9) { return "SLOT7_ROM9"; } + if (address == 0xc0FA) { return "SLOT7_ROMA"; } + if (address == 0xc0FB) { return "SLOT7_ROMB"; } + if (address == 0xc0FC) { return "SLOT7_ROMC"; } + if (address == 0xc0FD) { return "SLOT7_ROMD"; } + if (address == 0xc0FE) { return "SLOT7_ROME"; } + if (address == 0xc0FF) { return "SLOT7_ROMF"; } + + if (address == 0xc100) { return "M80_BFUNCPG"; } + if (address == 0xc107) { return "M80_B.FUNCK"; } + if (address == 0xc10E) { return "M80_B.FUNCNE"; } + if (address == 0xc11f) { return "M80_B.OLDFUNC"; } + if (address == 0xc129) { return "M80_F.CLREOP"; } + if (address == 0xc12d) { return "M80_CLEOP1"; } + if (address == 0xc143) { return "M80_F.HOME"; } + if (address == 0xc14d) { return "M80_F.SCROLL"; } + if (address == 0xc153) { return "M80_SCRL1"; } + if (address == 0xc169) { return "M80_SCRL2"; } + if (address == 0xc172) { return "M80_SCRL3"; } + if (address == 0xc17d) { return "M80_F.CLREOL"; } + if (address == 0xc181) { return "M80_CLEOL2"; } + if (address == 0xc18a) { return "M80_F.SETWND"; } + if (address == 0xc19c) { return "M80_F.CLEOLZ"; } + if (address == 0xc1a1) { return "M80_F.GORET"; } + if (address == 0xc1a4) { return "M80_B.FUNCO"; } + if (address == 0xc1c5) { return "M80_NOI"; } + if (address == 0xc1cd) { return "M80_B.SCROLL"; } + if (address == 0xc1d3) { return "M80_B.CLREOL"; } + if (address == 0xc1d9) { return "M80_B.CLEOLZ"; } + if (address == 0xc1e1) { return "M80_B.CLREOP"; } + if (address == 0xc1e7) { return "M80_B.SETWND"; } + if (address == 0xc1ea) { return "M80_B.RESET"; } + if (address == 0xc1ed) { return "M80_B.HOME"; } + if (address == 0xc1ff) { return "M80_B.VECTOR"; } + if (address == 0xc20e) { return "M80_B.GETCH"; } + if (address == 0xc211) { return "M80_B.FUNC1"; } + if (address == 0xc219) { return "M80_B.SETWNDX"; } + if (address == 0xc221) { return "M80_B.SETWND2"; } + if (address == 0xc22e) { return "M80_GOBACK"; } + if (address == 0xc234) { return "M80_B.RESETX"; } + if (address == 0xc252) { return "M80_BLAST"; } + if (address == 0xc261) { return "M80_DIAGS"; } + if (address == 0xc264) { return "M80_RESETRET"; } + if (address == 0xc26e) { return "M80_B.ESCFIX"; } + if (address == 0xc272) { return "M80_B.ESCFIX2"; } + if (address == 0xc27a) { return "M80_B.ESCFIX3"; } + if (address == 0xc27d) { return "M80_GORETN"; } + if (address == 0xc280) { return "M80_ESCIN"; } + if (address == 0xc284) { return "M80_ESCOUT"; } + if (address == 0xc288) { return "M80_B.KEYIN"; } + if (address == 0xc29c) { return "M80_B.KEYIN2"; } + if (address == 0xc2b5) { return "M80_GOTKEY"; } + if (address == 0xc2c6) { return "M80_KEYDLY"; } + if (address == 0xc2cc) { return "M80_IK1"; } + if (address == 0xc2ce) { return "M80_IK2"; } + if (address == 0xc2d5) { return "M80_IK2A"; } + if (address == 0xc2db) { return "M80_IK3"; } + if (address == 0xc2e6) { return "M80_KDRETN"; } + if (address == 0xc2e9) { return "M80_KDRETY"; } + if (address == 0xc2ea) { return "M80_KDRET"; } + if (address == 0xc2eb) { return "M80_F.RETURN"; } + if (address == 0xc2f1) { return "M80_F.RET1"; } + if (address == 0xc2f4) { return "M80_X.CLEOLZ"; } + if (address == 0xc2f6) { return "M80_X.CLEOL2"; } + if (address == 0xc300) { return "M80_CN00/M80_BASICINT"; } + if (address == 0xc305) { return "M80_BASICIN"; } + if (address == 0xc307) { return "M80_BASICOUT"; } + if (address == 0xc317) { return "M80_BASICENT"; } + if (address == 0xc336) { return "M80_BASICENT2"; } + if (address == 0xc348) { return "M80_JBASINIT"; } + if (address == 0xc34b) { return "M80_JPINIT"; } + if (address == 0xc351) { return "M80_JPREAD"; } + if (address == 0xc357) { return "M80_JPWRITE"; } + if (address == 0xc35d) { return "M80_JPSTAT"; } + if (address == 0xc363) { return "M80_MOVE"; } + if (address == 0xc378) { return "M80_MOVEC2M"; } + if (address == 0xc37b) { return "M80_MOVESTRT"; } + if (address == 0xc380) { return "M80_MOVELOOP"; } + if (address == 0xc38a) { return "M80_NXTA1"; } + if (address == 0xc398) { return "M80_C01"; } + if (address == 0xc3a3) { return "M80_C03"; } + if (address == 0xc3ac) { return "M80_MOVERET"; } + if (address == 0xc3b0) { return "M80_XFER"; } + if (address == 0xc3c5) { return "M80_XFERC2M"; } + if (address == 0xc3cd) { return "M80_XFERAZP"; } + if (address == 0xc3dc) { return "M80_XFERSZP"; } + if (address == 0xc3eb) { return "M80_SETCB"; } + if (address == 0xc803) { return "M80_BASICINIT"; } + if (address == 0xc813) { return "M80_HANG"; } + if (address == 0xc816) { return "M80_BINIT1"; } + if (address == 0xc831) { return "M80_BINIT1A"; } + if (address == 0xc850) { return "M80_BINIT2"; } + if (address == 0xc85d) { return "M80_CLEARIT"; } + if (address == 0xc866) { return "M80_C8BASIC"; } + if (address == 0xc874) { return "M80_C8B2"; } + if (address == 0xc87e) { return "M80_C8B3"; } + if (address == 0xc890) { return "M80_C8B4"; } + if (address == 0xc896) { return "M80_BOUT"; } + if (address == 0xc8a1) { return "M80_BPRINT"; } + if (address == 0xc8b4) { return "M80_KBDWAIT"; } + if (address == 0xc8c0) { return "M80_NOWAIT"; } + if (address == 0xc8cc) { return "M80_BPNCTL"; } + if (address == 0xc8e2) { return "M80_BIORET"; } + if (address == 0xc8f6) { return "M80_BINPUT"; } + if (address == 0xc905) { return "M80_B.INPUT"; } + if (address == 0xc918) { return "M80_ESCAPING"; } + if (address == 0xc929) { return "M80_ESC1"; } + if (address == 0xc92b) { return "M80_ESC2"; } + if (address == 0xc935) { return "M80_ESC3"; } + if (address == 0xc945) { return "M80_ESCSPEC"; } + if (address == 0xc954) { return "M80_ESCSPEC2"; } + if (address == 0xc960) { return "M80_ESCNONE"; } + if (address == 0xc963) { return "M80_ESCSPEC3"; } + if (address == 0xc972) { return "M80_ESCTAB"; } + if (address == 0xc983) { return "M80_ESCCHAR"; } + if (address == 0xc994) { return "M80_PSTATUS"; } + if (address == 0xc99e) { return "M80_PSTATUS2"; } + if (address == 0xc9b0) { return "M80_PSTATUS3"; } + if (address == 0xc9b4) { return "M80_PSTATUS4"; } + if (address == 0xc9b7) { return "M80_NOESC"; } + if (address == 0xc9c6) { return "M80_B.NOPICK"; } + if (address == 0xc9df) { return "M80_B.CHKCAN"; } + if (address == 0xc9f7) { return "M80_B.FLIP"; } + if (address == 0xca02) { return "M80_B.CANLIT"; } + if (address == 0xca0a) { return "M80_B.FIXCHR"; } + if (address == 0xca24) { return "M80_B.INRET"; } + if (address == 0xca27) { return "M80_GETPRIOR"; } + if (address == 0xca49) { return "M80_GPX"; } + if (address == 0xca4a) { return "M80_PREAD"; } + if (address == 0xca4f) { return "M80_PREADRET2"; } + if (address == 0xca51) { return "M80_PWRITE"; } + if (address == 0xca62) { return "M80_PIGOOD"; } + if (address == 0xca74) { return "M80_PREAD"; } + if (address == 0xca8a) { return "M80_PREADRET2"; } + if (address == 0xca8e) { return "M80_PWRITE"; } + if (address == 0xca9e) { return "M80_PWRITE2"; } + if (address == 0xcaaf) { return "M80_GETY"; } + if (address == 0xcacb) { return "M80_PWRITE3"; } + if (address == 0xcadc) { return "M80_STARTXY"; } + if (address == 0xcaeb) { return "M80_PWRITE4"; } + if (address == 0xcb09) { return "M80_PWWRAP"; } + if (address == 0xcb0f) { return "M80_PWRITERET"; } + if (address == 0xcb15) { return "M80_GETKEY"; } + if (address == 0xcb1b) { return "M80_GETK2"; } + if (address == 0xcb24) { return "M80_TESTCARD"; } + if (address == 0xcb48) { return "M80_STAY2"; } + if (address == 0xcb4d) { return "M80_STAY80"; } + if (address == 0xcb4e) { return "M80_TESTFAIL"; } + if (address == 0xcb51) { return "M80_BASCALC"; } + if (address == 0xcb54) { return "M80_BASCALCZ"; } + if (address == 0xcb55) { return "M80_BSCLC1"; } + if (address == 0xcb5b) { return "M80_BSCLC1A"; } + if (address == 0xcb6d) { return "M80_BSCLC2"; } + if (address == 0xcb7e) { return "M80_BASCLC3"; } + if (address == 0xcb97) { return "M80_BASCLCX"; } + if (address == 0xcb99) { return "M80_CTLCHAR"; } + if (address == 0xcbab) { return "M80_CTLCHARX"; } + if (address == 0xcbae) { return "M80_CTLGO"; } + if (address == 0xcbb2) { return "M80_CTLRET"; } + if (address == 0xcbb6) { return "M80_CTLXFER"; } + if (address == 0xcbbc) { return "M80_X.BELL"; } + if (address == 0xcbce) { return "M80_BELL2"; } + if (address == 0xcbcf) { return "M80_WAIT"; } + if (address == 0xcbd0) { return "M80_WAIT2"; } + if (address == 0xcbd1) { return "M80_WAIT3"; } + if (address == 0xcbdb) { return "M80_X.BS"; } + if (address == 0xcbe2) { return "M80_BS40"; } + if (address == 0xcbeb) { return "M80_BSDONE"; } + if (address == 0xcbec) { return "M80_X.CR"; } + if (address == 0xcbfd) { return "M80_X.CRPAS"; } + if (address == 0xcc0c) { return "M80_X.CRRET"; } + if (address == 0xcc0d) { return "M80_X.EM"; } + if (address == 0xcc1a) { return "M80_X.SUB"; } + if (address == 0xcc1d) { return "M80_X.SUB80"; } + if (address == 0xcc1f) { return "M80_X.SUBLP"; } + if (address == 0xcc26) { return "M80_X.FS"; } + if (address == 0xcc33) { return "M80_X.FSRET"; } + if (address == 0xcc34) { return "M80_X.US"; } + if (address == 0xcc40) { return "M80_X.US1"; } + if (address == 0xcc45) { return "M80_X.US2"; } + if (address == 0xcc48) { return "M80_X.USRET"; } + if (address == 0xcc49) { return "M80_X.SO"; } + if (address == 0xcc52) { return "M80_X.SI"; } + if (address == 0xcc59) { return "M80_STUFFINV"; } + if (address == 0xcc5f) { return "M80_CTLADL"; } + if (address == 0xcc78) { return "M80_CTLADH"; } + if (address == 0xcc91) { return "M80_X.LF"; } + if (address == 0xcc9e) { return "M80_X.LF2"; } + if (address == 0xcca4) { return "M80_SCROLLUP"; } + if (address == 0xccaa) { return "M80_SCROLLDN"; } + if (address == 0xccae) { return "M80_SCROLL1"; } + if (address == 0xccb8) { return "M80_SCROLL2"; } + if (address == 0xccd1) { return "M80_SCRLSUB"; } + if (address == 0xccdd) { return "M80_MSCROL0"; } + if (address == 0xcce1) { return "M80_MSCROL1"; } + if (address == 0xccf9) { return "M80_MSCRL2"; } + if (address == 0xcd02) { return "M80_MSCRLRET"; } + if (address == 0xcd09) { return "M80_ONEMORE"; } + if (address == 0xcd10) { return "M80_MSCRLRTS"; } + if (address == 0xcd11) { return "M80_X.SCRLRET"; } + if (address == 0xcd17) { return "M80_X.SCRLRET2"; } + if (address == 0xcd20) { return "M80_X.LFRET"; } + if (address == 0xcd23) { return "M80_X.VT"; } + if (address == 0xcd2c) { return "M80_X.VTLOOP"; } + if (address == 0xcd32) { return "M80_X.VTNEXT"; } + if (address == 0xcd42) { return "M80_X.FF"; } + if (address == 0xcd48) { return "M80_X.GS"; } + if (address == 0xcd4e) { return "M80_X.GSEOLZ"; } + if (address == 0xcd54) { return "M80_X.GS2"; } + if (address == 0xcd59) { return "M80_X.DC1"; } + if (address == 0xcd64) { return "M80_X.DC1B"; } + if (address == 0xcd76) { return "M80_X.DC1RTS"; } + if (address == 0xcd77) { return "M80_X.DC2"; } + if (address == 0xcd88) { return "M80_X.DC2B"; } + if (address == 0xcd90) { return "M80_X.NAK"; } + if (address == 0xcd9a) { return "M80_X.NAKRET/M80_DC2RET"; } + if (address == 0xcd9b) { return "M80_FULL80"; } + if (address == 0xcdaa) { return "M80_QUIT"; } + if (address == 0xcdc0) { return "M80_QUIT2"; } + if (address == 0xcddb) { return "M80_SCRN84"; } + if (address == 0xcdea) { return "M80_SCR40"; } + if (address == 0xce01) { return "M80_SCR40RET"; } + if (address == 0xce0a) { return "M80_ATEFOR"; } + if (address == 0xce13) { return "M80_ATEFOR1"; } + if (address == 0xce22) { return "M80_GET84"; } + if (address == 0xce32) { return "M80_SCRN48"; } + if (address == 0xce3e) { return "M80_SCR80"; } + if (address == 0xce55) { return "M80_SCR80RET"; } + if (address == 0xce58) { return "M80_SCRNRET"; } + if (address == 0xce63) { return "M80_FORATE"; } + if (address == 0xce6f) { return "M80_FORATE1"; } + if (address == 0xce91) { return "M80_CLRHALF"; } + if (address == 0xce9b) { return "M80_CLRHALF2"; } + if (address == 0xcea3) { return "M80_DO48"; } + if (address == 0xceaf) { return "M80_SETCH"; } + if (address == 0xced9) { return "M80_SETCHRTS"; } + if (address == 0xcedd) { return "M80_INVERT"; } + if (address == 0xcef2) { return "M80_STORCHAR"; } + if (address == 0xcef9) { return "M80_STOR2"; } + if (address == 0xcf00) { return "M80_SEV"; } + if (address == 0xcf01) { return "M80_PICK"; } + if (address == 0xcf06) { return "M80_SCREENIT"; } + if (address == 0xcf1e) { return "M80_SCRN2"; } + if (address == 0xcf2a) { return "M80_STOR80"; } + if (address == 0xcf37) { return "M80_SCRN3"; } + if (address == 0xcf40) { return "M80_SCRN40"; } + if (address == 0xcf4a) { return "M80_STOR40"; } + if (address == 0xcf4e) { return "M80_STPKEXIT"; } + if (address == 0xcf52) { return "M80_ESCON"; } + if (address == 0xcf65) { return "M80_ESCOFF"; } + if (address == 0xcf6e) { return "M80_ESCRET"; } + if (address == 0xcf78) { return "M80_COPYROM"; } + if (address == 0xcf95) { return "M80_COPYROM2"; } + if (address == 0xcfb3) { return "M80_LCB2ROM"; } + if (address == 0xcfb9) { return "M80_LCB1"; } + if (address == 0xcfc2) { return "M80_LCB1ROM"; } + if (address == 0xcfc5) { return "M80_COPYRET"; } + if (address == 0xcfc8) { return "M80_PSETUP"; } + if (address == 0xcfd2) { return "M80_PSETUP2"; } + if (address == 0xcfdf) { return "M80_PSETUPRET"; } + if (address == 0xcfea) { return "M80_F.TABLE"; } + if (address == 0xcff0) { return "M80_PLUSMINUS1"; } + if (address == 0xcff3) { return "M80_B.TABLE"; } + if (address == 0xcff9) { return "M80_WNDTAB"; } + if (address == 0xcffd) { return "M80_ZZEND"; } + + + if (address == 0xcfff) { return "MON.CLRROM"; } + if (address == 0xe000) { return "MON.BASIC"; } + if (address == 0xe003) { return "MON.BASIC2"; } + + if (address == 0xd365) { return "AS.GTFORPNT"; } + if (address == 0xd39e) { return "AS.BLTU"; } + if (address == 0xd39a) { return "AS.BLTU2"; } + if (address == 0xd3d6) { return "AS.CHKMEM"; } + if (address == 0xd3e3) { return "AS.REASON"; } + if (address == 0xd410) { return "AS.MEMERR"; } + if (address == 0xd412) { return "AS.ERROR"; } + if (address == 0xd431) { return "AS.PRINT_ERROR_LINNUM"; } + if (address == 0xd43c) { return "AS.RESTART"; } + if (address == 0xd45c) { return "AS.NUMBERED_LINE"; } + if (address == 0xd4b5) { return "AS.PUT_NEW_LINE"; } + if (address == 0xd4f2) { return "AS.FIX_LINKS"; } + if (address == 0xd52c) { return "AS.INLIN"; } + if (address == 0xd52e) { return "AS.INLIN2"; } + if (address == 0xd553) { return "AS.INCHR"; } + if (address == 0xd559) { return "AS.PARSE_INPUT_LINE"; } + if (address == 0xd56c) { return "AS.PARSE"; } + if (address == 0xd61a) { return "AS.FNDLIN"; } + if (address == 0xd61e) { return "AS.FL1"; } + if (address == 0xd648) { return "AS.RTS1"; } + if (address == 0xd649) { return "AS.NEW"; } + if (address == 0xd64b) { return "AS.SCRTCH"; } + if (address == 0xd665) { return "AS.SETPTRS"; } + if (address == 0xd66a) { return "AS.CLEAR"; } + if (address == 0xd66c) { return "AS.CLEARC"; } + if (address == 0xd683) { return "AS.STKINI"; } + if (address == 0xd696) { return "AS.RTS2"; } + if (address == 0xd697) { return "AS.STXTPT"; } + if (address == 0xd6a5) { return "AS.LIST"; } + if (address == 0xd6da) { return "AS.LIST0"; } + if (address == 0xd6fe) { return "AS.LIST1"; } + if (address == 0xd702) { return "AS.LIST2"; } + if (address == 0xd724) { return "AS.LIST3"; } + if (address == 0xd72c) { return "AS.GETCHR"; } + if (address == 0xd734) { return "AS.LIST4"; } + if (address == 0xd766) { return "AS.FOR"; } + if (address == 0xd7af) { return "AS.STEP"; } + if (address == 0xd7d2) { return "AS.NEWSTT"; } + if (address == 0xd805) { return "AS.TRACE_"; } + if (address == 0xd826) { return "AS.GOEND"; } + if (address == 0xd828) { return "AS.EXECUTE_STATEMENT"; } + if (address == 0xd82a) { return "AS.EXECUTE_STATEMENT1"; } + if (address == 0xd842) { return "AS.COLON_"; } + if (address == 0xd846) { return "AS.SYNERR1"; } + if (address == 0xd849) { return "AS.RESTORE"; } + if (address == 0xd853) { return "AS.SETDA"; } + if (address == 0xd857) { return "AS.RTS3"; } + if (address == 0xd858) { return "AS.ISCNTC"; } + if (address == 0xd863) { return "AS.CONTROL_C_TYPED"; } + if (address == 0xd86e) { return "AS.STOP"; } + if (address == 0xd870) { return "AS.END"; } + if (address == 0xd871) { return "AS.END2"; } + if (address == 0xd88a) { return "AS.END4"; } + if (address == 0xd896) { return "AS.CONT"; } + if (address == 0xd8af) { return "AS.RTS4"; } + if (address == 0xd8b0) { return "AS.SAVE"; } + if (address == 0xd8c9) { return "AS.LOAD"; } + if (address == 0xd8F0) { return "AS.VARTIO"; } + if (address == 0xd901) { return "AS.PROGIO"; } + if (address == 0xd912) { return "AS.RUN"; } + if (address == 0xd921) { return "AS.GOSUB"; } + if (address == 0xd935) { return "AS.GO_TO_LINE"; } + if (address == 0xd93e) { return "AS.GOTO"; } + if (address == 0xd96a) { return "AS.RTS5"; } + if (address == 0xd96b) { return "AS.POP"; } + if (address == 0xd97c) { return "AS.UNDERR"; } + if (address == 0xd981) { return "AS.SYNERR2"; } + if (address == 0xd984) { return "AS.RETURN"; } + if (address == 0xd995) { return "AS.DATA"; } + if (address == 0xd998) { return "AS.ADDON"; } + if (address == 0xd9a2) { return "AS.RTS6"; } + if (address == 0xd9a3) { return "AS.DATAN"; } + if (address == 0xd9a6) { return "AS.REMN"; } + if (address == 0xd9c5) { return "AS.PULL3"; } + if (address == 0xd9c9) { return "AS.IF"; } + if (address == 0xd9dc) { return "AS.REM"; } + if (address == 0xd9e1) { return "AS.IFTRUE"; } + if (address == 0xd9ec) { return "AS.ONGOTO"; } + if (address == 0xd9f4) { return "AS.ON1"; } + if (address == 0xd9f8) { return "AS.ON2"; } + if (address == 0xda0b) { return "AS.RTS7"; } + if (address == 0xda0c) { return "AS.LINGET"; } + if (address == 0xda46) { return "AS.LET"; } + if (address == 0xda63) { return "AS.LET2"; } + if (address == 0xda7a) { return "AS.LET_STRING"; } + if (address == 0xda7b) { return "AS.PUTSTR"; } + if (address == 0xdacf) { return "AS.PR_SPRING"; } + if (address == 0xdad5) { return "AS.PRINT"; } + if (address == 0xdad7) { return "AS.PRINT2"; } + if (address == 0xdafb) { return "AS.CRDO"; } + if (address == 0xdb00) { return "AS.NEGATE"; } + if (address == 0xdb02) { return "AS.PR_RTS8"; } + if (address == 0xdb03) { return "AS.PR_COMMA"; } + if (address == 0xdb16) { return "AS.PR_TAB_OR_SPC"; } + if (address == 0xdb2c) { return "AS.NXSPC"; } + if (address == 0xdb2f) { return "AS.PR_NEXT_CHAR"; } + if (address == 0xdb35) { return "AS.DOSPC"; } + if (address == 0xdb3a) { return "AS.STROUT"; } + if (address == 0xdb3d) { return "AS.STRPRT"; } + if (address == 0xdb57) { return "AS.OUTSP"; } + if (address == 0xdb5a) { return "AS.OUTQUES"; } + if (address == 0xdb5c) { return "AS.OUTDO"; } + if (address == 0xdb71) { return "AS.INPUTERR"; } + if (address == 0xdb7b) { return "AS.READERR"; } + if (address == 0xdb7f) { return "AS.ERLIN"; } + if (address == 0xdb86) { return "AS.INPERR"; } + if (address == 0xdb87) { return "AS.RESPERR"; } + if (address == 0xdba0) { return "AS.GET"; } + if (address == 0xdbb2) { return "AS.INPUT"; } + if (address == 0xdbdc) { return "AS.NXIN"; } + if (address == 0xdbe2) { return "AS.READ"; } + if (address == 0xdbe9) { return "AS.INPUT_FLAG_ZERO"; } + if (address == 0xdbeb) { return "AS.PROCESS_INPUT_LIST"; } + if (address == 0xdbf1) { return "AS.PROCESS_INPUT_ITEM"; } + if (address == 0xdC2b) { return "AS.INSTART"; } + if (address == 0xdC69) { return "AS.INPUT_DATA"; } + if (address == 0xdC72) { return "AS.INPUT_MORE"; } + if (address == 0xdC99) { return "AS.INPFIN"; } + if (address == 0xdCa0) { return "AS.FINDATA"; } + if (address == 0xdCC6) { return "AS.INPDONE"; } + if (address == 0xdcdf) { return "AS.ERR_EXTRA"; } + if (address == 0xdcef) { return "AS.ERR_REENTRY"; } + if (address == 0xdcf9) { return "AS.NEXT"; } + if (address == 0xdcff) { return "AS.NEXT1"; } + if (address == 0xdd02) { return "AS.NEXT2"; } + if (address == 0xdd0d) { return "AS.GERR"; } + if (address == 0xdd0f) { return "AS.NEXT3"; } + if (address == 0xdd67) { return "AS.FRMNUM"; } + if (address == 0xdd6a) { return "AS.CHKNUM"; } + if (address == 0xdd6c) { return "AS.CHKSTR"; } + if (address == 0xdd6d) { return "AS.CHKVAL"; } + if (address == 0xdd78) { return "AS.JERROR"; } + if (address == 0xdd7b) { return "AS.FRMEVL"; } + if (address == 0xdd86) { return "AS.FRMEVL1"; } + if (address == 0xdd95) { return "AS.FRMEVL2"; } + if (address == 0xddcd) { return "AS.FRM_PRECEDENCE_TEST"; } + if (address == 0xddd6) { return "AS.NXOP"; } + if (address == 0xddd7) { return "AS.SAVOP"; } + if (address == 0xdde4) { return "AS.FRM_RELATIONAL"; } + if (address == 0xddf6) { return "AS.FRM_PREFNC"; } + if (address == 0xddfd) { return "AS.FRM_RECURSE"; } + if (address == 0xde0d) { return "AS.SNTXERR"; } + if (address == 0xde10) { return "AS.FRM_STACK1"; } + if (address == 0xde15) { return "AS.FRM_STACK2"; } + if (address == 0xde20) { return "AS.FRM_STACK3"; } + if (address == 0xde35) { return "AS.NOTMATH"; } + if (address == 0xde38) { return "AS.GOEX"; } + if (address == 0xde3a) { return "AS.FRM_PERFORM1"; } + if (address == 0xde43) { return "AS.FRM_PERFORM2"; } + if (address == 0xde5d) { return "AS.EXIT"; } + if (address == 0xde60) { return "AS.FRM_ELEMENT"; } + if (address == 0xde81) { return "AS.STRTXT"; } + if (address == 0xde90) { return "AS.NOT_"; } + if (address == 0xde98) { return "AS.EQUOP"; } + if (address == 0xdea4) { return "AS.FN_"; } + if (address == 0xdeab) { return "AS.SGN_"; } + if (address == 0xdeb2) { return "AS.PARCHK"; } + if (address == 0xdeb8) { return "AS.CHKCLS"; } + if (address == 0xdebb) { return "AS.CHKOPN"; } + if (address == 0xdebe) { return "AS.CHKCOM"; } + if (address == 0xdec0) { return "AS.SYNCHR"; } + if (address == 0xdec9) { return "AS.SYNERR"; } + if (address == 0xdece) { return "AS.MIN"; } + if (address == 0xded0) { return "AS.EQUL"; } + if (address == 0xded5) { return "AS.FRM_VARIABLE"; } + if (address == 0xded7) { return "AS.FRM_VARIABLE_CALL"; } + if (address == 0xdef9) { return "AS.SCREEN"; } + if (address == 0xdf0c) { return "AS.UNARY"; } + if (address == 0xdf4f) { return "AS.OR"; } + if (address == 0xdf55) { return "AS.AND"; } + if (address == 0xdf5d) { return "AS.FALSE"; } + if (address == 0xdf60) { return "AS.TRUE"; } + if (address == 0xdf65) { return "AS.RELOPS"; } + if (address == 0xdf7d) { return "AS.STRCMP"; } + if (address == 0xdfaa) { return "AS.STRCMP1"; } + if (address == 0xdfb0) { return "AS.NUMCMP"; } + if (address == 0xdfb5) { return "AS.STRCMP2"; } + if (address == 0xdfc1) { return "AS.CMPDONE"; } + if (address == 0xdfcd) { return "AS.PDL"; } + if (address == 0xdfd6) { return "AS.NXDIM"; } + if (address == 0xdfd9) { return "AS.DIM"; } + if (address == 0xdfe3) { return "AS.PTRGET"; } + if (address == 0xdfe8) { return "AS.PTRGET2"; } + if (address == 0xdfea) { return "AS.PTRGET3"; } + if (address == 0xdff4) { return "AS.BADNAM"; } + if (address == 0xdff7) { return "AS.NAMOK"; } + if (address == 0xe007) { return "AS.PTRGET4"; } + if (address == 0xe07d) { return "AS.ISLETC"; } + if (address == 0xe087) { return "AS.NAME_NOT_FOUND"; } + if (address == 0xe09c) { return "AS.MAKE_NEW_VARIABLE"; } + if (address == 0xe0de) { return "AS.SET_VARPNT_AND_YA"; } + if (address == 0xe0ed) { return "AS.GETARY"; } + if (address == 0xe0ef) { return "AS.GETARY2"; } + if (address == 0xe102) { return "AS.MAKINT"; } + if (address == 0xe108) { return "AS.MKINT"; } + if (address == 0xe10c) { return "AS.AYINT"; } + if (address == 0xe119) { return "AS.MI1"; } + if (address == 0xe11b) { return "AS.MI2"; } + if (address == 0xe11e) { return "AS.ARRAY"; } + if (address == 0xe196) { return "AS.SUBERR"; } + if (address == 0xe199) { return "AS.IQERR"; } + if (address == 0xe19b) { return "AS.JER"; } + if (address == 0xe19e) { return "AS.USE_OLD_ARRAY"; } + if (address == 0xe1b8) { return "AS.MAKE_NEW_ARRAY"; } + if (address == 0xe24b) { return "AS.FIND_ARRAY_ELEMENT"; } + if (address == 0xe253) { return "AS.FAE1"; } + if (address == 0xe269) { return "AS.GSE"; } + if (address == 0xe26c) { return "AS.GME"; } + if (address == 0xe26f) { return "AS.FAE2"; } + if (address == 0xe270) { return "AS.FAE3"; } + if (address == 0xe2ac) { return "AS.RTS9"; } + if (address == 0xe2ad) { return "AS.MULTIPLY_SUBSCRIPT"; } + if (address == 0xe2b6) { return "AS.MULTIPLY_SUBS1"; } + if (address == 0xe2de) { return "AS.FRE"; } + if (address == 0xe2f2) { return "AS.GIVAYF"; } + if (address == 0xe2ff) { return "AS.POS"; } + if (address == 0xe301) { return "AS.SNGFLT"; } + if (address == 0xe306) { return "AS.ERRDIR"; } + if (address == 0xe30e) { return "AS.UNDFNC"; } + if (address == 0xe313) { return "AS.DEF"; } + if (address == 0xe341) { return "AS.FNC_"; } + if (address == 0xe354) { return "AS.FUNCT"; } + if (address == 0xe3af) { return "AS.FNCDATA"; } + if (address == 0xe3c5) { return "AS.STR"; } + if (address == 0xe3d5) { return "AS.STRINI"; } + if (address == 0xe3dd) { return "AS.STRSPA"; } + if (address == 0xe3e7) { return "AS.STRLIT"; } + if (address == 0xe3ed) { return "AS.STRLT2"; } + if (address == 0xe42a) { return "AS.PUTNEW"; } + if (address == 0xe432) { return "AS.JERR"; } + if (address == 0xe435) { return "AS.PUTEMP"; } + if (address == 0xe452) { return "AS.GETSPA"; } + if (address == 0xe484) { return "AS.GARBAG"; } + if (address == 0xe488) { return "AS.FIND_HIGHEST_STRING"; } + if (address == 0xe519) { return "AS.CHECK_SIMPLE_VARIABLE"; } + if (address == 0xe523) { return "AS.CHECK_VARIABLE"; } + if (address == 0xe552) { return "AS.CHECK_BUMP"; } + if (address == 0xe55d) { return "AS.CHECK_EXIT"; } + if (address == 0xe562) { return "AS.MOVE_HIGHEST_STRING_TO_TOP"; } + if (address == 0xe597) { return "AS.CAT"; } + if (address == 0xe5d4) { return "AS.MOVINS"; } + if (address == 0xe5e2) { return "AS.MOVSTR"; } + if (address == 0xe5e6) { return "AS.MOVSTR1"; } + if (address == 0xe5fd) { return "AS.FRESTR"; } + if (address == 0xe600) { return "AS.FREFAC"; } + if (address == 0xe604) { return "AS.FRETMP"; } + if (address == 0xe635) { return "AS.FRETMS"; } + if (address == 0xe646) { return "AS.CHRSTR"; } + if (address == 0xe65a) { return "AS.LEFTSTR"; } + if (address == 0xe660) { return "AS.SUBSTRING1"; } + if (address == 0xe667) { return "AS.SUBSTRING2"; } + if (address == 0xe668) { return "AS.SUBSTRING3"; } + if (address == 0xe686) { return "AS.RIGHTSTR"; } + if (address == 0xe691) { return "AS.MIDSTR"; } + if (address == 0xe6b9) { return "AS.SUBSTRING_SETUP"; } + if (address == 0xe6d6) { return "AS.LEN"; } + if (address == 0xe6dc) { return "AS.GETSTR"; } + if (address == 0xe6e5) { return "AS.ASC"; } + if (address == 0xe6f2) { return "AS.GOIQ"; } + if (address == 0xe6f5) { return "AS.GTBYTC"; } + if (address == 0xe6f8) { return "AS.GETBYT"; } + if (address == 0xe6fb) { return "AS.CONINT"; } + if (address == 0xe707) { return "AS.VAL"; } + if (address == 0xe73d) { return "AS.POINT"; } + if (address == 0xe746) { return "AS.GTNUM"; } + if (address == 0xe74c) { return "AS.COMBYTE"; } + if (address == 0xe752) { return "AS.GETADR"; } + if (address == 0xe764) { return "AS.PEEK"; } + if (address == 0xe77b) { return "AS.POKE"; } + if (address == 0xe784) { return "AS.WAIT"; } + if (address == 0xe79f) { return "AS.RTS10"; } + if (address == 0xe7a0) { return "AS.FADDH"; } + if (address == 0xe7a7) { return "AS.FSUB"; } + if (address == 0xe7aa) { return "AS.FSUBT"; } + if (address == 0xe7b9) { return "AS.FADD1"; } + if (address == 0xe7be) { return "AS.FADD"; } + if (address == 0xe7c1) { return "AS.FADDT"; } + if (address == 0xe7ce) { return "AS.FADD2"; } + if (address == 0xe7fa) { return "AS.FADD3"; } + if (address == 0xe829) { return "AS.NORMALIZE_FAC1"; } + if (address == 0xe82e) { return "AS.NORMALIZE_FAC2"; } + if (address == 0xe84e) { return "AS.ZERO_FAC"; } + if (address == 0xe850) { return "AS.STA_IN_FAC_SIGN_AND_EXP"; } + if (address == 0xe852) { return "AS.STA_IN_FAC_SIGN"; } + if (address == 0xe855) { return "AS.FADD4"; } + if (address == 0xe874) { return "AS.NORMALIZE_FAC3"; } + if (address == 0xe880) { return "AS.NORMALIZE_FAC4"; } + if (address == 0xe88d) { return "AS.NORMALIZE_FAC5"; } + if (address == 0xe88f) { return "AS.NORMALIZE_FAC6"; } + if (address == 0xe89d) { return "AS.RTS11"; } + if (address == 0xe89e) { return "AS.COMPLEMENT_FAC"; } + if (address == 0xe8a4) { return "AS.COMPLEMENT_FAC_MANTISSA"; } + if (address == 0xe8c6) { return "AS.INCREMENT_FAC_MANTISSA"; } + if (address == 0xe8d4) { return "AS.RTS12"; } + if (address == 0xe8d5) { return "AS.OVERFLOW"; } + if (address == 0xe8da) { return "AS.SHIFT_RIGHT1"; } + if (address == 0xe8dc) { return "AS.SHIFT_RIGHT2"; } + if (address == 0xe8f0) { return "AS.SHIFT_RIGHT"; } + if (address == 0xe8fd) { return "AS.SHIFT_RIGHT3"; } + if (address == 0xe907) { return "AS.SHIFT_RIGHT4"; } + if (address == 0xe911) { return "AS.SHIFT_RIGHT5"; } + if (address == 0xe941) { return "AS.LOG"; } + if (address == 0xe948) { return "AS.GIQ"; } + if (address == 0xe94b) { return "AS.LOG2"; } + if (address == 0xe97f) { return "AS.FMULT"; } + if (address == 0xe982) { return "AS.FMULTT"; } + if (address == 0xe9b0) { return "AS.MULTIPLY1"; } + if (address == 0xe9b5) { return "AS.MULTIPLY2"; } + if (address == 0xe9e2) { return "AS.RTS13"; } + if (address == 0xe9e3) { return "AS.LOAD_ARG_FROM_YA"; } + if (address == 0xea0e) { return "AS.ADD_EXPONENTS"; } + if (address == 0xea10) { return "AS.ADD_EXPONENTS1"; } + if (address == 0xea2b) { return "AS.OUTOFRNG"; } + if (address == 0xea31) { return "AS.ZERO"; } + if (address == 0xea36) { return "AS.JOV"; } + if (address == 0xeae9) { return "AS.MUL10"; } + if (address == 0xea55) { return "AS.DIV10"; } + if (address == 0xea5e) { return "AS.DIV"; } + if (address == 0xea66) { return "AS.FDIV"; } + if (address == 0xeae6) { return "AS.COPY_RESULT_INTO_FAC"; } + if (address == 0xeaf9) { return "AS.LOAD_FAC_FROM_YA"; } + if (address == 0xeb1e) { return "AS.STORE_FAC_IN_TEMP2_ROUNDED"; } + if (address == 0xeb21) { return "AS.STORE_FAC_IN_TEMP1_ROUNDED"; } + if (address == 0xeb27) { return "AS.SETFOR"; } + if (address == 0xeb2b) { return "AS.STORE_FAC_AT_YX_ROUNDED"; } + if (address == 0xeb53) { return "AS.COPY_FAC_TO_ARG"; } + if (address == 0xeb63) { return "AS.COPY_FAC_TO_ARG_ROUNDED"; } + if (address == 0xeb71) { return "AS.RTS14"; } + if (address == 0xeb72) { return "AS.ROUND_FAC"; } + if (address == 0xeb7a) { return "AS.INCREMENT_MANTISSA"; } + if (address == 0xeb82) { return "AS.SIGN"; } + if (address == 0xeb86) { return "AS.SIGN1"; } + if (address == 0xeb88) { return "AS.SIGN2"; } + if (address == 0xeb8f) { return "AS.RTS15"; } + if (address == 0xeb90) { return "AS.SGN"; } + if (address == 0xeb9e) { return "AS.FLOAT"; } + if (address == 0xeb9b) { return "AS.FLOAT1"; } + if (address == 0xeba0) { return "AS.FLOAT2"; } + if (address == 0xebaf) { return "AS.ABS"; } + if (address == 0xebb2) { return "AS.FCOMP"; } + if (address == 0xebb4) { return "AS.FCOMP2"; } + if (address == 0xebf2) { return "AS.QINT"; } + if (address == 0xec11) { return "AS.RTS16"; } + if (address == 0xec12) { return "AS.QINT2"; } + if (address == 0xec23) { return "AS.INT"; } + if (address == 0xec40) { return "AS.QINT3"; } + if (address == 0xec49) { return "AS.RTS17"; } + if (address == 0xec4a) { return "AS.FIN"; } + if (address == 0xec61) { return "AS.FIN1"; } + if (address == 0xec64) { return "AS.FIN2"; } + if (address == 0xec66) { return "AS.FIN3"; } + if (address == 0xec87) { return "AS.FIN4"; } + if (address == 0xec8a) { return "AS.FIN5"; } + if (address == 0xec8c) { return "AS.FIN6"; } + if (address == 0xec98) { return "AS.FIN10"; } + if (address == 0xec9e) { return "AS.FIN7"; } + if (address == 0xeca0) { return "AS.FIN8"; } + if (address == 0xecc1) { return "AS.FIN9"; } + if (address == 0xecd5) { return "AS.ADDACC"; } + if (address == 0xece8) { return "AS.GETEXP"; } + if (address == 0xed19) { return "AS.INPRT"; } + if (address == 0xed24) { return "AS.LINPRT"; } + if (address == 0xed2e) { return "AS.PRINT_FAC"; } + if (address == 0xed31) { return "AS.GO_STROUT"; } + if (address == 0xed34) { return "AS.FOUT"; } + if (address == 0xed36) { return "AS.FOUT1"; } + if (address == 0xed8c) { return "AS.FOUT2"; } + if (address == 0xee17) { return "AS.FOUT3"; } + if (address == 0xee57) { return "AS.FOUT4"; } + if (address == 0xee5a) { return "AS.FOUT5"; } + if (address == 0xee5f) { return "AS.FOUT6"; } + if (address == 0xee8d) { return "AS.SQR"; } + if (address == 0xee97) { return "AS.FPWRT"; } + if (address == 0xeed0) { return "AS.NEGOP"; } + if (address == 0xeeda) { return "AS.RTS18"; } + if (address == 0xef09) { return "AS.EXP"; } + if (address == 0xef5c) { return "AS.POLYNOMIAL_ODD"; } + if (address == 0xef72) { return "AS.POLYNOMIAL"; } + if (address == 0xef76) { return "AS.SERMAIN"; } + if (address == 0xefa5) { return "AS.RTS19"; } + if (address == 0xefae) { return "AS.RND"; } + if (address == 0xefe7) { return "AS.GO_MOVMF"; } + if (address == 0xefea) { return "AS.COS"; } + if (address == 0xeff1) { return "AS.SIN"; } + if (address == 0xf023) { return "AS.SIN1"; } + if (address == 0xf026) { return "AS.SIN2"; } + if (address == 0xf03a) { return "AS.TAN"; } + if (address == 0xf062) { return "AS.TAN1"; } + if (address == 0xf094) { return "AS.MS_EASTER_EGG_DATA"; } + if (address == 0xf09e) { return "AS.ATN"; } + if (address == 0xf0cd) { return "AS.RTS20"; } + if (address == 0xf10b) { return "AS.GENERIC_CHRGET"; } + if (address == 0xf128) { return "AS.COLD_START"; } + if (address == 0xf1d5) { return "AS.CALL"; } + if (address == 0xf1de) { return "AS.IN_NUMBER"; } + if (address == 0xf1e5) { return "AS.PR_NUMBER"; } + if (address == 0xf1ec) { return "AS.PLOTFNS"; } + if (address == 0xf206) { return "AS.GOERR"; } + if (address == 0xf209) { return "AS.LINCOOR"; } + if (address == 0xf225) { return "AS.PLOT"; } + if (address == 0xf232) { return "AS.HLIN"; } + if (address == 0xf241) { return "AS.VLIN"; } + if (address == 0xf24f) { return "AS.COLOR"; } + if (address == 0xf256) { return "AS.VTAB"; } + if (address == 0xf262) { return "AS.SPEED"; } + if (address == 0xf26d) { return "AS.TRACE"; } + if (address == 0xf26f) { return "AS.NOTRACE"; } + if (address == 0xf273) { return "AS.NORMAL"; } + if (address == 0xf277) { return "AS.INVERSE"; } + if (address == 0xf280) { return "AS.FLASH"; } + if (address == 0xf286) { return "AS.HIMEM"; } + if (address == 0xf296) { return "AS.JMM"; } + if (address == 0xf299) { return "AS.SETHI"; } + if (address == 0xf2a6) { return "AS.LOMEM"; } + if (address == 0xf2cb) { return "AS.ONERR"; } + if (address == 0xf2e9) { return "AS.HANDLERR"; } + if (address == 0xf318) { return "AS.RESUME"; } + if (address == 0xf32e) { return "AS.JSYN"; } + if (address == 0xf331) { return "AS.DEL"; } + if (address == 0xf390) { return "AS.GR"; } + if (address == 0xf399) { return "AS.TEXT"; } + if (address == 0xf39f) { return "AS.STORE"; } + if (address == 0xf3bc) { return "AS.RECALL"; } + if (address == 0xf3d8) { return "AS.HGR2"; } + if (address == 0xf3e2) { return "AS.HGR"; } + if (address == 0xf3ea) { return "AS.SETHPG"; } + if (address == 0xf3f2) { return "AS.HCLR"; } + if (address == 0xf3f6) { return "AS.BKGND"; } + if (address == 0xf411) { return "AS.HPOSN"; } + if (address == 0xf457) { return "AS.HPLOT0"; } + if (address == 0xf465) { return "AS.MOVE_LEFT_OR_RIGHT"; } + if (address == 0xf47e) { return "AS.COLOR_SHIFT"; } + if (address == 0xf48a) { return "AS.MOVE_RIGHT"; } + if (address == 0xf49c) { return "AS.LRUDX1"; } + if (address == 0xf49d) { return "AS.LRUDX2"; } + if (address == 0xf4b3) { return "AS.LRUD1"; } + if (address == 0xf4b4) { return "AS.LRUD2"; } + if (address == 0xf4c4) { return "AS.LRUD3"; } + if (address == 0xf4c8) { return "AS.LRUD4"; } + if (address == 0xf4d3) { return "AS.MOVE_UP_OR_DOWN"; } + if (address == 0xf505) { return "AS.MOVE_DOWN"; } + if (address == 0xf530) { return "AS.HLINRL"; } + if (address == 0xf53a) { return "AS.HGLN"; } + if (address == 0xf57c) { return "AS.MOVEX"; } + if (address == 0xf581) { return "AS.MOVEX2"; } + if (address == 0xf5cb) { return "AS.HFIND"; } + if (address == 0xf600) { return "AS.RTS22"; } + if (address == 0xf601) { return "AS.DRAW0"; } + if (address == 0xf605) { return "AS.DRAW1"; } + if (address == 0xf65d) { return "AS.XDRAW0"; } + if (address == 0xf661) { return "AS.XDRAW1"; } + if (address == 0xf6b9) { return "AS.HFNS"; } + if (address == 0xf6e6) { return "AS.GGERR"; } + if (address == 0xf6e9) { return "AS.HCOLOR"; } + if (address == 0xf6f5) { return "AS.RTS23"; } + if (address == 0xf6fc) { return "AS.COLORTBL"; } + if (address == 0xf6fe) { return "AS.HPLOT"; } + if (address == 0xf721) { return "AS.ROT"; } + if (address == 0xf727) { return "AS.SCALE"; } + if (address == 0xf72d) { return "AS.DRAWPNT"; } + if (address == 0xf769) { return "AS.DRAW"; } + if (address == 0xf76f) { return "AS.XDRAW"; } + if (address == 0xf775) { return "AS.SHLOAD"; } + if (address == 0xf7bc) { return "AS.TAPEPNT"; } + if (address == 0xf7d9) { return "AS.GETARYPT"; } + if (address == 0xf7e7) { return "AS.HTAB"; } + + if (address == 0xf800) { return "MON.PLOT"; } + if (address == 0xf80c) { return "MON.RTMASK"; } + if (address == 0xf80e) { return "MON.PLOT1"; } + if (address == 0xf819) { return "MON.HLINE"; } + if (address == 0xf828) { return "MON.VLINE"; } + if (address == 0xf831) { return "MON.RTS1"; } + if (address == 0xf832) { return "MON.CLRSCR"; } + if (address == 0xf836) { return "MON.CLRTOP"; } + if (address == 0xf838) { return "MON.CLRSC2"; } + if (address == 0xf83c) { return "MON.CLRSC3"; } + if (address == 0xf847) { return "MON.GBASCALC"; } + if (address == 0xf856) { return "MON.GBCALC"; } + if (address == 0xf85f) { return "MON.NXTCOL"; } + if (address == 0xf864) { return "MON.SETCOL"; } + if (address == 0xf871) { return "MON.SCRN"; } + if (address == 0xf879) { return "MON.SCRN2"; } + if (address == 0xf87f) { return "MON.RTMSKZ"; } + if (address == 0xf882) { return "MON.INDS1"; } + if (address == 0xf88c) { return "MON.INDS2"; } + if (address == 0xf89b) { return "MON.IEVEN"; } + if (address == 0xf8a5) { return "MON.ERR"; } + if (address == 0xf8a9) { return "MON.GETFMT"; } + if (address == 0xf8be) { return "MON.MNNDX1"; } + if (address == 0xf8c2) { return "MON.MNNDX2"; } + if (address == 0xf8c9) { return "MON.NBBDX3"; } + if (address == 0xf8d0) { return "MON.UBSDSP"; } + if (address == 0xf8d4) { return "MON.PRINTOP"; } + if (address == 0xf8db) { return "MON.PRNTBL"; } + if (address == 0xf8f5) { return "MON.PRMN1"; } + if (address == 0xf8f9) { return "MON.PRMN2"; } + if (address == 0xf910) { return "MON.PRADR1"; } + if (address == 0xf914) { return "MON.PRADR2"; } + if (address == 0xf926) { return "MON.PRADR3"; } + if (address == 0xf92a) { return "MON.PRADR4"; } + if (address == 0xf930) { return "MON.PRADR5"; } + if (address == 0xf938) { return "MON.RELADR"; } + if (address == 0xf940) { return "MON.PRNTYX"; } + if (address == 0xf941) { return "MON.PRNTAX"; } + if (address == 0xf944) { return "MON.PRNTX"; } + if (address == 0xf948) { return "MON.PRBLNK"; } + if (address == 0xf94a) { return "MON.PRBL2"; } + if (address == 0xf94c) { return "MON.PRBL3"; } + if (address == 0xf953) { return "MON.PCADJ"; } + if (address == 0xf954) { return "MON.PCADJ2"; } + if (address == 0xf956) { return "MON.PCADJ3"; } + if (address == 0xf95c) { return "MON.PCADJ4"; } + if (address == 0xf961) { return "MON.RTS2"; } + if (address == 0xf962) { return "MON.FMT1"; } + if (address == 0xf9a6) { return "MON.FMT2"; } + if (address == 0xf9b4) { return "MON.CHAR1"; } + if (address == 0xf9ba) { return "MON.CHAR2"; } + if (address == 0xf9c0) { return "MON.MNEML"; } + if (address == 0xfa00) { return "MON.MNEMR"; } + if (address == 0xfa40) { return "MON.IRQ"; } + if (address == 0xfa4c) { return "MON.BREAK"; } + if (address == 0xfa59) { return "MON.OLDBRK"; } + if (address == 0xfa62) { return "MON.RESET"; } + if (address == 0xfa6f) { return "MON.INITAN"; } + if (address == 0xfa81) { return "MON.NEWMON"; } + if (address == 0xfa9b) { return "MON.FIXSEV"; } + if (address == 0xfaa3) { return "MON.NOFIX"; } + if (address == 0xfaa6) { return "MON.PWRUP"; } + if (address == 0xfaa9) { return "MON.SETPG3"; } + if (address == 0xfaab) { return "MON.SETPLP"; } + if (address == 0xfaba) { return "MON.SLOOP"; } + if (address == 0xfac7) { return "MON.NXTBYT"; } + if (address == 0xfad7) { return "MON.REGDSP"; } + if (address == 0xfada) { return "MON.RGDPS1"; } + if (address == 0xfae4) { return "MON.RDSP1"; } + if (address == 0xfafd) { return "MON.PWRCON"; } + if (address == 0xfb02) { return "MON.DISKID"; } + if (address == 0xfb09) { return "MON.TITLE"; } + if (address == 0xfb11) { return "MON.XLTBL"; } + if (address == 0xfb19) { return "MON.RTBL"; } + if (address == 0xfb1e) { return "MON.PREAD"; } + if (address == 0xfb25) { return "MON.PREAD2"; } + if (address == 0xfb2e) { return "MON.RTS2D"; } + if (address == 0xfb2f) { return "MON.INIT"; } + if (address == 0xfb39) { return "MON.SETTXT"; } + if (address == 0xfb40) { return "MON.SETGR"; } + if (address == 0xfb4b) { return "MON.SETWND"; } + if (address == 0xfb5b) { return "MON.TABV"; } + if (address == 0xfb60) { return "MON.APPLEII"; } + if (address == 0xfb65) { return "MON.STITLE"; } + if (address == 0xfb6A) { return "MON.GETLN"; } + if (address == 0xfb6f) { return "MON.SETPWRC"; } + if (address == 0xfb78) { return "MON.VIDWAIT"; } + if (address == 0xfb88) { return "MON.KBDWAIT"; } + + if (address == 0xfbb3) { return "M80_F8VERSION"; } + + if (address == 0xfb94) { return "MON.NOWAIT"; } + if (address == 0xfb97) { return "MON.ESCOLD"; } + if (address == 0xfb9b) { return "MON.ESCNOW"; } + if (address == 0xfba5) { return "MON.ESCNEW"; } + if (address == 0xfbb3) { return "MON.VERSION"; } + if (address == 0xfbb4) { return "MON.GOTOCX"; } + if (address == 0xfbc1) { return "MON.BASCALC"; } + + if (address == 0xfbd0) { return "MON.BASCLC2"; } + if (address == 0xfbd9) { return "MON.BELL1"; } + if (address == 0xfbe4) { return "MON.BELL2"; } + if (address == 0xfbef) { return "MON.RTS2B"; } + if (address == 0xfbf0) { return "MON.STORADV"; } + if (address == 0xfbf4) { return "MON.ADVANCE"; } + if (address == 0xfbfc) { return "MON.RTS3"; } + if (address == 0xfbfd) { return "MON.VIDOUT"; } + if (address == 0xfc10) { return "MON.BS"; } + if (address == 0xfc1a) { return "MON.UP"; } + if (address == 0xfc22) { return "MON.VTAB"; } + if (address == 0xfc24) { return "MON.VTABZ"; } + if (address == 0xfc2b) { return "MON.RTS4"; } + if (address == 0xfc2c) { return "MON.ESC1"; } + if (address == 0xfc42) { return "MON.CLREOP"; } + if (address == 0xfc58) { return "MON.HOME"; } + if (address == 0xfc62) { return "MON.CR"; } + if (address == 0xfc66) { return "MON.LF"; } + if (address == 0xfc70) { return "MON.SCROLL"; } + if (address == 0xfc72) { return "MON.XGOTOCX"; } + + if (address == 0xfc75) { return "M80_SNIFFIRQ"; } + + if (address == 0xfc84) { return "MON.RDCX"; } + if (address == 0xfc91) { return "MON.ISSLOTS"; } + if (address == 0xfc99) { return "MON.ISPAGE1"; } + if (address == 0xfc9c) { return "MON.CLREOL"; } + if (address == 0xfc9e) { return "MON.CLREOLZ"; } + if (address == 0xfca8) { return "MON.WAIT"; } + if (address == 0xfca9) { return "MON.WAIT2"; } + if (address == 0xfcaa) { return "MON.WAIT3"; } + if (address == 0xfcb4) { return "MON.NXTA4"; } + if (address == 0xfcba) { return "MON.NXTA1"; } + if (address == 0xfcc8) { return "MON.RTS4B"; } + if (address == 0xfcc9) { return "MON.HEADR"; } + if (address == 0xfcd6) { return "MON.WRBIT"; } + if (address == 0xfcdb) { return "MON.ZERDLY"; } + if (address == 0xfce2) { return "MON.ONEDLY"; } + if (address == 0xfce5) { return "MON.WRTAPE"; } + if (address == 0xfcec) { return "MON.RDBYTE"; } + if (address == 0xfcee) { return "MON.RDBYT2"; } + if (address == 0xfcfa) { return "MON.READ2BIT"; } + if (address == 0xfcfd) { return "MON.RDBIT"; } + if (address == 0xfd0c) { return "MON.RDKEY"; } + + if (address == 0xfd18) { return "MON.KEYIN"; } + if (address == 0xfd21) { return "MON.RDESC"; } + + if (address == 0xfd29) { return "M80_FUNCEXIT"; } + + if (address == 0xfd2f) { return "MON.ESC"; } + if (address == 0xfd35) { return "MON.RDCHAR"; } + if (address == 0xfd3d) { return "MON.NOTCR"; } + if (address == 0xfd5f) { return "MON.NOTCR1"; } + if (address == 0xfd62) { return "MON.CANCEL"; } + if (address == 0xfd67) { return "MON.GETLNZ"; } + if (address == 0xfd6a) { return "MON.GETLN"; } + if (address == 0xfd71) { return "MON.BCKSPC"; } + if (address == 0xfd75) { return "MON.NXTCHAR"; } + if (address == 0xfd7e) { return "MON.CAPTST"; } + if (address == 0xfd84) { return "MON.ADDINP"; } + if (address == 0xfd8e) { return "MON.CROUT"; } + if (address == 0xfd92) { return "MON.PRA1"; } + if (address == 0xfd96) { return "MON.PRYX2"; } + if (address == 0xfda3) { return "MON.XAMB"; } + if (address == 0xfdad) { return "MON.MOD8CHK"; } + if (address == 0xfdb3) { return "MON.XAM"; } + if (address == 0xfdb6) { return "MON.DATAOUT"; } + if (address == 0xfdc5) { return "MON.RTS4C"; } + if (address == 0xfdc6) { return "MON.XAMPM"; } + if (address == 0xfdd1) { return "MON.ADD"; } + if (address == 0xfdda) { return "MON.PRBYTE"; } + if (address == 0xfde3) { return "MON.PRHEX"; } + if (address == 0xfde5) { return "MON.PRHEXZ"; } + if (address == 0xfded) { return "MON.COUT"; } + if (address == 0xfdf0) { return "MON.COUT1"; } + if (address == 0xfdf6) { return "MON.COUTZ"; } + if (address == 0xfe00) { return "MON.BLI"; } + if (address == 0xfe04) { return "MON.BLANK"; } + if (address == 0xfe0b) { return "MON.STOR"; } + if (address == 0xfe17) { return "MON.RTS5"; } + if (address == 0xfe18) { return "MON.SETMODE"; } + if (address == 0xfe1d) { return "MON.SETMDZ"; } + if (address == 0xfe20) { return "MON.LT"; } + if (address == 0xfe22) { return "MON.LT2"; } + if (address == 0xfe2c) { return "MON.MOVE"; } + if (address == 0xfe36) { return "MON.VFY"; } + if (address == 0xfe58) { return "MON.VFYOK"; } + if (address == 0xfe5e) { return "MON.LIST"; } + if (address == 0xfe63) { return "MON.LIST2"; } + if (address == 0xfe75) { return "MON.A1PC"; } + if (address == 0xfe78) { return "MON.A1PCLP"; } + if (address == 0xfe7f) { return "MON.A1PCRTS"; } + if (address == 0xfe80) { return "MON.SETINV"; } + if (address == 0xfe84) { return "MON.SETNORM"; } + if (address == 0xfe86) { return "MON.SETIFLG"; } + if (address == 0xfe89) { return "MON.SETKBD"; } + if (address == 0xfe8b) { return "MON.INPORT"; } + if (address == 0xfe8d) { return "MON.INPRT"; } + if (address == 0xfe93) { return "MON.SETVID"; } + if (address == 0xfe95) { return "MON.OUTPORT"; } + if (address == 0xfe97) { return "MON.OUTPRT"; } + if (address == 0xfe9b) { return "MON.IOPRT"; } + if (address == 0xfea7) { return "MON.IOPRT1"; } + if (address == 0xfea9) { return "MON.IOPRT2"; } + if (address == 0xfeaf) { return "MON.CKSUMFIX"; } + if (address == 0xfeb0) { return "MON.XBASIC"; } + if (address == 0xfeb3) { return "MON.BASCONT"; } + if (address == 0xfeb6) { return "MON.GO"; } + if (address == 0xfebf) { return "MON.REGZ"; } + if (address == 0xfec2) { return "MON.TRACE"; } + if (address == 0xfec4) { return "MON.STEPZ"; } + if (address == 0xfeca) { return "MON.USR"; } + if (address == 0xfecd) { return "MON.WRITE"; } + if (address == 0xfed4) { return "MON.WR1"; } + if (address == 0xfeed) { return "MON.WRBYTE"; } + if (address == 0xfeef) { return "MON.WRBYT2"; } + if (address == 0xfef6) { return "MON.CRMON"; } + if (address == 0xfefd) { return "MON.READ"; } + if (address == 0xff02) { return "MON.READ2"; } + if (address == 0xff0a) { return "MON.RD2"; } + if (address == 0xff16) { return "MON.RD3"; } + if (address == 0xff2d) { return "MON.PRERR"; } + if (address == 0xff3a) { return "MON.BELL"; } + if (address == 0xff3f) { return "MON.RESTORE"; } + if (address == 0xff44) { return "MON.RESTR1"; } + if (address == 0xff4a) { return "MON.SAVE"; } + if (address == 0xff4c) { return "MON.SAV1"; } + + if (address == 0xff58) { return "M80_IORTS"; } + + if (address == 0xff59) { return "MON.OLDRST"; } + if (address == 0xff65) { return "MON.MON"; } + if (address == 0xff69) { return "MON.MONZ"; } + if (address == 0xff73) { return "MON.NXTITM"; } + if (address == 0xff7a) { return "MON.CRSRCH"; } + if (address == 0xff8a) { return "MON.DIG"; } + if (address == 0xff90) { return "MON.NXTBIT"; } + if (address == 0xff98) { return "MON.NXTBAS"; } + if (address == 0xffa2) { return "MON.NXTBS2"; } + if (address == 0xffa7) { return "MON.GETNUM"; } + if (address == 0xffad) { return "MON.NXTCHR"; } + if (address == 0xffbe) { return "MON.TOSUB"; } + if (address == 0xffc7) { return "MON.ZMODE"; } + if (address == 0xffcc) { return "MON.CHRTBL"; } + if (address == 0xffe3) { return "MON.SUBTBL"; } + + return QString::Null(); +} + +bool DisassemblerViewer::optionsMenuItems(QMenu *menu) +{ + QSettings settings; + + if (!m_wordWrapAction) { + m_wordWrapAction = new QAction("&Word Wrap"); + m_wordWrapAction->setCheckable(true); + m_wordWrapAction->setChecked(settings.value("DisassemblerViewer.WordWrap",true).toBool()); + connect(m_wordWrapAction, &QAction::toggled, + this, &DisassemblerViewer::toggleWordWrap); + } + menu->addAction(m_wordWrapAction); + + menu->addSeparator(); + + if (!m_showMetadataAction) { + m_showMetadataAction = new QAction("&Dissassembler Metadata"); + connect(m_showMetadataAction, &QAction::triggered, + this, &DisassemblerViewer::showMetadataDialog); + } + menu->addAction(m_showMetadataAction); + + menu->addSeparator(); + + if (!m_setFontAction) { + m_setFontAction = new QAction("Set &Font..."); + } + menu->addAction(m_setFontAction); + + connect(m_setFontAction, &QAction::triggered, + this, [this] { + bool ok; + QFont font = QFontDialog::getFont(&ok, + ui->textArea->font(), + this, "Set Font", + QFontDialog::MonospacedFonts); + if (ok) { + setTextFont(font); + fontToSettings("DisassemblerViewer.textFont", font); + } + }); + + + return true; +} + +void DisassemblerViewer::showMetadataDialog() +{ + if (!m_dmd) { + m_dmd = new DisassemblerMetadataDialog(m_bfm, this); + } + m_dmd->show(); + m_dmd->raise(); +} + +void DisassemblerViewer::setData(QByteArray data) +{ + ui->textArea->setText(data); + ui->textArea->setJumpLines(&m_jumpLines); +} + + +bool DisassemblerViewer::canPrint() const { return true; } + +void DisassemblerViewer::doPrint() +{ + QPrinter printer; + + QPrintDialog dialog(&printer, this); + dialog.setWindowTitle(tr("Print Dissassembly")); + if (ui->textArea->textCursor().hasSelection()) + dialog.addEnabledOption(QAbstractPrintDialog::PrintSelection); + if (dialog.exec() != QDialog::Accepted) { + // qDebug() << "Cancelled"; + + return; + } + + ui->textArea->print(&printer); +} + +bool DisassemblerViewer::canExport() const { return true; } + +void DisassemblerViewer::doExport() +{ + QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); + QDir savename = QDir(defaultPath).filePath(m_file->filename()+".txt"); + + QString saveName = QFileDialog::getSaveFileName(this, + tr("Export Disassembly"), savename.path(), tr("Text Files (*.txt)")); + + if (saveName == "") return; // User cancelled + + // qDebug() << "Set filename: " << saveName; + + QFile saveFile(saveName); + if (!saveFile.open(QIODevice::WriteOnly | QIODevice::Text)) + { + QMessageBox::warning(this,"Save Error","Could not save "+saveName); + return; + } + + QTextStream out(&saveFile); + out << ui->textArea->document()->toPlainText(); + saveFile.close(); +} + +QString DisassemblerViewer::makeDescriptorStringForVal(quint8 val) +{ + QString retval; + + // QString zone; + // if (val <= 0x3f) zone = "Inverse"; + // else if (val <= 0x7f) zone = "Flash"; + // else if (val <= 0x9f) zone = "(Alt) Normal"; + // else zone = "Normal"; + + // quint8 baseascii = val; + // if (val <= 0x1f) baseascii += 0x40; + // else if (val <= 0x5f) baseascii += 0; + // else if (val <= 0xbf) baseascii -= 0x40; + // else baseascii -= 80; + + // QString ch = QChar(baseascii); + // if (val == 0xff) ch = "[DEL]"; + + // QString appleAscii = QString("%1 %2").arg(ch).arg(zone); + + // if (val < 0x20) + // { + // QString ctrl = QString(" / (^%1)").arg(QChar(val+0x40)); + // appleAscii.append(ctrl); + // } + + // return QString("; %1 / %2").arg(val).arg(appleAscii); + retval = QString("; %1").arg(val); + return retval; +} diff --git a/src/ui/viewers/disassemblerviewer.h b/src/ui/viewers/disassemblerviewer.h index 3422433..729f80d 100644 --- a/src/ui/viewers/disassemblerviewer.h +++ b/src/ui/viewers/disassemblerviewer.h @@ -1,69 +1,72 @@ -#ifndef DISASSEMBLERVIEWER_H -#define DISASSEMBLERVIEWER_H - -#include -#include - -#include "memory.h" -#include "binaryfile.h" -#include "relocatablefile.h" -#include "fileviewerinterface.h" -#include "DisassemblerMetadataDialog.h" -#include "JumpLineManager.h" - -namespace Ui { -class DisassemblerViewer; -} - -class DisassemblerViewer : public FileViewerInterface -{ - Q_OBJECT - -public: - explicit DisassemblerViewer(QWidget *parent = 0); - ~DisassemblerViewer(); - - void setFile(BinaryFile *file); - void setFile(RelocatableFile *file); - void setData(QByteArray data); - - QString getPotentialLabel(quint16 address); - virtual bool optionsMenuItems(QMenu *); - - bool canPrint() const; - bool canExport() const; - - QString makeDescriptorStringForVal(quint8 val); - - void disassemble(QList entryPoints); - QStringList getDisassemblyStrings(); - -public slots: - void setFile(GenericFile *file); - void toggleWordWrap(bool enabled); - - void doPrint(); - void doExport(); - void handleDisassembleRequest(QList addresses); -protected slots: - void showMetadataDialog(); -private: - Ui::DisassemblerViewer *ui; - - DisassemblerMetadataDialog *m_dmd; - GenericFile *m_file; - - QAction *m_wordWrapAction; - QAction *m_showMetadataAction; - - BinaryFileMetadata *m_bfm; - - Memory m_mem; - - bool m_isRelo; - - QStringList m_disassemblyStrings; - JumpLines m_jumpLines; -}; - -#endif // DISASSEMBLERVIEWER_H +#ifndef DISASSEMBLERVIEWER_H +#define DISASSEMBLERVIEWER_H + +#include +#include + +#include "memory.h" +#include "binaryfile.h" +#include "relocatablefile.h" +#include "fileviewerinterface.h" +#include "DisassemblerMetadataDialog.h" +#include "JumpLineManager.h" + +namespace Ui { +class DisassemblerViewer; +} + +class DisassemblerViewer : public FileViewerInterface +{ + Q_OBJECT + +public: + explicit DisassemblerViewer(QWidget *parent = 0); + ~DisassemblerViewer(); + + void setFile(BinaryFile *file); + void setFile(RelocatableFile *file); + void setData(QByteArray data); + + QString getPotentialLabel(quint16 address); + virtual bool optionsMenuItems(QMenu *); + + bool canPrint() const; + bool canExport() const; + + QString makeDescriptorStringForVal(quint8 val); + + void disassemble(QList entryPoints); + QStringList getDisassemblyStrings(); + +public slots: + void setFile(GenericFile *file); + void toggleWordWrap(bool enabled); + + void doPrint(); + void doExport(); + void handleDisassembleRequest(QList addresses); +protected: + void setTextFont(const QFont &font); +protected slots: + void showMetadataDialog(); +private: + Ui::DisassemblerViewer *ui; + + DisassemblerMetadataDialog *m_dmd; + GenericFile *m_file; + + QAction *m_wordWrapAction; + QAction *m_showMetadataAction; + QAction *m_setFontAction; + + BinaryFileMetadata *m_bfm; + + Memory m_mem; + + bool m_isRelo; + + QStringList m_disassemblyStrings; + JumpLines m_jumpLines; +}; + +#endif // DISASSEMBLERVIEWER_H diff --git a/src/ui/viewers/disassemblerviewer.ui b/src/ui/viewers/disassemblerviewer.ui index 10e08ab..5eb869a 100644 --- a/src/ui/viewers/disassemblerviewer.ui +++ b/src/ui/viewers/disassemblerviewer.ui @@ -1,47 +1,41 @@ - - - DisassemblerViewer - - - - 0 - 0 - 146 - 129 - - - - Form - - - - - - - Courier - 12 - - - - false - - - - - - - - FileViewerInterface - QWidget -
viewerbase.h
- 1 -
- - FlowLineTextBrowser - QTextBrowser -
FlowLineTextBrowser.h
-
-
- - -
+ + + DisassemblerViewer + + + + 0 + 0 + 146 + 129 + + + + Form + + + + + + false + + + + + + + + FileViewerInterface + QWidget +
viewerbase.h
+ 1 +
+ + FlowLineTextBrowser + QTextBrowser +
FlowLineTextBrowser.h
+
+
+ + +
diff --git a/src/ui/viewers/fileviewerinterface.h b/src/ui/viewers/fileviewerinterface.h index b3461fa..3bc4cba 100644 --- a/src/ui/viewers/fileviewerinterface.h +++ b/src/ui/viewers/fileviewerinterface.h @@ -1,41 +1,41 @@ -#ifndef FILEVIEWERINTERFACE_H -#define FILEVIEWERINTERFACE_H - -#include -#include -#include -#include -#include -#include -#include - -class GenericFile; -class QMenu; - -class FileViewerInterface : public QWidget -{ - Q_OBJECT - -public: - FileViewerInterface(QWidget *parent = Q_NULLPTR) : QWidget(parent) { } - - virtual bool optionsMenuItems(QMenu *) = 0; - - virtual bool canPrint() const { return false; } - virtual bool canExport() const { return false; } - - QString title() const { return m_title; } - -public slots: - virtual void setFile(GenericFile *file) = 0; - - virtual void doPrint() { } - virtual void doExport() { } - -signals: - -protected: - QString m_title; -}; - -#endif // FILEVIEWERINTERFACE_H +#ifndef FILEVIEWERINTERFACE_H +#define FILEVIEWERINTERFACE_H + +#include +#include +#include +#include +#include +#include +#include + +class GenericFile; +class QMenu; + +class FileViewerInterface : public QWidget +{ + Q_OBJECT + +public: + FileViewerInterface(QWidget *parent = Q_NULLPTR) : QWidget(parent) { setFont(QFont("courier")); } + + virtual bool optionsMenuItems(QMenu *) = 0; + + virtual bool canPrint() const { return false; } + virtual bool canExport() const { return false; } + + QString title() const { return m_title; } + +public slots: + virtual void setFile(GenericFile *file) = 0; + + virtual void doPrint() { } + virtual void doExport() { } + +signals: + +protected: + QString m_title; +}; + +#endif // FILEVIEWERINTERFACE_H diff --git a/src/ui/viewers/hexdumpviewer.cpp b/src/ui/viewers/hexdumpviewer.cpp index 21c44fb..3316d57 100644 --- a/src/ui/viewers/hexdumpviewer.cpp +++ b/src/ui/viewers/hexdumpviewer.cpp @@ -1,206 +1,244 @@ -#include "hexdumpviewer.h" -#include "ui_hexdumpviewer.h" - -#include -#include -#include -#include -#include - -HexDumpViewer::HexDumpViewer(QWidget *parent) : - FileViewerInterface(parent), - ui(new Ui::HexDumpViewer) -{ - m_file = Q_NULLPTR; - ui->setupUi(this); - m_offset = 0; - - QString title = QString("Hex Viewer"); - setWindowTitle(title); - - QSettings settings; - toggleWordWrap(settings.value("HexViewer.WordWrap",true).toBool()); -} - -HexDumpViewer::~HexDumpViewer() -{ - delete ui; -} - -void HexDumpViewer::toggleWordWrap(bool enabled) -{ - if (enabled) - { - ui->textArea->setWordWrapMode(QTextOption::WordWrap); - } - else - { - ui->textArea->setWordWrapMode(QTextOption::NoWrap); - } - QSettings settings; - settings.setValue("HexViewer.WordWrap",enabled); -} - - - -void HexDumpViewer::showHexAndAsciiValues() -{ - int offset = ui->textArea->verticalScrollBar()->value(); - - QStringList lines; - - //TODO: Align text from x00 to xFF. Currently it will start with whatever the offset is. - - quint16 addr = m_offset; - for (int idx = 0; idx <= m_data.count()/16; idx++) { - QString line = QString("(%1) %2: ") - .arg(m_offset+(idx*16),4,10,QChar('0')) - .arg(m_offset+(idx*16),4,16,QChar('0')); - QString asciiline; - - for (int jdx = (idx*16); jdx < (idx*16)+16; jdx++) { - addr++; - if (jdx < m_data.count()) { - asciiline += valToAppleAscii(m_data[jdx]); - - line += QString(" %1").arg((quint8) m_data[jdx],2,16,QChar('0')); - } - } - - if (line.length() > 14) { - int diff = (62 - line.length()); - if (diff < 0) { diff = 0; } - if (diff>0) { - for (int pdx = 0; pdx < diff; pdx++) - { - line.append(" "); - } - } - lines.append(line + "  " + asciiline); - } - } - setText(qPrintable(lines.join("
").toUpper())); - ui->textArea->verticalScrollBar()->setValue(offset); -} - -QString HexDumpViewer::valToAppleAscii(quint8 val) -{ - - typedef enum { - Inverse, - Flash, - Normal, - AltUC - } Zone; - - Zone zone; - - QString charval; - if (val <= 0x1F) { val += 0x40; charval = QString("%1").arg(QChar(val)); zone = Inverse; } //INV UC - else if (val <= 0x3F) { val = val; charval = QString("%1").arg(QChar(val)); zone = Inverse; } // INV SP - else if (val <= 0x5F) { val = val; charval = QString("%1").arg(QChar(val)); zone = Flash; } // FL UC - else if (val <= 0x7F) { val -= 0x40; charval = QString("%1").arg(QChar(val)); zone = Flash; } // FL SP - else if (val <= 0x9F) { val -= 0x40; charval = QString("%1").arg(QChar(val)); zone = AltUC; } // NORMx UC - else if (val <= 0xBF) { val -= 0x40; charval = QString("%1").arg(QChar(val)); zone = Normal; } // NORM SP - else if (val <= 0xDF) { val -= 0x80; charval = QString("%1").arg(QChar(val)); zone = Normal; } // NORM UC - else if (val < 0xFF) { val -= 0x80; charval = QString("%1").arg(QChar(val)); zone = Normal; } // NORM LC - else if (val == 0xFF) { val = val; charval = QString("\u25a0"); zone = Normal; } - - QString htmlstr = charval.toHtmlEscaped(); - - QString retval; - if (zone == Inverse) { retval = QString("%1").arg(htmlstr); } - else if (zone == Flash) { retval = QString("%1").arg(htmlstr);} - else if (zone == AltUC) { retval = QString("%1").arg(htmlstr);} - else /* zone == Normal */ { retval = QString("%1").arg(htmlstr);} - - return retval; -} - -void HexDumpViewer::setFile(GenericFile *file, quint16 offset) -{ - m_file = file; - QString title = QString("Hex Viewer: %1").arg(file->filename()); - setWindowTitle(title); - - m_offset = offset; - - m_data = file->data(); - - showHexAndAsciiValues(); -} - -void HexDumpViewer::setRawData(QByteArray data, quint16 offset) -{ - m_offset = offset; - m_data = data; - showHexAndAsciiValues(); -} - -bool HexDumpViewer::optionsMenuItems(QMenu *menu) -{ - QSettings settings; - - QAction *action = new QAction("&Word Wrap"); - action->setCheckable(true); - action->setChecked(settings.value("HexViewer.WordWrap",true).toBool()); - connect(action, &QAction::toggled, - this, &HexDumpViewer::toggleWordWrap); - menu->addAction(action); - - return true; -} - -void HexDumpViewer::setData(QByteArray data) -{ - ui->textArea->setHtml(data); -} - -void HexDumpViewer::setText(QString text) -{ - ui->textArea->setHtml(text); -} - -bool HexDumpViewer::canPrint() const { return true; } - -void HexDumpViewer::doPrint() -{ - QPrinter printer; - - QPrintDialog dialog(&printer, this); - dialog.setWindowTitle(tr("Print Hex Dump")); - if (ui->textArea->textCursor().hasSelection()) - dialog.addEnabledOption(QAbstractPrintDialog::PrintSelection); - if (dialog.exec() != QDialog::Accepted) { - return; - } - - ui->textArea->print(&printer); -} - - -bool HexDumpViewer::canExport() const { return true; } - -void HexDumpViewer::doExport() -{ - QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); - QDir savename = QDir(defaultPath).filePath(m_file->filename()+".txt"); - - QString saveName = QFileDialog::getSaveFileName(this, - tr("Export Hex Dump"), savename.path(), tr("Text Files (*.txt)")); - - if (saveName == "") return; // User cancelled - - qDebug() << "Set filename: " << saveName; - - QFile saveFile(saveName); - if (!saveFile.open(QIODevice::WriteOnly | QIODevice::Text)) - { - QMessageBox::warning(this,"Save Error","Could not save "+saveName); - return; - } - - QTextStream out(&saveFile); - out << ui->textArea->document()->toPlainText(); - saveFile.close(); -} +#include "hexdumpviewer.h" +#include "ui_hexdumpviewer.h" +#include "util.h" +#include +#include +#include +#include +#include +#include +#include "applestring.h" +#include + +HexDumpViewer::HexDumpViewer(QWidget *parent) : + FileViewerInterface(parent), + ui(new Ui::HexDumpViewer) +{ + QFont textAreaFont; + textAreaFont.setStyleHint(QFont::Monospace); + + + m_file = Q_NULLPTR; + ui->setupUi(this); + + setTextFont(fontFromSettings("HexDumpViewer.textFont", textAreaFont)); + m_offset = 0; + + + + QString title = QString("Hex Viewer"); + setWindowTitle(title); + + QSettings settings; + toggleWordWrap(settings.value("HexViewer.WordWrap",true).toBool()); +} + +HexDumpViewer::~HexDumpViewer() +{ + delete ui; +} + +void HexDumpViewer::toggleWordWrap(bool enabled) +{ + if (enabled) + { + ui->textArea->setWordWrapMode(QTextOption::WordWrap); + } + else + { + ui->textArea->setWordWrapMode(QTextOption::NoWrap); + } + QSettings settings; + settings.setValue("HexViewer.WordWrap",enabled); +} + + + +void HexDumpViewer::showHexAndAsciiValues() +{ + int offset = ui->textArea->verticalScrollBar()->value(); + + QStringList lines; + + //TODO: Align text from x00 to xFF. Currently it will start with whatever the offset is. + + quint16 addr = m_offset; + for (int idx = 0; idx <= m_data.count()/16; idx++) { + QString line = QString("(%1) %2: ") + .arg(m_offset+(idx*16),4,10,QChar('0')) + .arg(m_offset+(idx*16),4,16,QChar('0')); + QString asciiline; + + for (int jdx = (idx*16); jdx < (idx*16)+16; jdx++) { + addr++; + if (jdx < m_data.count()) { + asciiline += valToAppleAscii(m_data[jdx]); + + line += QString(" %1").arg((quint8) m_data[jdx],2,16,QChar('0')); + } + } + + if (line.length() > 14) { + int diff = (62 - line.length()); + if (diff < 0) { diff = 0; } + if (diff>0) { + for (int pdx = 0; pdx < diff; pdx++) + { + line.append(" "); + } + } + lines.append(line + "  " + asciiline); + } + } + setText(qPrintable(lines.join("
").toUpper())); + ui->textArea->verticalScrollBar()->setValue(offset); +} + +QString HexDumpViewer::valToAppleAscii(quint8 val) +{ + +// typedef enum { +// Inverse, +// Flash, +// Normal, +// AltUC +// } Zone; + + TextAttribute attribute = AppleChar::getAttribute(val); + QString charval = AppleChar::printable(val); + if (val == 0xff) { charval = "?"; } // QChar(0x25a0); } + +// if (val <= 0x1F) { val += 0x40; charval = QString("%1").arg(QChar(val)); zone = Inverse; } //INV UC +// else if (val <= 0x3F) { charval = QString("%1").arg(QChar(val)); zone = Inverse; } // INV SP +// else if (val <= 0x5F) { charval = QString("%1").arg(QChar(val)); zone = Flash; } // FL UC +// else if (val <= 0x7F) { val -= 0x40; charval = QString("%1").arg(QChar(val)); zone = Flash; } // FL SP +// else if (val <= 0x9F) { val -= 0x40; charval = QString("%1").arg(QChar(val)); zone = AltUC; } // NORMx UC +// else if (val <= 0xBF) { val -= 0x80; charval = QString("%1").arg(QChar(val)); zone = Normal; } // NORM SP +// else if (val <= 0xDF) { val -= 0x80; charval = QString("%1").arg(QChar(val)); zone = Normal; } // NORM UC +// else if (val < 0xFF) { val -= 0x80; charval = QString("%1").arg(QChar(val)); zone = Normal; } // NORM LC +// else /* (val == 0xFF)*/ { charval = QString("\u25a0"); zone = Normal; } + + QString htmlstr = charval.toHtmlEscaped(); + + QString retval; + if (attribute == Inverse) { retval = QString("%1").arg(htmlstr); } + else if (attribute == Flash) { retval = QString("%1").arg(htmlstr);} + else if (attribute == NormalLow) { retval = QString("%1").arg(htmlstr);} + else { retval = QString("%1").arg(htmlstr);} + + return retval; +} + +void HexDumpViewer::setFile(GenericFile *file, quint16 offset) +{ + m_file = file; + QString title = QString("Hex Viewer: %1").arg(file->filename()); + setWindowTitle(title); + + m_offset = offset; + + m_data = file->data(); + + showHexAndAsciiValues(); +} + +void HexDumpViewer::setRawData(QByteArray data, quint16 offset) +{ + m_offset = offset; + m_data = data; + showHexAndAsciiValues(); +} + +bool HexDumpViewer::optionsMenuItems(QMenu *menu) +{ + QSettings settings; + + QAction *action = new QAction("&Word Wrap"); + action->setCheckable(true); + action->setChecked(settings.value("HexViewer.WordWrap",true).toBool()); + connect(action, &QAction::toggled, + this, &HexDumpViewer::toggleWordWrap); + menu->addAction(action); + + menu->addSeparator(); + + if (m_setFontAction) { + m_setFontAction = new QAction("Set &Font..."); + } + menu->addAction(m_setFontAction); + + connect(m_setFontAction, &QAction::triggered, + this, [this] { + bool ok; + QFont font = QFontDialog::getFont(&ok, + ui->textArea->font(), + this, "Set Font", + QFontDialog::MonospacedFonts); + if (ok) { + setTextFont(font); + fontToSettings("HexDumpViewer.textFont", font); + } + + }); + + return true; +} + +void HexDumpViewer::setTextFont(const QFont &font) +{ + ui->textArea->setFont(font); +} + +void HexDumpViewer::setData(QByteArray data) +{ + ui->textArea->setHtml(data); +} + +void HexDumpViewer::setText(QString text) +{ + ui->textArea->setHtml(text); +} + +bool HexDumpViewer::canPrint() const { return true; } + +void HexDumpViewer::doPrint() +{ + QPrinter printer; + + QPrintDialog dialog(&printer, this); + dialog.setWindowTitle(tr("Print Hex Dump")); + if (ui->textArea->textCursor().hasSelection()) + dialog.addEnabledOption(QAbstractPrintDialog::PrintSelection); + if (dialog.exec() != QDialog::Accepted) { + return; + } + + ui->textArea->print(&printer); +} + + +bool HexDumpViewer::canExport() const { return true; } + +void HexDumpViewer::doExport() +{ + QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); + QDir savename = QDir(defaultPath).filePath(m_file->filename()+".txt"); + + QString saveName = QFileDialog::getSaveFileName(this, + tr("Export Hex Dump"), savename.path(), tr("Text Files (*.txt)")); + + if (saveName == "") return; // User cancelled + + qDebug() << "Set filename: " << saveName; + + QFile saveFile(saveName); + if (!saveFile.open(QIODevice::WriteOnly | QIODevice::Text)) + { + QMessageBox::warning(this,"Save Error","Could not save "+saveName); + return; + } + + QTextStream out(&saveFile); + out << ui->textArea->document()->toPlainText(); + saveFile.close(); +} diff --git a/src/ui/viewers/hexdumpviewer.h b/src/ui/viewers/hexdumpviewer.h index 17a6ab5..7553012 100644 --- a/src/ui/viewers/hexdumpviewer.h +++ b/src/ui/viewers/hexdumpviewer.h @@ -1,51 +1,55 @@ -#ifndef HEXDUMPVIEWER_H -#define HEXDUMPVIEWER_H - -#include "genericfile.h" -#include "fileviewerinterface.h" - -#include -#include -#include - - -namespace Ui { -class HexDumpViewer; -} - -class HexDumpViewer : public FileViewerInterface -{ - Q_OBJECT - -public: - explicit HexDumpViewer(QWidget *parent = 0); - ~HexDumpViewer(); - - void setFile(GenericFile *file) { setFile(file,0); } - void setFile(GenericFile *file, quint16 offset); - void setRawData(QByteArray data, quint16 offset = 0); - virtual bool optionsMenuItems(QMenu *menu); - - bool canPrint() const; - bool canExport() const; - -public slots: - void showHexAndAsciiValues(); - void toggleWordWrap(bool enabled); - void doPrint(); - void doExport(); - -private: - void setText(QString text); - void setData(QByteArray data); - QString valToAppleAscii(quint8 val); - - Ui::HexDumpViewer *ui; - - quint16 m_offset; - QByteArray m_data; - - GenericFile *m_file; -}; - -#endif // HEXDUMPVIEWER_H +#ifndef HEXDUMPVIEWER_H +#define HEXDUMPVIEWER_H + +#include "genericfile.h" +#include "fileviewerinterface.h" + +#include +#include +#include + + +namespace Ui { +class HexDumpViewer; +} + +class HexDumpViewer : public FileViewerInterface +{ + Q_OBJECT + +public: + explicit HexDumpViewer(QWidget *parent = 0); + ~HexDumpViewer(); + + void setFile(GenericFile *file) { setFile(file,0); } + void setFile(GenericFile *file, quint16 offset); + void setRawData(QByteArray data, quint16 offset = 0); + virtual bool optionsMenuItems(QMenu *menu); + + bool canPrint() const; + bool canExport() const; + +public slots: + void showHexAndAsciiValues(); + void toggleWordWrap(bool enabled); + void doPrint(); + void doExport(); + +protected: + void setTextFont(const QFont &font); +private: + void setText(QString text); + void setData(QByteArray data); + QString valToAppleAscii(quint8 val); + + QAction *m_setFontAction; + + Ui::HexDumpViewer *ui; + + quint16 m_offset; + QByteArray m_data; + + GenericFile *m_file; +}; + +#endif // HEXDUMPVIEWER_H diff --git a/src/ui/viewers/hexdumpviewer.ui b/src/ui/viewers/hexdumpviewer.ui index a054537..ef07048 100644 --- a/src/ui/viewers/hexdumpviewer.ui +++ b/src/ui/viewers/hexdumpviewer.ui @@ -1,48 +1,41 @@ - - - HexDumpViewer - - - - 0 - 0 - 538 - 483 - - - - Form - - - - 8 - - - 8 - - - 1 - - - - - - Courier 10 Pitch - 10 - - - - - - - - - FileViewerInterface - QWidget -
viewerbase.h
- 1 -
-
- - -
+ + + HexDumpViewer + + + + 0 + 0 + 538 + 483 + + + + Form + + + + 8 + + + 8 + + + 1 + + + + + + + + + FileViewerInterface + QWidget +
viewerbase.h
+ 1 +
+
+ + +
diff --git a/src/ui/viewers/hiresviewwidget.cxx b/src/ui/viewers/hiresviewwidget.cxx index f036447..2aaf8bd 100644 --- a/src/ui/viewers/hiresviewwidget.cxx +++ b/src/ui/viewers/hiresviewwidget.cxx @@ -1,122 +1,122 @@ -#include "hiresviewwidget.h" -#include "binaryfile.h" -#include "util.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - - -HiresViewWidget::HiresViewWidget(QWidget *parent) : - FileViewerInterface(parent) -{ - QGridLayout *gv = new QGridLayout(this); - setLayout(gv); - hrsw = new HiresScreenWidget(this); - gv->addWidget(hrsw); - m_offsetLabel = new QLabel(this); - m_offsetLabel->setText(""); - gv->addWidget(m_offsetLabel,1,0); - gv->setRowStretch(0,10000); - gv->setRowStretch(1,1); - - connect(hrsw, &HiresScreenWidget::newOffset, - this, &HiresViewWidget::handleNewOffset); - handleNewOffset(0); - - resize(561,384); -} - -void HiresViewWidget::setFile(BinaryFile *file) { - m_file = file; - - QString title = QString("Image: %1").arg(m_file->filename()); - setWindowTitle(title); - - hrsw->setData(file->data()); -} - -bool HiresViewWidget::optionsMenuItems(QMenu *menu) -{ - menu->addAction(hrsw->monochromeAction()); - menu->addAction(hrsw->ntscAction()); - menu->addAction(hrsw->perPixelColorAction()); - menu->addSeparator(); - menu->addAction(hrsw->showScanLinesAction()); - menu->addSeparator(); - menu->addAction(hrsw->prevPageAction()); - menu->addAction(hrsw->nextPageAction()); - - return true; -} - -void HiresViewWidget::setFile(GenericFile *file) -{ - BinaryFile *af = dynamic_cast(file); - if (af) - { - setFile(af); - } -} - -bool HiresViewWidget::canPrint() const { return true; } - -void HiresViewWidget::doPrint() -{ - QPrinter printer; - - QPrintDialog dialog(&printer, this); - - dialog.setWindowTitle(tr("Print HiRes Image")); - - if (dialog.exec() != QDialog::Accepted) { return; } - - QPainter painter(&printer); - QPixmap pm = hrsw->getPixmap(); - if (!pm.isNull() && pm.width() != 0 && pm.height() != 0) - { - painter.drawPixmap(0,0,pm.width(),pm.height(),pm); - } - else - { - QMessageBox::warning(this,"Print Error","Could not print image"); - } -} - -bool HiresViewWidget::canExport() const { return true; } - -void HiresViewWidget::doExport() -{ - QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); - QDir savename = QDir(defaultPath).filePath(m_file->filename()+".png"); - - QString saveName = QFileDialog::getSaveFileName(this, - tr("Export HiRes Image"), savename.path(), tr("Png Files (*.png)")); - - if (saveName == "") return; // User cancelled - - qDebug() << "Set filename: " << saveName; - - QFile saveFile(saveName); - if (!saveFile.open(QIODevice::WriteOnly | QIODevice::Text)) - { - QMessageBox::warning(this,"Save Error","Could not save "+saveName); - return; - } - - QPixmap pm = hrsw->getPixmap(); - pm.save(savename.path()); -} - -void HiresViewWidget::handleNewOffset(quint16 offset) -{ - QString text = QString("Offset: %1 (0x%2)").arg(offset).arg(uint16ToHex(offset)); - m_offsetLabel->setText(text); -} - +#include "hiresviewwidget.h" +#include "binaryfile.h" +#include "util.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + + +HiresViewWidget::HiresViewWidget(QWidget *parent) : + FileViewerInterface(parent) +{ + QGridLayout *gv = new QGridLayout(this); + setLayout(gv); + hrsw = new HiresScreenWidget(this); + gv->addWidget(hrsw); + m_offsetLabel = new QLabel(this); + m_offsetLabel->setText(""); + gv->addWidget(m_offsetLabel,1,0); + gv->setRowStretch(0,10000); + gv->setRowStretch(1,1); + + connect(hrsw, &HiresScreenWidget::newOffset, + this, &HiresViewWidget::handleNewOffset); + handleNewOffset(0); + + resize(561,384); +} + +void HiresViewWidget::setFile(BinaryFile *file) { + m_file = file; + + QString title = QString("Image: %1").arg(m_file->filename()); + setWindowTitle(title); + + hrsw->setData(file->data()); +} + +bool HiresViewWidget::optionsMenuItems(QMenu *menu) +{ + menu->addAction(hrsw->monochromeAction()); + menu->addAction(hrsw->ntscAction()); + menu->addAction(hrsw->perPixelColorAction()); + menu->addSeparator(); + menu->addAction(hrsw->showScanLinesAction()); + menu->addSeparator(); + menu->addAction(hrsw->prevPageAction()); + menu->addAction(hrsw->nextPageAction()); + + return true; +} + +void HiresViewWidget::setFile(GenericFile *file) +{ + BinaryFile *af = dynamic_cast(file); + if (af) + { + setFile(af); + } +} + +bool HiresViewWidget::canPrint() const { return true; } + +void HiresViewWidget::doPrint() +{ + QPrinter printer; + + QPrintDialog dialog(&printer, this); + + dialog.setWindowTitle(tr("Print HiRes Image")); + + if (dialog.exec() != QDialog::Accepted) { return; } + + QPainter painter(&printer); + QPixmap pm = hrsw->getPixmap(); + if (!pm.isNull() && pm.width() != 0 && pm.height() != 0) + { + painter.drawPixmap(0,0,pm.width(),pm.height(),pm); + } + else + { + QMessageBox::warning(this,"Print Error","Could not print image"); + } +} + +bool HiresViewWidget::canExport() const { return true; } + +void HiresViewWidget::doExport() +{ + QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); + QDir savename = QDir(defaultPath).filePath(m_file->filename()+".png"); + + QString saveName = QFileDialog::getSaveFileName(this, + tr("Export HiRes Image"), savename.path(), tr("Png Files (*.png)")); + + if (saveName == "") return; // User cancelled + + qDebug() << "Set filename: " << saveName; + + QFile saveFile(saveName); + if (!saveFile.open(QIODevice::WriteOnly | QIODevice::Text)) + { + QMessageBox::warning(this,"Save Error","Could not save "+saveName); + return; + } + + QPixmap pm = hrsw->getPixmap(); + pm.save(savename.path()); +} + +void HiresViewWidget::handleNewOffset(quint16 offset) +{ + QString text = QString("Offset: %1 (0x%2)").arg(offset).arg(uint16ToHex(offset)); + m_offsetLabel->setText(text); +} + diff --git a/src/ui/viewers/hiresviewwidget.h b/src/ui/viewers/hiresviewwidget.h index ffa1dba..0b9a921 100644 --- a/src/ui/viewers/hiresviewwidget.h +++ b/src/ui/viewers/hiresviewwidget.h @@ -1,47 +1,47 @@ -#ifndef HIRESVIEWWIDGET_H -#define HIRESVIEWWIDGET_H - -#include "binaryfile.h" -#include "fileviewerinterface.h" -#include "HiresScreenWidget.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -class HiresViewWidget : public FileViewerInterface -{ - Q_OBJECT -public: - - explicit HiresViewWidget(QWidget *parent = 0); - virtual bool optionsMenuItems(QMenu *); - - bool canPrint() const; - bool canExport() const; - -public slots: - void setFile(GenericFile *file); - void setFile(BinaryFile *file); - - void doPrint(); - void doExport(); - - void handleNewOffset(quint16 offset); - -private: - HiresScreenWidget *hrsw; - QLabel *m_offsetLabel; - - BinaryFile *m_file; -}; - - -#endif // HIRESVIEWWIDGET_H +#ifndef HIRESVIEWWIDGET_H +#define HIRESVIEWWIDGET_H + +#include "binaryfile.h" +#include "fileviewerinterface.h" +#include "HiresScreenWidget.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +class HiresViewWidget : public FileViewerInterface +{ + Q_OBJECT +public: + + explicit HiresViewWidget(QWidget *parent = 0); + virtual bool optionsMenuItems(QMenu *); + + bool canPrint() const; + bool canExport() const; + +public slots: + void setFile(GenericFile *file); + void setFile(BinaryFile *file); + + void doPrint(); + void doExport(); + + void handleNewOffset(quint16 offset); + +private: + HiresScreenWidget *hrsw; + QLabel *m_offsetLabel; + + BinaryFile *m_file; +}; + + +#endif // HIRESVIEWWIDGET_H diff --git a/src/ui/viewers/mazeviewer.cpp b/src/ui/viewers/mazeviewer.cpp index dee4fa9..6d36508 100644 --- a/src/ui/viewers/mazeviewer.cpp +++ b/src/ui/viewers/mazeviewer.cpp @@ -1,435 +1,435 @@ -#include "mazeviewer.h" -#include -#include -#include - -#include "memory.h" - -MazeViewer::MazeViewer(QWidget *parent) : FileViewerInterface(parent) -{ - //setMinimumSize(480,600); - m_maze = QPixmap(width(),height()); - drawMaze(); -} - -void MazeViewer::resizeEvent(QResizeEvent *event) -{ - QWidget::resizeEvent(event); - m_maze = QPixmap(event->size().width(), - event->size().height()); - drawMaze(); -} - -void MazeViewer::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - drawMaze(); - QPainter painter(this); - painter.drawPixmap(0, 0, m_maze); -} - -void MazeViewer::setFile(GenericFile *file) -{ - if (dynamic_cast(file)) - { - setFile(dynamic_cast(file)); - } -} - -void MazeViewer::setFile(BinaryFile *file) -{ - m_file = file; - - QString title = QString("Maze Viewer: %1").arg(m_file->filename()); - setWindowTitle(title); - - quint16 address = file->address(); - mem.addFile(file->data(), address); -} - - -void MazeViewer::drawMaze() -{ - QPainter painter(&m_maze); - - painter.setBrush(QColor(0xff,0xff,0xff)); - painter.setPen(QColor(0xff,0xff,0xff)); - painter.drawRect(0,0,m_maze.width(),m_maze.height()); - - double cellWidth = width()/8; - double cellHeight = height()/10; - - painter.setBrush(QColor(0xff,0xff,0xff)); - - QPen lockedDoorPen(Qt::red); - lockedDoorPen.setStyle(Qt::DashLine); - - QPen hiddenDoorPen(Qt::blue); - hiddenDoorPen.setStyle(Qt::DashLine); - hiddenDoorPen.setWidth(2); - - for (int idx = 0; idx < 8; idx++) - { - for (int jdx = 0; jdx < 10; jdx++) - { - int currentRoom = (jdx*8) + idx; - double cellTop = jdx * cellHeight + 1; - double cellBot = (jdx+1) * cellHeight - 1; - - double cellTopQuarter = cellTop + (cellHeight/4); - double cellBotQuarter = cellBot - (cellHeight/4); - - double cellLeft = idx * cellWidth + 1; - double cellRight = (idx+1) * cellWidth - 1; - - double cellLeftQuarter = cellLeft + (cellWidth/4); - double cellRightQuarter = cellRight - (cellWidth/4); - - - if (cellHasWalls(idx,jdx)) - { - painter.setPen(QColor(0xff,0xff,0xff)); - painter.setBrush(QColor(0xff,0xff,0xff)); - painter.drawRect(cellLeft, cellTop, cellWidth-2, cellHeight-2); - painter.setPen(Qt::black); - if (cellHasEastDoor(idx,jdx)) - { - painter.drawLine(QPointF(cellRight,cellTop),QPointF(cellRight,cellTopQuarter)); - painter.drawLine(QPointF(cellRight,cellBotQuarter),QPointF(cellRight,cellBot)); - - if (cellHasSpecialEast(idx,jdx)) { // Locked Door - QPen oldpen = painter.pen(); - - painter.setPen(lockedDoorPen); - painter.drawLine(QPointF(cellRight,cellTopQuarter),QPointF(cellRight,cellBotQuarter)); - painter.setPen(oldpen); - } - } - else - { - painter.drawLine(QPointF(cellRight,cellTop),QPointF(cellRight,cellBot)); - if (cellHasSpecialEast(idx,jdx)) { // Hidden Door - QPen oldpen = painter.pen(); - - painter.setPen(hiddenDoorPen); - painter.drawLine(QPointF(cellRight,cellTopQuarter),QPointF(cellRight,cellBotQuarter)); - painter.setPen(oldpen); - } - } - - if (cellHasWestDoor(idx,jdx)) - { - painter.drawLine(QPointF(cellLeft,cellTop),QPointF(cellLeft,cellTopQuarter)); - painter.drawLine(QPointF(cellLeft,cellBotQuarter),QPointF(cellLeft,cellBot)); - - if (cellHasSpecialWest(idx,jdx)) { // Locked Door - QPen oldpen = painter.pen(); - - painter.setPen(lockedDoorPen); - painter.drawLine(QPointF(cellLeft,cellTopQuarter),QPointF(cellLeft,cellBotQuarter)); - painter.setPen(oldpen); - } - } - else - { - painter.drawLine(QPointF(cellLeft,cellTop),QPointF(cellLeft,cellBot)); - if (cellHasSpecialWest(idx,jdx)) { // Hidden Door - QPen oldpen = painter.pen(); - - painter.setPen(hiddenDoorPen); - painter.drawLine(QPointF(cellLeft+1,cellTopQuarter),QPointF(cellLeft+1,cellBotQuarter)); - painter.setPen(oldpen); - } - } - - if (cellHasNorthDoor(idx,jdx)) - { - painter.drawLine(QPointF(cellLeft,cellTop),QPointF(cellLeftQuarter,cellTop)); - painter.drawLine(QPointF(cellRight,cellTop),QPointF(cellRightQuarter,cellTop)); - - - if (cellHasSpecialNorth(idx,jdx)) { // Locked Door - QPen oldpen = painter.pen(); - - painter.setPen(lockedDoorPen); - painter.drawLine(QPointF(cellLeftQuarter,cellTop),QPointF(cellRightQuarter,cellTop)); - painter.setPen(oldpen); - } - } - else - { - painter.drawLine(QPointF(cellLeft,cellTop),QPointF(cellRight,cellTop)); - if (cellHasSpecialNorth(idx,jdx)) { // Hidden Door - QPen oldpen = painter.pen(); - - painter.setPen(hiddenDoorPen); - painter.drawLine(QPointF(cellLeftQuarter,cellTop+1),QPointF(cellRightQuarter,cellTop+1)); - painter.setPen(oldpen); - } - } - - if (cellHasSouthDoor(idx,jdx)) - { - painter.drawLine(QPointF(cellLeft,cellBot),QPointF(cellLeftQuarter,cellBot)); - painter.drawLine(QPointF(cellRightQuarter,cellBot),QPointF(cellRight,cellBot)); - - - if (cellHasSpecialSouth(idx,jdx)) { // Locked Door - QPen oldpen = painter.pen(); - - painter.setPen(lockedDoorPen); - painter.drawLine(QPointF(cellLeftQuarter,cellBot),QPointF(cellRightQuarter,cellBot)); - painter.setPen(oldpen); - } - } - else - { - painter.drawLine(QPointF(cellLeft,cellBot),QPointF(cellRight,cellBot)); - if (cellHasSpecialSouth(idx,jdx)) { // Hidden Door - QPen oldpen = painter.pen(); - - painter.setPen(hiddenDoorPen); - painter.drawLine(QPointF(cellLeftQuarter,cellBot),QPointF(cellRightQuarter,cellBot)); - painter.setPen(oldpen); - } - - } - } - else - { - painter.setPen(QColor(0xef,0xef,0xef)); - painter.setBrush(QColor(0xef,0xef,0xef)); - painter.drawRect(cellLeft, cellTop, cellWidth-2, cellHeight-2); - } - - painter.setPen(Qt::black); - //quint8 cv = getCellDesc(idx,jdx); - quint8 tr = getCellInventory(idx,jdx); - QString trs = inventoryToString(tr); - quint8 mo = getCellMonsters(idx,jdx); - QString mos = monsterToString(mo); - - //QString str = QString("%1\nInv:0x%3\nMo:0x%4") - // .arg(idx+(jdx*8)) - // .arg(cv,2,16,QChar('0')) - // .arg(tr,2,16,QChar('0')) - // .arg(mo,2,16,QChar('0')); - - int playerCount = mem.at(0x80fd); - - QString pl; - for (int rdx = 0; rdx < playerCount; rdx++) - { - quint8 roomPlayerIsIn = mem.at(0x8008 + (32*rdx)); - - if (roomPlayerIsIn == currentRoom) { - if (rdx == 0) { pl += QString("\u2460"); } - if (rdx == 1) { pl += QString("\u2461"); } - if (rdx == 2) { pl += QString("\u2462"); } - if (rdx == 3) { pl += QString("\u2463"); } - if (rdx == 4) { pl += QString("\u2464"); } - } - } - - QString str = QString("%1\n%2\n%3\n%4") - .arg(idx+(jdx*8)) - .arg(mos) - .arg(trs) - .arg(pl); - - painter.drawText(QRect(cellLeft+2,cellTop+2,cellWidth-2,cellHeight-2),str); - } - } - -} - -bool MazeViewer::cellHasWalls(int x, int y) -{ - quint8 cellDesc = getCellDesc(x,y); - return (cellDesc != 0xFF); -} - -bool MazeViewer::cellHasNorthDoor(int x, int y) -{ - quint8 cellDesc = getCellDesc(x,y); - return (cellDesc & 0x04); -} - -bool MazeViewer::cellHasSpecialNorth(int x, int y) -{ - quint8 cellDesc = getCellDesc(x,y); - return (cellDesc & 0x40); -} - -bool MazeViewer::cellHasEastDoor(int x, int y) -{ - quint8 cellDesc = getCellDesc(x,y); - return (cellDesc & 0x08); -} - -bool MazeViewer::cellHasSpecialEast(int x, int y) -{ - quint8 cellDesc = getCellDesc(x,y); - return (cellDesc & 0x80); -} - -bool MazeViewer::cellHasSouthDoor(int x, int y) -{ - quint8 cellDesc = getCellDesc(x,y); - return (cellDesc & 0x01); -} - -bool MazeViewer::cellHasSpecialSouth(int x, int y) -{ - quint8 cellDesc = getCellDesc(x,y); - return (cellDesc & 0x10); -} - -bool MazeViewer::cellHasWestDoor(int x, int y) -{ - quint8 cellDesc = getCellDesc(x,y); - return (cellDesc & 0x02); -} - -bool MazeViewer::cellHasSpecialWest(int x, int y) -{ - quint8 cellDesc = getCellDesc(x,y); - return (cellDesc & 0x20); -} - -quint8 MazeViewer::getCellDesc(int x, int y) -{ - return mem.at(0x8100+x+(y*8)); -} - -quint8 MazeViewer::getCellMonsters(int x, int y) -{ - return mem.at(0x81A0+x+(y*8)); -} - -quint8 MazeViewer::getCellInventory(int x, int y) -{ - return mem.at(0x8150+x+(y*8)); -} - -QString MazeViewer::inventoryToString(quint8 inv) -{ - quint8 gems = (inv & 0xf0) >> 4; - quint8 gold_or_special = (inv & 0x0f); - - if (gems == 0 && gold_or_special == 0) { - return ""; - } - - if (gems == 0) // Special item; - { - if (gold_or_special == 0x00) { return ""; } - if (gold_or_special == 0x01) { return "Key1"; } - if (gold_or_special == 0x02) { return "Key2"; } - if (gold_or_special == 0x03) { return "Key3"; } - if (gold_or_special == 0x04) { return "Mirror"; } - if (gold_or_special == 0x05) { return "Goblet"; } - if (gold_or_special == 0x06) { return "Stauette"; } - if (gold_or_special == 0x07) { return "UNKN 7"; } - if (gold_or_special == 0x08) { return "UNKN 8"; } - if (gold_or_special == 0x09) { return "UNKN 9"; } - if (gold_or_special == 0x0A) { return "UNKN 10"; } - if (gold_or_special == 0x0B) { return "UNKN 11"; } - if (gold_or_special == 0x0C) { return "UNKN 12"; } - if (gold_or_special == 0x0D) { return "UNKN 13"; } - if (gold_or_special == 0x0E) { return "UNKN 14"; } - if (gold_or_special == 0x0F) { return "UNKN 15"; } - return ""; - } - else if (gold_or_special == 0) - { - if (gems == 0x01) { return "MagicShld (4)";} - if (gems == 0x02) { return "MthrlArmr (6)";} - if (gems == 0x03) { return "MagicSwd (255)";} - if (gems == 0x04) { return "MagicSwd (5)";} - if (gems == 0x05) { return "MagicArrs (3)";} - if (gems == 0x06) { return "MgcWarAx (4)";} - if (gems == 0x07) { return "MagicStf (4)";} - if (gems == 0x08) { return "GldRng (1)";} - if (gems == 0x09) { return "GldRng (2)";} - if (gems == 0x0a) { return "GldRng (4)";} - if (gems == 0x0b) { return "GldRng (8)";} - if (gems == 0x0c) { return "GldRng (16)";} - if (gems == 0x0d) { return "GldRng (32)";} - if (gems == 0x0e) { return "GldRng (64)";} - if (gems == 0x0f) { return "GldRng (128)"; } - } - else - { - return QString("%1Gm,%2Au").arg(gems).arg(gold_or_special * 4); - } - - return ""; -} - -QString MazeViewer::monsterToString(quint8 mc) -{ - quint8 count = mc & 0x0f; - quint8 monster = (mc & 0xf0) >> 4; - - QString name; - switch (monster) { - case 0x00: - name = ""; - break; - case 0x01: - name = "LgSpdr"; - break; - case 0x02: - name = "GntRat"; - break; - case 0x03: - name = "Orc"; - break; - case 0x04: - name = "FrBtle"; - break; - case 0x05: - name = "Goblin"; - break; - case 0x06: - name = "Sklton"; - break; - case 0x07: - name = "Zombie"; - break; - case 0x08: - name = "Grgyle"; - break; - case 0x09: - name = "DgOfWr"; - break; - case 0x0a: - name = "HlHnd"; - break; - case 0x0b: - name = "Wrght"; - break; - case 0x0c: - name = "HgSpdr"; - break; - case 0x0d: - name = "Hmncls"; - break; - case 0x0e: - name = "(INVAL)"; - break; - case 0x0f: - name = "EvlMage"; - break; - default: - name = "UNK"; - break; - } - - if (count > 0 && monster > 0) - { - return QString("%1 %2").arg(count).arg(name); - } - return ""; -} +#include "mazeviewer.h" +#include +#include +#include + +#include "memory.h" + +MazeViewer::MazeViewer(QWidget *parent) : FileViewerInterface(parent) +{ + //setMinimumSize(480,600); + m_maze = QPixmap(width(),height()); + drawMaze(); +} + +void MazeViewer::resizeEvent(QResizeEvent *event) +{ + QWidget::resizeEvent(event); + m_maze = QPixmap(event->size().width(), + event->size().height()); + drawMaze(); +} + +void MazeViewer::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + drawMaze(); + QPainter painter(this); + painter.drawPixmap(0, 0, m_maze); +} + +void MazeViewer::setFile(GenericFile *file) +{ + if (dynamic_cast(file)) + { + setFile(dynamic_cast(file)); + } +} + +void MazeViewer::setFile(BinaryFile *file) +{ + m_file = file; + + QString title = QString("Maze Viewer: %1").arg(m_file->filename()); + setWindowTitle(title); + + quint16 address = file->address(); + mem.addFile(file->data(), address); +} + + +void MazeViewer::drawMaze() +{ + QPainter painter(&m_maze); + + painter.setBrush(QColor(0xff,0xff,0xff)); + painter.setPen(QColor(0xff,0xff,0xff)); + painter.drawRect(0,0,m_maze.width(),m_maze.height()); + + double cellWidth = width()/8; + double cellHeight = height()/10; + + painter.setBrush(QColor(0xff,0xff,0xff)); + + QPen lockedDoorPen(Qt::red); + lockedDoorPen.setStyle(Qt::DashLine); + + QPen hiddenDoorPen(Qt::blue); + hiddenDoorPen.setStyle(Qt::DashLine); + hiddenDoorPen.setWidth(2); + + for (int idx = 0; idx < 8; idx++) + { + for (int jdx = 0; jdx < 10; jdx++) + { + int currentRoom = (jdx*8) + idx; + double cellTop = jdx * cellHeight + 1; + double cellBot = (jdx+1) * cellHeight - 1; + + double cellTopQuarter = cellTop + (cellHeight/4); + double cellBotQuarter = cellBot - (cellHeight/4); + + double cellLeft = idx * cellWidth + 1; + double cellRight = (idx+1) * cellWidth - 1; + + double cellLeftQuarter = cellLeft + (cellWidth/4); + double cellRightQuarter = cellRight - (cellWidth/4); + + + if (cellHasWalls(idx,jdx)) + { + painter.setPen(QColor(0xff,0xff,0xff)); + painter.setBrush(QColor(0xff,0xff,0xff)); + painter.drawRect(cellLeft, cellTop, cellWidth-2, cellHeight-2); + painter.setPen(Qt::black); + if (cellHasEastDoor(idx,jdx)) + { + painter.drawLine(QPointF(cellRight,cellTop),QPointF(cellRight,cellTopQuarter)); + painter.drawLine(QPointF(cellRight,cellBotQuarter),QPointF(cellRight,cellBot)); + + if (cellHasSpecialEast(idx,jdx)) { // Locked Door + QPen oldpen = painter.pen(); + + painter.setPen(lockedDoorPen); + painter.drawLine(QPointF(cellRight,cellTopQuarter),QPointF(cellRight,cellBotQuarter)); + painter.setPen(oldpen); + } + } + else + { + painter.drawLine(QPointF(cellRight,cellTop),QPointF(cellRight,cellBot)); + if (cellHasSpecialEast(idx,jdx)) { // Hidden Door + QPen oldpen = painter.pen(); + + painter.setPen(hiddenDoorPen); + painter.drawLine(QPointF(cellRight,cellTopQuarter),QPointF(cellRight,cellBotQuarter)); + painter.setPen(oldpen); + } + } + + if (cellHasWestDoor(idx,jdx)) + { + painter.drawLine(QPointF(cellLeft,cellTop),QPointF(cellLeft,cellTopQuarter)); + painter.drawLine(QPointF(cellLeft,cellBotQuarter),QPointF(cellLeft,cellBot)); + + if (cellHasSpecialWest(idx,jdx)) { // Locked Door + QPen oldpen = painter.pen(); + + painter.setPen(lockedDoorPen); + painter.drawLine(QPointF(cellLeft,cellTopQuarter),QPointF(cellLeft,cellBotQuarter)); + painter.setPen(oldpen); + } + } + else + { + painter.drawLine(QPointF(cellLeft,cellTop),QPointF(cellLeft,cellBot)); + if (cellHasSpecialWest(idx,jdx)) { // Hidden Door + QPen oldpen = painter.pen(); + + painter.setPen(hiddenDoorPen); + painter.drawLine(QPointF(cellLeft+1,cellTopQuarter),QPointF(cellLeft+1,cellBotQuarter)); + painter.setPen(oldpen); + } + } + + if (cellHasNorthDoor(idx,jdx)) + { + painter.drawLine(QPointF(cellLeft,cellTop),QPointF(cellLeftQuarter,cellTop)); + painter.drawLine(QPointF(cellRight,cellTop),QPointF(cellRightQuarter,cellTop)); + + + if (cellHasSpecialNorth(idx,jdx)) { // Locked Door + QPen oldpen = painter.pen(); + + painter.setPen(lockedDoorPen); + painter.drawLine(QPointF(cellLeftQuarter,cellTop),QPointF(cellRightQuarter,cellTop)); + painter.setPen(oldpen); + } + } + else + { + painter.drawLine(QPointF(cellLeft,cellTop),QPointF(cellRight,cellTop)); + if (cellHasSpecialNorth(idx,jdx)) { // Hidden Door + QPen oldpen = painter.pen(); + + painter.setPen(hiddenDoorPen); + painter.drawLine(QPointF(cellLeftQuarter,cellTop+1),QPointF(cellRightQuarter,cellTop+1)); + painter.setPen(oldpen); + } + } + + if (cellHasSouthDoor(idx,jdx)) + { + painter.drawLine(QPointF(cellLeft,cellBot),QPointF(cellLeftQuarter,cellBot)); + painter.drawLine(QPointF(cellRightQuarter,cellBot),QPointF(cellRight,cellBot)); + + + if (cellHasSpecialSouth(idx,jdx)) { // Locked Door + QPen oldpen = painter.pen(); + + painter.setPen(lockedDoorPen); + painter.drawLine(QPointF(cellLeftQuarter,cellBot),QPointF(cellRightQuarter,cellBot)); + painter.setPen(oldpen); + } + } + else + { + painter.drawLine(QPointF(cellLeft,cellBot),QPointF(cellRight,cellBot)); + if (cellHasSpecialSouth(idx,jdx)) { // Hidden Door + QPen oldpen = painter.pen(); + + painter.setPen(hiddenDoorPen); + painter.drawLine(QPointF(cellLeftQuarter,cellBot),QPointF(cellRightQuarter,cellBot)); + painter.setPen(oldpen); + } + + } + } + else + { + painter.setPen(QColor(0xef,0xef,0xef)); + painter.setBrush(QColor(0xef,0xef,0xef)); + painter.drawRect(cellLeft, cellTop, cellWidth-2, cellHeight-2); + } + + painter.setPen(Qt::black); + //quint8 cv = getCellDesc(idx,jdx); + quint8 tr = getCellInventory(idx,jdx); + QString trs = inventoryToString(tr); + quint8 mo = getCellMonsters(idx,jdx); + QString mos = monsterToString(mo); + + //QString str = QString("%1\nInv:0x%3\nMo:0x%4") + // .arg(idx+(jdx*8)) + // .arg(cv,2,16,QChar('0')) + // .arg(tr,2,16,QChar('0')) + // .arg(mo,2,16,QChar('0')); + + int playerCount = mem.at(0x80fd); + + QString pl; + for (int rdx = 0; rdx < playerCount; rdx++) + { + quint8 roomPlayerIsIn = mem.at(0x8008 + (32*rdx)); + + if (roomPlayerIsIn == currentRoom) { + if (rdx == 0) { pl += QString("\u2460"); } + if (rdx == 1) { pl += QString("\u2461"); } + if (rdx == 2) { pl += QString("\u2462"); } + if (rdx == 3) { pl += QString("\u2463"); } + if (rdx == 4) { pl += QString("\u2464"); } + } + } + + QString str = QString("%1\n%2\n%3\n%4") + .arg(idx+(jdx*8)) + .arg(mos) + .arg(trs) + .arg(pl); + + painter.drawText(QRect(cellLeft+2,cellTop+2,cellWidth-2,cellHeight-2),str); + } + } + +} + +bool MazeViewer::cellHasWalls(int x, int y) +{ + quint8 cellDesc = getCellDesc(x,y); + return (cellDesc != 0xFF); +} + +bool MazeViewer::cellHasNorthDoor(int x, int y) +{ + quint8 cellDesc = getCellDesc(x,y); + return (cellDesc & 0x04); +} + +bool MazeViewer::cellHasSpecialNorth(int x, int y) +{ + quint8 cellDesc = getCellDesc(x,y); + return (cellDesc & 0x40); +} + +bool MazeViewer::cellHasEastDoor(int x, int y) +{ + quint8 cellDesc = getCellDesc(x,y); + return (cellDesc & 0x08); +} + +bool MazeViewer::cellHasSpecialEast(int x, int y) +{ + quint8 cellDesc = getCellDesc(x,y); + return (cellDesc & 0x80); +} + +bool MazeViewer::cellHasSouthDoor(int x, int y) +{ + quint8 cellDesc = getCellDesc(x,y); + return (cellDesc & 0x01); +} + +bool MazeViewer::cellHasSpecialSouth(int x, int y) +{ + quint8 cellDesc = getCellDesc(x,y); + return (cellDesc & 0x10); +} + +bool MazeViewer::cellHasWestDoor(int x, int y) +{ + quint8 cellDesc = getCellDesc(x,y); + return (cellDesc & 0x02); +} + +bool MazeViewer::cellHasSpecialWest(int x, int y) +{ + quint8 cellDesc = getCellDesc(x,y); + return (cellDesc & 0x20); +} + +quint8 MazeViewer::getCellDesc(int x, int y) +{ + return mem.at(0x8100+x+(y*8)); +} + +quint8 MazeViewer::getCellMonsters(int x, int y) +{ + return mem.at(0x81A0+x+(y*8)); +} + +quint8 MazeViewer::getCellInventory(int x, int y) +{ + return mem.at(0x8150+x+(y*8)); +} + +QString MazeViewer::inventoryToString(quint8 inv) +{ + quint8 gems = (inv & 0xf0) >> 4; + quint8 gold_or_special = (inv & 0x0f); + + if (gems == 0 && gold_or_special == 0) { + return ""; + } + + if (gems == 0) // Special item; + { + if (gold_or_special == 0x00) { return ""; } + if (gold_or_special == 0x01) { return "Key1"; } + if (gold_or_special == 0x02) { return "Key2"; } + if (gold_or_special == 0x03) { return "Key3"; } + if (gold_or_special == 0x04) { return "Mirror"; } + if (gold_or_special == 0x05) { return "Goblet"; } + if (gold_or_special == 0x06) { return "Stauette"; } + if (gold_or_special == 0x07) { return "UNKN 7"; } + if (gold_or_special == 0x08) { return "UNKN 8"; } + if (gold_or_special == 0x09) { return "UNKN 9"; } + if (gold_or_special == 0x0A) { return "UNKN 10"; } + if (gold_or_special == 0x0B) { return "UNKN 11"; } + if (gold_or_special == 0x0C) { return "UNKN 12"; } + if (gold_or_special == 0x0D) { return "UNKN 13"; } + if (gold_or_special == 0x0E) { return "UNKN 14"; } + if (gold_or_special == 0x0F) { return "UNKN 15"; } + return ""; + } + else if (gold_or_special == 0) + { + if (gems == 0x01) { return "MagicShld (4)";} + if (gems == 0x02) { return "MthrlArmr (6)";} + if (gems == 0x03) { return "MagicSwd (255)";} + if (gems == 0x04) { return "MagicSwd (5)";} + if (gems == 0x05) { return "MagicArrs (3)";} + if (gems == 0x06) { return "MgcWarAx (4)";} + if (gems == 0x07) { return "MagicStf (4)";} + if (gems == 0x08) { return "GldRng (1)";} + if (gems == 0x09) { return "GldRng (2)";} + if (gems == 0x0a) { return "GldRng (4)";} + if (gems == 0x0b) { return "GldRng (8)";} + if (gems == 0x0c) { return "GldRng (16)";} + if (gems == 0x0d) { return "GldRng (32)";} + if (gems == 0x0e) { return "GldRng (64)";} + if (gems == 0x0f) { return "GldRng (128)"; } + } + else + { + return QString("%1Gm,%2Au").arg(gems).arg(gold_or_special * 4); + } + + return ""; +} + +QString MazeViewer::monsterToString(quint8 mc) +{ + quint8 count = mc & 0x0f; + quint8 monster = (mc & 0xf0) >> 4; + + QString name; + switch (monster) { + case 0x00: + name = ""; + break; + case 0x01: + name = "LgSpdr"; + break; + case 0x02: + name = "GntRat"; + break; + case 0x03: + name = "Orc"; + break; + case 0x04: + name = "FrBtle"; + break; + case 0x05: + name = "Goblin"; + break; + case 0x06: + name = "Sklton"; + break; + case 0x07: + name = "Zombie"; + break; + case 0x08: + name = "Grgyle"; + break; + case 0x09: + name = "DgOfWr"; + break; + case 0x0a: + name = "HlHnd"; + break; + case 0x0b: + name = "Wrght"; + break; + case 0x0c: + name = "HgSpdr"; + break; + case 0x0d: + name = "Hmncls"; + break; + case 0x0e: + name = "(INVAL)"; + break; + case 0x0f: + name = "EvlMage"; + break; + default: + name = "UNK"; + break; + } + + if (count > 0 && monster > 0) + { + return QString("%1 %2").arg(count).arg(name); + } + return ""; +} diff --git a/src/ui/viewers/mazeviewer.h b/src/ui/viewers/mazeviewer.h index fba4c73..ae55db4 100644 --- a/src/ui/viewers/mazeviewer.h +++ b/src/ui/viewers/mazeviewer.h @@ -1,55 +1,55 @@ -#ifndef MAZEVIEWER_H -#define MAZEVIEWER_H - -#include -#include -#include - -#include "binaryfile.h" -#include "memory.h" -#include "fileviewerinterface.h" - - -/// A class for viewing maze files in "The Missing Ring" by DataMost. - -class MazeViewer : public FileViewerInterface -{ - Q_OBJECT -public: - MazeViewer(QWidget *parent = 0); - - void drawMaze(); - void resizeEvent(QResizeEvent *event); - void paintEvent(QPaintEvent *event); - - void setFile(GenericFile *file); - - void setFile(BinaryFile *file); - - virtual bool optionsMenuItems(QMenu *) { return false; } - -private: - QPixmap m_maze; - BinaryFile *m_file; - Memory mem; - - bool cellHasWalls(int x, int y); - bool cellHasNorthDoor(int x, int y); - bool cellHasSouthDoor(int x, int y); - bool cellHasEastDoor(int x, int y); - bool cellHasWestDoor(int x, int y); - - bool cellHasSpecialNorth(int x, int y); - bool cellHasSpecialSouth(int x, int y); - bool cellHasSpecialEast(int x, int y); - bool cellHasSpecialWest(int x, int y); - - quint8 getCellDesc(int x, int y); - quint8 getCellMonsters(int x, int y); - quint8 getCellInventory(int x, int y); - - QString inventoryToString(quint8 inv); - QString monsterToString(quint8 mc); -}; - -#endif // MAZEVIEWER_H +#ifndef MAZEVIEWER_H +#define MAZEVIEWER_H + +#include +#include +#include + +#include "binaryfile.h" +#include "memory.h" +#include "fileviewerinterface.h" + + +/// A class for viewing maze files in "The Missing Ring" by DataMost. + +class MazeViewer : public FileViewerInterface +{ + Q_OBJECT +public: + MazeViewer(QWidget *parent = 0); + + void drawMaze(); + void resizeEvent(QResizeEvent *event); + void paintEvent(QPaintEvent *event); + + void setFile(GenericFile *file); + + void setFile(BinaryFile *file); + + virtual bool optionsMenuItems(QMenu *) { return false; } + +private: + QPixmap m_maze; + BinaryFile *m_file; + Memory mem; + + bool cellHasWalls(int x, int y); + bool cellHasNorthDoor(int x, int y); + bool cellHasSouthDoor(int x, int y); + bool cellHasEastDoor(int x, int y); + bool cellHasWestDoor(int x, int y); + + bool cellHasSpecialNorth(int x, int y); + bool cellHasSpecialSouth(int x, int y); + bool cellHasSpecialEast(int x, int y); + bool cellHasSpecialWest(int x, int y); + + quint8 getCellDesc(int x, int y); + quint8 getCellMonsters(int x, int y); + quint8 getCellInventory(int x, int y); + + QString inventoryToString(quint8 inv); + QString monsterToString(quint8 mc); +}; + +#endif // MAZEVIEWER_H diff --git a/src/ui/viewers/texthexdumpviewer.cpp b/src/ui/viewers/texthexdumpviewer.cpp index 959c314..53d7be8 100644 --- a/src/ui/viewers/texthexdumpviewer.cpp +++ b/src/ui/viewers/texthexdumpviewer.cpp @@ -1,177 +1,182 @@ -#include "texthexdumpviewer.h" -#include "ui_texthexdumpviewer.h" -#include "applestring.h" - -#include -#include -#include -#include -#include - -TextHexDumpViewer::TextHexDumpViewer(QWidget *parent) : - FileViewerInterface(parent), - ui(new Ui::TextHexDumpViewer) -{ - m_file = Q_NULLPTR; - ui->setupUi(this); - m_offset = 0; - - QString title = QString("Text/Hex File Viewer"); - setWindowTitle(title); - - QSettings settings; - toggleWordWrap(settings.value("TexHexViewer.WordWrap",true).toBool()); -} - -TextHexDumpViewer::~TextHexDumpViewer() -{ - delete ui; -} - -void TextHexDumpViewer::toggleWordWrap(bool enabled) -{ - if (enabled) - { - ui->textArea->setWordWrapMode(QTextOption::WordWrap); - } - else - { - ui->textArea->setWordWrapMode(QTextOption::NoWrap); - } - QSettings settings; - settings.setValue("TextHexViewer.WordWrap",enabled); -} - - -QString TextHexDumpViewer::makeHexStr(QByteArray data) -{ - QString retval; - for (int idx = 0; idx < data.length(); idx++) - { - retval += QString(" %1").arg((quint8) data[idx],2,16,QChar('0')); - } - retval.remove(0,1); - - return retval; -} - -QString TextHexDumpViewer::makeTextStr(QByteArray data) -{ - AppleString as; - as.setData(data); - - QString retval = as.printable(); - - retval.replace(QChar(0x7f),QChar(0x25a9)); - - for (int idx = 0; idx <= 0x1f; idx++) { - retval.replace(QChar(idx),QChar(idx+0x2400)); - } - - return retval; -} - -void TextHexDumpViewer::setFile(GenericFile *file, quint16 offset) -{ - m_file = file; - m_offset = offset; - QByteArray data = file->data(); - - QString title = QString("Text/Hex File Viewer: %1").arg(file->filename()); - setWindowTitle(title); - - QStringList outputlines; - - - QVector chunks; - - QByteArray tmpval = data; - - while (tmpval.count()) { - QByteArray tmpchunk = tmpval.left(16); - tmpval.remove(0,16); - chunks.append(tmpchunk); - } - - quint16 addr = 0; - foreach (QByteArray chunk, chunks) { - QString hexstr = makeHexStr(chunk); -// chunk.replace(0,'.'); - QString textstr = makeTextStr(chunk); - QString line = QString("%1: %2 %3").arg(addr,4,16,QChar('0')).arg(hexstr).arg(textstr); - - addr += 16; - outputlines.append(line); - } - - setData(qPrintable(outputlines.join("\n").toUpper())); -} - -void TextHexDumpViewer::setData(QByteArray data) -{ - ui->textArea->setText(data); -} - -void TextHexDumpViewer::setText(QString text) -{ - ui->textArea->setHtml(text); -} - -bool TextHexDumpViewer::optionsMenuItems(QMenu *menu) -{ - QSettings settings; - - QAction *action = new QAction("&Word Wrap"); - action->setCheckable(true); - action->setChecked(settings.value("TexHexViewer.WordWrap",true).toBool()); - connect(action, &QAction::toggled, - this, &TextHexDumpViewer::toggleWordWrap); - menu->addAction(action); - - return true; -} - -bool TextHexDumpViewer::canPrint() const { return true; } - -void TextHexDumpViewer::doPrint() -{ - QPrinter printer; - - QPrintDialog dialog(&printer, this); - dialog.setWindowTitle(tr("Print Text File Hex Dump")); - if (ui->textArea->textCursor().hasSelection()) - dialog.addEnabledOption(QAbstractPrintDialog::PrintSelection); - if (dialog.exec() != QDialog::Accepted) { - return; - } - - ui->textArea->print(&printer); -} - - -bool TextHexDumpViewer::canExport() const { return true; } - -void TextHexDumpViewer::doExport() -{ - QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); - QDir savename = QDir(defaultPath).filePath(m_file->filename()+".txt"); - - QString saveName = QFileDialog::getSaveFileName(this, - tr("Export Text Hex Dump"), savename.path(), tr("Text Files (*.txt)")); - - if (saveName == "") return; // User cancelled - - qDebug() << "Set filename: " << saveName; - - QFile saveFile(saveName); - if (!saveFile.open(QIODevice::WriteOnly | QIODevice::Text)) - { - QMessageBox::warning(this,"Save Error","Could not save "+saveName); - return; - } - - QTextStream out(&saveFile); - out << ui->textArea->document()->toPlainText(); - saveFile.close(); -} - +#include "texthexdumpviewer.h" +#include "ui_texthexdumpviewer.h" +#include "applestring.h" + +#include +#include +#include +#include +#include + +TextHexDumpViewer::TextHexDumpViewer(QWidget *parent) : + FileViewerInterface(parent), + ui(new Ui::TextHexDumpViewer) +{ + m_file = Q_NULLPTR; + ui->setupUi(this); + QFont textAreaFont; + textAreaFont.setStyleHint(QFont::Monospace); + ui->textArea->setFont(textAreaFont); + + + m_offset = 0; + + QString title = QString("Text/Hex File Viewer"); + setWindowTitle(title); + + QSettings settings; + toggleWordWrap(settings.value("TexHexViewer.WordWrap",true).toBool()); +} + +TextHexDumpViewer::~TextHexDumpViewer() +{ + delete ui; +} + +void TextHexDumpViewer::toggleWordWrap(bool enabled) +{ + if (enabled) + { + ui->textArea->setWordWrapMode(QTextOption::WordWrap); + } + else + { + ui->textArea->setWordWrapMode(QTextOption::NoWrap); + } + QSettings settings; + settings.setValue("TextHexViewer.WordWrap",enabled); +} + + +QString TextHexDumpViewer::makeHexStr(QByteArray data) +{ + QString retval; + for (int idx = 0; idx < data.length(); idx++) + { + retval += QString(" %1").arg((quint8) data[idx],2,16,QChar('0')); + } + retval.remove(0,1); + + return retval; +} + +QString TextHexDumpViewer::makeTextStr(QByteArray data) +{ + AppleString as; + as.setData(data); + + QString retval = as.printable(); + + retval.replace(QChar(0x7f),QChar(0x25a9)); + + for (int idx = 0; idx <= 0x1f; idx++) { + retval.replace(QChar(idx),QChar(idx+0x2400)); + } + + return retval; +} + +void TextHexDumpViewer::setFile(GenericFile *file, quint16 offset) +{ + m_file = file; + m_offset = offset; + QByteArray data = file->data(); + + QString title = QString("Text/Hex File Viewer: %1").arg(file->filename()); + setWindowTitle(title); + + QStringList outputlines; + + + QVector chunks; + + QByteArray tmpval = data; + + while (tmpval.count()) { + QByteArray tmpchunk = tmpval.left(16); + tmpval.remove(0,16); + chunks.append(tmpchunk); + } + + quint16 addr = 0; + foreach (QByteArray chunk, chunks) { + QString hexstr = makeHexStr(chunk); +// chunk.replace(0,'.'); + QString textstr = makeTextStr(chunk); + QString line = QString("%1: %2 %3").arg(addr,4,16,QChar('0')).arg(hexstr).arg(textstr); + + addr += 16; + outputlines.append(line); + } + + setData(qPrintable(outputlines.join("\n").toUpper())); +} + +void TextHexDumpViewer::setData(QByteArray data) +{ + ui->textArea->setText(data); +} + +void TextHexDumpViewer::setText(QString text) +{ + ui->textArea->setHtml(text); +} + +bool TextHexDumpViewer::optionsMenuItems(QMenu *menu) +{ + QSettings settings; + + QAction *action = new QAction("&Word Wrap"); + action->setCheckable(true); + action->setChecked(settings.value("TexHexViewer.WordWrap",true).toBool()); + connect(action, &QAction::toggled, + this, &TextHexDumpViewer::toggleWordWrap); + menu->addAction(action); + + return true; +} + +bool TextHexDumpViewer::canPrint() const { return true; } + +void TextHexDumpViewer::doPrint() +{ + QPrinter printer; + + QPrintDialog dialog(&printer, this); + dialog.setWindowTitle(tr("Print Text File Hex Dump")); + if (ui->textArea->textCursor().hasSelection()) + dialog.addEnabledOption(QAbstractPrintDialog::PrintSelection); + if (dialog.exec() != QDialog::Accepted) { + return; + } + + ui->textArea->print(&printer); +} + + +bool TextHexDumpViewer::canExport() const { return true; } + +void TextHexDumpViewer::doExport() +{ + QString defaultPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); + QDir savename = QDir(defaultPath).filePath(m_file->filename()+".txt"); + + QString saveName = QFileDialog::getSaveFileName(this, + tr("Export Text Hex Dump"), savename.path(), tr("Text Files (*.txt)")); + + if (saveName == "") return; // User cancelled + + qDebug() << "Set filename: " << saveName; + + QFile saveFile(saveName); + if (!saveFile.open(QIODevice::WriteOnly | QIODevice::Text)) + { + QMessageBox::warning(this,"Save Error","Could not save "+saveName); + return; + } + + QTextStream out(&saveFile); + out << ui->textArea->document()->toPlainText(); + saveFile.close(); +} + diff --git a/src/ui/viewers/texthexdumpviewer.h b/src/ui/viewers/texthexdumpviewer.h index 1dd356f..b12cd04 100644 --- a/src/ui/viewers/texthexdumpviewer.h +++ b/src/ui/viewers/texthexdumpviewer.h @@ -1,51 +1,51 @@ -#ifndef TEXTHEXDUMPVIEWER_H -#define TEXTHEXDUMPVIEWER_H - -#include "genericfile.h" -#include "fileviewerinterface.h" - -#include -#include -#include - - -namespace Ui { -class TextHexDumpViewer; -} - -class TextHexDumpViewer : public FileViewerInterface -{ - Q_OBJECT - -public: - explicit TextHexDumpViewer(QWidget *parent = 0); - ~TextHexDumpViewer(); - - void setFile(GenericFile *file) { setFile(file,0); } - void setFile(GenericFile *file, quint16 offset); - void setData(QByteArray data); - void setText(QString text); - - virtual bool optionsMenuItems(QMenu *menu); - - bool canPrint() const; - bool canExport() const; - -public slots: - void toggleWordWrap(bool enabled); - void doPrint(); - void doExport(); - -protected: - QString makeTextStr(QByteArray data); - QString makeHexStr(QByteArray data); - -private: - Ui::TextHexDumpViewer *ui; - - quint16 m_offset; - - GenericFile *m_file; -}; - -#endif // TEXTHEXDUMPVIEWER_H +#ifndef TEXTHEXDUMPVIEWER_H +#define TEXTHEXDUMPVIEWER_H + +#include "genericfile.h" +#include "fileviewerinterface.h" + +#include +#include +#include + + +namespace Ui { +class TextHexDumpViewer; +} + +class TextHexDumpViewer : public FileViewerInterface +{ + Q_OBJECT + +public: + explicit TextHexDumpViewer(QWidget *parent = 0); + ~TextHexDumpViewer(); + + void setFile(GenericFile *file) { setFile(file,0); } + void setFile(GenericFile *file, quint16 offset); + void setData(QByteArray data); + void setText(QString text); + + virtual bool optionsMenuItems(QMenu *menu); + + bool canPrint() const; + bool canExport() const; + +public slots: + void toggleWordWrap(bool enabled); + void doPrint(); + void doExport(); + +protected: + QString makeTextStr(QByteArray data); + QString makeHexStr(QByteArray data); + +private: + Ui::TextHexDumpViewer *ui; + + quint16 m_offset; + + GenericFile *m_file; +}; + +#endif // TEXTHEXDUMPVIEWER_H diff --git a/src/ui/viewers/texthexdumpviewer.ui b/src/ui/viewers/texthexdumpviewer.ui index 9bd2a96..9d96d04 100644 --- a/src/ui/viewers/texthexdumpviewer.ui +++ b/src/ui/viewers/texthexdumpviewer.ui @@ -1,39 +1,32 @@ - - - TextHexDumpViewer - - - - 0 - 0 - 152 - 121 - - - - Form - - - - - - - Courier - 12 - - - - - - - - - FileViewerInterface - QWidget -
viewerbase.h
- 1 -
-
- - -
+ + + TextHexDumpViewer + + + + 0 + 0 + 152 + 121 + + + + Form + + + + + + + + + + FileViewerInterface + QWidget +
viewerbase.h
+ 1 +
+
+ + +
diff --git a/src/ui/viewers/viewerbase.cpp b/src/ui/viewers/viewerbase.cpp index 690ed70..120d339 100644 --- a/src/ui/viewers/viewerbase.cpp +++ b/src/ui/viewers/viewerbase.cpp @@ -1,192 +1,205 @@ -#include "viewerbase.h" -#include "ui_viewerbase.h" - -#include -#include -#include -#include -#include -#include - -#include "applesoftfileviewer.h" -#include "hexdumpviewer.h" -#include "texthexdumpviewer.h" -#include "charsetviewer.h" -#include "hiresviewwidget.h" -#include "disassemblerviewer.h" -#include "textfile.h" -#include "mazeviewer.h" - -ViewerBase::ViewerBase(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::ViewerBase) -{ - setAttribute(Qt::WA_DeleteOnClose); - - m_stack = new QStackedWidget(this); - ui->setupUi(this); - - setCentralWidget(m_stack); - - m_toolbar = new QToolBar(this); - addToolBar(m_toolbar); - - QLabel *label = new QLabel("View With: "); - m_toolbar->addWidget(label); - - m_viewercombo = new QComboBox(m_toolbar); - m_toolbar->addWidget(m_viewercombo); - - m_optionMenu = new QMenu("&Viewer"); - menuBar()->addMenu(m_optionMenu); - m_optionMenu->setEnabled(false); -} - -ViewerBase::~ViewerBase() -{ - emit viewerClosing(this); - delete ui; -} - -void ViewerBase::setFile(GenericFile *file) -{ - m_file = file; - - QString descriptor; - QString defaultViewerDescriptor; - - HexDumpViewer *hdv = new HexDumpViewer(0); - if (dynamic_cast(file)) - hdv->setFile(file,0x801); //TODO: Double check this offset. - else - hdv->setFile(file,m_file->address()); - descriptor = ("Hex Dump Viewer"); - addViewer(descriptor,hdv); - defaultViewerDescriptor = descriptor; - - if (dynamic_cast(file)) - { - ApplesoftFileViewer *afv = new ApplesoftFileViewer(0); - afv->setFile(file); - descriptor="Applesoft File Viewer"; - addViewer(descriptor,afv); - defaultViewerDescriptor = descriptor; - } - else if (dynamic_cast(file)) - { - BinaryFile *bf = dynamic_cast(file); - - CharSetViewer *csv = new CharSetViewer(); - csv->setFile(bf); - descriptor ="HRCG Character Set Viewer"; - addViewer(descriptor,csv); - - HiresViewWidget *hrvw = new HiresViewWidget(); - hrvw->setFile(bf); - descriptor = "HiRes Image Viewer"; - addViewer(descriptor,hrvw); - - MazeViewer *mv = new MazeViewer(); - mv->setFile(file); - descriptor = "MissingRing Maze Viewer"; - addViewer(descriptor,mv); - - DisassemblerViewer *dv = new DisassemblerViewer(); - dv->setFile(bf); - descriptor = "Disassembler Viewer"; - addViewer(descriptor,dv); - defaultViewerDescriptor = descriptor; - - if (bf->filename().toUpper().endsWith(".SET")) - { - defaultViewerDescriptor ="HRCG Character Set Viewer"; - } - if (bf->filename().toUpper().startsWith("MAZE")) - { - defaultViewerDescriptor = "MissingRing Maze Viewer"; - } - if ((bf->address() == 0x2000 || bf->address() == 0x4000) - && bf->length() == 0x2000) - { - defaultViewerDescriptor = "HiRes Image Viewer"; - } - - } - else if (dynamic_cast(file)) - { - TextFile *bf = dynamic_cast(file); - - TextHexDumpViewer *thdv = new TextHexDumpViewer(); - thdv->setFile(bf); - descriptor = QString("Text/Hex Dump Viewer"); - addViewer(descriptor,thdv); - - defaultViewerDescriptor = descriptor; - } - else if (dynamic_cast(file)) - { - DisassemblerViewer *dv = new DisassemblerViewer(); - dv->setFile(file); - descriptor = "Relocatable Disassembler Viewer"; - addViewer(descriptor,dv); - defaultViewerDescriptor = descriptor; - - } - connect(m_viewercombo, static_cast(&QComboBox::currentIndexChanged), - this, &ViewerBase::showViewer); - showViewer(defaultViewerDescriptor); -} - -void ViewerBase::closeEvent(QCloseEvent *event) -{ - event->accept(); -} - -void ViewerBase::addViewer(QString descriptor, FileViewerInterface *viewer) -{ - if (!m_viewers.contains(descriptor)) - { - m_stack->addWidget(viewer); - m_viewers[descriptor] = viewer; - m_viewercombo->addItem(descriptor); - } -} - -void ViewerBase::showViewer(const QString& descriptor) -{ - FileViewerInterface *fvi = m_viewers[descriptor]; - if (fvi) - { - ui->actionExport->disconnect(SIGNAL(triggered(bool))); - ui->actionExport->setEnabled(fvi->canExport()); - connect(ui->actionExport, &QAction::triggered, - fvi, &FileViewerInterface::doExport); - - ui->action_Print->disconnect(SIGNAL(triggered(bool))); - ui->action_Print->setEnabled(fvi->canPrint()); - connect(ui->action_Print, &QAction::triggered, - fvi, &FileViewerInterface::doPrint); - - m_optionMenu->clear(); - m_viewercombo->setCurrentText(descriptor); - m_stack->setCurrentWidget(fvi); - setWindowTitle(fvi->windowTitle()); - - if (m_optionMenu) - { - if (!fvi->optionsMenuItems(m_optionMenu)) - { - m_optionMenu->setEnabled(false); - } - else - { - m_optionMenu->setEnabled(true); - } - } - } - else - { - qDebug() << "Could not find widget for descriptor" << descriptor; - } - -} +#include "viewerbase.h" +#include "ui_viewerbase.h" + +#include +#include +#include +#include +#include +#include + +#include "applesoftfileviewer.h" +#include "hexdumpviewer.h" +#include "texthexdumpviewer.h" +#include "charsetviewer.h" +#include "IntBasicFile.h" +#include "intbasicfileviewer.h" +#include "hiresviewwidget.h" +#include "disassemblerviewer.h" +#include "textfile.h" +#include "mazeviewer.h" + +ViewerBase::ViewerBase(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::ViewerBase) +{ + setAttribute(Qt::WA_DeleteOnClose); + + m_stack = new QStackedWidget(this); + ui->setupUi(this); + + setCentralWidget(m_stack); + + m_toolbar = new QToolBar(this); + addToolBar(m_toolbar); + + QLabel *label = new QLabel("View With: "); + m_toolbar->addWidget(label); + + m_viewercombo = new QComboBox(m_toolbar); + m_toolbar->addWidget(m_viewercombo); + + m_optionMenu = new QMenu("&Viewer"); + menuBar()->addMenu(m_optionMenu); + m_optionMenu->setEnabled(false); +} + +ViewerBase::~ViewerBase() +{ + emit viewerClosing(this); + delete ui; +} + +void ViewerBase::setFile(GenericFile *file) +{ + m_file = file; + + QString descriptor; + QString defaultViewerDescriptor; + + HexDumpViewer *hdv = new HexDumpViewer(0); + if (dynamic_cast(file)) + hdv->setFile(file,0x801); //TODO: Double check this offset. + else + hdv->setFile(file,m_file->address()); + descriptor = ("Hex Dump Viewer"); + addViewer(descriptor,hdv); + defaultViewerDescriptor = descriptor; + + if (dynamic_cast(file)) + { + ApplesoftFileViewer *afv = new ApplesoftFileViewer(0); + afv->setFile(file); + descriptor="Applesoft File Viewer"; + addViewer(descriptor,afv); + defaultViewerDescriptor = descriptor; + } + else if (dynamic_cast(file)) + { + IntBasicFileViewer *ibf = new IntBasicFileViewer(0); + ibf->setFile(file); + descriptor="Integer Basic File Viewer"; + addViewer(descriptor, ibf); + defaultViewerDescriptor = descriptor; + + + + } + else if (dynamic_cast(file)) + { + BinaryFile *bf = dynamic_cast(file); + + CharSetViewer *csv = new CharSetViewer(); + csv->setFile(bf); + descriptor ="HRCG Character Set Viewer"; + addViewer(descriptor,csv); + + HiresViewWidget *hrvw = new HiresViewWidget(); + hrvw->setFile(bf); + descriptor = "HiRes Image Viewer"; + addViewer(descriptor,hrvw); + + MazeViewer *mv = new MazeViewer(); + mv->setFile(file); + descriptor = "MissingRing Maze Viewer"; + addViewer(descriptor,mv); + + DisassemblerViewer *dv = new DisassemblerViewer(); + dv->setFile(bf); + descriptor = "Disassembler Viewer"; + addViewer(descriptor,dv); + defaultViewerDescriptor = descriptor; + + if (bf->filename().toUpper().endsWith(".SET")) + { + defaultViewerDescriptor ="HRCG Character Set Viewer"; + } + if (bf->filename().toUpper().startsWith("MAZE")) + { + defaultViewerDescriptor = "MissingRing Maze Viewer"; + } + if ((bf->address() == 0x2000 || bf->address() == 0x4000) + && bf->length() == 0x2000) + { + defaultViewerDescriptor = "HiRes Image Viewer"; + } + + } + else if (dynamic_cast(file)) + { + TextFile *bf = dynamic_cast(file); + + TextHexDumpViewer *thdv = new TextHexDumpViewer(); + thdv->setFile(bf); + descriptor = QString("Text/Hex Dump Viewer"); + addViewer(descriptor,thdv); + + defaultViewerDescriptor = descriptor; + } + else if (dynamic_cast(file)) + { + DisassemblerViewer *dv = new DisassemblerViewer(); + dv->setFile(file); + descriptor = "Relocatable Disassembler Viewer"; + addViewer(descriptor,dv); + defaultViewerDescriptor = descriptor; + + } + connect(m_viewercombo, static_cast(&QComboBox::currentIndexChanged), + this, &ViewerBase::showViewer); + showViewer(defaultViewerDescriptor); +} + +void ViewerBase::closeEvent(QCloseEvent *event) +{ + event->accept(); +} + +void ViewerBase::addViewer(QString descriptor, FileViewerInterface *viewer) +{ + if (!m_viewers.contains(descriptor)) + { + m_stack->addWidget(viewer); + m_viewers[descriptor] = viewer; + m_viewercombo->addItem(descriptor); + } +} + +void ViewerBase::showViewer(const QString& descriptor) +{ + FileViewerInterface *fvi = m_viewers[descriptor]; + if (fvi) + { + ui->actionExport->disconnect(SIGNAL(triggered(bool))); + ui->actionExport->setEnabled(fvi->canExport()); + connect(ui->actionExport, &QAction::triggered, + fvi, &FileViewerInterface::doExport); + + ui->action_Print->disconnect(SIGNAL(triggered(bool))); + ui->action_Print->setEnabled(fvi->canPrint()); + connect(ui->action_Print, &QAction::triggered, + fvi, &FileViewerInterface::doPrint); + + m_optionMenu->clear(); + m_viewercombo->setCurrentText(descriptor); + m_stack->setCurrentWidget(fvi); + setWindowTitle(fvi->windowTitle()); + + if (m_optionMenu) + { + if (!fvi->optionsMenuItems(m_optionMenu)) + { + m_optionMenu->setEnabled(false); + } + else + { + m_optionMenu->setEnabled(true); + } + } + } + else + { + qDebug() << "Could not find widget for descriptor" << descriptor; + } + +} diff --git a/src/ui/viewers/viewerbase.h b/src/ui/viewers/viewerbase.h index 9c42014..eec9821 100644 --- a/src/ui/viewers/viewerbase.h +++ b/src/ui/viewers/viewerbase.h @@ -1,48 +1,48 @@ -#ifndef VIEWERBASE_H -#define VIEWERBASE_H - -#include -#include -#include -#include - -#include "fileviewerinterface.h" -#include "genericfile.h" - -namespace Ui { -class ViewerBase; -} - -class ViewerBase : public QMainWindow -{ - Q_OBJECT - -public: - explicit ViewerBase(QWidget *parent = 0); - ~ViewerBase(); - - void setFile(GenericFile *file); - -signals: - void viewerClosing(ViewerBase *me); - -public slots: - void showViewer(const QString &descriptor); - -protected: - void closeEvent(QCloseEvent *event); - void addViewer(QString descriptor, FileViewerInterface *viewer); - -private: - Ui::ViewerBase *ui; - QStackedWidget *m_stack; - QToolBar *m_toolbar; - QComboBox *m_viewercombo; - - QMap m_viewers; - GenericFile *m_file; - QMenu *m_optionMenu; - -}; - -#endif // VIEWERBASE_H +#ifndef VIEWERBASE_H +#define VIEWERBASE_H + +#include +#include +#include +#include + +#include "fileviewerinterface.h" +#include "genericfile.h" + +namespace Ui { +class ViewerBase; +} + +class ViewerBase : public QMainWindow +{ + Q_OBJECT + +public: + explicit ViewerBase(QWidget *parent = 0); + ~ViewerBase(); + + void setFile(GenericFile *file); + +signals: + void viewerClosing(ViewerBase *me); + +public slots: + void showViewer(const QString &descriptor); + +protected: + void closeEvent(QCloseEvent *event); + void addViewer(QString descriptor, FileViewerInterface *viewer); + +private: + Ui::ViewerBase *ui; + QStackedWidget *m_stack; + QToolBar *m_toolbar; + QComboBox *m_viewercombo; + + QMap m_viewers; + GenericFile *m_file; + QMenu *m_optionMenu; + +}; + +#endif // VIEWERBASE_H diff --git a/src/ui/viewers/viewerbase.ui b/src/ui/viewers/viewerbase.ui index 38ad91e..2698e67 100644 --- a/src/ui/viewers/viewerbase.ui +++ b/src/ui/viewers/viewerbase.ui @@ -1,62 +1,62 @@ - - - ViewerBase - - - - 0 - 0 - 919 - 609 - - - - MainWindow - - - - - - 0 - 0 - 919 - 21 - - - - - &File - - - - - - - - - - - - false - - - &Print... - - - - - &Close - - - - - false - - - &Export... - - - - - - + + + ViewerBase + + + + 0 + 0 + 919 + 609 + + + + MainWindow + + + + + + 0 + 0 + 919 + 21 + + + + + &File + + + + + + + + + + + + false + + + &Print... + + + + + &Close + + + + + false + + + &Export... + + + + + + diff --git a/src/ui/widgets/CharacterSetExplorer.cpp b/src/ui/widgets/CharacterSetExplorer.cpp index 4786acf..1381524 100644 --- a/src/ui/widgets/CharacterSetExplorer.cpp +++ b/src/ui/widgets/CharacterSetExplorer.cpp @@ -1,83 +1,83 @@ -#include "CharacterSetExplorer.h" -#include "ui_CharacterSetExplorer.h" - -CharacterSetExplorer::CharacterSetExplorer(QWidget *parent) : - QDialog(parent), - ui(new Ui::CharacterSetExplorer) -{ - m_unpackedScreen.fill(0,8192); - ui->setupUi(this); - - connect(ui->insertChar, &QPushButton::clicked, - this, &CharacterSetExplorer::handleInsertCharButton); - connect(ui->inputText, &QLineEdit::textChanged, - this, &CharacterSetExplorer::handleTextChanged); -} - -void CharacterSetExplorer::setCharSet(CharacterSet &charset) -{ - m_charset = charset; -} - -CharacterSetExplorer::~CharacterSetExplorer() -{ - delete ui; -} - -void CharacterSetExplorer::handleInsertCharButton() -{ - //TODO -} - -void CharacterSetExplorer::handleTextChanged(QString string) -{ - int currCursorX = 0; - int currCursorY = 0; - m_unpackedScreen.fill(0x00,8192); - - foreach (QChar character, string) - { - if (character.unicode() < 128) - { - if (character.unicode() < 32) - { - // Handle control character - } - else - { - // Handle ASCII value - if (m_charset.contains(character.unicode())) - { - QByteArray chardata = m_charset[character.unicode()].data(); - - for (int idx = 0; idx < 8; idx++) - { - int baseY = (currCursorY * 8 + idx) * 40; - quint8 chr = chardata[idx]; - m_unpackedScreen[baseY + currCursorX] = chr; - } - currCursorX++; - - if (currCursorX >= 40) { - currCursorY++; - currCursorX = 0; - } - if (currCursorY >= 24) - { - currCursorX = 0; - currCursorY = 0; - } - } - else - { - qDebug() << "Character" << character.unicode() << "not defined in char set"; - } - } - } - else - { - qDebug() << "Unhandled character: " << character.unicode(); - } - } - ui->drawWidget->setUnpackedData(m_unpackedScreen); -} +#include "CharacterSetExplorer.h" +#include "ui_CharacterSetExplorer.h" + +CharacterSetExplorer::CharacterSetExplorer(QWidget *parent) : + QDialog(parent), + ui(new Ui::CharacterSetExplorer) +{ + m_unpackedScreen.fill(0,8192); + ui->setupUi(this); + + connect(ui->insertChar, &QPushButton::clicked, + this, &CharacterSetExplorer::handleInsertCharButton); + connect(ui->inputText, &QLineEdit::textChanged, + this, &CharacterSetExplorer::handleTextChanged); +} + +void CharacterSetExplorer::setCharSet(CharacterSet &charset) +{ + m_charset = charset; +} + +CharacterSetExplorer::~CharacterSetExplorer() +{ + delete ui; +} + +void CharacterSetExplorer::handleInsertCharButton() +{ + //TODO +} + +void CharacterSetExplorer::handleTextChanged(QString string) +{ + int currCursorX = 0; + int currCursorY = 0; + m_unpackedScreen.fill(0x00,8192); + + foreach (QChar character, string) + { + if (character.unicode() < 128) + { + if (character.unicode() < 32) + { + // Handle control character + } + else + { + // Handle ASCII value + if (m_charset.contains(character.unicode())) + { + QByteArray chardata = m_charset[character.unicode()].data(); + + for (int idx = 0; idx < 8; idx++) + { + int baseY = (currCursorY * 8 + idx) * 40; + quint8 chr = chardata[idx]; + m_unpackedScreen[baseY + currCursorX] = chr; + } + currCursorX++; + + if (currCursorX >= 40) { + currCursorY++; + currCursorX = 0; + } + if (currCursorY >= 24) + { + currCursorX = 0; + currCursorY = 0; + } + } + else + { + qDebug() << "Character" << character.unicode() << "not defined in char set"; + } + } + } + else + { + qDebug() << "Unhandled character: " << character.unicode(); + } + } + ui->drawWidget->setUnpackedData(m_unpackedScreen); +} diff --git a/src/ui/widgets/CharacterSetExplorer.h b/src/ui/widgets/CharacterSetExplorer.h index 1b1d322..34fcc17 100644 --- a/src/ui/widgets/CharacterSetExplorer.h +++ b/src/ui/widgets/CharacterSetExplorer.h @@ -1,34 +1,34 @@ -#ifndef CHARACTERSETEXPLORER_H -#define CHARACTERSETEXPLORER_H - -#include - -#include "charset.h" - -namespace Ui { -class CharacterSetExplorer; -} - -class CharacterSetExplorer : public QDialog -{ - Q_OBJECT - -public: - explicit CharacterSetExplorer(QWidget *parent = 0); - ~CharacterSetExplorer(); - - void setCharSet(CharacterSet &charset); - -public slots: - void handleInsertCharButton(); - void handleTextChanged(QString string); - -private: - Ui::CharacterSetExplorer *ui; - - QByteArray m_unpackedScreen; - - CharacterSet m_charset; -}; - -#endif // CHARACTERSETEXPLORER_H +#ifndef CHARACTERSETEXPLORER_H +#define CHARACTERSETEXPLORER_H + +#include + +#include "charset.h" + +namespace Ui { +class CharacterSetExplorer; +} + +class CharacterSetExplorer : public QDialog +{ + Q_OBJECT + +public: + explicit CharacterSetExplorer(QWidget *parent = 0); + ~CharacterSetExplorer(); + + void setCharSet(CharacterSet &charset); + +public slots: + void handleInsertCharButton(); + void handleTextChanged(QString string); + +private: + Ui::CharacterSetExplorer *ui; + + QByteArray m_unpackedScreen; + + CharacterSet m_charset; +}; + +#endif // CHARACTERSETEXPLORER_H diff --git a/src/ui/widgets/CharacterSetExplorer.ui b/src/ui/widgets/CharacterSetExplorer.ui index 68f4d98..4cfa9b4 100644 --- a/src/ui/widgets/CharacterSetExplorer.ui +++ b/src/ui/widgets/CharacterSetExplorer.ui @@ -1,75 +1,75 @@ - - - CharacterSetExplorer - - - - 0 - 0 - 423 - 352 - - - - - 0 - 0 - - - - HRCG Character Set Explorer - - - true - - - - - - - - - - 561 - 384 - - - - - - - - - - Text: - - - - - - - - - - false - - - Insert Char... - - - - - - - - - - HiresScreenWidget - QWidget -
HiresScreenWidget.h
- 1 -
-
- - -
+ + + CharacterSetExplorer + + + + 0 + 0 + 423 + 352 + + + + + 0 + 0 + + + + HRCG Character Set Explorer + + + true + + + + + + + + + + 561 + 384 + + + + + + + + + + Text: + + + + + + + + + + false + + + Insert Char... + + + + + + + + + + HiresScreenWidget + QWidget +
HiresScreenWidget.h
+ 1 +
+
+ + +
diff --git a/src/ui/widgets/DisassemblerMetadataDialog.cpp b/src/ui/widgets/DisassemblerMetadataDialog.cpp index 18cf62b..34004f3 100644 --- a/src/ui/widgets/DisassemblerMetadataDialog.cpp +++ b/src/ui/widgets/DisassemblerMetadataDialog.cpp @@ -1,143 +1,143 @@ -#include "DisassemblerMetadataDialog.h" -#include "ui_DisassemblerMetadataDialog.h" -#include "util.h" -#include - - -DisassemblerMetadataDialog::DisassemblerMetadataDialog(BinaryFileMetadata *bfm, QWidget *parent) : - QDialog(parent), - ui(new Ui::DisassemblerMetadataDialog) -{ - ui->setupUi(this); - ui->entryTable->verticalHeader()->show(); - ui->removeEntryPointButton->setEnabled(false); - ui->removeSymbolButton->setEnabled(false); - - m_bfm = bfm; - - m_epmodel = new EntryPointModel(this,m_bfm->entryPoints()); - m_asmodel = new AssemblerSymbolModel(this,m_bfm->assemblerSymbols()); - - ui->entryTable->setModel(m_epmodel); - ui->symbolTable->setModel(m_asmodel); - - connect(ui->exitButton, &QPushButton::clicked, - this, &DisassemblerMetadataDialog::handleExitButton); - connect(ui->processButton, &QPushButton::clicked, - this, &DisassemblerMetadataDialog::handleProcessButton); - - connect(ui->addEntryPointButton, &QToolButton::clicked, - this, &DisassemblerMetadataDialog::handleAddEntryPointButton); - connect(ui->addSymbolButton, &QToolButton::clicked, - this, &DisassemblerMetadataDialog::handleAddSymbolButton); - - connect(ui->removeEntryPointButton, &QToolButton::clicked, - this, &DisassemblerMetadataDialog::handleRemoveEntryPointButton); - connect(ui->removeSymbolButton, &QToolButton::clicked, - this, &DisassemblerMetadataDialog::handleRemoveSymbolButton); - - connect(ui->entryTable->selectionModel(), &QItemSelectionModel::selectionChanged, - this, &DisassemblerMetadataDialog::handleEntryPointSelectionChanged); - connect(ui->symbolTable->selectionModel(), &QItemSelectionModel::selectionChanged, - this, &DisassemblerMetadataDialog::handleSymbolSelectionChanged); -} - -DisassemblerMetadataDialog::~DisassemblerMetadataDialog() -{ - delete ui; -} - -void DisassemblerMetadataDialog::showEvent(QShowEvent *) -{ - ui->entryTable->resizeRowsToContents(); - ui->symbolTable->resizeRowsToContents(); -} - -void DisassemblerMetadataDialog::handleExitButton() -{ - m_bfm->requestDisassembly(); - m_bfm->save(); - this->close(); -} - -void DisassemblerMetadataDialog::handleProcessButton() -{ - m_bfm->requestDisassembly(); -} - -void DisassemblerMetadataDialog::handleAddEntryPointButton() -{ - LocationInfoDialog lid(this); - lid.setWindowTitle("Add Entry Point"); - if (lid.exec() == Accepted) - { - EntryPoint ep; - ep.address = lid.getAddress(); - ep.note = lid.getInfo(); - m_bfm->entryPoints()->addPoint(ep); - ui->entryTable->resizeRowsToContents(); - ui->entryTable->resizeRowsToContents(); - } -} - -void DisassemblerMetadataDialog::handleRemoveEntryPointButton() -{ - QModelIndexList selection = ui->entryTable->selectionModel()->selectedRows(0); - qDebug() << "Removing" << selection.count() << "row(s)"; - if (selection.count()) - { - // qDebug() << "Removing row" << selection[0].row(); - m_epmodel->removeRows(selection[0].row(),1); -// qDebug() << "Removed row" << selection[0].row(); - } -} - -void DisassemblerMetadataDialog::handleAddSymbolButton() -{ - LocationInfoDialog lid(this); - lid.setInfoLabelString("Symbol Name"); - lid.setWindowTitle("Add Symbol"); - lid.showSizeWidgets(true); - if (lid.exec() == Accepted) - { - AssemblerSymbol as; - as.address = lid.getAddress(); - as.name = lid.getInfo(); - if (lid.getSymbolSize() == 0) // Byte - { - as.symbolsize = SizeByte; - } - else - { - as.symbolsize = SizeWord; - } - m_bfm->assemblerSymbols()->addSymbol(as); - ui->symbolTable->resizeRowsToContents(); - } -} - -void DisassemblerMetadataDialog::handleRemoveSymbolButton() -{ - QModelIndexList selection = ui->symbolTable->selectionModel()->selectedRows(0); - qDebug() << "Removing" << selection.count() << "row(s)"; - if (selection.count()) - { - m_asmodel->removeRows(selection[0].row(),1); - } -} - -void DisassemblerMetadataDialog::handleEntryPointSelectionChanged(QItemSelection selected, QItemSelection deselected) -{ - Q_UNUSED(selected); - Q_UNUSED(deselected); - int selectedcount = ui->entryTable->selectionModel()->selectedRows().count(); - ui->removeEntryPointButton->setEnabled(selectedcount); -} - -void DisassemblerMetadataDialog::handleSymbolSelectionChanged(QItemSelection selected, QItemSelection deselected) -{ - Q_UNUSED(selected); - Q_UNUSED(deselected); - int selectedcount = ui->symbolTable->selectionModel()->selectedRows().count(); - ui->removeSymbolButton->setEnabled(selectedcount); -} +#include "DisassemblerMetadataDialog.h" +#include "ui_DisassemblerMetadataDialog.h" +#include "util.h" +#include + + +DisassemblerMetadataDialog::DisassemblerMetadataDialog(BinaryFileMetadata *bfm, QWidget *parent) : + QDialog(parent), + ui(new Ui::DisassemblerMetadataDialog) +{ + ui->setupUi(this); + ui->entryTable->verticalHeader()->show(); + ui->removeEntryPointButton->setEnabled(false); + ui->removeSymbolButton->setEnabled(false); + + m_bfm = bfm; + + m_epmodel = new EntryPointModel(this,m_bfm->entryPoints()); + m_asmodel = new AssemblerSymbolModel(this,m_bfm->assemblerSymbols()); + + ui->entryTable->setModel(m_epmodel); + ui->symbolTable->setModel(m_asmodel); + + connect(ui->exitButton, &QPushButton::clicked, + this, &DisassemblerMetadataDialog::handleExitButton); + connect(ui->processButton, &QPushButton::clicked, + this, &DisassemblerMetadataDialog::handleProcessButton); + + connect(ui->addEntryPointButton, &QToolButton::clicked, + this, &DisassemblerMetadataDialog::handleAddEntryPointButton); + connect(ui->addSymbolButton, &QToolButton::clicked, + this, &DisassemblerMetadataDialog::handleAddSymbolButton); + + connect(ui->removeEntryPointButton, &QToolButton::clicked, + this, &DisassemblerMetadataDialog::handleRemoveEntryPointButton); + connect(ui->removeSymbolButton, &QToolButton::clicked, + this, &DisassemblerMetadataDialog::handleRemoveSymbolButton); + + connect(ui->entryTable->selectionModel(), &QItemSelectionModel::selectionChanged, + this, &DisassemblerMetadataDialog::handleEntryPointSelectionChanged); + connect(ui->symbolTable->selectionModel(), &QItemSelectionModel::selectionChanged, + this, &DisassemblerMetadataDialog::handleSymbolSelectionChanged); +} + +DisassemblerMetadataDialog::~DisassemblerMetadataDialog() +{ + delete ui; +} + +void DisassemblerMetadataDialog::showEvent(QShowEvent *) +{ + ui->entryTable->resizeRowsToContents(); + ui->symbolTable->resizeRowsToContents(); +} + +void DisassemblerMetadataDialog::handleExitButton() +{ + m_bfm->requestDisassembly(); + m_bfm->save(); + this->close(); +} + +void DisassemblerMetadataDialog::handleProcessButton() +{ + m_bfm->requestDisassembly(); +} + +void DisassemblerMetadataDialog::handleAddEntryPointButton() +{ + LocationInfoDialog lid(this); + lid.setWindowTitle("Add Entry Point"); + if (lid.exec() == Accepted) + { + EntryPoint ep; + ep.address = lid.getAddress(); + ep.note = lid.getInfo(); + m_bfm->entryPoints()->addPoint(ep); + ui->entryTable->resizeRowsToContents(); + ui->entryTable->resizeRowsToContents(); + } +} + +void DisassemblerMetadataDialog::handleRemoveEntryPointButton() +{ + QModelIndexList selection = ui->entryTable->selectionModel()->selectedRows(0); + qDebug() << "Removing" << selection.count() << "row(s)"; + if (selection.count()) + { + // qDebug() << "Removing row" << selection[0].row(); + m_epmodel->removeRows(selection[0].row(),1); +// qDebug() << "Removed row" << selection[0].row(); + } +} + +void DisassemblerMetadataDialog::handleAddSymbolButton() +{ + LocationInfoDialog lid(this); + lid.setInfoLabelString("Symbol Name"); + lid.setWindowTitle("Add Symbol"); + lid.showSizeWidgets(true); + if (lid.exec() == Accepted) + { + AssemblerSymbol as; + as.address = lid.getAddress(); + as.name = lid.getInfo(); + if (lid.getSymbolSize() == 0) // Byte + { + as.symbolsize = SizeByte; + } + else + { + as.symbolsize = SizeWord; + } + m_bfm->assemblerSymbols()->addSymbol(as); + ui->symbolTable->resizeRowsToContents(); + } +} + +void DisassemblerMetadataDialog::handleRemoveSymbolButton() +{ + QModelIndexList selection = ui->symbolTable->selectionModel()->selectedRows(0); + qDebug() << "Removing" << selection.count() << "row(s)"; + if (selection.count()) + { + m_asmodel->removeRows(selection[0].row(),1); + } +} + +void DisassemblerMetadataDialog::handleEntryPointSelectionChanged(QItemSelection selected, QItemSelection deselected) +{ + Q_UNUSED(selected); + Q_UNUSED(deselected); + int selectedcount = ui->entryTable->selectionModel()->selectedRows().count(); + ui->removeEntryPointButton->setEnabled(selectedcount); +} + +void DisassemblerMetadataDialog::handleSymbolSelectionChanged(QItemSelection selected, QItemSelection deselected) +{ + Q_UNUSED(selected); + Q_UNUSED(deselected); + int selectedcount = ui->symbolTable->selectionModel()->selectedRows().count(); + ui->removeSymbolButton->setEnabled(selectedcount); +} diff --git a/src/ui/widgets/DisassemblerMetadataDialog.h b/src/ui/widgets/DisassemblerMetadataDialog.h index c9c3f66..5fbf3a1 100644 --- a/src/ui/widgets/DisassemblerMetadataDialog.h +++ b/src/ui/widgets/DisassemblerMetadataDialog.h @@ -1,56 +1,56 @@ -#ifndef DISASSEMBLERMETADATADIALOG_H -#define DISASSEMBLERMETADATADIALOG_H - -#include "binaryfilemetadata.h" -#include "EntryPoints.h" -#include "EntryPointModel.h" -#include "AssemblerSymbolModel.h" -#include "AssemblerSymbols.h" -#include "LocationInfoDialog.h" - -#include -#include - -namespace Ui { -class DisassemblerMetadataDialog; -} - -class DisassemblerMetadataDialog : public QDialog -{ - Q_OBJECT - -public: - explicit DisassemblerMetadataDialog(BinaryFileMetadata *bfm, QWidget *parent = 0); - ~DisassemblerMetadataDialog(); - -protected: - void showEvent(QShowEvent *); - -protected slots: - void handleExitButton(); - void handleProcessButton(); - - void handleAddEntryPointButton(); - void handleRemoveEntryPointButton(); - - void handleAddSymbolButton(); - void handleRemoveSymbolButton(); - - void handleEntryPointSelectionChanged(QItemSelection selected, QItemSelection deselected); - void handleSymbolSelectionChanged(QItemSelection selected, QItemSelection deselected); - - -private: - Ui::DisassemblerMetadataDialog *ui; - - BinaryFileMetadata *m_bfm; - - EntryPointModel *m_epmodel; - - AssemblerSymbolModel *m_asmodel; - - bool m_isRelocatable; -}; - - -#endif // DISASSEMBLERMETADATADIALOG_H +#ifndef DISASSEMBLERMETADATADIALOG_H +#define DISASSEMBLERMETADATADIALOG_H + +#include "binaryfilemetadata.h" +#include "EntryPoints.h" +#include "EntryPointModel.h" +#include "AssemblerSymbolModel.h" +#include "AssemblerSymbols.h" +#include "LocationInfoDialog.h" + +#include +#include + +namespace Ui { +class DisassemblerMetadataDialog; +} + +class DisassemblerMetadataDialog : public QDialog +{ + Q_OBJECT + +public: + explicit DisassemblerMetadataDialog(BinaryFileMetadata *bfm, QWidget *parent = 0); + ~DisassemblerMetadataDialog(); + +protected: + void showEvent(QShowEvent *); + +protected slots: + void handleExitButton(); + void handleProcessButton(); + + void handleAddEntryPointButton(); + void handleRemoveEntryPointButton(); + + void handleAddSymbolButton(); + void handleRemoveSymbolButton(); + + void handleEntryPointSelectionChanged(QItemSelection selected, QItemSelection deselected); + void handleSymbolSelectionChanged(QItemSelection selected, QItemSelection deselected); + + +private: + Ui::DisassemblerMetadataDialog *ui; + + BinaryFileMetadata *m_bfm; + + EntryPointModel *m_epmodel; + + AssemblerSymbolModel *m_asmodel; + + bool m_isRelocatable; +}; + + +#endif // DISASSEMBLERMETADATADIALOG_H diff --git a/src/ui/widgets/DisassemblerMetadataDialog.ui b/src/ui/widgets/DisassemblerMetadataDialog.ui index 4bce31b..03f63be 100644 --- a/src/ui/widgets/DisassemblerMetadataDialog.ui +++ b/src/ui/widgets/DisassemblerMetadataDialog.ui @@ -1,195 +1,195 @@ - - - DisassemblerMetadataDialog - - - - 0 - 0 - 634 - 429 - - - - Metadata - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Apply - - - - - - - &Exit - - - true - - - - - - - - - 0 - - - - Entry Points - - - - - - Entry Points - - - false - - - false - - - - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - false - - - true - - - false - - - - - - - Remove - - - - - - - Add - - - - - - - Qt::Horizontal - - - - 312 - 20 - - - - - - - - - - - - Symbols - - - - - - Symbols - - - - - - Qt::Horizontal - - - - 311 - 20 - - - - - - - - Add - - - - - - - Remove - - - - - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - false - - - true - - - - - - - - - - - - - - - + + + DisassemblerMetadataDialog + + + + 0 + 0 + 634 + 429 + + + + Metadata + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Apply + + + + + + + &Exit + + + true + + + + + + + + + 0 + + + + Entry Points + + + + + + Entry Points + + + false + + + false + + + + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + true + + + false + + + + + + + Remove + + + + + + + Add + + + + + + + Qt::Horizontal + + + + 312 + 20 + + + + + + + + + + + + Symbols + + + + + + Symbols + + + + + + Qt::Horizontal + + + + 311 + 20 + + + + + + + + Add + + + + + + + Remove + + + + + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + true + + + + + + + + + + + + + + + diff --git a/src/ui/widgets/FlowLineTextBrowser.cpp b/src/ui/widgets/FlowLineTextBrowser.cpp index 158dd54..bfa252f 100644 --- a/src/ui/widgets/FlowLineTextBrowser.cpp +++ b/src/ui/widgets/FlowLineTextBrowser.cpp @@ -1,314 +1,313 @@ -#include "FlowLineTextBrowser.h" - -#include -#include -#include -#include -#include -#include -#include - -FlowLineTextBrowser::FlowLineTextBrowser(QWidget *parent) : QTextBrowser(parent) -{ - m_lineArea = new LineArea(this); - m_jl = Q_NULLPTR; - - updateLineAreaWidth(); -} - -int FlowLineTextBrowser::getFirstVisibleBlock(QTextBlock *firstBlock) const -{ - - QTextCursor curs = QTextCursor(this->document()); - curs.movePosition(QTextCursor::Start); - for(int i=0; i < this->document()->blockCount(); ++i) - { - QTextBlock block = curs.block(); - - QRect r1 = this->viewport()->geometry(); - QRect r2 = this->document()->documentLayout()->blockBoundingRect(block).translated( - this->viewport()->geometry().x(), this->viewport()->geometry().y() - ( - this->verticalScrollBar()->sliderPosition() - ) ).toRect(); - - if (r1.contains(r2, true) || r1.intersects(r2)) - { - // qDebug() << r2; - if (firstBlock) - *firstBlock = block; - return i; - } - - curs.movePosition(QTextCursor::NextBlock); - } - - if (firstBlock) - *firstBlock = QTextBlock(); - return 0; - -} - -void FlowLineTextBrowser::showEvent(QShowEvent *) -{ - this->verticalScrollBar()->setSliderPosition(this->verticalScrollBar()->sliderPosition()); -} - -void FlowLineTextBrowser::lineAreaPaintEvent(QPaintEvent *event) -{ - - QPainter painter(m_lineArea); - painter.fillRect(event->rect(), Qt::lightGray); - - painter.setPen(Qt::red); - painter.setBrush(Qt::red); - - QTextBlock block; - getFirstVisibleBlock(&block); - - // qDebug() << block.text(); - bool foundFirst = false; - quint16 linenum; - - QTextCursor curs = QTextCursor(this->document()); - curs.movePosition(QTextCursor::Start); - bool inBlankLine = false; - // for each visible block - while (isBlockVisible(block) && block.next().isValid()) - { - QString text = block.text(); - if (text.contains(QRegularExpression("[0-9A-Fa-f]{4}:"))) - { - bool ok = true; - quint16 addr = (quint16) text.left(4).toInt(&ok,16); - if (ok) - { - // qDebug() << "Addr:" << uint16ToHex(addr); - linenum = addr; - foundFirst = true; - inBlankLine = false; - } - else - { - // qDebug() << "No address!"; - } - } - else - { - inBlankLine = true; - } - // qDebug() << "Channels:" << m_jl->channelsAtAddress(linenum); - - if (foundFirst) - { - QRect blockRect = getBlockGeometry(block); - float topInY = blockRect.top() + ((1./6.) * blockRect.height()); - float topOutY = blockRect.top() + ((2./6.) * blockRect.height()); - float botOutY = blockRect.top() + ((3./6.) * blockRect.height()); - float botInY = blockRect.top() + ((4./6.) * blockRect.height()); - - // painter.drawLine(0,blockRect.top(),m_lineArea->width(),blockRect.bottom()); - - QList jllist = m_jl->jumpLinesAtAddress(linenum); - - foreach (JumpLine jl, jllist) - { - if (jl.type == IsBranch || jl.type == IsBRA) - { - painter.setPen(Qt::yellow); - painter.setBrush(Qt::yellow); - - } - else if (jl.type == IsJMP) - { - painter.setPen(Qt::white); - painter.setBrush(Qt::white); - - } - else - { - painter.setPen(Qt::red); - painter.setBrush(Qt::red); - } - int offset = getChannelOffset(jl.channel); - if (!inBlankLine) - { - if (jl.from == linenum) - { - if (jl.from == jl.to) - { - painter.drawLine(offset, botInY, - m_lineArea->width(), botInY); - painter.drawLine(offset, botInY, offset, topOutY); - painter.drawLine(offset, topOutY, - m_lineArea->width(), topOutY); - // painter.drawEllipse(QPointF(m_lineArea->width(),topOutY),2,2); - } - else - { - if (jl.isUp()) - { - painter.drawLine(offset, topOutY, - offset, blockRect.top()); - painter.drawLine(offset, topOutY, - m_lineArea->width(), topOutY); - painter.drawEllipse(QPointF(m_lineArea->width(),topOutY),2,2); - } - else - { - painter.drawLine(offset, botOutY, - offset, blockRect.bottom()); - painter.drawLine(offset, botOutY, - m_lineArea->width(), botOutY); - // painter.drawEllipse(QPointF(m_lineArea->width(),botOutY),2,2); - } - } - } - else if (jl.to == linenum) - { - if (jl.isUp()) - { - painter.drawLine(offset, botInY, - offset, blockRect.bottom()); - painter.drawLine(offset, botInY, - m_lineArea->width(), botInY); - - QPolygonF varrow; - varrow.append(QPointF(offset, botInY)); - varrow.append(QPointF(offset-3, botInY+5)); - varrow.append(QPointF(offset+3, botInY+5)); - painter.drawConvexPolygon(varrow); - - - QPolygonF harrow; - harrow.append(QPointF(m_lineArea->width(),botInY)); - harrow.append(QPointF(m_lineArea->width()-4,botInY-3)); - harrow.append(QPointF(m_lineArea->width()-4,botInY+3)); - painter.drawConvexPolygon(harrow); - } - else - { - painter.drawLine(offset, topInY, - offset, blockRect.top()); - painter.drawLine(offset, topInY, - m_lineArea->width(), topInY); - QPolygonF varrow; - varrow.append(QPointF(offset, topInY)); - varrow.append(QPointF(offset-3, topInY-5)); - varrow.append(QPointF(offset+3, topInY-5)); - painter.drawConvexPolygon(varrow); - - QPolygonF harrow; - harrow.append(QPointF(m_lineArea->width(),topInY)); - harrow.append(QPointF(m_lineArea->width()-4,topInY-3)); - harrow.append(QPointF(m_lineArea->width()-4,topInY+3)); - painter.drawConvexPolygon(harrow); - } - } - - if (linenum > jl.min() && linenum < jl.max()) - { - painter.drawLine(offset, blockRect.top(),offset, blockRect.bottom()); - } - } - else // inBlankLine - { - if (jl.from == linenum) - { - if (jl.from != jl.to) - { - if (jl.isDown()) - { - painter.drawLine(offset, blockRect.top(),offset, blockRect.bottom()); - - } - } - } - else if (jl.to == linenum) - { - if (jl.isUp()) - { - painter.drawLine(offset, blockRect.top(),offset, blockRect.bottom()); - } - } - - if (linenum > jl.min() && linenum < jl.max()) - { - painter.drawLine(offset, blockRect.top(),offset, blockRect.bottom()); - } - } - } - } - block = block.next(); - } -} - -QRect FlowLineTextBrowser::getBlockGeometry(QTextBlock block) const -{ - QRect rect = this->document()->documentLayout()->blockBoundingRect(block).translated( - this->viewport()->geometry().x(), this->viewport()->geometry().y() - ( - this->verticalScrollBar()->sliderPosition() - ) ).toRect(); - return rect; -} - -bool FlowLineTextBrowser::isBlockVisible(QTextBlock block) const -{ - QRect r1 = this->viewport()->geometry(); - QRect r2 = this->document()->documentLayout()->blockBoundingRect(block).translated( - this->viewport()->geometry().x(), this->viewport()->geometry().y() - ( - this->verticalScrollBar()->sliderPosition() - ) ).toRect(); - - return (r1.contains(r2, true) || r1.intersects(r2)); -} - -int FlowLineTextBrowser::getChannelOffset(int channel) -{ - int width = lineAreaWidth(); - return width - (channel * 9)- 10; -} - -int FlowLineTextBrowser::lineAreaWidth() -{ - if (!m_jl) return 10; - return m_jl->m_maxChannel* 9 + 20; -} - -void FlowLineTextBrowser::setJumpLines(JumpLines *jl) -{ - m_jl = jl; - m_lineArea->setJumpLines(jl); - updateLineAreaWidth(); -} - -void FlowLineTextBrowser::paintEvent(QPaintEvent *event) -{ - m_lineArea->update(); - QTextBrowser::paintEvent(event); -} - -void FlowLineTextBrowser::resizeEvent(QResizeEvent *event) -{ - QTextBrowser::resizeEvent(event); - - QRect cr = contentsRect(); - m_lineArea->setGeometry(QRect(cr.left(), cr.top(), lineAreaWidth(), cr.height())); -} - -void FlowLineTextBrowser::updateLineAreaWidth() -{ - setViewportMargins(lineAreaWidth(),0,0,0); -} - -void FlowLineTextBrowser::updateLineArea(const QRect &rect, int dy) -{ - if (dy) - m_lineArea->scroll(0, dy); - else - m_lineArea->update(0, rect.y(), m_lineArea->width(), rect.height()); - - if (rect.contains(viewport()->rect())) - updateLineAreaWidth(); -} - -void FlowLineTextBrowser::setLineAreaVisible(bool visible) { m_lineArea->setVisible(visible); } +#include "FlowLineTextBrowser.h" + +#include +#include +#include +#include +#include +#include +#include + +FlowLineTextBrowser::FlowLineTextBrowser(QWidget *parent) : QTextBrowser(parent) +{ + m_lineArea = new LineArea(this); + m_jl = Q_NULLPTR; + + updateLineAreaWidth(); +} + +int FlowLineTextBrowser::getFirstVisibleBlock(QTextBlock *firstBlock) const +{ + QTextCursor curs = QTextCursor(this->document()); + curs.movePosition(QTextCursor::Start); + for(int i=0; i < this->document()->blockCount(); ++i) + { + QTextBlock block = curs.block(); + + QRect r1 = this->viewport()->geometry(); + QRect r2 = this->document()->documentLayout()->blockBoundingRect(block).translated( + this->viewport()->geometry().x(), this->viewport()->geometry().y() - ( + this->verticalScrollBar()->sliderPosition() + ) ).toRect(); + + if (r1.contains(r2, true) || r1.intersects(r2)) + { + // qDebug() << r2; + if (firstBlock) + *firstBlock = block; + return i; + } + + curs.movePosition(QTextCursor::NextBlock); + } + + if (firstBlock) + *firstBlock = QTextBlock(); + + return 0; +} + +void FlowLineTextBrowser::showEvent(QShowEvent *) +{ + this->verticalScrollBar()->setSliderPosition(this->verticalScrollBar()->sliderPosition()); +} + +void FlowLineTextBrowser::lineAreaPaintEvent(QPaintEvent *event) +{ + + QPainter painter(m_lineArea); + painter.fillRect(event->rect(), Qt::lightGray); + + painter.setPen(Qt::red); + painter.setBrush(Qt::red); + + QTextBlock block; + getFirstVisibleBlock(&block); + + // qDebug() << block.text(); + bool foundFirst = false; + quint16 linenum; + + QTextCursor curs = QTextCursor(this->document()); + curs.movePosition(QTextCursor::Start); + bool inBlankLine = false; + // for each visible block + while (isBlockVisible(block) && block.next().isValid()) + { + QString text = block.text(); + if (text.contains(QRegularExpression("[0-9A-Fa-f]{4}:"))) + { + bool ok = true; + quint16 addr = (quint16) text.left(4).toInt(&ok,16); + if (ok) + { + // qDebug() << "Addr:" << uint16ToHex(addr); + linenum = addr; + foundFirst = true; + inBlankLine = false; + } + else + { + // qDebug() << "No address!"; + } + } + else + { + inBlankLine = true; + } + // qDebug() << "Channels:" << m_jl->channelsAtAddress(linenum); + + if (foundFirst) + { + QRect blockRect = getBlockGeometry(block); + float topInY = blockRect.top() + ((1./6.) * blockRect.height()); + float topOutY = blockRect.top() + ((2./6.) * blockRect.height()); + float botOutY = blockRect.top() + ((3./6.) * blockRect.height()); + float botInY = blockRect.top() + ((4./6.) * blockRect.height()); + + // painter.drawLine(0,blockRect.top(),m_lineArea->width(),blockRect.bottom()); + + QList jllist = m_jl->jumpLinesAtAddress(linenum); + + foreach (JumpLine jl, jllist) + { + if (jl.type == IsBranch || jl.type == IsBRA) + { + painter.setPen(Qt::yellow); + painter.setBrush(Qt::yellow); + + } + else if (jl.type == IsJMP) + { + painter.setPen(Qt::white); + painter.setBrush(Qt::white); + + } + else + { + painter.setPen(Qt::red); + painter.setBrush(Qt::red); + } + int offset = getChannelOffset(jl.channel); + if (!inBlankLine) + { + if (jl.from == linenum) + { + if (jl.from == jl.to) + { + painter.drawLine(offset, botInY, + m_lineArea->width(), botInY); + painter.drawLine(offset, botInY, offset, topOutY); + painter.drawLine(offset, topOutY, + m_lineArea->width(), topOutY); + // painter.drawEllipse(QPointF(m_lineArea->width(),topOutY),2,2); + } + else + { + if (jl.isUp()) + { + painter.drawLine(offset, topOutY, + offset, blockRect.top()); + painter.drawLine(offset, topOutY, + m_lineArea->width(), topOutY); + painter.drawEllipse(QPointF(m_lineArea->width(),topOutY),2,2); + } + else + { + painter.drawLine(offset, botOutY, + offset, blockRect.bottom()); + painter.drawLine(offset, botOutY, + m_lineArea->width(), botOutY); + // painter.drawEllipse(QPointF(m_lineArea->width(),botOutY),2,2); + } + } + } + else if (jl.to == linenum) + { + if (jl.isUp()) + { + painter.drawLine(offset, botInY, + offset, blockRect.bottom()); + painter.drawLine(offset, botInY, + m_lineArea->width(), botInY); + + QPolygonF varrow; + varrow.append(QPointF(offset, botInY)); + varrow.append(QPointF(offset-3, botInY+5)); + varrow.append(QPointF(offset+3, botInY+5)); + painter.drawConvexPolygon(varrow); + + + QPolygonF harrow; + harrow.append(QPointF(m_lineArea->width(),botInY)); + harrow.append(QPointF(m_lineArea->width()-4,botInY-3)); + harrow.append(QPointF(m_lineArea->width()-4,botInY+3)); + painter.drawConvexPolygon(harrow); + } + else + { + painter.drawLine(offset, topInY, + offset, blockRect.top()); + painter.drawLine(offset, topInY, + m_lineArea->width(), topInY); + QPolygonF varrow; + varrow.append(QPointF(offset, topInY)); + varrow.append(QPointF(offset-3, topInY-5)); + varrow.append(QPointF(offset+3, topInY-5)); + painter.drawConvexPolygon(varrow); + + QPolygonF harrow; + harrow.append(QPointF(m_lineArea->width(),topInY)); + harrow.append(QPointF(m_lineArea->width()-4,topInY-3)); + harrow.append(QPointF(m_lineArea->width()-4,topInY+3)); + painter.drawConvexPolygon(harrow); + } + } + + if (linenum > jl.min() && linenum < jl.max()) + { + painter.drawLine(offset, blockRect.top(),offset, blockRect.bottom()); + } + } + else // inBlankLine + { + if (jl.from == linenum) + { + if (jl.from != jl.to) + { + if (jl.isDown()) + { + painter.drawLine(offset, blockRect.top(),offset, blockRect.bottom()); + + } + } + } + else if (jl.to == linenum) + { + if (jl.isUp()) + { + painter.drawLine(offset, blockRect.top(),offset, blockRect.bottom()); + } + } + + if (linenum > jl.min() && linenum < jl.max()) + { + painter.drawLine(offset, blockRect.top(),offset, blockRect.bottom()); + } + } + } + } + block = block.next(); + } +} + +QRect FlowLineTextBrowser::getBlockGeometry(QTextBlock block) const +{ + QRect rect = this->document()->documentLayout()->blockBoundingRect(block).translated( + this->viewport()->geometry().x(), this->viewport()->geometry().y() - ( + this->verticalScrollBar()->sliderPosition() + ) ).toRect(); + return rect; +} + +bool FlowLineTextBrowser::isBlockVisible(QTextBlock block) const +{ + QRect r1 = this->viewport()->geometry(); + QRect r2 = this->document()->documentLayout()->blockBoundingRect(block).translated( + this->viewport()->geometry().x(), this->viewport()->geometry().y() - ( + this->verticalScrollBar()->sliderPosition() + ) ).toRect(); + + return (r1.contains(r2, true) || r1.intersects(r2)); +} + +int FlowLineTextBrowser::getChannelOffset(int channel) +{ + int width = lineAreaWidth(); + return width - (channel * 9)- 10; +} + +int FlowLineTextBrowser::lineAreaWidth() +{ + if (!m_jl) return 10; + return m_jl->m_maxChannel* 9 + 20; +} + +void FlowLineTextBrowser::setJumpLines(JumpLines *jl) +{ + m_jl = jl; + m_lineArea->setJumpLines(jl); + updateLineAreaWidth(); +} + +void FlowLineTextBrowser::paintEvent(QPaintEvent *event) +{ + m_lineArea->update(); + QTextBrowser::paintEvent(event); +} + +void FlowLineTextBrowser::resizeEvent(QResizeEvent *event) +{ + QTextBrowser::resizeEvent(event); + + QRect cr = contentsRect(); + m_lineArea->setGeometry(QRect(cr.left(), cr.top(), lineAreaWidth(), cr.height())); +} + +void FlowLineTextBrowser::updateLineAreaWidth() +{ + setViewportMargins(lineAreaWidth(),0,0,0); +} + +void FlowLineTextBrowser::updateLineArea(const QRect &rect, int dy) +{ + if (dy) + m_lineArea->scroll(0, dy); + else + m_lineArea->update(0, rect.y(), m_lineArea->width(), rect.height()); + + if (rect.contains(viewport()->rect())) + updateLineAreaWidth(); +} + +void FlowLineTextBrowser::setLineAreaVisible(bool visible) { m_lineArea->setVisible(visible); } diff --git a/src/ui/widgets/FlowLineTextBrowser.h b/src/ui/widgets/FlowLineTextBrowser.h index 0f51e70..ee96e12 100644 --- a/src/ui/widgets/FlowLineTextBrowser.h +++ b/src/ui/widgets/FlowLineTextBrowser.h @@ -1,77 +1,77 @@ -#ifndef FLOWLINETEXTBROWSER_H -#define FLOWLINETEXTBROWSER_H - -#include "JumpLineManager.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class LineArea; - -class FlowLineTextBrowser : public QTextBrowser -{ -public: - FlowLineTextBrowser(QWidget *parent = Q_NULLPTR); - - void lineAreaPaintEvent(QPaintEvent *event); - int lineAreaWidth(); - - void setJumpLines(JumpLines *jl); - -protected: - void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; - void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; - - int getFirstVisibleBlock(QTextBlock *firstBlock) const; - - int getChannelOffset(int channel); - QRect getBlockGeometry(QTextBlock block) const; - bool isBlockVisible(QTextBlock block) const; - void showEvent(QShowEvent *) Q_DECL_OVERRIDE; -private slots: - void updateLineAreaWidth(); - void updateLineArea(const QRect &, int); - -public slots: - void setLineAreaVisible(bool visible); - -private: - LineArea *m_lineArea; - - JumpLines *m_jl; -}; - -class LineArea : public QWidget -{ -public: - LineArea(FlowLineTextBrowser *browser) : QWidget(browser) - { - m_browser = browser; - } - - void setJumpLines(JumpLines *jl) { m_jl = jl; } - - QSize sizeHint() const Q_DECL_OVERRIDE - { - return QSize(m_browser->lineAreaWidth(),0); - } -protected: - void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE - { - m_browser->lineAreaPaintEvent(event); - } - -private: - FlowLineTextBrowser *m_browser; - JumpLines *m_jl; -}; - - -#endif // FLOWLINETEXTBROWSER_H +#ifndef FLOWLINETEXTBROWSER_H +#define FLOWLINETEXTBROWSER_H + +#include "JumpLineManager.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class LineArea; + +class FlowLineTextBrowser : public QTextBrowser +{ +public: + FlowLineTextBrowser(QWidget *parent = Q_NULLPTR); + + void lineAreaPaintEvent(QPaintEvent *event); + int lineAreaWidth(); + + void setJumpLines(JumpLines *jl); + +protected: + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; + void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE; + + int getFirstVisibleBlock(QTextBlock *firstBlock) const; + + int getChannelOffset(int channel); + QRect getBlockGeometry(QTextBlock block) const; + bool isBlockVisible(QTextBlock block) const; + void showEvent(QShowEvent *) Q_DECL_OVERRIDE; +private slots: + void updateLineAreaWidth(); + void updateLineArea(const QRect &, int); + +public slots: + void setLineAreaVisible(bool visible); + +private: + LineArea *m_lineArea; + + JumpLines *m_jl; +}; + +class LineArea : public QWidget +{ +public: + LineArea(FlowLineTextBrowser *browser) : QWidget(browser) + { + m_browser = browser; + } + + void setJumpLines(JumpLines *jl) { m_jl = jl; } + + QSize sizeHint() const Q_DECL_OVERRIDE + { + return QSize(m_browser->lineAreaWidth(),0); + } +protected: + void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE + { + m_browser->lineAreaPaintEvent(event); + } + +private: + FlowLineTextBrowser *m_browser; + JumpLines *m_jl; +}; + + +#endif // FLOWLINETEXTBROWSER_H diff --git a/src/ui/widgets/HiresScreenWidget.cpp b/src/ui/widgets/HiresScreenWidget.cpp index bb61a82..899e087 100644 --- a/src/ui/widgets/HiresScreenWidget.cpp +++ b/src/ui/widgets/HiresScreenWidget.cpp @@ -1,608 +1,608 @@ -#include "HiresScreenWidget.h" - -#include "binaryfile.h" - -#include -#include -#include -#include -#include - -#include "util.h" - -#include - - -HiresScreenWidget::HiresScreenWidget(QWidget *parent) : - QWidget(parent) -{ - if (m_rawAddressToColRowList.size() == 0 || - m_appleAddressToColRowList.size() == 0) - { - makeAddressTables(); - } - - resize(561,384); - QSettings settings; - m_viewMode = static_cast(settings.value("HiresScreenWidget.ViewMode",NTSCColor).toInt()); - m_showScanLines = settings.value("HiresScreenWidget.ShowScanLines",true).toBool(); - - m_pixmap = QPixmap(561,384); - QPainter painter(&m_pixmap); - painter.setBrush(Qt::black); - painter.drawRect(0,0,this->width(),this->height()); - - formatGroup = new QActionGroup(this); - - m_monochromeAction = new QAction("Monochrome Display",this); - m_monochromeAction->setCheckable(true); - m_monochromeAction->setChecked((m_viewMode == Monochrome)); - formatGroup->addAction(m_monochromeAction); - - m_ntscAction = new QAction("NTSC Display",this); - m_ntscAction->setCheckable(true); - m_ntscAction->setChecked((m_viewMode == NTSCColor)); - formatGroup->addAction(m_ntscAction); - - m_perPixelColorAction= new QAction("Per-Pixel Color Display",this); - m_perPixelColorAction->setCheckable(true); - m_perPixelColorAction->setChecked((m_viewMode == PerPixelColor)); - formatGroup->addAction(m_perPixelColorAction); - - m_showScanLinesAction = new QAction("Show Scan Lines",this); - m_showScanLinesAction->setCheckable(true); - m_showScanLinesAction->setChecked(m_showScanLines); - - m_prevPageAction = new QAction("Previous Data Page"); - m_prevPageAction->setEnabled(false); - m_prevPageAction->setShortcut(QKeySequence(Qt::Key_Left | Qt::CTRL)); - - m_nextPageAction = new QAction("Next Data Page"); - m_nextPageAction->setEnabled(false); - m_nextPageAction->setShortcut(QKeySequence(Qt::Key_Right | Qt::CTRL)); - - connect(m_ntscAction, &QAction::toggled, this, &HiresScreenWidget::handleNtscAction); - connect(m_monochromeAction, &QAction::toggled, this, &HiresScreenWidget::handleMonochromeAction); - connect(m_perPixelColorAction, &QAction::toggled, this, &HiresScreenWidget::handlePerPixelColorAction); - - - connect(m_showScanLinesAction, &QAction::toggled, - this, &HiresScreenWidget::handleShowScanLinesAction); - - connect(m_prevPageAction, &QAction::triggered, - this, &HiresScreenWidget::handlePrevPageAction); - connect(m_nextPageAction, &QAction::triggered, - this, &HiresScreenWidget::handleNextPageAction); - - - m_offset = 0; -} - -void HiresScreenWidget::handleNtscAction(bool toggled) { - if (toggled) { - m_viewMode = NTSCColor; - update(); - } - QSettings settings; - settings.setValue("HiresScreenWidget.ViewMode",m_viewMode); -} - -void HiresScreenWidget::handleMonochromeAction(bool toggled) { - if (toggled) { - m_viewMode = Monochrome; - update(); - } - QSettings settings; - settings.setValue("HiresScreenWidget.ViewMode",m_viewMode); -} - -void HiresScreenWidget::handlePerPixelColorAction(bool toggled) { - if (toggled) { - m_viewMode = PerPixelColor; - update(); - } - QSettings settings; - settings.setValue("HiresScreenWidget.ViewMode",m_viewMode); -} - -void HiresScreenWidget::handleShowScanLinesAction(bool toggled) { - m_showScanLines = toggled; - update(); - QSettings settings; - settings.setValue("HiresScreenWidget.ShowScanLines",toggled); -} - - -void HiresScreenWidget::paintEvent(QPaintEvent *event) -{ - Q_UNUSED(event); - - // if (m_pixmap.size() != this->size()) { - // m_pixmap = m_pixmap.scaled(this->size(),Qt::KeepAspectRatio); - // } - - drawPixmap(); - - QPainter painter(this); - - QPixmap tmppixmap = m_pixmap; - // tmppixmap = tmppixmap.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); - - painter.drawPixmap(0,0,tmppixmap); -} - -void HiresScreenWidget::resizeEvent(QResizeEvent *) -{ - -} - -void HiresScreenWidget::drawPixmap() -{ - QPainter pmpainter(&m_pixmap); - - QByteArray workingdata = m_data.mid(m_offset); - - pmpainter.setBrush(Qt::black); - pmpainter.setPen(Qt::black); - pmpainter.drawRect(0,0,m_pixmap.width(),m_pixmap.height()); - - if (m_viewMode == Monochrome || m_viewMode == NTSCColor) - { - pmpainter.setPen(Qt::white); - pmpainter.setBrush(Qt::white); - - quint8 chunkCount = 0; - - int idx = 0; - while (idx < qMin(workingdata.size(),8192)) { - ColRow cr = getColRowFromAppleAddress(idx); - - int yoff = cr.row(); - - QBitArray bits(561,false); - int bitoffset = 0; - bool lastbit = false; - - for (int jdx = 0; jdx < 40; jdx++) - { - - quint8 byte = workingdata[idx++]; - QBitArray dataBits = byteToBits(byte); - - bool highBit = dataBits.at(0); - - if (highBit) { - bits[bitoffset++] = lastbit; - } - - for (int xdx = 1; xdx < 7; xdx++) { - bits[bitoffset++] = dataBits.at(xdx); - bits[bitoffset++] = dataBits.at(xdx); - } - lastbit = dataBits.at(7); - bits[bitoffset++] = dataBits.at(7); - if (!highBit) { - bits[bitoffset++] = dataBits.at(7); - } - - - } - - if (m_viewMode == Monochrome) - { - drawMonoLine(pmpainter, yoff*2, bits); - if (!m_showScanLines) drawMonoLine(pmpainter, yoff*2+1, bits); - } - else if (m_viewMode == NTSCColor) - { - drawNtscLine(pmpainter, yoff*2, bits); - if (!m_showScanLines) drawNtscLine(pmpainter, yoff*2+1, bits); - } - - - chunkCount++; - if (chunkCount == 3) { - chunkCount = 0; - idx+=8; // Skip screen hole - } - - } - } - else if (m_viewMode == PerPixelColor) - { - pmpainter.setPen(Qt::white); - pmpainter.setBrush(Qt::white); - - for (int idx = 0; idx < qMin(workingdata.size(),8192) ; idx++) { - ColRow cr = getColRowFromAppleAddress(idx); - - quint8 byte = workingdata[idx]; - - bool highBit = byte & 0x80; - - QColor oddColor = highBit? QColor(orangeColor) : QColor(greenColor); - QColor evenColor = highBit? QColor(blueColor) : QColor(purpleColor); - - int xoff = cr.col() * 7; - int yoff = cr.row() * 2; - - quint8 cOffset = highBit?1:0; - - quint8 doubleScan = 0; - if (!m_showScanLines) - { - doubleScan = 1; - } - - qDebug() << (byte & 0x01) << (byte & 0x02) << (byte & 0x04) << (byte & 0x08) - << (byte & 0x10) << (byte & 0x20) << (byte & 0x40) << "HI: " << (byte & 0x80); - - pmpainter.setPen(xoff & 0x01?oddColor:evenColor); - pmpainter.setBrush(xoff & 0x01?oddColor:evenColor); - - if (byte & 0x01) { pmpainter.drawRect((cOffset+xoff*2)+0,yoff,1,doubleScan); } - - pmpainter.setPen(xoff & 0x01?evenColor:oddColor); - pmpainter.setBrush(xoff & 0x01?evenColor:oddColor); - - if (byte & 0x02) { pmpainter.drawRect((cOffset+xoff*2)+2,yoff,1,doubleScan); } - - pmpainter.setPen(xoff & 0x01?oddColor:evenColor); - pmpainter.setBrush(xoff & 0x01?oddColor:evenColor); - - if (byte & 0x04) { pmpainter.drawRect((cOffset+xoff*2)+4,yoff,1,doubleScan); } - - pmpainter.setPen(xoff & 0x01?evenColor:oddColor); - pmpainter.setBrush(xoff & 0x01?evenColor:oddColor); - - if (byte & 0x08) { pmpainter.drawRect((cOffset+xoff*2)+6,yoff,1,doubleScan); } - - pmpainter.setPen(xoff & 0x01?oddColor:evenColor); - pmpainter.setBrush(xoff & 0x01?oddColor:evenColor); - - if (byte & 0x10) { pmpainter.drawRect((cOffset+xoff*2)+8,yoff,1,doubleScan); } - - pmpainter.setPen(xoff & 0x01?evenColor:oddColor); - pmpainter.setBrush(xoff & 0x01?evenColor:oddColor); - - if (byte & 0x20) { pmpainter.drawRect((cOffset+xoff*2)+10,yoff,1,doubleScan); } - - pmpainter.setPen(xoff & 0x01?oddColor:evenColor); - pmpainter.setBrush(xoff & 0x01?oddColor:evenColor); - - if (byte & 0x40) { pmpainter.drawRect((cOffset+xoff*2)+12,yoff,1,doubleScan); } - - - - if (idx >= (280*192)) break; - } - - } - -} - -void HiresScreenWidget::setUnpackedData(QByteArray unpackedData) -{ - QByteArray packedData = packData(unpackedData); - setData(packedData); -} - -void HiresScreenWidget::setOffset(quint16 offset) -{ - m_offset = offset; - emit newOffset(m_offset); - update(); -} - -quint16 HiresScreenWidget::offset() const { return m_offset; } - -void HiresScreenWidget::handlePrevPageAction(bool) -{ - if (m_offset >= 8192) - { - setOffset(m_offset - 8192); - m_nextPageAction->setEnabled(true); - } - - if (m_offset == 0) { m_prevPageAction->setEnabled(false); } -} - -void HiresScreenWidget::handleNextPageAction(bool) -{ - if (m_offset+8192 <= m_data.size()) - { - setOffset(m_offset+8192); - m_prevPageAction->setEnabled(true); - } - - if (m_offset+8192 > m_data.size()) - { - m_nextPageAction->setEnabled(false); - } -} - - - -QByteArray HiresScreenWidget::packData(QByteArray unpackedData) -{ - QByteArray packedData; - packedData.resize(8192); - packedData.fill(0x00); - - for (int idx = 0; idx < qMin(unpackedData.count(),8192); idx++) - { - ColRow cr = getColRowFromRawAddress(idx); - - if (cr.isDefined()) - { - packedData[cr.appleAddress()] = unpackedData[idx]; - } - } - - return packedData; -} - -int HiresScreenWidget::getLineAddressOffset(int line) -{ - static QList blockOffset { - 0x0000, 0x0080, 0x0100, 0x0180, 0x0200, 0x0280, 0x0300, 0x0380, - 0x0028, 0x00A0, 0x0128, 0x01A8, 0x0228, 0x02A8, 0x0328, 0x03A8, - 0x0040, 0x00D0, 0x0150, 0x00D0, 0x0250, 0x02D0, 0x0350, 0x03D0 - }; - - static QList boxSub { - 0x0000, 0x0400, 0x0800, 0x0C00, 0x1000, 0x1400, 0x1800, 0x1C00 - }; - - int block = line / 8; - int sub = line % 8; - - return blockOffset[block] + boxSub[sub]; -} - -void HiresScreenWidget::setData(QByteArray data) { - m_data = data; - - if (data.size() > 8192) - { - m_nextPageAction->setEnabled(true); - m_prevPageAction->setEnabled(false); - m_offset = 0; - } - else - { - m_nextPageAction->setEnabled(false); - m_prevPageAction->setEnabled(false); - m_offset = 0; - } - - - repaint(); -} - -void HiresScreenWidget::drawMonoLine(QPainter &painter, int lineNum, QBitArray data) { - painter.setPen(Qt::black); - painter.drawLine(0,lineNum,data.count(),lineNum); - painter.setPen(Qt::white); - for (int idx = 0; idx < data.count(); idx++) { - - if (data.at(idx)) - painter.drawPoint(idx,lineNum); - } -} - -void HiresScreenWidget::drawPerPositionColorLine(QPainter &painter, int lineNum, QBitArray data) { - painter.setPen(Qt::black); - painter.drawLine(0,lineNum,data.count(),lineNum); - - QList colorlist; - colorlist << QColor(orangeColor) << QColor(purpleColor) << QColor(blueColor) << QColor(greenColor); - - for (int idx = 0; idx < data.count(); idx++) - { - painter.setPen(colorlist[idx % 4]); - painter.setBrush(colorlist[idx % 4]); - - if (data.at(idx)) - { - painter.drawPoint(idx,lineNum); - } - } -} - -QColor HiresScreenWidget::getColorFromBits(QBitArray bits, quint8 phase) -{ - quint8 bitval = (bits[0] * 0x08) + - (bits[1] * 0x04) + - (bits[2] * 0x02) + - (bits[3] * 0x01); - - phase %= 4; - - if (bitval == 0) { return blackColor; } - - if (bitval == 1 && phase == 0) return brownColor; - if (bitval == 2 && phase == 1) return brownColor; - if (bitval == 4 && phase == 2) return brownColor; - if (bitval == 8 && phase == 3) return brownColor; - - if (bitval == 2 && phase == 0) return darkGreenColor; - if (bitval == 4 && phase == 1) return darkGreenColor; - if (bitval == 8 && phase == 2) return darkGreenColor; - if (bitval == 1 && phase == 3) return darkGreenColor; - - if (bitval == 3 && phase == 0) return greenColor; - if (bitval == 6 && phase == 1) return greenColor; - if (bitval == 12 && phase == 2) return greenColor; - if (bitval == 9 && phase == 3) return greenColor; - - if (bitval == 4 && phase == 0) return darkBlueColor; - if (bitval == 8 && phase == 1) return darkBlueColor; - if (bitval == 1 && phase == 2) return darkBlueColor; - if (bitval == 2 && phase == 3) return darkBlueColor; - - if (bitval == 5 && phase == 0) return grayColor; - if (bitval == 10 && phase == 1) return grayColor; - if (bitval == 5 && phase == 2) return grayColor; - if (bitval == 10 && phase == 3) return grayColor; - - if (bitval == 6 && phase == 0) return blueColor; - if (bitval == 12 && phase == 1) return blueColor; - if (bitval == 9 && phase == 2) return blueColor; - if (bitval == 3 && phase == 3) return blueColor; - - if (bitval == 7 && phase == 0) return aquaColor; - if (bitval == 14 && phase == 1) return aquaColor; - if (bitval == 13 && phase == 2) return aquaColor; - if (bitval == 11 && phase == 3) return aquaColor; - - if (bitval == 8 && phase == 0) return redColor; - if (bitval == 1 && phase == 1) return redColor; - if (bitval == 2 && phase == 2) return redColor; - if (bitval == 4 && phase == 3) return redColor; - - if (bitval == 9 && phase == 0) return orangeColor; - if (bitval == 3 && phase == 1) return orangeColor; - if (bitval == 6 && phase == 2) return orangeColor; - if (bitval == 12 && phase == 3) return orangeColor; - - if (bitval == 10 && phase == 0) return gray2Color; - if (bitval == 5 && phase == 1) return gray2Color; - if (bitval == 10 && phase == 2) return gray2Color; - if (bitval == 5 && phase == 3) return gray2Color; - - if (bitval == 11 && phase == 0) return yellowColor; - if (bitval == 7 && phase == 1) return yellowColor; - if (bitval == 14 && phase == 2) return yellowColor; - if (bitval == 13 && phase == 3) return yellowColor; - - if (bitval == 12 && phase == 0) return purpleColor; - if (bitval == 9 && phase == 1) return purpleColor; - if (bitval == 3 && phase == 2) return purpleColor; - if (bitval == 6 && phase == 3) return purpleColor; - - if (bitval == 13 && phase == 0) return pinkColor; - if (bitval == 11 && phase == 1) return pinkColor; - if (bitval == 7 && phase == 2) return pinkColor; - if (bitval == 14 && phase == 3) return pinkColor; - - if (bitval == 14 && phase == 0) return lightBlueColor; - if (bitval == 13 && phase == 1) return lightBlueColor; - if (bitval == 11 && phase == 2) return lightBlueColor; - if (bitval == 7 && phase == 3) return lightBlueColor; - - return whiteColor; -} - -void HiresScreenWidget::drawNtscLine(QPainter &painter, int lineNum, QBitArray data) { - QVector colors; - colors.resize(data.count()+3); - - for (int idx = 0; idx < data.count(); idx++) { - QBitArray tmp(4); - tmp[0]=data.at(idx+0); - if (idx < data.count()-1) tmp[1]=data.at(idx+1); else tmp[1] = false; - if (idx < data.count()-2) tmp[2]=data.at(idx+2); else tmp[2] = false; - if (idx < data.count()-3) tmp[3]=data.at(idx+3); else tmp[3] = false; - colors[idx] = getColorFromBits(tmp,idx %4); - colors[idx+1] = getColorFromBits(tmp,idx %4); - colors[idx+2] = getColorFromBits(tmp,idx %4); - colors[idx+3] = getColorFromBits(tmp,idx %4); - } - - for (int idx = 0; idx < colors.count(); idx++) - { - painter.setPen(colors.at(idx)); - painter.setBrush(colors.at(idx)); - painter.drawPoint(idx,lineNum); - } -} - - -QBitArray HiresScreenWidget::byteToBits(quint8 byte) { - QBitArray bits(8); - bits.setBit(0,byte & 0x80); - bits.setBit(7,byte & 0x40); - bits.setBit(6,byte & 0x20); - bits.setBit(5,byte & 0x10); - bits.setBit(4,byte & 0x08); - bits.setBit(3,byte & 0x04); - bits.setBit(2,byte & 0x02); - bits.setBit(1,byte & 0x01); - return bits; -} - -void HiresScreenWidget::setMode(HiresScreenWidget::ViewMode viewmode) -{ - m_viewMode = viewmode; - update(); -} - -void HiresScreenWidget::contextMenuEvent(QContextMenuEvent *event) { - QMenu menu(this); - menu.addAction(m_monochromeAction); - menu.addAction(m_ntscAction); - menu.addAction(m_perPixelColorAction); - menu.addSeparator(); - menu.addAction(m_showScanLinesAction); - menu.addSeparator(); - menu.addAction(prevPageAction()); - menu.addAction(nextPageAction()); - menu.exec(event->globalPos()); -} - -HiresScreenWidget::ColRow HiresScreenWidget::getColRowFromAppleAddress(quint16 address) -{ - if (address > 8191) { - qDebug() << "Invalid apple address " << address; - address = 8191; - } - return m_appleAddressToColRowList[address]; -} - -HiresScreenWidget::ColRow HiresScreenWidget::getColRowFromRawAddress(quint16 address) -{ - if (address > 8191) { - qDebug() << "Invalid raw address " << address; - address = 8191; - } - return m_rawAddressToColRowList[address]; -} - -void HiresScreenWidget::makeAddressTables() -{ - m_rawAddressToColRowList.resize(8192); - m_appleAddressToColRowList.resize(8192); - - for (int row = 0; row < 192; row++) - { - for (int col = 0; col < 40; col++) - { - ColRow cr(col,row); - - m_rawAddressToColRowList[cr.rawAddress()] = cr; - m_appleAddressToColRowList[cr.appleAddress()] = cr; - } - } - -#ifdef DEBUGHOLES - int num = 0; - quint16 lasthole = 0; - for (int idx = 0; idx < 8192; idx++) - { - if (!m_appleAddressToColRowList[idx].isDefined()) - { - if (lasthole != 0 && lasthole != (idx-1)) { qDebug() << "\n"; } - qDebug() << "Hole" << num << "at" << idx+0x2000 << uint16ToHex(idx+0x2000); ; - num++; - lasthole = idx; - } - } -#endif -} - - -QVector HiresScreenWidget::m_rawAddressToColRowList -= QVector(); -QVector HiresScreenWidget::m_appleAddressToColRowList -= QVector(); +#include "HiresScreenWidget.h" + +#include "binaryfile.h" + +#include +#include +#include +#include +#include + +#include "util.h" + +#include + + +HiresScreenWidget::HiresScreenWidget(QWidget *parent) : + QWidget(parent) +{ + if (m_rawAddressToColRowList.size() == 0 || + m_appleAddressToColRowList.size() == 0) + { + makeAddressTables(); + } + + resize(561,384); + QSettings settings; + m_viewMode = static_cast(settings.value("HiresScreenWidget.ViewMode",NTSCColor).toInt()); + m_showScanLines = settings.value("HiresScreenWidget.ShowScanLines",true).toBool(); + + m_pixmap = QPixmap(561,384); + QPainter painter(&m_pixmap); + painter.setBrush(Qt::black); + painter.drawRect(0,0,this->width(),this->height()); + + formatGroup = new QActionGroup(this); + + m_monochromeAction = new QAction("Monochrome Display",this); + m_monochromeAction->setCheckable(true); + m_monochromeAction->setChecked((m_viewMode == Monochrome)); + formatGroup->addAction(m_monochromeAction); + + m_ntscAction = new QAction("NTSC Display",this); + m_ntscAction->setCheckable(true); + m_ntscAction->setChecked((m_viewMode == NTSCColor)); + formatGroup->addAction(m_ntscAction); + + m_perPixelColorAction= new QAction("Per-Pixel Color Display",this); + m_perPixelColorAction->setCheckable(true); + m_perPixelColorAction->setChecked((m_viewMode == PerPixelColor)); + formatGroup->addAction(m_perPixelColorAction); + + m_showScanLinesAction = new QAction("Show Scan Lines",this); + m_showScanLinesAction->setCheckable(true); + m_showScanLinesAction->setChecked(m_showScanLines); + + m_prevPageAction = new QAction("Previous Data Page"); + m_prevPageAction->setEnabled(false); + m_prevPageAction->setShortcut(QKeySequence(Qt::Key_Left | Qt::CTRL)); + + m_nextPageAction = new QAction("Next Data Page"); + m_nextPageAction->setEnabled(false); + m_nextPageAction->setShortcut(QKeySequence(Qt::Key_Right | Qt::CTRL)); + + connect(m_ntscAction, &QAction::toggled, this, &HiresScreenWidget::handleNtscAction); + connect(m_monochromeAction, &QAction::toggled, this, &HiresScreenWidget::handleMonochromeAction); + connect(m_perPixelColorAction, &QAction::toggled, this, &HiresScreenWidget::handlePerPixelColorAction); + + + connect(m_showScanLinesAction, &QAction::toggled, + this, &HiresScreenWidget::handleShowScanLinesAction); + + connect(m_prevPageAction, &QAction::triggered, + this, &HiresScreenWidget::handlePrevPageAction); + connect(m_nextPageAction, &QAction::triggered, + this, &HiresScreenWidget::handleNextPageAction); + + + m_offset = 0; +} + +void HiresScreenWidget::handleNtscAction(bool toggled) { + if (toggled) { + m_viewMode = NTSCColor; + update(); + } + QSettings settings; + settings.setValue("HiresScreenWidget.ViewMode",m_viewMode); +} + +void HiresScreenWidget::handleMonochromeAction(bool toggled) { + if (toggled) { + m_viewMode = Monochrome; + update(); + } + QSettings settings; + settings.setValue("HiresScreenWidget.ViewMode",m_viewMode); +} + +void HiresScreenWidget::handlePerPixelColorAction(bool toggled) { + if (toggled) { + m_viewMode = PerPixelColor; + update(); + } + QSettings settings; + settings.setValue("HiresScreenWidget.ViewMode",m_viewMode); +} + +void HiresScreenWidget::handleShowScanLinesAction(bool toggled) { + m_showScanLines = toggled; + update(); + QSettings settings; + settings.setValue("HiresScreenWidget.ShowScanLines",toggled); +} + + +void HiresScreenWidget::paintEvent(QPaintEvent *event) +{ + Q_UNUSED(event); + + // if (m_pixmap.size() != this->size()) { + // m_pixmap = m_pixmap.scaled(this->size(),Qt::KeepAspectRatio); + // } + + drawPixmap(); + + QPainter painter(this); + + QPixmap tmppixmap = m_pixmap; + // tmppixmap = tmppixmap.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); + + painter.drawPixmap(0,0,tmppixmap); +} + +void HiresScreenWidget::resizeEvent(QResizeEvent *) +{ + +} + +void HiresScreenWidget::drawPixmap() +{ + QPainter pmpainter(&m_pixmap); + + QByteArray workingdata = m_data.mid(m_offset); + + pmpainter.setBrush(Qt::black); + pmpainter.setPen(Qt::black); + pmpainter.drawRect(0,0,m_pixmap.width(),m_pixmap.height()); + + if (m_viewMode == Monochrome || m_viewMode == NTSCColor) + { + pmpainter.setPen(Qt::white); + pmpainter.setBrush(Qt::white); + + quint8 chunkCount = 0; + + int idx = 0; + while (idx < qMin(workingdata.size(),8192)) { + ColRow cr = getColRowFromAppleAddress(idx); + + int yoff = cr.row(); + + QBitArray bits(561,false); + int bitoffset = 0; + bool lastbit = false; + + for (int jdx = 0; jdx < 40; jdx++) + { + + quint8 byte = workingdata[idx++]; + QBitArray dataBits = byteToBits(byte); + + bool highBit = dataBits.at(0); + + if (highBit) { + bits[bitoffset++] = lastbit; + } + + for (int xdx = 1; xdx < 7; xdx++) { + bits[bitoffset++] = dataBits.at(xdx); + bits[bitoffset++] = dataBits.at(xdx); + } + lastbit = dataBits.at(7); + bits[bitoffset++] = dataBits.at(7); + if (!highBit) { + bits[bitoffset++] = dataBits.at(7); + } + + + } + + if (m_viewMode == Monochrome) + { + drawMonoLine(pmpainter, yoff*2, bits); + if (!m_showScanLines) drawMonoLine(pmpainter, yoff*2+1, bits); + } + else if (m_viewMode == NTSCColor) + { + drawNtscLine(pmpainter, yoff*2, bits); + if (!m_showScanLines) drawNtscLine(pmpainter, yoff*2+1, bits); + } + + + chunkCount++; + if (chunkCount == 3) { + chunkCount = 0; + idx+=8; // Skip screen hole + } + + } + } + else if (m_viewMode == PerPixelColor) + { + pmpainter.setPen(Qt::white); + pmpainter.setBrush(Qt::white); + + for (int idx = 0; idx < qMin(workingdata.size(),8192) ; idx++) { + ColRow cr = getColRowFromAppleAddress(idx); + + quint8 byte = workingdata[idx]; + + bool highBit = byte & 0x80; + + QColor oddColor = highBit? QColor(orangeColor) : QColor(greenColor); + QColor evenColor = highBit? QColor(blueColor) : QColor(purpleColor); + + int xoff = cr.col() * 7; + int yoff = cr.row() * 2; + + quint8 cOffset = highBit?1:0; + + quint8 doubleScan = 0; + if (!m_showScanLines) + { + doubleScan = 1; + } + + qDebug() << (byte & 0x01) << (byte & 0x02) << (byte & 0x04) << (byte & 0x08) + << (byte & 0x10) << (byte & 0x20) << (byte & 0x40) << "HI: " << (byte & 0x80); + + pmpainter.setPen(xoff & 0x01?oddColor:evenColor); + pmpainter.setBrush(xoff & 0x01?oddColor:evenColor); + + if (byte & 0x01) { pmpainter.drawRect((cOffset+xoff*2)+0,yoff,1,doubleScan); } + + pmpainter.setPen(xoff & 0x01?evenColor:oddColor); + pmpainter.setBrush(xoff & 0x01?evenColor:oddColor); + + if (byte & 0x02) { pmpainter.drawRect((cOffset+xoff*2)+2,yoff,1,doubleScan); } + + pmpainter.setPen(xoff & 0x01?oddColor:evenColor); + pmpainter.setBrush(xoff & 0x01?oddColor:evenColor); + + if (byte & 0x04) { pmpainter.drawRect((cOffset+xoff*2)+4,yoff,1,doubleScan); } + + pmpainter.setPen(xoff & 0x01?evenColor:oddColor); + pmpainter.setBrush(xoff & 0x01?evenColor:oddColor); + + if (byte & 0x08) { pmpainter.drawRect((cOffset+xoff*2)+6,yoff,1,doubleScan); } + + pmpainter.setPen(xoff & 0x01?oddColor:evenColor); + pmpainter.setBrush(xoff & 0x01?oddColor:evenColor); + + if (byte & 0x10) { pmpainter.drawRect((cOffset+xoff*2)+8,yoff,1,doubleScan); } + + pmpainter.setPen(xoff & 0x01?evenColor:oddColor); + pmpainter.setBrush(xoff & 0x01?evenColor:oddColor); + + if (byte & 0x20) { pmpainter.drawRect((cOffset+xoff*2)+10,yoff,1,doubleScan); } + + pmpainter.setPen(xoff & 0x01?oddColor:evenColor); + pmpainter.setBrush(xoff & 0x01?oddColor:evenColor); + + if (byte & 0x40) { pmpainter.drawRect((cOffset+xoff*2)+12,yoff,1,doubleScan); } + + + + if (idx >= (280*192)) break; + } + + } + +} + +void HiresScreenWidget::setUnpackedData(QByteArray unpackedData) +{ + QByteArray packedData = packData(unpackedData); + setData(packedData); +} + +void HiresScreenWidget::setOffset(quint16 offset) +{ + m_offset = offset; + emit newOffset(m_offset); + update(); +} + +quint16 HiresScreenWidget::offset() const { return m_offset; } + +void HiresScreenWidget::handlePrevPageAction(bool) +{ + if (m_offset >= 8192) + { + setOffset(m_offset - 8192); + m_nextPageAction->setEnabled(true); + } + + if (m_offset == 0) { m_prevPageAction->setEnabled(false); } +} + +void HiresScreenWidget::handleNextPageAction(bool) +{ + if (m_offset+8192 <= m_data.size()) + { + setOffset(m_offset+8192); + m_prevPageAction->setEnabled(true); + } + + if (m_offset+8192 > m_data.size()) + { + m_nextPageAction->setEnabled(false); + } +} + + + +QByteArray HiresScreenWidget::packData(QByteArray unpackedData) +{ + QByteArray packedData; + packedData.resize(8192); + packedData.fill(0x00); + + for (int idx = 0; idx < qMin(unpackedData.count(),8192); idx++) + { + ColRow cr = getColRowFromRawAddress(idx); + + if (cr.isDefined()) + { + packedData[cr.appleAddress()] = unpackedData[idx]; + } + } + + return packedData; +} + +int HiresScreenWidget::getLineAddressOffset(int line) +{ + static QList blockOffset { + 0x0000, 0x0080, 0x0100, 0x0180, 0x0200, 0x0280, 0x0300, 0x0380, + 0x0028, 0x00A0, 0x0128, 0x01A8, 0x0228, 0x02A8, 0x0328, 0x03A8, + 0x0040, 0x00D0, 0x0150, 0x00D0, 0x0250, 0x02D0, 0x0350, 0x03D0 + }; + + static QList boxSub { + 0x0000, 0x0400, 0x0800, 0x0C00, 0x1000, 0x1400, 0x1800, 0x1C00 + }; + + int block = line / 8; + int sub = line % 8; + + return blockOffset[block] + boxSub[sub]; +} + +void HiresScreenWidget::setData(QByteArray data) { + m_data = data; + + if (data.size() > 8192) + { + m_nextPageAction->setEnabled(true); + m_prevPageAction->setEnabled(false); + m_offset = 0; + } + else + { + m_nextPageAction->setEnabled(false); + m_prevPageAction->setEnabled(false); + m_offset = 0; + } + + + repaint(); +} + +void HiresScreenWidget::drawMonoLine(QPainter &painter, int lineNum, QBitArray data) { + painter.setPen(Qt::black); + painter.drawLine(0,lineNum,data.count(),lineNum); + painter.setPen(Qt::white); + for (int idx = 0; idx < data.count(); idx++) { + + if (data.at(idx)) + painter.drawPoint(idx,lineNum); + } +} + +void HiresScreenWidget::drawPerPositionColorLine(QPainter &painter, int lineNum, QBitArray data) { + painter.setPen(Qt::black); + painter.drawLine(0,lineNum,data.count(),lineNum); + + QList colorlist; + colorlist << QColor(orangeColor) << QColor(purpleColor) << QColor(blueColor) << QColor(greenColor); + + for (int idx = 0; idx < data.count(); idx++) + { + painter.setPen(colorlist[idx % 4]); + painter.setBrush(colorlist[idx % 4]); + + if (data.at(idx)) + { + painter.drawPoint(idx,lineNum); + } + } +} + +QColor HiresScreenWidget::getColorFromBits(QBitArray bits, quint8 phase) +{ + quint8 bitval = (bits[0] * 0x08) + + (bits[1] * 0x04) + + (bits[2] * 0x02) + + (bits[3] * 0x01); + + phase %= 4; + + if (bitval == 0) { return blackColor; } + + if (bitval == 1 && phase == 0) return brownColor; + if (bitval == 2 && phase == 1) return brownColor; + if (bitval == 4 && phase == 2) return brownColor; + if (bitval == 8 && phase == 3) return brownColor; + + if (bitval == 2 && phase == 0) return darkGreenColor; + if (bitval == 4 && phase == 1) return darkGreenColor; + if (bitval == 8 && phase == 2) return darkGreenColor; + if (bitval == 1 && phase == 3) return darkGreenColor; + + if (bitval == 3 && phase == 0) return greenColor; + if (bitval == 6 && phase == 1) return greenColor; + if (bitval == 12 && phase == 2) return greenColor; + if (bitval == 9 && phase == 3) return greenColor; + + if (bitval == 4 && phase == 0) return darkBlueColor; + if (bitval == 8 && phase == 1) return darkBlueColor; + if (bitval == 1 && phase == 2) return darkBlueColor; + if (bitval == 2 && phase == 3) return darkBlueColor; + + if (bitval == 5 && phase == 0) return grayColor; + if (bitval == 10 && phase == 1) return grayColor; + if (bitval == 5 && phase == 2) return grayColor; + if (bitval == 10 && phase == 3) return grayColor; + + if (bitval == 6 && phase == 0) return blueColor; + if (bitval == 12 && phase == 1) return blueColor; + if (bitval == 9 && phase == 2) return blueColor; + if (bitval == 3 && phase == 3) return blueColor; + + if (bitval == 7 && phase == 0) return aquaColor; + if (bitval == 14 && phase == 1) return aquaColor; + if (bitval == 13 && phase == 2) return aquaColor; + if (bitval == 11 && phase == 3) return aquaColor; + + if (bitval == 8 && phase == 0) return redColor; + if (bitval == 1 && phase == 1) return redColor; + if (bitval == 2 && phase == 2) return redColor; + if (bitval == 4 && phase == 3) return redColor; + + if (bitval == 9 && phase == 0) return orangeColor; + if (bitval == 3 && phase == 1) return orangeColor; + if (bitval == 6 && phase == 2) return orangeColor; + if (bitval == 12 && phase == 3) return orangeColor; + + if (bitval == 10 && phase == 0) return gray2Color; + if (bitval == 5 && phase == 1) return gray2Color; + if (bitval == 10 && phase == 2) return gray2Color; + if (bitval == 5 && phase == 3) return gray2Color; + + if (bitval == 11 && phase == 0) return yellowColor; + if (bitval == 7 && phase == 1) return yellowColor; + if (bitval == 14 && phase == 2) return yellowColor; + if (bitval == 13 && phase == 3) return yellowColor; + + if (bitval == 12 && phase == 0) return purpleColor; + if (bitval == 9 && phase == 1) return purpleColor; + if (bitval == 3 && phase == 2) return purpleColor; + if (bitval == 6 && phase == 3) return purpleColor; + + if (bitval == 13 && phase == 0) return pinkColor; + if (bitval == 11 && phase == 1) return pinkColor; + if (bitval == 7 && phase == 2) return pinkColor; + if (bitval == 14 && phase == 3) return pinkColor; + + if (bitval == 14 && phase == 0) return lightBlueColor; + if (bitval == 13 && phase == 1) return lightBlueColor; + if (bitval == 11 && phase == 2) return lightBlueColor; + if (bitval == 7 && phase == 3) return lightBlueColor; + + return whiteColor; +} + +void HiresScreenWidget::drawNtscLine(QPainter &painter, int lineNum, QBitArray data) { + QVector colors; + colors.resize(data.count()+3); + + for (int idx = 0; idx < data.count(); idx++) { + QBitArray tmp(4); + tmp[0]=data.at(idx+0); + if (idx < data.count()-1) tmp[1]=data.at(idx+1); else tmp[1] = false; + if (idx < data.count()-2) tmp[2]=data.at(idx+2); else tmp[2] = false; + if (idx < data.count()-3) tmp[3]=data.at(idx+3); else tmp[3] = false; + colors[idx] = getColorFromBits(tmp,idx %4); + colors[idx+1] = getColorFromBits(tmp,idx %4); + colors[idx+2] = getColorFromBits(tmp,idx %4); + colors[idx+3] = getColorFromBits(tmp,idx %4); + } + + for (int idx = 0; idx < colors.count(); idx++) + { + painter.setPen(colors.at(idx)); + painter.setBrush(colors.at(idx)); + painter.drawPoint(idx,lineNum); + } +} + + +QBitArray HiresScreenWidget::byteToBits(quint8 byte) { + QBitArray bits(8); + bits.setBit(0,byte & 0x80); + bits.setBit(7,byte & 0x40); + bits.setBit(6,byte & 0x20); + bits.setBit(5,byte & 0x10); + bits.setBit(4,byte & 0x08); + bits.setBit(3,byte & 0x04); + bits.setBit(2,byte & 0x02); + bits.setBit(1,byte & 0x01); + return bits; +} + +void HiresScreenWidget::setMode(HiresScreenWidget::ViewMode viewmode) +{ + m_viewMode = viewmode; + update(); +} + +void HiresScreenWidget::contextMenuEvent(QContextMenuEvent *event) { + QMenu menu(this); + menu.addAction(m_monochromeAction); + menu.addAction(m_ntscAction); + menu.addAction(m_perPixelColorAction); + menu.addSeparator(); + menu.addAction(m_showScanLinesAction); + menu.addSeparator(); + menu.addAction(prevPageAction()); + menu.addAction(nextPageAction()); + menu.exec(event->globalPos()); +} + +HiresScreenWidget::ColRow HiresScreenWidget::getColRowFromAppleAddress(quint16 address) +{ + if (address > 8191) { + qDebug() << "Invalid apple address " << address; + address = 8191; + } + return m_appleAddressToColRowList[address]; +} + +HiresScreenWidget::ColRow HiresScreenWidget::getColRowFromRawAddress(quint16 address) +{ + if (address > 8191) { + qDebug() << "Invalid raw address " << address; + address = 8191; + } + return m_rawAddressToColRowList[address]; +} + +void HiresScreenWidget::makeAddressTables() +{ + m_rawAddressToColRowList.resize(8192); + m_appleAddressToColRowList.resize(8192); + + for (int row = 0; row < 192; row++) + { + for (int col = 0; col < 40; col++) + { + ColRow cr(col,row); + + m_rawAddressToColRowList[cr.rawAddress()] = cr; + m_appleAddressToColRowList[cr.appleAddress()] = cr; + } + } + +#ifdef DEBUGHOLES + int num = 0; + quint16 lasthole = 0; + for (int idx = 0; idx < 8192; idx++) + { + if (!m_appleAddressToColRowList[idx].isDefined()) + { + if (lasthole != 0 && lasthole != (idx-1)) { qDebug() << "\n"; } + qDebug() << "Hole" << num << "at" << idx+0x2000 << uint16ToHex(idx+0x2000); ; + num++; + lasthole = idx; + } + } +#endif +} + + +QVector HiresScreenWidget::m_rawAddressToColRowList += QVector(); +QVector HiresScreenWidget::m_appleAddressToColRowList += QVector(); diff --git a/src/ui/widgets/HiresScreenWidget.h b/src/ui/widgets/HiresScreenWidget.h index a878d52..11f624e 100644 --- a/src/ui/widgets/HiresScreenWidget.h +++ b/src/ui/widgets/HiresScreenWidget.h @@ -1,146 +1,146 @@ -#ifndef HIRESSCREENWIDGET_H -#define HIRESSCREENWIDGET_H - -#include "binaryfile.h" -#include "AppleColors.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class HiresScreenWidget : public QWidget -{ - Q_OBJECT -public: - - class ColRow { - public: - ColRow() { m_col = 0; m_row = 0; m_undefined = true; } - ColRow(quint8 col, quint8 row) { setColRow(col,row); } - void setColRow(quint8 col, quint8 row) { m_col = col; m_row = row; calc(); } - - quint8 col() const { return m_col; } - quint8 row() const { return m_row; } - - bool isDefined() const { return !m_undefined; } - bool isUndefined() const { return m_undefined; } - - quint16 appleAddress() { return m_appleAddress; } - quint16 rawAddress() { return m_rawAddress; } - - private: - quint8 m_col; - quint8 m_row; - - quint16 m_appleAddress; - quint16 m_rawAddress; - bool m_undefined; - - void calc() { - if (m_col > 39) { qDebug() << "Col out of range: " << m_col; m_col = 39; } - if (m_row > 191) { qDebug() << "Row out of range: " << m_row; m_row = 191; } - - m_rawAddress = (m_row*40) + m_col; - - unsigned short blockOffset[] = { - 0x0000, 0x0080, 0x0100, 0x0180, 0x0200, 0x0280, 0x0300, 0x0380, - 0x0028, 0x00A8, 0x0128, 0x01A8, 0x0228, 0x02A8, 0x0328, 0x03A8, - 0x0050, 0x00D0, 0x0150, 0x01D0, 0x0250, 0x02D0, 0x0350, 0x03D0 - }; - - unsigned short boxSub[] = { - 0x0000, 0x0400, 0x0800, 0x0C00, 0x1000, 0x1400, 0x1800, 0x1C00 - }; - - m_appleAddress = blockOffset[m_row/8]+boxSub[m_row%8] + m_col; - m_undefined = false; - } - - }; - - enum ViewMode { - Monochrome, - PerPixelColor, - NTSCColor - }; - - explicit HiresScreenWidget(QWidget *parent = 0); - void paintEvent(QPaintEvent *event); - - void resizeEvent(QResizeEvent *event); - - static QBitArray byteToBits(quint8 byte); - void contextMenuEvent(QContextMenuEvent *); - - QAction *monochromeAction() { return m_monochromeAction; } - QAction *ntscAction() { return m_ntscAction; } - QAction *perPixelColorAction() { return m_perPixelColorAction; } - QAction *showScanLinesAction() { return m_showScanLinesAction; } - QAction *prevPageAction() { return m_prevPageAction; } - QAction *nextPageAction() { return m_nextPageAction; } - - ColRow getColRowFromAppleAddress(quint16 address); - ColRow getColRowFromRawAddress(quint16 address); - - QPixmap getPixmap() const { return m_pixmap; } - - quint16 offset() const; -signals: - void newOffset(quint16 offset); - -public slots: - void setData(QByteArray data); - void setMode(ViewMode); - void setUnpackedData(QByteArray unpackedData); - void setOffset(quint16 offset); -protected: - int getLineAddressOffset(int line); - QByteArray packData(QByteArray unpackedData); - -protected slots: - void handleNtscAction(bool toggled); - void handleMonochromeAction(bool toggled); - void handlePerPixelColorAction(bool toggled); - void handleShowScanLinesAction(bool toggled); - - void handlePrevPageAction(bool); - void handleNextPageAction(bool); - -private: - void makeAddressTables(); - QColor getColorFromBits(QBitArray bits, quint8 phase); - void drawNtscLine(QPainter &painter,int linenum, QBitArray data); - void drawMonoLine(QPainter &painter, int lineNum, QBitArray data); - void drawPerPositionColorLine(QPainter &painter, int lineNum, QBitArray data); - void drawPixmap(); - - - QPixmap m_pixmap; - QByteArray m_data; - - ViewMode m_viewMode; - - QAction *m_monochromeAction; - QAction *m_ntscAction; - QAction *m_perPixelColorAction; - QAction *m_showScanLinesAction; - QAction *m_prevPageAction; - QAction *m_nextPageAction; - QActionGroup *formatGroup; - - bool m_showScanLines; - - static QVector m_rawAddressToColRowList; - static QVector m_appleAddressToColRowList; - - quint16 m_offset; -}; - -#endif // HIRESSCREENWIDGET_H +#ifndef HIRESSCREENWIDGET_H +#define HIRESSCREENWIDGET_H + +#include "binaryfile.h" +#include "AppleColors.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class HiresScreenWidget : public QWidget +{ + Q_OBJECT +public: + + class ColRow { + public: + ColRow() { m_col = 0; m_row = 0; m_undefined = true; } + ColRow(quint8 col, quint8 row) { setColRow(col,row); } + void setColRow(quint8 col, quint8 row) { m_col = col; m_row = row; calc(); } + + quint8 col() const { return m_col; } + quint8 row() const { return m_row; } + + bool isDefined() const { return !m_undefined; } + bool isUndefined() const { return m_undefined; } + + quint16 appleAddress() { return m_appleAddress; } + quint16 rawAddress() { return m_rawAddress; } + + private: + quint8 m_col; + quint8 m_row; + + quint16 m_appleAddress; + quint16 m_rawAddress; + bool m_undefined; + + void calc() { + if (m_col > 39) { qDebug() << "Col out of range: " << m_col; m_col = 39; } + if (m_row > 191) { qDebug() << "Row out of range: " << m_row; m_row = 191; } + + m_rawAddress = (m_row*40) + m_col; + + unsigned short blockOffset[] = { + 0x0000, 0x0080, 0x0100, 0x0180, 0x0200, 0x0280, 0x0300, 0x0380, + 0x0028, 0x00A8, 0x0128, 0x01A8, 0x0228, 0x02A8, 0x0328, 0x03A8, + 0x0050, 0x00D0, 0x0150, 0x01D0, 0x0250, 0x02D0, 0x0350, 0x03D0 + }; + + unsigned short boxSub[] = { + 0x0000, 0x0400, 0x0800, 0x0C00, 0x1000, 0x1400, 0x1800, 0x1C00 + }; + + m_appleAddress = blockOffset[m_row/8]+boxSub[m_row%8] + m_col; + m_undefined = false; + } + + }; + + enum ViewMode { + Monochrome, + PerPixelColor, + NTSCColor + }; + + explicit HiresScreenWidget(QWidget *parent = 0); + void paintEvent(QPaintEvent *event); + + void resizeEvent(QResizeEvent *event); + + static QBitArray byteToBits(quint8 byte); + void contextMenuEvent(QContextMenuEvent *); + + QAction *monochromeAction() { return m_monochromeAction; } + QAction *ntscAction() { return m_ntscAction; } + QAction *perPixelColorAction() { return m_perPixelColorAction; } + QAction *showScanLinesAction() { return m_showScanLinesAction; } + QAction *prevPageAction() { return m_prevPageAction; } + QAction *nextPageAction() { return m_nextPageAction; } + + ColRow getColRowFromAppleAddress(quint16 address); + ColRow getColRowFromRawAddress(quint16 address); + + QPixmap getPixmap() const { return m_pixmap; } + + quint16 offset() const; +signals: + void newOffset(quint16 offset); + +public slots: + void setData(QByteArray data); + void setMode(ViewMode); + void setUnpackedData(QByteArray unpackedData); + void setOffset(quint16 offset); +protected: + int getLineAddressOffset(int line); + QByteArray packData(QByteArray unpackedData); + +protected slots: + void handleNtscAction(bool toggled); + void handleMonochromeAction(bool toggled); + void handlePerPixelColorAction(bool toggled); + void handleShowScanLinesAction(bool toggled); + + void handlePrevPageAction(bool); + void handleNextPageAction(bool); + +private: + void makeAddressTables(); + QColor getColorFromBits(QBitArray bits, quint8 phase); + void drawNtscLine(QPainter &painter,int linenum, QBitArray data); + void drawMonoLine(QPainter &painter, int lineNum, QBitArray data); + void drawPerPositionColorLine(QPainter &painter, int lineNum, QBitArray data); + void drawPixmap(); + + + QPixmap m_pixmap; + QByteArray m_data; + + ViewMode m_viewMode; + + QAction *m_monochromeAction; + QAction *m_ntscAction; + QAction *m_perPixelColorAction; + QAction *m_showScanLinesAction; + QAction *m_prevPageAction; + QAction *m_nextPageAction; + QActionGroup *formatGroup; + + bool m_showScanLines; + + static QVector m_rawAddressToColRowList; + static QVector m_appleAddressToColRowList; + + quint16 m_offset; +}; + +#endif // HIRESSCREENWIDGET_H diff --git a/src/ui/widgets/LocationInfoDialog.cpp b/src/ui/widgets/LocationInfoDialog.cpp index 3bf4694..c8863da 100644 --- a/src/ui/widgets/LocationInfoDialog.cpp +++ b/src/ui/widgets/LocationInfoDialog.cpp @@ -1,41 +1,41 @@ -#include "LocationInfoDialog.h" -#include "ui_LocationInfoDialog.h" - -LocationInfoDialog::LocationInfoDialog(QWidget *parent) : - QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowTitleHint ), - ui(new Ui::LocationInfoDialog) -{ - ui->setupUi(this); - showSizeWidgets(false); -} - -LocationInfoDialog::~LocationInfoDialog() -{ - delete ui; -} - -void LocationInfoDialog::setInfoLabelString(QString label) -{ - ui->infoLabel->setText(label); -} - -quint16 LocationInfoDialog::getAddress() -{ - return ui->addressEdit->text().toInt(Q_NULLPTR,16); -} - -QString LocationInfoDialog::getInfo() -{ - return ui->infoEdit->text(); -} - -int LocationInfoDialog::getSymbolSize() -{ - return ui->sizeCombo->currentIndex(); -} - -void LocationInfoDialog::showSizeWidgets(bool show) -{ - ui->sizeCombo->setHidden(!show); - ui->sizeLabel->setHidden(!show); -} +#include "LocationInfoDialog.h" +#include "ui_LocationInfoDialog.h" + +LocationInfoDialog::LocationInfoDialog(QWidget *parent) : + QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowTitleHint ), + ui(new Ui::LocationInfoDialog) +{ + ui->setupUi(this); + showSizeWidgets(false); +} + +LocationInfoDialog::~LocationInfoDialog() +{ + delete ui; +} + +void LocationInfoDialog::setInfoLabelString(QString label) +{ + ui->infoLabel->setText(label); +} + +quint16 LocationInfoDialog::getAddress() +{ + return ui->addressEdit->text().toInt(Q_NULLPTR,16); +} + +QString LocationInfoDialog::getInfo() +{ + return ui->infoEdit->text(); +} + +int LocationInfoDialog::getSymbolSize() +{ + return ui->sizeCombo->currentIndex(); +} + +void LocationInfoDialog::showSizeWidgets(bool show) +{ + ui->sizeCombo->setHidden(!show); + ui->sizeLabel->setHidden(!show); +} diff --git a/src/ui/widgets/LocationInfoDialog.h b/src/ui/widgets/LocationInfoDialog.h index cda38b7..07ad181 100644 --- a/src/ui/widgets/LocationInfoDialog.h +++ b/src/ui/widgets/LocationInfoDialog.h @@ -1,32 +1,32 @@ -#ifndef LOCATIONINFODIALOG_H -#define LOCATIONINFODIALOG_H - -#include -#include - -namespace Ui { -class LocationInfoDialog; -} - -class LocationInfoDialog : public QDialog -{ - Q_OBJECT - -public: - explicit LocationInfoDialog(QWidget *parent = 0); - ~LocationInfoDialog(); - - void setInfoLabelString(QString label); - quint16 getAddress(); - QString getInfo(); - int getSymbolSize(); - - void showSizeWidgets(bool show); - -protected: - -private: - Ui::LocationInfoDialog *ui; -}; - -#endif // LOCATIONINFODIALOG_H +#ifndef LOCATIONINFODIALOG_H +#define LOCATIONINFODIALOG_H + +#include +#include + +namespace Ui { +class LocationInfoDialog; +} + +class LocationInfoDialog : public QDialog +{ + Q_OBJECT + +public: + explicit LocationInfoDialog(QWidget *parent = 0); + ~LocationInfoDialog(); + + void setInfoLabelString(QString label); + quint16 getAddress(); + QString getInfo(); + int getSymbolSize(); + + void showSizeWidgets(bool show); + +protected: + +private: + Ui::LocationInfoDialog *ui; +}; + +#endif // LOCATIONINFODIALOG_H diff --git a/src/ui/widgets/LocationInfoDialog.ui b/src/ui/widgets/LocationInfoDialog.ui index aa0226f..6fd7eec 100644 --- a/src/ui/widgets/LocationInfoDialog.ui +++ b/src/ui/widgets/LocationInfoDialog.ui @@ -1,119 +1,119 @@ - - - LocationInfoDialog - - - - 0 - 0 - 284 - 162 - - - - Address Metadata Info - - - - - - - - Address - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - HHHH - - - - - - - Note - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - - - Size - - - - - - - - Byte - - - - - Word - - - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - - buttonBox - accepted() - LocationInfoDialog - accept() - - - 248 - 254 - - - 157 - 274 - - - - - buttonBox - rejected() - LocationInfoDialog - reject() - - - 316 - 260 - - - 286 - 274 - - - - - + + + LocationInfoDialog + + + + 0 + 0 + 284 + 162 + + + + Address Metadata Info + + + + + + + + Address + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + HHHH + + + + + + + Note + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + + + + Size + + + + + + + + Byte + + + + + Word + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + LocationInfoDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + LocationInfoDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/ui/widgets/asciiinfodialog.h b/src/ui/widgets/asciiinfodialog.h index 65cde13..7c25cfe 100644 --- a/src/ui/widgets/asciiinfodialog.h +++ b/src/ui/widgets/asciiinfodialog.h @@ -1,62 +1,61 @@ -#ifndef ASCIIINFODIALOG_H -#define ASCIIINFODIALOG_H - -#include -#include "asciiinfodialog.h" -#include "ui_asciiinfodialog.h" - -namespace Ui { -class AsciiInfoDialog; -} - -class AsciiInfoDialog : public QDialog -{ - Q_OBJECT - -public: - explicit AsciiInfoDialog(QWidget *parent = 0) : - QDialog(parent), - ui(new Ui::AsciiInfoDialog) - { - ui->setupUi(this); - QFont font = ui->tableWidget->itemAt(0,0)->font(); - font.setBold(true); - for (int idx = 0; idx < ui->tableWidget->rowCount(); idx++) - { -// ui->tableWidget->item(idx,5 )->setFont(font); -// ui->tableWidget->item(idx,6 )->setFont(font); -// ui->tableWidget->item(idx,7 )->setFont(font); -// ui->tableWidget->item(idx,8 )->setFont(font); -// ui->tableWidget->item(idx,9 )->setFont(font); - } - - - for (int idx = 0; idx < ui->tableWidget->rowCount(); idx++) - { - for (int jdx = 0; jdx < ui->tableWidget->columnCount(); jdx++) - { - ui->tableWidget->item(idx,jdx )->setTextAlignment(Qt::AlignVCenter|Qt::AlignHCenter); - - if (jdx < 5 || jdx > 9) - { - ui->tableWidget->item(idx,jdx )->setBackgroundColor(QColor(235,235,235)); - } - } - } - - ui->tableWidget->resizeColumnsToContents(); - ui->tableWidget->resizeRowsToContents(); - ui->tableWidget->verticalHeader()->setVisible(false); - ui->tableWidget->repaint(); - } - - ~AsciiInfoDialog() - { - delete ui; - } - -private: - Ui::AsciiInfoDialog *ui; -}; - -#endif // ASCIIINFODIALOG_H +#ifndef ASCIIINFODIALOG_H +#define ASCIIINFODIALOG_H + +#include +#include "ui_asciiinfodialog.h" + +namespace Ui { +class AsciiInfoDialog; +} + +class AsciiInfoDialog : public QDialog +{ + Q_OBJECT + +public: + explicit AsciiInfoDialog(QWidget *parent = 0) : + QDialog(parent), + ui(new Ui::AsciiInfoDialog) + { + ui->setupUi(this); + QFont font = ui->tableWidget->itemAt(0,0)->font(); + font.setBold(true); + for (int idx = 0; idx < ui->tableWidget->rowCount(); idx++) + { +// ui->tableWidget->item(idx,5 )->setFont(font); +// ui->tableWidget->item(idx,6 )->setFont(font); +// ui->tableWidget->item(idx,7 )->setFont(font); +// ui->tableWidget->item(idx,8 )->setFont(font); +// ui->tableWidget->item(idx,9 )->setFont(font); + } + + + for (int idx = 0; idx < ui->tableWidget->rowCount(); idx++) + { + for (int jdx = 0; jdx < ui->tableWidget->columnCount(); jdx++) + { + ui->tableWidget->item(idx,jdx )->setTextAlignment(Qt::AlignVCenter|Qt::AlignHCenter); + + if (jdx < 5 || jdx > 9) + { + ui->tableWidget->item(idx,jdx )->setBackgroundColor(QColor(235,235,235)); + } + } + } + + ui->tableWidget->resizeColumnsToContents(); + ui->tableWidget->resizeRowsToContents(); + ui->tableWidget->verticalHeader()->setVisible(false); + ui->tableWidget->repaint(); + } + + ~AsciiInfoDialog() + { + delete ui; + } + +private: + Ui::AsciiInfoDialog *ui; +}; + +#endif // ASCIIINFODIALOG_H diff --git a/src/ui/widgets/asciiinfodialog.ui b/src/ui/widgets/asciiinfodialog.ui index 6c4e3c8..1d0cf28 100644 --- a/src/ui/widgets/asciiinfodialog.ui +++ b/src/ui/widgets/asciiinfodialog.ui @@ -1,4937 +1,4937 @@ - - - AsciiInfoDialog - - - - 0 - 0 - 705 - 665 - - - - ASCII and Apple Character Set Values - - - - - - QAbstractItemView::NoEditTriggers - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectItems - - - false - - - false - - - - 0 - - - - 75 - true - - - - - - 1 - - - - - 2 - - - - - 3 - - - - - 4 - - - - - 5 - - - - - 6 - - - - - 7 - - - - - 8 - - - - - 9 - - - - - 10 - - - - - 11 - - - - - 12 - - - - - 13 - - - - - 14 - - - - - 15 - - - - - 16 - - - - - 17 - - - - - 18 - - - - - 20 - - - - - 1 - - - - - 21 - - - - - 22 - - - - - 23 - - - - - 24 - - - - - 25 - - - - - 26 - - - - - 27 - - - - - 28 - - - - - 29 - - - - - 30 - - - - - 31 - - - - - 32 - - - - - 33 - - - - - 34 - - - - - 35 - - - - - 36 - - - - - 37 - - - - - 38 - - - - - 39 - - - - - 40 - - - - - 41 - - - - - 42 - - - - - 43 - - - - - 44 - - - - - 45 - - - - - 46 - - - - - 47 - - - - - 48 - - - - - 49 - - - - - 50 - - - - - 51 - - - - - 52 - - - - - 53 - - - - - 54 - - - - - 55 - - - - - 56 - - - - - 57 - - - - - 58 - - - - - 59 - - - - - 60 - - - - - 61 - - - - - 62 - - - - - 63 - - - - - Dec - - - - - Hex - - - - - ASCII - - - - - A2 - - - AlignLeading|AlignVCenter - - - - - Set - - - - - Dec - - - - - Hex - - - - - ASCII - - - - - A2 - - - - - Set - - - - - Dec - - - - - Hex - - - - - A2 - - - - - Set - - - - - 0 - - - - - 00 - - - - - NUL (^@) - - - - - @ - - - - - INVERSE - - - - - 255 - 255 - 255 - - - - - - - 0 - 0 - 0 - - - - - - - 64 - - - - - 40 - - - - - @ - - - - - @ - - - - - FLASH - - - - - 128/192 - - - - - 80/C0 - - - - - @ - - - - - NORM - - - - - 1 - - - - - 01 - - - - - SOH (^A) - - - - - A - - - - - INVERSE - - - - - 65 - - - - - 41 - - - - - A - - - - - A - - - - - FLASH - - - - - 129/193 - - - - - 81/C1 - - - - - A - - - - - NORM - - - - - 2 - - - - - 02 - - - - - STX (^B) - - - - - B - - - - - INVERSE - - - - - 66 - - - - - 42 - - - - - B - - - - - B - - - - - FLASH - - - - - 130/194 - - - - - 82/C2 - - - - - B - - - - - NORM - - - - - 3 - - - - - 03 - - - - - ETX (^C) - - - - - C - - - - - INVERSE - - - - - 67 - - - - - 43 - - - - - C - - - - - C - - - - - FLASH - - - - - 131/195 - - - - - 83/C3 - - - - - C - - - - - NORM - - - - - 4 - - - - - 04 - - - - - EOT (^D) - - - - - D - - - - - INVERSE - - - - - 68 - - - - - 44 - - - - - D - - - - - D - - - - - FLASH - - - - - 132/196 - - - - - 84/C4 - - - - - D - - - - - NORM - - - - - 5 - - - - - 05 - - - - - ENQ (^E) - - - - - E - - - - - INVERSE - - - - - 69 - - - - - 45 - - - - - E - - - - - E - - - - - FLASH - - - - - 133/197 - - - - - 85/C5 - - - - - E - - - - - NORM - - - - - 6 - - - - - 06 - - - - - ACK (^F) - - - - - F - - - - - INVERSE - - - - - 70 - - - - - 46 - - - - - F - - - - - F - - - - - FLASH - - - - - 134/198 - - - - - 86/C6 - - - - - F - - - - - NORM - - - - - 7 - - - - - 07 - - - - - BEL (^G) - - - - - G - - - - - INVERSE - - - - - 71 - - - - - 47 - - - - - G - - - - - G - - - - - FLASH - - - - - 135/199 - - - - - 87/C7 - - - - - G - - - - - NORM - - - - - 8 - - - - - 08 - - - - - BS (^H) - - - - - H - - - - - INVERSE - - - - - 72 - - - - - 48 - - - - - H - - - - - H - - - - - FLASH - - - - - 136/200 - - - - - 88/C8 - - - - - H - - - - - NORM - - - - - 9 - - - - - 09 - - - - - HT (^I) - - - - - I - - - - - INVERSE - - - - - 73 - - - - - 49 - - - - - I - - - - - I - - - - - FLASH - - - - - 137/201 - - - - - 89/C9 - - - - - I - - - - - NORM - - - - - 10 - - - - - 0A - - - - - LF (^J) - - - - - J - - - - - INVERSE - - - - - 74 - - - - - 4A - - - - - J - - - - - J - - - - - FLASH - - - - - 138/202 - - - - - 8A/CA - - - - - J - - - - - NORM - - - - - 11 - - - - - 0B - - - - - VT (^K) - - - - - K - - - - - INVERSE - - - - - 75 - - - - - 4B - - - - - K - - - - - K - - - - - FLASH - - - - - 139/203 - - - - - 8B/CB - - - - - K - - - - - NORM - - - - - 12 - - - - - 0C - - - - - FF (^L) - - - - - L - - - - - INVERSE - - - - - 76 - - - - - 4C - - - - - L - - - - - L - - - - - FLASH - - - - - 140/204 - - - - - 8C/CC - - - - - L - - - - - NORM - - - - - 13 - - - - - 0D - - - - - CR (^M) - - - - - M - - - - - INVERSE - - - - - 77 - - - - - 4D - - - - - M - - - - - M - - - - - FLASH - - - - - 141/205 - - - - - 8D/CD - - - - - M - - - - - NORM - - - - - 14 - - - - - 0E - - - - - SO (^N) - - - - - N - - - - - INVERSE - - - - - 78 - - - - - 4E - - - - - N - - - - - N - - - - - FLASH - - - - - 142/206 - - - - - 8E/CE - - - - - N - - - - - NORM - - - - - 15 - - - - - 0F - - - - - SI (^O) - - - - - O - - - - - INVERSE - - - - - 79 - - - - - 4F - - - - - O - - - - - O - - - - - FLASH - - - - - 143/207 - - - - - 8F/CF - - - - - O - - - - - NORM - - - - - 16 - - - - - 10 - - - - - DLE (^P) - - - - - P - - - - - INVERSE - - - - - 80 - - - - - 50 - - - - - P - - - - - P - - - - - FLASH - - - - - 144/208 - - - - - 90/D0 - - - - - P - - - - - NORM - - - - - 17 - - - - - 11 - - - - - DC1 (^Q) - - - - - Q - - - - - INVERSE - - - - - 81 - - - - - 51 - - - - - Q - - - - - Q - - - - - FLASH - - - - - 145/209 - - - - - 91/D1 - - - - - Q - - - - - NORM - - - - - 18 - - - - - 12 - - - - - DC2 (^R) - - - - - R - - - - - INVERSE - - - - - 82 - - - - - 52 - - - - - R - - - - - R - - - - - FLASH - - - - - 146/210 - - - - - 92/D2 - - - - - R - - - - - NORM - - - - - 19 - - - - - 13 - - - - - DC3 (^S) - - - - - S - - - - - INVERSE - - - - - 83 - - - - - 53 - - - - - S - - - - - S - - - - - FLASH - - - - - 147/211 - - - - - 93/D3 - - - - - S - - - - - NORM - - - - - 20 - - - - - 14 - - - - - DC4 (^T) - - - - - T - - - - - INVERSE - - - - - 84 - - - - - 54 - - - - - T - - - - - T - - - - - FLASH - - - - - 148/212 - - - - - 94/D4 - - - - - T - - - - - NORM - - - - - 21 - - - - - 15 - - - - - NAK (^U) - - - - - Y - - - - - INVERSE - - - - - 85 - - - - - 55 - - - - - U - - - - - U - - - - - FLASH - - - - - 149/213 - - - - - 95/D5 - - - - - U - - - - - NORM - - - - - 22 - - - - - 16 - - - - - SYN (^V) - - - - - V - - - - - INVERSE - - - - - 86 - - - - - 56 - - - - - V - - - - - V - - - - - FLASH - - - - - 150/214 - - - - - 96/D6 - - - - - V - - - - - NORM - - - - - 23 - - - - - 17 - - - - - ETB (^W) - - - - - W - - - - - INVERSE - - - - - 87 - - - - - 57 - - - - - W - - - - - W - - - - - FLASH - - - - - 151/215 - - - - - 97/D7 - - - - - W - - - - - NORM - - - - - 24 - - - - - 18 - - - - - CAN (^X) - - - - - X - - - - - INVERSE - - - - - 88 - - - - - 58 - - - - - X - - - - - X - - - - - FLASH - - - - - 152/216 - - - - - 96/D8 - - - - - X - - - - - NORM - - - - - 25 - - - - - 19 - - - - - EM (^Y) - - - - - Y - - - - - INVERSE - - - - - 89 - - - - - 59 - - - - - Y - - - - - Y - - - - - FLASH - - - - - 153/217 - - - - - 99/D9 - - - - - Y - - - - - NORM - - - - - 26 - - - - - 1A - - - - - SUB (^Z) - - - - - Z - - - - - INVERSE - - - - - 90 - - - - - 5A - - - - - Z - - - - - Z - - - - - FLASH - - - - - 154/218 - - - - - 9A/DA - - - - - Z - - - - - NORM - - - - - 27 - - - - - 1B - - - - - ESC (^[) - - - - - [ - - - - - INVERSE - - - - - 91 - - - - - 5B - - - - - [ - - - - - [ - - - - - FLASH - - - - - 155/219 - - - - - 9B/DB - - - - - [ - - - - - NORM - - - - - 28 - - - - - 1C - - - - - FS (^\) - - - - - \ - - - - - INVERSE - - - - - 92 - - - - - 5C - - - - - \ - - - - - \ - - - - - FLASH - - - - - 156/220 - - - - - 9C/DC - - - - - \ - - - - - NORM - - - - - 29 - - - - - 1D - - - - - GS (^]) - - - - - ] - - - - - INVERSE - - - - - 93 - - - - - 5D - - - - - ] - - - - - ] - - - - - FLASH - - - - - 157/221 - - - - - 9D/DD - - - - - ] - - - - - NORM - - - - - 30 - - - - - 1E - - - - - RS (^^) - - - - - ^ - - - - - INVERSE - - - - - 94 - - - - - 5E - - - - - ^ - - - - - ^ - - - - - FLASH - - - - - 158/222 - - - - - 9E/DE - - - - - ^ - - - - - NORM - - - - - 31 - - - - - 1F - - - - - US (^_) - - - - - _ - - - - - INVERSE - - - - - 95 - - - - - 5F - - - - - _ - - - - - _ - - - - - FLASH - - - - - 159/223 - - - - - 9F/DF - - - - - _ - - - - - NORM - - - - - 32 - - - - - 20 - - - - - Space - - - - - Space - - - - - INVERSE - - - - - 96 - - - - - 60 - - - - - ` - - - - - Space - - - - - FLASH - - - - - 160/224 - - - - - A0/E0 - - - - - Space - - - - - NORM - - - - - 33 - - - - - 21 - - - - - ! - - - - - ! - - - - - INVERSE - - - - - 97 - - - - - 61 - - - - - a - - - - - ! - - - - - FLASH - - - - - 161/225 - - - - - A1/E1 - - - - - ! - - - - - NORM - - - - - 34 - - - - - 22 - - - - - " - - - - - " - - - - - INVERSE - - - - - 98 - - - - - 62 - - - - - b - - - - - " - - - - - FLASH - - - - - 162/226 - - - - - A2/E2 - - - - - " - - - - - NORM - - - - - 35 - - - - - 23 - - - - - # - - - - - # - - - - - INVERSE - - - - - 99 - - - - - 63 - - - - - c - - - - - # - - - - - FLASH - - - - - 163/227 - - - - - A3/E3 - - - - - # - - - - - NORM - - - - - 36 - - - - - 24 - - - - - $ - - - - - $ - - - - - INVERSE - - - - - 100 - - - - - 64 - - - - - d - - - - - $ - - - - - FLASH - - - - - 164/228 - - - - - A4/E4 - - - - - $ - - - - - NORM - - - - - 37 - - - - - 25 - - - - - % - - - - - % - - - - - INVERSE - - - - - 101 - - - - - 65 - - - - - e - - - - - % - - - - - FLASH - - - - - 165/229 - - - - - A5/E5 - - - - - % - - - - - NORM - - - - - 38 - - - - - 26 - - - - - & - - - - - & - - - - - INVERSE - - - - - 102 - - - - - 66 - - - - - f - - - - - & - - - - - FLASH - - - - - 166/230 - - - - - A6/E6 - - - - - & - - - - - NORM - - - - - 39 - - - - - 27 - - - - - ' - - - - - ' - - - - - INVERSE - - - - - 103 - - - - - 67 - - - - - g - - - - - ' - - - - - FLASH - - - - - 167/231 - - - - - A7/E7 - - - - - ' - - - - - NORM - - - - - 40 - - - - - 28 - - - - - ( - - - - - ( - - - - - INVERSE - - - - - 104 - - - - - 68 - - - - - h - - - - - ( - - - - - FLASH - - - - - 168/232 - - - - - A8/E8 - - - - - ( - - - - - NORM - - - - - 41 - - - - - 29 - - - - - ) - - - - - ) - - - - - INVERSE - - - - - 105 - - - - - 69 - - - - - i - - - - - ) - - - - - FLASH - - - - - 169/233 - - - - - A9/E9 - - - - - ) - - - - - NORM - - - - - 42 - - - - - 2A - - - - - * - - - - - * - - - - - INVERSE - - - - - 106 - - - - - 6A - - - - - j - - - - - * - - - - - FLASH - - - - - 170/234 - - - - - AA/EA - - - - - * - - - - - NORM - - - - - 43 - - - - - 2B - - - - - + - - - - - + - - - - - INVERSE - - - - - 107 - - - - - 6B - - - - - k - - - - - + - - - - - FLASH - - - - - 171/235 - - - - - AB/EB - - - - - + - - - - - NORM - - - - - 44 - - - - - 2C - - - - - , - - - - - , - - - - - INVERSE - - - - - 108 - - - - - 6C - - - - - l - - - - - , - - - - - FLASH - - - - - 172/236 - - - - - AC/EC - - - - - , - - - - - NORM - - - - - 45 - - - - - 2D - - - - - - - - - - - - - - - - - INVERSE - - - - - 109 - - - - - 6D - - - - - m - - - - - - - - - - - FLASH - - - - - 173/237 - - - - - AD/ED - - - - - - - - - - - NORM - - - - - 46 - - - - - 2E - - - - - . - - - - - . - - - - - INVERSE - - - - - 110 - - - - - 6E - - - - - n - - - - - . - - - - - FLASH - - - - - 174/238 - - - - - AE/EE - - - - - . - - - - - NORM - - - - - 47 - - - - - 2F - - - - - / - - - - - / - - - - - INVERSE - - - - - 111 - - - - - 6F - - - - - o - - - - - / - - - - - FLASH - - - - - 175/239 - - - - - AF/EF - - - - - / - - - - - NORM - - - - - 48 - - - - - 30 - - - - - 0 - - - - - 0 - - - - - INVERSE - - - - - 112 - - - - - 70 - - - - - p - - - - - 0 - - - - - FLASH - - - - - 176/240 - - - - - B0/F0 - - - - - 0 - - - - - NORM - - - - - 49 - - - - - 31 - - - - - 1 - - - - - 1 - - - - - INVERSE - - - - - 113 - - - - - 71 - - - - - q - - - - - 1 - - - - - FLASH - - - - - 177/241 - - - - - B1/F1 - - - - - 1 - - - - - NORM - - - - - 50 - - - - - 32 - - - - - 2 - - - - - 2 - - - - - INVERSE - - - - - 114 - - - - - 72 - - - - - r - - - - - 2 - - - - - FLASH - - - - - 178/242 - - - - - B2/F2 - - - - - 2 - - - - - NORM - - - - - 51 - - - - - 33 - - - - - 3 - - - - - 3 - - - - - INVERSE - - - - - 115 - - - - - 73 - - - - - s - - - - - 3 - - - - - FLASH - - - - - 179/243 - - - - - B3/F3 - - - - - 3 - - - - - NORM - - - - - 52 - - - - - 34 - - - - - 4 - - - - - 4 - - - - - INVERSE - - - - - 116 - - - - - 74 - - - - - t - - - - - 4 - - - - - FLASH - - - - - 180/244 - - - - - B4/F4 - - - - - 4 - - - - - NORM - - - - - 53 - - - - - 35 - - - - - 5 - - - - - 5 - - - - - INVERSE - - - - - 117 - - - - - 75 - - - - - u - - - - - 5 - - - - - FLASH - - - - - 181/245 - - - - - B5/F5 - - - - - 5 - - - - - NORM - - - - - 54 - - - - - 36 - - - - - 6 - - - - - 6 - - - - - INVERSE - - - - - 118 - - - - - 76 - - - - - v - - - - - 6 - - - - - FLASH - - - - - 182/246 - - - - - B6/F6 - - - - - 6 - - - - - NORM - - - - - 55 - - - - - 37 - - - - - 7 - - - - - 7 - - - - - INVERSE - - - - - 119 - - - - - 77 - - - - - w - - - - - 7 - - - - - FLASH - - - - - 183/247 - - - - - B7/F7 - - - - - 7 - - - - - NORM - - - - - 56 - - - - - 38 - - - - - 8 - - - - - 8 - - - - - INVERSE - - - - - 120 - - - - - 78 - - - - - x - - - - - 8 - - - - - FLASH - - - - - 184/248 - - - - - B8/F8 - - - - - 8 - - - - - NORM - - - - - 57 - - - - - 39 - - - - - 9 - - - - - 9 - - - - - INVERSE - - - - - 121 - - - - - 79 - - - - - y - - - - - 9 - - - - - FLASH - - - - - 185/249 - - - - - B9/F9 - - - - - 9 - - - - - NORM - - - - - 58 - - - - - 3A - - - - - : - - - - - : - - - - - INVERSE - - - - - 122 - - - - - 7A - - - - - z - - - - - : - - - - - FLASH - - - - - 186/250 - - - - - BA/FA - - - - - : - - - - - NORM - - - - - 59 - - - - - 3B - - - - - ; - - - - - ; - - - - - INVERSE - - - - - 123 - - - - - 7B - - - - - { - - - - - ; - - - - - FLASH - - - - - 187/251 - - - - - BB/FB - - - - - ; - - - - - NORM - - - - - 60 - - - - - 3C - - - - - < - - - - - < - - - - - INVERSE - - - - - 124 - - - - - 7C - - - - - | - - - - - < - - - - - FLASH - - - - - 188/252 - - - - - BC/FC - - - - - < - - - - - NORM - - - - - 61 - - - - - 3D - - - - - = - - - - - = - - - - - INVERSE - - - - - 125 - - - - - 7D - - - - - } - - - - - = - - - - - FLASH - - - - - 189/253 - - - - - BD/FD - - - - - = - - - - - NORM - - - - - 62 - - - - - 3E - - - - - > - - - - - > - - - - - INVERSE - - - - - 126 - - - - - 7E - - - - - ~ - - - - - > - - - - - FLASH - - - - - 190/254 - - - - - BE/FE - - - - - > - - - - - NORM - - - - - 63 - - - - - 3F - - - - - ? - - - - - ? - - - - - INVERSE - - - - - 127 - - - - - 7F - - - - - DEL - - - - - ? - - - - - FLASH - - - - - 191/255 - - - - - BF/FF - - - - - ? - - - - - NORM - - - - - - - - - + + + AsciiInfoDialog + + + + 0 + 0 + 705 + 665 + + + + ASCII and Apple Character Set Values + + + + + + QAbstractItemView::NoEditTriggers + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectItems + + + false + + + false + + + + 0 + + + + 75 + true + + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + 5 + + + + + 6 + + + + + 7 + + + + + 8 + + + + + 9 + + + + + 10 + + + + + 11 + + + + + 12 + + + + + 13 + + + + + 14 + + + + + 15 + + + + + 16 + + + + + 17 + + + + + 18 + + + + + 20 + + + + + 1 + + + + + 21 + + + + + 22 + + + + + 23 + + + + + 24 + + + + + 25 + + + + + 26 + + + + + 27 + + + + + 28 + + + + + 29 + + + + + 30 + + + + + 31 + + + + + 32 + + + + + 33 + + + + + 34 + + + + + 35 + + + + + 36 + + + + + 37 + + + + + 38 + + + + + 39 + + + + + 40 + + + + + 41 + + + + + 42 + + + + + 43 + + + + + 44 + + + + + 45 + + + + + 46 + + + + + 47 + + + + + 48 + + + + + 49 + + + + + 50 + + + + + 51 + + + + + 52 + + + + + 53 + + + + + 54 + + + + + 55 + + + + + 56 + + + + + 57 + + + + + 58 + + + + + 59 + + + + + 60 + + + + + 61 + + + + + 62 + + + + + 63 + + + + + Dec + + + + + Hex + + + + + ASCII + + + + + A2 + + + AlignLeading|AlignVCenter + + + + + Set + + + + + Dec + + + + + Hex + + + + + ASCII + + + + + A2 + + + + + Set + + + + + Dec + + + + + Hex + + + + + A2 + + + + + Set + + + + + 0 + + + + + 00 + + + + + NUL (^@) + + + + + @ + + + + + INVERSE + + + + + 255 + 255 + 255 + + + + + + + 0 + 0 + 0 + + + + + + + 64 + + + + + 40 + + + + + @ + + + + + @ + + + + + FLASH + + + + + 128/192 + + + + + 80/C0 + + + + + @ + + + + + NORM + + + + + 1 + + + + + 01 + + + + + SOH (^A) + + + + + A + + + + + INVERSE + + + + + 65 + + + + + 41 + + + + + A + + + + + A + + + + + FLASH + + + + + 129/193 + + + + + 81/C1 + + + + + A + + + + + NORM + + + + + 2 + + + + + 02 + + + + + STX (^B) + + + + + B + + + + + INVERSE + + + + + 66 + + + + + 42 + + + + + B + + + + + B + + + + + FLASH + + + + + 130/194 + + + + + 82/C2 + + + + + B + + + + + NORM + + + + + 3 + + + + + 03 + + + + + ETX (^C) + + + + + C + + + + + INVERSE + + + + + 67 + + + + + 43 + + + + + C + + + + + C + + + + + FLASH + + + + + 131/195 + + + + + 83/C3 + + + + + C + + + + + NORM + + + + + 4 + + + + + 04 + + + + + EOT (^D) + + + + + D + + + + + INVERSE + + + + + 68 + + + + + 44 + + + + + D + + + + + D + + + + + FLASH + + + + + 132/196 + + + + + 84/C4 + + + + + D + + + + + NORM + + + + + 5 + + + + + 05 + + + + + ENQ (^E) + + + + + E + + + + + INVERSE + + + + + 69 + + + + + 45 + + + + + E + + + + + E + + + + + FLASH + + + + + 133/197 + + + + + 85/C5 + + + + + E + + + + + NORM + + + + + 6 + + + + + 06 + + + + + ACK (^F) + + + + + F + + + + + INVERSE + + + + + 70 + + + + + 46 + + + + + F + + + + + F + + + + + FLASH + + + + + 134/198 + + + + + 86/C6 + + + + + F + + + + + NORM + + + + + 7 + + + + + 07 + + + + + BEL (^G) + + + + + G + + + + + INVERSE + + + + + 71 + + + + + 47 + + + + + G + + + + + G + + + + + FLASH + + + + + 135/199 + + + + + 87/C7 + + + + + G + + + + + NORM + + + + + 8 + + + + + 08 + + + + + BS (^H) + + + + + H + + + + + INVERSE + + + + + 72 + + + + + 48 + + + + + H + + + + + H + + + + + FLASH + + + + + 136/200 + + + + + 88/C8 + + + + + H + + + + + NORM + + + + + 9 + + + + + 09 + + + + + HT (^I) + + + + + I + + + + + INVERSE + + + + + 73 + + + + + 49 + + + + + I + + + + + I + + + + + FLASH + + + + + 137/201 + + + + + 89/C9 + + + + + I + + + + + NORM + + + + + 10 + + + + + 0A + + + + + LF (^J) + + + + + J + + + + + INVERSE + + + + + 74 + + + + + 4A + + + + + J + + + + + J + + + + + FLASH + + + + + 138/202 + + + + + 8A/CA + + + + + J + + + + + NORM + + + + + 11 + + + + + 0B + + + + + VT (^K) + + + + + K + + + + + INVERSE + + + + + 75 + + + + + 4B + + + + + K + + + + + K + + + + + FLASH + + + + + 139/203 + + + + + 8B/CB + + + + + K + + + + + NORM + + + + + 12 + + + + + 0C + + + + + FF (^L) + + + + + L + + + + + INVERSE + + + + + 76 + + + + + 4C + + + + + L + + + + + L + + + + + FLASH + + + + + 140/204 + + + + + 8C/CC + + + + + L + + + + + NORM + + + + + 13 + + + + + 0D + + + + + CR (^M) + + + + + M + + + + + INVERSE + + + + + 77 + + + + + 4D + + + + + M + + + + + M + + + + + FLASH + + + + + 141/205 + + + + + 8D/CD + + + + + M + + + + + NORM + + + + + 14 + + + + + 0E + + + + + SO (^N) + + + + + N + + + + + INVERSE + + + + + 78 + + + + + 4E + + + + + N + + + + + N + + + + + FLASH + + + + + 142/206 + + + + + 8E/CE + + + + + N + + + + + NORM + + + + + 15 + + + + + 0F + + + + + SI (^O) + + + + + O + + + + + INVERSE + + + + + 79 + + + + + 4F + + + + + O + + + + + O + + + + + FLASH + + + + + 143/207 + + + + + 8F/CF + + + + + O + + + + + NORM + + + + + 16 + + + + + 10 + + + + + DLE (^P) + + + + + P + + + + + INVERSE + + + + + 80 + + + + + 50 + + + + + P + + + + + P + + + + + FLASH + + + + + 144/208 + + + + + 90/D0 + + + + + P + + + + + NORM + + + + + 17 + + + + + 11 + + + + + DC1 (^Q) + + + + + Q + + + + + INVERSE + + + + + 81 + + + + + 51 + + + + + Q + + + + + Q + + + + + FLASH + + + + + 145/209 + + + + + 91/D1 + + + + + Q + + + + + NORM + + + + + 18 + + + + + 12 + + + + + DC2 (^R) + + + + + R + + + + + INVERSE + + + + + 82 + + + + + 52 + + + + + R + + + + + R + + + + + FLASH + + + + + 146/210 + + + + + 92/D2 + + + + + R + + + + + NORM + + + + + 19 + + + + + 13 + + + + + DC3 (^S) + + + + + S + + + + + INVERSE + + + + + 83 + + + + + 53 + + + + + S + + + + + S + + + + + FLASH + + + + + 147/211 + + + + + 93/D3 + + + + + S + + + + + NORM + + + + + 20 + + + + + 14 + + + + + DC4 (^T) + + + + + T + + + + + INVERSE + + + + + 84 + + + + + 54 + + + + + T + + + + + T + + + + + FLASH + + + + + 148/212 + + + + + 94/D4 + + + + + T + + + + + NORM + + + + + 21 + + + + + 15 + + + + + NAK (^U) + + + + + Y + + + + + INVERSE + + + + + 85 + + + + + 55 + + + + + U + + + + + U + + + + + FLASH + + + + + 149/213 + + + + + 95/D5 + + + + + U + + + + + NORM + + + + + 22 + + + + + 16 + + + + + SYN (^V) + + + + + V + + + + + INVERSE + + + + + 86 + + + + + 56 + + + + + V + + + + + V + + + + + FLASH + + + + + 150/214 + + + + + 96/D6 + + + + + V + + + + + NORM + + + + + 23 + + + + + 17 + + + + + ETB (^W) + + + + + W + + + + + INVERSE + + + + + 87 + + + + + 57 + + + + + W + + + + + W + + + + + FLASH + + + + + 151/215 + + + + + 97/D7 + + + + + W + + + + + NORM + + + + + 24 + + + + + 18 + + + + + CAN (^X) + + + + + X + + + + + INVERSE + + + + + 88 + + + + + 58 + + + + + X + + + + + X + + + + + FLASH + + + + + 152/216 + + + + + 96/D8 + + + + + X + + + + + NORM + + + + + 25 + + + + + 19 + + + + + EM (^Y) + + + + + Y + + + + + INVERSE + + + + + 89 + + + + + 59 + + + + + Y + + + + + Y + + + + + FLASH + + + + + 153/217 + + + + + 99/D9 + + + + + Y + + + + + NORM + + + + + 26 + + + + + 1A + + + + + SUB (^Z) + + + + + Z + + + + + INVERSE + + + + + 90 + + + + + 5A + + + + + Z + + + + + Z + + + + + FLASH + + + + + 154/218 + + + + + 9A/DA + + + + + Z + + + + + NORM + + + + + 27 + + + + + 1B + + + + + ESC (^[) + + + + + [ + + + + + INVERSE + + + + + 91 + + + + + 5B + + + + + [ + + + + + [ + + + + + FLASH + + + + + 155/219 + + + + + 9B/DB + + + + + [ + + + + + NORM + + + + + 28 + + + + + 1C + + + + + FS (^\) + + + + + \ + + + + + INVERSE + + + + + 92 + + + + + 5C + + + + + \ + + + + + \ + + + + + FLASH + + + + + 156/220 + + + + + 9C/DC + + + + + \ + + + + + NORM + + + + + 29 + + + + + 1D + + + + + GS (^]) + + + + + ] + + + + + INVERSE + + + + + 93 + + + + + 5D + + + + + ] + + + + + ] + + + + + FLASH + + + + + 157/221 + + + + + 9D/DD + + + + + ] + + + + + NORM + + + + + 30 + + + + + 1E + + + + + RS (^^) + + + + + ^ + + + + + INVERSE + + + + + 94 + + + + + 5E + + + + + ^ + + + + + ^ + + + + + FLASH + + + + + 158/222 + + + + + 9E/DE + + + + + ^ + + + + + NORM + + + + + 31 + + + + + 1F + + + + + US (^_) + + + + + _ + + + + + INVERSE + + + + + 95 + + + + + 5F + + + + + _ + + + + + _ + + + + + FLASH + + + + + 159/223 + + + + + 9F/DF + + + + + _ + + + + + NORM + + + + + 32 + + + + + 20 + + + + + Space + + + + + Space + + + + + INVERSE + + + + + 96 + + + + + 60 + + + + + ` + + + + + Space + + + + + FLASH + + + + + 160/224 + + + + + A0/E0 + + + + + Space + + + + + NORM + + + + + 33 + + + + + 21 + + + + + ! + + + + + ! + + + + + INVERSE + + + + + 97 + + + + + 61 + + + + + a + + + + + ! + + + + + FLASH + + + + + 161/225 + + + + + A1/E1 + + + + + ! + + + + + NORM + + + + + 34 + + + + + 22 + + + + + " + + + + + " + + + + + INVERSE + + + + + 98 + + + + + 62 + + + + + b + + + + + " + + + + + FLASH + + + + + 162/226 + + + + + A2/E2 + + + + + " + + + + + NORM + + + + + 35 + + + + + 23 + + + + + # + + + + + # + + + + + INVERSE + + + + + 99 + + + + + 63 + + + + + c + + + + + # + + + + + FLASH + + + + + 163/227 + + + + + A3/E3 + + + + + # + + + + + NORM + + + + + 36 + + + + + 24 + + + + + $ + + + + + $ + + + + + INVERSE + + + + + 100 + + + + + 64 + + + + + d + + + + + $ + + + + + FLASH + + + + + 164/228 + + + + + A4/E4 + + + + + $ + + + + + NORM + + + + + 37 + + + + + 25 + + + + + % + + + + + % + + + + + INVERSE + + + + + 101 + + + + + 65 + + + + + e + + + + + % + + + + + FLASH + + + + + 165/229 + + + + + A5/E5 + + + + + % + + + + + NORM + + + + + 38 + + + + + 26 + + + + + & + + + + + & + + + + + INVERSE + + + + + 102 + + + + + 66 + + + + + f + + + + + & + + + + + FLASH + + + + + 166/230 + + + + + A6/E6 + + + + + & + + + + + NORM + + + + + 39 + + + + + 27 + + + + + ' + + + + + ' + + + + + INVERSE + + + + + 103 + + + + + 67 + + + + + g + + + + + ' + + + + + FLASH + + + + + 167/231 + + + + + A7/E7 + + + + + ' + + + + + NORM + + + + + 40 + + + + + 28 + + + + + ( + + + + + ( + + + + + INVERSE + + + + + 104 + + + + + 68 + + + + + h + + + + + ( + + + + + FLASH + + + + + 168/232 + + + + + A8/E8 + + + + + ( + + + + + NORM + + + + + 41 + + + + + 29 + + + + + ) + + + + + ) + + + + + INVERSE + + + + + 105 + + + + + 69 + + + + + i + + + + + ) + + + + + FLASH + + + + + 169/233 + + + + + A9/E9 + + + + + ) + + + + + NORM + + + + + 42 + + + + + 2A + + + + + * + + + + + * + + + + + INVERSE + + + + + 106 + + + + + 6A + + + + + j + + + + + * + + + + + FLASH + + + + + 170/234 + + + + + AA/EA + + + + + * + + + + + NORM + + + + + 43 + + + + + 2B + + + + + + + + + + + + + + + + + INVERSE + + + + + 107 + + + + + 6B + + + + + k + + + + + + + + + + + FLASH + + + + + 171/235 + + + + + AB/EB + + + + + + + + + + + NORM + + + + + 44 + + + + + 2C + + + + + , + + + + + , + + + + + INVERSE + + + + + 108 + + + + + 6C + + + + + l + + + + + , + + + + + FLASH + + + + + 172/236 + + + + + AC/EC + + + + + , + + + + + NORM + + + + + 45 + + + + + 2D + + + + + - + + + + + - + + + + + INVERSE + + + + + 109 + + + + + 6D + + + + + m + + + + + - + + + + + FLASH + + + + + 173/237 + + + + + AD/ED + + + + + - + + + + + NORM + + + + + 46 + + + + + 2E + + + + + . + + + + + . + + + + + INVERSE + + + + + 110 + + + + + 6E + + + + + n + + + + + . + + + + + FLASH + + + + + 174/238 + + + + + AE/EE + + + + + . + + + + + NORM + + + + + 47 + + + + + 2F + + + + + / + + + + + / + + + + + INVERSE + + + + + 111 + + + + + 6F + + + + + o + + + + + / + + + + + FLASH + + + + + 175/239 + + + + + AF/EF + + + + + / + + + + + NORM + + + + + 48 + + + + + 30 + + + + + 0 + + + + + 0 + + + + + INVERSE + + + + + 112 + + + + + 70 + + + + + p + + + + + 0 + + + + + FLASH + + + + + 176/240 + + + + + B0/F0 + + + + + 0 + + + + + NORM + + + + + 49 + + + + + 31 + + + + + 1 + + + + + 1 + + + + + INVERSE + + + + + 113 + + + + + 71 + + + + + q + + + + + 1 + + + + + FLASH + + + + + 177/241 + + + + + B1/F1 + + + + + 1 + + + + + NORM + + + + + 50 + + + + + 32 + + + + + 2 + + + + + 2 + + + + + INVERSE + + + + + 114 + + + + + 72 + + + + + r + + + + + 2 + + + + + FLASH + + + + + 178/242 + + + + + B2/F2 + + + + + 2 + + + + + NORM + + + + + 51 + + + + + 33 + + + + + 3 + + + + + 3 + + + + + INVERSE + + + + + 115 + + + + + 73 + + + + + s + + + + + 3 + + + + + FLASH + + + + + 179/243 + + + + + B3/F3 + + + + + 3 + + + + + NORM + + + + + 52 + + + + + 34 + + + + + 4 + + + + + 4 + + + + + INVERSE + + + + + 116 + + + + + 74 + + + + + t + + + + + 4 + + + + + FLASH + + + + + 180/244 + + + + + B4/F4 + + + + + 4 + + + + + NORM + + + + + 53 + + + + + 35 + + + + + 5 + + + + + 5 + + + + + INVERSE + + + + + 117 + + + + + 75 + + + + + u + + + + + 5 + + + + + FLASH + + + + + 181/245 + + + + + B5/F5 + + + + + 5 + + + + + NORM + + + + + 54 + + + + + 36 + + + + + 6 + + + + + 6 + + + + + INVERSE + + + + + 118 + + + + + 76 + + + + + v + + + + + 6 + + + + + FLASH + + + + + 182/246 + + + + + B6/F6 + + + + + 6 + + + + + NORM + + + + + 55 + + + + + 37 + + + + + 7 + + + + + 7 + + + + + INVERSE + + + + + 119 + + + + + 77 + + + + + w + + + + + 7 + + + + + FLASH + + + + + 183/247 + + + + + B7/F7 + + + + + 7 + + + + + NORM + + + + + 56 + + + + + 38 + + + + + 8 + + + + + 8 + + + + + INVERSE + + + + + 120 + + + + + 78 + + + + + x + + + + + 8 + + + + + FLASH + + + + + 184/248 + + + + + B8/F8 + + + + + 8 + + + + + NORM + + + + + 57 + + + + + 39 + + + + + 9 + + + + + 9 + + + + + INVERSE + + + + + 121 + + + + + 79 + + + + + y + + + + + 9 + + + + + FLASH + + + + + 185/249 + + + + + B9/F9 + + + + + 9 + + + + + NORM + + + + + 58 + + + + + 3A + + + + + : + + + + + : + + + + + INVERSE + + + + + 122 + + + + + 7A + + + + + z + + + + + : + + + + + FLASH + + + + + 186/250 + + + + + BA/FA + + + + + : + + + + + NORM + + + + + 59 + + + + + 3B + + + + + ; + + + + + ; + + + + + INVERSE + + + + + 123 + + + + + 7B + + + + + { + + + + + ; + + + + + FLASH + + + + + 187/251 + + + + + BB/FB + + + + + ; + + + + + NORM + + + + + 60 + + + + + 3C + + + + + < + + + + + < + + + + + INVERSE + + + + + 124 + + + + + 7C + + + + + | + + + + + < + + + + + FLASH + + + + + 188/252 + + + + + BC/FC + + + + + < + + + + + NORM + + + + + 61 + + + + + 3D + + + + + = + + + + + = + + + + + INVERSE + + + + + 125 + + + + + 7D + + + + + } + + + + + = + + + + + FLASH + + + + + 189/253 + + + + + BD/FD + + + + + = + + + + + NORM + + + + + 62 + + + + + 3E + + + + + > + + + + + > + + + + + INVERSE + + + + + 126 + + + + + 7E + + + + + ~ + + + + + > + + + + + FLASH + + + + + 190/254 + + + + + BE/FE + + + + + > + + + + + NORM + + + + + 63 + + + + + 3F + + + + + ? + + + + + ? + + + + + INVERSE + + + + + 127 + + + + + 7F + + + + + DEL + + + + + ? + + + + + FLASH + + + + + 191/255 + + + + + BF/FF + + + + + ? + + + + + NORM + + + + + + + + + diff --git a/src/ui/widgets/characterwidget.cpp b/src/ui/widgets/characterwidget.cpp index 30b1edc..aec3a10 100644 --- a/src/ui/widgets/characterwidget.cpp +++ b/src/ui/widgets/characterwidget.cpp @@ -1,143 +1,143 @@ -#include "characterwidget.h" - -#include -#include -#include -#include - -CharacterWidget::CharacterWidget(QWidget *parent, CharSetCharacter ch) - : QWidget(parent), m_character(ch) -{ - - m_dobitshift = true; - m_showgrid = true; - // setMaximumSize(this->size()); - // setMinimumSize(this->size()); - m_pixmap = QPixmap(this->size()); - setFgColor(Qt::black); - setBgColor(Qt::white); - setGridColor(Qt::red); - QString name = QChar(ch.asciiVal()); - if (ch.asciiVal() == ' ') { name = ""; } - if (ch.asciiVal() == 0x7f) { name = ""; } - QString ttstring = QString("Ascii: %1\nCharacter: %2").arg(ch.asciiVal()).arg(name); - setToolTip(ttstring); - doRepaint(); -} - -bool CharacterWidget::hasHeightForWidth() const { return true; } -int CharacterWidget::heightForWidth(int w) const { return w * 9 / 8; } - -void CharacterWidget::doRepaint() -{ - m_pixmap.fill(QColor(0,0,0,0)); - QPainter painter(&m_pixmap); - float hscale = width() / 15; - float vscale = height() / 8; - - painter.setPen(m_bgcolor); - painter.setBrush(m_bgcolor); - painter.drawRect(0,0, hscale * 15, vscale * 8); - - painter.setPen(m_fgcolor); - painter.setBrush(m_fgcolor); - - QByteArray chardata = m_character.data(); - - for (quint8 yval = 0; yval < 8; yval++) - { - int ypos = yval * vscale; - - quint8 line = chardata[yval]; - - QBitArray bits(7); - bits.setBit(0,(line & 0x01)); - bits.setBit(1,(line & 0x02)); - bits.setBit(2,(line & 0x04)); - bits.setBit(3,(line & 0x08)); - bits.setBit(4,(line & 0x10)); - bits.setBit(5,(line & 0x20)); - bits.setBit(6,(line & 0x40)); - - int shiftval = 0; - painter.setBrush(m_fgcolor); - if (m_dobitshift && (line & 0x80)) { - shiftval = 1; - painter.setBrush(Qt::gray); - } - - for (int jdx = 0; jdx < 7; jdx++) - { - if (bits.testBit(jdx)) - { - painter.drawRect((jdx*2+shiftval)*hscale, ypos, - hscale*2, vscale); - } - } - } - - if (m_showgrid) - { - painter.setPen(QPen(m_gridcolor,1,Qt::DotLine)); - painter.setBrush(Qt::NoBrush); - for (int idx = 0; idx < 9; idx++) - { - painter.drawLine(0, idx*vscale, - hscale * 15, idx*vscale); - } - for (int idx = 0; idx < 8; idx++) - { - painter.drawLine(idx*hscale*2, 0, - idx*hscale*2, vscale * 8); - } - painter.setPen(QPen(m_gridcolor,2,Qt::SolidLine)); - painter.drawLine(0,0, 0, vscale * 8); - painter.drawLine(0,vscale * 8, hscale * 15, vscale * 8); - painter.drawLine(hscale * 15, vscale * 8, hscale * 15,0); - painter.drawLine(hscale * 15,0, 0,0); - } - - repaint(); -} - -void CharacterWidget::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - painter.drawPixmap(0,0,m_pixmap); -} - -void CharacterWidget::resizeEvent(QResizeEvent *event) -{ - m_pixmap = m_pixmap.scaled(event->size().width(),event->size().height()); - doRepaint(); -} - -void CharacterWidget::setFgColor(QColor color) -{ - m_fgcolor = color; - doRepaint(); -} - -void CharacterWidget::setBgColor(QColor color) -{ - m_bgcolor = color; - doRepaint(); -} - -void CharacterWidget::setGridColor(QColor color) -{ - m_gridcolor = color; - doRepaint(); -} - -void CharacterWidget::showGrid(bool show) -{ - m_showgrid = show; - doRepaint(); -} - -void CharacterWidget::enableBitShift(bool enable) -{ - m_dobitshift = enable; - doRepaint(); -} +#include "characterwidget.h" + +#include +#include +#include +#include + +CharacterWidget::CharacterWidget(QWidget *parent, CharSetCharacter ch) + : QWidget(parent), m_character(ch) +{ + + m_dobitshift = true; + m_showgrid = true; + // setMaximumSize(this->size()); + // setMinimumSize(this->size()); + m_pixmap = QPixmap(this->size()); + setFgColor(Qt::black); + setBgColor(Qt::white); + setGridColor(Qt::red); + QString name = QChar(ch.asciiVal()); + if (ch.asciiVal() == ' ') { name = ""; } + if (ch.asciiVal() == 0x7f) { name = ""; } + QString ttstring = QString("Ascii: %1\nCharacter: %2").arg(ch.asciiVal()).arg(name); + setToolTip(ttstring); + doRepaint(); +} + +bool CharacterWidget::hasHeightForWidth() const { return true; } +int CharacterWidget::heightForWidth(int w) const { return w * 9 / 8; } + +void CharacterWidget::doRepaint() +{ + m_pixmap.fill(QColor(0,0,0,0)); + QPainter painter(&m_pixmap); + float hscale = width() / 15; + float vscale = height() / 8; + + painter.setPen(m_bgcolor); + painter.setBrush(m_bgcolor); + painter.drawRect(0,0, hscale * 15, vscale * 8); + + painter.setPen(m_fgcolor); + painter.setBrush(m_fgcolor); + + QByteArray chardata = m_character.data(); + + for (quint8 yval = 0; yval < 8; yval++) + { + int ypos = yval * vscale; + + quint8 line = chardata[yval]; + + QBitArray bits(7); + bits.setBit(0,(line & 0x01)); + bits.setBit(1,(line & 0x02)); + bits.setBit(2,(line & 0x04)); + bits.setBit(3,(line & 0x08)); + bits.setBit(4,(line & 0x10)); + bits.setBit(5,(line & 0x20)); + bits.setBit(6,(line & 0x40)); + + int shiftval = 0; + painter.setBrush(m_fgcolor); + if (m_dobitshift && (line & 0x80)) { + shiftval = 1; + painter.setBrush(Qt::gray); + } + + for (int jdx = 0; jdx < 7; jdx++) + { + if (bits.testBit(jdx)) + { + painter.drawRect((jdx*2+shiftval)*hscale, ypos, + hscale*2, vscale); + } + } + } + + if (m_showgrid) + { + painter.setPen(QPen(m_gridcolor,1,Qt::DotLine)); + painter.setBrush(Qt::NoBrush); + for (int idx = 0; idx < 9; idx++) + { + painter.drawLine(0, idx*vscale, + hscale * 15, idx*vscale); + } + for (int idx = 0; idx < 8; idx++) + { + painter.drawLine(idx*hscale*2, 0, + idx*hscale*2, vscale * 8); + } + painter.setPen(QPen(m_gridcolor,2,Qt::SolidLine)); + painter.drawLine(0,0, 0, vscale * 8); + painter.drawLine(0,vscale * 8, hscale * 15, vscale * 8); + painter.drawLine(hscale * 15, vscale * 8, hscale * 15,0); + painter.drawLine(hscale * 15,0, 0,0); + } + + repaint(); +} + +void CharacterWidget::paintEvent(QPaintEvent *) +{ + QPainter painter(this); + painter.drawPixmap(0,0,m_pixmap); +} + +void CharacterWidget::resizeEvent(QResizeEvent *event) +{ + m_pixmap = m_pixmap.scaled(event->size().width(),event->size().height()); + doRepaint(); +} + +void CharacterWidget::setFgColor(QColor color) +{ + m_fgcolor = color; + doRepaint(); +} + +void CharacterWidget::setBgColor(QColor color) +{ + m_bgcolor = color; + doRepaint(); +} + +void CharacterWidget::setGridColor(QColor color) +{ + m_gridcolor = color; + doRepaint(); +} + +void CharacterWidget::showGrid(bool show) +{ + m_showgrid = show; + doRepaint(); +} + +void CharacterWidget::enableBitShift(bool enable) +{ + m_dobitshift = enable; + doRepaint(); +} diff --git a/src/ui/widgets/characterwidget.h b/src/ui/widgets/characterwidget.h index 560fbf6..d1e0562 100644 --- a/src/ui/widgets/characterwidget.h +++ b/src/ui/widgets/characterwidget.h @@ -1,48 +1,48 @@ -#pragma once - -#include -#include -#include - -#include "charset.h" - -class CharacterWidget : public QWidget -{ - Q_OBJECT - -public: - CharacterWidget(QWidget *parent = 0, - CharSetCharacter ch = CharSetCharacter()); - - void doRepaint(); - - bool hasHeightForWidth() const; - int heightForWidth(int w) const; -protected: - void resizeEvent(QResizeEvent *event); - - void paintEvent(QPaintEvent *); -signals: - -public slots: - void setFgColor(QColor color); - void setBgColor(QColor color); - void setGridColor(QColor color); - - void showGrid(bool show); - void enableBitShift(bool enable); - - -private: - QPixmap m_pixmap; - - QColor m_fgcolor; - QColor m_bgcolor; - QColor m_gridcolor; - bool m_showgrid; - bool m_dobitshift; - - CharSetCharacter m_character; - -}; - +#pragma once + +#include +#include +#include + +#include "charset.h" + +class CharacterWidget : public QWidget +{ + Q_OBJECT + +public: + CharacterWidget(QWidget *parent = 0, + CharSetCharacter ch = CharSetCharacter()); + + void doRepaint(); + + bool hasHeightForWidth() const; + int heightForWidth(int w) const; +protected: + void resizeEvent(QResizeEvent *event); + + void paintEvent(QPaintEvent *); +signals: + +public slots: + void setFgColor(QColor color); + void setBgColor(QColor color); + void setGridColor(QColor color); + + void showGrid(bool show); + void enableBitShift(bool enable); + + +private: + QPixmap m_pixmap; + + QColor m_fgcolor; + QColor m_bgcolor; + QColor m_gridcolor; + bool m_showgrid; + bool m_dobitshift; + + CharSetCharacter m_character; + +}; + diff --git a/src/ui/widgets/hexconverter.cpp b/src/ui/widgets/hexconverter.cpp index 5a9cf70..d9272dd 100644 --- a/src/ui/widgets/hexconverter.cpp +++ b/src/ui/widgets/hexconverter.cpp @@ -1,100 +1,101 @@ -#include "hexconverter.h" -#include "ui_hexconverter.h" -#include - -HexConverter::HexConverter(QWidget *parent) : - QDialog(parent), - ui(new Ui::HexConverter) -{ - ui->setupUi(this); - - ui->uint8LineEdit->setValidator(new QIntValidator(0,255,this)); - ui->int8LineEdit->setValidator(new QIntValidator(-128,127,this)); - ui->uint16LineEdit->setValidator(new QIntValidator(0,65535,this)); - ui->int16LineEdit->setValidator(new QIntValidator(-32768,32767,this)); - - connect(ui->hexLineEdit, &QLineEdit::textEdited, this, &HexConverter::calcFromNewHex); - connect(ui->uint8LineEdit, &QLineEdit::textEdited, this, &HexConverter::calcFromNewUint8); - connect(ui->int8LineEdit, &QLineEdit::textEdited, this, &HexConverter::calcFromNewInt8); - connect(ui->uint16LineEdit, &QLineEdit::textEdited, this, &HexConverter::calcFromNewUint16); - connect(ui->int16LineEdit, &QLineEdit::textEdited, this, &HexConverter::calcFromNewInt16); -} - -HexConverter::~HexConverter() -{ - delete ui; -} - -void HexConverter::calcFromNewHex(QString value) -{ - bool ok = true; - quint16 ui16 = value.toInt(&ok,16); - qint16 i16 = ui16; - quint8 ui8 = ui16; - qint8 i8 = ui16; - - ui->uint16LineEdit->setText(QString::number(ui16)); - ui->int16LineEdit->setText(QString::number(i16)); - ui->uint8LineEdit->setText(QString::number(ui8)); - ui->int8LineEdit->setText(QString::number(i8)); -} - -void HexConverter::calcFromNewUint16(QString value) -{ - bool ok = true; - quint16 ui16 = value.toInt(&ok); - qint16 i16 = ui16; - quint8 ui8 = ui16; - qint8 i8 = ui16; - QString hex = QString::number(ui16,16); - - ui->int16LineEdit->setText(QString::number(i16)); - ui->uint8LineEdit->setText(QString::number(ui8)); - ui->int8LineEdit->setText(QString::number(i8)); - ui->hexLineEdit->setText(hex); -} - -void HexConverter::calcFromNewInt16(QString value) -{ - bool ok = true; - qint16 i16 = value.toInt(&ok); - quint16 ui16 = i16; - quint8 ui8 = i16; - qint8 i8 = i16; - QString hex = QString::number(ui16,16); - - ui->uint16LineEdit->setText(QString::number(ui16)); - ui->uint8LineEdit->setText(QString::number(ui8)); - ui->int8LineEdit->setText(QString::number(i8)); - ui->hexLineEdit->setText(hex); -} - -void HexConverter::calcFromNewUint8(QString value) -{ - bool ok = true; - quint8 ui8 = value.toInt(&ok); - quint16 ui16 = ui8; - qint16 i16 = ui16; - qint8 i8 = ui16; - QString hex = QString::number(ui16,16); - - ui->uint16LineEdit->setText(QString::number(ui16)); - ui->int16LineEdit->setText(QString::number(i16)); - ui->int8LineEdit->setText(QString::number(i8)); - ui->hexLineEdit->setText(hex); -} - -void HexConverter::calcFromNewInt8(QString value) -{ - bool ok = true; - qint8 i8 = value.toInt(&ok); - quint8 ui8 = i8; - quint16 ui16 = ui8; - qint16 i16 = ui16; - QString hex = QString::number(ui16,16); - - ui->uint16LineEdit->setText(QString::number(ui16)); - ui->int16LineEdit->setText(QString::number(i16)); - ui->uint8LineEdit->setText(QString::number(ui8)); - ui->hexLineEdit->setText(hex); -} +#include "hexconverter.h" +#include "ui_hexconverter.h" +#include +#include + +HexConverter::HexConverter(QWidget *parent) : + QDialog(parent), + ui(new Ui::HexConverter) +{ + ui->setupUi(this); + + ui->uint8LineEdit->setValidator(new QIntValidator(0,255,this)); + ui->int8LineEdit->setValidator(new QIntValidator(-128,127,this)); + ui->uint16LineEdit->setValidator(new QIntValidator(0,65535,this)); + ui->int16LineEdit->setValidator(new QIntValidator(-32768,32767,this)); + + connect(ui->hexLineEdit, &QLineEdit::textEdited, this, &HexConverter::calcFromNewHex); + connect(ui->uint8LineEdit, &QLineEdit::textEdited, this, &HexConverter::calcFromNewUint8); + connect(ui->int8LineEdit, &QLineEdit::textEdited, this, &HexConverter::calcFromNewInt8); + connect(ui->uint16LineEdit, &QLineEdit::textEdited, this, &HexConverter::calcFromNewUint16); + connect(ui->int16LineEdit, &QLineEdit::textEdited, this, &HexConverter::calcFromNewInt16); +} + +HexConverter::~HexConverter() +{ + delete ui; +} + +void HexConverter::calcFromNewHex(QString value) +{ + bool ok = true; + quint16 ui16 = value.toInt(&ok,16); + qint16 i16 = ui16; + quint8 ui8 = ui16; + qint8 i8 = ui16; + + ui->uint16LineEdit->setText(QString::number(ui16)); + ui->int16LineEdit->setText(QString::number(i16)); + ui->uint8LineEdit->setText(QString::number(ui8)); + ui->int8LineEdit->setText(QString::number(i8)); +} + +void HexConverter::calcFromNewUint16(QString value) +{ + bool ok = true; + quint16 ui16 = value.toInt(&ok); + qint16 i16 = ui16; + quint8 ui8 = ui16; + qint8 i8 = ui16; + QString hex = QString::number(ui16,16); + + ui->int16LineEdit->setText(QString::number(i16)); + ui->uint8LineEdit->setText(QString::number(ui8)); + ui->int8LineEdit->setText(QString::number(i8)); + ui->hexLineEdit->setText(hex); +} + +void HexConverter::calcFromNewInt16(QString value) +{ + bool ok = true; + qint16 i16 = value.toInt(&ok); + quint16 ui16 = i16; + quint8 ui8 = i16; + qint8 i8 = i16; + QString hex = QString::number(ui16,16); + + ui->uint16LineEdit->setText(QString::number(ui16)); + ui->uint8LineEdit->setText(QString::number(ui8)); + ui->int8LineEdit->setText(QString::number(i8)); + ui->hexLineEdit->setText(hex); +} + +void HexConverter::calcFromNewUint8(QString value) +{ + bool ok = true; + quint8 ui8 = value.toInt(&ok); + quint16 ui16 = ui8; + qint16 i16 = ui16; + qint8 i8 = ui16; + QString hex = QString::number(ui16,16); + + ui->uint16LineEdit->setText(QString::number(ui16)); + ui->int16LineEdit->setText(QString::number(i16)); + ui->int8LineEdit->setText(QString::number(i8)); + ui->hexLineEdit->setText(hex); +} + +void HexConverter::calcFromNewInt8(QString value) +{ + bool ok = true; + qint8 i8 = value.toInt(&ok); + quint8 ui8 = i8; + quint16 ui16 = ui8; + qint16 i16 = ui16; + QString hex = QString::number(ui16,16); + + ui->uint16LineEdit->setText(QString::number(ui16)); + ui->int16LineEdit->setText(QString::number(i16)); + ui->uint8LineEdit->setText(QString::number(ui8)); + ui->hexLineEdit->setText(hex); +} diff --git a/src/ui/widgets/hexconverter.h b/src/ui/widgets/hexconverter.h index 17ae3bd..94b1e10 100644 --- a/src/ui/widgets/hexconverter.h +++ b/src/ui/widgets/hexconverter.h @@ -1,30 +1,30 @@ -#ifndef HEXCONVERTER_H -#define HEXCONVERTER_H - -#include - -namespace Ui { -class HexConverter; -} - -class HexConverter : public QDialog -{ - Q_OBJECT - -public: - explicit HexConverter(QWidget *parent = 0); - ~HexConverter(); - -public slots: - void calcFromNewUint16(QString value); - void calcFromNewInt16(QString value); - void calcFromNewHex(QString value); - void calcFromNewUint8(QString value); - void calcFromNewInt8(QString value); - -protected slots: -private: - Ui::HexConverter *ui; -}; - -#endif // HEXCONVERTER_H +#ifndef HEXCONVERTER_H +#define HEXCONVERTER_H + +#include + +namespace Ui { +class HexConverter; +} + +class HexConverter : public QDialog +{ + Q_OBJECT + +public: + explicit HexConverter(QWidget *parent = 0); + ~HexConverter(); + +public slots: + void calcFromNewUint16(QString value); + void calcFromNewInt16(QString value); + void calcFromNewHex(QString value); + void calcFromNewUint8(QString value); + void calcFromNewInt8(QString value); + +protected slots: +private: + Ui::HexConverter *ui; +}; + +#endif // HEXCONVERTER_H diff --git a/src/ui/widgets/hexconverter.ui b/src/ui/widgets/hexconverter.ui index 7db65e2..5c0d68c 100644 --- a/src/ui/widgets/hexconverter.ui +++ b/src/ui/widgets/hexconverter.ui @@ -1,79 +1,79 @@ - - - HexConverter - - - - 0 - 0 - 247 - 113 - - - - HexConverter - - - - - - - - Hex - - - - - - - UInt16 - - - - - - - Int16 - - - - - - - HHHH - - - - - - - - - - - - - Uint8 - - - - - - - Int8 - - - - - - - - - - - - - - - - + + + HexConverter + + + + 0 + 0 + 247 + 113 + + + + HexConverter + + + + + + + + Hex + + + + + + + UInt16 + + + + + + + Int16 + + + + + + + HHHH + + + + + + + + + + + + + Uint8 + + + + + + + Int8 + + + + + + + + + + + + + + + + diff --git a/src/ui/widgets/hrcgcontrolsinfo.h b/src/ui/widgets/hrcgcontrolsinfo.h index a29a98d..b0ca844 100644 --- a/src/ui/widgets/hrcgcontrolsinfo.h +++ b/src/ui/widgets/hrcgcontrolsinfo.h @@ -1,33 +1,33 @@ -#ifndef HRCGCONTROLSINFO_H -#define HRCGCONTROLSINFO_H - -#include -#include "ui_hrcgcontrolsinfo.h" - - -namespace Ui { -class HRCGControlsInfo; -} - -class HRCGControlsInfo : public QDialog -{ - Q_OBJECT - -public: - explicit HRCGControlsInfo(QWidget *parent = 0) : - QDialog(parent), - ui(new Ui::HRCGControlsInfo) - { - ui->setupUi(this); - ui->tableWidget->resizeColumnsToContents(); - } - ~HRCGControlsInfo() - { - delete ui; - } - -private: - Ui::HRCGControlsInfo *ui; -}; - -#endif // HRCGCONTROLSINFO_H +#ifndef HRCGCONTROLSINFO_H +#define HRCGCONTROLSINFO_H + +#include +#include "ui_hrcgcontrolsinfo.h" + + +namespace Ui { +class HRCGControlsInfo; +} + +class HRCGControlsInfo : public QDialog +{ + Q_OBJECT + +public: + explicit HRCGControlsInfo(QWidget *parent = 0) : + QDialog(parent), + ui(new Ui::HRCGControlsInfo) + { + ui->setupUi(this); + ui->tableWidget->resizeColumnsToContents(); + } + ~HRCGControlsInfo() + { + delete ui; + } + +private: + Ui::HRCGControlsInfo *ui; +}; + +#endif // HRCGCONTROLSINFO_H diff --git a/src/ui/widgets/hrcgcontrolsinfo.ui b/src/ui/widgets/hrcgcontrolsinfo.ui index 4bb725d..626ce38 100644 --- a/src/ui/widgets/hrcgcontrolsinfo.ui +++ b/src/ui/widgets/hrcgcontrolsinfo.ui @@ -1,947 +1,947 @@ - - - HRCGControlsInfo - - - - 0 - 0 - 507 - 620 - - - - HRCG Contols - - - - - - QAbstractItemView::NoEditTriggers - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - true - - - false - - - 20 - - - 20 - - - - A - - - - - B - - - - - C - - - - - D - - - - - E - - - - - F - - - - - I - - - - - K - - - - - L - - - - - N - - - - - OA - - - - - OB - - - - - OC - - - - - OD - - - - - OO - - - - - OP - - - - - OR - - - - - OS - - - - - OT - - - - - OW - - - - - OY - - - - - OZ - - - - - P - - - - - Q - - - - - S - - - - - V - - - - - W - - - - - Y - - - - - Z - - - - - Sequence - - - - - Hex - - - - - Decimal - - - - - Chars - - - - - Description - - - - - ^A n - - - - - $01 n - - - - - 1 n - - - - - SOH - - - - - Select Character Set n - - - - - ^B - - - - - $02 - - - - - 2 - - - - - STX - - - - - Begin Block Display - - - - - ^C - - - - - $03 - - - - - 3 - - - - - ETX - - - - - Carriage Return - - - - - ^D - - - - - $04 - - - - - 4 - - - - - EOT - - - - - Delimit Block Display - - - - - ^E - - - - - $05 - - - - - 5 - - - - - ENQ - - - - - Clear to End of Line - - - - - ^F - - - - - $06 - - - - - 6 - - - - - ACK - - - - - Clear to End of Screen - - - - - ^I - - - - - $09 - - - - - 9 - - - - - HT - - - - - Inverse Video - - - - - ^K - - - - - $0B - - - - - 11 - - - - - VT - - - - - Caps Lock * - - - - - ^L - - - - - $0C - - - - - 12 - - - - - FF - - - - - Lower Case - - - - - ^N - - - - - $0E - - - - - 14 - - - - - SO - - - - - Normal Video * - - - - - ^O ^A - - - - - $0F $01 - - - - - 15 1 - - - - - SI SOH - - - - - Primary is Page 1 * - - - - - ^O ^B - - - - - $0F $02 - - - - - 15 2 - - - - - SI STX - - - - - Primary is Page 2 - - - - - ^O ^C - - - - - $0F $03 - - - - - 15 3 - - - - - SI ETX - - - - - Complement - - - - - ^O ^D - - - - - $0F $04 - - - - - 15 4 - - - - - SI EOT - - - - - Display Primary - - - - - ^O ^O - - - - - $0F $0F - - - - - 15 15 - - - - - SI SI - - - - - Overstrike - - - - - ^O ^P - - - - - $0F $10 - - - - - 15 16 - - - - - SI DLE - - - - - Print * - - - - - ^O ^R - - - - - $0F $12 - - - - - 15 18 - - - - - SI DC2 - - - - - Reverse Overlay - - - - - ^O ^S - - - - - $0F $13 - - - - - 15 19 - - - - - SI DC3 - - - - - Scroll * - - - - - ^O ^T - - - - - $0F $14 - - - - - 15 20 - - - - - SI DC4 - - - - - Transparent Overlay - - - - - ^O ^W - - - - - $0F $17 - - - - - 15 23 - - - - - SI ETB - - - - - Wrap - - - - - ^O ^Y - - - - - $0F $18 - - - - - 15 25 - - - - - SI EM - - - - - Call User Sub A (@ RLOAD + $0A/0B) - - - - - ^O ^Z - - - - - $0F $1A - - - - - 15 26 - - - - - SI SUB - - - - - Call User Sub B (@ RLOAD + $0D/0E) - - - - - ^P - - - - - $10 - - - - - 16 - - - - - DLE - - - - - Clear Page - - - - - ^Q - - - - - $11 - - - - - 17 - - - - - DC1 - - - - - Home Cursor - - - - - ^S - - - - - $13 - - - - - 19 - - - - - DC3 - - - - - Shift - - - - - ^V - - - - - $16 - - - - - 22 - - - - - SYN - - - - - Set Text Window (upper-left) - - - - - ^W - - - - - $17 - - - - - 23 - - - - - ETB - - - - - Set Text Window (lower-right) - - - - - ^Y - - - - - $19 - - - - - 25 - - - - - EM - - - - - Set Text Window (full screen) * - - - - - ^Z - - - - - $1A - - - - - 26 - - - - - SUB - - - - - Restore Default Parameters - - - - - - - - - + + + HRCGControlsInfo + + + + 0 + 0 + 507 + 620 + + + + HRCG Contols + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + true + + + false + + + 20 + + + 20 + + + + A + + + + + B + + + + + C + + + + + D + + + + + E + + + + + F + + + + + I + + + + + K + + + + + L + + + + + N + + + + + OA + + + + + OB + + + + + OC + + + + + OD + + + + + OO + + + + + OP + + + + + OR + + + + + OS + + + + + OT + + + + + OW + + + + + OY + + + + + OZ + + + + + P + + + + + Q + + + + + S + + + + + V + + + + + W + + + + + Y + + + + + Z + + + + + Sequence + + + + + Hex + + + + + Decimal + + + + + Chars + + + + + Description + + + + + ^A n + + + + + $01 n + + + + + 1 n + + + + + SOH + + + + + Select Character Set n + + + + + ^B + + + + + $02 + + + + + 2 + + + + + STX + + + + + Begin Block Display + + + + + ^C + + + + + $03 + + + + + 3 + + + + + ETX + + + + + Carriage Return + + + + + ^D + + + + + $04 + + + + + 4 + + + + + EOT + + + + + Delimit Block Display + + + + + ^E + + + + + $05 + + + + + 5 + + + + + ENQ + + + + + Clear to End of Line + + + + + ^F + + + + + $06 + + + + + 6 + + + + + ACK + + + + + Clear to End of Screen + + + + + ^I + + + + + $09 + + + + + 9 + + + + + HT + + + + + Inverse Video + + + + + ^K + + + + + $0B + + + + + 11 + + + + + VT + + + + + Caps Lock * + + + + + ^L + + + + + $0C + + + + + 12 + + + + + FF + + + + + Lower Case + + + + + ^N + + + + + $0E + + + + + 14 + + + + + SO + + + + + Normal Video * + + + + + ^O ^A + + + + + $0F $01 + + + + + 15 1 + + + + + SI SOH + + + + + Primary is Page 1 * + + + + + ^O ^B + + + + + $0F $02 + + + + + 15 2 + + + + + SI STX + + + + + Primary is Page 2 + + + + + ^O ^C + + + + + $0F $03 + + + + + 15 3 + + + + + SI ETX + + + + + Complement + + + + + ^O ^D + + + + + $0F $04 + + + + + 15 4 + + + + + SI EOT + + + + + Display Primary + + + + + ^O ^O + + + + + $0F $0F + + + + + 15 15 + + + + + SI SI + + + + + Overstrike + + + + + ^O ^P + + + + + $0F $10 + + + + + 15 16 + + + + + SI DLE + + + + + Print * + + + + + ^O ^R + + + + + $0F $12 + + + + + 15 18 + + + + + SI DC2 + + + + + Reverse Overlay + + + + + ^O ^S + + + + + $0F $13 + + + + + 15 19 + + + + + SI DC3 + + + + + Scroll * + + + + + ^O ^T + + + + + $0F $14 + + + + + 15 20 + + + + + SI DC4 + + + + + Transparent Overlay + + + + + ^O ^W + + + + + $0F $17 + + + + + 15 23 + + + + + SI ETB + + + + + Wrap + + + + + ^O ^Y + + + + + $0F $18 + + + + + 15 25 + + + + + SI EM + + + + + Call User Sub A (@ RLOAD + $0A/0B) + + + + + ^O ^Z + + + + + $0F $1A + + + + + 15 26 + + + + + SI SUB + + + + + Call User Sub B (@ RLOAD + $0D/0E) + + + + + ^P + + + + + $10 + + + + + 16 + + + + + DLE + + + + + Clear Page + + + + + ^Q + + + + + $11 + + + + + 17 + + + + + DC1 + + + + + Home Cursor + + + + + ^S + + + + + $13 + + + + + 19 + + + + + DC3 + + + + + Shift + + + + + ^V + + + + + $16 + + + + + 22 + + + + + SYN + + + + + Set Text Window (upper-left) + + + + + ^W + + + + + $17 + + + + + 23 + + + + + ETB + + + + + Set Text Window (lower-right) + + + + + ^Y + + + + + $19 + + + + + 25 + + + + + EM + + + + + Set Text Window (full screen) * + + + + + ^Z + + + + + $1A + + + + + 26 + + + + + SUB + + + + + Restore Default Parameters + + + + + + + + + diff --git a/src/util/AppleColors.h b/src/util/AppleColors.h index 2de78c3..c9ae0a5 100644 --- a/src/util/AppleColors.h +++ b/src/util/AppleColors.h @@ -1,23 +1,23 @@ -#ifndef APPLECOLORS_H -#define APPLECOLORS_H - -#include - -static const QColor blackColor = QColor(0x00,0x00,0x00); -static const QColor redColor = QColor(0xe3,0x1e,0x60); -static const QColor darkBlueColor = QColor(0x60,0x4e,0xbd); -static const QColor purpleColor = QColor(0xff,0x44,0xfd); -static const QColor darkGreenColor = QColor(0x00,0xa3,0x60); -static const QColor grayColor = QColor(0x9c,0x9c,0x9c); -static const QColor blueColor = QColor(0x14,0xcf,0xfd); -static const QColor lightBlueColor = QColor(0xd0,0xc3,0xff); -static const QColor brownColor = QColor(0x60,0x72,0x03); -static const QColor orangeColor = QColor(0xff,0x6a,0x3c); -static const QColor gray2Color = QColor(0x9c,0x9c,0x9c); -static const QColor pinkColor = QColor(0xff,0xa0,0xd0); -static const QColor greenColor = QColor(0x14,0xf5,0x3c); -static const QColor yellowColor = QColor(0xd0,0xdd,0x8d); -static const QColor aquaColor = QColor(0x72,0xff,0xd0); -static const QColor whiteColor = QColor(0xff,0xff,0xff); - -#endif // APPLECOLORS_H +#ifndef APPLECOLORS_H +#define APPLECOLORS_H + +#include + +static const QColor blackColor = QColor(0x00,0x00,0x00); +static const QColor redColor = QColor(0xe3,0x1e,0x60); +static const QColor darkBlueColor = QColor(0x60,0x4e,0xbd); +static const QColor purpleColor = QColor(0xff,0x44,0xfd); +static const QColor darkGreenColor = QColor(0x00,0xa3,0x60); +static const QColor grayColor = QColor(0x9c,0x9c,0x9c); +static const QColor blueColor = QColor(0x14,0xcf,0xfd); +static const QColor lightBlueColor = QColor(0xd0,0xc3,0xff); +static const QColor brownColor = QColor(0x60,0x72,0x03); +static const QColor orangeColor = QColor(0xff,0x6a,0x3c); +static const QColor gray2Color = QColor(0x9c,0x9c,0x9c); +static const QColor pinkColor = QColor(0xff,0xa0,0xd0); +static const QColor greenColor = QColor(0x14,0xf5,0x3c); +static const QColor yellowColor = QColor(0xd0,0xdd,0x8d); +static const QColor aquaColor = QColor(0x72,0xff,0xd0); +static const QColor whiteColor = QColor(0xff,0xff,0xff); + +#endif // APPLECOLORS_H diff --git a/src/util/applestring.cxx b/src/util/applestring.cxx index 2125676..8fcbb0c 100644 --- a/src/util/applestring.cxx +++ b/src/util/applestring.cxx @@ -1,80 +1,95 @@ -#include "applestring.h" - - - -QString AppleString::printable() const -{ - QString retval; - foreach (quint8 ch, *this) { - if (ch > 0x80) - retval.append(QChar(ch-0x80)); - else - retval.append(QChar(ch)); - } - return retval; -} - -QVector AppleString::attributes() const -{ - QVector retval(this->length()); - int idx = 0; - foreach (quint8 ch, *this) { - retval[idx++] = AppleChar(ch).getAttribute(); - } - return retval; -} - - -QChar AppleChar::printable() const -{ - quint8 newval; - switch (getTextSet()) { - case SetInvUC: - newval = m_val+0x40; - break; - case SetInvSp: - newval = m_val; - break; - case SetFlUC: - newval = m_val; - break; - case SetFlSp: - newval = m_val-0x40; - break; - case SetNormUC: - newval = m_val-0x40; - break; - case SetNormSp: - newval = m_val-0x80; - break; - case SetNormAltUC: - newval = m_val-0x80; - break; - case SetNormLC: - default: - newval = m_val-0x80; - break; - } - return QChar(newval); -} - -TextAttribute AppleChar::getAttribute() const -{ - if (m_val <= 0x3f) { return Inverse; } - if (m_val <= 0x7f) { return Flash; } - if (m_val <= 0xbf) { return Normal; } - if (m_val <= 0xdf) { return NormalHigh; } - return Normal; -} - -TextSet AppleChar::getTextSet() const { - if (m_val < 0x20) { return SetInvUC; } - if (m_val < 0x40) { return SetInvSp; } - if (m_val < 0x60) { return SetFlUC; } - if (m_val < 0x80) { return SetFlSp; } - if (m_val < 0xA0) { return SetNormUC; } - if (m_val < 0xC0) { return SetNormSp; } - if (m_val < 0xE0) { return SetNormAltUC; } - return SetNormLC; -} - +#include "applestring.h" + + + +QString AppleString::printable() const +{ + QString retval; + foreach (quint8 ch, *this) { + if (ch > 0x80) + retval.append(QChar(ch-0x80)); + else + retval.append(QChar(ch)); + } + return retval; +} + +QVector AppleString::attributes() const +{ + QVector retval(this->length()); + int idx = 0; + foreach (quint8 ch, *this) { + retval[idx++] = AppleChar(ch).getAttribute(); + } + return retval; +} + + +QChar AppleChar::printable(quint8 val) +{ + quint8 newval; + switch (getTextSet(val)) { + case SetInvUC: + newval = val+0x40; + break; + case SetInvSp: + newval = val; + break; + case SetFlUC: + newval = val; + break; + case SetFlSp: + newval = val-0x40; + break; + case SetNormUC: + newval = val-0x40; + break; + case SetNormSp: + newval = val-0x80; + break; + case SetNormAltUC: + newval = val-0x80; + break; + case SetNormLC: + default: + newval = val-0x80; + break; + } + return QChar(newval); +} + +TextAttribute AppleChar::getAttribute(quint8 val) +{ + if (val <= 0x3f) { return Inverse; } + if (val <= 0x7f) { return Flash; } + if (val <= 0xbf) { return NormalLow; } + if (val <= 0xdf) { return NormalHigh; } + return NormalHigh; +} + +TextSet AppleChar::getTextSet(quint8 val) { + if (val < 0x20) { return SetInvUC; } + if (val < 0x40) { return SetInvSp; } + if (val < 0x60) { return SetFlUC; } + if (val < 0x80) { return SetFlSp; } + if (val < 0xA0) { return SetNormUC; } + if (val < 0xC0) { return SetNormSp; } + if (val < 0xE0) { return SetNormAltUC; } + return SetNormLC; +} + +QString AppleChar::getHtmlString(quint8 val) +{ + TextAttribute attribute = getAttribute(val); + QString htmlstring = printable(val); + htmlstring = htmlstring.toHtmlEscaped(); + + QString retval; + if (attribute == Inverse) { retval = QString("%1").arg(htmlstring); } + else if (attribute == Flash) { retval = QString("%1").arg(htmlstring);} + else if (attribute == NormalLow) { retval = QString("%1").arg(htmlstring);} + else { retval = QString("%1").arg(htmlstring);} + + return retval; +} + diff --git a/src/util/applestring.h b/src/util/applestring.h index 6eee388..dece303 100644 --- a/src/util/applestring.h +++ b/src/util/applestring.h @@ -1,33 +1,40 @@ -#ifndef APPLESTRING_H -#define APPLESTRING_H - -#include -#include -#include -#include - -#include "util.h" - -class AppleChar { -public: - AppleChar() { m_val = 0; } - AppleChar(quint8 ch) { m_val = ch; } - - QChar printable() const; - - TextAttribute getAttribute() const; - TextSet getTextSet() const; - -private: - quint8 m_val; -}; - -class AppleString : public QByteArray { -public: - void setData(const QByteArray &data) { insert(0,data); } - QString printable() const; - QVector attributes() const; - -}; - -#endif // APPLESTRING_H +#ifndef APPLESTRING_H +#define APPLESTRING_H + +#include +#include +#include +#include + +#include "util.h" + +class AppleChar { +public: + AppleChar() { m_val = 0; } + AppleChar(quint8 ch) { m_val = ch; } + + QChar printable() const { return printable(m_val); } + + TextAttribute getAttribute() const { return getAttribute(m_val); } + TextSet getTextSet() const { return getTextSet(m_val); } + + static TextAttribute getAttribute(quint8 val) ; + static TextSet getTextSet(quint8 val) ; + static QChar printable(quint8 val) ; + static QString getHtmlString(quint8 val); + + +private: + quint8 m_val; +}; + +class AppleString : public QByteArray { +public: + void setData(const QByteArray &data) { insert(0,data); } + QString printable() const; + QVector attributes() const; + +}; + +#endif // APPLESTRING_H + diff --git a/src/util/charset.cpp b/src/util/charset.cpp index 36f1dc9..04c3fcd 100644 --- a/src/util/charset.cpp +++ b/src/util/charset.cpp @@ -1,53 +1,56 @@ -#include "charset.h" - - -CharSetCharacter::CharSetCharacter(quint8 asciival, QByteArray bytes) -{ - setAsciiVal(asciival); - setData(bytes); -} - -void CharSetCharacter::setData(QByteArray bytes) -{ - bytes.resize(8); - m_data = bytes; -} - -void CharSetCharacter::setData(quint8 b0, quint8 b1, quint8 b2, quint8 b3, quint8 b4, quint8 b5, quint8 b6, quint8 b7) -{ - QByteArray data; - data.append(b0); - data.append(b1); - data.append(b2); - data.append(b3); - data.append(b4); - data.append(b5); - data.append(b6); - data.append(b7); - - setData(data); -} - -void CharacterSet::buildSetFromSetBlob(QByteArray data) -{ - if (data.size() != 768) { - qWarning("Unexpected character set size: %d (not 768). Resizing.",data.size()); - data.resize(768); - } - int val = 32; - for (int idx = 0; idx < 768; idx+=8) - { - QByteArray ch = data.mid(idx,8); - - CharSetCharacter csc = CharSetCharacter(val,ch); - m_charmap.insert(val,csc); - val++; - } -} - -QList CharacterSet::allCharacters() const -{ - return m_charmap.values(); - - -} +#include "charset.h" + + +CharSetCharacter::CharSetCharacter(quint8 asciival, QByteArray bytes) +{ + setAsciiVal(asciival); + setData(bytes); +} + +void CharSetCharacter::setData(QByteArray bytes) +{ + bytes.resize(8); + m_data = bytes; +} + +void CharSetCharacter::setData(quint8 b0, quint8 b1, + quint8 b2, quint8 b3, + quint8 b4, quint8 b5, + quint8 b6, quint8 b7) +{ + QByteArray data; + data.append(b0); + data.append(b1); + data.append(b2); + data.append(b3); + data.append(b4); + data.append(b5); + data.append(b6); + data.append(b7); + + setData(data); +} + +void CharacterSet::buildSetFromSetBlob(QByteArray data) +{ + if (data.size() != 768) { + qWarning("Unexpected character set size: %d (not 768). Resizing.",data.size()); + data.resize(768); + } + int val = 32; + for (int idx = 0; idx < 768; idx+=8) + { + QByteArray ch = data.mid(idx,8); + + CharSetCharacter csc = CharSetCharacter(val,ch); + m_charmap.insert(val,csc); + val++; + } +} + +QList CharacterSet::allCharacters() const +{ + return m_charmap.values(); + + +} diff --git a/src/util/charset.h b/src/util/charset.h index fd34de5..6008882 100644 --- a/src/util/charset.h +++ b/src/util/charset.h @@ -1,42 +1,42 @@ -#ifndef CHARSETCHARACTER_H -#define CHARSETCHARACTER_H - -#include -#include - - - -class CharSetCharacter -{ -public: - CharSetCharacter(quint8 asciival = 0, QByteArray bytes = QByteArray()); - void setAsciiVal(quint8 val) { m_asciival = val; } - quint8 asciiVal() const { return m_asciival; } - - void setData(QByteArray bytes); - void setData(quint8 b0 = 0, quint8 b1 = 0, quint8 b2 = 0, quint8 b3 = 0, - quint8 b4 = 0, quint8 b5 = 0, quint8 b6 = 0, quint8 b7 = 0); - QByteArray data() const { return m_data; } - -private: - quint8 m_asciival; - QByteArray m_data; -}; - - -class CharacterSet -{ -public: - void buildSetFromSetBlob(QByteArray data); - CharSetCharacter operator[](int asciival) const { return m_charmap[asciival]; } - QList allCharacters() const; - bool contains(int asciival) { return m_charmap.keys().contains(asciival); } - -private: - QMap m_charmap; -}; - - - - -#endif // CHARSETCHARACTER_H +#ifndef CHARSETCHARACTER_H +#define CHARSETCHARACTER_H + +#include +#include + + + +class CharSetCharacter +{ +public: + CharSetCharacter(quint8 asciival = 0, QByteArray bytes = QByteArray()); + void setAsciiVal(quint8 val) { m_asciival = val; } + quint8 asciiVal() const { return m_asciival; } + + void setData(QByteArray bytes); + void setData(quint8 b0 = 0, quint8 b1 = 0, quint8 b2 = 0, quint8 b3 = 0, + quint8 b4 = 0, quint8 b5 = 0, quint8 b6 = 0, quint8 b7 = 0); + QByteArray data() const { return m_data; } + +private: + quint8 m_asciival; + QByteArray m_data; +}; + + +class CharacterSet +{ +public: + void buildSetFromSetBlob(QByteArray data); + CharSetCharacter operator[](int asciival) const { return m_charmap[asciival]; } + QList allCharacters() const; + bool contains(int asciival) { return m_charmap.keys().contains(asciival); } + +private: + QMap m_charmap; +}; + + + + +#endif // CHARSETCHARACTER_H diff --git a/src/util/util.h b/src/util/util.h index 790473b..c1194c8 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -1,79 +1,95 @@ -#ifndef UTIL_H -#define UTIL_H - -#include -#include -#include -#include - -typedef enum { - DOSTextFile = 0x00, - DOSIntegerBasicFile = 0x01, - DOSApplesoftBasicFile = 0x02, - DOSRawBinaryFile = 0x04, - DOSTypeSFile = 0x08, - DOSRelocatableFile = 0x10, - DOSTypeAFile = 0x20, - DOSTypeBFile= 0x40, - DOSIsLocked = 0x80 -} FileTypeFlag; - -typedef enum { - Inverse = 0x00, // 0x00 -- 0x3F - Flash = 0x01, // 0x40 -- 0x7F - Normal = 0x02, // 0x80 -- 0xBF - NormalHigh = 0x04 // 0xC0 -- 0xFF -} TextAttribute; - -typedef enum { - SetInvUC = 0x00, - SetInvSp = 0x20, - SetFlUC = 0x40, - SetFlSp = 0x60, - SetNormUC = 0x80, - SetNormSp = 0xA0, - SetNormAltUC = 0xC0, - SetNormLC = 0xE0 -} TextSet; - -struct TSPair { - TSPair() { track = sector = 0; } - TSPair(quint8 trackval, quint8 secval) { track=trackval; sector = secval; } - quint8 track; - quint8 sector; - - bool operator==(const TSPair &other) { - if (other.track == track && other.sector == sector) return true; - return false; - } - - bool operator!=(const TSPair &other) { - return !(operator==(other)); - } - - void dump() { qDebug() << "TSPair: track: " << track << " sector: " << sector; } -}; - -inline QString uint8ToHex(quint8 val) { - QString retval = QString("%1").arg(val,2,16,QChar('0')).toUpper(); - return retval; -} - -inline QString uint16ToHex(quint16 val) { - QString retval = QString("%1").arg(val,4,16,QChar('0')).toUpper(); - return retval; -} - -inline QString uint32ToHex(quint32 val) { - QString retval = QString("%1").arg(val,8,16,QChar('0')).toUpper(); - return retval; -} - -inline quint16 makeWord(quint8 lo, quint8 hi) -{ - return hi*256 + lo; -} - - - -#endif // UTIL_H +#ifndef UTIL_H +#define UTIL_H + +#include +#include +#include +#include +#include +#include + +typedef enum { + DOSTextFile = 0x00, + DOSIntegerBasicFile = 0x01, + DOSApplesoftBasicFile = 0x02, + DOSRawBinaryFile = 0x04, + DOSTypeSFile = 0x08, + DOSRelocatableFile = 0x10, + DOSTypeAFile = 0x20, + DOSTypeBFile= 0x40, + DOSIsLocked = 0x80 +} FileTypeFlag; + +typedef enum { + Inverse = 0x00, // 0x00 -- 0x3F + Flash = 0x01, // 0x40 -- 0x7F + NormalLow = 0x02, // 0x80 -- 0xBF + NormalHigh = 0x04 // 0xC0 -- 0xFF +} TextAttribute; + +typedef enum { + SetInvUC = 0x00, + SetInvSp = 0x20, + SetFlUC = 0x40, + SetFlSp = 0x60, + SetNormUC = 0x80, + SetNormSp = 0xA0, + SetNormAltUC = 0xC0, + SetNormLC = 0xE0 +} TextSet; + +struct TSPair { + TSPair() { track = sector = 0; } + TSPair(quint8 trackval, quint8 secval) { track=trackval; sector = secval; } + quint8 track; + quint8 sector; + + bool operator==(const TSPair &other) { + if (other.track == track && other.sector == sector) return true; + return false; + } + + bool operator!=(const TSPair &other) { + return !(operator==(other)); + } + + void dump() { qDebug() << "TSPair: track: " << track << " sector: " << sector; } +}; + +inline QString uint8ToHex(quint8 val) { + QString retval = QString("%1").arg(val,2,16,QChar('0')).toUpper(); + return retval; +} + +inline QString uint16ToHex(quint16 val) { + QString retval = QString("%1").arg(val,4,16,QChar('0')).toUpper(); + return retval; +} + +inline QString uint32ToHex(quint32 val) { + QString retval = QString("%1").arg(val,8,16,QChar('0')).toUpper(); + return retval; +} + +inline quint16 makeWord(quint8 lo, quint8 hi) +{ + return hi*256 + lo; +} + +inline QFont fontFromSettings(QString key, QFont &defaultfont) +{ + QSettings settings; + QString result = settings.value(key, defaultfont.toString()).toString(); + QFont retval; + retval.fromString(result); + return retval; +} + +inline void fontToSettings(const QString &key, const QFont &font) +{ + QSettings settings; + settings.setValue(key, font.toString()); +} + + +#endif // UTIL_H