Testing custom tape routines on Emu?

This is the best place to discuss about the various Oric operating systems like Sedoric, Randos, FT-Dos, and others, as well as serious software, utilities, word processors, disassemblers, etc... that runs on oric computers.
User avatar
6502Nerd
Pilot Officer
Posts: 111
Joined: Thu Oct 08, 2020 9:48 pm
Location: Leicestershire, UK
Contact:

Testing custom tape routines on Emu?

Post by 6502Nerd »

Hi

I have been working on one major hobby project for a while, which is a homebrew 65c02 computer build entirely on breadboard, with full software stack built from scratch.

One of that stack is a BASIC-like programming language I call dflat (play on C# - get the joke?!). I have started porting the code to my Oric-1, which has been a bit painful (65c02 has some useful features not present on 6502). But it's kind of working on the Oricutron emu with very little space in the 16KB ROM of the Oric.

One thing I haven't yet addressed is load/save. I want to use the tape system so that the ROM will work on a real Oric, however I am not sure if this is possible to test on the emulator? I can see the patch files are available for me to override load and save byte routines which allows use of the PC filesystem.. but will the PB7 port output and PB6 input work to generate and read WAV files? Also, I can't use the Oric ROM routines as I have literally got an entirely new BIOS and stack.

Any thoughts welcome!

Cheers, 6502Nerd
User avatar
Chema
Game master
Posts: 3014
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Testing custom tape routines on Emu?

Post by Chema »

I am quite sure that you can use the virtual tape (was that the name?) on Oricutron. I think that is what is used when the ROM is not the 1.1, and thus is not patched to load the data immediately from a PC file. Some turbo loading routines already exist and some games use them. With Oricutron, this works well when you select the wav file (not a tap). Never tried the saving though, but it may require some experimenting.

In fact I think that, when saving this way (custom routines), you need to insert a virtual tape (Oricutron's menu) and select a name for the file which will be in ORT format (some esoteric format used by Oricutron only). Maybe then start recording (again menu) and do the SAVE. I am writing this from memory, as I did something like that to get data saved from The Quill, which uses its own routines.

Hope this helps, somewhat :)

Cheers!
User avatar
6502Nerd
Pilot Officer
Posts: 111
Joined: Thu Oct 08, 2020 9:48 pm
Location: Leicestershire, UK
Contact:

Re: Testing custom tape routines on Emu?

Post by 6502Nerd »

Ah, right - I will try that. Because I am writing the code from scratch, it will not be using the same bit rate as the standard Oric routines (I want to make it more like 1200 baud than 2400 for better reliability - but will also experiment with variable rates on a real machine).

Thanks for the direction, yes very helpful! :-)
User avatar
Symoon
Archivist
Posts: 2307
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

Re: Testing custom tape routines on Emu?

Post by Symoon »

There's also the hardware tape on Euphoric - but the emulator is plain DOS and may be a bit painful to install these days.

I recall testing Novalight WAV files with both Euphoric and Oricutron.
User avatar
6502Nerd
Pilot Officer
Posts: 111
Joined: Thu Oct 08, 2020 9:48 pm
Location: Leicestershire, UK
Contact:

Re: Testing custom tape routines on Emu?

Post by 6502Nerd »

Thanks for the insight - I used Eurphoric many moons ago, but I cannot get it to work under Win10 at all, so these days Oricutron is what I use.

I am glad that it looks like I should be able to use PB7 for output to WAV and CB1 for input from WAV (PB6 I noted earlier is of course actually used just for the cassette motor). I have not yet had time to sit down and write the routines, but should have a couple of evenings available over the next few days.
User avatar
coco.oric
Squad Leader
Posts: 720
Joined: Tue Aug 11, 2009 9:50 am
Location: North of France
Contact:

Re: Testing custom tape routines on Emu?

Post by coco.oric »

@6502nerd :

There's no problem to launch euphoric on a win10 pc.
You only have to install dosbox-x.
https://dosbox-x.com/

i've it on my computer, using euphoric if needed.
anyway, oricutron is quicker to do some trials
coco.oric as DidierV, CEO Member
Historic owner of Oric, Apple II, Atari ST, Amiga
User avatar
Dbug
Site Admin
Posts: 4444
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Re: Testing custom tape routines on Emu?

Post by Dbug »

