Skip to content

Instantly share code, notes, and snippets.

@routevegetable
Last active March 18, 2022 17:38
Show Gist options
  • Save routevegetable/eb1d4006e2d2e3b15ffb45192aee166c to your computer and use it in GitHub Desktop.
Save routevegetable/eb1d4006e2d2e3b15ffb45192aee166c to your computer and use it in GitHub Desktop.
Propeller SPIN XGA driver
'VGA Driver by Lee Marshall
CON
_clkmode = XINPUT + PLL16X
_xinfreq = 4_000_000
VAR
long bitmapbase[1536]
byte cog
PUB Main
cognew(@vgastart,@bitmapbase)
PUB Running : YesNo
YesNo := cog
PUB Stop
cogstop(cog~ -1)
DAT
org
'Driver Start
vgastart
rdlong bitmap_base,par 'store base address of bitmap
mov dira,IOdir
mov vcfg,videoconfig 'configure video generator
mov vscl,videoscale
mov frqa,frequencya 'set up counter module to produce internal 64 mhz signal, and start counter
mov ctra,countera
loop7 mov currentline,vlines 'set currentline to 768
loop6 call #whiteline 'do a white line
djnz currentline,#loop6 'do this 768 times
call #vertical_sync 'do vertical sync
jmp #loop7 'start again
whiteline 'produce a white line
mov tilecount,#32
loop8 waitvid vid_colors,vid_test '32 horizontal pixelgroups of 32 pixels(1024 pixels)
djnz tilecount,#loop8
waitvid hsync_colors,hsync_pixels1 'hsync
waitvid hsync_colors,hsync_pixels2
waitvid hsync_colors,hsync_pixels2
waitvid hsync_colors,hsync_pixels2
waitvid hsync_colors,hsync_pixels2
waitvid hsync_colors,hsync_pixels3
waitvid hsync_colors,hsync_pixels3
waitvid hsync_colors,hsync_pixels3
waitvid hsync_colors,hsync_pixels3
waitvid hsync_colors,hsync_pixels3
whiteline_ret ret
blankline 'produce a blank line
mov tilecount,#32
loop1 waitvid vid_colors,zero '32 horizontal pixelgroups of 32 pixels(1024 pixels)
djnz tilecount,#loop1
waitvid hsync_colors,hsync_pixels1 'hsync
waitvid hsync_colors,hsync_pixels2
waitvid hsync_colors,hsync_pixels2
waitvid hsync_colors,hsync_pixels2
waitvid hsync_colors,hsync_pixels2
waitvid hsync_colors,hsync_pixels3
waitvid hsync_colors,hsync_pixels3
waitvid hsync_colors,hsync_pixels3
waitvid hsync_colors,hsync_pixels3
waitvid hsync_colors,hsync_pixels3
blankline_ret ret
vsync_line
mov tilecount,#32
loop2 waitvid vsync_colors,zero
djnz tilecount,#loop2
waitvid vsync_colors,hsync_pixels1 'hsync
waitvid vsync_colors,hsync_pixels2
waitvid vsync_colors,hsync_pixels2
waitvid vsync_colors,hsync_pixels2
waitvid vsync_colors,hsync_pixels2
waitvid vsync_colors,hsync_pixels3
waitvid vsync_colors,hsync_pixels3
waitvid vsync_colors,hsync_pixels3
waitvid vsync_colors,hsync_pixels3
waitvid vsync_colors,hsync_pixels3
vsync_line_ret ret
vertical_sync 'perform vsync
mov linecount,vfp 'front porch lines
loop3 call #blankline
djnz linecount,#loop3
mov linecount,vsync 'sync lines
loop4 call #vsync_line
djnz linecount,#loop4
mov linecount,vbp 'back porch lines
loop5 call #blankline
djnz linecount,#loop5
vertical_sync_ret ret
bitmap_base long 0 'pointer to bitmap(1536 longs(6KBytes))
temp long 0
IOdir long %00000000_11111111_0000000000000000
videoconfig long %0_01_0_0_0_000_00000000000_010_0_11111111
videoscale long %000000000000_00000001_000000100000
countera long %0_00001_110_00000000_000000_000_000000
frequencya long $2_000_0000
currentpixel long 0
currentline long 0
tilecount long 0
linecount long 0
hfp long 24 'horizontal details in pixels
hsync long 136
hbp long 160
hvid long 1024
vfp long 3 'vertical details in lines
vsync long 6
vbp long 29
zero long 0
vlines long 768
vsync_colors long %01010100_00000010 'color 0 : hsync 1, vsync 0 color 1 : hsync 0, vsync 0
hsync_colors long %00000001_01010111 'color 0 : hsync 1, vsync 1 color 1 : hsync 0, vsync 1
vid_colors long %11111111_01010111 'color 0 : syncs 1, rgb 000 color 1 : syncs 1, rgb 111
' hsync:
' requires:
' hsync_pixels1 (x1)
' hsync_pixels2 (x4)
' hsync_pixels3 (x5)
hsync_pixels1 long %11111111_000000000000000000000000 'front porch, then beginning of sync pulse
hsync_pixels2 long %11111111111111111111111111111111 'rest of sync pulse
hsync_pixels3 long %00000000000000000000000000000000 'back porch
vid_test long %11111111111111111111111111111111
fit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment