News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

CPC6128 - expansion board address decoding

Started by Wawavoun, 12:46, 25 April 23

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

McArti0

#50
OUT (C),r  has  4T to data writing. Any wait is impossible. Wait is only from GA for draw the screen correctly.

CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

Wawavoun

#51
Hi there !

Thanks all for your help and advice.

I found a schematic form something similar to what I want do. See attachment.
Again it is functionally equivalent as what I have do... But may be you can see some interesting point.
On difference : /MREQ is used to avoid /CS if low (G2A and G2B should be both low to enable LS138 outputs).

The /READY signal coming from the gate array is an output clear. It is connected to the /WAIT pin of the Z80.
But the 82 ohms resistor is here so this line can be shared with other peripherals. Multiple peripherals can tie it down if they need wait state. On the first version of the gate array it was is real open collector output. I put the diode for that reason. The peripheral cant force /READY to high but can force it to low. Without the diode the CPC dont boot at all.
During a read cycle I see /PAUSE going low and one pulse is missing on the /READY line during this time. This seems not give perturbation to the CPC.

My option of a bad reset of the apu was false. Reset go high and the 4 MHz CPC clock continue to tick. There is far enough cycles to get a reset.

The /END is not connected to /INT when I do my trial. Connect stop the CPC  at the first access to the APU (normal I assume, there is no routine to manage the interrupt).

Here I am... I have to think to that and will may be write a second message later !

Regards.
Philippe



If you think adventure is dangerous try routine, you'll see it's deadly!

Wawavoun

Hi there !

The board works !!!

Since the beginning the problem was a rotten flat cable ! :picard2:

This morning I want to give a look to /MREQ with the scope. The signal on the expansion board was flat at 0 V... For a active low signal its strange !
I begin to search around that and finally found the link is broken between the edge connector and the 2*25 connector. Then I think to myself if one wire is cut may be others also...
I dismantle two expansion flat wires I have for made one but this time working.

And the board works directly with this cable...

For the interested the up to date gerber and a bom are just below.

A CPM Plus library using this board will come soon.

Great thanks to all for your help !

Regards.
Philippe
If you think adventure is dangerous try routine, you'll see it's deadly!

Animalgril987

@Wawavoun congratulations! Excellent project.
Do you have an updated schematic?

Wawavoun

The schematic is th joined zip file.

Philippe
If you think adventure is dangerous try routine, you'll see it's deadly!

Wawavoun

#55
And here the pictures... Can always be useful !

On the gerbers above (V2) there is a place for the two diodes. No need of the hack you see on the picture.

Please note that the 9512 / 8232 configuration has not be tested. I was not able to find one of these chips somewhere.

If you have one or information where I can buy one please take contact.

Regards.
philippe
If you think adventure is dangerous try routine, you'll see it's deadly!

Wawavoun

In case of I have 2 remaining pcb.
If you think adventure is dangerous try routine, you'll see it's deadly!

McArti0

CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

Wawavoun

I have a library made for Microsoft Fortran and Microsoft Bascom.
Any program in these languages can then be linked with this library at compilation and then use the fpu instead of software arithmetic.

I have to finish to test this library but they work on my Z80 CPM Apple IIe so should work also on the CPC.

Its based on the work here : https://github.com/ratboy666/apu

How to use this board with Locomotive Basic ? I dont know a this moment and have to think to that.

Philippe

 
If you think adventure is dangerous try routine, you'll see it's deadly!

McArti0

    6128    ł 464      ł Size  ł Comments on the memory locations
-------------------------------------------------------------------------------
    &BD61 ł &BD3D ł 32*3 ł Maths Jumpblock (on the 464 this block is 48*3 bytes in size)

https://www.cpcwiki.eu/imgs/e/e1/The_Amstrad_CPC_Firmware_Guide.txt

You can change jumps to match procedures to other.

The Maths Firmware

000   &BDC1   MOVE REAL (&BD3D for the 464)
      Action: Copies the five bytes that are pointed to by DE to the
              location held in HL
      Entry:  DE points to the source real value, and HL points to
              the destination
      Exit:   HL points to the real  value  in the destination, Carry
              is true if the move  went  properly,  F is corrupt, and
              all other registers are preserved
      Notes:  For the 464 only, A holds the exponent byte of the real
              value when the routine is exited

