Hey all,
It's been a long while since posting here. However, recently I have been having some fun with my MSX emulator (BlueMSX) while still having a functional real one, a Philips NMS8245. During this, I wanted a routine that determines correctly and without messing with memory contents the size of the mapper. After having finished it, I thought.. it got pretty nifty! Well, from a perspective of Z80 coding. So I figured, without giving anything away yet, I am curious if anyone could come up with something equal or better. Soooo.... here is the contest!
The goal:
Create a routine that determines the size of the memory mapper in as few bytes as possible. To have the contest stick to the actual detection code, there are some rules that help with comparing the size of the routine and strip it from auxilaries like slot management etc. so only the number of bytes for the detection code is what remains.
Rules:
- Only the fixed sizes ought to be considered: 64K, 128K, 256K, 512KB, 1MB, 2MB and 4MB.
- The routine must return a value that indicates one of the fixed memory mapper sizes in a register.
- No requirement to save registers.
- No requirement to save flags.
- No requirement to handle primary and or secondary slot selection and restore.
- No requirement to test through a specific Z80 page, thus memory mapper register.
- Any memory locations used to test must be restored (no memory corruption)
- Any mapper IO registers must be restored.
- Reading mapper IO registers is not allowed (though would be, on computers supporting it, the fastest way )
So... what would be the prize? Well... that would be the version I cooked up in an assembly file, along with full comments that may have educational value. And ofcourse a big cheers.
So, when you have some time left and feel like a challenge, here it is!
Greetings from Holland,
MagicBox.