New tape cleaner tool

Include new and ported/converted games, and old games/tools. Subjects about CP/M software goes in the CP/M Forum.
Tony Brewer
Posts: 108
Joined: 08 Jan 2014 20:50

Re: New tape cleaner tool

Post by Tony Brewer »

A tape-related conundrum for you:

The MTX is interesting because the cassette input is via the CTC, which can be configured with this code:

Code: Select all

	LD C,0BH	;CTC channel 3 port
	LD B,0C5H	;Enable interrupt, counter mode, trigger on C/T3 falling edge
	LD A,1		;Time constant = 1
	OUT (C),B
	OUT (C),A
Could there be any tape input if the code were changed to the following?

Code: Select all

	LD C,0BH	;CTC channel 3 port
	LD B,45H	;Disable interrupt, counter mode, trigger on C/T3 falling edge
	LD A,2		;Time constant = 2
	OUT (C),B
	OUT (C),A
muldjord
Posts: 35
Joined: 07 Oct 2018 14:49

Re: New tape cleaner tool

Post by muldjord »

I guess you could poll it continually. The speed of the cpu should be sufficient to just continually read and somehow compare the output. It would be inefficient I believe, but should work.
Tony Brewer
Posts: 108
Joined: 08 Jan 2014 20:50

Re: New tape cleaner tool

Post by Tony Brewer »

muldjord wrote: 19 Nov 2018 00:45 I guess you could poll it continually. The speed of the cpu should be sufficient to just continually read and somehow compare the output. It would be inefficient I believe, but should work.
What is "it"? There is no cassette input that can be polled directly.
muldjord
Posts: 35
Joined: 07 Oct 2018 14:49

Re: New tape cleaner tool

Post by muldjord »

Does the CTC set a register that can be polled?
Tony Brewer
Posts: 108
Joined: 08 Jan 2014 20:50

Re: New tape cleaner tool

Post by Tony Brewer »

muldjord wrote: 19 Nov 2018 02:09 Does the CTC set a register that can be polled?
Yes, here is an extract from the Zilog Z80 Family User Manual:
The Down-Counter

The down-counter is an 8-bit register that is used in both COUNTER and
TIMER modes. This register is loaded by the Time Constant register both
initially, and when it counts down to zero. In the COUNTER mode, the
down-counter is decremented by each external clock edge. In the TIMER
mode, it is decremented by the clock output of the prescaler. By performing
a simple I/O Read at the port address assigned to the selected CTC channel,
the CPU can access the contents of the down-counter and obtain the number
of counts-to-zero. Any of the four CTC channels may be programmed to
generate an interrupt request sequence each time the zero count is reached.
If the time constant is set to any even number (including zero which is interpreted as 256), then the cassette input can be read without using interrupts:

Code: Select all

	DI
	IN A,(0BH)	;Bit 0 of A is tape input if CTC channel 3 time constant even
;or
	DI
	LD C,0BH
	IN A,(C)	;Sets parity flag, so can use JP PE or JP PO
User avatar
thewiz
Posts: 137
Joined: 12 Aug 2012 16:08

Re: New tape cleaner tool

Post by thewiz »

What would be read?

In normal operation an interrupt is triggered on an edge (can't remember which on). Would not the bit read just reflect if an edge has been detected or not?

As an aside, one of these days, when the emulators are up to it, I would love to write a tape loader with music and loading screen. The only example of this FBITD is Jet Set Willy.

TTFN
THIS is what Memotech is doing now.
Tony Brewer
Posts: 108
Joined: 08 Jan 2014 20:50

Re: New tape cleaner tool

Post by Tony Brewer »

thewiz wrote: 22 Nov 2018 13:48 What would be read?

In normal operation an interrupt is triggered on an edge (can't remember which on). Would not the bit read just reflect if an edge has been detected or not?

As an aside, one of these days, when the emulators are up to it, I would love to write a tape loader with music and loading screen. The only example of this FBITD is Jet Set Willy.

TTFN
Circuitry in the MTX converts an edge at the cassette input into a short pulse at the CTC C/T3 input. The ROM sets CTC channel 3 to counter mode triggered on the falling edge of C/T3 with a time constant of 1 and interrupts enabled. (I used the rising edge in the Speculator but it makes no difference.) Thus every cassette edge will generate an interrupt, which occurs when the down-counter is decremented to zero, then automatically re-loaded with the time constant.

The current value of the down-counter can be read at any time by an IN from the CTC channel port, which can be polled to see when a cassette edge has occurred. Suppose the time constant is 2 and interrupts are disabled. If IN 0BH changes to 1, then an edge has happened and if it changes to 0 there has been another edge and the down-counter is re-loaded with 2. The next edge decrements it to 1 again, etc.

Therefore bit 0 of IN 0BH is in effect the cassette input, provided the time constant is any even number. Polarity is irrelevant as there is no way of knowing whether or not the tape player inverts the signal. This means interrupts are not needed for cassette input and a load routine could be similar to the Spectrum. I have never tested this as my MTX is packed away in the attic. Perhaps someone would like to try it?
Bill B
Posts: 593
Joined: 26 Jan 2014 16:31

Re: New tape cleaner tool

Post by Bill B »

Just a teaser.

The attached version of Mice at least loads (I am using my version of MEMU which can load ".wav" files). It is a BASIC listing (not machine code). After loading, use "CLEAR", followed by "GOTO 50". I'm not sure whether it is working properly. I have not yet worked out how to play. However it may now be easier to fix any errors in the BASIC listing rather than clean the recording further.
Attachments
Mice.zip
(39.65 KiB) Downloaded 575 times
Mice_Screenshot.png
Mice_Screenshot.png (7.61 KiB) Viewed 16048 times
User avatar
thewiz
Posts: 137
Joined: 12 Aug 2012 16:08

Re: New tape cleaner tool

Post by thewiz »

Well done Bill. One down.
THIS is what Memotech is doing now.
Bill B
Posts: 593
Joined: 26 Jan 2014 16:31

Re: New tape cleaner tool

Post by Bill B »

MTX file.Also analysis of recording.
MTX file.Also analysis of recording.
KKing32.png (10.45 KiB) Viewed 15712 times
I have managed to turn "KKing32.mp3" into an MTX file which will load in MEMU. I am not a game player, so haven't played it through. There may be some corruption in the machine code that I have not seen in my quick testing.

I assume that this is an earlier version of "Karate King 64" which is in Andy's distribution.
Attachments
KKing32.zip
(38.93 KiB) Downloaded 589 times
Post Reply