Inside Replay Essentials.txt: Difference between revisions

From ReplayResources
Jump to navigationJump to search
mNo edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
''Inside_Replay_Essentials.txt'' is a rewritten version of the [[Inside_Replay.txt|original documentation]] and '''is used during development''' of the ''CPX RR ROM'' only. The FlashMode e.g. is not described at all.
''Inside_Replay_Essentials.txt'' is a rewritten version of the [[Inside_Replay.txt|original documentation]] and '''is used during development''' of the '''CPX Replay ROM''' only. The FlashMode for instance is not described at all.




Line 5: Line 5:
This document explains in short the register setup of the Retro Replay original
This document explains in short the register setup of the Retro Replay original
cartridge in non-flash mode. Since other ROM banking setups rather than the ones
cartridge in non-flash mode. Since other ROM banking setups rather than the ones
we use as an "environment" for the RR code are possible the document may lack or
we use as an "environment" for the ROM code are possible the document may lack partially.
appear biased. Please comment!


The entry to the ROM is the bank 0 reset vector ($8000 -> CBM80) just like on AR
The entry to the ROM is the bank 0 reset vector ($8000 -> CBM80) just like on AR
hardware. (TODO: Check Atomic and Nordic out of curiosity)
hardware.
On RR hardware we _SHOULD_ initialise Bit 1, 2 and 6 of $DE01 to enable
On Retro hardware we _SHOULD_ initialise Bit 1, 2 and 6 of $DE01 to enable
the REU compatible memory mode, keep the freeze button working and disallow banking
the REU compatible memory mode, keep the freeze button working and disallow banking
of cart RAM other than from bank 0.
of cart RAM other than from bank 0.


As a result any clone hardware emulating AR and RR hardware "seperately" in some
As a result any clone hardware emulating AR and RR hardware "seperately" in some
way should by default select to enable any accessory connector and of course the
way should by default enable any accessory connector and of course the
REU compatible memory map. Clone devices such as the 1541u may choose to "ignore"
REU compatible memory map. Clone devices such as the 1541u may choose to "ignore"
$de01 write accesses rendering it to a non-register effectively.
$de01 write accesses rendering it to a non-register effectively.
'''We hereby swear we will not use $de01 for setting reading back the current ROM bank!'''
'''We hereby swear we will not use $de01 for setting or reading back the current ROM bank!'''
(Note: $de01 is currently used for SilverSurfer detection but that needs fixing anyhow.)
(Note: $de01 is currently used for SilverSurfer detection but that needs fixing anyhow.)


Therefore $de01 can safely be ignored on hardware implementations of the register
Therefore $de01 can safely be ignored on hardware implementations of the register
setup as described below.
setup as described below.
It should be possible to distinguish between real RR hardware and clones by simply
reading back our initialisation value from startup from RAM bank 0 of the cartridge.
This should reveal wether the $de01 register is available and was addressed or not.


There are side effects of course: Dropping the "AllowBank" bit on clone hardware
There are side effects of course: Dropping the "AllowBank" bit on clone hardware
Line 32: Line 27:
feature.
feature.


RAM AllowBank usage would fragment RAM on banks 2 and above and in regards of using
RAM AllowBank usage would fragment RAM on banks above 0 and in regards of using
it continously for e.g. storing source codes and alike it would be a bad idea to use.
it continously for e.g. storing source codes and alike it would be a bad idea to use.


So the ideal startup code looks like:
So the ideal startup code looks like (unvalidated for a few things - FIXME):
- hit $de01 and init RR
- hit $de01 (with %01000000) and init RR hardware - ineffective on original AR hardware
- read back $9e01 and check with previous write
- read back $9e01 and check with previous write
- in any case continue - but be aware that 9e01 successful comparison means diff. HW
- in any case continue - but be aware that 9e01 successful comparison means diff. HW


- A secure but more excessive approach is taken by ... (FIXME)


This leaves us with just one register at $de00 set to $00 on reset/powerup
This leaves us with just one register at $de00 set to $00 on reset/powerup
which works like this on WRITE:
which works like this on WRITE:


bit 7 - ROM bank selector (A15)
bit 7 - ROM bank selector (A15)
bit 6 - Restores memory map after freeze, GAME and EXROM "reset"
bit 6 - Restores memory map after freeze, GAME and EXROM "reset"
      - no function when not in freeze mode
      - no function when not in freeze mode
bit 5 - 0 = ROM and 1 = RAM
bit 5 - 0 = ROM and 1 = RAM
bit 4 - ROM bank selector (A14)
bit 4 - ROM bank selector (A14)
bit 3 - ROM bank selector (A13)
bit 3 - ROM bank selector (A13)
bit 2 - 1 = cartridge kill
bit 2 - 1 = cartridge kill
bit 1 - 1 = /EXROM high  (0 = "assert" and 1 = "de-assert")
bit 1 - 1 = /EXROM high  (0 = "assert" and 1 = "de-assert")
bit 0 - 1 = /GAME  low  (1 = "assert" and 0 = "de-assert")
bit 0 - 1 = /GAME  low  (1 = "assert" and 0 = "de-assert")




Reading $de00 should result in:
Reading $de00 should result in:
bit 7 - ROM bank selector (A15)
bit 7 - ROM bank selector (A15)
bit 6 - initialised with 1 by RR software (REU compat memory map)
bit 6 - initialised with 1 by RR software (REU compat memory map)
      - clones should always return 1
      - clones should always return 1
bit 5 - 0 since no flash  
bit 5 - 0 since no flash  
      - clones should always return 1
      - clones should always return 1
bit 4 - ROM bank selector (A14)
bit 4 - ROM bank selector (A14)
bit 3 - ROM bank selector (A13)
bit 3 - ROM bank selector (A13)
bit 2 - 1 when freeze button is pressed and 0 otherwise
bit 2 - 1 when freeze button is pressed and 0 otherwise
bit 1 - initialised with 0 by RR software (AllowBank)
bit 1 - initialised with 0 by RR software (AllowBank)
      - clones should always return 0
      - clones should always return 0
bit 0 - 0 = no flash
bit 0 - 0 = no flash




On freezing bank 0 is activated at $e000 so the NMI "vector" of bank 0 is leading
On freezing bank 0 is activated at $e000 so the NMI "vector" of bank 0 is leading
the freeze code further. Make sure to check out the return code which on current
the freeze code further. Make sure to check out the return code which on current
RR needs to be aligned to a kernel RTS. :)
CPX Replay needs to be aligned to a kernel RTS. :)


During freeze mode the RR hardware is keeping control over GAME and EXROM and
During freeze mode the RR hardware is keeping control over GAME and EXROM and
ignores any write accesses until bit 6 is set. On setting bit 6 of $de00 the
ignores any write accesses until bit 6 is set. On setting bit 6 of $de00 the
standard memory map will instantly be restored and GAME/EXROM can be used again.
standard memory map will be restored and GAME/EXROM can be used again.


Being in freeze mode allows ROM banks to be mapped by $de00 as before but of course
Being in freeze mode allows ROM banks to be mapped by $de00 as before but of course
they are mapped to $e000. RAM can only be accessed on the free I/O1 area.  
they are mapped to $e000. RAM can only be accessed on the free I/O1 area.  
Doc Bacardi did some actual hardware testing and provides us with this memory map for RR hardware:
; DE00 bits 0 and 1
;    |  $8000  |  $a000  |  $e000  |  $dx00  |
;-----+---------+---------+---------+---------+
; $00 | RR-Rom  | C64-Rom | C64-Rom | RR-Rom  | All these can be toggled to C64-RAM using $01
;-----+---------+---------+---------+---------+
; $01 |  Hole  | RR-Rom  | C64-Rom |  Hole  | All these can be toggled to C64-RAM using $01
;-----+---------+---------+---------+---------+
; $02 | C64Ram  | C64-Rom | C64-Rom | RR-Rom  |
;-----+---------+---------+---------+---------+
; $03 | RR-Rom  |  Hole  | RR-Rom  |  Hole  |  Memory hole in RAM from $1000-$xxxx and in ROM at $a000-$xxxx, without set REU_Comp bit only Bank 0 is selectable
;-----+---------+---------+---------+---------+
;    |  $8000  |  $a000  |  $e000  |  $dx00  |
;-----+---------+---------+---------+---------+
; $20 | RR-Ram  | C64-Rom | C64-Rom | RR-Ram  | All these can be toggled to C64-RAM using $01
;-----+---------+---------+---------+---------+
; $21 | RR-Ram  | RR-Rom  | C64-Rom | RR-Ram  | All these can be toggled to C64-RAM using $01
;-----+---------+---------+---------+---------+
; $22 | C64Ram  | C64-Rom | C64-Rom | RR-Ram  |
;-----+---------+---------+---------+---------+
; $23 | RR-Ram  |  Hole  | RR-Rom  | RR-Ram  | Memory hole in RAM from $1000-$xxxx and in ROM at $a000-$xxxx, without set REU_Comp bit only Bank 0 is selectable
;-----+---------+---------+---------+---------+


</pre>
</pre>


[[Category:Retro_Replay_Hardware]]
[[Category:Retro_Replay_Hardware]]
[[Category:Retro_Replay_Software]]

Latest revision as of 23:23, 15 July 2011

Inside_Replay_Essentials.txt is a rewritten version of the original documentation and is used during development of the CPX Replay ROM only. The FlashMode for instance is not described at all.


This document explains in short the register setup of the Retro Replay original
cartridge in non-flash mode. Since other ROM banking setups rather than the ones
we use as an "environment" for the ROM code are possible the document may lack partially.

