CPCWiki forum

General Category => Programming => Topic started by: arnoldemu on 14:07, 26 September 13

Title: cartridge filesystem
Post by: arnoldemu on 14:07, 26 September 13
I have attached to this post a proof of concept file created using my "cartridge filesystem" tools.

It's a "direct to cartridge" port of Solomon's Key. (I didn't even bother to set the colours/mode for the title screen. Now I just have it working, I'll add the colours from the solomon's key + hack. Can anyone provide + colours for the title screen?

This is an example that should work on gx4000 etc.

This solution involves a little more work than No$Cash solution, but it opens up the full cartridge space, and works on gx4000.

The data is stored on the cart and copied into RAM. It's easier to do it this way. It's "loaded" from the cart - this is why I call it a filesystem. At the start of the cart data you will see the directory at offset &b.

This represents another way to have games on cart.

In the directory:

First byte is cart page (&80 etc)
next 2 bytes are address to read from (pages cart pages into upper rom area) so address is always from &c000 onwards.
next 2 bytes are the length.

and that is it.

So you can see there are 4 files in there.

1 small "boot" program, copied to &4000 and run from there,
1 screen, 1 main file, and another screen.

The "boot" program sets up the hardware state, loads the first to the screen, next to &100, next to the screen and executes the game.

An improved boot program will fade the title screen in and out (with correct colours), load up the main exe with plus colours.

I will post the tools and sources soon so others can use it to make plus games.

EDIT: Added the Plus colours from the Plus hack.
Title: Re: cartridge filesystem
Post by: Trebmint on 16:54, 26 September 13
Certainly works :) and I'll be using this method for sorcery. Good stuff... plus with an extra 16k bank from the cart we can add some nice extra stuff too
Title: Re: cartridge filesystem
Post by: Kris on 19:36, 26 September 13
Works perfectly, that's a great news for Plus users that this tool from noCash is back :)



Edit: I just burn an Eprom with the .CPR tranfer to .BIN file and it doesn't works on real Plus; screen freeze .
Title: Re: cartridge filesystem
Post by: Trebmint on 22:32, 26 September 13
Quote from: Kris on 19:36, 26 September 13
Works perfectly, that's a great news for Plus users that this tool from noCash is back :)



Edit: I just burn an Eprom with the .CPR tranfer to .BIN file and it doesn't works on real Plus; screen freeze .


You mean people can sell an unmodified GX4000 cart of Roland in Time on ebay for £100 haha.... hmmm actually  :P
Title: Re: cartridge filesystem
Post by: Devilmarkus on 23:56, 26 September 13
Would be interesting to know, if the CPR works on a real GX4000.
Did anyone try it yet?

(In my lousy Java emulator it doesnt even startup) :D

In rest: Nice work!

Whoops... Edit: Seen that Kris already tested it... Sad...

Does it also show grey border and black screen on the real thing?
Title: Re: cartridge filesystem
Post by: Kris on 05:33, 27 September 13
I will post a picture of the screen on real Plus asap ;)


EDIT: here is the 1st attempt:

(http://imageshack.us/photo/my-images/59/ywfg.jpg/)



Title: Re: cartridge filesystem
Post by: arnoldemu on 08:51, 27 September 13
Quote from: Kris on 19:36, 26 September 13
Works perfectly, that's a great news for Plus users that this tool from noCash is back :)



Edit: I just burn an Eprom with the .CPR tranfer to .BIN file and it doesn't works on real Plus; screen freeze .
This tool is not nocash's tool. It's my own.

:( Sad it doesn't work on real plus. I didn't test it yet.

BIN file is attached.

notice it's not an exact rom size.

I will make sure it works on plus and gx4000.
Title: Re: cartridge filesystem
Post by: gerald on 09:56, 27 September 13
Quote from: arnoldemu on 08:51, 27 September 13
This tool is not nocash's tool. It's my own.

:( Sad it doesn't work on real plus. I didn't test it yet.

BIN file is attached.

notice it's not an exact rom size.

I will make sure it works on plus and gx4000.

It get stuck at the game title screen waiting for a keypress.
Comparing the behaviour on winape and the real cpc, I notice that no interrupt occurs on the real cpc.
Since the title screen waiting loop (23BA-23D5) rely on data (keyboard line status) updated by interrupt, we get stuck there.

Question is why interrupt does not occur on real HW, and why this is different on emulator
Title: Re: cartridge filesystem
Post by: arnoldemu on 09:57, 27 September 13
Quote from: gerald on 09:56, 27 September 13
It get stuck at the game title screen waiting for a keypress.
Comparing the behaviour on winape and the real cpc, I notice that no interrupt occurs on the real cpc.
Since the title screen waiting loop (23BA-23D5) rely on data (keyboard line status) updated by interrupt, we get stuck there.

Question is why interrupt does not occur on real HW, and why this is different on emulator
great thanks for the analysis. Will fix that (on emu and in the code).

Title: Re: cartridge filesystem
Post by: gerald on 10:06, 27 September 13
Quote from: arnoldemu on 09:57, 27 September 13
great thanks for the analysis. Will fix that (on emu and in the code).
Any idea why there is a different behaviour regarding IRQ ?
Title: Re: cartridge filesystem
Post by: arnoldemu on 13:25, 27 September 13
Quote from: gerald on 10:06, 27 September 13
Any idea why there is a different behaviour regarding IRQ ?
I have worked out what is wrong.

The code does turn on interrupts, but the z80 is in the default interrupt state of IM 0.
The value on the bus supplied by the asic... well it's not going to be ff like it mostly is on CPC, so it jumps to the wrong place and doesn't execute the instructions.
In an emu, chances are the ram is probably filled with zeros, so it just happens to fall through and work.

So I added an "im 1" instruction into the setup code ;)

Will check what happens in my emu because it just happens to work on mine when it shouldn't.

new files attached.

Do these work better?
Title: Re: cartridge filesystem
Post by: gerald on 13:46, 27 September 13
Quote from: arnoldemu on 13:25, 27 September 13
I have worked out what is wrong.

The code does turn on interrupts, but the z80 is in the default interrupt state of IM 0.
The value on the bus supplied by the asic... well it's not going to be ff like it mostly is on CPC, so it jumps to the wrong place and doesn't execute the instructions.
In an emu, chances are the ram is probably filled with zeros, so it just happens to fall through and work.

So I added an "im 1" instruction into the setup code ;)

Will check what happens in my emu because it just happens to work on mine when it shouldn't.

new files attached.

Do these work better?
Now that's better  ;) .

Title: Re: cartridge filesystem
Post by: arnoldemu on 13:50, 27 September 13
So a lesson in cartridge programming  ;)

* When cart is started, cart page 0 is readable in the range &0000-&3fff and &c000-&3fff.
* Interrupts are disabled.
* You can write to the ram under the rom (ideal for transfering data from rom to ram).
* Make sure you set the Z80 interrupt mode to 1 (or 2 if you want that)
* Make sure you setup the PPI and CRTC (otherwise you'll get no keyboard input or screen display).
* Colours will be random, so you need to initialise those.
* Initialise the stack to be within the main 32k ram (&4000-&c000). I put it at &c000 and let it grow down.

EDIT: These are the lessons I learnt and I wanted to share them with you.
Title: Re: cartridge filesystem
Post by: arnoldemu on 17:48, 27 September 13
Quote from: Kris on 05:33, 27 September 13

EDIT: here is the 1st attempt:
Nice pic.

I forgot to setup the border colour.  :o
Title: Re: cartridge filesystem
Post by: Gryzor on 18:15, 27 September 13
Quote from: trebmintGood stuff... plus with an extra 16k bank from the cart we can add some nice extra stuff too

Like a cracktro :D
Title: Re: cartridge filesystem
Post by: gerald on 19:02, 27 September 13
Quote from: Kris on 05:33, 27 September 13
EDIT: here is the 1st attempt:

(http://img59.imageshack.us/img59/9680/ywfg.jpg)

I did not get the same border color, mine was always orange  :o
Title: Re: cartridge filesystem
Post by: Kris on 19:05, 27 September 13
Quote from: gerald on 19:02, 27 September 13
I did not get the same border color, mine was always orange  :o


Do you mean on real CPC+ ?


I'm erasing some eprom at the moment, I wil test the new file in few minutes :)
Title: Re: cartridge filesystem
Post by: Kris on 19:33, 27 September 13
Works perfectly on real machine now!  :D


Have a look:

(http://imageshack.us/photo/my-images/585/xpch.jpg/)



(http://imageshack.us/photo/my-images/194/kn2s.jpg/)



Title: Re: cartridge filesystem
Post by: gerald on 19:35, 27 September 13
Quote from: Kris on 19:05, 27 September 13
Do you mean on real CPC+ ?
Yes, with the 1st version arnoldemu provided. The last one has the correct black border.

Quote from: Kris on 19:05, 27 September 13
I'm erasing some eprom at the moment, I wil test the new file in few minutes :)
erasing, what is this ?  ;)
Title: Re: cartridge filesystem
Post by: Kris on 19:41, 27 September 13
You know what I mean even if my english is not perfect :)
Title: Re: cartridge filesystem
Post by: gerald on 19:42, 27 September 13
Quote from: gerald on 19:02, 27 September 13
I did not get the same border color, mine was always orange  :o
Well, greeninsh orange, I would say  :P
[attachimg=1]

And on a gx4000
[attachimg=2]
Title: Re: cartridge filesystem
Post by: gerald on 19:47, 27 September 13
Quote from: Kris on 19:41, 27 September 13
You know what I mean even if my english is not perfect :)
Your english is quite good, at least as good as mine  :)
Well, in more than 20 years playing with HW, I never erased an eprom.

