Some help to optimize my new ATARI ST emu for PocketPC...
An ATARI ST emulator Will out very soon,
it's a port of an unknown ATARI ST emu from PC LINUX PLATFORM, but believe me this is the fastest around...
As Atari ST is a BIG ENDIAN machine, ARM has some difficults to Work at 100% speed of a real ATARI ST in many case,
but the Worst (which slow down a lot of the emu) is the Drawing Routine , ATARI ST Screen buffer is composed of 4 layers (interlaced) in BIG ENDIAN order and one pixel take 4 bits (16 colors), A palette is use to draw the Good color on the screen.
Since i've started to Code this emu , i succeed to make the drawing routine 5 time faster!
Today ATARI ST bench say that My port is a lot of faster than a real ATARI ST emu (at the begining it said that it was only 30percent of real ATARI ST), but in reality Some game work at 100 percent of Original speed but others are slow or some really slow. I'm sure that somebody could help me to Optimize it.
Here is the Piece of Conversion Code which get and draw Two piwel, i tried Precalculate TAB, but it was really slower:
Line_i is the point to the ST Screen buffer *char
Line_o is the PocketPC screen Buffer *int
ptrhicolor is the pointer to the PAL array <<16
ptrcolor is the pointer to the PAL array
- Code:
register unsigned int val0 = *line_i++;
register unsigned int val1 = *line_i++;
val0 = (val0<<8)|(*line_i++);
val1 = (val1<<8)|(*line_i++);
val0 = (val0<<8)|(*line_i++);
val1 = (val1<<8)|(*line_i++);
val0 = (val0<<8)|(*line_i++);
val1 = (val1<<8)|(*line_i++);
*--line_o1 = ptrhicolor[(val0 >> 31) | ((val0 >> 22)&2) |((val0 >>13)&4) | ((val0 >> 4)&8)]|ptrcolor[((val0 >> 30)&1) | ((val0 >> 21)&2) |((val0 >> 12)&4) | ((val0 >> 3)&8)];
*--line_o1 = ptrhicolor[((val0 >> 29)&1) | ((val0 >> 20)&2) |((val0 >>11)&4) | ((val0 >> 2)&8)]|ptrcolor[((val0 >> 28)&1) | ((val0 >> 19)&2) |((val0 >> 10)&4) | ((val0 >> 1)&8)];
*--line_o1 = ptrhicolor[((val0 >> 27)&1) | ((val0 >> 18)&2) |((val0 >> 9)&4) | (val0&8)]|ptrcolor[((val0 >> 26)&1) | ((val0 >> 17)&2) |((val0>>8) &4) | ((val0 << 1)&8)];
*--line_o1 = ptrhicolor[((val0 >> 25)&1) | ((val0>>16)&2) |((val0 >> 7)&4) | ((val0 <<2)&8)]|ptrcolor[((val0>>24)&1) | ((val0>>15)&2) |((val0>>6)&4) | ((val0&1)<<3)];
*--line_o1 = ptrhicolor[(val1 >> 31) | ((val1 >> 22)&2) |((val1 >>13)&4) | ((val1 >> 4)&8)]|ptrcolor[((val1 >> 30)&1) | ((val1 >> 21)&2) |((val1 >> 12)&4) | ((val1 >> 3)&8)];
*--line_o1 = ptrhicolor[((val1 >> 29)&1) | ((val1 >> 20)&2) |((val1 >>11)&4) | ((val1 >> 2)&8)]|ptrcolor[((val1 >> 28)&1) | ((val1 >> 19)&2) |((val1 >> 10)&4) | ((val1 >> 1)&8)];
*--line_o1 = ptrhicolor[((val1 >> 27)&1) | ((val1 >> 18)&2) |((val1 >> 9)&4) | (val1&8)]|ptrcolor[((val1 >> 26)&1) | ((val1 >> 17)&2) |((val1>>8) &4) | ((val1 << 1)&8)];
*--line_o1 = ptrhicolor[((val1 >> 25)&1) | ((val1>>16)&2) |((val1 >> 7)&4) | ((val1 <<2)&8)]|ptrcolor[((val1>>24)&1) | ((val1>>15)&2) |((val1>>6)&4) | ((val1&1)<<3)];
ohh my.
I'll try and look at this later or tomorrow, it looks interesting (just my cup of tea after

).
My questions about the code would be:
Why load from the source a byte at a time (and re-arrange the bytes into two 32-bit words)? Why not just load two 32-bit words into variables (sequentially) and mask and shift off of them instead?
Cheers,
Ref.
Yes i tried this solution before, but when i use more Variable , i'm still obliged to make shift and mask, i assure you that the result is about 2 time slower than current .
here is the st video memory description:
00000000 11111111 22222222 33333333 44444444 55555555 66666666 77777777
the first pixel is composed of the first bit (bit 7) of the layer 00000000 (which is the bit 0 in the Color number), plus the layer 22222222 with the bit 7 left shifted to one, plus the layer 44444444 with the bit 7 left shifted to 2, plus the layer 66666666 with the bit 7 left shifted 3.
the 9th pixel is the first bit of the layer 1 etc.....
I think you misunderstood what I meant. You still have the
same number of variables, but you're not loading the valX vars a byte at a time (because you don't need to):
Line_i is the point to the ST Screen buffer *
unsigned int
Line_o is the PocketPC screen Buffer *int
ptrhicolor is the pointer to the PAL array <<16
ptrcolor is the pointer to the PAL array
- Code:
register unsigned int val0 = *line_i++;
register unsigned int val1 = *line_i++;
//val0 = (val0<<8)|(*line_i++);
//val1 = (val1<<8)|(*line_i++);
//val0 = (val0<<8)|(*line_i++);
//val1 = (val1<<8)|(*line_i++);
//val0 = (val0<<8)|(*line_i++);
//val1 = (val1<<8)|(*line_i++);
Then use the two variables instead when you're plucking out the output pixels:
(this is just altered from your source and is just an example)
*--line_o1 = ptrhicolor[(val0 >> 31) | ((val1 >> 22)&2) |((val0 >>13)&4) | ((val1 >> 4)&8)]|ptrcolor[((val0 >> 30)&1) | ((val1 >> 21)&2) |((val0 >> 12)&4) | ((val1 >> 3)&8)];
Shouldn't be slower...
I must have a look for my Atari ST source code at the weekend. I wrote a game for the ST ( which was published, in the shops etc but never sold well ) and I still have some ST resources plus many games.
I don't remember the ST video setup being difficult on the actual device so I assume it's the translation to another format that's the problem.
( I will be very happy to see my old games running on PocketPC )
Refractor, thanks for helping me,
if you can write at leat the first line , because mine don't work....
/me thinks schtruck could use a new forum for his atari emulator on PDAi...

There should be soom room for optimisation I think. Lots of those barrel shifts can be converted to free shifts, and many of those AND operations can be combined together by doing them at a different point
try this:
- Code:
//st video memory
//00000000 11111111 22222222 33333333
//44444444 55555555 66666666 77777777
//First load the 8 bytes in question into a couple
//of registers. Note we don't care that
//This swaps the endian of the bytes, we can easily
//compensate for this later
int r0=*Line_i++;
int r1=*Line_i++;
//r0 = 33333333 22222222 11111111 00000000
//r1 = 77777777 66666666 55555555 44444444
//Mask of the bits we want,
//using just 2 AND operations
//Takes advantage of ARM free barrel shift
//Which I've moved early to save doing it later
int r2=(r0>>7)&0x00010001;
int r3=(r1>>5)&0x00040004;
//r2 = xxxxxxxx xxxxxxx2 xxxxxxxx xxxxxxx0
//r3 = xxxxxxxx xxxxx6xx xxxxxxxx xxxxx4xx
//now just combine these bits together
//the shifts should be free if the compiler
//puts it together correctly
//finally I'm clearing up the unwanted bits
//with just one more AND operation
col=((r2+(r2>>14))+(r3+(r3>>14))&15;
//now just col as an index to your palette array
that's converted a single pixels in 4 shifts which should be free, and 6 other arithmetic ops,
should be pretty fast, assuming the compiler is half decent, I can write it in asm for you if necessary.
the other pixels can be done a similar way
If you need any other help with you ST emulator please just send me an email, I'd love to see an ATARI ST emu running on my pocket pc. I'm particularly interested in helping you optimise bits of code like this.
Note I haven't tested this code, if it doesn't work let me know and I'll stop being so lazy and I'll test is properly.
Thanks
Andrew
DELETED I WORKED OUT A FASTER WAY, see below
DELETED, I WORKED OUT A FASTER WAY, see below
sorry for my repeat posting, you can ignore my last posts I've worked out another way which is WAY faster. It's rather difficult to understand though, since it relies on calculating several pixels at once :-)
Here goes:
- Code:
int r0=*Line_i++;
int r1=*Line_i++;
//r0: 33333333 22222222 11111111 00000000
//r1: 77777777 66666666 55555555 44444444
//use bit masks to slice these up
int r2 = r0&0xaaaaaaaa;
int r3 = r1&0xaaaaaaaa;
//r2: 3x3x3x3x 2x2x2x2x 1x1x1x1x 0x0x0x0x
//r3: 7x7x7x7x 6x6x6x6x 5x5x5x5x 4x4x4x4x
//combine these pixels to give pairs
r2+=(r2>>17);
r3+=(r3>>17);
//r2: ???????? ???????? 13131313 02020202
//first half of pixels 8,10,12,14 and 0,2,4,6
//r3: ???????? ???????? 57575757 46464646
//second half of pixels 8,10,12,14 and 0,2,4,6
//slice again with more bit masks
int r4=r2&0x0000cccc;
int r5=r3&0x0000cccc;
//r4: xxxxxxxx xxxxxxxx 13xx13xx 02xx02xx
//r5: xxxxxxxx xxxxxxxx 57xx57xx 46xx46xx
//combine together to give 4 completed pixels
r4+=(r5>>2);
//r4: xxxxxxxx xxxxxxxx 13571357 02460246
//thats pixels 8,12,0,4 in chunky format
//do the same for pixels 10,14,2,6
r5=(r2<<2)&0x0000cccc;
int r6=(r3<<2)&0x0000cccc;
r5+=(r6>>2);
//r5: xxxxxxxx xxxxxxxx 13571357 02460246
//thats pixels 10,14,2,6 in chunky format
So we've converted 8 pixels in just 10 operations! (answer is in r4 & r5) The other 8 pixels will take another 10 operations And it will take 1 operation per pixel to pull out the indexes for the palette arrays
So thats just 36 operations for all 16 pixels, which is about three times faster than before (I hope!)
If you want me to I'll write out the entire program for you later.
Hope this helps
Andrew
OK andrew, you method seem very interesting, but i'm not sure the Result have Pixel in good order to give us the good index?
Could you write the entire program, i'll test it Quickly
Thanks you very much.
Anyelse this Emu Will be Open Source under GPL license
I'm curently making a Site, and when it will be Ready i'll out the Version and the source on CVS.
ok, I've got some degas pictures knocking around somewhere, and I remember they were just a raw dump of the st screen memory, so I'll make sure my code works properly using those and then post it here
ok here is the complete code as promised, I fixed the mistake with my pixel ordering and it works now.
I wrote a quick Java program to test the main algorithm out using a dump of the st screen memory, and it worked fine.
Here is the c++ version
- Code:
//IMPORTANT: line_i must be a *int array
register unsigned int mask1 = 0x55555555;
register unsigned int mask2 = 0x00003333;
//Then call the following code 4800 times :-)
register unsigned int r0 = *line_i++;
register unsigned int r1 = *line_i++;
register unsigned int r2=(r0>>1)&mask1;
register unsigned int r3=(r1>>1)&mask1;
r0&=mask1;
r1&=mask1;
r2+=(r2>>15);
r3+=(r3>>15);
r0+=(r0>>15);
r1+=(r1>>15);
register unsigned int r4=(r2>>2)&mask2;
register unsigned int r5=(r3>>2)&mask2;
r2&=mask2;
r3&=mask2;
r4+=(r5<<2);
r2+=(r3<<2);
r3=(r0>>2)&mask2;
r5=(r1>>2)&mask2;
r0&=mask2;
r1&=mask2;
r3+=(r5<<2);
r0+=(r1<<2);
*--line_o1 = ptrhicolor[(r4>>4)&15]+ptrcolor[(r3>>4)&15];
*--line_o1 = ptrhicolor[(r2>>4)&15]+ptrcolor[(r0>>4)&15];
*--line_o1 = ptrhicolor[r4&15]+ptrcolor[r3&15];
*--line_o1 = ptrhicolor[r2&15]+ptrcolor[r0&15];
*--line_o1 = ptrhicolor[(r4>>12)&15]+ptrcolor[(r3>>12)&15];
*--line_o1 = ptrhicolor[(r2>>12)&15]+ptrcolor[(r0>>12)&15];
*--line_o1 = ptrhicolor[(r4>>8)&15]+ptrcolor[(r3>>8)&15];
*--line_o1 = ptrhicolor[(r2>>8)&15]+ptrcolor[(r0>>8)&15];
I should point out that whilst I have optimised this to use very few operations I haven't really thought much about keeping the ARM pipelines full.
It's possible that having all the 8 pixels output command together at the end could cause some write stalls
It rather depends on the memory and cache architecture of the pocket-pc which I don't really know much about. If the memory is v.slow compared to the cpu then the speed might not be good as expected, and the commands might need reordering a bit to compensate. (assuming the compiler can't sort that out automatically).
lol, oops thought of another really good speed up.
You can save a LOT of memory lookups by combining the palette lookups for pairs of pixels.
Instead of having 2 size-16 arrays for the palette, just have 1 size-256 array for the palette which contains every combination of 2 adjacent pixels possible, then you can lookup 2 pixels at once with just one memory access.
e.g bigpal[0] would be for pixels 0,0
bigpal[1] would be for pixels 0,1
bigpal[2] would be for pixels 0,2
...
bigpal[32] would be for pixels,2,0
bigpal[33] would be for pixels,2,1
etc..
In which case the code becomes
- Code:
//IMPORTANT: line_i must be a *int array
register unsigned int mask1 = 0x55555555;
register unsigned int mask2 = 0x00003333;
//Then call the following code 4800 times :-)
register unsigned int r0 = *line_i++;
register unsigned int r1 = *line_i++;
register unsigned int r2=(r0>>1)&mask1;
register unsigned int r3=(r1>>1)&mask1;
r0&=mask1;
r1&=mask1;
r2+=(r2>>15);
r3+=(r3>>15);
r0+=(r0>>15);
r1+=(r1>>15);
register unsigned int r4=(r2>>2)&mask2;
register unsigned int r5=(r3>>2)&mask2;
r2&=mask2;
r3&=mask2;
r4+=(r5<<2);
r2+=(r3<<2);
r3=(r0>>2)&mask2;
r5=(r1>>2)&mask2;
r0&=mask2;
r1&=mask2;
r3+=(r5<<2);
r0+=(r1<<2);
*--line_o1 = bigpal[(r4&240)+((r3>>4)&15)];
*--line_o1 = bigpal[(r2&240)+((r0>>4)&15)];
*--line_o1 = bigpal[(r4<<4)&240)+(r3&15);
*--line_o1 = bigpal[((r2<<4)&240)+(r0&15)];
*--line_o1 = bigpal[((r4>>8)&240)+((r3>>12)&15)];
*--line_o1 = bigpal[((r2>>8)&240)+((r0>>12)&15)];
*--line_o1 = bigpal[((r4>>4)&240)+((r3>>8)&15)];
*--line_o1 = bigpal[((r2>>4)&240)+((r0>>8)&15)];
I really like this because I think this also solves most my concerns about the pipelines, since there is now enough straight math between each lookup to keep the cpu busy.
thanks Andrew!!!
it's excellent!!
your last optmisation crash, but previous has Win between 50% and 100% of speed!
if you can fix your last, i think we'll win at least 80*%
thanks
sorry it was me :)
that work vey well
let me see how much time we win.
hmm there is something wrong because there is Glitch...
if you can take alook
what sort of glitch?
pixels back to front? if so try swapping them around in bigpal.
Hi, it's Andrew, I'm posting as anonymous because I'm using someones elses computer, and i don't have my login cookie on this one.
Here is some code to generate bigpal[], since perhaps I didn't explain how it should be arranged very well. You will need to call this whenever the st screen palette is updated.
bigpal is a 256 size array
- Code:
for (int c1=0; c1<16; c1++) {
for (int c2=0; c2<16; c2++) {
bigpal[(c1<<4)+c2]=ptrhicolor[c1]+ptrcolor[c2];
}
}
here is how i init Bigpal:
for (i=0;i<256;i++)
bigpal[i]=(color[i&240]<<16)|color[i&15]:
glitch are vertical lines, like mask or shift are bad...
ah your init code is wrong
Just use mine instead, it should work ok then
hold on I misread it, although you could try using mine anyway

