Jump to content

Recommended Posts

Small update: took the Makefile from the Turmoil project and adapted for my use to convert CC, CH an MP lines directly from the .mag file I made.

I like his idea of using the sourcefile directly to generate a C header file more than doing a feature request for a C header file as export as I now do not need to export again on changes made in my screen, just a save of the main .mag file is sufficient

 

Please improve/comment where needed, else maybe usefull for others.

Next step is actually using that in a first C program to show that screen (but out of time now).

SCREENNAME=ludo_mainscreen.mag
GRAPHICS=graphics.h

$(GRAPHICS): $(SCREENNAME) Makefile
	( echo "static const u8 colorset[] = {" ;\
	gawk -F: -e '$$1=="CC" { if (i>=0 && i<25) { split($$2, a, "|"); printf("0x%x%x,\n", a[1], a[2]) } i++ }' $(SCREENNAME) ;\
	echo "};" ;\
	echo "static const u8 charset[] = {" ;\
	gawk -F: -e '$$1=="CH" { if (i>=0 && i<200) { print gensub(/(..)/,"0x\\1,","g",$$2) } i++ }' $(SCREENNAME) ;\
	echo "};" ;\
	echo "static const u8 mainscreen[] = {" ;\
	gawk -F: -e '$$1=="MP" { split($$2, a, "|"); for( b in a ) { printf("0x%02x,", a[b]); } print "" }' $(SCREENNAME) ;\
	echo "};" ) > [email protected]

 

Edited by xahmol
  • Like 2

Share this post


Link to post
Share on other sites
On 3/17/2021 at 4:02 PM, xahmol said:

Small update: took the Makefile from the Turmoil project and adapted for my use to convert CC, CH an MP lines directly from the .mag file I made.

I like his idea of using the sourcefile directly to generate a C header file more than doing a feature request for a C header file as export as I now do not need to export again on changes made in my screen, just a save of the main .mag file is sufficient

 

Please improve/comment where needed, else maybe usefull for others.

Next step is actually using that in a first C program to show that screen (but out of time now).

SCREENNAME=ludo_mainscreen.mag
GRAPHICS=graphics.h

$(GRAPHICS): $(SCREENNAME) Makefile
	( echo "static const u8 colorset[] = {" ;\
	gawk -F: -e '$$1=="CC" { if (i>=0 && i<25) { split($$2, a, "|"); printf("0x%x%x,\n", a[1], a[2]) } i++ }' $(SCREENNAME) ;\
	echo "};" ;\
	echo "static const u8 charset[] = {" ;\
	gawk -F: -e '$$1=="CH" { if (i>=0 && i<200) { print gensub(/(..)/,"0x\\1,","g",$$2) } i++ }' $(SCREENNAME) ;\
	echo "};" ;\
	echo "static const u8 mainscreen[] = {" ;\
	gawk -F: -e '$$1=="MP" { split($$2, a, "|"); for( b in a ) { printf("0x%02x,", a[b]); } print "" }' $(SCREENNAME) ;\
	echo "};" ) > [email protected]

 

I could relatively easy add a C export option if you're interested - especially if a had an example of the desired output. It would follow the assembly output closely but with C syntax.

  • Like 1

Share this post


Link to post
Share on other sites
7 minutes ago, Asmusr said:

I could relatively easy add a C export option if you're interested - especially if a had an example of the desired output. It would follow the assembly output closely but with C syntax.

Thanks. Will come back on that if I get a first program working, as then I also would know what format I need 😉

But advantage of such a Make script is that there is not even a need to use an export, and to be more flexible in how it is converted in different projects.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...