Reply to thread
GBAtemp.net - The Independent Video Game Community
Search
Search titles only
By:
Search titles only
By:
Reply to thread
GBAtemp.net - The Independent Video Game Community
Home
Log in
Terms & Rules
Donate
Forums
New posts
Search forums
Groups
Public Events
New
New posts
New resources
New blog entries
New profile posts
New blog entry comments
New threadmarks
Latest activity
Cheats
Cheat Codes Add and Request group
The Legend of Zelda: Tears of the Kingdom cheat codes
Pokémon Legends: Arceus cheat codes
Xenoblade Chronicles 3 cheat codes
Fire Emblem Engage cheat codes
Request a cheat...
Tutorials
Nintendo Switch tutorials
Nintendo 3DS tutorials
Nintendo Wii U tutorials
Reviews
Overview
Official reviews
User reviews
Downloads
Latest reviews
Search resources
Blogs
New entries
New comments
Blog list
Search blogs
Chat
Top chatters
Search
Search titles only
By:
Search titles only
By:
Log in
Register
New posts
Search forums
Log in
Register
Home
Forums
PC, Console & Handheld Discussions
Nintendo Switch
Any C coders in here?
Menu
Install the app
Install
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="mrdude" data-source="post: 8601176" data-attributes="member: 376937"><p>[USER=444019]@JustBrandonT[/USER]</p><p></p><p>Thanks for posting, I've updated some code in the source files compared to the version you've posted - I have another question though.</p><p></p><p>Currently I have this code to centre text on the screen (x co-ords only, not y).</p><p></p><p>[code]</p><p> //code to centre text on the screen</p><p> </p><p> const char *s = "Loading menu - please wait!";</p><p> int total_width = 1280;</p><p> int half_height = 360;</p><p> int scale = 3;</p><p> int font_size = ((scale * 8) / 2);</p><p> int y_loc = (half_height - font_size);</p><p> const int s_width = (strlen(s) * 8) * scale; //change 8 to size of bitmap font in use</p><p> const int field_width = (total_width - s_width) / 2;</p><p> </p><p> g_gfx_con.scale = scale;</p><p> gfx_con_setpos(&g_gfx_con, field_width, y_loc); </p><p> gfx_printf(&g_gfx_con, "%k%s%k", 0xFF3065E1, s, BLACK);</p><p>[/code]</p><p></p><p>Instead of needing to write the same code for every line of text I want to centre, I think it would make more sense to create a function that can be called with 2 variables:</p><p></p><p>Text</p><p>Scale</p><p></p><p>As the payloads are limited to the amount of bytes available - this would save some space and leave that for more code that could be added in future, I am unsure on creating a function with variables - would you happen to know how to code a function like that, and a little example on how to call that function so the variables are added?</p><p></p><p>Thanks.</p><p></p><p>EDIT: Scrap that request, I figured it out. Thanks for reading though.</p></blockquote><p></p>
[QUOTE="mrdude, post: 8601176, member: 376937"] [USER=444019]@JustBrandonT[/USER] Thanks for posting, I've updated some code in the source files compared to the version you've posted - I have another question though. Currently I have this code to centre text on the screen (x co-ords only, not y). [code] //code to centre text on the screen const char *s = "Loading menu - please wait!"; int total_width = 1280; int half_height = 360; int scale = 3; int font_size = ((scale * 8) / 2); int y_loc = (half_height - font_size); const int s_width = (strlen(s) * 8) * scale; //change 8 to size of bitmap font in use const int field_width = (total_width - s_width) / 2; g_gfx_con.scale = scale; gfx_con_setpos(&g_gfx_con, field_width, y_loc); gfx_printf(&g_gfx_con, "%k%s%k", 0xFF3065E1, s, BLACK); [/code] Instead of needing to write the same code for every line of text I want to centre, I think it would make more sense to create a function that can be called with 2 variables: Text Scale As the payloads are limited to the amount of bytes available - this would save some space and leave that for more code that could be added in future, I am unsure on creating a function with variables - would you happen to know how to code a function like that, and a little example on how to call that function so the variables are added? Thanks. EDIT: Scrap that request, I figured it out. Thanks for reading though. [/QUOTE]
Insert quotes…
Verification
Post reply
Home
Forums
PC, Console & Handheld Discussions
Nintendo Switch
Any C coders in here?
General chit-chat
Help
Users
Settings
Notifications
Miscellaneous
Inverse message direction
Display editor on top
Enable maximized mode
Display images as links
Hide bot messages
Hide statuses
Hide chatter list
Show messages from ignored users
Temporarily disable chat
Receive mention alerts
Sound notifications
Normal messages
Private messages
Whisper messages
Mention messages
Bot messages
Desktop notifications
Normal messages
Private messages
Whisper messages
Mention messages
Bot messages
Options
Options
View top chatters
Xdqwerty
Loading…
what are you looking at?
K3Nv2
Loading…
BigOnYa
Loading…
rqkaiju2
Loading…
@
Xdqwerty
:
@SylverReZ
, looks cool
Yesterday at 11:07 PM
@
Xdqwerty
:
@salazarcosplay
, fine i guess
Yesterday at 11:07 PM
@
K3Nv2
:
https://www.nickalive.net/2024/05/peter-bennett-long-time-art-director-on.html?m=1
sad
Yesterday at 11:16 PM
@
BigOnYa
:
I said to my wifey earlier, "I gotta pull a Nocto card on that one." Without even thinking she has no clue what that means.
47 minutes ago
@
rqkaiju2
:
im chewing on possibly expired gum right now. it tastes normal
40 minutes ago
@
Xdqwerty
:
@rqkaiju2
,
cuz it expired 5 minutes ago
38 minutes ago
@
rqkaiju2
:
@Xdqwerty
wrong it probably expired somewhere in 2023 most likely
+1
37 minutes ago
@
rqkaiju2
:
ok i just checked a pack it expires 28 november 2024 so it isnt expired
+1
36 minutes ago
@
BigOnYa
:
I've heard chewing expired gum, makes you grow a tail, just saying. You may need to buy new pants with a hole in the rear.
35 minutes ago
@
rqkaiju2
:
woah
35 minutes ago
@
SylverReZ
:
https://www.youtube.com/watch?v=4iMm6wIktNk
+3
34 minutes ago
@
rqkaiju2
:
kinda angry rn why am i getting no audio in my headphones when they're plugged in
33 minutes ago
@
BigOnYa
:
I've also heard chewing expired gum causes hearing loss when wearing headphones.
+2
31 minutes ago
@
Xdqwerty
:
@SylverReZ
, why is wish.com still alive?
31 minutes ago
@
SylverReZ
:
@Xdqwerty
, No idea, Wish.com is dead.
29 minutes ago
@
Xdqwerty
:
@SylverReZ
,
its probably still alive due to dumb people buying from there
+1
27 minutes ago
@
K3Nv2
:
https://www.cbsnews.com/news/tesla-cybertruck-rusting-complaints-from-owners/
26 minutes ago
@
Xdqwerty
:
@SylverReZ
,
that site is like if a clickbait youtuber made a online store themselves
+2
25 minutes ago
@
K3Nv2
:
You wouldn't leave this site even if it became a porn site
+1
24 minutes ago
@
SylverReZ
:
https://youtu.be/rtvRsQvkkrY?feature=shared&t=32
24 minutes ago
@
K3Nv2
:
You'd stay on it longer if anything
+2
23 minutes ago
@
BigOnYa
:
@K3Nv2
That's what uremum said, when I told her to go shower first.
+2
21 minutes ago
@
K3Nv2
:
https://a.co/d/3aCbNk8
lol smart keyboard
18 minutes ago
@
K3Nv2
:
+1
11 minutes ago
@
Xdqwerty
:
@K3Nv2
,
so smart it doesnt even exist
8 minutes ago
Submit
@
Xdqwerty
:
@K3Nv2, so smart it doesnt even exist
8 minutes ago
Chat
4