Skip to content

Instantly share code, notes, and snippets.

@ErnWong
Last active January 19, 2018 01:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErnWong/7db67164224aaa3be5f6fcc2a6f5dd21 to your computer and use it in GitHub Desktop.
Save ErnWong/7db67164224aaa3be5f6fcc2a6f5dd21 to your computer and use it in GitHub Desktop.
v86 VGA Implementation
Out of date. See V2.txt
Host Memory Write ________ Host Memory Read
| _|______ | ^
write | _|______ | | | read
logic | _|______ | |_| | logic
`-------->| | |_| ------------`
| Planes |_| ^ PLOT: Calculates 4 bit / 8 bit color data
|________| | from planes and plots them at the correct
256KiB | | pixel address. Full replots are rare, and
Nomenclature: | | usually only occur during video mode changes.
addr | PLOT -------------------. (O(1)) | Depends on and is triggered by:
diff_plot_min | | maps color index to | - a host memory write = partial replot
diff_plot_max v v pixel addresses | - PEL width, byte/word/dword mode,
______________ ______________ | shift mode, addr subst = full replot
| | | | doubly v - if addr subst: start_addr, offset = full replot
Nomenclature: | Pixel Buffer | |Color Use List| linked list
pixel_addr |______________| |______________| ^ DRAW: maps pixel color indices to image
diff_addr_min 512KiB | 2x2MiB | tells what pixels | data. Allows smooth fades and transitions.
diff_addr_max | | needs updating when | Depends on and is triggered by:
| DRAW <-----------------` palette has changed | - a plot update = partial redraw
v | - dac_map, vga256_palette = partial redraw
VGAScreen.js ______________ ______________ | - Palette bits 4/5/6/7 select
Above | | | | v color plane enable, = full redraw
####################| Image Buffer |##########| Layer Info |#################################################################
Below |______________| |______________| ^ ASSEMBLE: draws fragments of the
ScreenAdapter.js 2MiB | | | Image Data to build the final image.
| | | Allows rapid page flipping,
| ASSEMBLE <-------------` | scrolling, panning, & split screens.
v | Layer Info is determined from:
////////////////// | start_address, horizontal_panning, byte_panning
// Canvas // | line_compare, and registers that affect
////////////////// v screen width/height and plotting location.
Memory Layout:
.--------------------------------------------------------------------------------------------------- - - - ---.
| S V G A M E M O R Y |
|--------------------------------------------------------------------------------------------------- - - - ---|
| vga_memory | | DAC Color Use List | |
| . . . | | prev | next | |
| plane0 | plane1 | plane2 | plane3 | pixel_buffer | | | root | |
`--------^--------^--------^--------^--------------^--------^------^--------^----------------------- - - -----`
<-64KiB-><-64KiB-><-64KiB-><-64KiB-> <-256B->
<--------------256KiB--------------> <---512KiB---> <-2MiB-> <----2MiB----->
^^^^^^^^^^^^^^^^^^^^^^^^
This part is only used if
this.vga_memory_size is
large enough.
Same as V1 except we do complete redraws instead of using the color-use linked list. Simplifies the pipeline and code significantly.
Host Memory Write ________ Host Memory Read
| _|______ | ^
write | _|______ | | | read
logic | _|______ | |_| | logic
`-------->| | |_| ------------`
| Planes |_| ^ PLOT: Calculates 4 bit / 8 bit color data
|________| | from planes and plots them at the correct
256KiB | | pixel address. Full replots are rare, and
Nomenclature: | | usually only occur during video mode changes.
addr | PLOT | Depends on and is triggered by:
diff_plot_min | | - a host memory write = partial replot
diff_plot_max v | - PEL width, byte/word/dword mode,
______________ | shift mode, addr subst = full replot
| | v - if addr subst: start_addr, offset = full replot
Nomenclature: | Pixel Buffer |
pixel_addr |______________| ^ DRAW: maps pixel color indices to image
diff_addr_min 512KiB | | data. Allows smooth fades and transitions.
diff_addr_max | | Depends on and is triggered by:
| DRAW | - a plot update = partial redraw
v | - dac_map, vga256_palette = complete redraw
VGAScreen.js ______________ ______________ | - Palette bits 4/5/6/7 select
Above | | | | v color plane enable, = full redraw
####################| Image Buffer |##########| Layer Info |#################################################################
Below |______________| |______________| ^ ASSEMBLE: draws fragments of the
ScreenAdapter.js 2MiB | | | Image Data to build the final image.
| | | Allows rapid page flipping,
| ASSEMBLE <-------------` | scrolling, panning, & split screens.
v | Layer Info is determined from:
////////////////// | start_address, horizontal_panning, byte_panning
// Canvas // | line_compare, and registers that affect
////////////////// v screen width/height and plotting location.
Memory Layout:
.-------------------------------------------------------------------------------- - - - ---.
| S V G A M E M O R Y |
|-------------------------------------------------------------------------------- - - - ---|
| vga_memory | | |
| . . . | | |
| plane0 | plane1 | plane2 | plane3 | pixel_buffer | |
`--------^--------^--------^--------^--------------^----------------------------- - - -----`
<-64KiB-><-64KiB-><-64KiB-><-64KiB->
<--------------256KiB--------------> <---512KiB--->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment