Author Topic: help with fasm  (Read 12393 times)

0 Members and 1 Guest are viewing this topic.

xteraco

  • Guest
help with fasm
« on: June 16, 2006 »
could someone list all the vid modes in fasm?

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: help with fasm
« Reply #1 on: June 17, 2006 »
Hmm, not sure if I understand your question, but if you mean the VGA video mode, you can access this modes:

640×480 in 16 colors
640×350 in 16 colors
320×200 in 16 colors
320×200 in 256 colors (Mode 13h)

Mode 13h, it's probably one of the easiest modes to use.
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: help with fasm
« Reply #2 on: June 17, 2006 »
Isnt there documentation with Fasm? Where does one get hold of fasm, as im interested purely for the fact that FB uses asm.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

xteraco

  • Guest
Re: help with fasm
« Reply #3 on: June 17, 2006 »
you can get fasm here http://flatassembler.net/

it does come w/ documentation....  i was just wondering how i would go about doing an 800x600 screen with 256 colors in fasm

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: help with fasm
« Reply #4 on: June 17, 2006 »
Your question is a bit open ended really with many different answers depending on what you really want. Do you want to code it for Dos or Windows? Software rendering or Hardware rendering?  Do you want it to work on winxp machines etc.

I assume fasm still comes with includes for some stuff like it use to, there's probably a few examples of opening a window in them. It's been such a long time since I did any assembler and I think PC stuff is likely to be harder than the old 6502 I did on BBC model B's :)

xteraco

  • Guest
Re: help with fasm
« Reply #5 on: June 18, 2006 »
i'm wanting 800x600 256 colors, software rendered, and as portable as possible, meaining no directX

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: help with fasm
« Reply #6 on: June 18, 2006 »
Try Vesa graphics, here's an example that I found at fasm message board (don't remember the autor). I think that Vesa isn't compatible with all video cards, but you can do some tests and check if it's what you need. There's alot of information on the web about it. Here on my PC, only video mode that works are those below 640x480.

Code: [Select]
; Print Screen causes an immediate Hard Reset in case of vesa setmode BX=$13
_640x400x256=$100
_640x480x256=$101
_800x600x16=$102
_800x600x256=$103
_1024x768x16=$104
_1024x768x256=$105
_1280x1024x16=$106
_1280x1024x256=$107

_80x60t=$108
_132x25t=$109
_132x43t=$10A
_132x50t=$10B
_132x60t=$10C

;---VBE v1.2+ ---
_320x200x32k=$10D ;15bit 555
_320x200x64k=$10E ;16bit 565
_320x200x16m=$10F ;32bit 8888
_640x480x32k=$110 ;15bit 555
_640x480x64k=$111 ;16bit 565
_640x480x16m=$112 ;32bit 8888
_800x600x32k=$113 ;15bit 555
_800x600x64k=$114 ;16bit 565
_800x600x16m=$115 ;32bit 8888
_1024x768x32k=$116 ;15bit 555
_1024x768x64k=$117 ;16bit 565
_1024x768x16m=$118 ;32bit 8888
_1280x1024x32k=$119 ;15bit 1555
_1280x1024x64k=$11A ;16bit 565
_1280x1024x16m=$11B ;32bit 8888 not working
;---VBE 2.0+ ---
_1600x1200x256=$120 ;8bit
_1600x1200x32k=$121 ;15bit 555
_1600x1200x64k=$122 ;16bit 565

xmax=1279
ymax=1023

;xmax=639
;ymax=479

;colors=16777215

colors=65536
;colors=256

bitsperpixel=16

;bytesperline=xmax+1*bitsperpixel/8

org $100
push es
 push $a000
 pop es

mov bx,_640x480x64k;_1280x1024x64k;_640x480x16m;_640x480x256;_640x480x64k; ; $13 ; _320x200x64k; _1024x768x16m ;_800x600x16m
;bts bx,15 ; prevent video memory clearing in case of mode switch
call bsetvesamode

call initrandomz
 mainloop:

mov ecx,xmax+1
call randomz3
mov bx,ax

mov ecx,ymax+1
call randomz3
mov cx,ax

push ecx
mov ecx,colors
call randomz3
pop ecx

