Hallo Besucher, der Thread wurde 2,3k mal aufgerufen und enthält 6 Antworten

letzter Beitrag von esemef am

Calling c65 kernal disk i/o functions from assembly

  • I've got machine code that is loaded after a basic stub of 0 BANK0:SYS8209 that I ported from c64.


    The first thing it does is try to read the directory, but whatever I've tried crashes in the call to OPEN ($0xffc0) & I have no idea why.


    The code is basically the same as what is in c128 basic directory command & I've successfully run the same code on c16 & c128, I can't spot any relevant difference between c128 & c65 directory command. The c65 directory command works from a basic prompt.


    I've tried various ways of paging the kernal back in, which often works for CHROUT ($ffd2) but fails when doing disk i/o


    Currently I've stashed some code <$2000 that sets to kernal bank and calls the kernal and restores bank 0 afterwards.

    I'm calling SETBANK ($ff6b) with A/X = 0 like when I call $ff68 on the c128.


    I'm struggling to find examples whether it's even possible, most people seem to be writing a lot of their code in BASIC.


    I'm using xemu (tried xmega65 & xc65) with rom V0.9B.911001, I don't know if the problem is caused by either of these.


    Any help is greatly appreciated.

  • You need to set the memory banking more manually on the C65 as far as I am aware:


    0. Make sure to disable interrupts with SEI

    1. Use MAP instruction to set banking of RAM as required.

    2. Use $D030 to bank in standard ROM pieces as required.

    3. Use $01 to bank in IO and/or C64 ROM pieces as required.


    It is indeed quite frustrating that the BANK 0 command gives a bank with only RAM, IIRC, with no IO mapped, which means you have to do a lot in the assembly code yourself.


    There is a c64toc64wrapper or similarly named program in the github.com/mega65/mega65-tools repository, that implements an example of doing this, IIRC.


    LG

    Paul.

  • Actually, there is not really such a thing as "C64 mode".


    Unlike the C128, all of the MEGA65 features are available in its C64 configuration. And I mean all of them. Full speed, full RAM access, all VIC-IV features, all 4 SIDs, enhanced opcodes, 32-bit-addressing, everything.


    The only difference is that C64 starts in a more developer friendly memory configuration and has the C64 kernal banked in.


    Of course you can try remain in C65 configuration and call C65 kernal functions, but keep in mind that it's a hell of a lot more complicated and there's really no benefit, as both C64 and C65 kernal call the same CBDOS routines in the end.


    In fact, I suspect, someday the C65 'closed ROM' will vanish into oblivion anyway, as soon as the Open ROM evolves and gets a nice programming language.


    (yep, I completely understand why one would want to 'remain' in C65 mode... once I thought so too ;))

  • Yeah, I've already used 80 column text mode in c64 mode on c65/mega65 and activated 3.5mhz/40mhz respectively. But there are some benefit to staying in c65 kernal mode, the screen editor is 80 column compatible for a start & so you don't have to do your own.


    And I don't mind it being complicated, what I'm struggling with is it that it seems impossible.


    If there is no way to call c65 kernal disk routines from machine code in ram, no matter how complicated it is (I'll take any number of secret pokes, map and jumping through hoops into consideration as I'm using a code generator already), then so be it.


    But if it's possible then even if c65 mode disappears from mega65 when using openroms then I'm still interested for actual c65s.


    I'm going to do a cbmii p500 port as well, they really messed up the bankswitching on that.

  • I don't have one, but vice supports it and I can visit a museum a couple of hours away when the code is ready to test (they might be glad of some software for it).


    The banking is certainly fun, I did a demo with a font and raster irq and scrolling for a compo.


    I'm not sure if xemu has a debugger, but I don't know how to use it and miss the vice or mame debugger when doing c65/mega65 stuff.