djmips Posted June 12, 2005 Share Posted June 12, 2005 (edited) As I was growing up, I kept a notebook full of cool code snippets and ideas. My notebook had been misplaced but I ran across it recently and here is one of the pages which is from a 1987 Dr. Dobbs article by Mark S. Ackerman. "6502 Killer Hacks". Post your own 6502 Killer Hacks and share them with the rest of us! I also checked into Mark S. Ackerman with our trusty tool Google and found his 'vita' - Pretty sure it's the same guy as he worked at GCC from 1982 - 1984 and was the lead on Ms. PacMan, Galaxian and Moon Patrol - time to update AtariAge database as these games are empty when it comes to staff He has a patent on the Galaxian kernel. Well here is the killer hack. This one is to scrimp on RAM. Incrementing only the lower 4 bits of a byte (with wrap) ... lda word ; original byte and #$0f ; retrieve lower nybble tay ; index lda word clc ; might not be needed adc nextinc,y ; could be ora or sbc sta word ... nextinc .byte 1,2,3,4,5,6,7,8 .byte 9,10,11,12,13,14,15,0 Well, funny thing is - maybe I didn't transcribe it properly back in '87 - because it doesn't seem like it would work. Seems like it needs an AND #$F0 after the second LDA word So I thought I'd take a shot at a working version... ... lda word ; original byte and #$0f ; retrieve lower nybble tay ; index lda word clc adc nextinc,y sta word ... nextinc .byte 1,1,1,1,1,1,1,1 .byte 1,1,1,1,1,1,1,-15 who knows if that one works either. ? If someone has the original article from Feb 1987 Dr. Dobbs Journal, I'd be curious to see the code. Also, post your own 6502 Killer Hacks and share them with the rest of us! - David Updated 2017: Just came across the original PDF of the article by Mark S. Ackerman and confirmed that I did transcribe it incorrectly but my fixed version is the same as the published version. http://archive.6502.org/publications/dr_dobbs_journal_selected_articles/6502_hacks.pdf See the following post for a better version of this hack. Edited May 25, 2021 by djmips improvement. 1 Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.