6502 assembly language routines

bbc micro/electron/atom/risc os coding queries and routines
Post Reply
User avatar
deanb01
Posts: 29
Joined: Sun Feb 16, 2020 11:24 pm
Location: Manchester, UK
Contact:

6502 assembly language routines

Post by deanb01 »

I've started porting my Z80 library routines (originally written for the ZX Spectrum) to 6502 for the Beeb/Electron. So far ported fast plot, line and circle (Mode 2), a simple sprite handler and a handful of other routines.

The sprite routine in particular, is heavily influenced by one published by Kevin Edwards in The Micro User (1985).

These are available on GitHub, warts and all, under an MIT license, are currently a work-in-progress, and will be updated on a semi-regular basis.

https://github.com/breakintoprogram/lib-acorn-bbc

I'm doing this to brush up on my 6502, and learn more about programming the Beeb, and sharing in case they may be of use to others.
π—₯π—²π˜π—Ώπ—Ό π—–π—Όπ—Ίπ—½π˜‚π˜π—²π—Ώ π——π—²π˜ƒπ—²π—Ήπ—Όπ—½π—²π—Ώ & π—”π—Ώπ—°π—΅π—Άπ˜ƒπ—Άπ˜€π˜
Programming and Restoring Retro Computers from Acorn to ZX81
http://www.breakintoprogram.co.uk/
User avatar
BigEd
Posts: 3876
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: 6502 assembly language routines

Post by BigEd »

Nice one - thanks for sharing, and using an open source license.
User avatar
tricky
Posts: 5137
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: 6502 assembly language routines

Post by tricky »

Looks good.
I would have to reverse the loops to remove the compares :oops:
Have you read the threads on fast line drawing and the EOR filling routine?
User avatar
0xC0DE
Posts: 860
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: 6502 assembly language routines

Post by 0xC0DE »

Thanks for contributing these to the community, Dean! =D>
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my games and demos for Acorn Electron and BBC Micro
User avatar
deanb01
Posts: 29
Joined: Sun Feb 16, 2020 11:24 pm
Location: Manchester, UK
Contact:

Re: 6502 assembly language routines

Post by deanb01 »

tricky wrote: ↑
Sun Nov 01, 2020 12:11 pm
Looks good.
I would have to reverse the loops to remove the compares :oops:
Have you read the threads on fast line drawing and the EOR filling routine?
Thank you!
I think for the line/circle routine I'd probably do what I did on the Spectrum version, calculate the screen address once, then as the pixel moves, just increment/decrement address and plot pixel(s) accordingly. Should save a considerable number of cycles from the loop, though will make the circle routine fun - tracking 4 lots of screen row addresses and 8 pixel positions!
My 6502 is sub-optimal at the moment - it's been 20-odd years since I last coded it (on the NES), and I'm much more proficient in Z80, so happy to pick up any tips from the pros. And I know very little about the Beeb hardware!
π—₯π—²π˜π—Ώπ—Ό π—–π—Όπ—Ίπ—½π˜‚π˜π—²π—Ώ π——π—²π˜ƒπ—²π—Ήπ—Όπ—½π—²π—Ώ & π—”π—Ώπ—°π—΅π—Άπ˜ƒπ—Άπ˜€π˜
Programming and Restoring Retro Computers from Acorn to ZX81
http://www.breakintoprogram.co.uk/
User avatar
deanb01
Posts: 29
Joined: Sun Feb 16, 2020 11:24 pm
Location: Manchester, UK
Contact:

Re: 6502 assembly language routines

Post by deanb01 »

BigEd wrote: ↑
Sun Nov 01, 2020 12:10 pm
Nice one - thanks for sharing, and using an open source license.
Thank you!
π—₯π—²π˜π—Ώπ—Ό π—–π—Όπ—Ίπ—½π˜‚π˜π—²π—Ώ π——π—²π˜ƒπ—²π—Ήπ—Όπ—½π—²π—Ώ & π—”π—Ώπ—°π—΅π—Άπ˜ƒπ—Άπ˜€π˜
Programming and Restoring Retro Computers from Acorn to ZX81
http://www.breakintoprogram.co.uk/
User avatar
deanb01
Posts: 29
Joined: Sun Feb 16, 2020 11:24 pm
Location: Manchester, UK
Contact:

Re: 6502 assembly language routines

Post by deanb01 »

0xC0DE wrote: ↑
Sun Nov 01, 2020 2:00 pm
Thanks for contributing these to the community, Dean! =D>
No worries - as long as folk are happy to put up with my pidgin 6502! Glad the Acorn community is alive and well. Partly got you to blame for getting me hooked with my Electron by the way!! :D
π—₯π—²π˜π—Ώπ—Ό π—–π—Όπ—Ίπ—½π˜‚π˜π—²π—Ώ π——π—²π˜ƒπ—²π—Ήπ—Όπ—½π—²π—Ώ & π—”π—Ώπ—°π—΅π—Άπ˜ƒπ—Άπ˜€π˜
Programming and Restoring Retro Computers from Acorn to ZX81
http://www.breakintoprogram.co.uk/
User avatar
0xC0DE
Posts: 860
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: 6502 assembly language routines

Post by 0xC0DE »

deanb01 wrote: ↑
Sun Nov 01, 2020 3:41 pm
0xC0DE wrote: ↑
Sun Nov 01, 2020 2:00 pm
Thanks for contributing these to the community, Dean! =D>
No worries - as long as folk are happy to put up with my pidgin 6502! Glad the Acorn community is alive and well. Partly got you to blame for getting me hooked with my Electron by the way!! :D
You're welcome!
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my games and demos for Acorn Electron and BBC Micro
User avatar
alastairhm
Posts: 15
Joined: Fri Nov 22, 2019 1:28 pm
Contact:

Re: 6502 assembly language routines

Post by alastairhm »

Looks like a good resource, I'm sure I'll make use of it on my trip back into 6502.

Is there a "best practice" way to include these libraries in your own code?

With beebasm, I've been playing about with INCLUDE keyword.

Code: Select all

 \ Example 3.2

 INCLUDE "../../lib/constants.asm"
 screen = &7E40
 mode   = 6

 ORG &2000

 .start
     LDA mode
     JSR screenmode
     LDX #0
     LDY #0
     JSR tab
     LDA #15
     JSR printhex
     LDX #0
     LDY #1
     JSR tab
     LDA #&32
     JSR printhex
 .finish
     RTS
 .screenmode
     INCLUDE "../../lib/screenmode.asm"
 .printhex
     INCLUDE "../../lib/printhex.asm"
 .tab
     INCLUDE "../../lib/tab.asm"
 .end

 SAVE "MyCode", start, end
Post Reply

Return to β€œprogramming”