Login
Back to forumReply to this topicGo to last reply

Posted By

seff
on 2024-03-04
02:29:51
 Cartridge Challenge :: New 3+1 ROM

I want to do a proof a concept and call Kernal and Basic routines from within a 32k cartridge.
This will be the first step to create a new 3+1 ROM based on SpeedScript and SpeedCalc that will run from ROM and utilize all available RAM.
For example, the built-in 3+1 cartridge copies ROM to $1000 to $7000. It is no surprise that you have only 99 lines left available in the word processor.
I studied all possible cartridges available and wrote a new 3+1/3+1 Cartridge Challenge GitHub as follows:

;--------------------------------------------------
; cold_start
;--------------------------------------------------
cold_start:

lda CURBNK ; Get current ROM bank (to provide runnability in any slots)
and #$03 ; Use our ROM in low bank only and KERNAL in high
tax
stx CURBNK
sta $fdd0,x
ldx #< cart_message ; Print message below Basic header
ldy #> cart_message
jsr print_text ; print message
jsr def_key ; register F1 key
jsr def_sys ; register sys routine
; ROM charset in hi memory
rts

;--------------------------------------------------
; warm_start
;--------------------------------------------------
warm_start:
jsr print_intro
;jsr read_textl
jmp *

I enclose the CHROUT call in the LONG call:

;--------------------------------------------------
; print_textl, xy=pointer, 0
;--------------------------------------------------
print_textl:
stx IMPARM ; set pointer
sty IMPARM+1
ldy #0 ; we're pointing to 1st byte of string
-
lda (IMPARM),y ; loop to output string
beq +

;jsr CHROUT ; do a long call later
sta FETARG ; store acc
lda #$00 ; status register=0
sta FETSRG
lda #< CHROUT
sta LNGJMP
lda #> CHROUT
sta LNGJMP+1
lda CURBNK
ldx #$00 ; bank in Basic/Kernal
jsr LONG ; jsr CHROUT via long

iny
bne -
inc IMPARM+1
bne - ; this will never be 0
+ rts

But it works only partially. I get a few lines of text printed now and then:



So I failed. I did not achieve my objective to run code in a 32k ROM and be able to call both Kernal and Basic routines.
It is not simple and that's why so many developers resorted to copying ROM to RAM unfortunately.

I would be really grateful if somebody could guide me to a successful proof of concept.

Thank you very much Plus/4 World colleagues!
Seff

Posted By

SukkoPera
on 2024-02-28
05:52:07
 Re: Cartridge Challenge :: New 3+1 ROM

A bit OT, but I was wondering if anyone has ever attempted at creating a 64 kB cart program, by using both cartridge slots (C1_LO/HI and C2_LO/HI). I have a hardware design that can map all those to a single 64 kB EPROM so it would be interesting to have some software taking advantage of that.

Posted By

Harry Potter
on 2024-02-28
06:21:17
 Re: Cartridge Challenge :: New 3+1 ROM

Try copying code to Low memory to switch out the cartridge ROM, do the access, switch back in the cartridge ROM then return to the caller. BTW, I just finished reading your post. I encountered the same problem while trying a 32k cartridge setup for cc65. sad I've only been able to have a setup where only the low 16k is visible and extra code accesses the high 16k for data. For those here who use cc65 to program Plus4/C16 cartridges, I have two memory configurations for cartridges: one for 16k and one for 32k as described. They both load into C1. If you want, I can post a link to them.

Posted By

seff
on 2024-02-28
07:55:12
 Re: Cartridge Challenge :: New 3+1 ROM

It works if I change the config to: $01: $FDD1 (3+1)/Kernal (CHROUT, but not GETIN).
But it does not serve my purpose.
I want to execute code in 3+1 Hi and also want to call Basic routines, because SpeedCalc relies on Basic calls/functions.

@SukkoPera
Yes, it can be written, but it will work like a typical copy ROM to RAM & execute gamecart cartridge.
I would write a copy routine with a few parameters and copy the ROM block to RAM, see Cartridge Explorer.

Posted By

seff
on 2024-03-04
02:27:23
 Re: Cartridge Challenge :: New 3+1 ROM

I made it.

You need to wrap your Basic/Kernal calls as follows:

;--------------------------------------------------
; rom_getin
;--------------------------------------------------
rom_getin stx zpd2 ; store x
sty zpd3 ; store y
lda #$00 ; status register=0
sta FETSRG
lda #< GETIN
sta LNGJMP
lda #> GETIN
sta LNGJMP+1
lda CURBNK
ldx #$00 ; bank in Basic/Kernal
jsr LONG ; jsr GETIN via long
ldx zpd2 ; retrive x
ldy zpd3 ; retrive y
lda FETARG ; retrive acc
rts

One needs to pay attention to LONG input/output arguments and function arguments.

FETARG = $05f2
FETXRG = $05f3
FETSRG = $05f4

I did not change the interrupt routine at all and everything works like a charm.

Now, can you imagine the potential?

Why didn't David W Johnson program the 3-Plus-1 package that way? In fact, the 3-Plus-1 software package is pretty good if only you could have all 64 kb RAM memory available... Now imagine game cartridges with 32/64 kb ROM and 16 kb RAM.
You could keep your video RAM and charset in RAM..., double buffering, pre-computed soft sprites, special effects... on C16, C116...

Too bad that developers did not use this feature.

Posted By

MMS
on 2024-03-03
11:32:37
 Re: Cartridge Challenge :: New 3+1 ROM

This is a great project, and also clarified the 100 lines limitations.
I was also shocked to learned this limitation, as the C64 Easyscript, loaded from floppy (took RAM space!) allowed several thousand lines (logically, as it used much more RAM). I am not surprised the testers gave such a low score for a "word processor" can make only short notes.

I agree the potentials are really huge. Especially for the mentioned C16 games. Unfortunately (contrary to VIC-20) the cartridges were rather rare, I think mainly because they did not provide any extra to the "cheap" cassette version. But in the scenario you showed us now, they could release fantastic big games with a lot of screens and story, as you could store all of them in external ROM, but I think it worked in this way on VIC-20, as it had only 4KB RAM).



Back to topReply to this topic


Copyright © Plus/4 World Team, 2001-2024