call vesaputpixel ; al=color, bx=x, cx=y , es=segment
;call waitvretrace

 push ax
 mov ah,11h
 int 16h  Â  ; have we pressed a key?,if no then loop
 pop ax
 jz mainloop

 pop es
 mov ax,3Â  Â  Â  Â ;back to text mode.
 int 10h

 mov ax,4c00h  ; exit with dos
 int 21h

bsetvesamode: ; bx=mode number
;cmp bx,$99
;jnb .vesamode
bt bx,8
jc .vesamode
mov ax,bx
jmp .int10h
.vesamode:
 mov ax,4f02h  ;set vesa 1.0 screen mode
 int 10h
 mov ax,4f05h  Â  ;vesa 1 window select
.int10h:
 xor bx,bx
 xor dx,dx  Â  Â  ; set bank 0
 int 10h  Â  Â  Â  ;dx is  the reqired bank
ret

bselectbank:
 mov ax,4f05h  Â  ;vesa 1 bank select
 xor bx,bx
 int 10h  Â  Â  Â  ;dx is  the reqired bank
ret

waitvretrace:
  Â  Â mov dx,3dah
.v1: in al,dx
  Â  Â and al,08h
  Â  Â jnz .v1
.v2: in al,dx
  Â  Â and al,08h
  Â  Â jz .v2
ret


initrandomz: ; modifies edx, eax
rdtsc
ret

randomz3: ; Z3 ecx=range transparent
push ebx  ; number returned is: ]0,ecx]
push edx
mov ebx,eax
rdtsc

mov dx,cx

mov cl,al
xor cl,ah
ror ch,4
xor bl,ch
and cx,$f
rol bx,cl
btc bx,cx
xor bx,ax
ror eax,16
xor bx,ax
ror eax,16
mov cl,al
xor cl,ah
ror ch,4
xor bl,ch
and cx,$f
ror bx,cl
btc bx,cx

mov cl,bl
.minorloop:
rol eax,cl
and cx,$f
btc ax,cx
loopw .minorloop
mov cl,bh
.majorloop:
ror eax,cl
and cl,$f
btc ax,cx
loopw .majorloop
mov cx,dx

mul ecx
mov eax,edx
pop edx
pop ebx
ret

vesaputpixel: ; es=destination segment al=color, bx=x, cx=y , es=segment
push eax
movzx eax,cx
mov ecx,xmax+1
mul ecx
movzx ebx,bx
add eax,ebx
movzx ecx,byte [constant_bitsperpixel]
shr cx,3
mul ecx
mov di,ax
shr eax,16
mov dx,ax
cmp dx,[currentbank]
je nobank
mov [currentbank],dx
 mov ax,4f05h  Â  ;vesa 1 bank select
 xor bx,bx
 int 10h  Â  Â  Â  ;dx is  the required window
nobank:
 pop eax

cmp byte [constant_bitsperpixel],32
jne n32
mov [es:di],eax
jmp putten
n32:
cmp byte [constant_bitsperpixel],24
jne n24
mov [es:di],al
inc di
or di,di
jnz .nobank
inc dx
mov [currentbank],dx
 push eax
 mov ax,4f05h  Â  ;vesa 1 bank select
 xor bx,bx
 int 10h  Â  Â  Â  ;dx is  the required window
 pop eax
.nobank:
shr eax,8
mov [es:di],ax
jmp putten
n24:
cmp byte [constant_bitsperpixel],16
jne n16
mov [es:di],ax
jmp putten
n16:
mov [es:di],al
putten:
ret
currentbank dw 0
constant_bitsperpixel db bitsperpixel
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: help with fasm
« Reply #7 on: June 29, 2006 »
Ralph Brown's Interrupt List is the bible for all the interrupt calls http://www.ctyme.com/rbrown.htm.  Seems to be some missing images right now, but scroll down for the details.
For instance here http://www.ctyme.com/intr/rb-0069.htm is the set video mode page.

Another blast from the past HelpPC http://heim.ifi.uio.no/~stanisls/helppc/

