static void MemMod( mad_type_handle mth, mad_type_kind mas ) { item_mach item; item_type ops; address addr; mad_type_info mti; ops = IT_ERR | IT_INC; if( mas & MAS_IO ) { ops |= IT_IO; addr.mach.offset = ReqExpr(); } else { addr = GetDataDot(); OptMemAddr( EXPR_DATA, &addr ); } if( CurrToken == T_COMMA ) Scan(); MADTypeInfo( mth, &mti ); while( !ScanEOC() ) { if( !( ops & IT_IO ) ) { SetDataDot( addr ); } if( CurrToken != T_COMMA ) { NormalExpr(); ToItemMAD( ExprSP, &item, &mti ); PopEntry(); if( CurrToken != T_COMMA && !ScanEOC() ) { Error( ERR_LOC, LIT_ENG( ERR_WANT_EOC ) ); } ItemPutMAD( &addr, &item, ops, mth ); } if( CurrToken == T_COMMA ) { Scan(); } } if( !(ops & IT_IO) ) { DbgUpdate( UP_MEM_CHANGE | UP_CODE_ADDR_CHANGE | UP_REG_CHANGE ); } }
OVL_EXTERN void IOMenuItem( a_window wnd, gui_ctl_id id, wnd_row row, wnd_piece piece ) { io_window *io = WndIO( wnd ); address addr; bool ok; item_mach item; io_location *curr; mad_radix old_radix; /* unused parameters */ (void)piece; if( row < io->num_rows && row >= 0 ) { curr = &io->list[row]; } else { curr = NULL; } switch( id ) { case MENU_INITIALIZE: if( curr == NULL ) { WndMenuGrayAll( wnd ); } else { WndMenuEnableAll( wnd ); } WndMenuEnable( wnd, MENU_IO_NEW_ADDRESS, true ); break; case MENU_IO_DELETE: io->num_rows--; memcpy( &io->list[row], &io->list[row + 1], ( io->num_rows - row ) * sizeof( io_location ) ); WndNoSelect( wnd ); WndSetRepaint( wnd ); break; case MENU_IO_NEW_ADDRESS: addr = NilAddr; if( !DlgGivenAddr( LIT_DUI( New_Port_Addr ), &addr ) ) return; WndRowDirty( wnd, io->num_rows ); IOAddNewAddr( wnd, &addr, MENU_IO_FIRST_TYPE ); WndScrollBottom( wnd ); break; case MENU_IO_MODIFY: if( row >= io->num_rows || row < 0 ) break; if( piece == PIECE_VALUE ) { old_radix = NewCurrRadix( IOData.info[curr->type].piece_radix ); item.ud = curr->value_known ? curr->value.ud : 0; ok = DlgMadTypeExpr( TxtBuff, &item, IOData.info[curr->type].mth ); if( ok ) { curr->value = item; curr->value_known = true; } NewCurrRadix( old_radix ); } else { addr = curr->addr; if( !DlgGivenAddr( LIT_DUI( New_Port_Addr ), &addr ) ) return; curr->addr = addr; curr->value_known = false; } WndRowDirty( wnd, row ); break; case MENU_IO_READ: curr->value_known = true; if( ItemGetMAD( &curr->addr, &curr->value, IT_IO, IOData.info[curr->type].mth ) == IT_NIL ) { curr->value_known = false; } WndPieceDirty( wnd, row, PIECE_VALUE ); break; case MENU_IO_WRITE: if( curr->value_known ) { ItemPutMAD( &curr->addr, &curr->value, IT_IO, IOData.info[curr->type].mth ); } break; default: curr->type = PIECE_TYPE( id ); WndZapped( wnd ); break; } }