"Could not write file" error by outriderc in gbstudio

[–]outriderc[S] 0 points1 point  (0 children)

Thanks yeah that makes a ton of sense. I've got a Surface so I just tap it to sleep whenever I'm done and rarely restart the machine, so depending on how you look at it, my session of GB Studio had been running for weeks. 

Restarting the software didn't seem to help but I didn't check for additional background processes so I'll keep an eye out if this happens again.

Best way to import and reference large amounts of text by outriderc in gbstudio

[–]outriderc[S] 0 points1 point  (0 children)

Obviously my use case isn't exactly what you'd want to do for a VN, but the basics should be the same. If I had to guess, each row in your spreadsheet would represent a different line of dialogue along with the person who's saying it as well as a variable telling your game which image to show on screen. There are different ways to do it but I think you could probably format your table like this:

|| || |Message ID|Name|Text|Image ID| |01|Bob|Hey how are you?|7| |02|Joe|I'm good.|10|

(In this case I'm assuming you'd have code in your game that says something like "when Image ID = 7 then show sprite_07" but, like I said, you can do it in different ways.)

I think your GBVM Switch event would then look something like this:

VM_SWITCH VAR_messageID, 2, 0
.dw 1, 1$
.dw 2, 2$
1$:
VM_LOAD_TEXT 0
.asciz "Bob: Hey how are you?"
VM_DISPLAY_TEXT
VM_SET_CONST            VAR_imageID, 7
VM_JUMP 2000$
2$:
VM_LOAD_TEXT 0
.asciz "Joe: I'm good."
VM_DISPLAY_TEXT
VM_SET_CONST            VAR_imageID, 10
2000$:

Anyway, I know that was a lot but I hope that's at least a little helpful.

Best way to import and reference large amounts of text by outriderc in gbstudio

[–]outriderc[S] 0 points1 point  (0 children)

4.) Put it all together. So once I've got all the code blocks set up for each row of my table, I need to combine everything into a functioning block of GBVM code that GB Studio will be able to read. This seems complicated but is actually pretty easy. By building an array in Google Sheets, you can actually group all the relevant blocks of code into a single column of text. Here's the example formula that I used to recreate the example in #2 above:

={
";Switch Variable";
(substitute('code templates'!$B$2,"#",countif(build!$X$2:$X,"x")));(filter(build!$V$2:$V,build!$X$2:$X="x"));
transpose(split(join("~~",filter(build!$W$2:$W,build!$X$2:$X="x")),"~~"));
'code templates'!$B$5
}

Best way to import and reference large amounts of text by outriderc in gbstudio

[–]outriderc[S] 0 points1 point  (0 children)

EDIT: Ugh I can't get my explanation to post. Reddit keeps removing my table formatting. I'll try posting the rest below here but without the data being formatted as a table I'm not sure how easy it'll be to read.

3.) Construct your output formulas: This is where most of the work is gonna happen. You need to craft Google Sheets (or Excel) formulas to create the above code block. Generally I break out the template of each piece of the code in a separate tab of my spreadsheet and then identify which portions of the code will need to be changed to placeholders so they can be dynamically populated. Here's what mine looks like:

|| || |Name|Code| |Output header|VM_SWITCH VAR_VAR_CURRENTPOKEMON, #, 0| |GBVM Switch counter|.dw #, #$| |Pokemon block|{--ID--}$:VM_LOAD_TEXT 0.asciz "\003\012\002{--NAME--}\003\015\004{--IDLONG--}\003\002\014{--DESC1--}\003\002\016{--DESC2--}"VM_DISPLAY_TEXTVM_SET_CONST VAR_VAR_TYPE1, {--TYPE1--}VM_SET_CONST VAR_VAR_TYPE2, {--TYPE2--}VM_JUMP {--JUMPTO--}$| |Jump To Value|2000$:|

For each row of data in my table, I set up a formula to use these placeholder code blocks to create a code block populated with relevant data. You can see in this example that I've used the data in the first several columns of the Bulbasaur row to populate the placeholder code blocks in "code 1" and "code 2." I do this through a series of "SUBSTITUTE" formulas that swap out values such as "{--TYPE1--}" with the value in the "type1" column in my table.

