Progress

Talk about programming CreatiVision (except games programming). Projects of homebrew hardware are also welcome.
User avatar
@username@
Posts: 320
Joined: Tue Oct 22, 2013 6:59 pm
Location: Scotland

Progress

Post by @username@ » Mon Nov 25, 2013 10:37 am

Hi,

Just thought I'd share our progress so far.

Here's a hello world, from C.
You do not have the required permissions to view the files attached to this post.
User avatar
Mobsie
Posts: 708
Joined: Fri Jun 13, 2008 10:38 am
Location: Weinheim, Germany

Re: Progress

Post by Mobsie » Mon Nov 25, 2013 1:36 pm

yes, is a BIG step i CreatiVison develop tools, i long time want this solution for some friends.
I finish yesterday the actual CC65 setup and i am in a tetris game now just for fun :D Also i make some little routines for VDP handle.
User avatar
Mobsie
Posts: 708
Joined: Fri Jun 13, 2008 10:38 am
Location: Weinheim, Germany

Re: Progress

Post by Mobsie » Sun Dec 01, 2013 8:56 am

For me i time to thank @username@ and Oliver Schmidt to bring CreatiVision support to the CC65 C-Compiler.
I have some friends who now use this tool to begin write some interesting stuff. The code is really fast (thanks our 2 MHZ CPU) and compared for example with the TI-99/4a we have more free RAM left.
Very soon, i can say because i know the tools that are in work, we have greater tools than the ColecoVision community AND THAT is amazing.
User avatar
MADrigal
Site Admin
Posts: 1189
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: Progress

Post by MADrigal » Sun Dec 01, 2013 10:09 am

I have to admit that I'm not familiar with the CC65 development environment.
@username@: are you adding CreatiVision libraries to the compiler? Does this mean that there's specific functions to drive the VDP, PIA and SPU in the C compiler?
I definitely need to give it a try! ;)
User avatar
Mobsie
Posts: 708
Joined: Fri Jun 13, 2008 10:38 am
Location: Weinheim, Germany

Re: Progress

Post by Mobsie » Sun Dec 01, 2013 10:24 am

Not only the specific functions ALSO CreatiVision as target. So you can easy compile with cl65 -t creativision source.c
On the library functions we work together, but as he is the fastest developer i have ever seen (and i know a lot) maybe he is always faster finish then i.
C on the 6502 was never a problem, if you look at the cc65 NES example Games you will be shocked.
User avatar
MADrigal
Site Admin
Posts: 1189
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: Progress

Post by MADrigal » Sun Dec 01, 2013 10:31 am

so what happens when i compile the C listing?

does the compiler build a ROM with pre-set vectors, memory map, etc. in order to make it fully creativision compatible?
User avatar
Mobsie
Posts: 708
Joined: Fri Jun 13, 2008 10:38 am
Location: Weinheim, Germany

Re: Progress

Post by Mobsie » Sun Dec 01, 2013 11:04 am

YES of course this was the hard-part what @username@ and Oliver done.
-> The CreatiVision as target.
When you compile with cl65, the compiler and linker make a ready to use cart WITH ALL vectors, the needed irq, ram and zero-page.
Ready to use!
User avatar
@username@
Posts: 320
Joined: Tue Oct 22, 2013 6:59 pm
Location: Scotland

Re: Progress

Post by @username@ » Sun Dec 01, 2013 4:02 pm

Introducing CC65 for the Creativision - *OFFICIAL*

Thanks to the hard work of Oliver Schmidt, current maintainer of CC65, we have a working C development environment.

This is not to say that it's complete - there's a way to go, but there is enough to get you going!

How to setup on Windows

1) Download the required packages

GNU Make http://sourceforge.net/projects/gnuwin3 ... p/download
GNU Make Dependencies http://sourceforge.net/projects/gnuwin3 ... p/download
CC65 Sources https://github.com/oliverschmidt/cc65/a ... master.zip
CC65 Windows Binaries http://sourceforge.net/projects/cc65/fi ... p/download
CC65 Creativision WIP Attached to this post
CC65 Creativision Samples Attached to this post

2) Create a root directory for your environment. This guide will use C:\CC65. *DO NOT USE SPACES IN THE PATH NAME*

3) Extract CC65 sources. You now have C:\CC65\cc65-master

3) Extract CC65 Windows Binaries to C:\CC65\cc65-master\drop. Copy or move the executable files from drop to C:\CC65\cc65-master\bin.

4) Extract the CC65 Creativision WIP to C:\CC65\cc65-master. It's ok to overwite for now.

5) Extract GNU Make to C:\CC65\cc65-master\gnu.

6) Extract GNU Make Dependencies to C:\Cc65\cc65-master\gnu.

5) OK - If you're on Windows Vista or later, you need to work in an elevated console. Use 'Run as Administrator', or Win+R -> cmd.exe -> CTRL-SHIFT-ENTER.
Navigate to C:\CC65\cc65-master. Type C:\CC65\cc65-master\gnu\bin\make lib.*PUT THE KETTLE ON* - enjoy a beverage while you wait :)

If you get here - congratulations! - you're ready to start coding for your Creativision in C, or Assembler if you prefer, CA65 is pretty good.

Compiling your first program

Ok, extract the example to C:\CC65\cc65-master\cvexamples. Go to cvhello. Type

Code: Select all

..\bin\cl65 -t creativision hello.c -o cart.bin -m cart.map
That's it! You have your very own hello world :). Wasn't that cool? ... and so much easier than you thought.

The other example is a VGM player, not world class, but helps to demonstrate assembling and linking without the automation.

Go to cvvgmplayer. Type

Code: Select all

..\..\bin\cc65 -t creativision vgmplay.c 
..\..\bin\ca65 -t creativision vgmplay.s
..\..\bin\ca65 -t creativision vgm_support.s
..\..\bin\ld65 -t creativision -o cart.bin -t creativision vgmplay.o vgm_support.o creativision.lib
If all went well, load up your favourite emulator (there's a reasonable one at http://sourceforge.net/projects/creativisionemulator) and listen to the music!

The Executive Decisions We (Myself and Mobsie) Made On Your Behalf

As all C environments need some lines in the sand, we have a default setup of.

4K Cartridge at $B000. This can be extended with creativision.cfg, but will always write linearly. I'll be writing a quick utility to swap for emulators where needed later.
IRQ is BIOS default. We chose this as it makes it simple for the more adventurous to either hook or replace by using the vectors at $1FA(REPLACE) or $1FC(HOOK).
Copyright Screen F808 always called. Again, we chose this as it sets the Creativision to a known stable condition.
VDP is set to Graphics Mode 1. Again, we had to choose something, and we liked this.
BIOS has the lower 32 bytes of zeropage. This ensures that you can call BIOS functions, and they will still work. An example is the IRQ, sets inputs etc, as you expect.

Some extra utils

I've also attached a couple of utils you may find useful. The disassembler is not the best, but will comment and document your cart as best it can.

What now?

For me, there's a lot of cleaning up and getting the code into the official github.
For you, I hope, hours of fun porting whatever C game you like to the Creativision.

Remember that the machine is restricted in dynamic memory, so if it don't change, make sure it's declared const!

Any questions, please ask!

Thanks for reading this far.
You do not have the required permissions to view the files attached to this post.
Last edited by @username@ on Mon Dec 02, 2013 10:44 am, edited 1 time in total.
User avatar
MADrigal
Site Admin
Posts: 1189
Joined: Sun Sep 15, 2013 1:00 pm
Contact:

Re: Progress

Post by MADrigal » Sun Dec 01, 2013 8:58 pm

Really impressive! Need some time to test everything! :)
User avatar
@username@
Posts: 320
Joined: Tue Oct 22, 2013 6:59 pm
Location: Scotland

Re: Progress

Post by @username@ » Sun Dec 01, 2013 10:45 pm

MADrigal wrote:@username@: are you adding CreatiVision libraries to the compiler? Does this mean that there's specific functions to drive the VDP, PIA and SPU in the C compiler?
For the moment, we have very simplistic functions. One of the things that makes the CV easy to program is that it's memory mapped. Also, we have not abandoned BIOS, so everything is managed and stable, The PSG really needs only one function, which already exists psg_outb. The BIOS play sound is also available as bios_playsound, and follows the format of BASIC and the commercial carts. I've attached the C source which is a direct translation from the BASIC manual SOUND function.

The intention is to add very basic JOY(X) functions. Keyboard is already done with cgetch.

Next week we'll look at the VDP, but as it's very simple to use, most likely will only have SetMODE(x).

Long term, we can probably mimic a lot of the functions from the Coleco development libraries, which will perhaps bring on board even more C programmers from that community.

Of course, this will all need to be documented, which I always leave till last :)

In the meantime, both myself and mobsie will try to help out if you hit any problems.

Code: Select all

/* Rough demo
 * BASIC 83 SOUND song demo
 * Song from Chapter 13, page 104
 */
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <creativision.h>

static const char Text[] = "BIOS SOUNDS";
static const unsigned char notes[] = 
{ 
 (26<<3)+7, (21<<3)+7, (14<<3)+7,
 (30<<3)+3, (25<<3)+3, (18<<3)+3,
 (28<<3)+3, (23<<3)+3, (16<<3)+3,
 (26<<3)+3, (21<<3)+3, (14<<3)+3,
 (21<<3)+5, (16<<3)+5, ( 9<<3)+5,
 (28<<3)+3, (23<<3)+3, (16<<3)+3,
 (30<<3)+3, (25<<3)+3, (18<<3)+3,
 (26<<3)+3, (21<<3)+3, (14<<3)+3,
 0x10, /*Tempo / time between updates. 16 Seems ok for BASIC speed. */
};

int main( void )
{
	unsigned char XSize, YSize;

	clrscr();

	screensize(&XSize, &YSize);

	cputc(CH_ULCORNER);
	chline(XSize - 2);
	cputc(CH_URCORNER);

	cvlinexy(0,1,YSize-2);

	cputc(CH_LLCORNER);
	chline(XSize-2);
	cputc(CH_LRCORNER);

	cvlinexy(XSize-1, 1, YSize - 2);

	gotoxy((XSize - strlen(Text)) / 2, YSize / 2);
	cprintf("%s", Text);
	
	while (1)
	{
		bios_playsound((void *)notes,25); /* Go play it */
	}

	return 0;
}
You do not have the required permissions to view the files attached to this post.
Post Reply