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.
6502 assembly language routines
6502 assembly language routines
π₯π²ππΏπΌ ππΌπΊπ½πππ²πΏ ππ²ππ²πΉπΌπ½π²πΏ & ππΏπ°π΅πΆππΆππ
Programming and Restoring Retro Computers from Acorn to ZX81
http://www.breakintoprogram.co.uk/
Programming and Restoring Retro Computers from Acorn to ZX81
http://www.breakintoprogram.co.uk/
Re: 6502 assembly language routines
Nice one - thanks for sharing, and using an open source license.
Re: 6502 assembly language routines
Looks good.
I would have to reverse the loops to remove the compares
Have you read the threads on fast line drawing and the EOR filling routine?
I would have to reverse the loops to remove the compares

Have you read the threads on fast line drawing and the EOR filling routine?
Re: 6502 assembly language routines
Thanks for contributing these to the community, Dean! 

0xC0DE
"I program my home computer / Beam myself into the future"
Follow me on Twitter
Visit my YouTube channel featuring my games and demos for Acorn Electron and BBC Micro
"I program my home computer / Beam myself into the future"


Re: 6502 assembly language routines
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/
Programming and Restoring Retro Computers from Acorn to ZX81
http://www.breakintoprogram.co.uk/
Re: 6502 assembly language routines
Thank you!
π₯π²ππΏπΌ ππΌπΊπ½πππ²πΏ ππ²ππ²πΉπΌπ½π²πΏ & ππΏπ°π΅πΆππΆππ
Programming and Restoring Retro Computers from Acorn to ZX81
http://www.breakintoprogram.co.uk/
Programming and Restoring Retro Computers from Acorn to ZX81
http://www.breakintoprogram.co.uk/
Re: 6502 assembly language routines
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!!

π₯π²ππΏπΌ ππΌπΊπ½πππ²πΏ ππ²ππ²πΉπΌπ½π²πΏ & ππΏπ°π΅πΆππΆππ
Programming and Restoring Retro Computers from Acorn to ZX81
http://www.breakintoprogram.co.uk/
Programming and Restoring Retro Computers from Acorn to ZX81
http://www.breakintoprogram.co.uk/
Re: 6502 assembly language routines
You're welcome!
0xC0DE
"I program my home computer / Beam myself into the future"
Follow me on Twitter
Visit my YouTube channel featuring my games and demos for Acorn Electron and BBC Micro
"I program my home computer / Beam myself into the future"


- alastairhm
- Posts: 15
- Joined: Fri Nov 22, 2019 1:28 pm
- Contact:
Re: 6502 assembly language routines
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.
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