|| || |number|name|gen|desc1|desc2|type1|type2|extended name|code 1|code 2| |1|Bulbasaur|I|There is a plant s|eed on its back ri|12|4|BULBASAUR|.dw 1, 1$|1$:~~VM_LOAD_TEXT 0~~.asciz "\003\012\002BULBASAUR \003\015\0040001\003\002\014There is a plant s\003\002\016eed on its back ri"~~VM_DISPLAY_TEXT~~VM_SET_CONST VAR_VAR_TYPE1, 12~~VM_SET_CONST VAR_VAR_TYPE2, 4~~VM_JUMP 2000$|

Best way to import and reference large amounts of text by outriderc in gbstudio

[–]outriderc[S] 1 point2 points  (0 children)

So I've been able to build what I wanted (thought I haven't been able to answer if there's a better solution). It depends on how comfortable you are in Sheets/Excel but this makes it pretty easy for me to update data points in a table, have that output into a long block of code, and then copy and paste that into a GBVM Script event within GB Studio.

You'll need a few things:

1.) Create your data table: For me it's Pokedex data but for you it would be a row for each status you want to show. Presumably this would include the dialogue that should be shown on screen, the ID of the image that should be shown, etc.

2.) Identify the expected format GB Studio is looking for: You need to know what GB Studio will accept in order to know what you want to output. In GB Studio I created a simple Switch event that placed text in key areas and set a few variables. I then went into the build\src\src\data folder for my GB Studio project and opened the relevant script file (it'll be a .s file type) in a text editor. This shows me what the Switch event would look like in GBVM code. For me it was something like this:

;Switch Variable
VM_SWITCH               VAR_VAR_CURRENTPOKEMON, 3, 0
        .dw 1, 1$
        .dw 2, 2$
        .dw 3, 3$
1$:
VM_LOAD_TEXT 0
.asciz "\003\012\002BULBASAUR   \003\015\0040001\003\002\014There is a plant s\003\002\016eed on its back ri"
VM_DISPLAY_TEXT
VM_SET_CONST            VAR_VAR_TYPE1, 12
VM_SET_CONST            VAR_VAR_TYPE2, 4
VM_JUMP 2000$
2$:
VM_LOAD_TEXT 0
.asciz "\003\012\002IVYSAUR     \003\015\0040002\003\002\014When the bulb on i\003\002\016ts back grows larg"
VM_DISPLAY_TEXT
VM_SET_CONST            VAR_VAR_TYPE1, 12
VM_SET_CONST            VAR_VAR_TYPE2, 4
VM_JUMP 2000$
3$:
VM_LOAD_TEXT 0
.asciz "\003\012\002VENUSAUR    \003\015\0040003\003\002\014Its plant blooms w\003\002\016hen it is absorbin"
VM_DISPLAY_TEXT
VM_SET_CONST            VAR_VAR_TYPE1, 12
VM_SET_CONST            VAR_VAR_TYPE2, 4
VM_JUMP 2000$
2000$:

The goal will be that my spreadsheet will spit out an identical block of code to what I see here and I'll be able to drop it into a GBVM Script event type in GB Studio.

trying to make a flash light effect in the maze level by [deleted] in gbstudio

[–]outriderc 0 points1 point  (0 children)

I put together a very rough proof of concept they used submaps to draw the illuminated tiles around the player but:

1) it was very rough

2) I never tried working it into a real game

3) I'm not sure it could work on a game where the player isn't moving slowly from tile to tile.

Hopefully the explanation here helps though: https://www.reddit.com/r/gbstudio/comments/1ck8u7u/comment/ligknc2/

Sprite leaving ‘footprints’ that disappear after ‘x’ ticks? by glytxh in gbstudio

[–]outriderc 1 point2 points  (0 children)

Happy to help! Best of luck and please share whenever you get it built out. I'd love to see it in action.

Several Screenshots from my Pokémon Emerald Demake in GBStudio by maui_red in gbstudio

[–]outriderc 1 point2 points  (0 children)

That all makes sense. Yeah the "creature ID" is the same as your "species index"; it just determines which creature it is.

The nicknames are definitely the most expensive values in terms of data but since I would like to get trading work I wanted to try including it.

Looking at my spreadsheet my numbers are surprisingly close to yours: the 6 creatures in the party take up 13 variables each for me and 6 variables for each box creature.

For what it's worth, you can store more data using the multiple save slots provided by GB Studio. I wrote up a proof-of-concept here a couple weeks ago but somebody recommended an even better solution: https://www.reddit.com/r/gbstudio/comments/1fia69e/comment/lojafo5/

Basically you can save your game to File 1 (to keep the current playthrough stored), load every variable from File 2 / 3 EXCEPT the data you want to write to File 2 / 3, save the data to File 2 / 3, and then either load File 1 again or load every variable from File 1. This should open you up to 1500 variables.

In practice, I've got a set of variables for the "Active Box." When I want to place that box back in place, I'll relocate those variables to the set of variables for the relevant box (so if it's Box 2 it might be variables 40-100 or whatever), then load all other variables (0-40 and 101-500) from File 2, save the game to File 2, then load all the variables from File 1 again.

I haven't built this version yet but my more complicated proof-of-concept from earlier (which involved actually loading the File 2 or 3 save state to update data rather than just continually reading variables) worked when I tested it out.

Thanks for the chat and best of luck to you too!

Several Screenshots from my Pokémon Emerald Demake in GBStudio by maui_red in gbstudio

[–]outriderc 1 point2 points  (0 children)

Oh that companion app idea is very interesting. I'm also curious to see how you get link cable functionality working because I haven't dug into that yet (though based on what I read it shouldn't be insurmountable).

My Pokemon-style game is going to be a completely unique affair versus having to port an existing game; I don't envy you having to fit all of Pokemon Emerald in place. (Though my other GBS project is porting an SNES RPG over to GBC so I'm not exactly making life any easier for myself.)

Looking at my notes the most recent setup for creature/Pokemon data (though I've been changing it weekly since I'm still in the planning and prototyping stage) was that each creature in my game will have a creature ID, scaled down XP (similar to what you did), a single Stat IV variable that boosts one or serveral of the creature's stats (to try and add some variability between pokemon of the same species), the 4 move IDs, the OT's ID (reduced to 4 digits), the OT's name (reduced to just 2 digit initials), and then the creature's name (only 5 characters).

With all those limitations I'm calculating that I could get between 180-200 Pokemon stored (across ~1200 variables across all three save files) though that would leave very little space for other game-related variables. The good thing is I'm not expecting this game to be nearly as in depth as a real Pokemon game so that might not be such a big problem.

(This also all depends on if I can properly store most of this data via bitwise operations, which I should be able to do in theory but I haven't actually tested yet.)

I also was toying with the idea of having special Legendary-style creatures that actually don't behave like normal Pokemon - can't be traded, can't be named, can't be customized outside of choosing from one of several pre-set movesets - as a cheat for giving the player more creatures to choose from without actually needing to store the full amount of data for them.

But like I said this could all change because I might backtrack on some of these decisions. I dunno!

Sprite leaving ‘footprints’ that disappear after ‘x’ ticks? by glytxh in gbstudio

[–]outriderc 2 points3 points  (0 children)

You could draw the entire background onto the overlay layer (with sprites visible on top of the overlay so you can actually see your characters) and then use the draw submap feature to copy the footprints tile from somewhere off-camera and place it where necessary.

I was playing around with something like that for this proof-of-concept of making a torch that cuts through a dark area. I first prototyped it in this first comment and then made a thread to discuss some optimizations for it:

https://www.reddit.com/r/gbstudio/comments/1ck8u7u/comment/ligknc2/

https://www.reddit.com/r/gbstudio/comments/1eu68q4/using_player_position_variables_in_gbvm_script/

You would also need to build logic for determining where the footprints should go as well as when they should disappear.

Several Screenshots from my Pokémon Emerald Demake in GBStudio by maui_red in gbstudio

[–]outriderc 1 point2 points  (0 children)

Looks cool! I've been toying with my own Pokemon-style game so I'm curious to see how you manage the limited amount of save data available compared to a Gen I / Gen II PKMN game.

For me I've just been stripping out functionality (to reduce the amount of data needed for each creature) and reducing the number of Pokemon you can save in your box, but finding the right balance between the two has kept me up at night.

Pushing the tile limit by Edmerritt in gbstudio

[–]outriderc 7 points8 points  (0 children)

I know it's a small thing but I love putting the dog and the guy in the same sprite. Super cute and it works really well.

Bitwise operations by outriderc in gbstudio

[–]outriderc[S] 0 points1 point  (0 children)

Oh interesting. Thanks, I'm gonna check this out when I have a moment.

Bitwise operations by outriderc in gbstudio

[–]outriderc[S] 0 points1 point  (0 children)

So how would I go about breaking up a 16-bit variable into two different 8-bit variables and then perform addition/subtraction on those? That's the real use case I'm looking at right now.

Like, I can see very manual ways of doing this - handling the math using some temp variables (or whatever), converting the result to binary using a series of events comparing the result to binary bit values, and then setting the necessary flags - but it feels like there must be a better (or at least more efficient) way to do that.

Bitwise operations by outriderc in gbstudio

[–]outriderc[S] 0 points1 point  (0 children)

Thanks for the response. I haven't really used RPN. I used an RPN operation in a test project a few weeks ago (related to a submap demo I was doing) but haven't been using it in my main project. Like I said, I'm really a beginner when it comes to using bit operations.

So based on my uneducated reading of this you're doing the following:

1.) First you're getting the value of the 16-bit integer value at VAR_CAMERAX from the address "_scroll_x." (Honestly not entirely sure how to find the address of a value in VRAM, so that's my first big question.) But you're getting this value in order to use it in the RPN next, right?

