visopsys.org

Visopsys Forums
It is currently Fri Jan 19, 2018 2:49 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Sound Driver Possibility And TRYING TO WRITE PNG LOADER :)
PostPosted: Sat Dec 21, 2013 12:43 pm 
Offline
User avatar

Joined: Fri Jul 22, 2011 3:53 pm
Posts: 45
How to enable sound and sound drivers ?
Also how can we play mp3 sound ??
Somebody implemented anything about that ??
If not,
What procedures we should follow ??
I guess its too complicated..
Also What about png image files ??

[STRIKE]Also im writing calculator app right now :p :)
Hope i can complete that :D
[/STRIKE] Forget that.. Its Already written...

EDIT : DOH http://wiki.osdev.org/Intel_High_Definition_Audio
after reading that pdf i lost my brain lol :: http://www.intel.co.uk/content/www/us/e ... ation.html

Almost all new pc's has Intel HDA probably . I need to learn about all different cpu s and sound drivers

i hope we dont need to do all things in intel's page... :violin: :ugeek:


Last edited by doga-1494 on Sun Dec 22, 2013 10:19 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Sound Driver Possibility And PNG Images ??
PostPosted: Sun Dec 22, 2013 10:17 pm 
Offline
User avatar

Joined: Fri Jul 22, 2011 3:53 pm
Posts: 45
I have used some basic stuff from kernelloaderclass

and i created kernelimagepng.c library and linked in makefile but,
// HOW TO DETECT AND SEE IF THAT CODE WORKING ???
// HOW TO LOAD A PNG FILE AND TEST DETECTION :D ?

and i couldnt add exact png's identifier .. :(
#define PNG_MAGIC1 0x474E5089 // 89PNG

how to add PNG_MAGIC1 into --> // if (!strncmp(dataPtr, HERE , 2(should be 4 probably because we are looking for first 4 characters)))


if try like this // if (!strncmp(dataPtr, PNG_MAGIC1, 4))
Kernel goes away from the world :D it doesnt boot .and shows lots of error

or it should be something like this ?? \x47 \x4E \x50 \x89 instead of PNG_MAGIC1

Code:
//
//  GhostNet based on Visopsys
//  Copyright (C) 2013-2014 Doga Ozkaracaabatlioglu   
//
//
//  kernelImagePng.c
//

// This file contains code for loading, saving, and converting images
// in the "Portable Network Graphics" (.png) format, commonly used in
// almost all systems

#include "kernelImagePng.h"
#include "kernelError.h"
#include "kernelFile.h"
#include "kernelGraphic.h"
#include "kernelImage.h"
#include "kernelLoader.h"
#include "kernelMalloc.h"
#include "kernelMemory.h"
#include "kernelMisc.h"
#include <stdio.h>
#include <string.h>



static int detect(const char *fileName, void *dataPtr, unsigned size,
           loaderFileClass *class)
{

  // Check params
  if ((fileName == NULL) || (dataPtr == NULL) || (class == NULL))
    return (0);

  // Must be binary, and have the signature '0x89504E47 0x0D0A1A0A' at the
  // beginning

  #define PNG_MAGIC1 0x474E5089
  #define PNG_MAGIC2 0x0A1A0A0D

  unsigned *sig = dataPtr;

  // Make sure there's enough data here for our detection
  if (size < sizeof(PNG_MAGIC1))
    return (0);
 
// Binary Detection

// Cancelled

// This function returns 1 and fills the fileClass structure if the data
  // points to an PNG file.




  // See whether this file claims to be a bitmap file
//  if (!strncmp(dataPtr, "BM", 2))
//   {


//     return (1);
//    }
//  else
//    return (0);


char welcomeMessage[512];
  if (!strncmp(dataPtr, ".PNG", 4))
    {
      sprintf(class->className, "%s %s", FILECLASS_NAME_PNG,
         FILECLASS_NAME_IMAGE);
      class->class = (LOADERFILECLASS_BIN | LOADERFILECLASS_IMAGE);
   // kernelTextPrintLine("%s\nPNG file is this", welcomeMessage); //doesnt work :( we cant print text in system log
// HOW TO DETECT AND SEE IF THAT CODE WORKING ???
// HOW TO LOAD A PNG FILE AND TEST ??
      return (1);
    }
  else
    return (0);

//when we use jpg
// We will say this is a JPG file.
// sprintf(class->className, "%s %s", FILECLASS_NAME_JPG, FILECLASS_NAME_IMAGE);
// class->class = (LOADERFILECLASS_BIN | LOADERFILECLASS_IMAGE);
// return (1);
}


// PNG images.   
kernelFileClass pngFileClass = {
  FILECLASS_NAME_PNG,
  &detect,
  { }
};





/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
//
// Below here, the functions are exported for external use
//
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////

kernelFileClass *kernelFileClassPng(void)
{
  // The loader will call this function so that we can return a structure
  // for managing PNG images

  static int filled = 0;

  if (!filled)
    {
   //   pngFileClass.image.load = &load;
  //    pngFileClass.image.save = &save;
      filled = 1;
    }

  return (&pngFileClass);
}




Top
 Profile  
 
 Post subject: Re: Sound Driver Possibility And TRYING TO WRITE PNG LOADER
PostPosted: Mon Dec 23, 2013 7:01 pm 
Offline
User avatar

Joined: Fri Jul 22, 2011 3:53 pm
Posts: 45
Maybe we can use libpng ?
http://www.libpng.org/pub/png/book/chapter13.html

i dont know.. it looks like PNG file reading much complicated than jpg and bmp...
http://en.wikipedia.org/wiki/Portable_Network_Graphics

we need to read chunks in pngloader


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group