Commit Graph

52 Commits

Author SHA1 Message Date
Brad Grantham
704b926a7d Make graphics work in Emscripten target
Set NPOT textures with CLAMP_TO_EDGE so they are WebGL friendly.

Switch from RED to LUMINANCE textures.

Port shaders to GLESSL

    * version 100 instead of 140
    * prepend precision qualifiers for int and float
    * in, out -> attribute, varying (depending on shader)
    * color -> gl_FragColor
    * perform % by subtract x divided and multiplied by modulus
    * use int instead of uint
    * use an if-else chain instead of switch (ugh, should use dependend texture)

Wrap vertex array code in !defined(EMSCRIPTEN)

Wrap glfwSetDropCallback and glfwJoystickPresent in !defined(EMSCRIPTEN)
so that they don't kick out of execution with a JavaScript exception.
2017-01-07 22:58:28 -08:00
Brad Grantham
6870e4f962 Merge branch 'master' into web_target 2017-01-07 15:53:20 -08:00
Brad Grantham
0075ee6b3f Change text and lores shaders from R8UI to RED
Last of the INTEGER textures.

Scale values up from textport so they can be interpreted as byte values.
2017-01-07 15:51:02 -08:00
Brad Grantham
6de05cefb2 Move font texture from R8UI to RED 2017-01-07 15:42:11 -08:00
Brad Grantham
7570a1c842 Move image and hires textures from R8UI to RED
Rename initialize_texture to initialize_texture_integer.

New function initialize_texture that loads a GL_RED texture, and
use it for hires and image shaders.

Don't scale texture values back to 0.0-1.0 in image and hires shaders.
2017-01-07 15:38:54 -08:00
Brad Grantham
7ce091c23e Remove some unnecessary subtrations of 0 2017-01-07 15:27:41 -08:00
Brad Grantham
4460274b75 Fix hires color shader 2017-01-07 15:13:30 -08:00
Brad Grantham
be750dfac4 Use 2D for hires, images textures; not RECTANGLE
Rename "texture" to "opengl_texture" for a touch more readability
and less ambiguity.

Switch hires and image textures to "opengl_texture".

Use coordinate scale for image textures and hires textures in shaders
and pass in as Uniforms
2017-01-07 14:51:29 -08:00
Brad Grantham
4a3dc4a9b7 Fix broken 80-column text 2017-01-07 14:35:00 -08:00
Brad Grantham
3863010d07 Move textport textures from RECTANGLE to 2D
Change initialize_texture to return an object containing width and
height, since the GUI uses textport textures of various sizes.

Add scale factors to text, text80, and lores shaders and set them as Uniforms.
2017-01-07 14:00:46 -08:00
Brad Grantham
c9113ece86 Change font texture from RECTANGLE to 2D
Make new texture function for making 2D textures instead of RECTANGLE
textures.

Pass in scale factor from texel coordinates to UV coordinates.

Change text and text80 fragment shaders to scale texel coordinates
to UV for sampler for font_texture.

Use sampler2D instead of sampler2DRect for font_texture
2017-01-07 13:32:35 -08:00
Brad Grantham
442faa4677 Skip libAO when compiling with Emscripten 2017-01-04 23:19:00 -08:00
Brad Grantham
2e7f809bc9 Fix compile errors caused by moving to range for 2017-01-04 22:09:31 -08:00
Brad Grantham
30ec998252 Use range-for on containers 2017-01-03 09:41:38 -08:00
Brad Grantham
cb60985ef0 Move audio implementation into interface.cpp
Move all libao operation into interface.cpp
This should have the result of removing all AV and GUI code from apple2e.cpp
OS code remaining in apple2e.cpp should basically be only file I/O, console I/O, and chrono.
2016-12-26 22:28:45 -08:00
Brad Grantham
bf7961855f Reduce OpenGL texture download overhead a touch
Store all text and hgr writes in write() in a map.
Later, in apply_writes(), actually download all writes from the map.
This has the effect of downloading only the most recent write.
After implementation, this has the effect in FAST mode on my Mac of only reducing writes by between 0% and 4% in both QUADRADOODLE and LodeRunner.  So probably not worth it.  But maybe worth an interation on this which would mark rows and try to coalesce adjacent writes in X and Y to single texture updates.
2016-12-26 02:00:09 -08:00
Brad Grantham
81a4ab26bd resize to window, fix #3 2016-12-06 20:02:18 -08:00
Brad Grantham
15e0c797bd resize to fit window 2016-12-06 18:58:34 -08:00
Brad Grantham
f7b76a8631 center floppy icons 2016-12-06 00:16:43 -08:00
Brad Grantham
f1bd37a984 HGR colors, label floppy drives
New hirescolor fragment shader
2016-12-05 16:27:59 -08:00
Brad Grantham
66c8945d9f Provide cute floppy icons
New image shader
    Had so much trouble getting hires-like images (MSbit ignored) to work, finally gave up