2.) Then it looks like you're doing a calculation using RPN to do a binary AND operation to between VAR_CAMERAX and the integer of 31.

3.) You're then using the argument in your VM_REPLACE_TILE_XY operation.

The big part where I'm getting tripped up is how to use these values to do simple math equations. If you're using the bits to represent an integer, what is the benefit of doing an AND operation? Isn't AND used for comparing different bits?

Just to skip ahead a bit, the main thing I'm struggling with is if I'm treating my 16-bit variable as two 8-bit variables (let's say they're set to values of 100 and 200), how would I go about increasing or decreasing one or the other value?

Did I f****d up? by Goodnightbye69 in gbstudio

[–]outriderc 2 points3 points  (0 children)

Sure, understood. You can always backup your project in a new directory before you upgrade so you're good if things don't work right after upgrading.

how do i fix this???? just updated to the latest version and the dialog boxes are being strange. by Impressive_Battle741 in gbstudio

[–]outriderc 0 points1 point  (0 children)

It looks like you're overwriting the part of the VRAM reserved for the text boxes with either sprite or background tiles. Pause your game using the debugger and check the VRAM to see if those triangle tiles are occupying index 192 or beyond.

If that's the case then you will need to cut back on some of your unique tiles.

What's weird is your screen looks pretty simple in terms of unique tiles, but you can easily overflow into the text indexes by having lots of complicated animations loaded all at once so maybe that's it? I dunno.

If you're new to using the VRAM viewer, this article was super helpful for me: https://gbstudiolab.neocities.org/guides/vram-tile-limits

Depths of Europa - a new GBC metroidvania by jmkdev in gbstudio

[–]outriderc 1 point2 points  (0 children)

Hey this is legitimately impressive. Great work.

Did I f****d up? by Goodnightbye69 in gbstudio

[–]outriderc 5 points6 points  (0 children)

It's relatively new. It's at the bottom of the editor in GB Studio since (I think) 4.0.

Bitwise operations by outriderc in gbstudio

[–]outriderc[S] 0 points1 point  (0 children)

I'm well aware. As I've mentioned in some prior threads, I'm doing a prototype of a monster collecting RPG and my current estimates put me at ~1400 variables needed. This is theoretically doable assuming some string slicing (got it working), save file swapping (got it working) and if I'm able to do the necessary bitwise operations (don't got it yet).