Why Would a Game Cartridge Enable the Cassette Data Port?

Programming the 6502 microprocessor and its relatives in assembly and other languages.
Post Reply
load81
Posts: 71
Joined: 16 Nov 2018

Why Would a Game Cartridge Enable the Cassette Data Port?

Post by load81 »

I'm continuing work on disassembling and commenting the code on a a game cartridge. It's slow going, because I'm filling gaps in my modest 6502 assembly language programming as I go.

One of the oddball things I noticed while looking at the code is this this:

Code: Select all

		lda #$03		;0x8025	2	a903	; Likely a bit flag of %00000011
		sta $01		 ;0x8027	2	8501	; Write $03 (%00000011) to ZP $01, the cassette data line.
That looks like it's enabling writes to the cassette data line. But, I haven't spotted any writes to the cassette buffer. So, unless I've missed something there is no data actually being written to the cassette port itself.

Is this common in cartridge cold start routines? If so, why? Is it possible this is debug code intended to allow the cassette to be used as, well, something like a core dump target?
Chromatix
Posts: 1462
Joined: 21 May 2018

Re: Why Would a Game Cartridge Enable the Cassette Data Port

Post by Chromatix »

The 6510's "processor port" is not only used for the cassette interface. It also has some control lines that are used internally to the C64, particularly with respect to altering the memory map.

In particular, bits 0 and 1 (selected by a mask of #$03) control the /LORAM and /HIRAM lines.
load81
Posts: 71
Joined: 16 Nov 2018

Re: Why Would a Game Cartridge Enable the Cassette Data Port

Post by load81 »

Chromatix wrote:
The 6510's "processor port" is not only used for the cassette interface. It also has some control lines that are used internally to the C64, particularly with respect to altering the memory map.

In particular, bits 0 and 1 (selected by a mask of #$03) control the /LORAM and /HIRAM lines.
Right, I follow that the "processor port" [pin] is used for lots of things. What I failed to account for was zero indexed bit-masking. As a consequence, I conflated $03 with setting bit-flag #3.

From Mapping the C64...
Quote:
Bit 0: LORAM signal. Selects ROM or RAM at 40960 ($A000). 1=BASIC, 0=RAM
Bit 1: HIRAM signal. Selects ROM or RAM at 57344 ($E000). 1=Kernal, 0=RAM
Bit 2: CHAREN signal. Selects character ROM or I/O devices. 1=I/O, 0=ROM
Bit 3: Cassette Data Output line.
Bit 4: Cassette Switch Sense. Reads 0 if a button is pressed, 1 if not.
Bit 5: Cassette Motor Switch Control. A 1 turns the motor on, 0 turns it off.
Bits 6–7: Not connected—no function presently defined.
So, $03 (%00000011) would set /LORAM =1 (True), /HIRAM=1 (True) as you say, and does nothing else. By contrast, if I the cassette port were really enabled in actual fact, the value $04 (%00000100) would have been sent to $01. This is obviously not the case.

Thanks for helping me clear the cobwebs on this one.
thedrip
Posts: 48
Joined: 02 Oct 2018

Re: Why Would a Game Cartridge Enable the Cassette Data Port

Post by thedrip »

load81 wrote:
From Mapping the C64...
Quote:
Bit 0: LORAM signal. Selects ROM or RAM at 40960 ($A000). 1=BASIC, 0=RAM
Bit 1: HIRAM signal. Selects ROM or RAM at 57344 ($E000). 1=Kernal, 0=RAM
Bit 2: CHAREN signal. Selects character ROM or I/O devices. 1=I/O, 0=ROM
Bit 3: Cassette Data Output line.
Bit 4: Cassette Switch Sense. Reads 0 if a button is pressed, 1 if not.
Bit 5: Cassette Motor Switch Control. A 1 turns the motor on, 0 turns it off.
Bits 6–7: Not connected—no function presently defined.
So, $03 (%00000011) would set /LORAM =1 (True), /HIRAM=1 (True) as you say, and does nothing else. By contrast, if I the cassette port were really enabled in actual fact, the value $04 (%00000100) would have been sent to $01. This is obviously not the case.

Thanks for helping me clear the cobwebs on this one.
It looks like you're off by a bit. The Cassette Data Output line would be 00001000 = $08
$04 would be the CHAREN signal.

Doesn't matter for this discussion, but maybe prevent confusion in the future!
Post Reply