The entry to the ROM is the bank 0 reset vector ($8000 -> CBM80) just like on AR
hardware.
On Retro hardware we _SHOULD_ initialise Bit 1, 2 and 6 of $DE01 to enable
the REU compatible memory mode, keep the freeze button working and disallow banking
of cart RAM other than from bank 0.

As a result any clone hardware emulating AR and RR hardware "seperately" in some
way should by default enable any accessory connector and of course the
REU compatible memory map. Clone devices such as the 1541u may choose to "ignore"
$de01 write accesses rendering it to a non-register effectively.
'''We hereby swear we will not use $de01 for setting or reading back the current ROM bank!'''
(Note: $de01 is currently used for SilverSurfer detection but that needs fixing anyhow.)

Therefore $de01 can safely be ignored on hardware implementations of the register
setup as described below.

There are side effects of course: Dropping the "AllowBank" bit on clone hardware
adds a little incompatibility but at least the RR team never found it to be a useful
feature.

RAM AllowBank usage would fragment RAM on banks above 0 and in regards of using
it continously for e.g. storing source codes and alike it would be a bad idea to use.

So the ideal startup code looks like (unvalidated for a few things - FIXME):
- hit $de01 (with %01000000) and init RR hardware - ineffective on original AR hardware
- read back $9e01 and check with previous write
- in any case continue - but be aware that 9e01 successful comparison means diff. HW

- A secure but more excessive approach is taken by ... (FIXME)

This leaves us with just one register at $de00 set to $00 on reset/powerup
which works like this on WRITE:

 bit 7 - ROM bank selector (A15)
 bit 6 - Restores memory map after freeze, GAME and EXROM "reset"
       - no function when not in freeze mode
 bit 5 - 0 = ROM and 1 = RAM
 bit 4 - ROM bank selector (A14)
 bit 3 - ROM bank selector (A13)
 bit 2 - 1 = cartridge kill
 bit 1 - 1 = /EXROM high  (0 = "assert" and 1 = "de-assert")
 bit 0 - 1 = /GAME  low   (1 = "assert" and 0 = "de-assert")


Reading $de00 should result in:
 bit 7 - ROM bank selector (A15)
 bit 6 - initialised with 1 by RR software (REU compat memory map)
       - clones should always return 1
 bit 5 - 0 since no flash 
       - clones should always return 1
 bit 4 - ROM bank selector (A14)
 bit 3 - ROM bank selector (A13)
 bit 2 - 1 when freeze button is pressed and 0 otherwise
 bit 1 - initialised with 0 by RR software (AllowBank)
       - clones should always return 0
 bit 0 - 0 = no flash


On freezing bank 0 is activated at $e000 so the NMI "vector" of bank 0 is leading
the freeze code further. Make sure to check out the return code which on current
CPX Replay needs to be aligned to a kernel RTS. :)

During freeze mode the RR hardware is keeping control over GAME and EXROM and
ignores any write accesses until bit 6 is set. On setting bit 6 of $de00 the
standard memory map will be restored and GAME/EXROM can be used again.

Being in freeze mode allows ROM banks to be mapped by $de00 as before but of course
they are mapped to $e000. RAM can only be accessed on the free I/O1 area. 

Doc Bacardi did some actual hardware testing and provides us with this memory map for RR hardware:

; DE00 bits 0 and 1
;     |  $8000  |  $a000  |  $e000  |  $dx00  |
;-----+---------+---------+---------+---------+
; $00 | RR-Rom  | C64-Rom | C64-Rom | RR-Rom  | All these can be toggled to C64-RAM using $01
;-----+---------+---------+---------+---------+
; $01 |  Hole   | RR-Rom  | C64-Rom |  Hole   | All these can be toggled to C64-RAM using $01
;-----+---------+---------+---------+---------+
; $02 | C64Ram  | C64-Rom | C64-Rom | RR-Rom  |
;-----+---------+---------+---------+---------+
; $03 | RR-Rom  |  Hole   | RR-Rom  |  Hole   |  Memory hole in RAM from $1000-$xxxx and in ROM at $a000-$xxxx, without set REU_Comp bit only Bank 0 is selectable
;-----+---------+---------+---------+---------+

;     |  $8000  |  $a000  |  $e000  |  $dx00  |
;-----+---------+---------+---------+---------+
; $20 | RR-Ram  | C64-Rom | C64-Rom | RR-Ram  | All these can be toggled to C64-RAM using $01
;-----+---------+---------+---------+---------+
; $21 | RR-Ram  | RR-Rom  | C64-Rom | RR-Ram  | All these can be toggled to C64-RAM using $01
;-----+---------+---------+---------+---------+
; $22 | C64Ram  | C64-Rom | C64-Rom | RR-Ram  |
;-----+---------+---------+---------+---------+
; $23 | RR-Ram  |  Hole   | RR-Rom  | RR-Ram  | Memory hole in RAM from $1000-$xxxx and in ROM at $a000-$xxxx, without set REU_Comp bit only Bank 0 is selectable
;-----+---------+---------+---------+---------+