Title: Re: cartridge filesystem
Post by: Kris on 20:02, 27 September 13
It is the wording used in my software to manage Eproms, so I use it :)  but if a UK native guy can help us to improve our English it could be great :)


Anyway, back to the orignal subject: strange behaviour between both machine....are you using the final .bin file ?
Title: Re: cartridge filesystem
Post by: gerald on 20:17, 27 September 13
Quote from: Kris on 20:02, 27 September 13
It is the wording used in my software to manage Eproms, so I use it :)
And it's the right word.
I am currently using this :
[attachimg=1]
Title: Re: cartridge filesystem
Post by: Kris on 20:19, 27 September 13
OK, now I understand why we have 2 differents results  :-\


HW emulator ?
Title: Re: cartridge filesystem
Post by: gerald on 20:24, 27 September 13
Quote from: Kris on 20:19, 27 September 13
OK, now I understand why we have 2 differents results  :-\


HW emulator ?
Cartridge emulator would be the right word  :D

About the different result (border color), that cannot be explained by that piece of HW.
Title: Re: cartridge filesystem
Post by: Kris on 20:33, 27 September 13
Quote from: gerald on 20:24, 27 September 13

About the different result (border color), that cannot be explained by that piece of HW.


How can you be sure about that as results is OK on real CPC+ ?
Title: Re: cartridge filesystem
Post by: gerald on 20:39, 27 September 13
Quote from: Kris on 20:33, 27 September 13
How can you be sure about that as results is OK on real CPC+ ?
The two screeshot above have been taken on a real CPC+ and a real GX4000 using the same cartridge emulator and the 1st CPR that arnoldemu provided.
With fixed CPR, the border is black as expected.
Title: Re: cartridge filesystem
Post by: Kris on 20:45, 27 September 13
OK, I understand better now....In any case, look like a nice piece of HW. ACID emulation should be the most difficult isn't it ?
Title: Re: cartridge filesystem
Post by: gerald on 20:57, 27 September 13
Quote from: Kris on 20:45, 27 September 13
OK, I understand better now....In any case, look like a nice piece of HW. ACID emulation should be the most difficult isn't it ?
Well, the ACID part is the easiest, thanks to nocash work.
This proto is done in 3 parts
-  the cartridge itself, that use a PLD for emulating the acid, and can hold a proper eprom.
-  the eprom emulator, done with a RAM and a PLD for multiplexing access from CPC and access from the uC that program the RAM
-  a custom uC card that handle the transfert from a uSD card to the RAM and can be connected to a PC through USB

