News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Life in high rez

Started by Magnum, August 17, 2013, 09:33:57 AM

Previous topic - Next topic

Magnum

I am trying to get the life program in higher graphics mode.

C:\16_BIT>tasm life.asm
Turbo Assembler  Version 4.1  Copyright (c) 1988, 1996 Borland International

Line 87 or [byte di],10h        ;Birth: add 10h

Line 43  mov ebx,[033Ch]         ;Seed RNG with clock

Assembling file:   life.asm
*Warning* life.asm(43) [Constant] assumed to mean immediate constant
**Error** life.asm(87) Need right square bracket
*Warning* life.asm(87) Argument needs type override
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

Gunther

Andy,

try this:


[font=courier]
Line 43:     mov    ebx, 033ch
Line 87      or     byte ptr [di], 10h
[/font]


Gunther
You have to know the facts before you can distort them.

FORTRANS

Hi,

   Depending on what you are actually wanting to do, the following
might be a valid correction to Line 43.


      MOV     EBX,DS:[033CH]


   My code loads from a memory location, Gunther's loads a constant
without an error message.

HTH,

Steve N.

Magnum

Thanks gentlemen.
I will study and use what looks appropriate for the code.

Andy


; life.asm By Vladislav Kaipetsky and Tenie Remmel
;              Tasm code
.model small
.586
.stack 200h

.data

Vesa_Err db "Can not set Vesa mode !",0

.code

Start:     


SETUP101:       ; Initialize for mode 101, 640 x 480 x 256 colors

mov      ax,@data
       mov      ds,ax


MOV     AH,4FH          ; VESA functions
MOV     AL,2            ; Set Video mode
MOV     BX,101h      ; = video mode
INT     10H

; Should check for success/failure here
CMP     AX,4FH  ; AL = 4FH, AH = 0 for success
JNZ     SET101
jmp Next           


SET101:
        ;CALL    RESET_VID
MOV     DX,OFFSET VESA_ERR
;print error message and exit
mov     ah,9
int     21h

mov  ax,4c00h
int  21h

next:
            mov ds,ax               ;DS = 13h
            mov ebx,[033Ch]         ;Seed RNG with clock
                                   
            mov ax,cs               ;DS, ES = virtual video
            add ah,10h
            mov ds,ax
            mov es,ax

            xor cx,cx               ;64K bytes

RandLoop:   add ebx,ebx             ;Generate random number
            jnc RandSkip
            xor bl,197
            stc
RandSkip:   sbb al,al               ;Mask for 0 or 15
            and al,15
            stosb                   ;Store byte
            loop RandLoop           ;Loop back

            push 0A000h             ;ES = video memory
            pop es

MainLoop:   mov si,320              ;Display this frame
            push si
            xor di,di
            mov cx,32000
            rep movsw

            mov cx,64000            ;Set up for LifeLoop
            pop di

LifeLoop:   mov ax,-1               ;Get boundary count
            sub al,[di-1]
            sub ah,[di+1]
            sub al,[di-321]
            sub ah,[di+319]
            sub ax,[di-320]
            sub ax,[di+320]
            add al,ah
            and al,0Fh

            cmp al,1                ;2 = stay, 3 = birth
            jl LifeStay             ;any other = death
            jg LifeLB               ;actual value is 2 less

            or [byte di],10h        ;Birth: add 10h
            jmp LifeLB

LifeStay:   mov al,[di]             ;Stay: add 10h if it's on
            add al,al
            or [di],al

LifeLB:     inc di                  ;Loop back
            loop LifeLoop

CleanLoop:  mov al,[di]             ;Get pixel
            and al,10h              ;10h, 1Fh -> 0Fh
            cmp al,1                ;00h, 0Fh -> 00h
            adc al,-1
            mov [di],al             ;Set pixel

            inc di                  ;Loop back
            loop CleanLoop

            mov ah,1                ;Check for key
            int 16h
            jz MainLoop             ;Loop if no key

            mov ax,3                ;Set text mode
            int 10h
            ret                     ;Return

