Running (6 Digit) BASIC on a C4P/MF

Post Reply
Jeff
Posts: 370
Joined: Fri Mar 07, 2014 4:44 am
Location: British Columbia, Canada

Running (6 Digit) BASIC on a C4P/MF

Post by Jeff »

Hi Everyone.

When I purchased my C4P/MF, it didn't work. (You can read my other thread on how I got it working etc.) Once got it working, I was rather upset that BASIC didn't spring to life when I turned it on. My previous experience was with a Superboard II and a C1P (essentially the same machine) and back in the day I always drooled when I saw a C4P or a C4P with FLOPPIES! at the local computer store. They were WAY out of my price range. Now, I didn't realize that as the system gained features, they also lost them too! I figured the top of the line would have all the features the runt of the litter would have, but NO! OSI was a different company. If you have floppies, why would you need cassette input/output? And with all that RAM, we can do different things with it instead of dedicating the address space to BASIC, and only BASIC.

So, I have a working machine, and no floppies. I can turn it on, watch the beauty of the "H/D/M ? prompt on the screen and listen to the rhythmic whirring of the empty floppy drive with its beautiful LED glowing away..... and that is about it. Oh wait, I can key in some programs in machine language! (NOT going to happen!)

Feeling rather unsatisfied, I rolled up my sleeves and went to work. I wanted the machine to spring into "BASIC" life with as little effort as possible.

First Step: Disassemble what little ROM there is in the machine. See other Post.

Second Step: Get a copy of BASIC. I wanted the 6-digit precision version, not the 9-digit version that is part of OS65. Easy, right? There are loads of copies of the Basic roms on the web, even this site. Just download a copy. Wrong! Apparently the BASIC for the C4P is different than the BASIC for the C1P. And the C1P version is posted everywhere, not the C4P version. Getting a copy of C4P basic is a story all its own, and one for another day. Once I had a copy of C4P-BASIC, I ran it through the disassembler, and brushed the dust off my "OSI BASIC IN ROM" book. I tried the easy route first, load it into my C4P/MF and....wait....LOAD it? at 1200 baud over the modem port using a text program and 3 characters per byte.... Hell could freeze over! I clocked the throughput of the Monitor load speed at about 340 baud. It loads about 1K per minute. So 8K BASIC would take at least 8 minutes to load. Talk about springing to life! NOT!

Third Step: Decrease the software load time. I resolved this in two ways: First, I examined the schematics of the 505 board and carefully cut a trace, and added a jumper. Now the modem port cruises at 9600 baud. Second, I wrote QuickLoad. QuickLoad is 370 bytes of speed. Its job is to be small and fast. I will post the source and binaries for QuickLoad when I am finished it. Right now it is about a version 0.8. Unfortunately QuickLoad loads the old fashion way, at 340 baud through the monitor text interface and takes about a minute. QuickLoad then runs and then takes over and loads 8K of BASIC in 14 seconds! That works for me.

Fourth Step: Fix BASIC. So with a quick loader and C4P BASIC in hand, I simply loaded the BASIC image at $A000 and jumped to the cold start address. Nothing happened. As it turns out, C4P BASIC (and C1P BASIC) rely on SYNMON rom routines. And the C4P rom routines are not all available in the C4P/MF. So the trick here was to map the differences of the C4P (3 rom pages) and the C4P/MF (3 rom pages) , basically what is available on each machine between $FD00- $FFFF. Then locate the routines in the C4P BASIC that relied on on the C4P SYNMON pages and re-route them to use the counterpart routines in the C4P/MF SYNMON pages. This was not always possible, so some "glue" routines were written to replace them. Oh, and interestingly enough, C4P SYNMON relies on routines in the BASIC rom. That meant that those entry points in BASIC HAD to stay in the same locations. This killed the option of simply re-compiling the BASIC source (available on the web).

Well after a bunch of days of research, a few thousand compiles and links, I got it working. All except LOAD and SAVE. Those are next! They need to be routed from the cassette interface to the serial interface. Once I have those working I will post all the code, binaries, and instructions for all to enjoy.

Bringing Challenger back to life!
/Jeff
Image
Jeff
Posts: 370
Joined: Fri Mar 07, 2014 4:44 am
Location: British Columbia, Canada

