VERSION 5.00
Begin VB.Form Form1 
   BorderStyle     =   1  'Œ()
   Caption         =   "Sample Free area"
   ClientHeight    =   5955
   ClientLeft      =   3750
   ClientTop       =   2910
   ClientWidth     =   8775
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   5955
   ScaleWidth      =   8775
   Begin VB.CommandButton cmdInit 
      Caption         =   "Clear free area."
      Height          =   375
      Left            =   6000
      TabIndex        =   3
      Top             =   240
      Width           =   1695
   End
   Begin VB.CommandButton cmdDisp 
      Caption         =   "Disp"
      Height          =   375
      Left            =   1680
      TabIndex        =   2
      Top             =   240
      Width           =   1095
   End
   Begin VB.TextBox txtOffset 
      BeginProperty Font 
         Name            =   "lr SVbN"
         Size            =   12
         Charset         =   128
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   360
      TabIndex        =   1
      Text            =   "000040000"
      Top             =   240
      Width           =   1215
   End
   Begin VB.TextBox txtReadData 
      BeginProperty Font 
         Name            =   "lr SVbN"
         Size            =   12
         Charset         =   128
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   4575
      Left            =   360
      Locked          =   -1  'True
      MultiLine       =   -1  'True
      TabIndex        =   0
      Text            =   "Form1.frx":0000
      Top             =   720
      Width           =   7455
   End
   Begin VB.CommandButton cmdPre 
      Height          =   735
      Left            =   7920
      Picture         =   "Form1.frx":0006
      Style           =   1  '̨
      TabIndex        =   4
      Top             =   720
      Width           =   615
   End
   Begin VB.CommandButton cmdNext 
      Height          =   735
      Left            =   7920
      Picture         =   "Form1.frx":0448
      Style           =   1  '̨
      TabIndex        =   5
      Top             =   4560
      Width           =   615
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private curOffset As Long

Private Sub ReadSram(Offset As Long)
    Dim SramData(255) As Byte
    Dim lRetVal As Long
    Dim intCountRow As Integer
    Dim intCountCol As Integer
    Dim intCountData As Integer
    Dim strWork As String
    Dim strData As String
    
    ' \̈̏
    strData = Space(8) & ": 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F" & vbCrLf
    strData = strData & Space(8) & "-------------------------------------------------" & vbCrLf
    
    
    lRetVal = fcrasSRAMReadPhy(Offset, SramData(0), 256)
    intCountData = 0
    For intCountRow = 0 To 15
        If lRetVal = 0 Then
            strWork = Right("00000000" & Hex(Offset + intCountRow * 16), 8) & ":"
            strData = strData & strWork
            For intCountCol = 0 To 15
                strWork = Right("00" & Hex(SramData(intCountData)), 2)
                strData = strData & " " & strWork
                intCountData = intCountData + 1
            Next intCountCol
            strData = strData & vbCrLf
        Else
            Exit For
        End If
    Next intCountRow
    If lRetVal = 0 Then
        txtReadData.Text = strData
        curOffset = Offset
    Else
        Call MsgBox("Free area is from" & Right("00000000" & Hex(FCSRAM_FREE_START), 8) & " to " & _
                     Right("00000000" & Hex(FCSRAM_FREE_END), 8) & "." & _
                     vbCrLf & "Error(Return value=" & lRetVal & ")")
    End If
    
    txtOffset.Text = Right("0000000" & Hex(curOffset), 8)
End Sub

Private Sub cmdDisp_Click()
    Call ReadSram(Val("&h" & txtOffset.Text))
End Sub

Private Sub cmdInit_Click()
    ' 󂫗̈̏
    Call fcrasSRAMInit(4)
    Call ReadSram(curOffset)
End Sub

Private Sub cmdNext_Click()
    Call ReadSram(curOffset + &H100)
End Sub

Private Sub cmdPre_Click()
    Call ReadSram(curOffset - &H100)
End Sub

Private Sub Form_Load()
    Call fcsoftrasOpen

    curOffset = &H40000
    Call ReadSram(&H40000)
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Call fcsoftrasClose
End Sub

Private Sub txtReadData_DblClick()
    Dim selStart As Long
    Dim selRow As Long
    Dim selCol As Long
    selStart = txtReadData.selStart
    
    selRow = (selStart - 118) \ 59
    selCol = selStart Mod 59
    
    If selCol < 10 Then
        selCol = 0
    Else
        selCol = ((selCol - 10) \ 3) + 1
    End If
    
    Debug.Print txtReadData.selStart & "=(" & selRow & "," & selCol & ")"

    If selCol > 0 Then
        Form2.txtOffset = Right("00000000" & Hex(curOffset + selRow * &H10 + (selCol - 1)), 8)
        Form2.txtData = Mid(txtReadData.Text, (118 + selRow * 59 + 10 + (selCol - 1) * 3) + 1, 2)
        Form2.txtData.selStart = 0
        Form2.txtData.SelLength = 2
        Form2.Show (vbModal)
        Call ReadSram(curOffset)
        
    End If
End Sub