coco.oric wrote: Wed Oct 14, 2020 6:35 am There's no problem to launch euphoric on a win10 pc.
You only have to install dosbox-x.
https://dosbox-x.com/
Nice, I did not know this evolution of dosbox, I was still using my 0.74 something something from many years ago!
User avatar
6502Nerd
Pilot Officer
Posts: 111
Joined: Thu Oct 08, 2020 9:48 pm
Location: Leicestershire, UK
Contact:

Re: Testing custom tape routines on Emu?

Post by 6502Nerd »

Oh, thank you for this new information - I will try it for sure as I am not sure how much I can trust Oricutron to test my custom tape routines.

I am using Oricutron and my real Oric to detect the CB1 signal and measure using T2 the time between state changes which gives a 0 or 1 bit input (this is how Oric ROM does it, having looked at the commented disassembly).

I am feeding a 4800Hz WAV file in to Oricutron - the measurements are reliable and I am seeing '1' bits.

However same file played in to a real Oric, it's a mix of 0 and 1 and the measurement is not anything like stable.

So will try with Euphoric, maybe it could reveal what I am doing wrong..

(PS Just to say - my real Oric does load from tapes and WAV, so I do not think I have an issue with my machine).
User avatar
Symoon
Archivist
Posts: 2307
Joined: Sat Jan 14, 2006 12:44 am
Location: Paris, France

Re: Testing custom tape routines on Emu?

Post by Symoon »

In my Novalight tests, IIRC both had their advantages but Oricutron was better on the speed - Euphoric used to slow down a bit.

About your 4800Hz file, beware that files under 11kHz are not perfectly re-read by most players and create loading errors - it's a well-known problem by people that have been working with TAP and WAV files for decades ;)
User avatar
6502Nerd
Pilot Officer
Posts: 111
Joined: Thu Oct 08, 2020 9:48 pm
Location: Leicestershire, UK
Contact:

Re: Testing custom tape routines on Emu?

Post by 6502Nerd »

I am going back to basics and using Audacity to feed various frequencies (sampled as mono 44.1KHz) direct in to my real Oric-1. And it's not working! I know this set up works fine because I have played other WAV files through Audacity and the Oric has loaded them fine.

I basically have copied the 1.1 ROM code to read a bit from CB1:

Code: Select all

; IO_0 = 0x300 for base address of 6522
; X=0 on entry
tape_get_byte
	sei
	lda #0x40
	sta IO_0+PRB		; Tape motor ON
tape_get_bit_test
	jsr tape_get_bit
	ora #0x20
	sta 48800,x		; Poke counter value to screen bottom right
	inx
	jmp tape_get_bit_test

tape_get_bit				; Basically copied from 1.1 ROM address 0xe71c
	lda IO_0+PRB			; Clear CB1 interrupt flag by reading PRB
tape_get_bit_cb1
	lda IO_0+IFR			; Check for CB1 transition
	and #IFR_CB1
	beq tape_get_bit_cb1	; Keep checking until CB1 active
	lda IO_0+T2CH			; Get the high byte of T2 counter
	pha
	lda #0xff
	sta IO_0+T2CH			; Reset high byte of T2 counter
	pla					; What was previous counter?
	cmp #0xfe				; C=1 if T2 >= 0xfe else C=0
	rts					; Carry contains the bit received
If I feed a constant frequency e.g. 1200, 2400, 4800 Hertz, A should contain T2 counter high value of CB1 transition time.

My main routine is calling the tape_get_bit routine and poking the counter value (with bit 5 set to avoid attributes) to the screen.

What I am expecting is a reasonably stable value for the T2 high counter as I am feeding a single frequency. What I get is not very stable. I have even got a 1Hz signal getting picked up by CB1 transitions at what my hand timing is showing 1 per second, but the T2 counter high reading is still behaving oddly

Can anyone see a problem with the code above? The 6522 is set up earlier with the ACR set to 0x00 (T2 in normal countdown mode)..

Hoping I am making some school boy error! :-)
User avatar
6502Nerd
Pilot Officer
Posts: 111
Joined: Thu Oct 08, 2020 9:48 pm
Location: Leicestershire, UK
Contact:

Re: Testing custom tape routines on Emu?

Post by 6502Nerd »

Hello, well I thought I would update this thread in case it might help anyone else, but have more questions too!

The CB1 line of my real Oric was unstable due to the expansion board I was using (a breadboard circuit I made myself) - looks like /ROMDIS needs to be the NAND of A13 and A14 (same as the /OE line of the EEPROM). I don't understand why, so if anyone know please check the hardware board and enlighten!

