Skip to content

Commit

Permalink
Began multicog VGA refactor; currently experiencing bizarre behavior …
Browse files Browse the repository at this point in the history
…w/ only > 2 cogs working.
  • Loading branch information
cspang1 committed Nov 16, 2017
1 parent 0875488 commit df0fe57
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 80 deletions.
4 changes: 2 additions & 2 deletions Dev/Game/Software/game.spin
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ CON
_xinfreq = 5_000_000 ' 5 MHz clock for x16 = 80 MHz

' Constants defining screen dimensions
vTilesH = 1 ' Number of visible tiles horizontally
vTilesV = 1 ' Number of visible tiles vertically
vTilesH = 10 ' Number of visible tiles horizontally
vTilesV = 10 ' Number of visible tiles vertically

' Constants defining memory tile palette
tSizeH = 16 ' Width of tiles in pixels
Expand Down
21 changes: 14 additions & 7 deletions Dev/Game/Software/graphics.spin
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
}}

CON
' Constants defining screen dimensions
' Constants defining video resolution
sResH = 640 ' Horizontal screen resolution
sResV = 480 ' Vertical screen resolution
linesFP = 10 ' Number of vertical front porch lines
linesVS = 2 ' Number of vertical sync lines
linesBP = 33 ' Number of vertical back porch lines
fpV = 10 ' Number of vertical front porch lines
syncV = 2 ' Number of vertical sync lines
bpV = 33 ' Number of vertical back porch lines
fpH = 16 ' Number of horizontal front porch pixels
syncH = 96 ' Number of horizontal sync pixels
bpH = 48 ' Number of horizontal back porch pixels

' Enumeration of video modes
#0
Expand All @@ -30,6 +33,7 @@ OBJ
VAR
' Video dirver attributes
long graphics_addr_base_ ' Variable for pointer to base address of graphics
long n_att_ ' Variable for number of video attributes that follow
long v_tiles_h_ ' Variable for visible horizontal tiles
long v_tiles_v_ ' Variable for visible vertical tiles
long t_size_h_ ' Variable for horizontal tile size
Expand All @@ -46,13 +50,15 @@ VAR
long c_per_frame_ ' Variable for pixel clocks per pixel
long c_per_pixel_ ' Variable for pixel clocks per frame
long v_scl_val_ ' Variable for vscl register value for visible pixels

long l_scl_val_ ' Variable for vscl register value for entire line

' Graphics system attributes
byte video_mode_ ' Variable for current video mode

PUB config(vidMode, graphAddr, numHorTiles, numVertTiles, horTileSize, vertTileSize, horTileMapSize, vertTileMapSize) : vidstatus ' Function to start vga driver with pointer to Main RAM variables
' Calculate video/tile attributes
graphics_addr_base_ := graphAddr ' Point tile_map_base to base of tile maps
n_att_ := 17 ' Set number of video attributes that follow
v_tiles_h_ := numHorTiles ' Set visible horizontal tiles
v_tiles_v_ := numVertTiles ' Set visible vertical tiles
t_size_h_ := horTileSize ' Set horizontal tile size
Expand All @@ -69,14 +75,15 @@ PUB config(vidMode, graphAddr, numHorTiles, numVertTiles, horTileSize, vertTileS
c_per_frame_ := sResH / v_tiles_h_ ' Calculate pixel clocks per pixel
c_per_pixel_ := c_per_frame_ / t_size_h_ ' Calculate pixel clocks per frame
v_scl_val_ := (c_per_pixel_ << 12) + c_per_frame_ ' Calculate vscl register value for visible pixels

l_scl_val_ := sResH + fpH + syncH + bpH ' Calculate length of entire line

' Set video mode
video_mode_ := vidMode ' Initialize video mode

PUB start
' Start specified video driver
case video_mode_
VGA_mode : return vga.start(@graphics_addr_base_, linesFP, linesVS, linesBP) ' Initialize cog running VGA driver
VGA_mode : return vga.start(@graphics_addr_base_, fpV, syncV, bpV) ' Initialize cog running VGA driver
RGBS_mode : return FALSE ' Initialize cog running RGBS driver with reference to start of variable registers
NTSC_mode : return FALSE ' Initialize cog running NTSC driver with reference to start of variable registers
other : abort FALSE ' Invalid driver specified; abort
Expand Down
Loading

0 comments on commit df0fe57

Please sign in to comment.