diff --git a/software/CPM/1M44/DSK/CPM32_1M44_ZCPR3.DSK b/software/CPM/1M44/DSK/CPM32_1M44_ZCPR3.DSK new file mode 100644 index 0000000..2b3b268 Binary files /dev/null and b/software/CPM/1M44/DSK/CPM32_1M44_ZCPR3.DSK differ diff --git a/software/CPM/1M44/DSK/CPM33_1M44_ZCPR3_COMMON.DSK b/software/CPM/1M44/DSK/CPM33_1M44_ZCPR3_COMMON.DSK new file mode 100644 index 0000000..1257794 Binary files /dev/null and b/software/CPM/1M44/DSK/CPM33_1M44_ZCPR3_COMMON.DSK differ diff --git a/software/CPM/1M44/RAW/CPM32_1M44_ZCPR3.RAW b/software/CPM/1M44/RAW/CPM32_1M44_ZCPR3.RAW new file mode 100644 index 0000000..6168ef0 Binary files /dev/null and b/software/CPM/1M44/RAW/CPM32_1M44_ZCPR3.RAW differ diff --git a/software/CPM/1M44/RAW/CPM33_1M44_ZCPR3_COMMON.RAW b/software/CPM/1M44/RAW/CPM33_1M44_ZCPR3_COMMON.RAW new file mode 100644 index 0000000..8e3e7be Binary files /dev/null and b/software/CPM/1M44/RAW/CPM33_1M44_ZCPR3_COMMON.RAW differ diff --git a/software/CPM/CPM32_ZCPR3/!(C)1988 b/software/CPM/CPM32_ZCPR3/!(C)1988 new file mode 100755 index 0000000..1436706 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/!(C)1988 differ diff --git a/software/CPM/CPM32_ZCPR3/!NZ-COM b/software/CPM/CPM32_ZCPR3/!NZ-COM new file mode 100755 index 0000000..e69de29 diff --git a/software/CPM/CPM32_ZCPR3/!VERS--1.2H b/software/CPM/CPM32_ZCPR3/!VERS--1.2H new file mode 100755 index 0000000..e69de29 diff --git a/software/CPM/CPM32_ZCPR3/ALIAS.CMD b/software/CPM/CPM32_ZCPR3/ALIAS.CMD new file mode 100755 index 0000000..936006c Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/ALIAS.CMD differ diff --git a/software/CPM/CPM32_ZCPR3/ARUNZ.COM b/software/CPM/CPM32_ZCPR3/ARUNZ.COM new file mode 100755 index 0000000..041b87c Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/ARUNZ.COM differ diff --git a/software/CPM/CPM32_ZCPR3/BGZRDS19.LBR b/software/CPM/CPM32_ZCPR3/BGZRDS19.LBR new file mode 100755 index 0000000..5849efa Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/BGZRDS19.LBR differ diff --git a/software/CPM/CPM32_ZCPR3/CLEDINST.COM b/software/CPM/CPM32_ZCPR3/CLEDINST.COM new file mode 100755 index 0000000..c26a3cf Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/CLEDINST.COM differ diff --git a/software/CPM/CPM32_ZCPR3/CLEDSAVE.COM b/software/CPM/CPM32_ZCPR3/CLEDSAVE.COM new file mode 100755 index 0000000..dde04bc Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/CLEDSAVE.COM differ diff --git a/software/CPM/CPM32_ZCPR3/CONFIG.LBR b/software/CPM/CPM32_ZCPR3/CONFIG.LBR new file mode 100755 index 0000000..40d87ae Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/CONFIG.LBR differ diff --git a/software/CPM/CPM32_ZCPR3/COPY.COM b/software/CPM/CPM32_ZCPR3/COPY.COM new file mode 100755 index 0000000..734953d Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/COPY.COM differ diff --git a/software/CPM/CPM32_ZCPR3/CPSET.COM b/software/CPM/CPM32_ZCPR3/CPSET.COM new file mode 100755 index 0000000..54462ce Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/CPSET.COM differ diff --git a/software/CPM/CPM32_ZCPR3/CRUNCH.COM b/software/CPM/CPM32_ZCPR3/CRUNCH.COM new file mode 100755 index 0000000..ac17854 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/CRUNCH.COM differ diff --git a/software/CPM/CPM32_ZCPR3/DOCFILES.LBR b/software/CPM/CPM32_ZCPR3/DOCFILES.LBR new file mode 100755 index 0000000..c96cd42 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/DOCFILES.LBR differ diff --git a/software/CPM/CPM32_ZCPR3/EDITNDR.COM b/software/CPM/CPM32_ZCPR3/EDITNDR.COM new file mode 100755 index 0000000..149cb98 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/EDITNDR.COM differ diff --git a/software/CPM/CPM32_ZCPR3/FCP.LBR b/software/CPM/CPM32_ZCPR3/FCP.LBR new file mode 100755 index 0000000..8eb74a4 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/FCP.LBR differ diff --git a/software/CPM/CPM32_ZCPR3/FF.COM b/software/CPM/CPM32_ZCPR3/FF.COM new file mode 100755 index 0000000..b68b2ad Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/FF.COM differ diff --git a/software/CPM/CPM32_ZCPR3/HELP.COM b/software/CPM/CPM32_ZCPR3/HELP.COM new file mode 100755 index 0000000..58b4d6f Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/HELP.COM differ diff --git a/software/CPM/CPM32_ZCPR3/HLPFILES.LBR b/software/CPM/CPM32_ZCPR3/HLPFILES.LBR new file mode 100755 index 0000000..32200cd Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/HLPFILES.LBR differ diff --git a/software/CPM/CPM32_ZCPR3/IF.COM b/software/CPM/CPM32_ZCPR3/IF.COM new file mode 100755 index 0000000..c51cd0b Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/IF.COM differ diff --git a/software/CPM/CPM32_ZCPR3/JETLDR.COM b/software/CPM/CPM32_ZCPR3/JETLDR.COM new file mode 100755 index 0000000..c33c073 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/JETLDR.COM differ diff --git a/software/CPM/CPM32_ZCPR3/LBREXT.COM b/software/CPM/CPM32_ZCPR3/LBREXT.COM new file mode 100755 index 0000000..591922b Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/LBREXT.COM differ diff --git a/software/CPM/CPM32_ZCPR3/LBRHELP.COM b/software/CPM/CPM32_ZCPR3/LBRHELP.COM new file mode 100755 index 0000000..eb1ef6e Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/LBRHELP.COM differ diff --git a/software/CPM/CPM32_ZCPR3/LDIR.COM b/software/CPM/CPM32_ZCPR3/LDIR.COM new file mode 100755 index 0000000..d72eeef Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/LDIR.COM differ diff --git a/software/CPM/CPM32_ZCPR3/LPUT.COM b/software/CPM/CPM32_ZCPR3/LPUT.COM new file mode 100755 index 0000000..7271696 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/LPUT.COM differ diff --git a/software/CPM/CPM32_ZCPR3/LSH-HELP.COM b/software/CPM/CPM32_ZCPR3/LSH-HELP.COM new file mode 100755 index 0000000..0103795 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/LSH-HELP.COM differ diff --git a/software/CPM/CPM32_ZCPR3/LSH.COM b/software/CPM/CPM32_ZCPR3/LSH.COM new file mode 100755 index 0000000..6ec314f Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/LSH.COM differ diff --git a/software/CPM/CPM32_ZCPR3/LSH.WZ b/software/CPM/CPM32_ZCPR3/LSH.WZ new file mode 100755 index 0000000..690f991 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/LSH.WZ differ diff --git a/software/CPM/CPM32_ZCPR3/LSHINST.COM b/software/CPM/CPM32_ZCPR3/LSHINST.COM new file mode 100755 index 0000000..a9beb35 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/LSHINST.COM differ diff --git a/software/CPM/CPM32_ZCPR3/LX.COM b/software/CPM/CPM32_ZCPR3/LX.COM new file mode 100755 index 0000000..d424f9f Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/LX.COM differ diff --git a/software/CPM/CPM32_ZCPR3/MKZCM.COM b/software/CPM/CPM32_ZCPR3/MKZCM.COM new file mode 100755 index 0000000..ad0ce7b Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/MKZCM.COM differ diff --git a/software/CPM/CPM32_ZCPR3/NAME.COM b/software/CPM/CPM32_ZCPR3/NAME.COM new file mode 100755 index 0000000..d3a8cdf Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/NAME.COM differ diff --git a/software/CPM/CPM32_ZCPR3/NZ-DBASE.INF b/software/CPM/CPM32_ZCPR3/NZ-DBASE.INF new file mode 100755 index 0000000..72f2169 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/NZ-DBASE.INF differ diff --git a/software/CPM/CPM32_ZCPR3/NZBLITZ.COM b/software/CPM/CPM32_ZCPR3/NZBLITZ.COM new file mode 100755 index 0000000..0355279 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/NZBLITZ.COM differ diff --git a/software/CPM/CPM32_ZCPR3/NZBLTZ14.CFG b/software/CPM/CPM32_ZCPR3/NZBLTZ14.CFG new file mode 100755 index 0000000..5ffb875 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/NZBLTZ14.CFG differ diff --git a/software/CPM/CPM32_ZCPR3/NZBLTZ14.HZP b/software/CPM/CPM32_ZCPR3/NZBLTZ14.HZP new file mode 100755 index 0000000..86d8590 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/NZBLTZ14.HZP differ diff --git a/software/CPM/CPM32_ZCPR3/NZCOM.COM b/software/CPM/CPM32_ZCPR3/NZCOM.COM new file mode 100755 index 0000000..b80c4d3 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/NZCOM.COM differ diff --git a/software/CPM/CPM32_ZCPR3/NZCOM.LBR b/software/CPM/CPM32_ZCPR3/NZCOM.LBR new file mode 100755 index 0000000..bf432b4 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/NZCOM.LBR differ diff --git a/software/CPM/CPM32_ZCPR3/NZCPR.LBR b/software/CPM/CPM32_ZCPR3/NZCPR.LBR new file mode 100755 index 0000000..1f51b0f Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/NZCPR.LBR differ diff --git a/software/CPM/CPM32_ZCPR3/PATH.COM b/software/CPM/CPM32_ZCPR3/PATH.COM new file mode 100755 index 0000000..1245c1a Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/PATH.COM differ diff --git a/software/CPM/CPM32_ZCPR3/PUBLIC.COM b/software/CPM/CPM32_ZCPR3/PUBLIC.COM new file mode 100755 index 0000000..e22e67d Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/PUBLIC.COM differ diff --git a/software/CPM/CPM32_ZCPR3/PWD.COM b/software/CPM/CPM32_ZCPR3/PWD.COM new file mode 100755 index 0000000..dda7ce7 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/PWD.COM differ diff --git a/software/CPM/CPM32_ZCPR3/RCP.LBR b/software/CPM/CPM32_ZCPR3/RCP.LBR new file mode 100755 index 0000000..fdc452f Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/RCP.LBR differ diff --git a/software/CPM/CPM32_ZCPR3/RELEASE.NOT b/software/CPM/CPM32_ZCPR3/RELEASE.NOT new file mode 100755 index 0000000..6b00642 --- /dev/null +++ b/software/CPM/CPM32_ZCPR3/RELEASE.NOT @@ -0,0 +1,266 @@ + + RELEASE.NOT - UPDATE INFORMATION ON NZCOM + + +Please understand that unlike purely commercial enterprises, Z-System is +mainly the work of enthusiasts. As such, Z-System never truly reaches +completion; each new development is more of a plateau upon which further +innovation occurs. Though we have done our best, the printed documentation +inevitably lags behind the most recent enhancements. Try to consult as +much material as possible about a given command before proceeding; if there +is a help or document file pertaining to the command, it supercedes printed +instructions, especially with regard to such matters as syntax or technical +specifications. + + +Notes of September 12, 1991 +=========================== + + Release 1.2H involves a significant updating of the support utilities that +we distribute as a courtesy with NZCOM. We suggest that any Z-System user who +is not in regular contact with a Z-Node consider taking advantage of the Z- +System Software Update Service (ZSUS). Here are some of the important changes +with this release. + +ZCNFG.COM, CONFIG.LBR: + Al Hawley has introduced a powerful and convenient method for + configuring programs. ZCNFG works either with individual CFG files or + with CFG files stored in the CONFIG.LBR library. For example, try + running the command "ZCNFG ZLT". ZCNFG will automatically extract + ZLT15.CFG from CONFIG.LBR. + +NZBLITZ.COM, NZBLTZ14.HZP, NZBLTZ14.CFG: + These programs can be used to coldboot an NZCOM system very rapidly + with the complete system, including error handlers, shells, and TCAPs + already in place. Run "HELP NZBLTZ14" to learn more about it. Some + of its features can be tailored by running "ZCNFG NZBLITZ" with the + CFG file in the same directory. + +LBREXT.COM: + This replaces LGET for extracting member files from LBR library files. + +HELP.COM, LBRHELP.COM, HLPFILES.LBR: + HELP (actually HELPC14) is an improved version of the help utility. + It can work with normal help files (HLP) and crunched help files + (HZP). LBRHELP can work with normal or crunched help files that are + stored in a library (which is where we have put all the help files + distributed with NZCOM and Z3PLUS). + +DOCFILES.LBR: + Documentation and help files have been collected into an LBR file. + +ZLT.COM: + This is a full Z-System replacement for LT, and it handles the latest + LZH-compressed files. + +COPY.COM: + This is the version of COPY from the ZSDOS/ZDDOS release. Enter "COPY + //" for syntax information. It replaces a dangerously defective copy + program provided with earlier releases. + +LSH.COM, LSH.WZ, LSH-HELP.COM, LSHINST.COM, ZERR.COM: + These are the latest LSH command history shell and command-line editor + and the associated error handler (fixed-log versions). These + completely replace EASE. + +CLEDINST.COM, CLEDSAVE.COM: + A transient history shell like LSH can be slow on floppy systems with + sluggish disk drives, even if the files have been placed in optimal + locations. Some of the RCP modules supplied no include an RCP- + resident command-line editor called CLED. Its features can be + configured using CLEDINST.COM, and the history can be saved to a file + using CLEDSAVE.COM. + +TCAP.LBR, XTCAP.COM: + A number of programs now require a terminal capabilities descriptor + (TCAP) with extended functions. The standard TCAPs loaded with + TCSELECT do not have these functions. TCAP.LBR is a collection of + extended TCAPs for some terminals. XTCAP.COM is a program that can + add the most important extensions to a standard TCAP (it is a quick- + and-dirty fix until the full set of TCAPs is updated). + +VIEW.COM: + This is Bridger Mitchell's file viewing utility. It is very powerful + (but it requires an extended TCAP). + +NAME.COM: + This program can quickly add or remove a name for a single directory. + +TCJ.INF: + TCJ has a new publisher (one of our own Z-Node sysops), and this file + tells how to take out a subscription (which all Z-System users + absolutely should do!). + +ZFILEB38.LZT: + This is the BRIEF listing of all the support programs currently + available for use with Z-System. There is another file which includes + descriptions of all the programs, but it would fill up an entire + diskette! + + +Notes of November 5, 1989 +========================= + + 1. NEW FILES: NZCPR.LBR, FCP.LBR, RCP.LBR. + 2. TCSELECT PROBLEM. + 3. ERA.COM, REN.COM, SAVE.COM, ETC. + 4. LSH REPLACES EASE. + 5. NZBLITZ IS HERE! + 6. MINOR UPDATE NOTES. + 7. TO NEW Z-SYSTEM USERS. + 8. ALERT ABOUT NZCPM.COM AND NZCOM.CCP + 9. CHANGE IN MKZCM DEFAULT AND STANDARD RCP + 10. NZBIO+.ZRL + +1. NEW FILES: NZCPR.LBR, FCP.LBR, RCP.LBR. + +The main NZCOM.LBR now contains only the standard configurations of the +CPR, FCP, and RCP modules to minimize disk space requirements. Alternative +versions of these modules are now supplied in separate libraries. Modules +can be loaded directly from these libraries, or individual files can be +extracted and put into NZCOM.LBR to replace the default files. Each +library has a brief DOC file describing the modules (one of which is the +default version included in NZCOM.LBR). + + +2. TCSELECT PROBLEM. + +A problem has been discovered with the operation of TCSELECT as described +in the manual. TCSELECT is a Z-System program and does not function +reliably under CP/M (on some systems it causes a crash). Fortunately there +is a simple fix: reverse the order of the instructions in the manual. Boot +up NZ-COM before attempting to create MYTERM.Z3T, and run TCSELECT only +after NZ-COM is running. Remember that you need both TCSELECT.COM and +Z3TCAP.TCP to generate your .Z3T file. The entries in the Z3TCAP library +for the Xerox computers has been patched to correct a long-standing error. + + +3. ERA.COM, REN.COM, SAVE.COM, ETC. + +The standard configuration of Z-System does not include resident commands +for REN, DIR, or SAVE. These are provided instead as transient programs +(COM files), and you should copy any that you need to your working disk. +Several other functions that are often resident (but not always) are also +provided as COM files. Many of these are type-4 programs (see the manual). +We recommend using SDZ.COM as your standard directory display utility. It +is far more functional than the resident DIR commands in either Z-System or +CP/M, and it is designed to work properly under both. + + +4. LSH REPLACES EASE. + +EASE has been replaced by a newer, more versatile, and well-behaved program +named LSH (Log SHell). Like EASE, LSH allows you to edit command lines +using WordStar-like control. Consult LSH.WZ before use for general +information and/or run HELPLSH while running LSH for a display of LSH's +capabilities. LSHINST installs and customizes LSH to taste. Error +handling is now taken care of by ZERR.COM, a separate program. Our great +thanks to Rob Friefeld for writing these superb Z-System tools and for +allowing us to include them with NZ-COM. + + +5. NZBLITZ IS HERE! + +NZBLITZ is now included with NZ-COM. True to its name, NZBLITZ loads NZCOM +(and ZSDOS/ZDDOS, if present) in a flash, making it extremely helpful in +saving and reloading a given system configuration. Once you have configured +your system as wanted, log to drive A0: and type NZBLITZ NZLOAD. From now +on, your startup to Z-System is MUCH faster; just type "NZLOAD". Be +forewarned that NZBLITZ saves EVERYTHING as currently active, so be sure you +are at the directory (usually A0:) you wish the system to start in, and be +sure all active shells, flow states, terminal definitions, and so on are the +desired ones before proceeding. See NZBLITZ.NZT for more information. + + +6. MINOR UPDATE NOTES. + +- The RCP WHLQ command no longer used. "WHL" alone displays the current + wheel status. As before, "WHL password" turns the wheel byte on. "WHL + xxx" now turns the wheel byte OFF if xxx is something other than the + correct password. + +- ARUNZ is now a type-4 program which loads at the highest possible + memory location so as to save lower memory for immediate re-execution + with GO. See ARUNZ09R.DZC and TCJ31.MZG (as well as your NZ-COM or + Z3PLUS manual) for more on the amazing ARUNZ. + +- VLU is no longer included, as it was not reliable. Please use LDIR, + LGET, LPUT, and LT instead to manipulate library files. + +- At this writing, we are sorry to note that both Z-Node Central and the + Lillipute Z-Nodes mentioned in Chapter 7 of your manual are out of + service. Z-Nodes 2 and 3 are still going strong, however, as are the + many others listed in ZNODES.LST. Z-Node 2 is the new Z-Node Central. + We cannot recommend highly enough that you get a modem and investigate at + least one Z-Node as a source of inspiration and support. + +- Version 5.0 of the ZEX batch processor replaces earlier versions. ZEX + now runs under both NZ-COM and Z3PLUS and is a very powerful means of + customizing programs and commands. The ZEX.RSX file mentioned in the + manual is no longer required. See ZEX50.DZC for help. + + +7. TO NEW Z-SYSTEM USERS. + +- All files whose middle filetype character is "Z" (e.g., SAMPLE.DZC) are + "crunched" files which must be uncompressed with LT.COM or UNCRUNCH.COM + before use. + +- As outlined in section 4.3.2 of your manual, most Z-System programs + have built-in help; type the name of any program followed by "//" for a + short description if you are confused. + +- Finally, it is not at all necessary to master every nuance of the system + before it becomes useful. Please don't try to devour all of Z-System at + once. Instead, we suggest that you decide what aspects of the system you + will find most helpful and try to master one or two of those before + exploring further. We think you will find that if you choose wisely, + learning one aspect fully not only makes that aspect of your computing + world easier, it also equips you with the skills and confidence with + which to surmount other aspects of Z-System more confidently. + + +8. ALERT ABOUT NZCPM.COM AND NZCOM.CCP + +Some users have been tripped up by the way NZCOM handles the generation of +an NZCPM.COM file: it writes such a file only if one does not already exist. +This speeds up loading of the system. However, should you ever make any +change to your base CP/M system (such as installing ZSDOS/ZDDOS or a new +version of the BIOS), you should be sure to erase the NZCPM.COM file so that +NZCOM will create a new one the next time it is run. You should also be +sure to use NZCOM and not NZBLITZ to load the system the first time after +such a change. + +You should also be aware that warmboots of the NZ-COM Z-System are performed +by loading the NZCOM.CCP file containing the image of the current command +processor. This means that you must not change the diskette in the A: drive +unless you have copied the **CURRENT** NZCOM.CCP file (if you only use one +system configuration, the current version will not change) to the diskette +you are going to place in the A: drive. + + +9. CHANGE IN MKZCM DEFAULT AND STANDARD RCP + +Carson Wilson and Rob Friefeld have made some major changes in the RCP code +(see the DOC file in RCP.LBR). The standard RCP module is now 18 records +long instead of 16. MKZCM.COM has been patched to provide this value as a +default. + + +10. NZBIO+.ZRL + +The BIOS in some computers uses the Z80 index and alternate registers +without +saving them on the stack and restoring them. These computers include the +TeleVideo 80x machines, the Oneac On!, the Zorba, and a number of other +machines. Some programs (JETLDR and EDITNDR, for example) will not function +properly under these conditions. The file NZBIO+.ZRL in NZCOM.LBR is a +special version of the NZ-COM virtual BIOS that protects the Zilog registers +across all BIOS calls. To use this BIOS, you much use MKZCM to allocate 4 +records to the BIOS. If you observe strange behavior on your system with +NZ-COM, you might want to try using this special BIOS. + + + + - End of RELEASE.NOT - + \ No newline at end of file diff --git a/software/CPM/CPM32_ZCPR3/SAINST.COM b/software/CPM/CPM32_ZCPR3/SAINST.COM new file mode 100755 index 0000000..1e6db48 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/SAINST.COM differ diff --git a/software/CPM/CPM32_ZCPR3/SALIAS.COM b/software/CPM/CPM32_ZCPR3/SALIAS.COM new file mode 100755 index 0000000..9b85e04 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/SALIAS.COM differ diff --git a/software/CPM/CPM32_ZCPR3/SAVENDR.COM b/software/CPM/CPM32_ZCPR3/SAVENDR.COM new file mode 100755 index 0000000..bf8d112 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/SAVENDR.COM differ diff --git a/software/CPM/CPM32_ZCPR3/SDZ.COM b/software/CPM/CPM32_ZCPR3/SDZ.COM new file mode 100755 index 0000000..46f81fd Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/SDZ.COM differ diff --git a/software/CPM/CPM32_ZCPR3/SHOW.COM b/software/CPM/CPM32_ZCPR3/SHOW.COM new file mode 100755 index 0000000..b22ce69 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/SHOW.COM differ diff --git a/software/CPM/CPM32_ZCPR3/SUB.COM b/software/CPM/CPM32_ZCPR3/SUB.COM new file mode 100755 index 0000000..f87c087 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/SUB.COM differ diff --git a/software/CPM/CPM32_ZCPR3/TCAP.LBR b/software/CPM/CPM32_ZCPR3/TCAP.LBR new file mode 100755 index 0000000..9a3fd9c Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TCAP.LBR differ diff --git a/software/CPM/CPM32_ZCPR3/TCJ.INF b/software/CPM/CPM32_ZCPR3/TCJ.INF new file mode 100755 index 0000000..7d9322c --- /dev/null +++ b/software/CPM/CPM32_ZCPR3/TCJ.INF @@ -0,0 +1,31 @@ + + Information About Subscriptions to + + The Computer Journal + + +The subscription rates for TCJ as of September 1, 1991, are as follows: + + 1 year 2 years + ------ ------- + U.S. $18 $32 + Foreign (surface mail) $24 $44 + Foreign (air mail) $38 $72 + +There are six issues per year. To place a subscription, contact the +new publisher (as of July 1992): + + The Computer Journal + P.O. Box 535 + Lincoln, CA 95658 + 916-645-1670 (answering machine and FAX) + +You may order a trial subscription. Just place an order. If you decide +that TCJ is not for you, then just mark the invoice "cancel" and send it +back. + +Payments for TCJ must normally be in the form of a money order or a check +drawn on a U.S. bank in U.S. funds or a postal money order in U.S. funds. +It is expected that MasterCard and VISA will again be acceptable in the +future. + \ No newline at end of file diff --git a/software/CPM/CPM32_ZCPR3/TCJ25.WZ b/software/CPM/CPM32_ZCPR3/TCJ25.WZ new file mode 100755 index 0000000..ad1a14e Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TCJ25.WZ differ diff --git a/software/CPM/CPM32_ZCPR3/TCJ26.WZ b/software/CPM/CPM32_ZCPR3/TCJ26.WZ new file mode 100755 index 0000000..97410f7 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TCJ26.WZ differ diff --git a/software/CPM/CPM32_ZCPR3/TCJ27.WZ b/software/CPM/CPM32_ZCPR3/TCJ27.WZ new file mode 100755 index 0000000..35905c1 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TCJ27.WZ differ diff --git a/software/CPM/CPM32_ZCPR3/TCJ28.WZ b/software/CPM/CPM32_ZCPR3/TCJ28.WZ new file mode 100755 index 0000000..ba0bdd5 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TCJ28.WZ differ diff --git a/software/CPM/CPM32_ZCPR3/TCJ29.WZ b/software/CPM/CPM32_ZCPR3/TCJ29.WZ new file mode 100755 index 0000000..116420d Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TCJ29.WZ differ diff --git a/software/CPM/CPM32_ZCPR3/TCJ30.WZ b/software/CPM/CPM32_ZCPR3/TCJ30.WZ new file mode 100755 index 0000000..dca4d43 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TCJ30.WZ differ diff --git a/software/CPM/CPM32_ZCPR3/TCJ31UPD.WZ b/software/CPM/CPM32_ZCPR3/TCJ31UPD.WZ new file mode 100755 index 0000000..f55b704 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TCJ31UPD.WZ differ diff --git a/software/CPM/CPM32_ZCPR3/TCJ32.WZ b/software/CPM/CPM32_ZCPR3/TCJ32.WZ new file mode 100755 index 0000000..87a3caa Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TCJ32.WZ differ diff --git a/software/CPM/CPM32_ZCPR3/TCJ33UPD.WZ b/software/CPM/CPM32_ZCPR3/TCJ33UPD.WZ new file mode 100755 index 0000000..782a9e3 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TCJ33UPD.WZ differ diff --git a/software/CPM/CPM32_ZCPR3/TCSELECT.COM b/software/CPM/CPM32_ZCPR3/TCSELECT.COM new file mode 100755 index 0000000..4b29b83 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TCSELECT.COM differ diff --git a/software/CPM/CPM32_ZCPR3/TY3ERA.COM b/software/CPM/CPM32_ZCPR3/TY3ERA.COM new file mode 100755 index 0000000..ac18c87 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TY3ERA.COM differ diff --git a/software/CPM/CPM32_ZCPR3/TY3REN.COM b/software/CPM/CPM32_ZCPR3/TY3REN.COM new file mode 100755 index 0000000..e5746c5 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TY3REN.COM differ diff --git a/software/CPM/CPM32_ZCPR3/TY4ERA.COM b/software/CPM/CPM32_ZCPR3/TY4ERA.COM new file mode 100755 index 0000000..77dac7f Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TY4ERA.COM differ diff --git a/software/CPM/CPM32_ZCPR3/TY4REN.COM b/software/CPM/CPM32_ZCPR3/TY4REN.COM new file mode 100755 index 0000000..fdfa70b Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TY4REN.COM differ diff --git a/software/CPM/CPM32_ZCPR3/TY4SAVE.COM b/software/CPM/CPM32_ZCPR3/TY4SAVE.COM new file mode 100755 index 0000000..59f9d77 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TY4SAVE.COM differ diff --git a/software/CPM/CPM32_ZCPR3/TY4SP.COM b/software/CPM/CPM32_ZCPR3/TY4SP.COM new file mode 100755 index 0000000..6c117b1 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/TY4SP.COM differ diff --git a/software/CPM/CPM32_ZCPR3/UNCRUNCH.COM b/software/CPM/CPM32_ZCPR3/UNCRUNCH.COM new file mode 100755 index 0000000..5ffb68e Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/UNCRUNCH.COM differ diff --git a/software/CPM/CPM32_ZCPR3/VIEW.COM b/software/CPM/CPM32_ZCPR3/VIEW.COM new file mode 100755 index 0000000..c812f75 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/VIEW.COM differ diff --git a/software/CPM/CPM32_ZCPR3/XTCAP.COM b/software/CPM/CPM32_ZCPR3/XTCAP.COM new file mode 100755 index 0000000..06b26f0 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/XTCAP.COM differ diff --git a/software/CPM/CPM32_ZCPR3/Z3LOC.COM b/software/CPM/CPM32_ZCPR3/Z3LOC.COM new file mode 100755 index 0000000..fab1359 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/Z3LOC.COM differ diff --git a/software/CPM/CPM32_ZCPR3/Z3TCAP.TCP b/software/CPM/CPM32_ZCPR3/Z3TCAP.TCP new file mode 100755 index 0000000..07adc28 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/Z3TCAP.TCP differ diff --git a/software/CPM/CPM32_ZCPR3/ZCNFG.COM b/software/CPM/CPM32_ZCPR3/ZCNFG.COM new file mode 100755 index 0000000..b88a2d0 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/ZCNFG.COM differ diff --git a/software/CPM/CPM32_ZCPR3/ZERR.COM b/software/CPM/CPM32_ZCPR3/ZERR.COM new file mode 100755 index 0000000..4565e7a Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/ZERR.COM differ diff --git a/software/CPM/CPM32_ZCPR3/ZEX.COM b/software/CPM/CPM32_ZCPR3/ZEX.COM new file mode 100755 index 0000000..cd46405 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/ZEX.COM differ diff --git a/software/CPM/CPM32_ZCPR3/ZF-DIM.COM b/software/CPM/CPM32_ZCPR3/ZF-DIM.COM new file mode 100755 index 0000000..1b1332c Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/ZF-DIM.COM differ diff --git a/software/CPM/CPM32_ZCPR3/ZF-REV.COM b/software/CPM/CPM32_ZCPR3/ZF-REV.COM new file mode 100755 index 0000000..b0cc279 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/ZF-REV.COM differ diff --git a/software/CPM/CPM32_ZCPR3/ZFILEB38.LZT b/software/CPM/CPM32_ZCPR3/ZFILEB38.LZT new file mode 100755 index 0000000..6c2c539 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/ZFILEB38.LZT differ diff --git a/software/CPM/CPM32_ZCPR3/ZFILER.CMD b/software/CPM/CPM32_ZCPR3/ZFILER.CMD new file mode 100755 index 0000000..3fddad5 --- /dev/null +++ b/software/CPM/CPM32_ZCPR3/ZFILER.CMD @@ -0,0 +1,28 @@ + Z System Distribution ZFILER.CMD, 11 Oct 89 by Carson Wilson +0 ! $"Enter ZFILER macro script: " +E ! echo f%>ull file spec:%< $p;echo f%>ile directory:%< $d$u:;echo f%>ile name.....:%< $n;echo f%>ile type.....:%< $t +K ! $d$u:;$!crunch $f $"Destination directory: ";$h: +L ! $!if eq $t lbr;ldir $p;else;echo f%>ile %<$f%> is not a library;fi +T ! $!lt $p +U ! $d$u:;uncr $f;$h: +X ! if ~eq $t com;echo n%>ot a % file;else;$d$u:;:$n $" Command Tail: ";$h:;fi +Z ! $d$u:;$" Command to perform on file: " $f $" Tail: ";$h: +# + SAMPLE ZFILER COMMAND MACROS FOR USE WITH NZCOM AND Z3PLUS + +macros: 0. on-line macro + E. Echo data about file name + K. Krunch the file + L. display directory of Library + T. Type the file + U. Uncrunch the file + X. eXecute the file + Z. perform command on file + +ZFILER parameters for use with macro '0' + + $! ZEX 'GO' $P DU:FN.FT $D DRIVE + $".." PROMPT $F FN.FT $U USER + $'..' PROMPT $N FN $H HOME DU + $T FT + \ No newline at end of file diff --git a/software/CPM/CPM32_ZCPR3/ZFILER.COM b/software/CPM/CPM32_ZCPR3/ZFILER.COM new file mode 100755 index 0000000..1b1332c Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/ZFILER.COM differ diff --git a/software/CPM/CPM32_ZCPR3/ZHELPERS.LZT b/software/CPM/CPM32_ZCPR3/ZHELPERS.LZT new file mode 100755 index 0000000..976755a Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/ZHELPERS.LZT differ diff --git a/software/CPM/CPM32_ZCPR3/ZLT.COM b/software/CPM/CPM32_ZCPR3/ZLT.COM new file mode 100755 index 0000000..57d04c5 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/ZLT.COM differ diff --git a/software/CPM/CPM32_ZCPR3/ZNODES66.LZT b/software/CPM/CPM32_ZCPR3/ZNODES66.LZT new file mode 100755 index 0000000..0f52992 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/ZNODES66.LZT differ diff --git a/software/CPM/CPM32_ZCPR3/ZSYSTEM.IZF b/software/CPM/CPM32_ZCPR3/ZSYSTEM.IZF new file mode 100755 index 0000000..87fb58e Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/ZSYSTEM.IZF differ diff --git a/software/CPM/CPM32_ZCPR3/nzcom.env b/software/CPM/CPM32_ZCPR3/nzcom.env new file mode 100644 index 0000000..28bbf69 Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/nzcom.env differ diff --git a/software/CPM/CPM32_ZCPR3/nzcom.zcm b/software/CPM/CPM32_ZCPR3/nzcom.zcm new file mode 100644 index 0000000..ddc85de Binary files /dev/null and b/software/CPM/CPM32_ZCPR3/nzcom.zcm differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/ARUNZ.COM b/software/CPM/CPM33_ZCPR3_COMMON/ARUNZ.COM new file mode 100644 index 0000000..041b87c Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/ARUNZ.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/CLEDINST.COM b/software/CPM/CPM33_ZCPR3_COMMON/CLEDINST.COM new file mode 100644 index 0000000..c26a3cf Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/CLEDINST.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/CLEDSAVE.COM b/software/CPM/CPM33_ZCPR3_COMMON/CLEDSAVE.COM new file mode 100644 index 0000000..dde04bc Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/CLEDSAVE.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/COMMON.CRC b/software/CPM/CPM33_ZCPR3_COMMON/COMMON.CRC new file mode 100644 index 0000000..4fc626b Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/COMMON.CRC differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/CONFIG.LBR b/software/CPM/CPM33_ZCPR3_COMMON/CONFIG.LBR new file mode 100644 index 0000000..40d87ae Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/CONFIG.LBR differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/COPY.COM b/software/CPM/CPM33_ZCPR3_COMMON/COPY.COM new file mode 100644 index 0000000..734953d Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/COPY.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/CPSET.COM b/software/CPM/CPM33_ZCPR3_COMMON/CPSET.COM new file mode 100644 index 0000000..54462ce Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/CPSET.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/CRUNCH.COM b/software/CPM/CPM33_ZCPR3_COMMON/CRUNCH.COM new file mode 100644 index 0000000..ac17854 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/CRUNCH.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/DOCFILES.LBR b/software/CPM/CPM33_ZCPR3_COMMON/DOCFILES.LBR new file mode 100644 index 0000000..c96cd42 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/DOCFILES.LBR differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/EDITNDR.COM b/software/CPM/CPM33_ZCPR3_COMMON/EDITNDR.COM new file mode 100644 index 0000000..149cb98 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/EDITNDR.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/FCP.LBR b/software/CPM/CPM33_ZCPR3_COMMON/FCP.LBR new file mode 100644 index 0000000..8eb74a4 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/FCP.LBR differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/FF.COM b/software/CPM/CPM33_ZCPR3_COMMON/FF.COM new file mode 100644 index 0000000..b68b2ad Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/FF.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/HLPFILES.LBR b/software/CPM/CPM33_ZCPR3_COMMON/HLPFILES.LBR new file mode 100644 index 0000000..32200cd Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/HLPFILES.LBR differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/IF.COM b/software/CPM/CPM33_ZCPR3_COMMON/IF.COM new file mode 100644 index 0000000..c51cd0b Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/IF.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/JETLDR.COM b/software/CPM/CPM33_ZCPR3_COMMON/JETLDR.COM new file mode 100644 index 0000000..c33c073 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/JETLDR.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/LBREXT.COM b/software/CPM/CPM33_ZCPR3_COMMON/LBREXT.COM new file mode 100644 index 0000000..591922b Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/LBREXT.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/LBRHELP.COM b/software/CPM/CPM33_ZCPR3_COMMON/LBRHELP.COM new file mode 100644 index 0000000..eb1ef6e Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/LBRHELP.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/LDIR.COM b/software/CPM/CPM33_ZCPR3_COMMON/LDIR.COM new file mode 100644 index 0000000..d72eeef Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/LDIR.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/LPUT.COM b/software/CPM/CPM33_ZCPR3_COMMON/LPUT.COM new file mode 100644 index 0000000..7271696 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/LPUT.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/LSH-HELP.COM b/software/CPM/CPM33_ZCPR3_COMMON/LSH-HELP.COM new file mode 100644 index 0000000..0103795 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/LSH-HELP.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/LSH.COM b/software/CPM/CPM33_ZCPR3_COMMON/LSH.COM new file mode 100644 index 0000000..6ec314f Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/LSH.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/LSH.WZ b/software/CPM/CPM33_ZCPR3_COMMON/LSH.WZ new file mode 100644 index 0000000..690f991 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/LSH.WZ differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/LSHINST.COM b/software/CPM/CPM33_ZCPR3_COMMON/LSHINST.COM new file mode 100644 index 0000000..a9beb35 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/LSHINST.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/LX.COM b/software/CPM/CPM33_ZCPR3_COMMON/LX.COM new file mode 100644 index 0000000..d424f9f Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/LX.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/NAME.COM b/software/CPM/CPM33_ZCPR3_COMMON/NAME.COM new file mode 100644 index 0000000..d3a8cdf Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/NAME.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/PATH.COM b/software/CPM/CPM33_ZCPR3_COMMON/PATH.COM new file mode 100644 index 0000000..1245c1a Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/PATH.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/PWD.COM b/software/CPM/CPM33_ZCPR3_COMMON/PWD.COM new file mode 100644 index 0000000..dda7ce7 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/PWD.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/RCP.LBR b/software/CPM/CPM33_ZCPR3_COMMON/RCP.LBR new file mode 100644 index 0000000..fdc452f Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/RCP.LBR differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/SAINST.COM b/software/CPM/CPM33_ZCPR3_COMMON/SAINST.COM new file mode 100644 index 0000000..1e6db48 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/SAINST.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/SALIAS.COM b/software/CPM/CPM33_ZCPR3_COMMON/SALIAS.COM new file mode 100644 index 0000000..9b85e04 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/SALIAS.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/SAVENDR.COM b/software/CPM/CPM33_ZCPR3_COMMON/SAVENDR.COM new file mode 100644 index 0000000..bf8d112 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/SAVENDR.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/SDZ.COM b/software/CPM/CPM33_ZCPR3_COMMON/SDZ.COM new file mode 100644 index 0000000..46f81fd Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/SDZ.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/TCAP.LBR b/software/CPM/CPM33_ZCPR3_COMMON/TCAP.LBR new file mode 100644 index 0000000..9a3fd9c Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/TCAP.LBR differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/TCJ.INF b/software/CPM/CPM33_ZCPR3_COMMON/TCJ.INF new file mode 100644 index 0000000..7d9322c --- /dev/null +++ b/software/CPM/CPM33_ZCPR3_COMMON/TCJ.INF @@ -0,0 +1,31 @@ + + Information About Subscriptions to + + The Computer Journal + + +The subscription rates for TCJ as of September 1, 1991, are as follows: + + 1 year 2 years + ------ ------- + U.S. $18 $32 + Foreign (surface mail) $24 $44 + Foreign (air mail) $38 $72 + +There are six issues per year. To place a subscription, contact the +new publisher (as of July 1992): + + The Computer Journal + P.O. Box 535 + Lincoln, CA 95658 + 916-645-1670 (answering machine and FAX) + +You may order a trial subscription. Just place an order. If you decide +that TCJ is not for you, then just mark the invoice "cancel" and send it +back. + +Payments for TCJ must normally be in the form of a money order or a check +drawn on a U.S. bank in U.S. funds or a postal money order in U.S. funds. +It is expected that MasterCard and VISA will again be acceptable in the +future. + \ No newline at end of file diff --git a/software/CPM/CPM33_ZCPR3_COMMON/TCSELECT.COM b/software/CPM/CPM33_ZCPR3_COMMON/TCSELECT.COM new file mode 100644 index 0000000..4b29b83 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/TCSELECT.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/TY3ERA.COM b/software/CPM/CPM33_ZCPR3_COMMON/TY3ERA.COM new file mode 100644 index 0000000..ac18c87 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/TY3ERA.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/TY3REN.COM b/software/CPM/CPM33_ZCPR3_COMMON/TY3REN.COM new file mode 100644 index 0000000..e5746c5 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/TY3REN.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/TY4ERA.COM b/software/CPM/CPM33_ZCPR3_COMMON/TY4ERA.COM new file mode 100644 index 0000000..77dac7f Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/TY4ERA.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/TY4REN.COM b/software/CPM/CPM33_ZCPR3_COMMON/TY4REN.COM new file mode 100644 index 0000000..fdfa70b Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/TY4REN.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/TY4SAVE.COM b/software/CPM/CPM33_ZCPR3_COMMON/TY4SAVE.COM new file mode 100644 index 0000000..59f9d77 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/TY4SAVE.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/TY4SP.COM b/software/CPM/CPM33_ZCPR3_COMMON/TY4SP.COM new file mode 100644 index 0000000..6c117b1 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/TY4SP.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/UNCRUNCH.COM b/software/CPM/CPM33_ZCPR3_COMMON/UNCRUNCH.COM new file mode 100644 index 0000000..5ffb68e Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/UNCRUNCH.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/VIEW.COM b/software/CPM/CPM33_ZCPR3_COMMON/VIEW.COM new file mode 100644 index 0000000..c812f75 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/VIEW.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/XTCAP.COM b/software/CPM/CPM33_ZCPR3_COMMON/XTCAP.COM new file mode 100644 index 0000000..06b26f0 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/XTCAP.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/Z3TCAP.TCP b/software/CPM/CPM33_ZCPR3_COMMON/Z3TCAP.TCP new file mode 100644 index 0000000..07adc28 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/Z3TCAP.TCP differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/ZCNFG.COM b/software/CPM/CPM33_ZCPR3_COMMON/ZCNFG.COM new file mode 100644 index 0000000..b88a2d0 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/ZCNFG.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/ZERR.COM b/software/CPM/CPM33_ZCPR3_COMMON/ZERR.COM new file mode 100644 index 0000000..4565e7a Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/ZERR.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/ZEX.COM b/software/CPM/CPM33_ZCPR3_COMMON/ZEX.COM new file mode 100644 index 0000000..cd46405 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/ZEX.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/ZF-DIM.COM b/software/CPM/CPM33_ZCPR3_COMMON/ZF-DIM.COM new file mode 100644 index 0000000..1b1332c Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/ZF-DIM.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/ZF-REV.COM b/software/CPM/CPM33_ZCPR3_COMMON/ZF-REV.COM new file mode 100644 index 0000000..b0cc279 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/ZF-REV.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/ZFILEB38.LZT b/software/CPM/CPM33_ZCPR3_COMMON/ZFILEB38.LZT new file mode 100644 index 0000000..6c2c539 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/ZFILEB38.LZT differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/ZFILER.CMD b/software/CPM/CPM33_ZCPR3_COMMON/ZFILER.CMD new file mode 100644 index 0000000..3fddad5 --- /dev/null +++ b/software/CPM/CPM33_ZCPR3_COMMON/ZFILER.CMD @@ -0,0 +1,28 @@ + Z System Distribution ZFILER.CMD, 11 Oct 89 by Carson Wilson +0 ! $"Enter ZFILER macro script: " +E ! echo f%>ull file spec:%< $p;echo f%>ile directory:%< $d$u:;echo f%>ile name.....:%< $n;echo f%>ile type.....:%< $t +K ! $d$u:;$!crunch $f $"Destination directory: ";$h: +L ! $!if eq $t lbr;ldir $p;else;echo f%>ile %<$f%> is not a library;fi +T ! $!lt $p +U ! $d$u:;uncr $f;$h: +X ! if ~eq $t com;echo n%>ot a % file;else;$d$u:;:$n $" Command Tail: ";$h:;fi +Z ! $d$u:;$" Command to perform on file: " $f $" Tail: ";$h: +# + SAMPLE ZFILER COMMAND MACROS FOR USE WITH NZCOM AND Z3PLUS + +macros: 0. on-line macro + E. Echo data about file name + K. Krunch the file + L. display directory of Library + T. Type the file + U. Uncrunch the file + X. eXecute the file + Z. perform command on file + +ZFILER parameters for use with macro '0' + + $! ZEX 'GO' $P DU:FN.FT $D DRIVE + $".." PROMPT $F FN.FT $U USER + $'..' PROMPT $N FN $H HOME DU + $T FT + \ No newline at end of file diff --git a/software/CPM/CPM33_ZCPR3_COMMON/ZHELPERS.LZT b/software/CPM/CPM33_ZCPR3_COMMON/ZHELPERS.LZT new file mode 100644 index 0000000..976755a Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/ZHELPERS.LZT differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/ZLT.COM b/software/CPM/CPM33_ZCPR3_COMMON/ZLT.COM new file mode 100644 index 0000000..57d04c5 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/ZLT.COM differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/ZNODES66.LZT b/software/CPM/CPM33_ZCPR3_COMMON/ZNODES66.LZT new file mode 100644 index 0000000..0f52992 Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/ZNODES66.LZT differ diff --git a/software/CPM/CPM33_ZCPR3_COMMON/ZSYSTEM.IZF b/software/CPM/CPM33_ZCPR3_COMMON/ZSYSTEM.IZF new file mode 100644 index 0000000..87fb58e Binary files /dev/null and b/software/CPM/CPM33_ZCPR3_COMMON/ZSYSTEM.IZF differ diff --git a/software/MZF/BASIC_OM-1000.MZF b/software/MZF/BASIC_OM-1000.MZF index 6858c96..931c6ac 100644 Binary files a/software/MZF/BASIC_OM-1000.MZF and b/software/MZF/BASIC_OM-1000.MZF differ diff --git a/software/MZF/BASIC_SP-5025.MZF b/software/MZF/BASIC_SP-5025.MZF index 220c1b3..621bf5b 100644 Binary files a/software/MZF/BASIC_SP-5025.MZF and b/software/MZF/BASIC_SP-5025.MZF differ diff --git a/software/MZF/CIRCUS_STAR.MZF b/software/MZF/CIRCUS_STAR.MZF deleted file mode 100644 index 6c5ac28..0000000 Binary files a/software/MZF/CIRCUS_STAR.MZF and /dev/null differ diff --git a/software/MZF/clock1.MZF b/software/MZF/clock1.MZF index f601436..ca21786 100644 Binary files a/software/MZF/clock1.MZF and b/software/MZF/clock1.MZF differ diff --git a/software/MZF/cpm22.MZF b/software/MZF/cpm22.MZF index 02e6772..78235e3 100644 Binary files a/software/MZF/cpm22.MZF and b/software/MZF/cpm22.MZF differ diff --git a/software/MZF/sdtest.MZF b/software/MZF/sdtest.MZF new file mode 100644 index 0000000..0045847 Binary files /dev/null and b/software/MZF/sdtest.MZF differ diff --git a/software/asm/cbios.asm b/software/asm/cbios.asm index 5b9b575..3590814 100644 --- a/software/asm/cbios.asm +++ b/software/asm/cbios.asm @@ -58,48 +58,49 @@ ; is switched in and a jump made to the public function. The page remains ; selected until the next public access call and the page changed accordingly. -BANK4: PUSH AF - LD A,ROMBANK4 +BANK8: PUSH AF + LD A,ROMBANK8 LD (RFSBK2),A POP AF RET -BANK5: PUSH AF - LD A,ROMBANK5 +BANK9: PUSH AF + LD A,ROMBANK9 LD (RFSBK2),A POP AF RET ; Public methods for User Rom CBIOS Bank 1 -?REBOOT: CALL BANK4 +?REBOOT: LD A,ROMBANK8 + LD (RFSBK2),A JP QREBOOT -?MLDY: CALL BANK4 +?MLDY: CALL BANK8 JP QMELDY -?BEL: CALL BANK4 +?BEL: CALL BANK8 JP QBEL -?TEMP: CALL BANK4 +?TEMP: CALL BANK8 JP QTEMP -?MLDST: CALL BANK4 +?MLDST: CALL BANK8 JP QMSTA -?MLDSP: CALL BANK4 +?MLDSP: CALL BANK8 JP QMSTP ; Public methods for User Rom CBIOS Bank 2 -?PRNT: CALL BANK5 +?PRNT: CALL BANK9 JP QPRNT -?PRTHX: CALL BANK5 +?PRTHX: CALL BANK9 JP QPRTHX -?PRTHL: CALL BANK5 +?PRTHL: CALL BANK9 JP QPRTHL -?ANSITERM: CALL BANK5 +?ANSITERM: CALL BANK9 JP QANSITERM ?NL: LD A,LF @@ -109,11 +110,11 @@ BANK5: PUSH AF JR ?PRNT ; Public methods for User Rom CBIOS Bank 3 - LD A,ROMBANK6 + LD A,ROMBANK10 LD (RFSBK2),A JP 00000h ; Public methods for User Rom CBIOS Bank 4 - LD A,ROMBANK7 + LD A,ROMBANK11 LD (RFSBK2),A JP 00000h @@ -570,11 +571,8 @@ STRT1: CALL CLR8 LD A,0FFH LD (SWRK),A - ; Setup timer interrupts - LD BC,00000H ; Time starts at 00:00:00 01/01/1980 on initialisation. - LD DE,00000H - LD HL,00000H - CALL TIMESET + ; Initialise the SD Card subsystem. + ; CALL SPI_INIT ; Locate the CPM Image and store the Bank/Block to speed up warm boot. LD HL,CPMROMFNAME ; Name of CPM File in rom. @@ -602,6 +600,12 @@ STRT3: LD HL,NUMBERBUF LD (IOBYT),A LD (CDISK),A ; + ; Setup timer interrupts + LD BC,00000H ; Time starts at 00:00:00 01/01/1980 on initialisation. + LD DE,00000H + LD HL,00000H + CALL TIMESET + ; JR CPMINIT ;------------------------------------------------------------------------------- @@ -618,7 +622,7 @@ WINIT: DI LD DE,CPMBIOS-CBASE ; Only want to load in CCP and BDOS. LD BC,(CPMROMLOC) ; Load up the Bank and Page where the CPM Image can be found. CALL MROMLOAD - LD A,ROMBANK5 + LD A,ROMBANK9 ; Screen Bank. LD (RFSBK2),A ; CPMINIT: CALL DSKINIT ; Initialise the disk subsystem. @@ -1041,6 +1045,10 @@ TIMESET: DI NOP NOP NOP + LD A, 0C3H ; Install the interrupt vector for when interrupts are enabled. + LD HL,TIMIN + LD (00038H),A + LD (00039H),HL ; POP HL POP DE @@ -1209,11 +1217,10 @@ L0D78: DJNZ DUM2 DEC A LD (TMPCNT),A JR NZ,DUM3 -DUM4: LD A,(KEYBUF) +DUM4: CALL CHKKY CP 0FFH - ;CALL ?KEY - JR Z,DUM4 - ;CALL ?DACN + JR NZ,DUM4 + CALL GETKY CP 'D' JR NZ,DUM5 LD A,8 @@ -1327,7 +1334,7 @@ FINDMZF: LD (TMPADR), HL ; Save name of program to load. ; C = Block in page ; D = File sequence number. ; -FINDMZF0: LD B,8 ; First 8 pages are reserved in User ROM bank. +FINDMZF0: LD B,USRROMPAGES ; First 16 pages are reserved in User ROM bank. LD C,0 ; Block in page. LD D,0 ; File numbering start. FINDMZF1: LD A,B @@ -1475,7 +1482,7 @@ LROMLOAD7: LD A, B ; LROMLOAD8: POP BC LROMLOAD5: PUSH AF - LD A,ROMBANK7 + LD A,ROMBANK9 LD (RFSBK2), A ; Set the MROM bank back to original. POP AF RET @@ -1486,7 +1493,7 @@ LROMLOAD5: PUSH AF ROMREAD: LD DE,(HSTTRK) ; To cater for larger RFS images in the future we use the full 16bit track number. LD (TRACKNO),DE LD A, BANKSPERTRACK * SECTORSPERBANK - LD B,8 + LD B,8 LD HL,0 ROMREAD2: ADD HL,HL RLCA @@ -1623,7 +1630,7 @@ ROMREAD16: LD A, B ; ROMREAD17: POP BC ROMREAD18: PUSH AF - LD A,ROMBANK7 ; Reselect utilities bank. + LD A,ROMBANK9 ; Reselect utilities bank. LD (RFSBK2), A ; Set the MROM bank back to original. POP AF POP HL @@ -1967,9 +1974,7 @@ SELDRIVE: LD A,(CDISK) ;SCF ;CCF ;CALL DEBUG - LD A,(MOTON) ; motor on flag - RRCA ; motor off? - CALL NC,DSKMTRON ; yes, set motor on and wait + CALL DSKMTRON ; yes, set motor on and wait LD A,(FDCDISK) ; select drive no OR 084H OUT (FDC_MOTOR),A ; Motor on for drive 0-3 @@ -1997,7 +2002,9 @@ SELDRV3: CALL SETDRVCFG RET ; Turn disk motor on if not already running. -DSKMTRON: LD A,(MOTON) ; Test to see if motor is on, if it isnt, switch it on. +DSKMTRON: LD A,255 ; Ensure motor is kept running whilst we read/write. + LD (MTROFFTIMER),A + LD A,(MOTON) ; Test to see if motor is on, if it isnt, switch it on. RRCA JR NC, DSKMOTORON RET @@ -2050,8 +2057,11 @@ DSKWRITE3: CALL SETHEAD ; Set s LD IY,WRITEDATA ; Write sector from memory. DI ; - SCF - CALL DEBUG + IF ENADEBUG = 1 + SCF + CALL DEBUG + ENDIF + LD A,0B4H ; Write Sector multipe with Side Compare for side 1. CALL DISKCMDWAIT LD D,2 ; Regardless of 4x128, 2x256 or 1x512, we always read 512bytes by the 2x INI instruction with B=256. @@ -2321,7 +2331,50 @@ ERRPRTSTR: EX DE,HL EX DE,HL JP MONPRTSTR + ;------------------------------------------------------------------------------- + ; SPI I/O Routines. + ; + ; Basic Input and Output routines to send and receive data with an SD card. + ;------------------------------------------------------------------------------- + ; + ; Function to initialise the SPI hardware. + ; +;SPI_INIT: LD A,DOUT_HIGH | CLOCK_HIGH | CS_LOW ; Clock and MOSI High. +; OUT (SPI_OUT),A +; RET + + ; + ; Function to output a byte to the SPI port and read a byte being returned by the slave simultaneously. + ; Input; A = Char to send + ; Output: C = Char received. + ; +;SPI_IO: PUSH DE +; LD E,A ; E = Character to send. +; LD C,0 ; C = Character being read. +; LD B,008H +;SPI0: LD A,E +; RLCA +; LD E,A +; LD A,DOUT_LOW | CLOCK_HIGH | CS_LOW ; Output a 0 +; JR NC,SPI1 +; LD A,DOUT_HIGH | CLOCK_HIGH | CS_LOW ; Output a 1 +;SPI1: OUT (SPI_OUT),A +; LD D,A ; Preserve sent data. +; IN A,(SPI_IN) ; Input the received bit +; AND DIN_HIGH ; Mask and add to the byte being assembled. +; OR C +; RRCA +; LD C,A ; Store assembled byte. +; LD A,D +; AND DOUT_HIGH | CLOCK_LOW | CS_LOW ; Bring clock low preserving output data. +; OUT (SPI_OUT),A +; DJNZ SPI0 ; Perform actions for the full 8 bits. +; LD A,DOUT_HIGH | CLOCK_HIGH | CS_LOW ; Return clock and MOSI to high. +; OUT (SPI_OUT),A +; POP DE +; RET +; ; Debug routine to print out all registers and dump a section of memory for analysis. ; diff --git a/software/asm/cpm22-bios.asm b/software/asm/cpm22-bios.asm index 42663a6..e1da4d5 100644 --- a/software/asm/cpm22-bios.asm +++ b/software/asm/cpm22-bios.asm @@ -75,4 +75,4 @@ ALV2: DS (720/8)+1 ; alloc CSV3: DS 32 ; scratch area for drive 3. ALV3: DS (720/8)+1 ; allocation vector 3 - ALIGN_NOPS CBIOSDATA + ALIGN CBIOSDATA diff --git a/software/asm/include/CPM_Definitions.asm b/software/asm/include/CPM_Definitions.asm index 973d212..54a0302 100644 --- a/software/asm/include/CPM_Definitions.asm +++ b/software/asm/include/CPM_Definitions.asm @@ -77,7 +77,7 @@ NDISKS EQU 4 ; Numbe KEYBUFSIZE EQU 16 ; Ensure this is a power of 2, max size 256. ; Debugging -ENADEBUG EQU 0 ; Enable debugging logic, 1 = enable, 0 = disable +ENADEBUG EQU 1 ; Enable debugging logic, 1 = enable, 0 = disable ;----------------------------------------------- ; Configurable settings. @@ -149,6 +149,21 @@ RFSBK2: EQU 0EFFDh ; Selec RFSRST1: EQU 0EFFEh ; Reset RFS Bank1 to original. RFSRST2: EQU 0EFFFh ; Reset RFS Bank2 to original. +;----------------------------------------------- +; IO ports in hardware and values. +;----------------------------------------------- +SPI_OUT EQU 0FFH +SPI_IN EQU 0FEH +; +DOUT_LOW EQU 000H +DOUT_HIGH EQU 004H +DIN_LOW EQU 000H +DIN_HIGH EQU 001H +CLOCK_LOW EQU 000H +CLOCK_HIGH EQU 002H +CS_LOW EQU 000H +CS_HIGH EQU 001H + ;----------------------------------------------- ; Rom File System Header (MZF) ;----------------------------------------------- @@ -174,11 +189,16 @@ WRKROMBK1: EQU 01018H ; WORKI WRKROMBK2: EQU 01019H ; WORKING USERROM BANK ;----------------------------------------------- -; ROM Banks, 0-3 are reserved for alternative -; Monitor versions in MROM bank, -; 0-7 are reserved for RFS code in the -; User ROM bank. +; ROM Banks, 0-7 are reserved for alternative +; Monitor versions, CPM and RFS +; code in MROM bank, +; 0-7 are reserved for RFS code in +; the User ROM bank. +; 8-15 are reserved for CPM code in +; the User ROM bank. ;----------------------------------------------- +MROMPAGES EQU 8 +USRROMPAGES EQU 12 ROMBANK0 EQU 0 ROMBANK1 EQU 1 ROMBANK2 EQU 2 @@ -187,6 +207,10 @@ ROMBANK4 EQU 4 ROMBANK5 EQU 5 ROMBANK6 EQU 6 ROMBANK7 EQU 7 +ROMBANK8 EQU 8 +ROMBANK9 EQU 9 +ROMBANK10 EQU 10 +ROMBANK11 EQU 11 OBJCD EQU 001h @@ -289,7 +313,7 @@ SWPW: DS virtual 10 ; SWEEP KDATW: DS virtual 2 ; KEY WORK ;KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE) DSPXY: DS virtual 2 ; DISPLAY COORDINATES -DSPXYLST: DS virtual 2 ; Last known cursor position, to compare with DSPXY to detect changes. +;DSPXYLST: DS virtual 2 ; Last known cursor position, to compare with DSPXY to detect changes. FLASHCTL: DS virtual 1 ; CURSOR FLASH CONTROL. BIT 0 = Cursor On/Off, BIT 1 = Cursor displayed. DSPXYADDR: DS virtual 2 ; Address of last known position. MANG: DS virtual 6 ; COLUMN MANAGEMENT @@ -306,8 +330,8 @@ REVFLG: DS virtual 1 ; REVER FLSDT: DS virtual 1 ; CURSOR DATA STRGF: DS virtual 1 ; STRING FLAG DPRNT: DS virtual 1 ; TAB COUNTER -AMPM: DS virtual 1 ; AMPM DATA -TIMFG: DS virtual 1 ; TIME FLAG +;AMPM: DS virtual 1 ; AMPM DATA +;TIMFG: DS virtual 1 ; TIME FLAG SWRK: DS virtual 1 ; KEY SOUND FLAG TEMPW: DS virtual 1 ; TEMPO WORK ONTYO: DS virtual 1 ; ONTYO WORK @@ -392,8 +416,8 @@ SPISRSAVE: DS virtual 2 VAREND EQU $ ; End of variables ; Stack space for the CBIOS. - DS virtual 128 + DS virtual 64 BIOSSTACK EQU $ ; Stack space for the Interrupt Service Routine. - DS virtual 32 ; Max 8 stack pushes. + DS virtual 16 ; Max 8 stack pushes. ISRSTACK EQU $ diff --git a/software/asm/include/RFS_Definitions.asm b/software/asm/include/RFS_Definitions.asm index be53e66..11e6f3a 100644 --- a/software/asm/include/RFS_Definitions.asm +++ b/software/asm/include/RFS_Definitions.asm @@ -29,244 +29,330 @@ ;------------------------------------------------------- ; Function entry points in the standard SA-1510 Monitor. ;------------------------------------------------------- -GETL: EQU 00003h -LETNL: EQU 00006h -NL: EQU 00009h -PRNTS: EQU 0000Ch -PRNT: EQU 00012h -MSG: EQU 00015h -MSGX: EQU 00018h -GETKY EQU 0001Bh -BRKEY EQU 0001Eh -?WRI EQU 00021h -?WRD EQU 00024h -?RDI EQU 00027h -?RDD EQU 0002Ah -?VRFY EQU 0002Dh -MELDY EQU 00030h -?TMST EQU 00033h -MONIT: EQU 00000h -SS: EQU 00089h -ST1: EQU 00095h -MSGE1 EQU 00118h -HLHEX EQU 00410h -_2HEX EQU 0041Fh -?MODE: EQU 0074DH -?KEY EQU 008CAh -PRNT3 EQU 0096Ch -MSG?2 EQU 000F7h -?ADCN EQU 00BB9h -?DACN EQU 00BCEh -?BLNK EQU 00DA6h -?DPCT EQU 00DDCh -PRTHL: EQU 003BAh -PRTHX: EQU 003C3h -HEX: EQU 003F9h -DPCT: EQU 00DDCh -DLY12: EQU 00DA7h -DLY12A: EQU 00DAAh -?RSTR1: EQU 00EE6h +GETL: EQU 00003h +LETNL: EQU 00006h +NL: EQU 00009h +PRNTS: EQU 0000Ch +PRNT: EQU 00012h +MSG: EQU 00015h +MSGX: EQU 00018h +GETKY EQU 0001Bh +BRKEY EQU 0001Eh +?WRI EQU 00021h +?WRD EQU 00024h +?RDI EQU 00027h +?RDD EQU 0002Ah +?VRFY EQU 0002Dh +MELDY EQU 00030h +?TMST EQU 00033h +MONIT: EQU 00000h +SS: EQU 00089h +ST1: EQU 00095h +MSGE1 EQU 00118h +HLHEX EQU 00410h +_2HEX EQU 0041Fh +?MODE: EQU 0074DH +?KEY EQU 008CAh +PRNT3 EQU 0096Ch +MSG?2 EQU 000F7h +?ADCN EQU 00BB9h +?DACN EQU 00BCEh +?BLNK EQU 00DA6h +?DPCT EQU 00DDCh +PRTHL: EQU 003BAh +PRTHX: EQU 003C3h +HEX: EQU 003F9h +DPCT: EQU 00DDCh +DLY12: EQU 00DA7h +DLY12A: EQU 00DAAh +?RSTR1: EQU 00EE6h ;----------------------------------------------- ; Memory mapped ports in hardware. ;----------------------------------------------- -SCRN: EQU 0D000H -ARAM: EQU 0D800H -DSPCTL: EQU 0DFFFH ; Screen 40/80 select register (bit 7) -KEYPA: EQU 0E000h -KEYPB: EQU 0E001h -KEYPC: EQU 0E002h -KEYPF: EQU 0E003h -CSTR: EQU 0E002h -CSTPT: EQU 0E003h -CONT0: EQU 0E004h -CONT1: EQU 0E005h -CONT2: EQU 0E006h -CONTF: EQU 0E007h -SUNDG: EQU 0E008h -TEMP: EQU 0E008h -MEMSW: EQU 0E00CH -MEMSWR: EQU 0E010H -INVDSP: EQU 0E014H -NRMDSP: EQU 0E015H -SCLDSP: EQU 0E200H -SCLBASE: EQU 0E2H -RFSBK1: EQU 0EFFCh ; Select RFS Bank1 (MROM) -RFSBK2: EQU 0EFFDh ; Select RFS Bank2 (User ROM) -RFSRST1: EQU 0EFFEh ; Reset RFS Bank1 to original. -RFSRST2: EQU 0EFFFh ; Reset RFS Bank2 to original. +SCRN: EQU 0D000H +ARAM: EQU 0D800H +DSPCTL: EQU 0DFFFH ; Screen 40/80 select register (bit 7) +KEYPA: EQU 0E000h +KEYPB: EQU 0E001h +KEYPC: EQU 0E002h +KEYPF: EQU 0E003h +CSTR: EQU 0E002h +CSTPT: EQU 0E003h +CONT0: EQU 0E004h +CONT1: EQU 0E005h +CONT2: EQU 0E006h +CONTF: EQU 0E007h +SUNDG: EQU 0E008h +TEMP: EQU 0E008h +MEMSW: EQU 0E00CH +MEMSWR: EQU 0E010H +INVDSP: EQU 0E014H +NRMDSP: EQU 0E015H +SCLDSP: EQU 0E200H +SCLBASE: EQU 0E2H +RFSBK1: EQU 0EFFCh ; Select RFS Bank1 (MROM) +RFSBK2: EQU 0EFFDh ; Select RFS Bank2 (User ROM) +RFSRST1: EQU 0EFFEh ; Reset RFS Bank1 to original. +RFSRST2: EQU 0EFFFh ; Reset RFS Bank2 to original. ;----------------------------------------------- ; Rom File System Header (MZF) ;----------------------------------------------- -RFS_ATRB: EQU 00000h ; Code Type, 01 = Machine Code. -RFS_NAME: EQU 00001h ; Title/Name (17 bytes). -RFS_SIZE: EQU 00012h ; Size of program. -RFS_DTADR: EQU 00014h ; Load address of program. -RFS_EXADR: EQU 00016h ; Exec address of program. -RFS_COMNT: EQU 00018h ; COMMENT +RFS_ATRB: EQU 00000h ; Code Type, 01 = Machine Code. +RFS_NAME: EQU 00001h ; Title/Name (17 bytes). +RFS_SIZE: EQU 00012h ; Size of program. +RFS_DTADR: EQU 00014h ; Load address of program. +RFS_EXADR: EQU 00016h ; Exec address of program. +RFS_COMNT: EQU 00018h ; COMMENT ;----------------------------------------------- ; Entry/compilation start points. ;----------------------------------------------- -TPSTART: EQU 010F0h -MEMSTART: EQU 01200h -MSTART: EQU 0E900h -DIRMROM: EQU 0006Eh -MFINDMZF: EQU 00071h -MROMLOAD: EQU 00074h -MZFHDRSZ EQU 128 -RFSSECTSZ EQU 256 -MROMSIZE EQU 4096 -UROMSIZE EQU 2048 +TPSTART: EQU 010F0h +MEMSTART: EQU 01200h +MSTART: EQU 0E900h +DIRMROM: EQU 0006Eh +MFINDMZF: EQU 00071h +MROMLOAD: EQU 00074h +MZFHDRSZ EQU 128 +RFSSECTSZ EQU 256 +MROMSIZE EQU 4096 +UROMSIZE EQU 2048 ;----------------------------------------------- -; ROM Banks, 0-3 are reserved for alternative -; Monitor versions in MROM bank, -; 0-7 are reserved for RFS code in the -; User ROM bank. +; ROM Banks, 0-7 are reserved for alternative +; Monitor versions, CPM and RFS +; code in MROM bank, +; 0-7 are reserved for RFS code in +; the User ROM bank. +; 8-15 are reserved for CPM code in +; the User ROM bank. ;----------------------------------------------- -ROMBANK0 EQU 0 -ROMBANK1 EQU 1 -ROMBANK2 EQU 2 -ROMBANK3 EQU 3 -ROMBANK4 EQU 4 -ROMBANK5 EQU 5 -ROMBANK6 EQU 6 -ROMBANK7 EQU 7 +MROMPAGES EQU 8 +USRROMPAGES EQU 12 +ROMBANK0 EQU 0 +ROMBANK1 EQU 1 +ROMBANK2 EQU 2 +ROMBANK3 EQU 3 +ROMBANK4 EQU 4 +ROMBANK5 EQU 5 +ROMBANK6 EQU 6 +ROMBANK7 EQU 7 +ROMBANK8 EQU 8 +ROMBANK9 EQU 9 +ROMBANK10 EQU 10 +ROMBANK11 EQU 11 -;BRKCD EQU 00 -;NTFECD EQU 40 -;HDERCD EQU 41 -;WPRTCD EQU 46 -;QNTRCD EQU 50 -;NFSECD EQU 53 -;UNFMCD EQU 54 - -;NAMSIZ EQU 011h -OBJCD EQU 001h +OBJCD EQU 001h ;----------------------------------------------- ; Common character definitions. ;----------------------------------------------- -SCROLL EQU 01H ;Set scrool direction UP. -BELL EQU 07H -SPACE EQU 20H -TAB EQU 09H ;TAB ACROSS (8 SPACES FOR SD-BOARD) -CR EQU 0DH -LF EQU 0AH -FF EQU 0CH -ESC EQU 1BH -DELETE EQU 7FH -BACKS EQU 08H -SOH EQU 1 ; For XModem etc. -EOT EQU 4 -ACK EQU 6 -NAK EQU 15H -NUL EQU 00H +SCROLL EQU 01H ; Set scrool direction UP. +BELL EQU 07H +SPACE EQU 20H +TAB EQU 09H ; TAB ACROSS (8 SPACES FOR SD-BOARD) +CR EQU 0DH +LF EQU 0AH +FF EQU 0CH +ESC EQU 1BH +DELETE EQU 7FH +BACKS EQU 08H +SOH EQU 1 ; For XModem etc. +EOT EQU 4 +ACK EQU 6 +NAK EQU 15H +NUL EQU 00H + + +SPI_OUT EQU 0FFH +SPI_IN EQU 0FEH +DOUT_LOW EQU 000H +DOUT_HIGH EQU 004H +DOUT_MASK EQU 004H +DIN_LOW EQU 000H +DIN_HIGH EQU 001H +CLOCK_LOW EQU 000H +CLOCK_HIGH EQU 002H +CLOCK_MASK EQU 0FDH +CS_LOW EQU 000H +CS_HIGH EQU 001H + +; MMC/SD command (SPI mode) +CMD0 EQU 64 + 0 ; GO_IDLE_STATE +CMD1 EQU 64 + 1 ; SEND_OP_COND +ACMD41 EQU 0x40+41 ; SEND_OP_COND (SDC) +CMD8 EQU 64 + 8 ; SEND_IF_COND +CMD9 EQU 64 + 9 ; SEND_CSD +CMD10 EQU 64 + 10 ; SEND_CID +CMD12 EQU 64 + 12 ; STOP_TRANSMISSION +CMD13 EQU 64 + 13 ; SEND_STATUS +ACMD13 EQU 0x40+13 ; SD_STATUS (SDC) +CMD16 EQU 64 + 16 ; SET_BLOCKLEN +CMD17 EQU 64 + 17 ; READ_SINGLE_BLOCK +CMD18 EQU 64 + 18 ; READ_MULTIPLE_BLOCK +CMD23 EQU 64 + 23 ; SET_BLOCK_COUNT +ACMD23 EQU 0x40+23 ; SET_WR_BLK_ERASE_COUNT (SDC) +CMD24 EQU 64 + 24 ; WRITE_BLOCK +CMD25 EQU 64 + 25 ; WRITE_MULTIPLE_BLOCK +CMD32 EQU 64 + 32 ; ERASE_ER_BLK_START +CMD33 EQU 64 + 33 ; ERASE_ER_BLK_END +CMD38 EQU 64 + 38 ; ERASE +CMD55 EQU 64 + 55 ; APP_CMD +CMD58 EQU 64 + 58 ; READ_OCR +SD_SECSIZE EQU 512 ; Default size of an SD Sector + +; Card type flags (CardType) +CT_MMC EQU 001H ; MMC ver 3 +CT_SD1 EQU 002H ; SD ver 1 +CT_SD2 EQU 004H ; SD ver 2 +CT_SDC EQU CT_SD1|CT_SD2 ; SD +CT_BLOCK EQU 008H ; Block addressing + +; SD Card Directory structure. The directory entries are based on the MZF Header format and constraints. +; +; FLAG1 | FLAG2 | FILE NAME | START SECTOR | SIZE | LOAD ADDR | EXEC ADDR | RESERVED +; 1 Byte | 1 Byte | 17 Bytes | 2 Bytes | 2 Bytes | 2 Bytes | 2 Bytes | 5 Bytes +; +; FLAG1 : BIT 7 = 1, Valid directory entry, 0 = inactive. +; FLAG2 : MZF Execution Code, 0x01 = Binary +; FILENAME : Standard MZF format filename. +; START SECTOR : Sector in the SD card where the program starts. It always starts at position 0 of the sector. +; SIZE : Size in bytes of the program. Each file block occupies 64Kbyte space (as per a tape) and this +; parameter provides the actual space occupied by the program at the current time. +; LOAD ADDR : Start address in memory where data should be loaded. +; EXEC ADDR : If a binary then this parameter specifies the location to auto execute once loaded. +; RESERVED : Not used at the moemnt. +SDDIR_FLAG1 EQU 000H +SDDIR_FLAG2 EQU 001H +SDDIR_FILEN EQU 002H +SDDIR_SSEC EQU 013H +SDDIR_SIZE EQU 015H +SDDIR_LOAD EQU 017H +SDDIR_EXEC EQU 019H +SDDIR_FNSZ EQU 17 +SDDIR_ENTSZ EQU 32 ;----------------------------------------------- ; SA-1510 MONITOR WORK AREA (MZ80A) ;----------------------------------------------- -STACK: EQU 010F0H +STACK: EQU 010F0H ; - ORG STACK + ORG STACK ; SPV: IBUFE: ; TAPE BUFFER (128 BYTES) -ATRB: DS virtual 1 ; ATTRIBUTE -NAME: DS virtual 17 ; FILE NAME -SIZE: DS virtual 2 ; BYTESIZE -DTADR: DS virtual 2 ; DATA ADDRESS -EXADR: DS virtual 2 ; EXECUTION ADDRESS -COMNT: DS virtual 92 ; COMMENT -SWPW: DS virtual 10 ; SWEEP WORK -KDATW: DS virtual 2 ; KEY WORK -KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE) -DSPXY: DS virtual 2 ; DISPLAY COORDINATES -MANG: DS virtual 6 ; COLUMN MANAGEMENT -MANGE: DS virtual 1 ; COLUMN MANAGEMENT END -PBIAS: DS virtual 1 ; PAGE BIAS -ROLTOP: DS virtual 1 ; ROLL TOP BIAS -MGPNT: DS virtual 1 ; COLUMN MANAG. POINTER -PAGETP: DS virtual 2 ; PAGE TOP -ROLEND: DS virtual 1 ; ROLL END - DS virtual 14 ; BIAS -FLASH: DS virtual 1 ; FLASHING DATA -SFTLK: DS virtual 1 ; SHIFT LOCK -REVFLG: DS virtual 1 ; REVERSE FLAG -SPAGE: DS virtual 1 ; PAGE CHANGE -FLSDT: DS virtual 1 ; CURSOR DATA -STRGF: DS virtual 1 ; STRING FLAG -DPRNT: DS virtual 1 ; TAB COUNTER -TMCNT: DS virtual 2 ; TAPE MARK COUNTER -SUMDT: DS virtual 2 ; CHECK SUM DATA -CSMDT: DS virtual 2 ; FOR COMPARE SUM DATA -AMPM: DS virtual 1 ; AMPM DATA -TIMFG: DS virtual 1 ; TIME FLAG -SWRK: DS virtual 1 ; KEY SOUND FLAG -TEMPW: DS virtual 1 ; TEMPO WORK -ONTYO: DS virtual 1 ; ONTYO WORK -OCTV: DS virtual 1 ; OCTAVE WORK -RATIO: DS virtual 2 ; ONPU RATIO -BUFER: DS virtual 81 ; GET LINE BUFFER +ATRB: DS virtual 1 ; ATTRIBUTE +NAME: DS virtual 17 ; FILE NAME +SIZE: DS virtual 2 ; BYTESIZE +DTADR: DS virtual 2 ; DATA ADDRESS +EXADR: DS virtual 2 ; EXECUTION ADDRESS +COMNT: DS virtual 92 ; COMMENT +SWPW: DS virtual 10 ; SWEEP WORK +KDATW: DS virtual 2 ; KEY WORK +KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE) +DSPXY: DS virtual 2 ; DISPLAY COORDINATES +MANG: DS virtual 6 ; COLUMN MANAGEMENT +MANGE: DS virtual 1 ; COLUMN MANAGEMENT END +PBIAS: DS virtual 1 ; PAGE BIAS +ROLTOP: DS virtual 1 ; ROLL TOP BIAS +MGPNT: DS virtual 1 ; COLUMN MANAG. POINTER +PAGETP: DS virtual 2 ; PAGE TOP +ROLEND: DS virtual 1 ; ROLL END + DS virtual 14 ; BIAS +FLASH: DS virtual 1 ; FLASHING DATA +SFTLK: DS virtual 1 ; SHIFT LOCK +REVFLG: DS virtual 1 ; REVERSE FLAG +SPAGE: DS virtual 1 ; PAGE CHANGE +FLSDT: DS virtual 1 ; CURSOR DATA +STRGF: DS virtual 1 ; STRING FLAG +DPRNT: DS virtual 1 ; TAB COUNTER +TMCNT: DS virtual 2 ; TAPE MARK COUNTER +SUMDT: DS virtual 2 ; CHECK SUM DATA +CSMDT: DS virtual 2 ; FOR COMPARE SUM DATA +AMPM: DS virtual 1 ; AMPM DATA +TIMFG: DS virtual 1 ; TIME FLAG +SWRK: DS virtual 1 ; KEY SOUND FLAG +TEMPW: DS virtual 1 ; TEMPO WORK +ONTYO: DS virtual 1 ; ONTYO WORK +OCTV: DS virtual 1 ; OCTAVE WORK +RATIO: DS virtual 2 ; ONPU RATIO +BUFER: DS virtual 81 ; GET LINE BUFFER ; Starting 1000H - Generally unused bytes not cleared by the monitor. -ROMBK1: EQU 01016H ; CURRENT MROM BANK -ROMBK2: EQU 01017H ; CURRENT USERROM BANK -WRKROMBK1: EQU 01018H ; WORKING MROM BANK -WRKROMBK2: EQU 01019H ; WORKING USERROM BANK -SCRNMODE: EQU 0101AH ; Mode of screen, 0 = 40 char, 1 = 80 char. -TMPADR: EQU 0101BH ; TEMPORARY ADDRESS STORAGE -TMPSIZE: EQU 0101DH ; TEMPORARY SIZE -TMPCNT: EQU 0101FH ; TEMPORARY COUNTER -TMPLINECNT:EQU 01021H ; Temporary counter for displayed lines. -TMPSTACKP: EQU 01023H ; Temporary stack pointer save. +ROMBK1: EQU 01016H ; CURRENT MROM BANK +ROMBK2: EQU 01017H ; CURRENT USERROM BANK +WRKROMBK1: EQU 01018H ; WORKING MROM BANK +WRKROMBK2: EQU 01019H ; WORKING USERROM BANK +SCRNMODE: EQU 0101AH ; Mode of screen, 0 = 40 char, 1 = 80 char. +TMPADR: EQU 0101BH ; TEMPORARY ADDRESS STORAGE +TMPSIZE: EQU 0101DH ; TEMPORARY SIZE +TMPCNT: EQU 0101FH ; TEMPORARY COUNTER +TMPLINECNT: EQU 01021H ; Temporary counter for displayed lines. +TMPSTACKP: EQU 01023H ; Temporary stack pointer save. +SDVER: EQU 01025H +SDCAP: EQU 01026H +; Variables sharing the CMT buffer, normally the CMT and SD are not used at the same +; time. This frees up memory needed by the SD card. +SECTORBUF: EQU 0CE00H ; Working buffer to place an SD card sector. +SDBYTECNT EQU COMNT+2 ; Bytes to read/write to/from a sector. +SDOFFSET EQU COMNT+4 ; Offset into sector prior to data read/write. +SDSTARTSEC EQU COMNT+6 ; Starting sector of data to read/write from/to SD card. +SDLOADADDR EQU COMNT+10 ; Address to read/write data from/to SD card. +SDLOADSIZE EQU COMNT+12 ; Total remaining byte count data to read/write from/to SD card. +SDAUTOEXEC EQU COMNT+14 ; Flag to indicate if a loaded image should be executed (=0xFF) +SDBUF: EQU COMNT+15 ; SD Card command fram buffer for the command and response storage. +DIRSECBUF: EQU COMNT+26 ; Directory sector in cache. +RESULT: EQU COMNT+27 +BYTECNT: EQU COMNT+29 +WRITECNT: EQU COMNT+31 + ; Quickdisk work area -;QDPA EQU 01130h ; QD code 1 -;QDPB EQU 01131h ; QD code 2 -;QDPC EQU 01132h ; QD header startaddress -;QDPE EQU 01134h ; QD header length -;QDCPA EQU 0113Bh ; QD error flag -;HDPT EQU 0113Ch ; QD new headpoint possition -;HDPT0 EQU 0113Dh ; QD actual headpoint possition -;FNUPS EQU 0113Eh -;FNUPF EQU 01140h -;FNA EQU 01141h ; File Number A (actual file number) -;FNB EQU 01142h ; File Number B (next file number) -;MTF EQU 01143h ; QD motor flag -;RTYF EQU 01144h -;SYNCF EQU 01146h ; SyncFlags -;RETSP EQU 01147h -;BUFER EQU 011A3h -;QDIRBF EQU 0CD90h +;QDPA EQU 01130h ; QD code 1 +;QDPB EQU 01131h ; QD code 2 +;QDPC EQU 01132h ; QD header startaddress +;QDPE EQU 01134h ; QD header length +;QDCPA EQU 0113Bh ; QD error flag +;HDPT EQU 0113Ch ; QD new headpoint possition +;HDPT0 EQU 0113Dh ; QD actual headpoint possition +;FNUPS EQU 0113Eh +;FNUPF EQU 01140h +;FNA EQU 01141h ; File Number A (actual file number) +;FNB EQU 01142h ; File Number B (next file number) +;MTF EQU 01143h ; QD motor flag +;RTYF EQU 01144h +;SYNCF EQU 01146h ; SyncFlags +;RETSP EQU 01147h +;BUFER EQU 011A3h +;QDIRBF EQU 0CD90h ;SPV: -;IBUFE: ; TAPE BUFFER (128 BYTES) -;ATRB: DS virtual 1 ; Code Type, 01 = Machine Code. -;NAME: DS virtual 17 ; Title/Name (17 bytes). -;SIZE: DS virtual 2 ; Size of program. -;DTADR: DS virtual 2 ; Load address of program. -;EXADR: DS virtual 2 ; Exec address of program. -;COMNT: DS virtual 104 ; COMMENT -;KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE) -;DSPXY: DS virtual 2 ; DISPLAY COORDINATES -;MANG: DS virtual 27 ; COLUMN MANAGEMENT -;FLASH: DS virtual 1 ; FLASHING DATA -;FLPST: DS virtual 2 ; FLASHING POSITION -;FLSST: DS virtual 1 ; FLASHING STATUS -;FLSDT: DS virtual 1 ; CURSOR DATA -;STRGF: DS virtual 1 ; STRING FLAG -;DPRNT: DS virtual 1 ; TAB COUNTER -;TMCNT: DS virtual 2 ; TAPE MARK COUNTER -;SUMDT: DS virtual 2 ; CHECK SUM DATA -;CSMDT: DS virtual 2 ; FOR COMPARE SUM DATA -;AMPM: DS virtual 1 ; AMPM DATA -;TIMFG: DS virtual 1 ; TIME FLAG -;SWRK: DS virtual 1 ; KEY SOUND FLAG -;TEMPW: DS virtual 1 ; TEMPO WORK -;ONTYO: DS virtual 1 ; ONTYO WORK -;OCTV: DS virtual 1 ; OCTAVE WORK -;RATIO: DS virtual 2 ; ONPU RATIO +;IBUFE: ; TAPE BUFFER (128 BYTES) +;ATRB: DS virtual 1 ; Code Type, 01 = Machine Code. +;NAME: DS virtual 17 ; Title/Name (17 bytes). +;SIZE: DS virtual 2 ; Size of program. +;DTADR: DS virtual 2 ; Load address of program. +;EXADR: DS virtual 2 ; Exec address of program. +;COMNT: DS virtual 104 ; COMMENT +;KANAF: DS virtual 1 ; KANA FLAG (01=GRAPHIC MODE) +;DSPXY: DS virtual 2 ; DISPLAY COORDINATES +;MANG: DS virtual 27 ; COLUMN MANAGEMENT +;FLASH: DS virtual 1 ; FLASHING DATA +;FLPST: DS virtual 2 ; FLASHING POSITION +;FLSST: DS virtual 1 ; FLASHING STATUS +;FLSDT: DS virtual 1 ; CURSOR DATA +;STRGF: DS virtual 1 ; STRING FLAG +;DPRNT: DS virtual 1 ; TAB COUNTER +;TMCNT: DS virtual 2 ; TAPE MARK COUNTER +;SUMDT: DS virtual 2 ; CHECK SUM DATA +;CSMDT: DS virtual 2 ; FOR COMPARE SUM DATA +;AMPM: DS virtual 1 ; AMPM DATA +;TIMFG: DS virtual 1 ; TIME FLAG +;SWRK: DS virtual 1 ; KEY SOUND FLAG +;TEMPW: DS virtual 1 ; TEMPO WORK +;ONTYO: DS virtual 1 ; ONTYO WORK +;OCTV: DS virtual 1 ; OCTAVE WORK +;RATIO: DS virtual 2 ; ONPU RATIO diff --git a/software/asm/rfs.asm b/software/asm/rfs.asm index 1e77dbb..cfb0ec6 100644 --- a/software/asm/rfs.asm +++ b/software/asm/rfs.asm @@ -43,24 +43,24 @@ ; Common code spanning all banks. ;-------------------------------- ROMFS: NOP - JR ROMFS_0 ; Skip the reset vector. + JR ROMFS_0 ; Skip the reset vector. NOP NOP NOP NOP NOP NOP - JP 00000H ; Common point when an alternate bank needs to reset the system. -ROMFS_0: LD A, (ROMBK1) ; Ensure all banks are at default on - CP 4 ; If the ROMBK1 value is 255, an illegal value, then the machine has just started so skip. + JP 00000H ; Common point when an alternate bank needs to reset the system. +ROMFS_0: LD A, (ROMBK1) ; Ensure all banks are at default on + CP 4 ; If the ROMBK1 value is 255, an illegal value, then the machine has just started so skip. JR C, ROMFS_2 - XOR A ; Clear the lower stack space as we use it for variables. + XOR A ; Clear the lower stack space as we use it for variables. LD B, 7*8 LD HL, 01000H ROMFS_1: LD (HL),A INC HL DJNZ ROMFS_1 -ROMFS_2: LD (RFSBK1),A ; start up. +ROMFS_2: LD (RFSBK1),A ; start up. LD A, (ROMBK2) LD (RFSBK2),A JP MONITOR @@ -70,36 +70,56 @@ ROMFS_2: LD (RFSBK1),A ; s ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. ; BKSW0to0: PUSH AF - LD A, ROMBANK0 ; Calling bank (ie. us). + LD A, ROMBANK0 ; Calling bank (ie. us). PUSH AF - LD A, ROMBANK0 ; Required bank to call. + LD A, ROMBANK0 ; Required bank to call. JR BKSW0_0 BKSW0to1: PUSH AF - LD A, ROMBANK0 ; Calling bank (ie. us). + LD A, ROMBANK0 ; Calling bank (ie. us). PUSH AF - LD A, ROMBANK1 ; Required bank to call. + LD A, ROMBANK1 ; Required bank to call. JR BKSW0_0 BKSW0to2: PUSH AF - LD A, ROMBANK0 ; Calling bank (ie. us). + LD A, ROMBANK0 ; Calling bank (ie. us). PUSH AF - LD A, ROMBANK2 ; Required bank to call. + LD A, ROMBANK2 ; Required bank to call. JR BKSW0_0 BKSW0to3: PUSH AF - LD A, ROMBANK0 ; Calling bank (ie. us). + LD A, ROMBANK0 ; Calling bank (ie. us). PUSH AF - LD A, ROMBANK3 ; Required bank to call. + LD A, ROMBANK3 ; Required bank to call. + JR BKSW0_0 +BKSW0to4: PUSH AF + LD A, ROMBANK0 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK4 ; Required bank to call. + JR BKSW0_0 +BKSW0to5: PUSH AF + LD A, ROMBANK0 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK5 ; Required bank to call. + JR BKSW0_0 +BKSW0to6: PUSH AF + LD A, ROMBANK0 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK6 ; Required bank to call. + JR BKSW0_0 +BKSW0to7: PUSH AF + LD A, ROMBANK0 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK7 ; Required bank to call. ; -BKSW0_0: PUSH BC ; Save BC for caller. - LD BC, BKSWRET0 ; Place bank switchers return address on stack. +BKSW0_0: PUSH BC ; Save BC for caller. + LD BC, BKSWRET0 ; Place bank switchers return address on stack. PUSH BC - LD (RFSBK2), A ; Bank switch in user rom space, A=bank. - LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. - JP (HL) ; Jump to required function. + LD (RFSBK2), A ; Bank switch in user rom space, A=bank. + LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. + JP (HL) ; Jump to required function. BKSWRET0: POP BC - POP AF ; Get bank which called us. - LD (RFSBK2), A ; Return to that bank. + POP AF ; Get bank which called us. + LD (RFSBK2), A ; Return to that bank. POP AF - RET ; Return to caller. + RET ; Return to caller. ALIGN 0E880H ORG 0E880H @@ -119,147 +139,210 @@ MONITOR: LD A, (ROMBK1) CP 0 JR NZ, SIGNON ; -SET40CHAR: LD A, 0 ; Using MROM in Bank 0 = 40 char mode. +SET40CHAR: LD A, 0 ; Using MROM in Bank 0 = 40 char mode. LD (DSPCTL), A LD A, 0 LD (SCRNMODE), A - LD (SPAGE), A ; Allow MZ80A scrolling + LD (SPAGE), A ; Allow MZ80A scrolling JR SIGNON -SET80CHAR: LD A, 128 ; Using MROM in Bank 1 = 80 char mode. +SET80CHAR: LD A, 128 ; Using MROM in Bank 1 = 80 char mode. LD (DSPCTL), A LD A, 1 LD (SCRNMODE), A LD A, 0FFH - LD (SPAGE), A ; MZ80K Scrolling in 80 column mode for time being. + LD (SPAGE), A ; MZ80K Scrolling in 80 column mode for time being. ; -SIGNON: LD A,0C4h ; Move cursor left to overwrite part of SA-1510 monitor banner. - LD E,004h ; 2 times. +SIGNON: LD A,0C4h ; Move cursor left to overwrite part of SA-1510 monitor banner. + LD E,004h ; 2 times. SIGNON1: CALL DPCT DEC E JR NZ,SIGNON1 - LD DE,MSGSON ; Sign on message, + LD DE,MSGSON ; Sign on message, RST 018h -ST1X: CALL NL ; Command line monitor extension. + LD HL, SDINIT ; SD Card Initialisation + CALL BKSW0to2 ; Call the initialisation routine. + + ; Command processor, table based. + ; A line is inpt then a comparison made with entries in the table. If a match is found then the bank and function + ; address are extracted and a call to the function @ given bank made. The commands can be of variable length + ; but important to not that longer commands using the same letters as shorter commands must appear first in the table. + ; +ST1X: CALL NL ; Command line monitor extension. LD A,'*' CALL PRNT LD DE,BUFER CALL GETL + ; +CMDCMP: LD HL,CMDTABLE +CMDCMP0: LD DE,BUFER+1 ; First command byte after the * prompt. + LD A,(HL) + BIT 7,A ; Bit 7 set on command properties indicates table end, exit if needed. + JR NZ,CMDNOCMP + LD C,A ; Command properties into C + SET 6,C ; Assume command match. + AND 007H ; Mask out bytes in command mask. + LD B,A ; Number of bytes in command. + INC HL +CMDCMP1: LD A,(DE) ; Compare all bytes and reset match bit if we find a difference. + CP (HL) + JR Z, CMDCMP2 + RES 6,C ; No command match. +CMDCMP2: INC DE + INC HL + DJNZ CMDCMP1 + BIT 6,C ; Bit 7 is still set then we have a command match. + JR NZ,CMDCMP3 + INC HL + INC HL ; Skip over function address + JR CMDCMP0 ; Try match next command. +CMDCMP3: LD A,(HL) ; Command function address into HL + INC HL + LD H,(HL) + LD L,A + PUSH HL + LD (TMPADR),DE ; Store the key buffer location where arguments start. + LD A,C + SRL A + SRL A + SRL A + AND 007H ; Mask out just the bank number of the command. + LD B,A + LD HL,BKSW0to0 ; Base address of bank switching functions. + LD DE,BKSW0to1 - BKSW0to0 ; DE is the number of bytes between bank switch calls. + OR A + JR Z,CMDCMP5 +CMDCMP4: ADD HL,DE + DJNZ CMDCMP4 +CMDCMP5: EX DE,HL ; Address of bank switch function into DE. + POP HL ; Get address of command into HL. + LD BC,CMDCMPEND + PUSH BC ; Address to return to after command is executed. + PUSH DE ; Now jump to DE which will switch to the correct bank and execute function at HL. + LD DE,(TMPADR) + RET +CMDNOCMP: LD DE,MSGBADCMD + RST 018H +CMDCMPEND: JP ST1X -ST2X: LD A,(DE) - INC DE - CP 00Dh - JR Z,ST1X ; CR = end of input + ; Monitor command table. This table contains the list of recognised commands along with the + ; handler function and bank in which it is located. ; - CP '4' ; 40 Character Screen Mode - JP Z,SETMODE40 - ; - CP '8' ; 80 Character Screen Mode - JP Z,SETMODE80 - ; - CP 'B' ; Bell - JP Z,SGX - ; - CP 'C' ; Clear memory - JP Z,INITMEMX - ; - CP 'D' ; Dump memory - JP Z,DUMPX - ; - LD HL, FLOPPY ; Function to call if we have a match. - CP 'F' - CALL Z,BKSW0to1 ; Floppy boot (F). - ; - CP 0AAh ; Original Floppy boot (f) - JR Z,FDCK - ; - LD HL, HELP ; Function to call if we have a match. - CP 'H' - CALL Z,BKSW0to2 ; Help screen. - ; - CP 'I' ; List ROM directory. - JP Z,DIRROM - ; - CP 'J' ; JUMP - JR Z,GOTOX - ; - CP 'L' ; Load CMT - JR Z,LOADX - ; - CP 0B8h ; Load CMT without auto execution. - JR Z,LOADNX - ; - CP 'M' ; Memory correction - JP Z,MCORX - ; - CP 'P' ; Printer test - JP Z,PTESTX - ; - LD HL, MEMTEST ; Function to call if we have a match. - CP 'R' - CALL Z,BKSW0to3 ; Call function in bank 3. - ; - CP 'S' ; Save CMT - JP Z,SAVEX - ; - LD HL, TIMERTST ; Function to call if we have a match. - CP 'T' - CALL Z,BKSW0to3 ; Timer test. - ; - CP 'V' ; Verify - JP Z,VRFYX - ; - CP 'X' ; Exchange to hi load rom so DRAM = 0000:0CFFF - JP Z,HIROM - ; -ST1X1: JR ST2X + ; 7 6 5:3 2:0 + ; END MATCH BANK SIZE +CMDTABLE: DB 000H | 000H | 000H | 001H ; Bit 2:0 = Command Size, 5:3 = Bank, 6 = Command match, 7 = Command table end. + DB '4' ; 40 Char screen mode. + DW SETMODE40 + DB 000H | 000H | 000H | 001H + DB '8' ; 80 Char screen mode. + DW SETMODE80 + DB 000H | 000H | 000H | 001H + DB 'B' ; Bell. + DW SGX + DB 000H | 000H | 000H | 001H + DB 'C' ; Clear Memory. + DW INITMEMX + DB 000H | 000H | 000H | 001H + DB 'D' ; Dump Memory. + DW DUMPX + DB 000H | 000H | 008H | 001H + DB 'F' ; RFS Floppy boot code. + DW FLOPPY + DB 000H | 000H | 000H | 001H + DB 0AAH ; Original Floppy boot code. + DW FDCK + DB 000H | 000H | 018H | 001H + DB 'H' ; Help screen. + DW HELP + DB 000H | 000H | 000H | 002H + DB "IR" ; List ROM directory. + DW DIRROM + DB 000H | 000H | 010H | 002H + DB "IC" ; List SD Card directory. + DW DIRSDCARD + DB 000H | 000H | 000H | 001H + DB 'J' ; Jump to address. + DW GOTOX + DB 000H | 000H | 000H | 004H + DB "LTNX" ; Load from CMT without auto execution. + DW LOADTAPENX + DB 000H | 000H | 000H | 002H + DB "LT" ; Load from CMT + DW LOADTAPE + DB 000H | 000H | 000H | 004H + DB "LRNX" ; Load from ROM without auto execution. + DW LOADROMNX + DB 000H | 000H | 000H | 002H + DB "LR" ; Load from ROM + DW LOADROM + DB 000H | 000H | 000H | 004H + DB "LCNX" ; Load from SDCARD without auto execution. + DW LOADSDCARDX + DB 000H | 000H | 000H | 002H + DB "LC" ; Load from SD CARD + DW LOADSDCARD + DB 000H | 000H | 000H | 001H + DB "L" ; Original Load from CMT + DW LOADTAPE + DB 000H | 000H | 000H | 001H + DB 'M' ; Edit Memory. + DW MCORX + DB 000H | 000H | 000H | 001H + DB 'P' ; Printer test. + DW PTESTX + DB 000H | 000H | 018H | 001H + DB 'R' ; Memory test. + DW MEMTEST + DB 000H | 000H | 000H | 001H + DB 'S' ; Save to CMT + DW SAVEX + DB 000H | 000H | 018H | 001H + DB 'T' ; Timer test. + DW TIMERTST + DB 000H | 000H | 000H | 001H + DB 'V' ; Verify CMT Save. + DW VRFYX + DB 000H | 000H | 000H | 001H + DB 'X' ; Exchange to hi load rom so DRAM = 0000:0CFFF + DW HIROM + DB 080H | 000H | 000H | 001H -FDCK: CALL LEB22 ; Check to see if the Floppy ROM is present, exit if it isnt. + +FDCK: CALL LEB22 ; Check to see if the Floppy ROM is present, exit if it isnt. CALL Z,0F000h - JR ST1X1 + JP CMDCMPEND ?ERX: CP 002h - JR Z,ST1X1 + JP Z,CMDCMPEND CALL NL - LD DE,MSGE1 ; 'CHECK SUM ER.' + LD DE,MSGE1 ; 'CHECK SUM ER.' RST 018h - JR ST1X1 + JP CMDCMPEND BGETLX: EX (SP),HL POP BC LD DE,BUFER CALL GETL LD A,(DE) CP 01Bh - JR Z,ST1X1 + JP Z,CMDCMPEND JP (HL) HEXIYX: EX (SP),IY POP AF CALL HLHEX - JR C,ST1X1 + JP C,CMDCMPEND JP (IY) GOTOX: CALL HEXIYX JP (HL) -LOADNX: LD L,0FFh - JR LOADX1 -LOADX: LD L,000h -LOADX1: LD A,(DE) - CP 000h - JR Z, LOADXTAPE - CP 00Dh - JR Z, LOADXTAPE - CP ' ' - JR Z,LOADX2 - JP LOADROM ; Filename pointer stored in DE, attempt to load from ROM. - -LOADX2: INC DE - JR LOADX1 - -LOADXTAPE: CALL ?RDI +LOADTAPENX:LD L,0FFH + JR LOADTAPE1 +LOADTAPE: LD L,000H +LOADTAPE1: PUSH HL ; Preserve auto execute flag. + CALL ?RDI JR C,?ERX CALL NL - LD DE,MSG?2 ; 'LOADING ' + LD DE,MSG?2 ; 'LOADING ' RST 018h LD DE,NAME RST 018h @@ -279,48 +362,53 @@ LOADXTAPE: CALL ?RDI LD (DTADR),HL LE941: CALL ?RDD JR C,?ERX + POP HL ; Get back the auto execute flag. + LD A,L + OR A + JR Z,LOADTAPE4 ; Dont execute. LD A,(BUFER) CP 0FFh - JR Z,LE954 + JR Z,LOADTAPELM ; Execute at low memory? LD BC,00100h LD HL,(EXADR) JP (HL) -LE954: OUT (0E0h),A - LD HL,01200h +LOADTAPELM:LD A,(MEMSW) ; Perform memory switch, mapping out ROM from $0000 to $C000 + LD HL,01200h ; Shift the program down to RAM at $0000 LD DE,00000h LD BC,(SIZE) LDIR LD BC,00100h JP 00000h +LOADTAPE4: RET PTESTX: LD A,(DE) - CP '&' ; plotter test + CP '&' ; plotter test JR NZ,PTST1X PTST0X: INC DE LD A,(DE) - CP 'L' ; 40 in 1 line + CP 'L' ; 40 in 1 line JR Z,.LPTX - CP 'S' ; 80 in 1 line + CP 'S' ; 80 in 1 line JR Z,..LPTX - CP 'C' ; Pen change + CP 'C' ; Pen change JR Z,PENX - CP 'G' ; Graph mode + CP 'G' ; Graph mode JR Z,PLOTX - CP 'T' ; Test + CP 'T' ; Test JR Z,PTRNX ; PTST1X: CALL PMSGX -ST1X2: JP ST1X1 -.LPTX: LD DE,LLPT ; 01-09-09-0B-0D +ST1X2: JP CMDCMPEND +.LPTX: LD DE,LLPT ; 01-09-09-0B-0D JR PTST1X -..LPTX: LD DE,SLPT ; 01-09-09-09-0D +..LPTX: LD DE,SLPT ; 01-09-09-09-0D JR PTST1X -PTRNX: LD A,004h ; Test pattern +PTRNX: LD A,004h ; Test pattern JR LE999 -PLOTX: LD A,002h ; Graph mode +PLOTX: LD A,002h ; Graph mode LE999: CALL LPRNTX JR PTST0X -PENX: LD A,01Dh ; 1 change code (text mode) +PENX: LD A,01Dh ; 1 change code (text mode) JR LE999 ; ; @@ -329,16 +417,16 @@ PENX: LD A,01Dh ; 1 ; in: ACC print data ; ; -LPRNTX: LD C,000h ; RDAX test - LD B,A ; print data store +LPRNTX: LD C,000h ; RDAX test + LD B,A ; print data store CALL RDAX LD A,B - OUT (0FFh),A ; data out - LD A,080h ; RDP high + OUT (0FFh),A ; data out + LD A,080h ; RDP high OUT (0FEh),A - LD C,001h ; RDA test + LD C,001h ; RDA test CALL RDAX - XOR A ; RDP low + XOR A ; RDP low OUT (0FEh),A RET ; @@ -349,11 +437,11 @@ LPRNTX: LD C,000h ; R PMSGX: PUSH DE PUSH BC PUSH AF -PMSGX1: LD A,(DE) ; ACC = data +PMSGX1: LD A,(DE) ; ACC = data CALL LPRNTX LD A,(DE) INC DE - CP 00Dh ; end ? + CP 00Dh ; end ? JR NZ,PMSGX1 POP AF POP BC @@ -377,29 +465,29 @@ RDAX: IN A,(0FEh) ; Memory correction ; command 'M' ; -MCORX: CALL HEXIYX ; correction address -MCORX1: CALL NLPHL ; corr. adr. print - CALL SPHEX ; ACC ASCII display - CALL PRNTS ; space print - CALL BGETLX ; get data & check data - CALL HLHEX ; HLASCII(DE) +MCORX: CALL HEXIYX ; correction address +MCORX1: CALL NLPHL ; corr. adr. print + CALL SPHEX ; ACC ASCII display + CALL PRNTS ; space print + CALL BGETLX ; get data & check data + CALL HLHEX ; HLASCII(DE) JR C,MCRX3 - CALL DOT4DE ; INC DE * 4 + CALL DOT4DE ; INC DE * 4 INC DE - CALL _2HEX ; data check + CALL _2HEX ; data check JR C,MCORX1 CP (HL) JR NZ,MCORX1 INC DE LD A,(DE) - CP 00Dh ; not correction + CP 00Dh ; not correction JR Z,MCRX2 - CALL _2HEX ; ACCHL(ASCII) + CALL _2HEX ; ACCHL(ASCII) JR C,MCORX1 - LD (HL),A ; data correct + LD (HL),A ; data correct MCRX2: INC HL JR MCORX1 -MCRX3: LD H,B ; memory address +MCRX3: LD H,B ; memory address LD L,C JR MCORX1 ; @@ -407,45 +495,45 @@ MCRX3: LD H,B ; m ; ; cmd. 'S' ; -SAVEX: CALL HEXIYX ; Start address - LD (DTADR),HL ; data adress buffer +SAVEX: CALL HEXIYX ; Start address + LD (DTADR),HL ; data adress buffer LD B,H LD C,L CALL DOT4DE - CALL HEXIYX ; End address - SBC HL,BC ; byte size + CALL HEXIYX ; End address + SBC HL,BC ; byte size INC HL - LD (SIZE),HL ; byte size buffer + LD (SIZE),HL ; byte size buffer CALL DOT4DE - CALL HEXIYX ; execute address - LD (EXADR),HL ; buffer + CALL HEXIYX ; execute address + LD (EXADR),HL ; buffer CALL NL - LD DE,MSGSV ; 'FILENAME? ' + LD DE,MSGSV ; 'FILENAME? ' RST 018h - CALL BGETLX ; filename input + CALL BGETLX ; filename input CALL DOT4DE CALL DOT4DE - LD HL,NAME ; name buffer + LD HL,NAME ; name buffer SAVX1: INC DE LD A,(DE) - LD (HL),A ; filename trans. + LD (HL),A ; filename trans. INC HL - CP 00Dh ; end code + CP 00Dh ; end code JR NZ,SAVX1 - LD A,OBJCD ; attribute: OBJ + LD A,OBJCD ; attribute: OBJ LD (ATRB),A CALL ?WRI ?ERX1: JP C,?ERX - CALL ?WRD ; data + CALL ?WRD ; data JR C,?ERX1 CALL NL - LD DE,MSGOK ; 'OK!' + LD DE,MSGOK ; 'OK!' RST 018h LEA5B: JP ST1X VRFYX: CALL ?VRFY JP C,?ERX - LD DE,MSGOK ; 'OK!' + LD DE,MSGOK ; 'OK!' RST 018h JR LEA5B @@ -508,19 +596,18 @@ DUM1: LD HL,000A0h JR L0D36 FNINP: CALL NL - LD DE,MSGSV ; 'FILENAME? ' + LD DE,MSGSV ; 'FILENAME? ' RST 018h LD DE,BUFER CALL GETL LD A,(DE) CP #1B JR NZ,LEAF3 - LD HL,ST1X - EX (SP),HL + ;LD HL,ST1X + ;EX (SP),HL RET -LEAF3: - LD B,000h +LEAF3: LD B,000h LD DE,011ADh LD HL,BUFER LD A,(DE) @@ -564,9 +651,9 @@ DOT4DE: INC DE ; SPACE PRINT AND DISP ACC ; INPUT:HL=DISP. ADR. -SPHEX: CALL PRNTS ; SPACE PRINT +SPHEX: CALL PRNTS ; SPACE PRINT LD A,(HL) - CALL PRTHX ; DSP OF ACC (ASCII) + CALL PRTHX ; DSP OF ACC (ASCII) LD A,(HL) RET @@ -593,7 +680,7 @@ CLEAR1: LD A,00h ; 40 CHA. IN 1 LINE CODE (DATA) -LLPT: DB 01H ; TEXT MODE +LLPT: DB 01H ; TEXT MODE DB 09H DB 09H DB 0BH @@ -601,7 +688,7 @@ LLPT: DB 01H ; TEXT MODE ; 80 CHA. 1 LINE CODE (DATA) -SLPT: DB 01H ; TEXT MODE +SLPT: DB 01H ; TEXT MODE DB 09H DB 09H DB 09H @@ -613,20 +700,20 @@ SLPT: DB 01H ; TEXT MODE ; ;==================================== -HIROM: LD A, (MEMSW) ; Swap ROM into high range slot. +HIROM: LD A, (MEMSW) ; Swap ROM into high range slot. LD A, ROMBANK2 - LD (ROMBK1),A ; Save bank being enabled. - LD (RFSBK1),A ; Switch to the hiload rom in bank 2. + LD (ROMBK1),A ; Save bank being enabled. + LD (RFSBK1),A ; Switch to the hiload rom in bank 2. JP 0C000H -SETMODE40: LD A, ROMBANK0 ; Switch to 40Char monitor. +SETMODE40: LD A, ROMBANK0 ; Switch to 40Char monitor. LD (ROMBK1),A LD (RFSBK1),A LD A, 0 LD (DSPCTL), A JP MONIT -SETMODE80: LD A, ROMBANK1 ; Switch to 80char monitor. +SETMODE80: LD A, ROMBANK1 ; Switch to 80char monitor. LD (ROMBK1),A LD (RFSBK1),A LD A, 128 @@ -639,418 +726,441 @@ SETMODE80: LD A, ROMBANK1 ; Switch to 80char monitor. ; ;==================================== - ; HL contains address of block to check. -ISMZF: PUSH BC - PUSH DE - PUSH HL - ; - LD A,(HL) - CP 001h ; Only interested in machine code images. - JR NZ, ISMZFNOT - ; - INC HL - LD DE,NAME ; Checks to confirm this is an MZF header. - LD B,17 ; Maximum of 17 characters, including terminator in filename. -ISMZFNXT: LD A,(HL) - LD (DE),A - CP 00Dh ; If we find a terminator then this indicates potentially a valid name. - JR Z, ISMZFVFY - CP 020h ; >= Space - JR C, ISMZFNOT - CP 05Dh ; =< ] - JR C, ISMZFNXT3 -ISMZFNXT2: CP 091h - JR C, ISMZFNOT ; DEL or > 0x7F, cant be a valid filename so this is not an MZF header. -ISMZFNXT3: INC DE - INC HL - DJNZ ISMZFNXT - JR ISMZFNOT ; No end of string terminator, this cant be a valid filename. -ISMZFVFY: LD A,B - CP 17 - JR Z,ISMZFNOT ; If the filename has no length it cant be valid, so loop. -ISMZFYES: CP A ; Set zero flag to indicate match. + ; HL contains address of block to check. +ISMZF: PUSH BC + PUSH DE + PUSH HL + ; + LD A,(HL) + CP 001h ; Only interested in machine code images. + JR NZ, ISMZFNOT + ; + INC HL + LD DE,NAME ; Checks to confirm this is an MZF header. + LD B,17 ; Maximum of 17 characters, including terminator in filename. +ISMZFNXT: LD A,(HL) + LD (DE),A + CP 00Dh ; If we find a terminator then this indicates potentially a valid name. + JR Z, ISMZFVFY + CP 020h ; >= Space + JR C, ISMZFNOT + CP 05Dh ; =< ] + JR C, ISMZFNXT3 +ISMZFNXT2: CP 091h + JR C, ISMZFNOT ; DEL or > 0x7F, cant be a valid filename so this is not an MZF header. +ISMZFNXT3: INC DE + INC HL + DJNZ ISMZFNXT + JR ISMZFNOT ; No end of string terminator, this cant be a valid filename. +ISMZFVFY: LD A,B + CP 17 + JR Z,ISMZFNOT ; If the filename has no length it cant be valid, so loop. +ISMZFYES: CP A ; Set zero flag to indicate match. -ISMZFNOT: POP HL - POP DE - POP BC - RET +ISMZFNOT: POP HL + POP DE + POP BC + RET -PRTDBG: PUSH HL - PUSH DE - PUSH BC - PUSH AF - LD A,(ROMBK1) - LD (RFSBK1), A ; Set the MROM bank back to original. - CALL PRTHL ; HL - LD A, ' ' - CALL PRNT - LD H,B - LD L,C - CALL PRTHL ; BC - LD A, ' ' - CALL PRNT - LD H,D - LD L,E - CALL PRTHL ; DE - LD A, ' ' - CALL PRNT - POP HL ; Get AF into HL. - PUSH HL - CALL PRTHL ; AF - LD A, ' ' - CALL PRNT - LD A, ':' - CALL PRNT - LD A, ' ' - CALL PRNT - LD A,(WRKROMBK1) - LD (RFSBK1), A ; Set the MROM bank back to scanned bank. - POP AF - POP BC - POP DE - POP HL - RET +PRTDBG: PUSH HL + PUSH DE + PUSH BC + PUSH AF + LD A,(ROMBK1) + LD (RFSBK1), A ; Set the MROM bank back to original. + CALL PRTHL ; HL + LD A, ' ' + CALL PRNT + LD H,B + LD L,C + CALL PRTHL ; BC + LD A, ' ' + CALL PRNT + LD H,D + LD L,E + CALL PRTHL ; DE + LD A, ' ' + CALL PRNT + POP HL ; Get AF into HL. + PUSH HL + CALL PRTHL ; AF + LD A, ' ' + CALL PRNT + LD A, ':' + CALL PRNT + LD A, ' ' + CALL PRNT + LD A,(WRKROMBK1) + LD (RFSBK1), A ; Set the MROM bank back to scanned bank. + POP AF + POP BC + POP DE + POP HL + RET -_PRTMZF: PUSH DE - PUSH HL - ; - LD A,(ROMBK1) ; Ensure main MROM is switched in. - LD (RFSBK1), A - ; - LD A,(SCRNMODE) - CP 0 - LD H,46 - JR Z,PRTMZF0 - LD H,92 -PRTMZF0: LD A,(TMPLINECNT) ; Pause if we fill the screen. - LD E,A - INC E - CP H - JR NZ,PRTNOPAUSE - LD E, 0 -PRTPAUSE: CALL ?KEY - JR Z,PRTPAUSE -PRTNOPAUSE:LD A,E - LD (TMPLINECNT),A - ; - LD A, D ; Print out file number and increment. - CALL PRTHX - LD A, '.' - CALL PRNT - LD DE,NAME ; Print out filename. - RST 018h - ; - LD HL, (DSPXY) - ; - LD A,L - CP 20 - LD A,20 - JR C, PRTMZF2 - ; - LD A,(SCRNMODE) ; 40 Char mode? 2 columns of filenames displayed so NL. - CP 0 - JR Z,PRTMZF1 - ; - LD A,L ; 80 Char mode we print 4 columns of filenames. - CP 40 - LD A,40 - JR C, PRTMZF2 - ; - LD A,L - CP 60 - LD A,60 - JR C, PRTMZF2 - ; -PRTMZF1: CALL NL - JR PRTMZF3 -PRTMZF2: LD L,A - LD (DSPXY),HL -PRTMZF3: LD A, (WRKROMBK1) - LD (RFSBK1), A - POP HL - POP DE - RET +_PRTMZF: PUSH DE + PUSH HL + ; + LD A,(ROMBK1) ; Ensure main MROM is switched in. + LD (RFSBK1), A + ; + LD A,(SCRNMODE) + CP 0 + LD H,46 + JR Z,PRTMZF0 + LD H,92 +PRTMZF0: LD A,(TMPLINECNT) ; Pause if we fill the screen. + LD E,A + INC E + CP H + JR NZ,PRTNOPAUSE + LD E, 0 +PRTPAUSE: CALL ?KEY + JR Z,PRTPAUSE +PRTNOPAUSE: LD A,E + LD (TMPLINECNT),A + ; + LD A, D ; Print out file number and increment. + CALL PRTHX + LD A, '.' + CALL PRNT + LD DE,NAME ; Print out filename. + RST 018h + ; + LD HL, (DSPXY) + ; + LD A,L + CP 20 + LD A,20 + JR C, PRTMZF2 + ; + LD A,(SCRNMODE) ; 40 Char mode? 2 columns of filenames displayed so NL. + CP 0 + JR Z,PRTMZF1 + ; + LD A,L ; 80 Char mode we print 4 columns of filenames. + CP 40 + LD A,40 + JR C, PRTMZF2 + ; + LD A,L + CP 60 + LD A,60 + JR C, PRTMZF2 + ; +PRTMZF1: CALL NL + JR PRTMZF3 +PRTMZF2: LD L,A + LD (DSPXY),HL +PRTMZF3: LD A, (WRKROMBK1) + LD (RFSBK1), A + POP HL + POP DE + RET -DIRROM: DI ; Disable interrupts as we are switching out the main rom. - ; - LD A,1 ; Account for the title. - LD (TMPLINECNT),A - ; - LD DE,MSGDIRLST ; Print out header. - RST 018h - CALL NL - ; - ; Scan MROM Bank - ; B = Bank Page - ; C = Block in page - ; D = File sequence number. - ; - LD B,4 ; First 4 pages are reserved in MROM bank. - LD C,0 ; Block in page. - LD D,0 ; File numbering start. - ; -DIRNXTPG: LD A,B - LD (WRKROMBK1), A - LD (RFSBK1), A ; Select bank. - PUSH BC ; Preserve bank count/block number. - PUSH DE ; Preserve file numbering. - LD A,C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B,A - LD C,0 - LD HL,RFS_ATRB ; Add block offset to get the valid block address. - ADD HL,BC - CALL ISMZF - POP DE - POP BC - JR NZ, DIRNOTMZF - ; - CALL PRTMZF - INC D ; Next file sequence number. - ; -DIRNOTMZF: INC C ; Next block. - LD A,C - CP MROMSIZE/RFSSECTSZ ; Max blocks per page reached? - JR C, DIRNXTPG2 - LD C,0 - INC B -DIRNXTPG2: LD A,B - CP 080h ; MROM has 128 banks of 4K, so stop when we reach 128. - JR NZ, DIRNXTPG - ; - ; Get directory of User ROM. - ; - LD A,ROMBANK3 - LD (WRKROMBK1),A - LD (RFSBK1), A - CALL DIRMROM - LD A,(ROMBK1) - LD (RFSBK1), A ; Set the MROM bank back to original. - EI ; No need to block interrupts now as MROM bank restored. - JP ST1X ; End of scan, return to monitor +DIRROM: DI ; Disable interrupts as we are switching out the main rom. + ; + LD A,1 ; Account for the title. + LD (TMPLINECNT),A + ; + LD DE,MSGRDIRLST ; Print out header. + RST 018h + CALL NL + ; + ; Scan MROM Bank + ; B = Bank Page + ; C = Block in page + ; D = File sequence number. + ; + LD B,MROMPAGES ; First 4 pages are reserved in MROM bank. + LD C,0 ; Block in page. + LD D,0 ; File numbering start. + ; +DIRNXTPG: LD A,B + LD (WRKROMBK1), A + LD (RFSBK1), A ; Select bank. + PUSH BC ; Preserve bank count/block number. + PUSH DE ; Preserve file numbering. + LD A,C + IF RFSSECTSZ >= 512 + RLCA + ENDIF + IF RFSSECTSZ >= 1024 + RLCA + ENDIF + LD B,A + LD C,0 + LD HL,RFS_ATRB ; Add block offset to get the valid block address. + ADD HL,BC + CALL ISMZF + POP DE + POP BC + JR NZ, DIRNOTMZF + ; + CALL PRTMZF + INC D ; Next file sequence number. + ; +DIRNOTMZF: INC C ; Next block. + LD A,C + CP MROMSIZE/RFSSECTSZ ; Max blocks per page reached? + JR C, DIRNXTPG2 + LD C,0 + INC B +DIRNXTPG2: LD A,B + CP 080h ; MROM has 128 banks of 4K, so stop when we reach 128. + JR NZ, DIRNXTPG + ; + ; Get directory of User ROM. + ; + LD A,ROMBANK3 + LD (WRKROMBK1),A + LD (RFSBK1), A + CALL DIRMROM + LD A,(ROMBK1) + LD (RFSBK1), A ; Set the MROM bank back to original. + EI ; No need to block interrupts now as MROM bank restored. + RET ; End of scan, return to monitor + ; JP ST1X ; End of scan, return to monitor - ; In: - ; DE = filename - ; Out: - ; B = Bank Page file found - ; C = Block where found. - ; D = File sequence number. - ; Z set if found. -FINDMZF: PUSH DE - LD (TMPADR), DE ; Save name of program to load. - LD HL,0FFFFh ; Tag the filenumber as invalid. - LD (TMPCNT), HL - CALL ConvertStringToNumber ; See if a file number was given instead of a filename. - JR NZ, FINDMZF0 ; - LD (TMPCNT), HL ; Store filenumber making load by filenumber valid. - ; - ; Scan MROM Bank - ; B = Bank Page - ; C = Block in page - ; D = File sequence number. - ; -FINDMZF0: LD B,4 ; First 4 pages are reserved in User ROM bank. - LD C,0 ; Block in page. - LD D,0 ; File numbering start. -FINDMZF1: LD A,B - LD (WRKROMBK1), A - LD (RFSBK1), A ; Select bank. -FINDMZF2: PUSH BC ; Preserve bank count/block number. - PUSH DE ; Preserve file numbering. - LD HL,RFS_ATRB ; Add block offset to get the valid block. - LD A,C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B,A - LD C,0 - ADD HL,BC + ; In: + ; DE = filename + ; Out: + ; B = Bank Page file found + ; C = Block where found. + ; D = File sequence number. + ; Z set if found. +FINDMZF: PUSH DE + LD (TMPADR), DE ; Save name of program to load. + LD HL,0FFFFh ; Tag the filenumber as invalid. + LD (TMPCNT), HL + CALL ConvertStringToNumber ; See if a file number was given instead of a filename. + JR NZ, FINDMZF0 ; + LD (TMPCNT), HL ; Store filenumber making load by filenumber valid. + ; + ; Scan MROM Bank + ; B = Bank Page + ; C = Block in page + ; D = File sequence number. + ; +FINDMZF0: LD B,MROMPAGES ; First 4 pages are reserved in User ROM bank. + LD C,0 ; Block in page. + LD D,0 ; File numbering start. +FINDMZF1: LD A,B + LD (WRKROMBK1), A + LD (RFSBK1), A ; Select bank. +FINDMZF2: PUSH BC ; Preserve bank count/block number. + PUSH DE ; Preserve file numbering. + LD HL,RFS_ATRB ; Add block offset to get the valid block. + LD A,C + IF RFSSECTSZ >= 512 + RLCA + ENDIF + IF RFSSECTSZ >= 1024 + RLCA + ENDIF + LD B,A + LD C,0 + ADD HL,BC - CALL ISMZF - POP DE - POP BC - LD A,(ROMBK1) - LD (RFSBK1), A ; Set the MROM bank back to original. - JR NZ, FINDMZF4 ; Z set if we found an MZF record. - INC HL ; Save address of filename. - PUSH HL - ;CALL PRTMZF ; Print out for confirmation. - LD HL,(TMPCNT) - LD A,H - CP 0FFh ; If TMPCNT tagged as 0xFF then we dont have a filenumber so must match filename. - JR Z, FINDMZF3 - LD A,L ; Check file number, load if match - CP D - JR NZ, FINDMZF3 ; Check name just in case. - POP HL - JR FINDMZFYES ; Else the filenumber matches so load the file. + CALL ISMZF + POP DE + POP BC + LD A,(ROMBK1) + LD (RFSBK1), A ; Set the MROM bank back to original. + JR NZ, FINDMZF4 ; Z set if we found an MZF record. + INC HL ; Save address of filename. + PUSH HL + ; CALL PRTMZF ; Print out for confirmation. + LD HL,(TMPCNT) + LD A,H + CP 0FFh ; If TMPCNT tagged as 0xFF then we dont have a filenumber so must match filename. + JR Z, FINDMZF3 + LD A,L ; Check file number, load if match + CP D + JR NZ, FINDMZF3 ; Check name just in case. + POP HL + JR FINDMZFYES ; Else the filenumber matches so load the file. -FINDMZF3: POP HL - PUSH DE - PUSH BC - LD DE,(TMPADR) ; Original DE put onto stack, original filename into HL - LD BC,17 - LD A,(WRKROMBK1) - LD (RFSBK1), A ; Select correct bank for comparison. - CALL CMPSTRING - POP BC - POP DE - JR Z, FINDMZFYES - INC D ; Next file sequence number. -FINDMZF4: INC C - LD A,C - CP MROMSIZE/RFSSECTSZ ; Max blocks per page reached? - JR C, FINDMZF5 - LD C,0 - INC B -FINDMZF5: LD A,B - CP 080h ; MROM has 128 banks of 4K, so stop when we get to 128. - JR NZ, FINDMZF1 - INC B - JR FINDMZFNO +FINDMZF3: POP HL + PUSH DE + PUSH BC + LD DE,(TMPADR) ; Original DE put onto stack, original filename into HL + LD BC,17 + LD A,(WRKROMBK1) + LD (RFSBK1), A ; Select correct bank for comparison. + CALL CMPSTRING + POP BC + POP DE + JR Z, FINDMZFYES + INC D ; Next file sequence number. +FINDMZF4: INC C + LD A,C + CP MROMSIZE/RFSSECTSZ ; Max blocks per page reached? + JR C, FINDMZF5 + LD C,0 + INC B +FINDMZF5: LD A,B + CP 080h ; MROM has 128 banks of 4K, so stop when we get to 128. + JR NZ, FINDMZF1 + INC B + JR FINDMZFNO -FINDMZFYES: ; Flag set by previous test. -FINDMZFNO: PUSH AF - LD A,(ROMBK1) - LD (RFSBK1), A ; Set the MROM bank back to original. - POP AF - POP HL - RET +FINDMZFYES: ; Flag set by previous test. +FINDMZFNO: PUSH AF + LD A,(ROMBK1) + LD (RFSBK1), A ; Set the MROM bank back to original. + POP AF + POP HL + RET + ; Load Program from ROM + ; IN DE Name of program to load. + ; OUT zero Set if string1 = string2, reset if string1 != string2. + ; carry Set if string1 > string2, reset if string1 <= string2. +LOADROMNX: LD L,0FFH + JR LOADROM1 +LOADROM: LD L,000H +LOADROM1: DI + PUSH HL ; Preserve execute flag. + CALL FINDMZF ; Find the bank and block where the file resides. HL = filename. + JR Z, LROMLOAD - ; Load Program from ROM - ; IN DE Name of program to load. - ; OUT zero Set if string1 = string2, reset if string1 != string2. - ; carry Set if string1 > string2, reset if string1 <= string2. -LOADROM: DI - PUSH HL ; Preserve execute flag. - CALL FINDMZF ; Find the bank and block where the file resides. HL = filename. - JR Z, LROMLOAD + LD A,ROMBANK3 ; Activate the RFS Utilities MROM bank. + LD (WRKROMBK1), A + LD (RFSBK1), A + CALL MFINDMZF ; Try and find the file in User ROM via MROM utility. + JR NZ, LROMNTFND + CALL MROMLOAD ; Load the file from User ROM via MROM utility. + JP Z, LROMLOAD5 - LD A,ROMBANK3 ; Activate the RFS Utilities MROM bank. - LD (WRKROMBK1), A - LD (RFSBK1), A - CALL MFINDMZF ; Try and find the file in User ROM via MROM utility. - JR NZ, LROMNTFND - CALL MROMLOAD ; Load the file from User ROM via MROM utility. - JP Z, LROMLOAD5 +LROMNTFND: POP HL ; Dont need execute flag anymore so waste it. + LD A,(ROMBK1) + LD (RFSBK1),A + LD DE,MSGNOTFND ; Not found + RST 018h -LROMNTFND: POP HL ; Dont need execute flag anymore so waste it. - LD A,(ROMBK1) - LD (RFSBK1),A - LD DE,MSGNOTFND ; Not found - RST 018h +LOADROMEND: EI + RET -LOADROMEND:EI - JP ST1X ; No program of given name found, so show error and exit + ; + ; Load program from RFS Bank 1 (MROM Bank) + ; +LROMLOAD: PUSH BC + LD A,B + LD (WRKROMBK1),A + LD (RFSBK1), A + ; + LD DE, IBUFE ; Copy the header into the work area. + LD HL, 00000h ; Add block offset to get the valid block. + LD A,C + IF RFSSECTSZ >= 512 + RLCA + ENDIF + IF RFSSECTSZ >= 1024 + RLCA + ENDIF + LD B,A + LD C,0 + ADD HL,BC + LD BC, MZFHDRSZ + LDIR - ; - ; Load program from RFS Bank 1 (MROM Bank) - ; -LROMLOAD: PUSH BC - LD A,B - LD (WRKROMBK1),A - LD (RFSBK1), A - ; - LD DE, IBUFE ; Copy the header into the work area. - LD HL, 00000h ; Add block offset to get the valid block. - LD A,C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B,A - LD C,0 - ADD HL,BC - LD BC, MZFHDRSZ - LDIR + PUSH HL + LD DE, (DTADR) + LD HL, (SIZE) + LD BC, RFSSECTSZ - MZFHDRSZ + SBC HL, BC + JR NC, LROMLOAD4 + LD HL, (SIZE) + JR LROMLOAD4 - PUSH HL - LD DE, (DTADR) - LD HL, (SIZE) - LD BC, RFSSECTSZ - MZFHDRSZ - SBC HL, BC - JR NC, LROMLOAD4 - LD HL, (SIZE) - JR LROMLOAD4 + ; HL = address in active block to read. + ; B = Bank + ; C = Block +LROMLOAD2: LD A, B + LD (WRKROMBK1), A + LD (RFSBK1), A - ; HL = address in active block to read. - ; B = Bank - ; C = Block -LROMLOAD2: LD A, B - LD (WRKROMBK1), A - LD (RFSBK1), A +LROMLOAD3: PUSH BC + LD HL, 00000h + LD A, C + IF RFSSECTSZ >= 512 + RLCA + ENDIF + IF RFSSECTSZ >= 1024 + RLCA + ENDIF + LD B, A + LD C, 0 + ADD HL,BC + PUSH HL -LROMLOAD3: PUSH BC - LD HL, 00000h - LD A, C - IF RFSSECTSZ >= 512 - RLCA - ENDIF - IF RFSSECTSZ >= 1024 - RLCA - ENDIF - LD B, A - LD C, 0 - ADD HL,BC - PUSH HL + LD DE, (TMPADR) + LD HL, (TMPSIZE) + LD BC, RFSSECTSZ + SBC HL, BC + JR NC, LROMLOAD4 + LD BC, (TMPSIZE) + LD HL, 0 +LROMLOAD4: LD (TMPSIZE), HL ; HL contains remaining amount of bytes to load. + POP HL + ; + LD A, B ; Pre check to ensure BC is not zero. + OR C + JR Z, LROMLOAD8 + LDIR + LD BC, (TMPSIZE) + LD A, B ; Post check to ensure we still have bytes + OR C + JR Z, LROMLOAD8 + ; + LD (TMPADR),DE ; Address we are loading into. + POP BC +LROMLOAD6: INC C + LD A, C + CP MROMSIZE/RFSSECTSZ ; Max blocks per page reached? + JR C, LROMLOAD7 + LD C, 0 + INC B + ; +LROMLOAD7: LD A, B + CP 080h + JR Z, LROMLOAD5 + JR LROMLOAD2 + ; +LROMLOAD8: POP BC +LROMLOAD5: POP HL ; Retrieve execute flag. + LD A,(ROMBK1) + LD (RFSBK1), A ; Set the MROM bank back to original. + LD A,L ; Autoexecute turned off? + CP 0FFh + JP Z,LROMLOAD9 ; Go back to monitor if it has been, else execute. + LD HL,(EXADR) + EI ; No need to block interrupts now as MROM bank restored. + JP (HL) ; Execution address. +LROMLOAD9: RET - LD DE, (TMPADR) - LD HL, (TMPSIZE) - LD BC, RFSSECTSZ - SBC HL, BC - JR NC, LROMLOAD4 - LD BC, (TMPSIZE) - LD HL, 0 -LROMLOAD4: LD (TMPSIZE), HL ; HL contains remaining amount of bytes to load. - POP HL - ; - LD A, B ; Pre check to ensure BC is not zero. - OR C - JR Z, LROMLOAD8 - LDIR - LD BC, (TMPSIZE) - LD A, B ; Post check to ensure we still have bytes - OR C - JR Z, LROMLOAD8 - ; - LD (TMPADR),DE ; Address we are loading into. - POP BC -LROMLOAD6: INC C - LD A, C - CP MROMSIZE/RFSSECTSZ ; Max blocks per page reached? - JR C, LROMLOAD7 - LD C, 0 - INC B - ; -LROMLOAD7: LD A, B - CP 080h - JR Z, LROMLOAD5 - JR LROMLOAD2 - ; -LROMLOAD8: POP BC -LROMLOAD5: POP HL ; Retrieve execute flag. - LD A,(ROMBK1) - LD (RFSBK1), A ; Set the MROM bank back to original. - LD A,L ; Autoexecute turned off? - CP 0FFh - JP Z,ST1X ; Go back to monitor if it has been, else execute. - LD HL,(EXADR) - EI ; No need to block interrupts now as MROM bank restored. - JP (HL) ; Execution address. + + ; Load a program from the SD Card into RAM and/or execute it. + ; + ; DE points to a number or filename to load. +LOADSDCARDX:LD A,0FFH + JR LOADSDCARD0 +LOADSDCARD: LD A,000H +LOADSDCARD0:LD (SDAUTOEXEC),A + PUSH DE + LD HL,0FFFFh ; Tag the filenumber as invalid. + LD (TMPCNT), HL + CALL ConvertStringToNumber ; See if a file number was given instead of a filename. + JR NZ, LOADSDCARD1 ; + LD (TMPCNT), HL ; Store filenumber making load by filenumber valid. +LOADSDCARD1:POP DE + LD HL,LOADSDE + CALL BKSW0to2 ; Call the main functionality in Bank2. +LOADSDCARD2:RET ; ;====================================== @@ -1059,42 +1169,43 @@ LROMLOAD5: POP HL ; Retrieve execute flag. ; ;====================================== ; -MSGSON: DB "+ RFS ", 0ABh, "1.1 **",00Dh -MSGOK: DB "OK!" -MSGNOTFND: DB "NOT FOUND", 00Dh -MSGDIRLST: DB "ROM DIRECTORY:", 00Dh -MSGTRM: DB 00Dh -MSGSV: DB "FILENAME? ", 0DH -MSG_INITM: DB "INIT MEMORY", 0Dh +MSGSON: DB "+ RFS ", 0ABh, "1.1 **",00Dh +MSGOK: DB "OK!" +MSGNOTFND: DB "NOT FOUND", 00Dh +MSGRDIRLST: DB "ROM DIRECTORY:", 00Dh +MSGTRM: DB 00Dh +MSGSV: DB "FILENAME? ", 0DH +MSG_INITM: DB "INIT MEMORY", 0Dh +MSGBADCMD: DB "???", 0DH - ; Bring in additional resources. - USE_CMPSTRING: EQU 1 - USE_SUBSTRING: EQU 0 - USE_INDEX: EQU 0 - USE_STRINSERT: EQU 0 - USE_STRDELETE: EQU 0 - USE_CONCAT: EQU 0 - USE_CNVUPPER: EQU 1 - USE_CNVCHRTONUM: EQU 1 - USE_ISNUMERIC: EQU 1 - USE_CNVSTRTONUM: EQU 1 - ; - INCLUDE "Macros.asm" - INCLUDE "RFS_Utilities.asm" - ; - ; Ensure we fill the entire 2K by padding with FF's. - ALIGN 0EFFFh - DB 0FFh + ; Bring in additional resources. + USE_CMPSTRING: EQU 1 + USE_SUBSTRING: EQU 0 + USE_INDEX: EQU 0 + USE_STRINSERT: EQU 0 + USE_STRDELETE: EQU 0 + USE_CONCAT: EQU 0 + USE_CNVUPPER: EQU 1 + USE_CNVCHRTONUM: EQU 1 + USE_ISNUMERIC: EQU 1 + USE_CNVSTRTONUM: EQU 1 + ; + INCLUDE "Macros.asm" + INCLUDE "RFS_Utilities.asm" + ; + ; Ensure we fill the entire 2K by padding with FF's. + ALIGN 0EFFFh + DB 0FFh MEND: - ; - ; Include all other banks which make up the RFS User cited ROM. - ; - INCLUDE "rfs_bank1.asm" - INCLUDE "rfs_bank2.asm" - INCLUDE "rfs_bank3.asm" - ;INCLUDE "rfs_bank4.asm" - ;INCLUDE "rfs_bank5.asm" - ;INCLUDE "rfs_bank6.asm" - ;INCLUDE "rfs_bank7.asm" + ; + ; Include all other banks which make up the RFS User cited ROM. + ; + INCLUDE "rfs_bank1.asm" + INCLUDE "rfs_bank2.asm" + INCLUDE "rfs_bank3.asm" + INCLUDE "rfs_bank4.asm" + INCLUDE "rfs_bank5.asm" + INCLUDE "rfs_bank6.asm" + INCLUDE "rfs_bank7.asm" diff --git a/software/asm/rfs_bank1.asm b/software/asm/rfs_bank1.asm index a4bc369..9e652c1 100644 --- a/software/asm/rfs_bank1.asm +++ b/software/asm/rfs_bank1.asm @@ -68,6 +68,26 @@ BKSW1to3: PUSH AF LD A, ROMBANK1 ; Calling bank (ie. us). PUSH AF LD A, ROMBANK3 ; Required bank to call. + JR BKSW1_0 +BKSW1to4: PUSH AF + LD A, ROMBANK1 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK4 ; Required bank to call. + JR BKSW1_0 +BKSW1to5: PUSH AF + LD A, ROMBANK1 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK5 ; Required bank to call. + JR BKSW1_0 +BKSW1to6: PUSH AF + LD A, ROMBANK1 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK6 ; Required bank to call. + JR BKSW1_0 +BKSW1to7: PUSH AF + LD A, ROMBANK1 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK7 ; Required bank to call. ; BKSW1_0: PUSH BC ; Save BC for caller. LD BC, BKSWRET1 ; Place bank switchers return address on stack. diff --git a/software/asm/rfs_bank2.asm b/software/asm/rfs_bank2.asm index 7a6bb76..3b546f9 100644 --- a/software/asm/rfs_bank2.asm +++ b/software/asm/rfs_bank2.asm @@ -27,99 +27,1330 @@ ;- along with this program. If not, see . ;-------------------------------------------------------------------------------------------------------- - ;====================================== - ; - ; USER ROM BANK 2 - ; - ;====================================== - ORG 0E800h + ;====================================== + ; + ; USER ROM BANK 2 + ; + ;====================================== + ORG 0E800h - ;-------------------------------- - ; Common code spanning all banks. - ;-------------------------------- -ROMFS2: NOP - XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 - LD (RFSBK1),A - LD (RFSBK2),A ; and start up - ie. SA1510 Monitor. - ALIGN_NOPS 0E829H + ;-------------------------------- + ; Common code spanning all banks. + ;-------------------------------- +ROMFS2: NOP + XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 + LD (RFSBK1),A + LD (RFSBK2),A ; and start up - ie. SA1510 Monitor. + ALIGN_NOPS 0E829H - ; Bank switching code, allows a call to code in another bank. - ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. - ; -BKSW2to0: PUSH AF - LD A, ROMBANK2 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK0 ; Required bank to call. - JR BKSW2_0 -BKSW2to1: PUSH AF - LD A, ROMBANK2 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK1 ; Required bank to call. - JR BKSW2_0 -BKSW2to2: PUSH AF - LD A, ROMBANK2 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK2 ; Required bank to call. - JR BKSW2_0 -BKSW2to3: PUSH AF - LD A, ROMBANK2 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK3 ; Required bank to call. - ; -BKSW2_0: PUSH BC ; Save BC for caller. - LD BC, BKSWRET2 ; Place bank switchers return address on stack. - PUSH BC - LD (RFSBK2), A ; Bank switch in user rom space, A=bank. - LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. - JP (HL) ; Jump to required function. -BKSWRET2: POP BC - POP AF ; Get bank which called us. - LD (RFSBK2), A ; Return to that bank. - POP AF - RET ; Return to caller. + ; Bank switching code, allows a call to code in another bank. + ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. + ; +BKSW2to0: PUSH AF + LD A, ROMBANK2 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK0 ; Required bank to call. + JR BKSW2_0 +BKSW2to1: PUSH AF + LD A, ROMBANK2 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK1 ; Required bank to call. + JR BKSW2_0 +BKSW2to2: PUSH AF + LD A, ROMBANK2 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK2 ; Required bank to call. + JR BKSW2_0 +BKSW2to3: PUSH AF + LD A, ROMBANK2 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK3 ; Required bank to call. + JR BKSW2_0 +BKSW2to4: PUSH AF + LD A, ROMBANK2 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK4 ; Required bank to call. + JR BKSW2_0 +BKSW2to5: PUSH AF + LD A, ROMBANK2 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK5 ; Required bank to call. + JR BKSW2_0 +BKSW2to6: PUSH AF + LD A, ROMBANK2 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK6 ; Required bank to call. + JR BKSW2_0 +BKSW2to7: PUSH AF + LD A, ROMBANK2 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK7 ; Required bank to call. + ; +BKSW2_0: PUSH BC ; Save BC for caller. + LD BC, BKSWRET2 ; Place bank switchers return address on stack. + PUSH BC + LD (RFSBK2), A ; Bank switch in user rom space, A=bank. + LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. + JP (HL) ; Jump to required function. +BKSWRET2: POP BC + POP AF ; Get bank which called us. + LD (RFSBK2), A ; Return to that bank. + POP AF + RET ; Return to caller. - ; Simple help screen to display commands. -HELP: CALL NL - LD DE, HELPSCR - CALL PRTSTR - RET - ; Modification of original MSG function, use NULL terminated strings not CR terminated. -PRTSTR: PUSH AF - PUSH BC - PUSH DE -PRTSTR1: LD A,(DE) - CP 000H - JR Z,PRTSTRE - CALL PRNT - INC DE - JR PRTSTR1 -PRTSTRE: POP DE - POP BC - POP AF - RET - ; Help text. Use of lower case, due to Sharp's non standard character set, is not easy, you have to manually code each byte - ; hence using upper case. -HELPSCR: DB "4 - 40 COL MODE.", 00DH - DB "8 - 80 COL MODE.", 00DH - DB "B - TOGGLE KEYBOARD BELL.", 00DH - DB "C - CLEAR MEMORY $1200-$D000.", 00DH - DB "DXXXX[YYYY] - DUMP MEM XXXX TO YYYY.", 00DH - DB "F[X] - BOOT FD DRIVE X.", 00DH - DB 0AAH, " - BOOT FD ORIGINAL ROM.", 00DH - DB "H - THIS HELP SCREEN.", 00DH - DB "I - RFS DIRECTORY LISTING.", 00DH - DB "JXXXX - JUMP TO LOCATION XXXX.", 00DH - DB "L[FN] - LOAD RFS/TAPE, FN=NO OR FN.", 00DH - DB 0B8H, "[FN] - AS ABOVE BUT DONT AUTO-EXEC.", 00DH - DB "MXXXX - EDIT MEMORY STARTING AT XXXX.", 00DH - DB "P - TEST PRINTER.", 00DH - DB "R - TEST DRAM MEMORY.", 00DH - DB "S - SAVE CURRENT PROG TO TAPE.", 00DH - DB "T - TEST TIMER.", 00DH - DB "V - VERIFY TAPE SAVE.", 00DH - DB 000H + ; Method to initialise the SD card. + ; +SDINIT: LD A,000H ; CS to high + CALL SPICS + ; + CALL SPIINIT ; Train SD with our clock. + ; + LD A,0FFH ; CS to low + CALL SPICS + LD BC,0FFFFH + +SDINIT1: LD A,CMD0 ; Command 0 + LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD - ALIGN 0EFFFh - DB 0FFh + PUSH BC + LD A,(SDBUF+6) ; Get response code. + DEC A ; Set Z flag to test if response is 0x01 + JP Z,SDINIT2 ; Command response 0x01? Exit if match. + POP BC + DEC BC + LD A,B + OR C + JR NZ,SDINIT1 ; Retry for BC times. + LD A,1 + JP SD_EXIT ; Error, card is not responding to CMD0 +SDINIT2: POP BC + ; Now send CMD8 to get card details. This command can only be sent + ; when the card is idle. + LD A,CMD8 ; CMD8 has 0x00001AA as parameter, load up registers and call command routine. + LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,0AA01H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + + ; Version 2 card, check its voltage range. IF not in the 2.7-3.6V dont try the ACMD41 to get capabilities. +SDINIT3: LD A,1 ; Check that we receive 0x0001AA in response. + LD (SDVER),A ; Indicate this is not a version 2 card. + LD A,(SDBUF+9) + CP 1 + JP NZ,SDINIT8 + LD A,(SDBUF+10) + CP 0AAH + JP NZ,SDINIT8 + +SDINIT4: LD A,2 ; This is a version 2 card. +SDINIT5: LD (SDVER),A ; Indicate this is not a version 2 card. + + CALL SDACMD41 + JR Z,SDINIT6 + LD A,2 ; Error, card is not responding to ACMD41 + JP SD_EXIT + +SDINIT6: LD A,CMD58 ; CMD58 has 0x00000000 as parameter, load up registers and call command routine. + LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(SDBUF+6) + CP 040H + LD A,CT_SD2 + JR Z,SDINIT7 + LD A,CT_SD2 | CT_BLOCK +SDINIT7: LD (SDCAP),A ; Set the capabilities according to the returned flag. + JR SDINIT14 + + + ; Version 1 card or MMC v3. +SDINIT8: CALL SDACMD41 + LD A, CT_SD1 + LD E,ACMD41 ; SD1 cards we use the ACMD41 command. + JR Z,SDINIT9 + LD A,CT_MMC + LD E,CMD1 ; MMC cards we use the CMD1 command. +SDINIT9: LD (SDCAP),A + LD A,E + CP ACMD41 + JR NZ,SDINIT10 + CALL SDACMD41 + JR Z,SDINIT14 + LD A,3 ; Exit code, failed to initialise v1 card. + JP SD_EXIT + +SDINIT10: LD BC,10 ; ACMD41/CMD55 may take some cards time to process or respond, so give a large number of retries. +SDINIT11: PUSH BC + LD A,CMD1 ; CMD1 has 0x00000000 as parameter, load up registers and call command routine. + LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + OR A + JR Z,SDINIT13 + LD BC,0FFFFH ; Delay for at least 200mS for the card to recover and be ready. +SDINIT12: DEC BC ; 6T + LD A,B ; 9T + OR C ; 4T + JR NZ,SDINIT12 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS + ; + POP BC + DEC BC + LD A,B + OR C + JR NZ,SDINIT11 + LD A,4 ; Exit code, failed to initialise v1 MMC card. + JP SD_EXIT + +SDINIT13: LD A,CMD16 ; No response from the card for an ACMD41/CMD1 so try CMD16 with parameter 0x00000200 + LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,00002H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(SDBUF+6) + OR A + JR Z,SDINIT14 + LD A,0 + LD (SDCAP),A ; No capabilities on this unknown card. +SDINIT14: LD A,0 + JR SD_EXIT +SD_EXIT: LD L,A ; Return value goes into HL. + LD H,0 + RET + + ; Method to initialise communications with the SD card. We basically train it to our clock characteristics. + ; This is important, as is maintaining the same clock for read or write otherwise the card may not respond. +SPIINIT: LD B,80 +SPIINIT1: LD A,DOUT_HIGH | CLOCK_HIGH | CS_HIGH ; Output a 1 + OUT (SPI_OUT),A + LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Output a 1 + OUT (SPI_OUT),A + DJNZ SPIINIT1 + RET + + ; Method to set the Chip Select level on the SD card. The Chip Select is active LOW. + ; + ; A = 0 - Set CS HIGH + ; A = 0xFF - Set CS LOW +SPICS: OR A + LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Set CS High if parameter = 0 (ie. disable) + JR Z, SPICS0 + LD A,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Set CS Low if parameter != 0 (ie. disable) +SPICS0: OUT (SPI_OUT),A + RET + + ; Method to send a command to the card and receive back a response. + ; + ; A = CMD to send + ; LHED = Argument, ie. CMD = A, L, H, E, D, CRC + ; +SDCMD: LD (SDBUF),A + LD (SDBUF+1),HL + EX DE,HL + LD (SDBUF+3),HL + ; + ; Send command but with parameters preloaded by caller. +SDCMDNP: LD B,5 ; R1 + 32bit argument for CMD8, CMD58 + CP CMD8 + LD C,135 + JP Z,SDCMD0 + LD C,1 ; CMD58 is not CRC checked so just set to 0x01. + CP CMD58 + LD B,5 ; R1 + 32bit argument + JP Z,SDCMD0 + ; + LD B,1 ; Default, expect R1 which is 1 byte. + CP CMD0 ; Work out the CRC based on the command. CRC checking is + LD C,149 ; not implemented but certain commands require a fixed argument and CRC. + JP Z,SDCMD0 + LD C,1 ; Remaining commands are not CRC checked so just set to 0x01. +SDCMD0: PUSH BC ; Save the CRC and the number of bytes to be returned, + LD A,C ; Store the CRC + LD (SDBUF+5),A + LD A,255 ; Preamble byte + CALL SPIOUT + LD HL,SDBUF + LD B,6 +SDCMD1: PUSH BC + LD A,(HL) + INC HL + CALL SPIOUT ; Send the command and parameters. + POP BC + DJNZ SDCMD1 + PUSH HL +SDCMD2: CALL SPIIN + CP 0FFH + JR Z,SDCMD2 + JR SDCMD4 +SDCMD3: PUSH BC + PUSH HL + CALL SPIIN ; +SDCMD4: POP HL + LD (HL),A + INC HL + POP BC ; Get back number of expected bytes. HL = place in buffer to store response. + DJNZ SDCMD3 + LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH + OUT (SPI_OUT),A + RET + + ; Method to send an Application Command to the SD Card. This involves sending CMD55 followed by the required command. + ; + ; A = ACMD to send + ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC + ; +SDACMD: PUSH AF + PUSH DE + PUSH HL + LD A,CMD55 ; CMD55 has 0x00000000 as parameter, load up registers and call command routine. + LD HL,00000H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + DEC A + JR NZ,SDACMD + + POP HL + POP DE + POP AF + CALL SDCMD + LD A,(SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + OR A + RET + + ; Method to send Application Command 41 to the SD card. This command involves retries and delays + ; hence coded seperately. + ; + ; Returns Z set if successful, else NZ. + ; +SDACMD41: LD BC,10 ; ACMD41/CMD55 may take some cards time to process or respond, so give a large number of retries. +SDACMD1: PUSH BC + LD A,ACMD41 ; ACMD41 has 0x40000000 as parameter, load up registers and call command routine. + LD HL,00040H ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,00000H ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDACMD + LD A,(SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + OR A + JR Z,SDACMD3 + LD BC,12903 ; Delay for at least 200mS for the card to recover and be ready. +SDACMD2: DEC BC ; 6T + LD A,B ; 9T + OR C ; 4T + JR NZ,SDACMD2 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS + ; + POP BC + DEC BC + LD A,B + OR C + JR NZ,SDACMD1 + LD A,1 +SDACMD3: OR A + RET + + ; Method to send a byte to the SD card via the SPI protocol. + ; This method uses the bitbang technique, change if hardware spi is available. + ; + ; Input A = Byte to send. + ; +SPIOUT: RLCA ; 65432107 + RLCA ; 54321076 + RLCA ; 43210765 - Adjust so that starting bit is same position as Data line. + LD E,A ; E = Character to send. + LD B,8 ; B = Bit count +SPIOUT0: LD A,E + AND DOUT_MASK ; Data bit to data line, clock and cs low. + RLC E +SPIOUT1: OUT (SPI_OUT),A + OR CLOCK_HIGH ; Clock high + OUT (SPI_OUT),A + AND CLOCK_MASK ; Clock low + OUT (SPI_OUT),A + DJNZ SPIOUT0 ; Perform actions for the full 8 bits. + RET + + ; Method to receive a byte from the SD card via the SPI protocol. + ; This method uses the bitbang technique, change if hardware spi is available. + ; NB. Timing must be very similar in SPIOUT and SPIIN. + ; + ; Output: A = received byte. + ; +SPIIN: LD BC,00800H | SPI_OUT ; B = Bit count, C = clock port + LD L,0 ; L = Character being read. + LD D,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Output a 0 + OUT (C),D ; To start ensure clock is low and CS is low. + LD E,DOUT_HIGH | CLOCK_HIGH | CS_LOW ; Output a 0 +SPIIN1: OUT (C),E ; Clock to high. + IN A,(SPI_IN) ; Input the received bit + OUT (C),D ; Clock to low. + SRL A + RL L + DJNZ SPIIN1 ; Perform actions for the full 8 bits. + LD A,L ; return value + RET + + ; A function from the z88dk stdlib, a delay loop with T state accuracy. + ; + ; enter : hl = tstates >= 141 + ; uses : af, bc, hl +T_DELAY: LD BC,-141 + ADD HL,BC + LD BC,-23 +TDELAYLOOP: ADD HL,BC + JR C, TDELAYLOOP + LD A,L + ADD A,15 + JR NC, TDELAYG0 + CP 8 + JR C, TDELAYG1 + OR 0 +TDELAYG0: INC HL +TDELAYG1: RRA + JR C, TDELAYB0 + NOP +TDELAYB0: RRA + JR NC, TDELAYB1 + OR 0 +TDELAYB1: RRA + RET NC + RET + + ; Method to skip over an SD card input stream to arrive at the required bytes, + ; + ; Input: BC = Number of bytes to skip. + ; +SPISKIP: PUSH BC + CALL SPIIN + POP BC + DEC BC + LD A,B + OR C + JR NZ,SPISKIP + RET + + ; Method to convert an LBA value into a physical byte address. This is achieved by multiplying the block x 512. + ; We take the big endian sector value, shift left 9 times then store the result back onto the stack. + ; This is done as follows: <2> <1> <0> => <2> <1> <0> 0 (ie. 8 bit shift): Shift left <0> with carry, shift left <1> shift left <2>, 0 to + ; + ; Input: HL = Stack offset. +LBATOADDR: LD HL,(SDSTARTSEC+1) + LD A,(HL) ; Start ny retrieving bytes as HED0 + INC HL + LD E,(HL) + INC HL + LD D,(HL) + LD L,A + + SLA D ; Shift the long left by 9 to effect a x512 + RL E + RL H + LD BC,(SDSTARTSEC) + LD A,H ; Now save the results as LHED, big endian format as used by the SD Card argument + LD (BC),A + INC BC + LD A,E + LD (BC),A + INC BC + LD A,D + LD (BC),A + INC BC + LD A,0 + LD (BC),A + RET + +; +; ; Method to read a sector or partial sector contents to an SD Card. +; ; +; ; This method was originally a C routine I was using for FatFS but optimised it (still more can be done). The C->ASM is not so optimal. +; ; +; ; Input: on Stack : Position 2 = unsigned int count of 2 bytes. - The count of bytes to read. +; ; Position 4 = unsigned int offset of 2 bytes. - The offset in the 512 byte sector to commence read. +; ; Position 6 = unsigned long sector of 4 bytes. - The sector number or direct byte address for older cards. +; ; Position 10 = unsigned char BYTE *buf of 2 bytes- Pointer to a buffer where the bytes should be stored +; ; Output: A = 0 - All ok. A > 0 - error occurred. +; ; +;SD_READP: LD A,0 +; CALL SPICS ; Set CS low (active). +; +; LD HL,(SDCAP) ; Test to see if CT_BLOCK is available. +; LD H,0 +; LD A,CT_BLOCK +; AND L +; JP NZ,READP_3 ; If it has CT_BLOCK then use sector numbers otherwise multiply up to bytes. +; +; LD HL,6 + 2 ; It isnt so we need to convert the block to bytes by x512. +; CALL LBATOADDR +; +;READP_3: LD A,1 +; LD (RESULT),A +; +; ; A = ACMD to send +; ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC +; LD HL,6 ; Sector is stored as 3rd paramneter at offset 6, retrieve and arrange in little endian order in LHED +; ADD HL,SP +; LD D,(HL) +; INC HL +; LD E,(HL) +; INC HL +; PUSH DE +; LD D,(HL) +; INC HL +; LD E,(HL) +; LD A,CMD17 ; Send CMD17 to read a sector. +; POP HL +; EX DE,HL +; CALL SDCMD +; LD A,(SDBUF+6) ; Fetch result and store. +; AND A +; JP NZ,READP_4 +; +; LD HL,1000 ; Sit in a tight loop waiting for the data packet arrival (ie. not 0xFF). +;READP_7: PUSH HL +; LD HL,200 +; CALL T_DELAY +; CALL SPIIN +; POP HL +; CP 255 +; JP NZ,READP_6 +; DEC HL +; LD A,H +; OR L +; JR NZ,READP_7 +; +;READP_6: CP 254 +; JP NZ,READP_4 +; LD HL,4 +; ADD HL,SP +; LD E,(HL) +; INC HL +; LD D,(HL) +; LD HL,514 +; AND A +; SBC HL,DE +; EX DE,HL +; POP BC +; POP HL +; PUSH HL +; PUSH BC +; EX DE,HL +; AND A +; SBC HL,DE +; LD (BYTECNT),HL +; +; LD HL,4 +; ADD HL,SP +; LD A,(HL) +; INC HL +; LD H,(HL) +; LD L,A +; LD A,H +; OR L +; JP Z,READP_11 +; +; PUSH HL +; POP BC +; CALL SPISKIP +; +;READP_11: LD HL,10 ; Get the buffer pointer from where to read data. +; ADD HL,SP +; LD A,(HL) +; INC HL +; LD H,(HL) +; LD L,A +; LD A,H +; OR L +; JP Z,READP_12 +; +;READP_15: PUSH HL +; CALL SPIIN +; POP HL +; LD (HL),A +; INC HL +; PUSH HL +; POP BC +; +; LD HL,10 ; Update the pointer on the stack with register copy. +; ADD HL,SP +; LD (HL),C +; INC HL +; LD (HL),B +;READP_13: POP DE ; Return address. +; POP HL ; Count +; DEC HL ; Decrement count +; PUSH HL ; And return stack to previous state. +; PUSH DE +; LD A,H +; OR L +; PUSH BC +; POP HL +; JP NZ,READP_15 +; +;READP_12: LD HL,(BYTECNT) +; PUSH HL +; POP BC +; CALL SPISKIP +; LD A,0 +; LD (RESULT),A +;READP_4: +; LD A,0 +; CALL SPICS +; LD A,(RESULT) +; RET + + +; ; Method to write a sector or partial sector contents to an SD Card. +; ; This method was originally a C routine I was using for FatFS but optimised it (still more can be done). The C->ASM is not so optimal. +; ; +; ; Input: on Stack : Position 2 = unsigned long sector of 4 bytes. - This is the sector number if *buf = NULL, the byte count to write if *buf != NULL, +; ; or NULL to initialise/finalise a sector write. +; ; Position 6 = unsigned char BYTE *buf of 2 bytes.- This is the pointer to the data for writing. If NULL it indicates an initialise/ +; ; finalise action with above sector being use to indicate mode (!= 0 initialise, 0 = finalise). +; ; If not NULL points to actual data for writing with the number of bytes stored in sector above. +; ; Output: A = 0 - All ok. A > 0 - error occurred. +;SD_WRITEP: LD A,1 +; LD (RESULT),A +; +; LD A,0FFH ; Activate CS (set low). +; CALL SPICS +; +; LD HL,6 ; If buffer is not null, we are writing data, otherwise we are instigating a write transaction. +; ADD HL,SP +; LD A,(HL) +; INC HL +; LD H,(HL) +; LD L,A +; LD A,H +; OR L +; JP Z,WRITEP_3 ; NULL so we are performing a transaction open/close. +; +; LD HL,2 ; Get the sector into DEHL. +; ADD HL,SP +; LD A,(HL) +; INC HL +; LD H,(HL) +; LD L,A +; LD (BYTECNT),HL ; Only interested in the lower 16bit value of the long. +; +;WRITEP_4: LD A,H ; So long as we have bytes in the buffer, send to the card for writing. +; OR L +; JP Z,WRITEP_5 +; LD HL,(WRITECNT) ; Count of bytes to write. +; LD A,H +; OR L +; JR Z,WRITEP_5 ; If either the max count (512) or the requested count (BYTECNT) have expired, exit. +; +; LD HL,6 ; Load the buffer pointer. +; ADD HL,SP +; INC (HL) +; LD A,(HL) +; INC HL +; JR NZ,WRITEP_2 ; Increment by 1 carrying overflow into MSB. +; INC (HL) +;WRITEP_2: LD H,(HL) +; LD L,A +; DEC HL ; Back to current byte. +; LD A,(HL) +; CALL SPIOUT +; LD HL,(WRITECNT) ; Decrement the max count. +; DEC HL +; LD (WRITECNT),HL +; LD HL,(BYTECNT) ; Decrement the requested count. +; DEC HL +; LD (BYTECNT),HL +; JP WRITEP_4 +; +;WRITEP_5: LD A,0 +; LD (RESULT),A +; JP WRITEP_8 +; +;WRITEP_3: LD HL,2 ; Get the sector number into DEHL to test. +; ADD HL,SP +; LD E,(HL) +; INC HL +; LD D,(HL) +; INC HL +; LD A,(HL) +; INC HL +; LD H,(HL) +; LD L,A +; EX DE,HL +; LD A,H +; OR L +; OR D +; OR E +; JP Z,WRITEP_9 ; Sector is 0 so finalise the write transaction. +; +; LD HL,(SDCAP) ; Check to see if the card has block addressing. +; LD H,0 +; LD A,CT_BLOCK +; AND L +; JP NZ,WRITEP_10 ; If it hasnt then we need to multiply up to the correct byte. +; +; LD HL,2 + 2 ; Fetch the sector number, multiply (by left shift x 9) x512 and store. +; CALL LBATOADDR +; +; ; A = ACMD to send +; ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC +;WRITEP_10: LD HL,2 ; Sector is stored as 3rd paramneter at offset 6, retrieve and arrange in little endian order in LHED +; ADD HL,SP +; LD D,(HL) +; INC HL +; LD E,(HL) +; INC HL +; PUSH DE +; LD D,(HL) +; INC HL +; LD E,(HL) +; LD A,CMD24 ; Send CMD24 to write a sector. +; POP HL +; EX DE,HL +; CALL SDCMD +; LD A,(SDBUF+6) ; Fetch result and store. +; AND A +; JP NZ,WRITEP_8 +; LD A,255 +; CALL SPIOUT +; LD A,254 +; CALL SPIOUT +; LD HL,SD_SECSIZE +; LD (WRITECNT),HL +; LD A,0 +; LD (RESULT),A +; JP WRITEP_8 +; +;WRITEP_9: LD HL,(WRITECNT) +; INC HL +; INC HL +; LD (BYTECNT),HL +;WRITEP_13: +; LD HL,(BYTECNT) +; DEC HL +; LD (BYTECNT),HL +; INC HL +; LD A,H +; OR L +; JP Z,WRITEP_14 +; LD A,0 +; CALL SPIOUT +; JP WRITEP_13 +;WRITEP_14: +; CALL SPIIN +; AND 01FH +; LD L,A +; LD H,0 +; CP 5 +; JP NZ,WRITEP_15 +; +; LD HL,10000 +; PUSH HL +; JR WRITEP_18 +;WRITEP_20: DEC HL +; PUSH HL +; LD HL,200 +; CALL T_DELAY +;WRITEP_18: CALL SPIIN +; POP HL +; CP 255 +; JP Z,WRITEP_17 +; LD A,H +; OR L +; JR NZ,WRITEP_20 +; +;WRITEP_17: LD A,H +; OR L +; JP Z,WRITEP_15 +; LD A,0 +; LD (RESULT),HL +;WRITEP_15: LD A,000H +; CALL SPICS +;WRITEP_8: LD A,(RESULT) +; RET + + + ; Method to read a sector or partial sector contents to an SD Card. + ; + ; This method was originally a C routine I was using for FatFS but optimised it (still more can be done). The C->ASM is not so optimal. + ; + ; Input: Memory variables: SDBYTECNT = unsigned int count. - The count of bytes to read. + ; SDOFFSET = unsigned int offset. - The offset in the 512 byte sector to commence read. + ; SDSTARTSEC= unsigned long sector. - The sector number or direct byte address for older cards. This is big endian as per card. + ; SDLOADADDR= unsigned char BYTE *buf - Pointer to a buffer where the bytes should be stored + ; Output: A = 0 - All ok. A > 0 - error occurred. + ; +SD_READ: LD A,0 + CALL SPICS ; Set CS low (active). + + LD HL,(SDCAP) ; Test to see if CT_BLOCK is available. + LD H,0 + LD A,CT_BLOCK + AND L + JP NZ,SD_READ3 ; If it has CT_BLOCK then use sector numbers otherwise multiply up to bytes. + CALL LBATOADDR ; Multiply the sector by 512 for byte addressing on older cards. + +SD_READ3: LD A,1 + LD (RESULT),A + + ; A = ACMD to send + ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC + LD A,CMD17 ; Send CMD17 to read a sector. + LD (SDBUF),A + LD HL,(SDSTARTSEC) + LD (SDBUF+1),HL + LD HL,(SDSTARTSEC+2) + LD (SDBUF+3),HL + CALL SDCMDNP ; Execute SD Command, parameters already loaded into command buffer. + LD A,(SDBUF+6) ; Fetch result and store. + AND A + JP NZ,SD_READ4 + + LD HL,1000 ; Sit in a tight loop waiting for the data packet arrival (ie. not 0xFF). +SD_READ7: PUSH HL + LD HL,200 + CALL T_DELAY + CALL SPIIN + POP HL + CP 255 + JP NZ,SD_READ6 + DEC HL + LD A,H + OR L + JR NZ,SD_READ7 + +SD_READ6: CP 254 ; Data? If not exit with error code. + JP NZ,SD_READ4 + + LD DE,(SDOFFSET) ; Get offset. + LD HL,SD_SECSIZE+2 ; Size of sector + 2 CRC bytes. + AND A + SBC HL,DE ; Subtract the offset + LD DE,(SDBYTECNT) ; Get count. + AND A + SBC HL,DE ; Subtract the count + LD (BYTECNT),HL ; We are left with number of bytes we dont want to read. + + LD BC,(SDOFFSET) ; Check offset, if not zero then skip offset bytes. + LD A,B + OR C + JP Z,SD_READ11 + CALL SPISKIP + +SD_READ11: LD HL,(SDLOADADDR) ; Get the load address, check to see that it is not NULL before receiving. + LD A,H + OR L + JP Z,SD_READ12 + +SD_READ15: PUSH HL ; Start reading bytes into the buffer. + CALL SPIIN + POP HL + LD (HL),A + INC HL ; Update buffer pointer. + +SD_READ13: LD BC,(SDBYTECNT) ; Get the count + DEC BC + LD (SDBYTECNT),BC ; And decrement, test to see if we have reached zero. + LD A,B + OR C + JP NZ,SD_READ15 ; Not zero, keep reading. + LD (SDLOADADDR),HL ; Update memory copy of buffer pointer (for reference only). + +SD_READ12: LD BC,(BYTECNT) ; Get the number of bytes we dont want. + CALL SPISKIP ; Skip them to complete the transaction. + LD A,0 ; And exit with success. + LD (RESULT),A +SD_READ4: + LD A,0 + CALL SPICS + LD A,(RESULT) + RET + + ; Method to write a sector or partial sector contents to an SD Card. + ; This method was originally a C routine I was using for FatFS but optimised it (still more can be done). The C->ASM is not so optimal. + ; + ; Input: on Stack : Position 2 = unsigned long sector of 4 bytes. - This is the sector number if *buf = NULL, the byte count to write if *buf != NULL, + ; or NULL to initialise/finalise a sector write. + ; Position 6 = unsigned char BYTE *buf of 2 bytes.- This is the pointer to the data for writing. If NULL it indicates an initialise/ + ; finalise action with above sector being use to indicate mode (!= 0 initialise, 0 = finalise). + ; If not NULL points to actual data for writing with the number of bytes stored in sector above. + ; Input: Memory variables: SDSTARTSEC= unsigned long sector. - The sector number or direct byte address for older cards. This is big endian as per card. + ; SDLOADADDR= unsigned char BYTE *buf - Pointer to a buffer where the bytes should be stored + ; Output: A = 0 - All ok. A > 0 - error occurred. +SD_WRITE: LD A,1 + LD (RESULT),A + + LD A,0FFH ; Activate CS (set low). + CALL SPICS + + LD HL,(SDLOADADDR) ; If buffer is not null, we are writing data, otherwise we are instigating a write transaction. + LD A,H + OR L + JP Z,SD_WRITE3 ; NULL so we are performing a transaction open/close. + + LD HL,(SDSTARTSEC+2) ; Get the sector into DEHL. + ADD HL,SP + LD A,(HL) + INC HL + LD H,(HL) + LD L,A + LD (BYTECNT),HL ; Only interested in the lower 16bit value of the long. + +SD_WRITE4: LD A,H ; So long as we have bytes in the buffer, send to the card for writing. + OR L + JP Z,SD_WRITE5 + LD HL,(WRITECNT) ; Count of bytes to write. + LD A,H + OR L + JR Z,SD_WRITE5 ; If either the max count (512) or the requested count (BYTECNT) have expired, exit. + + LD HL,(SDLOADADDR) ; Load the buffer pointer. + LD A,(HL) ; Get the byte to transmit. + INC HL ; And update the pointer. + LD (SDLOADADDR),HL + CALL SPIOUT + + LD HL,(WRITECNT) ; Decrement the max count. + DEC HL + LD (WRITECNT),HL + LD HL,(BYTECNT) ; Decrement the requested count. + DEC HL + LD (BYTECNT),HL ; Whichever counter hits 0 first terminates the transmission. + JP SD_WRITE4 + +SD_WRITE5: LD A,0 + LD (RESULT),A + JP SD_WRITE8 + +SD_WRITE3: LD HL,(SDSTARTSEC) ; Get the sector number into DEHL to test if 0. Dont worry about endian as we are testing for 0. + LD DE,(SDSTARTSEC+2) + LD A,H + OR L + OR D + OR E + JP Z,SD_WRITE9 ; Sector is 0 so finalise the write transaction. + + LD HL,(SDCAP) ; Check to see if the card has block addressing. + LD H,0 + LD A,CT_BLOCK + AND L + JP NZ,SD_WRITE10 ; If it hasnt then we need to multiply up to the correct byte. + CALL LBATOADDR ; Multiply the sector by 512 for byte addressing. + + ; A = ACMD to send + ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC +SD_WRITE10: LD A,CMD24 ; Send CMD24 to write a sector. + LD (SDBUF),A + LD HL,(SDSTARTSEC) ; Place long endian sector into command buffer. + LD (SDBUF+1),HL + LD HL,(SDSTARTSEC+2) + LD (SDBUF+3),HL + CALL SDCMDNP ; Send command using No Parameters version as we loaded them into the command buffer already. + LD A,(SDBUF+6) ; Fetch result and store. + AND A + JP NZ,SD_WRITE8 + LD A,255 ; Ok, so command sent successfully, mark the write by sending an 0xFF followed by 0xFE + CALL SPIOUT + LD A,254 + CALL SPIOUT + LD HL,SD_SECSIZE ; Full sector write. + LD (WRITECNT),HL + LD A,0 ; Assume success unless directed otherwise. + LD (RESULT),A + JP SD_WRITE8 + +SD_WRITE9: LD HL,(WRITECNT) ; Add 2 to the remaining padding bytes to account for CRC even though we dont use it. + INC HL + INC HL + LD (BYTECNT),HL +SD_WRITE13: LD HL,(BYTECNT) ; Decrement by 1 to account for byte being sent. + DEC HL + LD (BYTECNT),HL + INC HL + LD A,H ; Test to see if we are already at zero, ie. all bytes sent. Exit if so. + OR L + JP Z,SD_WRITE14 + LD A,0 ; Send 0's as padding bytes and CRC. + CALL SPIOUT + JP SD_WRITE13 +SD_WRITE14: CALL SPIIN ; Check received response, if 0x05 which indicates write under way inside SD Card. + AND 01FH + LD L,A + LD H,0 + CP 5 + JP NZ,SD_WRITE15 + + LD HL,10000 ; Now wait for the write to complete allowing 1000mS before timing out. + PUSH HL + JR SD_WRITE18 +SD_WRITE20: DEC HL + PUSH HL + LD HL,200 ; 200T state delay = 200 x 1/2000000 = 100uS + CALL T_DELAY +SD_WRITE18: CALL SPIIN ; Get a byte, if it is not 0xFF then we have our response so exit. + POP HL + CP 255 + JP Z,SD_WRITE17 + LD A,H + OR L + JR NZ,SD_WRITE20 + +SD_WRITE17: LD A,H ; End of timeout? If so we exit with the preset fail code. + OR L + JP Z,SD_WRITE15 + LD A,0 ; Change to success code as all was ok. + LD (RESULT),HL +SD_WRITE15: LD A,000H ; Disable SD Card Chip Select to finish. + CALL SPICS +SD_WRITE8: LD A,(RESULT) ; Return result. + RET + + + ; Method to print out an SDC directory entry name along with an incremental file number. The file number can be + ; used as a quick reference to a file rather than the filename. + ; + ; Input: HL = Address of filename. + ; D = File number. + ; +PRTDIR: PUSH BC + PUSH DE + PUSH HL + ; + LD A,(SCRNMODE) + CP 0 + LD H,46 + JR Z,PRTDIR0 + LD H,92 +PRTDIR0: LD A,(TMPLINECNT) ; Pause if we fill the screen. + LD E,A + INC E + CP H + JR NZ,PRTNOWAIT + LD E, 0 +PRTDIRWAIT: CALL ?KEY + JR Z,PRTDIRWAIT +PRTNOWAIT: LD A,E + LD (TMPLINECNT),A + ; + LD A, D ; Print out file number and increment. + CALL PRTHX + LD A, '.' + CALL PRNT + POP DE + PUSH DE ; Get pointer to the file name and print. + RST 018h + ; + LD HL, (DSPXY) + ; + LD A,L + CP 20 + LD A,20 + JR C, PRTDIR2 + ; + LD A,(SCRNMODE) ; 40 Char mode? 2 columns of filenames displayed so NL. + CP 0 + JR Z,PRTDIR1 + ; + LD A,L ; 80 Char mode we print 4 columns of filenames. + CP 40 + LD A,40 + JR C, PRTDIR2 + ; + LD A,L + CP 60 + LD A,60 + JR C, PRTDIR2 + ; +PRTDIR1: CALL NL + JR PRTDIR3 +PRTDIR2: LD L,A + LD (DSPXY),HL +PRTDIR3: POP HL + POP DE + POP BC + RET + + + ; Method to get an SD Directory entry. + ; The SD Card works in 512byte sectors so a sector is cached and each call evaluates if the required request is in cache, if it is not, a new sector + ; is read. + ; + ; Input: E = Directory entry number to retrieve. + ; Output: HL = Address of directory entry. + ; A = 0, no errors, A > 1 error. +GETSDDIRENT:PUSH BC + PUSH DE; + ; + LD A,E + SRL A + SRL A + SRL A + SRL A ; Divide by 16 to get sector number. + LD C,A + LD A,(DIRSECBUF) ; Do we have this sector in the buffer? If we do, use it. + CP C + JR Z,GETDIRSD0 + LD A,C + LD (DIRSECBUF),A ; Save the sector number we will load into the buffer. + ; + LD HL,SECTORBUF + LD (SDLOADADDR),HL + LD HL,0 + LD (SDSTARTSEC),HL + LD (SDOFFSET),HL + LD B,0 + LD (SDSTARTSEC+2),BC + LD HL,SD_SECSIZE + LD (SDLOADSIZE),HL + LD (SDBYTECNT),HL + ; + DI + CALL SD_READ ; Read the sector. + EI + ; + OR A + JR NZ,DIRSDERR +GETDIRSD0: POP DE + PUSH DE + LD A,E ; Retrieve the directory entry number required. + AND 00FH + LD HL,SECTORBUF + JR Z,GETDIRSD2 + LD B,A + LD DE,SDDIR_ENTSZ ; Directory entry size +GETDIRSD1: ADD HL,DE ; Directory entry address into HL. + DJNZ GETDIRSD1 +GETDIRSD2: POP DE + POP BC + LD A,0 +GETDIRSD3: OR A + RET + ; +DIRSDERR: EX DE,HL ; Print error message, show HL as it contains sector number where error occurred. + LD DE,MSGSDRERR + RST 018H + CALL PRTHL + CALL NL + POP DE + POP BC + LD A,1 + JR GETDIRSD3 + + + + ; Method to list the directory of the SD Card. + ; + ; This method creates a unique sequenced number starting at 0 and attaches to each successive valid directory entry + ; The file number and file name are then printed out in tabular format. The file number can be used in Load/Save commands + ; instead of the filename. + ; + ; No inputs or outputs. + ; +DIRSDCARD: LD A,1 ; Setup screen for printing, account for the title line. TMPLINECNT is used for page pause. + LD (TMPLINECNT),A + LD A,0FFH + LD (DIRSECBUF),A ; Reset the sector buffer in memory indicator. + ; + LD DE,MSGCDIRLST ; Print out header. + RST 018h + CALL NL + ; +DIRSD0: LD E,0 ; Directory entry number + LD D,0 ; Directory file number (incr when a valid dirent is found). + LD B,0 +DIRSD1: CALL GETSDDIRENT ; Get SD Directory entry details for directory entry number stored in D. + RET NZ +DIRSD2: LD A,(HL) + INC HL + INC HL ; Hop over flags. + BIT 7,A ; Is this entry active, ie. Bit 7 of lower flag = 1? + JR Z,DIRSD3 + CALL PRTDIR ; Valid entry so print directory number and name pointed to by HL. + INC D +DIRSD3: INC E ; Onto next directory entry number. + DJNZ DIRSD1 + + LD DE,MSGSDRERR + RST 018H + CALL NL + + RET + ; + + ; Load a program from the SD Card into RAM and/or execute it - Part 2. + ; + ; DE contains start position of given filename. If TMPCNT contains a non 0FFFFH number then + ; DE points to a file number which will be used for matching. + ; +LOADSDE: PUSH DE + LD A,0FFH + LD (DIRSECBUF),A ; Reset the sector buffer in memory indicator. + LD E,0 ; Directory entry number start + LD D,0 ; Directory file number (incr when a valid dirent is found). + LD B,0 +LOADSD1: CALL GETSDDIRENT ; Get SD Directory entry details for directory entry number stored in D. +LOADSD2: LD A,(HL) + INC HL + INC HL ; Hop over flags. + BIT 7,A ; Is this entry active, ie. Bit 7 of lower flag = 1? + JR Z,LOADSD3 + PUSH HL + LD HL,(TMPCNT) + LD H,(HL) + LD A,H + CP 0FFH + LD A,L + POP HL + JR Z,LOADSD4 ; A filenumber wasnt given so will need to name match. + CP D ; Match on filenumber, does the given number match with the current? + JR Z,LOADSD9 + INC D +LOADSD3: INC E + DJNZ LOADSD1 + POP DE + LD A,1 + JP LOADSDX1 ; We didnt find a match so exit with code 1. + +LOADSD4: POP DE ; Get back pointer to given filename. HL contains directory filename. + PUSH DE + PUSH BC ; Save BC as we need it for comparison. + LD B,SDDIR_FNSZ +LOADSD5: LD A,(HL) + LD (DE),A + CP 00Dh ; If we find a terminator then this indicates potentially a valid name. + JR Z, LOADSD7 + CP 020h ; >= Space + JR C, LOADSD8 + CP 05Dh ; =< ] + JR C, LOADSD6 + CP 091h + JR C, LOADSD8 ; DEL or > 0x7F, cant be a valid filename so this is not an MZF header. +LOADSD6: INC DE + INC HL + DJNZ LOADSD5 + JR LOADSD8 ; No end of string terminator, this cant be a valid filename. +LOADSD7: LD A,B + CP SDDIR_FNSZ + JR NZ,LOADSD9 ; If the filename has no length it cant be valid, so loop. +LOADSD8: POP BC ; No match on filename so go back for next directory entry. + POP DE + JR LOADSD3 + + ; We have found the directory entry, so use it to load the program into memory. + ; HL points to end of filename so requires an update to point to start of the directory entry. +LOADSD9: POP DE ; No longer need buffer pointer so waste. + + ; Copy all relevant information into the CMT header (for reference) and working variables. + ; + LD A,L + AND 0E0H + INC A + LD L,A + LD A,(HL) + LD (ATRB),A ; Type of file, store in the tape header memory. + INC L + LD DE,NAME + LD BC,SDDIR_FNSZ + LDIR ; Copy the filename into the CMT area. + LD D,(HL) + INC HL + LD E,(HL) ; Start sector. + INC HL + LD (COMNT),DE + LD (SDSTARTSEC+2),DE + LD E,(HL) + INC HL + LD D,(HL) ; Size of file. + INC HL + LD (SIZE),DE + LD (SDLOADSIZE),DE + LD E,(HL) + INC HL + LD D,(HL) ; Load address. + INC HL + LD A,D + CP 001H + JR NC,LOADSD10 + LD DE,01200H ; If the file specifies a load address below 1000H then shift to 1200H as it is not valid. +LOADSD10: LD (DTADR),DE + LD (SDLOADADDR),DE + LD E,(HL) + INC HL + LD D,(HL) ; Execution address, store in tape header memory. + LD (EXADR),DE + LD DE,0 + LD (SDSTARTSEC),DE + LD (SDOFFSET),DE + ; + LD DE,MSGSDLOAD + RST 018H + LD DE,NAME + RST 018H + CALL NL + ; +LOADSD11: LD A,(SDLOADSIZE+1) + CP 002H + LD HL,SD_SECSIZE ; A full sector read if remaining bytes >=512 + JR NC,LOADSD12 + LD HL,(SDLOADSIZE) ; Get remaining bytes size. +LOADSD12: LD (SDBYTECNT),HL + DI + CALL SD_READ ; Read the sector. + EI + OR A + JR NZ,LOADSDERR ; Failure to read a sector, abandon with error message. + ; + LD HL,SDSTARTSEC+3 + INC (HL) + JR NZ,LOADSD12A + DEC HL + INC (HL) +LOADSD12A: LD A,(SDLOADSIZE+1) + CP 002H + JR C,LOADSD14 ; If carry then the last read obtained the remaining bytes. + LD HL,(SDLOADSIZE) + LD DE,SD_SECSIZE + OR A + SBC HL,DE +LOADSD13: LD (SDLOADSIZE),HL + JR LOADSD11 + +LOADSD14: LD A,(SDAUTOEXEC) ; Autoexecute turned off? + CP 0FFh + JP Z,LOADSD15 ; Go back to monitor if it has been, else execute. + LD A,(ATRB) + CP 1 + JR NZ,LOADSD17 + LD HL,(EXADR) + JP (HL) ; Execution address. +LOADSD15: LD DE,MSGEXECADDR ; Indicate where the program was loaded and the execution address. +LOADSD16: RST 018H + LD HL,(EXADR) + CALL PRTHL + LD DE,MSGLOADADDR + RST 018H + LD HL,(DTADR) + CALL PRTHL + CALL NL + JR LOADSDX +LOADSD17: LD DE,MSGNOTBIN + JR LOADSD16 +LOADSDX: LD A,0 ; Non error exit. +LOADSDX1: RET + +LOADSDERR: LD DE,MSGSDRERR + RST 018H + LD HL,(TMPCNT) + CALL PRTHL + CALL NL + LD A,2 + JR LOADSDX1 + + +MSGCDIRLST: DB "SDCARD DIRECTORY:", 00DH +MSGSDRERR: DB "SDCARD READ ERROR, SECTOR:", 00DH +MSGLOADADDR:DB ", LOAD ADDR:", 00DH +MSGEXECADDR:DB "EXEC ADDR:", 00DH +MSGNOTBIN: DB "NOT BINARY", 00DH +MSGSDLOAD: DB "LOADING ", 00DH + + ALIGN 0EFFFh + DB 0FFh diff --git a/software/asm/rfs_bank3.asm b/software/asm/rfs_bank3.asm index f1bb819..63c0087 100644 --- a/software/asm/rfs_bank3.asm +++ b/software/asm/rfs_bank3.asm @@ -27,414 +27,480 @@ ;- along with this program. If not, see . ;-------------------------------------------------------------------------------------------------------- -ROW EQU 25 -COLW EQU 40 -SCRNSZ EQU COLW * ROW -MODE80C EQU 0 +ROW EQU 25 +COLW EQU 40 +SCRNSZ EQU COLW * ROW +MODE80C EQU 0 - ;====================================== - ; - ; USER ROM BANK 3 - ; - ;====================================== - ORG 0E800h + ;====================================== + ; + ; USER ROM BANK 3 + ; + ;====================================== + ORG 0E800h - ;-------------------------------- - ; Common code spanning all banks. - ;-------------------------------- -ROMFS3: NOP - XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 - LD (RFSBK1),A - LD (RFSBK2),A ; and start up - ie. SA1510 Monitor. - ALIGN_NOPS 0E829H + ;-------------------------------- + ; Common code spanning all banks. + ;-------------------------------- +ROMFS3: NOP + XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 + LD (RFSBK1),A + LD (RFSBK2),A ; and start up - ie. SA1510 Monitor. + ALIGN_NOPS 0E829H - ; - ; Bank switching code, allows a call to code in another bank. - ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. - ; -BKSW3to0: PUSH AF - LD A, ROMBANK3 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK0 ; Required bank to call. - JR BKSW3_0 -BKSW3to1: PUSH AF - LD A, ROMBANK3 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK1 ; Required bank to call. - JR BKSW3_0 -BKSW3to2: PUSH AF - LD A, ROMBANK3 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK2 ; Required bank to call. - JR BKSW3_0 -BKSW3to3: PUSH AF - LD A, ROMBANK3 ; Calling bank (ie. us). - PUSH AF - LD A, ROMBANK3 ; Required bank to call. - ; -BKSW3_0: PUSH BC ; Save BC for caller. - LD BC, BKSWRET3 ; Place bank switchers return address on stack. - PUSH BC - LD (RFSBK2), A ; Bank switch in user rom space, A=bank. - LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. - JP (HL) ; Jump to required function. -BKSWRET3: POP BC - POP AF ; Get bank which called us. - LD (RFSBK2), A ; Return to that bank. - POP AF - RET ; Return to caller. + ; + ; Bank switching code, allows a call to code in another bank. + ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. + ; +BKSW3to0: PUSH AF + LD A, ROMBANK3 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK0 ; Required bank to call. + JR BKSW3_0 +BKSW3to1: PUSH AF + LD A, ROMBANK3 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK1 ; Required bank to call. + JR BKSW3_0 +BKSW3to2: PUSH AF + LD A, ROMBANK3 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK2 ; Required bank to call. + JR BKSW3_0 +BKSW3to3: PUSH AF + LD A, ROMBANK3 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK3 ; Required bank to call. + JR BKSW3_0 +BKSW3to4: PUSH AF + LD A, ROMBANK3 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK4 ; Required bank to call. + JR BKSW3_0 +BKSW3to5: PUSH AF + LD A, ROMBANK3 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK5 ; Required bank to call. + JR BKSW3_0 +BKSW3to6: PUSH AF + LD A, ROMBANK3 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK6 ; Required bank to call. + JR BKSW3_0 +BKSW3to7: PUSH AF + LD A, ROMBANK3 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK7 ; Required bank to call. + ; +BKSW3_0: PUSH BC ; Save BC for caller. + LD BC, BKSWRET3 ; Place bank switchers return address on stack. + PUSH BC + LD (RFSBK2), A ; Bank switch in user rom space, A=bank. + LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. + JP (HL) ; Jump to required function. +BKSWRET3: POP BC + POP AF ; Get bank which called us. + LD (RFSBK2), A ; Return to that bank. + POP AF + RET ; Return to caller. -MEMTEST: LD B,240 ; Number of loops -LOOP: LD HL,MEMSTART ; Start of checked memory, - LD D,0CFh ; End memory check CF00 -LOOP1: LD A,000h - CP L - JR NZ,LOOP1b - CALL PRTHL ; Print HL as 4digit hex. - LD A,0C4h ; Move cursor left. - LD E,004h ; 4 times. -LOOP1a: CALL DPCT - DEC E - JR NZ,LOOP1a -LOOP1b: INC HL - LD A,H - CP D ; Have we reached end of memory. - JR Z,LOOP3 ; Yes, exit. - LD A,(HL) ; Read memory location under test, ie. 0. - CPL ; Subtract, ie. FF - A, ie FF - 0 = FF. - LD (HL),A ; Write it back, ie. FF. - SUB (HL) ; Subtract written memory value from A, ie. should be 0. - JR NZ,LOOP2 ; Not zero, we have an error. - LD A,(HL) ; Reread memory location, ie. FF - CPL ; Subtract FF - FF - LD (HL),A ; Write 0 - SUB (HL) ; Subtract 0 - JR Z,LOOP1 ; Loop if the same, ie. 0 -LOOP2: LD A,16h - CALL PRNT ; Print A - CALL PRTHX ; Print HL as 4 digit hex. - CALL PRNTS ; Print space. - XOR A - LD (HL),A - LD A,(HL) ; Get into A the failing bits. - CALL PRTHX ; Print A as 2 digit hex. - CALL PRNTS ; Print space. - LD A,0FFh ; Repeat but first load FF into memory - LD (HL),A - LD A,(HL) - CALL PRTHX ; Print A as 2 digit hex. - NOP - JR LOOP4 +MEMTEST: LD B,240 ; Number of loops +LOOP: LD HL,MEMSTART ; Start of checked memory, + LD D,0CFh ; End memory check CF00 +LOOP1: LD A,000h + CP L + JR NZ,LOOP1b + CALL PRTHL ; Print HL as 4digit hex. + LD A,0C4h ; Move cursor left. + LD E,004h ; 4 times. +LOOP1a: CALL DPCT + DEC E + JR NZ,LOOP1a +LOOP1b: INC HL + LD A,H + CP D ; Have we reached end of memory. + JR Z,LOOP3 ; Yes, exit. + LD A,(HL) ; Read memory location under test, ie. 0. + CPL ; Subtract, ie. FF - A, ie FF - 0 = FF. + LD (HL),A ; Write it back, ie. FF. + SUB (HL) ; Subtract written memory value from A, ie. should be 0. + JR NZ,LOOP2 ; Not zero, we have an error. + LD A,(HL) ; Reread memory location, ie. FF + CPL ; Subtract FF - FF + LD (HL),A ; Write 0 + SUB (HL) ; Subtract 0 + JR Z,LOOP1 ; Loop if the same, ie. 0 +LOOP2: LD A,16h + CALL PRNT ; Print A + CALL PRTHX ; Print HL as 4 digit hex. + CALL PRNTS ; Print space. + XOR A + LD (HL),A + LD A,(HL) ; Get into A the failing bits. + CALL PRTHX ; Print A as 2 digit hex. + CALL PRNTS ; Print space. + LD A,0FFh ; Repeat but first load FF into memory + LD (HL),A + LD A,(HL) + CALL PRTHX ; Print A as 2 digit hex. + NOP + JR LOOP4 -LOOP3: CALL PRTHL - LD DE,OKCHECK - CALL MSG ; Print check message in DE - LD A,B ; Print loop count. - CALL PRTHX - LD DE,OKMSG - CALL MSG ; Print ok message in DE - CALL NL - DEC B - JR NZ,LOOP - LD DE,DONEMSG - CALL MSG ; Print check message in DE - JP ST1X +LOOP3: CALL PRTHL + LD DE,OKCHECK + CALL MSG ; Print check message in DE + LD A,B ; Print loop count. + CALL PRTHX + LD DE,OKMSG + CALL MSG ; Print ok message in DE + CALL NL + DEC B + JR NZ,LOOP + LD DE,DONEMSG + CALL MSG ; Print check message in DE + JP ST1X -LOOP4: LD B,09h - CALL PRNTS ; Print space. - XOR A ; Zero A - SCF ; Set Carry -LOOP5: PUSH AF ; Store A and Flags - LD (HL),A ; Store 0 to bad location. - LD A,(HL) ; Read back - CALL PRTHX ; Print A as 2 digit hex. - CALL PRNTS ; Print space - POP AF ; Get back A (ie. 0 + C) - RLA ; Rotate left A. Bit LSB becomes Carry (ie. 1 first instance), Carry becomes MSB - DJNZ LOOP5 ; Loop if not zero, ie. print out all bit locations written and read to memory to locate bad bit. - XOR A ; Zero A, clears flags. - LD A,80h - LD B,08h -LOOP6: PUSH AF ; Repeat above but AND memory location with original A (ie. 80) - LD C,A ; Basically walk through all the bits to find which one is stuck. - LD (HL),A - LD A,(HL) - AND C - NOP - JR Z,LOOP8 ; If zero then print out the bit number - NOP - NOP - LD A,C - CPL - LD (HL),A - LD A,(HL) - AND C - JR NZ,LOOP8 ; As above, if the compliment doesnt yield zero, print out the bit number. -LOOP7: POP AF - RRCA - NOP - DJNZ LOOP6 - JP ST1X +LOOP4: LD B,09h + CALL PRNTS ; Print space. + XOR A ; Zero A + SCF ; Set Carry +LOOP5: PUSH AF ; Store A and Flags + LD (HL),A ; Store 0 to bad location. + LD A,(HL) ; Read back + CALL PRTHX ; Print A as 2 digit hex. + CALL PRNTS ; Print space + POP AF ; Get back A (ie. 0 + C) + RLA ; Rotate left A. Bit LSB becomes Carry (ie. 1 first instance), Carry becomes MSB + DJNZ LOOP5 ; Loop if not zero, ie. print out all bit locations written and read to memory to locate bad bit. + XOR A ; Zero A, clears flags. + LD A,80h + LD B,08h +LOOP6: PUSH AF ; Repeat above but AND memory location with original A (ie. 80) + LD C,A ; Basically walk through all the bits to find which one is stuck. + LD (HL),A + LD A,(HL) + AND C + NOP + JR Z,LOOP8 ; If zero then print out the bit number + NOP + NOP + LD A,C + CPL + LD (HL),A + LD A,(HL) + AND C + JR NZ,LOOP8 ; As above, if the compliment doesnt yield zero, print out the bit number. +LOOP7: POP AF + RRCA + NOP + DJNZ LOOP6 + JP ST1X -LOOP8: CALL LETNL ; New line. - LD DE,BITMSG ; BIT message - CALL MSG ; Print message in DE - LD A,B - DEC A - CALL PRTHX ; Print A as 2 digit hex, ie. BIT number. - CALL LETNL ; New line - LD DE,BANKMSG ; BANK message - CALL MSG ; Print message in DE - LD A,H - CP 50h ; 'P' - JR NC,LOOP9 ; Work out bank number, 1, 2 or 3. - LD A,01h - JR LOOP11 +LOOP8: CALL LETNL ; New line. + LD DE,BITMSG ; BIT message + CALL MSG ; Print message in DE + LD A,B + DEC A + CALL PRTHX ; Print A as 2 digit hex, ie. BIT number. + CALL LETNL ; New line + LD DE,BANKMSG ; BANK message + CALL MSG ; Print message in DE + LD A,H + CP 50h ; 'P' + JR NC,LOOP9 ; Work out bank number, 1, 2 or 3. + LD A,01h + JR LOOP11 -LOOP9: CP 90h - JR NC,LOOP10 - LD A,02h - JR LOOP11 +LOOP9: CP 90h + JR NC,LOOP10 + LD A,02h + JR LOOP11 -LOOP10: LD A,03h -LOOP11: CALL PRTHX ; Print A as 2 digit hex, ie. BANK number. - JR LOOP7 +LOOP10: LD A,03h +LOOP11: CALL PRTHX ; Print A as 2 digit hex, ie. BANK number. + JR LOOP7 -DLY1S: PUSH AF - PUSH BC - LD C,10 -L0324: CALL DLY12 - DEC C - JR NZ,L0324 - POP BC - POP AF - RET +DLY1S: PUSH AF + PUSH BC + LD C,10 +L0324: CALL DLY12 + DEC C + JR NZ,L0324 + POP BC + POP AF + RET - ; Test the 8253 Timer, configure it as per the monitor and display the read back values. -TIMERTST: CALL NL - LD DE,MSG_TIMERTST - CALL MSG - CALL NL - LD DE,MSG_TIMERVAL - CALL MSG - LD A,01h - LD DE,8000h - CALL TIMERTST1 -NDE: JP NDE - JP ST1X -TIMERTST1: DI - PUSH BC - PUSH DE - PUSH HL - LD (AMPM),A - LD A,0F0H - LD (TIMFG),A -ABCD: LD HL,0A8C0H - XOR A - SBC HL,DE - PUSH HL - INC HL - EX DE,HL + ; Test the 8253 Timer, configure it as per the monitor and display the read back values. +TIMERTST: CALL NL + LD DE,MSG_TIMERTST + CALL MSG + CALL NL + LD DE,MSG_TIMERVAL + CALL MSG + LD A,01h + LD DE,8000h + CALL TIMERTST1 +NDE: JP NDE + JP ST1X +TIMERTST1: DI + PUSH BC + PUSH DE + PUSH HL + LD (AMPM),A + LD A,0F0H + LD (TIMFG),A +ABCD: LD HL,0A8C0H + XOR A + SBC HL,DE + PUSH HL + INC HL + EX DE,HL - LD HL,CONTF ; Control Register - LD (HL),0B0H ; 10110000 Control Counter 2 10, Write 2 bytes 11, 000 Interrupt on Terminal Count, 0 16 bit binary - LD (HL),074H ; 01110100 Control Counter 1 01, Write 2 bytes 11, 010 Rate Generator, 0 16 bit binary - LD (HL),030H ; 00110100 Control Counter 1 01, Write 2 bytes 11, 010 interrupt on Terminal Count, 0 16 bit binary + LD HL,CONTF ; Control Register + LD (HL),0B0H ; 10110000 Control Counter 2 10, Write 2 bytes 11, 000 Interrupt on Terminal Count, 0 16 bit binary + LD (HL),074H ; 01110100 Control Counter 1 01, Write 2 bytes 11, 010 Rate Generator, 0 16 bit binary + LD (HL),030H ; 00110100 Control Counter 1 01, Write 2 bytes 11, 010 interrupt on Terminal Count, 0 16 bit binary - LD HL,CONT2 ; Counter 2 - LD (HL),E - LD (HL),D + LD HL,CONT2 ; Counter 2 + LD (HL),E + LD (HL),D - LD HL,CONT1 ; Counter 1 - LD (HL),00AH - LD (HL),000H + LD HL,CONT1 ; Counter 1 + LD (HL),00AH + LD (HL),000H - LD HL,CONT0 ; Counter 0 - LD (HL),00CH - LD (HL),0C0H + LD HL,CONT0 ; Counter 0 + LD (HL),00CH + LD (HL),0C0H -; LD HL,CONT2 ; Counter 2 -; LD C,(HL) -; LD A,(HL) -; CP D -; JP NZ,L0323H -; LD A,C -; CP E -; JP Z,CDEF - ; +; LD HL,CONT2 ; Counter 2 +; LD C,(HL) +; LD A,(HL) +; CP D +; JP NZ,L0323H +; LD A,C +; CP E +; JP Z,CDEF + ; -L0323H: PUSH AF - PUSH BC - PUSH DE - PUSH HL - ; - LD HL,CONTF ; Control Register - LD (HL),080H - LD HL,CONT2 ; Counter 2 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL PRNTS - ;CALL DLY1S - ; - LD HL,CONTF ; Control Register - LD (HL),040H - LD HL,CONT1 ; Counter 1 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL PRNTS - ;CALL DLY1S - ; - LD HL,CONTF ; Control Register - LD (HL),000H - LD HL,CONT0 ; Counter 0 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - ;CALL DLY1S - ; - LD A,0C4h ; Move cursor left. - LD E,0Eh ; 4 times. -L0330: CALL DPCT - DEC E - JR NZ,L0330 - ; -; LD C,20 -;L0324: CALL DLY12 -; DEC C -; JR NZ,L0324 - ; - POP HL - POP DE - POP BC - POP AF - ; - LD HL,CONT2 ; Counter 2 - LD C,(HL) - LD A,(HL) - CP D - JP NZ,L0323H - LD A,C - CP E - JP NZ,L0323H - ; - ; - PUSH AF - PUSH BC - PUSH DE - PUSH HL - CALL NL - CALL NL - CALL NL - LD DE,MSG_TIMERVAL2 - CALL MSG - POP HL - POP DE - POP BC - POP AF +L0323H: PUSH AF + PUSH BC + PUSH DE + PUSH HL + ; + LD HL,CONTF ; Control Register + LD (HL),080H + LD HL,CONT2 ; Counter 2 + LD C,(HL) + LD A,(HL) + CALL PRTHX + LD A,C + CALL PRTHX + ; + CALL PRNTS + ;CALL DLY1S + ; + LD HL,CONTF ; Control Register + LD (HL),040H + LD HL,CONT1 ; Counter 1 + LD C,(HL) + LD A,(HL) + CALL PRTHX + LD A,C + CALL PRTHX + ; + CALL PRNTS + ;CALL DLY1S + ; + LD HL,CONTF ; Control Register + LD (HL),000H + LD HL,CONT0 ; Counter 0 + LD C,(HL) + LD A,(HL) + CALL PRTHX + LD A,C + CALL PRTHX + ; + ;CALL DLY1S + ; + LD A,0C4h ; Move cursor left. + LD E,0Eh ; 4 times. +L0330: CALL DPCT + DEC E + JR NZ,L0330 + ; +; LD C,20 +;L0324: CALL DLY12 +; DEC C +; JR NZ,L0324 + ; + POP HL + POP DE + POP BC + POP AF + ; + LD HL,CONT2 ; Counter 2 + LD C,(HL) + LD A,(HL) + CP D + JP NZ,L0323H + LD A,C + CP E + JP NZ,L0323H + ; + ; + PUSH AF + PUSH BC + PUSH DE + PUSH HL + CALL NL + CALL NL + CALL NL + LD DE,MSG_TIMERVAL2 + CALL MSG + POP HL + POP DE + POP BC + POP AF - ; -CDEF: POP DE - LD HL,CONT1 - LD (HL),00CH - LD (HL),07BH - INC HL + ; +CDEF: POP DE + LD HL,CONT1 + LD (HL),00CH + LD (HL),07BH + INC HL -L0336H: PUSH AF - PUSH BC - PUSH DE - PUSH HL - ; - LD HL,CONTF ; Control Register - LD (HL),080H - LD HL,CONT2 ; Counter 2 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL PRNTS - CALL DLY1S - ; - LD HL,CONTF ; Control Register - LD (HL),040H - LD HL,CONT1 ; Counter 1 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL PRNTS - CALL DLY1S - ; - LD HL,CONTF ; Control Register - LD (HL),000H - LD HL,CONT0 ; Counter 0 - LD C,(HL) - LD A,(HL) - CALL PRTHX - LD A,C - CALL PRTHX - ; - CALL DLY1S - ; - LD A,0C4h ; Move cursor left. - LD E,0Eh ; 4 times. -L0340: CALL DPCT - DEC E - JR NZ,L0340 - ; - POP HL - POP DE - POP BC - POP AF +L0336H: PUSH AF + PUSH BC + PUSH DE + PUSH HL + ; + LD HL,CONTF ; Control Register + LD (HL),080H + LD HL,CONT2 ; Counter 2 + LD C,(HL) + LD A,(HL) + CALL PRTHX + LD A,C + CALL PRTHX + ; + CALL PRNTS + CALL DLY1S + ; + LD HL,CONTF ; Control Register + LD (HL),040H + LD HL,CONT1 ; Counter 1 + LD C,(HL) + LD A,(HL) + CALL PRTHX + LD A,C + CALL PRTHX + ; + CALL PRNTS + CALL DLY1S + ; + LD HL,CONTF ; Control Register + LD (HL),000H + LD HL,CONT0 ; Counter 0 + LD C,(HL) + LD A,(HL) + CALL PRTHX + LD A,C + CALL PRTHX + ; + CALL DLY1S + ; + LD A,0C4h ; Move cursor left. + LD E,0Eh ; 4 times. +L0340: CALL DPCT + DEC E + JR NZ,L0340 + ; + POP HL + POP DE + POP BC + POP AF - LD HL,CONT2 ; Counter 2 - LD C,(HL) - LD A,(HL) - CP D - JR NZ,L0336H - LD A,C - CP E - JR NZ,L0336H - CALL NL - LD DE,MSG_TIMERVAL3 - CALL MSG - POP HL - POP DE - POP BC - EI - RET + LD HL,CONT2 ; Counter 2 + LD C,(HL) + LD A,(HL) + CP D + JR NZ,L0336H + LD A,C + CP E + JR NZ,L0336H + CALL NL + LD DE,MSG_TIMERVAL3 + CALL MSG + POP HL + POP DE + POP BC + EI + RET -OKCHECK: DB ", CHECK: ", 0Dh -OKMSG: DB " OK.", 0Dh -DONEMSG: DB 11h - DB "RAM TEST COMPLETE.", 0Dh + ; Simple help screen to display commands. +HELP: CALL NL + LD DE, HELPSCR + CALL PRTSTR + RET + + ; Modification of original MSG function, use NULL terminated strings not CR terminated. +PRTSTR: PUSH AF + PUSH BC + PUSH DE +PRTSTR1: LD A,(DE) + CP 000H + JR Z,PRTSTRE + CALL PRNT + INC DE + JR PRTSTR1 +PRTSTRE: POP DE + POP BC + POP AF + RET + + ; Help text. Use of lower case, due to Sharp's non standard character set, is not easy, you have to manually code each byte + ; hence using upper case. +HELPSCR: DB "4 - 40 COL MODE.", 00DH + DB "8 - 80 COL MODE.", 00DH + DB "B - TOGGLE KEYBOARD BELL.", 00DH + DB "C - CLEAR MEMORY $1200-$D000.", 00DH + DB "DXXXX[YYYY] - DUMP MEM XXXX TO YYYY.", 00DH + DB "F[X] - BOOT FD DRIVE X.", 00DH + DB 0AAH," - BOOT FD ORIGINAL ROM.", 00DH + DB "H - THIS HELP SCREEN.", 00DH + DB "IR/IC - RFS DIR LISTING ROM/CARD.", 00DH + DB "JXXXX - JUMP TO LOCATION XXXX.", 00DH + DB "LT[FN]- LOAD TAPE, FN=FILENAME", 00DH + DB "LR[FN]- LOAD ROM, FN=NO OR NAME", 00DH + DB "LC[FN]- LOAD SDCARD, FN=NO OR NAME", 00DH + DB " - ADD NX TO LOAD CMD FOR NO EXEC.", 00DH + DB "MXXXX - EDIT MEMORY STARTING AT XXXX.", 00DH + DB "P - TEST PRINTER.", 00DH + DB "R - TEST DRAM MEMORY.", 00DH + DB "S - SAVE CURRENT PROG TO TAPE.", 00DH + DB "T - TEST TIMER.", 00DH + DB "V - VERIFY TAPE SAVE.", 00DH + DB 000H + + +OKCHECK: DB ", CHECK: ", 0Dh +OKMSG: DB " OK.", 0Dh +DONEMSG: DB 11h + DB "RAM TEST COMPLETE.", 0Dh -BITMSG: DB " BIT: ", 0Dh -BANKMSG: DB " BANK: ", 0Dh +BITMSG: DB " BIT: ", 0Dh +BANKMSG: DB " BANK: ", 0Dh MSG_TIMERTST: - DB "8253 TIMER TEST", 0Dh, 00h + DB "8253 TIMER TEST", 0Dh, 00h MSG_TIMERVAL: - DB "READ VALUE 1: ", 0Dh, 00h + DB "READ VALUE 1: ", 0Dh, 00h MSG_TIMERVAL2: - DB "READ VALUE 2: ", 0Dh, 00h + DB "READ VALUE 2: ", 0Dh, 00h MSG_TIMERVAL3: - DB "READ DONE.", 0Dh, 00h + DB "READ DONE.", 0Dh, 00h - ALIGN 0EFFFh - DB 0FFh + ALIGN 0EFFFh + DB 0FFh diff --git a/software/asm/rfs_bank4.asm b/software/asm/rfs_bank4.asm new file mode 100644 index 0000000..037d63b --- /dev/null +++ b/software/asm/rfs_bank4.asm @@ -0,0 +1,106 @@ +;-------------------------------------------------------------------------------------------------------- +;- +;- Name: rfs_bank4.asm +;- Created: October 2018 +;- Author(s): Philip Smart +;- Description: Sharp MZ series Rom Filing System. +;- This assembly language program is written to utilise the banked flashroms added with +;- the MZ-80A RFS hardware upgrade. +;- +;- Credits: +;- Copyright: (c) 2018-20 Philip Smart +;- +;- History: October 2018 - Merged 2 utilities to create this compilation. +;- +;-------------------------------------------------------------------------------------------------------- +;- This source file is free software: you can redistribute it and-or modify +;- it under the terms of the GNU General Public License as published +;- by the Free Software Foundation, either version 3 of the License, or +;- (at your option) any later version. +;- +;- This source file is distributed in the hope that it will be useful, +;- but WITHOUT ANY WARRANTY; without even the implied warranty of +;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;- GNU General Public License for more details. +;- +;- You should have received a copy of the GNU General Public License +;- along with this program. If not, see . +;-------------------------------------------------------------------------------------------------------- + + + ;====================================== + ; + ; USER ROM BANK 4 + ; + ;====================================== + ORG 0E800h + + ;-------------------------------- + ; Common code spanning all banks. + ;-------------------------------- +ROMFS4: NOP + XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 + LD (RFSBK1),A + LD (RFSBK2),A ; and start up - ie. SA1510 Monitor. + ALIGN_NOPS 0E829H + + ; + ; Bank switching code, allows a call to code in another bank. + ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. + ; +BKSW4to0: PUSH AF + LD A, ROMBANK4 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK0 ; Required bank to call. + JR BKSW4_0 +BKSW4to1: PUSH AF + LD A, ROMBANK4 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK1 ; Required bank to call. + JR BKSW4_0 +BKSW4to2: PUSH AF + LD A, ROMBANK4 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK2 ; Required bank to call. + JR BKSW4_0 +BKSW4to3: PUSH AF + LD A, ROMBANK4 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK3 ; Required bank to call. + JR BKSW4_0 +BKSW4to4: PUSH AF + LD A, ROMBANK4 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK4 ; Required bank to call. + JR BKSW4_0 +BKSW4to5: PUSH AF + LD A, ROMBANK4 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK5 ; Required bank to call. + JR BKSW4_0 +BKSW4to6: PUSH AF + LD A, ROMBANK4 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK6 ; Required bank to call. + JR BKSW4_0 +BKSW4to7: PUSH AF + LD A, ROMBANK4 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK7 ; Required bank to call. + ; +BKSW4_0: PUSH BC ; Save BC for caller. + LD BC, BKSWRET4 ; Place bank switchers return address on stack. + PUSH BC + LD (RFSBK2), A ; Bank switch in user rom space, A=bank. + LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. + JP (HL) ; Jump to required function. +BKSWRET4: POP BC + POP AF ; Get bank which called us. + LD (RFSBK2), A ; Return to that bank. + POP AF + RET ; Return to caller. + + + + ALIGN 0EFFFh + DB 0FFh diff --git a/software/asm/rfs_bank5.asm b/software/asm/rfs_bank5.asm new file mode 100644 index 0000000..56476b9 --- /dev/null +++ b/software/asm/rfs_bank5.asm @@ -0,0 +1,106 @@ +;-------------------------------------------------------------------------------------------------------- +;- +;- Name: rfs_bank5.asm +;- Created: October 2018 +;- Author(s): Philip Smart +;- Description: Sharp MZ series Rom Filing System. +;- This assembly language program is written to utilise the banked flashroms added with +;- the MZ-80A RFS hardware upgrade. +;- +;- Credits: +;- Copyright: (c) 2018-20 Philip Smart +;- +;- History: October 2018 - Merged 2 utilities to create this compilation. +;- +;-------------------------------------------------------------------------------------------------------- +;- This source file is free software: you can redistribute it and-or modify +;- it under the terms of the GNU General Public License as published +;- by the Free Software Foundation, either version 3 of the License, or +;- (at your option) any later version. +;- +;- This source file is distributed in the hope that it will be useful, +;- but WITHOUT ANY WARRANTY; without even the implied warranty of +;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;- GNU General Public License for more details. +;- +;- You should have received a copy of the GNU General Public License +;- along with this program. If not, see . +;-------------------------------------------------------------------------------------------------------- + + + ;====================================== + ; + ; USER ROM BANK 5 + ; + ;====================================== + ORG 0E800h + + ;-------------------------------- + ; Common code spanning all banks. + ;-------------------------------- +ROMFS5: NOP + XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 + LD (RFSBK1),A + LD (RFSBK2),A ; and start up - ie. SA1510 Monitor. + ALIGN_NOPS 0E829H + + ; + ; Bank switching code, allows a call to code in another bank. + ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. + ; +BKSW5to0: PUSH AF + LD A, ROMBANK5 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK0 ; Required bank to call. + JR BKSW5_0 +BKSW5to1: PUSH AF + LD A, ROMBANK5 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK1 ; Required bank to call. + JR BKSW5_0 +BKSW5to2: PUSH AF + LD A, ROMBANK5 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK2 ; Required bank to call. + JR BKSW5_0 +BKSW5to3: PUSH AF + LD A, ROMBANK5 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK3 ; Required bank to call. + JR BKSW5_0 +BKSW5to4: PUSH AF + LD A, ROMBANK5 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK4 ; Required bank to call. + JR BKSW5_0 +BKSW5to5: PUSH AF + LD A, ROMBANK5 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK5 ; Required bank to call. + JR BKSW5_0 +BKSW5to6: PUSH AF + LD A, ROMBANK5 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK6 ; Required bank to call. + JR BKSW5_0 +BKSW5to7: PUSH AF + LD A, ROMBANK5 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK7 ; Required bank to call. + ; +BKSW5_0: PUSH BC ; Save BC for caller. + LD BC, BKSWRET5 ; Place bank switchers return address on stack. + PUSH BC + LD (RFSBK2), A ; Bank switch in user rom space, A=bank. + LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. + JP (HL) ; Jump to required function. +BKSWRET5: POP BC + POP AF ; Get bank which called us. + LD (RFSBK2), A ; Return to that bank. + POP AF + RET ; Return to caller. + + + + ALIGN 0EFFFh + DB 0FFh diff --git a/software/asm/rfs_bank6.asm b/software/asm/rfs_bank6.asm new file mode 100644 index 0000000..52ebbf3 --- /dev/null +++ b/software/asm/rfs_bank6.asm @@ -0,0 +1,106 @@ +;-------------------------------------------------------------------------------------------------------- +;- +;- Name: rfs_bank6.asm +;- Created: October 2018 +;- Author(s): Philip Smart +;- Description: Sharp MZ series Rom Filing System. +;- This assembly language program is written to utilise the banked flashroms added with +;- the MZ-80A RFS hardware upgrade. +;- +;- Credits: +;- Copyright: (c) 2018-20 Philip Smart +;- +;- History: October 2018 - Merged 2 utilities to create this compilation. +;- +;-------------------------------------------------------------------------------------------------------- +;- This source file is free software: you can redistribute it and-or modify +;- it under the terms of the GNU General Public License as published +;- by the Free Software Foundation, either version 3 of the License, or +;- (at your option) any later version. +;- +;- This source file is distributed in the hope that it will be useful, +;- but WITHOUT ANY WARRANTY; without even the implied warranty of +;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;- GNU General Public License for more details. +;- +;- You should have received a copy of the GNU General Public License +;- along with this program. If not, see . +;-------------------------------------------------------------------------------------------------------- + + + ;====================================== + ; + ; USER ROM BANK 6 + ; + ;====================================== + ORG 0E800h + + ;-------------------------------- + ; Common code spanning all banks. + ;-------------------------------- +ROMFS6: NOP + XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 + LD (RFSBK1),A + LD (RFSBK2),A ; and start up - ie. SA1510 Monitor. + ALIGN_NOPS 0E829H + + ; + ; Bank switching code, allows a call to code in another bank. + ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. + ; +BKSW6to0: PUSH AF + LD A, ROMBANK6 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK0 ; Required bank to call. + JR BKSW6_0 +BKSW6to1: PUSH AF + LD A, ROMBANK6 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK1 ; Required bank to call. + JR BKSW6_0 +BKSW6to2: PUSH AF + LD A, ROMBANK6 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK2 ; Required bank to call. + JR BKSW6_0 +BKSW6to3: PUSH AF + LD A, ROMBANK6 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK3 ; Required bank to call. + JR BKSW6_0 +BKSW6to4: PUSH AF + LD A, ROMBANK6 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK4 ; Required bank to call. + JR BKSW6_0 +BKSW6to5: PUSH AF + LD A, ROMBANK6 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK5 ; Required bank to call. + JR BKSW6_0 +BKSW6to6: PUSH AF + LD A, ROMBANK6 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK6 ; Required bank to call. + JR BKSW6_0 +BKSW6to7: PUSH AF + LD A, ROMBANK6 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK7 ; Required bank to call. + ; +BKSW6_0: PUSH BC ; Save BC for caller. + LD BC, BKSWRET6 ; Place bank switchers return address on stack. + PUSH BC + LD (RFSBK2), A ; Bank switch in user rom space, A=bank. + LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. + JP (HL) ; Jump to required function. +BKSWRET6: POP BC + POP AF ; Get bank which called us. + LD (RFSBK2), A ; Return to that bank. + POP AF + RET ; Return to caller. + + + + ALIGN 0EFFFh + DB 0FFh diff --git a/software/asm/rfs_bank7.asm b/software/asm/rfs_bank7.asm new file mode 100644 index 0000000..02a3eab --- /dev/null +++ b/software/asm/rfs_bank7.asm @@ -0,0 +1,106 @@ +;-------------------------------------------------------------------------------------------------------- +;- +;- Name: rfs_bank4.asm +;- Created: October 2018 +;- Author(s): Philip Smart +;- Description: Sharp MZ series Rom Filing System. +;- This assembly language program is written to utilise the banked flashroms added with +;- the MZ-80A RFS hardware upgrade. +;- +;- Credits: +;- Copyright: (c) 2018-20 Philip Smart +;- +;- History: October 2018 - Merged 2 utilities to create this compilation. +;- +;-------------------------------------------------------------------------------------------------------- +;- This source file is free software: you can redistribute it and-or modify +;- it under the terms of the GNU General Public License as published +;- by the Free Software Foundation, either version 3 of the License, or +;- (at your option) any later version. +;- +;- This source file is distributed in the hope that it will be useful, +;- but WITHOUT ANY WARRANTY; without even the implied warranty of +;- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;- GNU General Public License for more details. +;- +;- You should have received a copy of the GNU General Public License +;- along with this program. If not, see . +;-------------------------------------------------------------------------------------------------------- + + + ;====================================== + ; + ; USER ROM BANK 7 + ; + ;====================================== + ORG 0E800h + + ;-------------------------------- + ; Common code spanning all banks. + ;-------------------------------- +ROMFS7: NOP + XOR A ; We shouldnt arrive here after a reset, if we do, select UROM bank 0 + LD (RFSBK1),A + LD (RFSBK2),A ; and start up - ie. SA1510 Monitor. + ALIGN_NOPS 0E829H + + ; + ; Bank switching code, allows a call to code in another bank. + ; This code is duplicated in each bank such that a bank switch doesnt affect logic flow. + ; +BKSW7to0: PUSH AF + LD A, ROMBANK7 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK0 ; Required bank to call. + JR BKSW7_0 +BKSW7to1: PUSH AF + LD A, ROMBANK7 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK1 ; Required bank to call. + JR BKSW7_0 +BKSW7to2: PUSH AF + LD A, ROMBANK7 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK2 ; Required bank to call. + JR BKSW7_0 +BKSW7to3: PUSH AF + LD A, ROMBANK7 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK3 ; Required bank to call. + JR BKSW7_0 +BKSW7to4: PUSH AF + LD A, ROMBANK7 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK4 ; Required bank to call. + JR BKSW7_0 +BKSW7to5: PUSH AF + LD A, ROMBANK7 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK5 ; Required bank to call. + JR BKSW7_0 +BKSW7to6: PUSH AF + LD A, ROMBANK7 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK6 ; Required bank to call. + JR BKSW7_0 +BKSW7to7: PUSH AF + LD A, ROMBANK7 ; Calling bank (ie. us). + PUSH AF + LD A, ROMBANK7 ; Required bank to call. + ; +BKSW7_0: PUSH BC ; Save BC for caller. + LD BC, BKSWRET7 ; Place bank switchers return address on stack. + PUSH BC + LD (RFSBK2), A ; Bank switch in user rom space, A=bank. + LD (TMPSTACKP),SP ; Save the stack pointer as some old code corrupts it. + JP (HL) ; Jump to required function. +BKSWRET7: POP BC + POP AF ; Get bank which called us. + LD (RFSBK2), A ; Return to that bank. + POP AF + RET ; Return to caller. + + + + ALIGN 0EFFFh + DB 0FFh diff --git a/software/asm/rfs_mrom.asm b/software/asm/rfs_mrom.asm index 9f485af..695149d 100644 --- a/software/asm/rfs_mrom.asm +++ b/software/asm/rfs_mrom.asm @@ -126,22 +126,30 @@ RFS_EXADR: EQU 00016h ; Exec RFS_COMNT: EQU 00018h ; COMMENT ;----------------------------------------------- -; ROM Banks, 0-3 are reserved for alternative -; Monitor versions in MROM bank, -; 0-7 are reserved for RFS code in the -; User ROM bank. +; ROM Banks, 0-7 are reserved for alternative +; Monitor versions, CPM and RFS +; code in MROM bank, +; 0-7 are reserved for RFS code in +; the User ROM bank. +; 8-15 are reserved for CPM code in +; the User ROM bank. ;----------------------------------------------- -ROMBANK0 EQU 0 -ROMBANK1 EQU 1 -ROMBANK2 EQU 2 -ROMBANK3 EQU 3 -ROMBANK4 EQU 4 -ROMBANK5 EQU 5 -ROMBANK6 EQU 6 -ROMBANK7 EQU 7 +MROMPAGES EQU 8 +USRROMPAGES EQU 12 +ROMBANK0 EQU 0 +ROMBANK1 EQU 1 +ROMBANK2 EQU 2 +ROMBANK3 EQU 3 +ROMBANK4 EQU 4 +ROMBANK5 EQU 5 +ROMBANK6 EQU 6 +ROMBANK7 EQU 7 +ROMBANK8 EQU 8 +ROMBANK9 EQU 9 +ROMBANK10 EQU 10 +ROMBANK11 EQU 11 PRTMZF EQU 0E880H - MZFHDRSZ EQU 128 RFSSECTSZ EQU 256 MROMSIZE EQU 4096 @@ -256,7 +264,7 @@ _DIRMROM: PUSH BC ; C = Block in page ; D = File sequence number. ; - LD B,8 ; First 8x2K pages are reserved in User bank. + LD B,USRROMPAGES ; First 16x2K pages are reserved in User bank. LD C,0 ; Block in page. DIRNXTPG: LD A,B LD (WRKROMBK2), A @@ -329,7 +337,7 @@ _MFINDMZF: PUSH DE ; D = File sequence number. ; FINDMZF0: POP DE ; Get file sequence number in D. - LD B,8 ; First 8 pages are reserved in User ROM bank. + LD B,USRROMPAGES ; First 8 pages are reserved in User ROM bank. LD C,0 ; Block in page. ;LD D,0 ; File numbering start. FINDMZF1: LD A,B diff --git a/software/hdr/sdtest.HDR b/software/hdr/sdtest.HDR new file mode 100644 index 0000000..2214679 Binary files /dev/null and b/software/hdr/sdtest.HDR differ diff --git a/software/roms/MROM_256.bin b/software/roms/MROM_256.bin index 2d755c5..0bc42ce 100644 Binary files a/software/roms/MROM_256.bin and b/software/roms/MROM_256.bin differ diff --git a/software/roms/USER_ROM_256.bin b/software/roms/USER_ROM_256.bin index f5a9854..6d6ddd8 100644 Binary files a/software/roms/USER_ROM_256.bin and b/software/roms/USER_ROM_256.bin differ diff --git a/software/roms/blank_mrom.rom b/software/roms/blank_mrom.rom new file mode 100644 index 0000000..08e7df1 Binary files /dev/null and b/software/roms/blank_mrom.rom differ diff --git a/software/roms/cbios.rom b/software/roms/cbios.rom index 7467f31..e982b5c 100644 Binary files a/software/roms/cbios.rom and b/software/roms/cbios.rom differ diff --git a/software/roms/cbios_bank1.rom b/software/roms/cbios_bank1.rom index 16b8856..af2fac6 100644 Binary files a/software/roms/cbios_bank1.rom and b/software/roms/cbios_bank1.rom differ diff --git a/software/roms/cbios_bank2.rom b/software/roms/cbios_bank2.rom index 12a4ec2..6ca6d4b 100644 Binary files a/software/roms/cbios_bank2.rom and b/software/roms/cbios_bank2.rom differ diff --git a/software/roms/rfs.rom b/software/roms/rfs.rom index 095432e..b9f8c83 100644 Binary files a/software/roms/rfs.rom and b/software/roms/rfs.rom differ diff --git a/software/roms/rfs_mrom.rom b/software/roms/rfs_mrom.rom index 362f3ee..27f12b8 100644 Binary files a/software/roms/rfs_mrom.rom and b/software/roms/rfs_mrom.rom differ diff --git a/software/src/PetitFS/00readme.txt b/software/src/PetitFS/00readme.txt new file mode 100644 index 0000000..8054944 --- /dev/null +++ b/software/src/PetitFS/00readme.txt @@ -0,0 +1,53 @@ +Petit FatFs Module Source Files R0.03a (C)ChaN, 2019 + + +FILES + + pff.h Common include file for Petit FatFs and application module. + pff.c Petit FatFs module. + diskio.h Common include file for Petit FatFs and disk I/O module. + diskio.c Skeleton of low level disk I/O module. + + Low level disk I/O module is not included in this archive because the Petit + FatFs module is only a generic file system layer and not depend on any + specific storage device. You have to provide a low level disk I/O module that + written to control your storage device. + + + +AGREEMENTS + + Petit FatFs module is an open source software to implement FAT file system to + small embedded systems. This is a free software and is opened for education, + research and commercial developments under license policy of following trems. + + Copyright (C) 2019, ChaN, all right reserved. + + * The Petit FatFs module is a free software and there is NO WARRANTY. + * No restriction on use. You can use, modify and redistribute it for + personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. + * Redistributions of source code must retain the above copyright notice. + + + +REVISION HISTORY + + Jun 15, 2009 R0.01a First release (Branched from FatFs R0.07b) + + Dec 14, 2009 R0.02 Added multiple code page support. + Added write funciton. + Changed stream read mode interface. + + Dec 07,'2010 R0.02a Added some configuration options. + Fixed fails to open objects with DBCS character. + + Jun 10, 2014 R0.03 Separated out configuration options to pffconf.h. + Added _USE_LCC option. + Added _FS_FAT16 option. + + Jan 30, 2019 R0.03a Supported stdint.h for C99 and later. + Removed _WORD_ACCESS option. + Changed prefix of configuration options, _ to PF_. + Added some code pages. + Removed some code pages actually not valid. + diff --git a/software/src/PetitFS/Makefile b/software/src/PetitFS/Makefile new file mode 100644 index 0000000..f076528 --- /dev/null +++ b/software/src/PetitFS/Makefile @@ -0,0 +1,136 @@ +######################################################################################################### +## +## Name: Makefile +## Created: January 2019 +## Author(s): Philip Smart +## Description: PetitFS makefile +## This makefile builds the Petit FatFS for use in the RFS with banked ROMS. +## +## Credits: +## Copyright: (c) 2020 Philip Smart +## +## History: March 2020 - Initial script written. +## +## Notes: Optional component enables: +## +######################################################################################################### +## This source file is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## This source file is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program. If not, see . +######################################################################################################### +BASE = +CC = $(BASE)zcc +LD = $(BASE)zcc +AS = $(BASE)zcc +#CP = $(BASE) +#DUMP = $(BASE) + +BASEDIR = ../.. +#BASEDIR = ../../.. +SWDIR = $(BASEDIR)/software + +# we use printf from here +COMMON_DIR = $(SWDIR)/common +PFS_DIR = $(SWDIR)/common/PetitFS +INCLUDE_DIR = $(SWDIR)/include + +# Working directory to build object files. +BUILD_DIR = pff_obj + +COMMON_SRC = #$(COMMON_DIR)/sdmmc.c +PFS_SRC = $(PFS_DIR)/sdmmc.c $(PFS_DIR)/pff_func.c $(PFS_DIR)/pff_dir.c $(PFS_DIR)/pff_read.c $(PFS_DIR)/pff_write.c $(PFS_DIR)/pff_open.c $(PFS_DIR)/pff_mount.c + +COMMON_OBJ = $(patsubst $(COMMON_DIR)/%.c,$(BUILD_DIR)/%.o,$(COMMON_SRC)) +PFS_OBJ = $(patsubst $(PFS_DIR)/%.c,$(BUILD_DIR)/%.o,$(PFS_SRC)) +COMMON_ASM = $(patsubst $(COMMON_DIR)/%.c,$(BUILD_DIR)/%.asm,$(COMMON_SRC)) +PFS_ASM = $(patsubst $(PFS_DIR)/%.c,$(BUILD_DIR)/%.asm,$(PFS_SRC)) + +MAIN_PRJ = sdtest +MAIN_ASM = $(COMMON_ASM) $(PFS_ASM) $(patsubst %.c,$(BUILD_DIR)/%.asm,$(MAIN_SRC)) +MAIN_SRC = sdtest.c +MAIN_OBJ = $(COMMON_OBJ) $(PFS_OBJ) $(patsubst %.c,$(BUILD_DIR)/%.o,$(MAIN_SRC)) +MAIN_PRAGMA = rfs.inc + +ROM_PRJ = rom +ROM_SRC = +ROM_OBJ = $(COMMON_OBJ) $(PFS_OBJ) $(patsubst %.c,$(BUILD_DIR)/%.o,$(ROM_SRC)) + +# Commandline options for each tool. +# To disable use of a given instruction, prefix it with no- +TARGET = +mz +VERBOSITY = -vn +OPTIMISATION = -O3 +CFLAGS = $(TARGET) -pragma-define:REGISTER_SP=0xd000 -pragma-include:$(MAIN_PRAGMA) $(OPTIMISATION) -I. -I$(COMMON_DIR) -I$(PFS_DIR) -I$(INCLUDE_DIR) -lm $(VERBOSITY) +# +# Enable debug output. +OFLAGS += -DDEBUG +LFLAGS = $(TARGET) $(VERBOSITY) -pragma-define:REGISTER_SP=0xd000 -pragma-include:$(MAIN_PRAGMA) -lm -create-app -m +# +# Assembler flags. +ASFLAGS = $(TARGET) $(VERBOSITY) -c -I. -I$(COMMON_DIR) -I$(INCLUDE_DIR) -I$(STARTUP_DIR) +# + +# Our target. +all: $(BUILD_DIR) $(MAIN_PRJ) #$(MAIN_ASM) #$(ROM_PRJ) +# +$(MAIN_PRJ): $(BUILD_DIR) $(MAIN_OBJ) #$(MAIN_PRJ).asm + + +$(MAIN_ASM): $(BUILD_DIR) + +clean: + rm -f $(BUILD_DIR)/*.o *.hex *.lss *.elf *.map *.lst *.srec $(MAIN_PRJ) *~ */*.o *.bin *.srec *.dmp *.rpt *.ihx *.sym *.rel *.noi *.lk *.err *.mzt *.o + + +# Convert ELF binary to bin file. +%.bin: %.elf + @$(CP) -O binary $< $@ + +# Convert ELF to srec format for serial upload. +%.srec: %.elf + @$(CP) -O srec $< $@ + + +# Link - this produces an ELF binary. +$(MAIN_PRJ): $(MAIN_OBJ) + $(CC) $(LFLAGS) $(MAIN_OBJ) -o $@ $(LIBS) + +$(ROM_PRJ): $(ROM_OBJ) + $(CC) +z80 $(VERBOSITY) -pragma-define:REGISTER_SP=0xd000 -pragma-include:$(MAIN_PRAGMA) -lm -m $(ROM_OBJ) -o $@ $(LIBS) + +$(BUILD_DIR)/%.o: %.c Makefile + $(CC) $(CFLAGS) $(OFLAGS) -o $@ -c $< + +$(BUILD_DIR)/%.asm: %.c Makefile + $(CC) $(CFLAGS) $(OFLAGS) -a -o $@ -c $< + +$(BUILD_DIR)/%.o: %.cpp Makefile + $(CC) $(CFLAGS) $(OFLAGS) -o $@ -c $< + +$(BUILD_DIR)/%.o: %.asm Makefile + $(AS) $(ASFLAGS) -o $@ -c $< + +$(BUILD_DIR)/%.o: $(COMMON_DIR)/%.c Makefile + $(CC) $(CFLAGS) $(OFLAGS) -o $@ -c $< + +$(BUILD_DIR)/%.o: $(PFS_DIR)/%.c Makefile + $(CC) $(CFLAGS) $(OFLAGS) -o $@ -c $< + +$(BUILD_DIR)/%.o: %.s + $(AS) $(ASFLAGS) -o $@ $< + +$(BUILD_DIR)/%.o: $(STARTUP_DIR)/%.s + $(AS) $(ASFLAGS) -o $@ $< + +$(BUILD_DIR): + mkdir $(BUILD_DIR) + diff --git a/software/src/PetitFS/diskio.asm b/software/src/PetitFS/diskio.asm new file mode 100644 index 0000000..2c617d5 --- /dev/null +++ b/software/src/PetitFS/diskio.asm @@ -0,0 +1,95 @@ +;-------------------------------------------------------- +; File Created by SDCC : free open source ANSI-C Compiler +; Version 4.0.0 #11528 (Linux) +;-------------------------------------------------------- + .module diskio + .optsdcc -mz80 + +;-------------------------------------------------------- +; Public variables in this module +;-------------------------------------------------------- + .globl _disk_initialize + .globl _disk_readp + .globl _disk_writep +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; ram data +;-------------------------------------------------------- + .area _DATA +;-------------------------------------------------------- +; ram data +;-------------------------------------------------------- + .area _INITIALIZED +;-------------------------------------------------------- +; absolute external ram data +;-------------------------------------------------------- + .area _DABS (ABS) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area _HOME + .area _GSINIT + .area _GSFINAL + .area _GSINIT +;-------------------------------------------------------- +; Home +;-------------------------------------------------------- + .area _HOME + .area _HOME +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area _CODE +;diskio.c:12: DSTATUS disk_initialize (void) +; --------------------------------- +; Function disk_initialize +; --------------------------------- +_disk_initialize:: + push ix + ld ix,#0 + add ix,sp + dec sp +;diskio.c:18: return stat; + ld l, -1 (ix) +00101$: +;diskio.c:19: } + inc sp + pop ix + ret +;diskio.c:27: DRESULT disk_readp ( +; --------------------------------- +; Function disk_readp +; --------------------------------- +_disk_readp:: + push ix + ld ix,#0 + add ix,sp + dec sp +;diskio.c:38: return res; + ld l, -1 (ix) +00101$: +;diskio.c:39: } + inc sp + pop ix + ret +;diskio.c:47: DRESULT disk_writep ( +; --------------------------------- +; Function disk_writep +; --------------------------------- +_disk_writep:: + push ix + ld ix,#0 + add ix,sp + dec sp +;diskio.c:71: return res; + ld l, -1 (ix) +00103$: +;diskio.c:72: } + inc sp + pop ix + ret + .area _CODE + .area _INITIALIZER + .area _CABS (ABS) diff --git a/software/src/PetitFS/diskiotmp.c b/software/src/PetitFS/diskiotmp.c new file mode 100644 index 0000000..5b303b8 --- /dev/null +++ b/software/src/PetitFS/diskiotmp.c @@ -0,0 +1,73 @@ +/*-----------------------------------------------------------------------*/ +/* Low level disk I/O module skeleton for Petit FatFs (C)ChaN, 2014 */ +/*-----------------------------------------------------------------------*/ + +#include "diskio.h" + + +/*-----------------------------------------------------------------------*/ +/* Initialize Disk Drive */ +/*-----------------------------------------------------------------------*/ + +DSTATUS disk_initialize (void) +{ + DSTATUS stat; + + // Put your code here + + return stat; +} + + + +/*-----------------------------------------------------------------------*/ +/* Read Partial Sector */ +/*-----------------------------------------------------------------------*/ + +DRESULT disk_readp ( + BYTE* buff, /* Pointer to the destination object */ + DWORD sector, /* Sector number (LBA) */ + UINT offset, /* Offset in the sector */ + UINT count /* Byte count (bit15:destination) */ +) +{ + DRESULT res; + + // Put your code here + + return res; +} + + + +/*-----------------------------------------------------------------------*/ +/* Write Partial Sector */ +/*-----------------------------------------------------------------------*/ + +DRESULT disk_writep ( + BYTE* buff, /* Pointer to the data to be written, NULL:Initiate/Finalize write operation */ + DWORD sc /* Sector number (LBA) or Number of bytes to send */ +) +{ + DRESULT res; + + + if (!buff) { + if (sc) { + + // Initiate write process + + } else { + + // Finalize write process + + } + } else { + + // Send data to the disk + + } + + return res; +} + diff --git a/software/src/PetitFS/pff.asm b/software/src/PetitFS/pff.asm new file mode 100644 index 0000000..8c5b6d5 --- /dev/null +++ b/software/src/PetitFS/pff.asm @@ -0,0 +1,4534 @@ +;-------------------------------------------------------- +; File Created by SDCC : free open source ANSI-C Compiler +; Version 4.0.0 #11528 (Linux) +;-------------------------------------------------------- + .module pff + .optsdcc -mz80 + +;-------------------------------------------------------- +; Public variables in this module +;-------------------------------------------------------- + .globl _disk_initialize + .globl _disk_readp + .globl _disk_writep + .globl _pf_mount + .globl _pf_open + .globl _pf_read + .globl _pf_write + .globl _pf_lseek + .globl _pf_opendir + .globl _pf_readdir +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; ram data +;-------------------------------------------------------- + .area _DATA +_FatFs: + .ds 2 +;-------------------------------------------------------- +; ram data +;-------------------------------------------------------- + .area _INITIALIZED +;-------------------------------------------------------- +; absolute external ram data +;-------------------------------------------------------- + .area _DABS (ABS) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area _HOME + .area _GSINIT + .area _GSFINAL + .area _GSINIT +;-------------------------------------------------------- +; Home +;-------------------------------------------------------- + .area _HOME + .area _HOME +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area _CODE +;diskio.c:12: DSTATUS disk_initialize (void) +; --------------------------------- +; Function disk_initialize +; --------------------------------- +_disk_initialize:: +;diskio.c:18: return stat; + ld iy, #-1 + add iy, sp + ld l, 0 (iy) +l_disk_initialize_00101$: +;diskio.c:19: } + ret +;diskio.c:27: DRESULT disk_readp ( +; --------------------------------- +; Function disk_readp +; --------------------------------- +_disk_readp:: +;diskio.c:38: return res; + ld iy, #-1 + add iy, sp + ld l, 0 (iy) +l_disk_readp_00101$: +;diskio.c:39: } + ret +;diskio.c:47: DRESULT disk_writep ( +; --------------------------------- +; Function disk_writep +; --------------------------------- +_disk_writep:: +;diskio.c:71: return res; + ld iy, #-1 + add iy, sp + ld l, 0 (iy) +l_disk_writep_00103$: +;diskio.c:72: } + ret +;pff.c:384: static WORD ld_word (const BYTE* ptr) /* Load a 2-byte little-endian word */ +; --------------------------------- +; Function ld_word +; --------------------------------- +_ld_word: + call ___sdcc_enter_ix +;pff.c:388: rv = ptr[1]; + ld l, 4 (ix) + ld h, 5 (ix) + inc hl + ld c, (hl) + ld b, #0x00 +;pff.c:389: rv = rv << 8 | ptr[0]; + ld b, c + ld c, #0x00 + ld l, 4 (ix) + ld h, 5 (ix) + ld e, (hl) + ld d, #0x00 + ld a, c + or a, e + ld l, a + ld a, b + or a, d + ld h, a +;pff.c:390: return rv; +l_ld_word_00101$: +;pff.c:391: } + pop ix + ret +;pff.c:393: static DWORD ld_dword (const BYTE* ptr) /* Load a 4-byte little-endian word */ +; --------------------------------- +; Function ld_dword +; --------------------------------- +_ld_dword: + call ___sdcc_enter_ix + push af + push af +;pff.c:397: rv = ptr[3]; + ld l, 4 (ix) + ld h, 5 (ix) + inc hl + inc hl + inc hl + ld c, (hl) + ld b, #0x00 + ld e, #0x00 + ld d, #0x00 +;pff.c:398: rv = rv << 8 | ptr[2]; + ld -3 (ix), c + ld -2 (ix), b + ld -1 (ix), e + xor a, a + ld -4 (ix), a + ld l, 4 (ix) + ld h, 5 (ix) + inc hl + inc hl + ld c, (hl) + ld b, #0x00 + ld e, #0x00 + ld d, #0x00 + ld a, c + or a, -4 (ix) + ld c, a + ld a, b + or a, -3 (ix) + ld b, a + ld a, e + or a, -2 (ix) + ld e, a + ld a, d + or a, -1 (ix) + ld d, a +;pff.c:399: rv = rv << 8 | ptr[1]; + ld -3 (ix), c + ld -2 (ix), b + ld -1 (ix), e + xor a, a + ld -4 (ix), a + ld l, 4 (ix) + ld h, 5 (ix) + inc hl + ld c, (hl) + ld b, #0x00 + ld e, #0x00 + ld d, #0x00 + ld a, c + or a, -4 (ix) + ld c, a + ld a, b + or a, -3 (ix) + ld b, a + ld a, e + or a, -2 (ix) + ld e, a + ld a, d + or a, -1 (ix) + ld d, a +;pff.c:400: rv = rv << 8 | ptr[0]; + ld -3 (ix), c + ld -2 (ix), b + ld -1 (ix), e + xor a, a + ld -4 (ix), a + ld l, 4 (ix) + ld h, 5 (ix) + ld c, (hl) + ld b, #0x00 + ld e, #0x00 + ld d, #0x00 + ld a, -4 (ix) + or a, c + ld l, a + ld a, -3 (ix) + or a, b + ld h, a + ld a, -2 (ix) + or a, e + ld e, a + ld a, -1 (ix) + or a, d + ld d, a +;pff.c:401: return rv; +l_ld_dword_00101$: +;pff.c:402: } + ld sp, ix + pop ix + ret +;pff.c:411: static void mem_set (void* dst, int val, int cnt) { +; --------------------------------- +; Function mem_set +; --------------------------------- +_mem_set: + call ___sdcc_enter_ix +;pff.c:412: char *d = (char*)dst; + ld e, 4 (ix) + ld d, 5 (ix) +;pff.c:413: while (cnt--) *d++ = (char)val; + ld c, 8 (ix) + ld b, 9 (ix) +l_mem_set_00101$: + ld l, c + ld h, b + dec bc + ld a, h + or a, l + jp Z, l_mem_set_00104$ + ld a, 6 (ix) + ld (de), a + inc de + jp l_mem_set_00101$ +l_mem_set_00104$: +;pff.c:414: } + pop ix + ret +;pff.c:417: static int mem_cmp (const void* dst, const void* src, int cnt) { +; --------------------------------- +; Function mem_cmp +; --------------------------------- +_mem_cmp: + call ___sdcc_enter_ix + push af + push af +;pff.c:418: const char *d = (const char *)dst, *s = (const char *)src; + ld a, 4 (ix) + ld -4 (ix), a + ld a, 5 (ix) + ld -3 (ix), a + ld a, 6 (ix) + ld -2 (ix), a + ld a, 7 (ix) + ld -1 (ix), a +;pff.c:419: int r = 0; + ld hl, #0x0000 +;pff.c:420: while (cnt-- && (r = *d++ - *s++) == 0) ; + ld c, 8 (ix) + ld b, 9 (ix) +l_mem_cmp_00102$: + ld e, c + ld d, b + dec bc + ld a, d + or a, e + jp Z, l_mem_cmp_00104$ + pop hl + push hl + ld e, (hl) + inc -4 (ix) + jp NZ, l_mem_cmp_00118$ + inc -3 (ix) +l_mem_cmp_00118$: + ld d, #0x00 + ld l, -2 (ix) + ld h, -1 (ix) + ld l, (hl) + inc -2 (ix) + jp NZ, l_mem_cmp_00119$ + inc -1 (ix) +l_mem_cmp_00119$: + ld h, #0x00 + ld a, e + sub a, l + ld e, a + ld a, d + sbc a, h + ld d, a + ld l, e + ld h, d + ld a, d + or a, e + jp Z, l_mem_cmp_00102$ +l_mem_cmp_00104$: +;pff.c:421: return r; +l_mem_cmp_00105$: +;pff.c:422: } + ld sp, ix + pop ix + ret +;pff.c:430: static CLUST get_fat ( /* 1:IO error, Else:Cluster status */ +; --------------------------------- +; Function get_fat +; --------------------------------- +_get_fat: + call ___sdcc_enter_ix + ld hl, #-14 + add hl, sp + ld sp, hl +;pff.c:435: FATFS *fs = FatFs; + ld bc, (_FatFs) +;pff.c:440: if (clst < 2 || clst >= fs->n_fatent) return 1; /* Range check */ + ld a, 4 (ix) + sub a, #0x02 + ld a, 5 (ix) + sbc a, #0x00 + ld a, 6 (ix) + sbc a, #0x00 + ld a, 7 (ix) + sbc a, #0x00 + jp C, l_get_fat_00101$ + ld l, c + ld h, b + ld de, #0x0006 + add hl, de + ld e, (hl) + inc hl + ld d, (hl) + inc hl + inc hl + ld a, (hl) + dec hl + ld l, (hl) + ld h, a + ld a, 4 (ix) + sub a, e + ld a, 5 (ix) + sbc a, d + ld a, 6 (ix) + sbc a, l + ld a, 7 (ix) + sbc a, h + jp C, l_get_fat_00102$ +l_get_fat_00101$: + ld l, #0x01 + ld h, #0x00 + ld e, #0x00 + ld d, #0x00 + jp l_get_fat_00108$ +l_get_fat_00102$: +;pff.c:442: switch (fs->fs_type) { + ld a, (bc) + sub a, #0x03 + jp NZ,l_get_fat_00125$ + jp l_get_fat_00126$ +l_get_fat_00125$: + jp l_get_fat_00107$ +l_get_fat_00126$: +;pff.c:464: if (disk_readp(buf, fs->fatbase + clst / 128, ((UINT)clst % 128) * 4, 4)) break; + ld l, 4 (ix) + ld a, 5 (ix) + res 7, l + ld h, #0x00 + add hl, hl + add hl, hl + ld -10 (ix), l + ld -9 (ix), h + ld l, c + ld h, b + ld de, #0x000a + add hl, de + ld a, (hl) + ld -8 (ix), a + inc hl + ld a, (hl) + ld -7 (ix), a + inc hl + ld a, (hl) + ld -6 (ix), a + inc hl + ld a, (hl) + ld -5 (ix), a + ld e, 4 (ix) + ld d, 5 (ix) + ld l, 6 (ix) + ld h, 7 (ix) + ld b, #0x07 +l_get_fat_00127$: + srl h + rr l + rr d + rr e +l_get_fat_00128$: + djnz l_get_fat_00127$ + ld a, -8 (ix) + add a, e + ld -4 (ix), a + ld a, -7 (ix) + adc a, d + ld -3 (ix), a + ld a, -6 (ix) + adc a, l + ld -2 (ix), a + ld a, -5 (ix) + adc a, h + ld -1 (ix), a + ld hl, #0 + add hl, sp + ex de, hl + ld c, e + ld b, d + push de + ld hl, #0x0004 + push hl + ld l, -10 (ix) + ld h, -9 (ix) + push hl + ld l, -2 (ix) + ld h, -1 (ix) + push hl + ld l, -4 (ix) + ld h, -3 (ix) + push hl + push bc + call _disk_readp + ld iy, #10 + add iy, sp + ld sp, iy + ld a, l + pop de + or a, a + jp NZ, l_get_fat_00107$ +;pff.c:465: return ld_dword(buf) & 0x0FFFFFFF; + push de + call _ld_dword + pop af + ld a, d + and a, #0x0f + ld d, a + jp l_get_fat_00108$ +;pff.c:467: } +l_get_fat_00107$: +;pff.c:469: return 1; /* An error occured at the disk I/O layer */ + ld l, #0x01 + ld h, #0x00 + ld e, #0x00 + ld d, #0x00 +l_get_fat_00108$: +;pff.c:470: } + ld sp, ix + pop ix + ret +;pff.c:479: static DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ +; --------------------------------- +; Function clust2sect +; --------------------------------- +_clust2sect: + call ___sdcc_enter_ix + push af + push af +;pff.c:483: FATFS *fs = FatFs; + ld bc, (_FatFs) +;pff.c:486: clst -= 2; + ld a, 4 (ix) + add a, #0xfe + ld 4 (ix), a + ld a, 5 (ix) + adc a, #0xff + ld 5 (ix), a + ld a, 6 (ix) + adc a, #0xff + ld 6 (ix), a + ld a, 7 (ix) + adc a, #0xff + ld 7 (ix), a +;pff.c:487: if (clst >= (fs->n_fatent - 2)) return 0; /* Invalid cluster# */ + ld l, c + ld h, b + ld de, #0x0006 + add hl, de + ld e, (hl) + inc hl + ld d, (hl) + inc hl + inc hl + ld a, (hl) + dec hl + ld l, (hl) + ld h, a + ld a, e + add a, #0xfe + ld e, a + ld a, d + adc a, #0xff + ld d, a + ld a, l + adc a, #0xff + ld l, a + ld a, h + adc a, #0xff + ld h, a + ld a, 4 (ix) + sub a, e + ld a, 5 (ix) + sbc a, d + ld a, 6 (ix) + sbc a, l + ld a, 7 (ix) + sbc a, h + jp C, l_clust2sect_00102$ + ld l, #0x00 + ld h, #0x00 + ld e, #0x00 + ld d, #0x00 + jp l_clust2sect_00103$ +l_clust2sect_00102$: +;pff.c:488: return (DWORD)clst * fs->csize + fs->database; + ld l, c + ld h, b + inc hl + inc hl + ld e, (hl) + ld d, #0x00 + ld l, #0x00 + ld h, #0x00 + push bc + push hl + push de + ld l, 6 (ix) + ld h, 7 (ix) + push hl + ld l, 4 (ix) + ld h, 5 (ix) + push hl + call __mullong + pop af + pop af + pop af + pop af + ld -4 (ix), l + ld -3 (ix), h + ld -2 (ix), e + ld -1 (ix), d + pop bc + ld l, c + ld h, b + ld de, #0x0012 + add hl, de + ld c, (hl) + inc hl + ld b, (hl) + inc hl + ld e, (hl) + inc hl + ld d, (hl) + ld a, -4 (ix) + add a, c + ld l, a + ld a, -3 (ix) + adc a, b + ld h, a + ld a, -2 (ix) + adc a, e + ld e, a + ld a, -1 (ix) + adc a, d + ld d, a +l_clust2sect_00103$: +;pff.c:489: } + ld sp, ix + pop ix + ret +;pff.c:492: static CLUST get_clust ( +; --------------------------------- +; Function get_clust +; --------------------------------- +_get_clust: + call ___sdcc_enter_ix + push af + push af +;pff.c:501: clst = ld_word(dir+DIR_FstClusHI); + ld a, 4 (ix) + add a, #0x14 + ld c, a + ld a, 5 (ix) + adc a, #0x00 + ld b, a + push bc + call _ld_word + pop af + ld c, #0x00 + ld b, #0x00 +;pff.c:502: clst <<= 16; + ld -2 (ix), l + ld -1 (ix), h + xor a, a + ld -4 (ix), a + ld -3 (ix), a +;pff.c:504: clst |= ld_word(dir+DIR_FstClusLO); + ld a, 4 (ix) + add a, #0x1a + ld c, a + ld a, 5 (ix) + adc a, #0x00 + ld b, a + push bc + call _ld_word + pop af + ld c, #0x00 + ld b, #0x00 + ld a, -4 (ix) + or a, l + ld l, a + ld a, -3 (ix) + or a, h + ld h, a + ld a, -2 (ix) + or a, c + ld e, a + ld a, -1 (ix) + or a, b + ld d, a +;pff.c:506: return clst; +l_get_clust_00105$: +;pff.c:507: } + ld sp, ix + pop ix + ret +;pff.c:514: static FRESULT dir_rewind ( +; --------------------------------- +; Function dir_rewind +; --------------------------------- +_dir_rewind: + call ___sdcc_enter_ix + push af + push af + push af + push af +;pff.c:519: FATFS *fs = FatFs; + ld hl, (_FatFs) + ex (sp), hl +;pff.c:522: dj->index = 0; + ld a, 4 (ix) + ld -6 (ix), a + ld a, 5 (ix) + ld -5 (ix), a + pop bc + pop hl + push hl + push bc + xor a, a + ld (hl), a + inc hl + ld (hl), a +;pff.c:523: clst = dj->sclust; + pop bc + pop hl + push hl + push bc + ld de, #0x0004 + add hl, de + ld c, (hl) + inc hl + ld b, (hl) + inc hl + ld e, (hl) + inc hl + ld d, (hl) +;pff.c:524: if (clst == 1 || clst >= fs->n_fatent) { /* Check start cluster range */ + ld a, c + dec a + or a, b + or a, e + or a, d + jp NZ,l_dir_rewind_00128$ + jp l_dir_rewind_00101$ +l_dir_rewind_00128$: + pop hl + push hl + push bc + ld bc, #0x0006 + add hl, bc + pop bc + ld a, (hl) + ld -4 (ix), a + inc hl + ld a, (hl) + ld -3 (ix), a + inc hl + ld a, (hl) + ld -2 (ix), a + inc hl + ld a, (hl) + ld -1 (ix), a + ld a, c + sub a, -4 (ix) + ld a, b + sbc a, -3 (ix) + ld a, e + sbc a, -2 (ix) + ld a, d + sbc a, -1 (ix) + jp C, l_dir_rewind_00106$ +l_dir_rewind_00101$: +;pff.c:525: return FR_DISK_ERR; + ld l, #0x01 + jp l_dir_rewind_00109$ +;pff.c:527: if (PF_FS_FAT32 && !clst && (_FS_32ONLY || fs->fs_type == FS_FAT32)) { /* Replace cluster# 0 with root cluster# if in FAT32 */ +l_dir_rewind_00106$: + ld a, d + or a, e + or a, b + or a, c + jp NZ, l_dir_rewind_00105$ +;pff.c:528: clst = (CLUST)fs->dirbase; + pop hl + push hl + ld de, #0x000e + add hl, de + ld c, (hl) + inc hl + ld b, (hl) + inc hl + ld e, (hl) + inc hl + ld d, (hl) +l_dir_rewind_00105$: +;pff.c:530: dj->clust = clst; /* Current cluster */ + ld a, -6 (ix) + add a, #0x08 + ld l, a + ld a, -5 (ix) + adc a, #0x00 + ld h, a + ld (hl), c + inc hl + ld (hl), b + inc hl + ld (hl), e + inc hl + ld (hl), d +;pff.c:531: dj->sect = (_FS_32ONLY || clst) ? clust2sect(clst) : fs->dirbase; /* Current sector */ + ld a, -6 (ix) + add a, #0x0c + ld l, a + ld a, -5 (ix) + adc a, #0x00 + ld h, a + push hl + push de + push bc + call _clust2sect + pop af + pop af + ld c, l + ld b, h + pop hl + ld (hl), c + inc hl + ld (hl), b + inc hl + ld (hl), e + inc hl + ld (hl), d +;pff.c:533: return FR_OK; /* Seek succeeded */ + ld l, #0x00 +l_dir_rewind_00109$: +;pff.c:534: } + ld sp, ix + pop ix + ret +;pff.c:543: static FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table */ +; --------------------------------- +; Function dir_next +; --------------------------------- +_dir_next: + call ___sdcc_enter_ix + ld hl, #-14 + add hl, sp + ld sp, hl +;pff.c:549: FATFS *fs = FatFs; + ld hl, (_FatFs) + ex (sp), hl +;pff.c:552: i = dj->index + 1; + ld c, 4 (ix) + ld b, 5 (ix) + ld l, c + ld h, b + ld e, (hl) + inc hl + ld d, (hl) + inc de + ld -12 (ix), e + ld -11 (ix), d +;pff.c:553: if (!i || !dj->sect) return FR_NO_FILE; /* Report EOT when index has reached 65535 */ + ld a, -11 (ix) + or a, -12 (ix) + jp Z, l_dir_next_00101$ + ld hl, #0x000c + add hl, bc + ld -10 (ix), l + ld -9 (ix), h + ld l, -10 (ix) + ld h, -9 (ix) + ld e, (hl) + inc hl + ld d, (hl) + inc hl + inc hl + ld a, (hl) + dec hl + ld l, (hl) + ld h, a + ld a, h + or a, l + or a, d + or a, e + jp NZ, l_dir_next_00102$ +l_dir_next_00101$: + ld l, #0x03 + jp l_dir_next_00117$ +l_dir_next_00102$: +;pff.c:555: if (!(i % 16)) { /* Sector changed? */ + ld a, -12 (ix) + ld -8 (ix), a + ld a, -11 (ix) + ld -7 (ix), a + ld a, -8 (ix) + and a, #0x0f + jp NZ,l_dir_next_00154$ + jp l_dir_next_00155$ +l_dir_next_00154$: + jp l_dir_next_00116$ +l_dir_next_00155$: +;pff.c:556: dj->sect++; /* Next sector */ + ld a, e + add a, #0x01 + ld -4 (ix), a + ld a, d + adc a, #0x00 + ld -3 (ix), a + ld a, l + adc a, #0x00 + ld -2 (ix), a + ld a, h + adc a, #0x00 + ld -1 (ix), a + push bc + ld e, -10 (ix) + ld d, -9 (ix) + ld hl, #0x000c + add hl, sp + ld bc, #0x0004 + ldir + pop bc +;pff.c:558: if (dj->clust == 0) { /* Static table */ + ld hl, #0x0008 + add hl, bc + ld -6 (ix), l + ld -5 (ix), h + push bc + ld e, -6 (ix) + ld d, -5 (ix) + ld hl, #0x000c + add hl, sp + ex de, hl + ld bc, #0x0004 + ldir + pop bc + ld a, -1 (ix) + or a, -2 (ix) + or a, -3 (ix) + or a, -4 (ix) + jp NZ, l_dir_next_00113$ +;pff.c:559: if (i >= fs->n_rootdir) return FR_NO_FILE; /* Report EOT when end of table */ + pop hl + push hl + ld de, #0x0004 + add hl, de + ld e, (hl) + inc hl + ld d, (hl) + ld a, -12 (ix) + sub a, e + ld a, -11 (ix) + sbc a, d + jp C, l_dir_next_00116$ + ld l, #0x03 + jp l_dir_next_00117$ +l_dir_next_00113$: +;pff.c:562: if (((i / 16) & (fs->csize - 1)) == 0) { /* Cluster changed? */ + ld e, -8 (ix) + ld d, -7 (ix) + ld a, #0x04 +l_dir_next_00156$: + srl d + rr e + dec a + jp NZ, l_dir_next_00156$ + pop hl + push hl + inc hl + inc hl + ld l, (hl) + ld h, #0x00 + dec hl + ld a, l + and a, e + ld e, a + ld a, h + and a, d + or a, e + jp NZ, l_dir_next_00116$ +;pff.c:563: clst = get_fat(dj->clust); /* Get next cluster */ + push bc + ld l, -2 (ix) + ld h, -1 (ix) + push hl + ld l, -4 (ix) + ld h, -3 (ix) + push hl + call _get_fat + pop af + pop af + pop bc + ld -4 (ix), l + ld -3 (ix), h + ld -2 (ix), e + ld -1 (ix), d +;pff.c:564: if (clst <= 1) return FR_DISK_ERR; + ld a, #0x01 + cp a, -4 (ix) + ld a, #0x00 + sbc a, -3 (ix) + ld a, #0x00 + sbc a, -2 (ix) + ld a, #0x00 + sbc a, -1 (ix) + jp C, l_dir_next_00107$ + ld l, #0x01 + jp l_dir_next_00117$ +l_dir_next_00107$: +;pff.c:565: if (clst >= fs->n_fatent) return FR_NO_FILE; /* Report EOT when it reached end of dynamic table */ + pop hl + push hl + ld de, #0x0006 + add hl, de + ld e, (hl) + inc hl + ld d, (hl) + inc hl + inc hl + ld a, (hl) + dec hl + ld l, (hl) + ld h, a + ld a, -4 (ix) + sub a, e + ld a, -3 (ix) + sbc a, d + ld a, -2 (ix) + sbc a, l + ld a, -1 (ix) + sbc a, h + jp C, l_dir_next_00109$ + ld l, #0x03 + jp l_dir_next_00117$ +l_dir_next_00109$: +;pff.c:566: dj->clust = clst; /* Initialize data for new cluster */ + push bc + ld e, -6 (ix) + ld d, -5 (ix) + ld hl, #0x000c + add hl, sp + ld bc, #0x0004 + ldir + pop bc +;pff.c:567: dj->sect = clust2sect(clst); + push bc + ld l, -2 (ix) + ld h, -1 (ix) + push hl + ld l, -4 (ix) + ld h, -3 (ix) + push hl + call _clust2sect + pop af + pop af + ld -4 (ix), l + ld -3 (ix), h + ld -2 (ix), e + ld -1 (ix), d + pop bc + push bc + ld e, -10 (ix) + ld d, -9 (ix) + ld hl, #0x000c + add hl, sp + ld bc, #0x0004 + ldir + pop bc +l_dir_next_00116$: +;pff.c:572: dj->index = i; + ld a, -12 (ix) + ld (bc), a + inc bc + ld a, -11 (ix) + ld (bc), a +;pff.c:574: return FR_OK; + ld l, #0x00 +l_dir_next_00117$: +;pff.c:575: } + ld sp, ix + pop ix + ret +;pff.c:584: static FRESULT dir_find ( +; --------------------------------- +; Function dir_find +; --------------------------------- +_dir_find: + call ___sdcc_enter_ix + ld hl, #-9 + add hl, sp + ld sp, hl +;pff.c:593: res = dir_rewind(dj); /* Rewind directory object */ + ld l, 4 (ix) + ld h, 5 (ix) + push hl + call _dir_rewind + pop af +;pff.c:594: if (res != FR_OK) return res; + ld a, l + or a, a + jp Z, l_dir_find_00122$ + jp l_dir_find_00113$ +;pff.c:596: do { +l_dir_find_00122$: + ld c, 4 (ix) + ld b, 5 (ix) + ld -5 (ix), c + ld -4 (ix), b +l_dir_find_00110$: +;pff.c:597: res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ + ld l, c + ld h, b + ld e, (hl) + inc hl + ld d, (hl) + ld a, e + and a, #0x0f + ld l, a + ld h, #0x00 + add hl, hl + add hl, hl + add hl, hl + add hl, hl + add hl, hl + ld e, l + ld d, h + ld l, -5 (ix) + ld h, -4 (ix) + push bc + ld bc, #0x000c + add hl, bc + pop bc + ld a, (hl) + ld -9 (ix), a + inc hl + ld a, (hl) + ld -8 (ix), a + inc hl + ld a, (hl) + ld -7 (ix), a + inc hl + ld a, (hl) + ld -6 (ix), a + push bc + ld hl, #0x0020 + push hl + push de + ld l, -7 (ix) + ld h, -6 (ix) + push hl + ld l, -9 (ix) + ld h, -8 (ix) + push hl + ld l, 6 (ix) + ld h, 7 (ix) + push hl + call _disk_readp + ld iy, #10 + add iy, sp + ld sp, iy + ld a, l + pop bc + or a, a + jp Z, l_dir_find_00115$ +;pff.c:598: ? FR_DISK_ERR : FR_OK; + ld de, #0x0001 + jp l_dir_find_00116$ +l_dir_find_00115$: + ld de, #0x0000 +l_dir_find_00116$: + ld -3 (ix), e +;pff.c:599: if (res != FR_OK) break; + ld a, -3 (ix) + or a, a + jp NZ, l_dir_find_00112$ +;pff.c:600: c = dir[DIR_Name]; /* First character */ + ld l, 6 (ix) + ld h, 7 (ix) + ld a, (hl) +;pff.c:601: if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ + or a, a + jp NZ, l_dir_find_00106$ + ld -3 (ix), #0x03 + jp l_dir_find_00112$ +l_dir_find_00106$: +;pff.c:602: if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dj->fn, 11)) break; /* Is it a valid entry? */ + ld de, #0x000b + add hl, de + ld a, (hl) + bit 3, a + jp NZ,l_dir_find_00147$ + jp l_dir_find_00148$ +l_dir_find_00147$: + jp l_dir_find_00108$ +l_dir_find_00148$: + ld l, c + ld h, b + inc hl + inc hl + ld e, (hl) + inc hl + ld d, (hl) + ld -2 (ix), e + ld -1 (ix), d + ld e, 6 (ix) + ld d, 7 (ix) + push bc + ld hl, #0x000b + push hl + ld l, -2 (ix) + ld h, -1 (ix) + push hl + push de + call _mem_cmp + pop af + pop af + pop af + pop bc + ld a, h + or a, l + jp Z, l_dir_find_00112$ +l_dir_find_00108$: +;pff.c:603: res = dir_next(dj); /* Next entry */ + push bc + push bc + call _dir_next + pop af + pop bc + ld -3 (ix), l +;pff.c:604: } while (res == FR_OK); + ld a, -3 (ix) + or a, a + jp Z, l_dir_find_00110$ +l_dir_find_00112$: +;pff.c:606: return res; + ld l, -3 (ix) +l_dir_find_00113$: +;pff.c:607: } + ld sp, ix + pop ix + ret +;pff.c:616: static FRESULT dir_read ( +; --------------------------------- +; Function dir_read +; --------------------------------- +_dir_read: + call ___sdcc_enter_ix + push af + push af + push af +;pff.c:625: res = FR_NO_FILE; + ld e, #0x03 +;pff.c:626: while (dj->sect) { + ld c, 4 (ix) + ld b, 5 (ix) + ld hl, #0x000c + add hl, bc + ex (sp), hl +l_dir_read_00111$: + push de + push bc + ld e, -6 (ix) + ld d, -5 (ix) + ld hl, #0x0006 + add hl, sp + ex de, hl + ld bc, #0x0004 + ldir + pop bc + pop de + ld a, -1 (ix) + or a, -2 (ix) + or a, -3 (ix) + or a, -4 (ix) + jp Z, l_dir_read_00113$ +;pff.c:627: res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ + ld l, c + ld h, b + ld e, (hl) + inc hl + ld d, (hl) + ld a, e + and a, #0x0f + ld l, a + ld h, #0x00 + add hl, hl + add hl, hl + add hl, hl + add hl, hl + add hl, hl + push bc + ld de, #0x0020 + push de + push hl + ld l, -2 (ix) + ld h, -1 (ix) + push hl + ld l, -4 (ix) + ld h, -3 (ix) + push hl + ld l, 6 (ix) + ld h, 7 (ix) + push hl + call _disk_readp + ld iy, #10 + add iy, sp + ld sp, iy + ld a, l + pop bc + or a, a + jp Z, l_dir_read_00118$ +;pff.c:628: ? FR_DISK_ERR : FR_OK; + ld de, #0x0001 + jp l_dir_read_00119$ +l_dir_read_00118$: + ld de, #0x0000 +l_dir_read_00119$: +;pff.c:629: if (res != FR_OK) break; + ld a, e + or a, a + jp NZ, l_dir_read_00113$ +;pff.c:630: c = dir[DIR_Name]; + ld l, 6 (ix) + ld h, 7 (ix) + ld a, (hl) +;pff.c:631: if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ + or a, a + jp NZ, l_dir_read_00104$ + ld e, #0x03 + jp l_dir_read_00113$ +l_dir_read_00104$: +;pff.c:632: a = dir[DIR_Attr] & AM_MASK; + push bc + ld bc, #0x000b + add hl, bc + pop bc + ld d, (hl) + push af + ld a, d + and a, #0x3f + ld d, a + pop af +;pff.c:633: if (c != 0xE5 && c != '.' && !(a & AM_VOL)) break; /* Is it a valid entry? */ + cp a, #0xe5 + jp NZ,l_dir_read_00160$ + jp l_dir_read_00106$ +l_dir_read_00160$: + sub a, #0x2e + jp NZ,l_dir_read_00161$ + jp l_dir_read_00106$ +l_dir_read_00161$: + bit 3, d + jp NZ,l_dir_read_00162$ + jp l_dir_read_00113$ +l_dir_read_00162$: +l_dir_read_00106$: +;pff.c:634: res = dir_next(dj); /* Next entry */ + push bc + push bc + call _dir_next + pop af + ld a, l + pop bc + ld e, a +;pff.c:635: if (res != FR_OK) break; + ld a, e + or a, a + jp Z, l_dir_read_00111$ +l_dir_read_00113$: +;pff.c:638: if (res != FR_OK) dj->sect = 0; + ld a, e + or a, a + jp Z, l_dir_read_00115$ + pop hl + push hl + xor a, a + ld (hl), a + inc hl + ld (hl), a + inc hl + ld (hl), a + inc hl + ld (hl), a +l_dir_read_00115$: +;pff.c:640: return res; + ld l, e +l_dir_read_00116$: +;pff.c:641: } + ld sp, ix + pop ix + ret +;pff.c:651: static FRESULT create_name ( +; --------------------------------- +; Function create_name +; --------------------------------- +_create_name: + call ___sdcc_enter_ix + push af + push af + push af + dec sp +;pff.c:663: sfn = dj->fn; + ld l, 4 (ix) + ld h, 5 (ix) + inc hl + inc hl + ld c, (hl) + inc hl + ld b, (hl) +;pff.c:664: mem_set(sfn, ' ', 11); + ld e, c + ld d, b + push bc + ld hl, #0x000b + push hl + ld l, #0x20 + push hl + push de + call _mem_set + pop af + pop af + pop af + pop bc +;pff.c:665: si = i = 0; ni = 8; + xor a, a + ld -1 (ix), a + ld -7 (ix), #0x08 +;pff.c:666: p = *path; + ld a, 6 (ix) + ld -6 (ix), a + ld a, 7 (ix) + ld -5 (ix), a + ld l, -6 (ix) + ld h, -5 (ix) + ld a, (hl) + ld -4 (ix), a + inc hl + ld a, (hl) + ld -3 (ix), a + ld e, #0x00 +l_create_name_00120$: +;pff.c:668: c = p[si++]; + ld l, -4 (ix) + ld h, -3 (ix) + ld d, #0x00 + add hl, de + inc e + ld d, (hl) +;pff.c:669: if (c <= ' ' || c == '/') break; /* Break on end of segment */ + ld a, #0x20 + sub a, d + ld a, #0x00 + rla + ld -2 (ix), a + bit 0, -2 (ix) + jp Z, l_create_name_00119$ + ld a, d + sub a, #0x2f + jp NZ,l_create_name_00161$ + jp l_create_name_00119$ +l_create_name_00161$: +;pff.c:670: if (c == '.' || i >= ni) { + ld a, d + sub a, #0x2e + jp NZ,l_create_name_00162$ + ld a,#0x01 + jp l_create_name_00163$ +l_create_name_00162$: + xor a,a +l_create_name_00163$: + ld l, a + ld a, l + or a, a + jp NZ, l_create_name_00107$ + ld a, -1 (ix) + sub a, -7 (ix) + jp C, l_create_name_00111$ +l_create_name_00107$: +;pff.c:671: if (ni != 8 || c != '.') break; + ld a, -7 (ix) + sub a, #0x08 + jp NZ,l_create_name_00164$ + jp l_create_name_00165$ +l_create_name_00164$: + jp l_create_name_00119$ +l_create_name_00165$: + bit 0, l + jp Z, l_create_name_00119$ +;pff.c:672: i = 8; ni = 11; + ld -1 (ix), #0x08 + ld -7 (ix), #0x0b +;pff.c:673: continue; + jp l_create_name_00120$ +;pff.c:683: if (PF_USE_LCC && IsLower(c)) c -= 0x20; /* toupper */ +l_create_name_00111$: +;pff.c:684: sfn[i++] = c; + ld l, -1 (ix) + inc -1 (ix) + ld h, #0x00 + add hl, bc + ld (hl), d + jp l_create_name_00120$ +l_create_name_00119$: +;pff.c:687: *path = &p[si]; /* Rerurn pointer to the next segment */ + ld a, e + add a, -4 (ix) + ld e, a + ld a, #0x00 + adc a, -3 (ix) + ld d, a + ld l, -6 (ix) + ld h, -5 (ix) + ld (hl), e + inc hl + ld (hl), d +;pff.c:689: sfn[11] = (c <= ' ') ? 1 : 0; /* Set last segment flag if end of path */ + ld hl, #0x000b + add hl, bc + bit 0, -2 (ix) + jp NZ, l_create_name_00123$ + ld bc, #0x0001 + jp l_create_name_00124$ +l_create_name_00123$: + ld bc, #0x0000 +l_create_name_00124$: + ld (hl), c +;pff.c:691: return FR_OK; + ld l, #0x00 +l_create_name_00121$: +;pff.c:692: } + ld sp, ix + pop ix + ret +;pff.c:701: static void get_fileinfo ( /* No return code */ +; --------------------------------- +; Function get_fileinfo +; --------------------------------- +_get_fileinfo: + call ___sdcc_enter_ix + push af + push af + push af +;pff.c:711: p = fno->fname; + ld c, 8 (ix) + ld b, 9 (ix) + ld hl, #0x0009 + add hl, bc + ex (sp), hl +;pff.c:712: if (dj->sect) { + ld l, 4 (ix) + ld h, 5 (ix) + ld de, #0x000c + add hl, de + ld a, (hl) + ld -4 (ix), a + inc hl + ld a, (hl) + ld -3 (ix), a + inc hl + ld a, (hl) + ld -2 (ix), a + inc hl + ld a, (hl) + ld -1 (ix), a + ld a, -1 (ix) + or a, -2 (ix) + or a, -3 (ix) + or a, -4 (ix) + jp Z, l_get_fileinfo_00112$ +;pff.c:713: for (i = 0; i < 8; i++) { /* Copy file name body */ + pop de + push de + xor a, a + ld -1 (ix), a +l_get_fileinfo_00113$: +;pff.c:714: c = dir[i]; + ld a, 6 (ix) + add a, -1 (ix) + ld l, a + ld a, 7 (ix) + adc a, #0x00 + ld h, a + ld a, (hl) +;pff.c:715: if (c == ' ') break; + cp a, #0x20 + jp NZ,l_get_fileinfo_00156$ + jp l_get_fileinfo_00126$ +l_get_fileinfo_00156$: +;pff.c:716: if (c == 0x05) c = 0xE5; + cp a, #0x05 + jp NZ,l_get_fileinfo_00157$ + jp l_get_fileinfo_00158$ +l_get_fileinfo_00157$: + jp l_get_fileinfo_00104$ +l_get_fileinfo_00158$: + ld a, #0xe5 +l_get_fileinfo_00104$: +;pff.c:717: *p++ = c; + ld (de), a + inc de +;pff.c:713: for (i = 0; i < 8; i++) { /* Copy file name body */ + inc -1 (ix) + ld a, -1 (ix) + sub a, #0x08 + jp C, l_get_fileinfo_00113$ +l_get_fileinfo_00126$: + inc sp + inc sp + push de +;pff.c:719: if (dir[8] != ' ') { /* Copy file name extension */ + ld l, 6 (ix) + ld h, 7 (ix) + push bc + ld bc, #0x0008 + add hl, bc + pop bc + ld a, (hl) + sub a, #0x20 + jp NZ,l_get_fileinfo_00159$ + jp l_get_fileinfo_00110$ +l_get_fileinfo_00159$: +;pff.c:720: *p++ = '.'; + ld a, #0x2e + ld (de), a + inc de +;pff.c:721: for (i = 8; i < 11; i++) { + ld -1 (ix), #0x08 +l_get_fileinfo_00115$: +;pff.c:722: c = dir[i]; + ld a, 6 (ix) + add a, -1 (ix) + ld l, a + ld a, 7 (ix) + adc a, #0x00 + ld h, a + ld a, (hl) +;pff.c:723: if (c == ' ') break; + cp a, #0x20 + jp NZ,l_get_fileinfo_00160$ + jp l_get_fileinfo_00127$ +l_get_fileinfo_00160$: +;pff.c:724: *p++ = c; + ld (de), a + inc de +;pff.c:721: for (i = 8; i < 11; i++) { + inc -1 (ix) + ld a, -1 (ix) + sub a, #0x0b + jp C, l_get_fileinfo_00115$ +l_get_fileinfo_00127$: + inc sp + inc sp + push de +l_get_fileinfo_00110$: +;pff.c:727: fno->fattrib = dir[DIR_Attr]; /* Attribute */ + ld hl, #0x0008 + add hl, bc + ex de, hl + ld l, 6 (ix) + ld h, 7 (ix) + push bc + ld bc, #0x000b + add hl, bc + pop bc + ld a, (hl) + ld (de), a +;pff.c:728: fno->fsize = ld_dword(dir+DIR_FileSize); /* Size */ + ld a, 6 (ix) + add a, #0x1c + ld e, a + ld a, 7 (ix) + adc a, #0x00 + ld d, a + push bc + push de + call _ld_dword + pop af + ld -4 (ix), l + ld -3 (ix), h + ld -2 (ix), e + ld -1 (ix), d + pop bc + push bc + ld e, c + ld d, b + ld hl, #0x0004 + add hl, sp + ld bc, #0x0004 + ldir + pop bc +;pff.c:729: fno->fdate = ld_word(dir+DIR_WrtDate); /* Date */ + ld hl, #0x0004 + add hl, bc + ld a, 6 (ix) + add a, #0x18 + ld e, a + ld a, 7 (ix) + adc a, #0x00 + ld d, a + push hl + push bc + push de + call _ld_word + pop af + ld e, l + ld d, h + pop bc + pop hl + ld (hl), e + inc hl + ld (hl), d +;pff.c:730: fno->ftime = ld_word(dir+DIR_WrtTime); /* Time */ + ld hl, #0x0006 + add hl, bc + ld a, 6 (ix) + add a, #0x16 + ld c, a + ld a, 7 (ix) + adc a, #0x00 + ld b, a + push hl + push bc + call _ld_word + pop af + ld c, l + ld b, h + pop hl + ld (hl), c + inc hl + ld (hl), b +l_get_fileinfo_00112$: +;pff.c:732: *p = 0; + pop hl + push hl + ld (hl), #0x00 +l_get_fileinfo_00117$: +;pff.c:733: } + ld sp, ix + pop ix + ret +;pff.c:742: static FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ +; --------------------------------- +; Function follow_path +; --------------------------------- +_follow_path: + call ___sdcc_enter_ix + ld hl, #-10 + add hl, sp + ld sp, hl +;pff.c:751: while (*path == ' ') path++; /* Strip leading spaces */ + ld l, 8 (ix) + ld h, 9 (ix) +l_follow_path_00101$: + ld a, (hl) + ld e, l + ld d, h + inc de + cp a, #0x20 + jp NZ,l_follow_path_00168$ + jp l_follow_path_00169$ +l_follow_path_00168$: + jp l_follow_path_00131$ +l_follow_path_00169$: + ld l, e + ld h, d + ld 8 (ix), e + ld 9 (ix), d + jp l_follow_path_00101$ +l_follow_path_00131$: + ld 8 (ix), l + ld 9 (ix), h +;pff.c:752: if (*path == '/') path++; /* Strip heading separator if exist */ + sub a, #0x2f + jp NZ,l_follow_path_00170$ + jp l_follow_path_00171$ +l_follow_path_00170$: + jp l_follow_path_00105$ +l_follow_path_00171$: + ld 8 (ix), e + ld 9 (ix), d +l_follow_path_00105$: +;pff.c:753: dj->sclust = 0; /* Set start directory (always root dir) */ + ld c, 4 (ix) + ld b, 5 (ix) + ld hl, #0x0004 + add hl, bc + xor a, a + ld (hl), a + inc hl + ld (hl), a + inc hl + ld (hl), a + inc hl + ld (hl), a +;pff.c:755: if ((BYTE)*path < ' ') { /* Null path means the root directory */ + ld e, 8 (ix) + ld d, 9 (ix) + ld a, (de) + sub a, #0x20 + jp NC, l_follow_path_00130$ +;pff.c:756: res = dir_rewind(dj); + push bc + call _dir_rewind + pop af + ld a, l + ld e, a +;pff.c:757: dir[0] = 0; + ld c, 6 (ix) + ld b, 7 (ix) + xor a, a + ld (bc), a + jp l_follow_path_00117$ +l_follow_path_00130$: + inc sp + inc sp + push bc + ld a, 6 (ix) + ld -8 (ix), a + ld a, 7 (ix) + ld -7 (ix), a + ld -6 (ix), c + ld -5 (ix), b +l_follow_path_00118$: +;pff.c:761: res = create_name(dj, &path); /* Get a segment */ + ld hl, #18 + add hl, sp + push bc + push hl + push bc + call _create_name + pop af + pop af + ld a, l + pop bc + ld e, a +;pff.c:762: if (res != FR_OK) break; + ld a, e + or a, a + jp NZ, l_follow_path_00117$ +;pff.c:763: res = dir_find(dj, dir); /* Find it */ + push bc + ld l, 6 (ix) + ld h, 7 (ix) + push hl + push bc + call _dir_find + pop af + pop af + ld a, l + pop bc + ld e, a +;pff.c:764: if (res != FR_OK) break; /* Could not find the object */ + ld a, e + or a, a + jp NZ, l_follow_path_00117$ +;pff.c:765: if (dj->fn[11]) break; /* Last segment match. Function completed. */ + pop hl + push hl + inc hl + inc hl + ld d, (hl) + inc hl + ld h, (hl) + ld l, d + push bc + ld bc, #0x000b + add hl, bc + pop bc + ld a, (hl) + or a, a + jp NZ, l_follow_path_00117$ +;pff.c:766: if (!(dir[DIR_Attr] & AM_DIR)) { /* Cannot follow path because it is a file */ + ld l, -8 (ix) + ld h, -7 (ix) + ld de, #0x000b + add hl, de + ld a, (hl) + bit 4, a + jp NZ,l_follow_path_00172$ + jp l_follow_path_00173$ +l_follow_path_00172$: + jp l_follow_path_00113$ +l_follow_path_00173$: +;pff.c:767: res = FR_NO_FILE; break; + ld e, #0x03 + jp l_follow_path_00117$ +l_follow_path_00113$: +;pff.c:769: dj->sclust = get_clust(dir); /* Follow next */ + ld a, -6 (ix) + add a, #0x04 + ld e, a + ld a, -5 (ix) + adc a, #0x00 + ld d, a + push bc + push de + ld l, 6 (ix) + ld h, 7 (ix) + push hl + call _get_clust + pop af + ld -4 (ix), l + ld -3 (ix), h + ld -2 (ix), e + ld -1 (ix), d + pop de + pop bc + push bc + ld hl, #0x0008 + add hl, sp + ld bc, #0x0004 + ldir + pop bc + jp l_follow_path_00118$ +l_follow_path_00117$: +;pff.c:773: return res; + ld l, e +l_follow_path_00120$: +;pff.c:774: } + ld sp, ix + pop ix + ret +;pff.c:783: static BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:Not a boot record, 3:Error */ +; --------------------------------- +; Function check_fs +; --------------------------------- +_check_fs: + call ___sdcc_enter_ix +;pff.c:788: if (disk_readp(buf, sect, 510, 2)) { /* Read the boot record */ + ld hl, #0x0002 + push hl + ld hl, #0x01fe + push hl + ld l, 8 (ix) + ld h, 9 (ix) + push hl + ld l, 6 (ix) + ld h, 7 (ix) + push hl + ld l, 4 (ix) + ld h, 5 (ix) + push hl + call _disk_readp + ld iy, #10 + add iy, sp + ld sp, iy + ld a, l + or a, a + jp Z, l_check_fs_00102$ +;pff.c:789: return 3; + ld l, #0x03 + jp l_check_fs_00113$ +l_check_fs_00102$: +;pff.c:791: if (ld_word(buf) != 0xAA55) { /* Check record signature */ + ld l, 4 (ix) + ld h, 5 (ix) + push hl + call _ld_word + pop af + ld a, l + sub a, #0x55 + jp NZ,l_check_fs_00135$ + ld a, h + sub a, #0xaa + jp NZ,l_check_fs_00135$ + jp l_check_fs_00111$ +l_check_fs_00135$: +;pff.c:792: return 2; + ld l, #0x02 + jp l_check_fs_00113$ +;pff.c:798: if (PF_FS_FAT32 && !disk_readp(buf, sect, BS_FilSysType32, 2) && ld_word(buf) == 0x4146) { /* Check FAT32 */ +l_check_fs_00111$: + ld hl, #0x0002 + push hl + ld l, #0x52 + push hl + ld l, 8 (ix) + ld h, 9 (ix) + push hl + ld l, 6 (ix) + ld h, 7 (ix) + push hl + ld l, 4 (ix) + ld h, 5 (ix) + push hl + call _disk_readp + ld iy, #10 + add iy, sp + ld sp, iy + ld a, l + or a, a + jp NZ, l_check_fs_00110$ + ld l, 4 (ix) + ld h, 5 (ix) + push hl + call _ld_word + pop af + ld a, l + sub a, #0x46 + jp NZ,l_check_fs_00136$ + ld a, h + sub a, #0x41 + jp NZ,l_check_fs_00136$ + jp l_check_fs_00137$ +l_check_fs_00136$: + jp l_check_fs_00110$ +l_check_fs_00137$: +;pff.c:799: return 0; + ld l, #0x00 + jp l_check_fs_00113$ +l_check_fs_00110$: +;pff.c:801: return 1; + ld l, #0x01 +l_check_fs_00113$: +;pff.c:802: } + pop ix + ret +;pff.c:819: FRESULT pf_mount ( +; --------------------------------- +; Function pf_mount +; --------------------------------- +_pf_mount:: + call ___sdcc_enter_ix + ld hl, #-60 + add hl, sp + ld sp, hl +;pff.c:827: FatFs = 0; + ld hl, #0x0000 + ld (_FatFs), hl +;pff.c:828: if (disk_initialize() & STA_NOINIT) { /* Check if the drive is ready or not */ + call _disk_initialize + ld a, l + rrca + jp C,l_pf_mount_00194$ + jp l_pf_mount_00102$ +l_pf_mount_00194$: +;pff.c:829: return FR_NOT_READY; + ld l, #0x02 + jp l_pf_mount_00137$ +l_pf_mount_00102$: +;pff.c:833: bsect = 0; + xor a, a + ld -60 (ix), a + ld -59 (ix), a + ld -58 (ix), a + ld -57 (ix), a +;pff.c:834: fmt = check_fs(buf, bsect); /* Check sector 0 as an SFD format */ + ld hl, #4 + add hl, sp + ld -20 (ix), l + ld -19 (ix), h + ld c, -20 (ix) + ld b, -19 (ix) + ld hl, #0x0000 + push hl + ld hl, #0x0000 + push hl + push bc + call _check_fs + pop af + pop af + pop af + ld -5 (ix), l +;pff.c:840: if (buf[4]) { /* Is the partition existing? */ + ld a, -20 (ix) + add a, #0x04 + ld -2 (ix), a + ld a, -19 (ix) + adc a, #0x00 + ld -1 (ix), a +;pff.c:835: if (fmt == 1) { /* Not an FAT boot record, it may be FDISK format */ + ld a, -5 (ix) + dec a + jp NZ,l_pf_mount_00195$ + jp l_pf_mount_00196$ +l_pf_mount_00195$: + jp l_pf_mount_00109$ +l_pf_mount_00196$: +;pff.c:837: if (disk_readp(buf, bsect, MBR_Table, 16)) { /* 1st partition entry */ + ld a, -20 (ix) + ld -4 (ix), a + ld a, -19 (ix) + ld -3 (ix), a + ld hl, #0x0010 + push hl + ld hl, #0x01be + push hl + ld hl, #0x0000 + push hl + ld hl, #0x0000 + push hl + ld l, -4 (ix) + ld h, -3 (ix) + push hl + call _disk_readp + ld iy, #10 + add iy, sp + ld sp, iy + ld a, l + or a, a + jp Z, l_pf_mount_00106$ +;pff.c:838: fmt = 3; + ld -5 (ix), #0x03 + jp l_pf_mount_00109$ +l_pf_mount_00106$: +;pff.c:840: if (buf[4]) { /* Is the partition existing? */ + ld l, -2 (ix) + ld h, -1 (ix) + ld a, (hl) + or a, a + jp Z, l_pf_mount_00109$ +;pff.c:841: bsect = ld_dword(&buf[8]); /* Partition offset in LBA */ + ld a, -20 (ix) + add a, #0x08 + ld c, a + ld a, -19 (ix) + adc a, #0x00 + ld b, a + push bc + call _ld_dword + pop af + ld -60 (ix), l + ld -59 (ix), h + ld -58 (ix), e + ld -57 (ix), d +;pff.c:842: fmt = check_fs(buf, bsect); /* Check the partition */ + ld c, -20 (ix) + ld b, -19 (ix) + ld l, -58 (ix) + ld h, -57 (ix) + push hl + ld l, -60 (ix) + ld h, -59 (ix) + push hl + push bc + call _check_fs + pop af + pop af + pop af + ld -5 (ix), l +l_pf_mount_00109$: +;pff.c:846: if (fmt == 3) return FR_DISK_ERR; + ld a, -5 (ix) + sub a, #0x03 + jp NZ,l_pf_mount_00197$ + jp l_pf_mount_00198$ +l_pf_mount_00197$: + jp l_pf_mount_00111$ +l_pf_mount_00198$: + ld l, #0x01 + jp l_pf_mount_00137$ +l_pf_mount_00111$: +;pff.c:847: if (fmt) return FR_NO_FILESYSTEM; /* No valid FAT patition is found */ + ld a, -5 (ix) + or a, a + jp Z, l_pf_mount_00113$ + ld l, #0x06 + jp l_pf_mount_00137$ +l_pf_mount_00113$: +;pff.c:850: if (disk_readp(buf, bsect, 13, sizeof (buf))) return FR_DISK_ERR; + ld c, -20 (ix) + ld b, -19 (ix) + ld hl, #0x0024 + push hl + ld l, #0x0d + push hl + ld l, -58 (ix) + ld h, -57 (ix) + push hl + ld l, -60 (ix) + ld h, -59 (ix) + push hl + push bc + call _disk_readp + ld iy, #10 + add iy, sp + ld sp, iy + ld a, l + or a, a + jp Z, l_pf_mount_00115$ + ld l, #0x01 + jp l_pf_mount_00137$ +l_pf_mount_00115$: +;pff.c:852: fsize = ld_word(buf+BPB_FATSz16-13); /* Number of sectors per FAT */ + ld a, -20 (ix) + add a, #0x09 + ld c, a + ld a, -19 (ix) + adc a, #0x00 + ld b, a + push bc + call _ld_word + pop af + ld c, l + ld b, h + ld e, #0x00 + ld d, #0x00 +;pff.c:853: if (!fsize) fsize = ld_dword(buf+BPB_FATSz32-13); + ld a, d + or a, e + or a, b + or a, c + jp NZ, l_pf_mount_00117$ + ld a, -20 (ix) + add a, #0x17 + ld c, a + ld a, -19 (ix) + adc a, #0x00 + ld b, a + push bc + call _ld_dword + pop af + ld c, l + ld b, h +l_pf_mount_00117$: +;pff.c:855: fsize *= buf[BPB_NumFATs-13]; /* Number of sectors in FAT area */ + ld l, -20 (ix) + ld h, -19 (ix) + inc hl + inc hl + inc hl + ld a, (hl) + ld -6 (ix), a + xor a, a + ld -5 (ix), a + ld -4 (ix), a + ld -3 (ix), a + ld l, -4 (ix) + ld h, -3 (ix) + push hl + ld l, -6 (ix) + ld h, -5 (ix) + push hl + push de + push bc + call __mullong + pop af + pop af + pop af + pop af + ld -18 (ix), l + ld -17 (ix), h + ld -16 (ix), e + ld -15 (ix), d +;pff.c:856: fs->fatbase = bsect + ld_word(buf+BPB_RsvdSecCnt-13); /* FAT start sector (lba) */ + ld c, 4 (ix) + ld b, 5 (ix) + ld hl, #0x000a + add hl, bc + ld -14 (ix), l + ld -13 (ix), h + ld a, -20 (ix) + add a, #0x01 + ld -6 (ix), a + ld a, -19 (ix) + adc a, #0x00 + ld -5 (ix), a + ld e, -6 (ix) + ld d, -5 (ix) + push bc + push de + call _ld_word + pop af + pop bc + ld e, #0x00 + ld d, #0x00 + ld a, -60 (ix) + add a, l + ld -10 (ix), a + ld a, -59 (ix) + adc a, h + ld -9 (ix), a + ld a, -58 (ix) + adc a, e + ld -8 (ix), a + ld a, -57 (ix) + adc a, d + ld -7 (ix), a + push bc + ld e, -14 (ix) + ld d, -13 (ix) + ld hl, #0x0034 + add hl, sp + ld bc, #0x0004 + ldir + pop bc +;pff.c:857: fs->csize = buf[BPB_SecPerClus-13]; /* Number of sectors per cluster */ + ld hl, #0x0002 + add hl, bc + ld -12 (ix), l + ld -11 (ix), h + ld l, -20 (ix) + ld h, -19 (ix) + ld a, (hl) + ld l, -12 (ix) + ld h, -11 (ix) + ld (hl), a +;pff.c:858: fs->n_rootdir = ld_word(buf+BPB_RootEntCnt-13); /* Nmuber of root directory entries */ + ld hl, #0x0004 + add hl, bc + ld -10 (ix), l + ld -9 (ix), h + ld e, -2 (ix) + ld d, -1 (ix) + push bc + push de + call _ld_word + pop af + ld e, l + ld d, h + pop bc + ld l, -10 (ix) + ld h, -9 (ix) + ld (hl), e + inc hl + ld (hl), d +;pff.c:859: tsect = ld_word(buf+BPB_TotSec16-13); /* Number of sectors on the file system */ + ld a, -20 (ix) + add a, #0x06 + ld e, a + ld a, -19 (ix) + adc a, #0x00 + ld d, a + push bc + push de + call _ld_word + pop af + pop bc + ld e, #0x00 + ld d, #0x00 + ld -4 (ix), l + ld -3 (ix), h + ld -2 (ix), e + ld -1 (ix), d +;pff.c:860: if (!tsect) tsect = ld_dword(buf+BPB_TotSec32-13); + ld a, d + or a, e + or a, h + or a, l + jp NZ, l_pf_mount_00119$ + ld a, -20 (ix) + add a, #0x13 + ld e, a + ld a, -19 (ix) + adc a, #0x00 + ld d, a + push bc + push de + call _ld_dword + pop af + pop bc + ld -4 (ix), l + ld -3 (ix), h + ld -2 (ix), e + ld -1 (ix), d +l_pf_mount_00119$: +;pff.c:862: - ld_word(buf+BPB_RsvdSecCnt-13) - fsize - fs->n_rootdir / 16 + ld e, -6 (ix) + ld d, -5 (ix) + push bc + push de + call _ld_word + pop af + pop bc + ld e, #0x00 + ld d, #0x00 + ld a, -4 (ix) + sub a, l + ld l, a + ld a, -3 (ix) + sbc a, h + ld h, a + ld a, -2 (ix) + sbc a, e + ld e, a + ld a, -1 (ix) + sbc a, d + ld d, a + ld a, l + sub a, -18 (ix) + ld -8 (ix), a + ld a, h + sbc a, -17 (ix) + ld -7 (ix), a + ld a, e + sbc a, -16 (ix) + ld -6 (ix), a + ld a, d + sbc a, -15 (ix) + ld -5 (ix), a + ld l, -10 (ix) + ld h, -9 (ix) + ld e, (hl) + inc hl + ld d, (hl) + ld a, #0x04 +l_pf_mount_00199$: + srl d + rr e + dec a + jp NZ, l_pf_mount_00199$ + ld l, #0x00 + ld h, #0x00 + ld a, -8 (ix) + sub a, e + ld -4 (ix), a + ld a, -7 (ix) + sbc a, d + ld -3 (ix), a + ld a, -6 (ix) + sbc a, l + ld -2 (ix), a + ld a, -5 (ix) + sbc a, h + ld -1 (ix), a +;pff.c:863: ) / fs->csize + 2; + ld l, -12 (ix) + ld h, -11 (ix) + ld e, (hl) + ld d, #0x00 + ld l, #0x00 + ld h, #0x00 + push bc + push hl + push de + ld l, -2 (ix) + ld h, -1 (ix) + push hl + ld l, -4 (ix) + ld h, -3 (ix) + push hl + call __divulong + pop af + pop af + pop af + pop af + pop bc + ld a, l + add a, #0x02 + ld -4 (ix), a + ld a, h + adc a, #0x00 + ld -3 (ix), a + ld a, e + adc a, #0x00 + ld -2 (ix), a + ld a, d + adc a, #0x00 + ld -1 (ix), a +;pff.c:864: fs->n_fatent = (CLUST)mclst; + ld hl, #0x0006 + add hl, bc + ex de, hl + push bc + ld hl, #0x003a + add hl, sp + ld bc, #0x0004 + ldir + pop bc +;pff.c:866: fmt = 0; /* Determine the FAT sub type */ + ld e, #0x00 +;pff.c:869: if (PF_FS_FAT32 && mclst >= 0xFFF7) fmt = FS_FAT32; + ld a, -4 (ix) + sub a, #0xf7 + ld a, -3 (ix) + sbc a, #0xff + ld a, -2 (ix) + sbc a, #0x00 + ld a, -1 (ix) + sbc a, #0x00 + jp C, l_pf_mount_00128$ + ld e, #0x03 +l_pf_mount_00128$: +;pff.c:870: if (!fmt) return FR_NO_FILESYSTEM; + ld a, e + or a, a + jp NZ, l_pf_mount_00131$ + ld l, #0x06 + jp l_pf_mount_00137$ +l_pf_mount_00131$: +;pff.c:871: fs->fs_type = fmt; + ld a, e + ld (bc), a +;pff.c:874: fs->dirbase = ld_dword(buf+(BPB_RootClus-13)); /* Root directory start cluster */ + ld hl, #0x000e + add hl, bc + ex de, hl + ld a, -20 (ix) + add a, #0x1f + ld l, a + ld a, -19 (ix) + adc a, #0x00 + ld h, a + push bc + push de + push hl + call _ld_dword + pop af + ld -4 (ix), l + ld -3 (ix), h + ld -2 (ix), e + ld -1 (ix), d + pop de + pop bc + push bc + ld hl, #0x003a + add hl, sp + ld bc, #0x0004 + ldir + pop bc +;pff.c:878: fs->database = fs->fatbase + fsize + fs->n_rootdir / 16; /* Data start sector (lba) */ + ld hl, #0x0012 + add hl, bc + ld -2 (ix), l + ld -1 (ix), h + ld l, -14 (ix) + ld h, -13 (ix) + ld e, (hl) + inc hl + ld d, (hl) + inc hl + inc hl + ld a, (hl) + dec hl + ld l, (hl) + ld h, a + ld a, e + add a, -18 (ix) + ld -6 (ix), a + ld a, d + adc a, -17 (ix) + ld -5 (ix), a + ld a, l + adc a, -16 (ix) + ld -4 (ix), a + ld a, h + adc a, -15 (ix) + ld -3 (ix), a + ld l, -10 (ix) + ld h, -9 (ix) + ld e, (hl) + inc hl + ld d, (hl) + ld a, #0x04 +l_pf_mount_00200$: + srl d + rr e + dec a + jp NZ, l_pf_mount_00200$ + ld l, #0x00 + ld h, #0x00 + ld a, e + add a, -6 (ix) + ld -10 (ix), a + ld a, d + adc a, -5 (ix) + ld -9 (ix), a + ld a, l + adc a, -4 (ix) + ld -8 (ix), a + ld a, h + adc a, -3 (ix) + ld -7 (ix), a + push bc + ld e, -2 (ix) + ld d, -1 (ix) + ld hl, #0x0034 + add hl, sp + ld bc, #0x0004 + ldir + pop bc +;pff.c:880: fs->flag = 0; + ld e, c + ld d, b + inc de + xor a, a + ld (de), a +;pff.c:881: FatFs = fs; + ld (_FatFs), bc +;pff.c:883: return FR_OK; + ld l, #0x00 +l_pf_mount_00137$: +;pff.c:884: } + ld sp, ix + pop ix + ret +;pff.c:893: FRESULT pf_open ( +; --------------------------------- +; Function pf_open +; --------------------------------- +_pf_open:: + call ___sdcc_enter_ix + ld hl, #-68 + add hl, sp + ld sp, hl +;pff.c:900: FATFS *fs = FatFs; + ld bc, (_FatFs) +;pff.c:903: if (!fs) return FR_NOT_ENABLED; /* Check file system */ + ld a, b + or a, c + jp NZ, l_pf_open_00102$ + ld l, #0x05 + jp l_pf_open_00108$ +l_pf_open_00102$: +;pff.c:905: fs->flag = 0; + ld hl, #0x0001 + add hl, bc + ld -8 (ix), l + ld -7 (ix), h + ld l, -8 (ix) + ld h, -7 (ix) + ld (hl), #0x00 +;pff.c:906: dj.fn = sp; + ld hl, #0 + add hl, sp + ex de, hl + ld hl, #0x0002 + add hl, de + ld -4 (ix), l + ld -3 (ix), h + ld hl, #16 + add hl, sp + ld -2 (ix), l + ld -1 (ix), h + ld l, -4 (ix) + ld h, -3 (ix) + ld a, -2 (ix) + ld (hl), a + inc hl + ld a, -1 (ix) + ld (hl), a +;pff.c:907: res = follow_path(&dj, dir, path); /* Follow the file path */ + ld hl, #28 + add hl, sp + ld -6 (ix), l + ld -5 (ix), h + ld a, -6 (ix) + ld -2 (ix), a + ld a, -5 (ix) + ld -1 (ix), a + push bc + ld l, 4 (ix) + ld h, 5 (ix) + push hl + ld l, -2 (ix) + ld h, -1 (ix) + push hl + push de + call _follow_path + pop af + pop af + pop af + ld a, l + pop bc + ld l, a +;pff.c:908: if (res != FR_OK) return res; /* Follow failed */ + or a, a + jp Z, l_pf_open_00104$ + jp l_pf_open_00108$ +l_pf_open_00104$: +;pff.c:909: if (!dir[0] || (dir[DIR_Attr] & AM_DIR)) return FR_NO_FILE; /* It is a directory */ + ld l, -6 (ix) + ld h, -5 (ix) + ld a, (hl) + or a, a + jp Z, l_pf_open_00105$ + ld l, -6 (ix) + ld h, -5 (ix) + ld de, #0x000b + add hl, de + ld a, (hl) + bit 4, a + jp NZ,l_pf_open_00125$ + jp l_pf_open_00106$ +l_pf_open_00125$: +l_pf_open_00105$: + ld l, #0x03 + jp l_pf_open_00108$ +l_pf_open_00106$: +;pff.c:911: fs->org_clust = get_clust(dir); /* File start cluster */ + ld hl, #0x001e + add hl, bc + ex de, hl + ld l, -6 (ix) + ld h, -5 (ix) + push bc + push de + push hl + call _get_clust + pop af + ld -4 (ix), l + ld -3 (ix), h + ld -2 (ix), e + ld -1 (ix), d + pop de + pop bc + push bc + ld hl, #0x0042 + add hl, sp + ld bc, #0x0004 + ldir + pop bc +;pff.c:912: fs->fsize = ld_dword(dir+DIR_FileSize); /* File size */ + ld hl, #0x001a + add hl, bc + ex de, hl + ld a, -6 (ix) + add a, #0x1c + ld l, a + ld a, -5 (ix) + adc a, #0x00 + ld h, a + push bc + push de + push hl + call _ld_dword + pop af + ld -4 (ix), l + ld -3 (ix), h + ld -2 (ix), e + ld -1 (ix), d + pop de + pop bc + push bc + ld hl, #0x0042 + add hl, sp + ld bc, #0x0004 + ldir + pop bc +;pff.c:913: fs->fptr = 0; /* File pointer */ + ld hl, #0x0016 + add hl, bc + xor a, a + ld (hl), a + inc hl + ld (hl), a + inc hl + ld (hl), a + inc hl + ld (hl), a +;pff.c:914: fs->flag = FA_OPENED; + ld l, -8 (ix) + ld h, -7 (ix) + ld (hl), #0x01 +;pff.c:916: return FR_OK; + ld l, #0x00 +l_pf_open_00108$: +;pff.c:917: } + ld sp, ix + pop ix + ret +;pff.c:927: FRESULT pf_read ( +; --------------------------------- +; Function pf_read +; --------------------------------- +_pf_read:: + call ___sdcc_enter_ix + ld hl, #-34 + add hl, sp + ld sp, hl +;pff.c:937: BYTE cs, *rbuff = buff; + ld a, 4 (ix) + ld -2 (ix), a + ld a, 5 (ix) + ld -1 (ix), a +;pff.c:938: FATFS *fs = FatFs; + ld hl, (_FatFs) + ld -4 (ix), l + ld -3 (ix), h +;pff.c:941: *br = 0; + ld a, 8 (ix) + ld -30 (ix), a + ld a, 9 (ix) + ld -29 (ix), a + ld l, -30 (ix) + ld h, -29 (ix) + xor a, a + ld (hl), a + inc hl + ld (hl), a +;pff.c:942: if (!fs) return FR_NOT_ENABLED; /* Check file system */ + ld a, -3 (ix) + or a, -4 (ix) + jp NZ, l_pf_read_00102$ + ld l, #0x05 + jp l_pf_read_00127$ +l_pf_read_00102$: +;pff.c:943: if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ + ld a, -4 (ix) + add a, #0x01 + ld -28 (ix), a + ld a, -3 (ix) + adc a, #0x00 + ld -27 (ix), a + ld l, -28 (ix) + ld h, -27 (ix) + ld a, (hl) + rrca + jp C,l_pf_read_00194$ + jp l_pf_read_00195$ +l_pf_read_00194$: + jp l_pf_read_00104$ +l_pf_read_00195$: + ld l, #0x04 + jp l_pf_read_00127$ +l_pf_read_00104$: +;pff.c:945: remain = fs->fsize - fs->fptr; + ld a, -4 (ix) + ld -6 (ix), a + ld a, -3 (ix) + ld -5 (ix), a + ld l, -6 (ix) + ld h, -5 (ix) + ld de, #0x001a + add hl, de + ld a, (hl) + ld -16 (ix), a + inc hl + ld a, (hl) + ld -15 (ix), a + inc hl + ld a, (hl) + ld -14 (ix), a + inc hl + ld a, (hl) + ld -13 (ix), a + ld a, -4 (ix) + add a, #0x16 + ld -26 (ix), a + ld a, -3 (ix) + adc a, #0x00 + ld -25 (ix), a + ld e, -26 (ix) + ld d, -25 (ix) + ld hl, #0x0016 + add hl, sp + ex de, hl + ld bc, #0x0004 + ldir + ld a, -16 (ix) + sub a, -12 (ix) + ld -8 (ix), a + ld a, -15 (ix) + sbc a, -11 (ix) + ld -7 (ix), a + ld a, -14 (ix) + sbc a, -10 (ix) + ld -6 (ix), a + ld a, -13 (ix) + sbc a, -9 (ix) + ld -5 (ix), a +;pff.c:946: if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ + ld a, 6 (ix) + ld -12 (ix), a + ld a, 7 (ix) + ld -11 (ix), a + xor a, a + ld -10 (ix), a + ld -9 (ix), a + ld a, -8 (ix) + sub a, -12 (ix) + ld a, -7 (ix) + sbc a, -11 (ix) + ld a, -6 (ix) + sbc a, -10 (ix) + ld a, -5 (ix) + sbc a, -9 (ix) + jp NC, l_pf_read_00140$ + ld a, -8 (ix) + ld 6 (ix), a + ld a, -7 (ix) + ld 7 (ix), a +;pff.c:948: while (btr) { /* Repeat until all data transferred */ +l_pf_read_00140$: + ld a, -4 (ix) + add a, #0x22 + ld -24 (ix), a + ld a, -3 (ix) + adc a, #0x00 + ld -23 (ix), a + ld a, -4 (ix) + ld -22 (ix), a + ld a, -3 (ix) + ld -21 (ix), a + ld a, -4 (ix) + ld -20 (ix), a + ld a, -3 (ix) + ld -19 (ix), a + ld a, -4 (ix) + add a, #0x26 + ld -18 (ix), a + ld a, -3 (ix) + adc a, #0x00 + ld -17 (ix), a +l_pf_read_00124$: + ld a, 7 (ix) + or a, 6 (ix) + jp Z, l_pf_read_00126$ +;pff.c:949: if ((fs->fptr % 512) == 0) { /* On the sector boundary? */ + ld e, -26 (ix) + ld d, -25 (ix) + ld hl, #0x0019 + add hl, sp + ex de, hl + ld bc, #0x0004 + ldir + ld a, -9 (ix) + or a, a + jp NZ,l_pf_read_00196$ + bit 0, -8 (ix) + jp NZ,l_pf_read_00196$ + jp l_pf_read_00197$ +l_pf_read_00196$: + jp l_pf_read_00117$ +l_pf_read_00197$: +;pff.c:950: cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ + ld a, -8 (ix) + ld -13 (ix), a + ld a, -7 (ix) + ld -12 (ix), a + ld a, -6 (ix) + ld -11 (ix), a + xor a, a + ld -10 (ix), a + srl -11 (ix) + rr -12 (ix) + rr -13 (ix) + ld l, -20 (ix) + ld h, -19 (ix) + inc hl + inc hl + ld a, (hl) + ld -3 (ix), a + dec -3 (ix) + ld a, -3 (ix) + ld -5 (ix), a + ld a, -13 (ix) + ld -3 (ix), a + ld a, -3 (ix) + and a, -5 (ix) + ld -3 (ix), a + ld a, -3 (ix) + ld -4 (ix), a +;pff.c:951: if (!cs) { /* On the cluster boundary? */ + ld a, -3 (ix) + or a, a + jp NZ, l_pf_read_00113$ +;pff.c:952: if (fs->fptr == 0) { /* On the top of the file? */ + ld a, -6 (ix) + or a, -7 (ix) + or a, -8 (ix) + or a, -9 (ix) + jp NZ, l_pf_read_00108$ +;pff.c:953: clst = fs->org_clust; + ld l, -22 (ix) + ld h, -21 (ix) + ld de, #0x001e + add hl, de + ld a, (hl) + ld -8 (ix), a + inc hl + ld a, (hl) + ld -7 (ix), a + inc hl + ld a, (hl) + ld -6 (ix), a + inc hl + ld a, (hl) + ld -5 (ix), a + jp l_pf_read_00109$ +l_pf_read_00108$: +;pff.c:955: clst = get_fat(fs->curr_clust); + ld l, -24 (ix) + ld h, -23 (ix) + ld c, (hl) + inc hl + ld b, (hl) + inc hl + ld e, (hl) + inc hl + ld d, (hl) + push de + push bc + call _get_fat + pop af + pop af + ld -8 (ix), l + ld -7 (ix), h + ld -6 (ix), e + ld -5 (ix), d +l_pf_read_00109$: +;pff.c:957: if (clst <= 1) ABORT(FR_DISK_ERR); + ld a, #0x01 + cp a, -8 (ix) + ld a, #0x00 + sbc a, -7 (ix) + ld a, #0x00 + sbc a, -6 (ix) + ld a, #0x00 + sbc a, -5 (ix) + jp C, l_pf_read_00111$ + ld l, -28 (ix) + ld h, -27 (ix) + ld (hl), #0x00 + ld l, #0x01 + jp l_pf_read_00127$ +l_pf_read_00111$: +;pff.c:958: fs->curr_clust = clst; /* Update current cluster */ + ld e, -24 (ix) + ld d, -23 (ix) + ld hl, #0x001a + add hl, sp + ld bc, #0x0004 + ldir +l_pf_read_00113$: +;pff.c:960: sect = clust2sect(fs->curr_clust); /* Get current sector */ + ld e, -24 (ix) + ld d, -23 (ix) + ld hl, #0x001a + add hl, sp + ex de, hl + ld bc, #0x0004 + ldir + ld l, -6 (ix) + ld h, -5 (ix) + push hl + ld l, -8 (ix) + ld h, -7 (ix) + push hl + call _clust2sect + pop af + pop af + ld -8 (ix), l + ld -7 (ix), h + ld -6 (ix), e + ld -5 (ix), d + ld hl, #21 + add hl, sp + ex de, hl + ld hl, #26 + add hl, sp + ld bc, #4 + ldir +;pff.c:961: if (!sect) ABORT(FR_DISK_ERR); + ld a, -5 (ix) + or a, -6 (ix) + or a, -7 (ix) + or a, -8 (ix) + jp NZ, l_pf_read_00115$ + ld l, -28 (ix) + ld h, -27 (ix) + ld (hl), #0x00 + ld l, #0x01 + jp l_pf_read_00127$ +l_pf_read_00115$: +;pff.c:962: fs->dsect = sect + cs; + ld a, -4 (ix) + ld -9 (ix), a + xor a, a + ld -8 (ix), a + ld -7 (ix), a + ld -6 (ix), a + ld a, -13 (ix) + add a, -9 (ix) + ld -34 (ix), a + ld a, -12 (ix) + adc a, -8 (ix) + ld -33 (ix), a + ld a, -11 (ix) + adc a, -7 (ix) + ld -32 (ix), a + ld a, -10 (ix) + adc a, -6 (ix) + ld -31 (ix), a + ld e, -18 (ix) + ld d, -17 (ix) + ld hl, #0x0000 + add hl, sp + ld bc, #0x0004 + ldir +l_pf_read_00117$: +;pff.c:945: remain = fs->fsize - fs->fptr; + ld l, -26 (ix) + ld h, -25 (ix) + ld c, (hl) + inc hl + ld a, (hl) +;pff.c:964: rcnt = 512 - (UINT)fs->fptr % 512; /* Get partial sector data from sector buffer */ + ld -4 (ix), c + and a, #0x01 + ld -3 (ix), a + xor a, a + sub a, -4 (ix) + ld -16 (ix), a + ld a, #0x02 + sbc a, -3 (ix) + ld -15 (ix), a +;pff.c:965: if (rcnt > btr) rcnt = btr; + ld a, 6 (ix) + sub a, -16 (ix) + ld a, 7 (ix) + sbc a, -15 (ix) + jp NC, l_pf_read_00119$ + ld a, 6 (ix) + ld -16 (ix), a + ld a, 7 (ix) + ld -15 (ix), a +l_pf_read_00119$: +;pff.c:966: dr = disk_readp(rbuff, fs->dsect, (UINT)fs->fptr % 512, rcnt); + ld l, -18 (ix) + ld h, -17 (ix) + ld c, (hl) + inc hl + ld b, (hl) + inc hl + ld e, (hl) + inc hl + ld d, (hl) + ld l, -16 (ix) + ld h, -15 (ix) + push hl + ld l, -4 (ix) + ld h, -3 (ix) + push hl + push de + push bc + ld l, -2 (ix) + ld h, -1 (ix) + push hl + call _disk_readp + ld iy, #10 + add iy, sp + ld sp, iy + ld a, l +;pff.c:967: if (dr) ABORT(FR_DISK_ERR); + or a, a + jp Z, l_pf_read_00121$ + ld l, -28 (ix) + ld h, -27 (ix) + ld (hl), #0x00 + ld l, #0x01 + jp l_pf_read_00127$ +l_pf_read_00121$: +;pff.c:968: fs->fptr += rcnt; /* Advances file read pointer */ + ld e, -26 (ix) + ld d, -25 (ix) + ld hl, #0x0014 + add hl, sp + ex de, hl + ld bc, #0x0004 + ldir + ld a, -16 (ix) + ld -10 (ix), a + ld a, -15 (ix) + ld -9 (ix), a + xor a, a + ld -8 (ix), a + ld -7 (ix), a + ld a, -14 (ix) + add a, -10 (ix) + ld -6 (ix), a + ld a, -13 (ix) + adc a, -9 (ix) + ld -5 (ix), a + ld a, -12 (ix) + adc a, -8 (ix) + ld -4 (ix), a + ld a, -11 (ix) + adc a, -7 (ix) + ld -3 (ix), a + ld e, -26 (ix) + ld d, -25 (ix) + ld hl, #0x001c + add hl, sp + ld bc, #0x0004 + ldir +;pff.c:969: btr -= rcnt; *br += rcnt; /* Update read counter */ + ld a, 6 (ix) + sub a, -16 (ix) + ld 6 (ix), a + ld a, 7 (ix) + sbc a, -15 (ix) + ld 7 (ix), a + ld l, -30 (ix) + ld h, -29 (ix) + ld a, (hl) + ld -6 (ix), a + inc hl + ld a, (hl) + ld -5 (ix), a + ld a, -6 (ix) + add a, -16 (ix) + ld -4 (ix), a + ld a, -5 (ix) + adc a, -15 (ix) + ld -3 (ix), a + ld l, -30 (ix) + ld h, -29 (ix) + ld a, -4 (ix) + ld (hl), a + inc hl + ld a, -3 (ix) + ld (hl), a +;pff.c:970: if (rbuff) rbuff += rcnt; /* Advances the data pointer if destination is memory */ + ld a, -1 (ix) + or a, -2 (ix) + jp Z, l_pf_read_00124$ + ld a, -16 (ix) + add a, -2 (ix) + ld -2 (ix), a + ld a, -15 (ix) + adc a, -1 (ix) + ld -1 (ix), a + jp l_pf_read_00124$ +l_pf_read_00126$: +;pff.c:973: return FR_OK; + ld l, #0x00 +l_pf_read_00127$: +;pff.c:974: } + ld sp, ix + pop ix + ret +;pff.c:984: FRESULT pf_write ( +; --------------------------------- +; Function pf_write +; --------------------------------- +_pf_write:: + call ___sdcc_enter_ix + ld hl, #-27 + add hl, sp + ld sp, hl +;pff.c:992: const BYTE *p = buff; + ld a, 4 (ix) + ld -2 (ix), a + ld a, 5 (ix) + ld -1 (ix), a +;pff.c:995: FATFS *fs = FatFs; + ld hl, (_FatFs) + ld -23 (ix), l + ld -22 (ix), h +;pff.c:998: *bw = 0; + ld a, 8 (ix) + ld -21 (ix), a + ld a, 9 (ix) + ld -20 (ix), a + ld l, -21 (ix) + ld h, -20 (ix) + xor a, a + ld (hl), a + inc hl + ld (hl), a +;pff.c:999: if (!fs) return FR_NOT_ENABLED; /* Check file system */ + ld a, -22 (ix) + or a, -23 (ix) + jp NZ, l_pf_write_00102$ + ld l, #0x05 + jp l_pf_write_00139$ +l_pf_write_00102$: +;pff.c:1000: if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ + ld a, -23 (ix) + add a, #0x01 + ld -19 (ix), a + ld a, -22 (ix) + adc a, #0x00 + ld -18 (ix), a + ld l, -19 (ix) + ld h, -18 (ix) + ld a, (hl) + bit 0, a + jp NZ,l_pf_write_00236$ + jp l_pf_write_00237$ +l_pf_write_00236$: + jp l_pf_write_00104$ +l_pf_write_00237$: + ld l, #0x04 + jp l_pf_write_00139$ +l_pf_write_00104$: +;pff.c:1003: if ((fs->flag & FA__WIP) && disk_writep(0, 0)) ABORT(FR_DISK_ERR); + and a, #0x40 + ld c, a + ld b, #0x00 +;pff.c:1002: if (!btw) { /* Finalize request */ + ld a, 7 (ix) + or a, 6 (ix) + jp NZ, l_pf_write_00111$ +;pff.c:1003: if ((fs->flag & FA__WIP) && disk_writep(0, 0)) ABORT(FR_DISK_ERR); + ld a, b + or a, c + jp Z, l_pf_write_00106$ + ld hl, #0x0000 + push hl + ld hl, #0x0000 + push hl + ld l, #0x00 + push hl + call _disk_writep + pop af + pop af + pop af + ld a, l + or a, a + jp Z, l_pf_write_00106$ + ld l, -19 (ix) + ld h, -18 (ix) + ld (hl), #0x00 + ld l, #0x01 + jp l_pf_write_00139$ +l_pf_write_00106$: +;pff.c:1004: fs->flag &= ~FA__WIP; + ld l, -19 (ix) + ld h, -18 (ix) + ld a, (hl) + res 6, a + ld l, -19 (ix) + ld h, -18 (ix) + ld (hl), a +;pff.c:1005: return FR_OK; + ld l, #0x00 + jp l_pf_write_00139$ +l_pf_write_00111$: +;pff.c:1008: fs->fptr &= 0xFFFFFE00; + ld a, -23 (ix) + add a, #0x16 + ld -4 (ix), a + ld a, -22 (ix) + adc a, #0x00 + ld -3 (ix), a +;pff.c:1007: if (!(fs->flag & FA__WIP)) { /* Round-down fptr to the sector boundary */ + ld a, b + or a, c + jp NZ, l_pf_write_00112$ +;pff.c:1008: fs->fptr &= 0xFFFFFE00; + ld e, -4 (ix) + ld d, -3 (ix) + ld hl, #0x000f + add hl, sp + ex de, hl + ld bc, #0x0004 + ldir + ld -8 (ix), #0x00 + ld a, -11 (ix) + and a, #0xfe + ld -7 (ix), a + ld a, -10 (ix) + ld -6 (ix), a + ld a, -9 (ix) + ld -5 (ix), a + ld e, -4 (ix) + ld d, -3 (ix) + ld hl, #0x0013 + add hl, sp + ld bc, #0x0004 + ldir +l_pf_write_00112$: +;pff.c:1011: remain = fs->fsize - fs->fptr; + ld l, -23 (ix) + ld h, -22 (ix) + ld de, #0x001a + add hl, de + ld c, (hl) + inc hl + ld b, (hl) + inc hl + ld e, (hl) + inc hl + ld d, (hl) + ld a, -4 (ix) + ld -17 (ix), a + ld a, -3 (ix) + ld -16 (ix), a + push de + push bc + ld e, -4 (ix) + ld d, -3 (ix) + ld hl, #0x0019 + add hl, sp + ex de, hl + ld bc, #0x0004 + ldir + pop bc + pop de + ld a, c + sub a, -6 (ix) + ld c, a + ld a, b + sbc a, -5 (ix) + ld b, a + ld a, e + sbc a, -4 (ix) + ld e, a + ld a, d + sbc a, -3 (ix) + ld d, a +;pff.c:1012: if (btw > remain) btw = (UINT)remain; /* Truncate btw by remaining bytes */ + ld a, 6 (ix) + ld -6 (ix), a + ld a, 7 (ix) + ld -5 (ix), a + xor a, a + ld -4 (ix), a + ld -3 (ix), a + ld a, c + sub a, -6 (ix) + ld a, b + sbc a, -5 (ix) + ld a, e + sbc a, -4 (ix) + ld a, d + sbc a, -3 (ix) + jp NC, l_pf_write_00157$ + ld 6 (ix), c + ld 7 (ix), b +;pff.c:1014: while (btw) { /* Repeat until all data transferred */ +l_pf_write_00157$: + ld a, -23 (ix) + add a, #0x22 + ld -15 (ix), a + ld a, -22 (ix) + adc a, #0x00 + ld -14 (ix), a + ld a, -23 (ix) + ld -13 (ix), a + ld a, -22 (ix) + ld -12 (ix), a + ld a, -23 (ix) + ld -11 (ix), a + ld a, -22 (ix) + ld -10 (ix), a +l_pf_write_00136$: + ld a, 7 (ix) + or a, 6 (ix) + jp Z, l_pf_write_00138$ +;pff.c:1015: if ((UINT)fs->fptr % 512 == 0) { /* On the sector boundary? */ + ld l, -17 (ix) + ld h, -16 (ix) + ld c, (hl) + inc hl + ld b, (hl) + inc hl + ld e, (hl) + inc hl + ld d, (hl) + ld l, c + ld h, b + ld a, l + or a, a + jp NZ,l_pf_write_00238$ + bit 0, h + jp NZ,l_pf_write_00238$ + jp l_pf_write_00239$ +l_pf_write_00238$: + jp l_pf_write_00127$ +l_pf_write_00239$: +;pff.c:1016: cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ + ld -6 (ix), b + ld -5 (ix), e + ld -4 (ix), d + xor a, a + ld -3 (ix), a + srl -4 (ix) + rr -5 (ix) + rr -6 (ix) + ld l, -11 (ix) + ld h, -10 (ix) + inc hl + inc hl + ld l, (hl) + dec l + ld a, -6 (ix) + and a, l + ld -9 (ix), a +;pff.c:1017: if (!cs) { /* On the cluster boundary? */ + or a, a + jp NZ, l_pf_write_00121$ +;pff.c:1018: if (fs->fptr == 0) { /* On the top of the file? */ + ld a, d + or a, e + or a, b + or a, c + jp NZ, l_pf_write_00116$ +;pff.c:1019: clst = fs->org_clust; + ld l, -13 (ix) + ld h, -12 (ix) + ld de, #0x001e + add hl, de + ld a, (hl) + ld -6 (ix), a + inc hl + ld a, (hl) + ld -5 (ix), a + inc hl + ld a, (hl) + ld -4 (ix), a + inc hl + ld a, (hl) + ld -3 (ix), a + jp l_pf_write_00117$ +l_pf_write_00116$: +;pff.c:1021: clst = get_fat(fs->curr_clust); + ld l, -15 (ix) + ld h, -14 (ix) + ld c, (hl) + inc hl + ld b, (hl) + inc hl + ld e, (hl) + inc hl + ld d, (hl) + push de + push bc + call _get_fat + pop af + pop af + ld -6 (ix), l + ld -5 (ix), h + ld -4 (ix), e + ld -3 (ix), d +l_pf_write_00117$: +;pff.c:1023: if (clst <= 1) ABORT(FR_DISK_ERR); + ld a, #0x01 + cp a, -6 (ix) + ld a, #0x00 + sbc a, -5 (ix) + ld a, #0x00 + sbc a, -4 (ix) + ld a, #0x00 + sbc a, -3 (ix) + jp C, l_pf_write_00119$ + ld l, -19 (ix) + ld h, -18 (ix) + ld (hl), #0x00 + ld l, #0x01 + jp l_pf_write_00139$ +l_pf_write_00119$: +;pff.c:1024: fs->curr_clust = clst; /* Update current cluster */ + ld e, -15 (ix) + ld d, -14 (ix) + ld hl, #0x0015 + add hl, sp + ld bc, #0x0004 + ldir +l_pf_write_00121$: +;pff.c:1026: sect = clust2sect(fs->curr_clust); /* Get current sector */ + ld l, -15 (ix) + ld h, -14 (ix) + ld c, (hl) + inc hl + ld b, (hl) + inc hl + ld e, (hl) + inc hl + ld d, (hl) + push de + push bc + call _clust2sect + pop af + pop af + ld -8 (ix), l + ld -7 (ix), h + ld -6 (ix), e + ld -5 (ix), d +;pff.c:1027: if (!sect) ABORT(FR_DISK_ERR); + ld a, d + or a, e + or a, h + or a, l + jp NZ, l_pf_write_00123$ + ld l, -19 (ix) + ld h, -18 (ix) + ld (hl), #0x00 + ld l, #0x01 + jp l_pf_write_00139$ +l_pf_write_00123$: +;pff.c:1028: fs->dsect = sect + cs; + ld a, -23 (ix) + add a, #0x26 + ld -4 (ix), a + ld a, -22 (ix) + adc a, #0x00 + ld -3 (ix), a + ld c, -9 (ix) + ld b, #0x00 + ld e, #0x00 + ld d, #0x00 + ld a, -8 (ix) + add a, c + ld c, a + ld a, -7 (ix) + adc a, b + ld b, a + ld a, -6 (ix) + adc a, e + ld e, a + ld a, -5 (ix) + adc a, d + ld d, a + ld l, -4 (ix) + ld h, -3 (ix) + ld (hl), c + inc hl + ld (hl), b + inc hl + ld (hl), e + inc hl + ld (hl), d +;pff.c:1029: if (disk_writep(0, fs->dsect)) ABORT(FR_DISK_ERR); /* Initiate a sector write operation */ + push de + push bc + ld hl, #0x0000 + push hl + call _disk_writep + pop af + pop af + pop af + ld a, l + or a, a + jp Z, l_pf_write_00125$ + ld l, -19 (ix) + ld h, -18 (ix) + ld (hl), #0x00 + ld l, #0x01 + jp l_pf_write_00139$ +l_pf_write_00125$: +;pff.c:1030: fs->flag |= FA__WIP; + ld l, -19 (ix) + ld h, -18 (ix) + ld a, (hl) + set 6, a + ld l, -19 (ix) + ld h, -18 (ix) + ld (hl), a +l_pf_write_00127$: +;pff.c:1032: wcnt = 512 - (UINT)fs->fptr % 512; /* Number of bytes to write to the sector */ + ld l, -17 (ix) + ld h, -16 (ix) + ld c, (hl) + inc hl + ld a, (hl) + and a, #0x01 + ld b, a + xor a, a + sub a, c + ld c, a + ld a, #0x02 + sbc a, b + ld e, a +;pff.c:1033: if (wcnt > btw) wcnt = btw; + ld a, 6 (ix) + sub a, c + ld a, 7 (ix) + sbc a, e + jp NC, l_pf_write_00129$ + ld c, 6 (ix) + ld e, 7 (ix) +l_pf_write_00129$: +;pff.c:1034: if (disk_writep(p, wcnt)) ABORT(FR_DISK_ERR); /* Send data to the sector */ + ld -27 (ix), c + ld -26 (ix), e + xor a, a + ld -25 (ix), a + ld -24 (ix), a + push bc + push de + ld l, -25 (ix) + ld h, -24 (ix) + push hl + ld l, -27 (ix) + ld h, -26 (ix) + push hl + ld l, -2 (ix) + ld h, -1 (ix) + push hl + call _disk_writep + pop af + pop af + pop af + ld a, l + pop de + pop bc + or a, a + jp Z, l_pf_write_00131$ + ld l, -19 (ix) + ld h, -18 (ix) + ld (hl), #0x00 + ld l, #0x01 + jp l_pf_write_00139$ +l_pf_write_00131$: +;pff.c:1035: fs->fptr += wcnt; p += wcnt; /* Update pointers and counters */ + ld l, -17 (ix) + ld h, -16 (ix) + ld b, (hl) + inc hl + ld d, (hl) + inc hl + inc hl + ld a, (hl) + dec hl + ld l, (hl) + ld h, a + ld a, b + add a, -27 (ix) + ld -6 (ix), a + ld a, d + adc a, -26 (ix) + ld -5 (ix), a + ld a, l + adc a, -25 (ix) + ld -4 (ix), a + ld a, h + adc a, -24 (ix) + ld -3 (ix), a + push de + push bc + ld e, -17 (ix) + ld d, -16 (ix) + ld hl, #0x0019 + add hl, sp + ld bc, #0x0004 + ldir + pop bc + pop de + ld a, -2 (ix) + add a, c + ld -2 (ix), a + ld a, -1 (ix) + adc a, e + ld -1 (ix), a +;pff.c:1036: btw -= wcnt; *bw += wcnt; + ld a, 6 (ix) + sub a, c + ld 6 (ix), a + ld a, 7 (ix) + sbc a, e + ld 7 (ix), a + ld l, -21 (ix) + ld h, -20 (ix) + ld b, (hl) + inc hl + ld d, (hl) + ld a, b + add a, c + ld -8 (ix), a + ld a, d + adc a, e + ld -7 (ix), a + ld l, -21 (ix) + ld h, -20 (ix) + ld a, -8 (ix) + ld (hl), a + inc hl + ld a, -7 (ix) + ld (hl), a +;pff.c:1037: if ((UINT)fs->fptr % 512 == 0) { + ld a, -6 (ix) + ld -4 (ix), a + ld a, -5 (ix) + ld -3 (ix), a + ld a, -4 (ix) + or a, a + jp NZ,l_pf_write_00242$ + bit 0, -3 (ix) + jp NZ,l_pf_write_00242$ + jp l_pf_write_00243$ +l_pf_write_00242$: + jp l_pf_write_00136$ +l_pf_write_00243$: +;pff.c:1038: if (disk_writep(0, 0)) ABORT(FR_DISK_ERR); /* Finalize the currtent secter write operation */ + ld hl, #0x0000 + push hl + ld hl, #0x0000 + push hl + ld l, #0x00 + push hl + call _disk_writep + pop af + pop af + pop af + ld a, l + or a, a + jp Z, l_pf_write_00133$ + ld l, -19 (ix) + ld h, -18 (ix) + ld (hl), #0x00 + ld l, #0x01 + jp l_pf_write_00139$ +l_pf_write_00133$: +;pff.c:1039: fs->flag &= ~FA__WIP; + ld l, -19 (ix) + ld h, -18 (ix) + ld a, (hl) + res 6, a + ld l, -19 (ix) + ld h, -18 (ix) + ld (hl), a + jp l_pf_write_00136$ +l_pf_write_00138$: +;pff.c:1043: return FR_OK; + ld l, #0x00 +l_pf_write_00139$: +;pff.c:1044: } + ld sp, ix + pop ix + ret +;pff.c:1054: FRESULT pf_lseek ( +; --------------------------------- +; Function pf_lseek +; --------------------------------- +_pf_lseek:: + call ___sdcc_enter_ix + ld hl, #-26 + add hl, sp + ld sp, hl +;pff.c:1060: FATFS *fs = FatFs; + ld bc, (_FatFs) +;pff.c:1063: if (!fs) return FR_NOT_ENABLED; /* Check file system */ + ld a, b + or a, c + jp NZ, l_pf_lseek_00102$ + ld l, #0x05 + jp l_pf_lseek_00121$ +l_pf_lseek_00102$: +;pff.c:1064: if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ + ld hl, #0x0001 + add hl, bc + ld -22 (ix), l + ld -21 (ix), h + ld l, -22 (ix) + ld h, -21 (ix) + ld a, (hl) + rrca + jp C,l_pf_lseek_00173$ + jp l_pf_lseek_00174$ +l_pf_lseek_00173$: + jp l_pf_lseek_00104$ +l_pf_lseek_00174$: + ld l, #0x04 + jp l_pf_lseek_00121$ +l_pf_lseek_00104$: +;pff.c:1066: if (ofs > fs->fsize) ofs = fs->fsize; /* Clip offset with the file size */ + ld l, c + ld h, b + ld de, #0x001a + add hl, de + ld a, (hl) + ld -4 (ix), a + inc hl + ld a, (hl) + ld -3 (ix), a + inc hl + ld a, (hl) + ld -2 (ix), a + inc hl + ld a, (hl) + ld -1 (ix), a + ld a, -4 (ix) + sub a, 4 (ix) + ld a, -3 (ix) + sbc a, 5 (ix) + ld a, -2 (ix) + sbc a, 6 (ix) + ld a, -1 (ix) + sbc a, 7 (ix) + jp NC, l_pf_lseek_00106$ + push bc + ld hl, #32 + add hl, sp + ex de, hl + ld hl, #24 + add hl, sp + ld bc, #4 + ldir + pop bc +l_pf_lseek_00106$: +;pff.c:1067: ifptr = fs->fptr; + ld hl, #0x0016 + add hl, bc + ld -20 (ix), l + ld -19 (ix), h + push bc + ld e, -20 (ix) + ld d, -19 (ix) + ld hl, #0x0002 + add hl, sp + ex de, hl + ld bc, #0x0004 + ldir + pop bc +;pff.c:1068: fs->fptr = 0; + ld l, -20 (ix) + ld h, -19 (ix) + xor a, a + ld (hl), a + inc hl + ld (hl), a + inc hl + ld (hl), a + inc hl + ld (hl), a +;pff.c:1069: if (ofs > 0) { + ld a, 7 (ix) + or a, 6 (ix) + or a, 5 (ix) + or a, 4 (ix) + jp Z, l_pf_lseek_00120$ +;pff.c:1070: bcs = (DWORD)fs->csize * 512; /* Cluster size (byte) */ + ld hl, #0x0002 + add hl, bc + ld -18 (ix), l + ld -17 (ix), h + ld l, -18 (ix) + ld h, -17 (ix) + ld e, (hl) + ld d, #0x00 + ld l, #0x00 + ld h, #0x00 + ld -15 (ix), e + ld -14 (ix), d + ld -13 (ix), l + ld -16 (ix), #0x00 + sla -15 (ix) + rl -14 (ix) + rl -13 (ix) +;pff.c:1075: clst = fs->curr_clust; + ld hl, #0x0022 + add hl, bc + ld -12 (ix), l + ld -11 (ix), h +;pff.c:1071: if (ifptr > 0 && + ld a, -23 (ix) + or a, -24 (ix) + or a, -25 (ix) + or a, -26 (ix) + jp Z, l_pf_lseek_00108$ +;pff.c:1072: (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ + ld a, 4 (ix) + add a, #0xff + ld -4 (ix), a + ld a, 5 (ix) + adc a, #0xff + ld -3 (ix), a + ld a, 6 (ix) + adc a, #0xff + ld -2 (ix), a + ld a, 7 (ix) + adc a, #0xff + ld -1 (ix), a + push bc + ld l, -14 (ix) + ld h, -13 (ix) + push hl + ld l, -16 (ix) + ld h, -15 (ix) + push hl + ld l, -2 (ix) + ld h, -1 (ix) + push hl + ld l, -4 (ix) + ld h, -3 (ix) + push hl + call __divulong + pop af + pop af + pop af + pop af + ld -8 (ix), l + ld -7 (ix), h + ld -6 (ix), e + ld -5 (ix), d + pop bc + ld a, -26 (ix) + add a, #0xff + ld -4 (ix), a + ld a, -25 (ix) + adc a, #0xff + ld -3 (ix), a + ld a, -24 (ix) + adc a, #0xff + ld -2 (ix), a + ld a, -23 (ix) + adc a, #0xff + ld -1 (ix), a + push bc + ld l, -14 (ix) + ld h, -13 (ix) + push hl + ld l, -16 (ix) + ld h, -15 (ix) + push hl + ld l, -2 (ix) + ld h, -1 (ix) + push hl + ld l, -4 (ix) + ld h, -3 (ix) + push hl + call __divulong + pop af + pop af + pop af + pop af + pop bc + ld a, -8 (ix) + sub a, l + ld a, -7 (ix) + sbc a, h + ld a, -6 (ix) + sbc a, e + ld a, -5 (ix) + sbc a, d + jp C, l_pf_lseek_00108$ +;pff.c:1073: fs->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ + ld a, -16 (ix) + add a, #0xff + ld e, a + ld a, -15 (ix) + adc a, #0xff + ld d, a + ld a, -14 (ix) + adc a, #0xff + ld l, a + ld a, -13 (ix) + adc a, #0xff + cpl + ld h, a + ld a, e + cpl + push af + ld a, d + cpl + ld e, a + ld a, l + cpl + ld l, a + pop af + and a, -4 (ix) + ld -8 (ix), a + ld a, e + and a, -3 (ix) + ld -7 (ix), a + ld a, l + and a, -2 (ix) + ld -6 (ix), a + ld a, h + and a, -1 (ix) + ld -5 (ix), a + push bc + ld e, -20 (ix) + ld d, -19 (ix) + ld hl, #0x0014 + add hl, sp + ld bc, #0x0004 + ldir + pop bc +;pff.c:1074: ofs -= fs->fptr; + ld a, 4 (ix) + sub a, -8 (ix) + ld 4 (ix), a + ld a, 5 (ix) + sbc a, -7 (ix) + ld 5 (ix), a + ld a, 6 (ix) + sbc a, -6 (ix) + ld 6 (ix), a + ld a, 7 (ix) + sbc a, -5 (ix) + ld 7 (ix), a +;pff.c:1075: clst = fs->curr_clust; + push bc + ld e, -12 (ix) + ld d, -11 (ix) + ld hl, #0x0012 + add hl, sp + ex de, hl + ld bc, #0x0004 + ldir + pop bc + jp l_pf_lseek_00131$ +l_pf_lseek_00108$: +;pff.c:1077: clst = fs->org_clust; /* start from the first cluster */ + ld l, c + ld h, b + ld de, #0x001e + add hl, de + ld a, (hl) + ld -10 (ix), a + inc hl + ld a, (hl) + ld -9 (ix), a + inc hl + ld a, (hl) + ld -8 (ix), a + inc hl + ld a, (hl) + ld -7 (ix), a +;pff.c:1078: fs->curr_clust = clst; + push bc + ld e, -12 (ix) + ld d, -11 (ix) + ld hl, #0x0012 + add hl, sp + ld bc, #0x0004 + ldir + pop bc +;pff.c:1080: while (ofs > bcs) { /* Cluster following loop */ +l_pf_lseek_00131$: + ld -6 (ix), c + ld -5 (ix), b +l_pf_lseek_00114$: + ld a, -16 (ix) + sub a, 4 (ix) + ld a, -15 (ix) + sbc a, 5 (ix) + ld a, -14 (ix) + sbc a, 6 (ix) + ld a, -13 (ix) + sbc a, 7 (ix) + jp NC, l_pf_lseek_00116$ +;pff.c:1081: clst = get_fat(clst); /* Follow cluster chain */ + push bc + ld l, -8 (ix) + ld h, -7 (ix) + push hl + ld l, -10 (ix) + ld h, -9 (ix) + push hl + call _get_fat + pop af + pop af + pop bc + ld -10 (ix), l + ld -9 (ix), h + ld -8 (ix), e + ld -7 (ix), d +;pff.c:1082: if (clst <= 1 || clst >= fs->n_fatent) ABORT(FR_DISK_ERR); + ld a, #0x01 + cp a, -10 (ix) + ld a, #0x00 + sbc a, -9 (ix) + ld a, #0x00 + sbc a, -8 (ix) + ld a, #0x00 + sbc a, -7 (ix) + jp NC, l_pf_lseek_00111$ + ld l, -6 (ix) + ld h, -5 (ix) + ld de, #0x0006 + add hl, de + ld e, (hl) + inc hl + ld d, (hl) + inc hl + inc hl + ld a, (hl) + dec hl + ld l, (hl) + ld h, a + ld a, -10 (ix) + sub a, e + ld a, -9 (ix) + sbc a, d + ld a, -8 (ix) + sbc a, l + ld a, -7 (ix) + sbc a, h + jp C, l_pf_lseek_00112$ +l_pf_lseek_00111$: + ld l, -22 (ix) + ld h, -21 (ix) + ld (hl), #0x00 + ld l, #0x01 + jp l_pf_lseek_00121$ +l_pf_lseek_00112$: +;pff.c:1083: fs->curr_clust = clst; + push bc + ld e, -12 (ix) + ld d, -11 (ix) + ld hl, #0x0012 + add hl, sp + ld bc, #0x0004 + ldir + pop bc +;pff.c:1084: fs->fptr += bcs; + ld l, -20 (ix) + ld h, -19 (ix) + ld e, (hl) + inc hl + ld d, (hl) + inc hl + inc hl + ld a, (hl) + dec hl + ld l, (hl) + ld h, a + ld a, e + add a, -16 (ix) + ld -4 (ix), a + ld a, d + adc a, -15 (ix) + ld -3 (ix), a + ld a, l + adc a, -14 (ix) + ld -2 (ix), a + ld a, h + adc a, -13 (ix) + ld -1 (ix), a + push bc + ld e, -20 (ix) + ld d, -19 (ix) + ld hl, #0x0018 + add hl, sp + ld bc, #0x0004 + ldir + pop bc +;pff.c:1085: ofs -= bcs; + ld a, 4 (ix) + sub a, -16 (ix) + ld 4 (ix), a + ld a, 5 (ix) + sbc a, -15 (ix) + ld 5 (ix), a + ld a, 6 (ix) + sbc a, -14 (ix) + ld 6 (ix), a + ld a, 7 (ix) + sbc a, -13 (ix) + ld 7 (ix), a + jp l_pf_lseek_00114$ +l_pf_lseek_00116$: +;pff.c:1087: fs->fptr += ofs; + push bc + ld e, -20 (ix) + ld d, -19 (ix) + ld hl, #0x000e + add hl, sp + ex de, hl + ld bc, #0x0004 + ldir + pop bc + ld a, -14 (ix) + add a, 4 (ix) + ld -4 (ix), a + ld a, -13 (ix) + adc a, 5 (ix) + ld -3 (ix), a + ld a, -12 (ix) + adc a, 6 (ix) + ld -2 (ix), a + ld a, -11 (ix) + adc a, 7 (ix) + ld -1 (ix), a + push bc + ld e, -20 (ix) + ld d, -19 (ix) + ld hl, #0x0018 + add hl, sp + ld bc, #0x0004 + ldir + pop bc +;pff.c:1088: sect = clust2sect(clst); /* Current sector */ + push bc + ld l, -8 (ix) + ld h, -7 (ix) + push hl + ld l, -10 (ix) + ld h, -9 (ix) + push hl + call _clust2sect + pop af + pop af + pop bc + ld -4 (ix), l + ld -3 (ix), h + ld -2 (ix), e + ld -1 (ix), d +;pff.c:1089: if (!sect) ABORT(FR_DISK_ERR); + ld a, d + or a, e + or a, h + or a, l + jp NZ, l_pf_lseek_00118$ + ld l, -22 (ix) + ld h, -21 (ix) + ld (hl), #0x00 + ld l, #0x01 + jp l_pf_lseek_00121$ +l_pf_lseek_00118$: +;pff.c:1090: fs->dsect = sect + (fs->fptr / 512 & (fs->csize - 1)); + ld hl, #0x0026 + add hl, bc + ld -6 (ix), l + ld -5 (ix), h + ld l, -20 (ix) + ld h, -19 (ix) + ld c, (hl) + inc hl + ld b, (hl) + inc hl + ld d, (hl) + inc hl + ld e, (hl) + ld c, b + ld b, d + ld d, #0x00 + srl e + rr b + rr c + ld l, -18 (ix) + ld h, -17 (ix) + ld l, (hl) + ld h, #0x00 + dec hl + ld -10 (ix), l + ld a, h + ld -9 (ix), a + rla + sbc a, a + ld -8 (ix), a + ld -7 (ix), a + ld a, c + and a, -10 (ix) + ld c, a + ld a, b + and a, -9 (ix) + ld b, a + ld a, e + and a, -8 (ix) + ld e, a + ld a, d + and a, -7 (ix) + ld d, a + ld a, c + add a, -4 (ix) + ld c, a + ld a, b + adc a, -3 (ix) + ld b, a + ld a, e + adc a, -2 (ix) + ld e, a + ld a, d + adc a, -1 (ix) + ld d, a + ld l, -6 (ix) + ld h, -5 (ix) + ld (hl), c + inc hl + ld (hl), b + inc hl + ld (hl), e + inc hl + ld (hl), d +l_pf_lseek_00120$: +;pff.c:1093: return FR_OK; + ld l, #0x00 +l_pf_lseek_00121$: +;pff.c:1094: } + ld sp, ix + pop ix + ret +;pff.c:1104: FRESULT pf_opendir ( +; --------------------------------- +; Function pf_opendir +; --------------------------------- +_pf_opendir:: + call ___sdcc_enter_ix + ld hl, #-48 + add hl, sp + ld sp, hl +;pff.c:1114: if (!fs) { /* Check file system */ + ld iy, #_FatFs + ld a, 1 (iy) + or a, 0 (iy) + jp NZ, l_pf_opendir_00111$ +;pff.c:1115: res = FR_NOT_ENABLED; + ld c, #0x05 + jp l_pf_opendir_00112$ +l_pf_opendir_00111$: +;pff.c:1117: dj->fn = sp; + ld a, 4 (ix) + ld -2 (ix), a + ld a, 5 (ix) + ld -1 (ix), a + ld c, -2 (ix) + ld b, -1 (ix) + inc bc + inc bc + ld hl, #0 + add hl, sp + ex de, hl + ld a, e + ld (bc), a + inc bc + ld a, d + ld (bc), a +;pff.c:1118: res = follow_path(dj, dir, path); /* Follow the path to the directory */ + ld hl, #12 + add hl, sp + ex de, hl + ld c, e + ld b, d + push de + ld l, 6 (ix) + ld h, 7 (ix) + push hl + push bc + ld l, -2 (ix) + ld h, -1 (ix) + push hl + call _follow_path + pop af + pop af + pop af + ld a, l + pop de + ld c, a +;pff.c:1119: if (res == FR_OK) { /* Follow completed */ + ld a, c + or a, a + jp NZ, l_pf_opendir_00112$ +;pff.c:1120: if (dir[0]) { /* It is not the root dir */ + ld a, (de) + or a, a + jp Z, l_pf_opendir_00105$ +;pff.c:1121: if (dir[DIR_Attr] & AM_DIR) { /* The object is a directory */ + ld l, e + ld h, d + push bc + ld bc, #0x000b + add hl, bc + pop bc + ld a, (hl) + bit 4, a + jp NZ,l_pf_opendir_00140$ + jp l_pf_opendir_00102$ +l_pf_opendir_00140$: +;pff.c:1122: dj->sclust = get_clust(dir); + ld a, -2 (ix) + add a, #0x04 + ld l, a + ld a, -1 (ix) + adc a, #0x00 + ld h, a + push hl + push bc + push de + call _get_clust + pop af + ld -4 (ix), l + ld -3 (ix), h + ld -2 (ix), e + ld -1 (ix), d + pop bc + pop hl + push bc + ld e, l + ld d, h + ld hl, #0x002e + add hl, sp + ld bc, #0x0004 + ldir + pop bc + jp l_pf_opendir_00105$ +l_pf_opendir_00102$: +;pff.c:1124: res = FR_NO_FILE; + ld c, #0x03 +l_pf_opendir_00105$: +;pff.c:1127: if (res == FR_OK) { + ld a, c + or a, a + jp NZ, l_pf_opendir_00112$ +;pff.c:1128: res = dir_rewind(dj); /* Rewind dir */ + ld l, 4 (ix) + ld h, 5 (ix) + push hl + call _dir_rewind + pop af + ld a, l + ld c, a +l_pf_opendir_00112$: +;pff.c:1133: return res; + ld l, c +l_pf_opendir_00113$: +;pff.c:1134: } + ld sp, ix + pop ix + ret +;pff.c:1143: FRESULT pf_readdir ( +; --------------------------------- +; Function pf_readdir +; --------------------------------- +_pf_readdir:: + call ___sdcc_enter_ix + ld hl, #-46 + add hl, sp + ld sp, hl +;pff.c:1153: if (!fs) { /* Check file system */ + ld iy, #_FatFs + ld a, 1 (iy) + or a, 0 (iy) + jp NZ, l_pf_readdir_00111$ +;pff.c:1154: res = FR_NOT_ENABLED; + ld l, #0x05 + jp l_pf_readdir_00112$ +l_pf_readdir_00111$: +;pff.c:1156: dj->fn = sp; + ld c, 4 (ix) + ld b, 5 (ix) + ld e, c + ld d, b + inc de + inc de + ld hl, #0 + add hl, sp + ld -2 (ix), l + ld -1 (ix), h + ld a, -2 (ix) + ld (de), a + inc de + ld a, -1 (ix) + ld (de), a +;pff.c:1157: if (!fno) { + ld a, 7 (ix) + or a, 6 (ix) + jp NZ, l_pf_readdir_00108$ +;pff.c:1158: res = dir_rewind(dj); + push bc + call _dir_rewind + pop af + jp l_pf_readdir_00112$ +l_pf_readdir_00108$: +;pff.c:1160: res = dir_read(dj, dir); /* Get current directory item */ + ld hl, #12 + add hl, sp + ex de, hl + ld l, e + ld h, d + push bc + push de + push hl + push bc + call _dir_read + pop af + pop af + pop de + pop bc +;pff.c:1161: if (res == FR_NO_FILE) res = FR_OK; + ld a, l + sub a, #0x03 + jp NZ,l_pf_readdir_00140$ + jp l_pf_readdir_00141$ +l_pf_readdir_00140$: + jp l_pf_readdir_00102$ +l_pf_readdir_00141$: + ld l, #0x00 +l_pf_readdir_00102$: +;pff.c:1162: if (res == FR_OK) { /* A valid entry is found */ + ld a, l + or a, a + jp NZ, l_pf_readdir_00112$ +;pff.c:1163: get_fileinfo(dj, dir, fno); /* Get the object information */ + ld l, 6 (ix) + ld h, 7 (ix) + push hl + push de + push bc + call _get_fileinfo + pop af + pop af + pop af +;pff.c:1164: res = dir_next(dj); /* Increment read index for next */ + ld l, 4 (ix) + ld h, 5 (ix) + push hl + call _dir_next + pop af +;pff.c:1165: if (res == FR_NO_FILE) res = FR_OK; + ld a, l + sub a, #0x03 + jp NZ,l_pf_readdir_00142$ + jp l_pf_readdir_00143$ +l_pf_readdir_00142$: + jp l_pf_readdir_00112$ +l_pf_readdir_00143$: + ld l, #0x00 +l_pf_readdir_00112$: +;pff.c:1170: return res; +l_pf_readdir_00113$: +;pff.c:1171: } + ld sp, ix + pop ix + ret + .area _CODE + .area _INITIALIZER + .area _CABS (ABS) diff --git a/software/src/PetitFS/pff.c b/software/src/PetitFS/pff.c new file mode 100644 index 0000000..c2ad382 --- /dev/null +++ b/software/src/PetitFS/pff.c @@ -0,0 +1,1119 @@ +/*----------------------------------------------------------------------------/ +/ Petit FatFs - FAT file system module R0.03a +/-----------------------------------------------------------------------------/ +/ +/ Copyright (C) 2019, ChaN, all right reserved. +/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 +/ +/ Petit FatFs module is an open source software. Redistribution and use of +/ Petit FatFs in source and binary forms, with or without modification, are +/ permitted provided that the following condition is met: +/ +/ 1. Redistributions of source code must retain the above copyright notice, +/ this condition and the following disclaimer. +/ +/ This software is provided by the copyright holder and contributors "AS IS" +/ and any warranties related to this software are DISCLAIMED. +/ The copyright owner or contributors be NOT LIABLE for any damages caused +/ by use of this software. +/-----------------------------------------------------------------------------/ +/ Jun 15,'09 R0.01a First release. +/ +/ Dec 14,'09 R0.02 Added multiple code page support. +/ Added write funciton. +/ Changed stream read mode interface. +/ Dec 07,'10 R0.02a Added some configuration options. +/ Fixed fails to open objects with DBCS character. + +/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. +/ Added _USE_LCC option. +/ Added _FS_FAT16 option. +/ +/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. +/ Removed _WORD_ACCESS option. +/ Changed prefix of configuration options, _ to PF_. +/ Added some code pages. +/ Removed some code pages actually not valid. +/ +/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in +/ banked ROMS as part of the RFS on the Sharp MZ80A. +/----------------------------------------------------------------------------*/ + +#include +#include +#include "pff.h" /* Petit FatFs configurations and declarations */ +#include "sdmmc.h" /* Declarations of low level disk I/O functions */ + +/*-------------------------------------------------------------------------- + + Module Private Definitions + +---------------------------------------------------------------------------*/ + + +#if PF_DEFINED != 8088 /* Revision ID */ +#error Wrong include file (pff.h). +#endif + +#define _FS_32ONLY 1 + +#define ABORT(err) {fs->flag = 0; return err;} + + + +/*--------------------------------------------------------*/ +/* DBCS code ranges and SBCS extend char conversion table */ +/*--------------------------------------------------------*/ + +#if PF_USE_LCC == 0 /* ASCII upper case character only */ + +#elif PF_CODE_PAGE == 932 /* Japanese Shift-JIS */ +#define _DF1S 0x81 /* DBC 1st byte range 1 start */ +#define _DF1E 0x9F /* DBC 1st byte range 1 end */ +#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ +#define _DF2E 0xFC /* DBC 1st byte range 2 end */ +#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ +#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ +#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ +#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ + +#elif PF_CODE_PAGE == 936 /* Simplified Chinese GBK */ +#define _DF1S 0x81 +#define _DF1E 0xFE +#define _DS1S 0x40 +#define _DS1E 0x7E +#define _DS2S 0x80 +#define _DS2E 0xFE + +#elif PF_CODE_PAGE == 949 /* Korean */ +#define _DF1S 0x81 +#define _DF1E 0xFE +#define _DS1S 0x41 +#define _DS1E 0x5A +#define _DS2S 0x61 +#define _DS2E 0x7A +#define _DS3S 0x81 +#define _DS3E 0xFE + +#elif PF_CODE_PAGE == 950 /* Traditional Chinese Big5 */ +#define _DF1S 0x81 +#define _DF1E 0xFE +#define _DS1S 0x40 +#define _DS1E 0x7E +#define _DS2S 0xA1 +#define _DS2E 0xFE + +#elif PF_CODE_PAGE == 437 /* U.S. */ +#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ + 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 720 /* Arabic */ +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 737 /* Greek */ +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ + 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xEF,0xF5,0xF0,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 771 /* KBL */ +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDC,0xDE,0xDE, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFE,0xFF} + +#elif PF_CODE_PAGE == 775 /* Baltic */ +#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F, \ + 0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ + 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 850 /* Latin 1 */ +#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x41,0x43,0x45,0x45,0x45,0x49,0x49,0x49,0x41,0x41, \ + 0x45,0x92,0x92,0x4F,0x4F,0x4F,0x55,0x55,0x59,0x4F,0x55,0x4F,0x9C,0x4F,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0x41,0x41,0x41,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0x41,0x41,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD1,0xD1,0x45,0x45,0x45,0x49,0x49,0x49,0x49,0xD9,0xDA,0xDB,0xDC,0xDD,0x49,0xDF, \ + 0x4F,0xE1,0x4F,0x4F,0x4F,0x4F,0xE6,0xE8,0xE8,0x55,0x55,0x55,0x59,0x59,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 852 /* Latin 2 */ +#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0xAC, \ + 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} + +#elif PF_CODE_PAGE == 855 /* Cyrillic */ +#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F, \ + 0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ + 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ + 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF, \ + 0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 857 /* Turkish */ +#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x49,0x8E,0x8F, \ + 0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ + 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0x49,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0xED,0xEE,0xEF, \ + +#elif PF_CODE_PAGE == 860 /* Portuguese */ +#define _EXCVT {0x80,0x9A,0x90,0x8F,0x8E,0x91,0x86,0x80,0x89,0x89,0x92,0x8B,0x8C,0x98,0x8E,0x8F, \ + 0x90,0x91,0x92,0x8C,0x99,0xA9,0x96,0x9D,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x86,0x8B,0x9F,0x96,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 861 /* Icelandic */ +#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x8B,0x8B,0x8D,0x8E,0x8F, \ + 0x90,0x92,0x92,0x4F,0x99,0x8D,0x55,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ + 0xA4,0xA5,0xA6,0xA7,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 862 /* Hebrew */ +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 863 /* Canadian French */ +#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x41,0x8F, \ + 0x45,0x45,0x45,0x4F,0x45,0x49,0x55,0x55,0x98,0x4F,0x55,0x9B,0x9C,0x55,0x55,0x9F, \ + 0xA0,0xA1,0x4F,0x55,0xA4,0xA5,0xA6,0xA7,0x49,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 864 /* Arabic */ +#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ + 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 865 /* Nordic */ +#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ + 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 866 /* Russian */ +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 869 /* Greek 2 */ +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x86,0x9C,0x8D,0x8F,0x90, \ + 0x91,0x90,0x92,0x95,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xA4,0xA5,0xA6,0xD9,0xDA,0xDB,0xDC,0xA7,0xA8,0xDF, \ + 0xA9,0xAA,0xAC,0xAD,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xCF,0xCF,0xD0,0xEF, \ + 0xF0,0xF1,0xD1,0xD2,0xD3,0xF5,0xD4,0xF7,0xF8,0xF9,0xD5,0x96,0x95,0x98,0xFE,0xFF} + +#else +#error Unknown code page. + +#endif + + + +/* Character code support macros */ + +#define IsUpper(c) (((c)>='A')&&((c)<='Z')) +#define IsLower(c) (((c)>='a')&&((c)<='z')) + +#if PF_USE_LCC && !defined(_EXCVT) /* DBCS configuration */ + +#ifdef _DF2S /* Two 1st byte areas */ +#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) +#else /* One 1st byte area */ +#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) +#endif + +#ifdef _DS3S /* Three 2nd byte areas */ +#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) +#else /* Two 2nd byte areas */ +#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) +#endif + +#else /* SBCS configuration */ + +#define IsDBCS1(c) 0 +#define IsDBCS2(c) 0 + +#endif /* _EXCVT */ + + +/* FatFs refers the members in the FAT structures with byte offset instead +/ of structure member because there are incompatibility of the packing option +/ between various compilers. */ + +#define BS_jmpBoot 0 +#define BS_OEMName 3 +#define BPB_BytsPerSec 11 +#define BPB_SecPerClus 13 +#define BPB_RsvdSecCnt 14 +#define BPB_NumFATs 16 +#define BPB_RootEntCnt 17 +#define BPB_TotSec16 19 +#define BPB_Media 21 +#define BPB_FATSz16 22 +#define BPB_SecPerTrk 24 +#define BPB_NumHeads 26 +#define BPB_HiddSec 28 +#define BPB_TotSec32 32 +#define BS_55AA 510 + +#define BS_DrvNum 36 +#define BS_BootSig 38 +#define BS_VolID 39 +#define BS_VolLab 43 +#define BS_FilSysType 54 + +#define BPB_FATSz32 36 +#define BPB_ExtFlags 40 +#define BPB_FSVer 42 +#define BPB_RootClus 44 +#define BPB_FSInfo 48 +#define BPB_BkBootSec 50 +#define BS_DrvNum32 64 +#define BS_BootSig32 66 +#define BS_VolID32 67 +#define BS_VolLab32 71 +#define BS_FilSysType32 82 + +#define MBR_Table 446 + +#define DIR_Name 0 +#define DIR_Attr 11 +#define DIR_NTres 12 +#define DIR_CrtTime 14 +#define DIR_CrtDate 16 +#define DIR_FstClusHI 20 +#define DIR_WrtTime 22 +#define DIR_WrtDate 24 +#define DIR_FstClusLO 26 +#define DIR_FileSize 28 + + + + +/*-------------------------------------------------------------------------- + + Private Functions + +---------------------------------------------------------------------------*/ + + +static FATFS *FatFs; /* Pointer to the file system object (logical drive) */ + + +/*-----------------------------------------------------------------------*/ +/* Load multi-byte word in the FAT structure */ +/*-----------------------------------------------------------------------*/ + +static WORD ld_word (const BYTE* ptr) /* Load a 2-byte little-endian word */ +{ + WORD rv; + + rv = ptr[1]; + rv = rv << 8 | ptr[0]; + return rv; +} + +static DWORD ld_dword (const BYTE* ptr) /* Load a 4-byte little-endian word */ +{ + DWORD rv; + + rv = ptr[3]; + rv = rv << 8 | ptr[2]; + rv = rv << 8 | ptr[1]; + rv = rv << 8 | ptr[0]; + return rv; +} + + + +/*-----------------------------------------------------------------------*/ +/* String functions */ +/*-----------------------------------------------------------------------*/ + +/* Fill memory block */ +static void mem_set (void* dst, int val, int cnt) { + char *d = (char*)dst; + while (cnt--) *d++ = (char)val; +} + +/* Compare memory block */ +static int mem_cmp (const void* dst, const void* src, int cnt) { + const char *d = (const char *)dst, *s = (const char *)src; + int r = 0; + while (cnt-- && (r = *d++ - *s++) == 0) ; + return r; +} + + + +/*-----------------------------------------------------------------------*/ +/* FAT access - Read value of a FAT entry */ +/*-----------------------------------------------------------------------*/ + +static CLUST get_fat ( /* 1:IO error, Else:Cluster status */ + CLUST clst /* Cluster# to get the link information */ +) +{ + BYTE buf[4]; + FATFS *fs = FatFs; + + if (clst < 2 || clst >= fs->n_fatent) return 1; /* Range check */ + + switch (fs->fs_type) { + case FS_FAT32 : + if (disk_readp(buf, fs->fatbase + clst / 128, ((UINT)clst % 128) * 4, 4)) break; + return ld_dword(buf) & 0x0FFFFFFF; + } + + return 1; /* An error occured at the disk I/O layer */ +} + + + + +/*-----------------------------------------------------------------------*/ +/* Get sector# from cluster# / Get cluster field from directory entry */ +/*-----------------------------------------------------------------------*/ + +static DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ + CLUST clst /* Cluster# to be converted */ +) +{ + FATFS *fs = FatFs; + + clst -= 2; + if (clst >= (fs->n_fatent - 2)) return 0; /* Invalid cluster# */ + return (DWORD)clst * fs->csize + fs->database; +} + + +static CLUST get_clust ( + BYTE* dir /* Pointer to directory entry */ +) +{ + FATFS *fs = FatFs; + CLUST clst = 0; + + + clst = ld_word(dir+DIR_FstClusHI); + clst <<= 16; + clst |= ld_word(dir+DIR_FstClusLO); + + return clst; +} + + +/*-----------------------------------------------------------------------*/ +/* Directory handling - Rewind directory index */ +/*-----------------------------------------------------------------------*/ + +static FRESULT dir_rewind ( + DIR *dj /* Pointer to directory object */ +) +{ + CLUST clst; + FATFS *fs = FatFs; + + + dj->index = 0; + clst = dj->sclust; + if (clst == 1 || clst >= fs->n_fatent) { /* Check start cluster range */ + return FR_DISK_ERR; + } + if(!clst) + { + clst = (CLUST)fs->dirbase; + } + dj->clust = clst; /* Current cluster */ + dj->sect = clust2sect(clst); /* Current sector */ + return FR_OK; /* Seek succeeded */ +} + + + + +/*-----------------------------------------------------------------------*/ +/* Directory handling - Move directory index next */ +/*-----------------------------------------------------------------------*/ + +static FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table */ + DIR *dj /* Pointer to directory object */ +) +{ + CLUST clst; + WORD i; + FATFS *fs = FatFs; + + + i = dj->index + 1; + if (!i || !dj->sect) return FR_NO_FILE; /* Report EOT when index has reached 65535 */ + + if (!(i % 16)) { /* Sector changed? */ + dj->sect++; /* Next sector */ + + if (dj->clust == 0) { /* Static table */ + if (i >= fs->n_rootdir) return FR_NO_FILE; /* Report EOT when end of table */ + } + else { /* Dynamic table */ + if (((i / 16) & (fs->csize - 1)) == 0) { /* Cluster changed? */ + clst = get_fat(dj->clust); /* Get next cluster */ + if (clst <= 1) return FR_DISK_ERR; + if (clst >= fs->n_fatent) return FR_NO_FILE; /* Report EOT when it reached end of dynamic table */ + dj->clust = clst; /* Initialize data for new cluster */ + dj->sect = clust2sect(clst); + } + } + } + + dj->index = i; + + return FR_OK; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Directory handling - Find an object in the directory */ +/*-----------------------------------------------------------------------*/ + +static FRESULT dir_find ( + DIR *dj, /* Pointer to the directory object linked to the file name */ + BYTE *dir /* 32-byte working buffer */ +) +{ + FRESULT res; + BYTE c; + + + res = dir_rewind(dj); /* Rewind directory object */ + if (res != FR_OK) return res; + + do { + res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ + ? FR_DISK_ERR : FR_OK; + if (res != FR_OK) break; + c = dir[DIR_Name]; /* First character */ + if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ + if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dj->fn, 11)) break; /* Is it a valid entry? */ + res = dir_next(dj); /* Next entry */ + } while (res == FR_OK); + + return res; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Read an object from the directory */ +/*-----------------------------------------------------------------------*/ +static FRESULT dir_read ( + DIR *dj, /* Pointer to the directory object to store read object name */ + BYTE *dir /* 32-byte working buffer */ +) +{ + FRESULT res; + BYTE a, c; + + + res = FR_NO_FILE; + while (dj->sect) { + + res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ + ? FR_DISK_ERR : FR_OK; + if (res != FR_OK) break; + c = dir[DIR_Name]; + if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ + a = dir[DIR_Attr] & AM_MASK; + if (c != 0xE5 && c != '.' && !(a & AM_VOL)) break; /* Is it a valid entry? */ + res = dir_next(dj); /* Next entry */ + if (res != FR_OK) break; + } + + if (res != FR_OK) dj->sect = 0; + + return res; +} + + +/*-----------------------------------------------------------------------*/ +/* Pick a segment and create the object name in directory form */ +/*-----------------------------------------------------------------------*/ + + +static FRESULT create_name ( + DIR *dj, /* Pointer to the directory object */ + const char **path /* Pointer to pointer to the segment in the path string */ +) +{ + BYTE c, d, ni, si, i, *sfn; + const char *p; +#if PF_USE_LCC && defined(_EXCVT) + static const BYTE cvt[] = _EXCVT; +#endif + + /* Create file name in directory form */ + sfn = dj->fn; + mem_set(sfn, ' ', 11); + si = i = 0; ni = 8; + p = *path; + for (;;) { + c = p[si++]; + if (c <= ' ' || c == '/') break; /* Break on end of segment */ + if (c == '.' || i >= ni) { + if (ni != 8 || c != '.') break; + i = 8; ni = 11; + continue; + } +#if PF_USE_LCC && defined(_EXCVT) + if (c >= 0x80) c = cvt[c - 0x80]; /* To upper extended char (SBCS) */ +#endif + if (IsDBCS1(c) && i < ni - 1) { /* DBC 1st byte? */ + d = p[si++]; /* Get 2nd byte */ + sfn[i++] = c; + sfn[i++] = d; + } else { /* Single byte code */ + if (PF_USE_LCC && IsLower(c)) c -= 0x20; /* toupper */ + sfn[i++] = c; + } + } + *path = &p[si]; /* Rerurn pointer to the next segment */ + + sfn[11] = (c <= ' ') ? 1 : 0; /* Set last segment flag if end of path */ + + return FR_OK; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Get file information from directory entry */ +/*-----------------------------------------------------------------------*/ +static void get_fileinfo ( /* No return code */ + DIR *dj, /* Pointer to the directory object */ + BYTE *dir, /* 32-byte working buffer */ + FILINFO *fno /* Pointer to store the file information */ +) +{ + BYTE i, c; + char *p; + + + p = fno->fname; + if (dj->sect) { + for (i = 0; i < 8; i++) { /* Copy file name body */ + c = dir[i]; + if (c == ' ') break; + if (c == 0x05) c = 0xE5; + *p++ = c; + } + if (dir[8] != ' ') { /* Copy file name extension */ + *p++ = '.'; + for (i = 8; i < 11; i++) { + c = dir[i]; + if (c == ' ') break; + *p++ = c; + } + } + fno->fattrib = dir[DIR_Attr]; /* Attribute */ + fno->fsize = ld_dword(dir+DIR_FileSize); /* Size */ + fno->fdate = ld_word(dir+DIR_WrtDate); /* Date */ + fno->ftime = ld_word(dir+DIR_WrtTime); /* Time */ + } + *p = 0; +} + + +/*-----------------------------------------------------------------------*/ +/* Follow a file path */ +/*-----------------------------------------------------------------------*/ + +static FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ + DIR *dj, /* Directory object to return last directory and found object */ + BYTE *dir, /* 32-byte working buffer */ + const char *path /* Full-path string to find a file or directory */ +) +{ + FRESULT res; + + + while (*path == ' ') path++; /* Strip leading spaces */ + if (*path == '/') path++; /* Strip heading separator if exist */ + dj->sclust = 0; /* Set start directory (always root dir) */ + + if ((BYTE)*path < ' ') { /* Null path means the root directory */ + res = dir_rewind(dj); + dir[0] = 0; + + } else { /* Follow path */ + for (;;) { + res = create_name(dj, &path); /* Get a segment */ + if (res != FR_OK) break; + res = dir_find(dj, dir); /* Find it */ + if (res != FR_OK) break; /* Could not find the object */ + if (dj->fn[11]) break; /* Last segment match. Function completed. */ + if (!(dir[DIR_Attr] & AM_DIR)) { /* Cannot follow path because it is a file */ + res = FR_NO_FILE; break; + } + dj->sclust = get_clust(dir); /* Follow next */ + } + } + + return res; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Check a sector if it is an FAT boot record */ +/*-----------------------------------------------------------------------*/ + +static BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:Not a boot record, 3:Error */ + BYTE *buf, /* Working buffer */ + DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ +) +{ + if (disk_readp(buf, sect, 510, 2)) { /* Read the boot record */ + return 3; + } + if (ld_word(buf) != 0xAA55) { /* Check record signature */ + return 2; + } + +// if (!_FS_32ONLY && !disk_readp(buf, sect, BS_FilSysType, 2) && ld_word(buf) == 0x4146) { /* Check FAT12/16 */ +// return 0; +// } + if (!disk_readp(buf, sect, BS_FilSysType32, 2) && ld_word(buf) == 0x4146) { /* Check FAT32 */ + return 0; + } + return 1; +} + + + + +/*-------------------------------------------------------------------------- + + Public Functions + +--------------------------------------------------------------------------*/ + + + +/*-----------------------------------------------------------------------*/ +/* Mount/Unmount a Locical Drive */ +/*-----------------------------------------------------------------------*/ + +FRESULT pf_mount ( + FATFS *fs /* Pointer to new file system object */ +) +{ + BYTE fmt, buf[36]; + DWORD bsect, fsize, tsect, mclst; + + + FatFs = 0; + if (disk_initialize() & STA_NOINIT) { /* Check if the drive is ready or not */ + return FR_NOT_READY; + } + + /* Search FAT partition on the drive */ + bsect = 0; + fmt = check_fs(buf, bsect); /* Check sector 0 as an SFD format */ + if (fmt == 1) { /* Not an FAT boot record, it may be FDISK format */ + /* Check a partition listed in top of the partition table */ + if (disk_readp(buf, bsect, MBR_Table, 16)) { /* 1st partition entry */ + fmt = 3; + } else { + if (buf[4]) { /* Is the partition existing? */ + bsect = ld_dword(&buf[8]); /* Partition offset in LBA */ + fmt = check_fs(buf, bsect); /* Check the partition */ + } + } + } + if (fmt == 3) return FR_DISK_ERR; + if (fmt) return FR_NO_FILESYSTEM; /* No valid FAT patition is found */ + + /* Initialize the file system object */ + if (disk_readp(buf, bsect, 13, sizeof (buf))) return FR_DISK_ERR; + + fsize = ld_word(buf+BPB_FATSz16-13); /* Number of sectors per FAT */ + if (!fsize) fsize = ld_dword(buf+BPB_FATSz32-13); + + fsize *= buf[BPB_NumFATs-13]; /* Number of sectors in FAT area */ + fs->fatbase = bsect + ld_word(buf+BPB_RsvdSecCnt-13); /* FAT start sector (lba) */ + fs->csize = buf[BPB_SecPerClus-13]; /* Number of sectors per cluster */ + fs->n_rootdir = ld_word(buf+BPB_RootEntCnt-13); /* Nmuber of root directory entries */ + tsect = ld_word(buf+BPB_TotSec16-13); /* Number of sectors on the file system */ + if (!tsect) tsect = ld_dword(buf+BPB_TotSec32-13); + mclst = (tsect /* Last cluster# + 1 */ + - ld_word(buf+BPB_RsvdSecCnt-13) - fsize - fs->n_rootdir / 16 + ) / fs->csize + 2; + fs->n_fatent = (CLUST)mclst; + + fmt = 0; /* Determine the FAT sub type */ + if (mclst >= 0xFFF7) fmt = FS_FAT32; + if (!fmt) return FR_NO_FILESYSTEM; + fs->fs_type = fmt; + +// if (_FS_32ONLY || (PF_FS_FAT32 && fmt == FS_FAT32)) { + fs->dirbase = ld_dword(buf+(BPB_RootClus-13)); /* Root directory start cluster */ +// } else { +// fs->dirbase = fs->fatbase + fsize; /* Root directory start sector (lba) */ +// } + fs->database = fs->fatbase + fsize + fs->n_rootdir / 16; /* Data start sector (lba) */ + + fs->flag = 0; + FatFs = fs; + + return FR_OK; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Open or Create a File */ +/*-----------------------------------------------------------------------*/ + +FRESULT pf_open ( + const char *path /* Pointer to the file name */ +) +{ + FRESULT res; + DIR dj; + BYTE sp[12], dir[32]; + FATFS *fs = FatFs; + + + if (!fs) return FR_NOT_ENABLED; /* Check file system */ + + fs->flag = 0; + dj.fn = sp; + res = follow_path(&dj, dir, path); /* Follow the file path */ + if (res != FR_OK) return res; /* Follow failed */ + if (!dir[0] || (dir[DIR_Attr] & AM_DIR)) return FR_NO_FILE; /* It is a directory */ + + fs->org_clust = get_clust(dir); /* File start cluster */ + fs->fsize = ld_dword(dir+DIR_FileSize); /* File size */ + fs->fptr = 0; /* File pointer */ + fs->flag = FA_OPENED; + + return FR_OK; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Read File */ +/*-----------------------------------------------------------------------*/ +FRESULT pf_read ( + void* buff, /* Pointer to the read buffer (NULL:Forward data to the stream)*/ + UINT btr, /* Number of bytes to read */ + UINT* br /* Pointer to number of bytes read */ +) +{ + DRESULT dr; + CLUST clst; + DWORD sect, remain; + UINT rcnt; + BYTE cs, *rbuff = buff; + FATFS *fs = FatFs; + + + *br = 0; + if (!fs) return FR_NOT_ENABLED; /* Check file system */ + if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ + + remain = fs->fsize - fs->fptr; + if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ + + while (btr) { /* Repeat until all data transferred */ + if ((fs->fptr % 512) == 0) { /* On the sector boundary? */ + cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ + if (!cs) { /* On the cluster boundary? */ + if (fs->fptr == 0) { /* On the top of the file? */ + clst = fs->org_clust; + } else { + clst = get_fat(fs->curr_clust); + } + if (clst <= 1) ABORT(FR_DISK_ERR); + fs->curr_clust = clst; /* Update current cluster */ + } + sect = clust2sect(fs->curr_clust); /* Get current sector */ + if (!sect) ABORT(FR_DISK_ERR); + fs->dsect = sect + cs; + } + rcnt = 512 - (UINT)fs->fptr % 512; /* Get partial sector data from sector buffer */ + if (rcnt > btr) rcnt = btr; + dr = disk_readp(rbuff, fs->dsect, (UINT)fs->fptr % 512, rcnt); + if (dr) ABORT(FR_DISK_ERR); + fs->fptr += rcnt; /* Advances file read pointer */ + btr -= rcnt; *br += rcnt; /* Update read counter */ + if (rbuff) rbuff += rcnt; /* Advances the data pointer if destination is memory */ + } + + return FR_OK; +} + + +/*-----------------------------------------------------------------------*/ +/* Write File */ +/*-----------------------------------------------------------------------*/ +FRESULT pf_write ( + const void* buff, /* Pointer to the data to be written */ + UINT btw, /* Number of bytes to write (0:Finalize the current write operation) */ + UINT* bw /* Pointer to number of bytes written */ +) +{ + CLUST clst; + DWORD sect, remain; + const BYTE *p = buff; + BYTE cs; + UINT wcnt; + FATFS *fs = FatFs; + + + *bw = 0; + if (!fs) return FR_NOT_ENABLED; /* Check file system */ + if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ + + if (!btw) { /* Finalize request */ + if ((fs->flag & FA__WIP) && disk_writep(0, 0)) ABORT(FR_DISK_ERR); + fs->flag &= ~FA__WIP; + return FR_OK; + } else { /* Write data request */ + if (!(fs->flag & FA__WIP)) { /* Round-down fptr to the sector boundary */ + fs->fptr &= 0xFFFFFE00; + } + } + remain = fs->fsize - fs->fptr; + if (btw > remain) btw = (UINT)remain; /* Truncate btw by remaining bytes */ + + while (btw) { /* Repeat until all data transferred */ + if ((UINT)fs->fptr % 512 == 0) { /* On the sector boundary? */ + cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ + if (!cs) { /* On the cluster boundary? */ + if (fs->fptr == 0) { /* On the top of the file? */ + clst = fs->org_clust; + } else { + clst = get_fat(fs->curr_clust); + } + if (clst <= 1) ABORT(FR_DISK_ERR); + fs->curr_clust = clst; /* Update current cluster */ + } + sect = clust2sect(fs->curr_clust); /* Get current sector */ + if (!sect) ABORT(FR_DISK_ERR); + fs->dsect = sect + cs; + if (disk_writep(0, fs->dsect)) ABORT(FR_DISK_ERR); /* Initiate a sector write operation */ + fs->flag |= FA__WIP; + } + wcnt = 512 - (UINT)fs->fptr % 512; /* Number of bytes to write to the sector */ + if (wcnt > btw) wcnt = btw; + if (disk_writep(p, wcnt)) ABORT(FR_DISK_ERR); /* Send data to the sector */ + fs->fptr += wcnt; p += wcnt; /* Update pointers and counters */ + btw -= wcnt; *bw += wcnt; + if ((UINT)fs->fptr % 512 == 0) { + if (disk_writep(0, 0)) ABORT(FR_DISK_ERR); /* Finalize the currtent secter write operation */ + fs->flag &= ~FA__WIP; + } + } + + return FR_OK; +} + + +/*-----------------------------------------------------------------------*/ +/* Seek File R/W Pointer */ +/*-----------------------------------------------------------------------*/ +#if PF_USE_LSEEK + +FRESULT pf_lseek ( + DWORD ofs /* File pointer from top of file */ +) +{ + CLUST clst; + DWORD bcs, sect, ifptr; + FATFS *fs = FatFs; + + + if (!fs) return FR_NOT_ENABLED; /* Check file system */ + if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ + + if (ofs > fs->fsize) ofs = fs->fsize; /* Clip offset with the file size */ + ifptr = fs->fptr; + fs->fptr = 0; + if (ofs > 0) { + bcs = (DWORD)fs->csize * 512; /* Cluster size (byte) */ + if (ifptr > 0 && + (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ + fs->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ + ofs -= fs->fptr; + clst = fs->curr_clust; + } else { /* When seek to back cluster, */ + clst = fs->org_clust; /* start from the first cluster */ + fs->curr_clust = clst; + } + while (ofs > bcs) { /* Cluster following loop */ + clst = get_fat(clst); /* Follow cluster chain */ + if (clst <= 1 || clst >= fs->n_fatent) ABORT(FR_DISK_ERR); + fs->curr_clust = clst; + fs->fptr += bcs; + ofs -= bcs; + } + fs->fptr += ofs; + sect = clust2sect(clst); /* Current sector */ + if (!sect) ABORT(FR_DISK_ERR); + fs->dsect = sect + (fs->fptr / 512 & (fs->csize - 1)); + } + + return FR_OK; +} +#endif + + + +/*-----------------------------------------------------------------------*/ +/* Create a Directroy Object */ +/*-----------------------------------------------------------------------*/ +FRESULT pf_opendir ( + DIR *dj, /* Pointer to directory object to create */ + const char *path /* Pointer to the directory path */ +) +{ + FRESULT res; + BYTE sp[12], dir[32]; + FATFS *fs = FatFs; + + + if (!fs) { /* Check file system */ + res = FR_NOT_ENABLED; + } else { + dj->fn = sp; + res = follow_path(dj, dir, path); /* Follow the path to the directory */ + if (res == FR_OK) { /* Follow completed */ + if (dir[0]) { /* It is not the root dir */ + if (dir[DIR_Attr] & AM_DIR) { /* The object is a directory */ + dj->sclust = get_clust(dir); + } else { /* The object is not a directory */ + res = FR_NO_FILE; + } + } + if (res == FR_OK) { + res = dir_rewind(dj); /* Rewind dir */ + } + } + } + + return res; +} + + + +/*-----------------------------------------------------------------------*/ +/* Read Directory Entry in Sequense */ +/*-----------------------------------------------------------------------*/ + +FRESULT pf_readdir ( + DIR *dj, /* Pointer to the open directory object */ + FILINFO *fno /* Pointer to file information to return */ +) +{ + FRESULT res; + BYTE sp[12], dir[32]; + FATFS *fs = FatFs; + + + if (!fs) { /* Check file system */ + res = FR_NOT_ENABLED; + } else { + dj->fn = sp; + if (!fno) { + res = dir_rewind(dj); + } else { + res = dir_read(dj, dir); /* Get current directory item */ + // if (res == FR_NO_FILE) res = FR_OK; + if (res == FR_OK) { /* A valid entry is found */ + get_fileinfo(dj, dir, fno); /* Get the object information */ + res = dir_next(dj); /* Increment read index for next */ + if (res == FR_NO_FILE) res = FR_OK; + } + } + } + + return res; +} diff --git a/software/src/PetitFS/pff.c.asm b/software/src/PetitFS/pff.c.asm new file mode 100644 index 0000000..df6ceee --- /dev/null +++ b/software/src/PetitFS/pff.c.asm @@ -0,0 +1,4033 @@ +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Fri Mar 13 16:31:35 2020 + + + + MODULE pff_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION code_compiler + +; Function ld_word flags 0x00000200 __smallc +; unsigned int WORDld_word(const unsigned char BYTE*ptr) +; parameter 'const unsigned char BYTE*ptr' at 2 size(2) +._ld_word + push bc + ld hl,4 ;const + add hl,sp + call l_gint ; + inc hl + ld l,(hl) + ld h,0 + pop bc + push hl + ld h,l + ld l,0 + push hl + ld hl,6 ;const + add hl,sp + call l_gint ; + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop bc + ret + + + +; Function ld_dword flags 0x00000200 __smallc +; unsigned long DWORDld_dword(const unsigned char BYTE*ptr) +; parameter 'const unsigned char BYTE*ptr' at 2 size(2) +._ld_dword + push bc + push bc + ld hl,0 ;const + add hl,sp + push hl + ld hl,8 ;const + add hl,sp + call l_gint ; + inc hl + inc hl + inc hl + ld l,(hl) + ld h,0 + ld de,0 + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + ld a,(hl) + inc hl + ld e,(hl) + inc hl + ld d,(hl) + ld h,a + ld l,0 + push de + push hl + ld hl,12 ;const + add hl,sp + call l_gint ; + inc hl + inc hl + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + ld a,(hl) + inc hl + ld e,(hl) + inc hl + ld d,(hl) + ld h,a + ld l,0 + push de + push hl + ld hl,12 ;const + add hl,sp + call l_gint ; + inc hl + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + ld a,(hl) + inc hl + ld e,(hl) + inc hl + ld d,(hl) + ld h,a + ld l,0 + push de + push hl + ld hl,12 ;const + add hl,sp + call l_gint ; + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + call l_glong + pop bc + pop bc + ret + + + +; Function mem_set flags 0x00000200 __smallc +; void mem_set(void *dst, int val, int cnt) +; parameter 'int cnt' at 2 size(2) +; parameter 'int val' at 4 size(2) +; parameter 'void *dst' at 6 size(2) +._mem_set + ld hl,6 ;const + add hl,sp + call l_gint ; + push hl +.i_2 + ld hl,4 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + inc hl + ld a,h + or l + jp z,i_3 + pop hl + inc hl + push hl + dec hl + push hl + ld hl,8 ;const + add hl,sp + call l_gint ; + ld a,l + call l_sxt + ld a,l + call l_sxt + pop de + ld a,l + ld (de),a + jp i_2 +.i_3 + pop bc + ret + + + +; Function mem_cmp flags 0x00000200 __smallc +; int mem_cmp(const void *dst, const void *src, int cnt) +; parameter 'int cnt' at 2 size(2) +; parameter 'const void *src' at 4 size(2) +; parameter 'const void *dst' at 6 size(2) +._mem_cmp + ld hl,6 ;const + call l_g2intspsp ; + ld hl,0 ;const + push hl +.i_4 + ld hl,8 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + inc hl + ld a,h + or l + jp z,i_6 + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + call l_gchar + push hl + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + call l_gchar + pop de + ex de,hl + and a + sbc hl,de + pop bc + push hl + ld a,h + or l + jp nz,i_6 + inc hl + jr i_7 +.i_6 + ld hl,0 ;const +.i_7 + ld a,h + or l + jp nz,i_4 +.i_5 + pop hl + pop bc + pop bc + ret + + + +; Function get_fat flags 0x00000200 __smallc +; unsigned long DWORDget_fat(unsigned long clst) +; parameter 'unsigned long clst' at 2 size(4) +._get_fat + push bc + push bc + ld hl,(_FatFs) + push hl + ld hl,8 ;const + add hl,sp + call l_glong + ld a,l + sub 2 + ld a,h + sbc 0 + ld a,e + sbc 0 + ld a,d + sbc 0 + jp c,i_9 + ld hl,8 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + add hl,sp + call l_gint ; + ld bc,6 + add hl,bc + call l_glong + call l_long_uge + jp nc,i_8 +.i_9 + ld hl,1 ;const + ld de,0 + pop bc + pop bc + pop bc + ret + + +.i_8 + pop hl + push hl + ld l,(hl) + ld h,0 +.i_13 + ld a,l + cp +(3% 256) + jp nz,i_12 +.i_14 + ld hl,2 ;const + add hl,sp + push hl + dec hl + dec hl + call l_gint ; + ld bc,10 + add hl,bc + call l_glong2sp + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld l,+(7 % 256) + call l_long_asr_u + call l_long_add + push de + push hl + ld hl,14 ;const + add hl,sp + call l_glong + ld a,l + and +(127 % 256) + ld l,a + ld h,0 + add hl,hl + add hl,hl + push hl + ld hl,4 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp nz,i_12 +.i_15 + ld hl,2 ;const + add hl,sp + push hl + call _ld_dword + pop bc + ld a,d + and +(15 % 256) + ld d,a + pop bc + pop bc + pop bc + ret + + +.i_12 + ld hl,1 ;const + ld de,0 + pop bc + pop bc + pop bc + ret + + + +; Function clust2sect flags 0x00000200 __smallc +; unsigned long DWORDclust2sect(unsigned long clst) +; parameter 'unsigned long clst' at 2 size(4) +._clust2sect + ld hl,(_FatFs) + push hl + ld hl,4 ;const + add hl,sp + push hl + call l_glong + ld bc,65534 + add hl,bc + jr c,ASMPC+3 + dec de + pop bc + call l_plong + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + add hl,sp + call l_gint ; + ld bc,6 + add hl,bc + call l_glong + ld bc,65534 + add hl,bc + jr c,ASMPC+3 + dec de + call l_long_uge + jp nc,i_16 + ld hl,0 ;const + ld d,h + ld e,l + pop bc + ret + + +.i_16 + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + add hl,sp + call l_gint ; + inc hl + inc hl + ld l,(hl) + ld h,0 + ld de,0 + call l_long_mult + push de + push hl + ld hl,4 ;const + add hl,sp + call l_gint ; + ld bc,18 + add hl,bc + call l_glong + call l_long_add + pop bc + ret + + + +; Function get_clust flags 0x00000200 __smallc +; unsigned long DWORDget_clust(unsigned char BYTE*dir) +; parameter 'unsigned char BYTE*dir' at 2 size(2) +._get_clust + ld hl,(_FatFs) + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + ld hl,0 ;const + add hl,sp + push hl + ld hl,10 ;const + add hl,sp + call l_gint ; + ld bc,20 + add hl,bc + push hl + call _ld_word + pop bc + ld de,0 + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + call l_glong + ex de,hl + ld hl,0 ;const + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + call l_glong2sp + ld hl,14 ;const + add hl,sp + call l_gint ; + ld bc,26 + add hl,bc + push hl + call _ld_word + pop bc + pop de + call l_or + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + call l_glong + pop bc + pop bc + pop bc + ret + + + +; Function dir_rewind flags 0x00000200 __smallc +; const int FRESULTdir_rewind(struct 0__anonstruct_5 DIR*dj) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 2 size(2) +._dir_rewind + push bc + push bc + ld hl,(_FatFs) + push hl + ld hl,8 ;const + add hl,sp + ld a,(hl) + inc hl + ld h,(hl) + ld l,a + xor a + ld (hl),a + inc hl + ld (hl),a + ld hl,2 ;const + add hl,sp + push hl + ld hl,10 ;const + add hl,sp + call l_gint ; + ld bc,4 + add hl,bc + call l_glong + pop bc + call l_plong + ld hl,2 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_eq + jp c,i_18 + ld hl,2 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + add hl,sp + call l_gint ; + ld bc,6 + add hl,bc + call l_glong + call l_long_uge + jp nc,i_17 +.i_18 + ld hl,1 ;const + pop bc + pop bc + pop bc + ret + + +.i_17 + ld hl,2 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_20 + ld hl,2 ;const + add hl,sp + push hl + dec hl + dec hl + call l_gint ; + ld bc,14 + add hl,bc + call l_glong + pop bc + call l_plong +.i_20 + ld hl,8 ;const + add hl,sp + call l_gint ; + ld bc,8 + add hl,bc + push hl + ld hl,4 ;const + add hl,sp + call l_glong + pop bc + call l_plong + ld hl,8 ;const + add hl,sp + call l_gint ; + ld bc,12 + add hl,bc + push hl + jp i_21 + ld hl,4 ;const + add hl,sp + call l_glong + ld a,h + or l + or d + or e + jp nz,i_21 + ld hl,0 ;const + jr i_22 +.i_21 + ld hl,1 ;const +.i_22 + jp nc,i_23 + ld hl,4 ;const + add hl,sp + call l_glong + push de + push hl + call _clust2sect + pop bc + pop bc + jp i_24 +.i_23 + pop bc + pop hl + push hl + push bc + ld bc,14 + add hl,bc + call l_glong +.i_24 + pop bc + call l_plong + ld hl,8 ;const + add hl,sp + call l_gint ; + ld bc,12 + add hl,bc + push hl + ld hl,4 ;const + add hl,sp + call l_glong + push de + push hl + call _clust2sect + pop bc + pop bc + pop bc + call l_plong + ld hl,0 ;const + pop bc + pop bc + pop bc + ret + + + +; Function dir_next flags 0x00000200 __smallc +; const int FRESULTdir_next(struct 0__anonstruct_5 DIR*dj) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 2 size(2) +._dir_next + push bc + push bc + push bc + ld hl,(_FatFs) + push hl + ld hl,10 ;const + add hl,sp + call l_gint ; + call l_gint ; + inc hl + pop de + pop bc + push hl + push de + call l_lneg + jp c,i_26 + ld hl,10 ;const + add hl,sp + call l_gint ; + ld bc,12 + add hl,bc + call l_glong + call l_long_lneg + jp nc,i_25 +.i_26 + ld hl,3 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_25 + pop bc + pop hl + push hl + push bc + ld a,l + and +(15 % 256) + jp nz,i_28 + ld hl,10 ;const + add hl,sp + call l_gint ; + ld bc,12 + add hl,bc + push hl + call l_glong + call l_inclong + pop bc + call l_plong + ld hl,10 ;const + add hl,sp + call l_gint ; + ld bc,8 + add hl,bc + call l_glong + ld a,d + or e + or h + or l + jp nz,i_29 + ld hl,2 ;const + call l_gintspsp ; + pop bc + pop hl + push hl + push bc + ld bc,4 + add hl,bc + call l_gint ; + pop de + call l_uge + jp nc,i_30 + ld hl,3 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_30 + jp i_31 +.i_29 + pop bc + pop hl + push hl + push bc + ld de,4 + call l_asr_u_hl_by_e + pop de + push de + push hl + ex de,hl + inc hl + inc hl + ld l,(hl) + ld h,0 + dec hl + pop de + call l_and + ld a,h + or l + jp nz,i_32 + ld hl,4 ;const + add hl,sp + push hl + ld hl,12 ;const + add hl,sp + call l_gint ; + ld bc,8 + add hl,bc + call l_glong + push de + push hl + call _get_fat + pop bc + pop bc + pop bc + call l_plong + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_ule + jp nc,i_33 + ld hl,1 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_33 + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + add hl,sp + call l_gint ; + ld bc,6 + add hl,bc + call l_glong + call l_long_uge + jp nc,i_34 + ld hl,3 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_34 + ld hl,10 ;const + add hl,sp + call l_gint ; + ld bc,8 + add hl,bc + push hl + ld hl,6 ;const + add hl,sp + call l_glong + pop bc + call l_plong + ld hl,10 ;const + add hl,sp + call l_gint ; + ld bc,12 + add hl,bc + push hl + ld hl,6 ;const + add hl,sp + call l_glong + push de + push hl + call _clust2sect + pop bc + pop bc + pop bc + call l_plong +.i_32 +.i_31 +.i_28 + ld hl,10 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + call l_gint ; + pop de + call l_pint + ld hl,0 ;const + pop bc + pop bc + pop bc + pop bc + ret + + + +; Function dir_find flags 0x00000200 __smallc +; const int FRESULTdir_find(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir) +; parameter 'unsigned char BYTE*dir' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._dir_find + push bc + dec sp + ld hl,1 ;const + add hl,sp + push hl + ld hl,9 ;const + add hl,sp + call l_gint ; + push hl + call _dir_rewind + pop bc + pop de + call l_pint + ld hl,1 ;const + add hl,sp + call l_gint ; + ld a,h + or l + jp z,i_35 + ld hl,1 ;const + add hl,sp + call l_gint ; + inc sp + pop bc + ret + + +.i_35 +.i_38 + ld hl,1 ;const + add hl,sp + push hl + ld hl,7 ;const + call l_gintspsp ; + ld hl,11 ;const + add hl,sp + call l_gint ; + ld bc,12 + add hl,bc + call l_glong2sp + ld hl,15 ;const + add hl,sp + call l_gint ; + ld a,(hl) + and +(15 % 256) + ld l,a + ld h,0 + add hl,hl + add hl,hl + add hl,hl + add hl,hl + add hl,hl + push hl + ld hl,32 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_39 + ld hl,1 ;const + jp i_40 +.i_39 + ld hl,0 ;const +.i_40 + pop de + call l_pint + ld hl,1 ;const + add hl,sp + call l_gint ; + ld a,h + or l + jp nz,i_37 +.i_41 + ld hl,0 ;const + add hl,sp + push hl + ld hl,7 ;const + add hl,sp + call l_gint ; + ld a,(hl) + pop de + ld (de),a + pop hl + push hl + ld h,0 + ld a,l + and a + jp nz,i_42 + ld hl,1 ;const + add hl,sp + ld de,3 ;const + ex de,hl + call l_pint + jp i_37 +.i_42 + ld hl,5 ;const + add hl,sp + call l_gint ; + ld bc,11 + add hl,bc + ld a,(hl) + and +(8 % 256) + jp nz,i_44 + ld hl,5 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + call l_gint ; + inc hl + inc hl + ld e,(hl) + inc hl + ld d,(hl) + push de + ld hl,11 ;const + push hl + call _mem_cmp + pop bc + pop bc + pop bc + call l_lneg + jr c,i_45_i_44 +.i_44 + jp i_43 +.i_45_i_44 + jp i_37 +.i_43 + ld hl,1 ;const + add hl,sp + push hl + ld hl,9 ;const + add hl,sp + call l_gint ; + push hl + call _dir_next + pop bc + pop de + call l_pint +.i_36 + ld hl,1 ;const + add hl,sp + call l_gint ; + ld a,h + or l + jp z,i_38 +.i_37 + ld hl,1 ;const + add hl,sp + call l_gint ; + inc sp + pop bc + ret + + + +; Function dir_read flags 0x00000200 __smallc +; const int FRESULTdir_read(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir) +; parameter 'unsigned char BYTE*dir' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._dir_read + ld hl,3 ;const + push hl + push bc +.i_46 + ld hl,8 ;const + add hl,sp + call l_gint ; + ld bc,12 + add hl,bc + call l_glong + ld a,h + or l + or d + or e + jp z,i_47 + ld hl,i_1+0 + push hl + ld hl,10 ;const + add hl,sp + call l_gint ; + ld bc,12 + add hl,bc + call l_glong2sp + ld hl,14 ;const + add hl,sp + call l_gint ; + call l_gint ; + push hl + ld a,4 + call printf + pop bc + pop bc + pop bc + pop bc + ld hl,6 ;const + call l_gintspsp ; + ld hl,10 ;const + add hl,sp + call l_gint ; + ld bc,12 + add hl,bc + call l_glong2sp + ld hl,14 ;const + add hl,sp + call l_gint ; + ld a,(hl) + and +(15 % 256) + ld l,a + ld h,0 + add hl,hl + add hl,hl + add hl,hl + add hl,hl + add hl,hl + push hl + ld hl,32 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_48 + ld hl,1 ;const + jp i_49 +.i_48 + ld hl,0 ;const +.i_49 + pop de + pop bc + push hl + push de + ld a,h + or l + jp nz,i_47 +.i_50 + ld hl,0 ;const + add hl,sp + push hl + ld hl,8 ;const + add hl,sp + call l_gint ; + ld a,(hl) + pop de + ld (de),a + pop hl + push hl + ld h,0 + ld a,l + and a + jp nz,i_51 + ld hl,3 ;const + pop de + pop bc + push hl + push de + jp i_47 +.i_51 + ld hl,1 ;const + add hl,sp + push hl + ld hl,8 ;const + add hl,sp + call l_gint ; + ld bc,11 + add hl,bc + ld a,(hl) + and +(63 % 256) + ld l,a + ld h,0 + pop de + ld a,l + ld (de),a + ld hl,0 ;const + add hl,sp + ld a,(hl) + cp 229 + jp z,i_53 + pop hl + push hl + ld h,0 + ld de,46 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jp nc,i_53 + pop hl + push hl + ld l,h + ld h,0 + ld a,+(8 % 256) + and l + ld l,a + call l_lneg + jr c,i_54_i_53 +.i_53 + jp i_52 +.i_54_i_53 + jp i_47 +.i_52 + ld hl,8 ;const + add hl,sp + call l_gint ; + push hl + call _dir_next + pop bc + pop de + pop bc + push hl + push de + ld a,h + or l + jr nz,i_47 +.i_55 + jp i_46 +.i_47 + pop bc + pop hl + push hl + push bc + ld a,h + or l + jp z,i_56 + ld hl,8 ;const + add hl,sp + call l_gint ; + ld bc,12 + add hl,bc + push hl + ld hl,0 ;const + ld d,h + ld e,l + pop bc + call l_plong +.i_56 + pop bc + pop hl + ret + + + +; Function create_name flags 0x00000200 __smallc +; const int FRESULTcreate_name(struct 0__anonstruct_5 DIR*dj, const char **path) +; parameter 'const char **path' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._create_name + push bc + push bc + push bc + push bc + dec sp + ld hl,13 ;const + add hl,sp + call l_gint ; + inc hl + inc hl + call l_gint ; + pop de + pop bc + push hl + push de + ld hl,2 ;const + call l_gintspsp ; + ld hl,32 ;const + push hl + ld hl,11 ;const + push hl + call _mem_set + pop bc + pop bc + pop bc + ld hl,5 ;const + add hl,sp + push hl + ld hl,6 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld l,(hl) + ld h,0 + pop de + ld a,l + ld (de),a + ld hl,6 ;const + add hl,sp + ld (hl),+(8 % 256 % 256) + ld hl,11 ;const + add hl,sp + call l_gint ; + call l_gint ; + pop bc + push hl +.i_57 +.i_59 + ld hl,8 ;const + add hl,sp + push hl + ld hl,2 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + pop de + ld a,(hl) + ld (de),a + ld hl,8 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,32 + and a + sbc hl,de + ccf + jp c,i_61 + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,47 + and a + sbc hl,de + jr nz,i_60 +.i_61 + jp i_58 +.i_60 + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,46 + and a + sbc hl,de + scf + jr z,ASMPC+3 + ccf + jp c,i_64 + ld hl,4 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,6 ;const + add hl,sp + ld l,(hl) + ld h,0 + call l_uge + jp nc,i_63 +.i_64 + ld hl,6 ;const + add hl,sp + ld a,(hl) + cp 8 + jr z,ASMPC+3 + scf + jp c,i_67 + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,46 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jr nc,i_66 +.i_67 + jp i_58 +.i_66 + ld hl,4 ;const + add hl,sp + ld (hl),+(8 % 256 % 256) + ld hl,6 ;const + add hl,sp + ld (hl),+(11 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_57 +.i_63 + jp i_70 + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + dec hl + pop de + ex de,hl + and a + sbc hl,de + jr c,i_71_i_70 +.i_70 + jp i_69 +.i_71_i_70 + ld hl,7 ;const + add hl,sp + push hl + ld hl,2 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + pop de + ld a,(hl) + ld (de),a + ld hl,2 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + ex de,hl + ld hl,8 ;const + add hl,sp + ld a,(hl) + ld (de),a + ld hl,2 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + push hl + ld hl,9 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a + ld l,a + ld h,0 + jp i_72 +.i_69 + jp i_74 + ld hl,8 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,97 + call l_uge + jp nc,i_75 + ld hl,8 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,122 + and a + sbc hl,de + ccf + jr c,i_76_i_75 +.i_75 + jp i_74 +.i_76_i_75 + jr i_77_i_74 +.i_74 + jp i_73 +.i_77_i_74 + ld hl,8 ;const + add hl,sp + ld a,(hl) + add a,+(-32 % 256) + ld (hl),a +.i_73 + ld hl,2 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + push hl + ld hl,10 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a + ld l,a + ld h,0 +.i_72 + jp i_57 +.i_58 + ld hl,11 ;const + call l_gintspsp ; + ld hl,2 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,7 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + pop de + call l_pint + pop bc + pop hl + push hl + push bc + ld bc,11 + add hl,bc + push hl + ld hl,10 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,32 + and a + sbc hl,de + ccf + jp nc,i_78 + ld hl,1 ;const + jp i_79 +.i_78 + ld hl,0 ;const +.i_79 + pop de + ld a,l + ld (de),a + ld hl,0 ;const + inc sp + pop bc + pop bc + pop bc + pop bc + ret + + + +; Function get_fileinfo flags 0x00000200 __smallc +; void get_fileinfo(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir, struct 0__anonstruct_6 FILINFO*fno) +; parameter 'struct 0__anonstruct_6 FILINFO*fno' at 2 size(2) +; parameter 'unsigned char BYTE*dir' at 4 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 6 size(2) +._get_fileinfo + push bc + push bc + ld hl,6 ;const + add hl,sp + call l_gint ; + ld bc,9 + add hl,bc + pop bc + push hl + ld hl,10 ;const + add hl,sp + call l_gint ; + ld bc,12 + add hl,bc + call l_glong + ld a,h + or l + or d + or e + jp z,i_80 + ld hl,3 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_83 +.i_81 + ld hl,3 ;const + add hl,sp + inc (hl) +.i_83 + ld hl,3 ;const + add hl,sp + ld a,(hl) + sub 8 + jp nc,i_82 + ld hl,2 ;const + add hl,sp + push hl + ld hl,10 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,5 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + ld a,(hl) + pop de + ld (de),a + ld hl,2 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + jp z,i_82 +.i_84 + ld hl,2 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 5 + jp nz,i_85 + ld hl,2 ;const + add hl,sp + ld (hl),+(229 % 256 % 256) +.i_85 + pop hl + inc hl + push hl + dec hl + push hl + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld a,l + rla + sbc a + ld h,a + pop de + ld a,l + ld (de),a + jp i_81 +.i_82 + ld hl,8 ;const + add hl,sp + call l_gint ; + ld bc,8 + add hl,bc + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jp nc,i_86 + pop hl + ld (hl),+(46 % 256) + inc hl + push hl + ld hl,3 ;const + add hl,sp + ld (hl),+(8 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_89 +.i_87 + ld hl,3 ;const + add hl,sp + inc (hl) +.i_89 + ld hl,3 ;const + add hl,sp + ld a,(hl) + sub 11 + jp nc,i_88 + ld hl,2 ;const + add hl,sp + push hl + ld hl,10 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,5 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + ld a,(hl) + pop de + ld (de),a + ld hl,2 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + jp z,i_88 +.i_90 + pop hl + inc hl + push hl + dec hl + push hl + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld a,l + rla + sbc a + ld h,a + pop de + ld a,l + ld (de),a + jp i_87 +.i_88 +.i_86 + ld hl,6 ;const + add hl,sp + call l_gint ; + ld bc,8 + add hl,bc + push hl + ld hl,10 ;const + add hl,sp + call l_gint ; + ld bc,11 + add hl,bc + ld a,(hl) + pop de + ld (de),a + ld hl,6 ;const + call l_gintspsp ; + ld hl,10 ;const + add hl,sp + call l_gint ; + ld bc,28 + add hl,bc + push hl + call _ld_dword + pop bc + pop bc + call l_plong + ld hl,6 ;const + add hl,sp + call l_gint ; + ld bc,4 + add hl,bc + push hl + ld hl,10 ;const + add hl,sp + call l_gint ; + ld bc,24 + add hl,bc + push hl + call _ld_word + pop bc + pop de + call l_pint + ld hl,6 ;const + add hl,sp + call l_gint ; + ld bc,6 + add hl,bc + push hl + ld hl,10 ;const + add hl,sp + call l_gint ; + ld bc,22 + add hl,bc + push hl + call _ld_word + pop bc + pop de + call l_pint +.i_80 + pop de + push de + ld hl,0 ;const + ld a,l + ld (de),a + pop bc + pop bc + ret + + + +; Function follow_path flags 0x00000200 __smallc +; const int FRESULTfollow_path(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir, const char *path) +; parameter 'const char *path' at 2 size(2) +; parameter 'unsigned char BYTE*dir' at 4 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 6 size(2) +._follow_path + push bc +.i_91 + ld hl,4 ;const + add hl,sp + call l_gint ; + ld a,(hl) + cp 32 + jp nz,i_92 + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + jp i_91 +.i_92 + ld hl,4 ;const + add hl,sp + call l_gint ; + ld a,(hl) + cp 47 + jp nz,i_93 + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) +.i_93 + ld hl,8 ;const + add hl,sp + call l_gint ; + ld bc,4 + add hl,bc + xor a + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + ld hl,4 ;const + add hl,sp + call l_gint ; + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + jp nc,i_94 + ld hl,8 ;const + add hl,sp + call l_gint ; + push hl + call _dir_rewind + pop bc + pop bc + push hl + ld hl,6 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,0 % 256 ;const + ld a,l + ld (de),a + jp i_95 +.i_94 +.i_96 +.i_98 + ld hl,8 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + push hl + call _create_name + pop bc + pop bc + pop bc + push hl + ld a,h + or l + jp nz,i_97 +.i_99 + ld hl,8 ;const + call l_gintspsp ; + ld hl,8 ;const + add hl,sp + call l_gint ; + push hl + call _dir_find + pop bc + pop bc + pop bc + push hl + ld a,h + or l + jp nz,i_97 +.i_100 + ld hl,8 ;const + add hl,sp + call l_gint ; + inc hl + inc hl + call l_gint ; + ld bc,11 + add hl,bc + ld l,(hl) + ld h,0 + ld a,h + or l + jp nz,i_97 +.i_101 + ld hl,6 ;const + add hl,sp + call l_gint ; + ld bc,11 + add hl,bc + ld a,(hl) + and +(16 % 256) + jp nz,i_102 + ld hl,3 ;const + pop bc + push hl + jp i_97 +.i_102 + ld hl,8 ;const + add hl,sp + call l_gint ; + ld bc,4 + add hl,bc + push hl + ld hl,8 ;const + add hl,sp + call l_gint ; + push hl + call _get_clust + pop bc + pop bc + call l_plong + jp i_96 +.i_97 +.i_95 + pop hl + ret + + + +; Function check_fs flags 0x00000200 __smallc +; unsigned char BYTEcheck_fs(unsigned char BYTE*buf, unsigned long sect) +; parameter 'unsigned long sect' at 2 size(4) +; parameter 'unsigned char BYTE*buf' at 6 size(2) +._check_fs + ld hl,6 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,510 ;const + push hl + ld hl,2 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_103 + ld hl,3 % 256 ;const + ret + + +.i_103 + ld hl,6 ;const + add hl,sp + call l_gint ; + push hl + call _ld_word + pop bc + ld de,43605 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jp nc,i_104 + ld hl,2 % 256 ;const + ret + + +.i_104 + ld hl,6 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,82 ;const + push hl + ld hl,2 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + call l_lneg + jp nc,i_106 + ld hl,6 ;const + add hl,sp + call l_gint ; + push hl + call _ld_word + pop bc + ld de,16710 + and a + sbc hl,de + jr z,i_107_i_106 +.i_106 + jp i_105 +.i_107_i_106 + ld hl,0 % 256 ;const + ret + + +.i_105 + ld hl,1 % 256 ;const + ret + + + +; Function pf_mount flags 0x00000200 __smallc +; const int FRESULTpf_mount(struct 0__anonstruct_4 FATFS*fs) +; parameter 'struct 0__anonstruct_4 FATFS*fs' at 2 size(2) +._pf_mount + ld hl,65483 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ld (_FatFs),hl + call _disk_initialize + ld a,l + and +(1 % 256) + jp z,i_108 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,2 ;const + ret + + +.i_108 + ld hl,12 ;const + add hl,sp + xor a + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + ld hl,52 ;const + add hl,sp + push hl + ld hl,18 ;const + add hl,sp + push hl + ld hl,16 ;const + add hl,sp + call l_glong + push de + push hl + call _check_fs + pop bc + pop bc + pop bc + pop de + ld a,l + ld (de),a + ld hl,52 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 1 + jp nz,i_109 + ld hl,16 ;const + add hl,sp + push hl + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld hl,446 ;const + push hl + ld hl,16 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_110 + ld hl,52 ;const + add hl,sp + ld (hl),+(3 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_111 +.i_110 + ld hl,20 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_112 + ld hl,12 ;const + add hl,sp + push hl + ld hl,26 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong + ld hl,52 ;const + add hl,sp + push hl + ld hl,18 ;const + add hl,sp + push hl + ld hl,16 ;const + add hl,sp + call l_glong + push de + push hl + call _check_fs + pop bc + pop bc + pop bc + pop de + ld a,l + ld (de),a +.i_112 +.i_111 +.i_109 + ld hl,52 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 3 + jp nz,i_113 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_113 + ld hl,52 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_114 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,6 ;const + ret + + +.i_114 + ld hl,16 ;const + add hl,sp + push hl + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld hl,13 ;const + push hl + ld hl,36 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_115 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_115 + ld hl,8 ;const + add hl,sp + push hl + ld hl,27 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + pop bc + call l_plong + ld hl,8 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_116 + ld hl,8 ;const + add hl,sp + push hl + ld hl,41 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong +.i_116 + ld hl,8 ;const + add hl,sp + push hl + call l_glong2sp + ld hl,25 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + call l_long_mult + pop bc + call l_plong + ld hl,55 ;const + add hl,sp + call l_gint ; + ld bc,10 + add hl,bc + push hl + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld hl,23 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,55 ;const + add hl,sp + call l_gint ; + inc hl + inc hl + ex de,hl + ld hl,16 ;const + add hl,sp + ld a,(hl) + ld (de),a + ld hl,55 ;const + add hl,sp + call l_gint ; + ld bc,4 + add hl,bc + push hl + ld hl,22 ;const + add hl,sp + push hl + call _ld_word + pop bc + pop de + call l_pint + ld hl,4 ;const + add hl,sp + push hl + ld hl,24 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + pop bc + call l_plong + ld hl,4 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_117 + ld hl,4 ;const + add hl,sp + push hl + ld hl,37 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong +.i_117 + ld hl,0 ;const + add hl,sp + push hl + ld hl,6 ;const + add hl,sp + call l_glong2sp + ld hl,23 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + call l_long_sub + push de + push hl + ld hl,14 ;const + add hl,sp + call l_glong + call l_long_sub + push de + push hl + ld hl,61 ;const + add hl,sp + call l_gint ; + ld bc,4 + add hl,bc + call l_gint ; + ld de,4 + call l_asr_u_hl_by_e + ld de,0 + call l_long_sub + push de + push hl + ld hl,61 ;const + add hl,sp + call l_gint ; + inc hl + inc hl + ld l,(hl) + ld h,0 + ld de,0 + call l_long_div_u + ld bc,2 + add hl,bc + jr nc,ASMPC+3 + inc de + pop bc + call l_plong + ld hl,55 ;const + add hl,sp + call l_gint ; + ld bc,6 + add hl,bc + push hl + ld hl,2 ;const + add hl,sp + call l_glong + pop bc + call l_plong + ld hl,52 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld hl,0 ;const + add hl,sp + call l_glong2sp + ld hl,65527 ;const + ld de,0 + call l_long_uge + jp nc,i_118 + ld hl,52 ;const + add hl,sp + ld (hl),+(3 % 256 % 256) +.i_118 + ld hl,52 ;const + add hl,sp + ld a,(hl) + and a + jp nz,i_119 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,6 ;const + ret + + +.i_119 + ld hl,55 ;const + call l_gintspsp ; + ld hl,54 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a + ld hl,55 ;const + add hl,sp + call l_gint ; + ld bc,14 + add hl,bc + push hl + ld hl,49 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong + ld hl,55 ;const + add hl,sp + call l_gint ; + ld bc,18 + add hl,bc + push hl + ld hl,57 ;const + add hl,sp + call l_gint ; + ld bc,10 + add hl,bc + call l_glong2sp + ld hl,14 ;const + add hl,sp + call l_glong + call l_long_add + push de + push hl + ld hl,61 ;const + add hl,sp + call l_gint ; + ld bc,4 + add hl,bc + call l_gint ; + ld de,4 + call l_asr_u_hl_by_e + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,55 ;const + add hl,sp + call l_gint ; + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,55 ;const + add hl,sp + call l_gint ; + ld (_FatFs),hl + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; Function pf_open flags 0x00000200 __smallc +; const int FRESULTpf_open(const char *path) +; parameter 'const char *path' at 2 size(2) +._pf_open + ld hl,65474 ;const + add hl,sp + ld sp,hl + ld hl,(_FatFs) + push hl + call l_lneg + jp nc,i_120 + ld hl,64 ;const + add hl,sp + ld sp,hl + ld hl,5 ;const + ret + + +.i_120 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,48 ;const + add hl,sp + push hl + ld hl,36 ;const + add hl,sp + pop de + call l_pint + ld hl,62 ;const + add hl,sp + push hl + ld hl,48 ;const + add hl,sp + push hl + ld hl,6 ;const + add hl,sp + push hl + ld hl,72 ;const + add hl,sp + call l_gint ; + push hl + call _follow_path + pop bc + pop bc + pop bc + pop de + call l_pint + ld hl,62 ;const + add hl,sp + call l_gint ; + ld a,h + or l + jp z,i_121 + ld hl,62 ;const + add hl,sp + call l_gint ; + exx + ld hl,64 ;const + add hl,sp + ld sp,hl + exx + ret + + +.i_121 + ld hl,2 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_123 + ld hl,13 ;const + add hl,sp + ld a,+(16 % 256) + and (hl) + jp z,i_122 +.i_123 + ld hl,64 ;const + add hl,sp + ld sp,hl + ld hl,3 ;const + ret + + +.i_122 + pop hl + push hl + ld bc,30 + add hl,bc + push hl + ld hl,4 ;const + add hl,sp + push hl + call _get_clust + pop bc + pop bc + call l_plong + pop hl + push hl + ld bc,26 + add hl,bc + push hl + ld hl,32 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong + pop hl + push hl + ld bc,22 + add hl,bc + xor a + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + pop hl + push hl + inc hl + ld (hl),+(1 % 256 % 256) + ld hl,64 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; Function pf_read flags 0x00000200 __smallc +; const int FRESULTpf_read(void *buff, unsigned int btr, unsigned int UINT*br) +; parameter 'unsigned int UINT*br' at 2 size(2) +; parameter 'unsigned int btr' at 4 size(2) +; parameter 'void *buff' at 6 size(2) +._pf_read + ld hl,65519 ;const + add hl,sp + ld sp,hl + ld hl,23 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + push de + ld hl,(_FatFs) + push hl + ld hl,23 ;const + add hl,sp + ld a,(hl) + inc hl + ld h,(hl) + ld l,a + xor a + ld (hl),a + inc hl + ld (hl),a + pop hl + push hl + call l_lneg + jp nc,i_125 + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,5 ;const + ret + + +.i_125 + pop hl + push hl + inc hl + ld a,(hl) + and +(1 % 256) + jp nz,i_126 + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,4 ;const + ret + + +.i_126 + ld hl,7 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,26 + add hl,bc + call l_glong2sp + ld hl,6 ;const + add hl,sp + call l_gint ; + ld bc,22 + add hl,bc + call l_glong + call l_long_sub + pop bc + call l_plong + ld hl,25 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + call l_glong + exx + pop hl + ld de,0 + push de + push hl + exx + call l_long_ugt + jp nc,i_127 + ld hl,25 ;const + add hl,sp + push hl + ld hl,9 ;const + add hl,sp + call l_glong + pop de + call l_pint +.i_127 +.i_128 + ld hl,25 ;const + add hl,sp + call l_gint ; + ld a,h + or l + jp z,i_129 + pop hl + push hl + ld bc,22 + add hl,bc + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_div_u + exx + ld a,d + or e + or h + or l + jp nz,i_130 + ld hl,4 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,22 + add hl,bc + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_div_u + push de + push hl + ld hl,6 ;const + add hl,sp + call l_gint ; + inc hl + inc hl + ld l,(hl) + ld h,0 + dec hl + ld de,0 + call l_long_and + pop de + ld a,l + ld (de),a + ld hl,4 ;const + add hl,sp + ld a,(hl) + and a + jp nz,i_131 + pop hl + push hl + ld bc,22 + add hl,bc + call l_glong + ld a,d + or e + or h + or l + jp nz,i_132 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,30 + add hl,bc + call l_glong + pop bc + call l_plong + jp i_133 +.i_132 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _get_fat + pop bc + pop bc + pop bc + call l_plong +.i_133 + ld hl,15 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_ule + jp nc,i_134 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_134 + pop hl + push hl + ld bc,34 + add hl,bc + push hl + ld hl,17 ;const + add hl,sp + call l_glong + pop bc + call l_plong +.i_131 + ld hl,11 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _clust2sect + pop bc + pop bc + pop bc + call l_plong + ld hl,11 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_135 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_135 + pop hl + push hl + ld bc,38 + add hl,bc + push hl + ld hl,13 ;const + add hl,sp + call l_glong2sp + ld hl,10 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + call l_long_add + pop bc + call l_plong +.i_130 + ld hl,5 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ld hl,512 + and a + sbc hl,de + pop de + call l_pint + ld hl,5 ;const + call l_gintspsp ; + ld hl,27 ;const + add hl,sp + call l_gint ; + pop de + and a + sbc hl,de + jp nc,i_136 + ld hl,5 ;const + add hl,sp + ex de,hl + ld hl,25 ;const + add hl,sp + call l_gint ; + call l_pint +.i_136 + ld hl,19 ;const + add hl,sp + push hl + ld hl,4 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + call l_gint ; + ld bc,38 + add hl,bc + call l_glong2sp + ld hl,8 ;const + add hl,sp + call l_gint ; + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ex de,hl + push hl + ld hl,15 ;const + add hl,sp + call l_gint ; + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + pop de + call l_pint + ld hl,19 ;const + add hl,sp + call l_gint ; + ld a,h + or l + jp z,i_137 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_137 + pop hl + push hl + ld bc,22 + add hl,bc + push hl + call l_glong2sp + ld hl,11 ;const + add hl,sp + call l_gint ; + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,25 ;const + add hl,sp + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,7 ;const + add hl,sp + call l_gint + ex de,hl + and a + sbc hl,de + pop de + call l_pint + ld hl,23 ;const + add hl,sp + call l_gint ; + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,7 ;const + add hl,sp + call l_gint + add hl,de + pop de + call l_pint + pop bc + pop hl + push hl + push bc + ld a,h + or l + jp z,i_138 + ld hl,2 ;const + call l_gintspsp ; + ld hl,7 ;const + add hl,sp + call l_gint ; + pop de + add hl,de + pop de + pop bc + push hl + push de +.i_138 + jp i_128 +.i_129 + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; Function pf_write flags 0x00000200 __smallc +; const int FRESULTpf_write(const void *buff, unsigned int btw, unsigned int UINT*bw) +; parameter 'unsigned int UINT*bw' at 2 size(2) +; parameter 'unsigned int btw' at 4 size(2) +; parameter 'const void *buff' at 6 size(2) +._pf_write + ld hl,65524 ;const + add hl,sp + ld sp,hl + ld hl,18 ;const + add hl,sp + call l_gint ; + push hl + push bc + dec sp + ld hl,(_FatFs) + push hl + ld hl,21 ;const + add hl,sp + ld a,(hl) + inc hl + ld h,(hl) + ld l,a + xor a + ld (hl),a + inc hl + ld (hl),a + pop hl + push hl + call l_lneg + jp nc,i_139 + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,5 ;const + ret + + +.i_139 + pop hl + push hl + inc hl + ld a,(hl) + and +(1 % 256) + jp nz,i_140 + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,4 ;const + ret + + +.i_140 + ld hl,23 ;const + add hl,sp + call l_gint ; + call l_lneg + jp nc,i_141 + pop hl + push hl + inc hl + ld a,+(64 % 256) + and (hl) + jp z,i_143 + ld hl,0 ;const + push hl + ld d,h + ld e,l + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jr nz,i_144_i_143 +.i_143 + jp i_142 +.i_144_i_143 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_142 + pop hl + push hl + inc hl + push hl + ld a,(hl) + and 191 + ld l,a + ld h,0 + pop de + ld a,l + ld (de),a + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + +.i_141 + pop hl + push hl + inc hl + ld a,(hl) + and +(64 % 256) + jp nz,i_146 + pop hl + push hl + ld bc,22 + add hl,bc + push hl + call l_glong2sp + ld hl,65024 ;const + ld de,65535 + call l_long_and + pop bc + call l_plong +.i_146 +.i_145 + ld hl,7 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,26 + add hl,bc + call l_glong2sp + ld hl,6 ;const + add hl,sp + call l_gint ; + ld bc,22 + add hl,bc + call l_glong + call l_long_sub + pop bc + call l_plong + ld hl,23 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + call l_glong + exx + pop hl + ld de,0 + push de + push hl + exx + call l_long_ugt + jp nc,i_147 + ld hl,23 ;const + add hl,sp + push hl + ld hl,9 ;const + add hl,sp + call l_glong + pop de + call l_pint +.i_147 +.i_148 + ld hl,23 ;const + add hl,sp + call l_gint ; + ld a,h + or l + jp z,i_149 + pop hl + push hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ex de,hl + ld a,h + or l + jp nz,i_150 + ld hl,4 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,22 + add hl,bc + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_div_u + push de + push hl + ld hl,6 ;const + add hl,sp + call l_gint ; + inc hl + inc hl + ld l,(hl) + ld h,0 + dec hl + ld de,0 + call l_long_and + pop de + ld a,l + ld (de),a + ld hl,4 ;const + add hl,sp + ld a,(hl) + and a + jp nz,i_151 + pop hl + push hl + ld bc,22 + add hl,bc + call l_glong + ld a,d + or e + or h + or l + jp nz,i_152 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,30 + add hl,bc + call l_glong + pop bc + call l_plong + jp i_153 +.i_152 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _get_fat + pop bc + pop bc + pop bc + call l_plong +.i_153 + ld hl,15 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_ule + jp nc,i_154 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_154 + pop hl + push hl + ld bc,34 + add hl,bc + push hl + ld hl,17 ;const + add hl,sp + call l_glong + pop bc + call l_plong +.i_151 + ld hl,11 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _clust2sect + pop bc + pop bc + pop bc + call l_plong + ld hl,11 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_155 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_155 + pop hl + push hl + ld bc,38 + add hl,bc + push hl + ld hl,13 ;const + add hl,sp + call l_glong2sp + ld hl,10 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + call l_long_add + pop bc + call l_plong + pop hl + push hl + ld bc,0 + push bc + ld bc,38 + add hl,bc + call l_glong + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_156 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_156 + pop hl + push hl + inc hl + ld a,(hl) + or 64 + ld (hl),a +.i_150 + pop hl + push hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ld hl,512 + and a + sbc hl,de + pop de + pop bc + push hl + push de + ld hl,2 ;const + call l_gintspsp ; + ld hl,25 ;const + add hl,sp + call l_gint ; + pop de + and a + sbc hl,de + jp nc,i_157 + ld hl,23 ;const + add hl,sp + call l_gint ; + pop de + pop bc + push hl + push de +.i_157 + ld hl,5 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + call l_gint ; + ld de,0 + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_158 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_158 + pop hl + push hl + ld bc,22 + add hl,bc + push hl + call l_glong2sp + ld hl,8 ;const + add hl,sp + call l_gint ; + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,5 ;const + add hl,sp + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,4 ;const + add hl,sp + call l_gint + add hl,de + pop de + call l_pint + ld hl,23 ;const + add hl,sp + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,4 ;const + add hl,sp + call l_gint + ex de,hl + and a + sbc hl,de + pop de + call l_pint + ld hl,21 ;const + add hl,sp + call l_gint ; + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,4 ;const + add hl,sp + call l_gint + add hl,de + pop de + call l_pint + pop hl + push hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ex de,hl + ld a,h + or l + jp nz,i_159 + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_160 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_160 + pop hl + push hl + inc hl + push hl + ld a,(hl) + and 191 + ld l,a + ld h,0 + pop de + ld a,l + ld (de),a +.i_159 + jp i_148 +.i_149 + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; Function pf_opendir flags 0x00000200 __smallc +; const int FRESULTpf_opendir(struct 0__anonstruct_5 DIR*dj, const char *path) +; parameter 'const char *path' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._pf_opendir + ld hl,65490 ;const + add hl,sp + ld sp,hl + ld hl,(_FatFs) + push hl + call l_lneg + jp nc,i_161 + ld hl,46 ;const + add hl,sp + ld de,5 ;const + ex de,hl + call l_pint + jp i_162 +.i_161 + ld hl,i_1+33 + push hl + ld a,1 + call printf + pop bc + ld hl,52 ;const + add hl,sp + call l_gint ; + inc hl + inc hl + push hl + ld hl,36 ;const + add hl,sp + pop de + call l_pint + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + push hl + ld hl,56 ;const + add hl,sp + call l_gint ; + push hl + call _follow_path + pop bc + pop bc + pop bc + pop de + call l_pint + ld hl,i_1+42 + push hl + ld hl,48 ;const + add hl,sp + call l_gint ; + push hl + ld a,2 + call printf + pop bc + pop bc + ld hl,46 ;const + add hl,sp + call l_gint ; + ld a,h + or l + jp nz,i_163 + ld hl,2 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_164 + ld hl,i_1+55 + push hl + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld a,2 + call printf + pop bc + pop bc + ld hl,13 ;const + add hl,sp + ld a,+(16 % 256) + and (hl) + jp z,i_165 + ld hl,52 ;const + add hl,sp + call l_gint ; + ld bc,4 + add hl,bc + push hl + ld hl,4 ;const + add hl,sp + push hl + call _get_clust + pop bc + pop bc + call l_plong + jp i_166 +.i_165 + ld hl,46 ;const + add hl,sp + ld de,3 ;const + ex de,hl + call l_pint +.i_166 +.i_164 + ld hl,46 ;const + add hl,sp + call l_gint ; + ld a,h + or l + jp nz,i_167 + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + add hl,sp + call l_gint ; + push hl + call _dir_rewind + pop bc + pop de + call l_pint +.i_167 +.i_163 +.i_162 + ld hl,46 ;const + add hl,sp + call l_gint ; + exx + ld hl,48 ;const + add hl,sp + ld sp,hl + exx + ret + + + +; Function pf_readdir flags 0x00000200 __smallc +; const int FRESULTpf_readdir(struct 0__anonstruct_5 DIR*dj, struct 0__anonstruct_6 FILINFO*fno) +; parameter 'struct 0__anonstruct_6 FILINFO*fno' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._pf_readdir + ld hl,65490 ;const + add hl,sp + ld sp,hl + ld hl,(_FatFs) + push hl + call l_lneg + jp nc,i_168 + ld hl,46 ;const + add hl,sp + ld de,5 ;const + ex de,hl + call l_pint + jp i_169 +.i_168 + ld hl,52 ;const + add hl,sp + call l_gint ; + inc hl + inc hl + push hl + ld hl,36 ;const + add hl,sp + pop de + call l_pint + ld hl,50 ;const + add hl,sp + call l_gint ; + call l_lneg + jp nc,i_170 + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + add hl,sp + call l_gint ; + push hl + call _dir_rewind + pop bc + pop de + call l_pint + jp i_171 +.i_170 + ld hl,i_1+70 + push hl + ld a,1 + call printf + pop bc + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + push hl + call _dir_read + pop bc + pop bc + pop de + call l_pint + ld hl,46 ;const + add hl,sp + call l_gint ; + ld a,h + or l + jp nz,i_172 + ld hl,52 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + push hl + ld hl,54 ;const + add hl,sp + call l_gint ; + push hl + call _get_fileinfo + pop bc + pop bc + pop bc + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + add hl,sp + call l_gint ; + push hl + call _dir_next + pop bc + pop de + call l_pint + ld hl,46 ;const + add hl,sp + call l_gint ; + ld de,3 + and a + sbc hl,de + jp nz,i_173 + ld hl,46 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint +.i_173 +.i_172 +.i_171 +.i_169 + ld hl,46 ;const + add hl,sp + call l_gint ; + exx + ld hl,48 ;const + add hl,sp + ld sp,hl + exx + ret + + + SECTION rodata_compiler +.i_1 + defm "dir_read: sector:%ld, index:%l" + defm "d" + defb 10 + + defm "" + defb 0 + + defm "OPENDIR" + defb 10 + + defm "" + defb 0 + + defm "RESDIR:%02x" + defb 10 + + defm "" + defb 0 + + defm "IS A DIR:%02x" + defb 10 + + defm "" + defb 0 + + defm "Readdir" + defb 10 + + defm "" + defb 0 + + +; --- Start of Static Variables --- + + SECTION bss_compiler +._FatFs defs 2 + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- diff --git a/software/src/PetitFS/pff.h b/software/src/PetitFS/pff.h new file mode 100644 index 0000000..fd6c5c0 --- /dev/null +++ b/software/src/PetitFS/pff.h @@ -0,0 +1,486 @@ +/*---------------------------------------------------------------------------/ +/ Petit FatFs - FAT file system module include file R0.03a +/----------------------------------------------------------------------------/ +/ Petit FatFs module is an open source software to implement FAT file system to +/ small embedded systems. This is a free software and is opened for education, +/ research and commercial developments under license policy of following trems. +/ +/ Copyright (C) 2019, ChaN, all right reserved. +/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 +/ +/ * The Petit FatFs module is a free software and there is NO WARRANTY. +/ * No restriction on use. You can use, modify and redistribute it for +/ personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. +/ * Redistributions of source code must retain the above copyright notice. +/ +/----------------------------------------------------------------------------*/ + +#ifndef PF_DEFINED +#define PF_DEFINED 8088 /* Revision ID */ + +#ifdef __cplusplus +extern "C" { +#endif + +/*---------------------------------------------------------------------------/ +/ Locale and Namespace Configurations +/---------------------------------------------------------------------------*/ + +#define PF_USE_LCC 0 /* Allow lower case ASCII and non-ASCII chars */ +#define _FS_32ONLY 1 + +#define ABORT(err) {fs->flag = 0; return err;} + +#define PF_CODE_PAGE 437 +/* The PF_CODE_PAGE specifies the code page to be used on the target system. +/ SBCS code pages with PF_USE_LCC == 1 requiers a 128 byte of case conversion +/ table. It might occupy RAM on some platforms, e.g. avr-gcc. +/ When PF_USE_LCC == 0, PF_CODE_PAGE has no effect. +/ +/ 437 - U.S. +/ 720 - Arabic +/ 737 - Greek +/ 771 - KBL +/ 775 - Baltic +/ 850 - Latin 1 +/ 852 - Latin 2 +/ 855 - Cyrillic +/ 857 - Turkish +/ 860 - Portuguese +/ 861 - Icelandic +/ 862 - Hebrew +/ 863 - Canadian French +/ 864 - Arabic +/ 865 - Nordic +/ 866 - Russian +/ 869 - Greek 2 +/ 932 - Japanese (DBCS) +/ 936 - Simplified Chinese (DBCS) +/ 949 - Korean (DBCS) +/ 950 - Traditional Chinese (DBCS) +*/ + +/* Integer types used for FatFs API */ + +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus) /* C99 or later */ +#include +typedef unsigned int UINT; /* int must be 16-bit or 32-bit */ +typedef unsigned char BYTE; /* char must be 8-bit */ +typedef uint16_t WORD; /* 16-bit unsigned integer */ +typedef uint16_t WCHAR; /* 16-bit unsigned integer */ +typedef uint32_t DWORD; /* 32-bit unsigned integer */ +#else /* Earlier than C99 */ +typedef unsigned int UINT; /* int must be 16-bit or 32-bit */ +typedef unsigned char BYTE; /* char must be 8-bit */ +typedef unsigned short WORD; /* 16-bit unsigned integer */ +typedef unsigned short WCHAR; /* 16-bit unsigned integer */ +typedef unsigned long DWORD; /* 32-bit unsigned integer */ +#endif +#define PF_INTDEF 1 +#define CLUST DWORD + + +/* File system object structure */ + +typedef struct { + BYTE fs_type; /* FAT sub type */ + BYTE flag; /* File status flags */ + BYTE csize; /* Number of sectors per cluster */ + BYTE pad1; + WORD n_rootdir; /* Number of root directory entries (0 on FAT32) */ + CLUST n_fatent; /* Number of FAT entries (= number of clusters + 2) */ + DWORD fatbase; /* FAT start sector */ + DWORD dirbase; /* Root directory start sector (Cluster# on FAT32) */ + DWORD database; /* Data start sector */ + DWORD fptr; /* File R/W pointer */ + DWORD fsize; /* File size */ + CLUST org_clust; /* File start cluster */ + CLUST curr_clust; /* File current cluster */ + DWORD dsect; /* File current data sector */ +} FATFS; + + + +/* Directory object structure */ + +typedef struct { + WORD index; /* Current read/write index number */ + BYTE* fn; /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */ + CLUST sclust; /* Table start cluster (0:Static table) */ + CLUST clust; /* Current cluster */ + DWORD sect; /* Current sector */ +} DIR; + + + +/* File status structure */ + +typedef struct { + DWORD fsize; /* File size */ + WORD fdate; /* Last modified date */ + WORD ftime; /* Last modified time */ + BYTE fattrib; /* Attribute */ + char fname[13]; /* File name */ +} FILINFO; + + + +/* File function return code (FRESULT) */ + +typedef enum { + FR_OK = 0, /* 0 */ + FR_DISK_ERR, /* 1 */ + FR_NOT_READY, /* 2 */ + FR_NO_FILE, /* 3 */ + FR_NOT_OPENED, /* 4 */ + FR_NOT_ENABLED, /* 5 */ + FR_NO_FILESYSTEM /* 6 */ +} FRESULT; + + + +/*--------------------------------------------------------------*/ +/* Petit FatFs module application interface */ + +FRESULT pf_mount (FATFS* fs); /* Mount/Unmount a logical drive */ +FRESULT pf_open (const char* path); /* Open a file */ +FRESULT pf_read (void* buff, UINT btr, UINT* br); /* Read data from the open file */ +FRESULT pf_write (const void* buff, UINT btw, UINT* bw); /* Write data to the open file */ +FRESULT pf_lseek (DWORD ofs); /* Move file pointer of the open file */ +FRESULT pf_opendir (DIR* dj, const char* path); /* Open a directory */ +FRESULT pf_readdir (DIR* dj, FILINFO* fno); /* Read a directory item from the open directory */ + + + +/*--------------------------------------------------------------*/ +/* Flags and offset address */ + + +/* File status flag (FATFS.flag) */ +#define FA_OPENED 0x01 +#define FA_WPRT 0x02 +#define FA__WIP 0x40 + + +/* FAT sub type (FATFS.fs_type) */ +#define FS_FAT12 1 +#define FS_FAT16 2 +#define FS_FAT32 3 + + +/* File attribute bits for directory entry */ + +#define AM_RDO 0x01 /* Read only */ +#define AM_HID 0x02 /* Hidden */ +#define AM_SYS 0x04 /* System */ +#define AM_VOL 0x08 /* Volume label */ +#define AM_LFN 0x0F /* LFN entry */ +#define AM_DIR 0x10 /* Directory */ +#define AM_ARC 0x20 /* Archive */ +#define AM_MASK 0x3F /* Mask of defined bits */ + +/*--------------------------------------------------------*/ +/* DBCS code ranges and SBCS extend char conversion table */ +/*--------------------------------------------------------*/ + +#if PF_USE_LCC == 0 /* ASCII upper case character only */ + +#elif PF_CODE_PAGE == 932 /* Japanese Shift-JIS */ +#define _DF1S 0x81 /* DBC 1st byte range 1 start */ +#define _DF1E 0x9F /* DBC 1st byte range 1 end */ +#define _DF2S 0xE0 /* DBC 1st byte range 2 start */ +#define _DF2E 0xFC /* DBC 1st byte range 2 end */ +#define _DS1S 0x40 /* DBC 2nd byte range 1 start */ +#define _DS1E 0x7E /* DBC 2nd byte range 1 end */ +#define _DS2S 0x80 /* DBC 2nd byte range 2 start */ +#define _DS2E 0xFC /* DBC 2nd byte range 2 end */ + +#elif PF_CODE_PAGE == 936 /* Simplified Chinese GBK */ +#define _DF1S 0x81 +#define _DF1E 0xFE +#define _DS1S 0x40 +#define _DS1E 0x7E +#define _DS2S 0x80 +#define _DS2E 0xFE + +#elif PF_CODE_PAGE == 949 /* Korean */ +#define _DF1S 0x81 +#define _DF1E 0xFE +#define _DS1S 0x41 +#define _DS1E 0x5A +#define _DS2S 0x61 +#define _DS2E 0x7A +#define _DS3S 0x81 +#define _DS3E 0xFE + +#elif PF_CODE_PAGE == 950 /* Traditional Chinese Big5 */ +#define _DF1S 0x81 +#define _DF1E 0xFE +#define _DS1S 0x40 +#define _DS1E 0x7E +#define _DS2S 0xA1 +#define _DS2E 0xFE + +#elif PF_CODE_PAGE == 437 /* U.S. */ +#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ + 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 720 /* Arabic */ +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 737 /* Greek */ +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x92,0x92,0x93,0x94,0x95,0x96,0x97,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, \ + 0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0xAA,0x92,0x93,0x94,0x95,0x96, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0x97,0xEA,0xEB,0xEC,0xE4,0xED,0xEE,0xEF,0xF5,0xF0,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 771 /* KBL */ +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDC,0xDE,0xDE, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFE,0xFF} + +#elif PF_CODE_PAGE == 775 /* Baltic */ +#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F, \ + 0x90,0x92,0x92,0xE2,0x99,0x95,0x96,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ + 0xA0,0xA1,0xE0,0xA3,0xA3,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xA5,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE3,0xE8,0xE8,0xEA,0xEA,0xEE,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 850 /* Latin 1 */ +#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x41,0x43,0x45,0x45,0x45,0x49,0x49,0x49,0x41,0x41, \ + 0x45,0x92,0x92,0x4F,0x4F,0x4F,0x55,0x55,0x59,0x4F,0x55,0x4F,0x9C,0x4F,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0x41,0x41,0x41,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0x41,0x41,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD1,0xD1,0x45,0x45,0x45,0x49,0x49,0x49,0x49,0xD9,0xDA,0xDB,0xDC,0xDD,0x49,0xDF, \ + 0x4F,0xE1,0x4F,0x4F,0x4F,0x4F,0xE6,0xE8,0xE8,0x55,0x55,0x55,0x59,0x59,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 852 /* Latin 2 */ +#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x91,0xE2,0x99,0x95,0x95,0x97,0x97,0x99,0x9A,0x9B,0x9B,0x9D,0x9E,0xAC, \ + 0xB5,0xD6,0xE0,0xE9,0xA4,0xA4,0xA6,0xA6,0xA8,0xA8,0xAA,0x8D,0xAC,0xB8,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBD,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC6,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD1,0xD1,0xD2,0xD3,0xD2,0xD5,0xD6,0xD7,0xB7,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE3,0xD5,0xE6,0xE6,0xE8,0xE9,0xE8,0xEB,0xED,0xED,0xDD,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF} + +#elif PF_CODE_PAGE == 855 /* Cyrillic */ +#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F, \ + 0x91,0x91,0x93,0x93,0x95,0x95,0x97,0x97,0x99,0x99,0x9B,0x9B,0x9D,0x9D,0x9F,0x9F, \ + 0xA1,0xA1,0xA3,0xA3,0xA5,0xA5,0xA7,0xA7,0xA9,0xA9,0xAB,0xAB,0xAD,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB6,0xB6,0xB8,0xB8,0xB9,0xBA,0xBB,0xBC,0xBE,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD1,0xD1,0xD3,0xD3,0xD5,0xD5,0xD7,0xD7,0xDD,0xD9,0xDA,0xDB,0xDC,0xDD,0xE0,0xDF, \ + 0xE0,0xE2,0xE2,0xE4,0xE4,0xE6,0xE6,0xE8,0xE8,0xEA,0xEA,0xEC,0xEC,0xEE,0xEE,0xEF, \ + 0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 857 /* Turkish */ +#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x49,0x8E,0x8F, \ + 0x90,0x92,0x92,0xE2,0x99,0xE3,0xEA,0xEB,0x98,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9E, \ + 0xB5,0xD6,0xE0,0xE9,0xA5,0xA5,0xA6,0xA6,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC7,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0x49,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE5,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xDE,0xED,0xEE,0xEF, \ + +#elif PF_CODE_PAGE == 860 /* Portuguese */ +#define _EXCVT {0x80,0x9A,0x90,0x8F,0x8E,0x91,0x86,0x80,0x89,0x89,0x92,0x8B,0x8C,0x98,0x8E,0x8F, \ + 0x90,0x91,0x92,0x8C,0x99,0xA9,0x96,0x9D,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x86,0x8B,0x9F,0x96,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 861 /* Icelandic */ +#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x8B,0x8B,0x8D,0x8E,0x8F, \ + 0x90,0x92,0x92,0x4F,0x99,0x8D,0x55,0x97,0x97,0x99,0x9A,0x9D,0x9C,0x9D,0x9E,0x9F, \ + 0xA4,0xA5,0xA6,0xA7,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 862 /* Hebrew */ +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 863 /* Canadian French */ +#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x41,0x8F, \ + 0x45,0x45,0x45,0x4F,0x45,0x49,0x55,0x55,0x98,0x4F,0x55,0x9B,0x9C,0x55,0x55,0x9F, \ + 0xA0,0xA1,0x4F,0x55,0xA4,0xA5,0xA6,0xA7,0x49,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 864 /* Arabic */ +#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ + 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 865 /* Nordic */ +#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \ + 0x90,0x92,0x92,0x4F,0x99,0x4F,0x55,0x55,0x59,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x41,0x49,0x4F,0x55,0xA5,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, \ + 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 866 /* Russian */ +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, \ + 0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF} + +#elif PF_CODE_PAGE == 869 /* Greek 2 */ +#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \ + 0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x86,0x9C,0x8D,0x8F,0x90, \ + 0x91,0x90,0x92,0x95,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF, \ + 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, \ + 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, \ + 0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xA4,0xA5,0xA6,0xD9,0xDA,0xDB,0xDC,0xA7,0xA8,0xDF, \ + 0xA9,0xAA,0xAC,0xAD,0xB5,0xB6,0xB7,0xB8,0xBD,0xBE,0xC6,0xC7,0xCF,0xCF,0xD0,0xEF, \ + 0xF0,0xF1,0xD1,0xD2,0xD3,0xF5,0xD4,0xF7,0xF8,0xF9,0xD5,0x96,0x95,0x98,0xFE,0xFF} + +#else +#error Unknown code page. + +#endif + + + +/* Character code support macros */ + +#define IsUpper(c) (((c)>='A')&&((c)<='Z')) +#define IsLower(c) (((c)>='a')&&((c)<='z')) + +#if PF_USE_LCC && !defined(_EXCVT) /* DBCS configuration */ + +#ifdef _DF2S /* Two 1st byte areas */ +#define IsDBCS1(c) (((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) || ((BYTE)(c) >= _DF2S && (BYTE)(c) <= _DF2E)) +#else /* One 1st byte area */ +#define IsDBCS1(c) ((BYTE)(c) >= _DF1S && (BYTE)(c) <= _DF1E) +#endif + +#ifdef _DS3S /* Three 2nd byte areas */ +#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E) || ((BYTE)(c) >= _DS3S && (BYTE)(c) <= _DS3E)) +#else /* Two 2nd byte areas */ +#define IsDBCS2(c) (((BYTE)(c) >= _DS1S && (BYTE)(c) <= _DS1E) || ((BYTE)(c) >= _DS2S && (BYTE)(c) <= _DS2E)) +#endif + +#else /* SBCS configuration */ + +#define IsDBCS1(c) 0 +#define IsDBCS2(c) 0 + +#endif /* _EXCVT */ + + +/* FatFs refers the members in the FAT structures with byte offset instead +/ of structure member because there are incompatibility of the packing option +/ between various compilers. */ + +#define BS_jmpBoot 0 +#define BS_OEMName 3 +#define BPB_BytsPerSec 11 +#define BPB_SecPerClus 13 +#define BPB_RsvdSecCnt 14 +#define BPB_NumFATs 16 +#define BPB_RootEntCnt 17 +#define BPB_TotSec16 19 +#define BPB_Media 21 +#define BPB_FATSz16 22 +#define BPB_SecPerTrk 24 +#define BPB_NumHeads 26 +#define BPB_HiddSec 28 +#define BPB_TotSec32 32 +#define BS_55AA 510 + +#define BS_DrvNum 36 +#define BS_BootSig 38 +#define BS_VolID 39 +#define BS_VolLab 43 +#define BS_FilSysType 54 + +#define BPB_FATSz32 36 +#define BPB_ExtFlags 40 +#define BPB_FSVer 42 +#define BPB_RootClus 44 +#define BPB_FSInfo 48 +#define BPB_BkBootSec 50 +#define BS_DrvNum32 64 +#define BS_BootSig32 66 +#define BS_VolID32 67 +#define BS_VolLab32 71 +#define BS_FilSysType32 82 + +#define MBR_Table 446 + +#define DIR_Name 0 +#define DIR_Attr 11 +#define DIR_NTres 12 +#define DIR_CrtTime 14 +#define DIR_CrtDate 16 +#define DIR_FstClusHI 20 +#define DIR_WrtTime 22 +#define DIR_WrtDate 24 +#define DIR_FstClusLO 26 +#define DIR_FileSize 28 + + +extern FATFS *FatFs; /* Pointer to the file system object (logical drive) */ + +#ifdef __cplusplus +} +#endif + +#endif /* _PFATFS */ + diff --git a/software/src/PetitFS/pff_dir.c b/software/src/PetitFS/pff_dir.c new file mode 100644 index 0000000..7ce1129 --- /dev/null +++ b/software/src/PetitFS/pff_dir.c @@ -0,0 +1,302 @@ +/*----------------------------------------------------------------------------/ +/ Petit FatFs - FAT file system module R0.03a +/-----------------------------------------------------------------------------/ +/ +/ Copyright (C) 2019, ChaN, all right reserved. +/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 +/ +/ Petit FatFs module is an open source software. Redistribution and use of +/ Petit FatFs in source and binary forms, with or without modification, are +/ permitted provided that the following condition is met: +/ +/ 1. Redistributions of source code must retain the above copyright notice, +/ this condition and the following disclaimer. +/ +/ This software is provided by the copyright holder and contributors "AS IS" +/ and any warranties related to this software are DISCLAIMED. +/ The copyright owner or contributors be NOT LIABLE for any damages caused +/ by use of this software. +/-----------------------------------------------------------------------------/ +/ Jun 15,'09 R0.01a First release. +/ +/ Dec 14,'09 R0.02 Added multiple code page support. +/ Added write funciton. +/ Changed stream read mode interface. +/ Dec 07,'10 R0.02a Added some configuration options. +/ Fixed fails to open objects with DBCS character. + +/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. +/ Added _USE_LCC option. +/ Added _FS_FAT16 option. +/ +/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. +/ Removed _WORD_ACCESS option. +/ Changed prefix of configuration options, _ to PF_. +/ Added some code pages. +/ Removed some code pages actually not valid. +/ +/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in +/ banked ROMS as part of the RFS on the Sharp MZ80A. +/----------------------------------------------------------------------------*/ + +#include +#include +#include "pff.h" /* Petit FatFs configurations and declarations */ +#include "sdmmc.h" /* Declarations of low level disk I/O functions */ +#include "pff_func.h" +#define PFF_DIR_C +#include "pff_dir.h" + + +/*-----------------------------------------------------------------------*/ +/* Directory handling - Rewind directory index */ +/*-----------------------------------------------------------------------*/ + +FRESULT dir_rewind ( + DIR *dj /* Pointer to directory object */ +) +{ + CLUST clst; + FATFS *fs = FatFs; + + + dj->index = 0; + clst = dj->sclust; + if (clst == 1 || clst >= fs->n_fatent) { /* Check start cluster range */ + return FR_DISK_ERR; + } + if(!clst) + { + clst = (CLUST)fs->dirbase; + } + dj->clust = clst; /* Current cluster */ + dj->sect = clust2sect(clst); /* Current sector */ + return FR_OK; /* Seek succeeded */ +} + + + + +/*-----------------------------------------------------------------------*/ +/* Directory handling - Move directory index next */ +/*-----------------------------------------------------------------------*/ + +FRESULT dir_next ( /* FR_OK:Succeeded, FR_NO_FILE:End of table */ + DIR *dj /* Pointer to directory object */ +) +{ + CLUST clst; + WORD i; + FATFS *fs = FatFs; + + + i = dj->index + 1; + if (!i || !dj->sect) return FR_NO_FILE; /* Report EOT when index has reached 65535 */ + + if (!(i % 16)) { /* Sector changed? */ + dj->sect++; /* Next sector */ + + if (dj->clust == 0) { /* Static table */ + if (i >= fs->n_rootdir) return FR_NO_FILE; /* Report EOT when end of table */ + } + else { /* Dynamic table */ + if (((i / 16) & (fs->csize - 1)) == 0) { /* Cluster changed? */ + clst = get_fat(dj->clust); /* Get next cluster */ + if (clst <= 1) return FR_DISK_ERR; + if (clst >= fs->n_fatent) return FR_NO_FILE; /* Report EOT when it reached end of dynamic table */ + dj->clust = clst; /* Initialize data for new cluster */ + dj->sect = clust2sect(clst); + } + } + } + + dj->index = i; + + return FR_OK; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Directory handling - Find an object in the directory */ +/*-----------------------------------------------------------------------*/ + +FRESULT dir_find ( + DIR *dj, /* Pointer to the directory object linked to the file name */ + BYTE *dir /* 32-byte working buffer */ +) +{ + FRESULT res; + BYTE c; + + + res = dir_rewind(dj); /* Rewind directory object */ + if (res != FR_OK) return res; + + do { + res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ + ? FR_DISK_ERR : FR_OK; + if (res != FR_OK) break; + c = dir[DIR_Name]; /* First character */ + if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ + if (!(dir[DIR_Attr] & AM_VOL) && !mem_cmp(dir, dj->fn, 11)) break; /* Is it a valid entry? */ + res = dir_next(dj); /* Next entry */ + } while (res == FR_OK); + + return res; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Read an object from the directory */ +/*-----------------------------------------------------------------------*/ +FRESULT dir_read ( + DIR *dj, /* Pointer to the directory object to store read object name */ + BYTE *dir /* 32-byte working buffer */ +) +{ + FRESULT res; + BYTE a, c; + + + res = FR_NO_FILE; + while (dj->sect) { + + res = disk_readp(dir, dj->sect, (dj->index % 16) * 32, 32) /* Read an entry */ + ? FR_DISK_ERR : FR_OK; + if (res != FR_OK) break; + c = dir[DIR_Name]; + if (c == 0) { res = FR_NO_FILE; break; } /* Reached to end of table */ + a = dir[DIR_Attr] & AM_MASK; + if (c != 0xE5 && c != '.' && !(a & AM_VOL)) break; /* Is it a valid entry? */ + res = dir_next(dj); /* Next entry */ + if (res != FR_OK) break; + } + + if (res != FR_OK) dj->sect = 0; + + return res; +} + + +/*-----------------------------------------------------------------------*/ +/* Get file information from directory entry */ +/*-----------------------------------------------------------------------*/ +void get_fileinfo ( /* No return code */ + DIR *dj, /* Pointer to the directory object */ + BYTE *dir, /* 32-byte working buffer */ + FILINFO *fno /* Pointer to store the file information */ +) +{ + BYTE i, c; + char *p; + + + p = fno->fname; + if (dj->sect) { + for (i = 0; i < 8; i++) { /* Copy file name body */ + c = dir[i]; + if (c == ' ') break; + if (c == 0x05) c = 0xE5; + *p++ = c; + } + if (dir[8] != ' ') { /* Copy file name extension */ + *p++ = '.'; + for (i = 8; i < 11; i++) { + c = dir[i]; + if (c == ' ') break; + *p++ = c; + } + } + fno->fattrib = dir[DIR_Attr]; /* Attribute */ + fno->fsize = ld_dword(dir+DIR_FileSize); /* Size */ + fno->fdate = ld_word(dir+DIR_WrtDate); /* Date */ + fno->ftime = ld_word(dir+DIR_WrtTime); /* Time */ + } + *p = 0; +} + + + + +/*-------------------------------------------------------------------------- + + Public Functions + +--------------------------------------------------------------------------*/ + + + +/*-----------------------------------------------------------------------*/ +/* Create a Directroy Object */ +/*-----------------------------------------------------------------------*/ +FRESULT pf_opendir ( + DIR *dj, /* Pointer to directory object to create */ + const char *path /* Pointer to the directory path */ +) +{ + FRESULT res; + BYTE sp[12], dir[32]; + FATFS *fs = FatFs; + + + if (!fs) { /* Check file system */ + res = FR_NOT_ENABLED; + } else { + dj->fn = sp; + res = follow_path(dj, dir, path); /* Follow the path to the directory */ + if (res == FR_OK) { /* Follow completed */ + if (dir[0]) { /* It is not the root dir */ + if (dir[DIR_Attr] & AM_DIR) { /* The object is a directory */ + dj->sclust = get_clust(dir); + } else { /* The object is not a directory */ + res = FR_NO_FILE; + } + } + if (res == FR_OK) { + res = dir_rewind(dj); /* Rewind dir */ + } + } + } + + return res; +} + + + +/*-----------------------------------------------------------------------*/ +/* Read Directory Entry in Sequense */ +/*-----------------------------------------------------------------------*/ + +FRESULT pf_readdir ( + DIR *dj, /* Pointer to the open directory object */ + FILINFO *fno /* Pointer to file information to return */ +) +{ + FRESULT res; + BYTE sp[12], dir[32]; + FATFS *fs = FatFs; + + + if (!fs) { /* Check file system */ + res = FR_NOT_ENABLED; + } else { + dj->fn = sp; + if (!fno) { + res = dir_rewind(dj); + } else { + res = dir_read(dj, dir); /* Get current directory item */ + if (res == FR_NO_FILE) res = FR_OK; + if (res == FR_OK) { /* A valid entry is found */ + get_fileinfo(dj, dir, fno); /* Get the object information */ + res = dir_next(dj); /* Increment read index for next */ + // if (res == FR_NO_FILE) res = FR_OK; + } + } + } + + return res; +} diff --git a/software/src/PetitFS/pff_dir.h b/software/src/PetitFS/pff_dir.h new file mode 100644 index 0000000..68108bc --- /dev/null +++ b/software/src/PetitFS/pff_dir.h @@ -0,0 +1,39 @@ +/*---------------------------------------------------------------------------/ +/ Petit FatFs - FAT file system module include file R0.03a +/----------------------------------------------------------------------------/ +/ Petit FatFs module is an open source software to implement FAT file system to +/ small embedded systems. This is a free software and is opened for education, +/ research and commercial developments under license policy of following trems. +/ +/ Copyright (C) 2019, ChaN, all right reserved. +/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 +/ +/ * The Petit FatFs module is a free software and there is NO WARRANTY. +/ * No restriction on use. You can use, modify and redistribute it for +/ personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. +/ * Redistributions of source code must retain the above copyright notice. +/ +/----------------------------------------------------------------------------*/ + +#ifndef PF_DIR_DEFINED +#define PF_DIR_DEFINED 8088 /* Revision ID */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/*--------------------------------------------------------------*/ +/* Petit FatFs module application interface */ +FRESULT dir_rewind(DIR *dj); +FRESULT dir_next(DIR *dj); +FRESULT dir_find(DIR *dj, BYTE *dir); +FRESULT dir_read(DIR *dj, BYTE *dir); +void get_fileinfo(DIR *dj, BYTE *dir, FILINFO *fno); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/software/src/PetitFS/pff_func.c b/software/src/PetitFS/pff_func.c new file mode 100644 index 0000000..4df59cf --- /dev/null +++ b/software/src/PetitFS/pff_func.c @@ -0,0 +1,272 @@ +/*----------------------------------------------------------------------------/ +/ Petit FatFs - FAT file system module R0.03a +/-----------------------------------------------------------------------------/ +/ +/ Copyright (C) 2019, ChaN, all right reserved. +/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 +/ +/ Petit FatFs module is an open source software. Redistribution and use of +/ Petit FatFs in source and binary forms, with or without modification, are +/ permitted provided that the following condition is met: +/ +/ 1. Redistributions of source code must retain the above copyright notice, +/ this condition and the following disclaimer. +/ +/ This software is provided by the copyright holder and contributors "AS IS" +/ and any warranties related to this software are DISCLAIMED. +/ The copyright owner or contributors be NOT LIABLE for any damages caused +/ by use of this software. +/-----------------------------------------------------------------------------/ +/ Jun 15,'09 R0.01a First release. +/ +/ Dec 14,'09 R0.02 Added multiple code page support. +/ Added write funciton. +/ Changed stream read mode interface. +/ Dec 07,'10 R0.02a Added some configuration options. +/ Fixed fails to open objects with DBCS character. + +/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. +/ Added _USE_LCC option. +/ Added _FS_FAT16 option. +/ +/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. +/ Removed _WORD_ACCESS option. +/ Changed prefix of configuration options, _ to PF_. +/ Added some code pages. +/ Removed some code pages actually not valid. +/ +/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in +/ banked ROMS as part of the RFS on the Sharp MZ80A. +/----------------------------------------------------------------------------*/ + +#include +#include +#include "pff.h" /* Petit FatFs configurations and declarations */ +#include "sdmmc.h" /* Declarations of low level disk I/O functions */ +#define PFF_FUNC_C +#include "pff_func.h" + +/*-------------------------------------------------------------------------- + + Module Private Definitions + +---------------------------------------------------------------------------*/ + + +/*-------------------------------------------------------------------------- + + Private Functions + +---------------------------------------------------------------------------*/ + + +/*-----------------------------------------------------------------------*/ +/* Load multi-byte word in the FAT structure */ +/*-----------------------------------------------------------------------*/ + +WORD ld_word (const BYTE* ptr) /* Load a 2-byte little-endian word */ +{ + WORD rv; + + rv = ptr[1]; + rv = rv << 8 | ptr[0]; + return rv; +} + +DWORD ld_dword (const BYTE* ptr) /* Load a 4-byte little-endian word */ +{ + DWORD rv; + + rv = ptr[3]; + rv = rv << 8 | ptr[2]; + rv = rv << 8 | ptr[1]; + rv = rv << 8 | ptr[0]; + return rv; +} + + + +/*-----------------------------------------------------------------------*/ +/* String functions */ +/*-----------------------------------------------------------------------*/ + +/* Fill memory block */ +void mem_set (void* dst, int val, int cnt) { + char *d = (char*)dst; + while (cnt--) *d++ = (char)val; +} + +/* Compare memory block */ +int mem_cmp (const void* dst, const void* src, int cnt) { + const char *d = (const char *)dst, *s = (const char *)src; + int r = 0; + while (cnt-- && (r = *d++ - *s++) == 0) ; + return r; +} + +/*-----------------------------------------------------------------------*/ +/* FAT access - Read value of a FAT entry */ +/*-----------------------------------------------------------------------*/ + +CLUST get_fat ( /* 1:IO error, Else:Cluster status */ + CLUST clst /* Cluster# to get the link information */ +) +{ + BYTE buf[4]; + FATFS *fs = FatFs; + + if (clst < 2 || clst >= fs->n_fatent) return 1; /* Range check */ + + switch (fs->fs_type) { + case FS_FAT32 : + if (disk_readp(buf, fs->fatbase + clst / 128, ((UINT)clst % 128) * 4, 4)) break; + return ld_dword(buf) & 0x0FFFFFFF; + } + + return 1; /* An error occured at the disk I/O layer */ +} + + +/*-----------------------------------------------------------------------*/ +/* Get sector# from cluster# / Get cluster field from directory entry */ +/*-----------------------------------------------------------------------*/ + +DWORD clust2sect ( /* !=0: Sector number, 0: Failed - invalid cluster# */ + CLUST clst /* Cluster# to be converted */ +) +{ + FATFS *fs = FatFs; + + clst -= 2; + if (clst >= (fs->n_fatent - 2)) return 0; /* Invalid cluster# */ + return (DWORD)clst * fs->csize + fs->database; +} + + +CLUST get_clust ( + BYTE* dir /* Pointer to directory entry */ +) +{ + FATFS *fs = FatFs; + CLUST clst = 0; + + + clst = ld_word(dir+DIR_FstClusHI); + clst <<= 16; + clst |= ld_word(dir+DIR_FstClusLO); + + return clst; +} + +/*-----------------------------------------------------------------------*/ +/* Pick a segment and create the object name in directory form */ +/*-----------------------------------------------------------------------*/ + + +FRESULT create_name ( + DIR *dj, /* Pointer to the directory object */ + const char **path /* Pointer to pointer to the segment in the path string */ +) +{ + BYTE c, d, ni, si, i, *sfn; + const char *p; +#if PF_USE_LCC && defined(_EXCVT) + static const BYTE cvt[] = _EXCVT; +#endif + + /* Create file name in directory form */ + sfn = dj->fn; + mem_set(sfn, ' ', 11); + si = i = 0; ni = 8; + p = *path; + for (;;) { + c = p[si++]; + if (c <= ' ' || c == '/') break; /* Break on end of segment */ + if (c == '.' || i >= ni) { + if (ni != 8 || c != '.') break; + i = 8; ni = 11; + continue; + } +#if PF_USE_LCC && defined(_EXCVT) + if (c >= 0x80) c = cvt[c - 0x80]; /* To upper extended char (SBCS) */ +#endif + if (IsDBCS1(c) && i < ni - 1) { /* DBC 1st byte? */ + d = p[si++]; /* Get 2nd byte */ + sfn[i++] = c; + sfn[i++] = d; + } else { /* Single byte code */ + if (PF_USE_LCC && IsLower(c)) c -= 0x20; /* toupper */ + sfn[i++] = c; + } + } + *path = &p[si]; /* Rerurn pointer to the next segment */ + + sfn[11] = (c <= ' ') ? 1 : 0; /* Set last segment flag if end of path */ + + return FR_OK; +} + + +/*-----------------------------------------------------------------------*/ +/* Follow a file path */ +/*-----------------------------------------------------------------------*/ + +FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */ + DIR *dj, /* Directory object to return last directory and found object */ + BYTE *dir, /* 32-byte working buffer */ + const char *path /* Full-path string to find a file or directory */ +) +{ + FRESULT res; + + + while (*path == ' ') path++; /* Strip leading spaces */ + if (*path == '/') path++; /* Strip heading separator if exist */ + dj->sclust = 0; /* Set start directory (always root dir) */ + + if ((BYTE)*path < ' ') { /* Null path means the root directory */ + res = dir_rewind(dj); + dir[0] = 0; + + } else { /* Follow path */ + for (;;) { + res = create_name(dj, &path); /* Get a segment */ + if (res != FR_OK) break; + res = dir_find(dj, dir); /* Find it */ + if (res != FR_OK) break; /* Could not find the object */ + if (dj->fn[11]) break; /* Last segment match. Function completed. */ + if (!(dir[DIR_Attr] & AM_DIR)) { /* Cannot follow path because it is a file */ + res = FR_NO_FILE; break; + } + dj->sclust = get_clust(dir); /* Follow next */ + } + } + + return res; +} + + +/*-----------------------------------------------------------------------*/ +/* Check a sector if it is an FAT boot record */ +/*-----------------------------------------------------------------------*/ + +BYTE check_fs ( /* 0:The FAT boot record, 1:Valid boot record but not an FAT, 2:Not a boot record, 3:Error */ + BYTE *buf, /* Working buffer */ + DWORD sect /* Sector# (lba) to check if it is an FAT boot record or not */ +) +{ + if (disk_readp(buf, sect, 510, 2)) { /* Read the boot record */ + return 3; + } + if (ld_word(buf) != 0xAA55) { /* Check record signature */ + return 2; + } + +// if (!_FS_32ONLY && !disk_readp(buf, sect, BS_FilSysType, 2) && ld_word(buf) == 0x4146) { /* Check FAT12/16 */ +// return 0; +// } + if (!disk_readp(buf, sect, BS_FilSysType32, 2) && ld_word(buf) == 0x4146) { /* Check FAT32 */ + return 0; + } + return 1; +} diff --git a/software/src/PetitFS/pff_func.h b/software/src/PetitFS/pff_func.h new file mode 100644 index 0000000..d586421 --- /dev/null +++ b/software/src/PetitFS/pff_func.h @@ -0,0 +1,47 @@ +/*---------------------------------------------------------------------------/ +/ Petit FatFs - FAT file system module include file R0.03a +/----------------------------------------------------------------------------/ +/ Petit FatFs module is an open source software to implement FAT file system to +/ small embedded systems. This is a free software and is opened for education, +/ research and commercial developments under license policy of following trems. +/ +/ Copyright (C) 2019, ChaN, all right reserved. +/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 +/ +/ * The Petit FatFs module is a free software and there is NO WARRANTY. +/ * No restriction on use. You can use, modify and redistribute it for +/ personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. +/ * Redistributions of source code must retain the above copyright notice. +/ +/----------------------------------------------------------------------------*/ + +#ifndef PF_FUNC_DEFINED +#define PF_FUNC_DEFINED 8088 /* Revision ID */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/*--------------------------------------------------------------*/ +/* Petit FatFs module application interface */ +WORD ld_word (const BYTE* ptr); +DWORD ld_dword (const BYTE* ptr); +void mem_set (void* dst, int val, int cnt); +int mem_cmp (const void* dst, const void* src, int cnt); +CLUST get_fat(CLUST clst); +DWORD clust2sect( CLUST clst); +FRESULT create_name (DIR *dj, const char **path); +FRESULT follow_path ( DIR *dj, BYTE *dir, const char *path); +CLUST get_clust(BYTE* dir); +BYTE check_fs(BYTE *buf, DWORD sect); + +extern FRESULT dir_rewind(DIR *dj); +extern FRESULT dir_find(DIR *dj, BYTE *dir); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/software/src/PetitFS/pff_mount.c b/software/src/PetitFS/pff_mount.c new file mode 100644 index 0000000..ce66165 --- /dev/null +++ b/software/src/PetitFS/pff_mount.c @@ -0,0 +1,116 @@ +/*----------------------------------------------------------------------------/ +/ Petit FatFs - FAT file system module R0.03a +/-----------------------------------------------------------------------------/ +/ +/ Copyright (C) 2019, ChaN, all right reserved. +/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 +/ +/ Petit FatFs module is an open source software. Redistribution and use of +/ Petit FatFs in source and binary forms, with or without modification, are +/ permitted provided that the following condition is met: +/ +/ 1. Redistributions of source code must retain the above copyright notice, +/ this condition and the following disclaimer. +/ +/ This software is provided by the copyright holder and contributors "AS IS" +/ and any warranties related to this software are DISCLAIMED. +/ The copyright owner or contributors be NOT LIABLE for any damages caused +/ by use of this software. +/-----------------------------------------------------------------------------/ +/ Jun 15,'09 R0.01a First release. +/ +/ Dec 14,'09 R0.02 Added multiple code page support. +/ Added write funciton. +/ Changed stream read mode interface. +/ Dec 07,'10 R0.02a Added some configuration options. +/ Fixed fails to open objects with DBCS character. + +/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. +/ Added _USE_LCC option. +/ Added _FS_FAT16 option. +/ +/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. +/ Removed _WORD_ACCESS option. +/ Changed prefix of configuration options, _ to PF_. +/ Added some code pages. +/ Removed some code pages actually not valid. +/ +/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in +/ banked ROMS as part of the RFS on the Sharp MZ80A. +/----------------------------------------------------------------------------*/ + +#include +#include +#include "pff.h" /* Petit FatFs configurations and declarations */ +#include "sdmmc.h" /* Declarations of low level disk I/O functions */ +#define PFF_MOUNT_C +#include "pff_func.h" + +/*-----------------------------------------------------------------------*/ +/* Mount/Unmount a Locical Drive */ +/*-----------------------------------------------------------------------*/ + +FRESULT pf_mount ( + FATFS *fs /* Pointer to new file system object */ +) +{ + BYTE fmt, buf[36]; + DWORD bsect, fsize, tsect, mclst; + + + FatFs = 0; + if (disk_initialize() & STA_NOINIT) { /* Check if the drive is ready or not */ + return FR_NOT_READY; + } + + /* Search FAT partition on the drive */ + bsect = 0; + fmt = check_fs(buf, bsect); /* Check sector 0 as an SFD format */ + if (fmt == 1) { /* Not an FAT boot record, it may be FDISK format */ + /* Check a partition listed in top of the partition table */ + if (disk_readp(buf, bsect, MBR_Table, 16)) { /* 1st partition entry */ + fmt = 3; + } else { + if (buf[4]) { /* Is the partition existing? */ + bsect = ld_dword(&buf[8]); /* Partition offset in LBA */ + fmt = check_fs(buf, bsect); /* Check the partition */ + } + } + } + if (fmt == 3) return FR_DISK_ERR; + if (fmt) return FR_NO_FILESYSTEM; /* No valid FAT patition is found */ + + /* Initialize the file system object */ + if (disk_readp(buf, bsect, 13, sizeof (buf))) return FR_DISK_ERR; + + fsize = ld_word(buf+BPB_FATSz16-13); /* Number of sectors per FAT */ + if (!fsize) fsize = ld_dword(buf+BPB_FATSz32-13); + + fsize *= buf[BPB_NumFATs-13]; /* Number of sectors in FAT area */ + fs->fatbase = bsect + ld_word(buf+BPB_RsvdSecCnt-13); /* FAT start sector (lba) */ + fs->csize = buf[BPB_SecPerClus-13]; /* Number of sectors per cluster */ + fs->n_rootdir = ld_word(buf+BPB_RootEntCnt-13); /* Nmuber of root directory entries */ + tsect = ld_word(buf+BPB_TotSec16-13); /* Number of sectors on the file system */ + if (!tsect) tsect = ld_dword(buf+BPB_TotSec32-13); + mclst = (tsect /* Last cluster# + 1 */ + - ld_word(buf+BPB_RsvdSecCnt-13) - fsize - fs->n_rootdir / 16 + ) / fs->csize + 2; + fs->n_fatent = (CLUST)mclst; + + fmt = 0; /* Determine the FAT sub type */ + if (mclst >= 0xFFF7) fmt = FS_FAT32; + if (!fmt) return FR_NO_FILESYSTEM; + fs->fs_type = fmt; + +// if (_FS_32ONLY || (PF_FS_FAT32 && fmt == FS_FAT32)) { + fs->dirbase = ld_dword(buf+(BPB_RootClus-13)); /* Root directory start cluster */ +// } else { +// fs->dirbase = fs->fatbase + fsize; /* Root directory start sector (lba) */ +// } + fs->database = fs->fatbase + fsize + fs->n_rootdir / 16; /* Data start sector (lba) */ + + fs->flag = 0; + FatFs = fs; + + return FR_OK; +} diff --git a/software/src/PetitFS/pff_mount.h b/software/src/PetitFS/pff_mount.h new file mode 100644 index 0000000..729c2a3 --- /dev/null +++ b/software/src/PetitFS/pff_mount.h @@ -0,0 +1,36 @@ +/*---------------------------------------------------------------------------/ +/ Petit FatFs - FAT file system module include file R0.03a +/----------------------------------------------------------------------------/ +/ Petit FatFs module is an open source software to implement FAT file system to +/ small embedded systems. This is a free software and is opened for education, +/ research and commercial developments under license policy of following trems. +/ +/ Copyright (C) 2019, ChaN, all right reserved. +/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 +/ +/ * The Petit FatFs module is a free software and there is NO WARRANTY. +/ * No restriction on use. You can use, modify and redistribute it for +/ personal, non-profit or commercial use UNDER YOUR RESPONSIBILITY. +/ * Redistributions of source code must retain the above copyright notice. +/ +/----------------------------------------------------------------------------*/ + +#ifndef PF_MOUNT_DEFINED +#define PF_MOUNT_DEFINED 8088 /* Revision ID */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/*--------------------------------------------------------------*/ +/* Petit FatFs module application interface */ +extern FRESULT dir_rewind(DIR *dj); +extern FRESULT dir_find(DIR *dj, BYTE *dir); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/software/src/PetitFS/pff_obj/new.asm b/software/src/PetitFS/pff_obj/new.asm new file mode 100644 index 0000000..59667d5 --- /dev/null +++ b/software/src/PetitFS/pff_obj/new.asm @@ -0,0 +1,5962 @@ +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Fri Mar 13 16:37:44 2020 + + + + MODULE sdtest_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION code_compiler + +; Function die flags 0x00000200 __smallc +; void die(const int rc) +; parameter 'const int rc' at 2 size(2) +._die + ld hl,i_1+0 + push hl + ld hl,4 ;const + call l_gintsp ; + push hl + ld a,2 + call printf + pop bc + pop bc + ld hl,i_1+20 + push hl + ld a,1 + call printf + pop bc + ld hl,10 ;const + call sleep + ret + + + +; Function main flags 0x00000000 __stdc +; int main() +._main + ld hl,65381 ;const + add hl,sp + ld sp,hl + ld hl,i_1+41 + push hl + ld a,1 + call printf + pop bc + ld hl,i_1+86 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + ld de,5 ;const + ex de,hl + call l_pint + call _disk_initialize + call l_lneg + jp nc,i_2 + ld hl,i_1+115 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,115 ;const + add hl,sp + push hl + call _pf_mount + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_3 + ld hl,i_1+137 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_3 + ld hl,i_1+192 + push hl + ld a,1 + call printf + pop bc +.i_2 + ld hl,i_1+209 + push hl + ld hl,115 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,118 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,121 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,124 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,129 ;const + add hl,sp + call l_glong2sp + ld hl,137 ;const + call l_glongsp ; + ld a,9 + call printf + ld hl,18 ;const + add hl,sp + ld sp,hl + ld hl,i_1+275 + push hl + ld hl,129 ;const + add hl,sp + call l_glong2sp + ld hl,137 ;const + add hl,sp + call l_glong2sp + ld hl,145 ;const + add hl,sp + call l_glong2sp + ld hl,153 ;const + add hl,sp + call l_glong2sp + ld hl,161 ;const + add hl,sp + call l_glong2sp + ld hl,169 ;const + add hl,sp + call l_glong2sp + ld hl,177 ;const + call l_glongsp ; + ld a,15 + call printf + ld hl,30 ;const + add hl,sp + ld sp,hl + ld hl,10 ;const + call sleep + ld hl,i_1+365 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,99 ;const + add hl,sp + push hl + ld hl,i_1+19 + push hl + call _pf_opendir + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_4 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_4 + ld hl,i_1+388 + push hl + ld a,1 + call printf + pop bc +.i_5 +.i_7 + ld hl,3 ;const + add hl,sp + push hl + ld hl,99 ;const + add hl,sp + push hl + ld hl,79 ;const + add hl,sp + push hl + call _pf_readdir + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_9 + ld hl,75 ;const + call l_gcharsp ; + call l_lneg + jr nc,i_8 +.i_9 + jp i_6 +.i_8 + ld hl,83 ;const + add hl,sp + ld a,+(16 % 256) + and (hl) + jp z,i_11 + ld hl,i_1+411 + push hl + ld hl,86 ;const + add hl,sp + push hl + ld a,2 + call printf + pop bc + pop bc + jp i_12 +.i_11 + ld hl,i_1+425 + push hl + ld hl,77 ;const + add hl,sp + call l_glong2sp + ld hl,90 ;const + add hl,sp + push hl + ld a,4 + call printf + pop bc + pop bc + pop bc + pop bc +.i_12 + jp i_5 +.i_6 + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_13 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_13 + ld hl,i_1+435 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,i_1+469 + push hl + call _pf_open + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_14 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_14 + ld hl,i_1+481 + push hl + ld a,1 + call printf + pop bc +.i_15 + ld hl,3 ;const + add hl,sp + push hl + ld hl,7 ;const + add hl,sp + push hl + ld hl,64 ;const + push hl + ld hl,77 ;const + add hl,sp + push hl + call _pf_read + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_18 + ld hl,71 ;const + call l_gintsp ; + call l_lneg + jr nc,i_17 +.i_18 + jp i_16 +.i_17 + ld hl,69 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint + jp i_22 +.i_20 + ld hl,69 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) +.i_22 + ld hl,69 ;const + call l_gintspsp ; + ld hl,73 ;const + call l_gintsp ; + pop de + ex de,hl + and a + sbc hl,de + jp nc,i_21 + ld hl,5 ;const + add hl,sp + ex de,hl + ld hl,69 ;const + call l_gintsp ; + add hl,de + ld l,(hl) + ld h,0 + push hl + ld hl,__sgoioblk+10 + push hl + call fputc_callee + jp i_20 +.i_21 + jp i_15 +.i_16 + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_23 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_23 + ld hl,20 ;const + call sleep + ld hl,i_1+506 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,i_1+543 + push hl + call _pf_open + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_24 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_24 + ld hl,i_1+554 + push hl + ld a,1 + call printf + pop bc +.i_25 +.i_27 + ld hl,3 ;const + add hl,sp + push hl + ld hl,i_1+590 + push hl + ld hl,14 ;const + push hl + ld hl,79 ;const + add hl,sp + push hl + call _pf_write + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_29 + ld hl,73 ;const + call l_gintsp ; + call l_lneg + jr nc,i_28 +.i_29 + jp i_26 +.i_28 + jp i_25 +.i_26 + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_31 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_31 + ld hl,i_1+605 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,0 ;const + push hl + push hl + ld hl,79 ;const + add hl,sp + push hl + call _pf_write + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_32 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_32 + ld hl,i_1+641 + push hl + ld a,1 + call printf + pop bc +.i_33 +.i_35 + jp i_33 +.i_34 + ld hl,155 ;const + add hl,sp + ld sp,hl + ret + + + SECTION rodata_compiler +.i_1 + defm "Failed with rc=%u." + defb 10 + + defm "" + defb 0 + + defm "Please press reset." + defb 10 + + defm "" + defb 0 + + defm "Hello Philip, this C program i" + defm "s working...." + defb 10 + + defm "" + defb 0 + + defm "Firstly, initialise SD card" + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Now Mount a volume." + defb 10 + + defm "" + defb 0 + + defm "Failed to initialise sd card 0" + defm ", please init manually." + defb 10 + + defm "" + defb 0 + + defm "Volume mounted." + defb 10 + + defm "" + defb 0 + + defm "FSTYPE:%d, FLAG:%d, CSIZE:%d, " + defm "PADL:%d, N_FATENT:%ld, FATBASE" + defm ":%;d" + defb 10 + + defm "" + defb 0 + + defm "DIRBASE:%ld, DATABASE:%ld, FPT" + defm "R:%ld, FSIZE:%ld, ORG_CLUST:%l" + defm "d, CURR_CLUST:%ld, DSECT:%ld" + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Open root directory." + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Directory listing..." + defb 10 + + defm "" + defb 0 + + defm " %s" + defb 10 + + defm "" + defb 0 + + defm "%8lu %s" + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Open a test file (message.txt)" + defm "." + defb 10 + + defm "" + defb 0 + + defm "MESSAGE.TXT" + defb 0 + + defm "" + defb 10 + + defm "Type the file content." + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Open a file to write (readme.t" + defm "xt)." + defb 10 + + defm "" + defb 0 + + defm "README.TXT" + defb 0 + + defm "" + defb 10 + + defm "Write a text data. (Hello worl" + defm "d!)" + defb 10 + + defm "" + defb 0 + + defm "Hello world!" + defb 13 + + defm "" + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Terminate the file write proce" + defm "ss." + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Test completed." + defb 10 + + defm "" + defb 0 + + +; --- Start of Static Variables --- + + SECTION bss_compiler + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + GLOBAL _die + GLOBAL _main + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Fri Mar 13 16:37:44 2020 + + + + MODULE sdmmc_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION data_compiler +._Stat + defb 1 + SECTION code_compiler + +; Function spi_init flags 0x00000200 __smallc +; int spi_init() +._spi_init + LD A, 0x04 | 0x00 | 0x00 ; Clock and MOSI High. + OUT ( 0xFF ),A + LD B,80 + LD A, 0x04 | 0x00 | 0x00 ; Output a 1 +SPIINIT1: OUT ( 0xFF ),A + NOP + NOP + LD A, 0x04 | 0x02 | 0x00 ; Output a 1 + OUT ( 0xFF ),A + NOP + NOP + DJNZ SPIINIT1 + LD A, 0x04 | 0x00 | 0x00 ; Output a 1 + OUT ( 0xFF ),A + LD HL,0 ; hl is the return parameter + ret + + + +; Function spi_cs flags 0x00000200 __smallc +; int spi_cs(unsigned char b) +; parameter 'unsigned char b' at 2 size(1) +._spi_cs + ret + + + +; Function spi_out flags 0x00000200 __smallc +; int spi_out(unsigned char b) +; parameter 'unsigned char b' at 2 size(1) +._spi_out + LD HL,2 + ADD HL,SP ; skip over return address on stack + LD A,(HL) ; a = b, "char b" occupies 16 bits on stack + ; but only the LSB is relevant + LD E,A ; E = Character to send. + LD B,08H ; B = Bit count +SPIOUT0: RL E + LD A, 0x00 | 0x00 | 0x00 ; Output a 0 + JR NC,SPIOUT1 + LD A, 0x04 | 0x00 | 0x00 ; Output a 1 +SPIOUT1: OUT ( 0xFF ),A + LD D,A + OR 0x02 + OUT ( 0xFF ),A + LD A,D + OUT ( 0xFF ),A + DJNZ SPIOUT0 ; Perform actions for the full 8 bits. + ;LD A, 0x04 | 0x00 | 0x00 ; Return clock and MOSI to high. + ;OUT ( 0xFF ),A + LD HL,0 ; hl is the return parameter + ret + + + +; Function spi_in flags 0x00000200 __smallc +; unsigned char uint8_tspi_in() +._spi_in + LD BC,0800H ; B = Bit count, C = Character being read. +SPIIN0: LD A, 0x04 | 0x00 | 0x00 ; Output a 0 +SPIIN1: OUT ( 0xFF ),A + LD D,A + OR 0x02 + OUT ( 0xFF ),A + NOP + IN A,( 0xFE ) ; Input the received bit + SRL A + RL C + LD A,D + OUT ( 0xFF ),A + DJNZ SPIIN0 ; Perform actions for the full 8 bits. + LD L,C ; hl is the return parameter + LD H,0 + ret + + + +; Function spi_skip flags 0x00000200 __smallc +; void spi_skip(unsigned int n) +; parameter 'unsigned int n' at 2 size(2) +._spi_skip + dec sp +.i_5 + ld hl,0 ;const + add hl,sp + push hl + call _spi_in + pop de + ld a,l + ld (de),a +.i_3 + ld hl,3 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + ld a,h + or l + jp nz,i_5 +.i_4 + inc sp + ret + + + +; Function send_cmd flags 0x00000200 __smallc +; unsigned char BYTEsend_cmd(unsigned char cmd, unsigned long arg) +; parameter 'unsigned long arg' at 2 size(4) +; parameter 'unsigned char cmd' at 6 size(1) +._send_cmd + push bc + ld hl,8 ;const + add hl,sp + ld a,+(128 % 256) + and (hl) + jp z,i_6 + ld hl,8 ;const + add hl,sp + push hl + ld a,(hl) + and +(127 % 256) + ld l,a + ld h,0 + pop de + ld a,l + ld (de),a + ld hl,0 ;const + add hl,sp + push hl + ld hl,55 ;const + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + pop de + ld a,l + ld (de),a + pop hl + push hl + ld h,0 + ld a,1 + sub l + jp nc,i_7 + pop hl + push hl + ld h,0 + pop bc + ret + + +.i_7 +.i_6 + ld hl,255 ;const + push hl + call _spi_cs + pop bc + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + call _spi_out + pop bc + ld hl,7 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + push hl + call _spi_out + pop bc + ld hl,6 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + push hl + call _spi_out + pop bc + ld hl,5 ;const + add hl,sp + ld e,(hl) + inc hl + inc hl + ld l,(hl) + ld h,0 + ex de,hl + ld h,0 + push hl + call _spi_out + pop bc + ld hl,4 ;const + add hl,sp + call l_glong + ld h,0 + push hl + call _spi_out + pop bc + ld hl,1 ;const + add hl,sp + ld (hl),+(1 % 256 % 256) + ld hl,8 ;const + add hl,sp + ld a,(hl) + and a + jp nz,i_8 + ld hl,1 ;const + add hl,sp + ld (hl),+(149 % 256 % 256) +.i_8 + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 8 + jp nz,i_9 + ld hl,1 ;const + add hl,sp + ld (hl),+(135 % 256 % 256) +.i_9 + pop hl + push hl + ld l,h + ld h,0 + push hl + call _spi_out + pop bc + ld hl,1 ;const + add hl,sp + ld (hl),+(10 % 256 % 256) +.i_12 + ld hl,0 ;const + add hl,sp + push hl + call _spi_in + pop de + ld a,l + ld (de),a +.i_10 + pop hl + push hl + ld h,0 + ld a,l + and +(128 % 256) + jp z,i_13 + ld hl,1 ;const + add hl,sp + dec (hl) + ld a,(hl) + and a + jr nz,i_14_i_13 +.i_13 + jp i_11 +.i_14_i_13 + jp i_12 +.i_11 + pop hl + push hl + ld h,0 + pop bc + ret + + + +; Function disk_initialize flags 0x00000200 __smallc +; unsigned char DSTATUSdisk_initialize() +._disk_initialize + push bc + push bc + push bc + push bc + dec sp + call _spi_init + ld hl,6 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld hl,0 ;const + push hl + ld d,h + ld e,l + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + cp 1 + jp nz,i_15 + ld hl,8 ;const + push hl + ld hl,426 ;const + ld de,0 + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + cp 1 + jp nz,i_16 + ld hl,i_1+0 + push hl + ld a,1 + call printf + pop bc + ld hl,8 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_19 +.i_17 + ld hl,8 ;const + add hl,sp + inc (hl) +.i_19 + ld hl,8 ;const + add hl,sp + ld a,(hl) + sub 4 + jp nc,i_18 + ld hl,2 ;const + add hl,sp + ex de,hl + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + push hl + call _spi_in + pop de + ld a,l + ld (de),a + jp i_17 +.i_18 + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 1 + jp nz,i_21 + ld hl,5 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 170 + jr z,i_22_i_21 +.i_21 + jp i_20 +.i_22_i_21 + ld hl,1000 ;const + pop bc + push hl + jp i_25 +.i_23 + pop hl + dec hl + push hl + inc hl +.i_25 + pop hl + push hl + ld a,h + or l + jp z,i_24 + ld hl,169 ;const + push hl + ld hl,0 ;const + ld de,16384 + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + and a + jp z,i_24 +.i_26 + ld hl,2000 ;const + call t_delay + jp i_23 +.i_24 + pop hl + push hl + ld a,h + or l + jp z,i_28 + ld hl,58 ;const + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + and a + jr z,i_29_i_28 +.i_28 + jp i_27 +.i_29_i_28 + ld hl,8 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_32 +.i_30 + ld hl,8 ;const + add hl,sp + inc (hl) +.i_32 + ld hl,8 ;const + add hl,sp + ld a,(hl) + sub 4 + jp nc,i_31 + ld hl,2 ;const + add hl,sp + ex de,hl + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + push hl + call _spi_in + pop de + ld a,l + ld (de),a + jp i_30 +.i_31 + ld hl,6 ;const + add hl,sp + push hl + ld hl,4 ;const + add hl,sp + ld a,+(64 % 256) + and (hl) + jp z,i_33 + ld hl,12 ;const + jp i_34 +.i_33 + ld hl,4 ;const +.i_34 + pop de + ld a,l + ld (de),a +.i_27 +.i_20 + jp i_35 +.i_16 + ld hl,i_1+20 + push hl + ld a,1 + call printf + pop bc + ld hl,169 ;const + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,1 + sub l + ccf + jp nc,i_36 + ld hl,6 ;const + add hl,sp + ld (hl),+(2 % 256 % 256) + ld hl,7 ;const + add hl,sp + ld (hl),+(169 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_37 +.i_36 + ld hl,6 ;const + add hl,sp + ld (hl),+(1 % 256 % 256) + ld hl,7 ;const + add hl,sp + ld (hl),+(1 % 256 % 256) +.i_37 + ld hl,1000 ;const + pop bc + push hl + jp i_40 +.i_38 + pop hl + dec hl + push hl + inc hl +.i_40 + pop hl + push hl + ld a,h + or l + jp z,i_39 + ld hl,7 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + and a + jp z,i_39 +.i_41 + ld hl,2000 ;const + call t_delay + jp i_38 +.i_39 + pop hl + push hl + call l_lneg + jp c,i_43 + ld hl,16 ;const + push hl + ld hl,512 ;const + ld de,0 + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + and a + jp z,i_42 +.i_43 + ld hl,6 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld l,(hl) + ld h,0 +.i_42 +.i_35 +.i_15 + ld hl,6 ;const + add hl,sp + ld a,(hl) + ld (_CardType),a + ld hl,255 ;const + push hl + call _spi_cs + pop bc + ld hl,6 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_45 + ld hl,0 ;const + jp i_46 +.i_45 + ld hl,1 ;const +.i_46 + ld h,0 + inc sp + pop bc + pop bc + pop bc + pop bc + ret + + + +; Function disk_readp flags 0x00000200 __smallc +; const int DRESULTdisk_readp(unsigned char BYTE*buff, unsigned long sector, unsigned int offset, unsigned int count) +; parameter 'unsigned int count' at 2 size(2) +; parameter 'unsigned int offset' at 4 size(2) +; parameter 'unsigned long sector' at 6 size(4) +; parameter 'unsigned char BYTE*buff' at 10 size(2) +._disk_readp + push bc + push bc + push bc + dec sp + ld hl,0 ;const + push hl + call _spi_cs + pop bc + ld hl,(_CardType) + ld h,0 + ld a,+(8 % 256) + and l + ld l,a + call l_lneg + jp nc,i_47 + ld hl,13 ;const + add hl,sp + push hl + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_mult + pop bc + call l_plong +.i_47 + ld hl,5 ;const + add hl,sp + ld (hl),+(1 % 256) + inc hl + ld (hl),+(1 / 256) + ld hl,17 ;const + push hl + ld hl,15 ;const + call l_glongsp ; + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + and a + jp nz,i_48 + ld hl,1000 ;const + pop bc + push hl +.i_51 + ld hl,200 ;const + call t_delay + ld hl,4 ;const + add hl,sp + push hl + call _spi_in + pop de + ld a,l + ld (de),a +.i_49 + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 255 + jp nz,i_52 + pop hl + dec hl + push hl + ld a,h + or l + jr nz,i_53_i_52 +.i_52 + jp i_50 +.i_53_i_52 + jp i_51 +.i_50 + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 254 + jp nz,i_54 + ld hl,11 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,514 + and a + sbc hl,de + ex de,hl + ld hl,9 ;const + call l_gintsp ; + ex de,hl + and a + sbc hl,de + pop de + pop bc + push hl + push de + ld hl,11 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_55 + ld hl,11 ;const + call l_gintsp ; + push hl + call _spi_skip + pop bc +.i_55 + ld hl,17 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_56 +.i_59 + ld hl,4 ;const + add hl,sp + push hl + call _spi_in + pop de + ld a,l + ld (de),a + ld hl,17 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + push hl + ld hl,6 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a +.i_57 + ld hl,9 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + ld a,h + or l + jp nz,i_59 +.i_58 + jp i_60 +.i_56 +.i_63 + ld hl,4 ;const + add hl,sp + push hl + call _spi_in + pop de + ld a,l + ld (de),a +.i_61 + ld hl,9 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + ld a,h + or l + jp nz,i_63 +.i_62 +.i_60 + pop bc + pop hl + push hl + push bc + push hl + call _spi_skip + pop bc + ld hl,5 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint +.i_54 +.i_48 + ld hl,255 ;const + push hl + call _spi_cs + pop bc + ld hl,5 ;const + call l_gintsp ; + inc sp + pop bc + pop bc + pop bc + ret + + + +; Function disk_writep flags 0x00000200 __smallc +; const int DRESULTdisk_writep(const unsigned char BYTE*buff, unsigned long sc) +; parameter 'unsigned long sc' at 2 size(4) +; parameter 'const unsigned char BYTE*buff' at 6 size(2) +._disk_writep + push bc + push bc + push bc + ld hl,4 ;const + add hl,sp + ld (hl),+(1 % 256) + inc hl + ld (hl),+(1 / 256) + ld hl,0 ;const + push hl + call _spi_cs + pop bc + ld hl,12 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_64 + ld hl,8 ;const + add hl,sp + call l_glong + pop de + pop bc + push hl + push de +.i_65 + pop bc + pop hl + push hl + push bc + ld a,h + or l + jp z,i_67 + ld hl,(_st_disk_writep_wc) + ld a,h + or l + jr nz,i_68_i_67 +.i_67 + jp i_66 +.i_68_i_67 + ld hl,12 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + ld l,(hl) + ld h,0 + push hl + call _spi_out + pop bc + ld hl,(_st_disk_writep_wc) + dec hl + ld (_st_disk_writep_wc),hl + pop de + pop hl + dec hl + push hl + push de + inc hl + jp i_65 +.i_66 + ld hl,4 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint + jp i_69 +.i_64 + ld hl,8 ;const + add hl,sp + call l_glong + ld a,h + or l + or d + or e + jp z,i_70 + ld hl,(_CardType) + ld h,0 + ld a,+(8 % 256) + and l + ld l,a + call l_lneg + jp nc,i_71 + ld hl,8 ;const + add hl,sp + push hl + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_mult + pop bc + call l_plong +.i_71 + ld hl,24 ;const + push hl + ld hl,10 ;const + call l_glongsp ; + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + and a + jp nz,i_72 + ld hl,255 ;const + push hl + call _spi_out + pop bc + ld hl,254 ;const + push hl + call _spi_out + pop bc + ld hl,512 ;const + ld (_st_disk_writep_wc),hl + ld hl,4 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint +.i_72 + jp i_73 +.i_70 + ld hl,(_st_disk_writep_wc) + inc hl + inc hl + pop de + pop bc + push hl + push de +.i_74 + pop de + pop hl + dec hl + push hl + push de + inc hl + ld a,h + or l + jp z,i_75 + ld hl,0 ;const + push hl + call _spi_out + pop bc + jp i_74 +.i_75 + call _spi_in + ld a,l + and +(31 % 256) + ld l,a + ld h,0 + cp 5 + jp nz,i_76 + ld hl,10000 ;const + pop bc + push hl + jp i_79 +.i_77 + pop hl + dec hl + push hl + inc hl +.i_79 + call _spi_in + ld a,l + cp 255 + jp z,i_80 + pop hl + push hl + ld a,h + or l + jr nz,i_81_i_80 +.i_80 + jp i_78 +.i_81_i_80 + ld hl,200 ;const + call t_delay + jp i_77 +.i_78 + pop hl + push hl + ld a,h + or l + jp z,i_82 + ld hl,4 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint +.i_82 +.i_76 + ld hl,255 ;const + push hl + call _spi_cs + pop bc +.i_73 +.i_69 + ld hl,4 ;const + call l_gintsp ; + pop bc + pop bc + pop bc + ret + + + SECTION rodata_compiler +.i_1 + defm "Identified v2 card" + defb 10 + + defm "" + defb 0 + + defm "Identified v1 card" + defb 10 + + defm "" + defb 0 + + +; --- Start of Static Variables --- + + SECTION bss_compiler +._CardType defs 1 +._st_disk_writep_wc defs 2 + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + GLOBAL _spi_init + GLOBAL _spi_cs + GLOBAL _spi_out + GLOBAL _spi_in + GLOBAL _spi_skip + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Fri Mar 13 16:37:44 2020 + + + + MODULE pff_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION code_compiler + +; Function ld_word flags 0x00000200 __smallc +; unsigned int WORDld_word(const unsigned char BYTE*ptr) +; parameter 'const unsigned char BYTE*ptr' at 2 size(2) +._ld_word + push bc + ld hl,4 ;const + call l_gintsp ; + inc hl + ld l,(hl) + ld h,0 + pop bc + push hl + ld h,l + ld l,0 + push hl + ld hl,6 ;const + call l_gintsp ; + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop bc + ret + + + +; Function ld_dword flags 0x00000200 __smallc +; unsigned long DWORDld_dword(const unsigned char BYTE*ptr) +; parameter 'const unsigned char BYTE*ptr' at 2 size(2) +._ld_dword + push bc + push bc + ld hl,0 ;const + add hl,sp + push hl + ld hl,8 ;const + call l_gintsp ; + inc hl + inc hl + inc hl + ld l,(hl) + ld h,0 + ld de,0 + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + ld a,(hl) + inc hl + ld e,(hl) + inc hl + ld d,(hl) + ld h,a + ld l,0 + push de + push hl + ld hl,12 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + ld a,(hl) + inc hl + ld e,(hl) + inc hl + ld d,(hl) + ld h,a + ld l,0 + push de + push hl + ld hl,12 ;const + call l_gintsp ; + inc hl + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + ld a,(hl) + inc hl + ld e,(hl) + inc hl + ld d,(hl) + ld h,a + ld l,0 + push de + push hl + ld hl,12 ;const + call l_gintsp ; + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + call l_glong + pop bc + pop bc + ret + + + +; Function mem_set flags 0x00000200 __smallc +; void mem_set(void *dst, int val, int cnt) +; parameter 'int cnt' at 2 size(2) +; parameter 'int val' at 4 size(2) +; parameter 'void *dst' at 6 size(2) +._mem_set + ld hl,6 ;const + call l_gintsp ; + push hl +.i_2 + ld hl,4 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + inc hl + ld a,h + or l + jp z,i_3 + pop hl + inc hl + push hl + dec hl + push hl + ld hl,8 ;const + call l_gintsp ; + ld a,l + call l_sxt + ld a,l + call l_sxt + pop de + ld a,l + ld (de),a + jp i_2 +.i_3 + pop bc + ret + + + +; Function mem_cmp flags 0x00000200 __smallc +; int mem_cmp(const void *dst, const void *src, int cnt) +; parameter 'int cnt' at 2 size(2) +; parameter 'const void *src' at 4 size(2) +; parameter 'const void *dst' at 6 size(2) +._mem_cmp + ld hl,6 ;const + call l_g2intspsp ; + ld hl,0 ;const + push hl +.i_4 + ld hl,8 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + inc hl + ld a,h + or l + jp z,i_6 + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + call l_gchar + push hl + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + call l_gchar + pop de + ex de,hl + and a + sbc hl,de + pop bc + push hl + ld a,h + or l + jp nz,i_6 + inc hl + jr i_7 +.i_6 + ld hl,0 ;const +.i_7 + ld a,h + or l + jp nz,i_4 +.i_5 + pop hl + pop bc + pop bc + ret + + + +; Function get_fat flags 0x00000200 __smallc +; unsigned long DWORDget_fat(unsigned long clst) +; parameter 'unsigned long clst' at 2 size(4) +._get_fat + push bc + push bc + ld hl,(_FatFs) + push hl + ld hl,8 ;const + add hl,sp + call l_glong + ld a,l + sub 2 + ld a,h + sbc 0 + ld a,e + sbc 0 + ld a,d + sbc 0 + jp c,i_9 + ld hl,8 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + call l_glong + call l_long_uge + jp nc,i_8 +.i_9 + ld hl,1 ;const + ld de,0 + pop bc + pop bc + pop bc + ret + + +.i_8 + pop hl + push hl + ld l,(hl) + ld h,0 +.i_13 + ld a,l + cp +(3% 256) + jp nz,i_12 +.i_14 + ld hl,2 ;const + add hl,sp + push hl + dec hl + dec hl + call l_gint ; + ld bc,10 + add hl,bc + call l_glong2sp + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld l,+(7 % 256) + call l_long_asr_u + call l_long_add + push de + push hl + ld hl,14 ;const + add hl,sp + call l_glong + ld a,l + and +(127 % 256) + ld l,a + ld h,0 + add hl,hl + add hl,hl + push hl + ld hl,4 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp nz,i_12 +.i_15 + ld hl,2 ;const + add hl,sp + push hl + call _ld_dword + pop bc + ld a,d + and +(15 % 256) + ld d,a + pop bc + pop bc + pop bc + ret + + +.i_12 + ld hl,1 ;const + ld de,0 + pop bc + pop bc + pop bc + ret + + + +; Function clust2sect flags 0x00000200 __smallc +; unsigned long DWORDclust2sect(unsigned long clst) +; parameter 'unsigned long clst' at 2 size(4) +._clust2sect + ld hl,(_FatFs) + push hl + ld hl,4 ;const + add hl,sp + push hl + call l_glong + ld bc,65534 + add hl,bc + jr c,ASMPC+3 + dec de + pop bc + call l_plong + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + call l_glong + ld bc,65534 + add hl,bc + jr c,ASMPC+3 + dec de + call l_long_uge + jp nc,i_16 + ld hl,0 ;const + ld d,h + ld e,l + pop bc + ret + + +.i_16 + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + ld h,0 + ld de,0 + call l_long_mult + push de + push hl + ld hl,4 ;const + call l_gintsp ; + ld bc,18 + add hl,bc + call l_glong + call l_long_add + pop bc + ret + + + +; Function get_clust flags 0x00000200 __smallc +; unsigned long DWORDget_clust(unsigned char BYTE*dir) +; parameter 'unsigned char BYTE*dir' at 2 size(2) +._get_clust + ld hl,(_FatFs) + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + ld hl,0 ;const + add hl,sp + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,20 + add hl,bc + push hl + call _ld_word + pop bc + ld de,0 + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + call l_glong + ex de,hl + ld hl,0 ;const + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + call l_glong2sp + ld hl,14 ;const + call l_gintsp ; + ld bc,26 + add hl,bc + push hl + call _ld_word + pop bc + pop de + call l_or + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + call l_glong + pop bc + pop bc + pop bc + ret + + + +; Function dir_rewind flags 0x00000200 __smallc +; const int FRESULTdir_rewind(struct 0__anonstruct_5 DIR*dj) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 2 size(2) +._dir_rewind + push bc + push bc + ld hl,(_FatFs) + push hl + ld hl,8 ;const + add hl,sp + ld a,(hl) + inc hl + ld h,(hl) + ld l,a + xor a + ld (hl),a + inc hl + ld (hl),a + ld hl,2 ;const + add hl,sp + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + call l_glong + pop bc + call l_plong + ld hl,2 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_eq + jp c,i_18 + ld hl,2 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + call l_glong + call l_long_uge + jp nc,i_17 +.i_18 + ld hl,1 ;const + pop bc + pop bc + pop bc + ret + + +.i_17 + ld hl,2 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_20 + ld hl,2 ;const + add hl,sp + push hl + dec hl + dec hl + call l_gint ; + ld bc,14 + add hl,bc + call l_glong + pop bc + call l_plong +.i_20 + ld hl,8 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + push hl + ld hl,4 ;const + add hl,sp + call l_glong + pop bc + call l_plong + ld hl,8 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + push hl + jp i_21 + ld hl,4 ;const + add hl,sp + call l_glong + ld a,h + or l + or d + or e + jp nz,i_21 + ld hl,0 ;const + jr i_22 +.i_21 + ld hl,1 ;const +.i_22 + jp nc,i_23 + ld hl,4 ;const + call l_glongsp ; + call _clust2sect + pop bc + pop bc + jp i_24 +.i_23 + pop bc + pop hl + push hl + push bc + ld bc,14 + add hl,bc + call l_glong +.i_24 + pop bc + call l_plong + ld hl,8 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + push hl + ld hl,4 ;const + call l_glongsp ; + call _clust2sect + pop bc + pop bc + pop bc + call l_plong + ld hl,0 ;const + pop bc + pop bc + pop bc + ret + + + +; Function dir_next flags 0x00000200 __smallc +; const int FRESULTdir_next(struct 0__anonstruct_5 DIR*dj) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 2 size(2) +._dir_next + push bc + push bc + push bc + ld hl,(_FatFs) + push hl + ld hl,10 ;const + call l_gintsp ; + call l_gint ; + inc hl + pop de + pop bc + push hl + push de + call l_lneg + jp c,i_26 + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong + call l_long_lneg + jp nc,i_25 +.i_26 + ld hl,3 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_25 + pop bc + pop hl + push hl + push bc + ld a,l + and +(15 % 256) + jp nz,i_28 + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + push hl + call l_glong + call l_inclong + pop bc + call l_plong + ld hl,10 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + call l_glong + ld a,d + or e + or h + or l + jp nz,i_29 + ld hl,2 ;const + call l_gintspsp ; + pop bc + pop hl + push hl + push bc + ld bc,4 + add hl,bc + call l_gint ; + pop de + call l_uge + jp nc,i_30 + ld hl,3 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_30 + jp i_31 +.i_29 + pop bc + pop hl + push hl + push bc + ld de,4 + call l_asr_u_hl_by_e + pop de + push de + push hl + ex de,hl + inc hl + inc hl + ld l,(hl) + ld h,0 + dec hl + pop de + call l_and + ld a,h + or l + jp nz,i_32 + ld hl,4 ;const + add hl,sp + push hl + ld hl,12 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + call l_glong + push de + push hl + call _get_fat + pop bc + pop bc + pop bc + call l_plong + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_ule + jp nc,i_33 + ld hl,1 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_33 + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + call l_glong + call l_long_uge + jp nc,i_34 + ld hl,3 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_34 + ld hl,10 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + push hl + ld hl,6 ;const + add hl,sp + call l_glong + pop bc + call l_plong + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + push hl + ld hl,6 ;const + call l_glongsp ; + call _clust2sect + pop bc + pop bc + pop bc + call l_plong +.i_32 +.i_31 +.i_28 + ld hl,10 ;const + call l_gintspsp ; + ld hl,4 ;const + call l_gintsp ; + call l_pint_pop + ld hl,0 ;const + pop bc + pop bc + pop bc + pop bc + ret + + + +; Function dir_find flags 0x00000200 __smallc +; const int FRESULTdir_find(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir) +; parameter 'unsigned char BYTE*dir' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._dir_find + push bc + dec sp + ld hl,1 ;const + add hl,sp + push hl + ld hl,9 ;const + call l_gintsp ; + push hl + call _dir_rewind + pop bc + call l_pint_pop + ld hl,1 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_35 + ld hl,1 ;const + call l_gintsp ; + inc sp + pop bc + ret + + +.i_35 +.i_38 + ld hl,1 ;const + add hl,sp + push hl + ld hl,7 ;const + call l_gintspsp ; + ld hl,11 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong2sp + ld hl,15 ;const + call l_gintsp ; + ld a,(hl) + and +(15 % 256) + ld l,a + ld h,0 + add hl,hl + add hl,hl + add hl,hl + add hl,hl + add hl,hl + push hl + ld hl,32 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_39 + ld hl,1 ;const + jp i_40 +.i_39 + ld hl,0 ;const +.i_40 + call l_pint_pop + ld hl,1 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_37 +.i_41 + ld hl,0 ;const + add hl,sp + push hl + ld hl,7 ;const + call l_gintsp ; + ld a,(hl) + pop de + ld (de),a + pop hl + push hl + ld h,0 + ld a,l + and a + jp nz,i_42 + ld hl,1 ;const + add hl,sp + ld de,3 ;const + ex de,hl + call l_pint + jp i_37 +.i_42 + ld hl,5 ;const + call l_gintsp ; + ld bc,11 + add hl,bc + ld a,(hl) + and +(8 % 256) + jp nz,i_44 + ld hl,5 ;const + call l_gintspsp ; + ld hl,9 ;const + call l_gintsp ; + inc hl + inc hl + ld e,(hl) + inc hl + ld d,(hl) + push de + ld hl,11 ;const + push hl + call _mem_cmp + pop bc + pop bc + pop bc + call l_lneg + jr c,i_45_i_44 +.i_44 + jp i_43 +.i_45_i_44 + jp i_37 +.i_43 + ld hl,1 ;const + add hl,sp + push hl + ld hl,9 ;const + call l_gintsp ; + push hl + call _dir_next + pop bc + call l_pint_pop +.i_36 + ld hl,1 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_38 +.i_37 + ld hl,1 ;const + call l_gintsp ; + inc sp + pop bc + ret + + + +; Function dir_read flags 0x00000200 __smallc +; const int FRESULTdir_read(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir) +; parameter 'unsigned char BYTE*dir' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._dir_read + ld hl,3 ;const + push hl + push bc +.i_46 + ld hl,8 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong + ld a,h + or l + or d + or e + jp z,i_47 + ld hl,i_1+0 + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong2sp + ld hl,14 ;const + call l_gintsp ; + call l_gint ; + push hl + ld a,4 + call printf + pop bc + pop bc + pop bc + pop bc + ld hl,6 ;const + call l_gintspsp ; + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong2sp + ld hl,14 ;const + call l_gintsp ; + ld a,(hl) + and +(15 % 256) + ld l,a + ld h,0 + add hl,hl + add hl,hl + add hl,hl + add hl,hl + add hl,hl + push hl + ld hl,32 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_48 + ld hl,1 ;const + jp i_49 +.i_48 + ld hl,0 ;const +.i_49 + pop de + pop bc + push hl + push de + ld a,h + or l + jp nz,i_47 +.i_50 + ld hl,0 ;const + add hl,sp + push hl + ld hl,8 ;const + call l_gintsp ; + ld a,(hl) + pop de + ld (de),a + pop hl + push hl + ld h,0 + ld a,l + and a + jp nz,i_51 + ld hl,3 ;const + pop de + pop bc + push hl + push de + jp i_47 +.i_51 + ld hl,1 ;const + add hl,sp + push hl + ld hl,8 ;const + call l_gintsp ; + ld bc,11 + add hl,bc + ld a,(hl) + and +(63 % 256) + ld l,a + ld h,0 + pop de + ld a,l + ld (de),a + ld hl,0 ;const + add hl,sp + ld a,(hl) + cp 229 + jp z,i_53 + pop hl + push hl + ld h,0 + ld de,46 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jp nc,i_53 + pop hl + push hl + ld l,h + ld h,0 + ld a,+(8 % 256) + and l + ld l,a + call l_lneg + jr c,i_54_i_53 +.i_53 + jp i_52 +.i_54_i_53 + jp i_47 +.i_52 + ld hl,8 ;const + call l_gintsp ; + push hl + call _dir_next + pop bc + pop de + pop bc + push hl + push de + ld a,h + or l + jr nz,i_47 +.i_55 + jp i_46 +.i_47 + pop bc + pop hl + push hl + push bc + ld a,h + or l + jp z,i_56 + ld hl,8 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + push hl + ld hl,0 ;const + ld d,h + ld e,l + pop bc + call l_plong +.i_56 + pop bc + pop hl + ret + + + +; Function create_name flags 0x00000200 __smallc +; const int FRESULTcreate_name(struct 0__anonstruct_5 DIR*dj, const char **path) +; parameter 'const char **path' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._create_name + push bc + push bc + push bc + push bc + dec sp + ld hl,13 ;const + call l_gintsp ; + inc hl + inc hl + call l_gint ; + pop de + pop bc + push hl + push de + ld hl,2 ;const + call l_gintspsp ; + ld hl,32 ;const + push hl + ld hl,11 ;const + push hl + call _mem_set + pop bc + pop bc + pop bc + ld hl,5 ;const + add hl,sp + push hl + ld hl,6 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld a,(hl) + pop de + ld (de),a + ld hl,6 ;const + add hl,sp + ld (hl),+(8 % 256 % 256) + ld hl,11 ;const + call l_gintsp ; + call l_gint ; + pop bc + push hl +.i_57 +.i_59 + ld hl,8 ;const + add hl,sp + push hl + ld hl,2 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + pop de + ld a,(hl) + ld (de),a + ld hl,8 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,32 + and a + sbc hl,de + ccf + jp c,i_61 + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,47 + and a + sbc hl,de + jr nz,i_60 +.i_61 + jp i_58 +.i_60 + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,46 + and a + sbc hl,de + scf + jr z,ASMPC+3 + ccf + jp c,i_64 + ld hl,4 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,6 ;const + add hl,sp + ld l,(hl) + ld h,0 + call l_uge + jp nc,i_63 +.i_64 + ld hl,6 ;const + add hl,sp + ld a,(hl) + cp 8 + jr z,ASMPC+3 + scf + jp c,i_67 + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,46 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jr nc,i_66 +.i_67 + jp i_58 +.i_66 + ld hl,4 ;const + add hl,sp + ld (hl),+(8 % 256 % 256) + ld hl,6 ;const + add hl,sp + ld (hl),+(11 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_57 +.i_63 + jp i_70 + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + dec hl + pop de + ex de,hl + and a + sbc hl,de + jr c,i_71_i_70 +.i_70 + jp i_69 +.i_71_i_70 + ld hl,7 ;const + add hl,sp + push hl + ld hl,2 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + pop de + ld a,(hl) + ld (de),a + ld hl,2 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + ex de,hl + ld hl,8 ;const + add hl,sp + ld a,(hl) + ld (de),a + ld hl,2 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + push hl + ld hl,9 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a + ld l,a + ld h,0 + jp i_72 +.i_69 + jp i_74 + ld hl,8 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,97 + call l_uge + jp nc,i_75 + ld hl,8 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,122 + and a + sbc hl,de + ccf + jr c,i_76_i_75 +.i_75 + jp i_74 +.i_76_i_75 + jr i_77_i_74 +.i_74 + jp i_73 +.i_77_i_74 + ld hl,8 ;const + add hl,sp + ld a,(hl) + add a,+(-32 % 256) + ld (hl),a +.i_73 + ld hl,2 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + push hl + ld hl,10 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a + ld l,a + ld h,0 +.i_72 + jp i_57 +.i_58 + ld hl,11 ;const + call l_gintspsp ; + ld hl,2 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,7 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + call l_pint_pop + pop bc + pop hl + push hl + push bc + ld bc,11 + add hl,bc + push hl + ld hl,10 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,32 + and a + sbc hl,de + ccf + jp nc,i_78 + ld hl,1 ;const + jp i_79 +.i_78 + ld hl,0 ;const +.i_79 + pop de + ld a,l + ld (de),a + ld hl,0 ;const + inc sp + pop bc + pop bc + pop bc + pop bc + ret + + + +; Function get_fileinfo flags 0x00000200 __smallc +; void get_fileinfo(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir, struct 0__anonstruct_6 FILINFO*fno) +; parameter 'struct 0__anonstruct_6 FILINFO*fno' at 2 size(2) +; parameter 'unsigned char BYTE*dir' at 4 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 6 size(2) +._get_fileinfo + push bc + push bc + ld hl,6 ;const + call l_gintsp ; + ld bc,9 + add hl,bc + pop bc + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong + ld a,h + or l + or d + or e + jp z,i_80 + ld hl,3 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_83 +.i_81 + ld hl,3 ;const + add hl,sp + inc (hl) +.i_83 + ld hl,3 ;const + add hl,sp + ld a,(hl) + sub 8 + jp nc,i_82 + ld hl,2 ;const + add hl,sp + push hl + ld hl,10 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,5 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + ld a,(hl) + pop de + ld (de),a + ld hl,2 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + jp z,i_82 +.i_84 + ld hl,2 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 5 + jp nz,i_85 + ld hl,2 ;const + add hl,sp + ld (hl),+(229 % 256 % 256) +.i_85 + pop hl + inc hl + push hl + dec hl + push hl + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld a,l + rla + sbc a + ld h,a + pop de + ld a,l + ld (de),a + jp i_81 +.i_82 + ld hl,8 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jp nc,i_86 + pop hl + ld (hl),+(46 % 256) + inc hl + push hl + ld hl,3 ;const + add hl,sp + ld (hl),+(8 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_89 +.i_87 + ld hl,3 ;const + add hl,sp + inc (hl) +.i_89 + ld hl,3 ;const + add hl,sp + ld a,(hl) + sub 11 + jp nc,i_88 + ld hl,2 ;const + add hl,sp + push hl + ld hl,10 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,5 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + ld a,(hl) + pop de + ld (de),a + ld hl,2 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + jp z,i_88 +.i_90 + pop hl + inc hl + push hl + dec hl + push hl + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld a,l + rla + sbc a + ld h,a + pop de + ld a,l + ld (de),a + jp i_87 +.i_88 +.i_86 + ld hl,6 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,11 + add hl,bc + ld a,(hl) + pop de + ld (de),a + ld hl,6 ;const + call l_gintspsp ; + ld hl,10 ;const + call l_gintsp ; + ld bc,28 + add hl,bc + push hl + call _ld_dword + pop bc + pop bc + call l_plong + ld hl,6 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,24 + add hl,bc + push hl + call _ld_word + pop bc + call l_pint_pop + ld hl,6 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,22 + add hl,bc + push hl + call _ld_word + pop bc + call l_pint_pop +.i_80 + pop de + push de + ld hl,0 ;const + ld a,l + ld (de),a + pop bc + pop bc + ret + + + +; Function follow_path flags 0x00000200 __smallc +; const int FRESULTfollow_path(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir, const char *path) +; parameter 'const char *path' at 2 size(2) +; parameter 'unsigned char BYTE*dir' at 4 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 6 size(2) +._follow_path + push bc +.i_91 + ld hl,4 ;const + call l_gintsp ; + ld a,(hl) + cp 32 + jp nz,i_92 + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + jp i_91 +.i_92 + ld hl,4 ;const + call l_gintsp ; + ld a,(hl) + cp 47 + jp nz,i_93 + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) +.i_93 + ld hl,8 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + xor a + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + ld hl,4 ;const + call l_gintsp ; + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + jp nc,i_94 + ld hl,8 ;const + call l_gintsp ; + push hl + call _dir_rewind + pop bc + pop bc + push hl + ld hl,6 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,0 % 256 ;const + ld a,l + ld (de),a + jp i_95 +.i_94 +.i_96 +.i_98 + ld hl,8 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + push hl + call _create_name + pop bc + pop bc + pop bc + push hl + ld a,h + or l + jp nz,i_97 +.i_99 + ld hl,8 ;const + call l_gintspsp ; + ld hl,8 ;const + call l_gintsp ; + push hl + call _dir_find + pop bc + pop bc + pop bc + push hl + ld a,h + or l + jp nz,i_97 +.i_100 + ld hl,8 ;const + call l_gintsp ; + inc hl + inc hl + call l_gint ; + ld bc,11 + add hl,bc + ld l,(hl) + ld a,l + and a + jp nz,i_97 +.i_101 + ld hl,6 ;const + call l_gintsp ; + ld bc,11 + add hl,bc + ld a,(hl) + and +(16 % 256) + jp nz,i_102 + ld hl,3 ;const + pop bc + push hl + jp i_97 +.i_102 + ld hl,8 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + push hl + ld hl,8 ;const + call l_gintsp ; + push hl + call _get_clust + pop bc + pop bc + call l_plong + jp i_96 +.i_97 +.i_95 + pop hl + ret + + + +; Function check_fs flags 0x00000200 __smallc +; unsigned char BYTEcheck_fs(unsigned char BYTE*buf, unsigned long sect) +; parameter 'unsigned long sect' at 2 size(4) +; parameter 'unsigned char BYTE*buf' at 6 size(2) +._check_fs + ld hl,6 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,510 ;const + push hl + ld hl,2 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_103 + ld hl,3 % 256 ;const + ret + + +.i_103 + ld hl,6 ;const + call l_gintsp ; + push hl + call _ld_word + pop bc + ld de,43605 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jp nc,i_104 + ld hl,2 % 256 ;const + ret + + +.i_104 + ld hl,6 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,82 ;const + push hl + ld hl,2 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + call l_lneg + jp nc,i_106 + ld hl,6 ;const + call l_gintsp ; + push hl + call _ld_word + pop bc + ld de,16710 + and a + sbc hl,de + jr z,i_107_i_106 +.i_106 + jp i_105 +.i_107_i_106 + ld hl,0 % 256 ;const + ret + + +.i_105 + ld hl,1 % 256 ;const + ret + + + +; Function pf_mount flags 0x00000200 __smallc +; const int FRESULTpf_mount(struct 0__anonstruct_4 FATFS*fs) +; parameter 'struct 0__anonstruct_4 FATFS*fs' at 2 size(2) +._pf_mount + ld hl,65483 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ld (_FatFs),hl + call _disk_initialize + ld a,l + and +(1 % 256) + jp z,i_108 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,2 ;const + ret + + +.i_108 + ld hl,12 ;const + add hl,sp + xor a + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + ld hl,52 ;const + add hl,sp + push hl + ld hl,18 ;const + add hl,sp + push hl + ld hl,16 ;const + call l_glongsp ; + call _check_fs + pop bc + pop bc + pop bc + pop de + ld a,l + ld (de),a + ld hl,52 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 1 + jp nz,i_109 + ld hl,16 ;const + add hl,sp + push hl + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld hl,446 ;const + push hl + ld hl,16 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_110 + ld hl,52 ;const + add hl,sp + ld (hl),+(3 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_111 +.i_110 + ld hl,20 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_112 + ld hl,12 ;const + add hl,sp + push hl + ld hl,26 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong + ld hl,52 ;const + add hl,sp + push hl + ld hl,18 ;const + add hl,sp + push hl + ld hl,16 ;const + call l_glongsp ; + call _check_fs + pop bc + pop bc + pop bc + pop de + ld a,l + ld (de),a +.i_112 +.i_111 +.i_109 + ld hl,52 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 3 + jp nz,i_113 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_113 + ld hl,52 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_114 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,6 ;const + ret + + +.i_114 + ld hl,16 ;const + add hl,sp + push hl + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld hl,13 ;const + push hl + ld hl,36 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_115 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_115 + ld hl,8 ;const + add hl,sp + push hl + ld hl,27 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + pop bc + call l_plong + ld hl,8 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_116 + ld hl,8 ;const + add hl,sp + push hl + ld hl,41 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong +.i_116 + ld hl,8 ;const + add hl,sp + push hl + call l_glong2sp + ld hl,25 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + call l_long_mult + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + ld bc,10 + add hl,bc + push hl + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld hl,23 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + inc hl + inc hl + ex de,hl + ld hl,16 ;const + add hl,sp + ld a,(hl) + ld (de),a + ld hl,55 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + push hl + ld hl,22 ;const + add hl,sp + push hl + call _ld_word + pop bc + call l_pint_pop + ld hl,4 ;const + add hl,sp + push hl + ld hl,24 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + pop bc + call l_plong + ld hl,4 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_117 + ld hl,4 ;const + add hl,sp + push hl + ld hl,37 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong +.i_117 + ld hl,0 ;const + add hl,sp + push hl + ld hl,6 ;const + add hl,sp + call l_glong2sp + ld hl,23 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + call l_long_sub + push de + push hl + ld hl,14 ;const + add hl,sp + call l_glong + call l_long_sub + push de + push hl + ld hl,61 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + call l_gint ; + ld de,4 + call l_asr_u_hl_by_e + ld de,0 + call l_long_sub + push de + push hl + ld hl,61 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + ld h,0 + ld de,0 + call l_long_div_u + ld bc,2 + add hl,bc + jr nc,ASMPC+3 + inc de + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + push hl + ld hl,2 ;const + add hl,sp + call l_glong + pop bc + call l_plong + ld hl,52 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld hl,0 ;const + add hl,sp + call l_glong2sp + ld hl,65527 ;const + ld de,0 + call l_long_uge + jp nc,i_118 + ld hl,52 ;const + add hl,sp + ld (hl),+(3 % 256 % 256) +.i_118 + ld hl,52 ;const + add hl,sp + ld a,(hl) + and a + jp nz,i_119 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,6 ;const + ret + + +.i_119 + ld hl,55 ;const + call l_gintspsp ; + ld hl,54 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a + ld hl,55 ;const + call l_gintsp ; + ld bc,14 + add hl,bc + push hl + ld hl,49 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + ld bc,18 + add hl,bc + push hl + ld hl,57 ;const + call l_gintsp ; + ld bc,10 + add hl,bc + call l_glong2sp + ld hl,14 ;const + add hl,sp + call l_glong + call l_long_add + push de + push hl + ld hl,61 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + call l_gint ; + ld de,4 + call l_asr_u_hl_by_e + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,55 ;const + call l_gintsp ; + ld (_FatFs),hl + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; Function pf_open flags 0x00000200 __smallc +; const int FRESULTpf_open(const char *path) +; parameter 'const char *path' at 2 size(2) +._pf_open + ld hl,65474 ;const + add hl,sp + ld sp,hl + ld hl,(_FatFs) + push hl + call l_lneg + jp nc,i_120 + ld hl,64 ;const + add hl,sp + ld sp,hl + ld hl,5 ;const + ret + + +.i_120 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,48 ;const + add hl,sp + push hl + ld hl,36 ;const + add hl,sp + call l_pint_pop + ld hl,62 ;const + add hl,sp + push hl + ld hl,48 ;const + add hl,sp + push hl + ld hl,6 ;const + add hl,sp + push hl + ld hl,72 ;const + call l_gintsp ; + push hl + call _follow_path + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,62 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_121 + ld hl,62 ;const + call l_gintsp ; + exx + ld hl,64 ;const + add hl,sp + ld sp,hl + exx + ret + + +.i_121 + ld hl,2 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_123 + ld hl,13 ;const + add hl,sp + ld a,+(16 % 256) + and (hl) + jp z,i_122 +.i_123 + ld hl,64 ;const + add hl,sp + ld sp,hl + ld hl,3 ;const + ret + + +.i_122 + pop hl + push hl + ld bc,30 + add hl,bc + push hl + ld hl,4 ;const + add hl,sp + push hl + call _get_clust + pop bc + pop bc + call l_plong + pop hl + push hl + ld bc,26 + add hl,bc + push hl + ld hl,32 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong + pop hl + push hl + ld bc,22 + add hl,bc + xor a + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + pop hl + push hl + inc hl + ld (hl),+(1 % 256 % 256) + ld hl,64 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; Function pf_read flags 0x00000200 __smallc +; const int FRESULTpf_read(void *buff, unsigned int btr, unsigned int UINT*br) +; parameter 'unsigned int UINT*br' at 2 size(2) +; parameter 'unsigned int btr' at 4 size(2) +; parameter 'void *buff' at 6 size(2) +._pf_read + ld hl,65519 ;const + add hl,sp + ld sp,hl + ld hl,23 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + push de + ld hl,(_FatFs) + push hl + ld hl,23 ;const + add hl,sp + ld a,(hl) + inc hl + ld h,(hl) + ld l,a + xor a + ld (hl),a + inc hl + ld (hl),a + pop hl + push hl + call l_lneg + jp nc,i_125 + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,5 ;const + ret + + +.i_125 + pop hl + push hl + inc hl + ld a,(hl) + and +(1 % 256) + jp nz,i_126 + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,4 ;const + ret + + +.i_126 + ld hl,7 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,26 + add hl,bc + call l_glong2sp + ld hl,6 ;const + call l_gintsp ; + ld bc,22 + add hl,bc + call l_glong + call l_long_sub + pop bc + call l_plong + ld hl,25 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + call l_glong + exx + pop hl + ld de,0 + push de + push hl + exx + call l_long_ugt + jp nc,i_127 + ld hl,25 ;const + add hl,sp + push hl + ld hl,9 ;const + add hl,sp + call l_glong + call l_pint_pop +.i_127 +.i_128 + ld hl,25 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_129 + pop hl + push hl + ld bc,22 + add hl,bc + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_div_u + exx + ld a,d + or e + or h + or l + jp nz,i_130 + ld hl,4 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,22 + add hl,bc + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_div_u + push de + push hl + ld hl,6 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + ld h,0 + dec hl + ld de,0 + call l_long_and + pop de + ld a,l + ld (de),a + ld hl,4 ;const + add hl,sp + ld a,(hl) + and a + jp nz,i_131 + pop hl + push hl + ld bc,22 + add hl,bc + call l_glong + ld a,d + or e + or h + or l + jp nz,i_132 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,30 + add hl,bc + call l_glong + pop bc + call l_plong + jp i_133 +.i_132 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _get_fat + pop bc + pop bc + pop bc + call l_plong +.i_133 + ld hl,15 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_ule + jp nc,i_134 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_134 + pop hl + push hl + ld bc,34 + add hl,bc + push hl + ld hl,17 ;const + add hl,sp + call l_glong + pop bc + call l_plong +.i_131 + ld hl,11 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _clust2sect + pop bc + pop bc + pop bc + call l_plong + ld hl,11 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_135 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_135 + pop hl + push hl + ld bc,38 + add hl,bc + push hl + ld hl,13 ;const + add hl,sp + call l_glong2sp + ld hl,10 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + call l_long_add + pop bc + call l_plong +.i_130 + ld hl,5 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ld hl,512 + and a + sbc hl,de + call l_pint_pop + ld hl,5 ;const + call l_gintspsp ; + ld hl,27 ;const + call l_gintsp ; + pop de + and a + sbc hl,de + jp nc,i_136 + ld hl,5 ;const + add hl,sp + ex de,hl + ld hl,25 ;const + call l_gintsp ; + call l_pint +.i_136 + ld hl,19 ;const + add hl,sp + push hl + ld hl,4 ;const + call l_gintspsp ; + ld hl,4 ;const + call l_gintsp ; + ld bc,38 + add hl,bc + call l_glong2sp + ld hl,8 ;const + call l_gintsp ; + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ex de,hl + push hl + ld hl,15 ;const + call l_gintsp ; + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,19 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_137 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_137 + pop hl + push hl + ld bc,22 + add hl,bc + push hl + call l_glong2sp + ld hl,11 ;const + call l_gintsp ; + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,25 ;const + add hl,sp + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,7 ;const + add hl,sp + call l_gint + ex de,hl + and a + sbc hl,de + call l_pint_pop + ld hl,23 ;const + call l_gintsp ; + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,7 ;const + add hl,sp + call l_gint + add hl,de + call l_pint_pop + pop bc + pop hl + push hl + push bc + ld a,h + or l + jp z,i_138 + ld hl,2 ;const + call l_gintspsp ; + ld hl,7 ;const + call l_gintsp ; + pop de + add hl,de + pop de + pop bc + push hl + push de +.i_138 + jp i_128 +.i_129 + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; Function pf_write flags 0x00000200 __smallc +; const int FRESULTpf_write(const void *buff, unsigned int btw, unsigned int UINT*bw) +; parameter 'unsigned int UINT*bw' at 2 size(2) +; parameter 'unsigned int btw' at 4 size(2) +; parameter 'const void *buff' at 6 size(2) +._pf_write + ld hl,65524 ;const + add hl,sp + ld sp,hl + ld hl,18 ;const + call l_gintsp ; + push hl + push bc + dec sp + ld hl,(_FatFs) + push hl + ld hl,21 ;const + add hl,sp + ld a,(hl) + inc hl + ld h,(hl) + ld l,a + xor a + ld (hl),a + inc hl + ld (hl),a + pop hl + push hl + call l_lneg + jp nc,i_139 + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,5 ;const + ret + + +.i_139 + pop hl + push hl + inc hl + ld a,(hl) + and +(1 % 256) + jp nz,i_140 + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,4 ;const + ret + + +.i_140 + ld hl,23 ;const + call l_gintsp ; + call l_lneg + jp nc,i_141 + pop hl + push hl + inc hl + ld a,+(64 % 256) + and (hl) + jp z,i_143 + ld hl,0 ;const + push hl + ld d,h + ld e,l + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jr nz,i_144_i_143 +.i_143 + jp i_142 +.i_144_i_143 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_142 + pop hl + push hl + inc hl + push hl + ld a,(hl) + and 191 + ld l,a + ld h,0 + pop de + ld a,l + ld (de),a + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + +.i_141 + pop hl + push hl + inc hl + ld a,(hl) + and +(64 % 256) + jp nz,i_146 + pop hl + push hl + ld bc,22 + add hl,bc + push hl + call l_glong2sp + ld hl,65024 ;const + ld de,65535 + call l_long_and + pop bc + call l_plong +.i_146 +.i_145 + ld hl,7 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,26 + add hl,bc + call l_glong2sp + ld hl,6 ;const + call l_gintsp ; + ld bc,22 + add hl,bc + call l_glong + call l_long_sub + pop bc + call l_plong + ld hl,23 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + call l_glong + exx + pop hl + ld de,0 + push de + push hl + exx + call l_long_ugt + jp nc,i_147 + ld hl,23 ;const + add hl,sp + push hl + ld hl,9 ;const + add hl,sp + call l_glong + call l_pint_pop +.i_147 +.i_148 + ld hl,23 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_149 + pop hl + push hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ex de,hl + ld a,h + or l + jp nz,i_150 + ld hl,4 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,22 + add hl,bc + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_div_u + push de + push hl + ld hl,6 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + ld h,0 + dec hl + ld de,0 + call l_long_and + pop de + ld a,l + ld (de),a + ld hl,4 ;const + add hl,sp + ld a,(hl) + and a + jp nz,i_151 + pop hl + push hl + ld bc,22 + add hl,bc + call l_glong + ld a,d + or e + or h + or l + jp nz,i_152 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,30 + add hl,bc + call l_glong + pop bc + call l_plong + jp i_153 +.i_152 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _get_fat + pop bc + pop bc + pop bc + call l_plong +.i_153 + ld hl,15 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_ule + jp nc,i_154 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_154 + pop hl + push hl + ld bc,34 + add hl,bc + push hl + ld hl,17 ;const + add hl,sp + call l_glong + pop bc + call l_plong +.i_151 + ld hl,11 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _clust2sect + pop bc + pop bc + pop bc + call l_plong + ld hl,11 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_155 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_155 + pop hl + push hl + ld bc,38 + add hl,bc + push hl + ld hl,13 ;const + add hl,sp + call l_glong2sp + ld hl,10 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + call l_long_add + pop bc + call l_plong + pop hl + push hl + ld bc,0 + push bc + ld bc,38 + add hl,bc + call l_glong + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_156 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_156 + pop hl + push hl + inc hl + ld a,(hl) + or 64 + ld (hl),a +.i_150 + pop hl + push hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ld hl,512 + and a + sbc hl,de + pop de + pop bc + push hl + push de + ld hl,2 ;const + call l_gintspsp ; + ld hl,25 ;const + call l_gintsp ; + pop de + and a + sbc hl,de + jp nc,i_157 + ld hl,23 ;const + call l_gintsp ; + pop de + pop bc + push hl + push de +.i_157 + ld hl,5 ;const + call l_gintspsp ; + ld hl,4 ;const + call l_gintsp ; + ld de,0 + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_158 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_158 + pop hl + push hl + ld bc,22 + add hl,bc + push hl + call l_glong2sp + ld hl,8 ;const + call l_gintsp ; + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,5 ;const + add hl,sp + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,4 ;const + add hl,sp + call l_gint + add hl,de + call l_pint_pop + ld hl,23 ;const + add hl,sp + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,4 ;const + add hl,sp + call l_gint + ex de,hl + and a + sbc hl,de + call l_pint_pop + ld hl,21 ;const + call l_gintsp ; + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,4 ;const + add hl,sp + call l_gint + add hl,de + call l_pint_pop + pop hl + push hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ex de,hl + ld a,h + or l + jp nz,i_159 + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_160 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_160 + pop hl + push hl + inc hl + push hl + ld a,(hl) + and 191 + ld l,a + ld h,0 + pop de + ld a,l + ld (de),a +.i_159 + jp i_148 +.i_149 + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; Function pf_opendir flags 0x00000200 __smallc +; const int FRESULTpf_opendir(struct 0__anonstruct_5 DIR*dj, const char *path) +; parameter 'const char *path' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._pf_opendir + ld hl,65490 ;const + add hl,sp + ld sp,hl + ld hl,(_FatFs) + push hl + call l_lneg + jp nc,i_161 + ld hl,46 ;const + add hl,sp + ld de,5 ;const + ex de,hl + call l_pint + jp i_162 +.i_161 + ld hl,i_1+33 + push hl + ld a,1 + call printf + pop bc + ld hl,52 ;const + call l_gintsp ; + inc hl + inc hl + push hl + ld hl,36 ;const + add hl,sp + call l_pint_pop + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + push hl + ld hl,56 ;const + call l_gintsp ; + push hl + call _follow_path + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,i_1+42 + push hl + ld hl,48 ;const + call l_gintsp ; + push hl + ld a,2 + call printf + pop bc + pop bc + ld hl,46 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_163 + ld hl,2 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_164 + ld hl,i_1+55 + push hl + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld a,2 + call printf + pop bc + pop bc + ld hl,13 ;const + add hl,sp + ld a,+(16 % 256) + and (hl) + jp z,i_165 + ld hl,52 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + push hl + ld hl,4 ;const + add hl,sp + push hl + call _get_clust + pop bc + pop bc + call l_plong + jp i_166 +.i_165 + ld hl,46 ;const + add hl,sp + ld de,3 ;const + ex de,hl + call l_pint +.i_166 +.i_164 + ld hl,46 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_167 + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintsp ; + push hl + call _dir_rewind + pop bc + call l_pint_pop +.i_167 +.i_163 +.i_162 + ld hl,46 ;const + call l_gintsp ; + exx + ld hl,48 ;const + add hl,sp + ld sp,hl + exx + ret + + + +; Function pf_readdir flags 0x00000200 __smallc +; const int FRESULTpf_readdir(struct 0__anonstruct_5 DIR*dj, struct 0__anonstruct_6 FILINFO*fno) +; parameter 'struct 0__anonstruct_6 FILINFO*fno' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._pf_readdir + ld hl,65490 ;const + add hl,sp + ld sp,hl + ld hl,(_FatFs) + push hl + call l_lneg + jp nc,i_168 + ld hl,46 ;const + add hl,sp + ld de,5 ;const + ex de,hl + call l_pint + jp i_169 +.i_168 + ld hl,52 ;const + call l_gintsp ; + inc hl + inc hl + push hl + ld hl,36 ;const + add hl,sp + call l_pint_pop + ld hl,50 ;const + call l_gintsp ; + call l_lneg + jp nc,i_170 + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintsp ; + push hl + call _dir_rewind + pop bc + call l_pint_pop + jp i_171 +.i_170 + ld hl,i_1+70 + push hl + ld a,1 + call printf + pop bc + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + push hl + call _dir_read + pop bc + pop bc + call l_pint_pop + ld hl,46 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_172 + ld hl,52 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintsp ; + push hl + call _get_fileinfo + pop bc + pop bc + pop bc + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintsp ; + push hl + call _dir_next + pop bc + call l_pint_pop + ld hl,46 ;const + call l_gintsp ; + ld de,3 + and a + sbc hl,de + jp nz,i_173 + ld hl,46 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint +.i_173 +.i_172 +.i_171 +.i_169 + ld hl,46 ;const + call l_gintsp ; + exx + ld hl,48 ;const + add hl,sp + ld sp,hl + exx + ret + + + SECTION rodata_compiler +.i_1 + defm "dir_read: sector:%ld, index:%l" + defm "d" + defb 10 + + defm "" + defb 0 + + defm "OPENDIR" + defb 10 + + defm "" + defb 0 + + defm "RESDIR:%02x" + defb 10 + + defm "" + defb 0 + + defm "IS A DIR:%02x" + defb 10 + + defm "" + defb 0 + + defm "Readdir" + defb 10 + + defm "" + defb 0 + + +; --- Start of Static Variables --- + + SECTION bss_compiler +._FatFs defs 2 + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- diff --git a/software/src/PetitFS/pff_obj/new.err b/software/src/PetitFS/pff_obj/new.err new file mode 100644 index 0000000..958118e --- /dev/null +++ b/software/src/PetitFS/pff_obj/new.err @@ -0,0 +1,592 @@ +Error at file 'new.asm' line 13: cannot read file 'z80_crt0.hdr' +Error at file 'new.asm' line 858: cannot read file 'z80_crt0.hdr' +Error at file 'new.asm' line 951: symbol 'i_5' already defined +Error at file 'new.asm' line 959: symbol 'i_3' already defined +Error at file 'new.asm' line 973: symbol 'i_4' already defined +Error at file 'new.asm' line 1030: symbol 'i_7' already defined +Error at file 'new.asm' line 1031: symbol 'i_6' already defined +Error at file 'new.asm' line 1089: symbol 'i_8' already defined +Error at file 'new.asm' line 1100: symbol 'i_9' already defined +Error at file 'new.asm' line 1111: symbol 'i_12' already defined +Error at file 'new.asm' line 1132: symbol 'i_13' already defined +Error at file 'new.asm' line 1136: symbol 'i_11' already defined +Error at file 'new.asm' line 1194: symbol 'i_17' already defined +Error at file 'new.asm' line 1218: symbol 'i_18' already defined +Error at file 'new.asm' line 1233: symbol 'i_21' already defined +Error at file 'new.asm' line 1240: symbol 'i_23' already defined +Error at file 'new.asm' line 1245: symbol 'i_25' already defined +Error at file 'new.asm' line 1264: symbol 'i_26' already defined +Error at file 'new.asm' line 1268: symbol 'i_24' already defined +Error at file 'new.asm' line 1288: symbol 'i_28' already defined +Error at file 'new.asm' line 1301: symbol 'i_32' already defined +Error at file 'new.asm' line 1321: symbol 'i_31' already defined +Error at file 'new.asm' line 1332: symbol 'i_33' already defined +Error at file 'new.asm' line 1334: symbol 'i_34' already defined +Error at file 'new.asm' line 1338: symbol 'i_27' already defined +Error at file 'new.asm' line 1339: symbol 'i_20' already defined +Error at file 'new.asm' line 1341: symbol 'i_16' already defined +Error at file 'new.asm' line 1440: symbol 'i_35' already defined +Error at file 'new.asm' line 1441: symbol 'i_15' already defined +Error at file 'new.asm' line 1898: symbol 'i_1' already defined +Error at file 'new.asm' line 2112: cannot read file 'z80_crt0.hdr' +Error at file 'new.asm' line 2254: symbol 'i_2' already defined +Error at file 'new.asm' line 2284: symbol 'i_3' already defined +Error at file 'new.asm' line 2300: symbol 'i_4' already defined +Error at file 'new.asm' line 2349: symbol 'i_6' already defined +Error at file 'new.asm' line 2351: symbol 'i_7' already defined +Error at file 'new.asm' line 2355: symbol 'i_5' already defined +Error at file 'new.asm' line 2393: symbol 'i_9' already defined +Error at file 'new.asm' line 2402: symbol 'i_8' already defined +Error at file 'new.asm' line 2407: symbol 'i_13' already defined +Error at file 'new.asm' line 2411: symbol 'i_14' already defined +Error at file 'new.asm' line 2450: symbol 'i_15' already defined +Error at file 'new.asm' line 2465: symbol 'i_12' already defined +Error at file 'new.asm' line 2512: symbol 'i_16' already defined +Error at file 'new.asm' line 2640: symbol 'i_18' already defined +Error at file 'new.asm' line 2648: symbol 'i_17' already defined +Error at file 'new.asm' line 2665: symbol 'i_20' already defined +Error at file 'new.asm' line 2692: symbol 'i_21' already defined +Error at file 'new.asm' line 2694: symbol 'i_22' already defined +Error at file 'new.asm' line 2702: symbol 'i_23' already defined +Error at file 'new.asm' line 2710: symbol 'i_24' already defined +Error at file 'new.asm' line 2759: symbol 'i_26' already defined +Error at file 'new.asm' line 2768: symbol 'i_25' already defined +Error at file 'new.asm' line 2815: symbol 'i_30' already defined +Error at file 'new.asm' line 2817: symbol 'i_29' already defined +Error at file 'new.asm' line 2868: symbol 'i_33' already defined +Error at file 'new.asm' line 2887: symbol 'i_34' already defined +Error at file 'new.asm' line 2910: symbol 'i_32' already defined +Error at file 'new.asm' line 2911: symbol 'i_31' already defined +Error at file 'new.asm' line 2912: symbol 'i_28' already defined +Error at file 'new.asm' line 2955: symbol 'i_35' already defined +Error at file 'new.asm' line 2956: symbol 'i_38' already defined +Error at file 'new.asm' line 2992: symbol 'i_39' already defined +Error at file 'new.asm' line 2994: symbol 'i_40' already defined +Error at file 'new.asm' line 3001: symbol 'i_41' already defined +Error at file 'new.asm' line 3022: symbol 'i_42' already defined +Error at file 'new.asm' line 3052: symbol 'i_43' already defined +Error at file 'new.asm' line 3062: symbol 'i_36' already defined +Error at file 'new.asm' line 3068: symbol 'i_37' already defined +Error at file 'new.asm' line 3085: symbol 'i_46' already defined +Error at file 'new.asm' line 3145: symbol 'i_48' already defined +Error at file 'new.asm' line 3147: symbol 'i_49' already defined +Error at file 'new.asm' line 3155: symbol 'i_50' already defined +Error at file 'new.asm' line 3176: symbol 'i_51' already defined +Error at file 'new.asm' line 3219: symbol 'i_52' already defined +Error at file 'new.asm' line 3232: symbol 'i_55' already defined +Error at file 'new.asm' line 3234: symbol 'i_47' already defined +Error at file 'new.asm' line 3252: symbol 'i_56' already defined +Error at file 'new.asm' line 3305: symbol 'i_57' already defined +Error at file 'new.asm' line 3306: symbol 'i_59' already defined +Error at file 'new.asm' line 3340: symbol 'i_61' already defined +Error at file 'new.asm' line 3342: symbol 'i_60' already defined +Error at file 'new.asm' line 3364: symbol 'i_64' already defined +Error at file 'new.asm' line 3383: symbol 'i_67' already defined +Error at file 'new.asm' line 3385: symbol 'i_66' already defined +Error at file 'new.asm' line 3395: symbol 'i_63' already defined +Error at file 'new.asm' line 3412: symbol 'i_70' already defined +Error at file 'new.asm' line 3465: symbol 'i_69' already defined +Error at file 'new.asm' line 3483: symbol 'i_75' already defined +Error at file 'new.asm' line 3487: symbol 'i_74' already defined +Error at file 'new.asm' line 3495: symbol 'i_73' already defined +Error at file 'new.asm' line 3514: symbol 'i_72' already defined +Error at file 'new.asm' line 3516: symbol 'i_58' already defined +Error at file 'new.asm' line 3548: symbol 'i_78' already defined +Error at file 'new.asm' line 3550: symbol 'i_79' already defined +Error at file 'new.asm' line 3656: symbol 'i_82' already defined +Error at file 'new.asm' line 3782: symbol 'i_80' already defined +Error at file 'new.asm' line 5748: symbol 'i_1' already defined +Error at file 'new.asm' line 25: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 62: symbol 'l_pint' not defined +Error at file 'new.asm' line 64: symbol 'l_lneg' not defined +Error at file 'new.asm' line 79: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 81: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 91: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 126: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 128: symbol 'l_glongsp' not defined +Error at file 'new.asm' line 138: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 141: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 144: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 147: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 150: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 153: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 155: symbol 'l_glongsp' not defined +Error at file 'new.asm' line 179: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 181: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 186: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 210: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 212: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 217: symbol 'l_gcharsp' not defined +Error at file 'new.asm' line 218: symbol 'l_lneg' not defined +Error at file 'new.asm' line 243: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 257: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 262: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 279: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 281: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 286: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 312: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 314: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 319: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 320: symbol 'l_lneg' not defined +Error at file 'new.asm' line 329: symbol 'l_pint' not defined +Error at file 'new.asm' line 341: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 343: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 353: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 366: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 371: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 390: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 392: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 397: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 423: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 425: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 430: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 431: symbol 'l_lneg' not defined +Error at file 'new.asm' line 439: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 444: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 467: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 469: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 474: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 1073: symbol 'l_glong' not defined +Error at file 'new.asm' line 1418: symbol 'l_lneg' not defined +Error at file 'new.asm' line 1490: symbol 'l_lneg' not defined +Error at file 'new.asm' line 1495: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 1498: symbol 'l_long_mult' not defined +Error at file 'new.asm' line 1500: symbol 'l_plong' not defined +Error at file 'new.asm' line 1510: symbol 'l_glongsp' not defined +Error at file 'new.asm' line 1567: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 1576: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 1581: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 1587: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 1667: symbol 'l_pint' not defined +Error at file 'new.asm' line 1675: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 1702: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 1708: symbol 'l_glong' not defined +Error at file 'new.asm' line 1758: symbol 'l_pint' not defined +Error at file 'new.asm' line 1763: symbol 'l_glong' not defined +Error at file 'new.asm' line 1774: symbol 'l_lneg' not defined +Error at file 'new.asm' line 1779: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 1782: symbol 'l_long_mult' not defined +Error at file 'new.asm' line 1784: symbol 'l_plong' not defined +Error at file 'new.asm' line 1789: symbol 'l_glongsp' not defined +Error at file 'new.asm' line 1811: symbol 'l_pint' not defined +Error at file 'new.asm' line 1880: symbol 'l_pint' not defined +Error at file 'new.asm' line 1890: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2123: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2133: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2155: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2163: symbol 'l_plong' not defined +Error at file 'new.asm' line 2177: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2188: symbol 'l_plong' not defined +Error at file 'new.asm' line 2202: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2212: symbol 'l_plong' not defined +Error at file 'new.asm' line 2226: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2235: symbol 'l_plong' not defined +Error at file 'new.asm' line 2238: symbol 'l_glong' not defined +Error at file 'new.asm' line 2252: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2275: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2277: symbol 'l_sxt' not defined +Error at file 'new.asm' line 2279: symbol 'l_sxt' not defined +Error at file 'new.asm' line 2297: symbol 'l_g2intspsp' not defined +Error at file 'new.asm' line 2325: symbol 'l_gchar' not defined +Error at file 'new.asm' line 2337: symbol 'l_gchar' not defined +Error at file 'new.asm' line 2348: integer '-2385' out of range +Error at file 'new.asm' line 2373: symbol 'l_glong' not defined +Error at file 'new.asm' line 2385: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 2387: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2390: symbol 'l_glong' not defined +Error at file 'new.asm' line 2391: symbol 'l_long_uge' not defined +Error at file 'new.asm' line 2417: symbol 'l_gint' not defined +Error at file 'new.asm' line 2420: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 2423: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 2425: symbol 'l_long_asr_u' not defined +Error at file 'new.asm' line 2426: symbol 'l_long_add' not defined +Error at file 'new.asm' line 2431: symbol 'l_glong' not defined +Error at file 'new.asm' line 2484: symbol 'l_glong' not defined +Error at file 'new.asm' line 2490: symbol 'l_plong' not defined +Error at file 'new.asm' line 2493: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 2495: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2498: symbol 'l_glong' not defined +Error at file 'new.asm' line 2503: symbol 'l_long_uge' not defined +Error at file 'new.asm' line 2515: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 2517: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2523: symbol 'l_long_mult' not defined +Error at file 'new.asm' line 2527: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2530: symbol 'l_glong' not defined +Error at file 'new.asm' line 2531: symbol 'l_long_add' not defined +Error at file 'new.asm' line 2552: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2560: symbol 'l_plong' not defined +Error at file 'new.asm' line 2564: symbol 'l_glong' not defined +Error at file 'new.asm' line 2568: symbol 'l_plong' not defined +Error at file 'new.asm' line 2572: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 2574: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2581: symbol 'l_or' not defined +Error at file 'new.asm' line 2584: symbol 'l_plong' not defined +Error at file 'new.asm' line 2587: symbol 'l_glong' not defined +Error at file 'new.asm' line 2617: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2620: symbol 'l_glong' not defined +Error at file 'new.asm' line 2622: symbol 'l_plong' not defined +Error at file 'new.asm' line 2625: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 2628: symbol 'l_long_eq' not defined +Error at file 'new.asm' line 2632: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 2634: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2637: symbol 'l_glong' not defined +Error at file 'new.asm' line 2638: symbol 'l_long_uge' not defined +Error at file 'new.asm' line 2651: symbol 'l_glong' not defined +Error at file 'new.asm' line 2652: symbol 'l_long_lneg' not defined +Error at file 'new.asm' line 2659: symbol 'l_gint' not defined +Error at file 'new.asm' line 2662: symbol 'l_glong' not defined +Error at file 'new.asm' line 2664: symbol 'l_plong' not defined +Error at file 'new.asm' line 2667: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2673: symbol 'l_glong' not defined +Error at file 'new.asm' line 2675: symbol 'l_plong' not defined +Error at file 'new.asm' line 2677: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2684: symbol 'l_glong' not defined +Error at file 'new.asm' line 2691: integer '-2689' out of range +Error at file 'new.asm' line 2697: symbol 'l_glongsp' not defined +Error at file 'new.asm' line 2709: symbol 'l_glong' not defined +Error at file 'new.asm' line 2712: symbol 'l_plong' not defined +Error at file 'new.asm' line 2714: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2719: symbol 'l_glongsp' not defined +Error at file 'new.asm' line 2724: symbol 'l_plong' not defined +Error at file 'new.asm' line 2743: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2744: symbol 'l_gint' not defined +Error at file 'new.asm' line 2750: symbol 'l_lneg' not defined +Error at file 'new.asm' line 2753: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2756: symbol 'l_glong' not defined +Error at file 'new.asm' line 2757: symbol 'l_long_lneg' not defined +Error at file 'new.asm' line 2777: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2781: symbol 'l_glong' not defined +Error at file 'new.asm' line 2782: symbol 'l_inclong' not defined +Error at file 'new.asm' line 2784: symbol 'l_plong' not defined +Error at file 'new.asm' line 2786: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2789: symbol 'l_glong' not defined +Error at file 'new.asm' line 2796: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 2803: symbol 'l_gint' not defined +Error at file 'new.asm' line 2805: symbol 'l_uge' not defined +Error at file 'new.asm' line 2823: symbol 'l_asr_u_hl_by_e' not defined +Error at file 'new.asm' line 2834: symbol 'l_and' not defined +Error at file 'new.asm' line 2842: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2845: symbol 'l_glong' not defined +Error at file 'new.asm' line 2852: symbol 'l_plong' not defined +Error at file 'new.asm' line 2855: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 2858: symbol 'l_long_ule' not defined +Error at file 'new.asm' line 2871: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 2873: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2876: symbol 'l_glong' not defined +Error at file 'new.asm' line 2877: symbol 'l_long_uge' not defined +Error at file 'new.asm' line 2889: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2895: symbol 'l_glong' not defined +Error at file 'new.asm' line 2897: symbol 'l_plong' not defined +Error at file 'new.asm' line 2899: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2904: symbol 'l_glongsp' not defined +Error at file 'new.asm' line 2909: symbol 'l_plong' not defined +Error at file 'new.asm' line 2914: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 2916: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2917: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 2938: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2942: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 2944: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2949: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2961: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 2963: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2966: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 2968: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 2995: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 2997: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3006: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3020: symbol 'l_pint' not defined +Error at file 'new.asm' line 3024: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3031: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 3033: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3046: symbol 'l_lneg' not defined +Error at file 'new.asm' line 3057: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3061: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 3064: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3070: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3087: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3090: symbol 'l_glong' not defined +Error at file 'new.asm' line 3099: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3102: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 3104: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3105: symbol 'l_gint' not defined +Error at file 'new.asm' line 3114: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 3116: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3119: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 3121: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3160: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3181: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3213: symbol 'l_lneg' not defined +Error at file 'new.asm' line 3221: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3231: integer '-2386' out of range +Error at file 'new.asm' line 3243: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3251: symbol 'l_plong' not defined +Error at file 'new.asm' line 3270: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3273: symbol 'l_gint' not defined +Error at file 'new.asm' line 3279: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 3301: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3302: symbol 'l_gint' not defined +Error at file 'new.asm' line 3311: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 3339: integer '-2313' out of range +Error at file 'new.asm' line 3362: symbol 'l_uge' not defined +Error at file 'new.asm' line 3382: integer '-2251' out of range +Error at file 'new.asm' line 3419: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 3432: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 3447: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 3472: symbol 'l_uge' not defined +Error at file 'new.asm' line 3497: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 3518: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 3529: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 3573: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3579: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3582: symbol 'l_glong' not defined +Error at file 'new.asm' line 3658: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3734: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3739: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3746: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 3748: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3755: symbol 'l_plong' not defined +Error at file 'new.asm' line 3757: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3762: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3768: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 3770: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3775: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3781: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 3803: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3820: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3833: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3845: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3853: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3872: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 3886: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 3888: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3900: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3903: symbol 'l_gint' not defined +Error at file 'new.asm' line 3912: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3924: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3929: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3934: symbol 'l_plong' not defined +Error at file 'new.asm' line 3949: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 3952: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 3972: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 3989: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 3992: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4003: symbol 'l_lneg' not defined +Error at file 'new.asm' line 4006: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4065: symbol 'l_glongsp' not defined +Error at file 'new.asm' line 4085: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4120: symbol 'l_plong' not defined +Error at file 'new.asm' line 4128: symbol 'l_glongsp' not defined +Error at file 'new.asm' line 4172: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4204: symbol 'l_plong' not defined +Error at file 'new.asm' line 4207: symbol 'l_glong' not defined +Error at file 'new.asm' line 4208: symbol 'l_long_lneg' not defined +Error at file 'new.asm' line 4219: symbol 'l_plong' not defined +Error at file 'new.asm' line 4224: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4230: symbol 'l_long_mult' not defined +Error at file 'new.asm' line 4232: symbol 'l_plong' not defined +Error at file 'new.asm' line 4234: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4240: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4247: symbol 'l_long_add' not defined +Error at file 'new.asm' line 4249: symbol 'l_plong' not defined +Error at file 'new.asm' line 4251: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4260: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4269: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 4280: symbol 'l_plong' not defined +Error at file 'new.asm' line 4283: symbol 'l_glong' not defined +Error at file 'new.asm' line 4284: symbol 'l_long_lneg' not defined +Error at file 'new.asm' line 4295: symbol 'l_plong' not defined +Error at file 'new.asm' line 4302: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4309: symbol 'l_long_sub' not defined +Error at file 'new.asm' line 4314: symbol 'l_glong' not defined +Error at file 'new.asm' line 4315: symbol 'l_long_sub' not defined +Error at file 'new.asm' line 4319: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4322: symbol 'l_gint' not defined +Error at file 'new.asm' line 4324: symbol 'l_asr_u_hl_by_e' not defined +Error at file 'new.asm' line 4326: symbol 'l_long_sub' not defined +Error at file 'new.asm' line 4330: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4336: symbol 'l_long_div_u' not defined +Error at file 'new.asm' line 4342: symbol 'l_plong' not defined +Error at file 'new.asm' line 4344: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4350: symbol 'l_glong' not defined +Error at file 'new.asm' line 4352: symbol 'l_plong' not defined +Error at file 'new.asm' line 4358: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4361: symbol 'l_long_uge' not defined +Error at file 'new.asm' line 4381: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 4388: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4398: symbol 'l_plong' not defined +Error at file 'new.asm' line 4400: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4405: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4408: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4411: symbol 'l_glong' not defined +Error at file 'new.asm' line 4412: symbol 'l_long_add' not defined +Error at file 'new.asm' line 4416: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4419: symbol 'l_gint' not defined +Error at file 'new.asm' line 4421: symbol 'l_asr_u_hl_by_e' not defined +Error at file 'new.asm' line 4423: symbol 'l_long_add' not defined +Error at file 'new.asm' line 4425: symbol 'l_plong' not defined +Error at file 'new.asm' line 4427: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4431: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4450: symbol 'l_lneg' not defined +Error at file 'new.asm' line 4469: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 4480: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4486: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 4488: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4493: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4533: symbol 'l_plong' not defined +Error at file 'new.asm' line 4545: symbol 'l_plong' not defined +Error at file 'new.asm' line 4599: symbol 'l_lneg' not defined +Error at file 'new.asm' line 4631: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4633: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4636: symbol 'l_glong' not defined +Error at file 'new.asm' line 4637: symbol 'l_long_sub' not defined +Error at file 'new.asm' line 4639: symbol 'l_plong' not defined +Error at file 'new.asm' line 4641: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 4644: symbol 'l_glong' not defined +Error at file 'new.asm' line 4651: symbol 'l_long_ugt' not defined +Error at file 'new.asm' line 4658: symbol 'l_glong' not defined +Error at file 'new.asm' line 4659: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 4663: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4671: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4674: symbol 'l_long_div_u' not defined +Error at file 'new.asm' line 4689: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4692: symbol 'l_long_div_u' not defined +Error at file 'new.asm' line 4696: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4703: symbol 'l_long_and' not defined +Error at file 'new.asm' line 4716: symbol 'l_glong' not defined +Error at file 'new.asm' line 4730: symbol 'l_glong' not defined +Error at file 'new.asm' line 4732: symbol 'l_plong' not defined +Error at file 'new.asm' line 4743: symbol 'l_glong' not defined +Error at file 'new.asm' line 4750: symbol 'l_plong' not defined +Error at file 'new.asm' line 4754: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4757: symbol 'l_long_ule' not defined +Error at file 'new.asm' line 4778: symbol 'l_glong' not defined +Error at file 'new.asm' line 4780: symbol 'l_plong' not defined +Error at file 'new.asm' line 4790: symbol 'l_glong' not defined +Error at file 'new.asm' line 4797: symbol 'l_plong' not defined +Error at file 'new.asm' line 4800: symbol 'l_glong' not defined +Error at file 'new.asm' line 4801: symbol 'l_long_lneg' not defined +Error at file 'new.asm' line 4822: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4828: symbol 'l_long_add' not defined +Error at file 'new.asm' line 4830: symbol 'l_plong' not defined +Error at file 'new.asm' line 4840: symbol 'l_gint' not defined +Error at file 'new.asm' line 4843: symbol 'l_div_u' not defined +Error at file 'new.asm' line 4847: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 4849: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 4851: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4860: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4861: symbol 'l_pint' not defined +Error at file 'new.asm' line 4867: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 4869: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4872: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4874: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4877: symbol 'l_gint' not defined +Error at file 'new.asm' line 4880: symbol 'l_div_u' not defined +Error at file 'new.asm' line 4884: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4892: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 4894: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4915: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 4917: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4919: symbol 'l_long_add' not defined +Error at file 'new.asm' line 4921: symbol 'l_plong' not defined +Error at file 'new.asm' line 4930: symbol 'l_gint' not defined +Error at file 'new.asm' line 4934: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 4936: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4943: symbol 'l_gint' not defined +Error at file 'new.asm' line 4945: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 4954: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 4956: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 4984: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5002: symbol 'l_lneg' not defined +Error at file 'new.asm' line 5027: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5028: symbol 'l_lneg' not defined +Error at file 'new.asm' line 5094: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 5097: symbol 'l_long_and' not defined +Error at file 'new.asm' line 5099: symbol 'l_plong' not defined +Error at file 'new.asm' line 5110: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 5112: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5115: symbol 'l_glong' not defined +Error at file 'new.asm' line 5116: symbol 'l_long_sub' not defined +Error at file 'new.asm' line 5118: symbol 'l_plong' not defined +Error at file 'new.asm' line 5120: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 5123: symbol 'l_glong' not defined +Error at file 'new.asm' line 5130: symbol 'l_long_ugt' not defined +Error at file 'new.asm' line 5137: symbol 'l_glong' not defined +Error at file 'new.asm' line 5138: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 5142: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5150: symbol 'l_gint' not defined +Error at file 'new.asm' line 5153: symbol 'l_div_u' not defined +Error at file 'new.asm' line 5166: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 5169: symbol 'l_long_div_u' not defined +Error at file 'new.asm' line 5173: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5180: symbol 'l_long_and' not defined +Error at file 'new.asm' line 5193: symbol 'l_glong' not defined +Error at file 'new.asm' line 5207: symbol 'l_glong' not defined +Error at file 'new.asm' line 5209: symbol 'l_plong' not defined +Error at file 'new.asm' line 5220: symbol 'l_glong' not defined +Error at file 'new.asm' line 5227: symbol 'l_plong' not defined +Error at file 'new.asm' line 5231: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 5234: symbol 'l_long_ule' not defined +Error at file 'new.asm' line 5255: symbol 'l_glong' not defined +Error at file 'new.asm' line 5257: symbol 'l_plong' not defined +Error at file 'new.asm' line 5267: symbol 'l_glong' not defined +Error at file 'new.asm' line 5274: symbol 'l_plong' not defined +Error at file 'new.asm' line 5277: symbol 'l_glong' not defined +Error at file 'new.asm' line 5278: symbol 'l_long_lneg' not defined +Error at file 'new.asm' line 5299: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 5305: symbol 'l_long_add' not defined +Error at file 'new.asm' line 5307: symbol 'l_plong' not defined +Error at file 'new.asm' line 5314: symbol 'l_glong' not defined +Error at file 'new.asm' line 5347: symbol 'l_gint' not defined +Error at file 'new.asm' line 5350: symbol 'l_div_u' not defined +Error at file 'new.asm' line 5359: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 5361: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5367: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5374: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 5376: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5404: symbol 'l_glong2sp' not defined +Error at file 'new.asm' line 5406: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5408: symbol 'l_long_add' not defined +Error at file 'new.asm' line 5410: symbol 'l_plong' not defined +Error at file 'new.asm' line 5419: symbol 'l_gint' not defined +Error at file 'new.asm' line 5421: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 5430: symbol 'l_gint' not defined +Error at file 'new.asm' line 5434: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 5436: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5443: symbol 'l_gint' not defined +Error at file 'new.asm' line 5445: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 5450: symbol 'l_gint' not defined +Error at file 'new.asm' line 5453: symbol 'l_div_u' not defined +Error at file 'new.asm' line 5515: symbol 'l_lneg' not defined +Error at file 'new.asm' line 5521: symbol 'l_pint' not defined +Error at file 'new.asm' line 5530: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5536: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 5541: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 5546: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5552: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 5556: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5563: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5589: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5599: symbol 'l_plong' not defined +Error at file 'new.asm' line 5606: symbol 'l_pint' not defined +Error at file 'new.asm' line 5610: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5618: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5622: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 5627: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5647: symbol 'l_lneg' not defined +Error at file 'new.asm' line 5653: symbol 'l_pint' not defined +Error at file 'new.asm' line 5657: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5663: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 5665: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5666: symbol 'l_lneg' not defined +Error at file 'new.asm' line 5672: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5676: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 5688: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 5695: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 5697: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5702: symbol 'l_gintspsp' not defined +Error at file 'new.asm' line 5707: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5717: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5721: symbol 'l_pint_pop' not defined +Error at file 'new.asm' line 5723: symbol 'l_gintsp' not defined +Error at file 'new.asm' line 5732: symbol 'l_pint' not defined +Error at file 'new.asm' line 5738: symbol 'l_gintsp' not defined diff --git a/software/src/PetitFS/pff_obj/pff.asm b/software/src/PetitFS/pff_obj/pff.asm new file mode 100644 index 0000000..fdbaedd --- /dev/null +++ b/software/src/PetitFS/pff_obj/pff.asm @@ -0,0 +1,3863 @@ +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Fri Mar 13 17:13:29 2020 + + + + MODULE pff_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION code_compiler + +; Function ld_word flags 0x00000200 __smallc +; unsigned int WORDld_word(const unsigned char BYTE*ptr) +; parameter 'const unsigned char BYTE*ptr' at 2 size(2) +._ld_word + push bc + ld hl,4 ;const + call l_gintsp ; + inc hl + ld l,(hl) + ld h,0 + pop bc + push hl + ld h,l + ld l,0 + push hl + ld hl,6 ;const + call l_gintsp ; + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop bc + ret + + + +; Function ld_dword flags 0x00000200 __smallc +; unsigned long DWORDld_dword(const unsigned char BYTE*ptr) +; parameter 'const unsigned char BYTE*ptr' at 2 size(2) +._ld_dword + push bc + push bc + ld hl,0 ;const + add hl,sp + push hl + ld hl,8 ;const + call l_gintsp ; + inc hl + inc hl + inc hl + ld l,(hl) + ld h,0 + ld de,0 + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + ld a,(hl) + inc hl + ld e,(hl) + inc hl + ld d,(hl) + ld h,a + ld l,0 + push de + push hl + ld hl,12 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + ld a,(hl) + inc hl + ld e,(hl) + inc hl + ld d,(hl) + ld h,a + ld l,0 + push de + push hl + ld hl,12 ;const + call l_gintsp ; + inc hl + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + ld a,(hl) + inc hl + ld e,(hl) + inc hl + ld d,(hl) + ld h,a + ld l,0 + push de + push hl + ld hl,12 ;const + call l_gintsp ; + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + call l_glong + pop bc + pop bc + ret + + + +; Function mem_set flags 0x00000200 __smallc +; void mem_set(void *dst, int val, int cnt) +; parameter 'int cnt' at 2 size(2) +; parameter 'int val' at 4 size(2) +; parameter 'void *dst' at 6 size(2) +._mem_set + ld hl,6 ;const + call l_gintsp ; + push hl +.i_2 + ld hl,4 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + inc hl + ld a,h + or l + jp z,i_3 + pop hl + inc hl + push hl + dec hl + push hl + ld hl,8 ;const + call l_gintsp ; + ld a,l + call l_sxt + ld a,l + call l_sxt + pop de + ld a,l + ld (de),a + jp i_2 +.i_3 + pop bc + ret + + + +; Function mem_cmp flags 0x00000200 __smallc +; int mem_cmp(const void *dst, const void *src, int cnt) +; parameter 'int cnt' at 2 size(2) +; parameter 'const void *src' at 4 size(2) +; parameter 'const void *dst' at 6 size(2) +._mem_cmp + ld hl,6 ;const + call l_g2intspsp ; + ld hl,0 ;const + push hl +.i_4 + ld hl,8 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + inc hl + ld a,h + or l + jp z,i_6 + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + call l_gchar + push hl + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + call l_gchar + pop de + ex de,hl + and a + sbc hl,de + pop bc + push hl + ld a,h + or l + jp nz,i_6 + inc hl + jr i_7 +.i_6 + ld hl,0 ;const +.i_7 + ld a,h + or l + jp nz,i_4 +.i_5 + pop hl + pop bc + pop bc + ret + + + +; Function get_fat flags 0x00000200 __smallc +; unsigned long DWORDget_fat(unsigned long clst) +; parameter 'unsigned long clst' at 2 size(4) +._get_fat + push bc + push bc + ld hl,(_FatFs) + push hl + ld hl,8 ;const + add hl,sp + call l_glong + ld a,l + sub 2 + ld a,h + sbc 0 + ld a,e + sbc 0 + ld a,d + sbc 0 + jp c,i_9 + ld hl,8 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + call l_glong + call l_long_uge + jp nc,i_8 +.i_9 + ld hl,1 ;const + ld de,0 + pop bc + pop bc + pop bc + ret + + +.i_8 + pop hl + push hl + ld l,(hl) + ld h,0 +.i_13 + ld a,l + cp +(3% 256) + jp nz,i_12 +.i_14 + ld hl,2 ;const + add hl,sp + push hl + dec hl + dec hl + call l_gint ; + ld bc,10 + add hl,bc + call l_glong2sp + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld l,+(7 % 256) + call l_long_asr_u + call l_long_add + push de + push hl + ld hl,14 ;const + add hl,sp + call l_glong + ld a,l + and +(127 % 256) + ld l,a + ld h,0 + add hl,hl + add hl,hl + push hl + ld hl,4 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp nz,i_12 +.i_15 + ld hl,2 ;const + add hl,sp + push hl + call _ld_dword + pop bc + ld a,d + and +(15 % 256) + ld d,a + pop bc + pop bc + pop bc + ret + + +.i_12 + ld hl,1 ;const + ld de,0 + pop bc + pop bc + pop bc + ret + + + +; Function clust2sect flags 0x00000200 __smallc +; unsigned long DWORDclust2sect(unsigned long clst) +; parameter 'unsigned long clst' at 2 size(4) +._clust2sect + ld hl,(_FatFs) + push hl + ld hl,4 ;const + add hl,sp + push hl + call l_glong + ld bc,65534 + add hl,bc + jr c,ASMPC+3 + dec de + pop bc + call l_plong + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + call l_glong + ld bc,65534 + add hl,bc + jr c,ASMPC+3 + dec de + call l_long_uge + jp nc,i_16 + ld hl,0 ;const + ld d,h + ld e,l + pop bc + ret + + +.i_16 + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + ld h,0 + ld de,0 + call l_long_mult + push de + push hl + ld hl,4 ;const + call l_gintsp ; + ld bc,18 + add hl,bc + call l_glong + call l_long_add + pop bc + ret + + + +; Function get_clust flags 0x00000200 __smallc +; unsigned long DWORDget_clust(unsigned char BYTE*dir) +; parameter 'unsigned char BYTE*dir' at 2 size(2) +._get_clust + ld hl,(_FatFs) + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + ld hl,0 ;const + add hl,sp + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,20 + add hl,bc + push hl + call _ld_word + pop bc + ld de,0 + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + call l_glong + ex de,hl + ld hl,0 ;const + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + call l_glong2sp + ld hl,14 ;const + call l_gintsp ; + ld bc,26 + add hl,bc + push hl + call _ld_word + pop bc + pop de + call l_or + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + call l_glong + pop bc + pop bc + pop bc + ret + + + +; Function dir_rewind flags 0x00000200 __smallc +; const int FRESULTdir_rewind(struct 0__anonstruct_5 DIR*dj) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 2 size(2) +._dir_rewind + push bc + push bc + ld hl,(_FatFs) + push hl + ld hl,8 ;const + add hl,sp + ld a,(hl) + inc hl + ld h,(hl) + ld l,a + xor a + ld (hl),a + inc hl + ld (hl),a + ld hl,2 ;const + add hl,sp + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + call l_glong + pop bc + call l_plong + ld hl,2 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_eq + jp c,i_18 + ld hl,2 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + call l_glong + call l_long_uge + jp nc,i_17 +.i_18 + ld hl,1 ;const + pop bc + pop bc + pop bc + ret + + +.i_17 + ld hl,2 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_20 + ld hl,2 ;const + add hl,sp + push hl + dec hl + dec hl + call l_gint ; + ld bc,14 + add hl,bc + call l_glong + pop bc + call l_plong +.i_20 + ld hl,8 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + push hl + ld hl,4 ;const + add hl,sp + call l_glong + pop bc + call l_plong + ld hl,8 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + push hl + jp i_21 + ld hl,4 ;const + add hl,sp + call l_glong + ld a,h + or l + or d + or e + jp nz,i_21 + ld hl,0 ;const + jr i_22 +.i_21 + ld hl,1 ;const +.i_22 + jp nc,i_23 + ld hl,4 ;const + call l_glongsp ; + call _clust2sect + pop bc + pop bc + jp i_24 +.i_23 + pop bc + pop hl + push hl + push bc + ld bc,14 + add hl,bc + call l_glong +.i_24 + pop bc + call l_plong + ld hl,8 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + push hl + ld hl,4 ;const + call l_glongsp ; + call _clust2sect + pop bc + pop bc + pop bc + call l_plong + ld hl,0 ;const + pop bc + pop bc + pop bc + ret + + + +; Function dir_next flags 0x00000200 __smallc +; const int FRESULTdir_next(struct 0__anonstruct_5 DIR*dj) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 2 size(2) +._dir_next + push bc + push bc + push bc + ld hl,(_FatFs) + push hl + ld hl,10 ;const + call l_gintsp ; + call l_gint ; + inc hl + pop de + pop bc + push hl + push de + call l_lneg + jp c,i_26 + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong + call l_long_lneg + jp nc,i_25 +.i_26 + ld hl,3 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_25 + pop bc + pop hl + push hl + push bc + ld a,l + and +(15 % 256) + jp nz,i_28 + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + push hl + call l_glong + call l_inclong + pop bc + call l_plong + ld hl,10 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + call l_glong + ld a,d + or e + or h + or l + jp nz,i_29 + ld hl,2 ;const + call l_gintspsp ; + pop bc + pop hl + push hl + push bc + ld bc,4 + add hl,bc + call l_gint ; + pop de + call l_uge + jp nc,i_30 + ld hl,3 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_30 + jp i_31 +.i_29 + pop bc + pop hl + push hl + push bc + ld de,4 + call l_asr_u_hl_by_e + pop de + push de + push hl + ex de,hl + inc hl + inc hl + ld l,(hl) + ld h,0 + dec hl + pop de + call l_and + ld a,h + or l + jp nz,i_32 + ld hl,4 ;const + add hl,sp + push hl + ld hl,12 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + call l_glong + push de + push hl + call _get_fat + pop bc + pop bc + pop bc + call l_plong + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_ule + jp nc,i_33 + ld hl,1 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_33 + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + call l_glong + call l_long_uge + jp nc,i_34 + ld hl,3 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_34 + ld hl,10 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + push hl + ld hl,6 ;const + add hl,sp + call l_glong + pop bc + call l_plong + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + push hl + ld hl,6 ;const + call l_glongsp ; + call _clust2sect + pop bc + pop bc + pop bc + call l_plong +.i_32 +.i_31 +.i_28 + ld hl,10 ;const + call l_gintspsp ; + ld hl,4 ;const + call l_gintsp ; + call l_pint_pop + ld hl,0 ;const + pop bc + pop bc + pop bc + pop bc + ret + + + +; Function dir_find flags 0x00000200 __smallc +; const int FRESULTdir_find(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir) +; parameter 'unsigned char BYTE*dir' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._dir_find + push bc + dec sp + ld hl,1 ;const + add hl,sp + push hl + ld hl,9 ;const + call l_gintsp ; + push hl + call _dir_rewind + pop bc + call l_pint_pop + ld hl,1 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_35 + ld hl,1 ;const + call l_gintsp ; + inc sp + pop bc + ret + + +.i_35 +.i_38 + ld hl,1 ;const + add hl,sp + push hl + ld hl,7 ;const + call l_gintspsp ; + ld hl,11 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong2sp + ld hl,15 ;const + call l_gintsp ; + ld a,(hl) + and +(15 % 256) + ld l,a + ld h,0 + add hl,hl + add hl,hl + add hl,hl + add hl,hl + add hl,hl + push hl + ld hl,32 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_39 + ld hl,1 ;const + jp i_40 +.i_39 + ld hl,0 ;const +.i_40 + call l_pint_pop + ld hl,1 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_37 +.i_41 + ld hl,0 ;const + add hl,sp + push hl + ld hl,7 ;const + call l_gintsp ; + ld a,(hl) + pop de + ld (de),a + pop hl + push hl + ld h,0 + ld a,l + and a + jp nz,i_42 + ld hl,1 ;const + add hl,sp + ld de,3 ;const + ex de,hl + call l_pint + jp i_37 +.i_42 + ld hl,5 ;const + call l_gintsp ; + ld bc,11 + add hl,bc + ld a,(hl) + and +(8 % 256) + jp nz,i_44 + ld hl,5 ;const + call l_gintspsp ; + ld hl,9 ;const + call l_gintsp ; + inc hl + inc hl + ld e,(hl) + inc hl + ld d,(hl) + push de + ld hl,11 ;const + push hl + call _mem_cmp + pop bc + pop bc + pop bc + call l_lneg + jr c,i_45_i_44 +.i_44 + jp i_43 +.i_45_i_44 + jp i_37 +.i_43 + ld hl,1 ;const + add hl,sp + push hl + ld hl,9 ;const + call l_gintsp ; + push hl + call _dir_next + pop bc + call l_pint_pop +.i_36 + ld hl,1 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_38 +.i_37 + ld hl,1 ;const + call l_gintsp ; + inc sp + pop bc + ret + + + +; Function dir_read flags 0x00000200 __smallc +; const int FRESULTdir_read(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir) +; parameter 'unsigned char BYTE*dir' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._dir_read + ld hl,3 ;const + push hl + push bc +.i_46 + ld hl,8 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong + ld a,h + or l + or d + or e + jp z,i_47 + ld hl,i_1+0 + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong2sp + ld hl,14 ;const + call l_gintsp ; + call l_gint ; + push hl + ld a,4 + call printf + pop bc + pop bc + pop bc + pop bc + ld hl,6 ;const + call l_gintspsp ; + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong2sp + ld hl,14 ;const + call l_gintsp ; + ld a,(hl) + and +(15 % 256) + ld l,a + ld h,0 + add hl,hl + add hl,hl + add hl,hl + add hl,hl + add hl,hl + push hl + ld hl,32 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_48 + ld hl,1 ;const + jp i_49 +.i_48 + ld hl,0 ;const +.i_49 + pop de + pop bc + push hl + push de + ld a,h + or l + jp nz,i_47 +.i_50 + ld hl,0 ;const + add hl,sp + push hl + ld hl,8 ;const + call l_gintsp ; + ld a,(hl) + pop de + ld (de),a + pop hl + push hl + ld h,0 + ld a,l + and a + jp nz,i_51 + ld hl,3 ;const + pop de + pop bc + push hl + push de + jp i_47 +.i_51 + ld hl,1 ;const + add hl,sp + push hl + ld hl,8 ;const + call l_gintsp ; + ld bc,11 + add hl,bc + ld a,(hl) + and +(63 % 256) + ld l,a + ld h,0 + pop de + ld a,l + ld (de),a + ld hl,0 ;const + add hl,sp + ld a,(hl) + cp 229 + jp z,i_53 + pop hl + push hl + ld h,0 + ld de,46 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jp nc,i_53 + pop hl + push hl + ld l,h + ld h,0 + ld a,+(8 % 256) + and l + ld l,a + call l_lneg + jr c,i_54_i_53 +.i_53 + jp i_52 +.i_54_i_53 + jp i_47 +.i_52 + ld hl,8 ;const + call l_gintsp ; + push hl + call _dir_next + pop bc + pop de + pop bc + push hl + push de + ld a,h + or l + jr nz,i_47 +.i_55 + jp i_46 +.i_47 + pop bc + pop hl + push hl + push bc + ld a,h + or l + jp z,i_56 + ld hl,8 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + push hl + ld hl,0 ;const + ld d,h + ld e,l + pop bc + call l_plong +.i_56 + pop bc + pop hl + ret + + + +; Function create_name flags 0x00000200 __smallc +; const int FRESULTcreate_name(struct 0__anonstruct_5 DIR*dj, const char **path) +; parameter 'const char **path' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._create_name + push bc + push bc + push bc + push bc + dec sp + ld hl,13 ;const + call l_gintsp ; + inc hl + inc hl + call l_gint ; + pop de + pop bc + push hl + push de + ld hl,2 ;const + call l_gintspsp ; + ld hl,32 ;const + push hl + ld hl,11 ;const + push hl + call _mem_set + pop bc + pop bc + pop bc + ld hl,5 ;const + add hl,sp + push hl + ld hl,6 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld a,(hl) + pop de + ld (de),a + ld hl,6 ;const + add hl,sp + ld (hl),+(8 % 256 % 256) + ld hl,11 ;const + call l_gintsp ; + call l_gint ; + pop bc + push hl +.i_57 +.i_59 + ld hl,8 ;const + add hl,sp + push hl + ld hl,2 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + pop de + ld a,(hl) + ld (de),a + ld hl,8 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,32 + and a + sbc hl,de + ccf + jp c,i_61 + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,47 + and a + sbc hl,de + jr nz,i_60 +.i_61 + jp i_58 +.i_60 + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,46 + and a + sbc hl,de + scf + jr z,ASMPC+3 + ccf + jp c,i_64 + ld hl,4 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,6 ;const + add hl,sp + ld l,(hl) + ld h,0 + call l_uge + jp nc,i_63 +.i_64 + ld hl,6 ;const + add hl,sp + ld a,(hl) + cp 8 + jr z,ASMPC+3 + scf + jp c,i_67 + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,46 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jr nc,i_66 +.i_67 + jp i_58 +.i_66 + ld hl,4 ;const + add hl,sp + ld (hl),+(8 % 256 % 256) + ld hl,6 ;const + add hl,sp + ld (hl),+(11 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_57 +.i_63 + jp i_70 + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + dec hl + pop de + ex de,hl + and a + sbc hl,de + jr c,i_71_i_70 +.i_70 + jp i_69 +.i_71_i_70 + ld hl,7 ;const + add hl,sp + push hl + ld hl,2 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + pop de + ld a,(hl) + ld (de),a + ld hl,2 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + ex de,hl + ld hl,8 ;const + add hl,sp + ld a,(hl) + ld (de),a + ld hl,2 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + push hl + ld hl,9 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a + ld l,a + ld h,0 + jp i_72 +.i_69 + jp i_74 + ld hl,8 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,97 + call l_uge + jp nc,i_75 + ld hl,8 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,122 + and a + sbc hl,de + ccf + jr c,i_76_i_75 +.i_75 + jp i_74 +.i_76_i_75 + jr i_77_i_74 +.i_74 + jp i_73 +.i_77_i_74 + ld hl,8 ;const + add hl,sp + ld a,(hl) + add a,+(-32 % 256) + ld (hl),a +.i_73 + ld hl,2 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + push hl + ld hl,10 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a + ld l,a + ld h,0 +.i_72 + jp i_57 +.i_58 + ld hl,11 ;const + call l_gintspsp ; + ld hl,2 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,7 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + call l_pint_pop + pop bc + pop hl + push hl + push bc + ld bc,11 + add hl,bc + push hl + ld hl,10 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,32 + and a + sbc hl,de + ccf + jp nc,i_78 + ld hl,1 ;const + jp i_79 +.i_78 + ld hl,0 ;const +.i_79 + pop de + ld a,l + ld (de),a + ld hl,0 ;const + inc sp + pop bc + pop bc + pop bc + pop bc + ret + + + +; Function get_fileinfo flags 0x00000200 __smallc +; void get_fileinfo(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir, struct 0__anonstruct_6 FILINFO*fno) +; parameter 'struct 0__anonstruct_6 FILINFO*fno' at 2 size(2) +; parameter 'unsigned char BYTE*dir' at 4 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 6 size(2) +._get_fileinfo + push bc + push bc + ld hl,6 ;const + call l_gintsp ; + ld bc,9 + add hl,bc + pop bc + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong + ld a,h + or l + or d + or e + jp z,i_80 + ld hl,3 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_83 +.i_81 + ld hl,3 ;const + add hl,sp + inc (hl) +.i_83 + ld hl,3 ;const + add hl,sp + ld a,(hl) + sub 8 + jp nc,i_82 + ld hl,2 ;const + add hl,sp + push hl + ld hl,10 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,5 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + ld a,(hl) + pop de + ld (de),a + ld hl,2 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + jp z,i_82 +.i_84 + ld hl,2 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 5 + jp nz,i_85 + ld hl,2 ;const + add hl,sp + ld (hl),+(229 % 256 % 256) +.i_85 + pop hl + inc hl + push hl + dec hl + push hl + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld a,l + rla + sbc a + ld h,a + pop de + ld a,l + ld (de),a + jp i_81 +.i_82 + ld hl,8 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jp nc,i_86 + pop hl + ld (hl),+(46 % 256) + inc hl + push hl + ld hl,3 ;const + add hl,sp + ld (hl),+(8 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_89 +.i_87 + ld hl,3 ;const + add hl,sp + inc (hl) +.i_89 + ld hl,3 ;const + add hl,sp + ld a,(hl) + sub 11 + jp nc,i_88 + ld hl,2 ;const + add hl,sp + push hl + ld hl,10 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,5 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + ld a,(hl) + pop de + ld (de),a + ld hl,2 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + jp z,i_88 +.i_90 + pop hl + inc hl + push hl + dec hl + push hl + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld a,l + rla + sbc a + ld h,a + pop de + ld a,l + ld (de),a + jp i_87 +.i_88 +.i_86 + ld hl,6 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,11 + add hl,bc + ld a,(hl) + pop de + ld (de),a + ld hl,6 ;const + call l_gintspsp ; + ld hl,10 ;const + call l_gintsp ; + ld bc,28 + add hl,bc + push hl + call _ld_dword + pop bc + pop bc + call l_plong + ld hl,6 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,24 + add hl,bc + push hl + call _ld_word + pop bc + call l_pint_pop + ld hl,6 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,22 + add hl,bc + push hl + call _ld_word + pop bc + call l_pint_pop +.i_80 + pop de + push de + ld hl,0 ;const + ld a,l + ld (de),a + pop bc + pop bc + ret + + + +; Function follow_path flags 0x00000200 __smallc +; const int FRESULTfollow_path(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir, const char *path) +; parameter 'const char *path' at 2 size(2) +; parameter 'unsigned char BYTE*dir' at 4 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 6 size(2) +._follow_path + push bc +.i_91 + ld hl,4 ;const + call l_gintsp ; + ld a,(hl) + cp 32 + jp nz,i_92 + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + jp i_91 +.i_92 + ld hl,4 ;const + call l_gintsp ; + ld a,(hl) + cp 47 + jp nz,i_93 + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) +.i_93 + ld hl,8 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + xor a + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + ld hl,4 ;const + call l_gintsp ; + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + jp nc,i_94 + ld hl,8 ;const + call l_gintsp ; + push hl + call _dir_rewind + pop bc + pop bc + push hl + ld hl,6 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,0 % 256 ;const + ld a,l + ld (de),a + jp i_95 +.i_94 +.i_96 +.i_98 + ld hl,8 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + push hl + call _create_name + pop bc + pop bc + pop bc + push hl + ld a,h + or l + jp nz,i_97 +.i_99 + ld hl,8 ;const + call l_gintspsp ; + ld hl,8 ;const + call l_gintsp ; + push hl + call _dir_find + pop bc + pop bc + pop bc + push hl + ld a,h + or l + jp nz,i_97 +.i_100 + ld hl,8 ;const + call l_gintsp ; + inc hl + inc hl + call l_gint ; + ld bc,11 + add hl,bc + ld l,(hl) + ld a,l + and a + jp nz,i_97 +.i_101 + ld hl,6 ;const + call l_gintsp ; + ld bc,11 + add hl,bc + ld a,(hl) + and +(16 % 256) + jp nz,i_102 + ld hl,3 ;const + pop bc + push hl + jp i_97 +.i_102 + ld hl,8 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + push hl + ld hl,8 ;const + call l_gintsp ; + push hl + call _get_clust + pop bc + pop bc + call l_plong + jp i_96 +.i_97 +.i_95 + pop hl + ret + + + +; Function check_fs flags 0x00000200 __smallc +; unsigned char BYTEcheck_fs(unsigned char BYTE*buf, unsigned long sect) +; parameter 'unsigned long sect' at 2 size(4) +; parameter 'unsigned char BYTE*buf' at 6 size(2) +._check_fs + ld hl,6 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,510 ;const + push hl + ld hl,2 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_103 + ld hl,3 % 256 ;const + ret + + +.i_103 + ld hl,6 ;const + call l_gintsp ; + push hl + call _ld_word + pop bc + ld de,43605 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jp nc,i_104 + ld hl,2 % 256 ;const + ret + + +.i_104 + ld hl,6 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,82 ;const + push hl + ld hl,2 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + call l_lneg + jp nc,i_106 + ld hl,6 ;const + call l_gintsp ; + push hl + call _ld_word + pop bc + ld de,16710 + and a + sbc hl,de + jr z,i_107_i_106 +.i_106 + jp i_105 +.i_107_i_106 + ld hl,0 % 256 ;const + ret + + +.i_105 + ld hl,1 % 256 ;const + ret + + + +; Function pf_mount flags 0x00000200 __smallc +; const int FRESULTpf_mount(struct 0__anonstruct_4 FATFS*fs) +; parameter 'struct 0__anonstruct_4 FATFS*fs' at 2 size(2) +._pf_mount + ld hl,65483 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ld (_FatFs),hl + call _disk_initialize + ld a,l + and +(1 % 256) + jp z,i_108 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,2 ;const + ret + + +.i_108 + ld hl,12 ;const + add hl,sp + xor a + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + ld hl,52 ;const + add hl,sp + push hl + ld hl,18 ;const + add hl,sp + push hl + ld hl,16 ;const + call l_glongsp ; + call _check_fs + pop bc + pop bc + pop bc + pop de + ld a,l + ld (de),a + ld hl,52 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 1 + jp nz,i_109 + ld hl,16 ;const + add hl,sp + push hl + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld hl,446 ;const + push hl + ld hl,16 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_110 + ld hl,52 ;const + add hl,sp + ld (hl),+(3 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_111 +.i_110 + ld hl,20 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_112 + ld hl,12 ;const + add hl,sp + push hl + ld hl,26 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong + ld hl,52 ;const + add hl,sp + push hl + ld hl,18 ;const + add hl,sp + push hl + ld hl,16 ;const + call l_glongsp ; + call _check_fs + pop bc + pop bc + pop bc + pop de + ld a,l + ld (de),a +.i_112 +.i_111 +.i_109 + ld hl,52 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 3 + jp nz,i_113 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_113 + ld hl,52 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_114 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,6 ;const + ret + + +.i_114 + ld hl,16 ;const + add hl,sp + push hl + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld hl,13 ;const + push hl + ld hl,36 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_115 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_115 + ld hl,8 ;const + add hl,sp + push hl + ld hl,27 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + pop bc + call l_plong + ld hl,8 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_116 + ld hl,8 ;const + add hl,sp + push hl + ld hl,41 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong +.i_116 + ld hl,8 ;const + add hl,sp + push hl + call l_glong2sp + ld hl,25 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + call l_long_mult + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + ld bc,10 + add hl,bc + push hl + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld hl,23 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + inc hl + inc hl + ex de,hl + ld hl,16 ;const + add hl,sp + ld a,(hl) + ld (de),a + ld hl,55 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + push hl + ld hl,22 ;const + add hl,sp + push hl + call _ld_word + pop bc + call l_pint_pop + ld hl,4 ;const + add hl,sp + push hl + ld hl,24 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + pop bc + call l_plong + ld hl,4 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_117 + ld hl,4 ;const + add hl,sp + push hl + ld hl,37 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong +.i_117 + ld hl,0 ;const + add hl,sp + push hl + ld hl,6 ;const + add hl,sp + call l_glong2sp + ld hl,23 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + call l_long_sub + push de + push hl + ld hl,14 ;const + add hl,sp + call l_glong + call l_long_sub + push de + push hl + ld hl,61 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + call l_gint ; + ld de,4 + call l_asr_u_hl_by_e + ld de,0 + call l_long_sub + push de + push hl + ld hl,61 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + ld h,0 + ld de,0 + call l_long_div_u + ld bc,2 + add hl,bc + jr nc,ASMPC+3 + inc de + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + push hl + ld hl,2 ;const + add hl,sp + call l_glong + pop bc + call l_plong + ld hl,52 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld hl,0 ;const + add hl,sp + call l_glong2sp + ld hl,65527 ;const + ld de,0 + call l_long_uge + jp nc,i_118 + ld hl,52 ;const + add hl,sp + ld (hl),+(3 % 256 % 256) +.i_118 + ld hl,52 ;const + add hl,sp + ld a,(hl) + and a + jp nz,i_119 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,6 ;const + ret + + +.i_119 + ld hl,55 ;const + call l_gintspsp ; + ld hl,54 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a + ld hl,55 ;const + call l_gintsp ; + ld bc,14 + add hl,bc + push hl + ld hl,49 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + ld bc,18 + add hl,bc + push hl + ld hl,57 ;const + call l_gintsp ; + ld bc,10 + add hl,bc + call l_glong2sp + ld hl,14 ;const + add hl,sp + call l_glong + call l_long_add + push de + push hl + ld hl,61 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + call l_gint ; + ld de,4 + call l_asr_u_hl_by_e + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,55 ;const + call l_gintsp ; + ld (_FatFs),hl + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; Function pf_open flags 0x00000200 __smallc +; const int FRESULTpf_open(const char *path) +; parameter 'const char *path' at 2 size(2) +._pf_open + ld hl,65474 ;const + add hl,sp + ld sp,hl + ld hl,(_FatFs) + push hl + call l_lneg + jp nc,i_120 + ld hl,64 ;const + add hl,sp + ld sp,hl + ld hl,5 ;const + ret + + +.i_120 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,48 ;const + add hl,sp + push hl + ld hl,36 ;const + add hl,sp + call l_pint_pop + ld hl,62 ;const + add hl,sp + push hl + ld hl,48 ;const + add hl,sp + push hl + ld hl,6 ;const + add hl,sp + push hl + ld hl,72 ;const + call l_gintsp ; + push hl + call _follow_path + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,62 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_121 + ld hl,62 ;const + call l_gintsp ; + exx + ld hl,64 ;const + add hl,sp + ld sp,hl + exx + ret + + +.i_121 + ld hl,2 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_123 + ld hl,13 ;const + add hl,sp + ld a,+(16 % 256) + and (hl) + jp z,i_122 +.i_123 + ld hl,64 ;const + add hl,sp + ld sp,hl + ld hl,3 ;const + ret + + +.i_122 + pop hl + push hl + ld bc,30 + add hl,bc + push hl + ld hl,4 ;const + add hl,sp + push hl + call _get_clust + pop bc + pop bc + call l_plong + pop hl + push hl + ld bc,26 + add hl,bc + push hl + ld hl,32 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong + pop hl + push hl + ld bc,22 + add hl,bc + xor a + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + pop hl + push hl + inc hl + ld (hl),+(1 % 256 % 256) + ld hl,64 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; Function pf_read flags 0x00000200 __smallc +; const int FRESULTpf_read(void *buff, unsigned int btr, unsigned int UINT*br) +; parameter 'unsigned int UINT*br' at 2 size(2) +; parameter 'unsigned int btr' at 4 size(2) +; parameter 'void *buff' at 6 size(2) +._pf_read + ld hl,65519 ;const + add hl,sp + ld sp,hl + ld hl,23 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + push de + ld hl,(_FatFs) + push hl + ld hl,23 ;const + add hl,sp + ld a,(hl) + inc hl + ld h,(hl) + ld l,a + xor a + ld (hl),a + inc hl + ld (hl),a + pop hl + push hl + call l_lneg + jp nc,i_125 + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,5 ;const + ret + + +.i_125 + pop hl + push hl + inc hl + ld a,(hl) + and +(1 % 256) + jp nz,i_126 + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,4 ;const + ret + + +.i_126 + ld hl,7 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,26 + add hl,bc + call l_glong2sp + ld hl,6 ;const + call l_gintsp ; + ld bc,22 + add hl,bc + call l_glong + call l_long_sub + pop bc + call l_plong + ld hl,25 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + call l_glong + exx + pop hl + ld de,0 + push de + push hl + exx + call l_long_ugt + jp nc,i_127 + ld hl,25 ;const + add hl,sp + push hl + ld hl,9 ;const + add hl,sp + call l_glong + call l_pint_pop +.i_127 +.i_128 + ld hl,25 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_129 + pop hl + push hl + ld bc,22 + add hl,bc + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_div_u + exx + ld a,d + or e + or h + or l + jp nz,i_130 + ld hl,4 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,22 + add hl,bc + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_div_u + push de + push hl + ld hl,6 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + ld h,0 + dec hl + ld de,0 + call l_long_and + pop de + ld a,l + ld (de),a + ld hl,4 ;const + add hl,sp + ld a,(hl) + and a + jp nz,i_131 + pop hl + push hl + ld bc,22 + add hl,bc + call l_glong + ld a,d + or e + or h + or l + jp nz,i_132 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,30 + add hl,bc + call l_glong + pop bc + call l_plong + jp i_133 +.i_132 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _get_fat + pop bc + pop bc + pop bc + call l_plong +.i_133 + ld hl,15 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_ule + jp nc,i_134 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_134 + pop hl + push hl + ld bc,34 + add hl,bc + push hl + ld hl,17 ;const + add hl,sp + call l_glong + pop bc + call l_plong +.i_131 + ld hl,11 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _clust2sect + pop bc + pop bc + pop bc + call l_plong + ld hl,11 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_135 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_135 + pop hl + push hl + ld bc,38 + add hl,bc + push hl + ld hl,13 ;const + add hl,sp + call l_glong2sp + ld hl,10 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + call l_long_add + pop bc + call l_plong +.i_130 + ld hl,5 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ld hl,512 + and a + sbc hl,de + call l_pint_pop + ld hl,5 ;const + call l_gintspsp ; + ld hl,27 ;const + call l_gintsp ; + pop de + and a + sbc hl,de + jp nc,i_136 + ld hl,5 ;const + add hl,sp + ex de,hl + ld hl,25 ;const + call l_gintsp ; + call l_pint +.i_136 + ld hl,19 ;const + add hl,sp + push hl + ld hl,4 ;const + call l_gintspsp ; + ld hl,4 ;const + call l_gintsp ; + ld bc,38 + add hl,bc + call l_glong2sp + ld hl,8 ;const + call l_gintsp ; + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ex de,hl + push hl + ld hl,15 ;const + call l_gintsp ; + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,19 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_137 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_137 + pop hl + push hl + ld bc,22 + add hl,bc + push hl + call l_glong2sp + ld hl,11 ;const + call l_gintsp ; + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,25 ;const + add hl,sp + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,7 ;const + add hl,sp + call l_gint + ex de,hl + and a + sbc hl,de + call l_pint_pop + ld hl,23 ;const + call l_gintsp ; + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,7 ;const + add hl,sp + call l_gint + add hl,de + call l_pint_pop + pop bc + pop hl + push hl + push bc + ld a,h + or l + jp z,i_138 + ld hl,2 ;const + call l_gintspsp ; + ld hl,7 ;const + call l_gintsp ; + pop de + add hl,de + pop de + pop bc + push hl + push de +.i_138 + jp i_128 +.i_129 + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; Function pf_write flags 0x00000200 __smallc +; const int FRESULTpf_write(const void *buff, unsigned int btw, unsigned int UINT*bw) +; parameter 'unsigned int UINT*bw' at 2 size(2) +; parameter 'unsigned int btw' at 4 size(2) +; parameter 'const void *buff' at 6 size(2) +._pf_write + ld hl,65524 ;const + add hl,sp + ld sp,hl + ld hl,18 ;const + call l_gintsp ; + push hl + push bc + dec sp + ld hl,(_FatFs) + push hl + ld hl,21 ;const + add hl,sp + ld a,(hl) + inc hl + ld h,(hl) + ld l,a + xor a + ld (hl),a + inc hl + ld (hl),a + pop hl + push hl + call l_lneg + jp nc,i_139 + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,5 ;const + ret + + +.i_139 + pop hl + push hl + inc hl + ld a,(hl) + and +(1 % 256) + jp nz,i_140 + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,4 ;const + ret + + +.i_140 + ld hl,23 ;const + call l_gintsp ; + call l_lneg + jp nc,i_141 + pop hl + push hl + inc hl + ld a,+(64 % 256) + and (hl) + jp z,i_143 + ld hl,0 ;const + push hl + ld d,h + ld e,l + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jr nz,i_144_i_143 +.i_143 + jp i_142 +.i_144_i_143 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_142 + pop hl + push hl + inc hl + push hl + ld a,(hl) + and 191 + ld l,a + ld h,0 + pop de + ld a,l + ld (de),a + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + +.i_141 + pop hl + push hl + inc hl + ld a,(hl) + and +(64 % 256) + jp nz,i_146 + pop hl + push hl + ld bc,22 + add hl,bc + push hl + call l_glong2sp + ld hl,65024 ;const + ld de,65535 + call l_long_and + pop bc + call l_plong +.i_146 +.i_145 + ld hl,7 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,26 + add hl,bc + call l_glong2sp + ld hl,6 ;const + call l_gintsp ; + ld bc,22 + add hl,bc + call l_glong + call l_long_sub + pop bc + call l_plong + ld hl,23 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + call l_glong + exx + pop hl + ld de,0 + push de + push hl + exx + call l_long_ugt + jp nc,i_147 + ld hl,23 ;const + add hl,sp + push hl + ld hl,9 ;const + add hl,sp + call l_glong + call l_pint_pop +.i_147 +.i_148 + ld hl,23 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_149 + pop hl + push hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ex de,hl + ld a,h + or l + jp nz,i_150 + ld hl,4 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,22 + add hl,bc + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_div_u + push de + push hl + ld hl,6 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + ld h,0 + dec hl + ld de,0 + call l_long_and + pop de + ld a,l + ld (de),a + ld hl,4 ;const + add hl,sp + ld a,(hl) + and a + jp nz,i_151 + pop hl + push hl + ld bc,22 + add hl,bc + call l_glong + ld a,d + or e + or h + or l + jp nz,i_152 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,30 + add hl,bc + call l_glong + pop bc + call l_plong + jp i_153 +.i_152 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _get_fat + pop bc + pop bc + pop bc + call l_plong +.i_153 + ld hl,15 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_ule + jp nc,i_154 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_154 + pop hl + push hl + ld bc,34 + add hl,bc + push hl + ld hl,17 ;const + add hl,sp + call l_glong + pop bc + call l_plong +.i_151 + ld hl,11 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _clust2sect + pop bc + pop bc + pop bc + call l_plong + ld hl,11 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_155 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_155 + pop hl + push hl + ld bc,38 + add hl,bc + push hl + ld hl,13 ;const + add hl,sp + call l_glong2sp + ld hl,10 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + call l_long_add + pop bc + call l_plong + pop hl + push hl + ld bc,0 + push bc + ld bc,38 + add hl,bc + call l_glong + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_156 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_156 + pop hl + push hl + inc hl + ld a,(hl) + or 64 + ld (hl),a +.i_150 + pop hl + push hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ld hl,512 + and a + sbc hl,de + pop de + pop bc + push hl + push de + ld hl,2 ;const + call l_gintspsp ; + ld hl,25 ;const + call l_gintsp ; + pop de + and a + sbc hl,de + jp nc,i_157 + ld hl,23 ;const + call l_gintsp ; + pop de + pop bc + push hl + push de +.i_157 + ld hl,5 ;const + call l_gintspsp ; + ld hl,4 ;const + call l_gintsp ; + ld de,0 + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_158 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_158 + pop hl + push hl + ld bc,22 + add hl,bc + push hl + call l_glong2sp + ld hl,8 ;const + call l_gintsp ; + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,5 ;const + add hl,sp + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,4 ;const + add hl,sp + call l_gint + add hl,de + call l_pint_pop + ld hl,23 ;const + add hl,sp + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,4 ;const + add hl,sp + call l_gint + ex de,hl + and a + sbc hl,de + call l_pint_pop + ld hl,21 ;const + call l_gintsp ; + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,4 ;const + add hl,sp + call l_gint + add hl,de + call l_pint_pop + pop hl + push hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ex de,hl + ld a,h + or l + jp nz,i_159 + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_160 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_160 + pop hl + push hl + inc hl + push hl + ld a,(hl) + and 191 + ld l,a + ld h,0 + pop de + ld a,l + ld (de),a +.i_159 + jp i_148 +.i_149 + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; Function pf_opendir flags 0x00000200 __smallc +; const int FRESULTpf_opendir(struct 0__anonstruct_5 DIR*dj, const char *path) +; parameter 'const char *path' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._pf_opendir + ld hl,65490 ;const + add hl,sp + ld sp,hl + ld hl,(_FatFs) + push hl + call l_lneg + jp nc,i_161 + ld hl,46 ;const + add hl,sp + ld de,5 ;const + ex de,hl + call l_pint + jp i_162 +.i_161 + ld hl,i_1+33 + push hl + ld a,1 + call printf + pop bc + ld hl,52 ;const + call l_gintsp ; + inc hl + inc hl + push hl + ld hl,36 ;const + add hl,sp + call l_pint_pop + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + push hl + ld hl,56 ;const + call l_gintsp ; + push hl + call _follow_path + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,i_1+42 + push hl + ld hl,48 ;const + call l_gintsp ; + push hl + ld a,2 + call printf + pop bc + pop bc + ld hl,46 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_163 + ld hl,2 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_164 + ld hl,i_1+55 + push hl + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld a,2 + call printf + pop bc + pop bc + ld hl,13 ;const + add hl,sp + ld a,+(16 % 256) + and (hl) + jp z,i_165 + ld hl,52 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + push hl + ld hl,4 ;const + add hl,sp + push hl + call _get_clust + pop bc + pop bc + call l_plong + jp i_166 +.i_165 + ld hl,46 ;const + add hl,sp + ld de,3 ;const + ex de,hl + call l_pint +.i_166 +.i_164 + ld hl,46 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_167 + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintsp ; + push hl + call _dir_rewind + pop bc + call l_pint_pop +.i_167 +.i_163 +.i_162 + ld hl,46 ;const + call l_gintsp ; + exx + ld hl,48 ;const + add hl,sp + ld sp,hl + exx + ret + + + +; Function pf_readdir flags 0x00000200 __smallc +; const int FRESULTpf_readdir(struct 0__anonstruct_5 DIR*dj, struct 0__anonstruct_6 FILINFO*fno) +; parameter 'struct 0__anonstruct_6 FILINFO*fno' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._pf_readdir + ld hl,65490 ;const + add hl,sp + ld sp,hl + ld hl,(_FatFs) + push hl + call l_lneg + jp nc,i_168 + ld hl,46 ;const + add hl,sp + ld de,5 ;const + ex de,hl + call l_pint + jp i_169 +.i_168 + ld hl,52 ;const + call l_gintsp ; + inc hl + inc hl + push hl + ld hl,36 ;const + add hl,sp + call l_pint_pop + ld hl,50 ;const + call l_gintsp ; + call l_lneg + jp nc,i_170 + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintsp ; + push hl + call _dir_rewind + pop bc + call l_pint_pop + jp i_171 +.i_170 + ld hl,i_1+70 + push hl + ld a,1 + call printf + pop bc + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + push hl + call _dir_read + pop bc + pop bc + call l_pint_pop + ld hl,46 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_172 + ld hl,52 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintsp ; + push hl + call _get_fileinfo + pop bc + pop bc + pop bc + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintsp ; + push hl + call _dir_next + pop bc + call l_pint_pop + ld hl,46 ;const + call l_gintsp ; + ld de,3 + and a + sbc hl,de + jp nz,i_173 + ld hl,46 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint +.i_173 +.i_172 +.i_171 +.i_169 + ld hl,46 ;const + call l_gintsp ; + exx + ld hl,48 ;const + add hl,sp + ld sp,hl + exx + ret + + + SECTION rodata_compiler +.i_1 + defm "dir_read: sector:%ld, index:%l" + defm "d" + defb 10 + + defm "" + defb 0 + + defm "OPENDIR" + defb 10 + + defm "" + defb 0 + + defm "RESDIR:%02x" + defb 10 + + defm "" + defb 0 + + defm "IS A DIR:%02x" + defb 10 + + defm "" + defb 0 + + defm "Readdir" + defb 10 + + defm "" + defb 0 + + +; --- Start of Static Variables --- + + SECTION bss_compiler +._FatFs defs 2 + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- diff --git a/software/src/PetitFS/pff_obj/pff_dir.asm b/software/src/PetitFS/pff_obj/pff_dir.asm new file mode 100644 index 0000000..2be7af1 --- /dev/null +++ b/software/src/PetitFS/pff_obj/pff_dir.asm @@ -0,0 +1,1267 @@ +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Fri Mar 13 22:51:17 2020 + + + + MODULE pff_dir_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION code_compiler + +; Function dir_rewind flags 0x00000200 __smallc +; const int FRESULTdir_rewind(struct 0__anonstruct_5 DIR*dj) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 2 size(2) +._dir_rewind + push bc + push bc + ld hl,(_FatFs) + push hl + ld hl,8 ;const + add hl,sp + ld a,(hl) + inc hl + ld h,(hl) + ld l,a + xor a + ld (hl),a + inc hl + ld (hl),a + ld hl,2 ;const + add hl,sp + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + call l_glong + pop bc + call l_plong + ld hl,2 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_eq + jp c,i_3 + ld hl,2 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + call l_glong + call l_long_uge + jp nc,i_2 +.i_3 + ld hl,1 ;const + pop bc + pop bc + pop bc + ret + + +.i_2 + ld hl,2 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_5 + ld hl,2 ;const + add hl,sp + push hl + dec hl + dec hl + call l_gint ; + ld bc,14 + add hl,bc + call l_glong + pop bc + call l_plong +.i_5 + ld hl,8 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + push hl + ld hl,4 ;const + add hl,sp + call l_glong + pop bc + call l_plong + ld hl,8 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + push hl + ld hl,4 ;const + call l_glongsp ; + call _clust2sect + pop bc + pop bc + pop bc + call l_plong + ld hl,0 ;const + pop bc + pop bc + pop bc + ret + + + +; Function dir_next flags 0x00000200 __smallc +; const int FRESULTdir_next(struct 0__anonstruct_5 DIR*dj) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 2 size(2) +._dir_next + push bc + push bc + push bc + ld hl,(_FatFs) + push hl + ld hl,10 ;const + call l_gintsp ; + call l_gint ; + inc hl + pop de + pop bc + push hl + push de + call l_lneg + jp c,i_7 + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong + call l_long_lneg + jp nc,i_6 +.i_7 + ld hl,3 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_6 + pop bc + pop hl + push hl + push bc + ld a,l + and +(15 % 256) + jp nz,i_9 + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + push hl + call l_glong + call l_inclong + pop bc + call l_plong + ld hl,10 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + call l_glong + ld a,d + or e + or h + or l + jp nz,i_10 + ld hl,2 ;const + call l_gintspsp ; + pop bc + pop hl + push hl + push bc + ld bc,4 + add hl,bc + call l_gint ; + pop de + call l_uge + jp nc,i_11 + ld hl,3 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_11 + jp i_12 +.i_10 + pop bc + pop hl + push hl + push bc + ld de,4 + call l_asr_u_hl_by_e + pop de + push de + push hl + ex de,hl + inc hl + inc hl + ld l,(hl) + ld h,0 + dec hl + pop de + call l_and + ld a,h + or l + jp nz,i_13 + ld hl,4 ;const + add hl,sp + push hl + ld hl,12 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + call l_glong + push de + push hl + call _get_fat + pop bc + pop bc + pop bc + call l_plong + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_ule + jp nc,i_14 + ld hl,1 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_14 + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + call l_glong + call l_long_uge + jp nc,i_15 + ld hl,3 ;const + pop bc + pop bc + pop bc + pop bc + ret + + +.i_15 + ld hl,10 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + push hl + ld hl,6 ;const + add hl,sp + call l_glong + pop bc + call l_plong + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + push hl + ld hl,6 ;const + call l_glongsp ; + call _clust2sect + pop bc + pop bc + pop bc + call l_plong +.i_13 +.i_12 +.i_9 + ld hl,10 ;const + call l_gintspsp ; + ld hl,4 ;const + call l_gintsp ; + call l_pint_pop + ld hl,0 ;const + pop bc + pop bc + pop bc + pop bc + ret + + + +; Function dir_find flags 0x00000200 __smallc +; const int FRESULTdir_find(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir) +; parameter 'unsigned char BYTE*dir' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._dir_find + push bc + dec sp + ld hl,1 ;const + add hl,sp + push hl + ld hl,9 ;const + call l_gintsp ; + push hl + call _dir_rewind + pop bc + call l_pint_pop + ld hl,1 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_16 + ld hl,1 ;const + call l_gintsp ; + inc sp + pop bc + ret + + +.i_16 +.i_19 + ld hl,1 ;const + add hl,sp + push hl + ld hl,7 ;const + call l_gintspsp ; + ld hl,11 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong2sp + ld hl,15 ;const + call l_gintsp ; + ld a,(hl) + and +(15 % 256) + ld l,a + ld h,0 + add hl,hl + add hl,hl + add hl,hl + add hl,hl + add hl,hl + push hl + ld hl,32 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_20 + ld hl,1 ;const + jp i_21 +.i_20 + ld hl,0 ;const +.i_21 + call l_pint_pop + ld hl,1 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_18 +.i_22 + ld hl,0 ;const + add hl,sp + push hl + ld hl,7 ;const + call l_gintsp ; + ld a,(hl) + pop de + ld (de),a + pop hl + push hl + ld h,0 + ld a,l + and a + jp nz,i_23 + ld hl,1 ;const + add hl,sp + ld de,3 ;const + ex de,hl + call l_pint + jp i_18 +.i_23 + ld hl,5 ;const + call l_gintsp ; + ld bc,11 + add hl,bc + ld a,(hl) + and +(8 % 256) + jp nz,i_25 + ld hl,5 ;const + call l_gintspsp ; + ld hl,9 ;const + call l_gintsp ; + inc hl + inc hl + ld e,(hl) + inc hl + ld d,(hl) + push de + ld hl,11 ;const + push hl + call _mem_cmp + pop bc + pop bc + pop bc + call l_lneg + jr c,i_26_i_25 +.i_25 + jp i_24 +.i_26_i_25 + jp i_18 +.i_24 + ld hl,1 ;const + add hl,sp + push hl + ld hl,9 ;const + call l_gintsp ; + push hl + call _dir_next + pop bc + call l_pint_pop +.i_17 + ld hl,1 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_19 +.i_18 + ld hl,1 ;const + call l_gintsp ; + inc sp + pop bc + ret + + + +; Function dir_read flags 0x00000200 __smallc +; const int FRESULTdir_read(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir) +; parameter 'unsigned char BYTE*dir' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._dir_read + ld hl,3 ;const + push hl + push bc +.i_27 + ld hl,8 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong + ld a,h + or l + or d + or e + jp z,i_28 + ld hl,6 ;const + call l_gintspsp ; + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong2sp + ld hl,14 ;const + call l_gintsp ; + ld a,(hl) + and +(15 % 256) + ld l,a + ld h,0 + add hl,hl + add hl,hl + add hl,hl + add hl,hl + add hl,hl + push hl + ld hl,32 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_29 + ld hl,1 ;const + jp i_30 +.i_29 + ld hl,0 ;const +.i_30 + pop de + pop bc + push hl + push de + ld a,h + or l + jp nz,i_28 +.i_31 + ld hl,0 ;const + add hl,sp + push hl + ld hl,8 ;const + call l_gintsp ; + ld a,(hl) + pop de + ld (de),a + pop hl + push hl + ld h,0 + ld a,l + and a + jp nz,i_32 + ld hl,3 ;const + pop de + pop bc + push hl + push de + jp i_28 +.i_32 + ld hl,1 ;const + add hl,sp + push hl + ld hl,8 ;const + call l_gintsp ; + ld bc,11 + add hl,bc + ld a,(hl) + and +(63 % 256) + ld l,a + ld h,0 + pop de + ld a,l + ld (de),a + ld hl,0 ;const + add hl,sp + ld a,(hl) + cp 229 + jp z,i_34 + pop hl + push hl + ld h,0 + ld de,46 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jp nc,i_34 + pop hl + push hl + ld l,h + ld h,0 + ld a,+(8 % 256) + and l + ld l,a + call l_lneg + jr c,i_35_i_34 +.i_34 + jp i_33 +.i_35_i_34 + jp i_28 +.i_33 + ld hl,8 ;const + call l_gintsp ; + push hl + call _dir_next + pop bc + pop de + pop bc + push hl + push de + ld a,h + or l + jr nz,i_28 +.i_36 + jp i_27 +.i_28 + pop bc + pop hl + push hl + push bc + ld a,h + or l + jp z,i_37 + ld hl,8 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + push hl + ld hl,0 ;const + ld d,h + ld e,l + pop bc + call l_plong +.i_37 + pop bc + pop hl + ret + + + +; Function get_fileinfo flags 0x00000200 __smallc +; void get_fileinfo(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir, struct 0__anonstruct_6 FILINFO*fno) +; parameter 'struct 0__anonstruct_6 FILINFO*fno' at 2 size(2) +; parameter 'unsigned char BYTE*dir' at 4 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 6 size(2) +._get_fileinfo + push bc + push bc + ld hl,6 ;const + call l_gintsp ; + ld bc,9 + add hl,bc + pop bc + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,12 + add hl,bc + call l_glong + ld a,h + or l + or d + or e + jp z,i_38 + ld hl,3 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_41 +.i_39 + ld hl,3 ;const + add hl,sp + inc (hl) +.i_41 + ld hl,3 ;const + add hl,sp + ld a,(hl) + sub 8 + jp nc,i_40 + ld hl,2 ;const + add hl,sp + push hl + ld hl,10 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,5 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + ld a,(hl) + pop de + ld (de),a + ld hl,2 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + jp z,i_40 +.i_42 + ld hl,2 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 5 + jp nz,i_43 + ld hl,2 ;const + add hl,sp + ld (hl),+(229 % 256 % 256) +.i_43 + pop hl + inc hl + push hl + dec hl + push hl + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld a,l + rla + sbc a + ld h,a + pop de + ld a,l + ld (de),a + jp i_39 +.i_40 + ld hl,8 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jp nc,i_44 + pop hl + ld (hl),+(46 % 256) + inc hl + push hl + ld hl,3 ;const + add hl,sp + ld (hl),+(8 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_47 +.i_45 + ld hl,3 ;const + add hl,sp + inc (hl) +.i_47 + ld hl,3 ;const + add hl,sp + ld a,(hl) + sub 11 + jp nc,i_46 + ld hl,2 ;const + add hl,sp + push hl + ld hl,10 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,5 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + ld a,(hl) + pop de + ld (de),a + ld hl,2 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + jp z,i_46 +.i_48 + pop hl + inc hl + push hl + dec hl + push hl + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld a,l + rla + sbc a + ld h,a + pop de + ld a,l + ld (de),a + jp i_45 +.i_46 +.i_44 + ld hl,6 ;const + call l_gintsp ; + ld bc,8 + add hl,bc + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,11 + add hl,bc + ld a,(hl) + pop de + ld (de),a + ld hl,6 ;const + call l_gintspsp ; + ld hl,10 ;const + call l_gintsp ; + ld bc,28 + add hl,bc + push hl + call _ld_dword + pop bc + pop bc + call l_plong + ld hl,6 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,24 + add hl,bc + push hl + call _ld_word + pop bc + call l_pint_pop + ld hl,6 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,22 + add hl,bc + push hl + call _ld_word + pop bc + call l_pint_pop +.i_38 + pop de + push de + ld hl,0 ;const + ld a,l + ld (de),a + pop bc + pop bc + ret + + + +; Function pf_opendir flags 0x00000200 __smallc +; const int FRESULTpf_opendir(struct 0__anonstruct_5 DIR*dj, const char *path) +; parameter 'const char *path' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._pf_opendir + ld hl,65490 ;const + add hl,sp + ld sp,hl + ld hl,(_FatFs) + push hl + call l_lneg + jp nc,i_49 + ld hl,46 ;const + add hl,sp + ld de,5 ;const + ex de,hl + call l_pint + jp i_50 +.i_49 + ld hl,52 ;const + call l_gintsp ; + inc hl + inc hl + push hl + ld hl,36 ;const + add hl,sp + call l_pint_pop + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + push hl + ld hl,56 ;const + call l_gintsp ; + push hl + call _follow_path + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,46 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_51 + ld hl,2 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_52 + ld hl,13 ;const + add hl,sp + ld a,+(16 % 256) + and (hl) + jp z,i_53 + ld hl,52 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + push hl + ld hl,4 ;const + add hl,sp + push hl + call _get_clust + pop bc + pop bc + call l_plong + jp i_54 +.i_53 + ld hl,46 ;const + add hl,sp + ld de,3 ;const + ex de,hl + call l_pint +.i_54 +.i_52 + ld hl,46 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_55 + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintsp ; + push hl + call _dir_rewind + pop bc + call l_pint_pop +.i_55 +.i_51 +.i_50 + ld hl,46 ;const + call l_gintsp ; + exx + ld hl,48 ;const + add hl,sp + ld sp,hl + exx + ret + + + +; Function pf_readdir flags 0x00000200 __smallc +; const int FRESULTpf_readdir(struct 0__anonstruct_5 DIR*dj, struct 0__anonstruct_6 FILINFO*fno) +; parameter 'struct 0__anonstruct_6 FILINFO*fno' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._pf_readdir + ld hl,65490 ;const + add hl,sp + ld sp,hl + ld hl,(_FatFs) + push hl + call l_lneg + jp nc,i_56 + ld hl,46 ;const + add hl,sp + ld de,5 ;const + ex de,hl + call l_pint + jp i_57 +.i_56 + ld hl,52 ;const + call l_gintsp ; + inc hl + inc hl + push hl + ld hl,36 ;const + add hl,sp + call l_pint_pop + ld hl,50 ;const + call l_gintsp ; + call l_lneg + jp nc,i_58 + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintsp ; + push hl + call _dir_rewind + pop bc + call l_pint_pop + jp i_59 +.i_58 + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + push hl + call _dir_read + pop bc + pop bc + call l_pint_pop + ld hl,46 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_60 + ld hl,52 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintsp ; + push hl + call _get_fileinfo + pop bc + pop bc + pop bc + ld hl,46 ;const + add hl,sp + push hl + ld hl,54 ;const + call l_gintsp ; + push hl + call _dir_next + pop bc + call l_pint_pop + ld hl,46 ;const + call l_gintsp ; + ld de,3 + and a + sbc hl,de + jp nz,i_61 + ld hl,46 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint +.i_61 +.i_60 +.i_59 +.i_57 + ld hl,46 ;const + call l_gintsp ; + exx + ld hl,48 ;const + add hl,sp + ld sp,hl + exx + ret + + + +; --- Start of Static Variables --- + + SECTION bss_compiler + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _FatFs + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + GLOBAL _ld_word + GLOBAL _ld_dword + GLOBAL _mem_set + GLOBAL _mem_cmp + GLOBAL _get_fat + GLOBAL _clust2sect + GLOBAL _create_name + GLOBAL _follow_path + GLOBAL _get_clust + GLOBAL _check_fs + GLOBAL _dir_rewind + GLOBAL _dir_find + GLOBAL _dir_next + GLOBAL _dir_read + GLOBAL _get_fileinfo + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- diff --git a/software/src/PetitFS/pff_obj/pff_dir.o b/software/src/PetitFS/pff_obj/pff_dir.o new file mode 100644 index 0000000..2f881d9 Binary files /dev/null and b/software/src/PetitFS/pff_obj/pff_dir.o differ diff --git a/software/src/PetitFS/pff_obj/pff_func.asm b/software/src/PetitFS/pff_obj/pff_func.asm new file mode 100644 index 0000000..65cf055 --- /dev/null +++ b/software/src/PetitFS/pff_obj/pff_func.asm @@ -0,0 +1,1227 @@ +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Fri Mar 13 22:51:17 2020 + + + + MODULE pff_func_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION code_compiler + +; Function ld_word flags 0x00000200 __smallc +; unsigned int WORDld_word(const unsigned char BYTE*ptr) +; parameter 'const unsigned char BYTE*ptr' at 2 size(2) +._ld_word + push bc + ld hl,4 ;const + call l_gintsp ; + inc hl + ld l,(hl) + ld h,0 + pop bc + push hl + ld h,l + ld l,0 + push hl + ld hl,6 ;const + call l_gintsp ; + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop bc + ret + + + +; Function ld_dword flags 0x00000200 __smallc +; unsigned long DWORDld_dword(const unsigned char BYTE*ptr) +; parameter 'const unsigned char BYTE*ptr' at 2 size(2) +._ld_dword + push bc + push bc + ld hl,0 ;const + add hl,sp + push hl + ld hl,8 ;const + call l_gintsp ; + inc hl + inc hl + inc hl + ld l,(hl) + ld h,0 + ld de,0 + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + ld a,(hl) + inc hl + ld e,(hl) + inc hl + ld d,(hl) + ld h,a + ld l,0 + push de + push hl + ld hl,12 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + ld a,(hl) + inc hl + ld e,(hl) + inc hl + ld d,(hl) + ld h,a + ld l,0 + push de + push hl + ld hl,12 ;const + call l_gintsp ; + inc hl + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + ld a,(hl) + inc hl + ld e,(hl) + inc hl + ld d,(hl) + ld h,a + ld l,0 + push de + push hl + ld hl,12 ;const + call l_gintsp ; + ld l,(hl) + pop de + ld h,d + ld a,l + or e + ld l,a + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + call l_glong + pop bc + pop bc + ret + + + +; Function mem_set flags 0x00000200 __smallc +; void mem_set(void *dst, int val, int cnt) +; parameter 'int cnt' at 2 size(2) +; parameter 'int val' at 4 size(2) +; parameter 'void *dst' at 6 size(2) +._mem_set + ld hl,6 ;const + call l_gintsp ; + push hl +.i_2 + ld hl,4 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + inc hl + ld a,h + or l + jp z,i_3 + pop hl + inc hl + push hl + dec hl + push hl + ld hl,8 ;const + call l_gintsp ; + ld a,l + call l_sxt + ld a,l + call l_sxt + pop de + ld a,l + ld (de),a + jp i_2 +.i_3 + pop bc + ret + + + +; Function mem_cmp flags 0x00000200 __smallc +; int mem_cmp(const void *dst, const void *src, int cnt) +; parameter 'int cnt' at 2 size(2) +; parameter 'const void *src' at 4 size(2) +; parameter 'const void *dst' at 6 size(2) +._mem_cmp + ld hl,6 ;const + call l_g2intspsp ; + ld hl,0 ;const + push hl +.i_4 + ld hl,8 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + inc hl + ld a,h + or l + jp z,i_6 + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + call l_gchar + push hl + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + call l_gchar + pop de + ex de,hl + and a + sbc hl,de + pop bc + push hl + ld a,h + or l + jp nz,i_6 + inc hl + jr i_7 +.i_6 + ld hl,0 ;const +.i_7 + ld a,h + or l + jp nz,i_4 +.i_5 + pop hl + pop bc + pop bc + ret + + + +; Function get_fat flags 0x00000200 __smallc +; unsigned long DWORDget_fat(unsigned long clst) +; parameter 'unsigned long clst' at 2 size(4) +._get_fat + push bc + push bc + ld hl,(_FatFs) + push hl + ld hl,8 ;const + add hl,sp + call l_glong + ld a,l + sub 2 + ld a,h + sbc 0 + ld a,e + sbc 0 + ld a,d + sbc 0 + jp c,i_9 + ld hl,8 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + call l_glong + call l_long_uge + jp nc,i_8 +.i_9 + ld hl,1 ;const + ld de,0 + pop bc + pop bc + pop bc + ret + + +.i_8 + pop hl + push hl + ld l,(hl) + ld h,0 +.i_13 + ld a,l + cp +(3% 256) + jp nz,i_12 +.i_14 + ld hl,2 ;const + add hl,sp + push hl + dec hl + dec hl + call l_gint ; + ld bc,10 + add hl,bc + call l_glong2sp + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld l,+(7 % 256) + call l_long_asr_u + call l_long_add + push de + push hl + ld hl,14 ;const + add hl,sp + call l_glong + ld a,l + and +(127 % 256) + ld l,a + ld h,0 + add hl,hl + add hl,hl + push hl + ld hl,4 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp nz,i_12 +.i_15 + ld hl,2 ;const + add hl,sp + push hl + call _ld_dword + pop bc + ld a,d + and +(15 % 256) + ld d,a + pop bc + pop bc + pop bc + ret + + +.i_12 + ld hl,1 ;const + ld de,0 + pop bc + pop bc + pop bc + ret + + + +; Function clust2sect flags 0x00000200 __smallc +; unsigned long DWORDclust2sect(unsigned long clst) +; parameter 'unsigned long clst' at 2 size(4) +._clust2sect + ld hl,(_FatFs) + push hl + ld hl,4 ;const + add hl,sp + push hl + call l_glong + ld bc,65534 + add hl,bc + jr c,ASMPC+3 + dec de + pop bc + call l_plong + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + call l_glong + ld bc,65534 + add hl,bc + jr c,ASMPC+3 + dec de + call l_long_uge + jp nc,i_16 + ld hl,0 ;const + ld d,h + ld e,l + pop bc + ret + + +.i_16 + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,4 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + ld h,0 + ld de,0 + call l_long_mult + push de + push hl + ld hl,4 ;const + call l_gintsp ; + ld bc,18 + add hl,bc + call l_glong + call l_long_add + pop bc + ret + + + +; Function get_clust flags 0x00000200 __smallc +; unsigned long DWORDget_clust(unsigned char BYTE*dir) +; parameter 'unsigned char BYTE*dir' at 2 size(2) +._get_clust + ld hl,(_FatFs) + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + ld hl,0 ;const + add hl,sp + push hl + ld hl,10 ;const + call l_gintsp ; + ld bc,20 + add hl,bc + push hl + call _ld_word + pop bc + ld de,0 + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + call l_glong + ex de,hl + ld hl,0 ;const + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + push hl + call l_glong2sp + ld hl,14 ;const + call l_gintsp ; + ld bc,26 + add hl,bc + push hl + call _ld_word + pop bc + pop de + call l_or + pop de + pop bc + call l_plong + ld hl,0 ;const + add hl,sp + call l_glong + pop bc + pop bc + pop bc + ret + + + +; Function create_name flags 0x00000200 __smallc +; const int FRESULTcreate_name(struct 0__anonstruct_5 DIR*dj, const char **path) +; parameter 'const char **path' at 2 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 4 size(2) +._create_name + push bc + push bc + push bc + push bc + dec sp + ld hl,13 ;const + call l_gintsp ; + inc hl + inc hl + call l_gint ; + pop de + pop bc + push hl + push de + ld hl,2 ;const + call l_gintspsp ; + ld hl,32 ;const + push hl + ld hl,11 ;const + push hl + call _mem_set + pop bc + pop bc + pop bc + ld hl,5 ;const + add hl,sp + push hl + ld hl,6 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld a,(hl) + pop de + ld (de),a + ld hl,6 ;const + add hl,sp + ld (hl),+(8 % 256 % 256) + ld hl,11 ;const + call l_gintsp ; + call l_gint ; + pop bc + push hl +.i_17 +.i_19 + ld hl,8 ;const + add hl,sp + push hl + ld hl,2 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + pop de + ld a,(hl) + ld (de),a + ld hl,8 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,32 + and a + sbc hl,de + ccf + jp c,i_21 + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,47 + and a + sbc hl,de + jr nz,i_20 +.i_21 + jp i_18 +.i_20 + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,46 + and a + sbc hl,de + scf + jr z,ASMPC+3 + ccf + jp c,i_24 + ld hl,4 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,6 ;const + add hl,sp + ld l,(hl) + ld h,0 + call l_uge + jp nc,i_23 +.i_24 + ld hl,6 ;const + add hl,sp + ld a,(hl) + cp 8 + jr z,ASMPC+3 + scf + jp c,i_27 + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,46 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jr nc,i_26 +.i_27 + jp i_18 +.i_26 + ld hl,4 ;const + add hl,sp + ld (hl),+(8 % 256 % 256) + ld hl,6 ;const + add hl,sp + ld (hl),+(11 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_17 +.i_23 + jp i_30 + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + dec hl + pop de + ex de,hl + and a + sbc hl,de + jr c,i_31_i_30 +.i_30 + jp i_29 +.i_31_i_30 + ld hl,7 ;const + add hl,sp + push hl + ld hl,2 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + pop de + ld a,(hl) + ld (de),a + ld hl,2 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + ex de,hl + ld hl,8 ;const + add hl,sp + ld a,(hl) + ld (de),a + ld hl,2 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + push hl + ld hl,9 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a + ld l,a + ld h,0 + jp i_32 +.i_29 + jp i_34 + ld hl,8 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,97 + call l_uge + jp nc,i_35 + ld hl,8 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,122 + and a + sbc hl,de + ccf + jr c,i_36_i_35 +.i_35 + jp i_34 +.i_36_i_35 + jr i_37_i_34 +.i_34 + jp i_33 +.i_37_i_34 + ld hl,8 ;const + add hl,sp + ld a,(hl) + add a,+(-32 % 256) + ld (hl),a +.i_33 + ld hl,2 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + inc (hl) + ld l,(hl) + ld h,0 + dec l + pop de + add hl,de + push hl + ld hl,10 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a + ld l,a + ld h,0 +.i_32 + jp i_17 +.i_18 + ld hl,11 ;const + call l_gintspsp ; + ld hl,2 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,7 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + call l_pint_pop + pop bc + pop hl + push hl + push bc + ld bc,11 + add hl,bc + push hl + ld hl,10 ;const + add hl,sp + ld e,(hl) + ld d,0 + ld hl,32 + and a + sbc hl,de + ccf + jp nc,i_38 + ld hl,1 ;const + jp i_39 +.i_38 + ld hl,0 ;const +.i_39 + pop de + ld a,l + ld (de),a + ld hl,0 ;const + inc sp + pop bc + pop bc + pop bc + pop bc + ret + + + +; Function follow_path flags 0x00000200 __smallc +; const int FRESULTfollow_path(struct 0__anonstruct_5 DIR*dj, unsigned char BYTE*dir, const char *path) +; parameter 'const char *path' at 2 size(2) +; parameter 'unsigned char BYTE*dir' at 4 size(2) +; parameter 'struct 0__anonstruct_5 DIR*dj' at 6 size(2) +._follow_path + push bc +.i_40 + ld hl,4 ;const + call l_gintsp ; + ld a,(hl) + cp 32 + jp nz,i_41 + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + jp i_40 +.i_41 + ld hl,4 ;const + call l_gintsp ; + ld a,(hl) + cp 47 + jp nz,i_42 + ld hl,4 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) +.i_42 + ld hl,8 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + xor a + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + ld hl,4 ;const + call l_gintsp ; + ld l,(hl) + ld h,0 + ld de,32 + and a + sbc hl,de + jp nc,i_43 + ld hl,8 ;const + call l_gintsp ; + push hl + call _dir_rewind + pop bc + pop bc + push hl + ld hl,6 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,0 % 256 ;const + ld a,l + ld (de),a + jp i_44 +.i_43 +.i_45 +.i_47 + ld hl,8 ;const + call l_gintspsp ; + ld hl,6 ;const + add hl,sp + push hl + call _create_name + pop bc + pop bc + pop bc + push hl + ld a,h + or l + jp nz,i_46 +.i_48 + ld hl,8 ;const + call l_gintspsp ; + ld hl,8 ;const + call l_gintsp ; + push hl + call _dir_find + pop bc + pop bc + pop bc + push hl + ld a,h + or l + jp nz,i_46 +.i_49 + ld hl,8 ;const + call l_gintsp ; + inc hl + inc hl + call l_gint ; + ld bc,11 + add hl,bc + ld l,(hl) + ld a,l + and a + jp nz,i_46 +.i_50 + ld hl,6 ;const + call l_gintsp ; + ld bc,11 + add hl,bc + ld a,(hl) + and +(16 % 256) + jp nz,i_51 + ld hl,3 ;const + pop bc + push hl + jp i_46 +.i_51 + ld hl,8 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + push hl + ld hl,8 ;const + call l_gintsp ; + push hl + call _get_clust + pop bc + pop bc + call l_plong + jp i_45 +.i_46 +.i_44 + pop hl + ret + + + +; Function check_fs flags 0x00000200 __smallc +; unsigned char BYTEcheck_fs(unsigned char BYTE*buf, unsigned long sect) +; parameter 'unsigned long sect' at 2 size(4) +; parameter 'unsigned char BYTE*buf' at 6 size(2) +._check_fs + ld hl,6 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,510 ;const + push hl + ld hl,2 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_52 + ld hl,3 % 256 ;const + ret + + +.i_52 + ld hl,6 ;const + call l_gintsp ; + push hl + call _ld_word + pop bc + ld de,43605 + and a + sbc hl,de + scf + jr nz,ASMPC+3 + ccf + jp nc,i_53 + ld hl,2 % 256 ;const + ret + + +.i_53 + ld hl,6 ;const + call l_gintspsp ; + ld hl,4 ;const + add hl,sp + call l_glong2sp + ld hl,82 ;const + push hl + ld hl,2 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + call l_lneg + jp nc,i_55 + ld hl,6 ;const + call l_gintsp ; + push hl + call _ld_word + pop bc + ld de,16710 + and a + sbc hl,de + jr z,i_56_i_55 +.i_55 + jp i_54 +.i_56_i_55 + ld hl,0 % 256 ;const + ret + + +.i_54 + ld hl,1 % 256 ;const + ret + + + +; --- Start of Static Variables --- + + SECTION bss_compiler + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _FatFs + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + GLOBAL _ld_word + GLOBAL _ld_dword + GLOBAL _mem_set + GLOBAL _mem_cmp + GLOBAL _get_fat + GLOBAL _clust2sect + GLOBAL _create_name + GLOBAL _follow_path + GLOBAL _get_clust + GLOBAL _check_fs + GLOBAL _dir_rewind + GLOBAL _dir_find + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- diff --git a/software/src/PetitFS/pff_obj/pff_func.o b/software/src/PetitFS/pff_obj/pff_func.o new file mode 100644 index 0000000..423d5a8 Binary files /dev/null and b/software/src/PetitFS/pff_obj/pff_func.o differ diff --git a/software/src/PetitFS/pff_obj/pff_mount.asm b/software/src/PetitFS/pff_obj/pff_mount.asm new file mode 100644 index 0000000..848753f --- /dev/null +++ b/software/src/PetitFS/pff_obj/pff_mount.asm @@ -0,0 +1,625 @@ +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Fri Mar 13 22:51:17 2020 + + + + MODULE pff_mount_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION code_compiler + +; Function pf_mount flags 0x00000200 __smallc +; const int FRESULTpf_mount(struct 0__anonstruct_4 FATFS*fs) +; parameter 'struct 0__anonstruct_4 FATFS*fs' at 2 size(2) +._pf_mount + ld hl,65483 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ld (_FatFs),hl + call _disk_initialize + ld a,l + and +(1 % 256) + jp z,i_2 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,2 ;const + ret + + +.i_2 + ld hl,12 ;const + add hl,sp + xor a + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + ld hl,52 ;const + add hl,sp + push hl + ld hl,18 ;const + add hl,sp + push hl + ld hl,16 ;const + call l_glongsp ; + call _check_fs + pop bc + pop bc + pop bc + pop de + ld a,l + ld (de),a + ld hl,52 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 1 + jp nz,i_3 + ld hl,16 ;const + add hl,sp + push hl + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld hl,446 ;const + push hl + ld hl,16 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_4 + ld hl,52 ;const + add hl,sp + ld (hl),+(3 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_5 +.i_4 + ld hl,20 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_6 + ld hl,12 ;const + add hl,sp + push hl + ld hl,26 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong + ld hl,52 ;const + add hl,sp + push hl + ld hl,18 ;const + add hl,sp + push hl + ld hl,16 ;const + call l_glongsp ; + call _check_fs + pop bc + pop bc + pop bc + pop de + ld a,l + ld (de),a +.i_6 +.i_5 +.i_3 + ld hl,52 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 3 + jp nz,i_7 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_7 + ld hl,52 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_8 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,6 ;const + ret + + +.i_8 + ld hl,16 ;const + add hl,sp + push hl + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld hl,13 ;const + push hl + ld hl,36 ;const + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_9 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_9 + ld hl,8 ;const + add hl,sp + push hl + ld hl,27 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + pop bc + call l_plong + ld hl,8 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_10 + ld hl,8 ;const + add hl,sp + push hl + ld hl,41 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong +.i_10 + ld hl,8 ;const + add hl,sp + push hl + call l_glong2sp + ld hl,25 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + call l_long_mult + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + ld bc,10 + add hl,bc + push hl + ld hl,14 ;const + add hl,sp + call l_glong2sp + ld hl,23 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + inc hl + inc hl + ex de,hl + ld hl,16 ;const + add hl,sp + ld a,(hl) + ld (de),a + ld hl,55 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + push hl + ld hl,22 ;const + add hl,sp + push hl + call _ld_word + pop bc + call l_pint_pop + ld hl,4 ;const + add hl,sp + push hl + ld hl,24 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + pop bc + call l_plong + ld hl,4 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_11 + ld hl,4 ;const + add hl,sp + push hl + ld hl,37 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong +.i_11 + ld hl,0 ;const + add hl,sp + push hl + ld hl,6 ;const + add hl,sp + call l_glong2sp + ld hl,23 ;const + add hl,sp + push hl + call _ld_word + pop bc + ld de,0 + call l_long_sub + push de + push hl + ld hl,14 ;const + add hl,sp + call l_glong + call l_long_sub + push de + push hl + ld hl,61 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + call l_gint ; + ld de,4 + call l_asr_u_hl_by_e + ld de,0 + call l_long_sub + push de + push hl + ld hl,61 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + ld h,0 + ld de,0 + call l_long_div_u + ld bc,2 + add hl,bc + jr nc,ASMPC+3 + inc de + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + ld bc,6 + add hl,bc + push hl + ld hl,2 ;const + add hl,sp + call l_glong + pop bc + call l_plong + ld hl,52 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld hl,0 ;const + add hl,sp + call l_glong2sp + ld hl,65527 ;const + ld de,0 + call l_long_uge + jp nc,i_12 + ld hl,52 ;const + add hl,sp + ld (hl),+(3 % 256 % 256) +.i_12 + ld hl,52 ;const + add hl,sp + ld a,(hl) + and a + jp nz,i_13 + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,6 ;const + ret + + +.i_13 + ld hl,55 ;const + call l_gintspsp ; + ld hl,54 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a + ld hl,55 ;const + call l_gintsp ; + ld bc,14 + add hl,bc + push hl + ld hl,49 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + ld bc,18 + add hl,bc + push hl + ld hl,57 ;const + call l_gintsp ; + ld bc,10 + add hl,bc + call l_glong2sp + ld hl,14 ;const + add hl,sp + call l_glong + call l_long_add + push de + push hl + ld hl,61 ;const + call l_gintsp ; + ld bc,4 + add hl,bc + call l_gint ; + ld de,4 + call l_asr_u_hl_by_e + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,55 ;const + call l_gintsp ; + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,55 ;const + call l_gintsp ; + ld (_FatFs),hl + ld hl,53 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; --- Start of Static Variables --- + + SECTION bss_compiler + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _FatFs + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + GLOBAL _ld_word + GLOBAL _ld_dword + GLOBAL _mem_set + GLOBAL _mem_cmp + GLOBAL _get_fat + GLOBAL _clust2sect + GLOBAL _create_name + GLOBAL _follow_path + GLOBAL _get_clust + GLOBAL _check_fs + GLOBAL _dir_rewind + GLOBAL _dir_find + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- diff --git a/software/src/PetitFS/pff_obj/pff_mount.o b/software/src/PetitFS/pff_obj/pff_mount.o new file mode 100644 index 0000000..e6f1d14 Binary files /dev/null and b/software/src/PetitFS/pff_obj/pff_mount.o differ diff --git a/software/src/PetitFS/pff_obj/pff_open.asm b/software/src/PetitFS/pff_obj/pff_open.asm new file mode 100644 index 0000000..d9ac752 --- /dev/null +++ b/software/src/PetitFS/pff_obj/pff_open.asm @@ -0,0 +1,340 @@ +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Fri Mar 13 22:51:17 2020 + + + + MODULE pff_open_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION code_compiler + +; Function pf_open flags 0x00000200 __smallc +; const int FRESULTpf_open(const char *path) +; parameter 'const char *path' at 2 size(2) +._pf_open + ld hl,65474 ;const + add hl,sp + ld sp,hl + ld hl,(_FatFs) + push hl + call l_lneg + jp nc,i_2 + ld hl,64 ;const + add hl,sp + ld sp,hl + ld hl,5 ;const + ret + + +.i_2 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,48 ;const + add hl,sp + push hl + ld hl,36 ;const + add hl,sp + call l_pint_pop + ld hl,62 ;const + add hl,sp + push hl + ld hl,48 ;const + add hl,sp + push hl + ld hl,6 ;const + add hl,sp + push hl + ld hl,72 ;const + call l_gintsp ; + push hl + call _follow_path + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,62 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_3 + ld hl,62 ;const + call l_gintsp ; + exx + ld hl,64 ;const + add hl,sp + ld sp,hl + exx + ret + + +.i_3 + ld hl,2 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_5 + ld hl,13 ;const + add hl,sp + ld a,+(16 % 256) + and (hl) + jp z,i_4 +.i_5 + ld hl,64 ;const + add hl,sp + ld sp,hl + ld hl,3 ;const + ret + + +.i_4 + pop hl + push hl + ld bc,30 + add hl,bc + push hl + ld hl,4 ;const + add hl,sp + push hl + call _get_clust + pop bc + pop bc + call l_plong + pop hl + push hl + ld bc,26 + add hl,bc + push hl + ld hl,32 ;const + add hl,sp + push hl + call _ld_dword + pop bc + pop bc + call l_plong + pop hl + push hl + ld bc,22 + add hl,bc + xor a + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + inc hl + ld (hl),a + pop hl + push hl + inc hl + ld (hl),+(1 % 256 % 256) + ld hl,64 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; --- Start of Static Variables --- + + SECTION bss_compiler + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _FatFs + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + GLOBAL _ld_word + GLOBAL _ld_dword + GLOBAL _mem_set + GLOBAL _mem_cmp + GLOBAL _get_fat + GLOBAL _clust2sect + GLOBAL _create_name + GLOBAL _follow_path + GLOBAL _get_clust + GLOBAL _check_fs + GLOBAL _dir_rewind + GLOBAL _dir_find + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- diff --git a/software/src/PetitFS/pff_obj/pff_open.o b/software/src/PetitFS/pff_obj/pff_open.o new file mode 100644 index 0000000..6abdf9f Binary files /dev/null and b/software/src/PetitFS/pff_obj/pff_open.o differ diff --git a/software/src/PetitFS/pff_obj/pff_read.asm b/software/src/PetitFS/pff_obj/pff_read.asm new file mode 100644 index 0000000..140cd51 --- /dev/null +++ b/software/src/PetitFS/pff_obj/pff_read.asm @@ -0,0 +1,615 @@ +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Fri Mar 13 22:51:17 2020 + + + + MODULE pff_read_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION code_compiler + +; Function pf_read flags 0x00000200 __smallc +; const int FRESULTpf_read(void *buff, unsigned int btr, unsigned int UINT*br) +; parameter 'unsigned int UINT*br' at 2 size(2) +; parameter 'unsigned int btr' at 4 size(2) +; parameter 'void *buff' at 6 size(2) +._pf_read + ld hl,65519 ;const + add hl,sp + ld sp,hl + ld hl,23 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + push de + ld hl,(_FatFs) + push hl + ld hl,23 ;const + add hl,sp + ld a,(hl) + inc hl + ld h,(hl) + ld l,a + xor a + ld (hl),a + inc hl + ld (hl),a + pop hl + push hl + call l_lneg + jp nc,i_2 + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,5 ;const + ret + + +.i_2 + pop hl + push hl + inc hl + ld a,(hl) + and +(1 % 256) + jp nz,i_3 + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,4 ;const + ret + + +.i_3 + ld hl,7 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,26 + add hl,bc + call l_glong2sp + ld hl,6 ;const + call l_gintsp ; + ld bc,22 + add hl,bc + call l_glong + call l_long_sub + pop bc + call l_plong + ld hl,25 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + call l_glong + exx + pop hl + ld de,0 + push de + push hl + exx + call l_long_ugt + jp nc,i_4 + ld hl,25 ;const + add hl,sp + push hl + ld hl,9 ;const + add hl,sp + call l_glong + call l_pint_pop +.i_4 +.i_5 + ld hl,25 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_6 + pop hl + push hl + ld bc,22 + add hl,bc + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_div_u + exx + ld a,d + or e + or h + or l + jp nz,i_7 + ld hl,4 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,22 + add hl,bc + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_div_u + push de + push hl + ld hl,6 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + ld h,0 + dec hl + ld de,0 + call l_long_and + pop de + ld a,l + ld (de),a + ld hl,4 ;const + add hl,sp + ld a,(hl) + and a + jp nz,i_8 + pop hl + push hl + ld bc,22 + add hl,bc + call l_glong + ld a,d + or e + or h + or l + jp nz,i_9 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,30 + add hl,bc + call l_glong + pop bc + call l_plong + jp i_10 +.i_9 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _get_fat + pop bc + pop bc + pop bc + call l_plong +.i_10 + ld hl,15 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_ule + jp nc,i_11 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_11 + pop hl + push hl + ld bc,34 + add hl,bc + push hl + ld hl,17 ;const + add hl,sp + call l_glong + pop bc + call l_plong +.i_8 + ld hl,11 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _clust2sect + pop bc + pop bc + pop bc + call l_plong + ld hl,11 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_12 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_12 + pop hl + push hl + ld bc,38 + add hl,bc + push hl + ld hl,13 ;const + add hl,sp + call l_glong2sp + ld hl,10 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + call l_long_add + pop bc + call l_plong +.i_7 + ld hl,5 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ld hl,512 + and a + sbc hl,de + call l_pint_pop + ld hl,5 ;const + call l_gintspsp ; + ld hl,27 ;const + call l_gintsp ; + pop de + and a + sbc hl,de + jp nc,i_13 + ld hl,5 ;const + add hl,sp + ex de,hl + ld hl,25 ;const + call l_gintsp ; + call l_pint +.i_13 + ld hl,19 ;const + add hl,sp + push hl + ld hl,4 ;const + call l_gintspsp ; + ld hl,4 ;const + call l_gintsp ; + ld bc,38 + add hl,bc + call l_glong2sp + ld hl,8 ;const + call l_gintsp ; + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ex de,hl + push hl + ld hl,15 ;const + call l_gintsp ; + push hl + call _disk_readp + pop bc + pop bc + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,19 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_14 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_14 + pop hl + push hl + ld bc,22 + add hl,bc + push hl + call l_glong2sp + ld hl,11 ;const + call l_gintsp ; + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,25 ;const + add hl,sp + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,7 ;const + add hl,sp + call l_gint + ex de,hl + and a + sbc hl,de + call l_pint_pop + ld hl,23 ;const + call l_gintsp ; + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,7 ;const + add hl,sp + call l_gint + add hl,de + call l_pint_pop + pop bc + pop hl + push hl + push bc + ld a,h + or l + jp z,i_15 + ld hl,2 ;const + call l_gintspsp ; + ld hl,7 ;const + call l_gintsp ; + pop de + add hl,de + pop de + pop bc + push hl + push de +.i_15 + jp i_5 +.i_6 + ld hl,21 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; --- Start of Static Variables --- + + SECTION bss_compiler + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _FatFs + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + GLOBAL _ld_word + GLOBAL _ld_dword + GLOBAL _mem_set + GLOBAL _mem_cmp + GLOBAL _get_fat + GLOBAL _clust2sect + GLOBAL _create_name + GLOBAL _follow_path + GLOBAL _get_clust + GLOBAL _check_fs + GLOBAL _dir_rewind + GLOBAL _dir_find + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- diff --git a/software/src/PetitFS/pff_obj/pff_read.o b/software/src/PetitFS/pff_obj/pff_read.o new file mode 100644 index 0000000..18cdae5 Binary files /dev/null and b/software/src/PetitFS/pff_obj/pff_read.o differ diff --git a/software/src/PetitFS/pff_obj/pff_write.asm b/software/src/PetitFS/pff_obj/pff_write.asm new file mode 100644 index 0000000..641154b --- /dev/null +++ b/software/src/PetitFS/pff_obj/pff_write.asm @@ -0,0 +1,742 @@ +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Fri Mar 13 22:51:17 2020 + + + + MODULE pff_write_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION code_compiler + +; Function pf_write flags 0x00000200 __smallc +; const int FRESULTpf_write(const void *buff, unsigned int btw, unsigned int UINT*bw) +; parameter 'unsigned int UINT*bw' at 2 size(2) +; parameter 'unsigned int btw' at 4 size(2) +; parameter 'const void *buff' at 6 size(2) +._pf_write + ld hl,65524 ;const + add hl,sp + ld sp,hl + ld hl,18 ;const + call l_gintsp ; + push hl + push bc + dec sp + ld hl,(_FatFs) + push hl + ld hl,21 ;const + add hl,sp + ld a,(hl) + inc hl + ld h,(hl) + ld l,a + xor a + ld (hl),a + inc hl + ld (hl),a + pop hl + push hl + call l_lneg + jp nc,i_2 + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,5 ;const + ret + + +.i_2 + pop hl + push hl + inc hl + ld a,(hl) + and +(1 % 256) + jp nz,i_3 + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,4 ;const + ret + + +.i_3 + ld hl,23 ;const + call l_gintsp ; + call l_lneg + jp nc,i_4 + pop hl + push hl + inc hl + ld a,+(64 % 256) + and (hl) + jp z,i_6 + ld hl,0 ;const + push hl + ld d,h + ld e,l + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jr nz,i_7_i_6 +.i_6 + jp i_5 +.i_7_i_6 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_5 + pop hl + push hl + inc hl + push hl + ld a,(hl) + and 191 + ld l,a + ld h,0 + pop de + ld a,l + ld (de),a + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + +.i_4 + pop hl + push hl + inc hl + ld a,(hl) + and +(64 % 256) + jp nz,i_9 + pop hl + push hl + ld bc,22 + add hl,bc + push hl + call l_glong2sp + ld hl,65024 ;const + ld de,65535 + call l_long_and + pop bc + call l_plong +.i_9 +.i_8 + ld hl,7 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,26 + add hl,bc + call l_glong2sp + ld hl,6 ;const + call l_gintsp ; + ld bc,22 + add hl,bc + call l_glong + call l_long_sub + pop bc + call l_plong + ld hl,23 ;const + call l_gintspsp ; + ld hl,9 ;const + add hl,sp + call l_glong + exx + pop hl + ld de,0 + push de + push hl + exx + call l_long_ugt + jp nc,i_10 + ld hl,23 ;const + add hl,sp + push hl + ld hl,9 ;const + add hl,sp + call l_glong + call l_pint_pop +.i_10 +.i_11 + ld hl,23 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_12 + pop hl + push hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ex de,hl + ld a,h + or l + jp nz,i_13 + ld hl,4 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,22 + add hl,bc + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_div_u + push de + push hl + ld hl,6 ;const + call l_gintsp ; + inc hl + inc hl + ld l,(hl) + ld h,0 + dec hl + ld de,0 + call l_long_and + pop de + ld a,l + ld (de),a + ld hl,4 ;const + add hl,sp + ld a,(hl) + and a + jp nz,i_14 + pop hl + push hl + ld bc,22 + add hl,bc + call l_glong + ld a,d + or e + or h + or l + jp nz,i_15 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,30 + add hl,bc + call l_glong + pop bc + call l_plong + jp i_16 +.i_15 + ld hl,15 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _get_fat + pop bc + pop bc + pop bc + call l_plong +.i_16 + ld hl,15 ;const + add hl,sp + call l_glong2sp + ld hl,1 ;const + ld de,0 + call l_long_ule + jp nc,i_17 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_17 + pop hl + push hl + ld bc,34 + add hl,bc + push hl + ld hl,17 ;const + add hl,sp + call l_glong + pop bc + call l_plong +.i_14 + ld hl,11 ;const + add hl,sp + pop de + push de + push hl + ex de,hl + ld bc,34 + add hl,bc + call l_glong + push de + push hl + call _clust2sect + pop bc + pop bc + pop bc + call l_plong + ld hl,11 ;const + add hl,sp + call l_glong + call l_long_lneg + jp nc,i_18 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_18 + pop hl + push hl + ld bc,38 + add hl,bc + push hl + ld hl,13 ;const + add hl,sp + call l_glong2sp + ld hl,10 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + call l_long_add + pop bc + call l_plong + pop hl + push hl + ld bc,0 + push bc + ld bc,38 + add hl,bc + call l_glong + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_19 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_19 + pop hl + push hl + inc hl + ld a,(hl) + or 64 + ld (hl),a +.i_13 + pop hl + push hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ld hl,512 + and a + sbc hl,de + pop de + pop bc + push hl + push de + ld hl,2 ;const + call l_gintspsp ; + ld hl,25 ;const + call l_gintsp ; + pop de + and a + sbc hl,de + jp nc,i_20 + ld hl,23 ;const + call l_gintsp ; + pop de + pop bc + push hl + push de +.i_20 + ld hl,5 ;const + call l_gintspsp ; + ld hl,4 ;const + call l_gintsp ; + ld de,0 + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_21 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_21 + pop hl + push hl + ld bc,22 + add hl,bc + push hl + call l_glong2sp + ld hl,8 ;const + call l_gintsp ; + ld de,0 + call l_long_add + pop bc + call l_plong + ld hl,5 ;const + add hl,sp + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,4 ;const + add hl,sp + call l_gint + add hl,de + call l_pint_pop + ld hl,23 ;const + add hl,sp + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,4 ;const + add hl,sp + call l_gint + ex de,hl + and a + sbc hl,de + call l_pint_pop + ld hl,21 ;const + call l_gintsp ; + push hl + ld e,(hl) + inc hl + ld d,(hl) + ld hl,4 ;const + add hl,sp + call l_gint + add hl,de + call l_pint_pop + pop hl + push hl + ld bc,22 + add hl,bc + call l_gint + ld de,512 + ex de,hl + call l_div_u + ex de,hl + ld a,h + or l + jp nz,i_22 + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + call _disk_writep + pop bc + pop bc + pop bc + ld a,h + or l + jp z,i_23 + pop hl + push hl + inc hl + ld (hl),+(0 % 256 % 256) + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,1 ;const + ret + + +.i_23 + pop hl + push hl + inc hl + push hl + ld a,(hl) + and 191 + ld l,a + ld h,0 + pop de + ld a,l + ld (de),a +.i_22 + jp i_11 +.i_12 + ld hl,19 ;const + add hl,sp + ld sp,hl + ld hl,0 ;const + ret + + + +; --- Start of Static Variables --- + + SECTION bss_compiler + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _FatFs + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + GLOBAL _ld_word + GLOBAL _ld_dword + GLOBAL _mem_set + GLOBAL _mem_cmp + GLOBAL _get_fat + GLOBAL _clust2sect + GLOBAL _create_name + GLOBAL _follow_path + GLOBAL _get_clust + GLOBAL _check_fs + GLOBAL _dir_rewind + GLOBAL _dir_find + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- diff --git a/software/src/PetitFS/pff_obj/pff_write.o b/software/src/PetitFS/pff_obj/pff_write.o new file mode 100644 index 0000000..d7e6cef Binary files /dev/null and b/software/src/PetitFS/pff_obj/pff_write.o differ diff --git a/software/src/PetitFS/pff_obj/sdmmc.asm b/software/src/PetitFS/pff_obj/sdmmc.asm new file mode 100644 index 0000000..e8c9f74 --- /dev/null +++ b/software/src/PetitFS/pff_obj/sdmmc.asm @@ -0,0 +1,1111 @@ +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Sun Mar 15 00:33:56 2020 + + + + MODULE sdmmc_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION data_compiler +._Stat + defb 1 + SECTION code_compiler + +; Function spi_init flags 0x00000200 __smallc +; int spi_init() +._spi_init + ; Method to initialise communications with the SD card. We basically train it to our clock characteristics. + ; This is important, as is maintaining the same clock for read or write otherwise the card may not respond. +SPI_INIT: LD B,80 +SPI_INIT1: LD A, 0x04 | 0x02 | 0x01 ; Output a 1 + OUT ( 0xFF ),A + LD A, 0x04 | 0x00 | 0x01 ; Output a 1 + OUT ( 0xFF ),A + DJNZ SPI_INIT1 + LD HL,0 ; hl is the return parameter + ret + + + +; Function spi_cs flags 0x00000200 __smallc +; int spi_cs(unsigned char b) +; parameter 'unsigned char b' at 2 size(1) +._spi_cs + ; Method to set the Chip Select level on the SD card. The Chip Select is active LOW. + ; + ; A = 0 - Set CS HIGH + ; A = 0xFF - Set CS LOW +SPI_CS: LD HL,2 + ADD HL,SP ; skip over return address on stack + LD A,(HL) ; a = b, "char b" occupies 16 bits on stack + ; but only the LSB is relevant + OR A + LD A, 0x04 | 0x00 | 0x01 ; Set CS High if parameter = 0 (ie. disable) + JR Z, SPI_CS0 + LD A, 0x04 | 0x00 | 0x00 ; Set CS Low if parameter != 0 (ie. disable) +SPI_CS0: OUT ( 0xFF ),A + LD HL,0 ; hl is the return parameter + ret + + + +; Function spi_out flags 0x00000200 __smallc +; int spi_out(unsigned char b) +; parameter 'unsigned char b' at 2 size(1) +._spi_out + ; Method to send a byte to the SD card via the SPI protocol. + ; This method uses the bitbang technique, change if hardware spi is available. + ; + ; Input A = Byte to send. + ; + LD HL,2 + ADD HL,SP ; skip over return address on stack + LD A,(HL) ; a = b, "char b" occupies 16 bits on stack + ; but only the LSB is relevant + RLCA ; 65432107 + RLCA ; 54321076 + RLCA ; 43210765 - Adjust so that starting bit is same position as Data line. + LD E,A ; E = Character to send. + LD B,8 ; B = Bit count +SPI_OUT0: LD A,E + AND 0x04 ; Data bit to data line, clock and cs low. + RLC E +SPI_OUT1: OUT ( 0xFF ),A + OR 0x02 ; Clock high + OUT ( 0xFF ),A + AND 0xFD ; Clock low + OUT ( 0xFF ),A + DJNZ SPI_OUT0 ; Perform actions for the full 8 bits. + LD HL,0 ; hl is the return parameter + ret + + + +; Function spi_in flags 0x00000200 __smallc +; unsigned char uint8_tspi_in() +._spi_in + ; Method to receive a byte from the SD card via the SPI protocol. + ; This method uses the bitbang technique, change if hardware spi is available. + ; NB. Timing must be very similar in SPIOUT and SPIIN. + ; + ; Output: A = received byte. + ; + LD BC,$800 | 0xFF ; B = Bit count, C = clock port + LD L,0 ; L = Character being read. + LD D, 0x04 | 0x00 | 0x00 ; Output a 0 + OUT (C),D ; To start ensure clock is low and CS is low. + LD E, 0x04 | 0x02 | 0x00 ; Output a 0 +SPI_IN1: OUT (C),E ; Clock to high. + IN A,( 0xFE ) ; Input the received bit + OUT (C),D ; Clock to low. + SRL A + RL L + DJNZ SPI_IN1 ; Perform actions for the full 8 bits. + LD H,0 ; hl is the return parameter, L already set to received byte. + ret + + + +; Function spi_skip flags 0x00000200 __smallc +; void spi_skip(unsigned int n) +; parameter 'unsigned int n' at 2 size(2) +._spi_skip + LD HL,2 + ADD HL,SP ; skip over return address on stack + LD C,(HL) ; n occupies 16 bits on stack + INC HL + LD B,(HL) +SPISKIP0: PUSH BC + CALL SPIIN + POP BC + DEC BC + LD A,B + OR C + JR NZ,SPISKIP0 + ret + + + +; Function send_cmd flags 0x00000200 __smallc +; unsigned char BYTEsend_cmd(unsigned char cmd, unsigned long arg) +; parameter 'unsigned long arg' at 2 size(4) +; parameter 'unsigned char cmd' at 6 size(1) +._send_cmd + ; Method to send a command to the card and receive back a response. + ; + ; A = CMD to send + ; LHED = Argument, ie. CMD = A, L, H, E, D, CRC + ; + LD HL,2 + ADD HL,SP ; skip over return address on stack + LD A,(HL) + LD (_SDBUF+4),A + INC HL + LD A,(HL) + LD (_SDBUF+3),A + INC HL + LD A,(HL) + LD (_SDBUF+2),A + INC HL + LD A,(HL) + LD (_SDBUF+1),A + INC HL + LD A,(HL) + LD (_SDBUF),A + ; + LD B,5 ; R1 + 32bit argument for (8) , (58) + CP (8) + LD C,135 + JP Z,SD_CMD0 + LD C,1 ; (58) is not CRC checked so just set to 0x01. + CP (58) + LD B,5 ; R1 + 32bit argument + JP Z,SD_CMD0 + ; + LD B,1 ; Default, expect R1 which is 1 byte. + CP (0) ; Work out the CRC based on the command. CRC checking is + LD C,149 ; not implemented but certain commands require a fixed argument and CRC. + JP Z,SD_CMD0 + LD C,1 ; Remaining commands are not CRC checked so just set to 0x01. +SD_CMD0: PUSH BC ; Save the CRC and the number of bytes to be returned, + LD A,C ; Store the CRC + LD (_SDBUF+5),A + LD A,255 ; Preamble byte + CALL SPIOUT + LD HL,_SDBUF + LD B,6 +SD_CMD1: PUSH BC + LD A,(HL) + INC HL + CALL SPIOUT ; Send the command and parameters. + POP BC + DJNZ SD_CMD1 + PUSH HL +SD_CMD2: CALL SPIIN + CP $FF + JR Z,SD_CMD2 + JR SD_CMD4 +SD_CMD3: PUSH BC + PUSH HL + CALL SPIIN ; +SD_CMD4: POP HL + LD (HL),A + INC HL + POP BC ; Get back number of expected bytes. HL = place in buffer to store response. + DJNZ SD_CMD3 + LD A, 0x04 | 0x00 | 0x01 + OUT ( 0xFF ),A + LD A,(_SDBUF+6) + LD L,A + LD H,0 + ret + + + +; Function disk_initialize flags 0x00000200 __smallc +; unsigned char DSTATUSdisk_initialize() +._disk_initialize + ; Method to initialise the SD card. + ; +SDINIT: LD A,$00 ; CS to high + CALL SPICS + ; + CALL SPIINIT ; Train SD with our clock. + ; + LD A,$FF ; CS to low + CALL SPICS + LD BC,$FFFF +SDINIT1: LD A, (0) ; Command 0 + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + PUSH BC + LD A,(_SDBUF+6) ; Get response code. + DEC A ; Set Z flag to test if response is 0x01 + JP Z,SDINIT2 ; Command response 0x01? Exit if match. + POP BC + DEC BC + LD A,B + OR C + JR NZ,SDINIT1 ; Retry for BC times. + LD A,1 + JP SD_EXIT ; Error, card is not responding to (0) +SDINIT2: POP BC + ; Now send (8) to get card details. This command can only be sent + ; when the card is idle. + LD A, (8) ; (8) has 0x00001AA as parameter, load up registers and call command routine. + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$AA01 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + ; Version 2 card, check its voltage range. IF not in the 2.7-3.6V dont try the (0x80+41) to get capabilities. +SDINIT3: LD A,1 ; Check that we receive 0x0001AA in response. + LD (_SDVER),A ; Indicate this is not a version 2 card. + LD A,(_SDBUF+9) + CP 1 + JP NZ,SDINIT8 + LD A,(_SDBUF+10) + CP $AA + JP NZ,SDINIT8 +SDINIT4: LD A,2 ; This is a version 2 card. +SDINIT5: LD (_SDVER),A ; Indicate this is not a version 2 card. + CALL SDACMD41 + JR Z,SDINIT6 + LD A,2 ; Error, card is not responding to (0x80+41) + JP SD_EXIT +SDINIT6: LD A, (58) ; (58) has 0x00000000 as parameter, load up registers and call command routine. + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(_SDBUF+6) + CP $40 + LD A, 0x04 + JR Z,SDINIT7 + LD A, 0x04 | 0x08 +SDINIT7: LD (_SDCAP),A ; Set the capabilities according to the returned flag. + JR SDINIT14 + ; Version 1 card or MMC v3. +SDINIT8: CALL SDACMD41 + LD A, 0x02 + LD E, (0x80+41) ; SD1 cards we use the (0x80+41) command. + JR Z,SDINIT9 + LD A, 0x01 + LD E, (1) ; MMC cards we use the (1) command. +SDINIT9: LD (_SDCAP),A + LD A,E + CP (0x80+41) + JR NZ,SDINIT10 + CALL SDACMD41 + JR Z,SDINIT14 + LD A,3 ; Exit code, failed to initialise v1 card. + JP SD_EXIT +SDINIT10: LD BC,10 ; (0x80+41) / (55) may take some cards time to process or respond, so give a large number of retries. +SDINIT11: PUSH BC + LD A, (1) ; (1) has 0x00000000 as parameter, load up registers and call command routine. + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + OR A + JR Z,SDINIT13 + LD BC,$FFFF ; Delay for at least 200mS for the card to recover and be ready. +SDINIT12: DEC BC ; 6T + LD A,B ; 9T + OR C ; 4T + JR NZ,SDINIT12 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS + ; + POP BC + DEC BC + LD A,B + OR C + JR NZ,SDINIT11 + LD A,4 ; Exit code, failed to initialise v1 MMC card. + JP SD_EXIT +SDINIT13: LD A, (16) ; No response from the card for an (0x80+41) / (1) so try (16) with parameter 0x00000200 + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0002 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(_SDBUF+6) + OR A + JR Z,SDINIT14 + LD A,0 + LD (_SDCAP),A ; No capabilities on this unknown card. +SDINIT14: LD A,0 + JR SD_EXIT +SD_EXIT: LD L,A ; Return value goes into HL. + LD H,0 + RET + ; Method to initialise communications with the SD card. We basically train it to our clock characteristics. + ; This is important, as is maintaining the same clock for read or write otherwise the card may not respond. +SPIINIT: LD B,80 +SPIINIT1: LD A, 0x04 | 0x02 | 0x01 ; Output a 1 + OUT ( 0xFF ),A + LD A, 0x04 | 0x00 | 0x01 ; Output a 1 + OUT ( 0xFF ),A + DJNZ SPIINIT1 + RET + ; Method to set the Chip Select level on the SD card. The Chip Select is active LOW. + ; + ; A = 0 - Set CS HIGH + ; A = 0xFF - Set CS LOW +SPICS: OR A + LD A, 0x04 | 0x00 | 0x01 ; Set CS High if parameter = 0 (ie. disable) + JR Z, SPICS0 + LD A, 0x04 | 0x00 | 0x00 ; Set CS Low if parameter != 0 (ie. disable) +SPICS0: OUT ( 0xFF ),A + RET + ; Method to send a command to the card and receive back a response. + ; + ; A = CMD to send + ; LHED = Argument, ie. CMD = A, L, H, E, D, CRC + ; +SDCMD: LD (_SDBUF),A + LD (_SDBUF+1),HL + EX DE,HL + LD (_SDBUF+3),HL + ; + LD B,5 ; R1 + 32bit argument for (8) , (58) + CP (8) + LD C,135 + JP Z,SDCMD0 + LD C,1 ; (58) is not CRC checked so just set to 0x01. + CP (58) + LD B,5 ; R1 + 32bit argument + JP Z,SDCMD0 + ; + LD B,1 ; Default, expect R1 which is 1 byte. + CP (0) ; Work out the CRC based on the command. CRC checking is + LD C,149 ; not implemented but certain commands require a fixed argument and CRC. + JP Z,SDCMD0 + LD C,1 ; Remaining commands are not CRC checked so just set to 0x01. +SDCMD0: PUSH BC ; Save the CRC and the number of bytes to be returned, + LD A,C ; Store the CRC + LD (_SDBUF+5),A + LD A,255 ; Preamble byte + CALL SPIOUT + LD HL,_SDBUF + LD B,6 +SDCMD1: PUSH BC + LD A,(HL) + INC HL + CALL SPIOUT ; Send the command and parameters. + POP BC + DJNZ SDCMD1 + PUSH HL +SDCMD2: CALL SPIIN + CP $FF + JR Z,SDCMD2 + JR SDCMD4 +SDCMD3: PUSH BC + PUSH HL + CALL SPIIN ; +SDCMD4: POP HL + LD (HL),A + INC HL + POP BC ; Get back number of expected bytes. HL = place in buffer to store response. + DJNZ SDCMD3 + LD A, 0x04 | 0x00 | 0x01 + OUT ( 0xFF ),A + RET + ; Method to send an Application Command to the SD Card. This involves sending (55) followed by the required command. + ; + ; A = ACMD to send + ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC + ; +SDACMD: PUSH AF + PUSH DE + PUSH HL + LD A, (55) ; (55) has 0x00000000 as parameter, load up registers and call command routine. + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + DEC A + JR NZ,SDACMD + POP HL + POP DE + POP AF + CALL SDCMD + LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + OR A + RET + ; Method to send Application Command 41 to the SD card. This command involves retries and delays + ; hence coded seperately. + ; + ; Returns Z set if successful, else NZ. + ; +SDACMD41: LD BC,10 ; (0x80+41) / (55) may take some cards time to process or respond, so give a large number of retries. +SDACMD1: PUSH BC + LD A, (0x80+41) ; (0x80+41) has 0x40000000 as parameter, load up registers and call command routine. + LD HL,$0040 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDACMD + LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + OR A + JR Z,SDACMD3 + LD BC,12903 ; Delay for at least 200mS for the card to recover and be ready. +SDACMD2: DEC BC ; 6T + LD A,B ; 9T + OR C ; 4T + JR NZ,SDACMD2 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS + ; + POP BC + DEC BC + LD A,B + OR C + JR NZ,SDACMD1 + LD A,1 +SDACMD3: OR A + RET + ; Method to send a byte to the SD card via the SPI protocol. + ; This method uses the bitbang technique, change if hardware spi is available. + ; + ; Input A = Byte to send. + ; +SPIOUT: RLCA ; 65432107 + RLCA ; 54321076 + RLCA ; 43210765 - Adjust so that starting bit is same position as Data line. + LD E,A ; E = Character to send. + LD B,8 ; B = Bit count +SPIOUT0: LD A,E + AND 0x04 ; Data bit to data line, clock and cs low. + RLC E +SPIOUT1: OUT ( 0xFF ),A + OR 0x02 ; Clock high + OUT ( 0xFF ),A + AND 0xFD ; Clock low + OUT ( 0xFF ),A + DJNZ SPIOUT0 ; Perform actions for the full 8 bits. + RET + ; Method to receive a byte from the SD card via the SPI protocol. + ; This method uses the bitbang technique, change if hardware spi is available. + ; NB. Timing must be very similar in SPIOUT and SPIIN. + ; + ; Output: A = received byte. + ; +SPIIN: LD BC,$800 | 0xFF ; B = Bit count, C = clock port + LD L,0 ; L = Character being read. + LD D, 0x04 | 0x00 | 0x00 ; Output a 0 + OUT (C),D ; To start ensure clock is low and CS is low. + LD E, 0x04 | 0x02 | 0x00 ; Output a 0 +SPIIN1: OUT (C),E ; Clock to high. + IN A,( 0xFE ) ; Input the received bit + OUT (C),D ; Clock to low. + SRL A + RL L + DJNZ SPIIN1 ; Perform actions for the full 8 bits. + LD A,L ; return value + RET + ret + + + +; Function disk_readp flags 0x00000200 __smallc +; const int DRESULTdisk_readp(unsigned char BYTE*buff, unsigned long sector, unsigned int offset, unsigned int count) +; parameter 'unsigned int count' at 2 size(2) +; parameter 'unsigned int offset' at 4 size(2) +; parameter 'unsigned long sector' at 6 size(4) +; parameter 'unsigned char BYTE*buff' at 10 size(2) +._disk_readp + push bc + push bc + push bc + dec sp + ld hl,0 ;const + push hl + call _spi_cs + pop bc + ld hl,(_SDCAP) + ld h,0 + ld a,+(8 % 256) + and l + ld l,a + call l_lneg + jp nc,i_3 + ld hl,13 ;const + add hl,sp + push hl + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_mult + pop bc + call l_plong +.i_3 + ld hl,5 ;const + add hl,sp + ld (hl),+(1 % 256) + inc hl + ld (hl),+(1 / 256) + ld hl,17 ;const + push hl + ld hl,15 ;const + call l_glongsp ; + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + and a + jp nz,i_4 + ld hl,1000 ;const + pop bc + push hl +.i_7 + ld hl,200 ;const + call t_delay + ld hl,4 ;const + add hl,sp + push hl + call _spi_in + pop de + ld a,l + ld (de),a +.i_5 + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 255 + jp nz,i_8 + pop hl + dec hl + push hl + ld a,h + or l + jr nz,i_9_i_8 +.i_8 + jp i_6 +.i_9_i_8 + jp i_7 +.i_6 + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 254 + jp nz,i_10 + ld hl,11 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,514 + and a + sbc hl,de + ex de,hl + ld hl,9 ;const + call l_gintsp ; + ex de,hl + and a + sbc hl,de + pop de + pop bc + push hl + push de + ld hl,11 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_11 + ld hl,11 ;const + call l_gintsp ; + push hl + call _spi_skip + pop bc +.i_11 + ld hl,17 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_12 +.i_15 + ld hl,4 ;const + add hl,sp + push hl + call _spi_in + pop de + ld a,l + ld (de),a + ld hl,17 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + push hl + ld hl,6 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a +.i_13 + ld hl,9 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + ld a,h + or l + jp nz,i_15 +.i_14 + jp i_16 +.i_12 +.i_19 + ld hl,4 ;const + add hl,sp + push hl + call _spi_in + pop de + ld a,l + ld (de),a +.i_17 + ld hl,9 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + ld a,h + or l + jp nz,i_19 +.i_18 +.i_16 + pop bc + pop hl + push hl + push bc + push hl + call _spi_skip + pop bc + ld hl,5 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint +.i_10 +.i_4 + ld hl,255 ;const + push hl + call _spi_cs + pop bc + ld hl,5 ;const + call l_gintsp ; + inc sp + pop bc + pop bc + pop bc + ret + + + +; Function disk_writep flags 0x00000200 __smallc +; const int DRESULTdisk_writep(const unsigned char BYTE*buff, unsigned long sc) +; parameter 'unsigned long sc' at 2 size(4) +; parameter 'const unsigned char BYTE*buff' at 6 size(2) +._disk_writep + push bc + push bc + push bc + ld hl,4 ;const + add hl,sp + ld (hl),+(1 % 256) + inc hl + ld (hl),+(1 / 256) + ld hl,0 ;const + push hl + call _spi_cs + pop bc + ld hl,12 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_20 + ld hl,8 ;const + add hl,sp + call l_glong + pop de + pop bc + push hl + push de +.i_21 + pop bc + pop hl + push hl + push bc + ld a,h + or l + jp z,i_23 + ld hl,(_st_disk_writep_wc) + ld a,h + or l + jr nz,i_24_i_23 +.i_23 + jp i_22 +.i_24_i_23 + ld hl,12 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + ld l,(hl) + ld h,0 + push hl + call _spi_out + pop bc + ld hl,(_st_disk_writep_wc) + dec hl + ld (_st_disk_writep_wc),hl + pop de + pop hl + dec hl + push hl + push de + inc hl + jp i_21 +.i_22 + ld hl,4 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint + jp i_25 +.i_20 + ld hl,8 ;const + add hl,sp + call l_glong + ld a,h + or l + or d + or e + jp z,i_26 + ld hl,(_SDCAP) + ld h,0 + ld a,+(8 % 256) + and l + ld l,a + call l_lneg + jp nc,i_27 + ld hl,8 ;const + add hl,sp + push hl + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_mult + pop bc + call l_plong +.i_27 + ld hl,24 ;const + push hl + ld hl,10 ;const + call l_glongsp ; + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + and a + jp nz,i_28 + ld hl,255 ;const + push hl + call _spi_out + pop bc + ld hl,254 ;const + push hl + call _spi_out + pop bc + ld hl,512 ;const + ld (_st_disk_writep_wc),hl + ld hl,4 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint +.i_28 + jp i_29 +.i_26 + ld hl,(_st_disk_writep_wc) + inc hl + inc hl + pop de + pop bc + push hl + push de +.i_30 + pop de + pop hl + dec hl + push hl + push de + inc hl + ld a,h + or l + jp z,i_31 + ld hl,0 ;const + push hl + call _spi_out + pop bc + jp i_30 +.i_31 + call _spi_in + ld a,l + and +(31 % 256) + ld l,a + ld h,0 + cp 5 + jp nz,i_32 + ld hl,10000 ;const + pop bc + push hl + jp i_35 +.i_33 + pop hl + dec hl + push hl + inc hl +.i_35 + call _spi_in + ld a,l + cp 255 + jp z,i_36 + pop hl + push hl + ld a,h + or l + jr nz,i_37_i_36 +.i_36 + jp i_34 +.i_37_i_36 + ld hl,200 ;const + call t_delay + jp i_33 +.i_34 + pop hl + push hl + ld a,h + or l + jp z,i_38 + ld hl,4 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint +.i_38 +.i_32 + ld hl,255 ;const + push hl + call _spi_cs + pop bc +.i_29 +.i_25 + ld hl,4 ;const + call l_gintsp ; + pop bc + pop bc + pop bc + ret + + + +; --- Start of Static Variables --- + + SECTION bss_compiler +._SDBUF defs 11 +._SDVER defs 1 +._SDCAP defs 1 +._st_disk_writep_wc defs 2 + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _FatFs + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + GLOBAL _SDBUF + GLOBAL _SDVER + GLOBAL _SDCAP + GLOBAL _spi_init + GLOBAL _spi_cs + GLOBAL _spi_out + GLOBAL _spi_in + GLOBAL _spi_skip + GLOBAL _send_cmd + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- diff --git a/software/src/PetitFS/pff_obj/sdmmc.o b/software/src/PetitFS/pff_obj/sdmmc.o new file mode 100644 index 0000000..5f32a95 Binary files /dev/null and b/software/src/PetitFS/pff_obj/sdmmc.o differ diff --git a/software/src/PetitFS/pff_obj/sdtest.asm b/software/src/PetitFS/pff_obj/sdtest.asm new file mode 100644 index 0000000..f2d2375 --- /dev/null +++ b/software/src/PetitFS/pff_obj/sdtest.asm @@ -0,0 +1,857 @@ +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Fri Mar 13 22:51:18 2020 + + + + MODULE sdtest_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION code_compiler + +; Function die flags 0x00000200 __smallc +; void die(const int rc) +; parameter 'const int rc' at 2 size(2) +._die + ld hl,i_1+0 + push hl + ld hl,4 ;const + call l_gintsp ; + push hl + ld a,2 + call printf + pop bc + pop bc + ld hl,i_1+20 + push hl + ld a,1 + call printf + pop bc + ld hl,10 ;const + call sleep + ret + + + +; Function main flags 0x00000000 __stdc +; int main() +._main + ld hl,65381 ;const + add hl,sp + ld sp,hl + ld hl,i_1+41 + push hl + ld a,1 + call printf + pop bc + ld hl,i_1+86 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + ld de,5 ;const + ex de,hl + call l_pint + call _disk_initialize + call l_lneg + jp nc,i_2 + ld hl,i_1+115 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,115 ;const + add hl,sp + push hl + call _pf_mount + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_3 + ld hl,i_1+137 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_3 + ld hl,i_1+192 + push hl + ld a,1 + call printf + pop bc +.i_2 + ld hl,i_1+209 + push hl + ld hl,115 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,118 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,121 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,124 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,129 ;const + add hl,sp + call l_glong2sp + ld hl,137 ;const + call l_glongsp ; + ld a,9 + call printf + ld hl,18 ;const + add hl,sp + ld sp,hl + ld hl,i_1+275 + push hl + ld hl,129 ;const + add hl,sp + call l_glong2sp + ld hl,137 ;const + add hl,sp + call l_glong2sp + ld hl,145 ;const + add hl,sp + call l_glong2sp + ld hl,153 ;const + add hl,sp + call l_glong2sp + ld hl,161 ;const + add hl,sp + call l_glong2sp + ld hl,169 ;const + add hl,sp + call l_glong2sp + ld hl,177 ;const + call l_glongsp ; + ld a,15 + call printf + ld hl,30 ;const + add hl,sp + ld sp,hl + ld hl,10 ;const + call sleep + ld hl,i_1+365 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,99 ;const + add hl,sp + push hl + ld hl,i_1+19 + push hl + call _pf_opendir + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_4 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_4 + ld hl,i_1+388 + push hl + ld a,1 + call printf + pop bc +.i_5 +.i_7 + ld hl,3 ;const + add hl,sp + push hl + ld hl,99 ;const + add hl,sp + push hl + ld hl,79 ;const + add hl,sp + push hl + call _pf_readdir + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_9 + ld hl,75 ;const + call l_gcharsp ; + call l_lneg + jr nc,i_8 +.i_9 + jp i_6 +.i_8 + ld hl,83 ;const + add hl,sp + ld a,+(16 % 256) + and (hl) + jp z,i_11 + ld hl,i_1+411 + push hl + ld hl,86 ;const + add hl,sp + push hl + ld a,2 + call printf + pop bc + pop bc + jp i_12 +.i_11 + ld hl,i_1+425 + push hl + ld hl,77 ;const + add hl,sp + call l_glong2sp + ld hl,90 ;const + add hl,sp + push hl + ld a,4 + call printf + pop bc + pop bc + pop bc + pop bc +.i_12 + jp i_5 +.i_6 + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_13 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_13 + ld hl,i_1+435 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,i_1+469 + push hl + call _pf_open + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_14 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_14 + ld hl,i_1+481 + push hl + ld a,1 + call printf + pop bc +.i_15 + ld hl,3 ;const + add hl,sp + push hl + ld hl,7 ;const + add hl,sp + push hl + ld hl,64 ;const + push hl + ld hl,77 ;const + add hl,sp + push hl + call _pf_read + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_18 + ld hl,71 ;const + call l_gintsp ; + call l_lneg + jr nc,i_17 +.i_18 + jp i_16 +.i_17 + ld hl,69 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint + jp i_22 +.i_20 + ld hl,69 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) +.i_22 + ld hl,69 ;const + call l_gintspsp ; + ld hl,73 ;const + call l_gintsp ; + pop de + ex de,hl + and a + sbc hl,de + jp nc,i_21 + ld hl,5 ;const + add hl,sp + ex de,hl + ld hl,69 ;const + call l_gintsp ; + add hl,de + ld a,(hl) + cp 13 + jp z,i_23 + ld hl,5 ;const + add hl,sp + ex de,hl + ld hl,69 ;const + call l_gintsp ; + add hl,de + ld l,(hl) + ld h,0 + push hl + ld hl,__sgoioblk+10 + push hl + call fputc_callee +.i_23 + jp i_20 +.i_21 + jp i_15 +.i_16 + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_24 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_24 + ld hl,20 ;const + call sleep + ld hl,i_1+506 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,i_1+543 + push hl + call _pf_open + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_25 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_25 + ld hl,i_1+554 + push hl + ld a,1 + call printf + pop bc +.i_26 +.i_28 + ld hl,3 ;const + add hl,sp + push hl + ld hl,i_1+590 + push hl + ld hl,14 ;const + push hl + ld hl,79 ;const + add hl,sp + push hl + call _pf_write + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_30 + ld hl,73 ;const + call l_gintsp ; + call l_lneg + jr nc,i_29 +.i_30 + jp i_27 +.i_29 + jp i_26 +.i_27 + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_32 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_32 + ld hl,i_1+605 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,0 ;const + push hl + push hl + ld hl,79 ;const + add hl,sp + push hl + call _pf_write + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_33 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_33 + ld hl,i_1+641 + push hl + ld a,1 + call printf + pop bc +.i_34 +.i_36 + jp i_34 +.i_35 + ld hl,155 ;const + add hl,sp + ld sp,hl + ret + + + SECTION rodata_compiler +.i_1 + defm "Failed with rc=%u." + defb 10 + + defm "" + defb 0 + + defm "Please press reset." + defb 10 + + defm "" + defb 0 + + defm "Hello Philip, this C program i" + defm "s working...." + defb 10 + + defm "" + defb 0 + + defm "Firstly, initialise SD card" + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Now Mount a volume." + defb 10 + + defm "" + defb 0 + + defm "Failed to initialise sd card 0" + defm ", please init manually." + defb 10 + + defm "" + defb 0 + + defm "Volume mounted." + defb 10 + + defm "" + defb 0 + + defm "FSTYPE:%d, FLAG:%d, CSIZE:%d, " + defm "PADL:%d, N_FATENT:%ld, FATBASE" + defm ":%;d" + defb 10 + + defm "" + defb 0 + + defm "DIRBASE:%ld, DATABASE:%ld, FPT" + defm "R:%ld, FSIZE:%ld, ORG_CLUST:%l" + defm "d, CURR_CLUST:%ld, DSECT:%ld" + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Open root directory." + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Directory listing..." + defb 10 + + defm "" + defb 0 + + defm " %s" + defb 10 + + defm "" + defb 0 + + defm "%8lu %s" + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Open a test file (message.txt)" + defm "." + defb 10 + + defm "" + defb 0 + + defm "MESSAGE.TXT" + defb 0 + + defm "" + defb 10 + + defm "Type the file content." + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Open a file to write (readme.t" + defm "xt)." + defb 10 + + defm "" + defb 0 + + defm "README.TXT" + defb 0 + + defm "" + defb 10 + + defm "Write a text data. (Hello worl" + defm "d!)" + defb 10 + + defm "" + defb 0 + + defm "Hello world!" + defb 13 + + defm "" + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Terminate the file write proce" + defm "ss." + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Test completed." + defb 10 + + defm "" + defb 0 + + +; --- Start of Static Variables --- + + SECTION bss_compiler +._FatFs defs 2 + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _FatFs + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + GLOBAL _die + GLOBAL _main + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- diff --git a/software/src/PetitFS/pff_obj/sdtest.o b/software/src/PetitFS/pff_obj/sdtest.o new file mode 100644 index 0000000..8ebb17d Binary files /dev/null and b/software/src/PetitFS/pff_obj/sdtest.o differ diff --git a/software/src/PetitFS/pff_open.c b/software/src/PetitFS/pff_open.c new file mode 100644 index 0000000..3f389f3 --- /dev/null +++ b/software/src/PetitFS/pff_open.c @@ -0,0 +1,78 @@ +/*----------------------------------------------------------------------------/ +/ Petit FatFs - FAT file system module R0.03a +/-----------------------------------------------------------------------------/ +/ +/ Copyright (C) 2019, ChaN, all right reserved. +/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 +/ +/ Petit FatFs module is an open source software. Redistribution and use of +/ Petit FatFs in source and binary forms, with or without modification, are +/ permitted provided that the following condition is met: +/ +/ 1. Redistributions of source code must retain the above copyright notice, +/ this condition and the following disclaimer. +/ +/ This software is provided by the copyright holder and contributors "AS IS" +/ and any warranties related to this software are DISCLAIMED. +/ The copyright owner or contributors be NOT LIABLE for any damages caused +/ by use of this software. +/-----------------------------------------------------------------------------/ +/ Jun 15,'09 R0.01a First release. +/ +/ Dec 14,'09 R0.02 Added multiple code page support. +/ Added write funciton. +/ Changed stream read mode interface. +/ Dec 07,'10 R0.02a Added some configuration options. +/ Fixed fails to open objects with DBCS character. + +/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. +/ Added _USE_LCC option. +/ Added _FS_FAT16 option. +/ +/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. +/ Removed _WORD_ACCESS option. +/ Changed prefix of configuration options, _ to PF_. +/ Added some code pages. +/ Removed some code pages actually not valid. +/ +/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in +/ banked ROMS as part of the RFS on the Sharp MZ80A. +/----------------------------------------------------------------------------*/ + +#include +#include +#include "pff.h" /* Petit FatFs configurations and declarations */ +#include "sdmmc.h" /* Declarations of low level disk I/O functions */ +#include "pff_func.h" +#define PFF_OPEN_C + + +/*-----------------------------------------------------------------------*/ +/* Open or Create a File */ +/*-----------------------------------------------------------------------*/ + +FRESULT pf_open ( + const char *path /* Pointer to the file name */ +) +{ + FRESULT res; + DIR dj; + BYTE sp[12], dir[32]; + FATFS *fs = FatFs; + + + if (!fs) return FR_NOT_ENABLED; /* Check file system */ + + fs->flag = 0; + dj.fn = sp; + res = follow_path(&dj, dir, path); /* Follow the file path */ + if (res != FR_OK) return res; /* Follow failed */ + if (!dir[0] || (dir[DIR_Attr] & AM_DIR)) return FR_NO_FILE; /* It is a directory */ + + fs->org_clust = get_clust(dir); /* File start cluster */ + fs->fsize = ld_dword(dir+DIR_FileSize); /* File size */ + fs->fptr = 0; /* File pointer */ + fs->flag = FA_OPENED; + + return FR_OK; +} diff --git a/software/src/PetitFS/pff_read.c b/software/src/PetitFS/pff_read.c new file mode 100644 index 0000000..c8f8c81 --- /dev/null +++ b/software/src/PetitFS/pff_read.c @@ -0,0 +1,99 @@ +/*----------------------------------------------------------------------------/ +/ Petit FatFs - FAT file system module R0.03a +/-----------------------------------------------------------------------------/ +/ +/ Copyright (C) 2019, ChaN, all right reserved. +/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 +/ +/ Petit FatFs module is an open source software. Redistribution and use of +/ Petit FatFs in source and binary forms, with or without modification, are +/ permitted provided that the following condition is met: +/ +/ 1. Redistributions of source code must retain the above copyright notice, +/ this condition and the following disclaimer. +/ +/ This software is provided by the copyright holder and contributors "AS IS" +/ and any warranties related to this software are DISCLAIMED. +/ The copyright owner or contributors be NOT LIABLE for any damages caused +/ by use of this software. +/-----------------------------------------------------------------------------/ +/ Jun 15,'09 R0.01a First release. +/ +/ Dec 14,'09 R0.02 Added multiple code page support. +/ Added write funciton. +/ Changed stream read mode interface. +/ Dec 07,'10 R0.02a Added some configuration options. +/ Fixed fails to open objects with DBCS character. + +/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. +/ Added _USE_LCC option. +/ Added _FS_FAT16 option. +/ +/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. +/ Removed _WORD_ACCESS option. +/ Changed prefix of configuration options, _ to PF_. +/ Added some code pages. +/ Removed some code pages actually not valid. +/ +/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in +/ banked ROMS as part of the RFS on the Sharp MZ80A. +/----------------------------------------------------------------------------*/ + +#include +#include +#include "pff.h" /* Petit FatFs configurations and declarations */ +#include "sdmmc.h" /* Declarations of low level disk I/O functions */ +#include "pff_func.h" +#define PFF_READ_C + +/*-----------------------------------------------------------------------*/ +/* Read File */ +/*-----------------------------------------------------------------------*/ +FRESULT pf_read ( + void* buff, /* Pointer to the read buffer (NULL:Forward data to the stream)*/ + UINT btr, /* Number of bytes to read */ + UINT* br /* Pointer to number of bytes read */ +) +{ + DRESULT dr; + CLUST clst; + DWORD sect, remain; + UINT rcnt; + BYTE cs, *rbuff = buff; + FATFS *fs = FatFs; + + + *br = 0; + if (!fs) return FR_NOT_ENABLED; /* Check file system */ + if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ + + remain = fs->fsize - fs->fptr; + if (btr > remain) btr = (UINT)remain; /* Truncate btr by remaining bytes */ + + while (btr) { /* Repeat until all data transferred */ + if ((fs->fptr % 512) == 0) { /* On the sector boundary? */ + cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ + if (!cs) { /* On the cluster boundary? */ + if (fs->fptr == 0) { /* On the top of the file? */ + clst = fs->org_clust; + } else { + clst = get_fat(fs->curr_clust); + } + if (clst <= 1) ABORT(FR_DISK_ERR); + fs->curr_clust = clst; /* Update current cluster */ + } + sect = clust2sect(fs->curr_clust); /* Get current sector */ + if (!sect) ABORT(FR_DISK_ERR); + fs->dsect = sect + cs; + } + rcnt = 512 - (UINT)fs->fptr % 512; /* Get partial sector data from sector buffer */ + if (rcnt > btr) rcnt = btr; + dr = disk_readp(rbuff, fs->dsect, (UINT)fs->fptr % 512, rcnt); + if (dr) ABORT(FR_DISK_ERR); + fs->fptr += rcnt; /* Advances file read pointer */ + btr -= rcnt; *br += rcnt; /* Update read counter */ + if (rbuff) rbuff += rcnt; /* Advances the data pointer if destination is memory */ + } + + return FR_OK; +} diff --git a/software/src/PetitFS/pff_seek.c b/software/src/PetitFS/pff_seek.c new file mode 100644 index 0000000..2500807 --- /dev/null +++ b/software/src/PetitFS/pff_seek.c @@ -0,0 +1,90 @@ +/*----------------------------------------------------------------------------/ +/ Petit FatFs - FAT file system module R0.03a +/-----------------------------------------------------------------------------/ +/ +/ Copyright (C) 2019, ChaN, all right reserved. +/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 +/ +/ Petit FatFs module is an open source software. Redistribution and use of +/ Petit FatFs in source and binary forms, with or without modification, are +/ permitted provided that the following condition is met: +/ +/ 1. Redistributions of source code must retain the above copyright notice, +/ this condition and the following disclaimer. +/ +/ This software is provided by the copyright holder and contributors "AS IS" +/ and any warranties related to this software are DISCLAIMED. +/ The copyright owner or contributors be NOT LIABLE for any damages caused +/ by use of this software. +/-----------------------------------------------------------------------------/ +/ Jun 15,'09 R0.01a First release. +/ +/ Dec 14,'09 R0.02 Added multiple code page support. +/ Added write funciton. +/ Changed stream read mode interface. +/ Dec 07,'10 R0.02a Added some configuration options. +/ Fixed fails to open objects with DBCS character. + +/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. +/ Added _USE_LCC option. +/ Added _FS_FAT16 option. +/ +/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. +/ Removed _WORD_ACCESS option. +/ Changed prefix of configuration options, _ to PF_. +/ Added some code pages. +/ Removed some code pages actually not valid. +/ +/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in +/ banked ROMS as part of the RFS on the Sharp MZ80A. +/----------------------------------------------------------------------------*/ + +#include +#include +#include "pff.h" /* Petit FatFs configurations and declarations */ +#include "sdmmc.h" /* Declarations of low level disk I/O functions */ +#include "pff_func.h" +#define PFF_SEEK_C + +/*-----------------------------------------------------------------------*/ +/* Seek File R/W Pointer */ +/*-----------------------------------------------------------------------*/ +FRESULT pf_lseek ( DWORD ofs ) /* File pointer from top of file */ +{ + CLUST clst; + DWORD bcs, sect, ifptr; + FATFS *fs = FatFs; + + + if (!fs) return FR_NOT_ENABLED; /* Check file system */ + if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ + + if (ofs > fs->fsize) ofs = fs->fsize; /* Clip offset with the file size */ + ifptr = fs->fptr; + fs->fptr = 0; + if (ofs > 0) { + bcs = (DWORD)fs->csize * 512; /* Cluster size (byte) */ + if (ifptr > 0 && + (ofs - 1) / bcs >= (ifptr - 1) / bcs) { /* When seek to same or following cluster, */ + fs->fptr = (ifptr - 1) & ~(bcs - 1); /* start from the current cluster */ + ofs -= fs->fptr; + clst = fs->curr_clust; + } else { /* When seek to back cluster, */ + clst = fs->org_clust; /* start from the first cluster */ + fs->curr_clust = clst; + } + while (ofs > bcs) { /* Cluster following loop */ + clst = get_fat(clst); /* Follow cluster chain */ + if (clst <= 1 || clst >= fs->n_fatent) ABORT(FR_DISK_ERR); + fs->curr_clust = clst; + fs->fptr += bcs; + ofs -= bcs; + } + fs->fptr += ofs; + sect = clust2sect(clst); /* Current sector */ + if (!sect) ABORT(FR_DISK_ERR); + fs->dsect = sect + (fs->fptr / 512 & (fs->csize - 1)); + } + + return FR_OK; +} diff --git a/software/src/PetitFS/pff_write.c b/software/src/PetitFS/pff_write.c new file mode 100644 index 0000000..4ab7762 --- /dev/null +++ b/software/src/PetitFS/pff_write.c @@ -0,0 +1,112 @@ +/*----------------------------------------------------------------------------/ +/ Petit FatFs - FAT file system module R0.03a +/-----------------------------------------------------------------------------/ +/ +/ Copyright (C) 2019, ChaN, all right reserved. +/ Modifications for RFS/Sharp MZ80A: Philip Smart, 2020 +/ +/ Petit FatFs module is an open source software. Redistribution and use of +/ Petit FatFs in source and binary forms, with or without modification, are +/ permitted provided that the following condition is met: +/ +/ 1. Redistributions of source code must retain the above copyright notice, +/ this condition and the following disclaimer. +/ +/ This software is provided by the copyright holder and contributors "AS IS" +/ and any warranties related to this software are DISCLAIMED. +/ The copyright owner or contributors be NOT LIABLE for any damages caused +/ by use of this software. +/-----------------------------------------------------------------------------/ +/ Jun 15,'09 R0.01a First release. +/ +/ Dec 14,'09 R0.02 Added multiple code page support. +/ Added write funciton. +/ Changed stream read mode interface. +/ Dec 07,'10 R0.02a Added some configuration options. +/ Fixed fails to open objects with DBCS character. + +/ Jun 10,'14 R0.03 Separated out configuration options to pffconf.h. +/ Added _USE_LCC option. +/ Added _FS_FAT16 option. +/ +/ Jan 30,'19 R0.03a Supported stdint.h for C99 and later. +/ Removed _WORD_ACCESS option. +/ Changed prefix of configuration options, _ to PF_. +/ Added some code pages. +/ Removed some code pages actually not valid. +/ +/ Mar 12,'20 R0.04 Removal of all non-FAT32 code and adapted for use in +/ banked ROMS as part of the RFS on the Sharp MZ80A. +/----------------------------------------------------------------------------*/ + +#include +#include +#include "pff.h" /* Petit FatFs configurations and declarations */ +#include "sdmmc.h" /* Declarations of low level disk I/O functions */ +#include "pff_func.h" +#define PFF_WRITE_C + +/*-----------------------------------------------------------------------*/ +/* Write File */ +/*-----------------------------------------------------------------------*/ +FRESULT pf_write ( + const void* buff, /* Pointer to the data to be written */ + UINT btw, /* Number of bytes to write (0:Finalize the current write operation) */ + UINT* bw /* Pointer to number of bytes written */ +) +{ + CLUST clst; + DWORD sect, remain; + const BYTE *p = buff; + BYTE cs; + UINT wcnt; + FATFS *fs = FatFs; + + + *bw = 0; + if (!fs) return FR_NOT_ENABLED; /* Check file system */ + if (!(fs->flag & FA_OPENED)) return FR_NOT_OPENED; /* Check if opened */ + + if (!btw) { /* Finalize request */ + if ((fs->flag & FA__WIP) && disk_writep(0, 0)) ABORT(FR_DISK_ERR); + fs->flag &= ~FA__WIP; + return FR_OK; + } else { /* Write data request */ + if (!(fs->flag & FA__WIP)) { /* Round-down fptr to the sector boundary */ + fs->fptr &= 0xFFFFFE00; + } + } + remain = fs->fsize - fs->fptr; + if (btw > remain) btw = (UINT)remain; /* Truncate btw by remaining bytes */ + + while (btw) { /* Repeat until all data transferred */ + if ((UINT)fs->fptr % 512 == 0) { /* On the sector boundary? */ + cs = (BYTE)(fs->fptr / 512 & (fs->csize - 1)); /* Sector offset in the cluster */ + if (!cs) { /* On the cluster boundary? */ + if (fs->fptr == 0) { /* On the top of the file? */ + clst = fs->org_clust; + } else { + clst = get_fat(fs->curr_clust); + } + if (clst <= 1) ABORT(FR_DISK_ERR); + fs->curr_clust = clst; /* Update current cluster */ + } + sect = clust2sect(fs->curr_clust); /* Get current sector */ + if (!sect) ABORT(FR_DISK_ERR); + fs->dsect = sect + cs; + if (disk_writep(0, fs->dsect)) ABORT(FR_DISK_ERR); /* Initiate a sector write operation */ + fs->flag |= FA__WIP; + } + wcnt = 512 - (UINT)fs->fptr % 512; /* Number of bytes to write to the sector */ + if (wcnt > btw) wcnt = btw; + if (disk_writep(p, wcnt)) ABORT(FR_DISK_ERR); /* Send data to the sector */ + fs->fptr += wcnt; p += wcnt; /* Update pointers and counters */ + btw -= wcnt; *bw += wcnt; + if ((UINT)fs->fptr % 512 == 0) { + if (disk_writep(0, 0)) ABORT(FR_DISK_ERR); /* Finalize the currtent secter write operation */ + fs->flag &= ~FA__WIP; + } + } + + return FR_OK; +} diff --git a/software/src/PetitFS/pffconf.h b/software/src/PetitFS/pffconf.h new file mode 100644 index 0000000..bc16c30 --- /dev/null +++ b/software/src/PetitFS/pffconf.h @@ -0,0 +1,58 @@ +/*---------------------------------------------------------------------------/ +/ Petit FatFs - Configuration file +/---------------------------------------------------------------------------*/ + +#ifndef PFCONF_DEF +#define PFCONF_DEF 8088 /* Revision ID */ + +/*---------------------------------------------------------------------------/ +/ Function Configurations (0:Disable, 1:Enable) +/---------------------------------------------------------------------------*/ + +//#define PF_USE_READ 1 /* pf_read() function */ +//#define PF_USE_DIR 1 /* pf_opendir() and pf_readdir() function */ +//#define PF_USE_LSEEK 1 /* pf_lseek() function */ +//#define PF_USE_WRITE 1 /* pf_write() function */ + +//#define PF_FS_FAT12 1 /* FAT12 */ +//#define PF_FS_FAT16 1 /* FAT16 */ +//#define PF_FS_FAT32 1 /* FAT32 */ + + +/*---------------------------------------------------------------------------/ +/ Locale and Namespace Configurations +/---------------------------------------------------------------------------*/ + +#define PF_USE_LCC 0 /* Allow lower case ASCII and non-ASCII chars */ + +#define PF_CODE_PAGE 437 +/* The PF_CODE_PAGE specifies the code page to be used on the target system. +/ SBCS code pages with PF_USE_LCC == 1 requiers a 128 byte of case conversion +/ table. It might occupy RAM on some platforms, e.g. avr-gcc. +/ When PF_USE_LCC == 0, PF_CODE_PAGE has no effect. +/ +/ 437 - U.S. +/ 720 - Arabic +/ 737 - Greek +/ 771 - KBL +/ 775 - Baltic +/ 850 - Latin 1 +/ 852 - Latin 2 +/ 855 - Cyrillic +/ 857 - Turkish +/ 860 - Portuguese +/ 861 - Icelandic +/ 862 - Hebrew +/ 863 - Canadian French +/ 864 - Arabic +/ 865 - Nordic +/ 866 - Russian +/ 869 - Greek 2 +/ 932 - Japanese (DBCS) +/ 936 - Simplified Chinese (DBCS) +/ 949 - Korean (DBCS) +/ 950 - Traditional Chinese (DBCS) +*/ + + +#endif /* PF_CONF */ diff --git a/software/src/PetitFS/rfs.inc b/software/src/PetitFS/rfs.inc new file mode 100644 index 0000000..e69de29 diff --git a/software/src/PetitFS/sdmmc.c b/software/src/PetitFS/sdmmc.c new file mode 100644 index 0000000..e898b2a --- /dev/null +++ b/software/src/PetitFS/sdmmc.c @@ -0,0 +1,789 @@ +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Name: sdmmc.c +// Created: March 2020 +// Author(s): ChaN (framework), Philip Smart (Sharp MZ80A/RFS Z80 code and customisation) +// Description: Functionality to enable connectivity between the PetitFS ((C) ChaN) and the RFS +// subsystem of the Sharp MZ80A for SD drives. This module provides the public +// interfaces to interact with the hardware. +// Low level functions were written in C and the two disk_ methods were +// initially written in C but then converted into Z80 and optimised. The end purpose is +// to use the functions in this module inside the RFS roms. +// +// Credits: +// Copyright: (C) 2013, ChaN, all rights reserved - framework. +// Copyright: (C) 2020 Philip Smart +// +// History: March 2020 - Initial development. +// +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// This source file is free software: you can redistribute it and#or modify +// it under the terms of the GNU General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This source file is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +///////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include "pff.h" /* Obtains integer types for Petit FatFs */ +#include "sdmmc.h" /* Common include file for the disk I/O layer */ + +/*-------------------------------------------------------------------------*/ +/* Platform dependent macros and functions needed to be modified */ +/*-------------------------------------------------------------------------*/ + +#define SPI_OUT 0xFF +#define SPI_IN 0xFE +#define DOUT_LOW 0x00 +#define DOUT_HIGH 0x04 +#define DOUT_MASK 0x04 +#define DIN_LOW 0x00 +#define DIN_HIGH 0x01 +#define CLOCK_LOW 0x00 +#define CLOCK_HIGH 0x02 +#define CLOCK_MASK 0xFD +#define CS_LOW 0x00 +#define CS_HIGH 0x01 + +/*-------------------------------------------------------------------------- + Module Private Functions +---------------------------------------------------------------------------*/ + +/* MMC/SD command (SPI mode) */ +#define CMD0 64 + 0 /* GO_IDLE_STATE */ +#define CMD1 64 + 1 /* SEND_OP_COND */ +#define ACMD41 0x40+41 /* SEND_OP_COND (SDC) */ +#define CMD8 64 + 8 /* SEND_IF_COND */ +#define CMD9 64 + 9 /* SEND_CSD */ +#define CMD10 64 + 10 /* SEND_CID */ +#define CMD12 64 + 12 /* STOP_TRANSMISSION */ +#define CMD13 64 + 13 /* SEND_STATUS */ +#define ACMD13 0x40+13 /* SD_STATUS (SDC) */ +#define CMD16 64 + 16 /* SET_BLOCKLEN */ +#define CMD17 64 + 17 /* READ_SINGLE_BLOCK */ +#define CMD18 64 + 18 /* READ_MULTIPLE_BLOCK */ +#define CMD23 64 + 23 /* SET_BLOCK_COUNT */ +#define ACMD23 0x40+23 /* SET_WR_BLK_ERASE_COUNT (SDC) */ +#define CMD24 64 + 24 /* WRITE_BLOCK */ +#define CMD25 64 + 25 /* WRITE_MULTIPLE_BLOCK */ +#define CMD32 64 + 32 /* ERASE_ER_BLK_START */ +#define CMD33 64 + 33 /* ERASE_ER_BLK_END */ +#define CMD38 64 + 38 /* ERASE */ +#define CMD55 64 + 55 /* APP_CMD */ +#define CMD58 64 + 58 /* READ_OCR */ +#define SECTOR_SIZE 512 /* Default size of an SD Sector */ + +/* Card type flags (CardType) */ +#define CT_MMC 0x01 /* MMC ver 3 */ +#define CT_SD1 0x02 /* SD ver 1 */ +#define CT_SD2 0x04 /* SD ver 2 */ +#define CT_SDC CT_SD1|CT_SD2 /* SD */ +#define CT_BLOCK 0x08 /* Block addressing */ + +static DSTATUS Stat = STA_NOINIT; /* Disk status */ +BYTE SDBUF[11]; +BYTE SDVER; +BYTE SDCAP; +static DRESULT RESULT; +static UINT BYTECNT; +static UINT WRITECNT; +//static BYTE d; + + +/*-------------------------------------------------------------------------- + Public Functions +---------------------------------------------------------------------------*/ + + +/*-----------------------------------------------------------------------*/ +/* Initialize Disk Drive */ +/*-----------------------------------------------------------------------*/ +DSTATUS disk_initialize (void) +{ +#asm + ; Method to initialise the SD card. + ; +SDINIT: LD A,$00 ; CS to high + CALL SPICS + ; + CALL SPIINIT ; Train SD with our clock. + ; + LD A,$FF ; CS to low + CALL SPICS + LD BC,$FFFF + +SDINIT1: LD A,CMD0 ; Command 0 + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + + PUSH BC + LD A,(_SDBUF+6) ; Get response code. + DEC A ; Set Z flag to test if response is 0x01 + JP Z,SDINIT2 ; Command response 0x01? Exit if match. + POP BC + DEC BC + LD A,B + OR C + JR NZ,SDINIT1 ; Retry for BC times. + LD A,1 + JP SD_EXIT ; Error, card is not responding to CMD0 +SDINIT2: POP BC + ; Now send CMD8 to get card details. This command can only be sent + ; when the card is idle. + LD A,CMD8 ; CMD8 has 0x00001AA as parameter, load up registers and call command routine. + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$AA01 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + + ; Version 2 card, check its voltage range. IF not in the 2.7-3.6V dont try the ACMD41 to get capabilities. +SDINIT3: LD A,1 ; Check that we receive 0x0001AA in response. + LD (_SDVER),A ; Indicate this is not a version 2 card. + LD A,(_SDBUF+9) + CP 1 + JP NZ,SDINIT8 + LD A,(_SDBUF+10) + CP $AA + JP NZ,SDINIT8 + +SDINIT4: LD A,2 ; This is a version 2 card. +SDINIT5: LD (_SDVER),A ; Indicate this is not a version 2 card. + + CALL SDACMD41 + JR Z,SDINIT6 + LD A,2 ; Error, card is not responding to ACMD41 + JP SD_EXIT + +SDINIT6: LD A,CMD58 ; CMD58 has 0x00000000 as parameter, load up registers and call command routine. + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(_SDBUF+6) + CP $40 + LD A,CT_SD2 + JR Z,SDINIT7 + LD A,CT_SD2 | CT_BLOCK +SDINIT7: LD (_SDCAP),A ; Set the capabilities according to the returned flag. + JR SDINIT14 + + + ; Version 1 card or MMC v3. +SDINIT8: CALL SDACMD41 + LD A, CT_SD1 + LD E,ACMD41 ; SD1 cards we use the ACMD41 command. + JR Z,SDINIT9 + LD A,CT_MMC + LD E,CMD1 ; MMC cards we use the CMD1 command. +SDINIT9: LD (_SDCAP),A + LD A,E + CP ACMD41 + JR NZ,SDINIT10 + CALL SDACMD41 + JR Z,SDINIT14 + LD A,3 ; Exit code, failed to initialise v1 card. + JP SD_EXIT + +SDINIT10: LD BC,10 ; ACMD41/CMD55 may take some cards time to process or respond, so give a large number of retries. +SDINIT11: PUSH BC + LD A,CMD1 ; CMD1 has 0x00000000 as parameter, load up registers and call command routine. + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + OR A + JR Z,SDINIT13 + LD BC,$FFFF ; Delay for at least 200mS for the card to recover and be ready. +SDINIT12: DEC BC ; 6T + LD A,B ; 9T + OR C ; 4T + JR NZ,SDINIT12 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS + ; + POP BC + DEC BC + LD A,B + OR C + JR NZ,SDINIT11 + LD A,4 ; Exit code, failed to initialise v1 MMC card. + JP SD_EXIT + +SDINIT13: LD A,CMD16 ; No response from the card for an ACMD41/CMD1 so try CMD16 with parameter 0x00000200 + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0002 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(_SDBUF+6) + OR A + JR Z,SDINIT14 + LD A,0 + LD (_SDCAP),A ; No capabilities on this unknown card. +SDINIT14: LD A,0 + JR SD_EXIT +SD_EXIT: LD L,A ; Return value goes into HL. + LD H,0 +#endasm +} + + +#asm + ; Method to initialise communications with the SD card. We basically train it to our clock characteristics. + ; This is important, as is maintaining the same clock for read or write otherwise the card may not respond. +SPIINIT: LD B,80 +SPIINIT1: LD A,DOUT_HIGH | CLOCK_HIGH | CS_HIGH ; Output a 1 + OUT (SPI_OUT),A + LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Output a 1 + OUT (SPI_OUT),A + DJNZ SPIINIT1 + RET + + ; Method to set the Chip Select level on the SD card. The Chip Select is active LOW. + ; + ; A = 0 - Set CS HIGH + ; A = 0xFF - Set CS LOW +SPICS: OR A + LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Set CS High if parameter = 0 (ie. disable) + JR Z, SPICS0 + LD A,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Set CS Low if parameter != 0 (ie. disable) +SPICS0: OUT (SPI_OUT),A + RET + + ; Method to send a command to the card and receive back a response. + ; + ; A = CMD to send + ; LHED = Argument, ie. CMD = A, L, H, E, D, CRC + ; +SDCMD: LD (_SDBUF),A + LD (_SDBUF+1),HL + EX DE,HL + LD (_SDBUF+3),HL + ; + LD B,5 ; R1 + 32bit argument for CMD8, CMD58 + CP CMD8 + LD C,135 + JP Z,SDCMD0 + LD C,1 ; CMD58 is not CRC checked so just set to 0x01. + CP CMD58 + LD B,5 ; R1 + 32bit argument + JP Z,SDCMD0 + ; + LD B,1 ; Default, expect R1 which is 1 byte. + CP CMD0 ; Work out the CRC based on the command. CRC checking is + LD C,149 ; not implemented but certain commands require a fixed argument and CRC. + JP Z,SDCMD0 + LD C,1 ; Remaining commands are not CRC checked so just set to 0x01. +SDCMD0: PUSH BC ; Save the CRC and the number of bytes to be returned, + LD A,C ; Store the CRC + LD (_SDBUF+5),A + LD A,255 ; Preamble byte + CALL SPIOUT + LD HL,_SDBUF + LD B,6 +SDCMD1: PUSH BC + LD A,(HL) + INC HL + CALL SPIOUT ; Send the command and parameters. + POP BC + DJNZ SDCMD1 + PUSH HL +SDCMD2: CALL SPIIN + CP $FF + JR Z,SDCMD2 + JR SDCMD4 +SDCMD3: PUSH BC + PUSH HL + CALL SPIIN ; +SDCMD4: POP HL + LD (HL),A + INC HL + POP BC ; Get back number of expected bytes. HL = place in buffer to store response. + DJNZ SDCMD3 + LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH + OUT (SPI_OUT),A + RET + + ; Method to send an Application Command to the SD Card. This involves sending CMD55 followed by the required command. + ; + ; A = ACMD to send + ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC + ; +SDACMD: PUSH AF + PUSH DE + PUSH HL + LD A,CMD55 ; CMD55 has 0x00000000 as parameter, load up registers and call command routine. + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + DEC A + JR NZ,SDACMD + + POP HL + POP DE + POP AF + CALL SDCMD + LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + OR A + RET + + ; Method to send Application Command 41 to the SD card. This command involves retries and delays + ; hence coded seperately. + ; + ; Returns Z set if successful, else NZ. + ; +SDACMD41: LD BC,10 ; ACMD41/CMD55 may take some cards time to process or respond, so give a large number of retries. +SDACMD1: PUSH BC + LD A,ACMD41 ; ACMD41 has 0x40000000 as parameter, load up registers and call command routine. + LD HL,$0040 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDACMD + LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + OR A + JR Z,SDACMD3 + LD BC,12903 ; Delay for at least 200mS for the card to recover and be ready. +SDACMD2: DEC BC ; 6T + LD A,B ; 9T + OR C ; 4T + JR NZ,SDACMD2 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS + ; + POP BC + DEC BC + LD A,B + OR C + JR NZ,SDACMD1 + LD A,1 +SDACMD3: OR A + RET + + ; Method to send a byte to the SD card via the SPI protocol. + ; This method uses the bitbang technique, change if hardware spi is available. + ; + ; Input A = Byte to send. + ; +SPIOUT: RLCA ; 65432107 + RLCA ; 54321076 + RLCA ; 43210765 - Adjust so that starting bit is same position as Data line. + LD E,A ; E = Character to send. + LD B,8 ; B = Bit count +SPIOUT0: LD A,E + AND DOUT_MASK ; Data bit to data line, clock and cs low. + RLC E +SPIOUT1: OUT (SPI_OUT),A + OR CLOCK_HIGH ; Clock high + OUT (SPI_OUT),A + AND CLOCK_MASK ; Clock low + OUT (SPI_OUT),A + DJNZ SPIOUT0 ; Perform actions for the full 8 bits. + RET + + ; Method to receive a byte from the SD card via the SPI protocol. + ; This method uses the bitbang technique, change if hardware spi is available. + ; NB. Timing must be very similar in SPIOUT and SPIIN. + ; + ; Output: A = received byte. + ; +SPIIN: LD BC,$800 | SPI_OUT ; B = Bit count, C = clock port + LD L,0 ; L = Character being read. + LD D,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Output a 0 + OUT (C),D ; To start ensure clock is low and CS is low. + LD E,DOUT_HIGH | CLOCK_HIGH | CS_LOW ; Output a 0 +SPIIN1: OUT (C),E ; Clock to high. + IN A,(SPI_IN) ; Input the received bit + OUT (C),D ; Clock to low. + SRL A + RL L + DJNZ SPIIN1 ; Perform actions for the full 8 bits. + LD A,L ; return value + RET + + ; A function from the z88dk stdlib, a delay loop with T state accuracy. + ; + ; enter : hl = tstates >= 141 + ; uses : af, bc, hl +T_DELAY: LD BC,-141 + ADD HL,BC + LD BC,-23 +TDELAYLOOP: ADD HL,BC + JR C, TDELAYLOOP + LD A,L + ADD A,15 + JR NC, TDELAYG0 + CP 8 + JR C, TDELAYG1 + OR 0 +TDELAYG0: INC HL +TDELAYG1: RRA + JR C, TDELAYB0 + NOP +TDELAYB0: RRA + JR NC, TDELAYB1 + OR 0 +TDELAYB1: RRA + RET NC + RET + + ; Method to skip over an SD card input stream to arrive at the required bytes, + ; + ; Input: BC = Number of bytes to skip. + ; +SPISKIP: PUSH BC + CALL SPIIN + POP BC + DEC BC + LD A,B + OR C + JR NZ,SPISKIP + RET + + ; Method to convert an LBA value into a physical byte address. This is achieved by multiplying the block x 512. + ; We take the value off the stack, shift left 9 times then store the result back onto the stack. + ; + ; Input: HL = Stack offset. +LBATOADDR: ADD HL,SP ; Retrieve sector from stack. + PUSH HL + LD A,(HL) + INC HL + LD E,(HL) + INC HL + LD D,(HL) + LD H,A + LD L,0 + SLA H ; Shift the long left by 9 to effect a x512 + RL E + RL D + POP BC + LD A,L + LD (BC),A + INC BC + LD A,H + LD (BC),A + INC BC + LD A,E + LD (BC),A + INC BC + LD A,D + LD (BC),A + RET +#endasm + + +/*-----------------------------------------------------------------------*/ +/* Read partial sector */ +/*-----------------------------------------------------------------------*/ +DRESULT disk_readp ( BYTE *buff, /* Pointer to the read buffer (NULL:Read bytes are forwarded to the stream) */ + DWORD sector, /* Sector number (LBA) */ + UINT offset, /* Byte offset to read from (0..511) */ + UINT count ) /* Number of bytes to read (ofs + cnt mus be <= 512) */ +{ +#asm + ; parameter 'unsigned int count' at 2 size(2) + ; parameter 'unsigned int offset' at 4 size(2) + ; parameter 'unsigned long sector' at 6 size(4) + ; parameter 'unsigned char BYTE*buff' at 10 size(2) + + LD A,0 + CALL SPICS ; Set CS low (active). + + LD HL,(_SDCAP) ; Test to see if CT_BLOCK is available. + LD H,0 + LD A,CT_BLOCK + AND L + JP NZ,READP_3 ; If it has CT_BLOCK then use sector numbers otherwise multiply up to bytes. + + LD HL,6 + 2 ; It isnt so we need to convert the block to bytes by x512. + CALL LBATOADDR + +READP_3: LD HL,1 + LD (_RESULT),HL + + ; A = ACMD to send + ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC + LD HL,6 ; Sector is stored as 3rd paramneter at offset 6, retrieve and arrange in little endian order in LHED + ADD HL,SP + LD D,(HL) + INC HL + LD E,(HL) + INC HL + PUSH DE + LD D,(HL) + INC HL + LD E,(HL) + LD A,CMD17 ; Send CMD17 to read a sector. + POP HL + EX DE,HL + CALL SDCMD + LD A,(_SDBUF+6) ; Fetch result and store. + AND A + JP NZ,READP_4 + + LD HL,1000 ; Sit in a tight loop waiting for the data packet arrival (ie. not 0xFF). +READP_7: PUSH HL + LD HL,200 + CALL T_DELAY + CALL SPIIN + POP HL + CP 255 + JP NZ,READP_6 + DEC HL + LD A,H + OR L + JR NZ,READP_7 + +READP_6: CP 254 + JP NZ,READP_4 + LD HL,4 + ADD HL,SP + LD E,(HL) + INC HL + LD D,(HL) + LD HL,514 + AND A + SBC HL,DE + EX DE,HL + POP BC + POP HL + PUSH HL + PUSH BC + EX DE,HL + AND A + SBC HL,DE + LD (_BYTECNT),HL + + LD HL,4 + ADD HL,SP + LD A,(HL) + INC HL + LD H,(HL) + LD L,A + LD A,H + OR L + JP Z,READP_11 + + PUSH HL + POP BC + CALL SPISKIP + +READP_11: LD HL,10 ; Get the buffer pointer from where to read data. + ADD HL,SP + LD A,(HL) + INC HL + LD H,(HL) + LD L,A + LD A,H + OR L + JP Z,READP_12 + +READP_15: PUSH HL + CALL SPIIN + POP HL + LD (HL),A + INC HL + PUSH HL + POP BC + + LD HL,10 ; Update the pointer on the stack with register copy. + ADD HL,SP + LD (HL),C + INC HL + LD (HL),B +READP_13: POP DE ; Return address. + POP HL ; Count + DEC HL ; Decrement count + PUSH HL ; And return stack to previous state. + PUSH DE + LD A,H + OR L + PUSH BC + POP HL + JP NZ,READP_15 + +READP_12: LD HL,(_BYTECNT) + PUSH HL + POP BC + CALL SPISKIP + LD HL,0 + LD (_RESULT),HL +READP_4: + LD A,0 + CALL SPICS + LD HL,(_RESULT) +#endasm +} + + + +/*-----------------------------------------------------------------------*/ +/* Write partial sector */ +/*-----------------------------------------------------------------------*/ +DRESULT disk_writep ( const BYTE *buff, /* Pointer to the bytes to be written (NULL:Initiate/Finalize sector write) */ + DWORD sc ) /* Number of bytes to send, Sector number (LBA) or zero */ +{ +#asm + ; parameter 'unsigned long sc' at 2 size(4) + ; parameter 'const unsigned char BYTE*buff' at 6 size(2) + LD HL,1 + LD (_RESULT),HL + + LD A,$FF ; Activate CS (set low). + CALL SPICS + + LD HL,6 ; If buffer is not null, we are writing data, otherwise we are instigating a write transaction. + ADD HL,SP + LD A,(HL) + INC HL + LD H,(HL) + LD L,A + LD A,H + OR L + JP Z,WRITEP_3 ; NULL so we are performing a transaction open/close. + + LD HL,2 ; Get the sector into DEHL. + ADD HL,SP + LD A,(HL) + INC HL + LD H,(HL) + LD L,A + LD (_BYTECNT),HL ; Only interested in the lower 16bit value of the long. + +WRITEP_4: LD A,H ; So long as we have bytes in the buffer, send to the card for writing. + OR L + JP Z,WRITEP_5 + LD HL,(_WRITECNT) ; Count of bytes to write. + LD A,H + OR L + JR Z,WRITEP_5 ; If either the max count (512) or the requested count (_BYTECNT) have expired, exit. + + LD HL,6 ; Load the buffer pointer. + ADD HL,SP + INC (HL) + LD A,(HL) + INC HL + JR NZ,WRITEP_2 ; Increment by 1 carrying overflow into MSB. + INC (HL) +WRITEP_2: LD H,(HL) + LD L,A + DEC HL ; Back to current byte. + LD A,(HL) + CALL SPIOUT + LD HL,(_WRITECNT) ; Decrement the max count. + DEC HL + LD (_WRITECNT),HL + LD HL,(_BYTECNT) ; Decrement the requested count. + DEC HL + LD (_BYTECNT),HL + JP WRITEP_4 + +WRITEP_5: LD HL,0 + LD (_RESULT),HL + JP WRITEP_8 + +WRITEP_3: LD HL,2 ; Get the sector number into DEHL to test. + ADD HL,SP + LD E,(HL) + INC HL + LD D,(HL) + INC HL + LD A,(HL) + INC HL + LD H,(HL) + LD L,A + EX DE,HL + LD A,H + OR L + OR D + OR E + JP Z,WRITEP_9 ; Sector is 0 so finalise the write transaction. + + LD HL,(_SDCAP) ; Check to see if the card has block addressing. + LD H,0 + LD A,CT_BLOCK + AND L + JP NZ,WRITEP_10 ; If it hasnt then we need to multiply up to the correct byte. + + LD HL,2 + 2 ; Fetch the sector number, multiply (by left shift x 9) x512 and store. + CALL LBATOADDR + + ; A = ACMD to send + ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC +WRITEP_10: LD HL,2 ; Sector is stored as 3rd paramneter at offset 6, retrieve and arrange in little endian order in LHED + ADD HL,SP + LD D,(HL) + INC HL + LD E,(HL) + INC HL + PUSH DE + LD D,(HL) + INC HL + LD E,(HL) + LD A,CMD24 ; Send CMD24 to write a sector. + POP HL + EX DE,HL + CALL SDCMD + LD A,(_SDBUF+6) ; Fetch result and store. + ;LD (_d),A + AND A + JP NZ,WRITEP_8 + LD A,255 + CALL SPIOUT + LD A,254 + CALL SPIOUT + LD HL,512 + LD (_WRITECNT),HL + LD HL,0 + LD (_RESULT),HL + JP WRITEP_8 + +WRITEP_9: LD HL,(_WRITECNT) + INC HL + INC HL + LD (_BYTECNT),HL +WRITEP_13: + LD HL,(_BYTECNT) + DEC HL + LD (_BYTECNT),HL + INC HL + LD A,H + OR L + JP Z,WRITEP_14 + LD A,0 + CALL SPIOUT + JP WRITEP_13 +WRITEP_14: + CALL SPIIN + AND $1F + LD L,A + LD H,0 + CP 5 + JP NZ,WRITEP_15 + + LD HL,10000 + PUSH HL + JR WRITEP_18 +WRITEP_20: DEC HL + PUSH HL + LD HL,200 + CALL T_DELAY +WRITEP_18: CALL SPIIN + POP HL + CP 255 + JP Z,WRITEP_17 + LD A,H + OR L + JR NZ,WRITEP_20 + +WRITEP_17: LD A,H + OR L + JP Z,WRITEP_15 + LD HL,0 + LD (_RESULT),HL +WRITEP_15: LD A,$00 + CALL SPICS +WRITEP_8: LD HL,(_RESULT) + +#endasm +} diff --git a/software/src/PetitFS/sdmmc.c.asm b/software/src/PetitFS/sdmmc.c.asm new file mode 100644 index 0000000..689de2d --- /dev/null +++ b/software/src/PetitFS/sdmmc.c.asm @@ -0,0 +1,1267 @@ +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Fri Mar 13 16:31:35 2020 + + + + MODULE sdmmc_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION data_compiler +._Stat + defb 1 + SECTION code_compiler + +; Function spi_init flags 0x00000200 __smallc +; int spi_init() +._spi_init + LD A, 0x04 | 0x00 | 0x00 ; Clock and MOSI High. + OUT ( 0xFF ),A + LD B,80 + LD A, 0x04 | 0x00 | 0x00 ; Output a 1 +SPIINIT1: OUT ( 0xFF ),A + NOP + NOP + LD A, 0x04 | 0x02 | 0x00 ; Output a 1 + OUT ( 0xFF ),A + NOP + NOP + DJNZ SPIINIT1 + LD A, 0x04 | 0x00 | 0x00 ; Output a 1 + OUT ( 0xFF ),A + LD HL,0 ; hl is the return parameter + ret + + + +; Function spi_cs flags 0x00000200 __smallc +; int spi_cs(unsigned char b) +; parameter 'unsigned char b' at 2 size(1) +._spi_cs + ret + + + +; Function spi_out flags 0x00000200 __smallc +; int spi_out(unsigned char b) +; parameter 'unsigned char b' at 2 size(1) +._spi_out + LD HL,2 + ADD HL,SP ; skip over return address on stack + LD A,(HL) ; a = b, "char b" occupies 16 bits on stack + ; but only the LSB is relevant + LD E,A ; E = Character to send. + LD B,08H ; B = Bit count +SPIOUT0: RL E + LD A, 0x00 | 0x00 | 0x00 ; Output a 0 + JR NC,SPIOUT1 + LD A, 0x04 | 0x00 | 0x00 ; Output a 1 +SPIOUT1: OUT ( 0xFF ),A + LD D,A + OR 0x02 + OUT ( 0xFF ),A + LD A,D + OUT ( 0xFF ),A + DJNZ SPIOUT0 ; Perform actions for the full 8 bits. + ;LD A, 0x04 | 0x00 | 0x00 ; Return clock and MOSI to high. + ;OUT ( 0xFF ),A + LD HL,0 ; hl is the return parameter + ret + + + +; Function spi_in flags 0x00000200 __smallc +; unsigned char uint8_tspi_in() +._spi_in + LD BC,0800H ; B = Bit count, C = Character being read. +SPIIN0: LD A, 0x04 | 0x00 | 0x00 ; Output a 0 +SPIIN1: OUT ( 0xFF ),A + LD D,A + OR 0x02 + OUT ( 0xFF ),A + NOP + IN A,( 0xFE ) ; Input the received bit + SRL A + RL C + LD A,D + OUT ( 0xFF ),A + DJNZ SPIIN0 ; Perform actions for the full 8 bits. + LD L,C ; hl is the return parameter + LD H,0 + ret + + + +; Function spi_skip flags 0x00000200 __smallc +; void spi_skip(unsigned int n) +; parameter 'unsigned int n' at 2 size(2) +._spi_skip + dec sp +.i_5 + ld hl,0 ;const + add hl,sp + push hl + call _spi_in + pop de + ld a,l + ld (de),a +.i_3 + ld hl,3 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + ld a,h + or l + jp nz,i_5 +.i_4 + inc sp + ret + + + +; Function send_cmd flags 0x00000200 __smallc +; unsigned char BYTEsend_cmd(unsigned char cmd, unsigned long arg) +; parameter 'unsigned long arg' at 2 size(4) +; parameter 'unsigned char cmd' at 6 size(1) +._send_cmd + push bc + ld hl,8 ;const + add hl,sp + ld a,+(128 % 256) + and (hl) + jp z,i_6 + ld hl,8 ;const + add hl,sp + push hl + ld a,(hl) + and +(127 % 256) + ld l,a + ld h,0 + pop de + ld a,l + ld (de),a + ld hl,0 ;const + add hl,sp + push hl + ld hl,55 ;const + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + pop de + ld a,l + ld (de),a + pop hl + push hl + ld h,0 + ld a,1 + sub l + jp nc,i_7 + pop hl + push hl + ld h,0 + pop bc + ret + + +.i_7 +.i_6 + ld hl,255 ;const + push hl + call _spi_cs + pop bc + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + call _spi_out + pop bc + ld hl,7 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + push hl + call _spi_out + pop bc + ld hl,6 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld de,0 + push hl + call _spi_out + pop bc + ld hl,5 ;const + add hl,sp + ld e,(hl) + inc hl + inc hl + ld l,(hl) + ld h,0 + ex de,hl + ld h,0 + push hl + call _spi_out + pop bc + ld hl,4 ;const + add hl,sp + call l_glong + ld h,0 + push hl + call _spi_out + pop bc + ld hl,1 ;const + add hl,sp + ld (hl),+(1 % 256 % 256) + ld hl,8 ;const + add hl,sp + ld a,(hl) + and a + jp nz,i_8 + ld hl,1 ;const + add hl,sp + ld (hl),+(149 % 256 % 256) +.i_8 + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 8 + jp nz,i_9 + ld hl,1 ;const + add hl,sp + ld (hl),+(135 % 256 % 256) +.i_9 + pop hl + push hl + ld l,h + ld h,0 + push hl + call _spi_out + pop bc + ld hl,1 ;const + add hl,sp + ld (hl),+(10 % 256 % 256) +.i_12 + ld hl,0 ;const + add hl,sp + push hl + call _spi_in + pop de + ld a,l + ld (de),a +.i_10 + pop hl + push hl + ld h,0 + ld a,l + and +(128 % 256) + jp z,i_13 + ld hl,1 ;const + add hl,sp + dec (hl) + ld a,(hl) + and a + jr nz,i_14_i_13 +.i_13 + jp i_11 +.i_14_i_13 + jp i_12 +.i_11 + pop hl + push hl + ld h,0 + pop bc + ret + + + +; Function disk_initialize flags 0x00000200 __smallc +; unsigned char DSTATUSdisk_initialize() +._disk_initialize + push bc + push bc + push bc + push bc + dec sp + call _spi_init + ld hl,6 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld hl,0 ;const + push hl + ld d,h + ld e,l + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + cp 1 + jp nz,i_15 + ld hl,8 ;const + push hl + ld hl,426 ;const + ld de,0 + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + cp 1 + jp nz,i_16 + ld hl,i_1+0 + push hl + ld a,1 + call printf + pop bc + ld hl,8 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_19 +.i_17 + ld hl,8 ;const + add hl,sp + inc (hl) +.i_19 + ld hl,8 ;const + add hl,sp + ld a,(hl) + sub 4 + jp nc,i_18 + ld hl,2 ;const + add hl,sp + ex de,hl + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + push hl + call _spi_in + pop de + ld a,l + ld (de),a + jp i_17 +.i_18 + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 1 + jp nz,i_21 + ld hl,5 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 170 + jr z,i_22_i_21 +.i_21 + jp i_20 +.i_22_i_21 + ld hl,1000 ;const + pop bc + push hl + jp i_25 +.i_23 + pop hl + dec hl + push hl + inc hl +.i_25 + pop hl + push hl + ld a,h + or l + jp z,i_24 + ld hl,169 ;const + push hl + ld hl,0 ;const + ld de,16384 + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + and a + jp z,i_24 +.i_26 + ld hl,2000 ;const + call t_delay + jp i_23 +.i_24 + pop hl + push hl + ld a,h + or l + jp z,i_28 + ld hl,58 ;const + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + and a + jr z,i_29_i_28 +.i_28 + jp i_27 +.i_29_i_28 + ld hl,8 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_32 +.i_30 + ld hl,8 ;const + add hl,sp + inc (hl) +.i_32 + ld hl,8 ;const + add hl,sp + ld a,(hl) + sub 4 + jp nc,i_31 + ld hl,2 ;const + add hl,sp + ex de,hl + ld hl,8 ;const + add hl,sp + ld l,(hl) + ld h,0 + add hl,de + push hl + call _spi_in + pop de + ld a,l + ld (de),a + jp i_30 +.i_31 + ld hl,6 ;const + add hl,sp + push hl + ld hl,4 ;const + add hl,sp + ld a,+(64 % 256) + and (hl) + jp z,i_33 + ld hl,12 ;const + jp i_34 +.i_33 + ld hl,4 ;const +.i_34 + pop de + ld a,l + ld (de),a +.i_27 +.i_20 + jp i_35 +.i_16 + ld hl,i_1+20 + push hl + ld a,1 + call printf + pop bc + ld hl,169 ;const + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,1 + sub l + ccf + jp nc,i_36 + ld hl,6 ;const + add hl,sp + ld (hl),+(2 % 256 % 256) + ld hl,7 ;const + add hl,sp + ld (hl),+(169 % 256 % 256) + ld l,(hl) + ld h,0 + jp i_37 +.i_36 + ld hl,6 ;const + add hl,sp + ld (hl),+(1 % 256 % 256) + ld hl,7 ;const + add hl,sp + ld (hl),+(1 % 256 % 256) +.i_37 + ld hl,1000 ;const + pop bc + push hl + jp i_40 +.i_38 + pop hl + dec hl + push hl + inc hl +.i_40 + pop hl + push hl + ld a,h + or l + jp z,i_39 + ld hl,7 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,0 ;const + ld d,h + ld e,l + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + and a + jp z,i_39 +.i_41 + ld hl,2000 ;const + call t_delay + jp i_38 +.i_39 + pop hl + push hl + call l_lneg + jp c,i_43 + ld hl,16 ;const + push hl + ld hl,512 ;const + ld de,0 + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + and a + jp z,i_42 +.i_43 + ld hl,6 ;const + add hl,sp + ld (hl),+(0 % 256 % 256) + ld l,(hl) + ld h,0 +.i_42 +.i_35 +.i_15 + ld hl,6 ;const + add hl,sp + ld a,(hl) + ld (_CardType),a + ld hl,255 ;const + push hl + call _spi_cs + pop bc + ld hl,6 ;const + add hl,sp + ld a,(hl) + and a + jp z,i_45 + ld hl,0 ;const + jp i_46 +.i_45 + ld hl,1 ;const +.i_46 + ld h,0 + inc sp + pop bc + pop bc + pop bc + pop bc + ret + + + +; Function disk_readp flags 0x00000200 __smallc +; const int DRESULTdisk_readp(unsigned char BYTE*buff, unsigned long sector, unsigned int offset, unsigned int count) +; parameter 'unsigned int count' at 2 size(2) +; parameter 'unsigned int offset' at 4 size(2) +; parameter 'unsigned long sector' at 6 size(4) +; parameter 'unsigned char BYTE*buff' at 10 size(2) +._disk_readp + push bc + push bc + push bc + dec sp + ld hl,0 ;const + push hl + call _spi_cs + pop bc + ld hl,(_CardType) + ld h,0 + ld a,+(8 % 256) + and l + ld l,a + call l_lneg + jp nc,i_47 + ld hl,13 ;const + add hl,sp + push hl + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_mult + pop bc + call l_plong +.i_47 + ld hl,5 ;const + add hl,sp + ld (hl),+(1 % 256) + inc hl + ld (hl),+(1 / 256) + ld hl,17 ;const + push hl + ld hl,15 ;const + add hl,sp + call l_glong + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + and a + jp nz,i_48 + ld hl,1000 ;const + pop bc + push hl +.i_51 + ld hl,200 ;const + call t_delay + ld hl,4 ;const + add hl,sp + push hl + call _spi_in + pop de + ld a,l + ld (de),a +.i_49 + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 255 + jp nz,i_52 + pop hl + dec hl + push hl + ld a,h + or l + jr nz,i_53_i_52 +.i_52 + jp i_50 +.i_53_i_52 + jp i_51 +.i_50 + ld hl,4 ;const + add hl,sp + ld l,(hl) + ld h,0 + ld a,l + cp 254 + jp nz,i_54 + ld hl,11 ;const + add hl,sp + ld e,(hl) + inc hl + ld d,(hl) + ld hl,514 + and a + sbc hl,de + ex de,hl + ld hl,9 ;const + add hl,sp + call l_gint ; + ex de,hl + and a + sbc hl,de + pop de + pop bc + push hl + push de + ld hl,11 ;const + add hl,sp + call l_gint ; + ld a,h + or l + jp z,i_55 + ld hl,11 ;const + add hl,sp + call l_gint ; + push hl + call _spi_skip + pop bc +.i_55 + ld hl,17 ;const + add hl,sp + call l_gint ; + ld a,h + or l + jp z,i_56 +.i_59 + ld hl,4 ;const + add hl,sp + push hl + call _spi_in + pop de + ld a,l + ld (de),a + ld hl,17 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + push hl + ld hl,6 ;const + add hl,sp + ld a,(hl) + pop de + ld (de),a +.i_57 + ld hl,9 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + ld a,h + or l + jp nz,i_59 +.i_58 + jp i_60 +.i_56 +.i_63 + ld hl,4 ;const + add hl,sp + push hl + call _spi_in + pop de + ld a,l + ld (de),a +.i_61 + ld hl,9 ;const + add hl,sp + dec (hl) + ld a,(hl) + inc hl + cp 255 + jr nz,ASMPC+3 + dec (hl) + ld h,(hl) + ld l,a + ld a,h + or l + jp nz,i_63 +.i_62 +.i_60 + pop bc + pop hl + push hl + push bc + push hl + call _spi_skip + pop bc + ld hl,5 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint +.i_54 +.i_48 + ld hl,255 ;const + push hl + call _spi_cs + pop bc + ld hl,5 ;const + add hl,sp + call l_gint ; + inc sp + pop bc + pop bc + pop bc + ret + + + +; Function disk_writep flags 0x00000200 __smallc +; const int DRESULTdisk_writep(const unsigned char BYTE*buff, unsigned long sc) +; parameter 'unsigned long sc' at 2 size(4) +; parameter 'const unsigned char BYTE*buff' at 6 size(2) +._disk_writep + push bc + push bc + push bc + ld hl,4 ;const + add hl,sp + ld (hl),+(1 % 256) + inc hl + ld (hl),+(1 / 256) + ld hl,0 ;const + push hl + call _spi_cs + pop bc + ld hl,12 ;const + add hl,sp + call l_gint ; + ld a,h + or l + jp z,i_64 + ld hl,8 ;const + add hl,sp + call l_glong + pop de + pop bc + push hl + push de +.i_65 + pop bc + pop hl + push hl + push bc + ld a,h + or l + jp z,i_67 + ld hl,(_st_disk_writep_wc) + ld a,h + or l + jr nz,i_68_i_67 +.i_67 + jp i_66 +.i_68_i_67 + ld hl,12 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) + ld h,(hl) + ld l,a + dec hl + ld l,(hl) + ld h,0 + push hl + call _spi_out + pop bc + ld hl,(_st_disk_writep_wc) + dec hl + ld (_st_disk_writep_wc),hl + pop de + pop hl + dec hl + push hl + push de + inc hl + jp i_65 +.i_66 + ld hl,4 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint + jp i_69 +.i_64 + ld hl,8 ;const + add hl,sp + call l_glong + ld a,h + or l + or d + or e + jp z,i_70 + ld hl,(_CardType) + ld h,0 + ld a,+(8 % 256) + and l + ld l,a + call l_lneg + jp nc,i_71 + ld hl,8 ;const + add hl,sp + push hl + call l_glong2sp + ld hl,512 ;const + ld de,0 + call l_long_mult + pop bc + call l_plong +.i_71 + ld hl,24 ;const + push hl + ld hl,10 ;const + add hl,sp + call l_glong + push de + push hl + call _send_cmd + pop bc + pop bc + pop bc + ld a,l + and a + jp nz,i_72 + ld hl,255 ;const + push hl + call _spi_out + pop bc + ld hl,254 ;const + push hl + call _spi_out + pop bc + ld hl,512 ;const + ld (_st_disk_writep_wc),hl + ld hl,4 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint +.i_72 + jp i_73 +.i_70 + ld hl,(_st_disk_writep_wc) + inc hl + inc hl + pop de + pop bc + push hl + push de +.i_74 + pop de + pop hl + dec hl + push hl + push de + inc hl + ld a,h + or l + jp z,i_75 + ld hl,0 ;const + push hl + call _spi_out + pop bc + jp i_74 +.i_75 + call _spi_in + ld a,l + and +(31 % 256) + ld l,a + ld h,0 + cp 5 + jp nz,i_76 + ld hl,10000 ;const + pop bc + push hl + jp i_79 +.i_77 + pop hl + dec hl + push hl + inc hl +.i_79 + call _spi_in + ld a,l + cp 255 + jp z,i_80 + pop hl + push hl + ld a,h + or l + jr nz,i_81_i_80 +.i_80 + jp i_78 +.i_81_i_80 + ld hl,200 ;const + call t_delay + jp i_77 +.i_78 + pop hl + push hl + ld a,h + or l + jp z,i_82 + ld hl,4 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint +.i_82 +.i_76 + ld hl,255 ;const + push hl + call _spi_cs + pop bc +.i_73 +.i_69 + ld hl,4 ;const + add hl,sp + call l_gint ; + pop bc + pop bc + pop bc + ret + + + SECTION rodata_compiler +.i_1 + defm "Identified v2 card" + defb 10 + + defm "" + defb 0 + + defm "Identified v1 card" + defb 10 + + defm "" + defb 0 + + +; --- Start of Static Variables --- + + SECTION bss_compiler +._CardType defs 1 +._st_disk_writep_wc defs 2 + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + GLOBAL _spi_init + GLOBAL _spi_cs + GLOBAL _spi_out + GLOBAL _spi_in + GLOBAL _spi_skip + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- diff --git a/software/src/PetitFS/sdmmc.c.bak b/software/src/PetitFS/sdmmc.c.bak new file mode 100644 index 0000000..7af754b --- /dev/null +++ b/software/src/PetitFS/sdmmc.c.bak @@ -0,0 +1,1006 @@ +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Name: sdmmc.c +// Created: March 2020 +// Author(s): ChaN (framework), Philip Smart (Sharp MZ80A/RFS customisation) +// Description: Functionality to enable connectivity between the PetitFS ((C) ChaN) and the RFS +// subsystem of the Sharp MZ80A for SD drives. This module provides the public +// interfaces to interact with the hardware. +// +// Credits: +// Copyright: (C) 2013, ChaN, all rights reserved - framework. +// Copyright: (C) 2020 Philip Smart +// +// History: March 2020 - Initial development. +// +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// This source file is free software: you can redistribute it and#or modify +// it under the terms of the GNU General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This source file is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +///////////////////////////////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include "pff.h" /* Obtains integer types for Petit FatFs */ +#include "sdmmc.h" /* Common include file for the disk I/O layer */ + +/*-------------------------------------------------------------------------*/ +/* Platform dependent macros and functions needed to be modified */ +/*-------------------------------------------------------------------------*/ + +#define SPI_OUT 0xFF +#define SPI_IN 0xFE +#define DOUT_LOW 0x00 +#define DOUT_HIGH 0x04 +#define DOUT_MASK 0x04 +#define DIN_LOW 0x00 +#define DIN_HIGH 0x01 +#define CLOCK_LOW 0x00 +#define CLOCK_HIGH 0x02 +#define CLOCK_MASK 0xFD +#define CS_LOW 0x00 +#define CS_HIGH 0x01 + +/*-------------------------------------------------------------------------- + Module Private Functions +---------------------------------------------------------------------------*/ + +/* MMC/SD command (SPI mode) */ +#define CMD0 64 + 0 /* GO_IDLE_STATE */ +#define CMD1 64 + 1 /* SEND_OP_COND */ +#define ACMD41 0x40+41 /* SEND_OP_COND (SDC) */ +#define CMD8 64 + 8 /* SEND_IF_COND */ +#define CMD9 64 + 9 /* SEND_CSD */ +#define CMD10 64 + 10 /* SEND_CID */ +#define CMD12 64 + 12 /* STOP_TRANSMISSION */ +#define CMD13 64 + 13 /* SEND_STATUS */ +#define ACMD13 0x40+13 /* SD_STATUS (SDC) */ +#define CMD16 64 + 16 /* SET_BLOCKLEN */ +#define CMD17 64 + 17 /* READ_SINGLE_BLOCK */ +#define CMD18 64 + 18 /* READ_MULTIPLE_BLOCK */ +#define CMD23 64 + 23 /* SET_BLOCK_COUNT */ +#define ACMD23 0x40+23 /* SET_WR_BLK_ERASE_COUNT (SDC) */ +#define CMD24 64 + 24 /* WRITE_BLOCK */ +#define CMD25 64 + 25 /* WRITE_MULTIPLE_BLOCK */ +#define CMD32 64 + 32 /* ERASE_ER_BLK_START */ +#define CMD33 64 + 33 /* ERASE_ER_BLK_END */ +#define CMD38 64 + 38 /* ERASE */ +#define CMD55 64 + 55 /* APP_CMD */ +#define CMD58 64 + 58 /* READ_OCR */ +#define SECTOR_SIZE 512 /* Default size of an SD Sector */ + +/* Card type flags (CardType) */ +#define CT_MMC 0x01 /* MMC ver 3 */ +#define CT_SD1 0x02 /* SD ver 1 */ +#define CT_SD2 0x04 /* SD ver 2 */ +#define CT_SDC CT_SD1|CT_SD2 /* SD */ +#define CT_BLOCK 0x08 /* Block addressing */ + +static DSTATUS Stat = STA_NOINIT; /* Disk status */ +BYTE SDBUF[11]; +BYTE SDVER; +BYTE SDCAP; + +/*-------------------------------------------------------------------------- + Public Functions +---------------------------------------------------------------------------*/ + +/*-------------------------------------------------------------------------- + + Module Private Functions + +---------------------------------------------------------------------------*/ + + + +// Method to initialise the SPI hardware. +// +//int spi_init(void) +//{ +//#asm +// ; Method to initialise communications with the SD card. We basically train it to our clock characteristics. +// ; This is important, as is maintaining the same clock for read or write otherwise the card may not respond. +// LD B,80 +//SPI_INIT1: LD A,DOUT_HIGH | CLOCK_HIGH | CS_HIGH ; Output a 1 +// OUT (SPI_OUT),A +// LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Output a 1 +// OUT (SPI_OUT),A +// DJNZ SPI_INIT1 +// LD HL,0 ; hl is the return parameter +//#endasm +//} + +// Method to select/deselect the SD card within the SPI hardware +// addressing mechanism. +// +// Input: b = 0, deselect SD Card +// b = 1, select SD Card. +//int spi_cs(unsigned char b) +//{ +//#asm +// ; Method to set the Chip Select level on the SD card. The Chip Select is active LOW. +// ; +// ; A = 0 - Set CS HIGH +// ; A = 0xFF - Set CS LOW +// LD HL,2 +// ADD HL,SP ; skip over return address on stack +// LD A,(HL) ; a = b, "char b" occupies 16 bits on stack +// ; but only the LSB is relevant +// OR A +// LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Set CS High if parameter = 0 (ie. disable) +// JR Z, SPI_CS0 +// LD A,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Set CS Low if parameter != 0 (ie. disable) +//SPI_CS0: OUT (SPI_OUT),A +// LD HL,0 ; hl is the return parameter +//#endasm +//} + +// Method to transmit a byte via SPI. +// +// Input: b = 8 bit character to send. +// +//int spi_out(unsigned char b) +//{ +//#asm +// ; Method to send a byte to the SD card via the SPI protocol. +// ; This method uses the bitbang technique, change if hardware spi is available. +// ; +// ; Input A = Byte to send. +// ; +// LD HL,2 +// ADD HL,SP ; skip over return address on stack +// LD A,(HL) ; a = b, "char b" occupies 16 bits on stack +// ; but only the LSB is relevant +// RLCA ; 65432107 +// RLCA ; 54321076 +// RLCA ; 43210765 - Adjust so that starting bit is same position as Data line. +// LD E,A ; E = Character to send. +// LD B,8 ; B = Bit count +//SPI_OUT0: LD A,E +// AND DOUT_MASK ; Data bit to data line, clock and cs low. +// RLC E +//SPI_OUT1: OUT (SPI_OUT),A +// OR CLOCK_HIGH ; Clock high +// OUT (SPI_OUT),A +// AND CLOCK_MASK ; Clock low +// OUT (SPI_OUT),A +// DJNZ SPI_OUT0 ; Perform actions for the full 8 bits. +// LD HL,0 ; hl is the return parameter +//#endasm +//} + +// Method to receive a character from the SPI. +// +// Returns: 8 bit byte. +// +//uint8_t spi_in(void) +//{ +//#asm +// ; Method to receive a byte from the SD card via the SPI protocol. +// ; This method uses the bitbang technique, change if hardware spi is available. +// ; NB. Timing must be very similar in SPIOUT and SPIIN. +// ; +// ; Output: A = received byte. +// ; +// LD BC,$800 | SPI_OUT ; B = Bit count, C = clock port +// LD L,0 ; L = Character being read. +// LD D,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Output a 0 +// OUT (C),D ; To start ensure clock is low and CS is low. +// LD E,DOUT_HIGH | CLOCK_HIGH | CS_LOW ; Output a 0 +//SPI_IN1: OUT (C),E ; Clock to high. +// IN A,(SPI_IN) ; Input the received bit +// OUT (C),D ; Clock to low. +// SRL A +// RL L +// DJNZ SPI_IN1 ; Perform actions for the full 8 bits. +// LD H,0 ; hl is the return parameter, L already set to received byte. +//#endasm +//} + +// Method to skip data being sent over the SPI. +// +// Input: n = number of bytes to skip or flush. +// +//void spi_skip(UINT n) +//{ +//#asm +// LD HL,2 +// ADD HL,SP ; skip over return address on stack +// LD C,(HL) ; n occupies 16 bits on stack +// INC HL +// LD B,(HL) +// +//SPISKIP0: PUSH BC +// CALL SPIIN +// POP BC +// DEC BC +// LD A,B +// OR C +// JR NZ,SPISKIP0 +//#endasm +//} + +/*-----------------------------------------------------------------------*/ +/* Send a command packet to MMC */ +/*-----------------------------------------------------------------------*/ +// +//BYTE send_cmd (BYTE cmd, /* Command byte */ +// DWORD arg /* Argument */ +// ) +//{ +//#asm +// ; Method to send a command to the card and receive back a response. +// ; +// ; A = CMD to send +// ; LHED = Argument, ie. CMD = A, L, H, E, D, CRC +// ; +// LD HL,2 +// ADD HL,SP ; skip over return address on stack +// LD A,(HL) +// LD (_SDBUF+4),A +// INC HL +// LD A,(HL) +// LD (_SDBUF+3),A +// INC HL +// LD A,(HL) +// LD (_SDBUF+2),A +// INC HL +// LD A,(HL) +// LD (_SDBUF+1),A +// INC HL +// LD A,(HL) +// LD (_SDBUF),A +// ; +// LD B,5 ; R1 + 32bit argument for CMD8, CMD58 +// CP CMD8 +// LD C,135 +// JP Z,SD_CMD0 +// LD C,1 ; CMD58 is not CRC checked so just set to 0x01. +// CP CMD58 +// LD B,5 ; R1 + 32bit argument +// JP Z,SD_CMD0 +// ; +// LD B,1 ; Default, expect R1 which is 1 byte. +// CP CMD0 ; Work out the CRC based on the command. CRC checking is +// LD C,149 ; not implemented but certain commands require a fixed argument and CRC. +// JP Z,SD_CMD0 +// LD C,1 ; Remaining commands are not CRC checked so just set to 0x01. +//SD_CMD0: PUSH BC ; Save the CRC and the number of bytes to be returned, +// LD A,C ; Store the CRC +// LD (_SDBUF+5),A +// LD A,255 ; Preamble byte +// CALL SPIOUT +// LD HL,_SDBUF +// LD B,6 +//SD_CMD1: PUSH BC +// LD A,(HL) +// INC HL +// CALL SPIOUT ; Send the command and parameters. +// POP BC +// DJNZ SD_CMD1 +// PUSH HL +//SD_CMD2: CALL SPIIN +// CP $FF +// JR Z,SD_CMD2 +// JR SD_CMD4 +//SD_CMD3: PUSH BC +// PUSH HL +// CALL SPIIN ; +//SD_CMD4: POP HL +// LD (HL),A +// INC HL +// POP BC ; Get back number of expected bytes. HL = place in buffer to store response. +// DJNZ SD_CMD3 +// LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH +// OUT (SPI_OUT),A +// LD A,(_SDBUF+6) +// LD L,A +// LD H,0 +//#endasm +//} + + +/*-----------------------------------------------------------------------*/ +/* Initialize Disk Drive */ +/*-----------------------------------------------------------------------*/ +DSTATUS disk_initialize (void) +{ +#asm + ; Method to initialise the SD card. + ; +SDINIT: LD A,$00 ; CS to high + CALL SPICS + ; + CALL SPIINIT ; Train SD with our clock. + ; + LD A,$FF ; CS to low + CALL SPICS + LD BC,$FFFF + +SDINIT1: LD A,CMD0 ; Command 0 + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + + PUSH BC + LD A,(_SDBUF+6) ; Get response code. + DEC A ; Set Z flag to test if response is 0x01 + JP Z,SDINIT2 ; Command response 0x01? Exit if match. + POP BC + DEC BC + LD A,B + OR C + JR NZ,SDINIT1 ; Retry for BC times. + LD A,1 + JP SD_EXIT ; Error, card is not responding to CMD0 +SDINIT2: POP BC + ; Now send CMD8 to get card details. This command can only be sent + ; when the card is idle. + LD A,CMD8 ; CMD8 has 0x00001AA as parameter, load up registers and call command routine. + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$AA01 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + + ; Version 2 card, check its voltage range. IF not in the 2.7-3.6V dont try the ACMD41 to get capabilities. +SDINIT3: LD A,1 ; Check that we receive 0x0001AA in response. + LD (_SDVER),A ; Indicate this is not a version 2 card. + LD A,(_SDBUF+9) + CP 1 + JP NZ,SDINIT8 + LD A,(_SDBUF+10) + CP $AA + JP NZ,SDINIT8 + +SDINIT4: LD A,2 ; This is a version 2 card. +SDINIT5: LD (_SDVER),A ; Indicate this is not a version 2 card. + + CALL SDACMD41 + JR Z,SDINIT6 + LD A,2 ; Error, card is not responding to ACMD41 + JP SD_EXIT + +SDINIT6: LD A,CMD58 ; CMD58 has 0x00000000 as parameter, load up registers and call command routine. + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(_SDBUF+6) + CP $40 + LD A,CT_SD2 + JR Z,SDINIT7 + LD A,CT_SD2 | CT_BLOCK +SDINIT7: LD (_SDCAP),A ; Set the capabilities according to the returned flag. + JR SDINIT14 + + + ; Version 1 card or MMC v3. +SDINIT8: CALL SDACMD41 + LD A, CT_SD1 + LD E,ACMD41 ; SD1 cards we use the ACMD41 command. + JR Z,SDINIT9 + LD A,CT_MMC + LD E,CMD1 ; MMC cards we use the CMD1 command. +SDINIT9: LD (_SDCAP),A + LD A,E + CP ACMD41 + JR NZ,SDINIT10 + CALL SDACMD41 + JR Z,SDINIT14 + LD A,3 ; Exit code, failed to initialise v1 card. + JP SD_EXIT + +SDINIT10: LD BC,10 ; ACMD41/CMD55 may take some cards time to process or respond, so give a large number of retries. +SDINIT11: PUSH BC + LD A,CMD1 ; CMD1 has 0x00000000 as parameter, load up registers and call command routine. + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + OR A + JR Z,SDINIT13 + LD BC,$FFFF ; Delay for at least 200mS for the card to recover and be ready. +SDINIT12: DEC BC ; 6T + LD A,B ; 9T + OR C ; 4T + JR NZ,SDINIT12 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS + ; + POP BC + DEC BC + LD A,B + OR C + JR NZ,SDINIT11 + LD A,4 ; Exit code, failed to initialise v1 MMC card. + JP SD_EXIT + +SDINIT13: LD A,CMD16 ; No response from the card for an ACMD41/CMD1 so try CMD16 with parameter 0x00000200 + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0002 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(_SDBUF+6) + OR A + JR Z,SDINIT14 + LD A,0 + LD (_SDCAP),A ; No capabilities on this unknown card. +SDINIT14: LD A,0 + JR SD_EXIT +SD_EXIT: LD L,A ; Return value goes into HL. + LD H,0 + RET + +#endasm +} + + +static DRESULT res; +static UINT bc; +static static UINT wc; +static BYTE d; + +#asm + ; Method to initialise communications with the SD card. We basically train it to our clock characteristics. + ; This is important, as is maintaining the same clock for read or write otherwise the card may not respond. +SPIINIT: LD B,80 +SPIINIT1: LD A,DOUT_HIGH | CLOCK_HIGH | CS_HIGH ; Output a 1 + OUT (SPI_OUT),A + LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Output a 1 + OUT (SPI_OUT),A + DJNZ SPIINIT1 + RET + + ; Method to set the Chip Select level on the SD card. The Chip Select is active LOW. + ; + ; A = 0 - Set CS HIGH + ; A = 0xFF - Set CS LOW +SPICS: OR A + LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH ; Set CS High if parameter = 0 (ie. disable) + JR Z, SPICS0 + LD A,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Set CS Low if parameter != 0 (ie. disable) +SPICS0: OUT (SPI_OUT),A + RET + + ; Method to send a command to the card and receive back a response. + ; + ; A = CMD to send + ; LHED = Argument, ie. CMD = A, L, H, E, D, CRC + ; +SDCMD: LD (_SDBUF),A + LD (_SDBUF+1),HL + EX DE,HL + LD (_SDBUF+3),HL + ; + LD B,5 ; R1 + 32bit argument for CMD8, CMD58 + CP CMD8 + LD C,135 + JP Z,SDCMD0 + LD C,1 ; CMD58 is not CRC checked so just set to 0x01. + CP CMD58 + LD B,5 ; R1 + 32bit argument + JP Z,SDCMD0 + ; + LD B,1 ; Default, expect R1 which is 1 byte. + CP CMD0 ; Work out the CRC based on the command. CRC checking is + LD C,149 ; not implemented but certain commands require a fixed argument and CRC. + JP Z,SDCMD0 + LD C,1 ; Remaining commands are not CRC checked so just set to 0x01. +SDCMD0: PUSH BC ; Save the CRC and the number of bytes to be returned, + LD A,C ; Store the CRC + LD (_SDBUF+5),A + LD A,255 ; Preamble byte + CALL SPIOUT + LD HL,_SDBUF + LD B,6 +SDCMD1: PUSH BC + LD A,(HL) + INC HL + CALL SPIOUT ; Send the command and parameters. + POP BC + DJNZ SDCMD1 + PUSH HL +SDCMD2: CALL SPIIN + CP $FF + JR Z,SDCMD2 + JR SDCMD4 +SDCMD3: PUSH BC + PUSH HL + CALL SPIIN ; +SDCMD4: POP HL + LD (HL),A + INC HL + POP BC ; Get back number of expected bytes. HL = place in buffer to store response. + DJNZ SDCMD3 + LD A,DOUT_HIGH | CLOCK_LOW | CS_HIGH + OUT (SPI_OUT),A + RET + + ; Method to send an Application Command to the SD Card. This involves sending CMD55 followed by the required command. + ; + ; A = ACMD to send + ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC + ; +SDACMD: PUSH AF + PUSH DE + PUSH HL + LD A,CMD55 ; CMD55 has 0x00000000 as parameter, load up registers and call command routine. + LD HL,$0000 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDCMD + LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + DEC A + JR NZ,SDACMD + + POP HL + POP DE + POP AF + CALL SDCMD + LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + OR A + RET + + ; Method to send Application Command 41 to the SD card. This command involves retries and delays + ; hence coded seperately. + ; + ; Returns Z set if successful, else NZ. + ; +SDACMD41: LD BC,10 ; ACMD41/CMD55 may take some cards time to process or respond, so give a large number of retries. +SDACMD1: PUSH BC + LD A,ACMD41 ; ACMD41 has 0x40000000 as parameter, load up registers and call command routine. + LD HL,$0040 ; NB. Important, HL should be coded as LH due to little endian and the way it is used in SDCMD. + LD DE,$0000 ; NB. Important, DE should be coded as ED due to little endian and the way it is used in SDCMD. + CALL SDACMD + LD A,(_SDBUF+6) ; Should be a response of 0 whereby the card has left idle. + OR A + JR Z,SDACMD3 + LD BC,12903 ; Delay for at least 200mS for the card to recover and be ready. +SDACMD2: DEC BC ; 6T + LD A,B ; 9T + OR C ; 4T + JR NZ,SDACMD2 ; 12T = 31T x 500ns = 15.5uS x 12903 = 200mS + ; + POP BC + DEC BC + LD A,B + OR C + JR NZ,SDACMD1 + LD A,1 +SDACMD3: OR A + RET + + ; Method to send a byte to the SD card via the SPI protocol. + ; This method uses the bitbang technique, change if hardware spi is available. + ; + ; Input A = Byte to send. + ; +SPIOUT: RLCA ; 65432107 + RLCA ; 54321076 + RLCA ; 43210765 - Adjust so that starting bit is same position as Data line. + LD E,A ; E = Character to send. + LD B,8 ; B = Bit count +SPIOUT0: LD A,E + AND DOUT_MASK ; Data bit to data line, clock and cs low. + RLC E +SPIOUT1: OUT (SPI_OUT),A + OR CLOCK_HIGH ; Clock high + OUT (SPI_OUT),A + AND CLOCK_MASK ; Clock low + OUT (SPI_OUT),A + DJNZ SPIOUT0 ; Perform actions for the full 8 bits. + RET + + ; Method to receive a byte from the SD card via the SPI protocol. + ; This method uses the bitbang technique, change if hardware spi is available. + ; NB. Timing must be very similar in SPIOUT and SPIIN. + ; + ; Output: A = received byte. + ; +SPIIN: LD BC,$800 | SPI_OUT ; B = Bit count, C = clock port + LD L,0 ; L = Character being read. + LD D,DOUT_HIGH | CLOCK_LOW | CS_LOW ; Output a 0 + OUT (C),D ; To start ensure clock is low and CS is low. + LD E,DOUT_HIGH | CLOCK_HIGH | CS_LOW ; Output a 0 +SPIIN1: OUT (C),E ; Clock to high. + IN A,(SPI_IN) ; Input the received bit + OUT (C),D ; Clock to low. + SRL A + RL L + DJNZ SPIIN1 ; Perform actions for the full 8 bits. + LD A,L ; return value + RET + + ; enter : hl = tstates >= 141 + ; + ; uses : af, bc, hl +T_DELAY: LD BC,-141 + ADD HL,BC + LD BC,-23 +TDELAYLOOP: ADD HL,BC + JR C, TDELAYLOOP + LD A,L + ADD A,15 + JR NC, TDELAYG0 + CP 8 + JR C, TDELAYG1 + OR 0 +TDELAYG0: INC HL +TDELAYG1: RRA + JR C, TDELAYB0 + NOP +TDELAYB0: RRA + JR NC, TDELAYB1 + OR 0 +TDELAYB1: RRA + RET NC + RET + + ; Method to skip over an SD card input stream to arrive at the required bytes, + ; + ; Input: BC = Number of bytes to skip. + ; +SPISKIP: PUSH BC + CALL SPIIN + POP BC + DEC BC + LD A,B + OR C + JR NZ,SPISKIP + RET + + ; Method to convert an LBA value into a physical byte address. This is achieved by multiplying the block x 512. + ; We take the value off the stack, shift left 9 times then store the result back onto the stack. + ; + ; Input: HL = Stack offset. +LBATOADDR: ADD HL,SP ; Retrieve sector from stack. + PUSH HL + LD A,(HL) + INC HL + LD E,(HL) + INC HL + LD D,(HL) + LD H,A + LD L,0 + SLA H ; Shift the long left by 9 to effect a x512 + RL E + RL D + POP BC + LD A,L + LD (BC),A + INC BC + LD A,H + LD (BC),A + INC BC + LD A,E + LD (BC),A + INC BC + LD A,D + LD (BC),A + RET +#endasm + + +/*-----------------------------------------------------------------------*/ +/* Read partial sector */ +/*-----------------------------------------------------------------------*/ +DRESULT disk_readp ( BYTE *buff, /* Pointer to the read buffer (NULL:Read bytes are forwarded to the stream) */ + DWORD sector, /* Sector number (LBA) */ + UINT offset, /* Byte offset to read from (0..511) */ + UINT count ) /* Number of bytes to read (ofs + cnt mus be <= 512) */ +{ +#asm + ; parameter 'unsigned int count' at 2 size(2) + ; parameter 'unsigned int offset' at 4 size(2) + ; parameter 'unsigned long sector' at 6 size(4) + ; parameter 'unsigned char BYTE*buff' at 10 size(2) + + LD A,0 + CALL SPICS ; Set CS low (active). + + LD HL,(_SDCAP) ; Test to see if CT_BLOCK is available. + LD H,0 + LD A,CT_BLOCK + AND L + JP NZ,READP_3 ; If it has CT_BLOCK then use sector numbers otherwise multiply up to bytes. + + LD HL,6 + 2 ; It isnt so we need to convert the block to bytes by x512. + CALL LBATOADDR + +READP_3: LD HL,1 + LD (_res),HL + + ; A = ACMD to send + ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC + LD HL,6 ; Sector is stored as 3rd paramneter at offset 6, retrieve and arrange in little endian order in LHED + ADD HL,SP + LD D,(HL) + INC HL + LD E,(HL) + INC HL + PUSH DE + LD D,(HL) + INC HL + LD E,(HL) + LD A,CMD17 ; Send CMD17 to read a sector. + POP HL + EX DE,HL + CALL SDCMD + LD A,(_SDBUF+6) ; Fetch result and store. + LD (_d),A + AND A + JP NZ,READP_4 + + LD HL,1000 ; Sit in a tight loop waiting for the data packet arrival (ie. not 0xFF). +READP_7: PUSH HL + LD HL,200 + CALL T_DELAY + CALL SPIIN + LD (_d),A + POP HL + CP 255 + JP NZ,READP_6 + DEC HL + LD A,H + OR L + JR NZ,READP_7 + +READP_6: CP 254 + JP NZ,READP_4 + LD HL,4 + ADD HL,SP + LD E,(HL) + INC HL + LD D,(HL) + LD HL,514 + AND A + SBC HL,DE + EX DE,HL + POP BC + POP HL + PUSH HL + PUSH BC + EX DE,HL + AND A + SBC HL,DE + LD (_bc),HL + + LD HL,4 + ADD HL,SP + LD A,(HL) + INC HL + LD H,(HL) + LD L,A + LD A,H + OR L + JP Z,READP_11 + + PUSH HL + POP BC + CALL SPISKIP +READP_11: + LD HL,10 + ADD HL,SP + LD A,(HL) + INC HL + LD H,(HL) + LD L,A + LD A,H + OR L + JP Z,READP_12 + +READP_15: CALL SPIIN + LD (_d),A + LD HL,10 + ADD HL,SP + INC (HL) + LD A,(HL) + INC HL + JR NZ,READP_14 + INC (HL) +READP_14: LD H,(HL) + LD L,A + DEC HL + EX DE,HL + LD HL,_d + LD A,(HL) + LD (DE),A +READP_13: + POP DE + POP HL + DEC HL + PUSH HL + PUSH DE + LD A,H + OR L + JP NZ,READP_15 +READP_12: + LD HL,(_bc) + PUSH HL + POP BC + CALL SPISKIP + LD HL,0 + LD (_res),HL +READP_4: + LD A,0 + CALL SPICS + LD HL,(_res) + +#endasm +} + + + +/*-----------------------------------------------------------------------*/ +/* Write partial sector */ +/*-----------------------------------------------------------------------*/ +DRESULT disk_writep ( const BYTE *buff, /* Pointer to the bytes to be written (NULL:Initiate/Finalize sector write) */ + DWORD sc ) /* Number of bytes to send, Sector number (LBA) or zero */ +{ +#asm + ; parameter 'unsigned long sc' at 2 size(4) + ; parameter 'const unsigned char BYTE*buff' at 6 size(2) + LD HL,1 + LD (_res),HL + + LD A,$FF ; Activate CS (set low). + CALL SPICS + + LD HL,6 ; If buffer is not null, we are writing data, otherwise we are instigating a write transaction. + ADD HL,SP + LD A,(HL) + INC HL + LD H,(HL) + LD L,A + LD A,H + OR L + JP Z,WRITEP_3 ; NULL so we are performing a transaction open/close. + + LD HL,2 ; Get the sector into DEHL. + ADD HL,SP + LD A,(HL) + INC HL + LD H,(HL) + LD L,A + LD (_bc),HL ; Only interested in the lower 16bit value of the long. + +WRITEP_4: LD A,H ; So long as we have bytes in the buffer, send to the card for writing. + OR L + JP Z,WRITEP_5 + LD HL,(_wc) ; Count of bytes to write. + LD A,H + OR L + JR Z,WRITEP_5 ; If either the max count (512) or the requested count (_bc) have expired, exit. + + LD HL,6 ; Load the buffer pointer. + ADD HL,SP + INC (HL) + LD A,(HL) + INC HL + JR NZ,WRITEP_2 ; Increment by 1 carrying overflow into MSB. + INC (HL) +WRITEP_2: LD H,(HL) + LD L,A + DEC HL ; Back to current byte. + LD A,(HL) + CALL SPIOUT + LD HL,(_wc) ; Decrement the max count. + DEC HL + LD (_wc),HL + LD HL,(_bc) ; Decrement the requested count. + DEC HL + LD (_bc),HL + JP WRITEP_4 + +WRITEP_5: LD HL,0 + LD (_res),HL + JP WRITEP_8 + +WRITEP_3: LD HL,2 ; Get the sector number into DEHL to test. + ADD HL,SP + LD E,(HL) + INC HL + LD D,(HL) + INC HL + LD A,(HL) + INC HL + LD H,(HL) + LD L,A + EX DE,HL + LD A,H + OR L + OR D + OR E + JP Z,WRITEP_9 ; Sector is 0 so finalise the write transaction. + + LD HL,(_SDCAP) ; Check to see if the card has block addressing. + LD H,0 + LD A,CT_BLOCK + AND L + JP NZ,WRITEP_10 ; If it hasnt then we need to multiply up to the correct byte. + + LD HL,2 + 2 ; Fetch the sector number, multiply (by left shift x 9) x512 and store. + CALL LBATOADDR + + ; A = ACMD to send + ; LHED = Argument, ie. ACMD = A, L, H, E, D, CRC +WRITEP_10: LD HL,2 ; Sector is stored as 3rd paramneter at offset 6, retrieve and arrange in little endian order in LHED + ADD HL,SP + LD D,(HL) + INC HL + LD E,(HL) + INC HL + PUSH DE + LD D,(HL) + INC HL + LD E,(HL) + LD A,CMD24 ; Send CMD24 to write a sector. + POP HL + EX DE,HL + CALL SDCMD + LD A,(_SDBUF+6) ; Fetch result and store. + LD (_d),A + AND A + JP NZ,WRITEP_8 + LD A,255 + CALL SPIOUT + LD A,254 + CALL SPIOUT + LD HL,512 + LD (_wc),HL + LD HL,0 + LD (_res),HL + JP WRITEP_8 + +WRITEP_9: LD HL,(_wc) + INC HL + INC HL + LD (_bc),HL +WRITEP_13: + LD HL,(_bc) + DEC HL + LD (_bc),HL + INC HL + LD A,H + OR L + JP Z,WRITEP_14 + LD A,0 + CALL SPIOUT + JP WRITEP_13 +WRITEP_14: + CALL SPIIN + AND $1F + LD L,A + LD H,0 + CP 5 + JP NZ,WRITEP_15 + + LD HL,10000 + PUSH HL + JR WRITEP_18 +WRITEP_20: DEC HL + PUSH HL + LD HL,200 + CALL T_DELAY +WRITEP_18: CALL SPIIN + POP HL + CP 255 + JP Z,WRITEP_17 + LD A,H + OR L + JR NZ,WRITEP_20 + +WRITEP_17: LD A,H + OR L + JP Z,WRITEP_15 + LD HL,0 + LD (_res),HL +WRITEP_15: LD A,$00 + CALL SPICS +WRITEP_8: LD HL,(_res) + +#endasm +} diff --git a/software/src/PetitFS/sdmmc.h b/software/src/PetitFS/sdmmc.h new file mode 100644 index 0000000..fc74d9e --- /dev/null +++ b/software/src/PetitFS/sdmmc.h @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Name: sdmmc.c +// Created: March 2020 +// Author(s): ChaN (framework), Philip Smart (Sharp MZ80A/RFS customisation) +// Description: Low level disk interface module include file. +// Functionality to enable connectivity between the PetitFS ((C) ChaN) and the RFS +// subsystem of the Sharp MZ80A for SD drives. This module provides the public +// interfaces to interact with the hardware. +// +// Credits: +// Copyright: (C) 2013, ChaN, all rights reserved - framework. +// Copyright: (C) 2020 Philip Smart +// +// History: March 2020 - Initial development. +// +///////////////////////////////////////////////////////////////////////////////////////////////////////// +// This source file is free software: you can redistribute it and#or modify +// it under the terms of the GNU General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This source file is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +///////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifndef _SDMMC_H +#define _SDMCC_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "pff.h" + + +/* Status of Disk Functions */ +typedef BYTE DSTATUS; + + +/* Results of Disk Functions */ +typedef enum { + RES_OK = 0, /* 0: Function succeeded */ + RES_ERROR, /* 1: Disk error */ + RES_NOTRDY, /* 2: Not ready */ + RES_PARERR /* 3: Invalid parameter */ +} DRESULT; + + +/*---------------------------------------*/ +/* Prototypes for disk control functions */ + +DSTATUS disk_initialize (void); +DRESULT disk_readp (BYTE* buff, DWORD sector, UINT offser, UINT count); +DRESULT disk_writep (const BYTE* buff, DWORD sc); + +#define STA_NOINIT 0x01 /* Drive not initialized */ +#define STA_NODISK 0x02 /* No medium in the drive */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SDMMC_H */ diff --git a/software/src/PetitFS/sdtest b/software/src/PetitFS/sdtest new file mode 100644 index 0000000..71d44b2 Binary files /dev/null and b/software/src/PetitFS/sdtest differ diff --git a/software/src/PetitFS/sdtest.asm b/software/src/PetitFS/sdtest.asm new file mode 100644 index 0000000..9d8f539 --- /dev/null +++ b/software/src/PetitFS/sdtest.asm @@ -0,0 +1,857 @@ +;* * * * * Small-C/Plus z88dk * * * * * +; Version: 16120-f784809cf-20200301 +; +; Reconstructed for z80 Module Assembler +; +; Module compile time: Fri Mar 13 22:46:08 2020 + + + + MODULE sdtest_c + + + INCLUDE "z80_crt0.hdr" + + + SECTION code_compiler + +; Function die flags 0x00000200 __smallc +; void die(const int rc) +; parameter 'const int rc' at 2 size(2) +._die + ld hl,i_1+0 + push hl + ld hl,4 ;const + call l_gintsp ; + push hl + ld a,2 + call printf + pop bc + pop bc + ld hl,i_1+20 + push hl + ld a,1 + call printf + pop bc + ld hl,10 ;const + call sleep + ret + + + +; Function main flags 0x00000000 __stdc +; int main() +._main + ld hl,65381 ;const + add hl,sp + ld sp,hl + ld hl,i_1+41 + push hl + ld a,1 + call printf + pop bc + ld hl,i_1+86 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + ld de,5 ;const + ex de,hl + call l_pint + call _disk_initialize + call l_lneg + jp nc,i_2 + ld hl,i_1+115 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,115 ;const + add hl,sp + push hl + call _pf_mount + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_3 + ld hl,i_1+137 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_3 + ld hl,i_1+192 + push hl + ld a,1 + call printf + pop bc +.i_2 + ld hl,i_1+209 + push hl + ld hl,115 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,118 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,121 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,124 ;const + add hl,sp + ld l,(hl) + ld h,0 + push hl + ld hl,129 ;const + add hl,sp + call l_glong2sp + ld hl,137 ;const + call l_glongsp ; + ld a,9 + call printf + ld hl,18 ;const + add hl,sp + ld sp,hl + ld hl,i_1+275 + push hl + ld hl,129 ;const + add hl,sp + call l_glong2sp + ld hl,137 ;const + add hl,sp + call l_glong2sp + ld hl,145 ;const + add hl,sp + call l_glong2sp + ld hl,153 ;const + add hl,sp + call l_glong2sp + ld hl,161 ;const + add hl,sp + call l_glong2sp + ld hl,169 ;const + add hl,sp + call l_glong2sp + ld hl,177 ;const + call l_glongsp ; + ld a,15 + call printf + ld hl,30 ;const + add hl,sp + ld sp,hl + ld hl,10 ;const + call sleep + ld hl,i_1+365 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,99 ;const + add hl,sp + push hl + ld hl,i_1+19 + push hl + call _pf_opendir + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_4 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_4 + ld hl,i_1+388 + push hl + ld a,1 + call printf + pop bc +.i_5 +.i_7 + ld hl,3 ;const + add hl,sp + push hl + ld hl,99 ;const + add hl,sp + push hl + ld hl,79 ;const + add hl,sp + push hl + call _pf_readdir + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_9 + ld hl,75 ;const + call l_gcharsp ; + call l_lneg + jr nc,i_8 +.i_9 + jp i_6 +.i_8 + ld hl,83 ;const + add hl,sp + ld a,+(16 % 256) + and (hl) + jp z,i_11 + ld hl,i_1+411 + push hl + ld hl,86 ;const + add hl,sp + push hl + ld a,2 + call printf + pop bc + pop bc + jp i_12 +.i_11 + ld hl,i_1+425 + push hl + ld hl,77 ;const + add hl,sp + call l_glong2sp + ld hl,90 ;const + add hl,sp + push hl + ld a,4 + call printf + pop bc + pop bc + pop bc + pop bc +.i_12 + jp i_5 +.i_6 + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_13 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_13 + ld hl,i_1+435 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,i_1+469 + push hl + call _pf_open + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_14 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_14 + ld hl,i_1+481 + push hl + ld a,1 + call printf + pop bc +.i_15 + ld hl,3 ;const + add hl,sp + push hl + ld hl,7 ;const + add hl,sp + push hl + ld hl,64 ;const + push hl + ld hl,77 ;const + add hl,sp + push hl + call _pf_read + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_18 + ld hl,71 ;const + call l_gintsp ; + call l_lneg + jr nc,i_17 +.i_18 + jp i_16 +.i_17 + ld hl,69 ;const + add hl,sp + ld de,0 ;const + ex de,hl + call l_pint + jp i_22 +.i_20 + ld hl,69 ;const + add hl,sp + inc (hl) + ld a,(hl) + inc hl + jr nz,ASMPC+3 + inc (hl) +.i_22 + ld hl,69 ;const + call l_gintspsp ; + ld hl,73 ;const + call l_gintsp ; + pop de + ex de,hl + and a + sbc hl,de + jp nc,i_21 + ld hl,5 ;const + add hl,sp + ex de,hl + ld hl,69 ;const + call l_gintsp ; + add hl,de + ld a,(hl) + cp 13 + jp z,i_23 + ld hl,5 ;const + add hl,sp + ex de,hl + ld hl,69 ;const + call l_gintsp ; + add hl,de + ld l,(hl) + ld h,0 + push hl + ld hl,__sgoioblk+10 + push hl + call fputc_callee +.i_23 + jp i_20 +.i_21 + jp i_15 +.i_16 + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_24 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_24 + ld hl,20 ;const + call sleep + ld hl,i_1+506 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,i_1+543 + push hl + call _pf_open + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_25 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_25 + ld hl,i_1+554 + push hl + ld a,1 + call printf + pop bc +.i_26 +.i_28 + ld hl,3 ;const + add hl,sp + push hl + ld hl,i_1+590 + push hl + ld hl,14 ;const + push hl + ld hl,79 ;const + add hl,sp + push hl + call _pf_write + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp nz,i_30 + ld hl,73 ;const + call l_gintsp ; + call l_lneg + jr nc,i_29 +.i_30 + jp i_27 +.i_29 + jp i_26 +.i_27 + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_32 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_32 + ld hl,i_1+605 + push hl + ld a,1 + call printf + pop bc + ld hl,3 ;const + add hl,sp + push hl + ld hl,0 ;const + push hl + push hl + ld hl,79 ;const + add hl,sp + push hl + call _pf_write + pop bc + pop bc + pop bc + call l_pint_pop + ld hl,3 ;const + call l_gintsp ; + ld a,h + or l + jp z,i_33 + ld hl,3 ;const + call l_gintsp ; + push hl + call _die + pop bc +.i_33 + ld hl,i_1+641 + push hl + ld a,1 + call printf + pop bc +.i_34 +.i_36 + jp i_34 +.i_35 + ld hl,155 ;const + add hl,sp + ld sp,hl + ret + + + SECTION rodata_compiler +.i_1 + defm "Failed with rc=%u." + defb 10 + + defm "" + defb 0 + + defm "Please press reset." + defb 10 + + defm "" + defb 0 + + defm "Hello Philip, this C program i" + defm "s working...." + defb 10 + + defm "" + defb 0 + + defm "Firstly, initialise SD card" + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Now Mount a volume." + defb 10 + + defm "" + defb 0 + + defm "Failed to initialise sd card 0" + defm ", please init manually." + defb 10 + + defm "" + defb 0 + + defm "Volume mounted." + defb 10 + + defm "" + defb 0 + + defm "FSTYPE:%d, FLAG:%d, CSIZE:%d, " + defm "PADL:%d, N_FATENT:%ld, FATBASE" + defm ":%;d" + defb 10 + + defm "" + defb 0 + + defm "DIRBASE:%ld, DATABASE:%ld, FPT" + defm "R:%ld, FSIZE:%ld, ORG_CLUST:%l" + defm "d, CURR_CLUST:%ld, DSECT:%ld" + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Open root directory." + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Directory listing..." + defb 10 + + defm "" + defb 0 + + defm " %s" + defb 10 + + defm "" + defb 0 + + defm "%8lu %s" + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Open a test file (message.txt)" + defm "." + defb 10 + + defm "" + defb 0 + + defm "MESSAGE.TXT" + defb 0 + + defm "" + defb 10 + + defm "Type the file content." + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Open a file to write (readme.t" + defm "xt)." + defb 10 + + defm "" + defb 0 + + defm "README.TXT" + defb 0 + + defm "" + defb 10 + + defm "Write a text data. (Hello worl" + defm "d!)" + defb 10 + + defm "" + defb 0 + + defm "Hello world!" + defb 13 + + defm "" + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Terminate the file write proce" + defm "ss." + defb 10 + + defm "" + defb 0 + + defm "" + defb 10 + + defm "Test completed." + defb 10 + + defm "" + defb 0 + + +; --- Start of Static Variables --- + + SECTION bss_compiler +._FatFs defs 2 + SECTION code_compiler + + +; --- Start of Scope Defns --- + + GLOBAL open + GLOBAL creat + GLOBAL close + GLOBAL read + GLOBAL write + GLOBAL lseek + GLOBAL readbyte + GLOBAL writebyte + GLOBAL getcwd + GLOBAL chdir + GLOBAL getwd + GLOBAL rmdir + GLOBAL _RND_BLOCKSIZE + GLOBAL rnd_loadblock + GLOBAL rnd_saveblock + GLOBAL rnd_erase + GLOBAL __FOPEN_MAX + GLOBAL __sgoioblk + GLOBAL __sgoioblk_end + GLOBAL fopen_zsock + GLOBAL fopen + GLOBAL freopen + GLOBAL fdopen + GLOBAL _freopen1 + GLOBAL fmemopen + GLOBAL funopen + GLOBAL fclose + GLOBAL fflush + GLOBAL closeall + GLOBAL fgets + GLOBAL fputs + GLOBAL fputc + GLOBAL fputs_callee + GLOBAL fputc_callee + GLOBAL fgetc + GLOBAL ungetc + GLOBAL feof + GLOBAL ferror + GLOBAL puts + GLOBAL ftell + GLOBAL fgetpos + GLOBAL fseek + GLOBAL fread + GLOBAL fwrite + GLOBAL gets + GLOBAL printf + GLOBAL fprintf + GLOBAL sprintf + GLOBAL snprintf + GLOBAL vfprintf + GLOBAL vsnprintf + GLOBAL printn + GLOBAL scanf + GLOBAL fscanf + GLOBAL sscanf + GLOBAL vfscanf + GLOBAL vsscanf + GLOBAL getarg + GLOBAL fchkstd + GLOBAL fgetc_cons + GLOBAL fgetc_cons_inkey + GLOBAL fputc_cons + GLOBAL fgets_cons + GLOBAL puts_cons + GLOBAL fabandon + GLOBAL fdtell + GLOBAL fdgetpos + GLOBAL rename + GLOBAL remove + GLOBAL getk + GLOBAL getk_inkey + GLOBAL printk + GLOBAL perror + GLOBAL atoi + GLOBAL atol + GLOBAL itoa + GLOBAL itoa_callee + GLOBAL ltoa + GLOBAL ltoa_callee + GLOBAL strtol + GLOBAL strtol_callee + GLOBAL strtoul + GLOBAL strtoul_callee + GLOBAL ultoa + GLOBAL ultoa_callee + GLOBAL utoa + GLOBAL utoa_callee + GLOBAL rand + GLOBAL srand + GLOBAL mallinit + GLOBAL sbrk + GLOBAL sbrk_callee + GLOBAL calloc + GLOBAL calloc_callee + GLOBAL free + GLOBAL malloc + GLOBAL realloc + GLOBAL realloc_callee + GLOBAL mallinfo + GLOBAL mallinfo_callee + GLOBAL HeapCreate + GLOBAL HeapSbrk + GLOBAL HeapSbrk_callee + GLOBAL HeapCalloc + GLOBAL HeapCalloc_callee + GLOBAL HeapFree + GLOBAL HeapFree_callee + GLOBAL HeapAlloc + GLOBAL HeapAlloc_callee + GLOBAL HeapRealloc + GLOBAL HeapRealloc_callee + GLOBAL HeapInfo + GLOBAL HeapInfo_callee + GLOBAL exit + GLOBAL atexit + GLOBAL getopt + GLOBAL _optarg + GLOBAL _opterr + GLOBAL _optind + GLOBAL _optopt + GLOBAL _optreset + GLOBAL l_bsearch + GLOBAL l_bsearch_callee + GLOBAL l_qsort + GLOBAL l_qsort_callee + GLOBAL qsort_sccz80 + GLOBAL qsort_sccz80_callee + GLOBAL qsort_sdcc + GLOBAL qsort_sdcc_callee + GLOBAL _div_ + GLOBAL _div__callee + GLOBAL _divu_ + GLOBAL _divu__callee + GLOBAL _ldiv_ + GLOBAL _ldiv__callee + GLOBAL _ldivu_ + GLOBAL _ldivu__callee + GLOBAL abs + GLOBAL labs + GLOBAL isqrt + GLOBAL inp + GLOBAL outp + GLOBAL outp_callee + GLOBAL swapendian + GLOBAL bpoke + GLOBAL bpoke_callee + GLOBAL wpoke + GLOBAL wpoke_callee + GLOBAL bpeek + GLOBAL wpeek + GLOBAL t_delay + GLOBAL sleep + GLOBAL msleep + GLOBAL extract_bits + GLOBAL extract_bits_callee + GLOBAL wcmatch + GLOBAL unbcd + GLOBAL _pf_mount + GLOBAL _pf_open + GLOBAL _pf_read + GLOBAL _pf_write + GLOBAL _pf_lseek + GLOBAL _pf_opendir + GLOBAL _pf_readdir + GLOBAL _FatFs + GLOBAL _disk_initialize + GLOBAL _disk_readp + GLOBAL _disk_writep + GLOBAL _die + GLOBAL _main + + +; --- End of Scope Defns --- + + +; --- End of Compilation --- diff --git a/software/src/PetitFS/sdtest.c b/software/src/PetitFS/sdtest.c new file mode 100644 index 0000000..dc3e8c2 --- /dev/null +++ b/software/src/PetitFS/sdtest.c @@ -0,0 +1,122 @@ +/*----------------------------------------------------------------------*/ +/* Petit FatFs sample project for generic uC (C)ChaN, 2010 */ +/*----------------------------------------------------------------------*/ + +#include +#include +#include "pff.h" +#include "sdmmc.h" + +FATFS *FatFs; /* Pointer to the file system object (logical drive) */ +extern BYTE SDBUF[]; + +void die ( /* Stop with dying message */ + FRESULT rc /* FatFs return value */ +) +{ + printf("Failed with rc=%u.\n", rc); + printf("Please press reset.\n"); + sleep(10); + for (;;) ; +} + +/*-----------------------------------------------------------------------*/ +/* Program Main */ +/*-----------------------------------------------------------------------*/ + +int main (void) +{ + FATFS fatfs; /* File system object */ + DIR dir; /* Directory object */ + FILINFO fno; /* File information object */ + UINT bw, br, i; + BYTE buff[64]; + FRESULT rc; /* FatFs return value */ + unsigned char idx; + unsigned char b; + unsigned char ib; + + printf("Petit FatFS Test Program, Sharp MZ80A\n"); + + printf("Firstly, initialise SD card\n"); + rc = FR_NOT_ENABLED; + DSTATUS res = disk_initialize(); + if(!res) + { + printf("\nNow Mount a volume.\n"); + rc = pf_mount(&fatfs); + if (rc) + { + printf("Failed to initialise sd card 0, please init manually.\n"); + die(rc); + } else + { + printf("Volume mounted.\n"); + } + } else + { + printf("Failed disk initialise, RES=%02x.\n", res); + die(res); + } + BYTE *p = SDBUF; + for(i = 0; i < 11; i++) + printf("%02x", *p++); + printf("\n"); + printf("SDVER:%02x, SDCAP:%02x\n", SDVER, SDCAP); + sleep(1); + + printf("FSTYPE:%d, FLAG:%d, CSIZE:%d, PADL:%d, N_FATENT:%ld, FATBASE:%;d\n", fatfs.fs_type, fatfs.flag, fatfs.csize, fatfs.pad1, fatfs.n_fatent, fatfs.fatbase); + printf("DIRBASE:%ld, DATABASE:%ld, FPTR:%ld, FSIZE:%ld, ORG_CLUST:%ld, CURR_CLUST:%ld, DSECT:%ld\n", fatfs.dirbase, fatfs.database,fatfs.fptr, fatfs.fsize, fatfs.org_clust, fatfs.curr_clust, fatfs.dsect); + sleep(1); + + printf("\nOpen root directory.\n"); + rc = pf_opendir(&dir, ""); + if (rc) die(rc); + + printf("\nDirectory listing...\n"); + for (;;) { + rc = pf_readdir(&dir, &fno); /* Read a directory item */ + if (rc || !fno.fname[0]) break; /* Error or end of dir */ + if (fno.fattrib & AM_DIR) + printf(" %s\n", fno.fname); + else + printf("%8lu %s\n", fno.fsize, fno.fname); + } + if (rc && rc != FR_NO_FILE) die(rc); + + printf("\nOpen file to read (message.txt).\n"); + rc = pf_open("MESSAGE.TXT"); + if (rc) die(rc); + + printf("\nOutput contents.\n"); + while(1) + { + rc = pf_read(buff, sizeof(buff), &br); /* Read a chunk of file */ + if (rc || !br) break; /* Error or end of file */ + for (i = 0; i < br; i++) /* Type the data */ + if(buff[i] != 0x0d) + putchar(buff[i]); + } + if (rc) die(rc); + + sleep(5); + + printf("\nOpen file to write (readme.txt).\n"); + rc = pf_open("README.TXT"); + if (rc) die(rc); + + printf("\nWrite some repetitive text. (Hello world!)\n"); + for (;;) { + rc = pf_write("Hello world!\r\n", 14, &bw); + if (rc || !bw) break; + } + if (rc) die(rc); + + printf("\nClose the file.\n"); + rc = pf_write(0, 0, &bw); + if (rc) die(rc); + + + printf("\nTest completed.\n"); + for (;;) ; +} diff --git a/software/src/PetitFS/sdtest.cmp b/software/src/PetitFS/sdtest.cmp new file mode 100644 index 0000000..3e99d39 Binary files /dev/null and b/software/src/PetitFS/sdtest.cmp differ diff --git a/software/src/PetitFS/sdtest.mzt b/software/src/PetitFS/sdtest.mzt new file mode 100644 index 0000000..0045847 Binary files /dev/null and b/software/src/PetitFS/sdtest.mzt differ diff --git a/software/src/PetitFS/test.asm b/software/src/PetitFS/test.asm new file mode 100644 index 0000000..5e0cebb --- /dev/null +++ b/software/src/PetitFS/test.asm @@ -0,0 +1,66 @@ +;-------------------------------------------------------- +; File Created by SDCC : free open source ANSI-C Compiler +; Version 4.0.0 #11528 (Linux) +;-------------------------------------------------------- + .module test + .optsdcc -mz80 + +;-------------------------------------------------------- +; Public variables in this module +;-------------------------------------------------------- + .globl _main +;-------------------------------------------------------- +; special function registers +;-------------------------------------------------------- +;-------------------------------------------------------- +; ram data +;-------------------------------------------------------- + .area _DATA +;-------------------------------------------------------- +; ram data +;-------------------------------------------------------- + .area _INITIALIZED +;-------------------------------------------------------- +; absolute external ram data +;-------------------------------------------------------- + .area _DABS (ABS) +;-------------------------------------------------------- +; global & static initialisations +;-------------------------------------------------------- + .area _HOME + .area _GSINIT + .area _GSFINAL + .area _GSINIT +;-------------------------------------------------------- +; Home +;-------------------------------------------------------- + .area _HOME + .area _HOME +;-------------------------------------------------------- +; code +;-------------------------------------------------------- + .area _CODE +;test.c:3: int main() +; --------------------------------- +; Function main +; --------------------------------- +_main:: +;test.c:7: for ( a = 0; a < 10; a++ ) + ld bc, #0x000a +00104$: + ld e, c + ld d, b + dec de + ld c, e + ld b, d + ld a, d + or a, e + jp NZ, 00104$ +;test.c:11: return 0; + ld hl, #0x0000 +00105$: +;test.c:12: } + ret + .area _CODE + .area _INITIALIZER + .area _CABS (ABS) diff --git a/software/src/PetitFS/test.c b/software/src/PetitFS/test.c new file mode 100644 index 0000000..965e8eb --- /dev/null +++ b/software/src/PetitFS/test.c @@ -0,0 +1,12 @@ +#include + +int main() +{ + int a; + + for ( a = 0; a < 10; a++ ) + { + } + + return 0; +} diff --git a/software/src/PetitFS/zcc_opt.def b/software/src/PetitFS/zcc_opt.def new file mode 100644 index 0000000..d6e6b54 --- /dev/null +++ b/software/src/PetitFS/zcc_opt.def @@ -0,0 +1,8 @@ + +IF !DEFINED_REGISTER_SP + defc DEFINED_REGISTER_SP = 1 + defc REGISTER_SP = 53248 + IFNDEF REGISTER_SP + ENDIF +ENDIF + diff --git a/software/tools/make_cpmdisks.sh b/software/tools/make_cpmdisks.sh index 9324f35..bdbc9be 100755 --- a/software/tools/make_cpmdisks.sh +++ b/software/tools/make_cpmdisks.sh @@ -34,7 +34,7 @@ # These two variables configure which CPM images and disks to build. If only 1 CPM_RFS ROM Drive is needed, # remove it fro the lists. #BUILDCPMLIST="cpm22 CPM_RFS_1" -BUILDCPMLIST="cpm22 CPM_RFS_1 CPM_RFS_2" +BUILDCPMLIST="cpm22 CPM_RFS_1 CPM_RFS_2 sdtest" #SOURCEDIRS="CPM_RFS_[1] CPM[0-9][0-9]_* CPM_MC_5 CPM_MC_C? CPM_MC_D? CPM_MC_E? CPM_MC_F? CPM[0-9][0-9]_MZ800*" SOURCEDIRS="CPM_RFS_[1-2] CPM[0-9][0-9]_* CPM_MC_5 CPM_MC_C? CPM_MC_D? CPM_MC_E? CPM_MC_F? CPM[0-9][0-9]_MZ800*" diff --git a/software/tools/make_roms.sh b/software/tools/make_roms.sh index c36aa44..a550151 100755 --- a/software/tools/make_roms.sh +++ b/software/tools/make_roms.sh @@ -36,8 +36,10 @@ ROM_PATH=${ROOTDIR}/software/roms/ SECTORSIZE=256 # Place the RFS rom into the User ROM at the beginning as it contains all the banked pages. -echo "cat ${ROM_PATH}/rfs.rom > /tmp/user.rom" -cat ${ROM_PATH}/rfs.rom ${ROM_PATH}/cbios_bank1.rom ${ROM_PATH}/cbios_bank2.rom ${ROM_PATH}/cbios_bank3.rom ${ROM_PATH}/cbios_bank4.rom > /tmp/user.rom +echo "cat ${ROM_PATH}/rfs.rom ${ROM_PATH}/cbios_bank1.rom ${ROM_PATH}/cbios_bank2.rom ${ROM_PATH}/cbios_bank3.rom ${ROM_PATH}/cbios_bank4.rom > /tmp/user.rom" +cat ${ROM_PATH}/rfs.rom ${ROM_PATH}/cbios_bank1.rom ${ROM_PATH}/cbios_bank2.rom \ + ${ROM_PATH}/cbios_bank3.rom ${ROM_PATH}/cbios_bank4.rom \ + > /tmp/user.rom # CPM RFS Disks currently only in User ROM. for f in 1 2 @@ -49,14 +51,19 @@ do done # Place the monitor roms into the MROM at the beginning for banked page usage. -echo "cat ${ROM_PATH}/monitor_SA1510.rom ${ROM_PATH}/monitor_80c_SA1510.rom ${ROM_PATH}/cbios.rom ${ROM_PATH}/rfs_mrom.rom > /tmp/mrom.rom" -cat ${ROM_PATH}/monitor_SA1510.rom ${ROM_PATH}/monitor_80c_SA1510.rom ${ROM_PATH}/cbios.rom ${ROM_PATH}/rfs_mrom.rom > /tmp/mrom.rom +echo "cat ${ROM_PATH}/monitor_SA1510.rom ${ROM_PATH}/monitor_80c_SA1510.rom ${ROM_PATH}/cbios.rom ${ROM_PATH}/rfs_mrom.rom ${ROM_PATH}/blank_mrom.rom ${ROM_PATH}/blank_mrom.rom ${ROM_PATH}/blank_mrom.rom ${ROM_PATH}/blank_mrom.rom > /tmp/mrom.rom" +cat ${ROM_PATH}/monitor_SA1510.rom ${ROM_PATH}/monitor_80c_SA1510.rom \ + ${ROM_PATH}/cbios.rom ${ROM_PATH}/rfs_mrom.rom \ + ${ROM_PATH}/blank_mrom.rom ${ROM_PATH}/blank_mrom.rom \ + ${ROM_PATH}/blank_mrom.rom ${ROM_PATH}/blank_mrom.rom \ + > /tmp/mrom.rom GENROM=0 # Manually choose the programs you want installed into the ROMS. The files will be first placed into the USER ROM and when full into the # Monitor ROM. Thus order is important if you want a particular program in a particular ROM. ROM_INCLUDE= ROM_INCLUDE+="${MZB_PATH}/cpm22.${SECTORSIZE}.bin:" +ROM_INCLUDE+="${MZB_PATH}/sdtest.${SECTORSIZE}.bin:" ##ROM_INCLUDE+="${MZB_PATH}/1Z-013B.${SECTORSIZE}.bin:" ##ROM_INCLUDE+="${MZB_PATH}/2Z009E.${SECTORSIZE}.bin:" ##ROM_INCLUDE+="${MZB_PATH}/2z-046a.${SECTORSIZE}.bin:" @@ -83,7 +90,7 @@ ROM_INCLUDE+="${MZB_PATH}/BASIC_OM-1000.${SECTORSIZE}.bin:" ROM_INCLUDE+="${MZB_PATH}/BASIC_OM-1001.${SECTORSIZE}.bin:" ROM_INCLUDE+="${MZB_PATH}/BASIC_OM-500.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/basic_sa-5510.${SECTORSIZE}.bin:" -#ROM_INCLUDE+="${MZB_PATH}/BASIC.SA-5510.${SECTORSIZE}.bin:" +ROM_INCLUDE+="${MZB_PATH}/BASIC.SA-5510.${SECTORSIZE}.bin:" ROM_INCLUDE+="${MZB_PATH}/BASIC SA-5575_C.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/BASIC_SA-5575_C.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/BASIC SA-5575_S.${SECTORSIZE}.bin:" @@ -102,7 +109,7 @@ ROM_INCLUDE+="${MZB_PATH}/BAS_MOD_v3.74.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/BINARY_COUNT.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/BYTESAVER SA5510.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/BYTESAVER_SA5510.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/CIRCUS_STAR.${SECTORSIZE}.bin:" +#ROM_INCLUDE+="${MZB_PATH}/CIRCUS_STAR.${SECTORSIZE}.bin:" ROM_INCLUDE+="${MZB_PATH}/clock1.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/CLUB COPY.U1.${SECTORSIZE}.bin:" ROM_INCLUDE+="${MZB_PATH}/CLUB_COPY.U1.${SECTORSIZE}.bin:" @@ -242,7 +249,7 @@ ROM_INCLUDE+="${MZB_PATH}/SARGON_2.71.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/SUTAMC9.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/SUTAPEBA.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/SUTAPEMO.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/TETRIS.${SECTORSIZE}.bin:" +#ROM_INCLUDE+="${MZB_PATH}/TETRIS.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/tetris-2_MZ800.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/TEXT_BASIC_I.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/TEXT~ED_v1.2.${SECTORSIZE}.bin:" @@ -250,7 +257,7 @@ ROM_INCLUDE+="${MZB_PATH}/TETRIS.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/TRANS.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/ufo.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/UNI=BASIC800.${SECTORSIZE}.bin:" -ROM_INCLUDE+="${MZB_PATH}/UNIVERSAL_BASIC.${SECTORSIZE}.bin:" +#ROM_INCLUDE+="${MZB_PATH}/UNIVERSAL_BASIC.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/URAS-700.${SECTORSIZE}.bin:" ROM_INCLUDE+="${MZB_PATH}/Utility_2.${SECTORSIZE}.bin:" #ROM_INCLUDE+="${MZB_PATH}/Utility_V_1.1.${SECTORSIZE}.bin:" @@ -280,7 +287,9 @@ do else GENROM=1 fi - else + fi + + if (( ${GENROM} == 1 )); then cat /tmp/mrom.rom "${f}" > /tmp/tmp.size FILESIZE=$(stat -c%s "/tmp/tmp.size") if (( ${FILESIZE} < 524288 )); then @@ -290,10 +299,13 @@ do GENROM=2 fi fi + if (( ${GENROM} == 2 )); then echo "Limit reached ROMS full, skipping from ${f}..." break fi + else + echo "ALERT! File:${f} not found." fi done if [ -f /tmp/user.rom ]; then