End Start







Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

Magnum

Oops.

I got this message. "NTVDM CPU has encountered an illegal instruction."

cs:0000 ip:01a3 op:f0 4e 67 00 f0
Choose close to terminate app.

I am thinking this is not compatible with the Vesa mode 101 part of the code.

            push 0A000h             ;ES = video memory
            pop es



Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

MichaelW

For mode 101h this is what one of my old test programs returns:

VBE version = 0200h
Modes supported by this VBE implementation (hex):
0100    0101    0102    0103    0110    0111    0112    0113    0114    0115
010A
mode = 0101h
Mode is supported by the hardware configuration
BIOS TTY output functions are NOT supported
Mode is color
Mode is graphics
Mode is VGA compatible
Mode supports banking of the frame buffer
Mode does NOT support double scanning
Mode does NOT support interlaced operation
Mode does NOT support hardware triple buffering
Host memory window A is relocatable
Host memory window A is readable
Host memory window A is writeable
Host memory window B is NOT relocatable
Host memory window B is NOT readable
Host memory window B is NOT writeable
Frame buffer memory granularity = 64KB
Host memory window size = 64KB
Host memory window A segment = A000h
Host memory window B segment = 0000h
Banking function offset = 7153h
Banking function segment = C000h
Bytes per scan line = 640
X resolution = 640
Y resolution = 480
X character size = 8
Y character size = 16
Number of planes = 1
Bits per pixel = 8
Number of banks = 1
Memory model type = Packed pixel
Bank size in KB = 0
Number of image pages = 50
Red mask size = 0
Red field position = 0
Green mask size = 0
Green field position = 0
Blue mask size = 0
Blue field position = 0
Reserved mask size = 0
Reserved mask position = 0
Direct color mode info = 0


640*480*8bpp = 307200 bytes, so obviously the entire screen will not fit in the 64KB host memory window. Where in your code are you controlling the banking?
Well Microsoft, here's another nice mess you've gotten us into.

Gunther

Andy,

Michael is right. You should check my VESA source; it's an example for bank switching.

Gunther
You have to know the facts before you can distort them.

Magnum

I will check out the source.

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

Magnum

Vladislav Kaipetsky and Tenie Remmel wrote the code for life.asm.

I understand about 20% of the code, I have done very graphics programming.

I found something interesting with svga.exe.

I am using an AOC monitor with the laptop monitor turned off.

When I ran the program, I picked a mode (forgot which one) and the screen went black and then on to a BSOD.

Maybe it could not detect which Vesa modes that the external monitor could do ?

Andy
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

FORTRANS

Hi,

   No, it is (probably) not that simple.  If you look at my reply to
Gunther in the PowerBASIC forum, when I tested a desktop, the
monitor could not support the highest resolution, but the program
did not misbehave.  Your computer with Windows may have a
problem using an external monitor using the VESA emulation.  Or
some such.

Steve N.

Magnum

I wondered why RBIL has so many listings for all the video cards.
Looks like the video card makers are like Linux.

Everyone is still doing their own thing.



The posted code looks good except that it assumes 640x480/8-bit to be
Mode 101 on all cards. Could be that your 1/4 result comes from a
640x480/32-bit mode, but it can be another resolution as well.

VESA-mode numbers unfortunately don't follow any standard.
Even different graphic-cards from one vendor may show up with apart
mode-set numbering. Also most non-VESA numbers (<0x0100) are Vendor-
specific (see RBIL INT10/00 Table 00010).
Mode 3 (the BIOS-default) seem to be the only reliable.

The only way to get/set desired resolutions by VESA-numbers is to
check on supported modes (INT10/4F01) and list what's of interest.

Of course you can also try to get info from your graphic-card Vendor,
even this may than work only correct on your and equal machines.
__
wolfgang
Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

FORTRANS

Hi,

   It should be noted that Wolfgang responded to your posting
in comp.lang.asm.x86..  Where you posted the FIRE.COM ASM
source, modified to set Mode 101H rather than Mode 13H.  And
you said.

QuoteI am trying to get this 16 bit code to display in Vesa Mode 101.

It assembles O.K., but the fire is only on the top 1/4 of the screen.

   Now I am attaching a modified FIRE.COM.  I have added (a whole
bunch of) code to change VESA video pages/banks (and some debug
code).  Here is most of the relevant changes.

   First, code to change banks (there are 4.68+ banks in Mode 101H).
I used to need the granularity stuff for an old video card.  It is now
commented out.

; - - - Setup103 - - -
VESA_ERR DB     'Failed to set VESA mode.',13,10,'$'

CurPage DW      0               ; Current 64k page in VESA Window SRN
PageGran DW     0               ; Granularity factor for window   SRN
TrueSize DW     0               ; Size of true color pixel in bytes SRN

SetPageNum  DW  0
VidMode         EQU     101H

; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; DX = Implied segment / 64k bank
; 14 August 2001
        PUBLIC  SetPage
SETPAGE PROC    NEAR

        PUSH    BX      ; Save BX pointer within bank

        MOV     [CurPage],DX
;;        MOV     AX,[PageGran]
;;        MUL     DX      ; definitely implies we don't need to clear elsewhere
;;        MOV     DX,AX
        MOV     AX,4F05H ; VESA change bank
        MOV     BX,0
        INT     10H
;        CMP     AX,4FH          ; AL = 4FH, AH = 0 for success
;        JNZ     SET101

        POP     BX

        RET

SETPAGE ENDP


   Then some code to actually swap banks inserted into the source.


MainLoop:   push fs
            push gs              ;DS = frame 1
            pop es                ;ES = frame 2
            pop ds               ;ES = frame 2
        INC     [SetPageNum]
        AND     [SetPageNum],3
        MOV     DX,[SetPageNum]
        CALL SetPage
            mov si, 321              ;SI = ( 1, 1), DI = (1, 0)


   That should duplicate the fire effect in each of the first four banks.
Assuming your video card is compatible with mine.

   Converting from the 320 x 200 Mode 13H coordinates to the
640 x 480 coordinates of Mode 101H is the hard part.  I am
working on converting a star field program that I posted earlier.
And it is taking much longer than I thought it would take.

Regards,

Steve N.

Gunther

Hi Andy,

Quote from: Magnum on August 18, 2013, 11:16:47 PM
Everyone is still doing their own thing.

of course, and that was announced in 1998. Here's a quote from the VBE 3.0 specification (VESA BIOS EXTENSION (VBE)
Core Functions, Standard, Version: 3.0, Date: September 16, 1998), p. 19:
Quote
Starting with VBE version 2.0, VESA will no longer define new VESA mode numbers and it will no longer be mandatory to support these old mode numbers. OEM's who wish to add new VBE mode numbers to their implementations, must make sure that all new modes are defined with mode numbers above 0x100, However, it is highly recommended that BIOS implementations continue to support these mode numbers for compatibility with older software and add new mode numbers after the last VESA defined mode number. VBE 2.0-aware applications should follow the guidelines in Appendix 5 -
Application Programming Considerations - for setting a desired mode.

Therefore, your application has to check the available VESA modes during runtime. That's the trick.

Gunther
You have to know the facts before you can distort them.

MichaelW

Andy,

The early SVGA adapters were all over the place. The VBE standard was developed by the industry to correct the problem. It defines a set of extensions to the VGA BIOS that you can use to determine which standard modes are supported and what the characteristics of the modes are. If you don't have or can't get the standard you should be able to determine at least most of what you need from RBIL.

Well Microsoft, here's another nice mess you've gotten us into.

dedndave

even before the IBM EGA, they were all over the place
fortunately, many of those old cards are no longer in use
i had one that would support most EGA modes, and hi-res text if you had an NEC multi-sync monitor (i still have a few of those monitors - lol)

the big issue, back then, was variations in the chip-sets
there were a half-dozen or so chip-sets in wide use, and some paged a little differently