Search found 215 matches

by Garth
Thu Jul 13, 2017 3:08 pm
Forum: Newbie Help Center
Topic: Simplify long, repetitive code.
Replies: 39
Views: 20879

Re: Simplify long, repetitive code.

What I presented is really basic stuff, not rocket science. Make the table say, LvlFuncPtrTableLo .byte LOW(LEV01-1), LOW(LEV02-1), LOW(LEV03-1, <etc.> LvlFuncPtrTableHi .byte HIGH(LEV01-1), HIGH(LEV02-1), HIGH(LEV03-1), <etc.> Using the RTS for a jump simplifies things by eliminating the need for a...
by Garth
Wed Jul 12, 2017 8:49 pm
Forum: Newbie Help Center
Topic: Simplify long, repetitive code.
Replies: 39
Views: 20879

Re: Simplify long, repetitive code.

Once again: You don't need to store the indirect address in variable space and use JMP(ind). Put the address on the stack and use the RTS as the jump itself, not just the default return: [...] LDA LvlFuncPtrTableHi,x ; (high byte first) PHA LDA LvlFuncPtrTableLo,x PHA _exit RTS and you'll save 5-7 b...
by Garth
Sat Jul 08, 2017 1:34 pm
Forum: Newbie Help Center
Topic: Simplify long, repetitive code.
Replies: 39
Views: 20879

Re: Simplify long, repetitive code.

Do adjust the table for being 1-based rather than 0-based though. A way to do it without variables is to put the address on the stack and use the RTS as the jump itself, not just the default return: LDA LvlFuncPtrTableHi,x ; (high byte first) PHA LDA LvlFuncPtrTableLo,x PHA _exit RTS and you'll save...
by Garth
Tue Jun 06, 2017 1:51 pm
Forum: General Stuff
Topic: What a good forum for looking for programming help?
Replies: 57
Views: 13007

Re: What a good forum for looking for programming help?

Beginners may want to do things that lofty technologies and decades of accumulated code have produced. Our daughter-in-law has a degree in computer science, and graduated at the top of her class. She's good at html, css, php, sql, and a lot of other stuff that's outside my field (I do have my own ex...
by Garth
Mon Jun 05, 2017 12:18 pm
Forum: Newbie Help Center
Topic: How would I generate random numbers?
Replies: 12
Views: 4118

Re: How would I generate random numbers?

If there's a timer running anywhere in the system, reading its value to use for part of the RNG's operation usually works well since you don't know where it will be in its cycle when the random number is needed.
by Garth
Sun Jun 04, 2017 2:30 pm
Forum: General Stuff
Topic: What a good forum for looking for programming help?
Replies: 57
Views: 13007

Re: What a good forum for looking for programming help?

Tokumaru (who I think is on the 6502.org forum too) I haven't been there in ages, maybe I should drop by to see how things are. I love 6502 programming, but I can't think of many discussions to have about the CPU itself. Wow, your last log-in was Apr 01, 2007, and you only have two posts there. I d...
by Garth
Sun Jun 04, 2017 1:15 pm
Forum: General Stuff
Topic: What a good forum for looking for programming help?
Replies: 57
Views: 13007

Re: What a good forum for looking for programming help?

I am amazed at how much time some of the knowledgeable people on 6502.org's forum will give to others' code to help them figure out their problem. The active members' expertise ranges widely, and several of them are in this professionally and are very knowledgeable, yet patient with newbies. There's...
by Garth
Wed May 31, 2017 12:24 pm
Forum: NESdev
Topic: Koei bytecode
Replies: 44
Views: 36834

Re: Koei bytecode

I've been thinking about something similar for the 65816, but with the "word-code" being a list of addresses to jump to. That of course is what Forth normally does, at least in the indirect-threaded code (ITC) and direct-threaded code (DTC) models. On the 6502.org forum, Bruce Clark prese...
by Garth
Wed May 24, 2017 4:07 pm
Forum: NESdev
Topic: NORTH
Replies: 25
Views: 9804

Re: NORTH

That's true about the stack pointer (extra overhead notwithstanding), but there's at least one more consideration (and maybe more will come to me after I post, LOL). Forth typically has a scratchpad area called N which primitives can use however they like, as long as they are completely done with it...
by Garth
Thu May 11, 2017 12:48 pm
Forum: General Stuff
Topic: There was INX and INY, why no INA?
Replies: 20
Views: 7048

Re: There was INX and INY, why no INA?

The 65c02 does have INA (plus DEA, PHX, PHY, PLX, PLY, STZ, BRA, BIT#, and other goodies). The original 6502 was designed by hand though, and the masks were laid out by hand, similar to designing a PC board without CAD, which I imagine was largely why the things added later in the 65 c 02 didn't mak...
by Garth
Tue May 09, 2017 4:40 pm
Forum: NESdev
Topic: NORTH
Replies: 25
Views: 9804

Re: NORTH

Admittedly I wasn't trying to say very much. It was just a personal observation then when I write assembly, my subroutines rarely nest more than 2 or 3 layers deep. With, FORTH, my subroutine nest much deeper. So maybe that saves bytes, maybe it doesn't. Probably it falls into the "subjective&...
by Garth
Tue May 09, 2017 2:27 am
Forum: NESdev
Topic: NORTH
Replies: 25
Views: 9804

Re: NORTH

Why does "token threading" take the name "threading"? I suppose it's like using a needle to pull a thread through a group of beads, where each "bead" is an instruction. Dr. Brad Rodriguez who's a big name in the field of Forth has an article on five different threading...
by Garth
Mon May 08, 2017 11:52 pm
Forum: NESdev
Topic: NORTH
Replies: 25
Views: 9804

Re: NORTH

rainwarrior, I take it you are addressing multiple people here. My own last post was just giving some background to answer the implied question about why the term "words" is used in Forth. Parts of the Forth approach can be taken even in assembly language though, and you can also cut into ...
by Garth
Mon May 08, 2017 9:57 pm
Forum: NESdev
Topic: NORTH
Replies: 25
Views: 9804

Re: NORTH

For whatever reason, FORTH people like to call subroutines "words" Everything in Forth is a word except the data itself. Even . , @ ! " ( etc. are words, just with very short names since they're used constantly, and there is no real punctuation, nor syntax. For example, a variable ma...
by Garth
Mon May 08, 2017 12:08 pm
Forum: NESdev
Topic: NORTH
Replies: 25
Views: 9804

Re: NORTH

I saw this neat approach to interrupts in forth. Since it's a "real" forth environment, where words are interpreted at runtime, it can just acknowledge the interupt and insert a word to handle the interrupt after the word currently being processed. So the two can use the same stack withou...