Login
Back to forumReply to this topicGo to last reply

Posted By

ChrisM
on 2019-01-04
08:46:45
 JMP to machine code copied from cartridge ROM?

Hi,

I'm a newbie to programming on C16/Plus4 and I've received a couple cartridge PCBs in the post today so I made a test cartridge ROM which copies data stored at $8400(onwards) to $1001(onwards). There is a BASIC SYS call at $1001 to run the machine code program that follows it. If I RTS from the cartridge program, typing RUN at the command will execute the program code without issue. However. instead of using RTS, I'd like to jump directly to the machine code at $101D after I copy the data. Though when I do this, the code at $1001 appears corrupted/moved? (when looking at the memory monitor in VICE). I assume this is a banking issue? Can anyone clarify where I am going wrong?

Thanks!

Posted By

SVS
on 2019-01-04
09:56:06
 Re: JMP to machine code copied from cartridge ROM?

Hi ChrisM,
you wrote that you just copy the memory values from cartridge to RAM. Then you execute it by a SYS (from RAM). Pls clarify what is the RTS executing from cartridge.

Posted By

ChrisM
on 2019-01-04
10:24:57
 Re: JMP to machine code copied from cartridge ROM?

Hi SVS,

For testing, I've taken an existing PRG file (Zolyx) and copied that to its original location of $1001.

When the cartridge boots, it reads the header which JMPs to the code which copies that data.

Once I'm done copying, I'd like to JMP into the copied code and run the game. However, when I do this, I get corrupt data. If I RTS from the cartridge code, I am then able to successfully boot Zolyx with SYS 4125 ($101D).

I assume it's a bankswitching issue but I can't seem to solve it so far. Thanks for any suggestions!

Posted By

SVS
on 2019-01-04
12:04:07
 Re: JMP to machine code copied from cartridge ROM?

Try to use the Banking Routines located from $FC00 to $FCFF of the O.S. These subroutines are always visible by any memory configuration so that you don't need to switch the bank# of the cartridge.
In particular try $FC89 (Long Jump).
See more info on Ultimate Map

Posted By

ChrisM
on 2019-01-04
19:02:54
 Re: JMP to machine code copied from cartridge ROM?

Thanks, the ROM map is very helpful. Would this be correct to jump to $3100 from cartridge ROM?

;set jump pos
lda #$00
sta $05f0
lda #$31
sta $05f1

;long jump
jmp $FC89

Posted By

SVS
on 2019-01-06
09:37:06
 Re: JMP to machine code copied from cartridge ROM?

You should set .X with bank# (00) before to JMP $FC89.
If the routine needs values of registers, you can set them at: $05F2... $05F4.
A last tip, set SEI before to run, and CLI after it.

Let me know if it works wink



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024. Support Plus/4 World on Patreon