is the glitch just in the bigpal version or in both?
ah I find the error in your code it should be:
for (i=0;i<256;i++)
bigpal[i]=(color[i>>4]<<16)|color[i&15]:
It's possible that having all the 8 pixels output command together at the end could cause some write stalls.
Naah, the write buffer should catch those ok on the StrongARM if you're not going straight to display memory. Still, you probably are going to be bus-bound.
Struck, if you want to compile the "final" working function and post the assembler output up here then we can play at low-level optimising it too
Cheers,
Ref.
P.s. I know what you mean by "keeping the ARM pipelines full", but strictly speaking there is only one pipeline on the ARM. You just want to stop register contention so it doesn't stall for a cycle or two.

(And on the XScale there are penalties for barrel-shifting in some cases, IIRC). I'm being picky though - your code looks nice.

OK that work, but this last a a lot of slower (Atari ST bench result), i mean, for my last i got 317, for your First i got 367, and for your last 216...
strange
hmm how odd that it should be slower! That really makes no sense to me.
I can only conclude that either
a) the compiler is being really stupid
or
b) there is some huge penalty for reading data 16-bits at a time instead of 8-bits at a time. Although this strikes me as very unlikely!
Also make sure you only recalculate bigpal when the palette actually changes or else you will take a hit from building that table
with respect to implementing my code directly at assembler level, well actually it almost assembler already, I already named the variables after the ARM registers, and most lines are just equivalent to one assembler instruction, so writing it straight into assembler should be quite easy, although only necessary if the compiler isn't converting properly itself
ok i've just redone bench and yes it's your which is Faster!!!
mine gave 127, your first 165 and your last 216
thanks a lot.
Now i have to fix a little problem which Make many Game none playable because ACIA interrupt has Some problem when TIMER A or B is activate....
CYa+++
if you can make the Same Thing for Med - resolution which is 2 bit for one Pixel. and i take only One pixel of Two real. (because Width is only 320 for PPC....)
thanks a lot.
I already named the variables after the ARM registers,
I noticed that.
and most lines are just equivalent to one assembler instruction, so writing it straight into assembler should be quite easy
Yeah, piece of cake.
although only necessary if the compiler isn't converting properly itself
Exactly... which is why I suggested posting the code rather than just writing it in ARM now and posting it.
Cheers,
Ref.
ok as request here is the Code generated:
; 344 : r0 = *line_i++;
00638 e28b2004 add r2, r11, #4
0063c e59b1000 ldr r1, [r11]
; 345 : r1 = *line_i++;
00640 e592e000 ldr lr, [r2]
00644 e282b004 add r11, r2, #4
; 346 : r2=(r0>>1)&mask1;
00648 e00320a1 and r2, r3, r1, lsr #1
; 347 : r3=(r1>>1)&mask1;
0064c e00360ae and r6, r3, lr, lsr #1
; 348 : r0&=mask1;
00650 e0031001 and r1, r3, r1
; 349 : r1&=mask1;
00654 e003e00e and lr, r3, lr
; 350 :
; 351 : r2+=(r2>>15);
00658 e08227a2 add r2, r2, r2, lsr #15
; 352 : r3+=(r3>>15);
0065c e08667a6 add r6, r6, r6, lsr #15
; 353 : r0+=(r0>>15);
00660 e08197a1 add r9, r1, r1, lsr #15
; 354 : r1+=(r1>>15);
00664 e08ea7ae add r10, lr, lr, lsr #15
; 355 :
; 356 : r4=(r2>>2)&mask2;
; 357 : r5=(r3>>2)&mask2;
; 358 : r2&=mask2;
; 359 : r3&=mask2;
; 360 : r4+=(r5<<2);
00668 e000e122 and lr, r0, r2, lsr #2
0066c e0001126 and r1, r0, r6, lsr #2
00670 e08e1101 add r1, lr, r1, lsl #2
00674 e0002002 and r2, r0, r2
00678 e000e006 and lr, r0, r6
; 361 : r2+=(r3<<2);
0067c e082210e add r2, r2, lr, lsl #2
; 362 :
; 363 : r3=(r0>>2)&mask2;
; 364 : r5=(r1>>2)&mask2;
; 365 : r0&=mask2;
; 366 : r1&=mask2;
; 367 : r3+=(r5<<2);
00680 e000e12a and lr, r0, r10, lsr #2
00684 e000a00a and r10, r0, r10
00688 e0006129 and r6, r0, r9, lsr #2
0068c e0009009 and r9, r0, r9
00690 e086e10e add lr, r6, lr, lsl #2
; 368 : r0+=(r1<<2);
00694 e089610a add r6, r9, r10, lsl #2
; 369 :
; 370 : *--line_o1 = hicolor[(r4&240)+((r3>>4)&15)];
00698 e1a0a22e mov r10, lr, lsr #4
0069c e20aa00f and r10, r10, #0xF ; 0xF = 15
006a0 e20190f0 and r9, r1, #0xF0 ; 0xF0 = 240
006a4 e08aa009 add r10, r10, r9
006a8 e794a10a ldr r10, [r4, +r10, lsl #2]
006ac e2477004 sub r7, r7, #4
; 371 : *--line_o1 = hicolor[(r2&240)+((r0>>4)&15)];
006b0 e20290f0 and r9, r2, #0xF0 ; 0xF0 = 240
006b4 e587a000 str r10, [r7]
006b8 e1a0a226 mov r10, r6, lsr #4
006bc e20aa00f and r10, r10, #0xF ; 0xF = 15
006c0 e08aa009 add r10, r10, r9
006c4 e794a10a ldr r10, [r4, +r10, lsl #2]
006c8 e2477004 sub r7, r7, #4
; 372 : *--line_o1 = hicolor[((r4<<4)&240)+(r3&15)];
006cc e20e900f and r9, lr, #0xF ; 0xF = 15
006d0 e587a000 str r10, [r7]
006d4 e201a00f and r10, r1, #0xF ; 0xF = 15
006d8 e089a20a add r10, r9, r10, lsl #4
006dc e794a10a ldr r10, [r4, +r10, lsl #2]
006e0 e2477004 sub r7, r7, #4
; 373 : *--line_o1 = hicolor[((r2<<4)&240)+(r0&15)];
006e4 e206900f and r9, r6, #0xF ; 0xF = 15
006e8 e587a000 str r10, [r7]
006ec e202a00f and r10, r2, #0xF ; 0xF = 15
006f0 e089a20a add r10, r9, r10, lsl #4
006f4 e794a10a ldr r10, [r4, +r10, lsl #2]
006f8 e2477004 sub r7, r7, #4
; 374 : *--line_o1 = hicolor[((r4>>8)&240)+((r3>>12)&15)];
006fc e1a0962e mov r9, lr, lsr #12
00700 e587a000 str r10, [r7]
00704 e1a0a421 mov r10, r1, lsr #8
00708 e20aa0f0 and r10, r10, #0xF0 ; 0xF0 = 240
0070c e209900f and r9, r9, #0xF ; 0xF = 15
00710 e08aa009 add r10, r10, r9
00714 e794a10a ldr r10, [r4, +r10, lsl #2]
00718 e2477004 sub r7, r7, #4
; 375 : *--line_o1 = hicolor[((r2>>8)&240)+((r0>>12)&15)];
0071c e1a09626 mov r9, r6, lsr #12
00720 e587a000 str r10, [r7]
00724 e1a0a422 mov r10, r2, lsr #8
00728 e20aa0f0 and r10, r10, #0xF0 ; 0xF0 = 240
0072c e209900f and r9, r9, #0xF ; 0xF = 15
; 376 : *--line_o1 = hicolor[((r4>>4)&240)+((r3>>8)&15)];
00730 e1a01221 mov r1, r1, lsr #4
00734 e08aa009 add r10, r10, r9
00738 e1a0e42e mov lr, lr, lsr #8
0073c e794a10a ldr r10, [r4, +r10, lsl #2]
00740 e20110f0 and r1, r1, #0xF0 ; 0xF0 = 240
00744 e20ee00f and lr, lr, #0xF ; 0xF = 15
00748 e2477004 sub r7, r7, #4
0074c e081100e add r1, r1, lr
00750 e587a000 str r10, [r7]
00754 e7941101 ldr r1, [r4, +r1, lsl #2]
00758 e2477004 sub r7, r7, #4
; 377 : *--line_o1 = hicolor[((r2>>4)&240)+((r0>>8)&15)];
0075c e1a02222 mov r2, r2, lsr #4
00760 e5871000 str r1, [r7]
00764 e1a01426 mov r1, r6, lsr #8
00768 e20220f0 and r2, r2, #0xF0 ; 0xF0 = 240
0076c e201100f and r1, r1, #0xF ; 0xF = 15
00770 e0822001 add r2, r2, r1
00774 e7942102 ldr r2, [r4, +r2, lsl #2]
00778 e2477004 sub r7, r7, #4
0077c e2488001 sub r8, r8, #1
00780 e5872000 str r2, [r7]
00784 e3580000 cmp r8, #0
00788 8affffaa bhi |$L32010| ; 00000638
Can you generate it as "assembly with source code"?
Cheers,
Ref.
; 344 : r0 = *line_i++;
add r2, r11, #4
ldr r1, [r11]
; 345 : r1 = *line_i++;
ldr lr, [r2]
add r11, r2, #4
; 346 : r2=(r0>>1)&mask1;
and r2, r3, r1, lsr #1
; 347 : r3=(r1>>1)&mask1;
and r6, r3, lr, lsr #1
; 348 : r0&=mask1;
and r1, r3, r1
; 349 : r1&=mask1;
and lr, r3, lr
; 350 :
; 351 : r2+=(r2>>15);
add r2, r2, r2, lsr #15
; 352 : r3+=(r3>>15);
add r6, r6, r6, lsr #15
; 353 : r0+=(r0>>15);
add r9, r1, r1, lsr #15
; 354 : r1+=(r1>>15);
add r10, lr, lr, lsr #15
; 355 :
; 356 : r4=(r2>>2)&mask2;
; 357 : r5=(r3>>2)&mask2;
; 358 : r2&=mask2;
; 359 : r3&=mask2;
; 360 : r4+=(r5<<2);
and lr, r0, r2, lsr #2
and r1, r0, r6, lsr #2
add r1, lr, r1, lsl #2
and r2, r0, r2
and lr, r0, r6
; 361 : r2+=(r3<<2);
add r2, r2, lr, lsl #2
; 362 :
; 363 : r3=(r0>>2)&mask2;
; 364 : r5=(r1>>2)&mask2;
; 365 : r0&=mask2;
; 366 : r1&=mask2;
; 367 : r3+=(r5<<2);
and lr, r0, r10, lsr #2
and r10, r0, r10
and r6, r0, r9, lsr #2
and r9, r0, r9
add lr, r6, lr, lsl #2
; 368 : r0+=(r1<<2);
add r6, r9, r10, lsl #2
; 369 :
; 370 : *--line_o1 = hicolor[(r4&240)+((r3>>4)&15)];
mov r10, lr, lsr #4
and r10, r10, #0xF ; 0xF = 15
and r9, r1, #0xF0 ; 0xF0 = 240
add r10, r10, r9
ldr r10, [r4, +r10, lsl #2]
sub r7, r7, #4
; 371 : *--line_o1 = hicolor[(r2&240)+((r0>>4)&15)];
and r9, r2, #0xF0 ; 0xF0 = 240
str r10, [r7]
mov r10, r6, lsr #4
and r10, r10, #0xF ; 0xF = 15
add r10, r10, r9
ldr r10, [r4, +r10, lsl #2]
sub r7, r7, #4
; 372 : *--line_o1 = hicolor[((r4<<4)&240)+(r3&15)];
and r9, lr, #0xF ; 0xF = 15
str r10, [r7]
and r10, r1, #0xF ; 0xF = 15
add r10, r9, r10, lsl #4
ldr r10, [r4, +r10, lsl #2]
sub r7, r7, #4
; 373 : *--line_o1 = hicolor[((r2<<4)&240)+(r0&15)];
and r9, r6, #0xF ; 0xF = 15
str r10, [r7]
and r10, r2, #0xF ; 0xF = 15
add r10, r9, r10, lsl #4
ldr r10, [r4, +r10, lsl #2]
sub r7, r7, #4
; 374 : *--line_o1 = hicolor[((r4>>8)&240)+((r3>>12)&15)];
mov r9, lr, lsr #12
str r10, [r7]
mov r10, r1, lsr #8
and r10, r10, #0xF0 ; 0xF0 = 240
and r9, r9, #0xF ; 0xF = 15
add r10, r10, r9
ldr r10, [r4, +r10, lsl #2]
sub r7, r7, #4
; 375 : *--line_o1 = hicolor[((r2>>8)&240)+((r0>>12)&15)];
mov r9, r6, lsr #12
str r10, [r7]
mov r10, r2, lsr #8
and r10, r10, #0xF0 ; 0xF0 = 240
and r9, r9, #0xF ; 0xF = 15
; 376 : *--line_o1 = hicolor[((r4>>4)&240)+((r3>>8)&15)];
mov r1, r1, lsr #4
add r10, r10, r9
mov lr, lr, lsr #8
ldr r10, [r4, +r10, lsl #2]
and r1, r1, #0xF0 ; 0xF0 = 240
and lr, lr, #0xF ; 0xF = 15
sub r7, r7, #4
add r1, r1, lr
str r10, [r7]
ldr r1, [r4, +r1, lsl #2]
sub r7, r7, #4
; 377 : *--line_o1 = hicolor[((r2>>4)&240)+((r0>>8)&15)];
mov r2, r2, lsr #4
str r1, [r7]
mov r1, r6, lsr #8
and r2, r2, #0xF0 ; 0xF0 = 240
and r1, r1, #0xF ; 0xF = 15
add r2, r2, r1
ldr r2, [r4, +r2, lsl #2]
sub r7, r7, #4
sub r8, r8, #1
str r2, [r7]
cmp r8, #0
bhi |$L32010| ; 00000638
ldr r1, [sp, #0x20] ; 0x20 = 32
ldr r2, [sp, #0x14] ; 0x14 = 20
sub r1, r1, #0xA, 26 ; 0x280 = 640
str r1, [sp, #0x20] ; 0x20 = 32
add r2, r2, #2
ldr r1, [sp, #0x18] ; 0x18 = 24
str r2, [sp, #0x14] ; 0x14 = 20
ldr lr, [r1, #4]
ldr r1, [r1]
add r1, lr, r1
cmp r2, r1
blt |$L32006| ; 00000628[code][/code]
Here is a part which need to be optimized, this is the Reading and Writing of Big endian ST memory.
first there is this:
#define ReadW(addr) ((*(uint16 *)(addr) << 8) | (*(uint16 *)(addr) >> 8))
#define ReadL(address) ((uint16) ReadW(address) << 16) | (uint16) ReadW((address) + 2)
#define WriteW(addr,value) *((int16 *)(addr)) = ((((uint16)(value)) << 8) | (((uint16)(value)) >> 8))
#define WriteL(address,value) WriteW((address) + 2, value); WriteW(address, (value) >> 16)
and then here is the use of those define:
; 213 : {
|$M1495|
; 214 : return ReadW(address + membase);
ldr r1, [pc, #0x1C] ; pc+8+28 = 00000024
ldr r1, [r1]
ldrh r0, [r1, +r0]
mov r3, r0, lsl #8
mov r3, r3, lsl #16
mov r3, r3, lsr #16
mov r2, r0, lsl #16
orr r0, r3, r2, lsr #24
; 215 : }
; 218 : {
|$M1500|
; 219 : return ReadL(address + membase);
ldr r1, [pc, #0x30] ; pc+8+48 = 00000038
ldr r1, [r1]
ldrh r0, [r1, +r0]!
ldrh r1, [r1, #2]
mov r3, r0, lsl #8
mov r3, r3, lsl #16
mov r2, r1, lsl #8
mov r2, r2, lsl #16
mov r3, r3, lsr #16
mov r2, r2, lsr #16
orr r3, r3, r0, lsr #8
orr r2, r2, r1, lsr #8
orr r0, r2, r3, lsl #16
; 220 : }
; 173 : WriteW(address + membase, value);
mov r3, r4, lsl #16
ldr r0, [pc, #0x20] ; pc+8+32 = 00000058
mov r3, r3, asr #16
mov r3, r3, lsl #8
ldr r0, [r0]
mov r3, r3, lsl #16
mov r3, r3, asr #16
mov r2, r4, lsl #16
orr r3, r3, r2, lsr #24
strh r3, [r0, +r5]
; 174 : }
; 183 : WriteL(address + membase, value);
mov r3, r4, lsl #16
ldr r0, [pc, #0x44] ; pc+8+68 = 0000007C
mov r3, r3, lsr #16
mov r2, r4, lsl #8
ldr r1, [r0]
mov r3, r3, lsr #8
mov r2, r2, lsl #16
orr r3, r3, r2, asr #16
add r2, r1, r5
mov r1, r4, lsr #16
strh r3, [r2, #2]
mov r3, r1, lsl #16
ldr r0, [r0]
mov r3, r3, lsr #16
mov r2, r1, lsl #8
mov r3, r3, lsr #8
mov r2, r2, lsl #16
orr r3, r3, r2, asr #16
strh r3, [r0, +r5]
there is surely a way to optimize this conversion of Big Endian ----> Little Endian? no?
I had a quick look at the generated code for the screen thing, and it isn't all that bad. You could combine some instructions (especially with the loads and stores), but you probably won't gain huge amounts of speed. It might be better to just leave it as portable C in this case, unless the speed is still not fast enough for 100% speed emulation.
Cheers,
Ref.
Speed is fast enought for drawing now, what we could optimize now is the Little ENdian conversion, because i think this last Take too more time.
Btw most of game are playable now, speed is between 60 and 100 percent of original speed.
That never pass 100% because it's speed limited....
i think if Little Endian conversion can be optimized, Emulation will be boosted a lot of....
What code does this produce?
#define ReadW(addr) ((*(uint8 *)(addr)<<8)|((*(uchar *)(addr+1))
(Rather than loading a 16-bit word and splitting, loading the individual bytes should be faster).
before:
; 213 : return ReadW(address + membase);
ldr r1, [pc, #0x1C] ; pc+8+28 = 00000024
ldr r1, [r1]
add r2, r1, r0
ldrb r3, [r2, #1]
ldrb r2, [r1, +r0]
orr r3, r3, r2, lsl #8
mov r3, r3, lsl #16
mov r0, r3, lsr #16
Now:
; 214 : return ReadW(address + membase);
ldr r1, [pc, #0x1C] ; pc+8+28 = 00000024
ldr r1, [r1]
ldrh r0, [r1, +r0]
mov r3, r0, lsl #8
mov r3, r3, lsl #16
mov r3, r3, lsr #16
mov r2, r0, lsl #16
orr r0, r3, r2, lsr #24
What i tried before was to use Intrinsic Rotr but that didn't worked.
In fact a simple RoRw 8 would work no?
But i don't know how to implement it.
I presume you got before and now inverted?
A rotation on the ARM will occur over a 32-bit word.
The compiler is being sucky/stupid

There's an old trick you should try: Store all memory byteswapped. 68000 accesses only happen on word boundaries.
ok I've taken a look at the endian conversion thing
before you had:
----
ReadW(addr) ((*(uint16 *)(addr) << 8) | (*(uint16 *)(addr) >> 8))
which due to the compiler becoming unbeliveably stupid unfortunately compiled to:
add r2, r1, r0
ldrb r3, [r2, #1]
ldrb r2, [r1, +r0]
orr r3, r3, r2, lsl #8
mov r3, r3, lsl #16
mov r0, r3, lsr #16
------
Refract suggested the following - which seem to compile slightly better
-----
#define ReadW(addr) ((*(uint8 *)(addr)<<8)|((*(uchar *)(addr+1))
ldrh r0, [r1, +r0]
mov r3, r0, lsl #8
mov r3, r3, lsl #16
mov r3, r3, lsr #16
mov r2, r0, lsl #16
orr r0, r3, r2, lsr #24
------
however what we really want is, the following assembler
-----
ldrh r0, [r1, +r0] ;load word wrong way around
mov r2, r0, lsr #8 ;swap top half into r2
mov r3, r0, lsl #24 ;swap bottom half into r3
orr r0, r2, r3, lsr #16 ;combine parts together
-----
unfortunately the compiler seems too stupid to produce this,
so I think you're going to have to put this bit straight
in assembler, or find a better compiler :-)
Btw: just storing the memory byte swapped won't work.
Whilst 68000 word accesses are restricted on word boundaries, there
is no such restriction on byte acceses, so if you did that you'd hav
to reprogram all your byte accesses to compensate instead :-)
i can use Emit() to write ASM quickly,
could you take ReadL writeW writeL and do the same optimisation plz?
i'll try to use Emit()
These are the best I can manage for endian swap routines. I can't help but feel their should be an even better solution, but I can't work out what it is if there is.
-----
word endian swap
-input in r0
-big-endian answer returned in r1
-corrupts r2
mov r1, r0, lsr #8 ;swap top half into r1
mov r2, r0, lsl #24 ;swap bottom half into r2
add r1, r1, r2, lsr #16 ;combine parts together
-----
----
long endian swap
-input in r0
-big-endian answer returned in r1
-corrupts r2,r0
(if you would rather it corrupted r3 instead of r0 it could do, if you wished to retain the input)
mov r1, r0, lsr #24 ;put byte 4 in position
add r1, r1, r0, lsl #24 ;put byte 1 in position
mov r0, r0, ror #16 ;move bytes 2 and 3 to edge
mov r2, r0, lsr #24 ;put byte 2 in position
add r2, r2, r0, lsl #24 ;put byte 3 in position
add r1, r1, r2, ror #16 ;combine final answer
-----
To use these in your read and writes just use the above snippets of code to swap the endian-ness of the data in the register before writing it normally, or after reading it normally.
e.g
for read16, do a normal 16 bit read, then run 'word endian swap' on the register
for write16 run 'word endian swap' on the register, and then do a normal 16 bit write
for read32, do a normal 32 bit read, then run 'long endian swap' on the register
for write32 run 'long endian swap' on the register, and then do a normal 32 bit write
I haven't tested this :-) But it's getting late here in the uk, so I'll leave it at that for now
>These are the best I can manage for endian swap routines. I can't help but feel their should be an even better solution, but I can't work out what it is if there is.
Well there is a better solution - the best optimisation, as always, is to not need to byteswap in the first place :)
the problems with not byte swapping, and just storing everything back to front are:
a) byte read/writes on the 68000 are not word aligned. so if we just store it backwards and someone does:
move.w d0,(a0)
move.b 1(a0),d1
it's going to wrong. This could be compensated for relatively easy in the byte access routine, but probably not in in less than the 3 instructions it took to fix up the word access routine.
b) memory access is only word aligned, not long aligned, so if someone does:
move.l d0,(a0)
move.l 2(a0),d1
it's going to go wrong. Againt it could be compensated for but I'm not convinced be any quicker than the endian swap code I already place.
Perhaps you could post some code showing how to compensate for these issues quickly, because if it's shorter than the endian swap code it sounds really great.
Thanks
Andrew
ok i did this but that don't work:
extern uint16 Swap16(uint16 value);
extern uint32 Swap32(uint32 value);
#define ReadW(addr) Swap16(*(uint16 *)(addr))
#define ReadL(addr) Swap32(*(uint32 *)(addr))
#define WriteW(addr,value) *((uint16 *)(addr)) = Swap16(*(uint16 *)(addr))
#define WriteL(addr,value) *((uint32 *)(addr)) = Swap32(*(uint32 *)(addr))
and
AREA ArmSwapLib,CODE,READONLY
EXPORT Swap16
EXPORT Swap32
Swap16
mov r1, r0, lsr #8 ;swap top half into r1
mov r2, r0, lsl #24 ;swap bottom half into r2
add r0, r1, r2, lsr #16 ;combine parts together
mov pc, lr
Swap32
mov r1, r0, lsr #24 ;put byte 4 in position
add r1, r1, r0, lsl #24 ;put byte 1 in position
mov r0, r0, ror #16 ;move bytes 2 and 3 to edge
mov r2, r0, lsr #24 ;put byte 2 in position
add r2, r2, r0, lsl #24 ;put byte 3 in position
add r0, r1, r2, ror #16 ;combine final answer
mov pc, lr
END
but it seem neither Swap16 and neither Swap32 do their job correctly...
The only thing i've changed is the Return Value Which need to be in R0 (not r1)
I still don't understand why we can't use rolw $8?
like mov r0,r0,rol #8 ?
sorry i know well Only 68000 processor. i'm from old Generation...hehe
ARM only has ror

of course that not a problem, since any rol can be converted to a ror
however you can't rotate around just 16 bits, the ror command rotates around the full 32 bits, so it won't achieve what we want, ARM has very few 16 bit commands
I think I might have worked out why the C code is compiling so badly, I can't talk much now because I'm supposed to be at work at the moment, I'll post some C code to try compiling this evening.
Just thinking out loud...
Surely moving the endian swaps into functions rather than inline macro expansions forces a function prologue and epilogue (i.e. register stacking), and those must be accounted for when counting instructions. In some cases it might be that the original inline instructions are still faster than the function call.
I'm pretty sure that eVC++ doesn't handle inline functions. Also, an emit is dangerous (I believe) because you don't know which variable is in which register.. unless you write an entire function using emit, which brings us back to the function prologue and epilogue "problem".
Cheers,
Ref.
the problems with not byte swapping, and just storing everything back to front are:
a) byte read/writes on the 68000 are not word aligned. so if we just store it backwards and someone does:
move.w d0,(a0)
move.b 1(a0),d1
it's going to wrong. This could be compensated for relatively easy in the byte access routine, but probably not in in less than the 3 instructions it took to fix up the word access routine.
b) memory access is only word aligned, not long aligned, so if someone does:
move.l d0,(a0)
move.l 2(a0),d1
it's going to go wrong.
This isn't a new idea by the way, it's been used since about 1997 in about 90% of 680x0-machine emulators (and in every single high performance 680x0 emulator) and is established as by far the fastest way to emulate a 68000 on a little endian machine.
Genecyst, KGen, Callus, NeoRage, MGE, MAME
It's hard to think of one which doesn't use this method in fact.
To access bytes simply xor the address with 1.
To access dwords, swap the high and low order words.
Againt it could be compensated for but I'm not convinced be any quicker than the endian swap code I already place.
Swap the high and low order words = 1 opcode, instead of 6. If that doesn't convince you, then nothing will!
Honestly, you should try it: learn from previous emulators.
ok, sounds good to me
If you could provide the macros for reading and writing, bytes, words, and longs using this technique it would be great
Otherwise I'll try and write or find macros for these myself later this evening.
I have nothing against storing everything back-to-front at all, we just need the code to do it quickly, if it can be done using simple tricks with xors then thats great.
Andrew
yes this technique seem very interresting,
but the only source i found are from Mame, and there is nothing explained....
Macros will be welcome :)
Thanks you very much.
Hi,
here are the macroers for the technique, of storing words (but not long words) backwards.
#define ReadB(addr) *(uint8*)(addr^1)
#define WriteB(addr,value) *(uint8*)(addr^1)=value
#define ReadW(addr) *(uint16*)(addr)
#define WriteW(addr,value) *(uint16*)(addr)=value
#define readL(addr) (*(uint32*)(addr)<<16)|(*(uint32*)(addr)>>16)
#define WriteL(addr,value) *(uint32*)(addr)=(value<<16)|(value>>16);
Unfortunately as far as I am aware C++ doesn't have an operand for rotate (Correct me if I'm wrong!), so I just hope the compiler is smart enough to spot that (value<<16)|(value>>16) is in fact just a simple ror #16
Note that if you store the words backwards like this it's going to mess up any other code that accesses the memory, for instance the screen draw code I gave earlier will now end up drawing the columns back to front, this could be corrected easily enough
I guess the best thing to do would be try the code, see if it works, and how much faster is is (or isn't) and then if it gives a good speed up I'll rewrite the screen redraw code (again) to handle getting everything backwards
If you could post what the compiler produces from the above defines it would help to see how a good job it has managed to do
Thanks
Andrew
hey andrew ReadB and WriteB are strange, i've replaced by this:
#define ReadB(addr) (*(uint8*)(addr))^1
#define WriteB(addr,value) *(uint8*)(addr)=value^1
#define ReadW(addr) *(uint16*)(addr)
#define WriteW(addr,value) *(uint16*)(addr)=value
#define readL(addr) (*(uint32*)(addr)<<16)|(*(uint32*)(addr)>>16)
#define WriteL(addr,value) *(uint32*)(addr)=(value<<16)|(value>>16)
is it correct?
in the case of yes , here is what the compiler generate:
; 205 : WriteB(address + membase, value);
eor r3, r1, #1
ldr r1, [pc, #8] ; pc+8+8 = 00000014
ldr r1, [r1]
strb r3, [r1, +r0]
; 211 : WriteW(address + membase, value);
ldr r2, [pc, #8] ; pc+8+8 = 00000010
ldr r2, [r2]
strh r1, [r2, +r0]
; 217 : WriteL(address + membase, value);
mov r3, r1, lsr #16
orr r3, r3, r1, lsl #16
ldr r1, [pc, #8] ; pc+8+8 = 00000018
ldr r1, [r1]
str r3, [r1, +r0]
; 222 : return ReadB(address + membase);
ldr r1, [pc, #0xC] ; pc+8+12 = 00000014
ldr r1, [r1]
ldrb r3, [r1, +r0]
eor r0, r3, #1
; 227 : return ReadW(address + membase);
ldr r1, [pc, #8] ; pc+8+8 = 00000010
ldr r1, [r1]
ldrh r0, [r1, +r0]
; 232 : return ReadL(address + membase);
ldr r1, [pc, #0x10] ; pc+8+16 = 00000018
ldr r1, [r1]
ldr r0, [r1, +r0]
mov r3, r0, lsr #16
orr r0, r3, r0, lsl #16
readB and writeB were strange, but they were in fact right :-) you have to xor the address not the value! It's to compensate for the fact that the bytes aren't stored in the correct place
the compiler hasn't done an amazing job with readL and writeL but at least it's still better than what it was producing before, so it should still be a good speed up
just to confirm what i think, if we use this method, we'll must apply Read and Write on ROM (TOS) and on Floppy disk Sector read, no?
but how? just Readb and writeB or need to apply ReadB/WriteB a first time and then Apply ReadL and WriteL?
so when i compil there is a problem.....
mem.c(176) : error C2296: '^' : illegal, left operand has type 'char *'
mem.c(205) : error C2296: '^' : illegal, left operand has type 'char *'
mem.c(222) : error C2296: '^' : illegal, left operand has type 'char *'
the compiler dont like we use ^ on char *
any idear?
hmmm.. try casting addr to an int first
e.g
#define ReadB(addr) *(uint8*)((int)addr^1)
#define WriteB(addr,value) *(uint8*)((int)addr^1)=value
ok that has worked:
#define ReadB(addr) *(uint8*)((int)(addr)^1)
#define WriteB(addr,value) *(uint8*)((int)(addr)^1)=value
schtruck wrote:
just to confirm what i think, if we use this method, we'll must apply Read and Write on ROM (TOS) and on Floppy disk Sector read, no?
but how? just Readb and writeB or need to apply ReadB/WriteB a first time and then Apply ReadL and WriteL?
yes you are correct, you will need to byte swap the ROM when the emulator first starts up so that it is stored the same way around as the rest of the memory
so to do this use something like
- Code:
uint8* romadr;
for (int n=0; n<romlength; n+=2) {
uint8 val1 = romadr[n];
uint8 val2 = romadr[n+1];
romadr[n] = val2;
romadr[n+1] =val1;
}
to just swap the pairs of bytes in each word. Not exactly efficient, but I don't think this bit needs to be.
deleted, you got it working anyway
OK andrew i begin to Swap ROM then i start the emu to see if that work:
My ICQ is 160799917
Yeah BYTES SWAP TRICK Work!!!
the problem was that ARM can only access 32 to Address divisible only by 4..... so here is what i did:
#ifdef BYTES_SWAP
#define ReadB(address) *(uint8*)((uint32)(address)^1)
#define WriteB(address,value) *(uint8*)((uint32)(address)^1)=value
#define ReadW(addr) *(uint16*)(addr)
#define WriteW(addr,value) *(uint16*)(addr)=value
#define ReadL(address) ((*(uint16*)(address))<<16)|(*(uint16*)(address+2))
#define WriteL(address,value) WriteW(address + 2, value); WriteW(address, value>> 16)
#else
#define ReadB(address) *((int8 *) (address))
#define ReadW(addr) ((*(uint16 *)(addr) << 8) | (*(uint16 *)(addr) >> 8))
#define ReadL(address) ((uint16) ReadW(address) << 16) | (uint16) ReadW((address) + 2)
#define WriteB(address,value) *((int8 *) (address)) = (value)
#define WriteW(addr,value) *((int16 *)(addr)) = ((((uint16)(value)) << 8) | (((uint16)(value)) >> 8))
#define WriteL(address,value) WriteW((address) + 2, value); WriteW(address, (value) >> 16)
#endif
and here is what the Compiler Generate:
; 197 : WriteB(address + membase, value);
ldr r2, [pc, #0x10] ; pc+8+16 = 00000018
ldr r2, [r2]
add r3, r2, r0
eor r3, r3, #1
strb r1, [r3]
; 203 : WriteW(address + membase, value);
ldr r2, [pc, #8] ; pc+8+8 = 00000010
ldr r2, [r2]
strh r1, [r2, +r0]
; 209 : WriteL(address + membase, value);
ldr r2, [pc, #0x18] ; pc+8+24 = 00000024
ldr r3, [r2]
add r3, r3, r0
strh r1, [r3, #2]
mov r3, r1, lsr #16
ldr r1, [r2]
strh r3, [r1, +r0]
; 214 : return ReadB(address + membase);
ldr r1, [pc, #0x10] ; pc+8+16 = 00000018
ldr r1, [r1]
add r3, r1, r0
eor r3, r3, #1
ldrb r0, [r3]
; 219 : return ReadW(address + membase);
ldr r1, [pc, #8] ; pc+8+8 = 00000010
ldr r1, [r1]
ldrh r0, [r1, +r0]
; 224 : return ReadL(address + membase);
ldr r1, [pc, #0x14] ; pc+8+20 = 0000001C
ldr r1, [r1]
add r2, r1, r0
ldrh r3, [r2, #2]
ldrh r2, [r1, +r0]
orr r0, r3, r2, lsl #16
not so bad :)
let me test Game now to see How that boost....
Hey andrew could you Adapt you Draw Routine for Bytes SWAP please.
OK i have Modified your Draw routine to support BYTES SWAP trick.
What i can say is that the Speed we expected hasn't been Totally Reached. it's Faster, some game are FULL speed now, like Turrican 2 and Speedball, but some are still Really Slow (a few but that make me nervous).
The Reason is perhaps the Missing Of Implementation of Timer A and B in Counter mode, but i need to now :)
If you Want Andrew, i can send to you my sources, you'll can already implement PPC2000 support, it's easy.
For now i've already implemented PPC2002 IPAQ 36,37,38 support, but others PPC2002 can be implemeted quickly.
I presume you just changed the last 8 lines to
*--line_o1 = bigpal[((r4>>8)&240)+((r3>>12)&15)];
*--line_o1 = bigpal[((r2>>8)&240)+((r0>>12)&15)];
*--line_o1 = bigpal[(r4>>4)&240)+((r3>>8)&15);
*--line_o1 = bigpal[((r2>>4)&240)+((r0>>8)&15)];
*--line_o1 = bigpal[(r4&240)+((r3>>4)&15)];
*--line_o1 = bigpal[(r2&240)+((r0>>4)&15)];
*--line_o1 = bigpal[((r4<<4)&240)+(r3&15)];
*--line_o1 = bigpal[((r2<<4)&240)+(r0&15)];
and left the rest the same?
Ehm, this is getting extremely interesting. Demo?

Turrican at full speed?
That's awesome.
That leaves just one question unanswered:
When do you please us all with your masterpiece of software?
Ehm.. Hello?
What i can say i that i'm curently preparing a Site for CastCe (the name of this ATARI ST emulator ).
Emu is being very interresting..... Andrew Gower has joined the project and is curently hardly working to optimize it and make Exact Timing to improve Compatibility.
For Now the Emulator is Fast enought (full speed) for most Game, but we expect more to Add sound....
Btw, when Emu Will be ready (hope soon, less then 2 weeks), but sound will be add later..
Just a little List of Best game curently compatible and full speed:
Dongeon Master,Xenon 1 & 2, SpeedBall,Pang, Beach Volley, Ivanhoe, R-type, Ghost& Goblin, Buggy Boy, and many others..
The Site will Start with Some Shots of this Emu running those game and more.... hope very soon.
Believe Me , that worth the Wait......
this is the Best Emu i saw on PocketPC.....
Schtruck.
OK, thanks for the info. Hey, we here at Overloaded have lots of devices; if you want us to test the emu on some of them, just let me know.
Sounds exciting to me.
As an old Atari STE user I will me more that just happy when you will decide to share the emu with us.
I'm still a big fan of computers that belong to the golden 16-bit era and I hoard a large collection of Atari (and Amiga) disk images. I case your looking for a Jordana tester - give a shout. I was beta tester for a couple of things (WinFellow to name one).
Please keep us informed. We're keen to hear more about CastMe.
I am extremely eager to play dungeon master on my PocketPC... if you actually want any more testers I would be glad to be one (HP Jornada 565, I have friends with a Jornada 525 and some PocketPC 2000 iPaq). I tried with PocketDOS and it didn't like my fake hard disk so I've been waiting on either an Atari ST emulator or Apple IIGS emulator. Of course, an Amiga emulator would be best, but I'd be satisfied (and quite happy) with Atari ST. If you would like me to test it (or are just willing to LET me test it), please e-mail me at
alien@greenblooded.com
I owned a 520 STe when I was ... pfouuuu ! 14 years old ... AHHHHH!
Rick Dangerous
Joust
Speedball II
Capitain Blood
etc.
I was waiting for a ST emulator on my PPC since 2 years and ... it arrives !
I'm very impatient to see this old good "green desktop" on my HP and on my EM-505 !
... Sorry ... I think that I'm going to cry ... LOL ;-)
Thx Schtruck & Andrew
Hi all,
I have a question: will the emulator support Xscale tecnology and PDAs like Toshiba e740 and Fujitsu-siemens Loox 600?
Thx in advice for the reply.

Following a posting at PocketExtreme.ru the first release of CastCE will be for iPaq's only. Other PDA's may be supported after the CVS is open to public. That sounds to me that non-iPaq-users have to hope that someone else than the original author will adapt CastCE to their favorite device.
In case this is true my europhia is blown away.
Do I have to buy one of this cheesy looking iPaqs to get it to work? Please not ...

Ozzy would say in moments like this "FXXX!" ...
I mean, is it possible that this software won't work on a PDA with same CPU, like IPAQ 3970 and Loox, and why?
I mean I see software for ARM usually .... not for IPAQ

will the coder insert such a line?
x:=GetHardWareVendorID
if x <> 'COMPAQ' then Halt(0)

))))

There are some very specific differences between all ARM devices that may lead to some compatibility problems. I don't think that this is a serious probelm to address but the author would need a device to test the software ...
i have a old 1024 st somewhere at home, im not sure where.
is it suported?
Generally, STFM and STE's are inter-compatible.
For those you don't know, the ST line is split into two main parts (ignoring the earlier STF's, or STM's, whichever it was) - the STFM and the STE. Both are based on the m68000 (same as the Macintosh line I think).
The STFM I think was the most popular sort of Atari. It was quite basic, and came with TOS 1.02 (the operating system). The STE was an enhanced version, with a blitter chip (for graphics), some stereo features, and a newer TOS 1.62. STFMs and STEs were generally extremely compatible with each other. Few programs required an STE to run, but when they did, it was worth it!
Both machines were often upgraded to TOS 2.06... ahh, those were the days....
Then you get the 1040STFM, 1040STE, 4160STE etc... the numbers only refer to the memory. 520 was 512kb, 1040 was 1MB, 2080 was 2MB etc. The only difference between a 1040 ST and a 520 ST is the amount of RAM.
ST emulators usually emulate an STE, seeing as an STE is essentially an STFM with extra things bolted on. In fact, the different between STFM and STE is so slight, most people refer to them both as the 'Atari ST'. Anything you have which ran on an Atari STFM/E should run on any modern ST emulator.
From the STE Atari then made the 68040-based Falcon 040... and some other machines. But I've never used any of them
That's probably confused a load of people, but I just had to get the nostalgia out of the way
-- Dave
That is to say, abannedguy, that your ST games should run without problems on any modern ST emulator.
Dave
Don't you remember the list of 50-odd games that had to be patched to work on the STE when it was released?
Not quite sure how this affects compatibility between unpatched games and emulators that specifically emulate the STE.
That's what I get for waking up too early.
Yeah, you're right, lots of games did have problems working on the STE, but on the other hand, a lot more didn't. Granted, the ones that fiddled with the STFM registers and whatever else in various components to squeeze out extra coolness had problems with the minor changes in the STE... but something something.
But that number was quite small compared to the number that had problems with TOS 2.06 :) I remember finding various tutorials for making TOS switchers in ST Format (the last ST mag I remember seeing in the shops) so people could just switch between the two sets of TOS chips!
I was one of those who released a game which worked fine on the STFM only to have to do a quick fix for the STE. The main problem was that it ( the STE ) used slightly more ram for the system than the stfm so if you wrote a game to utilise all the memory you were in trouble. Fortunately the game publisher (Red Rat) had not made any floppy disks so disaster was averted by simplifying a few graphics.
My STFM will boot sometimes but othertimes it just won't start so if it wasn't for emulators I would not be able to play all those old favorites.
the 1024 ST is a 386 based atari, not a 680x0 based..
There was no 1024 ST, but there were 1040 ST's... no ST used a non-m68000 processor!
However, IIRC, Atari did bring out one IBM PC clone... (not the Mega ST, which was just an ST but with separate mouse and keyboard), but it wasn't under the ST name as far as I can recall.
Anyone else know? I read this stuff 8-10 years ago when I was just hitting teens and there's some stuff I can't remember and/or invented.
ATARI's IBM PC clone was called "ABC", all i can remember is that it featured an EGA graphics adapter.
cryo
So, has it been released or still in limbo?
I'm very interested ....
l8r
I don't want to sound too heretic but ...
... this sounds like playable emulation of a Amiga 500 is possible. That was meant as a question ;-)
Amiga had custom chipset, more difficult to emulate and more versions than ST.
Many games were common to both systems.
I think the better thing is to have a perfect ST emulator for current PPC powers.
Amiga can wait xscale better performace, probably another PPC generation is needed.
Enjoy the near CASTCE release, and leave amiga to the future world....
To SchTruck:
has the CASTCE a virtual HD support? Machine state save? Rasters support? I hope also in a good virtual joy and virtual mouse support, tapping screen is very less disintegrating for the PPC than real pd use ....
L8r friends.
I'm aware of that fact (I myself was a Amiga user for nearly 8 years). I wasn't talking about low level emulation of the full range of exsisting Amiga computers. I'm clever enough to know that this will be an impossible task. But Amiga 500 games have been playable on a P133 (with sound) by using Fellow (I know that Petter Schau coded the hole in Assembler only). But with a fast 68k core it should be possible ... an UAE port for Zaurus was released a few weeks ago ...
I don't want to say that I want anything that also works on the Zaurus ... but it would be a cool piece of software for any retro lover ... like me.
Ho no no, i'm not agree. Amiga isn't more difficult to emulate as we need more power to emulate an ST...
CPU 8mhz, Sample tricks etc..
An amiga has COP for Video etc, emulation is harder, but as there is already Near perfect emulator (Winuae...) that will be easy For US to make it. In fact we don't lose too more time as People have already Understood how Hardware is....
Hi SchTruck, how does it proceed with the release of CastCe? Will be near? In 2002 or must we wait 2003?
I'm waiting, and "wait" is hard ...
I have to admit, that I'm nervous, too.
Especially about possible Amiga emulation taking place on my palm ...
I've bought a 512 MB CF card on Sat ... so feel free to release it ;-)
as subject says ....
I have a simple question:
What filetype will CastCE support? .ST? .MSA?
I already have a complete archive of games just waiting for CastCE!

)
me too! but we haven't news about CastCe from about twelve days :~ I hope SchTruck is ok, he spoke of a little bug that lower compatibility, but he said it was fixable in a couple of days (21 november)
I hope it's about time.....
I hope so too. I hope this thing is not
vaporware.

It's going to be so
popular.

still no news..... what's happened?
Vaporware vaporware!!!
Come on folks.
There's a small chance that the guy developing this may have things called "family" and "life" that hinder his progress on the project.
My own project has been on hold for the last 3 weeks for this very reason.
Yea, and now that LDChen is done with the recompiler, his PS emu will be more busy too.. geez so quick to yell vapour.
Where the hell is schtruck??? I haven't seen him around for almost a month now. If I would have a Atari ST emu that runs full-speed I would be so happy about it and share a lot more during development on the boards.
Can we just here something about it's progress at least?
Ho no no don't worry we (me and AndreW Gower) are working hardly on CastCE to make it nearly perfection
The day of the official out is not so far......
Schtruck
The AtariST emulator called " CastCE "
Features:
Sound support
*.st, *.msa and *.zip images/files support
Switchable between the Soft keyboard and the virtual Joystick menu.
Virtual Joystick options : Fire, Auto-Fire, 8-way Joystick directions
TOS Screen resolution : Low and Medium
Here the link to download the video (1MB):
http://www.proplayadvance.com/Video/castce.wmv
Greetings,
CharlyV
Can't wait for it to come out.

Now I have
proof that it's not vaporware and strutck is still alive!

I'll shut up now and let the masters finish the good work.

Make it a Christmas present ;-)
I'm impressed.
Turn my high tech toy into a 15 years old homecomputer ...
Make my wildest dreams come true: Dungeon Master and Ambermoon on the palm of my hand. Iron Lord, Xenon, Pirates, Elite, Turrican, Legend of Faerghail, Chaos Engine, Elvira 2 ... I could type forever ...
You guys rule.
Just can't wait to play Super Cars II. Hopefully the Noisetrackers will also work with it. This would fill the void that PPC has had with its lack of any kind of trackers.
/jizmo
for Wickie:
sorry for Ambermoon, only Amberstar for ST
Ambermoon only Amiga, you are talking to the greatest Thalion/FLT/any RPG fan on ST, thrust me

Any SoundTracker will not work on CastCE !
The Trackers are going into hardware specific addresses.
CharlyV
You're right ... I meant Amberstar ... not Ambermoon.
I know that Ambermoon was not officially released ... only Amberstar was. But there's still a unreleased german version of Ambermoon for the STE and an English localized x86-version that was build for Red Baloon (the software comany of BMG) but also never released ... the STE-Version has been demoed to a UK ST print mag by Karsten Köper (Designer and Producer) ...
CharlyV,
too bad about the soundtracers. But there are still some normal composing utilities that produce sound without hacking the hardware.
There was some early ST-specific tracer that was ST-friendly (only 3 channels) .. TCB tracker if I recall correctly. It just might work.
Keep up the good work,
/jizmo
Still no news? From the video it appears near perfect ....

hoping in a Xmas present from SchTruck

)
yeah tooniighhttt
i prefer to delay a bit the official release, because i've just added Savestate, but haven't finished it, but it's very usefull
And Andrew has added Sample Trick, and i have optimized the emu a bit. But Game which use Soundtracker at freq > 11khz are slow (not 100%) (i mean the music, because those game are very playable), so we have to optimise a bit emu for those game (they aren't so many).
By the way, expect a version before the end of next week
Ps: the soundtrack of Xenon2 (bomb the bass) is Perfect!!!
Yau!!!!!!!!!!!!!!!!!
We love you SCHTruck!
I hope Santa bring u a Pamela Andersonn

thanx a lot
i wait it so bad

ehrrr.....Pamela Anderson has hepatitis C. You might want to reinterprate that well wish as a bad health advice instead.
lol
anyway, may Santa bring you another blond with bigboobs instead....
Hi schtruck, sent you a PM yesterday

I'm not sure when it will be released, but we're putting together a website for it now. I expect to spend this afternoon taking sreenshots and coding html :-)
It's running pretty well now, I've got 42 of my favourite Atari ST games crammed onto my 32meg ipaq. All of which run pretty much perfectly. Speed isn't quite 100% when playing samples, but it's a lot better now since we managed a few more speedups this week
Thanks
Andrew Gower
Hey if you need any help with the site, send me a mail or private message, I'd love to help.
Wooaaaa! A web site where i'll spend days hitting the refresh key for the release message to show up.

week ended
no release

:(:(:(:(
booooohhhhhhh no release !?????
nope .. nothing.
come on, guys

.. i'm beginning to think you actually enjoy this situation.
No no Sorry we are Working hard, and just 6 hours ago we have fixed a Bug which now surely boost compitibility to 99,99 percent!!!!
Dragon's lair1 ,2 and 3 re fully playable!!!!
now i have to work on some finition, that will take for me less than 48 hours, today we'll make public the Homepage.....
everybody will be very surprised :)
I'm very happy of this!
I think people are afraid of vaporware because many other emulators has been released in early stages, where they are not working at all or only a little working, instead of CastCE that seems that won't be released until it is at 1.0 Gold ED

In any case, keep up the good work and make we see this killer app when u think it's time!
Bye , meok

I've put up a webpage with some more information about CastCE.
You can see it here:
http://www.pocketinfinity.com/
I will also post up to date news on the page when we make any big improvements, and of course the download will be put on that page, when it is ready. We just want to finish Gapi support to hopefully make it work with a few more devices
Thanks
Andrew
cool i will refresh the page everyday,hum every hour

i hope the e570 will be supported
a GAPI draw support will come soon to be compatible with more different StrongARM PPC´s.
Greetings,
CharlyV
.
..