Jim
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: help with fasm
« Reply #8 on: June 29, 2006 »
There's a pretty bad problem with that vesa code there that means it won't work properly for everyone.
It assumes that to move down vertically 1 scanline you have to add on screen_width x bytes_per_pixel.
While that's correct for a lot of modes, it's not always right.  Sometimes, the card will allocate extra bytes at the end of the scanline that are just wasted and invisible, usually for alignment reasons. eg. on 800x600x16bpp, that would be 1600bytes per scanline, but multiplying by 1600 is difficult so the card might allocate 2048 bytes per scanline instead, wasting 448 bytes.  2048 is 1 Shl 11 which is simple to calculate.
In VESA1 it can be hard to know when this is happening.
Funnily enough the PSP uses this trick, to the programmer the screen is 512 wide, 2 or 4bytes per pixel, even though the LCD is only 480 pixels across.

Another problem is after the early mode numbers, there's no real standards, so for one person 120h might be 1600x1200x16 and for another it might be 320x200x24!
Newer versions of VESA offer ways round these problems, for instance by providing calls for interrogating the card for which modes it can do.  That can amount to a lot of work.

I reckon this code should do high colour 640x480 for most people though.

Jim
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17426
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: help with fasm
« Reply #9 on: June 29, 2006 »
Interesting stuff. It just goes to show the anarchic nature of PC hardware development back a few years ago that some of these screen modes won't work the same on all cards. Mind you, I suppose that not that many people develop in pure asm these days and that modern cards are more compatible with each other.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
Re: help with fasm
« Reply #10 on: June 29, 2006 »
Actually Modern cards are not really that compatible with older vesa stuff more due to them not really supporting dos modes, I recall reading somewhere that some cards actually emulate 2d drawing via the 3d chipset and dont really have any real 2d drawing at all, not sure if thats true but it wouldn't suprize me. Infact alot of cards now do not officially support screen modes below 640*480. This X1300 I have hates anything below 640*480 with a passion, either completely failing to display it or doing a really bad job of it, even if it's a windows/ogl or directx based program. I suspect in a few years even 640*480 will be considered archaic, just look at the crazy res's people run there desktop at nowadays  ;)

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: help with fasm
« Reply #11 on: August 31, 2006 »
Tin,

can you define "really hates"? I have an x1300 and it runs old dos 32byte and 16byte intros really well.
Im wondering if you have some driver setting thats killing 320x200 mode?
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: help with fasm
« Reply #12 on: August 31, 2006 »
He's right - some card manufacturers definitely removed 320 modes, mode X and or VESA support.  Maybe some of them have been persuaded to put it all back in?  Maybe these are the ones that went out of business?!
There is definitely a setting in WindowsXP that disables lots of modes below 800x600.  DirectX can be shy about enumerating 320 modes too.

Jim
Challenge Trophies Won:

Offline yetifoot

  • ZX 81
  • *
  • Posts: 3
  • Karma: 0
    • View Profile
Re: help with fasm
« Reply #13 on: September 16, 2006 »
I have an nvidia card, and that doesn't like vesa, old dos games won't work.  I use programs like vbeplus to get round this though, and now i can play most old dos games OK.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17426
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: help with fasm
« Reply #14 on: September 16, 2006 »
I don't understand why card manufacturers would remove compatibility though. It's not like the technology needs developing, the technology is already there and these guys need to know that some people love playing the old Vesa games. I have had a whole heap of trouble just trying to get Xcom enemy unknown to work on XP. I gave up in the end.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: help with fasm
« Reply #15 on: September 16, 2006 »
I'm really thinking of looking into Fasm this weekend. Thanks for the great resource links etc.

Cheers,
Clyde.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: help with fasm
« Reply #16 on: September 19, 2006 »
Hehehe. Im stuck on just the early stuff, like the commands that are used.
Haven't found much for beginners at the fasm message board.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17426
  • Karma: 499
  • evil/good
    • View Profile
    • My Homepage
Re: help with fasm
« Reply #17 on: September 20, 2006 »
It will click, don't worry.
Remember that all you need to think about doing at first is just to open a screen that exits when you press escape and to be able to plot a pixel anywhere you want in any colour you want and then you'll be up and away.
Shockwave ^ Codigos
Challenge Trophies Won: