Thread: How am I doing so far?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Apr 2021
    Posts
    29

    How am I doing so far?

    A sampling of code that I've translated from 680x assembly, formatted into C++, and tested in an online compiler.

    Code:
    int keyCheck ( bool enter, bool check, bool next, bool repeat, 
              bool testKey, bool restart, char keyDat, char keyNum )
    // Replacement for UGLY, BELABORED code at $FAA6
    // Presently based on matrix keyboard data fetched through 8279
    // "Old matrix" refers to custom Grayhill keypad in original unit - 
    // values shuffled around to accommodate off-the-shelf version
    // A partial rewrite may be necessary once a hardware platform is 
    // chosen but keyNum and Boolean variables are finalized
    {
        enter = false; // Old matrix: 0x1A - Accept data entered from keypad
        check = false; // Old matrix: 0x0B - Perform checksum on entered data
        next = false; // Old matrix: 0x1B - Proceed to next programmed test
        repeat = false; // Old matrix: 0x13 - Repeat current test
        testKey = false; // Old matrix: 0x03 - Perform Lamp Test
        restart = false; // Old matrix: 0x19 - Reboot the unit!
        keyNum = 0xFF; // set default 'NaN' value for keyNum
    
    
        if ( keyDat == 0x00 ) keyNum = 0x01; // Key 1
        else if ( keyDat == 0x01 ) keyNum = 0x02; // Key 2
        else if ( keyDat == 0x02 ) keyNum = 0x03; // Key 3
        else if ( keyDat == 0x03 ) enter = true; // Key A = Enter
        else if ( keyDat == 0x08 ) keyNum = 0x04; // Key 4
        else if ( keyDat == 0x09 ) keyNum = 0x05; // Key 5
        else if ( keyDat == 0x0A ) keyNum = 0x06; // Key 6
        else if ( keyDat == 0x0B ) check = true; // Key B = Check
        else if ( keyDat == 0x10 ) keyNum = 0x07; // Key 7
        else if ( keyDat == 0x11 ) keyNum = 0x08; // Key 8
        else if ( keyDat == 0x12 ) keyNum = 0x09; // Key 9
        else if ( keyDat == 0x13 ) next = true; // Key C = Next
        else if ( keyDat == 0x18 ) restart = true; // Key * = Restart
        else if ( keyDat == 0x19 ) keyNum = 0x00; // Key 0
        else if ( keyDat == 0x1A ) testKey = true; // Key # = Lamp Test
        else if ( keyDat == 0x1B ) repeat = true; // Key D = Repeat
    }
    
    
    int varLoad ( char MSG01, char MSG02, char MSG03, char MSG04, char MSG05, char MSG06, 
              char MSG07, char MSG08, char MSG09, char MSG10, char MSG11, char MSG12, 
              char MSG13, char MSG14, char MSG15, char MSG16, char MSG17, char MSG18, 
              char MSG19, char MSG20, char MSG21, char MSG22, char MSG23, char MSG24, 
              char MSG25, char MSG26, int index )
    // Replaces block of code at $FCB8 and data table from $FCE3 - $FD5A
    // This block of variables was so named for assumption it 
    // was a 'message block' but may actually be for other purposes
    // MSG01 and MSG02 are constants while rest were read from the table
    {
        MSG01 = 0xAA;
        MSG02 = 0xBA;
        MSG03 = 0xFF;
        if ( index == 1 || index == 4 ) MSG04 = 0x55; else MSG04 = 0x00;
        if ( index == 1 || index == 4 ) MSG05 = 0x55; else MSG05 = 0x00;
        if ( index == 1 ) MSG06 = 0x56; else if ( index == 2 ) MSG06 = 0x02; else if ( index == 3 ) MSG06 = 0x01; else if ( index == 4 ) MSG06 = 0x55; else if ( index == 5 ) MSG06 = 0x01;
        if ( index == 1 ) MSG07 = 0x22; else if ( index == 2 ) MSG07 = 0x3F; else if ( index == 3 ) MSG07 = 0x35; else if ( index == 4 ) MSG07 = 0x1F; else if ( index == 5 ) MSG07 = 0x3A;
        MSG08 = 0x00;
        if ( index == 2 || index == 3 ) MSG09 = 0xCF; else MSG09 = 0xC0;
        if ( index == 1 ) MSG10 = 0x00; else if ( index == 2 ) MSG10 = 0xF0; else if ( index == 3 ) MSG10 = 0xF0; else if ( index == 4 ) MSG10 = 0x00; else if ( index == 5 ) MSG10 = 0x03;
        if ( index == 2 ) MSG11 = 0x10; else if ( index == 5 ) MSG11 = 0xC0; else MSG11 = 0x00;
        if ( index == 4 ) MSG12 = 0x0F; else if ( index == 5 ) MSG12 = 0x03; else MSG12 = 0x00;
        if ( index == 4 ) MSG13 = 0xF0; else if ( index == 5 ) MSG13 = 0xC0; else MSG13 = 0x00;
        if ( index == 1 ) MSG14 = 0x00; else if ( index == 2 ) MSG14 = 0x00; else if ( index == 3 ) MSG14 = 0x44; else if ( index == 4 ) MSG14 = 0x34; else if ( index == 5 ) MSG14 = 0x44;
        if ( index == 1 || index == 2 ) MSG15 = 0x0C; else MSG15 = 0x0F;
        if ( index == 1 || index == 2 ) MSG16 = 0x00; else MSG16 = 0xFF;
        if ( index == 1 || index == 2 ) MSG17 = 0x00; else MSG17 = 0xFF;
        if ( index == 1 || index == 2 ) MSG18 = 0x00; else MSG18 = 0xFF;
        if ( index == 1 || index == 2 ) MSG19 = 0x00; else MSG19 = 0xFF;
        if ( index == 1 ) MSG20 = 0x01; else if ( index == 2 ) MSG20 = 0x02; else MSG20 = 0xFF;
        if ( index == 1 || index == 2 ) MSG21 = 0x40; else MSG21 = 0xFF;
        if ( index == 1 || index == 2 ) MSG22 = 0x00; else MSG22 = 0xFF;
        MSG23 = 0x41;
        if ( index == 1 || index == 2 ) MSG24 = 0x03; else MSG24 = 0x02;
        MSG25 = 0x00;
        if ( index == 1 || index == 2 ) MSG26 = 0x15; else MSG26 = 0x0F;
    }
    Thoughts? Comments?
    Last edited by Salem; 04-24-2021 at 04:08 AM. Reason: line wrap

Popular pages Recent additions subscribe to a feed

Tags for this Thread