summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/softfloat3/source/f16_le.c
blob: fa69432259e612334cd61ffc9069bb05a088e5ad (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*============================================================================

This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
Package, Release 3e, by John R. Hauser.

Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
California.  All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

 1. Redistributions of source code must retain the above copyright notice,
    this list of conditions, and the following disclaimer.

 2. Redistributions in binary form must reproduce the above copyright notice,
    this list of conditions, and the following disclaimer in the documentation
    and/or other materials provided with the distribution.

 3. Neither the name of the University nor the names of its contributors may
    be used to endorse or promote products derived from this software without
    specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

=============================================================================*/

#include <stdbool.h>
#include <stdint.h>
#include "platform.h"
#include "internals.h"
#include "softfloat.h"

bool f16_le( float16_t a, float16_t b )
{
    union ui16_f16 uA;
    uint_fast16_t uiA;
    union ui16_f16 uB;
    uint_fast16_t uiB;
    bool signA, signB;

    uA.f = a;
    uiA = uA.ui;
    uB.f = b;
    uiB = uB.ui;
    if ( isNaNF16UI( uiA ) || isNaNF16UI( uiB ) ) {
        softfloat_raiseFlags( softfloat_flag_invalid );
        return false;
    }
    signA = signF16UI( uiA );
    signB = signF16UI( uiB );
    return
        (signA != signB) ? signA || ! (uint16_t) ((uiA | uiB)<<1)
            : (uiA == uiB) || (signA ^ (uiA < uiB));

}
pan> (1<<2), //!< MX2 signal is bit 2 (latch bit 3) LMX2 = (1<<3), MY1 = (1<<4), //!< MY1 signal is bit 4 (latch bit 5) LMY1 = (1<<5), MY2 = (1<<6), //!< MY2 signal is bit 6 (latch bit 7) LMY2 = (1<<7), MACTIVE = (MX1|MX2|MY1|MY2), //!< mask for the active bits MLATCH = (LMX1|LMX2|LMY1|LMY2) //!< mask for the latched bits }; /** * <PRE> * The mouse inputs from the shutters are connected to a quad * 2/3 input RS flip flop (SN74279). * * 74279 * +---+--+---+ * | +--+ | * R1 -|1 16|- Vcc * | | * S1a -|2 15|- S4 * | | * S1b -|3 14|- R4 * | | * Q1 -|4 13|- Q4 * | | * R2 -|5 12|- S3a * | | * S2 -|6 11|- S3b * | | * Q2 -|7 10|- R3 * | | * GND -|8 9|- Q3 * | | * +----------+ * * The 'Y' Encoder signals are connected to IC1: * shutter pin(s) R/S output * ------------------------------------ * 0 2,3 S1a,b Q1 MX2 -> 1 * 1 1 R1 Q1 MX2 -> 0 * 2 5 R2 Q2 MX1 -> 0 * 3 6 S2 Q2 MX1 -> 1 * * The 'X' Encoder signals are connected to IC2: * shutter pin(s) R/S output * ------------------------------------ * 0 2,3 S1a,b Q1 MY2 -> 1 * 1 1 R1 Q1 MY2 -> 0 * 2 5 R2 Q2 MY1 -> 0 * 3 6 S2 Q2 MY1 -> 1 * * * The pulse train generated by a left or up rotation is: * * +---+ +---+ +---+ * MX1/MY1 | | | | | | * ---+ +---+ +---+ +--- * * +---+ +---+ +---+ +- * MX2/MY2 | | | | | | | * -+ +---+ +---+ +---+ * * * The pulse train generated by a right or down rotation is: * * +---+ +---+ +---+ +- * MX1/MY1 | | | | | | | * -+ +---+ +---+ +---+ * * +---+ +---+ +---+ * MX2/MY2 | | | | | | * ---+ +---+ +---+ +--- * * In order to simulate the shutter sequence for the mouse motions * we have to generate a sequence of pulses on MX1/MX2 and MY1/MY2 * that have their phases shifted by 90 degree. * </PRE> */ #define MOVEX(x) ((((x) < 0) ? MY2 : ((x) > 0) ? MY1 : 0)) #define MOVEY(y) ((((y) < 0) ? MX2 : ((y) > 0) ? MX1 : 0)) #define SIGN(a) ((a) < 0 ? -1 : (a) > 0 ? 1 : 0) /** * @brief return the mouse motion flags * * Advance the mouse x and y coordinates to the dx and dy * coordinates by either toggling MX2 or MX1 first for a * y movement, or MY2 or MY1 for x movement. * There are four read phases counted by m_mouse.phase * * @return lookup value from madr_a32 */ UINT16 alto2_cpu_device::mouse_read() { UINT16 data; m_mouse.latch = (m_mouse.latch << 1) & MLATCH; data = m_madr_a32[m_mouse.latch]; switch (m_mouse.phase) { case 0: m_mouse.latch |= MOVEX(m_mouse.dx - m_mouse.x); m_mouse.latch |= MOVEY(m_mouse.dy - m_mouse.y); break; case 1: m_mouse.latch |= MACTIVE; m_mouse.x -= SIGN(m_mouse.x - m_mouse.dx); m_mouse.y -= SIGN(m_mouse.y - m_mouse.dy); break; case 2: m_mouse.latch ^= MOVEX(m_mouse.dx - m_mouse.x); m_mouse.latch ^= MOVEY(m_mouse.dy - m_mouse.y); break; default: m_mouse.latch &= ~MACTIVE; m_mouse.x -= SIGN(m_mouse.x - m_mouse.dx); m_mouse.y -= SIGN(m_mouse.y - m_mouse.dy); } m_mouse.phase = (m_mouse.phase + 1) % 4; return data; } /** * @brief register a mouse motion in x direction * @param ioport_field reference to the field * @param param pointer passed in PORT_CHANGED_MEMBER last parameter * @param oldval the old ioport_value * @param newval the new ioport_value */ INPUT_CHANGED_MEMBER( alto2_cpu_device::mouse_motion_x ) { // set new destination (absolute) mouse x coordinate INT32 x = m_mouse.dx + newval - oldval; x = x < 0 ? 0 : x > 605 ? 605 : x; m_mouse.dx = x; #if MOUSE_DIRTY_HACK /* XXX: dirty, dirty, hack */ #if USE_HAMMING_CHECK m_mem.ram[0424/2] = hamming_code(1, 0424 / 2, (m_mouse.dx << 16) | m_mouse.dy); #else m_mem.ram[0424/2] = (m_mouse.dx << 16) | m_mouse.dy; #endif #endif } /** * @brief register a mouse motion in y direction * @param ioport_field reference to the field * @param param pointer passed in PORT_CHANGED_MEMBER last parameter * @param oldval the old ioport_value * @param newval the new ioport_value */ INPUT_CHANGED_MEMBER( alto2_cpu_device::mouse_motion_y ) { // set new destination (absolute) mouse y coordinate INT32 y = m_mouse.dy + newval - oldval; y = y < 0 ? 0 : y > 807 ? 807 : y; m_mouse.dy = y; #if MOUSE_DIRTY_HACK /* XXX: dirty, dirty, hack */ #if USE_HAMMING_CHECK m_mem.ram[0424/2] = hamming_code(1, 0424 / 2, (m_mouse.dx << 16) | m_mouse.dy); #else m_mem.ram[0424/2] = (m_mouse.dx << 16) | m_mouse.dy; #endif #endif } /** * @brief register a mouse button change * * convert button bit to UTILIN[13-15] * * @param ioport_field reference to the field * @param param pointer passed in PORT_CHANGED_MEMBER last parameter * @param oldval the old ioport_value * @param newval the new ioport_value */ INPUT_CHANGED_MEMBER( alto2_cpu_device::mouse_button_0 ) { X_WRBITS(m_hw.utilin,16,13,13,newval); } INPUT_CHANGED_MEMBER( alto2_cpu_device::mouse_button_1 ) { X_WRBITS(m_hw.utilin,16,14,14,newval); } INPUT_CHANGED_MEMBER( alto2_cpu_device::mouse_button_2 ) { X_WRBITS(m_hw.utilin,16,15,15,newval); } static const prom_load_t pl_madr_a32 = { "madr.a32", 0, "a0e3b4a7", "24e50afdeb637a6a8588f8d3a3493c9188b8da2c", /* size */ 0400, /* amap */ AMAP_DEFAULT, /* axor */ 0, /* dxor */ 017, // invert D0-D3 /* width */ 4, /* shift */ 0, /* dmap */ DMAP_REVERSE_0_3, // reverse D0-D3 to D3-D0 /* dand */ ZERO, /* type */ sizeof(UINT8) }; /** * @brief initialize the mouse context to useful values * * From the Alto Hardware Manual: * <PRE> * The mouse is a hand-held pointing device which contains two encoders * which digitize its position as it is rolled over a table-top. It also * has three buttons which may be read as the three low order bits of * memory location UTILIN (0177030), iin the manner of the keyboard. * The bit/button correspondence in UTILIN are (depressed keys * correspond to 0's in memory): * * UTILIN[13] TOP or LEFT button (RED) * UTILIN[14] BOTTOM or RIGHT button (BLUE) * UTILIN[15] MIDDLE button (YELLOW) * * The mouse coordinates are maintained by the MRT microcode in locations * MOUSELOC(0424)=X and MOUSELOC+1(0425)=Y in page one of the Alto memory. * These coordinates are relative, i.e., the hardware only increments and * decrements them. The resolution of the mouse is approximately 100 points * per inch. * </PRE> */ void alto2_cpu_device::init_mouse() { memset(&m_mouse, 0, sizeof(m_mouse)); m_madr_a32 = prom_load(machine(), &pl_madr_a32, memregion("madr_a32")->base()); } void alto2_cpu_device::exit_mouse() { // nothing to do yet } void alto2_cpu_device::reset_mouse() { m_mouse.x = 0; m_mouse.y = 0; m_mouse.dx = 0; m_mouse.dy = 0; m_mouse.latch = 0; m_mouse.phase = 0; }