Skip to content

Instantly share code, notes, and snippets.

View ErnWong's full-sized avatar
🦆

Ernest Wong ErnWong

🦆
View GitHub Profile
@ErnWong
ErnWong / default.html
Last active August 29, 2015 14:02
Stackedit Template
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><%= documentTitle %></title>
<link rel="stylesheet" href="https://stackedit.io/res-min/themes/base.css" />
<link rel="stylesheet" href="https://googledrive.com/host/0B72MM6AmH2NackJORmN6M3VFRTA/roboto.css" />
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
"HTML-CSS": {
@ErnWong
ErnWong / install-dev.ps1
Last active October 2, 2015 20:59
Scoop install, but using development fork
$scoopscript = (new-object net.webclient).downloadstring('https://raw.github.com/ErnWong/scoop/dev-portable/bin/install.ps1'); iex ("$scoopscript" -replace 'lukesampson', 'ErnWong' -replace 'master', 'dev-portable')
@ErnWong
ErnWong / Class.js
Created December 14, 2012 04:38
Javascript Inheritance in Different Ways.
// Parent:
function Book() {
// there could be a lot of things here
};
Book.prototype.read = function( lowerLimit, upperLimit ) {};
// 1.
function BIGBook() {};
BIGBook.prototype.read = Book.prototype.read;
BIGBook.prototype.ripPages = function( lowerLimit, upperLimit ) {};
@ErnWong
ErnWong / windows98-v86Box.05.config0.a1.mpu-butdma.log
Created November 17, 2017 09:51
Sound Blaster 16 Emulation Logs
log.js:13 21:58:39+758 [IO ] mmap_register addr=0x20000000 size=0xE0000000
log.js:13 21:58:39+783 [IO ] mmap_register addr=0xFEB00000 size=0x00100000
log.js:13 21:58:39+784 [IO ] mmap_register addr=0xFFF00000 size=0x00100000
log.js:13 21:58:39+804 [IO ] mmap_register addr=0x000A0000 size=0x00020000
log.js:13 21:58:39+804 [IO ] mmap_register addr=0xE0000000 size=0x02000000
log.js:13 21:58:40+074 [IO ] write8 port #0x000D <- 0x00 (PORT_DMA1_MASTER_CLEAR)
log.js:13 21:58:40+076 [IO ] write8 port #0x00DA <- 0x00 (PORT_DMA2_MASTER_CLEAR)
log.js:13 21:58:40+077 [IO ] write8 port #0x00D6 <- 0xC0 (PORT_DMA2_MODE_REG)
log.js:13 21:58:40+078 [IO ] write8 port #0x00D4 <- 0x00 (PORT_DMA2_MASK_REG)
log.js:13 21:58:40+183 [IO ] Read from unmapped memory space, addr=0xFEE00030
@ErnWong
ErnWong / windows98-startup.log
Created December 10, 2017 08:27
v86 Sound Blaster and DMA logs during startup
log.js:13 21:19:05+228 [SB16] lower irq
log.js:13 21:19:05+374 [DMA ] mode write [4] = 0xC0
log.js:13 21:19:05+375 [DMA ] singlechannel mask write [4] = false
log.js:13 21:19:19+399 [DMA ] flipflop reset
log.js:13 21:19:19+401 [DMA ] flipflop reset
log.js:13 21:19:19+401 [DMA ] page read [0]
log.js:13 21:19:19+404 [DMA ] addr read [0] -> 0x0
log.js:13 21:19:19+408 [DMA ] addr read [0] -> 0x0
log.js:13 21:19:19+408 [DMA ] count read [0] -> 0x0
log.js:13 21:19:19+410 [DMA ] count read [0] -> 0x0
@ErnWong
ErnWong / README.markdown
Last active January 3, 2018 09:19
WIP Model of the IBM VGA.

Things yet to add in this little model:

  • Use Offset register to reinitialize the address after horizontal retrace
  • Retrace signals
  • Line Compare register for split screens
  • Start Address for page flipping
  • Display enable signals
  • There is a register field in the Miscellaneous Graphics Register, called the Chain Odd/Even Enable bit. From the manual: "When set to 1, this bit directs the system address bit, A0, to be replaced by a higher-order bit. The odd map is then selected when A0 is 1, and the even map when A0 is 0." What exactly is this higher order bit? If it is bit 16, as people seem to say on https://www.vogons.org/viewtopic.php?f=9&amp;t=53803, then the display buffer addresses will all be odd addresses in VGA mode 4h/5h because all the system address are between 0xB8000 and 0xBBFFF, which does not make sense.
@ErnWong
ErnWong / ReactOS startup screen v86 vga.log
Created January 16, 2018 09:18
ReactOS startup screen v86 vga - wrong color
log.js:13 22:09:56+519 [VGA ] complete redraw
log.js:13 22:09:56+547 [VGA ] dac set color, index=0x0 value=0x0
log.js:13 22:09:56+549 [VGA ] dac set color, index=0x1 value=0x404
log.js:13 22:09:56+551 [VGA ] dac set color, index=0x2 value=0x404
log.js:13 22:09:56+555 [VGA ] dac set color, index=0x3 value=0x40404
log.js:13 22:09:56+557 [VGA ] dac set color, index=0x4 value=0x40408
log.js:13 22:09:56+558 [VGA ] dac set color, index=0x5 value=0x4080C
log.js:13 22:09:56+560 [VGA ] dac set color, index=0x6 value=0xC0C0C
log.js:13 22:09:56+564 [VGA ] dac set color, index=0x7 value=0x80C10
@ErnWong
ErnWong / VGA Data Pipeline V2.txt
Last active January 19, 2018 01:49
v86 VGA Implementation
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
@ErnWong
ErnWong / v86_debug_tools.js
Last active February 16, 2018 02:22
Additional tools for debugging v86 programs
// Searches memory for specific sequence represented by string
// want = desired string sequence
// buf = memory buffer
// skip = spacing between each consequtive element of the sequence in the buf to find
function find_str_in_mem(want, buf, skip) {
skip = skip || 1;
var wantbuf = new Uint8Array(want.length);
for (let i = 0; i < want.length; i++) {
wantbuf[i] = want.charCodeAt(i);
}
@ErnWong
ErnWong / zigzag.js
Created July 21, 2019 09:21
Zigzag CSS pattern
function generateZigZag(size, thickness) {
const ratio = (thickness / size / 2) * 100;
const quadrantMain = `transparent ${25 - ratio}%, black ${25 - ratio}%, black 25%, transparent 25%`;
const quadrantTip = `black ${ratio}%, transparent ${ratio}%`;
return {
background: [
`linear-gradient(-45deg, ${quadrantTip}) ${-size}px ${size}px`,
`linear-gradient(-45deg, ${quadrantTip}) 0 ${size}px`,
`linear-gradient(-135deg, ${quadrantTip}) ${-size}px ${-size}px`,
`linear-gradient(-135deg, ${quadrantTip}) 0 ${-size}px`,