Skip to content

Improve advice on C64-style banking: 0001 is write only; I/O is mis-described; example should use $84/$85 to demo I/O #669

Description

@dansanderson

Memory chapter on C64-style banking says:

To bank out the I/O registers such that the 16-bit addresses $D000 – $DFFF access the underlying Chip RAM at 0.D000 – 0.DFFF, clear bits 0 and 1 of location $0001. To restore the I/O registers, set bits 0 and 1 of location $0001.

This is inaccurate. It should say to write a value with bits 0 and 1 are clear to disable I/O, and bit 0 is set and bit 1 is clear to enable I/O. The intent is to recognize that MEGA65 programmers only care about enabling or disabling I/O, and probably do not want to bank in C64 ROM.

This also needs to be revised to emphasize that 0001 is write-only. You can't use TRB/TSB, nor a load-update-store method, to update just those bits in isolation. This section should recommend full 8-bit values for these two states, specifically $84 to disable I/O and $85 to enable I/O. The BASIC sample should be revised to use POKE 1,$84 to disable I/O and POKE 1,$85 to enable I/O.

Note that the BASIC sample does work in its current form, writing (decimal) 240 to disable and 255 to enable, but it would be more generally useful to recommend $84 (132) and $85 (133) instead, because it keeps C64 ROM out of the way when MAPHI is not the BASIC default. Confusingly, POKE 1,241 crashes BASIC, but POKE 1,$85 doesn't, so whatever difference there is between writing 255 (%11111111) and 241 (%11111101) is subtle and off-topic.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    newNew report, not classified yet

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions