Hi, especially to fpganoob - thank you so much for this core! The SVI-328 was my first computer, and being able to use it in MiSTer makes me so happy!
However, load times from tape are a little annoying, so I thought I would convert some of those classic Mass Tael games (Ninja, SASA, etc) to cartridges. Ninja loads at $8800 to $c7ff, so I made a dump of the entire RAM in BlueMSX and cut off the first 32k, then I added a CALL $8800 at offset 0 - but no, that didn't work.
How does loading a cartridge work in the SVI core? Looking at other carts, I can't see any obvious load addresses, or even get any obvious clues to where they're placed in RAM space.
Any help would be greatly appreciated!
XiA
Spectravideo 328: Converting a .cas to cart
- lister_of_smeg
- Posts: 54
- Joined: Mon May 25, 2020 3:11 am
- Has thanked: 2 times
- Been thanked: 24 times
Re: Spectravideo 328: Converting a .cas to cart
Carts get mapped at the bottom of the address space ($0000-$7ffff for a 32k cart). They need to start with the opcodes for DI and LD SP,xxxx (F3 31) in order to run.
So you need to copy the data from the cart to RAM. But that's not all - the game makes calls to the BASIC ROM, so that needs to be mapped back in before running the game code. But you can't do that while the PC is still below $8000 or you'll just end up executing random code from the BASIC ROM. So you need to add some code in RAM that performs the final OUT required to map in BASIC and jumps to the game code. As luck would have it the game code starts by immediately zeroing nine bytes starting at $fe74, so we can safely place this code there.
This code should build you a ROM from the cassette data:-
Note that 'ninja.dat' should be just the game data from $8800 to $c7ff, NOT the whole 32k of RAM from $8000-$ffff
So you need to copy the data from the cart to RAM. But that's not all - the game makes calls to the BASIC ROM, so that needs to be mapped back in before running the game code. But you can't do that while the PC is still below $8000 or you'll just end up executing random code from the BASIC ROM. So you need to add some code in RAM that performs the final OUT required to map in BASIC and jumps to the game code. As luck would have it the game code starts by immediately zeroing nine bytes starting at $fe74, so we can safely place this code there.
This code should build you a ROM from the cassette data:-
Code: Select all
org $0000
latch: equ $88
write: equ $8c
read: equ $90
psgreg: equ $07
portb: equ $0f
entry: equ $fe74
dest: equ $8800
stack: equ $f21c
; rom init
di
ld sp, stack
; push game entry point to stack
ld de, dest
push de
; copy data to ram
ld bc, pad-data
ld hl, data
ldir
; set up code in ram to map in basic rom
ld hl, $8cd3 ; out (write), a
ld (entry), hl
ld a, $c9 ; ret
ld (entry+2), a
; select basic rom in lower address space
ld a, psgreg
out (latch), a
ld a, $bf
out (write), a
ld a, portb
out (latch), a
in a, (read)
xor %00000001
; jump to ram
jp entry
; game data from cassette
data: incbin "ninja.dat"
; pad with ones up to 32k
pad: defs $8000-$, $ff
Re: Spectravideo 328: Converting a .cas to cart
Oh, just a quick follow-up question: What assembler is this for? The
bit makes perfect sense, but doesn't match the syntax of my assembler. Thanks again!
XiA
Code: Select all
defs $8000-$, $ff
XiA
- lister_of_smeg
- Posts: 54
- Joined: Mon May 25, 2020 3:11 am
- Has thanked: 2 times
- Been thanked: 24 times
Re: Spectravideo 328: Converting a .cas to cart
I know it works in zasm and z80asm but I've tried to make the syntax and directives as generic as possible so it should work in most Z80 assemblers.XiA wrote: ↑Wed Nov 24, 2021 3:07 pm Oh, just a quick follow-up question: What assembler is this for? Thebit makes perfect sense, but doesn't match the syntax of my assembler. Thanks again!Code: Select all
defs $8000-$, $ff
XiA
Re: Spectravideo 328: Converting a .cas to cart
Just a quick thank you, and to let you know it all worked perfectly here! You are truly a gentleman and a scholar.
Now then, how to convince Games Done Quick to accept SASA speedruns...
XiA
Now then, how to convince Games Done Quick to accept SASA speedruns...
XiA
- LamerDeluxe
- Top Contributor
- Posts: 1239
- Joined: Sun May 24, 2020 10:25 pm
- Has thanked: 887 times
- Been thanked: 284 times
Re: Spectravideo 328: Converting a .cas to cart
I didn't even expect that this would be possible, really cool.