SDCC

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

SDCC

Post by @username@ » Sun Mar 27, 2022 10:28 pm

Great news! SDCC 4.2.0 has resurrected the MOS6502 port.

Unfortunately, there's a few gotchas
  • DATA segment has been hard coded to 0x8000
  • --data-loc switch only changes zero page (ZP)
  • crt0.s has GSINIT before CODE section
  • Changing vectors from 0xfffa, to say 0xbffa causes the binary to be the wrong size (short 8-16 bytes)!
  • The release binaries for linux need an old verion of GLIBC - so rebuilding is usually the only option
To move the DATA segment to begin at 0x204, the src/mos6502/main.c needs to be changed with the following patch

Code: Select all

--- sdcc-4.2.0/src/mos6502/main.c	2022-02-24 20:52:17.000000000 +0000
+++ sdcc-4.2.0-patched/src/mos6502/main.c	2022-03-26 14:44:16.222182250 +0000
@@ -181,7 +181,11 @@
 {
   options.code_loc = 0x200;
   options.data_loc = 0x20;	/* zero page */
+#if 0
   options.xdata_loc = 0x8000;   /* 0 means immediately following data */
+#else
+  options.xdata_loc = 0x204;	/* Vtech creatiVision data */
+#endif
   options.stack_loc = 0x1ff;
 
   options.omitFramePtr = 1;     /* no frame pointer (we use SP */
Pre-requisites for linux build (in my case debian) are bison flex libboost-dev libz-dev gputils texinfo
Then the usual ./configure;make;make install.

For Windows x64, you can patch the sdcc.exe binary at these offsets

Code: Select all

003058DD: 00 04
003058DE: 80 02
For MacOS x64, you can patch sdcc binary at these offsets

Code: Select all

00329B95: 00 04
00329B96: 80 02
Attached is a simple tune player, which includes a working crt0.s and Makefile.

There's also the source to genrom.c which will convert the output .rom to a CV compatible .bin, which you need to compile on your platform.
Simple gcc -O2 genrom.c -o genrom

That's my Sunday done :lol:
You do not have the required permissions to view the files attached to this post.
User avatar
Scouter3d
Posts: 646
Joined: Mon Jun 28, 2010 7:02 am
Location: Wien
Contact:

Re: SDCC

Post by Scouter3d » Mon Mar 28, 2022 7:58 am

Great News!

Cheers, TOM:0)
User avatar
Mobsie
Posts: 708
Joined: Fri Jun 13, 2008 10:38 am
Location: Weinheim, Germany

Re: SDCC

Post by Mobsie » Mon Mar 28, 2022 9:09 am

Yes, it’s great. I patched the mac version and work perfect👍
User avatar
@username@
Posts: 320
Joined: Tue Oct 22, 2013 6:59 pm
Location: Scotland

Re: SDCC

Post by @username@ » Wed Mar 30, 2022 10:21 am

Here's a quick hack of One Lone Coder's Tetris example.

I never thought I'd say this - but ported from Windows 10 to creatiVision - wtf!

Tested on Salora Manager

Also includes updated genrom, which adds -f named isr function and -r vdpregs.

Enjoy
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: SDCC

Post by Mobsie » Wed Mar 30, 2022 6:00 pm

Cool, works perfect!
User avatar
Scouter3d
Posts: 646
Joined: Mon Jun 28, 2010 7:02 am
Location: Wien
Contact:

Re: SDCC

Post by Scouter3d » Thu Mar 31, 2022 9:29 am

Hi,

olc-tetris also works on the MegaSDCart :0)

Cheers, TOM:0)
User avatar
Mobsie
Posts: 708
Joined: Fri Jun 13, 2008 10:38 am
Location: Weinheim, Germany

Re: SDCC

Post by Mobsie » Wed Apr 05, 2023 12:01 pm

I really like the SDCC Setup. The argument passing and the code is much better then cc65 for example. I am not a fan of all this makefiles etc. but I try to port some functions to sdcc.
Post Reply