Comments (3)
Very interesting note. It seems to be exactly the issue I ran into this week and which really cost me a lot patience. All my IRQ code which was placed behind my Basic in $2300 was resulting in an unwanted BRK. I was not able to prevent this and the BRK was not resumable in any scenario I tried.
Finally I found out that when my IRQ code goes to $1600, it just works without BRK and complains, but the Basic part had to run with BANK 128 active - otherwise my IRQ branching is not triggered at all. Is this the problem you are describing above? Sounds very near for my ears.
Memory on M65 is very confusing!
You hear it in my question above, I am far not as ready as I should be to write the docs for it. But when it is not done in a time where I sorted all this out, I am in to help.
Nevertheless, I can support before, when something must be tested. E.g. the demo code of somebody else who is documenting it ... let me know ... or maybe somebody else sees this note.
from mega65-user-guide.
@Pimau That sounds more like MAP register state than base page B register state, but yes, the general idea is the same. It is difficult to combine machine code and KERNAL code without knowing a great deal about how the CPU and KERNAL behave. Some of these behaviors are not yet stable API surfaces, and so not yet documented. In your case, the KERNAL keeps MAPL set to E300 when running BASIC, which hides most RAM in $2000-$7FFF from the CPU. You don't mention how you're installing your IRQ handler, but if you're also engaging the KERNAL IRQ routines and BASIC, you'll need to manage the MAP register so it is what the KERNAL expects when it is time to run its code.
The Commodore 64 KERNAL has a "soft IRQ" installation vector, a memory location where you can set an address for some code that runs during the KERNAL IRQ handler. While Commodore intended a similar facility for the C65, this is not yet officially documented for the MEGA65 KERNAL, partly for this reason: the needs of a "soft IRQ" API are much more complex for the MEGA65 than for the C64, and we need to design, test, and document this API to be practical to use, such as the pre- and post-conditions of register state for the soft IRQ routine. For example, it would be an improvement for the KERNAL to take care of resetting MAP and B on return from the soft IRQ.
For what it's worth, the BASIC BANK command only affects how address arguments to BASIC commands are interpreted. It does not change the state of any CPU registers. See the Memory chapter for details.
from mega65-user-guide.
Some good news: I confirmed that the IRQ handler stashes and restore the program's B register. A program does not need to disable interrupts to set its own base page.
As far as I can tell, the same is not true of the MAP register. The MAP register requires delicate handling anyway, and is probably best used by programs that ditch the KERNAL entirely. We'll have to think about and document best practices for using MAP with the KERNAL resident.
from mega65-user-guide.
Related Issues (20)
- Unsure about term un-shifted HOT 1
- dirname is listed as filename HOT 1
- No exact description of CTRL+U HOT 1
- Trivial typo Appendix I HOT 1
- Review remarks: User Guide 2nd edition, version 15 September HOT 1
- More than 26 appendices breaks the build
- MODKEY bit description is wrong HOT 1
- ROLQ copy/paste mistake HOT 1
- Xemu keyboard layout picture does not show the Alt key
- FREEZER shortcomings not explained HOT 1
- Improve BLNK register description HOT 1
- Document Flash Slot Boot Selection Logic
- Mega65-book > page 12-9 > 6502 instead of 6510 like C64 CPU HOT 1
- LDQ example text needs fixing HOT 1
- Document the BASIC 65 command 'INFO'
- Document MegaInfo in User's Guide HOT 1
- Mention that >1MB MAP is not reset by the next MAP instruction HOT 5
- Document VIC-IV errata register HOT 1
- Improve "C65 Compatibility ROM Layout" table
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mega65-user-guide.