In its current state, the system still rely on a PC connected though USB for selecting the cartridge to use, but the goal is to be able to have all controlled from the CPC.
Title: Re: cartridge filesystem
Post by: Kris on 21:00, 27 September 13
Impressive work ! Sounds good for CPCplus users :D
Congratulations because there are not so much new HW project .

Title: Re: cartridge filesystem
Post by: gerald on 21:10, 27 September 13
I mainly hope that once the HW will be available for everyone  ::) we will see more cartridge game/demo.
Mais ne vendons pas la peau de l'ours avant de l'avoir tué, my current problem is that half the existing cartridges game are randomly crashing >:(
Title: Re: cartridge filesystem
Post by: Kris on 21:33, 27 September 13
If you are in "debugging" phase then your project is on the good way.....
Title: Re: cartridge filesystem
Post by: arnoldemu on 09:44, 28 September 13
Quote from: gerald on 19:02, 27 September 13
I did not get the same border color, mine was always orange  :o
Looking at the code, the border is not initialised, this includes with the second release.
So the border colour appears to be random at start up - official docs says this:
"The border colour will be undefined at power-on reset "

so if you got black. Well done ! :)

I will make another release soon with some colour fades and colours for the title screen.
My aim is to get this working as well as I can so I can give guidance to others for programming games and be sure my filesystem works correctly on gx4000 and all plus.

A modified filesystem will be useable on ctc-ay. (I have one of these now so I can make carts for cpc too ! :)


My final plan is more to release *new* plus games, especially my own games that have plus features added. Eventually one game which is written to take advantage of most of the plus hardware.
Title: Re: cartridge filesystem
Post by: arnoldemu on 09:45, 28 September 13
@gerald: Does it work fine on gx4000?
I know the gx4000 will be slightly slower (or faster???).
Title: Re: cartridge filesystem
Post by: arnoldemu on 09:46, 28 September 13
Quote from: gerald on 21:10, 27 September 13
I mainly hope that once the HW will be available for everyone  ::) we will see more cartridge game/demo.
Mais ne vendons pas la peau de l'ours avant de l'avoir tué, my current problem is that half the existing cartridges game are randomly crashing >:(
@ gerald: This hardware is nice. It would be good to see more hardware solutions so new games can be released.

I am also to see cartridge versions of existing games with plus enhancements.
Title: Re: cartridge filesystem
Post by: gerald on 10:36, 28 September 13
Quote from: arnoldemu on 09:45, 28 September 13
@gerald: Does it work fine on gx4000?
I know the gx4000 will be slightly slower (or faster???).
Yes, it works on gx4000. Regarding speed, my GX4000 has a 39.9MHz oscillator so it's 0.25% slower than a CPC which use a 40MHz one.

Quote from: arnoldemu on 09:46, 28 September 13
I am also to see cartridge versions of existing games with plus enhancements.
Maybe also true cartridge games, ie using ROM for data and code exec as much as possible and leave RAM for variable, screen or auto-modifing code.
Title: Re: cartridge filesystem
Post by: arnoldemu on 17:31, 30 December 13
I have released the source and tools for my cartridge filesystem:

http://www.cpctech.org.uk/download/cart_setup.zip (http://www.cpctech.org.uk/download/cart_setup.zip)

fs contains the directory for the filesystem, the tools and the code to load the data with instructions.
The tools can be built on linux. I don't have a windows exe in there yet.

single shows how you can create a single binary and download that into ram and execute that.

absolute is a work in progress because there isn't an example. The romInject tool can be used to inject files in a place of choice. In this way you can plan where code/data/music will go and inject the data to that position with this tool, then in your code you can enable specific cartridge pages and do as you want.

These tools need programming knowledge!

I have tried to explain how they work and what they do. Feedback is welcome. I will update them again especially when I start to use them more.

EDIT: absolute example has been updated.

If you use linux, you can make each tool then copy it into a binary directory of your choice and access the tools through shell scripts.

This now shows how you can put data into a cartridge in various ways.

remember, when writing cartridge games you must do everything yourself (drawing text, sprites, screen setup).
The examples show basic hardware setup, and in my other examples I show how to draw sprites so using all my examples together you should be able to have a go at making a cart game now.
Powered by SMFPacks Menu Editor Mod