Page 1 of 1

SDCC

Posted: Sun Mar 27, 2022 10:28 pm
by @username@
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:

Re: SDCC

Posted: Mon Mar 28, 2022 7:58 am
by Scouter3d
Great News!

Cheers, TOM:0)

Re: SDCC

Posted: Mon Mar 28, 2022 9:09 am
by Mobsie
Yes, itโ€™s great. I patched the mac version and work perfect๐Ÿ‘

Re: SDCC

Posted: Wed Mar 30, 2022 10:21 am
by @username@
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

Re: SDCC

Posted: Wed Mar 30, 2022 6:00 pm
by Mobsie
Cool, works perfect!

Re: SDCC

Posted: Thu Mar 31, 2022 9:29 am
by Scouter3d
Hi,

olc-tetris also works on the MegaSDCart :0)

Cheers, TOM:0)

Re: SDCC

Posted: Wed Apr 05, 2023 12:01 pm
by Mobsie
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.