Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved D template #1891

Merged
merged 7 commits into from
May 2, 2022
Merged

Improved D template #1891

merged 7 commits into from
May 2, 2022

Conversation

PierceNg
Copy link
Contributor

  • Add Makefile and dub.json for D.
  • Improved README.
  • Fix function signature type mismatches.

Fixes #1888.

"--strip-all",
"--allow-undefined",
"--stack-first",
"--no-entry"
Copy link
Collaborator

@joshgoebel joshgoebel Apr 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to pull over:

       "--initial-memory=65536",
       "--max-memory=65536",
       "-zstack-size=14752"

But with TIC-80 specific values, which I think would mean 256kb memory and 96kb "reserved"... which I THINK means stack-size should be 96*1024 + 8 * 1024 (assuming we want an 8kb actual stack)... does that sound right? With the stack growing downwards from 96kb+8kb, sicne we're using --stack-first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me run some tests with the numbers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the numbers for TIC-80 would be, for 8k actual stack:

       "--initial-memory=262144",
       "--max-memory=262144",
       "-zstack-size=106496"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we ever get this changed?

#!/bin/sh
make clean
make
tic80 --fs . --cmd 'load wasmdemo.wasmp & import binary cart.wasm & run & exit'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just me, but nothing about build to me implies "run" also... I think perhaps we need build_and_run or something...? Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine calling it build_and_run. As is typical, this started out with the make commands, and then I added the tic80 command line too to run. As the README states, these are just convenience scripts.

const PERSISTENT_MEMORY_PTR = cast(ubyte*)0x14004;
const SPRITE_FLAGS_PTR = cast(ubyte*)0x14404;
const SYSTEM_FONT_PTR = cast(ubyte*)0x14604;
const WASM_FREE_RAM_PTR = cast(ubyte*)0x18000;
Copy link
Collaborator

@joshgoebel joshgoebel Apr 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really think we should provide this out of the box? Does D not allocate globals and such things starting here automatically? (like C)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose you are referring to WASM_FREE_RAM_PTR? Since TIC-80 allows peeking and poking anywhere, I put this in as well. But yes, generally the game programmer will leave to D to manage memory.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. I'm just not sure we want to encourage this. Someone who knows what they are doing can add that line to their own source easily enough without us including it in the core examples. And if they do not know what they are doing they probably shouldn't be using WASM_FREE_RAM_PTR in the first place...

Thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave it out then.

make clean
make
tic80 --fs . --cmd 'load wasmdemo.wasmp & import binary cart.wasm & save game.tic & exit'
tic80 --fs . --cmd 'load game.tic & run & exit'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to invoke tic80 twice vs doing it all in a single session?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intention is to demonstrate the two separate actions -- creating a .tic file from necessary artifacts, and running the .tic directly without reference to said artifacts -- for the programmer who is new to this console.

@nesbox
Copy link
Owner

nesbox commented Apr 25, 2022

I OK with the PR, @joshgoebel please let me know when we are ready to merge.
Thank you.

@nesbox nesbox merged commit 2b85ca9 into nesbox:main May 2, 2022
@PierceNg PierceNg deleted the wasm-funcsig branch May 2, 2022 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wasm: Type mismatch between function signatures and implementations
3 participants