Announcement

Collapse
No announcement yet.

Easy Screen 13 support for PB/DOS?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Easy Screen 13 support for PB/DOS?

    I need a simple, easy to use MODE 13/MODE x library routine for use in
    one of my programs. Unfortunately, no routines thus far can adequately and easily
    simulate GET and PUT routines from QBasic. Any ideas?

    The GET and PUT formats I speak of are:

    GET (0,0)-(xxx,yyy),object%

    and

    PUT (0,0)-(xxx,yyy),object%,PSET

    (can also use XOR, OR and AND)

    A few other commands necessary would be LINE and SCREEN 13.

    I've tried out many of the programs in the PB Pub area, but they all
    use assembly and/or are extremely difficult to follow.

    Regards,

    Paul
    [email protected]

    ------------------
    Few cats act their age, while
    most just cough up furballs.
    Few cats act their age, while
    most just cough up furballs.

    #2
    If you are refering to mode 13h 320x240x256. I would use asm
    object file. There is basic code to do this at www.angelfire.com\mo\isswgaryr\index.html link -> MY PROGRAMS
    at the bottem of the page "chelpbas.zip.
    The .obj files are there w/ code and it tells you how it works.
    Let me know if it work for you.

    Gary Russell

    ------------------


    [This message has been edited by Gary Russell (edited September 05, 2001).]

    Comment


      #3
      Hey Gary I'll try it out this afternoon. What I am attempting to do is
      load in a certain sprite format (Tsugumo's JSprite) which uses a 256 color palette.
      It runs under Screen mode 13.

      For more information on the game I am working on, please visit:
      http://www.geocities.com/dunric/orbit.html

      Every picture is composed of small sprites.

      Regards,

      Dunric
      [email protected]


      ------------------
      Few cats act their age, while
      most just cough up furballs.
      Few cats act their age, while
      most just cough up furballs.

      Comment


        #4
        SCREEN 13 is by far the simplest graphics mode to work with. Each pixel
        is represented by exactly one byte, which is the color (0-255) at that
        location. Addressing begins at, let's see, segment &HB800, offset 0, if
        I recall correctly. You can create GET/PUT routines with simple PEEK
        and POKE sequences.


        ------------------
        Tom Hanlin
        PowerBASIC Staff

        Comment


          #5
          Hey Tom,

          Is there an example for PEEKing and POKEing the sprite into memory and then onto the screen?

          I am assuming you mean something like the old Commodore 64 days, i.e.:

          POKE 0, PEEK(&HB800)

          ??

          I just need something that emulates:

          PUT (xx,yy),sprite%,PSET (or XOR or PRESET or OR or AND)

          Something very easy to use and that, with Console Tools Plus Graphics, can be
          modified to work in a Windows PB/CC Console Mode with overlay Graphics program.

          Regards,

          Paul
          [email protected] http://www.geocities.com/dunric/orbit.html

          P.S. Not that the old C64 days were any easier. It was something like:

          V=53248:POKE 2040, 13:POKE V+16,7:POKE V+37,1:POKE V+38,15:POKE V+39,9
          FOR X=832 TO 895: READ A:POKE X,A:NEXT X
          POKE V+0,100:POKE V+1,100
          DATA 128,64,45,18,12,17,0,0
          DATA 162,218,15,0,28,19,0,128
          DATA 151,155,100,98,105,0,2,63
          DATA 127,199,106,64,63,62,0,3
          ...
          blah blah blah

          The C128 was better, but not by much:

          SCNCLR:GRAPHIC CLR
          FOR A=3584 to 3646:READ X:POKE A,X:NEXT A
          SPRITE 1,1,1,.,1,1,.
          MOVSPR 1,100,100 #2
          DATA 128,64,45,18,12,17,0,0
          DATA 162,218,15,0,28,19,0,128
          DATA 151,155,100,98,105,0,2,63
          DATA 127,199,106,64,63,62,0,3
          ...


          ------------------
          Few cats act their age, while
          most just cough up furballs.
          Few cats act their age, while
          most just cough up furballs.

          Comment


            #6
            Now, DOS graphics and Windows graphics are entirely different issues.
            You may be able to build high-level routines that function similarly,
            but the actual graphics handling is another matter. I am not familiar
            with how you'd approach something like this with Graphics Tools. You
            would be well advised to look into it before considering your design.

            As far as SCREEN 13 is concerned, each pixel is one byte. The display
            is 320x200 (columns x rows), so the address of each pixel can be simply
            enough calculated:

            offset = row * 320 + column

            ...where rows run 0-199 and columns, 0-319. Your segment is always
            going to be the same, &HA000 (not &HB800, that's for CGA: my mistake,
            it's been a long time). So, for example, to set (33,10) to color
            12, you'd:

            DEF SEG=&HA000
            POKE 10*320+33,12

            In the case of a "sprite", you're presumably dealing with multiple rows
            and columns. You can take advantage of the fact that columns are adjacent
            by using PEEK$ and POKE$ to deal with an entire row at a time.

            PSET and PRESET are interchangeable: you just POKE the data directly to
            the screen. For AND, OR, and XOR functionality, you first need to PEEK
            the existing data, do the AND/OR/XOR with your sprite data, and POKE the
            result to the screen.

            ------------------
            Tom Hanlin
            PowerBASIC Staff

            Comment


              #7
              Hey tom,

              I tried using your example with my code:

              REM ************************************************************************
              cls
              Modus13
              DIM earth%(673)
              CLOSE 1: OPEN "earth.spr" FOR INPUT AS #1: INPUT #1, a, b: INPUT #1, ArSize: FOR load = 0 TO ArSize: INPUT #1, earth%(load)
              for y=1 to a:for z=1 to b
              DEF SEG=&HA000
              poke y*320+z,earth%(load)
              NEXT:NEXT
              NEXT: CLOSE #1
              'DEF SEG=&HA000
              'poke 10*320+33,12
              end
              REM ************************************************************************

              SUB Modus13
              ! mov ax, &h0013
              ! int &h10
              END SUB

              But it failed to work. What am I doing wrong?

              Paul
              [email protected]

              ------------------
              Few cats act their age, while
              most just cough up furballs.
              Few cats act their age, while
              most just cough up furballs.

              Comment


                #8
                Hey Tom,

                Well, here is what I've got thus far:

                CLS
                ! mov ax, &h0013
                ! int &h10
                rem screen 13
                FOR x = 1 TO 10: FOR y = 1 TO 10
                READ data1(x, y)
                DEF SEG=&HA000:Poke x*320+y, data1(x, y)
                NEXT: NEXT
                sleep 2
                FOR x=1 to 10:for y=1 to 10
                read data1(x,y)
                def seg=&HA000 oke x*320+y,data1(x,y)
                NEXT:NEXT
                sleep 2
                end
                REM small earth data
                '10x10
                DATA 0,0,2,2,2,54,54,10,0,0
                DATA 0,54,2,2,2,2,10,2,2,0
                DATA 54,54,54,2,2,2,2,2,54,54
                DATA 54,54,54,10,2,2,2,2,54,54
                DATA 54,54,54,54,2,2,2,54,2,54
                DATA 54,54,54,54,54,2,10,2,54,54
                DATA 0,54,54,54,54,54,2,10,2,0
                DATA 0,0,54,54,54,54,54,54,0,0
                DATA 0,0,0,0,0,0,0,0,0,0
                DATA 0,0,0,0,0,0,0,0,0,0
                REM small moon data
                '10x10
                DATA 0,0,7,7,7,7,7,0,0,0
                DATA 0,7,0,8,7,8,8,7,0,0
                DATA 7,7,8,7,7,0,0,8,8,0
                DATA 7,7,7,7,7,0,0,8,8,0
                DATA 8,7,7,7,7,8,8,7,8,0
                DATA 0,8,7,0,8,7,7,8,0,0
                DATA 0,0,8,8,8,8,8,0,0,0
                DATA 0,0,0,0,0,0,0,0,0,0
                DATA 0,0,0,0,0,0,0,0,0,0
                DATA 0,0,0,0,0,0,0,0,0,0
                REM ship (red) data
                '8x8
                DATA 0,0,0,0,0,0,0,0
                DATA 0,0,0,0,0,0,40,0
                DATA 0,0,0,0,0,40,12,0
                DATA 40,12,12,12,12,12,12,0
                DATA 0,0,0,0,0,40,0,0
                DATA 0,0,0,0,0,0,0,0
                DATA 0,0,0,0,0,0,0,0
                DATA 0,0,0,0,0,0,0,0
                REM ship (green) data
                '8x8
                DATA 0,0,0,0,0,0,0,0
                DATA 0,0,0,0,0,0,2,0
                DATA 0,0,0,0,0,2,10,0
                DATA 2,10,10,10,10,10,10,0
                DATA 0,0,0,0,0,2,0,0
                DATA 0,0,0,0,0,0,0,0
                DATA 0,0,0,0,0,0,0,0
                DATA 0,0,0,0,0,0,0,0
                REM small yansah
                '10x10
                DATA 0,0,119,2,10,10,2,0,0,0
                DATA 0,2,10,10,10,10,10,2,0,0
                DATA 119,2,2,2,119,119,2,10,2,0
                DATA 119,119,119,119,119,119,2,10,10,0
                DATA 119,119,2,2,119,119,119,10,10,0
                DATA 119,2,10,119,119,119,119,10,10,0
                DATA 2,10,10,119,119,2,10,10,2,0
                DATA 0,10,10,10,119,119,2,2,0,0
                DATA 0,0,10,10,2,119,119,0,0,0
                DATA 0,0,0,0,0,0,0,0,0,0
                REM small dakbar
                '10x10
                DATA 0,0,1,54,9,1,1,0,0,0
                DATA 0,54,9,9,9,9,1,1,0,0
                DATA 1,54,54,54,1,1,54,9,54,0
                DATA 1,1,1,1,1,1,54,9,9,0
                DATA 1,1,1,1,1,1,1,9,9,0
                DATA 1,54,1,1,1,1,1,9,9,0
                DATA 54,9,1,1,1,54,9,9,1,0
                DATA 0,9,9,1,1,1,54,54,0,0
                DATA 0,0,1,1,1,1,1,0,0,0
                DATA 0,0,0,0,0,0,0,0,0,0
                REM small laurasia
                '15x10
                DATA 0,0,43,43,43,13,13,13,13,43,43,43,43,0,0
                DATA 0,43,43,43,13,13,13,13,13,43,43,43,43,13,0
                DATA 43,43,43,43,13,13,13,13,43,43,13,43,43,43,13
                DATA 13,13,43,43,13,13,13,13,43,43,43,13,13,43,43
                DATA 13,13,13,13,13,13,13,13,43,43,43,43,13,43,43
                DATA 13,13,13,13,13,13,13,13,13,43,43,43,13,43,43
                DATA 13,13,43,43,13,13,13,13,13,13,43,13,13,43,43
                DATA 13,43,43,43,13,13,13,13,13,13,13,13,43,13,43
                DATA 0,43,43,13,13,43,13,13,13,13,13,13,43,43,0
                DATA 0,0,43,43,43,43,13,13,13,13,13,13,13,0,0
                REM satellite
                '8x8
                DATA 7,8,0,0,0,8,7,0
                DATA 8,7,8,0,8,7,8,0
                DATA 0,8,15,15,15,8,0,0
                DATA 0,0,15,8,8,0,0,0
                DATA 0,8,15,15,15,8,0,0
                DATA 8,7,8,0,8,7,8,0
                DATA 7,8,9,9,9,8,7,0
                DATA 0,0,0,0,0,0,0,0
                REM blackhole
                '15x16
                DATA 0,0,7,7,8,115,115,115,115,115,115,115,8,7,0
                DATA 0,7,8,115,115,0,7,7,7,7,7,0,115,8,7
                DATA 0,7,8,115,0,7,8,8,8,8,8,7,115,8,7
                DATA 0,7,8,115,7,8,115,115,115,115,8,7,115,8,7
                DATA 0,7,8,115,7,8,115,7,7,115,8,7,115,8,7
                DATA 0,7,8,115,7,8,7,8,8,7,8,7,115,8,7
                DATA 0,7,8,115,7,8,7,8,8,7,8,7,115,8,7
                DATA 0,7,8,115,7,8,8,0,8,7,8,7,115,8,7
                DATA 0,7,8,115,7,8,8,8,7,115,8,7,115,8,7
                DATA 0,7,8,115,0,7,7,7,0,115,8,7,115,8,7
                DATA 0,7,8,115,115,115,115,115,115,115,8,7,115,8,7
                DATA 115,0,7,8,8,8,8,8,8,8,7,0,115,8,7
                DATA 8,115,0,7,7,7,7,7,7,7,0,0,115,8,7
                DATA 7,8,115,115,115,115,115,115,115,115,115,115,115,8,7
                DATA 0,7,8,8,8,8,8,8,8,8,8,8,8,7,0
                DATA 0,0,7,7,7,7,7,7,7,7,7,7,7,0,0
                REM starmap hole
                '16x16
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9
                DATA 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9
                REM

                Unfortunately, I can't seem to place the sprites anywhere
                but the first 1 col,1 row of the screen, otherwise it
                makes the sprites much larger and "dithers" them to a
                different size (viewing a page from up close to far away, and
                the little dots composed of light, etc)

                Any ideas?

                Regards,

                Paul
                [email protected]

                ------------------
                Few cats act their age, while
                most just cough up furballs.
                Few cats act their age, while
                most just cough up furballs.

                Comment


                  #9
                  "It doesn't work" is an inadequate description...! Details, please.

                  "mov ax, &h0013" moves 00 into AH, &H13 into AL: AH is the high register.
                  In context, this is "set mode 13" and is fine. Yes, QB's SCREEN 13 is the
                  same as BIOS screen mode &H13. It's likely that the "Modus13" SUB needs
                  to preserve some registers, though: time to dig into that Assembly Language
                  chapter!

                  The setting for DEF SEG sticks. You only need to set it once, unless
                  you change it somewhere else.

                  Dithering is a color manipulation technique which has nothing to do with
                  the size of an item...? If you're using an LCD monitor, you may be seeing
                  normal pixel approximation problems. An LCD has a fixed number of pixels,
                  and can only approximate some resolutions crudely.

                  Here, this bit of code puts the second image correctly near the center of
                  the display:

                  FOR x=1 to 10:for y=1 to 10
                  read data1(x,y)
                  def seg=&HA000
                  poke (x+99)*320+y+160,data1(x,y)
                  NEXT:NEXT

                  By the way, "x" is traditionally used for the column and "y" for the row...


                  ------------------
                  Tom Hanlin
                  PowerBASIC Staff

                  Comment


                    #10
                    As long as you don't mind some ASM routines that may not be 100%
                    intuitive or VERY easy to follow (such is the nature of ASM), I
                    might be able to post some code here that will do what you want.
                    Don't get me wrong, the USE of the routines would be very easy, but
                    by their nature, may not be as easy to follow as you'd like. Maybe
                    you'd prefer NO asm at all, but if you want fast graphics routines,
                    ASM is probably your best bet. I'm asking this because I'd hate to
                    waste time writing and posting code that would go disregarded based
                    on the use of ASM statements, which has happened in the past (and has
                    made me a little reluctant to bother responding as of late). If you
                    decide that ASM is ok, as long as the routines themselves are easy
                    to use, let me know, and I'll TRY to help, if I can.

                    ------------------

                    Comment


                      #11
                      Hey tom,

                      Thanks, that worked!

                      Paul


                      ------------------
                      Few cats act their age, while
                      most just cough up furballs.
                      Few cats act their age, while
                      most just cough up furballs.

                      Comment

                      Working...
                      X
                      😀
                      🥰
                      🤢
                      😎
                      😡
                      👍
                      👎