[Coco] tetris question
Darren A
mechacoco at gmail.com
Mon Jan 18 15:39:25 EST 2010
On 1/18/10, Arthur Flexser wrote:
> Care to explain in more detail why the reset vector (on a read CoCo) would
> affect it? I understand that the value the palette register returns for
> bits 6 and 7 depends on some register contents at the time it is read, but
> beyond that I'm a bit vague....
>
---
Whenever you read from an un-mapped hardware address or from an
address where some of the bits are undefined (like the GIME's palette
and MMU registers), the value obtained for those undefined bits is
predictable on the CoCo.
There are two possibilites which depend on the addressing mode you use
to read from such an address. If you use the "no-offset" indexed mode
(as in LDA ,X) the undefined bits will come from the first byte of the
next instruction. For any other addressing mode, the undefined bits
will come from the byte at $FFFF (LSB of the Reset vector).
When you use BASIC's PEEK command to read from an un-mapped address
(such as $FF70), you get a value of 126. This is because PEEK reads
the address with a LDA ,X instruction, so the value returned is the
opcode of the next instruction (JMP Extended = $7E = 126). If you
patch the PEEK command to use a 5-bit offset (LDA 0,X), the value
returned for an un-mapped address will instead come from $FFFF (27 on
a CoCo 3 or 39 on a CoCo 1/2).
The reason for this behavior is that the 6809 normally does a VMA
cycle just before reading the instruction's effective address. The
exception is the "no-offset" indexed mode in which case the next
instruction byte is read just prior to the effective address. During
a VMA cycle the address bus goes to Hi Impedance and the R/W line is
HI. This has the effect of loading the value from $FFFF onto the data
bus. This stale data from the previous cycle supplies the value for
the undefined bits.
Here is a small routine which will demonstrate this behavior:
ldx #$FF70
lda ,x
ldb $FF70
std $400
rts
On a CoCo 3, you should end up with the value $F61B at $400-401. On a
CoCo 1/2 you should get $F627 instead.
Darren
More information about the Coco
mailing list