001   &BD64   INTEGER TO REAL (&BD40 for the 464)
      Action: Converts an integer value into a real value
      Entry:  HL holds the integer  value,  DE  points  to the desti-
              nation for the real value, bit 7 of A holds the sign of
              the integer value - it is taken to be negative if bit 7
              is set
      Exit:   HL points to the real value  in the destination, AF and
              DE are corrupt, and all others are preserved

002   &BD67   BINARY TO REAL (&BD43 for the 464)
      Action: Converts a four byte binary value  into a real value at
              the same location
      Entry:  HL points to the binary  value,  bit  7  of A holds the
              sign of the binary value - negative if it is set
      Exit:   HL points to the real  value  in  lieu of the four byte
              binary  value,  AF  is  corrupt,  and  all  others  are
              preserved
      Notes:  A four byte binary value  is  an unsigned integer up to
              &FFFFFFFF and is stored with the least significant byte
              first, and with the most significant byte last

003   &BD6A   REAL TO INTEGER (&BD46 for the 464)
      Action: Converts a real  value,  rounding  it  into an unsigned
              integer value held in HL
      Entry:  HL points to the real value
      Exit:   HL holds  the  integer  value,  Carry  is  true  if the
              conversion worked successfully, the Sign flag holds the
              sign of the integer (negative if it is set).  A, IX and
              the other flags are  corrupt,  and  all other registers
              are preserved

      Notes:  This rounds the decimal part  down  if  it is less than
              0.5, but rounds up if it  is  greater than, or equal to
              0.5

004   &BD6D   REAL TO BINARY (&BD49 for the 464)
      Action: Converts a real value,  rounding  it  into  a four byte
              binary value at the same location
      Entry:  HL points to the real value
      Exit:   HL points to  the  binary  value  in  lieu  of the real
              value, bit 7 of B holds  the  sign for the binary value
              (it is negative if bit  7  is  set),  AF,  B and IX are
              corrupt, and all other registers are preserved
      Notes:  See REAL TO INTEGER for  details  of how the values are
              rounded up or down

005   &BD70   REAL FIX (&BD4C for the 464)
      Action: Performs an equivalent  of  BASIC's  FIX  function on a
              real value, leaving the  result  as  a four byte binary
              value at the same location
      Entry:  HL points to the real value
      Exit:   HL points to  the  binary  value  in  lieu  of the real
              value, bit 7 of B has the  sign of the binary value (it
              is negative if bit 7 is set), AF, B and IX are corrupt,
              and all others are preserved
      Notes:  FIX removes any  decimal  part  of  the value, rounding
              down whether  positive  or  negative  -  see  the BASIC
              handbook for more details on the FIX command

006   &BD73   REAL INT (&BD4F for the 464)
      Action: Performs an equivalent  of  BASIC's  INT  function on a
              real value, leaving the  result  as  a four byte binary
              value at the same location
      Entry:  HL points to the real value
      Exit:   HL points to  the  binary  value  in  lieu  of the real
              value, bit 7 of B has the  sign of the binary value (it
              is negative if bit 7 is set), AF, B and IX are corrupt,
              and all others are preserved
      Notes:  INT removes any  decimal  part  of  the value, rounding
              down if the nurnber is positive,  but rounding up if it
              is negative

007   &BD76   INTERNAL SUBROUTINE - not useful (&BD52 for the 464)

008   &BD79   REAL *10^A (&BD55 for the 464)
      Action: Multiplies a real value by 10 to the power of the value
              in the A  register,  leaving  the  result  at  the same
              location
      Entry:  HL points to the real value,  and  A holds the power of
              10
      Exit:   HL points to the  result,  AF,  BC,  DE,  IX and IY are
              corrupt

009   &BD7C   REAL ADDITION (&BD58 for the 464)
      Action: Adds two real values, and leaves  the result in lieu of
              the first real number
      Entry:  HL points to the first real value, and DE points to the
              second real value
      Exit:   HL points to the  result,  AF,  BC,  DE,  IX and IY are
              corrupt

010   &BD82   REAL REVERSE SUBTRACTION (&BD5E for the 464)
      Action: Subtracts the first  real  value  from  the second real
              value, and leaves  the  result  in  lieu  of  the first
              number
      Entry:  HL points to the first real value, and DE points to the
              second real value
      Exit:   HL points to the  result  in  place  of  the first real
              value, AF, BC, DE, IX and IY are corrupt

011   &BD85   REAL MULTIPLICATION (&BD61 for the 464)
      Action: Multiplies two real  values  together,  and  leaves the
              result in lieu of the first number
      Entry:  HL points to the first real value, and DE points to the
              second real value
      Exit:   HL points to the  result  in  place  of  the first real
              value, AF, BC, DE, IX and IY are corrupt

012   &BD88   REAL DIVISION (&BD64 for the 464)
      Action: Divides the first real value  by the second real value,
              and leaves the result in lieu of the first number
      Entry:  HL points to the first real value, and DE points to the
              second real value
      Exit:   HL points to the  result  in  place  of  the first real
              value, AF, BC, DE, IX and IY are corrupt

013   &BD8E   REAL COMPARISON (&BD6A for the 464)
      Action: Compares two real values
      Entry:  HL points to the first real value, and DE points to the
              second real value
      Exit:   A holds the result of  the  comparison process, IX, IY,
              and the other flags  are  corrupt,  and  all others are
              preserved
      Notes:  After this routine  has  been  called,  the  value in A
              depends on the result of the comparison as follows:
              if the first real  number  is  greater  than the second
              real number, then A holds &01
              if the first real number is the same as the second real
              number, then A holds &00  if  the second real number is
              greater than the first real number, then A holds &FF

014   &BD91   REAL UNARY MINUS (&BD6D for the 464)
      Action: Reverses the sign of a real value
      Entry:  HL points to the real value
      Exit:   HL points to the new value of the real number (which is
              stored in place of  the  original  number),  bit 7 of A
              holds the sign of the result  (it  is negative if bit 7
              is set), AF and IX are corrupt, and all other registers
              are preserved

015   &BD94   REAL SIGNUM/SGN (&BD70 for the 464)
      Action: Tests a real value, and compares it with zero
      Entry:  HL points to the real value
      Exit:   A holds the result of  this  comparison process, IX and
              the  other  ˇlags  are  corrupt,  and  all  others  are
              preserved
      Notes:  After this routine  has  been  called,  the  value in A
              depends on the result of the comparison as follows:
              if the real number is greater than 0, then A holds &01,
              Carry is false, and Zero is false
              if the real number is the same  as 0, then A holds &00,
              Carry is false, and Zero is true
              if the real number is smaller than 0, then A holds &FF,
              Carry is true, and Zero is false

016   &BD97   SET ANGLE MODE (&BD73 for the 464)
      Action: Sets the angular  calculation  mode  to  either degrees
              (DEG) or radians (RAD)
      Entry:  A holds the mode setting  -  0  for  RAD, and any other
              value for DEG
      Exit:   All registers are preserved

017   &BD9A   REAL PI (&BD76 for the 464)
      Action: Places the real value of pi at a given memory location
      Entry:  HL holds the address at which the  value of pi is to be
              placed
      Exit:   AF and DE  are  corrupt,  and  all  other registers are
              preserved

018   &BD9D   REAL SQR (&BD79 for the 464)

      Action: Calculates the square root of a real value, leaving the
              result in lieu of the real value
      Entry:  HL points to the real value
      Exit:   HL points to the result of the calculation, AF, BC, DE,
              IX and IY are corrupt

019   &BDA0   REAL POWER (&BD7C for the 464)
      Action: Raises the first real value to  the power of the second
              real value, leaving the  result  in  lieu  of the ˇirst
              real value
      Entry:  HL points to the first real value, and DE points to the
              second real value
      Exit:   HL points to the result of the calculation, AF, BC, DE,
              IX and IY are corrupt

020   &BDA3   REAL LOG (&BD7F for the 464)
      Action: Returns the naperian logarithm  (to  base  e) of a real
              value, leaving the result in lieu of the real value
      Entry:  HL points to the real value
      Exit:   HL points to the  logarithrn  that has been calculated,
              AF, BC, DE, LY and IY are corrupt

021   &BDA6   REAL LOG 10 (&BD82 for the 464)
      Action: Returns the logarithm (to  base  10)  of  a real value,
              leaving the result in lieu of the real value
      Entry:  HL points to the real value
      Exit:   HL points to the  logarithrn  that has been calculated,
              AF, BC, DE, IX and IY are corrupt

022   &BDA9   REAL EXP (&BD85 for the 464)
      Action: Returns the antilogarithm  (base  e)  of  a real value,
              leaving the result in lieu of the real value
      Entry:  HL points to the real value
      Exit:   HL points  to  the  antilogarithm  that  has  been cal-
              culated, AF, BC, DE, IX and IY are corrupt
      Notes:  See the BASIC handbook for details of EXP

