MEGA65 / mega65-user-guide

MEGA65 User Guide
73 stars 49 forks source link

Mention that >1MB MAP is not reset by the next MAP instruction #582

Open dansanderson opened 7 months ago

dansanderson commented 7 months ago

The >1MB MAP register can be set by performing a MAP twice with special values. If you perform another MAP without the special >1MB values, the upper bytes of the register retain their values. This should be mentioned in the Memory section about >1MB mapping. If a program ever sets the upper bytes, it must reset them (with two calls to MAP) when re-mapping to lower addresses.

lydon42 commented 7 months ago

Reset all mappings:

;; remove megabyte maps (setting them to 0 again)
lda #$00
ldx #$0f
ldy #$00
ldz #$0f
map
;; now zero all registers and remove all maps
tax
tay
taz
map
eom
dansanderson commented 7 months ago

@lydon42 Is the issue that the upper bytes of the MAP register are not reset when you do a <1MB MAP setting, or that they are? You're mentioning the zeroing sequence as if that needs emphasis, which suggests the former.

lydon42 commented 7 months ago

Full notes from @ki-bo (discord), emphasis mine:

Note also that if you enable >1MB mapping with

lda #$ff
ldx #$0f
ldy #$00
ldz #$00
map

then you won't disable the MB part with setting A,X,Y,Z to zero. The MB part will still stay. You need to disable MB mapping like this, too:

lda #$00
ldx #$0f
ldy #$00
ldz #$0f
map

So, to be really sure all mappings are reset, you can do this:

lda #$00
ldx #$0f
ldy #$00
ldz #$0f
map
tax
tay
taz
map
eom
ki-bo commented 5 months ago

You may want to edit the title to "Mention that >1MB MAP is not reset by the next MAP instruction"

dansanderson commented 5 months ago

Done. :)