[CLOCK]rat_2665's special clocks (Tourbillon, moonphase, ...) second time clock - HD2 Windows Mobile 6.5 Themes and Apps

Special modded clocks by rat_2665​
Co0kies Home Tab is an excellent basis for analog clocks. At first I tried some historical clocks. One of these has a separated dial for the seconds. So I looked further into modifications (thanks to Co0kie for some crucial tips) - and the possibilities are enormous. Clocks with complications are very expensive (ca. 100000 €), so I decided to make my own clock for CHT with a Tourbillon and some other modifications like date, continuously moving (not jumping) second and minute hand and a separated second hand. But that was not the last. Look in the first post for the clocks, in the second post for deeper information and in post 3 - 5 for a tutorial for modding the analog clock manila files.
EDIT: In CHT 2.0 all these clocks can be used as before. There is a new element - the widgets - but these are independent of the standard analog and digital clock. If you want to look at some new clock widgets look in my new widget thread.
Click to expand...
Click to collapse
NEWs​
- [30/08/2010] New clock with second (home) time.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
- [07/08/2010] Some transparent clocks
- [19/07/2010] New LT HD2 Concept clock with switching visibility added to the Lüm Tec clocks.zip
- [16/07/2010] New Templates Updated the descriptions in post 2 -5 and added some Templates in post 6.
- [15/07/2010] exceptional modification of the reference clocks by musezicos
- [13/07/2010] switching visibility reference clocks: Because of requests I've made versions of my carbon clocks with switching visibility and described the Tourbillon clock in post 2.
- [29/06/2010] Lüm-Tec clocks: The Combat B9 and the M24 are "switching" clocks which will change design between daylight and maxlumen in the morning and the evening. Edit [02/06/10]: Now with a new corrected version for 12h use. The first fix caused heavy CPU load.
- [23/06/2010] Hero clock: Added version with date.
- "day of week" version: It shows the day of the week like in the date on the homescreen in an extra display at the clock. There is only a version for the carbon clock with moon phase. Download and description
- [19/06/10] CHT 1.8.5: I made new versions for the clocks made by me and deleted the 1.8 versions (look at the attached files or the download links). For people who'd like to use CHT 1.7 I let the old versions stay. Descriptions will be updated in the next future. Announcement: I will post templates for the animations for other clock modders. Don't let disturb you if sometimes CHT 1.8.1 is mentioned. It is all good for CHT 1.8.5.
- "only seconds" version: Because of the heavy power use of the Tourbillon I made some versions without. For these the power use is acceptable.
- carbon style: Because of requests I made a darker alternative carbon design for the new versions.
- Moonphase: Some of these clocks have a fully functional moonphase display.
- Cookie Mod For people who are very fond of co0kie there is a mod for the moonphase clocks.
- [04/06/10] Lüm-Tec clocks Combat B 11 with 24 h and new date by tictac0566 and rat_2665 (description). This is a new date version useful for all clocks.
Click to expand...
Click to collapse
Deinstallation​
CHT 1.8.5 changes the structure of the manila files for the analog clock mods. Animations and object description are regulated in special separated manila files: 1E1A6CCD_manila (mode9 file for the objects) and 1EC5924B_manila (lua script for the animations). That's good for all future changes in CHT and for the independence of other mods, but it is a new step.So you can't use "advanced" clock mods for older versions of CHT because they will damage your Sense/Manila. If you've already done so try this solution or reinstall CHT 1.8.5.
Do not use the Windows mobile deinstallation routine, only install the attached original analog clock cab. Then make a manila restart.
The use of the WM routine will crash your manila because it deletes the used CHT files, which are necessary, and doesn't substitute them with the original files. If you done so and manila hangs at the start, try to deactivate manila in "settings, today", install the original clock cab and reactivate manila. It works with my stock ROM, but no guaranty for other ROMS.
If you still have problems at deinstallation try the solution by jaguaralani http://forum.xda-developers.com/showpost.php?p=6646478&postcount=23and copy the files in the added zip file in the windows directory of your device. Use Total Commander or Resco Explorer for this. Both cab and files in zip restore the original CHT files.
Click to expand...
Click to collapse
Clocks​
For clarity I put the clocks with the same design in one zip (download at the end). The original analog clock for deinstallation (for CHT 1.8.5 and the older versions) is as cab in every clock zip and also as cab and zip attached at the end of this post.
Golden versions with Tourbillon
These clocks have a functional image of a tourbillon a so called "complication" by watchmakers. A tourbillon counters the effects of gravity by mounting the escapement and balance wheel in a rotating cage, ostensibly in order to negate the effect of gravity when the timepiece (and thus the escapement) is rotated. For further information read the article in wikipedia http://en.wikipedia.org/wiki/Tourbillon.
There are two versions, one with the seconds in the upper dial and one with moon phase instead. Both clocks have a AMPM version. Only difference is the special field for AMPM in the background (and changed position). For the special case of no AMPM in the analog clock although using AMPM generally I made a new version . Instructions and download for this version are here.​
Golden versions without Tourbillon
These clocks are not so power consuming. They have still complications like date, continously moving minute and second hand and in one version the moonphase.
Carbon Versions
Because of requests for darker background and not so golden clocks I made a alternative carbon design for the new versions. In the basic versions it is only a layout change, the functionality of these clocks is the same as in the golden versions. Only exception is the "day of week" clock, which exists only as carbon version.
Reference clocks for switching visibility
Because of requests I've made two versions of my carbon clocks with switching visibility like in the Lüm-Tec clocks. In the zip are also the images and the lua scripts.
Lüm-Tec clocks
The Lüm-Tec clocks are made by TicTac0566 and me together . The Combat B11 has a 24h display, the Combat B9, the M24 and the LT HD2 Concept are "switching" clocks which will change design between daylight and maxlumen at 8:00 and 20:00. The B9 has versions both for CHT 1.7 and 1.8.5, the others only for 1.8.5. Look for more of TicTac's exciting clocks in his thread.
Hero clock
This is my version of Lechu's magnificent Hero clock (with overlapping case, AMPM and date)
versions by others​
For all who like black text poyensa made a version. You can download it in this post. Ancola66's contribution is a version with big second hand. Poyensa's clock is not modified for CHT 1.8 but text color is adjustable in CHT 1.8. Ancola66 has now a CHT 1.8.5 version.
And Jaguaralani made two more nice black versions of the Tourbillon . Download is for the CHT 1.7 version here and for the CHT 1.8.5 version here. Thanks to all.
exceptional modifications of the reference clocks by musezicos here and here
​
Click to expand...
Click to collapse
In the next posts I will describe how I made it so that all interested can do it themselves.​

form and function of the reference clocks
Tourbillon clock
form
For the mechanical description of a Tourbillon please read the article in Wikipedia. There is also a little video with a moving Tourbillon.
The clock consists of the following parts (in order of the layers in 1E1A6CCD_manila with the Sense names, cursiv are the standard ones):
4B55E014_manila DateDayTens (calendar date)
4DDA6CCF_manila DateDayOnes (calendar date)
20F62884_manila analogclock (normal clock background)
Here comes in 1E1A6CCD_manila the "ShowAMPM" text object.
7BA5E044_manila secondHand2 (balance wheel of the Tourbillon)
2A87D392_manila secondHand (cage of the Tourbillon)
3FDED376_manila analogclock2 (fixture of the Tourbillon)
7BB7F8C5_manila secondHand3 (real second hand)
0AB9C3F4_manila hourHand
4BDFBA48_manila minuteHand
0D505BB2_manila scaleButton
7126E342_manila clockdot
The secondHand was used for the Tourbillon cage because sometimes the Tourbillon is used as second hand (it turns once in a minute ).
The date display is made like in real clocks. Two disks, the date is to be seen by the rotation of the disk.
There are two other manila files, the mode9 file for the objects 1E1A6CCD_manila (in versions before CHT 1.8.5 7c60907d_manila) and the lua script for the animations 1EC5924B_manila (former 461d3306_manila).
function
A Tourbillon cage jumps every fifth of a second, a balance wheel rotates 180 ° back and forth five times a second. Sense/Manila shows an actual image of the elements and checks for an established period if there are changes. So if you want to get a picture like the real behavior you have to get 25 frames per second for the moving parts - especially the balance wheel. So the lua script in 1EC5924B_manila checks 25 times per second for changes instead of the original one time per second of co0kies home tab (which you can disable because of power consuming). You see this clock is nice to look at, but still expensive, not so much like the real but it costs in power consuming (but it seems only if the clock is to be seen). Also it is very depending of other processes, for example at the start at the calendar opening or at the weather animations. The HD2 has borders too .
Tourbillon clock with moonphase and switching visibility
form
Here are the parts (with manila name and object name in the lua script and the mode9 file in the order of the layers):
4B55E014_manila DateDayTens
4DDA6CCF_manila DateDayOnes
2056A60D_manila DateDayTensnight
09DE9308_manila DateDayOnesnight
2C2AA9E8_manila moonphase
09187EE1_manila moonphasenight
20F62884_manila analogclock
3C87827D_manila analogclocknight
ShowAMPM
7BA5E044_manila secondHand2
3B920A3D_manila secondHand2night
2A87D392_manila secondHand (dummy with blank picture)
596B8F02_manila secondHand1
4B1CC00B_manila secondHandnight
3FDED376_manila analogclock2
5A551AEF_manila analogclock2night
0AB9C3F4_manila hourHand
5CCDF1ED_manila hourHandnight
4BDFBA48_manila minuteHand
5E305741_manila minuteHandnight
0D505BB2_manila scaleButton
7126E342_manila ClockDot
6294D3BB_manila ClockDotnight
In the attached pdf document is a list of all this objects together with their "location folder" in the mode9 file.
function
moonphase
Moon phase is another so called "complication". It shows the phases of the moon in an extra display. Because in modern watches the clock maker tried to show the 3D-movement of the Moon with a 2D dial, you can't compare the image on the clock with the image in the night sky. You can see full and new moon and if it is waning or waxing moon. The moon phase movement is very slow. It is not the moon movement on the dayly night sky, but the movement of the phases of the moon. So the moon in the dial needs 14 days from left to right (in Northern hemisphere). It describes the lunar month (full moon - new moon - full moon, 29 days). At the development I read that the big clock makers who were all in the Northern Hemisphere made only clocks where you can see the phases of the moon only like at the Northern Hemisphere (NH). The Southern Hemisphere will see each phase rotated through 180°. So I made at some clocks an AddOn for all who are living there (named SH). It changes the the movement of the Moon (against clockwise).
switching visibility
As you can see above the visibility change needs the duplication of every changing object. The night version of every object is layed over the day version (only exception the date). In the lua script the switching is realised by changing the opacity of the night objects at definite points (8:00 AM and 8:00 PM).
In the next posts I'll describe the modification of the manila files.

Modifications to qtc files and manila hash names
modding the manila files
For analog clock modding there are three file types relevant: the image files (*.qtc), the mode9 file 1E1A6CCD_manila (former 7c60907d_manila) and the lua script 1EC5924B_manila (former 461d3306_manila). syntax of HTC mode9 files and lua scripts are not documented. The lua version of HTC is not the original version. Some original functions don't exist, some new functions are used. So it is trial and error and reverse engineering. Here is a link for starting
All this files are named by a hashed version of the original name. For this name you can use this tool by NisseDILLIGAF. For further information read Co0kies Name Guide.
QTC-files
First of all you have to create your files with a better image editing program (GIMP is for free). It should have layers function. That's good for later saving the individual images and for working at the images together. CHT uses 256x256 pixel images for the background. Greater dimensions are possible, but they crash with Co0kies design for the different versions of clock/weather. So I don't advice this.
For the hands the standard dimension is 16x256, for clockdot 32x32. You can use greater values (best 32, 64, 128, 256), but then you have to change the values in the mode9 file (see there).
If you use a picture with different layers, align the hands with the background like in the normal clock (the hands should be in the "12" position ), then change the dimensions of the "canvas" to the necessary values and save the different layers as individual images . Only exception are hands which are not in the centre of the clock (like my second hand). These should also be positioned in the centre. The different position is realized in the 1E1A6CCD_manila file.
Now you have to turn these images in manila files.
Franwella made a little guide for the clock background. The steps for the other standard pictures (hands and ClockDot) are the same. As an alternative you can use CFC GUI. Scan the selected folder, you should see all the qtc-manila-files in the left row. Select the manila file, replace (button bar in the right down corner) the image with your PNG image. That's all.
For new manila objects you should create a self-documenting name (f. e. DateDayTens). You have to use this name at all positions, where this object is used (in the mode9 file and the lua script). Use the manilahash program with this string :
\windows\htc\home\assets\images\Home\VGA\Your_Name.qtc
The pdf file in post 2 contains these strings for all the objects I used. Don't let you disturb by the folders. All manila files are in the windows directory.
Take another manila file, copy it in your temporary working directory, rename it with the new hash name, change the picture like above.

Modifications of the mode9 file
mode9 file 1E1A6CCD_manila (former 7c60907d_manila)
The mode9 files regulates the type, size, position, location and some times color . Thanks to poyensa there is already a guide for changing colors in text objects. Here we look at the analog clock objects. I use m9editor . After some clicking you find this
In this Group there are several "GLESSprite2D" objects and one "GLESText" object. This are the description for the analog clock objects and the AMPM field. I opened the secondHand for a moving object and the analogclock for an unmoved object. The difference is the <Property> line for Center Value which unmoved objects didn't have. Notice that moving means also rotate in a constant position.
new objects and order of objects
For adding of new objects simply point to an object with nearly the same properties (so you have not much to change), click right, select copy, then go to the object before the position of your new object, click right and select paste below. The order of the objects determines how they are "layered" at the clock (thanks to pchronos). If you have a clock with moving objects which are covered by the casing (f. e. the second hand in the Hero clock by Lechu), add the covering parts as a new layer/object (f. e. "analogclock2") after the moving parts. For my clock you can see that the order of the objects is the same as the layers in post 2.
In the picture you can see an added text object DayDatenight with luminous colour and an added hour hand for the night version.
properties
Click on the line. You can see at the lower border of the editor a line for changing the values. Don't forget after changing to click "Ok"
Name Instance
Is the name of the variable of the object in lua scripts. I used for my new objects for simplification the same name as for the qtc-image in second line (only with added _). That's not necessary.​Name Texture Path
Thats the location of the image file. Use this name (only the last part before .qtc! instead of the fat letters) for the hash manila name as described above. ​Name Position/Name Center/Name Size
These values are corresponding with each other. For standard values (normal size, rotating in centre) change nothing. If you want to change the size so 3lixir found a formula for the changed width of hands:
Change the width of hand image (best to a multiple of 16).
The "centre value" for the x-axis is half the new width of the hand minus 0.5
The "position value" for the x-axis is 128 minus half the width of the hand.
If you want to change the position of a hand then (after you applied the formula above) try different values of x- and y-axis in Position until they meet your intented place.
For the color look into poyensa's guide. For rotation to a constant position see under lua script.
These are only tips. Most of the time they are working, sometimes you have to do it by trial and error.
​

Modifications of the lua script/functions
lua script 1EC5924B_manila (former 461d3306_manila)
This file is responsible for the animations of the analog clock. It's a HTC lua script. HTC's version of lua is not documented. So if you want to mod manila lua scripts you should have some basic knowledge in coding. I'm at best clumsy. I didn't find for example a solution to bring the numerical value of the calendar day to a string on the screen (EDIT: Problem solved with the help of co0kie). So I went around to the classical mechanical approach with two disks. So there is still room for some useful inventions. For start look at this general lua programming guide . Another good resource ist the source code of Co0kies Home Tab. It's published at the end of this post.
For compiling and decompiling I used m9editor. If you in the lower part of the editor click right at the lua script manila file, you can decompile the file and save it in the lua script subfolder of the editor. There you can change it with Notepad2 (by Florian Balmer, compiled by Co0kiemonster). It is part of this kitchen. But because m9editor sometimes had problems with decompiling I used essentially the homealarmclock.lua from co0kie's source. After that once more click right on the 1EC5924B_manila file in the m9editor and compile the manila file.
functions
For every function in lua there are three essential parts: the definition of the function, the calling of the function and the update of the calling. In the HTC lua scripts these parts are typically not in sucession for each function but combined in blocks for all functions (at first all definitions and so on).
Tourbillon Cage/ second hand
In the original file by co0kie the query of the position of minute and hour hand was triggered by a change of the value of the minute. So the minute hand jumps every minute, the hour hand moves continously. The position of the second hand was determind by an own function triggered by a timer every second.
For the Tourbillon it was necessary to use milliseconds. HTC ROMs don't work with milliseconds (although windows mobile provides it). So this has to be made by a timer function. Here a tip by Co0kie:
Code:
MyTimerName = timer(time_in_seconds) -- the time can be 0.1 seconds for example
-- after the timer is created it immediately starts ticking
MyTimerName.OnElapsed:connect(some_function) -- the name of the function that should be called after timeout - the timer runs in a loop so the function will be called every 0.1 seconds
MyTimerName:Stop() -- stops the timer
MyTimerName:Start() -- starts it again
In the new function "ClockSecond" the cage (secondHand) makes five steps every second. This factor five I defined as FinenessFactor, so it can be changed very simple. The distance is every step 12° (really depending on the FinenessFactor), so the Cage turns once every minute and can be used as second hand.
The ClockSecondTimer = timer(0.2) in line 192 determines the period between two steps. The function starts every second with the new position, so the timer value should be 1 second / FinenessFactor for continous moving
rotation is realized with the function XXX.Rotation.z =
360 - myHandsPosition in clockwise direction
myHandsPosition against clockwise direction
The value of myHandsPosition is the numerical value of the ° position
Code:
SecondsCheck = machineStatus.CurrentTime.Value.Second
Counter = 1
ClockSecond = function()
if secondHand._visible == true then
local FinenessFactor = 5
local globalsecond = machineStatus.CurrentTime.Value.Second
local myHandsPosition0 = globalsecond * FinenessFactor
if SecondsCheck == globalsecond then
myHandsPosition0 = globalsecond * FinenessFactor + Counter
Counter = Counter + 1
else
Counter = 1
end
local myHandsPosition = (myHandsPosition0 - (2 * FinenessFactor) + 1) / (60 * FinenessFactor) * 360
secondHand.Rotation.z = 360 - myHandsPosition
secondHand1.Rotation.z = 360 - myHandsPosition
secondHandnight.Rotation.z = 360 - myHandsPosition
SecondsCheck = globalsecond
minuteHand.Rotation.z = -((machineStatus.CurrentTime.Value.Minute / 60 * 360) + ((machineStatus.CurrentTime.Value.Second - 5) / 10))
minuteHandnight.Rotation.z = -((machineStatus.CurrentTime.Value.Minute / 60 * 360) + ((machineStatus.CurrentTime.Value.Second - 5) / 10))
else
ClockSecondTimer:Stop()
end
end
balance wheel (secondhand2)
function "ClockSecond2". The balance wheel has not the same behavior as the other "hands". It swings with 5 (= FinenessFactor2) frames 180° back and forth. Crucial for the speed (and the frequency of queries) is the ClockSecond2Timer = timer(0.04) in line 194. At present it realizes 25 frames per second, a value 0.1 is only 10 fps (I attached a 1EC5924B_manila/461d3306_manila with this value in post 30) . This is the most CPU power and energy consuming process in the clock, but also the most visible.
Code:
Counter2 = 0
turn2 = 0
ClockSecond2 = function()
if secondHand._visible == true then
local FinenessFactor2 = 5
local myHandsPosition2 = 360
if turn2 == 0 then
myHandsPosition2 = 360 - ((360 / FinenessFactor2) * Counter2)
if Counter2 == FinenessFactor2 then
turn2 = 1
Counter2 = 0
end
else
myHandsPosition2 = (360 / FinenessFactor2) * Counter2
if Counter2 == FinenessFactor2 then
turn2 = 0
Counter2 = 0
end
end
Counter2 = Counter2 + 1
secondHand2.Rotation.z = 360 - myHandsPosition2
secondHand2night.Rotation.z = 360 - myHandsPosition2
else
ClockSecond2Timer:Stop()
end
end
The calling of both functions for the tourbillon with update:
Code:
if ShowSecondHand then
secondHand._visible = true
ClockSecondTimer = timer(0.2)
ClockSecondTimer.OnElapsed:connect(ClockSecond)
ClockSecond2Timer = timer(0.04)
ClockSecond2Timer.OnElapsed:connect(ClockSecond2)
else
secondHand._visible = false
secondHand1._visible = false
secondHandnight._visible = false
secondHand2night._visible = false
end
second hand (secondHand3)
It is bound to the movement of the Tourbillon cage. See code above
minute hand
function "ClockMinute". For continous moving every second a 1/60 of a minute step is added.
Code:
minuteHand.Rotation.z = -((machineStatus.CurrentTime.Value.Minute / 60 * 360) + ((machineStatus.CurrentTime.Value.Second - 5) / 10))
calendar day by disks
The disk for the tens (DateDayTens) turns every ten days for 90°, the disk for the ones (DateDayOnes) every day for 36°. (Don't be afraid for month with days lower than 30, it is in the formula). It checks at the change of the current time value of windows mobile.
Code:
CalendarDate1 = function()
local locday = machineStatus.CurrentTime.Value.Day
local DayTens = 0
local DayOnes = 1
if locday < 10 then
DayTens = 0
else
if locday < 20 then
DayTens = 1
else
if locday < 30 then
DayTens = 2
else
DayTens = 3
end
end
end
DayOnes = locday - (DayTens * 10)
DateDayTens.Rotation.z = DayTens * 90
DateDayOnes.Rotation.z = DayOnes * 36
DateDayTensnight.Rotation.z = DayTens * 90
DateDayOnesnight.Rotation.z = DayOnes * 36
end
Code:
CalendarDate1()
Code:
machineStatus.CurrentTime.OnValueChanged:connect(CalendarDate1)
calendar day by text object
Code:
CalendarDate1 = function()
local locday = machineStatus.CurrentTime.Value.Day
DayDate.String = tostring(locday)
DayDate.Rotation.z = 330
local val = (AnalogAMPMColor / 10) * 255
DayDate.Color = Color(val, val, val, 255)
DayDatenight.String = tostring(locday)
DayDatenight.Rotation.z = 330
end
In this example the color of DayDate is bound to the color of AMPM. So you can set in CHT Editor also the color of the Date. The calling and the update is the same as above.
If you want a constant rotated position for an object simply add the line
XXX.Rotation.z = 360 - y
where XXX is the name of your object in the mode9 file and y the ° value ot the incline of your object
(example for AMPM in the above mentioned Hero clock "ShowAMPM.Rotation.z = 330")
moonphase
The mathematical formula for the moonphases is described at various astronomical websites. I took it from this Swiss site (at Berechnungen). The formula takes a date of a full moon and then counts the difference to the present day and divides this through the lunar month. The not integer part of the result describes the position of the moon.
Code:
local lochour = machineStatus.CurrentTime.Value.Hour
local locday = machineStatus.CurrentTime.Value.Day
local locmonth = machineStatus.CurrentTime.Value.Month
local locyear = machineStatus.CurrentTime.Value.Year
local valueYear = 365 * (locyear - 2010)
if locyear > 2011 then
if locyear > 2016 then
valueYear = valueYear + 2
else
valueYear = valueYear + 1
end
end
local valueMonth = 0
if locmonth == 2 then valueMonth = 31 end
if locmonth == 3 then valueMonth = 59 end
if locmonth == 4 then valueMonth = 90 end
if locmonth == 5 then valueMonth = 120 end
if locmonth == 6 then valueMonth = 151 end
if locmonth == 7 then valueMonth = 181 end
if locmonth == 8 then valueMonth = 212 end
if locmonth == 9 then valueMonth = 243 end
if locmonth == 10 then valueMonth = 273 end
if locmonth == 11 then valueMonth = 304 end
if locmonth == 12 then valueMonth = 334 end
if locyear == 2012 then
if locmonth > 2 then valueMonth = valueMonth + 1 end end
if locyear == 2016 then
if locmonth > 2 then valueMonth = valueMonth + 1 end end
local presentday = (lochour / 24) + locday + valueMonth + valueYear
local moonposition1 = (presentday - 30.25) / 29.530588
moonphase.Rotation.z = - ((moonposition1 - math.floor(moonposition1)) * 180)
moonphasenight.Rotation.z = - ((moonposition1 - math.floor(moonposition1)) * 180)
end
Code:
moonposition()
Code:
machineStatus.CurrentTime.OnValueChanged:connect(moonposition)
day of week
This function takes the first (here two letters) of your date string.
Code:
DayOfWeek1 = function()
local weekday1
weekday1 = machineStatus.CurrentTime.Value:GetDateString(Locale:GetString("IDS_DATEFORMAT"))
weekday1 = string.sub(weekday1, 1, 2)
weekday.String = tostring(weekday1)
weekdaynight.String = tostring(weekday1)
end
Code:
DayOfWeek1()
Code:
machineStatus.CurrentTime.OnValueChanged:connect(DayOfWeek1)
For another approach with three letters you have to subtitute the lines
Code:
weekday1 = machineStatus.CurrentTime.Value:GetDateString(Locale:GetString("IDS_DATEFORMAT"))
weekday1 = string.sub(weekday1, 1, 2)
with
Code:
weekday1 = machineStatus.CurrentTime.Value:GetDateString(Locale:GetString("dddd"))
weekday1 = string.sub(weekday1, 1, 3)
visibility
Visibility depends on the hour value of the clock. That's a problem with the 12h use in AMPM Regions. So you have to transform all values to 24h. This happends in the first part of the function. In the second part the opacity of the "night objects" is determined in a definite time intervall. A special case in this code example are objects which can be made unvisible by settings in CHT or Windows Mobile. For the animation functions I found some tips in the attached animation toolkit for CHT 1.6.1 by Co0kie.
Code:
switchvisibility = function()
local locAMPM = machineStatus.CurrentTime.Value:GetTimeString("tt")
local lochour = machineStatus.CurrentTime.Value.Hour
if locAMPM == "AM" then
ShowAMPMnight.String = "AM" else
ShowAMPMnight.String = "PM" end
if machineStatus.CurrentTime.Value.IsTwentyFourHour
then
local lochour = machineStatus.CurrentTime.Value.Hour
else
if locAMPM == "AM" then
if lochour == 12 then lochour = 0
end
else
if lochour ~= 12 then lochour = lochour + 12
end
end
end
if lochour > 7
then
if lochour < 20 then
minuteHandnight.Opacity:Interpolate(0,200, 0, Interpolate_Linear)
hourHandnight.Opacity:Interpolate(0, 200, 0, Interpolate_Linear)
analogclocknight.Opacity:Interpolate(0, 200, 0, Interpolate_Linear)
moonphasenight.Opacity:Interpolate(0, 200, 0, Interpolate_Linear)
if secondHand._visible == true then
secondHandnight.Opacity:Interpolate(0, 200, 0, Interpolate_Linear)
secondHand2night.Opacity:Interpolate(0, 200, 0, Interpolate_Linear)
end
if machineStatus.CurrentTime.Value.IsTwentyFourHour then
ShowAMPMnight._visible = false
else
ShowAMPMnight.Opacity:Interpolate(0, 200, 0, Interpolate_Linear)
end
weekdaynight.Opacity:Interpolate(0, 200, 0, Interpolate_Linear)
DayDatenight.Opacity:Interpolate(0, 200, 0, Interpolate_Linear)
else
minuteHandnight.Opacity:Interpolate(100,200, 0, Interpolate_Linear)
hourHandnight.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
analogclocknight.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
moonphasenight.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
if secondHand._visible == true then
secondHandnight.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
secondHand2night.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
end
if machineStatus.CurrentTime.Value.IsTwentyFourHour then
ShowAMPMnight._visible = false
else
ShowAMPMnight.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
end
weekdaynight.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
DayDatenight.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
end
else
minuteHandnight.Opacity:Interpolate(100,200, 0, Interpolate_Linear)
hourHandnight.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
analogclocknight.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
moonphasenight.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
if secondHand._visible == true then
secondHandnight.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
secondHand2night.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
end
if machineStatus.CurrentTime.Value.IsTwentyFourHour then
ShowAMPMnight._visible = false
else
ShowAMPMnight.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
end
weekdaynight.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
DayDatenight.Opacity:Interpolate(100, 200, 0, Interpolate_Linear)
end
end
Code:
switchvisibility()
Code:
machineStatus.CurrentTime.OnValueChanged:connect(switchvisibility)
I hope this description will help you to understand a little bit the modifications and maybe to make yourself some examples. You can also mod or delete the indivual modifications. I'm open for improvements and simplifications.

files and templates
I hope the description in the above posts will help you to understand the modifications. I add the manila lua script, the manila files and the png files as zip. The Reference clock can be found in post 1.
For all who are about to despair because of compiling I made some templates. The first zip contains various versions of the compiled lua script and if necessary the mode9 file. You can get:
jumping minute/continous minute,
jumping second/continous second,
without date/ with date (as text object) not inclined, inclined 15°, inclined 30°,
12h/24h (the 24h modus works only with 24h settings).
The position and the colour of the objects can be changed in the mode9 file like described above.
The second Template zip contains a new reference clock with some basic modifications - continous minute and second, date as text object - and changing visibility for all objects (including AMPM). For the pictures I took my carbon clock but they can be changed by you as you like. Tip: If you wouldn't change some objects, take the same picture for day and night object. The text object DayDate could be "hidden" behind the clock background by repositioning in the mode9 file. So you have only to change the mode9 file.

Really nice job!

installed orig cab over orig CHT clock reset and all I got was a second hand added to CHT orig but quite abstact ?

really nice!

Really nice clock and you also made the second hand, date and AM/PM working which is something nobody had made yet. Great job

great work you are the best man

11calcal said:
installed orig cab over orig CHT clock reset and all I got was a second hand added to CHT orig but quite abstact ?
Click to expand...
Click to collapse
In this cab are the original CHT manila files. Can you post a screenshot?

THANKs for the Good WRK

11calcal said:
installed orig cab over orig CHT clock reset and all I got was a second hand added to CHT orig but quite abstact ?
Click to expand...
Click to collapse
Sorry, didn't saw the edit. You used a modificated 7c60907d_manila file (thats why the changed position of the second hand). Sometimes if you installed a cab without deactivating HTC Sense and a file is in use, then this file is not copied. Try this: Deactivate Sense and install the original cab once more, than activate Sense.
Or install the attached cab for the original file.

WOW, this is getting real awesome man. Thanks

The BEST CLOCK MADE FOR COOKIE HT SO FAR
And the first clock which forced me to enable the SECOND HAND
Well Done Mate.........

Steve0007 said:
Really nice clock and you also made the second hand, date and AM/PM working which is something nobody had made yet. Great job
Click to expand...
Click to collapse
I agree....
+1
----------------------
EDIT: After testing the clock, the second hand and the lower gear still get stuck and still after waking the phone up ................

jaguaralani said:
I agree....
+1
----------------------
EDIT: After testing the clock, the second hand and the lower gear still get stuck and still after waking the phone up ................
Click to expand...
Click to collapse
Thats right. The clock is very depending of other processes. Especially till the calendar is fully open there is a delay. Other point are the turning of the minute (with all the animations) or activesync. Sorry I tried to minimize this but thats the best solution I found.

CPU load.
Wonderfull clock.
But it takes 70% of my HD2 CPU when i am on "Home". I check this using BattClock v2.1.2.
I am afraid that it will drain battery. I'll monitor and let you know.
Congratulation for this.

emottier said:
Wonderfull clock.
But it takes 70% of my HD2 CPU when i am on "Home". I check this using BattClock v2.1.2.
I am afraid that it will drain battery. I'll monitor and let you know.
Congratulation for this.
Click to expand...
Click to collapse
That's the second disadvantage. It is power consuming because of the necessary processes in the background (please see later post 2). I noticed the same. But I think it is only when you use the home screen (f. e. for watching the clock), not in standby or at the use of other programs or functions. Can you please post your experiences? Thanks

Related

Add leading 0 (zero) on lockscreen clock

Hi guys - Happy New Year.
Can anyone tell me how to add a leading '0' (zero) to the lockscreen clock?
I have used a large number of lockscreens, NONE of them have a leading zero. I am using 24hour time. I have the leading zero on the home tab, and on the top taskbar menu. I cannot seem to get it on the lockscreen.
eg: Lockscreen shows 8:00. I want 08:00.
Thanks in advance.
PS - I can get the zero with lockscreen widgets in CHT2. BUT I want it without any widget add ons.
Try Start-Settings-System-Regional Settings-Time [Page]-Time style HH:mm:ss
hgalanos said:
Hi guys - Happy New Year.
Can anyone tell me how to add a leading '0' (zero) to the lockscreen clock?
I have used a large number of lockscreens, NONE of them have a leading zero. I am using 24hour time. I have the leading zero on the home tab, and on the top taskbar menu. I cannot seem to get it on the lockscreen.
eg: Lockscreen shows 8:00. I want 08:00.
Thanks in advance.
PS - I can get the zero with lockscreen widgets in CHT2. BUT I want it without any widget add ons.
Click to expand...
Click to collapse
Thanks for your reply. I have changed the regional settings to:
hh:mm:ss and also
HH:mm:ss
Nothing happens. The flip clock stays without a zero.
If you are looking for lockscreen with leading zero try manals Windows LockScreen V4 http://forum.xda-developers.com/showthread.php?t=854047
with settings below it have leading zero for sure. (This is standard windows lockscreen modification, not CHT)
hgalanos said:
Thanks for your reply. I have changed the regional settings to:
hh:mm:ss and also
HH:mm:ss
Nothing happens. The flip clock stays without a zero.
Click to expand...
Click to collapse
The Touch x 24 hours clock fixes the alarm and lockscreen so they now appear as 08:00.
However nothing I have tried works for the home screen flip clock.
Anyone?
Try reg:
[HKEY_LOCAL_MACHINE\nls\overrides]
"STFmt"="HH:mm:ss tt" // (Ex: 08:00 AM or 20:00 PM)
"SSDte"="dd-MM-yyyy" // (Ex: 08-01-2011)
Yep, already tried/checked that. It is as you wrote it.
ALL clocks are showing leading zero, just not Manila home flip clock. Very strange.
Surely there is a way to change it.
hgalanos said:
Yep, already tried/checked that. It is as you wrote it.
ALL clocks are showing leading zero, just not Manila home flip clock. Very strange.
Surely there is a way to change it.
Click to expand...
Click to collapse
It will be controlled by the LUA script for the CHT main clock (assuming it is the main one with various flip/analog/weather options. I'll have a look over the weekend if you like?
Would I be safe in assuming you've already gone to the manila settings tab, date & time and then ticked 24-hour format?
Swarvey said:
Would I be safe in assuming you've already gone to the manila settings tab, date & time and then ticked 24-hour format?
Click to expand...
Click to collapse
Yes you would be safe in assuming this.
As per the ealier threads, time format, local settings have all been checked and changed. Even the registry. Nothing changes the flip clock have a leading zero.
Depending on what version of cht or sense you have it will be in the lua. There should be a statement near the top that says "shouldhideleadingzeros = true" you just need to change it to false and recompile.
EDIT:
Looked into it a little more for you and the file is 5fa4d4b7_manila from your stock sense.
Code:
-- Decompiled using luadec 3.2.2beta -- Tue Jan 11 10:19:35 2011
-- File name: 5fa4d4b7_manila
trace("Loaded digital clock\n")
TabHalf = {Tab = nil, HighDigit = nil, LowDigit = nil}
UV = {UP = 0.26171875, DOWN = 0.5234375}
TabHalf.new = function(l_1_0, l_1_1)
if not l_1_1 then
l_1_1 = {}
end
setmetatable(l_1_1, l_1_0)
l_1_0.__index = l_1_0
return l_1_1
end
TabFlip = {Time = 0, TimeDifference = 0, ShowingTime = 0, WrapAroundNumber = 0, StartValue = 0, [B][COLOR="Red"][B]ShouldHideLeadingZeros = true[/B][/COLOR][/B], TopTab = nil, TopTabFlip = nil, BottomTab = nil, BottomTabFlip = nil, LastDuration = -1, UseAltTiming = false, rotatecount = 1, getDuration = function(l_2_0)
if l_2_0.UseAltTiming then
Wow, I have stock version of 1.72 WWE ROM.
It sound like you are on a winner.
I will check this out tonight when I get home and see what I can do.
Thank you for the information, I will be sure to let you know what happens.
mrhayami said:
Depending on what version of cht or sense you have it will be in the lua. There should be a statement near the top that says "shouldhideleadingzeros = true" you just need to change it to false and recompile.
EDIT:
Looked into it a little more for you and the file is 5fa4d4b7_manila from your stock sense.
Code:
-- Decompiled using luadec 3.2.2beta -- Tue Jan 11 10:19:35 2011
-- File name: 5fa4d4b7_manila
trace("Loaded digital clock\n")
TabHalf = {Tab = nil, HighDigit = nil, LowDigit = nil}
UV = {UP = 0.26171875, DOWN = 0.5234375}
TabHalf.new = function(l_1_0, l_1_1)
if not l_1_1 then
l_1_1 = {}
end
setmetatable(l_1_1, l_1_0)
l_1_0.__index = l_1_0
return l_1_1
end
TabFlip = {Time = 0, TimeDifference = 0, ShowingTime = 0, WrapAroundNumber = 0, StartValue = 0, [B][COLOR="Red"][B]ShouldHideLeadingZeros = true[/B][/COLOR][/B], TopTab = nil, TopTabFlip = nil, BottomTab = nil, BottomTabFlip = nil, LastDuration = -1, UseAltTiming = false, rotatecount = 1, getDuration = function(l_2_0)
if l_2_0.UseAltTiming then
Click to expand...
Click to collapse
ok so I couldn't wait and though I would give it a go now. I have found the same Manila file you have listed, I also downloaded lua utility. How doesn this work, I ran it on my pc and nothing happens.
How can I edit the file?
hgalanos said:
ok so I couldn't wait and though I would give it a go now. I have found the same Manila file you have listed, I also downloaded lua utility. How doesn this work, I ran it on my pc and nothing happens.
How can I edit the file?
Click to expand...
Click to collapse
Well I suggest downloading the manila kitchen by 12 and kilaireg found here:
Thread
It will tell you how to run everything you need but the down and dirty is this.
Copy the manila file into this directory "kitchen>_source>file>xxxx_manila
then use the command prompt link and drag the file manilatool.cmd into the cmd window.
your main commands are going to be as followed in order:
-oem:2.5
-mnf:2.5
-dec
(now that it is decompiled you will be edit the lua in notepad save and then move to the next step.)
Notice: not all files will decompile correctly and you may have to tweak it to get it to decompile correctly.
-cmp (only if it does not fully decompile aka. you have the file in your incomplete folder.)
-rec (will recompile the file which you can then put on your device and enjoy)
I know it isn't much but as I said they have detailed info in the pack.
In case anyone is still trying to figure this out.
I installed the latest 314 WWE ROM and it supports a leading zero on the original manila clock.
Awesome.
hgalanos said:
Hi guys - Happy New Year.
Can anyone tell me how to add a leading '0' (zero) to the lockscreen clock?
I have used a large number of lockscreens, NONE of them have a leading zero. I am using 24hour time. I have the leading zero on the home tab, and on the top taskbar menu. I cannot seem to get it on the lockscreen.
...
Click to expand...
Click to collapse
If you set PocketShield clock display to 24h it will display the leading 0
NO fix as yet.
Guys,
I have to apologise, I don't know what planet I was on, but the new 314 ROM, does NOT fix this issue. There is still no leading zero for manila flip clock.
Anyway have a fix that works?
I have no idea how to edit manila files, and have not been successful is doing so.
I will have to rely on someone generous enough to do it for me.
Thank you in advance to anyone willing to help.

[Q] glReadPixels() Problem in Android to reconstruct the frame

I am working on a project on Augmented Reality with Android. The code captures the camera video, finds the marker and displays a cube on top of it. After this a motion vector (in the form of pixels moved in the x and y direction) is found. What I need to do is read the pixels from the GL layer and draw them again after moving them by the distance specified by the motion vector.
The GL layer is specified using the GLSurfaceView class which is a transparent layer. The problem I am facing is that when I use glReadPixels() to read the pixels and convert it into a 480x800 array (nexus one screen resolution), I get 3 different portions of the cube instead of one.
I intend to move the pixels by the motion vector after this and use glDrawPixels() to put the pixels back into the frame buffer
Please help me with the interpretation of the same. Is there something I am missing while using glReadPixels and also if there is some other function that will help me achieve the same. I was thinking of using glBlitFrameBuffer() but this is not supported by the android GL10 class.
I have attached the part of the code where I am reading the pixels and changing them to a 2D matrix along with the image of the pixels I reconstructed using MatLab.
Any help will be greatly appreciated.
Code:
gl.glPixelStorei(GL10.GL_PACK_ALIGNMENT, 1);
IntBuffer pixels = IntBuffer.allocate(384000);
gl.glReadPixels(0, 0, 800, 480, GL10.GL_RGBA, GL10.GL_UNSIGNED_BYTE ,pixels);
File f = new File ("./mnt/sdcard/Sahiba_PixelData_" + flag + ".txt");
if(!f.exists())
f.createNewFile();
FileWriter fw = new FileWriter(f);
int pixelsArr [][] = new int [480][800];
//int temp[] = pixels.array();
int n=0;
for(int i=0; i<480; i++){
for(int j=0; j<800; j++){
pixelsArr[i][j] = pixels.get(n);
//temp[n + pixels.arrayOffset()];
fw.write(pixelsArr[i][j] + " ");
//fw.write(pixels.get(n) + " ");
n++;
}
//fw.write("\n");
}
Log.i("GLLayer", "Pixels reading and storing finished !!!");
}catch(Exception e){
Log.i("GLLayer","Exception = " +e);
}

Rounding down a float two decimal places

I have an equation that gives a decimal value. However I would like the final value to be rounded down only showing the first two decimal places. What would be the best function to achieve this.
Code:
String number,percentage;
Float calc;
percentage = ABV.getText().toString();
number = quantity.getText().toString();
calc = Float.parseFloat(number)* drinkType * Float.parseFloat(percentage)/1000;
units.setText(calc.toString());
MattD00 said:
I have an equation that gives a decimal value. However I would like the final value to be rounded down only showing the first two decimal places. What would be the best function to achieve this.
Code:
String number,percentage;
Float calc;
percentage = ABV.getText().toString();
number = quantity.getText().toString();
calc = Float.parseFloat(number)* drinkType * Float.parseFloat(percentage)/1000;
units.setText(calc.toString());
Click to expand...
Click to collapse
This can be achieved in several ways..
--- First thing that comes to mind:
calc = calc * 100;
calc = Math.round(calc);
calc = calc / 100;
It should be the simplest and cpu-saving solution.
--- A different way, format your output string:
String output = String.format("%.01f", calc);
units.setText(output);
This is good if you need to leave untouched your float value (but note, 2nd digit may be rounded)
Btw, you should post in the proper section
MattD00 said:
I have an equation that gives a decimal value. However I would like the final value to be rounded down only showing the first two decimal places. What would be the best function to achieve this.
Code:
String number,percentage;
Float calc;
percentage = ABV.getText().toString();
number = quantity.getText().toString();
calc = Float.parseFloat(number)* drinkType * Float.parseFloat(percentage)/1000;
units.setText(calc.toString());
Click to expand...
Click to collapse
Where should I write this code? I am a Newbie. Please bear. Thanks in advance.

Zarch android conversion from linux

I posted this a while ago in the dell streak forum, but now owning a galaxy S3 and a Galaxy Tab 10.1 , I feel they would more than cope with this.. So I'm putting it to the field again..
Zarch!
One of my old time favourite pastimes as a teenager.. Basically defender in 3D..
I noticed someone has done a linux remake of it..
But how, if at all, can I install a .tar file to my Streak?? or how could it be modified to run??
Quoted as " maybe better known as "Virus" on the Commodore Amiga. Linux Zarch is one of the very few freely available 3D graphics games available for UNIX/Linux that offer a very decent performance without needing 3D hardware support. "
Hmm, NO 3D support required?? Sounds like a winner.... The archimedes was an ARM based Acorn machine..
Is there an emulator anywhere?? we could run frontier and tempest 2000 maybe too if there was...
Our massive screen would be a great home for this title!!
Does anyone have any constructive advice here please??
1987
"Zarch" was written in three months in 1987 by David Braben as a launch title on Acorn's Archimedes series of computers. Another game, "Lander" was bundled with the machine, which used a cut down version of the landscape from Zarch as a demonstration of the machine's power. It became synonymous with the Archimedes, since it was featured in almost every review of the machine, and is apparently still the best selling title of all time on the Archimedes. The game consisted of a weird craft flying over a rolling patchwork quilt landscape, and many other games since (Zeewolf etc) have copied this technique.
Zarch was exceedingly well reviewed at the time, as most other games were either 2D platformers, or wire-frame 3D - hence the now seemingly amazing tag line on the cover of ACE magazine (now Edge) SOLID 3D - the future of games? Zarch was reviewed with a score of 979 - the highest rating ACE had given at that time (and only subsequently bettered by Virus at 981)
1988
"Virus" built on Zarch and was published by British Telecom (under the Firebird name) for the Atari ST, Commodore Amiga, and IBM PC in 1988. It was an instant success as many people had seen "Zarch" on the Archimedes but had not been able to play it on the more popular computers of the time. "Virus" won "16 bit Game of the Year" at the Computer Industry's InDin awards of 1988 and was later (incredibly) ported to the Spectrum in the following year by Steve Dunn. Most magazines gave it their top rating, and it got the highest ever score of 981 in the industry's leading magazine "ACE".
Chris Sawyer (now of Rollercoaster Tycoon fame) did the PC port, and later went on to work on PC "Elite+" and PC "Frontier: Elite II".
Zarch and Virus very much raised the ante for games on the 16 bit platform. It was one of the first solid 3D games. It was the first to have 3D lighting effects and shadowing. In fact it generated the shadow silhouettes on the fly - also a first.
1998
"V2000" is the sequel to Virus. It was published by Grolier Interactive on PC and Playstation in October 1998 and was very well reviewed (PC Zone Classic 90%, and five full pages in Edge magazine). It then went on to be one of only three nominees for best game of the preceding few years in the first BAFTA Awards in 1998.
In V2000 the player has to save 30 worlds from a virus menace that has infected them, and from the creatures that brought this virus. The game very much shows it's traditional gaming heritage in that the later worlds are very difficult to complete, but contain a feast of novel game play features. There has been some criticism of the difficulty, but also huge praise from hard-core gamers.
And for those that forgot....
http://www.youtube.com/watch?v=ALfnZjCiuUQ
That's the original archimedes footage
and this is the Linux tar
http://thom.best.vwh.net/zarch-0.92.tar.gz
I truly hope this inspires someone to get involved in converting this
I have the code for a working prototype in DBpro
as follows..
`PRESS SPACE TO:
`on LHS of screen, draw objects in dword space.
`on RHS, draw them with positions relative to "player" position
`check that player position loops around right.
sync on
sync rate 60:skipsyncmode=0:set display mode desktop width(),desktop height(),32,1 `STANDARD MODE
`sync rate 30:skipsyncmode=1:set display mode 848,480,32,1 `FOR YOUTUBE VID CAPTURE
autocam off
hide mouse
backdrop on:color backdrop 0
set camera aspect 1.66667
dim thing_posx(100) as dword
dim thing_posz(100) as dword
dim thing_color(100) as dword
for t=1 to 100
thing_posx(t)=rnd(255)<<24 `256=2^8 , 8+24=32
thing_posz(t)=rnd(255)<<24
`thing_color(t)=0xFF000000 OR rgb(rnd(255),rnd(255),rnd(255))
thing_color(t)=rgb(rnd(255),rnd(255),rnd(255))
next t
thing_color(0)=0xFFFFFF00 `make sure "player" is visible!
`now add terrain array (ground heights)
dim map_height(1023,1023) `whole map is 1024 square
dim map_tile(1023,1023) as byte `only need 4 values
for a=0 to 1023
for b=0 to 1023
`map_height(a,b)=rnd(255) `used rnd(255) so can easily get colour out if want to draw heightmap
map_height(a,b)=0.3* (rnd(50) +100*cos(50*a) +50*cos(40*a +50*b))
map_tile(a,b)=1+rnd(3) `tiles are numbered from 1-4
map_tile(a,b)=1+rnd(2) `no red
next b
next a
`make a square "launchpad", virus style.
for a=0 to 7:for b=0 to 7: map_tile(a,b)=2: next b:next a
for a=1 to 7:for b=1 to 7: map_height(a,b)=100.0: next b:next a
mat_divs=13 `13 squares - means that after cropping with box, 12x12 will be visible
mat_square_size=1<<22 `2^32 / 2^10, since whole world is dword (2^32) and divided into 1024x1024 squares.
subtract_factor=6*mat_square_size `(matrix size - mat square size)/2 =`6*mat square size
`subtract factor is taken from player position in order to find where from map array to take beginning corner of matrix from.
mat_view_size#=1000.0
conversion_factor#=mat_view_size#/(mat_square_size*12) `to convert from dword positions to float for positioning in DBP
`"real world" and rendering
mat_actual_size#=mat_view_size#*(13.0/12.0)
make matrix 1,mat_actual_size#,mat_actual_size#,13,13
`position matrix centrally.
position matrix 1,-0.5*mat_actual_size#,0.0,-0.5*mat_actual_size#
`load image "test2.bmp",1repare matrix texture 1,1,1,1
draw_mat_tex() `for no media
`load image "test3a.bmp",1
prepare matrix texture 1,1,2,2 `2 by 2 mat tex.
`set matrix trim 1,0.01,0.01 `prevent tex bleeding due to filtering
set matrix texture 1,2,0 `no mipmap. stops adjacent matrix tiles (on tile map) bleeding into eachother
`downside is that lines look ugly
set matrix 1,0,1,0,0,0,0,0
`position camera above it so can see it. will be repositioning camera every frame anyway.
`position camera 0,1000,0oint camera 0,0,0
`fill mat with info to check it's viewable
for a=0 to 13
for b=0 to 13
set matrix height 1,a,b,map_height(a,b)
next b
next a
update matrix 1
`box object to disguise edges moving
make object box 100,mat_view_size#,-10.0*mat_view_size#,mat_view_size#
`single_pixel_image(100,50,0,0,200)
single_pixel_image(100,0,0,0,255)
texture object 100,100
set object 100,1,3,1,0,0,0,0
`player (red ball on ground)
make object sphere 1,20
single_pixel_image(2,255,0,0,255)
texture object 1,2
`make some other objects positioned near to the player.
single_pixel_image(101,100,100,100,255)
for t=1 to 20
thing_posx(t)=rnd(10*mat_square_size) + 10*mat_square_size
thing_posz(t)=rnd(10*mat_square_size)
`make object box 50+t,10,100,10
make object sphere 50+t,100
offset limb 50+t,0,0,50,0
texture object 50+t,101
next t
`make a skyscraper
t=20
thing_posx(t)=15*mat_square_size
thing_posz(t)=12*mat_square_size
delete object 50+t
wide#=4.0*mat_square_size*conversion_factor#
make object box 50+t,wide#,500,wide#
offset limb 50+t,0,0,200,0
texture object 50+t,101
`make a "virus" style ship object!
make object box 200,50,20,80
`ADD HELICOPTER BLADES AS A LIMB!
make object box 201,10,2,150
make mesh from object 201,201
add limb 201,1,201
delete mesh 201
rotate limb 201,1,0,90,0
make mesh from object 201,201
delete object 201
add limb 200,1,201
delete mesh 201
offset limb 200,1,0,25,0
speedx#=0.0
speedz#=0.0
speedy#=0.0
hi#=0.0
do
if keystate(35):helimode=1:totalthr#=thr# * defaultthrust#:endif `h for heli
`added line to set thrust is not really necessary.
`stops heli crashing when switch to heli mode.
if keystate(31):helimode=0:endif `s for ship
if helimode
turnsmooth#=50.0
defaultthrust#=0.35 `should make this vary - increase when get close to ground => auto terrain following
clickthrust#=0.5
thrustsmooth#=50.0
pointsmooth#=10.0
show limb 200,1 `show helicopter blades
text 0,100,"HELICOPTER MODE (press S for spaceship)"
else
turnsmooth#=10.0
defaultthrust#=0.0
clickthrust#=1.0
thrustsmooth#=1.0
pointsmooth#=1.0
hide limb 200,1
text 0,100,"SPACESHIP MODE (press H for helicopter)"
endif
`text 0,100,str$(helimode)
text 0,120,"THRUST="+str$(totalthr#)
`MOUSE TO TILT SHIP `t denotes target (am adding smoothing to get mx,mz from these)
tmx#=tmx#+mousemovex()
tmz#=tmz#-mousemovey()
msq#=tmx#*tmx#+tmz#*tmz#
m#=sqrt(msq#)
if m#>100.0
tmx#=(tmx#/m#)*100.0
tmz#=(tmz#/m#)*100.0
endif
mx#=curvevalue(tmx#,mx#,pointsmooth#)
mz#=curvevalue(tmz#,mz#,pointsmooth#)
`get length of this vector
msq#=mx#*mx#+mz#*mz#
m#=sqrt(msq#)
`draw circle with cursor in
circle 50,50,48
dot 50+(50.0/100.0)*mx#, 50-(50.0/100.0)*mz#
dot 50+(50.0/100.0)*tmx#, 50-(50.0/100.0)*tmz# ,0xFFFF0000 `red dot for target
ya#=atanfull(mx#,mz#)
rotate object 200,m#,ya#,0.0
`want to 1st rotate to get "spin"
`then rotate to tilt to thrust angle (from horizontal)
`then rotate to "point" in thrust direction (viewed from above)
`for obj on ground this is
`1st "spin"
`then ground slope elevation
`then slope direction.
`this works!!
tu#=curveangle(ya#,tu#,turnsmooth#)
rotate limb 200,0,0,wrapvalue(tu#-ya#),0
`helicopter blades
br#=wrapvalue(br#+10.0) `blade rotation
rotate limb 200,1,0,wrapvalue(br#-ya#),0
`movespeed=1<<23 `bitshift<< makes bigger! (this number can be anything)
movespeed=1<<18
inc thing_posx(0), -movespeed*(leftkey()-rightkey())
inc thing_posz(0), movespeed*(upkey()-downkey())
mc=mouseclick()
thr#=2000.0
`speedx#=0.95*speedx#+thr#*mx#*mc `small angle approximation!
`speedz#=0.95*speedz#+thr#*mz#*mc
targetthrust#=thr# * ( clickthrust#*mc + defaultthrust#)
totalthr#=curvevalue( targetthrust# , totalthr# , thrustsmooth# )
speedx#=0.95*speedx#+ totalthr# *mx#*(sin(m#)/m#)*(180.0/3.14) `NOTE THAT CAN INCORPORATE (180/PI) INTO THRUST CONSTANT
speedz#=0.95*speedz#+ totalthr# *mz#*(sin(m#)/m#)*(180.0/3.14) `FOR FEWER CALCULATIONS. ALSO SIN NEED ONLY CALC ONCE.
inc thing_posx(0),speedx#
inc thing_posz(0),speedz#
`speedy#=0.95*speedy# + conversion_factor#*thr#*mc*(180.0/3.14) - 1.0 `should use proper trig! last part is gravity
speedy#=0.95*speedy# + conversion_factor#*totalthr# *cos(m#)*(180.0/3.14) - 1.0
inc hi#,speedy#
pgridx=thing_posx(0)>>22
pgridz=thing_posz(0)>>22
`gridx=(thing_posx(0)-subtract_factor)>>22 `not player grid, but grid where want to start reading landscape info to matrix
`gridz=(thing_posz(0)-subtract_factor)>>22
`can also achieve this by using (playergrid-6) &&1023
gridx=(pgridx-6)&&1023
gridz=(pgridz-6)&&1023
`using bitshift to right 22, grid goes from 0-1023.
`1024=2^10 22+10=32 (bits in a dword!)
`should only update when grid square changes.
`after that maybe use shifting- maybe faster.
if last_gridx<>gridx or last_gridz<>gridz
for a=0 to 13
for b=0 to 13
set matrix height 1,a,b,map_height((a+gridx)&&1023,(b+gridz)&&1023)
next b
next a
for a=0 to 12
for b=0 to 12
set matrix tile 1,a,b,map_tile((a+gridx)&&1023,(b+gridz)&&1023)
next b
next a
update matrix 1
last_gridx=gridx
last_gridz=gridz
endif
`POSITION CAMERA USING "REMAINDER"
`cx=-2097152+ ( (thing_posx(0)-subtract_factor) && 4194303 ) `2^22 -1 . =0x4FFFFF ?!
`cz=-2097152+ ( (thing_posz(0)-subtract_factor) && 4194303 )
cx=-2097152+ ( thing_posx(0) && 4194303 ) `dur! subtract factor && ... =0
cz=-2097152+ ( thing_posz(0) && 4194303 )
camx#=conversion_factor#*cx `bit lame that are getting +ve and -ve values. perhaps should have mat corner at origin.
camz#=conversion_factor#*cz
`position camera camx#,1000,camz#-400oint camera camx#,0,camz# `down looking. with this no need for clip plane
position object 100,camx#,0,camz#
position object 1, camx#,ground_height(thing_posx(0),thing_posz(0) ),camz#
`position object 200, camx#,100,camz#
gh#=50.0+ground_height(thing_posx(0),thing_posz(0) )
if hi#<gh#:hi#=gh#:speedy#=0.0:endif `really should be some other speed if moving horizontally..
position object 200, camx#,hi#,camz#
position camera camx#,hi#,camz#-995oint camera camx#,hi#,camz# `horiz looking. AT PLAYER
set camera clip 0,1,0,0,camz#-0.5*mat_view_size#,0,0,1
`POSITION OTHER OBJECTS! should decide whether to show (are on visible matrix)
`do that later.
for t=1 to 20
dx=thing_posx(t)-thing_posx(0)
dz=thing_posz(t)-thing_posz(0)
`tx#=(conversion_factor#*dx) +camx#
`tz#=(conversion_factor#*dz) +camz#
tx#=conversion_factor#*(dx+cx) `equivalent to above
tz#=conversion_factor#*(dz+cz)
position object 50+t,tx#,ground_height(thing_posx(t),thing_posz(t) ),tz#
next t
text 0,140,"DWORD CO-ORDS="+str$(thing_posx(0))+","+str$(thing_posz(0))
text 0,150,"GRID CO-ORDS="+str$(gridx)+","+str$(gridz)
text 0,170,str$(screen fps())+" FPS"
`text 100,20,str$(conversion_factor#)
`OLD TEST THING ===========================================
IF SPACEKEY()
`DRAW DOTS TO SCREEN
box 0,50,256,50+256,0xFF000080,0xFF000080,0xFF000080,0xFF000080
for t=0 to 10
spx=thing_posx(t)>>24 `gets 0-255 (2^8)
spz=50+(thing_posz(t)>>24)
dot spx,spz,thing_color(t)
next y
`NOW DRAW WITH POSITIONS RELATIVE TO PLAYER!
box 300,50,300+256,50+256,0xFF000080,0xFF000080,0xFF000080,0xFF000080
for t=0 to 10
REMSTART
spx=300+((thing_posx(t)-thing_posx(0))>>24) `gets 0-255 (2^8)
spz=50+((thing_posz(t)-thing_posz(0))>>24)
REMEND
`put player in middle
spx=300+((thing_posx(t)-thing_posx(0)-(1<<31))>>24) `gets 0-255 (2^8)
spz=50+((thing_posz(t)-thing_posz(0)-(1<<31))>>24)
dot spx,spz,thing_color(t)
next y
ENDIF
`============================================================
if skipsyncmode
skipsync=1-skipsync
if skipsync then sync
else
sync
endif
loop
end
function ground_height(x as dword, z as dword)
xg=x>>22
zg=z>>22
xgp=(xg+1)&&1023
zgp=(zg+1)&&1023
rx=x && 4194303
rz=z && 4194303
fx#=rx / (1.0*4194304)
fz#=rz / (1.0*4194304)
`text 100,100,str$(fx#)+","+str$(fz#)
height#=(map_height(xg,zg)*(1.0-fx#)*(1.0-fz#) + map_height(xgp,zg)*fx#*(1.0-fz#) +map_height(xg,zgp)*(1.0-fx#)*fz# +map_height(xgp,zgp)*fx#*fz#)
`^^ simplified version : mat square is treated as surface formed by straight lines in x, and z direction when viewed from above,
`connecting the square polygon grid. that there are actually 2 flat triangles is ignored.
endfunction height#
function single_pixel_image(imagenum,red,green,blue,alpha)
#constant temp_memblocknum 1
make memblock temp_memblocknum,16
write memblock dword temp_memblocknum,0,1
write memblock dword temp_memblocknum,4,1
write memblock dword temp_memblocknum,8,32
write memblock dword temp_memblocknum,12,rgba(red,green,blue,alpha)
make image from memblock imagenum,temp_memblocknum
delete memblock temp_memblocknum
endfunction
`RGBA function by Aaron Miller
function rgba(r,g,b,a)
c = (a and 0xff) << 24 or ((r and 0xff) << 16) or ((g and 0xff) << 8) or (b and 0xff)
endfunction c
`FOR NO MEDIA
function draw_mat_tex()
create bitmap 1,256,256
box 0,0,128,128,0xFFDFDFDF,0xFFFFFFFF,0xFFFFFFFF,0xFFEFEFEF
box 0,128,128,256,0xFF808080,0xFF808080,0xFF707070,0xFF808080
box 128,0,256,128,0xFF484848,0xFF606060,0xFF505050,0xFF606060
box 128,128,256,256,0xFFFF4040,0xFFFF4040,0xFFFF4040,0xFFFF4040 `red tile. not currently used.
`graduated boxes. means can see seam between tiles even if same type
`should play with graduations for best effect. should i have opposite corners same colour?
`should all corners be different?
`lines
ink 0xFF606060,0
w=0 `width `CURRENTLY LINES SWITCHED OFF
box 0,0,w,256
box 0,0,256,w
box 0,128-w,256,128+w
box 128-w,0,128+w,256
box 0,256-w,256,256
box 256-w,0,256,256
ink 0xFFFFFFFF,0
get image 1,0,0,256,256
`save image "testx.bmp",1
delete bitmap 1
endfunction

[Q] [WM] 6.5.x taskbar height

Hello all,
Actually, this message should be posted in WM Dev&Hacking, but I'm a noob with less than 15 postings.
Does anyone know, how to change the top taskbar height in WM 6.5.x? Via the registry, programmatically (manipulating HWND) or even hacking ROM/Kitchen?
The initial height is 36px which is not enough for me. I don't care about icons, since they are replaced.
Wast I've done:
1. Searched the registry for '36' (decimal). No entries.
2. Tried the following code:
Code:
HWND h1 = ::FindWindow(NULL, _T("Desktop"));
::MoveWindow(h1, 0, 64, 480, 576, TRUE);
HWND h2 = ::FindWindow(_T("HHTaskBar"), NULL);
::MoveWindow(h2, 0, 0, 480, 64, TRUE);
There is a gap between the taskbar and the desktop not-painted.
Regards,

Categories

Resources