6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 21, 2024 9:41 am

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun Sep 24, 2023 4:54 pm 
Offline

Joined: Sun Sep 24, 2023 3:45 pm
Posts: 47
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:
http://forum.6502.org/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.http://forum.6502.org/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.


Top
 Profile  
Reply with quote  
PostPosted: Sun Sep 24, 2023 7:54 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
NormalLuser wrote:
I'm open to any suggestions of resources for what else to add or where I can find some useful code examples.


Sounds good...

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/


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 25, 2023 12:46 am 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3367
Location: Ontario, Canada
NormalLuser wrote:
While I've read a lot, this is my first post here.
Nice to have you with us, NormalLuser! Welcome. :)

-- Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 25, 2023 4:05 am 
Offline

Joined: Sun Sep 24, 2023 3:45 pm
Posts: 47
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: