#include "blocks.h" #include Frame* Block::getFrame( int index ) { return index >= 0 && index < 64 ? &frames[index] : 0; } IdentificationFrame* DirectoryBlock::IDFrame() { return (IdentificationFrame*)&frames[0]; } DirectoryFrame* DirectoryBlock::Directory( int index ) { return index < 15 && index >= 0 ? (DirectoryFrame*)&frames[index + 1] : 0; } void DirectoryBlock::Directory( int index, DirectoryFrame *frame ) { memcpy( &frames[index], frame, sizeof( DirectoryFrame ) ); } Frame* DirectoryBlock::Reserved( int index ) { return index < 20 && index >= 0 ? &frames[index + 16] : 0; } Frame* DirectoryBlock::Unused( int index ) { return index < 27 && index >= 0 ? &frames[index + 36] : 0; } Frame* DirectoryBlock::WriteTest() { return &frames[63]; } int DirectoryBlock::nextOpenBlock() { for( int i = 0; i < 15; i++ ) { int type = Directory( i )->blockType(); if( type >= 160 && type <= 163 ) { return i + 1; } } return 0; } SaveHeaderFrame* InitialBlock::Header() { return (SaveHeaderFrame*)&frames[0]; } Icon* InitialBlock::getIcon( int index ) { //return index < 3 && index >= 0 ? &frames[index + 1] : 0; SaveHeaderFrame *header = Header(); IconFrame *frame = (IconFrame*)&frames[index + 1]; Icon *icon = new Icon(); for( int y = 0; y < 16; y++ ) { icon->paletteColor( y, header->paletteColor( y ) ); for( int x = 0; x < 16; x++ ) { icon->pixel( x, y, frame->colorAt( x, y ) ); } } return icon; }