Re: Running (6 Digit) BASIC on a C4P/MF

Post by Jeff »

OK, Save and Load are working now!

They basically behave just like the cassette system, except the data now saves and loads through the modem port.
I have attached the executable. Please unzip and read the ReadMe.text for further information. This works really well in the C4PMF Emulator too.
Let me know if this works for you guys! I am going to finish off my quick loader for this and post that soon.
Basic for C4PMF V0.90.zip
(8.34 KiB) Downloaded 735 times
Regards
/Jeff
Image
dave
Site Admin
Posts: 710
Joined: Tue Sep 09, 2008 5:24 am

Re: Running (6 Digit) BASIC on a C4P/MF

Post by dave »

Hi Jeff,

This is really cool. Any chance on making the source available as well? I also have your diagram of the 541 board, which I need to post. I apologize for taking so long on that--just a lot on my plate recently. Also, your loader program will be a nice tool to have as well. Thanks for sharing all your cool work with us!

BASIC relies on certain ROM support routines, as you indicated, and some of the ROM routines rely on ROM BASIC as well, as you also indicated. However, I always believed that the ROM images are the same. As I understand, OSI did not want to spend money on multiple ROM images (which is why the garbage collection bug was never fixed), and they used standardized ROM routine entries and zero page vectors to allow machine dependent code and alterable routines. I can't remember if the ROMs on my website are from my C2, or elsewhere. However, I would be happy to provide you a copy of my C2 ROM BASIC for comparison, if you are interested. If you found a different copy on the net, I'd be interested in that. It would be nice to document any differences.

Pagetable.com has a version of the source that can be compiled to be byte-equal to the OSI version, and the garbage collection bug can be turned on or off. That may not be a bad version to work with as well. http://www.pagetable.com/?p=46.

Dave
Jeff
Posts: 370
Joined: Fri Mar 07, 2014 4:44 am
Location: British Columbia, Canada

Re: Running (6 Digit) BASIC on a C4P/MF

Post by Jeff »

Hi Dave,

A quick answer on the ROMS for the C4P vs the C4P/MF. They present the different startup prompts, therefore, they must be different. But that isn't completely true. I have fully documented, in note form, which I will make presentable to the masses, all the differences between the roms for the two. The secret is that the SYN600.ROM has 8 pages of which each machine can choose 3., so that way they were able to use the same rom for all the machines. Problem is, on the C4P/MF, the page within the ROM that is mapped to $FF00 is chock full of floppy support code rather than Basic support code; likewise on the C4P-Cassette-Basic-In-Rom, the page mapped to $FF00 is full of cassette and basic support instead of hard disk support. The Pages mapped in for the C1P/SuperBoard II prompt with D/C/W/M and I suspect (since I haven't looked them over too deeply) they may contain both supports, but, but, but... the C1P has a way different keyboard and different addresses for the ACIA.

I would be happy to post the source code, once I am happy with it. I am aware of the byte-equal source for OSI Basic, I have it here and referenced it during the project. Unfortunately, it was not really of much use, the compiler flags and conditional code is so extensive as to make the source barely readable at best. I had forgotten about the garbage collection bug , so I will add it to my list of fixes in an upcoming version.

I have already found a bug in the code I posted. :-(

Please send me your C2 ROM BASIC, I will compare it with what I have here. Is your C2 floppy or cassette based? I used a copy of Basic that I pulled from my C4P-Cassette machine. I wrote a small program in Basic to ?CHR$() all the bytes from $A000 through $BFFF out to the cassette port, recorded as a WAV file on my Mac and then used a python script from the web to convert to ASCII, then pasted it into a Hex Dump program and then disassembled that. During that process I compared it to one of the C1P versions of Basic on the web, and noticed there were differences. I did not make note of what they were, but I will go back and investigate them.

Last night I added some features to QuickLoader. Now, in the .QLD (quickloader files) header, you can specify, the start page, number of pages, and start address to run the loaded file. Also, quickloader now gracefully terminates the load mode rather than requiring a RESET.

My goal is to create a single file that can be sent to the Challenger, at the moment it is a 2-step process.


Best Regards
/Jeff
Image
dave
Site Admin
Posts: 710
Joined: Tue Sep 09, 2008 5:24 am

Re: Running (6 Digit) BASIC on a C4P/MF

Post by dave »

Yes, there are different versions of the monitor ROMs. I am aware of the SYNMON1 ROM (for C2/4/8) which includes routines for polled and ASCII keyboards, serial and video machines, hard disk boot, floppy boot, 65V monitor, and ROM BASIC support. There is the SYN600 ROM that has the C1/600 routines for keyboard, video, BASIC support, 65V monitor, and floppy boot (supports all four since the serial port isn't right in the middle of the upper 2K), as well as video, BASIC support, Floppy boot, and 65V for the C2/4/8. The earlier ROMS were on 1702A chips, as far as I know. I check my ROM BASIC from my SBII and my C2, and the one on this site, and will report the difference. I'll be happy to send you a copy of my C2 ROM.

Keep up the good work,

Dave
Jeff
Posts: 370
Joined: Fri Mar 07, 2014 4:44 am
Location: British Columbia, Canada

Re: Running (6 Digit) BASIC on a C4P/MF

Post by Jeff »

my C4P Rom:
C4P ROM.JPG
C4P ROM.JPG (27.52 KiB) Viewed 11723 times
my C4PMF Rom:
C4PMF ROM.JPG
C4PMF ROM.JPG (21.13 KiB) Viewed 11723 times
Hard to tell them apart ;-)

/Jeff
Image
dave
Site Admin
Posts: 710
Joined: Tue Sep 09, 2008 5:24 am

Re: Running (6 Digit) BASIC on a C4P/MF

Post by dave »

That seems right. Most later machines came with the SYN600 ROM, since support for serial systems, ASCII keyboards, 74 MB hard drive were not required for most C4/C8 systems.
Steve Gray
Posts: 321
Joined: Mon Oct 06, 2008 1:54 pm
Location: Markham, Ontario, Canada
Contact:

Re: Running (6 Digit) BASIC on a C4P/MF

Post by Steve Gray »

Jeff, are you saying the contents of those two roms are different? I thought 7937 and 7935 are just manufacturing date codes for 1979, 35th or 37th week?

Very interesting what you are doing. Have you looked at the various 3rd-party monitor roms that are available? CEGMON, NEWMON, WEMON etc? I believe WEMON has a fast tape loader that might be similar to what you have done. Also take a look at CEGMON. It has source code available that might be useful.

I think the various monitor roms and mapping need to be better documented.

On a similar note, one of the things I am doing now is disassembling, commenting, and modifying the Commodore PET editor roms:

http://www.6502.org/users/sjgray/projec ... index.html
https://github.com/sjgray/cbm-edit-rom

I think the PET had the best screen editor of any 8-bit micro and it I always thought it would be cool if the OSI had similar features. I don't know if it's feasible but would anyone be interested in a new monitor rom like that?

Steve
C4P working, C1P working. 600D Replica working, C4P+D&N floppy not working. 505 board, 610 board, Mittendorf board, TOSIE hacker board need testing, PicoDOS disk untested.
Jeff
Posts: 370
Joined: Fri Mar 07, 2014 4:44 am
Location: British Columbia, Canada

Re: Running (6 Digit) BASIC on a C4P/MF

Post by Jeff »

Hi Steve, the two Roms are identical inside. They just map different parts to visible memory space. I haven't yet checked out the other Roms, but I will.
Image
MK14HAK
Posts: 356
Joined: Wed Mar 16, 2011 1:49 am
Location: New Zealand

Re: Running (6 Digit) BASIC on a C4P/MF

Post by MK14HAK »

Jeff wrote:
I am going to finish off my quick loader for this and post that soon.

Last night I added some features to QuickLoader. Now, in the .QLD (quickloader files) header, you can specify, the start page, number of pages, and start address to run the loaded file. Also, quickloader now gracefully terminates the load mode rather than requiring a RESET.

Regards
/Jeff
Jeff do you have this available ??

Mike
600RevB:16K,2MHz,64x32,470,CEGMON
SuperKit:502,540B,542B,CEGMON, 8" and 5" FDDs
Cards:PE IO,6522 D-A-D, AY3-8910,ProgramGraphics,Color,UK101
WIP:HexDOS,FDD Emulator
Post Reply