QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: ZapJackson on March 02, 2019, 12:05:24 pm

Title: Newbie question about custom screen modes for text
Post by: ZapJackson on March 02, 2019, 12:05:24 pm
Sorry for the basic question (ha ha) but I'm having a hard time teasing what I'm trying to do out of the documentation.

I'd like to have a custom sized text mode window (call it 60x40 characters,) that uses the double width version of the default 8x8 font, and has 32 bit color available for text foreground and background.

I keep finding ways to do two of these three things, but not all three at once.  What am I missing?
Title: Re: Newbie question about custom screen modes for text
Post by: SMcNeill on March 02, 2019, 12:28:22 pm
SCREEN _NEWIMAGE(60* _FONTWIDTH, 40 * _FONTHEIGHT, 32)

_FONTWIDTH and _FONTHEIGHT by themselves will give you the height/width for the default font.  (_FONT 16)

_NEWIMAGE gives you custom image sizes.

,32 at the end of _NEWIMAGE gives you 32-bit color mode.

NOTE:  This is actually a graphical mode and not text-exclusive, so blinking colors won’t work and the screen stores information in a pixel-by-pixel basis, rather than in 2-byte ASCII mode.
Title: Re: Newbie question about custom screen modes for text
Post by: bplus on March 02, 2019, 12:32:04 pm
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(480, 320, 32)
  2. FOR row = 1 TO 40
  3.     LOCATE row, 1
  4.     IF row MOD 2 THEN
  5.         PRINT row, "Hi, ZapJackson";
  6.     ELSE
  7.         PRINT row, "Welcome to the forum."; 'no cr lf
  8.     END IF
  9. LINE (0, 0)-(479, 319), , B
  10. SLEEP 'wait for keypress to ruin screen
  11.  
edit: 60 x 40

wait double "width" of font 8, oops too small.

Double width? 16 X 16 ? or 16 X 8?  might take a special font.
Title: Re: Newbie question about custom screen modes for text
Post by: ZapJackson on March 02, 2019, 01:35:11 pm
Aha!  Excellent, thank you all, this gets me more or less where I'd like to be.

I can get everything to look exactly the way I want it if I _FULLSCREEN, which is totally adequate.  A resizable window would be nice.  I know I can use $RESIZE:STRETCH to let the user resize it, but is there a way to stretch it in code?  Like if I wanted it to be 2x the default size... 

It sounds like I could achieve the same thing with a custom font, which is totally fine if it comes to that, but I thought maybe there was an easier way to just use _FONT 8 at double its native resolution.
Title: Re: Newbie question about custom screen modes for text
Post by: bplus on March 02, 2019, 02:16:25 pm
This might be easy enough:
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(60 * 16, 40 * 16, 32)
  2.  
  3. f8& = _NEWIMAGE(60 * 8, 40 * 8, 32) 'set uo isolated screen to print and do graphics
  4.  
  5. _DEST f8& 'move to isolation and create the screen to show
  6. FOR row = 1 TO 40
  7.     LOCATE row, 1
  8.     IF row MOD 3 = 1 THEN
  9.         PRINT row, "Hi, ZapJackson";
  10.     ELSEIF row MOD 3 = 2 THEN
  11.         PRINT "Welcome to the forum.";
  12.     ELSE
  13.         FOR i = 1 TO 60: PRINT LTRIM$(STR$(i MOD 10));: NEXT
  14.     END IF
  15. LINE (0, 0)-(60 * 8 - 1, 40 * 8 - 1), _RGB32(0, 0, 255), B 'blue box everything
  16.  
  17. _DEST 0 'set to screen it, 0 is handle for screen
  18. _PUTIMAGE , f8&, 0 'paste image to screen
  19.  
  20. SLEEP 'wait for keypress to ruin screen
  21.  

EDIT: remove unneeded line and comment better
Title: Re: Newbie question about custom screen modes for text
Post by: TempodiBasic on March 02, 2019, 04:52:49 pm
Hi guys

I like old ASCII screen with its 32 attributes of colors and its blinking!

Code: QB64: [Select]
  1. WIDTH 60, 40
  2.  
  3. FOR row = 1 TO 40
  4.     LOCATE row, 1
  5.     co1 = row MOD 31
  6.     IF co1 = 0 OR co1 = 16 THEN co2 = 14 ELSE co2 = 0
  7.     COLOR co1, co2
  8.     IF row MOD 2 THEN
  9.         PRINT row, "Hi, ZapJackson";
  10.     ELSE
  11.         PRINT row, "Welcome to the forum."; 'no cr lf
  12.     END IF
  13.  
  14. SLEEP 'wait for keypress to ruin screen
  15.  

but the request is an ASCII emulated screen 60x40 with 32bit colors...
so good example of Bplus but we must colorized it!
Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(60 * 16, 40 * 16, 32)
  2.  
  3. f8& = _NEWIMAGE(60 * 8, 40 * 8, 32) 'set uo isolated screen to print and do graphics
  4.  
  5. _DEST f8& 'move to isolation and create the screen to show
  6. FOR row = 1 TO 40
  7.     COLOR _RGB(RND * 255, RND * 255, RND * 255), _RGB(RND * 255, RND * 255, RND * 255)
  8.     LOCATE row, 1
  9.     IF row MOD 3 = 1 THEN
  10.         PRINT row, "Hi, ZapJackson";
  11.     ELSEIF row MOD 3 = 2 THEN
  12.         PRINT "Welcome to the forum.";
  13.     ELSE
  14.         FOR i = 1 TO 60: COLOR _RGB(RND * 255, RND * 255, RND * 255), _RGB(RND * 255, RND * 255, RND * 255): PRINT LTRIM$(STR$(i MOD 10));: NEXT
  15.     END IF
  16. LINE (0, 0)-(60 * 8 - 1, 40 * 8 - 1), _RGB32(0, 0, 255), B 'blue box everything
  17.  
  18. _DEST 0 'set to screen it, 0 is handle for screen
  19. _PUTIMAGE , f8&, 0 'paste image to screen
  20.  
  21. SLEEP 'wait for keypress to ruin screen
  22.  
here screenshot  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Newbie question about custom screen modes for text
Post by: Pete on March 02, 2019, 05:07:00 pm
Just use SCREEN 0 and you can avoid all this crap. Shesh.

Pete :D
Title: Re: Newbie question about custom screen modes for text
Post by: ZapJackson on March 09, 2019, 12:56:59 pm
Here's why I was asking... :)

https://jick.itch.io/ghost-wizard

Thanks for all the help!
Title: Re: Newbie question about custom screen modes for text
Post by: bplus on March 09, 2019, 01:16:01 pm
Here's why I was asking... :)

https://jick.itch.io/ghost-wizard

Thanks for all the help!

Damn $7 to see the bas code! :P
Title: Re: Newbie question about custom screen modes for text
Post by: Pete on March 09, 2019, 01:54:18 pm

Damn $7 to see the bas code! :P

Settle down Lucy. Everything can't cost 5-cents.

Pete :D
Title: Re: Newbie question about custom screen modes for text
Post by: Cobalt on March 10, 2019, 12:27:26 pm

Damn $7 to see the bas code! :P

Settle down Lucy. Everything can't cost 5-cents.

Pete :D

Why not? People still say my thoughts are only worth a penny! And my time is worthless!


Anyway, that game looks like it would be easy enough to make in SCREEN 0 with 16 colors. on a normal WIDTH 80,40.
Title: Re: Newbie question about custom screen modes for text
Post by: Pete on March 10, 2019, 01:40:59 pm
Sure, let's bring back inflation. If it's hard enough for BPlus to cough up $7 for it now, just think how hard it will be when someone remakes it in SCREEN 0, and the price jumps 200%.

Just putting in my 2-cents... which apparently means you can respond twice. :D

Pete SCREEN 0 Hero
Title: Re: Newbie question about custom screen modes for text
Post by: ZapJackson on March 10, 2019, 10:29:24 pm
It's pay-what-you-want -- you can see it for free.  Also here's the BAS source in case that's easier.  [ This attachment cannot be displayed inline in 'Print Page' view ]  
Title: Re: Newbie question about custom screen modes for text
Post by: Cobalt on March 10, 2019, 11:24:36 pm
Sure, let's bring back inflation. If it's hard enough for BPlus to cough up $7 for it now, just think how hard it will be when someone remakes it in SCREEN 0, and the price jumps 200%.

Just putting in my 2-cents... which apparently means you can respond twice. :D

Pete SCREEN 0 Hero

Today's ideology would be at least 400%, and I'll invest that other cent toward my retirement. sure it will go just as far as this conversation.

It's pay-what-you-want -- you can see it for free.  Also here's the BAS source in case that's easier.
I was wondering where Bplus got the $7 when I saw that myself. Don't take most of us too seriously around here, light-hearted fun is typically on tap. :D
It does look cool, but are you sure it couldn't just be done in straight SCREEN 0? or are you going for an upgraded look?
Title: Re: Newbie question about custom screen modes for text
Post by: bplus on March 11, 2019, 08:46:48 am
It's pay-what-you-want -- you can see it for free.  Also here's the BAS source in case that's easier.  [ This attachment cannot be displayed inline in 'Print Page' view ]

Apologies, I misread the pop-up. Zack Johnson author sounds allot like Zap Jackson.  :)

So this is how the author handled the font (with a full color graphics screen):
Code: QB64: [Select]

That is a 60 x 40 character screen with _FONT 8 just blown up with _FULLSCREEN and an option, _SQUAREPIXELS, that I had not known about before.
Title: Re: Newbie question about custom screen modes for text
Post by: Pete on March 11, 2019, 10:59:58 am
We really need stuff like this captured, tested, and added to the Wiki, well, if it works as intended. Who wants to be voted the next "Clippy?" Not it! Ouch! Guys, quit throwing stuff at me!!!

Pete
Title: Re: Newbie question about custom screen modes for text
Post by: ZapJackson on March 11, 2019, 04:00:32 pm
I am the author.

Why does everybody want this to be in SCREEN 0?  Is it some ideological thing?

I want access to more than the EGA palette.
Title: Re: Newbie question about custom screen modes for text
Post by: Pete on March 11, 2019, 04:24:15 pm
Because SCREEN 0 is the only screen any real programmer would ever need!

Pete
Title: Re: Newbie question about custom screen modes for text
Post by: bplus on March 11, 2019, 04:53:40 pm
I am the author.

Why does everybody want this to be in SCREEN 0?  Is it some ideological thing?

I want access to more than the EGA palette.

Pete is NOT everybody! :D
Title: Re: Newbie question about custom screen modes for text
Post by: Pete on March 11, 2019, 05:59:55 pm
I'd say take a bow, BPlus, but maybe not in that skirt.

Pete :D
Title: Re: Newbie question about custom screen modes for text
Post by: Cobalt on March 11, 2019, 06:13:49 pm
"Pete is NOT everybody! :D"

Yeah there is me too!

If you can read this you CHEATED!

I am the author.

Why does everybody want this to be in SCREEN 0?  Is it some ideological thing?

I want access to more than the EGA palette.

when it comes to text based games SCREEN 0 is usually the norm. But if your after a larger palette then yeah.
Could go straight up with a graphics mode and use an image based font.
Title: Re: Newbie question about custom screen modes for text
Post by: Pete on March 11, 2019, 07:23:59 pm
Sorry if
I'm being whiny
Hey Cobolt
Your font is tiny

Pete