Author Topic: Newbie question about custom screen modes for text  (Read 2960 times)

0 Members and 1 Guest are viewing this topic.

Offline ZapJackson

  • Newbie
  • Posts: 10
Newbie question about custom screen modes for text
« 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?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • Steve’s QB64 Archive Forum
Re: Newbie question about custom screen modes for text
« Reply #1 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.
« Last Edit: March 02, 2019, 12:32:51 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Newbie question about custom screen modes for text
« Reply #2 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.
« Last Edit: March 02, 2019, 12:47:44 pm by bplus »

Offline ZapJackson

  • Newbie
  • Posts: 10
Re: Newbie question about custom screen modes for text
« Reply #3 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.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Newbie question about custom screen modes for text
« Reply #4 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
« Last Edit: March 02, 2019, 02:20:57 pm by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
Re: Newbie question about custom screen modes for text
« Reply #5 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  [ You are not allowed to view this attachment ]  
Programming isn't difficult, only it's  consuming time and coffee

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
Re: Newbie question about custom screen modes for text
« Reply #6 on: March 02, 2019, 05:07:00 pm »
Just use SCREEN 0 and you can avoid all this crap. Shesh.

Pete :D
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline ZapJackson

  • Newbie
  • Posts: 10
Re: Newbie question about custom screen modes for text
« Reply #7 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!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Newbie question about custom screen modes for text
« Reply #8 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

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
Re: Newbie question about custom screen modes for text
« Reply #9 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
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
Re: Newbie question about custom screen modes for text
« Reply #10 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.
« Last Edit: March 10, 2019, 12:31:03 pm by Cobalt »
Granted after becoming radioactive I only have a half-life!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
Re: Newbie question about custom screen modes for text
« Reply #11 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
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline ZapJackson

  • Newbie
  • Posts: 10
Re: Newbie question about custom screen modes for text
« Reply #12 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.  [ You are not allowed to view this attachment ]  

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
Re: Newbie question about custom screen modes for text
« Reply #13 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?
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
Re: Newbie question about custom screen modes for text
« Reply #14 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.  [ You are not allowed to view this attachment ]

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.
« Last Edit: March 11, 2019, 09:05:19 am by bplus »