023   &BDAC   REAL SINE (&BD88 for the 464)
      Action: Returns the sine of a real value, leaving the result in
              lieu of the real value
      Entry:  HL points to the real value (ie all angle)
      Exit:   HL points to the sine  value  that has been calculated,
              AF, BC, DE, IX and IY are corrupt

024   &BDAF   REAL COSINE (&BD8B for the 464)
      Action: Returns the cosine  of  a  real  value,  leaving  a the
              result in lieu of the real value
      Entry:  HL points to the real value (ie an angle)
      Exit:   HL points to the cosine value that has been calculated,
              AF, BC, DE, IX and IY are corrupt

025   &BDB2   REAL TANGENT (&BD8E for the 464)
      Action: Returns the tangent of a real value, leaving the result
              in lieu of the real value
      Entry:  HL points to the real value (ie an angle)
      Exit:   HL points to  the  tangent  value  that  has  been cal-
              culated, AF, BC, DE, IX and IY are corrupt

026   &BDB5   REAL ARCTANGENT (&BD91 for the 464)
      Action: Returns the arctangent  of  a  real  value, leaving the
              result in lieu of the real value
      Entry:  HL points to the real value (ie an angle)
      Exit:   HL  points  to  the  arctangent  value  that  has  been
              calculated, AF, BC, DE, IX and IY are corrupt

         All of the above routines to calculate sine, cosine, tangent
              and
                        arctangent are slightly inaccuarate

and how work floatingpoint data:

https://www.cpcwiki.eu/index.php?title=Technical_information_about_Locomotive_BASIC&mobileaction=toggle_view_desktop#Floating_Point_data_definition
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

Animalgril987

I believe the FPU uses a different format  ( for floating point numbers ) than the CPC, so some conversion will be necessary.

McArti0

https://www.hartetechnologies.com/manuals/AMD/AMD%209511%20FPU.pdf

page 4

mantissa is shorter 3bytes plus one bit sigin in exponent byte.
exponent 7 bit
CPC 6128, Whole 6128 and Only 6128, with .....
NewPAL v3 for use all 128kB RAM by CRTC as VRAM
TYPICAL :) TV Funai 22FL532/10 with VGA-RGB-in.

Bread80

On a 6128 I'm pretty sure all the floating point stuff is in the firmware. If the data first within the 5-bytes of a standard BASIC real then it would (probably) be transparent to the rest to the system. Therefore you shouldn't need any mods to the BASIC code.

The only issue I can see is with conversion to/from strings. If I'm not mistaken the conversion to strings returns the mantissa as BCD in a buffer. I'm not sure about the exponent. Probably in a register.

For conversion to strings I have no idea off-hand of what's needed.

If that's a path your interested in then I can investigate more for you.

Wawavoun

Hello,

Thanks all for your suggestions and help.

At this moment I works on a asm library useable into compiled Basic and Fortran (both Microsoft).
Its slow because I have other stuffs to do...
Its based on a work found on github (link above).
Because this library made a great use of B register and because I need B for IN-OUT statement I have to made some modifications.

I know that this is board is useless without a software.
If somebody want write something usable from Locomotive Basic he his welcome.
I even can send him a fpu pcb (without components) for free so test will be possible. 

Regards.
Philippe

If you think adventure is dangerous try routine, you'll see it's deadly!

Bread80

I don't have time available to write a library, but I have a lot of domain knowledge of the BASIC source code. If you're interested in patching the firmware routines so BASIC would run 'as-is' but using the hardware instead of software routines then I'd be willing to check through the BASIC code for any possible issues, and to assist if any changes are needed to the BASIC source.

Wawavoun

#65
Hello,

The library herejoined is the first working version. It is far from optimized but it works !

The basic test program inside the zip, compiled / linked with bascom and l80, run in 13s50 in normal mode and in 2s55 if linked with this library (and of course if C8231 is present, 4 MHz in my case).

The process is as follow :

1_ compile sources
 m80 =am9511.mac/L  --> am9511.rel
 m80 =apu.mac/L --> apu.rel

2_ make the lib
 lib80 libapu.rel=am9511.rel,apu.rel/e --> libapu.rel

3_ compile basic program
 bascom =aputst.bas/o/l --> aputst.rel

4 link with or without the library (and then use or not the fpu)
 (with) l80 aputst.rel,libapu.rel,aputst.com/n/y/e or (without) l80 aputst.rel,aputst.com/n/y/e --> aputst.com

There is some warnings about double definitions at linking but works well...

Have fun !

Philippe
If you think adventure is dangerous try routine, you'll see it's deadly!

Powered by SMFPacks Menu Editor Mod