Allegro.cc - Online Community

Allegro.cc Forums » The Depot » My Sudoku is in Beta mode

This thread is locked; no one can reply to it. rss feed Print
My Sudoku is in Beta mode
DanielH
Member #934
January 2001
avatar

The game is now queued into the depot, but here it is for your use.

Download Page

There is a win32 binary and source code. If someone would like to create another version for me that would be great. I don't know how to create so's in Linux.

The language selection is still manual. You have to edit the ini file after you play the game the first time. I will make it apart of the options menu, but I forgot. Also , the game needs the language files updated with the new text. Which I cannot do myself.

I also forgot to add instructions to the game. I just realized that.

Short instructions: Put 1-9 into each row, column, and 3x3 square.

There are only two themes to choose from atm. One is a copy of the other, but with different color scheme. I needed at least two to work on the theme choose menu.

Please try it out and let me know of any bugs. I tried to find them all, but no program is bug-free.

(If you would like to finish a language file, send it to me either email or pm and I will get it into the zip file)

Derezo
Member #1,666
April 2001
avatar

Very well done! :)
I'm not much of a sudoku player, but that may change.. I've been meaning to get into it.

I noticed that you need these DLL files, though:
MSVCP71.DLL
MSVCP71D.DLL
MSVCR71.DLL
MSVCR71D.DLL

The files I linked to were taken off DLL-Files.com and I have no idea of their validity, but they worked for me. :)

"He who controls the stuffing controls the Universe"

miran
Member #2,407
June 2002

Quote:

I don't know how to create so's in Linux.

But I told you once already! Here's the generic makefile I use for compiling plugins for AMGC2:

1ifdef MINGDIR
2 CC = g++
3 FLAGS = -shared -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc -s -W -Wall -I../../src/
4 LIBS = -lalleg
5 EXT = dll
6else
7 CC = g++
8 FLAGS = -shared -s -fPIC -W -Wall -I../../src/
9 LIBS = `allegro-config --libs`
10 EXT = so
11endif
12 
13src = game.cpp
14 
15all: $(src)
16 $(CC) -o game.$(EXT) $(src) $(FLAGS) $(LIBS)

In short: gcc -o some.so some.c -shared -fPIC

--
sig used to be here

DanielH
Member #934
January 2001
avatar

A big thanks to miran for helping me out on that so problem. Miran, to let you know that I just needed to add the extern "C". When I messed with the path like you posted on the other post, I just kept getting errors. So I put it back to how I had it.

I got a Linux verison working on my machine, I would like to know if it will work on others. It's huge, 1.5Meg, because of static linking.

Web Page

If it doesn't work then please post the error codes.

miran
Member #2,407
June 2002

It works. But there are a few problems:

1. Any screen resolution other than 640x480 doesn't work. The game exits immediately without saying anything. It does that both if I change the resolution in-game and if I manually edit the ini file.

2. Language files don't work properly. That's because you use U_ASCII when in order to properly support more than a handfull of languages you should use U_UTF8 or something similar. Attached is a new Slovenian text file encoded with UTF-8. Btw, the extension should probably be si instead of sl.

3. The user interface is a bit laggy. Sometimes the mouse cursor gets stuck in one place for a fraction of a second and sometimes I have to click a button two or three times before it reacts. Could be a generic problem that Allegro programs have on Linux. I notice some other games too like to stutter once every few seconds.

4. I assume the binary is 32bit. While it works, I'd much rather have the full source (including headers and the generator and themes source) so I could compile my own 64bit version. Might solve problem #3.

EDIT: Regarding the international language support. I noticed that the themes have two fonts for printing text: large and small. The small one is good, it has 480 glyphs which include all the glyphs required by all European languages that use latin script. But the large font only has something like 224 glyphs and is missing many characters, including those required to display Slovenian text.

Btw, I noticed you do use U_UTF8 in game.cpp but perhaps you're manipulating strings with functions that are not unicode aware? You should always use Allegro's string functions, the ones prepended with a 'u'.

EDIT2: I did a little test. Loaded a string from a UTF-8 encoded file and displayed with your fonts. It turns out I had to call uconvert before it worked:

uconvert(stringFromTextFile, U_UTF8, stringForPrinting, U_ASCII, BUFFER_SIZE);

--
sig used to be here

DanielH
Member #934
January 2001
avatar

Can you show me how to load and convert a string from file?

uconvert(stringFromTextFile, U_UTF8, stringForPrinting, U_ASCII, BUFFER_SIZE);

Won't this convert a U_UTF8 to U_ASCII, which I don't want? Or do I?

Here is my get_string function. I needed to be able to process "\\","\n" into '\\','\n'. Any help would be appreciated.

1char *get_string( PACKFILE *pfile, char *string, int len )
2{
3 int index = 0;
4 int c = '\0';
5 
6 for ( int i = 0; i < len; i++ )
7 {
8 string[ i ] = '\0';
9 }
10 
11 if ( !pfile )
12 {
13 return string;
14 }
15 
16 while ( true )
17 {
18 c = pack_getc( pfile );
19 
20 if ( c == '\r' )
21 {
22 c = pack_getc( pfile );
23 }
24 
25 if ( c == EOF || c == '\n' )
26 {
27 break;
28 }
29 
30 if ( c == '\\' )
31 {
32 c = pack_getc( pfile );
33 switch ( c )
34 {
35 case 'n':
36 {
37 c = '\n';
38 } break;
39 case '\\':
40 {
41 c = '\\';
42 } break;
43 }
44 }
45 
46 string[ index++ ] = c;
47 }
48 
49 if ( need_uconvert( string, U_UTF8, U_CURRENT ) )
50 {
51 char stringBuffer[ 1024 ] = "";
52 uconvert( string, U_UTF8, stringBuffer, U_CURRENT, sizeof( stringBuffer ) );
53 ustrcpy( string, stringBuffer );
54 }
55 
56 return string;
57}

miran
Member #2,407
June 2002

Quote:

Can you show me how to load and convert a string from file?

My entire test program pasted below. Reads one line from text.si and prints it with both fonts from the theme dat files. Works as expected when the text file is UTF-8 encoded as long as required glyphs are found in the font.

1#include <allegro.h>
2 
3int main() {
4 set_uformat(U_UTF8);
5 allegro_init();
6 set_color_depth(32);
7 set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640,480,0,0);
8 install_keyboard();
9 FONT *f1 = load_font("textMenu.pcx", 0, 0);
10 FONT *f2 = load_font("text12.pcx", 0, 0);
11 PACKFILE *file = pack_fopen("text.si", "r");
12 char buf[256];
13 pack_fgets(buf, 256, file);
14 char testString[256];
15 uconvert(buf, U_UTF8, testString, U_ASCII, 256);
16 pack_fclose(file);
17 textprintf_centre_ex(screen, f1, SCREEN_W/2, SCREEN_H/2 - text_height(f1), -1, -1, testString);
18 textprintf_centre_ex(screen, f2, SCREEN_W/2, SCREEN_H/2 + text_height(f2), -1, -1, testString);
19 destroy_font(f1);
20 destroy_font(f2);
21 readkey();
22}
23END_OF_MAIN();

Quote:

Won't this convert a U_UTF8 to U_ASCII, which I don't want? Or do I?

It's confusing, I don't get it either, but it works.

--
sig used to be here

DanielH
Member #934
January 2001
avatar

Attached is what I have currently for the source. I also assume that the binary is 32bit. :) I have no idea.

However, I haven't done anything with the text routines. I changed the fonts to contain 480 glyphs each. Only the win32 binary has the new datafiles.

As for the graphics mode. When a mode is requested, the old one is saved. If the new one doesn't work then the old one is put back. I'll look into that. I didn't test that when I was running Linux. I have to reboot to check/test/fix it.

Go to: