dogen
Deep Blooper
Posts: 30
|
Post by dogen on Apr 11, 2022 2:51:41 GMT
Yo, first real post here. Some here have probably seen me in various discords. I figure I'm more likely to post here than anywhere else for now, so my first post will be here. Anyway I'm making a small PC Engine demo in HuC, and it's been very fun so far. If it gets finished to my satisfaction I will post it on the board.
|
|
dogen
Deep Blooper
Posts: 30
|
Post by dogen on Apr 11, 2022 21:05:17 GMT
|
|
|
Post by elmer on Apr 11, 2022 21:56:40 GMT
Actually, I do have a question. How do I enable supergrafx functionality in HuC? I've tried a handful of things but calls to the sgx library don't seem to work. Have you taken a look at HuC's SGX example project? That compiles and works, so I'm guessing that whatever it does in the Makefile would be the advice to follow.
|
|
dogen
Deep Blooper
Posts: 30
|
Post by dogen on Apr 11, 2022 22:52:10 GMT
Actually, I do have a question. How do I enable supergrafx functionality in HuC? I've tried a handful of things but calls to the sgx library don't seem to work. Have you taken a look at HuC's SGX example project? That compiles and works, so I'm guessing that whatever it does in the Makefile would be the advice to follow. Yeah I tried to compile it and got the same or similar error... I'm guessing it's a path or environment variable problem. I've always had some difficulty with those. I'll have to go back make sure I have those right.
|
|
|
Post by elmer on Apr 12, 2022 0:12:43 GMT
I'm guessing it's a path or environment variable problem. I've always had some difficulty with those. Ah ... have you set PCE_INCLUDE to tell the compiler/assembler where the libraries are?
|
|
dogen
Deep Blooper
Posts: 30
|
Post by dogen on Apr 12, 2022 1:15:40 GMT
Well, I have PCE_INCLUDE also pointing to C:\huc\include\pce now... which is where the sgx.h file is, and still no luck. I also tried $PCE_INCLUDE which I'd seen suggested somewhere. and if you're wondering how I had this working in the first place I've been using a script you posted to help noobs like me out 1.5 hours later of messing with this and still can't figure it out.. which is how this usually goes. I can clearly get PCE_INCLUDE to mean something ... because my graphics get seen when I put them in the corresponding folder(s). I have PCE_INCLUDE set to C:\huc\include\pce along with a folder with graphics files because including them in the folder with my c file didn't work.
|
|
|
Post by elmer on Apr 12, 2022 13:39:55 GMT
Are you giving HuC the "-sgx" flag on the command-line to tell it to enable SGX support?
|
|
dogen
Deep Blooper
Posts: 30
|
Post by dogen on Apr 12, 2022 13:59:24 GMT
YES!
So, yesterday I did try the -sgx flag, but I hadn't been able to get running huc -myfile.c actually working in the first place (don't I just need c:\huc\bin in path, and PCE_INCLUDE properly set though?). But if I add -sgx to that script I've been using it works.
|
|
|
Post by elmer on Apr 12, 2022 14:28:54 GMT
I'm glad that you've got it working and can move forward! Yep, in the batch-file build scripts that I've written for other folk, I just set PCE_INCLUDE and add huc\bin\ to the path, and everything seems to work ... as long as you pass the correct parameters to huc.exe on its command line.
|
|
|
Post by 0x8bitdev on Apr 13, 2022 10:56:42 GMT
How can I do such data binding with the HuC?
struct some_data_struct { const unsigned short* a; unsigned short b; unsigned char c; };
const unsigned short arr[] = { 1, 2, 3, 4, 5 };
const struct some_data_struct real_data = { arr, 100, 200 };
After compiling I got the following error:
Error(s) ;error: main.c(21) ;const struct some_data_struct real_data = { arr, 100, 200 }; ; ^ ;****** syntax error ****** ;error: main.c(21) ;const struct some_data_struct real_data = { arr, 100, 200 }; ; ^ ;****** syntax error ******
|
|
|
Post by elmer on Apr 13, 2022 15:16:45 GMT
How can I do such data binding with the HuC? I'm not sure that it's possible in the way that you appear to want, but perhaps someone with more practical HuC experience than me knows of a way. Please remember, HuC != standard-C, and doesn't aim to be. It's a very cut-down C compiler. I think that you can initialize individual variables and arrays, but structure initialization appears to have problems. Both of these alternatives seems to compile OK ... const unsigned short* a = arr; const unsigned short* a[] = { arr };
Also, please understand that using pointers in HuC can be a bit challenging, because a plain pointer will only let you access memory that is currently mapped, and so only applies to data in RAM, or data in the CONST_BANK. <EDIT> It absolutely doesn't help you with your problem, but FWIW, KickC does correctly compile the code that you're trying to use.
|
|
|
Post by 0x8bitdev on Apr 13, 2022 15:43:08 GMT
elmer Thanks for your answer! I'm just trying to make a tool generated code and avoid inline assembly. Will try to find another way... maybe parallel arrays...
|
|
|
Post by elmer on Apr 13, 2022 15:56:11 GMT
I'm just trying to make a tool generated code and avoid inline assembly. Will try to find another way... maybe parallel arrays... Cool! Yes, parallel arrays should work, and will generally result in the compiler generating better code. But if this is related to your map or sprite editors, please understand that HuC generates some pretty awful code, and so using the data in C is going to be slow. That's apart from any limitations with all the data needing to fit into the 8KB CONST_BANK or you'll have trouble accessing it. If you're writing data and functions for HuC developers to use, I'd personally recommend providing then with some library routines that they can call, written in assembly-language, and access the sprite/map/collision data through far-pointers so that it can be located in any bank in the HuCARD ROM or SuperCD RAM. And that same advice will apply to KickC development in the future, even though that compiler does generate much better code than HuC.
|
|
|
Post by 0x8bitdev on Apr 13, 2022 18:41:37 GMT
This is for sprite editor. And the 8KB CONST_BANK limitation can be a real problem. There is a nuance that keeps me from storing data in assembly. I'll think further... The MAPeD's tilemaps rendering library for the HuC uses data in assembly. Up to 120KB of data, several maps in a sample project work without problem.
|
|
|
Post by elmer on Apr 13, 2022 19:24:53 GMT
There is a nuance that keeps me from storing data in assembly. I'll think further... Let me know if there's anything that I can do to advise/help, either here or by private-message. The MAPeD's tilemaps rendering library for the HuC uses data in assembly. Up to 120KB of data, several maps in a sample project work without problem. Nice! When you're done, I hope that you won't mind me seeing if I can modify your library for inclusion into the ongoing work on building a new development environment for the PCE that uses KickC.
|
|