📄 yadl.h
字号:
/************************************************************************
**
** Copyright (C) 2002 Ulrich Behrenbeck <uli@yampp.com>.
**
**
** Yampp - Advanced Disk Layout
**
** File YADL.H
**
** NOTE:
** throughout this spec, all sector adresses are true 32 bit, not "only" 28 bit lba !
** no abuse of high bits in the sector values allowed ...
**
**
*************************************************************************
**
** This file is part of Jesper Hansen's yampp system.
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation; either version 2
** of the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software Foundation,
** Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
**
*************************************************************************
**
** Revision History
**
** when what who why
**
** 2002-09-01 1.0 Uli initial public release
**
************************************************************************/
#ifndef __YADL_H__
#define __YADL_H__
#ifdef _MSC_VER
typedef unsigned char u08;
typedef unsigned short u16;
typedef unsigned long u32;
typedef char s08;
typedef short s16;
typedef long s32;
#pragma pack(1)
#endif
typedef unsigned long SECTOR; /* u32 sector number */
typedef unsigned long CLUSTER; /* u32 cluster number (max 27 bits used */
typedef unsigned long FLENGTH; /* u32 File length */
typedef unsigned long FOFFSET; /* u32 offset inside file from start of file */
/* globalisms *********************************************************************/
#define SECTORSIZE 0x200 /* ever gonna change ???? ;-) */
/* our CLUSTERSIZE is fixed to 0x40000 or 2^18 or 256 k or 512*512 or 0x200*0x200 */
#define YADL_CLUSTERSIZE 0x40000
/* so this will remain always 512 */
#define YADL_SECTORS_PER_CLUSTER (YADL_CLUSTERSIZE / SECTORSIZE)
/* fixed sector numbers in ROOT_AREA these are NOT not change*/
#define YADL_SEC_ROOT 0
#define YADL_SEC_ARTIST_INDEX 1
#define YADL_SEC_TITLE_INDEX 2
#define YADL_SEC_APPL_STORAGE 3 /* place for generic application storage */
#define YADL_SEC_SCRATCH 4
#define YADL_SEC_SONG_BASE 5
/********************************************************************************
**
** these fixed sectors lead to the following DISK LAYOUT
**
********************************************************************************
SecNum
0: Root Sector
1: Artist Index (structure see below) (NOT FILLED YET -> now set to 0xFFFF)
2: Title Index (structure see below) (NOT FILLED YET -> now set to 0xFFFF)
3: Application Storage (NOT USED YET)
4: Spare / Scratch
5: start of songbase - the length of the songbase depends on the physical size of the disk
a simple guess is made here for the maximium number of song_base_entries:
song_base_entries = ((num_clusters >> 3) &0xFFFFFFF0) + 10;
xx FAT variable secno, pointed to fat_start: begin of FAT
yy DATA variable secno, to reach cluster 0 -> take "sector_cluster_offset"
zz after all data, there may (!) be some spare room
this is identified by (secnum) wasteland_start and (u16) wasteland_length
*******************************************************************************
Artist and Track Indices: (please note: NOT FILLED IN YET !!!)
*******************************************************************************
each song contains the following info in its songbase slot:
u16 next_artist; pointer into songbase to (alphabetically) next title of this artist or new artist
u16 next_artist_grouped; pointer into songbase to (alphabetically) next artist in unique(grouped) list
u16 next_title; pointer into songbase to (alphabetically) next song
these fields provide a means to browse the songs either alphabetically by song titles or artists
meaning that all songs titles/artists inside the base can be accessed via an ordered list
"end of list reached" indicated with 0xFFFF
the two additional sectors Artist/Title Index contain start values to go with them into the song base
you have to consider the sector as being the following array
u16 artist_index[0x100] (one sector in size)
artist_index[0] will always point to the VERY FIRST artist name in the current songbase
if you want to present the user with a list of all artists, eg. starting with 'S'
go inside the index to lookup the first songbase entry (if any)
note that it will be treated case insensitive, thus 'S' will be == 's'
first song starting with 'S' in base --> artist_index['S']
*************************************************************************
**
** The yaDL R O O T Sector
**
*************************************************************************/
/* STRINGS THAT THE FIRMWARE FILLS IN - note: all need a \0 termination except for the ID */
#define YADL_LEN_MODEL 30 /* eg yampp 4,5,6 etc */
#define YADL_LEN_BUILD_TIMESTAMP 32 /* compile timestamp of firmware */
#define YADL_LEN_DISK_INFO 80 /* Disk manuf name etc from atapi identify drive */
/* STRINGS THAT THE HOST APP FILLS IN */
#define YADL_LEN_IDENTIFIER 20 /* must be UNIQUE !! identifier for that particular yampp - used as subdir name on PC */
/* Values for the "unmount_state" field */
#define YADL_STATE_MOUNTED 0 /* Pc APP wrote to yampp and made it "dirty" */
#define YADL_STATE_OK 0x10 /* PC APP logged off normally , all data written , CLEAN state */
#define YADL_STATE_NEW 0xFF /* FRESH DISK */
#define YADL_MEDIA_UNKNOWN 0 /* type of storage yampp uses */
#define YADL_MEDIA_DISK 1
#define YADL_MEDIA_FLASH 2
typedef struct
{
/*************/
/* SECTION 1 */
/*************/
/* data the yampp firmware fills in ONCE upon new disk detection */
u08 id[4]; /* always "YADL" */
u32 disk_size; /* size in sectors of 512 byte - TRUE u32 here !!! */
u08 unmount_state; /* == YADL_STATE_OK -> fine, yaPC was exited cleanly
YADL_STATE_MOUNTED -> ERROR possibly corruption, disk not closed by yaPC!
firmware MUST NEVER touch this field except for new disk detection
-> then set to YADL_STATE_NEW */
u08 media_type; /* for now, only YADL_MEDIA_DISK, YADL_MEDIA_FLASH, YADL_MEDIA_UNKNOWN */
u08 disk_version_major; /* start with 1.0 */
u08 disk_version_minor;
u08 model[YADL_LEN_MODEL]; /* yampp 3,4,5,6,7 etc ... */
u08 disk_info[YADL_LEN_DISK_INFO]; /* ATAPI IDENTIFY DRIVE infos... */
/*************/
/* SECTION 2 */
/*************/
/* data the yampp firmware checks on startup and fills in new values after each FW update */
u08 build_timestamp[YADL_LEN_BUILD_TIMESTAMP]; /* to be filled in by __DATE__ __TIME__ macros */
u08 firmware_version_major;
u08 firmware_version_minor;
/*************/
/* SECTION 3 */
/*************/
/* data the Host APP fills in */
u08 identifier [YADL_LEN_IDENTIFIER]; /* must be unique and a valid PC subdirname */
u16 t_year; /* last PC access time */
u08 t_month;
u08 t_day;
u08 t_hour;
u08 t_minute;
u08 t_second;
u08 z_dummy00;
/* misc ADRESSING + DATA STUFF */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -