Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting the SCREEN mode
#21
(09-30-2022, 04:21 PM)mnrvovrfc Wrote:
(09-30-2022, 03:15 AM)mnrvovrfc Wrote: For a site called "QB64 Game Programming" it might be better to make a recommendation to use "_NEWIMAGE" instead of "SCREEN" for new programs. "SCREEN" prevails, though for a generic tutorial which must accept importing programs from M$QB or QBasic. ...
While I wrote this I failed to notice "SCREEN" statement was needed anyway combined with "_NEWIMAGE". I was unable to remember "_NEWIMAGE()" is a function, can't do stuff itself that "SCREEN" does! I'm sorry about that.

If there are people typing in programs from old books, meant for QuickBASIC then they must be running DOSBOX, or actually be on a computer old enough to support 16-bit, pre-Windows8. Less likely they would be doing it on QB64. It's because otherwise they would be whining, "Damn it SCREEN 13 is wee too small! How do I make it larger?" LOL why make it larger, so you could appreciate the rough resolution?  Tongue  This is before the hogs, of the many-inches television screens used as computer viewports, come into mind. In the music-creation world there is a lot of pathetic complaining about too-small GUI's out of programs created in decade-2000. They want to get out of 32-bit so much.

Somebody is going to ask to convert a GUI program done in VBDOS to QB64PE. Then expect it to run on Linux without Wine. Do it yourself bruv!

This "rant" wasn't aimed at anybody in particular.

Why would they need DOSBox? They can simply type the code into QB64 and it will run just fine. Remember, QB64 is nearly 100% compatible with all code written for GWBASIC (line numbers) and QuickBasic. No old computer or DOSBox needed.

And as far as making SCREEN 13 bigger, easy peasy:

SCREEN13& = _NEWIMAGE(320,200,13) ' Work Screen
SCREEN _NEWIMAGE(1024,800,32) ' Graphics Screen
_DEST SCREEN13& ' Switch to work screen
' Draw your graphics and such
_DEST 0 ' Switch to graphics screen
_PUTIMAGE ,SCREEN13& ' Map work screen onto graphics screen
Reply
#22
Terry, one of the biggest conversion problems is DEFN. Galleon decided to punt on that one. To save on memory, I had a couple of large programs I had to convert 100s of lines to regular function calls. So that is probably the best example of code that could be run more easily on DOSBox than converting to QB64, if yo don't plan to use it much.

Now SHELL commands might be a horse of a different color. I can't recall if the earlier versions of DOSBox supported all SHELL commands or not. VAPTAR() PEEK and POKE statements no longer able to function on newer Windows OS's probably can't run on DOSBox, either, but I haven't kept up with that project.

One cool thing DOSBox does have is an Android version. You can actually run QBasic programs on Android through that version of DOSBox.

Pete
If eggs are brain food, Biden has his scrambled.

Reply
#23
(09-30-2022, 04:47 PM)Pete Wrote: Terry, one of the biggest conversion problems is DEFN. Galleon decided to punt on that one. To save on memory, I had a couple of large programs I had to convert 100s of lines to regular function calls. So that is probably the best example of code that could be run more easily on DOSBox than converting to QB64, if yo don't plan to use it much.

Now SHELL commands might be a horse of a different color. I can't recall if the earlier versions of DOSBox supported all SHELL commands or not. VAPTAR() PEEK and POKE statements no longer able to function on newer Windows OS's probably can't run on DOSBox, either, but I haven't kept up with that project.

One cool thing DOSBox does have is an Android version. You can actually run QBasic programs on Android through that version of DOSBox.

Pete

Yeah, I remember those discussions way back then about DEFN and your need to do a lot of conversion.
Reply
#24
DEFN-itly.

Pete
Reply
#25
(09-30-2022, 04:38 PM)TerryRitchie Wrote: And as far as making SCREEN 13 bigger, easy peasy:

SCREEN13& = _NEWIMAGE(320,200,13) ' Work Screen
SCREEN _NEWIMAGE(1024,800,32) ' Graphics Screen
_DEST SCREEN13& ' Switch to work screen
' Draw your graphics and such
_DEST 0 ' Switch to graphics screen
_PUTIMAGE ,SCREEN13& ' Map work screen onto graphics screen
I prefer the jaggies only on an IBM PS/2 Model 30 color monitor or something like that from my high school. Not in the recent time on a 64-bit system LOL. This procedure won't be preferred by somebody who wants to import a game in "SCREEN 13" and "needs" to make it larger. A person would have to be clever enough to check the source code of a graphics program to see if it could support larger dimensions. But actually many old programs are hard-coded to certain screen dimensions.

I brought up the point about DOSBOX because a person who cannot have a computer and OS that could run 16-bit Q(uick)Basic has to pick his/her poison: either that or QB64PE, both are complex. That person might not care about 32-bit color, or about resolution larger than old VGA. However there are others who get curious. "But I need to do all that just to make the screen larger? Is there another easier way?" and "What do you think about Freebasic? Could it allow me to do it easier?" and "If I bought Purebasic..." and, well, you begin to understand what is the difficulty of persuading people who want to get into BASIC programming with a small amount of patience.

Many people complain about EXE/Linux-executable file sizes and how long an application finishes work (start from pressing [F5] in QB64PE IDE enough said). They would rather do something which is even less efficient because "I just want it to work like 20 years ago, how hard?"

Sometime ago I had a personal experience with 32-bit Free Pascal. None of my old programs would run correctly compiled by it because too many things were assumed out of "CRT" and "GRAPH" units, the two modules people were most interested in line with the most "popular" QB/QBasic programs posted on the web. It did have a "VIDEO" unit which does "portable console" like Freebasic "SCREEN 0", which could include changing the dimensions of "bash" or "cmd.exe" window.

The line-numbering luddite would just download PC-BASIC which, sadly it's difficult as heck to install it on Fedora and not available for many other Linux distros. It'll be interesting what happens to that one, once a certain popular programming tool finally reaches version 4...

(09-30-2022, 04:38 PM)TerryRitchie Wrote: Why would they need DOSBox? They can simply type the code into QB64 and it will run just fine. Remember, QB64 is nearly 100% compatible with all code written for GWBASIC (line numbers) and QuickBasic. No old computer or DOSBox needed.
Not if it supports "FOR... NEXT" loops for delaying eg. in an arcade game.
Reply
#26
Just calculate the frames per second of the old game and add the appropriate _LIMIT statement to the loop.

Anyway, in most cases old programs, of any consequence, require some conversion but absolutely nothing comes as close to QBasic products compatibility as QB64.

Pete
Reply
#27
Somebody edited the "NIBBLES.BAS" that came with QBasic long ago...

Before that, all the "FOR... NEXT" loops to do delays were commented out! So it was impossible to play the game, never mind "twiddle fingers" LOL.

BTW That program was a good example of doing graphics with text, which recalls eg. Tandy Color Computer. Much harder to do the 2x3 blocks of the TRS-80 Model III though...

Somebody might type in a QB/QBasic program into the QB64PE IDE, complete with those "FOR... NEXT" loops and then boggled by the result. "WTF this is unplayable! This sucks, this QB64 sucks and doesn't run my game right!" However, a small chance that occurs with the knowledgeable among us...
Reply
#28
Hi Terry
my two cents:
I remember an example of QBasic that get the screenmode using a mechanical method by error trapping (on error goto).

The news  of 32 bit screens aren't an exception to this... but the power of QB64 to create for example _NEWIMAGE(100,60,0) make needing the use of _WIDTH and _HEIGHT more than the ON ERROR GOTO way to get the screen MODE.

....
on the other hand I see in WikiHelp a function by Ted Weissgerber that should work and it uses INP and OUT

look at this
Code: (Select All)
FUNCTION ScreenMode&
SHARED colors 'share number of colors with main program
mode& = -1
_DEST 0 'destination zero always current screen mode
OUT &H3C7, 1 'set attribute to read
FOR colors = 1 TO 18 'get RGB color settings
  red = INP(&H3C9): grn = INP(&H3C9): blu = INP(&H3C9)
  IF red + grn + blu = 0 AND colors <> 16 THEN EXIT FOR
NEXT
wide& = _WIDTH: deep& = _HEIGHT 'get screen dimension
IF colors = 4 THEN mode& = 1
IF colors = 2 AND deep& = 200 THEN mode& = 2
IF colors = 17 AND wide& = 320 AND deep& = 200 THEN mode& = 7
IF colors = 17 AND wide& = 640 AND deep& = 200 THEN mode& = 8
IF colors = 17 AND deep& = 350 THEN mode& = 9
IF colors = 1 AND wide& = 640 AND deep& = 350 THEN mode& = 10
IF colors = 2 AND deep& = 480 THEN mode& = 11
IF colors = 17 AND deep& = 480 THEN mode& = 12
IF colors > 17 AND wide& = 320 AND deep& = 200 THEN mode& = 13
IF _PIXELSIZE = 0 THEN mode& = 0 'screen 0 any size
IF mode& = -1 THEN mode& = _DEST 'must be a QB64 screen
IF colors = 1 THEN colors = 4
IF colors = 17 THEN colors = 16
IF colors > 17 THEN colors = 256
IF _PIXELSIZE = 4 THEN colors = 32
ScreenMode& = mode&
END FUNCTION
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Code by Ted Weissgerber ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

You can find it in the wiki help of IDE.
Reply
#29
Hi
here the code developed by me following the idea of ON ERROR GOTO

Code: (Select All)
$Debug

Dim Mode As Integer, M As Integer

For M = 12 To 1 Step -1
    If M < 4 Then Mode = M - 1
    If M > 3 And M < 11 Then Mode = M + 3
    If M = 11 Then Mode = 256
    If M = 12 Then Mode = 32

    Screen _NewImage(400, 400, Mode)

    Print ScreenMode
    Sleep 2
Next
End

NewTry:

If Mode = 32 Then
    Print "error "; Mode
    Mode = 13
ElseIf Mode = 13 Then
    Print "error "; Mode
    Mode = 12
ElseIf Mode = 12 Then
    Print "error "; Mode
    Mode = 11
ElseIf Mode = 11 Then
    Mode = 10
ElseIf Mode = 10 Then
    Mode = 9
ElseIf Mode = 9 Then
    Mode = 8
ElseIf Mode = 8 Then
    Mode = 7
ElseIf Mode = 7 Then
    Mode = 2
ElseIf Mode = 2 Then
    Mode = 1
ElseIf Mode = 1 Then
    Mode = 0
ElseIf Mode = 0 Then
    Mode = 999
End If
Resume Next
End

Function ScreenMode
    ' it try to discover the screen MODE used for SCREEN settings
    Shared Mode As Integer
    On Error GoTo NewTry
    '   Mode = 32
    If Mode = 32 Then
        '32
        Paint (_Width(0) / 2, _Height(0) / 2), _RGB32(255, 255, 0)
    ElseIf Mode = 13 Then
        '256
        Paint (_Width(0) / 2, _Height(0) / 2), 56
    ElseIf Mode = 12 Then
        '12
        Paint (_Width(0) / 2, _Height(0) / 2), 15
    ElseIf Mode = 11 Then
        '11
        Color 1
    ElseIf Mode = 10 Then
        '10
        Color 4
    ElseIf Mode = 9 Then
        '9
        Paint (_Width(0) / 2, _Height(0) / 2), 16
    ElseIf Mode = 8 Then
        '8
        Paint (_Width(0) / 2, _Height(0) / 2), 16
    ElseIf Mode = 7 Then
        '7
        Paint (_Width(0) / 2, _Height(0) / 2), 16
    ElseIf Mode = 2 Then
        '2
        Color 2
    ElseIf Mode = 1 Then
        ' 1
        Color 15
    ElseIf Mode = 0 Then
        '0
        Color 31
    End If
    On Error GoTo 0
    ScreenMode = Mode
End Function

As you can see for the nature of ON ERROR GOTO label you need to put a part of code into MAIN and the rest of code into a FUNCTION.

I hope you like this routine.
Reply
#30
Try this:

Code: (Select All)
Data 0,1,2,7,8,9,10,11,12,13,256,32
Dim mode(11)

For i = 0 To 11
    Read mode(i)
Next

Dim m As _MEM

For i = 0 To 11
    If i < 10 Then
        Screen mode(i)
    Else
        Screen _NewImage(640, 400, mode(i))
    End If
    Print "ACTUAL MODE:"; mode(i)
    w = _Width(0)
    h = _Height(0)
    bpp = _PixelSize
    Select Case bpp
        Case 0 'text screen
            Print "SCREEN 0"
        Case 1
            For j = 1 To 255
                If _PaletteColor(j, 0) = &HFF000000 Then Exit For
            Next

            Select Case j
                Case 4: Print "SCREEN 1"
                Case 2: If h = 200 Then Print "SCREEN 2" Else Print "SCREEN 11"
                Case 1: Print "SCREEN 10"
                Case 16
                    If w = 320 Then
                        If _PaletteColor(17, 0) = &HFF000000 Then Print "SCREEN 7" Else Print "SCREEN 13"
                    Else
                        Select Case h
                            Case 200: Print "SCREEN 8"
                            Case 350: Print "SCREEN 9"
                            Case 480: Print "SCREEN 12"
                            Case Else
                                Print "SCREEN _NEWIMAGE("; w; ","; h; ", 256)"
                        End Select
                    End If
            End Select
        Case 4
            Print "SCREEN _NEWIMAGE("; w; ","; h; ",32)"
    End Select
    Sleep
Next
Reply




Users browsing this thread: 1 Guest(s)