Author Topic: Getting started programming?  (Read 4154 times)

MNKyDeth

  • Hero Member
  • *****
  • Posts: 715
Getting started programming?
« on: October 29, 2016, 05:21:52 AM »
So I have been starting to teach myself the 6502 assembly language from http://6502.org/tutorials/

I have went through most of the easy6502 and read a lot of the rest of the stuff there.

I can do basic little dot movements and color changes and seem to know how to use JMP, JSR and RTS. INC, IN.... etc.

So beyond these instructions and manuals where would be the next logical step to progress my learning of how to program for this console?


Edit: Wooops, thought I put this under the  PCE  Tool Game development. If a mod could move it, that would be great.
« Last Edit: October 29, 2016, 05:49:09 AM by MNKyDeth »

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: Getting started programming?
« Reply #1 on: October 29, 2016, 06:09:45 AM »
Congratulations on taking the step to learn 6502/6280 programming.  8)

It's not the easiest path, but you'll find that it'll completely open up the PCE's maximum performance for you, and you'll never look your PC/iPhone/RaspberryPI in quite the same way ever again.  :wink:

Do you know any other programming languages, or is this your first?

<EDIT>

One good thing to do (IMHO) would be to read more of the pages linked to from 6502.org, especially Garth Wilson's site that has a dumper-truck full of useful info/advice for 6502 programming http://wilsonminesco.com/links.html

You don't have to read-and-understand it all ... it's just a bunch of stuff that you can skim through to get immersed in how the 6502 is used in practice. Then you can keep on going back there later on as you learn more, to see specific techniques in use and learn new ones.

His page(s) on 6502 Stacks will probably introduce you to a whole bunch of useful info that you may not have seen yet.
« Last Edit: October 29, 2016, 06:33:34 AM by elmer »

MNKyDeth

  • Hero Member
  • *****
  • Posts: 715
Re: Getting started programming?
« Reply #2 on: October 29, 2016, 07:37:52 AM »
Mostly what I have done is a little experimenting with some of the branches. I wrote a little endless loop that would cycle through the colors on the 4 or 5 memory areas the little windows provided me.

It would just increment the color by one, compare that color value and once it reached a certain value it would then cycle to the next part of the loop. Once it got to the end it would JMP back to the top and start all over again.

So I havn't done much but I can see how some of the stuff was and some of the confusing stuff of why certain things either worked or didn't.

This is this first programming language I have messed with for this long. I have been poking around at it for about the past month.

I have messed with ruby, perl, python and such but never got past hello world. The only thing I can do any scripting with right now is BASH on Linux.

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: Getting started programming?
« Reply #3 on: October 29, 2016, 09:11:32 AM »
This is this first programming language I have messed with for this long. I have been poking around at it for about the past month.


OK, that's not a problem at all, but I'm going to suggest that you take a little step backwards for a few weeks before getting back into 6502/6280 assembly language on the PCE.

Assembly language is absolutely great for creating fast programs, but the reason that it's not used much any more is that it's a very verbose, often hard-to-read, and fairly slow-to-write language.

The incredible power that is gives you comes at the cost of having to manually take care of all of the tiny details of a program.

I'm not suggesting that you ditch the idea of programming in it ... far from it. But I am suggesting that you *start* by tackling the problem from a different perspective.

My advice to you would be to read this thread ...
    
Learn to code through a series of challenges?
http://www.pcenginefx.com/forums/index.php?topic=21498.0

... and then set yourself the task of writing that simple dots-on-the-screen Pong game in a high-level-language first.

You could either do it in PlayBasic like technozombie did, or do it in HuC if you really want to stick with the PCE.

You'll learn a lot of the basics of breaking down a task into some simple program steps, and you'll have the satisfaction of having something working that is your own code that you understand and can build on.

I'd recommend PlayBasic more than HuC at this point, because you'll have a decent debugger to use to see what's going wrong (and you will make a lot of errors, we all do).

You'd also have technozombie's version to look at for a comparison (AFTER you're done!).

If you do that, then you can take your simple Pong program, and figure out how to implement it in 6502 on the PCE.

The point is ... if you do it that way, you'll already have something that you understand to use as a template for your 6502 code.

For a fairly-novice programmer, it can be off-putting to start with the totally-blank-space that assembly language provides you, and know just where to start.

You might even take a middle step, and translate it from PlayBasic, to Huc, to 6502.

There are some good arguments for doing that.

johnnykonami

  • Hero Member
  • *****
  • Posts: 1350
Re: Getting started programming?
« Reply #4 on: October 29, 2016, 09:58:07 AM »
And please, don't forget to ASSBANK where you should have ASSCHUNK'D.

MNKyDeth

  • Hero Member
  • *****
  • Posts: 715
Re: Getting started programming?
« Reply #5 on: October 29, 2016, 03:33:02 PM »
lol

Well, I started with the 6502 mostly because I do have a hard time sticking with a language. My spare time right now is filled with repairing these consoles and learning Russian.

I learn the programming in my free time at work. So it is fairly sporadic when I can sit down and concentrate on it but I really wanted to get into something with programming even if it is not extremely useful today.

These systems hold my interest far more than Java does so learning 6502 seemed logical.

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: Getting started programming?
« Reply #6 on: October 29, 2016, 05:24:17 PM »
Well, I started with the 6502 mostly because I do have a hard time sticking with a language. My spare time right now is filled with repairing these consoles and learning Russian.
...
These systems hold my interest far more than Java does so learning 6502 seemed logical.

The thing is ... these systems are basically blank when you turn them on.

You've got to understand the hardware, and know what you want to write.

They're not really something like an old C64 or Atari 800 BASIC environment where it's easy to "play around".
 
OK, if you want to dive in ... here's my cut down SCD template that I wrote to get some idea of how much of HuC and the Super CDROM BIOS I could easily disable and get around.

It's not documented, it's not overly efficient, and it's not self-contained (it still uses a couple of BIOS functions).

But it's the simplest PCE assembly language "Hello, World!" source code that I have to hand.

https://www.dropbox.com/s/pqaw0cptdfqk7kn/template_scd.zip?dl=0

Run "build.cmd" to assemble the source into a PCE ISO file, and then run "run.cmd" to run the ISO in Mednafen (if you've got Mednafen set up in the directory above).

To make any sense out of it all, you're going to need the PCE CD programming documentation from bonknut's site, and also the regular PCE hardware documentation (or Charles MacDonald's pcetech.txt file).

P.S. If you don't want to go blind trying to read Mednafen's default debugging font, you should download the build that I modified to use a larger font.

https://www.dropbox.com/s/6rpkviyhgihw4gt/mednafen-0.9.38.7-x86-elmer-2.zip?dl=0

There's a link to that file in another one of the threads somewhere, and I really do need to build a new one sometime soon with all of Rypheca's latest changes (like Saturn support).

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Getting started programming?
« Reply #7 on: October 29, 2016, 07:31:56 PM »
Here's an old tutorial set I was working on back in '08:
http://www.pcedev.net/tuts/chapter_0.txt
http://www.pcedev.net/tuts/chapter_1.txt
http://www.pcedev.net/tuts/chapter_2.txt
http://www.pcedev.net/tuts/chapter_3.txt

 Has some stuff in there specific to PCEAS. Note: There's a typo that says 1023 cycles for the TIMER, but it's actually 1024 cycles.

 And here's two skeleton examples that were supposed to go with it (can't find the rest):
http://www.pcedev.net/tuts/example_1.zip
http://www.pcedev.net/tuts/example_2.zip


 Ohh! These cribsheets should come in handy (they are made for printing out on high res paper and put in a plastic protector; quick access at hand):
http://www.pcedev.net/blog/files/Otaku_no_PCE_cribsheet_page1_v1_0_3.png
http://www.pcedev.net/blog/files/Otaku_no_PCE_cribsheet_page2_0_1_4.png
« Last Edit: October 29, 2016, 07:36:50 PM by Bonknuts »

ccovell

  • Hero Member
  • *****
  • Posts: 2245
Re: Getting started programming?
« Reply #8 on: October 30, 2016, 01:44:46 AM »
Great written tutorials!  I was actually winding up to make some PCE ASM tutorial videos for YouTube, since there seems to be nothing out there, and you already covered the basics in those text files!

The main thing that has held me back from starting with the basics is the dilemma of recommending either an old MagicKit since the library portion is still "small" and easy for a beginner to grok, or stay contemporary and use the PCEAS in the latest Artemio/Elmer build of HuC.
The latter appears to make at least 4 banks just for library routines, even just for ASM-only projects!

So, I'm leaning towards the former.  Anyone have any advice?  Or, are textfile tutorials good enough?

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Getting started programming?
« Reply #9 on: October 30, 2016, 06:05:19 AM »
Would you be talking in the videos? The reason I ask, is not everyone learns the same way. Sometimes people need to hear someone explain it (visual and auditory), besides having the written explanations. For something like this, there's a steep learning curve in the immediate beginning because all the things involved (cpu, assembler itself, tools, video, audio, etc). It's calming to hear someone explain it in a lecture/tutorial style presentation, and helps with the anxiety and frustration of starting out.

elmer

  • Hero Member
  • *****
  • Posts: 2148
Re: Getting started programming?
« Reply #10 on: October 30, 2016, 07:22:01 AM »
Great written tutorials!

I agree, those are brilliant starting points! Thanks Bonknuts!  :D


So, I'm leaning towards the former.  Anyone have any advice?  Or, are textfile tutorials good enough?

IMHO, different tutorial examples should always be single source files that get more and more complex as the different concepts are introduced.

But there's an argument to be made for have 2 source files ... one for new code, and one for the code that you're building on.

I really don't think that there should be any use of library functions in assembly language tutorials.

IMHO, the whole point is to learn how to accomplish things yourself, and not just rely on some huge bank of hidden library functions.

I'm using Bonknuts's version of pceas, and that one doesn't seem to be including any library files/functions into the final ISO image ... an ISO, since I'm more interested in a minimal SCD template, rather than a minimal HuCard template.


Would you be talking in the videos?
...
For something like this, there's a steep learning curve in the immediate beginning because all the things involved (cpu, assembler itself, tools, video, audio, etc). It's calming to hear someone explain it in a lecture/tutorial style presentation, and helps with the anxiety and frustration of starting out.

It's a very steep curve for someone with no programming experience! There are so many new concepts to learn all at once.

I'd agree that a few good videos, with a friendly and calming voice, would be help immensely.

At least to cover the initial steps of getting set up, building the code, running it in Mednafen and then using the debugger.

One or two videos of the first few tutorial examples would help out, too.

I don't think that you'd need to explain what a CPU is, or how it works ... there are plenty of existing videos for that to link to.

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Getting started programming?
« Reply #11 on: October 30, 2016, 07:45:59 AM »
Just to note: I didn't proof read any of these tutorial chapters. I'm sure there are affect/effect, where/were, and other grammatical mistakes - you'll just have to bare with it. Those chapters are basically just a stream of consciousness on the topic, with some attempt at ordering. They aren't meant for someone that has zero experience in assembly. At least some novice experience is required, even just the bare basics. But regardless of that, I've always found docs and tutorials to be helpful, even if redundant, because you'll reach that level at some point and it'll make more sense then.  (Note: it's weird to see my writing style from 8 years ago).


 A tutorial on using the mednafen debugger would be very valuable too. People tend to shy away from debuggers for some reason. But to me, they are immensely helpful in tracking down bugs. I even use it in my Java class to fix things like complex reference bugs (advance linkedlist stuffs). Too bad the instructors don't want to teach the students on how to use it - they say wait until later classes to learn how to use it. Meh. It's a valuable tool and should be learned how to be used early on.
« Last Edit: October 30, 2016, 07:53:20 AM by Bonknuts »

Bonknuts

  • Hero Member
  • *****
  • Posts: 3292
Re: Getting started programming?
« Reply #12 on: October 30, 2016, 08:00:38 AM »
IMHO, the whole point is to learn how to accomplish things yourself, and not just rely on some huge bank of hidden library functions.

 I know there are two camps when it comes to this, but I totally agree. Especially for someone learning a system like this; having in-depth knowledge really is the key to working system on a low level. If you rely on fancy libraries, when starting out, you'll never really get the feel of things. Re-inventing the wheel, gives you intimate knowledge and experience of how the wheel works - vs someone who's only ever borrowed the wheel for whatever purpose. In higher level system development, that probably doesn't matter so much. But for the goal here, working with assembly, and limited resources (cpu, ram, etc), I think it's a must have strength.

ccovell

  • Hero Member
  • *****
  • Posts: 2245
Re: Getting started programming?
« Reply #13 on: October 30, 2016, 01:26:18 PM »
Yes, I would be talking in the video, no guarantees about calm or soothing-sounding voices.  I would start by talking about how the PCE works internally, using games as examples (in Mednafen) to show how RAM & VRAM are arranged & used, etc.

The idea of my tutorials is to get a person writing demos & the basic skeleton of a game, so I'm more leaning towards starting out with the early (<8k in $E000-) MKit library and stripping it even more (perhaps even in-video) & rebuild it like a hotrod.  :)

Necromancer

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 21335
Re: Getting started programming?
« Reply #14 on: October 31, 2016, 02:13:23 AM »
Edit: Wooops, thought I put this under the  PCE  Tool Game development. If a mod could move it, that would be great.

Done.

Good luck with the learnenings.
U.S. Collection: 97% complete    155/159 titles