Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Posts posted by rje

  1. You're right.  

    For now, though, I'm seeing what it can do when I stay in BASIC, to serve as a demo of what you can do with BASIC.

    Ah, but I am currently using that tiny interrupt-driven sound library by Dusan.  Even as simple as it is, it's adding a great bit of "color" to the game!



    • Like 1
  2. On 10/11/2021 at 10:14 PM, Scott Robison said:

    With the solution above, I am assuming P is the complete VRAM address from $00000 to $1FFFF. The second line doesn't have to do the "OR INT(P/65536)" part if the address will always be $FFFF or smaller.

    Thanks for that.  Managing the bitfields (and understanding what they do) is the full problem.  It looks to me like I was POKEing above $10000, so the OR is probably needed.


  3. Today I opened up the old "Rogue Forest" game I wrote a year ago, and I thought that this snippet could be sped up:

             if y>8 and y<40 then ff=int(rnd(1)*3)
             vpoke 1,P,fo(ff) :rem character index
             vpoke 1,P+1,cl   :rem bg/fg color nybbles

             if y>8 and y<40 then ff=int(rnd(1)*3)
             vpoke 1,P+2,fo(ff)
             vpoke 1,P+3,cl

             if y>8 and y<40 then ff=int(rnd(1)*3)
             vpoke 1,P+4,fo(ff)
             vpoke 1,P+5,cl

             if y>8 and y<40 then ff=int(rnd(1)*3)
             vpoke 1,P+6,fo(ff)
             vpoke 1,P+7,cl

    P, P+1, P+2, P+3... P+7.  I mean, that sounds like a shoo-in for using the auto-increment with Port 0, for example.

    Anyone think that sounds reasonable?  I THINK I should be able to do something like this:

             vpoke %10000, P, 0 :rem set up autoincrement

             if y>8 and y<40 then ff=int(rnd(1)*3)
             poke $9f23, fo(ff) :rem character index
             poke $9f23,cl   :rem bg/fg color nybbles

             if y>8 and y<40 then ff=int(rnd(1)*3)
             poke $9f23, fo(ff)
             poke $9f23, cl

             if y>8 and y<40 then ff=int(rnd(1)*3)
             poke $9f23, fo(ff)
             poke $9f23, cl

             if y>8 and y<40 then ff=int(rnd(1)*3)
             poke $9f23, fo(ff)
             poke $9f23, cl



  4. On 10/7/2021 at 2:43 PM, maktos said:

    If David knew what the heck he was going to do, 


    I don't know. 


    If you've watched his videos, you know how he works, and this seems to be the way he does it.

    Seems like a hill-climbing algorithm to me.  Certainly is not a top-down style.  If you know what I mean.


    Has 8BG ever given you the impression that he works in the manner you suggest? 

  5. I'm doing something wrong.

    I've got a PET font, and a VIC-20 font, both 2K and apparently representing similar PETSCII sets.

    I can load either one into the X16, like this:

    cbm_k_load(2, 0x0f800);

    So far, so good.

    Now when I load them, lowercase is uppercase, and uppercase are those graphic chars.  

    I solve that by printing the control code to switch cases:

    cbm_k_bsout(14); // to upper+lower case

    HOWEVER, what that does is switch the X16 back to its built-in Commodore 64 PETSCII font.  It does not get me the PET PETSCII (or the VIC-20 PETSCII if I use that binary instead).

    I'm obviously doing something wrong in a simple way.  Can someone tell me what that is?


  6. So reading his webpage a bit, it seems that CPLDs are most useful for all the glue hardware -- logic gates, for instance, that do some address decoding.  He uses a 65816 of course for the CPU. 

    Meanwhile, Frank shows us how FPGAs are suited for the raw capability of processor design, be it graphics, sound, or CPU.

    That leaves RAM, ROM, and I/O.



  7. No, that's reasonable.  I worry about the heap requirements, as well as the size of the codebase -- AWK is not small.

    V7 AWK is here: https://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/awk

    And now it's here: https://github.com/bobbyjim/AWK-7



    My question is: what would you use it for, if it were running on the X16?

    Catting files is useful, but is filtering them also useful?  Splitting records, and displaying columns?  Counting strings?  Selecting records?

  8. My current hack isn't a parser: it only uses sscanf() and strcmp() to detect some basic cases.  As a result, I can catenate a file with the command



    1 'MYFILE


    Note there's no trailing quote. 

    I wanted to use the PETSCII left-arrow, but I can't do that until I use a half decent tokenizer.

  9. Now that I'm thinking about it, I'm also thinking about the reasonable scope for the X16.  These sorts of UNIX-like operations aren't very common on Commodore 8 bit machines.

    I've already found the plain-old catenate pattern useful.  I suspect one that matches a substring and prints the matching line and line number would be useful, so a condition to match a string, and an action for printing NR and the line itself would be nice.  I wonder if vprintf() is as easy as it sounds?


  10. On 9/30/2021 at 1:43 PM, BruceMcF said:

    AFAIR, a bit thing V7 awk did not have was user definable functions.

    It had constant string regular expressions, but couldn't get a regular expression from a variable.

    The differences between the V7 awk and the "One True Awk" is described here.

    Thank you for the link.  I'm reading it now.

    I'm also writing a throw-away thing to do some very careless things in a vaguely AWKlike manner.

    • Like 1
  11. On 9/29/2021 at 12:43 PM, Ju+Te said:

    Whatever language I would use for developing serious software for the X8/16 hardware using a PC (even if it is just assembler) - it would be very cool to have some kind of hardware debugger available that allows me to step through the commands (in the language I use), see all the registers and memory contents. I had a disassembler and debugger on my 8-bit machine - without them I would not have been able to write that much code.

    There's two things for the X16.  First, there's a built-in machine language monitor.  Second, the emulator has a debugger.  Third, there's a rather nicely featured assembly development environment that's .. well I thought it was in Downloads, but perhaps not.

  12. BASIC has three uses:

    1. Small programs that don't require speed.  Classic "business simulation" games from the 1970s.  Some PETSCII games like Lunar Lander.

    --> Ambitious programs like Temple of Apshai can be written, but we're better off doing them in something other than BASIC.

    2. Prototyping, as you mentioned.

    3. Batch scripting.  In other words, as the pseudo shell command interpreter for Commodore machines.


    • Like 1
  13. I'd like to fopen() files in the native filesystem, i.e. not the mounted SD image, while I'm just writing code and testing things out.

    I'm not sure that can be done, though.  Except by using the KERNAL functions I suppose.  Anyone?


  14. As for AWK, I search for "practical examples" instead of tutorials that show me how to do uninteresting things.


    ^ This looks like the generic template for AWK statements.  Note I'm using [brackets] because PETSCII doesn't have {braces}.  No worries.

    First, let's posit that this particular AWK is only for one-liners. No reason to think so, except for simplicity maybe.

    All the settings/field separators etc are fine.



        1 MY_FILE

    Cats the file to the "terminal" (does it pause at the bottom of the screen?)

        'NR>1 && NR < 5' MY_FILE

    Cats lines 2 through 4.  Note that the initial condition, if complex, is in single quotes.

        NF MY_FILE

    Prints lines that have non-space characters on them.  I.E. ignores lines which only have whitespace.

        1  RS=''  file

    Ignores lines that only have the newline character.  Note that the Record Separator assignment is outside of the action, so isn't in brackets.

       '{ print $1, $3}' FS=, OFS=, file

    Prints columns 1 and 3 of every line.  Note the input and output field separators are both the comma.

       'NF { print $1, $3 }' FS=, OFS=, file

    If the line has fields, then print the columns, otherwise ignore the line.



    * * *


    Can we have multi-line scripts, complete with BEGIN and END options?

    I think variables would be no problem, so we could have variable assignment in the action blurbs.

    Associative arrays are, I think, just out of reach, without some shoehorning.  I'd defer that until the rest of it works beautifully.

    The most interesting parts of regular expressions will probably never work here.  Too big.



  15. On 9/29/2021 at 1:40 PM, BruceMcF said:

    AWK on the X16 is the thing most likely to make me learn the ins and outs of CC65. Programming in C is too much like working for a living for me to want to do it on a regular basis, but to get an AWK implemented, I'd make an exception.

    My online friend Alex had written a very very very low C heap manager, for the purpose of implementing a CSH variant on the C64.  I've got his code, but I didn't use it.  I'm having enough trouble writing a compiler down to interpretable bytecode.  

    I attach them here for your amusement.

    heap.c heap.h testcsh.c testcsh.notes

  16. On 9/29/2021 at 2:35 AM, kliepatsch said:


    struct_1 = [12, 13, 14]

    struct_2 = [0, 80, 0, 90, 0, 100]

    data = struct_1 + struct_2 + struct_1 # appending data is as easy as this.

    data_bytes = bytes(data)

    f = open("DATA.BIN","wb") # "wb" stands for write binary




    Hey, that doesn't write bytes to the output channel, it creates a text file containing the Python expression "[12, 13, 14, 0, 80, 0, 90, 0, 10, 0, 12, 13, 14]". The binary file should have 12 bytes in it, since there are 12 byte values in the concatted array. Maybe I'm doing something wrong?


    And, by the way, the Perl version looks very similar, and also creates a text file, although just the digits and not the Python expression.

    @struct_1 = ( 12, 13, 14 );
    @struct_2 = ( 0, 80, 0, 90, 0, 100 );
    @data = (@struct_1, @struct_2, @struct_1);
    open my $fh, ">:raw", "DATA.BIN";
    print $fh @data;
    close $fh;

    To write actual bytes, I still need pack():

    @struct_1 = ( 12, 13, 14 );
    @struct_2 = ( 0, 80, 0, 90, 0, 100 );
    @data = (@struct_1, @struct_2, @struct_1);
    open my $fh, ">:raw", "DATA.BIN";
    print $fh pack "C*", @data;
    close $fh;


    • Like 1
  17. I note that his Python code looks familiar:  if I was writing raw bytes, that's what the Perl code would look like.

    Note that he has to first break down larger numbers, and encode strings into bytes.  He might have to do some custom coding if endianness is a problem.


    ... I want AWK on the X16.




  18. On 9/29/2021 at 4:12 AM, Janne Sirén said:

    The thing is, I believe "hitting hardware" is exactly the appeal of a platform like this. What differentiates it from coding, say, a RasPi. So personally I'd prefer hardware level compatibility between different platform models, not just through an abstraction layer like kernal, as much as possible.

    But each their own of course, just adding my opinion to the poll. 🙂

    Ah, I get your meaning -- that goes to the original intent of the three versions of the X16.  They're all X16s, even though they're built differently.

    (As far as hitting hardware, well, I suppose the original X16e wouldn't hit any of the hardware, per se since all of it is mushed onto something like a single FPGA...)


    I know that 8BG has a soft spot for Commodore, one I understand, so I suspect that it's not just about the hardware, and therefore an ABI for X8 compatibility at least seems a fun and useful idea!

  • Create New...

Important Information

Please review our Terms of Use