Statistics: Posted by Chilly Willy — Tue Jul 25, 2017 2:36 pm

]]>

]]>

]]>

Here is an exclusive video !

https://www.youtube.com/watch?v=5DrcDBD ... e=youtu.be

No more comments, just watch & enjoy it !

Cheers,

Vetea

Statistics: Posted by Vetea — Tue Jul 25, 2017 2:16 pm

]]>

d1 = 21

d2 = 17

# d1 and d2 are random divisors

a % (d1*d2) == a // d1 % d2 * d1 + a % d1

a % 320 == a // 64 % 5 * 64 + a % 64

a % 320 == (((a >> 6) % 5) << 6) + (a & 0x3F)

r57shell, there's no need in "|" in next line, just use "+".

CODE:

`| (a & 0x3F);`

Statistics: Posted by GManiac — Tue Jul 25, 2017 9:21 am

]]>

And, for full desc, here is C code:

CODE:

`u16 rem320(u16 a){return (table[a>>6]<<6) | (a & 0x3F);}`

you may run it here: http://cpp.sh/

Second version using *2 instead of <<6, which is faster if your compiler do:

CODE:

`add d0, d0instead oflsr #1, d0`

plus you'll have issues with addressing 2 bytes instead of 1 bytes, because you'll need to discard least significant bit somehow.

you can do all of this with other modulo. results depends on modulo.

Statistics: Posted by r57shell — Tue Jul 25, 2017 8:31 am

]]>

The change is in Echo_GetStatus (and its C counterpart): the returned status will take into account any pending commands (i.e. that were just sent but still not processed by the Z80), so if you e.g. call Echo_PlayBGM then Echo_GetStatus, it'll show up as BGM playing even if the Z80 didn't get to it yet. This is cheating, but lines up more closely with programmer expectations, and should make things easier.

Technical explanation

We're going straight into hardcore multithreading territory here.

When the 68000 sends a command to Echo, it won't be executed immediately, but rather whenever the Z80 is free (more specifically, once it's done processing the current tick for all streams). If you tell it to play or stop a stream, the status flags will be updated accordingly once Echo gets to processing the commands. The problem is if the 68000 tries to retrieve the status right after sending such a command, since it's likely the status won't have updated yet, and this catches programmers off guard since they don't realize that they need to wait for Echo to handle it.

What this patch does is change Echo_GetStatus to look ahead at any pending commands (i.e. commands that haven't been processed by Echo yet) and guess what the status would be if Echo had already processed them (i.e. if a play BGM command was pending, it'll set the BGM playing flag), and then return this new guessed status instead of the real one. This way game code doesn't have to explicitly handle waiting for Echo to process commands.

tl;dr it's trying to predict the future =P

Statistics: Posted by Sik — Tue Jul 25, 2017 7:08 am

]]>

CODE:

`// convert buffer from s16 pcm samples to u16 pwm samplesfor (i = 0; i < num_samples*2; i++){ s16 s = *buffer + SAMPLE_CENTER; *buffer++ = (s < SAMPLE_MIN) ? SAMPLE_MIN : (s > SAMPLE_MAX) ? SAMPLE_MAX : s;}`

I also tried to rule out the possibility of improper 32X setup. He's using a Model 1 which I've heard can have audio problems with the 32X but most things I've seen have said that using the headphone output instead of the rear output will fix those, and he IS using the 3.5mm headphone output so... I suppose I could try and send him your own XM player build and see if he has problems with that too.

Also taking a look at getting my own 32X. Eyeing a whole set of 32X/cables/Megadrive on Ebay for $50. Don't have a TV for it though, gave all my CRTs to Goodwill when I moved like two houses ago, so I'd also probably have to pick up a cheap upscaler or something. Money's kinda tight though, which makes getting myself a real 32X a challenge.

Statistics: Posted by KillaMaaki — Tue Jul 25, 2017 6:37 am

]]>

Example:

CODE:

`a = 123m = 5b = 16# equal resultsprint( a % m )print( ( (b % m) * (a // b) + (a % b) ) % m )`

https://en.wikipedia.org/wiki/Residue_number_system

Conversion example:

http://neo.dmcs.p.lodz.pl/csII/ca2_ResidueNS.pdf

Fast example In Russian:

http://wiki.tgl.net.ru/index.php/%D0%A1 ... 0%BE%D0%B2

Code demo for your task

CODE:

`# pre-compute tabletable = [0]*320for i in range(320): table[64 * (i % 5 ) + (i % 64)] = ia = 65533mod64 = a & 0x3F;#a mod 5a = (a >> 8) + (a & 0xFF) # 256 % 5 = 1, a will become <= 510a = (a >> 4) + (a & 0x0F) # 16 % 5 = 1, a will become <= 45if (a > 14): a = a - 15;if (a > 14): a = a - 15;if (a > 4): a = a - 5;if (a > 4): a = a - 5;mod5 = amod320 = table[64*mod5 + mod64]print(mod320)`

Statistics: Posted by GManiac — Mon Jul 24, 2017 9:02 pm

]]>

Fast version will require pre-computed array.

Straightforward method is (don't be confused with different meaning of 'x'):

x mod 320 = x - x div 320 * 320.

1. x div 320 = table[x >> 6] - something like 20 cycles

2. x * 320 = (x << 6) * 5

x*5 = x << 2 + x

in asm (something like 24 cycles):

CODE:

`lsl.w #6, xmove.w x, x4lsl.w #2, x4add.w x4, x`

Statistics: Posted by GManiac — Mon Jul 24, 2017 7:21 pm

]]>

]]>

I prefer 384 over 320 because:

- This number still let you do a small scroll (looks better)

- Playfield, or map in RAM, is 4096x2048 pixels max in size, so using 384 fits better. (In true, playfield can take several sizes but all using numbers of 2^n serie, still 384 fits better).

So we have: 384 = 3*128. Mod of 128 is easy: x AND 127. For "x mod 3": I have found an easy solution:

( From http://homepage.cs.uiowa.edu/~jones/bcd/mod.shtml )

CODE:

`static inline u32 mod3( u32 a ){ a = (a >> 16) + (a & 0xFFFF); /* sum base 2**16 digits a <= 0x1FFFE */ a = (a >> 8) + (a & 0xFF); /* sum base 2**8 digits a <= 0x2FD */ a = (a >> 4) + (a & 0xF); /* sum base 2**4 digits a <= 0x3C; worst case 0x3B */ a = (a >> 2) + (a & 0x3); /* sum base 2**2 digits a <= 0x1D; worst case 0x1B */ a = (a >> 2) + (a & 0x3); /* sum base 2**2 digits a <= 0x9; worst case 0x7 */ a = (a >> 2) + (a & 0x3); /* sum base 2**2 digits a <= 0x4 */ if (a > 2) a = a - 3; return a;}`

Statistics: Posted by Miquel — Mon Jul 24, 2017 5:02 pm

]]>

https://www.youtube.com/watch?v=VQmHwAEOXl0

Statistics: Posted by SegaTim — Mon Jul 24, 2017 12:46 pm

]]>

We need cool property.

I'll describe it using decimals system.

Assume you want to divide decimal by 500.

In other words, you want to find floor(x / 500).

Imagine you know already result, and this result is y.

then y*5*100 <= x

in other words, floor of (x/500) is how many y*5 fits into number floor(x / 100) which is just cut off two digits in the end

Now, same in binary: 320 = 32*10 = 32*2*5 = 64*5.

this means, that floor(x/320)=floor(floor(x/64)/5)

where floor(x/64) is simple bitwise shift right by 6. 64 = 2^6.

assume z = floor(x/64), then it is 10 bits long if x is 16 bits long.

now you need only make table to find floor(z/5), for all numbers 10 bits long.

but then you need to multiply result by 320 again.

I suggest using another table for this purpose.

other possible way is some divisibility property.

If latest 6 bits is discardable, all you need is to find remainder of divison by 5.

And, there is only 5 possible remainders: 0, 1, 2, 3, 4, 5.

Somehow (I guess) you may find it as for example in divisibility of 3 in decimals: all digits must have sum divisible by 3.

But, it can be slower.

Edit: easier. If you imagine long division method from school,

you'll find that it will look as:

CODE:

` xxxx xxxx xxxx xxxx |1 0100 0000-1010 0000 0..... -1010 0000 0 ....`

from opposite, you can't subtract less than 1 0100 0000, this means shift is greater or equal to 6.

This means that it may subtract during process of division at following positions:

CODE:

` xxxx xxxx xxxx xxxx |1 0100 0000-101 -101 -10 1 ... -1 01`

result I mean remainder here. Three bits that you'll get, is same. Just because you do literally same.

This means: x % 320 = (floor(x/64)%5) * 64 + ( x % 64 ) = ( ((x >> 6) % 5) << 6) | (x & 0x3F)

where x & 0x3F is bitwise and.

With this method you need to precompute ((x % 5) << 6) table for 10 bits long numbers.

Edit: replaced ceil with floor.

Statistics: Posted by r57shell — Mon Jul 24, 2017 10:06 am

]]>

proof: https://youtu.be/X6q1VmEBfr8

I buy my mega-pc on ebay in very bad condition.

After repair and some upgrades it work fine with sega-cd

repair :

dead system controller 76c010

dead and leaked battery

removed recaped capactors

dead VIA pads on sega side

no sound - bad tracers

broken button on cartridge slot (sega power-on)

broken FDD (dead step motor)

invalid HDD (80GB!!!)

Upgrades:

added new 4 simm-30 sockets and 2mb ram (6mb overal)

added internal palcoder for RCA out (video, R, L)

installed 530MB HDD

changed FDD.

----------

some fotos : https://vk.com/album96271606_245412790

Statistics: Posted by piroxilin — Sun Jul 23, 2017 10:20 pm

]]>