Author Topic: QB 160x100x16 CGA mode  (Read 62 times)

QB 160x100x16 CGA mode
« on: July 03, 2018, 10:58:59 AM »
Just dropping this here because it took a while to get the code working correctly for the CGA 80x100 16 color truncated text mode, used for drawing 160x100x16 box characters to achieve effects seen in a few old games, and some new ones such as Silly Knight - http://www.doshaven.eu/game/silly-knight/ . I'm sure this is a trivial exercise for most, but there's not a wealth of information on achieving it in QB, which requires both disabling blinking, and poke'ing the characters to the screen.

This only works on CGA hardware (or DOSBOX with machine set to CGA mode). You could run it on VGA hardware/emulation, but it'd set up an 80x200x16 screen mode which is kinda useless since you can already go 320x200x256 on the same hardware. It's not really practical for much, QB isn't fast enough, but it's still fun to see (to my mind, anyway).

Code: [Select]
SCREEN 0

'disable blinking, enable hicolor text background
'(works in VGA screen 0 as well)
T% = INP(&H3DA)
OUT &H3C0, &H10
T% = INP(&H3C1)
OUT &H3C0, &H10
OUT &H3C1, T% AND NOT 8

GOSUB SetXCGA
DEF SEG = &HB800

'draw grid using foreground color 4, background color 9,
'alternating chr$(221) and chr$(222)

'color = fc + (bc * 16)
c = 4 + (9 * 16)
FOR y = 0 TO 99 STEP 2
    FOR x = 0 TO 79
        l = (x + (y * 80)) * 2
        m = (x + ((y + 1) * 80)) * 2
        POKE l, ASC("Þ")
        POKE l + 1, c
        POKE m, ASC("Ý")
        POKE m + 1, c
    NEXT
NEXT

a$ = INPUT$(1)
SCREEN 2: SCREEN 0: END                 'restore text mode and exit

SetXCGA:
DEF SEG = 0
POKE &H465, 0: OUT &H3D8, 0:
POKE &H466, 0: OUT &H3D9, 0
OUT &H3D4, 0: OUT &H3D5, 113
OUT &H3D4, 1: OUT &H3D5, 80
OUT &H3D4, 2: OUT &H3D5, 90
OUT &H3D4, 3: OUT &H3D5, 10
OUT &H3D4, 4: OUT &H3D5, 127
OUT &H3D4, 5: OUT &H3D5, 6
OUT &H3D4, 6: OUT &H3D5, 100
OUT &H3D4, 7: OUT &H3D5, 112
OUT &H3D4, 8: OUT &H3D5, 2
OUT &H3D4, 9: OUT &H3D5, 1
OUT &H3D4, 10: OUT &H3D5, 32
OUT &H3D4, 11: OUT &H3D5, 0
POKE &H465, 9: OUT &H3D8, 9
RETURN
« Last Edit: July 03, 2018, 11:01:13 AM by Raennik »