flat assembler
Message board for the users of flat assembler.

Index > Windows > 17 Byte DOS Demo by Bitshifter for 16bitless people !

Author
Thread Post new topic Reply to topic
Alphonso



Joined: 16 Jan 2007
Posts: 295
Alphonso 05 Sep 2008, 20:19
Well since neville went to the trouble of writing a FRM version, here's a windows simulation of bitshifter's 17 byte DOS demo.
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Demonstrates what bitshifters 17 byte .com demo looks;
;like in windows for people who cant run 16bits.      ;
;                                                     ;
;Very basic, no error handling and maybe some mistakes;
;Alt F4 or left mouse click on window to exit.        ;
;V2 7/9/08                                            ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

format PE GUI 4.0
include 'win32ax.inc'

Stretch=1     ;1=Normal (320x200), 2=x2 (shown on 640x400)

.code

start:
        invoke  GetSystemMetrics,SM_CXFULLSCREEN
        sub     eax,320*Stretch
        shr     eax,1
        mov     [Xofs],eax

        invoke  GetSystemMetrics,SM_CYFULLSCREEN
        sub     eax,200*Stretch
        shr     eax,1
        mov     [Yofs],eax

        invoke  GetModuleHandle,0
        mov     [hinstance],eax
        invoke  LoadIcon,0,IDI_APPLICATION
        mov     [wc.hIcon],eax
        invoke  LoadCursor,0,IDC_ARROW
        mov     [wc.hCursor],eax
        mov     eax,[hinstance]
        mov     [wc.hInstance],eax
        invoke  RegisterClass,wc

        invoke  CreateDIBSection,0,BmPinfo,0,BitValues,0,0
        mov     [hBmP],eax

if Stretch=1
        invoke  CreateWindowEx,WS_EX_TOPMOST,_class,_title,WS_BORDER+WS_POPUP,[Xofs],[Yofs],320,200,NULL,NULL,[hinstance],NULL
else
        invoke  CreateWindowEx,WS_EX_TOPMOST,_class,_title,WS_BORDER+WS_POPUP,[Xofs],[Yofs],640,400,NULL,NULL,[hinstance],NULL
end if
        mov     [mainhwnd],eax

        invoke  CreateCompatibleDC,0
        mov     [hdcMem],eax
        invoke  SelectObject,[hdcMem],[hBmP]
        mov     [hbmOld],eax

        invoke  ShowWindow,[mainhwnd],SW_SHOWNORMAL
        invoke  UpdateWindow,[mainhwnd]

        invoke  SetTimer,[mainhwnd],1,10,TimerProc
        mov     [hTimer1],eax

msg_loop:
        invoke  GetMessage,msg,NULL,0,0
        or      eax,eax
        jz      end_loop
        invoke  TranslateMessage,msg
        invoke  DispatchMessage,msg
        jmp     msg_loop

end_loop:
        invoke  KillTimer,[mainhwnd],[hTimer1]
        invoke  SelectObject,[hdcMem],[hbmOld]
        invoke  DeleteObject,[hbmMem]
        invoke  DeleteDC,[hdcMem]
        invoke  ExitProcess,[msg.wParam]
;------------------------------------------------
proc WindowProc, hwnd,wmsg,wparam,lparam
        push    ebx esi edi
        cmp     [wmsg],WM_DESTROY
        je      wmdestroy
        cmp     [wmsg],WM_PAINT
        je      PaintP
        cmp     [wmsg],WM_LBUTTONDOWN
        je      wmdestroy
        cmp     [wmsg],WM_ERASEBKGND
        jne     @f
        mov     eax,1
        jmp     finish
  @@:
  defwndproc:
        invoke  DefWindowProc,[hwnd],[wmsg],[wparam],[lparam]
        jmp     finish

  PaintP:
        invoke  BeginPaint,[hwnd],PaintS
        mov     [hDC],eax
  if Stretch=1
        invoke  BitBlt,[hDC],0,0,320,200,[hdcMem],0,0,SRCCOPY
  else
        invoke  StretchBlt,[hDC],0,0,640,400,[hdcMem],0,0,320,200,SRCCOPY
  end if
        invoke  EndPaint,[hwnd],PaintS
        mov     eax,1
        jmp     finish

  wmdestroy:
        invoke  PostQuitMessage,0
        xor     eax,eax

  finish:
        pop     edi esi ebx
        ret
endp

;------------------------------------------------
proc    TimerProc hwnd,tmsg,event,dtime
        push    ebx esi edi
        mov     eax,[lax]
        mov     edi,[BitValues]
        mov     ecx,10000h                          ;32bit uses ecx so need this to limit to 64k
paint:  adc     ax,cx                               ;bitshifter's 17 byte main routine
        stosb                                       ;
        loop    paint                               ;one full screen,
        inc     ax                                  ;try "add ax,20" here instead for faster effect
        mov     [lax],eax                           ;save for next run
        invoke  InvalidateRect,[mainhwnd],0,0       ;then plot and give other processes a timeslice
        xor     eax,eax
        pop     edi esi ebx
        ret
endp
;------------------------------------------------
.data
  mainhwnd           dd ?
  hinstance          dd ?
  hDC                dd ?
  hbmMem             dd ?
  hdcMem             dd ?
  hbmOld             dd ?
  BitValues          dd ?
  hTimer1            dd ?
  lax                dd 013h                                                                    ;What int 10h leaves us with
  Xofs               dd ?
  Yofs               dd ?
  hBmP               dd ?
  _title             db '17Bytes',0                                                              ;Window Title
  _class             db 'Mode13',0                                                               ;Window Class
align 4

  msg                MSG
  wc                 WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,7,NULL,_class
  PaintS             PAINTSTRUCT
  BmPinfo:
  BmP                BITMAPINFOHEADER bsize,320,200,1,8,BI_RGB,0,1,1,0,0
  bsize=$-BmP
  RGBq               dd       0h,0a80000h,  0a800h,0a8a800h,    0a8h,0a800a8h,   54a8h,0a8a8a8h  ;Mode13 Palette
                     dd  545454h,0fc5454h, 54fc54h,0fcfc54h, 5454fch,0fc54fch, 54fcfch,0fcfcfch
                     dd       0h, 141414h, 202020h, 2c2c2ch, 383838h, 444444h, 505050h, 606060h
                     dd  707070h, 808080h, 909090h,0a0a0a0h,0b4b4b4h,0c8c8c8h,0e0e0e0h,0fcfcfch
                     dd 0fc0000h,0fc0040h,0fc007ch,0fc00bch,0fc00fch,0bc00fch, 7c00fch, 4000fch
                     dd     0fch,   40fch,   7cfch,  0bcfch,  0fcfch,  0fcbch,  0fc7ch,  0fc40h
                     dd   0fc00h, 40fc00h, 7cfc00h,0bcfc00h,0fcfc00h,0fcbc00h,0fc7c00h,0fc4000h
                     dd 0fc7c7ch,0fc7c9ch,0fc7cbch,0fc7cdch,0fc7cfch,0dc7cfch,0bc7cfch, 9c7cfch
                     dd  7c7cfch, 7c9cfch, 7cbcfch, 7cdc7ch, 7cfcfch, 7cfcdch, 7cfcbch, 7cfc9ch
                     dd  7cfc7ch, 9cfc7ch,0bcfc7ch,0dcfc7ch,0fcfc7ch,0fcdc7ch,0fcbc7ch,0fc9c7ch
                     dd 0fcb4b4h,0fcb4c4h,0fcb4d8h,0fcb4e8h,0fcb4fch,0e8b4fch,0d8b4fch,0c4b4fch
                     dd 0b4b4fch,0b4c4fch,0b4d8fch,0b4e8fch,0b4fcfch,0b4fce8h,0b4fcd8h,0b4fcc4h
                     dd 0b4fcb4h,0b4fcc4h,0d8fcb4h,0e8fcb4h,0fcfcb4h,0fce8b4h,0fcd8b4h,0fcc4b4h
                     dd  700000h, 70001ch, 700038h, 700054h, 700070h, 540070h, 380070h, 1c0070h
                     dd      70h,   1c70h,   3870h,   5470h,   7070h,   7054h,   7038h,   701ch
                     dd    7000h, 1c7000h, 387000h, 547000h, 707000h, 705400h, 703800h, 701c00h  ;must be an easier way !
                     rd 80h                                                                      ;To be filled in...
.end start    
I'm sure there's probably some mistakes there or a better way of doing things, please let me know.


Last edited by Alphonso on 06 Sep 2008, 17:19; edited 1 time in total
Post 05 Sep 2008, 20:19
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4354
Location: Now
edfed 06 Sep 2008, 09:12
it crashes under windows98

page fault:
ALPHONSOWIN a causé une défaillance de page dans
le module ALPHONSOWIN.EXE à 015f:00401250.
Registres :
EAX=0000ffff CS=015f EIP=00401250 EFLGS=00010286
EBX=0053fd74 SS=0167 ESP=0053fd0c EBP=0053fd18
ECX=c13f0000 DS=0167 ESI=00008db4 FS=5257
EDX=0001dce4 ES=0167 EDI=83839000 GS=0000
Octets à CS : EIP :
aa e2 fa 66 40 a3 20 20 40 00 6a 00 6a 00 ff 35
État de la pile :
00400000 00008db4 0053fd74 0053fd58 bff72317 00000bec 00000113 00000001 0223fb4e 39478d78 202c3947 8dd48de0 00030007 00401238 01477678 0053ff68
Post 06 Sep 2008, 09:12
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4227
Location: vpcmpistri
bitRAKE 06 Sep 2008, 12:39
How are you setting the pallete? Does it require 8-bit color desktop?

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 06 Sep 2008, 12:39
View user's profile Send private message Visit poster's website Reply with quote
Alphonso



Joined: 16 Jan 2007
Posts: 295
Alphonso 06 Sep 2008, 17:37
Thanks for the feedback edfed. I made some pretty silly mistakes there, how it worked on my w2k I don't know, it shouldn't have. Have edited it accordingly.

The reason I think it crashed was because I was using loop with cx and not taking into account it should be 32bit (ecx). Duh!. Plus trying to tidy it up at the last moment left some text data inside the bitmap structure, sigh!, and other errors.

bitrake, AFAIK it should be a 'device independant bitmap' and not tied to the system color depth. The pallete information is the RGB data in the bitmap structure. It's supposed to be the same colors as mode13 pallette although I gave up typing them in half way.

It's not very interesting putting them in manually . Sad
Post 06 Sep 2008, 17:37
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4354
Location: Now
edfed 06 Sep 2008, 19:28
yesss

very good stuff Alphonso, but vs the 17 bytes from bitshifter, it is ridiculous.

3584 bytes
Post 06 Sep 2008, 19:28
View user's profile Send private message Visit poster's website Reply with quote
bitshifter



Joined: 04 Dec 2007
Posts: 796
Location: Massachusetts, USA
bitshifter 18 Sep 2008, 02:28
What have i started here Question
Post 18 Sep 2008, 02:28
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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 vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.