Hello 6502 people.
While I've read a lot, this is my first post here.
I've been working on adding routines I'm creating for another project to EhBasic for a little while now and I thought I'd let the folks around here know in case it is of interest to anyone.
Thanks to this video from visrealm:
viewtopic.php?f=5&t=7459
And lots of older posts around here and from Lee himself I've been able to add commands to EhBasic to support graphics and sound on my Ben Eater 6502 + Worlds Worst Video card kits.
Here is the code for that:
https://github.com/Fifty1Ford/BeEhBasic
I made several GFX commands to blit image data onto the bitmapped screen including with transparency and with a self erasing outline with the color of your choice. A plot, and a horizontal line etc.
I made a few hardware changes also.
I've added the BEEP command using PB7 on the VIA hooked to a speaker per one of the posts here.viewtopic.php?f=2&t=562
adding a speaker with a capacitor and resistor.
Added capacitors and extra power wires so I can clock faster.
I also hooked a jumper up from the VGA V-sync to the CPU NMI. Some hack-y code that probably ruins the EhBasic
interrupt handler gives me a countdown timer on that v-sync interrupt now.
And lastly 3 more 74 series gates so I could turn some unmapped RAM into a hardware double buffer for the Worlds Worst Video Card kit.
Commands added:
PAUSE - timer does not use via, adjust for CPU speed
PEN - sets plot color 0-256, colors repeat every 64
PLOT - Plots to screen x/y 0-99 width, 0-63 height. No bounds checking. Draws off screen can cause issues.
CLS - Clears the screen (fill black) also stops any BEEP
GFXH - Horizontal line from location of last PLOT. length
GFXV - Vertical line from location of last PLOT. length
GSET - sets size of adjustable size sprite Width, Height/2
GFX - Fixed size sprite routine. x/y location
GFXA- Adjustable size draw/sprite routine. Background color boarder for 0 color. x/y location
GFXS- Simple adjustable sprite. x/y location
GFXT - Adjustable Transparent sprite. Color 0 is transparent. x/y location
COLOR - Fills screen a single color and also sets the BackColor in zero page.
MOVE - Self erasing pixel. Will remember last color when moved and redraw. x/y
BEEP - Square wave on PB7 VIA. 0 to 255 for tone.
BSET - Turns double buffer on/off. 1 on 0 off.
BUFF - Swaps buffer. (toggles PB0 on and off on VIA)
BUFV - Swaps buffer but waits for a V-sync NMI first.
I'm open to any suggestions of resources for what else to add or where I can find some useful code examples.
Graphics routines for Ben Eater6502+Worlds Worst Video Card
-
NormalLuser
- Posts: 48
- Joined: 24 Sep 2023
Re: Graphics routines for Ben Eater6502+Worlds Worst Video C
NormalLuser wrote:
I'm open to any suggestions of resources for what else to add or where I can find some useful code examples.
Some suggestions - it might be worth while doing range checking on the point plot stuff - will stop all sorts of memory issues due to an errant program...
Lines - lookup the Bressenham line drawing algorithm.
Circles - The Midpoint circle algorithm (sometimes called Bressenhams Circle algorithm)
Line clipping - Cohen-Sutherland - but if you clip the lines (so they don't draw off-screen), then you can call a non-range checking version of your plot point code for speed.
Color is of-course spelt colour
Rectangles - draw solid ones by drawing horizontal lines - which are easier to optimise for.
Then add a "paddle" input by using a 555 timer (copy the Apple II schematic) then... Breakout!
Cheers,
-Gordon
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
Re: Graphics routines for Ben Eater6502+Worlds Worst Video C
NormalLuser wrote:
While I've read a lot, this is my first post here.
-- Jeff
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html
https://laughtonelectronics.com/Arcana/ ... mmary.html
-
NormalLuser
- Posts: 48
- Joined: 24 Sep 2023
Re: Graphics routines for Ben Eater6502+Worlds Worst Video C
Thanks Jeff!
Great suggestions Gordon! I never heard the term Line Clipping until your post and now I've just spent too much time reading Wikipedia articles on line clipping algorithms.
I plan a demo with lots of lines of different color and maybe gray and this will help me analyze the problem and plow through my program.
Great suggestions Gordon! I never heard the term Line Clipping until your post and now I've just spent too much time reading Wikipedia articles on line clipping algorithms.
I plan a demo with lots of lines of different color and maybe gray and this will help me analyze the problem and plow through my program.