Advertisement
LBASIC

320X240Q

Jun 5th, 2023
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 3.85 KB | Source Code | 0 0
  1. 'From: DAVE SHEA                 Conference: QUIK_BAS -Qui (298)
  2. '      Digital Encounters * Kamloops BC Canada 250/374-6168 (1:353/710)
  3. 'Example of how to achieve ModeX in QuickBasic, from Douglas Lusher
  4. 'Modified to show QBasic example by Kurt Kuzba, (5/23/1997)
  5. DECLARE SUB XCLS (Page%)
  6. DECLARE SUB ShowPage (Page%)
  7. DECLARE SUB Set320x240mode ()
  8. DECLARE SUB PutPixel (X%, Y%, Culler%, Page%)
  9. DIM BitMask%(7): FOR Bit% = 0 TO 7: BitMask%(Bit%) = 2 ^ Bit%: NEXT
  10. SCREEN 0: WIDTH 80, 25: COLOR 10, 0: LOCATE 5, 10
  11. PRINT "Hit any key to enter ModeX. 0-1-2 for pages. ESC exits."
  12. WHILE INKEY$ = "": WEND: Set320x240mode: SLEEP 1
  13. HMax% = 320: VMax% = 240: Pg% = 0
  14. FOR Scrpage% = 0 TO 2
  15.    C% = 10: IF Scrpage% > 0 THEN C% = 12: IF Scrpage% > 1 THEN C% = 13
  16.    XCLS Scrpage%: ShowPage Scrpage%
  17.    FOR Y% = Scrpage% * 9 TO VMax% - 1 - Scrpage% * 9
  18.       PutPixel Scrpage% * 9, Y%, C%, Scrpage%
  19.       PutPixel HMax% - 1 - Scrpage% * 9, Y%, C%, Scrpage%
  20.    NEXT
  21.    FOR X% = Scrpage% * 9 TO HMax% - 1 - Scrpage% * 9
  22.       CALL PutPixel(X%, Scrpage% * 9, C%, Scrpage%)
  23.       CALL PutPixel(X%, VMax% - 1 - Scrpage% * 9, C%, Scrpage%)
  24.    NEXT
  25. NEXT
  26. DO
  27.    DO: k$ = INKEY$: LOOP WHILE k$ = ""
  28.    SELECT CASE k$
  29.       CASE "0": ShowPage 0
  30.       CASE "1": ShowPage 1
  31.       CASE "2": ShowPage 2
  32.       CASE CHR$(27): EXIT DO
  33.       CASE ELSE: SOUND 999, .5
  34.    END SELECT
  35. LOOP: SCREEN 13: SCREEN 0: WIDTH 80, 25: END
  36.  
  37. SUB GetPixel (X%, Y%, Culler%, Page%)
  38.    SELECT CASE Page%
  39.       CASE 0: VidSegment% = &HA000
  40.       CASE 1: VidSegment% = &HA4F0
  41.       CASE 2: VidSegment% = &HA9E0
  42.       CASE ELSE: ERROR 5
  43.    END SELECT
  44.    OUT &H3CE, 4: OUT &H3CF, X% AND 3
  45.    DEF SEG = VidSegment%
  46.    Culler% = PEEK((Y% * 80) + (X% \ 4))
  47. END SUB
  48.  
  49. SUB PutPixel (X%, Y%, Culler%, Page%)
  50.    SHARED BitMask%()
  51.    SELECT CASE Page%
  52.       CASE 0: VidSegment% = &HA000
  53.       CASE 1: VidSegment% = &HA4F0
  54.       CASE 2: VidSegment% = &HA9E0
  55.       CASE ELSE: ERROR 5
  56.    END SELECT
  57.    OUT &H3C4, 2: OUT &H3C5, BitMask%(X% AND 3)
  58.    DEF SEG = VidSegment%
  59.    POKE (Y% * 80) + (X% \ 4), Culler%
  60. END SUB
  61.  
  62. SUB Set320x240mode
  63.    SCREEN 13                          'begin with standard mode 13h
  64.    OUT &H3C4, &H4: OUT &H3C5, &H6     'disable "chain4" mode
  65.    OUT &H3C4, &H2: OUT &H3C5, &HF     'enable writes to all four planes
  66.    CLS                                'clear video memory
  67.    OUT &H3C4, 0: OUT &H3C5, &H1       'synchronous reset while
  68.                                       'switching clocks
  69.    OUT &H3C2, &HE3                    'select 25 Mhz dot clock and
  70.                                       '60 hz scanning rate
  71.    OUT &H3C4, 0: OUT &H3C5, &H3       'restart the sequencer
  72.    OUT &H3D4, &H11: OUT &H3D5, INP(&H3D5) AND &H7F
  73.       'to reprogram the CRT controller, remove write protect from
  74.       'the registers
  75.    OUT &H3D4, &H6: OUT &H3D5, &HD     'total vertical pixels
  76.    OUT &H3D4, &H7: OUT &H3D5, &H3E    'overflow
  77.    OUT &H3D4, &H9: OUT &H3D5, &H41    'turn off double double-scan
  78.    OUT &H3D4, &H10: OUT &H3D5, &HEA   'vertical sync start
  79.    OUT &H3D4, &H11: OUT &H3D5, &HAC   'vertical sync end,
  80.                                       'reprotect_registers
  81.    OUT &H3D4, &H12: OUT &H3D5, &HDF   'vertical pixels displayed
  82.    OUT &H3D4, &H14: OUT &H3D5, 0      'turn off dword mode
  83.    OUT &H3D4, &H15: OUT &H3D5, &HE7   'vertical blank start
  84.    OUT &H3D4, &H16: OUT &H3D5, &H6    'vertical blank end
  85.    OUT &H3D4, &H17: OUT &H3D5, &HE3   'turn on byte mode
  86. END SUB
  87.  
  88. SUB ShowPage (Page%)
  89.    SELECT CASE Page%
  90.       CASE 0: OUT &H3D4, &HC: OUT &H3D5, 0
  91.       CASE 1: OUT &H3D4, &HC: OUT &H3D5, &H4F
  92.       CASE 2: OUT &H3D4, &HC: OUT &H3D5, &H9E
  93.       CASE ELSE: ERROR 5          'illegal function call
  94.    END SELECT
  95. END SUB
  96.  
  97. SUB XCLS (Page%)
  98.    SELECT CASE Page%
  99.       CASE 0: VidSegment% = &HA000
  100.       CASE 1: VidSegment% = &HA4F0
  101.       CASE 2: VidSegment% = &HA9E0
  102.       CASE ELSE: ERROR 5
  103.    END SELECT
  104.    OUT &H3C4, &H2: OUT &H3C5, &HF
  105.    DEF SEG = VidSegment%
  106.    FOR Address% = 0 TO 19199: POKE Address%, 0: NEXT
  107. END SUB
  108.  
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement