#N88BASIC

Dim id3genre[256] = [ _
  "Blues", "Classic Rock", "Country", "Dance", "Disco", "Funk", "Grunge", "Hip-Hop", "Jazz", "Metal", "New Age", "Oldies", _ 
  "Other", "Pop", "R&B", "Rap", "Reggae", "Rock", "Techno", "Industrial", "Alternative", "Ska", "Death Metal", "Pranks", _
  "Soundtrack", "Euro-Techno", "Ambient", "Trip-Hop", "Vocal", "Jazz+Funk", "Fusion", "Trance", "Classical", "Instrumental", _
  "Acid", "House", "Game", "Sound Clip", "Gospel", "Noise", "AlternRock", "Bass", "Soul", "Punk", "Space", "Meditative", _
  "Instrumental Pop", "Instrumental Rock", "Ethnic", "Gothic", "Darkwave", "Techno-Industrial", "Electronic", "Pop-Folk", _
  "Eurodance", "Dream", "Southern Rock", "Comedy", "Cult", "Gangsta", "Top 40", "Christian Rap", "Pop/Funk", "Jungle", _
  "Native American", "Cabaret", "New Wave", "Psychedelic", "Rave", "Showtunes", "Trailer", "Lo-Fi", "Tribal","Acid Punk", _
  "Acid Jazz", "Polka", "Retro", "Musical", "Rock & Roll", "Hard Rock", "Folk", "Folk/Rock", "National Folk", "Swing", _
  "Fast-Fusion", "Bebob", "Latin", "Revival", "Celtic", "Bluegrass", "Avantgarde", "Gothic Rock", "Progressive Rock", _
  "Psychedelic Rock", "Symphonic Rock", "Slow Rock", "Big Band", "Chorus", "Easy Listening", "Acoustic", "Humour", "Speech", _
  "Chanson", "Opera", "Chamber Music", "Sonata", "Symphony", "Booty Bass", "Primus", "Porn Groove", "Satire", "Slow Jam", _
  "Club", "Tango", "Samba", "Folklore", "Ballad", "Power Ballad", "Rhythmic Soul", "Freestyle", "Duet", "Punk Rock", "Drum Solo", _
  "A Cappella", "Euro-House", "Dance Hall", "Goa", "Drum & Bass", "Club-House", "Hardcore", "Terror", "Indie", "BritPop", _
  "Negerpunk", "Polsk Punk", "Beat", "Christian Gangsta Rap", "Heavy Metal",   "Black Metal", "Crossover", _
  "Contemporary Christian", "Christian Rock", "Merengue", "Salsa", "Thrash Metal", "Anime", "JPop", "Synthpop" _
  ] As BytePtr

Type ID3v1
  id[2] As Byte
  title[29] As Byte
  artist[29] As Byte
  album[29] As Byte
  year[3] As Byte
  comment[28] As Byte
  track As Byte
  genre As Byte
End Type

Sub Puts(str As BytePtr)
  Print MakeStr(str)
End Sub

Function GetID3(mp3file As BytePtr, id3 As *ID3v1) As Long
  Dim hFile As HANDLE
  Dim err As Long
  Dim read As Long
  debug
  hFile = CreateFile(mp3file, GENERIC_READ, 0, ByVal NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
  If hFile = INVALID_HANDLE_VALUE Then Exit Function
  err = SetFilePointer(hFile, -SizeOf(ID3V1), NULL, FILE_END)
  err = ReadFile(hFile, id3, SizeOf(ID3V1), VarPtr(read), ByVal NULL)
  CloseHandle(hFile)
  If err = FALSE Then Exit Function
  GetID3 = TRUE
End Function

Sub ShowID3(mp3file As BytePtr, id3 As *ID3v1)
  Dim b[3] As Byte
  Puts(mp3file)
  Puts(id3->title)
  Puts(id3->artist)
  Puts(id3->album)
  Puts(id3->year)
  Puts(id3->comment)
  b[0] = id3->track +Asc("0")
  Puts(b)
  Puts(id3genre[id3->genre])
End Sub

Dim id3 As ID3v1
GetID3("test.mp3", VarPtr(id3))
ShowID3("test.mp3", VarPtr(id3))