IRC logs for #opendune on OFTC at 2010-02-01
            
03:37:24 *** glx has quit IRC
05:56:32 *** Frankr has joined #openDune
05:57:04 *** Frankr has left #openDune
08:27:11 <TrueBrain> morning
13:18:27 *** glx has joined #openDune
13:18:27 *** ChanServ sets mode: +o glx
13:18:53 <glx> hello
13:19:10 <TrueBrain> morning :)
13:19:22 <Xaroth> hello glx
14:15:06 <TrueBrain> Xaroth pointed out I can do a bit of C-ifying again :) :)
15:00:21 <Xaroth> :)
15:14:00 <DorpsGek> SVN: truebrain (r836) -Add: C-ified GUI_DrawWiredRectangle (and with that completing cs 251B)
15:14:02 <TrueBrain> blob
15:20:42 <Xaroth> :o
15:20:50 * Xaroth cheers
15:20:53 <Xaroth> another file bites the dust!
15:21:06 <TrueBrain> :p It was an too easy one :)
15:35:06 <TrueBrain> hmm
15:35:12 <TrueBrain> we never saved anything while in debugScenario mode
15:37:56 <glx> new stuff ?
15:38:07 <TrueBrain> I was converting the Save_Main
15:38:09 <TrueBrain> and noticed it
15:38:13 <TrueBrain> now .. how to make it trigger .. hmm ..
15:39:28 <TrueBrain> k, got it
15:41:18 <TrueBrain> it runs a nice amount of code ..
15:42:12 <TrueBrain> I don't feel like updating the JIT :p
15:57:39 <TrueBrain> uint16 loc02 = 0x4D52;
15:57:41 <TrueBrain> uint16 loc04 = 0x4F46;
15:57:44 <TrueBrain> emu_push(emu_ss);
15:57:46 <TrueBrain> emu_push(emu_bp - 4);
15:57:50 <TrueBrain> DANGER SIR ROBISON! DANGER!
16:03:24 <TrueBrain> @base 16 26 4d
16:03:24 <DorpsGek> TrueBrain: 2P
16:03:28 <TrueBrain> @base 256 26 4d
16:03:28 <DorpsGek> TrueBrain: Error: '256' is not a valid base.
16:03:48 <TrueBrain> @base 16 26 4d524f46
16:03:48 <DorpsGek> TrueBrain: 454JBNC
16:05:41 <TrueBrain> 'MROF' .. 'NECS' ..
16:05:53 <TrueBrain> can be in any order ..
16:06:51 <TrueBrain> 'EMAN'
16:06:53 <TrueBrain> owh .. NAME
16:06:55 <TrueBrain> FORM
16:06:58 <TrueBrain> but: SCEN?
16:07:00 <TrueBrain> scenario :)
16:09:41 <TrueBrain> f__1FB5_0E9C_001B_37D1 is something like fwrite
16:10:04 <TrueBrain> (looking at the usage, not the function)
16:11:17 <TrueBrain> emu_andw(&emu_dx, 0x1);
16:11:18 <TrueBrain> emu_andw(&emu_ax, 0x0);
16:11:20 <TrueBrain> emu_orw(&emu_dx, emu_ax);
16:11:21 <TrueBrain> if (emu_dx == 0) goto l__0922;
16:11:23 <TrueBrain> any idea what that can do?
16:11:24 <TrueBrain> emu_ax &= 0 ?
16:11:33 <TrueBrain> it is a 32bit
16:11:42 <TrueBrain> so maybe it was: val32 & 0x00010000
16:13:45 <TrueBrain> it seems the NAME chunk is limited to 65536 chars :p Lol :)
16:20:58 <glx> looks like val32 & 0x00010000 yes
16:22:37 <glx> most 1FB5 are related to files IIRC
16:23:34 <TrueBrain> how would it ever be possible to enter a name of 64k chars? :p
16:23:43 <TrueBrain> like: hello insanity! How can I help you today?
16:30:29 <TrueBrain> I have to see at reading if this is a bug .. 256 seems like a more sane limit
16:41:18 <Xaroth> heh
16:41:22 * Xaroth at laptop once again
16:43:50 *** Yexo_ has joined #openDune
16:43:50 *** ChanServ sets mode: +v Yexo_
16:44:01 *** Yexo is now known as Guest332
16:44:02 *** Yexo_ is now known as Yexo
16:51:03 *** Guest332 has quit IRC
16:53:19 <TrueBrain> funny enough, the 'NAME' chunk is optional
16:53:26 <Xaroth> NAME chunk of the save?
16:53:30 <TrueBrain> yes
16:53:38 <Xaroth> what's the default then :o
16:53:50 <TrueBrain> no clue
16:54:10 <Xaroth> 256 char length for a savegame description may have seemed too short?
16:54:19 <Xaroth> completely odd, but still :P
16:54:20 <TrueBrain> not description
16:54:21 <TrueBrain> NAME
16:54:47 <Xaroth> yeh, which you see at the load screen
16:55:06 <TrueBrain> yes :)
16:55:09 <Xaroth> maybe room for expansion?
16:55:15 <TrueBrain> you think? :p
16:55:26 <TrueBrain> 65536 bytes of expension? :P
16:55:37 <TrueBrain> I think the idea was 'unlimited'
16:56:31 <TrueBrain> what is odd, is that byte 4 - 7 is written with 0
16:56:32 <Xaroth> providing more space than anybody would ever need :P
16:56:35 <TrueBrain> but in the savegames they all have values
16:56:39 <TrueBrain> the 'FORM' chunk
17:01:23 <Xaroth> odd
17:02:03 <TrueBrain> yup
17:02:07 <TrueBrain> FORM .. what would be in FORM ...
17:02:39 <TrueBrain> the chunk SCEN is empty; always
17:02:40 <TrueBrain> haha
17:03:11 <TrueBrain> 2 bytes remain 0, the other two .. a crc?
17:03:20 <TrueBrain> but how does it get there .. by which write ...
17:06:47 <TrueBrain> ah, filesize
17:06:48 <TrueBrain> lol
17:07:09 <TrueBrain> Save_Chunk updates it
17:08:59 <TrueBrain> f__0C3A_2433_0042_DBC6 <- Structure_RemoveFog, I guess
17:09:07 <TrueBrain> when you save in debugScenario, it recalculates all fog-stuff :)
17:14:30 <TrueBrain> it also resets houseID :p
17:17:33 <TrueBrain> weird .. it doesn't seem houseID is ever reset
17:17:37 <TrueBrain> re-reset :p
17:18:40 <TrueBrain> http://paste.openttd.org/221181
17:18:43 <TrueBrain> FYR
17:19:18 <TrueBrain> emu_andb(&emu_get_memory8(emu_es, emu_bx, 0x2), 0xF7); <- that line really empties HouseID, not?
17:19:24 <TrueBrain> @base 16 2 F7
17:19:24 <DorpsGek> TrueBrain: 11110111
17:19:27 <TrueBrain> owh, no
17:19:28 <TrueBrain> LOL
17:19:30 <TrueBrain> oopsie
17:19:52 <TrueBrain> @base 2 16 11110
17:19:52 <DorpsGek> TrueBrain: 1E
17:51:59 <glx> it clears bit 1 of flags
18:19:47 <TrueBrain> yeah ... my mistake :)
18:19:48 <TrueBrain> ghehe :)
18:19:59 <TrueBrain> I wonder if I can replace this with fopen() entries ...
18:20:04 <TrueBrain> guess I need to do Save_Chunk first
18:27:38 <TrueBrain> multiple places handle removing fog around structure
18:27:48 <DorpsGek> SVN: truebrain (r837) -Add: named one more function
19:11:14 *** Osai has joined #openDune
19:12:33 <TrueBrain> howdie Osai :)
19:12:37 <Osai> hi TB
19:12:49 <TrueBrain> about the other channel, nobody ever said anything, so I got bored by having it in my chanlist .. so I removed it :p
19:13:08 <Osai> yea, it was x-mas time
19:13:33 <TrueBrain> nah, the 3 months before that too :p
19:13:45 <TrueBrain> I think you can print the conversation of the last few months on 1 A4 page :p
19:13:50 <Osai> well - busy, busy, busy :D
19:13:55 <TrueBrain> we all are, yes :)
19:15:00 <TrueBrain> but how are you doing Osai? :)
19:15:24 <Osai> well, I am finally in the nationalteam
19:15:25 <Osai> :D
19:15:30 <TrueBrain> concratz :)
19:15:37 <TrueBrain> so when can we see you on tv? :p
19:15:38 <Osai> so I am absolutely focused on training
19:15:46 <Osai> I doubt you ever can :(
19:15:49 <TrueBrain> :'(
19:15:54 <Osai> its just not popular enough
19:16:03 <Osai> and if it is, I'll tell you of course
19:16:16 <Osai> there are some smaller reports, but I never was in
19:16:26 <TrueBrain> too bad :)
20:20:00 <TrueBrain> okay, my replacement save routine seems to work .. now I need to extend it :)
20:23:01 <TrueBrain> LOL! When you dont name a savegame, it gets the name [EMPTY SLOT] :p
20:23:21 <TrueBrain> no ... a random string
20:23:29 <TrueBrain> now it says: "there are no saved games to load." and a list of savegames below :p
20:23:38 <TrueBrain> so it is not as optional as they want us to make believe in the save routine :p
20:24:05 <planetmaker> for the fun: make sure the random string contains things like - & § \ é and so on
20:24:21 <planetmaker> oh, ( ) are also nice
20:25:19 <planetmaker> or start with a dash ;-)
20:25:36 <planetmaker> a file like "-f" (without quotes) is a nice one on *nix systems :-P
20:32:15 <TrueBrain> oh, not the filename
20:32:19 <TrueBrain> the name you get when loading it
20:32:25 <TrueBrain> so what ever it is, it is safe
20:32:33 <TrueBrain> just stupid it is mandatory while saving has exception code for it
20:48:58 <TrueBrain> okay, I think I can replace the save stuff with fopen and friends ... lets try it :)
20:50:11 <TrueBrain> glx: do you think it is wise to write such a fios layer around it immediatly, like OpenTTD has?
20:50:20 <TrueBrain> or just use fopen for now, and later replace them?
21:00:53 <glx> config uses fopen already, but I think it's ok to use fopen for now
21:01:33 <TrueBrain> k .. then I just need a strtolower function :)
21:01:48 <TrueBrain> or I need to adjust the template
21:01:58 <TrueBrain> as now it stores the files as _SAVE???.DAT
21:05:29 <TrueBrain> /* 2AC3(14) */ PACK char string_2AC3[14]; /*!< "_SAVE%03d.DAT" NULL terminated. */
21:05:36 <TrueBrain> thatone .. most likely the best approach, to alter that template
21:05:40 <TrueBrain> how .. hmm .. that is the next question
21:06:00 <TrueBrain> in the memory dump, or some override
21:14:09 <TrueBrain> or ... I just take over GenerateSavegameFilename :)
21:24:32 <TrueBrain> hmm .. I need to swap bytes ....
21:26:22 <TrueBrain> nsz: do you have a fancy idea for C89 or any fast way to swap bytes? (LE -> BE)
21:26:43 <TrueBrain> I am writing with fwrite, if that helps in any way
21:31:37 <TrueBrain> or SmatZ, do you have a nice idea?
21:32:35 <SmatZ> __builtin_bswap? :-)
21:33:01 <SmatZ> htonl, htons ...
21:33:08 <SmatZ> so it will be always stored in BE
21:33:19 <SmatZ> which is the BAD format for x86 :-/
21:33:34 <SmatZ> and generally worse imo
21:34:06 <TrueBrain> it is for in the savegames
21:34:17 <TrueBrain> those are mostly BE :) How ever, Dune2 defined it for us :)
21:34:26 <TrueBrain> hmm .. htonl ..
21:34:40 <TrueBrain> arpa/inet, bah ..
21:35:10 <TrueBrain> via BSD_SOURCE we have htobe32
21:36:38 <TrueBrain> are 4 fwrites :p Haha :)
21:37:35 <SmatZ> :-p
21:42:02 <TrueBrain> bah, htobe32 is not in standard libc or something
21:42:18 <SmatZ> the legal way to prevent breaking of aliasin rules is to use unions
21:42:20 <SmatZ> like
21:42:33 <TrueBrain> I have to store a length field
21:42:36 <TrueBrain> a 32bit value
21:42:41 <SmatZ> typedef union { uint a, unsigned char b[4]; } xxx;
21:42:54 <SmatZ> but I don't know how legal is it to read 'b' after write to 'a'
21:43:05 <TrueBrain> not a problem, we do that all the time
21:43:10 <TrueBrain> but .. how does it solve the endian problem?
21:43:15 <TrueBrain> on LE it is still 11 22 33 44
21:43:18 <TrueBrain> also in b
21:43:41 <SmatZ> I thought your problem is to convert the value BE<->LE
21:43:43 <SmatZ> so
21:44:10 <SmatZ> xxx.a = i; swap(xxx.b[0], xxx.b[3]); swap(xxx.b[1], xxx.b[2]); i = xxx.a
21:44:19 <TrueBrain> I want to avoid those 'swaps' :)
21:44:22 <TrueBrain> they are expensive :)
21:46:47 <TrueBrain> #include <endian.h>
21:46:48 <TrueBrain> #if __BYTE_ORDER == __LITTLE_ENDIAN
21:46:50 <TrueBrain> #define HTOBE32(x) __builtin_bswap32(x)
21:46:51 <TrueBrain> #else
21:46:53 <TrueBrain> #define HTOBE32(x) (x)
21:46:54 <TrueBrain> #endif
21:46:56 <TrueBrain> works for GCC :p
21:47:10 <TrueBrain> not the most optimal ... but best I can think of
21:47:37 <SmatZ> oh silly gcc
21:47:53 <SmatZ> http://paste.openttd.org/221182 instead of simple bswap!
21:48:18 <TrueBrain> does GCC do that?! I thought there were instructions to do swapping?
21:48:24 <SmatZ> yeah
21:48:25 <TrueBrain> what does bswap_32 do?
21:48:39 <TrueBrain> # define htobe32(x) __bswap_32 (x)
21:48:40 <SmatZ> http://paste.openttd.org/221183 that's for this
21:48:40 <TrueBrain> to be exact
21:48:46 <TrueBrain> ah :)
21:48:55 <TrueBrain> can you try __builtin_bswap32 and __bswap_32 for me please? :)
21:49:10 <TrueBrain> I like your swap :)
21:49:33 <SmatZ> return __builtin_bswap32(i);
21:49:43 <SmatZ> results in
21:49:45 <SmatZ> bswap edi
21:49:47 <SmatZ> so it's fine ;)
21:49:50 <SmatZ> but not portable :(
21:50:17 <TrueBrain> I know :)
21:50:21 <SmatZ> return __bswap_32(i);
21:50:22 <SmatZ> does
21:50:28 <SmatZ> xor eax, eax
21:50:29 <SmatZ> jmp __bswap_32
21:50:31 <SmatZ> (wtf?) ;)
21:50:40 <TrueBrain> okay .... __builtin_bswap32 it is :p
21:50:47 <TrueBrain> gcc has it for most targets, not all
21:52:34 <SmatZ> 4.3.4 http://paste.openttd.org/221184 4.4.2 http://paste.openttd.org/221185 4.5.0 http://paste.openttd.org/221186
21:52:50 <SmatZ> impressive they are improving :) but still not as good as
21:52:51 <SmatZ> __builtin_bswap32
21:53:00 <TrueBrain> -O3?
21:53:07 <SmatZ> yes
21:53:14 <TrueBrain> that is impressive progress
21:53:21 <TrueBrain> maybe one day it understands you were swapping :p
21:53:36 <TrueBrain> it btw made it 2 shifts :)
21:53:39 <SmatZ> hehe :)
21:54:03 <SmatZ> 2 shifts? where?
21:54:19 <TrueBrain> the 4.5
21:54:28 <TrueBrain> first swap of the higher/lower bits
21:54:31 <TrueBrain> then swap of middle bits
22:11:13 <TrueBrain> position = ftell(fp);
22:11:14 <TrueBrain> fwrite(data, dataLength, 1, fp);
22:11:16 <TrueBrain> length = ftell(fp) - position;
22:11:18 <TrueBrain> wtf .... length == dataLength!!
22:26:39 <DorpsGek> SVN: truebrain (r838) -Fix: overlay() has parameters, define them as such in extern
22:26:47 <TrueBrain> I always forget () means different things in C++ than in C
22:27:41 <TrueBrain> glx: http://svn.opendune.org/~truebrain/temp.patch
22:27:44 <TrueBrain> can you try that under MSVC?
22:27:50 <TrueBrain> and let me know if there is need for any fixing?
22:27:59 <TrueBrain> code-style comments are also very welcome :)
22:29:05 <glx> Xaroth: a download link would be nice for the patch viewer :)
22:32:02 <TrueBrain> small update: use Save_Chunk for NAME too
22:32:09 <glx> no endian.h
22:32:25 <TrueBrain> no suprise
22:32:40 <TrueBrain> you know what, let me commit endian to SVN, so you can fix it in SVN, much easier :)
22:32:52 <glx> fails for mingw too
22:33:10 <glx> same error
22:33:13 <DorpsGek> SVN: truebrain (r839) -Add: an OS file for endian related stuff
22:33:23 <TrueBrain> can you see if you can fix it? For both we know they are always LE
22:33:30 <TrueBrain> (Windows kind of demands that :p)
22:33:42 <TrueBrain> later we will detect endian via configure ( nsz, tell igor2 to hurry :p)
22:33:59 <TrueBrain> so any way you can do a swap, would be perfect :)
22:34:10 <TrueBrain> in the worst case, using shifts
22:36:48 <glx> checking in the SDK (just in case)
22:43:50 <TrueBrain> small update, which should finalize my patch :)
22:43:56 <TrueBrain> (given that endian.h is no longer part of my patch ;))
22:51:44 <TrueBrain> k, this was good progress today ... with this, we might be able to fabricate an auto-save
22:51:49 <TrueBrain> just loading had to be adjusted to see such games :p
22:51:55 <TrueBrain> either way, good night for now :)
23:10:55 <glx> ok removing the include is enough for mingw, and for MSVC it's doable with some __asm http://glx.dnsalias.net:8080/opendune/endian.diff