├── BDSHELL ├── DOC │ └── BDSHELL.TXT ├── Makefile ├── OUTPUT │ ├── BDSHELL.BIN │ ├── BDSHELL.CAS │ ├── BDSHELL.COM │ └── BDSHELL.ROM ├── README.md └── SRC │ ├── BADCAT.Z8A │ ├── BBDSHELL.Z8A │ ├── BDSHELL.Z8A │ ├── CBDSHELL.Z8A │ ├── CONST.Z8A │ ├── DBDSHELL.Z8A │ ├── GENERIC.Z8A │ ├── GVARS.Z8A │ ├── HARD.Z8A │ ├── INTER.Z8A │ ├── KEYJOY.Z8A │ ├── PRINT.Z8A │ ├── PROGRAM.Z8A │ ├── RAM.Z8A │ ├── ROM.Z8A │ ├── SLOT.Z8A │ ├── TABLES.Z8A │ ├── UART.Z8A │ └── VARS.Z8A ├── BDTERM ├── BDterm.asm ├── BDterm.bin └── README.md ├── COPYING ├── ERIX.COM ├── Readme.md ├── TELNETF ├── README.MD └── Telnetf.com ├── UNAPI ├── Readme.md ├── badcat_config.com ├── bcunapi.com └── sources │ ├── badcat.h │ ├── definitions.h │ ├── display.h │ ├── fcb.h │ ├── main.c │ ├── nifi.h │ ├── uart.h │ └── utils.h ├── badcat_documentation.pdf ├── badcats.jpg ├── driver.com └── http_server.py /BDSHELL/DOC/BDSHELL.TXT: -------------------------------------------------------------------------------- 1 | ---------------------------- 2 | BDShell BadCat Terminal v1.0 3 | (c) 2020 Armando Perez 4 | 5 | Based on previous work of: 6 | Andres Ortiz 7 | Oduvaldo Pavan Junior 8 | ---------------------------- 9 | 10 | 11 | ---- CONTENTS ---- 12 | 13 | 1.- INTRODUCTION AND FEATURES 14 | 15 | 2.- BINARY FILES. 16 | 17 | 3.- SETUP BADCAT WIFI CONNECTION 18 | 19 | 4.- CONNECT TO A BBS. 20 | 21 | 5.- FILESYSTEM AND INTERNET REPOSITORY 22 | 5.1.- CONFIGURE INTERNET REPOSITORY 23 | 5.2.- DOWNLOAD FILES FROM INTERNET REPOSITORY 24 | 25 | 6.- LOAD ROM FILES 26 | 27 | 7.- BADCAT OTA UPDATES 28 | 29 | 8.- RS232 PORT 30 | 31 | 9.- SUMMARY OF BADCAT COMMANDS 32 | 33 | 10.- SOURCE FILES / ASSEMBLING BDSHELL 34 | 35 | 11.- THANKS TO... 36 | 37 | ---- CONTENTS ---- 38 | 39 | 40 | 41 | 42 | 1.- INTRODUCTION AND FEATURES 43 | 44 | BDShell is a shell/terminal program intented for programming and handling the 45 | MSX BaDCat Wifi Cards. 46 | 47 | It includes next features: 48 | 49 | * Mininum requirements: MSX with 8k RAM. 50 | * Presented in 4 formats: DOS command (.COM), ROM version, MSX-BASIC BLOAD 51 | Binary version (.BIN) and cassette version (.CAS). 52 | * Fast and compatible telnet terminal program. 53 | 54 | 55 | 56 | 57 | 2.- BINARY FILES. 58 | 59 | BDShell is presented in several formats: 60 | 61 | - BDSHELL.BIN: Basic Binary file. Needs 16k of RAM to run. Type 62 | 63 | - BDSHELL.COM: MSX-DOS Command. Needs 64k of RAM to run. 64 | 65 | - BDSHELL.ROM: ROM file. Needs 8k of RAM to run. 66 | 67 | - BDSHELL.CAS: Cassette file. Similar to BDSHELL.BIN 68 | 69 | 70 | Choose your favorite format to run BDShell. Welcome screen will be displayed 71 | (40 columns on first generation MSX and 80 columns on MSX2 or higher). 72 | 73 | ------------------------------------------------------------------------------ 74 | 75 | BaDCaT Shell Terminal v1.0. 76 | (c) 2020 by Armando Perez 77 | 78 | Based on the original work of: 79 | Andres Ortiz & Oduvaldo Pavan Junior 80 | 81 | - System: 82 | - Ram: 83 | - Disk System: 84 | - BaDCat: 85 | 86 | - Initializing interrupt 87 | - Initializing UART 88 | 89 | Ready 90 | 91 | ------------------------------------------------------------------------------ 92 | 93 | 94 | Note: BDShell forces screen 0 and 40/80 columns but always keeps user colors. 95 | Please ensure your color configuration allow you read displayed texts. 96 | 97 | 98 | 99 | 100 | 3.- SETUP BADCAT WIFI CONNECTION 101 | 102 | Ensure the wifi switch is in the "ON" position. 103 | 104 | With BDShell running: 105 | 106 | - Type AT+CONFIG and press ENTER. The configuration menu will appear. 107 | - Then type WIFI and press ENTER. Wait until the received wifi networks 108 | appear. 109 | - Choose a wifi network. 110 | - Type the password of the wifi network and press ENTER 111 | - Press ENTER again an say YES to store changes. After a while this will 112 | exit the config mode and return to command mode. 113 | 114 | 115 | In command mode you can see your wifi network and the assigned IP by typing ATI 116 | and pressing ENTER. 117 | 118 | 119 | 120 | 121 | 4.- CONNECT TO A BBS. 122 | 123 | This section is an example on how to connect to a BBS using BDShell. For the 124 | example we will use Sotano MSX BBS. 125 | 126 | Ensure you're in command mode and: 127 | 128 | - Type ATD "sotanomsxbbsorg:23". 129 | - Choose the appropiate BBS profile. BDShell does not support ANSI: 130 | 131 | 132 | (0) Ascii (No Color) 133 | [0] MS-DOS CP437 134 | 135 | - Choose the profile: 136 | 137 | 1 (MSX2...) if you're running BDShell with MSX2 computer. 138 | 2 (MSX1...) if you're running BDShell with first generation MSX. 139 | 140 | 141 | 142 | 143 | 5.- FILESYSTEM AND INTERNET REPOSITORY 144 | 145 | BaDCat provides an extra local storage (ESP's flash) and the commands to handle 146 | it. Also we can configure an internet repository to load ROM files (Section 6) 147 | or download those files to the local storage. At this time you can only load ROM 148 | files from this local repository. More actions and commands will be added in the 149 | future, for example, load/save files from / to local storage or internet 150 | repository from / to local MSX storage (cassette, FDD, HD, SD...), read or edit 151 | local storage .TXT files, etc... 152 | 153 | 154 | 5.1.- CONFIGURE INTERNET REPOSITORY 155 | 156 | BadCat local storage filesystem comes factory configured. Internet repository 157 | needs and extra user configuration: 158 | 159 | - From BDShell command line type ATZ to ensure BaDCat is ready. "OK" 160 | should appear. 161 | - Type AT+CONFIG and press ENTER 162 | - Type repo and press ENTER 163 | - Enter the repository url and press ENTER. Warning: Only http (not 164 | https) is supported 165 | - Press ENTER again and accept changes. 166 | 167 | At this moment BaDCaT firmware needs and extra file configuration on your 168 | internet repository to be able to access files. This file must be named 169 | "filelist.txt". The filename will contain the files you want access from BaDCat 170 | as well as their length in following format: 171 | 172 | FILE1.EXTsize 173 | FILE2.EXTsize 174 | ... 175 | FILEX.EXTsize 176 | 177 | - FILEX.ROM is the name of file. 178 | - are two TABs (09) 179 | - size in bytes. 180 | 181 | Example: 182 | 183 | HERO16K.ROM 16384 184 | YIEARE.ROM 16384 185 | ALIBABA.ROM 16384 186 | BBOY.ROM 32768 187 | HERO.ROM 32768 188 | YIEARE2.ROM 32768 189 | ZANAC.ROM 32768 190 | EGGER.ROM 32768 191 | OPWOLF.ROM 49152 192 | MAJI.ROM 49152 193 | RLV933.ROM 49152 194 | TRITON.ROM 49152 195 | 196 | 197 | Now BaDCaT will be able to access those files both for download to local 198 | repository filesystem and load (simulate) ROM file. 199 | 200 | 201 | 5.2.- DOWNLOAD FILES FROM INTERNET REPOSITORY 202 | 203 | To enjoy the features of local filesytem firtly we need transfer files to this 204 | local repository. At this moment you can only transfer the files from your 205 | internet repository (above section). To transfer file from your internet 206 | repository follow this steps: 207 | 208 | - Type lfiles to ensure you've enough free space to download file 209 | - Type delete command if necessary to save and free space. 210 | - Type dload FILE.EXT to download file from your internet repository. Fille 211 | will transfer automatically from your internet repository to your local 212 | storage filesystem. 213 | - Type lfiles again to check if your file is correctly transfered to your 214 | local storage. 215 | 216 | 217 | 6.- LOAD ROM FILES 218 | 219 | One the most important BadCat features is the posibility of load ROMs files from 220 | internet repository simulating ROM cartridge on RAM memory. The feature 221 | downloads the ROM file data from internet (or local storage) to RAM and executes 222 | the RAM file. 223 | 224 | The feature works with ROM files from 8k up to 48k non-mapped (linear). Any 225 | other type of ROM file (custom mapper, megarom files, etc...) can't be 226 | simulated. 227 | 228 | There are, however, limitations to the simulation: 229 | 230 | - You need at least 64K of RAM to simulate the ROM files. Yes, you could run 231 | 8/16k ROM files with 32k of RAM but just a few 8/16k ROM files would work 232 | properly. 233 | 234 | - Since is a RAM simulation not all ROM files could be executed. The 235 | simulation could have problems to run or glitches in its execution. 236 | 237 | - Simulation of ROM files > 16k needs an specific memory environment: all 238 | pages of RAM must be on the same slot. For example: You've an MSX computer 239 | with 64k of RAM distributed in four 16k pages each of them in one 240 | different slot. Hypothetically your MSX has enough memory to emulate a 48k 241 | ROM file but a real ROM cartridge has *always* its pages in the same slot 242 | therefore the game would never work. 243 | 244 | - BaDCat Shell ROM version can't handle ROMs with disk access (like 245 | EGGERLAND MYSTERY or PERFECT FIT). Will be fixed in next version. If you 246 | want play these games and to use disk access, please, load binary, command 247 | or cassette version. 248 | 249 | Before load ROM file or download file to local storate we need access to 250 | internet ROM repository. See Section 5 on how to configure your local and internet 251 | repository. To load ROM file BaDCaT needs be able to access to this file from 252 | local storage filesystem or internet repository. 253 | 254 | Continuing with the example of internet repository (Section 5.1) let's start with 255 | the ROM simulation. 256 | 257 | * From internet repository: 258 | 259 | Warning: BaDCat needs be configured to access WIFI network to use this 260 | feature. 261 | 262 | - Type rload FILEX.EXT (eg: rload HERO.ROM) 263 | - "Press F1 to start download" message will appear in the screen. 264 | - Press to load ROM file or any command to continue and cancel. 265 | - If you press then next messages will appear in the screen: 266 | 267 | "Get file info..." 268 | "Loading xxxx bytes" 269 | 270 | - The file will load automatically. 271 | 272 | 273 | * From local storage filesystem: 274 | 275 | Warning: The file must be present in your local filesystem. (Section 5.2). You 276 | don't need internet connection to enjoy this feature. 277 | 278 | - Type load FILEX.EXT (eg: load MAJI.ROM) 279 | - "Press F1 to start download" message will appear in the screen. 280 | - Press to load ROM file or any command to continue and cancel. 281 | - If you press then next messages will appear in the screen: 282 | 283 | "Get file info..." 284 | "Loading xxxx bytes" 285 | 286 | - The file will load automatically. 287 | 288 | 289 | 290 | 291 | 7.- BADCAT OTA UPDATES 292 | 293 | From version 1.3 (comes factory configured) it's possible to upgrade BaDCaT 294 | firmware directly from internet 295 | 296 | 297 | - In command BDShell mode type AT&U. The version of the lastest available 298 | firmware will appear. 299 | - To upgrade type AT&U= and press ENTER (eg. AT&U=1.3) 300 | - This will take some time. After that, the BaDCaT will reboot and show the 301 | upgraded firmware (you can check with the ATI command). 302 | 303 | 304 | 305 | 306 | 8.- RS232 PORT 307 | 308 | BaDCaT provides a standard RS232 port mapped at #80 I/O port to provide 309 | compatibility with standard software such as Eric Mass Fossil Driver. 310 | 311 | To use the RS232 port, the wifi switch MUST BE IN THE OFF POSITION!! 312 | Hereafter, standard software can be used. Eric Maas ERIX terminal, is 313 | recommended, which works with his Fossil drive 314 | 315 | 316 | 317 | 318 | 9.- SUMMARY OF BADCAT COMMANDS 319 | 320 | Summary of commands you can introduce in command mode. 321 | 322 | - help: Show the help. 323 | 324 | * Related to connection: 325 | 326 | 327 | - AT+CONFIG: Enter configuration menu. 328 | 329 | - ATD"[HOSTNAME]:[PORT]": Open streaming connnection. 330 | 331 | - ATDT"[HOSTNAME]:[PORT]": Open TELNET connection 332 | 333 | - +++: With one second pause -> enter command mode. 334 | 335 | - ATZ: Close all open socket connections. 336 | 337 | - A/: Repeats previous command. 338 | 339 | - ATI2: Show modem's current IP address. 340 | 341 | - ATI3: Show modem's current wireless router connection 342 | 343 | - ATBn: Sets a new serial baud rate. Takes effect inmediately. 344 | 345 | - AT&W: Write changes to modem flash. BE SURE BEFORE DOING THIS! 346 | 347 | - ATC: Shows information about the curent network connection 348 | 349 | - ATH: Disconnect from the hosst. 350 | 351 | 352 | * Related to internet repository: 353 | 354 | - rfiles: Show files from internet repository 355 | 356 | - rload : load ROM file directly from internet repository 357 | 358 | * Related to local storage: 359 | 360 | - lfiles: Show the files in the storage system and the current free space 361 | 362 | - delete : Remove a file from local storage. 363 | 364 | - dload : Download a file from internet repository to the local storage 365 | 366 | - load : load ROM from local storage. 367 | 368 | 369 | 370 | 371 | 10.- SOURCE FILES / ASSEMBLING BDSHELL 372 | 373 | To assemble BDShell project you need Pipa Gerardo's SjasmPG assembler: 374 | 375 | https://github.com/pipagerardo/sjasmpg 376 | 377 | Also an *NIX environment system that support "make" build automation tool. For 378 | Windows you can install Cygwin or MinGW. 379 | 380 | The project is presented with this organization: 381 | 382 | Makefile 383 | | 384 | +-- DOC 385 | +-- OUTPUT 386 | +-- SRC 387 | 388 | - Makefile: Rules and directives for make tool. 389 | - DOC: Directory that contains this file. 390 | - OUTPUT: directory has preassembled / assembled binary BDShell files. 391 | - SRC: Source files. 392 | 393 | To assemble type "make". The binary files will be assembled automatically and 394 | stored in OUTPUT directory. 395 | 396 | An extra TMP folder will be created when you assemble the project. This temporal 397 | directory has intermediate files and typical output assembler files like .lst, 398 | lab... 399 | 400 | Type "make clean" to clean temporal files. 401 | Type "make cleanall" to clean temporal files and output files. 402 | 403 | 404 | 405 | 406 | 11.- THANKS TO... 407 | 408 | - Andrés Ortiz: For develop and build the awesome BadCaT card and help me with 409 | BDShell 410 | 411 | - Oduvaldo Pavan Junior (ducasp): For develop his open source TELNET tool. 412 | 413 | - x1Pepe, SYSOP of Sotano MSX BBS for test BDShell. 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | -------------------------------------------------------------------------------- /BDSHELL/Makefile: -------------------------------------------------------------------------------- 1 | # ************************************************************************* 2 | # * BadCat+ BDShell Terminal * 3 | # * (c) 2020 Armando Pérez * 4 | # ************************************************************************* 5 | 6 | .PHONY: build clean cleanall 7 | 8 | 9 | # ========================================================================= 10 | # CONSTANTS 11 | # ========================================================================= 12 | 13 | VARS = VARS.Z8A 14 | BDSHELL = BDSHELL.Z8A 15 | OUTPUT = BDSHELL 16 | ROM = $(BDSHELL) 17 | BIN = B$(BDSHELL) 18 | COM = D$(BDSHELL) 19 | CAS = C$(BDSHELL) 20 | ASM = sjasmpg -sp 21 | SHELL = /bin/bash 22 | 23 | # ========================================================================= 24 | # DIRECTORIES 25 | # ========================================================================= 26 | 27 | SRCDIR = SRC 28 | BINDIR = OUTPUT 29 | TMPDIR = TMP 30 | 31 | # ========================================================================= 32 | # DINAMIC VARS 33 | # ========================================================================= 34 | 35 | 36 | SOURCES = $(shell find $(SRCDIR) -type f ! -wholename "*.svn*" ! -wholename "*.DS_Store*" ! -regex "\./\..*" ! -regex "\." -name "*.Z8A") 37 | INCLUDES = -I$(SRCDIR)\ 38 | -I$(TMPDIR)\ 39 | -I. 40 | 41 | SETUP_DIR = $(BINDIR) $(TMPDIR) 42 | 43 | 44 | # ========================================================================= 45 | # OUTPUTS 46 | # ========================================================================= 47 | 48 | F_VARS = $(TMPDIR)/$(basename $(VARS)).sym 49 | 50 | 51 | F_OUTPUT = $(BINDIR)/$(basename $(OUTPUT)).ROM 52 | F_COUTPUT = $(BINDIR)/$(basename $(OUTPUT)).CAS 53 | F_BOUTPUT = $(BINDIR)/$(basename $(OUTPUT)).BIN 54 | F_DOUTPUT = $(BINDIR)/$(basename $(OUTPUT)).COM 55 | 56 | 57 | all: build 58 | 59 | 60 | # - CLEAN TARGET 61 | 62 | clean: 63 | @echo "Cleaning..." 64 | @$(RM) *.sym *.txt *.out 65 | @$(RM) $(BINDIR)/*.sym $(BINDIR)/*.sym $(BINDIR)/*.out 66 | @$(RM) -Rf $(TMPDIR) 67 | 68 | cleanall: clean 69 | @$(RM) -Rf $(SETUP_DIR) 70 | 71 | 72 | # - BUILD TARGET 73 | 74 | build: $(SETUP_DIR) $(F_OUTPUT) $(F_COUTPUT) $(F_BOUTPUT) $(F_DOUTPUT) 75 | 76 | 77 | # - DIRECTORIES TARGET 78 | 79 | $(SETUP_DIR): 80 | @echo "Creating directories -> $@" 81 | @mkdir -p $@ 82 | 83 | 84 | # - VARS TARGET 85 | 86 | $(F_VARS): $(SRCDIR)/VARS.Z8A $(SRCDIR)/GVARS.Z8A $(SRCDIR)/CONST.Z8A $(SRCDIR)/HARD.Z8A 87 | @echo "Creating .sym VARS file $@" 88 | @$(ASM) $(INCLUDES) VARS.Z8A $(basename $(VARS)).out 89 | @$(RM) $(basename $(VARS)).out 90 | @mv VARS.sym $(F_VARS) 91 | @mv VARS_lab.txt $(TMPDIR) 92 | @mv VARS_lst.txt $(TMPDIR) 93 | 94 | # - OUTPUT TARGET ROM 95 | 96 | $(F_OUTPUT): $(F_VARS) $(SOURCES) 97 | @echo "Assembling output file $@" 98 | @$(ASM) $(INCLUDES) $(ROM) $@ 99 | @mv $(BINDIR)/$(basename $(OUTPUT))_lab.txt $(TMPDIR)/$(basename $(OUTPUT))_lab.txt 100 | @mv $(BINDIR)/$(basename $(OUTPUT))_lst.txt $(TMPDIR)/$(basename $(OUTPUT))_lst.txt 101 | @mv $(BINDIR)/$(basename $(OUTPUT)).sym $(TMPDIR)/$(basename $(OUTPUT)).sym 102 | 103 | 104 | # - OUTPUT TARGET CAS 105 | 106 | $(F_COUTPUT): $(SOURCES) 107 | @echo "Assembling output file $@" 108 | @$(ASM) $(INCLUDES) $(CAS) $@ 109 | @mv $(BINDIR)/$(basename $(OUTPUT))_lab.txt $(TMPDIR)/C$(basename $(OUTPUT))_lab.txt 110 | @mv $(BINDIR)/$(basename $(OUTPUT))_lst.txt $(TMPDIR)/C$(basename $(OUTPUT))_lst.txt 111 | @mv $(BINDIR)/$(basename $(OUTPUT)).sym $(TMPDIR)/C$(basename $(OUTPUT)).sym 112 | 113 | 114 | # - OUTPUT TARGET BINARY 115 | 116 | $(F_BOUTPUT): $(SOURCES) 117 | @echo "Assembling output file $@" 118 | @$(ASM) $(INCLUDES) $(BIN) $@ 119 | @mv $(BINDIR)/$(basename $(OUTPUT))_lab.txt $(TMPDIR)/B$(basename $(OUTPUT))_lab.txt 120 | @mv $(BINDIR)/$(basename $(OUTPUT))_lst.txt $(TMPDIR)/B$(basename $(OUTPUT))_lst.txt 121 | @mv $(BINDIR)/$(basename $(OUTPUT)).sym $(TMPDIR)/B$(basename $(OUTPUT)).sym 122 | 123 | 124 | # - OUTPUT TARGET COM MSX-DOS 125 | 126 | $(F_DOUTPUT): $(SOURCES) 127 | @echo "Assembling output file $@" 128 | @$(ASM) $(INCLUDES) $(COM) $@ 129 | @mv $(BINDIR)/$(basename $(OUTPUT))_lab.txt $(TMPDIR)/D$(basename $(OUTPUT))_lab.txt 130 | @mv $(BINDIR)/$(basename $(OUTPUT))_lst.txt $(TMPDIR)/D$(basename $(OUTPUT))_lst.txt 131 | @mv $(BINDIR)/$(basename $(OUTPUT)).sym $(TMPDIR)/D$(basename $(OUTPUT)).sym 132 | 133 | 134 | log: 135 | @echo $(SOURCES) 136 | 137 | -------------------------------------------------------------------------------- /BDSHELL/OUTPUT/BDSHELL.BIN: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andortizg/BaDCaT/5e321ebff3070e16e81371c0cd775e3ef04841e4/BDSHELL/OUTPUT/BDSHELL.BIN -------------------------------------------------------------------------------- /BDSHELL/OUTPUT/BDSHELL.CAS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andortizg/BaDCaT/5e321ebff3070e16e81371c0cd775e3ef04841e4/BDSHELL/OUTPUT/BDSHELL.CAS -------------------------------------------------------------------------------- /BDSHELL/OUTPUT/BDSHELL.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andortizg/BaDCaT/5e321ebff3070e16e81371c0cd775e3ef04841e4/BDSHELL/OUTPUT/BDSHELL.COM -------------------------------------------------------------------------------- /BDSHELL/OUTPUT/BDSHELL.ROM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andortizg/BaDCaT/5e321ebff3070e16e81371c0cd775e3ef04841e4/BDSHELL/OUTPUT/BDSHELL.ROM -------------------------------------------------------------------------------- /BDSHELL/README.md: -------------------------------------------------------------------------------- 1 | BDShell BadCat Terminal v1.0 2 | (c) 2020 Armando Perez 3 | 4 | Based on previous work of: Andres Ortiz & Oduvaldo Pavan Junior 5 | 6 | 7 | --- CONTENTS ---- 8 | 9 | 1.- INTRODUCTION AND FEATURES 10 | 11 | 2.- BINARY FILES. 12 | 13 | 3.- SETUP BADCAT WIFI CONNECTION 14 | 15 | 4.- CONNECT TO A BBS. 16 | 17 | 5.- FILESYSTEM AND INTERNET REPOSITORY 18 | 5.1.- CONFIGURE INTERNET REPOSITORY 19 | 5.2.- DOWNLOAD FILES FROM INTERNET REPOSITORY 20 | 21 | 6.- LOAD ROM FILES 22 | 23 | 7.- BADCAT OTA UPDATES 24 | 25 | 8.- RS232 PORT 26 | 27 | 9.- SUMMARY OF BADCAT COMMANDS 28 | 29 | 10.- SOURCE FILES / ASSEMBLING BDSHELL 30 | 31 | 11.- THANKS TO... 32 | 33 | ---- CONTENTS ---- 34 | 35 | 36 | 37 | 38 | 1.- INTRODUCTION AND FEATURES 39 | 40 | BDShell is a shell/terminal program intented for programming and handling the 41 | MSX BaDCat Wifi Cards. 42 | 43 | It includes next features: 44 | 45 | * Mininum requirements: MSX with 8k RAM. 46 | * Presented in 4 formats: DOS command (.COM), ROM version, MSX-BASIC BLOAD 47 | Binary version (.BIN) and cassette version (.CAS). 48 | * Fast and compatible telnet terminal program. 49 | 50 | 51 | 52 | 53 | 2.- BINARY FILES. 54 | 55 | BDShell is presented in several formats: 56 | 57 | - BDSHELL.BIN: Basic Binary file. Needs 16k of RAM to run. Type 58 | 59 | - BDSHELL.COM: MSX-DOS Command. Needs 64k of RAM to run. 60 | 61 | - BDSHELL.ROM: ROM file. Needs 8k of RAM to run. 62 | 63 | - BDSHELL.CAS: Cassette file. Similar to BDSHELL.BIN 64 | 65 | 66 | Choose your favorite format to run BDShell. Welcome screen will be displayed 67 | (40 columns on first generation MSX and 80 columns on MSX2 or higher). 68 | 69 | ------------------------------------------------------------------------------ 70 | 71 | BaDCaT Shell Terminal v1.0. 72 | (c) 2020 by Armando Perez 73 | 74 | Based on the original work of: 75 | Andres Ortiz & Oduvaldo Pavan Junior 76 | 77 | - System: 78 | - Ram: 79 | - Disk System: 80 | - BaDCat: 81 | 82 | - Initializing interrupt 83 | - Initializing UART 84 | 85 | Ready 86 | 87 | ------------------------------------------------------------------------------ 88 | 89 | 90 | Note: BDShell forces screen 0 and 40/80 columns but always keeps user colors. 91 | Please ensure your color configuration allow you read displayed texts. 92 | 93 | 94 | 95 | 96 | 3.- SETUP BADCAT WIFI CONNECTION 97 | 98 | Ensure the wifi switch is in the "ON" position. 99 | 100 | With BDShell running: 101 | 102 | - Type AT+CONFIG and press ENTER. The configuration menu will appear. 103 | - Then type WIFI and press ENTER. Wait until the received wifi networks 104 | appear. 105 | - Choose a wifi network. 106 | - Type the password of the wifi network and press ENTER 107 | - Press ENTER again an say YES to store changes. After a while this will 108 | exit the config mode and return to command mode. 109 | 110 | 111 | In command mode you can see your wifi network and the assigned IP by typing ATI 112 | and pressing ENTER. 113 | 114 | 115 | 116 | 117 | 4.- CONNECT TO A BBS. 118 | 119 | This section is an example on how to connect to a BBS using BDShell. For the 120 | example we will use Sotano MSX BBS. 121 | 122 | Ensure you're in command mode and: 123 | 124 | - Type ATD "sotanomsxbbsorg:23". 125 | - Choose the appropiate BBS profile. BDShell does not support ANSI: 126 | 127 | 128 | (0) Ascii (No Color) 129 | [0] MS-DOS CP437 130 | 131 | - Choose the profile: 132 | 133 | 1 (MSX2...) if you're running BDShell with MSX2 computer. 134 | 2 (MSX1...) if you're running BDShell with first generation MSX. 135 | 136 | 137 | 138 | 139 | 5.- FILESYSTEM AND INTERNET REPOSITORY 140 | 141 | BaDCat provides an extra local storage (ESP's flash) and the commands to handle 142 | it. Also we can configure an internet repository to load ROM files (Section 6) 143 | or download those files to the local storage. At this time you can only load ROM 144 | files from this local repository. More actions and commands will be added in the 145 | future, for example, load/save files from / to local storage or internet 146 | repository from / to local MSX storage (cassette, FDD, HD, SD...), read or edit 147 | local storage .TXT files, etc... 148 | 149 | 150 | 5.1.- CONFIGURE INTERNET REPOSITORY 151 | 152 | BadCat local storage filesystem comes factory configured. Internet repository 153 | needs and extra user configuration: 154 | 155 | - From BDShell command line type ATZ to ensure BaDCat is ready. "OK" 156 | should appear. 157 | - Type AT+CONFIG and press ENTER 158 | - Type repo and press ENTER 159 | - Enter the repository url and press ENTER. Warning: Only http (not 160 | https) is supported 161 | - Press ENTER again and accept changes. 162 | 163 | At this moment BaDCaT firmware needs and extra file configuration on your 164 | internet repository to be able to access files. This file must be named 165 | "filelist.txt". The filename will contain the files you want access from BaDCat 166 | as well as their length in following format: 167 | 168 | FILE1.EXTsize 169 | FILE2.EXTsize 170 | ... 171 | FILEX.EXTsize 172 | 173 | - FILEX.ROM is the name of file. 174 | - are two TABs (09) 175 | - size in bytes. 176 | 177 | Example: 178 | 179 | HERO16K.ROM 16384 180 | YIEARE.ROM 16384 181 | ALIBABA.ROM 16384 182 | BBOY.ROM 32768 183 | HERO.ROM 32768 184 | YIEARE2.ROM 32768 185 | ZANAC.ROM 32768 186 | EGGER.ROM 32768 187 | OPWOLF.ROM 49152 188 | MAJI.ROM 49152 189 | RLV933.ROM 49152 190 | TRITON.ROM 49152 191 | 192 | 193 | Now BaDCaT will be able to access those files both for download to local 194 | repository filesystem and load (simulate) ROM file. 195 | 196 | 197 | 5.2.- DOWNLOAD FILES FROM INTERNET REPOSITORY 198 | 199 | To enjoy the features of local filesytem firtly we need transfer files to this 200 | local repository. At this moment you can only transfer the files from your 201 | internet repository (above section). To transfer file from your internet 202 | repository follow this steps: 203 | 204 | - Type lfiles to ensure you've enough free space to download file 205 | - Type delete command if necessary to save and free space. 206 | - Type dload FILE.EXT to download file from your internet repository. Fille 207 | will transfer automatically from your internet repository to your local 208 | storage filesystem. 209 | - Type lfiles again to check if your file is correctly transfered to your 210 | local storage. 211 | 212 | 213 | 6.- LOAD ROM FILES 214 | 215 | One the most important BadCat features is the posibility of load ROMs files from 216 | internet repository simulating ROM cartridge on RAM memory. The feature 217 | downloads the ROM file data from internet (or local storage) to RAM and executes 218 | the RAM file. 219 | 220 | The feature works with ROM files from 8k up to 48k non-mapped (linear). Any 221 | other type of ROM file (custom mapper, megarom files, etc...) can't be 222 | simulated. 223 | 224 | There are, however, limitations to the simulation: 225 | 226 | - You need at least 64K of RAM to simulate the ROM files. Yes, you could run 227 | 8/16k ROM files with 32k of RAM but just a few 8/16k ROM files would work 228 | properly. 229 | 230 | - Since is a RAM simulation not all ROM files could be executed. The 231 | simulation could have problems to run or glitches in its execution. 232 | 233 | - Simulation of ROM files > 16k needs an specific memory environment: all 234 | pages of RAM must be on the same slot. For example: You've an MSX computer 235 | with 64k of RAM distributed in four 16k pages each of them in one 236 | different slot. Hypothetically your MSX has enough memory to emulate a 48k 237 | ROM file but a real ROM cartridge has *always* its pages in the same slot 238 | therefore the game would never work. 239 | 240 | - BaDCat Shell ROM version can't handle ROMs with disk access (like 241 | EGGERLAND MYSTERY or PERFECT FIT). Will be fixed in next version. If you 242 | want play these games and to use disk access, please, load binary, command 243 | or cassette version. 244 | 245 | Before load ROM file or download file to local storate we need access to 246 | internet ROM repository. See Section 5 on how to configure your local and internet 247 | repository. To load ROM file BaDCaT needs be able to access to this file from 248 | local storage filesystem or internet repository. 249 | 250 | Continuing with the example of internet repository (Section 5.1) let's start with 251 | the ROM simulation. 252 | 253 | * From internet repository: 254 | 255 | Warning: BaDCat needs be configured to access WIFI network to use this 256 | feature. 257 | 258 | - Type rload FILEX.EXT (eg: rload HERO.ROM) 259 | - "Press F1 to start download" message will appear in the screen. 260 | - Press to load ROM file or any command to continue and cancel. 261 | - If you press then next messages will appear in the screen: 262 | 263 | "Get file info..." 264 | "Loading xxxx bytes" 265 | 266 | - The file will load automatically. 267 | 268 | 269 | * From local storage filesystem: 270 | 271 | Warning: The file must be present in your local filesystem. (Section 5.2). You 272 | don't need internet connection to enjoy this feature. 273 | 274 | - Type load FILEX.EXT (eg: load MAJI.ROM) 275 | - "Press F1 to start download" message will appear in the screen. 276 | - Press to load ROM file or any command to continue and cancel. 277 | - If you press then next messages will appear in the screen: 278 | 279 | "Get file info..." 280 | "Loading xxxx bytes" 281 | 282 | - The file will load automatically. 283 | 284 | 285 | 286 | 287 | 7.- BADCAT OTA UPDATES 288 | 289 | From version 1.3 (comes factory configured) it's possible to upgrade BaDCaT 290 | firmware directly from internet 291 | 292 | 293 | - In command BDShell mode type AT&U. The version of the lastest available 294 | firmware will appear. 295 | - To upgrade type AT&U= and press ENTER (eg. AT&U=1.3) 296 | - This will take some time. After that, the BaDCaT will reboot and show the 297 | upgraded firmware (you can check with the ATI command). 298 | 299 | 300 | 301 | 302 | 8.- RS232 PORT 303 | 304 | BaDCaT provides a standard RS232 port mapped at #80 I/O port to provide 305 | compatibility with standard software such as Eric Mass Fossil Driver. 306 | 307 | To use the RS232 port, the wifi switch MUST BE IN THE OFF POSITION!! 308 | Hereafter, standard software can be used. Eric Maas ERIX terminal, is 309 | recommended, which works with his Fossil drive 310 | 311 | 312 | 313 | 314 | 9.- SUMMARY OF BADCAT COMMANDS 315 | 316 | Summary of commands you can introduce in command mode. 317 | 318 | - help: Show the help. 319 | 320 | * Related to connection: 321 | 322 | 323 | - AT+CONFIG: Enter configuration menu. 324 | 325 | - ATD"[HOSTNAME]:[PORT]": Open streaming connnection. 326 | 327 | - ATDT"[HOSTNAME]:[PORT]": Open TELNET connection 328 | 329 | - +++: With one second pause -> enter command mode. 330 | 331 | - ATZ: Close all open socket connections. 332 | 333 | - A/: Repeats previous command. 334 | 335 | - ATI2: Show modem's current IP address. 336 | 337 | - ATI3: Show modem's current wireless router connection 338 | 339 | - ATBn: Sets a new serial baud rate. Takes effect inmediately. 340 | 341 | - AT&W: Write changes to modem flash. BE SURE BEFORE DOING THIS! 342 | 343 | - ATC: Shows information about the curent network connection 344 | 345 | - ATH: Disconnect from the hosst. 346 | 347 | 348 | * Related to internet repository: 349 | 350 | - rfiles: Show files from internet repository 351 | 352 | - rload : load ROM file directly from internet repository 353 | 354 | * Related to local storage: 355 | 356 | - lfiles: Show the files in the storage system and the current free space 357 | 358 | - delete : Remove a file from local storage. 359 | 360 | - dload : Download a file from internet repository to the local storage 361 | 362 | - load : load ROM from local storage. 363 | 364 | 365 | 366 | 367 | 10.- SOURCE FILES / ASSEMBLING BDSHELL 368 | 369 | To assemble BDShell project you need Pipa Gerardo's SjasmPG assembler: 370 | 371 | https://github.com/pipagerardo/sjasmpg 372 | 373 | Also an *NIX environment system that support "make" build automation tool. For 374 | Windows you can install Cygwin or MinGW. 375 | 376 | The project is presented with this organization: 377 | 378 | Makefile 379 | | 380 | +-- DOC 381 | +-- OUTPUT 382 | +-- SRC 383 | 384 | - Makefile: Rules and directives for make tool. 385 | - DOC: Directory that contains this file. 386 | - OUTPUT: directory has preassembled / assembled binary BDShell files. 387 | - SRC: Source files. 388 | 389 | To assemble type "make". The binary files will be assembled automatically and 390 | stored in OUTPUT directory. 391 | 392 | An extra TMP folder will be created when you assemble the project. This temporal 393 | directory has intermediate files and typical output assembler files like .lst, 394 | lab... 395 | 396 | Type "make clean" to clean temporal files. 397 | Type "make cleanall" to clean temporal files and output files. 398 | 399 | 400 | 401 | 402 | 11.- THANKS TO... 403 | 404 | - Andrés Ortiz: For develop and build the awesome BadCaT card and help me with 405 | BDShell 406 | 407 | - Oduvaldo Pavan Junior (ducasp): For develop his open source TELNET tool. 408 | 409 | - x1Pepe, SYSOP of Sotano MSX BBS for test BDShell. 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | -------------------------------------------------------------------------------- /BDSHELL/SRC/BADCAT.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************** 2 | ; * BADCAT RELATED * 3 | ; ***************************************** 4 | 5 | 6 | ; - CHECKBC ------------ 7 | ; - CHECK IF BADCAT WIFI 8 | ; - IS PRESENT 9 | ; - Zy = 1 -> PRESENT 10 | ; - 11 | 12 | CHECKBC LD A,#55 13 | OUT (BCSCRA),A 14 | IN A,(BCSCRA) 15 | CP #55 16 | RET NZ 17 | LD A,#AA 18 | OUT (BCSCRA),A 19 | IN A,(BCSCRA) 20 | CP #AA 21 | RET 22 | 23 | 24 | -------------------------------------------------------------------------------- /BDSHELL/SRC/BBDSHELL.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************************************************** 2 | ; * BDSHELL (BIN VERSION) * 3 | ; * (C) ANDRES ORTIZ / ARMANDO PEREZ * 4 | ; ***************************************************************************** 5 | 6 | 7 | ; --- HARD AND CONSTANTS ----------------------------------------- 8 | 9 | 10 | INCLUDE HARD.Z8A 11 | INCLUDE CONST.Z8A 12 | 13 | 14 | ; --- FLAGS ----------------------------------------- 15 | 16 | 17 | PTYPE EQU TBIN ; TYPE BINARY 18 | 19 | 20 | ; --- BIN HEADER ----------------------------------------- 21 | 22 | 23 | ORG BINORG - 7 24 | DEFB #FE 25 | DEFW INIT 26 | DEFW END - 1 27 | DEFW START 28 | 29 | 30 | ; --- PROGRAM ----------------------------------------- 31 | 32 | INIT 33 | ; PROGRAM 34 | 35 | INCLUDE PROGRAM.Z8A 36 | END 37 | ; VARS 38 | 39 | INCLUDE GVARS.Z8A 40 | 41 | -------------------------------------------------------------------------------- /BDSHELL/SRC/BDSHELL.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************************************************** 2 | ; * BDHSELL (ROM VERSION) * 3 | ; * (C) ANDRES ORTIZ / ARMANDO PEREZ * 4 | ; ***************************************************************************** 5 | 6 | 7 | ; --- HARD AND CONSTANTS ----------------------------------------- 8 | 9 | 10 | INCLUDE VARS.sym 11 | 12 | 13 | ; --- ROM FLAGS ----------------------------------------- 14 | 15 | 16 | PTYPE EQU TROM ; TYPE ROM 17 | 18 | 19 | ; --- ROM HEADER ----------------------------------------- 20 | 21 | 22 | ORG #4000 23 | DEFB #41, #42 24 | DEFW START 25 | DEFS 12 26 | 27 | 28 | ; --- PROGRAM ----------------------------------------- 29 | 30 | ; PROGRAM 31 | 32 | INCLUDE PROGRAM.Z8A 33 | 34 | ; PADDING ROM 35 | 36 | SIZE 8 * 1024 37 | 38 | 39 | -------------------------------------------------------------------------------- /BDSHELL/SRC/CBDSHELL.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************************************************** 2 | ; * BDSHELL (CAS VERSION) * 3 | ; * (C) ANDRES ORTIZ / ARMANDO PEREZ * 4 | ; ***************************************************************************** 5 | 6 | 7 | ; --- HARD AND CONSTANTS ----------------------------------------- 8 | 9 | 10 | INCLUDE HARD.Z8A 11 | INCLUDE CONST.Z8A 12 | 13 | 14 | ; --- FLAGS ----------------------------------------- 15 | 16 | 17 | PTYPE EQU TCAS ; TYPE CAS FILE 18 | 19 | 20 | ; --- CAS HEADER ----------------------------------------- 21 | 22 | ; .CAS HEADER 23 | 24 | DEFB #1F, #A6, #DE, #BA 25 | DEFB #CC, #13, #7D, #74 26 | 27 | ; .BIN HEADER 28 | 29 | DEFB #D0, #D0, #D0, #D0 30 | DEFB #D0, #D0, #D0, #D0 31 | DEFB #D0, #D0 32 | 33 | ; .BIN NAME 34 | 35 | DEFM "BDSHEL" 36 | 37 | ; .CAS HEADER 38 | 39 | DEFB #1F, #A6, #DE, #BA 40 | DEFB #CC, #13, #7D, #74 41 | 42 | 43 | ; --- BIN HEADER ----------------------------------------- 44 | 45 | ORG BINORG - 6 46 | 47 | DEFW INIT 48 | DEFW END - 1 49 | DEFW START 50 | 51 | 52 | ; --- PROGRAM ----------------------------------------- 53 | 54 | INIT 55 | ; PROGRAM 56 | 57 | INCLUDE PROGRAM.Z8A 58 | END 59 | ; VARS 60 | 61 | INCLUDE GVARS.Z8A 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /BDSHELL/SRC/CONST.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************** 2 | ; * CONSTANTS * 3 | ; ***************************************** 4 | 5 | 6 | 7 | ; --- PROGRAM ASSEMBLE OPTS. ----------------------------------------- 8 | 9 | 10 | ROMDSK EQU 0 ; 0 DISABLE ROM DISK SUPPORT 11 | ECHOON EQU 1 ; 0 DISABLE LOCAL ECHO 12 | SENDIC EQU 1 ; 0 DISABLE INIT CMDS (ATE AND ATZ) 13 | 14 | 15 | ; --- PROGRAM CONSTANS ----------------------------------------- 16 | 17 | 18 | BINORG EQU #C300 19 | RROMORG EQU #C000 20 | REXEORG EQU #FA00 21 | 22 | 23 | ; --- TYPE CONSTANTS ----------------------------------------- 24 | 25 | 26 | TROM EQU 0 27 | TBIN EQU 1 28 | TCOM EQU 2 29 | TCAS EQU 3 30 | 31 | 32 | ; - RAM TYPE CONSTANTS ----------------------------------------- 33 | 34 | 35 | RAM8K EQU 0 36 | RAM16K EQU 1 37 | RAM32K EQU 2 38 | RAM48K EQU 3 39 | RAM64K EQU 4 40 | 41 | 42 | ; - UART ----------------------------------------- 43 | 44 | 45 | BUFFSIZE EQU #100 46 | 47 | 48 | ; - FLAGS & STATUS ---------------------------------------- 49 | 50 | STAREAD EQU 0 51 | STAWRT EQU 1 52 | 53 | STAREADM EQU 1 54 | STAWRTM EQU 2 55 | 56 | -------------------------------------------------------------------------------- /BDSHELL/SRC/DBDSHELL.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************************************************** 2 | ; * BDSHELL (MSX-DOS VERSION) * 3 | ; * (C) ANDRES ORTIZ / ARMANDO PEREZ * 4 | ; ***************************************************************************** 5 | 6 | 7 | ; --- HARD AND CONSTANTS ----------------------------------------- 8 | 9 | 10 | INCLUDE HARD.Z8A 11 | INCLUDE CONST.Z8A 12 | 13 | 14 | ; --- FLAGS ----------------------------------------- 15 | 16 | 17 | PTYPE EQU TCOM ; TYPE COMMAND 18 | 19 | 20 | ; --- MSXDOS HEADER ----------------------------------------- 21 | 22 | 23 | ORG #100 24 | 25 | 26 | ; --- PROGRAM ----------------------------------------- 27 | 28 | JP REALLOC 29 | 30 | 31 | ; - REALLOC ----------- 32 | ; - REALLOCATE CODE 33 | ; - ENABLE BIOS 34 | ; - 35 | 36 | REALLOC LD HL,RFROM 37 | LD DE,RPROG 38 | LD BC,REND - RPROG 39 | LDIR 40 | JP RPROG 41 | 42 | RFROM 43 | PHASE #4010 44 | 45 | ; - RPROG ------------- 46 | ; - ENABLE BIOS PAGE 0 47 | ; - RUN PROGRAM 48 | ; - SIMULATE ROM VERSION 49 | ; - 50 | 51 | RPROG LD A,(EXPTBL) 52 | CALL SETSLTP0 53 | JP START 54 | 55 | ; PROGRAM 56 | 57 | INCLUDE PROGRAM.Z8A 58 | 59 | ; VARS 60 | 61 | INCLUDE GVARS.Z8A 62 | REND 63 | DEPHASE 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /BDSHELL/SRC/GENERIC.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************** 2 | ; * GENERIC * 3 | ; ***************************************** 4 | 5 | 6 | 7 | ; --- HL / A ----------------------------------------- 8 | 9 | 10 | ; - ADDHLA ----------------- 11 | ; - HL += A 12 | ; - 13 | 14 | ADDHLA ADD A,L 15 | LD L,A 16 | RET NC 17 | INC H 18 | RET 19 | 20 | 21 | ; - ADDHLPNT ------------ 22 | ; - A * 2 23 | ; - HL + = A 24 | ; - HL = (HL) 25 | ; - A = (HL) 26 | ; - 27 | 28 | ADDHLPNT ADD A,A 29 | CALL ADDHLA 30 | 31 | 32 | ; - PNTHL --------------- 33 | ; - HL = (HL) 34 | ; - 35 | 36 | PNTHL LD A,(HL) 37 | INC HL 38 | LD H,(HL) 39 | LD L,A 40 | RET 41 | 42 | 43 | 44 | ; --- FUNCTION KEYS ----------------------------------------- 45 | 46 | 47 | ; - CLFNKEY ------------ 48 | ; - CLEAR FUNCTION KEYS 49 | ; - 50 | 51 | CLFNKEY LD HL,FNKSTR 52 | LD DE,FNKBUF 53 | LD B,#0A 54 | .LOOP PUSH BC 55 | LD A,(HL) 56 | LD (DE),A 57 | INC DE 58 | LD (HL),0 59 | LD BC,#10 60 | ADD HL,BC 61 | POP BC 62 | DJNZ .LOOP 63 | RET 64 | 65 | ; - REFNKEY ------------ 66 | ; - RESTORE FUNCTION KEYS 67 | ; - 68 | 69 | REFNKEY LD HL,FNKSTR 70 | LD DE,FNKBUF 71 | LD B,#0A 72 | .LOOP PUSH BC 73 | LD A,(DE) 74 | INC DE 75 | LD (HL),A 76 | LD BC,#10 77 | ADD HL,BC 78 | POP BC 79 | DJNZ .LOOP 80 | RET 81 | 82 | 83 | ; --- MATH ----------------------------------------- 84 | 85 | 86 | ; - MULT12 ------------- 87 | ; - A * DE = HL 88 | ; - 89 | 90 | 91 | MULT12 LD HL,0 92 | ADD A,A 93 | JP NC,.ILOOP 94 | LD H,D 95 | LD L,E 96 | .ILOOP LD B,7 97 | .LOOP ADD HL,HL 98 | ADD A,A 99 | JP NC,.NOADD 100 | ADD HL,DE 101 | .NOADD DJNZ .LOOP 102 | RET 103 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /BDSHELL/SRC/GVARS.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************** 2 | ; * PROGRAM VARS * 3 | ; ***************************************** 4 | 5 | 6 | ; --- RAM MSX1 ----------------------------------------- 7 | 8 | 9 | INITVARS 10 | 11 | ALIGN 256 12 | 13 | ; UART (256 ALIGNED BUFFER) 14 | 15 | RXBUFF DEFS BUFFSIZE, 0 ; RING BUFFER 16 | RPTR DEFB 0 ; WRITE POINTER RING BUFFER 17 | WPTR DEFB 0 ; READ POINTER RING BUFFER 18 | AUX DEFB 0 19 | 20 | 21 | ; SLOT 22 | 23 | THISSLT DEFB 0 24 | SLOTVAR DEFB 0 25 | 26 | ; RAM 27 | 28 | RAMTYPUS DEFB 0 29 | RAMPAGE0 DEFB 0 30 | RAMPAGE1 DEFB 0 31 | RAMPAGE2 DEFB 0 32 | RAMPAGE3 DEFB 0 33 | 34 | ; TMP 35 | 36 | RAMCHK0 DEFB 0 37 | RAMCHK1 DEFB 0 38 | RAMCHK2 DEFB 0 39 | RAMCHK3 DEFB 0 40 | SAVESP DEFW 0 41 | FNKBUF DEFS 10 42 | CNSDFGT DEFB 0 43 | STRNUM DEFS 7 44 | 45 | ; SYSTEM 46 | 47 | SYSTEM DEFB 0 48 | FREQSET DEFB 0 49 | BADCAT DEFB 0 50 | 51 | ; INTERRUPT 52 | 53 | OLDHKEY DEFS 5 54 | OLDHTIM DEFS 5 55 | INTCNT DEFB 0 56 | 57 | ; KEYBOARD 58 | 59 | KEYDOW DEFB 0 60 | KEYTRG DEFB 0 61 | 62 | 63 | ; MAIN 64 | 65 | MSTAT DEFB 0 66 | 67 | 68 | 69 | 70 | ENDVARS 71 | 72 | -------------------------------------------------------------------------------- /BDSHELL/SRC/HARD.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************** 2 | ; * HARD * 3 | ; ***************************************** 4 | 5 | 6 | ; --- SOUND ----------------------------------------- 7 | 8 | 9 | OPLLCTRL EQU #7C 10 | OPLLDATA EQU #7D 11 | PSGCTRL EQU #A0 12 | PSGWRITE EQU #A1 13 | PSGREAD EQU #A2 14 | 15 | 16 | ; --- MEM ----------------------------------------- 17 | 18 | 19 | PGMRAM EQU #E000 20 | PGMRAMS EQU #1380 21 | 22 | 23 | ; --- BIOS ------------------------------------------ 24 | 25 | 26 | ENASCR_B EQU #44 27 | DISSCR_B EQU #41 28 | WRTVDP_B EQU #47 29 | WRTVRM EQU #4D 30 | FILVRM_B EQU #56 31 | LDIRVM_B EQU #5C 32 | LDIRMV_B EQU #59 33 | CHGMOD EQU #5F 34 | WRTPSG EQU #93 35 | RDPSG EQU #96 36 | GTSTCK EQU #D5 37 | GTTRIG EQU #D8 38 | SNSMAT EQU #141 39 | ENASLT EQU #24 40 | RSLREG EQU #138 41 | RDSLT EQU #0C 42 | WRSLT EQU #14 43 | CHPUT EQU #A2 44 | CALSLT EQU #1C 45 | DCOMPR_B EQU #20 46 | KILBUF EQU #156 47 | CHSNS EQU #9C 48 | CHGET EQU #9F 49 | EXTBIOS EQU #15F 50 | SUBROM EQU #15C 51 | CLS EQU #00C3 52 | EXTROM EQU #015F 53 | RDVDP EQU #013E 54 | CHGCPU EQU #180 55 | ERAFNK EQU #CC 56 | DSPFNK EQU #CF 57 | BREAKX EQU #B7 58 | 59 | 60 | ; --- SYSTEM VARS ------------------------------------------ 61 | 62 | 63 | HTIMI EQU #FD9F 64 | HKEYI EQU #FD9A 65 | CLIKSW EQU #F3DB 66 | FORCLR EQU #F3E9 67 | BAKCLR EQU #F3EA 68 | BDRCLR EQU #F3EB 69 | SCRMOD EQU #FCAF 70 | RG0SAV EQU #F3DF 71 | RG1SAV EQU RG0SAV + 1 72 | RG3SAV EQU RG0SAV + 3 73 | RG4SAV EQU RG0SAV + 4 74 | RG6SAV EQU RG0SAV + 6 75 | RG7SAV EQU RG0SAV + 7 76 | EXPTBL EQU #FCC1 77 | SLTTBL EQU #FCC5 78 | LINL40 EQU #F3AE 79 | LINL32 EQU #F3AF 80 | EXTVDP EQU #FFE7 81 | CSRY EQU #F3DC 82 | CSRX EQU #F3DD 83 | EXBRSA EQU #FAF8 84 | RAMAD0 EQU #F341 85 | RAMAD1 EQU #F342 86 | RAMAD2 EQU #F343 87 | RAMAD3 EQU #F344 88 | CNSDFG EQU #F3DE 89 | FNKSTR EQU #F87F 90 | REPCNT EQU #F3F7 91 | 92 | CMASK EQU #F92C 93 | CSRSW EQU #FCA9 94 | 95 | HSTKE EQU #FEDA 96 | HRUNC EQU #FECB 97 | HPHYD EQU #FFA7 98 | 99 | 100 | JIFFY EQU #FC9E 101 | STATFL EQU #F3E7 102 | 103 | RG10SA EQU #FFE9 104 | RG18SA EQU #FFF1 105 | RG19SA EQU #FFF2 106 | RG23SA EQU #FFF6 107 | 108 | RG25SA EQU #FFFA 109 | RG26SA EQU #FFFB 110 | RG27SA EQU #FFFC 111 | 112 | ; --- KEY / JOY ----------------------------------------- 113 | 114 | 115 | ; - B7 -> RIGHT 116 | ; - B6 -> DOWN 117 | ; - B5 -> UP 118 | ; - B4 -> LEFT 119 | ; - B3 -> EMPTY 120 | ; - B2 -> PAUSE 121 | ; - B1 -> BUTTON 2 122 | ; - B0 -> BUTTON 1 123 | 124 | 125 | JOYDIRR EQU 7 126 | JOYDIRD EQU 6 127 | JOYDIRU EQU 5 128 | JOYDIRL EQU 4 129 | JOYPAUS EQU 2 130 | JOYTRG2 EQU 1 131 | JOYTRG1 EQU 0 132 | 133 | JOYDIRRM EQU 128 134 | JOYDIRDM EQU 64 135 | JOYDIRUM EQU 32 136 | JOYDIRLM EQU 16 137 | JOYPAUSM EQU 4 138 | JOYTRG2M EQU 2 139 | JOYTRG1M EQU 1 140 | 141 | JOYTRGAM EQU JOYTRG1M | JOYTRG2M 142 | JOYDIRAM EQU JOYDIRUM | JOYDIRDM | JOYDIRLM | JOYDIRRM 143 | 144 | 145 | ; --- SR0 BASE ADDRESS ---------------------------------------------- 146 | 147 | SCR0PAT EQU #0800 ; PATTERN GENERATOR TABLE 148 | SCR0ATT EQU #0000 ; PATTERN NAME TABLE 149 | 150 | SCR02PAT EQU #1000 ; PATTERN GENERATOR TABLE 151 | SCR02ATT EQU #0000 ; PATTERN NAME TABLE 152 | 153 | 154 | ; --- SR2 BASE ADDRESS ---------------------------------------------- 155 | 156 | 157 | SCR2PAT EQU #0000 ; PATTERN GENERATOR TABLE 158 | SCR2COL EQU #2000 ; PATTERN COLOR TABLE 159 | SCR2ATT EQU #1800 ; PATTERN NAME TABLE 160 | SPR2PAT EQU #3800 ; SPRITE GENERATOR TABLE 161 | SPR2ATT EQU #1B00 ; SPRITE NAME TABLE 162 | SPRATTS EQU #80 163 | 164 | 165 | ; --- SR1 BASE ADDRESS ---------------------------------------------- 166 | 167 | 168 | SCR1PAT EQU #0000 ; PATTERN GENERATOR TABLE 169 | SCR1ATT EQU #1800 ; PATTERN NAME TABLE 170 | SCR1COL EQU #2000 ; PATTERN COLOR TABLE 171 | SPR1PAT EQU #3800 ; SPRITE GENERATOR TABLE 172 | SPR1ATT EQU #1B00 ; SPRITE NAME TABLE 173 | 174 | 175 | ; --- SR4 BASE ADDRESS ---------------------------------------------- 176 | 177 | 178 | SCR4PAT EQU #0000 ; PATTERN GENERATOR TABLE 179 | SCR4COL EQU #2000 ; PATTERN COLOR TABLE 180 | SCR4ATT EQU #1800 ; PATTERN NAME TABLE 181 | SPR4PAT EQU #3800 ; SPRITE GENERATOR TABLE 182 | SPR4ATT EQU #1E00 ; SPRITE NAME TABLE 183 | SPR4COL EQU #1C00 ; SPRIT COLOR TABLE 184 | 185 | 186 | 187 | ; --- SR5 BASE ADDRESS ---------------------------------------------- 188 | 189 | 190 | SCR5PAT EQU #0000 ; PATTERN GENERATOR TABLE 191 | SPR5PAT EQU #7800 ; SPRITE GENERATOR TABLE 192 | SPR5ATT EQU #7600 ; SPRITE NAME TABLE 193 | SPR5COL EQU #7400 ; SPRITE COLOR TABLE 194 | 195 | 196 | ; --- VDP COMMANDS ---------------------------------------------- 197 | 198 | 199 | ; - COMMANDS 200 | 201 | VDPCHMMM EQU #D0 202 | VDPCLMMM EQU #98 203 | 204 | ; - VDP COMMAND OFFSETS 205 | 206 | VDPOFFSX EQU 0 207 | VDPOFFSY EQU 2 208 | VDPOFFDX EQU 4 209 | VDPOFFDY EQU 6 210 | VDPOFFNX EQU 8 211 | VDPOFFNY EQU 10 212 | VDPOFFNU EQU 12 213 | VDPOFFDI EQU 13 214 | VDPOFFCM EQU 14 215 | 216 | 217 | ; --- SPRITE ---------------------------------------------- 218 | 219 | 220 | SPROFF EQU #D1 221 | 222 | 223 | 224 | ; --- AMD 29F040 ---------------------------------------------- 225 | 226 | 227 | ; COMMAND SEQUENCE 228 | 229 | FLHCMD1 EQU #AA 230 | FLHCMD2 EQU #55 231 | FLHADDR1 EQU #4555 232 | FLHADDR2 EQU #5AAA 233 | FLHCMD3E EQU #80 234 | 235 | ; COMMANDS 236 | 237 | FLHCMDRS EQU #F0 238 | FLHCMDSE EQU #30 239 | FLHCMDCE EQU #10 240 | FLHCMDWR EQU #A0 241 | FLHCMDAS EQU #90 242 | 243 | ; DEVICE ID 244 | 245 | FLHDEVID EQU #A4 246 | 247 | 248 | ; --- SRAM ---------------------------------------------- 249 | 250 | ; PAC 251 | 252 | SRAMPACA EQU #5FF0 253 | 254 | ; PANASONIC SRAM 255 | 256 | SRAMSRAA EQU #5FF0 257 | 258 | SRAMPASL EQU %10001111 259 | SRAMPAPA EQU #80 260 | SRAMPAMA EQU #6800 261 | 262 | 263 | 264 | 265 | ; --- BADCAT RS232 ---------------------------------------------- 266 | 267 | 268 | BPORT EQU #80 269 | 270 | BCSCRA EQU #87 271 | -------------------------------------------------------------------------------- /BDSHELL/SRC/INTER.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************** 2 | ; * ISR INTERRUPT * 3 | ; ***************************************** 4 | 5 | 6 | ; --- INIT / CONTROL ----------------------------------------- 7 | 8 | 9 | ; - INTINIT ------------ 10 | ; - INIT ISR 11 | ; - 12 | 13 | INTINIT DI 14 | LD HL,HKEYI 15 | LD DE,OLDHKEY 16 | LD BC,5 17 | LDIR 18 | 19 | LD A,#C3 20 | LD (HKEYI),A 21 | LD HL,HKEYHAND 22 | LD (HKEYI + 1),HL 23 | 24 | LD HL,HTIMI 25 | LD DE,OLDHTIM 26 | LD BC,5 27 | LDIR 28 | 29 | LD A,#C3 30 | LD (HTIMI),A 31 | LD HL,HTIMHAND 32 | LD (HTIMI + 1),HL 33 | 34 | RET 35 | 36 | 37 | ; --- INTERRUPT ----------------------------------------- 38 | 39 | 40 | ; - HKEYHAND ------------ 41 | ; - KEY INTERRUPT HANDLER 42 | ; - 43 | 44 | HKEYHAND CALL UARTINT 45 | JP OLDHKEY 46 | 47 | ; - HTIMHAND ---------- 48 | ; - IM1 INTERRUPT HANDLER 49 | ; - 50 | 51 | HTIMHAND CALL KEYREAD 52 | 53 | 54 | CALL OLDHTIM 55 | LD A,(INTCNT) 56 | INC A 57 | LD (INTCNT),A 58 | 59 | RET 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /BDSHELL/SRC/KEYJOY.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************** 2 | ; * KEY/JOY * 3 | ; ***************************************** 4 | 5 | ; --- KEY INIT ---------------------------------------- 6 | 7 | ; - KEYINIT ------------ 8 | ; - INIT KEYBOARD SYSTEM 9 | ; - 10 | 11 | 12 | KEYINIT LD HL,#FFFF 13 | LD (KEYDOW),HL 14 | RET 15 | 16 | 17 | ; --- KEY READ ---------------------------------------- 18 | 19 | 20 | 21 | ; - KEYREAD ----------- 22 | ; - READ KEYBOARD 23 | ; - 24 | ; - BITS: 25 | ; - B7 -> 26 | ; - B6 -> 27 | ; - B5 -> F1 28 | ; - B4 -> 29 | ; - B3 -> 30 | ; - B2 -> 31 | ; - B1 -> F5 32 | ; - B0 -> 33 | 34 | KEYREAD IN A,(#AA) 35 | AND #F0 36 | LD B,A 37 | OR 6 38 | OUT (#AA),A 39 | IN A,(#A9) 40 | AND %00100000 41 | LD C,A 42 | 43 | LD A,B 44 | OR 7 45 | OUT (#AA),A 46 | IN A,(#A9) 47 | AND %00000010 48 | OR C 49 | LD C,A 50 | 51 | 52 | ; KEY TRG OPERATION 53 | 54 | LD HL,KEYDOW 55 | LD A,(HL) 56 | LD (HL),C 57 | XOR C 58 | CPL 59 | OR C 60 | LD (KEYTRG),A 61 | 62 | RET 63 | 64 | 65 | -------------------------------------------------------------------------------- /BDSHELL/SRC/PRINT.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************** 2 | ; * PRINT OUTPUT ROUTINES * 3 | ; ***************************************** 4 | 5 | 6 | ; --- PRINT ----------------------------------------- 7 | 8 | 9 | ; - PRTCRLF ------------ 10 | ; - PRINT CR/LF 11 | ; - 12 | 13 | PRTCRLF LD A,#0D 14 | CALL CHPUT 15 | LD A,#0A 16 | JP CHPUT 17 | 18 | 19 | ; - PRINT --------------- 20 | ; - PRINT TEXT 21 | ; - HL: TEXT POINTER 22 | ; - DE: COORD 23 | ; - 24 | 25 | PRINT LD (CSRY),DE 26 | .GEN LD A,(HL) 27 | INC HL 28 | OR A 29 | RET Z 30 | PUSH HL 31 | CALL CHPUT 32 | POP HL 33 | JR .GEN 34 | 35 | 36 | ;- PRINTHEX ------------ 37 | ;- A: NUMBER 38 | ;- DE: COORD 39 | ;- 40 | PRINTHEX LD (CSRY),DE 41 | .GEN PUSH AF 42 | AND #F0 43 | SRL A 44 | SRL A 45 | SRL A 46 | SRL A 47 | LD E,A 48 | LD D,0 49 | LD HL,.HEXDATA 50 | ADD HL,DE 51 | LD A,(HL) 52 | CALL CHPUT 53 | POP AF 54 | AND #0F 55 | LD E,A 56 | LD D,0 57 | LD HL,.HEXDATA 58 | ADD HL,DE 59 | LD A,(HL) 60 | JP CHPUT 61 | 62 | .HEXDATA DEFM "0123456789ABCDEF" 63 | 64 | 65 | ; - PRTSLOT ------------ 66 | ; - PRINT SLOT 67 | ; - A: SLOT (FxxxSSPP) 68 | ; - 69 | 70 | PRTSLOT PUSH AF 71 | AND 3 72 | ADD A,"0" 73 | CALL CHPUT 74 | POP AF 75 | AND A 76 | JP P,.END 77 | 78 | PUSH AF 79 | LD A,"-" 80 | CALL CHPUT 81 | POP AF 82 | SRL A 83 | SRL A 84 | AND 3 85 | ADD A,"0" 86 | CALL CHPUT 87 | .END LD HL,TXTINTR 88 | JP PRINT.GEN 89 | 90 | 91 | 92 | 93 | ; --- CURSOR ----------------------------------------- 94 | 95 | 96 | ; - DEFCUR ------------ 97 | ; - DEFINE CURSOR 98 | ; - 99 | 100 | DEFCUR LD A,(SYSTEM) 101 | AND A 102 | LD DE,SCR0PAT + (#FF * 8) 103 | JR Z,.DEF 104 | LD DE,SCR02PAT + (#FF * 8) 105 | .DEF LD HL,.CURSOR 106 | LD BC,8 107 | JP LDIRVM_B 108 | 109 | .CURSOR DEFS 8, #FF 110 | 111 | 112 | ; - PRTCUR ------------- 113 | ; - PRINT CURSOR 114 | ; - 115 | 116 | PRTCUR LD A,#FF 117 | .GEN CALL CHPUT 118 | LD A,(CSRX) 119 | DEC A 120 | LD (CSRX),A 121 | RET 122 | 123 | ; - CLRCUR ------------- 124 | ; - CLEAR CURSOR 125 | ; - 126 | 127 | CLRCUR LD A,' ' 128 | JP PRTCUR.GEN 129 | 130 | 131 | ; - CLRCURS ------------ 132 | ; - CLEAR CURSOR SAFE 133 | ; - A: CHAR TO CLEAR 134 | ; - 135 | 136 | CLRCURS LD C,A 137 | LD A,(CSRX) 138 | CP 1 139 | RET Z 140 | LD A,C 141 | CALL CHPUT 142 | LD A,(CSRX) 143 | DEC A 144 | LD (CSRX),A 145 | RET 146 | 147 | 148 | ; --- STRING ----------------------------------------- 149 | 150 | 151 | ; - STR2INT ------------ 152 | ; - INPUT: 153 | ; - HL: POINTER TO STR NUMBER 154 | ; - OUTPUT: 155 | ; - HL: UNSIGNED INT NUMBER 156 | ; - 157 | 158 | STR2INT PUSH HL 159 | POP IX 160 | LD A,(IX + 0) 161 | SUB '0' 162 | LD DE,10000 163 | CALL MULT12 ; RESULT IN HL 164 | 165 | PUSH HL 166 | LD A,(IX + 1) 167 | SUB '0' 168 | LD DE,1000 169 | CALL MULT12 ; RESULT IN HL 170 | POP DE 171 | ADD HL,DE 172 | 173 | PUSH HL 174 | LD A,(IX + 2) 175 | SUB '0' 176 | LD DE,100 177 | CALL MULT12 ; RESULT IN HL 178 | POP DE 179 | ADD HL,DE 180 | 181 | PUSH HL 182 | LD A,(IX + 3) 183 | SUB '0' 184 | LD DE,10 185 | CALL MULT12 ; RESULT IN HL 186 | POP DE 187 | ADD HL,DE 188 | 189 | LD A,(IX + 4) 190 | SUB '0' 191 | LD E,A 192 | LD D,0 193 | ADD HL,DE 194 | RET 195 | 196 | 197 | -------------------------------------------------------------------------------- /BDSHELL/SRC/PROGRAM.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************************************************** 2 | ; * BDSHELL MAIN (SHARED) PROGRAM * 3 | ; * (C) ANDRES ORTIZ / ARMANDO PEREZ * 4 | ; ***************************************************************************** 5 | 6 | 7 | ; --- SLOT / RAM ROUTINES ----------------------------------------- 8 | 9 | 10 | INCLUDE SLOT.Z8A 11 | INCLUDE RAM.Z8A 12 | 13 | 14 | ; --- PROGRAM ----------------------------------------- 15 | 16 | 17 | 18 | ; - START -------------- 19 | ; - PROGRAM START 20 | ; - 21 | 22 | 23 | START 24 | 25 | ; THIS IS ONLY FOR ROM VERSION 26 | ; WAIT UNTIL DISK IS INITIALIZED 27 | 28 | IF PTYPE == TROM 29 | 30 | IF ROMDSK 31 | 32 | CALL SEARSLOT 33 | LD H,A 34 | LD L,#F7 35 | LD (HSTKE),HL 36 | LD HL,.DSK 37 | LD (HSTKE + 2),HL 38 | LD A,#C9 39 | LD (HSTKE + 4),A 40 | RET 41 | 42 | .DSK LD A,#C9 43 | LD (HSTKE),A 44 | ENDIF 45 | 46 | ENDIF 47 | 48 | DI 49 | 50 | 51 | ; CLEAR VARS 52 | 53 | LD HL,INITVARS 54 | LD DE,INITVARS + 1 55 | LD BC,ENDVARS - INITVARS 56 | LD (HL),0 57 | LDIR 58 | 59 | 60 | ; CLEAR FUNCTION KEYS 61 | 62 | CALL CLFNKEY 63 | 64 | ; GET SYSTEM 65 | 66 | LD A,(#2D) 67 | LD (SYSTEM),A 68 | LD A,(#2B) 69 | AND %10000000 70 | RLCA 71 | RLCA 72 | LD (FREQSET),A 73 | LD (SAVESP),SP 74 | 75 | LD A,(CNSDFG) 76 | LD (CNSDFGT),A 77 | 78 | ; SCREEN 0 W. 40 - 80 COL. 79 | ; KEEP USER COLORS 80 | 81 | LD A,(SYSTEM) 82 | AND A 83 | LD A,40 84 | JR Z,.SETCOL 85 | LD A,80 86 | .SETCOL LD (LINL40),A 87 | CALL ERAFNK 88 | XOR A 89 | CALL CHGMOD 90 | 91 | 92 | ; INIT VARS 93 | 94 | 95 | ; PRINT LOGO 96 | 97 | LD HL,TXTLOGO 98 | LD DE,#0101 99 | CALL PRINT 100 | 101 | 102 | ; GET SLOTVAR AND RAM VALUES 103 | 104 | IF (PTYPE == TCOM) 105 | 106 | LD A,(RAMAD0) 107 | LD (RAMPAGE0),A 108 | LD A,(RAMAD1) 109 | LD (RAMPAGE1),A 110 | LD (SLOTVAR),A 111 | LD A,(RAMAD2) 112 | LD (RAMPAGE2),A 113 | LD A,(RAMAD3) 114 | LD (RAMPAGE3),A 115 | LD A,RAM64K 116 | LD (RAMTYPUS),A 117 | 118 | ELSE 119 | 120 | CALL SEARSLOT 121 | LD (SLOTVAR),A 122 | CALL SEARRAM 123 | 124 | ENDIF 125 | 126 | ; THIS IS A BIT SPECIAL 127 | ; TO AVOID OVERWRITE DISK VARS 128 | ; WE DON'T INIT STACK POINTER 129 | ; HOWEVER IN 8K SYSTEM THERE IS NO DISK 130 | ; SO SP IS SET TO STANDARD #F380 131 | ; OF COURSE, ROM WITHOUT DISK MUST BE 132 | ; INITIALIZED AS STANDARD 133 | 134 | IF ( PTYPE == TROM and ROMDSK == 0 ) 135 | 136 | ELSE 137 | 138 | LD A,(RAMTYPUS) 139 | CP RAM8K 140 | JR NZ,.NOSTACK 141 | 142 | ENDIF 143 | 144 | ; DISABLE OLD HOOKS 145 | 146 | LD A,#C9 147 | LD (HKEYI),A 148 | LD (HTIMI),A 149 | 150 | LD SP,#F380 151 | 152 | .NOSTACK 153 | 154 | ; SHOW MSX SYSTEM 155 | 156 | CALL PTRMODEL 157 | 158 | ; SHOW RAM TYPE 159 | 160 | CALL PRTRTYPE 161 | 162 | ; SHOW DISK 163 | 164 | CALL PRTDISK 165 | 166 | ; SHOW BADCAT STATUS 167 | 168 | CALL PRTBADC 169 | 170 | CALL PRTCRLF 171 | 172 | 173 | ; DISABLE BADCAT 174 | 175 | CALL UARTDINI 176 | 177 | ; INTERRUPT 178 | 179 | LD HL,TXTIINT 180 | CALL PRINT.GEN 181 | CALL INTINIT 182 | 183 | ; UART INIT 184 | 185 | LD HL,TXTIUAR 186 | CALL PRINT.GEN 187 | CALL UARTINIT 188 | 189 | CALL PRTCRLF 190 | 191 | ; KEYBOARD INIT 192 | 193 | CALL KEYINIT 194 | 195 | ; CURSOR INIT 196 | 197 | CALL DEFCUR 198 | 199 | ; ROM ROUTINES AT PAGE 3 200 | 201 | LD HL,RROMRUT 202 | LD DE,RROMORG 203 | LD BC,RROMORGE - RROMORG 204 | LDIR 205 | 206 | ; SETSLTP0 AT PAGE 3 207 | 208 | LD HL,SETSLTP0 209 | LD DE,RROMORGE 210 | LD BC,SETSLTP0.END - SETSLTP0 211 | LDIR 212 | 213 | ; COPY OF VARS 214 | 215 | LD HL,RAMPAGE0 216 | LD DE,TRAM0 217 | LD BC,4 218 | LDIR 219 | 220 | LD A,(EXPTBL) 221 | LD (TEXPTBL),A 222 | 223 | LD HL,OLDHKEY 224 | LD DE,TOLDKEY 225 | LD BC,5 226 | LDIR 227 | 228 | LD HL,OLDHTIM 229 | LD DE,TOLDTIM 230 | LD BC,5 231 | LDIR 232 | 233 | 234 | 235 | ; CLEAN BUFFER 236 | 237 | CALL FLUSHBUF 238 | 239 | ; ENABLE RTS AND INTERRUPT 240 | 241 | LD A,#02 242 | OUT (BPORT + 4),A ; RTS = 1 TO RECEIVE AND LOOPBACK 243 | 244 | 245 | IF SENDIC 246 | 247 | ; SEND ATZ COMMAND 248 | 249 | LD HL,CMDATZ 250 | CALL SENDCMD 251 | 252 | ; WAIT UNTIL BUFFER IS EMPTY 253 | 254 | CALL WAITEBUF 255 | 256 | ; SEND ATE1 COMMAND 257 | 258 | IF ECHOON 259 | LD HL,CMDATE1 260 | ELSE 261 | LD HL,CMDATE0 262 | ENDIF 263 | 264 | CALL SENDCMD 265 | 266 | ; WAIT UNTIL BUFFER IS EMPTY 267 | 268 | CALL WAITEBUF 269 | 270 | ENDIF 271 | 272 | ; RESET INTERNAL JIFFY 273 | 274 | XOR A 275 | LD (INTCNT),A 276 | 277 | ; READY? 278 | 279 | LD HL,TXTREADY 280 | CALL PRINT.GEN 281 | 282 | ; PRINT CURSOR 283 | 284 | CALL PRTCUR 285 | 286 | LD A,1 287 | OUT (BPORT + 1),A ; ENABLE DATA RECEIVED INTERRUPT 288 | 289 | XOR A 290 | LD (JIFFY),A 291 | LD (MSTAT),A 292 | 293 | EI 294 | 295 | 296 | ; --- MAIN LOOP ----------------------------------------- 297 | 298 | 299 | ; - MAIN --------------- 300 | ; - MAIN LOOP 301 | ; - 302 | 303 | MAIN LD A,(KEYTRG) 304 | LD C,A 305 | 306 | ; CHECK F5 (AVOID ROM VERSION) 307 | 308 | IF PTYPE != TROM 309 | AND %00000010 310 | JP Z,EXIT 311 | ENDIF 312 | 313 | ; CHECK F1 TO LOAD ROM 314 | 315 | LD A,C 316 | AND %00100000 317 | JP Z,LOADROM 318 | 319 | ; WRITE DATA 320 | 321 | CALL WRTDATA 322 | 323 | ; READ DATA 324 | 325 | CALL READDATA 326 | 327 | ; PRINT CURSOR 328 | 329 | LD A,(MSTAT) 330 | AND STAWRTM | STAREADM 331 | CALL Z,PRTCUR 332 | 333 | 334 | EI 335 | JP MAIN 336 | 337 | 338 | 339 | 340 | ; --- DATA CONTROL ----------------------------------------- 341 | 342 | 343 | ; - WRTDATA ----------- 344 | ; - CHECK AND WRITE DATA 345 | ; - 346 | 347 | WRTDATA CALL RSINBUF 348 | JP NZ,.WRITE 349 | 350 | ; CLEAR FLAG 351 | 352 | .NOWRT LD A,(MSTAT) 353 | AND ~STAWRTM 354 | LD (MSTAT),A 355 | RET 356 | 357 | .WRITE PUSH AF 358 | LD A,#02 359 | OUT (BPORT + 4),A ; RTS = 1 TO RECEIVE AND LOOPBACK 360 | LD A,(MSTAT) 361 | AND STAWRTM 362 | JP NZ,.PRINT 363 | 364 | ; CLEAR CURSOR 365 | 366 | PUSH HL 367 | CALL CLRCUR 368 | POP HL 369 | 370 | ; PRINT RTS 371 | 372 | .PRINT LD A,(MSTAT) 373 | OR STAWRTM 374 | LD (MSTAT),A 375 | 376 | POP AF 377 | JP PRTRTS 378 | 379 | 380 | ; - READDATA ---------- 381 | ; - CHECK AND READ DATA 382 | ; - 383 | 384 | READDATA LD A,(MSTAT) 385 | AND STAWRTM 386 | RET NZ 387 | 388 | CALL INKEY 389 | JP NZ,.SEND 390 | 391 | .NOSEND LD A,(MSTAT) 392 | AND ~STAREADM 393 | LD (MSTAT),A 394 | RET 395 | 396 | ; SEND KEY 397 | 398 | .SEND CALL PRTKEY 399 | 400 | 401 | ; SET FLAG READ 402 | 403 | LD A,(MSTAT) 404 | OR STAREADM 405 | LD (MSTAT),A 406 | RET 407 | 408 | ; --- EXIT ----------------------------------------- 409 | 410 | IF PTYPE != TROM 411 | 412 | ; - EXIT -------------- 413 | ; - EXIT PROGRAM 414 | ; - 415 | 416 | EXIT 417 | 418 | ; CLOSING... 419 | 420 | LD HL,TXTCLOSE 421 | CALL PRINT.GEN 422 | 423 | DI 424 | 425 | ; DISABLE INTERRUPTS 426 | 427 | XOR A 428 | OUT (BPORT + 1),A 429 | 430 | 431 | ; RESTART HKEY ISR 432 | 433 | LD HL,OLDHKEY 434 | LD DE,HKEYI 435 | LD BC,5 436 | LDIR 437 | 438 | ; RESTORE HTIMI ISR 439 | 440 | LD HL,OLDHTIM 441 | LD DE,HTIMI 442 | LD BC,5 443 | LDIR 444 | 445 | LD HL,CMDCLOSE 446 | CALL SENDCMD 447 | 448 | ; WAIT... 449 | 450 | EI 451 | LD B,120 452 | .WAIT HALT 453 | DJNZ .WAIT 454 | 455 | CALL WAITEBUF 456 | 457 | 458 | CALL UARTDINI 459 | 460 | 461 | ; RESTORE FUNCTION KEYS 462 | 463 | CALL REFNKEY 464 | LD A,(CNSDFGT) 465 | AND A 466 | CALL NZ,DSPFNK 467 | 468 | ; BYE! 469 | 470 | LD HL,TXTBYE 471 | CALL PRINT.GEN 472 | 473 | ; MSX-DOS COMMAND, RETURN PAGE 0 474 | 475 | IF PTYPE = TCOM 476 | LD A,(RAMAD0) 477 | CALL SETSLTP0 478 | LD SP,(SAVESP) 479 | JP 0 480 | ENDIF 481 | 482 | 483 | LD SP,(SAVESP) 484 | RET 485 | 486 | 487 | ENDIF 488 | 489 | 490 | 491 | ; --- KEY / JOY ----------------------------------------- 492 | 493 | 494 | ; - INKEY -------------- 495 | ; - READ KEY 496 | ; - Z = 1 BUFFER EMPTY 497 | ; - OUTPUT: A KEY 498 | 499 | INKEY CALL CHSNS 500 | RET Z 501 | JP CHGET 502 | 503 | 504 | ; --- CONSOLE SPECIAL PRT ----------------------------------------- 505 | 506 | 507 | ; - PRTRTS ------------- 508 | ; - PRINT RTS BUFFER 509 | ; - A: SIZE 510 | ; - HL: POINTER 511 | ; 512 | 513 | PRTRTS LD B,A 514 | 515 | ; PRINT BUFFER 516 | 517 | .LOOP PUSH BC 518 | PUSH HL 519 | 520 | LD A,(HL) 521 | 522 | ; BACK? 523 | CP 8 524 | JP Z,.BACK 525 | 526 | ; IS != LF? 527 | 528 | CP #0A 529 | JP NZ,.NKEY 530 | 531 | ; LF 532 | CALL CHPUT 533 | LD A,#0D 534 | JP .NKEY 535 | 536 | ; SPECIAL BACKSPACE 537 | 538 | .BACK LD A,(CSRX) 539 | CP 1 540 | JP Z,.NEXT 541 | 542 | LD A,8 543 | CALL CHPUT 544 | LD A,' ' 545 | CALL CHPUT 546 | LD A,8 547 | 548 | ; WRITE BYTE 549 | 550 | .NKEY CALL CHPUT 551 | .NEXT POP HL 552 | INC L 553 | POP BC 554 | DJNZ .LOOP 555 | 556 | RET 557 | 558 | 559 | 560 | 561 | 562 | 563 | ; - PRTKEY ------------- 564 | ; - PRINT KEY 565 | ; - A: KEY 566 | ; - 567 | 568 | PRTKEY CP #08 569 | JP Z,PRTBACKS 570 | 571 | IF !ECHOON 572 | CP #0D 573 | JR NZ,.KEY 574 | LD A,#0A 575 | CALL CHPUT 576 | LD A,#0D 577 | .KEY PUSH AF 578 | CALL CHPUT 579 | POP AF 580 | ENDIF 581 | 582 | .SEND JP RSOUT 583 | 584 | 585 | ; - PRTBACKS ----------- 586 | ; - PRINT BACK SPACE 587 | ; - 588 | 589 | PRTBACKS LD A,(CSRX) 590 | CP 1 591 | RET Z 592 | 593 | IF !ECHOON 594 | LD A,' ' 595 | CALL CHPUT 596 | LD A,8 597 | CALL CHPUT 598 | LD A,8 599 | CALL CHPUT 600 | LD A,' ' 601 | CALL CHPUT 602 | LD A,8 603 | CALL CHPUT 604 | ENDIF 605 | 606 | LD A,8 607 | JP RSOUT 608 | 609 | 610 | ; --- PRINT ----------------------------------------- 611 | 612 | 613 | ; - PRTBADC ----------- 614 | ; - PRINT BADCAT STATUS 615 | ; - 616 | 617 | PRTBADC LD HL,TXTBCP 618 | CALL PRINT.GEN 619 | CALL CHECKBC 620 | LD HL,TXTNFOUN 621 | JR NZ,.PRINT 622 | LD HL,TXTFOUN 623 | .PRINT JP PRINT.GEN 624 | 625 | 626 | ; - PRTDISK ------------ 627 | ; - SHOW DISK STATUS 628 | ; - 629 | 630 | PRTDISK LD HL,TXTDISK 631 | CALL PRINT.GEN 632 | 633 | LD A,(HPHYD) 634 | LD HL,TXTDIS 635 | CP #C9 636 | JR Z,.PRINT 637 | LD HL,TXTENA 638 | .PRINT JP PRINT.GEN 639 | 640 | 641 | ; - PRTRTYPE ----------- 642 | ; - SHOW RAM TYPE 643 | ; - 644 | 645 | PRTRTYPE LD A,(RAMTYPUS) 646 | LD HL,.PNTTXT 647 | CALL ADDHLPNT 648 | JP PRINT.GEN 649 | 650 | .PNTTXT DEFW TXTRT8K 651 | DEFW TXTRT16K 652 | DEFW TXTRT32K 653 | DEFW TXTRT48K 654 | DEFW TXTRT64K 655 | 656 | 657 | ; - PTRMODEL ------------ 658 | ; - SHOW MSX MODEL 659 | ; - 660 | 661 | PTRMODEL LD HL,TXTMODEL 662 | CALL PRINT.GEN 663 | LD A,(SYSTEM) 664 | LD HL,.PNTTXT 665 | CALL ADDHLPNT 666 | JP PRINT.GEN 667 | 668 | .PNTTXT DEFW TXTMSX1 669 | DEFW TXTMSX2 670 | DEFW TXTMSX2P 671 | DEFW TXTMSXTR 672 | 673 | 674 | 675 | ; --- LOAD ROM ----------------------------------------- 676 | 677 | 678 | ; - LOADROM ------------ 679 | ; - LOAD ROM FILE 680 | ; - 681 | 682 | LOADROM CALL CLRCUR 683 | 684 | LD HL,TXTDOWN 685 | CALL PRINT.GEN 686 | 687 | ; DISABLE RTS 688 | 689 | XOR A 690 | OUT (BPORT + 4),A 691 | 692 | ; FLUSH BUFFER 693 | 694 | CALL FLUSHBUF 695 | 696 | ; ENABLE RTS 697 | 698 | LD A,#02 699 | OUT (BPORT + 4),A 700 | 701 | ; REQUEST FILE SIZE 702 | 703 | LD A,'<' 704 | CALL RSOUT 705 | 706 | LD B,60 * 4 ; APROX 4 SECONDS (NTSC) 707 | .WAIT HALT 708 | CALL CHINBUF 709 | CP 5 710 | JP NC,.LEN 711 | DJNZ .WAIT 712 | 713 | ; TIMEOUT ERROR 714 | 715 | XOR A 716 | OUT (BPORT + 4),A 717 | 718 | LD HL,TXTTOUT 719 | CALL PRINT.GEN 720 | 721 | .RETMAIN ; FLUSH BUF AND RETURN MAIN 722 | 723 | CALL FLUSHBUF 724 | 725 | LD A,#02 726 | OUT (BPORT + 4),A 727 | LD A,1 728 | OUT (BPORT + 1),A 729 | EI 730 | JP MAIN 731 | 732 | ; GET LEN 733 | 734 | .LEN DI 735 | XOR A 736 | OUT (BPORT + 4),A 737 | 738 | LD HL,STRNUM 739 | LD DE,STRNUM + 1 740 | LD BC,6 741 | LD (HL),0 742 | LDIR 743 | LD B,5 744 | 745 | LD HL,STRNUM 746 | 747 | .LOOPL PUSH HL 748 | CALL RSIN 749 | POP HL 750 | LD (HL),A 751 | INC HL 752 | DJNZ .LOOPL 753 | 754 | 755 | LD HL,TXTLOAD 756 | CALL PRINT.GEN 757 | LD HL,STRNUM 758 | CALL PRINT.GEN 759 | LD HL,TXTBYTE 760 | CALL PRINT.GEN 761 | 762 | LD HL,STRNUM 763 | CALL STR2INT 764 | 765 | ; HL BYTES 766 | 767 | CALL RXROM2M 768 | 769 | ; ERROR? 770 | 771 | JP .RETMAIN 772 | 773 | 774 | ; --- INCLUDES ----------------------------------------- 775 | 776 | ; BADCAT 777 | 778 | INCLUDE BADCAT.Z8A 779 | 780 | ; UART 781 | 782 | INCLUDE UART.Z8A 783 | 784 | ; INTERRUPT 785 | 786 | INCLUDE INTER.Z8A 787 | 788 | ; PRINT / OUTPUT 789 | 790 | INCLUDE PRINT.Z8A 791 | 792 | ; KEYBOARD 793 | 794 | INCLUDE KEYJOY.Z8A 795 | 796 | ; ROM LOAD 797 | 798 | INCLUDE ROM.Z8A 799 | 800 | ; GENERIC ROUTINES 801 | 802 | INCLUDE GENERIC.Z8A 803 | 804 | ; TABLES / RESOURCES 805 | 806 | INCLUDE TABLES.Z8A 807 | 808 | 809 | -------------------------------------------------------------------------------- /BDSHELL/SRC/RAM.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************** 2 | ; * RAM (SPECIAL PAGE 3) * 3 | ; ***************************************** 4 | 5 | 6 | ; - RAM ROUTINES ----------------------------------------- 7 | 8 | 9 | TMPSLTP0 EQU #8000 10 | 11 | ; - SEARRAM ------------- 12 | ; - SEARCH RAM (ALL PAGES) 13 | ; - 14 | 15 | 16 | SEARRAM LD A,RAM8K 17 | LD (RAMTYPUS),A 18 | LD A,(EXPTBL) 19 | LD (RAMPAGE0),A 20 | LD (RAMPAGE1),A 21 | LD (RAMPAGE2),A 22 | LD (RAMPAGE3),A 23 | XOR A 24 | LD (RAMCHK0),A 25 | LD (RAMCHK1),A 26 | LD (RAMCHK2),A 27 | LD (RAMCHK3),A 28 | 29 | CALL GETSLTP3 30 | LD (RAMPAGE3),A 31 | 32 | LD C,#C0 33 | CALL CHKMEMDI 34 | JR C,.END 35 | LD A,RAM16K 36 | LD (RAMTYPUS),A 37 | 38 | 39 | ; PAGE 1 40 | 41 | .SLOT40 LD C,#40 42 | CALL CHKMEM 43 | JR C,.SLOT80 44 | LD (RAMPAGE1),A 45 | LD A,1 46 | LD (RAMCHK1),A 47 | 48 | 49 | ; PAGE 2 50 | 51 | .SLOT80 LD C,#80 52 | CALL CHKMEM 53 | JR C,.END 54 | LD (RAMPAGE2),A 55 | LD A,1 56 | LD (RAMCHK2),A 57 | 58 | 59 | ; SPECIAL SLOT 0 60 | 61 | LD A,(RAMPAGE2) 62 | LD H,#80 63 | CALL ENASLT 64 | LD HL,SETSLTP0 65 | LD DE,TMPSLTP0 66 | LD BC,SETSLTP0.END - SETSLTP0 67 | LDIR 68 | 69 | ; PAGE 0 70 | 71 | .SLOT00 LD C,#00 72 | CALL CHKMEM 73 | JR C,.END 74 | LD (RAMPAGE0),A 75 | LD A,1 76 | LD (RAMCHK0),A 77 | 78 | ; - END 79 | 80 | .END LD A,(RAMTYPUS) 81 | CP RAM8K 82 | RET Z 83 | LD A,(RAMCHK2) 84 | OR A 85 | RET Z 86 | LD A,RAM32K 87 | LD (RAMTYPUS),A 88 | LD A,(RAMCHK1) 89 | OR A 90 | RET Z 91 | LD A,RAM48K 92 | LD (RAMTYPUS),A 93 | LD A,(RAMCHK0) 94 | OR A 95 | RET Z 96 | LD A,RAM64K 97 | LD (RAMTYPUS),A 98 | RET 99 | 100 | 101 | 102 | ; - CHK ROUTINES ----------------------------------------- 103 | 104 | 105 | 106 | 107 | ; - CHKMEM ------------- 108 | ; - CHECK MEM IN ALL SLOTS OF PAGE 109 | ; - C: PAGE 110 | ; - RETURNS: 111 | ; - CY NOT FOUND 112 | ; - 113 | 114 | CHKMEM 115 | LD A,#FF 116 | LD (THISSLT),A 117 | .LOOP PUSH BC 118 | CALL SIGSLOT 119 | POP BC 120 | CP #FF 121 | JR NZ,.CHK 122 | SCF 123 | RET 124 | .CHK 125 | PUSH BC 126 | CALL CHKMEMS0 127 | POP BC 128 | LD A,(THISSLT) 129 | RET NC 130 | JR .LOOP 131 | 132 | 133 | ; - CHKMEMS0 ----------- 134 | ; - CHECK MEM IN PAGE 135 | ; - C: PAGE 136 | ; - A: SLOT (FXXXSSPP 137 | ; - RETURNS: 138 | ; - CY = 1 NOT FOUND 139 | ; - IF SLOT 0 USES SPECIAL CHECK MEM 140 | ; - 141 | 142 | CHKMEMS0 LD B,A 143 | LD A,C 144 | OR A 145 | LD A,B 146 | JP Z,CHKMEMG0 147 | 148 | 149 | ; - CHKMEMGE ----------- 150 | ; - CHECK MEM IN PAGE 151 | ; - C: PAGE 152 | ; - A: SLOT (FXXXSSPP) 153 | ; - RETURNS: 154 | ; - CY = 1 NOT FOUND 155 | ; - 156 | 157 | CHKMEMGE PUSH BC 158 | PUSH HL 159 | LD H,C 160 | LD L,#10 161 | .LOOP PUSH AF 162 | CALL RDSLT 163 | CPL 164 | LD E,A 165 | POP AF 166 | PUSH DE 167 | PUSH AF 168 | CALL WRSLT 169 | POP AF 170 | POP DE 171 | PUSH AF 172 | PUSH DE 173 | CALL RDSLT 174 | POP BC 175 | LD B,A 176 | LD A,C 177 | CPL 178 | LD E,A 179 | POP AF 180 | PUSH AF 181 | PUSH BC 182 | CALL WRSLT 183 | POP BC 184 | LD A,C 185 | CP B 186 | JR NZ,.END 187 | POP AF 188 | DEC L 189 | JR NZ,.LOOP 190 | POP HL 191 | POP BC 192 | OR A 193 | RET 194 | .END POP AF 195 | POP HL 196 | POP BC 197 | SCF 198 | RET 199 | 200 | 201 | ; - SPECIAL PAGE 0 ----------------------------------------- 202 | 203 | 204 | ; - CHKMEMG0 ----------- 205 | ; - CHECK MEM IN PAGE 0 206 | ; - A: SLOT (FXXXSSPP) 207 | ; - CY = 1 NOT FOUND 208 | ; - 209 | 210 | CHKMEMG0 CALL TMPSLTP0 211 | LD C,#00 212 | CALL CHKMEMDI 213 | PUSH AF 214 | LD A,(EXPTBL) 215 | CALL TMPSLTP0 216 | POP AF 217 | RET 218 | 219 | 220 | ; - CHKMEMDI --------- 221 | ; - CHECK MEM IN PAGE C 222 | ; 223 | 224 | CHKMEMDI LD H,C 225 | LD L,#10 226 | .LOOP LD A,(HL) 227 | CPL 228 | LD C,A 229 | LD (HL),A 230 | LD A,(HL) 231 | LD B,A 232 | CPL 233 | LD (HL),A 234 | LD A,B 235 | CP C 236 | JR NZ,.NO 237 | DEC L 238 | JR NZ,.LOOP 239 | OR A 240 | RET 241 | .NO SCF 242 | RET 243 | 244 | 245 | 246 | -------------------------------------------------------------------------------- /BDSHELL/SRC/ROM.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************** 2 | ; * ROM RELATED * 3 | ; ***************************************** 4 | 5 | 6 | 7 | ; --- CHECK AND DOWNLOAD ----------------------------------------- 8 | 9 | 10 | RROMRUT 11 | ; RUN ROM ROUTINES 12 | 13 | PHASE RROMORG 14 | 15 | 16 | ; - RXROM2M ------------ 17 | ; - READ RX DATA (ROM) 18 | ; - TO RAM 19 | ; - HL: SIZE FILE 20 | ; - 21 | 22 | RXROM2M LD A,H 23 | AND #C0 24 | CP #C0 25 | JP Z,.LOAD48K 26 | 27 | LD A,H 28 | AND #80 29 | CP #80 30 | JP Z,.LOAD32K 31 | 32 | ; --- LOAD16K ----------------------------------------- 33 | 34 | 35 | .LOAD168K LD A,L 36 | AND A 37 | JP NZ,.LOAD32K 38 | 39 | LD A,(RAMTYPUS) 40 | CP RAM32K 41 | JP C,.NOTENMEM 42 | 43 | 44 | PUSH HL 45 | 46 | CALL PREPRUN 47 | 48 | ; ENABLE RAM PAGE 2 49 | 50 | LD A,(TRAM2) 51 | LD H,#80 52 | CALL ENASLT 53 | 54 | POP HL 55 | 56 | ; TRANSFER DATA TO PAGE 2 57 | 58 | LD DE,#8000 59 | CALL RX2MEM 60 | 61 | ; COPY TO PAGE 0 62 | 63 | LD A,(TRAM1) 64 | LD H,#40 65 | CALL ENASLT 66 | 67 | ; SET SLOT TO #4000 68 | 69 | LD HL,RROMORGE 70 | LD DE,#4000 71 | LD BC,SETSLTP0.END - SETSLTP0 72 | LDIR 73 | 74 | ; SET RAM ON PAGE 0 75 | 76 | LD A,(TRAM0) 77 | CALL #4000 78 | 79 | ; COPY DATA 80 | 81 | LD HL,#8000 82 | LD DE,#0000 83 | LD BC,#4000 84 | LDIR 85 | 86 | ; BIOS ROM PAGE 0 87 | 88 | LD A,(TEXPTBL) 89 | CALL #4000 90 | 91 | ; COPY ROM DATA TO PAGE 2 92 | 93 | LD HL,#8000 94 | LD DE,#4000 95 | LD BC,#4000 96 | LDIR 97 | 98 | ; RUN 99 | 100 | JP EXECROM 101 | 102 | 103 | 104 | ; --- LOAD32K ----------------------------------------- 105 | 106 | 107 | .LOAD32K LD A,L 108 | AND A 109 | JP NZ,.LOAD48K 110 | 111 | LD A,(RAMTYPUS) 112 | CP RAM64K 113 | JP C,.NOTENMEM 114 | 115 | 116 | PUSH HL 117 | 118 | CALL PREPRUN 119 | 120 | ; ENABLE RAM PAGE 1 121 | 122 | LD A,(TRAM1) 123 | LD H,#40 124 | CALL ENASLT 125 | 126 | ; ENABLE RAM PAGE 2 127 | 128 | LD A,(TRAM2) 129 | LD H,#80 130 | CALL ENASLT 131 | 132 | POP HL 133 | 134 | LD DE,#4000 135 | CALL RX2MEM 136 | 137 | 138 | ; CHECK RUN ADDRESS 139 | 140 | LD HL,(#4000) 141 | CALL .CHECKHD 142 | LD HL,(#4002) 143 | JR Z,.CHECKAD 144 | LD HL,(#8002) 145 | .CHECKAD LD A,H 146 | CP #40 147 | JP NC,EXECROM 148 | 149 | 150 | ; SPECIAL PAGE 0 151 | 152 | LD HL,#8000 153 | LD DE,RROMORGE 154 | LD BC,SETSLTP0.END - SETSLTP0 155 | CALL SWAPMEM 156 | 157 | LD A,(TRAM0) 158 | CALL #8000 159 | 160 | LD HL,#4000 161 | LD DE,#0000 162 | LD BC,#4000 163 | LDIR 164 | 165 | LD A,(TEXPTBL) 166 | CALL #8000 167 | 168 | LD HL,#8000 169 | LD DE,RROMORGE 170 | LD BC,SETSLTP0.END - SETSLTP0 171 | CALL SWAPMEM 172 | 173 | LD HL,#8000 174 | LD DE,#4000 175 | LD BC,#4000 176 | LDIR 177 | 178 | JP EXECROM 179 | 180 | .CHECKHD LD DE,#4241 181 | JP DCOMPR_B 182 | 183 | 184 | ; --- LOAD48K ----------------------------------------- 185 | 186 | 187 | .LOAD48K LD A,L 188 | AND A 189 | JP NZ,.MAX48K 190 | 191 | LD A,(RAMTYPUS) 192 | CP RAM64K 193 | JP C,.NOTENMEM 194 | 195 | PUSH HL 196 | 197 | CALL PREPRUN 198 | 199 | ; ENABLE RAM PAGE 1 200 | 201 | LD A,(TRAM1) 202 | LD H,#40 203 | CALL ENASLT 204 | 205 | ; ENABLE RAM PAGE 2 206 | 207 | LD A,(TRAM2) 208 | LD H,#80 209 | CALL ENASLT 210 | 211 | ; SET SLOT TO #8000 212 | 213 | LD HL,RROMORGE 214 | LD DE,#8000 215 | LD BC,SETSLTP0.END - SETSLTP0 216 | LDIR 217 | 218 | LD A,(TRAM0) 219 | CALL #8000 220 | 221 | POP HL 222 | 223 | LD DE,#0000 224 | CALL RX2MEM 225 | 226 | ; NOW WE NEED RETURN BIOS TO PAGE 0 227 | 228 | LD HL,#8000 229 | LD DE,RROMORGE 230 | LD BC,SETSLTP0.END - SETSLTP0 231 | CALL SWAPMEM 232 | 233 | LD A,(TEXPTBL) 234 | CALL #8000 235 | 236 | LD HL,#8000 237 | LD DE,RROMORGE 238 | LD BC,SETSLTP0.END - SETSLTP0 239 | CALL SWAPMEM 240 | 241 | 242 | ; RUN ROM 243 | 244 | JP EXECROM 245 | 246 | 247 | ; --- ERRORS ----------------------------------------- 248 | 249 | 250 | ; MAX 48K 251 | 252 | .MAX48K LD HL,TXTMAX48 253 | 254 | ; GENERIC ERROR 255 | 256 | .ERRORPRT CALL PRINT.GEN 257 | .ERROR SCF 258 | RET 259 | 260 | ; NOT ENOUGH MEMORY 261 | 262 | .NOTENMEM LD HL,TXTNEMEM 263 | JR .ERRORPRT 264 | 265 | 266 | ; --- RUN ROM ----------------------------------------- 267 | 268 | ; - PREPRUN ------------- 269 | ; - PREPARE TO RUN ROM 270 | ; - 271 | 272 | PREPRUN DI 273 | 274 | ; RESTART HKEY ISR 275 | 276 | LD HL,TOLDKEY 277 | LD DE,HKEYI 278 | LD BC,5 279 | LDIR 280 | 281 | ; RESTORE HTIMI ISR 282 | 283 | LD HL,TOLDTIM 284 | LD DE,HTIMI 285 | LD BC,5 286 | LDIR 287 | 288 | RET 289 | 290 | 291 | 292 | ; - EXECROM ----------- 293 | ; - EXECUTE LOADED (MEMORY) ROM 294 | ; - 295 | 296 | EXECROM DI 297 | 298 | ; UART DEINIT 299 | 300 | LD A,%00000111 301 | OUT (BPORT + 3),A 302 | XOR A 303 | OUT (BPORT + 4),A 304 | OUT (BPORT + 1),A 305 | 306 | ; CLEAR BDOS HOOKS 307 | 308 | IF PTYPE = TCOM 309 | LD A,#C9 310 | LD (#F368),A 311 | LD (#F36B),A 312 | LD (#F36E),A 313 | ENDIF 314 | 315 | ; PRINT MSG 316 | 317 | LD HL,.TXTRROM 318 | .PRINT LD A,(HL) 319 | AND A 320 | JR Z,.SCREEN1 321 | PUSH HL 322 | CALL CHPUT 323 | POP HL 324 | INC HL 325 | JR .PRINT 326 | 327 | ; SCREEN 1 (A-TRAIN) 328 | 329 | .SCREEN1 XOR A 330 | LD (CSRSW),A 331 | LD A,15 332 | LD (FORCLR),A 333 | LD A,4 334 | LD (BAKCLR),A 335 | LD A,7 336 | LD (BDRCLR),A 337 | LD A,29 338 | LD (LINL32),A 339 | LD A,1 340 | CALL CHGMOD 341 | 342 | DI 343 | 344 | ; CHECK RUN PAGE / ADDRESS 345 | 346 | LD HL,(#4000) 347 | LD DE,#4241 348 | RST DCOMPR_B 349 | LD HL,(#4002) 350 | JR Z,.FRUN 351 | LD HL,(#8002) 352 | .FRUN LD A,H 353 | CP #40 354 | JR NC,.STAND 355 | 356 | PUSH HL 357 | 358 | ; PAGE 0 ADDRESS 359 | 360 | LD HL,#8000 361 | LD DE,RROMORGE 362 | LD BC,SETSLTP0.END - SETSLTP0 363 | CALL SWAPMEM 364 | 365 | LD A,(TRAM0) 366 | CALL #8000 367 | 368 | LD HL,#8000 369 | LD DE,RROMORGE 370 | LD BC,SETSLTP0.END - SETSLTP0 371 | CALL SWAPMEM 372 | 373 | POP HL 374 | 375 | .STAND CALL .RUN 376 | LD HL,HSTKE 377 | .RUN JP (HL) 378 | 379 | .TXTRROM DEFB #0D, #0A 380 | DEFM "Run ROM file..." 381 | DEFB #0D, #0A, 0 382 | 383 | 384 | 385 | ; --- TRANSFER / DOWNLOAD ----------------------------------------- 386 | 387 | 388 | ; - RX2MEM ------------ 389 | ; - TRANSFER HL BYTES FROM 390 | ; - UART TO MEM 391 | ; - HL: BYTES TO TRANSFER 392 | ; - DE: DEST 393 | ; - 394 | 395 | RX2MEM DI 396 | 397 | ; DISABLE INTERRUPTS 398 | 399 | XOR A 400 | OUT (BPORT + 1),A 401 | 402 | ; START DOWNLOAD 403 | 404 | LD A,'>' 405 | CALL .RSOUT 406 | LD A,'+' 407 | CALL .RSOUT 408 | 409 | .NOINIT IN A,(BPORT + 5) 410 | AND 1 411 | JR NZ,.MRXFIFO 412 | .LBC LD A,2 413 | OUT (BPORT + 4),A 414 | JR .NOINIT 415 | .MRXFIFO IN A,(BPORT + 5) 416 | AND 1 417 | JR Z,.LBC 418 | 419 | ; READ BYTE 420 | 421 | IN A,(BPORT) 422 | LD (DE),A 423 | INC DE 424 | DEC HL 425 | LD A,H 426 | OR L 427 | JR NZ,.MRXFIFO 428 | 429 | RET 430 | 431 | ; MEM RSOUT 432 | 433 | .RSOUT PUSH AF 434 | .WAIT IN A,(BPORT + 5) 435 | AND 32 436 | JP Z,.WAIT 437 | POP AF 438 | OUT (BPORT),A 439 | RET 440 | 441 | 442 | 443 | ; - SWAPMEM ------------ 444 | ; - SWAP TWO MEMORY BLOCKS 445 | ; - HL: BLOCK 1 POINTER 446 | ; - DE: BLOCK 2 POINTER 447 | ; - BC: SIZE 448 | ; - 449 | 450 | SWAPMEM PUSH BC 451 | LD C,(HL) 452 | LD A,(DE) 453 | EX DE,HL 454 | LD (HL),C 455 | LD (DE),A 456 | POP BC 457 | INC HL 458 | INC DE 459 | DEC BC 460 | LD A,B 461 | OR C 462 | JR NZ,SWAPMEM 463 | RET 464 | 465 | 466 | 467 | ; --- EXTRA VARS COPY ----------------------------------------- 468 | 469 | 470 | TRAM0 DEFB 0 471 | TRAM1 DEFB 0 472 | TRAM2 DEFB 0 473 | TRAM3 DEFB 0 474 | TEXPTBL DEFB 0 475 | TOLDKEY DEFS 5 476 | TOLDTIM DEFS 5 477 | 478 | RROMORGE 479 | 480 | DEPHASE 481 | 482 | 483 | 484 | -------------------------------------------------------------------------------- /BDSHELL/SRC/SLOT.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************** 2 | ; * SLOT ROUTINES * 3 | ; ***************************************** 4 | 5 | 6 | 7 | ; - SIGSLOT ------------- 8 | ; - RETURNS IN A THE NEXT SLOT 9 | ; - INIT THISSLT HAS TO BE #FF. 10 | ; - IF NO MORE SLOTS, IT RETURNS A=#FF. 11 | ; - 12 | 13 | SIGSLOT LD A,(THISSLT) 14 | CP #FF 15 | JR NZ,.SIGSLT 16 | LD A,(EXPTBL) 17 | AND %10000000 18 | LD (THISSLT),A 19 | RET 20 | .SIGSLT LD A,(THISSLT) 21 | CP %10001111 22 | JR Z,.NOMASLT 23 | CP %00000011 24 | JR Z,.NOMASLT 25 | BIT 7,A 26 | JR NZ,.SLTEXP 27 | .SLTSIMP AND %00000011 28 | INC A 29 | LD C,A 30 | LD B,0 31 | LD HL,EXPTBL 32 | ADD HL,BC 33 | LD A,(HL) 34 | AND %10000000 35 | OR C 36 | LD (THISSLT),A 37 | RET 38 | .SLTEXP LD C,A 39 | AND %00001100 40 | CP %00001100 41 | LD A,C 42 | JR Z,.SLTSIMP 43 | ADD A,%00000100 44 | LD (THISSLT),A 45 | RET 46 | .NOMASLT LD A,#FF 47 | RET 48 | .END 49 | 50 | 51 | 52 | 53 | 54 | ; - SEARSLOT ------------ 55 | ; - SEARCH ROM SLOT 56 | ; - ROM IN PAGE 1 (#4000 - #7FFF) 57 | 58 | SEARSLOT CALL RSLREG 59 | RRCA 60 | RRCA 61 | AND 3 62 | LD C,A 63 | LD B,0 64 | LD HL,EXPTBL 65 | ADD HL,BC 66 | LD A,(HL) 67 | AND A 68 | JP P,.NOEXP 69 | OR C 70 | LD C,A 71 | INC HL 72 | INC HL 73 | INC HL 74 | INC HL 75 | LD A,(HL) 76 | AND %00001100 77 | .NOEXP OR C 78 | LD H,#80 79 | RET 80 | 81 | 82 | ; - SETSLOT ------------ 83 | ; - SEARCH AND SET SLOT 84 | ; - OUTPUT: 85 | ; - A SLOT 86 | 87 | SETSLOT CALL SEARSLOT 88 | PUSH AF 89 | CALL ENASLT 90 | POP AF 91 | RET 92 | 93 | 94 | ; - RECBIOS ------------- 95 | ; - SET BIOS ROM SLOT 96 | ; - 97 | 98 | RECBIOS LD A,(EXPTBL) 99 | 100 | ; - SETSLTP0 ------------ 101 | ; - SET SLOT IN PAGE 0 102 | ; - A: SLOT (FXXXSSPP) 103 | ; - 104 | 105 | SETSLTP0 DI 106 | LD B,A 107 | IN A,(#A8) 108 | AND %11111100 109 | LD D,A 110 | LD A,B 111 | AND #03 112 | OR D 113 | LD D,A 114 | OUT (#A8),A 115 | LD A,B 116 | AND A 117 | RET P 118 | AND #03 119 | RRCA 120 | RRCA 121 | AND %11000000 122 | LD C,A 123 | LD A,D 124 | AND %00111111 125 | OR C 126 | LD C,A 127 | LD A,B 128 | AND %00001100 129 | RRCA 130 | RRCA 131 | AND #03 132 | LD B,A 133 | LD A,C 134 | OUT (#A8),A 135 | LD A,(#FFFF) 136 | CPL 137 | AND %11111100 138 | OR B 139 | LD (#FFFF),A 140 | LD C,A 141 | LD A,D 142 | OUT (#A8),A 143 | RET 144 | .END 145 | 146 | 147 | ; - GETSLTP3 ------------ 148 | ; - GET SLOT PAGE 3 149 | ; - OUTPUT: A SLOT 150 | ; - 151 | 152 | GETSLTP3 CALL RSLREG 153 | RLCA 154 | RLCA 155 | AND 3 156 | LD C,A 157 | LD B,0 158 | LD HL,EXPTBL 159 | ADD HL,BC 160 | LD A,(HL) 161 | AND #80 162 | OR C 163 | LD C,A 164 | INC HL 165 | INC HL 166 | INC HL 167 | INC HL 168 | LD A,(HL) 169 | RLCA 170 | RLCA 171 | RLCA 172 | RLCA 173 | AND #0C 174 | OR C 175 | RET 176 | 177 | 178 | ; - SETSLTP3 ------------ 179 | ; - SET SLOT IN PAGE 3 180 | ; - A: SLOT (FXXXSSPP) 181 | ; - 182 | SETSLTP3 POP HL 183 | .NOMEM LD B,A 184 | IN A,(#A8) 185 | AND %00111111 186 | LD D,A 187 | LD A,B 188 | AND 03 189 | RRCA 190 | RRCA 191 | OR D 192 | LD D,A 193 | OUT (#A8),A 194 | LD A,B 195 | BIT 7,A 196 | JR Z,.EXIT 197 | LD A,B 198 | AND %00001100 199 | RRCA 200 | RRCA 201 | RRCA 202 | RRCA 203 | AND %11000000 204 | LD B,A 205 | LD A,(#FFFF) 206 | CPL 207 | AND %00111111 208 | OR B 209 | LD (#FFFF),A 210 | .EXIT JP (HL) 211 | .END 212 | 213 | 214 | ; ***************************************** 215 | ; * PAGE 3 ROUTINES * 216 | ; ***************************************** 217 | 218 | 219 | ; - ROM2P3 -------------- 220 | ; - ROM PAGE 3 DATA TO 221 | ; - RAM PAGE 3 222 | ; - HL: SOURCE 223 | ; - DE: DEST 224 | ; - BC: SIZE 225 | ; - 226 | 227 | ROM2P3 EXX 228 | LD A,(RAMPAGE3) 229 | LD E,A 230 | LD A,(SLOTVAR) 231 | CALL SETSLTP3 232 | EXX 233 | LD A,(HL) 234 | INC HL 235 | EXX 236 | EX AF,AF 237 | LD HL,.RET 238 | LD A,E 239 | JP SETSLTP3.NOMEM 240 | .RET EX AF,AF 241 | EXX 242 | LD (DE),A 243 | INC DE 244 | DEC BC 245 | LD A,B 246 | OR C 247 | JP NZ,ROM2P3 248 | RET 249 | 250 | -------------------------------------------------------------------------------- /BDSHELL/SRC/TABLES.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************** 2 | ; * TABLES / RESOURCES * 3 | ; ***************************************** 4 | 5 | 6 | 7 | 8 | ; --- COMMANDS ----------------------------------------- 9 | 10 | 11 | CMDATE1 DEFM "ATE1", #0D, 0 12 | CMDATE0 DEFM "ATE0", #0D, 0 13 | CMDATZ DEFM "ATZ", #0D, 0 14 | CMDATH DEFM "ATH", #0D, 0 15 | CMDCLOSE DEFM "+++", 0 16 | 17 | ; --- TEXT ----------------------------------------- 18 | 19 | 20 | 21 | TXTINTR DEFB #0D, #0A, 0 22 | TXTLOGO DEFM "BaDCaT Shell Terminal v1.0" 23 | DEFB #0D, #0A 24 | DEFM "(c) 2020 by Armando Perez" 25 | DEFB #0D, #0A 26 | DEFB #0D, #0A 27 | DEFM "Based on the original work of:" 28 | DEFB #0D, #0A 29 | DEFM "Andres Ortiz & Oduvaldo Pavan Junior" 30 | DEFB #0D, #0A 31 | DEFB #0D, #0A, 0 32 | 33 | TXTMODEL DEFM " - System: ",0 34 | TXTMSX1 DEFM "MSX", #0D, #0A, 0 35 | TXTMSX2 DEFM "MSX2", #0D, #0A, 0 36 | TXTMSX2P DEFM "MSX2+", #0D, #0A, 0 37 | TXTMSXTR DEFM "MSX Turbo R", #0D, #0A, 0 38 | 39 | TXTRT8K DEFM " - Ram: 8k", #0D, #0A,0 40 | TXTRT16K DEFM " - Ram: 16k", #0D, #0A,0 41 | TXTRT32K DEFM " - Ram: 32k", #0D, #0A,0 42 | TXTRT48K DEFM " - Ram: 48k", #0D, #0A,0 43 | TXTRT64K DEFM " - Ram: 64k or higher", #0D, #0A,0 44 | 45 | TXTDISK DEFM " - Disk System: ",0 46 | TXTENA DEFM "Enabled" 47 | DEFB #0D, #0A, 0 48 | TXTDIS DEFM "Disabled" 49 | DEFB #0D, #0A, 0 50 | 51 | TXTBCP DEFM " - BaDCat: ",0 52 | TXTFOUN DEFM "Found" 53 | DEFB #0D, #0A, 0 54 | TXTNFOUN DEFM "Not Found" 55 | DEFB #0D, #0A, 0 56 | 57 | TXTIINT DEFM " - Initializing interrupt" 58 | DEFB #0D, #0A, 0 59 | 60 | TXTIUAR DEFM " - Initializing UART" 61 | DEFB #0D, #0A, 0 62 | 63 | TXTREADY DEFM "Ready" 64 | DEFB #0D, #0A, 0 65 | 66 | TXTBYE DEFB #0D, #0A 67 | DEFM "Bye ^^" 68 | DEFB #0D, #0A, 0 69 | 70 | TXTCLOSE DEFB #0D, #0A 71 | DEFM "Closing connection..." 72 | DEFB #0D, #0A, 0 73 | 74 | 75 | TXTDOWN DEFB #0D, #0A 76 | DEFM "Get file info...",0 77 | DEFB #0D, #0A, 0 78 | 79 | TXTTOUT DEFB #0D, #0A 80 | DEFM "BaDCat did not respond!" 81 | DEFB #0D, #0A, 0 82 | 83 | TXTLOAD DEFB #0D, #0A 84 | DEFM "Loading: ",0 85 | TXTBYTE DEFM " bytes" 86 | DEFB #0D, #0A, 0 87 | 88 | 89 | TXTMAX48 DEFB #0D, #0A 90 | DEFM "Error: Max size file 48k" 91 | DEFB #0D, #0A, 0 92 | 93 | TXTNEMEM DEFB #0D, #0A 94 | DEFM "Error: Not enough memory" 95 | DEFB #0D, #0A, 0 96 | 97 | -------------------------------------------------------------------------------- /BDSHELL/SRC/UART.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************** 2 | ; * UART * 3 | ; ***************************************** 4 | 5 | 6 | ; --- INIT / DEINIT ----------------------------------------- 7 | 8 | 9 | ; - UARTINIT ----------- 10 | ; - INIT UART/BADCAT RELATED 11 | ; - 12 | 13 | UARTINIT DI 14 | XOR A 15 | OUT (BPORT + 1),A ; DISABLE INTERRUPTS 16 | OUT (BPORT + 4),A ; RST = 0 TO AVOID RECEIVING BYTES 17 | 18 | ; UNSET RTS 19 | ; ENABLE FIFO 20 | 21 | LD A,#87 22 | OUT (BPORT + 2),A 23 | 24 | ; SET SPEED 25 | 26 | LD A,#80 ; SET-UP ACCESS TO BAUD DIVISOR LATCH (DLAB FLAG) 27 | OUT (BPORT + 3),A ; WRITING 0X80 (BIT 7 SET) TO THE LCR (0X83) REGISTER 28 | LD A,#02 ; PROGRAM DLL (LOW BYTE) 29 | OUT (BPORT),A ; DLL=01, DLM=0 -> 57K6 BAUDS BY DEFAULT 30 | XOR A 31 | OUT (BPORT + 1),A 32 | 33 | ; SET PROTOCOL 34 | 35 | LD A,#03 ; 8, N, 1 WRITTING 0X03 00000011B 36 | OUT (BPORT + 3),A ; TO LCR (0X83) REGISTER. THIS RESET THE DLAB FLAG 37 | 38 | RET 39 | 40 | 41 | ; - UARTDINI ----------- 42 | ; - UART DEACTIVATE 43 | ; - 44 | 45 | UARTDINI DI 46 | LD A,%00000111 47 | OUT (BPORT + 3),A 48 | XOR A 49 | OUT (BPORT + 4),A 50 | OUT (BPORT + 1),A 51 | RET 52 | 53 | 54 | 55 | ; --- BUFFER ----------------------------------------- 56 | 57 | 58 | ; - WAITEBUF ----------- 59 | ; - WAIT UNTIL BUFFER IS EMPTY 60 | ; - 61 | 62 | WAITEBUF IN A,(BPORT + 5) 63 | AND 1 64 | JR Z,.END 65 | IN A,(BPORT) 66 | JR WAITEBUF 67 | .END IN A,(BPORT + 2) 68 | 69 | 70 | ; - FLUSHBUF ----------- 71 | ; - FLUSH RX BUFFER 72 | ; - 73 | 74 | FLUSHBUF XOR A 75 | LD (RPTR),A 76 | LD (WPTR),A 77 | LD HL,RXBUFF 78 | LD DE,RXBUFF + 1 79 | LD BC,BUFFSIZE - 1 80 | LD (HL),0 81 | LDIR 82 | RET 83 | 84 | 85 | ; - CHINBUF ------------ 86 | ; - RETURN NUMBER OF UNREADED 87 | ; - BYTES IN BUFFER IN A 88 | ; - Z = 1 EMPTY BUFFER 89 | ; - WPTR IS ALWAYS > RPTR 90 | ; - 91 | 92 | CHINBUF LD A,(RPTR) 93 | LD C,A 94 | LD A,(WPTR) 95 | SUB C 96 | RET 97 | 98 | 99 | ; --- READ / WRITE ----------------------------------------- 100 | 101 | 102 | ; - RSIN --------------- 103 | ; - RECEIVE ONE BYTE 104 | ; - FROM RING BUFFER 105 | ; - A: BYTE RECEIVED 106 | ; - Z: NO BYTES LEFT 107 | ; - 108 | 109 | 110 | RSIN LD A,(WPTR) 111 | LD C,A 112 | LD A,(RPTR) 113 | CP C 114 | RET Z ; WPTR == RPTR NO BYTES LEFT 115 | 116 | ; C BYTES TO RECEIVE 117 | ; A, RPTR 118 | 119 | LD D,0 120 | LD E,A 121 | INC A 122 | LD (RPTR),A 123 | LD HL,RXBUFF 124 | ADD HL,DE 125 | LD A,(HL) 126 | RET 127 | 128 | 129 | ; - RSINBUF ---------- 130 | ; - PREPARE FOR READ 131 | ; - CONSECUTIVE IN BYTES 132 | ; - OUTPUT: 133 | ; - A: BYTES TO READ 134 | ; - HL: POINTER TO NEXT BYTE TO READ 135 | ; - Zy = 1 BUFFER EMPTY 136 | ; - WPTR = RPTR 137 | ; 138 | 139 | RSINBUF DI 140 | LD A,(RPTR) 141 | LD L,A 142 | LD A,(WPTR) 143 | EI 144 | LD (RPTR),A 145 | SUB L 146 | LD H,RXBUFF >> 8 147 | RET 148 | 149 | 150 | 151 | 152 | ; - RSOUT ------------- 153 | ; - PUT BYTE IN THE TX FIFO 154 | ; - A: BYTE TO BE SENT 155 | ; - 156 | 157 | RSOUT PUSH AF 158 | .WAIT IN A,(BPORT + 5) 159 | AND 32 160 | JP Z,.WAIT 161 | POP AF 162 | OUT (BPORT),A 163 | RET 164 | 165 | 166 | 167 | ; --- INTERRUPT ----------------------------------------- 168 | 169 | 170 | ; - UARTINT ------------ 171 | ; - UART INTERRUPT 172 | ; - 173 | 174 | UARTINT 175 | 176 | ; CHECK UART IIR REGISTER 177 | 178 | IN A,(BPORT + 2) 179 | AND 1 ; 11000100 (RECEIVED DATA INTERRUPT, FIFO TRIGGER) 180 | RET NZ 181 | 182 | 183 | ; UNSET RTS 184 | 185 | XOR A 186 | OUT (BPORT + 4),A 187 | 188 | ; UART INTERRUPT, RX DATA AVAILABLE. 189 | 190 | ; FILL THE BUFFER UNTIL IT IS FULL OR THERE IS NOT MORE DATA 191 | ; RING BUFFER IS IMPLEMENTED. 192 | 193 | LD H,RXBUFF >> 8 194 | LD A,(WPTR) 195 | LD L,A 196 | 197 | .LOOP IN A,(BPORT + 5) 198 | AND 1 199 | JP Z,.END 200 | 201 | 202 | IN A,(BPORT) ; GET BYTE! 203 | LD (HL),A 204 | INC L 205 | JP .LOOP 206 | 207 | .END LD A,L 208 | LD (WPTR),A 209 | RET 210 | 211 | ; --- COMMANDS ----------------------------------------- 212 | 213 | 214 | ; - SENDCMD -------------- 215 | ; - SEND COMMAND 216 | ; - HL: POINTER TO COMMAND 217 | ; - 218 | 219 | SENDCMD LD A,(HL) 220 | AND A 221 | JP Z,.END 222 | INC HL 223 | CALL RSOUT 224 | JP SENDCMD 225 | .END LD B,80 226 | EI 227 | .WAIT HALT 228 | DJNZ .WAIT 229 | RET 230 | 231 | 232 | 233 | -------------------------------------------------------------------------------- /BDSHELL/SRC/VARS.Z8A: -------------------------------------------------------------------------------- 1 | ; ***************************************** 2 | ; * VARS (ROM PROGRAM) * 3 | ; ***************************************** 4 | 5 | 6 | ; --- INCLUDES ----------------------------------------- 7 | 8 | 9 | INCLUDE HARD.Z8A 10 | INCLUDE CONST.Z8A 11 | 12 | ORG PGMRAM 13 | 14 | INCLUDE GVARS.Z8A 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /BDTERM/BDterm.asm: -------------------------------------------------------------------------------- 1 | /* 2 | -- 3 | -- BaDCaT Terminal 4 | -- Revision 1.10 5 | -- 6 | -- Requires SJASM to compile 7 | -- Copyright (c) 2020 Andres Ortiz (andres.ortizg1@gmail.com) 8 | -- All rights reserved. 9 | -- 10 | -- Redistribution and use of this source code or any derivative works, are 11 | -- permitted provided that the following conditions are met: 12 | -- 13 | -- 1. Redistributions of source code must retain the above copyright notice, 14 | -- this list of conditions and the following disclaimer. 15 | -- 2. Redistributions in binary form must reproduce the above copyright 16 | -- notice, this list of conditions and the following disclaimer in the 17 | -- documentation and/or other materials provided with the distribution. 18 | -- 3. Redistributions may not be sold, nor may they be used in a commercial 19 | -- product or activity without specific prior written permission. 20 | -- 4. Source code of derivative works MUST be published to the public. 21 | -- 22 | -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 | -- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | -- PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 26 | -- CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | -- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | -- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 29 | -- OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 | -- WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 31 | -- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 32 | -- ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | -- 34 | */ 35 | output "BDterm.bin" 36 | 37 | // Bios Routines 38 | POSIT equ #00C6 ; H -> Y coordinate of cursor, L -> X coordinate of cursor 39 | ERAFNK equ #00CC 40 | DSPFNK equ #00CF 41 | ENASLT equ #0024 42 | slotvar equ #8501 ; My Rom slot 43 | RSLREG equ #0138 44 | BREAKX equ #00B7 ; check Ctrl-STOP 45 | DCOMPR equ #0020 46 | // HOOKS 47 | HTIMI equ #FD9F ; VBLANK 48 | HKEYI equ #FD9A ; H.KEYI 49 | 50 | // System Variables 51 | GETPNT equ #F3FA 52 | old_isr equ #F200 ; 5 bytes for the old isr jump code 53 | CSRX equ #F3DD ; Current cursor X-position 54 | CSRY equ #F3DC ; Current cursor Y-position 55 | JIFFY equ #FC9E ; To count VBLANK interrupts 56 | EXPTBL equ #FCC1 ; Bios Slot / Expansion Slot 57 | CLIKSW equ #F3DB ; Key click 58 | 59 | 60 | // UART baseport 61 | baseport equ #80 62 | 63 | // Ring buffer version 64 | // 256 bytes Ring buffer is implemented, so buffersize var is not really needed 65 | buffersize equ 256 66 | 67 | 68 | 69 | 70 | db #fe 71 | dw START 72 | dw END 73 | dw START 74 | org #C000 ; Program in page 3 75 | 76 | 77 | START: 78 | call ERAFNK ; Delete function keys 79 | ld b,160 80 | ld ix,0xF87F ; Delete F1 function key 81 | .efnk ld (ix),0 82 | inc ix 83 | djnz .efnk 84 | 85 | ld hl,TEXT_INIT 86 | call print_var_len_text 87 | call PUTCRLF 88 | 89 | ; Manage interrupts 90 | ; Save old isr at old_isr 91 | ld hl,HKEYI 92 | ld de,old_isr 93 | ld bc,5 94 | ldir 95 | 96 | ; UART ISR install 97 | di 98 | ld a,#c3 99 | ld hl,UART_isr 100 | ld [HKEYI],a 101 | ld [HKEYI+1],hl 102 | 103 | ld a,0 ; RTS=0 to avoid receiving bytes 104 | out (baseport+4),a 105 | 106 | call ERAFNK 107 | 108 | call Init 109 | call flushbuf 110 | 111 | 112 | ld A,#2 ; RTS=1 to receive & loopback 113 | out (baseport+4),A 114 | 115 | 116 | 117 | jp main_loop 118 | 119 | 120 | 121 | ;****************** UART_ISR definition **************************** 122 | ;******************************************************************* 123 | UART_isr: 124 | push hl 125 | push af 126 | ; *** ISR routine starts HERE 127 | 128 | 129 | ; Check UART IIR register 130 | in a,(baseport+2) 131 | and 1 ; 11000100 (received Data interrupt, FIFO trigger) 132 | jr nz,.eisr ; Interrupt not from UART. exit 133 | ; Unset RTS 134 | ld a,0 135 | out (baseport+4),a 136 | 137 | ; UART interrupt, RX data available. 138 | 139 | ; Fill the buffer until it is full or there is not more data 140 | ; Ring buffer is implemented. 141 | 142 | .flbuf: 143 | 144 | ld ix,RXBUFFER 145 | ld a,(wptr) 146 | ld d,0 147 | ld e,a 148 | add ix,de 149 | 150 | .fifor: 151 | ; Buffer lleno? 152 | ld a,(rptr) 153 | ld b,a 154 | ld a,(wptr) 155 | inc a 156 | cp b ; write+1=read ? 157 | jr z,.eisr ; Buffer lleno. Se sale y se deja RTS=0 para evitar overrun 158 | ; Queda espacio en el buffer 159 | in a,(baseport+5) ; FIFO vacia? 160 | and 1 161 | jr z,.eisr ; FIFO Vacia. Sale de la ISR 162 | ; Quedan datos en la FIFO. Se rellena el buffer 163 | in a,(baseport) ; Se recibe el byte de la FIFO 164 | ld (ix),a ; Se almacena en el buffer 165 | ; *** Inc write pointer and update buffer position. !!! #FF + 1 -> #00 !!!! (8-bits arithmetic) 166 | ld a,(wptr) ; 8 bit arithmetic to ensure overflow pointers! 167 | inc a 168 | ld (wptr),a 169 | ld d,0 170 | ld e,a 171 | ld ix,RXBUFFER 172 | add ix,de 173 | jr .fifor 174 | .eisr: 175 | pop af 176 | pop hl 177 | ;reti 178 | jp old_isr 179 | 180 | ;*************************************** UART Functions ************************** 181 | // UART INITIALIZATION 182 | Init: 183 | di 184 | ; Unset RTS 185 | ; Enable FIFO 186 | ld a,0x07 187 | out (baseport+2),a 188 | out (baseport+2),a 189 | ; Set Speed 190 | ld a,0x80 ; Set-up access to baud divisor latch (DLAB FLAG) 191 | out (baseport+3),a ; writing 0x80 (bit 7 set) to the LCR (0x83) register 192 | ld a,0x02 ; Program DLL (LOW BYTE) 193 | out (baseport),a 194 | ld a,0x00 ; Program DML (HIGH BYTE) 195 | out (baseport+1),a ; DLL=01, DLM=0 -> 57K6 bauds by default 196 | ; Set protocol 197 | ld a,0x03 ; 8, N, 1 writting 0x03 00000011b 198 | out (baseport+3),a ; to LCR (0x83) register. This RESET the DLAB FLAG 199 | ; Enable Interrupts 200 | ld a,1 201 | out (baseport+1),a ; enable Data Received interrupt 202 | ei 203 | ret 204 | 205 | // Return the number of unreaded bytes in A 206 | ; Z=1 if there are not unreaded bytes in buffer (rptr=wptr) 207 | ; wptr is always > rptr ! 208 | chars_in_buf: 209 | ld a,(wptr) 210 | ld b,a 211 | ld a,(rptr) 212 | cp b ; 213 | jr c,.rlw ; rptr wptr-rptr chars in buf 214 | jr z,.rew ; rptr=wptr -> Buffer vacio 215 | ; wptr < rptr 216 | ld a,#ff 217 | ld hl,rptr 218 | sub (hl) ; a=#ff-rptr 219 | ld hl,wptr 220 | add a,(hl) ; a=#ff-rptr+ wptr 221 | ret 222 | .rlw: ld a,(wptr) 223 | ld hl,rptr 224 | sub (hl) ; a=wptr-rptr 225 | ret 226 | .rew: ld a,0 227 | ret 228 | 229 | 230 | // A=0 if buffer is empty 231 | ; A=1 if there are bytes to be read in the buffer 232 | rs_in_stat: 233 | ld a,(wptr) 234 | ld b,a 235 | ld a,(rptr) 236 | cp b ; 237 | jr nz,.emp ; rptr=wptr -> Buffer vacio 238 | ld a,1 239 | ret 240 | .emp: ld a,0 241 | ret 242 | 243 | // Receive one byte from ring buffer 244 | ; A=Received byte. 245 | rs_in: 246 | ld a,(wptr) 247 | ld b,a 248 | ld a,(rptr) 249 | cp b 250 | jr z,.erx ; if wptr=rptr there are no bytes left. Exit 251 | ; a=rptr, b=bytes to recieve 252 | ld d,0 253 | ld a,(rptr) 254 | ld e,a 255 | ld ix,RXBUFFER 256 | add ix,de 257 | inc a 258 | ld (rptr),a 259 | ld a,(ix) 260 | .erx ret 261 | 262 | // RS232 De Init Routine 263 | ; This deactivates the interrupts from the UART 264 | DeInit: 265 | di 266 | ld a,00000111b 267 | out (baseport+3),a 268 | ld a,0 269 | out (baseport+4),a 270 | ld a,0 271 | out (baseport+1),a ; disable interrupts 272 | ei 273 | ret 274 | 275 | // Put a byte in the TX FIFO 276 | ; A=Byte to be sent 277 | rs_out: 278 | ld (AUX),a 279 | .rsol: IN A,(baseport+5) ; wait for TX ready 280 | AND 32 281 | JR Z,.rsol ; 32= 100000 (THRE bit) 282 | LD A,(AUX) 283 | OUT (baseport),A ; Send keypressed to the TX FIFO 284 | ret 285 | 286 | 287 | // Flush RX buffer 288 | flushbuf: 289 | xor a 290 | ld (rptr),a ; Reset read pointer 291 | ld (wptr),a ; Reset write pointer 292 | ld b,buffersize-1 293 | ld IX,RXBUFFER ; Initial position 294 | .fll: ld (IX),0 ; Fill with zeros 295 | inc IX 296 | djnz .fll 297 | ld hl,wptr 298 | ld hl,rptr 299 | ret 300 | 301 | 302 | 303 | ;**************************************************************************************************** 304 | // A simple delay function 305 | Simple_Delay: 306 | ld B,#FF 307 | .dl: nop 308 | djnz .dl 309 | ret 310 | 311 | ;************************* NUMERIC CONVERSION ROUINES ****************************** 312 | ; Input: HL -> Pointer to string number 313 | ; Output: HL -> Unsigned Integer number 314 | ; 315 | Str2int: 316 | ld (CW),hl 317 | ld ix,(CW) 318 | ld a,(ix) 319 | sub a,48 320 | ld de,10000 321 | call Mult12 ; Result in HL 322 | ld de,(NUM) 323 | add HL,de 324 | ld (NUM),hl 325 | inc ix 326 | 327 | ld a,(ix) 328 | sub a,48 329 | ld de,1000 330 | call Mult12 ; Result in HL 331 | ld de,(NUM) 332 | add hl,de 333 | ld (NUM),hl 334 | inc ix 335 | 336 | ld a,(ix) 337 | sub a,48 338 | ld de,100 339 | call Mult12 ; Result in HL 340 | ld de,(NUM) 341 | add hl,de 342 | ld (NUM),hl 343 | inc ix 344 | 345 | ld a,(ix) 346 | sub a,48 347 | ld de,10 348 | call Mult12 ; Result in HL 349 | ld de,(NUM) 350 | add hl,de 351 | ld (NUM),hl 352 | inc ix 353 | 354 | ld a,(ix) 355 | sub a,48 356 | ld de,(NUM) 357 | ld h,0 358 | ld l,A 359 | add hl,de 360 | ret 361 | 362 | 363 | ;Number to ASCII conversion Routine. From http://map.grauw.nl/sources/external/z80bits.html 364 | ;Input: HL = number to convert, DE = location of ASCII string 365 | ;Output: ASCII string at (DE) 366 | 367 | Num2Dec 368 | ld bc,-10000 369 | call Num11 370 | ld bc,-1000 371 | call Num11 372 | ld bc,-100 373 | call Num11 374 | ld c,-10 375 | call Num11 376 | ld c,b 377 | 378 | Num11 ld a,'0'-1 379 | Num12 inc a 380 | add hl,bc 381 | jr c,Num12 382 | sbc hl,bc 383 | ld (de),a 384 | inc de 385 | ld a,"$" 386 | ld (de),a 387 | ret 388 | 389 | ; Number to ASCII (HEX) conversion Routine. From http://map.grauw.nl/sources/external/z80bits.html 390 | ; Input: HL = number to convert, DE = location of ASCII string 391 | ; Output: ASCII string at (DE) 392 | 393 | Num2Hex: 394 | ld a,h 395 | call Num21 396 | ld a,h 397 | call Num22 398 | ld a,l 399 | call Num21 400 | ld a,l 401 | jr Num22 402 | 403 | Num21: rra 404 | rra 405 | rra 406 | rra 407 | Num22: or #F0 408 | daa 409 | add a,#A0 410 | adc a,#40 411 | ld (de),a 412 | inc de 413 | ld a,"$" 414 | ld (de),a 415 | ret 416 | 417 | ; Multiply 8-bit value with a 16-bit value. From http://map.grauw.nl/sources/external/z80bits.html 418 | ; In: Multiply A with DE 419 | ; Out: HL = result 420 | ; 421 | Mult12: 422 | ld l,0 423 | ld b,8 424 | Mult12_Loop: 425 | add hl,hl 426 | add a,a 427 | jr nc,Mult12_NoAdd 428 | add hl,de 429 | Mult12_NoAdd: 430 | djnz Mult12_Loop 431 | ret 432 | ;******************************************************************************* 433 | ;*************************** MAIN PROGRAM STARTS HERE ************************** 434 | ;******************************************************************************* 435 | main_loop: 436 | call BREAKX 437 | jr nc,.ctx 438 | call DeInit 439 | ret 440 | 441 | .ctx 442 | call check_F1 443 | and A 444 | jp nz,LOADBIN 445 | ;CALL check_F3 446 | ;AND A 447 | ;JR Z,.ink 448 | ;LD A,(LECHO) 449 | ;XOR #FF 450 | ;LD (LECHO),A 451 | 452 | .ink: call INKEY 453 | jr z,RXloop 454 | 455 | TXready: 456 | in a,(baseport+5) ; wait for TX ready 457 | and 32 458 | jr z,TXready 459 | 460 | ld a,(KEYPRESSED) 461 | cp 8 462 | jr z,backspace 463 | cp 13 464 | jr z,line_end 465 | ld a,(KEYPRESSED) 466 | call rs_out 467 | ld a,(LECHO) 468 | and #FF 469 | jr z,main_loop 470 | ld a,(KEYPRESSED) 471 | call CHPUT 472 | jr main_loop 473 | 474 | backspace: 475 | ld a,(CSRX) 476 | cp 1 477 | jr z,main_loop 478 | ld a,8 479 | call CHPUT 480 | ld a," " 481 | call CHPUT 482 | ;LD a,8 ; Needed for Local ECHO 483 | ;CALL CHPUT 484 | ld a,(KEYPRESSED) 485 | call rs_out 486 | jr main_loop 487 | 488 | line_end: 489 | ld a,13 490 | call CHPUT 491 | ld a,13 492 | call rs_out 493 | ld a,10 494 | call CHPUT 495 | jr main_loop 496 | 497 | RXloop: 498 | call chars_in_buf 499 | ld (cib),a 500 | jr z,.erl ; Chars in buf = 0? -> Assert RTS and loop 501 | call rs_in 502 | ld (AUX),a 503 | cp 10 504 | jr nz,.nclf 505 | ld a,13 506 | call CHPUT 507 | ld a,10 508 | call CHPUT 509 | jr .cnt 510 | .nclf: call CHPUT 511 | .cnt: ld b,20 512 | ld a,(cib) 513 | cp b ; (cib)<20? -> Keep RTS OFF 514 | jr nc,.ere 515 | .erl: 516 | ld a,#2 517 | out (baseport+4),a ; RTS=1 518 | 519 | .ere: jp main_loop 520 | 521 | // Write CR+LF to Screen 522 | PUTCRLF: 523 | 524 | ld a,13 525 | call CHPUT 526 | ld a,10 527 | call CHPUT 528 | ret 529 | 530 | ;******************** Checks whether Function key was pressed ********************* 531 | ; Output: A=1 if F1 Pressed 532 | check_F1: 533 | in a,(#AA) 534 | and #F0 ; only change bits 0-3 535 | ld b,6 536 | or b ; take row number from B 537 | out (#AA),a 538 | in a,(#A9) ; read row into A 539 | cp 11011111b 540 | jr z,.rt 541 | xor a 542 | ret 543 | .rt: ld a,1 544 | ret 545 | 546 | ; Output: A=1 if F5 Pressed 547 | check_F3: 548 | in a,(#AA) 549 | and #F0 ; only change bits 0-3 550 | ld b,6 551 | or b ; take row number from B 552 | out (#AA),a 553 | in a,(#A9) ; read row into A 554 | cp 01111111b 555 | jr z,.rt 556 | xor a 557 | ret 558 | .rt: ld a,1 559 | ret 560 | ;*********************************************************************************** 561 | 562 | ;*********************************************************************************** 563 | ;********************* LOAD BINARY FILES INTO MEMORY ******************************* 564 | ;*********************************************************************************** 565 | LOADBIN: 566 | ld hl,DOWNLOAD_TEXT 567 | call print_var_len_text 568 | call flushbuf 569 | ; Request file size (command <) 570 | ld a,'<' 571 | call rs_out 572 | ld hl,JIFFY 573 | ld de,250 574 | add hl,de 575 | ld (TIMER),hl 576 | .wb: call chars_in_buf ; Wait for BaDCaT's response 577 | cp 5 578 | jr z,.strx 579 | ld hl,JIFFY 580 | ld de,(TIMER) 581 | call DCOMPR 582 | jr c,.wb 583 | ld hl,TIMEOUT_TXT 584 | call print_var_len_text 585 | call flushbuf 586 | jp main_loop 587 | 588 | 589 | 590 | ; Receive the file length 591 | .strx: ld hl,STRNUM 592 | ld b,5 593 | .rxsl: push bc 594 | call rs_in 595 | pop bc 596 | ld (hl),a 597 | inc hl 598 | djnz .rxsl 599 | ; Convert string into number and store in HL 600 | ld hl,STRNUM 601 | call Str2int 602 | ld (BYTES2RX),hl ; Save in BYTES2RX 603 | ld hl,RCV_TEXT 604 | call print_var_len_text 605 | ld hl,STRNUM 606 | call print_var_len_text 607 | ld hl,BYTES_TEXT 608 | call print_var_len_text 609 | ld a,13 610 | call CHPUT 611 | ld a,10 612 | call CHPUT 613 | 614 | 615 | ;************************************************************************* 616 | ; *** This routine selects the same slot in page 1 that you have in page 3, 617 | ; *** which will always be the system RAM 618 | ; *** From http://map.tni.nl/sources/raminpage1.php 619 | ;************************************************************************* 620 | 621 | Enable_RAM2: ld a,(EXPTBL+3) 622 | ld b,a ;check if slot is expanded 623 | and a 624 | jp z,Ena_RAM2_jp 625 | ld a,(#FFFF) ;if so, read subslot value first 626 | cpl ;complement value 627 | and %11000000 628 | rrca ;shift subslot bits to bits 2-3 629 | rrca 630 | rrca 631 | rrca 632 | or b 633 | ld b,a 634 | Ena_RAM2_jp: in a,(#A8) ;read slot value 635 | and %11000000 ;shift slot bits to bits 0-1 636 | rlca 637 | rlca 638 | or b 639 | ld h,#40 ;select slot 640 | call ENASLT 641 | ;*************************************************************************** 642 | 643 | 644 | ; Start TX 645 | ld a,'>' 646 | call rs_out 647 | ld a,'+' 648 | call rs_out 649 | 650 | ld hl,(BYTES2RX) 651 | ld a,#40 652 | cp h ; BYTES2RX>#40000 (16KB) ? 653 | jr c, c32K 654 | jr c16K 655 | 656 | c16K: 657 | ; Copy to Page 1 658 | ld hl,(BYTES2RX) ; Bytes to copy 659 | ld de,#4000 ; Starting at #4000 660 | call RX2MEM 661 | jp ROMexec 662 | c32K: 663 | ; Copy to Pages 1 and 2 - 'AB' signature is found in Page 1 664 | ld hl,(BYTES2RX) ; Bytes to copy 665 | ld de,#4000 ; Starting at #4000 666 | call RX2MEM 667 | ld ix,#4000 668 | ld h,(ix+3) 669 | ld l,(ix+2) 670 | jp hl 671 | ; Binary copied into RAM. Now, execute it 672 | 673 | ROMexec: 674 | ; Retrieve the execution address and jump 675 | ld ix,#4000 676 | ld h,(ix+3) 677 | ld l,(ix+2) 678 | jp hl 679 | 680 | 681 | 682 | ;************************************************************************ 683 | ; ****** Store bytes received from UART into RAM ****** ***************** 684 | ; Input: DE-> Initial RAM address, HL -> Number of bytes to store 685 | ; Execute with JP ! 686 | ;************************************************************************ 687 | RX2MEM: 688 | ld a,0 689 | out (baseport+1),a ; Disable UART interrupts to speed up the proccess 690 | ; Receive bytes and store in RAM, initial address DE 691 | ld (AUX),de 692 | ld ix,(AUX) 693 | ; Loop to receive HL bytes 694 | .lbl: in A,(baseport+5) ; Check Data Ready bit 695 | and 00000001b 696 | jr NZ,.Mrxfifo ; DR=1 -> receive the FIFO 697 | .lblc: ld A,2 ; DR=0 -> Re-assert RTS 698 | out (baseport+4),a 699 | jr .lbl 700 | ; Loop to copy FIFO bytes into RAM 701 | .Mrxfifo: 702 | in a,(baseport+5) ; Check LSR - Data Ready 703 | and 00000001b 704 | jr z,.lblc ; Data not ready, re-assert RTS 705 | in a,(baseport) ; Receive a byte in A 706 | ld (ix),a ; and Load into (IX) 707 | 708 | inc ix ; Increment IX the pointer 709 | ;LD HL,(BYTES2RX) 710 | dec hl ; Decrement BYTES2RX 711 | ;LD (BYTES2RX),HL 712 | ld a,h 713 | and a 714 | jr z,.cL 715 | jr .Mrxfifo 716 | .cL ld a,l 717 | and a 718 | ret z 719 | ;JR Z,.lble 720 | jr .Mrxfifo 721 | ;******************************************************************************* 722 | 723 | 724 | 725 | ;************************************************ 726 | ; Print variable length text until "$" is found 727 | ; HL -> address of the variable size buffer 728 | ; Modifies HL, AF, B 729 | ;************************************************ 730 | print_var_len_text: 731 | ld a,(hl) 732 | cp '$' 733 | ret z 734 | call CHPUT 735 | inc hl 736 | jr print_var_len_text 737 | ;******************************************** 738 | 739 | ;********************************* 740 | ; 741 | ; List 5.5 get key code 742 | ; 743 | ; this routine doesn't wait for key hit 744 | ; 745 | ; A -> ASCII CODE OF THE PRESSED KEY 746 | ; C -> 0 IF A KEY WAS PRESSED 747 | ;******************************************************** 748 | ; 749 | CHSNS EQU 009CH ;check keyboard buffer 750 | CHGET EQU 009FH ;get a character from buffer 751 | CHPUT EQU 00A2H ;put a character to screen 752 | KILBUF EQU 0156H ;clear keyboard buffer 753 | REPCNT EQU 0F3F7H ;time interval until key-repeat 754 | KEYBUF EQU 0FBF0H ;keyboard buffer address 755 | 756 | 757 | ; Real-time input using CHGET 758 | 759 | INKEY: 760 | call CHSNS ;check keyboard buffer 761 | jr z,KEY1 762 | ld a,8 763 | ld (REPCNT),a ;not to wait until repeat 764 | call CHGET ;get a character (if exists) 765 | jr KEY2 766 | 767 | KEY1: 768 | ;LD A,0x00 ;A := '-' 769 | ret 770 | KEY2: 771 | ;CALL CHPUT ;put the character 772 | ld (KEYPRESSED),a 773 | call KILBUF ;clear keyboard buffer 774 | ;CALL BREAKX ;check Ctrl-STOP 775 | ;JR NC,INKEY 776 | ;LD A,(KEYPRESSED) 777 | ret 778 | 779 | 780 | 781 | KEYPRESSED: DB 0 782 | TXBUFFER: DB 40,0xFF 783 | TXBUFP: DB 0 784 | STRNUM DS 6,"$" 785 | TEXT_INIT DB "BaDCaT Terminal v1.1 by Andres Ortiz",13,10,"$" 786 | TEXT_INIT_UART DB "16550 UART INITILIZATION",13,10,"$" 787 | RCV_TEXT DB "LOADING: ","$" 788 | DOWNLOAD_TEXT DB "LOADING ","$" 789 | BYTES_TEXT DB " BYTES","$" 790 | LOAD_TXT DB "LOADING STARTED",13,10,"$" 791 | TIMEOUT_TXT DB "BaDCaT did not respond!",13,10,"$" 792 | RTS DB 0 ; RTS Signal copy 793 | LECHO DB 0 ; Local Echo 794 | BYTES2RX DB 0 795 | CW DW 0 796 | NUM DW 0 797 | AUX DB 0 798 | RXBUFFER DS buffersize,0 ; Ring buffer (with 8 bit pointers) 799 | rptr DB 0 ; Write pointer for ring bufferptr. Pointer will reset when overflowed 800 | wptr DB 0 ; Read pointer for ring buffer 801 | cib DB 0 802 | TIMER DW 0 803 | 804 | 805 | ; Speedtable for 1,8432 MHz 806 | speedtable1: 807 | dw 384 ;1 300 808 | dw 192 ;2 600 809 | dw 96 ;3 1200 810 | dw 48 ;4 2400 (with a little error) 811 | dw 24 ;5 4800 (idem) 812 | dw 12 ;6 9600 " 813 | dw 6 ;7 19200 814 | dw 3 ;8 38400 815 | dw 2 ;9 57600 816 | dw 1 ;A 115200 817 | 818 | ; Speedtable for 18,432 MHz 819 | speedtable2: 820 | dw 15360 ;0 75 821 | dw 3840 ;1 300 822 | dw 1920 ;2 600 823 | dw 960 ;3 1200 824 | dw 480 ;4 2400 (with a little error) 825 | dw 240 ;5 4800 (idem) 826 | dw 120 ;6 9600 " 827 | dw 60 ;7 19200 828 | dw 30 ;8 38400 829 | dw 20 ;9 57600 830 | dw 10 ;A 115200. 831 | 832 | END: 833 | -------------------------------------------------------------------------------- /BDTERM/BDterm.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andortizg/BaDCaT/5e321ebff3070e16e81371c0cd775e3ef04841e4/BDTERM/BDterm.bin -------------------------------------------------------------------------------- /BDTERM/README.md: -------------------------------------------------------------------------------- 1 | # BaDCaT 2 | BaDCaT MSX wifi modem 3 | Terminal program for MSX/MSX2 and higher computers. 4 | Developed to be used with BaDCaT wifi modem, including some functions to manage its local and remote filesystems and to load roms up to 32 KB. 5 | -------------------------------------------------------------------------------- /ERIX.COM: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andortizg/BaDCaT/5e321ebff3070e16e81371c0cd775e3ef04841e4/ERIX.COM -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # BaDCaT Wifi modem 2 | ----------------- 3 | BaDCaT, is a WiFi modem to connect our MSX computers to the Internet. The main goal was to reduce Z80 CPU load as much as possible with the addition of external hardware in the same cartridge for TCP/IP processing. On the other hand to be able to work on MSX1 computers even with low RAM. All this process is carried out 4 | by an ESP8266 integrated circuit, specifically the ESP12 version with 4MB of flash memory. 5 | 6 | The cartridge consists of an UART 16C550C which implements an RS232 port as interface between espressif ESP8266 network processor and the MSX bus. 7 | It also provides an standard serial port to the MSX. In short, we could say that this cartridge features two working modes: 8 | 9 | * MSX1: both the TCP/IP stack and telnet client run on the cartridge. The computer would only run a terminal program. 10 | * MSX2 and higher: the TCP/IP stack runs on cartridge and telnet client on the MSX. To do this, the ducasp's telnet version has been modified 11 | in order to offer the same functionality with the WiFi modem and UNAPI interfaces. This telnet version is already available on ducasp's Github. 12 | 13 | # Technical specifications: 14 | 15 | * MSX1/MSX2 (and higher) compatible. 16 | 17 | * RS232 Serial port up to 115200 bps. 18 | 19 | * RTS/CTS flow control. 20 | 21 | * Fossil driver compatible (without any modification). 22 | 23 | * ESP12 modem based on zimodem, effective speed of 57600 bps. 24 | 25 | * Ducasp's telnet compatible and with all its functionalities (fast ANSI decoding, file downloading...) 26 | 27 | * Possibility of running telnet client on the cartridge itself. 28 | 29 | * OTA Upgradable firmware. 30 | 31 | * Experimental feature: loading roms up to 48KB (thanks to Armando Pérez!) 32 | 33 | * UNAPI firmware/driver available (only for AFE/SMD version) and MSX2 34 | 35 | ## WARNING!: do not change FLOW option in the configuration menu unless you are completely sure of what you are doing! Making this permanent could cause malfunction of the BaDCaT!! 36 | 37 | ![alt text](https://github.com/andortizg/BaDCaT/blob/master/badcats.jpg?raw=true) 38 | 39 | 40 | # Disclaimer 41 | 42 | 43 | Copyright © (2020) Andrés Ortiz. All rights reserved. Redistribution without modification only for personal use is permitted, provided that the following conditions are met: 44 | 45 | Redistributions of schematics and gerber files must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in PCB form must reproduce the copyright text, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 46 | 47 | THE HARDWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS HARDWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | -------------------------------------------------------------------------------- /TELNETF/README.MD: -------------------------------------------------------------------------------- 1 | # TELNET v1.33 2 | 3 | (c)2019-2020 Oduvaldo Pavan Junior - ducasp@gmail.com 4 | 5 | # CHANGELOG v1.33 6 | - Farewell GZip, thanks for being with us in v1.32, time to rest friend! 7 | - Incorporate revision 1.7 of MSX2ANSI library, this will work around the 8 | issue created by Synchronet team that decided it is cool to send XTerm 9 | specific scape codes to terminals that report to be ANSI only 10 | - First release of a version that work with Zimodem ESP8266 firmware on 11 | Andrés Ortiz BadCat WiFi modem (it is not UNAPI based, it is working 12 | with FOSSIL driver), to use with it use TELNETF instead of TELNET 13 | 14 | # CHANGELOG v1.32 - GZip Edition 15 | - New version of MSX2ANSI library with better compatibility with nCurses 16 | applications running on host, changes in lib by PiterPunk 17 | - New version of MSX2ANSI library also fixes CSIJ behavior, fix done by me 18 | - New version of MSX2ANSI library allows to disable cursor while rendering 19 | text, this should get better speed on a few scenarios and a smoother 20 | screen rendering without cursor going all over the place during animation 21 | - Dedicated to the memory of GZip 22 | 23 | # CHANGELOG v1.31 24 | - General code cleaning. Removing unused variables, made the negotiation 25 | code more efficient and better to understand, as well as fixing old 26 | comments that were referring to stuff no longer used :) 27 | - Due to the better telnet negotiation code, along with a different way to 28 | detect a dead connection, the flow of ANSI animation and text rendering 29 | is smoother, specially on regular z80 clock and with Obsonet 30 | - If no portnumber is given, will assume default port (23) 31 | - Automatic detection of BBB's that misbehave on Telnet Protocol during 32 | file transfers (i.e.: based on Mystic) if the transfer protocol is YModem 33 | or YModem-G 34 | - There is a significant (50%) speed-up on YModem-G transfers when the BBS 35 | uses the proper TELNET protocol during file transfers (i.e.: every 0xFF 36 | byte is sent as 0xFF 0xFF) and the adapter allows for more than 3KB/s 37 | transfers (i.e.: SM-X, GR8NET... Sorry, Obsonet is not getting faster 38 | transfers) 39 | - Fixed an issue where SM-X wouldn't always properly handshake with the BBS 40 | during start-up, i.e.: HispaMSX wouldn't always detect terminal as ANSI 41 | capable 42 | 43 | # CHANGELOG v1.30 44 | - Made a few behavior changes, CTRL+B won't begin downloads anymore, CTRL+E 45 | won't exit anymore. Those keys will now be sent over the connection which 46 | might be useful when acessing a linux daemon. :) 47 | - Now, to start a file transfer, press F1 48 | - Now, to exit the program, press F5 49 | - Now, the program by default DO NOT send CR/LF when enter is pressed, just 50 | CR, this makes it works with a few door games like LORD and also do not 51 | seem to hurt how it works with all BBS 52 | - Just in case just CR is giving you troubles, added possibility of changing 53 | CRLF behavior on the fly, press F3 to toggle it 54 | - Added possibility of changing ECHO behavior on the fly, press F2 to toggle 55 | it 56 | - By default, now, automatic pop-up of file transfer protocol selection will 57 | be disabled if the BBS send a DO BINARY in the initial handshake, the only 58 | type of BBS that this feature works is Synchronet, and it do not send DO 59 | BINARY 60 | - Compiled with new version of MSX2ANSI library that supports BEEPing when 61 | BELL is received 62 | 63 | # CHANGELOG v1.24 64 | - Re-compiled with new version of MSX2ANSI library. Piter Punk kindly fixed 65 | an issue with CSIm (no parameters) as well added support to reverse colors. 66 | It was crashing and also the behavior of CSIm or CSI0m was not proper. 67 | Thanks Piter! 68 | 69 | # CHANGELOG v1.23 70 | - Changed the way to handle keyboard input, Fusion-C removed support for 71 | the method I've used before. 72 | - Compiled with the new MSX2ANSI library, it fixes quite a few issues seen 73 | while acessing Linux or Busybox telnet servers. 74 | 75 | # CHANGELOG v1.22 76 | - Reporting terminal as ANSI. Tried xterm 16 colors for a test and forgot 77 | to revert to ANSI. Using xterm could be bad if connecting to a host that 78 | is xterm aware, as this client do not implement xterm emulation 79 | 80 | # CHANGELOG v1.21 81 | - Now it is possible to connect to telnet servers hosted by Linux/BSD 82 | daemons, this issue was first reported by PiterPunk and then by Xipepe, 83 | it was caused due to some strings used during telnet negotiations being 84 | stored on the first page of memory that sometimes is overriden with MSX 85 | BIOS. This could potentially solve issues where some MSX setups would 86 | have issues loading this client. 87 | 88 | # CHANGELOG v1.20 89 | - ANSI-DRV.BIN is no longer externally loaded. I've converted it into a 90 | SDCC library, which give us a few benefits, first, performance wise it 91 | is a little bit better as now functions are called using a fast calling 92 | convention that doesn't use stack... Second, you can place it anywhere 93 | on your path and it will not complain about not being able to load 94 | ANSI-DRV.BIN... Last but not least... Having a SDCC library available 95 | might get more developers involved in using this great screen mode for 96 | many different applications. :) 97 | 98 | # CHANGELOG v1.11 99 | 100 | - Oops... When changing to send arrows as ESC commands, was sending also 101 | 0 (String terminator, not '0') after CR/LF and arrows, and this was causing 102 | SlyEdit to quit even before you could type anything. 103 | 104 | # CHANGELOG v1.10 105 | 106 | - Karloch from HISPAMSX BBS told about cursor keys not working properly, so 107 | it seems BBS's won't understand MSX Key Codes for cursors... :) Now this 108 | client sends ANSI Escape codes that BBS's understand, so you can edit 109 | your message properly. 110 | 111 | - Also Karloch told me about how bad it is to try to edit a message without 112 | a cursor on the screen, you move the cursor and have no idea where it is. 113 | Fair enough, I've updated ANSI-DRV.BIN as well, now it has a proper 114 | cursor, the same color as the current text color. 115 | 116 | # CHANGELOG v1.00 117 | 118 | - jANSI is no longer used. Long history short: I've talked to Carlos 119 | Santana about INLCLIES (work only for internestor light) and its ANSI 120 | rendering was awesome, asking if I could use it. He did send me the 121 | details of how it works, cool. Then I've reached the driver author, 122 | Tobias Keizer (Sonic_AKA_T), and he is an awesome guy, that sent me 123 | the source code of his driver and allowed me to change it and publish 124 | source code as well. End result: 6 seconds rendering HISPAMSX boot logo 125 | ANSI animation on OCM Turbo / Hardware accelerated UNAPI adapter, and 13 126 | seconds at regular z80 speeds, pretty damn blazing amazing fast! So 127 | Sonic_AKA_T just brought us BLAST PROCESSING from SEGA Genesis directly 128 | to our MSX's 2 or greater. :) (And it is way, waaay, waaaaay faster on 129 | OBSONET as well really usable even at regular z80 speeds, how does 30s to 130 | see HISPAMSX ANSI boot animation looks like? Remember that using jANSI 131 | it was 61s? :D ) 132 | 133 | - As such, command line options have reduced a lot, no need to deal with 134 | external ANSI drivers. 135 | 136 | - And the cool thing is, this still works with MSX1, but it will be not 137 | ANSI compatible. 138 | 139 | # CHANGELOG v0.90 140 | 141 | - You can use it to receive files from some BBSs that did not work 142 | before, i.e.: BBSs that use Mystic software. If download do not work 143 | try using r command switch to enable raw file receiving (i.e.: 144 | telnet bbs.telnet.org:666 r ). Those BBSs misbehave and do not 145 | implement TELNET protocol correctly, not doubling FF character, and 146 | this switch will cause telnet to not parse received download data as 147 | telnet data. 148 | 149 | - You have option to tell terminal is ANSI even without jANSI. Perhaps 150 | somene has a driver for GFX9000 or something like that and want to use 151 | it... Use e switch to tell that (i.e.: telnet bbs.gfx900.net:9990 e ) 152 | 153 | - Possibility to turn off automatic download detection. Default is on, as 154 | most BBSs around are Synchronet, mas other BBSs not using Synchronet 155 | might use the transfer binary telnet command to send data (and as it 156 | contains 8 bit characters, that is fine). This might get confusing... 157 | Specially on BBSs that hammer you with that darn transfer binary command 158 | every block of text they send.... Use s switch in that case (i.e.: telnet 159 | bbs.noautotransfer.com:23 a ) 160 | 161 | - Cursor is turned off by default,by using switch c you can turn cursor on. 162 | I just like not having the cursor showing and moving around while drawing 163 | ANSI screens. 164 | 165 | Note: if using my supplied version of jANSI, you get HISPAMSX boot screen 166 | working fine (using cursor or not), but without cursor it seems to draw 167 | a little faster and it is possible to have the screen border at the same 168 | color of screen background (all blue). When cursor is on, screen border 169 | will always be black, even if background is a different color. (This is 170 | relative to my version of jANSI and not to this software) 171 | 172 | - some internal improvements that allow a bit of better performance and 173 | also better handling of telnet protocol, as well as responding proper 174 | cursor position to ESC[6n, fixing synchronet BBSs pause when printing 175 | avatars (as well the avatars and text being misplaced) 176 | 177 | # CHANGELOG v0.80 178 | 179 | - Fix the program crashing when receiving two bytes TELNET commands. We do 180 | not execute those, but need to properly parse. It no longer crashes if 181 | you log-in at HISPAMSX and leave it logged/untouched 182 | 183 | - Fix on X/YMODEM(G) transfers corrupting some bytes of data 184 | 185 | - Enhancement on YMODEM(G) performance, got up to 8KB/s using MSX-SM WiFi 186 | UNAPI adapter 187 | 188 | - Some BBSs allow the Telnet Client to know that a transfer is in progress 189 | by sending Telnet command WILL TRANSFER_BINARY. Now this client is able 190 | to recognize it and it will pop-up the transfer protocol selection 191 | automatically. If the BBS do not send WILL TRANSFER_BINARY, you still 192 | can invoke the transfer protocol selection 193 | 194 | - Fix YMODEM/YMODEM-G not detecting the end of a batch or single file 195 | transfer properly. Now it detects properly. Exception is HISPAMSX when 196 | using YMODEM-G (you need to lie to it telling you want YMODEM as it does 197 | not list YMODEM-G as an option, so you tell it you are going to download 198 | YMODEM, configure your user options with YMODEM as preferred protocol, 199 | and when downloading a batch ou single file choose YMODEM but on the 200 | telnet client you choose YMODEM-G and the transfer will occur as YMODEM 201 | G, which is a blessing as XMODEM and YMODEM use 128 bytes long blocks at 202 | HISPA which is really slow, not sure why they do not enable 1K blocks) 203 | 204 | - ESC no longer quits the program, as this key might be requested to 205 | interact with some BBSs. Now, to quit the program hit CTRL+ESC 206 | 207 | - It should now work fine with MSX1 as long as you have an UNAPI adapter 208 | that works with it. It will understand that it is a MSX1 and not try to 209 | set 80 columns mode, but set it to 40 columns if less are set. Also, on 210 | MSX 2/2+/TR it will set the screen to 80 columns if less are set and 211 | jANSI is not installed (with jANSI, it always use 80x25). BBSs will be 212 | aware that terminal is 40x24 or 80x24. Also, if you have a MSX-1 with 213 | an 80 columns adapter that reports properly the number of columns in use, 214 | this software will not try to change anything so it should work on those 215 | as well 216 | 217 | - Instead of returning the real cursor position on 6n escape code, it will 218 | return 25x80 as some BBSs use this information to determine terminal 219 | window size 220 | 221 | - Not really an update, it was alway like that, but just making sure it is 222 | clear, jANSI/MEMMAN is not mandatory. It will work without it, but it is 223 | not going to tell the other end it is ANSI and of course colors and ANSI 224 | animations won't work. 225 | 226 | # DESCRIPTION 227 | 228 | This is a TELNET client that allow you to connect to a TELNET server / BBSs and 229 | interact with it. If an MSX2 or better is used, it will be able to receive and 230 | show ANSI escape codes / colors. It should be MSX1 friendly as long as your 231 | UNAPI adapter is compatible with MSX1. 232 | 233 | How is it different than TCPCON? Why not keep using it? 234 | 235 | - It implement telnet negotiations, as such, echo is used as the other end 236 | requests (no need to turn on or off manually), tell terminal type (Dumb 237 | if MSX1 or xterm 16 colors otherwise), tell window size as 40x24 (MSX1) 238 | or 80x24 (MSX1 with external 80 columns adapter and screen set to 80 239 | columns before executing this software) or 80x25 if MSX2 or better. 240 | 241 | - If using MSX2 or better, ANSI capabilities are automatically detected by 242 | most BBSs either by telnet negotiation of Window Size or responding to 243 | ANSI request to cursor position (some BBS's use this to detect if 244 | terminal is ANSI capable) 245 | 246 | - If using MSX2 or better, it will use MS-DOS character set, which allow 247 | seeing ANSI animations and menus as they are 248 | 249 | - It supports receiving files through XMODEM CRC, XMODEM 1K CRC, YMODEM and 250 | YMODEM-G, including file batch in YMODEM/YMODEM-G 251 | 252 | As a result, ANSI redering is real fast, on an OCM running at turbo speed it 253 | will be faster (less than 6s) than a MSX TURBO-R using built-in telnet client 254 | of GR8NET to draw the MSX boot animation of HISPAMSX BBS. It also draws menus 255 | of ANSI BBSs really really fast at z80 turbo speeds. When using with regular 256 | z80 speeds it is very usable, taking a couple of seconds to draw ANSI menus and 257 | 13s to draw the MSX boot animation of HISPAMSX BBS (H/W accelerated adapters, 258 | OBSONET uses a lot of z80 resources so it is slower). 259 | 260 | As a reference TCPCON with jANSI takes 35s (vs. 6s) to draw HISPAMSX boot at 261 | OCM turbo speed (and it is 85s vs. 13s at regular z80 speeds) on a MSX-SM with 262 | ESP8266. On BlueMSX using "OBSONET", HISPAMSX at regular z80 speeds TCPCON take 263 | 150s vs 29s using this client (OBSONET uses lots of z80 CPU resources as it is 264 | not using TCP/IP hardware acceleration, DENYONET and GR8NET should have better 265 | results). 266 | 267 | # USAGE 268 | 269 | telnet server:port [a] [r] 270 | 271 | server:port: 192.168.0.1:23 or bbs.hispamsx.org:23 272 | 273 | (NOTE: :port is now optional, and if it is not provided, will assume default 274 | telnet port, 23) 275 | 276 | a - Will turn off automatic file download detection. It works on all Synchronet 277 | BBS's and doesn't interfere on many others. But a few BBSs over use the Binary 278 | transfer command and this could cause the protocol pop-up to show a lot of 279 | times. In this case, just use the a switch to de-activate this feature. 280 | 281 | r - Some BBS's do file transfer over telnet the wrong way, not replacing 0xFF 282 | bytes to 0xFF 0xFF (double 0xFF). This is not compliant to Telnet specs. If 283 | file transfer do not work, try using this switch. 284 | 285 | Example to connect to rainmaker: 286 | 287 | telnet rainmaker.wunderground.com:23 288 | 289 | Most keys and CTRL+KEY combinations are sent to the telnet server. 290 | 291 | To exit the program, press F5. 292 | 293 | By default, echo is ON if server do not negotiate echo, and it will be ON or 294 | OFF following the server negotiation request. If for some reason that do not 295 | work, you can press F2 to change the current echo state. 296 | 297 | By default, program will send only CR upon pressing ENTER. If that doesn't work 298 | for the server/BBS you are using, press F3 to change this behavior (there are 299 | two possible behaviors: default, send only CR, non-default, send CR-LF). 300 | 301 | To use the file download capabilities of this telnet client, once the server is 302 | ready to send files, press F1 and then type the filename if XMODEM is being 303 | used, or Y if it is a YMODEM transfer, or G for YMODEM-G. On some BBS's (i.e. 304 | Synchronet BBSs) you do not need to do this as they send a telnet command that 305 | warns a binary data transfer is starting, so the list of protocol options pops 306 | up automatically. 307 | 308 | My recommendation is YMODEM-G, it is way faster due to not having to wait for 309 | client confirmation before sending the next packet. Most BBS's, like HISPAMSX, 310 | even though not listing YMODEM-G as an option, will use YMODEM-G if you choose 311 | YMODEM at the BBS end and YMODEM-G after pressing CTRL+B. 312 | 313 | ***WARNING*** 314 | 315 | I just have an OCM like MSX ( MSX-SM by Victor Trucco ) and I'm using its built 316 | in WiFi capabilities with a customized ESP8266 firmware and an UNAPI driver 317 | made by me. My other option to test this is using BlueMSX OBSONET emulation. So 318 | I've not tested it with other UNAPI adapters, but it should work fine. :) 319 | 320 | ***KNOWN ISSUES*** 321 | 322 | - XMODEM and YMODEM(G) transfers are a work in progress, at this moment it 323 | works on some BBSs, on others it just error. If you get errors, let me 324 | know the file/BBS. 325 | 326 | - XMODEM and YMODEM performance will generaly always suck, sorry! Those 327 | will send an ACK to the server after receiving a block, and the server 328 | will wait receiving the ACK before sending the next block, so, you have 329 | 2x the ping to the server between each block. Let's say it is using 128 330 | bytes per block, and 100ms ping, 200ms between 128 bytes packets... Yeah, 331 | it won't work at great speeds. Using 1024 bytes packets it gets better, 332 | but HISPAMSX as an example will use XMODEM and YMODEM with 128 bytes 333 | packets only. (I have a 180ms ping to HISPA server, so in my case this 334 | means ~350 bytes per second!) Use YMODEM-G if possible, it streams and 335 | is not ping/lag dependent, and most BBSs, even if not listing YMODEM-G, 336 | work with it if you choose YMODEM at BBS side and YMODEM-G on the MSX 337 | side. 338 | 339 | ***IMPORTANT COMPILATION NOTES*** 340 | 341 | Remember to copy the files in fusion-c\lib and fusion-c\header to your fusion-c lib and header folders! 342 | You will need the following libraries: 343 | 344 | - Konamiman's ASM.LIB ( https://www.konamiman.com/msx/sdcc/asmlib.zip ) 345 | - Oduvaldo & Tobias Keizer MSX2ANSI.LIB ( https://github.com/ducasp/MSX-Development/tree/master/SDCC/MSX2ANSI ) 346 | 347 | I recommend using Code::Blocks, it is a full featured UI that will allow you to check references, etc. 348 | 349 | Redistribution and use of this source code or any derivative works, are 350 | permitted provided that the following conditions are met: 351 | 352 | 1. Redistributions of source code must retain the above copyright notice, 353 | this list of conditions and the following disclaimer. 354 | 2. Redistributions in binary form must reproduce the above copyright 355 | notice, this list of conditions and the following disclaimer in the 356 | documentation and/or other materials provided with the distribution. 357 | 3. Redistributions may not be sold, nor may they be used in a commercial 358 | product or activity without specific prior written permission. 359 | 4. Source code of derivative works MUST be published to the public. 360 | 361 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 362 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 363 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 364 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 365 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 366 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 367 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 368 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 369 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 370 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 371 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 372 | -------------------------------------------------------------------------------- /TELNETF/Telnetf.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andortizg/BaDCaT/5e321ebff3070e16e81371c0cd775e3ef04841e4/TELNETF/Telnetf.com -------------------------------------------------------------------------------- /UNAPI/Readme.md: -------------------------------------------------------------------------------- 1 | # UNAPI driver for BaDCaT wifi modem (Only for AFE/SMD version and MSX2 computers!) 2 | Based on the work of Alexander Nihirash ( @nihirash ) and his Nifi firmware 3 | 4 | - badcat_config : Configuration and firmware utility 5 | - bcunapi : UNAPI driver. Once loaded, you can use BaDCaT wifi modem as standard UNAPI network interface 6 | 7 | # How to use: 8 | 9 | 1. Run badcat_config to setup your AP (option 1). 10 | 2. Only for Nextor <2.11 : it is necessary to load ramhelpr: ramhelpr i 11 | 3. Run bcunapi unapi driver to load it into RAM 12 | 4. Now you can use UNAPI applications! 13 | 14 | ***I strongly recommend to use the VERY nice MSX-HUB tool (or HUBG graphical interface) from ducaSP to install programs.*** 15 | 16 | 17 | # Limitations 18 | 19 | - Passive TCP not yet implemented. FTP based on passive connections is not working. 20 | - ICMP not yet implemented. PING command is not working. 21 | - Experimental functionality of ROM loading from BaDCaT does not work with the UNAPI firmware 22 | 23 | 24 | # Update procedure 25 | 26 | ## From non-unapi version: 27 | ***Be sure that you have the SMD/AFE version before updating. Otherwise, you will brick your BaDCaT!. You can check it using the badcat_config tool.*** 28 | **Ensure you have good WiFi signal ! 29 | 30 | 1. In AT+CONFIG menu, use the the repository -> [REPO] option 31 | 2. In command mode: at&u=2.0 32 | 3. Wait for BaDCaT reboot 33 | 34 | ## From unapi version: 35 | 1. Use badcat_config tool, option 2 to download the file badcat-2.0.bin from the repository: http://badcatrepo.ddns.net 36 | (or file badcat-1.5.bin if you can return to the non-unapi version). 37 | 3. Use option 3 to write the flash with the new firmware. 38 | 39 | 40 | ### If you like to improve the firmware/driver or to add new features, contact me! 41 | badcatelectronics@gmail.com 42 | 43 | -------------------------------------------------------------------------------- /UNAPI/badcat_config.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andortizg/BaDCaT/5e321ebff3070e16e81371c0cd775e3ef04841e4/UNAPI/badcat_config.com -------------------------------------------------------------------------------- /UNAPI/bcunapi.com: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/andortizg/BaDCaT/5e321ebff3070e16e81371c0cd775e3ef04841e4/UNAPI/bcunapi.com -------------------------------------------------------------------------------- /UNAPI/sources/badcat.h: -------------------------------------------------------------------------------- 1 | // **************************** 2 | // BaDCaT related functions 3 | // 4 | // Author: Andres Ortiz, 2023 5 | // **************************** 6 | 7 | #include "fcb.h" 8 | 9 | char fbuffer[512]; 10 | 11 | 12 | char check_badcat(void) 13 | { 14 | char av=0; 15 | if (check_BC()==1) 16 | { 17 | Print("BaDCaT: found\n"); 18 | av=1; 19 | } 20 | else 21 | { 22 | Print("BaDCaT: NOT found\n"); 23 | } 24 | if (uart_checkAFE()==1) 25 | { 26 | Print("Version: AFE \n"); 27 | av=2; 28 | } 29 | else 30 | { 31 | Print("Version: No AFE\n"); 32 | } 33 | return av; 34 | } 35 | 36 | 37 | int badcat_upload_protocol(void) 38 | { 39 | 40 | // Start file upload protocol to BaDCaT flash 41 | // Protocol is as follows: 42 | // Send 0xfe command (FWUPDATE command) 43 | // BaDCaT replies ">" waiting for file size 44 | // Since firmware filesize is 256KB, we send "261472<" (ASCII string with terminator character) 45 | // Start sending the binary file byte by byte 46 | unsigned char rb=0; 47 | unsigned char filesize_str[]="261472>"; 48 | unsigned int i; 49 | 50 | //nifi_init(); // Reset the Firmware 51 | uart_write(OP_FILEUPLOAD); // send 0xfd command 52 | rb=uart_readB(); // Receive character 53 | 54 | if (rb==0x3E) // We expect ">" character 55 | { 56 | Print("Current firmware: NiFi\n"); 57 | /*uart_write(OP_VERSION_STR); 58 | char* rxbuf = receive_buffer_NULL2(); 59 | Print(rxbuf); 60 | Print("\n");*/ 61 | } 62 | else 63 | { 64 | Print("Firmware Error. Exiting.\n"); 65 | return 1; 66 | } 67 | 68 | // Send the filesize as a string terminated with ">" 69 | 70 | for (i=0;i" to start sending file 78 | rb=0; 79 | while(rb!=0x3e) 80 | { 81 | rb=uart_readTimeout(retries); 82 | } 83 | return 0; 84 | } 85 | 86 | void badcat_fwupdate(char *file_name) 87 | { 88 | int res=0; 89 | // Upload firmware from disk 90 | res=FT_LoadbinFile(file_name); 91 | } 92 | 93 | void badcat_savefw(void) 94 | { 95 | int res=0; 96 | // Upload firmware from disk 97 | res=FT_SavebinFile("f.bin"); 98 | } 99 | 100 | void formatflash(void) 101 | { 102 | char rc; 103 | Print("Formatting Flash... "); 104 | uart_write(OP_FORMATFLASH); 105 | rc=uart_readB(); 106 | if (rc==0x00) 107 | { 108 | Print("OK\n"); 109 | rc=0xff; 110 | while(rc!=0x00) 111 | { 112 | rc=uart_readTimeout(retries); 113 | PrintChar(rc); 114 | } 115 | } 116 | else 117 | { 118 | Print("ERROR"); 119 | flush_FIFO(); 120 | } 121 | } 122 | 123 | -------------------------------------------------------------------------------- /UNAPI/sources/definitions.h: -------------------------------------------------------------------------------- 1 | // 16C550C register addresses 2 | #define RBR_THR 0x80 3 | #define IER 0x81 4 | #define IIR_FCR 0x82 5 | #define LCR 0x83 6 | #define MCR 0x84 7 | #define LSR 0x85 8 | #define MSR 0x86 9 | #define SR 0x87 10 | 11 | // Define Nifi commands 12 | #define OP_Reset 0x00 13 | #define OP_GET_IP 0x02 14 | #define OP_GET_AP_LIST 0x30 15 | #define OP_SET_AP 0x31 16 | #define OP_GET_AP 0x32 17 | #define OP_DLOADHTTP 0xF8 18 | #define OP_OTAUPDATE 0xF9 19 | #define OP_READFILE 0xFA 20 | #define OP_SHOWFILES 0xFB 21 | #define OP_FORMATFLASH 0xFC 22 | #define OP_FILEUPLOAD 0xFD 23 | #define OP_FWUPDATE 0xFE 24 | #define OP_VERSION_STR 0xFF 25 | 26 | // define NIFI ESP IP constants 27 | #define IP_LOCAL 1 28 | #define IP_REMOTE 2 29 | #define IP_MASK 3 30 | #define IP_GATEWAY 4 31 | #define IP_DNS1 5 32 | 33 | // UART constants 34 | #define retries 50 35 | 36 | // DEBUG definitions 37 | #define debug 1 -------------------------------------------------------------------------------- /UNAPI/sources/display.h: -------------------------------------------------------------------------------- 1 | // ************************************************ 2 | // Menus for the BadCat / NiFi Configuration tool 3 | // 4 | // Author: Andres Ortiz, 2023 5 | // Based on the work of Alexander Nihirash, 2021 6 | // ************************************************ 7 | 8 | void welcome_msg(void) 9 | { 10 | Print("BaDCaT/NiFi UNAPI configuration and update utility\n"); 11 | Print("2023 - Andres Ortiz & Alexander Nihirash\n\n"); 12 | } 13 | 14 | void show_menu(void) 15 | { 16 | Print("1. Wifi AP setup\n"); 17 | Print("2. Download file from http repo\n"); 18 | Print("3. Firmware Update\n"); 19 | Print("4. Exit\n"); 20 | 21 | Print("\n"); 22 | Print("Select option:"); 23 | } 24 | 25 | 26 | void show_IPs(void) 27 | { 28 | Print("Local IP: "); 29 | GetIP(IP_LOCAL); 30 | Print("\n"); 31 | Print("Gateway IP: "); 32 | GetIP(IP_GATEWAY); 33 | Print("\n"); 34 | Print("DNS IP: "); 35 | GetIP(IP_DNS1); 36 | Print("\n"); 37 | } -------------------------------------------------------------------------------- /UNAPI/sources/fcb.h: -------------------------------------------------------------------------------- 1 | // ************************************************ 2 | // FCB Management 3 | // 4 | // Author: Andres Ortiz, 2023 5 | // 6 | // ************************************************ 7 | 8 | 9 | #include "../fusion-c/header/msx_fusion.h" 10 | #include "../fusion-c/header/io.h" 11 | #include 12 | #include 13 | #include "utils.h" 14 | 15 | static FCB file; 16 | 17 | void FT_errorHandler(char n, char *name) 18 | { 19 | switch (n) 20 | { 21 | case 1: 22 | Print("\n\rERROR opening file "); 23 | Print(name); 24 | break; 25 | 26 | case 2: 27 | Print("\n\rERROR closing file "); 28 | Print(name); 29 | break; 30 | 31 | case 3: 32 | Print("\n\rStop Kidding, run me on MSX2 !"); 33 | break; 34 | 35 | case 4: 36 | Print("\n\rError writing file "); 37 | Print(name); 38 | break; 39 | } 40 | Exit(0); 41 | } 42 | 43 | void FT_SetName( FCB *p_fcb, const char *p_name ) 44 | { 45 | char i, j; 46 | memset( p_fcb, 0, sizeof(FCB) ); 47 | for( i = 0; i < 11; i++ ) { 48 | p_fcb->name[i] = ' '; 49 | } 50 | for( i = 0; (i < 8) && (p_name[i] != 0) && (p_name[i] != '.'); i++ ) { 51 | p_fcb->name[i] = p_name[i]; 52 | } 53 | if( p_name[i] == '.' ) { 54 | i++; 55 | for( j = 0; (j < 3) && (p_name[i + j] != 0) && (p_name[i + j] != '.'); j++ ) { 56 | p_fcb->ext[j] = p_name[i + j] ; 57 | } 58 | } 59 | } 60 | 61 | /* --------------------------------- 62 | FT_LoadbinFile 63 | 64 | Load a binary file and send data 65 | to the UART 66 | -----------------------------------*/ 67 | int FT_LoadbinFile(char *file_name) 68 | { 69 | int rd=16; 70 | unsigned int i; 71 | unsigned long j=0; 72 | char buffer[512]; 73 | 74 | FT_SetName( &file, file_name ); 75 | if(fcb_open( &file ) != FCB_SUCCESS) 76 | { 77 | FT_errorHandler(1, file_name); 78 | return (0); 79 | } 80 | Print("Uploading firmware *"); 81 | //while (uart_isavailable()) PrintChar(uart_readTimeout(retries)); 82 | //delay(100); 83 | //while (uart_isavailable()) PrintChar(uart_readTimeout(retries)); 84 | 85 | while(rd!=0) 86 | { 87 | rd = fcb_read(&file, buffer, 512); 88 | if (rd!=0) 89 | { 90 | for (i=0;i512) 147 | { 148 | MaxToWrite=512; 149 | bw=bw+512; 150 | } 151 | else 152 | { 153 | MaxToWrite=261472-bw; 154 | finish=1; 155 | } 156 | for (i=0; i 10 | #include "../fusion-c/header/msx_fusion.h" 11 | #include "../fusion-c/header/io.h" 12 | 13 | #include "definitions.h" 14 | #include "uart.h" 15 | #include "nifi.h" 16 | #include "badcat.h" 17 | #include "display.h" 18 | 19 | 20 | 21 | void main(void) 22 | { 23 | char option; 24 | int i=0; 25 | char rb=0; 26 | int r; 27 | char strs[50]; 28 | 29 | 30 | Width(80); 31 | Cls(); 32 | welcome_msg(); 33 | uart_init(); 34 | check_badcat(); 35 | GetVERSION(); 36 | nifi_init(); 37 | con_sta=GetAP(); 38 | show_IPs(); 39 | 40 | 41 | 42 | while(1) 43 | { 44 | Print("\n\n"); 45 | show_menu(); 46 | option=Getche(); 47 | Print("\n"); 48 | 49 | switch (option) { 50 | case '1': 51 | get_AP_LIST(); 52 | Print("\n"); 53 | setAP(); 54 | break; 55 | 56 | /*case '2': 57 | formatflash(); 58 | break;*/ 59 | 60 | case '2': 61 | if (con_sta==0) 62 | { 63 | uart_write(OP_DLOADHTTP); 64 | send_string("Rpository URL: "); 65 | send_string("File name: "); 66 | // Prints out Nifi output 67 | rb=uart_readB(); 68 | while(rb!=0x00) 69 | { 70 | PrintChar(rb); 71 | rb=uart_readB(); 72 | } 73 | } 74 | else 75 | { 76 | Print("Not Connected!\n"); 77 | } 78 | break; 79 | 80 | case '3': 81 | if (con_sta==0) 82 | { 83 | uart_write(OP_FWUPDATE); 84 | send_string("File name: "); 85 | send_string("Are you sure? (Y/n): "); 86 | // Prints out Nifi output 87 | rb=uart_readB(); 88 | while(rb!=0x00) 89 | { 90 | PrintChar(rb); 91 | rb=uart_readB(); 92 | } 93 | } 94 | else 95 | { 96 | Print("Not Connected!\n"); 97 | } 98 | break; 99 | 100 | case '4': 101 | Print("Exiting...\n"); 102 | Exit(0); 103 | break; 104 | } 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /UNAPI/sources/nifi.h: -------------------------------------------------------------------------------- 1 | // ******************************************************* 2 | // Nifi related functions 3 | // 4 | // Author: Andres Ortiz, 2023 5 | // Based on the previous work of Alexander Nihirash, 2021 6 | // ******************************************************* 7 | int con_sta=0; 8 | 9 | 10 | void nifi_init(void) 11 | { 12 | const char init_str[] = {"N", "i", "F", "i",0x00}; 13 | char rb=0xff; 14 | int success=0; 15 | unsigned long timer=0; 16 | Print("Initializing your modem..."); 17 | while (success==0) 18 | { 19 | uart_write(OP_Reset); // send reset command 20 | rb = uart_readTimeout(retries); 21 | while(rb!=0) 22 | { 23 | uart_write(OP_Reset); 24 | rb = uart_readTimeout(retries); 25 | delay(20); 26 | timer++; 27 | if (timer>100) 28 | { 29 | Print("[TIMEOUT ERROR]\n"); 30 | break; 31 | } 32 | } 33 | 34 | char* rxbuf = receive_buffer_NULL(); 35 | if (StrCompare(init_str,rxbuf)==0) 36 | { 37 | Print("[DONE]\n"); 38 | success=1; 39 | break; 40 | } 41 | } 42 | } 43 | 44 | void get_AP_LIST(void) 45 | { 46 | static char buf[50]; 47 | char rb; 48 | unsigned char i; 49 | 50 | uart_write(0x30); 51 | Print("getting AP LIST...\n"); 52 | while(!uart_isavailable()) 53 | { 54 | __asm 55 | nop 56 | __endasm; 57 | } 58 | 59 | while(uart_isavailable()) 60 | { 61 | rb=uart_readTimeout(retries); 62 | i=0; 63 | while((rb!=0x00)&&(rb!=0xFF)) 64 | { 65 | buf[i]=rb; 66 | rb=uart_readTimeout(retries); 67 | i++; 68 | } 69 | buf[i]=0x00; 70 | Print(buf); 71 | Print("\n"); 72 | } 73 | } 74 | 75 | void setAP(void) 76 | { 77 | char buf[51]; 78 | char rc; 79 | unsigned char i; 80 | uart_write(OP_SET_AP); 81 | Print("SSID:"); 82 | InputString(buf,50); 83 | i=0; 84 | while(buf[i]!=0x00) 85 | { 86 | uart_write(buf[i]); 87 | i++; 88 | } 89 | uart_write(0x00); 90 | Print("\n"); 91 | Print("Password:"); 92 | InputString(buf,50); 93 | i=0; 94 | while(buf[i]!=0x00) 95 | { 96 | uart_write(buf[i]); 97 | i++; 98 | } 99 | uart_write(0x00); 100 | Print("\n"); 101 | rc=uart_readB(); 102 | if (rc==0x00) 103 | { 104 | Print("Connected!\n"); 105 | con_sta=1; 106 | } 107 | else{ 108 | Print("ERROR\n"); 109 | } 110 | } 111 | 112 | int GetAP(void) 113 | { 114 | static char buf[64]; // Asignar memoria para el string 115 | unsigned char i=0; 116 | char rc; 117 | Print("Current AP: "); 118 | uart_write(OP_GET_AP); 119 | rc=uart_readB(); 120 | if (rc==0x00) 121 | { 122 | rc=uart_readB(); 123 | while(rc!=0) 124 | { 125 | buf[i]=rc; 126 | i++; 127 | rc=uart_readB(); 128 | } 129 | buf[i]=0x00; 130 | Print(buf); 131 | Print("\n"); 132 | return 0; 133 | } 134 | else 135 | { 136 | Print("Not Connected\n"); 137 | return -1; 138 | } 139 | } 140 | 141 | void GetIP(char tip) 142 | { 143 | int i=0; 144 | char rc; 145 | uart_write(OP_GET_IP); 146 | uart_write(tip); 147 | rc=uart_readB(); 148 | if (rc==0x00) 149 | { 150 | for (i=0; i<4;i++) 151 | { 152 | rc=uart_readB(); 153 | if (i>0) Print("."); 154 | PrintDec(rc); 155 | } 156 | } 157 | else 158 | { 159 | Print("No IP"); 160 | } 161 | } 162 | 163 | void GetVERSION(void) 164 | { 165 | char rc=0xff; 166 | Print("Firmware version: "); 167 | uart_write(OP_VERSION_STR); 168 | rc=uart_readB(); 169 | if (rc==0x00) 170 | { 171 | rc=uart_readTimeout(retries); 172 | while (rc!=00) 173 | { 174 | PrintChar(rc); 175 | rc=uart_readTimeout(200); 176 | } 177 | Print("\n"); 178 | } 179 | else 180 | { 181 | Print("ERROR\n"); 182 | flush_FIFO(); 183 | } 184 | } -------------------------------------------------------------------------------- /UNAPI/sources/uart.h: -------------------------------------------------------------------------------- 1 | // **************************** 2 | // 16C550C UART functions 3 | // 4 | // Author: Andres Ortiz, 2023 5 | // **************************** 6 | 7 | 8 | void uart_init(void) 9 | { 10 | Print("Initializing UART...\n"); 11 | OutPort(MCR,0x0D); // Assert RTS 12 | OutPort(IIR_FCR, 0x87); // Enable fifo 8 level, and clear it 13 | OutPort(LCR,0x83); // 8n1, DLAB=1 14 | OutPort(RBR_THR,0x01); // 115200 (divider 1) 15 | OutPort(IER,0x00); // (divider 0). Divider is 16 bit, so we get (#0002 divider) 16 | OutPort(LCR,0x03); // 8n1, DLAB=0 17 | OutPort(IER,0x00); // Disable int 18 | OutPort(MCR,0x2F); // Enable AFE (AFE + RTS bits) 19 | } 20 | 21 | 22 | 23 | 24 | char uart_checkAFE(void) 25 | { 26 | // Check if AFE is present 27 | unsigned char ub=0; 28 | OutPort(SR,0x22); 29 | if (InPort(SR)==0x22) 30 | { 31 | ub=1; 32 | } 33 | return ub; 34 | } 35 | 36 | unsigned char uart_isavailable(void) 37 | { 38 | // Check if Data is available in UART FIFO (LSR0 bit is set) 39 | return (InPort(LSR)&0x01); 40 | } 41 | 42 | char uart_read(void) 43 | { 44 | char readbyte=0; 45 | // Non-blocking read 46 | if (uart_isavailable()) { 47 | readbyte=InPort(RBR_THR); 48 | } 49 | return readbyte; 50 | } 51 | 52 | char uart_readTimeout(unsigned char nret) 53 | { 54 | char rb=0; 55 | unsigned int i; 56 | // Tries read byte with timeout 57 | for (i = 0; i < nret; ++i) 58 | { 59 | if (uart_isavailable()) 60 | { 61 | rb=uart_read(); 62 | break; 63 | } 64 | __asm 65 | halt 66 | __endasm; 67 | } 68 | return rb; 69 | } 70 | 71 | char uart_readB(void) 72 | { 73 | // Blocking read 74 | unsigned char rb; 75 | unsigned long i=0; 76 | while(uart_isavailable()==0) 77 | { 78 | __asm 79 | halt 80 | __endasm; 81 | } 82 | rb=InPort(RBR_THR); 83 | return rb; 84 | } 85 | 86 | void uart_write(char wb) 87 | { 88 | while ((InPort(LSR)&0x20)==0) 89 | { 90 | __asm 91 | nop 92 | __endasm; 93 | } 94 | OutPort(RBR_THR,wb); 95 | } 96 | 97 | 98 | 99 | char check_BC(void) 100 | { 101 | // Check if badcat is present 102 | unsigned char ub=0; 103 | OutPort(SR,0x55); 104 | if (InPort(SR)==0x55) 105 | { 106 | ub=1; 107 | } 108 | return ub; 109 | } 110 | 111 | // Helper Functions 112 | 113 | void read_sep_NULL( char *output) { 114 | char i = 0; 115 | char rb; 116 | uart_readTimeout(retries); 117 | while (uart_readTimeout(retries)!= 0x00) { 118 | rb=uart_readTimeout(retries); 119 | output[i] = rb; 120 | i++; 121 | } 122 | output[i]=0x00; 123 | } 124 | 125 | char* receive_buffer_NULL() 126 | { 127 | char buf[64]; // Asignar memoria para el string 128 | unsigned char i=0; 129 | char rc; 130 | while(uart_isavailable()) 131 | { 132 | rc=uart_readTimeout(retries); 133 | if (rc!=0x00) 134 | { 135 | buf[i]=rc; 136 | i++; 137 | } 138 | else 139 | { 140 | buf[i]=0x00; 141 | } 142 | } 143 | return buf; 144 | } 145 | 146 | char* receive_buffer_NULLB() 147 | { 148 | char buf[200]; // Asignar memoria para el string 149 | char rc; 150 | int i=0; 151 | rc=uart_readB(); 152 | if (rc==0x00) 153 | { 154 | rc=0xff; 155 | while(rc!=0x00) 156 | { 157 | rc=uart_readB(); 158 | if (rc!=0x00) 159 | { 160 | buf[i]=rc; 161 | i++; 162 | } 163 | 164 | } 165 | } 166 | return buf; 167 | } 168 | 169 | void flush_FIFO(void) 170 | { 171 | volatile int i; 172 | unsigned char r; 173 | for (i=0;i<20;i++) 174 | { 175 | r=InPort(RBR_THR); 176 | } 177 | } 178 | 179 | void delay(unsigned int n) 180 | { 181 | // Implements a n/50 seg delay 182 | unsigned int i; 183 | for (i=0;i