How to use Propcases? - General Discussion and Assistance - CHDK Forum

How to use Propcases?

  • 13 Replies
  • 669 Views
How to use Propcases?
« on: 11 / September / 2023, 23:41:03 »
Advertisements
I've spent hours trying to figure out how to use propcases but I have no idea how to use them. All I get is uBASIC unk errors. For example, #24 Image resolution, S3IS: 0,1,2,4,8 for L,M1,M2,S,W. Let's say I want to use 0 for Large.

I made a uBASIC script.
Code: [Select]
set_prop 24 0
When running it just doesn't do anything.

I even attempted a simple set timer propcase script in uBASIC and Lua, and got nothing, but an error! Anything I try, I get errors.

Lua Script
Code: [Select]
-- Set the self-timer to 10 seconds
props = require("propcase")
set_prop(props.SELF_TIMER, 1) -- Value 1 corresponds to a 10-second self-timer

uBASIC Script
Code: [Select]
@title Set 10-sec Timer
set_prop 219 1

What am I doing wrong?

*

Offline reyalp

  • ******
  • 14034
Re: How to use Propcases?
« Reply #1 on: 12 / September / 2023, 16:33:53 »
If you get errors on a very simple, valid script, make sure you saving the script file as plain ASCII text, not Unicode, UTF-8, or some not-text format like wordpad
Don't forget what the H stands for.

Re: How to use Propcases?
« Reply #2 on: 12 / September / 2023, 19:41:20 »
If you get errors on a very simple, valid script, make sure you saving the script file as plain ASCII text, not Unicode, UTF-8, or some not-text format like wordpad
Alright, thanks. Is my script valid though, or did I make a mistake, since I'm pretty sure I saved as a plain text format file.

*

Offline reyalp

  • ******
  • 14034
Re: How to use Propcases?
« Reply #3 on: 12 / September / 2023, 20:34:49 »
Alright, thanks. Is my script valid though, or did I make a mistake, since I'm pretty sure I saved as a plain text format file.
The ubasic looks valid to me, but I haven't tried it and I rarely use ubasic. For the Lua script, I do not believe SELF_TIMER is a valid propcase. If that's the case, you should probably have seen an error message about a nil value.

You can see a list of known propcases in the CHDK/LUALIB/GEN/propsetN.lua files. Most of the named propcases exist in all the propsets, but a few are only present in some. In particular, in propset 1 the TIMER_MODE doesn't exist, the setting is combined with others in the DRIVE_MODE propcase
Don't forget what the H stands for.


Re: How to use Propcases?
« Reply #4 on: 13 / September / 2023, 00:08:33 »
The uBASIC Script gave me a uBASIC:6 Parse err...

I even tried using the simple White Balance prop thing, to make a simple lua script, and even THAT simply gave me uBASIC:2 Parse err.

Here's the script.
Code: [Select]
props = require("propcase")
set_prop(props.WB_MODE, 2)

I'm beginning to doubt if propcases even work.

Even this super simple script just says "STARTED" and then "FINISHED", and once again, nothing changes.
Code: [Select]
set_capture_mode = 1
Is my syntax wrong? I'm starting to highly doubt any of this documentation by now, because nothing I have attempted to input for the past several years, has worked. I tried analyzing working scripts, and they seem straightforward, but when trying myself, it just fails. I even asked ChatGPT, and gave it all the documentation, and IT couldn't figure it out either. I'm really upset because I know how to write programs, but this is just impossible. Nothing I do works.


EDIT: Somehow I figured something out, by SHEER LUCK! I changed it to
Code: [Select]
set_capture_mode(1) and it worked!
« Last Edit: 13 / September / 2023, 00:13:26 by blenderbach »

Re: How to use Propcases?
« Reply #5 on: 13 / September / 2023, 00:42:18 »
The thing is, I'm trying to make a script for example, where I can change the resolution number, for example the S3IS has 480p at 30fps, and 320p at 60fps. If let's say 480p 30fps is number 1 in propcase video resolution, then I'd be able to write a simple lua script that would look something like this.
Code: [Select]
@params a = value
@default a = 0
set_video_resolution(a)

However, I'm not exactly sure how to do this, as I managed to do it with the set_capture_mode(1) script, but I have no idea what the syntax is for any of the other controls.

I just want to inject manual values because if there is a hidden locked off mode, let's say some kind of SCN mode like Foliage but for example let's say there was a SCN preset called Ocean that enhances certain colors and shadows, and it was only on the S1IS, but in the S3IS it still exists in the firmware, but is locked off in code, but if you inject the value, it turns it on.

I have modded many PlayStation2 games, using CheatEngine. I can inject a certain double digit hex value into a certain RAM section, which can make the tires of a car larger than what is possible by default in the game, and it works. Or for example, I can change the paint job of a car that had that option locked because it was a certain special car that isn't supposed to be editable, and yet by injecting a certain value, it assigns let's say "Gloss" paint job, and the value next to it, assigns the color of the paint, so by default you can't change the paint job, so the value is 00 00, but when I want to change it to Red Gloss Paint I inject 01 01. The first value is the paint type, and the second value is color. So by injecting 01 02, I get Green Gloss, and 01 03 I get Blue Gloss. But if I change the first value to 02 01, I get Red Matte paint. For example, by injecting a value larger than the last car in the game, I managed to open a car that was unused because the last car had the value 1F, but by switching it to the next hex value, it loaded a car into memory that was locked off from the game, as it was unused, which I managed to open and use in-game, by the manual hex value injection.

This is what I want to attempt with my S3IS.

I want to inject a value that isn't documented, and see what happens. Maybe it unlocks some hidden mode, maybe it enters a certain secret servicing menu. Unfortunately, I don't see that happening anytime soon, because I don't even know where to start.

Is this even possible, or am I asking for too much?
« Last Edit: 13 / September / 2023, 01:03:21 by blenderbach »

*

Offline reyalp

  • ******
  • 14034
Re: How to use Propcases?
« Reply #6 on: 13 / September / 2023, 19:48:43 »
The uBASIC Script gave me a uBASIC:6 Parse err...
The number should be the number of the line with the problem.
Quote
I'm beginning to doubt if propcases even work.
They do, in every minimally tested CHDK port. Almost no CHDK overrides or scripts would work if they did not. However, propcases may not behave in the way you expect them to. Some are "read only" meaning you can get the value, but there is no effect if you set them. Others can only be set at certain stages of the shooting process. Some get reset by various camera actions, like half pressing the shutter or changing shooting modes.

Quote
Even this super simple script just says "STARTED" and then "FINISHED", and once again, nothing changes.
Code: [Select]
set_capture_mode = 1Is my syntax wrong?
As you discovered below, yes ;)
In Lua, the code above would change the value of the variable set_capture_mode from the CHDK function you wanted to call, to the number 1. This is most likely not what you want.
Quote
I even asked ChatGPT, and gave it all the documentation, and IT couldn't figure it out either.
ChatGPT doesn't "figure things out", it just predicts what text should follow your prompt based on some complicated probabilities derived from the training data. While this can produce impressive results for things that are well covered by the training data, it's extremely unlikely to be useful for niche topics like CHDK. It will however confidently string together words that seem plausible, despite being utter nonsense.

Quote
EDIT: Somehow I figured something out, by SHEER LUCK! I changed it to
Code: [Select]
set_capture_mode(1) and it worked!
This is normal Lua syntax for a function call, which appears extensively in the documentation and examples.

The thing is, I'm trying to make a script for example, where I can change the resolution number, for example the S3IS has 480p at 30fps, and 320p at 60fps. If let's say 480p 30fps is number 1 in propcase video resolution, then I'd be able to write a simple lua script that would look something like this.
Code: [Select]
@params a = value
@default a = 0
set_video_resolution(a)

However, I'm not exactly sure how to do this, as I managed to do it with the set_capture_mode(1) script, but I have no idea what the syntax is for any of the other controls.
The syntax is the same standard Lua 5.1 syntax no matter which function you are using. The available functions are mostly listed on https://chdk.fandom.com/wiki/CHDK_Scripting_Cross_Reference_Page and documented to some extent.

Quote
I just want to inject manual values because if there is a hidden locked off mode, let's say some kind of SCN mode like Foliage but for example let's say there was a SCN preset called Ocean that enhances certain colors and shadows, and it was only on the S1IS, but in the S3IS it still exists in the firmware, but is locked off in code, but if you inject the value, it turns it on.
I believe there are a handful of cameras that have undocumented modes like this, though they may crash if you attempt to use them. In any case, the way things like this are discovered is by reverse engineering the firmware. In the specific case of shootings modes, the modes known to the canon firmware are found by the sigfinders and output to stubs_entry.S.

Quote
I have modded many PlayStation2 games, using CheatEngine. I can inject a certain double digit hex value into a certain RAM section, which can make the tires of a car larger than what is possible by default in the game, and it works.
...
Did you discover which address changes the tire size, or are you just changing values that someone else found? What you want to do with CHDK is more like the first option.

Quote
I want to inject a value that isn't documented, and see what happens. Maybe it unlocks some hidden mode, maybe it enters a certain secret servicing menu. Unfortunately, I don't see that happening anytime soon, because I don't even know where to start.

Is this even possible, or am I asking for too much?
You can set propcases, or call eventprocs with call_event_proc or arbitrary functions with call_func_ptr, or change memory directly with poke. Doing anything interesting with any of these generally requires significant understanding of the firmware, usually obtained by reverse engineering.

You might occasionally get lucky trying a propcase value based on a hunch, but otherwise you have to do the work.
Don't forget what the H stands for.

Re: How to use Propcases?
« Reply #7 on: 13 / September / 2023, 20:46:28 »
Quote
The number should be the number of the line with the problem.
Yeah, line 6 in a 2 line script.  :lol
Quote
The syntax is the same standard Lua 5.1 syntax no matter which function you are using. The available functions are mostly listed on https://chdk.fandom.com/wiki/CHDK_Scripting_Cross_Reference_Page and documented to some extent.
Yeah, but they all are preset functions. If I try changing them beyond anything, don't they just fail to work, since CHDK functions are designed to only output specific values? So for example, if set_mode(1) is video mode, set_mode(2) is auto mode, and set_mode(3) is sports mode, if there is a certain hidden mode, if I use set_mode(4), it won't actually trigger that mode since CHDK doesn't have that value to inject into the camera, right?
Quote
Did you discover which address changes the tire size, or are you just changing values that someone else found? What you want to do with CHDK is more like the first option.
Yes, I did. I even discovered multiple hidden things by simply injecting values above all the ones that exist in the game, and this would unlock hidden ones. For example, these Unused Paint Jobs were found by me, because when I extracted the ASSETS.DAT data file, which contained the game data files, there was a txt file which was by the devs that signified that there was supposed to be an Enamel paint job type, which isn't in the game, and I found it, among another two paint types which aren't even documented. https://tcrf.net/Midnight_Club_3:_DUB_Edition
Quote
You can set propcases, or call eventprocs with call_event_proc or arbitrary functions with call_func_ptr, or change memory directly with poke. Doing anything interesting with any of these generally requires significant understanding of the firmware, usually obtained by reverse engineering.

You might occasionally get lucky trying a propcase value based on a hunch, but otherwise you have to do the work.
Is there a chance I can brick my camera by directly writing to the addresses? Is there perhaps a tutorial where I can see how to do this? Is there actual information for the S3IS addresses for all the things CHDK uses? I mean, CHDK itself needs to know which address to write where when I override the shutter speed, or ISO, or Aperture. set_capture_mode() is a function if I understand correctly that CHDK uses to inject a custom value into the memory address of the camera to do this. If I could emulate the S3IS firmware on my computer, like what I do with the PS2 games, I could use Cheat Engine, see which address changes when a certain mode is changed, and directly write to it, and then when I know what to write where, I'd be able to use Poke, and simply write to that address, however, it seems you need to know how the firmware itself works before doing anything. The closest I could do was dump the sprites from the firmware bin, and I found some possibly hidden modes on the S3IS.

If only these sprites were of any use. :)


*

Offline blackhole

  • *****
  • 926
  • A590IS 101b
    • Planetary astrophotography
Re: How to use Propcases?
« Reply #8 on: 14 / September / 2023, 02:51:47 »
Is there a chance I can brick my camera by directly writing to the addresses?
Yes, if you make changes directly in the camera firmware, or bring the hardware to an unexpected position or something similar, but with POKE it is unlikely.
Randomly changing memory locations will probably only cause a crash, with or without permanent consequences, who knows.
Quote
Is there actual information for the S3IS addresses for all the things CHDK uses?
Yes, in the source code for S3IS, that is its purpose.
https://app.assembla.com/spaces/chdk/subversion/source/HEAD/trunk

Quote
it seems you need to know how the firmware itself works before doing anything
That seems to be true  ;)

I hope you find a way to UNLOCK the sensor size.
I believe all cameras have full frame sensors but they are locked to these unbearably small sizes. 8)

Re: How to use Propcases?
« Reply #9 on: 14 / September / 2023, 09:54:27 »
Quote
Randomly changing memory locations will probably only cause a crash, with or without permanent consequences, who knows.
I'm trying not to have consequences at all, though...
Quote
Yes, in the source code for S3IS, that is its purpose.
Ah, okay, thanks.
Quote
I believe all cameras have full frame sensors but they are locked to these unbearably small sizes. 8)
Seriously?  ???
As much as that would be cool, that's not the case. What I AM trying to do, is bypass resolution limitations, and overdrive the frame rate. So far, I'm trying to even find values to just change camera modes through RAM...

 

Related Topics