peek(197) & more
Moderator: Moderators
peek(197) & more
Hi there!
I'm well on my way to coding my first vic 20 game. Currently I'm writing the framework in basic (nearly done) before trying to move over to assembly so I can begin saving space and detailing out the game experience with more detail, sound and graphics. I'm aiming for unexpanded if I can.
I read the Butterfield Machine Language book, and now reading Mastering the Vic 20. I'll probably have loads of questions along the line so looking forward to getting to know you guys in this awesome little community!
For the moment, I have two questions to keep me going:
I'm retrieving the keycode by peek(197) and it looks like I'm getting:
1: 0
2: 56
3: 1
4: 57
5: 2
6: 58
etc..
i'm using cbm studio.. its kinda annoying having to remap each result.
is this normal? it doesnt seem so in some books and I've been looking for keycode mappers online but can't find one that confirms this?
also another random question: is there a way of shifting the CBM key in the vice emulator?
I'm also considering learning some C so I can use the 6502 compiler. Is this worth it or should I just stick to assembly in CMB prg?
Thanks!!!!
(windows)
I'm well on my way to coding my first vic 20 game. Currently I'm writing the framework in basic (nearly done) before trying to move over to assembly so I can begin saving space and detailing out the game experience with more detail, sound and graphics. I'm aiming for unexpanded if I can.
I read the Butterfield Machine Language book, and now reading Mastering the Vic 20. I'll probably have loads of questions along the line so looking forward to getting to know you guys in this awesome little community!
For the moment, I have two questions to keep me going:
I'm retrieving the keycode by peek(197) and it looks like I'm getting:
1: 0
2: 56
3: 1
4: 57
5: 2
6: 58
etc..
i'm using cbm studio.. its kinda annoying having to remap each result.
is this normal? it doesnt seem so in some books and I've been looking for keycode mappers online but can't find one that confirms this?
also another random question: is there a way of shifting the CBM key in the vice emulator?
I'm also considering learning some C so I can use the 6502 compiler. Is this worth it or should I just stick to assembly in CMB prg?
Thanks!!!!
(windows)
- eslapion
- ultimate expander
- Posts: 5037
- Joined: Fri Jun 23, 2006 7:50 pm
- Location: Canada
- Occupation: 8bit addict
Re: peek(197) & more
Remap?edinky wrote:I'm retrieving the keycode by peek(197) and it looks like I'm getting:
1: 0
2: 56
3: 1
4: 57
5: 2
6: 58
etc..
i'm using cbm studio.. its kinda annoying having to remap each result.
What you listed there matches exactly what's on page 179 of the VIC-20 Programmer's reference guide.
There's no remap...
Be normal.
Re: peek(197) & more
while C _can_ be useful on small platforms like vic20, they are really a bad platform for _learning_ C. dont do that - use a C-compiler on your PC. also to use C effectively on such small platforms, you really need to have a good understanding of the platform itself, the constraints and limits of the compiler, and how to decide what things should go into custom assembly functions and what can be kept in C code.I'm also considering learning some C so I can use the 6502 compiler. Is this worth it or should I just stick to assembly in CMB prg?
ie: for a start - learn assembly, you will need it
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
Re: peek(197) & more
I think learning C is useful exercise in itself and a much nicer and more readable language than BASIC and more powerful - I wrote tank battalion in C and Misfit's games also are written in it. C will also be a good foundation for most other modern languages such as Javascript or c#.
Learning the basics of C outside of the Vic is probably a good idea but I don't see why you would necessarily need to learn assembly first. 6502 can be very tedious and take a long time to see meaningful results with plenty of head scratching.
Also see this post as a possible jump-start to producing fairly high end games on the Vic with a minimum of effort.
Learning the basics of C outside of the Vic is probably a good idea but I don't see why you would necessarily need to learn assembly first. 6502 can be very tedious and take a long time to see meaningful results with plenty of head scratching.
Also see this post as a possible jump-start to producing fairly high end games on the Vic with a minimum of effort.
Re: peek(197) & more
hah ok will have to put that on my reading list so! thanks!eslapion wrote:Remap?edinky wrote:I'm retrieving the keycode by peek(197) and it looks like I'm getting:
1: 0
2: 56
3: 1
4: 57
5: 2
6: 58
etc..
i'm using cbm studio.. its kinda annoying having to remap each result.
What you listed there matches exactly what's on page 179 of the VIC-20 Programmer's reference guide.
There's no remap...
Re: peek(197) & more
thanks for the advice guys. i work with c#, also learning c++ at the moment. didnt mean to but looks like i'm learning backwards chronologically!beamrider wrote:I think learning C is useful exercise in itself and a much nicer and more readable language than BASIC and more powerful - I wrote tank battalion in C and Misfit's games also are written in it. C will also be a good foundation for most other modern languages such as Javascript or c#.
Learning the basics of C outside of the Vic is probably a good idea but I don't see why you would necessarily need to learn assembly first. 6502 can be very tedious and take a long time to see meaningful results with plenty of head scratching.
Also see this post as a possible jump-start to producing fairly high end games on the Vic with a minimum of effort.
Re: peek(197) & more
Well, some people don't like machine language, but if you are really up to the task of learning the most efficient way of making code for a computer with only 5KiB, assembly is certainly the way to go. C++ has too much overhead for my taste, so a RAM expansion will be needed for (most) programs.edinky wrote:thanks for the advice guys. i work with c#, also learning c++ at the moment. didnt mean to but looks like i'm learning backwards chronologically!beamrider wrote:I think learning C is useful exercise in itself and a much nicer and more readable language than BASIC and more powerful - I wrote tank battalion in C and Misfit's games also are written in it. C will also be a good foundation for most other modern languages such as Javascript or c#.
Learning the basics of C outside of the Vic is probably a good idea but I don't see why you would necessarily need to learn assembly first. 6502 can be very tedious and take a long time to see meaningful results with plenty of head scratching.
Also see this post as a possible jump-start to producing fairly high end games on the Vic with a minimum of effort.
I used C++ and other object oriented languages at the university. They are nice to make larger programs, but if you are really at scratch, I would start with small assembly routines and integrated them into your basic program.
A really good programming environment is CBM programming studio, which can be found here: http://sleepingelephant.com/ipw-web/bul ... =14&t=5019
If you want to see what can be achieved with assembly, check out my small mouse pointer and driver for the unexpanded Vic-20.
Re: peek(197) & more
Obviously machine code is best but if you are results focused rather than an efficiency zealot, then C especially with a sprite library and memory expansion will get you comparable(ish) results much faster. I'd say it takes about 5+ times more development time in assembly compared to C. Also the code is much more readable and maintainable than either BASIC or 6502. C++ is a different matter, I don't even think there is a compiler for the Vic.
Re: peek(197) & more
https://github.com/puppeh/gcc-6502beamrider wrote:Obviously machine code is best but if you are results focused rather than an efficiency zealot, then C especially with a sprite library and memory expansion will get you comparable(ish) results much faster. I'd say it takes about 5+ times more development time in assembly compared to C. Also the code is much more readable and maintainable than either BASIC or 6502. C++ is a different matter, I don't even think there is a compiler for the Vic.
Re: peek(197) & more
see: http://www.6502.org/tools/lang/Kakemoms wrote: https://github.com/puppeh/gcc-6502
"A port of the Gnu Compiler Collection to the 6502 processor family, also including the semi65x command line 6502 simulator. See also this support project. Described as a work in progress and not yet free of bugs."
Re: peek(197) & more
to use that gcc port you'll *really* have to know what you are doing, including how to spot (and circumvent) the many compiler bugs
with cc65 on the other hand... it produces not so great code, especially not if you dont know what to take care of. it'd be challenging to make anything non trivial with it that works on a stock vic20.
with cc65 on the other hand... it produces not so great code, especially not if you dont know what to take care of. it'd be challenging to make anything non trivial with it that works on a stock vic20.
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
-
- Vic 20 Hobbyist
- Posts: 128
- Joined: Sun Dec 26, 2010 1:51 pm
Re: peek(197) & more
The number you get from the poke 0-64 (64 being no key pressed) you put in either x or y regs and use lda $ec5e,x (unshifted decode table) to convert to PETSCII. The quirky numbers are a result of how the keyboard is wired. Remember it's PETSCII that is returned, not screen codes, so it is expected that the kernal will also print it, as opposed to you just poking it to the screen.
But in BASIC just use GET.
You detect shift and C= yourself (too lazy to keep looking at manuals, it's some other ZP location) then use the tables 64 or 128 bytes past that first table, respectively.
But in BASIC just use GET.
You detect shift and C= yourself (too lazy to keep looking at manuals, it's some other ZP location) then use the tables 64 or 128 bytes past that first table, respectively.