Anyway, I have made some progress. My custom routines use the same low level encoding as Oric;
- each bit is encoded as half cycle of 4800Hz then;
- half cycle of 4800Hz for a '1' or
- 2400Hz for a '0'

However, I deviate somewhat from this occasionally because;
- I have two start bits of '1', then 8 bits of data then one stop bit of '0'
- Knowing the last (stop) bit is a '0' means that the last half cycle was @ 2400Hz
- Without any further CPU intervention, CB1 toggles at this rate
- So that means I get full cycles at 2400Hz, until the next start bit
- I output 256 byte block at a time and leave 1 second between blocks
- Before each block is a 2-byte block number
- Before the block starts (even the block number) I output 64 bits of '0' in normal encoding
- The 1 second gap is at 2400Hz and is there so that during load, the CPU can process block in buffer before loading the next block

This seems to work fine on a real Oric-1 with my software, using PC (Audacity) to capture and play back the tape signals.

Unfortunately the wav file which works fine on the real Oric, does not work well in Oricutron. However if I make a program in the emulator and save using the ORT file format, it kind of works when loading back in to the emulator (some odd issue, but I will look more in to this first).

I would really like to play the ORT output to the real Oric and try it - but it needs to be a WAV.

So my question: Is there any program to convert from ORT to WAV? Apologies if this has already been answered but I looked but didn't find.

Thanks! :)
User avatar
Chema
Game master
Posts: 3014
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Testing custom tape routines on Emu?

Post by Chema »

About the ORT conversion, I made a quick and dirty program to convert from ORT to TAP, which could then be converted to WAV with wav2tap.

I have to get to my PC for the code, but it was a quick hack and I know it has bugs, but it worked for my needs back then.

As soon as I can, I may post it here. Full of shame for the horrific code for sure.
User avatar
6502Nerd
Pilot Officer
Posts: 111
Joined: Thu Oct 08, 2020 9:48 pm
Location: Leicestershire, UK
Contact:

Re: Testing custom tape routines on Emu?

Post by 6502Nerd »

Chema wrote: Thu Oct 22, 2020 10:27 pm As soon as I can, I may post it here. Full of shame for the horrific code for sure.
That would be great - and I sympathise with not wanting to release horrific code! I am not going to release my dflat system until I have done some beautification and optimisation so as not to look like a total idiot :oops: :lol:

You can just make the binary available if that feels better :)
User avatar
Chema
Game master
Posts: 3014
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: Testing custom tape routines on Emu?

Post by Chema »

Oh my gosh! I almost forgot this... sorry.

I looked through my disk folders and found the hack I made to convert an ort file to tap. I cannot remember how I came up with this code, but surely stealing functions from Oricutron's source code.

That being said, the filenames are hardcoded, because this was just a hack and I intended to create a fully functional tool later. Sadly, that never happened.

So, a binary won't be useful for anybody. Therefore I include the C source (it compiled with QtCreator under Windows) advising anyone using this, that it would require some completion, cleaning, and debugging. I just don't have time now :cry: so it'd be great if somebody come up with this and share the source code.
ort2tap.zip
(2.83 KiB) Downloaded 242 times
User avatar
6502Nerd
Pilot Officer
Posts: 111
Joined: Thu Oct 08, 2020 9:48 pm
Location: Leicestershire, UK
Contact:

Re: Testing custom tape routines on Emu?

Post by 6502Nerd »

Hi Chema

Thanks for posting this - I didn't reply sooner as I have been trying to solve strange instability in the ROM expansion board I created (now resolved - I put an update in the hardware hacks section).

So I have resumed working on my ROM with custom tape routines again and experimenting with my real Oric-1 and Oricutron (both running my custom ROM).

I realised a few days ago that Oricutron should read my custom WAV files, and write ORT files from my custom ROM - it seemed to get some bytes but corruption at the beginning. So I changed my tape routines a little bit, notably on the initial synchronisation and I found that this helped not only with the real Oric-1, but also on Oricutron!

I can now load a custom WAV file created on the real Oric-1 using the emu. I can also save and create ORT files with my custom ROM :-)

The thing I cannot yet do is create a program on emu and save it in a format that I can load in to a real Oric - and this is hopefully where your utility will come in handy!
Post Reply