Commit graph

1447 commits

Author SHA1 Message Date
Ernest Wong 0766da0fa0 Only use vga color linked list for small changes 2018-01-23 11:36:45 -06:00
Ernest Wong 0cc9b3651f Tidyup: use double quotes 2018-01-23 11:36:45 -06:00
Ernest Wong 868834974b Fix vga color use linked list corrupted values
dac_color_use_set was called with addr values outside the range
of the pixel buffer, and corrupted the linked list "root" pointers

Fixes the flashes of wrong color on some games.
2018-01-23 11:36:45 -06:00
Ernest Wong 465dd6fc94 Tidy up: remove unnecessary comment, add semicolon 2018-01-23 11:36:45 -06:00
Ernest Wong 964691eaa5 Toggle vga 3DA value manually during text mode
Fixes some infinite loops on some programs
2018-01-23 11:36:45 -06:00
Ernest Wong 1abb0895c8 Tidy: comments, unused code, naming convention 2018-01-23 11:36:45 -06:00
Ernest Wong 2a74c9d5af Implement generalized vga pipeline
Big Picture:
https://gist.github.com/ErnWong/7db67164224aaa3be5f6fcc2a6f5dd21

Fixes #26, and fixes #179.

Implements:
 - mode 4/5, x, and everything in between
 - page flipping, panning, split screen
 - transitions and animations that depend on changing dac_map and
vga256_palette.
 - a linked list to keep track of what pixels have what color, so in
theory it doesn't need to redraw the entire buffer every time the
palettes are modified. Currently slow and incorrect.
 - improved display-disable signal timing (port 3DA)

Changes:

 - Add layering concept to ScreenAdapter. The idea is that using the
built-in drawImageData to handle the split screens, panning, and page
flipping would be more efficient than writing a loop to recopy pixels
one by one.

 - All video modes are now handled by the same generalized pipeline, so
non-standard video modes and configurations such as Mode X will work.

 - Video size and buffer size are now determined from register values.

 - The code for converting the plane write data into pixel colors (also
known as the "shifting" or the "serializing" step) is deferred until the
next fill-buffer event. This appears to make programs (esp. games) run
smoother. See vga_replot

 - Separate VGA redraw from SVGA 8 bpp redraw
2018-01-23 11:36:45 -06:00
Ernest Wong c5d178a4d5 Copy the very last byte of modified video memory 2018-01-23 11:36:45 -06:00
Ernest Wong 8cb19bf3f9 Fix VGA write mode 3 typo
Fixes the Black Book's sample programs:
L26-1, L26-2, L28-3.

Does not fix L27-3.
2018-01-23 11:36:45 -06:00
Ernest Wong 5901c531ec Don't store derived states unless necessary 2018-01-23 11:36:45 -06:00
Ernest Wong 1c04a9ebb1 Tidy: vars and avoid non-op syntax sugar 2018-01-23 11:36:45 -06:00
Ernest Wong 7b6d901b5d Fix comments for vga planar shift mode
I got the shift modes mixed up. The original descriptive comment is
back.
2018-01-23 11:36:45 -06:00
Ernest Wong 7373a7ea30 Tidy: spacing and semicolons 2018-01-23 11:36:45 -06:00
Ernest Wong c471abc566 Simply call set_size_graphical after state restore
I misunderstood things: svga_width and height are set for non-vga modes,
but not svga_bpp. Left a todo comment to clear things up in the future.
2018-01-23 11:36:45 -06:00
Ernest Wong 4f0c35aa68 Tidy vga latch states and implement read mode 1 2018-01-23 11:36:45 -06:00
Ernest Wong 37b3b67ce5 Add new vga states to set/get_state
- Also expand the dword states
- Also set the appropriate graphical vga mode
2018-01-23 11:36:45 -06:00
Ernest Wong 10dae9deba Implement all vga planar write modes
- Write modes 0, 1, 2, 3
- Set/reset circuitry
- Barrel shifter (planar rotation)
- Use single 32bit dword to represent all 4 plane bytes
2018-01-23 11:36:45 -06:00
Ernest Wong 41b9d9935e Add reference to issue 165 2018-01-18 18:47:46 -06:00
Ernest Wong 7c4dd5fd46 Detect and trigger AltKey keyup, fixes #165
Firefox 57 and Edge 41 do not emit keyup event for the alt key when the
alt key is pressed with other keys -- occurs on Windows 10. Firefox
appears to emit the event in Ubuntu though.

This patch is tested on Firefox (Ubuntu Xenial and Windows 10) and
Chrome.
2018-01-18 18:47:46 -06:00
Ben 153c50f257 Allow the QEMU test to fail
I haven't seen this one work yet. *shrugs*
2018-01-14 12:06:58 -06:00
Amaan Cheval 6c44a716cc Update copyright year to 2018 2018-01-02 11:03:22 -06:00
Ernest Wong b22826525b Fix duplicated code after FloatQueue rewrite 2017-12-16 22:51:40 -06:00
Ernest Wong a3a1414b5a Avoid unnecessary audio recalculations in a loop 2017-12-16 22:51:40 -06:00
Ernest Wong 147cc8bf37 Rewrite FloatQueue to prototypical notation 2017-12-16 22:51:40 -06:00
Ernest Wong c017373c76 Avoid unnecessary copying of buffers. 2017-12-16 22:51:40 -06:00
Ernest Wong 9fa0fcd9b2 Reduce audio processor overhead when paused
First attempt: when pausing, clear the output buffers once using .fill(0)
during the onaudioprocess event, and set a flag so that it doesn't
have to continuously .fill(0) the buffers when paused.

