Omnimaga

Calculator Community => HP Calculators => Topic started by: DJ Omnimaga on March 17, 2013, 11:33:27 pm

Title: HP 39gII grayscale tunnel clone
Post by: DJ Omnimaga on March 17, 2013, 11:33:27 pm
This is a crude Tunnel clone for the HP 39gII calculators and probably the first ever game ever made available for download for this calculator model outside of China. It's crude in the way that it was coded very quickly so it might need plenty of optimizing. I am new to programming this calc and probably won't do much of it due to how instable it is. :P

Because of how incredibly fast this calc is, this is why I manage to get such high framerate even with redrawing the entire screen rectangles and text every frame. This is the BASIC-like language available on-calc. The game is ridiculously big (9.1 KB), probably due to code not being tokenized and partly due to lack of optimizing.

Two particular features seen in this Tunnel clone are grayscale road and bolded text (which is much easier to do than on TI calcs because you can set the text background transparent).

It's available in source code since I am unable to get the linking softwares to work. Here's a Youtube video below:

Code: [Select]
EXPORT Tunnel()
BEGIN
1►C;
0►P;
35►Y;
20►T;
70►L;
0►L1(512);
FOR Z FROM 0 TO 16 DO
3-INT(RANDOM(2))►L1(2Z+1);
20-INT(RANDOM(4))►L1(2Z+2);
END;
RECT();INVERT();
FOR Z FROM 0 TO 2 DO
TEXTOUT_P("Score:",Z,0,2,3,50);
TEXTOUT_P("τ υ η η ε ι  39ǤII",142+Z,0,2,3,128);
END;
WHILE Y>0 DO
FOR Z FROM 0 TO 15 DO
C+1►C;
IF C>16 THEN
1►C;
END;
L1(2C+2)►O;
L1(2C+1)►Q;
RECT_P(16*Z,15,16*Z+15,O,0);
RECT_P(16*Z,O,16*Z+15,O+L,Q,Q);
RECT_P(16*Z,O+L,16*Z+15,126,0);
IF Z=0 THEN
RECT_P(0,Y,8,Y+12,0,3);
RECT_P(2,Y+4,14,Y+8,1,2);
IF Y<O OR Y+12>O+L THEN
−9►Y;
END;
END;
END;
TEXTOUT_P(P,46,0,2,3,48,0);
TEXTOUT_P(P,47,0,2,3);
P+1►P;
L1(2C+2)►S;
3-INT(RANDOM(2))►U;
S+INT(RANDOM(20)-10)►Ans;
IF Ans<15 THEN
15►Ans;
ELSE
IF Ans>120-L THEN
120-L►Ans;
END;
END;
C+1►C;
IF C>16 THEN
1►C;
L-1►L;
END;
Ans►L1(2C+2);
U►L1(2C+1);
Y-(5*ISKEYDOWN(9))+(5*ISKEYDOWN(15))►Y;
END;
FOR Z FROM 0 TO 5 DO
INVERT();
FOR Y FROM 0 TO 999 DO
END;
END;
RECT_P(0,15,256,126,0,0);
MSGBOX("SCORE: "+P,1);
END;



By the way if a staff could create an HP section in the downloads section it would be appreciated. :P Here's the misplaced file for now: http://www.omnimaga.org/index.php?action=downloads;sa=view;down=846

Title: Re: HP 39gII grayscale tunnel clone
Post by: Juju on March 17, 2013, 11:52:35 pm
Nice :D
Title: Re: HP 39gII grayscale tunnel clone
Post by: Matrefeytontias on March 18, 2013, 04:16:04 am
It's HP Basic btw ?

Also, even unoptimized, the thing is going at a reasonable speed I think ;)
Title: Re: HP 39gII grayscale tunnel clone
Post by: TIfanx1999 on March 18, 2013, 04:36:00 am
That's pretty awesome! :D I hope Hp gets around to releasing it stateside, it looks like it could be a very nice calc! :)
Title: Re: HP 39gII grayscale tunnel clone
Post by: TravisE on March 18, 2013, 06:18:50 am
That does sound ridiculously fast. :O I'm not sure UserRPL code on the HP 50g would even come near that speed redrawing everything every frame (though scrolling the screen and redrawing new pixel columns each frame should work nicely in SysRPL, I think). Games on the 50g are tricky if you're using RPL due to the annoying garbage collection “pause” that occurs every so often; you have to force it to occur more often (“GARBAGE” in SysRPL or “MEM DROP” in User), but doing it every frame noticeably slows down the frame rate. If you get lucky, you can do it every few frames and get decent speed without the animation looking too jerky, but it seems to depend on exactly what you're doing.

I'm not familiar with the 39 series (I get the impression it has a significantly different internal software design from the 50g, but I have no idea). I can't imagine what would cause that program to take 9KB—even the untokenized text isn't even 1KB. I know the 39s have some kind of unusual “app” system or something like that; perhaps the 9KB includes all the configuration for the current app or something like that? (In case anyone's curious, the 50g compiles user programs into SysRPL code; each command word normally takes about 2.5 bytes (20 bits) each.)
Title: Re: HP 39gII grayscale tunnel clone
Post by: DJ Omnimaga on March 18, 2013, 10:14:59 am
It's HP Basic btw ?

Also, even unoptimized, the thing is going at a reasonable speed I think ;)
Yup, or at least it's the on-calc language that looks like BASIC. :) No ASM nor C were used. At 17-20 MHz with low batteries, I still managed to get 3 FPS with 25 columns of rectangles (3 per column) appearing. In Casio BASIC this thing would take 1 minute per frame to render for sure. I can't imagine how fast it would get if this language had scrolling commands. O.O

However, making this game was a challenge because:

-I don't think this language supports screen shifting commands. To scroll, you have to redraw everything like I did. I could speed my tunnel up by drawing 2 rectangles by column, but then the tunnel would flicker a lot.
-There's no way to redim a list, so no possibility to just shift a list content around by concatenating it with an extra element then truncating the end.
-Matrices can be resized, but you can't concatenate them together.
-You need to add semicolon after most code lines, although that is rather common on computers languages.

As for the rest of the 39 series I think they're way less powerful than the 50g except maybe the 39gs, and very different from the 39gII. THe 39gII was really redone from scratch, uses different screen resolution and as a result its language seems much faster. However it uses the same ARM processor as the 50g I think.

Also I just checked the apps section and they seemed to use the RAM. I am not sure what does use the rest of the flash memory. As for the large program size, I heard it was due to using unicode characters but I'm not sure if this is why.
Title: Re: HP 39gII grayscale tunnel clone
Post by: TravisE on March 18, 2013, 12:38:51 pm
If they recoded the 39gII in C or in some language that compiles to ARM ASM, that would definitely explain why it seems so fast. The 50g is somewhat held back due to most of its OS being written in RPL, running in an interpreter written in Saturn ASM, running in a Saturn emulator written for the ARM. In many ways, it actually seems surprisingly fast despite the overhead (many operations are much faster than on the TI calculators with their native CPU OSes). Though, it is possible to write programs directly in Saturn ASM, ARM ASM, C, or whatever for the 50g—I haven't looked into that, and to be honest, I haven't really tried any games even though I've had this calc for several years already—always too busy coding my own stuff. :P
Title: Re: HP 39gII grayscale tunnel clone
Post by: Sorunome on March 18, 2013, 06:58:32 pm
Looking nice, is the 39gcll a new calculator by hp? It seems to have a lot of power :)
Title: Re: HP 39gII grayscale tunnel clone
Post by: DJ Omnimaga on March 18, 2013, 07:50:03 pm
I think I recall watching a video of HP 49 or 50g calcs graphing equations and was surprised at how slow it was considering how fast it was on TI. On the 39gII it's much faster.

The downside is still that the 39gII OS is really buggy. It's not as bad as 2.71MP, though, but enough to turn people away. :P
Title: Re: HP 39gII grayscale tunnel clone
Post by: TravisE on March 18, 2013, 09:16:56 pm
My 50g seems to graph sin(x) at roughly the same speed as my 89t, when both are set to the same plotting resolution. Fast3D beats the 89's 3D hands-down, though, when it comes to interactive rotation framerate. :) It's possible that older 49-series calcs might be slower, though; the old models with actual Saturn processors would be much slower, of course. It's also possible that various speed optimizations may have been made in the ROM code over time.

I'd be interested in seeing some videos of the 39gII graphing equations for comparison purposes.
Title: Re: HP 39gII grayscale tunnel clone
Post by: blue_bear_94 on March 18, 2013, 09:17:01 pm
Nice work!
Title: Re: HP 39gII grayscale tunnel clone
Post by: DJ Omnimaga on March 19, 2013, 03:42:46 pm
Thanks, and TravisE the HP 49g+, 50g and 39gII are all 203 MHz CPUs, clocked down to around 75 MHz. The 39gII, however, slows down even more if batteries are low. As for the original 49g it's a 4 MHz Saturn. There is also a HP 48gII, which clocks down the 203 MHz CPU to 48 MHz and isn't a 48g upgrade.
Title: Re: HP 39gII grayscale tunnel clone
Post by: DJ Omnimaga on March 30, 2013, 03:07:35 am
I finally found an update to the emulator and can now send most files to my calc or vice-versa! However to edit code from the computer I must keep a copy of the emulator open in order to save changes. It seems fairly recent, and according to a tibank rumor there is supposedly a new calc firmware coming out in May.

Anyway this allowed me to make screenshots! The first is animated, from the emulator (slowed down to calculator speed):
(http://img.removedfromgame.com/imgs/tunnel39gII.gif)

And the second one is a still image modified from an emulator capture, fixing the grayscale problems:
(http://img.removedfromgame.com/imgs/tunnel39gII.png)

http://www.omnimaga.org/index.php?action=downloads;sa=view;down=846
Title: Re: HP 39gII grayscale tunnel clone
Post by: Lionel Debroux on March 30, 2013, 03:50:55 am
HP seems to keep manufacturing "powerful" calculator hardware (severely sub-par compared to recent equipment from the real world, still), and that particular model's OS' BASIC provides screen drawing abilities, unlike the Nspire's BASIC :)
This demo is smooth enough, but such a CPU should be able to do better than this, even in BASIC.
Title: Re: HP 39gII grayscale tunnel clone
Post by: CompSystems on March 30, 2013, 01:05:32 pm
I finally found an update to the emulator and can now send most files to my calc or vice-versa!

What version of emulator?
My emulator:  2012 9 4 revision 18360
http://www.hpgraphingcalc.org/hp39gii.html

>>tibank rumor there is supposedly a new calc firmware coming out in May.

I hope dialog boxes similar to the TI-89 calculator, none calculator relaunched  dialog boxes (TI-Nspire, ClassPad etc) =(
Title: Re: HP 39gII grayscale tunnel clone
Post by: DJ Omnimaga on March 31, 2013, 12:11:16 am
Yeah that's the version I found yesterday. The one I had before was found on some third-party website, along with an unnoficial French HP store, and it dated back in May 2012. I couldn't find any newer version until last night.