Jump to content

  • Log In with Google      Sign In   
  • Create Account

BASICFreak

Member Since 07 May 2006
Offline Last Active Jan 25 2016 06:01 PM

Topics I've Started

VBE 2.0+ Set Display Start for Page Flipping

20 August 2015 - 03:04 PM

Ok, hello again GameDEV - It's been a few years since I was last here.

 

Anyways,

 

I am in middle of writing a VBE driver for my kernel, currently I have a double buffer which does stop the flashing, but even at low resolutions I am unable to copy the entire buffer into active video memory within the refresh time. (at 640X480X8 it takes 2.5 refresh cycles which causes tearing)

 

In Real-Mode I have set the display resolution, enabled LFB, and grabbed the PMode Interface Table - and passed all information to the Kernel.

 

The issue that I have been facing is when trying to use the SetDisplayStart, no matter my input on DX/CX I end up with the same results.

Currently my video memory has at offset 0 color 0x83 640*480 times and just after this we have color 0x28 640*480 times.

 

The Current VBE Mode info contains:

BytesPerLine = 0x280 (640)

LinBytesPerScanLine = 0x280

 

I am calling SetDisplayStart the following way (Intel ASM):

FlipPage:
pusha
 
mov eax, DWORD [SecondBuffer]
test eax, eax
jz .NotSecond
 
mov dx, 0
mov cx, 0
mov DWORD [SecondBuffer], 0
jmp .flipme
 
.NotSecond:
mov dx, WORD [Height]
mov cx, 0
mov DWORD [SecondBuffer], 1
.flipme:
 
;Now Lets Page Flip
xor bx, bx
mov ax, 0x4F07
xchg bx, bx
call DWORD [VBE_FUNCTION7]
test ah, ah
jnz ERROR
cmp al, 0x4F
jne ERROR
 
popa
ret

And no matter how DX/CX is filled the result is always (or Y out of range panic from Bochs):

Attached File  2015-08-20-014835_642x555_scrot.png   14.67KB   0 downloads

and yes even with DX and CX = 0 this is the result.

 

So I'm hoping beyond all hope someone here has done this before (as the internet seems to have no reference other than what is in the VBE Specifications...)

 

I know we are going back to the mid/early 90's here, but I cannot write a driver per card (most have no Info) so I'm stuck with VBE support and software rendering.


Link ASM object (aout) in AR archive? [GNU DJGPP] [NASM]

24 May 2014 - 10:04 PM

I hope I placed this in the right topic as AR and LD are "Tools" rolleyes.gif .

 

First note I realize my build script should be a MakeFile, but it's a cmd script.

 

Second note I have attempted to search Google, this Forum, and OSDEV but the keywords here are way to vague and only 2 letters so all results I saw did not relate to my situation.

 

 

 

Ok, I have currently one ASM file containing all the assembly code I need; but, while rewriting parts of the project I decided I want to break this one ASM file into about 6.

 

Let me dump some of the build script here before I get into my question...:

...

@ECHO IDT.C
gcc %GCC_OPTIONS% ./OBJ/IDT.O ./DRIVERSRC/SYSTEM/CPU/IDT.c
@ECHO IRQ.ASM
nasm -f aout ./DRIVERSRC/SYSTEM/CPU/IRQ.ASM ./OBJ/IRQA.O
@ECHO IRQ.C
gcc %GCC_OPTIONS% ./OBJ/IRQ.O ./DRIVERSRC/SYSTEM/CPU/IRQ.c

...

ar rvs ./DRIVER/sys.a ./OBJ/8259.O ./OBJ/GDT.O ./OBJ/IDT.O ./OBJ/IRQA.O ./OBJ/IRQ.O ./OBJ/TSS.O ./OBJ/FAT12.O
ar rvs ./DRIVER/sys.a ./OBJ/VFS.O ./OBJ/PAGEDIR.O ./OBJ/PAGEFAULT.O ./OBJ/PAGETABLE.O ./OBJ/PHYSICAL.O
ar rvs ./DRIVER/sys.a ./OBJ/VIRTUAL.O
@ECHO START.ASM
nasm -f aout ./KERNELSRC/START.ASM -o ./OBJ/START.O
@ECHO MAIN.C
gcc %GCC_OPTIONS% ./OBJ/MAIN.O ./KERNELSRC/MAIN.c
@ECHO COMMAND.C
gcc %GCC_OPTIONS% ./OBJ/COMMAND.O ./KERNELSRC/COMMAND.c
@ECHO LINKING KERNEL.BIN
LD -T %LD_SCRIPT% -o %OUTPUT_FILE% ./OBJ/START.O ./OBJ/MAIN.O ./OBJ/COMMAND.O ./LIB/lib.a ./DRIVER/sys.a ./DRIVER/hw.a

...

As you can see above my only ASM file "START.ASM" is compiled format AOUT and placed in directly with the LD command - this works fine.

 

But when I split this source file into the appropriate sections I run into one of two problems:

1. Add to the archive - Error returned "./DRIVER/sys.a: could not read symbols: File truncated"

2. Add files to LD command - LD becomes too long and the system cannot process it.

 

The reason I oppose a MakeFile so much is I am constantly rebuilding / testing and a simple BATCH loop with a menu is great - plus I haven't sat down to find out how one is constructed...huh.png

 

So, anyways, my question is - Is there a way to archive ASM and C objects in the same library, or is there an all-together better way of doing this?


Returning a Char Array from function in C

20 September 2013 - 08:00 PM

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>


FILE *FS;
FILE *LF;


unsigned int HexDec(char Hx[16])
{
    unsigned int ret;
    ret = (long int)strtol(Hx, NULL, 16);
    return ret;
}
char DecHex(unsigned int Dec) //4 bytes
{
    char ret[16];
    sprintf(ret,"%08x", Dec);
    return ret;
}
char BinHex(char Bin[16]) //4 Bytes
{
    char ret[16];
    sprintf(ret, "%02x%02x%02x%02x", (unsigned int) Bin[0] & 0xFF, (unsigned int) Bin[1] & 0xFF, (unsigned int) Bin[2] & 0xFF, (unsigned int) Bin[3] & 0xFF);
    return ret;
}
void main()
{
    char BIN[16] = "AA55";
    char HEX[16] = BinHex(BIN);
    unsigned int DEC = HexDec(HEX);
    char DECHEX[16] = DecHex(DEC);
    printf("Bin: %s\n\n", BIN);
    printf("To Hex: %s\nTo Dec: %u\n\n Dec %u to Hex %s\n", HEX, DEC, DEC, DECHEX);
}
 
I am currently rewriting horrible looking test code and trying to get some functions to clean up, but I'm running into the issue where I must have arrays not pointers returned to be able to manipulate the data being processed.
 
​The end goal is to give me access to my custom File System threw linux terminal. Currently my first code works flawlessly, but the code is so hard to read and has the same segments over and over again (these segments are what I'm trying to get into functions).
 
The function DecHex is the main one I am worried about returning as an array because my code currently looks like:
 
//sprintf(hx,"%08x",(unsigned int) filesize);  what is currently here
hx = DecHex(filesize);
printf("Hex value of Decimal value %ld  is %s\n",filesize,hx);
sprintf (tmp, "%c%c", hx[6], hx[7]);
tmpb = strtol(tmp, NULL, 16);
printf("%s - %u\n", tmp, tmpb);
putc(tmpb, FS);
sprintf (tmp, "%c%c", hx[4], hx[5]);
tmpb = strtol(tmp, NULL, 16);
printf("%s - %u\n", tmp, tmpb);
putc(tmpb, FS);
sprintf (tmp, "%c%c", hx[2], hx[3]);
tmpb = strtol(tmp, NULL, 16);
printf("%s - %u\n", tmp, tmpb);
putc(tmpb, FS);
sprintf (tmp, "%c%c", hx[0], hx[1]);
tmpb = strtol(tmp, NULL, 16);
printf("%s - %u\n", tmp, tmpb);
putc(tmpb, FS);
 
 
And as I stated my old code is bad for the eyes (~900 lines of confusing), I am getting to that part but first I need this pointer array issue fixed.
 
If you need my old code for something let me know, otherwise it is best kept away from eyes lol.
 
Any help is appreciated, Thanks in advance B T Hoover
 

MySQL Database Structure and Data Lister

06 July 2013 - 02:35 AM

First here is the code:

<?php
require './includes/config.ini.php';
?>
<html>
    <head>
        <title>Database Structure</title>
    </head>
    <body bgcolor="#FFFFFF" text="#000000">
        <center><h1><?PHP echo $database; ?></h1>
            <table border="1" cellspacing="0" width="820">
                <tr>
                    <td width="175">Table</td>
                    <td width="175">Field</td>
                    <td width="175">Field Type</td>
                    <td width="290">Value</td>
                </tr>
        
<?PHP
mysql_connect($server, $username, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());


$tableresults = mysql_query("SHOW TABLES");
while ( $tablerows = mysql_fetch_array($tableresults) )
{
    $structureresults = mysql_query("DESCRIBE ".$tablerows[0]);
    while ( $structurerows = mysql_fetch_array($structureresults) )
    {
        $result = mysql_query("SELECT * FROM ".$tablerows[0]);
        while ( $row = mysql_fetch_array($result) )
        {
            echo '<tr>
                    <td>'.$tablerows[0].'</td>
                    <td>'.$structurerows['Field'].'</td>
                    <td>'.$structurerows['Type'].'</td>
                    <td>'.$row[$tablerows['Field']].'</td>
                </tr>';
        }
    }
}
?>
            </table>
        </center>
    </body>
</html>

The issue I am having is I am not displaying any of the values from the table, all other information is displaying fine, anyone have any ideas.

 

Could it be that I cannot use a variable to locate an array point?

 

 

Any help is greatly appreciated

 

BASICFreak

 


First complex BATCH file

10 September 2011 - 06:10 PM

This was my first time to use any commands in a BATCH file, I never thought it could get so confusing.

It took me 13 whole hours of trial and error and research.
I couldn't find a tool to do exactly what I wanted and figure it may be of use to others.

The script has no output while running, and can take a very long time to process depending on your registry size

FILE NAME = REGKEYEXTRACTOR.CMD


@ECHO OFF
setlocal enableextensions enabledelayedexpansion
COLOR 1F
CLS
SET ARGS=0
SET OPTS=0
SET OPTIONS=
FOR %%x IN (%*) DO SET /A ARGS+=1
IF %ARGS% LSS 1 GOTO ERROR
IF "%1" == "" GOTO ERROR
IF "%1" == "/?" GOTO ERROR
SET RtKy=%1
SHIFT
IF NOT X%1X==XX (
	SET OPTIONS=%1
	SET OPTION_ALL=%1
	SET /A OPTS+=1
)
IF NOT X%OPTIONS%X==XX GOTO LOOP
:LOOP
SHIFT
IF X%1X==XX GOTO ENDLOOP
SET OPTIONS=%OPTIONS% %1
SET OPTION_ALL=%OPTION_ALL%~%1
SET /A OPTS+=1
GOTO LOOP
:ENDLOOP
IF %OPTS% GEQ 1 GOTO GETOPTIONS
GOTO :EOF

:GETOPTIONS
FOR /F "USEBACKQ TOKENS=1-%OPTS% DELIMS=~" %%A IN ('%OPTION_ALL%') DO (
IF %OPTS% GEQ 1 SET OPTION_1=%%A
IF %OPTS% GEQ 2 SET OPTION_2=%%B
IF %OPTS% GEQ 3 SET OPTION_3=%%C
IF %OPTS% GEQ 4 SET OPTION_4=%%D
IF %OPTS% GEQ 5 SET OPTION_5=%%E
IF %OPTS% GEQ 6 SET OPTION_6=%%F
IF %OPTS% GEQ 7 SET OPTION_7=%%G
IF %OPTS% GEQ 8 SET OPTION_8=%%H
IF %OPTS% GEQ 9 SET OPTION_9=%%I
IF %OPTS% GEQ 10 SET OPTION_10=%%J
IF %OPTS% GEQ 11 SET OPTION_11=%%K
IF %OPTS% GEQ 12 SET OPTION_12=%%L
IF %OPTS% GEQ 13 SET OPTION_13=%%M
IF %OPTS% GEQ 14 SET OPTION_14=%%N
IF %OPTS% GEQ 15 SET OPTION_15=%%O
IF %OPTS% GEQ 16 SET OPTION_16=%%P
IF %OPTS% GEQ 17 SET OPTION_17=%%Q
IF %OPTS% GEQ 18 SET OPTION_18=%%R
IF %OPTS% GEQ 19 SET OPTION_19=%%S
IF %OPTS% GEQ 20 SET OPTION_20=%%T
)
IF "%OPTION_1%"=="/I" (
	IF %OPTS% EQU 2 (
		IF NOT X%OPTION_2%X==XX (
			SET INFILE=%OPTION_2%
			GOTO INPUTTEXT
		) ELSE (
			GOTO ERROR
		)
	) ELSE (
		GOTO ERROR
	)
)ELSE IF "%OPTION_1%"=="/i" (
	IF %OPTS% EQU 2 (
		IF NOT X%OPTION_2%X==XX (
			SET INFILE=%OPTION_2%
			GOTO INPUTTEXT
		) ELSE (
			GOTO ERROR
		)
	) ELSE (
		GOTO ERROR
	)
) ELSE (
	GOTO QUERY
)
GOTO :EOF


:INPUTTEXT
FINDSTR /B /C:"HKEY" %INFILE% > TEMP.TXT
ECHO Windows Registry Editor Version 5.00 > %RtKy%-FINAL.REG
ECHO. >> %RtKy%-FINAL.REG
FOR /F "TOKENS=1* DELIMS=\" %%A IN (TEMP.TXT) DO (
REG EXPORT "%RtKy%\%%B" TMP.REG /Y
TYPE TMP.REG > TEMP.REG
DEL TMP.REG /Q
FOR /F "SKIP=2 TOKENS=*" %%a IN (TEMP.REG) DO @ECHO %%a >> %RtKy%-FINAL.REG
DEL TEMP.REG /Q
)
DEL TEMP.TXT
GOTO :EOF

:QUERY
REG QUERY %RtKY% %OPTIONS% > QUERYTEMP.TXT
SET INFILE=QUERYTEMP.TXT
GOTO INPUTTEXT
GOTO :EOF

:ERROR
ECHO REGKEYEXTRACTOR.CMD
ECHO By Brian T. Hoover A.K.A. BASIC.Freak
ECHO.
ECHO USSAGE  REGKEYEXTRACTOR.CMD RootKey [OPTIONS]
ECHO EXAMPLE REGKEYEXTRACTOR.CMD HKLM /S /F "FOO bar" /Z
ECHO     	REGKEYEXTRACTOR.CMD HKLM /I hklm.TXT
ECHO.
ECHO RootKey - [ HKLM ^| HKCU ^| HKCR ^| HKU ^| HKCC ]
ECHO.
ECHO [OPTIONS]    -- WARNING DO NOT USE A '~' IN OPTIONS! --
ECHO /I "InputFile"  -  USE A PRE-OUTPUTED REG QURY FILE
ECHO.
ECHO   ----------------------------  OR  ----------------------------
ECHO.
ECHO /S      Queries all subkeys and values recursively (like dir /s).
ECHO.
ECHO /se 	Specifies the separator (length of 1 character only) in
ECHO     	data string for REG_MULTI_SZ. Defaults to "\0" as the separator.
ECHO.
ECHO /f      Specifies the data or pattern to search for.
ECHO     	Use double quotes if a string contains spaces. Default is "*".
ECHO.
ECHO /k      Specifies to search in key names only.
ECHO.
ECHO /d      Specifies the search in data only.
ECHO.
ECHO /c      Specifies that the search is case sensitive.
ECHO     	The default search is case insensitive.
ECHO.
ECHO /e      Specifies to return only exact matches.
ECHO     	By default all the matches are returned.
ECHO.
ECHO /t      Specifies registry value data type.
ECHO     	Valid types are:
ECHO       	REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ,
ECHO       	REG_DWORD, REG_QWORD, REG_BINARY, REG_NONE
ECHO     	Defaults to all types.
ECHO.
ECHO /z      Verbose: Shows the numeric equivalent for the type of the valuename.
GOTO :EOF



enjoy Posted Image

PARTNERS