Hi all,
Its nice to see new qscans emerging! I really like them :)
This evening I tried to create my own qscan. With a different twist
then the current qscans. Most new designs are based on the Q4
mathematics of qy*(qz-1)=1. But I decided I wanted to use something
else for my qscan, not only my own code, but also my own math!
The method I came up with uses a 'magicnumber' and a normal number.
Multiplied it decodes to the right position. This sounds the same as
the q4, but the math is a bit different. Here is my calculation:
(number+1)*magicnumber = number+(seperation between scanlocation and
the table)
When I calculated the pairs that created these patterns I found out
that there aren't magicnumbers that have more then one corresponding
number, so I could only make one sne/seq pair :-(
The problem I faced was this: How to change the magicnumber and the
number, while not having large lookup tables?
I solved this by the table placement. The position of the table
(multiplied by two) gives our magicnumber. If we precalculate this
into a qscan you get the following:
offset equ 3122 ;offset used between pairs
number1 equ 7722 ; = (number1 + 1) * magic1 = number1 + correction
magic1 equ 7510 ; = 8000-(ind-(tab-1))*magic6
number2 equ 1542 ; = (number2 + 1) * magic2 = number2 + correction
magic2 equ 7524 ; = 8000-(ind-tab)*magic6
number3 equ 2850 ; = (number3 + 1) * magic3 = number3 + correction
magic3 equ 7538 ; = 8000-(ind-(tab+1))*magic6
number4 equ 4433 ; = (number4 + 1) * magic4 = number4 + correction
magic4 equ 84 ; = 8000-((ind-1)-tab4)*magic6
number5 equ 5191 ; = (number5 + 1) * magic5 = number5 + correction
magic5 equ 7454 ; = 8000-((ind+1)-tab5)*magic6
number6 equ 6154 ; = (number6 + 1) * magic6 = number6 + correction
magic6 equ 14 ;lucky number
empty equ bomb-1
bomb equ tab5
tab5 dat >-86 , <number5
dat 0 , 0
dat 0 , 0
dat 0 , number1
tab dat 0 , number2
dat 0 , number3
dat 0 , 0
dat 0 , 0
dat 0 , 0
warrior jmp #0
qscan sne bptr+(magic1*number1) , bptr+(magic1*number1)+offset
seq >tab-1 , bptr+(magic1*(number1+1))+offset
jmp dec , <ind
sne bptr+(magic2*number2) , bptr+(magic2*number2)+offset
seq >tab , bptr+(magic2*(number2+1))+offset
jmp dec
sne bptr+(magic3*number3) , bptr+(magic3*number3)+offset
seq >tab+1 , bptr+(7208*(number3+1))+offset
jmp dec , >ind
sne bptr+(magic4*number4) , bptr+(magic4*number4)+offset
seq >tab4 , bptr+(magic4*(number4+1))+offset
jmp dec , {ptr
sne bptr+(magic5*number5) , bptr+(magic5*number5)+offset
seq >tab5 , bptr+(magic5*(number5+1))+offset
jmp dec , }ptr
sne bptr+(magic6*number6) , bptr+(magic6*number6)+offset
seq >tab4-1 , bptr+(magic6*(number6+1))+offset
djn.b ptr , {ptr ;faster, no magicnumber calculation needed
jmp warrior
dec mul.b *ptr , bptr ;calculate magicnumber
ptr mul.b @[EMAIL PROTECTED]
bptr ;decode location
sne empty , @[EMAIL PROTECTED]
bptr
mov.i bomb , @[EMAIL PROTECTED]
*magic6
sub #-7 , bptr
djn -3 , #19
jmp warrior , tab4
ind dat 0 , tab ;table used to calculate magic numbers
dat 0 , tab5
dat 0 , 0
dat 0 , 0
dat 0 , number6
tab4 dat 0 , number4
end qscan
To calculate the correct values I used a small program. It just
generates the values that are possible with the given table-placement.
Sometimes no values can be found at all...
The results of the qscan aren't anything like a q4, but might be a bit
better then q3, it just doesn't have enough scans (24 compared to 33),
and it is a bit slower in the decoding (3,83 instructions). The good
thing is that you are able to tweak it a little bit more. (I think).
But I'm satisfied for today!
All feedback is welcome of course, and tips/tricks to make it faster/
better ;-)


|