11 March 2020, 12:48 | #1 |
Registered User
Join Date: Nov 2019
Location: Groningen / the Netherlands
Posts: 16
|
How to pre-calculate the Protracker mt_PeriodTable
Hi,
How did Karsten Obarski ( coder of the first Amiga SoundTracker ) calculate the period table? How did Lars Hamre ( coder of Protracker ) calculate the fine_tune stages? Started coding a Protracker2.3 Replay routine for Windows using the Microsoft Assembler ( Masm ) To shave some bytes of the executable, I want to pre-calculate the "mt_PeriodTable". Wrote a routine assuming a western equal-tempered scale, but ended up with 37 mismatches. Code:
Calculate_mt_PeriodTable: mov edi,offset PeriodTable+576 ; Start at the second half of the Period Table memory buffer movss xmm0,BasePeriod ; Best possible period match: 906.9023 -> ( 3546895 / 3911 ) movss xmm1,xmm0 mov dl,2 ; Split the Period Table in 2 halves split_LP: mov dh,8 ; 8 fine tune stages per half Period Table next_finetune_step: mov cl,36 ; 3 octaves ( 3 * 12 notes ) octaves_LP: cvtss2si eax,xmm0 ; Convert period float to 32 bit integer mov [edi],ax ; Save period value as 16 bit integer divss xmm0,twelfth_root_of_2 ; Calculate next period value in the present octave -> 2^(1/12) = 1.059463 add edi,2 dec cl jnz octaves_LP divss xmm1,semitone ; Calculate next fine tune step -> 2^(1/12/8) = 1.007246 movss xmm0,xmm1 dec dh jnz next_finetune_step mov edi,offset PeriodTable ; Jump to the start of the Period Table memory buffer dec dl jnz split_LP ; Code size 70 bytes Or do I need to write some reconstruction code to repair the 37 mismatches? The challenge is to write the smallest piece of code that matches 100% the original "mt_PeriodTable". |
11 March 2020, 13:24 | #2 | |
Registered User
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,153
|
Quote:
https://eab.abime.net/showthread.php?t=69675 (I was looking absent-mindedly at your assembly code, wondering why it looked strange, until the penny dropped - it's X86 assembly! In an Amiga forum! Sacrilege! ) |
|
11 March 2020, 13:54 | #3 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
I completely fail to see the point in attempting to shave bytes out of a Windows executable...
|
11 March 2020, 14:11 | #4 |
Registered User
Join Date: Mar 2012
Location: Norfolk, UK
Posts: 1,153
|
|
11 March 2020, 14:45 | #5 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
In todays windows world, really ?
Considering the amount of work to do for just a simple 2D screen setup and for just playing a sound, i seriously doubt anything useful can be done with such a small executable size... |
11 March 2020, 14:45 | #6 | |
Registered User
Join Date: Nov 2019
Location: Groningen / the Netherlands
Posts: 16
|
Quote:
Thanks for the link to the thread ( missed that thread ), it seems a bit more difficult than I thought..... The most mismatches are in the Tuning 0 and -8 stages (28). See if I can create some kind of small period repair code...... |
|
11 March 2020, 15:06 | #7 | |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,211
|
Quote:
[ Show youtube player ] [ Show youtube player ] just a couple.... |
|
11 March 2020, 15:08 | #8 | |
Registered User
Join Date: Nov 2019
Location: Groningen / the Netherlands
Posts: 16
|
Quote:
DirectSound and Direct3D9 or OpenGL are your friends in the Windows Demos world. |
|
11 March 2020, 15:54 | #9 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
|
11 March 2020, 16:08 | #10 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
|
11 March 2020, 16:13 | #11 | |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
Quote:
1k with sound: https://www.pouet.net/prod.php?which=32194 |
|
11 March 2020, 16:18 | #12 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
|
|
11 March 2020, 16:38 | #13 |
Lemon. / Core Design
Join Date: Mar 2016
Location: Tier 5
Posts: 1,211
|
and of course, the classic Amiga demo Nexus 7, remade in 8k :P
[ Show youtube player ] |
11 March 2020, 16:49 | #14 |
move.l #$c0ff33,throat
Join Date: Dec 2005
Location: Berlin/Joymoney
Posts: 6,863
|
|
11 March 2020, 17:18 | #15 | |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
Quote:
It's just that they do only small part of a correct setup and work on a limited amount of machines (and don't multitask properly, etc). It indeed makes it a lot easier to write small code. I suppose anyway it's inherent to windows boxes that simple things never work properly everywhere. Doing graphics and sound has never been a problem for me on the miggy but on peecees there is always something that goes wrong. Sigh. I can't imagine playing protracker (with correct quality) with just a few kb of windows code. Yet if it is about removing bytes out of the exe, it may be better to use a module packer such as Player 6.1 (P61A). Some probably have a shorter replay routine as well. |
|
11 March 2020, 19:59 | #16 |
Registered User
Join Date: Nov 2019
Location: Groningen / the Netherlands
Posts: 16
|
I managed to produce a 100% correct mt_PeriodTable with only 144 bytes of code.
That's 12.5% of the original size, 1152 - 144 = 1008 bytes lost. Think I can make it even smaller..... |
11 March 2020, 20:10 | #17 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,323
|
|
11 March 2020, 20:29 | #18 |
Registered User
Join Date: Nov 2019
Location: Groningen / the Netherlands
Posts: 16
|
Yes I have, it's not a rounding error ( tested them all ), round to nearest gives the best possible result.
Even higher resolution ( doubles ) gives the same result. You end up with 32 periods that are 1 to high and 5 are 1 to low. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to calculate possible blit times? | Tigerskunk | Coders. Asm / Hardware | 32 | 11 January 2022 08:24 |
Calculate offset using labels | Beska | Coders. Asm / Hardware | 7 | 09 May 2016 18:56 |
Calculate Time-Tracks Pixel width? | AGS | Coders. General | 22 | 10 March 2015 19:19 |
Calculate a color gradient. | AGS | Coders. Asm / Hardware | 13 | 11 February 2015 11:20 |
Megaball (pre-4.0) | dansalvato | request.Old Rare Games | 1 | 18 June 2009 18:00 |
|
|