flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Embed COM Screen Saver as bootloader

Author
Thread Post new topic Reply to topic
h17



Joined: 05 Aug 2011
Posts: 1
h17
I have an old 16bit com screen saver I would like to embed as bootloader in MBR, but it needs some conversion. I think most of the code below is fine to run as bootloader except for a couple calls to int 21 for memory allocs at start

Where would be safe place to use for these memory blocks?

(following from disasm not my code)

Code:
             
[bits 16]
[org 100h]

             mov     bh, 10h
             mov     ah, 4Ah
             int     21h             ; DOS - 2+ - ADJUST MEMORY BLOCK SIZE (SETBLOCK)
                                    ; ES = segment address of block to change
                                   ; BX = new size in paragraphs
               mov     ah, 48h
             int     21h             ; DOS - 2+ - ALLOCATE MEMORY
                                        ; BX = number of 16-byte paragraphs desired
                 mov     gs, ax
              mov     bh, 20h
             mov     ah, 48h
             int     21h             ; DOS - 2+ - ALLOCATE MEMORY
                                        ; BX = number of 16-byte paragraphs desired
                 mov     fs, ax
              mov     es, ax
              mov     bp, 1DDh
            mov     cl, 0C8h
 loop1:
             xor     di, di
              mov     bx, 0FF60h

 near_top_loop1:
              mov     ax, cx
              sub     ax, 64h
             mov     [bp+3], ax
          mov     [bp+5], bx
          fild    word [bp+5]
                 fild    word [bp+3]
                 fld     st0
                 fmul    st0, st0
            fld     st2
                 fmul    st0, st0
            faddp   st1, st0
            fsqrt
               fidivr  word [bp+1]
                 fistp   word [es:di]
            fpatan
              fimul   word [bp+0]
                 fistp   word [es:di+1]
          inc     di
          inc     di
          inc     bx
          cmp     bx, 9Fh
             jle     near_top_loop1
              mov     ax, es
              add     ax, 28h
             mov     es, ax
              loop    loop1
 loop2:
                mov     al, cl
              xor     al, ch
              mov     bx, cx
              mov     [gs:bx], al
             loop    loop2
               mov     cl, 10h
 loop_3:

                 mov     al, [gs:bx]
             dec     bl
          add     al, [gs:bx]
             inc     bl
          inc     bh
          add     al, [gs:bx]
             sub     bh, 2
               add     al, [gs:bx]
             inc     bh
          shr     ax, 2
               mov     [gs:bx], al
             inc     bx
          jnz     loop_3
              loop    loop_3
              mov     al, 13h
             int     10h             ; - VIDEO -
                 push    0A000h
              pop     es
 loop4:
           mov     al, cl
              mov     dx, 3C8h
            out     dx, al
              inc     dx
          out     dx, al
              out     dx, al
              out     dx, al
              loop    loop4

 no_key:
           inc     bp
          mov     dl, 0DAh
 loc_101A4:
                 in      al, dx          ; Video status bits:
                                    ; 0: retrace.  1=display is in vert or horiz retrace.
                                   ; 1: 1=light pen is triggered; 0=armed
                                  ; 2: 1=light pen switch is open; 0=closed
                                       ; 3: 1=vertical sync pulse is occurring.
                test    al, 8
               jz      loc_101A4
 loc_101A9:
                in      al, dx          ; Video status bits:
                                    ; 0: retrace.  1=display is in vert or horiz retrace.
                                   ; 1: 1=light pen is triggered; 0=armed
                                  ; 2: 1=light pen switch is open; 0=closed
                                       ; 3: 1=vertical sync pulse is occurring.
                test    al, 8
               jnz     loc_101A9
           push    fs
          xor     di, di
              mov     cl, 0C8h
 loop5:
             xor     si, si
 loc_101B6:
           mov     bx, [fs:si]
             add     bx, bp
              mov     al, [gs:bx]
             stosb
               lodsw
               cmp     si, 280h
            jl      loc_101B6
           mov     ax, fs
              add     ax, 28h
             mov     fs, ax

          loop    loop5
               pop     fs

              mov     ah, 11h
             int     16h             ; KEYBOARD - CHECK ENHANCED KEYSTROKE                                                           ; Return: ZF clear if keystroke available
                                       ; AH = scan code \ meaningless if ZF = 1
                                   ; AL = character /
                                  ; ZF set if kbd buffer empty
                jz      short no_key
                mov     ax, 3
               int     10h             ; - VIDEO - SET VIDEO MODE
                                  ; AL = mode
                 retn

db 29h, 0, 0Ah, 0Ah, 
db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,
db 0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh,0FFh


Original:

B710B44ACD21B448CD218EE8B720B448CD218EE08EC0BDDD01B1C831FFBB
60FF89C82D6400894603895E05DF4605DF4603D9C0DCC8D9C2DCC8DEC1D9
FADE7E0126DF1DD9F3DE4E0026DF5D0147474381FB9F007ECB8CC0052800
8EC0E2BD88C830E889CB658807E2F5B110658A07FECB650207FEC3FEC765
020780EF02650207FEC7C1E8026588074375E0E2DEB013CD106800A00788
C8BAC803EE42EEEEEEE2F445B2DAECA80874FBECA80875FB0FA031FFB1C8
31F6648B1C01EB658A07AAAD81FE80027CF08CE00528008EE0E2E50FA1B4
11CD1674CAB80300CD10C329000A0AFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFF
    
Post 05 Aug 2011, 21:45
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
in boot, you cannot use int21h memalloc.
but it is not a problem since you don't need memalloc to generate a video effect.

then, instead of using dos, just use direct memory for video and buffers.

at boot, you can assume you have segments 1000h to 9000h free to use (don't care about the EBDA in 9000h segment for the moment).
then, you have 512 Kbytes to work with at boot.

this is largelly enough to generate a screen saver.
Post 05 Aug 2011, 23:49
View user's profile Send private message Visit poster's website 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.