2016-12-05 10:04:43 -08:00
Brad Grantham
ddf4655a43 Implement 80-column mode - ProDOS boots to 80 cols
Catch ALTCHAR but do nothing about it
Catch VID80 (80VID)
Add aux pages to interface.cpp
Plumb aux pages through apple2e.cpp display_write functions
Implement 80-column text shader using aux page
2016-12-04 22:07:00 -08:00
Brad Grantham
5418de45aa drag files onto screen to paste contents 2016-12-02 14:57:55 -08:00
Brad Grantham
96835e2400 Add drag-and-drop floppies, fix cold-start
On cold-start, force Button0/OpenApple on for a short period
    This is how cold-start (disk boot) is differentiated from plain RESET
Add padding widget that pads another widget on all sides
Add drag-and-drop functionality to widgets and manage through GLFW
Honor current time through all widget methods
Fix character encoding in text_widget (especially for ' ')
Add floppy_icon widget that manages drag-and-drop and drive motor (activity) light
    Later move to vector graphic or bitmap
Add floppy eject and insert notification from APPLE2Einterface
Add activity notification through APPLE2Einterface
Optimize with -O2
2016-12-02 10:42:22 -08:00
Brad Grantham
c5dc2ec782 Honor -fast in UI; lay groundwork for floppy UI 2016-12-01 12:03:40 -08:00
Brad Grantham
824459f575 support an initialization file that provides joystick mapping 2016-11-30 10:27:51 -08:00
Brad Grantham
067b3f4886 Gamepad (Samsung EI-GP20 tested) 2016-11-30 09:58:58 -08:00
Brad Grantham
ed8dfa33ea Rudimentary paddle support, fix audio stuttering
Mouse/Trackpad drag across the screen emulates paddles
Click on the screen emulates button 0
Ignore reads from C020 (tape out)
Add BRA instruction for 65C02 (maybe not necessary)
Disable audio in FAST mode
Throttle a little better when audio is enabled - stopped stutter
2016-11-29 22:17:17 -08:00
Brad Grantham
0687587428 Make all screen elements widgets
Widget for Apple 2 screen (graphics and textport)
Make box be vertical or horizontal
Add spacer widget
Fix calls to draw, click, drag, release to reflect whole screen being a widget
Fix #16
2016-11-29 13:16:20 -08:00
Brad Grantham
91e8aaf726 Widgets draw in area, and implement centering widget, fixing #7 and fixing #6 2016-11-28 18:43:53 -08:00
Brad Grantham
577a806799 Key repeat, fixes #21 2016-11-28 17:17:57 -08:00
Brad Grantham
ca376dab5a CAPS lock, More instructions and compatibility
GLFW doesn't pass through Mac CAPS lock key for some reason.
CAPS button in GUI works, though.
Implement more instructions, mostly for ChopLifter
    DEC abs, X
    INC abs, X
    AND (ind), Y
    AND abs, X
    ROR abs
Now ChopLifter needs unimplemented SED!  Probably uses decimal mode while printing score.
Set "then" at end of CPU loop to try to throttle better.  Not sure it helps.
2016-11-28 14:22:22 -08:00
Brad Grantham
604bf07b4f Partially implement floppy disks
Floppy disks partially work:
    apple2e -noaudio -fast -diskII disk2romfile {floppy1name,"none"} {floppy2name,"none"} apple2e.rom

Import nybblizer from Shamus but only DOS
Support floppy hardware
    track motor stepper
    enable
    read
Add -noaudio (otherwise execution is throttled by waits once audio buffer is filled)
Only read ROM at D000 and E000 if C08X_read_RAM isn't turned on
RAMRD, RAMWRT, and ALTZP are implemented, note them as such in constructor
Correctly decode C08X soft switches
Implement a bunch more instructions
    INC abs
    LDY abs, X
    SBC abs, Y
    ADC abs
    ASL abs
    LSR abs, X
    ORA abs
    ORA abs, X
    AND abs, Y
    STA (ind, X)
    LDX abs
    CPX abs
    EOR (ind, X)
    EOR abs
    EOR abs, X
    STX abs
Throttle to actual number of clocks per instruction
Temporarily enable "Fake6502" instead of my CPU because there's an obvious difference
Better blink speed in interface.cpp
2016-11-27 17:10:03 -08:00
Brad Grantham
97e5923939 fix paste to only work with SUPER key (CMD on Mac), fix #4 2016-11-23 22:20:04 -08:00
Brad Grantham
e9453b7fe7 use RED_INTEGER instead of RED_INTEGER_EXT, lose glext.h 2016-11-23 21:15:39 -08:00
Brad Grantham
df043ec9a0 fixup font lookup, solving off-by-one-pixel issue 2016-11-23 15:43:57 -08:00
Brad Grantham
4db793add1 PAUSE button works, CAPS and COLOR unimplemented 2016-11-23 10:53:56 -08:00
Brad Grantham
ff9f29ef9d name size getter more correctly; add some notes 2016-11-23 10:34:15 -08:00
Brad Grantham
f204764575 Add buttons for REBOOT, FAST
Factor out "text_widget" that can draw text
Change "button" widget to "momentary"
Add new "toggle" widget
Use vbox to contain all buttons
2016-11-22 20:02:49 -08:00
Brad Grantham
7f8539ae00 Add RESET button
Add button class to interface
Check for press/drag/release of RESET button
Add FG and BG color for textport shader (for active button)
Handle RESET and REBOOT events in main loop
2016-11-22 16:09:48 -08:00
Brad Grantham
8103d2a10f Correctly issue "lores" shader uniforms 2016-11-22 09:49:58 -08:00
Brad Grantham
faea049a6b Screen projection matrix to shaders for regularity
Multiply by a matrix in vertex shaders to convert from pixel
coordinates to window coordinates, moving that operation out to a
centralized place in the application.
2016-11-21 18:56:31 -08:00
Brad Grantham
c9cf0a753a remove debugging border 2016-11-20 14:25:18 -08:00
Brad Grantham
5a3c9deb21 Fix viewport. Some factoring.
Factor out shader binding for code simplification.
Factor out making vertex array in anticipation of UI buttons.
Change "mode" to "display_mode".
Fix setting of glViewport on window resize
2016-11-20 14:21:49 -08:00
Brad Grantham
eec4926c50 properly output and use checkerboard char 2016-11-19 00:57:42 -08:00
Brad Grantham
32854e2246 implement paste through interface 2016-11-19 00:45:39 -08:00
Brad Grantham
7192c35a42 blink text 2016-11-18 23:55:28 -08:00
Brad Grantham
21e800658c LORES ("GR") mode and inverse text
Add lores shader and implement in redraw
Handle inverse text, but it indicates glyph lookup or raster location is off by one, not sure what's going on there.
2016-11-18 23:17:07 -08:00
Brad Grantham
cabfe5191e Mostly rewrite graphics to use shaders
Move to GL 3.2
Draw a quad with shaders depending on the mode in that part of the screen
    HIRES shader reads from hires texture
    TEXTPORT shader reads from textpor texture and indirects through a font
      to get pixel values
MIXED now supported
Still to do: BLINK text, INVERSE text, LORES, gang up HGR memory updates
Why doesn't cursor flash the checkerboard?
2016-11-18 20:54:19 -08:00
Brad Grantham
dac35cccb1 hires graphics in a separate window 2016-11-16 22:50:09 -08:00