Author Topic: "Brightness Slider" for QBASIC and QB64.  (Read 5185 times)

0 Members and 1 Guest are viewing this topic.

Offline MarkSkits

  • Newbie
  • Posts: 3
    • View Profile
"Brightness Slider" for QBASIC and QB64.
« on: June 11, 2018, 10:15:43 pm »
Note: Uses QBMOUSE Sub

Code: QB64: [Select]
  1. startPos = 50
  2. endPos = 590
  3. currentPos = startPos
  4. colorValue = 9
  5. COLOR colorValue
  6. LINE (50, 239)-(590, 241), colorValue, BF
  7. LINE (startPos - 1, 230)-(startPos + 1, 250), colorValue, BF
  8. MOUSE 1
  9. Text$ = "Current Background Brightness:" + STR$(FIX(Brightness)) + "."
  10. LOCATE 13, 40 - (LEN(Text$) / 2)
  11. PRINT Text$
  12. LOCATE 13, (40 + (LEN(Text$) / 2)) - 3
  13. PRINT RTRIM$(STR$(FIX(Brightness))); ". "
  14.     MOUSE 3
  15.     SELECT CASE B
  16.         CASE 1
  17.             IF H >= startPos AND H <= endPos AND V >= 230 AND V <= 250 THEN
  18.                 DO WHILE B = 1
  19.                     MOUSE 3
  20.                     IF H >= startPos AND H <= endPos THEN
  21.                         LINE (currentPos - 1, 230)-(currentPos + 1, 238), 0, BF
  22.                         LINE (currentPos - 1, 242)-(currentPos + 1, 250), 0, BF
  23.                         currentPos = H
  24.                         Brightness = (currentPos - 50) / (540 / 63)
  25.                         OUT &H3C8, 0
  26.                         OUT &H3C9, Brightness
  27.                         OUT &H3C9, Brightness
  28.                         OUT &H3C9, Brightness
  29.                         LINE (currentPos - 1, 230)-(currentPos + 1, 250), colorValue, BF
  30.                         LOCATE 13, (40 + (LEN(Text$) / 2)) - 3
  31.                         PRINT RTRIM$(STR$(FIX(Brightness))); ". "
  32.                     END IF
  33.                 LOOP
  34.             END IF
  35.     END SELECT
  36. SUB MOUSE (Funk)
  37.     SHARED B, H, V
  38.     STATIC Crsr
  39.     IF Funk = 1 THEN Crsr = 1
  40.     IF Funk = 2 AND Crsr = 0 THEN EXIT SUB
  41.     IF Funk = 2 AND Crsr = 1 THEN: Crsr = 0
  42.     POKE 100, 184: POKE 101, Funk: POKE 102, 0
  43.     POKE 103, 205: POKE 104, 51: POKE 105, 137
  44.     POKE 106, 30: POKE 107, 170: POKE 108, 10
  45.     POKE 109, 137: POKE 110, 14: POKE 111, 187
  46.     POKE 112, 11: POKE 113, 137: POKE 114, 22
  47.     POKE 115, 204: POKE 116, 12: POKE 117, 203
  48.     CALL ABSOLUTE(100)
  49.     B = PEEK(&HAAA)
  50.     H2 = PEEK(&HBBC)
  51.     H2 = H2 * 256
  52.     H = PEEK(&HBBB) + H2
  53.     V = PEEK(&HCCC) + PEEK(&HCCD) * 256
  54.  

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: "Brightness Slider" for QBASIC and QB64.
« Reply #1 on: June 11, 2018, 11:50:57 pm »
Hi! I wonder why you don't use QB64's inbuilt mouse command. Using them will make your work easy.
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline MarkSkits

  • Newbie
  • Posts: 3
    • View Profile
Re: "Brightness Slider" for QBASIC and QB64.
« Reply #2 on: June 12, 2018, 09:16:03 am »
I made it so it would work with QB64 AND QBasic.

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: "Brightness Slider" for QBASIC and QB64.
« Reply #3 on: June 12, 2018, 10:49:41 am »
Nice work!