Problem with first attempt: It appears that performing .fill(0) once does
not guarantee clearing all the buffer that is given to the onaudioprocess
event, probably because the output buffers given are a subarray of a larger
buffer.

In this second attempt, we simply disconnect the processor node from the
destination node, and reconnect them when unpaused.
2017-12-16 22:51:40 -06:00
Ernest Wong 531f5ba84f Warn if pit counter larger than reload value
- Code by @copy
- Improves commit 8b6115d
2017-12-16 22:51:40 -06:00
Ernest Wong 326ab8cf07 Schedule audio values instead of the .value setter
This is about the use of Web Audio API in the speaker adapter.

- Removes the compiler deprecation warning about removed dezippering.
  See https://www.chromestatus.com/feature/5287995770929152
- Setting the parameter using .value can be ignored if other automation
  events are scheduled.
  See https://developer.mozilla.org/en-US/docs/Web/API/AudioParam
2017-12-16 22:51:40 -06:00
Ernest Wong a185fd13bc Tidy up: spacing, quotes, and line length.
- Space before ? in ternary operators
- Double quotes ' -> "
- Line length of 100
2017-12-16 22:51:40 -06:00
Ernest Wong 0ec16f5a03 Tidyup: use underscore naming 2017-12-16 22:51:40 -06:00
Ernest Wong d793d2eb51 Simplify FloatQueue.shiftBlock logic 2017-12-16 22:51:40 -06:00
Ernest Wong 833bc52df1 Move samplerate broadcast out of hot code 2017-12-16 22:51:40 -06:00
Ernest Wong dfd3202149 Send audio data only through bus
Problem: transferring ownership of the audio Float32Array buffers from
the speaker adapter to sb16 does not appear to work.

Demo: https://jsbin.com/vilafof/edit?html,js,output

This is probably because:

> the returned AudioBuffer is only valid in the scope of the
> onaudioprocess function.
(https://developer.mozilla.org/en-US/docs/Web/API/AudioProcessingEvent)

and probably because transferring ownership will make the buffer
unreadable in the non-worker thread.

Solution: send data through to the speaker adapter directly using the
bus. The sb16.dac_buffers has been modified to allow shifting out a chunk of
consequtive elements more efficiently.
2017-12-16 22:51:40 -06:00
Ernest Wong da0ffc4c20 Transfer ownership of buffers to sb16 onprocess
Don't send entire event object through as that is not compatible with
worker_bus.
2017-12-16 22:51:40 -06:00
Ernest Wong 1f8cfb41ff Pause sb16 when cpu is paused or via pause command
Previously, when the cpu is paused, sb16 continues to perform dma
transfers and the speaker continues to play the audio stored in the
buffer (looping), which is not what we want.

More importantly, when we pause the cpu to save the machine state,
because sb16 was continuing with its dma transfers, the machine might
restore back into a confused and muddled state.
2017-12-16 22:51:40 -06:00
Ernest Wong eb7c333a2e Tidy up unimplemented FM Synthesizer code 2017-12-16 22:51:40 -06:00
Ernest Wong 27789b7797 Realign sb16 state variables 2017-12-16 22:51:40 -06:00
Ernest Wong f30ddbd400 Prefix constants & avoid contextless magic numbers 2017-12-16 22:51:40 -06:00
Ernest Wong dd7f845e57 Make DMA on_unmask states restorable
Instead of registering an on_unmask listener every time we want a
transfer, and unregistering the listener every time we're done with it,
SB16 now registers a handler during init, and keeps this handler
registered throughout the session. The handler function is moved to SB16's
prototype.

The dma_waiting_transfer flag indicates whether the handler should
actually carry out the transfer.
2017-12-16 22:51:40 -06:00
Ernest Wong 1c092c215c Send via bus the required data only (pc speakers) 2017-12-16 22:51:40 -06:00
Ernest Wong ac8284f893 Remove DMA identification routine
Reasons:
- Incompatible licensing with dosbox's GPL license
- Couldn't find documentation
- Routine not used yet
- Not understood by me
2017-12-16 22:51:40 -06:00
Ernest Wong 584548de5c Tidy code
- Constant variable names to uppercase.
- Consistent use of spacing and semicolons.
- Avoid recursion.
- Prefer bitwise operators.
- Place operators before line continuation (to disambiguate problems
associated with automatic semicolon insertion).
2017-12-16 22:51:40 -06:00
Ernest Wong a9a29325e1 Remove speaker debugging code in production build 2017-12-16 22:51:40 -06:00
Ernest Wong 7d3c89241c Warn and abstain if AudioContext not available 2017-12-16 22:51:40 -06:00
Ernest Wong 0c439694b1 Begin plan for FM synthesizer 2017-12-16 22:51:40 -06:00
Ernest Wong edf589cc46 Nuke commented out old dma.js code
This is what version control is for right? Silly me.
2017-12-16 22:51:40 -06:00
Ernest Wong 0a5d5430d3 Improve consistent style and clarity 2017-12-16 22:51:40 -06:00
Ernest Wong 72f3a89e8f Disable stereo byte counting. Sound is now working!
Not just working, but super smooth and crisp with no distortion.
Well, except for the wrong pitch due to a very cheap method of sampling
rate conversion. However, that's an aesthetic problem for the future.

🎉 Celebrate? 🎉
2017-12-16 22:51:40 -06:00
Ernest Wong c43a21ad1b Add reminder todo for sb16 set transfer size. 2017-12-16 22:51:40 -06:00
Ernest Wong d0d96497f6 Changed sb16 dma block size. Investigate effect.
After "fixing" the dma address incrementation, the sounds are now
highly distorted with seemingly garbage signal. The dma block size is
increased to investigate this newly formed bug.
2017-12-16 22:51:40 -06:00